@bastani/atomic 0.9.38-alpha.5 → 0.9.38-alpha.7
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 +70 -0
- package/README.md +8 -6
- package/dist/builtin/intercom/CHANGELOG.md +9 -0
- package/dist/builtin/intercom/broker/broker.ts +6 -4
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +50 -4
- package/dist/builtin/intercom/broker/send-handler.ts +6 -4
- package/dist/builtin/intercom/index.bundle.mjs +78 -33
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +140 -145
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/index.bundle.mjs +53 -15
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +48 -0
- package/dist/builtin/workflows/builtin/{chunk-q7dx7kh7.js → chunk-85mx6wcf.js} +6 -6
- package/dist/builtin/workflows/builtin/{chunk-xg7kkgf8.js → chunk-8kkv04hz.js} +15 -15
- package/dist/builtin/workflows/builtin/{chunk-na3wpwzh.js → chunk-8x61e0s7.js} +396 -363
- package/dist/builtin/workflows/builtin/{chunk-qrrkfg9v.js → chunk-y45tkftg.js} +7 -7
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +3 -8
- package/dist/builtin/workflows/src/durable/journal/conformance.d.ts +9 -1
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +1 -0
- package/dist/builtin/workflows/src/durable/journal/lease-expiry.d.ts +2 -0
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +9 -1
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +19 -8
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +45 -0
- package/dist/builtin/workflows/src/durable/journal/sqlite-run-journal.d.ts +5 -47
- package/dist/builtin/workflows/src/durable/journal/types.d.ts +9 -114
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +6963 -6181
- package/dist/builtin/workflows/src/index.js +9078 -8395
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +8 -8
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +0 -14
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +35 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +2 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -5
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +2 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +2 -3
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +18 -10
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +6 -6
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +22 -22
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +10 -12
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +26 -14
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -2
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +75 -59
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +2 -2
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +17 -8
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +15 -15
- 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 +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +59 -42
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts +4 -4
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +16 -17
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +6 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +17 -15
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +7 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +88 -100
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-summary.js +1 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +7 -7
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -4
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +0 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.js +1 -3
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
- package/dist/core/export-html/index.js +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template-js/entries-navigation.js +1 -1
- package/dist/core/export-html/template.js +1 -1
- package/dist/core/extensions/api-types.d.ts +12 -12
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +4 -2
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/extension-work.d.ts +1 -0
- package/dist/core/extensions/extension-work.d.ts.map +1 -1
- package/dist/core/extensions/extension-work.js +5 -1
- package/dist/core/extensions/extension-work.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +40 -42
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +6 -2
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +1 -0
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +1 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +10 -3
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-handlers.d.ts +1 -1
- package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
- package/dist/core/extensions/runner-handlers.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -12
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +7 -7
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/session-events.d.ts +5 -5
- package/dist/core/extensions/session-events.d.ts.map +1 -1
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +1 -0
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/intercom-runtime-group.js +1 -1
- package/dist/core/intercom-runtime-group.js.map +1 -1
- package/dist/core/model-config.d.ts +765 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +46 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +1 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +4 -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 +50 -20
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-work.d.ts +3 -0
- package/dist/core/session-lifecycle-work.d.ts.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -0
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts +2 -16
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +8 -104
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +53 -51
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +547 -307
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +5 -10
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-errors.d.ts +10 -0
- package/dist/core/session-manager-errors.d.ts.map +1 -0
- package/dist/core/session-manager-errors.js +27 -0
- package/dist/core/session-manager-errors.js.map +1 -0
- package/dist/core/session-manager-list.d.ts +1 -0
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +21 -14
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +3 -13
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +28 -69
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -11
- 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-manager-validation.d.ts.map +1 -1
- package/dist/core/session-manager-validation.js +3 -2
- package/dist/core/session-manager-validation.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-mutation-queue.d.ts +3 -0
- package/dist/core/session-mutation-queue.d.ts.map +1 -0
- package/dist/core/session-mutation-queue.js +14 -0
- package/dist/core/session-mutation-queue.js.map +1 -0
- package/dist/core/session-resume-args.d.ts +4 -0
- package/dist/core/session-resume-args.d.ts.map +1 -0
- package/dist/core/session-resume-args.js +9 -0
- package/dist/core/session-resume-args.js.map +1 -0
- package/dist/core/session-storage.d.ts +26 -0
- package/dist/core/session-storage.d.ts.map +1 -0
- package/dist/core/session-storage.js +155 -0
- package/dist/core/session-storage.js.map +1 -0
- package/dist/core/session-store-list.d.ts +4 -0
- package/dist/core/session-store-list.d.ts.map +1 -0
- package/dist/core/session-store-list.js +28 -0
- package/dist/core/session-store-list.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts +0 -1
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +0 -5
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +8 -2
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-schema.d.ts +74 -8
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +29 -29
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/errors.d.ts +1 -0
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/index.d.ts +5 -1
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +4 -1
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts +2 -0
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +47 -6
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/provider.d.ts +58 -0
- package/dist/core/storage/provider.d.ts.map +1 -0
- package/dist/core/storage/provider.js +243 -0
- package/dist/core/storage/provider.js.map +1 -0
- package/dist/core/storage/run-journal.d.ts +93 -0
- package/dist/core/storage/run-journal.d.ts.map +1 -0
- package/dist/core/storage/run-journal.js +15 -0
- package/dist/core/storage/run-journal.js.map +1 -0
- package/dist/core/storage/selection.d.ts +16 -0
- package/dist/core/storage/selection.d.ts.map +1 -0
- package/dist/core/storage/selection.js +87 -0
- package/dist/core/storage/selection.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +11 -2
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +127 -54
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/storage/session/legacy-format.d.ts +18 -0
- package/dist/core/storage/session/legacy-format.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-format.js +63 -0
- package/dist/core/storage/session/legacy-format.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.d.ts +3 -1
- package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/memory-session-store.js +9 -2
- package/dist/core/storage/session/memory-session-store.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +4 -1
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +25 -6
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/storage/session/types.d.ts +4 -0
- package/dist/core/storage/session/types.d.ts.map +1 -1
- package/dist/core/storage/session/types.js.map +1 -1
- package/dist/core/storage/session/validation.js +1 -1
- package/dist/core/storage/session/validation.js.map +1 -1
- package/dist/core/storage/testing.d.ts +2 -0
- package/dist/core/storage/testing.d.ts.map +1 -1
- package/dist/core/storage/testing.js +45 -0
- package/dist/core/storage/testing.js.map +1 -1
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +2 -4
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
- package/dist/core/tools/bash-session-environment.js +0 -2
- package/dist/core/tools/bash-session-environment.js.map +1 -1
- package/dist/core/tools/read-url.d.ts.map +1 -1
- package/dist/core/tools/read-url.js +6 -1
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/core/tools/todos-model.js +3 -3
- package/dist/core/tools/todos-model.js.map +1 -1
- package/dist/core/tools/todos-mutations.js +2 -2
- package/dist/core/tools/todos-mutations.js.map +1 -1
- package/dist/core/tools/todos-render.js +1 -1
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/todos-storage.js +2 -2
- package/dist/core/tools/todos-storage.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +14 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +6 -8
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/mcp/index.js +1 -1
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +6 -1
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +12 -2
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +148 -53
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +97 -42
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +3 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +16 -7
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +1 -1
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +4 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +12 -9
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +27 -25
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +8 -4
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +27 -18
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +5 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +20 -3
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +2 -2
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +2 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +6 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +7 -3
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -5
- 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.js +12 -7
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +2 -2
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +38 -14
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +5 -3
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +11 -4
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +99 -74
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +2 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -2
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +20 -7
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +6 -2
- 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 +12 -9
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +2 -2
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.js +11 -2
- package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +6 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/canonical-path.d.ts +5 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +26 -0
- package/dist/utils/canonical-path.js.map +1 -0
- package/dist/utils/paths.d.ts +1 -7
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +1 -15
- package/dist/utils/paths.js.map +1 -1
- package/docs/codemode.md +2 -0
- package/docs/compaction.md +2 -2
- package/docs/custom-provider/oauth.md +2 -2
- package/docs/custom-provider/override.md +3 -3
- package/docs/custom-provider/registration.md +7 -7
- package/docs/custom-provider/streaming.md +1 -1
- package/docs/custom-provider.md +5 -5
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +10 -2
- package/docs/extensions/api-reference.md +40 -19
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/events.md +8 -8
- package/docs/extensions.md +2 -2
- package/docs/getting-started/installation.md +1 -2
- package/docs/models/reference.md +2 -0
- package/docs/models-configuration.md +206 -0
- package/docs/models.md +11 -1
- package/docs/providers.md +4 -4
- package/docs/quickstart.md +2 -1
- package/docs/reference/cli.md +7 -3
- package/docs/rpc/protocol.md +10 -4
- package/docs/sdk/reference.md +15 -13
- package/docs/sdk/web-server.md +5 -6
- package/docs/sdk.md +56 -2
- package/docs/session-format.md +35 -28
- package/docs/sessions.md +50 -17
- package/docs/settings.md +44 -7
- package/docs/storage.md +346 -2
- package/docs/usage.md +3 -2
- package/docs/workflows/api-reference.md +80 -16
- package/docs/workflows/operations.md +6 -4
- package/docs/workflows/reliable-design.md +16 -16
- package/examples/extensions/bookmark.ts +2 -2
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +15 -13
- package/examples/extensions/preset.ts +8 -8
- package/examples/extensions/session-name.ts +1 -1
- package/examples/extensions/snake.ts +3 -1
- package/examples/extensions/space-invaders.ts +3 -1
- package/examples/extensions/tic-tac-toe.ts +80 -80
- package/examples/sdk/11-sessions.ts +5 -5
- package/examples/sdk/13-session-runtime.ts +7 -7
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +53 -53
- package/package.json +7 -6
- package/schemas/models.schema.json +62 -29
- package/schemas/settings.schema.json +137 -53
- package/dist/builtin/workflows/builtin/chunk-h5fn47y5.js +0 -8
- package/dist/builtin/workflows/src/durable/journal/node-sqlite.d.ts +0 -20
|
@@ -10,65 +10,358 @@ import {
|
|
|
10
10
|
scoring_prompt_reads,
|
|
11
11
|
build_scoring_prompt
|
|
12
12
|
} from "./chunk-2377r57g.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
// dist/builtin/workflows/src/shared/workflow-artifacts.ts
|
|
15
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
16
|
+
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { getAgentDir, getEnvValue } from "@bastani/atomic";
|
|
19
|
+
|
|
20
|
+
// dist/builtin/workflows/src/shared/run-id.ts
|
|
21
|
+
var RUN_ID_LENGTH = 36;
|
|
22
|
+
var RUN_ID_PREFIX_LENGTH = 8;
|
|
23
|
+
var RUN_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
24
|
+
var RUN_ID_PREFIX_PATTERN = /^[0-9a-f]{8}$/i;
|
|
25
|
+
function isFullRunId(value) {
|
|
26
|
+
return RUN_ID_PATTERN.test(value);
|
|
27
|
+
}
|
|
28
|
+
function isRunIdPrefix(value) {
|
|
29
|
+
return RUN_ID_PREFIX_PATTERN.test(value);
|
|
30
|
+
}
|
|
31
|
+
function resolveRunIdTarget(target, runIds) {
|
|
32
|
+
const ids = [...new Set(runIds)];
|
|
33
|
+
if (isFullRunId(target)) {
|
|
34
|
+
const exact = ids.find((id) => id === target);
|
|
35
|
+
return exact === undefined ? { kind: "not_found" } : { kind: "exact", runId: exact };
|
|
36
|
+
}
|
|
37
|
+
if (!isRunIdPrefix(target))
|
|
38
|
+
return { kind: "malformed", message: malformedRunIdMessage(target) };
|
|
39
|
+
const normalized = target.toLowerCase();
|
|
40
|
+
const matches = ids.filter((id) => isFullRunId(id) && id.toLowerCase().startsWith(normalized));
|
|
41
|
+
if (matches.length === 0)
|
|
42
|
+
return { kind: "not_found" };
|
|
43
|
+
if (matches.length === 1)
|
|
44
|
+
return { kind: "unique_prefix", runId: matches[0] };
|
|
45
|
+
return { kind: "ambiguous", matches, message: ambiguousRunIdMessage(target, matches) };
|
|
46
|
+
}
|
|
47
|
+
function ambiguousRunIdMessage(target, matches) {
|
|
48
|
+
return `Run id prefix "${target}" is ambiguous; matches: ${matches.join(", ")}. Use the full UUID.`;
|
|
49
|
+
}
|
|
50
|
+
function malformedRunIdMessage(target) {
|
|
51
|
+
return `Run id must be a full ${RUN_ID_LENGTH}-character UUID or a unique ${RUN_ID_PREFIX_LENGTH}-character hexadecimal prefix; got "${target}" (${target.length} chars).`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// dist/builtin/workflows/src/shared/workflow-run-ownership.ts
|
|
55
|
+
function authoritativeWorkflowChildRunId(stage) {
|
|
56
|
+
if (stage === undefined || stage.status === "failed" || stage.status === "skipped") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (stage.status === "completed") {
|
|
60
|
+
return stage.workflowChild?.runId ?? stage.workflowChildRun?.runId;
|
|
61
|
+
}
|
|
62
|
+
return stage.workflowChildRun?.runId;
|
|
63
|
+
}
|
|
64
|
+
function reciprocalWorkflowRootRunId(runById, runId) {
|
|
65
|
+
const visited = new Set;
|
|
66
|
+
const declaredRoots = [];
|
|
67
|
+
let current = runById.get(runId);
|
|
68
|
+
while (current !== undefined) {
|
|
69
|
+
const currentId = current.id;
|
|
70
|
+
if (visited.has(currentId))
|
|
71
|
+
return;
|
|
72
|
+
visited.add(currentId);
|
|
73
|
+
if (current.rootRunId !== undefined)
|
|
74
|
+
declaredRoots.push(current.rootRunId);
|
|
75
|
+
const parentRunId = current.parentRunId;
|
|
76
|
+
const parentStageId = current.parentStageId;
|
|
77
|
+
if (parentRunId === undefined !== (parentStageId === undefined))
|
|
78
|
+
return;
|
|
79
|
+
if (parentRunId === undefined || parentStageId === undefined) {
|
|
80
|
+
return declaredRoots.every((declared) => declared === currentId) ? currentId : undefined;
|
|
81
|
+
}
|
|
82
|
+
const parent = runById.get(parentRunId);
|
|
83
|
+
const boundary = parent?.stages.find((stage) => stage.id === parentStageId);
|
|
84
|
+
if (parent === undefined || authoritativeWorkflowChildRunId(boundary) !== currentId) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
current = parent;
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// dist/builtin/workflows/src/durable/prompt-reservations.ts
|
|
93
|
+
function durablePromptScope(backend, workflowId) {
|
|
94
|
+
return backend.promptReservationScope(workflowId);
|
|
95
|
+
}
|
|
96
|
+
function claimDurablePromptToken(backend, workflowId, reservationId) {
|
|
97
|
+
return backend.pendingPromptToken(workflowId, reservationId);
|
|
98
|
+
}
|
|
99
|
+
function reserveDurablePrompt(backend, workflowId, reservationId) {
|
|
100
|
+
return backend.reservePendingPrompt(workflowId, reservationId);
|
|
101
|
+
}
|
|
102
|
+
function releaseDurablePrompt(backend, workflowId, reservationId, token) {
|
|
103
|
+
return backend.releasePendingPrompt(workflowId, reservationId, token);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// dist/builtin/workflows/src/durable/scoped-backend.ts
|
|
107
|
+
class ScopedDurableBackend {
|
|
108
|
+
persistent;
|
|
109
|
+
inner;
|
|
110
|
+
scope;
|
|
111
|
+
constructor(inner, scope) {
|
|
112
|
+
this.inner = inner;
|
|
113
|
+
this.scope = scope;
|
|
114
|
+
this.persistent = inner.persistent;
|
|
115
|
+
}
|
|
116
|
+
async archivePendingStageMessage(_workflowId, entry) {
|
|
117
|
+
await this.inner.archivePendingStageMessage?.(this.scope.rootWorkflowId, entry);
|
|
118
|
+
}
|
|
119
|
+
async readSettledPendingStageMessage(workflowId, messageId, logicalRunId = workflowId) {
|
|
120
|
+
return this.inner.readSettledPendingStageMessage?.(this.scope.rootWorkflowId, messageId, logicalRunId);
|
|
121
|
+
}
|
|
122
|
+
getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
|
|
123
|
+
return this.inner.getPendingStageMessageDeliveryCount?.(this.scope.rootWorkflowId, messageId, logicalRunId) ?? 0;
|
|
124
|
+
}
|
|
125
|
+
async readPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
|
|
126
|
+
return this.inner.readPendingStageMessageDeliveryCount === undefined ? this.getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId) : await this.inner.readPendingStageMessageDeliveryCount(this.scope.rootWorkflowId, messageId, logicalRunId);
|
|
127
|
+
}
|
|
128
|
+
async archivePendingStageDeliveryReceipt(_workflowId, messageId, delivery, accounting) {
|
|
129
|
+
await this.inner.archivePendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, accounting);
|
|
130
|
+
}
|
|
131
|
+
hasCachedPendingStageDeliveryReceipt(workflowId, messageId, delivery, anySession = false, logicalRunId = workflowId) {
|
|
132
|
+
return this.inner.hasCachedPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, anySession, logicalRunId) ?? false;
|
|
133
|
+
}
|
|
134
|
+
async hasPendingStageDeliveryReceipt(workflowId, messageId, delivery, logicalRunId = workflowId) {
|
|
135
|
+
return await this.inner.hasPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, logicalRunId) ?? false;
|
|
136
|
+
}
|
|
137
|
+
async commitWorkflowRegistration(_handle) {}
|
|
138
|
+
persistPendingStageMessages(workflowId, messages, logicalRunId = workflowId) {
|
|
139
|
+
return this.inner.persistPendingStageMessages(this.scope.rootWorkflowId, messages, logicalRunId);
|
|
140
|
+
}
|
|
141
|
+
async commitCheckpoint(checkpoint, options) {
|
|
142
|
+
await this.inner.commitCheckpoint(this.remap(checkpoint), options);
|
|
143
|
+
}
|
|
144
|
+
async commitAdditiveCheckpointBestEffort(checkpoint) {
|
|
145
|
+
return await this.inner.commitAdditiveCheckpointBestEffort(this.remap(checkpoint));
|
|
146
|
+
}
|
|
147
|
+
workflowOwnership(_workflowId) {
|
|
148
|
+
return this.inner.workflowOwnership(this.scope.rootWorkflowId);
|
|
149
|
+
}
|
|
150
|
+
getToolOutput(_workflowId, argsHash) {
|
|
151
|
+
return this.inner.getToolOutput(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
152
|
+
}
|
|
153
|
+
getToolCheckpoint(_workflowId, argsHash) {
|
|
154
|
+
return this.inner.getToolCheckpoint(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
155
|
+
}
|
|
156
|
+
getUiResponse(_workflowId, promptHash) {
|
|
157
|
+
return this.inner.getUiResponse(this.scope.rootWorkflowId, this.scopeKey(promptHash));
|
|
158
|
+
}
|
|
159
|
+
getStageOutput(_workflowId, replayKey) {
|
|
160
|
+
return this.inner.getStageOutput(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
161
|
+
}
|
|
162
|
+
getStageSession(_workflowId, replayKey) {
|
|
163
|
+
return this.inner.getStageSession(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
164
|
+
}
|
|
165
|
+
listCheckpoints(workflowId) {
|
|
166
|
+
const prefix = `${this.scope.scopePrefix}:`;
|
|
167
|
+
return this.inner.listCheckpoints(this.scope.rootWorkflowId).filter((checkpoint) => checkpointHasPrefix(checkpoint, prefix)).map((checkpoint) => localCheckpoint(checkpoint, workflowId, prefix));
|
|
168
|
+
}
|
|
169
|
+
getWorkflow(_workflowId) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
getLoadableWorkflow(_workflowId) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
async commitWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
|
|
176
|
+
async commitWorkflowStatusTransition(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
commitPendingPromptAdjustment(_workflowId, delta) {
|
|
180
|
+
return this.inner.commitPendingPromptAdjustment(this.scope.rootWorkflowId, delta);
|
|
181
|
+
}
|
|
182
|
+
promptReservationScope(_workflowId) {
|
|
183
|
+
return this.effectivePromptScope();
|
|
184
|
+
}
|
|
185
|
+
pendingPromptToken(_workflowId, reservationId) {
|
|
186
|
+
return claimDurablePromptToken(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
187
|
+
}
|
|
188
|
+
reservePendingPrompt(_workflowId, reservationId) {
|
|
189
|
+
return reserveDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
190
|
+
}
|
|
191
|
+
releasePendingPrompt(_workflowId, reservationId, token) {
|
|
192
|
+
return releaseDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId, token);
|
|
193
|
+
}
|
|
194
|
+
listResumableWorkflows() {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
listCompletedWorkflows() {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
async prepareWorkflowCatalog() {
|
|
201
|
+
return { resumable: [], completed: [] };
|
|
202
|
+
}
|
|
203
|
+
toMetadata(_workflowId) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
async deleteWorkflow(_workflowId) {}
|
|
207
|
+
async deleteWorkflowIfInactive(_workflowId) {
|
|
208
|
+
return { ok: false, reason: "not_found" };
|
|
209
|
+
}
|
|
210
|
+
isWorkflowLoadable(_workflowId) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
async commitReset() {}
|
|
214
|
+
hydrateWorkflow(_workflowId) {
|
|
215
|
+
return Promise.resolve();
|
|
216
|
+
}
|
|
217
|
+
hydrateResumableWorkflows() {
|
|
218
|
+
return Promise.resolve();
|
|
219
|
+
}
|
|
220
|
+
effectivePromptScope() {
|
|
221
|
+
const parent = durablePromptScope(this.inner, this.scope.rootWorkflowId);
|
|
222
|
+
const scope = parent.scope === "root" ? this.scope.scopePrefix : `${parent.scope}:${this.scope.scopePrefix}`;
|
|
223
|
+
return {
|
|
224
|
+
rootWorkflowId: parent.rootWorkflowId,
|
|
225
|
+
scope
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
scopeKey(key) {
|
|
229
|
+
return `${this.scope.scopePrefix}:${key}`;
|
|
230
|
+
}
|
|
231
|
+
remap(checkpoint) {
|
|
232
|
+
const workflowId = this.scope.rootWorkflowId;
|
|
233
|
+
if (checkpoint.kind === "tool") {
|
|
234
|
+
return {
|
|
235
|
+
...checkpoint,
|
|
236
|
+
workflowId,
|
|
237
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
238
|
+
argsHash: this.scopeKey(checkpoint.argsHash)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (checkpoint.kind === "ui") {
|
|
242
|
+
return {
|
|
243
|
+
...checkpoint,
|
|
244
|
+
workflowId,
|
|
245
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
246
|
+
promptHash: this.scopeKey(checkpoint.promptHash)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
...checkpoint,
|
|
251
|
+
workflowId,
|
|
252
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
253
|
+
replayKey: this.scopeKey(checkpoint.replayKey),
|
|
254
|
+
...remappedBoundaryScope(checkpoint, this.scopeKey(checkpoint.topology?.boundary?.replayScope ?? ""))
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function checkpointHasPrefix(checkpoint, prefix) {
|
|
259
|
+
if (!checkpoint.checkpointId.startsWith(prefix))
|
|
260
|
+
return false;
|
|
261
|
+
if (checkpoint.kind === "tool")
|
|
262
|
+
return checkpoint.argsHash.startsWith(prefix);
|
|
263
|
+
if (checkpoint.kind === "ui")
|
|
264
|
+
return checkpoint.promptHash.startsWith(prefix);
|
|
265
|
+
return checkpoint.replayKey.startsWith(prefix);
|
|
266
|
+
}
|
|
267
|
+
function localCheckpoint(checkpoint, workflowId, prefix) {
|
|
268
|
+
const checkpointId = checkpoint.checkpointId.slice(prefix.length);
|
|
269
|
+
if (checkpoint.kind === "tool") {
|
|
270
|
+
return { ...checkpoint, workflowId, checkpointId, argsHash: checkpoint.argsHash.slice(prefix.length) };
|
|
271
|
+
}
|
|
272
|
+
if (checkpoint.kind === "ui") {
|
|
273
|
+
return { ...checkpoint, workflowId, checkpointId, promptHash: checkpoint.promptHash.slice(prefix.length) };
|
|
274
|
+
}
|
|
275
|
+
const replayKey = checkpoint.replayKey.slice(prefix.length);
|
|
276
|
+
const replayScope = stripOnePrefix(checkpoint.topology?.boundary?.replayScope, prefix);
|
|
16
277
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
278
|
+
...checkpoint,
|
|
279
|
+
workflowId,
|
|
280
|
+
checkpointId,
|
|
281
|
+
replayKey,
|
|
282
|
+
...remappedBoundaryScope(checkpoint, replayScope)
|
|
21
283
|
};
|
|
22
284
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
285
|
+
function remappedBoundaryScope(checkpoint, replayScope) {
|
|
286
|
+
const topology = checkpoint.topology;
|
|
287
|
+
if (topology?.boundary === undefined || replayScope === undefined)
|
|
288
|
+
return {};
|
|
289
|
+
return {
|
|
290
|
+
topology: {
|
|
291
|
+
...topology,
|
|
292
|
+
boundary: { ...topology.boundary, replayScope }
|
|
293
|
+
}
|
|
294
|
+
};
|
|
25
295
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return existing;
|
|
31
|
-
const created = emptyOwner();
|
|
32
|
-
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
33
|
-
return created;
|
|
296
|
+
function stripOnePrefix(value, prefix) {
|
|
297
|
+
if (value === undefined || !value.startsWith(prefix))
|
|
298
|
+
return value;
|
|
299
|
+
return value.slice(prefix.length);
|
|
34
300
|
}
|
|
35
301
|
|
|
36
|
-
// dist/builtin/workflows/src/durable/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
302
|
+
// dist/builtin/workflows/src/durable/run-owner-backend.ts
|
|
303
|
+
var workflowRunBackend = Symbol.for("atomic-workflows/run-journal-backend@1");
|
|
304
|
+
function availableRunDurableBackend(runs, runId) {
|
|
305
|
+
const target = resolveRunIdTarget(runId, runs.map((run) => run.id));
|
|
306
|
+
const id = target.kind === "exact" || target.kind === "unique_prefix" ? target.runId : runId;
|
|
307
|
+
const rootRunId = durableRootRunIdForRun(runs, id);
|
|
308
|
+
return runs.find((run) => run.id === rootRunId)?.[workflowRunBackend];
|
|
309
|
+
}
|
|
310
|
+
function durableRootRunIdForRun(runs, runId) {
|
|
311
|
+
return reciprocalWorkflowRootRunId(new Map(runs.map((run) => [run.id, run])), runId);
|
|
312
|
+
}
|
|
313
|
+
function durableBackendForRun(backend, runs, runId) {
|
|
314
|
+
const rootRunId = durableRootRunIdForRun(runs, runId);
|
|
315
|
+
if (rootRunId === undefined)
|
|
316
|
+
return;
|
|
317
|
+
const runById = new Map(runs.map((run) => [run.id, run]));
|
|
318
|
+
const rootBackend = availableRunDurableBackend(runs, rootRunId) ?? backend;
|
|
319
|
+
if (rootRunId === runId)
|
|
320
|
+
return rootBackend;
|
|
321
|
+
const scopes = [];
|
|
322
|
+
let current = runById.get(runId);
|
|
323
|
+
while (current !== undefined && current.id !== rootRunId) {
|
|
324
|
+
const parent = current.parentRunId === undefined ? undefined : runById.get(current.parentRunId);
|
|
325
|
+
const boundary = parent?.stages.find((stage) => stage.id === current?.parentStageId);
|
|
326
|
+
if (parent === undefined || boundary?.replayKey === undefined)
|
|
327
|
+
return;
|
|
328
|
+
scopes.push(boundary.replayKey);
|
|
329
|
+
current = parent;
|
|
330
|
+
}
|
|
331
|
+
if (current?.id !== rootRunId)
|
|
332
|
+
return;
|
|
333
|
+
let view = rootBackend;
|
|
334
|
+
for (const scopePrefix of scopes.reverse()) {
|
|
335
|
+
view = new ScopedDurableBackend(view, { rootWorkflowId: rootRunId, scopePrefix });
|
|
336
|
+
}
|
|
337
|
+
return view;
|
|
338
|
+
}
|
|
41
339
|
|
|
42
340
|
// dist/builtin/workflows/src/durable/journal/types.ts
|
|
341
|
+
import { StorageSchemaVersionError } from "@bastani/atomic/storage";
|
|
342
|
+
import { StorageUnavailableError } from "@bastani/atomic/storage";
|
|
343
|
+
import { RUN_EVENT_TYPES } from "@bastani/atomic/storage";
|
|
43
344
|
class JournalError extends Error {
|
|
44
345
|
}
|
|
45
346
|
|
|
46
|
-
// dist/builtin/workflows/src/durable/
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
// dist/builtin/workflows/src/durable/factory.ts
|
|
347
|
+
// dist/builtin/workflows/src/durable/store-backend.ts
|
|
348
|
+
var workflowStoreBackend = Symbol.for("atomic-workflows/store-journal-backend@1");
|
|
349
|
+
var workflowStoreBackendOverride = Symbol.for("atomic-workflows/store-journal-override@1");
|
|
51
350
|
class DurableBackendNotInitializedError extends JournalError {
|
|
52
351
|
constructor() {
|
|
53
352
|
super("Workflow journal has not been initialized");
|
|
54
353
|
this.name = "DurableBackendNotInitializedError";
|
|
55
354
|
}
|
|
56
355
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
356
|
+
function availableStoreDurableBackend(store, runId) {
|
|
357
|
+
return (store !== undefined && runId !== undefined ? availableRunDurableBackend(store.runs(), runId) : undefined) ?? store?.[workflowStoreBackend];
|
|
358
|
+
}
|
|
359
|
+
function requireStoreDurableBackend(store, runId) {
|
|
360
|
+
const backend = availableStoreDurableBackend(store, runId);
|
|
59
361
|
if (backend === undefined)
|
|
60
362
|
throw new DurableBackendNotInitializedError;
|
|
61
363
|
return backend;
|
|
62
364
|
}
|
|
63
|
-
function getAvailableDurableBackend2() {
|
|
64
|
-
const owner = getDurableBackendProcessOwner();
|
|
65
|
-
return owner.injectedBackend ?? owner.initializedBackend;
|
|
66
|
-
}
|
|
67
|
-
// dist/builtin/workflows/src/shared/workflow-artifacts.ts
|
|
68
|
-
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
69
|
-
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
70
|
-
import { dirname, join } from "node:path";
|
|
71
|
-
import { getAgentDir as getAgentDir2, getEnvValue } from "@bastani/atomic";
|
|
72
365
|
|
|
73
366
|
// dist/builtin/workflows/src/shared/pending-stage-delivery.ts
|
|
74
367
|
var PENDING_STAGE_MESSAGE_LIMIT = 50;
|
|
@@ -347,6 +640,27 @@ function normalizeDeliveryGroup(value) {
|
|
|
347
640
|
const trimmed = value.trim();
|
|
348
641
|
return trimmed.length > 0 ? trimmed : "default";
|
|
349
642
|
}
|
|
643
|
+
// dist/builtin/workflows/src/durable/backend-process-owner.ts
|
|
644
|
+
var DURABLE_BACKEND_PROCESS_OWNER_KEY = Symbol.for("atomic-workflows/durable-backend-process-owner@1");
|
|
645
|
+
function emptyOwner() {
|
|
646
|
+
return {
|
|
647
|
+
version: 1,
|
|
648
|
+
injectedBackend: undefined
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
function ownerBag() {
|
|
652
|
+
return globalThis;
|
|
653
|
+
}
|
|
654
|
+
function getDurableBackendProcessOwner() {
|
|
655
|
+
const bag = ownerBag();
|
|
656
|
+
const existing = bag[DURABLE_BACKEND_PROCESS_OWNER_KEY];
|
|
657
|
+
if (existing !== undefined && existing.version === 1)
|
|
658
|
+
return existing;
|
|
659
|
+
const created = emptyOwner();
|
|
660
|
+
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
661
|
+
return created;
|
|
662
|
+
}
|
|
663
|
+
|
|
350
664
|
// dist/builtin/workflows/src/shared/session-scoped-singleton.ts
|
|
351
665
|
import { sessionScopedExtensionState } from "@bastani/atomic";
|
|
352
666
|
var SHARED_STATES_KEY = Symbol.for("atomic-workflows/session-scoped-singleton-pre-adoption@1");
|
|
@@ -397,6 +711,9 @@ function createSessionScopedSingleton(key, createLocal) {
|
|
|
397
711
|
}
|
|
398
712
|
return value;
|
|
399
713
|
},
|
|
714
|
+
set(_target, prop, value) {
|
|
715
|
+
return Reflect.set(live(), prop, value, live());
|
|
716
|
+
},
|
|
400
717
|
has(_target, prop) {
|
|
401
718
|
return Reflect.has(live(), prop);
|
|
402
719
|
}
|
|
@@ -751,69 +1068,31 @@ function compactRun(run) {
|
|
|
751
1068
|
};
|
|
752
1069
|
}
|
|
753
1070
|
function createGraphStoreSnapshot(runs, notices, version) {
|
|
754
|
-
const snapshot = {
|
|
755
|
-
runs: runs.map(compactRun),
|
|
756
|
-
notices: notices.map((notice) => ({ ...notice })),
|
|
757
|
-
version
|
|
758
|
-
};
|
|
759
|
-
deepFreezeGraphValue(snapshot);
|
|
760
|
-
return snapshot;
|
|
761
|
-
}
|
|
762
|
-
function deepFreezeGraphValue(value) {
|
|
763
|
-
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
764
|
-
return;
|
|
765
|
-
Object.freeze(value);
|
|
766
|
-
if (Array.isArray(value)) {
|
|
767
|
-
for (const item of value)
|
|
768
|
-
deepFreezeGraphValue(item);
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
for (const key of Object.keys(value)) {
|
|
772
|
-
deepFreezeGraphValue(value[key]);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
|
|
777
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
778
|
-
|
|
779
|
-
// dist/builtin/workflows/src/shared/workflow-run-ownership.ts
|
|
780
|
-
function authoritativeWorkflowChildRunId(stage) {
|
|
781
|
-
if (stage === undefined || stage.status === "failed" || stage.status === "skipped") {
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
if (stage.status === "completed") {
|
|
785
|
-
return stage.workflowChild?.runId ?? stage.workflowChildRun?.runId;
|
|
786
|
-
}
|
|
787
|
-
return stage.workflowChildRun?.runId;
|
|
788
|
-
}
|
|
789
|
-
function reciprocalWorkflowRootRunId(runById, runId) {
|
|
790
|
-
const visited = new Set;
|
|
791
|
-
const declaredRoots = [];
|
|
792
|
-
let current = runById.get(runId);
|
|
793
|
-
while (current !== undefined) {
|
|
794
|
-
const currentId = current.id;
|
|
795
|
-
if (visited.has(currentId))
|
|
796
|
-
return;
|
|
797
|
-
visited.add(currentId);
|
|
798
|
-
if (current.rootRunId !== undefined)
|
|
799
|
-
declaredRoots.push(current.rootRunId);
|
|
800
|
-
const parentRunId = current.parentRunId;
|
|
801
|
-
const parentStageId = current.parentStageId;
|
|
802
|
-
if (parentRunId === undefined !== (parentStageId === undefined))
|
|
803
|
-
return;
|
|
804
|
-
if (parentRunId === undefined || parentStageId === undefined) {
|
|
805
|
-
return declaredRoots.every((declared) => declared === currentId) ? currentId : undefined;
|
|
806
|
-
}
|
|
807
|
-
const parent = runById.get(parentRunId);
|
|
808
|
-
const boundary = parent?.stages.find((stage) => stage.id === parentStageId);
|
|
809
|
-
if (parent === undefined || authoritativeWorkflowChildRunId(boundary) !== currentId) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
current = parent;
|
|
1071
|
+
const snapshot = {
|
|
1072
|
+
runs: runs.map(compactRun),
|
|
1073
|
+
notices: notices.map((notice) => ({ ...notice })),
|
|
1074
|
+
version
|
|
1075
|
+
};
|
|
1076
|
+
deepFreezeGraphValue(snapshot);
|
|
1077
|
+
return snapshot;
|
|
1078
|
+
}
|
|
1079
|
+
function deepFreezeGraphValue(value) {
|
|
1080
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
1081
|
+
return;
|
|
1082
|
+
Object.freeze(value);
|
|
1083
|
+
if (Array.isArray(value)) {
|
|
1084
|
+
for (const item of value)
|
|
1085
|
+
deepFreezeGraphValue(item);
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
for (const key of Object.keys(value)) {
|
|
1089
|
+
deepFreezeGraphValue(value[key]);
|
|
813
1090
|
}
|
|
814
|
-
return;
|
|
815
1091
|
}
|
|
816
1092
|
|
|
1093
|
+
// dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
|
|
1094
|
+
import { randomUUID } from "node:crypto";
|
|
1095
|
+
|
|
817
1096
|
// dist/builtin/workflows/src/shared/workflow-activity.ts
|
|
818
1097
|
function workflowActivityNodeKey(runId, nodeId) {
|
|
819
1098
|
return `${runId}:${nodeId}`;
|
|
@@ -887,7 +1166,7 @@ class WorkflowObservationRuntime {
|
|
|
887
1166
|
kind: "lifecycle",
|
|
888
1167
|
event: {
|
|
889
1168
|
type: "workflow_lifecycle",
|
|
890
|
-
eventId:
|
|
1169
|
+
eventId: randomUUID(),
|
|
891
1170
|
runId: run.id,
|
|
892
1171
|
rootRunId,
|
|
893
1172
|
occurredAt: now,
|
|
@@ -1174,249 +1453,6 @@ function createStoreContext(state = createStoreState()) {
|
|
|
1174
1453
|
};
|
|
1175
1454
|
}
|
|
1176
1455
|
|
|
1177
|
-
// dist/builtin/workflows/src/durable/prompt-reservations.ts
|
|
1178
|
-
function durablePromptScope(backend, workflowId) {
|
|
1179
|
-
return backend.promptReservationScope(workflowId);
|
|
1180
|
-
}
|
|
1181
|
-
function claimDurablePromptToken(backend, workflowId, reservationId) {
|
|
1182
|
-
return backend.pendingPromptToken(workflowId, reservationId);
|
|
1183
|
-
}
|
|
1184
|
-
function reserveDurablePrompt(backend, workflowId, reservationId) {
|
|
1185
|
-
return backend.reservePendingPrompt(workflowId, reservationId);
|
|
1186
|
-
}
|
|
1187
|
-
function releaseDurablePrompt(backend, workflowId, reservationId, token) {
|
|
1188
|
-
backend.releasePendingPrompt(workflowId, reservationId, token);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
// dist/builtin/workflows/src/durable/scoped-backend.ts
|
|
1192
|
-
class ScopedDurableBackend {
|
|
1193
|
-
persistent;
|
|
1194
|
-
inner;
|
|
1195
|
-
scope;
|
|
1196
|
-
constructor(inner, scope) {
|
|
1197
|
-
this.inner = inner;
|
|
1198
|
-
this.scope = scope;
|
|
1199
|
-
this.persistent = inner.persistent;
|
|
1200
|
-
}
|
|
1201
|
-
async archivePendingStageMessage(_workflowId, entry) {
|
|
1202
|
-
await this.inner.archivePendingStageMessage?.(this.scope.rootWorkflowId, entry);
|
|
1203
|
-
}
|
|
1204
|
-
async readSettledPendingStageMessage(workflowId, messageId, logicalRunId = workflowId) {
|
|
1205
|
-
return this.inner.readSettledPendingStageMessage?.(this.scope.rootWorkflowId, messageId, logicalRunId);
|
|
1206
|
-
}
|
|
1207
|
-
getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
|
|
1208
|
-
return this.inner.getPendingStageMessageDeliveryCount?.(this.scope.rootWorkflowId, messageId, logicalRunId) ?? 0;
|
|
1209
|
-
}
|
|
1210
|
-
async readPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
|
|
1211
|
-
return this.inner.readPendingStageMessageDeliveryCount === undefined ? this.getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId) : await this.inner.readPendingStageMessageDeliveryCount(this.scope.rootWorkflowId, messageId, logicalRunId);
|
|
1212
|
-
}
|
|
1213
|
-
async archivePendingStageDeliveryReceipt(_workflowId, messageId, delivery, accounting) {
|
|
1214
|
-
await this.inner.archivePendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, accounting);
|
|
1215
|
-
}
|
|
1216
|
-
hasCachedPendingStageDeliveryReceipt(workflowId, messageId, delivery, anySession = false, logicalRunId = workflowId) {
|
|
1217
|
-
return this.inner.hasCachedPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, anySession, logicalRunId) ?? false;
|
|
1218
|
-
}
|
|
1219
|
-
async hasPendingStageDeliveryReceipt(workflowId, messageId, delivery, logicalRunId = workflowId) {
|
|
1220
|
-
return await this.inner.hasPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, logicalRunId) ?? false;
|
|
1221
|
-
}
|
|
1222
|
-
registerWorkflow(_handle) {}
|
|
1223
|
-
persistPendingStageMessages(workflowId, messages, logicalRunId = workflowId) {
|
|
1224
|
-
return this.inner.persistPendingStageMessages(this.scope.rootWorkflowId, messages, logicalRunId);
|
|
1225
|
-
}
|
|
1226
|
-
recordCheckpoint(checkpoint) {
|
|
1227
|
-
this.inner.recordCheckpoint(this.remap(checkpoint));
|
|
1228
|
-
}
|
|
1229
|
-
async recordCheckpointAsync(checkpoint, options) {
|
|
1230
|
-
await this.inner.recordCheckpointAsync(this.remap(checkpoint), options);
|
|
1231
|
-
}
|
|
1232
|
-
async recordAdditiveCheckpointBestEffort(checkpoint) {
|
|
1233
|
-
return await this.inner.recordAdditiveCheckpointBestEffort(this.remap(checkpoint));
|
|
1234
|
-
}
|
|
1235
|
-
workflowOwnership(_workflowId) {
|
|
1236
|
-
return this.inner.workflowOwnership(this.scope.rootWorkflowId);
|
|
1237
|
-
}
|
|
1238
|
-
getToolOutput(_workflowId, argsHash) {
|
|
1239
|
-
return this.inner.getToolOutput(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
1240
|
-
}
|
|
1241
|
-
getToolCheckpoint(_workflowId, argsHash) {
|
|
1242
|
-
return this.inner.getToolCheckpoint(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
1243
|
-
}
|
|
1244
|
-
getUiResponse(_workflowId, promptHash) {
|
|
1245
|
-
return this.inner.getUiResponse(this.scope.rootWorkflowId, this.scopeKey(promptHash));
|
|
1246
|
-
}
|
|
1247
|
-
getStageOutput(_workflowId, replayKey) {
|
|
1248
|
-
return this.inner.getStageOutput(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
1249
|
-
}
|
|
1250
|
-
getStageSession(_workflowId, replayKey) {
|
|
1251
|
-
return this.inner.getStageSession(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
1252
|
-
}
|
|
1253
|
-
listCheckpoints(workflowId) {
|
|
1254
|
-
const prefix = `${this.scope.scopePrefix}:`;
|
|
1255
|
-
return this.inner.listCheckpoints(this.scope.rootWorkflowId).filter((checkpoint) => checkpointHasPrefix(checkpoint, prefix)).map((checkpoint) => localCheckpoint(checkpoint, workflowId, prefix));
|
|
1256
|
-
}
|
|
1257
|
-
getWorkflow(_workflowId) {
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
getLoadableWorkflow(_workflowId) {
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
setWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
|
|
1264
|
-
async transitionWorkflowStatus(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
|
|
1265
|
-
return false;
|
|
1266
|
-
}
|
|
1267
|
-
adjustPendingPrompts(_workflowId, delta) {
|
|
1268
|
-
this.inner.adjustPendingPrompts(this.scope.rootWorkflowId, delta);
|
|
1269
|
-
}
|
|
1270
|
-
promptReservationScope(_workflowId) {
|
|
1271
|
-
return this.effectivePromptScope();
|
|
1272
|
-
}
|
|
1273
|
-
pendingPromptToken(_workflowId, reservationId) {
|
|
1274
|
-
return claimDurablePromptToken(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
1275
|
-
}
|
|
1276
|
-
reservePendingPrompt(_workflowId, reservationId) {
|
|
1277
|
-
return reserveDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
1278
|
-
}
|
|
1279
|
-
releasePendingPrompt(_workflowId, reservationId, token) {
|
|
1280
|
-
releaseDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId, token);
|
|
1281
|
-
}
|
|
1282
|
-
listResumableWorkflows() {
|
|
1283
|
-
return [];
|
|
1284
|
-
}
|
|
1285
|
-
listCompletedWorkflows() {
|
|
1286
|
-
return [];
|
|
1287
|
-
}
|
|
1288
|
-
async prepareWorkflowCatalog() {
|
|
1289
|
-
return { resumable: [], completed: [] };
|
|
1290
|
-
}
|
|
1291
|
-
toMetadata(_workflowId) {
|
|
1292
|
-
return;
|
|
1293
|
-
}
|
|
1294
|
-
async deleteWorkflow(_workflowId) {}
|
|
1295
|
-
async deleteWorkflowIfInactive(_workflowId) {
|
|
1296
|
-
return { ok: false, reason: "not_found" };
|
|
1297
|
-
}
|
|
1298
|
-
isWorkflowLoadable(_workflowId) {
|
|
1299
|
-
return false;
|
|
1300
|
-
}
|
|
1301
|
-
reset() {}
|
|
1302
|
-
hydrateWorkflow(_workflowId) {
|
|
1303
|
-
return Promise.resolve();
|
|
1304
|
-
}
|
|
1305
|
-
hydrateResumableWorkflows() {
|
|
1306
|
-
return Promise.resolve();
|
|
1307
|
-
}
|
|
1308
|
-
effectivePromptScope() {
|
|
1309
|
-
const parent = durablePromptScope(this.inner, this.scope.rootWorkflowId);
|
|
1310
|
-
const scope = parent.scope === "root" ? this.scope.scopePrefix : `${parent.scope}:${this.scope.scopePrefix}`;
|
|
1311
|
-
return {
|
|
1312
|
-
rootWorkflowId: parent.rootWorkflowId,
|
|
1313
|
-
scope
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
scopeKey(key) {
|
|
1317
|
-
return `${this.scope.scopePrefix}:${key}`;
|
|
1318
|
-
}
|
|
1319
|
-
remap(checkpoint) {
|
|
1320
|
-
const workflowId = this.scope.rootWorkflowId;
|
|
1321
|
-
if (checkpoint.kind === "tool") {
|
|
1322
|
-
return {
|
|
1323
|
-
...checkpoint,
|
|
1324
|
-
workflowId,
|
|
1325
|
-
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
1326
|
-
argsHash: this.scopeKey(checkpoint.argsHash)
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
if (checkpoint.kind === "ui") {
|
|
1330
|
-
return {
|
|
1331
|
-
...checkpoint,
|
|
1332
|
-
workflowId,
|
|
1333
|
-
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
1334
|
-
promptHash: this.scopeKey(checkpoint.promptHash)
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
return {
|
|
1338
|
-
...checkpoint,
|
|
1339
|
-
workflowId,
|
|
1340
|
-
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
1341
|
-
replayKey: this.scopeKey(checkpoint.replayKey),
|
|
1342
|
-
...remappedBoundaryScope(checkpoint, this.scopeKey(checkpoint.topology?.boundary?.replayScope ?? ""))
|
|
1343
|
-
};
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
function checkpointHasPrefix(checkpoint, prefix) {
|
|
1347
|
-
if (!checkpoint.checkpointId.startsWith(prefix))
|
|
1348
|
-
return false;
|
|
1349
|
-
if (checkpoint.kind === "tool")
|
|
1350
|
-
return checkpoint.argsHash.startsWith(prefix);
|
|
1351
|
-
if (checkpoint.kind === "ui")
|
|
1352
|
-
return checkpoint.promptHash.startsWith(prefix);
|
|
1353
|
-
return checkpoint.replayKey.startsWith(prefix);
|
|
1354
|
-
}
|
|
1355
|
-
function localCheckpoint(checkpoint, workflowId, prefix) {
|
|
1356
|
-
const checkpointId = checkpoint.checkpointId.slice(prefix.length);
|
|
1357
|
-
if (checkpoint.kind === "tool") {
|
|
1358
|
-
return { ...checkpoint, workflowId, checkpointId, argsHash: checkpoint.argsHash.slice(prefix.length) };
|
|
1359
|
-
}
|
|
1360
|
-
if (checkpoint.kind === "ui") {
|
|
1361
|
-
return { ...checkpoint, workflowId, checkpointId, promptHash: checkpoint.promptHash.slice(prefix.length) };
|
|
1362
|
-
}
|
|
1363
|
-
const replayKey = checkpoint.replayKey.slice(prefix.length);
|
|
1364
|
-
const replayScope = stripOnePrefix(checkpoint.topology?.boundary?.replayScope, prefix);
|
|
1365
|
-
return {
|
|
1366
|
-
...checkpoint,
|
|
1367
|
-
workflowId,
|
|
1368
|
-
checkpointId,
|
|
1369
|
-
replayKey,
|
|
1370
|
-
...remappedBoundaryScope(checkpoint, replayScope)
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
function remappedBoundaryScope(checkpoint, replayScope) {
|
|
1374
|
-
const topology = checkpoint.topology;
|
|
1375
|
-
if (topology?.boundary === undefined || replayScope === undefined)
|
|
1376
|
-
return {};
|
|
1377
|
-
return {
|
|
1378
|
-
topology: {
|
|
1379
|
-
...topology,
|
|
1380
|
-
boundary: { ...topology.boundary, replayScope }
|
|
1381
|
-
}
|
|
1382
|
-
};
|
|
1383
|
-
}
|
|
1384
|
-
function stripOnePrefix(value, prefix) {
|
|
1385
|
-
if (value === undefined || !value.startsWith(prefix))
|
|
1386
|
-
return value;
|
|
1387
|
-
return value.slice(prefix.length);
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
// dist/builtin/workflows/src/durable/run-owner-backend.ts
|
|
1391
|
-
function durableRootRunIdForRun(runs, runId) {
|
|
1392
|
-
return reciprocalWorkflowRootRunId(new Map(runs.map((run) => [run.id, run])), runId);
|
|
1393
|
-
}
|
|
1394
|
-
function durableBackendForRun(backend, runs, runId) {
|
|
1395
|
-
const rootRunId = durableRootRunIdForRun(runs, runId);
|
|
1396
|
-
if (rootRunId === undefined)
|
|
1397
|
-
return;
|
|
1398
|
-
const runById = new Map(runs.map((run) => [run.id, run]));
|
|
1399
|
-
if (rootRunId === runId)
|
|
1400
|
-
return backend;
|
|
1401
|
-
const scopes = [];
|
|
1402
|
-
let current = runById.get(runId);
|
|
1403
|
-
while (current !== undefined && current.id !== rootRunId) {
|
|
1404
|
-
const parent = current.parentRunId === undefined ? undefined : runById.get(current.parentRunId);
|
|
1405
|
-
const boundary = parent?.stages.find((stage) => stage.id === current?.parentStageId);
|
|
1406
|
-
if (parent === undefined || boundary?.replayKey === undefined)
|
|
1407
|
-
return;
|
|
1408
|
-
scopes.push(boundary.replayKey);
|
|
1409
|
-
current = parent;
|
|
1410
|
-
}
|
|
1411
|
-
if (current?.id !== rootRunId)
|
|
1412
|
-
return;
|
|
1413
|
-
let view = backend;
|
|
1414
|
-
for (const scopePrefix of scopes.reverse()) {
|
|
1415
|
-
view = new ScopedDurableBackend(view, { rootWorkflowId: rootRunId, scopePrefix });
|
|
1416
|
-
}
|
|
1417
|
-
return view;
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
1456
|
// dist/builtin/workflows/src/shared/pending-stage-retention.ts
|
|
1421
1457
|
var PENDING_STAGE_SETTLED_MESSAGE_LIMIT = 50;
|
|
1422
1458
|
async function retainPendingStageMessages(messages, archive) {
|
|
@@ -1469,8 +1505,7 @@ function createPendingStageDeliveryStoreMethods(context) {
|
|
|
1469
1505
|
const run = context.findRun(input.runId);
|
|
1470
1506
|
if (run === undefined)
|
|
1471
1507
|
return;
|
|
1472
|
-
const
|
|
1473
|
-
const availableBackend = getAvailableDurableBackend();
|
|
1508
|
+
const availableBackend = availableRunDurableBackend(context.state.runs, input.runId) ?? context.backend;
|
|
1474
1509
|
const backend = availableBackend === undefined ? undefined : durableBackendForRun(availableBackend, context.state.runs, input.runId);
|
|
1475
1510
|
const receipt = await backend?.readSettledPendingStageMessage?.(input.runId, input.message.id);
|
|
1476
1511
|
const result = queueStageMessage(receipt === undefined ? run.pendingStageMessages ?? [] : [...run.pendingStageMessages ?? [], receipt], input, undefined, undefined, resolvePendingStageIdentity(run, input.stageKey));
|
|
@@ -2400,19 +2435,9 @@ function createStageStoreMethods(context) {
|
|
|
2400
2435
|
if (!run)
|
|
2401
2436
|
return false;
|
|
2402
2437
|
const stage = context.findStage(run, stageId);
|
|
2403
|
-
if (!stage)
|
|
2404
|
-
return false;
|
|
2405
|
-
let changed = false;
|
|
2406
|
-
if (session.sessionId !== undefined && stage.sessionId !== session.sessionId) {
|
|
2407
|
-
stage.sessionId = session.sessionId;
|
|
2408
|
-
changed = true;
|
|
2409
|
-
}
|
|
2410
|
-
if (session.sessionFile !== undefined && stage.sessionFile !== session.sessionFile) {
|
|
2411
|
-
stage.sessionFile = session.sessionFile;
|
|
2412
|
-
changed = true;
|
|
2413
|
-
}
|
|
2414
|
-
if (!changed)
|
|
2438
|
+
if (!stage || stage.sessionId === session.sessionId)
|
|
2415
2439
|
return false;
|
|
2440
|
+
stage.sessionId = session.sessionId;
|
|
2416
2441
|
context.bumpAndNotify();
|
|
2417
2442
|
return true;
|
|
2418
2443
|
},
|
|
@@ -2631,8 +2656,16 @@ function createStageStoreMethods(context) {
|
|
|
2631
2656
|
// dist/builtin/workflows/src/shared/store-factory.ts
|
|
2632
2657
|
function createStore() {
|
|
2633
2658
|
const context = createStoreContext();
|
|
2659
|
+
context.backend = getDurableBackendProcessOwner().injectedBackend;
|
|
2634
2660
|
const created = {
|
|
2635
2661
|
[workflowObservationRuntimeKey]: context.observation,
|
|
2662
|
+
[workflowStoreBackendOverride]: context.backend,
|
|
2663
|
+
get [workflowStoreBackend]() {
|
|
2664
|
+
return context.backend;
|
|
2665
|
+
},
|
|
2666
|
+
set [workflowStoreBackend](backend) {
|
|
2667
|
+
context.backend = backend;
|
|
2668
|
+
},
|
|
2636
2669
|
...createRunStoreMethods(context),
|
|
2637
2670
|
...createPendingStageDeliveryStoreMethods(context),
|
|
2638
2671
|
...createStageStoreMethods(context),
|
|
@@ -2656,7 +2689,7 @@ function workflowArtifactRoot() {
|
|
|
2656
2689
|
const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
2657
2690
|
if (override !== undefined && override.length > 0)
|
|
2658
2691
|
return override;
|
|
2659
|
-
return join(dirname(
|
|
2692
|
+
return join(dirname(getAgentDir()), "workflows");
|
|
2660
2693
|
}
|
|
2661
2694
|
function workflowArtifactRunsRoot() {
|
|
2662
2695
|
return join(workflowArtifactRoot(), "runs");
|
|
@@ -2706,7 +2739,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2706
2739
|
let backend;
|
|
2707
2740
|
let backendReady = true;
|
|
2708
2741
|
try {
|
|
2709
|
-
backend =
|
|
2742
|
+
backend = requireStoreDurableBackend(store);
|
|
2710
2743
|
} catch {
|
|
2711
2744
|
backendReady = false;
|
|
2712
2745
|
}
|
|
@@ -2721,7 +2754,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2721
2754
|
let durable;
|
|
2722
2755
|
if (backend !== undefined) {
|
|
2723
2756
|
try {
|
|
2724
|
-
durable = durableRunState(backend, runId);
|
|
2757
|
+
durable = durableRunState(availableRunDurableBackend(store.runs(), runId) ?? backend, runId);
|
|
2725
2758
|
} catch {
|
|
2726
2759
|
backendReady = false;
|
|
2727
2760
|
return localState === "protected" ? "protected" : undefined;
|
|
@@ -2737,7 +2770,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2737
2770
|
async function deleteTerminalDurableEntry(runId) {
|
|
2738
2771
|
let backend;
|
|
2739
2772
|
try {
|
|
2740
|
-
backend =
|
|
2773
|
+
backend = requireStoreDurableBackend(store, runId);
|
|
2741
2774
|
} catch {
|
|
2742
2775
|
return false;
|
|
2743
2776
|
}
|
|
@@ -2801,8 +2834,8 @@ async function pruneArtifactRootIfDue(root, now) {
|
|
|
2801
2834
|
}
|
|
2802
2835
|
}
|
|
2803
2836
|
function workflowArtifactDirectoryPath(runId) {
|
|
2804
|
-
const effectiveRunId = runId ??
|
|
2805
|
-
return join(workflowArtifactRunPath(effectiveRunId), `artifact-${
|
|
2837
|
+
const effectiveRunId = runId ?? randomUUID2();
|
|
2838
|
+
return join(workflowArtifactRunPath(effectiveRunId), `artifact-${randomUUID2()}`);
|
|
2806
2839
|
}
|
|
2807
2840
|
async function ensureWorkflowArtifactDirectory(directory) {
|
|
2808
2841
|
await pruneArtifactRootIfDue(workflowArtifactRunsRoot(), Date.now());
|
|
@@ -3112,4 +3145,4 @@ async function reverify_consolidated_batch(ctx, input) {
|
|
|
3112
3145
|
return apply_reverify_results(input.batch, audits);
|
|
3113
3146
|
}
|
|
3114
3147
|
|
|
3115
|
-
export {
|
|
3148
|
+
export { workflowArtifactDirectoryPath, ensureWorkflowArtifactDirectory, createWorkflowArtifactDirectory, record_convergence, convergence_escalation_evidence, finalActionRemaining, stopReviewLoopContradictions, contradictedStopReviewLoopGap, consolidateFindingsBatch, parseFailureDiagnostics, reviewerFailureText, summarizeReviewConvergence, reverify_consolidated_batch };
|