@bastani/atomic 0.9.74-alpha.1 → 0.9.75
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 +162 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +80 -0
- package/dist/builtin/workflows/README.md +5 -2
- package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
- package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.d.ts +10 -0
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
- package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
- package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/index.js +685 -295
- package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
- package/dist/bun/app-host-modules.d.ts +1 -1
- package/dist/bun/app-host-modules.d.ts.map +1 -1
- package/dist/bun/app-host-modules.js.map +1 -1
- package/dist/bun/internal-workflow-worker.d.ts +2 -0
- package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
- package/dist/bun/internal-workflow-worker.js +2 -1
- package/dist/bun/internal-workflow-worker.js.map +1 -1
- package/dist/codemode-worker.js +2 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
- package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
- package/dist/core/agent-session-blueprint-environment.js +28 -0
- package/dist/core/agent-session-blueprint-environment.js.map +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- 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-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +14 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +20 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +55 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +2 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +13 -0
- package/dist/core/async-scope.d.ts.map +1 -0
- package/dist/core/async-scope.js +20 -0
- package/dist/core/async-scope.js.map +1 -0
- package/dist/core/cache-warmer.d.ts +3 -14
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +8 -60
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/extensions/extension-work.js +2 -2
- package/dist/core/extensions/extension-work.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/ui-types.d.ts +2 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +1 -1
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +4 -2
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +6 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/preferred-providers.d.ts +19 -0
- package/dist/core/preferred-providers.d.ts.map +1 -0
- package/dist/core/preferred-providers.js +25 -0
- package/dist/core/preferred-providers.js.map +1 -0
- package/dist/core/provider-alias.d.ts.map +1 -1
- package/dist/core/provider-alias.js +4 -0
- package/dist/core/provider-alias.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
- package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/action-expressions.js +389 -0
- package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
- package/dist/core/resume/blueprint/actions.d.ts +90 -0
- package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/actions.js +818 -0
- package/dist/core/resume/blueprint/actions.js.map +1 -0
- package/dist/core/resume/blueprint/build.d.ts +102 -0
- package/dist/core/resume/blueprint/build.d.ts.map +1 -0
- package/dist/core/resume/blueprint/build.js +535 -0
- package/dist/core/resume/blueprint/build.js.map +1 -0
- package/dist/core/resume/blueprint/context.d.ts +11 -0
- package/dist/core/resume/blueprint/context.d.ts.map +1 -0
- package/dist/core/resume/blueprint/context.js +106 -0
- package/dist/core/resume/blueprint/context.js.map +1 -0
- package/dist/core/resume/blueprint/envrc.d.ts +19 -0
- package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
- package/dist/core/resume/blueprint/envrc.js +77 -0
- package/dist/core/resume/blueprint/envrc.js.map +1 -0
- package/dist/core/resume/blueprint/errors.d.ts +179 -0
- package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
- package/dist/core/resume/blueprint/errors.js +169 -0
- package/dist/core/resume/blueprint/errors.js.map +1 -0
- package/dist/core/resume/blueprint/ledger.d.ts +51 -0
- package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
- package/dist/core/resume/blueprint/ledger.js +119 -0
- package/dist/core/resume/blueprint/ledger.js.map +1 -0
- package/dist/core/resume/blueprint/notices.d.ts +14 -0
- package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
- package/dist/core/resume/blueprint/notices.js +44 -0
- package/dist/core/resume/blueprint/notices.js.map +1 -0
- package/dist/core/resume/blueprint/process.d.ts +44 -0
- package/dist/core/resume/blueprint/process.d.ts.map +1 -0
- package/dist/core/resume/blueprint/process.js +142 -0
- package/dist/core/resume/blueprint/process.js.map +1 -0
- package/dist/core/resume/blueprint/resume.d.ts +73 -0
- package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
- package/dist/core/resume/blueprint/resume.js +206 -0
- package/dist/core/resume/blueprint/resume.js.map +1 -0
- package/dist/core/resume/blueprint/schema.d.ts +26 -0
- package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
- package/dist/core/resume/blueprint/schema.js +243 -0
- package/dist/core/resume/blueprint/schema.js.map +1 -0
- package/dist/core/resume/blueprint/steps.d.ts +54 -0
- package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
- package/dist/core/resume/blueprint/steps.js +155 -0
- package/dist/core/resume/blueprint/steps.js.map +1 -0
- package/dist/core/resume/blueprint/types.d.ts +63 -0
- package/dist/core/resume/blueprint/types.d.ts.map +1 -0
- package/dist/core/resume/blueprint/types.js +2 -0
- package/dist/core/resume/blueprint/types.js.map +1 -0
- package/dist/core/resume/errors.d.ts +7 -35
- package/dist/core/resume/errors.d.ts.map +1 -1
- package/dist/core/resume/errors.js +1 -21
- package/dist/core/resume/errors.js.map +1 -1
- package/dist/core/resume/index.d.ts +12 -4
- package/dist/core/resume/index.d.ts.map +1 -1
- package/dist/core/resume/index.js +11 -4
- package/dist/core/resume/index.js.map +1 -1
- package/dist/core/resume/run-setup.d.ts +36 -15
- package/dist/core/resume/run-setup.d.ts.map +1 -1
- package/dist/core/resume/run-setup.js +70 -54
- package/dist/core/resume/run-setup.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +34 -20
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +244 -106
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/retry-policy.d.ts +19 -1
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +26 -1
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts +56 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +94 -4
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +10 -5
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +11 -0
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +10 -4
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +2 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +2 -1
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
- package/dist/core/storage/write-ahead-log.js +27 -6
- package/dist/core/storage/write-ahead-log.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/file-tool-errors.d.ts +1 -1
- package/dist/core/tools/file-tool-errors.js +1 -1
- package/dist/core/tools/file-tool-errors.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +52 -26
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +10 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +2 -2
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +12 -4
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +28 -4
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -8
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +6 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +34 -13
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
- package/dist/modes/interactive/components/provider-brand.js +67 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +8 -6
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
- package/dist/modes/interactive/interactive-extension-runtime.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-surface.d.ts +12 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +59 -21
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +23 -12
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
- package/dist/modes/interactive/login-provider-options.js +2 -1
- package/dist/modes/interactive/login-provider-options.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
- package/dist/modes/interactive-engine/isolated-runtime.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.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +2 -18
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
- package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-error-decoding.js +25 -0
- package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +12 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +12 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/codemode.md +22 -0
- package/docs/extensions/api-reference.md +27 -1
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/ui.md +1 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/guides/resume-on-any-machine.md +72 -19
- package/docs/models/evals.md +85 -17
- package/docs/models/reference.md +1 -1
- package/docs/providers.md +38 -5
- package/docs/reference/cli.md +2 -0
- package/docs/rpc/protocol.md +11 -1
- package/docs/sdk/reference.md +36 -4
- package/docs/sdk.md +2 -2
- package/docs/sessions.md +11 -1
- package/docs/settings.md +7 -2
- package/docs/skills.md +3 -3
- package/docs/storage.md +1 -1
- package/docs/tools.md +3 -1
- package/docs/workflows/api-reference.md +14 -12
- package/docs/workflows/authoring.md +29 -1
- package/docs/workflows/builtins.md +9 -1
- package/docs/workflows/operations.md +8 -8
- package/docs/worktree-snapshots.md +3 -2
- package/npm-shrinkwrap.json +83 -67
- package/package.json +7 -7
- package/schemas/settings.schema.json +3 -2
- package/dist/core/resume/setup-hook.d.ts +0 -69
- package/dist/core/resume/setup-hook.d.ts.map +0 -1
- package/dist/core/resume/setup-hook.js +0 -261
- package/dist/core/resume/setup-hook.js.map +0 -1
|
@@ -1697,7 +1697,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
1697
1697
|
const context = (action) => action();
|
|
1698
1698
|
const results = await journal.appendMany(held, [
|
|
1699
1699
|
{ event: { type: "RunStarted", payload: null }, key: "start", context },
|
|
1700
|
-
{ event: { type: "StatusChanged", payload: { status: "
|
|
1700
|
+
{ event: { type: "StatusChanged", payload: { status: "suspended" } }, context },
|
|
1701
1701
|
{ event: { type: "RunFinished", payload: null }, key: "start", context }
|
|
1702
1702
|
]);
|
|
1703
1703
|
assert.deepEqual(results.map((result) => result.status === "fulfilled" ? [result.value.status, result.value.entry.seq] : []), [
|
|
@@ -1706,7 +1706,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
1706
1706
|
["exists", 1]
|
|
1707
1707
|
]);
|
|
1708
1708
|
assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
|
|
1709
|
-
assert.equal((await journal.getRun(header.runId))?.status, "
|
|
1709
|
+
assert.equal((await journal.getRun(header.runId))?.status, "suspended");
|
|
1710
1710
|
assert.equal((await journal.takeover(header.runId, "next", held.holderId)).status, "acquired");
|
|
1711
1711
|
await assert.rejects(journal.appendMany(held, [{ event: { type: "RunFinished", payload: null }, context }]), StaleLeaseError);
|
|
1712
1712
|
assert.equal((await entries(journal)).length, 2);
|
|
@@ -1720,14 +1720,14 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
1720
1720
|
const results = await journal.appendMany(held, [
|
|
1721
1721
|
{ event: { type: "RunStarted", payload: null }, context },
|
|
1722
1722
|
{ event: { type: "StatusChanged", payload: { status: "bad\x00status" } }, context },
|
|
1723
|
-
{ event: { type: "StatusChanged", payload: { status: "
|
|
1723
|
+
{ event: { type: "StatusChanged", payload: { status: "suspended" } }, context }
|
|
1724
1724
|
]);
|
|
1725
1725
|
assert.deepEqual(results.map((result) => result.status), ["fulfilled", "rejected", "fulfilled"]);
|
|
1726
|
-
const [started, invalid,
|
|
1726
|
+
const [started, invalid, suspended] = results;
|
|
1727
1727
|
assert.ok(invalid?.status === "rejected" && invalid.reason instanceof JournalInvalidTextError);
|
|
1728
|
-
assert.deepEqual([started,
|
|
1728
|
+
assert.deepEqual([started, suspended].map((result) => result?.status === "fulfilled" ? result.value.entry.seq : undefined), [1, 2]);
|
|
1729
1729
|
assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
|
|
1730
|
-
assert.equal((await journal.getRun(header.runId))?.status, "
|
|
1730
|
+
assert.equal((await journal.getRun(header.runId))?.status, "suspended");
|
|
1731
1731
|
});
|
|
1732
1732
|
check("optional createRunWithEvents creates a run with its events atomically, or nothing", async (journal) => {
|
|
1733
1733
|
const createRunWithEvents = journal.createRunWithEvents;
|
|
@@ -1940,6 +1940,9 @@ function validateText(field, value2) {
|
|
|
1940
1940
|
if (/\p{Surrogate}/u.test(value2))
|
|
1941
1941
|
throw new JournalInvalidTextError(field, "ill-formed-unicode");
|
|
1942
1942
|
}
|
|
1943
|
+
function runStatusFromRecord(status) {
|
|
1944
|
+
return status === "waiting" ? "suspended" : status;
|
|
1945
|
+
}
|
|
1943
1946
|
function serializeJson(value2) {
|
|
1944
1947
|
const text = JSON.stringify(value2);
|
|
1945
1948
|
return text.replace(/\p{Surrogate}/gu, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
@@ -2033,13 +2036,17 @@ class MemoryRunJournal {
|
|
|
2033
2036
|
this.ensureOpen();
|
|
2034
2037
|
validateText("runId", runId);
|
|
2035
2038
|
const run = this.runs.get(runId);
|
|
2036
|
-
return run ?
|
|
2039
|
+
return run ? this.summaryOf(run) : undefined;
|
|
2037
2040
|
}
|
|
2038
2041
|
async listRuns(filter) {
|
|
2039
2042
|
this.ensureOpen();
|
|
2040
2043
|
if (filter?.cwd !== undefined)
|
|
2041
2044
|
validateText("cwd", filter.cwd);
|
|
2042
|
-
return [...this.runs.values()].filter((run) => filter?.cwd === undefined || run.header.cwd === filter.cwd).sort((a, b) => Buffer.compare(Buffer.from(a.header.runId), Buffer.from(b.header.runId))).map((run) =>
|
|
2045
|
+
return [...this.runs.values()].filter((run) => filter?.cwd === undefined || run.header.cwd === filter.cwd).sort((a, b) => Buffer.compare(Buffer.from(a.header.runId), Buffer.from(b.header.runId))).map((run) => this.summaryOf(run));
|
|
2046
|
+
}
|
|
2047
|
+
summaryOf(run) {
|
|
2048
|
+
const summary = JSON.parse(serializeJson(run.header));
|
|
2049
|
+
return { ...summary, status: runStatusFromRecord(summary.status) };
|
|
2043
2050
|
}
|
|
2044
2051
|
requireRun(runId) {
|
|
2045
2052
|
this.ensureOpen();
|
|
@@ -2548,7 +2555,7 @@ class SqlRunJournal {
|
|
|
2548
2555
|
return this.operation(async () => {
|
|
2549
2556
|
const row = await this.database.get(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
2550
2557
|
const found = row ?? await this.legacy?.find(this.database, runId);
|
|
2551
|
-
return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: found[JOURNAL_COLUMNS.status] } : undefined;
|
|
2558
|
+
return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: runStatusFromRecord(found[JOURNAL_COLUMNS.status]) } : undefined;
|
|
2552
2559
|
});
|
|
2553
2560
|
}
|
|
2554
2561
|
async listRuns(filter) {
|
|
@@ -2558,7 +2565,10 @@ class SqlRunJournal {
|
|
|
2558
2565
|
return this.operation(async () => {
|
|
2559
2566
|
const rows = await this.database.all(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} ${filter?.cwd === undefined ? "" : `WHERE ${JOURNAL_COLUMNS.cwd} = ?`} ORDER BY ${JOURNAL_COLUMNS.runId}`, ...filter?.cwd === undefined ? [] : [filter.cwd]);
|
|
2560
2567
|
const legacy = await this.legacy?.pending(this.database, filter) ?? [];
|
|
2561
|
-
return [...rows, ...legacy].map((row) => ({
|
|
2568
|
+
return [...rows, ...legacy].map((row) => ({
|
|
2569
|
+
...JSON.parse(row[JOURNAL_COLUMNS.headerJson]),
|
|
2570
|
+
status: runStatusFromRecord(row[JOURNAL_COLUMNS.status])
|
|
2571
|
+
})).sort((left, right) => left.runId < right.runId ? -1 : left.runId > right.runId ? 1 : 0);
|
|
2562
2572
|
});
|
|
2563
2573
|
}
|
|
2564
2574
|
async changeToken() {
|
|
@@ -9035,7 +9045,7 @@ function createStageStoreMethods(context) {
|
|
|
9035
9045
|
}
|
|
9036
9046
|
if (stage.status === "running" && context.observation.liveRunIds.has(runId)) {
|
|
9037
9047
|
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stage.id));
|
|
9038
|
-
} else if (stage.status === "
|
|
9048
|
+
} else if (stage.status === "suspended") {
|
|
9039
9049
|
context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stage.id));
|
|
9040
9050
|
}
|
|
9041
9051
|
context.bumpAndNotify({ runId, stageId: stage.id });
|
|
@@ -9361,7 +9371,7 @@ function createStageStoreMethods(context) {
|
|
|
9361
9371
|
const resumedTs = nextControlTimestamp(resumedAt, stage.pausedAt);
|
|
9362
9372
|
if (context.observation.liveRunIds.has(runId) && stage.wait === undefined)
|
|
9363
9373
|
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stageId));
|
|
9364
|
-
stage.status = stage.wait === undefined ? "running" : "
|
|
9374
|
+
stage.status = stage.wait === undefined ? "running" : "suspended";
|
|
9365
9375
|
if (stage.startedAt !== undefined) {
|
|
9366
9376
|
stage.pausedDurationMs = accumulatePausedDurationMs(stage.pausedDurationMs, stage.pausedAt, resumedTs);
|
|
9367
9377
|
}
|
|
@@ -13169,7 +13179,12 @@ var init_stage_session_store = __esm(() => {
|
|
|
13169
13179
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts
|
|
13170
13180
|
import {
|
|
13171
13181
|
bindSessionWorkspace,
|
|
13182
|
+
currentWorktreeRootMappings,
|
|
13183
|
+
getAgentDir as getAgentDir3,
|
|
13184
|
+
mapRestoredPath,
|
|
13185
|
+
recordRestoredWorktreeContext,
|
|
13172
13186
|
resolveWorkspace,
|
|
13187
|
+
resumeStoreDir,
|
|
13173
13188
|
SessionManager as SessionManager2,
|
|
13174
13189
|
workspaceSessionCwd
|
|
13175
13190
|
} from "@bastani/atomic";
|
|
@@ -13250,6 +13265,13 @@ async function stripWorkflowOnlyOptions2(options, defaultSessionDir, meta, pendi
|
|
|
13250
13265
|
sessionOptions.sessionManager = await SessionManager2.create(cwd, sessionDir ?? defaultSessionDir, classification);
|
|
13251
13266
|
}
|
|
13252
13267
|
}
|
|
13268
|
+
const manager = sessionOptions.sessionManager;
|
|
13269
|
+
if (manager !== undefined) {
|
|
13270
|
+
const mappings = [...manager.getWorktreeRootMappings(), ...currentWorktreeRootMappings()];
|
|
13271
|
+
const notKept = await recordRestoredWorktreeContext(manager, resumeStoreDir(sessionOptions.agentDir ?? getAgentDir3()), mapRestoredPath(cwd, mappings));
|
|
13272
|
+
if (notKept !== undefined)
|
|
13273
|
+
console.warn(`atomic-workflows: ${notKept.message}`);
|
|
13274
|
+
}
|
|
13253
13275
|
return {
|
|
13254
13276
|
...sessionOptions,
|
|
13255
13277
|
...fallbackModels?.length === 0 ? { fallbackModels: [] } : {},
|
|
@@ -16729,7 +16751,7 @@ var init_workflows_host_module = __esm(() => {
|
|
|
16729
16751
|
});
|
|
16730
16752
|
|
|
16731
16753
|
// dist/builtin/workflows/src/durable/factory.ts
|
|
16732
|
-
import { getAgentDir as
|
|
16754
|
+
import { getAgentDir as getAgentDir4, SettingsManager } from "@bastani/atomic";
|
|
16733
16755
|
import { storageSelectionKey } from "@bastani/atomic/storage";
|
|
16734
16756
|
function abandonOpening(selected, key, entry) {
|
|
16735
16757
|
if (selected.get(key) === entry)
|
|
@@ -16748,7 +16770,7 @@ function abandonOpening(selected, key, entry) {
|
|
|
16748
16770
|
async function initializeDurableBackend(options = {}) {
|
|
16749
16771
|
const owner = getDurableBackendProcessOwner();
|
|
16750
16772
|
const choice = options.journal;
|
|
16751
|
-
const agentDir = options.agentDir ??
|
|
16773
|
+
const agentDir = options.agentDir ?? getAgentDir4();
|
|
16752
16774
|
const selection = selectRunJournal({
|
|
16753
16775
|
agentDir,
|
|
16754
16776
|
journal: choice,
|
|
@@ -16819,7 +16841,7 @@ async function runRestorePreconditionFailure(journal, runId, mappings, settings,
|
|
|
16819
16841
|
for (const boundary of workflowSnapshotFrontier(await listWorkflowSnapshotBoundaries(journal, runId))) {
|
|
16820
16842
|
const here = mapWorkflowWorktreePath(boundary.root, mappings);
|
|
16821
16843
|
if (await worktreeNeedsRestore(boundary.snapshot, here, { settings, signal })) {
|
|
16822
|
-
restoring.push({ root: boundary.root,
|
|
16844
|
+
restoring.push({ root: boundary.root, remotes: boundary.snapshot.remotes });
|
|
16823
16845
|
}
|
|
16824
16846
|
}
|
|
16825
16847
|
return await runRestorePreconditionError(runId, restoring);
|
|
@@ -17143,12 +17165,12 @@ var init_workflow_artifact_env = __esm(() => {
|
|
|
17143
17165
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17144
17166
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
17145
17167
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
17146
|
-
import { getAgentDir as
|
|
17168
|
+
import { getAgentDir as getAgentDir5, getEnvValue } from "@bastani/atomic";
|
|
17147
17169
|
function workflowArtifactRoot() {
|
|
17148
17170
|
const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
17149
17171
|
if (override !== undefined && override.length > 0)
|
|
17150
17172
|
return override;
|
|
17151
|
-
return join5(dirname4(
|
|
17173
|
+
return join5(dirname4(getAgentDir5()), "workflows");
|
|
17152
17174
|
}
|
|
17153
17175
|
function workflowArtifactRunsRoot() {
|
|
17154
17176
|
return join5(workflowArtifactRoot(), "runs");
|
|
@@ -20296,6 +20318,7 @@ var init_structured_output_errors = __esm(() => {
|
|
|
20296
20318
|
import {
|
|
20297
20319
|
AgentRehydrateError,
|
|
20298
20320
|
BackgroundCompactionError,
|
|
20321
|
+
BlueprintError,
|
|
20299
20322
|
DebugError,
|
|
20300
20323
|
DecisionError,
|
|
20301
20324
|
deserializeGitHubCopilotError,
|
|
@@ -20307,17 +20330,21 @@ import {
|
|
|
20307
20330
|
IntercomBrokerError,
|
|
20308
20331
|
isGitProvisionError as isGitProvisionError3,
|
|
20309
20332
|
isSerializedBackgroundCompactionError,
|
|
20333
|
+
isSerializedMissingSessionCwdError,
|
|
20310
20334
|
LlamaServerError,
|
|
20335
|
+
MissingSessionCwdError,
|
|
20311
20336
|
parseSerializedDecisionError,
|
|
20312
20337
|
ResumeError,
|
|
20313
20338
|
rehydrateAgentRehydrateError,
|
|
20314
20339
|
rehydrateBackgroundCompactionError,
|
|
20340
|
+
rehydrateBlueprintError,
|
|
20315
20341
|
rehydrateDebugError,
|
|
20316
20342
|
rehydrateDecisionError,
|
|
20317
20343
|
rehydrateEditToolError,
|
|
20318
20344
|
rehydrateGitProvisionError as rehydrateGitProvisionError2,
|
|
20319
20345
|
rehydrateIntercomBrokerError,
|
|
20320
20346
|
rehydrateLlamaServerError,
|
|
20347
|
+
rehydrateMissingSessionCwdError,
|
|
20321
20348
|
rehydrateResumeError,
|
|
20322
20349
|
rehydrateSessionStartError,
|
|
20323
20350
|
rehydrateShellToolError,
|
|
@@ -20333,11 +20360,13 @@ import {
|
|
|
20333
20360
|
SubscriptionError,
|
|
20334
20361
|
serializeAgentRehydrateError,
|
|
20335
20362
|
serializeBackgroundCompactionError,
|
|
20363
|
+
serializeBlueprintError,
|
|
20336
20364
|
serializeDebugError,
|
|
20337
20365
|
serializeDecisionError,
|
|
20338
20366
|
serializeFileToolError,
|
|
20339
20367
|
serializeGitHubCopilotError,
|
|
20340
20368
|
serializeIntercomBrokerError,
|
|
20369
|
+
serializeMissingSessionCwdError,
|
|
20341
20370
|
serializeResumeError,
|
|
20342
20371
|
serializeSessionStartError,
|
|
20343
20372
|
serializeSubscriptionError,
|
|
@@ -20515,6 +20544,22 @@ var init_serializable_error_families = __esm(() => {
|
|
|
20515
20544
|
},
|
|
20516
20545
|
rehydrate: rehydrateResumeError
|
|
20517
20546
|
}),
|
|
20547
|
+
"missing-session-cwd": family({
|
|
20548
|
+
is: instanceOf(MissingSessionCwdError),
|
|
20549
|
+
serialize: (error) => {
|
|
20550
|
+
const { cause: _cause, ...form } = serializeMissingSessionCwdError(error);
|
|
20551
|
+
return form;
|
|
20552
|
+
},
|
|
20553
|
+
rehydrate: (form, cause) => isSerializedMissingSessionCwdError(form) ? rehydrateMissingSessionCwdError(form, cause) : undefined
|
|
20554
|
+
}),
|
|
20555
|
+
blueprint: family({
|
|
20556
|
+
is: instanceOf(BlueprintError),
|
|
20557
|
+
serialize: (error) => {
|
|
20558
|
+
const { cause: _cause, ...form } = serializeBlueprintError(error);
|
|
20559
|
+
return form;
|
|
20560
|
+
},
|
|
20561
|
+
rehydrate: rehydrateBlueprintError
|
|
20562
|
+
}),
|
|
20518
20563
|
"structured-output": family({
|
|
20519
20564
|
is: instanceOf(WorkflowStructuredOutputInferenceError),
|
|
20520
20565
|
serialize: (error) => error.toJSON(),
|
|
@@ -23437,7 +23482,7 @@ function createStageControlRegistry() {
|
|
|
23437
23482
|
if (!runMap)
|
|
23438
23483
|
return [];
|
|
23439
23484
|
const controlEntries = controlledEntries(runId);
|
|
23440
|
-
const targets = stageId ? [runMap.get(stageId)].filter((entry) => entry?.controlsDependencies === true).map((entry) => entry.handle) : controlEntries.map((entry) => entry.handle).filter((h) => h.status === "running" || h.status === "pending" || h.status === "
|
|
23485
|
+
const targets = stageId ? [runMap.get(stageId)].filter((entry) => entry?.controlsDependencies === true).map((entry) => entry.handle) : controlEntries.map((entry) => entry.handle).filter((h) => h.status === "running" || h.status === "pending" || h.status === "suspended");
|
|
23441
23486
|
const before = new Map(controlEntries.map((entry) => [entry.handle.stageId, entry.handle.status]));
|
|
23442
23487
|
for (const handle of targets) {
|
|
23443
23488
|
if (handle.status === "paused")
|
|
@@ -67493,12 +67538,260 @@ var init_loop_until_done = __esm(() => {
|
|
|
67493
67538
|
});
|
|
67494
67539
|
});
|
|
67495
67540
|
|
|
67541
|
+
// dist/builtin/workflows/builtin/open-claude-design-images.ts
|
|
67542
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
67543
|
+
import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile8 } from "node:fs/promises";
|
|
67544
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
67545
|
+
import { AuthStorage } from "@bastani/atomic";
|
|
67546
|
+
import { builtinModels } from "@bastani/pi-ai/providers/all";
|
|
67547
|
+
import { Type as Type18 } from "typebox";
|
|
67548
|
+
function parseGptImageId(id) {
|
|
67549
|
+
const groups = GPT_IMAGE_ID.exec(id)?.groups;
|
|
67550
|
+
if (groups?.version === undefined)
|
|
67551
|
+
return;
|
|
67552
|
+
return { version: groups.version.split(".").map(Number), variant: groups.variant };
|
|
67553
|
+
}
|
|
67554
|
+
function compareVersions(left, right) {
|
|
67555
|
+
const differences = Array.from({ length: Math.max(left.length, right.length) }, (_, index) => (left[index] ?? 0) - (right[index] ?? 0));
|
|
67556
|
+
return differences.find((difference) => difference !== 0) ?? 0;
|
|
67557
|
+
}
|
|
67558
|
+
function variantRank(variant) {
|
|
67559
|
+
if (variant === undefined)
|
|
67560
|
+
return 0;
|
|
67561
|
+
if (LOWER_TIER_VARIANTS.has(variant))
|
|
67562
|
+
return -1;
|
|
67563
|
+
const preferred = PREFERRED_VARIANTS.indexOf(variant);
|
|
67564
|
+
return preferred === -1 ? 1 : PREFERRED_VARIANTS.length - preferred + 1;
|
|
67565
|
+
}
|
|
67566
|
+
function compareText(left, right) {
|
|
67567
|
+
return left.localeCompare(right, "en");
|
|
67568
|
+
}
|
|
67569
|
+
function fallbackProviderRank(model) {
|
|
67570
|
+
return model.provider === PREFERRED_FALLBACK_PROVIDER ? 0 : 1;
|
|
67571
|
+
}
|
|
67572
|
+
function compareImageModels(left, right) {
|
|
67573
|
+
const leftGpt = parseGptImageId(left.id);
|
|
67574
|
+
const rightGpt = parseGptImageId(right.id);
|
|
67575
|
+
if (leftGpt !== undefined && rightGpt !== undefined) {
|
|
67576
|
+
return compareVersions(rightGpt.version, leftGpt.version) || variantRank(rightGpt.variant) - variantRank(leftGpt.variant) || compareText(left.provider, right.provider) || compareText(left.id, right.id);
|
|
67577
|
+
}
|
|
67578
|
+
if (leftGpt !== undefined)
|
|
67579
|
+
return -1;
|
|
67580
|
+
if (rightGpt !== undefined)
|
|
67581
|
+
return 1;
|
|
67582
|
+
return fallbackProviderRank(left) - fallbackProviderRank(right) || compareText(left.provider, right.provider) || compareText(right.id, left.id);
|
|
67583
|
+
}
|
|
67584
|
+
function selectReferenceImageModel(available, override) {
|
|
67585
|
+
const requested = override?.trim() ?? "";
|
|
67586
|
+
if (requested.length > 0)
|
|
67587
|
+
return available.find((model) => `${model.provider}/${model.id}` === requested);
|
|
67588
|
+
return [...available].sort(compareImageModels)[0];
|
|
67589
|
+
}
|
|
67590
|
+
function excerpt(label, text, limit) {
|
|
67591
|
+
const trimmed = text?.trim() ?? "";
|
|
67592
|
+
if (trimmed.length === 0)
|
|
67593
|
+
return;
|
|
67594
|
+
return `${label}:
|
|
67595
|
+
${trimmed.slice(0, limit).trimEnd()}`;
|
|
67596
|
+
}
|
|
67597
|
+
function buildReferenceImagePrompt(context, direction) {
|
|
67598
|
+
return [
|
|
67599
|
+
`A finished ${SURFACE_BY_OUTPUT_TYPE[context.outputType]} for: ${context.brief.trim()}`,
|
|
67600
|
+
"Render the surface edge to edge with crisp, readable text and real, brief-specific content. No browser window, device, desk or poster framing, and no lorem ipsum.",
|
|
67601
|
+
`Direction: ${direction.composition}`,
|
|
67602
|
+
excerpt("Curated references (inspiration to adapt into this product; do not copy their layout or content)", context.curatedReferences, REFERENCES_EXCERPT_CHARS),
|
|
67603
|
+
excerpt("Design system (DESIGN.md)", context.designContext, DESIGN_EXCERPT_CHARS),
|
|
67604
|
+
excerpt("Product context (PRODUCT.md)", context.productContext, PRODUCT_EXCERPT_CHARS),
|
|
67605
|
+
"Keep the palette, typography and component character the context describes; the direction changes only composition and emphasis."
|
|
67606
|
+
].filter((section) => section !== undefined).join(`
|
|
67607
|
+
|
|
67608
|
+
`);
|
|
67609
|
+
}
|
|
67610
|
+
async function readOptionalText(path) {
|
|
67611
|
+
try {
|
|
67612
|
+
return await readFile5(path, "utf8");
|
|
67613
|
+
} catch (error) {
|
|
67614
|
+
const code = error.code;
|
|
67615
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
67616
|
+
return;
|
|
67617
|
+
throw error;
|
|
67618
|
+
}
|
|
67619
|
+
}
|
|
67620
|
+
function firstWritableImage(output) {
|
|
67621
|
+
for (const block of output) {
|
|
67622
|
+
if (block.type !== "image" || block.data.length === 0)
|
|
67623
|
+
continue;
|
|
67624
|
+
const extension = IMAGE_EXTENSIONS.get(block.mimeType);
|
|
67625
|
+
if (extension !== undefined)
|
|
67626
|
+
return { data: block.data, extension };
|
|
67627
|
+
}
|
|
67628
|
+
return;
|
|
67629
|
+
}
|
|
67630
|
+
async function renderDirection(input) {
|
|
67631
|
+
const { provider, model, prompt, outputBase, signal } = input;
|
|
67632
|
+
let result;
|
|
67633
|
+
try {
|
|
67634
|
+
result = await provider.generateImages(model, { input: [{ type: "text", text: prompt }] }, {
|
|
67635
|
+
signal,
|
|
67636
|
+
quality: "high",
|
|
67637
|
+
size: IMAGE_SIZE,
|
|
67638
|
+
n: 1,
|
|
67639
|
+
timeoutMs: IMAGE_REQUEST_TIMEOUT_MS,
|
|
67640
|
+
maxRetries: IMAGE_REQUEST_MAX_RETRIES
|
|
67641
|
+
});
|
|
67642
|
+
} catch {
|
|
67643
|
+
signal.throwIfAborted();
|
|
67644
|
+
return { failure: { reason: "unexpected-error" } };
|
|
67645
|
+
}
|
|
67646
|
+
signal.throwIfAborted();
|
|
67647
|
+
if (result.stopReason !== "stop") {
|
|
67648
|
+
return {
|
|
67649
|
+
failure: {
|
|
67650
|
+
reason: result.error?.code ?? "unclassified",
|
|
67651
|
+
...result.error === undefined ? {} : { retryable: result.error.retryable }
|
|
67652
|
+
}
|
|
67653
|
+
};
|
|
67654
|
+
}
|
|
67655
|
+
const image = firstWritableImage(result.output);
|
|
67656
|
+
if (image === undefined)
|
|
67657
|
+
return {};
|
|
67658
|
+
const path = `${outputBase}.${image.extension}`;
|
|
67659
|
+
try {
|
|
67660
|
+
await mkdir4(dirname14(path), { recursive: true });
|
|
67661
|
+
await writeFile8(path, Buffer.from(image.data, "base64"));
|
|
67662
|
+
} catch {
|
|
67663
|
+
return { failure: { reason: "write-failed" } };
|
|
67664
|
+
}
|
|
67665
|
+
return { path };
|
|
67666
|
+
}
|
|
67667
|
+
async function loadPromptContext(request) {
|
|
67668
|
+
const [productContext, designContext] = await Promise.all([
|
|
67669
|
+
readOptionalText(join25(request.workflowCwd, "PRODUCT.md")),
|
|
67670
|
+
readOptionalText(join25(request.workflowCwd, "DESIGN.md"))
|
|
67671
|
+
]);
|
|
67672
|
+
return {
|
|
67673
|
+
brief: request.brief,
|
|
67674
|
+
outputType: request.outputType,
|
|
67675
|
+
curatedReferences: request.curatedReferences,
|
|
67676
|
+
productContext,
|
|
67677
|
+
designContext
|
|
67678
|
+
};
|
|
67679
|
+
}
|
|
67680
|
+
function directionOutputBase(artifactDir, index, direction) {
|
|
67681
|
+
return join25(artifactDir, REFERENCE_IMAGES_DIRNAME, `${String(index + 1).padStart(2, "0")}-${direction.slug}`);
|
|
67682
|
+
}
|
|
67683
|
+
async function renderReferenceImages(request, provider, model, signal) {
|
|
67684
|
+
const promptContext = await loadPromptContext(request);
|
|
67685
|
+
const outcomes = await Promise.all(REFERENCE_IMAGE_DIRECTIONS.map((direction, index) => renderDirection({
|
|
67686
|
+
provider,
|
|
67687
|
+
model,
|
|
67688
|
+
prompt: buildReferenceImagePrompt(promptContext, direction),
|
|
67689
|
+
outputBase: directionOutputBase(request.artifactDir, index, direction),
|
|
67690
|
+
signal
|
|
67691
|
+
})));
|
|
67692
|
+
const modelId = `${model.provider}/${model.id}`;
|
|
67693
|
+
const paths = outcomes.flatMap(({ path }) => path === undefined ? [] : [path]);
|
|
67694
|
+
if (paths.length > 0)
|
|
67695
|
+
return { status: "generated", model: modelId, paths };
|
|
67696
|
+
const failure = outcomes.find((outcome) => outcome.failure !== undefined)?.failure;
|
|
67697
|
+
return {
|
|
67698
|
+
status: "failed",
|
|
67699
|
+
reason: failure?.reason ?? "no-images-written",
|
|
67700
|
+
model: modelId,
|
|
67701
|
+
paths: [],
|
|
67702
|
+
...failure?.retryable === undefined ? {} : { retryable: failure.retryable }
|
|
67703
|
+
};
|
|
67704
|
+
}
|
|
67705
|
+
function skipped(reason) {
|
|
67706
|
+
return { status: "skipped", reason, paths: [] };
|
|
67707
|
+
}
|
|
67708
|
+
async function generateReferenceImages(request, createProvider, signal) {
|
|
67709
|
+
try {
|
|
67710
|
+
const provider = await createProvider();
|
|
67711
|
+
const available = await provider.availableImageModels(signal);
|
|
67712
|
+
if (available.length === 0)
|
|
67713
|
+
return skipped("no-image-model");
|
|
67714
|
+
const model = selectReferenceImageModel(available, request.imageModel);
|
|
67715
|
+
if (model === undefined)
|
|
67716
|
+
return skipped("image-model-unavailable");
|
|
67717
|
+
return await renderReferenceImages(request, provider, model, signal);
|
|
67718
|
+
} catch {
|
|
67719
|
+
signal.throwIfAborted();
|
|
67720
|
+
return { status: "failed", reason: "unexpected-error", paths: [] };
|
|
67721
|
+
}
|
|
67722
|
+
}
|
|
67723
|
+
async function createBuiltinReferenceImageProvider(credentials = AuthStorage.create()) {
|
|
67724
|
+
const models = builtinModels({ credentials });
|
|
67725
|
+
return {
|
|
67726
|
+
availableImageModels: (signal) => models.getAvailableOfType("image", undefined, { signal }),
|
|
67727
|
+
generateImages: (model, context, options) => models.generateImages(model, context, options)
|
|
67728
|
+
};
|
|
67729
|
+
}
|
|
67730
|
+
async function runReferenceImagesStep(tool, request, deps = {}) {
|
|
67731
|
+
const createProvider = deps.createImageProvider ?? createBuiltinReferenceImageProvider;
|
|
67732
|
+
const outcome = await tool("reference-images", {
|
|
67733
|
+
brief: request.brief,
|
|
67734
|
+
outputType: request.outputType,
|
|
67735
|
+
artifactDir: request.artifactDir,
|
|
67736
|
+
...request.imageModel === undefined ? {} : { imageModel: request.imageModel }
|
|
67737
|
+
}, ({ signal }) => generateReferenceImages(request, createProvider, signal), { timeoutMs: REFERENCE_IMAGES_TOOL_TIMEOUT_MS, failureMode: "return" });
|
|
67738
|
+
return outcome.ok ? outcome.value : { status: "failed", reason: "tool-failed", paths: [] };
|
|
67739
|
+
}
|
|
67740
|
+
function existingReferenceImagePaths(status) {
|
|
67741
|
+
return status.status === "generated" ? status.paths.filter((path) => existsSync8(path)) : [];
|
|
67742
|
+
}
|
|
67743
|
+
var referenceImagesStatusSchema, REFERENCE_IMAGES_DIRNAME = "references", REFERENCE_IMAGES_TOOL_TIMEOUT_MS, IMAGE_REQUEST_TIMEOUT_MS, IMAGE_REQUEST_MAX_RETRIES = 1, IMAGE_SIZE = "1536x1024", PRODUCT_EXCERPT_CHARS = 1000, DESIGN_EXCERPT_CHARS = 1500, REFERENCES_EXCERPT_CHARS = 1500, REFERENCE_IMAGE_DIRECTIONS, SURFACE_BY_OUTPUT_TYPE, GPT_IMAGE_ID, PREFERRED_VARIANTS, LOWER_TIER_VARIANTS, PREFERRED_FALLBACK_PROVIDER = "openrouter", IMAGE_EXTENSIONS;
|
|
67744
|
+
var init_open_claude_design_images = __esm(() => {
|
|
67745
|
+
referenceImagesStatusSchema = Type18.Object({
|
|
67746
|
+
status: Type18.Union([Type18.Literal("skipped"), Type18.Literal("generated"), Type18.Literal("failed")]),
|
|
67747
|
+
reason: Type18.Optional(Type18.String()),
|
|
67748
|
+
model: Type18.Optional(Type18.String()),
|
|
67749
|
+
paths: Type18.Array(Type18.String()),
|
|
67750
|
+
retryable: Type18.Optional(Type18.Boolean())
|
|
67751
|
+
}, {
|
|
67752
|
+
additionalProperties: false,
|
|
67753
|
+
description: "Outcome of the reference image step: status (skipped, generated, or failed), the reason, the model used, the image paths under <artifact_dir>/references/, and whether a failure is retryable."
|
|
67754
|
+
});
|
|
67755
|
+
REFERENCE_IMAGES_TOOL_TIMEOUT_MS = 15 * 60000;
|
|
67756
|
+
IMAGE_REQUEST_TIMEOUT_MS = 5 * 60000;
|
|
67757
|
+
REFERENCE_IMAGE_DIRECTIONS = [
|
|
67758
|
+
{
|
|
67759
|
+
slug: "reference-led",
|
|
67760
|
+
composition: "Reference-led. Stay closest to the curated references and the project's design system: lead with the composition the strongest reference uses and show the product concept it implies."
|
|
67761
|
+
},
|
|
67762
|
+
{
|
|
67763
|
+
slug: "brand-forward",
|
|
67764
|
+
composition: "Brand-forward. One dominant, memorable focal move at large scale carries the brand; generous space, and every other region holds still at real reading size."
|
|
67765
|
+
},
|
|
67766
|
+
{
|
|
67767
|
+
slug: "information-dense",
|
|
67768
|
+
composition: "Information-dense. Summary-led, with a compact structured grid and a tight hierarchy that shows more real content at real reading size."
|
|
67769
|
+
}
|
|
67770
|
+
];
|
|
67771
|
+
SURFACE_BY_OUTPUT_TYPE = {
|
|
67772
|
+
prototype: "desktop web app screen",
|
|
67773
|
+
wireframe: "high-fidelity desktop screen",
|
|
67774
|
+
page: "desktop web page",
|
|
67775
|
+
component: "desktop screen showing the component in two or three representative contexts",
|
|
67776
|
+
theme: "representative product screen showing the theme applied across navigation, type, color and components",
|
|
67777
|
+
tokens: "style-guide screen showing the color, type and spacing tokens applied to real components"
|
|
67778
|
+
};
|
|
67779
|
+
GPT_IMAGE_ID = /^(?:[^/]+\/)?gpt-image-(?<version>\d+(?:\.\d+)*)(?:-(?<variant>.+))?$/;
|
|
67780
|
+
PREFERRED_VARIANTS = ["flare", "sunburst"];
|
|
67781
|
+
LOWER_TIER_VARIANTS = new Set(["mini", "nano"]);
|
|
67782
|
+
IMAGE_EXTENSIONS = new Map([
|
|
67783
|
+
["image/png", "png"],
|
|
67784
|
+
["image/jpeg", "jpg"],
|
|
67785
|
+
["image/webp", "webp"]
|
|
67786
|
+
]);
|
|
67787
|
+
});
|
|
67788
|
+
|
|
67496
67789
|
// dist/builtin/workflows/builtin/open-claude-design-utils.ts
|
|
67497
67790
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
67498
67791
|
import { mkdirSync as mkdirSync7 } from "node:fs";
|
|
67499
67792
|
import { tmpdir, userInfo } from "node:os";
|
|
67500
|
-
import { join as
|
|
67501
|
-
import { Type as
|
|
67793
|
+
import { dirname as dirname15, join as join26, relative as relative8, sep as sep9 } from "node:path";
|
|
67794
|
+
import { Type as Type19 } from "typebox";
|
|
67502
67795
|
import { createChildProcessEnvironment as createChildProcessEnvironment4 } from "@bastani/atomic";
|
|
67503
67796
|
function taggedPrompt3(sections) {
|
|
67504
67797
|
return sections.map(([tag, content]) => {
|
|
@@ -67526,6 +67819,12 @@ function discoveryDecisionFromResult(result, fallbackBrief) {
|
|
|
67526
67819
|
references
|
|
67527
67820
|
};
|
|
67528
67821
|
}
|
|
67822
|
+
function referenceImageFileUrl(path) {
|
|
67823
|
+
return `file://${path}`;
|
|
67824
|
+
}
|
|
67825
|
+
function referenceImageRelativeSrc(specPath, imagePath) {
|
|
67826
|
+
return relative8(dirname15(specPath), imagePath).split(sep9).join("/");
|
|
67827
|
+
}
|
|
67529
67828
|
function joinResults(results) {
|
|
67530
67829
|
return results.map((result) => `### ${result.name}
|
|
67531
67830
|
|
|
@@ -67540,32 +67839,32 @@ function tmpArtifactBase() {
|
|
|
67540
67839
|
try {
|
|
67541
67840
|
user = userInfo().username.replace(/[^A-Za-z0-9._-]/g, "_") || "default";
|
|
67542
67841
|
} catch {}
|
|
67543
|
-
return
|
|
67842
|
+
return join26(tmpdir(), `open-claude-design-${user}`);
|
|
67544
67843
|
}
|
|
67545
67844
|
function prepareArtifactDir(cwd = process.cwd()) {
|
|
67546
67845
|
const runId = `${new Date().toISOString().replace(/[:.]/g, "-")}-${Math.random().toString(36).slice(2, 8)}`;
|
|
67547
67846
|
const tmpCandidates = [
|
|
67548
|
-
|
|
67549
|
-
|
|
67847
|
+
join26(tmpArtifactBase(), runId),
|
|
67848
|
+
join26(tmpdir(), "open-claude-design", runId)
|
|
67550
67849
|
];
|
|
67551
|
-
const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [
|
|
67850
|
+
const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [join26(cwd, "specs", "design", runId), ...tmpCandidates];
|
|
67552
67851
|
for (const candidate of candidates) {
|
|
67553
67852
|
try {
|
|
67554
67853
|
mkdirSync7(candidate, { recursive: true });
|
|
67555
67854
|
return {
|
|
67556
67855
|
runId,
|
|
67557
67856
|
artifactDir: candidate,
|
|
67558
|
-
previewPath:
|
|
67559
|
-
specPath:
|
|
67857
|
+
previewPath: join26(candidate, "preview.html"),
|
|
67858
|
+
specPath: join26(candidate, "spec.html")
|
|
67560
67859
|
};
|
|
67561
67860
|
} catch {}
|
|
67562
67861
|
}
|
|
67563
|
-
const fallback =
|
|
67862
|
+
const fallback = join26(tmpArtifactBase(), runId);
|
|
67564
67863
|
return {
|
|
67565
67864
|
runId,
|
|
67566
67865
|
artifactDir: fallback,
|
|
67567
|
-
previewPath:
|
|
67568
|
-
specPath:
|
|
67866
|
+
previewPath: join26(fallback, "preview.html"),
|
|
67867
|
+
specPath: join26(fallback, "spec.html")
|
|
67569
67868
|
};
|
|
67570
67869
|
}
|
|
67571
67870
|
function ensureAgentBrowser() {
|
|
@@ -67670,10 +67969,10 @@ var init_open_claude_design_utils = __esm(() => {
|
|
|
67670
67969
|
"theme",
|
|
67671
67970
|
"tokens"
|
|
67672
67971
|
];
|
|
67673
|
-
discoveryDecisionSchema =
|
|
67674
|
-
brief:
|
|
67675
|
-
output_type:
|
|
67676
|
-
references:
|
|
67972
|
+
discoveryDecisionSchema = Type19.Object({
|
|
67973
|
+
brief: Type19.String(),
|
|
67974
|
+
output_type: Type19.Union([...OUTPUT_TYPES].map((value2) => Type19.Literal(value2))),
|
|
67975
|
+
references: Type19.Array(Type19.String())
|
|
67677
67976
|
}, { additionalProperties: false });
|
|
67678
67977
|
HTML_PREVIEW_RULES = [
|
|
67679
67978
|
"Produce one self-contained HTML document: inline CSS in <style> and JS in <script>; make no external requests except explicitly required Google Fonts.",
|
|
@@ -67867,9 +68166,18 @@ ${input.event.raw}
|
|
|
67867
68166
|
`);
|
|
67868
68167
|
}
|
|
67869
68168
|
function buildLiveSessionStartPrompt(input) {
|
|
68169
|
+
const referenceImagePaths = input.referenceImagePaths ?? [];
|
|
67870
68170
|
return [
|
|
67871
68171
|
`<preview_path>${input.previewPath}</preview_path>`,
|
|
67872
68172
|
`<preview_file_url>${input.previewFileUrl}</preview_file_url>`,
|
|
68173
|
+
...referenceImagePaths.length > 0 ? [
|
|
68174
|
+
[
|
|
68175
|
+
"<reference_images>",
|
|
68176
|
+
...referenceImagePaths.map((path) => `${path} (${referenceImageFileUrl(path)})`),
|
|
68177
|
+
"</reference_images>"
|
|
68178
|
+
].join(`
|
|
68179
|
+
`)
|
|
68180
|
+
] : [],
|
|
67873
68181
|
`<browser_use_guidelines>${input.browserBootstrapRules}</browser_use_guidelines>`,
|
|
67874
68182
|
"<role>You are an opinionated staff design engineer opening an impeccable `live` review session.</role>",
|
|
67875
68183
|
[
|
|
@@ -67884,6 +68192,9 @@ function buildLiveSessionStartPrompt(input) {
|
|
|
67884
68192
|
"2. Print the live `http://` review URL in plain text, plus the preview file URL as the manual fallback, so anyone attaching to this run can find the review.",
|
|
67885
68193
|
"3. Directly under the URL, print how the user ends the review, in plain text: click exit in the Impeccable overlay, close the browser tab, or say `exit live`. State that the review waits indefinitely until they do, and that ending it exports the design as it then stands, with no further round.",
|
|
67886
68194
|
"4. Do NOT start a poll loop. The workflow owns polling and will call you back for each event that needs you. Ending your turn does not end the review.",
|
|
68195
|
+
...referenceImagePaths.length > 0 ? [
|
|
68196
|
+
"5. Under the review URL, also print each <reference_images> path and file URL in plain text, labelled as the AI-generated design directions the preview was built from, so the user can open them beside the preview. Leave the live review tab on the preview."
|
|
68197
|
+
] : [],
|
|
67887
68198
|
"</instructions>"
|
|
67888
68199
|
].join(`
|
|
67889
68200
|
`),
|
|
@@ -67894,13 +68205,14 @@ function buildLiveSessionStartPrompt(input) {
|
|
|
67894
68205
|
}
|
|
67895
68206
|
var MODEL_EVENTS, LEGACY_REPLY_STATUSES, LIVE_POLL_VERB = "live-poll";
|
|
67896
68207
|
var init_open_claude_design_live_protocol = __esm(() => {
|
|
68208
|
+
init_open_claude_design_utils();
|
|
67897
68209
|
MODEL_EVENTS = new Set(["generate", "steer", "manual_edit_apply", "variant_mount_failed"]);
|
|
67898
68210
|
LEGACY_REPLY_STATUSES = new Set(["done", "error", "complete", "discard", "discarded"]);
|
|
67899
68211
|
});
|
|
67900
68212
|
|
|
67901
68213
|
// dist/builtin/workflows/builtin/open-claude-design-setup.ts
|
|
67902
68214
|
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync5 } from "node:fs";
|
|
67903
|
-
import { join as
|
|
68215
|
+
import { join as join27 } from "node:path";
|
|
67904
68216
|
function renderDiscoveryContext(discovery) {
|
|
67905
68217
|
return [
|
|
67906
68218
|
`Confirmed design brief: ${discovery.brief}`,
|
|
@@ -67965,10 +68277,10 @@ async function runDiscoveryAndInit(args) {
|
|
|
67965
68277
|
};
|
|
67966
68278
|
}
|
|
67967
68279
|
function designContextPath(artifactDir) {
|
|
67968
|
-
return
|
|
68280
|
+
return join27(artifactDir, DESIGN_CONTEXT_FILENAME);
|
|
67969
68281
|
}
|
|
67970
68282
|
function referencesBriefPath(artifactDir) {
|
|
67971
|
-
return
|
|
68283
|
+
return join27(artifactDir, REFERENCES_BRIEF_FILENAME);
|
|
67972
68284
|
}
|
|
67973
68285
|
function buildReferenceDiscoveryPrompt(args) {
|
|
67974
68286
|
const siteList = REFERENCE_DESIGN_SITES.map((site, index) => `${index + 1}. ${site.name} — ${site.url}`).join(`
|
|
@@ -67994,8 +68306,8 @@ function buildReferenceDiscoveryPrompt(args) {
|
|
|
67994
68306
|
[
|
|
67995
68307
|
"Use the agent-browser skill to open each gallery; if `agent-browser` reports a missing browser executable, follow the bootstrap rules and retry once.",
|
|
67996
68308
|
"From each gallery, choose 1-3 fitting designs and CLICK INTO each actual live or project-detail page; do not capture only the grid or thumbnail.",
|
|
67997
|
-
`Capture motion across the entire page: start \`agent-browser record start ${
|
|
67998
|
-
`Also run \`agent-browser screenshot ${
|
|
68309
|
+
`Capture motion across the entire page: start \`agent-browser record start ${join27(args.artifactDir, "ref-<site>-<n>.webm")}\`, scroll smoothly in small increments with waits (using repeated \`agent-browser scroll down 600\` or \`agent-browser mouse wheel 600\`) so animations fire and lazy content loads, then run \`agent-browser record stop\`.`,
|
|
68310
|
+
`Also run \`agent-browser screenshot ${join27(args.artifactDir, "ref-<site>-<n>.png")} --full\`; this still is the minimum when video is unavailable.`,
|
|
67999
68311
|
"Record the actual destination URL, title, and author. For each reference, cite observed layout, typography, color, spacing, and motion traits rather than inferred traits.",
|
|
68000
68312
|
"Assess fit against DESIGN.md, PRODUCT.md, and the ds-* discovery evidence in the design-context file; prefer on-brand references and flag departures.",
|
|
68001
68313
|
"Use ask_user_question to ask which reference direction they prefer, offering 2-4 strongest options plus `None of these fit`. If none fit, ask them to provide a reference image, screenshot, URL, or local file path and record the answer.",
|
|
@@ -68035,11 +68347,17 @@ function persistDesignContext(artifactDir, content) {
|
|
|
68035
68347
|
writeRequiredContextArtifact(artifactDir, designContextPath(artifactDir), content, "design-context");
|
|
68036
68348
|
}
|
|
68037
68349
|
function buildLiveReviewGateMessage(args) {
|
|
68350
|
+
const referenceImagePaths = args.referenceImagePaths ?? [];
|
|
68038
68351
|
return [
|
|
68039
68352
|
`Design review session ${args.round} is ready for your browser review.`,
|
|
68040
68353
|
"",
|
|
68041
68354
|
`Preview file: ${args.previewPath}`,
|
|
68042
68355
|
`Preview URL: ${args.previewFileUrl}`,
|
|
68356
|
+
...referenceImagePaths.length > 0 ? [
|
|
68357
|
+
"",
|
|
68358
|
+
"Reference images (AI-generated design directions the preview was built from):",
|
|
68359
|
+
...referenceImagePaths.map((path) => `- ${path} (${referenceImageFileUrl(path)})`)
|
|
68360
|
+
] : [],
|
|
68043
68361
|
"",
|
|
68044
68362
|
`"${LIVE_REVIEW_GATE_OPTIONS[0]}" opens an interactive browser session; the session-start stage prints the live http:// review URL as soon as its server is up (attach with /workflow connect to see it, or open the preview URL above directly).`,
|
|
68045
68363
|
"The session is unbounded: pick elements, accept variants, and steer for as long as you like, and everything you accept lands in the preview as you go.",
|
|
@@ -68075,7 +68393,7 @@ function forkContinuationOptions2(sessionId) {
|
|
|
68075
68393
|
return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
|
|
68076
68394
|
}
|
|
68077
68395
|
async function refineOpenClaudeDesign(options) {
|
|
68078
|
-
const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig, workflowCwd } = options;
|
|
68396
|
+
const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig, workflowCwd } = options;
|
|
68079
68397
|
const importContext = options.importContext ?? "";
|
|
68080
68398
|
const generated = await designContext.task("generate-1", {
|
|
68081
68399
|
prompt: buildInitialGeneratePrompt({
|
|
@@ -68084,12 +68402,14 @@ async function refineOpenClaudeDesign(options) {
|
|
|
68084
68402
|
previewPath,
|
|
68085
68403
|
designContextFile,
|
|
68086
68404
|
referencesFile,
|
|
68405
|
+
referenceImagePaths,
|
|
68087
68406
|
importContext
|
|
68088
68407
|
}),
|
|
68089
|
-
reads: [designContextFile, referencesFile],
|
|
68408
|
+
reads: [designContextFile, referencesFile, ...referenceImagePaths],
|
|
68409
|
+
...referenceImagePaths.length > 0 ? { taskNeeds: { needsImages: true } } : {},
|
|
68090
68410
|
...designModelConfig
|
|
68091
68411
|
});
|
|
68092
|
-
const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
|
|
68412
|
+
const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl, referenceImagePaths }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
|
|
68093
68413
|
if (isUiUnavailableRejection(error))
|
|
68094
68414
|
return LIVE_REVIEW_GATE_OPTIONS[0];
|
|
68095
68415
|
throw error;
|
|
@@ -68101,6 +68421,7 @@ async function refineOpenClaudeDesign(options) {
|
|
|
68101
68421
|
reviewStageName: "user-feedback-1",
|
|
68102
68422
|
previewPath,
|
|
68103
68423
|
previewFileUrl,
|
|
68424
|
+
referenceImagePaths,
|
|
68104
68425
|
browserBootstrapRules,
|
|
68105
68426
|
designModelConfig,
|
|
68106
68427
|
workflowCwd
|
|
@@ -68109,10 +68430,10 @@ async function refineOpenClaudeDesign(options) {
|
|
|
68109
68430
|
return { latestDesign: generated.text };
|
|
68110
68431
|
}
|
|
68111
68432
|
async function runLiveReviewSession(options) {
|
|
68112
|
-
const { designContext, round, reviewStageName, previewPath, previewFileUrl, browserBootstrapRules, designModelConfig, workflowCwd } = options;
|
|
68433
|
+
const { designContext, round, reviewStageName, previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, designModelConfig, workflowCwd } = options;
|
|
68113
68434
|
let sessionId;
|
|
68114
68435
|
const start = await designContext.task(`${reviewStageName}-start`, {
|
|
68115
|
-
prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, browserBootstrapRules, round }),
|
|
68436
|
+
prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, round }),
|
|
68116
68437
|
...designModelConfig
|
|
68117
68438
|
});
|
|
68118
68439
|
sessionId = start.sessionId;
|
|
@@ -68136,6 +68457,7 @@ async function runLiveReviewSession(options) {
|
|
|
68136
68457
|
}
|
|
68137
68458
|
}
|
|
68138
68459
|
function buildInitialGeneratePrompt(args) {
|
|
68460
|
+
const hasReferenceImages = args.referenceImagePaths.length > 0;
|
|
68139
68461
|
return taggedPrompt3([
|
|
68140
68462
|
["design_brief", args.prompt],
|
|
68141
68463
|
[
|
|
@@ -68147,6 +68469,7 @@ function buildInitialGeneratePrompt(args) {
|
|
|
68147
68469
|
"reference_inspiration_file",
|
|
68148
68470
|
`Read the file at ${args.referencesFile} for the curated reference inspiration to heavily emulate.`
|
|
68149
68471
|
],
|
|
68472
|
+
...hasReferenceImages ? [["reference_images", renderReferenceImagesForGeneration(args.referenceImagePaths)]] : [],
|
|
68150
68473
|
["reference_precedence", REFERENCE_PRECEDENCE],
|
|
68151
68474
|
["preview_artifact_path", args.previewPath],
|
|
68152
68475
|
["html_rules", HTML_PREVIEW_RULES],
|
|
@@ -68162,6 +68485,7 @@ function buildInitialGeneratePrompt(args) {
|
|
|
68162
68485
|
`First read the design-context and reference-inspiration files named above; they are the design system and reference authority for every decision. If a file is missing, say so and proceed from the brief.`,
|
|
68163
68486
|
`Create the HTML artifact exactly at ${args.previewPath}.`,
|
|
68164
68487
|
"Follow <reference_precedence>; heavily reference the reference-inspiration file without copying wholesale or inventing traits.",
|
|
68488
|
+
...hasReferenceImages ? [REFERENCE_IMAGE_GENERATION_RULE] : [],
|
|
68165
68489
|
`Build the requested output_type (${args.outputType}): render full realistic layouts for prototypes/pages, or the component in at least three representative contexts.`,
|
|
68166
68490
|
"Include structure, states, accessibility, responsive behavior, and integration notes as HTML comments so the preview stays clean.",
|
|
68167
68491
|
"Use project language rather than generic placeholders when conventions exist. Add no features or abstractions beyond this design brief."
|
|
@@ -68184,9 +68508,28 @@ function buildInitialGeneratePrompt(args) {
|
|
|
68184
68508
|
]
|
|
68185
68509
|
]);
|
|
68186
68510
|
}
|
|
68511
|
+
function renderReferenceImageList(paths) {
|
|
68512
|
+
return paths.map((path) => `- ${path}`).join(`
|
|
68513
|
+
`);
|
|
68514
|
+
}
|
|
68515
|
+
function renderReferenceImagesForGeneration(paths) {
|
|
68516
|
+
return [
|
|
68517
|
+
"AI-generated design reference images for this brief, one per visual direction (named by file). They were rendered from the brief, PRODUCT.md/DESIGN.md, and the curated references.",
|
|
68518
|
+
renderReferenceImageList(paths)
|
|
68519
|
+
].join(`
|
|
68520
|
+
`);
|
|
68521
|
+
}
|
|
68522
|
+
function renderReferenceImagesForExport(specPath, paths) {
|
|
68523
|
+
return [
|
|
68524
|
+
"AI-generated design reference images, one per visual direction (named by file), stored next to the spec. They are illustrations, not specifications.",
|
|
68525
|
+
...paths.map((path) => `- ${path} (src="${referenceImageRelativeSrc(specPath, path)}")`)
|
|
68526
|
+
].join(`
|
|
68527
|
+
`);
|
|
68528
|
+
}
|
|
68187
68529
|
async function exportOpenClaudeDesign(options) {
|
|
68188
|
-
const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig } = options;
|
|
68530
|
+
const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig } = options;
|
|
68189
68531
|
const latestDesign = options.latestDesign;
|
|
68532
|
+
const hasReferenceImages = referenceImagePaths.length > 0;
|
|
68190
68533
|
const handoff = await designContext.task("exporter", {
|
|
68191
68534
|
reads: [designContextFile, referencesFile],
|
|
68192
68535
|
prompt: taggedPrompt3([
|
|
@@ -68200,6 +68543,7 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68200
68543
|
],
|
|
68201
68544
|
["preview_artifact_path", previewPath],
|
|
68202
68545
|
["spec_artifact_path", specPath],
|
|
68546
|
+
...hasReferenceImages ? [["reference_images", renderReferenceImagesForExport(specPath, referenceImagePaths)]] : [],
|
|
68203
68547
|
["final_design_summary", "{previous}"],
|
|
68204
68548
|
["html_rules", HTML_PREVIEW_RULES],
|
|
68205
68549
|
["anti_design_slop_rules", ANTI_SLOP_RULES],
|
|
@@ -68214,7 +68558,8 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68214
68558
|
"First read the design-context file named above, then read preview_artifact_path as the canonical final design, and use the Write tool to create one self-contained HTML5 file at spec_artifact_path.",
|
|
68215
68559
|
'In order, include: sticky header with title/status/run id; Executive Summary; Live Preview embedding the full preview via `<iframe srcdoc="...">` or a side-by-side rendered copy in `<article class="preview-frame">`; the six DESIGN.md sections (Overview, Colors, Typography, Elevation, Components, Do\'s and Don\'ts) rendered with swatches, tables, and code blocks; Implementation handoff (Recommended files + components, Implementation steps, Usage example, Accessibility & responsive checklist, Validation commands, Known limitations); and an appendix linking the raw preview path.',
|
|
68216
68560
|
"Use dense legible typography, generous whitespace, monospaced code, rendered hex/oklch swatches, and copy-to-clipboard hints in HTML comments.",
|
|
68217
|
-
`Show the absolute preview path (${previewPath}) and file URL (${previewFileUrl}) prominently. Preserve assumptions and limitations; introduce no requirement absent from the final design or DESIGN.md
|
|
68561
|
+
`Show the absolute preview path (${previewPath}) and file URL (${previewFileUrl}) prominently. Preserve assumptions and limitations; introduce no requirement absent from the final design or DESIGN.md.`,
|
|
68562
|
+
...hasReferenceImages ? [REFERENCE_IMAGE_EXPORT_RULE] : []
|
|
68218
68563
|
].join(`
|
|
68219
68564
|
`)
|
|
68220
68565
|
],
|
|
@@ -68274,7 +68619,7 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68274
68619
|
});
|
|
68275
68620
|
return { latestDesign, handoff };
|
|
68276
68621
|
}
|
|
68277
|
-
var GROUNDED_REPORTING7 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.";
|
|
68622
|
+
var GROUNDED_REPORTING7 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.", REFERENCE_IMAGE_GENERATION_RULE = "Open every file listed in <reference_images> with the read tool before designing. They are illustrations of distinct visual directions for this brief. Choose the direction that best serves the brief and the references, say which one in your overview, and match its composition, palette, type character, density, and imagery stance in the HTML; borrow from the other directions only where they agree. Do not copy text from the images or invent content from them: <reference_precedence> still wins on any conflict. If an image cannot be read, say so and continue from the other context.", REFERENCE_IMAGE_EXPORT_RULE = 'Add a "Design References" section after the Live Preview that shows every file listed in <reference_images> as `<img src="..." alt="...">` using the relative src given for it, with a caption naming its direction and a note that these are AI-generated illustrations rather than specifications. This is the one exception to the self-contained rule: link the image files by relative path and never inline their data into the HTML.';
|
|
68278
68623
|
var init_open_claude_design_phases = __esm(() => {
|
|
68279
68624
|
init_open_claude_design_utils();
|
|
68280
68625
|
init_open_claude_design_live_protocol();
|
|
@@ -68282,7 +68627,7 @@ var init_open_claude_design_phases = __esm(() => {
|
|
|
68282
68627
|
});
|
|
68283
68628
|
|
|
68284
68629
|
// dist/builtin/workflows/builtin/open-claude-design-runner.ts
|
|
68285
|
-
async function runOpenClaudeDesignWorkflow(ctx) {
|
|
68630
|
+
async function runOpenClaudeDesignWorkflow(ctx, deps = {}) {
|
|
68286
68631
|
const designContext = ctx;
|
|
68287
68632
|
const agentBrowser = ensureAgentBrowser();
|
|
68288
68633
|
const browserBootstrapRules = buildAgentBrowserBootstrapRules(agentBrowser);
|
|
@@ -68471,6 +68816,15 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68471
68816
|
"Full design-system and reference evidence: read the design-context file."
|
|
68472
68817
|
].join(`
|
|
68473
68818
|
`) : "No user reference was provided; infer the design direction from the brief, project design context, research, and curated reference inspiration.";
|
|
68819
|
+
const referenceImages = await runReferenceImagesStep(designContext.tool, {
|
|
68820
|
+
brief: designBrief,
|
|
68821
|
+
outputType,
|
|
68822
|
+
artifactDir,
|
|
68823
|
+
workflowCwd,
|
|
68824
|
+
curatedReferences: referencesBriefRaw,
|
|
68825
|
+
imageModel: inputs.image_model
|
|
68826
|
+
}, deps);
|
|
68827
|
+
const referenceImagePaths = existingReferenceImagePaths(referenceImages);
|
|
68474
68828
|
const refinement = await refineOpenClaudeDesign({
|
|
68475
68829
|
designContext,
|
|
68476
68830
|
prompt: designBrief,
|
|
@@ -68480,6 +68834,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68480
68834
|
browserBootstrapRules,
|
|
68481
68835
|
designContextFile,
|
|
68482
68836
|
referencesFile,
|
|
68837
|
+
referenceImagePaths,
|
|
68483
68838
|
designModelConfig,
|
|
68484
68839
|
workflowCwd,
|
|
68485
68840
|
importContext,
|
|
@@ -68497,6 +68852,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68497
68852
|
browserBootstrapRules,
|
|
68498
68853
|
designContextFile,
|
|
68499
68854
|
referencesFile,
|
|
68855
|
+
referenceImagePaths,
|
|
68500
68856
|
latestDesign,
|
|
68501
68857
|
designModelConfig
|
|
68502
68858
|
});
|
|
@@ -68513,49 +68869,56 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68513
68869
|
preview_file_url: previewFileUrl,
|
|
68514
68870
|
spec_path: specPath,
|
|
68515
68871
|
spec_file_url: specFileUrl,
|
|
68516
|
-
agent_browser_status: agentBrowser.summary
|
|
68872
|
+
agent_browser_status: agentBrowser.summary,
|
|
68873
|
+
reference_images_status: referenceImages
|
|
68517
68874
|
};
|
|
68518
68875
|
}
|
|
68519
68876
|
var GROUNDED_REPORTING8 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.", DELEGATION_RULE = "Delegate further only work genuinely independent and too large for a handful of tool calls; do not delegate self-verification, and prefer one subagent over several.";
|
|
68520
68877
|
var init_open_claude_design_runner = __esm(() => {
|
|
68521
68878
|
init_open_claude_design_utils();
|
|
68879
|
+
init_open_claude_design_images();
|
|
68522
68880
|
init_open_claude_design_phases();
|
|
68523
68881
|
init_open_claude_design_setup();
|
|
68524
68882
|
});
|
|
68525
68883
|
|
|
68526
68884
|
// dist/builtin/workflows/builtin/open-claude-design.ts
|
|
68527
|
-
import { Type as
|
|
68885
|
+
import { Type as Type20 } from "typebox";
|
|
68528
68886
|
var open_claude_design_default;
|
|
68529
68887
|
var init_open_claude_design = __esm(() => {
|
|
68530
68888
|
init_workflow();
|
|
68531
68889
|
init_builtin_context();
|
|
68890
|
+
init_open_claude_design_images();
|
|
68532
68891
|
init_open_claude_design_runner();
|
|
68533
68892
|
open_claude_design_default = workflow({
|
|
68534
68893
|
name: "open-claude-design",
|
|
68535
68894
|
description: "AI-powered design workflow: combined discovery/init → design-system/reference research → curated reference discovery → HTML generation → one live review session → rich HTML handoff. The discovery stage asks what to build, the output type, and which references to emulate, then runs impeccable init for PRODUCT.md/DESIGN.md (references take precedence over project context). The user reviews the generated HTML in one live session.",
|
|
68536
68895
|
heartbeatIntervalMinutes: 0,
|
|
68537
68896
|
inputs: {
|
|
68538
|
-
prompt:
|
|
68897
|
+
prompt: Type20.String({
|
|
68539
68898
|
description: "What to design (for example, a dashboard, page, component, or prototype). The discovery stage refines this into a confirmed brief and asks for the output type and references."
|
|
68540
68899
|
}),
|
|
68541
|
-
discover_references:
|
|
68900
|
+
discover_references: Type20.Boolean({
|
|
68542
68901
|
default: true,
|
|
68543
68902
|
description: "Discover beautiful, current reference designs from notable design websites (Awwwards, recent.design, Dribbble, Monet, Motionsites) and feed them to generation. Set false to skip the network/browser reference pass."
|
|
68544
|
-
})
|
|
68903
|
+
}),
|
|
68904
|
+
image_model: Type20.Optional(Type20.String({
|
|
68905
|
+
description: "Image model for design reference images, as provider/id (for example openai-images/gpt-image-2.6-flare). Defaults to the newest available GPT Image model, then other image providers such as OpenRouter. Reference images are skipped when no image model is available."
|
|
68906
|
+
}))
|
|
68545
68907
|
},
|
|
68546
68908
|
outputs: {
|
|
68547
|
-
output_type:
|
|
68548
|
-
design_system:
|
|
68549
|
-
artifact:
|
|
68550
|
-
handoff:
|
|
68551
|
-
import_context:
|
|
68552
|
-
run_id:
|
|
68553
|
-
artifact_dir:
|
|
68554
|
-
preview_path:
|
|
68555
|
-
preview_file_url:
|
|
68556
|
-
spec_path:
|
|
68557
|
-
spec_file_url:
|
|
68558
|
-
agent_browser_status:
|
|
68909
|
+
output_type: Type20.Optional(Type20.String({ description: "Kind of design artifact produced." })),
|
|
68910
|
+
design_system: Type20.Optional(Type20.String({ description: "Design system source used for generation: the project-derived design system." })),
|
|
68911
|
+
artifact: Type20.Optional(Type20.String({ description: "Latest final design summary from the final preview artifact." })),
|
|
68912
|
+
handoff: Type20.Optional(Type20.String({ description: "Final rich HTML spec and implementation handoff summary." })),
|
|
68913
|
+
import_context: Type20.Optional(Type20.String({ description: "Reference-import context used during generation." })),
|
|
68914
|
+
run_id: Type20.Optional(Type20.String({ description: "Per-run design workflow artifact identifier." })),
|
|
68915
|
+
artifact_dir: Type20.Optional(Type20.String({ description: "Directory containing preview and spec artifacts." })),
|
|
68916
|
+
preview_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated preview.html file." })),
|
|
68917
|
+
preview_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated preview.html file." })),
|
|
68918
|
+
spec_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated spec.html file." })),
|
|
68919
|
+
spec_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated spec.html file." })),
|
|
68920
|
+
agent_browser_status: Type20.Optional(Type20.String({ description: "Outcome of the initial deterministic step that ensures the agent-browser skill's `agent-browser` command is installed." })),
|
|
68921
|
+
reference_images_status: Type20.Optional(referenceImagesStatusSchema)
|
|
68559
68922
|
},
|
|
68560
68923
|
run: async (ctx) => await runOpenClaudeDesignWorkflow(withBuiltinContext(ctx))
|
|
68561
68924
|
});
|
|
@@ -68571,9 +68934,9 @@ var init_ralph_review_gate = __esm(() => {
|
|
|
68571
68934
|
});
|
|
68572
68935
|
|
|
68573
68936
|
// dist/builtin/workflows/builtin/ralph-core.ts
|
|
68574
|
-
import { mkdir as
|
|
68575
|
-
import { dirname as
|
|
68576
|
-
import { Type as
|
|
68937
|
+
import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
68938
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
68939
|
+
import { Type as Type21 } from "typebox";
|
|
68577
68940
|
function taggedPrompt4(sections) {
|
|
68578
68941
|
return sections.map(([tag, content]) => {
|
|
68579
68942
|
const trimmed = content.trim();
|
|
@@ -68612,11 +68975,11 @@ function slugifyResearchTopic(prompt) {
|
|
|
68612
68975
|
}
|
|
68613
68976
|
function defaultResearchPath(prompt, now = new Date) {
|
|
68614
68977
|
const date = now.toISOString().slice(0, 10);
|
|
68615
|
-
return
|
|
68978
|
+
return join28(DEFAULT_RESEARCH_DIR, `${date}-${slugifyResearchTopic(prompt)}.md`);
|
|
68616
68979
|
}
|
|
68617
68980
|
async function createImplementationNotesFile(prompt, runId) {
|
|
68618
68981
|
const notesDir = await createWorkflowArtifactDirectory(runId);
|
|
68619
|
-
const notesPath =
|
|
68982
|
+
const notesPath = join28(notesDir, IMPLEMENTATION_NOTES_FILENAME);
|
|
68620
68983
|
const initialNotes = [
|
|
68621
68984
|
"# Implementation Notes",
|
|
68622
68985
|
"",
|
|
@@ -68628,7 +68991,7 @@ async function createImplementationNotesFile(prompt, runId) {
|
|
|
68628
68991
|
"- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified."
|
|
68629
68992
|
].join(`
|
|
68630
68993
|
`);
|
|
68631
|
-
await
|
|
68994
|
+
await writeFile9(notesPath, `${initialNotes}
|
|
68632
68995
|
`, {
|
|
68633
68996
|
encoding: "utf8",
|
|
68634
68997
|
flag: "wx"
|
|
@@ -68637,7 +69000,7 @@ async function createImplementationNotesFile(prompt, runId) {
|
|
|
68637
69000
|
}
|
|
68638
69001
|
async function createQaEvidenceVideoPath(runId) {
|
|
68639
69002
|
const qaDir = await createWorkflowArtifactDirectory(runId);
|
|
68640
|
-
return
|
|
69003
|
+
return join28(qaDir, QA_E2E_VIDEO_FILENAME);
|
|
68641
69004
|
}
|
|
68642
69005
|
function renderQaE2eVideoGuidance(qaVideoPath) {
|
|
68643
69006
|
return [
|
|
@@ -68703,8 +69066,8 @@ function artifactSafeName2(value2) {
|
|
|
68703
69066
|
return safe.length > 0 ? safe : "artifact";
|
|
68704
69067
|
}
|
|
68705
69068
|
async function writeJsonArtifact(path, content) {
|
|
68706
|
-
await
|
|
68707
|
-
await
|
|
69069
|
+
await mkdir5(dirname16(path), { recursive: true });
|
|
69070
|
+
await writeFile9(path, `${JSON.stringify(content, null, 2)}
|
|
68708
69071
|
`, {
|
|
68709
69072
|
encoding: "utf8"
|
|
68710
69073
|
});
|
|
@@ -68777,60 +69140,60 @@ var init_ralph_core = __esm(() => {
|
|
|
68777
69140
|
init_shared_prompts();
|
|
68778
69141
|
init_ralph_review_gate();
|
|
68779
69142
|
init_review_convergence();
|
|
68780
|
-
reviewFindingSchema2 =
|
|
68781
|
-
title:
|
|
68782
|
-
body:
|
|
68783
|
-
confidence_score:
|
|
68784
|
-
objective_alignment:
|
|
68785
|
-
|
|
68786
|
-
|
|
68787
|
-
|
|
68788
|
-
|
|
69143
|
+
reviewFindingSchema2 = Type21.Object({
|
|
69144
|
+
title: Type21.String(),
|
|
69145
|
+
body: Type21.String(),
|
|
69146
|
+
confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
|
|
69147
|
+
objective_alignment: Type21.Union([
|
|
69148
|
+
Type21.Literal("required_by_objective"),
|
|
69149
|
+
Type21.Literal("consistent_with_objective"),
|
|
69150
|
+
Type21.Literal("beyond_objective"),
|
|
69151
|
+
Type21.Literal("contradicts_objective")
|
|
68789
69152
|
]),
|
|
68790
|
-
priority:
|
|
68791
|
-
code_location:
|
|
68792
|
-
absolute_file_path:
|
|
68793
|
-
line_range:
|
|
68794
|
-
start:
|
|
68795
|
-
end:
|
|
69153
|
+
priority: Type21.Optional(Type21.Union([Type21.Integer({ minimum: 0, maximum: 3 }), Type21.Null()])),
|
|
69154
|
+
code_location: Type21.Object({
|
|
69155
|
+
absolute_file_path: Type21.String(),
|
|
69156
|
+
line_range: Type21.Object({
|
|
69157
|
+
start: Type21.Integer({ minimum: 1 }),
|
|
69158
|
+
end: Type21.Integer({ minimum: 1 })
|
|
68796
69159
|
}, { additionalProperties: false })
|
|
68797
69160
|
}, { additionalProperties: false })
|
|
68798
69161
|
}, { additionalProperties: false });
|
|
68799
|
-
requirementsTraceabilitySchema2 =
|
|
68800
|
-
requirement:
|
|
68801
|
-
status:
|
|
68802
|
-
|
|
68803
|
-
|
|
68804
|
-
|
|
68805
|
-
|
|
69162
|
+
requirementsTraceabilitySchema2 = Type21.Object({
|
|
69163
|
+
requirement: Type21.String(),
|
|
69164
|
+
status: Type21.Union([
|
|
69165
|
+
Type21.Literal("proven"),
|
|
69166
|
+
Type21.Literal("contradicted"),
|
|
69167
|
+
Type21.Literal("missing"),
|
|
69168
|
+
Type21.Literal("unverified")
|
|
68806
69169
|
]),
|
|
68807
|
-
evidence:
|
|
69170
|
+
evidence: Type21.String()
|
|
68808
69171
|
}, { additionalProperties: false });
|
|
68809
|
-
reviewerErrorSchema2 =
|
|
68810
|
-
kind:
|
|
68811
|
-
|
|
68812
|
-
|
|
68813
|
-
|
|
68814
|
-
|
|
69172
|
+
reviewerErrorSchema2 = Type21.Object({
|
|
69173
|
+
kind: Type21.Union([
|
|
69174
|
+
Type21.Literal("validation_unavailable"),
|
|
69175
|
+
Type21.Literal("dependency_unavailable"),
|
|
69176
|
+
Type21.Literal("tool_failure"),
|
|
69177
|
+
Type21.Literal("reviewer_failure")
|
|
68815
69178
|
]),
|
|
68816
|
-
message:
|
|
68817
|
-
attempted_recovery:
|
|
69179
|
+
message: Type21.String(),
|
|
69180
|
+
attempted_recovery: Type21.String()
|
|
68818
69181
|
}, { additionalProperties: false });
|
|
68819
|
-
reviewDecisionSchema2 =
|
|
68820
|
-
findings:
|
|
68821
|
-
overall_correctness:
|
|
68822
|
-
|
|
68823
|
-
|
|
69182
|
+
reviewDecisionSchema2 = Type21.Object({
|
|
69183
|
+
findings: Type21.Array(reviewFindingSchema2),
|
|
69184
|
+
overall_correctness: Type21.Union([
|
|
69185
|
+
Type21.Literal("patch is correct"),
|
|
69186
|
+
Type21.Literal("patch is incorrect")
|
|
68824
69187
|
]),
|
|
68825
|
-
overall_explanation:
|
|
68826
|
-
overall_confidence_score:
|
|
68827
|
-
criterion_scores:
|
|
68828
|
-
criterion_id:
|
|
69188
|
+
overall_explanation: Type21.String(),
|
|
69189
|
+
overall_confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
|
|
69190
|
+
criterion_scores: Type21.Optional(Type21.Array(Type21.Object({
|
|
69191
|
+
criterion_id: Type21.String(),
|
|
68829
69192
|
score: VERIFICATION_SCALE.schema
|
|
68830
69193
|
}, { additionalProperties: false }))),
|
|
68831
|
-
requirements_traceability:
|
|
68832
|
-
stop_review_loop:
|
|
68833
|
-
reviewer_error:
|
|
69194
|
+
requirements_traceability: Type21.Array(requirementsTraceabilitySchema2),
|
|
69195
|
+
stop_review_loop: Type21.Boolean(),
|
|
69196
|
+
reviewer_error: Type21.Optional(Type21.Union([Type21.Null(), reviewerErrorSchema2]))
|
|
68834
69197
|
}, { additionalProperties: false });
|
|
68835
69198
|
});
|
|
68836
69199
|
|
|
@@ -69040,8 +69403,8 @@ var init_ralph_models = __esm(() => {
|
|
|
69040
69403
|
});
|
|
69041
69404
|
|
|
69042
69405
|
// dist/builtin/workflows/builtin/ralph-runner.ts
|
|
69043
|
-
import { existsSync as
|
|
69044
|
-
import { join as
|
|
69406
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
69407
|
+
import { join as join29, resolve as resolve14 } from "node:path";
|
|
69045
69408
|
async function runRalphWorkflow(ctx, options) {
|
|
69046
69409
|
const { prompt, acceptanceCriteria, maxLoops, comparisonBaseBranch, workflowStartCwd, createPr, runId } = options;
|
|
69047
69410
|
let latestReviewReportPath;
|
|
@@ -69102,7 +69465,7 @@ async function runRalphWorkflow(ctx, options) {
|
|
|
69102
69465
|
const researchPath = workflowResearchPath;
|
|
69103
69466
|
finalResearchPath = researchPath;
|
|
69104
69467
|
finalPlanPath = researchPath;
|
|
69105
|
-
const orchestratorReportPath =
|
|
69468
|
+
const orchestratorReportPath = join29(artifactDir, "orchestrator-report.md");
|
|
69106
69469
|
const orchestratorForkOptions = forkContinuationOptions3(previousOrchestratorSessionId);
|
|
69107
69470
|
const orchestratorPrompt = orchestratorForkOptions.forkFromSessionId === undefined ? taggedPrompt4([
|
|
69108
69471
|
["acceptance_criteria", keepContext(acceptanceCriteria)],
|
|
@@ -69238,7 +69601,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69238
69601
|
diagnostics: parsed.diagnostics,
|
|
69239
69602
|
allowFinalActionRemaining: createPr
|
|
69240
69603
|
});
|
|
69241
|
-
const artifactPath =
|
|
69604
|
+
const artifactPath = join29(artifactDir, `review-${artifactSafeName2(reviewer)}.json`);
|
|
69242
69605
|
await writeJsonArtifact(artifactPath, {
|
|
69243
69606
|
reviewer,
|
|
69244
69607
|
decision: parsed.decision,
|
|
@@ -69294,7 +69657,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69294
69657
|
usage: fold_usage([orchestrator, ...reviews, ...reverifyResults])
|
|
69295
69658
|
}));
|
|
69296
69659
|
}
|
|
69297
|
-
latestReviewReportPath = await writeJsonArtifact(
|
|
69660
|
+
latestReviewReportPath = await writeJsonArtifact(join29(artifactDir, "review-round-latest.json"), {
|
|
69298
69661
|
convergence_decision: roundConvergenceDecision,
|
|
69299
69662
|
convergence: convergenceEntries,
|
|
69300
69663
|
consolidated_findings: reverified.batch,
|
|
@@ -69304,7 +69667,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69304
69667
|
if (approved)
|
|
69305
69668
|
break;
|
|
69306
69669
|
}
|
|
69307
|
-
const qaVideoAvailable =
|
|
69670
|
+
const qaVideoAvailable = existsSync9(qaVideoPath);
|
|
69308
69671
|
const unapprovedHandoff = createPr === true && !approved;
|
|
69309
69672
|
const escalationEvidence = unapprovedHandoff ? convergence_escalation_evidence(convergenceEntries) : [];
|
|
69310
69673
|
if (createPr === true) {
|
|
@@ -69419,7 +69782,7 @@ var init_ralph_runner = __esm(() => {
|
|
|
69419
69782
|
});
|
|
69420
69783
|
|
|
69421
69784
|
// dist/builtin/workflows/builtin/ralph.ts
|
|
69422
|
-
import { Type as
|
|
69785
|
+
import { Type as Type22 } from "typebox";
|
|
69423
69786
|
var ralph_default;
|
|
69424
69787
|
var init_ralph = __esm(() => {
|
|
69425
69788
|
init_workflow();
|
|
@@ -69431,38 +69794,38 @@ var init_ralph = __esm(() => {
|
|
|
69431
69794
|
description: "Raw prompt → research-prompt-refinement → research → orchestrate → multi-model parallel review loop with bounded iteration and immutable acceptance criteria. When launching follow-up ralph runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the prompt text and set create_pr=true instead when preparing the workflow inputs.",
|
|
69432
69795
|
heartbeatIntervalMinutes: 15,
|
|
69433
69796
|
inputs: {
|
|
69434
|
-
prompt:
|
|
69435
|
-
acceptance_criteria:
|
|
69436
|
-
max_loops:
|
|
69797
|
+
prompt: Type22.String({ description: "The task or goal to research, execute, and refine. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead." }),
|
|
69798
|
+
acceptance_criteria: Type22.Optional(Type22.String({ description: "Original immutable task contract this run must remain consistent with. Defaults to prompt. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here." })),
|
|
69799
|
+
max_loops: Type22.Number({
|
|
69437
69800
|
default: DEFAULT_MAX_LOOPS,
|
|
69438
69801
|
description: `Maximum research/orchestrate/review iterations (default ${DEFAULT_MAX_LOOPS}).`
|
|
69439
69802
|
}),
|
|
69440
|
-
base_branch:
|
|
69803
|
+
base_branch: Type22.String({
|
|
69441
69804
|
default: "origin/main",
|
|
69442
69805
|
description: "Branch reviewers compare the current code delta against (default origin/main)."
|
|
69443
69806
|
}),
|
|
69444
|
-
git_worktree_dir:
|
|
69807
|
+
git_worktree_dir: Type22.String({
|
|
69445
69808
|
default: "",
|
|
69446
69809
|
description: "Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Absolute paths are used as-is; relative paths resolve from the invoking repo root (or the invoking cwd outside a Git repo). An existing Git worktree root of any repository is reused as-is, even from another repository or a non-Git cwd. Creating a worktree requires starting inside the source Git repo: a missing path or an empty directory becomes a new worktree from base_branch, and a non-empty non-Git directory is treated as a worktree root that gets this run's own <dir>/<4-hex>/<repo-name> checkout, reused on resume."
|
|
69447
69810
|
}),
|
|
69448
|
-
create_pr:
|
|
69811
|
+
create_pr: Type22.Boolean({
|
|
69449
69812
|
default: false,
|
|
69450
69813
|
description: "Whether to run the final pull-request creation stage. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the prompt text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation."
|
|
69451
69814
|
})
|
|
69452
69815
|
},
|
|
69453
69816
|
outputs: {
|
|
69454
|
-
result:
|
|
69455
|
-
plan:
|
|
69456
|
-
plan_path:
|
|
69457
|
-
research:
|
|
69458
|
-
research_path:
|
|
69459
|
-
implementation_notes_path:
|
|
69460
|
-
qa_video_path:
|
|
69461
|
-
pr_report:
|
|
69462
|
-
approved:
|
|
69463
|
-
iterations_completed:
|
|
69464
|
-
review_report:
|
|
69465
|
-
review_report_path:
|
|
69817
|
+
result: Type22.Optional(Type22.String({ description: "Final implementation report from the orchestrator stage." })),
|
|
69818
|
+
plan: Type22.Optional(Type22.String({ description: "Latest transformed research question." })),
|
|
69819
|
+
plan_path: Type22.Optional(Type22.String({ description: "Backward-compatible alias for research_path." })),
|
|
69820
|
+
research: Type22.Optional(Type22.String({ description: "Latest research report text or artifact reference." })),
|
|
69821
|
+
research_path: Type22.Optional(Type22.String({ description: "Path to the latest generated research artifact under research/." })),
|
|
69822
|
+
implementation_notes_path: Type22.Optional(Type22.String({ description: "Durable run-scoped notes file containing decisions, deviations, blockers, and validation notes." })),
|
|
69823
|
+
qa_video_path: Type22.Optional(Type22.String({ description: "Absolute path to the reviewable QA end-to-end proof video recorded with domain-appropriate tooling for UI-applicable changes, when one was produced." })),
|
|
69824
|
+
pr_report: Type22.Optional(Type22.String({ description: "Pull-request report emitted only when create_pr=true and the final pull-request stage runs." })),
|
|
69825
|
+
approved: Type22.Optional(Type22.Boolean({ description: "Whether the reviewer loop approved before completion or optional final handoff." })),
|
|
69826
|
+
iterations_completed: Type22.Optional(Type22.Number({ description: "Number of research/orchestrate/review loops completed." })),
|
|
69827
|
+
review_report: Type22.Optional(Type22.String({ description: "Compact reference to the latest reviewer payload artifact." })),
|
|
69828
|
+
review_report_path: Type22.Optional(Type22.String({ description: "JSON artifact path for the latest review round." }))
|
|
69466
69829
|
},
|
|
69467
69830
|
worktreeFromInputs: {
|
|
69468
69831
|
gitWorktreeDir: "git_worktree_dir",
|
|
@@ -69662,9 +70025,9 @@ var init_tournament_prompts = __esm(() => {
|
|
|
69662
70025
|
});
|
|
69663
70026
|
|
|
69664
70027
|
// dist/builtin/workflows/builtin/tournament-runner.ts
|
|
69665
|
-
import { mkdir as
|
|
69666
|
-
import { join as
|
|
69667
|
-
import { Type as
|
|
70028
|
+
import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile10 } from "node:fs/promises";
|
|
70029
|
+
import { join as join30, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve15 } from "node:path";
|
|
70030
|
+
import { Type as Type23 } from "typebox";
|
|
69668
70031
|
function serializableObject2(value2) {
|
|
69669
70032
|
if (value2 === null || Array.isArray(value2) || typeof value2 !== "object")
|
|
69670
70033
|
return;
|
|
@@ -69702,7 +70065,7 @@ function judgeArtifactPath(judgesDir, job, criterionIndex) {
|
|
|
69702
70065
|
const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
|
|
69703
70066
|
const root = resolve15(judgesDir);
|
|
69704
70067
|
const path = resolve15(judgesDir, filename);
|
|
69705
|
-
const fromRoot =
|
|
70068
|
+
const fromRoot = relative9(root, path);
|
|
69706
70069
|
if (fromRoot.startsWith("..") || isAbsolute12(fromRoot)) {
|
|
69707
70070
|
throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
|
|
69708
70071
|
}
|
|
@@ -69752,16 +70115,16 @@ function combineUsage(totals) {
|
|
|
69752
70115
|
}
|
|
69753
70116
|
async function runTournament(ctx) {
|
|
69754
70117
|
const artifactDir = await stableArtifactRoot(ctx, "tournament");
|
|
69755
|
-
const attemptsDir =
|
|
70118
|
+
const attemptsDir = join30(artifactDir, "attempts");
|
|
69756
70119
|
const numAttempts = ctx.inputs.num_attempts ?? 4;
|
|
69757
70120
|
const maxConcurrency = ctx.inputs.max_concurrency ?? 4;
|
|
69758
70121
|
const nEvaluations = ctx.inputs.n_evaluations ?? 2;
|
|
69759
70122
|
const pivotCount = ctx.inputs.pivots ?? 1;
|
|
69760
70123
|
const seed = ctx.inputs.seed ?? 0;
|
|
69761
|
-
const judgesDir =
|
|
69762
|
-
await
|
|
69763
|
-
await
|
|
69764
|
-
const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) =>
|
|
70124
|
+
const judgesDir = join30(artifactDir, "judges");
|
|
70125
|
+
await mkdir6(attemptsDir, { recursive: true });
|
|
70126
|
+
await mkdir6(judgesDir, { recursive: true });
|
|
70127
|
+
const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) => join30(attemptsDir, `attempt-${index + 1}.md`));
|
|
69765
70128
|
const models = ctx.inputs.models;
|
|
69766
70129
|
const attemptResults = await ctx.parallel(attemptArtifactPaths.map((path, index) => ({
|
|
69767
70130
|
name: `attempt-${index + 1}`,
|
|
@@ -69774,7 +70137,7 @@ async function runTournament(ctx) {
|
|
|
69774
70137
|
const entrants = await Promise.all(attemptArtifactPaths.map(async (path, index) => ({
|
|
69775
70138
|
label: `attempt-${index + 1}`,
|
|
69776
70139
|
path,
|
|
69777
|
-
body: await
|
|
70140
|
+
body: await readFile6(path, "utf8")
|
|
69778
70141
|
})));
|
|
69779
70142
|
const criteria = tournamentCriteria(ctx.inputs.criteria);
|
|
69780
70143
|
const criterionIds = criteria.map((criterion) => criterion.id);
|
|
@@ -69845,7 +70208,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69845
70208
|
report = judgeReport(retried.structured);
|
|
69846
70209
|
}
|
|
69847
70210
|
if (report === undefined) {
|
|
69848
|
-
await
|
|
70211
|
+
await writeFile10(stage.path, `${JSON.stringify({ invalid: true }, null, 2)}
|
|
69849
70212
|
`);
|
|
69850
70213
|
comparisons.push({
|
|
69851
70214
|
a: stage.job.a,
|
|
@@ -69859,7 +70222,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69859
70222
|
});
|
|
69860
70223
|
continue;
|
|
69861
70224
|
}
|
|
69862
|
-
await
|
|
70225
|
+
await writeFile10(stage.path, `${JSON.stringify(report, null, 2)}
|
|
69863
70226
|
`);
|
|
69864
70227
|
const scoreA = stage.job.swapped ? report.score_b : report.score_a;
|
|
69865
70228
|
const scoreB = stage.job.swapped ? report.score_a : report.score_b;
|
|
@@ -69926,7 +70289,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69926
70289
|
const outputRanking = ranking.map(({ label, meanPreference }) => ({ label, meanPreference }));
|
|
69927
70290
|
const budgetPivots = Math.min(pivotCount, entrants.length);
|
|
69928
70291
|
const comparisonBudget = (entrants.length + budgetPivots * (entrants.length - budgetPivots) + budgetPivots * (budgetPivots - 1) / 2) * criteria.length * nEvaluations;
|
|
69929
|
-
const comparisonPath =
|
|
70292
|
+
const comparisonPath = join30(artifactDir, "comparisons.json");
|
|
69930
70293
|
const assignment = modelAssignment(entrants, models);
|
|
69931
70294
|
const phaseUsage = {
|
|
69932
70295
|
attempts: fold_usage(attemptResults),
|
|
@@ -69956,13 +70319,13 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69956
70319
|
reducer: reducerUsage,
|
|
69957
70320
|
total: combineUsage([phaseUsage.attempts, phaseUsage.ring, phaseUsage.pivots, reducerUsage])
|
|
69958
70321
|
};
|
|
69959
|
-
await
|
|
70322
|
+
await writeFile10(comparisonPath, `${JSON.stringify({ ...baseLedger, usage }, null, 2)}
|
|
69960
70323
|
`);
|
|
69961
70324
|
};
|
|
69962
70325
|
await writeLedger(fold_usage([]));
|
|
69963
70326
|
const winner = ranking[0];
|
|
69964
70327
|
const winnerEntrant = entrants[winner.index];
|
|
69965
|
-
const resultPath =
|
|
70328
|
+
const resultPath = join30(artifactDir, "winner.md");
|
|
69966
70329
|
const reducer = await ctx.task("comparisons-reducer", {
|
|
69967
70330
|
prompt: renderComparisonsReducerPrompt({
|
|
69968
70331
|
task: ctx.inputs.prompt,
|
|
@@ -69997,16 +70360,16 @@ var init_tournament_runner = __esm(() => {
|
|
|
69997
70360
|
init_verification_criteria();
|
|
69998
70361
|
init_tournament_prompts();
|
|
69999
70362
|
init_pattern_artifact_root();
|
|
70000
|
-
judgeScoreSchema =
|
|
70001
|
-
criterion_id:
|
|
70002
|
-
score_a:
|
|
70003
|
-
score_b:
|
|
70004
|
-
evidence:
|
|
70363
|
+
judgeScoreSchema = Type23.Object({
|
|
70364
|
+
criterion_id: Type23.String(),
|
|
70365
|
+
score_a: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
|
|
70366
|
+
score_b: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
|
|
70367
|
+
evidence: Type23.Array(Type23.String())
|
|
70005
70368
|
}, { additionalProperties: false });
|
|
70006
70369
|
});
|
|
70007
70370
|
|
|
70008
70371
|
// dist/builtin/workflows/builtin/tournament.ts
|
|
70009
|
-
import { Type as
|
|
70372
|
+
import { Type as Type24 } from "typebox";
|
|
70010
70373
|
var tournament_default;
|
|
70011
70374
|
var init_tournament = __esm(() => {
|
|
70012
70375
|
init_workflow();
|
|
@@ -70017,63 +70380,63 @@ var init_tournament = __esm(() => {
|
|
|
70017
70380
|
description: "Run independent whole-task attempts through a soft-scored pivot-pairing schedule and return an auditable ranking.",
|
|
70018
70381
|
heartbeatIntervalMinutes: 15,
|
|
70019
70382
|
inputs: {
|
|
70020
|
-
prompt:
|
|
70021
|
-
num_attempts:
|
|
70383
|
+
prompt: Type24.String({ description: "Task every competing agent must attempt independently." }),
|
|
70384
|
+
num_attempts: Type24.Integer({
|
|
70022
70385
|
minimum: 2,
|
|
70023
70386
|
maximum: 8,
|
|
70024
70387
|
default: 4,
|
|
70025
70388
|
description: "Number of independent whole-task attempts (2-8)."
|
|
70026
70389
|
}),
|
|
70027
|
-
max_concurrency:
|
|
70390
|
+
max_concurrency: Type24.Integer({
|
|
70028
70391
|
minimum: 1,
|
|
70029
70392
|
maximum: 8,
|
|
70030
70393
|
default: 4,
|
|
70031
70394
|
description: "Maximum simultaneously active attempts or pairwise judges (1-8)."
|
|
70032
70395
|
}),
|
|
70033
|
-
n_evaluations:
|
|
70396
|
+
n_evaluations: Type24.Integer({
|
|
70034
70397
|
minimum: 1,
|
|
70035
70398
|
default: 2,
|
|
70036
70399
|
description: "Number of repeated evaluations per criterion and directed pair."
|
|
70037
70400
|
}),
|
|
70038
|
-
pivots:
|
|
70401
|
+
pivots: Type24.Integer({
|
|
70039
70402
|
minimum: 1,
|
|
70040
70403
|
default: 1,
|
|
70041
70404
|
description: "Number of pivot candidates used for the second comparison phase."
|
|
70042
70405
|
}),
|
|
70043
|
-
seed:
|
|
70406
|
+
seed: Type24.Integer({
|
|
70044
70407
|
default: 0,
|
|
70045
70408
|
description: "Seed for the deterministic comparison schedule."
|
|
70046
70409
|
}),
|
|
70047
|
-
criteria:
|
|
70048
|
-
|
|
70049
|
-
|
|
70050
|
-
|
|
70051
|
-
|
|
70052
|
-
id:
|
|
70053
|
-
name:
|
|
70054
|
-
description:
|
|
70410
|
+
criteria: Type24.Optional(Type24.Union([
|
|
70411
|
+
Type24.String(),
|
|
70412
|
+
Type24.Record(Type24.String(), Type24.String()),
|
|
70413
|
+
Type24.Array(Type24.String()),
|
|
70414
|
+
Type24.Array(Type24.Object({
|
|
70415
|
+
id: Type24.Optional(Type24.String()),
|
|
70416
|
+
name: Type24.Optional(Type24.String()),
|
|
70417
|
+
description: Type24.String()
|
|
70055
70418
|
}, { additionalProperties: true }))
|
|
70056
70419
|
], {
|
|
70057
70420
|
description: "Optional V1 judge criteria; accepts a markdown rubric, record, string list, or CriterionInput list; omitted uses the default three-criterion rubric."
|
|
70058
70421
|
})),
|
|
70059
|
-
models:
|
|
70422
|
+
models: Type24.Optional(Type24.Array(Type24.String(), {
|
|
70060
70423
|
description: "Optional ordered model ids assigned round-robin to attempt slots."
|
|
70061
70424
|
}))
|
|
70062
70425
|
},
|
|
70063
70426
|
outputs: {
|
|
70064
|
-
result:
|
|
70065
|
-
winner:
|
|
70066
|
-
winner_artifact_path:
|
|
70067
|
-
result_path:
|
|
70068
|
-
attempt_artifact_paths:
|
|
70069
|
-
judge_artifact_paths:
|
|
70070
|
-
comparisons_path:
|
|
70071
|
-
ranking:
|
|
70072
|
-
label:
|
|
70073
|
-
meanPreference:
|
|
70427
|
+
result: Type24.String({ description: "Compact reference to the final reducer report; read `result_path` for the full report." }),
|
|
70428
|
+
winner: Type24.String({ description: "Stable attempt label selected as the top-ranked tournament winner." }),
|
|
70429
|
+
winner_artifact_path: Type24.String({ description: "Path to the original winning attempt artifact." }),
|
|
70430
|
+
result_path: Type24.String({ description: "Path to the final reducer report artifact." }),
|
|
70431
|
+
attempt_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to every independent attempt artifact." }),
|
|
70432
|
+
judge_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to all per-job structured judge artifacts." }),
|
|
70433
|
+
comparisons_path: Type24.String({ description: "Path to the durable JSON soft-scored comparisons ledger." }),
|
|
70434
|
+
ranking: Type24.Array(Type24.Object({
|
|
70435
|
+
label: Type24.String(),
|
|
70436
|
+
meanPreference: Type24.Number()
|
|
70074
70437
|
}, { additionalProperties: false }), { description: "All attempts ordered by mean preference." }),
|
|
70075
|
-
seed:
|
|
70076
|
-
artifact_dir:
|
|
70438
|
+
seed: Type24.Integer({ description: "Seed used for the deterministic comparison schedule." }),
|
|
70439
|
+
artifact_dir: Type24.String({ description: "Run-specific directory containing tournament artifacts." })
|
|
70077
70440
|
},
|
|
70078
70441
|
run: async (ctx) => await runTournament(withBuiltinContext(ctx))
|
|
70079
70442
|
});
|
|
@@ -70222,7 +70585,7 @@ var init_workflow_module_loader = __esm(() => {
|
|
|
70222
70585
|
|
|
70223
70586
|
// dist/builtin/workflows/src/workers/definitions.ts
|
|
70224
70587
|
import { createHash as createHash6 } from "node:crypto";
|
|
70225
|
-
import { readFile as
|
|
70588
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
70226
70589
|
import { isAbsolute as isAbsolute13 } from "node:path";
|
|
70227
70590
|
async function loadWorkerDefinition(source) {
|
|
70228
70591
|
if (!isAbsolute13(source.path) || await definitionDigest(source.path) !== source.digest)
|
|
@@ -70239,7 +70602,7 @@ async function loadWorkerWorkflow(path, exportName = "default") {
|
|
|
70239
70602
|
return loadWorkerDefinition({ path, exportName, digest: await definitionDigest(path) });
|
|
70240
70603
|
}
|
|
70241
70604
|
async function definitionDigest(path) {
|
|
70242
|
-
return createHash6("sha256").update(await
|
|
70605
|
+
return createHash6("sha256").update(await readFile7(path)).digest("hex");
|
|
70243
70606
|
}
|
|
70244
70607
|
var workerDefinitionSources;
|
|
70245
70608
|
var init_definitions = __esm(() => {
|
|
@@ -70640,7 +71003,7 @@ var init_pending_stage_status = __esm(() => {
|
|
|
70640
71003
|
"awaiting_input",
|
|
70641
71004
|
"paused",
|
|
70642
71005
|
"blocked",
|
|
70643
|
-
"
|
|
71006
|
+
"suspended"
|
|
70644
71007
|
]);
|
|
70645
71008
|
});
|
|
70646
71009
|
|
|
@@ -71530,7 +71893,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71530
71893
|
stageId: stage.id,
|
|
71531
71894
|
stageName: stage.name,
|
|
71532
71895
|
target: stageRouteTarget(lookups.runs, rootRunId, run.id, stage.id, lookups.segments),
|
|
71533
|
-
lifecycle: stage.status === "
|
|
71896
|
+
lifecycle: stage.status === "suspended" || stage.sessionId === undefined && stage.sessionFile === undefined ? "pending" : "running",
|
|
71534
71897
|
routeEligible: stage.pendingStageDeliveryAvailable === true && isAddressableStageStatus(stage.status),
|
|
71535
71898
|
group: stage.intercomGroup ?? workflowInvocationIntercomGroup(rootRunId)
|
|
71536
71899
|
})),
|
|
@@ -71809,7 +72172,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71809
72172
|
target: payload.target
|
|
71810
72173
|
};
|
|
71811
72174
|
const stage = destination.stage;
|
|
71812
|
-
const live = stage.status !== "
|
|
72175
|
+
const live = stage.status !== "suspended" && (stage.sessionId !== undefined || stage.sessionFile !== undefined);
|
|
71813
72176
|
const stageTerminal = stage.status === "completed" || stage.status === "skipped" || stage.status === "failed";
|
|
71814
72177
|
if (payload.live !== true && live && !stageTerminal && externalRunRouteOwner(activeStore, destination.run.id)?.deliversQueued(destination.run.id, stage.id) === true) {
|
|
71815
72178
|
payload.handled = true;
|
|
@@ -71817,7 +72180,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71817
72180
|
payload.completion = refusal === undefined ? queueAndPersist(activeStore, resolvedEvent, workflowInvocationIntercomGroup(rootRunId), true) : Promise.resolve({ outcome: "refused", reason: refusal });
|
|
71818
72181
|
return;
|
|
71819
72182
|
}
|
|
71820
|
-
if (payload.live === true && stage.status !== "
|
|
72183
|
+
if (payload.live === true && stage.status !== "suspended" || live && !stageTerminal) {
|
|
71821
72184
|
payload.handled = true;
|
|
71822
72185
|
payload.completion = validateLiveDelivery(activeStore, resolvedEvent).then((result) => result.outcome === "forward" ? {
|
|
71823
72186
|
outcome: "forward",
|
|
@@ -72169,7 +72532,7 @@ function knownUninitializedStage(run, stageKey) {
|
|
|
72169
72532
|
if (candidates.length !== 1)
|
|
72170
72533
|
return;
|
|
72171
72534
|
const stage = candidates[0];
|
|
72172
|
-
if (stage.status === "
|
|
72535
|
+
if (stage.status === "suspended")
|
|
72173
72536
|
return stage;
|
|
72174
72537
|
return isAddressableStageStatus(stage.status) && stage.sessionId === undefined && stage.sessionFile === undefined ? stage : undefined;
|
|
72175
72538
|
}
|
|
@@ -72413,7 +72776,7 @@ var init_broker_status = __esm(() => {
|
|
|
72413
72776
|
|
|
72414
72777
|
// dist/builtin/intercom/broker/paths.ts
|
|
72415
72778
|
import { homedir as homedir2 } from "os";
|
|
72416
|
-
import { join as
|
|
72779
|
+
import { join as join31 } from "path";
|
|
72417
72780
|
function getHomeDir() {
|
|
72418
72781
|
if (process.platform === "win32") {
|
|
72419
72782
|
if (process.env.USERPROFILE)
|
|
@@ -72430,42 +72793,42 @@ function expandTildePath(path) {
|
|
|
72430
72793
|
if (path === "~")
|
|
72431
72794
|
return getHomeDir();
|
|
72432
72795
|
if (path.startsWith("~/") || process.platform === "win32" && path.startsWith("~\\")) {
|
|
72433
|
-
return
|
|
72796
|
+
return join31(getHomeDir(), path.slice(2));
|
|
72434
72797
|
}
|
|
72435
72798
|
return path;
|
|
72436
72799
|
}
|
|
72437
|
-
function
|
|
72800
|
+
function getAgentDir6() {
|
|
72438
72801
|
const atomicAgentDir = process.env.ATOMIC_CODING_AGENT_DIR;
|
|
72439
72802
|
if (atomicAgentDir)
|
|
72440
72803
|
return expandTildePath(atomicAgentDir);
|
|
72441
72804
|
const piAgentDir = process.env.PI_CODING_AGENT_DIR;
|
|
72442
72805
|
if (piAgentDir)
|
|
72443
72806
|
return expandTildePath(piAgentDir);
|
|
72444
|
-
return
|
|
72807
|
+
return join31(getHomeDir(), ".atomic", "agent");
|
|
72445
72808
|
}
|
|
72446
72809
|
function sanitizePipeSegment(value2) {
|
|
72447
72810
|
return value2.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "default";
|
|
72448
72811
|
}
|
|
72449
|
-
function getIntercomDirPath(agentDir =
|
|
72450
|
-
return
|
|
72812
|
+
function getIntercomDirPath(agentDir = getAgentDir6()) {
|
|
72813
|
+
return join31(agentDir, "intercom");
|
|
72451
72814
|
}
|
|
72452
|
-
function getBrokerPidPath(agentDir =
|
|
72453
|
-
return
|
|
72815
|
+
function getBrokerPidPath(agentDir = getAgentDir6()) {
|
|
72816
|
+
return join31(getIntercomDirPath(agentDir), "broker.pid");
|
|
72454
72817
|
}
|
|
72455
|
-
function getBrokerSpawnLockPath(agentDir =
|
|
72456
|
-
return
|
|
72818
|
+
function getBrokerSpawnLockPath(agentDir = getAgentDir6()) {
|
|
72819
|
+
return join31(getIntercomDirPath(agentDir), "broker.spawn.lock");
|
|
72457
72820
|
}
|
|
72458
|
-
function getBrokerLogPath(agentDir =
|
|
72459
|
-
return
|
|
72821
|
+
function getBrokerLogPath(agentDir = getAgentDir6()) {
|
|
72822
|
+
return join31(getIntercomDirPath(agentDir), "broker.log");
|
|
72460
72823
|
}
|
|
72461
|
-
function getBrokerStartAnnouncementPath(agentDir =
|
|
72462
|
-
return
|
|
72824
|
+
function getBrokerStartAnnouncementPath(agentDir = getAgentDir6()) {
|
|
72825
|
+
return join31(getIntercomDirPath(agentDir), "broker.starting");
|
|
72463
72826
|
}
|
|
72464
|
-
function getBrokerSocketPath(platform = process.platform, agentDir =
|
|
72827
|
+
function getBrokerSocketPath(platform = process.platform, agentDir = getAgentDir6()) {
|
|
72465
72828
|
if (platform === "win32") {
|
|
72466
72829
|
return `\\\\.\\pipe\\pi-intercom-${sanitizePipeSegment(agentDir)}`;
|
|
72467
72830
|
}
|
|
72468
|
-
return
|
|
72831
|
+
return join31(getIntercomDirPath(agentDir), "broker.sock");
|
|
72469
72832
|
}
|
|
72470
72833
|
var BROKER_STORAGE_ENV = "ATOMIC_STORAGE";
|
|
72471
72834
|
var init_paths = () => {};
|
|
@@ -74639,8 +75002,8 @@ var init_shared_storage_setting = __esm(() => {
|
|
|
74639
75002
|
// dist/builtin/intercom/broker/spawn.ts
|
|
74640
75003
|
import { spawn } from "child_process";
|
|
74641
75004
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
74642
|
-
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as
|
|
74643
|
-
import { join as
|
|
75005
|
+
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as existsSync10, mkdirSync as mkdirSync9, openSync as openSync3, readFileSync as readFileSync8, readSync as readSync2, renameSync, statSync as statSync5, unlinkSync as unlinkSync4, writeFileSync as writeFileSync7 } from "fs";
|
|
75006
|
+
import { join as join32, dirname as dirname17 } from "path";
|
|
74644
75007
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
74645
75008
|
import { createRequire as createRequire3 } from "module";
|
|
74646
75009
|
import {
|
|
@@ -74651,17 +75014,17 @@ import {
|
|
|
74651
75014
|
processSharedStorageSelection
|
|
74652
75015
|
} from "@bastani/atomic";
|
|
74653
75016
|
function isIntercomPackageRoot(dir) {
|
|
74654
|
-
return
|
|
75017
|
+
return existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "broker"));
|
|
74655
75018
|
}
|
|
74656
75019
|
function resolveIntercomPackageRoot(moduleHref) {
|
|
74657
|
-
const here =
|
|
75020
|
+
const here = dirname17(fileURLToPath5(moduleHref));
|
|
74658
75021
|
if (isIntercomPackageRoot(here))
|
|
74659
75022
|
return here;
|
|
74660
|
-
return
|
|
75023
|
+
return join32(here, "..");
|
|
74661
75024
|
}
|
|
74662
75025
|
function resolveBrokerEntrypoint(packageRoot) {
|
|
74663
|
-
const bundled =
|
|
74664
|
-
return
|
|
75026
|
+
const bundled = join32(packageRoot, "broker", "broker.bundle.mjs");
|
|
75027
|
+
return existsSync10(bundled) ? bundled : join32(packageRoot, "broker", "broker.ts");
|
|
74665
75028
|
}
|
|
74666
75029
|
function ensurePrivateDirectory(path) {
|
|
74667
75030
|
mkdirSync9(path, { recursive: true, mode: 448 });
|
|
@@ -74677,14 +75040,14 @@ function getCurrentBrokerRuntime() {
|
|
|
74677
75040
|
return isBunBinary ? "bun-binary" : "bun-source";
|
|
74678
75041
|
}
|
|
74679
75042
|
function requireFromExtensionDir(extensionDir) {
|
|
74680
|
-
return createRequire3(
|
|
75043
|
+
return createRequire3(join32(extensionDir, "package.json"));
|
|
74681
75044
|
}
|
|
74682
75045
|
function getJitiCliPath(extensionDir = EXTENSION_DIR) {
|
|
74683
75046
|
try {
|
|
74684
75047
|
const jitiPackage = requireFromExtensionDir(extensionDir).resolve("jiti/package.json");
|
|
74685
|
-
return
|
|
75048
|
+
return join32(dirname17(jitiPackage), "lib", "jiti-cli.mjs");
|
|
74686
75049
|
} catch {
|
|
74687
|
-
return
|
|
75050
|
+
return join32(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
|
|
74688
75051
|
}
|
|
74689
75052
|
}
|
|
74690
75053
|
function getDefaultBrokerRunnerPath(extensionDir) {
|
|
@@ -74706,7 +75069,7 @@ function quoteWindowsArg(value2) {
|
|
|
74706
75069
|
return `"${value2.replace(/"/g, '""')}"`;
|
|
74707
75070
|
}
|
|
74708
75071
|
function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
|
|
74709
|
-
return
|
|
75072
|
+
return join32(intercomDir, "broker-launch.vbs");
|
|
74710
75073
|
}
|
|
74711
75074
|
function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
|
|
74712
75075
|
return brokerCommand === "npx" && brokerArgs.length === 2 && brokerArgs[0] === "--no-install" && brokerArgs[1] === "tsx";
|
|
@@ -74733,7 +75096,7 @@ function getWindowsHiddenLauncherScript(commandLine) {
|
|
|
74733
75096
|
`);
|
|
74734
75097
|
}
|
|
74735
75098
|
function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHiddenLauncherPath()) {
|
|
74736
|
-
ensurePrivateDirectory(
|
|
75099
|
+
ensurePrivateDirectory(dirname17(launcherPath));
|
|
74737
75100
|
writeFileSync7(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
|
|
74738
75101
|
return launcherPath;
|
|
74739
75102
|
}
|
|
@@ -74777,7 +75140,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
|
|
|
74777
75140
|
};
|
|
74778
75141
|
}
|
|
74779
75142
|
function resetBrokerLog(logPath = getBrokerLogPath()) {
|
|
74780
|
-
ensurePrivateDirectory(
|
|
75143
|
+
ensurePrivateDirectory(dirname17(logPath));
|
|
74781
75144
|
try {
|
|
74782
75145
|
const previous = readBrokerLogTail(logPath);
|
|
74783
75146
|
closeSync3(openSync3(logPath, "w"));
|
|
@@ -74928,7 +75291,7 @@ async function isBrokerRunning() {
|
|
|
74928
75291
|
if (await checkSocketConnectable()) {
|
|
74929
75292
|
return true;
|
|
74930
75293
|
}
|
|
74931
|
-
if (!
|
|
75294
|
+
if (!existsSync10(getBrokerPidPath()))
|
|
74932
75295
|
return false;
|
|
74933
75296
|
try {
|
|
74934
75297
|
const pid = parseInt(readFileSync8(getBrokerPidPath(), "utf-8").trim(), 10);
|
|
@@ -74994,7 +75357,7 @@ function isProcessAlive(pid) {
|
|
|
74994
75357
|
}
|
|
74995
75358
|
}
|
|
74996
75359
|
function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
|
|
74997
|
-
if (!
|
|
75360
|
+
if (!existsSync10(lockPath)) {
|
|
74998
75361
|
return false;
|
|
74999
75362
|
}
|
|
75000
75363
|
try {
|
|
@@ -75121,10 +75484,10 @@ var init_reply_waiter = __esm(() => {
|
|
|
75121
75484
|
});
|
|
75122
75485
|
|
|
75123
75486
|
// dist/builtin/intercom/config.ts
|
|
75124
|
-
import { existsSync as
|
|
75487
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
|
|
75125
75488
|
import { getAgentConfigPaths } from "@bastani/atomic";
|
|
75126
75489
|
function loadConfig() {
|
|
75127
|
-
if (!
|
|
75490
|
+
if (!existsSync11(CONFIG_PATH)) {
|
|
75128
75491
|
return { ...defaults };
|
|
75129
75492
|
}
|
|
75130
75493
|
try {
|
|
@@ -75206,7 +75569,7 @@ var init_config = __esm(() => {
|
|
|
75206
75569
|
init_diagnostics();
|
|
75207
75570
|
init_reply_waiter();
|
|
75208
75571
|
CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
|
|
75209
|
-
CONFIG_PATH = CONFIG_PATHS.find((path) =>
|
|
75572
|
+
CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync11(path)) ?? CONFIG_PATHS[0];
|
|
75210
75573
|
DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
|
|
75211
75574
|
defaults = {
|
|
75212
75575
|
brokerCommand: DEFAULT_BROKER_COMMAND,
|
|
@@ -76563,6 +76926,17 @@ var init_stage_queued_user_messages = __esm(() => {
|
|
|
76563
76926
|
});
|
|
76564
76927
|
});
|
|
76565
76928
|
|
|
76929
|
+
// dist/builtin/workflows/src/shared/legacy-waiting-status.ts
|
|
76930
|
+
function isLegacyWaiting(status) {
|
|
76931
|
+
return status === "waiting";
|
|
76932
|
+
}
|
|
76933
|
+
function stageStatusFromRecord(status) {
|
|
76934
|
+
return status === "waiting" ? "suspended" : status;
|
|
76935
|
+
}
|
|
76936
|
+
function runSnapshotsFromRecord(runs) {
|
|
76937
|
+
return runs.map((run) => run.stages.some((stage) => isLegacyWaiting(stage.status)) ? { ...run, stages: run.stages.map((stage) => ({ ...stage, status: stageStatusFromRecord(stage.status) })) } : run);
|
|
76938
|
+
}
|
|
76939
|
+
|
|
76566
76940
|
// dist/builtin/workflows/src/workers/ended-watches.ts
|
|
76567
76941
|
var EndedWatches;
|
|
76568
76942
|
var init_ended_watches = __esm(() => {
|
|
@@ -76619,14 +76993,14 @@ var UNATTRIBUTED_WRITE = "other";
|
|
|
76619
76993
|
var init_pool_coordination_stats = () => {};
|
|
76620
76994
|
|
|
76621
76995
|
// dist/builtin/workflows/src/workers/pooled-watch-trace.ts
|
|
76622
|
-
import { dirname as
|
|
76996
|
+
import { dirname as dirname18, join as join33, resolve as resolve16 } from "node:path";
|
|
76623
76997
|
import { appendDebugRecord, isDebugEnabled as isDebugEnabled2, reportDebug } from "@bastani/atomic";
|
|
76624
76998
|
function configurePooledWatchTrace(journal, processRole) {
|
|
76625
76999
|
journalPath = journal;
|
|
76626
77000
|
role = processRole;
|
|
76627
77001
|
}
|
|
76628
77002
|
function ownTraceFile(journal, setting) {
|
|
76629
|
-
return setting === "1" ?
|
|
77003
|
+
return setting === "1" ? join33(dirname18(resolve16(journal)), "pooled-watch-trace.jsonl") : resolve16(setting);
|
|
76630
77004
|
}
|
|
76631
77005
|
function tracePooledWatch(step, detail) {
|
|
76632
77006
|
if (!isDebugEnabled2("pooled-watch"))
|
|
@@ -76647,7 +77021,7 @@ var init_pooled_watch_trace = () => {};
|
|
|
76647
77021
|
// dist/builtin/workflows/src/workers/process-log.ts
|
|
76648
77022
|
import { createWriteStream, mkdirSync as mkdirSync10 } from "node:fs";
|
|
76649
77023
|
import { rm as rm3, rmdir } from "node:fs/promises";
|
|
76650
|
-
import { dirname as
|
|
77024
|
+
import { dirname as dirname19 } from "node:path";
|
|
76651
77025
|
function logFailureOf(error) {
|
|
76652
77026
|
const code = error.code;
|
|
76653
77027
|
return typeof code === "string" ? code : error.name;
|
|
@@ -76684,7 +77058,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
|
|
|
76684
77058
|
return { close };
|
|
76685
77059
|
stderr.on("error", fail);
|
|
76686
77060
|
try {
|
|
76687
|
-
mkdirSync10(
|
|
77061
|
+
mkdirSync10(dirname19(logPath), { recursive: true });
|
|
76688
77062
|
} catch (error) {
|
|
76689
77063
|
fail(asError(error));
|
|
76690
77064
|
return { close };
|
|
@@ -76696,7 +77070,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
|
|
|
76696
77070
|
}
|
|
76697
77071
|
async function removeProcessLog(logPath) {
|
|
76698
77072
|
await rm3(logPath, { force: true });
|
|
76699
|
-
await rmdir(
|
|
77073
|
+
await rmdir(dirname19(logPath)).catch((error) => {
|
|
76700
77074
|
const code = error.code;
|
|
76701
77075
|
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
|
|
76702
77076
|
throw error;
|
|
@@ -77366,9 +77740,9 @@ var init_worker_timing = __esm(() => {
|
|
|
77366
77740
|
// dist/builtin/workflows/src/workers/pool-coordinator.ts
|
|
77367
77741
|
import { fork } from "node:child_process";
|
|
77368
77742
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
77369
|
-
import { existsSync as
|
|
77370
|
-
import { appendFile, mkdir as
|
|
77371
|
-
import { delimiter, dirname as
|
|
77743
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
77744
|
+
import { appendFile, mkdir as mkdir7, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
|
|
77745
|
+
import { delimiter, dirname as dirname20, isAbsolute as isAbsolute14, join as join34, resolve as resolve17 } from "node:path";
|
|
77372
77746
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
77373
77747
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
77374
77748
|
import { setDebugSetting } from "@bastani/atomic";
|
|
@@ -77377,10 +77751,10 @@ function unconfirmedCleanup(groups) {
|
|
|
77377
77751
|
return new WorkerCleanupUnconfirmedError({ processGroups: groups });
|
|
77378
77752
|
}
|
|
77379
77753
|
function workerLogDirectory(journalPath, root) {
|
|
77380
|
-
return
|
|
77754
|
+
return join34(dirname20(resolve17(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
|
|
77381
77755
|
}
|
|
77382
77756
|
function traceAnchor(options) {
|
|
77383
|
-
return options.shared === undefined ? options.journalPath :
|
|
77757
|
+
return options.shared === undefined ? options.journalPath : join34(options.shared.stateDirectory, "shared-pool");
|
|
77384
77758
|
}
|
|
77385
77759
|
function token(work) {
|
|
77386
77760
|
return {
|
|
@@ -77828,7 +78202,7 @@ class PoolCoordinator {
|
|
|
77828
78202
|
if (options.shared !== undefined)
|
|
77829
78203
|
this.journal ??= await this.countedJournal(await openDurableJournal(options.durable));
|
|
77830
78204
|
else {
|
|
77831
|
-
if (options.journalShard !== undefined && !
|
|
78205
|
+
if (options.journalShard !== undefined && !existsSync12(options.journalPath))
|
|
77832
78206
|
throw new JournalShardUnavailableError2({
|
|
77833
78207
|
code: "shard-missing",
|
|
77834
78208
|
shardId: options.journalShard,
|
|
@@ -78063,7 +78437,7 @@ class PoolCoordinator {
|
|
|
78063
78437
|
crossHost: true
|
|
78064
78438
|
});
|
|
78065
78439
|
this.logDirectory = workerLogDirectory(traceAnchor(this.options), root);
|
|
78066
|
-
await
|
|
78440
|
+
await mkdir7(this.logDirectory, { recursive: true });
|
|
78067
78441
|
if (this.closed)
|
|
78068
78442
|
return;
|
|
78069
78443
|
this.starting = Promise.resolve();
|
|
@@ -78174,7 +78548,7 @@ class PoolCoordinator {
|
|
|
78174
78548
|
this.activityCursor = Math.max(this.activityCursor, entry.version);
|
|
78175
78549
|
if (local.has(entry.work.id) || !this.attemptBase.has(entry.work.id))
|
|
78176
78550
|
continue;
|
|
78177
|
-
const runs = JSON.parse(entry.runs);
|
|
78551
|
+
const runs = runSnapshotsFromRecord(JSON.parse(entry.runs));
|
|
78178
78552
|
this.pendingActivity.set(entry.work.id, { work: entry.work, runs });
|
|
78179
78553
|
for (const [id, reason] of this.remoteWatches.relayed(entry.work, runs))
|
|
78180
78554
|
this.endRemoteWatch(id, reason);
|
|
@@ -78801,7 +79175,7 @@ class PoolCoordinator {
|
|
|
78801
79175
|
let ready = false;
|
|
78802
79176
|
const lanes = new WorkerRequestLanes;
|
|
78803
79177
|
const extensions = new AttemptLeaseExtensions(slot, (attempt) => this.queue.extend(this.lease, attempt, options.leaseMs));
|
|
78804
|
-
const logPath =
|
|
79178
|
+
const logPath = join34(this.logDirectory, `${id}.log`);
|
|
78805
79179
|
this.logs.set(child, logPath);
|
|
78806
79180
|
appendProcessLog(child.stderr, logPath, (failure) => this.logUnwritable(logPath, failure));
|
|
78807
79181
|
const startupTimeoutMs = options.startupTimeoutMs;
|
|
@@ -79594,7 +79968,7 @@ function withHostGit(env, git) {
|
|
|
79594
79968
|
return {
|
|
79595
79969
|
...env,
|
|
79596
79970
|
...git.env,
|
|
79597
|
-
...isAbsolute14(git.path) ? { [pathKey]: [
|
|
79971
|
+
...isAbsolute14(git.path) ? { [pathKey]: [dirname20(git.path), env[pathKey]].filter(Boolean).join(delimiter) } : {}
|
|
79598
79972
|
};
|
|
79599
79973
|
}
|
|
79600
79974
|
var CONTROL_ACKNOWLEDGEMENT_STALL_MS = 5000, RECOVERY_INTERVAL_MS = 500, TICK_INTERVAL_MS = 100, STALL_THRESHOLD_MS = 500, COORDINATOR_LEASE_MS, LATE_ROOT_POLL_MS, MIRROR_INTERVAL_MS = 1e4, STDERR_DRAIN_GRACE_MS = 1000, WORKER_EXIT_CONFIRMATION_MS = 5000, WORKER_EXIT_POLL_MS = 50, MAX_CHILD_ATTEMPTS = 3, PLACEMENT_CANDIDATES = 32, PREFERENCE_CACHE_MS = 1000, PREFERENCE_CACHE_ENTRIES = 256, SHARED_POLL_MS = 500, SHARED_IDLE_CLAIM_MS = 500, STAGE_INPUT_LEASE_MS = 30000, STAGE_INPUT_RECEIPT_TIMEOUT_MS = 60000, STAGE_INPUT_RETRY_MAX_MS = 4000, WORKER_HOST_TTL_MS = 15000, MAX_WORKER_REPLACEMENTS = 3, ROUTE_REGISTRATION_WAIT_MS = 120000, STAGE_WATCH_BACKLOG_EVENTS = 2000, STAGE_WATCH_BACKLOG_BYTES, PENDING_STAGE_MESSAGE_EVENT2 = "atomic:workflow-pending-stage-message", STICKY_LIVE_DELIVERED_EVENT2 = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_UNDELIVERABLE_EVENT2 = "atomic:workflow-pending-stage-undeliverable", ENDED_WATCHES_REMEMBERED = 1024;
|
|
@@ -79708,7 +80082,7 @@ function remoteStageDrainTargets(generation, runs, queueOf, rootQueue) {
|
|
|
79708
80082
|
for (const stage of run.stages) {
|
|
79709
80083
|
const target = { runId: run.id, stageId: stage.id };
|
|
79710
80084
|
const { sessionId } = stage;
|
|
79711
|
-
if (sessionId === undefined || stage.status === "
|
|
80085
|
+
if (sessionId === undefined || stage.status === "suspended" || stage.pendingStageDeliveryAvailable !== true || isTerminalStageStatus(stage.status))
|
|
79712
80086
|
forget.push(target);
|
|
79713
80087
|
else
|
|
79714
80088
|
drain.push({ target: { ...target, sessionId, generation, queues }, stageName: stage.name });
|
|
@@ -81959,14 +82333,14 @@ class PooledStageRegistrations {
|
|
|
81959
82333
|
var LIVE;
|
|
81960
82334
|
var init_pooled_stage_registry = __esm(() => {
|
|
81961
82335
|
init_stage_queued_user_messages();
|
|
81962
|
-
LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "
|
|
82336
|
+
LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "suspended"]);
|
|
81963
82337
|
});
|
|
81964
82338
|
|
|
81965
82339
|
// dist/builtin/workflows/src/workers/local-pool.ts
|
|
81966
82340
|
import { fork as fork2 } from "node:child_process";
|
|
81967
82341
|
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
81968
|
-
import { existsSync as
|
|
81969
|
-
import { join as
|
|
82342
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
82343
|
+
import { join as join35, resolve as resolve18 } from "node:path";
|
|
81970
82344
|
import { setTimeout as delay5 } from "node:timers/promises";
|
|
81971
82345
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
81972
82346
|
import {
|
|
@@ -82172,7 +82546,7 @@ class LocalWorkerPool {
|
|
|
82172
82546
|
this.options = options;
|
|
82173
82547
|
if (options.shared === undefined ? options.journalPath === undefined : options.durable === undefined)
|
|
82174
82548
|
throw new WorkerPlacementConfigError("sdk", options.shared === undefined ? "journalPath" : "durable", "invalid-option", "a local worker pool needs the database its tables are in");
|
|
82175
|
-
configurePooledWatchTrace(options.shared === undefined ? options.journalPath :
|
|
82549
|
+
configurePooledWatchTrace(options.shared === undefined ? options.journalPath : join35(options.shared.stateDirectory, "shared-pool"), "root");
|
|
82176
82550
|
if (!Number.isSafeInteger(options.workers) || options.workers < 1)
|
|
82177
82551
|
throw new Error("Invalid local worker count");
|
|
82178
82552
|
if (options.startupTimeoutMs !== undefined && (!Number.isSafeInteger(options.startupTimeoutMs) || options.startupTimeoutMs < 1 || options.startupTimeoutMs > MAX_TIMER_DELAY_MS))
|
|
@@ -82210,7 +82584,7 @@ class LocalWorkerPool {
|
|
|
82210
82584
|
async prepare(root, store) {
|
|
82211
82585
|
if (this.closed)
|
|
82212
82586
|
throw new Error("Local worker pool is closed");
|
|
82213
|
-
if (this.options.journalShard !== undefined && !
|
|
82587
|
+
if (this.options.journalShard !== undefined && !existsSync13(this.options.journalPath))
|
|
82214
82588
|
throw new JournalShardUnavailableError3({
|
|
82215
82589
|
code: "shard-missing",
|
|
82216
82590
|
shardId: this.options.journalShard,
|
|
@@ -82992,7 +83366,7 @@ class LocalWorkerPool {
|
|
|
82992
83366
|
const root = this.root;
|
|
82993
83367
|
if (root === undefined)
|
|
82994
83368
|
throw new PoolNotInitializedError({});
|
|
82995
|
-
const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(
|
|
83369
|
+
const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(join35(workerLogDirectory(traceAnchor(this.options), root), "coordinator.log"));
|
|
82996
83370
|
this.coordinator = coordinator;
|
|
82997
83371
|
const outbox = new RateLimitObservationOutbox((observations) => coordinator.port.send({ kind: "rate-limits", observations }));
|
|
82998
83372
|
const unobserve = observeProviderRateLimits((observation) => outbox.offer(observation));
|
|
@@ -83671,8 +84045,8 @@ var init_public_pool = __esm(() => {
|
|
|
83671
84045
|
// dist/builtin/workflows/src/workers/shared-setup.ts
|
|
83672
84046
|
import { constants } from "node:fs";
|
|
83673
84047
|
import { access } from "node:fs/promises";
|
|
83674
|
-
import { dirname as
|
|
83675
|
-
import { getAgentDir as
|
|
84048
|
+
import { dirname as dirname21, isAbsolute as isAbsolute15, join as join36 } from "node:path";
|
|
84049
|
+
import { getAgentDir as getAgentDir7, SettingsManager as SettingsManager2 } from "@bastani/atomic";
|
|
83676
84050
|
import {
|
|
83677
84051
|
loadStorageAdapter,
|
|
83678
84052
|
StorageAdapterLoadError,
|
|
@@ -83708,13 +84082,13 @@ async function sharedSelectionProblems(selection, agentDir) {
|
|
|
83708
84082
|
if ("env" in ref) {
|
|
83709
84083
|
if (process.env[ref.env] === undefined)
|
|
83710
84084
|
problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
|
|
83711
|
-
} else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file :
|
|
84085
|
+
} else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file : join36(dirname21(agentDir), ref.file)))
|
|
83712
84086
|
problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
|
|
83713
84087
|
}
|
|
83714
84088
|
return problems;
|
|
83715
84089
|
}
|
|
83716
84090
|
async function checkSharedPlacementSetup(journal, options = {}) {
|
|
83717
|
-
const agentDir = options.agentDir ??
|
|
84091
|
+
const agentDir = options.agentDir ?? getAgentDir7();
|
|
83718
84092
|
const problems = await sharedSelectionProblems(sharedJournalSelection(journal, { agentDir, ...options.cwd === undefined ? {} : { cwd: options.cwd } }), agentDir);
|
|
83719
84093
|
if (!await processContainmentAvailable())
|
|
83720
84094
|
problems.push(sharedPoolProblems.processContainmentUnavailable());
|
|
@@ -85866,7 +86240,7 @@ function waitForStageStartup(operation, signal) {
|
|
|
85866
86240
|
import {
|
|
85867
86241
|
AutoRoutingInferenceError,
|
|
85868
86242
|
convertToLlm,
|
|
85869
|
-
currentWorktreeRootMappings,
|
|
86243
|
+
currentWorktreeRootMappings as currentWorktreeRootMappings2,
|
|
85870
86244
|
findToolDetachmentError,
|
|
85871
86245
|
isExtensionStartupFailure,
|
|
85872
86246
|
isTaskCleanupError as isTaskCleanupError2,
|
|
@@ -86017,7 +86391,7 @@ class StageSessionController {
|
|
|
86017
86391
|
pauseControl = new StageSessionPause(() => this.session ?? this.residencyState?.replacement.retiringSession);
|
|
86018
86392
|
residencyState;
|
|
86019
86393
|
hasExplicitModelFallbackConfig;
|
|
86020
|
-
runWorktreeRootMappings =
|
|
86394
|
+
runWorktreeRootMappings = currentWorktreeRootMappings2();
|
|
86021
86395
|
candidatesPromise;
|
|
86022
86396
|
scopedModelsPromise;
|
|
86023
86397
|
modelRoute;
|
|
@@ -88460,8 +88834,8 @@ var init_stage_runner_controller = __esm(() => {
|
|
|
88460
88834
|
|
|
88461
88835
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
|
|
88462
88836
|
import { createHash as createHash7 } from "node:crypto";
|
|
88463
|
-
import { mkdir as
|
|
88464
|
-
import { basename as basename6, dirname as
|
|
88837
|
+
import { mkdir as mkdir8, writeFile as writeFile11 } from "node:fs/promises";
|
|
88838
|
+
import { basename as basename6, dirname as dirname22, isAbsolute as isAbsolute16, join as join37, resolve as resolve20 } from "node:path";
|
|
88465
88839
|
function normalizeMaxOutput2(maxOutput) {
|
|
88466
88840
|
return {
|
|
88467
88841
|
bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
@@ -88524,7 +88898,7 @@ function formatByteSize(bytes) {
|
|
|
88524
88898
|
}
|
|
88525
88899
|
function transcriptPath(runId, outputPath) {
|
|
88526
88900
|
const digest = createHash7("sha256").update(outputPath).digest("hex").slice(0, 16);
|
|
88527
|
-
return
|
|
88901
|
+
return join37(workflowArtifactRunPath(runId), "transcripts", `${digest}-${basename6(outputPath)}.transcript.md`);
|
|
88528
88902
|
}
|
|
88529
88903
|
function appendContent(lines, content) {
|
|
88530
88904
|
if (typeof content === "string") {
|
|
@@ -88645,8 +89019,8 @@ async function finalizePromptOutput(fullOutput, outputOptions, runtimeCwd, runId
|
|
|
88645
89019
|
const transcriptFile = transcriptPath(runId, outputPath);
|
|
88646
89020
|
const transcript = renderTranscript(messages, fullOutput);
|
|
88647
89021
|
try {
|
|
88648
|
-
await
|
|
88649
|
-
await
|
|
89022
|
+
await mkdir8(dirname22(outputPath), { recursive: true });
|
|
89023
|
+
await writeFile11(outputPath, fullOutput, "utf8");
|
|
88650
89024
|
} catch (err) {
|
|
88651
89025
|
return `${displayOutput}
|
|
88652
89026
|
|
|
@@ -88657,8 +89031,8 @@ ${err instanceof Error ? err.message : String(err)}`;
|
|
|
88657
89031
|
let transcriptError;
|
|
88658
89032
|
try {
|
|
88659
89033
|
await ensureWorkflowArtifactRunDirectory(runId);
|
|
88660
|
-
await
|
|
88661
|
-
await
|
|
89034
|
+
await mkdir8(dirname22(transcriptFile), { recursive: true });
|
|
89035
|
+
await writeFile11(transcriptFile, transcript, "utf8");
|
|
88662
89036
|
transcriptAvailable = true;
|
|
88663
89037
|
} catch (err) {
|
|
88664
89038
|
transcriptError = err instanceof Error ? err.message : String(err);
|
|
@@ -89873,7 +90247,7 @@ var init_child_workflow_failure_message = __esm(() => {
|
|
|
89873
90247
|
});
|
|
89874
90248
|
|
|
89875
90249
|
// dist/builtin/workflows/src/engine/primitives/workflow.ts
|
|
89876
|
-
import { existsSync as
|
|
90250
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
89877
90251
|
import {
|
|
89878
90252
|
acquireWorkspaceWriterLease,
|
|
89879
90253
|
isBoundWorkspace as isBoundWorkspace4,
|
|
@@ -90065,7 +90439,7 @@ async function bindChildWorkspace(workspace, invocation, signal, owner, restored
|
|
|
90065
90439
|
binding = recorded;
|
|
90066
90440
|
} catch (error) {
|
|
90067
90441
|
const worktree = mapWorkflowWorktreePath(recorded.worktree, restored);
|
|
90068
|
-
if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree ||
|
|
90442
|
+
if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree || existsSync14(recorded.worktree))
|
|
90069
90443
|
throw error;
|
|
90070
90444
|
binding = { ...recorded, worktree };
|
|
90071
90445
|
}
|
|
@@ -92390,7 +92764,7 @@ function runSnapshotsFromCheckpoints(checkpoints, rootRunId, rootRunName, fallba
|
|
|
92390
92764
|
return runs;
|
|
92391
92765
|
}
|
|
92392
92766
|
function stageSnapshotFromDraft(draft, id, parentIds) {
|
|
92393
|
-
const status = draft.topology?.status ?? "completed";
|
|
92767
|
+
const status = stageStatusFromRecord(draft.topology?.status ?? "completed");
|
|
92394
92768
|
const startedAt = draft.startedAt ?? draft.firstCompletedAt;
|
|
92395
92769
|
const endedAt = draft.endedAt ?? (status === "running" ? undefined : draft.firstCompletedAt);
|
|
92396
92770
|
const workflowChild = workflowChildFromDraft(draft);
|
|
@@ -95046,7 +95420,7 @@ function createStageControlHandle(runtime) {
|
|
|
95046
95420
|
readinessPauseVersion = (runtime.state.readinessPauseVersion ?? 0) + 1;
|
|
95047
95421
|
runtime.state.readinessPauseVersion = readinessPauseVersion;
|
|
95048
95422
|
}
|
|
95049
|
-
if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "
|
|
95423
|
+
if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "suspended" || runtime.innerCtx.isStreaming) {
|
|
95050
95424
|
try {
|
|
95051
95425
|
await runtime.innerCtx.__requestPause();
|
|
95052
95426
|
} catch (error) {
|
|
@@ -95511,14 +95885,14 @@ function createWorkflowStageFactory(input) {
|
|
|
95511
95885
|
return;
|
|
95512
95886
|
statusBeforeRelease = wait.kind !== "tool" || stageSnapshot.status === "completed" || stageSnapshot.status === "failed" ? stageSnapshot.status : undefined;
|
|
95513
95887
|
if (stageSnapshot.status !== "paused")
|
|
95514
|
-
stageSnapshot.status = "
|
|
95888
|
+
stageSnapshot.status = "suspended";
|
|
95515
95889
|
if (wait.kind !== "tool")
|
|
95516
95890
|
idleReleaser.trackReleased(stageId, settleReleased);
|
|
95517
95891
|
};
|
|
95518
95892
|
const settleReleased = () => {
|
|
95519
95893
|
shownWait = undefined;
|
|
95520
95894
|
delete stageSnapshot.wait;
|
|
95521
|
-
if (stageSnapshot.status === "
|
|
95895
|
+
if (stageSnapshot.status === "suspended")
|
|
95522
95896
|
stageSnapshot.status = statusBeforeRelease ?? "completed";
|
|
95523
95897
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
95524
95898
|
};
|
|
@@ -95600,7 +95974,7 @@ function createWorkflowStageFactory(input) {
|
|
|
95600
95974
|
}
|
|
95601
95975
|
runtime.abortListeners.attach();
|
|
95602
95976
|
delete stageSnapshot.wait;
|
|
95603
|
-
if (stageSnapshot.status === "
|
|
95977
|
+
if (stageSnapshot.status === "suspended")
|
|
95604
95978
|
stageSnapshot.status = statusBeforeRelease ?? "running";
|
|
95605
95979
|
statusBeforeRelease = undefined;
|
|
95606
95980
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
@@ -95904,7 +96278,7 @@ function createWorkflowStageFactory(input) {
|
|
|
95904
96278
|
await dropStageControlForCompletion();
|
|
95905
96279
|
if (shownWait !== undefined) {
|
|
95906
96280
|
statusBeforeRelease = "completed";
|
|
95907
|
-
stageSnapshot.status = "
|
|
96281
|
+
stageSnapshot.status = "suspended";
|
|
95908
96282
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
95909
96283
|
}
|
|
95910
96284
|
return recorded;
|
|
@@ -96309,7 +96683,7 @@ import {
|
|
|
96309
96683
|
formatWorktreeRestoreWarning,
|
|
96310
96684
|
resolveWorktreeSnapshotSettings as resolveWorktreeSnapshotSettings2,
|
|
96311
96685
|
scheduleSnapshotCollection,
|
|
96312
|
-
|
|
96686
|
+
setUpResumedRunWorktrees,
|
|
96313
96687
|
withWorktreeRootMappings as withWorktreeRootMappings3
|
|
96314
96688
|
} from "@bastani/atomic";
|
|
96315
96689
|
async function run(def, inputs, opts = {}) {
|
|
@@ -96374,15 +96748,27 @@ async function run(def, inputs, opts = {}) {
|
|
|
96374
96748
|
createdAt: Date.now()
|
|
96375
96749
|
})
|
|
96376
96750
|
});
|
|
96377
|
-
if (restored.length > 0) {
|
|
96751
|
+
if (mappings.length > 0 || restored.length > 0) {
|
|
96378
96752
|
const snapshots = new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
|
|
96379
96753
|
boundary.snapshot.id,
|
|
96380
96754
|
boundary.snapshot
|
|
96381
96755
|
]));
|
|
96382
|
-
|
|
96383
|
-
|
|
96384
|
-
|
|
96385
|
-
|
|
96756
|
+
const resumeToken = crypto.randomUUID();
|
|
96757
|
+
let blueprintNoticeCount = 0;
|
|
96758
|
+
await setUpResumedRunWorktrees({ restored, mappings, snapshots }, {
|
|
96759
|
+
signal: opts.signal,
|
|
96760
|
+
onNotices: (notices) => {
|
|
96761
|
+
for (const notice of notices) {
|
|
96762
|
+
activeStore.recordNotice({
|
|
96763
|
+
id: `workflow-blueprint:${runId}:${resumeToken}:${blueprintNoticeCount++}`,
|
|
96764
|
+
runId,
|
|
96765
|
+
level: notice.type,
|
|
96766
|
+
message: notice.message,
|
|
96767
|
+
createdAt: Date.now()
|
|
96768
|
+
});
|
|
96769
|
+
}
|
|
96770
|
+
}
|
|
96771
|
+
});
|
|
96386
96772
|
}
|
|
96387
96773
|
const allMappings = [...mappings, ...restored];
|
|
96388
96774
|
if (restored.length > 0) {
|
|
@@ -97924,12 +98310,12 @@ var init_registry = () => {};
|
|
|
97924
98310
|
|
|
97925
98311
|
// dist/builtin/workflows/src/extension/discovery-loaders.ts
|
|
97926
98312
|
import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
97927
|
-
import { extname, isAbsolute as isAbsolute18, join as
|
|
98313
|
+
import { extname, isAbsolute as isAbsolute18, join as join38, resolve as resolve22 } from "node:path";
|
|
97928
98314
|
async function scanWorkflowDir(dir) {
|
|
97929
98315
|
try {
|
|
97930
98316
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
97931
98317
|
const WORKFLOW_EXTS = new Set([".ts", ".js", ".mjs", ".cjs"]);
|
|
97932
|
-
return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) =>
|
|
98318
|
+
return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) => join38(dir, e.name)).sort();
|
|
97933
98319
|
} catch {
|
|
97934
98320
|
return null;
|
|
97935
98321
|
}
|
|
@@ -97996,16 +98382,16 @@ var init_discovery_loaders = __esm(() => {
|
|
|
97996
98382
|
});
|
|
97997
98383
|
|
|
97998
98384
|
// dist/builtin/workflows/src/extension/discovery.ts
|
|
97999
|
-
import { join as
|
|
98000
|
-
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as
|
|
98385
|
+
import { join as join39 } from "node:path";
|
|
98386
|
+
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as getAgentDir8 } from "@bastani/atomic";
|
|
98001
98387
|
function workflowAgentDirs(options) {
|
|
98002
98388
|
if (options?.agentDirs !== undefined)
|
|
98003
98389
|
return options.agentDirs;
|
|
98004
98390
|
if (options?.homeDir !== undefined) {
|
|
98005
98391
|
const homeDir = options.homeDir;
|
|
98006
|
-
return [
|
|
98392
|
+
return [join39(homeDir, CONFIG_DIR_NAME2, "agent")];
|
|
98007
98393
|
}
|
|
98008
|
-
return [
|
|
98394
|
+
return [getAgentDir8()];
|
|
98009
98395
|
}
|
|
98010
98396
|
function validateConfig(config) {
|
|
98011
98397
|
if (config === null || typeof config !== "object") {
|
|
@@ -98159,7 +98545,7 @@ async function discoverWorkflows(options) {
|
|
|
98159
98545
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98160
98546
|
}
|
|
98161
98547
|
}
|
|
98162
|
-
for (const dir of [
|
|
98548
|
+
for (const dir of [join39(cwd, CONFIG_DIR_NAME2, "workflows")]) {
|
|
98163
98549
|
const candidates = await loadFromDir(dir, "project-local", diagnostics, getWorkflowHostModules);
|
|
98164
98550
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98165
98551
|
}
|
|
@@ -98171,7 +98557,7 @@ async function discoverWorkflows(options) {
|
|
|
98171
98557
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98172
98558
|
}
|
|
98173
98559
|
}
|
|
98174
|
-
for (const dir of agentDirs.map((agentDir) =>
|
|
98560
|
+
for (const dir of agentDirs.map((agentDir) => join39(agentDir, "workflows")).reverse()) {
|
|
98175
98561
|
const candidates = await loadFromDir(dir, "user-global", diagnostics, getWorkflowHostModules);
|
|
98176
98562
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98177
98563
|
}
|
|
@@ -98475,10 +98861,10 @@ var init_snapshot_restore = __esm(() => {
|
|
|
98475
98861
|
|
|
98476
98862
|
// dist/builtin/workflows/src/workers/worker-host.ts
|
|
98477
98863
|
import { execFile as execFile2 } from "node:child_process";
|
|
98478
|
-
import { existsSync as
|
|
98479
|
-
import { join as
|
|
98864
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
98865
|
+
import { join as join40 } from "node:path";
|
|
98480
98866
|
import {
|
|
98481
|
-
getAgentDir as
|
|
98867
|
+
getAgentDir as getAgentDir9,
|
|
98482
98868
|
isGitProvisionError as isGitProvisionError4,
|
|
98483
98869
|
resolveGit as resolveGit2,
|
|
98484
98870
|
resolveGitSync as resolveGitSync2,
|
|
@@ -98553,7 +98939,7 @@ function probeGit(git) {
|
|
|
98553
98939
|
async function runnableSources(root) {
|
|
98554
98940
|
const sources = [];
|
|
98555
98941
|
for (const source of root.config.definitions) {
|
|
98556
|
-
if (!
|
|
98942
|
+
if (!existsSync15(source.path))
|
|
98557
98943
|
continue;
|
|
98558
98944
|
const digest = await definitionDigest(source.path);
|
|
98559
98945
|
if (digest === source.digest)
|
|
@@ -98824,17 +99210,21 @@ function hostRestorePort(options, git, shared, journal, agentDir) {
|
|
|
98824
99210
|
const restore = snapshotRestore({
|
|
98825
99211
|
recorded: (binding) => shared.recordedSnapshots(binding),
|
|
98826
99212
|
blobs: journal.snapshotBlobs,
|
|
98827
|
-
storeDir:
|
|
99213
|
+
storeDir: join40(agentDir, "worktree-snapshots"),
|
|
98828
99214
|
git
|
|
98829
99215
|
});
|
|
98830
|
-
return (binding, hook) => restoreRunWorktree(hook.snapshot?.
|
|
99216
|
+
return (binding, hook) => restoreRunWorktree(hook.snapshot?.remotes, () => restore(binding, hook), {
|
|
98831
99217
|
signal: hook.signal,
|
|
98832
|
-
agentDir
|
|
99218
|
+
agentDir,
|
|
99219
|
+
onNotices: (notices) => {
|
|
99220
|
+
for (const notice of notices)
|
|
99221
|
+
console.warn(`atomic-workflows: ${notice.message}`);
|
|
99222
|
+
}
|
|
98833
99223
|
});
|
|
98834
99224
|
}
|
|
98835
99225
|
async function startWorkflowWorkerHost(options) {
|
|
98836
99226
|
validated(options);
|
|
98837
|
-
const agentDir = options.agentDir ??
|
|
99227
|
+
const agentDir = options.agentDir ?? getAgentDir9();
|
|
98838
99228
|
const { selection, git, gitCommand } = await checkHostSetup(options, agentDir);
|
|
98839
99229
|
const journal = await openSelectedRunJournal(selection, agentDir);
|
|
98840
99230
|
try {
|