@bastani/atomic 0.9.2 → 0.9.3-alpha.2
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 +66 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +15 -0
- package/dist/builtin/cursor/README.md +2 -1
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/cursor/src/cursor-models-raw.json +2 -9
- package/dist/builtin/cursor/src/model-mapper.ts +14 -3
- package/dist/builtin/cursor/src/proto/protobuf-codec-base64.ts +22 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +53 -13
- package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +24 -7
- package/dist/builtin/cursor/src/proto/protobuf-codec.ts +3 -2
- package/dist/builtin/cursor/src/stream.ts +5 -11
- package/dist/builtin/cursor/src/transport-types.ts +3 -0
- package/dist/builtin/cursor/src/transport.ts +1 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/direct-tools.ts +4 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/proxy-call.ts +3 -1
- package/dist/builtin/mcp/utils.ts +18 -7
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/README.md +6 -6
- package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
- package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
- package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
- package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
- package/dist/builtin/subagents/agents/debugger.md +5 -5
- package/dist/builtin/subagents/agents/worker.md +56 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
- package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -0
- package/dist/builtin/subagents/src/extension/index.ts +6 -3
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -7
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -4
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +15 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +35 -1
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +4 -2
- package/dist/builtin/subagents/src/shared/types-async.ts +1 -0
- package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
- package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +27 -5
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-layout.ts +27 -4
- package/dist/builtin/subagents/src/tui/render-result-animation.ts +22 -31
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +6 -6
- package/dist/builtin/subagents/src/tui/render-result.ts +20 -19
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +3 -3
- package/dist/builtin/subagents/src/tui/render-widget.ts +46 -7
- package/dist/builtin/subagents/src/tui/render.ts +2 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +56 -0
- package/dist/builtin/workflows/README.md +3 -3
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
- package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
- package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
- package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
- package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
- package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
- package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
- package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
- package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
- package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/durable/backend.ts +343 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +79 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +421 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +171 -0
- package/dist/builtin/workflows/src/durable/factory.ts +96 -0
- package/dist/builtin/workflows/src/durable/file-backend.ts +433 -0
- package/dist/builtin/workflows/src/durable/index.ts +73 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +217 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +299 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +171 -0
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +284 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +180 -0
- package/dist/builtin/workflows/src/durable/types.ts +168 -0
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +96 -0
- package/dist/builtin/workflows/src/engine/options.ts +3 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +2 -2
- package/dist/builtin/workflows/src/engine/primitives/task.ts +4 -4
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +22 -8
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +8 -0
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +69 -0
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +31 -0
- package/dist/builtin/workflows/src/engine/run.ts +148 -6
- package/dist/builtin/workflows/src/engine/runtime.ts +8 -2
- package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
- package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
- package/dist/builtin/workflows/src/extension/extension-factory.ts +6 -12
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +5 -1
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +4 -2
- package/dist/builtin/workflows/src/extension/runtime.ts +48 -9
- package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +143 -4
- package/dist/builtin/workflows/src/runs/background/quit.ts +61 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +5 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +74 -33
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +20 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +8 -7
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +19 -2
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +10 -10
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +5 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +25 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +20 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +23 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +30 -1
- package/dist/builtin/workflows/src/shared/store-public-types.ts +6 -2
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +12 -6
- package/dist/builtin/workflows/src/shared/types.ts +55 -0
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -1
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +41 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +82 -24
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +7 -0
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +22 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +4 -5
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +9 -11
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +9 -3
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +11 -2
- package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +35 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +51 -17
- package/dist/builtin/workflows/src/tui/stage-chat-view-status.ts +36 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +5 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/status-list.ts +14 -2
- package/dist/builtin/workflows/src/tui/widget.ts +23 -8
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +5 -4
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +8 -8
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +151 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/config-self-update.d.ts.map +1 -1
- package/dist/config-self-update.js +3 -4
- package/dist/config-self-update.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -5
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -0
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +23 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +29 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +36 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.js +50 -1
- package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +2 -0
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +1 -1
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +5 -5
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +23 -3
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
- package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tools.js +18 -10
- package/dist/core/compaction/context-deletion-tools.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +2 -4
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.js +2 -60
- package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +2 -0
- 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/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +57 -32
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +11 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +13 -13
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-events.js +3 -3
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/flattened-tool-arguments.d.ts +18 -0
- package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
- package/dist/core/flattened-tool-arguments.js +104 -0
- package/dist/core/flattened-tool-arguments.js.map +1 -1
- package/dist/core/messages.d.ts +1 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +46 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -2
- 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.map +1 -1
- package/dist/core/sdk.js +12 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +15 -7
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +20 -9
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +9 -3
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +2 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts +3 -3
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +27 -8
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +3 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +55 -12
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-tool-dependencies.d.ts +10 -0
- package/dist/core/session-manager-tool-dependencies.d.ts.map +1 -0
- package/dist/core/session-manager-tool-dependencies.js +133 -0
- package/dist/core/session-manager-tool-dependencies.js.map +1 -0
- package/dist/core/session-manager-types.d.ts +22 -0
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +18 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.js +15 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +11 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/artifact-protocol.d.ts +11 -0
- package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
- package/dist/core/tools/artifact-protocol.js +76 -0
- package/dist/core/tools/artifact-protocol.js.map +1 -0
- package/dist/core/tools/artifacts.d.ts +18 -0
- package/dist/core/tools/artifacts.d.ts.map +1 -0
- package/dist/core/tools/artifacts.js +90 -0
- package/dist/core/tools/artifacts.js.map +1 -0
- package/dist/core/tools/bash-async-jobs.d.ts +20 -0
- package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
- package/dist/core/tools/bash-async-jobs.js +59 -0
- package/dist/core/tools/bash-async-jobs.js.map +1 -0
- package/dist/core/tools/bash-async-output.d.ts +10 -0
- package/dist/core/tools/bash-async-output.d.ts.map +1 -0
- package/dist/core/tools/bash-async-output.js +80 -0
- package/dist/core/tools/bash-async-output.js.map +1 -0
- package/dist/core/tools/bash-interceptor.d.ts +10 -0
- package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
- package/dist/core/tools/bash-interceptor.js +39 -0
- package/dist/core/tools/bash-interceptor.js.map +1 -0
- package/dist/core/tools/bash-leading-cd.d.ts +7 -0
- package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
- package/dist/core/tools/bash-leading-cd.js +59 -0
- package/dist/core/tools/bash-leading-cd.js.map +1 -0
- package/dist/core/tools/bash-pty-native.d.ts +14 -0
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
- package/dist/core/tools/bash-pty-native.js +71 -0
- package/dist/core/tools/bash-pty-native.js.map +1 -0
- package/dist/core/tools/bash.d.ts +28 -17
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +152 -35
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/block-resolver.d.ts +16 -0
- package/dist/core/tools/block-resolver.d.ts.map +1 -0
- package/dist/core/tools/block-resolver.js +74 -0
- package/dist/core/tools/block-resolver.js.map +1 -0
- package/dist/core/tools/conflict-registry.d.ts +16 -0
- package/dist/core/tools/conflict-registry.d.ts.map +1 -0
- package/dist/core/tools/conflict-registry.js +44 -0
- package/dist/core/tools/conflict-registry.js.map +1 -0
- package/dist/core/tools/directory-tree.d.ts +13 -0
- package/dist/core/tools/directory-tree.d.ts.map +1 -0
- package/dist/core/tools/directory-tree.js +81 -0
- package/dist/core/tools/directory-tree.js.map +1 -0
- package/dist/core/tools/edit.d.ts +4 -29
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +136 -228
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/fetch-url.d.ts +74 -0
- package/dist/core/tools/fetch-url.d.ts.map +1 -0
- package/dist/core/tools/fetch-url.js +518 -0
- package/dist/core/tools/fetch-url.js.map +1 -0
- package/dist/core/tools/find.d.ts +27 -9
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +400 -176
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/glob-path-utils.d.ts +8 -0
- package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
- package/dist/core/tools/glob-path-utils.js +26 -0
- package/dist/core/tools/glob-path-utils.js.map +1 -0
- package/dist/core/tools/grep.d.ts +12 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +141 -17
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
- package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/apply.js +752 -0
- package/dist/core/tools/hashline-engine/apply.js.map +1 -0
- package/dist/core/tools/hashline-engine/block.d.ts +40 -0
- package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/block.js +117 -0
- package/dist/core/tools/hashline-engine/block.js.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
- package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
- package/dist/core/tools/hashline-engine/format.d.ts +71 -0
- package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/format.js +178 -0
- package/dist/core/tools/hashline-engine/format.js.map +1 -0
- package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
- package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/fs.js +143 -0
- package/dist/core/tools/hashline-engine/fs.js.map +1 -0
- package/dist/core/tools/hashline-engine/index.d.ts +18 -0
- package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/index.js +20 -0
- package/dist/core/tools/hashline-engine/index.js.map +1 -0
- package/dist/core/tools/hashline-engine/input.d.ts +101 -0
- package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/input.js +398 -0
- package/dist/core/tools/hashline-engine/input.js.map +1 -0
- package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
- package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/messages.js +144 -0
- package/dist/core/tools/hashline-engine/messages.js.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.js +90 -0
- package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.js +33 -0
- package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
- package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
- package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/parser.js +381 -0
- package/dist/core/tools/hashline-engine/parser.js.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.js +341 -0
- package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.js +135 -0
- package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.js +168 -0
- package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.js +108 -0
- package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
- package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
- package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/stream.js +111 -0
- package/dist/core/tools/hashline-engine/stream.js.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
- package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
- package/dist/core/tools/hashline-engine/types.d.ts +166 -0
- package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/types.js +9 -0
- package/dist/core/tools/hashline-engine/types.js.map +1 -0
- package/dist/core/tools/hashline.d.ts +29 -0
- package/dist/core/tools/hashline.d.ts.map +1 -0
- package/dist/core/tools/hashline.js +110 -0
- package/dist/core/tools/hashline.js.map +1 -0
- package/dist/core/tools/index.d.ts +6 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +52 -35
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/notebook.d.ts +38 -0
- package/dist/core/tools/notebook.d.ts.map +1 -0
- package/dist/core/tools/notebook.js +125 -0
- package/dist/core/tools/notebook.js.map +1 -0
- package/dist/core/tools/read-document-extract.d.ts +9 -0
- package/dist/core/tools/read-document-extract.d.ts.map +1 -0
- package/dist/core/tools/read-document-extract.js +212 -0
- package/dist/core/tools/read-document-extract.js.map +1 -0
- package/dist/core/tools/read-selectors.d.ts +24 -0
- package/dist/core/tools/read-selectors.d.ts.map +1 -0
- package/dist/core/tools/read-selectors.js +277 -0
- package/dist/core/tools/read-selectors.js.map +1 -0
- package/dist/core/tools/read-url.d.ts +37 -0
- package/dist/core/tools/read-url.d.ts.map +1 -0
- package/dist/core/tools/read-url.js +39 -0
- package/dist/core/tools/read-url.js.map +1 -0
- package/dist/core/tools/read.d.ts +11 -11
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +224 -94
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +44 -0
- package/dist/core/tools/resource-selectors.d.ts.map +1 -0
- package/dist/core/tools/resource-selectors.js +808 -0
- package/dist/core/tools/resource-selectors.js.map +1 -0
- package/dist/core/tools/search-details.d.ts +26 -0
- package/dist/core/tools/search-details.d.ts.map +1 -0
- package/dist/core/tools/search-details.js +24 -0
- package/dist/core/tools/search-details.js.map +1 -0
- package/dist/core/tools/search-line-ranges.d.ts +11 -0
- package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
- package/dist/core/tools/search-line-ranges.js +65 -0
- package/dist/core/tools/search-line-ranges.js.map +1 -0
- package/dist/core/tools/search-native.d.ts +97 -0
- package/dist/core/tools/search-native.d.ts.map +1 -0
- package/dist/core/tools/search-native.js +27 -0
- package/dist/core/tools/search-native.js.map +1 -0
- package/dist/core/tools/search.d.ts +24 -0
- package/dist/core/tools/search.d.ts.map +1 -0
- package/dist/core/tools/search.js +573 -0
- package/dist/core/tools/search.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +4 -4
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +3 -3
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/url-ip-guards.d.ts +4 -0
- package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
- package/dist/core/tools/url-ip-guards.js +126 -0
- package/dist/core/tools/url-ip-guards.js.map +1 -0
- package/dist/core/tools/write.d.ts +12 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +166 -14
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -3
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +12 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +4 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js +131 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +7 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +15 -4
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +9 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +7 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +26 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +0 -5
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +1 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +80 -2
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +51 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +5 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +4 -1
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-onboarding.js +220 -0
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +4 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +9 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +28 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +21 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/markit.d.ts +8 -0
- package/dist/utils/markit.d.ts.map +1 -0
- package/dist/utils/markit.js +53 -0
- package/dist/utils/markit.js.map +1 -0
- package/dist/utils/paths.d.ts +2 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +14 -1
- package/dist/utils/paths.js.map +1 -1
- package/docs/compaction.md +18 -1
- package/docs/containerization.md +1 -1
- package/docs/docs.json +1 -0
- package/docs/extensions.md +25 -36
- package/docs/models.md +1 -1
- package/docs/providers.md +2 -1
- package/docs/quickstart.md +11 -6
- package/docs/sdk.md +5 -5
- package/docs/session-format.md +6 -0
- package/docs/sessions.md +6 -0
- package/docs/settings.md +7 -0
- package/docs/subagents.md +3 -2
- package/docs/tools.md +49 -0
- package/docs/usage.md +3 -3
- package/docs/workflows.md +112 -8
- package/examples/extensions/subagent/README.md +5 -5
- package/examples/extensions/subagent/agents/planner.md +1 -1
- package/examples/extensions/subagent/agents/reviewer.md +1 -1
- package/examples/extensions/subagent/agents/scout.md +2 -2
- package/examples/extensions/subagent/display.ts +3 -3
- package/examples/sdk/05-tools.ts +3 -3
- package/examples/sdk/README.md +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable workflow backend seam.
|
|
3
|
+
*
|
|
4
|
+
* This interface abstracts durable checkpoint storage so the workflow engine
|
|
5
|
+
* can persist `ctx.*` operation results without coupling to a specific storage
|
|
6
|
+
* backend. The default implementation is the zero-infrastructure
|
|
7
|
+
* per-workflow file backend, rooted under `~/.atomic/workflow-durable`, so
|
|
8
|
+
* cross-session resume works without user setup. {@link InMemoryDurableBackend}
|
|
9
|
+
* remains available for isolated tests and explicit custom overrides. The
|
|
10
|
+
* {@link DbosDurableBackend} adapter (in dbos-backend.ts) wraps the real
|
|
11
|
+
* `@dbos-inc/dbos-sdk` when configured.
|
|
12
|
+
*
|
|
13
|
+
* Design:
|
|
14
|
+
* - Only `ctx.*` blocks write checkpoints (tool, ui, stage).
|
|
15
|
+
* - Checkpoints are keyed by (workflowId, kind, checkpointId) for uniqueness.
|
|
16
|
+
* - Tool/ui checkpoints also key on a content hash so identical calls are
|
|
17
|
+
* idempotent (completed side effects are not repeated on resume).
|
|
18
|
+
* - The backend is the checkpoint source of truth; session JSONL entries are
|
|
19
|
+
* a discovery cache.
|
|
20
|
+
*
|
|
21
|
+
* cross-ref: issue #1498 — DBOS integration behind a backend seam.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { WorkflowSerializableValue } from "../shared/types.js";
|
|
25
|
+
import { createHash } from "node:crypto";
|
|
26
|
+
import type {
|
|
27
|
+
DurableCheckpoint,
|
|
28
|
+
DurableCheckpointEntry,
|
|
29
|
+
DurableToolCheckpoint,
|
|
30
|
+
DurableUiCheckpoint,
|
|
31
|
+
DurableStageCheckpoint,
|
|
32
|
+
DurableWorkflowHandle,
|
|
33
|
+
DurableWorkflowStatus,
|
|
34
|
+
ResumableWorkflowEntry,
|
|
35
|
+
WorkflowSerializableObject,
|
|
36
|
+
} from "./types.js";
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Backend interface
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Input for registering/updating a workflow in the durable backend.
|
|
44
|
+
* Optional fields default to existing values or zero.
|
|
45
|
+
*/
|
|
46
|
+
export type WorkflowRegistrationInput =
|
|
47
|
+
Omit<DurableWorkflowHandle, "completedCheckpoints" | "pendingPrompts" | "updatedAt">
|
|
48
|
+
& Partial<Pick<DurableWorkflowHandle, "completedCheckpoints" | "pendingPrompts" | "updatedAt">>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Abstract durable checkpoint store. Implementations:
|
|
52
|
+
* - per-workflow file backend — JSON-file-backed; default cross-process resume.
|
|
53
|
+
* - {@link DbosDurableBackend} — wraps `@dbos-inc/dbos-sdk` + Postgres.
|
|
54
|
+
* - {@link InMemoryDurableBackend} — process-local; explicit test/custom use.
|
|
55
|
+
*/
|
|
56
|
+
export interface DurableWorkflowBackend {
|
|
57
|
+
/**
|
|
58
|
+
* True when the backend persists across processes (file/DBOS). When false
|
|
59
|
+
* (in-memory), the engine skips session-cache persistence since there is no
|
|
60
|
+
* cross-session state to discover. This keeps in-process test runs from
|
|
61
|
+
* polluting session JSONL with discovery cache entries.
|
|
62
|
+
*/
|
|
63
|
+
readonly persistent: boolean;
|
|
64
|
+
/** Register or update a workflow's top-level metadata. */
|
|
65
|
+
registerWorkflow(handle: WorkflowRegistrationInput): void;
|
|
66
|
+
|
|
67
|
+
/** Record a completed checkpoint. Idempotent: same (kind, checkpointId) is a no-op. */
|
|
68
|
+
recordCheckpoint(checkpoint: DurableCheckpoint): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Optional async checkpoint persistence. DBOS-backed implementations use this
|
|
72
|
+
* so ctx.tool/ctx.ui can await durable writes before returning side-effect
|
|
73
|
+
* results to workflow code.
|
|
74
|
+
*/
|
|
75
|
+
recordCheckpointAsync?(checkpoint: DurableCheckpoint): Promise<void>;
|
|
76
|
+
|
|
77
|
+
/** Optional: wait for serialized durable writes to settle. */
|
|
78
|
+
flush?(): Promise<void>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Look up a cached tool output by content hash. Returns `undefined` if the
|
|
82
|
+
* tool has not completed. This is how `ctx.tool` avoids re-executing side
|
|
83
|
+
* effects on resume.
|
|
84
|
+
*/
|
|
85
|
+
getToolOutput(workflowId: string, argsHash: string): WorkflowSerializableValue | undefined;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Look up a cached UI response by prompt hash. Returns `undefined` if the
|
|
89
|
+
* prompt has not been answered. This is how `ctx.ui.*` resumes at pending
|
|
90
|
+
* prompts instead of re-asking completed ones.
|
|
91
|
+
*/
|
|
92
|
+
getUiResponse(workflowId: string, promptHash: string): WorkflowSerializableValue | undefined;
|
|
93
|
+
|
|
94
|
+
/** Look up a cached stage output by replay key. */
|
|
95
|
+
getStageOutput(workflowId: string, replayKey: string): WorkflowSerializableValue | undefined;
|
|
96
|
+
|
|
97
|
+
/** Look up resumable stage session metadata by replay key, when available. */
|
|
98
|
+
getStageSession(workflowId: string, replayKey: string): { sessionId?: string; sessionFile?: string } | undefined;
|
|
99
|
+
|
|
100
|
+
/** List all checkpoints for a workflow (in completion order). */
|
|
101
|
+
listCheckpoints(workflowId: string): readonly DurableCheckpoint[];
|
|
102
|
+
|
|
103
|
+
/** Get the top-level workflow handle, or `undefined` if not registered. */
|
|
104
|
+
getWorkflow(workflowId: string): DurableWorkflowHandle | undefined;
|
|
105
|
+
|
|
106
|
+
/** Update workflow status (running/paused/completed/failed/cancelled/blocked). */
|
|
107
|
+
setWorkflowStatus(workflowId: string, status: DurableWorkflowStatus, pendingPrompts?: number, resumable?: boolean): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* List resumable workflows (not completed/cancelled, or explicitly marked
|
|
111
|
+
* resumable after failure). Used by the `/workflow resume` selector.
|
|
112
|
+
*/
|
|
113
|
+
listResumableWorkflows(): readonly ResumableWorkflowEntry[];
|
|
114
|
+
|
|
115
|
+
/** Export a session-cache entry for the given workflow (for JSONL persistence). */
|
|
116
|
+
toCacheEntry(workflowId: string): DurableCheckpointEntry | undefined;
|
|
117
|
+
|
|
118
|
+
/** Clear all state (for tests). */
|
|
119
|
+
reset(): void;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Optional: hydrate a single workflow's checkpoints from the persistent
|
|
123
|
+
* store (DBOS) into the in-memory mirror. Implementations that do not need
|
|
124
|
+
* async hydration (in-memory, file) omit this method.
|
|
125
|
+
*/
|
|
126
|
+
hydrateWorkflow?(workflowId: string): Promise<void>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Optional: hydrate all resumable workflows from the persistent store (DBOS)
|
|
130
|
+
* into the in-memory mirror. Called before listing/resuming in a fresh
|
|
131
|
+
* process. Implementations that do not need async hydration omit this.
|
|
132
|
+
*/
|
|
133
|
+
hydrateResumableWorkflows?(): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
// Hashing helpers
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Compute a deterministic content digest for a JSON-serializable value.
|
|
142
|
+
* Uses canonical JSON stringification (sorted keys) for stability and SHA-256
|
|
143
|
+
* for collision resistance. The earlier 32-bit DJB2 hash demonstrably
|
|
144
|
+
* collided across distinct tool/stage identities and could cause completed
|
|
145
|
+
* side effects to be skipped (or merged) incorrectly on resume.
|
|
146
|
+
*
|
|
147
|
+
* cross-ref: issue #1498 — collision-resistant durable replay identities.
|
|
148
|
+
*/
|
|
149
|
+
export function durableHash(value: WorkflowSerializableValue | WorkflowSerializableObject): string {
|
|
150
|
+
const canonical = canonicalJsonString(value);
|
|
151
|
+
const digest = createHash("sha256").update(canonical).digest("hex");
|
|
152
|
+
return `h${digest.slice(0, 32)}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function canonicalJsonString(value: unknown): string {
|
|
156
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
157
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJsonString).join(",")}]`;
|
|
158
|
+
const obj = value as Record<string, unknown>;
|
|
159
|
+
const keys = Object.keys(obj).sort();
|
|
160
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJsonString(obj[k])}`).join(",")}}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// In-memory backend
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
interface InMemoryWorkflowRecord {
|
|
168
|
+
handle: DurableWorkflowHandle;
|
|
169
|
+
checkpoints: Map<string, DurableCheckpoint>;
|
|
170
|
+
toolByHash: Map<string, DurableToolCheckpoint>;
|
|
171
|
+
uiByHash: Map<string, DurableUiCheckpoint>;
|
|
172
|
+
stageOutputByReplayKey: Map<string, DurableStageCheckpoint>;
|
|
173
|
+
stageSessionByReplayKey: Map<string, DurableStageCheckpoint>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function checkpointKey(c: DurableCheckpoint): string {
|
|
177
|
+
return `${c.kind}:${c.checkpointId}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Process-local durable backend for tests and explicit custom overrides.
|
|
182
|
+
* Checkpoints live in memory for the lifetime of the process; the production
|
|
183
|
+
* default is the cross-process per-workflow file backend.
|
|
184
|
+
*/
|
|
185
|
+
export class InMemoryDurableBackend implements DurableWorkflowBackend {
|
|
186
|
+
public readonly persistent = false;
|
|
187
|
+
private readonly workflows = new Map<string, InMemoryWorkflowRecord>();
|
|
188
|
+
|
|
189
|
+
registerWorkflow(handle: WorkflowRegistrationInput): void {
|
|
190
|
+
const existing = this.workflows.get(handle.workflowId);
|
|
191
|
+
const completedCheckpoints = handle.completedCheckpoints ?? existing?.handle.completedCheckpoints ?? 0;
|
|
192
|
+
const pendingPrompts = handle.pendingPrompts ?? existing?.handle.pendingPrompts ?? 0;
|
|
193
|
+
const updatedAt = handle.updatedAt ?? Date.now();
|
|
194
|
+
const full: DurableWorkflowHandle = {
|
|
195
|
+
workflowId: handle.workflowId,
|
|
196
|
+
name: handle.name,
|
|
197
|
+
inputs: handle.inputs,
|
|
198
|
+
createdAt: handle.createdAt,
|
|
199
|
+
status: handle.status,
|
|
200
|
+
...(handle.sessionFile !== undefined ? { sessionFile: handle.sessionFile } : {}),
|
|
201
|
+
completedCheckpoints,
|
|
202
|
+
pendingPrompts,
|
|
203
|
+
updatedAt,
|
|
204
|
+
...(handle.label !== undefined ? { label: handle.label } : {}),
|
|
205
|
+
...(handle.rootWorkflowId !== undefined ? { rootWorkflowId: handle.rootWorkflowId } : {}),
|
|
206
|
+
...(handle.resumable !== undefined ? { resumable: handle.resumable } : {}),
|
|
207
|
+
};
|
|
208
|
+
if (existing) existing.handle = full;
|
|
209
|
+
else this.workflows.set(handle.workflowId, { handle: full, checkpoints: new Map(), toolByHash: new Map(), uiByHash: new Map(), stageOutputByReplayKey: new Map(), stageSessionByReplayKey: new Map() });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
recordCheckpoint(checkpoint: DurableCheckpoint): void {
|
|
213
|
+
const rec = this.workflows.get(checkpoint.workflowId);
|
|
214
|
+
if (!rec) return;
|
|
215
|
+
const key = checkpointKey(checkpoint);
|
|
216
|
+
if (rec.checkpoints.has(key)) return; // idempotent
|
|
217
|
+
rec.checkpoints.set(key, checkpoint);
|
|
218
|
+
if (checkpoint.kind === "tool") rec.toolByHash.set(checkpoint.argsHash, checkpoint);
|
|
219
|
+
else if (checkpoint.kind === "ui") rec.uiByHash.set(checkpoint.promptHash, checkpoint);
|
|
220
|
+
else {
|
|
221
|
+
if ("output" in checkpoint) rec.stageOutputByReplayKey.set(checkpoint.replayKey, checkpoint);
|
|
222
|
+
if (checkpoint.sessionId !== undefined || checkpoint.sessionFile !== undefined) {
|
|
223
|
+
const existing = rec.stageSessionByReplayKey.get(checkpoint.replayKey);
|
|
224
|
+
if (existing === undefined || checkpoint.completedAt >= existing.completedAt) {
|
|
225
|
+
rec.stageSessionByReplayKey.set(checkpoint.replayKey, checkpoint);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
rec.handle = { ...rec.handle, completedCheckpoints: rec.checkpoints.size, updatedAt: checkpoint.completedAt };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
getToolOutput(workflowId: string, argsHash: string): WorkflowSerializableValue | undefined {
|
|
233
|
+
return this.workflows.get(workflowId)?.toolByHash.get(argsHash)?.output;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
getUiResponse(workflowId: string, promptHash: string): WorkflowSerializableValue | undefined {
|
|
237
|
+
return this.workflows.get(workflowId)?.uiByHash.get(promptHash)?.response;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getStageOutput(workflowId: string, replayKey: string): WorkflowSerializableValue | undefined {
|
|
241
|
+
const checkpoint = this.workflows.get(workflowId)?.stageOutputByReplayKey.get(replayKey);
|
|
242
|
+
return checkpoint !== undefined && "output" in checkpoint ? checkpoint.output : undefined;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
getStageSession(workflowId: string, replayKey: string): { sessionId?: string; sessionFile?: string } | undefined {
|
|
246
|
+
const checkpoint = this.workflows.get(workflowId)?.stageSessionByReplayKey.get(replayKey);
|
|
247
|
+
if (checkpoint?.sessionId === undefined && checkpoint?.sessionFile === undefined) return undefined;
|
|
248
|
+
return { ...(checkpoint.sessionId !== undefined ? { sessionId: checkpoint.sessionId } : {}), ...(checkpoint.sessionFile !== undefined ? { sessionFile: checkpoint.sessionFile } : {}) };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
listCheckpoints(workflowId: string): readonly DurableCheckpoint[] {
|
|
252
|
+
const rec = this.workflows.get(workflowId);
|
|
253
|
+
if (!rec) return [];
|
|
254
|
+
return [...rec.checkpoints.values()].sort((a, b) => a.completedAt - b.completedAt);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
getWorkflow(workflowId: string): DurableWorkflowHandle | undefined {
|
|
258
|
+
return this.workflows.get(workflowId)?.handle;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
setWorkflowStatus(workflowId: string, status: DurableWorkflowStatus, pendingPrompts?: number, resumable?: boolean): void {
|
|
262
|
+
const rec = this.workflows.get(workflowId);
|
|
263
|
+
if (!rec) return;
|
|
264
|
+
rec.handle = { ...rec.handle, status, updatedAt: Date.now(), ...(pendingPrompts !== undefined ? { pendingPrompts } : {}), ...(resumable !== undefined ? { resumable } : {}) };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
listResumableWorkflows(): readonly ResumableWorkflowEntry[] {
|
|
268
|
+
return [...this.workflows.values()]
|
|
269
|
+
.filter((rec) => isRootWorkflow(rec.handle) && isResumableHandle(rec.handle))
|
|
270
|
+
.map((rec) => toResumableEntry(rec.handle));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
toCacheEntry(workflowId: string): DurableCheckpointEntry | undefined {
|
|
274
|
+
const rec = this.workflows.get(workflowId);
|
|
275
|
+
if (!rec) return undefined;
|
|
276
|
+
const h = rec.handle;
|
|
277
|
+
return {
|
|
278
|
+
type: "workflow.durable.checkpoint",
|
|
279
|
+
workflowId: h.workflowId,
|
|
280
|
+
name: h.name,
|
|
281
|
+
inputs: h.inputs,
|
|
282
|
+
status: h.status,
|
|
283
|
+
completedCheckpoints: h.completedCheckpoints,
|
|
284
|
+
pendingPrompts: h.pendingPrompts,
|
|
285
|
+
...(h.label !== undefined ? { label: h.label } : {}),
|
|
286
|
+
...(h.rootWorkflowId !== undefined ? { rootWorkflowId: h.rootWorkflowId } : {}),
|
|
287
|
+
...(h.resumable !== undefined ? { resumable: h.resumable } : {}),
|
|
288
|
+
ts: h.updatedAt,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
reset(): void {
|
|
293
|
+
this.workflows.clear();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Export all records (for FileDurableBackend serialization or debugging). */
|
|
297
|
+
exportAll(): readonly { readonly handle: DurableWorkflowHandle; readonly checkpoints: readonly DurableCheckpoint[] }[] {
|
|
298
|
+
return [...this.workflows.values()].map((rec) => ({ handle: rec.handle, checkpoints: [...rec.checkpoints.values()] }));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Import records (for FileDurableBackend deserialization). */
|
|
302
|
+
importAll(records: readonly { readonly handle: DurableWorkflowHandle; readonly checkpoints: readonly DurableCheckpoint[] }[]): void {
|
|
303
|
+
for (const rec of records) {
|
|
304
|
+
this.registerWorkflow(rec.handle);
|
|
305
|
+
for (const cp of rec.checkpoints) this.recordCheckpoint(cp);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function isRootWorkflow(handle: DurableWorkflowHandle): boolean {
|
|
311
|
+
return handle.rootWorkflowId === undefined || handle.rootWorkflowId === handle.workflowId;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function hasResumeProgress(handle: DurableWorkflowHandle): boolean {
|
|
315
|
+
return handle.completedCheckpoints > 0 || handle.pendingPrompts > 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function isResumableHandle(handle: DurableWorkflowHandle): boolean {
|
|
319
|
+
if (handle.status === "failed" || handle.status === "blocked") return handle.resumable !== false;
|
|
320
|
+
// `running`/`paused` are both resumable at the backend level: a `running`
|
|
321
|
+
// durable handle may belong to a crashed process (no live executor), which
|
|
322
|
+
// is exactly the cross-session crash-recovery case. Same-session
|
|
323
|
+
// double-resume is prevented by the command layer, which hides durable
|
|
324
|
+
// entries that match an active live run.
|
|
325
|
+
return (handle.status === "running" || handle.status === "paused") && hasResumeProgress(handle);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function toResumableEntry(handle: DurableWorkflowHandle): ResumableWorkflowEntry {
|
|
329
|
+
return {
|
|
330
|
+
workflowId: handle.workflowId,
|
|
331
|
+
name: handle.name,
|
|
332
|
+
inputs: handle.inputs,
|
|
333
|
+
status: handle.status,
|
|
334
|
+
completedCheckpoints: handle.completedCheckpoints,
|
|
335
|
+
pendingPrompts: handle.pendingPrompts,
|
|
336
|
+
...(handle.sessionFile !== undefined ? { sessionFile: handle.sessionFile } : {}),
|
|
337
|
+
...(handle.label !== undefined ? { label: handle.label } : {}),
|
|
338
|
+
...(handle.rootWorkflowId !== undefined ? { rootWorkflowId: handle.rootWorkflowId } : {}),
|
|
339
|
+
...(handle.resumable !== undefined ? { resumable: handle.resumable } : {}),
|
|
340
|
+
createdAt: handle.createdAt,
|
|
341
|
+
updatedAt: handle.updatedAt,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WorkflowChildResult,
|
|
3
|
+
WorkflowDefinition,
|
|
4
|
+
WorkflowInputValues,
|
|
5
|
+
WorkflowOutputValues,
|
|
6
|
+
WorkflowRunChildArgs,
|
|
7
|
+
WorkflowSerializableValue,
|
|
8
|
+
} from "../shared/types.js";
|
|
9
|
+
import { isWorkflowDefinition, workflowDefinitionRequirementMessage } from "../runs/foreground/executor-child-helpers.js";
|
|
10
|
+
import type { DurableWorkflowBackend } from "./backend.js";
|
|
11
|
+
import type { DurableScope } from "./scoped-backend.js";
|
|
12
|
+
import { recordCheckpointDurably } from "./tool-primitive.js";
|
|
13
|
+
|
|
14
|
+
export function createDurableChildWorkflowPrimitive(input: {
|
|
15
|
+
readonly workflowId: string;
|
|
16
|
+
readonly rootWorkflowId: string;
|
|
17
|
+
readonly backend: DurableWorkflowBackend;
|
|
18
|
+
readonly nextReplayKey: (name: string) => string;
|
|
19
|
+
readonly recordCachedStage: (name: string, replayKey: string, output: WorkflowSerializableValue) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Publish the durable scope computed for the next child invocation so the
|
|
22
|
+
* child runner can consume it and route its internal side-effect checkpoints
|
|
23
|
+
* under the root workflow. Avoids re-deriving the ordinal independently.
|
|
24
|
+
*/
|
|
25
|
+
readonly setChildDurableScope: (scope: DurableScope) => void;
|
|
26
|
+
readonly workflow: <
|
|
27
|
+
TChildInputs extends WorkflowInputValues,
|
|
28
|
+
TChildOutputs extends WorkflowOutputValues,
|
|
29
|
+
TChildRunInputs extends WorkflowInputValues = TChildInputs,
|
|
30
|
+
>(
|
|
31
|
+
child: WorkflowDefinition<TChildInputs, TChildOutputs, TChildRunInputs>,
|
|
32
|
+
...args: WorkflowRunChildArgs<TChildRunInputs>
|
|
33
|
+
) => Promise<WorkflowChildResult<TChildOutputs>>;
|
|
34
|
+
}) {
|
|
35
|
+
return async <
|
|
36
|
+
TChildInputs extends WorkflowInputValues,
|
|
37
|
+
TChildOutputs extends WorkflowOutputValues,
|
|
38
|
+
TChildRunInputs extends WorkflowInputValues = TChildInputs,
|
|
39
|
+
>(
|
|
40
|
+
child: WorkflowDefinition<TChildInputs, TChildOutputs, TChildRunInputs>,
|
|
41
|
+
...args: WorkflowRunChildArgs<TChildRunInputs>
|
|
42
|
+
): Promise<WorkflowChildResult<TChildOutputs>> => {
|
|
43
|
+
if (!isWorkflowDefinition(child)) throw new Error(workflowDefinitionRequirementMessage("ctx.workflow(definition)", child));
|
|
44
|
+
const options = args[0] as { readonly stageName?: string } | undefined;
|
|
45
|
+
const boundaryName = options?.stageName ?? `workflow:${child.normalizedName}`;
|
|
46
|
+
const replayKey = input.nextReplayKey(boundaryName);
|
|
47
|
+
// Route this child's internal side-effect checkpoints under the root
|
|
48
|
+
// workflow with a stable boundary key, so an interrupted child does not
|
|
49
|
+
// re-execute completed side effects on parent resume.
|
|
50
|
+
// cross-ref: issue #1498.
|
|
51
|
+
input.setChildDurableScope({ rootWorkflowId: input.rootWorkflowId, scopePrefix: replayKey });
|
|
52
|
+
const cached = input.backend.getStageOutput(input.workflowId, replayKey);
|
|
53
|
+
if (cached !== undefined && isWorkflowChildResult(cached)) {
|
|
54
|
+
input.recordCachedStage(boundaryName, replayKey, cached);
|
|
55
|
+
return cached as WorkflowChildResult<TChildOutputs>;
|
|
56
|
+
}
|
|
57
|
+
const result = await input.workflow(child, ...args);
|
|
58
|
+
await recordCheckpointDurably(input.backend, {
|
|
59
|
+
kind: "stage",
|
|
60
|
+
workflowId: input.workflowId,
|
|
61
|
+
checkpointId: `workflow:${replayKey}`,
|
|
62
|
+
name: boundaryName,
|
|
63
|
+
replayKey,
|
|
64
|
+
output: result as WorkflowSerializableValue,
|
|
65
|
+
completedAt: Date.now(),
|
|
66
|
+
});
|
|
67
|
+
return result as WorkflowChildResult<TChildOutputs>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isWorkflowChildResult(value: WorkflowSerializableValue): value is WorkflowChildResult<WorkflowOutputValues> {
|
|
72
|
+
return typeof value === "object"
|
|
73
|
+
&& value !== null
|
|
74
|
+
&& !Array.isArray(value)
|
|
75
|
+
&& typeof (value as { readonly workflow?: WorkflowSerializableValue }).workflow === "string"
|
|
76
|
+
&& typeof (value as { readonly runId?: WorkflowSerializableValue }).runId === "string"
|
|
77
|
+
&& typeof (value as { readonly status?: WorkflowSerializableValue }).status === "string"
|
|
78
|
+
&& typeof (value as { readonly outputs?: WorkflowSerializableValue }).outputs === "object";
|
|
79
|
+
}
|