@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.
- package/README.md +629 -167
- package/RUST_THIRD_PARTY_LICENSES.txt +5 -5
- package/bin/zmux-darwin-arm64 +0 -0
- package/bin/zmux-linux-x64 +0 -0
- package/bin/ztc-audio-darwin-arm64 +0 -0
- package/bin/ztc-capture-darwin-arm64 +0 -0
- package/bin/ztc-computer-darwin-arm64 +0 -0
- package/bin/ztc-llm-darwin-arm64 +0 -0
- package/bin/ztc-tts-darwin-arm64 +0 -0
- package/bin/ztc-tui-darwin-arm64 +0 -0
- package/bin/ztc-tui-linux-x64 +0 -0
- package/bin/zterm-darwin-arm64 +2 -2
- package/dist/App.js +6 -1
- package/dist/agent/agent.d.ts +21 -15
- package/dist/agent/agent.js +389 -163
- package/dist/agent/backends/codex_app_server.d.ts +7 -1
- package/dist/agent/backends/codex_app_server.js +11 -1
- package/dist/agent/backends/gemini.js +22 -8
- package/dist/agent/commands/batch.js +8 -0
- package/dist/agent/commands/config.js +10 -0
- package/dist/agent/commands/environment.js +5 -5
- package/dist/agent/commands/goal.d.ts +1 -0
- package/dist/agent/commands/goal.js +2 -1
- package/dist/agent/commands/index.js +2 -1
- package/dist/agent/commands/manifest.js +4 -0
- package/dist/agent/commands/optimize.js +5 -2
- package/dist/agent/commands/pane_cli.d.ts +29 -0
- package/dist/agent/commands/pane_cli.js +303 -0
- package/dist/agent/commands/settings.js +13 -3
- package/dist/agent/commands/shannon.js +8 -0
- package/dist/agent/commands/update.js +15 -3
- package/dist/agent/commands/zerg.js +31 -1
- package/dist/agent/commands/ztc_pane.js +3 -1
- package/dist/agent/factory.d.ts +4 -0
- package/dist/agent/factory.js +11 -1
- package/dist/agent/loop_policy.d.ts +42 -5
- package/dist/agent/loop_policy.js +206 -3
- package/dist/agent/runtime/command_jobs.d.ts +5 -0
- package/dist/agent/runtime/command_jobs.js +241 -31
- package/dist/agent/runtime/command_wait.d.ts +2 -0
- package/dist/agent/runtime/command_wait.js +1 -0
- package/dist/agent/runtime/done_report.d.ts +18 -0
- package/dist/agent/runtime/done_report.js +130 -0
- package/dist/agent/runtime/execution_context.js +4 -1
- package/dist/agent/runtime/failure_cause.d.ts +2 -0
- package/dist/agent/runtime/failure_cause.js +35 -0
- package/dist/agent/runtime/policy.d.ts +14 -2
- package/dist/agent/runtime/policy.js +104 -12
- package/dist/agent/runtime/quiet_job.d.ts +18 -0
- package/dist/agent/runtime/quiet_job.js +48 -0
- package/dist/agent/runtime/recovery.d.ts +1 -5
- package/dist/agent/runtime/recovery.js +2 -44
- package/dist/agent/runtime/tool_runtime.d.ts +1 -0
- package/dist/agent/runtime/tool_runtime.js +2 -0
- package/dist/agent/subagent.js +6 -1
- package/dist/agent/tools/deferred.js +1 -0
- package/dist/agent/tools/index.d.ts +2 -0
- package/dist/agent/tools/index.js +1 -0
- package/dist/agent/tools/outcome.d.ts +15 -0
- package/dist/agent/tools/outcome.js +107 -0
- package/dist/agent/tools/pane.d.ts +2 -1
- package/dist/agent/tools/pane.js +21 -3
- package/dist/agent/tools/registry.js +2 -0
- package/dist/agent/tools/shell.d.ts +1 -0
- package/dist/agent/tools/shell.js +128 -17
- package/dist/agent/tools/sim_domain_tools.js +4 -2
- package/dist/agent/tools/supervision.js +4 -2
- package/dist/agent/tools/types.d.ts +3 -0
- package/dist/app/command_context.js +5 -9
- package/dist/app/conversation_compaction.d.ts +4 -2
- package/dist/app/conversation_compaction.js +16 -5
- package/dist/app/headless_shell_mode.d.ts +14 -0
- package/dist/app/headless_shell_mode.js +7 -0
- package/dist/app/hosted_resident.d.ts +356 -0
- package/dist/app/hosted_resident.js +677 -0
- package/dist/app/restart.js +11 -2
- package/dist/app/session_manager.d.ts +5 -0
- package/dist/app/session_manager.js +21 -6
- package/dist/app/session_messages.js +6 -6
- package/dist/app/workspace_layout_controller.js +7 -0
- package/dist/batch/worktree.d.ts +10 -0
- package/dist/batch/worktree.js +15 -0
- package/dist/bench/registry.js +4 -2
- package/dist/cli_args.js +1 -1
- package/dist/cli_main.js +80 -10
- package/dist/cli_ratatui.d.ts +75 -0
- package/dist/cli_ratatui.js +485 -84
- package/dist/components/InputArea.js +4 -4
- package/dist/config/execution.d.ts +10 -0
- package/dist/config/execution.js +10 -0
- package/dist/config/hosted_runtime.d.ts +4 -1
- package/dist/config/hosted_runtime.js +4 -1
- package/dist/config/permission_pin.d.ts +34 -2
- package/dist/config/permission_pin.js +52 -2
- package/dist/config/person_command_policy.d.ts +38 -0
- package/dist/config/person_command_policy.js +11 -0
- package/dist/config/profiles.d.ts +21 -0
- package/dist/config/profiles.js +56 -2
- package/dist/config/types.d.ts +4 -1
- package/dist/config.js +34 -19
- package/dist/desktop/daily/codex_exec_adapter.js +7 -2
- package/dist/desktop/daily/desktop_wiring.d.ts +7 -1
- package/dist/desktop/daily/desktop_wiring.js +11 -3
- package/dist/desktop/daily/recipes.js +20 -4
- package/dist/desktop/health.d.ts +24 -0
- package/dist/desktop/health.js +151 -0
- package/dist/desktop/native_dialogs.d.ts +37 -0
- package/dist/desktop/native_dialogs.js +105 -0
- package/dist/diagnostics/session_export.d.ts +1 -0
- package/dist/diagnostics/session_export.js +28 -0
- package/dist/embedded/registry.js +4 -2
- package/dist/emulation/tool_adapters.js +9 -4
- package/dist/emulation/ztc_addendum.js +3 -0
- package/dist/headless.d.ts +11 -4
- package/dist/headless.js +99 -34
- package/dist/headless_approval.d.ts +6 -0
- package/dist/headless_cli.js +1 -1
- package/dist/hooks/runner.js +7 -6
- package/dist/library.d.ts +4 -0
- package/dist/library.js +3 -0
- package/dist/mcp/client.js +3 -3
- package/dist/modes/registry.js +13 -4
- package/dist/onboarding/setup_environment.js +13 -1
- package/dist/optimize/adapters/kernelbench.js +88 -10
- package/dist/optimize/adapters/types.d.ts +5 -0
- package/dist/optimize/executor.js +21 -0
- package/dist/panes/cli_install.d.ts +54 -0
- package/dist/panes/cli_install.js +157 -0
- package/dist/panes/model_catalog.js +3 -0
- package/dist/panes/new_pane_choices.d.ts +6 -2
- package/dist/panes/new_pane_choices.js +24 -12
- package/dist/panes/pane_cli_launch.d.ts +50 -0
- package/dist/panes/pane_cli_launch.js +124 -0
- package/dist/panes/pane_clis.d.ts +171 -0
- package/dist/panes/pane_clis.js +325 -0
- package/dist/panes/person_only_panes.d.ts +45 -0
- package/dist/panes/person_only_panes.js +117 -0
- package/dist/plugin/simulation_living.js +0 -2
- package/dist/plugin/simulation_living_engine.d.ts +1 -0
- package/dist/plugin/simulation_living_engine.js +1 -0
- package/dist/plugin/simulation_living_labels.d.ts +3 -0
- package/dist/plugin/simulation_living_labels.js +2 -0
- package/dist/router_auth.js +12 -1
- package/dist/session.js +26 -1
- package/dist/simulation/art/gemini_image.js +11 -5
- package/dist/simulation/domains/loader.js +25 -3
- package/dist/simulation/living/cold.d.ts +23 -0
- package/dist/simulation/living/cold.js +41 -0
- package/dist/simulation/living/context.d.ts +591 -1283
- package/dist/simulation/living/context.js +378 -244
- package/dist/simulation/living/contradictions.d.ts +14 -0
- package/dist/simulation/living/contradictions.js +282 -0
- package/dist/simulation/living/core/ids.d.ts +53 -0
- package/dist/simulation/living/core/ids.js +39 -0
- package/dist/simulation/living/core/kind.d.ts +20 -0
- package/dist/simulation/living/core/kind.js +15 -0
- package/dist/simulation/living/core/laws.d.ts +179 -0
- package/dist/simulation/living/core/laws.js +184 -0
- package/dist/simulation/living/core/ops.d.ts +257 -0
- package/dist/simulation/living/core/ops.js +34 -0
- package/dist/simulation/living/definer.d.ts +17 -1
- package/dist/simulation/living/definer.js +130 -51
- package/dist/simulation/living/definition.d.ts +174 -65
- package/dist/simulation/living/definition.js +287 -180
- package/dist/simulation/living/director.d.ts +80 -0
- package/dist/simulation/living/director.js +363 -0
- package/dist/simulation/living/frame.d.ts +108 -21
- package/dist/simulation/living/frame.js +111 -66
- package/dist/simulation/living/identifiers.d.ts +0 -1
- package/dist/simulation/living/identifiers.js +0 -3
- package/dist/simulation/living/index.d.ts +18 -9
- package/dist/simulation/living/index.js +18 -9
- package/dist/simulation/living/inference.d.ts +92 -50
- package/dist/simulation/living/inference.js +319 -175
- package/dist/simulation/living/knowledge.d.ts +28 -0
- package/dist/simulation/living/knowledge.js +73 -0
- package/dist/simulation/living/library.json +1177 -0
- package/dist/simulation/living/mechanics.d.ts +31 -34
- package/dist/simulation/living/mechanics.js +222 -138
- package/dist/simulation/living/model-input.d.ts +6 -3
- package/dist/simulation/living/model-input.js +18 -26
- package/dist/simulation/living/open-world.d.ts +74 -94
- package/dist/simulation/living/open-world.js +151 -30
- package/dist/simulation/living/phrases.d.ts +3 -0
- package/dist/simulation/living/phrases.js +37 -0
- package/dist/simulation/living/phrases.json +560 -0
- package/dist/simulation/living/projection.d.ts +316 -2
- package/dist/simulation/living/projection.js +50 -2
- package/dist/simulation/living/prompts/example-spec.json +11 -0
- package/dist/simulation/living/prompts/role-text.json +14 -0
- package/dist/simulation/living/prompts.d.ts +5 -0
- package/dist/simulation/living/prompts.js +275 -0
- package/dist/simulation/living/recall.d.ts +2 -2
- package/dist/simulation/living/reduce.d.ts +51 -14
- package/dist/simulation/living/reduce.js +941 -579
- package/dist/simulation/living/replay.d.ts +5 -4
- package/dist/simulation/living/replay.js +10 -9
- package/dist/simulation/living/runtime.d.ts +135 -25
- package/dist/simulation/living/runtime.js +1641 -583
- package/dist/simulation/living/scale.d.ts +96 -0
- package/dist/simulation/living/scale.js +124 -0
- package/dist/simulation/living/script.d.ts +5 -0
- package/dist/simulation/living/script.js +115 -0
- package/dist/simulation/living/shared-kinds.d.ts +4 -11
- package/dist/simulation/living/shared-kinds.js +11 -81
- package/dist/simulation/living/space.d.ts +14 -0
- package/dist/simulation/living/space.js +132 -0
- package/dist/simulation/living/state.d.ts +100 -0
- package/dist/simulation/living/state.js +393 -0
- package/dist/simulation/living/types.d.ts +829 -512
- package/dist/simulation/living/types.js +162 -187
- package/dist/simulation/living/world-rules.d.ts +100 -0
- package/dist/simulation/living/world-rules.js +267 -0
- package/dist/simulation/plugins/loader.js +11 -0
- package/dist/skills/loader.js +4 -0
- package/dist/tools.d.ts +1 -0
- package/dist/tools.js +1 -0
- package/dist/ui/ratatui/headless_pane_manager.d.ts +4 -1
- package/dist/ui/ratatui/headless_pane_manager.js +13 -9
- package/dist/ui/ratatui/pane_relay.js +29 -0
- package/dist/ui/ratatui/pane_type.d.ts +10 -0
- package/dist/ui/ratatui/pane_type.js +11 -0
- package/dist/ui/ratatui/process.d.ts +30 -0
- package/dist/ui/ratatui/process.js +133 -19
- package/dist/ui/ratatui/protocol.d.ts +124 -2
- package/dist/ui/ratatui/protocol.js +35 -0
- package/dist/ui/ratatui/relay_policy.js +3 -0
- package/dist/ui/ratatui/ztc_launch_trust.d.ts +2 -1
- package/dist/ui/ratatui/ztc_launch_trust.js +8 -1
- package/dist/ui/terminal_image.d.ts +12 -0
- package/dist/ui/terminal_image.js +21 -1
- package/dist/utils/codex_project_trust.d.ts +19 -0
- package/dist/utils/codex_project_trust.js +37 -0
- package/dist/utils/compaction.js +103 -20
- package/dist/utils/git_program_files.d.ts +19 -12
- package/dist/utils/git_program_files.js +411 -83
- package/dist/utils/host_shell.d.ts +10 -1
- package/dist/utils/host_shell.js +14 -1
- package/dist/utils/mid_turn_compaction.d.ts +2 -0
- package/dist/utils/mid_turn_compaction.js +2 -0
- package/dist/utils/models.js +6 -1
- package/dist/utils/sandbox.d.ts +109 -8
- package/dist/utils/sandbox.js +981 -187
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.js +10 -4
- package/dist/utils/subprocess_env.d.ts +47 -11
- package/dist/utils/subprocess_env.js +107 -15
- package/dist/utils/system_ps.d.ts +8 -0
- package/dist/utils/system_ps.js +39 -7
- package/dist/utils/unattended_compaction.d.ts +9 -0
- package/dist/utils/unattended_compaction.js +13 -0
- package/dist/utils/ztc_own_state.d.ts +8 -5
- package/dist/utils/ztc_own_state.js +17 -11
- package/dist/web/mirror_client.js +1 -0
- package/dist/web/mirror_stream.d.ts +50 -6
- package/dist/web/mirror_stream.js +160 -15
- package/dist/workflows/registry.js +3 -1
- package/dist/workspace/controller.js +12 -0
- package/dist/workspace_collision.d.ts +3 -0
- package/dist/workspace_collision.js +14 -1
- package/dist/workspace_session_context.js +2 -1
- package/dist/zlm-embed.mjs +3823 -1970
- package/node_modules/@zerg/model-contracts/README.md +16 -4
- package/node_modules/@zerg/model-contracts/index.js +6 -1
- package/npm-shrinkwrap.json +1 -1
- package/package.json +42 -24
- package/packages/model-contracts/README.md +16 -4
- 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
|
|
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.
|
package/dist/utils/host_shell.js
CHANGED
|
@@ -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:
|
|
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;
|
package/dist/utils/models.js
CHANGED
|
@@ -498,7 +498,12 @@ export async function listModels(options) {
|
|
|
498
498
|
return parseList(res);
|
|
499
499
|
}
|
|
500
500
|
if (provider === 'gemini') {
|
|
501
|
-
|
|
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
|
}
|
package/dist/utils/sandbox.d.ts
CHANGED
|
@@ -61,9 +61,89 @@ export interface SandboxBackendStatus {
|
|
|
61
61
|
notes: string[];
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
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
|
|
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),
|
|
147
|
-
*
|
|
148
|
-
*
|
|
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;
|