@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
package/dist/runtime_info.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { execFile, execFileSync } from 'child_process';
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import { existsSync, realpathSync } from 'fs';
|
|
4
|
+
import { GIT_DIFF_OPTIONS, GIT_PROBE_OPTIONS } from './utils/git_probe_options.js';
|
|
5
|
+
import { GIT_NO_REPOSITORY_PROGRAM_OPTIONS, gitProbesStartNoRepositoryProgram } from './utils/git_repository_programs.js';
|
|
6
|
+
import { buildGitSubprocessEnvFor } from './utils/subprocess_env.js';
|
|
4
7
|
import { getVersion } from './utils/version.js';
|
|
5
|
-
import { withoutMirrorCredentials } from './web/pane_credentials.js';
|
|
6
8
|
const STARTED_AT = new Date();
|
|
7
9
|
const GIT_TIMEOUT_MS = 2_000;
|
|
8
10
|
const DIFF_HASH_TIMEOUT_MS = 5_000;
|
|
@@ -19,28 +21,36 @@ function gitErrorText(error) {
|
|
|
19
21
|
return `${stderrText}\n${String(message ?? '')}`;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
|
-
* The environment
|
|
23
|
-
*
|
|
24
|
+
* The environment the git probes of CWD start with: a user subprocess's (buildUserSubprocessEnv), the person's
|
|
25
|
+
* environment without any of ZTC's credentials, since git starts the programs the repository's config names with it
|
|
26
|
+
* (an external diff, a clean filter), and any program running as this user can read the environment a process starts
|
|
27
|
+
* with. A CWD with a repository of its own is probed as that repository, whatever GIT_DIR or another repository
|
|
28
|
+
* variable of ZTC's environment says; one with none keeps them, as a person's vcsh or yadm work tree needs
|
|
29
|
+
* (buildGitSubprocessEnvFor). A gatherer asks once and runs every probe with it.
|
|
24
30
|
*/
|
|
25
|
-
function gitEnvironment() {
|
|
26
|
-
return
|
|
31
|
+
function gitEnvironment(cwd) {
|
|
32
|
+
return buildGitSubprocessEnvFor(cwd);
|
|
33
|
+
}
|
|
34
|
+
function gitProbeRun(cwd) {
|
|
35
|
+
return { env: gitEnvironment(cwd), barred: gitProbesStartNoRepositoryProgram() };
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* the agent's work tree cannot hand these probes its config; it is honoured from the command line, which the agent
|
|
34
|
-
* cannot write, and leaves normal work trees, linked worktrees and a cwd inside .git working.
|
|
38
|
+
* The options a probe of RUN takes first; each diff takes GIT_DIFF_OPTIONS too. The probes run in a work tree the agent
|
|
39
|
+
* writes to (at startup, and for /status and /runtime, which the agent can run too), outside any sandbox the agent works
|
|
40
|
+
* under, so under every profile they start no fsmonitor, external diff, textconv driver or signature program its config
|
|
41
|
+
* names, and read no planted implicit bare repository's config (utils/git_probe_options.ts).
|
|
35
42
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
function probeOptions(run) {
|
|
44
|
+
return run.barred ? GIT_NO_REPOSITORY_PROGRAM_OPTIONS : GIT_PROBE_OPTIONS;
|
|
45
|
+
}
|
|
46
|
+
function runGit(cwd, run, args, timeout = GIT_TIMEOUT_MS) {
|
|
47
|
+
const env = run.env;
|
|
38
48
|
try {
|
|
39
|
-
const output = execFileSync('git', [...
|
|
49
|
+
const output = execFileSync('git', [...probeOptions(run), ...args], {
|
|
40
50
|
cwd,
|
|
41
51
|
encoding: 'utf8',
|
|
42
52
|
timeout,
|
|
43
|
-
env
|
|
53
|
+
env,
|
|
44
54
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
45
55
|
// Leading spaces carry meaning: porcelain's " M file" is unstaged, and a full trim once turned it into a staged
|
|
46
56
|
// "M nventory/..." for the model (2026-10-27).
|
|
@@ -156,14 +166,18 @@ function statusHasChanges(status) {
|
|
|
156
166
|
return status.ok && status.output !== '';
|
|
157
167
|
}
|
|
158
168
|
function gatherGitOutputsSync(cwd, includeDirtyHash) {
|
|
159
|
-
const
|
|
169
|
+
const run = gitProbeRun(cwd);
|
|
170
|
+
const root = runGit(cwd, run, ['rev-parse', '--show-toplevel']);
|
|
160
171
|
if (!root.ok)
|
|
161
172
|
return { root, head: null, branch: null, status: null, staged: null, unstaged: null };
|
|
162
|
-
const head = runGit(cwd, ['rev-parse', 'HEAD']);
|
|
173
|
+
const head = runGit(cwd, run, ['rev-parse', 'HEAD']);
|
|
163
174
|
if (!head.ok)
|
|
164
175
|
return { root, head, branch: null, status: null, staged: null, unstaged: null };
|
|
165
|
-
const branch = runGit(cwd, ['branch', '--show-current']);
|
|
166
|
-
|
|
176
|
+
const branch = runGit(cwd, run, ['branch', '--show-current']);
|
|
177
|
+
// A status runs the repository's clean filter on a changed file, and its index write a hook: not read (see GitProbeRun).
|
|
178
|
+
if (run.barred)
|
|
179
|
+
return { root, head, branch, status: null, staged: null, unstaged: null };
|
|
180
|
+
const status = runGit(cwd, run, ['status', '--porcelain=v1']);
|
|
167
181
|
if (!statusHasChanges(status) || !includeDirtyHash) {
|
|
168
182
|
return { root, head, branch, status, staged: null, unstaged: null };
|
|
169
183
|
}
|
|
@@ -172,8 +186,8 @@ function gatherGitOutputsSync(cwd, includeDirtyHash) {
|
|
|
172
186
|
head,
|
|
173
187
|
branch,
|
|
174
188
|
status,
|
|
175
|
-
staged: runGit(cwd, ['diff', '--cached', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
176
|
-
unstaged: runGit(cwd, ['diff', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
189
|
+
staged: runGit(cwd, run, ['diff', ...GIT_DIFF_OPTIONS, '--cached', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
190
|
+
unstaged: runGit(cwd, run, ['diff', ...GIT_DIFF_OPTIONS, '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
177
191
|
};
|
|
178
192
|
}
|
|
179
193
|
/**
|
|
@@ -184,9 +198,9 @@ function gatherGitOutputsSync(cwd, includeDirtyHash) {
|
|
|
184
198
|
* spawn and handshake, which is why the prefetch must use this runner instead:
|
|
185
199
|
* the scan has to overlap startup, not cut through it.
|
|
186
200
|
*/
|
|
187
|
-
function runGitAsync(cwd, args, timeout = GIT_TIMEOUT_MS) {
|
|
201
|
+
function runGitAsync(cwd, run, args, timeout = GIT_TIMEOUT_MS) {
|
|
188
202
|
return new Promise((resolve) => {
|
|
189
|
-
execFile('git', [...
|
|
203
|
+
execFile('git', [...probeOptions(run), ...args], { cwd, encoding: 'utf8', timeout, env: run.env }, (error, stdout) => {
|
|
190
204
|
if (error) {
|
|
191
205
|
const failure = /not a git repository/i.test(gitErrorText(error)) ? 'not_repository' : 'unknown';
|
|
192
206
|
resolve({ ok: false, failure });
|
|
@@ -205,17 +219,19 @@ function runGitAsync(cwd, args, timeout = GIT_TIMEOUT_MS) {
|
|
|
205
219
|
* same way the synchronous chain reads them.
|
|
206
220
|
*/
|
|
207
221
|
async function gatherGitOutputsAsync(cwd, includeDirtyHash) {
|
|
222
|
+
const run = gitProbeRun(cwd);
|
|
208
223
|
const [root, head, branch, status] = await Promise.all([
|
|
209
|
-
runGitAsync(cwd, ['rev-parse', '--show-toplevel']),
|
|
210
|
-
runGitAsync(cwd, ['rev-parse', 'HEAD']),
|
|
211
|
-
runGitAsync(cwd, ['branch', '--show-current']),
|
|
212
|
-
|
|
224
|
+
runGitAsync(cwd, run, ['rev-parse', '--show-toplevel']),
|
|
225
|
+
runGitAsync(cwd, run, ['rev-parse', 'HEAD']),
|
|
226
|
+
runGitAsync(cwd, run, ['branch', '--show-current']),
|
|
227
|
+
// Not read where the agent may have written the repository's config (see GitProbeRun).
|
|
228
|
+
run.barred ? Promise.resolve(null) : runGitAsync(cwd, run, ['status', '--porcelain=v1']),
|
|
213
229
|
]);
|
|
214
230
|
if (!root.ok)
|
|
215
231
|
return { root, head: null, branch: null, status: null, staged: null, unstaged: null };
|
|
216
232
|
if (!head.ok)
|
|
217
233
|
return { root, head, branch: null, status: null, staged: null, unstaged: null };
|
|
218
|
-
if (!statusHasChanges(status) || !includeDirtyHash) {
|
|
234
|
+
if (status === null || !statusHasChanges(status) || !includeDirtyHash) {
|
|
219
235
|
return { root, head, branch, status, staged: null, unstaged: null };
|
|
220
236
|
}
|
|
221
237
|
return {
|
|
@@ -223,8 +239,8 @@ async function gatherGitOutputsAsync(cwd, includeDirtyHash) {
|
|
|
223
239
|
head,
|
|
224
240
|
branch,
|
|
225
241
|
status,
|
|
226
|
-
staged: await runGitAsync(cwd, ['diff', '--cached', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
227
|
-
unstaged: await runGitAsync(cwd, ['diff', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
242
|
+
staged: await runGitAsync(cwd, run, ['diff', ...GIT_DIFF_OPTIONS, '--cached', '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
243
|
+
unstaged: await runGitAsync(cwd, run, ['diff', ...GIT_DIFF_OPTIONS, '--binary'], DIFF_HASH_TIMEOUT_MS),
|
|
228
244
|
};
|
|
229
245
|
}
|
|
230
246
|
function probeGit(cwd, includeDirtyHash) {
|
|
@@ -237,18 +253,20 @@ function mainBranchName(symbolic, mainExists, masterExists) {
|
|
|
237
253
|
return !mainExists && masterExists ? 'master' : 'main';
|
|
238
254
|
}
|
|
239
255
|
function gatherPromptContextSync(cwd) {
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
256
|
+
const run = gitProbeRun(cwd);
|
|
257
|
+
const symbolic = runGit(cwd, run, ['symbolic-ref', 'refs/remotes/origin/HEAD']);
|
|
258
|
+
const mainExists = !symbolic.ok && runGit(cwd, run, ['rev-parse', '--verify', 'main']).ok;
|
|
259
|
+
const masterExists = !symbolic.ok && !mainExists && runGit(cwd, run, ['rev-parse', '--verify', 'master']).ok;
|
|
260
|
+
const log = runGit(cwd, run, ['log', '--oneline', '-5']);
|
|
244
261
|
return { mainBranch: mainBranchName(symbolic, mainExists, masterExists), recentCommits: log.ok ? log.output : '' };
|
|
245
262
|
}
|
|
246
263
|
async function gatherPromptContextAsync(cwd) {
|
|
264
|
+
const run = gitProbeRun(cwd);
|
|
247
265
|
const [symbolic, main, master, log] = await Promise.all([
|
|
248
|
-
runGitAsync(cwd, ['symbolic-ref', 'refs/remotes/origin/HEAD']),
|
|
249
|
-
runGitAsync(cwd, ['rev-parse', '--verify', 'main']),
|
|
250
|
-
runGitAsync(cwd, ['rev-parse', '--verify', 'master']),
|
|
251
|
-
runGitAsync(cwd, ['log', '--oneline', '-5']),
|
|
266
|
+
runGitAsync(cwd, run, ['symbolic-ref', 'refs/remotes/origin/HEAD']),
|
|
267
|
+
runGitAsync(cwd, run, ['rev-parse', '--verify', 'main']),
|
|
268
|
+
runGitAsync(cwd, run, ['rev-parse', '--verify', 'master']),
|
|
269
|
+
runGitAsync(cwd, run, ['log', '--oneline', '-5']),
|
|
252
270
|
]);
|
|
253
271
|
return { mainBranch: mainBranchName(symbolic, main.ok, master.ok), recentCommits: log.ok ? log.output : '' };
|
|
254
272
|
}
|
package/dist/session.js
CHANGED
|
@@ -225,6 +225,16 @@ function isCompactionTitle(title) {
|
|
|
225
225
|
// Includes the truncated 50-character title written by older versions.
|
|
226
226
|
return typeof title === 'string' && title.startsWith('[Conversation summary');
|
|
227
227
|
}
|
|
228
|
+
/** How long a title taken from a prompt is: past it, the prompt is cut there. */
|
|
229
|
+
const PROMPT_TITLE_LENGTH = 50;
|
|
230
|
+
/**
|
|
231
|
+
* PROMPT as a session's title: whole when it is PROMPT_TITLE_LENGTH characters or fewer, else cut there with an
|
|
232
|
+
* ellipsis saying so. A title is shown wherever sessions are listed (/sessions among them), perhaps to a read-only
|
|
233
|
+
* observer of the mirror, which withholds what may start a credential before the mark.
|
|
234
|
+
*/
|
|
235
|
+
function promptTitle(prompt) {
|
|
236
|
+
return prompt.length > PROMPT_TITLE_LENGTH ? `${prompt.slice(0, PROMPT_TITLE_LENGTH)}…` : prompt;
|
|
237
|
+
}
|
|
228
238
|
/** Recover only the explicit original-user record in the local summary format. */
|
|
229
239
|
function titleFromCompactedStart(content, depth = 0) {
|
|
230
240
|
if (depth >= 8)
|
|
@@ -238,7 +248,7 @@ function titleFromCompactedStart(content, depth = 0) {
|
|
|
238
248
|
return undefined;
|
|
239
249
|
return isCompactionTitle(parsed.content)
|
|
240
250
|
? titleFromCompactedStart(parsed.content, depth + 1)
|
|
241
|
-
: parsed.content
|
|
251
|
+
: promptTitle(parsed.content) || undefined;
|
|
242
252
|
}
|
|
243
253
|
catch {
|
|
244
254
|
// A bounded summary may have elided this record. Use surviving dialogue.
|
|
@@ -260,7 +270,7 @@ function deriveSessionTitle(messages, previousTitle) {
|
|
|
260
270
|
return recovered;
|
|
261
271
|
}
|
|
262
272
|
else if (message.content) {
|
|
263
|
-
return message.content
|
|
273
|
+
return promptTitle(message.content);
|
|
264
274
|
}
|
|
265
275
|
}
|
|
266
276
|
return 'Untitled session';
|
package/dist/shannon/runtime.js
CHANGED
|
@@ -4,6 +4,7 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeF
|
|
|
4
4
|
import { open } from 'fs/promises';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { join } from 'path';
|
|
7
|
+
import { buildModelClientSubprocessEnv } from '../utils/subprocess_env.js';
|
|
7
8
|
const MAX_LOG_LINES = 2000;
|
|
8
9
|
const MAX_EVENTS = 2000;
|
|
9
10
|
const STATE_DIR = join(homedir(), '.ztc', 'shannon_runner');
|
|
@@ -74,11 +75,21 @@ class ShannonRuntime {
|
|
|
74
75
|
errFd = await open(LOG_FILE, 'a');
|
|
75
76
|
const child = spawn(this.command, this.args, {
|
|
76
77
|
cwd: this.cwd,
|
|
77
|
-
|
|
78
|
+
// The runner is Shannon's, a model client of its own: the person's environment and provider keys, its own
|
|
79
|
+
// options, and none of ZTC's credentials (its mirror's secret and token among them, which /shannon-runner logs
|
|
80
|
+
// would print).
|
|
81
|
+
env: { ...buildModelClientSubprocessEnv(process.env), ...(options.env || {}) },
|
|
78
82
|
shell: false,
|
|
79
83
|
detached: true,
|
|
80
84
|
stdio: ['ignore', out.fd, errFd.fd],
|
|
81
85
|
});
|
|
86
|
+
// Node reports a command it cannot start (no such program, or one that is not executable) as an 'error' event
|
|
87
|
+
// once spawn has returned, not as a throw, and an 'error' event that nothing listens for ends ZTC: wait until the
|
|
88
|
+
// runner has started or failed to, so a failure is reported below as one thrown here is.
|
|
89
|
+
await new Promise((resolve, reject) => {
|
|
90
|
+
child.once('spawn', () => resolve());
|
|
91
|
+
child.on('error', reject);
|
|
92
|
+
});
|
|
82
93
|
child.unref();
|
|
83
94
|
this.status = 'running';
|
|
84
95
|
this.appendLog(`[runner] running (pid=${child.pid})`, true);
|
|
@@ -97,6 +108,7 @@ class ShannonRuntime {
|
|
|
97
108
|
catch (err) {
|
|
98
109
|
this.status = 'error';
|
|
99
110
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
111
|
+
this.appendLog(`[runner] failed to start: ${this.lastError}`, true);
|
|
100
112
|
this.setPersistedState({
|
|
101
113
|
status: 'error',
|
|
102
114
|
pid: null,
|
|
@@ -41,7 +41,8 @@ export declare function getDomainSearchRoots(): string[];
|
|
|
41
41
|
/**
|
|
42
42
|
* Resolve a domain name to a concrete YAML file path by scanning the search roots.
|
|
43
43
|
* Tries both {root}/{name}/{name}.yaml (directory layout) and {root}/{name}.yaml (flat).
|
|
44
|
-
* Returns null when nothing is found; caller throws with a helpful message.
|
|
44
|
+
* Returns null when nothing is found; caller throws with a helpful message. Under explicit extension discovery a name
|
|
45
|
+
* that is a path (isDomainPath) finds nothing: joined onto a root, it would name a file outside every root.
|
|
45
46
|
*/
|
|
46
47
|
export declare function resolveDomainYamlPath(name: string): {
|
|
47
48
|
yamlPath: string;
|
|
@@ -12,7 +12,7 @@ import { extensionPathsFromEnvironment, isExplicitExtensionDiscovery, } from '..
|
|
|
12
12
|
import { createRequire } from 'node:module';
|
|
13
13
|
import { closeSync, openSync, readSync, readFileSync, existsSync } from 'node:fs';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { resolve, dirname, join } from 'node:path';
|
|
15
|
+
import { resolve, dirname, join, isAbsolute } from 'node:path';
|
|
16
16
|
import { homedir } from 'node:os';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
18
18
|
import { getBuiltinHandler } from './handlers/registry.js';
|
|
@@ -389,12 +389,27 @@ export function getDomainSearchRoots() {
|
|
|
389
389
|
roots.push(thisDir);
|
|
390
390
|
return roots;
|
|
391
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Whether NAME, a domain's, is a path rather than a name: it has a folder separator or a drive, or is `.` or `..`. Joined
|
|
394
|
+
* onto a search root, such a name names a file outside it.
|
|
395
|
+
*/
|
|
396
|
+
function isDomainPath(name) {
|
|
397
|
+
return name === '.' || name === '..' || isAbsolute(name) || /[\\/:]/.test(name);
|
|
398
|
+
}
|
|
399
|
+
/** Why DomainFactory.load finds no domain named by a path under explicit discovery (isDomainPath). */
|
|
400
|
+
function domainPathRefusal(name) {
|
|
401
|
+
return `Domain "${name}" is named by a path; under explicit extension discovery a domain is found only by its name, in `
|
|
402
|
+
+ 'ZTC_DOMAIN_PATHS and ZTC\'s own domains.';
|
|
403
|
+
}
|
|
392
404
|
/**
|
|
393
405
|
* Resolve a domain name to a concrete YAML file path by scanning the search roots.
|
|
394
406
|
* Tries both {root}/{name}/{name}.yaml (directory layout) and {root}/{name}.yaml (flat).
|
|
395
|
-
* Returns null when nothing is found; caller throws with a helpful message.
|
|
407
|
+
* Returns null when nothing is found; caller throws with a helpful message. Under explicit extension discovery a name
|
|
408
|
+
* that is a path (isDomainPath) finds nothing: joined onto a root, it would name a file outside every root.
|
|
396
409
|
*/
|
|
397
410
|
export function resolveDomainYamlPath(name) {
|
|
411
|
+
if (isExplicitExtensionDiscovery() && isDomainPath(name))
|
|
412
|
+
return { yamlPath: null, tried: [] };
|
|
398
413
|
const tried = [];
|
|
399
414
|
for (const root of getDomainSearchRoots()) {
|
|
400
415
|
const dirPath = resolve(root, name, `${name}.yaml`);
|
|
@@ -446,6 +461,8 @@ export class DomainFactory {
|
|
|
446
461
|
* the process lifetime.
|
|
447
462
|
*/
|
|
448
463
|
static load(name) {
|
|
464
|
+
if (isExplicitExtensionDiscovery() && isDomainPath(name))
|
|
465
|
+
throw new Error(domainPathRefusal(name));
|
|
449
466
|
const cached = loadedPresets.get(name);
|
|
450
467
|
// Return a clone so bootstrap mutations (e.g., eventArtifactMap, sentimentByType)
|
|
451
468
|
// don't leak across games in a long-running lobby server.
|
|
@@ -157,7 +157,7 @@ export declare function gameMasterAttemptInput(state: LivingState, actorId: stri
|
|
|
157
157
|
id: string;
|
|
158
158
|
toId: string;
|
|
159
159
|
topic: string;
|
|
160
|
-
status: "refused" | "
|
|
160
|
+
status: "refused" | "done" | "open" | "answered";
|
|
161
161
|
}[];
|
|
162
162
|
recentHere: {
|
|
163
163
|
at: string;
|
|
@@ -394,7 +394,7 @@ export declare function gameMasterAttemptInput(state: LivingState, actorId: stri
|
|
|
394
394
|
id: string;
|
|
395
395
|
toId: string;
|
|
396
396
|
topic: string;
|
|
397
|
-
status: "refused" | "
|
|
397
|
+
status: "refused" | "done" | "open" | "answered";
|
|
398
398
|
}[];
|
|
399
399
|
recentHere: {
|
|
400
400
|
at: string;
|
|
@@ -636,7 +636,7 @@ export declare function gameMasterAttemptInput(state: LivingState, actorId: stri
|
|
|
636
636
|
id: string;
|
|
637
637
|
toId: string;
|
|
638
638
|
topic: string;
|
|
639
|
-
status: "refused" | "
|
|
639
|
+
status: "refused" | "done" | "open" | "answered";
|
|
640
640
|
}[];
|
|
641
641
|
recentHere: {
|
|
642
642
|
at: string;
|
|
@@ -880,7 +880,7 @@ export declare function gameMasterAttemptInput(state: LivingState, actorId: stri
|
|
|
880
880
|
id: string;
|
|
881
881
|
toId: string;
|
|
882
882
|
topic: string;
|
|
883
|
-
status: "refused" | "
|
|
883
|
+
status: "refused" | "done" | "open" | "answered";
|
|
884
884
|
}[];
|
|
885
885
|
recentHere: {
|
|
886
886
|
at: string;
|
|
@@ -2062,7 +2062,7 @@ export declare function characterMind(state: LivingState, person: LivingPerson,
|
|
|
2062
2062
|
fromId: string;
|
|
2063
2063
|
toId: string;
|
|
2064
2064
|
topic: string;
|
|
2065
|
-
status: "refused" | "
|
|
2065
|
+
status: "refused" | "done" | "open" | "answered";
|
|
2066
2066
|
}[];
|
|
2067
2067
|
stances: {
|
|
2068
2068
|
actorId: string;
|
|
@@ -2319,7 +2319,7 @@ export declare function characterReactionInput(state: LivingState, person: Livin
|
|
|
2319
2319
|
fromId: string;
|
|
2320
2320
|
toId: string;
|
|
2321
2321
|
topic: string;
|
|
2322
|
-
status: "refused" | "
|
|
2322
|
+
status: "refused" | "done" | "open" | "answered";
|
|
2323
2323
|
}[];
|
|
2324
2324
|
stances: {
|
|
2325
2325
|
actorId: string;
|
|
@@ -2583,7 +2583,7 @@ export declare function characterPlanInput(state: LivingState, person: LivingPer
|
|
|
2583
2583
|
fromId: string;
|
|
2584
2584
|
toId: string;
|
|
2585
2585
|
topic: string;
|
|
2586
|
-
status: "refused" | "
|
|
2586
|
+
status: "refused" | "done" | "open" | "answered";
|
|
2587
2587
|
}[];
|
|
2588
2588
|
stances: {
|
|
2589
2589
|
actorId: string;
|
|
@@ -2804,7 +2804,7 @@ export declare function characterMessageReplyInput(state: LivingState, person: L
|
|
|
2804
2804
|
fromId: string;
|
|
2805
2805
|
toId: string;
|
|
2806
2806
|
topic: string;
|
|
2807
|
-
status: "refused" | "
|
|
2807
|
+
status: "refused" | "done" | "open" | "answered";
|
|
2808
2808
|
}[];
|
|
2809
2809
|
stances: {
|
|
2810
2810
|
actorId: string;
|
|
@@ -376,8 +376,8 @@ export declare const requestSchema: z.ZodObject<{
|
|
|
376
376
|
topic: z.ZodString;
|
|
377
377
|
status: z.ZodEnum<{
|
|
378
378
|
refused: "refused";
|
|
379
|
-
open: "open";
|
|
380
379
|
done: "done";
|
|
380
|
+
open: "open";
|
|
381
381
|
answered: "answered";
|
|
382
382
|
}>;
|
|
383
383
|
openedSeq: z.ZodNumber;
|
|
@@ -1817,8 +1817,8 @@ export declare const stateSchema: z.ZodObject<{
|
|
|
1817
1817
|
topic: z.ZodString;
|
|
1818
1818
|
status: z.ZodEnum<{
|
|
1819
1819
|
refused: "refused";
|
|
1820
|
-
open: "open";
|
|
1821
1820
|
done: "done";
|
|
1821
|
+
open: "open";
|
|
1822
1822
|
answered: "answered";
|
|
1823
1823
|
}>;
|
|
1824
1824
|
openedSeq: z.ZodNumber;
|
|
@@ -50,7 +50,8 @@ export declare class ZeroEmbeddingProvider implements EmbeddingProvider {
|
|
|
50
50
|
* A simulation's embeddings, from the first of: an embedding key or endpoint its world configures; its own route when
|
|
51
51
|
* that serves embeddings, OpenAI with its key or a custom endpoint with its key and base URL (see
|
|
52
52
|
* resolveSimulationInference); the ZergAI platform's own proxy, with the platform login, as ZTC's own completions use it
|
|
53
|
-
* (configStore.getPlatformProxyLogin: no other Router, Zerg Router's own origin included, ever gets that login)
|
|
53
|
+
* (configStore.getPlatformProxyLogin: no other Router, Zerg Router's own origin included, ever gets that login); the
|
|
54
|
+
* Router the host named, with the host's Router runtime grant (configStore.getHostRouterGrant: no other address gets it).
|
|
54
55
|
* Without any, memory stays lexical, no request is made, and `onNotice` hears why and how to give it embeddings (the
|
|
55
56
|
* simulation says it once). Another provider's key never reaches an embeddings endpoint, and OPENAI_API_KEY is not
|
|
56
57
|
* picked on its own for a route that is not OpenAI's: it never worked while a provider key was set (that key went
|
|
@@ -15,6 +15,7 @@ import { resolveSimulationInference } from '../inference.js';
|
|
|
15
15
|
import { routerAccount, routerRefusalGate } from '../../agent/backends/router_gate.js';
|
|
16
16
|
import { endingRouterRefusal, readRouterRefusal } from '../../agent/backends/router_refusal.js';
|
|
17
17
|
import { noteRouterRequest } from '../../agent/backends/router_requests.js';
|
|
18
|
+
import { MODEL_REQUEST_REDIRECT, refuseModelRedirect } from '../../agent/backends/model_redirect.js';
|
|
18
19
|
const EMBEDDING_MODEL = 'text-embedding-3-small';
|
|
19
20
|
/** Fallback zero vector for when embedding API is unavailable (1536 dims for text-embedding-3-small) */
|
|
20
21
|
const ZERO_VEC = new Array(1536).fill(0);
|
|
@@ -62,11 +63,14 @@ export class OpenAIEmbeddingProvider {
|
|
|
62
63
|
},
|
|
63
64
|
body: JSON.stringify({ input: texts, model: this.model }),
|
|
64
65
|
signal: controller.signal,
|
|
66
|
+
redirect: MODEL_REQUEST_REDIRECT,
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
finally {
|
|
68
70
|
clearTimeout(timeout);
|
|
69
71
|
}
|
|
72
|
+
// The texts go to no other address, and the endpoint would only redirect them again.
|
|
73
|
+
await refuseModelRedirect(response, `${this.baseUrl}/embeddings`);
|
|
70
74
|
if (response.ok) {
|
|
71
75
|
const data = (await response.json());
|
|
72
76
|
if (this.router)
|
|
@@ -204,11 +208,24 @@ function platformProxyRoute(inference) {
|
|
|
204
208
|
const login = configStore.getPlatformProxyLogin(inference.router.proxyUrl);
|
|
205
209
|
return login?.token === inference.router.authToken ? login : undefined;
|
|
206
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The host's Router runtime grant, where it goes (configStore.getHostRouterGrant): on the configured Router, when the
|
|
213
|
+
* route is not direct; on a waiting profile (INFERENCE given), when the route this run chose goes through Router on it.
|
|
214
|
+
*/
|
|
215
|
+
function hostGrantRoute(inference) {
|
|
216
|
+
if (!inference)
|
|
217
|
+
return configStore.getAuthMode() !== 'direct' ? configStore.getHostRouterGrant() : undefined;
|
|
218
|
+
if (!inference.router)
|
|
219
|
+
return undefined;
|
|
220
|
+
const grant = configStore.getHostRouterGrant(inference.router.proxyUrl);
|
|
221
|
+
return grant?.token === inference.router.authToken ? grant : undefined;
|
|
222
|
+
}
|
|
207
223
|
/**
|
|
208
224
|
* A simulation's embeddings, from the first of: an embedding key or endpoint its world configures; its own route when
|
|
209
225
|
* that serves embeddings, OpenAI with its key or a custom endpoint with its key and base URL (see
|
|
210
226
|
* resolveSimulationInference); the ZergAI platform's own proxy, with the platform login, as ZTC's own completions use it
|
|
211
|
-
* (configStore.getPlatformProxyLogin: no other Router, Zerg Router's own origin included, ever gets that login)
|
|
227
|
+
* (configStore.getPlatformProxyLogin: no other Router, Zerg Router's own origin included, ever gets that login); the
|
|
228
|
+
* Router the host named, with the host's Router runtime grant (configStore.getHostRouterGrant: no other address gets it).
|
|
212
229
|
* Without any, memory stays lexical, no request is made, and `onNotice` hears why and how to give it embeddings (the
|
|
213
230
|
* simulation says it once). Another provider's key never reaches an embeddings endpoint, and OPENAI_API_KEY is not
|
|
214
231
|
* picked on its own for a route that is not OpenAI's: it never worked while a provider key was set (that key went
|
|
@@ -243,11 +260,13 @@ export function createEmbeddingProvider(cache, world, onNotice) {
|
|
|
243
260
|
return new CachedEmbeddingProvider(embeddings, cache);
|
|
244
261
|
}
|
|
245
262
|
// A session signed in to the ZergAI platform embeds through the platform's own proxy, the one place its login goes;
|
|
246
|
-
// on
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
263
|
+
// a resident on its host's Router runtime grant, through the Router the host named, the one place the grant goes. On
|
|
264
|
+
// a waiting profile, either only when the route this run chose goes there on that credential.
|
|
265
|
+
const waiting = configStore.retiredRouteAwaitingChoice() !== undefined;
|
|
266
|
+
const platform = !waiting ? configStore.getPlatformProxyLogin(configStore.get().zergProxyUrl) : platformProxyRoute(inference);
|
|
267
|
+
const routed = platform ?? (!waiting ? hostGrantRoute() : hostGrantRoute(inference));
|
|
268
|
+
if (routed) {
|
|
269
|
+
const embeddings = new OpenAIEmbeddingProvider(routed.token, `${routed.origin}/v1`, model, routed.origin);
|
|
251
270
|
return new CachedEmbeddingProvider(embeddings, cache);
|
|
252
271
|
}
|
|
253
272
|
onNotice?.(withoutEmbeddingsNotice(inference.provider, inference.model, configStore.retiredRouteAwaitingChoice() !== undefined));
|
package/dist/terminal_attach.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Durable terminal attachment through local tmux or authenticated OpenSSH. */
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
|
+
import { buildUserSubprocessEnv } from './utils/subprocess_env.js';
|
|
3
4
|
import { resolve } from 'node:path';
|
|
4
5
|
const HELP = `Usage: ztc attach --session <tmux-session> [--ssh <host>] [--ssh-config <file>] [--read-only] [--no-reconnect]
|
|
5
6
|
|
|
@@ -76,7 +77,7 @@ export async function runTerminalAttachCli(args) {
|
|
|
76
77
|
const limit = host && reconnect ? 4 : 1;
|
|
77
78
|
for (let attempt = 0; attempt < limit; attempt++) {
|
|
78
79
|
const code = await new Promise(resolveExit => {
|
|
79
|
-
const child = spawn(executable, command, { stdio: 'inherit' });
|
|
80
|
+
const child = spawn(executable, command, { stdio: 'inherit', env: buildUserSubprocessEnv() });
|
|
80
81
|
let interrupted = null;
|
|
81
82
|
let forceStop = null;
|
|
82
83
|
const stop = (signal, exitCode) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -197,6 +197,16 @@ export interface Message {
|
|
|
197
197
|
* read while sign-in is off: it carries the mirror's own link and credential (/mirror's messages).
|
|
198
198
|
*/
|
|
199
199
|
localOnly?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* The note that stands in for each image the person attached to this message in every request, since Zerg Router
|
|
202
|
+
* refused them as costs it can't price under a spending limit (agent/attached_images.ts withheldAttachedImages).
|
|
203
|
+
*/
|
|
204
|
+
withheldImages?: string;
|
|
205
|
+
/**
|
|
206
|
+
* The media types of this message's images that still go when withheldImages is set (those Router prices on the
|
|
207
|
+
* route, such as PNG for OpenAI's models); without it, the note stands in for every one of them.
|
|
208
|
+
*/
|
|
209
|
+
keptImageTypes?: string[];
|
|
200
210
|
};
|
|
201
211
|
attachments?: MessageAttachment[];
|
|
202
212
|
widget?: FormWidgetData;
|
|
@@ -407,6 +417,17 @@ export type AgentEvent = {
|
|
|
407
417
|
type: 'notice';
|
|
408
418
|
message: string;
|
|
409
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Zerg Router took a request only once it went with NOTE in place of the images the person attached that it can't
|
|
422
|
+
* price under a spending limit (all but those of a media type in KEEP): the host puts NOTE in their place in its
|
|
423
|
+
* transcript and saved session (agent/attached_images.ts withheldAttachedImages), so no later turn or resumed session
|
|
424
|
+
* sends them again.
|
|
425
|
+
*/
|
|
426
|
+
| {
|
|
427
|
+
type: 'attached_images_withheld';
|
|
428
|
+
note: string; /** The media types of the person's images that still go: none when absent. */
|
|
429
|
+
keep?: string[];
|
|
430
|
+
}
|
|
410
431
|
/** `fatal`: the run throws this error right after the event, so a host that retries the turn may hold it back. */
|
|
411
432
|
| {
|
|
412
433
|
type: 'error';
|
|
@@ -6,10 +6,13 @@ export declare function encodeZtcPaneInput(input: string): string;
|
|
|
6
6
|
* Compute the env a managed pane child is spawned with.
|
|
7
7
|
*
|
|
8
8
|
* colony_ztc panes are framework children and inherit the full parent env,
|
|
9
|
-
* except the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* except the credentials of ZTC's that a cell never needs
|
|
10
|
+
* (withoutZtcCredentials ztcChild): the parent's mirror credentials, since each
|
|
11
|
+
* pane is given a credential of its own by PaneCredentialBroker (a ZTC pane or
|
|
12
|
+
* a workspace monitor in a one-time file its arguments name, any other pane in
|
|
13
|
+
* `commandEnv`), the host's approval token and a runtime session secret. A
|
|
14
|
+
* cell is a ZTC: it keeps the Router grant it infers with (ZTC_AUTH_TOKEN) and
|
|
15
|
+
* its host's RPC transport.
|
|
13
16
|
* Every other pane type runs as a user subprocess: ZTC infra vars
|
|
14
17
|
* (ZTC_MIRROR_PORT, ZTC_PANE_RELAY, ...) are stripped via
|
|
15
18
|
* buildUserSubprocessEnv so nested user processes don't inherit the parent's
|
|
@@ -20,12 +23,15 @@ export declare function encodeZtcPaneInput(input: string): string;
|
|
|
20
23
|
* inference credentials are removed from every pane except `ztc` panes, which
|
|
21
24
|
* infer for themselves and reserve them again for their own tool children.
|
|
22
25
|
* A host's effort policy (ZTC_EFFORT_POLICY_URL and its token) reaches `ztc`
|
|
23
|
-
* panes and colony cells as a pair, both or neither, and no other pane.
|
|
26
|
+
* panes and colony cells as a pair, both or neither, and no other pane. So
|
|
27
|
+
* does the host's Router runtime grant, with the Router it names
|
|
28
|
+
* (hostRouterGrantForZtcChild), when it takes effect: merged last, so no
|
|
29
|
+
* `commandEnv` sends it elsewhere.
|
|
24
30
|
*/
|
|
25
31
|
export declare function computePaneSpawnEnv(paneType: string, paneId: number, options?: {
|
|
26
32
|
persona?: string;
|
|
27
33
|
commandEnv?: Record<string, string>;
|
|
28
|
-
},
|
|
34
|
+
}, ownEnvironment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
29
35
|
/**
|
|
30
36
|
* Inverse of encodeZtcPaneInput: recover the original input from a stdin line a
|
|
31
37
|
* ZTC pane child receives from its parent. The RatatuiApp pane reader must call
|