Skip to content

feat(zai): add z.ai provider with OpenAI-compatible coding endpoint#1040

Open
Vasilev Dmitrii (gHashTag) wants to merge 73 commits into
browseros-ai:mainfrom
gHashTag:feat/zai-provider
Open

feat(zai): add z.ai provider with OpenAI-compatible coding endpoint#1040
Vasilev Dmitrii (gHashTag) wants to merge 73 commits into
browseros-ai:mainfrom
gHashTag:feat/zai-provider

Conversation

@gHashTag
Copy link
Copy Markdown

Summary

Adds support for z.ai (Zhipu AI) as a new LLM provider in BrowserOS. z.ai provides an OpenAI-compatible API for coding models including glm-4.6, glm-4.5, and glm-4.5-air.

Changes

Core Integration

  • Shared schemas (packages/shared/src/schemas/llm.ts): Added ZAI to LLM_PROVIDERS enum
  • External URLs (packages/shared/src/constants/urls.ts): Added ZAI_API endpoint (https://api.z.ai/api/coding/paas/v4)
  • Server provider factory (apps/server/src/lib/clients/llm/provider.ts): createZaiModel via OpenAI-compatible client
  • Agent provider factory (apps/server/src/agent/provider-factory.ts): createZaiFactory for agent runtime

UI Integration

  • Provider templates (lib/llm-providers/providerTemplates.ts): z.ai template with default model glm-4.6, 200K context window, image support
  • Provider types (lib/llm-providers/types.ts): Added 'zai' to ProviderType union
  • Provider icons (lib/llm-providers/providerIcons.tsx): Maps zai to @lobehub/icons ZAI icon
  • OpenClaw map (entrypoints/app/agents/openclaw-supported-providers.ts): z.ai registered as supported provider
  • New provider dialog (entrypoints/app/ai-settings/NewProviderDialog.tsx): z.ai available in manual provider setup

Models & Data

  • models-dev-data.json: Added z-ai provider key with models:
    • glm-4.6 (default)
    • glm-4.5
    • glm-4.5-air
  • providerTemplates.ts: Maps provider id zai → models-dev key z-ai

Dev Fixes

  • helpers.ts: VITE_BROWSEROS_SERVER_PORT fallback for getMcpPort
  • background/index.ts: Removed sidePanel.setOptions({enabled:false}) blocking dev sidepanel
  • web-ext.config.ts: Removed --disable-browseros-extensions flag
  • ProviderTemplatesSection.tsx: Added safeguard to ensure z.ai always appears in Quick provider templates

Testing

  • Production build succeeds (bun run build)
  • zai strings confirmed in output chunks (12 occurrences)
  • Provider template hotfix verified in minified output

Screenshots

N/A — UI visible in AI Settings → Quick provider templates

Checklist

  • Code follows project conventions
  • No breaking changes to existing providers
  • All provider types updated (server + agent + UI)
  • Models dev data includes z.ai models

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 23, 2026

PR author is not in the allowed authors list.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2026

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement.

To sign the CLA, please add a comment to this PR with the following text:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once. After signing, this check will pass automatically.


Troubleshooting
  • Already signed but still failing? Comment recheck to trigger a re-verification.
  • Signed with a different email? Make sure your commit email matches your GitHub account email, or add your commit email to your GitHub account.
- - - I have read the CLA Document and I hereby sign the CLA - - - **1** out of **2** committers have signed the CLA.
✅ (gHashTag)[https://github.com/gHashTag]
Dmitrii Calzago (@dmitrii) Vasilev
**Dmitrii Vasilev** seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please [add the email address used for this commit to your account](https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/#commits-are-not-linked-to-any-user).
You can retrigger this bot by commenting **recheck** in this Pull Request. Posted by the **CLA Assistant Lite bot**.

- Add ZAI to shared schemas/constants (https://api.z.ai/api/coding/paas/v4)
- Server provider factory: createZaiModel via OpenAI-compatible client
- Agent provider factory: createZaiFactory for agent runtime
- UI templates: z.ai in provider templates, icons, types, openclaw map
- Models dev data: glm-4.6, glm-4.5, glm-4.5-air
- Dev fixes:
  - helpers.ts: VITE_BROWSEROS_SERVER_PORT fallback for getMcpPort
  - providerTemplates.ts: map provider id 'zai' -> models-dev key 'z-ai'
  - background: remove sidePanel.setOptions({enabled:false}) blocking dev
  - web-ext.config.ts: remove --disable-browseros-extensions flag
@gHashTag
Copy link
Copy Markdown
Author

recheck

@gHashTag
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Dmitrii Vasilev and others added 24 commits May 24, 2026 17:08
- Add TriosRagClient with stdio MCP, circuit breaker, health checks
- Register 5 RAG tools: search_chapters, get_chapter, list_chapters,
  forbidden_audit, get_claim_status
- Update BridgeConfig with --rag-cli and DATABASE_URL support
- Wire RAG into index.ts with health checks, Observatory, graceful shutdown
- Update PM2 ecosystem with TRIONS_RAG_CLI and DATABASE_URL
- Test: 80 chapters loaded from Railway PostgreSQL, latency 1–4ms
- Update INTEGRATION.md with RAG architecture and War Games results

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ms, get_honest_counters, preview_chapter_update, backup_ssot

- Proxy 7 additional trios-mcp-rag tools through bridge
- All PDF/book tools default to dry-run for SSOT safety
- backup_ssot requires confirm=true (returns SQL otherwise)
- Test: get_honest_counters returns 1,762 theorems / 5 Admitted / 14 refutations
- Update INTEGRATION.md with PhD War Games result

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add RailwayMcpClient with HTTP Streamable transport
- Resilience: 3-attempt retry, circuit breaker, 30s health checks
- Expose 4 tools: railway_redeploy, railway_logs, railway_list_services, railway_status
- Update BridgeConfig with railwayMcpUrl, loadConfig reads RAILWAY_MCP_URL
- Add Railway to /health/detailed observatory endpoint
- Update INTEGRATION.md with Railway MCP architecture docs
- Update PM2 ecosystem with RAILWAY_MCP_URL env

Closes the full loop: Vision → Git → RAG → Deploy.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Discovery against trios-railway-mcp-production.up.railway.app revealed
actual tool names differed from assumed names:
- railway_service_redeploy (was: redeploy)
- railway_service_list     (was: list_services)
- railway_service_deploy   (new — replaces railway_logs)
- fleet_health             (new — replaces railway_status)

Updates:
- railway-client.ts: map all methods to correct upstream tool names
- bridge-server.ts: update tool schemas (project, environment params)
- INTEGRATION.md: document correct exposed tools

Verified: list_services returns 32 IGLA services;
fleet_health shows 152 services across 8 accounts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add trios-mcp-github stdio MCP server with 12 tools:
  github_repo_info, github_read_file, github_list_files,
  github_list_issues, github_create_issue, github_create_pr,
  github_list_commits, github_search_code, github_list_branches,
  github_get_workflow_status, github_add_comment, github_list_pulls
- Add GitHubMcpClient with stdio transport, retry, circuit breaker
- Update BridgeConfig with githubCliPath, loadConfig reads TRIOS_GITHUB_CLI
- Register all 12 GitHub tools in bridge-server.ts via proxy helper
- Update /health/detailed observatory with github latency + circuit state
- Update INTEGRATION.md with GitHub MCP architecture docs
- PM2 ecosystem: TRIOS_GITHUB_CLI env var for production

Full loop CLOSED: Vision → Git → RAG → Code (GitHub) → Deploy (Railway)

Known issue: GH_TOKEN env var contains expired token.
Workaround: unset GH_TOKEN or renew via gh auth login.
Keyring token works when GH_TOKEN is not set.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add scripts/test-github-e2e.ts for 7-test GitHub bridge validation
- Revert githubCliPath default to trios-mcp-github (remove stray src/github-server.ts)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add PgAgentStore with PostgreSQL backend for A2A agent cards
- Create agents table + agent_matrix view with seconds_since_heartbeat
- Hybrid storage: PG persistence + in-memory message queuing / SSE
- Add /a2a/matrix endpoint with IGLA canon metadata
- Update server.ts to pass DATABASE_URL to A2aRegistryService
- Add pg + @types/pg dependencies

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- feat: Clean Capture Mode (setCleanCaptureMode) — disables .darkAqua vibrancy before screenshot capture
- feat: env vars for LLM config (TRIOS_PROVIDER, TRIOS_MODEL, TRIOS_BASE_URL)
- feat: env vars for paths (TRIOS_BUN_PATH, TRIOS_TAILSCALE_PATH)
- fix: replace grok* design system colors with standard SwiftUI (22 files)
- build: clean swiftc compilation

Closes browseros-ai#304
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add convenient alias names for filesystem tools:
- fs_read (alias for filesystem_read)
- fs_write (alias for filesystem_write)
- fs_list (alias for filesystem_ls)
- shell_execute (alias for filesystem_bash)
- fs_edit (alias for filesystem_edit)

These aliases make the BrowserOS MCP server more compatible with
external agents that expect shorter conventional tool names.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add TriosTabView with 4 tabs: Chat, GitHub, GitButler, Terminal
- GitHub integration: GitHubAPIClient, GitHubDashboardView, models
- GitButler integration: GitButlerViewModel, GitButlerPanelView, models
- Terminal: TerminalTabView with zsh shell execution
- Update main.swift to use TriosTabView
- Add build.sh for swiftc compilation
- Fix GlassmorphismBackground, MessageBubbleView, TriosTheme
- BrowserOS MCP server: add fs_read, fs_write, shell_execute aliases
- Update @hono/mcp to 0.3.0 to fix 500 error

Build: 33 Swift files compiled successfully via build.sh
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
 #1)

- queen-browseros.md: BrowserOS Agent for Trinity A2A
- skills: tri, doctor, god-mode, bridge
- cron-queen.sh: 15-min autonomous lifecycle
- launchd: com.trinity.queen-cron running
- .trinity/experience.md: knowledge base
- Full MCP access: fs_read, fs_write, shell_execute
- Add cronStatus @published property to ChatViewModel
- Add checkCronStatus() that reads .trinity/state/last_wake.json
- Timer every 30s for auto-refresh
- Show 👑 🟢/🔴/⚪ indicator in ChatPanelView header
- Update ChatProtocols for status display

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 26 new agents (A-Z) in .claude/agents/ — Trinity-compliant stubs
- Full agents: queen-bridge, queen-swift, queen-reviewer, tri-doctor
- AGENTS.md: 27-agent register table with letters, roles, layers
- graph_v2.json: module dependency graph for trios (nodes, edges, layers)
- .trinity/SOUL.md: canonical law for Queen BrowserOS
- Updated skills: tri, doctor, god-mode — Trinity compliance
- Removed legacy: .claude/cron-queen.sh, queen-runner.sh, queen-status.sh
- .gitignore: exclude .trinity logs/state, build artifacts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Dmitrii Vasilev and others added 30 commits May 30, 2026 11:58
- clade-worktree: add ensure/reset commands, auto-sync .claude artifacts,
  sync with upstream, verify build before Canary use
- clade-promote: boot_probe now kills old Sovereign, starts new binary,
  waits 30s for health, auto-rollback on failure
- clade-improve: call worktree ensure before sandbox; add differential
  test (clade-diff) as test browseros-ai#6; real cargo test/build/swiftc tests
- clade-monitor: exponential backoff + file-exists guard (P0 carryover)
- clade-diff: skeleton for Sovereign-vs-Canary regression detection
- Staging worktree fast-forwarded to HEAD and verified clean

Closes: fake tests, missing worktree sync, manual boot probe
First function of clade-audit (RUST-12).
Runs swiftc -typecheck on main.swift + rings/SR-*/ + BR-OUTPUT/*.swift,
then cargo check --workspace. Returns structured BuildCheckResult.

Cargo.toml updated with walkdir + regex deps for upcoming checks.
Workspace Cargo.toml now includes rings/RUST-12/clade-audit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Scans all .swift, .rs, .sh files for:
- rm -rf /, curl | sh (critical)
- try!, as!, hardcoded api_key/token (warning)
- NSLog/print leaking secrets

Returns structured SecurityCheckResult with file/line fingerprints.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Scans .swift files for Process() + zsh -c without explicit allowlist.
Flags violations of SOUL.md Article IX §9.2.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Scans .swift and .rs for force unwraps and bare try! macros.
Flags unsafe patterns with line-accurate fingerprints.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Detects strong self capture in Timer, DispatchQueue, and Task closures.
Flags missing [weak self] patterns with file/line fingerprints.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Scans .swift, .rs, .md for TODO/FIXME/HACK/XXX/BUG/WARN.
Categorizes severity: FIXME/BUG=critical, TODO/HACK=warning.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Detects private Swift func and non-pub Rust fn with zero references
within the same file. Info severity — heuristic, not definitive.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Detects strong self capture in Combine sink, assign(to:on:),
DispatchQueue asyncAfter, and URLSession closures.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Walks rings/RUST-*, rings/SR-*, .claude/skills/, .claude/agents/
to produce .trinity/self-awareness.json with component inventory.
Subcommand: cargo run --bin clade-audit -- generate-awareness [--dry-run]

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ation

POST /repos/gHashTag/{repo}/issues with JSON payload.
Returns decoded GitHubIssue on success.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Models for PR creation response parsing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
createPR(repo:title:body:head:base:) — POST /pulls, returns GitHubPullRequest.
addComment(repo:issueNumber:body:) — POST /issues/{n}/comments, returns GitHubComment.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reads .trinity/audit/*.json and .trinity/state/safety_budget.json.
Publishes score, openIssues, lastAuditAgo, safetyBudget, lastCritique.
Keeps rolling auditHistory window of last 10 records.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Shows score gauge, open issues, safety budget, last critique,
pending PRs, and action buttons (Run Audit, Awareness).
Inserted between healthGrid and skillsSection.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
New ring RUST-14/clade-tablecloth. Loads safety budget from
.trinity/state/safety_budget.json. If halted or budget <= 0,
logs loop_halted_budget and exits immediately.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…e graph

run_audit() spawns clade-audit --json and parses structured report.
update_awareness() spawns clade-audit generate-awareness.
Both log outcomes to event_log.jsonl.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…-fix

create_issues() creates GitHub issues for critical/warning findings
via reqwest blocking POST, deduplicated by fingerprint.
attempt_fix() creates branch, applies try!→try? regex, runs swiftc
subset check, commits/pushes on pass, discards on fail.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Writes structured ImprovementReport to .trinity/state/last_improvement.json
including budget, issues created, fixes attempted/passed, and mode.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Spawns clade-tablecloth every 60 minutes with safety budget gate.
If budget halted or <= 0, logs tablecloth_halted and skips.
Backoff multiplier on consecutive failures.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add .claude/scheduled_tasks.* to root .gitignore
- Add target/, Cargo.lock, .worktrees/, .trinity/snapshots/,
  .trinity/experience/, .trinity/clades/, .trinity/state/,
  lefthook.yml, trios.app/ to trios/.gitignore

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add create_pr() using reqwest blocking POST to /pulls
- Extend attempt_fix() return type to (attempted, passed, prs_created)
- Link PR to original finding via title + body referencing file/line/severity
- Pass prs_created count through to write_report() and summary output

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Replace runAsync() shell sink with execDirect() using direct Process
  calls — no more zsh -c with string interpolation
- Add [weak self] to all 10 DispatchQueue.main.asyncAfter closures
  fixing retain cycles in QueenStatusViewModel
- Add allowlist validation to startAgent(), stopAgent(), runSkill()
- Replace shell-interpolated git commands in GitButlerViewModel with
  parameterized runGit() calls
- Replace shell glob in loadVirtualBranches with FileManager
- Add command allowlist + dangerous pattern filter to runCommand()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add dangerous shell pattern filter to TerminalTabView (;, &&, ||,
  backticks, $(, rm -rf, curl|sh)
- Replace force-unwrap URL(string:)! with throwing guard in
  GitHubAPIClient.request() — prevents crash on malformed endpoints
- Remove dead runShell() from GitButlerViewModel — no callers remain
- Replace panic!() with graceful exit in clade-promote fitness CSV
- Fix all Rust compiler warnings (unused imports/vars)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace deprecated onChange(of:perform:) with zero-param variant
  (macOS 14+) in TerminalTabView
- Reset safety budget from 0 (halted) to 3 (graduated) — allows
  monitored self-improvement without full autonomy
- Log budget_reset and audit_complete to event_log.jsonl

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… deny

- Eliminate all 18 Swift compiler warnings (async let :Void, var→let, unreachable catch, unused vars, deprecated onChange, callback→async/await)
- Eliminate all Rust .unwrap()/.expect() calls across 13 crates (graceful error handling)
- Remove all URL force-unwraps (URL(string:)!) — safe fallbacks everywhere
- Remove all Regex::new().unwrap() — match with early return
- Centralize 14 hardcoded port references (9105/9200/9205) into ProjectPaths constants
- Add canaryMcpPort, mcpBaseURL to ProjectPaths.swift
- Convert GitButlerViewModel from callback-based runGit to async runGitAsync
- Add error logging to 6 critical silent try? patterns (RecursionGuard PID write, CladeGuard snapshot pruning, SessionGuard A2A registration, QueenStatus pkill, ServerManager funnel)
- Add workspace-level clippy lint: unwrap_used="deny", expect_used="warn"
- All 13 Rust crates inherit workspace lints via [lints] workspace=true

Build: Swift 0 warnings / 0 errors, Rust 0 warnings / 0 errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…g, jitter backoff

Comprehensive hardening across all 13 Rust crates:

- 123 unit tests (from 0), every crate now has test coverage
- SHA256 snapshot verification before rollback (sha2 crate)
- PID-file singleton + pgrep orphan cleanup for clade-monitor
- Multi-dimensional health scoring (5 weighted components) in dashboard
- Decorrelated jitter on exponential backoff (AWS pattern)
- Graceful port binding (TcpListener pre-check, no panic)
- Signal handling (SIGTERM/SIGINT) with AtomicBool for clean shutdown
- Weighted safety budget (critical=-3, high=-2, medium=-1, low=-0.5)
- Async dashboard (tokio::fs + reqwest async + tokio::join!)
- Constitution evaluate() with 9 enforced principles (14 tests)
- All silent `let _ =` in production code replaced with error logging
- Zero clippy warnings (workspace-wide unwrap_used = "deny")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ecosystem.config.js: pm2 managed clade-monitor + clade-dashboard
  with TRIOS_ROOT, port env vars, auto-restart, max 10 restarts
- build.sh: restored execute permission
- e2e: updated flow script

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- BrowserOSChatViewModel: async/await migration, var-to-let fixes
- ChatPanelView, MessageBubbleView: deprecated onChange resolved
- CLAUDE.md: AEL v2.0 loop, PHI LOOP phases, security rules
- SOUL.md: constitutional law updates
- Skills: clade-guard, clade-promote, clade-seal
- Agents: E/V/W agent instruction updates
- cron-life.md: pm2 restart rule, clade-specific triggers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant