@bastani/atomic 0.10.1 → 0.10.2
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/CHANGELOG.md +95 -0
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/broker/watchdog.ts +4 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +32 -0
- package/dist/builtin/subagents/README.md +2 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/index.bundle.mjs +9 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -14
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +13 -9
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +6 -3
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
- package/dist/core/agent-session-nested-tools.js +2 -1
- package/dist/core/agent-session-nested-tools.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +12 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +6 -0
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +71 -4
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +9 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +15 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +40 -2
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +2 -1
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/export-html/template.js +14 -4
- package/dist/core/extensions/context-types.d.ts +6 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +100 -7
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +194 -4
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +32 -0
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
- package/dist/core/resume-cache-checkpoint.js +67 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -0
- package/dist/core/sdk-types.d.ts +37 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +57 -28
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +12 -3
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +13 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +38 -6
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +2 -1
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
- package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
- package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
- package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +72 -2
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +216 -15
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
- package/dist/core/storage/session/entry-structure.js +39 -2
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/storage/session/session-resume.d.ts.map +1 -1
- package/dist/core/storage/session/session-resume.js +1 -0
- package/dist/core/storage/session/session-resume.js.map +1 -1
- package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
- package/dist/core/storage/session/session-search-index.js +56 -9
- package/dist/core/storage/session/session-search-index.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +36 -0
- package/dist/core/storage/statement-sequence.d.ts.map +1 -0
- package/dist/core/storage/statement-sequence.js +22 -0
- package/dist/core/storage/statement-sequence.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +13 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +2 -1
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +4 -2
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +27 -5
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +2 -1
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +22 -22
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +7 -0
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/transformed-system-prompt.d.ts +92 -0
- package/dist/core/transformed-system-prompt.d.ts.map +1 -0
- package/dist/core/transformed-system-prompt.js +240 -0
- package/dist/core/transformed-system-prompt.js.map +1 -0
- package/dist/extensions/codemode/execute.js +1 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +16 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +13 -8
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +2 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +5 -0
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +289 -64
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +2 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +58 -0
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-records.js +129 -0
- package/dist/extensions/mcp/tool-records.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +65 -80
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +35 -28
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +16 -0
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +7 -0
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +8 -4
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +0 -1
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +6 -14
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +7 -6
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/token-segment.d.ts +2 -1
- package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
- package/dist/modes/interactive/components/token-segment.js +2 -4
- package/dist/modes/interactive/components/token-segment.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -2
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.js +0 -9
- package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
- package/dist/modes/interactive/extension-command-hold.js +45 -0
- package/dist/modes/interactive/extension-command-hold.js.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +2 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +18 -10
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +54 -13
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +15 -9
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +47 -1
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +165 -65
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/screen-hold.d.ts +3 -0
- package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
- package/dist/modes/interactive/screen-hold.js +9 -1
- package/dist/modes/interactive/screen-hold.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js +5 -4
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +0 -13
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +74 -10
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +27 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +81 -5
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +9 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +16 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +10 -2
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +2 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.js +1 -0
- package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts.map +1 -1
- package/dist/utils/interactive-engine-env.js +1 -0
- package/dist/utils/interactive-engine-env.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +2 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/token-count.d.ts +8 -0
- package/dist/utils/token-count.d.ts.map +1 -0
- package/dist/utils/token-count.js +25 -0
- package/dist/utils/token-count.js.map +1 -0
- package/dist/utils/worker-threads.d.ts +18 -0
- package/dist/utils/worker-threads.d.ts.map +1 -0
- package/dist/utils/worker-threads.js +28 -0
- package/dist/utils/worker-threads.js.map +1 -0
- package/docs/background-tasks.md +13 -12
- package/docs/compaction.md +2 -2
- package/docs/development.md +1 -1
- package/docs/extensions/api-reference.md +5 -3
- package/docs/extensions/events.md +2 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/storage.md +3 -1
- package/docs/subagents.md +6 -2
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -2,6 +2,7 @@ import { setCapabilityOverrides } from "@bastani/atomic-tui";
|
|
|
2
2
|
import { chatReceipt } from "../../core/chat-receipts.js";
|
|
3
3
|
import { FooterDataProvider } from "../../core/footer-data-provider.js";
|
|
4
4
|
import { waitForRawStdoutBackpressure } from "../../core/output-guard.js";
|
|
5
|
+
import { withQueuedDeliveryChange } from "../../core/queued-message-delivery.js";
|
|
5
6
|
import { serializeInteractiveEngineMessage } from "../interactive-engine/protocol.js";
|
|
6
7
|
import { toJsonEvent } from "../json-event.js";
|
|
7
8
|
import { bindAgentPanel } from "./agent-panel-bridge.js";
|
|
@@ -25,12 +26,13 @@ export class RpcSessionBinding {
|
|
|
25
26
|
sessionPicker;
|
|
26
27
|
inputForm;
|
|
27
28
|
writeEngineLine;
|
|
29
|
+
queuedDeliveries;
|
|
28
30
|
requestShutdown;
|
|
29
31
|
checkShutdownRequested;
|
|
30
32
|
reloadCoordinator;
|
|
31
33
|
onStartupReload;
|
|
32
34
|
footerDataProvider;
|
|
33
|
-
constructor({ runtimeHost, output, pendingExtensionRequests, extensionUICapabilities, requestShutdown, checkShutdownRequested, customUi, renderService, sessionPicker, inputForm, writeEngineLine, reloadCoordinator, onStartupReload, }) {
|
|
35
|
+
constructor({ runtimeHost, output, pendingExtensionRequests, extensionUICapabilities, requestShutdown, checkShutdownRequested, customUi, renderService, sessionPicker, inputForm, writeEngineLine, queuedDeliveries, reloadCoordinator, onStartupReload, }) {
|
|
34
36
|
this.runtimeHost = runtimeHost;
|
|
35
37
|
this.output = output;
|
|
36
38
|
this.pendingExtensionRequests = pendingExtensionRequests;
|
|
@@ -42,6 +44,7 @@ export class RpcSessionBinding {
|
|
|
42
44
|
this.sessionPicker = sessionPicker;
|
|
43
45
|
this.inputForm = inputForm;
|
|
44
46
|
this.writeEngineLine = writeEngineLine;
|
|
47
|
+
this.queuedDeliveries = queuedDeliveries;
|
|
45
48
|
this.reloadCoordinator = reloadCoordinator;
|
|
46
49
|
this.onStartupReload = onStartupReload;
|
|
47
50
|
this.session = runtimeHost.session;
|
|
@@ -72,6 +75,10 @@ export class RpcSessionBinding {
|
|
|
72
75
|
get currentSession() {
|
|
73
76
|
return this.session;
|
|
74
77
|
}
|
|
78
|
+
/** The bound session is being replaced: its later events tell the host nothing about queued messages. */
|
|
79
|
+
retireQueuedDeliveries() {
|
|
80
|
+
this.queuedDeliveries?.retire(this.session);
|
|
81
|
+
}
|
|
75
82
|
async rebindSession() {
|
|
76
83
|
if (this.session === this.runtimeHost.session && this.boundRunner === this.session.extensionRunner)
|
|
77
84
|
return;
|
|
@@ -201,7 +208,8 @@ export class RpcSessionBinding {
|
|
|
201
208
|
const receipt = this.writeEngineLine && chatReceipt(event);
|
|
202
209
|
const json = toJsonEvent(event);
|
|
203
210
|
const withSaved = saved === undefined ? json : { ...json, entryId: saved.entryId, seq: saved.seq };
|
|
204
|
-
|
|
211
|
+
const record = withQueuedDeliveryChange(withSaved, this.queuedDeliveries?.note(session, event));
|
|
212
|
+
this.output(receipt ? { ...record, atomicChatReceipt: receipt } : record);
|
|
205
213
|
if (event.type === "agent_settled")
|
|
206
214
|
this.checkShutdownRequested?.();
|
|
207
215
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,E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-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionInternalSurface } from \"../../core/agent-session-methods.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { chatReceipt } from \"../../core/chat-receipts.js\";\nimport type { ProjectTrustContext } from \"../../core/extensions/index.js\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { serializeInteractiveEngineMessage } from \"../interactive-engine/protocol.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { bindAgentPanel } from \"./agent-panel-bridge.ts\";\nimport { bindEngineAgentView } from \"./agent-view-rpc.ts\";\nimport { outputExtensionLoadErrors } from \"./rpc-extension-load-errors.ts\";\nimport {\n\tcreateRpcExtensionUIContext,\n\ttype RpcExtensionUICapabilities,\n\ttype RpcPendingExtensionRequests,\n} from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\nimport { engineTaskInspectorUi } from \"./task-ui-bridge.js\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\textensionUICapabilities?: RpcExtensionUICapabilities;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\t/** Send terminal UI updates from the interactive engine child to its host. */\n\twriteEngineLine?: (line: string) => void;\n\trequestShutdown: () => void;\n\tcheckShutdownRequested?: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n\tonStartupReload?: (session: AgentSession) => Promise<void>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate boundRunner: AgentSession[\"extensionRunner\"] | undefined;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate unsubscribeTasks?: () => void;\n\tprivate stopAgentView?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly extensionUICapabilities: RpcExtensionUICapabilities | undefined;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly writeEngineLine: ((line: string) => void) | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly checkShutdownRequested: (() => void) | undefined;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\tprivate readonly onStartupReload: ((session: AgentSession) => Promise<void>) | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\textensionUICapabilities,\n\t\trequestShutdown,\n\t\tcheckShutdownRequested,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\twriteEngineLine,\n\t\treloadCoordinator,\n\t\tonStartupReload,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.extensionUICapabilities = extensionUICapabilities;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.checkShutdownRequested = checkShutdownRequested;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.writeEngineLine = writeEngineLine;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.onStartupReload = onStartupReload;\n\t\tthis.session = runtimeHost.session;\n\t\tthis.runtimeHost.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\t}\n\n\tprivate createProjectTrustContext(cwd: string): ProjectTrustContext {\n\t\tconst runner = this.runtimeHost.session.extensionRunner;\n\t\tconst ui = runner.getUIContext();\n\t\tconst hasUI = this.customUi !== undefined;\n\t\treturn {\n\t\t\tcwd,\n\t\t\tmode: hasUI ? \"tui\" : \"rpc\",\n\t\t\thasUI,\n\t\t\tui: {\n\t\t\t\tselect: (title, options, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"select\", title, () => ui.select(title, options, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"confirm\", title, () => ui.confirm(title, message, opts))\n\t\t\t\t\t\t: Promise.resolve(false),\n\t\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"input\", title, () => ui.input(title, placeholder, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tnotify: (message, type) => ui.notify(message, type),\n\t\t\t},\n\t\t};\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tif (this.session === this.runtimeHost.session && this.boundRunner === this.session.extensionRunner) return;\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tsetCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());\n\t\tthis.renderService?.bindSession(session);\n\t\tconst footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\tthis.footerDataProvider = footerDataProvider;\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tfooterDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tonUIPrompt: (event) => {\n\t\t\t\t\tif (event.reason === \"ui_prompt\") {\n\t\t\t\t\t\tthis.writeEngineLine?.(serializeInteractiveEngineMessage({ type: \"engine_ui_prompt\", event }));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider,\n\t\t\t\t\tcapabilities: this.extensionUICapabilities,\n\t\t\t\t\tgetToolDefinition: (name) =>\n\t\t\t\t\t\tsession.extensionRunner.resolveToolRenderers(name, () => session.getToolDefinition(name)),\n\t\t\t\t\tgetCustomMessageRenderer: (name) => session.extensionRunner.getMessageRenderer(name),\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, { ...options, history: \"tail\" });\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\t// The interactive engine's user sees extension errors on the host; a standalone RPC client keeps failed starts.\n\t\t\t\treportStartupErrors: this.customUi !== undefined,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t\t...(this.customUi &&\n\t\t\t\t\t\t(err.event === \"session_start\" || err.event === \"resources_discover\") &&\n\t\t\t\t\t\terr.stack\n\t\t\t\t\t\t\t? { stack: err.stack }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tfooterDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails. A concurrent rebind may already own the binding's\n\t\t\t// footer, so only clear the one this bind created.\n\t\t\tfooterDataProvider.dispose();\n\t\t\tif (this.footerDataProvider === footerDataProvider) this.footerDataProvider = undefined;\n\t\t\t// RPC admits commands while the startup bind is still starting extensions, so a\n\t\t\t// replacement (or shutdown) can close this session mid-start (#4711). Its successor,\n\t\t\t// if any, is bound by its own rebind; nothing is left to bind here.\n\t\t\tif (isSessionClosed(error) && (session as unknown as AgentSessionInternalSurface)._disposed) return;\n\t\t\tthrow error;\n\t\t}\n\t\t// A replacement bound its own session while this bind was pending; its state is not ours.\n\t\tif (session !== this.session) {\n\t\t\tfooterDataProvider.dispose();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.customUi) {\n\t\t\tconst customUi = this.customUi;\n\t\t\tconst ui = session.extensionRunner.getUIContext();\n\t\t\t// The host shows this engine's subagents on its own screen through these views.\n\t\t\tthis.stopAgentView?.();\n\t\t\tthis.stopAgentView = bindEngineAgentView({\n\t\t\t\tsession,\n\t\t\t\tsend: (message) => this.writeEngineLine?.(serializeInteractiveEngineMessage(message)),\n\t\t\t\tcustomUi,\n\t\t\t\tui,\n\t\t\t});\n\t\t\tthis.unsubscribeTasks = bindAgentPanel(\n\t\t\t\tsession,\n\t\t\t\tui,\n\t\t\t\t(counts) => {\n\t\t\t\t\tthis.writeEngineLine?.(\n\t\t\t\t\t\tserializeInteractiveEngineMessage({ type: \"engine_agent_panel_state\", ...counts }),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tengineTaskInspectorUi(ui, {\n\t\t\t\t\tcustom: customUi.custom.bind(customUi),\n\t\t\t\t\tgetHostRenderSettings: () => customUi.getHostRenderSettings(),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\t// A finished message carries its save receipt, so a host can tell which saved entry its rows show.\n\t\t\tconst saved = event.type === \"message_end\" ? session.entryReceipt?.(event.message) : undefined;\n\t\t\tconst receipt = this.writeEngineLine && chatReceipt(event);\n\t\t\tconst json = toJsonEvent(event);\n\t\t\tconst withSaved = saved === undefined ? json : { ...json, entryId: saved.entryId, seq: saved.seq };\n\t\t\tthis.output(receipt ? { ...withSaved, atomicChatReceipt: receipt } : withSaved);\n\t\t\tif (event.type === \"agent_settled\") this.checkShutdownRequested?.();\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t\tthis.boundRunner = session.extensionRunner;\n\t}\n\n\t/** Load and atomically publish the optional resource set after the minimal interactive engine binds. */\n\tasync loadDeferredResources(): Promise<void> {\n\t\tconst session = this.session;\n\t\ttry {\n\t\t\tif (!(await this.runtimeHost.completeStartup?.())) {\n\t\t\t\tawait session.reload({ reason: \"startup\" });\n\t\t\t\tawait this.onStartupReload?.(session);\n\t\t\t}\n\t\t} finally {\n\t\t\toutputExtensionLoadErrors(session, \"startup\", this.output);\n\t\t}\n\t\tif (session !== this.session) return;\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.boundRunner = undefined;\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.unsubscribeTasks?.();\n\t\tthis.unsubscribeTasks = undefined;\n\t\tthis.stopAgentView?.();\n\t\tthis.stopAgentView = undefined;\n\t\tthis.writeEngineLine?.(\n\t\t\tserializeInteractiveEngineMessage({\n\t\t\t\ttype: \"engine_ui_prompt\",\n\t\t\t\tevent: { type: \"ui_prompt_end\", reason: \"ui_prompt\", kind: \"custom\" },\n\t\t\t}),\n\t\t);\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n\nfunction isSessionClosed(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && (error as { code?: unknown }).code === \"SessionClosed\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAA4B,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAK3G,OAAO,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACN,2BAA2B,GAG3B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAqB5D,MAAM,OAAO,iBAAiB;IACrB,OAAO,CAAe;IACtB,WAAW,CAA8C;IACzD,WAAW,CAAc;IACzB,uBAAuB,CAAc;IACrC,gBAAgB,CAAc;IAC9B,aAAa,CAAc;IAClB,WAAW,CAAsB;IACjC,MAAM,CAAY;IAClB,wBAAwB,CAA8B;IACtD,uBAAuB,CAAyC;IAChE,QAAQ,CAAoC;IAC5C,aAAa,CAAkC;IAC/C,aAAa,CAAyC;IACtD,SAAS,CAAqC;IAC9C,eAAe,CAAuC;IACtD,gBAAgB,CAAkC;IAClD,eAAe,CAAa;IAC5B,sBAAsB,CAA2B;IACjD,iBAAiB,CAAyD;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mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,oBAAoB;QACnB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,eAAe,EAAE,CACrB,iCAAiC,CAAC;YACjC,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;SACrE,CAAC,CACF,CAAC;QACF,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;CACD;AAED,SAAS,eAAe,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAA4B,CAAC,IAAI,KAAK,eAAe,CAAC;AAC9G,CAAC","sourcesContent":["import { setCapabilityOverrides } from \"@bastani/atomic-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionInternalSurface } from \"../../core/agent-session-methods.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { chatReceipt } from \"../../core/chat-receipts.js\";\nimport type { ProjectTrustContext } from \"../../core/extensions/index.js\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport { type QueuedDeliveryRelay, withQueuedDeliveryChange } from \"../../core/queued-message-delivery.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { serializeInteractiveEngineMessage } from \"../interactive-engine/protocol.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { bindAgentPanel } from \"./agent-panel-bridge.ts\";\nimport { bindEngineAgentView } from \"./agent-view-rpc.ts\";\nimport { outputExtensionLoadErrors } from \"./rpc-extension-load-errors.ts\";\nimport {\n\tcreateRpcExtensionUIContext,\n\ttype RpcExtensionUICapabilities,\n\ttype RpcPendingExtensionRequests,\n} from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\nimport { engineTaskInspectorUi } from \"./task-ui-bridge.js\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\textensionUICapabilities?: RpcExtensionUICapabilities;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\t/** Send terminal UI updates from the interactive engine child to its host. */\n\twriteEngineLine?: (line: string) => void;\n\t/** Tells a host that asked for them which queued messages the session is delivering, on its event lines. */\n\tqueuedDeliveries?: QueuedDeliveryRelay;\n\trequestShutdown: () => void;\n\tcheckShutdownRequested?: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n\tonStartupReload?: (session: AgentSession) => Promise<void>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate boundRunner: AgentSession[\"extensionRunner\"] | undefined;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate unsubscribeTasks?: () => void;\n\tprivate stopAgentView?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly extensionUICapabilities: RpcExtensionUICapabilities | undefined;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly writeEngineLine: ((line: string) => void) | undefined;\n\tprivate readonly queuedDeliveries: QueuedDeliveryRelay | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly checkShutdownRequested: (() => void) | undefined;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\tprivate readonly onStartupReload: ((session: AgentSession) => Promise<void>) | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\textensionUICapabilities,\n\t\trequestShutdown,\n\t\tcheckShutdownRequested,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\twriteEngineLine,\n\t\tqueuedDeliveries,\n\t\treloadCoordinator,\n\t\tonStartupReload,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.extensionUICapabilities = extensionUICapabilities;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.checkShutdownRequested = checkShutdownRequested;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.writeEngineLine = writeEngineLine;\n\t\tthis.queuedDeliveries = queuedDeliveries;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.onStartupReload = onStartupReload;\n\t\tthis.session = runtimeHost.session;\n\t\tthis.runtimeHost.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\t}\n\n\tprivate createProjectTrustContext(cwd: string): ProjectTrustContext {\n\t\tconst runner = this.runtimeHost.session.extensionRunner;\n\t\tconst ui = runner.getUIContext();\n\t\tconst hasUI = this.customUi !== undefined;\n\t\treturn {\n\t\t\tcwd,\n\t\t\tmode: hasUI ? \"tui\" : \"rpc\",\n\t\t\thasUI,\n\t\t\tui: {\n\t\t\t\tselect: (title, options, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"select\", title, () => ui.select(title, options, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"confirm\", title, () => ui.confirm(title, message, opts))\n\t\t\t\t\t\t: Promise.resolve(false),\n\t\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"input\", title, () => ui.input(title, placeholder, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tnotify: (message, type) => ui.notify(message, type),\n\t\t\t},\n\t\t};\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\t/** The bound session is being replaced: its later events tell the host nothing about queued messages. */\n\tretireQueuedDeliveries(): void {\n\t\tthis.queuedDeliveries?.retire(this.session);\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tif (this.session === this.runtimeHost.session && this.boundRunner === this.session.extensionRunner) return;\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tsetCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());\n\t\tthis.renderService?.bindSession(session);\n\t\tconst footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\tthis.footerDataProvider = footerDataProvider;\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tfooterDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tonUIPrompt: (event) => {\n\t\t\t\t\tif (event.reason === \"ui_prompt\") {\n\t\t\t\t\t\tthis.writeEngineLine?.(serializeInteractiveEngineMessage({ type: \"engine_ui_prompt\", event }));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider,\n\t\t\t\t\tcapabilities: this.extensionUICapabilities,\n\t\t\t\t\tgetToolDefinition: (name) =>\n\t\t\t\t\t\tsession.extensionRunner.resolveToolRenderers(name, () => session.getToolDefinition(name)),\n\t\t\t\t\tgetCustomMessageRenderer: (name) => session.extensionRunner.getMessageRenderer(name),\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, { ...options, history: \"tail\" });\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\t// The interactive engine's user sees extension errors on the host; a standalone RPC client keeps failed starts.\n\t\t\t\treportStartupErrors: this.customUi !== undefined,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t\t...(this.customUi &&\n\t\t\t\t\t\t(err.event === \"session_start\" || err.event === \"resources_discover\") &&\n\t\t\t\t\t\terr.stack\n\t\t\t\t\t\t\t? { stack: err.stack }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tfooterDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails. A concurrent rebind may already own the binding's\n\t\t\t// footer, so only clear the one this bind created.\n\t\t\tfooterDataProvider.dispose();\n\t\t\tif (this.footerDataProvider === footerDataProvider) this.footerDataProvider = undefined;\n\t\t\t// RPC admits commands while the startup bind is still starting extensions, so a\n\t\t\t// replacement (or shutdown) can close this session mid-start (#4711). Its successor,\n\t\t\t// if any, is bound by its own rebind; nothing is left to bind here.\n\t\t\tif (isSessionClosed(error) && (session as unknown as AgentSessionInternalSurface)._disposed) return;\n\t\t\tthrow error;\n\t\t}\n\t\t// A replacement bound its own session while this bind was pending; its state is not ours.\n\t\tif (session !== this.session) {\n\t\t\tfooterDataProvider.dispose();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.customUi) {\n\t\t\tconst customUi = this.customUi;\n\t\t\tconst ui = session.extensionRunner.getUIContext();\n\t\t\t// The host shows this engine's subagents on its own screen through these views.\n\t\t\tthis.stopAgentView?.();\n\t\t\tthis.stopAgentView = bindEngineAgentView({\n\t\t\t\tsession,\n\t\t\t\tsend: (message) => this.writeEngineLine?.(serializeInteractiveEngineMessage(message)),\n\t\t\t\tcustomUi,\n\t\t\t\tui,\n\t\t\t});\n\t\t\tthis.unsubscribeTasks = bindAgentPanel(\n\t\t\t\tsession,\n\t\t\t\tui,\n\t\t\t\t(counts) => {\n\t\t\t\t\tthis.writeEngineLine?.(\n\t\t\t\t\t\tserializeInteractiveEngineMessage({ type: \"engine_agent_panel_state\", ...counts }),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tengineTaskInspectorUi(ui, {\n\t\t\t\t\tcustom: customUi.custom.bind(customUi),\n\t\t\t\t\tgetHostRenderSettings: () => customUi.getHostRenderSettings(),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\t// A finished message carries its save receipt, so a host can tell which saved entry its rows show.\n\t\t\tconst saved = event.type === \"message_end\" ? session.entryReceipt?.(event.message) : undefined;\n\t\t\tconst receipt = this.writeEngineLine && chatReceipt(event);\n\t\t\tconst json = toJsonEvent(event);\n\t\t\tconst withSaved = saved === undefined ? json : { ...json, entryId: saved.entryId, seq: saved.seq };\n\t\t\tconst record = withQueuedDeliveryChange(withSaved, this.queuedDeliveries?.note(session, event));\n\t\t\tthis.output(receipt ? { ...record, atomicChatReceipt: receipt } : record);\n\t\t\tif (event.type === \"agent_settled\") this.checkShutdownRequested?.();\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t\tthis.boundRunner = session.extensionRunner;\n\t}\n\n\t/** Load and atomically publish the optional resource set after the minimal interactive engine binds. */\n\tasync loadDeferredResources(): Promise<void> {\n\t\tconst session = this.session;\n\t\ttry {\n\t\t\tif (!(await this.runtimeHost.completeStartup?.())) {\n\t\t\t\tawait session.reload({ reason: \"startup\" });\n\t\t\t\tawait this.onStartupReload?.(session);\n\t\t\t}\n\t\t} finally {\n\t\t\toutputExtensionLoadErrors(session, \"startup\", this.output);\n\t\t}\n\t\tif (session !== this.session) return;\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.boundRunner = undefined;\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.unsubscribeTasks?.();\n\t\tthis.unsubscribeTasks = undefined;\n\t\tthis.stopAgentView?.();\n\t\tthis.stopAgentView = undefined;\n\t\tthis.writeEngineLine?.(\n\t\t\tserializeInteractiveEngineMessage({\n\t\t\t\ttype: \"engine_ui_prompt\",\n\t\t\t\tevent: { type: \"ui_prompt_end\", reason: \"ui_prompt\", kind: \"custom\" },\n\t\t\t}),\n\t\t);\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n\nfunction isSessionClosed(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && (error as { code?: unknown }).code === \"SessionClosed\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-resize.d.ts","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAGjB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"image-resize.d.ts","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAGjB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAiE/E;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAqB9B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAO5E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Worker } from "node:worker_threads";
|
|
2
2
|
import { IMAGE_RESIZE_WORKER_RESPONSE_TYPE, resizeImageInProcess, } from "./image-resize-core.js";
|
|
3
|
+
import { startModuleWorker } from "./worker-threads.js";
|
|
3
4
|
function toTransferableBytes(input) {
|
|
4
5
|
// Transfer detaches the buffer, so transfer a worker-owned copy and leave the
|
|
5
6
|
// caller's bytes intact.
|
|
@@ -9,7 +10,7 @@ function isResizeImageWorkerResponse(value) {
|
|
|
9
10
|
return (value !== null && typeof value === "object" && "type" in value && value.type === IMAGE_RESIZE_WORKER_RESPONSE_TYPE);
|
|
10
11
|
}
|
|
11
12
|
function createResizeWorker(workerSpecifier) {
|
|
12
|
-
return new Worker(workerSpecifier);
|
|
13
|
+
return typeof workerSpecifier === "string" ? new Worker(workerSpecifier) : startModuleWorker(workerSpecifier);
|
|
13
14
|
}
|
|
14
15
|
async function resizeImageInWorker(workerSpecifier, inputBytes, mimeType, options) {
|
|
15
16
|
const worker = createResizeWorker(workerSpecifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-resize.js","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACN,iCAAiC,EAIjC,oBAAoB,GACpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"image-resize.js","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACN,iCAAiC,EAIjC,oBAAoB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,SAAS,mBAAmB,CAAC,KAAiB;IAC7C,8EAA8E;IAC9E,yBAAyB;IACzB,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,2BAA2B,CAAC,KAAc;IAClD,OAAO,CACN,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iCAAiC,CAClH,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,eAA6B;IACxD,OAAO,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,eAA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OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;IAClD,OAAO,oBAAoB,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,cAAc,kBAAkB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,6BAA6B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC;AACnM,CAAC","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport {\n\tIMAGE_RESIZE_WORKER_RESPONSE_TYPE,\n\ttype ImageResizeOptions,\n\ttype ResizedImage,\n\ttype ResizeImageWorkerResponse,\n\tresizeImageInProcess,\n} from \"./image-resize-core.js\";\nimport { startModuleWorker } from \"./worker-threads.js\";\n\nexport type { ImageResizeOptions, ResizedImage } from \"./image-resize-core.js\";\n\nfunction toTransferableBytes(input: Uint8Array): Uint8Array<ArrayBuffer> {\n\t// Transfer detaches the buffer, so transfer a worker-owned copy and leave the\n\t// caller's bytes intact.\n\treturn new Uint8Array(input);\n}\n\nfunction isResizeImageWorkerResponse(value: unknown): value is ResizeImageWorkerResponse {\n\treturn (\n\t\tvalue !== null && typeof value === \"object\" && \"type\" in value && value.type === IMAGE_RESIZE_WORKER_RESPONSE_TYPE\n\t);\n}\n\nfunction createResizeWorker(workerSpecifier: string | URL): Worker {\n\treturn typeof workerSpecifier === \"string\" ? new Worker(workerSpecifier) : startModuleWorker(workerSpecifier);\n}\n\nasync function resizeImageInWorker(\n\tworkerSpecifier: string | URL,\n\tinputBytes: Uint8Array,\n\tmimeType: string,\n\toptions?: ImageResizeOptions,\n): Promise<ResizedImage | null> {\n\tconst worker = createResizeWorker(workerSpecifier);\n\ttry {\n\t\tconst inputBytesForWorker = toTransferableBytes(inputBytes);\n\t\treturn await new Promise<ResizedImage | null>((resolve, reject) => {\n\t\t\tlet settled = false;\n\t\t\tconst settle = (result: ResizedImage | null): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolve(result);\n\t\t\t};\n\t\t\tconst fail = (error: Error): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tworker.on(\"message\", (message: unknown) => {\n\t\t\t\tif (!isResizeImageWorkerResponse(message)) return;\n\t\t\t\tif (\"error\" in message) fail(new Error(message.error));\n\t\t\t\telse settle(message.result);\n\t\t\t});\n\t\t\tworker.once(\"error\", fail);\n\t\t\tworker.once(\"exit\", (code) => {\n\t\t\t\tif (!settled) {\n\t\t\t\t\tfail(new Error(`Image resize worker exited with code ${code}`));\n\t\t\t\t}\n\t\t\t});\n\t\t\tworker.postMessage(\n\t\t\t\t{\n\t\t\t\t\tinputBytes: inputBytesForWorker,\n\t\t\t\t\tmimeType,\n\t\t\t\t\toptions,\n\t\t\t\t},\n\t\t\t\t[inputBytesForWorker.buffer],\n\t\t\t);\n\t\t});\n\t} finally {\n\t\tawait worker.terminate();\n\t}\n}\n\n/**\n * Resize an image to fit within the specified max dimensions and encoded file size.\n * Runs Photon in a worker thread so WASM decoding, resizing, and encoding do not\n * block the TUI event loop. If the worker cannot be loaded (for example in some\n * Bun compiled executable layouts), fall back to in-process resizing so image\n * reads still work.\n */\nexport async function resizeImage(\n\tinputBytes: Uint8Array,\n\tmimeType: string,\n\toptions?: ImageResizeOptions,\n): Promise<ResizedImage | null> {\n\tconst isTypeScriptRuntime = import.meta.url.endsWith(\".ts\");\n\tconst workerUrl = new URL(\n\t\tisTypeScriptRuntime ? \"./image-resize-worker.ts\" : \"./image-resize-worker.js\",\n\t\timport.meta.url,\n\t);\n\n\t// Bun compiled executables resolve worker entrypoints by string path, not via\n\t// new URL(..., import.meta.url). Try the string path first under Bun so the\n\t// release binary uses the embedded worker instead of falling back in-process.\n\tif (typeof process.versions.bun === \"string\") {\n\t\ttry {\n\t\t\treturn await resizeImageInWorker(\"./src/utils/image-resize-worker.ts\", inputBytes, mimeType, options);\n\t\t} catch {}\n\t}\n\n\ttry {\n\t\treturn await resizeImageInWorker(workerUrl, inputBytes, mimeType, options);\n\t} catch {\n\t\treturn resizeImageInProcess(inputBytes, mimeType, options);\n\t}\n}\n\n/**\n * Format a dimension note for resized images.\n * This helps the model understand the coordinate mapping.\n */\nexport function formatDimensionNote(result: ResizedImage): string | undefined {\n\tif (!result.wasResized) {\n\t\treturn undefined;\n\t}\n\n\tconst scale = result.originalWidth / result.width;\n\treturn `[Image: original ${result.originalWidth}x${result.originalHeight}, displayed at ${result.width}x${result.height}. Multiply coordinates by ${scale.toFixed(2)} to map to original image.]`;\n}\n"]}
|
|
@@ -36,6 +36,8 @@ export interface InteractiveEngineBootstrap {
|
|
|
36
36
|
trustDecisions?: SessionTrustDecisions;
|
|
37
37
|
/** The host accepts a pending withdrawal, distinct from a settled trust decision. */
|
|
38
38
|
projectResourceWithdrawals?: true;
|
|
39
|
+
/** The host draws the queued messages the main session is delivering, from changes on the engine's event lines. */
|
|
40
|
+
queuedDeliveries?: true;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Proof that this process created a bootstrap record. A bare path — in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-engine-bootstrap.d.ts","sourceRoot":"","sources":["../../src/utils/interactive-engine-bootstrap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,oCAAoC,IAAI,CAAC;AACtD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,8BAA8B,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,qFAAqF;IACrF,0BAA0B,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive-engine-bootstrap.d.ts","sourceRoot":"","sources":["../../src/utils/interactive-engine-bootstrap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,oCAAoC,IAAI,CAAC;AACtD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,8BAA8B,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,qFAAqF;IACrF,0BAA0B,CAAC,EAAE,IAAI,CAAC;IAClC,mHAAmH;IACnH,gBAAgB,CAAC,EAAE,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC,GACjD,gCAAgC,CAclC;AAED,qFAAqF;AACrF,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,gCAAgC,GAAG,SAAS,GAAG,IAAI,CAGhH;AAED,wBAAsB,oCAAoC,CACzD,MAAM,EAAE,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC,GACjD,OAAO,CAAC,gCAAgC,CAAC,CAc3C;AAED,wBAAsB,0CAA0C,CAC/D,MAAM,EAAE,gCAAgC,GAAG,SAAS,GAClD,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG;IAC3E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB,CAgBA;AAED,2EAA2E;AAC3E,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS,CA0BnG"}
|
|
@@ -138,6 +138,7 @@ export function readInteractiveEngineBootstrap(path) {
|
|
|
138
138
|
...(typeof parsed.apiKey === "string" ? { apiKey: parsed.apiKey } : {}),
|
|
139
139
|
...(trustDecisions ? { trustDecisions } : {}),
|
|
140
140
|
...(parsed.projectResourceWithdrawals === true ? { projectResourceWithdrawals: true } : {}),
|
|
141
|
+
...(parsed.queuedDeliveries === true ? { queuedDeliveries: true } : {}),
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-engine-bootstrap.js","sourceRoot":"","sources":["../../src/utils/interactive-engine-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,6BAA6B,CAAC;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C,gBAAgB,CAAC;KACxD,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC;QACjG,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,OAAO,KAAK,SAAS;YAAE,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC7D,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { mkdtemp, rename, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { SessionTrustDecisions } from \"../core/project-trust-state.ts\";\n\n/**\n * Private startup channel for the isolated interactive engine.\n *\n * The engine child needs four control values (engine role, host PID, guardian\n * path, and optionally an API key) before its runtime exists. They used to\n * travel as environment variables, which cannot be taken back: under Bun a\n * child spawned without an explicit `env` inherits the runtime's launch-time\n * environment map, so deleting the variables from `process.env` afterwards does\n * not stop arbitrary extension or hook code from leaking them — including the\n * API key — into its own subprocesses.\n *\n * The engine is therefore launched with an environment that never contained the\n * values, and the values travel in a 0600 file whose path is passed as a private\n * CLI argument. The child reads it once, freezes the snapshot, and unlinks it.\n * The filename carries no secret material.\n *\n * Cleanup is ownership-scoped. The path is untrusted child input — anyone can\n * pass the private flag — so a reader may unlink only that exact file. Only the\n * writer, which holds an {@link InteractiveEngineBootstrapHandle} for the\n * directory it created, may remove that directory recursively.\n */\nexport const INTERACTIVE_ENGINE_BOOTSTRAP_FLAG = \"--internal-engine-bootstrap\";\nexport const INTERACTIVE_ENGINE_BOOTSTRAP_VERSION = 1;\n/**\n * The only argument of an engine child an interactive host starts before it knows the engine's arguments: the child\n * loads the application, then reads them from its first stdin line (see engine-prewarm.ts).\n */\nexport const INTERACTIVE_ENGINE_PREWARM_FLAG = \"--internal-engine-prewarm\";\n\nexport interface InteractiveEngineBootstrap {\n\tversion: number;\n\thostPid: number;\n\tguardFile: string;\n\tapiKey?: string;\n\t/** Trust decisions the host session already made; never saved to trust.json. */\n\ttrustDecisions?: SessionTrustDecisions;\n\t/** The host accepts a pending withdrawal, distinct from a settled trust decision. */\n\tprojectResourceWithdrawals?: true;\n}\n\n/**\n * Proof that this process created a bootstrap record. A bare path — in\n * particular one taken from argv — is never sufficient for recursive removal.\n */\nexport interface InteractiveEngineBootstrapHandle {\n\treadonly path: string;\n\treadonly directory: string;\n}\n\n/**\n * Publish a bootstrap record atomically so a reader never sees a partial file.\n *\n * On any failure the exact temporary file and the directory this call created\n * are removed before the original error propagates, so a `0600` file holding a\n * credential is never left behind.\n */\nexport function writeInteractiveEngineBootstrap(\n\trecord: Omit<InteractiveEngineBootstrap, \"version\">,\n): InteractiveEngineBootstrapHandle {\n\tconst directory = mkdtempSync(join(tmpdir(), \"atomic-engine-bootstrap-\"));\n\tconst path = join(directory, \"bootstrap.json\");\n\tconst tempPath = `${path}.tmp`;\n\tconst payload: InteractiveEngineBootstrap = { version: INTERACTIVE_ENGINE_BOOTSTRAP_VERSION, ...record };\n\ttry {\n\t\twriteFileSync(tempPath, JSON.stringify(payload), { encoding: \"utf8\", mode: 0o600 });\n\t\trenameSync(tempPath, path);\n\t} catch (error) {\n\t\trmSync(tempPath, { force: true });\n\t\trmSync(directory, { recursive: true, force: true });\n\t\tthrow error;\n\t}\n\treturn { path, directory };\n}\n\n/** Remove a bootstrap record and the directory whose creation this handle proves. */\nexport function removeOwnedInteractiveEngineBootstrap(handle: InteractiveEngineBootstrapHandle | undefined): void {\n\tif (!handle) return;\n\trmSync(handle.directory, { recursive: true, force: true });\n}\n\nexport async function writeInteractiveEngineBootstrapAsync(\n\trecord: Omit<InteractiveEngineBootstrap, \"version\">,\n): Promise<InteractiveEngineBootstrapHandle> {\n\tconst directory = await mkdtemp(join(tmpdir(), \"atomic-engine-bootstrap-\"));\n\tconst path = join(directory, \"bootstrap.json\");\n\tconst tempPath = `${path}.tmp`;\n\tconst payload: InteractiveEngineBootstrap = { version: INTERACTIVE_ENGINE_BOOTSTRAP_VERSION, ...record };\n\ttry {\n\t\tawait writeFile(tempPath, JSON.stringify(payload), { encoding: \"utf8\", mode: 0o600 });\n\t\tawait rename(tempPath, path);\n\t} catch (error) {\n\t\tawait rm(tempPath, { force: true }).catch(() => {});\n\t\tawait rm(directory, { recursive: true, force: true }).catch(() => {});\n\t\tthrow error;\n\t}\n\treturn { path, directory };\n}\n\nexport async function removeOwnedInteractiveEngineBootstrapAsync(\n\thandle: InteractiveEngineBootstrapHandle | undefined,\n): Promise<void> {\n\tif (!handle) return;\n\tawait rm(handle.directory, { recursive: true, force: true }).catch(() => {});\n}\n\n/**\n * Split the private bootstrap argument out of an argv slice.\n *\n * Returns the remaining arguments so normal CLI parsing never sees the flag.\n */\nexport function takeInteractiveEngineBootstrapArg(args: readonly string[]): {\n\targs: string[];\n\tpath: string | undefined;\n} {\n\tconst remaining: string[] = [];\n\tlet path: string | undefined;\n\tfor (let index = 0; index < args.length; index += 1) {\n\t\tconst value = args[index]!;\n\t\tif (value === INTERACTIVE_ENGINE_BOOTSTRAP_FLAG && index + 1 < args.length) {\n\t\t\tpath = args[++index];\n\t\t\tcontinue;\n\t\t}\n\t\tif (value.startsWith(`${INTERACTIVE_ENGINE_BOOTSTRAP_FLAG}=`)) {\n\t\t\tpath = value.slice(INTERACTIVE_ENGINE_BOOTSTRAP_FLAG.length + 1);\n\t\t\tcontinue;\n\t\t}\n\t\tremaining.push(value);\n\t}\n\treturn { args: remaining, path };\n}\n\n/** True when this argv belongs to an isolated interactive engine child. */\nexport function hasInteractiveEngineBootstrapArg(args: readonly string[]): boolean {\n\treturn takeInteractiveEngineBootstrapArg(args).path !== undefined;\n}\n\n/**\n * Read and consume a bootstrap record.\n *\n * The named file is always unlinked, including on malformed content, so a stale\n * API key never outlives the handshake. The path came from argv, so nothing\n * around it is touched: no parent directory, no sibling.\n */\nexport function readInteractiveEngineBootstrap(path: string): InteractiveEngineBootstrap | undefined {\n\tlet raw: string;\n\ttry {\n\t\traw = readFileSync(path, \"utf8\");\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\trmSync(path, { force: true });\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as Partial<InteractiveEngineBootstrap>;\n\t\tif (parsed.version !== INTERACTIVE_ENGINE_BOOTSTRAP_VERSION) return undefined;\n\t\tif (typeof parsed.hostPid !== \"number\" || typeof parsed.guardFile !== \"string\") return undefined;\n\t\tconst trustDecisions = readTrustDecisions(parsed.trustDecisions);\n\t\treturn {\n\t\t\tversion: parsed.version,\n\t\t\thostPid: parsed.hostPid,\n\t\t\tguardFile: parsed.guardFile,\n\t\t\t...(typeof parsed.apiKey === \"string\" ? { apiKey: parsed.apiKey } : {}),\n\t\t\t...(trustDecisions ? { trustDecisions } : {}),\n\t\t\t...(parsed.projectResourceWithdrawals === true ? { projectResourceWithdrawals: true } : {}),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The trust decisions of a bootstrap record: only true or false values by path; anything else is left out. */\nfunction readTrustDecisions(value: unknown): SessionTrustDecisions | undefined {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tconst decisions = {\n\t\tprojects: readDecisions(record.projects),\n\t\textensionSources: readDecisions(record.extensionSources),\n\t};\n\treturn Object.keys(decisions.projects).length + Object.keys(decisions.extensionSources).length > 0\n\t\t? decisions\n\t\t: undefined;\n}\n\nfunction readDecisions(value: unknown): Record<string, boolean> {\n\tconst decisions: Record<string, boolean> = {};\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return decisions;\n\tfor (const [path, trusted] of Object.entries(value)) {\n\t\tif (typeof trusted === \"boolean\") decisions[path] = trusted;\n\t}\n\treturn decisions;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-engine-bootstrap.js","sourceRoot":"","sources":["../../src/utils/interactive-engine-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,6BAA6B,CAAC;AAC/E,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,CAAC;AACtD;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,2BAA2B,CAAC;AAwB3E;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAC9C,MAAmD;IAEnD,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,GAAG,IAAI,MAAM,CAAC;IAC/B,MAAM,OAAO,GAA+B,EAAE,OAAO,EAAE,oCAAoC,EAAE,GAAG,MAAM,EAA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,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,OAAO,KAAK,SAAS;YAAE,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC7D,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { mkdtemp, rename, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { SessionTrustDecisions } from \"../core/project-trust-state.ts\";\n\n/**\n * Private startup channel for the isolated interactive engine.\n *\n * The engine child needs four control values (engine role, host PID, guardian\n * path, and optionally an API key) before its runtime exists. They used to\n * travel as environment variables, which cannot be taken back: under Bun a\n * child spawned without an explicit `env` inherits the runtime's launch-time\n * environment map, so deleting the variables from `process.env` afterwards does\n * not stop arbitrary extension or hook code from leaking them — including the\n * API key — into its own subprocesses.\n *\n * The engine is therefore launched with an environment that never contained the\n * values, and the values travel in a 0600 file whose path is passed as a private\n * CLI argument. The child reads it once, freezes the snapshot, and unlinks it.\n * The filename carries no secret material.\n *\n * Cleanup is ownership-scoped. The path is untrusted child input — anyone can\n * pass the private flag — so a reader may unlink only that exact file. Only the\n * writer, which holds an {@link InteractiveEngineBootstrapHandle} for the\n * directory it created, may remove that directory recursively.\n */\nexport const INTERACTIVE_ENGINE_BOOTSTRAP_FLAG = \"--internal-engine-bootstrap\";\nexport const INTERACTIVE_ENGINE_BOOTSTRAP_VERSION = 1;\n/**\n * The only argument of an engine child an interactive host starts before it knows the engine's arguments: the child\n * loads the application, then reads them from its first stdin line (see engine-prewarm.ts).\n */\nexport const INTERACTIVE_ENGINE_PREWARM_FLAG = \"--internal-engine-prewarm\";\n\nexport interface InteractiveEngineBootstrap {\n\tversion: number;\n\thostPid: number;\n\tguardFile: string;\n\tapiKey?: string;\n\t/** Trust decisions the host session already made; never saved to trust.json. */\n\ttrustDecisions?: SessionTrustDecisions;\n\t/** The host accepts a pending withdrawal, distinct from a settled trust decision. */\n\tprojectResourceWithdrawals?: true;\n\t/** The host draws the queued messages the main session is delivering, from changes on the engine's event lines. */\n\tqueuedDeliveries?: true;\n}\n\n/**\n * Proof that this process created a bootstrap record. A bare path — in\n * particular one taken from argv — is never sufficient for recursive removal.\n */\nexport interface InteractiveEngineBootstrapHandle {\n\treadonly path: string;\n\treadonly directory: string;\n}\n\n/**\n * Publish a bootstrap record atomically so a reader never sees a partial file.\n *\n * On any failure the exact temporary file and the directory this call created\n * are removed before the original error propagates, so a `0600` file holding a\n * credential is never left behind.\n */\nexport function writeInteractiveEngineBootstrap(\n\trecord: Omit<InteractiveEngineBootstrap, \"version\">,\n): InteractiveEngineBootstrapHandle {\n\tconst directory = mkdtempSync(join(tmpdir(), \"atomic-engine-bootstrap-\"));\n\tconst path = join(directory, \"bootstrap.json\");\n\tconst tempPath = `${path}.tmp`;\n\tconst payload: InteractiveEngineBootstrap = { version: INTERACTIVE_ENGINE_BOOTSTRAP_VERSION, ...record };\n\ttry {\n\t\twriteFileSync(tempPath, JSON.stringify(payload), { encoding: \"utf8\", mode: 0o600 });\n\t\trenameSync(tempPath, path);\n\t} catch (error) {\n\t\trmSync(tempPath, { force: true });\n\t\trmSync(directory, { recursive: true, force: true });\n\t\tthrow error;\n\t}\n\treturn { path, directory };\n}\n\n/** Remove a bootstrap record and the directory whose creation this handle proves. */\nexport function removeOwnedInteractiveEngineBootstrap(handle: InteractiveEngineBootstrapHandle | undefined): void {\n\tif (!handle) return;\n\trmSync(handle.directory, { recursive: true, force: true });\n}\n\nexport async function writeInteractiveEngineBootstrapAsync(\n\trecord: Omit<InteractiveEngineBootstrap, \"version\">,\n): Promise<InteractiveEngineBootstrapHandle> {\n\tconst directory = await mkdtemp(join(tmpdir(), \"atomic-engine-bootstrap-\"));\n\tconst path = join(directory, \"bootstrap.json\");\n\tconst tempPath = `${path}.tmp`;\n\tconst payload: InteractiveEngineBootstrap = { version: INTERACTIVE_ENGINE_BOOTSTRAP_VERSION, ...record };\n\ttry {\n\t\tawait writeFile(tempPath, JSON.stringify(payload), { encoding: \"utf8\", mode: 0o600 });\n\t\tawait rename(tempPath, path);\n\t} catch (error) {\n\t\tawait rm(tempPath, { force: true }).catch(() => {});\n\t\tawait rm(directory, { recursive: true, force: true }).catch(() => {});\n\t\tthrow error;\n\t}\n\treturn { path, directory };\n}\n\nexport async function removeOwnedInteractiveEngineBootstrapAsync(\n\thandle: InteractiveEngineBootstrapHandle | undefined,\n): Promise<void> {\n\tif (!handle) return;\n\tawait rm(handle.directory, { recursive: true, force: true }).catch(() => {});\n}\n\n/**\n * Split the private bootstrap argument out of an argv slice.\n *\n * Returns the remaining arguments so normal CLI parsing never sees the flag.\n */\nexport function takeInteractiveEngineBootstrapArg(args: readonly string[]): {\n\targs: string[];\n\tpath: string | undefined;\n} {\n\tconst remaining: string[] = [];\n\tlet path: string | undefined;\n\tfor (let index = 0; index < args.length; index += 1) {\n\t\tconst value = args[index]!;\n\t\tif (value === INTERACTIVE_ENGINE_BOOTSTRAP_FLAG && index + 1 < args.length) {\n\t\t\tpath = args[++index];\n\t\t\tcontinue;\n\t\t}\n\t\tif (value.startsWith(`${INTERACTIVE_ENGINE_BOOTSTRAP_FLAG}=`)) {\n\t\t\tpath = value.slice(INTERACTIVE_ENGINE_BOOTSTRAP_FLAG.length + 1);\n\t\t\tcontinue;\n\t\t}\n\t\tremaining.push(value);\n\t}\n\treturn { args: remaining, path };\n}\n\n/** True when this argv belongs to an isolated interactive engine child. */\nexport function hasInteractiveEngineBootstrapArg(args: readonly string[]): boolean {\n\treturn takeInteractiveEngineBootstrapArg(args).path !== undefined;\n}\n\n/**\n * Read and consume a bootstrap record.\n *\n * The named file is always unlinked, including on malformed content, so a stale\n * API key never outlives the handshake. The path came from argv, so nothing\n * around it is touched: no parent directory, no sibling.\n */\nexport function readInteractiveEngineBootstrap(path: string): InteractiveEngineBootstrap | undefined {\n\tlet raw: string;\n\ttry {\n\t\traw = readFileSync(path, \"utf8\");\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\trmSync(path, { force: true });\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as Partial<InteractiveEngineBootstrap>;\n\t\tif (parsed.version !== INTERACTIVE_ENGINE_BOOTSTRAP_VERSION) return undefined;\n\t\tif (typeof parsed.hostPid !== \"number\" || typeof parsed.guardFile !== \"string\") return undefined;\n\t\tconst trustDecisions = readTrustDecisions(parsed.trustDecisions);\n\t\treturn {\n\t\t\tversion: parsed.version,\n\t\t\thostPid: parsed.hostPid,\n\t\t\tguardFile: parsed.guardFile,\n\t\t\t...(typeof parsed.apiKey === \"string\" ? { apiKey: parsed.apiKey } : {}),\n\t\t\t...(trustDecisions ? { trustDecisions } : {}),\n\t\t\t...(parsed.projectResourceWithdrawals === true ? { projectResourceWithdrawals: true } : {}),\n\t\t\t...(parsed.queuedDeliveries === true ? { queuedDeliveries: true } : {}),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The trust decisions of a bootstrap record: only true or false values by path; anything else is left out. */\nfunction readTrustDecisions(value: unknown): SessionTrustDecisions | undefined {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tconst decisions = {\n\t\tprojects: readDecisions(record.projects),\n\t\textensionSources: readDecisions(record.extensionSources),\n\t};\n\treturn Object.keys(decisions.projects).length + Object.keys(decisions.extensionSources).length > 0\n\t\t? decisions\n\t\t: undefined;\n}\n\nfunction readDecisions(value: unknown): Record<string, boolean> {\n\tconst decisions: Record<string, boolean> = {};\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return decisions;\n\tfor (const [path, trusted] of Object.entries(value)) {\n\t\tif (typeof trusted === \"boolean\") decisions[path] = trusted;\n\t}\n\treturn decisions;\n}\n"]}
|
|
@@ -19,6 +19,8 @@ export interface InteractiveEngineStartupEnv {
|
|
|
19
19
|
/** Trust decisions of this host session, handed to an engine started to replace one that stopped. */
|
|
20
20
|
readonly trustDecisions?: SessionTrustDecisions;
|
|
21
21
|
readonly projectResourceWithdrawals?: true;
|
|
22
|
+
/** The host draws the queued messages the main session is delivering (see `QueuedDeliveryRelay`). */
|
|
23
|
+
readonly queuedDeliveries?: true;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Copy an environment without the interactive-engine control variables.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-engine-env.d.ts","sourceRoot":"","sources":["../../src/utils/interactive-engine-env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,YACvC,iCAAiC,EACjC,oCAAoC,EACpC,sCAAsC,EACtC,mCAAmC,CAC1B,CAAC;AAEX,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,qGAAqG;IACrG,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,0BAA0B,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive-engine-env.d.ts","sourceRoot":"","sources":["../../src/utils/interactive-engine-env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,YACvC,iCAAiC,EACjC,oCAAoC,EACpC,sCAAsC,EACtC,mCAAmC,CAC1B,CAAC;AAEX,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,qGAAqG;IACrG,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,0BAA0B,CAAC,EAAE,IAAI,CAAC;IAC3C,qGAAqG;IACrG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;CACjC;AAID;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAIhF;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CACjD,SAAS,CAAC,EAAE,0BAA0B,GACpC,2BAA2B,CAsB7B;AAED,oEAAoE;AACpE,wBAAgB,2BAA2B,IAAI,2BAA2B,CAEzE;AAED,mFAAmF;AACnF,wBAAgB,wBAAwB,IAAI,OAAO,CAElD"}
|
|
@@ -47,6 +47,7 @@ export function captureInteractiveEngineStartupEnv(bootstrap) {
|
|
|
47
47
|
apiKey: bootstrap.apiKey,
|
|
48
48
|
...(bootstrap.trustDecisions ? { trustDecisions: bootstrap.trustDecisions } : {}),
|
|
49
49
|
...(bootstrap.projectResourceWithdrawals ? { projectResourceWithdrawals: true } : {}),
|
|
50
|
+
...(bootstrap.queuedDeliveries ? { queuedDeliveries: true } : {}),
|
|
50
51
|
}
|
|
51
52
|
: {
|
|
52
53
|
child: process.env.ATOMIC_INTERACTIVE_ENGINE_CHILD,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-engine-env.js","sourceRoot":"","sources":["../../src/utils/interactive-engine-env.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,iCAAiC;IACjC,oCAAoC;IACpC,sCAAsC;IACtC,mCAAmC;CAC1B,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive-engine-env.js","sourceRoot":"","sources":["../../src/utils/interactive-engine-env.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,iCAAiC;IACjC,oCAAoC;IACpC,sCAAsC;IACtC,mCAAmC;CAC1B,CAAC;AAeX,IAAI,QAAiD,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAA8B,GAAM;IAC5E,MAAM,IAAI,GAAG,EAAE,GAAG,GAAG,EAAO,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,2BAA2B;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kCAAkC,CACjD,SAAsC;IAEtC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,QAAQ,GAAG,MAAM,CAAC,MAAM,CACvB,SAAS;QACR,CAAC,CAAC;YACA,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;YAClC,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjF,GAAG,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,0BAA0B,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9F,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1E;QACF,CAAC,CAAC;YACA,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,+BAA+B;YAClD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC;YACvD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oCAAoC;YAC3D,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iCAAiC;SACrD,CACH,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,2BAA2B;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzE,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,2BAA2B;IAC1C,OAAO,kCAAkC,EAAE,CAAC;AAC7C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,wBAAwB;IACvC,OAAO,2BAA2B,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC;AACpD,CAAC","sourcesContent":["import type { SessionTrustDecisions } from \"../core/project-trust-state.ts\";\nimport type { InteractiveEngineBootstrap } from \"./interactive-engine-bootstrap.ts\";\n\n/**\n * Legacy interactive-engine control variables.\n *\n * The host no longer sets these: engine startup metadata travels through a\n * protected bootstrap file (see interactive-engine-bootstrap.ts) precisely\n * because environment values cannot be taken back from a Bun process tree. They\n * are still recognized and scrubbed as defense in depth, so an inherited or\n * caller-supplied value can neither select engine mode nor reach a child.\n */\nexport const INTERACTIVE_ENGINE_ENV_VARS = [\n\t\"ATOMIC_INTERACTIVE_ENGINE_CHILD\",\n\t\"ATOMIC_INTERACTIVE_ENGINE_HOST_PID\",\n\t\"ATOMIC_INTERACTIVE_ENGINE_GUARD_FILE\",\n\t\"ATOMIC_INTERACTIVE_ENGINE_API_KEY\",\n] as const;\n\n/** Immutable startup values captured before they are removed from `process.env`. */\nexport interface InteractiveEngineStartupEnv {\n\treadonly child: string | undefined;\n\treadonly hostPid: string | undefined;\n\treadonly guardFile: string | undefined;\n\treadonly apiKey: string | undefined;\n\t/** Trust decisions of this host session, handed to an engine started to replace one that stopped. */\n\treadonly trustDecisions?: SessionTrustDecisions;\n\treadonly projectResourceWithdrawals?: true;\n\t/** The host draws the queued messages the main session is delivering (see `QueuedDeliveryRelay`). */\n\treadonly queuedDeliveries?: true;\n}\n\nlet snapshot: InteractiveEngineStartupEnv | undefined;\n\n/**\n * Copy an environment without the interactive-engine control variables.\n *\n * Pure: the input object is never mutated. Call this AFTER merging every other\n * environment source so a caller-supplied value cannot reintroduce a key.\n */\nexport function scrubInteractiveEngineEnv<T extends NodeJS.ProcessEnv>(env: T): T {\n\tconst copy = { ...env } as T;\n\tfor (const name of INTERACTIVE_ENGINE_ENV_VARS) delete copy[name];\n\treturn copy;\n}\n\n/**\n * Capture the engine startup values once and remove the legacy variables from\n * `process.env`.\n *\n * A bootstrap record is authoritative when present. The legacy environment is\n * only a fallback for a host that still launches the old way; it cannot be made\n * safe on its own, because Bun children spawned without an explicit `env`\n * inherit the runtime's launch-time environment no matter what this process\n * deletes afterwards. Idempotent: later calls return the same frozen snapshot.\n */\nexport function captureInteractiveEngineStartupEnv(\n\tbootstrap?: InteractiveEngineBootstrap,\n): InteractiveEngineStartupEnv {\n\tif (snapshot) return snapshot;\n\tsnapshot = Object.freeze(\n\t\tbootstrap\n\t\t\t? {\n\t\t\t\t\tchild: \"1\",\n\t\t\t\t\thostPid: String(bootstrap.hostPid),\n\t\t\t\t\tguardFile: bootstrap.guardFile,\n\t\t\t\t\tapiKey: bootstrap.apiKey,\n\t\t\t\t\t...(bootstrap.trustDecisions ? { trustDecisions: bootstrap.trustDecisions } : {}),\n\t\t\t\t\t...(bootstrap.projectResourceWithdrawals ? { projectResourceWithdrawals: true as const } : {}),\n\t\t\t\t\t...(bootstrap.queuedDeliveries ? { queuedDeliveries: true as const } : {}),\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tchild: process.env.ATOMIC_INTERACTIVE_ENGINE_CHILD,\n\t\t\t\t\thostPid: process.env.ATOMIC_INTERACTIVE_ENGINE_HOST_PID,\n\t\t\t\t\tguardFile: process.env.ATOMIC_INTERACTIVE_ENGINE_GUARD_FILE,\n\t\t\t\t\tapiKey: process.env.ATOMIC_INTERACTIVE_ENGINE_API_KEY,\n\t\t\t\t},\n\t);\n\tfor (const name of INTERACTIVE_ENGINE_ENV_VARS) delete process.env[name];\n\treturn snapshot;\n}\n\n/** Frozen startup snapshot; captures (and scrubs) on first read. */\nexport function interactiveEngineStartupEnv(): InteractiveEngineStartupEnv {\n\treturn captureInteractiveEngineStartupEnv();\n}\n\n/** True when this process was started as the isolated interactive engine child. */\nexport function isInteractiveEngineChild(): boolean {\n\treturn interactiveEngineStartupEnv().child === \"1\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,eAAe,CAAC;AAO9E,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC;AAwLD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAqDpE;AAED,wBAAsB,mBAAmB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAiDxF;AAED,eAAO,MAAM,eAAe,YAAI,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAEpH,wBAAgB,mBAAmB,IAAI,WAAW,CAmBjD;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,CAAC,CAkBrE;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAO/C;AAED,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAOnE;AAqBD,wBAAgB,WAAW,IAAI,MAAM,CAAC,UAAU,CAE/C;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAEnE;AA8CD,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAkBpG;AAQD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGvD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIzD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGzD;AAED,wBAAgB,2BAA2B,IAAI,IAAI,CAWlD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAwB/E;AAgCD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA6BjD"}
|
package/dist/utils/shell.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getBinDir } from "../config.js";
|
|
|
7
7
|
import { createChildProcessEnvironment } from "./child-process.js";
|
|
8
8
|
import { pathExists as shellPathExistsAsync } from "./path-exists.js";
|
|
9
9
|
import { getGitShellEnvironment, getGitShellEnvironmentAsync } from "./tools-manager.js";
|
|
10
|
+
import { evalWorkerExecArgv } from "./worker-threads.js";
|
|
10
11
|
function isLegacyWslBashPath(path) {
|
|
11
12
|
const normalized = win32.normalize(path).toLowerCase();
|
|
12
13
|
const systemRoot = process.env.SystemRoot;
|
|
@@ -391,6 +392,7 @@ export function startParentProcessGuardian(parentPid, stopFile) {
|
|
|
391
392
|
return async () => { };
|
|
392
393
|
const guardian = new Worker(PARENT_GUARDIAN_SOURCE, {
|
|
393
394
|
eval: true,
|
|
395
|
+
execArgv: evalWorkerExecArgv(),
|
|
394
396
|
workerData: { parentPid, stopFile, aiAgent: createChildProcessEnvironment().AI_AGENT },
|
|
395
397
|
});
|
|
396
398
|
detachedChildGuardian = guardian;
|