@0xmaxma/claude-gateway 2.0.10 → 2.0.12
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 +15 -0
- package/config.template.json +1 -1
- package/dist/agent/runner.d.ts +119 -11
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +58 -8
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/browser-bindings-router.d.ts +6 -0
- package/dist/api/browser-bindings-router.d.ts.map +1 -0
- package/dist/api/browser-bindings-router.js +150 -0
- package/dist/api/browser-bindings-router.js.map +1 -0
- package/dist/api/connectors-router.js +1 -1
- package/dist/api/connectors-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +30 -2
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/jev-router.d.ts +8 -0
- package/dist/api/jev-router.d.ts.map +1 -0
- package/dist/api/jev-router.js +128 -0
- package/dist/api/jev-router.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +53 -6
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +42 -3
- package/dist/api/voice-router.js.map +1 -1
- package/dist/automation/browser-command.d.ts +79 -0
- package/dist/automation/browser-command.d.ts.map +1 -0
- package/dist/automation/browser-command.js +118 -0
- package/dist/automation/browser-command.js.map +1 -0
- package/dist/automation/browser-outcome.d.ts +3 -0
- package/dist/automation/browser-outcome.d.ts.map +1 -0
- package/dist/automation/browser-outcome.js +78 -0
- package/dist/automation/browser-outcome.js.map +1 -0
- package/dist/automation/browser-steps.d.ts +33 -0
- package/dist/automation/browser-steps.d.ts.map +1 -0
- package/dist/automation/browser-steps.js +293 -0
- package/dist/automation/browser-steps.js.map +1 -0
- package/dist/automation/browser-trace.d.ts +60 -0
- package/dist/automation/browser-trace.d.ts.map +1 -0
- package/dist/automation/browser-trace.js +24 -0
- package/dist/automation/browser-trace.js.map +1 -0
- package/dist/automation/browser-use.d.ts +210 -0
- package/dist/automation/browser-use.d.ts.map +1 -0
- package/dist/automation/browser-use.js +1271 -0
- package/dist/automation/browser-use.js.map +1 -0
- package/dist/automation/command-speech.d.ts +33 -0
- package/dist/automation/command-speech.d.ts.map +1 -0
- package/dist/automation/command-speech.js +117 -0
- package/dist/automation/command-speech.js.map +1 -0
- package/dist/automation/command-steps.d.ts +35 -0
- package/dist/automation/command-steps.d.ts.map +1 -0
- package/dist/automation/command-steps.js +155 -0
- package/dist/automation/command-steps.js.map +1 -0
- package/dist/automation/computer-choice-ids.d.ts +7 -0
- package/dist/automation/computer-choice-ids.d.ts.map +1 -0
- package/dist/automation/computer-choice-ids.js +24 -0
- package/dist/automation/computer-choice-ids.js.map +1 -0
- package/dist/automation/computer-command.d.ts +126 -0
- package/dist/automation/computer-command.d.ts.map +1 -0
- package/dist/automation/computer-command.js +313 -0
- package/dist/automation/computer-command.js.map +1 -0
- package/dist/automation/computer-outcome.d.ts +8 -0
- package/dist/automation/computer-outcome.d.ts.map +1 -0
- package/dist/automation/computer-outcome.js +82 -0
- package/dist/automation/computer-outcome.js.map +1 -0
- package/dist/automation/computer-policy.d.ts +84 -0
- package/dist/automation/computer-policy.d.ts.map +1 -0
- package/dist/automation/computer-policy.js +56 -0
- package/dist/automation/computer-policy.js.map +1 -0
- package/dist/automation/computer-safety.d.ts +27 -0
- package/dist/automation/computer-safety.d.ts.map +1 -0
- package/dist/automation/computer-safety.js +47 -0
- package/dist/automation/computer-safety.js.map +1 -0
- package/dist/automation/computer-steps.d.ts +20 -0
- package/dist/automation/computer-steps.d.ts.map +1 -0
- package/dist/automation/computer-steps.js +251 -0
- package/dist/automation/computer-steps.js.map +1 -0
- package/dist/automation/computer-use.d.ts +315 -0
- package/dist/automation/computer-use.d.ts.map +1 -0
- package/dist/automation/computer-use.js +864 -0
- package/dist/automation/computer-use.js.map +1 -0
- package/dist/automation/direct-command.d.ts +51 -0
- package/dist/automation/direct-command.d.ts.map +1 -0
- package/dist/automation/direct-command.js +152 -0
- package/dist/automation/direct-command.js.map +1 -0
- package/dist/automation/interrupt.d.ts +4 -0
- package/dist/automation/interrupt.d.ts.map +1 -0
- package/dist/automation/interrupt.js +26 -0
- package/dist/automation/interrupt.js.map +1 -0
- package/dist/build-provenance.json +4 -4
- package/dist/child-env-exclusions.d.ts +4 -0
- package/dist/child-env-exclusions.d.ts.map +1 -0
- package/dist/child-env-exclusions.js +23 -0
- package/dist/child-env-exclusions.js.map +1 -0
- package/dist/cli/startup-diagnostics.d.ts.map +1 -1
- package/dist/cli/startup-diagnostics.js +19 -0
- package/dist/cli/startup-diagnostics.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +4 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/reload-policy.d.ts.map +1 -1
- package/dist/config/reload-policy.js +2 -1
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/jev/automatic-browser-bindings.d.ts +15 -0
- package/dist/jev/automatic-browser-bindings.d.ts.map +1 -0
- package/dist/jev/automatic-browser-bindings.js +115 -0
- package/dist/jev/automatic-browser-bindings.js.map +1 -0
- package/dist/jev/browser-connector.d.ts +29 -0
- package/dist/jev/browser-connector.d.ts.map +1 -0
- package/dist/jev/browser-connector.js +347 -0
- package/dist/jev/browser-connector.js.map +1 -0
- package/dist/jev/browser-consent.d.ts +6 -0
- package/dist/jev/browser-consent.d.ts.map +1 -0
- package/dist/jev/browser-consent.js +50 -0
- package/dist/jev/browser-consent.js.map +1 -0
- package/dist/jev/browser-contract.d.ts +215 -0
- package/dist/jev/browser-contract.d.ts.map +1 -0
- package/dist/jev/browser-contract.js +10 -0
- package/dist/jev/browser-contract.js.map +1 -0
- package/dist/jev/browser-evidence-summary.d.ts +73 -0
- package/dist/jev/browser-evidence-summary.d.ts.map +1 -0
- package/dist/jev/browser-evidence-summary.js +22 -0
- package/dist/jev/browser-evidence-summary.js.map +1 -0
- package/dist/jev/browser-module-import.d.ts +3 -0
- package/dist/jev/browser-module-import.d.ts.map +1 -0
- package/dist/jev/browser-module-import.js +6 -0
- package/dist/jev/browser-module-import.js.map +1 -0
- package/dist/jev/child-env.d.ts +11 -0
- package/dist/jev/child-env.d.ts.map +1 -0
- package/dist/jev/child-env.js +60 -0
- package/dist/jev/child-env.js.map +1 -0
- package/dist/jev/computer-connector.d.ts +34 -0
- package/dist/jev/computer-connector.d.ts.map +1 -0
- package/dist/jev/computer-connector.js +82 -0
- package/dist/jev/computer-connector.js.map +1 -0
- package/dist/jev/computer-inputs.d.ts +41 -0
- package/dist/jev/computer-inputs.d.ts.map +1 -0
- package/dist/jev/computer-inputs.js +7 -0
- package/dist/jev/computer-inputs.js.map +1 -0
- package/dist/jev/index.d.ts +6 -0
- package/dist/jev/index.d.ts.map +1 -0
- package/dist/jev/index.js +25 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/jev/relay-grants.d.ts +9 -0
- package/dist/jev/relay-grants.d.ts.map +1 -0
- package/dist/jev/relay-grants.js +49 -0
- package/dist/jev/relay-grants.js.map +1 -0
- package/dist/jev/service.d.ts +27 -0
- package/dist/jev/service.d.ts.map +1 -0
- package/dist/jev/service.js +264 -0
- package/dist/jev/service.js.map +1 -0
- package/dist/jev/thinking-provider.d.ts +7 -0
- package/dist/jev/thinking-provider.d.ts.map +1 -0
- package/dist/jev/thinking-provider.js +25 -0
- package/dist/jev/thinking-provider.js.map +1 -0
- package/dist/jev/types.d.ts +124 -0
- package/dist/jev/types.d.ts.map +1 -0
- package/dist/jev/types.js +13 -0
- package/dist/jev/types.js.map +1 -0
- package/dist/jev/validation.d.ts +45 -0
- package/dist/jev/validation.d.ts.map +1 -0
- package/dist/jev/validation.js +179 -0
- package/dist/jev/validation.js.map +1 -0
- package/dist/load-dotenv.d.ts.map +1 -1
- package/dist/load-dotenv.js +5 -1
- package/dist/load-dotenv.js.map +1 -1
- package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/agent-tool-schemas.js +12 -7
- package/dist/orchestration/agent-tool-schemas.js.map +1 -1
- package/dist/orchestration/background-work.d.ts +1 -0
- package/dist/orchestration/background-work.d.ts.map +1 -1
- package/dist/orchestration/background-work.js +1 -0
- package/dist/orchestration/background-work.js.map +1 -1
- package/dist/orchestration/bridge.d.ts +4 -0
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +176 -41
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/browser-fields.d.ts +25 -0
- package/dist/orchestration/browser-fields.d.ts.map +1 -0
- package/dist/orchestration/browser-fields.js +23 -0
- package/dist/orchestration/browser-fields.js.map +1 -0
- package/dist/orchestration/browser-routing.d.ts +1 -1
- package/dist/orchestration/browser-routing.d.ts.map +1 -1
- package/dist/orchestration/browser-routing.js +7 -3
- package/dist/orchestration/browser-routing.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts +4 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +15 -9
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/channel-controls.js +1 -1
- package/dist/orchestration/channel-controls.js.map +1 -1
- package/dist/orchestration/cli-skills.d.ts.map +1 -1
- package/dist/orchestration/cli-skills.js +3 -2
- package/dist/orchestration/cli-skills.js.map +1 -1
- package/dist/orchestration/computer-end-screenshot.d.ts +11 -0
- package/dist/orchestration/computer-end-screenshot.d.ts.map +1 -0
- package/dist/orchestration/computer-end-screenshot.js +37 -0
- package/dist/orchestration/computer-end-screenshot.js.map +1 -0
- package/dist/orchestration/computer-prompt.d.ts +6 -0
- package/dist/orchestration/computer-prompt.d.ts.map +1 -0
- package/dist/orchestration/computer-prompt.js +24 -0
- package/dist/orchestration/computer-prompt.js.map +1 -0
- package/dist/orchestration/config.d.ts +17 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +10 -4
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/container-tool-schemas.d.ts +47 -3
- package/dist/orchestration/container-tool-schemas.d.ts.map +1 -1
- package/dist/orchestration/container-tool-schemas.js +41 -6
- package/dist/orchestration/container-tool-schemas.js.map +1 -1
- package/dist/orchestration/container.d.ts +4 -1
- package/dist/orchestration/container.d.ts.map +1 -1
- package/dist/orchestration/container.js +48 -29
- package/dist/orchestration/container.js.map +1 -1
- package/dist/orchestration/context-footprint.d.ts +1 -1
- package/dist/orchestration/context-footprint.d.ts.map +1 -1
- package/dist/orchestration/context-footprint.js +5 -5
- package/dist/orchestration/context-footprint.js.map +1 -1
- package/dist/orchestration/control-notification.d.ts +6 -0
- package/dist/orchestration/control-notification.d.ts.map +1 -0
- package/dist/orchestration/control-notification.js +23 -0
- package/dist/orchestration/control-notification.js.map +1 -0
- package/dist/orchestration/dashboard-reader-worker.js +2 -2
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
- package/dist/orchestration/execution-observation.d.ts +3 -0
- package/dist/orchestration/execution-observation.d.ts.map +1 -1
- package/dist/orchestration/execution-observation.js.map +1 -1
- package/dist/orchestration/gateway-tasks/browser.d.ts +59 -0
- package/dist/orchestration/gateway-tasks/browser.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/browser.js +426 -0
- package/dist/orchestration/gateway-tasks/browser.js.map +1 -0
- package/dist/orchestration/gateway-tasks/computer-context.d.ts +6 -0
- package/dist/orchestration/gateway-tasks/computer-context.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/computer-context.js +19 -0
- package/dist/orchestration/gateway-tasks/computer-context.js.map +1 -0
- package/dist/orchestration/gateway-tasks/computer.d.ts +123 -0
- package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -0
- package/dist/orchestration/gateway-tasks/computer.js +519 -0
- package/dist/orchestration/gateway-tasks/computer.js.map +1 -0
- package/dist/orchestration/gateway-tasks/controller.d.ts +40 -6
- package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/controller.js +118 -12
- package/dist/orchestration/gateway-tasks/controller.js.map +1 -1
- package/dist/orchestration/gateway-tasks/safemode.d.ts.map +1 -1
- package/dist/orchestration/gateway-tasks/safemode.js +2 -1
- package/dist/orchestration/gateway-tasks/safemode.js.map +1 -1
- package/dist/orchestration/jev-gateway.d.ts +25 -0
- package/dist/orchestration/jev-gateway.d.ts.map +1 -0
- package/dist/orchestration/jev-gateway.js +103 -0
- package/dist/orchestration/jev-gateway.js.map +1 -0
- package/dist/orchestration/jev-tool.d.ts +45 -0
- package/dist/orchestration/jev-tool.d.ts.map +1 -0
- package/dist/orchestration/jev-tool.js +10 -0
- package/dist/orchestration/jev-tool.js.map +1 -0
- package/dist/orchestration/live-execution-input.d.ts +26 -0
- package/dist/orchestration/live-execution-input.d.ts.map +1 -0
- package/dist/orchestration/live-execution-input.js +70 -0
- package/dist/orchestration/live-execution-input.js.map +1 -0
- package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
- package/dist/orchestration/notification-mailbox.js +5 -2
- package/dist/orchestration/notification-mailbox.js.map +1 -1
- package/dist/orchestration/process-platform.d.ts +0 -3
- package/dist/orchestration/process-platform.d.ts.map +1 -1
- package/dist/orchestration/process-platform.js +0 -4
- package/dist/orchestration/process-platform.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts +8 -0
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +65 -8
- package/dist/orchestration/process-turn.js.map +1 -1
- package/dist/orchestration/response-errors.d.ts.map +1 -1
- package/dist/orchestration/response-errors.js +1 -0
- package/dist/orchestration/response-errors.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +51 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +383 -27
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/skill-catalog-budget.d.ts +6 -0
- package/dist/orchestration/skill-catalog-budget.d.ts.map +1 -0
- package/dist/orchestration/skill-catalog-budget.js +9 -0
- package/dist/orchestration/skill-catalog-budget.js.map +1 -0
- package/dist/orchestration/skills.d.ts +4 -2
- package/dist/orchestration/skills.d.ts.map +1 -1
- package/dist/orchestration/skills.js +44 -3
- package/dist/orchestration/skills.js.map +1 -1
- package/dist/orchestration/store.d.ts +1 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js +2 -0
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/task-controls.d.ts +78 -8
- package/dist/orchestration/task-controls.d.ts.map +1 -1
- package/dist/orchestration/task-controls.js +6 -1
- package/dist/orchestration/task-controls.js.map +1 -1
- package/dist/orchestration/tasks/automation-session.d.ts +25 -0
- package/dist/orchestration/tasks/automation-session.d.ts.map +1 -0
- package/dist/orchestration/tasks/automation-session.js +68 -0
- package/dist/orchestration/tasks/automation-session.js.map +1 -0
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +3 -2
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +68 -7
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +646 -44
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/types.d.ts +82 -3
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js.map +1 -1
- package/dist/safemode/context.d.ts.map +1 -1
- package/dist/safemode/context.js +169 -72
- package/dist/safemode/context.js.map +1 -1
- package/dist/safemode/external-owners.d.ts +4 -1
- package/dist/safemode/external-owners.d.ts.map +1 -1
- package/dist/safemode/external-owners.js +36 -9
- package/dist/safemode/external-owners.js.map +1 -1
- package/dist/safemode/native.d.ts.map +1 -1
- package/dist/safemode/native.js +16 -10
- package/dist/safemode/native.js.map +1 -1
- package/dist/session/codex-extension-discovery.d.ts.map +1 -1
- package/dist/session/codex-extension-discovery.js +4 -2
- package/dist/session/codex-extension-discovery.js.map +1 -1
- package/dist/session/codex-native-mcp-client.d.ts.map +1 -1
- package/dist/session/codex-native-mcp-client.js +2 -1
- package/dist/session/codex-native-mcp-client.js.map +1 -1
- package/dist/session/codex-process.d.ts.map +1 -1
- package/dist/session/codex-process.js +9 -4
- package/dist/session/codex-process.js.map +1 -1
- package/dist/session/process.d.ts +16 -4
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +153 -75
- package/dist/session/process.js.map +1 -1
- package/dist/session/runtime-profile.d.ts +10 -5
- package/dist/session/runtime-profile.d.ts.map +1 -1
- package/dist/session/runtime-profile.js +5 -5
- package/dist/session/runtime-profile.js.map +1 -1
- package/dist/session/worker-extensions.d.ts.map +1 -1
- package/dist/session/worker-extensions.js +2 -1
- package/dist/session/worker-extensions.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-client.d.ts.map +1 -1
- package/dist/ui/dashboard-client.js +33 -3
- package/dist/ui/dashboard-client.js.map +1 -1
- package/dist/ui/web-ui.js +1 -1
- package/lib/automation/browser-thinking.cjs +9 -0
- package/lib/automation/browser-thinking.d.cts +2 -0
- package/lib/automation/computer-thinking.cjs +10 -0
- package/lib/automation/computer-thinking.d.cts +2 -0
- package/lib/automation/index.cjs +47 -0
- package/lib/automation/index.d.cts +3 -0
- package/lib/automation/reasoning-instructions.cjs +5 -0
- package/lib/automation/thinking.cjs +35 -0
- package/lib/automation/thinking.d.cts +2 -0
- package/mcp/capability-catalog.ts +2 -2
- package/mcp/server.ts +1 -1
- package/mcp/tools/tasks/module.ts +9 -0
- package/package.json +5 -3
- package/scripts/orchestration/smoke-safemode-codex.cjs +1 -1
|
@@ -20,6 +20,9 @@ export declare class SessionProcess extends EventEmitter {
|
|
|
20
20
|
readonly runtimeProfile?: RuntimeProfile | undefined;
|
|
21
21
|
private managedProcessGroup?;
|
|
22
22
|
private containerAttempt?;
|
|
23
|
+
/** Bumped by stop(): a spawnProcess() that awaited across it abandons its spawn. */
|
|
24
|
+
private spawnEpoch;
|
|
25
|
+
private starts;
|
|
23
26
|
managedGroupStopped: boolean;
|
|
24
27
|
get processId(): number | undefined;
|
|
25
28
|
get managedProcessId(): number | undefined;
|
|
@@ -185,12 +188,19 @@ export declare class SessionProcess extends EventEmitter {
|
|
|
185
188
|
/** Only trust connector namespaces actually written into this subprocess config. */
|
|
186
189
|
isSpawnedConnectorTool(name: string): boolean;
|
|
187
190
|
private managedMcpConfigPath?;
|
|
188
|
-
/**
|
|
191
|
+
/** Host file holding the appended system prompt (see writeSystemPromptFile). */
|
|
189
192
|
private systemPromptPath?;
|
|
190
193
|
private managedConnectorPaths;
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
/** `.sessions/<id>`, once a spawn without a runtime profile has written its mcp-config.json there. */
|
|
195
|
+
private sessionDirPath?;
|
|
196
|
+
/** The appended system prompt never travels on the command line: Windows caps a
|
|
197
|
+
* whole command line at 32767 characters and Linux caps ONE argument at 128 KiB
|
|
198
|
+
* (MAX_ARG_STRLEN), so a large workspace context or skill catalog would fail
|
|
199
|
+
* every spawn (#559); argv is also world-readable through /proc/<pid>/cmdline.
|
|
200
|
+
* The host CLI reads a 0600 file beside the attempt's MCP config (a 0700
|
|
201
|
+
* directory), named per spawn so stopping one spawn never removes another's.
|
|
202
|
+
* A container CLI reads one that prepareContainerProfile writes in its attempt
|
|
203
|
+
* directory, in the same docker exec as the attempt's mcp.json and ticket. */
|
|
194
204
|
private writeSystemPromptFile;
|
|
195
205
|
private writeMcpConfig;
|
|
196
206
|
/** Find the first API key that has access to this agent (agents: '*' or includes agentId). */
|
|
@@ -205,6 +215,8 @@ export declare class SessionProcess extends EventEmitter {
|
|
|
205
215
|
private resolveRecordRetrievals;
|
|
206
216
|
private buildArgs;
|
|
207
217
|
private static toStreamJsonTurn;
|
|
218
|
+
/** Resolves false when a stop() during its awaits abandoned the spawn: nothing was
|
|
219
|
+
* started, and a container attempt it prepared is already cleaned up. */
|
|
208
220
|
private spawnProcess;
|
|
209
221
|
private scheduleRestart;
|
|
210
222
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/session/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/session/process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAA6B,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AAMlG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGtD,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAevC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAqHvC,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR;AAqDD,qBAAa,cAAe,SAAQ,YAAY;IAsJ5C,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc;IArJ1C,OAAO,CAAC,mBAAmB,CAAC,CAAS;IACrC,OAAO,CAAC,gBAAgB,CAAC,CAAwC;IACjE,oFAAoF;IACpF,OAAO,CAAC,UAAU,CAAK;IAEvB,OAAO,CAAC,MAAM,CAAK;IACnB,mBAAmB,UAAS;IAC5B,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAA6D;IAChG,IAAI,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAAqC;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CA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AI;IAmB/C;;;;;;;OAOG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAkBhC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB1D,IAAI,YAAY,IAAI,OAAO,CAA6B;IAExD,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,iCAAiC;IAczC,OAAO,CAAC,4BAA4B;IAOpC;;;;;;;;OAQG;IACH,4BAA4B,IAAI,OAAO;IA8BvC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAwCpC,SAAS,IAAI,OAAO;IAYpB;;;;;;OAMG;IACH,oBAAoB,IAAI,OAAO;IAM/B,kBAAkB,IAAI,IAAI;IAQ1B;;;;;;OAMG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;;;;;;;;OASG;IACH,kBAAkB,IAAI,OAAO;IAI7B,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI/B;;;;;;;;OAQG;IACH,kCAAkC,IAAI,OAAO;IAK7C,SAAS,IAAI,OAAO;IAOpB,OAAO,CAAC,WAAW,CAAC,CAAqB;IACnC,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAEvE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkF5B"}
|
package/dist/session/process.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.SessionProcess = exports.INTERRUPTED_NO_REPLY_TEXT = exports.MAX_HISTORY_MESSAGES = void 0;
|
|
40
40
|
exports.resolveMaxHistoryMessages = resolveMaxHistoryMessages;
|
|
41
|
+
const child_env_1 = require("../jev/child-env");
|
|
41
42
|
const worker_environment_1 = require("./worker-environment");
|
|
42
43
|
const process_diagnostics_1 = require("./process-diagnostics");
|
|
43
44
|
const managed_connectors_1 = require("./managed-connectors");
|
|
@@ -52,12 +53,12 @@ const path = __importStar(require("path"));
|
|
|
52
53
|
const runtime_profile_1 = require("./runtime-profile");
|
|
53
54
|
const string_decoder_1 = require("string_decoder");
|
|
54
55
|
const process_supervisor_1 = require("../orchestration/process-supervisor");
|
|
55
|
-
const process_platform_1 = require("../orchestration/process-platform");
|
|
56
56
|
const capacity_1 = require("../orchestration/capacity");
|
|
57
|
+
const types_1 = require("../orchestration/types");
|
|
57
58
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
58
59
|
const knowledge_1 = require("../agent/knowledge");
|
|
59
60
|
const config_1 = require("../agent/dreaming/config");
|
|
60
|
-
const
|
|
61
|
+
const types_2 = require("../history/types");
|
|
61
62
|
const logger_1 = require("../logger");
|
|
62
63
|
const pty_stream_registry_1 = require("../shell/pty-stream-registry");
|
|
63
64
|
const screen_1 = require("../shell/screen");
|
|
@@ -253,6 +254,10 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
253
254
|
runtimeProfile) {
|
|
254
255
|
super();
|
|
255
256
|
this.runtimeProfile = runtimeProfile;
|
|
257
|
+
/** Bumped by stop(): a spawnProcess() that awaited across it abandons its spawn. */
|
|
258
|
+
this.spawnEpoch = 0;
|
|
259
|
+
// Bumped by every start(): a stop() still awaiting after one ran no longer owns the session's live state.
|
|
260
|
+
this.starts = 0;
|
|
256
261
|
this.managedGroupStopped = false;
|
|
257
262
|
this.lastActivityAt = Date.now(); // accessible by AgentRunner for eviction sort
|
|
258
263
|
// Wall-clock time of the most recent BACKGROUND_DISPATCH_TOOLS tool_use seen
|
|
@@ -370,7 +375,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
370
375
|
this.sessionId = sessionId;
|
|
371
376
|
this.source = source;
|
|
372
377
|
this.chatId = chatId ?? sessionId;
|
|
373
|
-
this.sessionChannel = (0,
|
|
378
|
+
this.sessionChannel = (0, types_2.toChatChannel)(source);
|
|
374
379
|
this.agentConfig = agentConfig;
|
|
375
380
|
this.gatewayConfig = gatewayConfig;
|
|
376
381
|
this.sessionStore = sessionStore;
|
|
@@ -422,6 +427,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
422
427
|
return this.agentConfig.claude.model;
|
|
423
428
|
}
|
|
424
429
|
async start() {
|
|
430
|
+
this.starts++;
|
|
425
431
|
this.stopping = false;
|
|
426
432
|
this.restartCount = 0;
|
|
427
433
|
this.setupRestartWatcher();
|
|
@@ -697,17 +703,22 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
697
703
|
return false;
|
|
698
704
|
return [...this.spawnedConnectors.keys()].some(id => name.startsWith(`mcp__${id}__`) && name.length > id.length + 7);
|
|
699
705
|
}
|
|
700
|
-
/**
|
|
701
|
-
*
|
|
702
|
-
*
|
|
706
|
+
/** The appended system prompt never travels on the command line: Windows caps a
|
|
707
|
+
* whole command line at 32767 characters and Linux caps ONE argument at 128 KiB
|
|
708
|
+
* (MAX_ARG_STRLEN), so a large workspace context or skill catalog would fail
|
|
709
|
+
* every spawn (#559); argv is also world-readable through /proc/<pid>/cmdline.
|
|
710
|
+
* The host CLI reads a 0600 file beside the attempt's MCP config (a 0700
|
|
711
|
+
* directory), named per spawn so stopping one spawn never removes another's.
|
|
712
|
+
* A container CLI reads one that prepareContainerProfile writes in its attempt
|
|
713
|
+
* directory, in the same docker exec as the attempt's mcp.json and ticket. */
|
|
703
714
|
writeSystemPromptFile(args, mcpConfigPath) {
|
|
704
|
-
if (!this.runtimeProfile
|
|
715
|
+
if (!this.runtimeProfile)
|
|
705
716
|
return args;
|
|
706
|
-
const file = path.join(path.dirname(mcpConfigPath ?? this.runtimeProfile.mcpConfigPath), `system-prompt-${this.sessionId.replace(/[^\w.-]/g, '_')}.md`);
|
|
717
|
+
const file = path.join(path.dirname(mcpConfigPath ?? this.runtimeProfile.mcpConfigPath), `system-prompt-${this.sessionId.replace(/[^\w.-]/g, '_')}-${(0, crypto_1.randomUUID)()}.md`);
|
|
707
718
|
const moved = (0, runtime_profile_1.appendSystemPromptViaFile)(args, file);
|
|
708
719
|
if (moved.prompt === undefined)
|
|
709
720
|
return args;
|
|
710
|
-
fs.writeFileSync(file, moved.prompt, { mode: 0o600 });
|
|
721
|
+
fs.writeFileSync(file, moved.prompt, { mode: 0o600, flag: 'wx' });
|
|
711
722
|
this.systemPromptPath = file;
|
|
712
723
|
return moved.args;
|
|
713
724
|
}
|
|
@@ -722,7 +733,11 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
722
733
|
const { servers, connectors } = (0, managed_connectors_1.prepareManagedConnectors)(this.agentConfig, this.gatewayConfig, this.runtimeProfile, this.managedConnectorPaths);
|
|
723
734
|
this.spawnedConnectors = new Map(Object.entries(connectors).map(([id, server]) => [id, connectorFingerprint(server)]));
|
|
724
735
|
const configPath = path.join(path.dirname(this.runtimeProfile.mcpConfigPath), 'managed-connectors.json');
|
|
725
|
-
|
|
736
|
+
const mcpServers = { ...servers, ...ticket.mcpServers };
|
|
737
|
+
for (const server of Object.values(mcpServers))
|
|
738
|
+
if (server?.env)
|
|
739
|
+
server.env = (0, child_env_1.sanitizeJevChildEnv)(server.env, this.gatewayConfig.gateway.jev);
|
|
740
|
+
fs.writeFileSync(configPath, JSON.stringify({ mcpServers }), { mode: 0o600 });
|
|
726
741
|
fs.chmodSync(configPath, 0o600);
|
|
727
742
|
this.managedMcpConfigPath = configPath;
|
|
728
743
|
return configPath;
|
|
@@ -739,6 +754,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
739
754
|
throw new Error('invalid session id');
|
|
740
755
|
}
|
|
741
756
|
fs.mkdirSync(sessionDir, { recursive: true, mode: 0o700 });
|
|
757
|
+
this.sessionDirPath = sessionDir;
|
|
742
758
|
const mcpServerPath = path.resolve(__dirname, '..', '..', 'mcp', 'server.ts');
|
|
743
759
|
// Merge stdio servers from Claude Code user + project configs (project overrides user).
|
|
744
760
|
// Skip the gateway's own server names from both — gateway always generates its own
|
|
@@ -884,6 +900,9 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
884
900
|
},
|
|
885
901
|
};
|
|
886
902
|
const configPath = path.join(sessionDir, 'mcp-config.json');
|
|
903
|
+
for (const server of Object.values(mcpConfig.mcpServers))
|
|
904
|
+
if (server?.env)
|
|
905
|
+
server.env = (0, child_env_1.sanitizeJevChildEnv)(server.env, this.gatewayConfig.gateway.jev);
|
|
887
906
|
fs.writeFileSync(configPath, JSON.stringify(mcpConfig, null, 2), { mode: 0o600 });
|
|
888
907
|
const serverNames = Object.keys(mcpConfig.mcpServers);
|
|
889
908
|
this.logger.debug('MCP config written', { sessionId: this.sessionId, servers: serverNames });
|
|
@@ -915,7 +934,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
915
934
|
const shared = (0, knowledge_1.resolveSharedConfig)(this.agentConfig.knowledge?.shared, this.gatewayConfig.gateway.knowledge?.shared).staleness;
|
|
916
935
|
return (personal.enabled && personal.recordRetrievals) || (shared.enabled && shared.recordRetrievals) ? '1' : '';
|
|
917
936
|
}
|
|
918
|
-
buildArgs(mcpConfigPath, model) {
|
|
937
|
+
buildArgs(mcpConfigPath, model, containerAttempt = this.containerAttempt) {
|
|
919
938
|
const args = [
|
|
920
939
|
'--model', model,
|
|
921
940
|
'--input-format', 'stream-json',
|
|
@@ -941,7 +960,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
941
960
|
throw error;
|
|
942
961
|
}
|
|
943
962
|
}
|
|
944
|
-
const profileArgs = (0, runtime_profile_1.runtimeProfileArgs)({ ...this.runtimeProfile, context, checkpointCommand:
|
|
963
|
+
const profileArgs = (0, runtime_profile_1.runtimeProfileArgs)({ ...this.runtimeProfile, context, checkpointCommand: containerAttempt && this.runtimeProfile.checkpointCommand ? `node ${containerAttempt.directory}/checkpoint.cjs ${containerAttempt.directory}/ticket.json` : this.runtimeProfile.checkpointCommand, containerExecution: this.agentConfig.type === 'app-agent', mcpConfigPath: containerAttempt?.config ?? mcpConfigPath ?? this.runtimeProfile.mcpConfigPath, skillPluginDir: containerAttempt && this.runtimeProfile.skillPluginDir ? containerAttempt.directory + '/skill-plugin' : this.runtimeProfile.skillPluginDir }, this.agentConfig.claude.extraFlags ?? []);
|
|
945
964
|
args.push(...profileArgs);
|
|
946
965
|
if (this.runtimeProfile.cliSession) {
|
|
947
966
|
const session = this.runtimeProfile.cliSession;
|
|
@@ -979,15 +998,33 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
979
998
|
message: { role: 'user', content: [{ type: 'text', text }, ...images] },
|
|
980
999
|
});
|
|
981
1000
|
}
|
|
1001
|
+
/** Resolves false when a stop() during its awaits abandoned the spawn: nothing was
|
|
1002
|
+
* started, and a container attempt it prepared is already cleaned up. */
|
|
982
1003
|
async spawnProcess() {
|
|
1004
|
+
const epoch = this.spawnEpoch;
|
|
983
1005
|
const { historyPrompt, loadedAtSpawn, archivedCount, messageCountAtSpawn } = await this.buildInitialPrompt();
|
|
1006
|
+
if (epoch !== this.spawnEpoch)
|
|
1007
|
+
return false;
|
|
984
1008
|
this.spawnContext = { loadedAtSpawn, archivedCount, messageCountAtSpawn };
|
|
985
1009
|
// Determine if this is a docker-exec app-agent before computing paths
|
|
986
1010
|
(0, container_1.assertContainerBinding)(this.agentConfig, this.runtimeProfile);
|
|
987
1011
|
const isAppAgent = this.agentConfig.type === 'app-agent' && !!this.agentConfig.container;
|
|
1012
|
+
const freshModel = this.readFreshModel();
|
|
1013
|
+
let containerArgs;
|
|
988
1014
|
if (isAppAgent && this.runtimeProfile) {
|
|
989
|
-
|
|
990
|
-
|
|
1015
|
+
const profile = this.runtimeProfile, container = this.agentConfig.container;
|
|
1016
|
+
const attempt = await (0, container_1.prepareContainerProfile)(this.agentConfig, profile, async (directory) => {
|
|
1017
|
+
profile.context = await (0, container_1.containerNode)(container, "process.stdout.write(require('fs').readFileSync('/workspace/CLAUDE.md','utf8'))");
|
|
1018
|
+
const moved = (0, runtime_profile_1.appendSystemPromptViaFile)(this.buildArgs(null, freshModel, { directory, config: directory + '/mcp.json' }), directory + '/system-prompt.md');
|
|
1019
|
+
containerArgs = moved.args;
|
|
1020
|
+
return moved.prompt;
|
|
1021
|
+
});
|
|
1022
|
+
// stop() could not see this attempt yet; remove its ticket and prompt here.
|
|
1023
|
+
if (epoch !== this.spawnEpoch) {
|
|
1024
|
+
await (0, container_1.stopContainerProfile)(container, attempt.directory);
|
|
1025
|
+
return false;
|
|
1026
|
+
}
|
|
1027
|
+
this.containerAttempt = attempt;
|
|
991
1028
|
}
|
|
992
1029
|
const mcpConfigPath = this.writeMcpConfig();
|
|
993
1030
|
// For app-agents, Claude runs inside the container where /workspace is mounted.
|
|
@@ -995,8 +1032,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
995
1032
|
const toContainerPath = (hostPath) => `/workspace/${path.relative(this.agentConfig.workspace, hostPath)}`;
|
|
996
1033
|
const effectiveMcpPath = (isAppAgent && mcpConfigPath) ? toContainerPath(mcpConfigPath) : mcpConfigPath;
|
|
997
1034
|
const containerRestartPath = isAppAgent ? toContainerPath(this.restartSignalPath) : this.restartSignalPath;
|
|
998
|
-
const
|
|
999
|
-
const args = this.writeSystemPromptFile(this.buildArgs(effectiveMcpPath, freshModel), effectiveMcpPath);
|
|
1035
|
+
const args = containerArgs ?? this.writeSystemPromptFile(this.buildArgs(effectiveMcpPath, freshModel), mcpConfigPath);
|
|
1000
1036
|
// Resolve the claude binary. An explicit CLAUDE_BIN (which may carry args) is
|
|
1001
1037
|
// parsed by parseClaudeBin; otherwise probe PATH and the native-installer / legacy
|
|
1002
1038
|
// install locations so a gateway launched with a minimal PATH still finds it.
|
|
@@ -1087,10 +1123,13 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1087
1123
|
containerUid = os.userInfo().uid;
|
|
1088
1124
|
}
|
|
1089
1125
|
catch { /* use 1000 */ }
|
|
1090
|
-
const configuredWorkerEnvironment = this.runtimeProfile?.role === 'worker' ? (0, worker_environment_1.workerEnvironment)(this.agentConfig, this.gatewayConfig) : {};
|
|
1126
|
+
const configuredWorkerEnvironment = (0, child_env_1.sanitizeJevChildEnv)(this.runtimeProfile?.role === 'worker' ? (0, worker_environment_1.workerEnvironment)(this.agentConfig, this.gatewayConfig) : {}, this.gatewayConfig.gateway.jev);
|
|
1127
|
+
const turnEnvironment = this.runtimeProfile?.role === 'agent' && this.runtimeProfile.claudeEffort
|
|
1128
|
+
? { CLAUDE_CODE_EFFORT_LEVEL: this.runtimeProfile.claudeEffort } : {};
|
|
1091
1129
|
const containerEnv = {
|
|
1092
1130
|
HOME: os.homedir(),
|
|
1093
1131
|
CLAUDE_WORKSPACE: '/workspace',
|
|
1132
|
+
...turnEnvironment,
|
|
1094
1133
|
GATEWAY_RESTART_SIGNAL_PATH: containerRestartPath,
|
|
1095
1134
|
};
|
|
1096
1135
|
if (!this.runtimeProfile && process.env.GATEWAY_API_URL)
|
|
@@ -1109,6 +1148,8 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1109
1148
|
const dockerEnvFlags = [
|
|
1110
1149
|
...Object.entries(containerEnv).flatMap(([k, v]) => ['-e', `${k}=${v}`]),
|
|
1111
1150
|
...byNameKeys.flatMap((k) => ['-e', k]),
|
|
1151
|
+
// Also mask values baked into an existing container's own environment.
|
|
1152
|
+
...(0, child_env_1.jevCredentialEnvNames)(this.gatewayConfig.gateway.jev).flatMap(k => ['-e', `${k}=`]),
|
|
1112
1153
|
];
|
|
1113
1154
|
const spawnArgs = isAppAgent
|
|
1114
1155
|
? [
|
|
@@ -1146,13 +1187,14 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1146
1187
|
let proc;
|
|
1147
1188
|
try {
|
|
1148
1189
|
proc = (0, child_process_1.spawn)(spawnBin, spawnArgs, {
|
|
1149
|
-
env: {
|
|
1190
|
+
env: (0, child_env_1.sanitizeJevChildEnv)({
|
|
1150
1191
|
...process.env,
|
|
1151
1192
|
...(!isAppAgent && this.runtimeProfile?.checkpointCommand && !this.runtimeProfile.hostExecution ? Object.fromEntries(CONTAINER_CREDENTIAL_KEYS.map(key => [key, undefined])) : {}),
|
|
1152
1193
|
...containerAuthEnv,
|
|
1153
1194
|
...(toolCapture ? { OTEL_LOG_RAW_API_BODIES: 'file:' + toolCapture.directory } : {}),
|
|
1154
1195
|
...(hardenedPath ? { PATH: hardenedPath } : {}),
|
|
1155
1196
|
...configuredWorkerEnvironment,
|
|
1197
|
+
...turnEnvironment,
|
|
1156
1198
|
GATEWAY_ORIGIN_SESSION_ID: this.runtimeProfile?.originSessionId ?? this.sessionId,
|
|
1157
1199
|
GATEWAY_TASK_ID: this.runtimeProfile?.taskId ?? '',
|
|
1158
1200
|
GATEWAY_TASK_ATTEMPT_ID: this.runtimeProfile?.attemptId ?? '',
|
|
@@ -1162,7 +1204,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1162
1204
|
...(ptyRealBin ? { CLAUDE_REAL_BIN: ptyRealBin } : {}),
|
|
1163
1205
|
...(ptyHeartbeatPath ? { PTY_SHELL_HEARTBEAT_PATH: ptyHeartbeatPath } : {}),
|
|
1164
1206
|
...(ptyStreamSocketPath ? { PTY_SHELL_STREAM_SOCKET: ptyStreamSocketPath } : {}),
|
|
1165
|
-
},
|
|
1207
|
+
}, this.gatewayConfig.gateway.jev),
|
|
1166
1208
|
cwd: this.agentConfig.workspace,
|
|
1167
1209
|
...(this.runtimeProfile?.role === 'worker' && (0, process_supervisor_1.processSupervisorSupported)() && (0, process_supervisor_1.workerSpawnDetached)() ? { detached: true } : {}),
|
|
1168
1210
|
windowsHide: true,
|
|
@@ -1172,9 +1214,18 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1172
1214
|
catch (error) {
|
|
1173
1215
|
toolCapture?.close();
|
|
1174
1216
|
releaseCapacity();
|
|
1217
|
+
// Node throws E2BIG/ENAMETOOLONG (and most other execve failures) from spawn()
|
|
1218
|
+
// itself; they never reach proc.on('error') below, so log them here. Sizes
|
|
1219
|
+
// only: the arguments may carry prompts and settings.
|
|
1220
|
+
const cause = error.code;
|
|
1221
|
+
const bytes = [spawnBin, ...spawnArgs].map(arg => Buffer.byteLength(arg));
|
|
1222
|
+
this.logger.error('session subprocess could not be spawned', { sessionId: this.sessionId, code: cause, argCount: bytes.length, largestArgBytes: Math.max(...bytes), totalArgBytes: bytes.reduce((sum, n) => sum + n, 0) });
|
|
1223
|
+
if (cause === 'E2BIG' || cause === 'ENAMETOOLONG')
|
|
1224
|
+
throw new types_1.OrchestrationError('PROCESS_ARGS_TOO_LARGE', `spawn ${cause}`);
|
|
1175
1225
|
throw error;
|
|
1176
1226
|
}
|
|
1177
1227
|
this.process = proc;
|
|
1228
|
+
const startsAtSpawn = this.starts;
|
|
1178
1229
|
proc.once('exit', releaseCapacity);
|
|
1179
1230
|
proc.once('exit', () => { setTimeout(() => toolCapture?.close(), 200).unref(); });
|
|
1180
1231
|
proc.once('error', () => toolCapture?.close());
|
|
@@ -1563,6 +1614,15 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1563
1614
|
});
|
|
1564
1615
|
if (ptyStreamSocketPath)
|
|
1565
1616
|
pty_stream_registry_1.ptyStreamRegistry.close(ptyStreamSocketPath);
|
|
1617
|
+
// A start() while an earlier stop() still waited for this exit owns the
|
|
1618
|
+
// session now, whether or not its child is attached yet; this exit is not
|
|
1619
|
+
// that session's death, so no 'exit' listener may see it and nothing restarts.
|
|
1620
|
+
// The stopped turn settles when its stop() resolves.
|
|
1621
|
+
if (this.starts !== startsAtSpawn || (this.process && this.process !== proc)) {
|
|
1622
|
+
if (this.process === proc)
|
|
1623
|
+
this.process = null;
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1566
1626
|
this.process = null;
|
|
1567
1627
|
this._exited = true;
|
|
1568
1628
|
this.resetBackgroundDispatchState();
|
|
@@ -1608,6 +1668,7 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1608
1668
|
this.emit('startup-error', Object.assign(new Error(code), { code }));
|
|
1609
1669
|
}
|
|
1610
1670
|
});
|
|
1671
|
+
return true;
|
|
1611
1672
|
}
|
|
1612
1673
|
scheduleRestart() {
|
|
1613
1674
|
// Graceful self-restart requested by agent — reset counter so it doesn't
|
|
@@ -1647,9 +1708,12 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
1647
1708
|
// sendMessage() will no longer silently no-op. Emitted on every
|
|
1648
1709
|
// successful crash-triggered respawn — cheap, and nothing currently
|
|
1649
1710
|
// listens outside that one call site.
|
|
1650
|
-
.then(
|
|
1711
|
+
.then(spawned => {
|
|
1651
1712
|
this._restartScheduled = false;
|
|
1652
|
-
|
|
1713
|
+
if (spawned)
|
|
1714
|
+
this.emit('restarted');
|
|
1715
|
+
else
|
|
1716
|
+
this.emit('restartFailed', new Error('Session restart abandoned: session stopping'));
|
|
1653
1717
|
})
|
|
1654
1718
|
.catch(err => {
|
|
1655
1719
|
this._restartScheduled = false;
|
|
@@ -2010,28 +2074,56 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
2010
2074
|
if (this.diagnostics.outcome === 'pending' && !this.diagnostics.stopReason)
|
|
2011
2075
|
this.diagnostics.stopReason = 'shutdown';
|
|
2012
2076
|
this.stopping = true;
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2077
|
+
this.spawnEpoch++;
|
|
2078
|
+
// Take over what the spawn being stopped wrote, so a start() while this stop
|
|
2079
|
+
// still waits for the exit records its own files from scratch. Connector and
|
|
2080
|
+
// MCP config files keep fixed names, and such a start() rewrites them in place:
|
|
2081
|
+
// at the exit, removeSessionDir skips every path that newer spawn holds again.
|
|
2082
|
+
const owned = {
|
|
2083
|
+
systemPrompt: this.systemPromptPath,
|
|
2084
|
+
connectors: [...this.managedConnectorPaths],
|
|
2085
|
+
managedMcpConfig: this.managedMcpConfigPath,
|
|
2086
|
+
};
|
|
2087
|
+
this.systemPromptPath = undefined;
|
|
2088
|
+
this.managedConnectorPaths = new Set();
|
|
2089
|
+
this.managedMcpConfigPath = undefined;
|
|
2090
|
+
this.sessionDirPath = undefined;
|
|
2091
|
+
// The same for the spawn's live state: a start() during the awaits below
|
|
2092
|
+
// attaches its own child, group, attempt and watcher, which this stop must
|
|
2093
|
+
// neither signal nor clear. A newer stop() of that spawn handles them.
|
|
2094
|
+
const starts = this.starts;
|
|
2095
|
+
const superseded = () => this.starts !== starts;
|
|
2096
|
+
const proc = this.process;
|
|
2097
|
+
const attempt = this.containerAttempt;
|
|
2098
|
+
const group = this.managedProcessGroup;
|
|
2099
|
+
const watcher = this.restartWatcher;
|
|
2100
|
+
this.restartWatcher = null;
|
|
2101
|
+
let exited = false;
|
|
2102
|
+
const exit = proc ? new Promise(resolve => proc.once('exit', () => { exited = true; resolve(); })) : undefined;
|
|
2103
|
+
this.resetBackgroundDispatchState();
|
|
2104
|
+
if (attempt && this.agentConfig.container) {
|
|
2105
|
+
this.managedGroupStopped = await (0, container_1.stopContainerProfile)(this.agentConfig.container, attempt.directory);
|
|
2106
|
+
if (this.containerAttempt === attempt)
|
|
2107
|
+
this.containerAttempt = undefined;
|
|
2016
2108
|
}
|
|
2017
|
-
if (
|
|
2018
|
-
const hostStopped = await (0, process_supervisor_1.stopProcessGroup)(
|
|
2109
|
+
if (group) {
|
|
2110
|
+
const hostStopped = await (0, process_supervisor_1.stopProcessGroup)(group);
|
|
2019
2111
|
this.managedGroupStopped = this.agentConfig.type === 'app-agent' ? this.managedGroupStopped && hostStopped : hostStopped;
|
|
2020
|
-
if (this.managedGroupStopped)
|
|
2112
|
+
if (this.managedGroupStopped && this.managedProcessGroup === group)
|
|
2021
2113
|
this.managedProcessGroup = undefined;
|
|
2022
2114
|
}
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
this.restartWatcher = null;
|
|
2026
|
-
try {
|
|
2027
|
-
fs.rmSync(this.restartSignalPath, { force: true });
|
|
2028
|
-
}
|
|
2029
|
-
catch { }
|
|
2030
|
-
if (this.source === 'telegram' && !this.runtimeProfile) {
|
|
2115
|
+
await watcher?.close();
|
|
2116
|
+
if (!superseded()) {
|
|
2031
2117
|
try {
|
|
2032
|
-
fs.rmSync(
|
|
2118
|
+
fs.rmSync(this.restartSignalPath, { force: true });
|
|
2033
2119
|
}
|
|
2034
2120
|
catch { }
|
|
2121
|
+
if (this.source === 'telegram' && !this.runtimeProfile) {
|
|
2122
|
+
try {
|
|
2123
|
+
fs.rmSync(path.join(this.typingDir, `${this.chatId}.processing`), { force: true });
|
|
2124
|
+
}
|
|
2125
|
+
catch { }
|
|
2126
|
+
}
|
|
2035
2127
|
}
|
|
2036
2128
|
// mcp-config.json under here holds fully-substituted secrets (channel bot
|
|
2037
2129
|
// tokens, GATEWAY_API_KEY, connector OAuth tokens) — it must not outlive
|
|
@@ -2041,56 +2133,42 @@ class SessionProcess extends events_1.EventEmitter {
|
|
|
2041
2133
|
// subprocess (or, for a container agent, the still-running container that
|
|
2042
2134
|
// bind-mounts this path) can be alive for up to the 10s graceful-shutdown
|
|
2043
2135
|
// window immediately after this point, and must not find it gone under it.
|
|
2136
|
+
// A newer spawn that wrote the shared directory owns it now; its stop removes it.
|
|
2044
2137
|
const removeSessionDir = () => {
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
if (this.managedMcpConfigPath) {
|
|
2053
|
-
try {
|
|
2054
|
-
fs.rmSync(this.managedMcpConfigPath, { force: true });
|
|
2055
|
-
}
|
|
2056
|
-
catch { }
|
|
2057
|
-
this.managedMcpConfigPath = undefined;
|
|
2058
|
-
}
|
|
2059
|
-
if (this.systemPromptPath) {
|
|
2060
|
-
try {
|
|
2061
|
-
fs.rmSync(this.systemPromptPath, { force: true });
|
|
2138
|
+
const reclaimed = (file) => this.managedConnectorPaths.has(file) || file === this.managedMcpConfigPath;
|
|
2139
|
+
for (const file of [...owned.connectors, owned.managedMcpConfig, owned.systemPrompt]) {
|
|
2140
|
+
if (file && !reclaimed(file)) {
|
|
2141
|
+
try {
|
|
2142
|
+
fs.rmSync(file, { force: true });
|
|
2143
|
+
}
|
|
2144
|
+
catch { }
|
|
2062
2145
|
}
|
|
2063
|
-
catch { }
|
|
2064
|
-
this.systemPromptPath = undefined;
|
|
2065
2146
|
}
|
|
2147
|
+
if (this.sessionDirPath)
|
|
2148
|
+
return;
|
|
2066
2149
|
try {
|
|
2067
2150
|
fs.rmSync(path.join(this.agentConfig.workspace, '.sessions', this.sessionId), { recursive: true, force: true });
|
|
2068
2151
|
}
|
|
2069
2152
|
catch { }
|
|
2070
2153
|
};
|
|
2071
|
-
|
|
2154
|
+
// A child that failed to spawn never exits; its 'error' handler already let go of it.
|
|
2155
|
+
if (!proc || exited || (this.process !== proc && !proc.pid)) {
|
|
2072
2156
|
removeSessionDir();
|
|
2073
2157
|
return;
|
|
2074
2158
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
forceKillTimer = setTimeout(() => {
|
|
2089
|
-
forceKillTimer = null;
|
|
2090
|
-
if (this.process)
|
|
2091
|
-
proc.kill('SIGKILL');
|
|
2092
|
-
}, 10000);
|
|
2093
|
-
});
|
|
2159
|
+
let forceKillTimer = null;
|
|
2160
|
+
proc.kill('SIGTERM');
|
|
2161
|
+
forceKillTimer = setTimeout(() => {
|
|
2162
|
+
forceKillTimer = null;
|
|
2163
|
+
if (!exited)
|
|
2164
|
+
proc.kill('SIGKILL');
|
|
2165
|
+
}, 10000);
|
|
2166
|
+
await exit;
|
|
2167
|
+
if (forceKillTimer !== null)
|
|
2168
|
+
clearTimeout(forceKillTimer);
|
|
2169
|
+
if (this.process === proc)
|
|
2170
|
+
this.process = null;
|
|
2171
|
+
removeSessionDir();
|
|
2094
2172
|
}
|
|
2095
2173
|
}
|
|
2096
2174
|
exports.SessionProcess = SessionProcess;
|