@bastani/atomic 0.9.89-alpha.2 → 0.9.90-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 +357 -0
- package/dist/builtin/intercom/CHANGELOG.md +36 -0
- package/dist/builtin/intercom/README.md +3 -1
- package/dist/builtin/intercom/broker/broker.ts +35 -10
- package/dist/builtin/intercom/broker/client.ts +42 -1
- package/dist/builtin/intercom/index.bundle.mjs +400 -67
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/skills/intercom/SKILL.md +24 -5
- package/dist/builtin/intercom/types.ts +5 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +66 -0
- package/dist/builtin/subagents/README.md +18 -20
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/feedback/SKILL.md +2 -2
- package/dist/builtin/subagents/skills/qlty/SKILL.md +2 -2
- package/dist/builtin/subagents/skills/qlty/references/commands.md +45 -12
- package/dist/builtin/subagents/skills/qlty/references/quickstart.md +102 -21
- package/dist/builtin/subagents/skills/subagent/SKILL.md +18 -17
- package/dist/builtin/subagents/skills/tdd/LICENSE.txt +50 -0
- package/dist/builtin/subagents/skills/tdd/SKILL.md +10 -0
- package/dist/builtin/subagents/skills/tdd/tests.md +16 -0
- package/dist/builtin/subagents/skills/tmux/LICENSE.txt +24 -0
- package/dist/builtin/subagents/skills/tmux/SKILL.md +20 -1
- package/dist/builtin/subagents/skills/tmux/scripts/find-sessions.sh +19 -10
- package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +231 -19
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1911 -845
- package/dist/builtin/web-access/CHANGELOG.md +17 -0
- package/dist/builtin/web-access/index.bundle.mjs +158 -34
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +130 -0
- package/dist/builtin/workflows/builtin/{chunk-tjk7jp9a.js → chunk-akmcsx14.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-913nwrzq.js → chunk-erpybg3c.js} +109 -30
- package/dist/builtin/workflows/builtin/{chunk-e07n7en6.js → chunk-wpgpr31s.js} +1 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/bro/SKILL.md +1 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +19 -19
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_2.md +3 -2
- package/dist/builtin/workflows/skills/show-me/SKILL.md +2 -2
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +29 -24
- package/dist/builtin/workflows/skills/teach/SKILL.md +8 -8
- package/dist/builtin/workflows/skills/unslop/SKILL.md +29 -51
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +10 -5
- package/dist/builtin/workflows/src/durable/journal/sharded-run-journal.d.ts +6 -3
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +25 -3
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +4444 -1356
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +2544 -568
- package/dist/builtin/workflows/src/index.js +2467 -549
- package/dist/builtin/workflows/src/local-worker-entry.mjs +2544 -568
- package/dist/cli/storage-command.d.ts +6 -0
- package/dist/cli/storage-command.d.ts.map +1 -1
- package/dist/cli/storage-command.js +11 -0
- package/dist/cli/storage-command.js.map +1 -1
- package/dist/cli/storage-search-database.d.ts +18 -0
- package/dist/cli/storage-search-database.d.ts.map +1 -0
- package/dist/cli/storage-search-database.js +90 -0
- package/dist/cli/storage-search-database.js.map +1 -0
- package/dist/cli/storage-search-session.d.ts +5 -0
- package/dist/cli/storage-search-session.d.ts.map +1 -0
- package/dist/cli/storage-search-session.js +133 -0
- package/dist/cli/storage-search-session.js.map +1 -0
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +107 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +2 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +9 -4
- package/dist/core/agent-session-boundaries.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 +2 -1
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-detached-tools.d.ts +3 -2
- package/dist/core/agent-session-detached-tools.d.ts.map +1 -1
- package/dist/core/agent-session-detached-tools.js +156 -41
- package/dist/core/agent-session-detached-tools.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +2 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +59 -23
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +53 -4
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +2 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +23 -3
- 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-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +2 -0
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +14 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts +2 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +8 -4
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +7 -3
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +113 -112
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +15 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +26 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -2
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +6 -6
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +4 -2
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +19 -1
- 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 +11 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +8 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +16 -1
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +124 -7
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/auth-storage.d.ts +3 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +10 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/detached-tool-output.d.ts +4 -0
- package/dist/core/detached-tool-output.d.ts.map +1 -0
- package/dist/core/detached-tool-output.js +48 -0
- package/dist/core/detached-tool-output.js.map +1 -0
- package/dist/core/event-loop-monitor.d.ts +4 -1
- package/dist/core/event-loop-monitor.d.ts.map +1 -1
- package/dist/core/event-loop-monitor.js +84 -159
- package/dist/core/event-loop-monitor.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +26 -4
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/saved-agent-cards.d.ts +15 -0
- package/dist/core/export-html/saved-agent-cards.d.ts.map +1 -0
- package/dist/core/export-html/saved-agent-cards.js +255 -0
- package/dist/core/export-html/saved-agent-cards.js.map +1 -0
- package/dist/core/export-html/saved-agent-viewer.js +101 -0
- package/dist/core/extensions/builtin-subagent-record-writer.d.ts +11 -0
- package/dist/core/extensions/builtin-subagent-record-writer.d.ts.map +1 -0
- package/dist/core/extensions/builtin-subagent-record-writer.js +33 -0
- package/dist/core/extensions/builtin-subagent-record-writer.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +9 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.d.ts +7 -0
- package/dist/core/extensions/loader-bindings.d.ts.map +1 -1
- package/dist/core/extensions/loader-bindings.js +42 -1
- package/dist/core/extensions/loader-bindings.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +33 -12
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +2 -0
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +17 -7
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +4 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.d.ts +2 -2
- package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.js +2 -2
- package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +10 -3
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/first-prompt-model.d.ts +22 -0
- package/dist/core/first-prompt-model.d.ts.map +1 -0
- package/dist/core/first-prompt-model.js +84 -0
- package/dist/core/first-prompt-model.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +11 -7
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/fork-replay-pair.d.ts +22 -0
- package/dist/core/fork-replay-pair.d.ts.map +1 -0
- package/dist/core/fork-replay-pair.js +174 -0
- package/dist/core/fork-replay-pair.js.map +1 -0
- package/dist/core/fork-replay-wire.d.ts +11 -0
- package/dist/core/fork-replay-wire.d.ts.map +1 -0
- package/dist/core/fork-replay-wire.js +116 -0
- package/dist/core/fork-replay-wire.js.map +1 -0
- package/dist/core/messages.d.ts +2 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +8 -4
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-runtime.d.ts +10 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +76 -11
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +3 -2
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-resource-files.js +7 -8
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/project-trust-state.d.ts +90 -0
- package/dist/core/project-trust-state.d.ts.map +1 -0
- package/dist/core/project-trust-state.js +65 -0
- package/dist/core/project-trust-state.js.map +1 -0
- package/dist/core/provider-rate-limits.d.ts +6 -0
- package/dist/core/provider-rate-limits.d.ts.map +1 -1
- package/dist/core/provider-rate-limits.js +43 -0
- package/dist/core/provider-rate-limits.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +10 -1
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +6 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +22 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +5 -2
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +3 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts +2 -2
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +6 -4
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-package-resources.d.ts +1 -0
- package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
- package/dist/core/resource-loader-package-resources.js +2 -1
- package/dist/core/resource-loader-package-resources.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +3 -2
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +2 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/resume/blueprint/actions.d.ts.map +1 -1
- package/dist/core/resume/blueprint/actions.js +15 -15
- package/dist/core/resume/blueprint/actions.js.map +1 -1
- package/dist/core/resume/blueprint/process.d.ts +6 -1
- package/dist/core/resume/blueprint/process.d.ts.map +1 -1
- package/dist/core/resume/blueprint/process.js +132 -21
- package/dist/core/resume/blueprint/process.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +34 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +187 -32
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-account-model.d.ts +15 -0
- package/dist/core/session-account-model.d.ts.map +1 -0
- package/dist/core/session-account-model.js +105 -0
- package/dist/core/session-account-model.js.map +1 -0
- package/dist/core/session-lifecycle-scope.d.ts +5 -0
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
- package/dist/core/session-lifecycle-scope.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +21 -2
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +64 -8
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +3 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +19 -5
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +2 -0
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-retry-status.d.ts +22 -0
- package/dist/core/session-retry-status.d.ts.map +1 -0
- package/dist/core/session-retry-status.js +25 -0
- package/dist/core/session-retry-status.js.map +1 -0
- package/dist/core/session-worktree-snapshots.d.ts +4 -2
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +8 -4
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +4 -0
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +73 -1
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-schema.js +1 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -2
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +15 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/storage/database.d.ts +14 -2
- package/dist/core/storage/database.d.ts.map +1 -1
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +13 -0
- package/dist/core/storage/dialect.d.ts.map +1 -1
- package/dist/core/storage/dialect.js +9 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +23 -1
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js +28 -5
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/journal-transfer.d.ts.map +1 -1
- package/dist/core/storage/journal-transfer.js +90 -5
- package/dist/core/storage/journal-transfer.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +61 -1
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/chunked-resume-projection.d.ts +4 -0
- package/dist/core/storage/session/chunked-resume-projection.d.ts.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.js +369 -0
- package/dist/core/storage/session/chunked-resume-projection.js.map +1 -0
- package/dist/core/storage/session/legacy-session-store.d.ts +5 -0
- package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/legacy-session-store.js +10 -2
- package/dist/core/storage/session/legacy-session-store.js.map +1 -1
- package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/memory-session-store.js +6 -1
- package/dist/core/storage/session/memory-session-store.js.map +1 -1
- package/dist/core/storage/session/snapshot-generation.d.ts +8 -0
- package/dist/core/storage/session/snapshot-generation.d.ts.map +1 -0
- package/dist/core/storage/session/snapshot-generation.js +17 -0
- package/dist/core/storage/session/snapshot-generation.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.d.ts +12 -0
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +243 -46
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/storage/sqlite-facade.d.ts +17 -2
- package/dist/core/storage/sqlite-facade.d.ts.map +1 -1
- package/dist/core/storage/sqlite-facade.js +17 -1
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts +13 -2
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
- package/dist/core/tasks/agent-adapter.js +25 -8
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/agent-panel-rules.d.ts +77 -0
- package/dist/core/tasks/agent-panel-rules.d.ts.map +1 -0
- package/dist/core/tasks/agent-panel-rules.js +88 -0
- package/dist/core/tasks/agent-panel-rules.js.map +1 -0
- package/dist/core/tasks/agent-panel-source.d.ts +19 -0
- package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
- package/dist/core/tasks/agent-panel-source.js +50 -9
- package/dist/core/tasks/agent-panel-source.js.map +1 -1
- package/dist/core/tasks/command-output.d.ts +17 -2
- package/dist/core/tasks/command-output.d.ts.map +1 -1
- package/dist/core/tasks/command-output.js +59 -3
- package/dist/core/tasks/command-output.js.map +1 -1
- package/dist/core/tasks/completion-message.d.ts +8 -3
- package/dist/core/tasks/completion-message.d.ts.map +1 -1
- package/dist/core/tasks/completion-message.js +14 -10
- package/dist/core/tasks/completion-message.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +14 -4
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +58 -17
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/contracts.d.ts +10 -1
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js +3 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/heartbeat.js +2 -1
- package/dist/core/tasks/heartbeat.js.map +1 -1
- package/dist/core/tasks/live-elapsed.d.ts +16 -1
- package/dist/core/tasks/live-elapsed.d.ts.map +1 -1
- package/dist/core/tasks/live-elapsed.js +43 -4
- package/dist/core/tasks/live-elapsed.js.map +1 -1
- package/dist/core/tasks/owner-store.d.ts +8 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -1
- package/dist/core/tasks/owner-store.js +34 -4
- package/dist/core/tasks/owner-store.js.map +1 -1
- package/dist/core/tasks/session-scope.d.ts +7 -0
- package/dist/core/tasks/session-scope.d.ts.map +1 -1
- package/dist/core/tasks/session-scope.js +15 -9
- package/dist/core/tasks/session-scope.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +7 -3
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +92 -17
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tasks/task-archive-snapshot.d.ts +7 -0
- package/dist/core/tasks/task-archive-snapshot.d.ts.map +1 -0
- package/dist/core/tasks/task-archive-snapshot.js +33 -0
- package/dist/core/tasks/task-archive-snapshot.js.map +1 -0
- package/dist/core/tasks/task-resumer.d.ts +5 -3
- package/dist/core/tasks/task-resumer.d.ts.map +1 -1
- package/dist/core/tasks/task-resumer.js +37 -13
- package/dist/core/tasks/task-resumer.js.map +1 -1
- package/dist/core/tasks/task-view-source.d.ts +25 -3
- package/dist/core/tasks/task-view-source.d.ts.map +1 -1
- package/dist/core/tasks/task-view-source.js +144 -44
- package/dist/core/tasks/task-view-source.js.map +1 -1
- package/dist/core/tasks/transcript.d.ts +3 -1
- package/dist/core/tasks/transcript.d.ts.map +1 -1
- package/dist/core/tasks/transcript.js +27 -0
- package/dist/core/tasks/transcript.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js +2 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.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-protocol.d.ts.map +1 -1
- package/dist/core/tools/history-protocol.js +130 -29
- package/dist/core/tools/history-protocol.js.map +1 -1
- package/dist/core/tools/history-search-position.d.ts +30 -0
- package/dist/core/tools/history-search-position.d.ts.map +1 -0
- package/dist/core/tools/history-search-position.js +161 -0
- package/dist/core/tools/history-search-position.js.map +1 -0
- package/dist/core/tools/history-search-wire.d.ts +25 -0
- package/dist/core/tools/history-search-wire.d.ts.map +1 -0
- package/dist/core/tools/history-search-wire.js +210 -0
- package/dist/core/tools/history-search-wire.js.map +1 -0
- package/dist/core/tools/resource-selectors.d.ts +7 -1
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.js +18 -11
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/search.js +24 -3
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.d.ts +3 -0
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +4 -0
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/tools/tool-abort-grace.d.ts +13 -0
- package/dist/core/tools/tool-abort-grace.d.ts.map +1 -0
- package/dist/core/tools/tool-abort-grace.js +72 -0
- package/dist/core/tools/tool-abort-grace.js.map +1 -0
- package/dist/core/tools/tool-concurrency.d.ts +5 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +36 -6
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/core/workflow-resume.d.ts +1 -1
- package/dist/core/workflow-resume.d.ts.map +1 -1
- package/dist/core/workflow-resume.js +13 -3
- package/dist/core/workflow-resume.js.map +1 -1
- package/dist/core/workflow-summary-lifecycle.d.ts.map +1 -1
- package/dist/core/workflow-summary-lifecycle.js +8 -2
- package/dist/core/workflow-summary-lifecycle.js.map +1 -1
- package/dist/core/workspace/errors.d.ts +5 -2
- package/dist/core/workspace/errors.d.ts.map +1 -1
- package/dist/core/workspace/errors.js +59 -5
- package/dist/core/workspace/errors.js.map +1 -1
- package/dist/core/worktree-snapshot/blob-store.d.ts +138 -17
- package/dist/core/worktree-snapshot/blob-store.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/blob-store.js +788 -82
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/garbage.d.ts +17 -2
- package/dist/core/worktree-snapshot/garbage.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/garbage.js +20 -4
- package/dist/core/worktree-snapshot/garbage.js.map +1 -1
- package/dist/core/worktree-snapshot/index.d.ts +1 -1
- package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/index.js +1 -1
- package/dist/core/worktree-snapshot/index.js.map +1 -1
- package/dist/core/worktree-snapshot/pool.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/pool.js +38 -6
- package/dist/core/worktree-snapshot/pool.js.map +1 -1
- package/dist/core/worktree-snapshot/shared-clock.d.ts +3 -1
- package/dist/core/worktree-snapshot/shared-clock.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/shared-clock.js +116 -26
- package/dist/core/worktree-snapshot/shared-clock.js.map +1 -1
- package/dist/core/worktree-snapshot/types.d.ts +4 -1
- package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/types.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +2 -2
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/index.d.ts +2 -0
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +19 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +74 -15
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +22 -6
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +80 -23
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +11 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js +10 -3
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +3 -2
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +7 -7
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +6 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -7
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +24 -3
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +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 +16 -10
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +10 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +76 -31
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +17 -5
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +79 -24
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +5 -4
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +16 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +22 -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 +8 -2
- 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/chat-session-host-utils.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js +2 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +35 -9
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +129 -35
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +13 -2
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +24 -4
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +6 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +12 -7
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/composer-rule.d.ts +0 -2
- package/dist/modes/interactive/components/composer-rule.d.ts.map +1 -1
- package/dist/modes/interactive/components/composer-rule.js +4 -6
- package/dist/modes/interactive/components/composer-rule.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +5 -9
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +32 -23
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -3
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +6 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +15 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +7 -3
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +17 -15
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +10 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +37 -45
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/heartbeat-block.d.ts.map +1 -1
- package/dist/modes/interactive/components/heartbeat-block.js +3 -1
- package/dist/modes/interactive/components/heartbeat-block.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -1
- package/dist/modes/interactive/components/host-input-form.js +3 -3
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/input-label.d.ts.map +1 -1
- package/dist/modes/interactive/components/input-label.js +4 -5
- package/dist/modes/interactive/components/input-label.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +27 -6
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.d.ts +17 -2
- package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.js +44 -27
- package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +6 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +13 -7
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/nav-keys.d.ts +7 -2
- package/dist/modes/interactive/components/nav-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/nav-keys.js +51 -17
- package/dist/modes/interactive/components/nav-keys.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +8 -0
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +6 -1
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/selector.d.ts +3 -0
- package/dist/modes/interactive/components/selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/selector.js +30 -7
- package/dist/modes/interactive/components/selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +11 -11
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-picker.d.ts +5 -0
- package/dist/modes/interactive/components/settings-picker.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-picker.js +36 -2
- package/dist/modes/interactive/components/settings-picker.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +10 -0
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +89 -19
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +12 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +6 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +12 -7
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +9 -2
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts +10 -3
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.js +173 -19
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +28 -19
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.d.ts +7 -3
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-list.js +60 -33
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts +7 -0
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +25 -11
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-notices.d.ts +16 -0
- package/dist/modes/interactive/components/task-transcript-notices.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-transcript-notices.js +74 -0
- package/dist/modes/interactive/components/task-transcript-notices.js.map +1 -0
- package/dist/modes/interactive/components/task-transcript-page.d.ts +11 -6
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +48 -21
- 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 +2 -1
- package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -2
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +23 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/transcript-block-clicks.d.ts +54 -14
- package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
- package/dist/modes/interactive/components/transcript-block-clicks.js +151 -16
- package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js +25 -30
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts +4 -0
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js +21 -21
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts +31 -2
- package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.js +81 -10
- package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +67 -14
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +2 -2
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +10 -4
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +4 -1
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +13 -3
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +4 -2
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.js +6 -8
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +43 -3
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +9 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +9 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +10 -2
- 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-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +63 -21
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +71 -10
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +9 -18
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +106 -57
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +10 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts +3 -0
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +11 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +3 -0
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.d.ts +5 -1
- package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.js +8 -3
- package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
- package/dist/modes/interactive/interactive-startup-trust.d.ts +2 -0
- package/dist/modes/interactive/interactive-startup-trust.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup-trust.js +21 -0
- package/dist/modes/interactive/interactive-startup-trust.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +39 -17
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-task-projection.js +11 -1
- package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
- package/dist/modes/interactive/resume-catalog.d.ts.map +1 -1
- package/dist/modes/interactive/resume-catalog.js +1 -0
- package/dist/modes/interactive/resume-catalog.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +6 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +19 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-child-liveness.js +2 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +54 -4
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +21 -2
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +4 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +4 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +39 -3
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +219 -29
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +33 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +40 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +2 -2
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.js +7 -3
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +31 -5
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.d.ts +20 -12
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js +100 -34
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +4 -1
- 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 +119 -114
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +2 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +8 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +5 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +19 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +7 -0
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +3 -0
- package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.js +25 -0
- package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
- package/dist/utils/interactive-engine-env.d.ts +3 -0
- package/dist/utils/interactive-engine-env.d.ts.map +1 -1
- package/dist/utils/interactive-engine-env.js +1 -0
- package/dist/utils/interactive-engine-env.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +3 -3
- package/dist/utils/shell.js.map +1 -1
- package/docs/background-tasks.md +32 -37
- package/docs/compaction.md +2 -2
- package/docs/computer-use.md +2 -0
- package/docs/development.md +11 -1
- package/docs/environment-variables.md +2 -0
- package/docs/extensions/api-reference.md +7 -3
- package/docs/extensions/authoring.md +3 -1
- package/docs/extensions/events.md +3 -1
- package/docs/extensions/ui.md +2 -0
- package/docs/guides/resume-on-any-machine.md +3 -1
- package/docs/intercom/reference.md +1 -1
- package/docs/intercom.md +3 -3
- package/docs/keybindings.md +6 -2
- package/docs/libraries/tui.md +4 -0
- package/docs/providers.md +1 -1
- package/docs/rpc/protocol.md +6 -4
- package/docs/sdk/reference.md +10 -4
- package/docs/sdk.md +5 -2
- package/docs/security.md +5 -1
- package/docs/session-format.md +1 -1
- package/docs/sessions.md +16 -0
- package/docs/settings.md +2 -2
- package/docs/skills.md +3 -3
- package/docs/storage.md +25 -4
- package/docs/subagents.md +42 -45
- package/docs/tui.md +1 -1
- package/docs/usage.md +3 -1
- package/docs/workflows/api-reference.md +3 -1
- package/docs/workflows/authoring.md +1 -1
- package/docs/workflows/operations.md +21 -14
- package/docs/workflows.md +1 -1
- package/docs/worktree-snapshots.md +10 -8
- package/npm-shrinkwrap.json +71 -49
- package/package.json +9 -8
- package/schemas/settings.schema.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SqliteBatchOptions, SqliteDatabase, SqliteStatement, SqliteValue, StorageDescriptor, StorageNotifications, TransactionConcurrency } from "./database.js";
|
|
2
2
|
import { type StorageDialect } from "./dialect.js";
|
|
3
|
-
import { type StorageFailureCause, type StoragePayloadLimits, type StorageTransientErrorCode, type StorageTransientOutcome } from "./errors.js";
|
|
3
|
+
import { type StorageFailureCause, type StoragePayloadLimits, type StorageTransientErrorCode, type StorageTransientHop, type StorageTransientOutcome } from "./errors.js";
|
|
4
4
|
type Awaitable<T> = T | Promise<T>;
|
|
5
5
|
/** A value as a driver returns it. Blobs may be any binary view; the facade returns them as `Uint8Array` copies. */
|
|
6
6
|
export type SqliteDriverValue = SqliteValue | ArrayBuffer | ArrayBufferView;
|
|
@@ -31,9 +31,17 @@ export interface SqliteDriverTransientFailure {
|
|
|
31
31
|
* after the server may have applied it.
|
|
32
32
|
*/
|
|
33
33
|
readonly outcome: StorageTransientOutcome;
|
|
34
|
+
/**
|
|
35
|
+
* Optional. Where on the way to the server the call failed, when it did not reach the server, such as at a proxy:
|
|
36
|
+
* `StorageTransientError` then names this hop where it would name the database server. The facade passes both texts
|
|
37
|
+
* through `redact`.
|
|
38
|
+
*/
|
|
39
|
+
readonly hop?: StorageTransientHop;
|
|
34
40
|
}
|
|
35
41
|
/** How the facade asks a driver to begin a transaction. */
|
|
36
42
|
export interface SqliteDriverTransactionOptions {
|
|
43
|
+
/** @internal A consistent read snapshot without acquiring the database's writer lock. */
|
|
44
|
+
readonly readOnly?: boolean;
|
|
37
45
|
/** Always present when the facade calls; `{ kind: "serial" }` unless the transaction asked for another. */
|
|
38
46
|
readonly concurrency: TransactionConcurrency;
|
|
39
47
|
/** The transaction's `SqliteTransactionOptions.lockWaitMs`, when it set one. */
|
|
@@ -60,7 +68,8 @@ export interface SqliteDriver extends SqliteDriverExecutor {
|
|
|
60
68
|
/**
|
|
61
69
|
* Begins a write transaction. With `options.concurrency` `{ kind: "serial" }` (the default) it holds the write lock of the whole database
|
|
62
70
|
* or of `concurrency.domain`, like `BEGIN IMMEDIATE`; with `fenced` it may take no lock, and the body locks its rows.
|
|
63
|
-
* A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the argument.
|
|
71
|
+
* A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the concurrency argument. An internal `readOnly`
|
|
72
|
+
* request instead opens a consistent read snapshot without any writer lock.
|
|
64
73
|
*/
|
|
65
74
|
beginTransaction(options?: SqliteDriverTransactionOptions): Awaitable<SqliteDriverTransaction>;
|
|
66
75
|
/**
|
|
@@ -94,6 +103,12 @@ export interface SqliteDriver extends SqliteDriverExecutor {
|
|
|
94
103
|
* `close` stops its listening connection.
|
|
95
104
|
*/
|
|
96
105
|
readonly notifications?: StorageNotifications;
|
|
106
|
+
/**
|
|
107
|
+
* Optional. The bytes this process may still write on the file system that holds the database's file, or undefined
|
|
108
|
+
* when the file system does not say; the facade exposes it as `SqliteDatabase.freeBytes`. Provide it only for a
|
|
109
|
+
* database in a file this process can see, such as a local SQLite or libSQL file.
|
|
110
|
+
*/
|
|
111
|
+
freeBytes?(): Awaitable<number | undefined>;
|
|
97
112
|
}
|
|
98
113
|
/**
|
|
99
114
|
* How many times the facade runs a call that a transient failure ended before it wrote anything, the first run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-facade.d.ts","sourceRoot":"","sources":["../../../src/core/storage/sqlite-facade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,cAAc,EAGd,eAAe,EAEf,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,cAAc,CAAC;AAClE,OAAO,EAKN,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EAKzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAErB,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnC,oHAAoH;AACpH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,GAAG,eAAe,CAAC;AAE5E,6GAA6G;AAC7G,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACpF,4DAA4D;IAC5D,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACpE,MAAM,IAA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,MAAM,KAAK,MAAM,CAEjF;AAgjBD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAEzE"}
|
|
@@ -341,10 +341,14 @@ class DriverDatabase {
|
|
|
341
341
|
executor;
|
|
342
342
|
batch;
|
|
343
343
|
notifications;
|
|
344
|
+
freeBytes;
|
|
344
345
|
constructor(driver, redact) {
|
|
345
346
|
this.driver = driver;
|
|
346
347
|
if (driver.notifications !== undefined)
|
|
347
348
|
this.notifications = driver.notifications;
|
|
349
|
+
const freeBytes = driver.freeBytes?.bind(driver);
|
|
350
|
+
if (freeBytes)
|
|
351
|
+
this.freeBytes = async () => freeBytes();
|
|
348
352
|
this.redact = redact;
|
|
349
353
|
this.descriptor = { adapter: driver.descriptor.adapter, location: redact(driver.descriptor.location) };
|
|
350
354
|
this.dialect = driver.dialect ?? sqliteDialect;
|
|
@@ -467,6 +471,14 @@ class DriverDatabase {
|
|
|
467
471
|
code: transient.code,
|
|
468
472
|
outcome: applies ? transient.outcome : "not-applied",
|
|
469
473
|
attempts: attempt.number,
|
|
474
|
+
...(transient.hop === undefined
|
|
475
|
+
? {}
|
|
476
|
+
: {
|
|
477
|
+
hop: {
|
|
478
|
+
name: this.redact(transient.hop.name),
|
|
479
|
+
failure: this.redact(transient.hop.failure),
|
|
480
|
+
},
|
|
481
|
+
}),
|
|
470
482
|
}, safe);
|
|
471
483
|
attempt.transient ??= failure;
|
|
472
484
|
throw failure;
|
|
@@ -523,7 +535,11 @@ class DriverDatabase {
|
|
|
523
535
|
catch (error) {
|
|
524
536
|
return Promise.reject(error);
|
|
525
537
|
}
|
|
526
|
-
const begin =
|
|
538
|
+
const begin = {
|
|
539
|
+
concurrency,
|
|
540
|
+
...(options?.lockWaitMs === undefined ? {} : { lockWaitMs: options.lockWaitMs }),
|
|
541
|
+
...(options?.readOnly === true ? { readOnly: true } : {}),
|
|
542
|
+
};
|
|
527
543
|
const run = () => this.retrying((attempt) => this.runTransaction(callback, attempt, begin), replay);
|
|
528
544
|
if (concurrency.kind === "serial" || this.driver.concurrentTransactions !== true)
|
|
529
545
|
return this.queue.push(run);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-facade.js","sourceRoot":"","sources":["../../../src/core/storage/sqlite-facade.ts"],"names":[],"mappings":"AAYA,OAAO,EAAuB,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EAEZ,uBAAuB,EAEvB,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EAGrB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,aAAa,CAAC;AA2GrB;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAClD,2GAA2G;AAC3G,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAClD,mHAAmH;AACnH,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,uHAAuH;AACvH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,sCAAsC;AACtC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD,wGAAwG;AACxG,SAAS,qBAAqB,CAAC,OAAe;IAC7C,MAAM,MAAM,GAAG,CAAC,GAAG,8BAA8B,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,KAAK,CAAC,qCAAqC,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AACxF,CAAC;AAQD,MAAM,QAAQ,GAAG,YAAY,CAAC;AAQ9B;;;GAGG;AACH,MAAM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O,EAAE,aAAoC,CAAC,CAAC;YACnF,CAAC;YACD,oEAAoE;YACpE,MAAM,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC9B,MAAM,OAAO,CAAC;QACf,CAAC;QACD,MAAM,KAAK,EAAE,CAAC;QACd,OAAO,MAAM,CAAC;IACf,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACvF,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CACpC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACxD,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type {\n\tSqliteBatchOptions,\n\tSqliteDatabase,\n\tSqliteExecutor,\n\tSqliteRow,\n\tSqliteStatement,\n\tSqliteTransactionOptions,\n\tSqliteValue,\n\tStorageDescriptor,\n\tStorageNotifications,\n\tTransactionConcurrency,\n} from \"./database.js\";\nimport { type StorageDialect, sqliteDialect } from \"./dialect.js\";\nimport {\n\tlargestValueBytes,\n\tpayloadTooLargeKind,\n\tStorageConfigError,\n\tStorageError,\n\ttype StorageFailureCause,\n\tStorageInvalidTextError,\n\ttype StoragePayloadLimits,\n\tStoragePayloadTooLargeError,\n\tStorageRollbackError,\n\tStorageTransactionClosedError,\n\tStorageTransientError,\n\ttype StorageTransientErrorCode,\n\ttype StorageTransientOutcome,\n\tStorageUnavailableError,\n\tStoreClosedError,\n} from \"./errors.js\";\n\ntype Awaitable<T> = T | Promise<T>;\n\n/** A value as a driver returns it. Blobs may be any binary view; the facade returns them as `Uint8Array` copies. */\nexport type SqliteDriverValue = SqliteValue | ArrayBuffer | ArrayBufferView;\n\n/** One statement's result as a driver returns it: column names, positional rows, and the rows it changed. */\nexport interface SqliteDriverResult {\n\treadonly columns: readonly string[];\n\treadonly rows: readonly ArrayLike<SqliteDriverValue>[];\n\treadonly changes: number;\n}\n\n/** Runs SQL on a driver connection or on an open driver transaction. */\nexport interface SqliteDriverExecutor {\n\t/** Runs one statement with positional `?` parameters. */\n\texecute(sql: string, params: readonly SqliteValue[]): Awaitable<SqliteDriverResult>;\n\t/** Runs zero or more statements that take no parameters. */\n\texecuteMultiple(sql: string): Awaitable<void>;\n}\n\nexport interface SqliteDriverTransaction extends SqliteDriverExecutor {\n\tcommit(): Awaitable<void>;\n\trollback(): Awaitable<void>;\n\t/** Releases the transaction after it commits or rolls back. */\n\tclose?(): Awaitable<void>;\n}\n\n/** A driver failure that passes, as `SqliteDriver.transientFailure` recognizes it. */\nexport interface SqliteDriverTransientFailure {\n\treadonly code: StorageTransientErrorCode;\n\t/**\n\t * `\"not-applied\"` when the failed request cannot have changed the database, `\"unknown\"` when the connection broke\n\t * after the server may have applied it.\n\t */\n\treadonly outcome: StorageTransientOutcome;\n}\n\n/** How the facade asks a driver to begin a transaction. */\nexport interface SqliteDriverTransactionOptions {\n\t/** Always present when the facade calls; `{ kind: \"serial\" }` unless the transaction asked for another. */\n\treadonly concurrency: TransactionConcurrency;\n\t/** The transaction's `SqliteTransactionOptions.lockWaitMs`, when it set one. */\n\treadonly lockWaitMs?: number;\n}\n\n/** The driver calls `createSqliteDatabase` turns into a `SqliteDatabase`. */\nexport interface SqliteDriver extends SqliteDriverExecutor {\n\t/** Diagnostic identity. Its `location` passes through `redact` before the facade exposes it. */\n\treadonly descriptor: StorageDescriptor;\n\t/** The SQL dialect the driver speaks; SQLite when absent. The facade exposes it as `SqliteDatabase.dialect`. */\n\treadonly dialect?: StorageDialect;\n\t/**\n\t * Optional. The driver runs `fenced` transactions on connections of their own, concurrently with other calls: the\n\t * facade then starts them without waiting for queued calls. Otherwise every transaction waits its turn.\n\t */\n\treadonly concurrentTransactions?: boolean;\n\t/**\n\t * Optional. A transaction's connection takes a statement before the one before it is answered, and runs them in the\n\t * order it took them (a pipelined connection): the facade then sends each call of a transaction as it is made, so a\n\t * body that makes several calls without awaiting each sends them in one round trip. Otherwise each call waits for\n\t * the one before it to settle.\n\t */\n\treadonly pipelinedTransactions?: boolean;\n\t/**\n\t * Begins a write transaction. With `options.concurrency` `{ kind: \"serial\" }` (the default) it holds the write lock of the whole database\n\t * or of `concurrency.domain`, like `BEGIN IMMEDIATE`; with `fenced` it may take no lock, and the body locks its rows.\n\t * A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the argument.\n\t */\n\tbeginTransaction(options?: SqliteDriverTransactionOptions): Awaitable<SqliteDriverTransaction>;\n\t/**\n\t * Optional. Runs the statements in order in one write transaction, in one request: all commit or none do. Provide it\n\t * only when the driver sends the whole batch at once; the facade then offers `SqliteDatabase.batch`. `options` are the\n\t * caller's, as `SqliteDatabase.batch` took them.\n\t */\n\tbatch?(\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions?: SqliteBatchOptions,\n\t): Awaitable<readonly SqliteDriverResult[]>;\n\t/** Releases the connection. Called once, after accepted work drains. */\n\tclose(): Awaitable<void>;\n\t/** Removes credentials from diagnostic text: the descriptor location and driver failure messages and stacks. */\n\tredact?(text: string): string;\n\t/**\n\t * Optional. Recognizes a failed `batch` that found the database's write lock busy and wrote nothing: the facade sends\n\t * it again, after a randomized wait outside its call queue, for up to the caller's `lockWaitMs`. It receives the\n\t * failure the facade reports, whose `cause` chain holds the driver's own.\n\t */\n\tlockBusy?(failure: StorageFailureCause): boolean;\n\t/**\n\t * Optional. Recognizes a failure a driver call threw as one that passes, from the failure's own fields, before the\n\t * facade redacts it. The call then fails with `StorageTransientError`, and a call that wrote nothing runs again.\n\t */\n\ttransientFailure?(failure: StorageFailureCause): SqliteDriverTransientFailure | undefined;\n\t/**\n\t * Optional. The backend's payload limits in bytes, named in the `StoragePayloadTooLargeError` the facade throws when\n\t * a driver call fails because a value, row or response was too large for the backend (#4954).\n\t */\n\treadonly payloadLimits?: StoragePayloadLimits;\n\t/**\n\t * Optional. Wake-ups through the database, which the facade exposes as `SqliteDatabase.notifications`; the driver's\n\t * `close` stops its listening connection.\n\t */\n\treadonly notifications?: StorageNotifications;\n}\n\n/**\n * How many times the facade runs a call that a transient failure ended before it wrote anything, the first run\n * included. A transaction runs again only when its options allow it (`retryTransientFailures`).\n */\nexport const STORAGE_TRANSIENT_RETRY_ATTEMPTS = 5;\n/** The wait before the second run, in milliseconds; each later wait is twice as long as the one before. */\nconst STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS = 250;\n/** Each wait varies by up to this fraction either way, so processes that failed together do not retry together. */\nconst STORAGE_TRANSIENT_RETRY_JITTER = 0.2;\n/** The first bound on the wait before a batch that found the write lock busy is sent again; each later one doubles. */\nconst BUSY_RETRY_BASE_MS = 20;\n/** The largest bound on that wait. */\nconst BUSY_RETRY_MAX_MS = 1000;\n\n/**\n * How long the running call may run before the calls queued behind it fail without running (#5114). The facade\n * runs one call at a time, so a call that cannot complete, such as one waiting on a write lock a server keeps for a\n * stream an outage cut, would otherwise hold every call queued behind it, priority calls such as a worker host's\n * heartbeat included. A call queued behind it fails with `StorageUnavailableError` instead, having written nothing,\n * and its caller retries it as it retries any outage.\n */\nexport const STORAGE_QUEUED_CALL_MAX_WAIT_MS = 60_000;\n/**\n * The same bound for a priority call, such as a worker host's heartbeat or a work lease renewal: a third of the 30 s a\n * host's or a work lease's last write keeps it live (`FLEET_HOST_LIVE_MS`), so a priority call stuck behind a call that\n * cannot complete fails, and its caller tries it again, while the lease it renews still holds.\n */\nexport const STORAGE_PRIORITY_CALL_MAX_WAIT_MS = 10_000;\n\n/** How long the facade waits after the failed run `attempt` (1-based) before it runs the call again. */\nfunction transientRetryDelayMs(attempt: number): number {\n\tconst jitter = 1 + STORAGE_TRANSIENT_RETRY_JITTER * (2 * Math.random() - 1);\n\treturn Math.round(STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * jitter);\n}\n\n/** One run of a call: which run it is, and the first transient failure it met. */\ninterface Attempt {\n\treadonly number: number;\n\ttransient?: StorageTransientError;\n}\n\nconst REDACTED = \"[redacted]\";\n\n/** How {@link configuredSecretRedactor} matches the secrets it is given. */\nexport interface ConfiguredSecretRedactorOptions {\n\t/** Forms of a secret shorter than this are not redacted where they appear: they would match ordinary words. */\n\treadonly minLength?: number;\n}\n\n/**\n * Fewest characters of a form derived from a secret (a line of it, or an encoding) that is redacted, so short pieces\n * of a secret do not match ordinary text. A secret itself is redacted at any length its caller allows.\n */\nconst MIN_DERIVED_LENGTH = 6;\n/** Fewest base64 characters of a secret's encoding that are redacted, so short secrets do not match random base64. */\nconst MIN_BASE64_LENGTH = 7;\n\n/**\n * The base64 runs that appear wherever `secret`'s bytes are encoded, in standard and URL-safe alphabets: for each of\n * the three alignments of its first byte in a 3-byte group, the characters that only its bits decide.\n */\nfunction base64Forms(secret: string): string[] {\n\tconst bytes = Buffer.from(secret);\n\tconst forms: string[] = [];\n\tfor (let offset = 0; offset < 3; offset++) {\n\t\tconst encoded = Buffer.concat([Buffer.alloc(offset), bytes, Buffer.alloc(2)]).toString(\"base64\");\n\t\tconst form = encoded.slice(Math.ceil((8 * offset) / 6), Math.floor((8 * (offset + bytes.length)) / 6));\n\t\tif (form.length >= MIN_BASE64_LENGTH) forms.push(form, form.replaceAll(\"+\", \"-\").replaceAll(\"/\", \"_\"));\n\t}\n\treturn forms;\n}\n\n/** The JSON-escaped, URI-encoded, URI-decoded and base64 forms of `plain`. */\nfunction encodedForms(plain: string): string[] {\n\tconst forms = [JSON.stringify(plain).slice(1, -1), ...base64Forms(plain)];\n\ttry {\n\t\tforms.push(encodeURIComponent(plain));\n\t} catch {}\n\ttry {\n\t\tforms.push(decodeURIComponent(plain));\n\t} catch {}\n\treturn forms;\n}\n\n/** A line of a multi-line secret that many secrets share, such as a PEM armor line (`-----BEGIN … KEY-----`). */\nconst GENERIC_LINE = /^-----[A-Z0-9 ]+-----$|^[A-Za-z-]+: /u;\n\n/**\n * The forms a configured secret takes in output: trimmed, since a secret read from a file often ends with a line break\n * that the text around a printed secret need not repeat; each line of a multi-line secret, trimmed, that holds a letter\n * or digit and is not a line many secrets share (a PEM armor or header line); and the encodings of both. The secret as given holds its trimmed form, so overlapping matches still remove\n * it whole. Forms derived from the secret are kept only from {@link MIN_DERIVED_LENGTH} characters.\n */\nfunction secretForms(secret: string, minLength: number): string[] {\n\tconst trimmed = secret.trim();\n\tif (trimmed.length < Math.max(1, minLength)) return [];\n\tconst derivedLength = Math.max(minLength, MIN_DERIVED_LENGTH);\n\tconst lines = trimmed.includes(\"\\n\")\n\t\t? trimmed\n\t\t\t\t.split(/\\r?\\n/u)\n\t\t\t\t.map((line) => line.trim())\n\t\t\t\t.filter((line) => /[\\p{L}\\p{N}]/u.test(line) && !GENERIC_LINE.test(line))\n\t\t: [];\n\tconst derived = [...lines, ...[trimmed, ...lines].flatMap(encodedForms)];\n\treturn [trimmed, ...derived.filter((form) => form.length >= derivedLength)];\n}\n\n/** Every occurrence of each of `forms` in `text`, overlapping ones merged, as `[start, end)` ranges in order. */\nfunction secretRanges(text: string, forms: readonly string[]): [number, number][] {\n\tconst found: [number, number][] = [];\n\tfor (const form of forms) {\n\t\tfor (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) found.push([at, at + form.length]);\n\t}\n\tfound.sort((first, second) => first[0] - second[0]);\n\tconst merged: [number, number][] = [];\n\tfor (const [start, end] of found) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && start < last[1]) last[1] = Math.max(last[1], end);\n\t\telse merged.push([start, end]);\n\t}\n\treturn merged;\n}\n\n/**\n * A redactor that replaces each configured secret with `[redacted]`: its plain, trimmed and per-line forms, and their\n * JSON-escaped, URI-encoded, URI-decoded and base64 forms. Occurrences that overlap, such as two secrets that share\n * characters, are replaced together, so no part of either survives, and text around them is left as it is. A\n * `[redacted]` marker already in the text is kept as it is, so redacting twice changes nothing.\n */\nexport function configuredSecretRedactor(\n\tsecrets: Iterable<string>,\n\toptions: ConfiguredSecretRedactorOptions = {},\n): (text: string) => string {\n\tconst forms = new Set<string>();\n\tfor (const secret of secrets) for (const form of secretForms(secret, options.minLength ?? 1)) forms.add(form);\n\tconst ordered = [...forms];\n\treturn (text) =>\n\t\ttext\n\t\t\t.split(REDACTED)\n\t\t\t.map((piece) => {\n\t\t\t\tlet redacted = \"\";\n\t\t\t\tlet copied = 0;\n\t\t\t\tfor (const [start, end] of secretRanges(piece, ordered)) {\n\t\t\t\t\tredacted += piece.slice(copied, start) + REDACTED;\n\t\t\t\t\tcopied = end;\n\t\t\t\t}\n\t\t\t\treturn redacted + piece.slice(copied);\n\t\t\t})\n\t\t\t.join(REDACTED);\n}\n\n/**\n * A redactor that replaces every non-empty secret, and its trimmed, per-line, URI-encoded, URI-decoded, JSON-escaped\n * and base64 forms, with `[redacted]`. Occurrences that overlap are replaced together, so a secret that contains or\n * shares characters with another is removed whole. A `[redacted]` marker already in the text is kept as it is, so\n * redacting twice changes nothing, even for a secret that is part of the marker.\n */\nexport function redactSecrets(secrets: Iterable<string>): (text: string) => string {\n\treturn configuredSecretRedactor(secrets);\n}\n\nfunction redactCause(cause: StorageFailureCause, redact: (text: string) => string): StorageFailureCause {\n\tif (typeof cause === \"string\") return redact(cause);\n\tif (!(cause instanceof Error)) return cause;\n\tconst nested = cause.cause as StorageFailureCause;\n\tconst safeCause = redactCause(nested, redact);\n\tconst message = redact(cause.message);\n\tconst stack = cause.stack === undefined ? undefined : redact(cause.stack);\n\tif (message === cause.message && stack === cause.stack && safeCause === nested) return cause;\n\tconst safe = new StorageError(message, { cause: safeCause });\n\tsafe.stack = stack;\n\t// The code names the failure, such as a TLS error's, and holds no credential.\n\tconst code = (cause as { readonly code?: string | number }).code;\n\tif (typeof code === \"string\") Object.assign(safe, { code });\n\treturn safe;\n}\n\nfunction snapshotParams(params: readonly SqliteValue[]): SqliteValue[] {\n\treturn params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));\n}\n\nfunction normalizeValue(value: SqliteDriverValue): SqliteValue {\n\tif (typeof value === \"bigint\") {\n\t\treturn value >= -BigInt(Number.MAX_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? Number(value)\n\t\t\t: value;\n\t}\n\tif (value instanceof ArrayBuffer) return new Uint8Array(value.slice(0));\n\tif (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();\n\treturn value;\n}\n\nfunction normalizeRow(row: ArrayLike<SqliteDriverValue>, columns: readonly string[]): SqliteRow {\n\treturn Object.fromEntries(columns.map((column, index) => [column, normalizeValue(row[index] ?? null)]));\n}\n\n/** Rejects a `retryTransientFailures` that is not a boolean, before the transaction is queued. */\nfunction retriesTransientFailures(options: SqliteTransactionOptions | undefined): boolean {\n\tconst retry = options?.retryTransientFailures;\n\tif (retry !== undefined && typeof retry !== \"boolean\")\n\t\tthrow new StorageConfigError(\n\t\t\t\"sdk\",\n\t\t\t\"retryTransientFailures\",\n\t\t\t\"boolean-required\",\n\t\t\t\"Pass true or false, or omit it\",\n\t\t);\n\treturn retry === true;\n}\n\nconst SERIAL: TransactionConcurrency = Object.freeze({ kind: \"serial\" });\n\n/** Rejects a `concurrency` that is not one of the two kinds, before the transaction is queued. */\nfunction transactionConcurrency(options: SqliteTransactionOptions | undefined): TransactionConcurrency {\n\tconst concurrency = options?.concurrency;\n\tif (concurrency === undefined) return SERIAL;\n\tif (typeof concurrency !== \"object\" || concurrency === null) throw concurrencyConfigError();\n\tif (concurrency.kind === \"serial\" && (concurrency.domain === undefined || typeof concurrency.domain === \"string\"))\n\t\treturn concurrency;\n\tif (\n\t\tconcurrency.kind === \"fenced\" &&\n\t\ttypeof concurrency.audit === \"string\" &&\n\t\tconcurrency.audit !== \"\" &&\n\t\t(concurrency.excludesSerial === undefined || typeof concurrency.excludesSerial === \"boolean\")\n\t)\n\t\treturn concurrency;\n\tthrow concurrencyConfigError();\n}\n\nfunction concurrencyConfigError(): StorageConfigError {\n\treturn new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"concurrency\",\n\t\t\"kind-required\",\n\t\t'Pass { kind: \"serial\" }, { kind: \"serial\", domain }, or { kind: \"fenced\", audit: fencedPath(name) }, or omit it',\n\t);\n}\n\n/** Serializes operations in call order; a failed operation does not stop the ones queued after it. */\nclass CallQueue {\n\tprivate tail: Promise<void> = Promise.resolve();\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn this.tail;\n\t}\n}\n\n/** Starts each operation as it is pushed, so a pipelined connection receives them in push order without waiting. */\nclass PipelineQueue {\n\tprivate readonly started = new Set<Promise<void>>();\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = operation();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\t// A queue lasts one transaction, so it keeps every call it started.\n\t\tthis.started.add(settled);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn Promise.all(this.started).then(() => {});\n\t}\n}\n\ninterface QueuedCall {\n\trun(): Promise<void>;\n\tfail(error: Error): void;\n}\n\n/**\n * Runs operations one at a time, in call order within each lane: an operation of the priority lane runs before every\n * waiting operation of the normal lane. A failed operation does not stop the ones queued after it. Once the running\n * operation has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` without settling, every priority operation waiting behind it\n * fails with `stalled()` without running, and once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`, every other one does;\n * so does every one queued behind it after that. Each operation that starts gets full waits of its own, so a queue of\n * operations that each settle in time never fails one.\n */\nclass LaneQueue {\n\tprivate readonly normal: QueuedCall[] = [];\n\tprivate readonly priority: QueuedCall[] = [];\n\tprivate running = false;\n\t/** When the running operation started, as `Date.now()`. */\n\tprivate runningSince = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** The bound the planned check enforces, or undefined when none is planned. */\n\tprivate watchdogBound?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error) {\n\t\tthis.stalled = stalled;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\t(priority ? this.priority : this.normal).push({\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t});\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (!this.running && this.normal.length === 0 && this.priority.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\tprivate next(): void {\n\t\tif (this.running) return;\n\t\tconst operation = this.priority.shift() ?? this.normal.shift();\n\t\tif (operation === undefined) {\n\t\t\tconst idle = this.idle;\n\t\t\tthis.idle = [];\n\t\t\tfor (const resolve of idle) resolve();\n\t\t\treturn;\n\t\t}\n\t\tthis.running = true;\n\t\tthis.runningSince = Date.now();\n\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\tvoid operation.run().finally(() => {\n\t\t\tclearTimeout(this.watchdog);\n\t\t\tthis.watchdog = undefined;\n\t\t\tthis.watchdogBound = undefined;\n\t\t\tthis.running = false;\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\t/**\n\t * While operations wait behind a running one, fails the priority ones once that one has run\n\t * `STORAGE_PRIORITY_CALL_MAX_WAIT_MS`, and the others once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`. No timer\n\t * runs while nothing waits.\n\t */\n\tprivate watch(): void {\n\t\tconst bound =\n\t\t\tthis.priority.length > 0\n\t\t\t\t? STORAGE_PRIORITY_CALL_MAX_WAIT_MS\n\t\t\t\t: this.normal.length > 0\n\t\t\t\t\t? STORAGE_QUEUED_CALL_MAX_WAIT_MS\n\t\t\t\t\t: undefined;\n\t\t// A priority call queued behind ordinary ones brings the planned check forward to its own, shorter bound.\n\t\tif (bound === this.watchdogBound) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogBound = bound;\n\t\tif (bound === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogBound = undefined;\n\t\t\t\tconst ran = Date.now() - this.runningSince;\n\t\t\t\tconst failing = this.priority.splice(0);\n\t\t\t\tif (ran >= STORAGE_QUEUED_CALL_MAX_WAIT_MS) failing.push(...this.normal.splice(0));\n\t\t\t\tfor (const waiting of failing) waiting.fail(this.stalled(ran));\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, this.runningSince + bound - Date.now()),\n\t\t);\n\t\t// A stuck operation ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\nclass DriverDatabase implements SqliteDatabase {\n\treadonly descriptor: StorageDescriptor;\n\treadonly dialect: StorageDialect;\n\tprivate readonly driver: SqliteDriver;\n\t/** Fenced transactions a concurrent driver runs outside the queue; closing waits for them. */\n\tprivate readonly concurrent = new Set<Promise<unknown>>();\n\tprivate readonly redact: (text: string) => string;\n\tprivate readonly queue = new LaneQueue(\n\t\t(ranMs) =>\n\t\t\tnew StorageUnavailableError(\n\t\t\t\tthis.descriptor,\n\t\t\t\tundefined,\n\t\t\t\t`the call was queued behind an earlier call that ran ${Math.round(ranMs / 1000)} seconds without settling, and did not run; nothing was written, retry it`,\n\t\t\t),\n\t);\n\tprivate closePromise?: Promise<void>;\n\t/** End the waits before calls run again, when closing begins during them. */\n\tprivate readonly wakeRetries = new Set<() => void>();\n\tprivate retryReported = false;\n\tprivate readonly executor: SqliteExecutor;\n\treadonly batch?: (statements: readonly SqliteStatement[], options?: SqliteBatchOptions) => Promise<SqliteRow[][]>;\n\treadonly notifications?: StorageNotifications;\n\n\tconstructor(driver: SqliteDriver, redact: (text: string) => string) {\n\t\tthis.driver = driver;\n\t\tif (driver.notifications !== undefined) this.notifications = driver.notifications;\n\t\tthis.redact = redact;\n\t\tthis.descriptor = { adapter: driver.descriptor.adapter, location: redact(driver.descriptor.location) };\n\t\tthis.dialect = driver.dialect ?? sqliteDialect;\n\t\tthis.executor = this.createExecutor(\n\t\t\tdriver,\n\t\t\t(operation) => {\n\t\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t\t\treturn this.queue.push(() => this.retrying(operation, true));\n\t\t\t},\n\t\t\ttrue,\n\t\t);\n\t\tconst batch = driver.batch?.bind(driver);\n\t\tif (batch) this.batch = (statements, options) => this.runBatch(batch, statements, options);\n\t}\n\n\tprivate runBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst bound = statements.map((statement) => ({ sql: statement.sql, params: snapshotParams(statement.params) }));\n\t\tconst passed = options === undefined ? undefined : { ...options };\n\t\tconst send = () => this.sendBatch(batch, bound, passed);\n\t\tconst lockWaitMs = passed?.lockWaitMs ?? 0;\n\t\tconst busy = this.driver.lockBusy?.bind(this.driver);\n\t\tif (lockWaitMs <= 0 || busy === undefined) return send();\n\t\treturn this.whileBusy(send, busy, performance.now() + lockWaitMs);\n\t}\n\n\t/**\n\t * Sends a batch again while it finds the write lock busy, until `deadline`. Each wait is random up to a bound that\n\t * doubles from `BUSY_RETRY_BASE_MS` to `BUSY_RETRY_MAX_MS` (\"full jitter\"), so writers that failed together do not\n\t * come back together. The waits happen outside the call queue, so calls queued meanwhile, a priority batch such as\n\t * a lease renewal included, run during them.\n\t */\n\tprivate async whileBusy<T>(\n\t\tsend: () => Promise<T>,\n\t\tbusy: (failure: StorageFailureCause) => boolean,\n\t\tdeadline: number,\n\t): Promise<T> {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await send();\n\t\t\t} catch (failure) {\n\t\t\t\tif (!busy(failure as StorageFailureCause) || performance.now() >= deadline || this.closePromise)\n\t\t\t\t\tthrow failure;\n\t\t\t}\n\t\t\tconst bound = Math.min(BUSY_RETRY_MAX_MS, BUSY_RETRY_BASE_MS * 2 ** Math.min(attempt, 16));\n\t\t\tawait new Promise((resolve) =>\n\t\t\t\tsetTimeout(resolve, Math.min(Math.random() * bound, deadline - performance.now())),\n\t\t\t);\n\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t}\n\t}\n\n\tprivate sendBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tbound: readonly SqliteStatement[],\n\t\tpassed: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tfor (const statement of bound) {\n\t\t\t\t\t\tconst invalidIndex = statement.params.findIndex(\n\t\t\t\t\t\t\t(value) => typeof value === \"string\" && value.includes(\"\\0\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconst results = await this.call(\n\t\t\t\t\t\t() => batch(bound, passed),\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tbound.flatMap((statement) => statement.params),\n\t\t\t\t\t);\n\t\t\t\t\treturn results.map((result) => result.rows.map((row) => normalizeRow(row, result.columns)));\n\t\t\t\t}, true),\n\t\t\tpassed?.priority === true,\n\t\t);\n\t}\n\n\t/**\n\t * Runs `operation` again while a transient failure ended its run before it wrote anything, waiting longer before\n\t * each run, and only when `replay` allows it. Gives up with the last run's failure after\n\t * `STORAGE_TRANSIENT_RETRY_ATTEMPTS` runs, or once closing begins.\n\t */\n\tprivate async retrying<T>(operation: (attempt: Attempt) => Promise<T>, replay: boolean): Promise<T> {\n\t\tfor (let number = 1; ; number++) {\n\t\t\tconst attempt: Attempt = { number };\n\t\t\ttry {\n\t\t\t\treturn await operation(attempt);\n\t\t\t} catch (failure) {\n\t\t\t\tconst transient = attempt.transient;\n\t\t\t\tif (!replay || transient?.outcome !== \"not-applied\" || !(await this.backoff(transient))) throw failure;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Waits before the run after `failure`'s, and says whether to run again: not after the last run, nor once closing\n\t * begins, which also ends a wait under way. The first transient failure that makes the database run a call again is\n\t * emitted as a process warning.\n\t */\n\tprivate async backoff(failure: StorageTransientError): Promise<boolean> {\n\t\tif (failure.attempts >= STORAGE_TRANSIENT_RETRY_ATTEMPTS || this.closePromise) return false;\n\t\tif (!this.retryReported) {\n\t\t\tthis.retryReported = true;\n\t\t\tprocess.emitWarning(failure);\n\t\t}\n\t\tlet wake: (() => void) | undefined;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timer = setTimeout(resolve, transientRetryDelayMs(failure.attempts));\n\t\t\twake = () => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.wakeRetries.add(wake);\n\t\t});\n\t\tif (wake) this.wakeRetries.delete(wake);\n\t\treturn this.closePromise === undefined;\n\t}\n\n\t/**\n\t * Maps a driver failure to `StorageUnavailableError` with a credential-free cause: a `StorageTransientError` when\n\t * the driver recognizes it and the call belongs to an `attempt`. `applies` says whether the call commits on its\n\t * own; a failed call inside an open transaction applied nothing, whatever the driver says of the request.\n\t */\n\tprivate async call<T>(\n\t\toperation: () => Awaitable<T>,\n\t\tattempt?: Attempt,\n\t\tapplies = false,\n\t\tparams: readonly SqliteValue[] = [],\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (cause) {\n\t\t\tconst safe = redactCause(cause as StorageFailureCause, this.redact);\n\t\t\t// A payload too large for the backend fails the same way every time: permanent, never an outage (#4954).\n\t\t\tconst kind = payloadTooLargeKind(cause as StorageFailureCause);\n\t\t\tif (kind !== undefined) {\n\t\t\t\tthrow new StoragePayloadTooLargeError(\n\t\t\t\t\tthis.driver.payloadLimits?.[kind] ?? 0,\n\t\t\t\t\tkind === \"value\" ? largestValueBytes(params) : 0,\n\t\t\t\t\t{ kind, descriptor: this.descriptor, cause: safe },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (attempt !== undefined) {\n\t\t\t\tconst transient = this.driver.transientFailure?.(cause as StorageFailureCause);\n\t\t\t\tif (transient !== undefined) {\n\t\t\t\t\tconst failure = new StorageTransientError(\n\t\t\t\t\t\tthis.descriptor,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: transient.code,\n\t\t\t\t\t\t\toutcome: applies ? transient.outcome : \"not-applied\",\n\t\t\t\t\t\t\tattempts: attempt.number,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsafe,\n\t\t\t\t\t);\n\t\t\t\t\tattempt.transient ??= failure;\n\t\t\t\t\tthrow failure;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new StorageUnavailableError(this.descriptor, safe);\n\t\t}\n\t}\n\n\tprivate createExecutor(\n\t\tconnection: SqliteDriverExecutor,\n\t\tadmit: <T>(operation: (attempt: Attempt) => Promise<T>) => Promise<T>,\n\t\tapplies: boolean,\n\t): SqliteExecutor {\n\t\tconst statement = (sql: string, params: readonly SqliteValue[]) => {\n\t\t\tconst bound = snapshotParams(params);\n\t\t\treturn admit(async (attempt) => {\n\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\treturn this.call(() => connection.execute(sql, bound), attempt, applies, bound);\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\texec: (sql) => admit((attempt) => this.call(() => connection.executeMultiple(sql), attempt, applies)),\n\t\t\trun: async (sql, ...params) => ({ changes: (await statement(sql, params)).changes }),\n\t\t\tget: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\tconst row = result.rows[0];\n\t\t\t\treturn row === undefined ? undefined : (normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t\tall: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t};\n\t}\n\n\texec(sql: string): Promise<void> {\n\t\treturn this.executor.exec(sql);\n\t}\n\n\trun(sql: string, ...params: readonly SqliteValue[]) {\n\t\treturn this.executor.run(sql, ...params);\n\t}\n\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {\n\t\treturn this.executor.get<T>(sql, ...params);\n\t}\n\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {\n\t\treturn this.executor.all<T>(sql, ...params);\n\t}\n\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet replay: boolean;\n\t\tlet concurrency: TransactionConcurrency;\n\t\ttry {\n\t\t\treplay = retriesTransientFailures(options);\n\t\t\tconcurrency = transactionConcurrency(options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst begin: SqliteDriverTransactionOptions =\n\t\t\toptions?.lockWaitMs === undefined ? { concurrency } : { concurrency, lockWaitMs: options.lockWaitMs };\n\t\tconst run = () => this.retrying((attempt) => this.runTransaction(callback, attempt, begin), replay);\n\t\tif (concurrency.kind === \"serial\" || this.driver.concurrentTransactions !== true) return this.queue.push(run);\n\t\tconst result = run();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn result;\n\t}\n\n\tprivate async runTransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\tattempt: Attempt,\n\t\tbegin: SqliteDriverTransactionOptions,\n\t): Promise<T> {\n\t\tconst connection = await this.call(() => this.driver.beginTransaction(begin), attempt);\n\t\tconst pipelined = this.driver.pipelinedTransactions === true;\n\t\tconst handleQueue = pipelined ? new PipelineQueue() : new CallQueue();\n\t\tlet active = true;\n\t\tlet result: T;\n\t\tconst handle = this.createExecutor(\n\t\t\tconnection,\n\t\t\t(operation) =>\n\t\t\t\tactive ? handleQueue.push(() => operation(attempt)) : Promise.reject(new StorageTransactionClosedError()),\n\t\t\tfalse,\n\t\t);\n\t\tconst close = () => this.call(() => connection.close?.());\n\t\t// Once the callback has returned, the commit's own failure decides whether the transaction runs again: a commit\n\t\t// that may have applied, or that failed for a reason the driver does not recognize, never does, whatever the\n\t\t// callback met before it. A committed transaction never runs again either.\n\t\tconst commit = () => {\n\t\t\tattempt.transient = undefined;\n\t\t\treturn this.call(() => connection.commit(), attempt, true);\n\t\t};\n\t\ttry {\n\t\t\tlet committing: Promise<void> | undefined;\n\t\t\ttry {\n\t\t\t\tresult = await callback(handle);\n\t\t\t\t// A pipelined connection takes the commit behind statements the callback left unanswered, so locks they take\n\t\t\t\t// are held for one round trip. The driver's commit fails when one of them failed, so nothing commits then;\n\t\t\t\t// a statement that fails as transient after this point lets the transaction run again, having written nothing.\n\t\t\t\tif (pipelined) {\n\t\t\t\t\tcommitting = commit();\n\t\t\t\t\tcommitting.catch(() => {});\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tactive = false;\n\t\t\t\tawait handleQueue.drained();\n\t\t\t}\n\t\t\tawait (committing ?? commit());\n\t\t} catch (cause) {\n\t\t\tlet failure = cause as StorageFailureCause;\n\t\t\ttry {\n\t\t\t\tawait this.call(() => connection.rollback());\n\t\t\t} catch (rollbackCause) {\n\t\t\t\tfailure = new StorageRollbackError(failure, rollbackCause as StorageFailureCause);\n\t\t\t}\n\t\t\t// Cleanup must not replace a callback, commit, or rollback failure.\n\t\t\tawait close().catch(() => {});\n\t\t\tthrow failure;\n\t\t}\n\t\tawait close();\n\t\treturn result;\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= Promise.all([this.queue.drained(), ...this.concurrent]).then(() =>\n\t\t\tthis.call(() => this.driver.close()),\n\t\t);\n\t\tfor (const wake of this.wakeRetries) wake();\n\t\treturn this.closePromise;\n\t}\n}\n\n/**\n * Wraps a SQLite-compatible driver as a `SqliteDatabase`. The facade queues operations in call order and keeps them\n * outside active transactions, snapshots binary parameters at call time, rejects NUL text, returns safe-range integers\n * as numbers and blobs as `Uint8Array` copies, expires transaction handles when their callback settles, maps driver\n * failures to `StorageUnavailableError` with credentials redacted, and reports failed rollbacks with\n * `StorageRollbackError`. A failure the driver recognizes as transient is a `StorageTransientError`; a statement, a\n * batch, or a transaction whose options allow it runs again, up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` times in all,\n * while such a failure ended it before it wrote anything. Closing rejects new calls, stops those retries, drains\n * accepted work, then closes the driver once.\n */\nexport function createSqliteDatabase(driver: SqliteDriver): SqliteDatabase {\n\treturn new DriverDatabase(driver, driver.redact?.bind(driver) ?? ((text) => text));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sqlite-facade.js","sourceRoot":"","sources":["../../../src/core/storage/sqlite-facade.ts"],"names":[],"mappings":"AAYA,OAAO,EAAuB,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EAEZ,uBAAuB,EAEvB,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EAIrB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,aAAa,CAAC;AA0HrB;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAClD,2GAA2G;AAC3G,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAClD,mHAAmH;AACnH,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,uHAAuH;AACvH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,sCAAsC;AACtC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD,wGAAwG;AACxG,SAAS,qBAAqB,CAAC,OAAe;IAC7C,MAAM,MAAM,GAAG,CAAC,GAAG,8BAA8B,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,KAAK,CAAC,qCAAqC,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AACxF,CAAC;AAQD,MAAM,QAAQ,GAAG,YAAY,CAAC;AAQ9B;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,sHAAsH;AACtH,MAAM,iBAAiB,GAAG,CAA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AoB,CAAC,MAAoB;IACxD,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type {\n\tSqliteBatchOptions,\n\tSqliteDatabase,\n\tSqliteExecutor,\n\tSqliteRow,\n\tSqliteStatement,\n\tSqliteTransactionOptions,\n\tSqliteValue,\n\tStorageDescriptor,\n\tStorageNotifications,\n\tTransactionConcurrency,\n} from \"./database.js\";\nimport { type StorageDialect, sqliteDialect } from \"./dialect.js\";\nimport {\n\tlargestValueBytes,\n\tpayloadTooLargeKind,\n\tStorageConfigError,\n\tStorageError,\n\ttype StorageFailureCause,\n\tStorageInvalidTextError,\n\ttype StoragePayloadLimits,\n\tStoragePayloadTooLargeError,\n\tStorageRollbackError,\n\tStorageTransactionClosedError,\n\tStorageTransientError,\n\ttype StorageTransientErrorCode,\n\ttype StorageTransientHop,\n\ttype StorageTransientOutcome,\n\tStorageUnavailableError,\n\tStoreClosedError,\n} from \"./errors.js\";\n\ntype Awaitable<T> = T | Promise<T>;\n\n/** A value as a driver returns it. Blobs may be any binary view; the facade returns them as `Uint8Array` copies. */\nexport type SqliteDriverValue = SqliteValue | ArrayBuffer | ArrayBufferView;\n\n/** One statement's result as a driver returns it: column names, positional rows, and the rows it changed. */\nexport interface SqliteDriverResult {\n\treadonly columns: readonly string[];\n\treadonly rows: readonly ArrayLike<SqliteDriverValue>[];\n\treadonly changes: number;\n}\n\n/** Runs SQL on a driver connection or on an open driver transaction. */\nexport interface SqliteDriverExecutor {\n\t/** Runs one statement with positional `?` parameters. */\n\texecute(sql: string, params: readonly SqliteValue[]): Awaitable<SqliteDriverResult>;\n\t/** Runs zero or more statements that take no parameters. */\n\texecuteMultiple(sql: string): Awaitable<void>;\n}\n\nexport interface SqliteDriverTransaction extends SqliteDriverExecutor {\n\tcommit(): Awaitable<void>;\n\trollback(): Awaitable<void>;\n\t/** Releases the transaction after it commits or rolls back. */\n\tclose?(): Awaitable<void>;\n}\n\n/** A driver failure that passes, as `SqliteDriver.transientFailure` recognizes it. */\nexport interface SqliteDriverTransientFailure {\n\treadonly code: StorageTransientErrorCode;\n\t/**\n\t * `\"not-applied\"` when the failed request cannot have changed the database, `\"unknown\"` when the connection broke\n\t * after the server may have applied it.\n\t */\n\treadonly outcome: StorageTransientOutcome;\n\t/**\n\t * Optional. Where on the way to the server the call failed, when it did not reach the server, such as at a proxy:\n\t * `StorageTransientError` then names this hop where it would name the database server. The facade passes both texts\n\t * through `redact`.\n\t */\n\treadonly hop?: StorageTransientHop;\n}\n\n/** How the facade asks a driver to begin a transaction. */\nexport interface SqliteDriverTransactionOptions {\n\t/** @internal A consistent read snapshot without acquiring the database's writer lock. */\n\treadonly readOnly?: boolean;\n\t/** Always present when the facade calls; `{ kind: \"serial\" }` unless the transaction asked for another. */\n\treadonly concurrency: TransactionConcurrency;\n\t/** The transaction's `SqliteTransactionOptions.lockWaitMs`, when it set one. */\n\treadonly lockWaitMs?: number;\n}\n\n/** The driver calls `createSqliteDatabase` turns into a `SqliteDatabase`. */\nexport interface SqliteDriver extends SqliteDriverExecutor {\n\t/** Diagnostic identity. Its `location` passes through `redact` before the facade exposes it. */\n\treadonly descriptor: StorageDescriptor;\n\t/** The SQL dialect the driver speaks; SQLite when absent. The facade exposes it as `SqliteDatabase.dialect`. */\n\treadonly dialect?: StorageDialect;\n\t/**\n\t * Optional. The driver runs `fenced` transactions on connections of their own, concurrently with other calls: the\n\t * facade then starts them without waiting for queued calls. Otherwise every transaction waits its turn.\n\t */\n\treadonly concurrentTransactions?: boolean;\n\t/**\n\t * Optional. A transaction's connection takes a statement before the one before it is answered, and runs them in the\n\t * order it took them (a pipelined connection): the facade then sends each call of a transaction as it is made, so a\n\t * body that makes several calls without awaiting each sends them in one round trip. Otherwise each call waits for\n\t * the one before it to settle.\n\t */\n\treadonly pipelinedTransactions?: boolean;\n\t/**\n\t * Begins a write transaction. With `options.concurrency` `{ kind: \"serial\" }` (the default) it holds the write lock of the whole database\n\t * or of `concurrency.domain`, like `BEGIN IMMEDIATE`; with `fenced` it may take no lock, and the body locks its rows.\n\t * A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the concurrency argument. An internal `readOnly`\n\t * request instead opens a consistent read snapshot without any writer lock.\n\t */\n\tbeginTransaction(options?: SqliteDriverTransactionOptions): Awaitable<SqliteDriverTransaction>;\n\t/**\n\t * Optional. Runs the statements in order in one write transaction, in one request: all commit or none do. Provide it\n\t * only when the driver sends the whole batch at once; the facade then offers `SqliteDatabase.batch`. `options` are the\n\t * caller's, as `SqliteDatabase.batch` took them.\n\t */\n\tbatch?(\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions?: SqliteBatchOptions,\n\t): Awaitable<readonly SqliteDriverResult[]>;\n\t/** Releases the connection. Called once, after accepted work drains. */\n\tclose(): Awaitable<void>;\n\t/** Removes credentials from diagnostic text: the descriptor location and driver failure messages and stacks. */\n\tredact?(text: string): string;\n\t/**\n\t * Optional. Recognizes a failed `batch` that found the database's write lock busy and wrote nothing: the facade sends\n\t * it again, after a randomized wait outside its call queue, for up to the caller's `lockWaitMs`. It receives the\n\t * failure the facade reports, whose `cause` chain holds the driver's own.\n\t */\n\tlockBusy?(failure: StorageFailureCause): boolean;\n\t/**\n\t * Optional. Recognizes a failure a driver call threw as one that passes, from the failure's own fields, before the\n\t * facade redacts it. The call then fails with `StorageTransientError`, and a call that wrote nothing runs again.\n\t */\n\ttransientFailure?(failure: StorageFailureCause): SqliteDriverTransientFailure | undefined;\n\t/**\n\t * Optional. The backend's payload limits in bytes, named in the `StoragePayloadTooLargeError` the facade throws when\n\t * a driver call fails because a value, row or response was too large for the backend (#4954).\n\t */\n\treadonly payloadLimits?: StoragePayloadLimits;\n\t/**\n\t * Optional. Wake-ups through the database, which the facade exposes as `SqliteDatabase.notifications`; the driver's\n\t * `close` stops its listening connection.\n\t */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * Optional. The bytes this process may still write on the file system that holds the database's file, or undefined\n\t * when the file system does not say; the facade exposes it as `SqliteDatabase.freeBytes`. Provide it only for a\n\t * database in a file this process can see, such as a local SQLite or libSQL file.\n\t */\n\tfreeBytes?(): Awaitable<number | undefined>;\n}\n\n/**\n * How many times the facade runs a call that a transient failure ended before it wrote anything, the first run\n * included. A transaction runs again only when its options allow it (`retryTransientFailures`).\n */\nexport const STORAGE_TRANSIENT_RETRY_ATTEMPTS = 5;\n/** The wait before the second run, in milliseconds; each later wait is twice as long as the one before. */\nconst STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS = 250;\n/** Each wait varies by up to this fraction either way, so processes that failed together do not retry together. */\nconst STORAGE_TRANSIENT_RETRY_JITTER = 0.2;\n/** The first bound on the wait before a batch that found the write lock busy is sent again; each later one doubles. */\nconst BUSY_RETRY_BASE_MS = 20;\n/** The largest bound on that wait. */\nconst BUSY_RETRY_MAX_MS = 1000;\n\n/**\n * How long the running call may run before the calls queued behind it fail without running (#5114). The facade\n * runs one call at a time, so a call that cannot complete, such as one waiting on a write lock a server keeps for a\n * stream an outage cut, would otherwise hold every call queued behind it, priority calls such as a worker host's\n * heartbeat included. A call queued behind it fails with `StorageUnavailableError` instead, having written nothing,\n * and its caller retries it as it retries any outage.\n */\nexport const STORAGE_QUEUED_CALL_MAX_WAIT_MS = 60_000;\n/**\n * The same bound for a priority call, such as a worker host's heartbeat or a work lease renewal: a third of the 30 s a\n * host's or a work lease's last write keeps it live (`FLEET_HOST_LIVE_MS`), so a priority call stuck behind a call that\n * cannot complete fails, and its caller tries it again, while the lease it renews still holds.\n */\nexport const STORAGE_PRIORITY_CALL_MAX_WAIT_MS = 10_000;\n\n/** How long the facade waits after the failed run `attempt` (1-based) before it runs the call again. */\nfunction transientRetryDelayMs(attempt: number): number {\n\tconst jitter = 1 + STORAGE_TRANSIENT_RETRY_JITTER * (2 * Math.random() - 1);\n\treturn Math.round(STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * jitter);\n}\n\n/** One run of a call: which run it is, and the first transient failure it met. */\ninterface Attempt {\n\treadonly number: number;\n\ttransient?: StorageTransientError;\n}\n\nconst REDACTED = \"[redacted]\";\n\n/** How {@link configuredSecretRedactor} matches the secrets it is given. */\nexport interface ConfiguredSecretRedactorOptions {\n\t/** Forms of a secret shorter than this are not redacted where they appear: they would match ordinary words. */\n\treadonly minLength?: number;\n}\n\n/**\n * Fewest characters of a form derived from a secret (a line of it, or an encoding) that is redacted, so short pieces\n * of a secret do not match ordinary text. A secret itself is redacted at any length its caller allows.\n */\nconst MIN_DERIVED_LENGTH = 6;\n/** Fewest base64 characters of a secret's encoding that are redacted, so short secrets do not match random base64. */\nconst MIN_BASE64_LENGTH = 7;\n\n/**\n * The base64 runs that appear wherever `secret`'s bytes are encoded, in standard and URL-safe alphabets: for each of\n * the three alignments of its first byte in a 3-byte group, the characters that only its bits decide.\n */\nfunction base64Forms(secret: string): string[] {\n\tconst bytes = Buffer.from(secret);\n\tconst forms: string[] = [];\n\tfor (let offset = 0; offset < 3; offset++) {\n\t\tconst encoded = Buffer.concat([Buffer.alloc(offset), bytes, Buffer.alloc(2)]).toString(\"base64\");\n\t\tconst form = encoded.slice(Math.ceil((8 * offset) / 6), Math.floor((8 * (offset + bytes.length)) / 6));\n\t\tif (form.length >= MIN_BASE64_LENGTH) forms.push(form, form.replaceAll(\"+\", \"-\").replaceAll(\"/\", \"_\"));\n\t}\n\treturn forms;\n}\n\n/** The JSON-escaped, URI-encoded, URI-decoded and base64 forms of `plain`. */\nfunction encodedForms(plain: string): string[] {\n\tconst forms = [JSON.stringify(plain).slice(1, -1), ...base64Forms(plain)];\n\ttry {\n\t\tforms.push(encodeURIComponent(plain));\n\t} catch {}\n\ttry {\n\t\tforms.push(decodeURIComponent(plain));\n\t} catch {}\n\treturn forms;\n}\n\n/** A line of a multi-line secret that many secrets share, such as a PEM armor line (`-----BEGIN … KEY-----`). */\nconst GENERIC_LINE = /^-----[A-Z0-9 ]+-----$|^[A-Za-z-]+: /u;\n\n/**\n * The forms a configured secret takes in output: trimmed, since a secret read from a file often ends with a line break\n * that the text around a printed secret need not repeat; each line of a multi-line secret, trimmed, that holds a letter\n * or digit and is not a line many secrets share (a PEM armor or header line); and the encodings of both. The secret as given holds its trimmed form, so overlapping matches still remove\n * it whole. Forms derived from the secret are kept only from {@link MIN_DERIVED_LENGTH} characters.\n */\nfunction secretForms(secret: string, minLength: number): string[] {\n\tconst trimmed = secret.trim();\n\tif (trimmed.length < Math.max(1, minLength)) return [];\n\tconst derivedLength = Math.max(minLength, MIN_DERIVED_LENGTH);\n\tconst lines = trimmed.includes(\"\\n\")\n\t\t? trimmed\n\t\t\t\t.split(/\\r?\\n/u)\n\t\t\t\t.map((line) => line.trim())\n\t\t\t\t.filter((line) => /[\\p{L}\\p{N}]/u.test(line) && !GENERIC_LINE.test(line))\n\t\t: [];\n\tconst derived = [...lines, ...[trimmed, ...lines].flatMap(encodedForms)];\n\treturn [trimmed, ...derived.filter((form) => form.length >= derivedLength)];\n}\n\n/** Every occurrence of each of `forms` in `text`, overlapping ones merged, as `[start, end)` ranges in order. */\nfunction secretRanges(text: string, forms: readonly string[]): [number, number][] {\n\tconst found: [number, number][] = [];\n\tfor (const form of forms) {\n\t\tfor (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) found.push([at, at + form.length]);\n\t}\n\tfound.sort((first, second) => first[0] - second[0]);\n\tconst merged: [number, number][] = [];\n\tfor (const [start, end] of found) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && start < last[1]) last[1] = Math.max(last[1], end);\n\t\telse merged.push([start, end]);\n\t}\n\treturn merged;\n}\n\n/**\n * A redactor that replaces each configured secret with `[redacted]`: its plain, trimmed and per-line forms, and their\n * JSON-escaped, URI-encoded, URI-decoded and base64 forms. Occurrences that overlap, such as two secrets that share\n * characters, are replaced together, so no part of either survives, and text around them is left as it is. A\n * `[redacted]` marker already in the text is kept as it is, so redacting twice changes nothing.\n */\nexport function configuredSecretRedactor(\n\tsecrets: Iterable<string>,\n\toptions: ConfiguredSecretRedactorOptions = {},\n): (text: string) => string {\n\tconst forms = new Set<string>();\n\tfor (const secret of secrets) for (const form of secretForms(secret, options.minLength ?? 1)) forms.add(form);\n\tconst ordered = [...forms];\n\treturn (text) =>\n\t\ttext\n\t\t\t.split(REDACTED)\n\t\t\t.map((piece) => {\n\t\t\t\tlet redacted = \"\";\n\t\t\t\tlet copied = 0;\n\t\t\t\tfor (const [start, end] of secretRanges(piece, ordered)) {\n\t\t\t\t\tredacted += piece.slice(copied, start) + REDACTED;\n\t\t\t\t\tcopied = end;\n\t\t\t\t}\n\t\t\t\treturn redacted + piece.slice(copied);\n\t\t\t})\n\t\t\t.join(REDACTED);\n}\n\n/**\n * A redactor that replaces every non-empty secret, and its trimmed, per-line, URI-encoded, URI-decoded, JSON-escaped\n * and base64 forms, with `[redacted]`. Occurrences that overlap are replaced together, so a secret that contains or\n * shares characters with another is removed whole. A `[redacted]` marker already in the text is kept as it is, so\n * redacting twice changes nothing, even for a secret that is part of the marker.\n */\nexport function redactSecrets(secrets: Iterable<string>): (text: string) => string {\n\treturn configuredSecretRedactor(secrets);\n}\n\nfunction redactCause(cause: StorageFailureCause, redact: (text: string) => string): StorageFailureCause {\n\tif (typeof cause === \"string\") return redact(cause);\n\tif (!(cause instanceof Error)) return cause;\n\tconst nested = cause.cause as StorageFailureCause;\n\tconst safeCause = redactCause(nested, redact);\n\tconst message = redact(cause.message);\n\tconst stack = cause.stack === undefined ? undefined : redact(cause.stack);\n\tif (message === cause.message && stack === cause.stack && safeCause === nested) return cause;\n\tconst safe = new StorageError(message, { cause: safeCause });\n\tsafe.stack = stack;\n\t// The code names the failure, such as a TLS error's, and holds no credential.\n\tconst code = (cause as { readonly code?: string | number }).code;\n\tif (typeof code === \"string\") Object.assign(safe, { code });\n\treturn safe;\n}\n\nfunction snapshotParams(params: readonly SqliteValue[]): SqliteValue[] {\n\treturn params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));\n}\n\nfunction normalizeValue(value: SqliteDriverValue): SqliteValue {\n\tif (typeof value === \"bigint\") {\n\t\treturn value >= -BigInt(Number.MAX_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? Number(value)\n\t\t\t: value;\n\t}\n\tif (value instanceof ArrayBuffer) return new Uint8Array(value.slice(0));\n\tif (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();\n\treturn value;\n}\n\nfunction normalizeRow(row: ArrayLike<SqliteDriverValue>, columns: readonly string[]): SqliteRow {\n\treturn Object.fromEntries(columns.map((column, index) => [column, normalizeValue(row[index] ?? null)]));\n}\n\n/** Rejects a `retryTransientFailures` that is not a boolean, before the transaction is queued. */\nfunction retriesTransientFailures(options: SqliteTransactionOptions | undefined): boolean {\n\tconst retry = options?.retryTransientFailures;\n\tif (retry !== undefined && typeof retry !== \"boolean\")\n\t\tthrow new StorageConfigError(\n\t\t\t\"sdk\",\n\t\t\t\"retryTransientFailures\",\n\t\t\t\"boolean-required\",\n\t\t\t\"Pass true or false, or omit it\",\n\t\t);\n\treturn retry === true;\n}\n\nconst SERIAL: TransactionConcurrency = Object.freeze({ kind: \"serial\" });\n\n/** Rejects a `concurrency` that is not one of the two kinds, before the transaction is queued. */\nfunction transactionConcurrency(options: SqliteTransactionOptions | undefined): TransactionConcurrency {\n\tconst concurrency = options?.concurrency;\n\tif (concurrency === undefined) return SERIAL;\n\tif (typeof concurrency !== \"object\" || concurrency === null) throw concurrencyConfigError();\n\tif (concurrency.kind === \"serial\" && (concurrency.domain === undefined || typeof concurrency.domain === \"string\"))\n\t\treturn concurrency;\n\tif (\n\t\tconcurrency.kind === \"fenced\" &&\n\t\ttypeof concurrency.audit === \"string\" &&\n\t\tconcurrency.audit !== \"\" &&\n\t\t(concurrency.excludesSerial === undefined || typeof concurrency.excludesSerial === \"boolean\")\n\t)\n\t\treturn concurrency;\n\tthrow concurrencyConfigError();\n}\n\nfunction concurrencyConfigError(): StorageConfigError {\n\treturn new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"concurrency\",\n\t\t\"kind-required\",\n\t\t'Pass { kind: \"serial\" }, { kind: \"serial\", domain }, or { kind: \"fenced\", audit: fencedPath(name) }, or omit it',\n\t);\n}\n\n/** Serializes operations in call order; a failed operation does not stop the ones queued after it. */\nclass CallQueue {\n\tprivate tail: Promise<void> = Promise.resolve();\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn this.tail;\n\t}\n}\n\n/** Starts each operation as it is pushed, so a pipelined connection receives them in push order without waiting. */\nclass PipelineQueue {\n\tprivate readonly started = new Set<Promise<void>>();\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = operation();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\t// A queue lasts one transaction, so it keeps every call it started.\n\t\tthis.started.add(settled);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn Promise.all(this.started).then(() => {});\n\t}\n}\n\ninterface QueuedCall {\n\trun(): Promise<void>;\n\tfail(error: Error): void;\n}\n\n/**\n * Runs operations one at a time, in call order within each lane: an operation of the priority lane runs before every\n * waiting operation of the normal lane. A failed operation does not stop the ones queued after it. Once the running\n * operation has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` without settling, every priority operation waiting behind it\n * fails with `stalled()` without running, and once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`, every other one does;\n * so does every one queued behind it after that. Each operation that starts gets full waits of its own, so a queue of\n * operations that each settle in time never fails one.\n */\nclass LaneQueue {\n\tprivate readonly normal: QueuedCall[] = [];\n\tprivate readonly priority: QueuedCall[] = [];\n\tprivate running = false;\n\t/** When the running operation started, as `Date.now()`. */\n\tprivate runningSince = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** The bound the planned check enforces, or undefined when none is planned. */\n\tprivate watchdogBound?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error) {\n\t\tthis.stalled = stalled;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\t(priority ? this.priority : this.normal).push({\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t});\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (!this.running && this.normal.length === 0 && this.priority.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\tprivate next(): void {\n\t\tif (this.running) return;\n\t\tconst operation = this.priority.shift() ?? this.normal.shift();\n\t\tif (operation === undefined) {\n\t\t\tconst idle = this.idle;\n\t\t\tthis.idle = [];\n\t\t\tfor (const resolve of idle) resolve();\n\t\t\treturn;\n\t\t}\n\t\tthis.running = true;\n\t\tthis.runningSince = Date.now();\n\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\tvoid operation.run().finally(() => {\n\t\t\tclearTimeout(this.watchdog);\n\t\t\tthis.watchdog = undefined;\n\t\t\tthis.watchdogBound = undefined;\n\t\t\tthis.running = false;\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\t/**\n\t * While operations wait behind a running one, fails the priority ones once that one has run\n\t * `STORAGE_PRIORITY_CALL_MAX_WAIT_MS`, and the others once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`. No timer\n\t * runs while nothing waits.\n\t */\n\tprivate watch(): void {\n\t\tconst bound =\n\t\t\tthis.priority.length > 0\n\t\t\t\t? STORAGE_PRIORITY_CALL_MAX_WAIT_MS\n\t\t\t\t: this.normal.length > 0\n\t\t\t\t\t? STORAGE_QUEUED_CALL_MAX_WAIT_MS\n\t\t\t\t\t: undefined;\n\t\t// A priority call queued behind ordinary ones brings the planned check forward to its own, shorter bound.\n\t\tif (bound === this.watchdogBound) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogBound = bound;\n\t\tif (bound === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogBound = undefined;\n\t\t\t\tconst ran = Date.now() - this.runningSince;\n\t\t\t\tconst failing = this.priority.splice(0);\n\t\t\t\tif (ran >= STORAGE_QUEUED_CALL_MAX_WAIT_MS) failing.push(...this.normal.splice(0));\n\t\t\t\tfor (const waiting of failing) waiting.fail(this.stalled(ran));\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, this.runningSince + bound - Date.now()),\n\t\t);\n\t\t// A stuck operation ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\nclass DriverDatabase implements SqliteDatabase {\n\treadonly descriptor: StorageDescriptor;\n\treadonly dialect: StorageDialect;\n\tprivate readonly driver: SqliteDriver;\n\t/** Fenced transactions a concurrent driver runs outside the queue; closing waits for them. */\n\tprivate readonly concurrent = new Set<Promise<unknown>>();\n\tprivate readonly redact: (text: string) => string;\n\tprivate readonly queue = new LaneQueue(\n\t\t(ranMs) =>\n\t\t\tnew StorageUnavailableError(\n\t\t\t\tthis.descriptor,\n\t\t\t\tundefined,\n\t\t\t\t`the call was queued behind an earlier call that ran ${Math.round(ranMs / 1000)} seconds without settling, and did not run; nothing was written, retry it`,\n\t\t\t),\n\t);\n\tprivate closePromise?: Promise<void>;\n\t/** End the waits before calls run again, when closing begins during them. */\n\tprivate readonly wakeRetries = new Set<() => void>();\n\tprivate retryReported = false;\n\tprivate readonly executor: SqliteExecutor;\n\treadonly batch?: (statements: readonly SqliteStatement[], options?: SqliteBatchOptions) => Promise<SqliteRow[][]>;\n\treadonly notifications?: StorageNotifications;\n\treadonly freeBytes?: () => Promise<number | undefined>;\n\n\tconstructor(driver: SqliteDriver, redact: (text: string) => string) {\n\t\tthis.driver = driver;\n\t\tif (driver.notifications !== undefined) this.notifications = driver.notifications;\n\t\tconst freeBytes = driver.freeBytes?.bind(driver);\n\t\tif (freeBytes) this.freeBytes = async () => freeBytes();\n\t\tthis.redact = redact;\n\t\tthis.descriptor = { adapter: driver.descriptor.adapter, location: redact(driver.descriptor.location) };\n\t\tthis.dialect = driver.dialect ?? sqliteDialect;\n\t\tthis.executor = this.createExecutor(\n\t\t\tdriver,\n\t\t\t(operation) => {\n\t\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t\t\treturn this.queue.push(() => this.retrying(operation, true));\n\t\t\t},\n\t\t\ttrue,\n\t\t);\n\t\tconst batch = driver.batch?.bind(driver);\n\t\tif (batch) this.batch = (statements, options) => this.runBatch(batch, statements, options);\n\t}\n\n\tprivate runBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst bound = statements.map((statement) => ({ sql: statement.sql, params: snapshotParams(statement.params) }));\n\t\tconst passed = options === undefined ? undefined : { ...options };\n\t\tconst send = () => this.sendBatch(batch, bound, passed);\n\t\tconst lockWaitMs = passed?.lockWaitMs ?? 0;\n\t\tconst busy = this.driver.lockBusy?.bind(this.driver);\n\t\tif (lockWaitMs <= 0 || busy === undefined) return send();\n\t\treturn this.whileBusy(send, busy, performance.now() + lockWaitMs);\n\t}\n\n\t/**\n\t * Sends a batch again while it finds the write lock busy, until `deadline`. Each wait is random up to a bound that\n\t * doubles from `BUSY_RETRY_BASE_MS` to `BUSY_RETRY_MAX_MS` (\"full jitter\"), so writers that failed together do not\n\t * come back together. The waits happen outside the call queue, so calls queued meanwhile, a priority batch such as\n\t * a lease renewal included, run during them.\n\t */\n\tprivate async whileBusy<T>(\n\t\tsend: () => Promise<T>,\n\t\tbusy: (failure: StorageFailureCause) => boolean,\n\t\tdeadline: number,\n\t): Promise<T> {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await send();\n\t\t\t} catch (failure) {\n\t\t\t\tif (!busy(failure as StorageFailureCause) || performance.now() >= deadline || this.closePromise)\n\t\t\t\t\tthrow failure;\n\t\t\t}\n\t\t\tconst bound = Math.min(BUSY_RETRY_MAX_MS, BUSY_RETRY_BASE_MS * 2 ** Math.min(attempt, 16));\n\t\t\tawait new Promise((resolve) =>\n\t\t\t\tsetTimeout(resolve, Math.min(Math.random() * bound, deadline - performance.now())),\n\t\t\t);\n\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t}\n\t}\n\n\tprivate sendBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tbound: readonly SqliteStatement[],\n\t\tpassed: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tfor (const statement of bound) {\n\t\t\t\t\t\tconst invalidIndex = statement.params.findIndex(\n\t\t\t\t\t\t\t(value) => typeof value === \"string\" && value.includes(\"\\0\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconst results = await this.call(\n\t\t\t\t\t\t() => batch(bound, passed),\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tbound.flatMap((statement) => statement.params),\n\t\t\t\t\t);\n\t\t\t\t\treturn results.map((result) => result.rows.map((row) => normalizeRow(row, result.columns)));\n\t\t\t\t}, true),\n\t\t\tpassed?.priority === true,\n\t\t);\n\t}\n\n\t/**\n\t * Runs `operation` again while a transient failure ended its run before it wrote anything, waiting longer before\n\t * each run, and only when `replay` allows it. Gives up with the last run's failure after\n\t * `STORAGE_TRANSIENT_RETRY_ATTEMPTS` runs, or once closing begins.\n\t */\n\tprivate async retrying<T>(operation: (attempt: Attempt) => Promise<T>, replay: boolean): Promise<T> {\n\t\tfor (let number = 1; ; number++) {\n\t\t\tconst attempt: Attempt = { number };\n\t\t\ttry {\n\t\t\t\treturn await operation(attempt);\n\t\t\t} catch (failure) {\n\t\t\t\tconst transient = attempt.transient;\n\t\t\t\tif (!replay || transient?.outcome !== \"not-applied\" || !(await this.backoff(transient))) throw failure;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Waits before the run after `failure`'s, and says whether to run again: not after the last run, nor once closing\n\t * begins, which also ends a wait under way. The first transient failure that makes the database run a call again is\n\t * emitted as a process warning.\n\t */\n\tprivate async backoff(failure: StorageTransientError): Promise<boolean> {\n\t\tif (failure.attempts >= STORAGE_TRANSIENT_RETRY_ATTEMPTS || this.closePromise) return false;\n\t\tif (!this.retryReported) {\n\t\t\tthis.retryReported = true;\n\t\t\tprocess.emitWarning(failure);\n\t\t}\n\t\tlet wake: (() => void) | undefined;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timer = setTimeout(resolve, transientRetryDelayMs(failure.attempts));\n\t\t\twake = () => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.wakeRetries.add(wake);\n\t\t});\n\t\tif (wake) this.wakeRetries.delete(wake);\n\t\treturn this.closePromise === undefined;\n\t}\n\n\t/**\n\t * Maps a driver failure to `StorageUnavailableError` with a credential-free cause: a `StorageTransientError` when\n\t * the driver recognizes it and the call belongs to an `attempt`. `applies` says whether the call commits on its\n\t * own; a failed call inside an open transaction applied nothing, whatever the driver says of the request.\n\t */\n\tprivate async call<T>(\n\t\toperation: () => Awaitable<T>,\n\t\tattempt?: Attempt,\n\t\tapplies = false,\n\t\tparams: readonly SqliteValue[] = [],\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (cause) {\n\t\t\tconst safe = redactCause(cause as StorageFailureCause, this.redact);\n\t\t\t// A payload too large for the backend fails the same way every time: permanent, never an outage (#4954).\n\t\t\tconst kind = payloadTooLargeKind(cause as StorageFailureCause);\n\t\t\tif (kind !== undefined) {\n\t\t\t\tthrow new StoragePayloadTooLargeError(\n\t\t\t\t\tthis.driver.payloadLimits?.[kind] ?? 0,\n\t\t\t\t\tkind === \"value\" ? largestValueBytes(params) : 0,\n\t\t\t\t\t{ kind, descriptor: this.descriptor, cause: safe },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (attempt !== undefined) {\n\t\t\t\tconst transient = this.driver.transientFailure?.(cause as StorageFailureCause);\n\t\t\t\tif (transient !== undefined) {\n\t\t\t\t\tconst failure = new StorageTransientError(\n\t\t\t\t\t\tthis.descriptor,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: transient.code,\n\t\t\t\t\t\t\toutcome: applies ? transient.outcome : \"not-applied\",\n\t\t\t\t\t\t\tattempts: attempt.number,\n\t\t\t\t\t\t\t...(transient.hop === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\thop: {\n\t\t\t\t\t\t\t\t\t\t\tname: this.redact(transient.hop.name),\n\t\t\t\t\t\t\t\t\t\t\tfailure: this.redact(transient.hop.failure),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsafe,\n\t\t\t\t\t);\n\t\t\t\t\tattempt.transient ??= failure;\n\t\t\t\t\tthrow failure;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new StorageUnavailableError(this.descriptor, safe);\n\t\t}\n\t}\n\n\tprivate createExecutor(\n\t\tconnection: SqliteDriverExecutor,\n\t\tadmit: <T>(operation: (attempt: Attempt) => Promise<T>) => Promise<T>,\n\t\tapplies: boolean,\n\t): SqliteExecutor {\n\t\tconst statement = (sql: string, params: readonly SqliteValue[]) => {\n\t\t\tconst bound = snapshotParams(params);\n\t\t\treturn admit(async (attempt) => {\n\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\treturn this.call(() => connection.execute(sql, bound), attempt, applies, bound);\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\texec: (sql) => admit((attempt) => this.call(() => connection.executeMultiple(sql), attempt, applies)),\n\t\t\trun: async (sql, ...params) => ({ changes: (await statement(sql, params)).changes }),\n\t\t\tget: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\tconst row = result.rows[0];\n\t\t\t\treturn row === undefined ? undefined : (normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t\tall: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t};\n\t}\n\n\texec(sql: string): Promise<void> {\n\t\treturn this.executor.exec(sql);\n\t}\n\n\trun(sql: string, ...params: readonly SqliteValue[]) {\n\t\treturn this.executor.run(sql, ...params);\n\t}\n\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {\n\t\treturn this.executor.get<T>(sql, ...params);\n\t}\n\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {\n\t\treturn this.executor.all<T>(sql, ...params);\n\t}\n\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet replay: boolean;\n\t\tlet concurrency: TransactionConcurrency;\n\t\ttry {\n\t\t\treplay = retriesTransientFailures(options);\n\t\t\tconcurrency = transactionConcurrency(options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst begin: SqliteDriverTransactionOptions = {\n\t\t\tconcurrency,\n\t\t\t...(options?.lockWaitMs === undefined ? {} : { lockWaitMs: options.lockWaitMs }),\n\t\t\t...(options?.readOnly === true ? { readOnly: true } : {}),\n\t\t};\n\t\tconst run = () => this.retrying((attempt) => this.runTransaction(callback, attempt, begin), replay);\n\t\tif (concurrency.kind === \"serial\" || this.driver.concurrentTransactions !== true) return this.queue.push(run);\n\t\tconst result = run();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn result;\n\t}\n\n\tprivate async runTransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\tattempt: Attempt,\n\t\tbegin: SqliteDriverTransactionOptions,\n\t): Promise<T> {\n\t\tconst connection = await this.call(() => this.driver.beginTransaction(begin), attempt);\n\t\tconst pipelined = this.driver.pipelinedTransactions === true;\n\t\tconst handleQueue = pipelined ? new PipelineQueue() : new CallQueue();\n\t\tlet active = true;\n\t\tlet result: T;\n\t\tconst handle = this.createExecutor(\n\t\t\tconnection,\n\t\t\t(operation) =>\n\t\t\t\tactive ? handleQueue.push(() => operation(attempt)) : Promise.reject(new StorageTransactionClosedError()),\n\t\t\tfalse,\n\t\t);\n\t\tconst close = () => this.call(() => connection.close?.());\n\t\t// Once the callback has returned, the commit's own failure decides whether the transaction runs again: a commit\n\t\t// that may have applied, or that failed for a reason the driver does not recognize, never does, whatever the\n\t\t// callback met before it. A committed transaction never runs again either.\n\t\tconst commit = () => {\n\t\t\tattempt.transient = undefined;\n\t\t\treturn this.call(() => connection.commit(), attempt, true);\n\t\t};\n\t\ttry {\n\t\t\tlet committing: Promise<void> | undefined;\n\t\t\ttry {\n\t\t\t\tresult = await callback(handle);\n\t\t\t\t// A pipelined connection takes the commit behind statements the callback left unanswered, so locks they take\n\t\t\t\t// are held for one round trip. The driver's commit fails when one of them failed, so nothing commits then;\n\t\t\t\t// a statement that fails as transient after this point lets the transaction run again, having written nothing.\n\t\t\t\tif (pipelined) {\n\t\t\t\t\tcommitting = commit();\n\t\t\t\t\tcommitting.catch(() => {});\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tactive = false;\n\t\t\t\tawait handleQueue.drained();\n\t\t\t}\n\t\t\tawait (committing ?? commit());\n\t\t} catch (cause) {\n\t\t\tlet failure = cause as StorageFailureCause;\n\t\t\ttry {\n\t\t\t\tawait this.call(() => connection.rollback());\n\t\t\t} catch (rollbackCause) {\n\t\t\t\tfailure = new StorageRollbackError(failure, rollbackCause as StorageFailureCause);\n\t\t\t}\n\t\t\t// Cleanup must not replace a callback, commit, or rollback failure.\n\t\t\tawait close().catch(() => {});\n\t\t\tthrow failure;\n\t\t}\n\t\tawait close();\n\t\treturn result;\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= Promise.all([this.queue.drained(), ...this.concurrent]).then(() =>\n\t\t\tthis.call(() => this.driver.close()),\n\t\t);\n\t\tfor (const wake of this.wakeRetries) wake();\n\t\treturn this.closePromise;\n\t}\n}\n\n/**\n * Wraps a SQLite-compatible driver as a `SqliteDatabase`. The facade queues operations in call order and keeps them\n * outside active transactions, snapshots binary parameters at call time, rejects NUL text, returns safe-range integers\n * as numbers and blobs as `Uint8Array` copies, expires transaction handles when their callback settles, maps driver\n * failures to `StorageUnavailableError` with credentials redacted, and reports failed rollbacks with\n * `StorageRollbackError`. A failure the driver recognizes as transient is a `StorageTransientError`; a statement, a\n * batch, or a transaction whose options allow it runs again, up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` times in all,\n * while such a failure ended it before it wrote anything. Closing rejects new calls, stops those retries, drains\n * accepted work, then closes the driver once.\n */\nexport function createSqliteDatabase(driver: SqliteDriver): SqliteDatabase {\n\treturn new DriverDatabase(driver, driver.redact?.bind(driver) ?? ((text) => text));\n}\n"]}
|
|
@@ -41,8 +41,19 @@ export declare class AgentTaskHost {
|
|
|
41
41
|
retainTaskRecord(taskId: C.TaskId): C.Result<void, C.WaitError>;
|
|
42
42
|
/** Ends a {@link retainTaskRecord} hold; a task this owner no longer keeps is left alone. */
|
|
43
43
|
releaseTaskRecord(taskId: C.TaskId): void;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The launch's observation of an agent task, which always runs in the background: it yields once registered, with
|
|
46
|
+
* `explicit` when the launch asked for the background and `default-background` otherwise, also for any other policy
|
|
47
|
+
* an untyped caller passes. Wait for the task explicitly with {@link waitForTask}.
|
|
48
|
+
*/
|
|
49
|
+
observeAgentLaunch(taskId: C.TaskId, policy?: {
|
|
50
|
+
readonly kind: "background";
|
|
51
|
+
}, onRegistered?: () => void): Promise<C.Result<C.WaitOutcome, C.WaitError>>;
|
|
52
|
+
/**
|
|
53
|
+
* Waits for the task to settle, until `budgetMs` (the owner's agent budget when omitted) yields the wait. An aborted
|
|
54
|
+
* `signal` ends the wait at once with `ObserverCancelled`, as it does when it is already aborted; the task keeps running.
|
|
55
|
+
*/
|
|
56
|
+
waitForTask(taskId: C.TaskId, budgetMs?: number, onRegistered?: (wait: WaitLease) => void, signal?: AbortSignal): Promise<C.Result<C.WaitOutcome, C.WaitError>>;
|
|
46
57
|
/** The automatic foreground budget this owner gives a command wait that names none (bash's default); `undefined` waits until settled. */
|
|
47
58
|
get commandWaitBudgetMs(): number | undefined;
|
|
48
59
|
/** Let inbound routing reach SDK admission instead of waiting for this owner to become idle. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{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,IAAI,IAAI,CAEzB;IAED,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,eAAe,wDAG7B;IAED,0HAA0H;IAC1H,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,GAAG,KAAK,CAGhE;IAED,OAAO,CAAC,WAAW,CAAS;IAC5B,mFAAmF;IACnF,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1B;IACD,WAAW,IAAI,IAAI,CAElB;IACD,OAAO,CAAC,mBAAmB;CAK3B"}
|
|
@@ -103,21 +103,38 @@ export class AgentTaskHost {
|
|
|
103
103
|
if (task.ok)
|
|
104
104
|
this.supervisor.releaseTaskRecord(task.value);
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The launch's observation of an agent task, which always runs in the background: it yields once registered, with
|
|
108
|
+
* `explicit` when the launch asked for the background and `default-background` otherwise, also for any other policy
|
|
109
|
+
* an untyped caller passes. Wait for the task explicitly with {@link waitForTask}.
|
|
110
|
+
*/
|
|
106
111
|
observeAgentLaunch(taskId, policy, onRegistered) {
|
|
107
112
|
const task = this.resolveTask(taskId);
|
|
113
|
+
const background = policy?.kind === "background" ? policy : undefined;
|
|
108
114
|
return task.ok
|
|
109
|
-
? this.supervisor.initialObservation(task.value,
|
|
110
|
-
if (policy?.kind === "foreground")
|
|
111
|
-
this.trackMessageWait(wait);
|
|
112
|
-
onRegistered?.((reason) => this.supervisor.yieldTaskWait(wait, reason));
|
|
113
|
-
})
|
|
115
|
+
? this.supervisor.initialObservation(task.value, background, () => onRegistered?.())
|
|
114
116
|
: Promise.resolve(task);
|
|
115
117
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Waits for the task to settle, until `budgetMs` (the owner's agent budget when omitted) yields the wait. An aborted
|
|
120
|
+
* `signal` ends the wait at once with `ObserverCancelled`, as it does when it is already aborted; the task keeps running.
|
|
121
|
+
*/
|
|
122
|
+
waitForTask(taskId, budgetMs, onRegistered, signal) {
|
|
123
|
+
let registered;
|
|
124
|
+
const stop = () => {
|
|
125
|
+
if (registered)
|
|
126
|
+
this.supervisor.disposeTaskWait(registered);
|
|
127
|
+
};
|
|
128
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
129
|
+
return this.supervisor
|
|
130
|
+
.waitForTaskId(this.owner, taskId, budgetMs, (wait) => {
|
|
131
|
+
registered = wait;
|
|
118
132
|
this.trackMessageWait(wait);
|
|
119
133
|
onRegistered?.(wait);
|
|
120
|
-
|
|
134
|
+
if (signal?.aborted)
|
|
135
|
+
stop();
|
|
136
|
+
})
|
|
137
|
+
.finally(() => signal?.removeEventListener("abort", stop));
|
|
121
138
|
}
|
|
122
139
|
/** The automatic foreground budget this owner gives a command wait that names none (bash's default); `undefined` waits until settled. */
|
|
123
140
|
get commandWaitBudgetMs() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-adapter.js","sourceRoot":"","sources":["../../../src/core/tasks/agent-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AAE7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAA8B,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EACN,qBAAqB,EAKrB,cAAc,GAGd,MAAM,iBAAiB,CAAC;AAkBzB,6FAA6F;AAC7F,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAiB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;AAEvD,yFAAyF;AACzF,MAAM,OAAO,aAAa;IACR,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;IAClC,KAAK,CA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IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,kBAAkB;QACjB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,KAAwB;QAC7B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,0HAA0H;IAC1H,UAAU,CAAC,KAAuB,EAAE,OAAqB;QACxD,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe;YAAE,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9F,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACxG,CAAC;IAEO,WAAW,GAAG,KAAK,CAAC;IAC5B,mFAAmF;IACnF,UAAU;QACT,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,WAAW;QACV,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1B,CAAC;IACO,mBAAmB;QAC1B,IAAI,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { TaskCleanupError, type TaskCleanupPhase } from \"./cleanup-error.js\";\nimport type * as C from \"./contracts.js\";\nimport { trackAdmittedAgentTask } from \"./execution-scope.js\";\nimport { defaultTaskHeartbeatMs, type TaskHeartbeatDelivery, TaskHeartbeatMonitor } from \"./heartbeat.js\";\nimport { cancelPausedOwnerTasks } from \"./pause.js\";\nimport {\n\tautomaticWaitBudgetMs,\n\ttype FakeExecution,\n\ttype FakeRunnerContext,\n\ttype OwnerLease,\n\ttype TaskLease,\n\tTaskSupervisor,\n\ttype TrustedTaskHost,\n\ttype WaitLease,\n} from \"./supervisor.js\";\n\nexport type AgentTaskRunnerFactory = (context: FakeRunnerContext, intent: C.AgentIntent) => FakeExecution;\nexport type AgentTaskHostBinding = Omit<TrustedTaskHost, \"createRunner\"> & {\n\t/** The owner's chat for periodic task heartbeats; omitted, the owner's tasks never heartbeat. */\n\theartbeat?: TaskHeartbeatDelivery;\n};\n\n/**\n * The runner factory of one launch, handed to its dispatch once. The task runs in this launch's async context, and on\n * Node 22 every promise it creates keeps that context's store, including promises that outlive the task, such as a\n * module it imports first or its owner's session write chain. So the store keeps the factory, and the launch input\n * it closes over, only until the dispatch takes it.\n */\ninterface RunnerHandoff {\n\tfactory: AgentTaskRunnerFactory | undefined;\n}\n\n// S1 converges repeated live-scope bindings on one owner, so dispatch context is shared too.\nconst runners = new AsyncLocalStorage<RunnerHandoff>();\n\n/**\n * Runs a callback in the async context of this module's load, outside every session. An owner can outlive the\n * session that first bound it (a workflow stage's), so what it keeps for its lifetime must not start in that\n * session's async context, which would keep the session reachable.\n */\nconst outsideAnySession = AsyncLocalStorage.snapshot();\n\n/** Internal trusted-host seam. Bind actual host identity, never model-supplied scope. */\nexport class AgentTaskHost {\n\tprivate readonly supervisor = new TaskSupervisor();\n\tprivate readonly owner;\n\tprivate binding: AgentTaskHostBinding;\n\tprivate readonly messageWaits = new Set<WaitLease>();\n\tprivate readonly heartbeats: TaskHeartbeatMonitor;\n\t/** Whether this owner has launched anything; owners that never do pay nothing for heartbeats. */\n\tprivate launched = false;\n\t/** Stage replacement updates callbacks, never native identity or ownership. */\n\tupdateBinding(binding: Omit<AgentTaskHostBinding, \"scope\">): void {\n\t\tthis.binding = { ...this.binding, ...binding };\n\t\tthis.watchHeartbeats();\n\t}\n\t/** Internal projection binding; never serialize these native-backed capabilities. */\n\tget ownerBinding(): { supervisor: TaskSupervisor; owner: OwnerLease; waitForTask: AgentTaskHost[\"waitForTask\"] } {\n\t\treturn { supervisor: this.supervisor, owner: this.owner, waitForTask: this.waitForTask.bind(this) };\n\t}\n\n\tconstructor(binding: AgentTaskHostBinding) {\n\t\tthis.binding = binding;\n\t\t// The native host keeps this binding as long as the owner lives; the heartbeat belongs to whichever session\n\t\t// binds the owner, so it reaches the monitor only through `updateBinding`.\n\t\tconst { heartbeat: _heartbeat, ...hostBinding } = binding;\n\t\tconst host = this.supervisor.bindHostSession({\n\t\t\t...hostBinding,\n\t\t\tauthorizeLaunch: (intent) => {\n\t\t\t\tthis.authorizeTaskLaunch();\n\t\t\t\tthis.binding.authorizeLaunch(intent);\n\t\t\t},\n\t\t\tauthorizeCommandLaunch: (intent, origin) => {\n\t\t\t\tthis.authorizeTaskLaunch();\n\t\t\t\tthis.binding.authorizeCommandLaunch?.(intent, origin);\n\t\t\t},\n\t\t\tonTaskSettled: (ref, receipt, timing) => this.binding.onTaskSettled?.(ref, receipt, timing),\n\t\t\tonTaskCleanupQuarantined: (ref, resources) => this.binding.onTaskCleanupQuarantined?.(ref, resources),\n\t\t\tdefaultHeartbeatMs: () =>\n\t\t\t\tthis.binding.heartbeat ? defaultTaskHeartbeatMs(this.binding.heartbeat) : undefined,\n\t\t\tcreateRunner: (context, intent) => {\n\t\t\t\tconst handoff = runners.getStore();\n\t\t\t\tconst runner = handoff?.factory;\n\t\t\t\tif (!handoff || !runner) throw new Error(\"Agent runner factory missing from launch context\");\n\t\t\t\thandoff.factory = undefined;\n\t\t\t\treturn runner(context, intent);\n\t\t\t},\n\t\t});\n\t\tconst opened = this.supervisor.openTaskOwner(host, binding.scope);\n\t\tif (!opened.ok) throw new Error(`${opened.error.code}: ${opened.error.message}`);\n\t\tthis.owner = opened.value;\n\t\t// One monitor per owner, whichever session currently binds it.\n\t\tthis.heartbeats = new TaskHeartbeatMonitor({\n\t\t\tsupervisor: this.supervisor,\n\t\t\towner: this.owner,\n\t\t\tdelivery: () => this.binding.heartbeat,\n\t\t});\n\t}\n\n\t/** One monitor per owner, started with its first launch, whichever session binds it then. */\n\tprivate watchHeartbeats(): void {\n\t\tif (this.launched && this.binding.heartbeat) outsideAnySession(() => this.heartbeats.start());\n\t}\n\n\tasync startAgentTask(\n\t\tintent: C.AgentIntent,\n\t\toperation: C.OperationId,\n\t\trunner: AgentTaskRunnerFactory,\n\t\tschedule?: (dispatch: () => Promise<void>) => void,\n\t): Promise<C.Result<{ taskId: C.TaskId; lease: TaskLease }, C.StartFailure>> {\n\t\tconst started = await runners.run({ factory: runner }, () =>\n\t\t\tthis.supervisor.startAgentTask(this.owner, intent, operation, schedule),\n\t\t);\n\t\tif (started.ok)\n\t\t\ttrackAdmittedAgentTask({ host: this, taskId: this.supervisor.taskReference(started.value).taskId });\n\t\treturn started.ok\n\t\t\t? {\n\t\t\t\t\tok: true as const,\n\t\t\t\t\tvalue: { taskId: this.supervisor.taskReference(started.value).taskId, lease: started.value },\n\t\t\t\t}\n\t\t\t: started;\n\t}\n\tresolveTask(taskId: C.TaskId): C.Result<TaskLease, C.WaitError> {\n\t\treturn this.supervisor.lookupTask(this.owner, taskId);\n\t}\n\t/**\n\t * Keeps a finished task's record past the finished-task retention until {@link releaseTaskRecord}, while its\n\t * completion notice is still being built (#4385). A task this owner does not hold, or never had, is left alone and\n\t * the refusal returned: a task the owner already evicted, also one it evicts while this call resolves it, refuses\n\t * with `TaskEvicted` (#4472).\n\t */\n\tretainTaskRecord(taskId: C.TaskId): C.Result<void, C.WaitError> {\n\t\tconst task = this.resolveTask(taskId);\n\t\treturn task.ok ? this.supervisor.retainTaskRecord(task.value) : task;\n\t}\n\t/** Ends a {@link retainTaskRecord} hold; a task this owner no longer keeps is left alone. */\n\treleaseTaskRecord(taskId: C.TaskId): void {\n\t\tconst task = this.resolveTask(taskId);\n\t\tif (task.ok) this.supervisor.releaseTaskRecord(task.value);\n\t}\n\n\tobserveAgentLaunch(\n\t\ttaskId: C.TaskId,\n\t\tpolicy?: C.WaitPolicy,\n\t\tonRegistered?: (yieldWait: (reason: C.YieldReason) => C.Result<C.WaitOutcome, C.YieldError>) => void,\n\t) {\n\t\tconst task = this.resolveTask(taskId);\n\t\treturn task.ok\n\t\t\t? this.supervisor.initialObservation(task.value, policy, (wait) => {\n\t\t\t\t\tif (policy?.kind === \"foreground\") this.trackMessageWait(wait);\n\t\t\t\t\tonRegistered?.((reason) => this.supervisor.yieldTaskWait(wait, reason));\n\t\t\t\t})\n\t\t\t: Promise.resolve(task);\n\t}\n\n\twaitForTask(taskId: C.TaskId, budgetMs?: number, onRegistered?: (wait: WaitLease) => void) {\n\t\treturn this.supervisor.waitForTaskId(this.owner, taskId, budgetMs, (wait) => {\n\t\t\tthis.trackMessageWait(wait);\n\t\t\tonRegistered?.(wait);\n\t\t});\n\t}\n\n\t/** The automatic foreground budget this owner gives a command wait that names none (bash's default); `undefined` waits until settled. */\n\tget commandWaitBudgetMs(): number | undefined {\n\t\treturn automaticWaitBudgetMs(this.binding.tasks?.wait, true);\n\t}\n\n\t/** Let inbound routing reach SDK admission instead of waiting for this owner to become idle. */\n\tget hasActiveTaskWaits(): boolean {\n\t\treturn this.messageWaits.size > 0;\n\t}\n\n\t/** Incoming owner messages release observation only, never the child execution. */\n\tyieldTaskWaits(reason: C.YieldReason): void {\n\t\tfor (const wait of this.messageWaits) this.supervisor.yieldTaskWait(wait, reason);\n\t}\n\n\tprivate trackMessageWait(wait: WaitLease): void {\n\t\tthis.messageWaits.add(wait);\n\t\tconst remove = () => this.messageWaits.delete(wait);\n\t\tvoid this.supervisor.observeTaskWait(wait).then(remove, remove);\n\t}\n\n\tcancelTask(taskId: C.TaskId, cause: C.CancelCause) {\n\t\tconst task = this.resolveTask(taskId);\n\t\treturn task.ok ? this.supervisor.cancelTask(task.value, cause) : Promise.resolve(task);\n\t}\n\n\twatchOwnerTasks(cursor?: C.Cursor) {\n\t\treturn this.supervisor.watchOwnerTasks(this.owner, cursor);\n\t}\n\n\t/** This owner's current records of the tasks `ids` names, or of all, without a fresh snapshot of them (#5186). */\n\ttaskRecords(ids?: ReadonlySet<C.TaskId>): readonly C.TaskRecord[] {\n\t\treturn this.supervisor.taskRecords(this.owner, ids);\n\t}\n\n\treportSettledTasks(): void {\n\t\tthis.supervisor.reportSettledTasks(this.owner);\n\t}\n\n\tclose(cause: C.OwnerCloseCause) {\n\t\tthis.heartbeats.dispose();\n\t\treturn this.supervisor.closeTaskOwner(this.owner, cause);\n\t}\n\n\t/** The error a failed close reports: a {@link TaskCleanupError} naming every unconfirmed resource when cleanup failed. */\n\tcloseError(phase: TaskCleanupPhase, failure: C.CloseError): Error {\n\t\tif (failure.code !== \"CleanupFailed\") return new Error(`${failure.code}: ${failure.message}`);\n\t\treturn new TaskCleanupError(phase, this.supervisor.failedTaskCleanups(this.owner), { cause: failure });\n\t}\n\n\tprivate tasksPaused = false;\n\t/** Reversible execution hold; message admission and owner identity remain open. */\n\tpauseTasks(): Promise<void> {\n\t\tthis.tasksPaused = true;\n\t\treturn cancelPausedOwnerTasks(this);\n\t}\n\tresumeTasks(): void {\n\t\tthis.tasksPaused = false;\n\t}\n\tprivate authorizeTaskLaunch(): void {\n\t\tif (this.tasksPaused) throw new Error(\"Workflow stage tasks are paused\");\n\t\tthis.launched = true;\n\t\tthis.watchHeartbeats();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-adapter.js","sourceRoot":"","sources":["../../../src/core/tasks/agent-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AAE7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC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AAK,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9F,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACxG,CAAC;IAEO,WAAW,GAAG,KAAK,CAAC;IAC5B,mFAAmF;IACnF,UAAU;QACT,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,WAAW;QACV,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1B,CAAC;IACO,mBAAmB;QAC1B,IAAI,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { TaskCleanupError, type TaskCleanupPhase } from \"./cleanup-error.js\";\nimport type * as C from \"./contracts.js\";\nimport { trackAdmittedAgentTask } from \"./execution-scope.js\";\nimport { defaultTaskHeartbeatMs, type TaskHeartbeatDelivery, TaskHeartbeatMonitor } from \"./heartbeat.js\";\nimport { cancelPausedOwnerTasks } from \"./pause.js\";\nimport {\n\tautomaticWaitBudgetMs,\n\ttype FakeExecution,\n\ttype FakeRunnerContext,\n\ttype OwnerLease,\n\ttype TaskLease,\n\tTaskSupervisor,\n\ttype TrustedTaskHost,\n\ttype WaitLease,\n} from \"./supervisor.js\";\n\nexport type AgentTaskRunnerFactory = (context: FakeRunnerContext, intent: C.AgentIntent) => FakeExecution;\nexport type AgentTaskHostBinding = Omit<TrustedTaskHost, \"createRunner\"> & {\n\t/** The owner's chat for periodic task heartbeats; omitted, the owner's tasks never heartbeat. */\n\theartbeat?: TaskHeartbeatDelivery;\n};\n\n/**\n * The runner factory of one launch, handed to its dispatch once. The task runs in this launch's async context, and on\n * Node 22 every promise it creates keeps that context's store, including promises that outlive the task, such as a\n * module it imports first or its owner's session write chain. So the store keeps the factory, and the launch input\n * it closes over, only until the dispatch takes it.\n */\ninterface RunnerHandoff {\n\tfactory: AgentTaskRunnerFactory | undefined;\n}\n\n// S1 converges repeated live-scope bindings on one owner, so dispatch context is shared too.\nconst runners = new AsyncLocalStorage<RunnerHandoff>();\n\n/**\n * Runs a callback in the async context of this module's load, outside every session. An owner can outlive the\n * session that first bound it (a workflow stage's), so what it keeps for its lifetime must not start in that\n * session's async context, which would keep the session reachable.\n */\nconst outsideAnySession = AsyncLocalStorage.snapshot();\n\n/** Internal trusted-host seam. Bind actual host identity, never model-supplied scope. */\nexport class AgentTaskHost {\n\tprivate readonly supervisor = new TaskSupervisor();\n\tprivate readonly owner;\n\tprivate binding: AgentTaskHostBinding;\n\tprivate readonly messageWaits = new Set<WaitLease>();\n\tprivate readonly heartbeats: TaskHeartbeatMonitor;\n\t/** Whether this owner has launched anything; owners that never do pay nothing for heartbeats. */\n\tprivate launched = false;\n\t/** Stage replacement updates callbacks, never native identity or ownership. */\n\tupdateBinding(binding: Omit<AgentTaskHostBinding, \"scope\">): void {\n\t\tthis.binding = { ...this.binding, ...binding };\n\t\tthis.watchHeartbeats();\n\t}\n\t/** Internal projection binding; never serialize these native-backed capabilities. */\n\tget ownerBinding(): { supervisor: TaskSupervisor; owner: OwnerLease; waitForTask: AgentTaskHost[\"waitForTask\"] } {\n\t\treturn { supervisor: this.supervisor, owner: this.owner, waitForTask: this.waitForTask.bind(this) };\n\t}\n\n\tconstructor(binding: AgentTaskHostBinding) {\n\t\tthis.binding = binding;\n\t\t// The native host keeps this binding as long as the owner lives; the heartbeat belongs to whichever session\n\t\t// binds the owner, so it reaches the monitor only through `updateBinding`.\n\t\tconst { heartbeat: _heartbeat, ...hostBinding } = binding;\n\t\tconst host = this.supervisor.bindHostSession({\n\t\t\t...hostBinding,\n\t\t\tauthorizeLaunch: (intent) => {\n\t\t\t\tthis.authorizeTaskLaunch();\n\t\t\t\tthis.binding.authorizeLaunch(intent);\n\t\t\t},\n\t\t\tauthorizeCommandLaunch: (intent, origin) => {\n\t\t\t\tthis.authorizeTaskLaunch();\n\t\t\t\tthis.binding.authorizeCommandLaunch?.(intent, origin);\n\t\t\t},\n\t\t\tonTaskSettled: (ref, receipt, timing) => this.binding.onTaskSettled?.(ref, receipt, timing),\n\t\t\tonTaskCleanupQuarantined: (ref, resources) => this.binding.onTaskCleanupQuarantined?.(ref, resources),\n\t\t\tdefaultHeartbeatMs: () =>\n\t\t\t\tthis.binding.heartbeat ? defaultTaskHeartbeatMs(this.binding.heartbeat) : undefined,\n\t\t\tcreateRunner: (context, intent) => {\n\t\t\t\tconst handoff = runners.getStore();\n\t\t\t\tconst runner = handoff?.factory;\n\t\t\t\tif (!handoff || !runner) throw new Error(\"Agent runner factory missing from launch context\");\n\t\t\t\thandoff.factory = undefined;\n\t\t\t\treturn runner(context, intent);\n\t\t\t},\n\t\t});\n\t\tconst opened = this.supervisor.openTaskOwner(host, binding.scope);\n\t\tif (!opened.ok) throw new Error(`${opened.error.code}: ${opened.error.message}`);\n\t\tthis.owner = opened.value;\n\t\t// One monitor per owner, whichever session currently binds it.\n\t\tthis.heartbeats = new TaskHeartbeatMonitor({\n\t\t\tsupervisor: this.supervisor,\n\t\t\towner: this.owner,\n\t\t\tdelivery: () => this.binding.heartbeat,\n\t\t});\n\t}\n\n\t/** One monitor per owner, started with its first launch, whichever session binds it then. */\n\tprivate watchHeartbeats(): void {\n\t\tif (this.launched && this.binding.heartbeat) outsideAnySession(() => this.heartbeats.start());\n\t}\n\n\tasync startAgentTask(\n\t\tintent: C.AgentIntent,\n\t\toperation: C.OperationId,\n\t\trunner: AgentTaskRunnerFactory,\n\t\tschedule?: (dispatch: () => Promise<void>) => void,\n\t): Promise<C.Result<{ taskId: C.TaskId; lease: TaskLease }, C.StartFailure>> {\n\t\tconst started = await runners.run({ factory: runner }, () =>\n\t\t\tthis.supervisor.startAgentTask(this.owner, intent, operation, schedule),\n\t\t);\n\t\tif (started.ok)\n\t\t\ttrackAdmittedAgentTask({ host: this, taskId: this.supervisor.taskReference(started.value).taskId });\n\t\treturn started.ok\n\t\t\t? {\n\t\t\t\t\tok: true as const,\n\t\t\t\t\tvalue: { taskId: this.supervisor.taskReference(started.value).taskId, lease: started.value },\n\t\t\t\t}\n\t\t\t: started;\n\t}\n\tresolveTask(taskId: C.TaskId): C.Result<TaskLease, C.WaitError> {\n\t\treturn this.supervisor.lookupTask(this.owner, taskId);\n\t}\n\t/**\n\t * Keeps a finished task's record past the finished-task retention until {@link releaseTaskRecord}, while its\n\t * completion notice is still being built (#4385). A task this owner does not hold, or never had, is left alone and\n\t * the refusal returned: a task the owner already evicted, also one it evicts while this call resolves it, refuses\n\t * with `TaskEvicted` (#4472).\n\t */\n\tretainTaskRecord(taskId: C.TaskId): C.Result<void, C.WaitError> {\n\t\tconst task = this.resolveTask(taskId);\n\t\treturn task.ok ? this.supervisor.retainTaskRecord(task.value) : task;\n\t}\n\t/** Ends a {@link retainTaskRecord} hold; a task this owner no longer keeps is left alone. */\n\treleaseTaskRecord(taskId: C.TaskId): void {\n\t\tconst task = this.resolveTask(taskId);\n\t\tif (task.ok) this.supervisor.releaseTaskRecord(task.value);\n\t}\n\n\t/**\n\t * The launch's observation of an agent task, which always runs in the background: it yields once registered, with\n\t * `explicit` when the launch asked for the background and `default-background` otherwise, also for any other policy\n\t * an untyped caller passes. Wait for the task explicitly with {@link waitForTask}.\n\t */\n\tobserveAgentLaunch(taskId: C.TaskId, policy?: { readonly kind: \"background\" }, onRegistered?: () => void) {\n\t\tconst task = this.resolveTask(taskId);\n\t\tconst background = policy?.kind === \"background\" ? policy : undefined;\n\t\treturn task.ok\n\t\t\t? this.supervisor.initialObservation(task.value, background, () => onRegistered?.())\n\t\t\t: Promise.resolve(task);\n\t}\n\n\t/**\n\t * Waits for the task to settle, until `budgetMs` (the owner's agent budget when omitted) yields the wait. An aborted\n\t * `signal` ends the wait at once with `ObserverCancelled`, as it does when it is already aborted; the task keeps running.\n\t */\n\twaitForTask(taskId: C.TaskId, budgetMs?: number, onRegistered?: (wait: WaitLease) => void, signal?: AbortSignal) {\n\t\tlet registered: WaitLease | undefined;\n\t\tconst stop = () => {\n\t\t\tif (registered) this.supervisor.disposeTaskWait(registered);\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", stop, { once: true });\n\t\treturn this.supervisor\n\t\t\t.waitForTaskId(this.owner, taskId, budgetMs, (wait) => {\n\t\t\t\tregistered = wait;\n\t\t\t\tthis.trackMessageWait(wait);\n\t\t\t\tonRegistered?.(wait);\n\t\t\t\tif (signal?.aborted) stop();\n\t\t\t})\n\t\t\t.finally(() => signal?.removeEventListener(\"abort\", stop));\n\t}\n\n\t/** The automatic foreground budget this owner gives a command wait that names none (bash's default); `undefined` waits until settled. */\n\tget commandWaitBudgetMs(): number | undefined {\n\t\treturn automaticWaitBudgetMs(this.binding.tasks?.wait, true);\n\t}\n\n\t/** Let inbound routing reach SDK admission instead of waiting for this owner to become idle. */\n\tget hasActiveTaskWaits(): boolean {\n\t\treturn this.messageWaits.size > 0;\n\t}\n\n\t/** Incoming owner messages release observation only, never the child execution. */\n\tyieldTaskWaits(reason: C.YieldReason): void {\n\t\tfor (const wait of this.messageWaits) this.supervisor.yieldTaskWait(wait, reason);\n\t}\n\n\tprivate trackMessageWait(wait: WaitLease): void {\n\t\tthis.messageWaits.add(wait);\n\t\tconst remove = () => this.messageWaits.delete(wait);\n\t\tvoid this.supervisor.observeTaskWait(wait).then(remove, remove);\n\t}\n\n\tcancelTask(taskId: C.TaskId, cause: C.CancelCause) {\n\t\tconst task = this.resolveTask(taskId);\n\t\treturn task.ok ? this.supervisor.cancelTask(task.value, cause) : Promise.resolve(task);\n\t}\n\n\twatchOwnerTasks(cursor?: C.Cursor) {\n\t\treturn this.supervisor.watchOwnerTasks(this.owner, cursor);\n\t}\n\n\t/** This owner's current records of the tasks `ids` names, or of all, without a fresh snapshot of them (#5186). */\n\ttaskRecords(ids?: ReadonlySet<C.TaskId>): readonly C.TaskRecord[] {\n\t\treturn this.supervisor.taskRecords(this.owner, ids);\n\t}\n\n\treportSettledTasks(): void {\n\t\tthis.supervisor.reportSettledTasks(this.owner);\n\t}\n\n\tclose(cause: C.OwnerCloseCause) {\n\t\tthis.heartbeats.dispose();\n\t\treturn this.supervisor.closeTaskOwner(this.owner, cause);\n\t}\n\n\t/** The error a failed close reports: a {@link TaskCleanupError} naming every unconfirmed resource when cleanup failed. */\n\tcloseError(phase: TaskCleanupPhase, failure: C.CloseError): Error {\n\t\tif (failure.code !== \"CleanupFailed\") return new Error(`${failure.code}: ${failure.message}`);\n\t\treturn new TaskCleanupError(phase, this.supervisor.failedTaskCleanups(this.owner), { cause: failure });\n\t}\n\n\tprivate tasksPaused = false;\n\t/** Reversible execution hold; message admission and owner identity remain open. */\n\tpauseTasks(): Promise<void> {\n\t\tthis.tasksPaused = true;\n\t\treturn cancelPausedOwnerTasks(this);\n\t}\n\tresumeTasks(): void {\n\t\tthis.tasksPaused = false;\n\t}\n\tprivate authorizeTaskLaunch(): void {\n\t\tif (this.tasksPaused) throw new Error(\"Workflow stage tasks are paused\");\n\t\tthis.launched = true;\n\t\tthis.watchHeartbeats();\n\t}\n}\n"]}
|