@bastani/atomic 0.9.20-alpha.1 → 0.9.20-alpha.11
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 +318 -0
- package/README.md +52 -7
- package/dist/builtin/intercom/CHANGELOG.md +34 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.ts +110 -39
- package/dist/builtin/intercom/broker/client.ts +8 -1
- package/dist/builtin/intercom/broker/send-handler.ts +59 -2
- package/dist/builtin/intercom/index.bundle.mjs +162 -18
- package/dist/builtin/intercom/live-route-refusal.ts +69 -0
- package/dist/builtin/intercom/package.json +3 -5
- package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
- package/dist/builtin/intercom/session-target.ts +34 -9
- package/dist/builtin/intercom/skills/intercom/SKILL.md +47 -16
- package/dist/builtin/intercom/types.ts +3 -1
- package/dist/builtin/mcp/CHANGELOG.md +13 -0
- package/dist/builtin/mcp/OAUTH.md +1 -1
- package/dist/builtin/mcp/README.md +3 -1
- package/dist/builtin/mcp/index.bundle.mjs +412 -64
- package/dist/builtin/mcp/package.json +4 -4
- package/dist/builtin/subagents/CHANGELOG.md +69 -0
- package/dist/builtin/subagents/README.md +4 -2
- package/dist/builtin/subagents/agents/code-simplifier.md +3 -4
- package/dist/builtin/subagents/agents/codebase-analyzer.md +3 -4
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -3
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +5 -6
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -3
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -3
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -3
- package/dist/builtin/subagents/agents/debugger.md +8 -7
- package/dist/builtin/subagents/agents/worker.md +5 -4
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
- package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
- package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
- package/dist/builtin/subagents/skills/feedback/SKILL.md +49 -0
- package/dist/builtin/subagents/skills/feedback/scripts/scrub.mjs +498 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +45 -19
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +276 -68
- package/dist/builtin/web-access/CHANGELOG.md +18 -0
- package/dist/builtin/web-access/index.bundle.mjs +372 -300
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +180 -0
- package/dist/builtin/workflows/README.md +20 -33
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-g0csgs7w.js → chunk-18yz7r43.js} +8 -10
- package/dist/builtin/workflows/builtin/{chunk-31j2gs7h.js → chunk-1pd5zcfa.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-ewkkkbak.js → chunk-1q7hfqzd.js} +40 -111
- package/dist/builtin/workflows/builtin/{chunk-xtxcq5tj.js → chunk-24c235x7.js} +17 -1
- package/dist/builtin/workflows/builtin/{chunk-6w6cvk6b.js → chunk-2jv44yz7.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-yeee2jrc.js → chunk-2npg6daz.js} +76 -90
- package/dist/builtin/workflows/builtin/chunk-73c5tayt.js +10699 -0
- package/dist/builtin/workflows/builtin/{chunk-z29qbehr.js → chunk-7ps7bnb4.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-fg9esgkj.js → chunk-f8jjd90r.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-a2kdsqn8.js → chunk-gxrhbnaj.js} +5 -3
- package/dist/builtin/workflows/builtin/{chunk-zqtm1d2c.js → chunk-s2zgzs4j.js} +13 -218
- package/dist/builtin/workflows/builtin/{chunk-wf741bv3.js → chunk-z5xdqrs6.js} +4 -6
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +4 -4
- package/dist/builtin/workflows/builtin/index.d.ts +1 -1
- package/dist/builtin/workflows/builtin/index.js +12 -12
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +4 -4
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +4 -4
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
- package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +10 -9
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +96 -23
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +75 -27
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +72 -26
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +58 -22
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +118 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +70 -29
- package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +1 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +95 -32
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +79 -30
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +139 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -4
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +6 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +26549 -22500
- package/dist/builtin/workflows/src/index.js +43097 -6424
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +11 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +17 -1
- package/dist/bun/split-loader.js +13 -0
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +17 -6
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +2 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +49 -14
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +3 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +27 -14
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +68 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -0
- package/dist/core/agent-session-boundaries.js +339 -0
- package/dist/core/agent-session-boundaries.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +38 -15
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +6 -6
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +175 -74
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +34 -39
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +3 -2
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +274 -70
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +36 -7
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +55 -15
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +38 -29
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -1
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +18 -1
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +186 -36
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts +2 -0
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +15 -3
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +0 -3
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +28 -20
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
- package/dist/core/agent-session-runtime-auth.js +10 -0
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +21 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +434 -197
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +4 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +31 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +10 -2
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +32 -22
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +9 -2
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts +10 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +94 -21
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +41 -8
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +13 -26
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +8 -3
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +13 -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 +36 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +137 -68
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -3
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +18 -5
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-diagnostics.d.ts +2 -0
- package/dist/core/builtin-diagnostics.d.ts.map +1 -0
- package/dist/core/builtin-diagnostics.js +14 -0
- package/dist/core/builtin-diagnostics.js.map +1 -0
- package/dist/core/builtin-packages.d.ts +5 -2
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +24 -3
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts +4 -0
- package/dist/core/builtin-resource-loader.d.ts.map +1 -0
- package/dist/core/builtin-resource-loader.js +239 -0
- package/dist/core/builtin-resource-loader.js.map +1 -0
- package/dist/core/cache-retention.d.ts +4 -0
- package/dist/core/cache-retention.d.ts.map +1 -0
- package/dist/core/cache-retention.js +58 -0
- package/dist/core/cache-retention.js.map +1 -0
- package/dist/core/cache-stats.d.ts +7 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +34 -4
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +66 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +313 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/child-session-options.d.ts +5 -0
- package/dist/core/child-session-options.d.ts.map +1 -0
- package/dist/core/child-session-options.js +30 -0
- package/dist/core/child-session-options.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +29 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +48 -10
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +18 -5
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +7 -0
- 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 +3 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +55 -0
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/fallback-planner.d.ts +1 -0
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
- package/dist/core/compaction/fallback-planner.js +2 -0
- package/dist/core/compaction/fallback-planner.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.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +3 -3
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/session-summarization.d.ts.map +1 -1
- package/dist/core/compaction/session-summarization.js +2 -1
- package/dist/core/compaction/session-summarization.js.map +1 -1
- package/dist/core/compaction/whole-context-stats.d.ts +21 -0
- package/dist/core/compaction/whole-context-stats.d.ts.map +1 -0
- package/dist/core/compaction/whole-context-stats.js +32 -0
- package/dist/core/compaction/whole-context-stats.js.map +1 -0
- package/dist/core/crash-log.d.ts +6 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +69 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/credential-screening.d.ts +17 -0
- package/dist/core/credential-screening.d.ts.map +1 -0
- package/dist/core/credential-screening.js +30 -0
- package/dist/core/credential-screening.js.map +1 -0
- package/dist/core/execution-model-router.d.ts +45 -0
- package/dist/core/execution-model-router.d.ts.map +1 -0
- package/dist/core/execution-model-router.js +249 -0
- package/dist/core/execution-model-router.js.map +1 -0
- package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
- package/dist/core/export-html/template.js +6 -1
- package/dist/core/extensions/agent-events.d.ts +82 -8
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +51 -42
- 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 +7 -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/event-results.d.ts +10 -6
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +3 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/extension-work.d.ts +14 -0
- package/dist/core/extensions/extension-work.d.ts.map +1 -0
- package/dist/core/extensions/extension-work.js +73 -0
- package/dist/core/extensions/extension-work.js.map +1 -0
- package/dist/core/extensions/herdr-file-integration.d.ts +36 -0
- package/dist/core/extensions/herdr-file-integration.d.ts.map +1 -0
- package/dist/core/extensions/herdr-file-integration.js +60 -0
- package/dist/core/extensions/herdr-file-integration.js.map +1 -0
- package/dist/core/extensions/host-input.d.ts +51 -0
- package/dist/core/extensions/host-input.d.ts.map +1 -0
- package/dist/core/extensions/host-input.js +211 -0
- package/dist/core/extensions/host-input.js.map +1 -0
- package/dist/core/extensions/index.d.ts +4 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +0 -3
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +3 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +3 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts +7 -0
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +154 -28
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.d.ts +24 -0
- package/dist/core/extensions/loader-bindings.d.ts.map +1 -0
- package/dist/core/extensions/loader-bindings.js +128 -0
- package/dist/core/extensions/loader-bindings.js.map +1 -0
- package/dist/core/extensions/loader-core.d.ts +2 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +92 -14
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts +14 -0
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -0
- package/dist/core/extensions/loader-rollback.js +95 -0
- package/dist/core/extensions/loader-rollback.js.map +1 -0
- package/dist/core/extensions/loader-runtime.d.ts +3 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +38 -14
- package/dist/core/extensions/loader-runtime.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 -2
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +34 -14
- 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/reactive-widget.d.ts +1 -1
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +4 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +25 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +24 -6
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +153 -58
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
- package/dist/core/extensions/runner-project-trust.js +2 -4
- package/dist/core/extensions/runner-project-trust.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +34 -6
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +223 -24
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +6 -0
- 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/tool-types.d.ts +9 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +0 -12
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +2 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +5 -3
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +5 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts +3 -3
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +4 -3
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +30 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +43 -1
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts +4 -0
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +29 -1
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/mandatory-runtime-tools.d.ts +1 -4
- package/dist/core/mandatory-runtime-tools.d.ts.map +1 -1
- package/dist/core/mandatory-runtime-tools.js +1 -9
- package/dist/core/mandatory-runtime-tools.js.map +1 -1
- package/dist/core/messages.d.ts +10 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +76 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +178 -10
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -19
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +12 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-routing-constraints.d.ts +24 -0
- package/dist/core/model-routing-constraints.d.ts.map +1 -0
- package/dist/core/model-routing-constraints.js +46 -0
- package/dist/core/model-routing-constraints.js.map +1 -0
- package/dist/core/model-routing-task.d.ts +4 -0
- package/dist/core/model-routing-task.d.ts.map +1 -0
- package/dist/core/model-routing-task.js +77 -0
- package/dist/core/model-routing-task.js.map +1 -0
- package/dist/core/model-runtime-auth.d.ts +2 -2
- package/dist/core/model-runtime-auth.d.ts.map +1 -1
- package/dist/core/model-runtime-auth.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +13 -3
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +16 -5
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime-types.d.ts +2 -2
- package/dist/core/model-runtime-types.d.ts.map +1 -1
- package/dist/core/model-runtime-types.js.map +1 -1
- package/dist/core/model-runtime.d.ts +29 -6
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +84 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +32 -8
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/package-manager-resolver.js +3 -1
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +1 -0
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +2 -2
- package/dist/core/prompt-templates-async.d.ts.map +1 -1
- package/dist/core/prompt-templates-async.js +57 -29
- package/dist/core/prompt-templates-async.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +41 -20
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +43 -20
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -3
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +54 -10
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +8 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +46 -4
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +2 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +23 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +6 -6
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +6 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +41 -6
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
- package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
- package/dist/core/resource-loader-extension-warnings.js +54 -0
- package/dist/core/resource-loader-extension-warnings.js.map +1 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +3 -0
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +13 -2
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader.d.ts +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +2 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +18 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +18 -5
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +231 -42
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-scope.d.ts +15 -0
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -0
- package/dist/core/session-lifecycle-scope.js +13 -0
- package/dist/core/session-lifecycle-scope.js.map +1 -0
- package/dist/core/session-lifecycle-work.d.ts +17 -0
- package/dist/core/session-lifecycle-work.d.ts.map +1 -0
- package/dist/core/session-lifecycle-work.js +144 -0
- package/dist/core/session-lifecycle-work.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +19 -6
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +117 -12
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +4 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +8 -0
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +16 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +106 -40
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts +3 -3
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +89 -74
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +10 -7
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +41 -4
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-startup-rollback.d.ts +5 -0
- package/dist/core/session-startup-rollback.d.ts.map +1 -0
- package/dist/core/session-startup-rollback.js +16 -0
- package/dist/core/session-startup-rollback.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts +5 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +35 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +4 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +4 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/settings-write-ownership.d.ts +7 -0
- package/dist/core/settings-write-ownership.d.ts.map +1 -0
- package/dist/core/settings-write-ownership.js +24 -0
- package/dist/core/settings-write-ownership.js.map +1 -0
- package/dist/core/skill-catalog.d.ts.map +1 -1
- package/dist/core/skill-catalog.js +18 -6
- package/dist/core/skill-catalog.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/structured-output/choice-schema.d.ts +8 -0
- package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
- package/dist/core/structured-output/choice-schema.js +79 -0
- package/dist/core/structured-output/choice-schema.js.map +1 -0
- package/dist/core/structured-output/index.d.ts +10 -0
- package/dist/core/structured-output/index.d.ts.map +1 -0
- package/dist/core/structured-output/index.js +424 -0
- package/dist/core/structured-output/index.js.map +1 -0
- package/dist/core/structured-output/invalid-output.d.ts +8 -0
- package/dist/core/structured-output/invalid-output.d.ts.map +1 -0
- package/dist/core/structured-output/invalid-output.js +4 -0
- package/dist/core/structured-output/invalid-output.js.map +1 -0
- package/dist/core/structured-output/resolver.d.ts +3 -0
- package/dist/core/structured-output/resolver.d.ts.map +1 -0
- package/dist/core/structured-output/resolver.js +26 -0
- package/dist/core/structured-output/resolver.js.map +1 -0
- package/dist/core/structured-output/types.d.ts +76 -0
- package/dist/core/structured-output/types.d.ts.map +1 -0
- package/dist/core/structured-output/types.js +2 -0
- package/dist/core/structured-output/types.js.map +1 -0
- package/dist/core/system-prompt.d.ts +48 -5
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +141 -100
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/child-command-owner.d.ts +34 -0
- package/dist/core/tasks/child-command-owner.d.ts.map +1 -0
- package/dist/core/tasks/child-command-owner.js +70 -0
- package/dist/core/tasks/child-command-owner.js.map +1 -0
- package/dist/core/tasks/contracts.d.ts +6 -0
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/owner-store.d.ts +6 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -1
- package/dist/core/tasks/owner-store.js +16 -3
- package/dist/core/tasks/owner-store.js.map +1 -1
- package/dist/core/tasks/pause.js +1 -1
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +4 -2
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +16 -3
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +4 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +32 -35
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/index.d.ts +1 -1
- package/dist/core/tools/ask-user-question/index.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts +5 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +15 -7
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +32 -24
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.js +45 -38
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/kill.d.ts +2 -2
- package/dist/core/tools/kill.d.ts.map +1 -1
- package/dist/core/tools/kill.js +3 -4
- package/dist/core/tools/kill.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +5 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/structured-output.d.ts +9 -6
- package/dist/core/tools/structured-output.d.ts.map +1 -1
- package/dist/core/tools/structured-output.js +36 -8
- package/dist/core/tools/structured-output.js.map +1 -1
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +1 -0
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts +23 -0
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
- package/dist/core/tools/tool-concurrency.js +58 -0
- package/dist/core/tools/tool-concurrency.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +4 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +0 -7
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +6 -2
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +18 -4
- package/dist/extensions/llama/provider.js.map +1 -1
- 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 +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts +1 -1
- package/dist/main-app-mode.d.ts.map +1 -1
- package/dist/main-app-mode.js +3 -2
- package/dist/main-app-mode.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +24 -16
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +3 -2
- package/dist/modes/interactive/components/atomic-banner.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 +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +5 -1
- 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 +2 -2
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +30 -12
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +6 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +17 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.d.ts +1 -1
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
- package/dist/modes/interactive/components/scroll-widget.d.ts +1 -1
- package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +52 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +2 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +8 -2
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
- package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
- package/dist/modes/interactive/components/startup-identity.js +11 -2
- package/dist/modes/interactive/components/startup-identity.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +11 -11
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.d.ts +9 -3
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-list.js +26 -2
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +14 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +6 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.js +1 -0
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +20 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +3 -5
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +2 -2
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +4 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +13 -6
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +5 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +2 -2
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
- 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-process-lifecycle.js +13 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +30 -34
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +11 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +5 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +2 -2
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +3 -6
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +15 -5
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
- package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
- package/dist/modes/interactive/overlay-line-composite.js +24 -0
- package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +3 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-input-form.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +16 -0
- package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.js +27 -0
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +19 -2
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +1 -1
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +7 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +3 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +3 -2
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +2 -2
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/session-id-target.d.ts +31 -0
- package/dist/session-id-target.d.ts.map +1 -0
- package/dist/session-id-target.js +57 -0
- package/dist/session-id-target.js.map +1 -0
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +29 -4
- package/dist/utils/abort.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -0
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +7 -8
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +15 -29
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +88 -12
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +18 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +3 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js +4 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/docs/background-tasks.md +36 -16
- package/docs/build.md +6 -16
- package/docs/compaction/reference.md +12 -12
- package/docs/compaction.md +33 -109
- package/docs/computer-use.md +124 -76
- package/docs/containerization.md +4 -5
- package/docs/custom-provider/api-reference.md +10 -1
- package/docs/custom-provider/oauth.md +4 -2
- package/docs/custom-provider/registration.md +1 -1
- package/docs/custom-provider/streaming.md +8 -3
- package/docs/custom-provider.md +44 -2
- package/docs/development.md +13 -138
- package/docs/docs.json +19 -4
- package/docs/environment-variables.md +21 -5
- package/docs/extensions/api-reference.md +6 -2
- package/docs/extensions/authoring.md +29 -7
- package/docs/extensions/events.md +107 -31
- package/docs/extensions/examples.md +1 -0
- package/docs/extensions/ui.md +3 -4
- package/docs/extensions.md +28 -20
- package/docs/getting-started/authentication.md +4 -1
- package/docs/getting-started/first-session.md +11 -8
- package/docs/getting-started/installation.md +14 -6
- package/docs/getting-started/project-instructions.md +5 -1
- package/docs/guides/configuration.md +10 -5
- package/docs/guides/non-interactive.md +2 -2
- package/docs/guides.md +8 -17
- package/docs/herdr.md +2 -1
- package/docs/index.md +2 -2
- package/docs/intercom/operations.md +25 -67
- package/docs/intercom/reference.md +15 -5
- package/docs/intercom.md +16 -7
- package/docs/json.md +12 -2
- package/docs/keybindings.md +15 -8
- package/docs/llama-cpp.md +6 -2
- package/docs/mcp-servers.md +93 -0
- package/docs/models/evals.md +75 -465
- package/docs/models/model-selection.md +35 -116
- package/docs/models/reference.md +70 -24
- package/docs/models.md +7 -4
- package/docs/packages/authoring.md +8 -2
- package/docs/packages/reference.md +5 -1
- package/docs/packages.md +7 -3
- package/docs/programmatic.md +3 -1
- package/docs/prompt-templates.md +3 -2
- package/docs/providers/reference.md +2 -2
- package/docs/providers.md +55 -18
- package/docs/quickstart.md +8 -4
- package/docs/reference/cli.md +21 -13
- package/docs/reference.md +3 -6
- package/docs/rpc/examples.md +2 -0
- package/docs/rpc/protocol.md +11 -13
- package/docs/rpc.md +5 -1
- package/docs/sdk/reference.md +62 -267
- package/docs/sdk/structured-decisions.md +94 -0
- package/docs/sdk.md +194 -19
- package/docs/security.md +7 -4
- package/docs/session-format.md +35 -7
- package/docs/sessions.md +12 -6
- package/docs/settings.md +68 -16
- package/docs/skills/authoring.md +7 -1
- package/docs/skills.md +33 -8
- package/docs/subagents/authoring.md +11 -1
- package/docs/subagents/reference.md +97 -10
- package/docs/subagents.md +52 -36
- package/docs/terminal-setup.md +4 -2
- package/docs/termux.md +3 -1
- package/docs/themes/reference.md +4 -1
- package/docs/themes.md +1 -1
- package/docs/tools.md +431 -20
- package/docs/tui/reference.md +13 -14
- package/docs/tui.md +10 -6
- package/docs/usage.md +34 -7
- package/docs/web-access.md +5 -1
- package/docs/windows.md +18 -11
- package/docs/workflows/api-reference.md +112 -27
- package/docs/workflows/authoring.md +345 -33
- package/docs/workflows/builtins.md +22 -28
- package/docs/workflows/operations.md +255 -140
- package/docs/workflows/reliable-design.md +59 -130
- package/docs/workflows/verification.md +40 -14
- package/docs/workflows.md +12 -17
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +15 -10
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/prompt-customizer.ts +17 -37
- package/examples/extensions/structured-output.ts +6 -0
- package/examples/rpc-client.ts +38 -0
- package/examples/rpc-extension-ui.ts +19 -5
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +506 -713
- package/package.json +13 -11
- package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
- package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
- package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
- package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
- package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
- package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
- package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
- package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
- package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
- package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
- package/dist/builtin/workflows/builtin/chunk-m0xfsef8.js +0 -2813
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
- package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
- package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
- package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
- package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
- package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
- package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
- package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
- package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
- package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
- package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
- package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
- package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
- package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
- package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
- package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
- package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
- package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
- package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
- package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
- package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
- package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
- package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
- package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
- package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
- package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +0 -58
- package/docs/models/artificial-analysis-index.md +0 -89
- package/docs/models/pareto-efficiency.md +0 -90
- package/docs/tools/edit.md +0 -378
|
@@ -1,2813 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
VERIFICATION_SCALE
|
|
3
|
-
} from "./chunk-n1910xc4.js";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_RISE_DELTA,
|
|
6
|
-
DEFAULT_FALL_DELTA,
|
|
7
|
-
classify_trend
|
|
8
|
-
} from "./chunk-z0d03ktm.js";
|
|
9
|
-
import {
|
|
10
|
-
scoring_prompt_reads,
|
|
11
|
-
build_scoring_prompt
|
|
12
|
-
} from "./chunk-2377r57g.js";
|
|
13
|
-
|
|
14
|
-
// dist/builtin/workflows/src/shared/workflow-artifacts.ts
|
|
15
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
16
|
-
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
17
|
-
import { dirname, join } from "node:path";
|
|
18
|
-
import { getAgentDir, getEnvValue } from "@bastani/atomic";
|
|
19
|
-
// dist/builtin/workflows/src/durable/backend-process-owner.ts
|
|
20
|
-
var DURABLE_BACKEND_PROCESS_OWNER_KEY = Symbol.for("atomic-workflows/durable-backend-process-owner@1");
|
|
21
|
-
function emptyOwner() {
|
|
22
|
-
return {
|
|
23
|
-
version: 1,
|
|
24
|
-
injectedBackend: undefined,
|
|
25
|
-
initializedBackend: undefined,
|
|
26
|
-
initializing: undefined,
|
|
27
|
-
warningSink: undefined,
|
|
28
|
-
warningReported: false
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function ownerBag() {
|
|
32
|
-
return globalThis;
|
|
33
|
-
}
|
|
34
|
-
function getDurableBackendProcessOwner() {
|
|
35
|
-
const bag = ownerBag();
|
|
36
|
-
const existing = bag[DURABLE_BACKEND_PROCESS_OWNER_KEY];
|
|
37
|
-
if (existing !== undefined && existing.version === 1)
|
|
38
|
-
return existing;
|
|
39
|
-
const created = emptyOwner();
|
|
40
|
-
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
41
|
-
return created;
|
|
42
|
-
}
|
|
43
|
-
// dist/builtin/workflows/src/shared/possible-stages.ts
|
|
44
|
-
var BUILTIN_BARREL_SPECIFIERS = new Set([
|
|
45
|
-
"@bastani/atomic/workflows/builtin",
|
|
46
|
-
"@bastani/workflows/builtin"
|
|
47
|
-
]);
|
|
48
|
-
var TRACKED_NODE_METHODS = new Set(["stage", "task", "chain", "parallel", "workflow", "tool"]);
|
|
49
|
-
|
|
50
|
-
// dist/builtin/workflows/src/shared/workflow-failures-contract.ts
|
|
51
|
-
var WORKFLOW_FAILURE_KINDS = new Set([
|
|
52
|
-
"auth",
|
|
53
|
-
"rate_limit",
|
|
54
|
-
"provider",
|
|
55
|
-
"cancelled",
|
|
56
|
-
"unknown"
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
// dist/builtin/workflows/src/shared/workflow-failures-decisions.ts
|
|
60
|
-
var INVALID_API_KEY_CODES = new Set([
|
|
61
|
-
"401",
|
|
62
|
-
"invalid_api_key",
|
|
63
|
-
"incorrect_api_key",
|
|
64
|
-
"invalid_api_key_error",
|
|
65
|
-
"invalid_credentials",
|
|
66
|
-
"bad_credentials",
|
|
67
|
-
"authentication_error"
|
|
68
|
-
]);
|
|
69
|
-
var LOGIN_REQUIRED_CODES = new Set([
|
|
70
|
-
"auth",
|
|
71
|
-
"auth_required",
|
|
72
|
-
"authentication_required",
|
|
73
|
-
"login_required",
|
|
74
|
-
"not_logged_in"
|
|
75
|
-
]);
|
|
76
|
-
var MISSING_API_KEY_CODES = new Set(["missing_api_key", "api_key_missing", "no_api_key"]);
|
|
77
|
-
var RATE_LIMIT_CODES = new Set(["429", "rate_limit", "rate_limited", "rate_limit_exceeded", "too_many_requests"]);
|
|
78
|
-
var QUOTA_LIMIT_CODES = new Set([
|
|
79
|
-
"quota",
|
|
80
|
-
"quota_exceeded",
|
|
81
|
-
"insufficient_quota",
|
|
82
|
-
"usage_limit",
|
|
83
|
-
"usage_limit_exceeded"
|
|
84
|
-
]);
|
|
85
|
-
var CANCELLED_CODES = new Set(["aborterror", "aborted", "cancelled", "canceled"]);
|
|
86
|
-
var PROVIDER_UNAVAILABLE_CODES = new Set([
|
|
87
|
-
"500",
|
|
88
|
-
"502",
|
|
89
|
-
"503",
|
|
90
|
-
"504",
|
|
91
|
-
"provider_error",
|
|
92
|
-
"service_unavailable",
|
|
93
|
-
"temporarily_unavailable",
|
|
94
|
-
"overloaded",
|
|
95
|
-
"timeout",
|
|
96
|
-
"network_error"
|
|
97
|
-
]);
|
|
98
|
-
var UNKNOWN_MODEL_CODES = new Set(["unknown_model", "model_not_found", "model_not_available", "unsupported_model"]);
|
|
99
|
-
var FORBIDDEN_CONFIG_CODES = new Set([
|
|
100
|
-
"403",
|
|
101
|
-
"forbidden",
|
|
102
|
-
"permission_denied",
|
|
103
|
-
"access_denied",
|
|
104
|
-
"forbidden_config",
|
|
105
|
-
"invalid_model_config",
|
|
106
|
-
"model_access_denied"
|
|
107
|
-
]);
|
|
108
|
-
var INVALID_API_KEY_CONTEXT = new Set(["invalid", "incorrect"]);
|
|
109
|
-
var AUTH_CONTEXT = new Set([
|
|
110
|
-
"token",
|
|
111
|
-
"credential",
|
|
112
|
-
"credentials",
|
|
113
|
-
"required",
|
|
114
|
-
"expired",
|
|
115
|
-
"invalid",
|
|
116
|
-
"missing",
|
|
117
|
-
"unauthorized",
|
|
118
|
-
"login",
|
|
119
|
-
"signin"
|
|
120
|
-
]);
|
|
121
|
-
var MODEL_PROVIDER_CONTEXT = new Set(["unavailable", "overloaded", "temporarily", "service"]);
|
|
122
|
-
var PROVIDER_CONTEXT = new Set(["error", "failure", "failed", "overloaded", "unavailable", "temporarily", "service"]);
|
|
123
|
-
var STATUS_MESSAGE_REFINEMENT_CODES = new Set([
|
|
124
|
-
"invalid_api_key",
|
|
125
|
-
"missing_api_key",
|
|
126
|
-
"unknown_model",
|
|
127
|
-
"forbidden_config"
|
|
128
|
-
]);
|
|
129
|
-
var BROAD_AUTH_MESSAGE_REFINEMENT_CODES = new Set([
|
|
130
|
-
"invalid_api_key",
|
|
131
|
-
"missing_api_key"
|
|
132
|
-
]);
|
|
133
|
-
var STATUS_RELATED_MESSAGE_REFINEMENT_CODES = new Set([
|
|
134
|
-
"invalid_api_key",
|
|
135
|
-
"missing_api_key",
|
|
136
|
-
"unknown_model",
|
|
137
|
-
"forbidden_config",
|
|
138
|
-
"rate_limited",
|
|
139
|
-
"quota_limited",
|
|
140
|
-
"cancelled"
|
|
141
|
-
]);
|
|
142
|
-
// dist/builtin/workflows/src/durable/dbos-process-owner.ts
|
|
143
|
-
var DBOS_PROCESS_OWNER_KEY = Symbol.for("atomic-workflows/dbos-process-owner@1");
|
|
144
|
-
function emptyOwner2() {
|
|
145
|
-
return {
|
|
146
|
-
version: 1,
|
|
147
|
-
state: "uninitialized",
|
|
148
|
-
configured: undefined,
|
|
149
|
-
active: undefined,
|
|
150
|
-
launchPromise: undefined,
|
|
151
|
-
shutdownPromise: undefined,
|
|
152
|
-
failure: undefined,
|
|
153
|
-
wrappers: undefined
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function ownerBag2() {
|
|
157
|
-
return globalThis;
|
|
158
|
-
}
|
|
159
|
-
function getDbosProcessOwner() {
|
|
160
|
-
const bag = ownerBag2();
|
|
161
|
-
const existing = bag[DBOS_PROCESS_OWNER_KEY];
|
|
162
|
-
if (existing !== undefined && existing.version === 1)
|
|
163
|
-
return existing;
|
|
164
|
-
const created = emptyOwner2();
|
|
165
|
-
bag[DBOS_PROCESS_OWNER_KEY] = created;
|
|
166
|
-
return created;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// dist/builtin/workflows/src/durable/dbos-sdk-handle.ts
|
|
170
|
-
var ATOMIC_EXECUTOR_ID = `atomic-${process.pid.toString(36)}-${crypto.randomUUID().slice(0, 8)}`;
|
|
171
|
-
|
|
172
|
-
// dist/builtin/workflows/src/durable/local-command.ts
|
|
173
|
-
import { createChildProcessEnvironment } from "@bastani/atomic";
|
|
174
|
-
|
|
175
|
-
// dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts
|
|
176
|
-
var HASH_CHUNK_BYTES = 64 * 1024;
|
|
177
|
-
|
|
178
|
-
// dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts
|
|
179
|
-
var EMBEDDED_HOST = "127.0.0.1";
|
|
180
|
-
var EMBEDDED_PORT = 5439;
|
|
181
|
-
var EMBEDDED_USER = "postgres";
|
|
182
|
-
var EMBEDDED_PASSWORD = "atomic";
|
|
183
|
-
var EMBEDDED_DBOS_SYSTEM_DATABASE_URL = `postgresql://${EMBEDDED_USER}:${EMBEDDED_PASSWORD}@${EMBEDDED_HOST}:${EMBEDDED_PORT}/atomic_workflows_dbos_sys?connect_timeout=10&sslmode=disable`;
|
|
184
|
-
|
|
185
|
-
// dist/builtin/workflows/src/durable/dbos-lifecycle.ts
|
|
186
|
-
class DbosDurabilityError extends Error {
|
|
187
|
-
constructor(message, options) {
|
|
188
|
-
super(message, options);
|
|
189
|
-
this.name = "DbosDurabilityError";
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
class DbosNotReadyError extends DbosDurabilityError {
|
|
194
|
-
constructor() {
|
|
195
|
-
super("DBOS workflow durability is not ready. Await initializeDurableBackend() before accessing workflows.");
|
|
196
|
-
this.name = "DbosNotReadyError";
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function owner() {
|
|
200
|
-
return getDbosProcessOwner();
|
|
201
|
-
}
|
|
202
|
-
function getReadyDbosBackendSync() {
|
|
203
|
-
const slot = owner();
|
|
204
|
-
return slot.state === "ready" ? slot.active?.backend : undefined;
|
|
205
|
-
}
|
|
206
|
-
function dbosLifecycleState() {
|
|
207
|
-
return owner().state;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// dist/builtin/workflows/src/durable/factory.ts
|
|
211
|
-
function isMemoizedBackendUsable(backend) {
|
|
212
|
-
return !backend.persistent || dbosLifecycleState() === "ready";
|
|
213
|
-
}
|
|
214
|
-
function getDurableBackend() {
|
|
215
|
-
const owner = getDurableBackendProcessOwner();
|
|
216
|
-
const memoized = owner.initializedBackend !== undefined && isMemoizedBackendUsable(owner.initializedBackend) ? owner.initializedBackend : undefined;
|
|
217
|
-
const backend = owner.injectedBackend ?? memoized ?? getReadyDbosBackendSync();
|
|
218
|
-
if (backend === undefined)
|
|
219
|
-
throw new DbosNotReadyError;
|
|
220
|
-
return backend;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// dist/builtin/workflows/src/shared/pending-stage-delivery.ts
|
|
224
|
-
var PENDING_STAGE_MESSAGE_LIMIT = 50;
|
|
225
|
-
var PENDING_STAGE_UNDELIVERABLE_NOTIFICATION_PREFIX = "atomic-pending-stage-undeliverable";
|
|
226
|
-
function queueStageMessage(messages, input, senderGroup, runGroup, stageIdentity) {
|
|
227
|
-
if (normalizeDeliveryGroup(senderGroup) !== normalizeDeliveryGroup(runGroup)) {
|
|
228
|
-
return { ok: false, reason: "group_mismatch", runId: input.runId, stageKey: input.stageKey };
|
|
229
|
-
}
|
|
230
|
-
const messageId = input.message.id;
|
|
231
|
-
const queued = pendingStageMessagesFor(messages, input.runId, input.stageKey, stageIdentity);
|
|
232
|
-
const existing = messages.find((entry) => entry.runId === input.runId && entry.id === messageId);
|
|
233
|
-
if (existing !== undefined) {
|
|
234
|
-
if (pendingStageMessageSignature(existing, stageIdentity) !== pendingStageMessageSignature(input, stageIdentity)) {
|
|
235
|
-
return {
|
|
236
|
-
ok: false,
|
|
237
|
-
reason: "message_id_conflict",
|
|
238
|
-
runId: input.runId,
|
|
239
|
-
stageKey: input.stageKey,
|
|
240
|
-
messageId
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
const queuedPosition = queued.indexOf(existing);
|
|
244
|
-
return {
|
|
245
|
-
ok: true,
|
|
246
|
-
messages,
|
|
247
|
-
entry: existing,
|
|
248
|
-
...queuedPosition >= 0 ? { position: queuedPosition + 1 } : {},
|
|
249
|
-
deduplicated: true
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
if (queued.length >= PENDING_STAGE_MESSAGE_LIMIT) {
|
|
253
|
-
return {
|
|
254
|
-
ok: false,
|
|
255
|
-
reason: "capacity",
|
|
256
|
-
limit: PENDING_STAGE_MESSAGE_LIMIT,
|
|
257
|
-
runId: input.runId,
|
|
258
|
-
stageKey: input.stageKey
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
const entry = {
|
|
262
|
-
...input,
|
|
263
|
-
id: messageId,
|
|
264
|
-
...stageIdentity !== undefined ? { stageId: stageIdentity.id } : {},
|
|
265
|
-
...stageIdentity?.replayKey !== undefined ? { stageReplayKey: stageIdentity.replayKey } : {},
|
|
266
|
-
admissionOrder: nextAdmissionOrder(messages, input.runId),
|
|
267
|
-
status: "queued"
|
|
268
|
-
};
|
|
269
|
-
return {
|
|
270
|
-
ok: true,
|
|
271
|
-
messages: [...messages, entry],
|
|
272
|
-
entry,
|
|
273
|
-
position: queued.length + 1,
|
|
274
|
-
deduplicated: false
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function queueStickyStageMessage(messages, input, senderGroup, runGroup) {
|
|
278
|
-
if (normalizeDeliveryGroup(senderGroup) !== normalizeDeliveryGroup(runGroup)) {
|
|
279
|
-
return { ok: false, reason: "group_mismatch", runId: input.runId, stageKey: input.targetPath };
|
|
280
|
-
}
|
|
281
|
-
const messageId = input.message.id;
|
|
282
|
-
const existing = messages.find((entry) => entry.runId === input.runId && entry.id === messageId);
|
|
283
|
-
if (existing !== undefined) {
|
|
284
|
-
if (pendingStageMessageSignature(existing) !== pendingStageMessageSignature(input)) {
|
|
285
|
-
return {
|
|
286
|
-
ok: false,
|
|
287
|
-
reason: "message_id_conflict",
|
|
288
|
-
runId: input.runId,
|
|
289
|
-
stageKey: input.targetPath,
|
|
290
|
-
messageId
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
const queuedForTarget = queuedStickyCount(messages, input.runId, input.targetPath);
|
|
294
|
-
return {
|
|
295
|
-
ok: true,
|
|
296
|
-
messages,
|
|
297
|
-
entry: existing,
|
|
298
|
-
...existing.status === "queued" ? { position: queuedForTarget } : {},
|
|
299
|
-
deduplicated: true
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
if (queuedStickyCount(messages, input.runId, input.targetPath) >= PENDING_STAGE_MESSAGE_LIMIT) {
|
|
303
|
-
return {
|
|
304
|
-
ok: false,
|
|
305
|
-
reason: "capacity",
|
|
306
|
-
limit: PENDING_STAGE_MESSAGE_LIMIT,
|
|
307
|
-
runId: input.runId,
|
|
308
|
-
stageKey: input.targetPath
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
const entry = {
|
|
312
|
-
...input,
|
|
313
|
-
id: messageId,
|
|
314
|
-
stageKey: input.targetPath,
|
|
315
|
-
sticky: true,
|
|
316
|
-
deliveries: [],
|
|
317
|
-
deliveryCount: 0,
|
|
318
|
-
admissionOrder: nextAdmissionOrder(messages, input.runId),
|
|
319
|
-
status: "queued"
|
|
320
|
-
};
|
|
321
|
-
return {
|
|
322
|
-
ok: true,
|
|
323
|
-
messages: [...messages, entry],
|
|
324
|
-
entry,
|
|
325
|
-
position: queuedStickyCount(messages, input.runId, input.targetPath) + 1,
|
|
326
|
-
deduplicated: false
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function queuedStickyCount(messages, runId, targetPath) {
|
|
330
|
-
return messages.filter((entry) => entry.runId === runId && entry.sticky === true && entry.targetPath === targetPath && entry.status === "queued").length;
|
|
331
|
-
}
|
|
332
|
-
function recordPendingStageMessageDeliveries(messages, runId, messageId, records, deliveredAt) {
|
|
333
|
-
const index = messages.findIndex((entry) => entry.runId === runId && entry.id === messageId && entry.sticky === true && entry.status === "queued");
|
|
334
|
-
if (index < 0)
|
|
335
|
-
return messages;
|
|
336
|
-
const entry = messages[index];
|
|
337
|
-
const recorded = new Set((entry.deliveries ?? []).map((delivery) => `${delivery.runId}\x00${delivery.stageId}`));
|
|
338
|
-
const additions = [];
|
|
339
|
-
for (const record of records) {
|
|
340
|
-
const key = `${record.runId}\x00${record.stageId}`;
|
|
341
|
-
if (recorded.has(key))
|
|
342
|
-
continue;
|
|
343
|
-
recorded.add(key);
|
|
344
|
-
additions.push({
|
|
345
|
-
runId: record.runId,
|
|
346
|
-
stageId: record.stageId,
|
|
347
|
-
...record.stageName === undefined ? {} : { stageName: record.stageName },
|
|
348
|
-
deliveredAt
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
if (additions.length === 0)
|
|
352
|
-
return messages;
|
|
353
|
-
const deliveries = [...entry.deliveries ?? [], ...additions];
|
|
354
|
-
const next = { ...entry, deliveries, deliveryCount: deliveries.length };
|
|
355
|
-
const result = [...messages];
|
|
356
|
-
result[index] = next;
|
|
357
|
-
return result;
|
|
358
|
-
}
|
|
359
|
-
function settleStickyPendingStageMessageDelivered(messages, runId, messageId, settledAt) {
|
|
360
|
-
const index = messages.findIndex((entry) => entry.runId === runId && entry.id === messageId && entry.sticky === true && entry.status === "queued" && (entry.deliveryCount ?? 0) > 0);
|
|
361
|
-
if (index < 0)
|
|
362
|
-
return messages;
|
|
363
|
-
const next = [...messages];
|
|
364
|
-
next[index] = { ...next[index], status: "delivered", deliveredAt: settledAt };
|
|
365
|
-
return next;
|
|
366
|
-
}
|
|
367
|
-
function pendingStageMessagesFor(messages, runId, stageKey, stageIdentity) {
|
|
368
|
-
return messages.map((entry, index) => ({ entry, index })).filter(({ entry }) => matchesPendingStage(entry, runId, stageKey, stageIdentity) && entry.status === "queued").sort((left, right) => (left.entry.admissionOrder ?? left.index + 1) - (right.entry.admissionOrder ?? right.index + 1) || left.index - right.index).map(({ entry }) => entry);
|
|
369
|
-
}
|
|
370
|
-
function markPendingStageMessageDelivered(messages, runId, stageKey, messageId, deliveredAt, stageIdentity) {
|
|
371
|
-
return updateQueuedPendingStageMessage(messages, runId, stageKey, messageId, stageIdentity, (entry) => ({
|
|
372
|
-
...entry,
|
|
373
|
-
status: "delivered",
|
|
374
|
-
deliveredAt
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
function markPendingStageMessageUndeliverable(messages, runId, stageKey, messageId, reason, stageIdentity) {
|
|
378
|
-
return updateQueuedPendingStageMessage(messages, runId, stageKey, messageId, stageIdentity, (entry) => ({
|
|
379
|
-
...entry,
|
|
380
|
-
status: "undeliverable",
|
|
381
|
-
undeliverableReason: reason,
|
|
382
|
-
undeliverableNotificationId: pendingStageUndeliverableNotificationId(entry)
|
|
383
|
-
}));
|
|
384
|
-
}
|
|
385
|
-
function markPendingStageMessageUndeliverableNotified(messages, runId, stageKey, messageId, notificationId, notifiedAt) {
|
|
386
|
-
const index = messages.findIndex((entry) => (entry.sticky === true ? entry.runId === runId : matchesPendingStage(entry, runId, stageKey)) && entry.id === messageId && entry.status === "undeliverable" && entry.undeliverableNotificationId === notificationId && entry.undeliverableNotifiedAt === undefined);
|
|
387
|
-
if (index < 0)
|
|
388
|
-
return messages;
|
|
389
|
-
const next = [...messages];
|
|
390
|
-
next[index] = { ...next[index], undeliverableNotifiedAt: notifiedAt };
|
|
391
|
-
return next;
|
|
392
|
-
}
|
|
393
|
-
function pendingStageUndeliverableNotificationId(entry) {
|
|
394
|
-
return [
|
|
395
|
-
PENDING_STAGE_UNDELIVERABLE_NOTIFICATION_PREFIX,
|
|
396
|
-
encodeURIComponent(entry.runId),
|
|
397
|
-
encodeURIComponent(entry.stageKey),
|
|
398
|
-
encodeURIComponent(entry.id)
|
|
399
|
-
].join(":");
|
|
400
|
-
}
|
|
401
|
-
function updateQueuedPendingStageMessage(messages, runId, stageKey, messageId, stageIdentity, update) {
|
|
402
|
-
const index = messages.findIndex((entry) => queuedEntryMatches(entry, runId, stageKey, messageId, stageIdentity));
|
|
403
|
-
if (index < 0)
|
|
404
|
-
return messages;
|
|
405
|
-
const next = [...messages];
|
|
406
|
-
next[index] = update(next[index]);
|
|
407
|
-
return next;
|
|
408
|
-
}
|
|
409
|
-
function queuedEntryMatches(entry, runId, stageKey, messageId, stageIdentity) {
|
|
410
|
-
if (entry.runId !== runId || entry.id !== messageId || entry.status !== "queued")
|
|
411
|
-
return false;
|
|
412
|
-
return entry.sticky === true || matchesPendingStage(entry, runId, stageKey, stageIdentity);
|
|
413
|
-
}
|
|
414
|
-
function matchesPendingStage(entry, runId, stageKey, stageIdentity) {
|
|
415
|
-
if (entry.sticky === true)
|
|
416
|
-
return false;
|
|
417
|
-
if (entry.runId !== runId)
|
|
418
|
-
return false;
|
|
419
|
-
if (stageIdentity === undefined)
|
|
420
|
-
return entry.stageKey === stageKey;
|
|
421
|
-
return entry.stageId === stageIdentity.id || entry.stageReplayKey !== undefined && entry.stageReplayKey === stageIdentity.replayKey || entry.stageId === undefined && stageIdentity.aliases.includes(entry.stageKey);
|
|
422
|
-
}
|
|
423
|
-
function nextAdmissionOrder(messages, runId) {
|
|
424
|
-
let greatest = 0;
|
|
425
|
-
let legacyPosition = 0;
|
|
426
|
-
for (const entry of messages) {
|
|
427
|
-
if (entry.runId !== runId)
|
|
428
|
-
continue;
|
|
429
|
-
legacyPosition += 1;
|
|
430
|
-
greatest = Math.max(greatest, entry.admissionOrder ?? legacyPosition);
|
|
431
|
-
}
|
|
432
|
-
return greatest + 1;
|
|
433
|
-
}
|
|
434
|
-
function pendingStageMessageSignature(entry, stageIdentity) {
|
|
435
|
-
const storedTarget = "status" in entry ? entry.stageReplayKey ?? entry.stageId : undefined;
|
|
436
|
-
const { timestamp: transportTimestamp, ...logicalMessage } = entry.message;
|
|
437
|
-
return stableJson({
|
|
438
|
-
target: storedTarget ?? stageIdentity?.replayKey ?? stageIdentity?.id ?? entry.stageKey,
|
|
439
|
-
sender: entry.senderReturnAddress ?? entry.from.id,
|
|
440
|
-
message: {
|
|
441
|
-
...logicalMessage,
|
|
442
|
-
expectsReply: logicalMessage.expectsReply ?? false,
|
|
443
|
-
content: {
|
|
444
|
-
...logicalMessage.content,
|
|
445
|
-
attachments: logicalMessage.content.attachments ?? []
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
function stableJson(value) {
|
|
451
|
-
return JSON.stringify(sortJsonValue(value));
|
|
452
|
-
}
|
|
453
|
-
function sortJsonValue(value) {
|
|
454
|
-
if (Array.isArray(value))
|
|
455
|
-
return value.map(sortJsonValue);
|
|
456
|
-
if (typeof value !== "object" || value === null)
|
|
457
|
-
return value;
|
|
458
|
-
return Object.fromEntries(Object.entries(value).filter(([, nested]) => nested !== undefined).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, sortJsonValue(nested)]));
|
|
459
|
-
}
|
|
460
|
-
function normalizeDeliveryGroup(value) {
|
|
461
|
-
if (typeof value !== "string")
|
|
462
|
-
return "default";
|
|
463
|
-
const trimmed = value.trim();
|
|
464
|
-
return trimmed.length > 0 ? trimmed : "default";
|
|
465
|
-
}
|
|
466
|
-
// dist/builtin/workflows/src/shared/session-scoped-singleton.ts
|
|
467
|
-
import { sessionScopedExtensionState } from "@bastani/atomic";
|
|
468
|
-
var SHARED_STATES_KEY = Symbol.for("atomic-workflows/session-scoped-singleton-pre-adoption@1");
|
|
469
|
-
function processBag() {
|
|
470
|
-
return globalThis;
|
|
471
|
-
}
|
|
472
|
-
function recordLocal(key, local) {
|
|
473
|
-
const bag = processBag();
|
|
474
|
-
let states = bag[SHARED_STATES_KEY];
|
|
475
|
-
if (states === undefined || states.version !== 1) {
|
|
476
|
-
states = { version: 1, byKey: new Map };
|
|
477
|
-
bag[SHARED_STATES_KEY] = states;
|
|
478
|
-
}
|
|
479
|
-
const existing = states.byKey.get(key);
|
|
480
|
-
if (existing !== undefined)
|
|
481
|
-
return existing;
|
|
482
|
-
const created = { local, instance: undefined, localClaimed: false };
|
|
483
|
-
states.byKey.set(key, created);
|
|
484
|
-
return created;
|
|
485
|
-
}
|
|
486
|
-
function createSessionScopedSingleton(key, createLocal) {
|
|
487
|
-
const local = createLocal();
|
|
488
|
-
const shared = recordLocal(key, local);
|
|
489
|
-
let instance = local;
|
|
490
|
-
const live = () => shared.instance ?? instance;
|
|
491
|
-
const current = () => live();
|
|
492
|
-
const adoptWithResult = (scope, options) => {
|
|
493
|
-
const current = live();
|
|
494
|
-
let targetCreated = false;
|
|
495
|
-
const target = sessionScopedExtensionState(scope, key, () => {
|
|
496
|
-
targetCreated = true;
|
|
497
|
-
if (shared.localClaimed)
|
|
498
|
-
return createLocal();
|
|
499
|
-
shared.localClaimed = true;
|
|
500
|
-
return shared.local;
|
|
501
|
-
});
|
|
502
|
-
const preservedCurrent = !targetCreated && target !== current && options?.preserveCurrentWhenTargetExists?.(current, target) === true;
|
|
503
|
-
shared.instance = preservedCurrent ? current : target;
|
|
504
|
-
instance = shared.instance;
|
|
505
|
-
return { instance: shared.instance, preservedCurrent };
|
|
506
|
-
};
|
|
507
|
-
const adopt = (scope, options) => adoptWithResult(scope, options).instance;
|
|
508
|
-
const facade = new Proxy(local, {
|
|
509
|
-
get(_target, prop) {
|
|
510
|
-
const value = Reflect.get(live(), prop, live());
|
|
511
|
-
if (typeof value === "function") {
|
|
512
|
-
return value.bind(live());
|
|
513
|
-
}
|
|
514
|
-
return value;
|
|
515
|
-
},
|
|
516
|
-
has(_target, prop) {
|
|
517
|
-
return Reflect.has(live(), prop);
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
return { facade, adopt, adoptWithResult, current };
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// dist/builtin/workflows/src/shared/flat-string.ts
|
|
524
|
-
function flattenTruncatedString(value) {
|
|
525
|
-
return value.split("").join("");
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// dist/builtin/workflows/src/shared/tool-payload-bounds.ts
|
|
529
|
-
var TOOL_PAYLOAD_MAX_KEYS = 2048;
|
|
530
|
-
var TOOL_PAYLOAD_VALUE_LIMIT = 16384;
|
|
531
|
-
var TOOL_PAYLOAD_TRUNCATION_MARKER = "… [truncated]";
|
|
532
|
-
var TOOL_PAYLOAD_CYCLE_PLACEHOLDER = "<cycle>";
|
|
533
|
-
var TOOL_PAYLOAD_UNREADABLE_PLACEHOLDER = "<unreadable>";
|
|
534
|
-
var TOOL_PAYLOAD_UNSERIALIZABLE_PLACEHOLDER = "<unserializable>";
|
|
535
|
-
var TOOL_PAYLOAD_TRUNCATION_KEY = "…";
|
|
536
|
-
var TOOL_PAYLOAD_MAX_DEPTH = 256;
|
|
537
|
-
function isOmittedJsonValue(value) {
|
|
538
|
-
return value === undefined || typeof value === "function" || typeof value === "symbol";
|
|
539
|
-
}
|
|
540
|
-
function isToolPayloadObject(value) {
|
|
541
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
542
|
-
}
|
|
543
|
-
function isToolPayloadArray(value) {
|
|
544
|
-
return Array.isArray(value);
|
|
545
|
-
}
|
|
546
|
-
function isToolPayloadObjectLike(value) {
|
|
547
|
-
return value !== null && typeof value === "object";
|
|
548
|
-
}
|
|
549
|
-
function isToolPayloadCallable(value) {
|
|
550
|
-
return typeof value === "function";
|
|
551
|
-
}
|
|
552
|
-
function readToolPayloadProperty(value, key) {
|
|
553
|
-
try {
|
|
554
|
-
const property = Reflect.get(value, key);
|
|
555
|
-
return { ok: true, value: property };
|
|
556
|
-
} catch {
|
|
557
|
-
return { ok: false };
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function safeProperty(value, key) {
|
|
561
|
-
const result = readToolPayloadProperty(value, key);
|
|
562
|
-
return result.ok ? result.value : TOOL_PAYLOAD_UNREADABLE_PLACEHOLDER;
|
|
563
|
-
}
|
|
564
|
-
function safeOwnKeys(value, consumeKey) {
|
|
565
|
-
let stopped = false;
|
|
566
|
-
function* enumerate() {
|
|
567
|
-
let keys;
|
|
568
|
-
try {
|
|
569
|
-
keys = Reflect.ownKeys(value);
|
|
570
|
-
} catch {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
for (const key of keys) {
|
|
574
|
-
if (!consumeKey()) {
|
|
575
|
-
stopped = true;
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
if (typeof key !== "string")
|
|
579
|
-
continue;
|
|
580
|
-
let descriptor;
|
|
581
|
-
try {
|
|
582
|
-
descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
583
|
-
} catch {
|
|
584
|
-
continue;
|
|
585
|
-
}
|
|
586
|
-
if (descriptor?.enumerable === true)
|
|
587
|
-
yield key;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
return { keys: enumerate(), stoppedByLimit: () => stopped };
|
|
591
|
-
}
|
|
592
|
-
function safeArrayLength(value) {
|
|
593
|
-
const result = readToolPayloadProperty(value, "length");
|
|
594
|
-
if (!result.ok || typeof result.value !== "number")
|
|
595
|
-
return 0;
|
|
596
|
-
return Number.isSafeInteger(result.value) && result.value > 0 ? result.value : 0;
|
|
597
|
-
}
|
|
598
|
-
function resolveJsonValue(value) {
|
|
599
|
-
if (!isToolPayloadObjectLike(value))
|
|
600
|
-
return value;
|
|
601
|
-
const toJson = readToolPayloadProperty(value, "toJSON");
|
|
602
|
-
if (!toJson.ok)
|
|
603
|
-
return TOOL_PAYLOAD_UNREADABLE_PLACEHOLDER;
|
|
604
|
-
if (!isToolPayloadCallable(toJson.value))
|
|
605
|
-
return value;
|
|
606
|
-
try {
|
|
607
|
-
return toJson.value.call(value);
|
|
608
|
-
} catch {
|
|
609
|
-
return TOOL_PAYLOAD_UNSERIALIZABLE_PLACEHOLDER;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
var NULL_COST = 4;
|
|
613
|
-
var NUMBER_COST = 8;
|
|
614
|
-
var BOOLEAN_COST = 5;
|
|
615
|
-
var CONTAINER_COST = 2;
|
|
616
|
-
var SEPARATOR_COST = 1;
|
|
617
|
-
function consumeKeyBudget(state) {
|
|
618
|
-
if (state.keysRemaining <= 0)
|
|
619
|
-
return false;
|
|
620
|
-
state.keysRemaining -= 1;
|
|
621
|
-
return true;
|
|
622
|
-
}
|
|
623
|
-
function addTruncationMarker(record) {
|
|
624
|
-
let key = TOOL_PAYLOAD_TRUNCATION_KEY;
|
|
625
|
-
let suffix = 1;
|
|
626
|
-
while (Object.hasOwn(record, key))
|
|
627
|
-
key = `${TOOL_PAYLOAD_TRUNCATION_KEY}${suffix++}`;
|
|
628
|
-
record[key] = TOOL_PAYLOAD_TRUNCATION_MARKER;
|
|
629
|
-
}
|
|
630
|
-
function cloneObjectLike(state, value) {
|
|
631
|
-
if (state.seen.has(value))
|
|
632
|
-
return TOOL_PAYLOAD_CYCLE_PLACEHOLDER;
|
|
633
|
-
if (state.depth >= TOOL_PAYLOAD_MAX_DEPTH)
|
|
634
|
-
return TOOL_PAYLOAD_TRUNCATION_MARKER;
|
|
635
|
-
state.seen.add(value);
|
|
636
|
-
state.depth += 1;
|
|
637
|
-
state.remaining -= CONTAINER_COST;
|
|
638
|
-
try {
|
|
639
|
-
if (isToolPayloadArray(value)) {
|
|
640
|
-
const items = [];
|
|
641
|
-
const length = safeArrayLength(value);
|
|
642
|
-
for (let index = 0;index < length; index++) {
|
|
643
|
-
if (state.remaining <= 0) {
|
|
644
|
-
items.push(TOOL_PAYLOAD_TRUNCATION_MARKER);
|
|
645
|
-
break;
|
|
646
|
-
}
|
|
647
|
-
state.remaining -= SEPARATOR_COST;
|
|
648
|
-
const item = safeProperty(value, index);
|
|
649
|
-
if (isOmittedJsonValue(item)) {
|
|
650
|
-
state.remaining -= NULL_COST;
|
|
651
|
-
items.push(null);
|
|
652
|
-
continue;
|
|
653
|
-
}
|
|
654
|
-
items.push(cloneValue(state, item));
|
|
655
|
-
}
|
|
656
|
-
return items;
|
|
657
|
-
}
|
|
658
|
-
const cloned = {};
|
|
659
|
-
const scan = safeOwnKeys(value, () => state.remaining > 0 && consumeKeyBudget(state));
|
|
660
|
-
for (const key of scan.keys) {
|
|
661
|
-
state.remaining -= key.length + SEPARATOR_COST;
|
|
662
|
-
const child = safeProperty(value, key);
|
|
663
|
-
if (isOmittedJsonValue(child))
|
|
664
|
-
continue;
|
|
665
|
-
cloned[key] = cloneValue(state, child);
|
|
666
|
-
}
|
|
667
|
-
if (scan.stoppedByLimit())
|
|
668
|
-
addTruncationMarker(cloned);
|
|
669
|
-
return cloned;
|
|
670
|
-
} finally {
|
|
671
|
-
state.depth -= 1;
|
|
672
|
-
state.seen.delete(value);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function cloneValue(state, value) {
|
|
676
|
-
const resolved = resolveJsonValue(value);
|
|
677
|
-
if (resolved === null) {
|
|
678
|
-
state.remaining -= NULL_COST;
|
|
679
|
-
return null;
|
|
680
|
-
}
|
|
681
|
-
switch (typeof resolved) {
|
|
682
|
-
case "string":
|
|
683
|
-
return cloneString(state, resolved);
|
|
684
|
-
case "number":
|
|
685
|
-
state.remaining -= NUMBER_COST;
|
|
686
|
-
return Number.isFinite(resolved) ? resolved : null;
|
|
687
|
-
case "boolean":
|
|
688
|
-
state.remaining -= BOOLEAN_COST;
|
|
689
|
-
return resolved;
|
|
690
|
-
case "object":
|
|
691
|
-
return cloneObjectLike(state, resolved);
|
|
692
|
-
case "bigint":
|
|
693
|
-
state.remaining -= NUMBER_COST;
|
|
694
|
-
return resolved;
|
|
695
|
-
default:
|
|
696
|
-
state.remaining -= TOOL_PAYLOAD_UNSERIALIZABLE_PLACEHOLDER.length;
|
|
697
|
-
return TOOL_PAYLOAD_UNSERIALIZABLE_PLACEHOLDER;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
function boundedToolPayload(value, limit = TOOL_PAYLOAD_VALUE_LIMIT) {
|
|
701
|
-
return cloneValue({ remaining: Math.max(1, limit), depth: 0, keysRemaining: TOOL_PAYLOAD_MAX_KEYS, seen: new Set }, value);
|
|
702
|
-
}
|
|
703
|
-
function boundedToolPayloadRecord(value, limit = TOOL_PAYLOAD_VALUE_LIMIT) {
|
|
704
|
-
const record = {};
|
|
705
|
-
if (!isToolPayloadObject(value) && !isToolPayloadArray(value))
|
|
706
|
-
return record;
|
|
707
|
-
const state = {
|
|
708
|
-
remaining: Math.max(1, limit),
|
|
709
|
-
depth: 0,
|
|
710
|
-
keysRemaining: TOOL_PAYLOAD_MAX_KEYS,
|
|
711
|
-
seen: new Set([value])
|
|
712
|
-
};
|
|
713
|
-
const scan = safeOwnKeys(value, () => state.remaining > 0 && consumeKeyBudget(state));
|
|
714
|
-
for (const key of scan.keys) {
|
|
715
|
-
state.remaining -= key.length + SEPARATOR_COST;
|
|
716
|
-
const child = safeProperty(value, key);
|
|
717
|
-
if (isOmittedJsonValue(child))
|
|
718
|
-
continue;
|
|
719
|
-
record[key] = cloneValue(state, child);
|
|
720
|
-
}
|
|
721
|
-
if (scan.stoppedByLimit())
|
|
722
|
-
addTruncationMarker(record);
|
|
723
|
-
return record;
|
|
724
|
-
}
|
|
725
|
-
function cloneString(state, value) {
|
|
726
|
-
if (state.remaining <= 0)
|
|
727
|
-
return TOOL_PAYLOAD_TRUNCATION_MARKER;
|
|
728
|
-
if (value.length <= state.remaining) {
|
|
729
|
-
state.remaining -= value.length;
|
|
730
|
-
return value;
|
|
731
|
-
}
|
|
732
|
-
const keep = state.remaining;
|
|
733
|
-
state.remaining = 0;
|
|
734
|
-
return `${flattenTruncatedString(value.slice(0, keep))}${TOOL_PAYLOAD_TRUNCATION_MARKER}`;
|
|
735
|
-
}
|
|
736
|
-
function boundedToolText(value, limit = TOOL_PAYLOAD_VALUE_LIMIT) {
|
|
737
|
-
const cap = Math.max(TOOL_PAYLOAD_TRUNCATION_MARKER.length + 1, limit);
|
|
738
|
-
if (value.length <= cap)
|
|
739
|
-
return value;
|
|
740
|
-
const keep = Math.max(0, cap - TOOL_PAYLOAD_TRUNCATION_MARKER.length);
|
|
741
|
-
return `${flattenTruncatedString(value.slice(0, keep))}${TOOL_PAYLOAD_TRUNCATION_MARKER}`;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// dist/builtin/workflows/src/shared/graph-store-snapshot.ts
|
|
745
|
-
var COMPACT_RESULT_FIELD_LIMIT = 1024;
|
|
746
|
-
var COMPACT_EXIT_OUTPUT_LIMIT = COMPACT_RESULT_FIELD_LIMIT * 4;
|
|
747
|
-
function compactResultField(value) {
|
|
748
|
-
if (typeof value !== "string")
|
|
749
|
-
return;
|
|
750
|
-
if (value.length <= COMPACT_RESULT_FIELD_LIMIT)
|
|
751
|
-
return value;
|
|
752
|
-
return flattenTruncatedString(value.slice(0, COMPACT_RESULT_FIELD_LIMIT));
|
|
753
|
-
}
|
|
754
|
-
function compactRunResult(result, preserveExitedOutputs = false) {
|
|
755
|
-
if (result === undefined)
|
|
756
|
-
return;
|
|
757
|
-
const status = compactResultField(result.status);
|
|
758
|
-
const summary = compactResultField(result.summary);
|
|
759
|
-
const remainingWork = compactResultField(result.remaining_work);
|
|
760
|
-
const resultText = compactResultField(result.result);
|
|
761
|
-
const budgetDimension = status === "budget_exceeded" && (result.dimension === "duration" || result.dimension === "tokens" || result.dimension === "cost") ? result.dimension : undefined;
|
|
762
|
-
const compact = {
|
|
763
|
-
...status !== undefined ? { status } : {},
|
|
764
|
-
...summary !== undefined ? { summary } : {},
|
|
765
|
-
...remainingWork !== undefined ? { remaining_work: remainingWork } : {},
|
|
766
|
-
...resultText !== undefined ? { result: resultText } : {},
|
|
767
|
-
...budgetDimension !== undefined ? { dimension: budgetDimension } : {}
|
|
768
|
-
};
|
|
769
|
-
if (!preserveExitedOutputs)
|
|
770
|
-
return Object.keys(compact).length === 0 ? undefined : compact;
|
|
771
|
-
return compactExitedOutputs(result, compact);
|
|
772
|
-
}
|
|
773
|
-
function compactExitedOutputs(result, compact) {
|
|
774
|
-
try {
|
|
775
|
-
const serialized = JSON.stringify(result);
|
|
776
|
-
if (serialized !== undefined && serialized.length <= COMPACT_EXIT_OUTPUT_LIMIT) {
|
|
777
|
-
const parsed = JSON.parse(serialized);
|
|
778
|
-
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
779
|
-
return compactExitedObject(parsed);
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
} catch {}
|
|
783
|
-
return Object.keys(compact).length === 0 ? undefined : compact;
|
|
784
|
-
}
|
|
785
|
-
function compactExitedObject(result) {
|
|
786
|
-
const compacted = { ...result };
|
|
787
|
-
for (const key of ["status", "summary", "remaining_work", "result"]) {
|
|
788
|
-
const value = compacted[key];
|
|
789
|
-
if (typeof value === "string")
|
|
790
|
-
compacted[key] = compactResultField(value) ?? "";
|
|
791
|
-
}
|
|
792
|
-
return Object.keys(compacted).length === 0 ? undefined : compacted;
|
|
793
|
-
}
|
|
794
|
-
function clonePrompt(prompt) {
|
|
795
|
-
return {
|
|
796
|
-
...prompt,
|
|
797
|
-
...prompt.choices !== undefined ? { choices: [...prompt.choices] } : {}
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
function cloneInputRequest(request) {
|
|
801
|
-
return {
|
|
802
|
-
...request,
|
|
803
|
-
questions: request.questions.map((question) => ({
|
|
804
|
-
...question,
|
|
805
|
-
options: question.options.map((option) => ({ ...option }))
|
|
806
|
-
}))
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
function compactToolEvents(events) {
|
|
810
|
-
const event = events.at(-1);
|
|
811
|
-
return event === undefined ? [] : [{ name: event.name }];
|
|
812
|
-
}
|
|
813
|
-
function compactWorkflowChild(child) {
|
|
814
|
-
return {
|
|
815
|
-
...child,
|
|
816
|
-
outputs: {},
|
|
817
|
-
outputCount: child.outputCount ?? Object.keys(child.outputs).length
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
function compactStage(stage) {
|
|
821
|
-
const {
|
|
822
|
-
toolEvents,
|
|
823
|
-
workflowChild,
|
|
824
|
-
workflowChildRun,
|
|
825
|
-
pendingPrompt,
|
|
826
|
-
promptFootprint,
|
|
827
|
-
inputRequest,
|
|
828
|
-
notices,
|
|
829
|
-
mcpScope: _mcpScope,
|
|
830
|
-
attemptedModels: _attemptedModels,
|
|
831
|
-
modelAttempts: _modelAttempts,
|
|
832
|
-
result: _result,
|
|
833
|
-
structured: _structured,
|
|
834
|
-
...metadata
|
|
835
|
-
} = stage;
|
|
836
|
-
return {
|
|
837
|
-
...metadata,
|
|
838
|
-
parentIds: [...stage.parentIds],
|
|
839
|
-
toolEvents: compactToolEvents(toolEvents),
|
|
840
|
-
...workflowChild !== undefined ? { workflowChild: compactWorkflowChild(workflowChild) } : {},
|
|
841
|
-
...workflowChildRun !== undefined ? { workflowChildRun: { ...workflowChildRun } } : {},
|
|
842
|
-
...pendingPrompt !== undefined ? { pendingPrompt: clonePrompt(pendingPrompt) } : {},
|
|
843
|
-
...promptFootprint !== undefined ? { promptFootprint: clonePrompt(promptFootprint) } : {},
|
|
844
|
-
...inputRequest !== undefined ? { inputRequest: cloneInputRequest(inputRequest) } : {},
|
|
845
|
-
...notices !== undefined ? { notices: notices.map((notice) => ({ ...notice })) } : {}
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
function compactToolNode(node) {
|
|
849
|
-
return {
|
|
850
|
-
...node,
|
|
851
|
-
parentIds: [...node.parentIds],
|
|
852
|
-
...node.args !== undefined ? { args: boundedToolPayloadRecord(node.args) } : {},
|
|
853
|
-
...node.result !== undefined ? { result: boundedToolPayload(node.result) } : {},
|
|
854
|
-
...node.source !== undefined ? { source: boundedToolText(node.source) } : {}
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
function compactRun(run) {
|
|
858
|
-
const { inputs: _inputs, result: sourceResult, stages, toolNodes, pendingPrompt, ...metadata } = run;
|
|
859
|
-
const result = compactRunResult(sourceResult, run.exited === true && run.status === "failed");
|
|
860
|
-
return {
|
|
861
|
-
...metadata,
|
|
862
|
-
inputs: {},
|
|
863
|
-
stages: stages.map(compactStage),
|
|
864
|
-
...toolNodes !== undefined ? { toolNodes: toolNodes.map(compactToolNode) } : {},
|
|
865
|
-
...pendingPrompt !== undefined ? { pendingPrompt: clonePrompt(pendingPrompt) } : {},
|
|
866
|
-
...result !== undefined ? { result } : {}
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
function createGraphStoreSnapshot(runs, notices, version) {
|
|
870
|
-
const snapshot = {
|
|
871
|
-
runs: runs.map(compactRun),
|
|
872
|
-
notices: notices.map((notice) => ({ ...notice })),
|
|
873
|
-
version
|
|
874
|
-
};
|
|
875
|
-
deepFreezeGraphValue(snapshot);
|
|
876
|
-
return snapshot;
|
|
877
|
-
}
|
|
878
|
-
function deepFreezeGraphValue(value) {
|
|
879
|
-
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
880
|
-
return;
|
|
881
|
-
Object.freeze(value);
|
|
882
|
-
if (Array.isArray(value)) {
|
|
883
|
-
for (const item of value)
|
|
884
|
-
deepFreezeGraphValue(item);
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
for (const key of Object.keys(value)) {
|
|
888
|
-
deepFreezeGraphValue(value[key]);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
// dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
|
|
893
|
-
import { randomUUID } from "node:crypto";
|
|
894
|
-
|
|
895
|
-
// dist/builtin/workflows/src/shared/workflow-activity.ts
|
|
896
|
-
function workflowActivityNodeKey(runId, nodeId) {
|
|
897
|
-
return `${runId}:${nodeId}`;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
|
|
901
|
-
class WorkflowObservationRuntime {
|
|
902
|
-
runs;
|
|
903
|
-
invalidate;
|
|
904
|
-
liveRunIds = new Set;
|
|
905
|
-
executingStageIds = new Set;
|
|
906
|
-
executingToolNodeIds = new Set;
|
|
907
|
-
stoppingRunIds = new Set;
|
|
908
|
-
retryingStageIds = new Set;
|
|
909
|
-
acknowledgedFailureRunIds = new Set;
|
|
910
|
-
listeners = new Set;
|
|
911
|
-
replayStageIds = new Set;
|
|
912
|
-
previous = new Map;
|
|
913
|
-
recoveryDepth = 0;
|
|
914
|
-
constructor(runs, invalidate) {
|
|
915
|
-
this.runs = runs;
|
|
916
|
-
this.invalidate = invalidate;
|
|
917
|
-
}
|
|
918
|
-
get recovering() {
|
|
919
|
-
return this.recoveryDepth > 0;
|
|
920
|
-
}
|
|
921
|
-
startRun(runId) {
|
|
922
|
-
this.liveRunIds.add(runId);
|
|
923
|
-
this.stoppingRunIds.delete(runId);
|
|
924
|
-
}
|
|
925
|
-
finishRun(runId) {
|
|
926
|
-
this.liveRunIds.delete(runId);
|
|
927
|
-
this.stoppingRunIds.delete(runId);
|
|
928
|
-
for (const ids of [
|
|
929
|
-
this.executingStageIds,
|
|
930
|
-
this.executingToolNodeIds,
|
|
931
|
-
this.retryingStageIds,
|
|
932
|
-
this.replayStageIds
|
|
933
|
-
]) {
|
|
934
|
-
for (const id of ids)
|
|
935
|
-
if (id.startsWith(`${runId}:`))
|
|
936
|
-
ids.delete(id);
|
|
937
|
-
}
|
|
938
|
-
this.invalidate();
|
|
939
|
-
}
|
|
940
|
-
emit(event) {
|
|
941
|
-
for (const listener of this.listeners) {
|
|
942
|
-
try {
|
|
943
|
-
listener(event);
|
|
944
|
-
} catch {}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
rootRunId(run) {
|
|
948
|
-
if (run.rootRunId !== undefined)
|
|
949
|
-
return run.rootRunId;
|
|
950
|
-
if (run.parentRunId === undefined)
|
|
951
|
-
return run.id;
|
|
952
|
-
const parent = this.runs().find((candidate) => candidate.id === run.parentRunId);
|
|
953
|
-
return parent ? this.rootRunId(parent) : run.parentRunId;
|
|
954
|
-
}
|
|
955
|
-
lifecycle(target, attribution = "unknown") {
|
|
956
|
-
if (this.recovering && !this.liveRunIds.has(target.runId))
|
|
957
|
-
return;
|
|
958
|
-
const run = this.runs().find((candidate) => candidate.id === target.runId);
|
|
959
|
-
if (!run)
|
|
960
|
-
return;
|
|
961
|
-
const rootRunId = this.rootRunId(run);
|
|
962
|
-
const now = Date.now();
|
|
963
|
-
this.emit({
|
|
964
|
-
kind: "lifecycle",
|
|
965
|
-
event: {
|
|
966
|
-
type: "workflow_lifecycle",
|
|
967
|
-
eventId: randomUUID(),
|
|
968
|
-
runId: run.id,
|
|
969
|
-
rootRunId,
|
|
970
|
-
occurredAt: now,
|
|
971
|
-
observedAt: now,
|
|
972
|
-
target: canonicalTarget(target, rootRunId),
|
|
973
|
-
attribution,
|
|
974
|
-
delivery: target.kind === "stage" && this.replayStageIds.has(workflowActivityNodeKey(run.id, target.stageId)) ? "replay" : "live"
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
control(runId, action, attribution = "unknown") {
|
|
979
|
-
const run = this.runs().find((candidate) => candidate.id === runId);
|
|
980
|
-
if (!run)
|
|
981
|
-
return;
|
|
982
|
-
if ((action === "quit" || action === "kill" || action === "pause") && this.liveRunIds.has(runId))
|
|
983
|
-
this.stoppingRunIds.add(runId);
|
|
984
|
-
if (action === "resume")
|
|
985
|
-
this.stoppingRunIds.delete(runId);
|
|
986
|
-
this.lifecycle({ kind: "run", runId, status: run.status, action }, attribution);
|
|
987
|
-
this.invalidate();
|
|
988
|
-
}
|
|
989
|
-
heartbeat(runId, scheduledAt, intervalMinutes) {
|
|
990
|
-
const run = this.runs().find((candidate) => candidate.id === runId);
|
|
991
|
-
if (run)
|
|
992
|
-
this.emit({
|
|
993
|
-
kind: "heartbeat",
|
|
994
|
-
event: { type: "workflow_heartbeat", runId, rootRunId: this.rootRunId(run), scheduledAt, intervalMinutes }
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
beginRecovery() {
|
|
998
|
-
this.recoveryDepth++;
|
|
999
|
-
if (this.recoveryDepth === 1)
|
|
1000
|
-
this.emit({ kind: "availability" });
|
|
1001
|
-
let ended = false;
|
|
1002
|
-
return () => {
|
|
1003
|
-
if (ended)
|
|
1004
|
-
return;
|
|
1005
|
-
ended = true;
|
|
1006
|
-
this.capture();
|
|
1007
|
-
this.recoveryDepth--;
|
|
1008
|
-
if (!this.recovering)
|
|
1009
|
-
this.emit({ kind: "availability" });
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
capture() {
|
|
1013
|
-
const next = new Map;
|
|
1014
|
-
const visit = (key, target, historical = false) => {
|
|
1015
|
-
next.set(key, target);
|
|
1016
|
-
const previous = this.previous.get(key);
|
|
1017
|
-
if (!historical && this.liveRunIds.has(target.runId) && previous?.status !== target.status) {
|
|
1018
|
-
this.lifecycle(previous && previous.kind !== "prompt" && target.kind !== "prompt" ? { ...target, previousStatus: previous.status } : target, this.runs().find((run) => run.id === target.runId)?.origin);
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
for (const run of this.runs()) {
|
|
1022
|
-
const existing = this.previous.has(`run:${run.id}`);
|
|
1023
|
-
visit(`run:${run.id}`, { kind: "run", runId: run.id, status: run.status });
|
|
1024
|
-
for (const stage of run.stages) {
|
|
1025
|
-
visit(`stage:${workflowActivityNodeKey(run.id, stage.id)}`, { kind: "stage", runId: run.id, stageId: stage.id, stageName: stage.name, status: stage.status }, !existing);
|
|
1026
|
-
if (stage.pendingPrompt)
|
|
1027
|
-
visit(`prompt:${stage.pendingPrompt.id}`, {
|
|
1028
|
-
kind: "prompt",
|
|
1029
|
-
runId: run.id,
|
|
1030
|
-
stageId: stage.id,
|
|
1031
|
-
promptId: stage.pendingPrompt.id,
|
|
1032
|
-
status: "opened"
|
|
1033
|
-
}, !existing);
|
|
1034
|
-
}
|
|
1035
|
-
for (const tool of run.toolNodes ?? [])
|
|
1036
|
-
visit(`tool:${workflowActivityNodeKey(run.id, tool.id)}`, { kind: "tool", runId: run.id, toolNodeId: tool.id, toolName: tool.name, status: tool.status }, !existing);
|
|
1037
|
-
if (run.pendingPrompt)
|
|
1038
|
-
visit(`prompt:${run.pendingPrompt.id}`, { kind: "prompt", runId: run.id, promptId: run.pendingPrompt.id, status: "opened" }, !existing);
|
|
1039
|
-
}
|
|
1040
|
-
this.previous = next;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
var workflowObservationRuntimeKey = Symbol.for("atomic-workflows/store-observation-runtime@1");
|
|
1044
|
-
function canonicalTarget(target, rootRunId) {
|
|
1045
|
-
if (target.runId === rootRunId)
|
|
1046
|
-
return target;
|
|
1047
|
-
switch (target.kind) {
|
|
1048
|
-
case "stage":
|
|
1049
|
-
return { ...target, stageId: workflowActivityNodeKey(target.runId, target.stageId) };
|
|
1050
|
-
case "tool":
|
|
1051
|
-
return { ...target, toolNodeId: workflowActivityNodeKey(target.runId, target.toolNodeId) };
|
|
1052
|
-
case "prompt":
|
|
1053
|
-
return target.stageId === undefined ? target : { ...target, stageId: workflowActivityNodeKey(target.runId, target.stageId) };
|
|
1054
|
-
case "run":
|
|
1055
|
-
return target;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
// dist/builtin/workflows/src/shared/store-internal.ts
|
|
1060
|
-
var TERMINAL_STATUSES = new Set([
|
|
1061
|
-
"completed",
|
|
1062
|
-
"failed",
|
|
1063
|
-
"killed",
|
|
1064
|
-
"skipped",
|
|
1065
|
-
"cancelled",
|
|
1066
|
-
"blocked"
|
|
1067
|
-
]);
|
|
1068
|
-
function isTerminalStageStatus(status) {
|
|
1069
|
-
return status === "completed" || status === "failed" || status === "skipped";
|
|
1070
|
-
}
|
|
1071
|
-
function cannotAwaitInput(status) {
|
|
1072
|
-
return isTerminalStageStatus(status) || status === "paused" || status === "blocked";
|
|
1073
|
-
}
|
|
1074
|
-
function cannotBlock(status) {
|
|
1075
|
-
return isTerminalStageStatus(status) || status === "paused";
|
|
1076
|
-
}
|
|
1077
|
-
function cannotPause(status) {
|
|
1078
|
-
return isTerminalStageStatus(status) || status === "paused" || status === "blocked";
|
|
1079
|
-
}
|
|
1080
|
-
function clearRunFailureMetadata(run) {
|
|
1081
|
-
delete run.error;
|
|
1082
|
-
delete run.failureKind;
|
|
1083
|
-
delete run.failureCode;
|
|
1084
|
-
delete run.failureRecoverability;
|
|
1085
|
-
delete run.failureDisposition;
|
|
1086
|
-
delete run.failureMessage;
|
|
1087
|
-
delete run.failedStageId;
|
|
1088
|
-
delete run.failedToolNodeId;
|
|
1089
|
-
delete run.resumable;
|
|
1090
|
-
delete run.retryAfterMs;
|
|
1091
|
-
delete run.blockedAt;
|
|
1092
|
-
delete run.exited;
|
|
1093
|
-
delete run.exitReason;
|
|
1094
|
-
}
|
|
1095
|
-
function clearStaleBlockedRunMetadata(run, metadata) {
|
|
1096
|
-
if (metadata?.failureKind === undefined)
|
|
1097
|
-
delete run.failureKind;
|
|
1098
|
-
if (metadata?.failureCode === undefined)
|
|
1099
|
-
delete run.failureCode;
|
|
1100
|
-
if (metadata?.failureRecoverability === undefined)
|
|
1101
|
-
delete run.failureRecoverability;
|
|
1102
|
-
if (metadata?.failureDisposition === undefined)
|
|
1103
|
-
delete run.failureDisposition;
|
|
1104
|
-
if (metadata?.failureMessage === undefined)
|
|
1105
|
-
delete run.failureMessage;
|
|
1106
|
-
if (metadata?.failedStageId === undefined)
|
|
1107
|
-
delete run.failedStageId;
|
|
1108
|
-
if (metadata?.failedToolNodeId === undefined)
|
|
1109
|
-
delete run.failedToolNodeId;
|
|
1110
|
-
if (metadata?.resumable === undefined)
|
|
1111
|
-
delete run.resumable;
|
|
1112
|
-
if (metadata?.retryAfterMs === undefined)
|
|
1113
|
-
delete run.retryAfterMs;
|
|
1114
|
-
if (metadata?.exited === undefined)
|
|
1115
|
-
delete run.exited;
|
|
1116
|
-
if (metadata?.exitReason === undefined)
|
|
1117
|
-
delete run.exitReason;
|
|
1118
|
-
}
|
|
1119
|
-
function applyRunEndMetadata(run, metadata) {
|
|
1120
|
-
if (metadata.failureKind !== undefined)
|
|
1121
|
-
run.failureKind = metadata.failureKind;
|
|
1122
|
-
if (metadata.failureCode !== undefined)
|
|
1123
|
-
run.failureCode = metadata.failureCode;
|
|
1124
|
-
if (metadata.failureRecoverability !== undefined)
|
|
1125
|
-
run.failureRecoverability = metadata.failureRecoverability;
|
|
1126
|
-
if (metadata.failureDisposition !== undefined)
|
|
1127
|
-
run.failureDisposition = metadata.failureDisposition;
|
|
1128
|
-
if (metadata.retryAfterMs !== undefined)
|
|
1129
|
-
run.retryAfterMs = metadata.retryAfterMs;
|
|
1130
|
-
if (metadata.failureMessage !== undefined)
|
|
1131
|
-
run.failureMessage = metadata.failureMessage;
|
|
1132
|
-
if (metadata.failedStageId !== undefined)
|
|
1133
|
-
run.failedStageId = metadata.failedStageId;
|
|
1134
|
-
if (metadata.failedToolNodeId !== undefined)
|
|
1135
|
-
run.failedToolNodeId = metadata.failedToolNodeId;
|
|
1136
|
-
if (metadata.resumable !== undefined)
|
|
1137
|
-
run.resumable = metadata.resumable;
|
|
1138
|
-
if (metadata.exited !== undefined)
|
|
1139
|
-
run.exited = metadata.exited;
|
|
1140
|
-
if (metadata.exitReason !== undefined)
|
|
1141
|
-
run.exitReason = metadata.exitReason;
|
|
1142
|
-
}
|
|
1143
|
-
function createStoreState() {
|
|
1144
|
-
return {
|
|
1145
|
-
runs: [],
|
|
1146
|
-
notices: [],
|
|
1147
|
-
listeners: new Set,
|
|
1148
|
-
invalidationListeners: new Set,
|
|
1149
|
-
resolvers: new Map,
|
|
1150
|
-
stagePromptAnswers: new Map,
|
|
1151
|
-
stagePromptDrafts: new Map,
|
|
1152
|
-
version: 0
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
function createStoreContext(state = createStoreState()) {
|
|
1156
|
-
let cachedGraphVersion = -1;
|
|
1157
|
-
let cachedGraphSnapshot;
|
|
1158
|
-
const observation = new WorkflowObservationRuntime(() => state.runs, bumpAndNotify);
|
|
1159
|
-
function snapshot() {
|
|
1160
|
-
return JSON.parse(JSON.stringify({ runs: state.runs, notices: state.notices, version: state.version }));
|
|
1161
|
-
}
|
|
1162
|
-
function graphSnapshot() {
|
|
1163
|
-
if (cachedGraphSnapshot === undefined || cachedGraphVersion !== state.version) {
|
|
1164
|
-
cachedGraphSnapshot = createGraphStoreSnapshot(state.runs, state.notices, state.version);
|
|
1165
|
-
cachedGraphVersion = state.version;
|
|
1166
|
-
}
|
|
1167
|
-
return cachedGraphSnapshot;
|
|
1168
|
-
}
|
|
1169
|
-
function notify() {
|
|
1170
|
-
observation.capture();
|
|
1171
|
-
for (const fn of state.invalidationListeners) {
|
|
1172
|
-
try {
|
|
1173
|
-
fn();
|
|
1174
|
-
} catch {}
|
|
1175
|
-
}
|
|
1176
|
-
if (state.listeners.size > 0) {
|
|
1177
|
-
const snap = snapshot();
|
|
1178
|
-
for (const fn of state.listeners) {
|
|
1179
|
-
try {
|
|
1180
|
-
fn(snap);
|
|
1181
|
-
} catch {}
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
function bumpAndNotify() {
|
|
1186
|
-
state.version++;
|
|
1187
|
-
notify();
|
|
1188
|
-
}
|
|
1189
|
-
function findRun(runId) {
|
|
1190
|
-
return state.runs.find((r) => r.id === runId);
|
|
1191
|
-
}
|
|
1192
|
-
function findStage(run, stageId) {
|
|
1193
|
-
return run.stages.find((s) => s.id === stageId);
|
|
1194
|
-
}
|
|
1195
|
-
function rejectPrompt(promptId, reason) {
|
|
1196
|
-
const entry = state.resolvers.get(promptId);
|
|
1197
|
-
if (!entry)
|
|
1198
|
-
return;
|
|
1199
|
-
state.resolvers.delete(promptId);
|
|
1200
|
-
entry.reject(new Error(reason));
|
|
1201
|
-
}
|
|
1202
|
-
function stagePromptAnswerKey(runId, stageId) {
|
|
1203
|
-
return JSON.stringify([runId, stageId]);
|
|
1204
|
-
}
|
|
1205
|
-
function stagePromptDraftKey(runId, stageId, promptId) {
|
|
1206
|
-
return JSON.stringify([runId, stageId, promptId]);
|
|
1207
|
-
}
|
|
1208
|
-
function stageHasActiveTextPrompt(runId, stageId, promptId) {
|
|
1209
|
-
const run = findRun(runId);
|
|
1210
|
-
if (!run || TERMINAL_STATUSES.has(run.status))
|
|
1211
|
-
return;
|
|
1212
|
-
const stage = findStage(run, stageId);
|
|
1213
|
-
if (!stage || isTerminalStageStatus(stage.status))
|
|
1214
|
-
return;
|
|
1215
|
-
const prompt = stage.pendingPrompt;
|
|
1216
|
-
if (!prompt || prompt.id !== promptId)
|
|
1217
|
-
return;
|
|
1218
|
-
if (prompt.kind !== "input" && prompt.kind !== "editor")
|
|
1219
|
-
return;
|
|
1220
|
-
return { prompt };
|
|
1221
|
-
}
|
|
1222
|
-
function rejectStagePrompt(runId, stage, reason) {
|
|
1223
|
-
const prompt = stage.pendingPrompt;
|
|
1224
|
-
if (!prompt)
|
|
1225
|
-
return;
|
|
1226
|
-
observation.lifecycle({ kind: "prompt", runId, stageId: stage.id, promptId: prompt.id, status: "cancelled" });
|
|
1227
|
-
stage.pendingPrompt = undefined;
|
|
1228
|
-
state.stagePromptDrafts.delete(stagePromptDraftKey(runId, stage.id, prompt.id));
|
|
1229
|
-
rejectPrompt(prompt.id, reason);
|
|
1230
|
-
}
|
|
1231
|
-
function rejectAllStagePrompts(runId, run, reason) {
|
|
1232
|
-
for (const stage of run.stages) {
|
|
1233
|
-
rejectStagePrompt(runId, stage, reason);
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
return {
|
|
1237
|
-
state,
|
|
1238
|
-
observation,
|
|
1239
|
-
snapshot,
|
|
1240
|
-
graphSnapshot,
|
|
1241
|
-
notify,
|
|
1242
|
-
bumpAndNotify,
|
|
1243
|
-
findRun,
|
|
1244
|
-
findStage,
|
|
1245
|
-
rejectPrompt,
|
|
1246
|
-
rejectStagePrompt,
|
|
1247
|
-
rejectAllStagePrompts,
|
|
1248
|
-
stagePromptAnswerKey,
|
|
1249
|
-
stagePromptDraftKey,
|
|
1250
|
-
stageHasActiveTextPrompt
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
// dist/builtin/workflows/src/shared/store-pending-stage-delivery-methods.ts
|
|
1255
|
-
function createPendingStageDeliveryStoreMethods(context) {
|
|
1256
|
-
const transitions = new Map;
|
|
1257
|
-
const serialize = async (runId, transition) => {
|
|
1258
|
-
const previous = transitions.get(runId) ?? Promise.resolve();
|
|
1259
|
-
const result = previous.catch(() => {
|
|
1260
|
-
return;
|
|
1261
|
-
}).then(transition);
|
|
1262
|
-
const settled = result.then(() => {
|
|
1263
|
-
return;
|
|
1264
|
-
}, () => {
|
|
1265
|
-
return;
|
|
1266
|
-
});
|
|
1267
|
-
transitions.set(runId, settled);
|
|
1268
|
-
settled.finally(() => {
|
|
1269
|
-
if (transitions.get(runId) === settled)
|
|
1270
|
-
transitions.delete(runId);
|
|
1271
|
-
});
|
|
1272
|
-
return await result;
|
|
1273
|
-
};
|
|
1274
|
-
return {
|
|
1275
|
-
async queueStageMessage(input, senderGroup, runGroup, backend) {
|
|
1276
|
-
return await serialize(input.runId, async () => {
|
|
1277
|
-
const run = context.findRun(input.runId);
|
|
1278
|
-
if (run === undefined)
|
|
1279
|
-
return;
|
|
1280
|
-
const stageIdentity = resolvePendingStageIdentity(run, input.stageKey);
|
|
1281
|
-
const result = queueStageMessage(run.pendingStageMessages ?? [], input, senderGroup, runGroup, stageIdentity);
|
|
1282
|
-
if (result.ok && !result.deduplicated) {
|
|
1283
|
-
await persistTransition(backend, input.runId, result.messages);
|
|
1284
|
-
run.pendingStageMessages = [...result.messages];
|
|
1285
|
-
context.bumpAndNotify();
|
|
1286
|
-
}
|
|
1287
|
-
return result;
|
|
1288
|
-
});
|
|
1289
|
-
},
|
|
1290
|
-
async validateLiveStageMessage(input) {
|
|
1291
|
-
return await serialize(input.runId, async () => {
|
|
1292
|
-
const run = context.findRun(input.runId);
|
|
1293
|
-
if (run === undefined)
|
|
1294
|
-
return;
|
|
1295
|
-
const result = queueStageMessage(run.pendingStageMessages ?? [], input, undefined, undefined, resolvePendingStageIdentity(run, input.stageKey));
|
|
1296
|
-
if (!result.ok) {
|
|
1297
|
-
return result.reason === "message_id_conflict" ? { outcome: "message_id_conflict", messageId: result.messageId } : { outcome: "forward" };
|
|
1298
|
-
}
|
|
1299
|
-
if (!result.deduplicated)
|
|
1300
|
-
return { outcome: "forward" };
|
|
1301
|
-
if (result.entry.status === "delivered")
|
|
1302
|
-
return { outcome: "delivered" };
|
|
1303
|
-
if (result.entry.status === "undeliverable") {
|
|
1304
|
-
return { outcome: "undeliverable", reason: result.entry.undeliverableReason };
|
|
1305
|
-
}
|
|
1306
|
-
if (result.position === undefined) {
|
|
1307
|
-
throw new Error(`atomic-workflows: queued message ${input.message.id} has no active position`);
|
|
1308
|
-
}
|
|
1309
|
-
return { outcome: "queued", position: result.position };
|
|
1310
|
-
});
|
|
1311
|
-
},
|
|
1312
|
-
pendingStageMessagesFor(runId, stageKey) {
|
|
1313
|
-
const run = context.findRun(runId);
|
|
1314
|
-
return pendingStageMessagesFor(run?.pendingStageMessages ?? [], runId, stageKey, run === undefined ? undefined : resolvePendingStageIdentity(run, stageKey));
|
|
1315
|
-
},
|
|
1316
|
-
async markPendingStageMessageDelivered(runId, stageKey, messageId, deliveredAt, backend) {
|
|
1317
|
-
return await serialize(runId, async () => {
|
|
1318
|
-
const run = context.findRun(runId);
|
|
1319
|
-
if (run === undefined)
|
|
1320
|
-
return false;
|
|
1321
|
-
const current = run.pendingStageMessages ?? [];
|
|
1322
|
-
const next = markPendingStageMessageDelivered(current, runId, stageKey, messageId, deliveredAt, resolvePendingStageIdentity(run, stageKey));
|
|
1323
|
-
if (next === current)
|
|
1324
|
-
return false;
|
|
1325
|
-
await persistTransition(backend, runId, next);
|
|
1326
|
-
run.pendingStageMessages = [...next];
|
|
1327
|
-
context.bumpAndNotify();
|
|
1328
|
-
return true;
|
|
1329
|
-
});
|
|
1330
|
-
},
|
|
1331
|
-
async markPendingStageMessageUndeliverable(runId, stageKey, messageId, reason, backend) {
|
|
1332
|
-
return await serialize(runId, async () => {
|
|
1333
|
-
const run = context.findRun(runId);
|
|
1334
|
-
if (run === undefined)
|
|
1335
|
-
return false;
|
|
1336
|
-
const current = run.pendingStageMessages ?? [];
|
|
1337
|
-
const next = markPendingStageMessageUndeliverable(current, runId, stageKey, messageId, reason, resolvePendingStageIdentity(run, stageKey));
|
|
1338
|
-
if (next === current)
|
|
1339
|
-
return false;
|
|
1340
|
-
await persistTransition(backend, runId, next);
|
|
1341
|
-
run.pendingStageMessages = [...next];
|
|
1342
|
-
context.bumpAndNotify();
|
|
1343
|
-
return true;
|
|
1344
|
-
});
|
|
1345
|
-
},
|
|
1346
|
-
async markPendingStageMessageUndeliverableNotified(runId, stageKey, messageId, notificationId, notifiedAt, backend) {
|
|
1347
|
-
return await serialize(runId, async () => {
|
|
1348
|
-
const run = context.findRun(runId);
|
|
1349
|
-
if (run === undefined)
|
|
1350
|
-
return false;
|
|
1351
|
-
const current = run.pendingStageMessages ?? [];
|
|
1352
|
-
const next = markPendingStageMessageUndeliverableNotified(current, runId, stageKey, messageId, notificationId, notifiedAt);
|
|
1353
|
-
if (next === current)
|
|
1354
|
-
return false;
|
|
1355
|
-
await persistTransition(backend, runId, next);
|
|
1356
|
-
run.pendingStageMessages = [...next];
|
|
1357
|
-
context.bumpAndNotify();
|
|
1358
|
-
return true;
|
|
1359
|
-
});
|
|
1360
|
-
},
|
|
1361
|
-
async queueStickyStageMessage(input, senderGroup, runGroup, backend) {
|
|
1362
|
-
return await serialize(input.runId, async () => {
|
|
1363
|
-
const run = context.findRun(input.runId);
|
|
1364
|
-
if (run === undefined)
|
|
1365
|
-
return;
|
|
1366
|
-
const result = queueStickyStageMessage(run.pendingStageMessages ?? [], input, senderGroup, runGroup);
|
|
1367
|
-
if (result.ok && !result.deduplicated) {
|
|
1368
|
-
await persistTransition(backend, input.runId, result.messages);
|
|
1369
|
-
run.pendingStageMessages = [...result.messages];
|
|
1370
|
-
context.bumpAndNotify();
|
|
1371
|
-
}
|
|
1372
|
-
return result;
|
|
1373
|
-
});
|
|
1374
|
-
},
|
|
1375
|
-
async recordPendingStageMessageDeliveries(runId, messageId, records, deliveredAt, backend) {
|
|
1376
|
-
return await serialize(runId, async () => {
|
|
1377
|
-
const run = context.findRun(runId);
|
|
1378
|
-
if (run === undefined)
|
|
1379
|
-
return false;
|
|
1380
|
-
const current = run.pendingStageMessages ?? [];
|
|
1381
|
-
const next = recordPendingStageMessageDeliveries(current, runId, messageId, records, deliveredAt);
|
|
1382
|
-
if (next === current)
|
|
1383
|
-
return false;
|
|
1384
|
-
await persistTransition(backend, runId, next);
|
|
1385
|
-
run.pendingStageMessages = [...next];
|
|
1386
|
-
context.bumpAndNotify();
|
|
1387
|
-
return true;
|
|
1388
|
-
});
|
|
1389
|
-
},
|
|
1390
|
-
async settleStickyPendingStageMessageDelivered(runId, messageId, settledAt, backend) {
|
|
1391
|
-
return await serialize(runId, async () => {
|
|
1392
|
-
const run = context.findRun(runId);
|
|
1393
|
-
if (run === undefined)
|
|
1394
|
-
return false;
|
|
1395
|
-
const current = run.pendingStageMessages ?? [];
|
|
1396
|
-
const next = settleStickyPendingStageMessageDelivered(current, runId, messageId, settledAt);
|
|
1397
|
-
if (next === current)
|
|
1398
|
-
return false;
|
|
1399
|
-
await persistTransition(backend, runId, next);
|
|
1400
|
-
run.pendingStageMessages = [...next];
|
|
1401
|
-
context.bumpAndNotify();
|
|
1402
|
-
return true;
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
function resolvePendingStageIdentity(run, stageKey) {
|
|
1408
|
-
const exactIds = run.stages.filter((stage) => stage.id === stageKey);
|
|
1409
|
-
const candidates = exactIds.length > 0 ? exactIds : run.stages.filter((stage) => stage.name === stageKey);
|
|
1410
|
-
if (candidates.length !== 1)
|
|
1411
|
-
return;
|
|
1412
|
-
const stage = candidates[0];
|
|
1413
|
-
return {
|
|
1414
|
-
id: stage.id,
|
|
1415
|
-
...stage.replayKey !== undefined ? { replayKey: stage.replayKey } : {},
|
|
1416
|
-
aliases: stage.id === stage.name ? [stage.id] : [stage.id, stage.name]
|
|
1417
|
-
};
|
|
1418
|
-
}
|
|
1419
|
-
async function persistTransition(backend, runId, messages) {
|
|
1420
|
-
if (!await backend.persistPendingStageMessages(runId, messages)) {
|
|
1421
|
-
throw new Error(`atomic-workflows: durable workflow ${runId} is unavailable for pending-stage persistence`);
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
// dist/builtin/workflows/src/shared/store-prompt-methods.ts
|
|
1426
|
-
function createPromptStoreMethods(context) {
|
|
1427
|
-
const { state } = context;
|
|
1428
|
-
return {
|
|
1429
|
-
recordPendingPrompt(runId, prompt) {
|
|
1430
|
-
const run = context.findRun(runId);
|
|
1431
|
-
if (!run)
|
|
1432
|
-
return false;
|
|
1433
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1434
|
-
return false;
|
|
1435
|
-
if (run.pendingPrompt !== undefined)
|
|
1436
|
-
return false;
|
|
1437
|
-
run.pendingPrompt = { ...prompt };
|
|
1438
|
-
context.bumpAndNotify();
|
|
1439
|
-
return true;
|
|
1440
|
-
},
|
|
1441
|
-
resolvePendingPrompt(runId, promptId, response) {
|
|
1442
|
-
const run = context.findRun(runId);
|
|
1443
|
-
if (!run)
|
|
1444
|
-
return false;
|
|
1445
|
-
const pending = run.pendingPrompt;
|
|
1446
|
-
if (!pending || pending.id !== promptId)
|
|
1447
|
-
return false;
|
|
1448
|
-
context.observation.lifecycle({ kind: "prompt", runId, promptId, status: "answered" });
|
|
1449
|
-
run.pendingPrompt = undefined;
|
|
1450
|
-
context.bumpAndNotify();
|
|
1451
|
-
const entry = state.resolvers.get(promptId);
|
|
1452
|
-
if (entry) {
|
|
1453
|
-
state.resolvers.delete(promptId);
|
|
1454
|
-
entry.resolve(response);
|
|
1455
|
-
}
|
|
1456
|
-
return true;
|
|
1457
|
-
},
|
|
1458
|
-
awaitPendingPrompt(runId, promptId) {
|
|
1459
|
-
return new Promise((resolve, reject) => {
|
|
1460
|
-
const run = context.findRun(runId);
|
|
1461
|
-
if (!run) {
|
|
1462
|
-
reject(new Error(`atomic-workflows: run "${runId}" not found`));
|
|
1463
|
-
return;
|
|
1464
|
-
}
|
|
1465
|
-
const pending = run.pendingPrompt;
|
|
1466
|
-
if (!pending || pending.id !== promptId) {
|
|
1467
|
-
reject(new Error(`atomic-workflows: pending prompt "${promptId}" not registered on run "${runId}"`));
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
1470
|
-
state.resolvers.set(promptId, { promptId, resolve, reject });
|
|
1471
|
-
});
|
|
1472
|
-
},
|
|
1473
|
-
recordStagePendingPrompt(runId, stageId, prompt) {
|
|
1474
|
-
const run = context.findRun(runId);
|
|
1475
|
-
if (!run)
|
|
1476
|
-
return false;
|
|
1477
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1478
|
-
return false;
|
|
1479
|
-
const stage = context.findStage(run, stageId);
|
|
1480
|
-
if (!stage)
|
|
1481
|
-
return false;
|
|
1482
|
-
if (isTerminalStageStatus(stage.status))
|
|
1483
|
-
return false;
|
|
1484
|
-
if (stage.pendingPrompt !== undefined)
|
|
1485
|
-
return false;
|
|
1486
|
-
stage.pendingPrompt = { ...prompt };
|
|
1487
|
-
stage.promptFootprint = { ...prompt };
|
|
1488
|
-
stage.status = "awaiting_input";
|
|
1489
|
-
stage.awaitingInputSince = prompt.createdAt;
|
|
1490
|
-
context.bumpAndNotify();
|
|
1491
|
-
return true;
|
|
1492
|
-
},
|
|
1493
|
-
resolveStagePendingPrompt(runId, stageId, promptId, response, options = {}) {
|
|
1494
|
-
const run = context.findRun(runId);
|
|
1495
|
-
if (!run)
|
|
1496
|
-
return false;
|
|
1497
|
-
const stage = context.findStage(run, stageId);
|
|
1498
|
-
if (!stage)
|
|
1499
|
-
return false;
|
|
1500
|
-
const pending = stage.pendingPrompt;
|
|
1501
|
-
if (!pending || pending.id !== promptId)
|
|
1502
|
-
return false;
|
|
1503
|
-
state.stagePromptDrafts.delete(context.stagePromptDraftKey(runId, stageId, promptId));
|
|
1504
|
-
if (options.recordAnswer !== false) {
|
|
1505
|
-
state.stagePromptAnswers.set(context.stagePromptAnswerKey(runId, stageId), {
|
|
1506
|
-
runId,
|
|
1507
|
-
stageId,
|
|
1508
|
-
promptId,
|
|
1509
|
-
kind: pending.kind,
|
|
1510
|
-
value: response,
|
|
1511
|
-
answeredAt: Date.now(),
|
|
1512
|
-
...options.answerSource !== undefined ? { answerSource: options.answerSource } : {}
|
|
1513
|
-
});
|
|
1514
|
-
stage.promptAnswerState = "available";
|
|
1515
|
-
} else {
|
|
1516
|
-
state.stagePromptAnswers.delete(context.stagePromptAnswerKey(runId, stageId));
|
|
1517
|
-
delete stage.promptAnswerState;
|
|
1518
|
-
}
|
|
1519
|
-
context.observation.lifecycle({
|
|
1520
|
-
kind: "prompt",
|
|
1521
|
-
runId,
|
|
1522
|
-
stageId,
|
|
1523
|
-
promptId,
|
|
1524
|
-
status: options.recordAnswer === false ? "cancelled" : "answered"
|
|
1525
|
-
});
|
|
1526
|
-
stage.pendingPrompt = undefined;
|
|
1527
|
-
if (stage.status === "awaiting_input") {
|
|
1528
|
-
stage.status = "running";
|
|
1529
|
-
delete stage.awaitingInputSince;
|
|
1530
|
-
}
|
|
1531
|
-
context.bumpAndNotify();
|
|
1532
|
-
const entry = state.resolvers.get(promptId);
|
|
1533
|
-
if (entry) {
|
|
1534
|
-
state.resolvers.delete(promptId);
|
|
1535
|
-
entry.resolve(response);
|
|
1536
|
-
}
|
|
1537
|
-
return true;
|
|
1538
|
-
},
|
|
1539
|
-
awaitStagePendingPrompt(runId, stageId, promptId) {
|
|
1540
|
-
return new Promise((resolve, reject) => {
|
|
1541
|
-
const run = context.findRun(runId);
|
|
1542
|
-
if (!run) {
|
|
1543
|
-
reject(new Error(`atomic-workflows: run "${runId}" not found`));
|
|
1544
|
-
return;
|
|
1545
|
-
}
|
|
1546
|
-
const stage = context.findStage(run, stageId);
|
|
1547
|
-
if (!stage) {
|
|
1548
|
-
reject(new Error(`atomic-workflows: stage "${stageId}" not found on run "${runId}"`));
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
const pending = stage.pendingPrompt;
|
|
1552
|
-
if (!pending || pending.id !== promptId) {
|
|
1553
|
-
reject(new Error(`atomic-workflows: pending prompt "${promptId}" not registered on stage "${stageId}" in run "${runId}"`));
|
|
1554
|
-
return;
|
|
1555
|
-
}
|
|
1556
|
-
state.resolvers.set(promptId, { promptId, resolve, reject });
|
|
1557
|
-
});
|
|
1558
|
-
},
|
|
1559
|
-
recordStagePromptAnswer(runId, stageId, prompt, response, options = {}) {
|
|
1560
|
-
const run = context.findRun(runId);
|
|
1561
|
-
if (!run)
|
|
1562
|
-
return false;
|
|
1563
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1564
|
-
return false;
|
|
1565
|
-
const stage = context.findStage(run, stageId);
|
|
1566
|
-
if (!stage)
|
|
1567
|
-
return false;
|
|
1568
|
-
if (isTerminalStageStatus(stage.status))
|
|
1569
|
-
return false;
|
|
1570
|
-
state.stagePromptAnswers.set(context.stagePromptAnswerKey(runId, stageId), {
|
|
1571
|
-
runId,
|
|
1572
|
-
stageId,
|
|
1573
|
-
promptId: prompt.id,
|
|
1574
|
-
kind: prompt.kind,
|
|
1575
|
-
value: response,
|
|
1576
|
-
answeredAt: Date.now(),
|
|
1577
|
-
...options.answerSource !== undefined ? { answerSource: options.answerSource } : {}
|
|
1578
|
-
});
|
|
1579
|
-
if (stage.promptFootprint === undefined)
|
|
1580
|
-
stage.promptFootprint = { ...prompt };
|
|
1581
|
-
stage.promptAnswerState = "available";
|
|
1582
|
-
if (stage.status === "awaiting_input") {
|
|
1583
|
-
stage.status = "running";
|
|
1584
|
-
delete stage.awaitingInputSince;
|
|
1585
|
-
}
|
|
1586
|
-
context.bumpAndNotify();
|
|
1587
|
-
return true;
|
|
1588
|
-
},
|
|
1589
|
-
recordStagePromptDraft(runId, stageId, promptId, text) {
|
|
1590
|
-
if (context.stageHasActiveTextPrompt(runId, stageId, promptId) === undefined)
|
|
1591
|
-
return false;
|
|
1592
|
-
state.stagePromptDrafts.set(context.stagePromptDraftKey(runId, stageId, promptId), text);
|
|
1593
|
-
return true;
|
|
1594
|
-
},
|
|
1595
|
-
getStagePromptDraft(runId, stageId, promptId) {
|
|
1596
|
-
if (context.stageHasActiveTextPrompt(runId, stageId, promptId) === undefined)
|
|
1597
|
-
return;
|
|
1598
|
-
return state.stagePromptDrafts.get(context.stagePromptDraftKey(runId, stageId, promptId));
|
|
1599
|
-
},
|
|
1600
|
-
clearStagePromptDraft(runId, stageId, promptId) {
|
|
1601
|
-
return state.stagePromptDrafts.delete(context.stagePromptDraftKey(runId, stageId, promptId));
|
|
1602
|
-
},
|
|
1603
|
-
getStagePromptAnswer(runId, stageId) {
|
|
1604
|
-
return state.stagePromptAnswers.get(context.stagePromptAnswerKey(runId, stageId));
|
|
1605
|
-
},
|
|
1606
|
-
clearStagePromptAnswer(runId, stageId) {
|
|
1607
|
-
const removed = state.stagePromptAnswers.delete(context.stagePromptAnswerKey(runId, stageId));
|
|
1608
|
-
const run = context.findRun(runId);
|
|
1609
|
-
const stage = run ? context.findStage(run, stageId) : undefined;
|
|
1610
|
-
const clearAvailabilityMarker = stage?.promptAnswerState === "available";
|
|
1611
|
-
if (clearAvailabilityMarker) {
|
|
1612
|
-
delete stage.promptAnswerState;
|
|
1613
|
-
}
|
|
1614
|
-
if (removed || clearAvailabilityMarker) {
|
|
1615
|
-
context.bumpAndNotify();
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
// dist/builtin/workflows/src/shared/run-visibility.ts
|
|
1622
|
-
function isTopLevelWorkflowRun(run) {
|
|
1623
|
-
return run.parentRunId === undefined;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
// dist/builtin/workflows/src/shared/timing.ts
|
|
1627
|
-
function nonNegative(ms) {
|
|
1628
|
-
return Math.max(0, ms);
|
|
1629
|
-
}
|
|
1630
|
-
function nextControlTimestamp(requestedAt, previousAt) {
|
|
1631
|
-
const candidate = requestedAt ?? Date.now();
|
|
1632
|
-
return previousAt === undefined || candidate > previousAt ? candidate : previousAt + 1;
|
|
1633
|
-
}
|
|
1634
|
-
function elapsedFromStart(startedAt, now, pausedDurationMs, pausedAt) {
|
|
1635
|
-
const completedPausedSegment = pausedDurationMs ?? 0;
|
|
1636
|
-
const activePausedSegment = pausedAt === undefined ? 0 : nonNegative(now - pausedAt);
|
|
1637
|
-
return nonNegative(now - startedAt - completedPausedSegment - activePausedSegment);
|
|
1638
|
-
}
|
|
1639
|
-
function accumulatePausedDurationMs(pausedDurationMs, pausedAt, resumedAt) {
|
|
1640
|
-
if (pausedAt === undefined)
|
|
1641
|
-
return pausedDurationMs ?? 0;
|
|
1642
|
-
return (pausedDurationMs ?? 0) + nonNegative(resumedAt - pausedAt);
|
|
1643
|
-
}
|
|
1644
|
-
function elapsedRunMs(run, now = Date.now()) {
|
|
1645
|
-
if (run.durationMs !== undefined)
|
|
1646
|
-
return nonNegative(run.durationMs);
|
|
1647
|
-
const effectiveNow = run.endedAt ?? now;
|
|
1648
|
-
return nonNegative(run.accumulatedDurationMs ?? 0) + elapsedFromStart(run.startedAt, effectiveNow, run.pausedDurationMs, run.pausedAt);
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
// dist/builtin/workflows/src/shared/store-run-methods.ts
|
|
1652
|
-
function createRunStoreMethods(context) {
|
|
1653
|
-
const { state } = context;
|
|
1654
|
-
return {
|
|
1655
|
-
runs() {
|
|
1656
|
-
return state.runs;
|
|
1657
|
-
},
|
|
1658
|
-
notices() {
|
|
1659
|
-
return state.notices;
|
|
1660
|
-
},
|
|
1661
|
-
activeRunId() {
|
|
1662
|
-
for (let i = state.runs.length - 1;i >= 0; i--) {
|
|
1663
|
-
const run = state.runs[i];
|
|
1664
|
-
if (run && isTopLevelWorkflowRun(run) && run.endedAt === undefined) {
|
|
1665
|
-
return run.id;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
for (let i = state.runs.length - 1;i >= 0; i--) {
|
|
1669
|
-
const run = state.runs[i];
|
|
1670
|
-
if (run && run.endedAt === undefined) {
|
|
1671
|
-
return run.id;
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
return null;
|
|
1675
|
-
},
|
|
1676
|
-
recordRunStart(run) {
|
|
1677
|
-
state.runs.push(run);
|
|
1678
|
-
context.bumpAndNotify();
|
|
1679
|
-
},
|
|
1680
|
-
reconcileRunParentStage(runId, expectedParentStageId, parentStageId) {
|
|
1681
|
-
const run = context.findRun(runId);
|
|
1682
|
-
if (run?.parentStageId !== expectedParentStageId || parentStageId === expectedParentStageId)
|
|
1683
|
-
return false;
|
|
1684
|
-
run.parentStageId = parentStageId;
|
|
1685
|
-
context.bumpAndNotify();
|
|
1686
|
-
return true;
|
|
1687
|
-
},
|
|
1688
|
-
recordRunEnd(runId, status, result, error, metadata) {
|
|
1689
|
-
const run = context.findRun(runId);
|
|
1690
|
-
if (!run)
|
|
1691
|
-
return false;
|
|
1692
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1693
|
-
return false;
|
|
1694
|
-
run.status = status;
|
|
1695
|
-
run.endedAt = Date.now();
|
|
1696
|
-
if (run.pausedAt !== undefined) {
|
|
1697
|
-
run.pausedDurationMs = accumulatePausedDurationMs(run.pausedDurationMs, run.pausedAt, run.endedAt);
|
|
1698
|
-
run.pausedAt = undefined;
|
|
1699
|
-
}
|
|
1700
|
-
run.durationMs = elapsedRunMs(run, run.endedAt);
|
|
1701
|
-
if (result !== undefined && shouldStoreRunResult(status))
|
|
1702
|
-
run.result = result;
|
|
1703
|
-
const wasBlocked = run.blockedAt !== undefined || run.failureDisposition === "active_blocked";
|
|
1704
|
-
delete run.blockedAt;
|
|
1705
|
-
if (status === "completed" || status === "skipped" || status === "cancelled" || status === "blocked") {
|
|
1706
|
-
clearRunFailureMetadata(run);
|
|
1707
|
-
if (status === "blocked" && error !== undefined)
|
|
1708
|
-
run.error = error;
|
|
1709
|
-
if (metadata !== undefined)
|
|
1710
|
-
applyRunEndMetadata(run, metadata);
|
|
1711
|
-
} else {
|
|
1712
|
-
if (wasBlocked && error === undefined)
|
|
1713
|
-
delete run.error;
|
|
1714
|
-
if ((status === "failed" || status === "killed") && error !== undefined) {
|
|
1715
|
-
run.error = error;
|
|
1716
|
-
}
|
|
1717
|
-
if (wasBlocked)
|
|
1718
|
-
clearStaleBlockedRunMetadata(run, metadata);
|
|
1719
|
-
if (metadata !== undefined)
|
|
1720
|
-
applyRunEndMetadata(run, metadata);
|
|
1721
|
-
if (run.failureDisposition === "active_blocked")
|
|
1722
|
-
delete run.failureDisposition;
|
|
1723
|
-
if (status === "killed") {
|
|
1724
|
-
run.failureRecoverability = "non_recoverable";
|
|
1725
|
-
run.failureDisposition = "terminal_killed";
|
|
1726
|
-
run.resumable = false;
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
const pending = run.pendingPrompt;
|
|
1730
|
-
if (pending) {
|
|
1731
|
-
context.observation.lifecycle({ kind: "prompt", runId, promptId: pending.id, status: "cancelled" });
|
|
1732
|
-
run.pendingPrompt = undefined;
|
|
1733
|
-
context.rejectPrompt(pending.id, `atomic-workflows: run ${runId} ended before prompt resolved`);
|
|
1734
|
-
}
|
|
1735
|
-
context.rejectAllStagePrompts(runId, run, `atomic-workflows: run ${runId} ended before prompt resolved`);
|
|
1736
|
-
context.bumpAndNotify();
|
|
1737
|
-
return true;
|
|
1738
|
-
},
|
|
1739
|
-
recordRunBlocked(runId, error, metadata) {
|
|
1740
|
-
const run = context.findRun(runId);
|
|
1741
|
-
if (!run)
|
|
1742
|
-
return false;
|
|
1743
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1744
|
-
return false;
|
|
1745
|
-
run.status = "running";
|
|
1746
|
-
run.error = error;
|
|
1747
|
-
run.failureKind = metadata.failureKind;
|
|
1748
|
-
run.failureCode = metadata.failureCode;
|
|
1749
|
-
run.failureRecoverability = metadata.failureRecoverability;
|
|
1750
|
-
run.failureDisposition = metadata.failureDisposition;
|
|
1751
|
-
run.failureMessage = metadata.failureMessage;
|
|
1752
|
-
if (metadata.failedStageId === undefined)
|
|
1753
|
-
delete run.failedStageId;
|
|
1754
|
-
else
|
|
1755
|
-
run.failedStageId = metadata.failedStageId;
|
|
1756
|
-
run.resumable = metadata.resumable;
|
|
1757
|
-
run.blockedAt = metadata.blockedAt ?? Date.now();
|
|
1758
|
-
if (metadata.endedAt !== undefined) {
|
|
1759
|
-
run.endedAt = metadata.endedAt;
|
|
1760
|
-
run.durationMs = elapsedRunMs(run, metadata.endedAt);
|
|
1761
|
-
}
|
|
1762
|
-
if (metadata.retryAfterMs !== undefined)
|
|
1763
|
-
run.retryAfterMs = metadata.retryAfterMs;
|
|
1764
|
-
if (metadata.result !== undefined)
|
|
1765
|
-
run.result = metadata.result;
|
|
1766
|
-
if (metadata.budgetState !== undefined)
|
|
1767
|
-
run.budgetState = metadata.budgetState;
|
|
1768
|
-
context.bumpAndNotify();
|
|
1769
|
-
return true;
|
|
1770
|
-
},
|
|
1771
|
-
restoreActiveBlockedRun(source, error, metadata) {
|
|
1772
|
-
const restored = {
|
|
1773
|
-
...source,
|
|
1774
|
-
status: "running",
|
|
1775
|
-
error,
|
|
1776
|
-
resumable: metadata.resumable,
|
|
1777
|
-
failureRecoverability: metadata.failureRecoverability,
|
|
1778
|
-
failureDisposition: metadata.failureDisposition,
|
|
1779
|
-
blockedAt: metadata.blockedAt ?? Date.now(),
|
|
1780
|
-
stages: source.stages.map((stage) => ({ ...stage })),
|
|
1781
|
-
toolNodes: source.toolNodes?.map((node) => ({ ...node }))
|
|
1782
|
-
};
|
|
1783
|
-
delete restored.endedAt;
|
|
1784
|
-
delete restored.durationMs;
|
|
1785
|
-
restored.failureKind = metadata.failureKind;
|
|
1786
|
-
restored.failureCode = metadata.failureCode;
|
|
1787
|
-
restored.failureMessage = metadata.failureMessage;
|
|
1788
|
-
if (metadata.failedStageId === undefined)
|
|
1789
|
-
delete restored.failedStageId;
|
|
1790
|
-
else
|
|
1791
|
-
restored.failedStageId = metadata.failedStageId;
|
|
1792
|
-
if (metadata.retryAfterMs !== undefined)
|
|
1793
|
-
restored.retryAfterMs = metadata.retryAfterMs;
|
|
1794
|
-
if (metadata.result !== undefined)
|
|
1795
|
-
restored.result = metadata.result;
|
|
1796
|
-
if (metadata.budgetState !== undefined)
|
|
1797
|
-
restored.budgetState = metadata.budgetState;
|
|
1798
|
-
const index = state.runs.findIndex((candidate) => candidate.id === source.id);
|
|
1799
|
-
if (index < 0)
|
|
1800
|
-
state.runs.push(restored);
|
|
1801
|
-
else
|
|
1802
|
-
state.runs[index] = restored;
|
|
1803
|
-
context.bumpAndNotify();
|
|
1804
|
-
return true;
|
|
1805
|
-
},
|
|
1806
|
-
removeRun(runId) {
|
|
1807
|
-
const index = state.runs.findIndex((r) => r.id === runId);
|
|
1808
|
-
if (index < 0)
|
|
1809
|
-
return false;
|
|
1810
|
-
const run = state.runs[index];
|
|
1811
|
-
const pending = run.pendingPrompt;
|
|
1812
|
-
if (pending) {
|
|
1813
|
-
context.observation.lifecycle({ kind: "prompt", runId, promptId: pending.id, status: "cancelled" });
|
|
1814
|
-
context.rejectPrompt(pending.id, `atomic-workflows: run ${runId} was removed before prompt resolved`);
|
|
1815
|
-
}
|
|
1816
|
-
context.rejectAllStagePrompts(runId, run, `atomic-workflows: run ${runId} was removed before prompt resolved`);
|
|
1817
|
-
for (const stage of run.stages) {
|
|
1818
|
-
state.stagePromptAnswers.delete(context.stagePromptAnswerKey(runId, stage.id));
|
|
1819
|
-
}
|
|
1820
|
-
state.runs.splice(index, 1);
|
|
1821
|
-
for (let i = state.notices.length - 1;i >= 0; i--) {
|
|
1822
|
-
if (state.notices[i]?.runId === runId)
|
|
1823
|
-
state.notices.splice(i, 1);
|
|
1824
|
-
}
|
|
1825
|
-
context.bumpAndNotify();
|
|
1826
|
-
return true;
|
|
1827
|
-
},
|
|
1828
|
-
recordNotice(notice) {
|
|
1829
|
-
state.notices.push(notice);
|
|
1830
|
-
context.bumpAndNotify();
|
|
1831
|
-
},
|
|
1832
|
-
ackNotice(id) {
|
|
1833
|
-
const notice = state.notices.find((n) => n.id === id);
|
|
1834
|
-
if (!notice || notice.ackedAt !== undefined)
|
|
1835
|
-
return false;
|
|
1836
|
-
notice.ackedAt = Date.now();
|
|
1837
|
-
context.bumpAndNotify();
|
|
1838
|
-
return true;
|
|
1839
|
-
},
|
|
1840
|
-
recordRunPaused(runId, pausedAt, metadata) {
|
|
1841
|
-
const run = context.findRun(runId);
|
|
1842
|
-
if (!run)
|
|
1843
|
-
return false;
|
|
1844
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1845
|
-
return false;
|
|
1846
|
-
const wasPaused = run.status === "paused";
|
|
1847
|
-
if (!wasPaused) {
|
|
1848
|
-
run.status = "paused";
|
|
1849
|
-
run.pausedAt = nextControlTimestamp(pausedAt, run.resumedAt);
|
|
1850
|
-
run.resumedAt = undefined;
|
|
1851
|
-
delete run.pauseActor;
|
|
1852
|
-
delete run.resumeActor;
|
|
1853
|
-
delete run.resumeSource;
|
|
1854
|
-
}
|
|
1855
|
-
if (metadata?.resumable !== undefined)
|
|
1856
|
-
run.resumable = metadata.resumable;
|
|
1857
|
-
if (metadata?.exitReason !== undefined)
|
|
1858
|
-
run.exitReason = metadata.exitReason;
|
|
1859
|
-
if (metadata?.exitReason === "quit" && run.quitAt === undefined)
|
|
1860
|
-
run.quitAt = nextControlTimestamp(undefined, run.pausedAt);
|
|
1861
|
-
if (metadata?.actor !== undefined)
|
|
1862
|
-
run.pauseActor = metadata.actor;
|
|
1863
|
-
if (wasPaused && metadata === undefined)
|
|
1864
|
-
return false;
|
|
1865
|
-
context.bumpAndNotify();
|
|
1866
|
-
return true;
|
|
1867
|
-
},
|
|
1868
|
-
recordRunResumed(runId, resumedAt, metadata) {
|
|
1869
|
-
const run = context.findRun(runId);
|
|
1870
|
-
if (!run)
|
|
1871
|
-
return false;
|
|
1872
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
1873
|
-
return false;
|
|
1874
|
-
const claimsRunControl = metadata?.source === "run_control";
|
|
1875
|
-
if (run.status !== "paused") {
|
|
1876
|
-
if (!claimsRunControl || run.status !== "running" || run.resumedAt === undefined)
|
|
1877
|
-
return false;
|
|
1878
|
-
if (run.resumeSource === "run_control" && run.resumeActor === metadata?.actor)
|
|
1879
|
-
return false;
|
|
1880
|
-
run.resumeSource = "run_control";
|
|
1881
|
-
if (metadata?.actor === undefined)
|
|
1882
|
-
delete run.resumeActor;
|
|
1883
|
-
else
|
|
1884
|
-
run.resumeActor = metadata.actor;
|
|
1885
|
-
context.bumpAndNotify();
|
|
1886
|
-
return false;
|
|
1887
|
-
}
|
|
1888
|
-
const resumedTs = nextControlTimestamp(resumedAt, run.pausedAt);
|
|
1889
|
-
run.status = "running";
|
|
1890
|
-
run.pausedDurationMs = accumulatePausedDurationMs(run.pausedDurationMs, run.pausedAt, resumedTs);
|
|
1891
|
-
run.resumedAt = resumedTs;
|
|
1892
|
-
run.pausedAt = undefined;
|
|
1893
|
-
delete run.quitAt;
|
|
1894
|
-
delete run.exitReason;
|
|
1895
|
-
delete run.pauseActor;
|
|
1896
|
-
if (metadata === undefined) {
|
|
1897
|
-
delete run.resumeActor;
|
|
1898
|
-
delete run.resumeSource;
|
|
1899
|
-
} else {
|
|
1900
|
-
run.resumeSource = metadata.source;
|
|
1901
|
-
if (metadata.actor === undefined)
|
|
1902
|
-
delete run.resumeActor;
|
|
1903
|
-
else
|
|
1904
|
-
run.resumeActor = metadata.actor;
|
|
1905
|
-
}
|
|
1906
|
-
context.bumpAndNotify();
|
|
1907
|
-
return true;
|
|
1908
|
-
},
|
|
1909
|
-
clear() {
|
|
1910
|
-
if (state.runs.length === 0 && state.notices.length === 0 && state.resolvers.size === 0 && state.stagePromptAnswers.size === 0 && state.stagePromptDrafts.size === 0)
|
|
1911
|
-
return;
|
|
1912
|
-
state.runs.length = 0;
|
|
1913
|
-
state.notices.length = 0;
|
|
1914
|
-
for (const entry of state.resolvers.values()) {
|
|
1915
|
-
entry.reject(new Error("atomic-workflows: store cleared"));
|
|
1916
|
-
}
|
|
1917
|
-
state.resolvers.clear();
|
|
1918
|
-
state.stagePromptAnswers.clear();
|
|
1919
|
-
state.stagePromptDrafts.clear();
|
|
1920
|
-
context.bumpAndNotify();
|
|
1921
|
-
},
|
|
1922
|
-
snapshot() {
|
|
1923
|
-
return context.snapshot();
|
|
1924
|
-
},
|
|
1925
|
-
graphSnapshot() {
|
|
1926
|
-
return context.graphSnapshot();
|
|
1927
|
-
},
|
|
1928
|
-
subscribe(fn) {
|
|
1929
|
-
state.listeners.add(fn);
|
|
1930
|
-
return () => {
|
|
1931
|
-
state.listeners.delete(fn);
|
|
1932
|
-
};
|
|
1933
|
-
},
|
|
1934
|
-
subscribeInvalidation(fn) {
|
|
1935
|
-
state.invalidationListeners.add(fn);
|
|
1936
|
-
return () => state.invalidationListeners.delete(fn);
|
|
1937
|
-
}
|
|
1938
|
-
};
|
|
1939
|
-
}
|
|
1940
|
-
function shouldStoreRunResult(status) {
|
|
1941
|
-
return status === "completed" || status === "skipped" || status === "cancelled" || status === "blocked" || status === "failed";
|
|
1942
|
-
}
|
|
1943
|
-
|
|
1944
|
-
// dist/builtin/workflows/src/shared/store-tool-node-methods.ts
|
|
1945
|
-
function nextExecutionOrder(run) {
|
|
1946
|
-
const stageOrders = run.stages.map((stage) => stage.executionOrder ?? 0);
|
|
1947
|
-
const toolOrders = (run.toolNodes ?? []).map((node) => node.executionOrder ?? 0);
|
|
1948
|
-
return Math.max(0, ...stageOrders, ...toolOrders) + 1;
|
|
1949
|
-
}
|
|
1950
|
-
function createToolNodeStoreMethods(context) {
|
|
1951
|
-
return {
|
|
1952
|
-
recordToolNodeStart(runId, node) {
|
|
1953
|
-
const run = context.findRun(runId);
|
|
1954
|
-
if (run === undefined || TERMINAL_STATUSES.has(run.status))
|
|
1955
|
-
return false;
|
|
1956
|
-
const mutableRun = run;
|
|
1957
|
-
if (mutableRun.toolNodes === undefined)
|
|
1958
|
-
mutableRun.toolNodes = [];
|
|
1959
|
-
const nodes = mutableRun.toolNodes;
|
|
1960
|
-
if (nodes.some((candidate) => candidate.id === node.id))
|
|
1961
|
-
return false;
|
|
1962
|
-
if (node.executionOrder === undefined)
|
|
1963
|
-
node.executionOrder = nextExecutionOrder(run);
|
|
1964
|
-
nodes.push(node);
|
|
1965
|
-
context.bumpAndNotify();
|
|
1966
|
-
return true;
|
|
1967
|
-
},
|
|
1968
|
-
recordToolNodeRunning(runId, nodeId, startedAt) {
|
|
1969
|
-
const node = context.findRun(runId)?.toolNodes?.find((candidate) => candidate.id === nodeId);
|
|
1970
|
-
if (node === undefined || node.status !== "pending")
|
|
1971
|
-
return false;
|
|
1972
|
-
node.status = "running";
|
|
1973
|
-
node.startedAt = startedAt;
|
|
1974
|
-
if (context.observation.liveRunIds.has(runId))
|
|
1975
|
-
context.observation.executingToolNodeIds.add(workflowActivityNodeKey(runId, nodeId));
|
|
1976
|
-
context.bumpAndNotify();
|
|
1977
|
-
return true;
|
|
1978
|
-
},
|
|
1979
|
-
recordToolNodeEnd(runId, nodeId, update) {
|
|
1980
|
-
const node = context.findRun(runId)?.toolNodes?.find((candidate) => candidate.id === nodeId);
|
|
1981
|
-
if (node === undefined || node.status === "completed" || node.status === "failed" || node.status === "cached" || node.status === "cancelled")
|
|
1982
|
-
return false;
|
|
1983
|
-
context.observation.executingToolNodeIds.delete(workflowActivityNodeKey(runId, nodeId));
|
|
1984
|
-
node.status = update.status;
|
|
1985
|
-
if (update.endedAt !== undefined)
|
|
1986
|
-
node.endedAt = update.endedAt;
|
|
1987
|
-
if (update.durationMs !== undefined)
|
|
1988
|
-
node.durationMs = update.durationMs;
|
|
1989
|
-
if (update.result !== undefined)
|
|
1990
|
-
node.result = boundedToolPayload(update.result);
|
|
1991
|
-
if (update.resultSummary !== undefined)
|
|
1992
|
-
node.resultSummary = update.resultSummary;
|
|
1993
|
-
if (update.error !== undefined)
|
|
1994
|
-
node.error = update.error;
|
|
1995
|
-
context.bumpAndNotify();
|
|
1996
|
-
return true;
|
|
1997
|
-
}
|
|
1998
|
-
};
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
// dist/builtin/workflows/src/shared/store-stage-methods.ts
|
|
2002
|
-
function createStageStoreMethods(context) {
|
|
2003
|
-
return {
|
|
2004
|
-
recordStageStart(runId, stage) {
|
|
2005
|
-
const run = context.findRun(runId);
|
|
2006
|
-
if (!run)
|
|
2007
|
-
return;
|
|
2008
|
-
if (stage.executionOrder === undefined)
|
|
2009
|
-
stage.executionOrder = nextExecutionOrder(run);
|
|
2010
|
-
if (!run.stages.some((s) => s.id === stage.id)) {
|
|
2011
|
-
run.stages.push(stage);
|
|
2012
|
-
}
|
|
2013
|
-
if (stage.status === "running" && context.observation.liveRunIds.has(runId)) {
|
|
2014
|
-
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stage.id));
|
|
2015
|
-
}
|
|
2016
|
-
context.bumpAndNotify();
|
|
2017
|
-
},
|
|
2018
|
-
recordStageWorkflowChildRun(runId, stageId, ref) {
|
|
2019
|
-
const run = context.findRun(runId);
|
|
2020
|
-
if (!run)
|
|
2021
|
-
return false;
|
|
2022
|
-
const stage = context.findStage(run, stageId);
|
|
2023
|
-
if (!stage)
|
|
2024
|
-
return false;
|
|
2025
|
-
const released = context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stageId));
|
|
2026
|
-
if (stage.workflowChildRun?.runId === ref.runId && stage.workflowChildRun.alias === ref.alias && stage.workflowChildRun.workflow === ref.workflow) {
|
|
2027
|
-
if (released)
|
|
2028
|
-
context.bumpAndNotify();
|
|
2029
|
-
return false;
|
|
2030
|
-
}
|
|
2031
|
-
stage.workflowChildRun = { ...ref };
|
|
2032
|
-
context.bumpAndNotify();
|
|
2033
|
-
return true;
|
|
2034
|
-
},
|
|
2035
|
-
recordToolStart(runId, stageId, evt) {
|
|
2036
|
-
const run = context.findRun(runId);
|
|
2037
|
-
if (!run)
|
|
2038
|
-
return;
|
|
2039
|
-
const stage = context.findStage(run, stageId);
|
|
2040
|
-
if (!stage)
|
|
2041
|
-
return;
|
|
2042
|
-
const exists = stage.toolEvents.some((e) => e.name === evt.name && e.startedAt === evt.startedAt);
|
|
2043
|
-
if (!exists) {
|
|
2044
|
-
stage.toolEvents.push(evt);
|
|
2045
|
-
}
|
|
2046
|
-
context.bumpAndNotify();
|
|
2047
|
-
},
|
|
2048
|
-
recordToolEnd(runId, stageId, evt) {
|
|
2049
|
-
const run = context.findRun(runId);
|
|
2050
|
-
if (!run)
|
|
2051
|
-
return;
|
|
2052
|
-
const stage = context.findStage(run, stageId);
|
|
2053
|
-
if (!stage)
|
|
2054
|
-
return;
|
|
2055
|
-
const existing = stage.toolEvents.find((e) => e.name === evt.name && e.startedAt === evt.startedAt);
|
|
2056
|
-
if (existing) {
|
|
2057
|
-
existing.endedAt = evt.endedAt;
|
|
2058
|
-
existing.output = evt.output;
|
|
2059
|
-
}
|
|
2060
|
-
context.bumpAndNotify();
|
|
2061
|
-
},
|
|
2062
|
-
recordStageEnd(runId, stage) {
|
|
2063
|
-
const run = context.findRun(runId);
|
|
2064
|
-
if (!run)
|
|
2065
|
-
return;
|
|
2066
|
-
const existing = context.findStage(run, stage.id);
|
|
2067
|
-
if (!existing)
|
|
2068
|
-
return;
|
|
2069
|
-
context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stage.id));
|
|
2070
|
-
existing.status = stage.status;
|
|
2071
|
-
existing.endedAt = stage.endedAt;
|
|
2072
|
-
if (existing.endedAt !== undefined && existing.pausedAt !== undefined) {
|
|
2073
|
-
existing.pausedDurationMs = accumulatePausedDurationMs(existing.pausedDurationMs, existing.pausedAt, existing.endedAt);
|
|
2074
|
-
existing.pausedAt = undefined;
|
|
2075
|
-
}
|
|
2076
|
-
existing.durationMs = stage.durationMs;
|
|
2077
|
-
existing.result = stage.result;
|
|
2078
|
-
existing.error = stage.error;
|
|
2079
|
-
if (stage.sessionId !== undefined)
|
|
2080
|
-
existing.sessionId = stage.sessionId;
|
|
2081
|
-
if (stage.sessionFile !== undefined)
|
|
2082
|
-
existing.sessionFile = stage.sessionFile;
|
|
2083
|
-
if (stage.modelAttempts !== undefined)
|
|
2084
|
-
existing.modelAttempts = stage.modelAttempts;
|
|
2085
|
-
existing.failureKind = stage.failureKind;
|
|
2086
|
-
existing.failureCode = stage.failureCode;
|
|
2087
|
-
existing.failureRecoverability = stage.failureRecoverability;
|
|
2088
|
-
existing.failureDisposition = stage.failureDisposition;
|
|
2089
|
-
existing.retryAfterMs = stage.retryAfterMs;
|
|
2090
|
-
existing.failureMessage = stage.failureMessage;
|
|
2091
|
-
existing.skippedReason = stage.skippedReason;
|
|
2092
|
-
if (stage.replayKey !== undefined)
|
|
2093
|
-
existing.replayKey = stage.replayKey;
|
|
2094
|
-
if (stage.promptAnswerState !== undefined)
|
|
2095
|
-
existing.promptAnswerState = stage.promptAnswerState;
|
|
2096
|
-
if (stage.replayedFromStageId !== undefined)
|
|
2097
|
-
existing.replayedFromStageId = stage.replayedFromStageId;
|
|
2098
|
-
if (stage.replayed !== undefined)
|
|
2099
|
-
existing.replayed = stage.replayed;
|
|
2100
|
-
if (stage.status === "completed") {
|
|
2101
|
-
if (stage.workflowChildRun !== undefined)
|
|
2102
|
-
existing.workflowChildRun = { ...stage.workflowChildRun };
|
|
2103
|
-
if (stage.workflowChild !== undefined)
|
|
2104
|
-
existing.workflowChild = structuredClone(stage.workflowChild);
|
|
2105
|
-
} else {
|
|
2106
|
-
delete existing.workflowChildRun;
|
|
2107
|
-
delete existing.workflowChild;
|
|
2108
|
-
}
|
|
2109
|
-
delete existing.awaitingInputSince;
|
|
2110
|
-
delete existing.inputRequest;
|
|
2111
|
-
context.rejectStagePrompt(runId, existing, `atomic-workflows: stage ${stage.id} ended before prompt resolved`);
|
|
2112
|
-
context.bumpAndNotify();
|
|
2113
|
-
},
|
|
2114
|
-
recordStageSession(runId, stageId, session) {
|
|
2115
|
-
const run = context.findRun(runId);
|
|
2116
|
-
if (!run)
|
|
2117
|
-
return false;
|
|
2118
|
-
const stage = context.findStage(run, stageId);
|
|
2119
|
-
if (!stage)
|
|
2120
|
-
return false;
|
|
2121
|
-
let changed = false;
|
|
2122
|
-
if (session.sessionId !== undefined && stage.sessionId !== session.sessionId) {
|
|
2123
|
-
stage.sessionId = session.sessionId;
|
|
2124
|
-
changed = true;
|
|
2125
|
-
}
|
|
2126
|
-
if (session.sessionFile !== undefined && stage.sessionFile !== session.sessionFile) {
|
|
2127
|
-
stage.sessionFile = session.sessionFile;
|
|
2128
|
-
changed = true;
|
|
2129
|
-
}
|
|
2130
|
-
if (!changed)
|
|
2131
|
-
return false;
|
|
2132
|
-
context.bumpAndNotify();
|
|
2133
|
-
return true;
|
|
2134
|
-
},
|
|
2135
|
-
recordStageAttachable(runId, stageId, attachable) {
|
|
2136
|
-
const run = context.findRun(runId);
|
|
2137
|
-
if (!run)
|
|
2138
|
-
return false;
|
|
2139
|
-
const stage = context.findStage(run, stageId);
|
|
2140
|
-
if (!stage)
|
|
2141
|
-
return false;
|
|
2142
|
-
const next = attachable === true ? true : undefined;
|
|
2143
|
-
if (stage.attachable === next)
|
|
2144
|
-
return false;
|
|
2145
|
-
if (next === undefined) {
|
|
2146
|
-
delete stage.attachable;
|
|
2147
|
-
} else {
|
|
2148
|
-
stage.attachable = next;
|
|
2149
|
-
}
|
|
2150
|
-
context.bumpAndNotify();
|
|
2151
|
-
return true;
|
|
2152
|
-
},
|
|
2153
|
-
recordStageAttached(runId, stageId, attached) {
|
|
2154
|
-
const run = context.findRun(runId);
|
|
2155
|
-
if (!run)
|
|
2156
|
-
return false;
|
|
2157
|
-
const stage = context.findStage(run, stageId);
|
|
2158
|
-
if (!stage)
|
|
2159
|
-
return false;
|
|
2160
|
-
const next = attached === true ? true : undefined;
|
|
2161
|
-
if (stage.attached === next)
|
|
2162
|
-
return false;
|
|
2163
|
-
if (next === undefined) {
|
|
2164
|
-
delete stage.attached;
|
|
2165
|
-
} else {
|
|
2166
|
-
stage.attached = next;
|
|
2167
|
-
}
|
|
2168
|
-
context.bumpAndNotify();
|
|
2169
|
-
return true;
|
|
2170
|
-
},
|
|
2171
|
-
recordStageAwaitingInput(runId, stageId, awaiting, ts) {
|
|
2172
|
-
const run = context.findRun(runId);
|
|
2173
|
-
if (!run)
|
|
2174
|
-
return false;
|
|
2175
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
2176
|
-
return false;
|
|
2177
|
-
const stage = context.findStage(run, stageId);
|
|
2178
|
-
if (!stage)
|
|
2179
|
-
return false;
|
|
2180
|
-
if (cannotAwaitInput(stage.status))
|
|
2181
|
-
return false;
|
|
2182
|
-
if (awaiting) {
|
|
2183
|
-
if (stage.status === "awaiting_input")
|
|
2184
|
-
return false;
|
|
2185
|
-
stage.status = "awaiting_input";
|
|
2186
|
-
stage.awaitingInputSince = ts ?? Date.now();
|
|
2187
|
-
} else {
|
|
2188
|
-
if (stage.pendingPrompt !== undefined)
|
|
2189
|
-
return false;
|
|
2190
|
-
if (stage.status !== "awaiting_input")
|
|
2191
|
-
return false;
|
|
2192
|
-
stage.status = "running";
|
|
2193
|
-
delete stage.awaitingInputSince;
|
|
2194
|
-
}
|
|
2195
|
-
context.bumpAndNotify();
|
|
2196
|
-
return true;
|
|
2197
|
-
},
|
|
2198
|
-
recordStageInputRequest(runId, stageId, request) {
|
|
2199
|
-
const run = context.findRun(runId);
|
|
2200
|
-
if (!run)
|
|
2201
|
-
return false;
|
|
2202
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
2203
|
-
return false;
|
|
2204
|
-
const stage = context.findStage(run, stageId);
|
|
2205
|
-
if (!stage)
|
|
2206
|
-
return false;
|
|
2207
|
-
if (isTerminalStageStatus(stage.status))
|
|
2208
|
-
return false;
|
|
2209
|
-
if (stage.inputRequest?.id === request.id)
|
|
2210
|
-
return false;
|
|
2211
|
-
stage.inputRequest = { ...request };
|
|
2212
|
-
context.bumpAndNotify();
|
|
2213
|
-
return true;
|
|
2214
|
-
},
|
|
2215
|
-
clearStageInputRequest(runId, stageId) {
|
|
2216
|
-
const run = context.findRun(runId);
|
|
2217
|
-
if (!run)
|
|
2218
|
-
return false;
|
|
2219
|
-
const stage = context.findStage(run, stageId);
|
|
2220
|
-
if (!stage || stage.inputRequest === undefined)
|
|
2221
|
-
return false;
|
|
2222
|
-
delete stage.inputRequest;
|
|
2223
|
-
context.bumpAndNotify();
|
|
2224
|
-
return true;
|
|
2225
|
-
},
|
|
2226
|
-
recordStageBlocked(runId, stageId, blockedBy) {
|
|
2227
|
-
const run = context.findRun(runId);
|
|
2228
|
-
if (!run)
|
|
2229
|
-
return false;
|
|
2230
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
2231
|
-
return false;
|
|
2232
|
-
const stage = context.findStage(run, stageId);
|
|
2233
|
-
if (!stage)
|
|
2234
|
-
return false;
|
|
2235
|
-
if (cannotBlock(stage.status))
|
|
2236
|
-
return false;
|
|
2237
|
-
if (stage.status === "blocked") {
|
|
2238
|
-
if (stage.blockedByStageId === blockedBy)
|
|
2239
|
-
return false;
|
|
2240
|
-
stage.blockedByStageId = blockedBy;
|
|
2241
|
-
} else {
|
|
2242
|
-
stage.status = "blocked";
|
|
2243
|
-
stage.blockedByStageId = blockedBy;
|
|
2244
|
-
delete stage.awaitingInputSince;
|
|
2245
|
-
}
|
|
2246
|
-
context.bumpAndNotify();
|
|
2247
|
-
return true;
|
|
2248
|
-
},
|
|
2249
|
-
recordStageUnblocked(runId, stageId) {
|
|
2250
|
-
const run = context.findRun(runId);
|
|
2251
|
-
if (!run)
|
|
2252
|
-
return false;
|
|
2253
|
-
const stage = context.findStage(run, stageId);
|
|
2254
|
-
if (stage?.status !== "blocked")
|
|
2255
|
-
return false;
|
|
2256
|
-
stage.status = "pending";
|
|
2257
|
-
delete stage.blockedByStageId;
|
|
2258
|
-
delete stage.awaitingInputSince;
|
|
2259
|
-
context.bumpAndNotify();
|
|
2260
|
-
return true;
|
|
2261
|
-
},
|
|
2262
|
-
recordStageNotice(runId, stageId, notice) {
|
|
2263
|
-
const run = context.findRun(runId);
|
|
2264
|
-
if (!run)
|
|
2265
|
-
return false;
|
|
2266
|
-
const stage = context.findStage(run, stageId);
|
|
2267
|
-
if (!stage)
|
|
2268
|
-
return false;
|
|
2269
|
-
if (!stage.notices)
|
|
2270
|
-
stage.notices = [];
|
|
2271
|
-
stage.notices.push(notice);
|
|
2272
|
-
context.bumpAndNotify();
|
|
2273
|
-
return true;
|
|
2274
|
-
},
|
|
2275
|
-
recordStagePaused(runId, stageId, pausedAt, metadata) {
|
|
2276
|
-
const run = context.findRun(runId);
|
|
2277
|
-
if (!run)
|
|
2278
|
-
return false;
|
|
2279
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
2280
|
-
return false;
|
|
2281
|
-
const stage = context.findStage(run, stageId);
|
|
2282
|
-
if (!stage)
|
|
2283
|
-
return false;
|
|
2284
|
-
if (cannotPause(stage.status)) {
|
|
2285
|
-
if (stage.status !== "paused" || metadata?.actor === undefined)
|
|
2286
|
-
return false;
|
|
2287
|
-
if (stage.pauseActor === metadata.actor)
|
|
2288
|
-
return false;
|
|
2289
|
-
stage.pauseActor = metadata.actor;
|
|
2290
|
-
context.bumpAndNotify();
|
|
2291
|
-
return false;
|
|
2292
|
-
}
|
|
2293
|
-
context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stageId));
|
|
2294
|
-
stage.status = "paused";
|
|
2295
|
-
stage.pausedAt = nextControlTimestamp(pausedAt, stage.resumedAt);
|
|
2296
|
-
stage.resumedAt = undefined;
|
|
2297
|
-
delete stage.awaitingInputSince;
|
|
2298
|
-
delete stage.resumeActor;
|
|
2299
|
-
if (metadata?.actor === undefined)
|
|
2300
|
-
delete stage.pauseActor;
|
|
2301
|
-
else
|
|
2302
|
-
stage.pauseActor = metadata.actor;
|
|
2303
|
-
context.bumpAndNotify();
|
|
2304
|
-
return true;
|
|
2305
|
-
},
|
|
2306
|
-
recordStageResumed(runId, stageId, resumedAt, metadata) {
|
|
2307
|
-
const run = context.findRun(runId);
|
|
2308
|
-
if (!run)
|
|
2309
|
-
return false;
|
|
2310
|
-
if (TERMINAL_STATUSES.has(run.status))
|
|
2311
|
-
return false;
|
|
2312
|
-
const stage = context.findStage(run, stageId);
|
|
2313
|
-
if (!stage)
|
|
2314
|
-
return false;
|
|
2315
|
-
if (stage.status !== "paused" && stage.status !== "blocked") {
|
|
2316
|
-
if (stage.status !== "running" || stage.resumedAt === undefined || metadata?.actor === undefined) {
|
|
2317
|
-
return false;
|
|
2318
|
-
}
|
|
2319
|
-
if (stage.resumeActor === metadata.actor)
|
|
2320
|
-
return false;
|
|
2321
|
-
stage.resumeActor = metadata.actor;
|
|
2322
|
-
context.bumpAndNotify();
|
|
2323
|
-
return false;
|
|
2324
|
-
}
|
|
2325
|
-
const resumedTs = nextControlTimestamp(resumedAt, stage.pausedAt);
|
|
2326
|
-
if (context.observation.liveRunIds.has(runId))
|
|
2327
|
-
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stageId));
|
|
2328
|
-
stage.status = "running";
|
|
2329
|
-
if (stage.startedAt !== undefined) {
|
|
2330
|
-
stage.pausedDurationMs = accumulatePausedDurationMs(stage.pausedDurationMs, stage.pausedAt, resumedTs);
|
|
2331
|
-
}
|
|
2332
|
-
stage.resumedAt = resumedTs;
|
|
2333
|
-
stage.pausedAt = undefined;
|
|
2334
|
-
delete stage.blockedByStageId;
|
|
2335
|
-
delete stage.awaitingInputSince;
|
|
2336
|
-
delete stage.pauseActor;
|
|
2337
|
-
if (metadata?.actor === undefined)
|
|
2338
|
-
delete stage.resumeActor;
|
|
2339
|
-
else
|
|
2340
|
-
stage.resumeActor = metadata.actor;
|
|
2341
|
-
context.bumpAndNotify();
|
|
2342
|
-
return true;
|
|
2343
|
-
}
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
// dist/builtin/workflows/src/shared/store-factory.ts
|
|
2348
|
-
function createStore() {
|
|
2349
|
-
const context = createStoreContext();
|
|
2350
|
-
const created = {
|
|
2351
|
-
[workflowObservationRuntimeKey]: context.observation,
|
|
2352
|
-
...createRunStoreMethods(context),
|
|
2353
|
-
...createPendingStageDeliveryStoreMethods(context),
|
|
2354
|
-
...createStageStoreMethods(context),
|
|
2355
|
-
...createToolNodeStoreMethods(context),
|
|
2356
|
-
...createPromptStoreMethods(context)
|
|
2357
|
-
};
|
|
2358
|
-
return created;
|
|
2359
|
-
}
|
|
2360
|
-
var SESSION_KEY = "workflows:store:v1";
|
|
2361
|
-
var singleton = createSessionScopedSingleton(SESSION_KEY, createStore);
|
|
2362
|
-
var store = singleton.facade;
|
|
2363
|
-
// dist/builtin/workflows/src/shared/workflow-artifact-env.ts
|
|
2364
|
-
var WORKFLOW_ARTIFACT_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
2365
|
-
var ENV_WORKFLOW_ARTIFACT_DIR = "ATOMIC_WORKFLOW_ARTIFACT_DIR";
|
|
2366
|
-
|
|
2367
|
-
// dist/builtin/workflows/src/shared/workflow-artifacts.ts
|
|
2368
|
-
var ARTIFACT_PRUNE_RECHECK_MS = 60 * 60 * 1000;
|
|
2369
|
-
var lastArtifactPruneAt = new Map;
|
|
2370
|
-
var pendingArtifactPrunes = new Map;
|
|
2371
|
-
function workflowArtifactRoot() {
|
|
2372
|
-
const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
2373
|
-
if (override !== undefined && override.length > 0)
|
|
2374
|
-
return override;
|
|
2375
|
-
return join(dirname(getAgentDir()), "workflows");
|
|
2376
|
-
}
|
|
2377
|
-
function workflowArtifactRunsRoot() {
|
|
2378
|
-
return join(workflowArtifactRoot(), "runs");
|
|
2379
|
-
}
|
|
2380
|
-
function safeRunId(runId) {
|
|
2381
|
-
const safe = runId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
2382
|
-
return safe.length > 0 ? safe : "run";
|
|
2383
|
-
}
|
|
2384
|
-
function workflowArtifactRunPath(runId) {
|
|
2385
|
-
return join(workflowArtifactRunsRoot(), safeRunId(runId));
|
|
2386
|
-
}
|
|
2387
|
-
function storeRunState(run) {
|
|
2388
|
-
const hasPendingInput = run.pendingPrompt !== undefined || run.stages.some((stage) => stage.status === "awaiting_input" || stage.status === "paused" || stage.status === "blocked");
|
|
2389
|
-
if (hasPendingInput || run.status === "pending" || run.status === "running" || run.status === "paused" || run.status === "blocked" || run.exitReason === "quit") {
|
|
2390
|
-
return "protected";
|
|
2391
|
-
}
|
|
2392
|
-
return "terminal";
|
|
2393
|
-
}
|
|
2394
|
-
function durableRunState(backend, runId) {
|
|
2395
|
-
const handle = backend.getLoadableWorkflow(runId);
|
|
2396
|
-
if (handle === undefined)
|
|
2397
|
-
return;
|
|
2398
|
-
if (handle.status === "running" || handle.status === "paused" || handle.status === "blocked" || handle.pendingPrompts > 0) {
|
|
2399
|
-
return "protected";
|
|
2400
|
-
}
|
|
2401
|
-
return "terminal";
|
|
2402
|
-
}
|
|
2403
|
-
function createWorkflowArtifactRunStateResolver() {
|
|
2404
|
-
const localRuns = new Map(store.runs().map((run) => [run.id, run]));
|
|
2405
|
-
const findLocalRun = (runId) => localRuns.get(runId) ?? [...localRuns.values()].find((run) => safeRunId(run.id) === runId);
|
|
2406
|
-
const protectedOwners = new Set;
|
|
2407
|
-
for (const run of localRuns.values()) {
|
|
2408
|
-
if (storeRunState(run) !== "protected")
|
|
2409
|
-
continue;
|
|
2410
|
-
let cursor = run;
|
|
2411
|
-
const visited = new Set;
|
|
2412
|
-
while (cursor !== undefined && !visited.has(cursor.id)) {
|
|
2413
|
-
visited.add(cursor.id);
|
|
2414
|
-
protectedOwners.add(safeRunId(cursor.id));
|
|
2415
|
-
const sourceId = cursor.resumedFromRunId;
|
|
2416
|
-
if (sourceId === undefined)
|
|
2417
|
-
break;
|
|
2418
|
-
protectedOwners.add(safeRunId(sourceId));
|
|
2419
|
-
cursor = findLocalRun(sourceId);
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
let backend;
|
|
2423
|
-
let backendReady = true;
|
|
2424
|
-
try {
|
|
2425
|
-
backend = getDurableBackend();
|
|
2426
|
-
} catch {
|
|
2427
|
-
backendReady = false;
|
|
2428
|
-
}
|
|
2429
|
-
return (runId) => {
|
|
2430
|
-
if (protectedOwners.has(runId))
|
|
2431
|
-
return "protected";
|
|
2432
|
-
const local = findLocalRun(runId);
|
|
2433
|
-
const localState = local === undefined ? undefined : storeRunState(local);
|
|
2434
|
-
if (!backendReady) {
|
|
2435
|
-
return localState === "protected" ? "protected" : undefined;
|
|
2436
|
-
}
|
|
2437
|
-
let durable;
|
|
2438
|
-
if (backend !== undefined) {
|
|
2439
|
-
try {
|
|
2440
|
-
durable = durableRunState(backend, runId);
|
|
2441
|
-
} catch {
|
|
2442
|
-
backendReady = false;
|
|
2443
|
-
return localState === "protected" ? "protected" : undefined;
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
if (durable === "protected" || localState === "protected")
|
|
2447
|
-
return "protected";
|
|
2448
|
-
if (durable === "terminal" || localState === "terminal")
|
|
2449
|
-
return "terminal";
|
|
2450
|
-
return "orphan";
|
|
2451
|
-
};
|
|
2452
|
-
}
|
|
2453
|
-
async function deleteTerminalDurableEntry(runId) {
|
|
2454
|
-
let backend;
|
|
2455
|
-
try {
|
|
2456
|
-
backend = getDurableBackend();
|
|
2457
|
-
} catch {
|
|
2458
|
-
return false;
|
|
2459
|
-
}
|
|
2460
|
-
try {
|
|
2461
|
-
const result = await backend.deleteWorkflowIfInactive(runId);
|
|
2462
|
-
return result.ok || result.reason === "not_found";
|
|
2463
|
-
} catch {
|
|
2464
|
-
return false;
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
async function pruneWorkflowArtifactRuns(root = workflowArtifactRunsRoot(), now = Date.now(), stateResolver) {
|
|
2468
|
-
try {
|
|
2469
|
-
const entries = await readdir(root, { withFileTypes: true, encoding: "utf8" });
|
|
2470
|
-
for (const entry of entries) {
|
|
2471
|
-
if (!entry.isDirectory())
|
|
2472
|
-
continue;
|
|
2473
|
-
const entryPath = join(root, entry.name);
|
|
2474
|
-
let metadata;
|
|
2475
|
-
try {
|
|
2476
|
-
metadata = await stat(entryPath);
|
|
2477
|
-
} catch (error) {
|
|
2478
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
2479
|
-
continue;
|
|
2480
|
-
throw error;
|
|
2481
|
-
}
|
|
2482
|
-
if (now - metadata.mtimeMs <= WORKFLOW_ARTIFACT_RETENTION_MS)
|
|
2483
|
-
continue;
|
|
2484
|
-
if (stateResolver === undefined)
|
|
2485
|
-
continue;
|
|
2486
|
-
const state = stateResolver(entry.name);
|
|
2487
|
-
if (state !== "terminal" && state !== "orphan")
|
|
2488
|
-
continue;
|
|
2489
|
-
if (state === "terminal" && !await deleteTerminalDurableEntry(entry.name))
|
|
2490
|
-
continue;
|
|
2491
|
-
await rm(entryPath, { recursive: true, force: true });
|
|
2492
|
-
}
|
|
2493
|
-
} catch (error) {
|
|
2494
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
2495
|
-
return;
|
|
2496
|
-
throw error;
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
async function pruneArtifactRootIfDue(root, now) {
|
|
2500
|
-
const pending = pendingArtifactPrunes.get(root);
|
|
2501
|
-
if (pending !== undefined) {
|
|
2502
|
-
try {
|
|
2503
|
-
await pending;
|
|
2504
|
-
} catch {}
|
|
2505
|
-
return;
|
|
2506
|
-
}
|
|
2507
|
-
const previous = lastArtifactPruneAt.get(root);
|
|
2508
|
-
if (previous !== undefined && now - previous < ARTIFACT_PRUNE_RECHECK_MS)
|
|
2509
|
-
return;
|
|
2510
|
-
const operation = pruneWorkflowArtifactRuns(root, now, createWorkflowArtifactRunStateResolver());
|
|
2511
|
-
pendingArtifactPrunes.set(root, operation);
|
|
2512
|
-
try {
|
|
2513
|
-
await operation;
|
|
2514
|
-
} catch {} finally {
|
|
2515
|
-
lastArtifactPruneAt.set(root, now);
|
|
2516
|
-
pendingArtifactPrunes.delete(root);
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
function workflowArtifactDirectoryPath(runId) {
|
|
2520
|
-
const effectiveRunId = runId ?? randomUUID2();
|
|
2521
|
-
return join(workflowArtifactRunPath(effectiveRunId), `artifact-${randomUUID2()}`);
|
|
2522
|
-
}
|
|
2523
|
-
async function ensureWorkflowArtifactDirectory(directory) {
|
|
2524
|
-
await pruneArtifactRootIfDue(workflowArtifactRunsRoot(), Date.now());
|
|
2525
|
-
await mkdir(directory, { recursive: true });
|
|
2526
|
-
return directory;
|
|
2527
|
-
}
|
|
2528
|
-
async function createWorkflowArtifactDirectory(runId) {
|
|
2529
|
-
return ensureWorkflowArtifactDirectory(workflowArtifactDirectoryPath(runId));
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
// dist/builtin/workflows/builtin/goal-convergence.ts
|
|
2533
|
-
var FRACTION_TREND_RISE_DELTA = DEFAULT_RISE_DELTA / (VERIFICATION_SCALE.max - VERIFICATION_SCALE.min);
|
|
2534
|
-
var FRACTION_TREND_FALL_DELTA = DEFAULT_FALL_DELTA / (VERIFICATION_SCALE.max - VERIFICATION_SCALE.min);
|
|
2535
|
-
function record_convergence(round) {
|
|
2536
|
-
return {
|
|
2537
|
-
unresolvedBlockingCount: round.unresolvedBlockingCount,
|
|
2538
|
-
meanFindingConfidence: round.meanFindingConfidence,
|
|
2539
|
-
fractionProven: round.fractionProven,
|
|
2540
|
-
demotions: round.demotions,
|
|
2541
|
-
usage: round.usage
|
|
2542
|
-
};
|
|
2543
|
-
}
|
|
2544
|
-
function classify_convergence(entries) {
|
|
2545
|
-
return {
|
|
2546
|
-
blocking: classify_trend(entries.map((entry) => entry.unresolvedBlockingCount)),
|
|
2547
|
-
proven: classify_trend(entries.map((entry) => entry.fractionProven), {
|
|
2548
|
-
riseDelta: FRACTION_TREND_RISE_DELTA,
|
|
2549
|
-
fallDelta: FRACTION_TREND_FALL_DELTA
|
|
2550
|
-
})
|
|
2551
|
-
};
|
|
2552
|
-
}
|
|
2553
|
-
function convergence_escalation_evidence(entries) {
|
|
2554
|
-
if (entries.length === 0)
|
|
2555
|
-
return [];
|
|
2556
|
-
const { blocking, proven } = classify_convergence(entries);
|
|
2557
|
-
if (blocking.trend === "regressing" || proven.trend === "rising" && blocking.trend !== "rising")
|
|
2558
|
-
return [];
|
|
2559
|
-
const latest = entries[entries.length - 1]?.meanFindingConfidence;
|
|
2560
|
-
return [
|
|
2561
|
-
`${entries.length} round${entries.length === 1 ? "" : "s"} recorded; no observed convergence: the blocking-count trend is ${blocking.trend}.`,
|
|
2562
|
-
`Blocking-count trend: ${blocking.trend}; raw series: ${JSON.stringify(blocking.evidence.series)}.`,
|
|
2563
|
-
`Fraction-proven trend: ${proven.trend}; raw series: ${JSON.stringify(proven.evidence.series)}.`,
|
|
2564
|
-
latest === null ? "Latest mean finding confidence: no findings were filed." : `Latest mean finding confidence: ${latest}.`,
|
|
2565
|
-
"This is escalation EVIDENCE only; it never approves or terminates anything."
|
|
2566
|
-
];
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
// dist/builtin/workflows/builtin/review-convergence.ts
|
|
2570
|
-
var FINAL_ACTION_PATTERN = /\b(?:pr|pull[- ]request|merge[- ]request|review request|github pr|create pr)\b/iu;
|
|
2571
|
-
function isFinalActionTraceability(entry) {
|
|
2572
|
-
return FINAL_ACTION_PATTERN.test(`${entry.requirement}
|
|
2573
|
-
${entry.evidence}`);
|
|
2574
|
-
}
|
|
2575
|
-
function finalActionRemaining(traceability) {
|
|
2576
|
-
return traceability.some((entry) => entry.status !== "proven" && isFinalActionTraceability(entry));
|
|
2577
|
-
}
|
|
2578
|
-
var MAX_BLOCKING_PRIORITY = 2;
|
|
2579
|
-
function findingBlocksClosure(finding) {
|
|
2580
|
-
const alignment = finding.objective_alignment;
|
|
2581
|
-
if (alignment === "beyond_objective" || alignment === "contradicts_objective") {
|
|
2582
|
-
return false;
|
|
2583
|
-
}
|
|
2584
|
-
if (alignment === "required_by_objective")
|
|
2585
|
-
return true;
|
|
2586
|
-
if (alignment !== "consistent_with_objective")
|
|
2587
|
-
return true;
|
|
2588
|
-
const priority = finding.priority;
|
|
2589
|
-
if (priority === undefined || priority === null)
|
|
2590
|
-
return true;
|
|
2591
|
-
return priority <= MAX_BLOCKING_PRIORITY;
|
|
2592
|
-
}
|
|
2593
|
-
function findingConsolidationKey(finding) {
|
|
2594
|
-
const normalizedTitle = finding.title.replace(/^\s*\[P[0-3]\]\s*/iu, "").toLowerCase().replace(/\s+/gu, " ").trim();
|
|
2595
|
-
return `${finding.code_location?.absolute_file_path ?? ""}::${normalizedTitle}`;
|
|
2596
|
-
}
|
|
2597
|
-
function consolidateFindingsBatch(reviews) {
|
|
2598
|
-
const byKey = new Map;
|
|
2599
|
-
for (const review of reviews) {
|
|
2600
|
-
for (const finding of review.findings) {
|
|
2601
|
-
const key = findingConsolidationKey(finding);
|
|
2602
|
-
const existing = byKey.get(key);
|
|
2603
|
-
if (existing === undefined) {
|
|
2604
|
-
byKey.set(key, {
|
|
2605
|
-
finding,
|
|
2606
|
-
reviewers: [review.reviewer],
|
|
2607
|
-
blocking: findingBlocksClosure(finding)
|
|
2608
|
-
});
|
|
2609
|
-
continue;
|
|
2610
|
-
}
|
|
2611
|
-
if (!existing.reviewers.includes(review.reviewer)) {
|
|
2612
|
-
existing.reviewers.push(review.reviewer);
|
|
2613
|
-
}
|
|
2614
|
-
existing.blocking = existing.blocking || findingBlocksClosure(finding);
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
return [...byKey.values()].sort((a, b) => Number(b.blocking) - Number(a.blocking));
|
|
2618
|
-
}
|
|
2619
|
-
var PREVIEW_LIMIT = 500;
|
|
2620
|
-
function rawTextPreview(rawText) {
|
|
2621
|
-
const trimmed = rawText.trim();
|
|
2622
|
-
if (trimmed.length === 0)
|
|
2623
|
-
return;
|
|
2624
|
-
return trimmed.slice(0, PREVIEW_LIMIT);
|
|
2625
|
-
}
|
|
2626
|
-
function parseFailureDiagnostics(reviewer, rawText) {
|
|
2627
|
-
const preview = rawTextPreview(rawText);
|
|
2628
|
-
const base = `Structured reviewer decision parse failed for ${reviewer}: no schema-valid JSON decision was returned.`;
|
|
2629
|
-
return preview === undefined ? [base] : [base, `Raw reviewer output preview: ${preview}`];
|
|
2630
|
-
}
|
|
2631
|
-
function errorMessage2(error) {
|
|
2632
|
-
return error instanceof Error ? error.message : String(error);
|
|
2633
|
-
}
|
|
2634
|
-
function reviewerFailureText(error) {
|
|
2635
|
-
const messages = [errorMessage2(error)];
|
|
2636
|
-
if (error instanceof AggregateError) {
|
|
2637
|
-
for (const nested of error.errors) {
|
|
2638
|
-
messages.push(errorMessage2(nested));
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
return [...new Set(messages.map((message) => message.trim()).filter(Boolean))].join(`
|
|
2642
|
-
`);
|
|
2643
|
-
}
|
|
2644
|
-
function summarizeReviewConvergence(args) {
|
|
2645
|
-
return {
|
|
2646
|
-
parsed: args.parsed,
|
|
2647
|
-
approved: args.approved,
|
|
2648
|
-
stopReviewLoop: args.stopReviewLoop,
|
|
2649
|
-
nextAction: args.nextAction,
|
|
2650
|
-
finalActionRemaining: args.finalActionRemaining ?? args.nextAction === "pull-request",
|
|
2651
|
-
diagnostics: args.diagnostics
|
|
2652
|
-
};
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
// dist/builtin/workflows/builtin/goal-reverify.ts
|
|
2656
|
-
import { Type } from "typebox";
|
|
2657
|
-
var DEFAULT_REVERIFY_THRESHOLD = 0.7;
|
|
2658
|
-
var STANDARD_CONFIRM_THRESHOLD = 10;
|
|
2659
|
-
var REQUIRED_CONFIRM_THRESHOLD = 6;
|
|
2660
|
-
var DEFAULT_REPEATS = 3;
|
|
2661
|
-
var REVERIFY_QUESTION = "Assess this specific finding against the code it cites: is it a real, objective-relevant, currently-unresolved blocker?";
|
|
2662
|
-
var reverifySchema = Type.Object({
|
|
2663
|
-
score: VERIFICATION_SCALE.schema,
|
|
2664
|
-
evidence: Type.Array(Type.String())
|
|
2665
|
-
}, { additionalProperties: false });
|
|
2666
|
-
function isRecord(value) {
|
|
2667
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2668
|
-
}
|
|
2669
|
-
function isStringArray(value) {
|
|
2670
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
2671
|
-
}
|
|
2672
|
-
function parseReport(result) {
|
|
2673
|
-
if (!isRecord(result.structured))
|
|
2674
|
-
return;
|
|
2675
|
-
const score = result.structured.score;
|
|
2676
|
-
if (typeof score !== "number" || !Number.isInteger(score) || score < VERIFICATION_SCALE.min || score > VERIFICATION_SCALE.max) {
|
|
2677
|
-
return;
|
|
2678
|
-
}
|
|
2679
|
-
const evidence = result.structured.evidence;
|
|
2680
|
-
return {
|
|
2681
|
-
score,
|
|
2682
|
-
evidence: isStringArray(evidence) ? evidence : []
|
|
2683
|
-
};
|
|
2684
|
-
}
|
|
2685
|
-
function requiredByObjective(finding) {
|
|
2686
|
-
return finding.finding.objective_alignment === "required_by_objective";
|
|
2687
|
-
}
|
|
2688
|
-
function is_reverifiable(finding, threshold = DEFAULT_REVERIFY_THRESHOLD) {
|
|
2689
|
-
const confidence = finding.finding.confidence_score;
|
|
2690
|
-
return finding.blocking && finding.reviewers.length === 1 && typeof confidence === "number" && Number.isFinite(confidence) && confidence < threshold && finding.finding.objective_alignment !== "beyond_objective" && finding.finding.objective_alignment !== "contradicts_objective";
|
|
2691
|
-
}
|
|
2692
|
-
function readPaths(finding, candidateRefs) {
|
|
2693
|
-
const codePath = finding.finding.code_location?.absolute_file_path;
|
|
2694
|
-
return [
|
|
2695
|
-
...codePath === undefined ? [] : [codePath],
|
|
2696
|
-
...candidateRefs
|
|
2697
|
-
];
|
|
2698
|
-
}
|
|
2699
|
-
function promptFor(finding, context) {
|
|
2700
|
-
const codePath = finding.finding.code_location?.absolute_file_path;
|
|
2701
|
-
const candidate = {
|
|
2702
|
-
...codePath === undefined ? {} : { path: codePath },
|
|
2703
|
-
body: [
|
|
2704
|
-
`Title: ${finding.finding.title}`,
|
|
2705
|
-
`Body: ${finding.finding.body ?? ""}`,
|
|
2706
|
-
`Code location: ${codePath ?? "not supplied"}`
|
|
2707
|
-
].join(`
|
|
2708
|
-
`)
|
|
2709
|
-
};
|
|
2710
|
-
const head = {
|
|
2711
|
-
task: `${REVERIFY_QUESTION}
|
|
2712
|
-
|
|
2713
|
-
Objective:
|
|
2714
|
-
${context.objective}`,
|
|
2715
|
-
groundTruthNote: `The objective is the contract. Verify the finding against observed code, not reviewer narration.`,
|
|
2716
|
-
candidates: [candidate],
|
|
2717
|
-
outputFormat: "Call structured_output with score (an integer from 1 to 20) and evidence (an array of observed, concise reasons)."
|
|
2718
|
-
};
|
|
2719
|
-
const prompt = build_scoring_prompt(head, {
|
|
2720
|
-
id: "finding_reverification",
|
|
2721
|
-
name: "Finding re-verification",
|
|
2722
|
-
description: REVERIFY_QUESTION
|
|
2723
|
-
});
|
|
2724
|
-
return {
|
|
2725
|
-
prompt,
|
|
2726
|
-
reads: [
|
|
2727
|
-
...readPaths(finding, context.candidateRefs),
|
|
2728
|
-
...scoring_prompt_reads(head)
|
|
2729
|
-
]
|
|
2730
|
-
};
|
|
2731
|
-
}
|
|
2732
|
-
async function runRepeat(ctx, finding, context, stageName) {
|
|
2733
|
-
try {
|
|
2734
|
-
const rendered = promptFor(finding, context);
|
|
2735
|
-
const options = {
|
|
2736
|
-
prompt: rendered.prompt,
|
|
2737
|
-
context: "fresh",
|
|
2738
|
-
reads: rendered.reads,
|
|
2739
|
-
schema: reverifySchema
|
|
2740
|
-
};
|
|
2741
|
-
return parseReport(await ctx.task(stageName, options));
|
|
2742
|
-
} catch {
|
|
2743
|
-
return;
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
async function reverify_finding(ctx, input) {
|
|
2747
|
-
if (!is_reverifiable(input.finding, input.threshold)) {
|
|
2748
|
-
throw new Error("Cannot re-verify an ineligible finding.");
|
|
2749
|
-
}
|
|
2750
|
-
const repeatCount = Number.isFinite(input.repeats) && input.repeats !== undefined ? Math.max(0, Math.floor(input.repeats)) : DEFAULT_REPEATS;
|
|
2751
|
-
const perRepeat = [];
|
|
2752
|
-
const evidence = [];
|
|
2753
|
-
const validScores = [];
|
|
2754
|
-
for (let repeat = 1;repeat <= repeatCount; repeat += 1) {
|
|
2755
|
-
let report = await runRepeat(ctx, input.finding, input.context, `reverify-${repeat}`);
|
|
2756
|
-
if (report === undefined) {
|
|
2757
|
-
report = await runRepeat(ctx, input.finding, input.context, `reverify-${repeat}-reask`);
|
|
2758
|
-
}
|
|
2759
|
-
if (report === undefined) {
|
|
2760
|
-
perRepeat.push(null);
|
|
2761
|
-
evidence.push(`Re-verification repeat ${repeat} was invalid after one re-ask; doubt defaults to confirmed.`);
|
|
2762
|
-
continue;
|
|
2763
|
-
}
|
|
2764
|
-
perRepeat.push(report.score);
|
|
2765
|
-
validScores.push(report.score);
|
|
2766
|
-
if (report.evidence.length === 0) {
|
|
2767
|
-
evidence.push(`Re-verification repeat ${repeat} scored ${report.score}/20.`);
|
|
2768
|
-
} else {
|
|
2769
|
-
evidence.push(...report.evidence);
|
|
2770
|
-
}
|
|
2771
|
-
}
|
|
2772
|
-
const meanScore = validScores.length === 0 ? 0 : validScores.reduce((total, score) => total + score, 0) / validScores.length;
|
|
2773
|
-
const validCount = validScores.length;
|
|
2774
|
-
const requiredQuorum = Math.ceil(repeatCount / 2);
|
|
2775
|
-
const demoted = requiredByObjective(input.finding) ? repeatCount > 0 && validCount === repeatCount && meanScore < REQUIRED_CONFIRM_THRESHOLD : validCount > 0 && validCount >= requiredQuorum && meanScore < STANDARD_CONFIRM_THRESHOLD;
|
|
2776
|
-
return {
|
|
2777
|
-
verdict: demoted ? "demoted" : "confirmed",
|
|
2778
|
-
meanScore,
|
|
2779
|
-
perRepeat,
|
|
2780
|
-
evidence
|
|
2781
|
-
};
|
|
2782
|
-
}
|
|
2783
|
-
function auditKey(finding) {
|
|
2784
|
-
return JSON.stringify([
|
|
2785
|
-
finding.finding.code_location?.absolute_file_path ?? "",
|
|
2786
|
-
finding.finding.title,
|
|
2787
|
-
finding.reviewers
|
|
2788
|
-
]);
|
|
2789
|
-
}
|
|
2790
|
-
function apply_reverify_results(batch, audits) {
|
|
2791
|
-
const demoted = new Set(audits.filter((audit) => audit.verdict === "demoted").map((audit) => auditKey(audit.finding)));
|
|
2792
|
-
return {
|
|
2793
|
-
batch: batch.map((entry) => demoted.has(auditKey(entry)) ? { ...entry, blocking: false } : entry),
|
|
2794
|
-
audits
|
|
2795
|
-
};
|
|
2796
|
-
}
|
|
2797
|
-
async function reverify_consolidated_batch(ctx, input) {
|
|
2798
|
-
const audits = [];
|
|
2799
|
-
for (const entry of input.batch) {
|
|
2800
|
-
if (!is_reverifiable(entry, input.threshold))
|
|
2801
|
-
continue;
|
|
2802
|
-
const result = await reverify_finding(ctx, {
|
|
2803
|
-
finding: entry,
|
|
2804
|
-
context: input.context,
|
|
2805
|
-
repeats: input.repeats,
|
|
2806
|
-
threshold: input.threshold
|
|
2807
|
-
});
|
|
2808
|
-
audits.push({ finding: entry, ...result });
|
|
2809
|
-
}
|
|
2810
|
-
return apply_reverify_results(input.batch, audits);
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
export { workflowArtifactDirectoryPath, ensureWorkflowArtifactDirectory, createWorkflowArtifactDirectory, record_convergence, convergence_escalation_evidence, finalActionRemaining, consolidateFindingsBatch, parseFailureDiagnostics, reviewerFailureText, summarizeReviewConvergence, reverify_consolidated_batch };
|