@bastani/atomic 0.10.2 → 0.10.3-alpha.1
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 +44 -0
- package/dist/builtin/intercom/CHANGELOG.md +11 -0
- package/dist/builtin/intercom/broker/broker-instance.ts +2 -13
- package/dist/builtin/intercom/broker/broker.ts +158 -73
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +14 -2
- package/dist/builtin/intercom/broker/host-command-environment.ts +13 -0
- package/dist/builtin/intercom/broker/hosted-session-errors.ts +1 -0
- package/dist/builtin/intercom/broker/multinode-router.ts +111 -16
- package/dist/builtin/intercom/broker/multinode-state-store.ts +50 -4
- package/dist/builtin/intercom/broker/open-broker-state.ts +5 -4
- package/dist/builtin/intercom/broker/spawn.ts +144 -25
- package/dist/builtin/intercom/broker/sql-add-column.ts +33 -0
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +120 -36
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +75 -13
- package/dist/builtin/intercom/broker/start-announcement.ts +55 -10
- package/dist/builtin/intercom/broker/watchdog.ts +10 -7
- package/dist/builtin/intercom/index.bundle.mjs +111 -27
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +13 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/SKILL.md +30 -52
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +34 -40
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/viewer.html +2 -2
- package/dist/builtin/subagents/skills/skill-creator/scripts/atomic_cli.py +668 -0
- package/dist/builtin/subagents/skills/skill-creator/scripts/generate_report.py +3 -3
- package/dist/builtin/subagents/skills/skill-creator/scripts/improve_description.py +42 -38
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +268 -176
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_loop.py +20 -11
- package/dist/builtin/subagents/skills/skill-creator/scripts/utils.py +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -97
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/index.bundle.mjs +5 -4
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +10 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +54 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +4 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +17 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +3 -1
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +2 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +34 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +3 -0
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +27 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +213 -30
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -1
- 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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +35 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +6 -1
- 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 +15 -2
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-typed-queue.d.ts +14 -1
- package/dist/core/agent-session-typed-queue.d.ts.map +1 -1
- package/dist/core/agent-session-typed-queue.js +26 -1
- package/dist/core/agent-session-typed-queue.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -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.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +9 -4
- package/dist/core/async-scope.d.ts.map +1 -1
- package/dist/core/async-scope.js +13 -5
- package/dist/core/async-scope.js.map +1 -1
- package/dist/core/builtin-diagnostics.js +2 -2
- package/dist/core/builtin-diagnostics.js.map +1 -1
- package/dist/core/chat-admission-order.d.ts.map +1 -1
- package/dist/core/chat-admission-order.js +2 -1
- package/dist/core/chat-admission-order.js.map +1 -1
- package/dist/core/chat-record-saves.d.ts +4 -0
- package/dist/core/chat-record-saves.d.ts.map +1 -0
- package/dist/core/chat-record-saves.js +25 -0
- package/dist/core/chat-record-saves.js.map +1 -0
- package/dist/core/command-deliveries.d.ts +62 -0
- package/dist/core/command-deliveries.d.ts.map +1 -0
- package/dist/core/command-deliveries.js +139 -0
- package/dist/core/command-deliveries.js.map +1 -0
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +5 -4
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/extension-startup-close.d.ts +1 -2
- package/dist/core/extension-startup-close.d.ts.map +1 -1
- package/dist/core/extension-startup-close.js +2 -2
- package/dist/core/extension-startup-close.js.map +1 -1
- package/dist/core/extensions/jiti-aliases.d.ts +11 -0
- package/dist/core/extensions/jiti-aliases.d.ts.map +1 -0
- package/dist/core/extensions/jiti-aliases.js +28 -0
- package/dist/core/extensions/jiti-aliases.js.map +1 -0
- package/dist/core/extensions/loader-api.js +3 -3
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.js +2 -2
- package/dist/core/extensions/loader-bindings.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts +1 -2
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +2 -2
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +53 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/native-builtin-entries.d.ts +5 -0
- package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -1
- package/dist/core/extensions/native-builtin-entries.js +8 -1
- package/dist/core/extensions/native-builtin-entries.js.map +1 -1
- package/dist/core/extensions/reloadable-scripts.d.ts +21 -2
- package/dist/core/extensions/reloadable-scripts.d.ts.map +1 -1
- package/dist/core/extensions/reloadable-scripts.js +11 -3
- package/dist/core/extensions/reloadable-scripts.js.map +1 -1
- package/dist/core/extensions/source-builtin-imports.d.ts +40 -0
- package/dist/core/extensions/source-builtin-imports.d.ts.map +1 -0
- package/dist/core/extensions/source-builtin-imports.js +142 -0
- package/dist/core/extensions/source-builtin-imports.js.map +1 -0
- package/dist/core/extensions/transform-graph.d.ts +15 -0
- package/dist/core/extensions/transform-graph.d.ts.map +1 -0
- package/dist/core/extensions/transform-graph.js +85 -0
- package/dist/core/extensions/transform-graph.js.map +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts +2 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +7 -0
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/extensions/ts-transform-worker.d.ts +2 -0
- package/dist/core/extensions/ts-transform-worker.d.ts.map +1 -0
- package/dist/core/extensions/ts-transform-worker.js +43 -0
- package/dist/core/extensions/ts-transform-worker.js.map +1 -0
- package/dist/core/message-admission.d.ts.map +1 -1
- package/dist/core/message-admission.js +4 -4
- package/dist/core/message-admission.js.map +1 -1
- package/dist/core/messages.d.ts +5 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +35 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +18 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/process-start-token.d.ts +7 -0
- package/dist/core/process-start-token.d.ts.map +1 -1
- package/dist/core/process-start-token.js +14 -0
- package/dist/core/process-start-token.js.map +1 -1
- package/dist/core/project-trust-electorate.d.ts +24 -0
- package/dist/core/project-trust-electorate.d.ts.map +1 -0
- package/dist/core/project-trust-electorate.js +52 -0
- package/dist/core/project-trust-electorate.js.map +1 -0
- package/dist/core/project-trust-state.d.ts +15 -0
- package/dist/core/project-trust-state.d.ts.map +1 -1
- package/dist/core/project-trust-state.js +15 -0
- package/dist/core/project-trust-state.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +2 -2
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/queued-input-admission.js +2 -2
- package/dist/core/queued-input-admission.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +2 -2
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +6 -3
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resource-admission-scope.js +2 -2
- package/dist/core/resource-admission-scope.js.map +1 -1
- package/dist/core/resume/blueprint/process.d.ts +3 -4
- package/dist/core/resume/blueprint/process.d.ts.map +1 -1
- package/dist/core/resume/blueprint/process.js +33 -17
- package/dist/core/resume/blueprint/process.js.map +1 -1
- package/dist/core/resume/path-mapping.js +4 -4
- package/dist/core/resume/path-mapping.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +9 -0
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +27 -2
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +27 -1
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -1
- package/dist/core/resume-cache-checkpoint.js +45 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -31
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-scope.d.ts +1 -2
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
- package/dist/core/session-lifecycle-scope.js +2 -2
- package/dist/core/session-lifecycle-scope.js.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -2
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +3 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-storage.d.ts +12 -0
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +68 -1
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +4 -3
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/settings-write-ownership.d.ts +1 -2
- package/dist/core/settings-write-ownership.d.ts.map +1 -1
- package/dist/core/settings-write-ownership.js +2 -2
- package/dist/core/settings-write-ownership.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +6 -4
- 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 +22 -8
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/system-prompt.d.ts +16 -2
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +33 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
- package/dist/core/tasks/agent-adapter.js +2 -1
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +3 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/execution-scope.js +2 -2
- package/dist/core/tasks/execution-scope.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +3 -2
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +3 -2
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +7 -5
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts +6 -2
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +13 -8
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +4 -3
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
- package/dist/core/tools/windows-directory-security.js +2 -1
- package/dist/core/tools/windows-directory-security.js.map +1 -1
- package/dist/core/worktree-snapshot/git.js +2 -2
- package/dist/core/worktree-snapshot/git.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +6 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +150 -18
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +44 -9
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -1
- package/dist/extensions/mcp/tool-records.js +58 -16
- package/dist/extensions/mcp/tool-records.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +3 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +230 -96
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +5 -0
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +5 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.js +3 -3
- package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +6 -0
- package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
- package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/install.js +2 -1
- package/dist/modes/interactive/agent-view/install.js.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.d.ts +4 -2
- package/dist/modes/interactive/agent-view/open-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.js +4 -3
- package/dist/modes/interactive/agent-view/open-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.js +18 -5
- package/dist/modes/interactive/agent-view/prompt-retarget.js.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts +10 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.js +36 -4
- package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts +56 -0
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js +63 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts +14 -4
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-submit.js +51 -17
- package/dist/modes/interactive/agent-view/viewed-submit.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +8 -21
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +18 -5
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +6 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +33 -2
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +58 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +2 -2
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.d.ts +16 -5
- package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.js +27 -8
- package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +8 -25
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +18 -17
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +20 -3
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +82 -32
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.d.ts +5 -2
- package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.js +12 -5
- package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +5 -8
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +5 -49
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.js +9 -2
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
- package/dist/modes/interactive/components/task-marks.d.ts +19 -0
- package/dist/modes/interactive/components/task-marks.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-marks.js +25 -0
- package/dist/modes/interactive/components/task-marks.js.map +1 -0
- package/dist/modes/interactive/components/task-row.d.ts +10 -2
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +39 -32
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts +7 -0
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +106 -10
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.js +8 -9
- package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -1
- package/dist/modes/interactive/extension-command-hold.js +5 -7
- package/dist/modes/interactive/extension-command-hold.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +6 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +21 -7
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts +1 -2
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +2 -2
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +13 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +6 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +6 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +96 -17
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +5 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +37 -5
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +45 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts +4 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +20 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +3 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +43 -5
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +6 -3
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js +3 -2
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +33 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +7 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +15 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/host-listener-failures.d.ts +24 -0
- package/dist/modes/interactive-engine/host-listener-failures.d.ts.map +1 -0
- package/dist/modes/interactive-engine/host-listener-failures.js +98 -0
- package/dist/modes/interactive-engine/host-listener-failures.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +16 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +74 -7
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +5 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +8 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +13 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +69 -4
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +34 -6
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +11 -1
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.js +11 -5
- package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +8 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +89 -65
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +21 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +77 -33
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +5 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +8 -2
- 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 +9 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/shell.d.ts +5 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -7
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/worker-threads.d.ts +10 -4
- package/dist/utils/worker-threads.d.ts.map +1 -1
- package/dist/utils/worker-threads.js +10 -4
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/background-tasks.md +10 -10
- package/docs/compaction.md +1 -0
- package/docs/development.md +1 -1
- package/docs/environment-variables.md +4 -0
- package/docs/extensions/api-reference.md +2 -0
- package/docs/extensions/events.md +1 -1
- package/docs/getting-started/installation.md +1 -0
- package/docs/guides/non-interactive.md +2 -0
- package/docs/guides/resume-on-any-machine.md +3 -1
- package/docs/intercom/reference.md +1 -1
- package/docs/keybindings.md +6 -5
- package/docs/libraries/ai.md +2 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/sdk/reference.md +1 -1
- package/docs/sdk.md +6 -0
- package/docs/security.md +4 -2
- package/docs/settings.md +2 -1
- package/docs/storage.md +2 -0
- package/docs/subagents.md +2 -2
- package/docs/tui/reference.md +3 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -4,6 +4,7 @@ import type { ResourceOverlap } from "../../core/diagnostics.ts";
|
|
|
4
4
|
import type { UIPromptEndEvent, UIPromptStartEvent } from "../../core/extensions/agent-events.ts";
|
|
5
5
|
import type { ExtensionUIContext } from "../../core/extensions/index.js";
|
|
6
6
|
import type { KeybindingsManager } from "../../core/keybindings.ts";
|
|
7
|
+
import type { ExtensionShortcutHandler } from "../interactive/components/custom-editor.ts";
|
|
7
8
|
import type { RpcAutocompleteItem, RpcResourceExtension, RpcSlashCommand } from "../rpc/rpc-types.ts";
|
|
8
9
|
import type { ActivityWatchdogDiagnostic } from "./activity-watchdog.ts";
|
|
9
10
|
import { type EngineResourceIssues } from "./isolated-runtime.js";
|
|
@@ -14,7 +15,7 @@ interface EngineMessageSource {
|
|
|
14
15
|
onKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;
|
|
15
16
|
}
|
|
16
17
|
export declare function attachInteractiveEngineKeybindingSync(runtime: EngineMessageSource, keybindings: KeybindingsManager, onState?: (state: EngineKeybindingState) => void): () => void;
|
|
17
|
-
export declare function attachInteractiveEngineHost(runtime: AgentSessionRuntime, ui: ExtensionUIContext, onDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void, tuiRendererLifecycle: TuiRendererLifecycle, setShortcutHandler?: (handler:
|
|
18
|
+
export declare function attachInteractiveEngineHost(runtime: AgentSessionRuntime, ui: ExtensionUIContext, onDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void, tuiRendererLifecycle: TuiRendererLifecycle, setShortcutHandler?: (handler: ExtensionShortcutHandler) => undefined | (() => void), keybindings?: KeybindingsManager, onUIPrompt?: (event: UIPromptStartEvent | UIPromptEndEvent | undefined) => void): () => void;
|
|
18
19
|
/** Route host-owned trust waits to the runner that actually owns the subscribers. */
|
|
19
20
|
export declare function withHostProjectTrustPrompt<T>(runtime: AgentSessionRuntime, kind: "select" | "confirm" | "input", title: string, run: () => Promise<T>): Promise<T>;
|
|
20
21
|
export declare function waitForInteractiveEngineBound(runtime: AgentSessionRuntime, preview?: (lines: string[]) => void): Promise<void>;
|
|
@@ -31,6 +32,11 @@ export declare function interactiveEngineNeedsExplicitTermination(runtime: Agent
|
|
|
31
32
|
* Only ever reached from a deliberate user action (Ctrl+C) — never from Escape.
|
|
32
33
|
*/
|
|
33
34
|
export declare function terminateInteractiveEngine(runtime: AgentSessionRuntime): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The interactive engine a shutdown of this host leaves to the runtime's own stop, which gives it a bounded window
|
|
37
|
+
* to run its extensions' shutdown: the ready engine of an isolated runtime, none for an in-process one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function gracefullyStoppedEnginePids(runtime: AgentSessionRuntime): ReadonlySet<number>;
|
|
34
40
|
/**
|
|
35
41
|
* Command catalog the engine child exposes to the isolated host. Returns an
|
|
36
42
|
* empty list for non-isolated runtimes so callers can merge unconditionally.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-ui-bridge.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/extension-ui-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAClG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,KAAK,oBAAoB,EAA8B,MAAM,uBAA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,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,oBAAoB,EAAE,EAAE,WAAW,CAAC,EAAE,IAAI,KAAK,IAAI,GACjF,MAAM,IAAI,CAEZ;AAED,4GAA4G;AAC5G,wBAAgB,sCAAsC,CACrD,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,CAAC,gBAAgB,EAAE,OAAO,KAAK,IAAI,GAC3C,MAAM,IAAI,CAEZ;AAED,oEAAoE;AACpE,wBAAgB,4CAA4C,CAC3D,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,CAIvC;AAED,kFAAkF;AAClF,wBAAgB,wCAAwC,CACvD,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,EAAE,WAAW,CAAC,EAAE,IAAI,KAAK,IAAI,GAC1E,MAAM,IAAI,CAEZ;AAED,mGAAmG;AACnG,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAErH"}
|
|
@@ -34,8 +34,9 @@ export function attachInteractiveEngineHost(runtime, ui, onDiagnostic, tuiRender
|
|
|
34
34
|
// outlive, or answer through, a replacement engine child.
|
|
35
35
|
const dialogs = new EngineDialogHostController(runtime, ui);
|
|
36
36
|
let shortcuts = [];
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const find = (data) => shortcuts.find(({ key, editorKeys }) => matchesKey(data, key) && !editorKeys?.some((editorKey) => matchesKey(data, editorKey)));
|
|
38
|
+
const dispatch = (data) => {
|
|
39
|
+
const shortcut = find(data);
|
|
39
40
|
if (!shortcut)
|
|
40
41
|
return false;
|
|
41
42
|
void runtime
|
|
@@ -43,6 +44,10 @@ export function attachInteractiveEngineHost(runtime, ui, onDiagnostic, tuiRender
|
|
|
43
44
|
.catch((error) => onDiagnostic({ activity: undefined, elapsedMs: 0, level: "unresponsive", message: error.message }));
|
|
44
45
|
return true;
|
|
45
46
|
};
|
|
47
|
+
// `takes` answers as `dispatch` would, without running the shortcut.
|
|
48
|
+
const dispatchShortcut = Object.assign(dispatch, {
|
|
49
|
+
takes: (data) => find(data) !== undefined,
|
|
50
|
+
});
|
|
46
51
|
let disposeShortcutHandler;
|
|
47
52
|
const installShortcutHandler = () => {
|
|
48
53
|
disposeShortcutHandler?.();
|
|
@@ -122,6 +127,14 @@ export function terminateInteractiveEngine(runtime) {
|
|
|
122
127
|
void runtime.terminateAndRecover();
|
|
123
128
|
return true;
|
|
124
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* The interactive engine a shutdown of this host leaves to the runtime's own stop, which gives it a bounded window
|
|
132
|
+
* to run its extensions' shutdown: the ready engine of an isolated runtime, none for an in-process one.
|
|
133
|
+
*/
|
|
134
|
+
export function gracefullyStoppedEnginePids(runtime) {
|
|
135
|
+
const pid = runtime instanceof IsolatedInteractiveRuntime ? runtime.getReadyEngineChildPid() : undefined;
|
|
136
|
+
return new Set(pid === undefined ? [] : [pid]);
|
|
137
|
+
}
|
|
125
138
|
/**
|
|
126
139
|
* Command catalog the engine child exposes to the isolated host. Returns an
|
|
127
140
|
* empty list for non-isolated runtimes so callers can merge unconditionally.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-ui-bridge.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/extension-ui-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAS7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAA6B,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,EAAE,yBAAyB,EAA6B,MAAM,uB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AA0B,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC3G,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,4CAA4C,CAC3D,OAA4B,EAC5B,WAAmB,EACnB,cAAsB;IAEtB,OAAO,OAAO,YAAY,0BAA0B;QACnD,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,WAAW,EAAE,cAAc,CAAC;QAClE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,wCAAwC,CACvD,OAA4B,EAC5B,QAA4E;IAE5E,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC7G,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,sCAAsC,CAAC,OAA4B,EAAE,QAAoB;IACxG,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import { type KeyId, matchesKey } from \"@bastani/atomic-tui\";\nimport type { ClearedQueue } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { UIPromptEndEvent, UIPromptStartEvent } from \"../../core/extensions/agent-events.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { RpcAutocompleteItem, RpcResourceExtension, RpcSlashCommand } from \"../rpc/rpc-types.ts\";\nimport type { ActivityWatchdogDiagnostic } from \"./activity-watchdog.ts\";\nimport { EngineDialogHostController } from \"./engine-dialog-host.ts\";\nimport { InputFormHostController } from \"./input-form-host.ts\";\nimport { type EngineResourceIssues, IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { EngineExtensionShortcut, EngineKeybindingState, InteractiveEngineMessage } from \"./protocol.ts\";\nimport { RemoteComponentController, type TuiRendererLifecycle } from \"./remote-component.ts\";\nimport { registerRemoteProxyOwnership } from \"./remote-input-ownership.ts\";\nimport { SessionPickerHostController } from \"./session-picker-host.ts\";\n\ninterface EngineMessageSource {\n\tonEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;\n\tonKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;\n}\n\nexport function attachInteractiveEngineKeybindingSync(\n\truntime: EngineMessageSource,\n\tkeybindings: KeybindingsManager,\n\tonState?: (state: EngineKeybindingState) => void,\n): () => void {\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tkeybindings.setUserBindings(state.userBindings);\n\t\tonState?.(state);\n\t};\n\tif (runtime.onKeybindingState) return runtime.onKeybindingState(applyState);\n\treturn runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t});\n}\n\nexport function attachInteractiveEngineHost(\n\truntime: AgentSessionRuntime,\n\tui: ExtensionUIContext,\n\tonDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void,\n\ttuiRendererLifecycle: TuiRendererLifecycle,\n\tsetShortcutHandler?: (handler: (data: string) => boolean) => undefined | (() => void),\n\tkeybindings?: KeybindingsManager,\n\tonUIPrompt?: (event: UIPromptStartEvent | UIPromptEndEvent | undefined) => void,\n): () => void {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\tconst disposeDiagnostic = runtime.onDiagnostic(onDiagnostic);\n\tconst disposeUIPrompts = runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_ui_prompt\") onUIPrompt?.(message.event);\n\t\t// The footer paints the engine's panel counts, which the runtime has already mirrored. They can change\n\t\t// with no panel widget mounted (only shells running), so a widget's repaint cannot be relied on.\n\t\telse if (message.type === \"engine_agent_panel_state\") ui.requestRender();\n\t});\n\tconst disposePromptGeneration = runtime.onGenerationEnded(() => onUIPrompt?.(undefined));\n\t// Generation-owned: RPC dialogs mount real host components and must not\n\t// outlive, or answer through, a replacement engine child.\n\tconst dialogs = new EngineDialogHostController(runtime, ui);\n\tlet shortcuts: EngineExtensionShortcut[] = [];\n\tconst dispatchShortcut = (data: string): boolean => {\n\t\tconst shortcut = shortcuts.find(\n\t\t\t({ key, editorKeys }) =>\n\t\t\t\tmatchesKey(data, key as KeyId) && !editorKeys?.some((editorKey) => matchesKey(data, editorKey)),\n\t\t);\n\t\tif (!shortcut) return false;\n\t\tvoid runtime\n\t\t\t.invokeRemoteShortcut(shortcut.key)\n\t\t\t.catch((error: Error) =>\n\t\t\t\tonDiagnostic({ activity: undefined, elapsedMs: 0, level: \"unresponsive\", message: error.message }),\n\t\t\t);\n\t\treturn true;\n\t};\n\tlet disposeShortcutHandler: (() => void) | undefined;\n\tconst installShortcutHandler = (): void => {\n\t\tdisposeShortcutHandler?.();\n\t\tconst dispose = setShortcutHandler?.(dispatchShortcut);\n\t\tdisposeShortcutHandler = typeof dispose === \"function\" ? dispose : undefined;\n\t};\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tshortcuts = [...state.shortcuts];\n\t\tinstallShortcutHandler();\n\t};\n\tinstallShortcutHandler();\n\tconst disposeKeybindings = keybindings\n\t\t? attachInteractiveEngineKeybindingSync(runtime, keybindings, applyState)\n\t\t: runtime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t\t\t});\n\tconst remoteComponents = new RemoteComponentController(runtime, ui, tuiRendererLifecycle);\n\t// Ctrl+C must reach the host while a remote proxy owns input, so publish the\n\t// only component that can answer that question exactly.\n\tconst disposeOwnership = registerRemoteProxyOwnership(runtime, remoteComponents);\n\tconst sessionPicker = new SessionPickerHostController(runtime, ui);\n\tconst inputForm = new InputFormHostController(runtime, ui);\n\tlet disposed = false;\n\treturn () => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tdisposeShortcutHandler?.();\n\t\tdisposeKeybindings();\n\t\tdisposeUIPrompts();\n\t\tdisposePromptGeneration();\n\t\tonUIPrompt?.(undefined);\n\t\tdisposeOwnership();\n\t\tremoteComponents.dispose();\n\t\tsessionPicker.dispose();\n\t\tinputForm.dispose();\n\t\tdialogs.dispose();\n\t\tdisposeDiagnostic();\n\t};\n}\n\n/** Route host-owned trust waits to the runner that actually owns the subscribers. */\nexport function withHostProjectTrustPrompt<T>(\n\truntime: AgentSessionRuntime,\n\tkind: \"select\" | \"confirm\" | \"input\",\n\ttitle: string,\n\trun: () => Promise<T>,\n): Promise<T> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.withProjectTrustPrompt(kind, title, run)\n\t\t: runtime.session.extensionRunner.withProjectTrustPrompt(kind, title, run);\n}\n\nexport async function waitForInteractiveEngineBound(\n\truntime: AgentSessionRuntime,\n\tpreview?: (lines: string[]) => void,\n): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilBound();\n\tawait runtime.initializeFromEngine(undefined, preview);\n}\n\nexport async function waitForInteractiveEngineProjectTrust(runtime: AgentSessionRuntime): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilProjectTrustSettled();\n}\n\nexport function interruptBlockedInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.interruptBlockedCallback();\n}\n\n/**\n * True when the interactive engine still owes a cooperative abort or the\n * heartbeat watchdog has declared it unresponsive, i.e. when the explicit\n * Ctrl+C escape hatch promised by the watchdog copy applies.\n */\nexport function interactiveEngineNeedsExplicitTermination(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.needsExplicitTermination();\n}\n\n/**\n * Explicitly terminate an unresponsive interactive engine and start recovery.\n * Only ever reached from a deliberate user action (Ctrl+C) — never from Escape.\n */\nexport function terminateInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\tif (!interactiveEngineNeedsExplicitTermination(runtime)) return false;\n\tvoid (runtime as IsolatedInteractiveRuntime).terminateAndRecover();\n\treturn true;\n}\n\n/**\n * Command catalog the engine child exposes to the isolated host. Returns an\n * empty list for non-isolated runtimes so callers can merge unconditionally.\n */\nexport function getInteractiveEngineRemoteCommands(runtime: AgentSessionRuntime): readonly RpcSlashCommand[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getRemoteCommands() : [];\n}\n\n/**\n * Clear the engine child's queue and return exactly the messages it removed. The host's copy of that queue lags\n * the engine by a round trip, so a host that restores the queue to its editor restores this answer rather than\n * its copy (#4257). Returns `undefined` for a session that runs in this process, whose `clearQueue()` is exact.\n */\nexport function clearInteractiveEngineQueue(runtime: AgentSessionRuntime): Promise<ClearedQueue> | undefined {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.clearEngineQueue() : undefined;\n}\n\nexport function getInteractiveEngineResourceOverlaps(runtime: AgentSessionRuntime): readonly ResourceOverlap[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceOverlaps() : [];\n}\n\nexport function getInteractiveEngineResourceExtensions(runtime: AgentSessionRuntime): readonly RpcResourceExtension[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceExtensions() : [];\n}\n\n/** The interactive engine's extension load errors and warnings; empty for a session that runs in this process. */\nexport function getInteractiveEngineResourceIssues(runtime: AgentSessionRuntime): EngineResourceIssues {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceIssues() : { errors: [], warnings: [] };\n}\n\nexport function onInteractiveEngineResourceExtensionsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (extensions: readonly RpcResourceExtension[], forNextView?: true) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onResourceExtensionsChanged(listener) : () => {};\n}\n\n/** Called when the isolated host's trust for its session, or whether its engine has decided it, changes. */\nexport function onInteractiveEngineProjectTrustChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (resourcesChanged: boolean) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onProjectTrustChanged(listener) : () => {};\n}\n\n/** Evaluate an engine-child command's live argument completions. */\nexport function getInteractiveEngineRemoteCommandCompletions(\n\truntime: AgentSessionRuntime,\n\tcommandName: string,\n\targumentPrefix: string,\n): Promise<RpcAutocompleteItem[] | null> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.getRemoteCommandCompletions(commandName, argumentPrefix)\n\t\t: Promise.resolve(null);\n}\n\n/** Subscribe to engine-child command catalog changes. No-op when not isolated. */\nexport function onInteractiveEngineRemoteCommandsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (commands: readonly RpcSlashCommand[], forNextView?: true) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onRemoteCommandsChanged(listener) : () => {};\n}\n\n/** Subscribe to fresh engine session stats, so the footer can repaint. No-op when not isolated. */\nexport function onInteractiveEngineSessionStatsChanged(runtime: AgentSessionRuntime, listener: () => void): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onSessionStatsChanged(listener) : () => {};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extension-ui-bridge.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/extension-ui-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAU7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAA6B,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,EAA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AAsC,CAAC,OAA4B,EAAE,QAAoB;IACxG,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import { type KeyId, matchesKey } from \"@bastani/atomic-tui\";\nimport type { ClearedQueue } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { UIPromptEndEvent, UIPromptStartEvent } from \"../../core/extensions/agent-events.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { ExtensionShortcutHandler } from \"../interactive/components/custom-editor.ts\";\nimport type { RpcAutocompleteItem, RpcResourceExtension, RpcSlashCommand } from \"../rpc/rpc-types.ts\";\nimport type { ActivityWatchdogDiagnostic } from \"./activity-watchdog.ts\";\nimport { EngineDialogHostController } from \"./engine-dialog-host.ts\";\nimport { InputFormHostController } from \"./input-form-host.ts\";\nimport { type EngineResourceIssues, IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { EngineExtensionShortcut, EngineKeybindingState, InteractiveEngineMessage } from \"./protocol.ts\";\nimport { RemoteComponentController, type TuiRendererLifecycle } from \"./remote-component.ts\";\nimport { registerRemoteProxyOwnership } from \"./remote-input-ownership.ts\";\nimport { SessionPickerHostController } from \"./session-picker-host.ts\";\n\ninterface EngineMessageSource {\n\tonEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;\n\tonKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;\n}\n\nexport function attachInteractiveEngineKeybindingSync(\n\truntime: EngineMessageSource,\n\tkeybindings: KeybindingsManager,\n\tonState?: (state: EngineKeybindingState) => void,\n): () => void {\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tkeybindings.setUserBindings(state.userBindings);\n\t\tonState?.(state);\n\t};\n\tif (runtime.onKeybindingState) return runtime.onKeybindingState(applyState);\n\treturn runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t});\n}\n\nexport function attachInteractiveEngineHost(\n\truntime: AgentSessionRuntime,\n\tui: ExtensionUIContext,\n\tonDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void,\n\ttuiRendererLifecycle: TuiRendererLifecycle,\n\tsetShortcutHandler?: (handler: ExtensionShortcutHandler) => undefined | (() => void),\n\tkeybindings?: KeybindingsManager,\n\tonUIPrompt?: (event: UIPromptStartEvent | UIPromptEndEvent | undefined) => void,\n): () => void {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\tconst disposeDiagnostic = runtime.onDiagnostic(onDiagnostic);\n\tconst disposeUIPrompts = runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_ui_prompt\") onUIPrompt?.(message.event);\n\t\t// The footer paints the engine's panel counts, which the runtime has already mirrored. They can change\n\t\t// with no panel widget mounted (only shells running), so a widget's repaint cannot be relied on.\n\t\telse if (message.type === \"engine_agent_panel_state\") ui.requestRender();\n\t});\n\tconst disposePromptGeneration = runtime.onGenerationEnded(() => onUIPrompt?.(undefined));\n\t// Generation-owned: RPC dialogs mount real host components and must not\n\t// outlive, or answer through, a replacement engine child.\n\tconst dialogs = new EngineDialogHostController(runtime, ui);\n\tlet shortcuts: EngineExtensionShortcut[] = [];\n\tconst find = (data: string) =>\n\t\tshortcuts.find(\n\t\t\t({ key, editorKeys }) =>\n\t\t\t\tmatchesKey(data, key as KeyId) && !editorKeys?.some((editorKey) => matchesKey(data, editorKey)),\n\t\t);\n\tconst dispatch = (data: string): boolean => {\n\t\tconst shortcut = find(data);\n\t\tif (!shortcut) return false;\n\t\tvoid runtime\n\t\t\t.invokeRemoteShortcut(shortcut.key)\n\t\t\t.catch((error: Error) =>\n\t\t\t\tonDiagnostic({ activity: undefined, elapsedMs: 0, level: \"unresponsive\", message: error.message }),\n\t\t\t);\n\t\treturn true;\n\t};\n\t// `takes` answers as `dispatch` would, without running the shortcut.\n\tconst dispatchShortcut: ExtensionShortcutHandler = Object.assign(dispatch, {\n\t\ttakes: (data: string) => find(data) !== undefined,\n\t});\n\tlet disposeShortcutHandler: (() => void) | undefined;\n\tconst installShortcutHandler = (): void => {\n\t\tdisposeShortcutHandler?.();\n\t\tconst dispose = setShortcutHandler?.(dispatchShortcut);\n\t\tdisposeShortcutHandler = typeof dispose === \"function\" ? dispose : undefined;\n\t};\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tshortcuts = [...state.shortcuts];\n\t\tinstallShortcutHandler();\n\t};\n\tinstallShortcutHandler();\n\tconst disposeKeybindings = keybindings\n\t\t? attachInteractiveEngineKeybindingSync(runtime, keybindings, applyState)\n\t\t: runtime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t\t\t});\n\tconst remoteComponents = new RemoteComponentController(runtime, ui, tuiRendererLifecycle);\n\t// Ctrl+C must reach the host while a remote proxy owns input, so publish the\n\t// only component that can answer that question exactly.\n\tconst disposeOwnership = registerRemoteProxyOwnership(runtime, remoteComponents);\n\tconst sessionPicker = new SessionPickerHostController(runtime, ui);\n\tconst inputForm = new InputFormHostController(runtime, ui);\n\tlet disposed = false;\n\treturn () => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tdisposeShortcutHandler?.();\n\t\tdisposeKeybindings();\n\t\tdisposeUIPrompts();\n\t\tdisposePromptGeneration();\n\t\tonUIPrompt?.(undefined);\n\t\tdisposeOwnership();\n\t\tremoteComponents.dispose();\n\t\tsessionPicker.dispose();\n\t\tinputForm.dispose();\n\t\tdialogs.dispose();\n\t\tdisposeDiagnostic();\n\t};\n}\n\n/** Route host-owned trust waits to the runner that actually owns the subscribers. */\nexport function withHostProjectTrustPrompt<T>(\n\truntime: AgentSessionRuntime,\n\tkind: \"select\" | \"confirm\" | \"input\",\n\ttitle: string,\n\trun: () => Promise<T>,\n): Promise<T> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.withProjectTrustPrompt(kind, title, run)\n\t\t: runtime.session.extensionRunner.withProjectTrustPrompt(kind, title, run);\n}\n\nexport async function waitForInteractiveEngineBound(\n\truntime: AgentSessionRuntime,\n\tpreview?: (lines: string[]) => void,\n): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilBound();\n\tawait runtime.initializeFromEngine(undefined, preview);\n}\n\nexport async function waitForInteractiveEngineProjectTrust(runtime: AgentSessionRuntime): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilProjectTrustSettled();\n}\n\nexport function interruptBlockedInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.interruptBlockedCallback();\n}\n\n/**\n * True when the interactive engine still owes a cooperative abort or the\n * heartbeat watchdog has declared it unresponsive, i.e. when the explicit\n * Ctrl+C escape hatch promised by the watchdog copy applies.\n */\nexport function interactiveEngineNeedsExplicitTermination(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.needsExplicitTermination();\n}\n\n/**\n * Explicitly terminate an unresponsive interactive engine and start recovery.\n * Only ever reached from a deliberate user action (Ctrl+C) — never from Escape.\n */\nexport function terminateInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\tif (!interactiveEngineNeedsExplicitTermination(runtime)) return false;\n\tvoid (runtime as IsolatedInteractiveRuntime).terminateAndRecover();\n\treturn true;\n}\n\n/**\n * The interactive engine a shutdown of this host leaves to the runtime's own stop, which gives it a bounded window\n * to run its extensions' shutdown: the ready engine of an isolated runtime, none for an in-process one.\n */\nexport function gracefullyStoppedEnginePids(runtime: AgentSessionRuntime): ReadonlySet<number> {\n\tconst pid = runtime instanceof IsolatedInteractiveRuntime ? runtime.getReadyEngineChildPid() : undefined;\n\treturn new Set(pid === undefined ? [] : [pid]);\n}\n\n/**\n * Command catalog the engine child exposes to the isolated host. Returns an\n * empty list for non-isolated runtimes so callers can merge unconditionally.\n */\nexport function getInteractiveEngineRemoteCommands(runtime: AgentSessionRuntime): readonly RpcSlashCommand[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getRemoteCommands() : [];\n}\n\n/**\n * Clear the engine child's queue and return exactly the messages it removed. The host's copy of that queue lags\n * the engine by a round trip, so a host that restores the queue to its editor restores this answer rather than\n * its copy (#4257). Returns `undefined` for a session that runs in this process, whose `clearQueue()` is exact.\n */\nexport function clearInteractiveEngineQueue(runtime: AgentSessionRuntime): Promise<ClearedQueue> | undefined {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.clearEngineQueue() : undefined;\n}\n\nexport function getInteractiveEngineResourceOverlaps(runtime: AgentSessionRuntime): readonly ResourceOverlap[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceOverlaps() : [];\n}\n\nexport function getInteractiveEngineResourceExtensions(runtime: AgentSessionRuntime): readonly RpcResourceExtension[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceExtensions() : [];\n}\n\n/** The interactive engine's extension load errors and warnings; empty for a session that runs in this process. */\nexport function getInteractiveEngineResourceIssues(runtime: AgentSessionRuntime): EngineResourceIssues {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceIssues() : { errors: [], warnings: [] };\n}\n\nexport function onInteractiveEngineResourceExtensionsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (extensions: readonly RpcResourceExtension[], forNextView?: true) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onResourceExtensionsChanged(listener) : () => {};\n}\n\n/** Called when the isolated host's trust for its session, or whether its engine has decided it, changes. */\nexport function onInteractiveEngineProjectTrustChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (resourcesChanged: boolean) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onProjectTrustChanged(listener) : () => {};\n}\n\n/** Evaluate an engine-child command's live argument completions. */\nexport function getInteractiveEngineRemoteCommandCompletions(\n\truntime: AgentSessionRuntime,\n\tcommandName: string,\n\targumentPrefix: string,\n): Promise<RpcAutocompleteItem[] | null> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.getRemoteCommandCompletions(commandName, argumentPrefix)\n\t\t: Promise.resolve(null);\n}\n\n/** Subscribe to engine-child command catalog changes. No-op when not isolated. */\nexport function onInteractiveEngineRemoteCommandsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (commands: readonly RpcSlashCommand[], forNextView?: true) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onRemoteCommandsChanged(listener) : () => {};\n}\n\n/** Subscribe to fresh engine session stats, so the footer can repaint. No-op when not isolated. */\nexport function onInteractiveEngineSessionStatsChanged(runtime: AgentSessionRuntime, listener: () => void): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onSessionStatsChanged(listener) : () => {};\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ActivityWatchdogDiagnostic } from "./activity-watchdog.ts";
|
|
2
|
+
/** What a host listener was handling when it failed. */
|
|
3
|
+
export type HostListenerInput = "event" | "message" | "extension UI request" | "end";
|
|
4
|
+
/**
|
|
5
|
+
* Calls the host's own listeners with what the interactive engine sent. A listener runs in this process, so what it
|
|
6
|
+
* throws, or what the promise it returns rejects with, is a failure of the host's handling, not of the engine's
|
|
7
|
+
* output (#6107). Each failure is reported once, as that, and goes no further: the other listeners still get the
|
|
8
|
+
* input, the engine's connection is not failed, and nothing escapes from a timer or a promise and ends the process.
|
|
9
|
+
*/
|
|
10
|
+
export declare class HostListenerFailures {
|
|
11
|
+
private readonly report;
|
|
12
|
+
/** How a listener's pending promise reaches this reporter without keeping it, or its host, alive. */
|
|
13
|
+
private readonly weak;
|
|
14
|
+
constructor(report: (diagnostic: ActivityWatchdogDiagnostic) => void);
|
|
15
|
+
/** Call `listener` with `value`, which is, or comes from, `about`: what the engine sent, described on failure. */
|
|
16
|
+
call<T>(listener: (value: T) => unknown, value: T, input: HostListenerInput, about?: unknown): void;
|
|
17
|
+
/**
|
|
18
|
+
* What observes a listener's promise holds while it is pending: the description of the input and a weak
|
|
19
|
+
* reference to the reporter, never the input itself or the host behind the reporter.
|
|
20
|
+
*/
|
|
21
|
+
private static rejectionObserver;
|
|
22
|
+
private fail;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=host-listener-failures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-listener-failures.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/host-listener-failures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,sBAAsB,GAAG,KAAK,CAAC;AAmDrF;;;;;GAKG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;IAC1E,qGAAqG;IACrG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAE1C,YAAY,MAAM,EAAE,CAAC,UAAU,EAAE,0BAA0B,KAAK,IAAI,EAEnE;IAED,kHAAkH;IAClH,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI,CAUzG;IAED;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC,OAAO,CAAC,IAAI;CAcZ"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isNativeError, isPromise } from "node:util/types";
|
|
2
|
+
const SHOWN_TYPE = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
3
|
+
/** The `type` the engine gave what it sent, when it can be read and is safe to show. */
|
|
4
|
+
function shownType(value) {
|
|
5
|
+
try {
|
|
6
|
+
const type = value?.type;
|
|
7
|
+
return typeof type === "string" && SHOWN_TYPE.test(type) ? `"${type}"` : "unrecognized";
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return "unrecognized";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function describeInput(input, value) {
|
|
14
|
+
switch (input) {
|
|
15
|
+
case "event":
|
|
16
|
+
return `the interactive engine's ${shownType(value)} event`;
|
|
17
|
+
case "message":
|
|
18
|
+
return `the interactive engine's ${shownType(value)} message`;
|
|
19
|
+
case "extension UI request":
|
|
20
|
+
return "an extension UI request from the interactive engine";
|
|
21
|
+
case "end":
|
|
22
|
+
return "the end of the interactive engine";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** What the listener threw, as its message. A value that throws again when it is read gets a fixed text. */
|
|
26
|
+
function describeFailure(error) {
|
|
27
|
+
try {
|
|
28
|
+
return String(isNativeError(error) ? error.message || error.name : error);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return "an exception whose message cannot be read";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const ignore = () => { };
|
|
35
|
+
/**
|
|
36
|
+
* Observe a native promise's rejection with the intrinsic `then`, so the promise's own `then` or `catch` never runs.
|
|
37
|
+
* Only a native promise is observed at all: checking any other value for `then` would run that value's code. A
|
|
38
|
+
* promise that cannot be observed (its constructor throws) is left as it is.
|
|
39
|
+
*/
|
|
40
|
+
function observe(promise, onRejected) {
|
|
41
|
+
try {
|
|
42
|
+
Reflect.apply(Promise.prototype.then, promise, [undefined, onRejected]);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Nothing was registered, so nothing can be reported; the listener itself did not fail.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Calls the host's own listeners with what the interactive engine sent. A listener runs in this process, so what it
|
|
50
|
+
* throws, or what the promise it returns rejects with, is a failure of the host's handling, not of the engine's
|
|
51
|
+
* output (#6107). Each failure is reported once, as that, and goes no further: the other listeners still get the
|
|
52
|
+
* input, the engine's connection is not failed, and nothing escapes from a timer or a promise and ends the process.
|
|
53
|
+
*/
|
|
54
|
+
export class HostListenerFailures {
|
|
55
|
+
report;
|
|
56
|
+
/** How a listener's pending promise reaches this reporter without keeping it, or its host, alive. */
|
|
57
|
+
weak = new WeakRef(this);
|
|
58
|
+
constructor(report) {
|
|
59
|
+
this.report = report;
|
|
60
|
+
}
|
|
61
|
+
/** Call `listener` with `value`, which is, or comes from, `about`: what the engine sent, described on failure. */
|
|
62
|
+
call(listener, value, input, about = value) {
|
|
63
|
+
let result;
|
|
64
|
+
try {
|
|
65
|
+
result = listener(value);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.fail(describeInput(input, about), error);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (isPromise(result))
|
|
72
|
+
observe(result, HostListenerFailures.rejectionObserver(this.weak, describeInput(input, about)));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What observes a listener's promise holds while it is pending: the description of the input and a weak
|
|
76
|
+
* reference to the reporter, never the input itself or the host behind the reporter.
|
|
77
|
+
*/
|
|
78
|
+
static rejectionObserver(failures, handling) {
|
|
79
|
+
return (error) => failures.deref()?.fail(handling, error);
|
|
80
|
+
}
|
|
81
|
+
fail(handling, error) {
|
|
82
|
+
try {
|
|
83
|
+
const reported = this.report({
|
|
84
|
+
activity: undefined,
|
|
85
|
+
elapsedMs: 0,
|
|
86
|
+
level: "unresponsive",
|
|
87
|
+
source: "host",
|
|
88
|
+
message: `Atomic failed while handling ${handling}: ${describeFailure(error)}`,
|
|
89
|
+
});
|
|
90
|
+
if (isPromise(reported))
|
|
91
|
+
observe(reported, ignore);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Reporting the failure failed too. There is nowhere left to report it, and it must not end the process.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=host-listener-failures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-listener-failures.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/host-listener-failures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM3D,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAE7C,wFAAwF;AACxF,SAAS,SAAS,CAAC,KAAc;IAChC,IAAI,CAAC;QACJ,MAAM,IAAI,GAAI,KAAwC,EAAE,IAAI,CAAC;QAC7D,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,cAAc,CAAC;IACvB,CAAC;AACF,CAAC;AAED,SAAS,aAAa,CAAC,KAAwB,EAAE,KAAc;IAC9D,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,OAAO;YACX,OAAO,4BAA4B,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7D,KAAK,SAAS;YACb,OAAO,4BAA4B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QAC/D,KAAK,sBAAsB;YAC1B,OAAO,qDAAqD,CAAC;QAC9D,KAAK,KAAK;YACT,OAAO,mCAAmC,CAAC;IAC7C,CAAC;AACF,CAAC;AAED,4GAA4G;AAC5G,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,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uC,EAAE,QAAgB;QACzF,OAAO,CAAC,KAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAEO,IAAI,CAAC,QAAgB,EAAE,KAAc;QAC5C,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAY,IAAI,CAAC,MAAM,CAAC;gBACrC,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,CAAC;gBACZ,KAAK,EAAE,cAAc;gBACrB,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,gCAAgC,QAAQ,KAAK,eAAe,CAAC,KAAK,CAAC,EAAE;aAC9E,CAAC,CAAC;YACH,IAAI,SAAS,CAAC,QAAQ,CAAC;gBAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACR,yGAAyG;QAC1G,CAAC;IACF,CAAC;CACD","sourcesContent":["import { isNativeError, isPromise } from \"node:util/types\";\nimport type { ActivityWatchdogDiagnostic } from \"./activity-watchdog.ts\";\n\n/** What a host listener was handling when it failed. */\nexport type HostListenerInput = \"event\" | \"message\" | \"extension UI request\" | \"end\";\n\nconst SHOWN_TYPE = /^[A-Za-z0-9_.:-]{1,64}$/;\n\n/** The `type` the engine gave what it sent, when it can be read and is safe to show. */\nfunction shownType(value: unknown): string {\n\ttry {\n\t\tconst type = (value as { type?: unknown } | undefined)?.type;\n\t\treturn typeof type === \"string\" && SHOWN_TYPE.test(type) ? `\"${type}\"` : \"unrecognized\";\n\t} catch {\n\t\treturn \"unrecognized\";\n\t}\n}\n\nfunction describeInput(input: HostListenerInput, value: unknown): string {\n\tswitch (input) {\n\t\tcase \"event\":\n\t\t\treturn `the interactive engine's ${shownType(value)} event`;\n\t\tcase \"message\":\n\t\t\treturn `the interactive engine's ${shownType(value)} message`;\n\t\tcase \"extension UI request\":\n\t\t\treturn \"an extension UI request from the interactive engine\";\n\t\tcase \"end\":\n\t\t\treturn \"the end of the interactive engine\";\n\t}\n}\n\n/** What the listener threw, as its message. A value that throws again when it is read gets a fixed text. */\nfunction describeFailure(error: unknown): string {\n\ttry {\n\t\treturn String(isNativeError(error) ? error.message || error.name : error);\n\t} catch {\n\t\treturn \"an exception whose message cannot be read\";\n\t}\n}\n\nconst ignore = (): void => {};\n\n/**\n * Observe a native promise's rejection with the intrinsic `then`, so the promise's own `then` or `catch` never runs.\n * Only a native promise is observed at all: checking any other value for `then` would run that value's code. A\n * promise that cannot be observed (its constructor throws) is left as it is.\n */\nfunction observe(promise: Promise<unknown>, onRejected: (error: unknown) => void): void {\n\ttry {\n\t\tReflect.apply(Promise.prototype.then, promise, [undefined, onRejected]);\n\t} catch {\n\t\t// Nothing was registered, so nothing can be reported; the listener itself did not fail.\n\t}\n}\n\n/**\n * Calls the host's own listeners with what the interactive engine sent. A listener runs in this process, so what it\n * throws, or what the promise it returns rejects with, is a failure of the host's handling, not of the engine's\n * output (#6107). Each failure is reported once, as that, and goes no further: the other listeners still get the\n * input, the engine's connection is not failed, and nothing escapes from a timer or a promise and ends the process.\n */\nexport class HostListenerFailures {\n\tprivate readonly report: (diagnostic: ActivityWatchdogDiagnostic) => void;\n\t/** How a listener's pending promise reaches this reporter without keeping it, or its host, alive. */\n\tprivate readonly weak = new WeakRef(this);\n\n\tconstructor(report: (diagnostic: ActivityWatchdogDiagnostic) => void) {\n\t\tthis.report = report;\n\t}\n\n\t/** Call `listener` with `value`, which is, or comes from, `about`: what the engine sent, described on failure. */\n\tcall<T>(listener: (value: T) => unknown, value: T, input: HostListenerInput, about: unknown = value): void {\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = listener(value);\n\t\t} catch (error) {\n\t\t\tthis.fail(describeInput(input, about), error);\n\t\t\treturn;\n\t\t}\n\t\tif (isPromise(result))\n\t\t\tobserve(result, HostListenerFailures.rejectionObserver(this.weak, describeInput(input, about)));\n\t}\n\n\t/**\n\t * What observes a listener's promise holds while it is pending: the description of the input and a weak\n\t * reference to the reporter, never the input itself or the host behind the reporter.\n\t */\n\tprivate static rejectionObserver(failures: WeakRef<HostListenerFailures>, handling: string) {\n\t\treturn (error: unknown) => failures.deref()?.fail(handling, error);\n\t}\n\n\tprivate fail(handling: string, error: unknown): void {\n\t\ttry {\n\t\t\tconst reported: unknown = this.report({\n\t\t\t\tactivity: undefined,\n\t\t\t\telapsedMs: 0,\n\t\t\t\tlevel: \"unresponsive\",\n\t\t\t\tsource: \"host\",\n\t\t\t\tmessage: `Atomic failed while handling ${handling}: ${describeFailure(error)}`,\n\t\t\t});\n\t\t\tif (isPromise(reported)) observe(reported, ignore);\n\t\t} catch {\n\t\t\t// Reporting the failure failed too. There is nowhere left to report it, and it must not end the process.\n\t\t}\n\t}\n}\n"]}
|
|
@@ -43,6 +43,8 @@ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
43
43
|
private readonly client;
|
|
44
44
|
/** The host session's listeners, which get the engine's events through one ordered subscription. */
|
|
45
45
|
private readonly hostListeners;
|
|
46
|
+
/** A host listener's failure, even one that surfaces while held events are released, is reported, not fatal. */
|
|
47
|
+
private readonly hostListenerFailures;
|
|
46
48
|
private lastHostListener;
|
|
47
49
|
private releasingHostEvents?;
|
|
48
50
|
private hostEventsSubscribed;
|
|
@@ -84,6 +86,10 @@ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
84
86
|
* draws them as queued until their own row arrives.
|
|
85
87
|
*/
|
|
86
88
|
private readonly queuedDeliveries;
|
|
89
|
+
/** What the engine was delivering when it was lost unexpectedly, until the main chat takes it. */
|
|
90
|
+
private deliveringAtLoss;
|
|
91
|
+
/** Queued messages whose row the chat shows and whose save (`message_end`) has not reached it, oldest first. */
|
|
92
|
+
private startedUnsaved;
|
|
87
93
|
/** Ends waiting for their event to reach the host's listeners, which a compaction can hold back. */
|
|
88
94
|
private readonly queuedDeliveryEnds;
|
|
89
95
|
private readonly queuedDeliveryResetListeners;
|
|
@@ -201,6 +207,8 @@ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
201
207
|
private waitForReplacementGeneration;
|
|
202
208
|
private throwIfUnavailable;
|
|
203
209
|
getEnginePid(): number | undefined;
|
|
210
|
+
/** The process ID of the ready engine child, which this runtime's disposal stops within a bounded window. */
|
|
211
|
+
getReadyEngineChildPid(): number | undefined;
|
|
204
212
|
getEngineGeneration(): number;
|
|
205
213
|
isRecovering(): boolean;
|
|
206
214
|
/** Subscribe to host-local engine generation death (see engine-generation.ts). */
|
|
@@ -219,6 +227,14 @@ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
219
227
|
/** Called when the messages being delivered are forgotten at once: the engine was lost or retired its session. */
|
|
220
228
|
onQueuedDeliveriesForgotten(listener: () => void): () => void;
|
|
221
229
|
private forgetQueuedDeliveries;
|
|
230
|
+
/** A user message's save reached the chat: the oldest queued message shown with its text is saved. */
|
|
231
|
+
private noteQueuedMessageSaved;
|
|
232
|
+
/**
|
|
233
|
+
* The messages the engine had taken from its queue when it was lost unexpectedly and the chat never saw saved: being
|
|
234
|
+
* delivered, or shown without their save. The engine may or may not have saved them. Taken once; nothing after a
|
|
235
|
+
* deliberate stop.
|
|
236
|
+
*/
|
|
237
|
+
takeDeliveringAtLoss(): QueuedMessageLanes | undefined;
|
|
222
238
|
/**
|
|
223
239
|
* Forget the queue the lost engine listed: its messages went down with it, and its replacement lists its own. The
|
|
224
240
|
* main chat's steering controller has already taken them for the user (see `loseTarget`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isolated-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,6BAA6B,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,KAAK,gCAAg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Failure, isRpcTransportFailure, markRpcTransportFailure, rpcTransportError, } from "../rpc/rpc-transport-error.js";
|
|
19
19
|
import { EngineHealthController } from "./engine-health.js";
|
|
20
20
|
import { EngineSessionStats } from "./engine-session-stats.js";
|
|
21
|
+
import { HostListenerFailures } from "./host-listener-failures.js";
|
|
21
22
|
import { loginIsolatedApiKeyProvider, loginIsolatedOAuthProvider, } from "./isolated-auth.js";
|
|
22
23
|
import { RemoteCommandCatalog } from "./remote-command-catalog.js";
|
|
23
24
|
import { RemoteModelCatalog } from "./remote-model-catalog.js";
|
|
@@ -70,6 +71,16 @@ export function engineAgentPanelCounts(message) {
|
|
|
70
71
|
}
|
|
71
72
|
/** How long host listeners wait for the session view after a compaction before they get its events anyway. */
|
|
72
73
|
const COMPACTION_VIEW_HOLD_MS = 3_000;
|
|
74
|
+
/**
|
|
75
|
+
* Whether `message`, a user message as the engine sends it, is the queued message listed as `text`: by the text it was
|
|
76
|
+
* queued with, which a message with images keeps as its raw text when its content gains a note about them.
|
|
77
|
+
*/
|
|
78
|
+
function isQueuedText(message, text) {
|
|
79
|
+
if (message.rawText === text)
|
|
80
|
+
return true;
|
|
81
|
+
const content = userMessageText(message.content);
|
|
82
|
+
return content === text || content.startsWith(`${text}\n\n`);
|
|
83
|
+
}
|
|
73
84
|
function userMessageText(content) {
|
|
74
85
|
if (typeof content === "string")
|
|
75
86
|
return content;
|
|
@@ -81,6 +92,8 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
81
92
|
client;
|
|
82
93
|
/** The host session's listeners, which get the engine's events through one ordered subscription. */
|
|
83
94
|
hostListeners = new Map();
|
|
95
|
+
/** A host listener's failure, even one that surfaces while held events are released, is reported, not fatal. */
|
|
96
|
+
hostListenerFailures = new HostListenerFailures((diagnostic) => this.emitDiagnostic(diagnostic));
|
|
84
97
|
lastHostListener = 0;
|
|
85
98
|
releasingHostEvents;
|
|
86
99
|
hostEventsSubscribed = false;
|
|
@@ -122,6 +135,10 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
122
135
|
* draws them as queued until their own row arrives.
|
|
123
136
|
*/
|
|
124
137
|
queuedDeliveries = new QueuedDeliveryView();
|
|
138
|
+
/** What the engine was delivering when it was lost unexpectedly, until the main chat takes it. */
|
|
139
|
+
deliveringAtLoss;
|
|
140
|
+
/** Queued messages whose row the chat shows and whose save (`message_end`) has not reached it, oldest first. */
|
|
141
|
+
startedUnsaved = [];
|
|
125
142
|
/** Ends waiting for their event to reach the host's listeners, which a compaction can hold back. */
|
|
126
143
|
queuedDeliveryEnds = new WeakMap();
|
|
127
144
|
queuedDeliveryResetListeners = new Set();
|
|
@@ -255,7 +272,18 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
255
272
|
if (event.generation === this.client.getGeneration()) {
|
|
256
273
|
this.panelCounts = { total: 0, agents: 0, needsInput: 0, shells: 0, subagents: 0 };
|
|
257
274
|
this.updateResources({});
|
|
258
|
-
// What
|
|
275
|
+
// What a lost engine took from its queue and the chat never saw saved may have gone with it unsaved: kept for
|
|
276
|
+
// the chat to account for.
|
|
277
|
+
if (!event.expected) {
|
|
278
|
+
const delivering = this.queuedDeliveries.texts;
|
|
279
|
+
const started = (lane) => this.startedUnsaved.flatMap((entry) => (entry.lane === lane ? [entry.text] : []));
|
|
280
|
+
this.deliveringAtLoss = {
|
|
281
|
+
steering: [...started("steer"), ...delivering.steering],
|
|
282
|
+
followUp: [...started("followUp"), ...delivering.followUp],
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
this.startedUnsaved = [];
|
|
286
|
+
// Its replacement starts telling afresh.
|
|
259
287
|
this.forgetQueuedDeliveries();
|
|
260
288
|
}
|
|
261
289
|
// A first child that never became ready failed startup; initialStart reports it instead of a restart.
|
|
@@ -467,7 +495,10 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
467
495
|
this.restrictedStartupCatalogs.add(session);
|
|
468
496
|
else if (state.projectTrusted !== undefined)
|
|
469
497
|
this.restrictedStartupCatalogs.delete(session);
|
|
470
|
-
|
|
498
|
+
// A pending report can hold the project's resources back but never grants them: until the engine dispatches the
|
|
499
|
+
// decision, an extension can still register a handler that declines the folder. The decision itself arrives as
|
|
500
|
+
// `engine_trust_decision` or in the final report (#5693).
|
|
501
|
+
const resourcesTrusted = state.projectTrusted ?? (state.pendingProjectResourcesTrusted === false ? false : undefined);
|
|
471
502
|
if (resourcesTrusted !== undefined && session.settingsManager.isProjectTrusted() !== resourcesTrusted) {
|
|
472
503
|
// The child owns trust hooks/decisions. The host only mirrors their result.
|
|
473
504
|
await session.settingsManager.setProjectTrustedAsync(resourcesTrusted);
|
|
@@ -718,6 +749,10 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
718
749
|
getEnginePid() {
|
|
719
750
|
return this.client.getEnginePid();
|
|
720
751
|
}
|
|
752
|
+
/** The process ID of the ready engine child, which this runtime's disposal stops within a bounded window. */
|
|
753
|
+
getReadyEngineChildPid() {
|
|
754
|
+
return this.client.getReadyEngineChildPid();
|
|
755
|
+
}
|
|
721
756
|
getEngineGeneration() {
|
|
722
757
|
return this.client.getGeneration();
|
|
723
758
|
}
|
|
@@ -759,11 +794,30 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
759
794
|
return () => this.queuedDeliveryResetListeners.delete(listener);
|
|
760
795
|
}
|
|
761
796
|
forgetQueuedDeliveries() {
|
|
797
|
+
this.startedUnsaved = [];
|
|
762
798
|
if (!this.queuedDeliveries.reset())
|
|
763
799
|
return;
|
|
764
800
|
for (const listener of [...this.queuedDeliveryResetListeners])
|
|
765
801
|
listener();
|
|
766
802
|
}
|
|
803
|
+
/** A user message's save reached the chat: the oldest queued message shown with its text is saved. */
|
|
804
|
+
noteQueuedMessageSaved(message) {
|
|
805
|
+
if (this.startedUnsaved.length === 0)
|
|
806
|
+
return;
|
|
807
|
+
const index = this.startedUnsaved.findIndex((entry) => isQueuedText(message, entry.text));
|
|
808
|
+
if (index >= 0)
|
|
809
|
+
this.startedUnsaved.splice(index, 1);
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* The messages the engine had taken from its queue when it was lost unexpectedly and the chat never saw saved: being
|
|
813
|
+
* delivered, or shown without their save. The engine may or may not have saved them. Taken once; nothing after a
|
|
814
|
+
* deliberate stop.
|
|
815
|
+
*/
|
|
816
|
+
takeDeliveringAtLoss() {
|
|
817
|
+
const delivering = this.deliveringAtLoss;
|
|
818
|
+
this.deliveringAtLoss = undefined;
|
|
819
|
+
return delivering;
|
|
820
|
+
}
|
|
767
821
|
/**
|
|
768
822
|
* Forget the queue the lost engine listed: its messages went down with it, and its replacement lists its own. The
|
|
769
823
|
* main chat's steering controller has already taken them for the user (see `loseTarget`).
|
|
@@ -865,7 +919,8 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
865
919
|
});
|
|
866
920
|
}
|
|
867
921
|
emitDiagnostic(diagnostic) {
|
|
868
|
-
|
|
922
|
+
// A failure of the host's own listeners says nothing about what the engine is doing.
|
|
923
|
+
if (diagnostic.source !== "stderr" && diagnostic.source !== "host")
|
|
869
924
|
this.engineCallbackActive = true;
|
|
870
925
|
this.health.publish(diagnostic);
|
|
871
926
|
}
|
|
@@ -982,8 +1037,10 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
982
1037
|
// Optional like the other transport surfaces focused test doubles omit.
|
|
983
1038
|
const unrecordedQuit = !options?.fromSignal && (await this.client.announceExplicitQuit?.()) === false;
|
|
984
1039
|
// A quit lets the engine run its extensions' shutdown on every platform. After a
|
|
985
|
-
// signal, Windows still ends the engine at once.
|
|
986
|
-
const stop =
|
|
1040
|
+
// signal, Windows still ends the engine at once. A disposal after a failed start is not one for a signal.
|
|
1041
|
+
const stop = options?.fromSignal && !this.startupFailure
|
|
1042
|
+
? { graceful: false, hostSignaled: true }
|
|
1043
|
+
: { graceful: !options?.fromSignal };
|
|
987
1044
|
// EngineHealthController owns the first client stop and joins recovery.
|
|
988
1045
|
await this.health.shutdown(stop);
|
|
989
1046
|
// A replacement may have spawned while shutdown joined recovery; the
|
|
@@ -1399,11 +1456,21 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
1399
1456
|
const end = this.queuedDeliveryEnds.get(event);
|
|
1400
1457
|
if (end !== undefined) {
|
|
1401
1458
|
this.queuedDeliveryEnds.delete(event);
|
|
1402
|
-
this.queuedDeliveries.end(end);
|
|
1459
|
+
const ended = this.queuedDeliveries.end(end);
|
|
1460
|
+
// Only the queued message this user message_start shows is started; one that ended otherwise (a turn that
|
|
1461
|
+
// failed before sending it queued it again) is not.
|
|
1462
|
+
const started = ended.at(-1);
|
|
1463
|
+
if (started !== undefined &&
|
|
1464
|
+
event.type === "message_start" &&
|
|
1465
|
+
event.message.role === "user" &&
|
|
1466
|
+
isQueuedText(event.message, started.text))
|
|
1467
|
+
this.startedUnsaved.push(started);
|
|
1403
1468
|
}
|
|
1469
|
+
if (event.type === "message_end" && event.message.role === "user")
|
|
1470
|
+
this.noteQueuedMessageSaved(event.message);
|
|
1404
1471
|
for (const [id, listener] of [...this.hostListeners])
|
|
1405
1472
|
if (id <= audience)
|
|
1406
|
-
listener
|
|
1473
|
+
this.hostListenerFailures.call(listener, event, "event");
|
|
1407
1474
|
}
|
|
1408
1475
|
discardHeldHostEvents() {
|
|
1409
1476
|
const hold = this.compactionHold;
|