feat(agents): add ZCode as first-class supported agent - #10654
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdded ZCode to shared agent types, labels, catalog metadata, selection order, telemetry mappings, mobile configuration, and translated documentation. Implemented ZCode lifecycle event normalization and 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 698af32e-ec42-4583-9a4e-19e4fa1eaac1
📒 Files selected for processing (43)
README.mddocs/readme/README.es.mddocs/readme/README.fr.mddocs/readme/README.ja.mddocs/readme/README.ko.mddocs/readme/README.pt.mddocs/readme/README.zh-CN.mdmobile/src/tasks/mobile-tui-agents.tssrc/main/agent-hooks/agent-hook-memory-sftp.test-fixture.tssrc/main/agent-hooks/managed-agent-hook-controls.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/agent-hooks/remote-managed-hook-installers.tssrc/main/ipc/agent-hooks.test.tssrc/main/ipc/agent-hooks.tssrc/main/zcode/hook-service.test.tssrc/main/zcode/hook-service.tssrc/main/zcode/zcode-hook-config.test.tssrc/main/zcode/zcode-hook-config.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-catalog.tsxsrc/renderer/src/lib/agent-status.test.tssrc/renderer/src/lib/agent-status.tssrc/renderer/src/web/web-preload-api.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.tssrc/shared/agent-hook-types.tssrc/shared/agent-kind.tssrc/shared/agent-name-token-match.tssrc/shared/agent-session-resume.tssrc/shared/agent-status-types.tssrc/shared/agent-type-label.tssrc/shared/telemetry-events.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-display-names.tssrc/shared/tui-agent-selection.tssrc/shared/types.ts
Sync update (
|
c31b485 to
83fa941
Compare
Register Z.ai ZCode (GLM) as a launchable TuiAgent with PATH detection (`zcode`), agent catalog / labels, telemetry agent_kind, and managed status hooks that POST to /hook/zcode. Hook installer writes zcode-hook.sh under ~/.orca/agent-hooks and registers Claude-compatible lifecycle events in ~/.zcode/cli/config.json (hooks.enabled + hooks.events), bridging ZCode's local subprocess hook protocol to Orca's HTTP endpoint. Residual blockers (documented for follow-up; not fixed here): - ZCode hooks are process/command only (no native HTTP/webhook). The managed script is the bridge; status only works when ZCode actually fires configured hooks. - zai-org/feedback#32: native/built-in ZCode agent may not fire hooks.events; only external CLI sub-agents currently trigger them. - Desktop installs often lack a standalone `zcode` binary on PATH (app-only); detection then leaves the agent available but not auto-picked until the CLI is present or a cmd override is set. Closes stablyai#10564
CodeRabbit: SessionStart is a documented ZCode lifecycle event, and remove() left hooks.enabled forced true after managed install. Stash the pre-install value and restore it when managed hooks are removed.
83fa941 to
4b8066a
Compare
Sync update (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/agent-hooks/remote-hook-service-installers.test.ts (1)
425-426: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert
SessionStartis installed.
SessionStartis a required lifecycle event and was called out as a prior regression; this test currently cannot catch its removal.Proposed fix
+ expect(config.hooks?.events?.SessionStart).toBeDefined() expect(config.hooks?.events?.UserPromptSubmit).toBeDefined()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 174907a1-12b9-49fe-961f-125d34f32ac7
📒 Files selected for processing (12)
README.mddocs/readme/README.es.mddocs/readme/README.fr.mddocs/readme/README.ja.mddocs/readme/README.ko.mddocs/readme/README.pt.mddocs/readme/README.zh-CN.mdmobile/src/tasks/mobile-tui-agents.tssrc/main/agent-hooks/agent-hook-memory-sftp.test-fixture.tssrc/main/agent-hooks/managed-agent-hook-controls.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/agent-hooks/remote-managed-hook-installers.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- docs/readme/README.zh-CN.md
- src/main/agent-hooks/remote-managed-hook-installers.ts
- docs/readme/README.es.md
- docs/readme/README.ko.md
- docs/readme/README.pt.md
- docs/readme/README.ja.md
- mobile/src/tasks/mobile-tui-agents.ts
- src/main/agent-hooks/agent-hook-memory-sftp.test-fixture.ts
Greptile SummaryThis PR adds ZCode (Z.ai) as a first-class
Confidence Score: 5/5Safe to merge. The ZCode integration follows the identical pattern as all other recently-added TUI agents, and the concurrent refactor of agent-hooks.ts reduces copy-paste risk going forward. All shared registration points (TuiAgent, WellKnownAgentType, AGENT_HOOK_TARGETS, telemetry schema, display names, selection order, preload API) are updated consistently. The hook service is well-tested with idempotency, user-config preservation, and enabled-flag restoration covered. The IPC refactor is a mechanical extraction with no logic change. The two findings are style nits with no user-visible impact. Files Needing Attention: No files require special attention. The new src/main/zcode/ files are the most novel code but have good test coverage.
|
| Filename | Overview |
|---|---|
| src/main/zcode/hook-service.ts | New ZCode hook service: install/remove/getStatus/installRemote, generates zcode-hook.sh. Dead-code duplicate in buildStatus() for present.size===0 (both branches set state='not_installed'). |
| src/main/zcode/zcode-hook-config.ts | New ZCode hook config: apply/remove/read managed hooks into hooks.events JSON. Well-tested idempotent logic; preserves user hooks and restores pre-install enabled flag. |
| src/shared/agent-hook-listener.ts | Refactors normalizeKimiEvent into shared normalizeClaudeCompatibleAgentEvent; adds normalizeZcodeEvent and /hook/zcode endpoint. Logic is clean and consistent with kimi path. |
| src/main/ipc/agent-hooks.ts | Replaces 14 copy-pasted IPC handler blocks with a data-driven AGENT_HOOK_STATUS_HANDLERS table and shared registerAgentHookStatusHandler; adds zcode entry. Cleaner and removes ~200 LOC of duplication. |
| src/main/zcode/hook-service.test.ts | New test file: covers not_installed, install, reinstall idempotency, user-config preservation, and remove with enabled-flag restoration. Solid coverage. |
| src/main/agent-hooks/remote-hook-service-installers.test.ts | Extracts inline FakeFs/createFakeSftp to shared fixture (createAgentHookMemorySftp); adds ZcodeHookService to invariant checks. Reduces duplication. |
| src/shared/agent-status-types.ts | Adds kimi (pre-existing omission) and zcode to WellKnownAgentType; straightforward type extension. |
| src/shared/agent-session-resume.ts | Adds zcode to the switch case that reads Claude-compatible session_id; uses falls-through pattern consistent with kimi. |
| src/main/agent-hooks/agent-hook-memory-sftp.test-fixture.ts | Promotes inline FakeFs / createFakeSftp to a shared test fixture with failRenameTo; no logic changes. |
Sequence Diagram
sequenceDiagram
participant ZCode as ZCode CLI Process
participant Script as zcode-hook.sh
participant HTTP as Orca HTTP Listener /hook/zcode
participant Listener as agent-hook-listener normalizeZcodeEvent
participant IPC as IPC agentHooks:zcodeStatus
participant UI as Renderer / Sidebar
Note over ZCode,Script: On each hook event (UserPromptSubmit, PreToolUse, etc.)
ZCode->>Script: executes managed script via hooks.events
Script->>HTTP: POST /hook/zcode with paneKey, payload, token
HTTP->>Listener: "normalizeHookPayload(source='zcode', ...)"
Listener->>Listener: normalizeZcodeEvent() → normalizeClaudeCompatibleAgentEvent()
Listener-->>UI: AgentStatusEntry (state: working/waiting/done)
Note over IPC,UI: On sidebar open / refresh
UI->>IPC: agentHooks:zcodeStatus IPC
IPC->>IPC: zcodeHookService.getStatus() reads ~/.zcode/cli/config.json
IPC-->>UI: AgentHookInstallStatus (installed/partial/not_installed/error)
Reviews (2): Last reviewed commit: "fix(zcode): repair broken openclaude imp..." | Re-trigger Greptile
CodeRabbit/Greptile: unterminated string on openClaudeHookService import broke the whole test file; indent falls-through comment for kimi→zcode. Co-Authored-By: Grok Companion <noreply@x.ai>
Sync update (
|
|
Fresh empirical validation against ZCode Desktop 3.7.5 / bundled CLI 0.16.1 / macOS arm64: Hooks and subagent lifecycle do workA user-level For an internally dispatched Launch remains blocked for desktop-only installsThe app does not install |
|
I opened #13965 as a current-main refresh of this ZCode integration. It preserves the original first-class-agent intent from @innocarpe's work here, while adapting it to Orca's newer managed hook registry, agent-status listener, SSH installer, IPC/preload, mobile, and localization architecture. Thank you for establishing the original direction. |
Summary
TuiAgent(detect/launchzcode, catalog, labels, telemetry).zcode-hook.shand wire ZCode local process hooks to Orca's HTTP listener (POST /hook/zcode).agentType: 'zcode'.Fixes
Closes #10564
Notes / residual
zcodeon PATH — use cmd override if needed.Test plan
ELI5
ZCode is registered as a first-class Orca agent with detection, launch, hooks, and telemetry so ZCode users can run it managed like Claude or Codex.