@zergai/ztc 0.26.3-dev.202611211442 → 0.26.5-dev.202611240151

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 (239) hide show
  1. package/README.md +671 -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 +74 -9
  31. package/dist/agent/backends/zrouter_stream.js +225 -43
  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 +28 -1
  43. package/dist/agent/commands/types.d.ts +31 -3
  44. package/dist/agent/commands/update.js +6 -0
  45. package/dist/agent/commands/zerg.d.ts +6 -0
  46. package/dist/agent/commands/zerg.js +43 -1
  47. package/dist/agent/commands/ztc_pane.js +8 -5
  48. package/dist/agent/factory.js +22 -4
  49. package/dist/agent/request_encoder.js +11 -2
  50. package/dist/agent/runtime/command_jobs.js +3 -0
  51. package/dist/agent/runtime/cpu_benchmark.js +2 -0
  52. package/dist/agent/runtime/execution_context.d.ts +8 -1
  53. package/dist/agent/runtime/execution_context.js +8 -2
  54. package/dist/agent/runtime/policy.d.ts +66 -5
  55. package/dist/agent/runtime/policy.js +161 -33
  56. package/dist/agent/runtime/remote_broker_transport.js +4 -2
  57. package/dist/agent/runtime/source_verification.js +12 -7
  58. package/dist/agent/runtime/tool_runtime.js +165 -58
  59. package/dist/agent/runtime/verifier_capture.d.ts +1 -1
  60. package/dist/agent/runtime/verifier_capture.js +6 -0
  61. package/dist/agent/runtime/work_base.js +43 -18
  62. package/dist/agent/tools/adaptation.js +7 -5
  63. package/dist/agent/tools/apply_patch.js +62 -5
  64. package/dist/agent/tools/background.js +2 -0
  65. package/dist/agent/tools/benchmark_cpu.js +2 -0
  66. package/dist/agent/tools/bus_message.d.ts +4 -2
  67. package/dist/agent/tools/bus_message.js +21 -3
  68. package/dist/agent/tools/delegate.js +2 -0
  69. package/dist/agent/tools/file.d.ts +12 -1
  70. package/dist/agent/tools/file.js +92 -11
  71. package/dist/agent/tools/lsp.d.ts +12 -0
  72. package/dist/agent/tools/lsp.js +61 -5
  73. package/dist/agent/tools/ml.js +36 -9
  74. package/dist/agent/tools/pane.js +18 -46
  75. package/dist/agent/tools/project_context.js +5 -2
  76. package/dist/agent/tools/routine.js +16 -4
  77. package/dist/agent/tools/screenshot.d.ts +8 -0
  78. package/dist/agent/tools/screenshot.js +39 -25
  79. package/dist/agent/tools/search.js +27 -1
  80. package/dist/agent/tools/shell.js +7 -1
  81. package/dist/agent/tools/supervision.js +6 -0
  82. package/dist/agent/tools/types.d.ts +18 -0
  83. package/dist/agent/tools/zerg.js +15 -19
  84. package/dist/agent/tools/ztc_command.d.ts +15 -4
  85. package/dist/agent/tools/ztc_command.js +48 -34
  86. package/dist/app/command_context.js +6 -1
  87. package/dist/app/conversation_compaction.d.ts +6 -3
  88. package/dist/app/conversation_compaction.js +6 -3
  89. package/dist/app/tool_callbacks.js +1 -0
  90. package/dist/audio/sfx.js +6 -0
  91. package/dist/batch/worktree.js +8 -7
  92. package/dist/board/client.js +2 -1
  93. package/dist/cli_main.d.ts +1 -0
  94. package/dist/cli_main.js +145 -45
  95. package/dist/cli_ratatui.d.ts +33 -3
  96. package/dist/cli_ratatui.js +275 -53
  97. package/dist/conductor_branch.js +4 -1
  98. package/dist/config/host_credentials.d.ts +157 -0
  99. package/dist/config/host_credentials.js +589 -0
  100. package/dist/config/model_pin.d.ts +111 -0
  101. package/dist/config/model_pin.js +182 -0
  102. package/dist/config/own_state_files.d.ts +35 -0
  103. package/dist/config/own_state_files.js +161 -0
  104. package/dist/config/permission_pin.d.ts +161 -0
  105. package/dist/config/permission_pin.js +221 -0
  106. package/dist/config/permissions.d.ts +9 -2
  107. package/dist/config/permissions.js +14 -3
  108. package/dist/config/platform_login.d.ts +72 -0
  109. package/dist/config/platform_login.js +111 -0
  110. package/dist/config/profile_limits.d.ts +34 -0
  111. package/dist/config/profile_limits.js +66 -0
  112. package/dist/config/provider_api_key_env.js +3 -2
  113. package/dist/config/provider_models.d.ts +6 -1
  114. package/dist/config/provider_models.js +38 -11
  115. package/dist/config/router_runtime_grant.d.ts +9 -6
  116. package/dist/config/router_runtime_grant.js +12 -9
  117. package/dist/config/settings_merge.d.ts +22 -0
  118. package/dist/config/settings_merge.js +75 -0
  119. package/dist/config/types.d.ts +8 -0
  120. package/dist/config.d.ts +303 -2
  121. package/dist/config.js +940 -39
  122. package/dist/context/project_intelligence.d.ts +11 -2
  123. package/dist/context/project_intelligence.js +18 -7
  124. package/dist/desktop/daily/desktop_wiring.js +8 -6
  125. package/dist/desktop/daily/native_pane_launcher.js +2 -1
  126. package/dist/desktop/daily/native_tool.js +4 -3
  127. package/dist/desktop/daily/process_identity.js +10 -2
  128. package/dist/desktop/daily/source_baseline.js +4 -3
  129. package/dist/diagnostics/native_terminal_benchmark.js +3 -2
  130. package/dist/diagnostics/session_export.js +27 -14
  131. package/dist/emulation/catalog.js +6 -1
  132. package/dist/emulation/tool_adapters.js +13 -3
  133. package/dist/extension_discovery.d.ts +12 -2
  134. package/dist/extension_discovery.js +52 -7
  135. package/dist/headless.d.ts +8 -0
  136. package/dist/headless.js +46 -11
  137. package/dist/headless_cli.js +18 -1
  138. package/dist/headless_workflow_trigger.js +1 -1
  139. package/dist/hooks/dispatcher.d.ts +8 -0
  140. package/dist/hooks/dispatcher.js +22 -2
  141. package/dist/hooks/lifecycle.d.ts +6 -0
  142. package/dist/hooks/lifecycle.js +1 -0
  143. package/dist/hooks/program_files.d.ts +10 -0
  144. package/dist/hooks/program_files.js +175 -0
  145. package/dist/hooks/runner.d.ts +11 -1
  146. package/dist/hooks/runner.js +112 -11
  147. package/dist/hooks/types.d.ts +2 -0
  148. package/dist/host_credentials_startup.d.ts +6 -0
  149. package/dist/host_credentials_startup.js +17 -0
  150. package/dist/instance_registry.d.ts +6 -2
  151. package/dist/instance_registry.js +9 -15
  152. package/dist/lsp/client.d.ts +5 -2
  153. package/dist/lsp/client.js +42 -5
  154. package/dist/lsp/manager.d.ts +1 -1
  155. package/dist/lsp/manager.js +4 -5
  156. package/dist/mcp/client.d.ts +2 -0
  157. package/dist/mcp/client.js +116 -17
  158. package/dist/mcp/registry.d.ts +12 -0
  159. package/dist/mcp/registry.js +15 -1
  160. package/dist/modes/handlers.js +14 -5
  161. package/dist/panes/agent_cli.d.ts +23 -1
  162. package/dist/panes/agent_cli.js +96 -1
  163. package/dist/panes/agent_panes.d.ts +27 -4
  164. package/dist/panes/agent_panes.js +73 -11
  165. package/dist/panes/editor_program.d.ts +8 -0
  166. package/dist/panes/editor_program.js +25 -0
  167. package/dist/panes/motsi.d.ts +11 -1
  168. package/dist/panes/motsi.js +14 -1
  169. package/dist/panes/pane_registry.d.ts +28 -1
  170. package/dist/panes/pane_registry.js +25 -0
  171. package/dist/panes/ztc_launch.d.ts +8 -0
  172. package/dist/panes/ztc_launch.js +26 -1
  173. package/dist/profile_baseline.js +2 -0
  174. package/dist/router_auth.js +2 -1
  175. package/dist/runtime_info.js +46 -36
  176. package/dist/shannon/runtime.js +8 -0
  177. package/dist/simulation/domains/loader.d.ts +2 -1
  178. package/dist/simulation/domains/loader.js +19 -2
  179. package/dist/terminal_attach.js +2 -1
  180. package/dist/types.d.ts +21 -0
  181. package/dist/ui/ratatui/headless_pane_manager.d.ts +1 -1
  182. package/dist/ui/ratatui/headless_pane_manager.js +16 -6
  183. package/dist/ui/ratatui/pane_credential_broker.d.ts +17 -4
  184. package/dist/ui/ratatui/pane_credential_broker.js +23 -5
  185. package/dist/ui/ratatui/pane_relay.d.ts +66 -0
  186. package/dist/ui/ratatui/pane_relay.js +158 -3
  187. package/dist/ui/ratatui/process.d.ts +15 -1
  188. package/dist/ui/ratatui/process.js +127 -163
  189. package/dist/ui/ratatui/protocol.d.ts +11 -1
  190. package/dist/ui/ratatui/protocol.js +6 -0
  191. package/dist/ui/ratatui/ztc_launch_trust.d.ts +87 -0
  192. package/dist/ui/ratatui/ztc_launch_trust.js +249 -0
  193. package/dist/utils/admitted_open.d.ts +40 -0
  194. package/dist/utils/admitted_open.js +111 -0
  195. package/dist/utils/clipboard.js +2 -1
  196. package/dist/utils/computer_native.js +12 -56
  197. package/dist/utils/dictation.js +15 -12
  198. package/dist/utils/dictation_native.js +17 -81
  199. package/dist/utils/git_probe_options.d.ts +28 -0
  200. package/dist/utils/git_probe_options.js +30 -0
  201. package/dist/utils/git_program_files.d.ts +145 -0
  202. package/dist/utils/git_program_files.js +1282 -0
  203. package/dist/utils/git_repository_programs.d.ts +13 -0
  204. package/dist/utils/git_repository_programs.js +38 -0
  205. package/dist/utils/host_shell.js +2 -1
  206. package/dist/utils/idle_compaction.js +8 -1
  207. package/dist/utils/image_fit.d.ts +4 -1
  208. package/dist/utils/image_fit.js +6 -2
  209. package/dist/utils/image_preview.js +3 -2
  210. package/dist/utils/ml_native.js +11 -56
  211. package/dist/utils/native_install.d.ts +55 -0
  212. package/dist/utils/native_install.js +107 -0
  213. package/dist/utils/open_url.js +2 -0
  214. package/dist/utils/router_catalog.js +9 -2
  215. package/dist/utils/sandbox.d.ts +82 -2
  216. package/dist/utils/sandbox.js +648 -93
  217. package/dist/utils/shell.js +31 -12
  218. package/dist/utils/subprocess_env.d.ts +116 -18
  219. package/dist/utils/subprocess_env.js +213 -51
  220. package/dist/utils/system_ps.d.ts +5 -0
  221. package/dist/utils/system_ps.js +30 -0
  222. package/dist/utils/tts.js +5 -0
  223. package/dist/utils/tts_native.js +13 -60
  224. package/dist/utils/zlicky_overlay.js +17 -50
  225. package/dist/utils/ztc_own_state.d.ts +58 -0
  226. package/dist/utils/ztc_own_state.js +236 -0
  227. package/dist/web/mirror_authenticator.d.ts +7 -6
  228. package/dist/web/mirror_authenticator.js +12 -10
  229. package/dist/web/mirror_stream.d.ts +27 -8
  230. package/dist/web/mirror_stream.js +83 -24
  231. package/dist/web/observer_secret_redaction.d.ts +8 -5
  232. package/dist/web/observer_secret_redaction.js +210 -40
  233. package/dist/web/pane_credentials.d.ts +15 -1
  234. package/dist/web/pane_credentials.js +36 -3
  235. package/dist/worker/executor.js +3 -1
  236. package/dist/workspace_collision.js +12 -10
  237. package/dist/zlm-embed.mjs +6118 -2812
  238. package/npm-shrinkwrap.json +1 -1
  239. package/package.json +43 -16
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,13 @@ 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 without requiring an OS sandbox for them, whether it asks for none (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`) or only asks for one (one that names `allowedPaths` or `deniedPaths`, keeps commands off the network or names a sandbox backend, where `/status` would say `OS command sandbox: not required; enforced by seatbelt`, and under which the LSP tools, `run_and_capture` and `workflow` start programs outside the sandbox), 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 "doesn't require an OS sandbox (sandbox.requireOsEnforcement), so the agent's commands, and the programs some of its tools start, can run outside one, 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 requires the OS sandbox (set sandbox.requireOsEnforcement to true in it, as workspace_autonomous does) or runs no command (shell_exec off), 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 requires the OS sandbox for its commands (`sandbox.requireOsEnforcement` in it or in the sandbox settings, or one that writes nothing), or runs none (`shell_exec` off in it or in the tool permissions), as every built-in one that limits the agent does. Your own commands (`!cmd` and `/shell`, `/diff`'s git, the commands `/optimize` runs), yours or a controller's, then run only inside the OS sandbox too, as the agent's do, under the pinned profile's roots with ZTC's own state hidden, even where the profile runs none of the agent's, and where no OS sandbox is usable they are refused with "OS sandbox enforcement required but unavailable: ..." (the Ink interface's run outside any: see the Limits under [A profile that limits the agent](#a-profile-that-limits-the-agent)). 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 there, which every pinned profile that runs them keeps in the OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile). 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, or that folder gone); 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 (in `ZTC_PERMISSION_PIN_SOURCE`, which that ZTC, `zerg-ztc-headless` too, takes out of its environment as it starts, before any MCP server connects, and which no MCP server, hook, pane or command is given, whatever an MCP server's `passEnv` names), 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. Nor does a pinned ZTC update itself, since an update would put a ZTC its host didn't choose in its place: `/update` installs nothing and says "ZTC doesn't update itself in a session its host pins (ZTC_PERMISSION_PROFILE_PINNED): an update replaces the ZTC that holds the session's permission profile and sandbox, and a ZTC its host didn't choose might not hold them. Nothing was installed. Update ZTC where its host starts it, or with `ztc update` from a shell.", the native interface's start-up check, which installs a newer release with npm and starts it in place, doesn't run (the Ink interface's still installs one: see the Limits under [A profile that limits the agent](#a-profile-that-limits-the-agent)), and the desktop app is given no context to start that ZTC again with, without which its updater installs no app update while that ZTC runs. 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 or doesn't require the OS sandbox; 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_PROMPT_CACHE_TTL` | The prompt cache ZTC asks for on a Claude model: `1h` (the default), `5m` or `off`, in any letter case. With `off`, ZTC's requests to Anthropic, and on Zerg Router's native Anthropic route, carry no `cache_control`, and a Claude turn on Zerg Router's chat route (on a host's Router runtime grant or your own Router key or sign-in) asks Router for no prompt cache either (`prompt_cache: false`), so Router adds none to a long system prompt and can price the turn (one it records without a price counts against a dollar spending limit at its whole hold). Zerg Router drops the field before any provider sees it (since Router #903), so ZTC adds no route for it, and a deck's or workspace's stored route plan, with its fallbacks, applies as with the variable unset. Use `off` only with a Router at or past #903: an older one (this repository's `zapps/zergrouter` among them) hands the field as it came to another provider's model that a stored route plan falls back to, which may refuse it, and ZTC adds no route to keep the turn on Claude (`allow_fallbacks: false`), since Router refuses one from a service-account key. A route plan of the turn's own (`zrouterRoutePlan`) that can fall back to another provider's model asks for nothing, nor do Router's Responses route and another provider's model. An older Router that refuses the field from a service-account key (400 "Unsupported service inference option") gets the turn again at once without it, and nothing more of it on that Router and key for the rest of the run, which ZTC says once among its runtime diagnostics (the Logs tab; stderr in a headless run). With `off`, the settings panel's "Compact before the cache expires" counts no Anthropic cache lifetime, unless you set "Prompt cache lifetime (seconds)" |
2460
+ | `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) |
2461
+ | `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
2462
  | `ZTC_PLUGIN_PATHS` | Explicit plugin roots (platform-delimited) |
2394
2463
  | `ZTC_MODE_PATHS` | Explicit mode YAML roots (platform-delimited) |
2395
2464
  | `ZTC_DOMAIN_PATHS` | Extra roots for external domain YAML (colon-separated on *nix, `;` on Windows) |
@@ -2401,6 +2470,582 @@ unset preserves normal interactive discovery.
2401
2470
  | `ZTC_SIM_DOMAIN` | Domain for simulation/swarm child panes (mux/pane mode only) |
2402
2471
  | `SDL_MOUSE_RELATIVE_MODE_WARP` | Force SDL warp mode (computer use fallback) |
2403
2472
 
2473
+ #### Credentials a host hands over
2474
+
2475
+ A host that runs ZTC for someone (ZergCloud's resident in each service zerg) routes its model traffic on a Router
2476
+ runtime grant: `ZTC_ROUTER_RUNTIME_GRANT`, for the Router `ZERG_ROUTER_BASE_URL` names (https, or http on this
2477
+ computer's loopback). ZTC sends the grant only to that Router and never saves or shows it.
2478
+
2479
+ **What a launcher sets.** For Router turns on a host credential: `ZTC_ROUTER_RUNTIME_GRANT` (or
2480
+ `ZTC_ROUTER_RUNTIME_GRANT_FILE`, below) with the Router it is for in `ZERG_ROUTER_BASE_URL`, never `ZTC_AUTH_TOKEN`. For
2481
+ a ZergAI platform login: `ZTC_AUTH_TOKEN` with `ZTC_API_BASE_URL`, the platform API that issued it; the ZergAI
2482
+ platform's own launch, which names that API's Router proxy itself in `ZERG_PROXY_URL`
2483
+ (`https://api.zergai.com/api/zrouter`), counts too, and so does a colony cell's `COLONY_PORT`. ZTC sends a
2484
+ `ZTC_AUTH_TOKEN` no platform API is named for nowhere, and says so once (on stderr in a headless run; in the terminal
2485
+ app, in its Logs tab). `ZTC_API_ENVIRONMENT` and `ZERG_DEPLOY_TIER` name no platform API, nor does a Router proxy the
2486
+ zerg image fills in from its tier for a launcher that names none: its entrypoint marks one in `ZERG_PROXY_URL_SOURCE`. A
2487
+ Zerg Router credential ZTC can recognize is no platform login: ZTC sends none (an `sk-zr-` key or another prefix Router
2488
+ issues, a Router JSON Web Token with audience `zergrouter`, or a value it also holds as a Router credential, the grant
2489
+ itself among them) to a platform API call, named or not, in `ZTC_AUTH_TOKEN` or saved in `config.json`. An opaque Router
2490
+ token in `ZTC_AUTH_TOKEN` that ZTC holds nowhere else has no shape it can tell: with a platform API named, it is sent
2491
+ there as the login; with none named, it goes nowhere.
2492
+
2493
+ **The credential store.** As it starts, before any other part of it runs, ZTC takes its credentials out of its
2494
+ environment (`process.env`, which its children are started from; the environment it was started with is another
2495
+ matter, below) and keeps them in memory: the grant, the platform login in `ZTC_AUTH_TOKEN`, the mirror's
2496
+ `ZTC_MIRROR_SHARED_SECRET`, the host's approval, broker and effort-policy tokens (the policy's `ZTC_EFFORT_POLICY_URL`
2497
+ goes with its token), and any other variable holding one of their values, such as the `ZERG_API_TOKEN` copy of the
2498
+ grant ZergCloud passes. The mirror's secret and token that ZTC makes itself go there too, never into its environment.
2499
+ A read-only observer of the mirror is shown none of these values, wherever they appear, nor a pane's live mirror
2500
+ credential that a pane's output prints, though up to 15 of its 43 characters can show where an output piece ends, and
2501
+ one wrapped across a frame's rows under a gutter of other characters than blanks and box drawing (vim's `showbreak`),
2502
+ under one wider than 24 columns, or beside a right-hand border is not withheld.
2503
+
2504
+ **What a child gets.** ZTC keeps these credentials out of every child's own environment: the commands and tools its
2505
+ 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
2506
+ server's `passEnv`), ZTC's native helpers, `git`, image helpers, the renderers it starts and the shells you open beside
2507
+ ZTC get your environment without them. That keeps them out of what a child inherits, not out of reach of every program
2508
+ (see Limits below). ZTC hands a child what it needs explicitly, and only these:
2509
+
2510
+ - A ZTC pane or colony cell ZTC opens (yours, its agent's, a split) gets the grant with the Router it names, explicit
2511
+ extension discovery and the host's effort policy, since it routes on them, and keeps them from its own children the
2512
+ same way. A colony cell, and a ZTC pane a renderer starts, also get the platform login in `ZTC_AUTH_TOKEN`; a colony
2513
+ cell also gets its broker token.
2514
+ - 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
2515
+ a launch of ZTC's own install. Anything else a pane asks for opens as a process pane, holding none of them.
2516
+ - ZTC's own `/restart` keeps everything it was started with. A ZTC pane you start again in place (the desktop app's
2517
+ resume, a replace) and ZTC's relaunch in a new ghostty window (`--new-window`) get what they need in a one-time file
2518
+ that only their command line names, never in their environment or arguments.
2519
+
2520
+ A process or command pane zmux starts again in place (`restart_pane`: zmux's key binding, and the mirror's restart
2521
+ button and an agent's `restart_pane` where zmux runs the session's panes) gets the environment its creation gave it,
2522
+ 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
2523
+ comes back on that profile. Its mirror credential is left blank and a one-time credential file on its command line isn't
2524
+ named again, so its workspace tools reach the mirror again only once you reopen it. A resident's headless mirror runs
2525
+ its panes without zmux, and starts them again otherwise (see Limits below).
2526
+
2527
+ **MCP servers and native helpers.** A stdio MCP server and ZTC's native helpers (dictation, speech, ML, computer use,
2528
+ the zlicky overlay) also start without the credentials ZTC routes models with: `ZERG_AUTH_TOKEN`, `ZTC_API_KEY`, each
2529
+ provider's key, a variable your profile names in `apiKeyEnv`, and any variable holding a copy of one, in the terminal
2530
+ app as in a headless run. If an MCP server needs one, list it in the entry's `passEnv`:
2531
+
2532
+ ```json
2533
+ "mcpServers": {
2534
+ "search": { "command": "search-mcp", "passEnv": ["OPENAI_API_KEY"] }
2535
+ }
2536
+ ```
2537
+
2538
+ `passEnv` never gives a server ZTC's own credentials or variables (those above, the mirror's port, the pane relay) or a
2539
+ variable holding a copy of one. The servers that start without a route credential you have set, and whose entries have
2540
+ no `passEnv`, are named in one line at startup, with the variables and never their values; the terminal app shows that
2541
+ line in its transcript too, and `/mcp` shows it under each. An entry with a `passEnv` of its own says what its server
2542
+ needs, and isn't named: `"passEnv": []` says it needs none. An entry's `env` still applies on top. A `passEnv` that
2543
+ isn't a list of variable names keeps the server from starting. `/mcp`, which an agent may run, shows an HTTP server's
2544
+ scheme, host and port, never its URL's userinfo, path or query, and a stdio server's command line with the value after
2545
+ a credential flag (`--token`, `--api-key` and the like) withheld.
2546
+
2547
+ **Under a grant.** A ZTC that holds a grant, one it can use or not, also:
2548
+
2549
+ - Discovers extensions explicitly unless its host sets `ZTC_EXTENSION_DISCOVERY`: it loads plugins, modes, skills and
2550
+ workflows only from the roots its host names (`ZTC_PLUGIN_PATHS` and the other `ZTC_*_PATHS`) and its own builtins,
2551
+ none from its working directory, that directory's repository or HOME, where an agent writes, and it ignores
2552
+ `<cwd>/.ztc/config.json`. A host that wants normal discovery for it sets `ZTC_EXTENSION_DISCOVERY=default`. A
2553
+ browser mirror plugin it should serve is named in `ZTC_PLUGIN_PATHS`.
2554
+ - Starts no pane through MotSi, whatever MotSi's remote view says. MotSi is a program of its own, found on `PATH`, in
2555
+ `~/go/bin` or `~/.local/bin`, where an agent can write, and a ZTC pane inside it would hand it the grant. Each pane
2556
+ starts directly, a ZTC pane with the grant handed over as above, so Zerg Router's Command Central shows none of a
2557
+ resident's panes.
2558
+
2559
+ The desktop app and an npm install, which hold no grant, discover extensions and wrap your panes in MotSi as before.
2560
+
2561
+ **Credentials in files.** The environment a process was started with stays readable by any program running as the same
2562
+ user (`/proc/<pid>/environ` on Linux, `ps -E` on macOS), whatever ZTC later takes out of its own. To keep the grant and
2563
+ the mirror's secret out of ZTC's, hand each over in a file instead, and set no other variable to it:
2564
+
2565
+ | Variable | Description |
2566
+ |----------|-------------|
2567
+ | `ZTC_ROUTER_RUNTIME_GRANT_FILE` | Path of a file holding the Router runtime grant, in place of `ZTC_ROUTER_RUNTIME_GRANT` |
2568
+ | `ZTC_MIRROR_SHARED_SECRET_FILE` | Path of a file holding the mirror's shared secret, in place of `ZTC_MIRROR_SHARED_SECRET` |
2569
+
2570
+ ZTC reads each file once as it starts and then removes it. The file must be a regular file with one name, not a
2571
+ symbolic link or a hard link, that only its owner can read or change (`chmod 600`); a variable can't be set together
2572
+ with its file, and each credential needs a file of its own, not one both variables name. Otherwise ZTC says why,
2573
+ naming the variable and never the value, and exits 2. It reads and checks every file, and a relaunch's one-time handoff,
2574
+ before it removes any, so when one is refused every credential file, and a handoff that passed, stays where it was (a
2575
+ refused one-time handoff in a folder of yours is still removed): fix the one it named and start ZTC again, and that
2576
+ start takes them all.
2577
+
2578
+ **Limits.**
2579
+
2580
+ - The environment ZTC was started with stays readable by any program running as the same user: a grant handed over in
2581
+ `ZTC_ROUTER_RUNTIME_GRANT` can be read there, in ZTC's own; one handed over in `ZTC_ROUTER_RUNTIME_GRANT_FILE` isn't
2582
+ there under that name, but a copy the launcher also sets is. ZergCloud's launch sets the grant as `ZERG_API_TOKEN` and
2583
+ `ZTC_AUTH_TOKEN`, and in zrouter mode the zerg image copies `ZERG_API_TOKEN` into `ZTC_AUTH_TOKEN` when that is unset,
2584
+ so there ZTC's start environment holds the grant even when the host hands it over in the file. The file keeps the
2585
+ grant out of ZTC's start environment only when no other variable holds it.
2586
+ - Each ZTC pane and colony cell ZTC opens starts with the grant in its own environment, where the same holds.
2587
+ - A program running as root, or as the same user, can still read ZTC's memory, where the store holds the values.
2588
+ - zmux refuses to start a ZTC pane again in place (`restart_pane` asks for its session to be resumed): reopen the pane.
2589
+ - A pane zmux starts with `replace_pane`, which carries no environment (one sent through the pane relay included), or
2590
+ restores from a saved workspace, which keeps none, starts with zmux's own environment: ZTC's coordinates, such as the
2591
+ pane relay's socket, and in a resident the provider keys it keeps from its tools. zmux holds none of the credentials
2592
+ above.
2593
+ - A resident's headless mirror runs its panes without zmux: there the mirror's restart button and `restart_pane` start
2594
+ an exited process pane again with a fresh environment, not the one its creation gave it, so a Claude Code or Codex
2595
+ pane on a sign-in profile comes back on the default account.
2596
+ - ZTC used as a library takes nothing out of its environment, so a renderer it starts still inherits what a ZTC pane
2597
+ infers and routes with.
2598
+
2599
+ #### A profile that limits the agent
2600
+
2601
+ A permission profile limits the agent when it names `allowedPaths` or `deniedPaths`, shell or network limits, turns a
2602
+ capability off or asks before one, or keeps commands in an OS sandbox (`sandbox.requireOsEnforcement`, a backend of its
2603
+ own, no network there): `read_only`, the hosted `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` and
2604
+ `hosted_read_only`, and a resident's own profile do; `trusted`, the default, and `local_full` don't. `/status` names the
2605
+ profile the agent runs under and says whether its commands must run in an OS sandbox (they must under one that requires
2606
+ it, or writes nothing) and what enforces them here (`OS command sandbox: required; enforced by seatbelt`, or
2607
+ `not enforced: no OS sandbox on this host, so commands don't run`), never what the profile allows, which `/permissions`
2608
+ shows: `/status --verbose`, which adds the agent's execution facts, leaves out their permission block (the profile's
2609
+ capabilities, its file roots and the OS sandbox it asks for), whoever asks; the facts in the agent's own prompt keep
2610
+ it. On Linux it says `enforced by bubblewrap` only where the `bwrap` on `PATH` makes the namespaces ZTC runs commands
2611
+ in, which ZTC checks once, by running it on `/bin/true`, and otherwise `not enforced: bubblewrap is installed, but
2612
+ can't make the namespaces ZTC runs commands in here (the host must let this user create user namespaces), so commands
2613
+ fail`. A profile of your own that writes nothing runs commands only in an OS sandbox, as `read_only` does, so on a host
2614
+ with none it runs no commands. Under one:
2615
+
2616
+ - **ZTC's own state is never the agent's**, but for its commands, and the programs its tools start, where they run
2617
+ outside any OS sandbox (see the Limits). Its config folder, `~/.ztc`, its sessions and its runtime's hand-offs in a
2618
+ temp folder are refused to the file tools, search, the project-context index and the host verifiers by name and, for
2619
+ a hard link to one of them, by the file it is, and to the OS sandbox by name. Your own skills folder,
2620
+ `~/.ztc/skills`, stays readable, never writable, where discovery is not explicit. Commands that run outside any OS
2621
+ sandbox read and write that state as any program of yours does: those of a profile that runs them but asks for no OS
2622
+ sandbox for them (one that only turns `computer_control`, `screen_capture`, `ml_inference` or `file_read` off, asks
2623
+ before a capability, or limits shell commands or network hosts), and, on a host that has none, those of one that asks
2624
+ for it without requiring it (`/status` says `not enforced: no OS sandbox on this host`); neither kind starts under
2625
+ `ZTC_PERMISSION_PROFILE_PINNED` (below). A profile whose sandbox block turns the network off
2626
+ (`sandbox.network: false`) asks for the OS sandbox for its commands, as one that turns its `network` capability off
2627
+ does.
2628
+ - **ZTC's own files must be its own, with one name.** ZTC doesn't start while `config.json` (or a backup of it),
2629
+ `router-auth.json`, `~/.ztc/hooks_approved.json`, `~/.ztc/plugin.yaml` or a pooled account's credential file in its
2630
+ config folder (a Codex `auth.json`, a Kimi Code `kimi-code.json`) is a hard link, a symbolic link or not a file:
2631
+ another name, in a folder the agent's commands write, would let them change or read it where no check of a path
2632
+ sees. It says which file and how to give it one name (`cp -p <file> <file>.copy && mv <file>.copy <file>`; the copy
2633
+ 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
2634
+ launch with `--permission-profile trusted` starts with the file as it is, and exits 2 before it starts any MCP server
2635
+ or plugin `config.json` names. It asks under the profile `--permission-profile`,
2636
+ the saved `permissionProfile` or a host's `--session-file` thread gives it. Keep a dotfiles copy of `config.json` as a
2637
+ copy, not a link, if you run such a profile.
2638
+ - **ZTC takes no `config.json` edit to what could widen the profile**: hooks, MCP servers, permission profiles, tool
2639
+ permissions, the sandbox, skills and workflows. A change made in the session itself is taken all the same: the
2640
+ settings panel's skills and workflows rows and its "Attach to local colony" row, and `/config workflows`, change them.
2641
+ A restart in place that the agent's command (`kill -USR1`) or relayed input asks for, or that follows an update ZTC
2642
+ installed, takes no `config.json` edit to them: ZTC stays as it is and says why. It reads `config.json` for that
2643
+ whatever the file's inode, size and modification time say, so another process's edit made in place that kept all three
2644
+ is held back too. Your own `/restart` (a mirror controller's counts as yours), and the session you pick to resume,
2645
+ take `config.json` as it is, and say first which of them it changed. The agent can't clear the session's own settings
2646
+ (`/config scope clear`), which may hold its limits, and a host's thread (`--session-file`) keeps its permission
2647
+ profile, sandbox and instructions when anyone clears them.
2648
+ A config-profile switch (`/profile`, whoever asks for it) keeps the permission profile `--permission-profile` named
2649
+ as ZTC holds it, and refuses a config profile that doesn't define it, or defines it otherwise, rather than fall back
2650
+ to another; a factory reset keeps it too. A switch back to a config profile ZTC ran on, and the copy
2651
+ `/profile duplicate` makes of the one it runs on, keep these settings as ZTC held them there, so an edit it held back
2652
+ still waits for a restart; a config profile ZTC hasn't run on brings its own, as its `config.json` has them.
2653
+ - **A host can pin the profile so no one changes it** (`ZTC_PERMISSION_PROFILE_PINNED=1`, which ZergCloud's hub sets
2654
+ next to `ZTC_MODEL_PINNED`, since several clients reach a resident's mirror). The profile the session holds once it
2655
+ has started, `--permission-profile`'s, a host thread's (a `--headless --mirror` resident's) or the one `config.json`
2656
+ saves, with its definition, the sandbox and the tool permissions, is then its only one. ZTC reads the variable as its
2657
+ startup ends, and so does `zerg-ztc-headless`. Where that profile limits nothing (`trusted`, the default, or
2658
+ `local_full`, with no sandbox setting that requires the OS sandbox), or runs the agent's commands without requiring an
2659
+ OS sandbox for them, whether it asks for none (`/status` would say
2660
+ `OS command sandbox: not required, and none is used`: one that only turns `computer_control` off, say) or only asks
2661
+ for one (`not required; enforced by seatbelt`: one that names `allowedPaths`, say, under which the LSP tools,
2662
+ `run_and_capture` and `workflow` start programs outside the sandbox), where they could reach ZTC's own state and the
2663
+ `config.json` the pin is taken from, ZTC doesn't start, whatever starts it: a one-prompt run, a resident (one on a
2664
+ host's thread that has no settings yet included), a ZTC pane or colony cell a pinned session opens. It exits 2, saying
2665
+ that its host pins the permission settings and the profile it would pin limits nothing, or doesn't require an OS
2666
+ sandbox, and to start ZTC with `--permission-profile` and a profile that limits the agent, or, for the second, one
2667
+ that requires the OS sandbox (set `sandbox.requireOsEnforcement` to true in it, as `workspace_autonomous` does) or
2668
+ runs no command (`shell_exec` off) (`zerg-ztc-headless`: to save one as `permissionProfile`), or to unset the
2669
+ variable. Every other profile that limits the agent is pinned: one that requires the OS sandbox for its commands
2670
+ (`sandbox.requireOsEnforcement` in it or in the sandbox settings, or one that writes nothing), or runs none, as every
2671
+ built-in one that limits the agent does. Your own commands (`!cmd` and `/shell`, `/diff`'s git, the commands
2672
+ `/optimize` runs), yours or a controller's, then run only inside the OS sandbox too, as the agent's do, under the
2673
+ pinned profile's roots with ZTC's own state hidden, even under one that runs none of the agent's (`safe_edits`), so
2674
+ they reach neither that state nor the `config.json` the pin is taken from, and where no OS sandbox is usable they are
2675
+ refused ("OS sandbox enforcement required but unavailable: ..."); the Ink interface's, and your hooks under a profile
2676
+ that runs no command, run outside it (see the Limits). You, a controller, a relayed line and the agent are all
2677
+ refused `/permissions use` and `set`, a `/profile` switch to a config profile that holds other ones, the settings
2678
+ panel's rows for them, a factory reset (it would remove `config.json`; `ztc config reset` from a shell takes no pin),
2679
+ and a restart in place (your `/restart` too) while `config.json` holds an edit to them. The host is refused a thread
2680
+ revision that names another profile than the session started on (its thread's then, or, where its thread had no
2681
+ settings yet, the pinned one), and nothing of the revision is taken; one it takes leaves the pinned profile and
2682
+ sandbox as they are. A session whose thread had no settings yet as it started, pinned on a profile no revision can
2683
+ name (a resident's own), takes none. Each refusal names the variable, never the profile, and `/permissions` and
2684
+ `/status` show the pin. Under it a clear of the session's settings leaves the pinned ones (the agent's own clear is
2685
+ refused, saying so), and a Claude Code or Codex pane you open starts with its permission prompts. A ZTC pane it opens
2686
+ pins what it starts on itself, and an agent's `/ztc` compares the pane's saved profile with the pinned one by the
2687
+ folder the pane starts in. The pinned profile's relative file roots (`workspace_autonomous`'s `.`) are the folder the
2688
+ session started in, its mounted workspace, and `/permissions` names them (`File roots: /path/to/workspace`). A `/cd`
2689
+ elsewhere (yours, a controller's or a relayed one), or an environment the session opens, moves none: the agent, built
2690
+ again there, is still refused its file tools outside them, and its commands there, which every pinned profile that
2691
+ runs them keeps in the OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement`
2692
+ profile). A restart in place starts the next ZTC in the folder the session started in, wherever an environment moved
2693
+ the session, and is refused where it would start elsewhere (a session the resume panel picks that works in another
2694
+ folder, or that folder gone). The ZTC that starts is handed the variable itself and what the pin was taken from, as
2695
+ `config.json` or the host's thread gives it: where they changed the pinned settings after the restart's check, it
2696
+ doesn't start, says so ("ZTC did not start again in place: the permission settings it would pin changed after the ZTC
2697
+ it replaces checked them: ..."), and exits 2, so its host or you start it again. No built-in profile they don't
2698
+ redefine and no default goes with it, so an update that rewords a built-in profile or changes a default doesn't keep
2699
+ it from starting. It takes what it was handed (`ZTC_PERMISSION_PIN_SOURCE`) out of its environment as it starts,
2700
+ before any MCP server connects, and no MCP server, hook, pane or command is given that variable, whatever an MCP
2701
+ server's `passEnv` names.
2702
+ A pinned ZTC doesn't update itself, since an update would put a ZTC its host didn't choose in its place: `/update`
2703
+ installs nothing, saying why (naming the variable) and to update ZTC where its host starts it, or with `ztc update`
2704
+ from a shell; the native interface's start-up check, which installs a newer release with npm and starts it in place,
2705
+ doesn't run; and the desktop app is given no context to start that ZTC again with, without which its updater installs
2706
+ no app update while that ZTC runs.
2707
+ - **Hooks run inside the OS sandbox the profile requires, or not at all**, except under a profile whose agent writes
2708
+ nothing (`read_only`, `hosted_read_only`), where your own approved hooks run as before. In the sandbox a hook reads,
2709
+ beside the system's folders and the project, its own code, read-only: the program its command line starts (found on
2710
+ its `PATH`), the interpreter a script's `#!` names and the script an interpreter is given, so a guard in `~/bin` or a
2711
+ hook run by nvm's `node` starts. Anything else it reads, writes or reaches stays as the agent's commands have it: a
2712
+ hook that logs to a file in `HOME` fails there, as does one that uses the network where the profile keeps commands off
2713
+ it, and its result says the OS sandbox refused it. A PostToolUse hook's failure follows the tool's result as a note,
2714
+ `[hook] PostToolUse hook failed (after <tool> ran; not part of its result)`, so the result stays as the tool gave it
2715
+ and a JSON one still parses from its start. A PostToolUseFailure hook's words and failure follow a failed result the
2716
+ same way, the note beginning `[hook] PostToolUseFailure hook failed (after <tool> failed; not part of its result)`
2717
+ where it failed, so `read_command`'s failed receipt still parses. A PreToolUse hook that fails keeps the tool from
2718
+ running, as one that denies it does; its failure follows the refusal as the same note.
2719
+ - **Where the agent's commands run only inside an OS sandbox** (`requireOsEnforcement`, or a profile that writes
2720
+ nothing), ZTC starts no program the agent chose outside it: `run_and_capture`, `create_terminal_pane`,
2721
+ `write_terminal_pane`, `restart_pane`, `create_ztc_pane`, `create_supervised_ztc_pane`, `workflow`, `adaptation_run`,
2722
+ the computer-use routine tools (`computer_run_routine`, `computer_save_routine`, `computer_list_routines`,
2723
+ `computer_delete_routine`, whose runner runs the agent's JavaScript outside any sandbox), the LSP tools
2724
+ (`goto_definition`, `find_references`, `hover`, `diagnostics`, `lsp_status`, whose language server runs the
2725
+ workspace's code: rust-analyzer runs a crate's build script), the ML tools in ML mode (`ml_load_model`, `ml_infer`,
2726
+ `ml_train`, `ml_status`, which start ZTC's ML helper, `ztc-ml`, and hand it files), and through `ztc_command`
2727
+ `/claude`, `/codex`, `/zerg launch`, `/zerg serve` and `/debug headlines` are refused and not offered, the routine
2728
+ tools whatever the profile says of `computer_control`. A profile that runs no command (`hosted_read_only`,
2729
+ `safe_edits`, `locked_down`) doesn't offer the LSP tools, the routine tools, the ML tools or
2730
+ `create_supervised_ztc_pane` either. The file an LSP tool names is checked as `read_file`'s path is, and so are the
2731
+ weights `ml_load_model` loads and the session data `ml_train` trains on, while the place `ml_train` saves weights to
2732
+ is checked as `write_file`'s path is, each resolved against the agent's folder. A profile that asks before each shell
2733
+ command (`tests_allowed`, `ask_before_mutation`) asks, and you decide; a call it refuses whatever you answer (a
2734
+ working directory or a path outside its roots, a file a patch writes there, the file an LSP tool or an ML tool reads
2735
+ there, the weights `ml_train` would save there) is refused without asking you, a file read with
2736
+ `Permission denied: path is outside allowed profile roots (<file>). <tool> read nothing.` A language server the LSP
2737
+ tools started is ended once the permissions change to ones that don't admit those tools without asking (through
2738
+ `/permissions use` or `set`, the settings panel's permission profile, tool permission and sandbox rows, `/profile` or
2739
+ a host's revision: a switch to `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` or `read_only`,
2740
+ `shell_exec` turned off, the OS sandbox required): ZTC asks it to shut down and exit, and once it has left, or a
2741
+ second after it was asked to exit, ends what is left of its process group, the server and what it started there; a
2742
+ server that doesn't answer the request to shut down is ended the same way once ZTC has waited 10 seconds for the
2743
+ answer and a second more (each server leads a process group and session of its own on macOS and Linux, so the
2744
+ Ctrl+C or hangup your terminal sends ZTC no longer reaches it; on Windows the server alone is ended). So none goes on
2745
+ building the workspace outside the sandbox; under permissions that admit them without asking (`trusted`,
2746
+ `local_full`) it keeps running, and the next call admitted starts one again. The agent built again under the same
2747
+ permissions (after a `/model` switch or a `/cd`) stops none, so one you approved under `tests_allowed` or
2748
+ `ask_before_mutation` keeps running until a change of the permissions stops it as above. `run_command`,
2749
+ `delegate_task`, Claude Code's `Bash`, `WebFetch`, `Glob` and `Task`, MCP tools and `/ztc` (whose pane runs under
2750
+ permissions no wider than this one's) stay. There, a `run_command` (or Codex's `exec_command`) whose working
2751
+ directory is outside the profile's roots is refused before it runs, with
2752
+ `Permission denied: working directory is outside allowed profile roots (<folder>)`, and one in a folder it denies with
2753
+ `Permission denied: working directory is blocked by profile (<folder>)`; each goes on to name the profile's roots to
2754
+ run the command in instead (`Run the command in a folder inside this profile's roots (...)`), or the session's folder,
2755
+ by giving none: macOS's sandbox lets a command read the folder it runs in, which the file tools may not. A working
2756
+ directory in a folder every sandboxed command reads anyway (the system's and its tools', `/usr/bin`) isn't refused,
2757
+ unless the profile denies it. A subfolder of the workspace isn't refused: a command there has the profile's roots, the
2758
+ whole workspace, as its read and write roots, as the file tools do (before, its own subfolder was its only root).
2759
+ Claude Code's `Bash` and Codex's `shell_command`, which write files, are refused a working directory outside the roots
2760
+ under every profile that names them, not only here, with
2761
+ `Permission denied: path is outside allowed profile roots (<folder>)`.
2762
+ - **A profile's relative roots are the session's folder's for the agent's commands too.** The OS sandbox resolves `.`,
2763
+ `./build` or a relative `deniedPaths` entry against the folder the session works in, as the file tools do, wherever
2764
+ the command runs. Under a profile that names `allowedPaths`, the folder a `run_command` names as its `cwd` is no root
2765
+ of its own, so a command there can't write outside the workspace (`.` used to name that folder); one that names none
2766
+ keeps the folder a command runs in as its write root, while its relative `deniedPaths` are the session's folder's. The
2767
+ sandbox audit's `allowed_paths` and `denied_paths` name the roots so. Both sandboxes hold every root by its real path
2768
+ too: macOS's matches only real paths, and bubblewrap binds a root named through a link as named and by its real path,
2769
+ and hides, or holds read-only, at both spellings what the plan keeps from a command in it (a denial, ZTC's own state,
2770
+ a hook's own files, where its repository names the programs git starts). So with the session's folder named through a
2771
+ link (a `/cd` to it by another name) a command still writes in the workspace, and a relative denial still keeps it out
2772
+ of the denied folder. bubblewrap enters a working directory named through a link into the workspace by its real path.
2773
+ One outside the roots and the system's folders every command reads (`/usr`, `/bin`, `/etc`), which a profile not
2774
+ requiring the sandbox lets a command run in, it binds read-only, so the command starts, only where a filter refuses
2775
+ the command Unix sockets (a profile without network, on x86-64 and arm64). Where none does, a read-only bind would
2776
+ leave a host service's socket in that folder, or below it, in the command's reach, so bubblewrap binds no such folder:
2777
+ the command doesn't start, and is refused with "Permission denied: working directory is outside this profile's roots
2778
+ (<folder>), and bubblewrap binds no folder outside them for a command that may use the network: a host service's
2779
+ socket in it would be in the command's reach. Run the command in a folder inside this profile's roots (<roots>): give
2780
+ it one there as its working directory, or none to run it in the session's folder.", the last words only where a root
2781
+ holds the session's folder (under `allowedPaths: ['./build']` none does, and a command in the session's folder is
2782
+ refused too). Without network, on an architecture ZTC has no such filter for (anything but x86-64 and arm64), the
2783
+ refusal says "for a command no filter keeps from Unix sockets, as ZTC has none for this architecture" in place of
2784
+ "for a command that may use the network". Whatever the network, a working directory that is a folder where the host's
2785
+ services keep their sockets (`/tmp`, `/var/tmp`, `/dev/shm`, `/run`, `/var/run`, `/run/user`, the session's
2786
+ `XDG_RUNTIME_DIR`), lies in one (tmux's `/tmp/tmux-<uid>`; a drive the host mounts for you in `/run/media` lies in
2787
+ none, below) or holds one (`/var`, or `/`, which holds them all) is never bound so, since a read-only
2788
+ bind would put those sockets in reach (tmux's, the session bus, `docker.sock`): the command doesn't start, and is
2789
+ refused with
2790
+ `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2791
+ `lies in <folder>, where ...`, `holds <folder>, where ...`, and for `/` `holds the folders where ...`), followed by
2792
+ where to run it instead: a folder inside the profile's roots, or none, to run it in the session's folder.
2793
+ - **Where the agent's commands keep the network, bubblewrap binds no root that would put the host's services' sockets in
2794
+ their reach**, as no filter refuses them Unix sockets there: it plans no command whose root is `/`, is or holds one of
2795
+ the folders above, or lies in one of the host's runtime folders (`/run`, `/var/run`, `/run/user`, the session's
2796
+ `XDG_RUNTIME_DIR`) but on a drive the host mounts for you in `/run/media` (below), judged as named and by where a link
2797
+ leads, and its refusal says what to do instead. A root the profile names is refused with "Permission denied: this
2798
+ profile's root is a folder where the host's services keep their sockets (/tmp), which bubblewrap keeps out of a
2799
+ command's reach. Name a project's folder in its allowedPaths instead, to run commands under it." (or
2800
+ `holds <folder>, where ...`,
2801
+ `lies in /run, where the host's services keep their sockets (/run/postgresql)`, and for `/`
2802
+ `holds the folders where ...`). Its relative root (`workspace_autonomous`'s `.`) in a session started in `/tmp` or `/`
2803
+ keeps every command from running, the refusal ending "Start ZTC in a project's folder, which its relative root (.)
2804
+ then names, to run commands under it." Under a profile that names no `allowedPaths` (`trusted` where the sandbox
2805
+ settings require the OS sandbox, or one of your own), whose only root is the folder a command runs in, that folder is
2806
+ refused where it is `/`, is or holds one of those folders, lies in a runtime folder, or lies in a scratch folder
2807
+ (`/tmp`, `/var/tmp`, `/dev/shm`) outside the session's folder (`/tmp/tmux-<uid>`), with
2808
+ `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2809
+ `lies in`, `holds` as above), followed by "Run the command in another folder, such as a project's: give it one as its
2810
+ working directory, or none to run it in the session's folder." A root that only lies in a scratch folder (`/tmp/proj`)
2811
+ is bound as before, as are the session's own folder there and the folders in it under a profile that names no
2812
+ `allowedPaths`, and a profile without network, whose commands bubblewrap refuses Unix sockets on x86-64 and arm64,
2813
+ plans its commands as before. A drive the host mounts for you in `/run/media` (udisks2's `/run/media/<user>/<drive>`,
2814
+ on Fedora, Arch and openSUSE) is no folder where the host's services keep their sockets: a project there is bound as
2815
+ any project's folder is, as a root the profile names, as `workspace_autonomous`'s `.` in a session started there and
2816
+ as the folder a profile that names no `allowedPaths` runs a command in, and a working directory there outside the
2817
+ roots is treated as any other folder outside them. The rest of `/run` is refused, `/run/user/<uid>/gvfs` (GNOME's
2818
+ network shares) and `/run/host` (the host's root in a Toolbx or Distrobox container) among it (see the Limits). A
2819
+ plan refused for its roots records no repository of theirs in `~/.ztc/sandbox/known-repositories.json`.
2820
+ - **A denied path that doesn't exist yet can't be made in the sandbox.** macOS's sandbox denies a path by its name,
2821
+ whether or not it exists. bubblewrap hides a path with a mount over it, which needs something there, so where a
2822
+ `deniedPaths` entry, or one of the folders of ZTC's own state (`~/.ztc`, its config folder, `ZTC_SESSIONS_DIR`,
2823
+ `ZTC_WORKSPACE_LAYOUT_DIR`), doesn't exist when a command starts, in a root the command writes, it stands an empty
2824
+ read-only folder over it for the command's run: the command can make neither it nor anything in it
2825
+ (`Read-only file system`, `Is a directory` or `File exists`), so a denied `.env` or `.github/workflows` stays unmade.
2826
+ bwrap makes that folder on the host, as you, with any folder above it that didn't exist either, and it stands there
2827
+ for the whole of the command's run, a background command's too; every command this ZTC plans meanwhile stands one
2828
+ there again, and ZTC removes them once the last of those commands ends, keeping one that something was put in.
2829
+ Meanwhile your other programs see an empty folder there: writing `.env`, or reading it as dotenv and `docker compose`
2830
+ do, gets `Is a directory`, and a file watcher sees the folder come and go around each command. A folder made above
2831
+ it (`.github`, for a denied `.github/workflows`) is an ordinary writable folder on the host meanwhile, and what is
2832
+ put in it stays. A file you put at the path while such a command runs, once you have removed its folder, is hidden
2833
+ from the next command as a file is, with `/dev/null` over it. None is put outside the roots the command writes,
2834
+ through a link below a root, under a read-only or emptied mount, under a profile that writes nothing, inside another
2835
+ one, or in a folder you can't write, where the command can make nothing either (see the Limits).
2836
+ - **On macOS, a sandboxed command that keeps the network gets IP networking and the system's name resolver, and connects
2837
+ to no other Unix socket.** It connects out to any address, listens and accepts on local ones and resolves names
2838
+ through the resolver's socket (`mDNSResponder`), but no other Unix socket is in its reach, in its workspace or outside
2839
+ it: not Docker's `docker.sock`, an ssh-agent's (`SSH_AUTH_SOCK`), tmux's or a local database's (PostgreSQL's in
2840
+ `/tmp`), whose programs act outside the sandbox. So `docker`, and a database client that connects through a socket,
2841
+ fail in the sandbox; a database's TCP port on `localhost` still answers. This holds wherever the agent's commands run
2842
+ in the OS sandbox with the network (`workspace_autonomous`, `ask_before_mutation`, `tests_allowed`, a profile of your
2843
+ own that asks for the sandbox), and for a hook run there. `trusted` and `local_full` run commands with no sandbox, so
2844
+ nothing changes there, unless the sandbox settings require one. bubblewrap, on Linux, leaves such a command the
2845
+ sockets in its roots (see the Limits).
2846
+ - **The file tools open only the file the profile admitted**: a link swapped in between the check and the open is
2847
+ refused, and nothing is read or written through it. A unified diff, which `git apply` writes, and `search` open files
2848
+ themselves (see the Limits).
2849
+ - **A sandboxed command can't write where a repository names programs.** Where the agent's commands write inside an OS
2850
+ sandbox (`workspace_autonomous`, `ask_before_mutation`, `tests_allowed`, a resident's own profile), it commits,
2851
+ stages, branches, fetches and pushes as before, but in every repository ZTC finds that it can write (the session's,
2852
+ the ones your workspace holds down to four folders deep, their linked worktrees and submodules; the Limits below name
2853
+ those it doesn't find), `.git/config`, `config.worktree`, the `commondir` of a git directory, a worktree's or
2854
+ submodule's `.git` file, the hooks folder and an untracked `core.hooksPath` folder are read-only to it, on macOS
2855
+ missing ones included. On Linux, of the missing ones, only the common config and the hooks folders are: a `commondir`
2856
+ or `config.worktree` the command creates, or a link among them it replaces, stands until the command ends. Everywhere,
2857
+ `.git` and the folders above it can't be moved away or removed. A repository ZTC has found stays protected in that
2858
+ ZTC, even after a command removes its `HEAD`, moves its refs or objects aside, removes what it may of it, or fills the
2859
+ folders ZTC looks through, and in every one started after it while the record holds it (ZTC keeps the 512 found last
2860
+ in `~/.ztc/sandbox/known-repositories.json`: see the Limits), and a `.git` that git takes for no repository is
2861
+ protected where ZTC looks; when ZTC stops looking
2862
+ for repositories at one of its limits, the command's result says where. When a command leaves one of these
2863
+ repositories one git takes for none (its `HEAD` removed or rewritten, its `refs` or `objects` moved aside), ZTC puts
2864
+ back what it broke as soon as the command ends, before anything reads its result, and the result says what it put
2865
+ back: from then on your git there finds that repository again, not one the command made in a folder above it (while
2866
+ the command runs, it doesn't: see the Limits). It may still start repositories (`git init`, `git clone`,
2867
+ `git worktree add`, `git submodule update` of an initialized submodule), on macOS as on Linux: a repository it makes
2868
+ is its own in that command and protected from its next command on. A checkout, a commit, a branch switch or a detached
2869
+ `HEAD` is never undone. On Linux, ZTC undoes a `commondir` or `config.worktree` a command made in a protected git
2870
+ directory, and a protected link it replaced, when the command ends, and the command's result says so. The file tools
2871
+ refuse the `core.hooksPath` folder and a `.git/config` link's target as they refuse `.git`. So `git config`,
2872
+ `git remote add`, `git branch -m`, `git submodule init` and `git submodule update --init`, hook installers, and
2873
+ `rm -r` of a folder that holds one of these repositories fail there, and `git push -u`, `git switch` to a branch only
2874
+ the remote has and `git checkout --track` say they set up tracking but record no upstream: run those yourself. The
2875
+ command's result says so in its sandbox notes: which file the sandbox kept, and the command to run. Hooks your
2876
+ repository tracks (a `.githooks` folder, husky's) are its code, which the agent may change like any file: the first
2877
+ command in that repository is told so, and you review them as you review code.
2878
+ - **ZTC's own git in the work tree starts no program the repository's config names** where the agent's commands can
2879
+ write that config: the startup snapshot, `/status`, `/runtime`, the work check and a verified command's receipt read
2880
+ the repository's root, HEAD, branch and recent commits, never the work tree's status or diff, which show as not read.
2881
+
2882
+ Under every profile, the one that limits nothing included, ZTC's own git in your work tree (the startup snapshot,
2883
+ `/status`, `/runtime`, `/diff`, the work check, a verified command's receipt, session isolation, `/batch`, the
2884
+ project-context index) runs git's own diff and log: it starts no fsmonitor, external diff, textconv driver or signature
2885
+ program the repository's config names, and `/diff` shows git's own diff. A clean filter that `.gitattributes` selects
2886
+ (`filter.<name>.clean` or `process`) still runs where that git reads a status or a diff, and `/diff` shows the content
2887
+ after it; where the agent's commands can write that config under a profile that limits it, the startup snapshot and the
2888
+ other reads the item above names read no status or diff. Your own git commands, and the agent's, keep the repository's
2889
+ programs.
2890
+
2891
+ **Limits.**
2892
+
2893
+ - Seatbelt and bubblewrap deny ZTC's own state by path, so a sandboxed command reads and writes through a hard link to
2894
+ one of its files that something outside the sandbox made on the same filesystem; the file tools refuse such a link by
2895
+ identity, and ZTC checks its own files' names (above) only as it starts. Keep `HOME` and `ZTC_CONFIG_DIR`, and
2896
+ `ZTC_SESSIONS_DIR` and `ZTC_WORKSPACE_LAYOUT_DIR` where they are set, on another filesystem than the workspace, and no
2897
+ such link to them can exist. ZTC's hand-offs in the temp folders (`TMPDIR`'s and `/tmp`) can still be linked where
2898
+ those share the workspace's filesystem, as they usually do on macOS.
2899
+ - That startup check doesn't look again later: not at a profile chosen after startup (a `/permissions` switch, hosted
2900
+ settings sent to a running ZTC), nor at an account added to the pool after it, a CLI's own sign-in (in
2901
+ `~/.ztc/agent-profiles`, or a `codex_home` account's folder) or an account's file kept outside ZTC's config folder.
2902
+ - On macOS a sandboxed command under a profile that writes can signal your other processes, ZTC's included: it can
2903
+ stop ZTC, or ask it to start again in place (`kill -USR1`), which takes no `config.json` edit to the settings above.
2904
+ bubblewrap gives a command processes of its own.
2905
+ - On Linux, bubblewrap refuses no Unix socket to a command whose profile leaves it the network. It keeps the folders
2906
+ where the host's services keep their sockets out of the command's reach, and binds no folder outside the roots for it
2907
+ to run in (above), but the command shares the host's network, and with it the host's abstract sockets, and reaches a
2908
+ socket file in any folder it binds: a root at or above your home folder holds the sockets programs keep there (Docker
2909
+ Desktop's `~/.docker/desktop/docker.sock`), and a profile of your own that writes nothing and names no `allowedPaths`
2910
+ binds every folder, read-only, but the socket folders. `read_only` keeps its commands off the network and, on x86-64
2911
+ and arm64, refuses them Unix sockets.
2912
+ - On Linux, a project in `/run/user/<uid>/gvfs` (GNOME's network shares) or in `/run/host` (the host's root in a Toolbx
2913
+ or Distrobox container, its `/run` and sockets included) lies in `/run`, so where no filter keeps commands from Unix
2914
+ sockets (a profile that keeps the network) bubblewrap plans no command with a root there (above). Turn the profile's
2915
+ network off (`sandbox.network: false`), whose filter keeps commands from Unix sockets on x86-64 and arm64, or work on
2916
+ a copy elsewhere.
2917
+ - On Linux, where `bwrap` is on `PATH` but can't make the namespaces ZTC asks of it (a host or container that doesn't
2918
+ let the user create user namespaces, as Ubuntu 24.04's AppArmor doesn't by default), every sandboxed command fails
2919
+ with bubblewrap's error, and none runs outside the sandbox, a profile's that only asks for it included; `/status`
2920
+ says so (above).
2921
+ - Under bubblewrap, ZTC removes the empty folders that keep a denied path not made yet (above) once the command ends:
2922
+ one can stay where ZTC is killed while the command runs, and where it exits or starts again in place then, since it
2923
+ stops a running command without waiting for it to end (remove it with `rmdir`); and where two ZTCs run commands in
2924
+ one workspace at once with the same denied path not made yet, the end of one's command can remove the folder the
2925
+ other's stands on, and the other command can then make that path. A denied path that is a link leading nowhere is
2926
+ neither hidden nor held: a command can remove the link and make the path.
2927
+ - A restart in place checks `config.json` before it starts the next ZTC, which reads the file again as it starts: an
2928
+ edit another process makes in between to the hooks, MCP servers, skills or workflows is taken. Under
2929
+ `ZTC_PERMISSION_PROFILE_PINNED`, one to the pinned permission settings keeps that ZTC from starting instead.
2930
+ - A colony cell's `/restart` isn't a restart in place: it asks its overseer to start the cell again, which doesn't
2931
+ check `config.json` first, nor hand the ZTC it starts what the pin was taken from: that ZTC takes the permission
2932
+ settings from `config.json` as a fresh start does, and pins them where its environment holds
2933
+ `ZTC_PERMISSION_PROFILE_PINNED`. Nor is the desktop app's start of ZTC after it installs an update, which doesn't
2934
+ check `config.json` first either, and which it makes only for a ZTC that isn't pinned (above).
2935
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, ZTC takes the pin as its startup ends, after it has started the MCP servers
2936
+ `config.json` names: one that then doesn't start (the profile it would pin limits nothing or doesn't require an OS
2937
+ sandbox, or the pinned settings changed after a restart's check) has started them by then. A ZTC started again in
2938
+ place takes what it was handed (`ZTC_PERMISSION_PIN_SOURCE`) out of its environment before any of them starts, so
2939
+ none holds it, but the environment the process was started with (`/proc/<pid>/environ` on Linux) still does, which a
2940
+ program running as the same user can read, as it can read `config.json`.
2941
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, the Ink interface, which ZTC runs where its native interface isn't built
2942
+ (Windows, say), still installs a newer release with npm as it starts, for the next start to run (it starts nothing in
2943
+ place); `ZTC_DISABLE_UPDATE=1` keeps it from checking, and the `ztc` command the npm package installs sets it.
2944
+ - The Ink interface runs your own commands (`!cmd` and `/shell`, `/diff`'s git, the commands `/optimize` runs) outside
2945
+ any OS sandbox, under every profile, `ZTC_PERMISSION_PROFILE_PINNED` or not: the native interface runs them in the
2946
+ sandbox the profile asks for, and under the pin only inside one.
2947
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, a pinned profile that runs none of the agent's commands (`safe_edits`, or one
2948
+ that turns `shell_exec` off) requires no OS sandbox, so your hooks run outside one there, as under `read_only`: a hook
2949
+ reaches ZTC's own state, and the `config.json` the pin is taken from, as any program of yours does, and where the
2950
+ profile lets the agent write, a hook that runs the workspace's code (`npm run lint`) runs what the agent may have
2951
+ written there.
2952
+ - `--new-window` in Terminal or iTerm starts the new window's ZTC in a shell of its own, which ZTC hands neither
2953
+ `ZTC_PERMISSION_PROFILE_PINNED` nor `ZTC_MODEL_PINNED`: that ZTC pins neither.
2954
+ - Settings that name programs ZTC runs when you ask aren't kept as ZTC started with them: the Codex app server's
2955
+ command, arguments and sandbox, the Shannon runner's command, custom pane options, remote resources and a worker
2956
+ endpoint.
2957
+ - Without a host's grant, extension discovery stays as it is: ZTC loads plugins, modes, skills and workflows from its
2958
+ working directory and that directory's repository as it starts, where the agent's commands can write, and reads a
2959
+ skill or workflow written into a folder it already reads while it runs. Set `ZTC_EXTENSION_DISCOVERY=explicit` to
2960
+ load only the roots you name.
2961
+ - Your own `/zerg launch` still runs Poetry in the working directory's `zerg/` project, which the agent may have
2962
+ written, as `make` there would.
2963
+ - A headless run with no approval client approves what a profile that asks would ask you (`--approval-url` hands those
2964
+ decisions to a service), so there the tools above that start a program outside the sandbox can run. Under
2965
+ `--computer-use`, the computer-control tools can type into any window.
2966
+ - A mirror you start in the terminal UI (`ztc --mirror`, `/mirror`) with sign-in off, the default outside production,
2967
+ answers anyone on this computer (see the mirror's section) and takes their input as yours: under a profile that
2968
+ leaves the agent's commands the network (`workspace_autonomous`), a command of the agent's could post
2969
+ `/permissions use trusted` to its port as you, and widen its own permissions. Sign-in (`ZTC_MIRROR_REQUIRE_AUTH=1`)
2970
+ keeps it out, as do the desktop app's mirror and the one a zmux session starts by itself, which answer only callers
2971
+ with a credential; under `ZTC_PERMISSION_PROFILE_PINNED`, `/permissions use` is refused whoever asks. Turn sign-in on
2972
+ for a mirror you run under such a profile.
2973
+ - Where a profile lets the agent start a program outside the OS sandbox (`trusted`, `local_full`, a profile of your own
2974
+ that doesn't require the sandbox, or one that asks, once you approve), the tools above that start one start it outside
2975
+ any sandbox. The LSP tools' language server runs the workspace's code there as it builds it (rust-analyzer runs a
2976
+ crate's build scripts and proc macros), and ZTC exits, or starts again in place, without waiting for it to stop, so a
2977
+ server that ignores the request to exit, and the end of its input, runs on after that ZTC. In ML mode, ZTC's ML helper
2978
+ (`ztc-ml`) opens the files the ML tools name, which the profile checks as above, and, for `ml_train`, the
2979
+ `events.jsonl` and `session.json` in the folder it names, which it opens itself, following a link there.
2980
+ - The file tools check what they opened, but a unified diff, which `git apply` writes, and `search`, which runs
2981
+ ripgrep, open files themselves.
2982
+ - Git in a workspace a sandboxed command writes:
2983
+ - While a command runs, git in a repository it broke looks in the folders above. A command may remove or rewrite a
2984
+ repository's `.git/HEAD`, or move its `refs` or `objects` aside (checkouts and commits write them): git then takes
2985
+ that folder for no repository and looks in the folders above it, where the same command may make a repository of its
2986
+ own (`git init` there is allowed, and so is a `.git` file naming a git directory it made). ZTC puts the broken
2987
+ repository back when the command ends, before anything reads its result, so from then on your git there, or a host
2988
+ service's, finds the repository again. Until then, while the command runs (a long build, a server it keeps in the
2989
+ foreground), git in that folder reads the config above and starts the programs it names: run no git in the agent's
2990
+ workspace, and keep a host service's git out of it, while a sandboxed command runs there. On macOS, a process the
2991
+ command leaves running (`cmd &`, a server; ZTC stops them as it exits) may break the repository again after that,
2992
+ and git there reads what is above until the next command ends and ZTC puts it back again; under bubblewrap nothing
2993
+ a command starts outlives it. A repository no ZTC saw whole
2994
+ (already broken when a plan first found it) can't be put back: its config and hooks are protected where it is, but
2995
+ git there looks above until you fix its `HEAD`. Where a command moved `refs` or `objects` aside, ZTC puts back an
2996
+ empty folder, and the repository's branches or commits are where the command moved them. A repository at a writable
2997
+ root itself has no writable folder above it.
2998
+ - A repository a command makes is its own in that command: `git init`, `git clone`, `git worktree add`, a submodule it
2999
+ checks out or absorbs, a `.git` file it writes naming a git directory, in any folder of a writable root, a folder of
3000
+ your work tree included. A program it plants in that repository's config, or a submodule's (which your
3001
+ `git status` in the superproject runs), in the same command runs when you run git there. The next command's plan
3002
+ finds it if the walk reaches it, and protects it from then on.
3003
+ - What a plan protected stays protected in that ZTC and in every one started after it, from its first command, until
3004
+ its git directory is gone (you removed it): ZTC keeps the repositories its plans found, with what each protected, in
3005
+ `~/.ztc/sandbox/known-repositories.json` (under `HOME`, even where `ZTC_CONFIG_DIR` names another config folder),
3006
+ and reads it as it starts. The record holds 512 repositories at most, those found last: one found before them drops
3007
+ out of it, and a ZTC started later protects that one only once its own plans find it again. A sandboxed command can
3008
+ push one out by making git directories where the walk finds them (`mkdir -p x{1..600}/.git/hooks`); the later ZTC
3009
+ 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
3010
+ isn't in the form ZTC writes) leaves it starting a new one, which the first command's result says once, as it says
3011
+ when it can't write the record (on a fresh `HOME`, where no ZTC has kept one, it starts one without a word); that
3012
+ ZTC protects a `.git` that git takes for none by where it is, where it looks, but not such a repository's
3013
+ `core.hooksPath` folder outside `.git` (an untracked `.githooks`, husky 9's `.husky/_`) until a plan asks git about
3014
+ the repository while it is whole.
3015
+ - The walk stops 4 folders below a writable root and after 2,000 folders, and enters no `node_modules`; a plan reads
3016
+ 512 folders of a `.git/modules` and 256 linked worktrees at most, and asks git about 48 repositories at most. A
3017
+ repository, submodule or worktree past those that no plan of this ZTC or of one before it found keeps a writable
3018
+ config and hooks, unless it is the session's or the command's, and one past the 48 git runs keeps its
3019
+ `core.hooksPath` folder writable. A command can keep a repository no plan has found out of the walk's reach by
3020
+ filling the folders it reads first; one already found stays protected in this ZTC, and in those started after it
3021
+ while the record holds it. A plan that stops at a limit says so in the command's result and its audit, naming where.
3022
+ - Each command's plan asks git about the repositories it knows, every time: in a workspace that holds many, a trivial
3023
+ command takes longer under such a profile (about a second with 40 repositories, on a busy Mac).
3024
+ - Hooks a repository tracks are its code (a `core.hooksPath` folder it tracks, and the tracked scripts husky 9's
3025
+ generated `.husky/_` hooks run): a sandboxed command can change them, through the index too, and git runs them for
3026
+ whoever commits next. A `core.hooksPath` folder a plan protected stays read-only to sandboxed commands, in the ZTCs
3027
+ started after it too, even once you start tracking hooks there (a sandboxed checkout then can't update them) or stop
3028
+ using it. To have ZTC look afresh, remove `~/.ztc/sandbox/known-repositories.json` while no ZTC runs: that forgets
3029
+ every repository ZTC found, and its plans find again those they reach.
3030
+ - `rm -r` of a folder that holds a repository ZTC found fails after removing what the command may write there (the
3031
+ work tree's files, objects, refs, `HEAD`), leaving `.git` with its config and hooks, which stay read-only to later
3032
+ commands; ZTC then puts back its `HEAD` and empty `refs` and `objects` folders, so git takes it for a repository
3033
+ with no commits. `git worktree remove` or `move` of a worktree ZTC found fails too (a worktree a command adds, it
3034
+ can remove in that same command). Remove those yourself: the command's result names them.
3035
+ - A git directory under another name that a command makes (a bare `x.git`, a `--separate-git-dir`), or a `.git` file
3036
+ in a folder of its own outside every work tree, is the command's: your git there reads its config. ZTC's own git
3037
+ never takes a bare repository it did not name (`safe.bareRepository=explicit`);
3038
+ `git config --global safe.bareRepository explicit` does the same for yours.
3039
+ - On Linux (bubblewrap), a `commondir` or `config.worktree` a command creates in a protected git directory, or a
3040
+ protected `.git/config` or `.git` link it replaces, stands until the command ends, when ZTC removes it or puts the
3041
+ link back. Until then, git outside the sandbox in that repository (yours, or a host service's) reads what the
3042
+ command made there, such as a `commondir` that points it at a config of the command's, and starts the programs that
3043
+ config names.
3044
+ - An `include.path` in a repository's config that names a file in the work tree, and a `HOME` inside a writable root
3045
+ (its `~/.gitconfig`), are not covered. Both sandboxes deny by path (Seatbelt by its rules, bubblewrap by a read-only
3046
+ mount of that path): a hard link to `.git/config` made before the sandbox is still written through (neither lets a
3047
+ command make one).
3048
+
2404
3049
  ---
2405
3050
 
2406
3051
  ## License