@bastani/atomic 0.9.5-alpha.8 → 0.9.5
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 +122 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +12 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/cursor/src/model-mapper.ts +6 -3
- package/dist/builtin/intercom/CHANGELOG.md +37 -0
- package/dist/builtin/intercom/README.md +4 -2
- package/dist/builtin/intercom/broker/broker.ts +6 -114
- package/dist/builtin/intercom/broker/client.ts +29 -54
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
- package/dist/builtin/intercom/broker/send-handler.ts +106 -0
- package/dist/builtin/intercom/broker/send-signature.ts +37 -0
- package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
- package/dist/builtin/intercom/index-heavy.ts +49 -53
- package/dist/builtin/intercom/index.ts +278 -262
- package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
- package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
- package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
- package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
- package/dist/builtin/intercom/lifecycle.ts +37 -20
- package/dist/builtin/intercom/package.json +3 -6
- package/dist/builtin/intercom/reply-routing.ts +17 -0
- package/dist/builtin/intercom/subagent-relay.ts +58 -12
- package/dist/builtin/intercom/types.ts +3 -3
- package/dist/builtin/mcp/CHANGELOG.md +38 -0
- package/dist/builtin/mcp/OAUTH.md +1 -0
- package/dist/builtin/mcp/README.md +10 -6
- package/dist/builtin/mcp/apps-cancellation.ts +32 -0
- package/dist/builtin/mcp/call-tool-result.ts +9 -0
- package/dist/builtin/mcp/caller-wait.ts +50 -0
- package/dist/builtin/mcp/command-registration.ts +82 -0
- package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
- package/dist/builtin/mcp/direct-tools.ts +40 -255
- package/dist/builtin/mcp/host-html-template.ts +4 -2
- package/dist/builtin/mcp/index.ts +274 -239
- package/dist/builtin/mcp/init.ts +96 -126
- package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
- package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
- package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
- package/dist/builtin/mcp/metadata-hydration.ts +52 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +4 -4
- package/dist/builtin/mcp/proxy-call.ts +111 -40
- package/dist/builtin/mcp/proxy-connect.ts +35 -15
- package/dist/builtin/mcp/proxy-info-modes.ts +106 -23
- package/dist/builtin/mcp/proxy-modes.ts +3 -3
- package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/state-lease.ts +12 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/mcp/ui-server.ts +8 -8
- package/dist/builtin/mcp/ui-session.ts +9 -18
- package/dist/builtin/subagents/CHANGELOG.md +78 -0
- package/dist/builtin/subagents/README.md +30 -29
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
- package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
- package/dist/builtin/subagents/src/extension/index.ts +289 -320
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
- package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +26 -20
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
- package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +177 -233
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +29 -15
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +63 -46
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +55 -12
- package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
- package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +20 -10
- package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
- package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
- package/dist/builtin/subagents/src/tui/render-widget.ts +157 -89
- package/dist/builtin/web-access/CHANGELOG.md +28 -0
- package/dist/builtin/web-access/README.md +4 -0
- package/dist/builtin/web-access/content-tools.ts +8 -3
- package/dist/builtin/web-access/index-heavy.ts +1 -1
- package/dist/builtin/web-access/index.ts +190 -46
- package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/result-renderers.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/web-access/web-search-activity.ts +1 -1
- package/dist/builtin/web-access/web-search-return.ts +7 -0
- package/dist/builtin/web-access/web-search-summary.ts +1 -1
- package/dist/builtin/web-access/web-search-tool.ts +4 -2
- package/dist/builtin/workflows/CHANGELOG.md +86 -0
- package/dist/builtin/workflows/README.md +5 -5
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +27 -4
- package/dist/builtin/workflows/builtin/goal-runner.ts +86 -27
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +10 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +9 -9
- package/dist/builtin/workflows/builtin/ralph-models.ts +71 -36
- package/dist/builtin/workflows/builtin/ralph-runner.ts +20 -31
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +17 -1
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +2 -1
- package/dist/builtin/workflows/src/durable/types.ts +16 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +20 -19
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -22
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +3 -2
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
- package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +23 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +129 -17
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +9 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -3
- 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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -2
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +1 -1
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +5 -5
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +42 -32
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +15 -15
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +14 -9
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +79 -46
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
- package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
- package/dist/core/compaction/context-assistant-turns.js +87 -0
- package/dist/core/compaction/context-assistant-turns.js.map +1 -0
- package/dist/core/compaction/context-compaction-critical.d.ts +1 -1
- package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-critical.js +2 -2
- package/dist/core/compaction/context-compaction-critical.js.map +1 -1
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts +10 -2
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-eviction.js +196 -146
- package/dist/core/compaction/context-compaction-eviction.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +1 -1
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-types.d.ts +2 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-types.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +5 -4
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +17 -15
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-store.js +1 -1
- package/dist/core/compaction/context-deletion-store.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +36 -31
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +1 -2
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +33 -37
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.js +3 -1
- package/dist/core/copilot-model-synthesis.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -7
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/messages.d.ts +9 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +100 -18
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +5 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +49 -8
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +11 -5
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +8 -0
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +93 -8
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +24 -12
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +7 -6
- 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 +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +23 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +33 -5
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +6 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +12 -7
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +24 -9
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts +1 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -10
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-entry-normalization.d.ts +7 -0
- package/dist/core/session-entry-normalization.d.ts.map +1 -0
- package/dist/core/session-entry-normalization.js +14 -0
- package/dist/core/session-entry-normalization.js.map +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +127 -108
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- 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 +11 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +2 -2
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-early-input.d.ts.map +1 -1
- package/dist/main-early-input.js +7 -0
- package/dist/main-early-input.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.js +3 -1
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-child-ordering.js +26 -0
- package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +43 -30
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -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 +41 -6
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- 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-surface.d.ts +2 -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-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +11 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +0 -3
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +15 -1
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +5 -1
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +20 -21
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +3 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/docs/changelog.mdx +19 -0
- package/docs/compaction.md +60 -49
- package/docs/custom-provider.md +18 -5
- package/docs/development.md +4 -0
- package/docs/extensions.md +11 -2
- package/docs/json.md +1 -1
- package/docs/models.md +69 -10
- package/docs/providers.md +1 -1
- package/docs/quickstart.md +12 -8
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +4 -4
- package/docs/subagents.md +40 -5
- package/docs/tools.md +1 -1
- package/docs/usage.md +4 -2
- package/docs/windows.md +4 -0
- package/docs/workflows.md +33 -48
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/subagent/README.md +2 -2
- package/examples/extensions/subagent/index.ts +1 -2
- package/examples/extensions/subagent/schemas.ts +4 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/npm-shrinkwrap.json +48 -51
- package/package.json +7 -7
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
|
@@ -32,6 +32,14 @@ export interface DurableWorkflowHandle {
|
|
|
32
32
|
readonly updatedAt: number;
|
|
33
33
|
/** Current durable status. */
|
|
34
34
|
readonly status: DurableWorkflowStatus;
|
|
35
|
+
/** Original invocation cwd used to resolve repo-relative workflow defaults on resume. */
|
|
36
|
+
readonly invocationCwd?: string;
|
|
37
|
+
/** Resolved workflow cwd when an input-bound reusable worktree was set up. */
|
|
38
|
+
readonly workflowCwd?: string;
|
|
39
|
+
/** Invoking repository root used for reusable worktree validation. */
|
|
40
|
+
readonly repositoryRoot?: string;
|
|
41
|
+
/** Resolved reusable git worktree root, when setup happened at workflow start. */
|
|
42
|
+
readonly gitWorktreeRoot?: string;
|
|
35
43
|
/** Session file path that caches this workflow's durable metadata. */
|
|
36
44
|
readonly sessionFile?: string;
|
|
37
45
|
/** Number of completed durable checkpoints. */
|
|
@@ -158,6 +166,10 @@ export interface DurableCheckpointEntry {
|
|
|
158
166
|
readonly label?: string;
|
|
159
167
|
readonly rootWorkflowId?: string;
|
|
160
168
|
readonly resumable?: boolean;
|
|
169
|
+
readonly invocationCwd?: string;
|
|
170
|
+
readonly workflowCwd?: string;
|
|
171
|
+
readonly repositoryRoot?: string;
|
|
172
|
+
readonly gitWorktreeRoot?: string;
|
|
161
173
|
readonly ts: number;
|
|
162
174
|
}
|
|
163
175
|
|
|
@@ -176,6 +188,10 @@ export interface ResumableWorkflowEntry {
|
|
|
176
188
|
readonly label?: string;
|
|
177
189
|
readonly rootWorkflowId?: string;
|
|
178
190
|
readonly resumable?: boolean;
|
|
191
|
+
readonly invocationCwd?: string;
|
|
192
|
+
readonly workflowCwd?: string;
|
|
193
|
+
readonly repositoryRoot?: string;
|
|
194
|
+
readonly gitWorktreeRoot?: string;
|
|
179
195
|
readonly createdAt: number;
|
|
180
196
|
readonly updatedAt: number;
|
|
181
197
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WorkflowChainOptions, WorkflowParallelOptions, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskStep } from "../../shared/types.js";
|
|
2
2
|
import type { ParallelFailFastScope } from "../../runs/foreground/executor-types.js";
|
|
3
3
|
import type { EngineRuntime } from "../runtime.js";
|
|
4
|
+
import { RESUME_CONTINUATION_PROMPT } from "../../shared/resume-continuation.js";
|
|
4
5
|
import {
|
|
5
6
|
applyTaskContext,
|
|
6
7
|
structuredTaskOutputText,
|
|
@@ -41,6 +42,7 @@ function createTaskPrimitive(runtime: EngineRuntime): WorkflowTaskPrimitive {
|
|
|
41
42
|
const resolvedTaskOptions = stageOptionsWithGitWorktree(
|
|
42
43
|
stageOptionsWithInputDefaults(taskOptions, runtime.inputRuntimeDefaults),
|
|
43
44
|
runtime.workflowInvocationCwd,
|
|
45
|
+
runtime.gitWorktreeSetupCache,
|
|
44
46
|
) ?? taskOptions;
|
|
45
47
|
const stageOptions = taskStageOptions(resolvedTaskOptions);
|
|
46
48
|
const stageHandle = runtime.spawnStage(name, {
|
|
@@ -50,7 +52,7 @@ function createTaskPrimitive(runtime: EngineRuntime): WorkflowTaskPrimitive {
|
|
|
50
52
|
});
|
|
51
53
|
const stage = stageHandle.context;
|
|
52
54
|
const promptText = resolvedTaskOptions.resumeFromSessionFile !== undefined
|
|
53
|
-
?
|
|
55
|
+
? RESUME_CONTINUATION_PROMPT
|
|
54
56
|
: applyTaskContext(`${taskReadInstruction(resolvedTaskOptions)}${taskPrompt(resolvedTaskOptions)}`, taskPrevious(resolvedTaskOptions));
|
|
55
57
|
const rawOutput = await stage.prompt(promptText, taskPromptOptions(resolvedTaskOptions));
|
|
56
58
|
const structured = typeof rawOutput === "string" ? undefined : rawOutput;
|
|
@@ -38,8 +38,7 @@ export async function finalizeDurableTerminalStatus(input: DurableTerminalFinali
|
|
|
38
38
|
|
|
39
39
|
const durableStatus = toDurableStatus(status);
|
|
40
40
|
if (durableStatus !== undefined) {
|
|
41
|
-
|
|
42
|
-
input.durableBackend.setWorkflowStatus(input.runId, durableStatus, undefined, resumable);
|
|
41
|
+
input.durableBackend.setWorkflowStatus(input.runId, durableStatus, undefined, input.runSnapshot.resumable);
|
|
43
42
|
}
|
|
44
43
|
try {
|
|
45
44
|
await input.durableBackend.flush?.();
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { RunEndMetadata } from "../shared/store-public-types.js";
|
|
2
2
|
import type { WorkflowOutputValues } from "../shared/types.js";
|
|
3
|
+
import type { RunSnapshot } from "../shared/store-types.js";
|
|
4
|
+
import {
|
|
5
|
+
actionableReturnedStatusText,
|
|
6
|
+
isReturnedBlockedWorkflowStatus,
|
|
7
|
+
isReturnedResumableBlockedWorkflowStatus,
|
|
8
|
+
normalizeReturnedWorkflowStatus,
|
|
9
|
+
structuredRecoverableWorkflowFailure,
|
|
10
|
+
} from "../shared/returned-run-status.js";
|
|
3
11
|
|
|
4
12
|
export interface ReturnedRunStatus {
|
|
5
13
|
readonly status: "completed" | "failed" | "blocked";
|
|
@@ -7,23 +15,44 @@ export interface ReturnedRunStatus {
|
|
|
7
15
|
readonly metadata?: RunEndMetadata;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
export function classifyReturnedRunStatus(result: WorkflowOutputValues | undefined): ReturnedRunStatus {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
18
|
+
export function classifyReturnedRunStatus(result: WorkflowOutputValues | undefined, runSnapshot?: RunSnapshot): ReturnedRunStatus {
|
|
19
|
+
const structuredFailure = runSnapshot !== undefined ? structuredRecoverableWorkflowFailure(runSnapshot) : undefined;
|
|
20
|
+
if (structuredFailure !== undefined) {
|
|
21
|
+
return {
|
|
22
|
+
status: "blocked",
|
|
23
|
+
error: structuredFailure.error,
|
|
24
|
+
metadata: structuredFailure.metadata,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const returnedStatus = normalizeReturnedWorkflowStatus(result?.["status"]);
|
|
28
|
+
if (returnedStatus === undefined || returnedStatus === "completed" || returnedStatus === "complete") {
|
|
13
29
|
return { status: "completed" };
|
|
14
30
|
}
|
|
15
31
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
const error = returnedStatusError(result, returnedStatus);
|
|
33
|
+
if (returnedStatus === "failed") {
|
|
34
|
+
return {
|
|
35
|
+
status: "failed",
|
|
36
|
+
error,
|
|
37
|
+
metadata: returnedFailureMetadata(error),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (isReturnedBlockedWorkflowStatus(returnedStatus)) {
|
|
41
|
+
const metadata = isReturnedResumableBlockedWorkflowStatus(returnedStatus)
|
|
42
|
+
? returnedRecoverableBlockedMetadata(error)
|
|
43
|
+
: { resumable: false };
|
|
44
|
+
return {
|
|
45
|
+
status: "blocked",
|
|
46
|
+
error,
|
|
47
|
+
metadata,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return { status: "completed" };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function returnedStatusError(result: WorkflowOutputValues | undefined, returnedStatus: string): string {
|
|
55
|
+
return actionableReturnedStatusText(result) ?? `Workflow returned status ${JSON.stringify(returnedStatus)}.`;
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
function returnedFailureMetadata(error: string): RunEndMetadata {
|
|
@@ -36,6 +65,11 @@ function returnedFailureMetadata(error: string): RunEndMetadata {
|
|
|
36
65
|
};
|
|
37
66
|
}
|
|
38
67
|
|
|
39
|
-
function
|
|
40
|
-
return {
|
|
68
|
+
function returnedRecoverableBlockedMetadata(error: string): RunEndMetadata {
|
|
69
|
+
return {
|
|
70
|
+
failureRecoverability: "recoverable",
|
|
71
|
+
failureDisposition: "active_blocked",
|
|
72
|
+
failureMessage: error,
|
|
73
|
+
resumable: true,
|
|
74
|
+
};
|
|
41
75
|
}
|
|
@@ -19,7 +19,7 @@ import { stageControlRegistry as defaultStageControlRegistry } from "../runs/for
|
|
|
19
19
|
import type { RunOpts, RunResult } from "../runs/foreground/executor-types.js";
|
|
20
20
|
import { unknownErrorMessage, findWorkflowExitSignal, parentWorkflowExitAbortReason } from "../runs/foreground/executor-abort.js";
|
|
21
21
|
import { resolveAndValidateInputs, resolveInputConcurrency, resolveInputRuntimeDefaults } from "../runs/foreground/executor-inputs.js";
|
|
22
|
-
import { workflowCwdWithInputWorktree } from "../runs/foreground/executor-direct-helpers.js";
|
|
22
|
+
import { createGitWorktreeSetupCache, workflowCwdWithInputWorktree, workflowInvocationMetadata } from "../runs/foreground/executor-direct-helpers.js";
|
|
23
23
|
import { createStageScheduler } from "../runs/foreground/executor-scheduler.js";
|
|
24
24
|
import { createRunFinalizers } from "../runs/foreground/executor-run-finalizers.js";
|
|
25
25
|
import { buildPromptNodeUiAdapter } from "../runs/foreground/executor-prompt-nodes.js";
|
|
@@ -152,11 +152,11 @@ export async function run<
|
|
|
152
152
|
|
|
153
153
|
const tracker = new GraphFrontierTracker();
|
|
154
154
|
const inputConcurrency = resolveInputConcurrency(def.inputs, resolvedInputs);
|
|
155
|
-
const inputRuntimeDefaults = resolveInputRuntimeDefaults(def, resolvedInputs);
|
|
155
|
+
const inputRuntimeDefaults = resolveInputRuntimeDefaults(def, resolvedInputs), gitWorktreeSetupCache = createGitWorktreeSetupCache();
|
|
156
156
|
const workflowInvocationCwd = opts.cwd ?? process.cwd();
|
|
157
157
|
let workflowCwd: string | undefined;
|
|
158
158
|
const resolveWorkflowCwd = (): string => {
|
|
159
|
-
workflowCwd ??= workflowCwdWithInputWorktree(inputRuntimeDefaults, workflowInvocationCwd);
|
|
159
|
+
workflowCwd ??= workflowCwdWithInputWorktree(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache);
|
|
160
160
|
return workflowCwd;
|
|
161
161
|
};
|
|
162
162
|
const limiter = createRunLimiter(inputConcurrency ?? opts.config?.defaultConcurrency);
|
|
@@ -271,7 +271,7 @@ export async function run<
|
|
|
271
271
|
limiter,
|
|
272
272
|
inputRuntimeDefaults,
|
|
273
273
|
workflowInvocationCwd,
|
|
274
|
-
stageRegistry,
|
|
274
|
+
stageRegistry, gitWorktreeSetupCache,
|
|
275
275
|
exit,
|
|
276
276
|
classifyExecutorFailure,
|
|
277
277
|
});
|
|
@@ -310,22 +310,19 @@ export async function run<
|
|
|
310
310
|
},
|
|
311
311
|
runWorkflow: run,
|
|
312
312
|
});
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
const durableRootWorkflowRegistration = {
|
|
314
|
+
workflowId: runId,
|
|
315
|
+
name: def.name,
|
|
316
|
+
inputs: resolvedInputs as Record<string, import("../shared/types.js").WorkflowSerializableValue>,
|
|
317
|
+
createdAt: runSnapshot.startedAt,
|
|
318
|
+
status: "running" as const,
|
|
319
|
+
rootWorkflowId: runId,
|
|
320
|
+
resumable: true,
|
|
321
|
+
...(opts.persistence !== undefined ? { sessionFile: undefined } : {}),
|
|
322
|
+
};
|
|
315
323
|
if (opts.continuation === undefined && opts.parentRun === undefined) {
|
|
316
|
-
|
|
317
|
-
durableBackend.registerWorkflow({
|
|
318
|
-
workflowId: runId,
|
|
319
|
-
name: def.name,
|
|
320
|
-
inputs: resolvedInputs as Record<string, import("../shared/types.js").WorkflowSerializableValue>,
|
|
321
|
-
createdAt: runSnapshot.startedAt,
|
|
322
|
-
status: "running",
|
|
323
|
-
rootWorkflowId: runId,
|
|
324
|
-
resumable: true,
|
|
325
|
-
...(opts.persistence !== undefined ? { sessionFile: undefined } : {}),
|
|
326
|
-
});
|
|
324
|
+
durableBackend.registerWorkflow({ ...durableRootWorkflowRegistration, invocationCwd: workflowInvocationCwd });
|
|
327
325
|
} else if (opts.parentRun === undefined) {
|
|
328
|
-
// Resuming a root workflow: mark it as running again in the backend.
|
|
329
326
|
durableBackend.setWorkflowStatus(runId, "running");
|
|
330
327
|
}
|
|
331
328
|
const tool = createToolPrimitive({
|
|
@@ -408,6 +405,10 @@ export async function run<
|
|
|
408
405
|
}
|
|
409
406
|
}
|
|
410
407
|
|
|
408
|
+
if (opts.continuation === undefined && opts.parentRun === undefined) {
|
|
409
|
+
durableBackend.registerWorkflow({ ...durableRootWorkflowRegistration, ...workflowInvocationMetadata(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache) });
|
|
410
|
+
}
|
|
411
|
+
|
|
411
412
|
const rawResult = await def.run(ctx);
|
|
412
413
|
if (ownController.signal.aborted) {
|
|
413
414
|
const selectedExit = findWorkflowExitSignal(ownController.signal.reason, exitScope);
|
|
@@ -421,7 +422,7 @@ export async function run<
|
|
|
421
422
|
assertWorkflowRunOutputs(def.name, result, def.outputs);
|
|
422
423
|
assertWorkflowCreatedStage(runSnapshot);
|
|
423
424
|
await durableBackend.flush?.();
|
|
424
|
-
const returned = classifyReturnedRunStatus(result);
|
|
425
|
+
const returned = classifyReturnedRunStatus(result, runSnapshot);
|
|
425
426
|
const recorded = activeStore.recordRunEnd(runId, returned.status, result, returned.error, returned.metadata);
|
|
426
427
|
appendRunEndWhenRecorded(opts.persistence, recorded, { runId, status: returned.status, result, ...(returned.error !== undefined ? { error: returned.error } : {}), ...(returned.metadata ?? {}), ...(runSnapshot.endedAt !== undefined ? { endedAt: runSnapshot.endedAt } : {}), ...(runSnapshot.durationMs !== undefined ? { durationMs: runSnapshot.durationMs } : {}), ts: Date.now() });
|
|
427
428
|
durableBackend.setWorkflowStatus(runId, returned.status, undefined, returned.metadata?.resumable);
|
|
@@ -13,6 +13,7 @@ import { createWorkflowStageFactory } from "../runs/foreground/executor-stage-fa
|
|
|
13
13
|
import { createWorkflowBoundaryFactory, type WorkflowBoundaryStage } from "../runs/foreground/executor-child-boundary.js";
|
|
14
14
|
import type { GraphFrontierTracker } from "./graph-inference.js";
|
|
15
15
|
import type { EngineChildRunOptions, EngineStageRuntimeOptions, EngineWorkflowBoundaryOptions } from "./options.js";
|
|
16
|
+
import type { GitWorktreeSetupCache } from "../runs/foreground/executor-direct-helpers.js";
|
|
16
17
|
|
|
17
18
|
export interface EngineRuntimeInput {
|
|
18
19
|
readonly runId: string;
|
|
@@ -31,6 +32,7 @@ export interface EngineRuntimeInput {
|
|
|
31
32
|
readonly limiter: ConcurrencyLimiter;
|
|
32
33
|
readonly inputRuntimeDefaults: Partial<StageOptions>;
|
|
33
34
|
readonly workflowInvocationCwd: string;
|
|
35
|
+
readonly gitWorktreeSetupCache: GitWorktreeSetupCache;
|
|
34
36
|
readonly stageRegistry: StageControlRegistry;
|
|
35
37
|
readonly exit: WorkflowExitManager;
|
|
36
38
|
readonly classifyExecutorFailure: LiveStageRuntime["classifyExecutorFailure"];
|
|
@@ -73,6 +75,7 @@ export class EngineRuntime {
|
|
|
73
75
|
readonly exit: WorkflowExitManager;
|
|
74
76
|
readonly inputRuntimeDefaults: Partial<StageOptions>;
|
|
75
77
|
readonly workflowInvocationCwd: string;
|
|
78
|
+
readonly gitWorktreeSetupCache: GitWorktreeSetupCache;
|
|
76
79
|
|
|
77
80
|
private readonly spawnAgentStage: (
|
|
78
81
|
name: string,
|
|
@@ -93,6 +96,7 @@ export class EngineRuntime {
|
|
|
93
96
|
this.exit = input.exit;
|
|
94
97
|
this.inputRuntimeDefaults = input.inputRuntimeDefaults;
|
|
95
98
|
this.workflowInvocationCwd = input.workflowInvocationCwd;
|
|
99
|
+
this.gitWorktreeSetupCache = input.gitWorktreeSetupCache;
|
|
96
100
|
|
|
97
101
|
// The runtime only wires host-injected ports; stage sessions are still
|
|
98
102
|
// created lazily by the stage runner through input.adapters.agentSession.
|
|
@@ -108,6 +112,7 @@ export class EngineRuntime {
|
|
|
108
112
|
limiter: input.limiter,
|
|
109
113
|
inputRuntimeDefaults: input.inputRuntimeDefaults,
|
|
110
114
|
workflowInvocationCwd: input.workflowInvocationCwd,
|
|
115
|
+
gitWorktreeSetupCache: input.gitWorktreeSetupCache,
|
|
111
116
|
stageRegistry: input.stageRegistry,
|
|
112
117
|
exit: input.exit,
|
|
113
118
|
classifyExecutorFailure: input.classifyExecutorFailure,
|
|
@@ -85,6 +85,7 @@ function factory(pi: ExtensionAPI): void {
|
|
|
85
85
|
(ctx) => runtimeState.runtimeForContext(ctx),
|
|
86
86
|
() => runtimeState.persistenceRef.current,
|
|
87
87
|
runtimeState.reloadWorkflowResources,
|
|
88
|
+
runtimeState.ensureWorkflowResourcesLoaded,
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
registerWorkflowTool(pi, executeWorkflowTool, runtimeState.runWithLifecycleSuppressedForPolicy);
|
|
@@ -93,12 +94,14 @@ function factory(pi: ExtensionAPI): void {
|
|
|
93
94
|
runtimeForContext: runtimeState.runtimeForContext,
|
|
94
95
|
overlay,
|
|
95
96
|
reloadWorkflowResources: runtimeState.reloadWorkflowResources,
|
|
97
|
+
ensureWorkflowResourcesLoaded: runtimeState.ensureWorkflowResourcesLoaded,
|
|
96
98
|
runWithLifecycleSuppressedForPolicy: runtimeState.runWithLifecycleSuppressedForPolicy,
|
|
97
99
|
runControl: {
|
|
98
100
|
pi,
|
|
99
101
|
overlay,
|
|
100
102
|
getPersistence: () => runtimeState.persistenceRef.current,
|
|
101
103
|
runtimeForContext: runtimeState.runtimeForContext,
|
|
104
|
+
ensureWorkflowResourcesLoaded: runtimeState.ensureWorkflowResourcesLoaded,
|
|
102
105
|
},
|
|
103
106
|
});
|
|
104
107
|
registerWorkflowMessageRenderers(pi);
|
|
@@ -58,7 +58,9 @@ export function registerWorkflowLifecycleHandlers(
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
pi.on("session_start", async (_event, ctx) => {
|
|
61
|
+
runtimeState.resetWorkflowDiscoveryForSession();
|
|
61
62
|
deAdvertiseAskUserQuestionWhenHeadless(pi, ctx?.hasUI);
|
|
63
|
+
await runtimeState.ensureWorkflowConfigLoaded();
|
|
62
64
|
killAllRuns({ store, cancellation: cancellationRegistry, persistence: runtimeState.persistenceRef.current });
|
|
63
65
|
store.clear();
|
|
64
66
|
clearForms();
|
|
@@ -66,10 +68,14 @@ export function registerWorkflowLifecycleHandlers(
|
|
|
66
68
|
resetWorkflowHilAnswerNotificationState(runtimeState.hilAnswerNotificationState);
|
|
67
69
|
stageControlRegistry.clear();
|
|
68
70
|
runtimeState.setIntercomParentSession(registerIntercomParentSession(pi));
|
|
69
|
-
await runtimeState.discoveryPromise;
|
|
70
71
|
runtimeState.setNotificationsActive(true);
|
|
72
|
+
runtimeState.startWorkflowDiscoveryWarmup(() => {
|
|
73
|
+
if (!ctx?.ui) return;
|
|
74
|
+
const diagnostics = formatStartupDiagnostics(null, runtimeState.discoveryRef.current);
|
|
75
|
+
if (diagnostics !== null) ctx.ui.notify?.(diagnostics, "warning");
|
|
76
|
+
});
|
|
71
77
|
if (ctx?.ui) {
|
|
72
|
-
const diagnostics = formatStartupDiagnostics(runtimeState.configLoadRef.current,
|
|
78
|
+
const diagnostics = formatStartupDiagnostics(runtimeState.configLoadRef.current, null);
|
|
73
79
|
if (diagnostics !== null) ctx.ui.notify?.(diagnostics, "warning");
|
|
74
80
|
deps.storeWidgetRef.current?.();
|
|
75
81
|
deps.storeWidgetRef.current = installStoreWidget({ ui: ctx.ui }, store);
|
|
@@ -108,6 +114,7 @@ export function registerWorkflowLifecycleHandlers(
|
|
|
108
114
|
}
|
|
109
115
|
deps.storeWidgetRef.current?.();
|
|
110
116
|
deps.storeWidgetRef.current = null;
|
|
117
|
+
runtimeState.resetWorkflowDiscoveryForSession();
|
|
111
118
|
runtimeState.setNotificationsActive(false);
|
|
112
119
|
});
|
|
113
120
|
}
|
|
@@ -44,11 +44,14 @@ export interface WorkflowExtensionRuntimeState {
|
|
|
44
44
|
runtimeProxy: ExtensionRuntime;
|
|
45
45
|
configLoadRef: { current: ConfigLoadResult | null };
|
|
46
46
|
discoveryRef: { current: DiscoveryResult | null };
|
|
47
|
-
discoveryPromise: Promise<void>;
|
|
48
47
|
lifecycleNotificationState: ReturnType<typeof createWorkflowLifecycleNotificationState>;
|
|
49
48
|
hilAnswerNotificationState: ReturnType<typeof createWorkflowHilAnswerNotificationState>;
|
|
50
49
|
runtimeForContext(ctx?: PiModelContext): ExtensionRuntime;
|
|
50
|
+
resetWorkflowDiscoveryForSession(): void;
|
|
51
|
+
ensureWorkflowConfigLoaded(): Promise<void>;
|
|
52
|
+
ensureWorkflowResourcesLoaded(options?: { allowInFlight?: boolean }): Promise<void>;
|
|
51
53
|
reloadWorkflowResources(options?: { allowInFlight?: boolean }): Promise<void>;
|
|
54
|
+
startWorkflowDiscoveryWarmup(onSettled?: () => void): void;
|
|
52
55
|
runWithLifecycleSuppressedForPolicy<T>(policy: WorkflowExecutionPolicy, fn: () => Promise<T>): Promise<T>;
|
|
53
56
|
setNotificationsActive(active: boolean): void;
|
|
54
57
|
setIntercomParentSession(session: string | null): void;
|
|
@@ -74,6 +77,7 @@ export function createWorkflowExtensionRuntimeState(
|
|
|
74
77
|
let lifecycleNotificationsUnsubscribe: (() => void) | null = null;
|
|
75
78
|
let hilAnswerNotificationsUnsubscribe: (() => void) | null = null;
|
|
76
79
|
let notificationsActive = false;
|
|
80
|
+
let notificationGeneration = 0;
|
|
77
81
|
const lifecycleNotificationState = createWorkflowLifecycleNotificationState();
|
|
78
82
|
const hilAnswerNotificationState = createWorkflowHilAnswerNotificationState();
|
|
79
83
|
const lifecycleNotificationConfigRef: { current: WorkflowLifecycleNotificationConfig } = {
|
|
@@ -185,32 +189,15 @@ export function createWorkflowExtensionRuntimeState(
|
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
let workflowReloadQueue: Promise<void> = Promise.resolve();
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
async function loadPackageWorkflowPaths(): Promise<string[]> {
|
|
194
|
-
const packageResources = (await pi.refreshWorkflowResources?.()) ?? pi.getWorkflowResources?.() ?? [];
|
|
195
|
-
return packageResources.filter((resource) => resource.enabled !== false).map((resource) => resource.path);
|
|
192
|
+
|
|
193
|
+
let lazyDiscoveryPromise: Promise<void> | null = null;
|
|
194
|
+
let workflowDiscoveryGeneration = 0;
|
|
195
|
+
function deferToMacrotask(): Promise<void> {
|
|
196
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (options?.allowInFlight !== true && activeRuns > 0) {
|
|
200
|
-
throw new WorkflowReloadBlockedError(reloadBlockedMessage(activeRuns));
|
|
201
|
-
}
|
|
202
|
-
if (options?.allowInFlight === true && activeRuns > 0 && process.env.ATOMIC_WORKFLOW_DEBUG === "1") {
|
|
203
|
-
console.warn(`Workflow reload bypassed in-flight guard with ${activeRuns} active run(s).`);
|
|
204
|
-
}
|
|
205
|
-
const configResult = await loadWorkflowConfig();
|
|
198
|
+
|
|
199
|
+
function applyWorkflowConfig(configResult: ConfigLoadResult): void {
|
|
206
200
|
configLoadRef.current = configResult;
|
|
207
|
-
const hasGlobal = configResult.globalConfig != null;
|
|
208
|
-
const hasProject = configResult.projectConfig != null;
|
|
209
|
-
const discoveryConfig = hasGlobal || hasProject
|
|
210
|
-
? toScopedDiscoveryConfig(configResult.globalConfig ?? null, configResult.projectConfig ?? null, { projectRoot: process.cwd() })
|
|
211
|
-
: undefined;
|
|
212
|
-
const result = await discoverWorkflows({ config: discoveryConfig, packageWorkflowPaths: await loadPackageWorkflowPaths() });
|
|
213
|
-
discoveryRef.current = result;
|
|
214
201
|
const effectiveConfig = withWorkflowDefaults(configResult.config ?? {});
|
|
215
202
|
runtimeConfigRef.current = {
|
|
216
203
|
maxDepth: effectiveConfig.maxDepth,
|
|
@@ -224,8 +211,11 @@ export function createWorkflowExtensionRuntimeState(
|
|
|
224
211
|
statusWriterRef.unsubscribe();
|
|
225
212
|
statusWriterRef = createStatusWriter(store, runtimeConfigRef.current);
|
|
226
213
|
persistenceRef.current = makePersistencePort(pi, effectiveConfig.persistRuns);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function rebuildRuntime(registry = runtimeRef.current.registry): void {
|
|
227
217
|
runtimeRef.current = createExtensionRuntime({
|
|
228
|
-
registry
|
|
218
|
+
registry,
|
|
229
219
|
cwd: process.cwd(),
|
|
230
220
|
adapters,
|
|
231
221
|
cancellation: cancellationRegistry,
|
|
@@ -237,23 +227,143 @@ export function createWorkflowExtensionRuntimeState(
|
|
|
237
227
|
});
|
|
238
228
|
}
|
|
239
229
|
|
|
230
|
+
function isWorkflowDiscoveryCurrent(generation: number): boolean {
|
|
231
|
+
return generation === workflowDiscoveryGeneration;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function resetWorkflowDiscoveryForSession(): void {
|
|
235
|
+
workflowDiscoveryGeneration += 1;
|
|
236
|
+
discoveryRef.current = null;
|
|
237
|
+
lazyDiscoveryPromise = null;
|
|
238
|
+
workflowReloadQueue = Promise.resolve();
|
|
239
|
+
rebuildRuntime(startupDiscovery.registry);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function ensureWorkflowConfigLoaded(): Promise<void> {
|
|
243
|
+
const generation = workflowDiscoveryGeneration;
|
|
244
|
+
const configResult = await loadWorkflowConfig();
|
|
245
|
+
if (!isWorkflowDiscoveryCurrent(generation)) return;
|
|
246
|
+
applyWorkflowConfig(configResult);
|
|
247
|
+
rebuildRuntime();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function queueWorkflowResourceReload(options: { allowInFlight?: boolean } | undefined, generation: number): Promise<void> {
|
|
251
|
+
const reload = workflowReloadQueue.then(() => reloadWorkflowResourcesNow(options, generation));
|
|
252
|
+
workflowReloadQueue = reload.catch(() => {});
|
|
253
|
+
return reload;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function trackLazyDiscovery(pending: Promise<void>): Promise<void> {
|
|
257
|
+
lazyDiscoveryPromise = pending;
|
|
258
|
+
void pending.finally(() => {
|
|
259
|
+
if (lazyDiscoveryPromise === pending) lazyDiscoveryPromise = null;
|
|
260
|
+
}).catch(() => {});
|
|
261
|
+
return pending;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function reloadWorkflowResources(options?: { allowInFlight?: boolean }): Promise<void> {
|
|
265
|
+
const generation = workflowDiscoveryGeneration;
|
|
266
|
+
return trackLazyDiscovery(queueWorkflowResourceReload(options, generation));
|
|
267
|
+
}
|
|
268
|
+
async function loadPackageWorkflowPaths(): Promise<string[]> {
|
|
269
|
+
const packageResources = (await pi.refreshWorkflowResources?.()) ?? pi.getWorkflowResources?.() ?? [];
|
|
270
|
+
return packageResources.filter((resource) => resource.enabled !== false).map((resource) => resource.path);
|
|
271
|
+
}
|
|
272
|
+
async function reloadWorkflowResourcesNow(options: { allowInFlight?: boolean } | undefined, generation: number): Promise<void> {
|
|
273
|
+
const activeRuns = inFlightRunCount();
|
|
274
|
+
if (options?.allowInFlight !== true && activeRuns > 0) {
|
|
275
|
+
throw new WorkflowReloadBlockedError(reloadBlockedMessage(activeRuns));
|
|
276
|
+
}
|
|
277
|
+
if (options?.allowInFlight === true && activeRuns > 0 && process.env.ATOMIC_WORKFLOW_DEBUG === "1") {
|
|
278
|
+
console.warn(`Workflow reload bypassed in-flight guard with ${activeRuns} active run(s).`);
|
|
279
|
+
}
|
|
280
|
+
const configResult = await loadWorkflowConfig();
|
|
281
|
+
if (!isWorkflowDiscoveryCurrent(generation)) return;
|
|
282
|
+
applyWorkflowConfig(configResult);
|
|
283
|
+
const hasGlobal = configResult.globalConfig != null;
|
|
284
|
+
const hasProject = configResult.projectConfig != null;
|
|
285
|
+
const discoveryConfig = hasGlobal || hasProject
|
|
286
|
+
? toScopedDiscoveryConfig(configResult.globalConfig ?? null, configResult.projectConfig ?? null, { projectRoot: process.cwd() })
|
|
287
|
+
: undefined;
|
|
288
|
+
const packageWorkflowPaths = await loadPackageWorkflowPaths();
|
|
289
|
+
if (!isWorkflowDiscoveryCurrent(generation)) return;
|
|
290
|
+
const result = await discoverWorkflows({ config: discoveryConfig, packageWorkflowPaths });
|
|
291
|
+
if (!isWorkflowDiscoveryCurrent(generation)) return;
|
|
292
|
+
discoveryRef.current = result;
|
|
293
|
+
rebuildRuntime(result.registry);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async function ensureWorkflowResourcesLoaded(options?: { allowInFlight?: boolean }): Promise<void> {
|
|
297
|
+
while (!pi.disableAsyncDiscovery && discoveryRef.current === null) {
|
|
298
|
+
const generation = workflowDiscoveryGeneration;
|
|
299
|
+
const pending = lazyDiscoveryPromise ?? trackLazyDiscovery(
|
|
300
|
+
queueWorkflowResourceReload({ allowInFlight: options?.allowInFlight ?? true }, generation),
|
|
301
|
+
);
|
|
302
|
+
await pending;
|
|
303
|
+
if (!isWorkflowDiscoveryCurrent(generation)) continue;
|
|
304
|
+
if (discoveryRef.current === null) {
|
|
305
|
+
lazyDiscoveryPromise = null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function startWorkflowDiscoveryWarmup(onSettled?: () => void): void {
|
|
311
|
+
if (pi.disableAsyncDiscovery || discoveryRef.current !== null || lazyDiscoveryPromise !== null) return;
|
|
312
|
+
const notificationStart = notificationGeneration;
|
|
313
|
+
const discoveryStart = workflowDiscoveryGeneration;
|
|
314
|
+
const pending = (async () => {
|
|
315
|
+
await deferToMacrotask();
|
|
316
|
+
if (!isWorkflowDiscoveryCurrent(discoveryStart)) return;
|
|
317
|
+
await queueWorkflowResourceReload({ allowInFlight: true }, discoveryStart);
|
|
318
|
+
})();
|
|
319
|
+
lazyDiscoveryPromise = pending;
|
|
320
|
+
const isCurrentWarmup = (): boolean => lazyDiscoveryPromise === pending
|
|
321
|
+
&& notificationGeneration === notificationStart
|
|
322
|
+
&& isWorkflowDiscoveryCurrent(discoveryStart);
|
|
323
|
+
void pending
|
|
324
|
+
.catch((error) => {
|
|
325
|
+
if (isCurrentWarmup() && process.env.ATOMIC_WORKFLOW_DEBUG === "1") {
|
|
326
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
327
|
+
console.warn(`Workflow background discovery failed: ${message}`);
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
.finally(() => {
|
|
331
|
+
const current = isCurrentWarmup();
|
|
332
|
+
if (lazyDiscoveryPromise === pending) lazyDiscoveryPromise = null;
|
|
333
|
+
if (!current || !notificationsActive) return;
|
|
334
|
+
try {
|
|
335
|
+
onSettled?.();
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (process.env.ATOMIC_WORKFLOW_DEBUG === "1") {
|
|
338
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
339
|
+
console.warn(`Workflow background discovery callback failed: ${message}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
.catch(() => {});
|
|
344
|
+
}
|
|
345
|
+
|
|
240
346
|
return {
|
|
241
347
|
persistenceRef,
|
|
242
348
|
mcpPort,
|
|
243
349
|
runtimeProxy,
|
|
244
350
|
configLoadRef,
|
|
245
351
|
discoveryRef,
|
|
246
|
-
discoveryPromise: pi.disableAsyncDiscovery ? Promise.resolve() : reloadWorkflowResources({ allowInFlight: true }),
|
|
247
352
|
lifecycleNotificationState,
|
|
248
353
|
hilAnswerNotificationState,
|
|
249
354
|
runtimeForContext,
|
|
355
|
+
resetWorkflowDiscoveryForSession,
|
|
356
|
+
ensureWorkflowConfigLoaded,
|
|
357
|
+
ensureWorkflowResourcesLoaded,
|
|
250
358
|
reloadWorkflowResources,
|
|
359
|
+
startWorkflowDiscoveryWarmup,
|
|
251
360
|
runWithLifecycleSuppressedForPolicy(policy, fn) {
|
|
252
361
|
return policy.mode !== "non_interactive" || policy.awaitTerminalRun !== true
|
|
253
362
|
? fn()
|
|
254
363
|
: withWorkflowLifecycleNotificationsSuppressedAsync(lifecycleNotificationState, fn);
|
|
255
364
|
},
|
|
256
365
|
setNotificationsActive(active) {
|
|
366
|
+
notificationGeneration += 1;
|
|
257
367
|
notificationsActive = active;
|
|
258
368
|
reinstallLifecycleNotifications();
|
|
259
369
|
reinstallHilAnswerNotifications();
|
|
@@ -15,6 +15,13 @@ import type {
|
|
|
15
15
|
StoreSnapshot,
|
|
16
16
|
} from "../shared/store-types.js";
|
|
17
17
|
import { isTopLevelWorkflowRun } from "../shared/run-visibility.js";
|
|
18
|
+
import {
|
|
19
|
+
actionableReturnedStatusText,
|
|
20
|
+
effectiveRunStatus,
|
|
21
|
+
isReturnedBlockedWorkflowStatus,
|
|
22
|
+
normalizeReturnedWorkflowStatus,
|
|
23
|
+
structuredRecoverableWorkflowFailureText,
|
|
24
|
+
} from "../shared/returned-run-status.js";
|
|
18
25
|
import { deriveGraphThemeFromPiTheme, type GraphTheme } from "../tui/graph-theme.js";
|
|
19
26
|
import { renderWorkflowNoticeCard, type WorkflowNoticeTone } from "../tui/workflow-notice-card.js";
|
|
20
27
|
|
|
@@ -299,13 +306,13 @@ function makeTerminalNotice(
|
|
|
299
306
|
const failedStage = run.failedStageId
|
|
300
307
|
? run.stages.find((stage) => stage.id === run.failedStageId)
|
|
301
308
|
: undefined;
|
|
302
|
-
const error = run.error ?? (kind === "blocked" ? run.exitReason : undefined);
|
|
309
|
+
const error = run.error ?? returnedNoticeError(run, kind) ?? (kind === "blocked" ? run.exitReason : undefined);
|
|
303
310
|
return {
|
|
304
311
|
kind,
|
|
305
312
|
scope: "run",
|
|
306
313
|
runId: run.id,
|
|
307
314
|
workflowName: run.name,
|
|
308
|
-
status: run
|
|
315
|
+
status: effectiveRunStatus(run),
|
|
309
316
|
...(error ? { error: truncateSnippet(error) } : {}),
|
|
310
317
|
...(run.failedStageId ? { failedStageId: run.failedStageId } : {}),
|
|
311
318
|
...(failedStage ? { stageId: failedStage.id, stageName: failedStage.name } : {}),
|
|
@@ -330,13 +337,22 @@ function jsonString(value: string): string {
|
|
|
330
337
|
}
|
|
331
338
|
|
|
332
339
|
function terminalNoticeKind(run: RunSnapshot): "completed" | "failed" | "blocked" | undefined {
|
|
333
|
-
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
if (returnedStatus === "failed" || returnedStatus === "blocked") return returnedStatus;
|
|
340
|
+
const status = effectiveRunStatus(run);
|
|
341
|
+
if (status === "failed" || status === "blocked") return status;
|
|
342
|
+
if (status !== "completed") return undefined;
|
|
337
343
|
return "completed";
|
|
338
344
|
}
|
|
339
345
|
|
|
346
|
+
function returnedNoticeError(run: RunSnapshot, kind: "completed" | "failed" | "blocked"): string | undefined {
|
|
347
|
+
const structuredFailureText = structuredRecoverableWorkflowFailureText(run);
|
|
348
|
+
if (kind === "blocked" && structuredFailureText !== undefined) return structuredFailureText;
|
|
349
|
+
const returnedStatus = normalizeReturnedWorkflowStatus(run.result?.["status"]);
|
|
350
|
+
if (returnedStatus === undefined) return undefined;
|
|
351
|
+
if (kind === "failed" && returnedStatus === "failed") return actionableReturnedStatusText(run.result);
|
|
352
|
+
if (kind === "blocked" && isReturnedBlockedWorkflowStatus(returnedStatus)) return actionableReturnedStatusText(run.result);
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
|
|
340
356
|
function terminalRunKey(kind: "completed" | "failed" | "blocked", runId: string): string {
|
|
341
357
|
return `${kind}:${runId}`;
|
|
342
358
|
}
|
|
@@ -61,7 +61,7 @@ export type PiArgumentCompletionResult = PiArgumentCompletion[] | null;
|
|
|
61
61
|
export interface PiCommandOptions {
|
|
62
62
|
description: string;
|
|
63
63
|
handler: (args: string, ctx: PiCommandContext) => Promise<void> | void;
|
|
64
|
-
getArgumentCompletions?: (partial: string) => PiArgumentCompletionResult
|
|
64
|
+
getArgumentCompletions?: (partial: string) => PiArgumentCompletionResult | Promise<PiArgumentCompletionResult>;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface PiRuntimeModel {
|
|
@@ -13,8 +13,9 @@ function completeToken(
|
|
|
13
13
|
: Math.max(argumentText.lastIndexOf(" "), argumentText.lastIndexOf("\t")) + 1;
|
|
14
14
|
const head = argumentText.slice(0, tokenStart);
|
|
15
15
|
const token = argumentText.slice(tokenStart);
|
|
16
|
+
const normalizedToken = token.trimEnd();
|
|
16
17
|
const filtered = candidates
|
|
17
|
-
.filter((candidate) => candidate.value.startsWith(token))
|
|
18
|
+
.filter((candidate) => candidate.value.startsWith(token) && candidate.value.trimEnd() !== normalizedToken)
|
|
18
19
|
.map((candidate) => ({ ...candidate, value: `${head}${candidate.value}` }));
|
|
19
20
|
return filtered.length > 0 ? filtered : null;
|
|
20
21
|
}
|
|
@@ -50,6 +51,17 @@ function runIdItems(): PiArgumentCompletion[] {
|
|
|
50
51
|
}));
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
export function workflowArgumentCompletionsNeedWorkflowResources(partial: string): boolean {
|
|
55
|
+
const parts = partial.trim().split(/\s+/).filter(Boolean);
|
|
56
|
+
const subcommand = parts[0] ?? "";
|
|
57
|
+
if (!partial.includes(" ")) return true;
|
|
58
|
+
if (!subcommand || subcommand === "inputs") return true;
|
|
59
|
+
if (["status", "connect", "resume", "attach", "pause", "interrupt", "kill", "reload"].includes(subcommand)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
export function workflowArgumentCompletions(
|
|
54
66
|
partial: string,
|
|
55
67
|
runtime: ExtensionRuntime,
|