@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/cli_ratatui.js
CHANGED
|
@@ -4,6 +4,9 @@ import { buildWorkspaceMonitorLaunch, loadWorkspacePreset } from './app/workspac
|
|
|
4
4
|
import { DesktopDaily, nativeChoices, canResumeNative, safeDailyMessage } from './desktop/daily/desktop_wiring.js';
|
|
5
5
|
import { parseNativeRecords } from './desktop/daily/native_records.js';
|
|
6
6
|
import { environmentOperationInProgress } from './agent/commands/environment.js';
|
|
7
|
+
import { withheldAttachedImages } from './agent/attached_images.js';
|
|
8
|
+
import { pinnedRoute, pinnedRouteCommandRefusal, pinnedRouteMessage, pinnedRoutingRefusal, routingEnvOverride } from './config/model_pin.js';
|
|
9
|
+
import { isPinFolder, permissionPinChildEnv, pinnedRestartFolderMessage, pinnedRestartMessage, pinnedSettingsARestartWouldTake } from './config/permission_pin.js';
|
|
7
10
|
import { terminateActiveShellChildren } from './utils/shell.js';
|
|
8
11
|
import { getEnvironment, openEnvironment, releaseEnvironment, describeEnvironmentForAgent, isEnvironmentWorkspacePath } from './environment/store.js';
|
|
9
12
|
import { readPaneLabels, sessionNamePaneTitle } from './panes/labels.js';
|
|
@@ -12,7 +15,7 @@ import { layoutChangeEffects } from './app/layout_change.js';
|
|
|
12
15
|
import { workspacePaneTopology } from './app/workspace_topology.js';
|
|
13
16
|
import { listCommandJobs, shutdownCommandJobs, subscribeCommandJobs } from './agent/runtime/command_jobs.js';
|
|
14
17
|
import { CommandPaneManager, commandPaneText } from './agent/runtime/command_panes.js';
|
|
15
|
-
import { isPaneRefusalFor, waitForPaneCreatedOrError } from './agent/tools/pane.js';
|
|
18
|
+
import { getMuxTransport, isPaneRefusalFor, waitForPaneCreatedOrError } from './agent/tools/pane.js';
|
|
16
19
|
import { AGENT_CLIS, findAgentCli } from './panes/agent_cli.js';
|
|
17
20
|
import { openResumedAgentPane, openedSessionLine, resumeLaunchPlan, resumeSavedAgentPane, elsewhereCommandLine } from './panes/agent_resume.js';
|
|
18
21
|
import { createAgentSessionsController } from './panes/agent_sessions/controller.js';
|
|
@@ -20,11 +23,12 @@ import { orderRows } from './panes/agent_sessions/scan.js';
|
|
|
20
23
|
import { RECENT_ACTIVITY_MS } from './panes/agent_sessions/limits.js';
|
|
21
24
|
import { openAgentSessionPanes } from './panes/agent_pane_sessions.js';
|
|
22
25
|
import { AgentSessionsPanelWidget } from './ui/widgets/agent_sessions_panel.js';
|
|
23
|
-
import { agentCliFromRequestId, agentPaneAnswerText, agentPaneNoteForModel, formatAgentPaneMessage, openAgentPane, typeLineIntoPane, typingSettled } from './panes/agent_panes.js';
|
|
26
|
+
import { agentCliFromRequestId, agentPaneAnswerText, agentPaneNoteForModel, formatAgentPaneMessage, formatTypedPaneMessage, openAgentPane, typeLineIntoPane, typingSettled } from './panes/agent_panes.js';
|
|
24
27
|
import { ReplyExchanges, arbitrationNotice, arbitrationStopForPane, arbitrationSummary, arrivalNote, capLoweredNotice, capLoweredStopForPane, capNoteForPane, capStopNotice, heldNotice, heldNoticeForPane, knownSecrets, replyModeRefusal, replyModeSettings, resumedNotice, staleArbitrationNotice, withheldNotice } from './panes/reply_modes.js';
|
|
25
28
|
import { askArbitrator } from './panes/reply_arbitrator.js';
|
|
26
29
|
import { agentCliFromChoice, newPaneChoices } from './panes/new_pane_choices.js';
|
|
27
30
|
import { MOTSI_PANE_ENV, remoteViewMotsi, runsMotsi, throughMotsi } from './panes/motsi.js';
|
|
31
|
+
import { editorProgram } from './panes/editor_program.js';
|
|
28
32
|
import { IntakeNotifications } from './intake/notifications.js';
|
|
29
33
|
import { projectGoal } from './goal_contract.js';
|
|
30
34
|
import { isToolResultMessage } from './utils/tool_result_message.js';
|
|
@@ -47,6 +51,7 @@ import { dirname, join } from 'path';
|
|
|
47
51
|
import { execFile, spawnSync } from 'child_process';
|
|
48
52
|
import { promisify, isDeepStrictEqual } from 'util';
|
|
49
53
|
import { configStore, resolveTerminalInteractionSettings } from './config.js';
|
|
54
|
+
import { commandPolicyFor } from './config/permissions.js';
|
|
50
55
|
import { applyAccountOp, getAccountsPayloadWithCodexStatus } from './web/accounts_mirror.js';
|
|
51
56
|
import { canonicalAccountProvider } from './agent/backends/account_pool.js';
|
|
52
57
|
import { normalizeProviderId } from './agent/backends/provider_ids.js';
|
|
@@ -59,7 +64,7 @@ import { getSupportedCodexReasoningEfforts, unsupportedEffortMessage, } from './
|
|
|
59
64
|
import { getVersion } from './utils/version.js';
|
|
60
65
|
import { isPersistableAssistantMessage, isToolUsePlaceholderMessage } from './utils/assistant_message.js';
|
|
61
66
|
import { claimObservationWarning, withHostClaimObservation } from './agent/claim_observation.js';
|
|
62
|
-
import { isMirrorMediaPath } from './utils/mirror_media.js';
|
|
67
|
+
import { isMirrorMediaPath, stripForeignMediaTokens } from './utils/mirror_media.js';
|
|
63
68
|
import { readDurableSessionImageSync, SessionMediaError } from './session_media.js';
|
|
64
69
|
import { checkForUpdate } from './utils/update.js';
|
|
65
70
|
import { isBundledDesktopRuntime } from './desktop/runtime.js';
|
|
@@ -131,16 +136,16 @@ import { headlessInteractionPolicy } from './app/headless_interaction.js';
|
|
|
131
136
|
import { formatAskUserResponse, ASK_USER_SKIP } from './app/ask_user_response.js';
|
|
132
137
|
import { connectStartupZerg } from './zerg/startup_connect.js';
|
|
133
138
|
import { showSettingsPage } from './app/settings_page.js';
|
|
134
|
-
import {
|
|
139
|
+
import { updateRepoConfig } from './config/repo_config.js';
|
|
135
140
|
import { formatDuration, shortenPath } from './utils/path_format.js';
|
|
136
141
|
import { getModeRegistry } from './modes/index.js';
|
|
137
142
|
import { generateSessionId, bindToolResponseStoreToSession, findRecentSessionSummary, findSessionHandoffOffers, getProjectHash, getSessionPathForCwd, setSessionLabels, saveSessionToFile, loadSessionFromFile, listAllSessions, listWorkspaceSessions, } from './session.js';
|
|
138
143
|
import { awaitStartupGitSnapshot, getRuntimeInfo, getStartupGitSnapshot } from './runtime_info.js';
|
|
139
144
|
import { ContextOverflowError, isContextOverflowMessage, StreamLostError } from './agent/agent.js';
|
|
140
145
|
import { dumpContextOverflow } from './agent/contextDump.js';
|
|
141
|
-
import { BROWSER_BUS_MEMBER_ID, OVERSEER_BUS_MEMBER_ID, createMirrorStreamServer, startMirrorStreamServer, stopMirrorStreamServer, } from './web/mirror_stream.js';
|
|
146
|
+
import { BROWSER_BUS_MEMBER_ID, OVERSEER_BUS_MEMBER_ID, createMirrorStreamServer, notAnAgentResult, startMirrorStreamServer, stopMirrorStreamServer, } from './web/mirror_stream.js';
|
|
142
147
|
import { initMirrorClient } from './web/mirror_client.js';
|
|
143
|
-
import { PaneRelayServer, PaneRelayClient, generateRelaySocketPath } from './ui/ratatui/pane_relay.js';
|
|
148
|
+
import { PaneRelayServer, PaneRelayClient, generateRelaySocketPath, startStaleRelaySweep } from './ui/ratatui/pane_relay.js';
|
|
144
149
|
import { paneReadRefusal, setPaneReadRefusal } from './ui/ratatui/screen_privacy.js';
|
|
145
150
|
import { perfBeginKeystroke, perfStage, perfEndKeystroke } from './debug/perf_trace.js';
|
|
146
151
|
import { resolveMuxPersistenceOptions, sanitizeMuxSessionState, validateWorkspaceState } from './ui/ratatui/mux_persistence.js';
|
|
@@ -160,7 +165,7 @@ import { linkOnlyLogsNotice, linkOnlyPageNotice, remoteMirrorLogSource } from '.
|
|
|
160
165
|
import { keylessRouterModelRefusal } from './agent/commands/router_availability.js';
|
|
161
166
|
import { keylessZtcPaneRoute } from './panes/worker_route.js';
|
|
162
167
|
import { buildDesktopUpdateRelaunchContext, buildHotRestartLaunch, prepareDesktopUpdateAuthorization, reduceDesktopUpdateOwnerHandshake, requestColonyCellRestart, } from './app/restart.js';
|
|
163
|
-
import { PANE_CREDENTIAL_ENV, WORKSPACE_MONITOR_CREDENTIAL_REQUEST, paneCredentialRelaunchArgs
|
|
168
|
+
import { PANE_CREDENTIAL_ENV, WORKSPACE_MONITOR_CREDENTIAL_REQUEST, paneCredentialRelaunchArgs } from './web/pane_credentials.js';
|
|
164
169
|
export { buildDesktopUpdateRelaunchContext, buildHotRestartArgs, requestColonyCellRestart, } from './app/restart.js';
|
|
165
170
|
import { formatWorkflowEventDisplay } from './app/workflow_event_display.js';
|
|
166
171
|
import { getBackgroundRegistry, clearBackgroundRegistry } from './agent/tools/index.js';
|
|
@@ -170,10 +175,10 @@ import { SessionManager } from './app/session_manager.js';
|
|
|
170
175
|
import { interruptedTurnMarker } from './app/session_messages.js';
|
|
171
176
|
import { createWorkspaceLayoutController } from './app/workspace_layout_controller.js';
|
|
172
177
|
import { linkWorkspaceAgentSessions, resolveWorkspaceAgentSession } from './workspace_agent.js';
|
|
173
|
-
import { hostedSessionSettingsEqual,
|
|
178
|
+
import { hostedSessionSettingsEqual, isHostedMuxCommandAllowed, parseHostedSessionSettings, } from './hosted/session_settings.js';
|
|
174
179
|
import { registerHostedAgentToolBridge } from './hosted/tool_bridge.js';
|
|
175
|
-
import { PaneRegistry, isNativeZtcPane, mergeSessionPaneSpecs, nativeLaunchRouterOrigin } from './panes/pane_registry.js';
|
|
176
|
-
import { buildZtcPaneLaunchCommand, createZtcLaunchSpec, ztcLaunchSpecFromArgs } from './panes/ztc_launch.js';
|
|
180
|
+
import { PaneRegistry, isNativeZtcPane, mergeSessionPaneSpecs, nativeLaunchRouterOrigin, nativeNonAgentPane, runsZtcAgent } from './panes/pane_registry.js';
|
|
181
|
+
import { buildZtcPaneLaunchCommand, createZtcLaunchSpec, ztcLaunchSpecFromArgs, ztcPaneRoutingRefusal } from './panes/ztc_launch.js';
|
|
177
182
|
import { preparePaneInitialInput, loadPaneInitialInput, readSavedPaneInitialInput, acknowledgePaneInitialInput, waitForPaneInitialInput, cleanupPaneInitialInput, PANE_TASK_AS_MESSAGE_ENV } from './panes/initial_input.js';
|
|
178
183
|
import { getProviderForModel, isCatalogModelForProvider, isPaneProvider, resolveModelAndProvider } from './panes/model_catalog.js';
|
|
179
184
|
import { registerToolCallbacks, clearToolCallbacks } from './app/tool_callbacks.js';
|
|
@@ -215,7 +220,8 @@ import { createRecapController } from './app/recap.js';
|
|
|
215
220
|
import { sessionRouteSummaryLlm, ThoughtSummaries } from './app/thought_summary.js';
|
|
216
221
|
import { clearStaleTodosOnBoot, normalizeTodoItems } from './app/todo_state.js';
|
|
217
222
|
import { writePaneResponseSync } from './utils/pane_response.js';
|
|
218
|
-
import { hostEffortPolicyBlanks, launchedByAnotherZtc } from './utils/subprocess_env.js';
|
|
223
|
+
import { buildGitSubprocessEnvFor, buildUserSubprocessEnv, hostEffortPolicyBlanks, hostRouterGrantBlank, hostRouterGrantDiscovery, launchedByAnotherZtc, reserveModelRouteCredentials } from './utils/subprocess_env.js';
|
|
224
|
+
import { hostCredentialRelaunchEnv } from './config/host_credentials.js';
|
|
219
225
|
import { registerInstance, deregisterInstance, loadInstances, updateInstance, heartbeatInstance, reapStoppedInstances, INSTANCE_HEARTBEAT_MS, } from './instance_registry.js';
|
|
220
226
|
import { loadPreviewsForInstances } from './navigator_preview.js';
|
|
221
227
|
import { FormWidget, SelectWidget, selectOptionSummary, TextInputWidget, QuestionnaireWidget, PromptViewerWidget, LogViewWidget } from './ui/widgets/index.js';
|
|
@@ -402,6 +408,10 @@ async function resolveNavigatorInstanceTitle(cwd) {
|
|
|
402
408
|
cwd,
|
|
403
409
|
encoding: 'utf8',
|
|
404
410
|
timeout: INSTANCE_TITLE_TIMEOUT_MS,
|
|
411
|
+
// CWD's branch: its own repository's, whatever repository this process's environment names, or, in a vcsh or yadm
|
|
412
|
+
// work tree, which has none, that of the repository its GIT_DIR names. git runs the programs its config names and
|
|
413
|
+
// writes the variables trace2.envVars names, so it gets a user subprocess's environment: none of ZTC's credentials.
|
|
414
|
+
env: buildGitSubprocessEnvFor(cwd),
|
|
405
415
|
});
|
|
406
416
|
return stdout.trim() || fallback;
|
|
407
417
|
}
|
|
@@ -430,6 +440,11 @@ function formatMirrorPaneInput(input) {
|
|
|
430
440
|
* Reconstruct a MessageInput from a submit envelope. The parent encodes pane input that
|
|
431
441
|
* carries attachments as `{"__ztc_cmd":"submit_input","input":{...}}` so a child pane can
|
|
432
442
|
* recover the structured attachments instead of receiving a flattened string.
|
|
443
|
+
*
|
|
444
|
+
* Only a parent's mirror relay sends one (registerMirrorPaneFallbacks), with mirror text its
|
|
445
|
+
* ingress has sanitized already, so the decoded text is sanitized as mirror text again: an
|
|
446
|
+
* envelope anyone typed, or that a pane got as its task, could spell a media token in JSON
|
|
447
|
+
* escapes that no sanitizer saw before it was decoded.
|
|
433
448
|
*/
|
|
434
449
|
function parseStructuredSubmitInput(rawInput) {
|
|
435
450
|
if (typeof rawInput !== 'string')
|
|
@@ -442,7 +457,7 @@ function parseStructuredSubmitInput(rawInput) {
|
|
|
442
457
|
const inner = cmd.input;
|
|
443
458
|
if (cmd.__ztc_cmd === 'submit_input' && inner && typeof inner.text === 'string') {
|
|
444
459
|
return {
|
|
445
|
-
text: inner.text,
|
|
460
|
+
text: stripForeignMediaTokens(inner.text),
|
|
446
461
|
attachments: Array.isArray(inner.attachments) ? inner.attachments : [],
|
|
447
462
|
...(typeof inner.pane_id === 'number' ? { pane_id: inner.pane_id } : {}),
|
|
448
463
|
};
|
|
@@ -1641,6 +1656,8 @@ export class RatatuiApp {
|
|
|
1641
1656
|
model: configStore.getModel(),
|
|
1642
1657
|
}),
|
|
1643
1658
|
getApprovalRequester: () => (request) => this.requestHookApproval(request),
|
|
1659
|
+
// A hook runs under the agent's permission profile: inside the OS sandbox it requires, as run_command does.
|
|
1660
|
+
getCommandPolicy: () => commandPolicyFor(configStore.get()),
|
|
1644
1661
|
});
|
|
1645
1662
|
// Initialize context status to show meter from the start
|
|
1646
1663
|
const model = configStore.get().model;
|
|
@@ -1859,9 +1876,10 @@ export class RatatuiApp {
|
|
|
1859
1876
|
}
|
|
1860
1877
|
// Main's own bus transport: it sends as Main through the mirror it runs at the time, the one it started with, or the
|
|
1861
1878
|
// one /mirror start started, whose bus its panes' mirror clients rejoin; never one /mirror stop stopped, whose bus is
|
|
1862
|
-
// gone. While it runs none, the message is typed into the panes.
|
|
1863
|
-
//
|
|
1864
|
-
//
|
|
1879
|
+
// gone. While it runs none, the message is typed into the panes. Either way it goes to agents alone: one for a shell
|
|
1880
|
+
// or a command pane is refused, as a pane's own is (typeOverseerMessage). Its answers to the Claude Code and Codex
|
|
1881
|
+
// panes in its workspace go out on it, a colony cell's included. Its model's send_message speaks on it too, unless
|
|
1882
|
+
// this ZTC has a parent mirror client (a colony cell), whose model speaks on its parent's bus (above).
|
|
1865
1883
|
if (this.muxMode) {
|
|
1866
1884
|
this.mainBusTransport = overseerBusTransport(() => this.mirrorServer, message => this.typeOverseerMessage(message), () => this.mainBusMember().name);
|
|
1867
1885
|
if (!this.mirrorClient)
|
|
@@ -2897,7 +2915,7 @@ export class RatatuiApp {
|
|
|
2897
2915
|
const servers = configStore.get().mcpServers;
|
|
2898
2916
|
if ((servers && Object.keys(servers).length > 0) || colonyOptIn()) {
|
|
2899
2917
|
const { initMcpServers } = await import('./mcp/client.js');
|
|
2900
|
-
await initMcpServers(servers);
|
|
2918
|
+
await initMcpServers(servers, { providerKeyEnv: configStore.get().apiKeyEnv });
|
|
2901
2919
|
}
|
|
2902
2920
|
};
|
|
2903
2921
|
const reloadSkills = async () => {
|
|
@@ -3023,7 +3041,12 @@ export class RatatuiApp {
|
|
|
3023
3041
|
if (render)
|
|
3024
3042
|
this.render();
|
|
3025
3043
|
}
|
|
3026
|
-
|
|
3044
|
+
/**
|
|
3045
|
+
* `atTerminal`: the command is the person's own, typed at this ZTC's terminal (see runCommand). Only then does an answer
|
|
3046
|
+
* it gives the attention queue keep their own paths; any other command's answer is mirror text
|
|
3047
|
+
* (MirrorStreamServer.respondAttention).
|
|
3048
|
+
*/
|
|
3049
|
+
buildCommandContext(addMessage, commandOrigin, atTerminal = false) {
|
|
3027
3050
|
const context = {
|
|
3028
3051
|
addMessage,
|
|
3029
3052
|
...(!this.paneMode && this.muxMode ? { workspaceLayouts: this.createWorkspaceLayoutOwner() } : {}),
|
|
@@ -3107,7 +3130,8 @@ export class RatatuiApp {
|
|
|
3107
3130
|
this.mirrorServer?.setPaneModel(0, configStore.getModel(), configStore.getProvider());
|
|
3108
3131
|
return ok ? { ok } : { ok, message: 'This pane keeps the model it runs on; it says why above.' };
|
|
3109
3132
|
}),
|
|
3110
|
-
|
|
3133
|
+
// The person's own /restart takes config.json as it is; relayed input's, as a restart another process asks for, does not.
|
|
3134
|
+
restartZtc: () => this.restartZtc(commandOrigin !== 'agent' && commandOrigin !== 'relayed'),
|
|
3111
3135
|
setDebug: (enabled) => this.controller.setDebug(enabled),
|
|
3112
3136
|
retry: () => { },
|
|
3113
3137
|
exit: () => this.exit(),
|
|
@@ -3615,7 +3639,7 @@ export class RatatuiApp {
|
|
|
3615
3639
|
respond: (id, answer) => {
|
|
3616
3640
|
if (!this.mirrorServer)
|
|
3617
3641
|
throw new Error('The overseer attention queue is unavailable.');
|
|
3618
|
-
this.mirrorServer.respondAttention(id, answer);
|
|
3642
|
+
this.mirrorServer.respondAttention(id, answer, atTerminal ? 'terminal' : 'mirror');
|
|
3619
3643
|
},
|
|
3620
3644
|
dismiss: (id) => {
|
|
3621
3645
|
if (!this.mirrorServer)
|
|
@@ -3864,6 +3888,11 @@ export class RatatuiApp {
|
|
|
3864
3888
|
const command = commands.find(candidate => candidate.name === cmd.toLowerCase());
|
|
3865
3889
|
if (!command)
|
|
3866
3890
|
return;
|
|
3891
|
+
const pinned = pinnedRouteCommandRefusal(cmd, args);
|
|
3892
|
+
if (pinned) {
|
|
3893
|
+
this.addSystemMessage(pinned);
|
|
3894
|
+
return;
|
|
3895
|
+
}
|
|
3867
3896
|
const context = this.buildCommandContext((msg) => this.controller.addMessage(msg));
|
|
3868
3897
|
try {
|
|
3869
3898
|
await Promise.resolve(command.handler(args, context));
|
|
@@ -3885,6 +3914,12 @@ export class RatatuiApp {
|
|
|
3885
3914
|
if (denial) {
|
|
3886
3915
|
return denial;
|
|
3887
3916
|
}
|
|
3917
|
+
// A session its host pinned keeps its route, whoever asks to move it (config/model_pin.ts).
|
|
3918
|
+
const pinned = pinnedRouteCommandRefusal(cmd, cmdArgs);
|
|
3919
|
+
if (pinned) {
|
|
3920
|
+
this.controller.addMessage({ role: 'system', content: pinned });
|
|
3921
|
+
return pinned;
|
|
3922
|
+
}
|
|
3888
3923
|
const context = this.buildCommandContext((msg) => {
|
|
3889
3924
|
capturedMessages.push(msg.content);
|
|
3890
3925
|
this.controller.addMessage(msg);
|
|
@@ -4010,6 +4045,9 @@ export class RatatuiApp {
|
|
|
4010
4045
|
return false;
|
|
4011
4046
|
return typeLineIntoPane(this.tui, paneId, formatAgentPaneMessage(msg));
|
|
4012
4047
|
});
|
|
4048
|
+
// A native Claude Code, Codex or shell pane the desktop app opened takes the person's typing alone, and a delegated
|
|
4049
|
+
// one shows a worker's feed: none is typed into above, and the refusal, Main's or a pane's own, says which it is.
|
|
4050
|
+
server.onNativeNonAgentPane(paneId => nativeNonAgentPane(this.paneRegistry.get(paneId)));
|
|
4013
4051
|
// A pane's message is checked for its reply mode first, and its sender told what became of it.
|
|
4014
4052
|
server.onBusMessageCheck(msg => this.checkAgentPaneBusMessage(msg));
|
|
4015
4053
|
}
|
|
@@ -4017,14 +4055,24 @@ export class RatatuiApp {
|
|
|
4017
4055
|
* Main's MESSAGE while this ZTC runs no mirror (it started without one, or /mirror stop stopped it): there is no bus,
|
|
4018
4056
|
* so it is typed into the panes it is for. One for this ZTC itself reaches its own agent, as a mirror's member 0
|
|
4019
4057
|
* hands it over. A Claude Code or Codex pane gets it as a mirror types it in (registerMirrorPaneFallbacks); any other
|
|
4020
|
-
* pane, as the prompt "[Message from Main]: …", Main named as its pane is
|
|
4021
|
-
*
|
|
4058
|
+
* pane that runs a ZTC agent (runsZtcAgent), as the prompt "[Message from Main]: …", Main named as its pane is, in one
|
|
4059
|
+
* inert line (formatTypedPaneMessage), since the pane submits it as its own typing. Any other pane (a shell, a command,
|
|
4060
|
+
* another program) gets nothing, as a bus would deliver it nothing: the message is refused in the bus's words
|
|
4061
|
+
* (notAnAgentResult), since a shell would run it as a command; for one of the desktop app's native Claude Code, Codex,
|
|
4062
|
+
* shell or delegated panes (nativeNonAgentPane), in the words that say what that pane takes. A broadcast reaches the
|
|
4063
|
+
* ZTC panes, the members a bus would have, and no shell.
|
|
4022
4064
|
*/
|
|
4023
4065
|
typeOverseerMessage(message) {
|
|
4024
4066
|
if (message.to === OVERSEER_BUS_MEMBER_ID) {
|
|
4025
4067
|
void this.handleBusMessage(message);
|
|
4026
4068
|
return;
|
|
4027
4069
|
}
|
|
4070
|
+
if (message.to !== 'all') {
|
|
4071
|
+
const target = this.paneRegistry.get(message.to);
|
|
4072
|
+
if (!this.agentCliPanes.has(message.to) && !runsZtcAgent(target)) {
|
|
4073
|
+
return notAnAgentResult(message.to, target === undefined, nativeNonAgentPane(target));
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4028
4076
|
const paneIds = message.to === 'all'
|
|
4029
4077
|
? this.paneRegistry.all().filter(pane => pane.paneType === 'ztc' && pane.paneId !== OVERSEER_BUS_MEMBER_ID).map(pane => pane.paneId)
|
|
4030
4078
|
: [message.to];
|
|
@@ -4032,7 +4080,7 @@ export class RatatuiApp {
|
|
|
4032
4080
|
if (this.agentCliPanes.has(paneId))
|
|
4033
4081
|
typeLineIntoPane(this.tui, paneId, formatAgentPaneMessage(message));
|
|
4034
4082
|
else
|
|
4035
|
-
this.tui.send({ type: 'write_pane', pane_id: paneId, input:
|
|
4083
|
+
this.tui.send({ type: 'write_pane', pane_id: paneId, input: formatTypedPaneMessage(message), submit: true });
|
|
4036
4084
|
}
|
|
4037
4085
|
}
|
|
4038
4086
|
/**
|
|
@@ -5193,8 +5241,22 @@ export class RatatuiApp {
|
|
|
5193
5241
|
throw error;
|
|
5194
5242
|
}
|
|
5195
5243
|
}
|
|
5244
|
+
/**
|
|
5245
|
+
* A headless mirror (a resident `--headless --mirror`, a headless ZTC pane, a colony cell with no terminal) runs
|
|
5246
|
+
* whatever its model and the holders of its mirror ask, with no one at a terminal watching each command. So, as a
|
|
5247
|
+
* `--headless` run does, it keeps the run's inference credentials from its tool children (run_command shells, panes,
|
|
5248
|
+
* language servers, search and git helpers): reserveModelRouteCredentials. This process keeps them. The interactive
|
|
5249
|
+
* app is the person's own session: their commands keep their environment, provider keys included. Reservation is
|
|
5250
|
+
* additive and idempotent, so the agent's every construction repeats it for a profile that names a new apiKeyEnv.
|
|
5251
|
+
*/
|
|
5252
|
+
reserveHeadlessRouteCredentials() {
|
|
5253
|
+
if (this.headlessMirror)
|
|
5254
|
+
reserveModelRouteCredentials(configStore.get().apiKeyEnv ?? {});
|
|
5255
|
+
}
|
|
5196
5256
|
async startRuntime() {
|
|
5197
5257
|
debugLog('[start] Beginning start()');
|
|
5258
|
+
// Before anything here can start a tool child.
|
|
5259
|
+
this.reserveHeadlessRouteCredentials();
|
|
5198
5260
|
const savedEnvironment = this.resumedSession?.metadata.environment;
|
|
5199
5261
|
if (savedEnvironment && this.detachEnvironment) {
|
|
5200
5262
|
this.controller.addMessage({ role: 'system', content: `Environment ${savedEnvironment.name} detached by launch option; conversation resumed in ${this.shellCwd}.` });
|
|
@@ -5488,7 +5550,10 @@ export class RatatuiApp {
|
|
|
5488
5550
|
// Both interactive (TuiProcess) and headless (HeadlessPaneManager) serve the relay.
|
|
5489
5551
|
// This allows sub-panes spawned within colony cells to connect and use pane tools.
|
|
5490
5552
|
// Children's pane lists say which panes run Claude Code or Codex, which only this ZTC knows.
|
|
5491
|
-
|
|
5553
|
+
// A ZTC pane a child asks for through MotSi runs inside the motsi this ZTC starts its own panes through, never the
|
|
5554
|
+
// child's (ztc_launch_trust.ts).
|
|
5555
|
+
this.paneRelay = new PaneRelayServer(this.tui, process.env.ZTC_PANE_RELAY, { agentCliOf: paneId => this.agentCliPanes.get(paneId),
|
|
5556
|
+
ztcPanesThroughMotsi: () => this.paneMotsi() });
|
|
5492
5557
|
// A child's report of its own pane tells this process the route it runs on (see noteChildPaneReport), and a ZTC
|
|
5493
5558
|
// pane it opens, the route that pane starts on (see noteChildPaneLaunch).
|
|
5494
5559
|
this.paneRelay.onChildCommand((command, announced) => {
|
|
@@ -5498,6 +5563,8 @@ export class RatatuiApp {
|
|
|
5498
5563
|
await this.paneRelay.start();
|
|
5499
5564
|
this.assertStartupActive();
|
|
5500
5565
|
debugLog(`[start] Pane relay server started: ${process.env.ZTC_PANE_RELAY}`);
|
|
5566
|
+
// A relay with a directory of its own in /tmp clears the ones relays that are gone left there.
|
|
5567
|
+
startStaleRelaySweep(process.env.ZTC_PANE_RELAY);
|
|
5501
5568
|
}
|
|
5502
5569
|
else if (this.paneMode && process.env.ZTC_PANE_RELAY) {
|
|
5503
5570
|
// The relay learns which pane this connection speaks for, so the main ZTC can trust what it reports.
|
|
@@ -5783,6 +5850,14 @@ export class RatatuiApp {
|
|
|
5783
5850
|
this.controller.addMessage(createFirstRunLaunchMessage(notice.text));
|
|
5784
5851
|
this.mirror?.publishMessage('system', notice.text);
|
|
5785
5852
|
}
|
|
5853
|
+
// What startup said of the MCP servers that started without a provider key (mcp/client.ts), in its one line: zmux's
|
|
5854
|
+
// screen hides what went to stderr before it, and a resident's mirror shows the transcript.
|
|
5855
|
+
const { mcpStartupNotice } = await import('./mcp/registry.js');
|
|
5856
|
+
const mcpNotice = mcpStartupNotice();
|
|
5857
|
+
if (mcpNotice) {
|
|
5858
|
+
this.controller.addMessage(createFirstRunLaunchMessage(mcpNotice));
|
|
5859
|
+
this.mirror?.publishMessage('system', mcpNotice);
|
|
5860
|
+
}
|
|
5786
5861
|
this.initialPromptStep = topLevelLaunch ? initialPromptStep(launchNotices) : null;
|
|
5787
5862
|
this.assertStartupActive();
|
|
5788
5863
|
if (this.launchConnectPromptWanted() && !this.composerHasDraft())
|
|
@@ -5938,6 +6013,7 @@ export class RatatuiApp {
|
|
|
5938
6013
|
}
|
|
5939
6014
|
process.on('SIGUSR1', () => {
|
|
5940
6015
|
debugLog('[SIGUSR1] Hot-restart requested by child pane');
|
|
6016
|
+
// Any process of this user can send it, the agent's own sandboxed command among them: not the person's restart.
|
|
5941
6017
|
void this.hotRestart();
|
|
5942
6018
|
});
|
|
5943
6019
|
// Check for updates (non-blocking)
|
|
@@ -6317,9 +6393,9 @@ export class RatatuiApp {
|
|
|
6317
6393
|
const proc = spawn('npm', ['install', '-g', info.packageSpec], {
|
|
6318
6394
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
6319
6395
|
shell: true,
|
|
6320
|
-
//
|
|
6321
|
-
//
|
|
6322
|
-
env:
|
|
6396
|
+
// A user subprocess's environment, as /update's: the person's own (PATH, HOME, their npm settings) and none of
|
|
6397
|
+
// ZTC's credentials under any name, since npm and the install scripts it runs get the environment it starts with.
|
|
6398
|
+
env: buildUserSubprocessEnv(),
|
|
6323
6399
|
});
|
|
6324
6400
|
let stdout = '';
|
|
6325
6401
|
let stderr = '';
|
|
@@ -6970,7 +7046,16 @@ export class RatatuiApp {
|
|
|
6970
7046
|
return undefined;
|
|
6971
7047
|
}
|
|
6972
7048
|
const eventPromise = this.waitForTuiEvent((event) => event.type === 'session_state', timeoutMs);
|
|
6973
|
-
|
|
7049
|
+
// A renderer that can't describe its workspace (the headless pane manager throws on a layout naming a pane it leaves
|
|
7050
|
+
// out) gives no snapshot, as one that refuses the request does: its answer is never waited for, so the wait's
|
|
7051
|
+
// timeout is no unhandled rejection, which would end ZTC.
|
|
7052
|
+
let sent = false;
|
|
7053
|
+
try {
|
|
7054
|
+
sent = this.tui.send({ type: 'get_session_state' });
|
|
7055
|
+
}
|
|
7056
|
+
catch (err) {
|
|
7057
|
+
debugLog(`[mux-session] Failed to snapshot mux state: ${err.message}`);
|
|
7058
|
+
}
|
|
6974
7059
|
if (!sent) {
|
|
6975
7060
|
eventPromise.catch(() => { });
|
|
6976
7061
|
return undefined;
|
|
@@ -6990,19 +7075,9 @@ export class RatatuiApp {
|
|
|
6990
7075
|
}
|
|
6991
7076
|
}
|
|
6992
7077
|
applyHostedConfig(settings) {
|
|
6993
|
-
|
|
6994
|
-
//
|
|
6995
|
-
configStore.
|
|
6996
|
-
configStore.setConfigScope('session');
|
|
6997
|
-
configStore.set('provider', settings.provider);
|
|
6998
|
-
configStore.set('model', settings.model);
|
|
6999
|
-
configStore.set('maxTokens', settings.maxOutputTokens);
|
|
7000
|
-
configStore.set('hostedThreadInstructions', patch.hostedThreadInstructions);
|
|
7001
|
-
configStore.set('zrouterRoutePlan', patch.zrouterRoutePlan);
|
|
7002
|
-
configStore.set('codexEffort', patch.codexEffort);
|
|
7003
|
-
configStore.set('permissionProfile', patch.permissionProfile);
|
|
7004
|
-
configStore.set('authMode', 'zrouter');
|
|
7005
|
-
configStore.set('sandbox', patch.sandbox);
|
|
7078
|
+
// The thread's settings are the host's, not a route the person chose in this session; a session its host pinned to
|
|
7079
|
+
// another route keeps that one.
|
|
7080
|
+
configStore.applyHostedThreadSettings(settings);
|
|
7006
7081
|
}
|
|
7007
7082
|
isHostedRuntime() {
|
|
7008
7083
|
return process.env.ZTC_HOSTED === '1' || this.hostedSessionSettings !== null;
|
|
@@ -7043,13 +7118,20 @@ export class RatatuiApp {
|
|
|
7043
7118
|
if (next.provider !== currentProvider || next.model !== currentModel) {
|
|
7044
7119
|
return { ok: false, error: 'Provider and model are immutable for a hosted thread; fork it instead.' };
|
|
7045
7120
|
}
|
|
7121
|
+
// A revision the host's pin of the permission settings refuses is refused before anything of it is taken, so nothing
|
|
7122
|
+
// is rolled back: the rollback below sets the settings in the scope they are in, the person's own (config.json) on a
|
|
7123
|
+
// runtime that took no thread as it started (ZTC_PERMISSION_PROFILE_PINNED; the reviewer's C1 probe, 2026-11-22).
|
|
7124
|
+
const pinned = configStore.hostedRevisionPinRefusal(next);
|
|
7125
|
+
if (pinned)
|
|
7126
|
+
return { ok: false, error: pinned };
|
|
7046
7127
|
const previous = this.hostedSessionSettings;
|
|
7047
7128
|
const previousConfig = configStore.get();
|
|
7048
7129
|
try {
|
|
7049
7130
|
this.applyHostedConfig(next);
|
|
7050
7131
|
this.hostedSessionSettings = next;
|
|
7051
7132
|
this.reloadAgentInPlace();
|
|
7052
|
-
|
|
7133
|
+
// The model the session now runs on: the thread's, or the route its host pinned it to.
|
|
7134
|
+
this.mirrorServer?.setPaneModel(0, configStore.getModel(), configStore.getProvider());
|
|
7053
7135
|
await this.saveCurrentSession(true);
|
|
7054
7136
|
return { ok: true, settings: next };
|
|
7055
7137
|
}
|
|
@@ -7141,8 +7223,17 @@ export class RatatuiApp {
|
|
|
7141
7223
|
if (this.isHostedRuntime()) {
|
|
7142
7224
|
return { ok: false, error: 'Hosted workbenches allow one agent pane per thread.' };
|
|
7143
7225
|
}
|
|
7144
|
-
// The browser keeps its own default model and sends it here, unchecked
|
|
7145
|
-
//
|
|
7226
|
+
// The browser keeps its own default model and sends it here, unchecked. A pane runs on its provider's routing:
|
|
7227
|
+
// one off the routing ZTC_LLM_AUTH_MODE pins (a local login under zrouter) is refused before anything is asked,
|
|
7228
|
+
// as the model picker refuses that provider for a pane already open, and Main says so.
|
|
7229
|
+
const offRouting = ztcPaneRoutingRefusal(command.provider);
|
|
7230
|
+
if (offRouting) {
|
|
7231
|
+
const error = `No ZTC pane was opened: ${offRouting}`;
|
|
7232
|
+
this.publishPaneSystemMessage(0, error);
|
|
7233
|
+
return { ok: false, error };
|
|
7234
|
+
}
|
|
7235
|
+
// A pane on a model Router has no key for would fail on its first message, so it is refused with where the key
|
|
7236
|
+
// goes, and Main says so.
|
|
7146
7237
|
const keyless = await this.keylessZtcPaneRoute(command.provider, command.model);
|
|
7147
7238
|
if (keyless) {
|
|
7148
7239
|
const error = `No ZTC pane was opened: ${keyless}`;
|
|
@@ -7204,10 +7295,15 @@ export class RatatuiApp {
|
|
|
7204
7295
|
return error ? { ok: false, error } : { ok: true };
|
|
7205
7296
|
}
|
|
7206
7297
|
case 'write_pane': {
|
|
7298
|
+
// A shell's or a command's pane (an agent CLI's too) gets what the browser writes as written: its keys. Any other
|
|
7299
|
+
// pane's program, a ZTC pane's agent above all, runs it as its prompt, so there it is mirror text, as what
|
|
7300
|
+
// /pane-input sends a pane is: a forged `[image PATH]` in it would read PATH.
|
|
7301
|
+
const paneType = this.paneRegistry.get(command.pane_id)?.paneType;
|
|
7302
|
+
const keys = paneType === 'process' || paneType === 'command';
|
|
7207
7303
|
return this.tui.send({
|
|
7208
7304
|
type: 'write_pane',
|
|
7209
7305
|
pane_id: command.pane_id,
|
|
7210
|
-
input: command.input,
|
|
7306
|
+
input: keys ? command.input : stripForeignMediaTokens(command.input),
|
|
7211
7307
|
})
|
|
7212
7308
|
? { ok: true }
|
|
7213
7309
|
: { ok: false, error: 'failed to write to pane' };
|
|
@@ -7258,6 +7354,14 @@ export class RatatuiApp {
|
|
|
7258
7354
|
return { ok: false, error };
|
|
7259
7355
|
}
|
|
7260
7356
|
// --- Overseer (pane 0): hot-swap directly in this process, for this pane alone ---
|
|
7357
|
+
// A session its host pinned keeps its route: its own pane's model picker is refused, naming it. A model off the
|
|
7358
|
+
// routing the environment pins (ZTC_LLM_AUTH_MODE) is refused for any pane, whose routing follows this one's.
|
|
7359
|
+
const refused = command.pane_id === 0 ? configStore.routeChangeRefusal(nextOverride?.provider, nextOverride?.model)
|
|
7360
|
+
: nextOverride?.provider ? configStore.routingRefusal(nextOverride.provider) : undefined;
|
|
7361
|
+
if (refused) {
|
|
7362
|
+
this.publishPaneSystemMessage(command.pane_id, refused);
|
|
7363
|
+
return { ok: false, error: refused };
|
|
7364
|
+
}
|
|
7261
7365
|
if (command.pane_id === 0) {
|
|
7262
7366
|
this.hotSwapModel(nextOverride?.provider, nextOverride?.model);
|
|
7263
7367
|
this.mirrorServer?.setPaneModel(0, configStore.getModel(), configStore.getProvider());
|
|
@@ -7368,14 +7472,26 @@ export class RatatuiApp {
|
|
|
7368
7472
|
// Web-mirror equivalent of /config auth-mode. Auth routing is global
|
|
7369
7473
|
// (not per-pane): persist, rebuild the overseer's agent so the next
|
|
7370
7474
|
// turn uses the new route, and broadcast the mode so every connected
|
|
7371
|
-
// client updates its settings row.
|
|
7372
|
-
// the UI can warn that
|
|
7475
|
+
// client updates its settings row. An env override that outranks the
|
|
7476
|
+
// change is surfaced so the UI can warn that it is inert while set.
|
|
7373
7477
|
const mode = command.mode;
|
|
7478
|
+
if (pinnedRoute()) {
|
|
7479
|
+
// A session its host pinned keeps its routing with its provider and model (config/model_pin.ts).
|
|
7480
|
+
const error = pinnedRouteMessage();
|
|
7481
|
+
this.publishPaneSystemMessage(0, error);
|
|
7482
|
+
return { ok: false, error };
|
|
7483
|
+
}
|
|
7374
7484
|
if (mode !== 'auto' && mode !== 'direct' && mode !== 'zrouter') {
|
|
7375
7485
|
const error = `unknown auth mode "${mode}" — expected auto|direct|zrouter`;
|
|
7376
7486
|
this.publishPaneSystemMessage(0, error);
|
|
7377
7487
|
return { ok: false, error };
|
|
7378
7488
|
}
|
|
7489
|
+
// The routing the environment pins (ZTC_LLM_AUTH_MODE) is the only one it takes; another saves nothing.
|
|
7490
|
+
const offRouting = pinnedRoutingRefusal(mode);
|
|
7491
|
+
if (offRouting) {
|
|
7492
|
+
this.publishPaneSystemMessage(0, offRouting);
|
|
7493
|
+
return { ok: false, error: offRouting };
|
|
7494
|
+
}
|
|
7379
7495
|
const previousMode = configStore.get().authMode;
|
|
7380
7496
|
configStore.setAuthMode(mode);
|
|
7381
7497
|
try {
|
|
@@ -7388,8 +7504,9 @@ export class RatatuiApp {
|
|
|
7388
7504
|
return { ok: false, error };
|
|
7389
7505
|
}
|
|
7390
7506
|
await configStore.save();
|
|
7391
|
-
|
|
7392
|
-
|
|
7507
|
+
// The variable is surfaced only while it outranks the routing just saved: the one it pins leaves it nothing to
|
|
7508
|
+
// override (config/model_pin.ts).
|
|
7509
|
+
this.mirrorServer?.publishAuthMode(mode, routingEnvOverride(mode));
|
|
7393
7510
|
return { ok: true };
|
|
7394
7511
|
}
|
|
7395
7512
|
case 'set_colony_config': {
|
|
@@ -7463,7 +7580,10 @@ export class RatatuiApp {
|
|
|
7463
7580
|
}
|
|
7464
7581
|
clean.model = { provider: m.provider, model: m.model };
|
|
7465
7582
|
}
|
|
7466
|
-
|
|
7583
|
+
else {
|
|
7584
|
+
// null clears the override.
|
|
7585
|
+
clean.model = null;
|
|
7586
|
+
}
|
|
7467
7587
|
}
|
|
7468
7588
|
if ('workflowAllowlist' in patch) {
|
|
7469
7589
|
const value = patch.workflowAllowlist;
|
|
@@ -7474,13 +7594,17 @@ export class RatatuiApp {
|
|
|
7474
7594
|
}
|
|
7475
7595
|
clean.workflowAllowlist = value;
|
|
7476
7596
|
}
|
|
7477
|
-
//
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
}
|
|
7483
|
-
|
|
7597
|
+
// Only what the patch names changes (null clears; absent keeps), and every other key of the file stays; where
|
|
7598
|
+
// the file is ZTC's own saved config (a home directory), nothing is written.
|
|
7599
|
+
let next;
|
|
7600
|
+
try {
|
|
7601
|
+
next = updateRepoConfig(process.cwd(), clean);
|
|
7602
|
+
}
|
|
7603
|
+
catch (error) {
|
|
7604
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7605
|
+
this.publishPaneSystemMessage(0, message);
|
|
7606
|
+
return { ok: false, error: message };
|
|
7607
|
+
}
|
|
7484
7608
|
this.mirrorServer?.publishRepoConfig({ cwd: process.cwd(), config: next });
|
|
7485
7609
|
return { ok: true };
|
|
7486
7610
|
}
|
|
@@ -9758,11 +9882,7 @@ export class RatatuiApp {
|
|
|
9758
9882
|
if (isControlKey(input, key, 'g')) {
|
|
9759
9883
|
const planFile = this.controller.getPlanFile();
|
|
9760
9884
|
if (planFile) {
|
|
9761
|
-
|
|
9762
|
-
const { spawn } = require('child_process');
|
|
9763
|
-
const editor = process.env.EDITOR || 'vim';
|
|
9764
|
-
spawn(editor, [planFile], { stdio: 'inherit' });
|
|
9765
|
-
this.controller.setToast(`Opening ${planFile} in ${editor}`);
|
|
9885
|
+
void this.openPlanInEditor(planFile);
|
|
9766
9886
|
}
|
|
9767
9887
|
else {
|
|
9768
9888
|
this.controller.setToast('No plan file. Use /plan to create one.', undefined, 'warning');
|
|
@@ -10981,15 +11101,17 @@ export class RatatuiApp {
|
|
|
10981
11101
|
// Such input passes no Zerg Router refusal either, unless /broadcast delivered it. A held entry keeps who entered
|
|
10982
11102
|
// it and where, not this answer, which is worked out again when it is sent.
|
|
10983
11103
|
const routerAttempt = this.takesRouterAttempt(person, via);
|
|
11104
|
+
// Only the person's own command at this ZTC's terminal is no mirror text: not the browser's, nor any relayed here.
|
|
11105
|
+
const atTerminal = origin === undefined && via === 'terminal';
|
|
10984
11106
|
if (route.type === 'shell') {
|
|
10985
11107
|
this.mirror?.publishMessage('user', text);
|
|
10986
|
-
await this.handleCommand('shell', [route.command], false, origin);
|
|
11108
|
+
await this.handleCommand('shell', [route.command], false, origin, atTerminal);
|
|
10987
11109
|
return;
|
|
10988
11110
|
}
|
|
10989
11111
|
if (route.type === 'command') {
|
|
10990
11112
|
// The mirror records it without a key or a session of the person's (redactMirroredCommand); it runs as typed.
|
|
10991
11113
|
this.mirror?.publishMessage('user', redactMirroredCommand(text));
|
|
10992
|
-
await this.handleCommand(route.cmd, route.args, false, origin);
|
|
11114
|
+
await this.handleCommand(route.cmd, route.args, false, origin, atTerminal);
|
|
10993
11115
|
return;
|
|
10994
11116
|
}
|
|
10995
11117
|
// A message of the person's own starts the count of every exchange with an agent pane again, and one that had
|
|
@@ -11126,6 +11248,9 @@ export class RatatuiApp {
|
|
|
11126
11248
|
if (error instanceof RouterConfigurationError && error.needsSignIn) {
|
|
11127
11249
|
return { ready: false, signIn: routerSignInRefusal(error.kind === 'expired' ? 'expired' : 'signed_out') };
|
|
11128
11250
|
}
|
|
11251
|
+
// The host's Router runtime grant is no usable bearer: nothing is sent, and the pane says so in the grant's words.
|
|
11252
|
+
if (error instanceof RouterConfigurationError && error.kind === 'host_grant')
|
|
11253
|
+
return { ready: false, signIn: error.message };
|
|
11129
11254
|
return { ready: configStore.hasApiKey() || configStore.isAuthenticated() };
|
|
11130
11255
|
}
|
|
11131
11256
|
// A provider only Zerg Router serves (Modal among them) has no platform fallback: the factory refuses it off Router.
|
|
@@ -12562,6 +12687,13 @@ export class RatatuiApp {
|
|
|
12562
12687
|
// Display-only: the agent sends the model no system line, and a local-only one no recap or summary reads.
|
|
12563
12688
|
this.addSystemMessage(event.message, { localOnly: true });
|
|
12564
12689
|
break;
|
|
12690
|
+
case 'attached_images_withheld':
|
|
12691
|
+
// Zerg Router took the turn only without the images the person attached: the note stands in for them in the
|
|
12692
|
+
// transcript, this turn's checkpoint and the saved session, so no later turn or resumed session sends them.
|
|
12693
|
+
this.controller.setMessages(withheldAttachedImages(this.controller.getState().messages, event.note, event.keep));
|
|
12694
|
+
historyCheckpoint = withheldAttachedImages(historyCheckpoint, event.note, event.keep);
|
|
12695
|
+
void this.saveCurrentSession(true).catch(error => debugLog(`[attached-images] session save failed: ${error.message}`));
|
|
12696
|
+
break;
|
|
12565
12697
|
case 'api_retry': {
|
|
12566
12698
|
// The request is asked again: an answer its last attempt showed, which the agent withdrew, goes first.
|
|
12567
12699
|
const dropped = this.dropWithdrawnAnswer(withdrawnAnswer);
|
|
@@ -13835,18 +13967,19 @@ export class RatatuiApp {
|
|
|
13835
13967
|
}
|
|
13836
13968
|
/**
|
|
13837
13969
|
* `origin`: 'relayed' for a command the person didn't enter themselves, or one a ZTC another ZTC launched into one of
|
|
13838
|
-
* its panes reads from its terminal (see handleSubmit).
|
|
13970
|
+
* its panes reads from its terminal (see handleSubmit). `atTerminal`: the person entered it at this ZTC's own terminal,
|
|
13971
|
+
* not in the browser mirror (see buildCommandContext).
|
|
13839
13972
|
*/
|
|
13840
|
-
async handleCommand(cmd, cmdArgs, publishUserMessage = true, origin) {
|
|
13973
|
+
async handleCommand(cmd, cmdArgs, publishUserMessage = true, origin, atTerminal = false) {
|
|
13841
13974
|
this.commandsRunning++;
|
|
13842
13975
|
try {
|
|
13843
|
-
await this.runCommand(cmd, cmdArgs, publishUserMessage, origin);
|
|
13976
|
+
await this.runCommand(cmd, cmdArgs, publishUserMessage, origin, atTerminal);
|
|
13844
13977
|
}
|
|
13845
13978
|
finally {
|
|
13846
13979
|
this.commandsRunning--;
|
|
13847
13980
|
}
|
|
13848
13981
|
}
|
|
13849
|
-
async runCommand(cmd, cmdArgs, publishUserMessage, origin) {
|
|
13982
|
+
async runCommand(cmd, cmdArgs, publishUserMessage, origin, atTerminal = false) {
|
|
13850
13983
|
if (cmd === 'pane' && cmdArgs[0] === 'stop' && this.dailyDesktop) {
|
|
13851
13984
|
if (origin === 'relayed') {
|
|
13852
13985
|
this.addSystemMessage('Native Stop requires a direct human command');
|
|
@@ -13906,7 +14039,9 @@ export class RatatuiApp {
|
|
|
13906
14039
|
const lines = tasks.map(t => {
|
|
13907
14040
|
const elapsed = Date.now() - t.startedAt.getTime();
|
|
13908
14041
|
const dur = formatDuration(elapsed);
|
|
13909
|
-
|
|
14042
|
+
// A task cut short says so: the mirror withholds from an observer what may start a credential at the mark.
|
|
14043
|
+
const description = t.description.length > 60 ? `${t.description.slice(0, 60)}…` : t.description;
|
|
14044
|
+
return ` ${t.id} ${t.status.padEnd(10)} ${dur.padEnd(8)} ${description}`;
|
|
13910
14045
|
});
|
|
13911
14046
|
this.addSystemMessage(`Background agents:\n\n ID Status Duration Description\n${lines.join('\n')}`);
|
|
13912
14047
|
return;
|
|
@@ -13979,13 +14114,19 @@ export class RatatuiApp {
|
|
|
13979
14114
|
}
|
|
13980
14115
|
return;
|
|
13981
14116
|
}
|
|
14117
|
+
// A session its host pinned keeps its route, whoever asks to move it (config/model_pin.ts).
|
|
14118
|
+
const pinned = pinnedRouteCommandRefusal(cmd, cmdArgs);
|
|
14119
|
+
if (pinned) {
|
|
14120
|
+
this.addSystemMessage(pinned);
|
|
14121
|
+
return;
|
|
14122
|
+
}
|
|
13982
14123
|
const context = this.buildCommandContext((msg) => {
|
|
13983
14124
|
this.controller.addMessage(msg);
|
|
13984
14125
|
// A message for this terminal only (the mirror's own link) never reaches the mirror's transcript.
|
|
13985
14126
|
if (msg.role === 'system' && msg.metadata?.localOnly !== true) {
|
|
13986
14127
|
this.mirror?.publishMessage('system', msg.content);
|
|
13987
14128
|
}
|
|
13988
|
-
}, origin);
|
|
14129
|
+
}, origin, atTerminal);
|
|
13989
14130
|
// Find and execute command — global first, then mode fallback for YAML-only commands.
|
|
13990
14131
|
// Global commands are preferred because some (like /execute in plan mode) have richer
|
|
13991
14132
|
// behavior (approval widgets, etc.) that mode handlers don't replicate.
|
|
@@ -14082,6 +14223,13 @@ export class RatatuiApp {
|
|
|
14082
14223
|
this.addSystemMessage(isRetiredProvider(provider) ? retiredProviderMessage(provider, current) : retiredModelMessage(model));
|
|
14083
14224
|
return false;
|
|
14084
14225
|
}
|
|
14226
|
+
// A session its host pinned keeps its route (config/model_pin.ts), and one whose routing the environment pins
|
|
14227
|
+
// (ZTC_LLM_AUTH_MODE) keeps that routing: a choice of another is refused.
|
|
14228
|
+
const refused = !options.keepsRoute && provider && model ? configStore.routeChangeRefusal(provider, model) : undefined;
|
|
14229
|
+
if (refused) {
|
|
14230
|
+
this.addSystemMessage(refused);
|
|
14231
|
+
return false;
|
|
14232
|
+
}
|
|
14085
14233
|
// Snapshot the live selection so a failed rebuild rolls back cleanly. The
|
|
14086
14234
|
// rebuild returns null when the target provider isn't set up (kimi_code /
|
|
14087
14235
|
// codex_* before login). Swapping that null in would kill the
|
|
@@ -14308,6 +14456,7 @@ export class RatatuiApp {
|
|
|
14308
14456
|
activeToolCheckpointHandler = null;
|
|
14309
14457
|
toolCheckpointTurn = 0;
|
|
14310
14458
|
createAgent(options = {}) {
|
|
14459
|
+
this.reserveHeadlessRouteCredentials();
|
|
14311
14460
|
const diagnostics = this.ensureSessionManager().getDiagnostics();
|
|
14312
14461
|
this.commandJobsUnsubscribe?.();
|
|
14313
14462
|
this.commandJobsUnsubscribe = subscribeCommandJobs(this.sessionId, jobs => {
|
|
@@ -14322,7 +14471,9 @@ export class RatatuiApp {
|
|
|
14322
14471
|
this.ensureSessionManager().recordCommandJob(job);
|
|
14323
14472
|
if (this.commandJobStates.get(job.job_id) !== job.status) {
|
|
14324
14473
|
this.commandJobStates.set(job.job_id, job.status);
|
|
14325
|
-
|
|
14474
|
+
// A command cut short says so: the mirror withholds from an observer what may start a credential at the mark.
|
|
14475
|
+
const command = job.command.length > 120 ? `${job.command.slice(0, 120)}…` : job.command;
|
|
14476
|
+
this.addSystemMessage(`Command ${job.job_id}: ${job.status}${job.exit_code === undefined ? '' : ` (exit ${job.exit_code})`}. ${command}`);
|
|
14326
14477
|
}
|
|
14327
14478
|
}
|
|
14328
14479
|
});
|
|
@@ -14864,7 +15015,15 @@ export class RatatuiApp {
|
|
|
14864
15015
|
const agent = this.agent;
|
|
14865
15016
|
if (!agent)
|
|
14866
15017
|
return undefined;
|
|
14867
|
-
|
|
15018
|
+
// A summary is asked for between turns as much as during one: the transcript hears what its request went without
|
|
15019
|
+
// here, not through a turn's events.
|
|
15020
|
+
const context = agent.getHandoffContext(messages ?? this.controller.getState().messages, {
|
|
15021
|
+
onNotice: message => this.addSystemMessage(message, { localOnly: true }),
|
|
15022
|
+
onAttachedImagesWithheld: (note, keep) => {
|
|
15023
|
+
this.controller.setMessages(withheldAttachedImages(this.controller.getState().messages, note, keep));
|
|
15024
|
+
void this.saveCurrentSession(true).catch(error => debugLog(`[attached-images] session save failed: ${error.message}`));
|
|
15025
|
+
},
|
|
15026
|
+
});
|
|
14868
15027
|
return modelHandoffSummarizer(context.backend, context.model, {
|
|
14869
15028
|
request: context,
|
|
14870
15029
|
signal,
|
|
@@ -15745,10 +15904,19 @@ export class RatatuiApp {
|
|
|
15745
15904
|
}
|
|
15746
15905
|
}
|
|
15747
15906
|
}
|
|
15748
|
-
/**
|
|
15907
|
+
/**
|
|
15908
|
+
* What a ZTC pane needs to join this workspace; its mirror credential is its own (see pane.ts childZtcPaneEnv). The
|
|
15909
|
+
* renderer that starts it holds this process's environment: the pane keeps a host's grant that takes effect, and gets
|
|
15910
|
+
* a blank for one that doesn't, and with the grant it imports no plugin from where an agent writes, as the panes an
|
|
15911
|
+
* agent opens do (hostRouterGrantBlank, hostRouterGrantDiscovery).
|
|
15912
|
+
*/
|
|
15749
15913
|
childZtcPaneEnv() {
|
|
15750
15914
|
const env = {
|
|
15751
15915
|
ZTC_PARENT_PID: String(process.pid),
|
|
15916
|
+
...hostRouterGrantBlank(),
|
|
15917
|
+
...hostRouterGrantDiscovery(),
|
|
15918
|
+
// Under the host's pin of the permission settings the pane pins its own (config/permission_pin.ts).
|
|
15919
|
+
...permissionPinChildEnv(configStore.permissionsPinned()),
|
|
15752
15920
|
};
|
|
15753
15921
|
if (process.env.ZTC_MIRROR_PORT) {
|
|
15754
15922
|
env.ZTC_MIRROR_PORT = process.env.ZTC_MIRROR_PORT;
|
|
@@ -16147,6 +16315,56 @@ export class RatatuiApp {
|
|
|
16147
16315
|
? null
|
|
16148
16316
|
: 'failed to create shell pane';
|
|
16149
16317
|
}
|
|
16318
|
+
/**
|
|
16319
|
+
* Ctrl+G: open the plan in $EDITOR (vim when it is unset) in a pane of its own, where ZTC has panes (zmux, the
|
|
16320
|
+
* desktop app, or a pane of either through its relay), as open_editor_pane opens a file. The renderer starts the
|
|
16321
|
+
* editor on the pane's own terminal, so the keys typed in it are the editor's. The single-pane renderer reads ZTC's
|
|
16322
|
+
* terminal the whole time ZTC runs: an editor ZTC started on that terminal would get only some of the keys typed for
|
|
16323
|
+
* it and ZTC the rest, so there ZTC starts none and says where the plan is.
|
|
16324
|
+
*/
|
|
16325
|
+
async openPlanInEditor(planFile) {
|
|
16326
|
+
const panes = getMuxTransport();
|
|
16327
|
+
if (!panes) {
|
|
16328
|
+
this.controller.addMessage({ role: 'system', content: 'Ctrl+G opens the plan in your editor in a pane of its own, '
|
|
16329
|
+
+ `which needs ZTC's panes: start ZTC with zmux (plain \`ztc\`) or use the desktop app. The plan is ${planFile}.` });
|
|
16330
|
+
return;
|
|
16331
|
+
}
|
|
16332
|
+
// A blank $EDITOR is none: run through the shell, it would leave the plan itself as the command.
|
|
16333
|
+
const editor = process.env.EDITOR?.trim() || 'vim';
|
|
16334
|
+
const title = 'Plan';
|
|
16335
|
+
const motsi = this.paneMotsi();
|
|
16336
|
+
const program = editorProgram(editor, planFile);
|
|
16337
|
+
const launched = motsi ? throughMotsi(motsi, title, program) : program;
|
|
16338
|
+
// As for a shell pane: a host's effort policy in the renderer's environment is ZTC's own (hostEffortPolicyBlanks).
|
|
16339
|
+
const env = { ...hostEffortPolicyBlanks(), ...(motsi ? MOTSI_PANE_ENV : {}) };
|
|
16340
|
+
const requestId = `plan-editor-${generateSessionId()}`;
|
|
16341
|
+
// The renderer refuses a pane whose program cannot start, naming this request.
|
|
16342
|
+
const answered = waitForPaneCreatedOrError(panes, { requestId }, 15000);
|
|
16343
|
+
const sent = panes.send({
|
|
16344
|
+
type: 'create_pane',
|
|
16345
|
+
request_id: requestId,
|
|
16346
|
+
command: launched.command,
|
|
16347
|
+
args: launched.args,
|
|
16348
|
+
cwd: this.shellCwd || process.cwd(),
|
|
16349
|
+
title,
|
|
16350
|
+
pane_type: 'command',
|
|
16351
|
+
...(Object.keys(env).length > 0 ? { env } : {}),
|
|
16352
|
+
});
|
|
16353
|
+
if (!sent) {
|
|
16354
|
+
answered.catch(() => { });
|
|
16355
|
+
this.controller.setToast(`Could not open the editor ${editor}: the renderer did not take the pane`, undefined, 'warning');
|
|
16356
|
+
return;
|
|
16357
|
+
}
|
|
16358
|
+
this.controller.setToast(`Opening ${planFile} in ${editor}`);
|
|
16359
|
+
try {
|
|
16360
|
+
const event = await answered;
|
|
16361
|
+
if (event.type === 'error')
|
|
16362
|
+
this.controller.setToast(`Could not open the editor ${editor}: ${event.message}`, undefined, 'warning');
|
|
16363
|
+
}
|
|
16364
|
+
catch {
|
|
16365
|
+
this.controller.setToast(`The renderer did not open the editor ${editor} in time`, undefined, 'warning');
|
|
16366
|
+
}
|
|
16367
|
+
}
|
|
16150
16368
|
/**
|
|
16151
16369
|
* Run a command in a shell pane — how a custom option becomes a pane. Returns
|
|
16152
16370
|
* an error to report, or null when zmux accepted the pane.
|
|
@@ -16608,23 +16826,25 @@ export class RatatuiApp {
|
|
|
16608
16826
|
* Restart this ZTC instance. Colony children delegate to the parent bridge
|
|
16609
16827
|
* so the whole cell pane, mirror, and runtime entrypoint are recreated.
|
|
16610
16828
|
*/
|
|
16611
|
-
async restartZtc() {
|
|
16829
|
+
async restartZtc(byPerson = false) {
|
|
16612
16830
|
if (process.env.ZTC_COLONY_CHILD) {
|
|
16613
16831
|
await requestColonyCellRestart();
|
|
16614
16832
|
return;
|
|
16615
16833
|
}
|
|
16616
|
-
await this.hotRestart();
|
|
16834
|
+
await this.hotRestart(byPerson);
|
|
16617
16835
|
}
|
|
16618
16836
|
/**
|
|
16619
16837
|
* Hot-restart: save session, tear down TUI, exec new version with --resume.
|
|
16620
16838
|
* Used after auto-update so the user gets the new code without manual restart.
|
|
16621
16839
|
*/
|
|
16622
|
-
async hotRestart() {
|
|
16840
|
+
async hotRestart(takesEdits = false) {
|
|
16623
16841
|
await this.relaunchTui({
|
|
16624
16842
|
sessionId: this.sessionId,
|
|
16625
|
-
|
|
16843
|
+
// Under the host's pin, the folder its relative roots are rooted at, wherever an environment moved this process.
|
|
16844
|
+
cwd: configStore.permissionPinFolder() ?? process.cwd(),
|
|
16626
16845
|
label: 'hotRestart',
|
|
16627
16846
|
failureMessage: 'Hot restart failed. Please restart ZTC manually.',
|
|
16847
|
+
takesEdits,
|
|
16628
16848
|
});
|
|
16629
16849
|
}
|
|
16630
16850
|
/**
|
|
@@ -16633,8 +16853,52 @@ export class RatatuiApp {
|
|
|
16633
16853
|
* Both hot restart (same session, new code) and resume-from-panel (another
|
|
16634
16854
|
* session, possibly another workspace) run through this one path so the
|
|
16635
16855
|
* relaunch semantics can never drift apart.
|
|
16856
|
+
*
|
|
16857
|
+
* Under a permission profile that limits the agent, ZTC takes no config.json edit to its hooks, MCP servers,
|
|
16858
|
+
* profiles, sandbox or extension roots while it runs, and the ZTC it would exec reads config.json afresh: while
|
|
16859
|
+
* config.json holds such an edit it starts none, says why, and returns false (it never returns otherwise). The
|
|
16860
|
+
* agent's own command can ask for a hot restart (SIGUSR1, as a mux pane's /restart does), so the edit another process
|
|
16861
|
+
* made would otherwise reach the agent's next command. `takesEdits`: the person asked for this restart (their /restart,
|
|
16862
|
+
* their pick in the resume panel), so it takes config.json as it is, as starting ZTC again would (the reviewer's owner
|
|
16863
|
+
* run: an owner's /restart after their own edit was refused). The restart after an update keeps the check. Where the
|
|
16864
|
+
* host pinned the permission settings (ZTC_PERMISSION_PROFILE_PINNED), an edit to them refuses every restart in place,
|
|
16865
|
+
* the person's included: the ZTC started again would pin what config.json says (config/permission_pin.ts). Under that
|
|
16866
|
+
* pin it also starts only in the folder the session started in, whose relative roots the pin holds, as the ZTC started
|
|
16867
|
+
* again pins them at the folder it starts in: an environment left elsewhere moved this process's folder to the one a
|
|
16868
|
+
* /cd named (the reviewer's resident probe, 2026-11-22), and the resume panel may pick a session that works elsewhere.
|
|
16636
16869
|
*/
|
|
16637
16870
|
async relaunchTui(options) {
|
|
16871
|
+
const pinFolder = configStore.permissionPinFolder();
|
|
16872
|
+
if (pinFolder !== undefined && !isPinFolder(options.cwd, pinFolder)) {
|
|
16873
|
+
const message = pinnedRestartFolderMessage(pinFolder, existsSync(pinFolder) ? options.cwd : pinFolder);
|
|
16874
|
+
debugLog(`[${options.label}] ${message}`);
|
|
16875
|
+
this.addSystemMessage(message);
|
|
16876
|
+
return false;
|
|
16877
|
+
}
|
|
16878
|
+
// Read config.json now either way, so this ZTC holds the edit too and writes it back on a save rather than over it.
|
|
16879
|
+
const untaken = await configStore.listSettingsARestartWouldTake();
|
|
16880
|
+
// Under the host's pin of the permission settings (ZTC_PERMISSION_PROFILE_PINNED), the ZTC started again in place
|
|
16881
|
+
// would pin what config.json says of them: an edit to them refuses the restart, whoever asks (the person included).
|
|
16882
|
+
const pinnedEdits = configStore.permissionsPinned() ? pinnedSettingsARestartWouldTake(untaken) : [];
|
|
16883
|
+
if (pinnedEdits.length > 0) {
|
|
16884
|
+
const message = pinnedRestartMessage(pinnedEdits);
|
|
16885
|
+
debugLog(`[${options.label}] ${message}`);
|
|
16886
|
+
this.addSystemMessage(message);
|
|
16887
|
+
return false;
|
|
16888
|
+
}
|
|
16889
|
+
if (untaken.length > 0 && !options.takesEdits) {
|
|
16890
|
+
const message = `ZTC did not start again in place: config.json changed ${untaken.join(', ')} since this ZTC started, `
|
|
16891
|
+
+ 'and under a permission profile that limits the agent, or one its host pinned, ZTC takes no such edit while it '
|
|
16892
|
+
+ 'runs, which a ZTC started again in place would. Start ZTC again yourself to take it, or put those settings back.';
|
|
16893
|
+
debugLog(`[${options.label}] ${message}`);
|
|
16894
|
+
this.addSystemMessage(message);
|
|
16895
|
+
return false;
|
|
16896
|
+
}
|
|
16897
|
+
// The person's restart takes the edit, as starting ZTC again would; it says so first, so one they didn't make is seen.
|
|
16898
|
+
if (untaken.length > 0) {
|
|
16899
|
+
this.addSystemMessage(`ZTC starts again in place with config.json as it is now, which changed ${untaken.join(', ')} `
|
|
16900
|
+
+ 'since this ZTC started.');
|
|
16901
|
+
}
|
|
16638
16902
|
try {
|
|
16639
16903
|
debugLog(`[${options.label}] Saving session before relaunch...`);
|
|
16640
16904
|
await this.saveCurrentSession();
|
|
@@ -16661,14 +16925,21 @@ export class RatatuiApp {
|
|
|
16661
16925
|
// reclaim the terminal, so the orphaned renderer fails with raw-mode EIO.
|
|
16662
16926
|
// Node 20 lacks execve; its fallback must wait until the replacement ends.
|
|
16663
16927
|
const runtime = process;
|
|
16928
|
+
// The ZTC that takes this one's place is this ZTC again: it is started with what the host-credential store took
|
|
16929
|
+
// out of this process's environment and what it minted (the host's grant, the platform login, the mirror's secret
|
|
16930
|
+
// and token), and takes them out of its own environment as it starts.
|
|
16931
|
+
// Under the host's pin of the permission settings, it is handed the variable, whatever this process's environment says
|
|
16932
|
+
// of it now, and what this ZTC's pin was taken from, and doesn't start where config.json, or the host's thread, says
|
|
16933
|
+
// otherwise by the time it reads them (config/permission_pin.ts).
|
|
16934
|
+
const relaunchEnv = { ...process.env, ...hostCredentialRelaunchEnv(), ...configStore.permissionPinRestartEnv() };
|
|
16664
16935
|
if (runtime.execve) {
|
|
16665
16936
|
process.chdir(spawnCwd);
|
|
16666
|
-
runtime.execve(command, [command, ...args],
|
|
16937
|
+
runtime.execve(command, [command, ...args], relaunchEnv);
|
|
16667
16938
|
}
|
|
16668
16939
|
const result = spawnSync(command, args, {
|
|
16669
16940
|
stdio: 'inherit',
|
|
16670
16941
|
cwd: spawnCwd,
|
|
16671
|
-
env:
|
|
16942
|
+
env: relaunchEnv,
|
|
16672
16943
|
shell,
|
|
16673
16944
|
});
|
|
16674
16945
|
if (result.error)
|
|
@@ -17237,12 +17508,17 @@ export class RatatuiApp {
|
|
|
17237
17508
|
this.instanceRegistry.reapStopped();
|
|
17238
17509
|
this.relaunchingFromPicker = true;
|
|
17239
17510
|
this.resumePanelWidget.cancel();
|
|
17240
|
-
await this.relaunchTui({
|
|
17511
|
+
const relaunched = await this.relaunchTui({
|
|
17241
17512
|
sessionId: entry.id,
|
|
17242
17513
|
cwd: entry.cwd || process.cwd(),
|
|
17243
17514
|
label: 'resumePanel',
|
|
17244
17515
|
failureMessage: `Could not resume ${entry.id}. Please run \`ztc resume ${entry.id}\` manually.`,
|
|
17516
|
+
// The person picked the session.
|
|
17517
|
+
takesEdits: true,
|
|
17245
17518
|
});
|
|
17519
|
+
// Not started in place (relaunchTui said why): this ZTC goes on with its own session.
|
|
17520
|
+
if (!relaunched)
|
|
17521
|
+
this.relaunchingFromPicker = false;
|
|
17246
17522
|
}
|
|
17247
17523
|
}
|
|
17248
17524
|
function getColonyService() {
|