@bastani/atomic 0.9.9 → 0.9.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +2 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/README.md +12 -4
- package/dist/builtin/intercom/broker/broker.ts +96 -14
- package/dist/builtin/intercom/broker/client-message-validation.ts +39 -0
- package/dist/builtin/intercom/broker/client.ts +101 -92
- package/dist/builtin/intercom/broker/group-isolation.ts +28 -0
- package/dist/builtin/intercom/broker/send-handler.ts +62 -10
- package/dist/builtin/intercom/broker/send-signature.ts +3 -0
- package/dist/builtin/intercom/broker/supervisor-channel.ts +126 -0
- package/dist/builtin/intercom/closed-workflow-stage-message.ts +66 -0
- package/dist/builtin/intercom/config.ts +10 -0
- package/dist/builtin/intercom/contact-supervisor-tool.ts +14 -10
- package/dist/builtin/intercom/foreground-detach-handoff.ts +12 -2
- package/dist/builtin/intercom/group.ts +46 -0
- package/dist/builtin/intercom/inbound-message-admission.ts +79 -0
- package/dist/builtin/intercom/incoming-message-delivery.ts +49 -0
- package/dist/builtin/intercom/index-heavy.ts +148 -94
- package/dist/builtin/intercom/index.ts +66 -4
- package/dist/builtin/intercom/intercom-test-seams.ts +6 -0
- package/dist/builtin/intercom/intercom-tool.ts +71 -20
- package/dist/builtin/intercom/intercom-utils.ts +15 -2
- package/dist/builtin/intercom/late-stage-message-router.ts +148 -0
- package/dist/builtin/intercom/lifecycle.ts +10 -4
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/reconnect-backoff.ts +6 -0
- package/dist/builtin/intercom/reply-tracker.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +2 -0
- package/dist/builtin/intercom/stable-delivery-retry.ts +32 -0
- package/dist/builtin/intercom/subagent-relay.ts +67 -14
- package/dist/builtin/intercom/supervisor-authorization-registry.ts +22 -0
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +144 -25
- package/dist/builtin/intercom/types.ts +18 -5
- package/dist/builtin/intercom/workflow-reply-tracker.ts +19 -0
- package/dist/builtin/intercom/workflow-stage-admission.ts +43 -0
- package/dist/builtin/intercom/workflow-stage-delivery-failure.ts +77 -0
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/README.md +6 -2
- package/dist/builtin/mcp/config.ts +8 -8
- package/dist/builtin/mcp/direct-tool-executor.ts +7 -6
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-call.ts +5 -4
- package/dist/builtin/mcp/sampling-handler.ts +7 -2
- package/dist/builtin/mcp/tool-call-timeout.ts +101 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -2
- package/dist/builtin/mcp/types.ts +5 -0
- package/dist/builtin/mcp/ui-server.ts +3 -2
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/README.md +6 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +37 -61
- package/dist/builtin/subagents/src/extension/notification-content.ts +80 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +9 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +1 -0
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +23 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +75 -13
- package/dist/builtin/subagents/src/runs/background/async-status.ts +19 -0
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +76 -15
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +2 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +13 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +19 -2
- package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +26 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +19 -30
- package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +47 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +60 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +21 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +21 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +6 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +50 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +16 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +75 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +51 -0
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +69 -77
- package/dist/builtin/subagents/src/shared/types-config.ts +6 -0
- package/dist/builtin/subagents/src/slash/slash-commands.ts +3 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-result.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +7 -4
- package/dist/builtin/web-access/CHANGELOG.md +11 -0
- package/dist/builtin/web-access/extract-frames.ts +14 -13
- package/dist/builtin/web-access/extract.ts +2 -2
- package/dist/builtin/web-access/gemini-api.ts +0 -3
- package/dist/builtin/web-access/gemini-web-config.ts +1 -3
- package/dist/builtin/web-access/gemini-web.ts +1 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/perplexity.ts +0 -3
- package/dist/builtin/web-access/result-renderers.ts +7 -5
- package/dist/builtin/web-access/subprocess.ts +100 -0
- package/dist/builtin/web-access/summary-review.ts +14 -3
- package/dist/builtin/web-access/video-extract.ts +12 -17
- package/dist/builtin/web-access/web-search-browser.ts +18 -10
- package/dist/builtin/web-access/web-search-summary.ts +9 -2
- package/dist/builtin/web-access/youtube-extract.ts +22 -25
- package/dist/builtin/workflows/CHANGELOG.md +77 -0
- package/dist/builtin/workflows/README.md +76 -38
- package/dist/builtin/workflows/ambient.d.ts +30 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +93 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.d.ts +11 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.d.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act.ts +35 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +8 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +96 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.d.ts +23 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +32 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +75 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.d.ts +11 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +26 -0
- package/dist/builtin/workflows/builtin/goal-models.ts +72 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +2 -64
- package/dist/builtin/workflows/builtin/index.d.ts +44 -0
- package/dist/builtin/workflows/builtin/index.ts +6 -0
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +189 -0
- package/dist/builtin/workflows/builtin/loop-until-done.d.ts +34 -0
- package/dist/builtin/workflows/builtin/loop-until-done.ts +31 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +6 -1
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +28 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +26 -5
- package/dist/builtin/workflows/builtin/ralph-runner.ts +1 -0
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/tournament-runner.ts +188 -0
- package/dist/builtin/workflows/builtin/tournament.d.ts +33 -0
- package/dist/builtin/workflows/builtin/tournament.ts +34 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +2 -6
- package/dist/builtin/workflows/src/durable/backend.ts +163 -120
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +37 -64
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +4 -72
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +242 -195
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +207 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +42 -42
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +155 -0
- package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +126 -0
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +105 -58
- package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +320 -0
- package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +161 -0
- package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +62 -0
- package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +2 -2
- package/dist/builtin/workflows/src/durable/durable-hash.ts +20 -0
- package/dist/builtin/workflows/src/durable/factory.ts +23 -83
- package/dist/builtin/workflows/src/durable/format-version.ts +4 -10
- package/dist/builtin/workflows/src/durable/index.ts +16 -20
- package/dist/builtin/workflows/src/durable/local-command.ts +63 -0
- package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +177 -0
- package/dist/builtin/workflows/src/durable/prompt-reservations.ts +36 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +2 -200
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +42 -2
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +121 -118
- package/dist/builtin/workflows/src/durable/retention-policy.ts +42 -0
- package/dist/builtin/workflows/src/durable/run-timing.ts +98 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +62 -14
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +15 -2
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +11 -7
- package/dist/builtin/workflows/src/durable/types.ts +25 -18
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +117 -29
- package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +30 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +20 -5
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -2
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +6 -3
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +14 -22
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +14 -14
- package/dist/builtin/workflows/src/engine/run.ts +35 -37
- package/dist/builtin/workflows/src/engine/runtime.ts +3 -0
- package/dist/builtin/workflows/src/engine/workflow-activity.ts +9 -0
- package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +155 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +13 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +20 -0
- package/dist/builtin/workflows/src/extension/dispatcher.ts +56 -17
- package/dist/builtin/workflows/src/extension/extension-factory.ts +13 -10
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +37 -59
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +16 -18
- package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +83 -0
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +80 -41
- package/dist/builtin/workflows/src/extension/postmortem-deps.ts +73 -0
- package/dist/builtin/workflows/src/extension/public-types.ts +11 -51
- package/dist/builtin/workflows/src/extension/render-call.ts +3 -9
- package/dist/builtin/workflows/src/extension/render-result.ts +22 -7
- package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +78 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +50 -29
- package/dist/builtin/workflows/src/extension/runtime.ts +70 -219
- package/dist/builtin/workflows/src/extension/ui-surface.ts +107 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +76 -7
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +10 -5
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +27 -5
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +49 -19
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +8 -8
- package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +55 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +193 -145
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +9 -133
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +189 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +78 -3
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +185 -89
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +92 -11
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +18 -24
- package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +63 -0
- package/dist/builtin/workflows/src/runs/background/quit.ts +139 -29
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +97 -0
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +111 -0
- package/dist/builtin/workflows/src/runs/background/runner.ts +46 -17
- package/dist/builtin/workflows/src/runs/background/startup-admission.ts +77 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +133 -224
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +44 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +57 -256
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +7 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +12 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +39 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +75 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +44 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +63 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +30 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +3 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +0 -67
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +0 -1
- package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +169 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +38 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +21 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +21 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +85 -84
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +12 -5
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +42 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +100 -8
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +51 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +19 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +28 -2
- package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +4 -6
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +89 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +29 -133
- package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +130 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-root.ts +84 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +77 -63
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +4 -0
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +29 -22
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +26 -24
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/intercom-group.ts +51 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +6 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +4 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +3 -0
- package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +13 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +2 -1
- package/dist/builtin/workflows/src/shared/session-transcript.ts +74 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +1 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/timing.ts +4 -1
- package/dist/builtin/workflows/src/shared/types.ts +2 -6
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +2 -42
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +2 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +7 -3
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +29 -67
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +15 -10
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +0 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -9
- package/dist/builtin/workflows/src/tui/host-input-form.ts +62 -0
- package/dist/builtin/workflows/src/tui/mouse-input.ts +63 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -0
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +67 -42
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +49 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +3 -104
- package/dist/builtin/workflows/src/tui/session-picker.ts +3 -12
- package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +19 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +30 -10
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +19 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +25 -38
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +1 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +7 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +7 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +19 -20
- package/dist/builtin/workflows/src/tui/switcher.ts +4 -4
- package/dist/builtin/workflows/src/tui/widget.ts +46 -33
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +26 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +14 -2
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +26 -27
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +208 -69
- package/dist/bun/cli.js +3 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +3 -0
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +19 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -3
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -4
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +9 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +6 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +107 -36
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +18 -7
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +3 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts +16 -0
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-post-tool-compaction.js +113 -0
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +12 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +22 -5
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +21 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +7 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +18 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async/job-manager.d.ts +1 -0
- package/dist/core/async/job-manager.d.ts.map +1 -1
- package/dist/core/async/job-manager.js +29 -5
- package/dist/core/async/job-manager.js.map +1 -1
- package/dist/core/async/session-manager.d.ts +2 -4
- package/dist/core/async/session-manager.d.ts.map +1 -1
- package/dist/core/async/session-manager.js +5 -32
- package/dist/core/async/session-manager.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -0
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -10
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +151 -92
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/callback-activity.d.ts +27 -0
- package/dist/core/callback-activity.d.ts.map +1 -0
- package/dist/core/callback-activity.js +44 -0
- package/dist/core/callback-activity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +4 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +10 -23
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +4 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +1 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +3 -2
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +6 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +12 -9
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +101 -0
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -0
- package/dist/core/compaction/range-planner-diagnostics.js +116 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -0
- package/dist/core/compaction/range-planner.d.ts +13 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +117 -68
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/truncated-range-recovery.d.ts +47 -0
- package/dist/core/compaction/truncated-range-recovery.d.ts.map +1 -0
- package/dist/core/compaction/truncated-range-recovery.js +112 -0
- package/dist/core/compaction/truncated-range-recovery.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +2 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +23 -1
- 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 +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.js +2 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +8 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +9 -6
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +17 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +3 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +11 -10
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +78 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts +2 -1
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-auth.js +25 -6
- package/dist/core/model-registry-auth.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts +3 -2
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +12 -6
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts +1 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +53 -13
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts +2 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +2 -2
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +10 -3
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +15 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +214 -30
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/models-store.d.ts +25 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +73 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/oauth-compat.d.ts +17 -0
- package/dist/core/oauth-compat.d.ts.map +1 -0
- package/dist/core/oauth-compat.js +2 -0
- package/dist/core/oauth-compat.js.map +1 -0
- package/dist/core/oauth-provider-bridge.d.ts +40 -0
- package/dist/core/oauth-provider-bridge.d.ts.map +1 -0
- package/dist/core/oauth-provider-bridge.js +169 -0
- package/dist/core/oauth-provider-bridge.js.map +1 -0
- package/dist/core/output-guard.d.ts +2 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +14 -0
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +138 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.js +2 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +65 -23
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +9 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.js +2 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.js +2 -2
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts.map +1 -1
- package/dist/core/tools/todos-render.js +3 -2
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.js +2 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +29 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -0
- package/dist/core/workflow-stage-admission.js +81 -0
- package/dist/core/workflow-stage-admission.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main-types.d.ts +13 -0
- package/dist/main-types.d.ts.map +1 -0
- package/dist/main-types.js +2 -0
- package/dist/main-types.js.map +1 -0
- package/dist/main.d.ts +2 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +7 -0
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +20 -0
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +5 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -4
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +79 -8
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +4 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +4 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +14 -0
- package/dist/modes/interactive/components/host-input-form-mount.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form-mount.js +79 -0
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -0
- package/dist/modes/interactive/components/host-input-form.d.ts +52 -0
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form.js +278 -0
- package/dist/modes/interactive/components/host-input-form.js.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts +46 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.js +183 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +8 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +7 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +57 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +15 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +35 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +24 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +7 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +3 -3
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +49 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-global-clear.d.ts +13 -0
- package/dist/modes/interactive/interactive-global-clear.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-global-clear.js +11 -0
- package/dist/modes/interactive/interactive-global-clear.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +17 -10
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +25 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +4 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +14 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +7 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +2 -2
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +25 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +3 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +5 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +22 -9
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-terminal-title.d.ts +6 -0
- package/dist/modes/interactive/interactive-terminal-title.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-terminal-title.js +7 -0
- package/dist/modes/interactive/interactive-terminal-title.js.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +45 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.js +74 -0
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +14 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js +56 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/engine-args.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-args.js +55 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js +50 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +47 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js +276 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts +13 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.js +49 -0
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts +18 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.js +63 -0
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +17 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.js +150 -0
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +22 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.js +106 -0
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +23 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js +126 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts +15 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.js +44 -0
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +75 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.js +448 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts +184 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -0
- package/dist/modes/interactive-engine/protocol.js +254 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +33 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js +51 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -0
- package/dist/modes/interactive-engine/remote-component.d.ts +16 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-component.js +209 -0
- package/dist/modes/interactive-engine/remote-component.js.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts +25 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js +43 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts +59 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.js +123 -0
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts +25 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.js +75 -0
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +43 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js +109 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -0
- package/dist/modes/rpc/bounded-writer.d.ts +27 -0
- package/dist/modes/rpc/bounded-writer.d.ts.map +1 -0
- package/dist/modes/rpc/bounded-writer.js +103 -0
- package/dist/modes/rpc/bounded-writer.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +15 -12
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +102 -28
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +83 -0
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-api.js +64 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts +19 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-process.js +79 -0
- package/dist/modes/rpc/rpc-client-process.js.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts +8 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.js +33 -0
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +48 -124
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +295 -249
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +5 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +79 -3
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +11 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-event-buffer.js +30 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +7 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +54 -32
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts +16 -0
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js +69 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +2 -1
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +4 -9
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +27 -0
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js +69 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +63 -8
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +10 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-output-buffer.js +70 -0
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +16 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +16 -3
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +109 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.d.ts +2 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -1
- package/dist/package-manager-cli-parser.js +24 -5
- package/dist/package-manager-cli-parser.js.map +1 -1
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +65 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +46 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/changelog.mdx +11 -0
- package/docs/compaction.md +53 -17
- package/docs/custom-provider.md +24 -5
- package/docs/development.md +9 -7
- package/docs/docs.json +1 -0
- package/docs/extensions.md +30 -16
- package/docs/intercom.md +489 -0
- package/docs/json.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +1 -0
- package/docs/quickstart.md +11 -5
- package/docs/rpc.md +9 -7
- package/docs/sdk.md +6 -0
- package/docs/session-format.md +7 -6
- package/docs/sessions.md +4 -2
- package/docs/settings.md +2 -2
- package/docs/subagents.md +7 -2
- package/docs/tui.md +61 -2
- package/docs/usage.md +6 -5
- package/docs/workflows.md +2572 -1379
- package/examples/extensions/handoff.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/summarize.ts +1 -1
- package/npm-shrinkwrap.json +225 -76
- package/package.json +7 -6
- package/dist/builtin/workflows/src/durable/file-backend.ts +0 -439
- package/dist/builtin/workflows/src/durable/file-lock.ts +0 -153
- package/dist/builtin/workflows/src/durable/file-state.ts +0 -104
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +0 -96
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +0 -66
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +0 -91
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +0 -282
- package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +0 -43
- package/dist/builtin/workflows/src/tui/session-confirm.ts +0 -299
|
@@ -66,13 +66,22 @@ export function createTrackedStageCaller(input: {
|
|
|
66
66
|
return false;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const drainResumeContinuations = async <T>(currentResult: T): Promise<
|
|
69
|
+
const drainResumeContinuations = async <T>(currentResult: T): Promise<{
|
|
70
|
+
readonly result: T;
|
|
71
|
+
readonly chatAnswerObserved: boolean;
|
|
72
|
+
}> => {
|
|
70
73
|
let result = currentResult;
|
|
71
|
-
|
|
74
|
+
let chatAnswerObserved = runtime.state.chatAnswerObservedThisTurn;
|
|
75
|
+
const captureChatAnswer = (): void => {
|
|
76
|
+
chatAnswerObserved ||= runtime.state.chatAnswerObservedThisTurn;
|
|
77
|
+
};
|
|
78
|
+
while (runtime.state.resumeContinuationPending !== false) {
|
|
79
|
+
const reason = runtime.state.resumeContinuationPending;
|
|
72
80
|
runtime.state.resumeContinuationPending = false;
|
|
81
|
+
captureChatAnswer();
|
|
73
82
|
suppressReadinessForCurrentTurn();
|
|
74
83
|
if (!shouldInjectResumeContinuation({
|
|
75
|
-
|
|
84
|
+
reason,
|
|
76
85
|
gateEnabled: readinessGateEnabled,
|
|
77
86
|
aborted: runtime.signal.aborted,
|
|
78
87
|
})) {
|
|
@@ -80,8 +89,10 @@ export function createTrackedStageCaller(input: {
|
|
|
80
89
|
}
|
|
81
90
|
if (skipResumeContinuationInjection()) continue;
|
|
82
91
|
result = await raceAbort(runtime.innerCtx.prompt(RESUME_CONTINUATION_PROMPT), runtime.signal) as T;
|
|
92
|
+
captureChatAnswer();
|
|
83
93
|
}
|
|
84
|
-
|
|
94
|
+
captureChatAnswer();
|
|
95
|
+
return { result, chatAnswerObserved };
|
|
85
96
|
};
|
|
86
97
|
|
|
87
98
|
return async <T>(call: () => Promise<T>, eagerSessionOrOptions?: boolean | TrackedStageCallOptions): Promise<T> => {
|
|
@@ -148,9 +159,16 @@ export function createTrackedStageCaller(input: {
|
|
|
148
159
|
runtime.state.askUserQuestionObservedThisTurn = false;
|
|
149
160
|
runtime.state.chatAnswerObservedThisTurn = false;
|
|
150
161
|
result = await raceAbort(call(), runtime.signal);
|
|
151
|
-
|
|
162
|
+
const initialDrain = await drainResumeContinuations(result);
|
|
163
|
+
result = initialDrain.result;
|
|
164
|
+
let repeatReadinessAfterChatTurn = initialDrain.chatAnswerObserved;
|
|
152
165
|
|
|
153
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
!runtime.signal.aborted &&
|
|
168
|
+
readinessGateEnabled &&
|
|
169
|
+
(runtime.state.askUserQuestionObservedThisTurn || repeatReadinessAfterChatTurn) &&
|
|
170
|
+
!runtime.innerCtx.__structuredOutputFinalized()
|
|
171
|
+
) {
|
|
154
172
|
let resolveNextTurnEnd: (() => void) | null = null;
|
|
155
173
|
const unsubscribeTurnWatcher = runtime.innerCtx.subscribe((event) => {
|
|
156
174
|
if ((event as { type?: unknown }).type === "agent_end" && resolveNextTurnEnd) {
|
|
@@ -160,16 +178,24 @@ export function createTrackedStageCaller(input: {
|
|
|
160
178
|
}
|
|
161
179
|
});
|
|
162
180
|
try {
|
|
163
|
-
while (runtime.state.askUserQuestionObservedThisTurn) {
|
|
164
|
-
const decision =
|
|
181
|
+
while (runtime.state.askUserQuestionObservedThisTurn || repeatReadinessAfterChatTurn) {
|
|
182
|
+
const decision = await confirmReadiness();
|
|
165
183
|
if (decision === "advance") break;
|
|
166
184
|
if (runtime.signal.aborted) break;
|
|
167
185
|
runtime.state.askUserQuestionObservedThisTurn = false;
|
|
168
186
|
runtime.state.chatAnswerObservedThisTurn = false;
|
|
169
|
-
|
|
187
|
+
runtime.state.waitingForStageChatTurn = true;
|
|
188
|
+
try {
|
|
189
|
+
await raceAbort(new Promise<void>((resolve) => { resolveNextTurnEnd = resolve; }), runtime.signal);
|
|
190
|
+
} finally {
|
|
191
|
+
runtime.state.waitingForStageChatTurn = false;
|
|
192
|
+
}
|
|
170
193
|
if (runtime.signal.aborted) break;
|
|
171
194
|
result = (runtime.innerCtx.__getLastAssistantText() ?? result) as T;
|
|
172
|
-
|
|
195
|
+
const continuationDrain = await drainResumeContinuations(result);
|
|
196
|
+
result = continuationDrain.result;
|
|
197
|
+
repeatReadinessAfterChatTurn ||= continuationDrain.chatAnswerObserved;
|
|
198
|
+
if (runtime.innerCtx.__structuredOutputFinalized()) break;
|
|
173
199
|
}
|
|
174
200
|
} finally {
|
|
175
201
|
resolveNextTurnEnd = null;
|
|
@@ -179,6 +205,7 @@ export function createTrackedStageCaller(input: {
|
|
|
179
205
|
} finally {
|
|
180
206
|
runtime.signal.removeEventListener("abort", abortSession);
|
|
181
207
|
}
|
|
208
|
+
await runtime.innerCtx.__closeGeneration();
|
|
182
209
|
runtime.captureStageSessionMeta();
|
|
183
210
|
runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
|
|
184
211
|
if (trackStageLifecycle && runtime.stageFailFastScope?.failed === true && runtime.stageFailFastScope.activeStages.has(runtime.stageId)) {
|
|
@@ -210,13 +237,18 @@ export function createTrackedStageCaller(input: {
|
|
|
210
237
|
// so the concurrency semaphore is not leaked.
|
|
211
238
|
// cross-ref: issue #1498 — durable finalization failures must not leak the stage limiter.
|
|
212
239
|
runtime.mcpScope.clear();
|
|
213
|
-
runtime.captureStageSessionMeta();
|
|
214
240
|
let finalizationError: { readonly thrown: true; readonly error: unknown } | undefined;
|
|
241
|
+
try {
|
|
242
|
+
await runtime.innerCtx.__closeGeneration();
|
|
243
|
+
runtime.captureStageSessionMeta();
|
|
244
|
+
} catch (err) {
|
|
245
|
+
finalizationError = { thrown: true, error: err };
|
|
246
|
+
}
|
|
215
247
|
if (trackStageLifecycle) {
|
|
216
248
|
try {
|
|
217
249
|
await runtime.finalizeStageSnapshot();
|
|
218
250
|
} catch (err) {
|
|
219
|
-
finalizationError
|
|
251
|
+
finalizationError ??= { thrown: true, error: err };
|
|
220
252
|
}
|
|
221
253
|
try {
|
|
222
254
|
if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StageControlHandle, AgentSessionEventListener } from "./stage-control-registry.js";
|
|
2
2
|
import type { LiveStageRuntime } from "./executor-stage-types.js";
|
|
3
|
+
import type { StageUserMessageDeliveryAction } from "./stage-runner-types.js";
|
|
3
4
|
import { isTerminalStage } from "./executor-scheduler.js";
|
|
4
5
|
import { StageToolExecutionBuffer } from "./stage-tool-execution-buffer.js";
|
|
5
6
|
|
|
@@ -54,21 +55,52 @@ export function createStageControlHandle(runtime: LiveStageRuntime): StageContro
|
|
|
54
55
|
runtime.throwIfStageMutationBlocked();
|
|
55
56
|
runtime.captureStageSessionMeta();
|
|
56
57
|
},
|
|
57
|
-
async
|
|
58
|
+
async sendUserMessage(text, options) {
|
|
58
59
|
runtime.throwIfStageMutationBlocked();
|
|
59
60
|
await ensureMessagingSession();
|
|
61
|
+
runtime.throwIfStageMutationBlocked();
|
|
60
62
|
try {
|
|
61
|
-
await runtime.innerCtx.
|
|
63
|
+
const action = await runtime.innerCtx.__sendUserMessage(
|
|
64
|
+
text,
|
|
65
|
+
options,
|
|
66
|
+
runtime.throwIfStageMutationBlocked,
|
|
67
|
+
);
|
|
68
|
+
if (action === "steer" || action === "followUp") {
|
|
69
|
+
runtime.state.resumeContinuationPending = "queued-user-message";
|
|
70
|
+
}
|
|
71
|
+
return action;
|
|
62
72
|
} finally {
|
|
63
73
|
runtime.captureStageSessionMeta();
|
|
64
74
|
}
|
|
75
|
+
},
|
|
76
|
+
async prompt(text: string) {
|
|
65
77
|
runtime.throwIfStageMutationBlocked();
|
|
78
|
+
await ensureMessagingSession();
|
|
79
|
+
let action: StageUserMessageDeliveryAction | undefined;
|
|
80
|
+
try {
|
|
81
|
+
action = await runtime.innerCtx.__sendUserMessage(
|
|
82
|
+
text,
|
|
83
|
+
undefined,
|
|
84
|
+
runtime.throwIfStageMutationBlocked,
|
|
85
|
+
);
|
|
86
|
+
} finally {
|
|
87
|
+
runtime.captureStageSessionMeta();
|
|
88
|
+
}
|
|
89
|
+
if (action !== "handled") runtime.throwIfStageMutationBlocked();
|
|
66
90
|
},
|
|
67
91
|
async steer(text: string) {
|
|
68
92
|
runtime.throwIfStageMutationBlocked();
|
|
69
93
|
await ensureMessagingSession();
|
|
94
|
+
runtime.throwIfStageMutationBlocked();
|
|
95
|
+
// A user message queued into an in-flight turn should nudge the stage
|
|
96
|
+
// back to its objective once that turn ends: arm the pending flag so
|
|
97
|
+
// drainResumeContinuations injects RESUME_CONTINUATION_PROMPT after the
|
|
98
|
+
// tracked call resolves. Idle deliveries start a fresh user turn and
|
|
99
|
+
// need no continuation nudge, so only arm while streaming.
|
|
100
|
+
const queuedIntoInFlightTurn = runtime.innerCtx.isStreaming;
|
|
70
101
|
try {
|
|
71
102
|
await runtime.innerCtx.steer(text);
|
|
103
|
+
if (queuedIntoInFlightTurn) runtime.state.resumeContinuationPending = "queued-user-message";
|
|
72
104
|
} finally {
|
|
73
105
|
runtime.captureStageSessionMeta();
|
|
74
106
|
}
|
|
@@ -76,8 +108,12 @@ export function createStageControlHandle(runtime: LiveStageRuntime): StageContro
|
|
|
76
108
|
async followUp(text: string) {
|
|
77
109
|
runtime.throwIfStageMutationBlocked();
|
|
78
110
|
await ensureMessagingSession();
|
|
111
|
+
runtime.throwIfStageMutationBlocked();
|
|
112
|
+
// Same in-flight continuation arming as steer(): see comment above.
|
|
113
|
+
const queuedIntoInFlightTurn = runtime.innerCtx.isStreaming;
|
|
79
114
|
try {
|
|
80
115
|
await runtime.innerCtx.followUp(text);
|
|
116
|
+
if (queuedIntoInFlightTurn) runtime.state.resumeContinuationPending = "queued-user-message";
|
|
81
117
|
} finally {
|
|
82
118
|
runtime.captureStageSessionMeta();
|
|
83
119
|
}
|
|
@@ -85,38 +121,53 @@ export function createStageControlHandle(runtime: LiveStageRuntime): StageContro
|
|
|
85
121
|
async pause() {
|
|
86
122
|
runtime.throwIfStageMutationBlocked();
|
|
87
123
|
const statusBeforePause = runtime.stageSnapshot.status;
|
|
124
|
+
if (statusBeforePause === "pending" || statusBeforePause === "running" || runtime.innerCtx.isStreaming) {
|
|
125
|
+
await runtime.innerCtx.__requestPause();
|
|
126
|
+
}
|
|
88
127
|
const changed = runtime.activeStore.recordStagePaused(runtime.runId, runtime.stageId);
|
|
89
128
|
if (changed) {
|
|
90
129
|
runtime.scheduler.ensureReleaseBarrier(runtime.stageId);
|
|
91
130
|
await runtime.scheduler.cascadePauseFrom(runtime.stageId);
|
|
92
131
|
const run = runtime.activeStore.runs().find((candidate) => candidate.id === runtime.runId);
|
|
93
132
|
const stillActive = run?.stages.some(
|
|
94
|
-
(
|
|
133
|
+
(stage) => stage.status === "running" && stage.id !== runtime.stageId,
|
|
95
134
|
) ?? false;
|
|
96
135
|
if (!stillActive) runtime.activeStore.recordRunPaused(runtime.runId);
|
|
97
136
|
}
|
|
98
|
-
if (statusBeforePause === "pending" || statusBeforePause === "running" || runtime.innerCtx.isStreaming) {
|
|
99
|
-
await runtime.innerCtx.__requestPause();
|
|
100
|
-
}
|
|
101
137
|
},
|
|
102
138
|
async resume(message?: string) {
|
|
103
139
|
runtime.throwIfStageMutationBlocked();
|
|
104
140
|
await ensureMessagingSession();
|
|
141
|
+
runtime.throwIfStageMutationBlocked();
|
|
105
142
|
const wasPausedBeforeResume = runtime.innerCtx.__isPaused();
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
143
|
+
const resumesIdleStageChat = wasPausedBeforeResume && runtime.state.waitingForStageChatTurn;
|
|
144
|
+
const hasMessage = typeof message === "string" && message.trim().length > 0;
|
|
145
|
+
const resumeMessage = hasMessage ? message : undefined;
|
|
146
|
+
const queuedResumeContinuation = wasPausedBeforeResume && !resumesIdleStageChat;
|
|
147
|
+
const addedResumeContinuation = queuedResumeContinuation && runtime.state.resumeContinuationPending === false;
|
|
148
|
+
if (addedResumeContinuation) runtime.state.resumeContinuationPending = "resume";
|
|
110
149
|
try {
|
|
150
|
+
await runtime.innerCtx.__resume(resumesIdleStageChat ? undefined : resumeMessage);
|
|
111
151
|
const changed = runtime.activeStore.recordStageResumed(runtime.runId, runtime.stageId);
|
|
112
152
|
if (changed) {
|
|
113
153
|
runtime.scheduler.releaseStageBarrier(runtime.stageId);
|
|
114
154
|
await runtime.scheduler.cascadeResumeFrom(runtime.stageId);
|
|
155
|
+
// Preserve manual per-stage semantics: once this acknowledged
|
|
156
|
+
// resume succeeds, the run is active even if sibling stages remain paused.
|
|
115
157
|
runtime.activeStore.recordRunResumed(runtime.runId);
|
|
116
158
|
}
|
|
117
|
-
|
|
159
|
+
if (resumesIdleStageChat && hasMessage) {
|
|
160
|
+
runtime.throwIfStageMutationBlocked();
|
|
161
|
+
return await runtime.innerCtx.__sendUserMessage(
|
|
162
|
+
message,
|
|
163
|
+
undefined,
|
|
164
|
+
runtime.throwIfStageMutationBlocked,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
118
167
|
} catch (err) {
|
|
119
|
-
if (
|
|
168
|
+
if (addedResumeContinuation && runtime.state.resumeContinuationPending === "resume") {
|
|
169
|
+
runtime.state.resumeContinuationPending = false;
|
|
170
|
+
}
|
|
120
171
|
throw err;
|
|
121
172
|
} finally {
|
|
122
173
|
runtime.captureStageSessionMeta();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runCallback, runSynchronousCallback } from "@bastani/atomic";
|
|
1
2
|
import type { Store } from "../../shared/store.js";
|
|
2
3
|
import type { StageSnapshot } from "../../shared/store-types.js";
|
|
3
4
|
import type { StageOptions } from "../../shared/types.js";
|
|
@@ -25,6 +26,7 @@ import { createStageControlHandle } from "./executor-stage-control.js";
|
|
|
25
26
|
import { createTrackedStageCaller } from "./executor-stage-call.js";
|
|
26
27
|
import { createStageContext } from "./executor-stage-context.js";
|
|
27
28
|
import { stageOptionsWithGitWorktree, stageOptionsWithInputDefaults, type GitWorktreeSetupCache } from "./executor-direct-helpers.js";
|
|
29
|
+
import { createQueuedUserMessageConsumptionWatcher } from "./executor-queued-user-message.js";
|
|
28
30
|
|
|
29
31
|
export function createWorkflowStageFactory(input: {
|
|
30
32
|
readonly runId: string;
|
|
@@ -145,6 +147,7 @@ export function createWorkflowStageFactory(input: {
|
|
|
145
147
|
askUserQuestionObservedThisTurn: false,
|
|
146
148
|
chatAnswerObservedThisTurn: false,
|
|
147
149
|
resumeContinuationPending: false,
|
|
150
|
+
waitingForStageChatTurn: false,
|
|
148
151
|
liveHandleReleased: false,
|
|
149
152
|
stageClosedByWorkflowExit: false,
|
|
150
153
|
stageFinalized: false,
|
|
@@ -178,9 +181,15 @@ export function createWorkflowStageFactory(input: {
|
|
|
178
181
|
stageUiBroker.clearStagePrompt(input.runId, stageId);
|
|
179
182
|
}
|
|
180
183
|
});
|
|
184
|
+
const unsubscribeQueuedUserMessageWatcher = innerCtx.subscribe(
|
|
185
|
+
createQueuedUserMessageConsumptionWatcher(() => {
|
|
186
|
+
state.resumeContinuationPending = "queued-user-message";
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
181
189
|
|
|
182
190
|
const disposeInnerContext = async (): Promise<void> => {
|
|
183
191
|
unsubscribeAskUserQuestionWatcher();
|
|
192
|
+
unsubscribeQueuedUserMessageWatcher();
|
|
184
193
|
activeAskUserQuestionCalls.clear();
|
|
185
194
|
state.activeAskUserQuestionAnonymousCalls = 0;
|
|
186
195
|
input.activeStore.recordStageAwaitingInput(input.runId, stageId, false);
|
|
@@ -212,6 +221,9 @@ export function createWorkflowStageFactory(input: {
|
|
|
212
221
|
throw new Error(`atomic-workflows: stage "${name}" skipped by workflow exit`);
|
|
213
222
|
}
|
|
214
223
|
input.exit.throwIfWorkflowExitSelected();
|
|
224
|
+
if (input.signal.aborted) {
|
|
225
|
+
throw input.signal.reason ?? new DOMException("workflow killed", "AbortError");
|
|
226
|
+
}
|
|
215
227
|
};
|
|
216
228
|
|
|
217
229
|
let stageStartEntryAppended = false;
|
|
@@ -244,7 +256,12 @@ export function createWorkflowStageFactory(input: {
|
|
|
244
256
|
applyModelFallbackMeta(innerCtx.__modelFallbackMeta());
|
|
245
257
|
input.activeStore.recordStageEnd(input.runId, stageSnapshot);
|
|
246
258
|
stageUiBroker.cancelStagePrompt(input.runId, stageId, new Error(`atomic-workflows: stage ${stageId} completed with pending custom UI`));
|
|
247
|
-
|
|
259
|
+
if (input.opts.onStageEnd) {
|
|
260
|
+
await runCallback(
|
|
261
|
+
{ kind: "workflow.stage_adapter", name: `onStageEnd:${name}`, runId: input.runId, stageId },
|
|
262
|
+
() => input.opts.onStageEnd!(input.runId, stageSnapshot),
|
|
263
|
+
);
|
|
264
|
+
}
|
|
248
265
|
if (input.opts.persistence) {
|
|
249
266
|
appendStageStartOnce();
|
|
250
267
|
appendStageEnd(input.opts.persistence, {
|
|
@@ -318,7 +335,12 @@ export function createWorkflowStageFactory(input: {
|
|
|
318
335
|
runtime.unregisterStageHandle = input.stageRegistry.register(handle);
|
|
319
336
|
|
|
320
337
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
321
|
-
input.opts.onStageStart
|
|
338
|
+
if (input.opts.onStageStart) {
|
|
339
|
+
runSynchronousCallback(
|
|
340
|
+
{ kind: "workflow.stage_adapter", name: `onStageStart:${name}`, runId: input.runId, stageId },
|
|
341
|
+
() => input.opts.onStageStart!(input.runId, stageSnapshot),
|
|
342
|
+
);
|
|
343
|
+
}
|
|
322
344
|
const blockedBy = input.scheduler.blockingAncestorFor(stageSnapshot);
|
|
323
345
|
if (blockedBy !== undefined) input.scheduler.blockStageUntilCascadeRelease(stageSnapshot, blockedBy);
|
|
324
346
|
|
|
@@ -330,20 +352,24 @@ export function createWorkflowStageFactory(input: {
|
|
|
330
352
|
const skipForParallelFailFast = async (): Promise<void> => {
|
|
331
353
|
if (isTerminalStage(stageSnapshot)) return;
|
|
332
354
|
markSkippedForParallelFailFast();
|
|
333
|
-
|
|
355
|
+
innerCtx.__sealGeneration();
|
|
334
356
|
await innerCtx.abort().catch(() => {});
|
|
357
|
+
await innerCtx.__closeGeneration();
|
|
358
|
+
await finalizeStageSnapshot();
|
|
335
359
|
await dropStageControlForCompletion().catch(() => {});
|
|
336
360
|
};
|
|
337
361
|
stageFailFastScope?.activeStages.set(stageId, { skip: skipForParallelFailFast });
|
|
338
362
|
runtime.unregisterWorkflowExitCleanup = input.exit.registerWorkflowExitCleanup(stageId, {
|
|
339
363
|
async skipForWorkflowExit(reason?: string): Promise<void> {
|
|
340
364
|
state.stageClosedByWorkflowExit = true;
|
|
365
|
+
innerCtx.__sealGeneration();
|
|
366
|
+
await innerCtx.abort().catch(() => {});
|
|
367
|
+
await innerCtx.__closeGeneration();
|
|
341
368
|
if (!isTerminalStage(stageSnapshot)) {
|
|
342
369
|
stageSnapshot.status = "skipped";
|
|
343
370
|
stageSnapshot.skippedReason = input.exit.workflowExitSkippedReason(reason);
|
|
344
371
|
await finalizeStageSnapshot();
|
|
345
372
|
}
|
|
346
|
-
await innerCtx.abort().catch(() => {});
|
|
347
373
|
await releaseLiveHandle().catch(() => {});
|
|
348
374
|
},
|
|
349
375
|
});
|
|
@@ -96,6 +96,7 @@ export function createReplayStageContext(input: {
|
|
|
96
96
|
prompt: replayText,
|
|
97
97
|
complete: replayText,
|
|
98
98
|
sendUserMessage: async () => rejectReplayMutation("send a user message"),
|
|
99
|
+
__sendUserMessage: async () => rejectReplayMutation("send a user message"),
|
|
99
100
|
steer: async () => rejectReplayMutation("steer"),
|
|
100
101
|
followUp: async () => rejectReplayMutation("follow up"),
|
|
101
102
|
subscribe: () => () => {},
|
|
@@ -119,6 +120,8 @@ export function createReplayStageContext(input: {
|
|
|
119
120
|
getLastAssistantText: () => replayResult,
|
|
120
121
|
__ensureSession: async () => {},
|
|
121
122
|
__ensureSessionFromFile: async () => {},
|
|
123
|
+
__sealGeneration: () => {},
|
|
124
|
+
__closeGeneration: async () => {},
|
|
122
125
|
__sessionMeta: () => ({ sessionId: replaySource.sessionId, sessionFile: replaySource.sessionFile }),
|
|
123
126
|
__agentSession: () => undefined,
|
|
124
127
|
__pendingMessageCount: () => 0,
|
|
@@ -14,11 +14,14 @@ export interface StageMcpScope {
|
|
|
14
14
|
clear(): void;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export type ResumeContinuationReason = "resume" | "queued-user-message";
|
|
18
|
+
|
|
17
19
|
export interface LiveStageMutableState {
|
|
18
20
|
activeAskUserQuestionAnonymousCalls: number;
|
|
19
21
|
askUserQuestionObservedThisTurn: boolean;
|
|
20
22
|
chatAnswerObservedThisTurn: boolean;
|
|
21
|
-
resumeContinuationPending:
|
|
23
|
+
resumeContinuationPending: false | ResumeContinuationReason;
|
|
24
|
+
waitingForStageChatTurn: boolean;
|
|
22
25
|
liveHandleReleased: boolean;
|
|
23
26
|
stageClosedByWorkflowExit: boolean;
|
|
24
27
|
stageFinalized: boolean;
|
|
@@ -7,8 +7,6 @@ import type {
|
|
|
7
7
|
WorkflowTaskStep,
|
|
8
8
|
WorkflowChainOptions,
|
|
9
9
|
WorkflowParallelOptions,
|
|
10
|
-
WorkflowDirectOptions,
|
|
11
|
-
WorkflowDirectTaskItem,
|
|
12
10
|
WorkflowMaxOutput,
|
|
13
11
|
} from "../../shared/types.js";
|
|
14
12
|
|
|
@@ -147,9 +145,6 @@ export function parallelFallbackTask(steps: readonly WorkflowTaskStep[], options
|
|
|
147
145
|
return "";
|
|
148
146
|
}
|
|
149
147
|
|
|
150
|
-
export function directTaskPrompt(item: WorkflowDirectTaskItem): string | undefined {
|
|
151
|
-
return item.prompt ?? item.task;
|
|
152
|
-
}
|
|
153
148
|
|
|
154
149
|
export function normalizeMaxOutput(maxOutput: WorkflowMaxOutput | undefined): Required<WorkflowMaxOutput> {
|
|
155
150
|
return {
|
|
@@ -229,65 +224,3 @@ export function taskWithSharedDefaults(
|
|
|
229
224
|
...withoutUndefinedProperties(taskOptions),
|
|
230
225
|
} as WorkflowTaskExecutionOptions;
|
|
231
226
|
}
|
|
232
|
-
|
|
233
|
-
export function directTaskWithDefaults(
|
|
234
|
-
item: WorkflowDirectTaskItem,
|
|
235
|
-
options: WorkflowDirectOptions,
|
|
236
|
-
): WorkflowDirectTaskItem {
|
|
237
|
-
const {
|
|
238
|
-
task: _task,
|
|
239
|
-
chainName: _chainName,
|
|
240
|
-
concurrency: _concurrency,
|
|
241
|
-
failFast: _failFast,
|
|
242
|
-
chainDir: _chainDir,
|
|
243
|
-
reads,
|
|
244
|
-
output,
|
|
245
|
-
outputMode,
|
|
246
|
-
worktree,
|
|
247
|
-
gitWorktreeDir,
|
|
248
|
-
baseBranch,
|
|
249
|
-
maxOutput,
|
|
250
|
-
artifacts,
|
|
251
|
-
...stageDefaults
|
|
252
|
-
} = options;
|
|
253
|
-
|
|
254
|
-
const taskWithStageDefaults = {
|
|
255
|
-
...withoutUndefinedProperties(stageDefaults),
|
|
256
|
-
...withoutUndefinedProperties(item),
|
|
257
|
-
name: item.name,
|
|
258
|
-
} as WorkflowDirectTaskItem;
|
|
259
|
-
|
|
260
|
-
return {
|
|
261
|
-
...taskWithStageDefaults,
|
|
262
|
-
...(item.reads === undefined && reads !== undefined ? { reads } : {}),
|
|
263
|
-
...(item.output === undefined && output !== undefined ? { output } : {}),
|
|
264
|
-
...(item.outputMode === undefined && outputMode !== undefined ? { outputMode } : {}),
|
|
265
|
-
...(item.worktree === undefined && worktree !== undefined ? { worktree } : {}),
|
|
266
|
-
...(item.gitWorktreeDir === undefined && gitWorktreeDir !== undefined ? { gitWorktreeDir } : {}),
|
|
267
|
-
...(item.baseBranch === undefined && baseBranch !== undefined ? { baseBranch } : {}),
|
|
268
|
-
...(item.maxOutput === undefined && maxOutput !== undefined ? { maxOutput } : {}),
|
|
269
|
-
...(item.artifacts === undefined && artifacts !== undefined ? { artifacts } : {}),
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export function directTaskToStep(
|
|
274
|
-
item: WorkflowDirectTaskItem,
|
|
275
|
-
fallbackPrompt?: string,
|
|
276
|
-
previous?: WorkflowTaskOptions["previous"],
|
|
277
|
-
): WorkflowTaskStep {
|
|
278
|
-
const {
|
|
279
|
-
count: _count,
|
|
280
|
-
output: _output,
|
|
281
|
-
outputMode: _outputMode,
|
|
282
|
-
worktree: _worktree,
|
|
283
|
-
prompt,
|
|
284
|
-
task,
|
|
285
|
-
previous: itemPrevious,
|
|
286
|
-
...stageOptions
|
|
287
|
-
} = item;
|
|
288
|
-
return {
|
|
289
|
-
...stageOptions,
|
|
290
|
-
prompt: prompt ?? task ?? fallbackPrompt,
|
|
291
|
-
previous: previous ?? itemPrevious,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
@@ -57,6 +57,12 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
|
|
|
57
57
|
signal?: AbortSignal;
|
|
58
58
|
/** Yield to the next event-loop turn before invoking user workflow code. */
|
|
59
59
|
deferWorkflowStart?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Invoked once the run has persisted `run.start`, registered its durable
|
|
62
|
+
* invocation metadata, and is about to execute the workflow body. Callers
|
|
63
|
+
* can finalize a source claim only after this startup-admission signal.
|
|
64
|
+
*/
|
|
65
|
+
onWorkflowStartReady?: () => void;
|
|
60
66
|
/** Resolved runtime configuration. */
|
|
61
67
|
config?: WorkflowRuntimeConfig;
|
|
62
68
|
/** Optional model catalog used for fallback validation/resolution. */
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
export type { ResolvedInputs, RunContinuationOpts, RunOpts, RunResult } from "./executor-types.js";
|
|
10
10
|
export { run } from "./executor-run.js";
|
|
11
|
-
export { runTask, runParallel, runChain } from "./executor-direct.js";
|
|
12
11
|
export { resolveInputs, resolveAndValidateInputs } from "./executor-inputs.js";
|
|
13
12
|
export { raceAbort } from "./executor-abort.js";
|
|
14
13
|
export {
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-mortem stage-chat resolver.
|
|
3
|
+
*
|
|
4
|
+
* Generalizes the safe detached-handle pattern introduced by completed
|
|
5
|
+
* durable-workflow inspection (#1758) so any eligible terminal agent stage
|
|
6
|
+
* with a valid retained Atomic session can be reopened as an interactive
|
|
7
|
+
* post-mortem chat — from generic `/workflow attach` / `/workflow connect`,
|
|
8
|
+
* restored/replayed durable snapshots, and `workflow send` — not only the
|
|
9
|
+
* dedicated completed-inspection path.
|
|
10
|
+
*
|
|
11
|
+
* A post-mortem chat appends follow-up conversation to the stage's retained
|
|
12
|
+
* session (append-in-place, matching same-process handles and #1758). It never
|
|
13
|
+
* resumes, retries, rewinds, or otherwise mutates workflow execution: the
|
|
14
|
+
* handle is detached from run-level pause/resume control from birth and cannot
|
|
15
|
+
* pause/resume the workflow DAG. Tool side effects from follow-up turns are
|
|
16
|
+
* possible (the agent keeps its ordinary tools); only the workflow execution
|
|
17
|
+
* state is immutable.
|
|
18
|
+
*
|
|
19
|
+
* The resolver deliberately does NOT fabricate a `LiveStageRuntime`: that
|
|
20
|
+
* carries scheduler, store-mutation, exit, failure, and finalization
|
|
21
|
+
* dependencies a post-mortem conversation must never receive.
|
|
22
|
+
*
|
|
23
|
+
* cross-ref:
|
|
24
|
+
* - src/durable/completed-inspection.ts (authoritative completed catalog/open)
|
|
25
|
+
* - src/runs/foreground/stage-control-registry.ts (get-or-create ownership)
|
|
26
|
+
* - src/shared/session-transcript.ts (retained-session validation)
|
|
27
|
+
*/
|
|
28
|
+
import type { StageSnapshot } from "../../shared/store-types.js";
|
|
29
|
+
import { isReopenableSessionTranscript } from "../../shared/session-transcript.js";
|
|
30
|
+
import { createStageContext, type StageAdapters } from "./stage-runner.js";
|
|
31
|
+
import {
|
|
32
|
+
type AgentSessionEventListener,
|
|
33
|
+
type StageControlHandle,
|
|
34
|
+
type StageControlRegistry,
|
|
35
|
+
} from "./stage-control-registry.js";
|
|
36
|
+
|
|
37
|
+
/** Why a terminal stage could not be revived as an interactive post-mortem chat. */
|
|
38
|
+
export type PostMortemUnavailableReason =
|
|
39
|
+
| "no_adapter"
|
|
40
|
+
| "not_terminal"
|
|
41
|
+
| "no_session"
|
|
42
|
+
| "invalid_session";
|
|
43
|
+
|
|
44
|
+
export type EnsurePostMortemStageHandleResult =
|
|
45
|
+
| { readonly ok: true; readonly handle: StageControlHandle }
|
|
46
|
+
| { readonly ok: false; readonly reason: PostMortemUnavailableReason };
|
|
47
|
+
|
|
48
|
+
export interface PostMortemStageChatDeps {
|
|
49
|
+
readonly registry: StageControlRegistry;
|
|
50
|
+
readonly adapters?: StageAdapters;
|
|
51
|
+
/** Working directory used when reopening the retained session. */
|
|
52
|
+
readonly cwd?: string;
|
|
53
|
+
/** Default stage session directory to restore after a host restart. */
|
|
54
|
+
readonly defaultSessionDir?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Terminal statuses whose retained agent session may be reopened for follow-up. */
|
|
58
|
+
const TERMINAL_POSTMORTEM_STATUSES = new Set<StageSnapshot["status"]>(["completed"]);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* True when the snapshot is an eligible terminal agent stage: a completed stage
|
|
62
|
+
* that retains a `sessionFile`. Prompt/boundary/summary/skipped nodes without
|
|
63
|
+
* their own agent session are excluded because they have no `sessionFile`.
|
|
64
|
+
*/
|
|
65
|
+
export function isPostMortemEligibleStage(stage: StageSnapshot): boolean {
|
|
66
|
+
return TERMINAL_POSTMORTEM_STATUSES.has(stage.status)
|
|
67
|
+
&& typeof stage.sessionFile === "string"
|
|
68
|
+
&& stage.sessionFile.length > 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resolve an interactive post-mortem chat handle for a terminal agent stage.
|
|
73
|
+
*
|
|
74
|
+
* Reuses an existing non-disposed registry handle when present; otherwise
|
|
75
|
+
* validates the retained session and lazily creates a detached, single-flight
|
|
76
|
+
* handle keyed by the real `{ runId, stageId }`. Returns an explicit
|
|
77
|
+
* unavailable reason so callers can preserve the read-only transcript.
|
|
78
|
+
*/
|
|
79
|
+
export function ensurePostMortemStageHandle(
|
|
80
|
+
runId: string,
|
|
81
|
+
stage: StageSnapshot,
|
|
82
|
+
deps: PostMortemStageChatDeps,
|
|
83
|
+
): EnsurePostMortemStageHandleResult {
|
|
84
|
+
if (!TERMINAL_POSTMORTEM_STATUSES.has(stage.status)) return { ok: false, reason: "not_terminal" };
|
|
85
|
+
const existing = deps.registry.get(runId, stage.id);
|
|
86
|
+
if (existing !== undefined && existing.isDisposed !== true) {
|
|
87
|
+
return { ok: true, handle: existing };
|
|
88
|
+
}
|
|
89
|
+
if (deps.adapters?.agentSession === undefined) return { ok: false, reason: "no_adapter" };
|
|
90
|
+
const sessionFile = stage.sessionFile;
|
|
91
|
+
if (typeof sessionFile !== "string" || sessionFile.length === 0) return { ok: false, reason: "no_session" };
|
|
92
|
+
if (!isReopenableSessionTranscript(sessionFile)) return { ok: false, reason: "invalid_session" };
|
|
93
|
+
|
|
94
|
+
const adapters = deps.adapters;
|
|
95
|
+
const handle = deps.registry.getOrCreateDetached(runId, stage.id, () =>
|
|
96
|
+
createPostMortemStageHandle(runId, stage, sessionFile, adapters, deps.cwd, deps.defaultSessionDir),
|
|
97
|
+
);
|
|
98
|
+
return { ok: true, handle };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Build a lazy session-only stage-control handle that reopens `sessionFile` on
|
|
103
|
+
* first use and appends follow-up conversation without dispatching the
|
|
104
|
+
* workflow. Pause/resume of workflow execution is rejected.
|
|
105
|
+
*/
|
|
106
|
+
export function createPostMortemStageHandle(
|
|
107
|
+
runId: string,
|
|
108
|
+
stage: Pick<StageSnapshot, "id" | "name" | "sessionId">,
|
|
109
|
+
sessionFile: string,
|
|
110
|
+
adapters: StageAdapters,
|
|
111
|
+
cwd: string | undefined,
|
|
112
|
+
defaultSessionDir: string | undefined,
|
|
113
|
+
): StageControlHandle {
|
|
114
|
+
const context = createStageContext({
|
|
115
|
+
runId,
|
|
116
|
+
stageId: stage.id,
|
|
117
|
+
stageName: stage.name,
|
|
118
|
+
adapters,
|
|
119
|
+
stageOptions: {
|
|
120
|
+
resumeFromSessionFile: sessionFile,
|
|
121
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
122
|
+
},
|
|
123
|
+
...(defaultSessionDir !== undefined ? { defaultSessionDir } : {}),
|
|
124
|
+
});
|
|
125
|
+
let disposed = false;
|
|
126
|
+
const ensureAttached = async (): Promise<void> => {
|
|
127
|
+
if (disposed) throw new Error(`Post-mortem stage chat "${stage.name}" is closed.`);
|
|
128
|
+
if (context.__sessionMeta().sessionFile === undefined) {
|
|
129
|
+
await context.__ensureSessionFromFile(sessionFile);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
runId,
|
|
134
|
+
stageId: stage.id,
|
|
135
|
+
stageName: stage.name,
|
|
136
|
+
status: "completed",
|
|
137
|
+
get sessionId() { return context.__sessionMeta().sessionId ?? stage.sessionId; },
|
|
138
|
+
get sessionFile() { return context.__sessionMeta().sessionFile ?? sessionFile; },
|
|
139
|
+
get isStreaming() { return context.isStreaming; },
|
|
140
|
+
get isDisposed() { return disposed; },
|
|
141
|
+
get messages() { return context.messages; },
|
|
142
|
+
get agentSession() { return context.__agentSession(); },
|
|
143
|
+
async ensureAttached() { await ensureAttached(); },
|
|
144
|
+
async prompt(text: string) {
|
|
145
|
+
await ensureAttached();
|
|
146
|
+
await context.prompt(text);
|
|
147
|
+
},
|
|
148
|
+
async steer(text: string) {
|
|
149
|
+
await ensureAttached();
|
|
150
|
+
await context.steer(text);
|
|
151
|
+
},
|
|
152
|
+
async followUp(text: string) {
|
|
153
|
+
await ensureAttached();
|
|
154
|
+
await context.followUp(text);
|
|
155
|
+
},
|
|
156
|
+
async pause() {
|
|
157
|
+
throw new Error("Post-mortem stage chat cannot pause or resume workflow execution.");
|
|
158
|
+
},
|
|
159
|
+
async resume() {
|
|
160
|
+
throw new Error("Post-mortem stage chat cannot pause or resume workflow execution.");
|
|
161
|
+
},
|
|
162
|
+
subscribe(listener: AgentSessionEventListener) { return context.subscribe(listener); },
|
|
163
|
+
async dispose() {
|
|
164
|
+
if (disposed) return;
|
|
165
|
+
disposed = true;
|
|
166
|
+
await context.__dispose();
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|