@zergai/ztc 0.26.2-dev.202611210149 → 0.26.4-dev.202611231953
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +590 -28
- 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-tui-darwin-arm64 +0 -0
- package/bin/ztc-tui-linux-x64 +0 -0
- package/bin/zterm-darwin-arm64 +2 -2
- package/dist/App.js +18 -1
- package/dist/agent/agent.d.ts +25 -1
- package/dist/agent/agent.js +26 -1
- package/dist/agent/attached_images.d.ts +58 -0
- package/dist/agent/attached_images.js +145 -0
- package/dist/agent/backends/anthropic.d.ts +14 -0
- package/dist/agent/backends/anthropic.js +49 -2
- package/dist/agent/backends/codex_app_server.d.ts +3 -1
- package/dist/agent/backends/codex_app_server.js +9 -6
- package/dist/agent/backends/codex_auth.js +3 -0
- package/dist/agent/backends/gemini.js +3 -0
- package/dist/agent/backends/host_effort_policy.js +14 -2
- package/dist/agent/backends/http_error.d.ts +17 -0
- package/dist/agent/backends/http_error.js +50 -1
- package/dist/agent/backends/index.js +2 -1
- package/dist/agent/backends/model_redirect.d.ts +47 -0
- package/dist/agent/backends/model_redirect.js +97 -0
- package/dist/agent/backends/openai_compatible.js +5 -0
- package/dist/agent/backends/openai_responses.d.ts +9 -1
- package/dist/agent/backends/openai_responses.js +21 -12
- package/dist/agent/backends/prompt_cache.d.ts +8 -0
- package/dist/agent/backends/prompt_cache.js +10 -0
- package/dist/agent/backends/provider_ids.d.ts +1 -1
- package/dist/agent/backends/provider_ids.js +1 -1
- package/dist/agent/backends/types.d.ts +8 -0
- package/dist/agent/backends/zerg-api.js +5 -1
- package/dist/agent/backends/zrouter_stream.d.ts +75 -9
- package/dist/agent/backends/zrouter_stream.js +250 -49
- package/dist/agent/commands/config.js +51 -4
- package/dist/agent/commands/connect.js +20 -0
- package/dist/agent/commands/credential_status.js +5 -3
- package/dist/agent/commands/debug.js +3 -0
- package/dist/agent/commands/diff.js +9 -5
- package/dist/agent/commands/emulation.js +7 -1
- package/dist/agent/commands/inbox.js +4 -3
- package/dist/agent/commands/mcp.js +3 -0
- package/dist/agent/commands/models.js +20 -3
- package/dist/agent/commands/permissions.js +16 -2
- package/dist/agent/commands/provider_selection.js +13 -6
- package/dist/agent/commands/settings.js +15 -4
- package/dist/agent/commands/status.js +23 -1
- package/dist/agent/commands/types.d.ts +34 -3
- package/dist/agent/commands/update.d.ts +2 -1
- package/dist/agent/commands/update.js +8 -3
- package/dist/agent/commands/zerg.d.ts +6 -0
- package/dist/agent/commands/zerg.js +152 -28
- package/dist/agent/commands/ztc_pane.js +8 -5
- package/dist/agent/factory.js +22 -4
- package/dist/agent/request_encoder.js +11 -2
- package/dist/agent/runtime/command_jobs.js +16 -1
- package/dist/agent/runtime/command_panes.js +4 -1
- package/dist/agent/runtime/execution_context.d.ts +8 -1
- package/dist/agent/runtime/execution_context.js +8 -2
- package/dist/agent/runtime/policy.d.ts +66 -5
- package/dist/agent/runtime/policy.js +161 -33
- package/dist/agent/runtime/remote_broker_transport.d.ts +7 -0
- package/dist/agent/runtime/remote_broker_transport.js +33 -3
- package/dist/agent/runtime/remote_resource_errors.d.ts +7 -0
- package/dist/agent/runtime/remote_resource_errors.js +10 -0
- package/dist/agent/runtime/remote_resources.d.ts +1 -1
- package/dist/agent/runtime/remote_resources.js +7 -3
- package/dist/agent/runtime/source_verification.js +15 -12
- package/dist/agent/runtime/tool_runtime.js +165 -58
- package/dist/agent/runtime/verifier_capture.d.ts +1 -1
- package/dist/agent/runtime/verifier_capture.js +6 -0
- package/dist/agent/runtime/work_base.js +46 -14
- package/dist/agent/tools/adaptation.js +29 -12
- package/dist/agent/tools/apply_patch.js +62 -5
- package/dist/agent/tools/background.js +2 -0
- package/dist/agent/tools/benchmark_cpu.js +2 -0
- package/dist/agent/tools/bus_message.d.ts +4 -2
- package/dist/agent/tools/bus_message.js +21 -3
- package/dist/agent/tools/delegate.js +2 -0
- package/dist/agent/tools/file.d.ts +12 -1
- package/dist/agent/tools/file.js +92 -11
- package/dist/agent/tools/lsp.d.ts +12 -0
- package/dist/agent/tools/lsp.js +61 -5
- package/dist/agent/tools/pane.js +20 -45
- package/dist/agent/tools/project_context.js +5 -2
- package/dist/agent/tools/routine.js +20 -4
- package/dist/agent/tools/screenshot.d.ts +8 -0
- package/dist/agent/tools/screenshot.js +39 -25
- package/dist/agent/tools/search.js +31 -3
- package/dist/agent/tools/shell.js +7 -1
- package/dist/agent/tools/supervision.js +6 -0
- package/dist/agent/tools/types.d.ts +18 -0
- package/dist/agent/tools/zerg.js +15 -19
- package/dist/agent/tools/ztc_command.d.ts +15 -4
- package/dist/agent/tools/ztc_command.js +48 -34
- package/dist/app/agent_runner.js +8 -6
- package/dist/app/conversation_compaction.d.ts +6 -3
- package/dist/app/conversation_compaction.js +6 -3
- package/dist/app/tool_callbacks.js +1 -0
- package/dist/audio/sfx.js +6 -0
- package/dist/batch/worktree.js +22 -10
- package/dist/board/client.js +2 -1
- package/dist/cli_main.d.ts +1 -0
- package/dist/cli_main.js +141 -45
- package/dist/cli_ratatui.d.ts +49 -4
- package/dist/cli_ratatui.js +355 -79
- package/dist/conductor_branch.js +4 -1
- package/dist/config/host_credentials.d.ts +157 -0
- package/dist/config/host_credentials.js +589 -0
- package/dist/config/model_pin.d.ts +111 -0
- package/dist/config/model_pin.js +182 -0
- package/dist/config/own_state_files.d.ts +35 -0
- package/dist/config/own_state_files.js +161 -0
- package/dist/config/permission_pin.d.ts +148 -0
- package/dist/config/permission_pin.js +203 -0
- package/dist/config/permissions.d.ts +9 -2
- package/dist/config/permissions.js +14 -3
- package/dist/config/platform_login.d.ts +72 -0
- package/dist/config/platform_login.js +111 -0
- package/dist/config/profile_limits.d.ts +34 -0
- package/dist/config/profile_limits.js +66 -0
- package/dist/config/provider_api_key_env.js +3 -2
- package/dist/config/provider_models.d.ts +6 -1
- package/dist/config/provider_models.js +38 -11
- package/dist/config/repo_config.d.ts +22 -0
- package/dist/config/repo_config.js +77 -3
- package/dist/config/router_runtime_grant.d.ts +53 -0
- package/dist/config/router_runtime_grant.js +131 -0
- package/dist/config/settings_merge.d.ts +22 -0
- package/dist/config/settings_merge.js +75 -0
- package/dist/config/types.d.ts +8 -0
- package/dist/config.d.ts +334 -4
- package/dist/config.js +1024 -41
- package/dist/context/project_intelligence.d.ts +11 -2
- package/dist/context/project_intelligence.js +38 -15
- package/dist/desktop/daily/desktop_wiring.js +8 -6
- package/dist/desktop/daily/native_pane_launcher.js +2 -1
- package/dist/desktop/daily/native_tool.d.ts +1 -1
- package/dist/desktop/daily/native_tool.js +4 -3
- package/dist/desktop/daily/process_identity.js +10 -2
- package/dist/desktop/daily/source_baseline.js +4 -3
- package/dist/diagnostics/native_terminal_benchmark.js +3 -2
- package/dist/diagnostics/session_export.js +27 -14
- package/dist/embedded/anempa_runtime.js +3 -3
- package/dist/embedded/gameboy_runtime.js +5 -4
- package/dist/embedded/zergpod_runtime.js +5 -4
- package/dist/emulation/catalog.js +6 -1
- package/dist/emulation/tool_adapters.js +13 -3
- package/dist/environment/store.js +5 -4
- package/dist/extension_discovery.d.ts +12 -2
- package/dist/extension_discovery.js +52 -7
- package/dist/headless.d.ts +8 -0
- package/dist/headless.js +52 -13
- package/dist/headless_cli.js +16 -1
- package/dist/headless_workflow_trigger.js +1 -1
- package/dist/hooks/dispatcher.d.ts +8 -0
- package/dist/hooks/dispatcher.js +22 -2
- package/dist/hooks/lifecycle.d.ts +6 -0
- package/dist/hooks/lifecycle.js +1 -0
- package/dist/hooks/program_files.d.ts +10 -0
- package/dist/hooks/program_files.js +175 -0
- package/dist/hooks/runner.d.ts +11 -1
- package/dist/hooks/runner.js +112 -11
- package/dist/hooks/types.d.ts +2 -0
- package/dist/host_credentials_startup.d.ts +6 -0
- package/dist/host_credentials_startup.js +17 -0
- package/dist/instance_registry.d.ts +6 -2
- package/dist/instance_registry.js +9 -15
- package/dist/intake/format.d.ts +6 -0
- package/dist/intake/format.js +9 -0
- package/dist/intake/notifications.js +2 -1
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +4 -5
- package/dist/mcp/client.d.ts +2 -0
- package/dist/mcp/client.js +116 -18
- package/dist/mcp/registry.d.ts +12 -0
- package/dist/mcp/registry.js +15 -1
- package/dist/modes/handlers.js +14 -5
- package/dist/panes/agent_cli.d.ts +23 -1
- package/dist/panes/agent_cli.js +96 -1
- package/dist/panes/agent_panes.d.ts +27 -4
- package/dist/panes/agent_panes.js +73 -11
- package/dist/panes/editor_program.d.ts +8 -0
- package/dist/panes/editor_program.js +25 -0
- package/dist/panes/motsi.d.ts +11 -1
- package/dist/panes/motsi.js +14 -1
- package/dist/panes/pane_registry.d.ts +28 -1
- package/dist/panes/pane_registry.js +25 -0
- package/dist/panes/worker_route.js +5 -3
- package/dist/panes/ztc_launch.d.ts +8 -0
- package/dist/panes/ztc_launch.js +26 -1
- package/dist/profile_baseline.js +2 -0
- package/dist/router_auth.d.ts +8 -3
- package/dist/router_auth.js +34 -2
- package/dist/runtime_info.js +56 -38
- package/dist/session.js +12 -2
- package/dist/shannon/runtime.js +13 -1
- package/dist/simulation/domains/loader.d.ts +2 -1
- package/dist/simulation/domains/loader.js +19 -2
- package/dist/simulation/living/context.d.ts +8 -8
- package/dist/simulation/living/types.d.ts +2 -2
- package/dist/simulation/memory/embedding.d.ts +2 -1
- package/dist/simulation/memory/embedding.js +25 -6
- package/dist/terminal_attach.js +2 -1
- package/dist/types.d.ts +21 -0
- package/dist/ui/ratatui/headless_pane_manager.d.ts +12 -6
- package/dist/ui/ratatui/headless_pane_manager.js +65 -21
- package/dist/ui/ratatui/ipc_path.d.ts +41 -2
- package/dist/ui/ratatui/ipc_path.js +164 -5
- package/dist/ui/ratatui/pane_credential_broker.d.ts +17 -4
- package/dist/ui/ratatui/pane_credential_broker.js +23 -5
- package/dist/ui/ratatui/pane_relay.d.ts +74 -0
- package/dist/ui/ratatui/pane_relay.js +188 -13
- package/dist/ui/ratatui/process.d.ts +15 -1
- package/dist/ui/ratatui/process.js +129 -163
- package/dist/ui/ratatui/protocol.d.ts +11 -1
- package/dist/ui/ratatui/protocol.js +6 -0
- package/dist/ui/ratatui/ztc_launch_trust.d.ts +87 -0
- package/dist/ui/ratatui/ztc_launch_trust.js +249 -0
- package/dist/utils/admitted_open.d.ts +40 -0
- package/dist/utils/admitted_open.js +111 -0
- package/dist/utils/clipboard.js +2 -1
- package/dist/utils/computer_native.js +12 -56
- package/dist/utils/dictation.js +15 -12
- package/dist/utils/dictation_native.js +17 -60
- package/dist/utils/git_probe_options.d.ts +28 -0
- package/dist/utils/git_probe_options.js +30 -0
- package/dist/utils/git_program_files.d.ts +145 -0
- package/dist/utils/git_program_files.js +1282 -0
- package/dist/utils/git_repository_programs.d.ts +13 -0
- package/dist/utils/git_repository_programs.js +38 -0
- package/dist/utils/host_shell.js +2 -1
- package/dist/utils/idle_compaction.js +8 -1
- package/dist/utils/image_fit.d.ts +4 -1
- package/dist/utils/image_fit.js +6 -2
- package/dist/utils/image_preview.js +3 -2
- package/dist/utils/mirror_media.d.ts +22 -4
- package/dist/utils/mirror_media.js +87 -86
- package/dist/utils/ml_native.js +11 -56
- package/dist/utils/native_install.d.ts +55 -0
- package/dist/utils/native_install.js +107 -0
- package/dist/utils/open_url.js +2 -0
- package/dist/utils/process_end.d.ts +16 -0
- package/dist/utils/process_end.js +73 -0
- package/dist/utils/router_catalog.js +9 -2
- package/dist/utils/sandbox.d.ts +64 -1
- package/dist/utils/sandbox.js +397 -89
- package/dist/utils/shell.js +31 -12
- package/dist/utils/subprocess_env.d.ts +218 -2
- package/dist/utils/subprocess_env.js +429 -11
- package/dist/utils/system_ps.d.ts +5 -0
- package/dist/utils/system_ps.js +30 -0
- package/dist/utils/tts.js +5 -0
- package/dist/utils/tts_native.js +13 -60
- package/dist/utils/zlicky_overlay.js +17 -50
- package/dist/utils/ztc_own_state.d.ts +58 -0
- package/dist/utils/ztc_own_state.js +236 -0
- package/dist/web/mirror_authenticator.d.ts +67 -6
- package/dist/web/mirror_authenticator.js +131 -22
- package/dist/web/mirror_stream.d.ts +54 -10
- package/dist/web/mirror_stream.js +379 -92
- package/dist/web/observer_query_redaction.js +53 -13
- package/dist/web/observer_secret_redaction.d.ts +59 -0
- package/dist/web/observer_secret_redaction.js +714 -0
- package/dist/web/pane_credentials.d.ts +20 -2
- package/dist/web/pane_credentials.js +58 -5
- package/dist/worker/executor.js +3 -1
- package/dist/workspace_collision.js +19 -15
- package/dist/zerg/local_zerg_launches.d.ts +27 -0
- package/dist/zerg/local_zerg_launches.js +198 -0
- package/dist/zlm-embed.mjs +6257 -2791
- package/npm-shrinkwrap.json +1 -1
- package/package.json +42 -15
|
@@ -6,69 +6,23 @@
|
|
|
6
6
|
* - Cross-platform support
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from 'child_process';
|
|
9
|
-
import { existsSync } from 'fs';
|
|
10
9
|
import { createInterface } from 'readline';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
-
const __dirname = dirname(__filename);
|
|
10
|
+
import { platform } from 'os';
|
|
11
|
+
import { findNativeProgram, nativeProgramBuildCommand } from './native_install.js';
|
|
12
|
+
import { buildNativeHelperEnv } from './subprocess_env.js';
|
|
16
13
|
let eventHandlers = [];
|
|
17
14
|
/**
|
|
18
|
-
* Get the
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
os = 'darwin';
|
|
27
|
-
break;
|
|
28
|
-
case 'linux':
|
|
29
|
-
os = 'linux';
|
|
30
|
-
break;
|
|
31
|
-
case 'win32':
|
|
32
|
-
os = 'win';
|
|
33
|
-
break;
|
|
34
|
-
default:
|
|
35
|
-
os = p;
|
|
36
|
-
}
|
|
37
|
-
let cpu;
|
|
38
|
-
switch (a) {
|
|
39
|
-
case 'x64':
|
|
40
|
-
cpu = 'x64';
|
|
41
|
-
break;
|
|
42
|
-
case 'arm64':
|
|
43
|
-
cpu = 'arm64';
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
cpu = a;
|
|
47
|
-
}
|
|
48
|
-
const ext = p === 'win32' ? '.exe' : '';
|
|
49
|
-
return `ztc-audio-${os}-${cpu}${ext}`;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the path to the ztc-audio binary
|
|
15
|
+
* Get the path to the ztc-audio binary, from ZTC's own install only (native_install.ts findNativeProgram, which the other
|
|
16
|
+
* native programs share): a source checkout's cargo release build under the package, then the package's bin/ (an npm
|
|
17
|
+
* install's, the npm launcher's copy of it, and the desktop app's bundle), then the checkout's debug build, which runs
|
|
18
|
+
* only where the install has no other copy. Never the working directory or ~/.ztc/bin, which a resident's agent can
|
|
19
|
+
* write: a ztc-audio planted there would run as dictation. A packed install ships no cargo build, so none is looked for
|
|
20
|
+
* there: the launcher's copy lies under HOME (~/.cache/zergai-cli), and a ztc-audio put at its packages/ztc-dictation
|
|
21
|
+
* build ran ahead of its bin/. The copy's own files, its bin/ among them, are as writable as HOME is, as is everything
|
|
22
|
+
* else ZTC runs from the copy.
|
|
53
23
|
*/
|
|
54
24
|
function getBinaryPath() {
|
|
55
|
-
|
|
56
|
-
const possiblePaths = [
|
|
57
|
-
// Development: Rust build output
|
|
58
|
-
join(process.cwd(), 'packages', 'ztc-dictation', 'target', 'release', 'ztc-audio'),
|
|
59
|
-
// Development: bin directory (for local testing)
|
|
60
|
-
join(process.cwd(), 'bin', binaryName),
|
|
61
|
-
// Installed via npm (relative to this file in dist/utils/)
|
|
62
|
-
join(__dirname, '..', '..', 'bin', binaryName),
|
|
63
|
-
// Global install location
|
|
64
|
-
join(homedir(), '.ztc', 'bin', binaryName),
|
|
65
|
-
];
|
|
66
|
-
for (const p of possiblePaths) {
|
|
67
|
-
if (existsSync(p)) {
|
|
68
|
-
return p;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
25
|
+
return findNativeProgram('ztc-audio');
|
|
72
26
|
}
|
|
73
27
|
/**
|
|
74
28
|
* Check if native dictation is available
|
|
@@ -231,13 +185,15 @@ export class NativeDictationSession {
|
|
|
231
185
|
if (!binaryPath) {
|
|
232
186
|
this.emitLocal({
|
|
233
187
|
type: 'error',
|
|
234
|
-
message:
|
|
188
|
+
message: `ztc-audio binary not found. Build with: ${nativeProgramBuildCommand('ztc-audio')}`
|
|
235
189
|
});
|
|
236
190
|
return false;
|
|
237
191
|
}
|
|
238
192
|
try {
|
|
193
|
+
// The person's own environment, none of ZTC's or its route's credentials.
|
|
239
194
|
this.activeProcess = spawn(binaryPath, args, {
|
|
240
195
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
196
|
+
env: buildNativeHelperEnv(),
|
|
241
197
|
});
|
|
242
198
|
const rl = createInterface({
|
|
243
199
|
input: this.activeProcess.stdout,
|
|
@@ -315,6 +271,7 @@ export async function listAudioDevices() {
|
|
|
315
271
|
const devices = [];
|
|
316
272
|
const proc = spawn(binaryPath, ['--list-devices'], {
|
|
317
273
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
274
|
+
env: buildNativeHelperEnv(),
|
|
318
275
|
});
|
|
319
276
|
const rl = createInterface({
|
|
320
277
|
input: proc.stdout,
|
|
@@ -360,7 +317,7 @@ export function getNativeDictationStatus() {
|
|
|
360
317
|
}
|
|
361
318
|
else {
|
|
362
319
|
parts.push('Native dictation: not available');
|
|
363
|
-
parts.push(
|
|
320
|
+
parts.push(`Build with: ${nativeProgramBuildCommand('ztc-audio')}`);
|
|
364
321
|
}
|
|
365
322
|
if (isNativeRecording()) {
|
|
366
323
|
parts.push('\nCurrently recording...');
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the git ZTC runs for itself in the agent's work tree takes, under every permission profile: the startup snapshot
|
|
3
|
+
* (runtime_info.ts), /status and /runtime, /diff, the session's work check (agent/runtime/work_base.ts), a verified
|
|
4
|
+
* command's source receipt (agent/runtime/source_verification.ts), session isolation (workspace_collision.ts), /batch's
|
|
5
|
+
* worktrees (batch/worktree.ts), the project-context index (context/project_intelligence.ts) and the desktop daily
|
|
6
|
+
* driver's source baseline. That git runs as ZTC, outside any sandbox the agent works under, and starts the programs the
|
|
7
|
+
* repository's config names: an fsmonitor for a status or a diff, an external diff and a textconv driver for a diff, a
|
|
8
|
+
* signature program for a log of a signed commit (the reviewer's round-1 probe, item 3). None of them is what ZTC asks
|
|
9
|
+
* git for, so its own git starts none of them. (A lone rev-parse or symbolic-ref, such as the navigator's title, starts
|
|
10
|
+
* none of them anyway.) The agent's own commands and the person's are theirs, and keep the repository's programs. Where
|
|
11
|
+
* the agent may have written that config, ZTC's git takes more (utils/git_repository_programs.ts). No imports: the lowest
|
|
12
|
+
* modules that run git take these.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Options before the command: no core.fsmonitor command runs (a status or a diff would start it), no log verifies a
|
|
16
|
+
* signature (log.showSignature would start gpg.program for a signed commit), and safe.bareRepository=explicit keeps git
|
|
17
|
+
* from discovering a bare repository planted in the work tree and reading its config. Each is honoured from the command
|
|
18
|
+
* line, which no repository's config overrides, and leaves normal work trees, linked worktrees and a cwd inside .git
|
|
19
|
+
* working.
|
|
20
|
+
*/
|
|
21
|
+
export declare const GIT_PROBE_OPTIONS: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Options after `diff`: git's own diff of the bytes, with no external diff program (diff.external, or a diff driver's
|
|
24
|
+
* command) and no textconv driver. One without the other is not enough: with the external diff off, git falls back to
|
|
25
|
+
* its own diff and runs the textconv driver. A diff that names files only (--name-only) starts neither, and takes them
|
|
26
|
+
* too, so no change to it can.
|
|
27
|
+
*/
|
|
28
|
+
export declare const GIT_DIFF_OPTIONS: readonly string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the git ZTC runs for itself in the agent's work tree takes, under every permission profile: the startup snapshot
|
|
3
|
+
* (runtime_info.ts), /status and /runtime, /diff, the session's work check (agent/runtime/work_base.ts), a verified
|
|
4
|
+
* command's source receipt (agent/runtime/source_verification.ts), session isolation (workspace_collision.ts), /batch's
|
|
5
|
+
* worktrees (batch/worktree.ts), the project-context index (context/project_intelligence.ts) and the desktop daily
|
|
6
|
+
* driver's source baseline. That git runs as ZTC, outside any sandbox the agent works under, and starts the programs the
|
|
7
|
+
* repository's config names: an fsmonitor for a status or a diff, an external diff and a textconv driver for a diff, a
|
|
8
|
+
* signature program for a log of a signed commit (the reviewer's round-1 probe, item 3). None of them is what ZTC asks
|
|
9
|
+
* git for, so its own git starts none of them. (A lone rev-parse or symbolic-ref, such as the navigator's title, starts
|
|
10
|
+
* none of them anyway.) The agent's own commands and the person's are theirs, and keep the repository's programs. Where
|
|
11
|
+
* the agent may have written that config, ZTC's git takes more (utils/git_repository_programs.ts). No imports: the lowest
|
|
12
|
+
* modules that run git take these.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Options before the command: no core.fsmonitor command runs (a status or a diff would start it), no log verifies a
|
|
16
|
+
* signature (log.showSignature would start gpg.program for a signed commit), and safe.bareRepository=explicit keeps git
|
|
17
|
+
* from discovering a bare repository planted in the work tree and reading its config. Each is honoured from the command
|
|
18
|
+
* line, which no repository's config overrides, and leaves normal work trees, linked worktrees and a cwd inside .git
|
|
19
|
+
* working.
|
|
20
|
+
*/
|
|
21
|
+
export const GIT_PROBE_OPTIONS = Object.freeze([
|
|
22
|
+
'-c', 'core.fsmonitor=false', '-c', 'safe.bareRepository=explicit', '-c', 'log.showSignature=false',
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Options after `diff`: git's own diff of the bytes, with no external diff program (diff.external, or a diff driver's
|
|
26
|
+
* command) and no textconv driver. One without the other is not enough: with the external diff off, git falls back to
|
|
27
|
+
* its own diff and runs the textconv driver. A diff that names files only (--name-only) starts neither, and takes them
|
|
28
|
+
* too, so no change to it can.
|
|
29
|
+
*/
|
|
30
|
+
export const GIT_DIFF_OPTIONS = Object.freeze(['--no-ext-diff', '--no-textconv']);
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export interface GitProgramFiles {
|
|
2
|
+
/** Files no write may change or create, each as named and, for a link, as its target. */
|
|
3
|
+
files: string[];
|
|
4
|
+
/** The repositories' common configs among `files`, which git reads whenever one exists. */
|
|
5
|
+
configs: string[];
|
|
6
|
+
/** Hooks folders: nothing in them may be written or created, nor the folder itself. */
|
|
7
|
+
folders: string[];
|
|
8
|
+
/** Folders that may not be renamed, removed or replaced, though what they hold may change; shallowest first. */
|
|
9
|
+
pinned: string[];
|
|
10
|
+
/** Files among `files` that were not there when the plan was made, the common configs aside (undoGitProgramWrites). */
|
|
11
|
+
absent: string[];
|
|
12
|
+
/** Names among `files`, `folders` and `pinned` that were links when the plan was made, each with what it read (readlink). */
|
|
13
|
+
links: Array<{
|
|
14
|
+
path: string;
|
|
15
|
+
target: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* What the plan says beside what it protects: a core.hooksPath folder the repository tracks, which it leaves to the
|
|
19
|
+
* command, and each limit it stopped looking for repositories at, naming where.
|
|
20
|
+
*/
|
|
21
|
+
notes: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Each repository the command may break that a plan of this ZTC knew when it started, with what git needs of it to
|
|
24
|
+
* take its folder for that repository, as a plan last saw it whole: the step after the command puts back what the
|
|
25
|
+
* command broke of it (putBackBrokenRepositories).
|
|
26
|
+
*/
|
|
27
|
+
repositories: KnownRepositoryState[];
|
|
28
|
+
}
|
|
29
|
+
/** HEAD as git takes it for a repository's: a file's text (as its bytes) and mode, or where a link leads (refs/...). */
|
|
30
|
+
export type WholeHead = {
|
|
31
|
+
text: string;
|
|
32
|
+
mode: number;
|
|
33
|
+
} | {
|
|
34
|
+
link: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A git directory as git takes it for a repository's (git's is_git_directory): its HEAD, and the modes of the folders git
|
|
38
|
+
* enters to tell, the git directory and its common directory's refs and objects; and the folders git passes through to
|
|
39
|
+
* reach its work tree's .git, from the one below the writable root down to the work tree's top, each with its mode.
|
|
40
|
+
*/
|
|
41
|
+
export interface WholeRepository {
|
|
42
|
+
head: WholeHead;
|
|
43
|
+
modes: {
|
|
44
|
+
gitDir: number;
|
|
45
|
+
refs: number;
|
|
46
|
+
objects: number;
|
|
47
|
+
};
|
|
48
|
+
reach: Array<{
|
|
49
|
+
folder: string;
|
|
50
|
+
mode: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** A repository a plan knew (GitProgramFiles.repositories). */
|
|
54
|
+
export interface KnownRepositoryState {
|
|
55
|
+
/** Its git directory, as the filesystem spells it. */
|
|
56
|
+
gitDir: string;
|
|
57
|
+
/** Its common directory, which holds its refs and objects (the git directory itself, but for a linked worktree's). */
|
|
58
|
+
commonDir: string;
|
|
59
|
+
/** Its work tree's top folder, where the person runs git, when a plan has seen one. */
|
|
60
|
+
workTree: string | null;
|
|
61
|
+
/** As a plan last saw it whole, of this ZTC or one before it (its record); null when none has. */
|
|
62
|
+
whole: WholeRepository | null;
|
|
63
|
+
/** Whether git took its folder for no repository already when the plan was made (a process left running, the person). */
|
|
64
|
+
brokenAtStart: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Options for gitProgramFiles beyond the folders and the writable roots. */
|
|
67
|
+
export interface GitProgramFilesOptions {
|
|
68
|
+
/** The folders whose work trees a bounded walk looks for (default: the writable roots); none for a profile that names none. */
|
|
69
|
+
walk?: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Where ZTC keeps knownGitDirectories for the ZTCs started after it: in its own state under HOME (~/.ztc), which no
|
|
73
|
+
* command under a profile that limits the agent reaches (utils/ztc_own_state.ts), and not in its config folder, which a
|
|
74
|
+
* hosted resident's start rewrites (its ZTC_CONFIG_DIR is a tmpfs).
|
|
75
|
+
*/
|
|
76
|
+
export declare function knownRepositoryRecordPath(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Take the record of the repositories earlier ZTCs' plans found into knownGitDirectories, once per process (and again
|
|
79
|
+
* should HOME name another): ZTC loads it as it starts (cli_main.ts) and before its first plan. One it cannot take leaves
|
|
80
|
+
* it starting a new one, which every plan of the process notes and the first command's result says (sandbox notices are
|
|
81
|
+
* told once), and which the next plan writes. Where no ZTC has kept anything of its sandbox yet (a fresh HOME, with no
|
|
82
|
+
* folder for the record), there was no record to miss: it starts one without a word.
|
|
83
|
+
*/
|
|
84
|
+
export declare function loadKnownRepositoryRecord(): void;
|
|
85
|
+
/**
|
|
86
|
+
* What a sandboxed command working in DIRECTORIES (its cwd, the session's, the writable roots), with WRITE_ROOTS
|
|
87
|
+
* writable, may not change of the repositories there and of those a walk of the writable roots finds, and of every
|
|
88
|
+
* repository an earlier plan of this process found (knownGitDirectories).
|
|
89
|
+
*/
|
|
90
|
+
export declare function gitProgramFiles(directories: readonly string[], writeRoots: readonly string[], options?: GitProgramFilesOptions): GitProgramFiles;
|
|
91
|
+
/**
|
|
92
|
+
* The step after a command, on both backends (utils/sandbox.ts), once it has ended and before anything reads its result
|
|
93
|
+
* or any other git runs there: each repository the plan knew (FILES.repositories) that git takes for none now, put back
|
|
94
|
+
* as a plan last saw it whole. A command may write a repository's HEAD, refs and objects (checkouts, commits and fetches
|
|
95
|
+
* do), and git takes a git directory whose HEAD names no ref or commit, or whose refs or objects folder it cannot enter,
|
|
96
|
+
* for no repository: in a work tree whose .git that is, it looks for one in the folders above, where the same command
|
|
97
|
+
* may have made one (git init, which a command may run anywhere it writes, or a .git file naming a git directory of its
|
|
98
|
+
* own), and the person's git there, or a host service's, would read that config and start what it names (the walk-up
|
|
99
|
+
* route of the R3e review). So HEAD is put back as it was, the permissions of the git directory and of the folders from
|
|
100
|
+
* below the writable root down to the work tree too (bwrap lets a command change a pinned folder's; git, in a shell
|
|
101
|
+
* already in a folder it cannot reach from the top, looks above on Linux), and a refs or objects folder git cannot enter
|
|
102
|
+
* is an empty one again: one that is missing made new, one git may not enter moved aside first. A repository git takes
|
|
103
|
+
* for one is the command's as it left it: a checkout, a commit, a branch switch, a detached HEAD, refs packed or
|
|
104
|
+
* emptied. What ZTC did, for the command's result.
|
|
105
|
+
*/
|
|
106
|
+
export declare function putBackBrokenRepositories(files: GitProgramFiles): string[];
|
|
107
|
+
/**
|
|
108
|
+
* What a sandboxed COMMAND's result says, run in CWD under a plan that protects the repositories it can write, when its
|
|
109
|
+
* OUTPUT shows the OS sandbox kept one of their protected files (config, hooks, worktree records) from it: which files,
|
|
110
|
+
* why, and that the person runs the command themselves where they want it done. git that writes a protected config
|
|
111
|
+
* fails, or says it did what it could not record there ("set up to track"); an rm of a repository leaves those files
|
|
112
|
+
* behind. Nothing when the output shows neither.
|
|
113
|
+
*/
|
|
114
|
+
export declare function refusedGitWriteNotes(output: string, command: string, cwd: string): string[];
|
|
115
|
+
/**
|
|
116
|
+
* The step after a command bwrap ran (utils/sandbox.ts), once it has ended and before any other git runs there: what it
|
|
117
|
+
* did where FILES (the plan's record) protects that bwrap could not refuse, undone. bwrap keeps a path that exists
|
|
118
|
+
* read-only, but not a name a command creates in a folder it may write, nor a link's own name, since a mount follows a
|
|
119
|
+
* link: so a protected file the command made (a commondir, which points git at a common directory and config of its
|
|
120
|
+
* own, a config.worktree) is removed, and a protected link it replaced or removed is put back as it was (the reviewer's
|
|
121
|
+
* round-1 probe: one write to .git/commondir, and the person's git status ran the command's fsmonitor). What ZTC did,
|
|
122
|
+
* for the command's result; nothing when it left them alone. Seatbelt refuses both, since its rules go by a path, which
|
|
123
|
+
* a name not made yet has too and a link's own name is, so it has no such step.
|
|
124
|
+
*/
|
|
125
|
+
export declare function undoGitProgramWrites(files: GitProgramFiles): string[];
|
|
126
|
+
/**
|
|
127
|
+
* The Seatbelt rules for FILES, after the rule that lets a writable root be written: each file denied every write, a
|
|
128
|
+
* hooks folder's within it, a pinned folder's as itself (what it holds stays writable). They go by the paths the plan
|
|
129
|
+
* found, so a name that does not exist yet is refused as one that does, and Seatbelt matches a name as the volume does:
|
|
130
|
+
* on one that ignores case `.git/COMMONDIR`, which git reads as `.git/commondir`, is refused too. Nothing is refused by a
|
|
131
|
+
* pattern: a repository the command makes is its own until the next command's plan finds it, as under bwrap.
|
|
132
|
+
*/
|
|
133
|
+
export declare function seatbeltGitProgramRules(files: GitProgramFiles, quote: (path: string) => string): string[];
|
|
134
|
+
/**
|
|
135
|
+
* bwrap options for FILES, after the writable roots are bound and before anything is hidden. bwrap protects a path with
|
|
136
|
+
* a mount, which a rename or a removal cannot move (EBUSY) and a read-only one no write gets through: each pinned folder
|
|
137
|
+
* is bound onto itself, writable; each file is bound read-only, and a missing common config is an empty one (git reads
|
|
138
|
+
* an empty config as none, and a command cannot create one there); each hooks folder is bound read-only, or, missing,
|
|
139
|
+
* an empty read-only folder. The mount points of the last two are left behind, empty. A link is bound at its target
|
|
140
|
+
* (a mount follows a link), so the link itself can still be replaced, and a file the command creates where none was
|
|
141
|
+
* (a commondir, a config.worktree) cannot be refused: bwrap stops writes to a path that exists, not a new name in a
|
|
142
|
+
* folder that stays writable. The step after the command undoes both (undoGitProgramWrites); Seatbelt's rules, which go
|
|
143
|
+
* by path, deny both.
|
|
144
|
+
*/
|
|
145
|
+
export declare function bubblewrapGitProgramBinds(files: GitProgramFiles): string[];
|