Skip to content

feat(zcode): supervise orchestration workers and transcripts - #16228

Closed
guanbear wants to merge 16 commits into
stablyai:mainfrom
guanbear:codex/zcode-orchestration
Closed

guanbear wants to merge 16 commits into
stablyai:mainfrom
guanbear:codex/zcode-orchestration

Conversation

@guanbear

@guanbear guanbear commented Aug 24, 2026 •

Copy link
Copy Markdown

Summary

Adds supervised ZCode workers and transcript support to Orca orchestration:

  • Chooses persistent TUI input only after positively detecting an interactive client.
  • Uses bounded startup-prompt execution for prompt-only, remote, or overridden runtimes.
  • Bridges ZCode provider sessions and SQLite transcripts into worker-read and lifecycle cleanup.
  • Preserves setup gates, dispatch authority, readiness checks, and durable worker receipts.
  • Builds the interactive worker command from Orca's configured agent arguments instead of forcing --mode yolo.

Dependency

Draft follow-up to #13965 and #16227. This branch is intentionally stacked; review the final follow-up commit after its parents.

Permissions

ZCode now follows the same global permission model as other TUI agents:

  • Orca's automatic mode supplies --mode yolo through agentDefaultArgs.
  • Manual mode supplies no bypass flag.
  • User command/argument overrides remain authoritative.

No orchestration-specific permission bypass is hard-coded.

Validation

  • The full affected-suite run passed during the split; the post-rebase ZCode startup and orchestration smoke passes 37 tests across 4 suites.
  • orca-runtime.test.ts passes (1,210 passed, 1 skipped).
  • Node, web, and CLI typechecks pass on Node 24.
  • Changed-file formatting, lint, max-lines, and git diff --check pass.

Scope

This PR intentionally excludes the ZCode usage meter. Usage reporting remains in #14556 and depends only on the core ZCode identity/provider registration.

@guanbear
guanbear force-pushed the codex/zcode-orchestration branch 2 times, most recently from 9b4d5ce to a2b01ec Compare August 25, 2026 06:48
@guanbear

Copy link
Copy Markdown
Author

Restacked onto the refreshed #16227 head on current main (6faaf3af); no new conflicts. Validation: Node/Web typecheck passes; transcript-watch, zcode transcript tail, sqlite transcript, foreground-process, and orchestration setup-gate/federation/start-validation suites pass (50 tests).

@guanbear
guanbear force-pushed the codex/zcode-orchestration branch from a2b01ec to 1a90820 Compare September 20, 2026 09:21
@guanbear

Copy link
Copy Markdown
Author

Restacked onto refreshed #13965 and #16227 on current upstream main (ee61e3bd4), with the live PTY/readiness fixes found during an Orca-managed ZCode end-to-end run.

Additional fixes in this refresh:

  • avoid waiting for tui-idle on the deliberately bare shell before sending the ZCode startup command
  • prevent Kiro shell integration from nesting ZCode outside Orca's supervised PTY
  • recognize the alternate-screen ZCode composer through the rendered-screen path
  • poll provider/process/composer readiness through slow cold starts without release-version assumptions

Validation:

  • Node/CLI/Web/mobile TypeScript projects pass typecheck.
  • 7 focused suites / 42 tests pass (worker topology, cold-start timeout, interactive client, SQLite transcript, transcript tail, foreground process, older SSH relay).
  • Full build:desktop passed for the combined stack.
  • Live E2E: Run run_243457e7976e, Task task_81664cf899f1, Dispatch ctx_bfc23d3d944e; ZCode TUI became visible, read the repository, returned the exact expected result, sent worker_done, and settled as completed / succeeded with a clean worktree.

@nwparker

Copy link
Copy Markdown
Contributor

Leaving this open rather than closing it, because about half of it is still wanted.

Status after #22464 landed:

Superseded — ZCode is orchestratable on main now (process identity zcode-cli, stdin-after-start delivery, composer-gated draft paste, resume). One thing I deliberately did not carry over: a session-option catalog. ZCode's CLI has no --model flag at all, and Orca's option-launch path applies nothing until a model id is chosen, so a catalog would have accepted --model and silently dropped it. Took opencode's position instead — no catalog, so worker-start --model is refused with a clear message and ZCode launches with the model from its own config.

Still wanted, and still yours if you want it — the AI Vault side. zcode-sqlite-transcript.ts and the native-chat transcript bridging have no equivalent on main. Session history for ZCode is genuinely missing, and the schema in ~/.zcode/cli/db/db.sqlite (session / message / part) is OpenCode-shaped, so it should be able to reuse the existing OpenCode SQLite worker rather than needing a new parser — which I think is what you'd already concluded.

The catch is that this branch is stacked on #13965, which I've just closed as superseded, so it won't rebase cleanly. If you'd rather open a fresh PR scoped to just the AI Vault work, that would be very welcome and much easier to review. Happy to leave this one open as reference for as long as it's useful to you.

Also worth saying: your E2E receipt on this PR — worker reads a repo, returns an answer, sends worker_done, settles completed — was the only live orchestration evidence anywhere in this set. That was useful.

@guanbear

Copy link
Copy Markdown
Author

Thanks for the scope guidance. I moved the remaining ZCode AI Vault work to a fresh PR from current main: #23513. It reuses the existing OpenCode SQLite worker for ZCode session listing, previews, search capture, first-prompt reads, and resume commands; the superseded orchestration stack is not included. I am closing this draft so review can continue on the focused replacement.

@guanbear guanbear closed this Sep 28, 2026
@nwparker

Copy link
Copy Markdown
Contributor

@guanbear awesome

I see it's still a draft but happy to dive in there

@guanbear

Copy link
Copy Markdown
Author

@nwparker Thanks for offering to review the replacement. #23513 is now out of draft. I incorporated your follow-up notes there: one shared hidden-transcript predicate, an explanation of how compacted sessions appear, and reuse of the existing OpenCode SQLite worker. The focused tests and Node 24 typecheck pass. A read-only smoke check against a real ZCode history would still be valuable before merge, as noted on #23513. I appreciate your help.

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.

2 participants