@bastani/atomic 0.9.38-alpha.4 → 0.9.38-alpha.6
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 +39 -0
- package/README.md +8 -6
- package/dist/builtin/intercom/CHANGELOG.md +15 -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 +89 -40
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +29 -33
- 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 +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +36 -0
- package/dist/builtin/workflows/builtin/{chunk-qrrkfg9v.js → chunk-2qgfyvzs.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-na3wpwzh.js → chunk-g1a4hw0s.js} +390 -345
- package/dist/builtin/workflows/builtin/{chunk-xg7kkgf8.js → chunk-neszcj53.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/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 +20 -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 +17 -1
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +6 -1
- 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 +15 -30
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +23390 -22820
- package/dist/builtin/workflows/src/index.js +7614 -7060
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +7 -7
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +0 -14
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -2
- 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 +3 -3
- 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 +20 -13
- 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 +3 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +44 -96
- package/dist/core/agent-session-runtime.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/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 +3 -2
- 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/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -6
- package/dist/core/sdk.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 +48 -49
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +438 -306
- 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 +14 -7
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +0 -11
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -61
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +2 -10
- 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 +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -0
- 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/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +3 -2
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-schema.d.ts +0 -5
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +1 -15
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +1 -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/session/jsonl-session-store.d.ts +9 -2
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +71 -27
- package/dist/core/storage/session/jsonl-session-store.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/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.js +1 -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 +1 -5
- 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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +7 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +86 -52
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +51 -30
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +1 -0
- 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-list.d.ts +9 -6
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +15 -14
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +7 -4
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +12 -14
- 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.js +1 -1
- 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 +24 -12
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +7 -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 +90 -71
- 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 +18 -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 +11 -8
- 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-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/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/environment-variables.md +5 -1
- 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/providers.md +2 -2
- package/docs/quickstart.md +2 -1
- package/docs/reference/cli.md +3 -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 +18 -1
- package/docs/session-format.md +7 -5
- package/docs/sessions.md +11 -2
- package/docs/settings.md +17 -2
- package/docs/storage.md +262 -1
- package/docs/usage.md +3 -2
- package/docs/workflows/api-reference.md +67 -11
- package/docs/workflows/operations.md +4 -2
- 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 +32 -32
- package/package.json +3 -3
- package/schemas/settings.schema.json +1 -22
- 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,360 @@ 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
|
+
registerWorkflow(_handle) {}
|
|
138
|
+
persistPendingStageMessages(workflowId, messages, logicalRunId = workflowId) {
|
|
139
|
+
return this.inner.persistPendingStageMessages(this.scope.rootWorkflowId, messages, logicalRunId);
|
|
140
|
+
}
|
|
141
|
+
recordCheckpoint(checkpoint) {
|
|
142
|
+
return this.inner.recordCheckpoint(this.remap(checkpoint));
|
|
143
|
+
}
|
|
144
|
+
async recordCheckpointAsync(checkpoint, options) {
|
|
145
|
+
await this.inner.recordCheckpointAsync(this.remap(checkpoint), options);
|
|
146
|
+
}
|
|
147
|
+
async recordAdditiveCheckpointBestEffort(checkpoint) {
|
|
148
|
+
return await this.inner.recordAdditiveCheckpointBestEffort(this.remap(checkpoint));
|
|
149
|
+
}
|
|
150
|
+
workflowOwnership(_workflowId) {
|
|
151
|
+
return this.inner.workflowOwnership(this.scope.rootWorkflowId);
|
|
152
|
+
}
|
|
153
|
+
getToolOutput(_workflowId, argsHash) {
|
|
154
|
+
return this.inner.getToolOutput(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
155
|
+
}
|
|
156
|
+
getToolCheckpoint(_workflowId, argsHash) {
|
|
157
|
+
return this.inner.getToolCheckpoint(this.scope.rootWorkflowId, this.scopeKey(argsHash));
|
|
158
|
+
}
|
|
159
|
+
getUiResponse(_workflowId, promptHash) {
|
|
160
|
+
return this.inner.getUiResponse(this.scope.rootWorkflowId, this.scopeKey(promptHash));
|
|
161
|
+
}
|
|
162
|
+
getStageOutput(_workflowId, replayKey) {
|
|
163
|
+
return this.inner.getStageOutput(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
164
|
+
}
|
|
165
|
+
getStageSession(_workflowId, replayKey) {
|
|
166
|
+
return this.inner.getStageSession(this.scope.rootWorkflowId, this.scopeKey(replayKey));
|
|
167
|
+
}
|
|
168
|
+
listCheckpoints(workflowId) {
|
|
169
|
+
const prefix = `${this.scope.scopePrefix}:`;
|
|
170
|
+
return this.inner.listCheckpoints(this.scope.rootWorkflowId).filter((checkpoint) => checkpointHasPrefix(checkpoint, prefix)).map((checkpoint) => localCheckpoint(checkpoint, workflowId, prefix));
|
|
171
|
+
}
|
|
172
|
+
getWorkflow(_workflowId) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
getLoadableWorkflow(_workflowId) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
|
|
179
|
+
async transitionWorkflowStatus(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
adjustPendingPrompts(_workflowId, delta) {
|
|
183
|
+
return this.inner.adjustPendingPrompts(this.scope.rootWorkflowId, delta);
|
|
184
|
+
}
|
|
185
|
+
promptReservationScope(_workflowId) {
|
|
186
|
+
return this.effectivePromptScope();
|
|
187
|
+
}
|
|
188
|
+
pendingPromptToken(_workflowId, reservationId) {
|
|
189
|
+
return claimDurablePromptToken(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
190
|
+
}
|
|
191
|
+
reservePendingPrompt(_workflowId, reservationId) {
|
|
192
|
+
return reserveDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId);
|
|
193
|
+
}
|
|
194
|
+
releasePendingPrompt(_workflowId, reservationId, token) {
|
|
195
|
+
return releaseDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId, token);
|
|
196
|
+
}
|
|
197
|
+
listResumableWorkflows() {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
listCompletedWorkflows() {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
async prepareWorkflowCatalog() {
|
|
204
|
+
return { resumable: [], completed: [] };
|
|
205
|
+
}
|
|
206
|
+
toMetadata(_workflowId) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
async deleteWorkflow(_workflowId) {}
|
|
210
|
+
async deleteWorkflowIfInactive(_workflowId) {
|
|
211
|
+
return { ok: false, reason: "not_found" };
|
|
212
|
+
}
|
|
213
|
+
isWorkflowLoadable(_workflowId) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
reset() {}
|
|
217
|
+
hydrateWorkflow(_workflowId) {
|
|
218
|
+
return Promise.resolve();
|
|
219
|
+
}
|
|
220
|
+
hydrateResumableWorkflows() {
|
|
221
|
+
return Promise.resolve();
|
|
222
|
+
}
|
|
223
|
+
effectivePromptScope() {
|
|
224
|
+
const parent = durablePromptScope(this.inner, this.scope.rootWorkflowId);
|
|
225
|
+
const scope = parent.scope === "root" ? this.scope.scopePrefix : `${parent.scope}:${this.scope.scopePrefix}`;
|
|
226
|
+
return {
|
|
227
|
+
rootWorkflowId: parent.rootWorkflowId,
|
|
228
|
+
scope
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
scopeKey(key) {
|
|
232
|
+
return `${this.scope.scopePrefix}:${key}`;
|
|
233
|
+
}
|
|
234
|
+
remap(checkpoint) {
|
|
235
|
+
const workflowId = this.scope.rootWorkflowId;
|
|
236
|
+
if (checkpoint.kind === "tool") {
|
|
237
|
+
return {
|
|
238
|
+
...checkpoint,
|
|
239
|
+
workflowId,
|
|
240
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
241
|
+
argsHash: this.scopeKey(checkpoint.argsHash)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (checkpoint.kind === "ui") {
|
|
245
|
+
return {
|
|
246
|
+
...checkpoint,
|
|
247
|
+
workflowId,
|
|
248
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
249
|
+
promptHash: this.scopeKey(checkpoint.promptHash)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
...checkpoint,
|
|
254
|
+
workflowId,
|
|
255
|
+
checkpointId: this.scopeKey(checkpoint.checkpointId),
|
|
256
|
+
replayKey: this.scopeKey(checkpoint.replayKey),
|
|
257
|
+
...remappedBoundaryScope(checkpoint, this.scopeKey(checkpoint.topology?.boundary?.replayScope ?? ""))
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function checkpointHasPrefix(checkpoint, prefix) {
|
|
262
|
+
if (!checkpoint.checkpointId.startsWith(prefix))
|
|
263
|
+
return false;
|
|
264
|
+
if (checkpoint.kind === "tool")
|
|
265
|
+
return checkpoint.argsHash.startsWith(prefix);
|
|
266
|
+
if (checkpoint.kind === "ui")
|
|
267
|
+
return checkpoint.promptHash.startsWith(prefix);
|
|
268
|
+
return checkpoint.replayKey.startsWith(prefix);
|
|
269
|
+
}
|
|
270
|
+
function localCheckpoint(checkpoint, workflowId, prefix) {
|
|
271
|
+
const checkpointId = checkpoint.checkpointId.slice(prefix.length);
|
|
272
|
+
if (checkpoint.kind === "tool") {
|
|
273
|
+
return { ...checkpoint, workflowId, checkpointId, argsHash: checkpoint.argsHash.slice(prefix.length) };
|
|
274
|
+
}
|
|
275
|
+
if (checkpoint.kind === "ui") {
|
|
276
|
+
return { ...checkpoint, workflowId, checkpointId, promptHash: checkpoint.promptHash.slice(prefix.length) };
|
|
277
|
+
}
|
|
278
|
+
const replayKey = checkpoint.replayKey.slice(prefix.length);
|
|
279
|
+
const replayScope = stripOnePrefix(checkpoint.topology?.boundary?.replayScope, prefix);
|
|
16
280
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
281
|
+
...checkpoint,
|
|
282
|
+
workflowId,
|
|
283
|
+
checkpointId,
|
|
284
|
+
replayKey,
|
|
285
|
+
...remappedBoundaryScope(checkpoint, replayScope)
|
|
21
286
|
};
|
|
22
287
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
288
|
+
function remappedBoundaryScope(checkpoint, replayScope) {
|
|
289
|
+
const topology = checkpoint.topology;
|
|
290
|
+
if (topology?.boundary === undefined || replayScope === undefined)
|
|
291
|
+
return {};
|
|
292
|
+
return {
|
|
293
|
+
topology: {
|
|
294
|
+
...topology,
|
|
295
|
+
boundary: { ...topology.boundary, replayScope }
|
|
296
|
+
}
|
|
297
|
+
};
|
|
25
298
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return existing;
|
|
31
|
-
const created = emptyOwner();
|
|
32
|
-
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
33
|
-
return created;
|
|
299
|
+
function stripOnePrefix(value, prefix) {
|
|
300
|
+
if (value === undefined || !value.startsWith(prefix))
|
|
301
|
+
return value;
|
|
302
|
+
return value.slice(prefix.length);
|
|
34
303
|
}
|
|
35
304
|
|
|
36
|
-
// dist/builtin/workflows/src/durable/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
305
|
+
// dist/builtin/workflows/src/durable/run-owner-backend.ts
|
|
306
|
+
var workflowRunBackend = Symbol.for("atomic-workflows/run-journal-backend@1");
|
|
307
|
+
function availableRunDurableBackend(runs, runId) {
|
|
308
|
+
const target = resolveRunIdTarget(runId, runs.map((run) => run.id));
|
|
309
|
+
const id = target.kind === "exact" || target.kind === "unique_prefix" ? target.runId : runId;
|
|
310
|
+
const rootRunId = durableRootRunIdForRun(runs, id);
|
|
311
|
+
return runs.find((run) => run.id === rootRunId)?.[workflowRunBackend];
|
|
312
|
+
}
|
|
313
|
+
function durableRootRunIdForRun(runs, runId) {
|
|
314
|
+
return reciprocalWorkflowRootRunId(new Map(runs.map((run) => [run.id, run])), runId);
|
|
315
|
+
}
|
|
316
|
+
function durableBackendForRun(backend, runs, runId) {
|
|
317
|
+
const rootRunId = durableRootRunIdForRun(runs, runId);
|
|
318
|
+
if (rootRunId === undefined)
|
|
319
|
+
return;
|
|
320
|
+
const runById = new Map(runs.map((run) => [run.id, run]));
|
|
321
|
+
const rootBackend = availableRunDurableBackend(runs, rootRunId) ?? backend;
|
|
322
|
+
if (rootRunId === runId)
|
|
323
|
+
return rootBackend;
|
|
324
|
+
const scopes = [];
|
|
325
|
+
let current = runById.get(runId);
|
|
326
|
+
while (current !== undefined && current.id !== rootRunId) {
|
|
327
|
+
const parent = current.parentRunId === undefined ? undefined : runById.get(current.parentRunId);
|
|
328
|
+
const boundary = parent?.stages.find((stage) => stage.id === current?.parentStageId);
|
|
329
|
+
if (parent === undefined || boundary?.replayKey === undefined)
|
|
330
|
+
return;
|
|
331
|
+
scopes.push(boundary.replayKey);
|
|
332
|
+
current = parent;
|
|
333
|
+
}
|
|
334
|
+
if (current?.id !== rootRunId)
|
|
335
|
+
return;
|
|
336
|
+
let view = rootBackend;
|
|
337
|
+
for (const scopePrefix of scopes.reverse()) {
|
|
338
|
+
view = new ScopedDurableBackend(view, { rootWorkflowId: rootRunId, scopePrefix });
|
|
339
|
+
}
|
|
340
|
+
return view;
|
|
341
|
+
}
|
|
41
342
|
|
|
42
343
|
// dist/builtin/workflows/src/durable/journal/types.ts
|
|
344
|
+
import { StorageSchemaVersionError } from "@bastani/atomic/storage";
|
|
345
|
+
import { StorageUnavailableError } from "@bastani/atomic/storage";
|
|
43
346
|
class JournalError extends Error {
|
|
44
347
|
}
|
|
45
348
|
|
|
46
|
-
// dist/builtin/workflows/src/durable/
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
// dist/builtin/workflows/src/durable/factory.ts
|
|
349
|
+
// dist/builtin/workflows/src/durable/store-backend.ts
|
|
350
|
+
var workflowStoreBackend = Symbol.for("atomic-workflows/store-journal-backend@1");
|
|
351
|
+
var workflowStoreBackendOverride = Symbol.for("atomic-workflows/store-journal-override@1");
|
|
51
352
|
class DurableBackendNotInitializedError extends JournalError {
|
|
52
353
|
constructor() {
|
|
53
354
|
super("Workflow journal has not been initialized");
|
|
54
355
|
this.name = "DurableBackendNotInitializedError";
|
|
55
356
|
}
|
|
56
357
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
358
|
+
function availableStoreDurableBackend(store, runId) {
|
|
359
|
+
return (store !== undefined && runId !== undefined ? availableRunDurableBackend(store.runs(), runId) : undefined) ?? store?.[workflowStoreBackend];
|
|
360
|
+
}
|
|
361
|
+
function requireStoreDurableBackend(store, runId) {
|
|
362
|
+
const backend = availableStoreDurableBackend(store, runId);
|
|
59
363
|
if (backend === undefined)
|
|
60
364
|
throw new DurableBackendNotInitializedError;
|
|
61
365
|
return backend;
|
|
62
366
|
}
|
|
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
367
|
|
|
73
368
|
// dist/builtin/workflows/src/shared/pending-stage-delivery.ts
|
|
74
369
|
var PENDING_STAGE_MESSAGE_LIMIT = 50;
|
|
@@ -347,6 +642,27 @@ function normalizeDeliveryGroup(value) {
|
|
|
347
642
|
const trimmed = value.trim();
|
|
348
643
|
return trimmed.length > 0 ? trimmed : "default";
|
|
349
644
|
}
|
|
645
|
+
// dist/builtin/workflows/src/durable/backend-process-owner.ts
|
|
646
|
+
var DURABLE_BACKEND_PROCESS_OWNER_KEY = Symbol.for("atomic-workflows/durable-backend-process-owner@1");
|
|
647
|
+
function emptyOwner() {
|
|
648
|
+
return {
|
|
649
|
+
version: 1,
|
|
650
|
+
injectedBackend: undefined
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function ownerBag() {
|
|
654
|
+
return globalThis;
|
|
655
|
+
}
|
|
656
|
+
function getDurableBackendProcessOwner() {
|
|
657
|
+
const bag = ownerBag();
|
|
658
|
+
const existing = bag[DURABLE_BACKEND_PROCESS_OWNER_KEY];
|
|
659
|
+
if (existing !== undefined && existing.version === 1)
|
|
660
|
+
return existing;
|
|
661
|
+
const created = emptyOwner();
|
|
662
|
+
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
663
|
+
return created;
|
|
664
|
+
}
|
|
665
|
+
|
|
350
666
|
// dist/builtin/workflows/src/shared/session-scoped-singleton.ts
|
|
351
667
|
import { sessionScopedExtensionState } from "@bastani/atomic";
|
|
352
668
|
var SHARED_STATES_KEY = Symbol.for("atomic-workflows/session-scoped-singleton-pre-adoption@1");
|
|
@@ -397,6 +713,9 @@ function createSessionScopedSingleton(key, createLocal) {
|
|
|
397
713
|
}
|
|
398
714
|
return value;
|
|
399
715
|
},
|
|
716
|
+
set(_target, prop, value) {
|
|
717
|
+
return Reflect.set(live(), prop, value, live());
|
|
718
|
+
},
|
|
400
719
|
has(_target, prop) {
|
|
401
720
|
return Reflect.has(live(), prop);
|
|
402
721
|
}
|
|
@@ -757,63 +1076,25 @@ function createGraphStoreSnapshot(runs, notices, version) {
|
|
|
757
1076
|
version
|
|
758
1077
|
};
|
|
759
1078
|
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;
|
|
1079
|
+
return snapshot;
|
|
1080
|
+
}
|
|
1081
|
+
function deepFreezeGraphValue(value) {
|
|
1082
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
1083
|
+
return;
|
|
1084
|
+
Object.freeze(value);
|
|
1085
|
+
if (Array.isArray(value)) {
|
|
1086
|
+
for (const item of value)
|
|
1087
|
+
deepFreezeGraphValue(item);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
for (const key of Object.keys(value)) {
|
|
1091
|
+
deepFreezeGraphValue(value[key]);
|
|
813
1092
|
}
|
|
814
|
-
return;
|
|
815
1093
|
}
|
|
816
1094
|
|
|
1095
|
+
// dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
|
|
1096
|
+
import { randomUUID } from "node:crypto";
|
|
1097
|
+
|
|
817
1098
|
// dist/builtin/workflows/src/shared/workflow-activity.ts
|
|
818
1099
|
function workflowActivityNodeKey(runId, nodeId) {
|
|
819
1100
|
return `${runId}:${nodeId}`;
|
|
@@ -887,7 +1168,7 @@ class WorkflowObservationRuntime {
|
|
|
887
1168
|
kind: "lifecycle",
|
|
888
1169
|
event: {
|
|
889
1170
|
type: "workflow_lifecycle",
|
|
890
|
-
eventId:
|
|
1171
|
+
eventId: randomUUID(),
|
|
891
1172
|
runId: run.id,
|
|
892
1173
|
rootRunId,
|
|
893
1174
|
occurredAt: now,
|
|
@@ -1174,249 +1455,6 @@ function createStoreContext(state = createStoreState()) {
|
|
|
1174
1455
|
};
|
|
1175
1456
|
}
|
|
1176
1457
|
|
|
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
1458
|
// dist/builtin/workflows/src/shared/pending-stage-retention.ts
|
|
1421
1459
|
var PENDING_STAGE_SETTLED_MESSAGE_LIMIT = 50;
|
|
1422
1460
|
async function retainPendingStageMessages(messages, archive) {
|
|
@@ -1469,8 +1507,7 @@ function createPendingStageDeliveryStoreMethods(context) {
|
|
|
1469
1507
|
const run = context.findRun(input.runId);
|
|
1470
1508
|
if (run === undefined)
|
|
1471
1509
|
return;
|
|
1472
|
-
const
|
|
1473
|
-
const availableBackend = getAvailableDurableBackend();
|
|
1510
|
+
const availableBackend = availableRunDurableBackend(context.state.runs, input.runId) ?? context.backend;
|
|
1474
1511
|
const backend = availableBackend === undefined ? undefined : durableBackendForRun(availableBackend, context.state.runs, input.runId);
|
|
1475
1512
|
const receipt = await backend?.readSettledPendingStageMessage?.(input.runId, input.message.id);
|
|
1476
1513
|
const result = queueStageMessage(receipt === undefined ? run.pendingStageMessages ?? [] : [...run.pendingStageMessages ?? [], receipt], input, undefined, undefined, resolvePendingStageIdentity(run, input.stageKey));
|
|
@@ -2631,8 +2668,16 @@ function createStageStoreMethods(context) {
|
|
|
2631
2668
|
// dist/builtin/workflows/src/shared/store-factory.ts
|
|
2632
2669
|
function createStore() {
|
|
2633
2670
|
const context = createStoreContext();
|
|
2671
|
+
context.backend = getDurableBackendProcessOwner().injectedBackend;
|
|
2634
2672
|
const created = {
|
|
2635
2673
|
[workflowObservationRuntimeKey]: context.observation,
|
|
2674
|
+
[workflowStoreBackendOverride]: context.backend,
|
|
2675
|
+
get [workflowStoreBackend]() {
|
|
2676
|
+
return context.backend;
|
|
2677
|
+
},
|
|
2678
|
+
set [workflowStoreBackend](backend) {
|
|
2679
|
+
context.backend = backend;
|
|
2680
|
+
},
|
|
2636
2681
|
...createRunStoreMethods(context),
|
|
2637
2682
|
...createPendingStageDeliveryStoreMethods(context),
|
|
2638
2683
|
...createStageStoreMethods(context),
|
|
@@ -2656,7 +2701,7 @@ function workflowArtifactRoot() {
|
|
|
2656
2701
|
const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
2657
2702
|
if (override !== undefined && override.length > 0)
|
|
2658
2703
|
return override;
|
|
2659
|
-
return join(dirname(
|
|
2704
|
+
return join(dirname(getAgentDir()), "workflows");
|
|
2660
2705
|
}
|
|
2661
2706
|
function workflowArtifactRunsRoot() {
|
|
2662
2707
|
return join(workflowArtifactRoot(), "runs");
|
|
@@ -2706,7 +2751,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2706
2751
|
let backend;
|
|
2707
2752
|
let backendReady = true;
|
|
2708
2753
|
try {
|
|
2709
|
-
backend =
|
|
2754
|
+
backend = requireStoreDurableBackend(store);
|
|
2710
2755
|
} catch {
|
|
2711
2756
|
backendReady = false;
|
|
2712
2757
|
}
|
|
@@ -2721,7 +2766,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2721
2766
|
let durable;
|
|
2722
2767
|
if (backend !== undefined) {
|
|
2723
2768
|
try {
|
|
2724
|
-
durable = durableRunState(backend, runId);
|
|
2769
|
+
durable = durableRunState(availableRunDurableBackend(store.runs(), runId) ?? backend, runId);
|
|
2725
2770
|
} catch {
|
|
2726
2771
|
backendReady = false;
|
|
2727
2772
|
return localState === "protected" ? "protected" : undefined;
|
|
@@ -2737,7 +2782,7 @@ function createWorkflowArtifactRunStateResolver() {
|
|
|
2737
2782
|
async function deleteTerminalDurableEntry(runId) {
|
|
2738
2783
|
let backend;
|
|
2739
2784
|
try {
|
|
2740
|
-
backend =
|
|
2785
|
+
backend = requireStoreDurableBackend(store, runId);
|
|
2741
2786
|
} catch {
|
|
2742
2787
|
return false;
|
|
2743
2788
|
}
|
|
@@ -2801,8 +2846,8 @@ async function pruneArtifactRootIfDue(root, now) {
|
|
|
2801
2846
|
}
|
|
2802
2847
|
}
|
|
2803
2848
|
function workflowArtifactDirectoryPath(runId) {
|
|
2804
|
-
const effectiveRunId = runId ??
|
|
2805
|
-
return join(workflowArtifactRunPath(effectiveRunId), `artifact-${
|
|
2849
|
+
const effectiveRunId = runId ?? randomUUID2();
|
|
2850
|
+
return join(workflowArtifactRunPath(effectiveRunId), `artifact-${randomUUID2()}`);
|
|
2806
2851
|
}
|
|
2807
2852
|
async function ensureWorkflowArtifactDirectory(directory) {
|
|
2808
2853
|
await pruneArtifactRootIfDue(workflowArtifactRunsRoot(), Date.now());
|
|
@@ -3112,4 +3157,4 @@ async function reverify_consolidated_batch(ctx, input) {
|
|
|
3112
3157
|
return apply_reverify_results(input.batch, audits);
|
|
3113
3158
|
}
|
|
3114
3159
|
|
|
3115
|
-
export {
|
|
3160
|
+
export { workflowArtifactDirectoryPath, ensureWorkflowArtifactDirectory, createWorkflowArtifactDirectory, record_convergence, convergence_escalation_evidence, finalActionRemaining, stopReviewLoopContradictions, contradictedStopReviewLoopGap, consolidateFindingsBatch, parseFailureDiagnostics, reviewerFailureText, summarizeReviewConvergence, reverify_consolidated_batch };
|