@zergai/ztc 0.26.3-dev.202611211442 → 0.26.4-dev.202611231953

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +585 -26
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/zmux-linux-x64 +0 -0
  4. package/bin/ztc-audio-darwin-arm64 +0 -0
  5. package/bin/ztc-capture-darwin-arm64 +0 -0
  6. package/bin/ztc-tui-darwin-arm64 +0 -0
  7. package/bin/ztc-tui-linux-x64 +0 -0
  8. package/bin/zterm-darwin-arm64 +2 -2
  9. package/dist/App.js +18 -1
  10. package/dist/agent/agent.d.ts +25 -1
  11. package/dist/agent/agent.js +26 -1
  12. package/dist/agent/attached_images.d.ts +58 -0
  13. package/dist/agent/attached_images.js +145 -0
  14. package/dist/agent/backends/anthropic.d.ts +14 -0
  15. package/dist/agent/backends/anthropic.js +44 -2
  16. package/dist/agent/backends/codex_app_server.js +4 -3
  17. package/dist/agent/backends/host_effort_policy.js +14 -2
  18. package/dist/agent/backends/http_error.d.ts +17 -0
  19. package/dist/agent/backends/http_error.js +50 -1
  20. package/dist/agent/backends/index.js +2 -1
  21. package/dist/agent/backends/model_redirect.d.ts +23 -4
  22. package/dist/agent/backends/model_redirect.js +53 -10
  23. package/dist/agent/backends/openai_responses.d.ts +9 -1
  24. package/dist/agent/backends/openai_responses.js +19 -12
  25. package/dist/agent/backends/prompt_cache.d.ts +8 -0
  26. package/dist/agent/backends/prompt_cache.js +10 -0
  27. package/dist/agent/backends/provider_ids.d.ts +1 -1
  28. package/dist/agent/backends/provider_ids.js +1 -1
  29. package/dist/agent/backends/types.d.ts +8 -0
  30. package/dist/agent/backends/zrouter_stream.d.ts +73 -9
  31. package/dist/agent/backends/zrouter_stream.js +229 -45
  32. package/dist/agent/commands/config.js +51 -4
  33. package/dist/agent/commands/connect.js +20 -0
  34. package/dist/agent/commands/debug.js +3 -0
  35. package/dist/agent/commands/diff.js +7 -4
  36. package/dist/agent/commands/inbox.js +2 -1
  37. package/dist/agent/commands/mcp.js +3 -0
  38. package/dist/agent/commands/models.js +20 -3
  39. package/dist/agent/commands/permissions.js +16 -2
  40. package/dist/agent/commands/provider_selection.js +13 -6
  41. package/dist/agent/commands/settings.js +15 -4
  42. package/dist/agent/commands/status.js +23 -1
  43. package/dist/agent/commands/types.d.ts +29 -3
  44. package/dist/agent/commands/zerg.d.ts +6 -0
  45. package/dist/agent/commands/zerg.js +43 -1
  46. package/dist/agent/commands/ztc_pane.js +8 -5
  47. package/dist/agent/factory.js +22 -4
  48. package/dist/agent/request_encoder.js +11 -2
  49. package/dist/agent/runtime/command_jobs.js +3 -0
  50. package/dist/agent/runtime/execution_context.d.ts +8 -1
  51. package/dist/agent/runtime/execution_context.js +8 -2
  52. package/dist/agent/runtime/policy.d.ts +66 -5
  53. package/dist/agent/runtime/policy.js +161 -33
  54. package/dist/agent/runtime/remote_broker_transport.js +4 -2
  55. package/dist/agent/runtime/source_verification.js +12 -7
  56. package/dist/agent/runtime/tool_runtime.js +165 -58
  57. package/dist/agent/runtime/verifier_capture.d.ts +1 -1
  58. package/dist/agent/runtime/verifier_capture.js +6 -0
  59. package/dist/agent/runtime/work_base.js +43 -18
  60. package/dist/agent/tools/adaptation.js +7 -5
  61. package/dist/agent/tools/apply_patch.js +62 -5
  62. package/dist/agent/tools/background.js +2 -0
  63. package/dist/agent/tools/benchmark_cpu.js +2 -0
  64. package/dist/agent/tools/bus_message.d.ts +4 -2
  65. package/dist/agent/tools/bus_message.js +21 -3
  66. package/dist/agent/tools/delegate.js +2 -0
  67. package/dist/agent/tools/file.d.ts +12 -1
  68. package/dist/agent/tools/file.js +92 -11
  69. package/dist/agent/tools/lsp.d.ts +12 -0
  70. package/dist/agent/tools/lsp.js +61 -5
  71. package/dist/agent/tools/pane.js +18 -46
  72. package/dist/agent/tools/project_context.js +5 -2
  73. package/dist/agent/tools/routine.js +16 -4
  74. package/dist/agent/tools/screenshot.d.ts +8 -0
  75. package/dist/agent/tools/screenshot.js +39 -25
  76. package/dist/agent/tools/search.js +27 -1
  77. package/dist/agent/tools/shell.js +7 -1
  78. package/dist/agent/tools/supervision.js +6 -0
  79. package/dist/agent/tools/types.d.ts +18 -0
  80. package/dist/agent/tools/zerg.js +15 -19
  81. package/dist/agent/tools/ztc_command.d.ts +15 -4
  82. package/dist/agent/tools/ztc_command.js +48 -34
  83. package/dist/app/conversation_compaction.d.ts +6 -3
  84. package/dist/app/conversation_compaction.js +6 -3
  85. package/dist/app/tool_callbacks.js +1 -0
  86. package/dist/audio/sfx.js +6 -0
  87. package/dist/batch/worktree.js +8 -7
  88. package/dist/board/client.js +2 -1
  89. package/dist/cli_main.d.ts +1 -0
  90. package/dist/cli_main.js +141 -45
  91. package/dist/cli_ratatui.d.ts +33 -3
  92. package/dist/cli_ratatui.js +267 -52
  93. package/dist/conductor_branch.js +4 -1
  94. package/dist/config/host_credentials.d.ts +157 -0
  95. package/dist/config/host_credentials.js +589 -0
  96. package/dist/config/model_pin.d.ts +111 -0
  97. package/dist/config/model_pin.js +182 -0
  98. package/dist/config/own_state_files.d.ts +35 -0
  99. package/dist/config/own_state_files.js +161 -0
  100. package/dist/config/permission_pin.d.ts +148 -0
  101. package/dist/config/permission_pin.js +203 -0
  102. package/dist/config/permissions.d.ts +9 -2
  103. package/dist/config/permissions.js +14 -3
  104. package/dist/config/platform_login.d.ts +72 -0
  105. package/dist/config/platform_login.js +111 -0
  106. package/dist/config/profile_limits.d.ts +34 -0
  107. package/dist/config/profile_limits.js +66 -0
  108. package/dist/config/provider_api_key_env.js +3 -2
  109. package/dist/config/provider_models.d.ts +6 -1
  110. package/dist/config/provider_models.js +38 -11
  111. package/dist/config/router_runtime_grant.d.ts +9 -6
  112. package/dist/config/router_runtime_grant.js +12 -9
  113. package/dist/config/settings_merge.d.ts +22 -0
  114. package/dist/config/settings_merge.js +75 -0
  115. package/dist/config/types.d.ts +8 -0
  116. package/dist/config.d.ts +294 -2
  117. package/dist/config.js +930 -39
  118. package/dist/context/project_intelligence.d.ts +11 -2
  119. package/dist/context/project_intelligence.js +18 -7
  120. package/dist/desktop/daily/desktop_wiring.js +8 -6
  121. package/dist/desktop/daily/native_pane_launcher.js +2 -1
  122. package/dist/desktop/daily/native_tool.js +4 -3
  123. package/dist/desktop/daily/process_identity.js +10 -2
  124. package/dist/desktop/daily/source_baseline.js +4 -3
  125. package/dist/diagnostics/native_terminal_benchmark.js +3 -2
  126. package/dist/diagnostics/session_export.js +27 -14
  127. package/dist/emulation/catalog.js +6 -1
  128. package/dist/emulation/tool_adapters.js +13 -3
  129. package/dist/extension_discovery.d.ts +12 -2
  130. package/dist/extension_discovery.js +52 -7
  131. package/dist/headless.d.ts +8 -0
  132. package/dist/headless.js +46 -11
  133. package/dist/headless_cli.js +16 -1
  134. package/dist/headless_workflow_trigger.js +1 -1
  135. package/dist/hooks/dispatcher.d.ts +8 -0
  136. package/dist/hooks/dispatcher.js +22 -2
  137. package/dist/hooks/lifecycle.d.ts +6 -0
  138. package/dist/hooks/lifecycle.js +1 -0
  139. package/dist/hooks/program_files.d.ts +10 -0
  140. package/dist/hooks/program_files.js +175 -0
  141. package/dist/hooks/runner.d.ts +11 -1
  142. package/dist/hooks/runner.js +112 -11
  143. package/dist/hooks/types.d.ts +2 -0
  144. package/dist/host_credentials_startup.d.ts +6 -0
  145. package/dist/host_credentials_startup.js +17 -0
  146. package/dist/instance_registry.d.ts +6 -2
  147. package/dist/instance_registry.js +9 -15
  148. package/dist/lsp/manager.d.ts +1 -1
  149. package/dist/lsp/manager.js +4 -5
  150. package/dist/mcp/client.d.ts +2 -0
  151. package/dist/mcp/client.js +116 -17
  152. package/dist/mcp/registry.d.ts +12 -0
  153. package/dist/mcp/registry.js +15 -1
  154. package/dist/modes/handlers.js +14 -5
  155. package/dist/panes/agent_cli.d.ts +23 -1
  156. package/dist/panes/agent_cli.js +96 -1
  157. package/dist/panes/agent_panes.d.ts +27 -4
  158. package/dist/panes/agent_panes.js +73 -11
  159. package/dist/panes/editor_program.d.ts +8 -0
  160. package/dist/panes/editor_program.js +25 -0
  161. package/dist/panes/motsi.d.ts +11 -1
  162. package/dist/panes/motsi.js +14 -1
  163. package/dist/panes/pane_registry.d.ts +28 -1
  164. package/dist/panes/pane_registry.js +25 -0
  165. package/dist/panes/ztc_launch.d.ts +8 -0
  166. package/dist/panes/ztc_launch.js +26 -1
  167. package/dist/profile_baseline.js +2 -0
  168. package/dist/router_auth.js +2 -1
  169. package/dist/runtime_info.js +46 -36
  170. package/dist/shannon/runtime.js +8 -0
  171. package/dist/simulation/domains/loader.d.ts +2 -1
  172. package/dist/simulation/domains/loader.js +19 -2
  173. package/dist/terminal_attach.js +2 -1
  174. package/dist/types.d.ts +21 -0
  175. package/dist/ui/ratatui/headless_pane_manager.d.ts +1 -1
  176. package/dist/ui/ratatui/headless_pane_manager.js +16 -6
  177. package/dist/ui/ratatui/pane_credential_broker.d.ts +17 -4
  178. package/dist/ui/ratatui/pane_credential_broker.js +23 -5
  179. package/dist/ui/ratatui/pane_relay.d.ts +66 -0
  180. package/dist/ui/ratatui/pane_relay.js +158 -3
  181. package/dist/ui/ratatui/process.d.ts +15 -1
  182. package/dist/ui/ratatui/process.js +127 -163
  183. package/dist/ui/ratatui/protocol.d.ts +11 -1
  184. package/dist/ui/ratatui/protocol.js +6 -0
  185. package/dist/ui/ratatui/ztc_launch_trust.d.ts +87 -0
  186. package/dist/ui/ratatui/ztc_launch_trust.js +249 -0
  187. package/dist/utils/admitted_open.d.ts +40 -0
  188. package/dist/utils/admitted_open.js +111 -0
  189. package/dist/utils/clipboard.js +2 -1
  190. package/dist/utils/computer_native.js +12 -56
  191. package/dist/utils/dictation.js +15 -12
  192. package/dist/utils/dictation_native.js +17 -81
  193. package/dist/utils/git_probe_options.d.ts +28 -0
  194. package/dist/utils/git_probe_options.js +30 -0
  195. package/dist/utils/git_program_files.d.ts +145 -0
  196. package/dist/utils/git_program_files.js +1282 -0
  197. package/dist/utils/git_repository_programs.d.ts +13 -0
  198. package/dist/utils/git_repository_programs.js +38 -0
  199. package/dist/utils/host_shell.js +2 -1
  200. package/dist/utils/idle_compaction.js +8 -1
  201. package/dist/utils/image_fit.d.ts +4 -1
  202. package/dist/utils/image_fit.js +6 -2
  203. package/dist/utils/image_preview.js +3 -2
  204. package/dist/utils/ml_native.js +11 -56
  205. package/dist/utils/native_install.d.ts +55 -0
  206. package/dist/utils/native_install.js +107 -0
  207. package/dist/utils/open_url.js +2 -0
  208. package/dist/utils/router_catalog.js +9 -2
  209. package/dist/utils/sandbox.d.ts +64 -1
  210. package/dist/utils/sandbox.js +397 -89
  211. package/dist/utils/shell.js +31 -12
  212. package/dist/utils/subprocess_env.d.ts +116 -18
  213. package/dist/utils/subprocess_env.js +209 -51
  214. package/dist/utils/system_ps.d.ts +5 -0
  215. package/dist/utils/system_ps.js +30 -0
  216. package/dist/utils/tts.js +5 -0
  217. package/dist/utils/tts_native.js +13 -60
  218. package/dist/utils/zlicky_overlay.js +17 -50
  219. package/dist/utils/ztc_own_state.d.ts +58 -0
  220. package/dist/utils/ztc_own_state.js +236 -0
  221. package/dist/web/mirror_authenticator.d.ts +7 -6
  222. package/dist/web/mirror_authenticator.js +12 -10
  223. package/dist/web/mirror_stream.d.ts +27 -8
  224. package/dist/web/mirror_stream.js +83 -24
  225. package/dist/web/observer_secret_redaction.d.ts +8 -5
  226. package/dist/web/observer_secret_redaction.js +210 -40
  227. package/dist/web/pane_credentials.d.ts +15 -1
  228. package/dist/web/pane_credentials.js +36 -3
  229. package/dist/worker/executor.js +3 -1
  230. package/dist/workspace_collision.js +12 -10
  231. package/dist/zlm-embed.mjs +5969 -2811
  232. package/npm-shrinkwrap.json +1 -1
  233. package/package.json +42 -15
package/README.md CHANGED
@@ -525,7 +525,14 @@ for Status recovery, resume refusals, receipt handling, and verification limits.
525
525
  limit or quota, too many or too large media), ZTC sends it again without
526
526
  them, says so once in the transcript (a line no model, recap or summary
527
527
  reads), and that model reads `[image]` while Router refuses them; ZTC tries
528
- images again every 5 minutes. A tool's image
528
+ images again every 5 minutes. Through Zerg Router, on a host's Router runtime
529
+ grant or on your own key or sign-in alike, a spending limit's refusal of a
530
+ request it can't price for an image you attached sends the request again at
531
+ once without those of yours in a format Router never prices there (all but
532
+ PNG, JPEG and WebP for OpenAI's models, every image for other providers),
533
+ before any tool image gives way, and without all of yours if Router refuses
534
+ it again; the transcript names the model and the format, and a note stands in
535
+ for each withheld image in the conversation and the saved session. A tool's image
529
536
  never reaches a model as text: an image result's image is never cut, only its
530
537
  words, as any tool's text is, and wherever a model reads a result as text (a
531
538
  delegated worker, the evidence block, a compaction's summary or handoff, the
@@ -1290,7 +1297,7 @@ preserve operation tombstones and call linkage before archiving evidence.
1290
1297
 
1291
1298
  `/profile list` and `/settings` → **Config Scope** → **Active config profile** show one profile catalog. The built-in `ztc`, `ztc-coder`, `ztc-datascience`, and `scientist` profiles share the default settings and sign-ins; each selects its named emulation layer. They work without setup. An existing saved directory with one of those names remains an independent config profile, so its data stays accessible.
1292
1299
 
1293
- Custom config profiles keep settings and sign-ins separate. Start one with `ztc --profile work`, or switch the running session with `/profile work`. `/profile create work` starts a new profile. Switching keeps the session ID and conversation while rebuilding the agent. A later `ztc resume` restores the session's saved profile unless you specify `--profile`. The default config stays at `~/.ztc/config.json`; custom named configs live at `~/.ztc/profiles/<name>/config.json`. Session history stays shared. Switching does not rewrite settings after the one-time migration described below.
1300
+ Custom config profiles keep settings and sign-ins separate. Start one with `ztc --profile work`, or switch the running session with `/profile work`. `/profile create work` starts a new profile. Switching keeps the session ID and conversation while rebuilding the agent. It also keeps the permission profile ZTC was started with (`--permission-profile`) as ZTC holds it, with the OS sandbox it requires. Every config profile has the built-in ones unless its `config.json` redefines one. A config profile whose `config.json` doesn't define the one ZTC was started with (your own, under `permissionProfiles`; a new config profile defines none) is refused, naming the file to define it in, and the session stays on its config profile. Where that permission profile limits the agent, so is one whose `config.json` defines it otherwise, naming both files and where they differ. `/profile duplicate` copies the definition with the rest. A factory reset (`/config reset`) keeps it as well, and is refused where the reset `config.json` wouldn't define it (your own) or, where it limits the agent, would define it otherwise (a built-in one you redefined). The launch's `--provider`, `--model`, `--auth-mode`, `--router-url` and `--effort` stay with the config profile they were given for. A later `ztc resume` restores the session's saved profile unless you specify `--profile`. The default config stays at `~/.ztc/config.json`; custom named configs live at `~/.ztc/profiles/<name>/config.json`. Session history stays shared. Switching does not rewrite settings after the one-time migration described below.
1294
1301
 
1295
1302
  An expired or unsigned Router profile can be selected in the running session. The agent waits for sign-in, and ZTC shows `/auth login --url <profile-router-origin>` for that profile. The conversation stays available. Invalid settings and mismatched Router origins still roll back the switch.
1296
1303
 
@@ -1597,6 +1604,16 @@ include HTTP status and bounded, redacted response details.
1597
1604
 
1598
1605
  Built with `npm run build:rust` — cross-compiled per platform.
1599
1606
 
1607
+ ZTC runs its native programs (these, dictation's ztc-audio, ztc-tts, the zlicky overlay, and the renderers ztc-tui, zmux
1608
+ and ZTerm) only from its own install: the package's `bin/` (an npm install, the npm launcher's copy of one, the desktop
1609
+ app's bundle) and, in a source checkout, that checkout's own build under `packages/<crate>/target` (the zlicky overlay's
1610
+ under `native/zlicky-overlay`, where `/usr/bin/swift` runs its source if none is built). A `target/debug` build runs
1611
+ only where there is no release build and no `bin/` copy. ZTC never runs a copy from your working directory, from
1612
+ `~/.ztc/bin` or from a folder above the install; the desktop app's own ZTerm, an installed `ZTerm.app` and a renderer a
1613
+ host that embeds ZTC hands it are the only ones it takes from elsewhere. No variable names a helper's path. The helpers
1614
+ start without the credentials ZTC routes models with, a variable your profile names in `apiKeyEnv` among them (see
1615
+ [Credentials a host hands over](#credentials-a-host-hands-over)).
1616
+
1600
1617
  ### Project Structure
1601
1618
  ```
1602
1619
  ztc/
@@ -1806,7 +1823,7 @@ The host supplies `saveCheckpoint` and `consumeEvent` in this example.
1806
1823
  | `onMidTurnCompact` | Receives messages, token usage, optional context window, and cancellation signal. Return replacement messages or `null` to retain history. |
1807
1824
  | `remoteResourceSession` | Supplies the host-owned resource list, owner identity, optional transport, and journal directory. Activates guarded remote execution. |
1808
1825
  | `hooks` | Supplies a `HookDispatcher` for lifecycle and tool hooks. Use `approvalRequester` to resolve tool approval requests. |
1809
- | `mcpServers` | Uses the same server configuration and discovery as the CLI. Each named server supports HTTP or stdio transport, `disabled`, and `required`. Required connection failures reject creation. |
1826
+ | `mcpServers` | Uses the same server configuration and discovery as the CLI. Each named server supports HTTP or stdio transport, `disabled`, `required`, and for stdio `passEnv`. A stdio server starts without the credentials ZTC routes models with unless its `passEnv` names one. Required connection failures reject creation. |
1810
1827
 
1811
1828
  The root also exports `ToolCheckpointHandler`, `ToolCheckpoint`, `MidTurnCompactContext`, `RemoteResourceSession`, `RemoteResourceTransport`, `MCPServerConfig`, and hook types.
1812
1829
  It exports `HookDispatcher` and `ToolCapability` for host construction.
@@ -1913,18 +1930,28 @@ adds nothing: `/claude --permission-mode plan`,
1913
1930
  `--yolo`, `-p <profile>` or `-c approval_policy=…`. Run as root outside a
1914
1931
  sandbox, Claude Code refuses its flag, so ZTC leaves it out and says so. To
1915
1932
  have both ask as their own settings say, set Claude Code and Codex permissions
1916
- to ask in `/settings` → Panes (`panes.agentPermissions: "ask"`).
1933
+ to ask in `/settings` → Panes (`panes.agentPermissions: "ask"`). Each pane you
1934
+ open reads that setting from the saved profile as it starts the CLI, the
1935
+ desktop app's own Claude Code and Codex panes too, so an ask saved in any ZTC
1936
+ pane on the profile holds at once for every pane any of them opens after it.
1917
1937
 
1918
1938
  Panes an agent opens ask before running commands, whatever that setting says:
1919
1939
  an agent's `/claude` or `/codex` (through `ztc_command`) and workspace-mcp's
1920
- `open_pane` get no flag from ZTC, and an agent's own
1921
- `--dangerously-skip-permissions`, `bypassPermissions` mode,
1922
- `--dangerously-bypass-approvals-and-sandbox`, `--yolo` or `danger-full-access`
1923
- sandbox is refused. Opening one starts a program that runs commands, so the
1924
- agent's permission profile governs it as it governs a shell: a profile without
1925
- `shell_exec` refuses it, and one that asks before shell commands asks before it
1926
- opens. The delegated Codex and ZTC workers of the New pane chooser never
1927
- bypass: they stay read-only.
1940
+ `open_pane` get no flag from ZTC, and of the CLI's own words an agent may pass
1941
+ only those that can't change how it asks: Claude Code's `--model`, `--effort`,
1942
+ `--fallback-model`, `-n`/`--name`, `-c`/`--continue`, `-r`/`--resume`,
1943
+ `--fork-session` and `--verbose`, Codex's `-m`/`--model` and `--no-alt-screen`,
1944
+ each with its value where it takes one, and a prompt. Any other flag is refused,
1945
+ such as `--allowedTools`, `--settings`, `--permission-mode`, `--mcp-config`,
1946
+ `--add-dir`, Codex's `-a`, `-s`, `-c`, `-p` or `--full-auto`, any
1947
+ `--dangerously-…` or `--yolo`, and one ZTC doesn't know; and so is a first word
1948
+ either CLI would run as one of its own commands, such as `/codex -m o3 apply` or
1949
+ a one-word Claude Code task like `update`, which Claude Code reads as
1950
+ `claude update` even after `--`. Panes you open take your words as they are.
1951
+ Opening one starts a program that runs commands, so the agent's permission
1952
+ profile governs it as it governs a shell: a profile without `shell_exec` refuses
1953
+ it, and one that asks before shell commands asks before it opens. The delegated
1954
+ Codex and ZTC workers of the New pane chooser never bypass: they stay read-only.
1928
1955
 
1929
1956
  An agent's `/ztc` follows the same rule, as ZTC's own `create_ztc_pane` does: a
1930
1957
  ZTC pane runs an agent that runs commands. A new ZTC pane runs under the
@@ -1953,15 +1980,43 @@ is never edited. Its tools give the agent the workspace:
1953
1980
  A ZTC agent reaches these panes by name as well: a message for a Claude Code or
1954
1981
  Codex pane is typed into it as `[Message from ben (pane 2)] …` (a question also
1955
1982
  says how to answer), and the answer comes back as a message from that pane.
1956
- Broadcasts to `all` reach ZTC agents only. `send_message` reaches agents alone:
1957
- a message for a shell or a command pane is refused, and `type_into_pane` types
1958
- into those. A ZTC agent's own `send_message` and `ask_ztc_pane` say so too
1959
- (`write_terminal_pane` types into those panes there). A ZTC pane still starting,
1960
- such as one just opened with `open_pane`, gets a message when it joins ZTC's
1961
- bus: `send_message` (and a ZTC agent's `ask_ztc_pane`) says "Pane 7 is still
1962
- starting; it gets your message when it joins.", and an answer comes back later
1963
- as a message from that pane. A worker opened with a task answers the task
1964
- first, and the message once that turn has ended.
1983
+ The sender's name and pane id are typed as one line: line breaks, escape
1984
+ sequences and other control characters go, a square bracket becomes a
1985
+ parenthesis, and a name longer than 64 characters is cut, so no name can end the
1986
+ line or read as Main's answer. Broadcasts to `all` reach ZTC agents only.
1987
+ `send_message` reaches agents alone, Main's as well as a pane's and with or
1988
+ without a mirror running: a message for a shell or a command pane is refused,
1989
+ and `type_into_pane` types into those. A ZTC agent's own `send_message` and
1990
+ `ask_ztc_pane` say so too (`write_terminal_pane` types into those panes there).
1991
+ The desktop app's native Claude Code and Codex panes are for your typing (the
1992
+ desktop labels them "human input only"), and its native shell panes take typing
1993
+ (`type_into_pane`); none takes messages, so a message for one is refused as
1994
+ well, and so is one for a delegated worker's pane, which shows its feed and
1995
+ takes no input. `type_into_pane` and `write_terminal_pane` still type into any
1996
+ of them, as into any pane, and a native Claude Code or Codex pane on the default
1997
+ setting runs what is typed there without asking. The refusal says which the
1998
+ pane is and what works instead: `type_into_pane` for a native shell, and for a
1999
+ native Claude Code or Codex pane, one that `/claude` or `/codex` opens, which an
2000
+ agent can message. A native ZTC pane is an agent, and gets messages as any ZTC
2001
+ pane does.
2002
+ A ZTC pane still starting, such as one just opened with `open_pane`, gets a
2003
+ message when it joins ZTC's bus: `send_message` (and a ZTC agent's
2004
+ `ask_ztc_pane`) says "Pane 7 is still starting; it gets your message when it
2005
+ joins.", and an answer comes back later as a message from that pane. A worker
2006
+ opened with a task answers the task first, and the message once that turn has
2007
+ ended.
2008
+
2009
+ While ZTC runs no mirror (it started without one, or you ran `/mirror stop`)
2010
+ there is no bus, so Main's message for a ZTC pane is typed into it and
2011
+ submitted as `[Message from Main]: …` in one line, Main's name cleaned as a
2012
+ Claude Code pane's sender is. The text's line breaks become spaces, so no line
2013
+ of it is submitted on its own, as your input or a slash command. With a mirror
2014
+ running, a pane on its bus gets the message whole; a ZTC pane that reads its
2015
+ input from stdin and joins no bus (the ones a controller opens in a headless
2016
+ resident) gets it as that same one line, Main's agent's and another pane's
2017
+ alike. Main's agent's message that is a pane control command
2018
+ (`{"__ztc_cmd":…}`), which only the ZTC that runs the workspace sends, is
2019
+ refused; a pane's reaches another only as a message.
1965
2020
 
1966
2021
  Main answers a message one of these panes sends it once it has finished the
1967
2022
  work on it: the turn that read it, and any turn that goes on with that work by
@@ -2041,8 +2096,9 @@ Main with `send_message`.
2041
2096
  A pane the agent opens with `open_pane` starts as one you open yourself, by
2042
2097
  ZTC's settings as saved at that moment: the profile new Claude Code and Codex
2043
2098
  panes start on, MotSi's remote view, the route a ZTC pane starts on and, in
2044
- the desktop app, Claude Code badges. Only the permission prompts differ: a
2045
- Claude Code or Codex pane an agent opens asks before running commands. A ZTC
2099
+ the desktop app, Claude Code badges. Only the permission prompts differ, and the
2100
+ words an agent may pass (above): a Claude Code or Codex pane an agent opens asks
2101
+ before running commands. A ZTC
2046
2102
  pane an agent opens gets the agent's task as a message to its own agent, never
2047
2103
  as a command it runs as yours, whether the task comes from `open_pane` or as
2048
2104
  words among the pane's arguments to ZTC's own `create_ztc_pane`,
@@ -2376,12 +2432,19 @@ Hosted launchers can set `ZTC_EXTENSION_DISCOVERY=explicit` to disable all
2376
2432
  automatic cwd, repository, and home extension discovery. In that mode ZTC
2377
2433
  loads only roots named by the corresponding `ZTC_*_PATHS` variable plus its
2378
2434
  packaged builtins. It also ignores `<cwd>/.ztc/config.json`, so repository
2379
- content cannot replace the launcher's provider or model. Leaving the policy
2380
- unset preserves normal interactive discovery.
2435
+ content cannot replace the launcher's provider or model. A ZTC that holds a
2436
+ host's Router runtime grant, one it can use or not (see
2437
+ [Credentials a host hands over](#credentials-a-host-hands-over)), runs in that
2438
+ mode whenever the policy is unset; a host that wants normal discovery for it
2439
+ sets `ZTC_EXTENSION_DISCOVERY=default`. Otherwise, leaving the policy unset
2440
+ preserves normal interactive discovery.
2381
2441
 
2382
2442
  | Variable | Description |
2383
2443
  |----------|-------------|
2384
2444
  | `ANTHROPIC_API_KEY` | Anthropic API key for direct API billing |
2445
+ | `ZTC_AUTH_TOKEN` | A ZergAI platform login, for the platform API named for it: `ZTC_API_BASE_URL`, a colony cell's `COLONY_PORT`, an API environment chosen in the settings, or that API's own `/api/zrouter` in `ZERG_PROXY_URL`. ZTC sends it nowhere when no platform API is named for it, and never sends a Zerg Router credential it can recognize in it to a platform API: an `sk-zr-` key or another prefix Router issues, a Router JSON Web Token (audience `zergrouter`), or a value ZTC also holds as a Router credential (the host's grant, `ZERG_AUTH_TOKEN`, your Router sign-in). An opaque Router token that ZTC holds nowhere else has no shape it can tell: with a platform API named, it is sent there as the login; with none named, it goes nowhere. `ZTC_API_ENVIRONMENT` and `ZERG_DEPLOY_TIER` name none, nor does a proxy the zerg image filled in from its tier (`ZERG_PROXY_URL_SOURCE`). For Zerg Router turns a host sets `ZTC_ROUTER_RUNTIME_GRANT` with `ZERG_ROUTER_BASE_URL`, and a person runs `ztc auth login`; see [Credentials a host hands over](#credentials-a-host-hands-over) |
2446
+ | `ZTC_API_BASE_URL` | The ZergAI platform API (`https://api.zergai.com`, say) that issued `ZTC_AUTH_TOKEN`. The account check, `/zerg` and the zerg tools use it, and model turns can go through its `/api/zrouter` |
2447
+ | `ZERG_PROXY_URL_SOURCE` | Set by the zerg image's entrypoint when it filled `ZERG_PROXY_URL` in itself, from `ZERG_DEPLOY_TIER` or `ZERG_ROUTER_BASE_URL`. ZTC then takes that proxy as naming no platform API, so on its own it gets `ZTC_AUTH_TOKEN` sent neither to that platform's API nor through the proxy. A `ZERG_PROXY_URL` the launcher names itself carries no mark |
2385
2448
  | `ZTC_NO_BROWSER` | Set to `1` so ZTC never opens a browser (logins, `/mirror`, billing); it prints the URL instead. CI and test runs behave this way already |
2386
2449
  | `ZTC_DEBUG` | Enable debug logging |
2387
2450
  | `ZTC_SUBAGENT_DEBUG` | Log sub-agent execution |
@@ -2389,7 +2452,12 @@ unset preserves normal interactive discovery.
2389
2452
  | `ZTC_DICTATION_FILTER` | Disable filler word filter (set to 0) |
2390
2453
  | `ZTC_DOCKER_CONTAINER` | Route file tools through Docker |
2391
2454
  | `ZTC_TODO_STORE` | Override path to the todo JSON file (defaults to `~/.ztc/todos/<projectHash>.json`) |
2392
- | `ZTC_EXTENSION_DISCOVERY` | Set to `explicit` for env-root-plus-builtin discovery with no cwd/repository/home extensions or repo config |
2455
+ | `ZTC_EXTENSION_DISCOVERY` | Set to `explicit` for env-root-plus-builtin discovery with no cwd/repository/home extensions or repo config, or `default` for normal discovery; unset, it is `explicit` under a host's Router runtime grant and `default` otherwise |
2456
+ | `ZTC_MODEL_PINNED` | Set to `1` to pin the session to the provider and model it starts on (`ZTC_PROVIDER` and `ZTC_MODEL`, or `--provider` and `--model`): `/model`, `/models set` and `/models latest`, `/provider`, `/config`'s route settings and Zerg Router address (`zrouter-url`), `/connect`, the agent's own `ztc_command`, the mirror's model picker and routing setting, a resumed session's saved route and a host effort policy that names another model (schema 2) are refused with the pinned route named. A host `--session-file` thread saved on another route runs on the pinned route, and its other settings still apply. Effort and reasoning the model takes can still change. Where `ZTC_LLM_AUTH_MODE` also pins the routing, a refused switch names the pinned route. Not held: a Morph key saved while the session runs (`/config key morph`) takes a session pinned to Morph through Zerg Router to Morph's own API unless `ZTC_LLM_AUTH_MODE=zrouter` holds too; `/profile` can move it to the routing another profile saves unless `ZTC_LLM_AUTH_MODE` pins that, and where the environment names no Zerg Router, `/profile` and `/auth login --url` can change its Zerg Router address; and a new ZTC pane is pinned to the route it opens on: another model when it names one (the web client's "+ ZTC pane", the agent's `create_ztc_pane`), the route new panes start on when it names none (`ZTC_PROVIDER` and `ZTC_MODEL` pass to a pane, `--provider` and `--model` don't) |
2457
+ | `ZTC_PERMISSION_PROFILE_PINNED` | Set to `1` (or `true`) to pin the session's permission profile and sandbox as its startup leaves them: the profile `--permission-profile` names, a host's `--session-file` thread gives it (a `--headless --mirror` resident's) or `config.json` saves, with that profile's definition, the sandbox settings and the tool permissions as ZTC holds them. ZergCloud's hub sets it next to `ZTC_MODEL_PINNED`. ZTC reads it once, as its startup ends (`zerg-ztc-headless` too), so nothing later in the process unsets it. A host that pins them means them to limit the agent: where the profile ZTC would pin limits nothing (`trusted`, the default, `local_full` or an id nothing defines, unless the sandbox settings require the OS sandbox), or runs the agent's commands but asks for no OS sandbox for them (one that only turns `computer_control` off, asks before a capability or limits shell commands or network hosts, where `/status` would say `OS command sandbox: not required, and none is used`), ZTC doesn't start, whatever starts it (a one-prompt run; a resident, one on a host's thread with no settings yet included; a ZTC pane or colony cell a pinned session opens), and exits 2 saying "ZTC did not start: its host pins this session's permission profile and sandbox (ZTC_PERMISSION_PROFILE_PINNED), and the permission profile it would pin, trusted, limits nothing. Start ZTC with --permission-profile and a profile that limits the agent, such as workspace_autonomous, or unset ZTC_PERMISSION_PROFILE_PINNED.", or, for the second, that the profile "lets the agent's commands run outside an OS sandbox, where they reach ZTC's own state and the config.json the pin is taken from. Start ZTC with --permission-profile and a profile that keeps them in one (sandbox.requireOsEnforcement, as workspace_autonomous has) or runs none, or unset ZTC_PERMISSION_PROFILE_PINNED." (`zerg-ztc-headless`, which takes no `--permission-profile`, says to save such a profile as `permissionProfile` in `config.json`). Every other profile that limits the agent is pinned: one that asks for the OS sandbox for its commands, or runs none (`shell_exec` off in it or in the tool permissions), as every built-in one that limits the agent does. From then on, whoever asks (you, a controller, a relayed line, the agent), `/permissions use` and `/permissions set`, a `/profile` switch, `create` or `duplicate` to a config profile that holds other ones, the settings panel's permission profile, tool permission and sandbox rows, a host thread's later `set_session_settings` revision that names another permission profile than the session started on (the thread's then, else the pinned one), a factory reset, which would remove `config.json` (`/config reset`, the settings panel's; `ztc config reset`, run from a shell, takes no pin), and a restart in place, your own `/restart` included, while `config.json` holds an edit to them (ZTC reads the file for it whatever its inode, size and modification time say, so an edit made in place that kept them counts too) are refused with "This session's permission profile and sandbox are pinned by its host (ZTC_PERMISSION_PROFILE_PINNED): ...", which names nothing of the profile, and nothing is saved, nor anything of a refused revision taken. A revision that names that profile is taken without its profile and sandbox, which the pin holds; a session that took no thread's settings as it started, pinned on a profile no revision can name (a resident's own), takes none. The profile's relative file roots (`workspace_autonomous`'s `.`) are resolved once, against the folder the session started in (its `--cwd`, the mounted workspace), and `/permissions` names them: a `/cd` elsewhere (yours, a controller's or a relayed one), an environment the session opens, or the agent built again there moves none, so the agent's file tools outside them are refused, and so are its commands where the profile keeps them in the OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile; under a pinned profile that doesn't, a command there still runs and can read there, unless bubblewrap refuses it a folder where the host's services keep their sockets, and the sandbox, where one is used, holds only its writes to the roots). A restart in place starts the next ZTC in that folder, wherever an environment moved the session, and refuses one that would start elsewhere (a session the resume panel picks that works in another folder); it hands that ZTC the variable, whatever this process's environment says of it by then, and what its pin was taken from as `config.json` or the host's thread gives it, with no built-in profile they don't redefine and no default (so an update that rewords a built-in profile or changes a default doesn't keep that ZTC from starting), and one that finds `config.json` or the host's thread changed them after the restart's check doesn't start, saying "ZTC did not start again in place: the permission settings it would pin changed after the ZTC it replaces checked them: ..." and exiting 2. An agent's `/ztc` compares the pane's saved profile with the pinned one by the folder the pane starts in. A reload takes no `config.json` edit to them, nor to the hooks, MCP servers, skills and workflows, as under a profile that limits the agent, and a save leaves another process's edit as it made it, never writing what the pin holds as yours. `/config scope clear` leaves them (the agent's is refused, and says its host pinned them), `/permissions` shows them and says they are pinned, `/status` names the profile and says "pinned by its host (ZTC_PERMISSION_PROFILE_PINNED)", and a Claude Code or Codex pane you open starts with its permission prompts, whatever `panes.agentPermissions` says. A ZTC pane opened from the session is given the variable and pins what it starts on itself (`--permission-profile` passes to it), or doesn't start where that limits nothing; a colony cell inherits it. Not held: words that skip a Claude Code or Codex pane's permission checks (`/claude --dangerously-skip-permissions`), yours, a controller's or a relayed line's, still do, and a config profile that holds the same permission settings brings its own hooks and MCP servers, as without the pin. Without the variable, or with one that isn't `1` or `true`, nothing changes |
2458
+ | `ZTC_LLM_AUTH_MODE` | `zrouter`, `direct` or `auto`, over the saved Routing setting (`ZERG_LLM_AUTH_MODE` is read when it is unset; the zerg image sets it from its deploy tier). `zrouter` and `direct` pin the routing: a switch to a route that runs another way, from `/model`, `/provider`, `/models latest`, `/config`, `/connect`, the settings panel, the mirror or the agent's `ztc_command`, and a new ZTC pane that names a provider on one, are refused with the mode named, and nothing is saved. That is a local login (Codex, Kimi Code) or a provider's own key under `zrouter`, where Morph runs through Zerg Router even with a Morph key on this machine, and Zerg Router under `direct`. Any model on that routing can still be chosen. The pin refuses switches: it doesn't move a session that starts on another routing (a default saved before it, a `ZTC_PROVIDER` or `--provider` that names a local login), nor refuse a `/profile` switch to a profile saved on one, or a new ZTC pane that names no provider, which starts on the route new panes start on. `auto` picks each provider's routing and pins none |
2459
+ | `ZTC_ROUTER_RUNTIME_GRANT_FILE` | Path of a file holding the host's Router runtime grant, in place of `ZTC_ROUTER_RUNTIME_GRANT`: read once and removed as ZTC starts, so the environment ZTC was started with never holds the grant under `ZTC_ROUTER_RUNTIME_GRANT`. A copy the launcher also sets is still there: ZergCloud's launch sets the grant as `ZERG_API_TOKEN` and `ZTC_AUTH_TOKEN`, and in zrouter mode the zerg image copies `ZERG_API_TOKEN` into `ZTC_AUTH_TOKEN` when that is unset. The file keeps the grant out of ZTC's start environment only when no other variable holds it. A regular file with one name that only its owner can read; see [Credentials a host hands over](#credentials-a-host-hands-over) |
2460
+ | `ZTC_MIRROR_SHARED_SECRET_FILE` | Path of a file holding the mirror's shared secret, in place of `ZTC_MIRROR_SHARED_SECRET`, taken the same way |
2393
2461
  | `ZTC_PLUGIN_PATHS` | Explicit plugin roots (platform-delimited) |
2394
2462
  | `ZTC_MODE_PATHS` | Explicit mode YAML roots (platform-delimited) |
2395
2463
  | `ZTC_DOMAIN_PATHS` | Extra roots for external domain YAML (colon-separated on *nix, `;` on Windows) |
@@ -2401,6 +2469,497 @@ unset preserves normal interactive discovery.
2401
2469
  | `ZTC_SIM_DOMAIN` | Domain for simulation/swarm child panes (mux/pane mode only) |
2402
2470
  | `SDL_MOUSE_RELATIVE_MODE_WARP` | Force SDL warp mode (computer use fallback) |
2403
2471
 
2472
+ #### Credentials a host hands over
2473
+
2474
+ A host that runs ZTC for someone (ZergCloud's resident in each service zerg) routes its model traffic on a Router
2475
+ runtime grant: `ZTC_ROUTER_RUNTIME_GRANT`, for the Router `ZERG_ROUTER_BASE_URL` names (https, or http on this
2476
+ computer's loopback). ZTC sends the grant only to that Router and never saves or shows it.
2477
+
2478
+ **What a launcher sets.** For Router turns on a host credential: `ZTC_ROUTER_RUNTIME_GRANT` (or
2479
+ `ZTC_ROUTER_RUNTIME_GRANT_FILE`, below) with the Router it is for in `ZERG_ROUTER_BASE_URL`, never `ZTC_AUTH_TOKEN`. For
2480
+ a ZergAI platform login: `ZTC_AUTH_TOKEN` with `ZTC_API_BASE_URL`, the platform API that issued it; the ZergAI
2481
+ platform's own launch, which names that API's Router proxy itself in `ZERG_PROXY_URL`
2482
+ (`https://api.zergai.com/api/zrouter`), counts too, and so does a colony cell's `COLONY_PORT`. ZTC sends a
2483
+ `ZTC_AUTH_TOKEN` no platform API is named for nowhere, and says so once (on stderr in a headless run; in the terminal
2484
+ app, in its Logs tab). `ZTC_API_ENVIRONMENT` and `ZERG_DEPLOY_TIER` name no platform API, nor does a Router proxy the
2485
+ zerg image fills in from its tier for a launcher that names none: its entrypoint marks one in `ZERG_PROXY_URL_SOURCE`. A
2486
+ Zerg Router credential ZTC can recognize is no platform login: ZTC sends none (an `sk-zr-` key or another prefix Router
2487
+ issues, a Router JSON Web Token with audience `zergrouter`, or a value it also holds as a Router credential, the grant
2488
+ itself among them) to a platform API call, named or not, in `ZTC_AUTH_TOKEN` or saved in `config.json`. An opaque Router
2489
+ token in `ZTC_AUTH_TOKEN` that ZTC holds nowhere else has no shape it can tell: with a platform API named, it is sent
2490
+ there as the login; with none named, it goes nowhere.
2491
+
2492
+ **The credential store.** As it starts, before any other part of it runs, ZTC takes its credentials out of its
2493
+ environment (`process.env`, which its children are started from; the environment it was started with is another
2494
+ matter, below) and keeps them in memory: the grant, the platform login in `ZTC_AUTH_TOKEN`, the mirror's
2495
+ `ZTC_MIRROR_SHARED_SECRET`, the host's approval, broker and effort-policy tokens (the policy's `ZTC_EFFORT_POLICY_URL`
2496
+ goes with its token), and any other variable holding one of their values, such as the `ZERG_API_TOKEN` copy of the
2497
+ grant ZergCloud passes. The mirror's secret and token that ZTC makes itself go there too, never into its environment.
2498
+ A read-only observer of the mirror is shown none of these values, wherever they appear, nor a pane's live mirror
2499
+ credential that a pane's output prints, though up to 15 of its 43 characters can show where an output piece ends, and
2500
+ one wrapped across a frame's rows under a gutter of other characters than blanks and box drawing (vim's `showbreak`),
2501
+ under one wider than 24 columns, or beside a right-hand border is not withheld.
2502
+
2503
+ **What a child gets.** ZTC keeps these credentials out of every child's own environment: the commands and tools its
2504
+ agent runs, hooks (a hook's `passEnv` can't name one, under its name or a copy's), stdio MCP servers (nor can an MCP
2505
+ server's `passEnv`), ZTC's native helpers, `git`, image helpers, the renderers it starts and the shells you open beside
2506
+ ZTC get your environment without them. That keeps them out of what a child inherits, not out of reach of every program
2507
+ (see Limits below). ZTC hands a child what it needs explicitly, and only these:
2508
+
2509
+ - A ZTC pane or colony cell ZTC opens (yours, its agent's, a split) gets the grant with the Router it names, explicit
2510
+ extension discovery and the host's effort policy, since it routes on them, and keeps them from its own children the
2511
+ same way. A colony cell, and a ZTC pane a renderer starts, also get the platform login in `ZTC_AUTH_TOKEN`; a colony
2512
+ cell also gets its broker token.
2513
+ - A ZTC pane that a pane asks the pane relay to open gets the same only when the relay issued it a launch nonce for
2514
+ a launch of ZTC's own install. Anything else a pane asks for opens as a process pane, holding none of them.
2515
+ - ZTC's own `/restart` keeps everything it was started with. A ZTC pane you start again in place (the desktop app's
2516
+ resume, a replace) and ZTC's relaunch in a new ghostty window (`--new-window`) get what they need in a one-time file
2517
+ that only their command line names, never in their environment or arguments.
2518
+
2519
+ A process or command pane zmux starts again in place (`restart_pane`: zmux's key binding, and the mirror's restart
2520
+ button and an agent's `restart_pane` where zmux runs the session's panes) gets the environment its creation gave it,
2521
+ never zmux's own in its place: a pane ZTC narrowed stays narrowed, and a Claude Code or Codex pane on a sign-in profile
2522
+ comes back on that profile. Its mirror credential is left blank and a one-time credential file on its command line isn't
2523
+ named again, so its workspace tools reach the mirror again only once you reopen it. A resident's headless mirror runs
2524
+ its panes without zmux, and starts them again otherwise (see Limits below).
2525
+
2526
+ **MCP servers and native helpers.** A stdio MCP server and ZTC's native helpers (dictation, speech, ML, computer use,
2527
+ the zlicky overlay) also start without the credentials ZTC routes models with: `ZERG_AUTH_TOKEN`, `ZTC_API_KEY`, each
2528
+ provider's key, a variable your profile names in `apiKeyEnv`, and any variable holding a copy of one, in the terminal
2529
+ app as in a headless run. If an MCP server needs one, list it in the entry's `passEnv`:
2530
+
2531
+ ```json
2532
+ "mcpServers": {
2533
+ "search": { "command": "search-mcp", "passEnv": ["OPENAI_API_KEY"] }
2534
+ }
2535
+ ```
2536
+
2537
+ `passEnv` never gives a server ZTC's own credentials or variables (those above, the mirror's port, the pane relay) or a
2538
+ variable holding a copy of one. The servers that start without a route credential you have set, and whose entries have
2539
+ no `passEnv`, are named in one line at startup, with the variables and never their values; the terminal app shows that
2540
+ line in its transcript too, and `/mcp` shows it under each. An entry with a `passEnv` of its own says what its server
2541
+ needs, and isn't named: `"passEnv": []` says it needs none. An entry's `env` still applies on top. A `passEnv` that
2542
+ isn't a list of variable names keeps the server from starting. `/mcp`, which an agent may run, shows an HTTP server's
2543
+ scheme, host and port, never its URL's userinfo, path or query, and a stdio server's command line with the value after
2544
+ a credential flag (`--token`, `--api-key` and the like) withheld.
2545
+
2546
+ **Under a grant.** A ZTC that holds a grant, one it can use or not, also:
2547
+
2548
+ - Discovers extensions explicitly unless its host sets `ZTC_EXTENSION_DISCOVERY`: it loads plugins, modes, skills and
2549
+ workflows only from the roots its host names (`ZTC_PLUGIN_PATHS` and the other `ZTC_*_PATHS`) and its own builtins,
2550
+ none from its working directory, that directory's repository or HOME, where an agent writes, and it ignores
2551
+ `<cwd>/.ztc/config.json`. A host that wants normal discovery for it sets `ZTC_EXTENSION_DISCOVERY=default`. A
2552
+ browser mirror plugin it should serve is named in `ZTC_PLUGIN_PATHS`.
2553
+ - Starts no pane through MotSi, whatever MotSi's remote view says. MotSi is a program of its own, found on `PATH`, in
2554
+ `~/go/bin` or `~/.local/bin`, where an agent can write, and a ZTC pane inside it would hand it the grant. Each pane
2555
+ starts directly, a ZTC pane with the grant handed over as above, so Zerg Router's Command Central shows none of a
2556
+ resident's panes.
2557
+
2558
+ The desktop app and an npm install, which hold no grant, discover extensions and wrap your panes in MotSi as before.
2559
+
2560
+ **Credentials in files.** The environment a process was started with stays readable by any program running as the same
2561
+ user (`/proc/<pid>/environ` on Linux, `ps -E` on macOS), whatever ZTC later takes out of its own. To keep the grant and
2562
+ the mirror's secret out of ZTC's, hand each over in a file instead, and set no other variable to it:
2563
+
2564
+ | Variable | Description |
2565
+ |----------|-------------|
2566
+ | `ZTC_ROUTER_RUNTIME_GRANT_FILE` | Path of a file holding the Router runtime grant, in place of `ZTC_ROUTER_RUNTIME_GRANT` |
2567
+ | `ZTC_MIRROR_SHARED_SECRET_FILE` | Path of a file holding the mirror's shared secret, in place of `ZTC_MIRROR_SHARED_SECRET` |
2568
+
2569
+ ZTC reads each file once as it starts and then removes it. The file must be a regular file with one name, not a
2570
+ symbolic link or a hard link, that only its owner can read or change (`chmod 600`); a variable can't be set together
2571
+ with its file, and each credential needs a file of its own, not one both variables name. Otherwise ZTC says why,
2572
+ naming the variable and never the value, and exits 2. It reads and checks every file, and a relaunch's one-time handoff,
2573
+ before it removes any, so when one is refused every credential file, and a handoff that passed, stays where it was (a
2574
+ refused one-time handoff in a folder of yours is still removed): fix the one it named and start ZTC again, and that
2575
+ start takes them all.
2576
+
2577
+ **Limits.**
2578
+
2579
+ - The environment ZTC was started with stays readable by any program running as the same user: a grant handed over in
2580
+ `ZTC_ROUTER_RUNTIME_GRANT` can be read there, in ZTC's own; one handed over in `ZTC_ROUTER_RUNTIME_GRANT_FILE` isn't
2581
+ there under that name, but a copy the launcher also sets is. ZergCloud's launch sets the grant as `ZERG_API_TOKEN` and
2582
+ `ZTC_AUTH_TOKEN`, and in zrouter mode the zerg image copies `ZERG_API_TOKEN` into `ZTC_AUTH_TOKEN` when that is unset,
2583
+ so there ZTC's start environment holds the grant even when the host hands it over in the file. The file keeps the
2584
+ grant out of ZTC's start environment only when no other variable holds it.
2585
+ - Each ZTC pane and colony cell ZTC opens starts with the grant in its own environment, where the same holds.
2586
+ - A program running as root, or as the same user, can still read ZTC's memory, where the store holds the values.
2587
+ - zmux refuses to start a ZTC pane again in place (`restart_pane` asks for its session to be resumed): reopen the pane.
2588
+ - A pane zmux starts with `replace_pane`, which carries no environment (one sent through the pane relay included), or
2589
+ restores from a saved workspace, which keeps none, starts with zmux's own environment: ZTC's coordinates, such as the
2590
+ pane relay's socket, and in a resident the provider keys it keeps from its tools. zmux holds none of the credentials
2591
+ above.
2592
+ - A resident's headless mirror runs its panes without zmux: there the mirror's restart button and `restart_pane` start
2593
+ an exited process pane again with a fresh environment, not the one its creation gave it, so a Claude Code or Codex
2594
+ pane on a sign-in profile comes back on the default account.
2595
+ - ZTC used as a library takes nothing out of its environment, so a renderer it starts still inherits what a ZTC pane
2596
+ infers and routes with.
2597
+
2598
+ #### A profile that limits the agent
2599
+
2600
+ A permission profile limits the agent when it names `allowedPaths` or `deniedPaths`, shell or network limits, turns a
2601
+ capability off or asks before one, or keeps commands in an OS sandbox (`sandbox.requireOsEnforcement`, a backend of its
2602
+ own, no network there): `read_only`, the hosted `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` and
2603
+ `hosted_read_only`, and a resident's own profile do; `trusted`, the default, and `local_full` don't. `/status` names the
2604
+ profile the agent runs under and says whether its commands must run in an OS sandbox and what enforces them here
2605
+ (`OS command sandbox: required; enforced by seatbelt`, or
2606
+ `not enforced: no OS sandbox on this host, so commands don't run`), never what the profile allows, which `/permissions`
2607
+ shows: `/status --verbose`, which adds the agent's execution facts, leaves out their permission block (the profile's
2608
+ capabilities, its file roots and the OS sandbox it asks for), whoever asks; the facts in the agent's own prompt keep
2609
+ it. Under one:
2610
+
2611
+ - **ZTC's own state is never the agent's**, but for its commands where they run outside any OS sandbox, and the ML tools
2612
+ in ML mode (see the Limits). Its config folder, `~/.ztc`, its sessions and its runtime's hand-offs in a temp folder
2613
+ are refused to the file tools, search, the project-context index and the host verifiers by name and, for a hard link
2614
+ to one of them, by the file it is, and to the OS sandbox by name. Your own skills folder, `~/.ztc/skills`, stays
2615
+ readable, never writable, where discovery is not explicit. Commands that run outside any OS sandbox read and write
2616
+ that state as any program of yours does: those of a profile that runs them but asks for no OS sandbox for them (one
2617
+ that only turns `computer_control`, `screen_capture`, `ml_inference` or `file_read` off, asks before a capability, or
2618
+ limits shell commands or network hosts), which doesn't start under `ZTC_PERMISSION_PROFILE_PINNED` (below), and, on a
2619
+ host that has none, those of one that asks for it without requiring it (`/status` says
2620
+ `not enforced: no OS sandbox on this host`). A profile whose sandbox block turns the network off
2621
+ (`sandbox.network: false`) asks for the OS sandbox for its commands, as one that turns its `network` capability off
2622
+ does.
2623
+ - **ZTC's own files must be its own, with one name.** ZTC doesn't start while `config.json` (or a backup of it),
2624
+ `router-auth.json`, `~/.ztc/hooks_approved.json`, `~/.ztc/plugin.yaml` or a pooled account's credential file in its
2625
+ config folder (a Codex `auth.json`, a Kimi Code `kimi-code.json`) is a hard link, a symbolic link or not a file:
2626
+ another name, in a folder the agent's commands write, would let them change or read it where no check of a path
2627
+ sees. It says which file and how to give it one name (`cp -p <file> <file>.copy && mv <file>.copy <file>`; the copy
2628
+ no longer follows the file's other name, or the file a link led to, and they no longer get ZTC's edits), that a
2629
+ launch with `--permission-profile trusted` starts with the file as it is, and exits 2 before it starts any MCP server
2630
+ or plugin `config.json` names. It asks under the profile `--permission-profile`,
2631
+ the saved `permissionProfile` or a host's `--session-file` thread gives it. Keep a dotfiles copy of `config.json` as a
2632
+ copy, not a link, if you run such a profile.
2633
+ - **ZTC takes no `config.json` edit to what could widen the profile**: hooks, MCP servers, permission profiles, tool
2634
+ permissions, the sandbox, skills and workflows. A change made in the session itself is taken all the same: the
2635
+ settings panel's skills and workflows rows and its "Attach to local colony" row, and `/config workflows`, change them.
2636
+ A restart in place that the agent's command (`kill -USR1`) or relayed input asks for, or that follows an update ZTC
2637
+ installed, takes no `config.json` edit to them: ZTC stays as it is and says why. It reads `config.json` for that
2638
+ whatever the file's inode, size and modification time say, so another process's edit made in place that kept all three
2639
+ is held back too. Your own `/restart` (a mirror controller's counts as yours), and the session you pick to resume,
2640
+ take `config.json` as it is, and say first which of them it changed. The agent can't clear the session's own settings
2641
+ (`/config scope clear`), which may hold its limits, and a host's thread (`--session-file`) keeps its permission
2642
+ profile, sandbox and instructions when anyone clears them.
2643
+ A config-profile switch (`/profile`, whoever asks for it) keeps the permission profile `--permission-profile` named
2644
+ as ZTC holds it, and refuses a config profile that doesn't define it, or defines it otherwise, rather than fall back
2645
+ to another; a factory reset keeps it too. A switch back to a config profile ZTC ran on, and the copy
2646
+ `/profile duplicate` makes of the one it runs on, keep these settings as ZTC held them there, so an edit it held back
2647
+ still waits for a restart; a config profile ZTC hasn't run on brings its own, as its `config.json` has them.
2648
+ - **A host can pin the profile so no one changes it** (`ZTC_PERMISSION_PROFILE_PINNED=1`, which ZergCloud's hub sets
2649
+ next to `ZTC_MODEL_PINNED`, since several clients reach a resident's mirror). The profile the session holds once it
2650
+ has started, `--permission-profile`'s, a host thread's (a `--headless --mirror` resident's) or the one `config.json`
2651
+ saves, with its definition, the sandbox and the tool permissions, is then its only one. ZTC reads the variable as its
2652
+ startup ends, and so does `zerg-ztc-headless`. Where that profile limits nothing (`trusted`, the default, or
2653
+ `local_full`, with no sandbox setting that requires the OS sandbox), or runs the agent's commands but asks for no OS
2654
+ sandbox for them (`/status` would say `OS command sandbox: not required, and none is used`: one that only turns
2655
+ `computer_control` off, say), where they would reach ZTC's own state and the `config.json` the pin is taken from, ZTC
2656
+ doesn't start, whatever starts it: a one-prompt run, a resident (one on a host's thread that has no settings yet
2657
+ included), a ZTC pane or colony cell a pinned session opens. It exits 2, saying that its host pins the permission
2658
+ settings and the profile it would pin limits nothing, or lets the agent's commands run outside an OS sandbox, and to
2659
+ start ZTC with `--permission-profile` and a profile that limits the agent, or, for the second, one that keeps them in
2660
+ one (`sandbox.requireOsEnforcement`, as `workspace_autonomous` has) or runs none (`zerg-ztc-headless`: to save one as
2661
+ `permissionProfile`), or to unset the variable. Every other profile that limits the agent is pinned: one that asks for
2662
+ the OS sandbox for its commands, or runs none, as every built-in one that limits the agent does. You, a controller, a
2663
+ relayed line and the agent are all
2664
+ refused `/permissions use` and `set`, a `/profile` switch to a config profile that holds other ones, the settings
2665
+ panel's rows for them, a factory reset (it would remove `config.json`; `ztc config reset` from a shell takes no pin),
2666
+ and a restart in place (your `/restart` too) while `config.json` holds an edit to them. The host is refused a thread
2667
+ revision that names another profile than the session started on (its thread's then, or, where its thread had no
2668
+ settings yet, the pinned one), and nothing of the revision is taken; one it takes leaves the pinned profile and
2669
+ sandbox as they are. A session whose thread had no settings yet as it started, pinned on a profile no revision can
2670
+ name (a resident's own), takes none. Each refusal names the variable, never the profile, and `/permissions` and
2671
+ `/status` show the pin. Under it a clear of the session's settings leaves the pinned ones (the agent's own clear is
2672
+ refused, saying so), and a Claude Code or Codex pane you open starts with its permission prompts. A ZTC pane it opens
2673
+ pins what it starts on itself, and an agent's `/ztc` compares the pane's saved profile with the pinned one by the
2674
+ folder the pane starts in. The pinned profile's relative file roots (`workspace_autonomous`'s `.`) are the folder the
2675
+ session started in, its mounted workspace, and `/permissions` names them (`File roots: /path/to/workspace`). A `/cd`
2676
+ elsewhere (yours, a controller's or a relayed one), or an environment the session opens, moves none: the agent, built
2677
+ again there, is still refused its file tools outside them, and its commands there where the profile keeps them in the
2678
+ OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile). Under a
2679
+ pinned profile that doesn't, a command there still runs and can read there (bubblewrap refuses one in a folder where
2680
+ the host's services keep their sockets, below); the sandbox, where one is used, holds only its writes to the roots. A
2681
+ restart in place starts the next ZTC in the folder the session started in, wherever an environment moved the session,
2682
+ and is refused where it would start elsewhere (a session the resume panel picks that works in another folder, or that
2683
+ folder gone). The ZTC that starts is handed the variable itself and what the pin was taken from, as `config.json` or
2684
+ the host's thread gives it: where they changed the pinned settings after the restart's check, it doesn't start, says
2685
+ so ("ZTC did not start again in place: the permission settings it would pin changed after the ZTC it replaces checked
2686
+ them: ..."), and exits 2, so its host or you start it again. No built-in profile they don't redefine and no default
2687
+ goes with it, so an update that rewords a built-in profile or changes a default doesn't keep it from starting.
2688
+ - **Hooks run inside the OS sandbox the profile requires, or not at all**, except under a profile whose agent writes
2689
+ nothing (`read_only`, `hosted_read_only`), where your own approved hooks run as before. In the sandbox a hook reads,
2690
+ beside the system's folders and the project, its own code, read-only: the program its command line starts (found on
2691
+ its `PATH`), the interpreter a script's `#!` names and the script an interpreter is given, so a guard in `~/bin` or a
2692
+ hook run by nvm's `node` starts. Anything else it reads, writes or reaches stays as the agent's commands have it: a
2693
+ hook that logs to a file in `HOME` fails there, as does one that uses the network where the profile keeps commands off
2694
+ it, and its result says the OS sandbox refused it. A PostToolUse hook's failure follows the tool's result as a note,
2695
+ `[hook] PostToolUse hook failed (after <tool> ran; not part of its result)`, so the result stays as the tool gave it
2696
+ and a JSON one still parses from its start. A PostToolUseFailure hook's words and failure follow a failed result the
2697
+ same way, the note beginning `[hook] PostToolUseFailure hook failed (after <tool> failed; not part of its result)`
2698
+ where it failed, so `read_command`'s failed receipt still parses. A PreToolUse hook that fails keeps the tool from
2699
+ running, as one that denies it does; its failure follows the refusal as the same note.
2700
+ - **Where the agent's commands run only inside an OS sandbox** (`requireOsEnforcement`, or a profile that writes
2701
+ nothing), ZTC starts no program the agent chose outside it: `run_and_capture`, `create_terminal_pane`,
2702
+ `write_terminal_pane`, `restart_pane`, `create_ztc_pane`, `create_supervised_ztc_pane`, `workflow`, `adaptation_run`,
2703
+ the computer-use routine tools (`computer_run_routine`, `computer_save_routine`, `computer_list_routines`,
2704
+ `computer_delete_routine`, whose runner runs the agent's JavaScript outside any sandbox), the LSP tools
2705
+ (`goto_definition`, `find_references`, `hover`, `diagnostics`, `lsp_status`, whose language server runs the
2706
+ workspace's code: rust-analyzer runs a crate's build script), and through `ztc_command` `/claude`, `/codex`,
2707
+ `/zerg launch`, `/zerg serve` and `/debug headlines` are refused and not offered, the routine tools whatever the
2708
+ profile says of `computer_control`. A profile that runs no command (`hosted_read_only`, `safe_edits`, `locked_down`)
2709
+ doesn't offer the LSP tools, the routine tools or `create_supervised_ztc_pane` either, and the file an LSP tool names
2710
+ is checked as `read_file`'s path is. A profile that asks before each shell command (`tests_allowed`,
2711
+ `ask_before_mutation`) asks, and you decide; a call it refuses whatever you answer (a working directory or a path
2712
+ outside its roots, a file a patch writes there, the file an LSP tool reads there) is refused without asking you, the
2713
+ last with `Permission denied: path is outside allowed profile roots (<file>). <tool> read nothing.` A language server
2714
+ the LSP tools started stops once the permissions change to ones that don't admit those tools without asking (through
2715
+ `/permissions use` or `set`, the settings panel's permission profile, tool permission and sandbox rows, `/profile` or
2716
+ a host's revision: a switch to `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` or `read_only`,
2717
+ `shell_exec` turned off, the OS sandbox required), so none goes on building the workspace outside the sandbox; under
2718
+ permissions that admit them without asking (`trusted`, `local_full`) it keeps running, and the next call admitted
2719
+ starts one again. The agent built again under the same permissions (after a `/model` switch or a `/cd`) stops none,
2720
+ so one you approved under `tests_allowed` or `ask_before_mutation` keeps running until a change of the permissions
2721
+ stops it as above. `run_command`, `delegate_task`, Claude Code's `Bash`, `WebFetch`, `Glob` and `Task`, MCP tools and
2722
+ `/ztc` (whose pane runs under permissions no wider than this one's) stay. There, a `run_command` (or Codex's
2723
+ `exec_command`) whose working directory is outside the profile's roots is refused before it runs, with
2724
+ `Permission denied: working directory is outside allowed profile roots (<folder>)`, and one in a folder it denies with
2725
+ `Permission denied: working directory is blocked by profile (<folder>)`; each goes on to name the profile's roots to
2726
+ run the command in instead (`Run the command in a folder inside this profile's roots (...)`), or the session's folder,
2727
+ by giving none: macOS's sandbox lets a command read the folder it runs in, which the file tools may not. A working
2728
+ directory in a folder every sandboxed command reads anyway (the system's and its tools', `/usr/bin`) isn't refused,
2729
+ unless the profile denies it. A subfolder of the workspace isn't refused: a command there has the profile's roots, the
2730
+ whole workspace, as its read and write roots, as the file tools do (before, its own subfolder was its only root).
2731
+ Claude Code's `Bash` and Codex's `shell_command`, which write files, are refused a working directory outside the roots
2732
+ under every profile that names them, not only here, with
2733
+ `Permission denied: path is outside allowed profile roots (<folder>)`.
2734
+ - **A profile's relative roots are the session's folder's for the agent's commands too.** The OS sandbox resolves `.`,
2735
+ `./build` or a relative `deniedPaths` entry against the folder the session works in, as the file tools do, wherever
2736
+ the command runs. Under a profile that names `allowedPaths`, the folder a `run_command` names as its `cwd` is no root
2737
+ of its own, so a command there can't write outside the workspace (`.` used to name that folder); one that names none
2738
+ keeps the folder a command runs in as its write root, while its relative `deniedPaths` are the session's folder's. The
2739
+ sandbox audit's `allowed_paths` and `denied_paths` name the roots so. macOS's sandbox holds every root by its real
2740
+ path too, as it matches only real paths, so with the session's folder named through a link (a `/cd` to it by another
2741
+ name) a command still writes in the workspace, and a relative denial still keeps it out of the denied folder.
2742
+ bubblewrap enters a working directory named through a link into the workspace by its real path, and binds read-only
2743
+ one outside the roots that a profile not requiring the sandbox lets a command run in, so the command starts. Where
2744
+ that folder is one where the host's services keep their sockets (`/tmp`, `/run`, `/var/run`, `/var/tmp`, the session's
2745
+ `XDG_RUNTIME_DIR`), lies in one (tmux's `/tmp/tmux-<uid>`) or holds one (`/var`, or `/`, which holds them all), it
2746
+ binds nothing, since a read-only bind would put those sockets in reach (tmux's, the session bus, `docker.sock`): the
2747
+ command doesn't start, and is refused with
2748
+ `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2749
+ `lies in <folder>, where ...`, `holds <folder>, where ...`, and for `/` `holds the folders where ...`), followed by
2750
+ where to run it instead: a folder inside the profile's roots, or none, to run it in the session's folder.
2751
+ - **Where the agent's commands keep the network, bubblewrap binds no root that would put the host's services' sockets in
2752
+ their reach**, as no filter refuses them Unix sockets there: it plans no command whose root is `/`, or is or holds one
2753
+ of the folders above, judged as named and by where a link leads, and its refusal says what to do instead. A root the
2754
+ profile names is refused with "Permission denied: this profile's root is a folder where the host's services keep their
2755
+ sockets (/tmp), which bubblewrap keeps out of a command's reach. Name a project's folder in its allowedPaths instead,
2756
+ to run commands under it." (or `holds <folder>, where ...`, and for `/` `holds the folders where ...`). Its relative
2757
+ root (`workspace_autonomous`'s `.`) in a session started in `/tmp` or `/` keeps every command from running, the
2758
+ refusal ending "Start ZTC in a project's folder, which its relative root (.) then names, to run commands under it."
2759
+ Under a profile that names no `allowedPaths` (`trusted` where the sandbox settings require the OS sandbox, or one of
2760
+ your own), whose only root is the folder a command runs in, that folder is refused where it is `/`, is or holds one of
2761
+ those folders, or lies in one outside the session's folder (`/tmp/tmux-<uid>`), with
2762
+ `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2763
+ `lies in`, `holds` as above), followed by "Run the command in another folder, such as a project's: give it one as its
2764
+ working directory, or none to run it in the session's folder." A root that only lies in one of those folders
2765
+ (`/tmp/proj`) is bound as before, as are the session's own folder there and the folders in it under a profile that
2766
+ names no `allowedPaths`, and a profile without network, whose commands bubblewrap refuses Unix sockets on x86-64 and
2767
+ arm64, plans its commands as before. A plan refused for its roots records no repository of theirs in
2768
+ `~/.ztc/sandbox/known-repositories.json`.
2769
+ - **On macOS, a sandboxed command that keeps the network gets IP networking and the system's name resolver, and connects
2770
+ to no other Unix socket.** It connects out to any address, listens and accepts on local ones and resolves names
2771
+ through the resolver's socket (`mDNSResponder`), but no other Unix socket is in its reach, in its workspace or outside
2772
+ it: not Docker's `docker.sock`, an ssh-agent's (`SSH_AUTH_SOCK`), tmux's or a local database's (PostgreSQL's in
2773
+ `/tmp`), whose programs act outside the sandbox. So `docker`, and a database client that connects through a socket,
2774
+ fail in the sandbox; a database's TCP port on `localhost` still answers. This holds wherever the agent's commands run
2775
+ in the OS sandbox with the network (`workspace_autonomous`, `ask_before_mutation`, `tests_allowed`, a profile of your
2776
+ own that asks for the sandbox), and for a hook run there. `trusted` and `local_full` run commands with no sandbox, so
2777
+ nothing changes there, unless the sandbox settings require one. bubblewrap, on Linux, leaves such a command the
2778
+ sockets in its roots (see the Limits).
2779
+ - **The file tools open only the file the profile admitted**: a link swapped in between the check and the open is
2780
+ refused, and nothing is read or written through it. A unified diff, which `git apply` writes, and `search` open files
2781
+ themselves (see the Limits).
2782
+ - **A sandboxed command can't write where a repository names programs.** Where the agent's commands write inside an OS
2783
+ sandbox (`workspace_autonomous`, `ask_before_mutation`, `tests_allowed`, a resident's own profile), it commits,
2784
+ stages, branches, fetches and pushes as before, but in every repository ZTC finds that it can write (the session's,
2785
+ the ones your workspace holds down to four folders deep, their linked worktrees and submodules; the Limits below name
2786
+ those it doesn't find), `.git/config`, `config.worktree`, the `commondir` of a git directory, a worktree's or
2787
+ submodule's `.git` file, the hooks folder and an untracked `core.hooksPath` folder are read-only to it, on macOS
2788
+ missing ones included. On Linux, of the missing ones, only the common config and the hooks folders are: a `commondir`
2789
+ or `config.worktree` the command creates, or a link among them it replaces, stands until the command ends. Everywhere,
2790
+ `.git` and the folders above it can't be moved away or removed. A repository ZTC has found stays protected in that
2791
+ ZTC, even after a command removes its `HEAD`, moves its refs or objects aside, removes what it may of it, or fills the
2792
+ folders ZTC looks through, and in every one started after it while the record holds it (ZTC keeps the 512 found last
2793
+ in `~/.ztc/sandbox/known-repositories.json`: see the Limits), and a `.git` that git takes for no repository is
2794
+ protected where ZTC looks; when ZTC stops looking
2795
+ for repositories at one of its limits, the command's result says where. When a command leaves one of these
2796
+ repositories one git takes for none (its `HEAD` removed or rewritten, its `refs` or `objects` moved aside), ZTC puts
2797
+ back what it broke as soon as the command ends, before anything reads its result, and the result says what it put
2798
+ back: from then on your git there finds that repository again, not one the command made in a folder above it (while
2799
+ the command runs, it doesn't: see the Limits). It may still start repositories (`git init`, `git clone`,
2800
+ `git worktree add`, `git submodule update` of an initialized submodule), on macOS as on Linux: a repository it makes
2801
+ is its own in that command and protected from its next command on. A checkout, a commit, a branch switch or a detached
2802
+ `HEAD` is never undone. On Linux, ZTC undoes a `commondir` or `config.worktree` a command made in a protected git
2803
+ directory, and a protected link it replaced, when the command ends, and the command's result says so. The file tools
2804
+ refuse the `core.hooksPath` folder and a `.git/config` link's target as they refuse `.git`. So `git config`,
2805
+ `git remote add`, `git branch -m`, `git submodule init` and `git submodule update --init`, hook installers, and
2806
+ `rm -r` of a folder that holds one of these repositories fail there, and `git push -u`, `git switch` to a branch only
2807
+ the remote has and `git checkout --track` say they set up tracking but record no upstream: run those yourself. The
2808
+ command's result says so in its sandbox notes: which file the sandbox kept, and the command to run. Hooks your
2809
+ repository tracks (a `.githooks` folder, husky's) are its code, which the agent may change like any file: the first
2810
+ command in that repository is told so, and you review them as you review code.
2811
+ - **ZTC's own git in the work tree starts no program the repository's config names** where the agent's commands can
2812
+ write that config: the startup snapshot, `/status`, `/runtime`, the work check and a verified command's receipt read
2813
+ the repository's root, HEAD, branch and recent commits, never the work tree's status or diff, which show as not read.
2814
+
2815
+ Under every profile, the one that limits nothing included, ZTC's own git in your work tree (the startup snapshot,
2816
+ `/status`, `/runtime`, `/diff`, the work check, a verified command's receipt, session isolation, `/batch`, the
2817
+ project-context index) runs git's own diff and log: it starts no fsmonitor, external diff, textconv driver or signature
2818
+ program the repository's config names, and `/diff` shows git's own diff. A clean filter that `.gitattributes` selects
2819
+ (`filter.<name>.clean` or `process`) still runs where that git reads a status or a diff, and `/diff` shows the content
2820
+ after it; where the agent's commands can write that config under a profile that limits it, the startup snapshot and the
2821
+ other reads the item above names read no status or diff. Your own git commands, and the agent's, keep the repository's
2822
+ programs.
2823
+
2824
+ **Limits.**
2825
+
2826
+ - Seatbelt and bubblewrap deny ZTC's own state by path, so a sandboxed command reads and writes through a hard link to
2827
+ one of its files that something outside the sandbox made on the same filesystem; the file tools refuse such a link by
2828
+ identity, and ZTC checks its own files' names (above) only as it starts. Keep `HOME` and `ZTC_CONFIG_DIR`, and
2829
+ `ZTC_SESSIONS_DIR` and `ZTC_WORKSPACE_LAYOUT_DIR` where they are set, on another filesystem than the workspace, and no
2830
+ such link to them can exist. ZTC's hand-offs in the temp folders (`TMPDIR`'s and `/tmp`) can still be linked where
2831
+ those share the workspace's filesystem, as they usually do on macOS.
2832
+ - That startup check doesn't look again later: not at a profile chosen after startup (a `/permissions` switch, hosted
2833
+ settings sent to a running ZTC), nor at an account added to the pool after it, a CLI's own sign-in (in
2834
+ `~/.ztc/agent-profiles`, or a `codex_home` account's folder) or an account's file kept outside ZTC's config folder.
2835
+ - On macOS a sandboxed command under a profile that writes can signal your other processes, ZTC's included: it can
2836
+ stop ZTC, or ask it to start again in place (`kill -USR1`), which takes no `config.json` edit to the settings above.
2837
+ bubblewrap gives a command processes of its own.
2838
+ - On Linux, bubblewrap refuses no Unix socket to a command whose profile leaves it the network. It keeps the folders
2839
+ where the host's services keep their sockets out of the command's reach (above), but the command shares the host's
2840
+ network, and with it the host's abstract sockets, and reaches a socket file in any folder it binds: a root at or
2841
+ above your home folder holds the sockets programs keep there (Docker Desktop's `~/.docker/desktop/docker.sock`), and
2842
+ a profile of your own that writes nothing and names no `allowedPaths` binds every folder, read-only, but the socket
2843
+ folders. `read_only` keeps its commands off the network and, on x86-64 and arm64, refuses them Unix sockets.
2844
+ - On Linux, `/status` says `enforced by bubblewrap` wherever `bwrap` is on `PATH`, without checking that it can create
2845
+ the namespaces ZTC asks of it. Where it can't (a host or container that restricts user namespaces), every sandboxed
2846
+ command fails with bubblewrap's error, and none runs outside the sandbox.
2847
+ - A restart in place checks `config.json` before it starts the next ZTC, which reads the file again as it starts: an
2848
+ edit another process makes in between to the hooks, MCP servers, skills or workflows is taken. Under
2849
+ `ZTC_PERMISSION_PROFILE_PINNED`, one to the pinned permission settings keeps that ZTC from starting instead.
2850
+ - Two restarts aren't restarts in place: a colony cell's `/restart` asks its overseer to start the cell again, and the
2851
+ desktop app starts ZTC again itself once it has installed an update. Neither checks `config.json` first, nor hands the
2852
+ ZTC it starts what the pin was taken from: that ZTC takes the permission settings from `config.json` as a fresh start
2853
+ does, and pins them where its environment holds `ZTC_PERMISSION_PROFILE_PINNED`.
2854
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, ZTC takes the pin as its startup ends, after it has started the MCP servers
2855
+ `config.json` names: one that then doesn't start (the profile it would pin limits nothing or lets the agent's commands
2856
+ run outside an OS sandbox, or the pinned settings changed after a restart's check) has started them by then.
2857
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, a profile that asks for the OS sandbox for the agent's commands without
2858
+ requiring it (one that names `allowedPaths`, or keeps them off the network) is pinned, and on a host with no OS
2859
+ sandbox (Linux without bubblewrap) its commands run outside any, as `/status` says
2860
+ (`OS command sandbox: not required; not enforced: no OS sandbox on this host`). Give it
2861
+ `sandbox.requireOsEnforcement`, and there they don't run.
2862
+ - `--new-window` in Terminal or iTerm starts the new window's ZTC in a shell of its own, which ZTC hands neither
2863
+ `ZTC_PERMISSION_PROFILE_PINNED` nor `ZTC_MODEL_PINNED`: that ZTC pins neither.
2864
+ - Settings that name programs ZTC runs when you ask aren't kept as ZTC started with them: the Codex app server's
2865
+ command, arguments and sandbox, the Shannon runner's command, custom pane options, remote resources and a worker
2866
+ endpoint.
2867
+ - Without a host's grant, extension discovery stays as it is: ZTC loads plugins, modes, skills and workflows from its
2868
+ working directory and that directory's repository as it starts, where the agent's commands can write, and reads a
2869
+ skill or workflow written into a folder it already reads while it runs. Set `ZTC_EXTENSION_DISCOVERY=explicit` to
2870
+ load only the roots you name.
2871
+ - Your own `/zerg launch` still runs Poetry in the working directory's `zerg/` project, which the agent may have
2872
+ written, as `make` there would.
2873
+ - A headless run with no approval client approves what a profile that asks would ask you (`--approval-url` hands those
2874
+ decisions to a service), so there the tools above that start a program outside the sandbox can run. Under
2875
+ `--computer-use`, the computer-control tools can type into any window.
2876
+ - A mirror you start in the terminal UI (`ztc --mirror`, `/mirror`) with sign-in off, the default outside production,
2877
+ answers anyone on this computer (see the mirror's section) and takes their input as yours: under a profile that
2878
+ leaves the agent's commands the network (`workspace_autonomous`), a command of the agent's could post
2879
+ `/permissions use trusted` to its port as you, and widen its own permissions. Sign-in (`ZTC_MIRROR_REQUIRE_AUTH=1`)
2880
+ keeps it out, as do the desktop app's mirror and the one a zmux session starts by itself, which answer only callers
2881
+ with a credential; under `ZTC_PERMISSION_PROFILE_PINNED`, `/permissions use` is refused whoever asks. Turn sign-in on
2882
+ for a mirror you run under such a profile.
2883
+ - Where a profile lets the agent start a program outside the OS sandbox (`trusted`, `local_full`, a profile of your own
2884
+ that doesn't require the sandbox, or one that asks, once you approve), the LSP tools start their language server
2885
+ outside any sandbox, and it runs the workspace's code there as it builds it (rust-analyzer runs a crate's build
2886
+ scripts and proc macros).
2887
+ - In ML mode, `ml_load_model` and `ml_train` open the files their arguments name (`weights_path`, `data_path`,
2888
+ `save_weights_path`) through ZTC's ML helper (`ztc-ml`), which runs outside the OS sandbox, and no profile root
2889
+ checks those paths: under a profile that leaves `ml_inference` on (`workspace_autonomous`, `ask_before_mutation`,
2890
+ which doesn't ask before them, `hosted_read_only`), the agent can have the helper read a file outside its roots, or
2891
+ in ZTC's own state, and `ml_train` write its weights there. ML mode is a launch choice (`--ml`): without it ZTC
2892
+ offers no ML tool, and a profile with `ml_inference: false` (`read_only`, `safe_edits`, `tests_allowed`,
2893
+ `locked_down`) refuses them.
2894
+ - The file tools check what they opened, but a unified diff, which `git apply` writes, and `search`, which runs
2895
+ ripgrep, open files themselves.
2896
+ - Git in a workspace a sandboxed command writes:
2897
+ - While a command runs, git in a repository it broke looks in the folders above. A command may remove or rewrite a
2898
+ repository's `.git/HEAD`, or move its `refs` or `objects` aside (checkouts and commits write them): git then takes
2899
+ that folder for no repository and looks in the folders above it, where the same command may make a repository of its
2900
+ own (`git init` there is allowed, and so is a `.git` file naming a git directory it made). ZTC puts the broken
2901
+ repository back when the command ends, before anything reads its result, so from then on your git there, or a host
2902
+ service's, finds the repository again. Until then, while the command runs (a long build, a server it keeps in the
2903
+ foreground), git in that folder reads the config above and starts the programs it names: run no git in the agent's
2904
+ workspace, and keep a host service's git out of it, while a sandboxed command runs there. On macOS, a process the
2905
+ command leaves running (`cmd &`, a server; ZTC stops them as it exits) may break the repository again after that,
2906
+ and git there reads what is above until the next command ends and ZTC puts it back again; under bubblewrap nothing
2907
+ a command starts outlives it. A repository no ZTC saw whole
2908
+ (already broken when a plan first found it) can't be put back: its config and hooks are protected where it is, but
2909
+ git there looks above until you fix its `HEAD`. Where a command moved `refs` or `objects` aside, ZTC puts back an
2910
+ empty folder, and the repository's branches or commits are where the command moved them. A repository at a writable
2911
+ root itself has no writable folder above it.
2912
+ - A repository a command makes is its own in that command: `git init`, `git clone`, `git worktree add`, a submodule it
2913
+ checks out or absorbs, a `.git` file it writes naming a git directory, in any folder of a writable root, a folder of
2914
+ your work tree included. A program it plants in that repository's config, or a submodule's (which your
2915
+ `git status` in the superproject runs), in the same command runs when you run git there. The next command's plan
2916
+ finds it if the walk reaches it, and protects it from then on.
2917
+ - What a plan protected stays protected in that ZTC and in every one started after it, from its first command, until
2918
+ its git directory is gone (you removed it): ZTC keeps the repositories its plans found, with what each protected, in
2919
+ `~/.ztc/sandbox/known-repositories.json` (under `HOME`, even where `ZTC_CONFIG_DIR` names another config folder),
2920
+ and reads it as it starts. The record holds 512 repositories at most, those found last: one found before them drops
2921
+ out of it, and a ZTC started later protects that one only once its own plans find it again. A sandboxed command can
2922
+ push one out by making git directories where the walk finds them (`mkdir -p x{1..600}/.git/hooks`); the later ZTC
2923
+ says nothing of it. A record ZTC can't take (you removed it, it is a link or has another name, it can't be read or
2924
+ isn't in the form ZTC writes) leaves it starting a new one, which the first command's result says once, as it says
2925
+ when it can't write the record (on a fresh `HOME`, where no ZTC has kept one, it starts one without a word); that
2926
+ ZTC protects a `.git` that git takes for none by where it is, where it looks, but not such a repository's
2927
+ `core.hooksPath` folder outside `.git` (an untracked `.githooks`, husky 9's `.husky/_`) until a plan asks git about
2928
+ the repository while it is whole.
2929
+ - The walk stops 4 folders below a writable root and after 2,000 folders, and enters no `node_modules`; a plan reads
2930
+ 512 folders of a `.git/modules` and 256 linked worktrees at most, and asks git about 48 repositories at most. A
2931
+ repository, submodule or worktree past those that no plan of this ZTC or of one before it found keeps a writable
2932
+ config and hooks, unless it is the session's or the command's, and one past the 48 git runs keeps its
2933
+ `core.hooksPath` folder writable. A command can keep a repository no plan has found out of the walk's reach by
2934
+ filling the folders it reads first; one already found stays protected in this ZTC, and in those started after it
2935
+ while the record holds it. A plan that stops at a limit says so in the command's result and its audit, naming where.
2936
+ - Each command's plan asks git about the repositories it knows, every time: in a workspace that holds many, a trivial
2937
+ command takes longer under such a profile (about a second with 40 repositories, on a busy Mac).
2938
+ - Hooks a repository tracks are its code (a `core.hooksPath` folder it tracks, and the tracked scripts husky 9's
2939
+ generated `.husky/_` hooks run): a sandboxed command can change them, through the index too, and git runs them for
2940
+ whoever commits next. A `core.hooksPath` folder a plan protected stays read-only to sandboxed commands, in the ZTCs
2941
+ started after it too, even once you start tracking hooks there (a sandboxed checkout then can't update them) or stop
2942
+ using it. To have ZTC look afresh, remove `~/.ztc/sandbox/known-repositories.json` while no ZTC runs: that forgets
2943
+ every repository ZTC found, and its plans find again those they reach.
2944
+ - `rm -r` of a folder that holds a repository ZTC found fails after removing what the command may write there (the
2945
+ work tree's files, objects, refs, `HEAD`), leaving `.git` with its config and hooks, which stay read-only to later
2946
+ commands; ZTC then puts back its `HEAD` and empty `refs` and `objects` folders, so git takes it for a repository
2947
+ with no commits. `git worktree remove` or `move` of a worktree ZTC found fails too (a worktree a command adds, it
2948
+ can remove in that same command). Remove those yourself: the command's result names them.
2949
+ - A git directory under another name that a command makes (a bare `x.git`, a `--separate-git-dir`), or a `.git` file
2950
+ in a folder of its own outside every work tree, is the command's: your git there reads its config. ZTC's own git
2951
+ never takes a bare repository it did not name (`safe.bareRepository=explicit`);
2952
+ `git config --global safe.bareRepository explicit` does the same for yours.
2953
+ - On Linux (bubblewrap), a `commondir` or `config.worktree` a command creates in a protected git directory, or a
2954
+ protected `.git/config` or `.git` link it replaces, stands until the command ends, when ZTC removes it or puts the
2955
+ link back. Until then, git outside the sandbox in that repository (yours, or a host service's) reads what the
2956
+ command made there, such as a `commondir` that points it at a config of the command's, and starts the programs that
2957
+ config names.
2958
+ - An `include.path` in a repository's config that names a file in the work tree, and a `HOME` inside a writable root
2959
+ (its `~/.gitconfig`), are not covered. Both sandboxes deny by path (Seatbelt by its rules, bubblewrap by a read-only
2960
+ mount of that path): a hard link to `.git/config` made before the sandbox is still written through (neither lets a
2961
+ command make one).
2962
+
2404
2963
  ---
2405
2964
 
2406
2965
  ## License