@zergai/ztc 0.26.2-dev.202611210149 → 0.26.4-dev.202611231953

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/README.md +590 -28
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/zmux-linux-x64 +0 -0
  4. package/bin/ztc-audio-darwin-arm64 +0 -0
  5. package/bin/ztc-capture-darwin-arm64 +0 -0
  6. package/bin/ztc-tui-darwin-arm64 +0 -0
  7. package/bin/ztc-tui-linux-x64 +0 -0
  8. package/bin/zterm-darwin-arm64 +2 -2
  9. package/dist/App.js +18 -1
  10. package/dist/agent/agent.d.ts +25 -1
  11. package/dist/agent/agent.js +26 -1
  12. package/dist/agent/attached_images.d.ts +58 -0
  13. package/dist/agent/attached_images.js +145 -0
  14. package/dist/agent/backends/anthropic.d.ts +14 -0
  15. package/dist/agent/backends/anthropic.js +49 -2
  16. package/dist/agent/backends/codex_app_server.d.ts +3 -1
  17. package/dist/agent/backends/codex_app_server.js +9 -6
  18. package/dist/agent/backends/codex_auth.js +3 -0
  19. package/dist/agent/backends/gemini.js +3 -0
  20. package/dist/agent/backends/host_effort_policy.js +14 -2
  21. package/dist/agent/backends/http_error.d.ts +17 -0
  22. package/dist/agent/backends/http_error.js +50 -1
  23. package/dist/agent/backends/index.js +2 -1
  24. package/dist/agent/backends/model_redirect.d.ts +47 -0
  25. package/dist/agent/backends/model_redirect.js +97 -0
  26. package/dist/agent/backends/openai_compatible.js +5 -0
  27. package/dist/agent/backends/openai_responses.d.ts +9 -1
  28. package/dist/agent/backends/openai_responses.js +21 -12
  29. package/dist/agent/backends/prompt_cache.d.ts +8 -0
  30. package/dist/agent/backends/prompt_cache.js +10 -0
  31. package/dist/agent/backends/provider_ids.d.ts +1 -1
  32. package/dist/agent/backends/provider_ids.js +1 -1
  33. package/dist/agent/backends/types.d.ts +8 -0
  34. package/dist/agent/backends/zerg-api.js +5 -1
  35. package/dist/agent/backends/zrouter_stream.d.ts +75 -9
  36. package/dist/agent/backends/zrouter_stream.js +250 -49
  37. package/dist/agent/commands/config.js +51 -4
  38. package/dist/agent/commands/connect.js +20 -0
  39. package/dist/agent/commands/credential_status.js +5 -3
  40. package/dist/agent/commands/debug.js +3 -0
  41. package/dist/agent/commands/diff.js +9 -5
  42. package/dist/agent/commands/emulation.js +7 -1
  43. package/dist/agent/commands/inbox.js +4 -3
  44. package/dist/agent/commands/mcp.js +3 -0
  45. package/dist/agent/commands/models.js +20 -3
  46. package/dist/agent/commands/permissions.js +16 -2
  47. package/dist/agent/commands/provider_selection.js +13 -6
  48. package/dist/agent/commands/settings.js +15 -4
  49. package/dist/agent/commands/status.js +23 -1
  50. package/dist/agent/commands/types.d.ts +34 -3
  51. package/dist/agent/commands/update.d.ts +2 -1
  52. package/dist/agent/commands/update.js +8 -3
  53. package/dist/agent/commands/zerg.d.ts +6 -0
  54. package/dist/agent/commands/zerg.js +152 -28
  55. package/dist/agent/commands/ztc_pane.js +8 -5
  56. package/dist/agent/factory.js +22 -4
  57. package/dist/agent/request_encoder.js +11 -2
  58. package/dist/agent/runtime/command_jobs.js +16 -1
  59. package/dist/agent/runtime/command_panes.js +4 -1
  60. package/dist/agent/runtime/execution_context.d.ts +8 -1
  61. package/dist/agent/runtime/execution_context.js +8 -2
  62. package/dist/agent/runtime/policy.d.ts +66 -5
  63. package/dist/agent/runtime/policy.js +161 -33
  64. package/dist/agent/runtime/remote_broker_transport.d.ts +7 -0
  65. package/dist/agent/runtime/remote_broker_transport.js +33 -3
  66. package/dist/agent/runtime/remote_resource_errors.d.ts +7 -0
  67. package/dist/agent/runtime/remote_resource_errors.js +10 -0
  68. package/dist/agent/runtime/remote_resources.d.ts +1 -1
  69. package/dist/agent/runtime/remote_resources.js +7 -3
  70. package/dist/agent/runtime/source_verification.js +15 -12
  71. package/dist/agent/runtime/tool_runtime.js +165 -58
  72. package/dist/agent/runtime/verifier_capture.d.ts +1 -1
  73. package/dist/agent/runtime/verifier_capture.js +6 -0
  74. package/dist/agent/runtime/work_base.js +46 -14
  75. package/dist/agent/tools/adaptation.js +29 -12
  76. package/dist/agent/tools/apply_patch.js +62 -5
  77. package/dist/agent/tools/background.js +2 -0
  78. package/dist/agent/tools/benchmark_cpu.js +2 -0
  79. package/dist/agent/tools/bus_message.d.ts +4 -2
  80. package/dist/agent/tools/bus_message.js +21 -3
  81. package/dist/agent/tools/delegate.js +2 -0
  82. package/dist/agent/tools/file.d.ts +12 -1
  83. package/dist/agent/tools/file.js +92 -11
  84. package/dist/agent/tools/lsp.d.ts +12 -0
  85. package/dist/agent/tools/lsp.js +61 -5
  86. package/dist/agent/tools/pane.js +20 -45
  87. package/dist/agent/tools/project_context.js +5 -2
  88. package/dist/agent/tools/routine.js +20 -4
  89. package/dist/agent/tools/screenshot.d.ts +8 -0
  90. package/dist/agent/tools/screenshot.js +39 -25
  91. package/dist/agent/tools/search.js +31 -3
  92. package/dist/agent/tools/shell.js +7 -1
  93. package/dist/agent/tools/supervision.js +6 -0
  94. package/dist/agent/tools/types.d.ts +18 -0
  95. package/dist/agent/tools/zerg.js +15 -19
  96. package/dist/agent/tools/ztc_command.d.ts +15 -4
  97. package/dist/agent/tools/ztc_command.js +48 -34
  98. package/dist/app/agent_runner.js +8 -6
  99. package/dist/app/conversation_compaction.d.ts +6 -3
  100. package/dist/app/conversation_compaction.js +6 -3
  101. package/dist/app/tool_callbacks.js +1 -0
  102. package/dist/audio/sfx.js +6 -0
  103. package/dist/batch/worktree.js +22 -10
  104. package/dist/board/client.js +2 -1
  105. package/dist/cli_main.d.ts +1 -0
  106. package/dist/cli_main.js +141 -45
  107. package/dist/cli_ratatui.d.ts +49 -4
  108. package/dist/cli_ratatui.js +355 -79
  109. package/dist/conductor_branch.js +4 -1
  110. package/dist/config/host_credentials.d.ts +157 -0
  111. package/dist/config/host_credentials.js +589 -0
  112. package/dist/config/model_pin.d.ts +111 -0
  113. package/dist/config/model_pin.js +182 -0
  114. package/dist/config/own_state_files.d.ts +35 -0
  115. package/dist/config/own_state_files.js +161 -0
  116. package/dist/config/permission_pin.d.ts +148 -0
  117. package/dist/config/permission_pin.js +203 -0
  118. package/dist/config/permissions.d.ts +9 -2
  119. package/dist/config/permissions.js +14 -3
  120. package/dist/config/platform_login.d.ts +72 -0
  121. package/dist/config/platform_login.js +111 -0
  122. package/dist/config/profile_limits.d.ts +34 -0
  123. package/dist/config/profile_limits.js +66 -0
  124. package/dist/config/provider_api_key_env.js +3 -2
  125. package/dist/config/provider_models.d.ts +6 -1
  126. package/dist/config/provider_models.js +38 -11
  127. package/dist/config/repo_config.d.ts +22 -0
  128. package/dist/config/repo_config.js +77 -3
  129. package/dist/config/router_runtime_grant.d.ts +53 -0
  130. package/dist/config/router_runtime_grant.js +131 -0
  131. package/dist/config/settings_merge.d.ts +22 -0
  132. package/dist/config/settings_merge.js +75 -0
  133. package/dist/config/types.d.ts +8 -0
  134. package/dist/config.d.ts +334 -4
  135. package/dist/config.js +1024 -41
  136. package/dist/context/project_intelligence.d.ts +11 -2
  137. package/dist/context/project_intelligence.js +38 -15
  138. package/dist/desktop/daily/desktop_wiring.js +8 -6
  139. package/dist/desktop/daily/native_pane_launcher.js +2 -1
  140. package/dist/desktop/daily/native_tool.d.ts +1 -1
  141. package/dist/desktop/daily/native_tool.js +4 -3
  142. package/dist/desktop/daily/process_identity.js +10 -2
  143. package/dist/desktop/daily/source_baseline.js +4 -3
  144. package/dist/diagnostics/native_terminal_benchmark.js +3 -2
  145. package/dist/diagnostics/session_export.js +27 -14
  146. package/dist/embedded/anempa_runtime.js +3 -3
  147. package/dist/embedded/gameboy_runtime.js +5 -4
  148. package/dist/embedded/zergpod_runtime.js +5 -4
  149. package/dist/emulation/catalog.js +6 -1
  150. package/dist/emulation/tool_adapters.js +13 -3
  151. package/dist/environment/store.js +5 -4
  152. package/dist/extension_discovery.d.ts +12 -2
  153. package/dist/extension_discovery.js +52 -7
  154. package/dist/headless.d.ts +8 -0
  155. package/dist/headless.js +52 -13
  156. package/dist/headless_cli.js +16 -1
  157. package/dist/headless_workflow_trigger.js +1 -1
  158. package/dist/hooks/dispatcher.d.ts +8 -0
  159. package/dist/hooks/dispatcher.js +22 -2
  160. package/dist/hooks/lifecycle.d.ts +6 -0
  161. package/dist/hooks/lifecycle.js +1 -0
  162. package/dist/hooks/program_files.d.ts +10 -0
  163. package/dist/hooks/program_files.js +175 -0
  164. package/dist/hooks/runner.d.ts +11 -1
  165. package/dist/hooks/runner.js +112 -11
  166. package/dist/hooks/types.d.ts +2 -0
  167. package/dist/host_credentials_startup.d.ts +6 -0
  168. package/dist/host_credentials_startup.js +17 -0
  169. package/dist/instance_registry.d.ts +6 -2
  170. package/dist/instance_registry.js +9 -15
  171. package/dist/intake/format.d.ts +6 -0
  172. package/dist/intake/format.js +9 -0
  173. package/dist/intake/notifications.js +2 -1
  174. package/dist/lsp/manager.d.ts +1 -1
  175. package/dist/lsp/manager.js +4 -5
  176. package/dist/mcp/client.d.ts +2 -0
  177. package/dist/mcp/client.js +116 -18
  178. package/dist/mcp/registry.d.ts +12 -0
  179. package/dist/mcp/registry.js +15 -1
  180. package/dist/modes/handlers.js +14 -5
  181. package/dist/panes/agent_cli.d.ts +23 -1
  182. package/dist/panes/agent_cli.js +96 -1
  183. package/dist/panes/agent_panes.d.ts +27 -4
  184. package/dist/panes/agent_panes.js +73 -11
  185. package/dist/panes/editor_program.d.ts +8 -0
  186. package/dist/panes/editor_program.js +25 -0
  187. package/dist/panes/motsi.d.ts +11 -1
  188. package/dist/panes/motsi.js +14 -1
  189. package/dist/panes/pane_registry.d.ts +28 -1
  190. package/dist/panes/pane_registry.js +25 -0
  191. package/dist/panes/worker_route.js +5 -3
  192. package/dist/panes/ztc_launch.d.ts +8 -0
  193. package/dist/panes/ztc_launch.js +26 -1
  194. package/dist/profile_baseline.js +2 -0
  195. package/dist/router_auth.d.ts +8 -3
  196. package/dist/router_auth.js +34 -2
  197. package/dist/runtime_info.js +56 -38
  198. package/dist/session.js +12 -2
  199. package/dist/shannon/runtime.js +13 -1
  200. package/dist/simulation/domains/loader.d.ts +2 -1
  201. package/dist/simulation/domains/loader.js +19 -2
  202. package/dist/simulation/living/context.d.ts +8 -8
  203. package/dist/simulation/living/types.d.ts +2 -2
  204. package/dist/simulation/memory/embedding.d.ts +2 -1
  205. package/dist/simulation/memory/embedding.js +25 -6
  206. package/dist/terminal_attach.js +2 -1
  207. package/dist/types.d.ts +21 -0
  208. package/dist/ui/ratatui/headless_pane_manager.d.ts +12 -6
  209. package/dist/ui/ratatui/headless_pane_manager.js +65 -21
  210. package/dist/ui/ratatui/ipc_path.d.ts +41 -2
  211. package/dist/ui/ratatui/ipc_path.js +164 -5
  212. package/dist/ui/ratatui/pane_credential_broker.d.ts +17 -4
  213. package/dist/ui/ratatui/pane_credential_broker.js +23 -5
  214. package/dist/ui/ratatui/pane_relay.d.ts +74 -0
  215. package/dist/ui/ratatui/pane_relay.js +188 -13
  216. package/dist/ui/ratatui/process.d.ts +15 -1
  217. package/dist/ui/ratatui/process.js +129 -163
  218. package/dist/ui/ratatui/protocol.d.ts +11 -1
  219. package/dist/ui/ratatui/protocol.js +6 -0
  220. package/dist/ui/ratatui/ztc_launch_trust.d.ts +87 -0
  221. package/dist/ui/ratatui/ztc_launch_trust.js +249 -0
  222. package/dist/utils/admitted_open.d.ts +40 -0
  223. package/dist/utils/admitted_open.js +111 -0
  224. package/dist/utils/clipboard.js +2 -1
  225. package/dist/utils/computer_native.js +12 -56
  226. package/dist/utils/dictation.js +15 -12
  227. package/dist/utils/dictation_native.js +17 -60
  228. package/dist/utils/git_probe_options.d.ts +28 -0
  229. package/dist/utils/git_probe_options.js +30 -0
  230. package/dist/utils/git_program_files.d.ts +145 -0
  231. package/dist/utils/git_program_files.js +1282 -0
  232. package/dist/utils/git_repository_programs.d.ts +13 -0
  233. package/dist/utils/git_repository_programs.js +38 -0
  234. package/dist/utils/host_shell.js +2 -1
  235. package/dist/utils/idle_compaction.js +8 -1
  236. package/dist/utils/image_fit.d.ts +4 -1
  237. package/dist/utils/image_fit.js +6 -2
  238. package/dist/utils/image_preview.js +3 -2
  239. package/dist/utils/mirror_media.d.ts +22 -4
  240. package/dist/utils/mirror_media.js +87 -86
  241. package/dist/utils/ml_native.js +11 -56
  242. package/dist/utils/native_install.d.ts +55 -0
  243. package/dist/utils/native_install.js +107 -0
  244. package/dist/utils/open_url.js +2 -0
  245. package/dist/utils/process_end.d.ts +16 -0
  246. package/dist/utils/process_end.js +73 -0
  247. package/dist/utils/router_catalog.js +9 -2
  248. package/dist/utils/sandbox.d.ts +64 -1
  249. package/dist/utils/sandbox.js +397 -89
  250. package/dist/utils/shell.js +31 -12
  251. package/dist/utils/subprocess_env.d.ts +218 -2
  252. package/dist/utils/subprocess_env.js +429 -11
  253. package/dist/utils/system_ps.d.ts +5 -0
  254. package/dist/utils/system_ps.js +30 -0
  255. package/dist/utils/tts.js +5 -0
  256. package/dist/utils/tts_native.js +13 -60
  257. package/dist/utils/zlicky_overlay.js +17 -50
  258. package/dist/utils/ztc_own_state.d.ts +58 -0
  259. package/dist/utils/ztc_own_state.js +236 -0
  260. package/dist/web/mirror_authenticator.d.ts +67 -6
  261. package/dist/web/mirror_authenticator.js +131 -22
  262. package/dist/web/mirror_stream.d.ts +54 -10
  263. package/dist/web/mirror_stream.js +379 -92
  264. package/dist/web/observer_query_redaction.js +53 -13
  265. package/dist/web/observer_secret_redaction.d.ts +59 -0
  266. package/dist/web/observer_secret_redaction.js +714 -0
  267. package/dist/web/pane_credentials.d.ts +20 -2
  268. package/dist/web/pane_credentials.js +58 -5
  269. package/dist/worker/executor.js +3 -1
  270. package/dist/workspace_collision.js +19 -15
  271. package/dist/zerg/local_zerg_launches.d.ts +27 -0
  272. package/dist/zerg/local_zerg_launches.js +198 -0
  273. package/dist/zlm-embed.mjs +6257 -2791
  274. package/npm-shrinkwrap.json +1 -1
  275. package/package.json +42 -15
@@ -1,12 +1,14 @@
1
- import { execFileSync, spawn } from 'child_process';
1
+ import { spawn } from 'child_process';
2
2
  import { randomUUID } from 'crypto';
3
3
  import { existsSync, readFileSync, rmSync } from 'fs';
4
4
  import { join, resolve, sep } from 'path';
5
5
  import { homedir, tmpdir } from 'os';
6
6
  import { stat } from 'fs/promises';
7
- import { buildSandboxCommandPlan } from './sandbox.js';
7
+ import { buildSandboxCommandPlan, sandboxNoticesToTell } from './sandbox.js';
8
+ import { refusedGitWriteNotes } from './git_program_files.js';
8
9
  import { hostShell, killWindowsProcessTree } from './host_shell.js';
9
10
  import { buildTemporaryWriteRootSubprocessEnv, buildUserSubprocessEnv } from './subprocess_env.js';
11
+ import { systemPsOutput } from './system_ps.js';
10
12
  import { CheckedShellCoordinator, formatCheckedStageCommand } from './checked_shell.js';
11
13
  import { parseCommandExecutionPolicy } from '../agent/runtime/command_execution_policy.js';
12
14
  import { COPY_ADVICE, copyNote, ToolOutputCopy } from './tool_output_copies.js';
@@ -169,18 +171,20 @@ const activeChildGroups = new Set();
169
171
  * by id alone would hit (Idan's review of #884, 2026-11-16).
170
172
  */
171
173
  const leftGroups = new Map();
172
- /** Each process's group, by pid, from one `ps` listing; empty when it cannot be read. */
174
+ /**
175
+ * Each process's group, by pid, from one listing by the system's ps, never one found on PATH and never given ZTC's
176
+ * environment (utils/system_ps.ts); empty when it cannot be read.
177
+ */
173
178
  function processGroups() {
174
179
  const groups = new Map();
175
- try {
176
- const listing = execFileSync('ps', ['-A', '-o', 'pid=,pgid='], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
177
- for (const line of listing.split('\n')) {
178
- const [pid, pgid] = line.trim().split(/\s+/).map(Number);
179
- if (Number.isInteger(pid) && Number.isInteger(pgid))
180
- groups.set(pid, pgid);
181
- }
180
+ const listing = systemPsOutput(['-A', '-o', 'pid=,pgid='], 5000);
181
+ if (listing === null)
182
+ return groups; // no listing: nothing is proven ours
183
+ for (const line of listing.split('\n')) {
184
+ const [pid, pgid] = line.trim().split(/\s+/).map(Number);
185
+ if (Number.isInteger(pid) && Number.isInteger(pgid))
186
+ groups.set(pid, pgid);
182
187
  }
183
- catch { /* no listing: nothing is proven ours */ }
184
188
  return groups;
185
189
  }
186
190
  /** A finished command's group: kept, with what it left running, or forgotten when nothing of it is left. */
@@ -434,18 +438,33 @@ export async function runShellCommand(command, cwd, signal, timeoutMs, sandboxOp
434
438
  return { stdout: out.text, stderr: err.text, ...(Object.keys(outputCopies).length ? { outputCopies } : {}) };
435
439
  };
436
440
  let settled = false;
441
+ // The sandbox's step after the command, once it has ended and before anything reads its result (and before any
442
+ // other git ZTC runs there): what it undid is the result's to say.
443
+ const afterCommand = () => {
444
+ try {
445
+ return sandboxPlan.afterCommand?.() ?? [];
446
+ }
447
+ catch (error) {
448
+ return [`ZTC could not check what the command left where the repository names the programs git starts: ${error.message}`];
449
+ }
450
+ };
437
451
  const settleResolve = (r) => {
438
452
  if (settled)
439
453
  return;
440
454
  settled = true;
441
455
  cleanup();
442
- resolveResult({ ...r, timedOut, execution_policy: structuredClone(executionPolicy) });
456
+ // A plan that protects the repositories the command can write (its step after the command): what the sandbox kept
457
+ // from the command's git or rm there, which git's own words don't say, and what the person can do.
458
+ const refused = sandboxPlan.afterCommand ? refusedGitWriteNotes(`${r.stdout}\n${r.stderr}`, command, cwd) : [];
459
+ const said = [...sandboxNoticesToTell(sandboxPlan), ...afterCommand(), ...refused];
460
+ resolveResult({ ...r, ...(said.length > 0 ? { sandboxNotes: said } : {}), timedOut, execution_policy: structuredClone(executionPolicy) });
443
461
  };
444
462
  const settleReject = (e) => {
445
463
  if (settled)
446
464
  return;
447
465
  settled = true;
448
466
  cleanup();
467
+ afterCommand();
449
468
  rejectResult(e);
450
469
  };
451
470
  child.on('error', async (err) => {
@@ -1,3 +1,20 @@
1
+ import { ZTC_CREDENTIAL_ENV } from '../config/host_credentials.js';
2
+ /**
3
+ * The names above whose values are secrets (ZTC_CREDENTIAL_ENV, config/host_credentials.ts, which holds them outside
4
+ * process.env): what speaks for this ZTC (its mirror's shared secret and process-wide token, its own pane credential,
5
+ * the Router grant it infers with, the host's Router runtime grant, its host's approval, broker and effort-policy
6
+ * tokens) and the zerg service's session secret. The other names are coordinates (a port, a pane's id, the relay's
7
+ * path, the Router's URL), not credentials. A read-only observer of the mirror is never shown their values either
8
+ * (web/observer_secret_redaction.ts reads them through the store).
9
+ */
10
+ export { ZTC_CREDENTIAL_ENV };
11
+ /**
12
+ * What variable NAME holds, when it is reserved for a credential ZTC sends only where it is for, so a remote resource's
13
+ * broker (which is sent its tokenEnv's value) may not take its credential from it: the host's Router runtime grant,
14
+ * another of ZTC's own credentials (ZTC_CREDENTIAL_ENV; ZTC_BROKER_TOKEN is the broker's own), or a model route's
15
+ * credential (MODEL_ROUTE_CREDENTIAL_ENV). Undefined for any other name.
16
+ */
17
+ export declare function reservedCredentialEnv(name: string): 'host_router_grant' | 'ztc_credential' | 'model_route' | undefined;
1
18
  /**
2
19
  * Whether another ZTC launched this one into one of its panes: a --pane child, a colony cell (--mirror --mux), or any
3
20
  * launch through buildChildZtcPaneLaunch or childZtcPaneEnv, which set ZTC_PARENT_PID or ZTC_COLONY_CHILD. A user
@@ -29,6 +46,13 @@ export declare const MODEL_ROUTE_CREDENTIAL_ENV: readonly string[];
29
46
  * a key from are skipped rather than failing the run.
30
47
  */
31
48
  export declare function reserveModelRouteCredentials(namedKeyEnv?: Readonly<Record<string, string>>): readonly string[];
49
+ /** Read the variables the person's profile names as provider keys from READ (config.ts gives its ConfigStore's). */
50
+ export declare function followProfileProviderKeyEnv(read: () => Readonly<Record<string, string>> | undefined): void;
51
+ /**
52
+ * Whether this process keeps its route credentials from its tools (reserveModelRouteCredentials): a --headless run or
53
+ * a headless mirror, which a model drives with no human reviewing each command. The interactive app reserves none.
54
+ */
55
+ export declare function modelRouteCredentialsReserved(): boolean;
32
56
  /**
33
57
  * Give a ZTC framework child that runs its own inference (a headless `ztc`
34
58
  * pane: sub-agent or sim agent) back the reserved route credentials present
@@ -52,12 +76,199 @@ export declare function withoutHostEffortPolicy<T extends NodeJS.ProcessEnv | Re
52
76
  /**
53
77
  * Overrides that blank the host policy in a pane a renderer starts, which inherits the renderer's copy of this
54
78
  * process's environment, when this process holds either of the pair; none when it holds neither, so the person's own
55
- * shells carry nothing about a policy they don't have.
79
+ * shells carry nothing about a policy they don't have. The CLI's store keeps both out of the renderer's environment;
80
+ * a process that never took its credentials out of its environment (ZTC used as a library) passes them on to it.
56
81
  */
57
82
  export declare function hostEffortPolicyBlanks(source?: NodeJS.ProcessEnv): Record<string, string>;
83
+ /**
84
+ * `env` without the host's Router runtime grant (config/router_runtime_grant.ts): for a ZTC child that otherwise inherits
85
+ * its parent's environment, such as a colony cell, which is given it only as hostRouterGrantForZtcChild says.
86
+ */
87
+ export declare function withoutHostRouterGrant<T extends NodeJS.ProcessEnv | Record<string, string>>(env: T): T;
88
+ /**
89
+ * What a ZTC child that runs its own turns (a ZTC pane, a colony cell) is given of the host's Router runtime grant: the
90
+ * grant and the Router it is for (ZERG_ROUTER_BASE_URL), when SOURCE holds one ZTC sends there (hostRouterGrantFor:
91
+ * https, or http on loopback, and a usable bearer); nothing otherwise. A resident whose only route is the grant has
92
+ * nothing else to start them on. Each binds it to that Router as its parent does and strips it from its own children;
93
+ * no child that is not a ZTC is given it. It starts with explicit extension discovery (hostRouterGrantDiscovery).
94
+ */
95
+ export declare function hostRouterGrantForZtcChild(source?: NodeJS.ProcessEnv): Record<string, string>;
96
+ /**
97
+ * How a ZTC child given the host's grant (hostRouterGrantForZtcChild) discovers extensions: explicitly
98
+ * (extension_discovery.ts), so it imports no plugin, mode or skill from its working directory, that directory's
99
+ * repository root or HOME, where an agent writes, only what its host names (ZTC_PLUGIN_PATHS and its kin) and ZTC's
100
+ * own. Nothing when SOURCE holds no grant that takes effect: a pane without one discovers them as it always has.
101
+ */
102
+ export declare function hostRouterGrantDiscovery(source?: NodeJS.ProcessEnv): Record<string, string>;
103
+ /**
104
+ * Whether a ZTC child this process starts (a ZTC pane, a colony cell) discovers extensions explicitly: given the host's
105
+ * grant, it is given explicit discovery (hostRouterGrantDiscovery); and it inherits this process's own.
106
+ */
107
+ export declare function ztcChildDiscoversExplicitly(source?: NodeJS.ProcessEnv): boolean;
108
+ /**
109
+ * The override for a ZTC pane a renderer starts, which inherits the renderer's copy of this process's environment: it
110
+ * keeps a grant ZTC sends to the Router it names, with that Router (hostRouterGrantForZtcChild), and blanks one that
111
+ * takes no effect; nothing when this process holds none, so the person's own panes carry nothing about a grant they
112
+ * don't have.
113
+ */
114
+ export declare function hostRouterGrantBlank(source?: NodeJS.ProcessEnv): Record<string, string>;
115
+ /**
116
+ * The environment of a renderer ZTC starts (zmux, ztc-tui, ZTerm), which starts each pane it opens with its own
117
+ * environment and the pane's: SOURCE without the credentials no pane needs (RENDERER_UNNEEDED_CREDENTIAL_ENV, the
118
+ * remote-resource broker tokens a host configured, which no child regains), or any variable holding one of their
119
+ * values. The person's own environment and the coordinates ZTC hands its panes (the mirror's port, the pane relay) stay.
120
+ *
121
+ * In the CLI, process.env holds none of ZTC's own credentials either: the host-credential store
122
+ * (config/host_credentials.ts) took them out at startup, so no renderer holds the host's Router runtime grant, the
123
+ * platform login in ZTC_AUTH_TOKEN or the host's effort policy for a pane to inherit. A ZTC pane or colony cell is given
124
+ * what it infers and routes with explicitly instead: in its create_pane environment (ui/ratatui/process.ts
125
+ * withZtcChildCredentials), and in a one-time handoff when the owner starts one again in place with replace_pane, which
126
+ * carries no environment (withZtcChildHandoff). zmux's restart_pane starts a process or command pane's program again
127
+ * with the environment its create_pane gave it over the renderer's own, its pane credential blank and no one-time
128
+ * credential file on its command line, so a pane narrowed as a tool child stays narrowed; it refuses a ZTC pane, which
129
+ * is reopened to be given what it routes with again. A process that never took its credentials out of its environment
130
+ * (ZTC used as a library) still passes what a ZTC pane infers and routes with on to its renderer. The mirror's
131
+ * credentials are the caller's to remove (withoutMirrorCredentials).
132
+ */
133
+ export declare function buildRendererEnv(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
58
134
  /** Keep pane-local control fields while removing host RPC credentials. */
59
135
  export declare function removeUserSubprocessCredentials(source: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
136
+ /**
137
+ * Every variable a user subprocess loses as a credential, by name and by value: ZTC's own (ZTC_CREDENTIAL_ENV) and
138
+ * those the host reserved so far (remote-resource broker tokens, a headless run's route credentials and the keys its
139
+ * profile names). What shows output to someone who is not this ZTC's user, such as a read-only observer of the mirror,
140
+ * withholds their values too, read through the host-credential store (config/host_credentials.ts
141
+ * liveCredentialValues), which holds ZTC's own outside process.env.
142
+ */
143
+ export declare function userSubprocessCredentialEnv(): string[];
144
+ /**
145
+ * The environment of a user subprocess: SOURCE without ZTC's own variables (USER_SUBPROCESS_STRIPPED_ZTC_ENV), the
146
+ * credentials the host reserved, or any other variable that holds one of those credentials' values. Everything else
147
+ * is the person's own and is kept, their own ZERG_API_TOKEN and provider keys among it.
148
+ */
60
149
  export declare function buildUserSubprocessEnv(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
150
+ /**
151
+ * The names among NAMES that no hook is given, whatever its passEnv lists: those ZTC keeps from every user subprocess
152
+ * (USER_SUBPROCESS_STRIPPED_ZTC_ENV: its credentials, the host's Router runtime grant among them, and its own
153
+ * variables), the remote-resource broker tokens this process reserved, and any variable of SOURCE holding one of those
154
+ * credentials' values (ZergCloud passes the Router grant as ZERG_API_TOKEN too). SOURCE is read as ZTC was started with
155
+ * it (hostLaunchEnvironment): the host-credential store took such a copy out of process.env with the credential, and the
156
+ * hook's result still names it. The person's own names (a GITHUB_TOKEN, a provider key) are none of these.
157
+ */
158
+ export declare function refusedPassEnvNames(names: Iterable<string>, source?: NodeJS.ProcessEnv): string[];
159
+ /**
160
+ * The variables that tell git which repository, work tree, index or object store to use in place of the one it finds
161
+ * from its working directory. git sets GIT_INDEX_FILE for the hooks it runs (and GIT_DIR too in a linked worktree,
162
+ * naming the main repository's .git/worktrees/<name>), and GIT_PREFIX for an alias, so a ZTC started from either holds
163
+ * them. A git ZTC runs in a directory that has a repository of its own acts on that one, so it takes none of these from
164
+ * ZTC's environment (gitEnvFor): with GIT_DIR naming another repository, /batch registered its worktree and branch
165
+ * there.
166
+ */
167
+ export declare const REPOSITORY_GIT_ENV: readonly string[];
168
+ /** ENV without REPOSITORY_GIT_ENV, for a git that ZTC runs in a repository it names. */
169
+ export declare function withoutRepositoryGitEnv<T extends NodeJS.ProcessEnv>(env: T): T;
170
+ /**
171
+ * The environment of a git that ZTC runs in a repository it names, which has one of its own: a user subprocess's
172
+ * (buildUserSubprocessEnv), since git runs the repository's hooks and the programs its config names with it, without
173
+ * REPOSITORY_GIT_ENV. A directory that may have none (the person's working directory) takes buildGitSubprocessEnvFor.
174
+ */
175
+ export declare function buildGitSubprocessEnv(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
176
+ /**
177
+ * ENV for a git that ZTC runs in DIRECTORY. When git finds a repository from DIRECTORY by itself (a project, a /batch
178
+ * worktree, a clone), that is the one it acts on, so ENV loses REPOSITORY_GIT_ENV: a hook's GIT_DIR or another
179
+ * repository's cannot redirect it. When it finds none, ENV keeps them, since they are then the only repository
180
+ * DIRECTORY has: `vcsh enter` and `yadm enter` export GIT_DIR naming a bare repository of the person's dotfiles and
181
+ * GIT_WORK_TREE naming its work tree, which holds no .git, and the person's own git works there. Telling which takes
182
+ * a git run, made only when ENV holds one of the variables.
183
+ */
184
+ export declare function gitEnvFor<T extends NodeJS.ProcessEnv>(directory: string, env: T): T;
185
+ /**
186
+ * The environment of a git that ZTC runs in DIRECTORY, which need not have a repository of its own (the person's
187
+ * working directory): a user subprocess's (buildUserSubprocessEnv), with REPOSITORY_GIT_ENV as gitEnvFor leaves it.
188
+ */
189
+ export declare function buildGitSubprocessEnvFor(directory: string, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
190
+ /**
191
+ * The environment of a child that is a model client by design and someone else's program, never a ZTC, that the person
192
+ * starts: the Shannon runner, the Zerg service /zerg launch starts. (The adaptation pipeline, a tool the agent starts,
193
+ * gets a user subprocess's environment and only the key it injects.) It is a user subprocess's environment
194
+ * (buildUserSubprocessEnv), with the provider keys a headless run reserved from its tools given back, since the child
195
+ * infers with them. ZTC's own credentials (ZTC_AUTH_TOKEN among them), broker tokens, and any variable holding one of
196
+ * their values, it never gets.
197
+ */
198
+ export declare function buildModelClientSubprocessEnv(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
199
+ /**
200
+ * The environment of a native helper ZTC starts from its own install (utils/native_install.ts: ztc-audio, ztc-computer,
201
+ * ztc-ml, ztc-tts, the zlicky overlay): a user subprocess's (buildUserSubprocessEnv: none of ZTC's own variables or
202
+ * credentials, under any name), without the credentials ZTC routes models with either (MODEL_ROUTE_CREDENTIAL_ENV, those
203
+ * this process reserved, the variables PROVIDER_KEY_ENV names as provider keys, by default those the person's profile
204
+ * names now (followProfileProviderKeyEnv), and any other variable holding one of their values), whether or not this
205
+ * process reserved them from its tools: the terminal app never does. None of the helpers reads one: they capture the
206
+ * screen and audio, inject input, transcribe and speak locally (ztc-tts reads ZTC_TTS_CPU, and HF_HOME where it
207
+ * downloads a model to), and the programs they start get what they got.
208
+ */
209
+ export declare function buildNativeHelperEnv(providerKeyEnv?: Readonly<Record<string, string>>, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
210
+ /** What a stdio MCP server is started with (buildMcpServerEnv), and what it was started without. */
211
+ export interface McpServerEnv {
212
+ /** Its whole environment. */
213
+ readonly env: Record<string, string>;
214
+ /**
215
+ * The route credentials set in ZTC's environment, and the other variables holding one of their values, that it was
216
+ * started without because its entry neither names them in passEnv nor sets them in env: names only, never values.
217
+ */
218
+ readonly withheld: readonly string[];
219
+ /** The names its passEnv lists that no MCP server is given (refusedPassEnvNames). */
220
+ readonly refused: readonly string[];
221
+ }
222
+ /**
223
+ * The environment of a stdio MCP server, someone else's program, which runs as long as ZTC does. It gets what a tool
224
+ * child of a headless run gets: a user subprocess's environment (buildUserSubprocessEnv: none of ZTC's own variables or
225
+ * credentials, nor the broker tokens a host configured, under any name), without the credentials ZTC routes models with
226
+ * either (MODEL_ROUTE_CREDENTIAL_ENV, those this process reserved, the variables a profile names as provider keys,
227
+ * PROVIDER_KEY_ENV, and any other variable holding one of their values), whether or not this process has reserved them
228
+ * yet (reserveModelRouteCredentials): the terminal app never does, and a headless run does once its agent is built,
229
+ * after its MCP servers start. So a server ZTC starts is the same in the app, a headless run and a resident. What the
230
+ * entry's passEnv names it is given from ZTC's environment as well, as a hook's passEnv is, unless no MCP server may be
231
+ * given it (refusedPassEnvNames: ZTC's own credentials and variables, a broker token, a copy of one of ZTC's
232
+ * credentials); a provider key it may name. The entry's own env goes over all of it.
233
+ */
234
+ export declare function buildMcpServerEnv(entry: {
235
+ readonly env?: Readonly<Record<string, string>>;
236
+ readonly passEnv?: readonly string[];
237
+ }, providerKeyEnv?: Readonly<Record<string, string>>, source?: NodeJS.ProcessEnv): McpServerEnv;
238
+ /**
239
+ * ENV without ZTC's own credentials (ZTC_CREDENTIAL_ENV), the remote-resource broker tokens this process reserved, or
240
+ * any other variable holding one of their values, for a child given the rest of ZTC's environment. ZTC's coordinates
241
+ * (the mirror's port, a pane's id, the relay) are not credentials and stay. For a child that is ZTC itself (`ztcChild`:
242
+ * a colony cell), the credentials it needs by design stay too (ZTC_CHILD_CREDENTIAL_ENV, the configured broker tokens).
243
+ * A stdio MCP server, someone else's program, gets what a tool child gets instead (buildMcpServerEnv).
244
+ */
245
+ export declare function withoutZtcCredentials(env: NodeJS.ProcessEnv, options?: {
246
+ ztcChild?: boolean;
247
+ }): NodeJS.ProcessEnv;
248
+ /**
249
+ * What a ZTC child of PANE_TYPE that a renderer starts (zmux, ZTerm) is given of ZTC's credentials, in its create_pane
250
+ * environment. A renderer starts each pane with its own environment plus the pane's, and its own holds none of them:
251
+ * the host-credential store took them out of this process's environment before the renderer was spawned. So a ZTC
252
+ * pane is given the host's Router runtime grant with the Router it names (hostRouterGrantForZtcChild), the host's
253
+ * effort policy, as a pair, and the platform login in ZTC_AUTH_TOKEN, which it inherited from the renderer before and
254
+ * signs in on (the headless pane manager has never given a ZTC pane that one); a colony cell those and what a cell
255
+ * keeps by design (ZTC_CHILD_CREDENTIAL_ENV), as the headless pane manager gives them (computePaneSpawnEnv). Any other
256
+ * pane gets nothing.
257
+ */
258
+ export declare function ztcChildCredentialEnv(paneType: string | undefined, source?: NodeJS.ProcessEnv): Record<string, string>;
259
+ /**
260
+ * What ZTC's own relaunch through someone else's program is to be started with beyond what that program passes on: a
261
+ * terminal's new window (--new-window) runs the relaunched ZTC with the terminal's environment, and ZTC gives the
262
+ * terminal a user subprocess's (buildUserSubprocessEnv). That leaves out ZTC's own variables (the mirror's sign-in and
263
+ * port, the Router it routes on, ...), the credentials the host-credential store holds with every copy of one, and the
264
+ * credentials a host reserved: this is each of those, as the environment ZTC was started with holds it
265
+ * (hostLaunchEnvironment). The relaunched ZTC is given them in a one-time handoff its command line names
266
+ * (config/host_credentials.ts HOST_HANDOFF_FLAG), so it starts as this one was started, and the terminal holds none.
267
+ * Taking a handoff sets its variables over the ones that ZTC was started with, so it holds none that the relaunch sets
268
+ * afresh: the desktop app's runtime lease marker (DESKTOP_RUNTIME_LEASE_ENV), and LAUNCH_SET, the variables the
269
+ * relaunch's command line sets (an owned relaunch's bundle state routing).
270
+ */
271
+ export declare function ztcRelaunchWithheldEnv(source?: NodeJS.ProcessEnv, launchSet?: readonly string[]): Record<string, string>;
61
272
  export declare function buildTemporaryWriteRootSubprocessEnv(temporaryWriteRoot: string, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
62
273
  /**
63
274
  * Build the exact child environment used with per-request inference
@@ -66,4 +277,9 @@ export declare function buildTemporaryWriteRootSubprocessEnv(temporaryWriteRoot:
66
277
  * names, while an allowlist makes the non-inheritance guarantee explicit.
67
278
  */
68
279
  export declare function buildCredentialSafeSubprocessEnv(source?: NodeJS.ProcessEnv): Record<string, string>;
69
- export declare function buildUserSubprocessEnvOverrides(): Record<string, string>;
280
+ /**
281
+ * Overrides that blank, in a pane the renderer starts with its copy of SOURCE (this process's environment), what a
282
+ * user subprocess never gets (buildUserSubprocessEnv): ZTC's own variables, the reserved credentials, and every other
283
+ * variable holding one of those credentials' values.
284
+ */
285
+ export declare function buildUserSubprocessEnvOverrides(source?: NodeJS.ProcessEnv): Record<string, string>;