@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
|
@@ -337,8 +337,8 @@ export const InputArea = ({ onSubmit, onCancelRun, isRunning = false, onQueue, o
|
|
|
337
337
|
const parts = plainText.slice(1).split(/\s+/);
|
|
338
338
|
const cmd = parts[0].toLowerCase();
|
|
339
339
|
const args = parts.slice(1);
|
|
340
|
-
// Handle /
|
|
341
|
-
if (cmd === '
|
|
340
|
+
// Handle /paste-image directly - intercept before passing to onCommand (/pi is Pi's)
|
|
341
|
+
if (cmd === 'paste-image') {
|
|
342
342
|
dispatch({ type: 'submit', historyEnabled, historyEntry: serialized });
|
|
343
343
|
if (handleClipboardImagePasteRef.current) {
|
|
344
344
|
void handleClipboardImagePasteRef.current('state');
|
|
@@ -1324,8 +1324,8 @@ export const InputArea = ({ onSubmit, onCancelRun, isRunning = false, onQueue, o
|
|
|
1324
1324
|
const parts = plainText.slice(1).split(/\s+/);
|
|
1325
1325
|
const cmd = parts[0].toLowerCase();
|
|
1326
1326
|
const args = parts.slice(1);
|
|
1327
|
-
// Handle /
|
|
1328
|
-
if (cmd === '
|
|
1327
|
+
// Handle /paste-image directly (/pi is Pi's)
|
|
1328
|
+
if (cmd === 'paste-image') {
|
|
1329
1329
|
overlayStateRef.current = recordInputHistory(current, historyEnabled ? serialized : undefined, 101);
|
|
1330
1330
|
renderOverlay(overlayStateRef.current);
|
|
1331
1331
|
void handleClipboardImagePaste('overlay');
|
|
@@ -9,6 +9,16 @@ export interface ExecutionSettings {
|
|
|
9
9
|
recovery?: 'automatic' | 'pause';
|
|
10
10
|
repeatedFailureLimit?: number;
|
|
11
11
|
recoveryAttempts?: number;
|
|
12
|
+
noProgressNudgeAfter?: number;
|
|
13
|
+
noProgressStopAfter?: number;
|
|
14
|
+
commandRepeatLimit?: number;
|
|
15
|
+
commandRepeatLongRunningMs?: number;
|
|
16
|
+
runawayEscalations?: number;
|
|
17
|
+
endProtocolNudges?: number;
|
|
18
|
+
endProtocolTotalNudges?: number;
|
|
19
|
+
longSessionCompactAfter?: number;
|
|
20
|
+
/** The share of the model's window at which an unattended run compacts; 100 leaves it to the ordinary trigger. */
|
|
21
|
+
unattendedCompactPercent?: number;
|
|
12
22
|
interruptBackgroundJobs?: boolean;
|
|
13
23
|
maxBackgroundJobs?: number;
|
|
14
24
|
}
|
package/dist/config/execution.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_UNATTENDED_COMPACT_PERCENT } from '../utils/unattended_compaction.js';
|
|
1
2
|
export function resolveExecutionSettings(settings = {}) {
|
|
2
3
|
const count = (value, fallback, max, min = 1) => Number.isSafeInteger(value) && value >= min && value <= max ? value : fallback;
|
|
3
4
|
const maxCallsPerResponse = count(settings.maxCallsPerResponse, 64, 256);
|
|
@@ -9,6 +10,15 @@ export function resolveExecutionSettings(settings = {}) {
|
|
|
9
10
|
recovery: settings.recovery === 'pause' ? 'pause' : 'automatic',
|
|
10
11
|
repeatedFailureLimit: count(settings.repeatedFailureLimit, 3, 20),
|
|
11
12
|
recoveryAttempts: count(settings.recoveryAttempts, 1, 5, 0),
|
|
13
|
+
noProgressNudgeAfter: count(settings.noProgressNudgeAfter, 40, 1000),
|
|
14
|
+
noProgressStopAfter: count(settings.noProgressStopAfter, 20, 1000),
|
|
15
|
+
commandRepeatLimit: count(settings.commandRepeatLimit, 2, 20),
|
|
16
|
+
commandRepeatLongRunningMs: count(settings.commandRepeatLongRunningMs, 60_000, 3_600_000),
|
|
17
|
+
runawayEscalations: count(settings.runawayEscalations, 1, 10, 0),
|
|
18
|
+
endProtocolNudges: count(settings.endProtocolNudges, 3, 20, 0),
|
|
19
|
+
endProtocolTotalNudges: count(settings.endProtocolTotalNudges, 12, 100, 0),
|
|
20
|
+
longSessionCompactAfter: count(settings.longSessionCompactAfter, 150, 10_000),
|
|
21
|
+
unattendedCompactPercent: count(settings.unattendedCompactPercent, DEFAULT_UNATTENDED_COMPACT_PERCENT, 100),
|
|
12
22
|
interruptBackgroundJobs: settings.interruptBackgroundJobs === true,
|
|
13
23
|
maxBackgroundJobs: count(settings.maxBackgroundJobs, 4, 32),
|
|
14
24
|
};
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* rest of the host's (agent/backends/codex_app_server.ts buildCodexAppServerEnv and codexPaneEnv); what a headless start
|
|
5
5
|
* its host runs (ZTC_HOSTED=1) says as it refuses a permission profile that runs the agent's commands without requiring an
|
|
6
6
|
* OS sandbox, or that lets them write wherever the agent runs them (cli_main.ts, headless_cli.ts); and what such a run
|
|
7
|
-
* says as it refuses, with no one to ask, a call that starts a program outside the sandbox (headless.ts).
|
|
7
|
+
* says as it refuses, with no one to ask, a call that starts a program outside the sandbox (headless.ts). Where ZTC runs
|
|
8
|
+
* as its host's (hostedOrPinnedRuntime), no program it starts that is not a ZTC is given a ZergAI platform or Zerg Router
|
|
9
|
+
* bearer either (utils/subprocess_env.ts platformRouterBearersWithheld, which imports this module; this module imports
|
|
10
|
+
* only config/permission_pin.ts, which imports only ZTC's types, so there is no cycle).
|
|
8
11
|
*
|
|
9
12
|
* Self-contained (no config store), as config/permission_pin.ts and config/model_pin.ts are: config.ts gives its
|
|
10
13
|
* ConfigStore's view of the session (followHostedSession), and the backends read it without importing the store.
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* rest of the host's (agent/backends/codex_app_server.ts buildCodexAppServerEnv and codexPaneEnv); what a headless start
|
|
5
5
|
* its host runs (ZTC_HOSTED=1) says as it refuses a permission profile that runs the agent's commands without requiring an
|
|
6
6
|
* OS sandbox, or that lets them write wherever the agent runs them (cli_main.ts, headless_cli.ts); and what such a run
|
|
7
|
-
* says as it refuses, with no one to ask, a call that starts a program outside the sandbox (headless.ts).
|
|
7
|
+
* says as it refuses, with no one to ask, a call that starts a program outside the sandbox (headless.ts). Where ZTC runs
|
|
8
|
+
* as its host's (hostedOrPinnedRuntime), no program it starts that is not a ZTC is given a ZergAI platform or Zerg Router
|
|
9
|
+
* bearer either (utils/subprocess_env.ts platformRouterBearersWithheld, which imports this module; this module imports
|
|
10
|
+
* only config/permission_pin.ts, which imports only ZTC's types, so there is no cycle).
|
|
8
11
|
*
|
|
9
12
|
* Self-contained (no config store), as config/permission_pin.ts and config/model_pin.ts are: config.ts gives its
|
|
10
13
|
* ConfigStore's view of the session (followHostedSession), and the backends read it without importing the store.
|
|
@@ -76,6 +76,38 @@ export declare function pinnedSelfUpdateMessage(): string;
|
|
|
76
76
|
* (a language server, run_and_capture's command), and only a real approver decides one there (headless.ts).
|
|
77
77
|
*/
|
|
78
78
|
export declare function pinnedOutsideSandboxApprovalRefusal(tool: string): string;
|
|
79
|
+
/** Read whether this process's session is pinned by its host from READ (config.ts gives its ConfigStore's). */
|
|
80
|
+
export declare function followPermissionPin(read: () => boolean): void;
|
|
81
|
+
/**
|
|
82
|
+
* What a program of the person's, or of a mirror's controller, that ZTC would start outside the OS sandbox says under the
|
|
83
|
+
* pin, where it isn't started: LEAD (what wasn't, "No Shannon runner was started"), WHAT would run outside the sandbox,
|
|
84
|
+
* and what to do INSTEAD. Under the pin the person's commands run only inside it (config/person_command_policy.ts);
|
|
85
|
+
* these ran outside any, where they could write the config.json the pin is taken from (the bearers' follow-up review:
|
|
86
|
+
* /shannon-runner start, /zerg launch, an /embedded or /bench workspace's programs, /layout run, /batch's git and a
|
|
87
|
+
* workspace's isolation, which run the work tree's hooks and filters, and a controller's shell and command panes).
|
|
88
|
+
*/
|
|
89
|
+
export declare function pinnedPersonProgramMessage(lead: string, what: string, instead: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Why a program of the person's, or a mirror controller's, isn't started outside the OS sandbox (pinnedPersonProgramMessage),
|
|
92
|
+
* or undefined where it may start: without the pin. Each place ZTC starts one asks it first
|
|
93
|
+
* (tests/unit/person_command_policy_lint.test.ts).
|
|
94
|
+
*/
|
|
95
|
+
export declare function personProgramRefusal(lead: string, what: string, instead: string): string | undefined;
|
|
96
|
+
/** What runs the person's command inside the OS sandbox where, under the pin, a pane's program would run outside it. */
|
|
97
|
+
export declare const PINNED_PANE_INSTEAD = "Use !cmd, which runs your command inside the sandbox.";
|
|
98
|
+
/** What a refusal to type into a pane that is no shell's or command's says instead: the panes that are typed into. */
|
|
99
|
+
export declare const PINNED_TYPING_ELSEWHERE = "A ZTC pane, a colony cell, and a Claude Code or Codex pane are still typed into.";
|
|
100
|
+
/**
|
|
101
|
+
* Why what a mirror's controller types isn't typed into a pane of PANE_TYPE, or undefined where it may be: under its
|
|
102
|
+
* host's pin the person's commands run only inside the OS sandbox, and a pane that runs no ZTC (a shell's, a command's,
|
|
103
|
+
* one ZTC doesn't know) would run what it is typed outside it. A ZTC pane (ztc, colony_ztc) takes it as its agent's
|
|
104
|
+
* prompt; a Claude Code or Codex pane (ASKS_BEFORE_EACH_COMMAND, which zmux and a resident's pane manager alike say a pane
|
|
105
|
+
* /claude or /codex opened is) asks before each of its commands under the pin (panes/agent_panes.ts), a limit the docs
|
|
106
|
+
* name. Without the pin, none is refused. A shell's or a command's pane (process, command) would run what it is typed as
|
|
107
|
+
* a command, so its refusal says to use !cmd, which runs one inside the sandbox; any other (one ZTC doesn't know, a
|
|
108
|
+
* document, a feed) runs no command of the person's to move there, so its refusal names the panes that are typed into.
|
|
109
|
+
*/
|
|
110
|
+
export declare function pinnedPaneTypingRefusal(paneType: string | undefined, asksBeforeEachCommand: boolean): string | undefined;
|
|
79
111
|
/** What a refused config-profile switch says: NAME would hold other permission settings; the session stays on CURRENT. */
|
|
80
112
|
export declare function pinnedPermissionsSwitchMessage(name: string, current: string): string;
|
|
81
113
|
/**
|
|
@@ -174,8 +206,8 @@ export interface PinnedOwnStateInRoot {
|
|
|
174
206
|
* write (INSIDE: what names each, where it is, and the root that holds it): a command there could rename a folder above
|
|
175
207
|
* it and carry it off under another name, forging the config.json the pin is taken from (which a cold start pins) or
|
|
176
208
|
* reading a credential ZTC hands over (the reviewer's follow-up review, N2 and N3). Own state may be a root of its own, or
|
|
177
|
-
* a folder directly in one that is no link,
|
|
178
|
-
* says what to do instead.
|
|
209
|
+
* a folder directly in one that is no link, where no folder lies between it and the root to rename away with it, though
|
|
210
|
+
* that doesn't keep it from every command (ztcOwnStateInRoots); TMPDIR may be neither. It says what to do instead.
|
|
179
211
|
*/
|
|
180
212
|
export declare function pinnedOwnStateInRootsMessage(profileId: string, inside: readonly PinnedOwnStateInRoot[]): string;
|
|
181
213
|
/**
|
|
@@ -100,6 +100,56 @@ export function pinnedOutsideSandboxApprovalRefusal(tool) {
|
|
|
100
100
|
+ `its host pins this session's permission profile and sandbox (${PERMISSION_PIN_ENV}). Give the run an approval service `
|
|
101
101
|
+ '(--approval-url or ZTC_APPROVAL_URL) to decide it, or use run_command, which runs inside the sandbox.';
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* What says whether this process's session is pinned: config.ts gives its ConfigStore's (permissionsPinned), as
|
|
105
|
+
* config/hosted_runtime.ts is given its view of the session, so a module that starts programs reads it without
|
|
106
|
+
* importing the store. Nothing for ZTC used as a library that never loads a profile, which pins nothing.
|
|
107
|
+
*/
|
|
108
|
+
let sessionPinned = () => false;
|
|
109
|
+
/** Read whether this process's session is pinned by its host from READ (config.ts gives its ConfigStore's). */
|
|
110
|
+
export function followPermissionPin(read) {
|
|
111
|
+
sessionPinned = read;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* What a program of the person's, or of a mirror's controller, that ZTC would start outside the OS sandbox says under the
|
|
115
|
+
* pin, where it isn't started: LEAD (what wasn't, "No Shannon runner was started"), WHAT would run outside the sandbox,
|
|
116
|
+
* and what to do INSTEAD. Under the pin the person's commands run only inside it (config/person_command_policy.ts);
|
|
117
|
+
* these ran outside any, where they could write the config.json the pin is taken from (the bearers' follow-up review:
|
|
118
|
+
* /shannon-runner start, /zerg launch, an /embedded or /bench workspace's programs, /layout run, /batch's git and a
|
|
119
|
+
* workspace's isolation, which run the work tree's hooks and filters, and a controller's shell and command panes).
|
|
120
|
+
*/
|
|
121
|
+
export function pinnedPersonProgramMessage(lead, what, instead) {
|
|
122
|
+
return `${lead}: ${what} would run outside the OS sandbox, and ZTC runs none of your programs outside it while its host pins `
|
|
123
|
+
+ `this session's permission profile and sandbox (${PERMISSION_PIN_ENV}). ${instead}`;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Why a program of the person's, or a mirror controller's, isn't started outside the OS sandbox (pinnedPersonProgramMessage),
|
|
127
|
+
* or undefined where it may start: without the pin. Each place ZTC starts one asks it first
|
|
128
|
+
* (tests/unit/person_command_policy_lint.test.ts).
|
|
129
|
+
*/
|
|
130
|
+
export function personProgramRefusal(lead, what, instead) {
|
|
131
|
+
return sessionPinned() ? pinnedPersonProgramMessage(lead, what, instead) : undefined;
|
|
132
|
+
}
|
|
133
|
+
/** What runs the person's command inside the OS sandbox where, under the pin, a pane's program would run outside it. */
|
|
134
|
+
export const PINNED_PANE_INSTEAD = 'Use !cmd, which runs your command inside the sandbox.';
|
|
135
|
+
/** What a refusal to type into a pane that is no shell's or command's says instead: the panes that are typed into. */
|
|
136
|
+
export const PINNED_TYPING_ELSEWHERE = 'A ZTC pane, a colony cell, and a Claude Code or Codex pane are still typed into.';
|
|
137
|
+
/**
|
|
138
|
+
* Why what a mirror's controller types isn't typed into a pane of PANE_TYPE, or undefined where it may be: under its
|
|
139
|
+
* host's pin the person's commands run only inside the OS sandbox, and a pane that runs no ZTC (a shell's, a command's,
|
|
140
|
+
* one ZTC doesn't know) would run what it is typed outside it. A ZTC pane (ztc, colony_ztc) takes it as its agent's
|
|
141
|
+
* prompt; a Claude Code or Codex pane (ASKS_BEFORE_EACH_COMMAND, which zmux and a resident's pane manager alike say a pane
|
|
142
|
+
* /claude or /codex opened is) asks before each of its commands under the pin (panes/agent_panes.ts), a limit the docs
|
|
143
|
+
* name. Without the pin, none is refused. A shell's or a command's pane (process, command) would run what it is typed as
|
|
144
|
+
* a command, so its refusal says to use !cmd, which runs one inside the sandbox; any other (one ZTC doesn't know, a
|
|
145
|
+
* document, a feed) runs no command of the person's to move there, so its refusal names the panes that are typed into.
|
|
146
|
+
*/
|
|
147
|
+
export function pinnedPaneTypingRefusal(paneType, asksBeforeEachCommand) {
|
|
148
|
+
if (paneType === 'ztc' || paneType === 'colony_ztc' || asksBeforeEachCommand)
|
|
149
|
+
return undefined;
|
|
150
|
+
const terminal = paneType === 'process' || paneType === 'command';
|
|
151
|
+
return personProgramRefusal('Nothing was typed into the pane', 'what it runs', terminal ? PINNED_PANE_INSTEAD : PINNED_TYPING_ELSEWHERE);
|
|
152
|
+
}
|
|
103
153
|
/** What a refused config-profile switch says: NAME would hold other permission settings; the session stays on CURRENT. */
|
|
104
154
|
export function pinnedPermissionsSwitchMessage(name, current) {
|
|
105
155
|
return `Config profile "${name}" holds another permission profile, sandbox or tool permissions than this session. `
|
|
@@ -228,8 +278,8 @@ export class PermissionPinUnlimitedError extends Error {
|
|
|
228
278
|
* write (INSIDE: what names each, where it is, and the root that holds it): a command there could rename a folder above
|
|
229
279
|
* it and carry it off under another name, forging the config.json the pin is taken from (which a cold start pins) or
|
|
230
280
|
* reading a credential ZTC hands over (the reviewer's follow-up review, N2 and N3). Own state may be a root of its own, or
|
|
231
|
-
* a folder directly in one that is no link,
|
|
232
|
-
* says what to do instead.
|
|
281
|
+
* a folder directly in one that is no link, where no folder lies between it and the root to rename away with it, though
|
|
282
|
+
* that doesn't keep it from every command (ztcOwnStateInRoots); TMPDIR may be neither. It says what to do instead.
|
|
233
283
|
*/
|
|
234
284
|
export function pinnedOwnStateInRootsMessage(profileId, inside) {
|
|
235
285
|
const listed = inside.map(({ name, path, root, itself }) => (itself ? `${name} (${path}), a root itself` : `${name} (${path}) inside ${root}`))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a command the person starts is planned: under the permission profile and sandbox settings the session holds, and,
|
|
3
|
+
* under its host's pin of them (ZTC_PERMISSION_PROFILE_PINNED, config/permission_pin.ts), with the OS sandbox required
|
|
4
|
+
* (requireOsEnforcement), so it runs inside it or not at all, as the agent's do. A pinned profile that runs none of the
|
|
5
|
+
* agent's commands needs no OS sandbox for them, and the person's ran outside any, where they wrote the config folder the
|
|
6
|
+
* pin is taken from (the recheck of the follow-ups, 2026-11-23, FU-D). Without the pin, the session's settings as they are.
|
|
7
|
+
* A ztc such a command starts is the person's, and saves their settings and signs them in and out as one they start in a
|
|
8
|
+
* terminal does: no nested run of this ZTC, as one its agent's command starts is (byPerson; config/profiles.ts nestedRunEnv).
|
|
9
|
+
*
|
|
10
|
+
* Every place a command of the person's is planned takes it (tests/unit/person_command_policy_lint.test.ts): !cmd and
|
|
11
|
+
* /shell, from the terminal or a mirror's controller, /diff's git and /optimize's commands (app/command_context.ts
|
|
12
|
+
* buildShellController), the Ink interface's shell (App.tsx), a /job command pane's (cli_ratatui.ts ensureCommandPanes)
|
|
13
|
+
* and an /environment service's (agent/commands/environment.ts).
|
|
14
|
+
*
|
|
15
|
+
* A program of the person's that ZTC starts by any other way runs outside any sandbox, so under the pin it isn't started
|
|
16
|
+
* at all (config/permission_pin.ts personProgramRefusal): /shannon-runner start, /zerg launch, an /embedded or /bench
|
|
17
|
+
* workspace, /layout run, /batch and a workspace's isolation, and the shell and command panes the person or a mirror's
|
|
18
|
+
* controller opens, restarts or types into. The lint's second row finds every program ZTC starts, and checks each of those
|
|
19
|
+
* asks it first.
|
|
20
|
+
*
|
|
21
|
+
* Self-contained (types only), so each of those can take it.
|
|
22
|
+
*/
|
|
23
|
+
import type { ZTCConfig, ZTCPermissionProfile, ZTCSandboxSettings } from './types.js';
|
|
24
|
+
/** What a person's command is planned from: the session's settings, its effective profile, and whether its host pinned them. */
|
|
25
|
+
export interface PersonCommandSettings {
|
|
26
|
+
get(): Pick<ZTCConfig, 'permissionProfile' | 'sandbox'>;
|
|
27
|
+
getEffectivePermissionProfile(id?: string): ZTCPermissionProfile | undefined;
|
|
28
|
+
permissionsPinned(): boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The permission profile and sandbox settings a command the person starts is planned with, and that it is theirs. */
|
|
31
|
+
export interface PersonCommandPolicy {
|
|
32
|
+
profileId: string;
|
|
33
|
+
profile: ZTCPermissionProfile | undefined;
|
|
34
|
+
sandbox: ZTCSandboxSettings | undefined;
|
|
35
|
+
byPerson: true;
|
|
36
|
+
}
|
|
37
|
+
/** The policy a command the person starts is planned with, from SETTINGS (the config store): see the module's comment. */
|
|
38
|
+
export declare function personCommandPolicy(settings: PersonCommandSettings): PersonCommandPolicy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The policy a command the person starts is planned with, from SETTINGS (the config store): see the module's comment. */
|
|
2
|
+
export function personCommandPolicy(settings) {
|
|
3
|
+
const config = settings.get();
|
|
4
|
+
const profileId = config.permissionProfile || 'trusted';
|
|
5
|
+
return {
|
|
6
|
+
profileId,
|
|
7
|
+
profile: settings.getEffectivePermissionProfile(profileId),
|
|
8
|
+
sandbox: settings.permissionsPinned() ? { ...config.sandbox, requireOsEnforcement: true } : config.sandbox,
|
|
9
|
+
byPerson: true,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -3,6 +3,27 @@ export declare function builtinProfileEmulation(name: string): string | undefine
|
|
|
3
3
|
export declare function validateProfileName(name: string): string;
|
|
4
4
|
export declare function activeProfile(): string;
|
|
5
5
|
export declare function profileConfigDir(profile?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* The marker of a nested run: what a ZTC sets in the environment of what its agent's tools start (a shell command, a ZTC
|
|
8
|
+
* pane, never a command the person starts or a pane they open). The settings file it owns (ZTC_NESTED_RUN) and which process it is
|
|
9
|
+
* (ZTC_NESTED_RUN_BY: its pid and when it started), so a ZTC started there leaves that file as it is while it runs
|
|
10
|
+
* (sharesParentSettings). A nested run passes its own marker on: what it starts leaves the same ZTC's settings.
|
|
11
|
+
*/
|
|
12
|
+
export declare function nestedRunEnv(): Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Whether this ZTC is a nested run on its parent's own settings file, which then stays that ZTC's to write: it saves no
|
|
15
|
+
* settings, resets nothing and signs neither in nor out. The marker is two variables, which anything that starts ZTC can
|
|
16
|
+
* set: a project's dev environment, or a terminal multiplexer or an editor that an agent's command started and that
|
|
17
|
+
* outlived it. So it counts only where it names this settings file and a process that is running, by its pid and when
|
|
18
|
+
* it started: one left behind once that process is gone is nobody's, and what it would have refused, the person's
|
|
19
|
+
* settings, their reset and their sign-out, goes ahead. It is a convenience against a ZTC an agent starts writing the
|
|
20
|
+
* person's settings by accident, not a security boundary. Any process's pid and start time are anyone's to read (ps),
|
|
21
|
+
* and the process need not be a ZTC, so an environment set so on purpose, a project's among them, can name one (pid 1,
|
|
22
|
+
* say) and this ZTC then refuses to save its settings, reset them, sign in and sign out, saying so each time, and writes
|
|
23
|
+
* no migration of them; it does nothing else on the marker's account. Unsetting ZTC_NESTED_RUN and ZTC_NESTED_RUN_BY
|
|
24
|
+
* clears it. A nested run gains nothing by the marker: all it does is refuse.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sharesParentSettings(): boolean;
|
|
6
27
|
/** Profiles live beside the default config. Listing never creates or changes one. */
|
|
7
28
|
export declare function listConfigProfiles(): Promise<string[]>;
|
|
8
29
|
/** Replace a launch's original --profile with the profile selected in this process. */
|
package/dist/config/profiles.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
4
4
|
import { readdir } from 'node:fs/promises';
|
|
5
|
+
import { processStart } from '../utils/system_ps.js';
|
|
5
6
|
export const BUILTIN_CONFIG_PROFILES = ['ztc', 'ztc-coder', 'ztc-datascience', 'scientist'];
|
|
6
7
|
export function builtinProfileEmulation(name) {
|
|
7
8
|
const builtin = BUILTIN_CONFIG_PROFILES.find(profile => profile === name);
|
|
@@ -32,6 +33,59 @@ export function profileConfigDir(profile = activeProfile()) {
|
|
|
32
33
|
// explicitly created directory with the same name instead of hiding its data.
|
|
33
34
|
return builtinProfileEmulation(name) ? root : namedDir;
|
|
34
35
|
}
|
|
36
|
+
/** The same text for one settings file in every process, whatever path or link names it. */
|
|
37
|
+
function settingsFileIdentity(path) {
|
|
38
|
+
const absolute = resolve(path);
|
|
39
|
+
try {
|
|
40
|
+
return realpathSync(absolute);
|
|
41
|
+
}
|
|
42
|
+
catch { /* not saved yet */ }
|
|
43
|
+
try {
|
|
44
|
+
return join(realpathSync(dirname(absolute)), basename(absolute));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return absolute;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** The settings file this ZTC loads and saves. */
|
|
51
|
+
function ownSettingsFile() {
|
|
52
|
+
return settingsFileIdentity(join(profileConfigDir(), 'config.json'));
|
|
53
|
+
}
|
|
54
|
+
/** When this process started (processStart), read once. */
|
|
55
|
+
let ownStart;
|
|
56
|
+
/**
|
|
57
|
+
* The marker of a nested run: what a ZTC sets in the environment of what its agent's tools start (a shell command, a ZTC
|
|
58
|
+
* pane, never a command the person starts or a pane they open). The settings file it owns (ZTC_NESTED_RUN) and which process it is
|
|
59
|
+
* (ZTC_NESTED_RUN_BY: its pid and when it started), so a ZTC started there leaves that file as it is while it runs
|
|
60
|
+
* (sharesParentSettings). A nested run passes its own marker on: what it starts leaves the same ZTC's settings.
|
|
61
|
+
*/
|
|
62
|
+
export function nestedRunEnv() {
|
|
63
|
+
if (sharesParentSettings())
|
|
64
|
+
return { ZTC_NESTED_RUN: process.env.ZTC_NESTED_RUN, ZTC_NESTED_RUN_BY: process.env.ZTC_NESTED_RUN_BY };
|
|
65
|
+
if (ownStart === undefined)
|
|
66
|
+
ownStart = processStart(process.pid);
|
|
67
|
+
return { ZTC_NESTED_RUN: ownSettingsFile(), ...(ownStart === null ? {} : { ZTC_NESTED_RUN_BY: `${process.pid}@${ownStart}` }) };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether this ZTC is a nested run on its parent's own settings file, which then stays that ZTC's to write: it saves no
|
|
71
|
+
* settings, resets nothing and signs neither in nor out. The marker is two variables, which anything that starts ZTC can
|
|
72
|
+
* set: a project's dev environment, or a terminal multiplexer or an editor that an agent's command started and that
|
|
73
|
+
* outlived it. So it counts only where it names this settings file and a process that is running, by its pid and when
|
|
74
|
+
* it started: one left behind once that process is gone is nobody's, and what it would have refused, the person's
|
|
75
|
+
* settings, their reset and their sign-out, goes ahead. It is a convenience against a ZTC an agent starts writing the
|
|
76
|
+
* person's settings by accident, not a security boundary. Any process's pid and start time are anyone's to read (ps),
|
|
77
|
+
* and the process need not be a ZTC, so an environment set so on purpose, a project's among them, can name one (pid 1,
|
|
78
|
+
* say) and this ZTC then refuses to save its settings, reset them, sign in and sign out, saying so each time, and writes
|
|
79
|
+
* no migration of them; it does nothing else on the marker's account. Unsetting ZTC_NESTED_RUN and ZTC_NESTED_RUN_BY
|
|
80
|
+
* clears it. A nested run gains nothing by the marker: all it does is refuse.
|
|
81
|
+
*/
|
|
82
|
+
export function sharesParentSettings() {
|
|
83
|
+
const settings = process.env.ZTC_NESTED_RUN;
|
|
84
|
+
const by = /^(\d{1,10})@([\w:-]{1,64})$/.exec(process.env.ZTC_NESTED_RUN_BY ?? '');
|
|
85
|
+
if (!settings || !by || Number(by[1]) === process.pid)
|
|
86
|
+
return false;
|
|
87
|
+
return settingsFileIdentity(settings) === ownSettingsFile() && processStart(Number(by[1])) === by[2];
|
|
88
|
+
}
|
|
35
89
|
/** Profiles live beside the default config. Listing never creates or changes one. */
|
|
36
90
|
export async function listConfigProfiles() {
|
|
37
91
|
const root = process.env.ZTC_CONFIG_DIR || join(homedir(), '.ztc');
|
package/dist/config/types.d.ts
CHANGED
|
@@ -596,6 +596,7 @@ export interface ZTCConfig {
|
|
|
596
596
|
voice?: VoiceSettings;
|
|
597
597
|
/** Auto-continue mode: agent continues without prompting when work appears incomplete (default: true) */
|
|
598
598
|
autoContinue?: boolean;
|
|
599
|
+
endProtocol?: boolean;
|
|
599
600
|
/**
|
|
600
601
|
* Auto-compaction trigger in `percent` mode: a share of the model's context
|
|
601
602
|
* window (default: 95). Inert while `compactionTriggerMode` is `tokens`.
|
|
@@ -778,7 +779,9 @@ export interface MCPServerConfig {
|
|
|
778
779
|
* Variables of ZTC's environment the server is started with beyond what a tool child gets
|
|
779
780
|
* (utils/subprocess_env.ts buildMcpServerEnv), as a hook's passEnv: a provider key, ZERG_AUTH_TOKEN or ZTC_API_KEY,
|
|
780
781
|
* say, which a server is otherwise started without. ZTC's own credentials and variables, and a variable holding a
|
|
781
|
-
* copy of one of its credentials, are never given
|
|
782
|
+
* copy of one of its credentials, are never given, nor, where ZTC runs as its host's or under its host's pin
|
|
783
|
+
* (ZTC_HOSTED, a host's thread, ZTC_PERMISSION_PROFILE_PINNED), a ZergAI platform or Zerg Router bearer
|
|
784
|
+
* (ZERG_AUTH_TOKEN, ZERG_API_TOKEN, ...) or a copy of one; the server's startup diagnostics say so. A list of variable
|
|
782
785
|
* names; anything else keeps the server from starting.
|
|
783
786
|
*/
|
|
784
787
|
passEnv?: string[];
|
package/dist/config.js
CHANGED
|
@@ -9,7 +9,7 @@ import { homedir } from 'os';
|
|
|
9
9
|
import { randomUUID } from 'crypto';
|
|
10
10
|
import { isDeepStrictEqual } from 'util';
|
|
11
11
|
import { constants as fsConstants } from 'node:fs';
|
|
12
|
-
import { activeProfile, builtinProfileEmulation, listConfigProfiles, profileConfigDir, validateProfileName } from './config/profiles.js';
|
|
12
|
+
import { activeProfile, builtinProfileEmulation, listConfigProfiles, profileConfigDir, sharesParentSettings, validateProfileName } from './config/profiles.js';
|
|
13
13
|
import { agentRunsCommands, agentRunsCommandsUnsandboxed, profileLimitsAgent } from './config/profile_limits.js';
|
|
14
14
|
import { isSettingsGroup, mergeSettingEntries, mergeSettingValue } from './config/settings_merge.js';
|
|
15
15
|
import { accountSourceToBackendOptions, canonicalAccountProvider, probeAccountIsolated, resolveActiveAccount, } from './agent/backends/account_pool.js';
|
|
@@ -27,7 +27,7 @@ import { CODEX_APP_SERVER_SENTINEL, CODEX_LEGACY_PROVIDER, isCodexAppServerProvi
|
|
|
27
27
|
import { requiredRouterModel } from './config/router_required.js';
|
|
28
28
|
import { holdPinnedRoute, isPinnedRoute, modelPinRequested, pinnedRoute, pinnedRouteMessage, pinnedRouting, pinnedRoutingRefusal, RoutePinnedError, routeChangeError, routeChangeRefusal } from './config/model_pin.js';
|
|
29
29
|
import { hostedSettingsConfigPatch } from './hosted/session_settings.js';
|
|
30
|
-
import { PermissionPinChangedError, PermissionPinOwnStateInRootsError, permissionPinRequested, permissionPinRestartEnv, PermissionPinUnlimitedError, PermissionPinUnrootedError, PermissionsPinnedError, pinnedFactoryResetMessage, pinnedPermissionsMessage, pinnedPermissionsSwitchMessage, pinnedSelfUpdateMessage, PINNED_PERMISSION_SETTINGS, profileRootedAt, takePermissionPinSource } from './config/permission_pin.js';
|
|
30
|
+
import { followPermissionPin, PermissionPinChangedError, PermissionPinOwnStateInRootsError, permissionPinRequested, permissionPinRestartEnv, PermissionPinUnlimitedError, PermissionPinUnrootedError, PermissionsPinnedError, pinnedFactoryResetMessage, pinnedPermissionsMessage, pinnedPermissionsSwitchMessage, pinnedSelfUpdateMessage, PINNED_PERMISSION_SETTINGS, profileRootedAt, takePermissionPinSource } from './config/permission_pin.js';
|
|
31
31
|
import { commandWriteRoots, commandWriteRootsFollowCwd } from './utils/sandbox.js';
|
|
32
32
|
import { ztcOwnStateInRoots } from './utils/ztc_own_state.js';
|
|
33
33
|
import { holdsHostRouterGrant, hostClaimsRouter, hostRouterGrantFor, UNUSABLE_ROUTER_RUNTIME_GRANT_REFUSED } from './config/router_runtime_grant.js';
|
|
@@ -1101,15 +1101,16 @@ export class ConfigStore {
|
|
|
1101
1101
|
if (!retirement)
|
|
1102
1102
|
return saved;
|
|
1103
1103
|
const backup = backupText(saved, savedText);
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1104
|
+
if (!sharesParentSettings())
|
|
1105
|
+
try {
|
|
1106
|
+
await writeBackupOnce(backupPath, backup);
|
|
1107
|
+
await this.rewriteOwnSettings(() => replaceSettingsFile(configFile(), JSON.stringify(retirement.settings, null, 2)));
|
|
1108
|
+
}
|
|
1109
|
+
catch (error) {
|
|
1110
|
+
this.unsavedRetirement = { backupPath, backup };
|
|
1111
|
+
runtimeDiag('warn', `[ztc] Could not save ${configFile()} with a backup after moving it off the retired Claude Code routes `
|
|
1112
|
+
+ `(${error?.message ?? error}); the move applies to this run only.`);
|
|
1113
|
+
}
|
|
1113
1114
|
// Headless runs and pipes see the move as it happens (an interactive
|
|
1114
1115
|
// terminal keeps it for its launch notice; runtimeDiag stays quiet there).
|
|
1115
1116
|
// A move that left no route is said by the gate (app/retired_route_gate.ts),
|
|
@@ -1137,7 +1138,7 @@ export class ConfigStore {
|
|
|
1137
1138
|
const repair = repairMovedClaudeDefault(saved);
|
|
1138
1139
|
if (!repair)
|
|
1139
1140
|
return saved;
|
|
1140
|
-
if (!this.unsavedRetirement) {
|
|
1141
|
+
if (!this.unsavedRetirement && !sharesParentSettings()) {
|
|
1141
1142
|
try {
|
|
1142
1143
|
await this.rewriteOwnSettings(() => replaceSettingsFile(configFile(), JSON.stringify(repair.settings, null, 2)));
|
|
1143
1144
|
}
|
|
@@ -1605,7 +1606,8 @@ export class ConfigStore {
|
|
|
1605
1606
|
const migrated = migrateSettingsDefaults(saved);
|
|
1606
1607
|
// A failed write must not make an unmigrated profile appear migrated.
|
|
1607
1608
|
// Its backup keeps no Claude Code token either (see backupText).
|
|
1608
|
-
|
|
1609
|
+
if (!sharesParentSettings())
|
|
1610
|
+
await this.rewriteOwnSettings(() => writeMigratedSettings(configFile(), migrated, backupText(saved, savedText)));
|
|
1609
1611
|
saved = migrated;
|
|
1610
1612
|
savedText = JSON.stringify(migrated, null, 2);
|
|
1611
1613
|
}
|
|
@@ -2000,6 +2002,12 @@ export class ConfigStore {
|
|
|
2000
2002
|
this.notifyChange();
|
|
2001
2003
|
return;
|
|
2002
2004
|
}
|
|
2005
|
+
if (sharesParentSettings()) {
|
|
2006
|
+
runtimeDiag('warn', `[ztc] Settings not saved: this ZTC was started by another ZTC process, so ${configFile()} belongs to `
|
|
2007
|
+
+ 'it and stays as it is. These settings apply to this run only; change them from a top-level ZTC.');
|
|
2008
|
+
this.notifyChange();
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2003
2011
|
// After any read of another ZTC's save under way, so that read can't replace what this one writes.
|
|
2004
2012
|
await this.withSettingsLock(() => this.writeSettings());
|
|
2005
2013
|
this.notifyChange();
|
|
@@ -2070,6 +2078,10 @@ export class ConfigStore {
|
|
|
2070
2078
|
// a ZTC started again reads them from: it is refused, naming the variable, before anything is removed.
|
|
2071
2079
|
if (this.permissionPin)
|
|
2072
2080
|
throw new PermissionsPinnedError(pinnedFactoryResetMessage());
|
|
2081
|
+
if (sharesParentSettings()) {
|
|
2082
|
+
throw new Error('This ZTC was started by another ZTC process, so it cannot reset the shared configuration. '
|
|
2083
|
+
+ 'Run the reset from a top-level ZTC.');
|
|
2084
|
+
}
|
|
2073
2085
|
const kept = this.launchOverridesKeptAcrossProfiles();
|
|
2074
2086
|
if (kept.permissionProfile !== undefined) {
|
|
2075
2087
|
const id = kept.permissionProfile;
|
|
@@ -2894,12 +2906,13 @@ export class ConfigStore {
|
|
|
2894
2906
|
return [];
|
|
2895
2907
|
delete this.config.pendingNotices;
|
|
2896
2908
|
delete this.sessionOverrides.pendingNotices;
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2909
|
+
if (!sharesParentSettings())
|
|
2910
|
+
try {
|
|
2911
|
+
await this.rewriteOwnSettings(() => removeSavedSetting(configFile(), 'pendingNotices'));
|
|
2912
|
+
}
|
|
2913
|
+
catch (error) {
|
|
2914
|
+
runtimeDiag('warn', `[ztc] Could not clear shown notices from ${configFile()}: ${error?.message ?? error}`);
|
|
2915
|
+
}
|
|
2903
2916
|
const sessionRoute = this.sessionRouteNote();
|
|
2904
2917
|
return pending.map(notice => {
|
|
2905
2918
|
const [first, ...rest] = notice.text.split('\n');
|
|
@@ -4298,4 +4311,6 @@ followProfileProviderKeyEnv(() => configStore.get().apiKeyEnv);
|
|
|
4298
4311
|
// A resident on a host's thread (--session-file), and a session its host pinned, start the codex app-server with only the
|
|
4299
4312
|
// allowlisted names (config/hosted_runtime.ts hostedOrPinnedRuntime), as ZTC_HOSTED=1 does.
|
|
4300
4313
|
followHostedSession(() => configStore.isHostedSession() || configStore.permissionsPinned());
|
|
4314
|
+
// The modules that start the person's programs refuse them under the pin (config/permission_pin.ts personProgramRefusal).
|
|
4315
|
+
followPermissionPin(() => configStore.permissionsPinned());
|
|
4301
4316
|
export default configStore;
|
|
@@ -93,8 +93,13 @@ export async function runCodexExec(record, options) {
|
|
|
93
93
|
record.launch.policy.schemaId = 'fixture-count-v1';
|
|
94
94
|
record.launch.policy.schemaHash = schema.hash;
|
|
95
95
|
record.launch.policy.policyHash = policyHash(record.launch.policy);
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// The worker's folder, its work tree's root and its main checkout's root, each of which must be there. Codex runs in
|
|
97
|
+
// the folder the worker's resolves to, and recipes.ts marks each root, as given and as it resolves, and every folder
|
|
98
|
+
// above it untrusted.
|
|
99
|
+
const givenRoots = [record.launch.cwd, record.launch.worktree.repositoryRoot, dirname(record.launch.worktree.gitCommonDir)];
|
|
100
|
+
const resolvedRoots = await Promise.all(givenRoots.map(path => realpath(path)));
|
|
101
|
+
const commandRecord = { ...record, codexProjectRoots: [...resolvedRoots, ...givenRoots], codexCredentialStore: await readCodexCredentialStore(env),
|
|
102
|
+
launch: { ...record.launch, cwd: resolvedRoots[0] } };
|
|
98
103
|
const args = options.resume ? buildResumeArgv(commandRecord, options.prompt) : buildLaunchArgv(commandRecord);
|
|
99
104
|
const expectedId = options.resume ? record.identity.canonicalId : null;
|
|
100
105
|
if (!options.resume)
|
|
@@ -18,6 +18,12 @@ export interface DailyDesktopHost {
|
|
|
18
18
|
label: string;
|
|
19
19
|
}[]): Promise<string | null>;
|
|
20
20
|
input(title: string, defaultValue?: string): Promise<string | null>;
|
|
21
|
+
approve?(request: {
|
|
22
|
+
title: string;
|
|
23
|
+
paneId: number;
|
|
24
|
+
capabilities: string[];
|
|
25
|
+
approvable: boolean;
|
|
26
|
+
}): Promise<'approved' | 'denied'>;
|
|
21
27
|
track(record: NativeToolPaneRecord): void;
|
|
22
28
|
changed(): void;
|
|
23
29
|
notify(message: string): void;
|
|
@@ -34,7 +40,7 @@ export interface DailyDesktopSnapshot {
|
|
|
34
40
|
}
|
|
35
41
|
export declare function canResumeNative(record: SavedNativeRecord, lease?: LeaseView | null): boolean;
|
|
36
42
|
export declare function validateNativeResume(record: NativeToolPaneRecord, lease: LeaseView | null, resolvePolicy?: () => Promise<EffectivePolicy>): Promise<void>;
|
|
37
|
-
export declare function answerDesktopApproval(broker: ApprovalBroker, select: DailyDesktopHost['select']): Promise<void>;
|
|
43
|
+
export declare function answerDesktopApproval(broker: ApprovalBroker, select: DailyDesktopHost['select'], approve?: DailyDesktopHost['approve']): Promise<void>;
|
|
38
44
|
export declare function safeDailyMessage(error: unknown): string;
|
|
39
45
|
export declare class DesktopDaily {
|
|
40
46
|
readonly ownerId: string;
|
|
@@ -69,11 +69,19 @@ export async function validateNativeResume(record, lease, resolvePolicy) {
|
|
|
69
69
|
throw new Error('Resume policy changed');
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
export async function answerDesktopApproval(broker, select) {
|
|
72
|
+
export async function answerDesktopApproval(broker, select, approve) {
|
|
73
73
|
const approval = broker.pending[0];
|
|
74
74
|
if (!approval)
|
|
75
75
|
return;
|
|
76
|
-
const
|
|
76
|
+
const title = `Pane ${approval.childPaneId}: ${approval.capabilities.join(', ') || 'unknown'}`;
|
|
77
|
+
const answer = approve
|
|
78
|
+
? await approve({
|
|
79
|
+
title,
|
|
80
|
+
paneId: approval.childPaneId,
|
|
81
|
+
capabilities: [...approval.capabilities],
|
|
82
|
+
approvable: approval.approvable,
|
|
83
|
+
})
|
|
84
|
+
: await select(title, [{ value: 'denied', label: 'Deny' }, ...(approval.approvable ? [{ value: 'approved', label: 'Approve' }] : [])]);
|
|
77
85
|
if (broker.pending.some(item => item.requestId === approval.requestId))
|
|
78
86
|
broker.decide(approval.requestId, answer === 'approved' && approval.approvable ? 'approved' : 'denied', 'desktop_human');
|
|
79
87
|
}
|
|
@@ -969,7 +977,7 @@ export class DesktopDaily {
|
|
|
969
977
|
const approval = this.broker.pending[0];
|
|
970
978
|
if (approval && !this.dialog) {
|
|
971
979
|
this.dialog = true;
|
|
972
|
-
void answerDesktopApproval(this.broker, (title, options) => this.host.select(title, options))
|
|
980
|
+
void answerDesktopApproval(this.broker, (title, options) => this.host.select(title, options), this.host.approve ? (req) => this.host.approve(req) : undefined)
|
|
973
981
|
.catch(() => { }).finally(() => { this.dialog = false; });
|
|
974
982
|
}
|
|
975
983
|
}
|
|
@@ -3,6 +3,7 @@ import { checkoutEntry } from './profile_bootstrap.js';
|
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
import { policyHash } from './native_tool.js';
|
|
5
5
|
import { schemaRegistry } from './schema_registry.js';
|
|
6
|
+
import { untrustedProjectsConfig } from '../../utils/codex_project_trust.js';
|
|
6
7
|
const forbiddenFlags = Object.freeze(['--approve-for-me', '--dangerously-bypass-approvals-and-sandbox', '--dangerously-bypass-hook-trust']);
|
|
7
8
|
export function assertSettingsAllowed(args) {
|
|
8
9
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -51,6 +52,18 @@ function codexPrompt(record, text) {
|
|
|
51
52
|
const value = prompt(record, text);
|
|
52
53
|
return value.startsWith('-') ? ['--', value] : [value];
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* The folders a delegated Codex marks untrusted, so it loads no project-local Codex config on these marks alone, not
|
|
57
|
+
* only behind --ignore-user-config, which keeps CODEX_HOME's config.toml, and the trust it saved, out: each of ROOTS
|
|
58
|
+
* (the folder it runs in, its work tree's root and the main checkout's root, the folder above the git common dir, by
|
|
59
|
+
* which Codex looks a linked worktree's trust up) and every folder above each, under the path given and the one it
|
|
60
|
+
* resolves to, as the App Server's threads mark theirs (untrustedProjectsConfig). Codex loads the .codex/config.toml of
|
|
61
|
+
* each folder it trusts from the repository's root down to the folder it runs in, so marking the roots alone left a
|
|
62
|
+
* folder between them to what CODEX_HOME saved (codex 0.167.2).
|
|
63
|
+
*/
|
|
64
|
+
function untrustedFolders(roots) {
|
|
65
|
+
return [...new Set(roots.flatMap(root => Object.keys(untrustedProjectsConfig(root).projects)))];
|
|
66
|
+
}
|
|
54
67
|
function codexOptions(record) {
|
|
55
68
|
const launch = record.launch;
|
|
56
69
|
assertSettingsAllowed(launch.args);
|
|
@@ -64,12 +77,15 @@ function codexOptions(record) {
|
|
|
64
77
|
|| !launch.args[1].startsWith('/') || launch.policy.schemaId !== 'fixture-count-v1'
|
|
65
78
|
|| launch.policy.schemaHash !== schemaRegistry['fixture-count-v1'].hash))
|
|
66
79
|
throw new Error('Unsupported Codex settings');
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
// The adapter names the roots as given and as they resolve (codex_exec_adapter.ts); a record alone names them as given.
|
|
81
|
+
const folders = untrustedFolders(record.codexProjectRoots ?? [launch.cwd, launch.worktree.repositoryRoot, dirname(launch.worktree.gitCommonDir)]);
|
|
82
|
+
if (folders.some(path => /[\x00-\x1f\x7f-\x9f]/.test(path)))
|
|
69
83
|
throw new Error('Codex project roots must not contain control characters');
|
|
70
|
-
const projects = `projects={${
|
|
84
|
+
const projects = `projects={${folders.map(path => `${JSON.stringify(path)}={trust_level="untrusted"}`).join(',')}}`;
|
|
85
|
+
// No `-c mcp_servers={}`: Codex merges a -c table into the layers it loads, so an empty one removes no MCP server.
|
|
86
|
+
// --ignore-user-config keeps CODEX_HOME's servers out, and the project marks every .codex/config.toml's.
|
|
71
87
|
const args = ['exec', '--ignore-user-config', '--ignore-rules', '--disable', 'hooks', '--disable', 'plugins', '--disable', 'apps', '--disable', 'multi_agent',
|
|
72
|
-
'-C', launch.cwd, '-s', 'read-only', '-c', 'approval_policy="never"', '-c', '
|
|
88
|
+
'-C', launch.cwd, '-s', 'read-only', '-c', 'approval_policy="never"', '-c', 'web_search="disabled"', '-c', 'notify=[]',
|
|
73
89
|
'-c', projects, '--json', '-o', launch.policy.outputSink];
|
|
74
90
|
if (record.codexCredentialStore !== undefined)
|
|
75
91
|
args.push('-c', `cli_auth_credentials_store=${JSON.stringify(record.codexCredentialStore)}`);
|