@zergai/ztc 0.26.6-dev.202611240947 → 0.27.0-beta.1

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 (268) hide show
  1. package/README.md +629 -167
  2. package/RUST_THIRD_PARTY_LICENSES.txt +5 -5
  3. package/bin/zmux-darwin-arm64 +0 -0
  4. package/bin/zmux-linux-x64 +0 -0
  5. package/bin/ztc-audio-darwin-arm64 +0 -0
  6. package/bin/ztc-capture-darwin-arm64 +0 -0
  7. package/bin/ztc-computer-darwin-arm64 +0 -0
  8. package/bin/ztc-llm-darwin-arm64 +0 -0
  9. package/bin/ztc-tts-darwin-arm64 +0 -0
  10. package/bin/ztc-tui-darwin-arm64 +0 -0
  11. package/bin/ztc-tui-linux-x64 +0 -0
  12. package/bin/zterm-darwin-arm64 +2 -2
  13. package/dist/App.js +6 -1
  14. package/dist/agent/agent.d.ts +21 -15
  15. package/dist/agent/agent.js +389 -163
  16. package/dist/agent/backends/codex_app_server.d.ts +7 -1
  17. package/dist/agent/backends/codex_app_server.js +11 -1
  18. package/dist/agent/backends/gemini.js +22 -8
  19. package/dist/agent/commands/batch.js +8 -0
  20. package/dist/agent/commands/config.js +10 -0
  21. package/dist/agent/commands/environment.js +5 -5
  22. package/dist/agent/commands/goal.d.ts +1 -0
  23. package/dist/agent/commands/goal.js +2 -1
  24. package/dist/agent/commands/index.js +2 -1
  25. package/dist/agent/commands/manifest.js +4 -0
  26. package/dist/agent/commands/optimize.js +5 -2
  27. package/dist/agent/commands/pane_cli.d.ts +29 -0
  28. package/dist/agent/commands/pane_cli.js +303 -0
  29. package/dist/agent/commands/settings.js +13 -3
  30. package/dist/agent/commands/shannon.js +8 -0
  31. package/dist/agent/commands/update.js +15 -3
  32. package/dist/agent/commands/zerg.js +31 -1
  33. package/dist/agent/commands/ztc_pane.js +3 -1
  34. package/dist/agent/factory.d.ts +4 -0
  35. package/dist/agent/factory.js +11 -1
  36. package/dist/agent/loop_policy.d.ts +42 -5
  37. package/dist/agent/loop_policy.js +206 -3
  38. package/dist/agent/runtime/command_jobs.d.ts +5 -0
  39. package/dist/agent/runtime/command_jobs.js +241 -31
  40. package/dist/agent/runtime/command_wait.d.ts +2 -0
  41. package/dist/agent/runtime/command_wait.js +1 -0
  42. package/dist/agent/runtime/done_report.d.ts +18 -0
  43. package/dist/agent/runtime/done_report.js +130 -0
  44. package/dist/agent/runtime/execution_context.js +4 -1
  45. package/dist/agent/runtime/failure_cause.d.ts +2 -0
  46. package/dist/agent/runtime/failure_cause.js +35 -0
  47. package/dist/agent/runtime/policy.d.ts +14 -2
  48. package/dist/agent/runtime/policy.js +104 -12
  49. package/dist/agent/runtime/quiet_job.d.ts +18 -0
  50. package/dist/agent/runtime/quiet_job.js +48 -0
  51. package/dist/agent/runtime/recovery.d.ts +1 -5
  52. package/dist/agent/runtime/recovery.js +2 -44
  53. package/dist/agent/runtime/tool_runtime.d.ts +1 -0
  54. package/dist/agent/runtime/tool_runtime.js +2 -0
  55. package/dist/agent/subagent.js +6 -1
  56. package/dist/agent/tools/deferred.js +1 -0
  57. package/dist/agent/tools/index.d.ts +2 -0
  58. package/dist/agent/tools/index.js +1 -0
  59. package/dist/agent/tools/outcome.d.ts +15 -0
  60. package/dist/agent/tools/outcome.js +107 -0
  61. package/dist/agent/tools/pane.d.ts +2 -1
  62. package/dist/agent/tools/pane.js +21 -3
  63. package/dist/agent/tools/registry.js +2 -0
  64. package/dist/agent/tools/shell.d.ts +1 -0
  65. package/dist/agent/tools/shell.js +128 -17
  66. package/dist/agent/tools/sim_domain_tools.js +4 -2
  67. package/dist/agent/tools/supervision.js +4 -2
  68. package/dist/agent/tools/types.d.ts +3 -0
  69. package/dist/app/command_context.js +5 -9
  70. package/dist/app/conversation_compaction.d.ts +4 -2
  71. package/dist/app/conversation_compaction.js +16 -5
  72. package/dist/app/headless_shell_mode.d.ts +14 -0
  73. package/dist/app/headless_shell_mode.js +7 -0
  74. package/dist/app/hosted_resident.d.ts +356 -0
  75. package/dist/app/hosted_resident.js +677 -0
  76. package/dist/app/restart.js +11 -2
  77. package/dist/app/session_manager.d.ts +5 -0
  78. package/dist/app/session_manager.js +21 -6
  79. package/dist/app/session_messages.js +6 -6
  80. package/dist/app/workspace_layout_controller.js +7 -0
  81. package/dist/batch/worktree.d.ts +10 -0
  82. package/dist/batch/worktree.js +15 -0
  83. package/dist/bench/registry.js +4 -2
  84. package/dist/cli_args.js +1 -1
  85. package/dist/cli_main.js +80 -10
  86. package/dist/cli_ratatui.d.ts +75 -0
  87. package/dist/cli_ratatui.js +485 -84
  88. package/dist/components/InputArea.js +4 -4
  89. package/dist/config/execution.d.ts +10 -0
  90. package/dist/config/execution.js +10 -0
  91. package/dist/config/hosted_runtime.d.ts +4 -1
  92. package/dist/config/hosted_runtime.js +4 -1
  93. package/dist/config/permission_pin.d.ts +34 -2
  94. package/dist/config/permission_pin.js +52 -2
  95. package/dist/config/person_command_policy.d.ts +38 -0
  96. package/dist/config/person_command_policy.js +11 -0
  97. package/dist/config/profiles.d.ts +21 -0
  98. package/dist/config/profiles.js +56 -2
  99. package/dist/config/types.d.ts +4 -1
  100. package/dist/config.js +34 -19
  101. package/dist/desktop/daily/codex_exec_adapter.js +7 -2
  102. package/dist/desktop/daily/desktop_wiring.d.ts +7 -1
  103. package/dist/desktop/daily/desktop_wiring.js +11 -3
  104. package/dist/desktop/daily/recipes.js +20 -4
  105. package/dist/desktop/health.d.ts +24 -0
  106. package/dist/desktop/health.js +151 -0
  107. package/dist/desktop/native_dialogs.d.ts +37 -0
  108. package/dist/desktop/native_dialogs.js +105 -0
  109. package/dist/diagnostics/session_export.d.ts +1 -0
  110. package/dist/diagnostics/session_export.js +28 -0
  111. package/dist/embedded/registry.js +4 -2
  112. package/dist/emulation/tool_adapters.js +9 -4
  113. package/dist/emulation/ztc_addendum.js +3 -0
  114. package/dist/headless.d.ts +11 -4
  115. package/dist/headless.js +99 -34
  116. package/dist/headless_approval.d.ts +6 -0
  117. package/dist/headless_cli.js +1 -1
  118. package/dist/hooks/runner.js +7 -6
  119. package/dist/library.d.ts +4 -0
  120. package/dist/library.js +3 -0
  121. package/dist/mcp/client.js +3 -3
  122. package/dist/modes/registry.js +13 -4
  123. package/dist/onboarding/setup_environment.js +13 -1
  124. package/dist/optimize/adapters/kernelbench.js +88 -10
  125. package/dist/optimize/adapters/types.d.ts +5 -0
  126. package/dist/optimize/executor.js +21 -0
  127. package/dist/panes/cli_install.d.ts +54 -0
  128. package/dist/panes/cli_install.js +157 -0
  129. package/dist/panes/model_catalog.js +3 -0
  130. package/dist/panes/new_pane_choices.d.ts +6 -2
  131. package/dist/panes/new_pane_choices.js +24 -12
  132. package/dist/panes/pane_cli_launch.d.ts +50 -0
  133. package/dist/panes/pane_cli_launch.js +124 -0
  134. package/dist/panes/pane_clis.d.ts +171 -0
  135. package/dist/panes/pane_clis.js +325 -0
  136. package/dist/panes/person_only_panes.d.ts +45 -0
  137. package/dist/panes/person_only_panes.js +117 -0
  138. package/dist/plugin/simulation_living.js +0 -2
  139. package/dist/plugin/simulation_living_engine.d.ts +1 -0
  140. package/dist/plugin/simulation_living_engine.js +1 -0
  141. package/dist/plugin/simulation_living_labels.d.ts +3 -0
  142. package/dist/plugin/simulation_living_labels.js +2 -0
  143. package/dist/router_auth.js +12 -1
  144. package/dist/session.js +26 -1
  145. package/dist/simulation/art/gemini_image.js +11 -5
  146. package/dist/simulation/domains/loader.js +25 -3
  147. package/dist/simulation/living/cold.d.ts +23 -0
  148. package/dist/simulation/living/cold.js +41 -0
  149. package/dist/simulation/living/context.d.ts +591 -1283
  150. package/dist/simulation/living/context.js +378 -244
  151. package/dist/simulation/living/contradictions.d.ts +14 -0
  152. package/dist/simulation/living/contradictions.js +282 -0
  153. package/dist/simulation/living/core/ids.d.ts +53 -0
  154. package/dist/simulation/living/core/ids.js +39 -0
  155. package/dist/simulation/living/core/kind.d.ts +20 -0
  156. package/dist/simulation/living/core/kind.js +15 -0
  157. package/dist/simulation/living/core/laws.d.ts +179 -0
  158. package/dist/simulation/living/core/laws.js +184 -0
  159. package/dist/simulation/living/core/ops.d.ts +257 -0
  160. package/dist/simulation/living/core/ops.js +34 -0
  161. package/dist/simulation/living/definer.d.ts +17 -1
  162. package/dist/simulation/living/definer.js +130 -51
  163. package/dist/simulation/living/definition.d.ts +174 -65
  164. package/dist/simulation/living/definition.js +287 -180
  165. package/dist/simulation/living/director.d.ts +80 -0
  166. package/dist/simulation/living/director.js +363 -0
  167. package/dist/simulation/living/frame.d.ts +108 -21
  168. package/dist/simulation/living/frame.js +111 -66
  169. package/dist/simulation/living/identifiers.d.ts +0 -1
  170. package/dist/simulation/living/identifiers.js +0 -3
  171. package/dist/simulation/living/index.d.ts +18 -9
  172. package/dist/simulation/living/index.js +18 -9
  173. package/dist/simulation/living/inference.d.ts +92 -50
  174. package/dist/simulation/living/inference.js +319 -175
  175. package/dist/simulation/living/knowledge.d.ts +28 -0
  176. package/dist/simulation/living/knowledge.js +73 -0
  177. package/dist/simulation/living/library.json +1177 -0
  178. package/dist/simulation/living/mechanics.d.ts +31 -34
  179. package/dist/simulation/living/mechanics.js +222 -138
  180. package/dist/simulation/living/model-input.d.ts +6 -3
  181. package/dist/simulation/living/model-input.js +18 -26
  182. package/dist/simulation/living/open-world.d.ts +74 -94
  183. package/dist/simulation/living/open-world.js +151 -30
  184. package/dist/simulation/living/phrases.d.ts +3 -0
  185. package/dist/simulation/living/phrases.js +37 -0
  186. package/dist/simulation/living/phrases.json +560 -0
  187. package/dist/simulation/living/projection.d.ts +316 -2
  188. package/dist/simulation/living/projection.js +50 -2
  189. package/dist/simulation/living/prompts/example-spec.json +11 -0
  190. package/dist/simulation/living/prompts/role-text.json +14 -0
  191. package/dist/simulation/living/prompts.d.ts +5 -0
  192. package/dist/simulation/living/prompts.js +275 -0
  193. package/dist/simulation/living/recall.d.ts +2 -2
  194. package/dist/simulation/living/reduce.d.ts +51 -14
  195. package/dist/simulation/living/reduce.js +941 -579
  196. package/dist/simulation/living/replay.d.ts +5 -4
  197. package/dist/simulation/living/replay.js +10 -9
  198. package/dist/simulation/living/runtime.d.ts +135 -25
  199. package/dist/simulation/living/runtime.js +1641 -583
  200. package/dist/simulation/living/scale.d.ts +96 -0
  201. package/dist/simulation/living/scale.js +124 -0
  202. package/dist/simulation/living/script.d.ts +5 -0
  203. package/dist/simulation/living/script.js +115 -0
  204. package/dist/simulation/living/shared-kinds.d.ts +4 -11
  205. package/dist/simulation/living/shared-kinds.js +11 -81
  206. package/dist/simulation/living/space.d.ts +14 -0
  207. package/dist/simulation/living/space.js +132 -0
  208. package/dist/simulation/living/state.d.ts +100 -0
  209. package/dist/simulation/living/state.js +393 -0
  210. package/dist/simulation/living/types.d.ts +829 -512
  211. package/dist/simulation/living/types.js +162 -187
  212. package/dist/simulation/living/world-rules.d.ts +100 -0
  213. package/dist/simulation/living/world-rules.js +267 -0
  214. package/dist/simulation/plugins/loader.js +11 -0
  215. package/dist/skills/loader.js +4 -0
  216. package/dist/tools.d.ts +1 -0
  217. package/dist/tools.js +1 -0
  218. package/dist/ui/ratatui/headless_pane_manager.d.ts +4 -1
  219. package/dist/ui/ratatui/headless_pane_manager.js +13 -9
  220. package/dist/ui/ratatui/pane_relay.js +29 -0
  221. package/dist/ui/ratatui/pane_type.d.ts +10 -0
  222. package/dist/ui/ratatui/pane_type.js +11 -0
  223. package/dist/ui/ratatui/process.d.ts +30 -0
  224. package/dist/ui/ratatui/process.js +133 -19
  225. package/dist/ui/ratatui/protocol.d.ts +124 -2
  226. package/dist/ui/ratatui/protocol.js +35 -0
  227. package/dist/ui/ratatui/relay_policy.js +3 -0
  228. package/dist/ui/ratatui/ztc_launch_trust.d.ts +2 -1
  229. package/dist/ui/ratatui/ztc_launch_trust.js +8 -1
  230. package/dist/ui/terminal_image.d.ts +12 -0
  231. package/dist/ui/terminal_image.js +21 -1
  232. package/dist/utils/codex_project_trust.d.ts +19 -0
  233. package/dist/utils/codex_project_trust.js +37 -0
  234. package/dist/utils/compaction.js +103 -20
  235. package/dist/utils/git_program_files.d.ts +19 -12
  236. package/dist/utils/git_program_files.js +411 -83
  237. package/dist/utils/host_shell.d.ts +10 -1
  238. package/dist/utils/host_shell.js +14 -1
  239. package/dist/utils/mid_turn_compaction.d.ts +2 -0
  240. package/dist/utils/mid_turn_compaction.js +2 -0
  241. package/dist/utils/models.js +6 -1
  242. package/dist/utils/sandbox.d.ts +109 -8
  243. package/dist/utils/sandbox.js +981 -187
  244. package/dist/utils/shell.d.ts +2 -0
  245. package/dist/utils/shell.js +10 -4
  246. package/dist/utils/subprocess_env.d.ts +47 -11
  247. package/dist/utils/subprocess_env.js +107 -15
  248. package/dist/utils/system_ps.d.ts +8 -0
  249. package/dist/utils/system_ps.js +39 -7
  250. package/dist/utils/unattended_compaction.d.ts +9 -0
  251. package/dist/utils/unattended_compaction.js +13 -0
  252. package/dist/utils/ztc_own_state.d.ts +8 -5
  253. package/dist/utils/ztc_own_state.js +17 -11
  254. package/dist/web/mirror_client.js +1 -0
  255. package/dist/web/mirror_stream.d.ts +50 -6
  256. package/dist/web/mirror_stream.js +160 -15
  257. package/dist/workflows/registry.js +3 -1
  258. package/dist/workspace/controller.js +12 -0
  259. package/dist/workspace_collision.d.ts +3 -0
  260. package/dist/workspace_collision.js +14 -1
  261. package/dist/workspace_session_context.js +2 -1
  262. package/dist/zlm-embed.mjs +3823 -1970
  263. package/node_modules/@zerg/model-contracts/README.md +16 -4
  264. package/node_modules/@zerg/model-contracts/index.js +6 -1
  265. package/npm-shrinkwrap.json +1 -1
  266. package/package.json +42 -24
  267. package/packages/model-contracts/README.md +16 -4
  268. package/packages/model-contracts/index.js +6 -1
@@ -1,6 +1,6 @@
1
1
  /** How this host runs a command's shell text. */
2
2
  export interface HostShell {
3
- /** sh: /bin/sh on macOS and Linux. git-bash: Git for Windows' bash. cmd: cmd.exe, on Windows without Git for Windows. */
3
+ /** sh: the host POSIX shell, bash when installed and /bin/sh otherwise. git-bash: Git for Windows' bash. cmd: cmd.exe, on Windows without Git for Windows. */
4
4
  kind: 'sh' | 'git-bash' | 'cmd';
5
5
  executable: string;
6
6
  args: string[];
@@ -18,6 +18,15 @@ export declare function findGitBash(env?: NodeJS.ProcessEnv): string | null;
18
18
  * and cmd.exe reads none of sleep, printf, single quotes or $(...). Without Git for Windows it is cmd.exe.
19
19
  */
20
20
  export declare function hostShell(command: string): HostShell;
21
+ /** The program POSIX shell text runs under on macOS and Linux: bash where the host has it, else /bin/sh. */
22
+ export declare function posixShell(): string;
23
+ /**
24
+ * posixShell's arguments for COMMAND, with which it reads nothing else: privileged mode (-p) takes no BASH_ENV, exported
25
+ * function or SHELLOPTS from the environment, and --noprofile and --norc keep it from ~/.bashrc, which bash reads without
26
+ * them, -p or not, where its standard input is a socket (every pipe Node gives a child) and no SHLVL says a shell started
27
+ * it (a service, a hosted resident, the desktop app). /bin/sh reads no startup file either way.
28
+ */
29
+ export declare function posixShellArgs(command: string): string[];
21
30
  /**
22
31
  * Stops the process `pid` and every process it started. Windows has no process groups or signals to send them:
23
32
  * taskkill /T walks the tree from `pid`, and /F ends each process, since a console program cannot be asked to close.
@@ -28,12 +28,25 @@ export function findGitBash(env = process.env) {
28
28
  */
29
29
  export function hostShell(command) {
30
30
  if (process.platform !== 'win32')
31
- return { kind: 'sh', executable: '/bin/sh', args: ['-c', command] };
31
+ return { kind: 'sh', executable: posixShell(), args: posixShellArgs(command) };
32
32
  const bash = findGitBash();
33
33
  if (bash)
34
34
  return { kind: 'git-bash', executable: bash, args: ['--noprofile', '--norc', '-c', command] };
35
35
  return { kind: 'cmd', executable: process.env.ComSpec || 'cmd.exe', args: ['/d', '/s', '/c', `"${command}"`], windowsVerbatimArguments: true };
36
36
  }
37
+ /** The program POSIX shell text runs under on macOS and Linux: bash where the host has it, else /bin/sh. */
38
+ export function posixShell() {
39
+ return existsSync('/bin/bash') ? '/bin/bash' : '/bin/sh';
40
+ }
41
+ /**
42
+ * posixShell's arguments for COMMAND, with which it reads nothing else: privileged mode (-p) takes no BASH_ENV, exported
43
+ * function or SHELLOPTS from the environment, and --noprofile and --norc keep it from ~/.bashrc, which bash reads without
44
+ * them, -p or not, where its standard input is a socket (every pipe Node gives a child) and no SHLVL says a shell started
45
+ * it (a service, a hosted resident, the desktop app). /bin/sh reads no startup file either way.
46
+ */
47
+ export function posixShellArgs(command) {
48
+ return posixShell().endsWith('bash') ? ['--noprofile', '--norc', '-p', '-c', command] : ['-c', command];
49
+ }
37
50
  /**
38
51
  * Stops the process `pid` and every process it started. Windows has no process groups or signals to send them:
39
52
  * taskkill /T walks the tree from `pid`, and /F ends each process, since a console program cannot be asked to close.
@@ -4,6 +4,8 @@ export interface MidTurnCompactionInput {
4
4
  windowTokens: number;
5
5
  thresholdPercent: number;
6
6
  tokenBudget?: number;
7
+ /** Where an unattended run compacts under its share of the window (unattendedCompactTokens). A token budget wins. */
8
+ earlyTokens?: number;
7
9
  reservedOutputTokens?: number;
8
10
  messagesSinceLastCompaction: number;
9
11
  lastFreedTokens?: number;
@@ -11,6 +11,8 @@ export function shouldCompactMidTurn(input) {
11
11
  return true;
12
12
  if (typeof input.tokenBudget === 'number' && input.tokenBudget > 0)
13
13
  return input.usedTokens >= input.tokenBudget;
14
+ if (typeof input.earlyTokens === 'number' && input.earlyTokens > 0 && input.usedTokens >= input.earlyTokens)
15
+ return true;
14
16
  if (input.windowTokens <= 0)
15
17
  return false;
16
18
  return (input.usedTokens / input.windowTokens) * 100 >= input.thresholdPercent;
@@ -498,7 +498,12 @@ export async function listModels(options) {
498
498
  return parseList(res);
499
499
  }
500
500
  if (provider === 'gemini') {
501
- const res = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`, { signal });
501
+ // The key goes in x-goog-api-key, never in the URL; fetch would take that header on to where a redirect points.
502
+ const { MODEL_REQUEST_REDIRECT, refuseModelRedirect } = await import('../agent/backends/model_redirect.js');
503
+ const url = 'https://generativelanguage.googleapis.com/v1beta/models';
504
+ const headers = { 'x-goog-api-key': apiKey };
505
+ const res = await fetch(url, { signal, headers, redirect: MODEL_REQUEST_REDIRECT });
506
+ await refuseModelRedirect(res, url, headers);
502
507
  if (!res.ok) {
503
508
  throw new Error(`Gemini error (${res.status})`);
504
509
  }
@@ -61,9 +61,89 @@ export interface SandboxBackendStatus {
61
61
  notes: string[];
62
62
  }
63
63
  /**
64
- * The folders a command under PROFILE may write, its relative roots those of FOLDER (allowedRoots), each as named and by
65
- * its real path (seatbeltRoots); none under a profile that writes nothing. ConfigStore.pinStartupPermissions keeps ZTC's
66
- * own state and TMPDIR out of them.
64
+ * A root a profile names, as one look at each folder on the way to it found it (profileRootLooks): the root as the profile
65
+ * names it (absolute; a relative one the session's folder's), and its real path, which every rule, bind and check after
66
+ * that look takes as it is, without looking again.
67
+ */
68
+ export interface ProfileRoot {
69
+ /** The root, as the profile names it (absolute; a relative one the session's folder's). */
70
+ root: string;
71
+ /** Its real path, as the look found it: each folder that exists resolved, the part that doesn't exist yet as named. */
72
+ real: string;
73
+ /** Why nothing is at its real path yet, where nothing is: ENOENT, or ENOTDIR where a file stands where a folder above it would. */
74
+ missing?: 'ENOENT' | 'ENOTDIR';
75
+ }
76
+ /** A root a profile names that is, or is named through, a link a command could have made (profileRootLooks). */
77
+ export interface LinkedProfileRoot {
78
+ /** The root, as the profile names it (absolute; a relative one the session's folder's). */
79
+ root: string;
80
+ /** The link: the root itself, or a folder above it, as named (as the look found it, where a link's target led to it). */
81
+ link: string;
82
+ /** Where the link leads, as it names it (absolute). */
83
+ leads: string;
84
+ /** The root by its real path, as the look found it (where the link leads, the part that doesn't exist as named). */
85
+ real: string;
86
+ }
87
+ /** A root a profile names that ZTC couldn't look at, so it is no root (profileRootLooks). */
88
+ export interface UnreadableProfileRoot {
89
+ /** The root, as the profile names it (absolute; a relative one the session's folder's). */
90
+ root: string;
91
+ /** The folder ZTC couldn't look into, or, for ECHANGED, the path its look built, which led elsewhere when looked at again. */
92
+ folder: string;
93
+ /** lstat's, readlink's or realpath's error code; ECHANGED where a folder on the way became a link while ZTC looked. */
94
+ code: string;
95
+ }
96
+ /** What one look at each root a profile names found (profileRootLooks). */
97
+ export interface ProfileRootLooks {
98
+ /** The roots kept, in the profile's order, each once. */
99
+ roots: ProfileRoot[];
100
+ /** The roots refused for a link a command could have made. */
101
+ linked: LinkedProfileRoot[];
102
+ /** The roots refused because ZTC couldn't look at them. */
103
+ unreadable: UnreadableProfileRoot[];
104
+ }
105
+ /**
106
+ * One look at each root PROFILE names (allowedPaths, a relative one ROOTS_CWD's: lookAtRoot), which every plan, rule and
107
+ * check after it takes as it found them, each root by the real path that look built, without resolving the root again:
108
+ * the look was a walk by lstat, and everything after it resolved each root again by its path (the policy's canonical
109
+ * roots, Seatbelt's rules, bubblewrap's real path and bind), so a command left running in the background that swapped a
110
+ * root, or a folder above it, between a folder and a link to a folder outside every root had the policy, the rules or
111
+ * the bind follow the link the look hadn't seen: write_file, read_file and the command itself wrote and read outside
112
+ * every root (the review of fix/r9-release-blockers' repair, R9C-ESCAPE-1, R9C-ESCAPE-2). A root that is, or is named
113
+ * through, a symbolic link in a folder that lies, by its real path, in one of the roots (their real paths, this one's
114
+ * among them) is a link a confined command could have made, or pointed elsewhere, as one can any file in a root it
115
+ * writes, or a writing profile's command did before; it is refused, and it alone (LINKED): the OS sandbox doesn't bind
116
+ * it, so the link stays a plain link in the bind of the root that holds it, and the policy keeps the file tools out of it
117
+ * (agent/runtime/policy.ts). The policy, which resolved each root through links on every call, let write_file write
118
+ * HOME/.bashrc once a command had made `./build` a link there, and the next plan bound where the link led (the review of
119
+ * fix/r9-release-blockers, RV8-LINK); a profile whose commands write nothing read through one a writing profile's command
120
+ * had made (R9C-ESCAPE-3), so this holds under every profile that names allowedPaths. A link no root holds (macOS's /tmp
121
+ * and /var, ~/link -> ~/real, a HOME that is a link) names a root as before. A root ZTC can't look at (a folder on the
122
+ * way it can't look into, `chmod 000`; one that became a link as it looked) is refused alone too (UNREADABLE): the policy
123
+ * threw on it, and every tool of the profile failed (R9C-TRUTH-5).
124
+ */
125
+ export declare function profileRootLooks(profile: ZTCPermissionProfile | undefined, rootsCwd: string): ProfileRootLooks;
126
+ /**
127
+ * Why ZTC couldn't look at a root (UnreadableProfileRoot: FOLDER, where its look stopped, and CODE, why), and what to do
128
+ * about it: a folder that changed as ZTC looked; a link on the way that leads round in a loop (ELOOP); a name longer than
129
+ * the filesystem allows (ENAMETOOLONG); a folder ZTC may not look into (EACCES, EPERM, and anything else), whose mode to
130
+ * give back. Each but the last said to give a folder back its mode, which none of them helps.
131
+ */
132
+ export declare function unreadableRootReason({ folder, code }: UnreadableProfileRoot): string;
133
+ /**
134
+ * What a link root's refusal says to do (LINKED, a root its profile names that is, or is named through, a link a command
135
+ * could have made; ROOTS, the real paths of the roots kept beside it; SESSION, the session's folder, or none): remove the
136
+ * link, or name the folder the person meant in allowedPaths, by its real path, or start the session from it where the
137
+ * root is the session's own (allowedPaths [~, .] in a session at ~/proj-link), once they have checked that it is the
138
+ * folder the link leads to now, which a command could have chosen; and where the link leads into another root, that its
139
+ * folder is reachable through that root (the review of fix/r9-release-blockers' repair, R9C-REGRESSION-6). It said to
140
+ * name the folder the link leads to, whatever a command had pointed it at (appstore's LINK-ADVICE).
141
+ */
142
+ export declare function linkedRootAdvice({ root, real }: LinkedProfileRoot, roots: readonly string[], session?: string): string;
143
+ /**
144
+ * The folders a command under PROFILE may write, its relative roots those of FOLDER, each as named and by the real path
145
+ * one look at it found (commandRoots); none under a profile that writes nothing. ConfigStore.pinStartupPermissions keeps
146
+ * ZTC's own state and TMPDIR out of them.
67
147
  */
68
148
  export declare function commandWriteRoots(profile: ZTCPermissionProfile | undefined, folder: string): string[];
69
149
  /**
@@ -114,10 +194,28 @@ export interface BubblewrapPlanOptions {
114
194
  /** Files the command may also read, read-only (SandboxCommandOptions.readPaths). */
115
195
  readPaths?: readonly string[];
116
196
  /**
117
- * Where the folders bwrap makes for the plan's placeholders go (placeholderPlan), for its caller to hold and, after the
197
+ * Where the folders made for the plan's placeholders go (placeholderPlan), for its caller to make and, after the
118
198
  * command, remove (buildBubblewrapCommandPlan).
119
199
  */
120
200
  placeholders?: string[];
201
+ /**
202
+ * Where the folders above the plan's placeholders that don't exist yet go, outermost first, for its caller to make on
203
+ * the host before it starts bwrap (makeBubblewrapAncestors), which pins each: bwrap looks up every bind's source before
204
+ * it applies any option, so a pin of a folder that isn't there starts no command.
205
+ */
206
+ ancestors?: string[];
207
+ /**
208
+ * Where the folders the plan's placeholders stand on go, for its caller to make on the host before it starts bwrap and
209
+ * hold, with a hold of the plan's own in each (holdPlaceholderFolders), which no other ZTC's step after its command removes.
210
+ */
211
+ placeholderFolders?: string[];
212
+ /**
213
+ * What one look at each root the profile names found (profileRootLooks), which the plan's caller took once for the whole
214
+ * plan: the argv binds each root by what it found, and looks at none again.
215
+ */
216
+ rootLooks?: ProfileRootLooks;
217
+ /** The real path each of the ancestors and placeholder folders above is to have (placeholderPlan), for madeFolderError. */
218
+ physical?: Map<string, string>;
121
219
  }
122
220
  /**
123
221
  * Whether the bwrap this host's PATH finds makes the namespaces ZTC runs commands in: it is run once, by its path, on
@@ -143,9 +241,12 @@ export declare function buildBubblewrapArgs(command: string, cwd: string, profil
143
241
  seccompFd?: number, plan?: BubblewrapPlanOptions): string[];
144
242
  /**
145
243
  * The bwrap plan for COMMAND in CWD under OPTIONS, which buildSandboxCommandPlan makes once it has found bwrap on this
146
- * host: its argv (buildBubblewrapArgs), and the step after the command (afterCommand) that undoes what bwrap could not
147
- * refuse it where a repository names the programs git starts, then puts back what it broke of a repository the plan
148
- * knew, both from what the plan found before it ran.
244
+ * host: its argv (buildBubblewrapArgs), by one look at each root its profile names (LOOKS, profileRootLooks, which
245
+ * buildSandboxCommandPlan's audit records too), with what its placeholders stand on, and the folders above a denial not
246
+ * made yet for bwrap to pin, made and held on the host (holdPlaceholderFolders) and removed by its cleanup where left
247
+ * empty, still the ones it made, and no other plan holds them (bubblewrapRelease), and the step after the command
248
+ * (afterCommand) that undoes what bwrap could not refuse it where a repository names the programs git starts, then puts
249
+ * back what it broke of a repository the plan knew, both from what the plan found before it ran.
149
250
  */
150
- export declare function buildBubblewrapCommandPlan(command: string, cwd: string, options?: SandboxCommandOptions): SandboxCommandPlan;
251
+ export declare function buildBubblewrapCommandPlan(command: string, cwd: string, options?: SandboxCommandOptions, looks?: ProfileRootLooks): SandboxCommandPlan;
151
252
  export declare function buildSandboxCommandPlan(command: string, cwd: string, options?: SandboxCommandOptions): SandboxCommandPlan;