@zergai/ztc 0.26.4-dev.202611231953 → 0.26.6-dev.202611240947

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 (47) hide show
  1. package/README.md +384 -114
  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 +1 -1
  9. package/dist/agent/backends/codex_app_server.d.ts +54 -9
  10. package/dist/agent/backends/codex_app_server.js +102 -20
  11. package/dist/agent/backends/zrouter_stream.d.ts +9 -8
  12. package/dist/agent/backends/zrouter_stream.js +19 -21
  13. package/dist/agent/commands/status.js +10 -5
  14. package/dist/agent/commands/types.d.ts +2 -0
  15. package/dist/agent/commands/update.js +6 -0
  16. package/dist/agent/runtime/cpu_benchmark.js +2 -0
  17. package/dist/agent/runtime/tool_runtime.d.ts +1 -1
  18. package/dist/agent/runtime/tool_runtime.js +7 -0
  19. package/dist/agent/tools/ml.js +36 -9
  20. package/dist/app/command_context.js +6 -1
  21. package/dist/cli_main.js +53 -10
  22. package/dist/cli_ratatui.js +8 -1
  23. package/dist/config/hosted_runtime.d.ts +71 -0
  24. package/dist/config/hosted_runtime.js +94 -0
  25. package/dist/config/permission_pin.d.ts +73 -12
  26. package/dist/config/permission_pin.js +99 -16
  27. package/dist/config/profile_limits.d.ts +11 -1
  28. package/dist/config/profile_limits.js +14 -0
  29. package/dist/config.d.ts +36 -5
  30. package/dist/config.js +90 -17
  31. package/dist/headless.js +17 -0
  32. package/dist/headless_cli.js +40 -7
  33. package/dist/hooks/types.d.ts +6 -0
  34. package/dist/lsp/client.d.ts +5 -2
  35. package/dist/lsp/client.js +42 -5
  36. package/dist/panes/agent_cli.d.ts +6 -0
  37. package/dist/panes/agent_cli.js +15 -2
  38. package/dist/panes/agent_panes.js +31 -11
  39. package/dist/utils/sandbox.d.ts +30 -1
  40. package/dist/utils/sandbox.js +586 -42
  41. package/dist/utils/subprocess_env.d.ts +15 -0
  42. package/dist/utils/subprocess_env.js +39 -1
  43. package/dist/utils/ztc_own_state.d.ts +25 -0
  44. package/dist/utils/ztc_own_state.js +78 -4
  45. package/dist/zlm-embed.mjs +11465 -10882
  46. package/npm-shrinkwrap.json +1 -1
  47. package/package.json +13 -13
package/README.md CHANGED
@@ -1058,6 +1058,8 @@ Their `data` contains the request fields; resolved events also contain the decis
1058
1058
  Use `requestId` to pair events, and `sessionId` to associate the run.
1059
1059
  Only `approved` allows the requested hook or tool; questions require `answered` with a string `answer`.
1060
1060
  Without a remote URL, headless mode keeps automatic approvals and selects each question's first option.
1061
+ Under `ZTC_PERMISSION_PROFILE_PINNED`, or where its host runs it (`ZTC_HOSTED=1`), it approves no call that starts a program outside the OS sandbox by itself (an LSP tool's language server, `run_and_capture`'s command, a Claude Code or Codex pane): it refuses one, naming the variable, and its JSON output carries `approval_denied` and status `hook_auto_denied`.
1062
+ The request a remote service is sent doesn't say whether the call starts a program outside the OS sandbox; a library host's approver is told, in `startsProgramsOutsideSandbox`.
1061
1063
 
1062
1064
  ### Environment-only sandboxes
1063
1065
 
@@ -1076,6 +1078,7 @@ node dist/cli_main.js --headless --json --cwd /workspace --session-file /workspa
1076
1078
  `ZTC_OPENAI_COMPATIBLE_BASE_URL` overrides saved compatible endpoint settings.
1077
1079
  `ZTC_CONFIG_DIR` selects the configuration directory; `ZTC_SESSIONS_DIR` selects the default session store.
1078
1080
  `--session-file` takes precedence for the active session's load and save operations.
1081
+ A host that runs such a run for someone sets `ZTC_HOSTED=1`: a run with a prompt or a Voyager task on its command line, or one on a `--session-file` thread, then starts only on a permission profile that requires the OS sandbox for the agent's commands and names the folders they may write (`allowedPaths`), or runs none (`--permission-profile workspace_autonomous`, say), and otherwise exits 2 saying why; with no approval service it approves no call that starts a program outside the sandbox by itself (see `ZTC_HOSTED` under [Environment Variables](#environment-variables)). The zerg service's one-shot run doesn't set the variable yet, so it starts on `trusted` as before (see the Limits under [A profile that limits the agent](#a-profile-that-limits-the-agent)).
1079
1082
  When `ZTC_ROUTER_REQUIRED=1`, `ZERG_PROXY_URL` and `ZERG_AUTH_TOKEN` select the required router and its credential.
1080
1083
  The required profile permits exactly one model, `openai/gpt-6.1-sol`, for the parent, subagents and compaction.
1081
1084
  A host can pin a different single model with `ZTC_ROUTER_REQUIRED_MODEL=provider/model`; `ZTC_PROVIDER`, `ZTC_MODEL` and callers cannot move it.
@@ -2442,8 +2445,11 @@ preserves normal interactive discovery.
2442
2445
  | Variable | Description |
2443
2446
  |----------|-------------|
2444
2447
  | `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) |
2448
+ | `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). No Codex ZTC starts is given it, whatever it holds, nor another variable holding its value ([Codex's environment](#codexs-environment)) |
2446
2449
  | `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` |
2450
+ | `ZERG_API_TOKEN` | The zerg image's platform token, which its entrypoint hands ZTC as `ZTC_AUTH_TOKEN` in zrouter mode when that is unset, and where ZergCloud's launch passes the host's Router grant too. A copy of a credential ZTC holds is taken out with it (see [Credentials a host hands over](#credentials-a-host-hands-over)); one ZTC doesn't hold is yours, and ZTC's children keep it, but no Codex ZTC starts is given it, whatever it holds, nor another variable holding its value ([Codex's environment](#codexs-environment)) |
2451
+ | `ZERG_AUTH_TOKEN` | The required Router's credential, with `ZERG_PROXY_URL`, when `ZTC_ROUTER_REQUIRED=1`. No Codex ZTC starts is given it, whatever it holds, nor another variable holding its value ([Codex's environment](#codexs-environment)) |
2452
+ | `ZTC_ROUTER_RUNTIME_GRANT` | A host's Router runtime grant, for the Router `ZERG_ROUTER_BASE_URL` names; see [Credentials a host hands over](#credentials-a-host-hands-over). No Codex ZTC starts is given it, whatever it holds, nor another variable holding its value ([Codex's environment](#codexs-environment)) |
2447
2453
  | `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 |
2448
2454
  | `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 |
2449
2455
  | `ZTC_DEBUG` | Enable debug logging |
@@ -2453,10 +2459,13 @@ preserves normal interactive discovery.
2453
2459
  | `ZTC_DOCKER_CONTAINER` | Route file tools through Docker |
2454
2460
  | `ZTC_TODO_STORE` | Override path to the todo JSON file (defaults to `~/.ztc/todos/<projectHash>.json`) |
2455
2461
  | `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 |
2462
+ | `ZTC_HOSTED` | Set to `1` by a host that runs ZTC for someone: ZergRouter's hosted runtime runs it as a hosted workbench, which allows one agent pane per thread (among its other limits ZTC opens no ZTC pane of its own there: "Hosted workbenches allow one agent pane per thread."), and a service may start a one-shot headless ZTC for a turn with it set (the zerg service's doesn't yet: see the Limits under [A profile that limits the agent](#a-profile-that-limits-the-agent)). ZTC then gives Codex only the allowlisted environment, as it does on a host's `--session-file` thread ([Codex's environment](#codexs-environment)). A headless start there whose settings are its launch's, `ztc`'s or `zerg-ztc-headless`'s, doesn't start where the permission profile it holds once its startup is done (`--permission-profile`'s, a host thread's under `--headless --mirror`, or the one `config.json` saves) runs the agent's commands without requiring an OS sandbox for them, or writes and runs them but names no `allowedPaths`, by the tests `ZTC_PERMISSION_PROFILE_PINNED` applies to them: `trusted`, the default, or one that only asks for the sandbox, under which its commands, and the programs some of its tools start, would run outside one with whatever ZTC itself can reach, as root where the host runs ZTC as root; or one that requires the sandbox but names no roots, whose commands may write in whatever folder the agent runs them in (`run_command`'s `cwd`), ZTC's own state among them. Such a start is a run with a prompt or a Voyager task on its command line (`-p <prompt>`, `--prompt`, `--prompt-file`, `--voyager-task`), one on a `--session-file` thread, the mux workbench's among them, a headless mirror without mux (`--headless --mirror --no-mux`, whose prompts come through the mirror), and one that names a prompt or a thread where `ZTC_HEADLESS_MUX` is set (a headless mux gives it to every pane it opens, a shell pane's commands among them). It exits 2 before it asks any model, saying "ZTC did not start: its host runs it (ZTC_HOSTED=1), and the permission profile it would run on, trusted, 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 whatever ZTC itself can, its own state included. Start ZTC with --permission-profile and a profile that requires the OS sandbox (sandbox.requireOsEnforcement) and names the folders it may write in allowedPaths, as workspace_autonomous does, or one that runs no command (shell_exec off), or set ZTC_PERMISSION_PROFILE_PINNED=1 with such a profile.", or, for a profile with no roots, that it "lets the agent write and run commands but names no allowedPaths, so each command it runs may write in whatever folder the agent runs it in, ZTC's own state included." (`zerg-ztc-headless`, which takes no `--permission-profile`, says to save such a profile as `permissionProfile` in `config.json`, and closes the MCP servers it started before it exits). A profile that requires the OS sandbox and names its roots (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile with its `allowedPaths`, any a host's thread gives) or runs no command (`safe_edits`) starts as before, and so does the mux workbench on a thread its host wrote before it started ZTC, as ZergRouter's hosted runtime writes one, whose settings require the sandbox; on a thread not written yet, or with a prompt on its command line and no thread, the workbench is checked on its launch's profile, as any start is. The mux workbench started with neither a thread nor a prompt on its command line, whose threads get their settings from its host once it runs, isn't checked (see the Limits). With no approval service such a headless run approves by itself no call that starts a program outside the OS sandbox (an LSP tool's language server, `run_and_capture`'s command, a Claude Code or Codex pane), which a profile that asks before each command (`tests_allowed`, `ask_before_mutation`) leaves it to approve: it refuses the call, saying "Permission denied: diagnostics starts a program outside the OS sandbox, and ZTC approves no such call by itself where its host runs it (ZTC_HOSTED=1). Give the run an approval service (--approval-url or ZTC_APPROVAL_URL) to decide it, or use run_command, which runs inside the sandbox.", as under `ZTC_PERMISSION_PROFILE_PINNED`; an approval service decides one as before. Any other value is none of this |
2463
+ | `ZTC_CODEX_ENV_ALLOWLIST` | Set to `1` (or `true`) to give every Codex ZTC starts, the codex app-server and a Codex pane, only the allowlisted environment, as a hosted runtime does, with nothing else of one: none of what `ZTC_HOSTED` brings (the hosted workbench's limits, the check of a headless start's permission profile), and no pin, which needs a profile that limits the agent and an OS sandbox under it ([Codex's environment](#codexs-environment)). The zerg image's entrypoint sets it, unless its launcher sets `0`. Without it, or with another value, Codex's environment is allowlisted only where its host runs ZTC |
2456
2464
  | `ZTC_MODEL_PINNED` | Set to `1` to pin the session to the provider and model it starts on (`ZTC_PROVIDER` and `ZTC_MODEL`, or `--provider` and `--model`): `/model`, `/models set` and `/models latest`, `/provider`, `/config`'s route settings and Zerg Router address (`zrouter-url`), `/connect`, the agent's own `ztc_command`, the mirror's model picker and routing setting, a resumed session's saved route and a host effort policy that names another model (schema 2) are refused with the pinned route named. A host `--session-file` thread saved on another route runs on the pinned route, and its other settings still apply. Effort and reasoning the model takes can still change. Where `ZTC_LLM_AUTH_MODE` also pins the routing, a refused switch names the pinned route. Not held: a Morph key saved while the session runs (`/config key morph`) takes a session pinned to Morph through Zerg Router to Morph's own API unless `ZTC_LLM_AUTH_MODE=zrouter` holds too; `/profile` can move it to the routing another profile saves unless `ZTC_LLM_AUTH_MODE` pins that, and where the environment names no Zerg Router, `/profile` and `/auth login --url` can change its Zerg Router address; and a new ZTC pane is pinned to the route it opens on: another model when it names one (the web client's "+ ZTC pane", the agent's `create_ztc_pane`), the route new panes start on when it names none (`ZTC_PROVIDER` and `ZTC_MODEL` pass to a pane, `--provider` and `--model` don't) |
2457
- | `ZTC_PERMISSION_PROFILE_PINNED` | Set to `1` (or `true`) to pin the session's permission profile and sandbox as its startup leaves them: the profile `--permission-profile` names, a host's `--session-file` thread gives it (a `--headless --mirror` resident's) or `config.json` saves, with that profile's definition, the sandbox settings and the tool permissions as ZTC holds them. ZergCloud's hub sets it next to `ZTC_MODEL_PINNED`. ZTC reads it once, as its startup ends (`zerg-ztc-headless` too), so nothing later in the process unsets it. A host that pins them means them to limit the agent: where the profile ZTC would pin limits nothing (`trusted`, the default, `local_full` or an id nothing defines, unless the sandbox settings require the OS sandbox), or runs the agent's commands but asks for no OS sandbox for them (one that only turns `computer_control` off, asks before a capability or limits shell commands or network hosts, where `/status` would say `OS command sandbox: not required, and none is used`), ZTC doesn't start, whatever starts it (a one-prompt run; a resident, one on a host's thread with no settings yet included; a ZTC pane or colony cell a pinned session opens), and exits 2 saying "ZTC did not start: its host pins this session's permission profile and sandbox (ZTC_PERMISSION_PROFILE_PINNED), and the permission profile it would pin, trusted, limits nothing. Start ZTC with --permission-profile and a profile that limits the agent, such as workspace_autonomous, or unset ZTC_PERMISSION_PROFILE_PINNED.", or, for the second, that the profile "lets the agent's commands run outside an OS sandbox, where they reach ZTC's own state and the config.json the pin is taken from. Start ZTC with --permission-profile and a profile that keeps them in one (sandbox.requireOsEnforcement, as workspace_autonomous has) or runs none, or unset ZTC_PERMISSION_PROFILE_PINNED." (`zerg-ztc-headless`, which takes no `--permission-profile`, says to save such a profile as `permissionProfile` in `config.json`). Every other profile that limits the agent is pinned: one that asks for the OS sandbox for its commands, or runs none (`shell_exec` off in it or in the tool permissions), as every built-in one that limits the agent does. From then on, whoever asks (you, a controller, a relayed line, the agent), `/permissions use` and `/permissions set`, a `/profile` switch, `create` or `duplicate` to a config profile that holds other ones, the settings panel's permission profile, tool permission and sandbox rows, a host thread's later `set_session_settings` revision that names another permission profile than the session started on (the thread's then, else the pinned one), a factory reset, which would remove `config.json` (`/config reset`, the settings panel's; `ztc config reset`, run from a shell, takes no pin), and a restart in place, your own `/restart` included, while `config.json` holds an edit to them (ZTC reads the file for it whatever its inode, size and modification time say, so an edit made in place that kept them counts too) are refused with "This session's permission profile and sandbox are pinned by its host (ZTC_PERMISSION_PROFILE_PINNED): ...", which names nothing of the profile, and nothing is saved, nor anything of a refused revision taken. A revision that names that profile is taken without its profile and sandbox, which the pin holds; a session that took no thread's settings as it started, pinned on a profile no revision can name (a resident's own), takes none. The profile's relative file roots (`workspace_autonomous`'s `.`) are resolved once, against the folder the session started in (its `--cwd`, the mounted workspace), and `/permissions` names them: a `/cd` elsewhere (yours, a controller's or a relayed one), an environment the session opens, or the agent built again there moves none, so the agent's file tools outside them are refused, and so are its commands where the profile keeps them in the OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile; under a pinned profile that doesn't, a command there still runs and can read there, unless bubblewrap refuses it a folder where the host's services keep their sockets, and the sandbox, where one is used, holds only its writes to the roots). A restart in place starts the next ZTC in that folder, wherever an environment moved the session, and refuses one that would start elsewhere (a session the resume panel picks that works in another folder); it hands that ZTC the variable, whatever this process's environment says of it by then, and what its pin was taken from as `config.json` or the host's thread gives it, with no built-in profile they don't redefine and no default (so an update that rewords a built-in profile or changes a default doesn't keep that ZTC from starting), and one that finds `config.json` or the host's thread changed them after the restart's check doesn't start, saying "ZTC did not start again in place: the permission settings it would pin changed after the ZTC it replaces checked them: ..." and exiting 2. An agent's `/ztc` compares the pane's saved profile with the pinned one by the folder the pane starts in. A reload takes no `config.json` edit to them, nor to the hooks, MCP servers, skills and workflows, as under a profile that limits the agent, and a save leaves another process's edit as it made it, never writing what the pin holds as yours. `/config scope clear` leaves them (the agent's is refused, and says its host pinned them), `/permissions` shows them and says they are pinned, `/status` names the profile and says "pinned by its host (ZTC_PERMISSION_PROFILE_PINNED)", and a Claude Code or Codex pane you open starts with its permission prompts, whatever `panes.agentPermissions` says. A ZTC pane opened from the session is given the variable and pins what it starts on itself (`--permission-profile` passes to it), or doesn't start where that limits nothing; a colony cell inherits it. Not held: words that skip a Claude Code or Codex pane's permission checks (`/claude --dangerously-skip-permissions`), yours, a controller's or a relayed line's, still do, and a config profile that holds the same permission settings brings its own hooks and MCP servers, as without the pin. Without the variable, or with one that isn't `1` or `true`, nothing changes |
2465
+ | `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. It doesn't start either where ZTC's own state (`ZTC_CONFIG_DIR`, `~/.ztc`, `ZTC_SESSIONS_DIR`, `ZTC_WORKSPACE_LAYOUT_DIR`) lies inside a folder that profile lets the agent write, its relative roots those of the folder the session starts in, but as a root of its own or a folder directly in one that is no link, which both sandboxes hold whole (so a root that is your home folder, holding `~/.ztc`, and `workspace_autonomous` started there, start), nor where `TMPDIR` or `/tmp`, where ZTC's runtime keeps its credential hand-offs, lies inside one or is one: a command there could rename a folder above it and carry it off under another name, forging the `config.json` the pin is taken from or reading a credential ZTC hands over. It exits 2 naming each and the root that holds it ("ZTC did not start: its host pins this session's permission profile and sandbox (ZTC_PERMISSION_PROFILE_PINNED), and ZTC's own state lies inside a folder the permission profile it would pin, resident, lets the agent write: TMPDIR (/workspace/.tmp) inside /workspace. ...") and says to keep them outside the profile's `allowedPaths`, own state as a root of its own or a folder directly in one that is no link, or to unset the variable; a profile that writes nothing isn't checked. Nor does it start on a profile that writes and runs the agent's commands but names no `allowedPaths`, whose commands write wherever they run, ZTC's own state and `TMPDIR` among it: it says to name the folders the profile may write in its `allowedPaths` (`.` for the folder ZTC starts in), as every built-in one that limits the agent and writes 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, and `/environment service start` and `/job` run theirs as the profile has them: see the Limits under [A profile that limits the agent](#a-profile-that-limits-the-agent)). A pinned headless run (`ztc --headless` or `-p`, `zerg-ztc-headless`) with no approval service approves by itself no call that starts a program outside the OS sandbox, which a pinned profile that asks before one (`tests_allowed`, `ask_before_mutation`) left it to approve: an LSP tool's language server, `run_and_capture`'s command, a Claude Code or Codex pane. It refuses the call, saying "Permission denied: diagnostics starts a program outside the OS sandbox, and ZTC approves no such call by itself while its host pins this session's permission profile and sandbox (ZTC_PERMISSION_PROFILE_PINNED). Give the run an approval service (--approval-url or ZTC_APPROVAL_URL) to decide it, or use run_command, which runs inside the sandbox."; an approval service decides one as before, and `run_command` is still approved. 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. Codex, as the codex app-server or in a Codex pane, is given only the allowlisted environment ([Codex's environment](#codexs-environment)). 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
2466
  | `ZTC_LLM_AUTH_MODE` | `zrouter`, `direct` or `auto`, over the saved Routing setting (`ZERG_LLM_AUTH_MODE` is read when it is unset; the zerg image sets it from its deploy tier). `zrouter` and `direct` pin the routing: a switch to a route that runs another way, from `/model`, `/provider`, `/models latest`, `/config`, `/connect`, the settings panel, the mirror or the agent's `ztc_command`, and a new ZTC pane that names a provider on one, are refused with the mode named, and nothing is saved. That is a local login (Codex, Kimi Code) or a provider's own key under `zrouter`, where Morph runs through Zerg Router even with a Morph key on this machine, and Zerg Router under `direct`. Any model on that routing can still be chosen. The pin refuses switches: it doesn't move a session that starts on another routing (a default saved before it, a `ZTC_PROVIDER` or `--provider` that names a local login), nor refuse a `/profile` switch to a profile saved on one, or a new ZTC pane that names no provider, which starts on the route new panes start on. `auto` picks each provider's routing and pins none |
2459
- | `ZTC_ROUTER_RUNTIME_GRANT_FILE` | Path of a file holding the host's Router runtime grant, in place of `ZTC_ROUTER_RUNTIME_GRANT`: read once and removed as ZTC starts, so the environment ZTC was started with never holds the grant under `ZTC_ROUTER_RUNTIME_GRANT`. A copy the launcher also sets is still there: ZergCloud's launch sets the grant as `ZERG_API_TOKEN` and `ZTC_AUTH_TOKEN`, and in zrouter mode the zerg image copies `ZERG_API_TOKEN` into `ZTC_AUTH_TOKEN` when that is unset. The file keeps the grant out of ZTC's start environment only when no other variable holds it. A regular file with one name that only its owner can read; see [Credentials a host hands over](#credentials-a-host-hands-over) |
2467
+ | `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)" |
2468
+ | `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). No Codex ZTC starts is given the variable, nor the grant under any name ([Codex's environment](#codexs-environment)) |
2460
2469
  | `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 |
2461
2470
  | `ZTC_PLUGIN_PATHS` | Explicit plugin roots (platform-delimited) |
2462
2471
  | `ZTC_MODE_PATHS` | Explicit mode YAML roots (platform-delimited) |
@@ -2503,8 +2512,10 @@ under one wider than 24 columns, or beside a right-hand border is not withheld.
2503
2512
  **What a child gets.** ZTC keeps these credentials out of every child's own environment: the commands and tools its
2504
2513
  agent runs, hooks (a hook's `passEnv` can't name one, under its name or a copy's), stdio MCP servers (nor can an MCP
2505
2514
  server's `passEnv`), ZTC's native helpers, `git`, image helpers, the renderers it starts and the shells you open beside
2506
- ZTC get your environment without them. That keeps them out of what a child inherits, not out of reach of every program
2507
- (see Limits below). ZTC hands a child what it needs explicitly, and only these:
2515
+ ZTC get your environment without them. Codex, which ZTC starts as the codex app-server or in a Codex pane, gets less
2516
+ still: no platform or Router bearer at all, and where its host runs ZTC only an allowlisted environment (see
2517
+ [Codex's environment](#codexs-environment)). That keeps them out of what a child inherits, not out of reach of every
2518
+ program (see Limits below). ZTC hands a child what it needs explicitly, and only these:
2508
2519
 
2509
2520
  - A ZTC pane or colony cell ZTC opens (yours, its agent's, a split) gets the grant with the Router it names, explicit
2510
2521
  extension discovery and the host's effort policy, since it routes on them, and keeps them from its own children the
@@ -2595,31 +2606,83 @@ start takes them all.
2595
2606
  - ZTC used as a library takes nothing out of its environment, so a renderer it starts still inherits what a ZTC pane
2596
2607
  infers and routes with.
2597
2608
 
2609
+ #### Codex's environment
2610
+
2611
+ Codex runs the commands its model asks for with the environment ZTC starts it with, and so does every program its own
2612
+ `git` runs: a work tree's filter driver (a clean filter that a tracked `.gitattributes` selects and `.git/config`
2613
+ names) runs whenever Codex's git reads the work tree, even when the model's only command is `pwd`, since Codex turns
2614
+ fsmonitor and hooks off for its git but leaves filter drivers on. So every Codex ZTC starts, the codex app-server (a
2615
+ `codex_app_server` turn, the model list, the account status, the `/accounts` login) and a Codex pane (`/codex`, the
2616
+ chooser, the + menus, a resumed session, workspace-mcp's `open_pane`), is given:
2617
+
2618
+ - **No ZergAI platform or Zerg Router bearer, for anyone.** None of `ZTC_AUTH_TOKEN`, `ZERG_API_TOKEN`,
2619
+ `ZERG_AUTH_TOKEN`, `ZTC_ROUTER_RUNTIME_GRANT` and `ZTC_ROUTER_RUNTIME_GRANT_FILE`, whatever each holds (your own
2620
+ platform token too), nor any other variable holding one's value. A Codex pane has them blanked in its environment,
2621
+ and its shell unsets them again after your login files run, so one they export doesn't reach it either. On your own
2622
+ computer the rest of your environment reaches Codex: your SSH agent and toolchains, which your builds and git need,
2623
+ and in a Codex pane the sign-in methods your own Codex offers (`OPENAI_API_KEY` and the like). The app-server, which
2624
+ runs on the sign-in under its `CODEX_HOME`, is never given those.
2625
+ - **Only the allowlisted names, where Codex's environment is allowlisted:** where its host runs ZTC (`ZTC_HOSTED=1`, a
2626
+ `--headless --mirror` resident on a host's `--session-file` thread, `ZTC_PERMISSION_PROFILE_PINNED`), or asks for that
2627
+ alone (`ZTC_CODEX_ENV_ALLOWLIST=1`, which the zerg image's entrypoint sets). Codex then starts with only `CI`,
2628
+ `COLORTERM`, `FORCE_COLOR`, `HOME`, `LANG`, `LOGNAME`, `NO_COLOR`, `PATH`, `SHELL`, `TEMP`, `TERM`, `TMP`, `TMPDIR`,
2629
+ `TZ`, `USER` and `LC_*` (the names the bubblewrap sandbox gives a command), `CODEX_HOME`, the CA bundles a private CA
2630
+ or a TLS-inspecting proxy is trusted with (`CODEX_CA_CERTIFICATE`, `SSL_CERT_FILE`, `SSL_CERT_DIR`,
2631
+ `NODE_EXTRA_CA_CERTS`, `GIT_SSL_CAINFO`, `CURL_CA_BUNDLE` and `REQUESTS_CA_BUNDLE`) and the proxies (`HTTP_PROXY`,
2632
+ `HTTPS_PROXY`, `ALL_PROXY` and `NO_PROXY`, in both cases): never `CODEX_AUTH_JSON`, a key or a bearer. A Codex pane
2633
+ there also gets what its renderer gives every pane (its id, the terminal's type), starts from `/bin/sh`, not a login
2634
+ shell, whose files are its host's, and opens without ZTC's workspace tools, saying "Codex opened without ZTC's
2635
+ workspace tools (where its host keeps Codex to an allowlisted environment, a Codex pane is given no pane relay), so it
2636
+ cannot open or message other panes.": through the pane relay, what runs in the pane could open a pane with the rest of
2637
+ the environment.
2638
+
2639
+ Where Codex's environment is allowlisted, Codex runs only on the sign-in its `CODEX_HOME` holds, and nothing from the
2640
+ environment stands in for it. A Codex with none there is refused before any thread starts, as a Codex with no sign-in
2641
+ always was, and says what its host does about it: "codex_app_server has no sign-in in its CODEX_HOME, so nothing was
2642
+ sent. Where its host runs ZTC (ZTC_HOSTED, a host's thread, ZTC_PERMISSION_PROFILE_PINNED) or keeps Codex to the
2643
+ allowlisted environment (ZTC_CODEX_ENV_ALLOWLIST), Codex runs only on the sign-in its CODEX_HOME holds and is given no
2644
+ key from the environment in its place (OPENAI_API_KEY, CODEX_API_KEY, CODEX_AUTH_JSON). The host signs Codex in there
2645
+ (CODEX_HOME=<folder> codex login), or runs this thread through Zerg Router." A plain `ztc --headless --mirror` is no
2646
+ hosted runtime: it is your own session, whose Codex keeps your environment, but for the bearers.
2647
+
2648
+ **Limits.**
2649
+
2650
+ - This keeps the rest of the environment out of what Codex inherits, not out of reach of a program that looks for it:
2651
+ one running as the same user can still read the environment ZTC was started with (see the Limits under
2652
+ [Credentials a host hands over](#credentials-a-host-hands-over)), and reach the pane relay's socket where it finds it.
2653
+ - A `codex` you start yourself, in a shell pane say, gets that shell's environment, and the desktop app's native Codex
2654
+ panes, which its own launcher starts, are none of the Codex panes above.
2655
+
2598
2656
  #### A profile that limits the agent
2599
2657
 
2600
2658
  A permission profile limits the agent when it names `allowedPaths` or `deniedPaths`, shell or network limits, turns a
2601
2659
  capability off or asks before one, or keeps commands in an OS sandbox (`sandbox.requireOsEnforcement`, a backend of its
2602
2660
  own, no network there): `read_only`, the hosted `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` and
2603
2661
  `hosted_read_only`, and a resident's own profile do; `trusted`, the default, and `local_full` don't. `/status` names the
2604
- profile the agent runs under and says whether its commands must run in an OS sandbox and what enforces them here
2605
- (`OS command sandbox: required; enforced by seatbelt`, or
2662
+ profile the agent runs under and says whether its commands must run in an OS sandbox (they must under one that requires
2663
+ it, or writes nothing) and what enforces them here (`OS command sandbox: required; enforced by seatbelt`, or
2606
2664
  `not enforced: no OS sandbox on this host, so commands don't run`), never what the profile allows, which `/permissions`
2607
2665
  shows: `/status --verbose`, which adds the agent's execution facts, leaves out their permission block (the profile's
2608
2666
  capabilities, its file roots and the OS sandbox it asks for), whoever asks; the facts in the agent's own prompt keep
2609
- it. Under one:
2610
-
2611
- - **ZTC's own state is never the agent's**, but for its commands where they run outside any OS sandbox, and the ML tools
2612
- in ML mode (see the Limits). Its config folder, `~/.ztc`, its sessions and its runtime's hand-offs in a temp folder
2613
- are refused to the file tools, search, the project-context index and the host verifiers by name and, for a hard link
2614
- to one of them, by the file it is, and to the OS sandbox by name. Your own skills folder, `~/.ztc/skills`, stays
2615
- readable, never writable, where discovery is not explicit. Commands that run outside any OS sandbox read and write
2616
- that state as any program of yours does: those of a profile that runs them but asks for no OS sandbox for them (one
2617
- that only turns `computer_control`, `screen_capture`, `ml_inference` or `file_read` off, asks before a capability, or
2618
- limits shell commands or network hosts), which doesn't start under `ZTC_PERMISSION_PROFILE_PINNED` (below), and, on a
2619
- host that has none, those of one that asks for it without requiring it (`/status` says
2620
- `not enforced: no OS sandbox on this host`). A profile whose sandbox block turns the network off
2621
- (`sandbox.network: false`) asks for the OS sandbox for its commands, as one that turns its `network` capability off
2622
- does.
2667
+ it. On Linux it says `enforced by bubblewrap` only where the `bwrap` on `PATH` makes the namespaces ZTC runs commands
2668
+ in, which ZTC checks once, by running it on `/bin/true`, and otherwise `not enforced: bubblewrap is installed, but
2669
+ can't make the namespaces ZTC runs commands in here (the host must let this user create user namespaces), so commands
2670
+ fail`. A profile of your own that writes nothing runs commands only in an OS sandbox, as `read_only` does, so on a host
2671
+ with none it runs no commands. Under one:
2672
+
2673
+ - **ZTC's own state is never the agent's**, but for its commands, and the programs its tools start, where they run
2674
+ outside any OS sandbox (see the Limits). Its config folder, `~/.ztc`, its sessions and its runtime's hand-offs in a
2675
+ temp folder are refused to the file tools, search, the project-context index and the host verifiers by name and, for a
2676
+ hard link to one of them, by the file it is, and to the OS sandbox by name, which also pins the folders above them in
2677
+ the command's roots so that no command carries them off under another name (below). Your own skills folder,
2678
+ `~/.ztc/skills`, stays readable, never writable, where discovery is not explicit. Commands that run outside any OS
2679
+ sandbox read and write that state as any program of yours does: those of a profile that runs them but asks for no OS
2680
+ sandbox for them (one that only turns `computer_control`, `screen_capture`, `ml_inference` or `file_read` off, asks
2681
+ before a capability, or limits shell commands or network hosts), and, on a host that has none, those of one that asks
2682
+ for it without requiring it (`/status` says `not enforced: no OS sandbox on this host`); neither kind starts under
2683
+ `ZTC_PERMISSION_PROFILE_PINNED`, nor as a headless start its host runs under `ZTC_HOSTED=1` (below). A profile whose
2684
+ sandbox block turns the network off (`sandbox.network: false`) asks for the OS sandbox for its commands, as one that
2685
+ turns its `network` capability off does.
2623
2686
  - **ZTC's own files must be its own, with one name.** ZTC doesn't start while `config.json` (or a backup of it),
2624
2687
  `router-auth.json`, `~/.ztc/hooks_approved.json`, `~/.ztc/plugin.yaml` or a pooled account's credential file in its
2625
2688
  config folder (a Codex `auth.json`, a Kimi Code `kimi-code.json`) is a hard link, a symbolic link or not a file:
@@ -2650,17 +2713,42 @@ it. Under one:
2650
2713
  has started, `--permission-profile`'s, a host thread's (a `--headless --mirror` resident's) or the one `config.json`
2651
2714
  saves, with its definition, the sandbox and the tool permissions, is then its only one. ZTC reads the variable as its
2652
2715
  startup ends, and so does `zerg-ztc-headless`. Where that profile limits nothing (`trusted`, the default, or
2653
- `local_full`, with no sandbox setting that requires the OS sandbox), or runs the agent's commands but asks for no OS
2654
- sandbox for them (`/status` would say `OS command sandbox: not required, and none is used`: one that only turns
2655
- `computer_control` off, say), where they would reach ZTC's own state and the `config.json` the pin is taken from, ZTC
2656
- doesn't start, whatever starts it: a one-prompt run, a resident (one on a host's thread that has no settings yet
2657
- included), a ZTC pane or colony cell a pinned session opens. It exits 2, saying that its host pins the permission
2658
- settings and the profile it would pin limits nothing, or lets the agent's commands run outside an OS sandbox, and to
2659
- start ZTC with `--permission-profile` and a profile that limits the agent, or, for the second, one that keeps them in
2660
- one (`sandbox.requireOsEnforcement`, as `workspace_autonomous` has) or runs none (`zerg-ztc-headless`: to save one as
2661
- `permissionProfile`), or to unset the variable. Every other profile that limits the agent is pinned: one that asks for
2662
- the OS sandbox for its commands, or runs none, as every built-in one that limits the agent does. You, a controller, a
2663
- relayed line and the agent are all
2716
+ `local_full`, with no sandbox setting that requires the OS sandbox), or runs the agent's commands without requiring an
2717
+ OS sandbox for them, whether it asks for none (`/status` would say
2718
+ `OS command sandbox: not required, and none is used`: one that only turns `computer_control` off, say) or only asks
2719
+ for one (`not required; enforced by seatbelt`: one that names `allowedPaths`, say, under which the LSP tools,
2720
+ `run_and_capture` and `workflow` start programs outside the sandbox), where they could reach ZTC's own state and the
2721
+ `config.json` the pin is taken from, ZTC doesn't start, whatever starts it: a one-prompt run, a resident (one on a
2722
+ host's thread that has no settings yet included), a ZTC pane or colony cell a pinned session opens. It exits 2, saying
2723
+ that its host pins the permission settings and the profile it would pin limits nothing, or doesn't require an OS
2724
+ sandbox, and to start ZTC with `--permission-profile` and a profile that limits the agent, or, for the second, one
2725
+ that requires the OS sandbox (set `sandbox.requireOsEnforcement` to true in it, as `workspace_autonomous` does) or
2726
+ runs no command (`shell_exec` off) (`zerg-ztc-headless`: to save one as `permissionProfile`), or to unset the
2727
+ variable. Every other profile that limits the agent is pinned: one that requires the OS sandbox for its commands
2728
+ (`sandbox.requireOsEnforcement` in it or in the sandbox settings, or one that writes nothing), or runs none, as every
2729
+ built-in one that limits the agent does. It doesn't start either where ZTC's own state (`ZTC_CONFIG_DIR`, `~/.ztc`,
2730
+ `ZTC_SESSIONS_DIR`, `ZTC_WORKSPACE_LAYOUT_DIR`) lies inside a folder that profile lets the agent write (its relative
2731
+ roots are the folder the session starts in), but as a root of its own or a folder directly in one that is no link,
2732
+ which both sandboxes hold whole, so a root that is your home folder, and `workspace_autonomous` started there, start;
2733
+ nor where `TMPDIR` or `/tmp`, where ZTC's runtime keeps its credential hand-offs, lies inside one or is one. A command
2734
+ there could rename a folder above it and carry it off under another name, forging the `config.json` the pin is taken
2735
+ from or reading a credential ZTC hands over. It exits 2, naming each and the root that holds it, and says to keep them
2736
+ outside the profile's `allowedPaths` (own state may be a root of its own or a folder directly in one that is no link)
2737
+ or to unset the variable; a profile that writes nothing isn't checked. Nor does it start on a profile that writes and
2738
+ runs the agent's commands but names no `allowedPaths`, whose commands write wherever they run, `TMPDIR` among it: it
2739
+ says to name the folders the profile may write in its `allowedPaths` (`.` for the folder ZTC starts in). Your own
2740
+ commands (`!cmd` and `/shell`, `/diff`'s git, the commands `/optimize` runs), yours or a controller's, then run only
2741
+ inside the OS sandbox too, as the agent's do, under the pinned profile's roots with ZTC's own state hidden, even under
2742
+ one that runs none of the agent's (`safe_edits`), so they reach neither that state nor the `config.json` the pin is
2743
+ taken from, and where no OS sandbox is usable they are refused ("OS sandbox enforcement required but unavailable:
2744
+ ..."); the Ink interface's, and your hooks under a profile that runs no command, run outside it, and
2745
+ `/environment service start` and `/job` run theirs as the profile has them (see the Limits). A pinned headless run
2746
+ (`ztc --headless` or `-p`, `zerg-ztc-headless`) with no approval service approves by itself no call that starts a
2747
+ program outside the OS sandbox, which a pinned profile that asks before one (`tests_allowed`, `ask_before_mutation`)
2748
+ left it to approve (an LSP tool's language server, `run_and_capture`'s command, a Claude Code or Codex pane): it
2749
+ refuses the call, saying to give the run an approval service (`--approval-url` or `ZTC_APPROVAL_URL`) to decide it or
2750
+ to use `run_command`, which is still approved; so does a headless run its host runs under `ZTC_HOSTED=1` without the
2751
+ pin (below). You, a controller, a relayed line and the agent are all
2664
2752
  refused `/permissions use` and `set`, a `/profile` switch to a config profile that holds other ones, the settings
2665
2753
  panel's rows for them, a factory reset (it would remove `config.json`; `ztc config reset` from a shell takes no pin),
2666
2754
  and a restart in place (your `/restart` too) while `config.json` holds an edit to them. The host is refused a thread
@@ -2674,17 +2762,44 @@ it. Under one:
2674
2762
  folder the pane starts in. The pinned profile's relative file roots (`workspace_autonomous`'s `.`) are the folder the
2675
2763
  session started in, its mounted workspace, and `/permissions` names them (`File roots: /path/to/workspace`). A `/cd`
2676
2764
  elsewhere (yours, a controller's or a relayed one), or an environment the session opens, moves none: the agent, built
2677
- again there, is still refused its file tools outside them, and its commands there where the profile keeps them in the
2678
- OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement` profile). Under a
2679
- pinned profile that doesn't, a command there still runs and can read there (bubblewrap refuses one in a folder where
2680
- the host's services keep their sockets, below); the sandbox, where one is used, holds only its writes to the roots. A
2681
- restart in place starts the next ZTC in the folder the session started in, wherever an environment moved the session,
2682
- and is refused where it would start elsewhere (a session the resume panel picks that works in another folder, or that
2683
- folder gone). The ZTC that starts is handed the variable itself and what the pin was taken from, as `config.json` or
2684
- the host's thread gives it: where they changed the pinned settings after the restart's check, it doesn't start, says
2685
- so ("ZTC did not start again in place: the permission settings it would pin changed after the ZTC it replaces checked
2686
- them: ..."), and exits 2, so its host or you start it again. No built-in profile they don't redefine and no default
2687
- goes with it, so an update that rewords a built-in profile or changes a default doesn't keep it from starting.
2765
+ again there, is still refused its file tools outside them, and its commands there, which every pinned profile that
2766
+ runs them keeps in the OS sandbox (`workspace_autonomous`, `ask_before_mutation`, a resident's `requireOsEnforcement`
2767
+ profile). A restart in place starts the next ZTC in the folder the session started in, wherever an environment moved
2768
+ the session, and is refused where it would start elsewhere (a session the resume panel picks that works in another
2769
+ folder, or that folder gone). The ZTC that starts is handed the variable itself and what the pin was taken from, as
2770
+ `config.json` or the host's thread gives it: where they changed the pinned settings after the restart's check, it
2771
+ doesn't start, says so ("ZTC did not start again in place: the permission settings it would pin changed after the ZTC
2772
+ it replaces checked them: ..."), and exits 2, so its host or you start it again. No built-in profile they don't
2773
+ redefine and no default goes with it, so an update that rewords a built-in profile or changes a default doesn't keep
2774
+ it from starting. It takes what it was handed (`ZTC_PERMISSION_PIN_SOURCE`) out of its environment as it starts,
2775
+ before any MCP server connects, and no MCP server, hook, pane or command is given that variable, whatever an MCP
2776
+ server's `passEnv` names.
2777
+ A pinned ZTC doesn't update itself, since an update would put a ZTC its host didn't choose in its place: `/update`
2778
+ installs nothing, saying why (naming the variable) and to update ZTC where its host starts it, or with `ztc update`
2779
+ from a shell; the native interface's start-up check, which installs a newer release with npm and starts it in place,
2780
+ doesn't run; and the desktop app is given no context to start that ZTC again with, without which its updater installs
2781
+ no app update while that ZTC runs.
2782
+ - **A headless start its host runs keeps the agent's commands in an OS sandbox** (`ZTC_HOSTED=1`, which a host sets
2783
+ where it runs ZTC for someone), whether or not the host pins the profile. A start whose settings are its launch's,
2784
+ `ztc`'s or `zerg-ztc-headless`'s, doesn't start where the profile it holds once its startup is done
2785
+ (`--permission-profile`'s, a host thread's or the one `config.json` saves) runs the agent's commands without
2786
+ requiring an OS sandbox for them, or writes and runs them but names no `allowedPaths`, by the tests the pin applies
2787
+ (above): `trusted`, the default, or one that only asks for the sandbox, under which its commands, and the programs
2788
+ some of its tools start, would run outside one with whatever ZTC itself can reach; or one that requires the sandbox
2789
+ but names no roots, whose commands may write in whatever folder the agent runs them in. Such a start is a run with a
2790
+ prompt or a Voyager task on its command line (`-p <prompt>`, `--prompt`, `--prompt-file`, `--voyager-task`), one on
2791
+ a `--session-file` thread, a headless mirror without mux, and one that names a prompt or a thread where
2792
+ `ZTC_HEADLESS_MUX` is set (every pane of a headless mux has it). It exits 2 before it asks any model, naming the
2793
+ variable and saying to start ZTC with `--permission-profile` and a profile that requires the OS sandbox
2794
+ (`sandbox.requireOsEnforcement`) and names the folders it may write in `allowedPaths`, as `workspace_autonomous`
2795
+ does, or one that runs no command (`shell_exec` off), or to set `ZTC_PERMISSION_PROFILE_PINNED=1` with such a profile
2796
+ (`zerg-ztc-headless`: to save one as `permissionProfile` in `config.json`). The mux workbench (a `--headless --mirror`
2797
+ or `--headless-mirror` without `--no-mux`) is checked on a `--session-file` thread or a prompt on its command line
2798
+ too: on a thread its host wrote before it started ZTC, as ZergRouter's hosted runtime writes one, the thread's
2799
+ settings, which require the sandbox, are its profile, and it starts; on one not written yet it holds its launch's.
2800
+ Started with neither, its threads get their settings from its host once it runs, and it starts as before (see the
2801
+ Limits). With no approval service such a run approves no call that starts a program outside the OS sandbox by
2802
+ itself, as a pinned one doesn't (above), and says the variable is why.
2688
2803
  - **Hooks run inside the OS sandbox the profile requires, or not at all**, except under a profile whose agent writes
2689
2804
  nothing (`read_only`, `hosted_read_only`), where your own approved hooks run as before. In the sandbox a hook reads,
2690
2805
  beside the system's folders and the project, its own code, read-only: the program its command line starts (found on
@@ -2703,24 +2818,33 @@ it. Under one:
2703
2818
  the computer-use routine tools (`computer_run_routine`, `computer_save_routine`, `computer_list_routines`,
2704
2819
  `computer_delete_routine`, whose runner runs the agent's JavaScript outside any sandbox), the LSP tools
2705
2820
  (`goto_definition`, `find_references`, `hover`, `diagnostics`, `lsp_status`, whose language server runs the
2706
- workspace's code: rust-analyzer runs a crate's build script), and through `ztc_command` `/claude`, `/codex`,
2707
- `/zerg launch`, `/zerg serve` and `/debug headlines` are refused and not offered, the routine tools whatever the
2708
- profile says of `computer_control`. A profile that runs no command (`hosted_read_only`, `safe_edits`, `locked_down`)
2709
- doesn't offer the LSP tools, the routine tools or `create_supervised_ztc_pane` either, and the file an LSP tool names
2710
- is checked as `read_file`'s path is. A profile that asks before each shell command (`tests_allowed`,
2711
- `ask_before_mutation`) asks, and you decide; a call it refuses whatever you answer (a working directory or a path
2712
- outside its roots, a file a patch writes there, the file an LSP tool reads there) is refused without asking you, the
2713
- last with `Permission denied: path is outside allowed profile roots (<file>). <tool> read nothing.` A language server
2714
- the LSP tools started stops once the permissions change to ones that don't admit those tools without asking (through
2821
+ workspace's code: rust-analyzer runs a crate's build script), the ML tools in ML mode (`ml_load_model`, `ml_infer`,
2822
+ `ml_train`, `ml_status`, which start ZTC's ML helper, `ztc-ml`, and hand it files), and through `ztc_command`
2823
+ `/claude`, `/codex`, `/zerg launch`, `/zerg serve` and `/debug headlines` are refused and not offered, the routine
2824
+ tools whatever the profile says of `computer_control`. A profile that runs no command (`hosted_read_only`,
2825
+ `safe_edits`, `locked_down`) doesn't offer the LSP tools, the routine tools, the ML tools or
2826
+ `create_supervised_ztc_pane` either. The file an LSP tool names is checked as `read_file`'s path is, and so are the
2827
+ weights `ml_load_model` loads and the session data `ml_train` trains on, while the place `ml_train` saves weights to
2828
+ is checked as `write_file`'s path is, each resolved against the agent's folder. A profile that asks before each shell
2829
+ command (`tests_allowed`, `ask_before_mutation`) asks, and you decide; a call it refuses whatever you answer (a
2830
+ working directory or a path outside its roots, a file a patch writes there, the file an LSP tool or an ML tool reads
2831
+ there, the weights `ml_train` would save there) is refused without asking you, a file read with
2832
+ `Permission denied: path is outside allowed profile roots (<file>). <tool> read nothing.` A language server the LSP
2833
+ tools started is ended once the permissions change to ones that don't admit those tools without asking (through
2715
2834
  `/permissions use` or `set`, the settings panel's permission profile, tool permission and sandbox rows, `/profile` or
2716
2835
  a host's revision: a switch to `workspace_autonomous`, `ask_before_mutation`, `tests_allowed` or `read_only`,
2717
- `shell_exec` turned off, the OS sandbox required), so none goes on building the workspace outside the sandbox; under
2718
- permissions that admit them without asking (`trusted`, `local_full`) it keeps running, and the next call admitted
2719
- starts one again. The agent built again under the same permissions (after a `/model` switch or a `/cd`) stops none,
2720
- so one you approved under `tests_allowed` or `ask_before_mutation` keeps running until a change of the permissions
2721
- stops it as above. `run_command`, `delegate_task`, Claude Code's `Bash`, `WebFetch`, `Glob` and `Task`, MCP tools and
2722
- `/ztc` (whose pane runs under permissions no wider than this one's) stay. There, a `run_command` (or Codex's
2723
- `exec_command`) whose working directory is outside the profile's roots is refused before it runs, with
2836
+ `shell_exec` turned off, the OS sandbox required): ZTC asks it to shut down and exit, and once it has left, or a
2837
+ second after it was asked to exit, ends what is left of its process group, the server and what it started there; a
2838
+ server that doesn't answer the request to shut down is ended the same way once ZTC has waited 10 seconds for the
2839
+ answer and a second more (each server leads a process group and session of its own on macOS and Linux, so the
2840
+ Ctrl+C or hangup your terminal sends ZTC no longer reaches it; on Windows the server alone is ended). So none goes on
2841
+ building the workspace outside the sandbox; under permissions that admit them without asking (`trusted`,
2842
+ `local_full`) it keeps running, and the next call admitted starts one again. The agent built again under the same
2843
+ permissions (after a `/model` switch or a `/cd`) stops none, so one you approved under `tests_allowed` or
2844
+ `ask_before_mutation` keeps running until a change of the permissions stops it as above. `run_command`,
2845
+ `delegate_task`, Claude Code's `Bash`, `WebFetch`, `Glob` and `Task`, MCP tools and `/ztc` (whose pane runs under
2846
+ permissions no wider than this one's) stay. There, a `run_command` (or Codex's `exec_command`) whose working
2847
+ directory is outside the profile's roots is refused before it runs, with
2724
2848
  `Permission denied: working directory is outside allowed profile roots (<folder>)`, and one in a folder it denies with
2725
2849
  `Permission denied: working directory is blocked by profile (<folder>)`; each goes on to name the profile's roots to
2726
2850
  run the command in instead (`Run the command in a folder inside this profile's roots (...)`), or the session's folder,
@@ -2736,36 +2860,108 @@ it. Under one:
2736
2860
  the command runs. Under a profile that names `allowedPaths`, the folder a `run_command` names as its `cwd` is no root
2737
2861
  of its own, so a command there can't write outside the workspace (`.` used to name that folder); one that names none
2738
2862
  keeps the folder a command runs in as its write root, while its relative `deniedPaths` are the session's folder's. The
2739
- sandbox audit's `allowed_paths` and `denied_paths` name the roots so. macOS's sandbox holds every root by its real
2740
- path too, as it matches only real paths, so with the session's folder named through a link (a `/cd` to it by another
2741
- name) a command still writes in the workspace, and a relative denial still keeps it out of the denied folder.
2742
- bubblewrap enters a working directory named through a link into the workspace by its real path, and binds read-only
2743
- one outside the roots that a profile not requiring the sandbox lets a command run in, so the command starts. Where
2744
- that folder is one where the host's services keep their sockets (`/tmp`, `/run`, `/var/run`, `/var/tmp`, the session's
2745
- `XDG_RUNTIME_DIR`), lies in one (tmux's `/tmp/tmux-<uid>`) or holds one (`/var`, or `/`, which holds them all), it
2746
- binds nothing, since a read-only bind would put those sockets in reach (tmux's, the session bus, `docker.sock`): the
2747
- command doesn't start, and is refused with
2863
+ sandbox audit's `allowed_paths` and `denied_paths` name the roots so. Both sandboxes hold every root by its real path
2864
+ too: macOS's matches only real paths, and bubblewrap binds a root named through a link as named and by its real path,
2865
+ and hides, or holds read-only, at both spellings what the plan keeps from a command in it (a denial, ZTC's own state,
2866
+ a hook's own files, where its repository names the programs git starts). So with the session's folder named through a
2867
+ link (a `/cd` to it by another name) a command still writes in the workspace, and a relative denial still keeps it out
2868
+ of the denied folder. bubblewrap enters a working directory named through a link into the workspace by its real path.
2869
+ One outside the roots and the system's folders every command reads (`/usr`, `/bin`, `/etc`), which a profile not
2870
+ requiring the sandbox lets a command run in, it binds read-only, so the command starts, only where a filter refuses
2871
+ the command Unix sockets (a profile without network, on x86-64 and arm64). Where none does, a read-only bind would
2872
+ leave a host service's socket in that folder, or below it, in the command's reach, so bubblewrap binds no such folder:
2873
+ the command doesn't start, and is refused with "Permission denied: working directory is outside this profile's roots
2874
+ (<folder>), and bubblewrap binds no folder outside them for a command that may use the network: a host service's
2875
+ socket in it would be in the command's reach. Run the command in a folder inside this profile's roots (<roots>): give
2876
+ it one there as its working directory, or none to run it in the session's folder.", the last words only where a root
2877
+ holds the session's folder (under `allowedPaths: ['./build']` none does, and a command in the session's folder is
2878
+ refused too). Without network, on an architecture ZTC has no such filter for (anything but x86-64 and arm64), the
2879
+ refusal says "for a command no filter keeps from Unix sockets, as ZTC has none for this architecture" in place of
2880
+ "for a command that may use the network". Whatever the network, a working directory that is a folder where the host's
2881
+ services keep their sockets (`/tmp`, `/var/tmp`, `/dev/shm`, `/run`, `/var/run`, `/run/user`, the session's
2882
+ `XDG_RUNTIME_DIR`), lies in one (tmux's `/tmp/tmux-<uid>`; a drive the host mounts for you in `/run/media` lies in
2883
+ none, below) or holds one (`/var`, or `/`, which holds them all) is never bound so, since a read-only
2884
+ bind would put those sockets in reach (tmux's, the session bus, `docker.sock`): the command doesn't start, and is
2885
+ refused with
2748
2886
  `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2749
2887
  `lies in <folder>, where ...`, `holds <folder>, where ...`, and for `/` `holds the folders where ...`), followed by
2750
2888
  where to run it instead: a folder inside the profile's roots, or none, to run it in the session's folder.
2751
2889
  - **Where the agent's commands keep the network, bubblewrap binds no root that would put the host's services' sockets in
2752
- their reach**, as no filter refuses them Unix sockets there: it plans no command whose root is `/`, or is or holds one
2753
- of the folders above, judged as named and by where a link leads, and its refusal says what to do instead. A root the
2754
- profile names is refused with "Permission denied: this profile's root is a folder where the host's services keep their
2755
- sockets (/tmp), which bubblewrap keeps out of a command's reach. Name a project's folder in its allowedPaths instead,
2756
- to run commands under it." (or `holds <folder>, where ...`, and for `/` `holds the folders where ...`). Its relative
2757
- root (`workspace_autonomous`'s `.`) in a session started in `/tmp` or `/` keeps every command from running, the
2758
- refusal ending "Start ZTC in a project's folder, which its relative root (.) then names, to run commands under it."
2759
- Under a profile that names no `allowedPaths` (`trusted` where the sandbox settings require the OS sandbox, or one of
2760
- your own), whose only root is the folder a command runs in, that folder is refused where it is `/`, is or holds one of
2761
- those folders, or lies in one outside the session's folder (`/tmp/tmux-<uid>`), with
2890
+ their reach**, as no filter refuses them Unix sockets there: it plans no command whose root is `/`, is or holds one of
2891
+ the folders above, or lies in one of the host's runtime folders (`/run`, `/var/run`, `/run/user`, the session's
2892
+ `XDG_RUNTIME_DIR`) but on a drive the host mounts for you in `/run/media` (below), judged as named and by where a link
2893
+ leads, and its refusal says what to do instead. A root the profile names is refused with "Permission denied: this
2894
+ profile's root is a folder where the host's services keep their sockets (/tmp), which bubblewrap keeps out of a
2895
+ command's reach. Name a project's folder in its allowedPaths instead, to run commands under it." (or
2896
+ `holds <folder>, where ...`,
2897
+ `lies in /run, where the host's services keep their sockets (/run/postgresql)`, and for `/`
2898
+ `holds the folders where ...`). Its relative root (`workspace_autonomous`'s `.`) in a session started in `/tmp` or `/`
2899
+ keeps every command from running, the refusal ending "Start ZTC in a project's folder, which its relative root (.)
2900
+ then names, to run commands under it." Under a profile that names no `allowedPaths` (`trusted` where the sandbox
2901
+ settings require the OS sandbox, or one of your own), whose only root is the folder a command runs in, that folder is
2902
+ refused where it is `/`, is or holds one of those folders, lies in a runtime folder, or lies in a scratch folder
2903
+ (`/tmp`, `/var/tmp`, `/dev/shm`) outside the session's folder (`/tmp/tmux-<uid>`), with
2762
2904
  `Permission denied: working directory is a folder where the host's services keep their sockets (<folder>)` (or
2763
2905
  `lies in`, `holds` as above), followed by "Run the command in another folder, such as a project's: give it one as its
2764
- working directory, or none to run it in the session's folder." A root that only lies in one of those folders
2765
- (`/tmp/proj`) is bound as before, as are the session's own folder there and the folders in it under a profile that
2766
- names no `allowedPaths`, and a profile without network, whose commands bubblewrap refuses Unix sockets on x86-64 and
2767
- arm64, plans its commands as before. A plan refused for its roots records no repository of theirs in
2768
- `~/.ztc/sandbox/known-repositories.json`.
2906
+ working directory, or none to run it in the session's folder." A root that only lies in a scratch folder (`/tmp/proj`)
2907
+ is bound as before, as are the session's own folder there and the folders in it under a profile that names no
2908
+ `allowedPaths`, and a profile without network, whose commands bubblewrap refuses Unix sockets on x86-64 and arm64,
2909
+ plans its commands as before. A drive the host mounts for you in `/run/media` (udisks2's `/run/media/<user>/<drive>`,
2910
+ on Fedora, Arch and openSUSE) is no folder where the host's services keep their sockets: a project there is bound as
2911
+ any project's folder is, as a root the profile names, as `workspace_autonomous`'s `.` in a session started there and
2912
+ as the folder a profile that names no `allowedPaths` runs a command in, and a working directory there outside the
2913
+ roots is treated as any other folder outside them. The rest of `/run` is refused, `/run/user/<uid>/gvfs` (GNOME's
2914
+ network shares) and `/run/host` (the host's root in a Toolbx or Distrobox container) among it (see the Limits). A
2915
+ plan refused for its roots records no repository of theirs in `~/.ztc/sandbox/known-repositories.json`.
2916
+ - **A denied path that doesn't exist yet can't be made in the sandbox.** macOS's sandbox denies a path by its name,
2917
+ whether or not it exists. bubblewrap hides a path with a mount over it, which needs something there, so where a
2918
+ `deniedPaths` entry, or one of the folders of ZTC's own state (`~/.ztc`, its config folder, `ZTC_SESSIONS_DIR`,
2919
+ `ZTC_WORKSPACE_LAYOUT_DIR`), doesn't exist when a command starts, in a root the command writes, it stands an empty
2920
+ read-only folder over it for the command's run: the command can make neither it nor anything in it
2921
+ (`Read-only file system`, `Is a directory` or `File exists`), so a denied `.env` or `.github/workflows` stays unmade,
2922
+ and no command can rename a folder above it away to make it anew (below). bwrap makes that folder on the host, as you,
2923
+ and it stands there for the whole of the command's run, a background command's too; every command this ZTC plans
2924
+ meanwhile stands one there again, and ZTC removes it once the last of those commands ends, keeping one that something
2925
+ was put in. Meanwhile your other programs see an empty folder there: writing `.env`, or reading it as dotenv and
2926
+ `docker compose` do, gets `Is a directory`, and a file watcher sees the folder come and go around each command. A file
2927
+ you put at the path while such a command runs, once you have removed its folder, is hidden from the next command as a
2928
+ file is, with `/dev/null` over it. None is put outside the roots the command writes, under a read-only or emptied
2929
+ mount, under a profile that writes nothing, inside another one, or in a folder you can't write, where the command can
2930
+ make nothing either (see the Limits). On both, a folder above a denied path that doesn't exist either (`.github`, for
2931
+ a denied `.github/workflows`) is made before the command starts, as you and only inside the roots the command writes
2932
+ (by bwrap, or on macOS by ZTC), and pinned as every folder above a denial is (below): it stays writable, so
2933
+ `.github/dependabot.yml` and `.github/ISSUE_TEMPLATE/` land beside the denied `.github/workflows`, and a checkout adds
2934
+ `.github/CODEOWNERS` there, but no command can remove it or rename it away. It is an ordinary folder on the host
2935
+ meanwhile, and ZTC removes it once the commands it was made for have ended, if nothing was put in it.
2936
+ - **No command carries off what the sandbox hides with a folder above it.** Both sandboxes hide a denied path, ZTC's own
2937
+ state and its runtime's hand-offs by their paths, and a rename of a folder above one moved it out from under that: a
2938
+ command renamed `config` above a denied `config/prod/secrets.json` and read the file under its new name (on macOS in
2939
+ the same command, under bubblewrap in the next, whose plan hides the path by its old name), renamed a folder above a
2940
+ denial away and made the denied path anew, or built it elsewhere and renamed a folder into its place; ZTC's
2941
+ `config.json` two levels inside a root could be forged so, and a hand-off read in a `TMPDIR` inside one. Now every
2942
+ folder from a root the command writes down to a denied path, and, under a profile that limits the agent, to ZTC's own
2943
+ state and to its runtime's temp folder (`TMPDIR`, `/tmp`) where that lies inside a root, is pinned as itself:
2944
+ bubblewrap binds each onto itself, so a `mv` or `rmdir` of it gets `Device or resource busy`, and macOS's sandbox
2945
+ denies removing or making each as itself, so a `mv` of it, or of another folder into its place, gets
2946
+ `Operation not permitted`, exchange and exclusive renames included. It stays writable: a command writes in it as
2947
+ before, and on macOS `touch`, `chmod`, extended attributes and `tar`'s or `cp -p`'s restore of its times still work on
2948
+ it. macOS's sandbox pins a link among those folders as itself. bubblewrap can stand no mount on a link, so it plans no
2949
+ command whose `deniedPaths` entry is named through a symbolic link in a folder the command may write, the path itself
2950
+ included (`./secrets` a link to `.vault`), nor, under a profile that limits the agent, one whose ZTC's own state is:
2951
+ the command doesn't start, and the refusal names the link and what to name instead ("ZTC did not start this command:
2952
+ its permission profile denies ./secrets (/workspace/secrets), named through a link in a folder the command may write
2953
+ (/workspace/secrets). bubblewrap hides a path by a mount, which stands where a link leads and never on the link
2954
+ itself, so a command could remove or rename the link, and the next command would see what the denial hides at its real
2955
+ path. Name the denial by its real path (/workspace/.vault) in the profile's deniedPaths."; for ZTC's own state, to
2956
+ name `ZTC_CONFIG_DIR`, `HOME`, `ZTC_SESSIONS_DIR` and `ZTC_WORKSPACE_LAYOUT_DIR` by their real paths, or keep them
2957
+ outside the profile's roots). A link outside the roots the command writes, or one no hidden path runs through, plans
2958
+ as before. bubblewrap pins at most 256 folders a plan, besides those it pins for the repositories' git programs, and
2959
+ refuses a plan that would pin more: "ZTC did not start this command: hiding what its permission profile denies, and
2960
+ ZTC's own state, would pin 300 folders above them in the roots the command writes (each bound onto itself, so that no
2961
+ command can rename it away), more than the 256 a plan pins. Name fewer or shallower deniedPaths, or keep ZTC's own
2962
+ state (ZTC_CONFIG_DIR, ~/.ztc, ZTC_SESSIONS_DIR, ZTC_WORKSPACE_LAYOUT_DIR) and TMPDIR outside the profile's roots."
2963
+ macOS's sandbox has no such cap. Only the folders above something a plan hides are pinned, and a pinned folder can't
2964
+ be removed or renamed, with what that costs (see the Limits).
2769
2965
  - **On macOS, a sandboxed command that keeps the network gets IP networking and the system's name resolver, and connects
2770
2966
  to no other Unix socket.** It connects out to any address, listens and accepts on local ones and resolves names
2771
2967
  through the resolver's socket (`mDNSResponder`), but no other Unix socket is in its reach, in its workspace or outside
@@ -2836,29 +3032,105 @@ programs.
2836
3032
  stop ZTC, or ask it to start again in place (`kill -USR1`), which takes no `config.json` edit to the settings above.
2837
3033
  bubblewrap gives a command processes of its own.
2838
3034
  - On Linux, bubblewrap refuses no Unix socket to a command whose profile leaves it the network. It keeps the folders
2839
- where the host's services keep their sockets out of the command's reach (above), but the command shares the host's
2840
- network, and with it the host's abstract sockets, and reaches a socket file in any folder it binds: a root at or
2841
- above your home folder holds the sockets programs keep there (Docker Desktop's `~/.docker/desktop/docker.sock`), and
2842
- a profile of your own that writes nothing and names no `allowedPaths` binds every folder, read-only, but the socket
2843
- folders. `read_only` keeps its commands off the network and, on x86-64 and arm64, refuses them Unix sockets.
2844
- - On Linux, `/status` says `enforced by bubblewrap` wherever `bwrap` is on `PATH`, without checking that it can create
2845
- the namespaces ZTC asks of it. Where it can't (a host or container that restricts user namespaces), every sandboxed
2846
- command fails with bubblewrap's error, and none runs outside the sandbox.
3035
+ where the host's services keep their sockets out of the command's reach, and binds no folder outside the roots for it
3036
+ to run in (above), but the command shares the host's network, and with it the host's abstract sockets, and reaches a
3037
+ socket file in any folder it binds: a root at or above your home folder holds the sockets programs keep there (Docker
3038
+ Desktop's `~/.docker/desktop/docker.sock`), and a profile of your own that writes nothing and names no `allowedPaths`
3039
+ binds every folder, read-only, but the socket folders. `read_only` keeps its commands off the network and, on x86-64
3040
+ and arm64, refuses them Unix sockets.
3041
+ - On Linux, a project in `/run/user/<uid>/gvfs` (GNOME's network shares) or in `/run/host` (the host's root in a Toolbx
3042
+ or Distrobox container, its `/run` and sockets included) lies in `/run`, so where no filter keeps commands from Unix
3043
+ sockets (a profile that keeps the network) bubblewrap plans no command with a root there (above). Turn the profile's
3044
+ network off (`sandbox.network: false`), whose filter keeps commands from Unix sockets on x86-64 and arm64, or work on
3045
+ a copy elsewhere.
3046
+ - On Linux, where `bwrap` is on `PATH` but can't make the namespaces ZTC asks of it (a host or container that doesn't
3047
+ let the user create user namespaces, as Ubuntu 24.04's AppArmor doesn't by default), every sandboxed command fails
3048
+ with bubblewrap's error, and none runs outside the sandbox, a profile's that only asks for it included; `/status`
3049
+ says so (above).
3050
+ - ZTC removes the empty folders it makes for a denied path not made yet (above) once the command ends, bwrap's
3051
+ placeholder and the folders above it under bubblewrap, the folders above it on macOS: one can stay where ZTC is killed
3052
+ while the command runs, and where it exits or starts again in place then, since it stops a running command without
3053
+ waiting for it to end (remove it with `rmdir`). One ZTC doesn't count another's: where two run commands in one
3054
+ workspace at once with the same denied path not made yet, the end of one's command can remove a folder the other's
3055
+ command stands on, and under bubblewrap that command can then make the denied path, while on macOS it can no longer
3056
+ make the folder above it that the other ZTC made and removed.
3057
+ - Under bubblewrap each pinned folder (above) is a mount of its own, and a rename works within one mount only: a rename
3058
+ into or out of a pinned folder fails with `Invalid cross-device link`, as
3059
+ `git mv config/prod/app.yml config/staging/app.yml` does beside a denied `config/prod/secrets.json`, and so does a
3060
+ move from the root's own part into a pinned folder or, where `TMPDIR` lies inside a root and holds a hand-off of
3061
+ ZTC's, of a temp file from it into the workspace. `git mv`, Node's `fs.rename`, Rust's `std::fs::rename` and Python's
3062
+ `os.rename` fail so; GNU `mv` and Python's `shutil.move` copy instead. A rename within one pinned folder, or within
3063
+ the root's own part, goes through, and only the folders above something a plan hides are pinned: a profile that names
3064
+ no `deniedPaths`, with ZTC's own state and `TMPDIR` outside its roots, pins none.
3065
+ - On both, a command can't remove or rename a pinned folder (above): `rm -rf dist`, where `dist` holds a denied
3066
+ `dist/secret.key`, fails at `dist` (remove what is in it instead), and `git mv config cfg` above a denied
3067
+ `config/prod/secrets.json` is refused.
3068
+ - Under bubblewrap, ZTC's runtime hand-offs in a temp folder are hidden one by one, as they are when a command is
3069
+ planned, and the folders above those that exist then pinned: where `TMPDIR` lies in a command's view (inside or equal
3070
+ to a root the command writes, as it can be for a command a profile that names no `allowedPaths` runs in `TMPDIR` or
3071
+ `/tmp`), a hand-off ZTC makes while that command runs (a pane's credential or input, the host credential a relaunch is
3072
+ handed) is in its reach, and a `TMPDIR` that holds none when the command is planned isn't pinned, so that command can
3073
+ rename it. macOS's sandbox denies the hand-offs by pattern, now or later. `ZTC_PERMISSION_PROFILE_PINNED` keeps
3074
+ `TMPDIR` out of the agent's commands' roots (above).
3075
+ - bubblewrap binds each pinned folder by its path, which bwrap looks up again as it starts the command: a command still
3076
+ running from an earlier plan (one left in the background), for which that folder wasn't pinned, could replace it with
3077
+ a link in between, and bwrap would bind where the link leads. ZTC checks the folders as it plans the command, not as
3078
+ bwrap binds them.
3079
+ - bubblewrap's cap counts the folders a plan pins, not the bytes of bwrap's arguments: a profile with many long
3080
+ `deniedPaths` (up to 128 of up to 2,048 characters each) can make a plan whose arguments pass Linux's limit (2 MiB by
3081
+ default), and then bwrap starts no command (`Argument list too long`).
2847
3082
  - A restart in place checks `config.json` before it starts the next ZTC, which reads the file again as it starts: an
2848
3083
  edit another process makes in between to the hooks, MCP servers, skills or workflows is taken. Under
2849
3084
  `ZTC_PERMISSION_PROFILE_PINNED`, one to the pinned permission settings keeps that ZTC from starting instead.
2850
- - Two restarts aren't restarts in place: a colony cell's `/restart` asks its overseer to start the cell again, and the
2851
- desktop app starts ZTC again itself once it has installed an update. Neither checks `config.json` first, nor hands the
2852
- ZTC it starts what the pin was taken from: that ZTC takes the permission settings from `config.json` as a fresh start
2853
- does, and pins them where its environment holds `ZTC_PERMISSION_PROFILE_PINNED`.
3085
+ - A colony cell's `/restart` isn't a restart in place: it asks its overseer to start the cell again, which doesn't
3086
+ check `config.json` first, nor hand the ZTC it starts what the pin was taken from: that ZTC takes the permission
3087
+ settings from `config.json` as a fresh start does, and pins them where its environment holds
3088
+ `ZTC_PERMISSION_PROFILE_PINNED`. Nor is the desktop app's start of ZTC after it installs an update, which doesn't
3089
+ check `config.json` first either, and which it makes only for a ZTC that isn't pinned (above).
2854
3090
  - Under `ZTC_PERMISSION_PROFILE_PINNED`, ZTC takes the pin as its startup ends, after it has started the MCP servers
2855
- `config.json` names: one that then doesn't start (the profile it would pin limits nothing or lets the agent's commands
2856
- run outside an OS sandbox, or the pinned settings changed after a restart's check) has started them by then.
2857
- - Under `ZTC_PERMISSION_PROFILE_PINNED`, a profile that asks for the OS sandbox for the agent's commands without
2858
- requiring it (one that names `allowedPaths`, or keeps them off the network) is pinned, and on a host with no OS
2859
- sandbox (Linux without bubblewrap) its commands run outside any, as `/status` says
2860
- (`OS command sandbox: not required; not enforced: no OS sandbox on this host`). Give it
2861
- `sandbox.requireOsEnforcement`, and there they don't run.
3091
+ `config.json` names: one that then doesn't start (the profile it would pin limits nothing, doesn't require an OS
3092
+ sandbox, holds ZTC's own state or `TMPDIR` in its roots, or writes and runs commands but names no `allowedPaths`; or
3093
+ the pinned settings changed after a restart's check) has started them by then. A ZTC started again in place takes what
3094
+ it was handed (`ZTC_PERMISSION_PIN_SOURCE`) out of its environment before any of them starts, so none holds it, but
3095
+ the environment the process was started with (`/proc/<pid>/environ` on Linux) still does, which a program running as
3096
+ the same user can read, as it can read `config.json`.
3097
+ - Under `ZTC_HOSTED=1`, ZTC checks a headless start's profile as its startup ends, where the pin is taken, so a start it
3098
+ refuses has done what its startup does first: it has started the MCP servers `config.json` names (which it closes
3099
+ again before it exits), `zerg-ztc-headless` has loaded and built the handlers an `--agent-domain` names and, for
3100
+ `--effort` on a Zerg Router route, may have asked Router for its model catalog, and a headless mirror has loaded the
3101
+ plugins ZTC discovers. It checks a start whose settings are its launch's: a run with a prompt or a Voyager task on its
3102
+ command line, one on a `--session-file` thread, a headless mirror without mux, and one that names a prompt or a
3103
+ thread where `ZTC_HEADLESS_MUX` is set. The mux workbench started with neither a thread nor a prompt on its command
3104
+ line, whose threads get their settings from its host once it runs (a prompt a controller sends before then runs on
3105
+ the profile it started on), a ZTC pane (zmux's `--pane`, or the pane child a headless mux opens, which names
3106
+ neither), the terminal app and a headless run that takes its prompts on stdin with no `--session-file`
3107
+ (`--json-stream`, `ztc -p` with no prompt after it, or a prompt piped to `ztc --headless`) start on whatever profile
3108
+ they hold, as before. Without `ZTC_PERMISSION_PROFILE_PINNED` nothing holds the profile once the run has started:
3109
+ your own `/permissions use`, or a controller's, can still change it.
3110
+ - The zerg service's one-shot run (`run_headless_ztc`, `zerg/zerg/agent/core/workflows/ztc_headless/runtime.py`)
3111
+ doesn't set `ZTC_HOSTED` yet: the environment it gives the ZTC it starts (`zerg-ztc-headless`) keeps an allowlist of
3112
+ names that holds neither it nor `ZTC_PERMISSION_PROFILE_PINNED`, whatever the service's own holds, so that run starts
3113
+ on `trusted`, its commands outside any OS sandbox, as root where the service runs as root. For the check to hold it,
3114
+ the service must set `ZTC_HOSTED=1` in that environment itself; save, as `permissionProfile` in the run's own config
3115
+ folder (`ZTC_CONFIG_DIR`), a profile that requires the OS sandbox and names its roots, or one that runs no command,
3116
+ since `zerg-ztc-headless` takes no `--permission-profile`; and run where an OS sandbox is usable, which the zerg image
3117
+ isn't (it ships no bubblewrap).
3118
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, the Ink interface, which ZTC runs where its native interface isn't built
3119
+ (Windows, say), still installs a newer release with npm as it starts, for the next start to run (it starts nothing in
3120
+ place); `ZTC_DISABLE_UPDATE=1` keeps it from checking, and the `ztc` command the npm package installs sets it.
3121
+ - The Ink interface runs your own commands (`!cmd` and `/shell`, `/diff`'s git, the commands `/optimize` runs) outside
3122
+ any OS sandbox, under every profile, `ZTC_PERMISSION_PROFILE_PINNED` or not: the native interface runs them in the
3123
+ sandbox the profile asks for, and under the pin only inside one.
3124
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, a pinned profile that runs none of the agent's commands (`safe_edits`, or one
3125
+ that turns `shell_exec` off) requires no OS sandbox, so your hooks run outside one there, as under `read_only`: a hook
3126
+ reaches ZTC's own state, and the `config.json` the pin is taken from, as any program of yours does, and where the
3127
+ profile lets the agent write, a hook that runs the workspace's code (`npm run lint`) runs what the agent may have
3128
+ written there.
3129
+ - Under `ZTC_PERMISSION_PROFILE_PINNED`, `/environment service start` and the commands `/job` runs in named command
3130
+ panes are planned with the pinned profile's own sandbox settings, not with the OS sandbox required as your `!cmd` and
3131
+ `/shell` are: under a pinned profile that runs none of the agent's commands, which needn't require it, they run
3132
+ outside any OS sandbox where the profile asks for none or this host has none, and reach ZTC's own state and the
3133
+ `config.json` the pin is taken from.
2862
3134
  - `--new-window` in Terminal or iTerm starts the new window's ZTC in a shell of its own, which ZTC hands neither
2863
3135
  `ZTC_PERMISSION_PROFILE_PINNED` nor `ZTC_MODEL_PINNED`: that ZTC pins neither.
2864
3136
  - Settings that name programs ZTC runs when you ask aren't kept as ZTC started with them: the Codex app server's
@@ -2871,8 +3143,10 @@ programs.
2871
3143
  - Your own `/zerg launch` still runs Poetry in the working directory's `zerg/` project, which the agent may have
2872
3144
  written, as `make` there would.
2873
3145
  - A headless run with no approval client approves what a profile that asks would ask you (`--approval-url` hands those
2874
- decisions to a service), so there the tools above that start a program outside the sandbox can run. Under
2875
- `--computer-use`, the computer-control tools can type into any window.
3146
+ decisions to a service), so there the tools above that start a program outside the sandbox can run, but under
3147
+ `ZTC_PERMISSION_PROFILE_PINNED`, which refuses each such call there (above). The request an approval service is sent
3148
+ doesn't say whether a call starts a program outside the OS sandbox (a library host's approver is told, in
3149
+ `startsProgramsOutsideSandbox`). Under `--computer-use`, the computer-control tools can type into any window.
2876
3150
  - A mirror you start in the terminal UI (`ztc --mirror`, `/mirror`) with sign-in off, the default outside production,
2877
3151
  answers anyone on this computer (see the mirror's section) and takes their input as yours: under a profile that
2878
3152
  leaves the agent's commands the network (`workspace_autonomous`), a command of the agent's could post
@@ -2881,16 +3155,12 @@ programs.
2881
3155
  with a credential; under `ZTC_PERMISSION_PROFILE_PINNED`, `/permissions use` is refused whoever asks. Turn sign-in on
2882
3156
  for a mirror you run under such a profile.
2883
3157
  - Where a profile lets the agent start a program outside the OS sandbox (`trusted`, `local_full`, a profile of your own
2884
- that doesn't require the sandbox, or one that asks, once you approve), the LSP tools start their language server
2885
- outside any sandbox, and it runs the workspace's code there as it builds it (rust-analyzer runs a crate's build
2886
- scripts and proc macros).
2887
- - In ML mode, `ml_load_model` and `ml_train` open the files their arguments name (`weights_path`, `data_path`,
2888
- `save_weights_path`) through ZTC's ML helper (`ztc-ml`), which runs outside the OS sandbox, and no profile root
2889
- checks those paths: under a profile that leaves `ml_inference` on (`workspace_autonomous`, `ask_before_mutation`,
2890
- which doesn't ask before them, `hosted_read_only`), the agent can have the helper read a file outside its roots, or
2891
- in ZTC's own state, and `ml_train` write its weights there. ML mode is a launch choice (`--ml`): without it ZTC
2892
- offers no ML tool, and a profile with `ml_inference: false` (`read_only`, `safe_edits`, `tests_allowed`,
2893
- `locked_down`) refuses them.
3158
+ that doesn't require the sandbox, or one that asks, once you approve), the tools above that start one start it outside
3159
+ any sandbox. The LSP tools' language server runs the workspace's code there as it builds it (rust-analyzer runs a
3160
+ crate's build scripts and proc macros), and ZTC exits, or starts again in place, without waiting for it to stop, so a
3161
+ 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
3162
+ (`ztc-ml`) opens the files the ML tools name, which the profile checks as above, and, for `ml_train`, the
3163
+ `events.jsonl` and `session.json` in the folder it names, which it opens itself, following a link there.
2894
3164
  - The file tools check what they opened, but a unified diff, which `git apply` writes, and `search`, which runs
2895
3165
  ripgrep, open files themselves.
2896
3166
  - Git in a workspace a sandboxed command writes: