@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
|
@@ -12,17 +12,60 @@ import { spawn } from 'child_process';
|
|
|
12
12
|
import { randomUUID } from 'node:crypto';
|
|
13
13
|
import { existsSync, unlinkSync } from 'fs';
|
|
14
14
|
import { createInterface } from 'readline';
|
|
15
|
-
import { join
|
|
16
|
-
import { homedir, platform
|
|
17
|
-
import { fileURLToPath } from 'url';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
import { homedir, platform } from 'os';
|
|
18
17
|
import { createConnection } from 'net';
|
|
19
18
|
import { serializeCommand, parseEvent, CAPABILITY_CLIPBOARD_IMAGE, CAPABILITY_CLIPBOARD_TEXT } from './protocol.js';
|
|
20
19
|
import { generateIpcPath, removeOwnedIpcPath } from './ipc_path.js';
|
|
21
20
|
import { loadDesktopRuntime, validateDesktopRendererReady } from '../../desktop/runtime.js';
|
|
22
21
|
import { debugFileLog as debugLog, describeInputForLog } from '../../utils/debug_log.js';
|
|
23
22
|
import { rendererOpensInBackground } from '../../utils/session_interactivity.js';
|
|
23
|
+
import { HOST_HANDOFF_FLAG, removeHostHandoff, writeHostHandoff } from '../../config/host_credentials.js';
|
|
24
|
+
import { buildRendererEnv, ztcChildCredentialEnv } from '../../utils/subprocess_env.js';
|
|
24
25
|
import { withoutMirrorCredentials } from '../../web/pane_credentials.js';
|
|
25
|
-
import {
|
|
26
|
+
import { findNativeProgram, isPackedZtcInstall, nativeProgramBuildCommand, packagedName } from '../../utils/native_install.js';
|
|
27
|
+
import { isOwnersCommand, isZtcLaunchTrusted, PaneCredentialBroker } from './pane_credential_broker.js';
|
|
28
|
+
/**
|
|
29
|
+
* CMD, a create_pane for this renderer, with what a ZTC pane or colony cell it starts is given of ZTC's credentials
|
|
30
|
+
* (ztcChildCredentialEnv) in its environment: the renderer starts it with its own environment, which holds none of them.
|
|
31
|
+
* A pane a pane asks the relay to open is given them only on a launch nonce the relay issued (isZtcLaunchTrusted), as
|
|
32
|
+
* the headless pane manager checks too, whatever type it names. The command's marks (a pane relay's, see markRelayed)
|
|
33
|
+
* stay on it.
|
|
34
|
+
*/
|
|
35
|
+
function withZtcChildCredentials(cmd) {
|
|
36
|
+
if (!isZtcLaunchTrusted(cmd))
|
|
37
|
+
return cmd;
|
|
38
|
+
const credentials = ztcChildCredentialEnv(cmd.pane_type);
|
|
39
|
+
if (Object.keys(credentials).length === 0)
|
|
40
|
+
return cmd;
|
|
41
|
+
const given = { ...cmd, env: { ...(cmd.env ?? {}), ...credentials } };
|
|
42
|
+
for (const symbol of Object.getOwnPropertySymbols(cmd))
|
|
43
|
+
Object.defineProperty(given, symbol, Object.getOwnPropertyDescriptor(cmd, symbol));
|
|
44
|
+
return given;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* CMD, a replace_pane for this renderer, with what a ZTC pane or colony cell is given of ZTC's credentials
|
|
48
|
+
* (ztcChildCredentialEnv) as a create_pane gives it (withZtcChildCredentials), and the handoff they went in. A
|
|
49
|
+
* replace_pane carries no environment, and the renderer starts the pane's program again with its own environment
|
|
50
|
+
* alone, which holds none of them: so they go in a one-time owner-only handoff named among the program's options
|
|
51
|
+
* (HOST_HANDOFF_FLAG), never on its command line. A ZTC pane opened with a task ends its command line with an end of
|
|
52
|
+
* options ('--') and the task, literal text, so the flag goes before the two. Only the owner's own replacement of a
|
|
53
|
+
* ZTC pane is given them: one a pane sends through the relay, a pane of any other type, and a replacement with no
|
|
54
|
+
* program get none.
|
|
55
|
+
*/
|
|
56
|
+
function withZtcChildHandoff(cmd) {
|
|
57
|
+
if (!cmd.command || (cmd.pane_type !== 'ztc' && cmd.pane_type !== 'colony_ztc') || !isOwnersCommand(cmd))
|
|
58
|
+
return { command: cmd };
|
|
59
|
+
const handoff = writeHostHandoff(ztcChildCredentialEnv(cmd.pane_type));
|
|
60
|
+
if (!handoff)
|
|
61
|
+
return { command: cmd };
|
|
62
|
+
const args = cmd.args ?? [];
|
|
63
|
+
const option = [HOST_HANDOFF_FLAG, handoff];
|
|
64
|
+
const given = { ...cmd, args: args.at(-2) === '--' ? [...args.slice(0, -2), ...option, ...args.slice(-2)] : [...args, ...option] };
|
|
65
|
+
for (const symbol of Object.getOwnPropertySymbols(cmd))
|
|
66
|
+
Object.defineProperty(given, symbol, Object.getOwnPropertyDescriptor(cmd, symbol));
|
|
67
|
+
return { command: given, handoff };
|
|
68
|
+
}
|
|
26
69
|
/** Renderer events that carry no user text, logged whole. */
|
|
27
70
|
const PLAIN_RENDERER_EVENTS = new Set(['ready', 'resize', 'resize_ack', 'quit_requested']);
|
|
28
71
|
/**
|
|
@@ -37,161 +80,20 @@ function describeRendererLine(line, event) {
|
|
|
37
80
|
return `input ${describeInputForLog(event.input, event.paste)}`;
|
|
38
81
|
return PLAIN_RENDERER_EVENTS.has(event.type) ? line : `${event.type} ${line.length} bytes`;
|
|
39
82
|
}
|
|
40
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
41
|
-
const __dirname = dirname(__filename);
|
|
42
|
-
/**
|
|
43
|
-
* Get the platform-specific binary name
|
|
44
|
-
*/
|
|
45
|
-
function getBinaryName() {
|
|
46
|
-
const p = platform();
|
|
47
|
-
const a = arch();
|
|
48
|
-
let os;
|
|
49
|
-
switch (p) {
|
|
50
|
-
case 'darwin':
|
|
51
|
-
os = 'darwin';
|
|
52
|
-
break;
|
|
53
|
-
case 'linux':
|
|
54
|
-
os = 'linux';
|
|
55
|
-
break;
|
|
56
|
-
case 'win32':
|
|
57
|
-
os = 'win';
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
os = p;
|
|
61
|
-
}
|
|
62
|
-
let cpu;
|
|
63
|
-
switch (a) {
|
|
64
|
-
case 'x64':
|
|
65
|
-
cpu = 'x64';
|
|
66
|
-
break;
|
|
67
|
-
case 'arm64':
|
|
68
|
-
cpu = 'arm64';
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
cpu = a;
|
|
72
|
-
}
|
|
73
|
-
const ext = p === 'win32' ? '.exe' : '';
|
|
74
|
-
return `ztc-tui-${os}-${cpu}${ext}`;
|
|
75
|
-
}
|
|
76
|
-
function candidateProjectRoots() {
|
|
77
|
-
const anchors = [
|
|
78
|
-
__dirname,
|
|
79
|
-
process.argv[1] ? dirname(resolve(process.argv[1])) : null,
|
|
80
|
-
].filter((anchor) => !!anchor);
|
|
81
|
-
const roots = [];
|
|
82
|
-
const seen = new Set();
|
|
83
|
-
for (const anchor of anchors) {
|
|
84
|
-
let current = resolve(anchor);
|
|
85
|
-
while (!seen.has(current)) {
|
|
86
|
-
seen.add(current);
|
|
87
|
-
roots.push(current);
|
|
88
|
-
const parent = dirname(current);
|
|
89
|
-
if (parent === current)
|
|
90
|
-
break;
|
|
91
|
-
current = parent;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return roots;
|
|
95
|
-
}
|
|
96
|
-
function findRustBinaryPath(roots, packageName, executableName, packagedBinaryName) {
|
|
97
|
-
const possiblePaths = [
|
|
98
|
-
join(__dirname, '..', '..', '..', 'bin', packagedBinaryName),
|
|
99
|
-
];
|
|
100
|
-
for (const root of roots) {
|
|
101
|
-
possiblePaths.push(join(root, 'packages', packageName, 'target', 'release', executableName), join(root, 'packages', packageName, 'target', 'debug', executableName), join(root, 'bin', packagedBinaryName));
|
|
102
|
-
}
|
|
103
|
-
possiblePaths.push(join(homedir(), '.ztc', 'bin', packagedBinaryName));
|
|
104
|
-
const seen = new Set();
|
|
105
|
-
for (const path of possiblePaths) {
|
|
106
|
-
if (seen.has(path))
|
|
107
|
-
continue;
|
|
108
|
-
seen.add(path);
|
|
109
|
-
if (existsSync(path)) {
|
|
110
|
-
return path;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
83
|
/**
|
|
116
|
-
* Get the path to the ztc-tui binary
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
84
|
+
* Get the path to the ztc-tui binary, from ZTC's own install only (utils/native_install.ts findNativeProgram): the
|
|
85
|
+
* package's bin/ (an npm install, the npm launcher's copy, the desktop app's bundle), then, in a source checkout, the
|
|
86
|
+
* package's cargo build. Binary discovery never depends on process.cwd(): child-pane launch code may intentionally strip
|
|
87
|
+
* or override cwd, and an agent writes there, as it does ~/.ztc/bin and the folders above the install.
|
|
120
88
|
*/
|
|
121
89
|
function getBinaryPath() {
|
|
122
|
-
|
|
123
|
-
return findRustBinaryPath(candidateProjectRoots(), 'ztc-tui', 'ztc-tui', binaryName);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the platform-specific zmux binary name
|
|
127
|
-
*/
|
|
128
|
-
function getZmuxBinaryName() {
|
|
129
|
-
const p = platform();
|
|
130
|
-
const a = arch();
|
|
131
|
-
let os;
|
|
132
|
-
switch (p) {
|
|
133
|
-
case 'darwin':
|
|
134
|
-
os = 'darwin';
|
|
135
|
-
break;
|
|
136
|
-
case 'linux':
|
|
137
|
-
os = 'linux';
|
|
138
|
-
break;
|
|
139
|
-
case 'win32':
|
|
140
|
-
os = 'win';
|
|
141
|
-
break;
|
|
142
|
-
default: os = p;
|
|
143
|
-
}
|
|
144
|
-
let cpu;
|
|
145
|
-
switch (a) {
|
|
146
|
-
case 'x64':
|
|
147
|
-
cpu = 'x64';
|
|
148
|
-
break;
|
|
149
|
-
case 'arm64':
|
|
150
|
-
cpu = 'arm64';
|
|
151
|
-
break;
|
|
152
|
-
default: cpu = a;
|
|
153
|
-
}
|
|
154
|
-
const ext = p === 'win32' ? '.exe' : '';
|
|
155
|
-
return `zmux-${os}-${cpu}${ext}`;
|
|
90
|
+
return findNativeProgram('ztc-tui');
|
|
156
91
|
}
|
|
157
92
|
/**
|
|
158
|
-
* Get the path to the zmux binary
|
|
93
|
+
* Get the path to the zmux binary, from ZTC's own install only (findNativeProgram), as ztc-tui's.
|
|
159
94
|
*/
|
|
160
95
|
export function getZmuxBinaryPath() {
|
|
161
|
-
|
|
162
|
-
return findRustBinaryPath(candidateProjectRoots(), 'zmux', 'zmux', binaryName);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Get the platform-specific zterm binary name
|
|
166
|
-
*/
|
|
167
|
-
function getZtermBinaryName() {
|
|
168
|
-
const p = platform();
|
|
169
|
-
const a = arch();
|
|
170
|
-
let os;
|
|
171
|
-
switch (p) {
|
|
172
|
-
case 'darwin':
|
|
173
|
-
os = 'darwin';
|
|
174
|
-
break;
|
|
175
|
-
case 'linux':
|
|
176
|
-
os = 'linux';
|
|
177
|
-
break;
|
|
178
|
-
case 'win32':
|
|
179
|
-
os = 'win';
|
|
180
|
-
break;
|
|
181
|
-
default: os = p;
|
|
182
|
-
}
|
|
183
|
-
let cpu;
|
|
184
|
-
switch (a) {
|
|
185
|
-
case 'x64':
|
|
186
|
-
cpu = 'x64';
|
|
187
|
-
break;
|
|
188
|
-
case 'arm64':
|
|
189
|
-
cpu = 'arm64';
|
|
190
|
-
break;
|
|
191
|
-
default: cpu = a;
|
|
192
|
-
}
|
|
193
|
-
const ext = p === 'win32' ? '.exe' : '';
|
|
194
|
-
return `zterm-${os}-${cpu}${ext}`;
|
|
96
|
+
return findNativeProgram('zmux');
|
|
195
97
|
}
|
|
196
98
|
/** Resolve the executable inside a standard installed ZTerm.app bundle. */
|
|
197
99
|
export function resolveInstalledZtermExecutable(userHome = homedir(), pathExists = existsSync) {
|
|
@@ -219,12 +121,12 @@ function getZtermBinaryPath(admission) {
|
|
|
219
121
|
const runtime = admission === undefined ? loadDesktopRuntime() : admission;
|
|
220
122
|
if (runtime)
|
|
221
123
|
return runtime.rendererPath;
|
|
222
|
-
const binaryName = getZtermBinaryName();
|
|
223
124
|
return resolveZtermBinaryPath({
|
|
224
125
|
operatingSystem: platform(),
|
|
225
126
|
userHome: homedir(),
|
|
226
127
|
pathExists: existsSync,
|
|
227
|
-
|
|
128
|
+
// Else ZTC's own install's (findNativeProgram), as ztc-tui's.
|
|
129
|
+
resolveFallback: () => findNativeProgram('zterm'),
|
|
228
130
|
});
|
|
229
131
|
}
|
|
230
132
|
/**
|
|
@@ -246,7 +148,7 @@ export function isZtermAvailable(admission) {
|
|
|
246
148
|
export async function launchZtermDesktop(options) {
|
|
247
149
|
const binaryPath = getZtermBinaryPath();
|
|
248
150
|
if (!binaryPath) {
|
|
249
|
-
throw new Error(
|
|
151
|
+
throw new Error(`zterm binary not found. Build with: ${nativeProgramBuildCommand('zterm')}`);
|
|
250
152
|
}
|
|
251
153
|
const spawnArgs = options?.args ?? [];
|
|
252
154
|
const child = spawn(binaryPath, spawnArgs, {
|
|
@@ -294,6 +196,25 @@ export function isTTY() {
|
|
|
294
196
|
export function isRatatuiBinaryAvailable() {
|
|
295
197
|
return getBinaryPath() !== null;
|
|
296
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Why no ZTC pane opens where this install has no ztc-tui (isRatatuiBinaryAvailable): create_ztc_pane's refusal, and the
|
|
201
|
+
* pane relay's to a launch nonce asked for one. A source checkout is told to build it; a packed install, which would never
|
|
202
|
+
* run that build (utils/native_install.ts), that it ships none.
|
|
203
|
+
*/
|
|
204
|
+
export function ztcPaneRendererMissing() {
|
|
205
|
+
return isPackedZtcInstall()
|
|
206
|
+
? `ZTC child panes require the Rust ztc-tui binary, which this ZTC install does not ship (bin/${packagedName('ztc-tui')}).`
|
|
207
|
+
: `ZTC child panes require the Rust ztc-tui binary. Build it with \`${nativeProgramBuildCommand('ztc-tui')}\`.`;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Why RENDERER can't start: in a source checkout, the cargo build to make; in a packed install, which would never run
|
|
211
|
+
* that build, that it ships none (bin/<name>-<os>-<cpu>).
|
|
212
|
+
*/
|
|
213
|
+
function rendererMissing(renderer) {
|
|
214
|
+
return isPackedZtcInstall()
|
|
215
|
+
? `${renderer} binary not found: this ZTC install does not ship bin/${packagedName(renderer)}.`
|
|
216
|
+
: `${renderer} binary not found. Build with: ${nativeProgramBuildCommand(renderer)}`;
|
|
217
|
+
}
|
|
297
218
|
/**
|
|
298
219
|
* Check if the Ratatui TUI renderer is available
|
|
299
220
|
* Requires both the binary to exist and a TTY to be present
|
|
@@ -399,6 +320,12 @@ export class TuiProcess {
|
|
|
399
320
|
* (see PaneCredentialBroker).
|
|
400
321
|
*/
|
|
401
322
|
paneCredentials = new PaneCredentialBroker(() => this.rendererMirrorPort);
|
|
323
|
+
/**
|
|
324
|
+
* The one-time handoff of ZTC's credentials each ZTC pane the renderer started again in place was given, by pane id
|
|
325
|
+
* (withZtcChildHandoff): its program takes it as it starts, and one it never took goes when the pane closes, or
|
|
326
|
+
* when the renderer is gone.
|
|
327
|
+
*/
|
|
328
|
+
hostHandoffs = new Map();
|
|
402
329
|
/**
|
|
403
330
|
* In-flight `read_clipboard_image` requests, keyed by request id. The
|
|
404
331
|
* renderer answers asynchronously (it reads and PNG-encodes the clipboard
|
|
@@ -485,6 +412,17 @@ export class TuiProcess {
|
|
|
485
412
|
}
|
|
486
413
|
if (completed?.timer)
|
|
487
414
|
clearTimeout(completed.timer);
|
|
415
|
+
// A handoff is used once: one the pane's program never took goes with its pane, or with a replacement that failed.
|
|
416
|
+
if (event.type === 'pane_closed')
|
|
417
|
+
this.releaseHostHandoff(event.pane_id);
|
|
418
|
+
if (completed?.hostHandoff) {
|
|
419
|
+
if (event.type === 'pane_created') {
|
|
420
|
+
this.releaseHostHandoff(event.pane_id);
|
|
421
|
+
this.hostHandoffs.set(event.pane_id, completed.hostHandoff);
|
|
422
|
+
}
|
|
423
|
+
else
|
|
424
|
+
removeHostHandoff(completed.hostHandoff);
|
|
425
|
+
}
|
|
488
426
|
for (const handler of this.eventHandlers) {
|
|
489
427
|
try {
|
|
490
428
|
handler(event);
|
|
@@ -511,8 +449,14 @@ export class TuiProcess {
|
|
|
511
449
|
pending.wireRequestId = pending.requestId;
|
|
512
450
|
if (!this.socket || !this.ready)
|
|
513
451
|
throw new Error('Native pane renderer unavailable');
|
|
514
|
-
let
|
|
515
|
-
|
|
452
|
+
let replacement;
|
|
453
|
+
if (pending.command.type === 'replace_pane') {
|
|
454
|
+
const given = withZtcChildHandoff(pending.command);
|
|
455
|
+
replacement = given.command;
|
|
456
|
+
pending.hostHandoff = given.handoff;
|
|
457
|
+
}
|
|
458
|
+
let command = pending.command.type === 'create_pane' ? this.paneCredentials.prepare(withZtcChildCredentials(pending.command))
|
|
459
|
+
: this.paneCredentials.prepareReplace(replacement);
|
|
516
460
|
if (command.request_id !== undefined && this.timedOutPaneRequestIds.has(command.request_id))
|
|
517
461
|
command = { ...command, request_id: randomUUID() };
|
|
518
462
|
pending.wireRequestId = command.request_id;
|
|
@@ -520,6 +464,14 @@ export class TuiProcess {
|
|
|
520
464
|
pending.timer.unref();
|
|
521
465
|
this.socket.write(serializeCommand(command) + '\n');
|
|
522
466
|
}
|
|
467
|
+
/** Remove the handoff pane PANE_ID was given when it was started again in place, if its program never took it. */
|
|
468
|
+
releaseHostHandoff(paneId) {
|
|
469
|
+
const handoff = this.hostHandoffs.get(paneId);
|
|
470
|
+
if (handoff === undefined)
|
|
471
|
+
return;
|
|
472
|
+
this.hostHandoffs.delete(paneId);
|
|
473
|
+
removeHostHandoff(handoff);
|
|
474
|
+
}
|
|
523
475
|
timeoutPaneMutation(pending) {
|
|
524
476
|
if (!this.pendingPaneCreations.has(pending) || !pending.dispatched)
|
|
525
477
|
return;
|
|
@@ -613,7 +565,7 @@ export class TuiProcess {
|
|
|
613
565
|
const runtime = options?.desktopRuntime === undefined ? loadDesktopRuntime() : options.desktopRuntime;
|
|
614
566
|
binaryPath = runtime?.rendererPath ?? this.options.desktopBinaryPath ?? getZtermBinaryPath(runtime);
|
|
615
567
|
if (!binaryPath) {
|
|
616
|
-
throw new Error(
|
|
568
|
+
throw new Error(`zterm binary not found. Build with: ${nativeProgramBuildCommand('zterm')}`);
|
|
617
569
|
}
|
|
618
570
|
if (runtime)
|
|
619
571
|
this.desktopCompatibility = { version: runtime.rendererVersion, requiredCapabilities: runtime.requiredCapabilities };
|
|
@@ -623,13 +575,13 @@ export class TuiProcess {
|
|
|
623
575
|
else if (this._muxMode) {
|
|
624
576
|
binaryPath = getZmuxBinaryPath();
|
|
625
577
|
if (!binaryPath) {
|
|
626
|
-
throw new Error('zmux
|
|
578
|
+
throw new Error(rendererMissing('zmux'));
|
|
627
579
|
}
|
|
628
580
|
}
|
|
629
581
|
else {
|
|
630
582
|
binaryPath = getBinaryPath();
|
|
631
583
|
if (!binaryPath) {
|
|
632
|
-
throw new Error('ztc-tui
|
|
584
|
+
throw new Error(rendererMissing('ztc-tui'));
|
|
633
585
|
}
|
|
634
586
|
}
|
|
635
587
|
// Generate socket path
|
|
@@ -654,8 +606,14 @@ export class TuiProcess {
|
|
|
654
606
|
if (isHeadless && !this._desktopMode)
|
|
655
607
|
spawnArgs.push('--headless');
|
|
656
608
|
// The renderer starts every pane it opens with its own environment plus the pane's: it is spawned without this
|
|
657
|
-
// process's mirror credentials, so no pane can inherit them (each pane gets its own; see PaneCredentialBroker)
|
|
658
|
-
|
|
609
|
+
// process's mirror credentials, so no pane can inherit them (each pane gets its own; see PaneCredentialBroker),
|
|
610
|
+
// and without the other credentials no pane needs (buildRendererEnv). It holds no credential a ZTC pane routes
|
|
611
|
+
// with either: the host-credential store took the grant, the platform login and the effort policy out of
|
|
612
|
+
// process.env, so a ZTC pane or colony cell is given them in its create_pane environment
|
|
613
|
+
// (withZtcChildCredentials), or in a one-time handoff when the owner starts it again in place (withZtcChildHandoff).
|
|
614
|
+
// zmux's restart_pane starts a pane's program again with what its create_pane gave it over this environment,
|
|
615
|
+
// its pane credential blank (revoked as it starts again), and refuses a ZTC pane.
|
|
616
|
+
const childEnv = withoutMirrorCredentials(buildRendererEnv(process.env));
|
|
659
617
|
Object.assign(childEnv, options?.env ?? {});
|
|
660
618
|
// The renderer hands this port to every pane it starts, whatever this process's environment names later.
|
|
661
619
|
this.rendererMirrorPort = childEnv.ZTC_MIRROR_PORT || undefined;
|
|
@@ -974,6 +932,8 @@ export class TuiProcess {
|
|
|
974
932
|
if (pending.timer)
|
|
975
933
|
clearTimeout(pending.timer);
|
|
976
934
|
this.paneCredentials.failed(pending.wireRequestId);
|
|
935
|
+
if (pending.hostHandoff)
|
|
936
|
+
removeHostHandoff(pending.hostHandoff);
|
|
977
937
|
this.pendingPaneCreations.delete(pending);
|
|
978
938
|
}
|
|
979
939
|
return false;
|
|
@@ -989,13 +949,19 @@ export class TuiProcess {
|
|
|
989
949
|
* Clean up resources
|
|
990
950
|
*/
|
|
991
951
|
cleanup() {
|
|
992
|
-
for (const pending of this.pendingPaneCreations)
|
|
952
|
+
for (const pending of this.pendingPaneCreations) {
|
|
993
953
|
if (pending.timer)
|
|
994
954
|
clearTimeout(pending.timer);
|
|
955
|
+
if (pending.hostHandoff)
|
|
956
|
+
removeHostHandoff(pending.hostHandoff);
|
|
957
|
+
}
|
|
995
958
|
this.pendingPaneCreations.clear();
|
|
996
959
|
this.ready = false;
|
|
997
960
|
// The renderer is gone, and with it every pane it opened.
|
|
998
961
|
this.paneCredentials.revokeAll();
|
|
962
|
+
for (const handoff of this.hostHandoffs.values())
|
|
963
|
+
removeHostHandoff(handoff);
|
|
964
|
+
this.hostHandoffs.clear();
|
|
999
965
|
// A torn-down socket can never deliver answers; release waiters.
|
|
1000
966
|
for (const pending of this.clipboardRequests.values()) {
|
|
1001
967
|
clearTimeout(pending.timer);
|
|
@@ -55,6 +55,12 @@ export declare const CAPABILITY_DESKTOP_RUNTIME_CHOICES = "desktop_runtime_choic
|
|
|
55
55
|
* anything else, so the main ZTC knows which pane each child connection speaks for (see PaneRelayServer).
|
|
56
56
|
*/
|
|
57
57
|
export declare const CAPABILITY_PANE_RELAY_IDENTITY = "pane_relay_identity_v1";
|
|
58
|
+
/**
|
|
59
|
+
* The pane relay's own (never a renderer's): it starts a ZTC pane a child asks for only on a launch nonce it issued for
|
|
60
|
+
* that exact launch (a `ztc_launch_nonce` line, answered with one), and any other a child asks for as a process pane
|
|
61
|
+
* (ztc_launch_trust.ts).
|
|
62
|
+
*/
|
|
63
|
+
export declare const CAPABILITY_ZTC_LAUNCH_NONCE = "ztc_launch_nonce_v1";
|
|
58
64
|
export declare const CAPABILITY_DESKTOP_SESSION_SHARE = "desktop_session_share_v1";
|
|
59
65
|
export declare const CAPABILITY_TERMINAL_FRAME_METRICS = "terminal_frame_metrics_v1";
|
|
60
66
|
export declare const CAPABILITY_TERMINAL_INTERACTION = "terminal_interaction_v1";
|
|
@@ -553,7 +559,9 @@ export type RustCommand = {
|
|
|
553
559
|
} | {
|
|
554
560
|
type: 'cancel_update_restart';
|
|
555
561
|
message: string;
|
|
556
|
-
}
|
|
562
|
+
}
|
|
563
|
+
/** `launch_nonce`: a child's, through the pane relay, which takes it off before the command goes on (ztc_launch_trust.ts). */
|
|
564
|
+
| {
|
|
557
565
|
type: 'create_pane';
|
|
558
566
|
command: string;
|
|
559
567
|
args?: string[];
|
|
@@ -568,6 +576,7 @@ export type RustCommand = {
|
|
|
568
576
|
env?: Record<string, string>;
|
|
569
577
|
request_id?: string;
|
|
570
578
|
persona?: string;
|
|
579
|
+
launch_nonce?: string;
|
|
571
580
|
} | {
|
|
572
581
|
type: 'create_feed_pane';
|
|
573
582
|
title?: string;
|
|
@@ -623,6 +632,7 @@ export type RustCommand = {
|
|
|
623
632
|
desktop_status?: boolean;
|
|
624
633
|
content?: string;
|
|
625
634
|
request_id?: string;
|
|
635
|
+
launch_nonce?: string;
|
|
626
636
|
} | {
|
|
627
637
|
type: 'list_panes';
|
|
628
638
|
} | {
|
|
@@ -26,6 +26,12 @@ export const CAPABILITY_DESKTOP_RUNTIME_CHOICES = 'desktop_runtime_choices_v1';
|
|
|
26
26
|
* anything else, so the main ZTC knows which pane each child connection speaks for (see PaneRelayServer).
|
|
27
27
|
*/
|
|
28
28
|
export const CAPABILITY_PANE_RELAY_IDENTITY = 'pane_relay_identity_v1';
|
|
29
|
+
/**
|
|
30
|
+
* The pane relay's own (never a renderer's): it starts a ZTC pane a child asks for only on a launch nonce it issued for
|
|
31
|
+
* that exact launch (a `ztc_launch_nonce` line, answered with one), and any other a child asks for as a process pane
|
|
32
|
+
* (ztc_launch_trust.ts).
|
|
33
|
+
*/
|
|
34
|
+
export const CAPABILITY_ZTC_LAUNCH_NONCE = 'ztc_launch_nonce_v1';
|
|
29
35
|
export const CAPABILITY_DESKTOP_SESSION_SHARE = 'desktop_session_share_v1';
|
|
30
36
|
export const CAPABILITY_TERMINAL_FRAME_METRICS = 'terminal_frame_metrics_v1';
|
|
31
37
|
export const CAPABILITY_TERMINAL_INTERACTION = 'terminal_interaction_v1';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which launches a pane relay's owner starts as ZTC panes, which are given its Router runtime grant
|
|
3
|
+
* (hostRouterGrantForZtcChild): those it decides are ZTC's own, never because a child of the relay says so.
|
|
4
|
+
*
|
|
5
|
+
* Every program in a pane the main ZTC runs can reach the relay's socket (relay_policy.ts), and a pane's type is only
|
|
6
|
+
* what its sender wrote. A create_pane or replace_pane that arrives through the relay as a ZTC pane (pane_type ztc or
|
|
7
|
+
* colony_ztc) therefore starts as a plain process pane, with a user subprocess's environment, unless it carries a launch
|
|
8
|
+
* nonce: one the relay issued, to that connection, a moment before, for that exact command and those exact arguments,
|
|
9
|
+
* and only for a launch that runs ZTC from the install this process runs from (ownZtcLaunch). A nonce is good once, and
|
|
10
|
+
* what it starts is the install's own program as this process found it, never the paths the client named, which it
|
|
11
|
+
* can point elsewhere once the nonce is issued, nor a motsi the client named.
|
|
12
|
+
* A ZTC pane's own pane tools ask for one as they open a ZTC pane through the relay (PaneRelayClient), as do the
|
|
13
|
+
* workspace tools of a Claude Code or Codex pane; ZTC's own launches that reach the renderer through its own transport
|
|
14
|
+
* (its agent's create_ztc_pane, the person's splits and the colony's cells) never pass through the relay.
|
|
15
|
+
*/
|
|
16
|
+
/** A ZTC entry point by its name, as a ZTC pane's command line names it. */
|
|
17
|
+
export declare const CHILD_ZTC_SCRIPT_RE: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* The entry point a ZTC pane this process opens runs: the host's ZTC_CHILD_ENTRYPOINT (a colony cell's worktree ZTC),
|
|
20
|
+
* else this process's own, else a checkout's in the working directory, for a process not started from one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveChildZtcEntrypoint(): string | null;
|
|
23
|
+
/** A program that is ZTC: a command and the arguments it starts with (its entry point, or the desktop app's CLI flag). */
|
|
24
|
+
export interface ZtcProgram {
|
|
25
|
+
readonly command: string;
|
|
26
|
+
readonly lead: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The ZTC this process launches its own ZTC panes with (panes/ztc_launch.ts buildZtcPaneLaunchCommand): the entry point
|
|
30
|
+
* its panes run (resolveChildZtcEntrypoint) and the one it runs itself, each under the Node it runs on, or a checkout's
|
|
31
|
+
* sources under the tsx beside them (npx's where there is none), and the desktop app's renderer in its CLI mode when it
|
|
32
|
+
* runs from the app.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ownZtcPrograms(): ZtcProgram[];
|
|
35
|
+
/**
|
|
36
|
+
* ZTC's own launch, as a pane relay starts it on a launch nonce (ownZtcLaunch): the command and leading arguments of the
|
|
37
|
+
* program this process runs ZTC with (ownZtcPrograms), then the rest of the arguments the client gave; and the title of
|
|
38
|
+
* the MotSi terminal the client asked to run it in, when it asked for one.
|
|
39
|
+
*/
|
|
40
|
+
export interface OwnZtcLaunch {
|
|
41
|
+
readonly command: string;
|
|
42
|
+
readonly args: readonly string[];
|
|
43
|
+
readonly motsiTitle?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The launch of ZTC from this process's install that COMMAND with ARGS asks for, or null when it asks for none: one of
|
|
47
|
+
* PROGRAMS (ownZtcPrograms) with its leading arguments, each named by the same path once links are resolved, directly
|
|
48
|
+
* or as MotSi runs it (`motsi run --title=… -- <program>`, panes/motsi.ts). What it returns names the program as this
|
|
49
|
+
* process found it, never the paths the client named, which the client could point at a program of its own once its
|
|
50
|
+
* nonce was issued; and it names no motsi, since the client's could be any program: whether a relayed ZTC pane runs
|
|
51
|
+
* inside MotSi is for the relay's owner to decide, with its own motsi (PaneRelayServer).
|
|
52
|
+
*/
|
|
53
|
+
export declare function ownZtcLaunch(command: string, args: readonly string[], programs?: readonly ZtcProgram[]): OwnZtcLaunch | null;
|
|
54
|
+
/**
|
|
55
|
+
* The launch nonces a pane relay issued: each for one connection (OWNER), one command and its arguments, good once and
|
|
56
|
+
* for LAUNCH_NONCE_MS, with the LAUNCH the relay starts on it. A nonce presented is spent whatever it is presented with.
|
|
57
|
+
*/
|
|
58
|
+
export declare class ZtcLaunchNonces<Launch> {
|
|
59
|
+
private readonly now;
|
|
60
|
+
private readonly issued;
|
|
61
|
+
constructor(now?: () => number);
|
|
62
|
+
/** A nonce for OWNER to start COMMAND with ARGS as a ZTC pane, which starts LAUNCH. */
|
|
63
|
+
issue(owner: object, command: string, args: readonly string[], launch: Launch): string;
|
|
64
|
+
/**
|
|
65
|
+
* The launch NONCE was issued for, when it was issued to OWNER for COMMAND with exactly ARGS and has not expired; null
|
|
66
|
+
* otherwise. It is spent either way.
|
|
67
|
+
*/
|
|
68
|
+
redeem(nonce: string, owner: object, command: string | undefined, args: readonly string[] | undefined): Launch | null;
|
|
69
|
+
/** Forget every nonce OWNER holds (its connection closed). */
|
|
70
|
+
forget(owner: object): void;
|
|
71
|
+
private sweep;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* What a ZTC pane a child opens through the relay keeps of the environment its command sends: the names ZTC's own pane
|
|
75
|
+
* tools send a ZTC pane (agent/tools/pane.ts childZtcPaneEnv and agentZtcPaneEnv), and only the values they send, and a
|
|
76
|
+
* request for the pane's own mirror credential, which the pane transport answers (pane_credential_broker.ts). Nothing
|
|
77
|
+
* else of it reaches the pane: not a program to preload (NODE_OPTIONS), not a PATH or another grant or Router of the
|
|
78
|
+
* child's choosing; the host's pin of the permission settings only as 1, which pins. The pane joins this relay
|
|
79
|
+
* (RELAY_PATH) when its command asks to join one. One the relay starts
|
|
80
|
+
* inside MotSi (THROUGH_MOTSI) has MotSi's terminal id blank (panes/motsi.ts MOTSI_PANE_ENV), as ZTC's own do. What this
|
|
81
|
+
* process gives one of its own ZTC panes of its grant goes in whatever the client sent: a blank for a grant that takes
|
|
82
|
+
* no effect, and explicit discovery with one that does (hostRouterGrantBlank, hostRouterGrantDiscovery), so a pane a
|
|
83
|
+
* renderer starts with this process's environment imports no plugin from where an agent writes.
|
|
84
|
+
*/
|
|
85
|
+
export declare function relayedZtcPaneEnv(env: Readonly<Record<string, string>> | undefined, relayPath: string, { throughMotsi }?: {
|
|
86
|
+
throughMotsi?: boolean;
|
|
87
|
+
}): Record<string, string>;
|