@bastani/atomic 0.10.2 → 0.10.3
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 +120 -0
- package/dist/builtin/intercom/CHANGELOG.md +22 -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 +26 -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 +731 -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 +41 -38
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +276 -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 +14 -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
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
holdsSessionId,
|
|
36
36
|
KNOWN_SESSION_RETENTION_MS,
|
|
37
37
|
type KnownSession,
|
|
38
|
+
type KnownSessionBindResult,
|
|
38
39
|
type KnownSessionState,
|
|
39
40
|
type Lease,
|
|
40
41
|
type LeaseState,
|
|
@@ -54,6 +55,7 @@ import {
|
|
|
54
55
|
reservationKeyFor,
|
|
55
56
|
returnAddressOf,
|
|
56
57
|
type SentMessageReservation,
|
|
58
|
+
type SessionIdReclaimResult,
|
|
57
59
|
} from "./multinode-state-store.js";
|
|
58
60
|
import type { PendingQuestion, PendingQuestionIndex } from "./pending-question-index.js";
|
|
59
61
|
import { ROUTE_UNAVAILABLE_REASON } from "./delivery-failure-reason.js";
|
|
@@ -168,6 +170,31 @@ const MAX_SUPERSEDED_HOPS = 8;
|
|
|
168
170
|
export const KNOWN_SESSION_REFRESH_INTERVAL_MS = 60 * 60 * 1000;
|
|
169
171
|
const TARGET_GROUP_REFUSAL = "Target session is in a different intercom group";
|
|
170
172
|
|
|
173
|
+
/** How a registration's claim of its preferred id ended (`MultiNodeRouter.claimSessionId`). */
|
|
174
|
+
export type SessionIdClaim =
|
|
175
|
+
| { readonly status: "granted" }
|
|
176
|
+
| { readonly status: "refused" }
|
|
177
|
+
/** #5607: the shared database did not answer in time; see `SessionIdReclaimRequest`. */
|
|
178
|
+
| { readonly status: "unanswered"; readonly unanswered: UnansweredSessionIdClaim };
|
|
179
|
+
|
|
180
|
+
/** #5607: a claim the shared database did not answer in time: the id it asked for, and the value it wrote with it. */
|
|
181
|
+
export interface UnansweredSessionIdClaim {
|
|
182
|
+
readonly sessionId: string;
|
|
183
|
+
readonly claim: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* #5607: given to `sessionRegistered` for a session whose claim went unanswered. The session is not registered on this
|
|
188
|
+
* broker yet: `settle` registers it, once, under the claimed id (`keep`) or the fresh one its registration started
|
|
189
|
+
* with, and reports whether it kept the claimed id. It cannot keep it once its registration has been answered or a
|
|
190
|
+
* session here holds that id, and does nothing after the first call.
|
|
191
|
+
*/
|
|
192
|
+
export interface SessionIdReclaimRequest extends UnansweredSessionIdClaim {
|
|
193
|
+
readonly settle: (keep: boolean) => boolean;
|
|
194
|
+
/** Whether `settle` is still to be called: false once the registration settled without it, as when it was answered. */
|
|
195
|
+
readonly unsettled: () => boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
171
198
|
/** What the broker uses of `open-broker-state.ts`, which it loads lazily (replaceable in tests). */
|
|
172
199
|
export interface BrokerStateOpener<Source> {
|
|
173
200
|
resolveBrokerStateSource(
|
|
@@ -421,6 +448,14 @@ function outboxFullReason(full: { readonly limit: number; readonly byteLimit: nu
|
|
|
421
448
|
} MiB); this message was not queued. Messages already queued for it are kept. Try again after it returns and receives them.`;
|
|
422
449
|
}
|
|
423
450
|
|
|
451
|
+
/**
|
|
452
|
+
* #5607: what an enqueue for a recipient the sender found offline (`hostBrokerId` absent) also does: wake the broker
|
|
453
|
+
* holding the recipient's live presence as the row is written, should it have registered meanwhile.
|
|
454
|
+
*/
|
|
455
|
+
function offlineHost(hostBrokerId: string | undefined): Pick<OutboxEnqueueRequest, "wakeHostWithinMs"> {
|
|
456
|
+
return hostBrokerId === undefined ? { wakeHostWithinMs: BROKER_LEASE_STALE_AFTER_MS } : {};
|
|
457
|
+
}
|
|
458
|
+
|
|
424
459
|
function queuedFrame(messageId: string, attemptId: string | undefined, position: number): BrokerOutboundFrame {
|
|
425
460
|
return {
|
|
426
461
|
type: "queued",
|
|
@@ -608,29 +643,77 @@ export class MultiNodeRouter {
|
|
|
608
643
|
/**
|
|
609
644
|
* Whether a registration with `returnAddress` may take the Intercom id `sessionId`, binding the id to it when free.
|
|
610
645
|
* In multi-node mode an id carries authority (shared ask routes and known sessions name sessions by id), so only the
|
|
611
|
-
* session that registered it gets it back.
|
|
646
|
+
* session that registered it gets it back. `unanswered` when the shared store does not answer in time: the session
|
|
647
|
+
* registers under a fresh id, and its registration's binding write tries once more to keep this one (#5607).
|
|
612
648
|
*/
|
|
613
|
-
async claimSessionId(sessionId: string, returnAddress: string): Promise<
|
|
614
|
-
if (this.closed) return
|
|
649
|
+
async claimSessionId(sessionId: string, returnAddress: string): Promise<SessionIdClaim> {
|
|
650
|
+
if (this.closed) return { status: "refused" };
|
|
651
|
+
// #5607: written with the binding, so a later write can tell whether the binding is still this claim's.
|
|
652
|
+
const claim = randomUUID();
|
|
615
653
|
let bound: ReturnType<typeof setTimeout> | undefined;
|
|
616
654
|
try {
|
|
617
|
-
return await Promise.race([
|
|
655
|
+
return await Promise.race<SessionIdClaim>([
|
|
618
656
|
this.state.knownSessions
|
|
619
|
-
.bind(sessionId, returnAddress, KNOWN_SESSION_RETENTION_MS)
|
|
620
|
-
.then((result) => result.status === "bound"),
|
|
621
|
-
new Promise<
|
|
622
|
-
bound = setTimeout(
|
|
657
|
+
.bind(sessionId, returnAddress, KNOWN_SESSION_RETENTION_MS, claim)
|
|
658
|
+
.then((result) => ({ status: result.status === "bound" ? "granted" : "refused" })),
|
|
659
|
+
new Promise<SessionIdClaim>((resolve) => {
|
|
660
|
+
bound = setTimeout(
|
|
661
|
+
() => resolve({ status: "unanswered", unanswered: { sessionId, claim } }),
|
|
662
|
+
SESSION_ID_CLAIM_BOUND_MS,
|
|
663
|
+
);
|
|
623
664
|
bound.unref?.();
|
|
624
665
|
}),
|
|
625
666
|
]);
|
|
626
667
|
} catch (error) {
|
|
627
668
|
this.report(error);
|
|
628
|
-
return
|
|
669
|
+
return { status: "refused" };
|
|
629
670
|
} finally {
|
|
630
671
|
clearTimeout(bound);
|
|
631
672
|
}
|
|
632
673
|
}
|
|
633
674
|
|
|
675
|
+
/**
|
|
676
|
+
* #5607: the binding write of a registration whose claim of its preferred id went unanswered, in the slot today's
|
|
677
|
+
* fresh-id binding takes. One write keeps the preferred id when the binding is still the one that claim wrote and no
|
|
678
|
+
* other broker presents a session of its return address, in any group; otherwise it binds the fresh id. The session is then registered
|
|
679
|
+
* here under the id the write chose, or under the fresh id when the claimed one can no longer be given (its
|
|
680
|
+
* registration was answered meanwhile, or a session here holds it), which is then bound as today.
|
|
681
|
+
*/
|
|
682
|
+
private async reclaimOrBind(
|
|
683
|
+
session: BrokerConnectedSession,
|
|
684
|
+
reclaim: SessionIdReclaimRequest,
|
|
685
|
+
): Promise<KnownSessionBindResult> {
|
|
686
|
+
const { knownSessions } = this.state;
|
|
687
|
+
const returnAddress = session.registrationReturnAddress ?? "";
|
|
688
|
+
const freshId = session.info.id;
|
|
689
|
+
const bindFresh = () => {
|
|
690
|
+
reclaim.settle(false);
|
|
691
|
+
return knownSessions.bind(freshId, returnAddress, KNOWN_SESSION_RETENTION_MS);
|
|
692
|
+
};
|
|
693
|
+
if (knownSessions.reclaim === undefined || !reclaim.unsettled()) return bindFresh();
|
|
694
|
+
let reclaimed: SessionIdReclaimResult;
|
|
695
|
+
try {
|
|
696
|
+
reclaimed = await knownSessions.reclaim({
|
|
697
|
+
intercomSessionId: reclaim.sessionId,
|
|
698
|
+
returnAddress,
|
|
699
|
+
claim: reclaim.claim,
|
|
700
|
+
retentionMs: KNOWN_SESSION_RETENTION_MS,
|
|
701
|
+
brokerId: this.brokerId,
|
|
702
|
+
presenceStaleAfterMs: BROKER_LEASE_STALE_AFTER_MS,
|
|
703
|
+
freshId,
|
|
704
|
+
});
|
|
705
|
+
} catch (error) {
|
|
706
|
+
reclaim.settle(false);
|
|
707
|
+
throw error;
|
|
708
|
+
}
|
|
709
|
+
if (reclaimed.status === "fresh") {
|
|
710
|
+
reclaim.settle(false);
|
|
711
|
+
return reclaimed.binding;
|
|
712
|
+
}
|
|
713
|
+
if (reclaimed.status === "kept" && reclaim.settle(true)) return { status: "bound" };
|
|
714
|
+
return bindFresh();
|
|
715
|
+
}
|
|
716
|
+
|
|
634
717
|
private holdsSessionId(sessionId: string, returnAddress: string | undefined): Promise<boolean> {
|
|
635
718
|
return holdsSessionId(this.state.knownSessions, sessionId, returnAddress);
|
|
636
719
|
}
|
|
@@ -643,6 +726,7 @@ export class MultiNodeRouter {
|
|
|
643
726
|
sessionRegistered(
|
|
644
727
|
session: BrokerConnectedSession,
|
|
645
728
|
consumed?: ConsumedReservation,
|
|
729
|
+
reclaim?: SessionIdReclaimRequest,
|
|
646
730
|
): Promise<void> {
|
|
647
731
|
if (this.closed || this.presence.has(session)) return Promise.resolve();
|
|
648
732
|
const entry: PresenceEntry = {};
|
|
@@ -657,11 +741,14 @@ export class MultiNodeRouter {
|
|
|
657
741
|
this.serial(identity, async () => {
|
|
658
742
|
try {
|
|
659
743
|
// An id bound to another session's return address is not this session's across nodes (see `claimSessionId`).
|
|
660
|
-
const binding =
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
744
|
+
const binding =
|
|
745
|
+
reclaim === undefined
|
|
746
|
+
? await this.state.knownSessions.bind(
|
|
747
|
+
session.info.id,
|
|
748
|
+
session.registrationReturnAddress ?? "",
|
|
749
|
+
KNOWN_SESSION_RETENTION_MS,
|
|
750
|
+
)
|
|
751
|
+
: await this.reclaimOrBind(session, reclaim);
|
|
665
752
|
if (binding.status === "refused") {
|
|
666
753
|
entry.unbound = true;
|
|
667
754
|
return;
|
|
@@ -948,6 +1035,7 @@ export class MultiNodeRouter {
|
|
|
948
1035
|
digest: crossNodeDigest(JSON.stringify(frame)),
|
|
949
1036
|
frame,
|
|
950
1037
|
owed: true,
|
|
1038
|
+
...offlineHost(owner.hostBrokerId),
|
|
951
1039
|
});
|
|
952
1040
|
if (enqueued.status === "invalid" || enqueued.status === "full") continue;
|
|
953
1041
|
if (enqueued.status === "inserted" && owner.hostBrokerId !== undefined) {
|
|
@@ -1055,6 +1143,7 @@ export class MultiNodeRouter {
|
|
|
1055
1143
|
digest: crossNodeDigest(JSON.stringify(frame)),
|
|
1056
1144
|
frame,
|
|
1057
1145
|
owed: true,
|
|
1146
|
+
...offlineHost(hosted?.holderId),
|
|
1058
1147
|
});
|
|
1059
1148
|
// Not queued: the ask stays marked ended, so a later sweep tries again.
|
|
1060
1149
|
if (enqueued.status === "full" || enqueued.status === "invalid") continue;
|
|
@@ -1974,7 +2063,13 @@ export class MultiNodeRouter {
|
|
|
1974
2063
|
const { owner, frame } = decision;
|
|
1975
2064
|
const digest = crossNodeDigest(request.signature);
|
|
1976
2065
|
const enqueued = await this.state.outbox
|
|
1977
|
-
.enqueue({
|
|
2066
|
+
.enqueue({
|
|
2067
|
+
targetIdentity: owner.identity,
|
|
2068
|
+
originBrokerId: this.brokerId,
|
|
2069
|
+
digest,
|
|
2070
|
+
frame,
|
|
2071
|
+
...offlineHost(owner.hostBrokerId),
|
|
2072
|
+
})
|
|
1978
2073
|
.catch((error: Error) => this.reopenAfter(decision, error));
|
|
1979
2074
|
if (enqueued.status === "conflict") {
|
|
1980
2075
|
await this.reopenQuestion(decision);
|
|
@@ -2253,7 +2348,7 @@ export class MultiNodeRouter {
|
|
|
2253
2348
|
? { questionRoute: { targetSessionId: target.sessionId, senderGroupIdentity: senderGroupIdentity(from) } }
|
|
2254
2349
|
: {}),
|
|
2255
2350
|
},
|
|
2256
|
-
{ targetIdentity: target.identity, originBrokerId: this.brokerId, digest, frame },
|
|
2351
|
+
{ targetIdentity: target.identity, originBrokerId: this.brokerId, digest, frame, ...offlineHost(target.hostBrokerId) },
|
|
2257
2352
|
);
|
|
2258
2353
|
if (enqueued.status === "conflict") {
|
|
2259
2354
|
this.failConflict(request);
|
|
@@ -183,6 +183,13 @@ export interface OutboxEnqueueRequest {
|
|
|
183
183
|
* refusing it would leave the ask waiting forever.
|
|
184
184
|
*/
|
|
185
185
|
readonly owed?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* #5607: the sender found the recipient offline. In the write that inserts the row, the broker holding the
|
|
188
|
+
* recipient's presence lease, renewed within this many milliseconds, is sent a wake-up hint for it (the database
|
|
189
|
+
* wake-up bus's `outbox` hint), so a recipient that registered elsewhere meanwhile gets the row at once. A store that
|
|
190
|
+
* ignores it wakes nobody; the backup poll still finds the row.
|
|
191
|
+
*/
|
|
192
|
+
readonly wakeHostWithinMs?: number;
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
export interface OutboxRow {
|
|
@@ -227,7 +234,12 @@ export interface OutboxClaimRequest {
|
|
|
227
234
|
}
|
|
228
235
|
|
|
229
236
|
export type OutboxEnqueueResult =
|
|
230
|
-
| {
|
|
237
|
+
| {
|
|
238
|
+
readonly status: "inserted";
|
|
239
|
+
readonly row: OutboxRow;
|
|
240
|
+
/** #5607: with `wakeHostWithinMs`, the broker the write sent a wake-up hint for the row. */
|
|
241
|
+
readonly woke?: string;
|
|
242
|
+
}
|
|
231
243
|
/** Same id and digest: no second row is written and the existing row reports its current state. */
|
|
232
244
|
| { readonly status: "duplicate"; readonly row: OutboxRow }
|
|
233
245
|
| { readonly status: "conflict"; readonly messageId: string }
|
|
@@ -833,6 +845,27 @@ export type KnownSessionBindResult =
|
|
|
833
845
|
| { readonly status: "bound" }
|
|
834
846
|
| { readonly status: "refused"; readonly returnAddress: string }
|
|
835
847
|
| InvalidStateInput;
|
|
848
|
+
/** #5607: see `KnownSessionStore.reclaim`. */
|
|
849
|
+
export interface SessionIdReclaim {
|
|
850
|
+
readonly intercomSessionId: string;
|
|
851
|
+
readonly returnAddress: string;
|
|
852
|
+
/** The `claim` the registration's own `bind` was given. */
|
|
853
|
+
readonly claim: string;
|
|
854
|
+
readonly retentionMs: number;
|
|
855
|
+
/** The broker reclaiming; a presence lease it holds itself does not count. */
|
|
856
|
+
readonly brokerId: string;
|
|
857
|
+
/** A presence lease renewed within this many milliseconds is live. */
|
|
858
|
+
readonly presenceStaleAfterMs: number;
|
|
859
|
+
/** The id bound instead when the id is not kept. */
|
|
860
|
+
readonly freshId: string;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export type SessionIdReclaimResult =
|
|
864
|
+
| { readonly status: "kept" }
|
|
865
|
+
/** Not kept: `freshId` was bound as `bind` binds it, with its result. */
|
|
866
|
+
| { readonly status: "fresh"; readonly binding: KnownSessionBindResult }
|
|
867
|
+
| InvalidStateInput;
|
|
868
|
+
|
|
836
869
|
export type KnownSessionBindingResult =
|
|
837
870
|
| { readonly status: "bound"; readonly returnAddress: string }
|
|
838
871
|
| { readonly status: "unbound" }
|
|
@@ -855,9 +888,22 @@ export interface KnownSessionStore {
|
|
|
855
888
|
* gave none), unless another return address has held it within `retentionMs`, and reset the binding's age. In multi-node mode an id carries
|
|
856
889
|
* authority: it is granted, and delivered to, only the session it is bound to. An id with no binding yet is bound
|
|
857
890
|
* first to the return address its earliest known-session record has, so a record kept from before bindings existed
|
|
858
|
-
* still holds it.
|
|
859
|
-
|
|
860
|
-
|
|
891
|
+
* still holds it. #5607: `claim`, a value unique to this registration, is recorded as the binding's latest claim
|
|
892
|
+
* when it binds, so `reclaim` can tell later whether the binding is still the one this registration wrote.
|
|
893
|
+
*/
|
|
894
|
+
bind(
|
|
895
|
+
intercomSessionId: string,
|
|
896
|
+
returnAddress: string,
|
|
897
|
+
retentionMs: number,
|
|
898
|
+
claim?: string,
|
|
899
|
+
): Promise<KnownSessionBindResult>;
|
|
900
|
+
/**
|
|
901
|
+
* #5607: the one write a returning registration makes when its `bind` did not answer in time. It keeps the id when
|
|
902
|
+
* the binding is still the one that `bind` wrote (same return address and claim, within `retentionMs`) and no other
|
|
903
|
+
* broker holds a live presence lease for a session of that return address, in any group, resetting the binding's age. Otherwise
|
|
904
|
+
* it binds `freshId` as `bind` does. Optional: without it such a registration gets a fresh id, bound as `bind` binds it.
|
|
905
|
+
*/
|
|
906
|
+
reclaim?(request: SessionIdReclaim): Promise<SessionIdReclaimResult>;
|
|
861
907
|
/** The return address the id is bound to, if a binding recorded within `retentionMs` holds it. */
|
|
862
908
|
binding(intercomSessionId: string, retentionMs: number): Promise<KnownSessionBindingResult>;
|
|
863
909
|
/** Delete records and bindings last recorded more than `olderThanMs` ago; returns the count of records. */
|
|
@@ -21,7 +21,7 @@ import { openSqlEndedChildQueueStore } from "./sql-ended-child-queue-store.js";
|
|
|
21
21
|
import { openSqlHeldSendStore } from "./sql-held-send-store.js";
|
|
22
22
|
import { openSqlKnownSessionStore } from "./sql-known-session-store.js";
|
|
23
23
|
import { openSqlBrokerLeaseStore } from "./sql-lease-store.js";
|
|
24
|
-
import { openSqlOutboxStore } from "./sql-outbox-store.js";
|
|
24
|
+
import { openSqlOutboxStore, withoutFailedWake } from "./sql-outbox-store.js";
|
|
25
25
|
import { openSqlPendingAskStore } from "./sql-pending-ask-store.js";
|
|
26
26
|
import { openSqlReleasedAskStore } from "./sql-released-ask-store.js";
|
|
27
27
|
import { openSqlRestoringReservationStore } from "./sql-restoring-reservation-store.js";
|
|
@@ -158,11 +158,12 @@ export async function openIntercomBrokerState(
|
|
|
158
158
|
sentMessages,
|
|
159
159
|
knownSessions,
|
|
160
160
|
reserveAndEnqueue(reservation, request) {
|
|
161
|
-
|
|
161
|
+
// #5607: written again, without it, when only an offline recipient's wake-up hint failed.
|
|
162
|
+
return withoutFailedWake(request, (attempt) => database.transaction(async (tx) => {
|
|
162
163
|
const key = { messageId: reservation.messageId, digest: reservation.digest };
|
|
163
164
|
const earlier = await sentMessages.lookupIn(tx, key);
|
|
164
165
|
if (earlier.status === "conflict") return { status: "conflict", messageId: reservation.messageId } as const;
|
|
165
|
-
const enqueued = await outbox.enqueueIn(tx,
|
|
166
|
+
const enqueued = await outbox.enqueueIn(tx, attempt);
|
|
166
167
|
if (enqueued.status === "full") {
|
|
167
168
|
// Refused before anything was written, so the transaction has no commit to sync.
|
|
168
169
|
if (earlier.status === "match") await sentMessages.forgetIn(tx, key);
|
|
@@ -171,7 +172,7 @@ export async function openIntercomBrokerState(
|
|
|
171
172
|
// Its answer is not needed: the outbox's unique message id is the authority for a row it holds (spec §5.5).
|
|
172
173
|
await sentMessages.reserveIn(tx, reservation);
|
|
173
174
|
return enqueued;
|
|
174
|
-
});
|
|
175
|
+
}));
|
|
175
176
|
},
|
|
176
177
|
openEndedChildQueue(owner) {
|
|
177
178
|
return openSqlEndedChildQueueStore(options, owner);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { BROKER_READY_TIMEOUT_MS } from "./startup-timeout.js";
|
|
26
26
|
import {
|
|
27
27
|
BROKER_ANNOUNCE_PATH_ENV,
|
|
28
|
+
BROKER_ANNOUNCE_START_ENV,
|
|
28
29
|
BROKER_ANNOUNCE_TOKEN_ENV,
|
|
29
30
|
type BrokerStartAnnouncement,
|
|
30
31
|
readBrokerStartAnnouncementAsync,
|
|
@@ -36,9 +37,11 @@ import {
|
|
|
36
37
|
isIntercomBrokerStopTimeoutError,
|
|
37
38
|
processSharedStorageSelection,
|
|
38
39
|
processSharedStorageSelectionAsync,
|
|
40
|
+
readProcessCreationTime,
|
|
39
41
|
takeTakeoverMutex,
|
|
40
42
|
takeTakeoverMutexAsync,
|
|
41
43
|
} from "@bastani/atomic";
|
|
44
|
+
import { hostCommandEnvironment } from "./host-command-environment.js";
|
|
42
45
|
import { isBrokerStatusReport } from "./broker-status.js";
|
|
43
46
|
import { BROKER_UPGRADE_STOP_TIMEOUT_MS, requestBrokerShutdown, waitForBrokerExit } from "./broker-stop.js";
|
|
44
47
|
import { BROKER_CONTROL_TIMEOUT_MS, controlRequest } from "./control-request.js";
|
|
@@ -298,7 +301,8 @@ export function getBrokerLaunchSpec(
|
|
|
298
301
|
*
|
|
299
302
|
* The broker routes through the shared storage this process was launched with (`--storage`,
|
|
300
303
|
* `--storage-file` or `ATOMIC_STORAGE`), passed as `ATOMIC_STORAGE`; without one it reads settings.
|
|
301
|
-
* With `announcement` it also gets the file and token it announces its pid with
|
|
304
|
+
* With `announcement` it also gets the file and token it announces its pid with, and asks it to add when it was created
|
|
305
|
+
* (`start-announcement.ts`).
|
|
302
306
|
*/
|
|
303
307
|
function buildBrokerSpawnOptions(
|
|
304
308
|
storage: string | undefined,
|
|
@@ -321,7 +325,11 @@ function buildBrokerSpawnOptions(
|
|
|
321
325
|
...(storage === undefined ? {} : { [BROKER_STORAGE_ENV]: storage }),
|
|
322
326
|
...(announcement === undefined
|
|
323
327
|
? {}
|
|
324
|
-
: {
|
|
328
|
+
: {
|
|
329
|
+
[BROKER_ANNOUNCE_PATH_ENV]: announcement.path,
|
|
330
|
+
[BROKER_ANNOUNCE_TOKEN_ENV]: announcement.token,
|
|
331
|
+
[BROKER_ANNOUNCE_START_ENV]: "1",
|
|
332
|
+
}),
|
|
325
333
|
}),
|
|
326
334
|
windowsHide: true,
|
|
327
335
|
};
|
|
@@ -641,7 +649,9 @@ async function spawnBrokerHoldingLock(
|
|
|
641
649
|
// returns while that broker is writing its start-up files.
|
|
642
650
|
waitForBroker(
|
|
643
651
|
readyTimeoutMs,
|
|
644
|
-
announcement === undefined
|
|
652
|
+
announcement === undefined
|
|
653
|
+
? undefined
|
|
654
|
+
: async () => (await readBrokerStartAnnouncementAsync(announcement))?.pid,
|
|
645
655
|
cancelSignal,
|
|
646
656
|
).then(() => {
|
|
647
657
|
cleanup();
|
|
@@ -651,14 +661,22 @@ async function spawnBrokerHoldingLock(
|
|
|
651
661
|
const starting = launch.kind === "direct" && child.exitCode === null && child.signalCode === null;
|
|
652
662
|
// #4727: the session that launched this broker is gone and the broker did not start in time; it is stopped
|
|
653
663
|
// before this call returns, so it never writes into an agent directory its host may already be removing. Behind
|
|
654
|
-
// the Windows launcher the broker is found by the pid it announced; one that never announced cannot be found
|
|
655
|
-
|
|
664
|
+
// the Windows launcher the broker is found by the pid it announced; one that never announced cannot be found,
|
|
665
|
+
// and one that did not announce when it was created cannot be told apart from a later process given its pid
|
|
666
|
+
// (#6133), so neither is stopped.
|
|
667
|
+
let abandoned: StartingBroker | undefined;
|
|
656
668
|
if (signal?.aborted) {
|
|
657
|
-
if (launch.kind === "direct")
|
|
658
|
-
|
|
669
|
+
if (launch.kind === "direct") {
|
|
670
|
+
if (starting && child.pid !== undefined) abandoned = { kind: "group", pid: child.pid };
|
|
671
|
+
} else if (announcement !== undefined) {
|
|
672
|
+
const announced = await readBrokerStartAnnouncementAsync(announcement);
|
|
673
|
+
if (announced?.started !== undefined) {
|
|
674
|
+
abandoned = { kind: "announced", pid: announced.pid, started: announced.started };
|
|
675
|
+
}
|
|
676
|
+
}
|
|
659
677
|
}
|
|
660
|
-
if (
|
|
661
|
-
void stopStartingBroker(
|
|
678
|
+
if (abandoned !== undefined) {
|
|
679
|
+
void stopStartingBroker(abandoned).finally(() => reject(toError(error)));
|
|
662
680
|
return;
|
|
663
681
|
}
|
|
664
682
|
// A broker still starting keeps the lock, so later spawners wait for it instead of starting another.
|
|
@@ -685,29 +703,130 @@ const STARTING_BROKER_KILL_WAIT_MS = 5_000;
|
|
|
685
703
|
/** A killed process is gone within milliseconds, and a session that is closing waits for it. */
|
|
686
704
|
const STARTING_BROKER_KILL_POLL_MS = 10;
|
|
687
705
|
|
|
706
|
+
/** A broker that has not started listening, as the spawner that launched it finds it. */
|
|
707
|
+
type StartingBroker =
|
|
708
|
+
/**
|
|
709
|
+
* Spawned directly and detached, so it leads a process group of its own. A custom broker command can run the broker
|
|
710
|
+
* as its own child rather than replacing itself with it; the group holds both. Its pid is read while the spawner's
|
|
711
|
+
* child has not been reaped, so it still names that child.
|
|
712
|
+
*/
|
|
713
|
+
| { readonly kind: "group"; readonly pid: number }
|
|
714
|
+
/** Behind the Windows launcher: the pid the broker announced, and when that process was created. */
|
|
715
|
+
| { readonly kind: "announced"; readonly pid: number; readonly started: string };
|
|
716
|
+
|
|
717
|
+
/** How long the check and Windows PowerShell's start may take before the session stops waiting for the broker. */
|
|
718
|
+
const ANNOUNCED_BROKER_STOP_START_MS = 5_000;
|
|
719
|
+
/** Beyond the PowerShell's own bounds, how much longer the session waits for it to end. */
|
|
720
|
+
const ANNOUNCED_BROKER_STOP_MARGIN_MS = 1_000;
|
|
721
|
+
|
|
688
722
|
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
723
|
+
* The PowerShell that stops the Windows broker `pid` created at `started` (#6133), with every process it started. Each
|
|
724
|
+
* process is ended only through a handle this PowerShell holds to it, opened before it is checked and kept until the
|
|
725
|
+
* PowerShell ends: Windows gives a pid to no other process while a handle to it is open, so a check made through the
|
|
726
|
+
* handle stays true for the process it ends. So a PowerShell that is itself ended part way leaves processes running,
|
|
727
|
+
* and never ends one that is not the broker's.
|
|
728
|
+
*
|
|
729
|
+
* The broker is the process whose creation time is `started`. Its processes are found from one `Win32_Process`
|
|
730
|
+
* snapshot by parent pid: a process counts as a child only if it was created no earlier than its parent (an older
|
|
731
|
+
* process naming that pid as its parent was started by an earlier holder of the pid), and only if the process its
|
|
732
|
+
* handle holds was created when the snapshot says (not a later process given the snapshot's pid). Without a snapshot it
|
|
733
|
+
* ends the broker alone. It waits up to `waitMs` for the broker to exit. A process it may not open, or one created at
|
|
734
|
+
* another time, is left alone.
|
|
693
735
|
*/
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
736
|
+
function stopAnnouncedBrokerScript(pid: number, started: string, waitMs: number): string {
|
|
737
|
+
return `$ErrorActionPreference = 'Stop'
|
|
738
|
+
function Hold([int]$id) {
|
|
739
|
+
try { $p = [System.Diagnostics.Process]::GetProcessById($id); $null = $p.Handle; $p } catch { $null }
|
|
740
|
+
}
|
|
741
|
+
function Created($p) {
|
|
742
|
+
try { $p.StartTime.ToFileTimeUtc() } catch { $null }
|
|
743
|
+
}
|
|
744
|
+
function Micros([datetime]$time) { $time.ToUniversalTime().ToString('yyyyMMddHHmmssffffff') }
|
|
745
|
+
$broker = Hold ${pid}
|
|
746
|
+
if ($null -eq $broker) { exit 3 }
|
|
747
|
+
$brokerCreated = Created $broker
|
|
748
|
+
if ($null -eq $brokerCreated -or $brokerCreated -ne [long]'${started}') { exit 3 }
|
|
749
|
+
$held = New-Object System.Collections.ArrayList
|
|
750
|
+
[void]$held.Add($broker)
|
|
751
|
+
$ids = New-Object 'System.Collections.Generic.HashSet[int]'
|
|
752
|
+
[void]$ids.Add($broker.Id)
|
|
753
|
+
$snapshot = @()
|
|
754
|
+
try { $snapshot = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId, ParentProcessId, CreationDate) } catch { }
|
|
755
|
+
$level = @(, @($broker, $brokerCreated))
|
|
756
|
+
while ($level.Count -gt 0) {
|
|
757
|
+
$next = @()
|
|
758
|
+
foreach ($parent in $level) {
|
|
759
|
+
foreach ($entry in $snapshot) {
|
|
760
|
+
if ($entry.ParentProcessId -ne $parent[0].Id -or $ids.Contains([int]$entry.ProcessId) -or $null -eq $entry.CreationDate) { continue }
|
|
761
|
+
$child = Hold $entry.ProcessId
|
|
762
|
+
if ($null -eq $child) { continue }
|
|
763
|
+
$created = Created $child
|
|
764
|
+
if ($null -eq $created -or $created -lt $parent[1]) { continue }
|
|
765
|
+
if ((Micros $child.StartTime) -ne (Micros $entry.CreationDate)) { continue }
|
|
766
|
+
[void]$held.Add($child)
|
|
767
|
+
[void]$ids.Add($child.Id)
|
|
768
|
+
$next += , @($child, $created)
|
|
769
|
+
}
|
|
704
770
|
}
|
|
771
|
+
$level = $next
|
|
772
|
+
}
|
|
773
|
+
foreach ($p in $held) { try { $p.Kill() } catch { } }
|
|
774
|
+
if ($broker.WaitForExit(${waitMs})) { exit 0 } else { exit 4 }
|
|
775
|
+
`;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Stop the Windows broker found by its announcement, as {@link stopAnnouncedBrokerScript} does. A pid that already names
|
|
780
|
+
* another process is left alone without starting PowerShell. The session waits at most
|
|
781
|
+
* {@link ANNOUNCED_BROKER_STOP_START_MS} for the check and PowerShell's start, {@link STARTING_BROKER_KILL_WAIT_MS} for
|
|
782
|
+
* the broker to exit, and {@link ANNOUNCED_BROKER_STOP_MARGIN_MS}. It never ends the PowerShell: once the session stops
|
|
783
|
+
* waiting, the PowerShell finishes on its own, or ends with this process, which can only leave processes running.
|
|
784
|
+
*/
|
|
785
|
+
async function stopAnnouncedBroker(pid: number, started: string): Promise<void> {
|
|
786
|
+
const entered = performance.now();
|
|
787
|
+
const bound = ANNOUNCED_BROKER_STOP_START_MS + STARTING_BROKER_KILL_WAIT_MS + ANNOUNCED_BROKER_STOP_MARGIN_MS;
|
|
788
|
+
if ((await readProcessCreationTime(pid)) !== started) return;
|
|
789
|
+
if (performance.now() - entered >= ANNOUNCED_BROKER_STOP_START_MS) return;
|
|
790
|
+
const systemRoot = process.env.SystemRoot || process.env.windir || "C:\\Windows";
|
|
791
|
+
await new Promise<void>((resolve) => {
|
|
792
|
+
const powershell = spawn(
|
|
793
|
+
join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
794
|
+
[
|
|
795
|
+
"-NoProfile",
|
|
796
|
+
"-NonInteractive",
|
|
797
|
+
"-EncodedCommand",
|
|
798
|
+
Buffer.from(stopAnnouncedBrokerScript(pid, started, STARTING_BROKER_KILL_WAIT_MS), "utf16le").toString("base64"),
|
|
799
|
+
],
|
|
800
|
+
{ cwd: systemRoot, env: hostCommandEnvironment(), stdio: "ignore", windowsHide: true },
|
|
801
|
+
);
|
|
802
|
+
powershell.unref();
|
|
803
|
+
const done = () => {
|
|
804
|
+
clearTimeout(timer);
|
|
805
|
+
resolve();
|
|
806
|
+
};
|
|
807
|
+
const timer = setTimeout(done, bound - (performance.now() - entered));
|
|
808
|
+
powershell.once("error", done);
|
|
809
|
+
powershell.once("exit", done);
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Kill a broker that has not started listening, with every process it started, and wait until they are gone.
|
|
815
|
+
*
|
|
816
|
+
* #6133: on Windows the broker is found by the pid it announced, which Windows gives to another process within seconds
|
|
817
|
+
* once the broker has exited. It is stopped only through a handle to the process whose creation time is the one it
|
|
818
|
+
* announced ({@link stopAnnouncedBroker}), never by its pid alone; a pid that names another process, or a process this
|
|
819
|
+
* one may not open, counts as a broker that has already exited.
|
|
820
|
+
*/
|
|
821
|
+
async function stopStartingBroker(broker: StartingBroker): Promise<void> {
|
|
822
|
+
if (broker.kind === "announced") return stopAnnouncedBroker(broker.pid, broker.started);
|
|
823
|
+
const deadline = Date.now() + STARTING_BROKER_KILL_WAIT_MS;
|
|
705
824
|
try {
|
|
706
|
-
process.kill(-pid, "SIGKILL");
|
|
825
|
+
process.kill(-broker.pid, "SIGKILL");
|
|
707
826
|
} catch {
|
|
708
827
|
return;
|
|
709
828
|
}
|
|
710
|
-
while (isProcessAlive(-pid) && Date.now() < deadline) await sleep(STARTING_BROKER_KILL_POLL_MS);
|
|
829
|
+
while (isProcessAlive(-broker.pid) && Date.now() < deadline) await sleep(STARTING_BROKER_KILL_POLL_MS);
|
|
711
830
|
}
|
|
712
831
|
|
|
713
832
|
/** How often a session waiting to upgrade the broker checks whether the spawn lock is free. */
|
|
@@ -9,6 +9,39 @@ function isDuplicateColumn(error: unknown): boolean {
|
|
|
9
9
|
return /duplicate column|column .* already exists/i.test(text);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* A statement the database refused for a privilege the role lacks: the PostgreSQL adapter's `missing-privilege`, which
|
|
14
|
+
* the database facade reports as the cause of its `StorageUnavailableError`.
|
|
15
|
+
*/
|
|
16
|
+
function isMissingPrivilege(error: unknown): boolean {
|
|
17
|
+
let at = error;
|
|
18
|
+
for (let depth = 0; depth < 4 && typeof at === "object" && at !== null; depth++) {
|
|
19
|
+
if ((at as { reason?: unknown }).reason === "missing-privilege") return true;
|
|
20
|
+
at = (at as { cause?: unknown }).cause;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `addMissingColumns` for one column a store can do without: whether the column is there. A role that may not change
|
|
27
|
+
* tables (a PostgreSQL runtime role with only DML privileges) leaves it out, and the store works as before it existed
|
|
28
|
+
* until `atomic storage migrate`, run as the owner role, adds it. Any other failure is thrown.
|
|
29
|
+
*/
|
|
30
|
+
export async function addOptionalColumn(
|
|
31
|
+
database: SqliteDatabase,
|
|
32
|
+
table: string,
|
|
33
|
+
column: string,
|
|
34
|
+
definition: string,
|
|
35
|
+
): Promise<boolean> {
|
|
36
|
+
try {
|
|
37
|
+
await addMissingColumns(database, table, { [column]: definition });
|
|
38
|
+
return true;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (isMissingPrivilege(error)) return false;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
12
45
|
/**
|
|
13
46
|
* Adds each missing column of `columns` (name → definition after the name) to `table`, in order. A table from an older
|
|
14
47
|
* broker gets the columns, and an older broker ignores them. Each column is probed and added in a serial transaction,
|