@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,61 @@
|
|
|
1
|
+
import { pauseRun, type PauseResult } from "./status.js";
|
|
2
|
+
import { store as defaultStore } from "../../shared/store.js";
|
|
3
|
+
import type { Store } from "../../shared/store-public-types.js";
|
|
4
|
+
import { topLevelWorkflowRuns } from "../../shared/run-visibility.js";
|
|
5
|
+
import type { StageControlRegistry } from "../foreground/stage-control-registry.js";
|
|
6
|
+
import { getDurableBackend } from "../../durable/factory.js";
|
|
7
|
+
|
|
8
|
+
export type QuitRunResult = PauseResult;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quit/detach a workflow UI without authoritatively killing the workflow.
|
|
12
|
+
*
|
|
13
|
+
* This is the graph-panel/orchestrator close affordance: it pauses any live
|
|
14
|
+
* stage handles when possible, annotates the run as resumable via
|
|
15
|
+
* `/workflow resume`, and deliberately does NOT abort through the cancellation
|
|
16
|
+
* registry or append a terminal `workflow.run.end` entry. `/workflow kill`
|
|
17
|
+
* remains the only explicit non-resumable manual kill path.
|
|
18
|
+
*/
|
|
19
|
+
export function quitRun(
|
|
20
|
+
runId: string,
|
|
21
|
+
opts?: {
|
|
22
|
+
store?: Store;
|
|
23
|
+
stageControlRegistry?: StageControlRegistry;
|
|
24
|
+
},
|
|
25
|
+
): QuitRunResult {
|
|
26
|
+
const activeStore = opts?.store ?? defaultStore;
|
|
27
|
+
const run = activeStore.runs().find((candidate) => candidate.id === runId);
|
|
28
|
+
if (!run) return { ok: false, runId, reason: "not_found" };
|
|
29
|
+
if (run.endedAt !== undefined) return { ok: false, runId, reason: "already_ended" };
|
|
30
|
+
|
|
31
|
+
const paused = pauseRun(runId, opts);
|
|
32
|
+
if (!paused.ok && paused.reason !== "no_active_stages") return paused;
|
|
33
|
+
activeStore.recordRunPaused(runId, undefined, { exitReason: "quit", resumable: true });
|
|
34
|
+
// Mark the durable handle inactive so `/workflow resume` in this or another
|
|
35
|
+
// session can discover it again. While the run stays `running` in the store
|
|
36
|
+
// and (after a fresh dispatch) in the durable backend, it is hidden from the
|
|
37
|
+
// resume selector and refused on resume; quitting flips durable to `paused`.
|
|
38
|
+
markDurableQuit(runId);
|
|
39
|
+
return paused.ok ? paused : { ok: true, runId, paused: [] };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function markDurableQuit(runId: string): void {
|
|
43
|
+
let backend;
|
|
44
|
+
try {
|
|
45
|
+
backend = getDurableBackend();
|
|
46
|
+
} catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (backend.getWorkflow(runId) !== undefined) {
|
|
50
|
+
backend.setWorkflowStatus(runId, "paused", undefined, true);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function quitAllRuns(opts?: {
|
|
55
|
+
store?: Store;
|
|
56
|
+
stageControlRegistry?: StageControlRegistry;
|
|
57
|
+
}): QuitRunResult[] {
|
|
58
|
+
const activeStore = opts?.store ?? defaultStore;
|
|
59
|
+
const inFlight = topLevelWorkflowRuns(activeStore.runs()).filter((r) => r.endedAt === undefined);
|
|
60
|
+
return inFlight.map((r) => quitRun(r.id, { store: activeStore, stageControlRegistry: opts?.stageControlRegistry }));
|
|
61
|
+
}
|
|
@@ -67,7 +67,7 @@ export async function mapParallelSteps<T>(
|
|
|
67
67
|
concurrency: number | undefined,
|
|
68
68
|
failFast: boolean | undefined,
|
|
69
69
|
mapper: (step: WorkflowTaskStep) => Promise<T>,
|
|
70
|
-
onFirstFailure?: (error: unknown) => void
|
|
70
|
+
onFirstFailure?: (error: unknown) => void | Promise<void>,
|
|
71
71
|
control?: {
|
|
72
72
|
readonly beforeDequeue?: () => void;
|
|
73
73
|
readonly beforeMap?: () => void;
|
|
@@ -92,11 +92,11 @@ export async function mapParallelSteps<T>(
|
|
|
92
92
|
controlSignal = error;
|
|
93
93
|
if (failFastEnabled) rejectFirstFailure(error);
|
|
94
94
|
};
|
|
95
|
-
const recordFailure = (index: number, error: unknown): void => {
|
|
95
|
+
const recordFailure = async (index: number, error: unknown): Promise<void> => {
|
|
96
96
|
failures.push({ index, error });
|
|
97
97
|
if (firstFailure === undefined) {
|
|
98
98
|
firstFailure = error;
|
|
99
|
-
onFirstFailure?.(error);
|
|
99
|
+
await onFirstFailure?.(error);
|
|
100
100
|
if (failFastEnabled) rejectFirstFailure(error);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
@@ -112,7 +112,7 @@ export async function mapParallelSteps<T>(
|
|
|
112
112
|
selectControlSignal(err);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
recordFailure(nextIndex, err);
|
|
115
|
+
await recordFailure(nextIndex, err);
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
if (controlSignal !== undefined) return;
|
|
@@ -128,7 +128,7 @@ export async function mapParallelSteps<T>(
|
|
|
128
128
|
selectControlSignal(err);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
recordFailure(index, err);
|
|
131
|
+
await recordFailure(index, err);
|
|
132
132
|
if (failFastEnabled) return;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -8,6 +8,21 @@ import { hasExplicitFastModeCandidate } from "./executor-direct-helpers.js";
|
|
|
8
8
|
import { applyFailureToStage } from "./executor-lifecycle.js";
|
|
9
9
|
import { isTerminalStage } from "./executor-scheduler.js";
|
|
10
10
|
|
|
11
|
+
export interface TrackedStageCallOptions {
|
|
12
|
+
readonly eagerSession?: boolean;
|
|
13
|
+
readonly allowFinalized?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TrackedStageCaller = <T>(
|
|
17
|
+
call: () => Promise<T>,
|
|
18
|
+
eagerSessionOrOptions?: boolean | TrackedStageCallOptions,
|
|
19
|
+
) => Promise<T>;
|
|
20
|
+
|
|
21
|
+
function normalizeTrackedStageCallOptions(input: boolean | TrackedStageCallOptions | undefined): Required<TrackedStageCallOptions> {
|
|
22
|
+
if (typeof input === "boolean") return { eagerSession: input, allowFinalized: false };
|
|
23
|
+
return { eagerSession: input?.eagerSession === true, allowFinalized: input?.allowFinalized === true };
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
export function createTrackedStageCaller(input: {
|
|
12
27
|
readonly runtime: LiveStageRuntime;
|
|
13
28
|
readonly limiter: ConcurrencyLimiter;
|
|
@@ -15,7 +30,7 @@ export function createTrackedStageCaller(input: {
|
|
|
15
30
|
readonly adapters: StageAdapters;
|
|
16
31
|
readonly hasContinuation: boolean;
|
|
17
32
|
readonly hasScopedParents: boolean;
|
|
18
|
-
}):
|
|
33
|
+
}): TrackedStageCaller {
|
|
19
34
|
const { runtime } = input;
|
|
20
35
|
const readinessGateEnabled = runtime.opts.confirmStageReadiness !== undefined || runtime.opts.usePromptNodesForUi === true;
|
|
21
36
|
const confirmReadiness = async (): Promise<"advance" | "stay"> => {
|
|
@@ -68,22 +83,24 @@ export function createTrackedStageCaller(input: {
|
|
|
68
83
|
return result;
|
|
69
84
|
};
|
|
70
85
|
|
|
71
|
-
return async <T>(call: () => Promise<T>,
|
|
86
|
+
return async <T>(call: () => Promise<T>, eagerSessionOrOptions?: boolean | TrackedStageCallOptions): Promise<T> => {
|
|
87
|
+
const callOptions = normalizeTrackedStageCallOptions(eagerSessionOrOptions);
|
|
72
88
|
runtime.exit.throwIfWorkflowExitSelected();
|
|
73
89
|
await runtime.scheduler.waitForStageRelease(runtime.stageId, runtime.releaseLiveHandle);
|
|
74
|
-
if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
|
|
90
|
+
if (runtime.state.stageFinalized && !callOptions.allowFinalized) throw runtime.parallelFailFastError();
|
|
75
91
|
|
|
76
92
|
await input.limiter.acquire();
|
|
77
93
|
try {
|
|
78
94
|
await runtime.scheduler.waitForStageRelease(runtime.stageId, runtime.releaseLiveHandle);
|
|
79
95
|
runtime.exit.throwIfWorkflowExitSelected();
|
|
80
|
-
if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
|
|
96
|
+
if (runtime.state.stageFinalized && !callOptions.allowFinalized) throw runtime.parallelFailFastError();
|
|
81
97
|
} catch (err) {
|
|
82
98
|
input.limiter.release();
|
|
83
99
|
throw err;
|
|
84
100
|
}
|
|
85
101
|
|
|
86
|
-
|
|
102
|
+
const trackStageLifecycle = !runtime.state.stageFinalized;
|
|
103
|
+
if (trackStageLifecycle && !input.hasContinuation && runtime.stageSnapshot.startedAt === undefined && !input.hasScopedParents) {
|
|
87
104
|
const actualParentIds = runtime.scheduler.tracker.currentParents();
|
|
88
105
|
const sameParents = actualParentIds.length === runtime.stageSnapshot.parentIds.length &&
|
|
89
106
|
actualParentIds.every((value) => runtime.stageSnapshot.parentIds.includes(value));
|
|
@@ -92,25 +109,29 @@ export function createTrackedStageCaller(input: {
|
|
|
92
109
|
runtime.scheduler.setStageParentIds(runtime.stageSnapshot, actualParentIds);
|
|
93
110
|
}
|
|
94
111
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
if (trackStageLifecycle) {
|
|
113
|
+
runtime.stageSnapshot.status = "running";
|
|
114
|
+
runtime.stageSnapshot.startedAt = Date.now();
|
|
115
|
+
const hasNoExplicitModelConfig = input.options?.model === undefined && input.options?.fallbackModels === undefined;
|
|
116
|
+
const promptAdapterHandlesInitialPrompt = input.adapters.prompt !== undefined;
|
|
117
|
+
if (callOptions.eagerSession && !promptAdapterHandlesInitialPrompt && (hasNoExplicitModelConfig || await hasExplicitFastModeCandidate({
|
|
118
|
+
model: input.options?.model,
|
|
119
|
+
fallbackModels: input.options?.fallbackModels,
|
|
120
|
+
models: runtime.opts.models,
|
|
121
|
+
}))) {
|
|
122
|
+
try {
|
|
123
|
+
await runtime.innerCtx.__ensureSession();
|
|
124
|
+
runtime.captureStageSessionMeta();
|
|
125
|
+
} catch (err) {
|
|
126
|
+
if (!(err instanceof Error && err.message.includes("prompt adapter not configured"))) throw err;
|
|
127
|
+
}
|
|
109
128
|
}
|
|
129
|
+
runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
|
|
130
|
+
runtime.activeStore.recordStageStart(runtime.runId, runtime.stageSnapshot);
|
|
131
|
+
runtime.appendStageStartOnce();
|
|
132
|
+
} else {
|
|
133
|
+
runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
|
|
110
134
|
}
|
|
111
|
-
runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
|
|
112
|
-
runtime.activeStore.recordStageStart(runtime.runId, runtime.stageSnapshot);
|
|
113
|
-
runtime.appendStageStartOnce();
|
|
114
135
|
|
|
115
136
|
runtime.mcpScope.apply();
|
|
116
137
|
|
|
@@ -158,37 +179,57 @@ export function createTrackedStageCaller(input: {
|
|
|
158
179
|
}
|
|
159
180
|
runtime.captureStageSessionMeta();
|
|
160
181
|
runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
|
|
161
|
-
if (runtime.stageFailFastScope?.failed === true && runtime.stageFailFastScope.activeStages.has(runtime.stageId)) {
|
|
182
|
+
if (trackStageLifecycle && runtime.stageFailFastScope?.failed === true && runtime.stageFailFastScope.activeStages.has(runtime.stageId)) {
|
|
162
183
|
runtime.markSkippedForParallelFailFast();
|
|
163
184
|
throw runtime.parallelFailFastError();
|
|
164
185
|
}
|
|
165
|
-
if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
if (trackStageLifecycle && runtime.state.stageFinalized) throw runtime.parallelFailFastError();
|
|
187
|
+
if (trackStageLifecycle) {
|
|
188
|
+
runtime.stageSnapshot.status = "completed";
|
|
189
|
+
const assistantText = runtime.innerCtx.__getLastAssistantText();
|
|
190
|
+
if (assistantText !== undefined) runtime.stageSnapshot.result = assistantText;
|
|
191
|
+
}
|
|
169
192
|
return result;
|
|
170
193
|
} catch (err) {
|
|
171
194
|
const workflowExitAbort = runtime.signal.aborted ? runtime.exit.currentWorkflowExitAbortReason() : undefined;
|
|
172
195
|
if (workflowExitAbort !== undefined && !runtime.state.skippedForParallelFailFast) {
|
|
173
196
|
runtime.state.stageClosedByWorkflowExit = true;
|
|
174
|
-
if (!isTerminalStage(runtime.stageSnapshot)) {
|
|
197
|
+
if (trackStageLifecycle && !isTerminalStage(runtime.stageSnapshot)) {
|
|
175
198
|
runtime.stageSnapshot.status = "skipped";
|
|
176
199
|
runtime.stageSnapshot.skippedReason = runtime.exit.workflowExitSkippedReason(workflowExitAbort.reason);
|
|
177
200
|
}
|
|
178
|
-
} else if (!runtime.signal.aborted && !runtime.state.skippedForParallelFailFast) {
|
|
201
|
+
} else if (trackStageLifecycle && !runtime.signal.aborted && !runtime.state.skippedForParallelFailFast) {
|
|
179
202
|
applyFailureToStage(runtime.stageSnapshot, runtime.classifyExecutorFailure(err));
|
|
180
203
|
}
|
|
181
204
|
throw err;
|
|
182
205
|
} finally {
|
|
206
|
+
// Finalization, handle release, and limiter release are each independent.
|
|
207
|
+
// If finalizeStageSnapshot() throws, the limiter must still be released
|
|
208
|
+
// so the concurrency semaphore is not leaked.
|
|
209
|
+
// cross-ref: issue #1498 — durable finalization failures must not leak the stage limiter.
|
|
183
210
|
runtime.mcpScope.clear();
|
|
184
211
|
runtime.captureStageSessionMeta();
|
|
185
|
-
|
|
186
|
-
if (
|
|
212
|
+
let finalizationError: { readonly thrown: true; readonly error: unknown } | undefined;
|
|
213
|
+
if (trackStageLifecycle) {
|
|
214
|
+
try {
|
|
215
|
+
await runtime.finalizeStageSnapshot();
|
|
216
|
+
} catch (err) {
|
|
217
|
+
finalizationError = { thrown: true, error: err };
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
|
|
221
|
+
await runtime.releaseLiveHandle().catch(() => {});
|
|
222
|
+
} else {
|
|
223
|
+
await runtime.dropStageControlForCompletion().catch(() => {});
|
|
224
|
+
}
|
|
225
|
+
} catch {
|
|
226
|
+
// Best-effort: handle release failure must not prevent limiter release.
|
|
227
|
+
}
|
|
228
|
+
} else if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
|
|
187
229
|
await runtime.releaseLiveHandle().catch(() => {});
|
|
188
|
-
} else {
|
|
189
|
-
await runtime.dropStageControlForCompletion().catch(() => {});
|
|
190
230
|
}
|
|
191
231
|
input.limiter.release();
|
|
232
|
+
if (finalizationError !== undefined) throw finalizationError.error;
|
|
192
233
|
}
|
|
193
234
|
};
|
|
194
235
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StageContextWithMeta, StageNoticeInput, LiveStageRuntime } from "./executor-stage-types.js";
|
|
2
2
|
import type { InternalStageContext } from "./stage-runner.js";
|
|
3
|
+
import type { TrackedStageCaller } from "./executor-stage-call.js";
|
|
3
4
|
|
|
4
5
|
function noticeValue(value: unknown): string {
|
|
5
6
|
if (typeof value === "string") return value;
|
|
@@ -31,7 +32,7 @@ function compactionMeta(result: unknown): string | undefined {
|
|
|
31
32
|
|
|
32
33
|
export function createStageContext(input: {
|
|
33
34
|
readonly runtime: LiveStageRuntime;
|
|
34
|
-
readonly runTrackedStageCall:
|
|
35
|
+
readonly runTrackedStageCall: TrackedStageCaller;
|
|
35
36
|
}): StageContextWithMeta {
|
|
36
37
|
const { runtime } = input;
|
|
37
38
|
const recordStageNotice = (notice: StageNoticeInput): void => {
|
|
@@ -43,6 +44,19 @@ export function createStageContext(input: {
|
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
const innerCtx: InternalStageContext = runtime.innerCtx;
|
|
47
|
+
const sendStreamingUserMessage: InternalStageContext["sendUserMessage"] = async (text, options) => {
|
|
48
|
+
runtime.mcpScope.apply();
|
|
49
|
+
try {
|
|
50
|
+
await innerCtx.sendUserMessage(text, options);
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
runtime.mcpScope.clear();
|
|
54
|
+
} finally {
|
|
55
|
+
runtime.captureStageSessionMeta();
|
|
56
|
+
runtime.applyModelFallbackMeta(innerCtx.__modelFallbackMeta());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
46
60
|
return {
|
|
47
61
|
name: innerCtx.name,
|
|
48
62
|
prompt: (text, promptOptions) => {
|
|
@@ -53,6 +67,11 @@ export function createStageContext(input: {
|
|
|
53
67
|
runtime.throwIfStageMutationBlocked();
|
|
54
68
|
return input.runTrackedStageCall(() => innerCtx.complete(text, completeOptions));
|
|
55
69
|
},
|
|
70
|
+
sendUserMessage: (text, options) => {
|
|
71
|
+
runtime.throwIfStageMutationBlocked();
|
|
72
|
+
if (innerCtx.isStreaming) return sendStreamingUserMessage(text, options);
|
|
73
|
+
return input.runTrackedStageCall(() => innerCtx.sendUserMessage(text, options), { allowFinalized: true });
|
|
74
|
+
},
|
|
56
75
|
steer: (text) => {
|
|
57
76
|
runtime.throwIfStageMutationBlocked();
|
|
58
77
|
return innerCtx.steer(text);
|
|
@@ -193,6 +193,7 @@ export function createWorkflowStageFactory(input: {
|
|
|
193
193
|
if (meta.sessionId !== undefined) stageSnapshot.sessionId = meta.sessionId;
|
|
194
194
|
if (meta.sessionFile !== undefined) stageSnapshot.sessionFile = meta.sessionFile;
|
|
195
195
|
if (meta.sessionId !== undefined || meta.sessionFile !== undefined) input.activeStore.recordStageSession(input.runId, stageId, meta);
|
|
196
|
+
void input.opts.onStageSession?.(input.runId, stageSnapshot);
|
|
196
197
|
};
|
|
197
198
|
const releaseLiveHandle = async (): Promise<void> => {
|
|
198
199
|
if (state.liveHandleReleased) return;
|
|
@@ -226,7 +227,7 @@ export function createWorkflowStageFactory(input: {
|
|
|
226
227
|
});
|
|
227
228
|
};
|
|
228
229
|
|
|
229
|
-
const finalizeStageSnapshot = (): boolean => {
|
|
230
|
+
const finalizeStageSnapshot = async (): Promise<boolean> => {
|
|
230
231
|
if (state.stageFinalized) return false;
|
|
231
232
|
if (stageSnapshot.endedAt !== undefined && isTerminalStage(stageSnapshot)) {
|
|
232
233
|
state.stageFinalized = true;
|
|
@@ -242,7 +243,7 @@ export function createWorkflowStageFactory(input: {
|
|
|
242
243
|
applyModelFallbackMeta(innerCtx.__modelFallbackMeta());
|
|
243
244
|
input.activeStore.recordStageEnd(input.runId, stageSnapshot);
|
|
244
245
|
stageUiBroker.cancelStagePrompt(input.runId, stageId, new Error(`atomic-workflows: stage ${stageId} completed with pending custom UI`));
|
|
245
|
-
input.opts.onStageEnd?.(input.runId, stageSnapshot);
|
|
246
|
+
await input.opts.onStageEnd?.(input.runId, stageSnapshot);
|
|
246
247
|
if (input.opts.persistence) {
|
|
247
248
|
appendStageStartOnce();
|
|
248
249
|
appendStageEnd(input.opts.persistence, {
|
|
@@ -325,12 +326,12 @@ export function createWorkflowStageFactory(input: {
|
|
|
325
326
|
// workflow-exit cleanup and removes the stage from the fail-fast active set.
|
|
326
327
|
// Later paths must not overwrite the terminal skippedReason; they only abort
|
|
327
328
|
// and release idempotent live handles.
|
|
328
|
-
const skipForParallelFailFast = (): void => {
|
|
329
|
+
const skipForParallelFailFast = async (): Promise<void> => {
|
|
329
330
|
if (isTerminalStage(stageSnapshot)) return;
|
|
330
331
|
markSkippedForParallelFailFast();
|
|
331
|
-
finalizeStageSnapshot();
|
|
332
|
-
|
|
333
|
-
|
|
332
|
+
await finalizeStageSnapshot();
|
|
333
|
+
await innerCtx.abort().catch(() => {});
|
|
334
|
+
await dropStageControlForCompletion().catch(() => {});
|
|
334
335
|
};
|
|
335
336
|
stageFailFastScope?.activeStages.set(stageId, { skip: skipForParallelFailFast });
|
|
336
337
|
runtime.unregisterWorkflowExitCleanup = input.exit.registerWorkflowExitCleanup(stageId, {
|
|
@@ -339,7 +340,7 @@ export function createWorkflowStageFactory(input: {
|
|
|
339
340
|
if (!isTerminalStage(stageSnapshot)) {
|
|
340
341
|
stageSnapshot.status = "skipped";
|
|
341
342
|
stageSnapshot.skippedReason = input.exit.workflowExitSkippedReason(reason);
|
|
342
|
-
finalizeStageSnapshot();
|
|
343
|
+
await finalizeStageSnapshot();
|
|
343
344
|
}
|
|
344
345
|
await innerCtx.abort().catch(() => {});
|
|
345
346
|
await releaseLiveHandle().catch(() => {});
|
|
@@ -95,6 +95,7 @@ export function createReplayStageContext(input: {
|
|
|
95
95
|
name,
|
|
96
96
|
prompt: replayText,
|
|
97
97
|
complete: replayText,
|
|
98
|
+
sendUserMessage: async () => rejectReplayMutation("send a user message"),
|
|
98
99
|
steer: async () => rejectReplayMutation("steer"),
|
|
99
100
|
followUp: async () => rejectReplayMutation("follow up"),
|
|
100
101
|
subscribe: () => () => {},
|
|
@@ -48,7 +48,7 @@ export interface LiveStageRuntime {
|
|
|
48
48
|
readonly captureStageSessionMeta: () => void;
|
|
49
49
|
readonly applyModelFallbackMeta: (meta: ReturnType<InternalStageContext["__modelFallbackMeta"]>) => void;
|
|
50
50
|
readonly appendStageStartOnce: () => void;
|
|
51
|
-
readonly finalizeStageSnapshot: () => boolean
|
|
51
|
+
readonly finalizeStageSnapshot: () => Promise<boolean>;
|
|
52
52
|
readonly releaseLiveHandle: () => Promise<void>;
|
|
53
53
|
readonly dropStageControlForCompletion: () => Promise<void>;
|
|
54
54
|
readonly markSkippedForParallelFailFast: () => void;
|
|
@@ -70,6 +70,22 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
|
|
|
70
70
|
runId?: string;
|
|
71
71
|
/** Replay completed stages from a failed source run, then resume at this stage. */
|
|
72
72
|
continuation?: RunContinuationOpts;
|
|
73
|
+
/**
|
|
74
|
+
* Durable workflow backend override (for testing). Defaults to the global
|
|
75
|
+
* backend resolved by `getDurableBackend()`.
|
|
76
|
+
*
|
|
77
|
+
* cross-ref: issue #1498 — DBOS-backed cross-session resumability.
|
|
78
|
+
*/
|
|
79
|
+
durableBackend?: import("../../durable/backend.js").DurableWorkflowBackend;
|
|
80
|
+
/**
|
|
81
|
+
* Durable scope for a child workflow run. When set, the child's internal
|
|
82
|
+
* `ctx.tool`/`ctx.ui`/`ctx.stage` checkpoints are routed under the root
|
|
83
|
+
* workflow id with a stable boundary prefix so an interrupted child does
|
|
84
|
+
* not re-execute completed side effects on parent resume.
|
|
85
|
+
*
|
|
86
|
+
* cross-ref: issue #1498.
|
|
87
|
+
*/
|
|
88
|
+
durableScope?: import("../../durable/scoped-backend.js").DurableScope;
|
|
73
89
|
/** Internal parent linkage for nested ctx.workflow(...) runs. */
|
|
74
90
|
parentRun?: {
|
|
75
91
|
readonly runId: string;
|
|
@@ -78,7 +94,8 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
|
|
|
78
94
|
};
|
|
79
95
|
onRunStart?: (snapshot: RunSnapshot) => void;
|
|
80
96
|
onStageStart?: (runId: string, snapshot: StageSnapshot) => void;
|
|
81
|
-
onStageEnd?: (runId: string, snapshot: StageSnapshot) =>
|
|
97
|
+
onStageEnd?: (runId: string, snapshot: StageSnapshot) => unknown;
|
|
98
|
+
onStageSession?: (runId: string, snapshot: StageSnapshot) => unknown;
|
|
82
99
|
onRunEnd?: (runId: string, status: RunStatus, result?: WorkflowOutputValues, error?: string, exitReason?: string) => void;
|
|
83
100
|
}
|
|
84
101
|
|
|
@@ -94,7 +111,7 @@ export interface RunResult<TOutputs extends WorkflowOutputValues = WorkflowOutpu
|
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
export interface ParallelFailFastStage {
|
|
97
|
-
readonly skip: () => void
|
|
114
|
+
readonly skip: () => Promise<void>;
|
|
98
115
|
}
|
|
99
116
|
|
|
100
117
|
export interface ParallelFailFastScope {
|
|
@@ -92,6 +92,10 @@ export function createStageContext(opts: StageRunnerOpts): InternalStageContext
|
|
|
92
92
|
return lastAssistantText;
|
|
93
93
|
},
|
|
94
94
|
|
|
95
|
+
async sendUserMessage(text, options) {
|
|
96
|
+
await controller.sendUserMessage(text, options);
|
|
97
|
+
},
|
|
98
|
+
|
|
95
99
|
async steer(text) {
|
|
96
100
|
await (await controller.ensureSession()).steer(text);
|
|
97
101
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getModelDefaultContextWindow, getSupportedContextWindows, SessionManager, shouldApplyCodexFastModeForScope, type AgentSession, type CreateAgentSessionOptions, type PromptOptions, type StructuredOutputCapture } from "@bastani/atomic";
|
|
2
|
-
import type { StageContext, StageExecutionMeta, StageOptions, WorkflowModelAttempt, WorkflowModelCatalogPort } from "../../shared/types.js";
|
|
2
|
+
import type { StageContext, StageExecutionMeta, StageOptions, StageSendUserMessageOptions, StageUserMessageContent, WorkflowModelAttempt, WorkflowModelCatalogPort } from "../../shared/types.js";
|
|
3
3
|
import { buildModelCandidatesFromCatalog, errorMessage, isRetryableModelFailure, workflowModelId, type WorkflowResolvedModelCandidate } from "../shared/model-fallback.js";
|
|
4
4
|
import { WorkflowPromptModelFailure, lastAssistantTextFromSession, latestTerminalAssistantFailureSince } from "./stage-runner-messages.js";
|
|
5
5
|
import { missingAdapter, stripWorkflowOnlyOptions, unavailableSync } from "./stage-runner-options.js";
|
|
6
6
|
import { asAgentSession, disposeStageSession, normalizeSessionCreateResult } from "./stage-runner-session.js";
|
|
7
7
|
import { structuredOutputToolErrorFromEvent } from "./stage-runner-structured-output.js";
|
|
8
|
+
import { sendStageUserMessage } from "./stage-runner-send-user-message.js";
|
|
8
9
|
import type { AgentSessionConsumer, StageModelFallbackMeta, StageRunnerOpts, StageSessionCreateOptions, StageSessionCreateResult, StageSessionEvent, StageSessionRuntime, WorkflowFastModeSettingsManager } from "./stage-runner-types.js";
|
|
9
10
|
|
|
10
11
|
type PauseRequest = {
|
|
@@ -60,7 +61,6 @@ export class StageSessionController {
|
|
|
60
61
|
get latestStructuredOutputToolError(): string | undefined { return this.latestStructuredOutputToolErrorValue; }
|
|
61
62
|
|
|
62
63
|
resetStructuredOutputToolError(): void { this.latestStructuredOutputToolErrorValue = undefined; }
|
|
63
|
-
|
|
64
64
|
requireSession(property: string): StageSessionRuntime {
|
|
65
65
|
if (!this.session) unavailableSync(property);
|
|
66
66
|
return this.session;
|
|
@@ -98,6 +98,10 @@ export class StageSessionController {
|
|
|
98
98
|
return this.ensureSession(consumer);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
async sendUserMessage(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void> {
|
|
102
|
+
await sendStageUserMessage(await this.ensureSession("prompt"), content, options);
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
async promptWithFallback(
|
|
102
106
|
text: string,
|
|
103
107
|
sdkOptions: PromptOptions | undefined,
|
|
@@ -242,14 +246,10 @@ export class StageSessionController {
|
|
|
242
246
|
fallbackThinkingLevels: undefined,
|
|
243
247
|
};
|
|
244
248
|
if (resumeOptions?.restoreSavedModel) delete optionsForCandidate.model;
|
|
245
|
-
// Pin a tiered model's
|
|
246
|
-
// the
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
// selected long tier) from leaking into workflow stages, so a tiered model
|
|
250
|
-
// uses its short tier unless the author explicitly opts into the long tier
|
|
251
|
-
// via the `(1m)` token or the numeric contextWindow option. Single-window
|
|
252
|
-
// models carry no selectable long tier, so they are left untouched.
|
|
249
|
+
// Pin a tiered model's short default context window for fresh, non-resumed
|
|
250
|
+
// stage sessions unless the author selected a long tier via `(1m)` or
|
|
251
|
+
// contextWindow. This prevents persisted interactive long-tier preferences
|
|
252
|
+
// from leaking into workflow stages; single-window models are left alone.
|
|
253
253
|
if (
|
|
254
254
|
resumeOptions?.restoreSavedModel !== true &&
|
|
255
255
|
this.reattachSessionFile === undefined &&
|
|
@@ -18,6 +18,8 @@ export function stripWorkflowOnlyOptions(
|
|
|
18
18
|
fallbackThinkingLevels: _fallbackThinkingLevels,
|
|
19
19
|
context,
|
|
20
20
|
forkFromSessionFile,
|
|
21
|
+
resumeFromSessionFile,
|
|
22
|
+
durableReplayKey: _durableReplayKey,
|
|
21
23
|
sessionDir,
|
|
22
24
|
gitWorktreeDir: _gitWorktreeDir,
|
|
23
25
|
baseBranch: _baseBranch,
|
|
@@ -26,7 +28,9 @@ export function stripWorkflowOnlyOptions(
|
|
|
26
28
|
if (sessionOptions.sessionManager === undefined) {
|
|
27
29
|
const cwd = sessionOptions.cwd ?? process.cwd();
|
|
28
30
|
const effectiveSessionDir = sessionDir ?? defaultSessionDir;
|
|
29
|
-
if (
|
|
31
|
+
if (resumeFromSessionFile !== undefined) {
|
|
32
|
+
sessionOptions.sessionManager = SessionManager.open(resumeFromSessionFile, effectiveSessionDir, cwd);
|
|
33
|
+
} else if (context === "fork" && forkFromSessionFile !== undefined) {
|
|
30
34
|
sessionOptions.sessionManager = SessionManager.forkFrom(forkFromSessionFile, cwd, effectiveSessionDir);
|
|
31
35
|
} else if (effectiveSessionDir !== undefined) {
|
|
32
36
|
sessionOptions.sessionManager = SessionManager.create(cwd, effectiveSessionDir);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StageSendUserMessageOptions, StageUserMessageContent } from "../../shared/types.js";
|
|
2
|
+
import type { StageSessionRuntime } from "./stage-runner-types.js";
|
|
3
|
+
|
|
4
|
+
function unsupportedContentError(): Error {
|
|
5
|
+
return new Error("atomic-workflows: this stage session adapter does not support non-string sendUserMessage content; provide a runtime sendUserMessage implementation for text/image blocks.");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function sendStageUserMessage(
|
|
9
|
+
activeSession: StageSessionRuntime,
|
|
10
|
+
content: StageUserMessageContent,
|
|
11
|
+
options?: StageSendUserMessageOptions,
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
const deliverAs = activeSession.isStreaming ? options?.deliverAs ?? "followUp" : options?.deliverAs;
|
|
14
|
+
if (activeSession.sendUserMessage !== undefined) {
|
|
15
|
+
await activeSession.sendUserMessage(content, deliverAs === undefined ? undefined : { deliverAs });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (typeof content !== "string") throw unsupportedContentError();
|
|
19
|
+
if (activeSession.isStreaming) {
|
|
20
|
+
if (deliverAs === "steer") await activeSession.steer(content);
|
|
21
|
+
else await activeSession.followUp(content);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await activeSession.prompt(content);
|
|
25
|
+
}
|
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
import type {
|
|
7
7
|
CompleteStageOpts,
|
|
8
8
|
StageContext,
|
|
9
|
+
StageSendUserMessageOptions,
|
|
10
|
+
StageUserMessageContent,
|
|
9
11
|
StageExecutionMeta,
|
|
10
12
|
StageOptions,
|
|
11
13
|
WorkflowExecutionMode,
|
|
@@ -26,6 +28,7 @@ export type WorkflowFastModeSettingsManager = {
|
|
|
26
28
|
|
|
27
29
|
export interface StageSessionRuntime {
|
|
28
30
|
prompt(text: string, options?: PromptOptions): Promise<string | void>;
|
|
31
|
+
sendUserMessage?(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
|
|
29
32
|
steer(text: string): Promise<void>;
|
|
30
33
|
followUp(text: string): Promise<void>;
|
|
31
34
|
subscribe(listener: (event: StageSessionEvent) => void): () => void;
|
|
@@ -40,6 +40,16 @@ export interface WorkflowModelFallbackFields {
|
|
|
40
40
|
readonly fallbackThinkingLevels?: readonly string[];
|
|
41
41
|
}
|
|
42
42
|
export type WorkflowModelValue = string | object;
|
|
43
|
+
export interface StageTextContent {
|
|
44
|
+
readonly type: "text";
|
|
45
|
+
readonly text: string;
|
|
46
|
+
}
|
|
47
|
+
export interface StageImageContent {
|
|
48
|
+
readonly type: "image";
|
|
49
|
+
readonly data: string;
|
|
50
|
+
readonly mimeType: string;
|
|
51
|
+
}
|
|
52
|
+
export type StageUserMessageContent = string | readonly (StageTextContent | StageImageContent)[];
|
|
43
53
|
export type WorkflowStageResult<TSchemaDef extends TSchema | undefined = undefined> = [TSchemaDef] extends [TSchema] ? Static<TSchemaDef> : string;
|
|
44
54
|
export interface WorkflowModelUsage extends WorkflowSerializableObject {
|
|
45
55
|
readonly input?: number;
|
|
@@ -178,6 +188,7 @@ export interface WorkflowPersistencePort {
|
|
|
178
188
|
}
|
|
179
189
|
export interface StageSessionRuntime {
|
|
180
190
|
prompt(text: string, options?: PromptOptions): Promise<string | void>;
|
|
191
|
+
sendUserMessage?(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
|
|
181
192
|
steer(text: string): Promise<void>;
|
|
182
193
|
followUp(text: string): Promise<void>;
|
|
183
194
|
subscribe(listener: (event: never) => void): () => void;
|
|
@@ -236,10 +247,15 @@ export interface StageAdapters {
|
|
|
236
247
|
readonly prompt?: PromptAdapter;
|
|
237
248
|
readonly complete?: CompleteAdapter;
|
|
238
249
|
}
|
|
250
|
+
export type StageUserMessageDelivery = "steer" | "followUp";
|
|
251
|
+
export interface StageSendUserMessageOptions {
|
|
252
|
+
readonly deliverAs?: StageUserMessageDelivery;
|
|
253
|
+
}
|
|
239
254
|
export interface StageContext<TSchemaDef extends TSchema | undefined = undefined> {
|
|
240
255
|
readonly name: string;
|
|
241
256
|
prompt(text: string, options?: StagePromptOptions): Promise<WorkflowStageResult<TSchemaDef>>;
|
|
242
257
|
complete(text: string, options?: CompleteStageOpts): Promise<string>;
|
|
258
|
+
sendUserMessage(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
|
|
243
259
|
steer(text: string): Promise<void>;
|
|
244
260
|
followUp(text: string): Promise<void>;
|
|
245
261
|
subscribe(listener: (event: never) => void): () => void;
|