@bastani/atomic 0.9.74-alpha.1 → 0.9.75-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -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 +48 -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
|
@@ -1857,6 +1857,9 @@ function validateText(field, value2) {
|
|
|
1857
1857
|
if (/\p{Surrogate}/u.test(value2))
|
|
1858
1858
|
throw new JournalInvalidTextError(field, "ill-formed-unicode");
|
|
1859
1859
|
}
|
|
1860
|
+
function runStatusFromRecord(status) {
|
|
1861
|
+
return status === "waiting" ? "suspended" : status;
|
|
1862
|
+
}
|
|
1860
1863
|
function serializeJson(value2) {
|
|
1861
1864
|
const text = JSON.stringify(value2);
|
|
1862
1865
|
return text.replace(/\p{Surrogate}/gu, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
@@ -1950,13 +1953,17 @@ class MemoryRunJournal {
|
|
|
1950
1953
|
this.ensureOpen();
|
|
1951
1954
|
validateText("runId", runId);
|
|
1952
1955
|
const run = this.runs.get(runId);
|
|
1953
|
-
return run ?
|
|
1956
|
+
return run ? this.summaryOf(run) : undefined;
|
|
1954
1957
|
}
|
|
1955
1958
|
async listRuns(filter) {
|
|
1956
1959
|
this.ensureOpen();
|
|
1957
1960
|
if (filter?.cwd !== undefined)
|
|
1958
1961
|
validateText("cwd", filter.cwd);
|
|
1959
|
-
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) =>
|
|
1962
|
+
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));
|
|
1963
|
+
}
|
|
1964
|
+
summaryOf(run) {
|
|
1965
|
+
const summary = JSON.parse(serializeJson(run.header));
|
|
1966
|
+
return { ...summary, status: runStatusFromRecord(summary.status) };
|
|
1960
1967
|
}
|
|
1961
1968
|
requireRun(runId) {
|
|
1962
1969
|
this.ensureOpen();
|
|
@@ -3944,7 +3951,7 @@ class SqlRunJournal {
|
|
|
3944
3951
|
return this.operation(async () => {
|
|
3945
3952
|
const row = await this.database.get(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
3946
3953
|
const found = row ?? await this.legacy?.find(this.database, runId);
|
|
3947
|
-
return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: found[JOURNAL_COLUMNS.status] } : undefined;
|
|
3954
|
+
return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: runStatusFromRecord(found[JOURNAL_COLUMNS.status]) } : undefined;
|
|
3948
3955
|
});
|
|
3949
3956
|
}
|
|
3950
3957
|
async listRuns(filter) {
|
|
@@ -3954,7 +3961,10 @@ class SqlRunJournal {
|
|
|
3954
3961
|
return this.operation(async () => {
|
|
3955
3962
|
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]);
|
|
3956
3963
|
const legacy = await this.legacy?.pending(this.database, filter) ?? [];
|
|
3957
|
-
return [...rows, ...legacy].map((row) => ({
|
|
3964
|
+
return [...rows, ...legacy].map((row) => ({
|
|
3965
|
+
...JSON.parse(row[JOURNAL_COLUMNS.headerJson]),
|
|
3966
|
+
status: runStatusFromRecord(row[JOURNAL_COLUMNS.status])
|
|
3967
|
+
})).sort((left, right) => left.runId < right.runId ? -1 : left.runId > right.runId ? 1 : 0);
|
|
3958
3968
|
});
|
|
3959
3969
|
}
|
|
3960
3970
|
async changeToken() {
|
|
@@ -7108,7 +7118,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
7108
7118
|
const context = (action) => action();
|
|
7109
7119
|
const results = await journal.appendMany(held, [
|
|
7110
7120
|
{ event: { type: "RunStarted", payload: null }, key: "start", context },
|
|
7111
|
-
{ event: { type: "StatusChanged", payload: { status: "
|
|
7121
|
+
{ event: { type: "StatusChanged", payload: { status: "suspended" } }, context },
|
|
7112
7122
|
{ event: { type: "RunFinished", payload: null }, key: "start", context }
|
|
7113
7123
|
]);
|
|
7114
7124
|
assert.deepEqual(results.map((result) => result.status === "fulfilled" ? [result.value.status, result.value.entry.seq] : []), [
|
|
@@ -7117,7 +7127,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
7117
7127
|
["exists", 1]
|
|
7118
7128
|
]);
|
|
7119
7129
|
assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
|
|
7120
|
-
assert.equal((await journal.getRun(header.runId))?.status, "
|
|
7130
|
+
assert.equal((await journal.getRun(header.runId))?.status, "suspended");
|
|
7121
7131
|
assert.equal((await journal.takeover(header.runId, "next", held.holderId)).status, "acquired");
|
|
7122
7132
|
await assert.rejects(journal.appendMany(held, [{ event: { type: "RunFinished", payload: null }, context }]), StaleLeaseError);
|
|
7123
7133
|
assert.equal((await entries(journal)).length, 2);
|
|
@@ -7131,14 +7141,14 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
7131
7141
|
const results = await journal.appendMany(held, [
|
|
7132
7142
|
{ event: { type: "RunStarted", payload: null }, context },
|
|
7133
7143
|
{ event: { type: "StatusChanged", payload: { status: "bad\x00status" } }, context },
|
|
7134
|
-
{ event: { type: "StatusChanged", payload: { status: "
|
|
7144
|
+
{ event: { type: "StatusChanged", payload: { status: "suspended" } }, context }
|
|
7135
7145
|
]);
|
|
7136
7146
|
assert.deepEqual(results.map((result) => result.status), ["fulfilled", "rejected", "fulfilled"]);
|
|
7137
|
-
const [started, invalid,
|
|
7147
|
+
const [started, invalid, suspended] = results;
|
|
7138
7148
|
assert.ok(invalid?.status === "rejected" && invalid.reason instanceof JournalInvalidTextError);
|
|
7139
|
-
assert.deepEqual([started,
|
|
7149
|
+
assert.deepEqual([started, suspended].map((result) => result?.status === "fulfilled" ? result.value.entry.seq : undefined), [1, 2]);
|
|
7140
7150
|
assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
|
|
7141
|
-
assert.equal((await journal.getRun(header.runId))?.status, "
|
|
7151
|
+
assert.equal((await journal.getRun(header.runId))?.status, "suspended");
|
|
7142
7152
|
});
|
|
7143
7153
|
check("optional createRunWithEvents creates a run with its events atomically, or nothing", async (journal) => {
|
|
7144
7154
|
const createRunWithEvents = journal.createRunWithEvents;
|
|
@@ -12618,7 +12628,7 @@ function createStageStoreMethods(context) {
|
|
|
12618
12628
|
}
|
|
12619
12629
|
if (stage.status === "running" && context.observation.liveRunIds.has(runId)) {
|
|
12620
12630
|
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stage.id));
|
|
12621
|
-
} else if (stage.status === "
|
|
12631
|
+
} else if (stage.status === "suspended") {
|
|
12622
12632
|
context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stage.id));
|
|
12623
12633
|
}
|
|
12624
12634
|
context.bumpAndNotify({ runId, stageId: stage.id });
|
|
@@ -12944,7 +12954,7 @@ function createStageStoreMethods(context) {
|
|
|
12944
12954
|
const resumedTs = nextControlTimestamp(resumedAt, stage.pausedAt);
|
|
12945
12955
|
if (context.observation.liveRunIds.has(runId) && stage.wait === undefined)
|
|
12946
12956
|
context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stageId));
|
|
12947
|
-
stage.status = stage.wait === undefined ? "running" : "
|
|
12957
|
+
stage.status = stage.wait === undefined ? "running" : "suspended";
|
|
12948
12958
|
if (stage.startedAt !== undefined) {
|
|
12949
12959
|
stage.pausedDurationMs = accumulatePausedDurationMs(stage.pausedDurationMs, stage.pausedAt, resumedTs);
|
|
12950
12960
|
}
|
|
@@ -15400,7 +15410,12 @@ var init_stage_session_store = __esm(() => {
|
|
|
15400
15410
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts
|
|
15401
15411
|
import {
|
|
15402
15412
|
bindSessionWorkspace,
|
|
15413
|
+
currentWorktreeRootMappings,
|
|
15414
|
+
getAgentDir as getAgentDir3,
|
|
15415
|
+
mapRestoredPath,
|
|
15416
|
+
recordRestoredWorktreeContext,
|
|
15403
15417
|
resolveWorkspace,
|
|
15418
|
+
resumeStoreDir,
|
|
15404
15419
|
SessionManager as SessionManager2,
|
|
15405
15420
|
workspaceSessionCwd
|
|
15406
15421
|
} from "@bastani/atomic";
|
|
@@ -15481,6 +15496,13 @@ async function stripWorkflowOnlyOptions2(options, defaultSessionDir, meta, pendi
|
|
|
15481
15496
|
sessionOptions.sessionManager = await SessionManager2.create(cwd, sessionDir ?? defaultSessionDir, classification);
|
|
15482
15497
|
}
|
|
15483
15498
|
}
|
|
15499
|
+
const manager = sessionOptions.sessionManager;
|
|
15500
|
+
if (manager !== undefined) {
|
|
15501
|
+
const mappings = [...manager.getWorktreeRootMappings(), ...currentWorktreeRootMappings()];
|
|
15502
|
+
const notKept = await recordRestoredWorktreeContext(manager, resumeStoreDir(sessionOptions.agentDir ?? getAgentDir3()), mapRestoredPath(cwd, mappings));
|
|
15503
|
+
if (notKept !== undefined)
|
|
15504
|
+
console.warn(`atomic-workflows: ${notKept.message}`);
|
|
15505
|
+
}
|
|
15484
15506
|
return {
|
|
15485
15507
|
...sessionOptions,
|
|
15486
15508
|
...fallbackModels?.length === 0 ? { fallbackModels: [] } : {},
|
|
@@ -17264,7 +17286,7 @@ var init_child_primitive = __esm(() => {
|
|
|
17264
17286
|
});
|
|
17265
17287
|
|
|
17266
17288
|
// dist/builtin/workflows/src/durable/factory.ts
|
|
17267
|
-
import { getAgentDir as
|
|
17289
|
+
import { getAgentDir as getAgentDir4, SettingsManager } from "@bastani/atomic";
|
|
17268
17290
|
import { storageSelectionKey } from "@bastani/atomic/storage";
|
|
17269
17291
|
function abandonOpening(selected, key, entry) {
|
|
17270
17292
|
if (selected.get(key) === entry)
|
|
@@ -17283,7 +17305,7 @@ function abandonOpening(selected, key, entry) {
|
|
|
17283
17305
|
async function initializeDurableBackend(options = {}) {
|
|
17284
17306
|
const owner = getDurableBackendProcessOwner();
|
|
17285
17307
|
const choice = options.journal;
|
|
17286
|
-
const agentDir = options.agentDir ??
|
|
17308
|
+
const agentDir = options.agentDir ?? getAgentDir4();
|
|
17287
17309
|
const selection = selectRunJournal({
|
|
17288
17310
|
agentDir,
|
|
17289
17311
|
journal: choice,
|
|
@@ -17354,7 +17376,7 @@ async function runRestorePreconditionFailure(journal, runId, mappings, settings,
|
|
|
17354
17376
|
for (const boundary of workflowSnapshotFrontier(await listWorkflowSnapshotBoundaries(journal, runId))) {
|
|
17355
17377
|
const here = mapWorkflowWorktreePath(boundary.root, mappings);
|
|
17356
17378
|
if (await worktreeNeedsRestore(boundary.snapshot, here, { settings, signal })) {
|
|
17357
|
-
restoring.push({ root: boundary.root,
|
|
17379
|
+
restoring.push({ root: boundary.root, remotes: boundary.snapshot.remotes });
|
|
17358
17380
|
}
|
|
17359
17381
|
}
|
|
17360
17382
|
return await runRestorePreconditionError(runId, restoring);
|
|
@@ -17678,12 +17700,12 @@ var init_workflow_artifact_env = __esm(() => {
|
|
|
17678
17700
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17679
17701
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
17680
17702
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
17681
|
-
import { getAgentDir as
|
|
17703
|
+
import { getAgentDir as getAgentDir5, getEnvValue } from "@bastani/atomic";
|
|
17682
17704
|
function workflowArtifactRoot() {
|
|
17683
17705
|
const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
17684
17706
|
if (override !== undefined && override.length > 0)
|
|
17685
17707
|
return override;
|
|
17686
|
-
return join5(dirname4(
|
|
17708
|
+
return join5(dirname4(getAgentDir5()), "workflows");
|
|
17687
17709
|
}
|
|
17688
17710
|
function workflowArtifactRunsRoot() {
|
|
17689
17711
|
return join5(workflowArtifactRoot(), "runs");
|
|
@@ -20290,6 +20312,7 @@ var init_structured_output_errors = __esm(() => {
|
|
|
20290
20312
|
import {
|
|
20291
20313
|
AgentRehydrateError,
|
|
20292
20314
|
BackgroundCompactionError,
|
|
20315
|
+
BlueprintError,
|
|
20293
20316
|
DebugError,
|
|
20294
20317
|
DecisionError,
|
|
20295
20318
|
deserializeGitHubCopilotError,
|
|
@@ -20301,17 +20324,21 @@ import {
|
|
|
20301
20324
|
IntercomBrokerError,
|
|
20302
20325
|
isGitProvisionError as isGitProvisionError3,
|
|
20303
20326
|
isSerializedBackgroundCompactionError,
|
|
20327
|
+
isSerializedMissingSessionCwdError,
|
|
20304
20328
|
LlamaServerError,
|
|
20329
|
+
MissingSessionCwdError,
|
|
20305
20330
|
parseSerializedDecisionError,
|
|
20306
20331
|
ResumeError,
|
|
20307
20332
|
rehydrateAgentRehydrateError,
|
|
20308
20333
|
rehydrateBackgroundCompactionError,
|
|
20334
|
+
rehydrateBlueprintError,
|
|
20309
20335
|
rehydrateDebugError,
|
|
20310
20336
|
rehydrateDecisionError,
|
|
20311
20337
|
rehydrateEditToolError,
|
|
20312
20338
|
rehydrateGitProvisionError as rehydrateGitProvisionError2,
|
|
20313
20339
|
rehydrateIntercomBrokerError,
|
|
20314
20340
|
rehydrateLlamaServerError,
|
|
20341
|
+
rehydrateMissingSessionCwdError,
|
|
20315
20342
|
rehydrateResumeError,
|
|
20316
20343
|
rehydrateSessionStartError,
|
|
20317
20344
|
rehydrateShellToolError,
|
|
@@ -20327,11 +20354,13 @@ import {
|
|
|
20327
20354
|
SubscriptionError,
|
|
20328
20355
|
serializeAgentRehydrateError,
|
|
20329
20356
|
serializeBackgroundCompactionError,
|
|
20357
|
+
serializeBlueprintError,
|
|
20330
20358
|
serializeDebugError,
|
|
20331
20359
|
serializeDecisionError,
|
|
20332
20360
|
serializeFileToolError,
|
|
20333
20361
|
serializeGitHubCopilotError,
|
|
20334
20362
|
serializeIntercomBrokerError,
|
|
20363
|
+
serializeMissingSessionCwdError,
|
|
20335
20364
|
serializeResumeError,
|
|
20336
20365
|
serializeSessionStartError,
|
|
20337
20366
|
serializeSubscriptionError,
|
|
@@ -20509,6 +20538,22 @@ var init_serializable_error_families = __esm(() => {
|
|
|
20509
20538
|
},
|
|
20510
20539
|
rehydrate: rehydrateResumeError
|
|
20511
20540
|
}),
|
|
20541
|
+
"missing-session-cwd": family({
|
|
20542
|
+
is: instanceOf(MissingSessionCwdError),
|
|
20543
|
+
serialize: (error) => {
|
|
20544
|
+
const { cause: _cause, ...form } = serializeMissingSessionCwdError(error);
|
|
20545
|
+
return form;
|
|
20546
|
+
},
|
|
20547
|
+
rehydrate: (form, cause) => isSerializedMissingSessionCwdError(form) ? rehydrateMissingSessionCwdError(form, cause) : undefined
|
|
20548
|
+
}),
|
|
20549
|
+
blueprint: family({
|
|
20550
|
+
is: instanceOf(BlueprintError),
|
|
20551
|
+
serialize: (error) => {
|
|
20552
|
+
const { cause: _cause, ...form } = serializeBlueprintError(error);
|
|
20553
|
+
return form;
|
|
20554
|
+
},
|
|
20555
|
+
rehydrate: rehydrateBlueprintError
|
|
20556
|
+
}),
|
|
20512
20557
|
"structured-output": family({
|
|
20513
20558
|
is: instanceOf(WorkflowStructuredOutputInferenceError),
|
|
20514
20559
|
serialize: (error) => error.toJSON(),
|
|
@@ -23431,7 +23476,7 @@ function createStageControlRegistry() {
|
|
|
23431
23476
|
if (!runMap)
|
|
23432
23477
|
return [];
|
|
23433
23478
|
const controlEntries = controlledEntries(runId);
|
|
23434
|
-
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 === "
|
|
23479
|
+
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");
|
|
23435
23480
|
const before = new Map(controlEntries.map((entry) => [entry.handle.stageId, entry.handle.status]));
|
|
23436
23481
|
for (const handle of targets) {
|
|
23437
23482
|
if (handle.status === "paused")
|
|
@@ -67341,12 +67386,260 @@ var init_loop_until_done = __esm(() => {
|
|
|
67341
67386
|
});
|
|
67342
67387
|
});
|
|
67343
67388
|
|
|
67389
|
+
// dist/builtin/workflows/builtin/open-claude-design-images.ts
|
|
67390
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
67391
|
+
import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile8 } from "node:fs/promises";
|
|
67392
|
+
import { dirname as dirname13, join as join24 } from "node:path";
|
|
67393
|
+
import { AuthStorage } from "@bastani/atomic";
|
|
67394
|
+
import { builtinModels } from "@bastani/pi-ai/providers/all";
|
|
67395
|
+
import { Type as Type18 } from "typebox";
|
|
67396
|
+
function parseGptImageId(id) {
|
|
67397
|
+
const groups = GPT_IMAGE_ID.exec(id)?.groups;
|
|
67398
|
+
if (groups?.version === undefined)
|
|
67399
|
+
return;
|
|
67400
|
+
return { version: groups.version.split(".").map(Number), variant: groups.variant };
|
|
67401
|
+
}
|
|
67402
|
+
function compareVersions(left, right) {
|
|
67403
|
+
const differences = Array.from({ length: Math.max(left.length, right.length) }, (_, index) => (left[index] ?? 0) - (right[index] ?? 0));
|
|
67404
|
+
return differences.find((difference) => difference !== 0) ?? 0;
|
|
67405
|
+
}
|
|
67406
|
+
function variantRank(variant) {
|
|
67407
|
+
if (variant === undefined)
|
|
67408
|
+
return 0;
|
|
67409
|
+
if (LOWER_TIER_VARIANTS.has(variant))
|
|
67410
|
+
return -1;
|
|
67411
|
+
const preferred = PREFERRED_VARIANTS.indexOf(variant);
|
|
67412
|
+
return preferred === -1 ? 1 : PREFERRED_VARIANTS.length - preferred + 1;
|
|
67413
|
+
}
|
|
67414
|
+
function compareText(left, right) {
|
|
67415
|
+
return left.localeCompare(right, "en");
|
|
67416
|
+
}
|
|
67417
|
+
function fallbackProviderRank(model) {
|
|
67418
|
+
return model.provider === PREFERRED_FALLBACK_PROVIDER ? 0 : 1;
|
|
67419
|
+
}
|
|
67420
|
+
function compareImageModels(left, right) {
|
|
67421
|
+
const leftGpt = parseGptImageId(left.id);
|
|
67422
|
+
const rightGpt = parseGptImageId(right.id);
|
|
67423
|
+
if (leftGpt !== undefined && rightGpt !== undefined) {
|
|
67424
|
+
return compareVersions(rightGpt.version, leftGpt.version) || variantRank(rightGpt.variant) - variantRank(leftGpt.variant) || compareText(left.provider, right.provider) || compareText(left.id, right.id);
|
|
67425
|
+
}
|
|
67426
|
+
if (leftGpt !== undefined)
|
|
67427
|
+
return -1;
|
|
67428
|
+
if (rightGpt !== undefined)
|
|
67429
|
+
return 1;
|
|
67430
|
+
return fallbackProviderRank(left) - fallbackProviderRank(right) || compareText(left.provider, right.provider) || compareText(right.id, left.id);
|
|
67431
|
+
}
|
|
67432
|
+
function selectReferenceImageModel(available, override) {
|
|
67433
|
+
const requested = override?.trim() ?? "";
|
|
67434
|
+
if (requested.length > 0)
|
|
67435
|
+
return available.find((model) => `${model.provider}/${model.id}` === requested);
|
|
67436
|
+
return [...available].sort(compareImageModels)[0];
|
|
67437
|
+
}
|
|
67438
|
+
function excerpt(label, text, limit) {
|
|
67439
|
+
const trimmed = text?.trim() ?? "";
|
|
67440
|
+
if (trimmed.length === 0)
|
|
67441
|
+
return;
|
|
67442
|
+
return `${label}:
|
|
67443
|
+
${trimmed.slice(0, limit).trimEnd()}`;
|
|
67444
|
+
}
|
|
67445
|
+
function buildReferenceImagePrompt(context, direction) {
|
|
67446
|
+
return [
|
|
67447
|
+
`A finished ${SURFACE_BY_OUTPUT_TYPE[context.outputType]} for: ${context.brief.trim()}`,
|
|
67448
|
+
"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.",
|
|
67449
|
+
`Direction: ${direction.composition}`,
|
|
67450
|
+
excerpt("Curated references (inspiration to adapt into this product; do not copy their layout or content)", context.curatedReferences, REFERENCES_EXCERPT_CHARS),
|
|
67451
|
+
excerpt("Design system (DESIGN.md)", context.designContext, DESIGN_EXCERPT_CHARS),
|
|
67452
|
+
excerpt("Product context (PRODUCT.md)", context.productContext, PRODUCT_EXCERPT_CHARS),
|
|
67453
|
+
"Keep the palette, typography and component character the context describes; the direction changes only composition and emphasis."
|
|
67454
|
+
].filter((section) => section !== undefined).join(`
|
|
67455
|
+
|
|
67456
|
+
`);
|
|
67457
|
+
}
|
|
67458
|
+
async function readOptionalText(path) {
|
|
67459
|
+
try {
|
|
67460
|
+
return await readFile5(path, "utf8");
|
|
67461
|
+
} catch (error) {
|
|
67462
|
+
const code = error.code;
|
|
67463
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
67464
|
+
return;
|
|
67465
|
+
throw error;
|
|
67466
|
+
}
|
|
67467
|
+
}
|
|
67468
|
+
function firstWritableImage(output) {
|
|
67469
|
+
for (const block of output) {
|
|
67470
|
+
if (block.type !== "image" || block.data.length === 0)
|
|
67471
|
+
continue;
|
|
67472
|
+
const extension = IMAGE_EXTENSIONS.get(block.mimeType);
|
|
67473
|
+
if (extension !== undefined)
|
|
67474
|
+
return { data: block.data, extension };
|
|
67475
|
+
}
|
|
67476
|
+
return;
|
|
67477
|
+
}
|
|
67478
|
+
async function renderDirection(input) {
|
|
67479
|
+
const { provider, model, prompt, outputBase, signal } = input;
|
|
67480
|
+
let result;
|
|
67481
|
+
try {
|
|
67482
|
+
result = await provider.generateImages(model, { input: [{ type: "text", text: prompt }] }, {
|
|
67483
|
+
signal,
|
|
67484
|
+
quality: "high",
|
|
67485
|
+
size: IMAGE_SIZE,
|
|
67486
|
+
n: 1,
|
|
67487
|
+
timeoutMs: IMAGE_REQUEST_TIMEOUT_MS,
|
|
67488
|
+
maxRetries: IMAGE_REQUEST_MAX_RETRIES
|
|
67489
|
+
});
|
|
67490
|
+
} catch {
|
|
67491
|
+
signal.throwIfAborted();
|
|
67492
|
+
return { failure: { reason: "unexpected-error" } };
|
|
67493
|
+
}
|
|
67494
|
+
signal.throwIfAborted();
|
|
67495
|
+
if (result.stopReason !== "stop") {
|
|
67496
|
+
return {
|
|
67497
|
+
failure: {
|
|
67498
|
+
reason: result.error?.code ?? "unclassified",
|
|
67499
|
+
...result.error === undefined ? {} : { retryable: result.error.retryable }
|
|
67500
|
+
}
|
|
67501
|
+
};
|
|
67502
|
+
}
|
|
67503
|
+
const image = firstWritableImage(result.output);
|
|
67504
|
+
if (image === undefined)
|
|
67505
|
+
return {};
|
|
67506
|
+
const path = `${outputBase}.${image.extension}`;
|
|
67507
|
+
try {
|
|
67508
|
+
await mkdir4(dirname13(path), { recursive: true });
|
|
67509
|
+
await writeFile8(path, Buffer.from(image.data, "base64"));
|
|
67510
|
+
} catch {
|
|
67511
|
+
return { failure: { reason: "write-failed" } };
|
|
67512
|
+
}
|
|
67513
|
+
return { path };
|
|
67514
|
+
}
|
|
67515
|
+
async function loadPromptContext(request) {
|
|
67516
|
+
const [productContext, designContext] = await Promise.all([
|
|
67517
|
+
readOptionalText(join24(request.workflowCwd, "PRODUCT.md")),
|
|
67518
|
+
readOptionalText(join24(request.workflowCwd, "DESIGN.md"))
|
|
67519
|
+
]);
|
|
67520
|
+
return {
|
|
67521
|
+
brief: request.brief,
|
|
67522
|
+
outputType: request.outputType,
|
|
67523
|
+
curatedReferences: request.curatedReferences,
|
|
67524
|
+
productContext,
|
|
67525
|
+
designContext
|
|
67526
|
+
};
|
|
67527
|
+
}
|
|
67528
|
+
function directionOutputBase(artifactDir, index, direction) {
|
|
67529
|
+
return join24(artifactDir, REFERENCE_IMAGES_DIRNAME, `${String(index + 1).padStart(2, "0")}-${direction.slug}`);
|
|
67530
|
+
}
|
|
67531
|
+
async function renderReferenceImages(request, provider, model, signal) {
|
|
67532
|
+
const promptContext = await loadPromptContext(request);
|
|
67533
|
+
const outcomes = await Promise.all(REFERENCE_IMAGE_DIRECTIONS.map((direction, index) => renderDirection({
|
|
67534
|
+
provider,
|
|
67535
|
+
model,
|
|
67536
|
+
prompt: buildReferenceImagePrompt(promptContext, direction),
|
|
67537
|
+
outputBase: directionOutputBase(request.artifactDir, index, direction),
|
|
67538
|
+
signal
|
|
67539
|
+
})));
|
|
67540
|
+
const modelId = `${model.provider}/${model.id}`;
|
|
67541
|
+
const paths = outcomes.flatMap(({ path }) => path === undefined ? [] : [path]);
|
|
67542
|
+
if (paths.length > 0)
|
|
67543
|
+
return { status: "generated", model: modelId, paths };
|
|
67544
|
+
const failure = outcomes.find((outcome) => outcome.failure !== undefined)?.failure;
|
|
67545
|
+
return {
|
|
67546
|
+
status: "failed",
|
|
67547
|
+
reason: failure?.reason ?? "no-images-written",
|
|
67548
|
+
model: modelId,
|
|
67549
|
+
paths: [],
|
|
67550
|
+
...failure?.retryable === undefined ? {} : { retryable: failure.retryable }
|
|
67551
|
+
};
|
|
67552
|
+
}
|
|
67553
|
+
function skipped(reason) {
|
|
67554
|
+
return { status: "skipped", reason, paths: [] };
|
|
67555
|
+
}
|
|
67556
|
+
async function generateReferenceImages(request, createProvider, signal) {
|
|
67557
|
+
try {
|
|
67558
|
+
const provider = await createProvider();
|
|
67559
|
+
const available = await provider.availableImageModels(signal);
|
|
67560
|
+
if (available.length === 0)
|
|
67561
|
+
return skipped("no-image-model");
|
|
67562
|
+
const model = selectReferenceImageModel(available, request.imageModel);
|
|
67563
|
+
if (model === undefined)
|
|
67564
|
+
return skipped("image-model-unavailable");
|
|
67565
|
+
return await renderReferenceImages(request, provider, model, signal);
|
|
67566
|
+
} catch {
|
|
67567
|
+
signal.throwIfAborted();
|
|
67568
|
+
return { status: "failed", reason: "unexpected-error", paths: [] };
|
|
67569
|
+
}
|
|
67570
|
+
}
|
|
67571
|
+
async function createBuiltinReferenceImageProvider(credentials = AuthStorage.create()) {
|
|
67572
|
+
const models = builtinModels({ credentials });
|
|
67573
|
+
return {
|
|
67574
|
+
availableImageModels: (signal) => models.getAvailableOfType("image", undefined, { signal }),
|
|
67575
|
+
generateImages: (model, context, options) => models.generateImages(model, context, options)
|
|
67576
|
+
};
|
|
67577
|
+
}
|
|
67578
|
+
async function runReferenceImagesStep(tool, request, deps = {}) {
|
|
67579
|
+
const createProvider = deps.createImageProvider ?? createBuiltinReferenceImageProvider;
|
|
67580
|
+
const outcome = await tool("reference-images", {
|
|
67581
|
+
brief: request.brief,
|
|
67582
|
+
outputType: request.outputType,
|
|
67583
|
+
artifactDir: request.artifactDir,
|
|
67584
|
+
...request.imageModel === undefined ? {} : { imageModel: request.imageModel }
|
|
67585
|
+
}, ({ signal }) => generateReferenceImages(request, createProvider, signal), { timeoutMs: REFERENCE_IMAGES_TOOL_TIMEOUT_MS, failureMode: "return" });
|
|
67586
|
+
return outcome.ok ? outcome.value : { status: "failed", reason: "tool-failed", paths: [] };
|
|
67587
|
+
}
|
|
67588
|
+
function existingReferenceImagePaths(status) {
|
|
67589
|
+
return status.status === "generated" ? status.paths.filter((path) => existsSync7(path)) : [];
|
|
67590
|
+
}
|
|
67591
|
+
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;
|
|
67592
|
+
var init_open_claude_design_images = __esm(() => {
|
|
67593
|
+
referenceImagesStatusSchema = Type18.Object({
|
|
67594
|
+
status: Type18.Union([Type18.Literal("skipped"), Type18.Literal("generated"), Type18.Literal("failed")]),
|
|
67595
|
+
reason: Type18.Optional(Type18.String()),
|
|
67596
|
+
model: Type18.Optional(Type18.String()),
|
|
67597
|
+
paths: Type18.Array(Type18.String()),
|
|
67598
|
+
retryable: Type18.Optional(Type18.Boolean())
|
|
67599
|
+
}, {
|
|
67600
|
+
additionalProperties: false,
|
|
67601
|
+
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."
|
|
67602
|
+
});
|
|
67603
|
+
REFERENCE_IMAGES_TOOL_TIMEOUT_MS = 15 * 60000;
|
|
67604
|
+
IMAGE_REQUEST_TIMEOUT_MS = 5 * 60000;
|
|
67605
|
+
REFERENCE_IMAGE_DIRECTIONS = [
|
|
67606
|
+
{
|
|
67607
|
+
slug: "reference-led",
|
|
67608
|
+
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."
|
|
67609
|
+
},
|
|
67610
|
+
{
|
|
67611
|
+
slug: "brand-forward",
|
|
67612
|
+
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."
|
|
67613
|
+
},
|
|
67614
|
+
{
|
|
67615
|
+
slug: "information-dense",
|
|
67616
|
+
composition: "Information-dense. Summary-led, with a compact structured grid and a tight hierarchy that shows more real content at real reading size."
|
|
67617
|
+
}
|
|
67618
|
+
];
|
|
67619
|
+
SURFACE_BY_OUTPUT_TYPE = {
|
|
67620
|
+
prototype: "desktop web app screen",
|
|
67621
|
+
wireframe: "high-fidelity desktop screen",
|
|
67622
|
+
page: "desktop web page",
|
|
67623
|
+
component: "desktop screen showing the component in two or three representative contexts",
|
|
67624
|
+
theme: "representative product screen showing the theme applied across navigation, type, color and components",
|
|
67625
|
+
tokens: "style-guide screen showing the color, type and spacing tokens applied to real components"
|
|
67626
|
+
};
|
|
67627
|
+
GPT_IMAGE_ID = /^(?:[^/]+\/)?gpt-image-(?<version>\d+(?:\.\d+)*)(?:-(?<variant>.+))?$/;
|
|
67628
|
+
PREFERRED_VARIANTS = ["flare", "sunburst"];
|
|
67629
|
+
LOWER_TIER_VARIANTS = new Set(["mini", "nano"]);
|
|
67630
|
+
IMAGE_EXTENSIONS = new Map([
|
|
67631
|
+
["image/png", "png"],
|
|
67632
|
+
["image/jpeg", "jpg"],
|
|
67633
|
+
["image/webp", "webp"]
|
|
67634
|
+
]);
|
|
67635
|
+
});
|
|
67636
|
+
|
|
67344
67637
|
// dist/builtin/workflows/builtin/open-claude-design-utils.ts
|
|
67345
67638
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
67346
67639
|
import { mkdirSync as mkdirSync6 } from "node:fs";
|
|
67347
67640
|
import { tmpdir, userInfo } from "node:os";
|
|
67348
|
-
import { join as
|
|
67349
|
-
import { Type as
|
|
67641
|
+
import { dirname as dirname14, join as join25, relative as relative8, sep as sep9 } from "node:path";
|
|
67642
|
+
import { Type as Type19 } from "typebox";
|
|
67350
67643
|
import { createChildProcessEnvironment as createChildProcessEnvironment3 } from "@bastani/atomic";
|
|
67351
67644
|
function taggedPrompt3(sections) {
|
|
67352
67645
|
return sections.map(([tag, content]) => {
|
|
@@ -67374,6 +67667,12 @@ function discoveryDecisionFromResult(result, fallbackBrief) {
|
|
|
67374
67667
|
references
|
|
67375
67668
|
};
|
|
67376
67669
|
}
|
|
67670
|
+
function referenceImageFileUrl(path) {
|
|
67671
|
+
return `file://${path}`;
|
|
67672
|
+
}
|
|
67673
|
+
function referenceImageRelativeSrc(specPath, imagePath) {
|
|
67674
|
+
return relative8(dirname14(specPath), imagePath).split(sep9).join("/");
|
|
67675
|
+
}
|
|
67377
67676
|
function joinResults(results) {
|
|
67378
67677
|
return results.map((result) => `### ${result.name}
|
|
67379
67678
|
|
|
@@ -67388,32 +67687,32 @@ function tmpArtifactBase() {
|
|
|
67388
67687
|
try {
|
|
67389
67688
|
user = userInfo().username.replace(/[^A-Za-z0-9._-]/g, "_") || "default";
|
|
67390
67689
|
} catch {}
|
|
67391
|
-
return
|
|
67690
|
+
return join25(tmpdir(), `open-claude-design-${user}`);
|
|
67392
67691
|
}
|
|
67393
67692
|
function prepareArtifactDir(cwd = process.cwd()) {
|
|
67394
67693
|
const runId = `${new Date().toISOString().replace(/[:.]/g, "-")}-${Math.random().toString(36).slice(2, 8)}`;
|
|
67395
67694
|
const tmpCandidates = [
|
|
67396
|
-
|
|
67397
|
-
|
|
67695
|
+
join25(tmpArtifactBase(), runId),
|
|
67696
|
+
join25(tmpdir(), "open-claude-design", runId)
|
|
67398
67697
|
];
|
|
67399
|
-
const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [
|
|
67698
|
+
const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [join25(cwd, "specs", "design", runId), ...tmpCandidates];
|
|
67400
67699
|
for (const candidate of candidates) {
|
|
67401
67700
|
try {
|
|
67402
67701
|
mkdirSync6(candidate, { recursive: true });
|
|
67403
67702
|
return {
|
|
67404
67703
|
runId,
|
|
67405
67704
|
artifactDir: candidate,
|
|
67406
|
-
previewPath:
|
|
67407
|
-
specPath:
|
|
67705
|
+
previewPath: join25(candidate, "preview.html"),
|
|
67706
|
+
specPath: join25(candidate, "spec.html")
|
|
67408
67707
|
};
|
|
67409
67708
|
} catch {}
|
|
67410
67709
|
}
|
|
67411
|
-
const fallback =
|
|
67710
|
+
const fallback = join25(tmpArtifactBase(), runId);
|
|
67412
67711
|
return {
|
|
67413
67712
|
runId,
|
|
67414
67713
|
artifactDir: fallback,
|
|
67415
|
-
previewPath:
|
|
67416
|
-
specPath:
|
|
67714
|
+
previewPath: join25(fallback, "preview.html"),
|
|
67715
|
+
specPath: join25(fallback, "spec.html")
|
|
67417
67716
|
};
|
|
67418
67717
|
}
|
|
67419
67718
|
function ensureAgentBrowser() {
|
|
@@ -67518,10 +67817,10 @@ var init_open_claude_design_utils = __esm(() => {
|
|
|
67518
67817
|
"theme",
|
|
67519
67818
|
"tokens"
|
|
67520
67819
|
];
|
|
67521
|
-
discoveryDecisionSchema =
|
|
67522
|
-
brief:
|
|
67523
|
-
output_type:
|
|
67524
|
-
references:
|
|
67820
|
+
discoveryDecisionSchema = Type19.Object({
|
|
67821
|
+
brief: Type19.String(),
|
|
67822
|
+
output_type: Type19.Union([...OUTPUT_TYPES].map((value2) => Type19.Literal(value2))),
|
|
67823
|
+
references: Type19.Array(Type19.String())
|
|
67525
67824
|
}, { additionalProperties: false });
|
|
67526
67825
|
HTML_PREVIEW_RULES = [
|
|
67527
67826
|
"Produce one self-contained HTML document: inline CSS in <style> and JS in <script>; make no external requests except explicitly required Google Fonts.",
|
|
@@ -67715,9 +68014,18 @@ ${input.event.raw}
|
|
|
67715
68014
|
`);
|
|
67716
68015
|
}
|
|
67717
68016
|
function buildLiveSessionStartPrompt(input) {
|
|
68017
|
+
const referenceImagePaths = input.referenceImagePaths ?? [];
|
|
67718
68018
|
return [
|
|
67719
68019
|
`<preview_path>${input.previewPath}</preview_path>`,
|
|
67720
68020
|
`<preview_file_url>${input.previewFileUrl}</preview_file_url>`,
|
|
68021
|
+
...referenceImagePaths.length > 0 ? [
|
|
68022
|
+
[
|
|
68023
|
+
"<reference_images>",
|
|
68024
|
+
...referenceImagePaths.map((path) => `${path} (${referenceImageFileUrl(path)})`),
|
|
68025
|
+
"</reference_images>"
|
|
68026
|
+
].join(`
|
|
68027
|
+
`)
|
|
68028
|
+
] : [],
|
|
67721
68029
|
`<browser_use_guidelines>${input.browserBootstrapRules}</browser_use_guidelines>`,
|
|
67722
68030
|
"<role>You are an opinionated staff design engineer opening an impeccable `live` review session.</role>",
|
|
67723
68031
|
[
|
|
@@ -67732,6 +68040,9 @@ function buildLiveSessionStartPrompt(input) {
|
|
|
67732
68040
|
"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.",
|
|
67733
68041
|
"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.",
|
|
67734
68042
|
"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.",
|
|
68043
|
+
...referenceImagePaths.length > 0 ? [
|
|
68044
|
+
"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."
|
|
68045
|
+
] : [],
|
|
67735
68046
|
"</instructions>"
|
|
67736
68047
|
].join(`
|
|
67737
68048
|
`),
|
|
@@ -67742,13 +68053,14 @@ function buildLiveSessionStartPrompt(input) {
|
|
|
67742
68053
|
}
|
|
67743
68054
|
var MODEL_EVENTS, LEGACY_REPLY_STATUSES, LIVE_POLL_VERB = "live-poll";
|
|
67744
68055
|
var init_open_claude_design_live_protocol = __esm(() => {
|
|
68056
|
+
init_open_claude_design_utils();
|
|
67745
68057
|
MODEL_EVENTS = new Set(["generate", "steer", "manual_edit_apply", "variant_mount_failed"]);
|
|
67746
68058
|
LEGACY_REPLY_STATUSES = new Set(["done", "error", "complete", "discard", "discarded"]);
|
|
67747
68059
|
});
|
|
67748
68060
|
|
|
67749
68061
|
// dist/builtin/workflows/builtin/open-claude-design-setup.ts
|
|
67750
68062
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync4 } from "node:fs";
|
|
67751
|
-
import { join as
|
|
68063
|
+
import { join as join26 } from "node:path";
|
|
67752
68064
|
function renderDiscoveryContext(discovery) {
|
|
67753
68065
|
return [
|
|
67754
68066
|
`Confirmed design brief: ${discovery.brief}`,
|
|
@@ -67813,10 +68125,10 @@ async function runDiscoveryAndInit(args) {
|
|
|
67813
68125
|
};
|
|
67814
68126
|
}
|
|
67815
68127
|
function designContextPath(artifactDir) {
|
|
67816
|
-
return
|
|
68128
|
+
return join26(artifactDir, DESIGN_CONTEXT_FILENAME);
|
|
67817
68129
|
}
|
|
67818
68130
|
function referencesBriefPath(artifactDir) {
|
|
67819
|
-
return
|
|
68131
|
+
return join26(artifactDir, REFERENCES_BRIEF_FILENAME);
|
|
67820
68132
|
}
|
|
67821
68133
|
function buildReferenceDiscoveryPrompt(args) {
|
|
67822
68134
|
const siteList = REFERENCE_DESIGN_SITES.map((site, index) => `${index + 1}. ${site.name} — ${site.url}`).join(`
|
|
@@ -67842,8 +68154,8 @@ function buildReferenceDiscoveryPrompt(args) {
|
|
|
67842
68154
|
[
|
|
67843
68155
|
"Use the agent-browser skill to open each gallery; if `agent-browser` reports a missing browser executable, follow the bootstrap rules and retry once.",
|
|
67844
68156
|
"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.",
|
|
67845
|
-
`Capture motion across the entire page: start \`agent-browser record start ${
|
|
67846
|
-
`Also run \`agent-browser screenshot ${
|
|
68157
|
+
`Capture motion across the entire page: start \`agent-browser record start ${join26(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\`.`,
|
|
68158
|
+
`Also run \`agent-browser screenshot ${join26(args.artifactDir, "ref-<site>-<n>.png")} --full\`; this still is the minimum when video is unavailable.`,
|
|
67847
68159
|
"Record the actual destination URL, title, and author. For each reference, cite observed layout, typography, color, spacing, and motion traits rather than inferred traits.",
|
|
67848
68160
|
"Assess fit against DESIGN.md, PRODUCT.md, and the ds-* discovery evidence in the design-context file; prefer on-brand references and flag departures.",
|
|
67849
68161
|
"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.",
|
|
@@ -67883,11 +68195,17 @@ function persistDesignContext(artifactDir, content) {
|
|
|
67883
68195
|
writeRequiredContextArtifact(artifactDir, designContextPath(artifactDir), content, "design-context");
|
|
67884
68196
|
}
|
|
67885
68197
|
function buildLiveReviewGateMessage(args) {
|
|
68198
|
+
const referenceImagePaths = args.referenceImagePaths ?? [];
|
|
67886
68199
|
return [
|
|
67887
68200
|
`Design review session ${args.round} is ready for your browser review.`,
|
|
67888
68201
|
"",
|
|
67889
68202
|
`Preview file: ${args.previewPath}`,
|
|
67890
68203
|
`Preview URL: ${args.previewFileUrl}`,
|
|
68204
|
+
...referenceImagePaths.length > 0 ? [
|
|
68205
|
+
"",
|
|
68206
|
+
"Reference images (AI-generated design directions the preview was built from):",
|
|
68207
|
+
...referenceImagePaths.map((path) => `- ${path} (${referenceImageFileUrl(path)})`)
|
|
68208
|
+
] : [],
|
|
67891
68209
|
"",
|
|
67892
68210
|
`"${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).`,
|
|
67893
68211
|
"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.",
|
|
@@ -67923,7 +68241,7 @@ function forkContinuationOptions2(sessionId) {
|
|
|
67923
68241
|
return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
|
|
67924
68242
|
}
|
|
67925
68243
|
async function refineOpenClaudeDesign(options) {
|
|
67926
|
-
const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig, workflowCwd } = options;
|
|
68244
|
+
const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig, workflowCwd } = options;
|
|
67927
68245
|
const importContext = options.importContext ?? "";
|
|
67928
68246
|
const generated = await designContext.task("generate-1", {
|
|
67929
68247
|
prompt: buildInitialGeneratePrompt({
|
|
@@ -67932,12 +68250,14 @@ async function refineOpenClaudeDesign(options) {
|
|
|
67932
68250
|
previewPath,
|
|
67933
68251
|
designContextFile,
|
|
67934
68252
|
referencesFile,
|
|
68253
|
+
referenceImagePaths,
|
|
67935
68254
|
importContext
|
|
67936
68255
|
}),
|
|
67937
|
-
reads: [designContextFile, referencesFile],
|
|
68256
|
+
reads: [designContextFile, referencesFile, ...referenceImagePaths],
|
|
68257
|
+
...referenceImagePaths.length > 0 ? { taskNeeds: { needsImages: true } } : {},
|
|
67938
68258
|
...designModelConfig
|
|
67939
68259
|
});
|
|
67940
|
-
const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
|
|
68260
|
+
const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl, referenceImagePaths }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
|
|
67941
68261
|
if (isUiUnavailableRejection(error))
|
|
67942
68262
|
return LIVE_REVIEW_GATE_OPTIONS[0];
|
|
67943
68263
|
throw error;
|
|
@@ -67949,6 +68269,7 @@ async function refineOpenClaudeDesign(options) {
|
|
|
67949
68269
|
reviewStageName: "user-feedback-1",
|
|
67950
68270
|
previewPath,
|
|
67951
68271
|
previewFileUrl,
|
|
68272
|
+
referenceImagePaths,
|
|
67952
68273
|
browserBootstrapRules,
|
|
67953
68274
|
designModelConfig,
|
|
67954
68275
|
workflowCwd
|
|
@@ -67957,10 +68278,10 @@ async function refineOpenClaudeDesign(options) {
|
|
|
67957
68278
|
return { latestDesign: generated.text };
|
|
67958
68279
|
}
|
|
67959
68280
|
async function runLiveReviewSession(options) {
|
|
67960
|
-
const { designContext, round, reviewStageName, previewPath, previewFileUrl, browserBootstrapRules, designModelConfig, workflowCwd } = options;
|
|
68281
|
+
const { designContext, round, reviewStageName, previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, designModelConfig, workflowCwd } = options;
|
|
67961
68282
|
let sessionId;
|
|
67962
68283
|
const start = await designContext.task(`${reviewStageName}-start`, {
|
|
67963
|
-
prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, browserBootstrapRules, round }),
|
|
68284
|
+
prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, round }),
|
|
67964
68285
|
...designModelConfig
|
|
67965
68286
|
});
|
|
67966
68287
|
sessionId = start.sessionId;
|
|
@@ -67984,6 +68305,7 @@ async function runLiveReviewSession(options) {
|
|
|
67984
68305
|
}
|
|
67985
68306
|
}
|
|
67986
68307
|
function buildInitialGeneratePrompt(args) {
|
|
68308
|
+
const hasReferenceImages = args.referenceImagePaths.length > 0;
|
|
67987
68309
|
return taggedPrompt3([
|
|
67988
68310
|
["design_brief", args.prompt],
|
|
67989
68311
|
[
|
|
@@ -67995,6 +68317,7 @@ function buildInitialGeneratePrompt(args) {
|
|
|
67995
68317
|
"reference_inspiration_file",
|
|
67996
68318
|
`Read the file at ${args.referencesFile} for the curated reference inspiration to heavily emulate.`
|
|
67997
68319
|
],
|
|
68320
|
+
...hasReferenceImages ? [["reference_images", renderReferenceImagesForGeneration(args.referenceImagePaths)]] : [],
|
|
67998
68321
|
["reference_precedence", REFERENCE_PRECEDENCE],
|
|
67999
68322
|
["preview_artifact_path", args.previewPath],
|
|
68000
68323
|
["html_rules", HTML_PREVIEW_RULES],
|
|
@@ -68010,6 +68333,7 @@ function buildInitialGeneratePrompt(args) {
|
|
|
68010
68333
|
`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.`,
|
|
68011
68334
|
`Create the HTML artifact exactly at ${args.previewPath}.`,
|
|
68012
68335
|
"Follow <reference_precedence>; heavily reference the reference-inspiration file without copying wholesale or inventing traits.",
|
|
68336
|
+
...hasReferenceImages ? [REFERENCE_IMAGE_GENERATION_RULE] : [],
|
|
68013
68337
|
`Build the requested output_type (${args.outputType}): render full realistic layouts for prototypes/pages, or the component in at least three representative contexts.`,
|
|
68014
68338
|
"Include structure, states, accessibility, responsive behavior, and integration notes as HTML comments so the preview stays clean.",
|
|
68015
68339
|
"Use project language rather than generic placeholders when conventions exist. Add no features or abstractions beyond this design brief."
|
|
@@ -68032,9 +68356,28 @@ function buildInitialGeneratePrompt(args) {
|
|
|
68032
68356
|
]
|
|
68033
68357
|
]);
|
|
68034
68358
|
}
|
|
68359
|
+
function renderReferenceImageList(paths) {
|
|
68360
|
+
return paths.map((path) => `- ${path}`).join(`
|
|
68361
|
+
`);
|
|
68362
|
+
}
|
|
68363
|
+
function renderReferenceImagesForGeneration(paths) {
|
|
68364
|
+
return [
|
|
68365
|
+
"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.",
|
|
68366
|
+
renderReferenceImageList(paths)
|
|
68367
|
+
].join(`
|
|
68368
|
+
`);
|
|
68369
|
+
}
|
|
68370
|
+
function renderReferenceImagesForExport(specPath, paths) {
|
|
68371
|
+
return [
|
|
68372
|
+
"AI-generated design reference images, one per visual direction (named by file), stored next to the spec. They are illustrations, not specifications.",
|
|
68373
|
+
...paths.map((path) => `- ${path} (src="${referenceImageRelativeSrc(specPath, path)}")`)
|
|
68374
|
+
].join(`
|
|
68375
|
+
`);
|
|
68376
|
+
}
|
|
68035
68377
|
async function exportOpenClaudeDesign(options) {
|
|
68036
|
-
const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig } = options;
|
|
68378
|
+
const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig } = options;
|
|
68037
68379
|
const latestDesign = options.latestDesign;
|
|
68380
|
+
const hasReferenceImages = referenceImagePaths.length > 0;
|
|
68038
68381
|
const handoff = await designContext.task("exporter", {
|
|
68039
68382
|
reads: [designContextFile, referencesFile],
|
|
68040
68383
|
prompt: taggedPrompt3([
|
|
@@ -68048,6 +68391,7 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68048
68391
|
],
|
|
68049
68392
|
["preview_artifact_path", previewPath],
|
|
68050
68393
|
["spec_artifact_path", specPath],
|
|
68394
|
+
...hasReferenceImages ? [["reference_images", renderReferenceImagesForExport(specPath, referenceImagePaths)]] : [],
|
|
68051
68395
|
["final_design_summary", "{previous}"],
|
|
68052
68396
|
["html_rules", HTML_PREVIEW_RULES],
|
|
68053
68397
|
["anti_design_slop_rules", ANTI_SLOP_RULES],
|
|
@@ -68062,7 +68406,8 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68062
68406
|
"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.",
|
|
68063
68407
|
'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.',
|
|
68064
68408
|
"Use dense legible typography, generous whitespace, monospaced code, rendered hex/oklch swatches, and copy-to-clipboard hints in HTML comments.",
|
|
68065
|
-
`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
|
|
68409
|
+
`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.`,
|
|
68410
|
+
...hasReferenceImages ? [REFERENCE_IMAGE_EXPORT_RULE] : []
|
|
68066
68411
|
].join(`
|
|
68067
68412
|
`)
|
|
68068
68413
|
],
|
|
@@ -68122,7 +68467,7 @@ async function exportOpenClaudeDesign(options) {
|
|
|
68122
68467
|
});
|
|
68123
68468
|
return { latestDesign, handoff };
|
|
68124
68469
|
}
|
|
68125
|
-
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.";
|
|
68470
|
+
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.';
|
|
68126
68471
|
var init_open_claude_design_phases = __esm(() => {
|
|
68127
68472
|
init_open_claude_design_utils();
|
|
68128
68473
|
init_open_claude_design_live_protocol();
|
|
@@ -68130,7 +68475,7 @@ var init_open_claude_design_phases = __esm(() => {
|
|
|
68130
68475
|
});
|
|
68131
68476
|
|
|
68132
68477
|
// dist/builtin/workflows/builtin/open-claude-design-runner.ts
|
|
68133
|
-
async function runOpenClaudeDesignWorkflow(ctx) {
|
|
68478
|
+
async function runOpenClaudeDesignWorkflow(ctx, deps = {}) {
|
|
68134
68479
|
const designContext = ctx;
|
|
68135
68480
|
const agentBrowser = ensureAgentBrowser();
|
|
68136
68481
|
const browserBootstrapRules = buildAgentBrowserBootstrapRules(agentBrowser);
|
|
@@ -68319,6 +68664,15 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68319
68664
|
"Full design-system and reference evidence: read the design-context file."
|
|
68320
68665
|
].join(`
|
|
68321
68666
|
`) : "No user reference was provided; infer the design direction from the brief, project design context, research, and curated reference inspiration.";
|
|
68667
|
+
const referenceImages = await runReferenceImagesStep(designContext.tool, {
|
|
68668
|
+
brief: designBrief,
|
|
68669
|
+
outputType,
|
|
68670
|
+
artifactDir,
|
|
68671
|
+
workflowCwd,
|
|
68672
|
+
curatedReferences: referencesBriefRaw,
|
|
68673
|
+
imageModel: inputs.image_model
|
|
68674
|
+
}, deps);
|
|
68675
|
+
const referenceImagePaths = existingReferenceImagePaths(referenceImages);
|
|
68322
68676
|
const refinement = await refineOpenClaudeDesign({
|
|
68323
68677
|
designContext,
|
|
68324
68678
|
prompt: designBrief,
|
|
@@ -68328,6 +68682,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68328
68682
|
browserBootstrapRules,
|
|
68329
68683
|
designContextFile,
|
|
68330
68684
|
referencesFile,
|
|
68685
|
+
referenceImagePaths,
|
|
68331
68686
|
designModelConfig,
|
|
68332
68687
|
workflowCwd,
|
|
68333
68688
|
importContext,
|
|
@@ -68345,6 +68700,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68345
68700
|
browserBootstrapRules,
|
|
68346
68701
|
designContextFile,
|
|
68347
68702
|
referencesFile,
|
|
68703
|
+
referenceImagePaths,
|
|
68348
68704
|
latestDesign,
|
|
68349
68705
|
designModelConfig
|
|
68350
68706
|
});
|
|
@@ -68361,49 +68717,56 @@ async function runOpenClaudeDesignWorkflow(ctx) {
|
|
|
68361
68717
|
preview_file_url: previewFileUrl,
|
|
68362
68718
|
spec_path: specPath,
|
|
68363
68719
|
spec_file_url: specFileUrl,
|
|
68364
|
-
agent_browser_status: agentBrowser.summary
|
|
68720
|
+
agent_browser_status: agentBrowser.summary,
|
|
68721
|
+
reference_images_status: referenceImages
|
|
68365
68722
|
};
|
|
68366
68723
|
}
|
|
68367
68724
|
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.";
|
|
68368
68725
|
var init_open_claude_design_runner = __esm(() => {
|
|
68369
68726
|
init_open_claude_design_utils();
|
|
68727
|
+
init_open_claude_design_images();
|
|
68370
68728
|
init_open_claude_design_phases();
|
|
68371
68729
|
init_open_claude_design_setup();
|
|
68372
68730
|
});
|
|
68373
68731
|
|
|
68374
68732
|
// dist/builtin/workflows/builtin/open-claude-design.ts
|
|
68375
|
-
import { Type as
|
|
68733
|
+
import { Type as Type20 } from "typebox";
|
|
68376
68734
|
var open_claude_design_default;
|
|
68377
68735
|
var init_open_claude_design = __esm(() => {
|
|
68378
68736
|
init_workflow();
|
|
68379
68737
|
init_builtin_context();
|
|
68738
|
+
init_open_claude_design_images();
|
|
68380
68739
|
init_open_claude_design_runner();
|
|
68381
68740
|
open_claude_design_default = workflow({
|
|
68382
68741
|
name: "open-claude-design",
|
|
68383
68742
|
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.",
|
|
68384
68743
|
heartbeatIntervalMinutes: 0,
|
|
68385
68744
|
inputs: {
|
|
68386
|
-
prompt:
|
|
68745
|
+
prompt: Type20.String({
|
|
68387
68746
|
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."
|
|
68388
68747
|
}),
|
|
68389
|
-
discover_references:
|
|
68748
|
+
discover_references: Type20.Boolean({
|
|
68390
68749
|
default: true,
|
|
68391
68750
|
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."
|
|
68392
|
-
})
|
|
68751
|
+
}),
|
|
68752
|
+
image_model: Type20.Optional(Type20.String({
|
|
68753
|
+
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."
|
|
68754
|
+
}))
|
|
68393
68755
|
},
|
|
68394
68756
|
outputs: {
|
|
68395
|
-
output_type:
|
|
68396
|
-
design_system:
|
|
68397
|
-
artifact:
|
|
68398
|
-
handoff:
|
|
68399
|
-
import_context:
|
|
68400
|
-
run_id:
|
|
68401
|
-
artifact_dir:
|
|
68402
|
-
preview_path:
|
|
68403
|
-
preview_file_url:
|
|
68404
|
-
spec_path:
|
|
68405
|
-
spec_file_url:
|
|
68406
|
-
agent_browser_status:
|
|
68757
|
+
output_type: Type20.Optional(Type20.String({ description: "Kind of design artifact produced." })),
|
|
68758
|
+
design_system: Type20.Optional(Type20.String({ description: "Design system source used for generation: the project-derived design system." })),
|
|
68759
|
+
artifact: Type20.Optional(Type20.String({ description: "Latest final design summary from the final preview artifact." })),
|
|
68760
|
+
handoff: Type20.Optional(Type20.String({ description: "Final rich HTML spec and implementation handoff summary." })),
|
|
68761
|
+
import_context: Type20.Optional(Type20.String({ description: "Reference-import context used during generation." })),
|
|
68762
|
+
run_id: Type20.Optional(Type20.String({ description: "Per-run design workflow artifact identifier." })),
|
|
68763
|
+
artifact_dir: Type20.Optional(Type20.String({ description: "Directory containing preview and spec artifacts." })),
|
|
68764
|
+
preview_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated preview.html file." })),
|
|
68765
|
+
preview_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated preview.html file." })),
|
|
68766
|
+
spec_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated spec.html file." })),
|
|
68767
|
+
spec_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated spec.html file." })),
|
|
68768
|
+
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." })),
|
|
68769
|
+
reference_images_status: Type20.Optional(referenceImagesStatusSchema)
|
|
68407
68770
|
},
|
|
68408
68771
|
run: async (ctx) => await runOpenClaudeDesignWorkflow(withBuiltinContext(ctx))
|
|
68409
68772
|
});
|
|
@@ -68419,9 +68782,9 @@ var init_ralph_review_gate = __esm(() => {
|
|
|
68419
68782
|
});
|
|
68420
68783
|
|
|
68421
68784
|
// dist/builtin/workflows/builtin/ralph-core.ts
|
|
68422
|
-
import { mkdir as
|
|
68423
|
-
import { dirname as
|
|
68424
|
-
import { Type as
|
|
68785
|
+
import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
68786
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
68787
|
+
import { Type as Type21 } from "typebox";
|
|
68425
68788
|
function taggedPrompt4(sections) {
|
|
68426
68789
|
return sections.map(([tag, content]) => {
|
|
68427
68790
|
const trimmed = content.trim();
|
|
@@ -68460,11 +68823,11 @@ function slugifyResearchTopic(prompt) {
|
|
|
68460
68823
|
}
|
|
68461
68824
|
function defaultResearchPath(prompt, now = new Date) {
|
|
68462
68825
|
const date = now.toISOString().slice(0, 10);
|
|
68463
|
-
return
|
|
68826
|
+
return join27(DEFAULT_RESEARCH_DIR, `${date}-${slugifyResearchTopic(prompt)}.md`);
|
|
68464
68827
|
}
|
|
68465
68828
|
async function createImplementationNotesFile(prompt, runId) {
|
|
68466
68829
|
const notesDir = await createWorkflowArtifactDirectory(runId);
|
|
68467
|
-
const notesPath =
|
|
68830
|
+
const notesPath = join27(notesDir, IMPLEMENTATION_NOTES_FILENAME);
|
|
68468
68831
|
const initialNotes = [
|
|
68469
68832
|
"# Implementation Notes",
|
|
68470
68833
|
"",
|
|
@@ -68476,7 +68839,7 @@ async function createImplementationNotesFile(prompt, runId) {
|
|
|
68476
68839
|
"- 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."
|
|
68477
68840
|
].join(`
|
|
68478
68841
|
`);
|
|
68479
|
-
await
|
|
68842
|
+
await writeFile9(notesPath, `${initialNotes}
|
|
68480
68843
|
`, {
|
|
68481
68844
|
encoding: "utf8",
|
|
68482
68845
|
flag: "wx"
|
|
@@ -68485,7 +68848,7 @@ async function createImplementationNotesFile(prompt, runId) {
|
|
|
68485
68848
|
}
|
|
68486
68849
|
async function createQaEvidenceVideoPath(runId) {
|
|
68487
68850
|
const qaDir = await createWorkflowArtifactDirectory(runId);
|
|
68488
|
-
return
|
|
68851
|
+
return join27(qaDir, QA_E2E_VIDEO_FILENAME);
|
|
68489
68852
|
}
|
|
68490
68853
|
function renderQaE2eVideoGuidance(qaVideoPath) {
|
|
68491
68854
|
return [
|
|
@@ -68551,8 +68914,8 @@ function artifactSafeName2(value2) {
|
|
|
68551
68914
|
return safe.length > 0 ? safe : "artifact";
|
|
68552
68915
|
}
|
|
68553
68916
|
async function writeJsonArtifact(path, content) {
|
|
68554
|
-
await
|
|
68555
|
-
await
|
|
68917
|
+
await mkdir5(dirname15(path), { recursive: true });
|
|
68918
|
+
await writeFile9(path, `${JSON.stringify(content, null, 2)}
|
|
68556
68919
|
`, {
|
|
68557
68920
|
encoding: "utf8"
|
|
68558
68921
|
});
|
|
@@ -68625,60 +68988,60 @@ var init_ralph_core = __esm(() => {
|
|
|
68625
68988
|
init_shared_prompts();
|
|
68626
68989
|
init_ralph_review_gate();
|
|
68627
68990
|
init_review_convergence();
|
|
68628
|
-
reviewFindingSchema2 =
|
|
68629
|
-
title:
|
|
68630
|
-
body:
|
|
68631
|
-
confidence_score:
|
|
68632
|
-
objective_alignment:
|
|
68633
|
-
|
|
68634
|
-
|
|
68635
|
-
|
|
68636
|
-
|
|
68991
|
+
reviewFindingSchema2 = Type21.Object({
|
|
68992
|
+
title: Type21.String(),
|
|
68993
|
+
body: Type21.String(),
|
|
68994
|
+
confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
|
|
68995
|
+
objective_alignment: Type21.Union([
|
|
68996
|
+
Type21.Literal("required_by_objective"),
|
|
68997
|
+
Type21.Literal("consistent_with_objective"),
|
|
68998
|
+
Type21.Literal("beyond_objective"),
|
|
68999
|
+
Type21.Literal("contradicts_objective")
|
|
68637
69000
|
]),
|
|
68638
|
-
priority:
|
|
68639
|
-
code_location:
|
|
68640
|
-
absolute_file_path:
|
|
68641
|
-
line_range:
|
|
68642
|
-
start:
|
|
68643
|
-
end:
|
|
69001
|
+
priority: Type21.Optional(Type21.Union([Type21.Integer({ minimum: 0, maximum: 3 }), Type21.Null()])),
|
|
69002
|
+
code_location: Type21.Object({
|
|
69003
|
+
absolute_file_path: Type21.String(),
|
|
69004
|
+
line_range: Type21.Object({
|
|
69005
|
+
start: Type21.Integer({ minimum: 1 }),
|
|
69006
|
+
end: Type21.Integer({ minimum: 1 })
|
|
68644
69007
|
}, { additionalProperties: false })
|
|
68645
69008
|
}, { additionalProperties: false })
|
|
68646
69009
|
}, { additionalProperties: false });
|
|
68647
|
-
requirementsTraceabilitySchema2 =
|
|
68648
|
-
requirement:
|
|
68649
|
-
status:
|
|
68650
|
-
|
|
68651
|
-
|
|
68652
|
-
|
|
68653
|
-
|
|
69010
|
+
requirementsTraceabilitySchema2 = Type21.Object({
|
|
69011
|
+
requirement: Type21.String(),
|
|
69012
|
+
status: Type21.Union([
|
|
69013
|
+
Type21.Literal("proven"),
|
|
69014
|
+
Type21.Literal("contradicted"),
|
|
69015
|
+
Type21.Literal("missing"),
|
|
69016
|
+
Type21.Literal("unverified")
|
|
68654
69017
|
]),
|
|
68655
|
-
evidence:
|
|
69018
|
+
evidence: Type21.String()
|
|
68656
69019
|
}, { additionalProperties: false });
|
|
68657
|
-
reviewerErrorSchema2 =
|
|
68658
|
-
kind:
|
|
68659
|
-
|
|
68660
|
-
|
|
68661
|
-
|
|
68662
|
-
|
|
69020
|
+
reviewerErrorSchema2 = Type21.Object({
|
|
69021
|
+
kind: Type21.Union([
|
|
69022
|
+
Type21.Literal("validation_unavailable"),
|
|
69023
|
+
Type21.Literal("dependency_unavailable"),
|
|
69024
|
+
Type21.Literal("tool_failure"),
|
|
69025
|
+
Type21.Literal("reviewer_failure")
|
|
68663
69026
|
]),
|
|
68664
|
-
message:
|
|
68665
|
-
attempted_recovery:
|
|
69027
|
+
message: Type21.String(),
|
|
69028
|
+
attempted_recovery: Type21.String()
|
|
68666
69029
|
}, { additionalProperties: false });
|
|
68667
|
-
reviewDecisionSchema2 =
|
|
68668
|
-
findings:
|
|
68669
|
-
overall_correctness:
|
|
68670
|
-
|
|
68671
|
-
|
|
69030
|
+
reviewDecisionSchema2 = Type21.Object({
|
|
69031
|
+
findings: Type21.Array(reviewFindingSchema2),
|
|
69032
|
+
overall_correctness: Type21.Union([
|
|
69033
|
+
Type21.Literal("patch is correct"),
|
|
69034
|
+
Type21.Literal("patch is incorrect")
|
|
68672
69035
|
]),
|
|
68673
|
-
overall_explanation:
|
|
68674
|
-
overall_confidence_score:
|
|
68675
|
-
criterion_scores:
|
|
68676
|
-
criterion_id:
|
|
69036
|
+
overall_explanation: Type21.String(),
|
|
69037
|
+
overall_confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
|
|
69038
|
+
criterion_scores: Type21.Optional(Type21.Array(Type21.Object({
|
|
69039
|
+
criterion_id: Type21.String(),
|
|
68677
69040
|
score: VERIFICATION_SCALE.schema
|
|
68678
69041
|
}, { additionalProperties: false }))),
|
|
68679
|
-
requirements_traceability:
|
|
68680
|
-
stop_review_loop:
|
|
68681
|
-
reviewer_error:
|
|
69042
|
+
requirements_traceability: Type21.Array(requirementsTraceabilitySchema2),
|
|
69043
|
+
stop_review_loop: Type21.Boolean(),
|
|
69044
|
+
reviewer_error: Type21.Optional(Type21.Union([Type21.Null(), reviewerErrorSchema2]))
|
|
68682
69045
|
}, { additionalProperties: false });
|
|
68683
69046
|
});
|
|
68684
69047
|
|
|
@@ -68888,8 +69251,8 @@ var init_ralph_models = __esm(() => {
|
|
|
68888
69251
|
});
|
|
68889
69252
|
|
|
68890
69253
|
// dist/builtin/workflows/builtin/ralph-runner.ts
|
|
68891
|
-
import { existsSync as
|
|
68892
|
-
import { join as
|
|
69254
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
69255
|
+
import { join as join28, resolve as resolve13 } from "node:path";
|
|
68893
69256
|
async function runRalphWorkflow(ctx, options) {
|
|
68894
69257
|
const { prompt, acceptanceCriteria, maxLoops, comparisonBaseBranch, workflowStartCwd, createPr, runId } = options;
|
|
68895
69258
|
let latestReviewReportPath;
|
|
@@ -68950,7 +69313,7 @@ async function runRalphWorkflow(ctx, options) {
|
|
|
68950
69313
|
const researchPath = workflowResearchPath;
|
|
68951
69314
|
finalResearchPath = researchPath;
|
|
68952
69315
|
finalPlanPath = researchPath;
|
|
68953
|
-
const orchestratorReportPath =
|
|
69316
|
+
const orchestratorReportPath = join28(artifactDir, "orchestrator-report.md");
|
|
68954
69317
|
const orchestratorForkOptions = forkContinuationOptions3(previousOrchestratorSessionId);
|
|
68955
69318
|
const orchestratorPrompt = orchestratorForkOptions.forkFromSessionId === undefined ? taggedPrompt4([
|
|
68956
69319
|
["acceptance_criteria", keepContext(acceptanceCriteria)],
|
|
@@ -69086,7 +69449,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69086
69449
|
diagnostics: parsed.diagnostics,
|
|
69087
69450
|
allowFinalActionRemaining: createPr
|
|
69088
69451
|
});
|
|
69089
|
-
const artifactPath =
|
|
69452
|
+
const artifactPath = join28(artifactDir, `review-${artifactSafeName2(reviewer)}.json`);
|
|
69090
69453
|
await writeJsonArtifact(artifactPath, {
|
|
69091
69454
|
reviewer,
|
|
69092
69455
|
decision: parsed.decision,
|
|
@@ -69142,7 +69505,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69142
69505
|
usage: fold_usage([orchestrator, ...reviews, ...reverifyResults])
|
|
69143
69506
|
}));
|
|
69144
69507
|
}
|
|
69145
|
-
latestReviewReportPath = await writeJsonArtifact(
|
|
69508
|
+
latestReviewReportPath = await writeJsonArtifact(join28(artifactDir, "review-round-latest.json"), {
|
|
69146
69509
|
convergence_decision: roundConvergenceDecision,
|
|
69147
69510
|
convergence: convergenceEntries,
|
|
69148
69511
|
consolidated_findings: reverified.batch,
|
|
@@ -69152,7 +69515,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69152
69515
|
if (approved)
|
|
69153
69516
|
break;
|
|
69154
69517
|
}
|
|
69155
|
-
const qaVideoAvailable =
|
|
69518
|
+
const qaVideoAvailable = existsSync8(qaVideoPath);
|
|
69156
69519
|
const unapprovedHandoff = createPr === true && !approved;
|
|
69157
69520
|
const escalationEvidence = unapprovedHandoff ? convergence_escalation_evidence(convergenceEntries) : [];
|
|
69158
69521
|
if (createPr === true) {
|
|
@@ -69267,7 +69630,7 @@ var init_ralph_runner = __esm(() => {
|
|
|
69267
69630
|
});
|
|
69268
69631
|
|
|
69269
69632
|
// dist/builtin/workflows/builtin/ralph.ts
|
|
69270
|
-
import { Type as
|
|
69633
|
+
import { Type as Type22 } from "typebox";
|
|
69271
69634
|
var ralph_default;
|
|
69272
69635
|
var init_ralph = __esm(() => {
|
|
69273
69636
|
init_workflow();
|
|
@@ -69279,38 +69642,38 @@ var init_ralph = __esm(() => {
|
|
|
69279
69642
|
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.",
|
|
69280
69643
|
heartbeatIntervalMinutes: 15,
|
|
69281
69644
|
inputs: {
|
|
69282
|
-
prompt:
|
|
69283
|
-
acceptance_criteria:
|
|
69284
|
-
max_loops:
|
|
69645
|
+
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." }),
|
|
69646
|
+
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." })),
|
|
69647
|
+
max_loops: Type22.Number({
|
|
69285
69648
|
default: DEFAULT_MAX_LOOPS,
|
|
69286
69649
|
description: `Maximum research/orchestrate/review iterations (default ${DEFAULT_MAX_LOOPS}).`
|
|
69287
69650
|
}),
|
|
69288
|
-
base_branch:
|
|
69651
|
+
base_branch: Type22.String({
|
|
69289
69652
|
default: "origin/main",
|
|
69290
69653
|
description: "Branch reviewers compare the current code delta against (default origin/main)."
|
|
69291
69654
|
}),
|
|
69292
|
-
git_worktree_dir:
|
|
69655
|
+
git_worktree_dir: Type22.String({
|
|
69293
69656
|
default: "",
|
|
69294
69657
|
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."
|
|
69295
69658
|
}),
|
|
69296
|
-
create_pr:
|
|
69659
|
+
create_pr: Type22.Boolean({
|
|
69297
69660
|
default: false,
|
|
69298
69661
|
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."
|
|
69299
69662
|
})
|
|
69300
69663
|
},
|
|
69301
69664
|
outputs: {
|
|
69302
|
-
result:
|
|
69303
|
-
plan:
|
|
69304
|
-
plan_path:
|
|
69305
|
-
research:
|
|
69306
|
-
research_path:
|
|
69307
|
-
implementation_notes_path:
|
|
69308
|
-
qa_video_path:
|
|
69309
|
-
pr_report:
|
|
69310
|
-
approved:
|
|
69311
|
-
iterations_completed:
|
|
69312
|
-
review_report:
|
|
69313
|
-
review_report_path:
|
|
69665
|
+
result: Type22.Optional(Type22.String({ description: "Final implementation report from the orchestrator stage." })),
|
|
69666
|
+
plan: Type22.Optional(Type22.String({ description: "Latest transformed research question." })),
|
|
69667
|
+
plan_path: Type22.Optional(Type22.String({ description: "Backward-compatible alias for research_path." })),
|
|
69668
|
+
research: Type22.Optional(Type22.String({ description: "Latest research report text or artifact reference." })),
|
|
69669
|
+
research_path: Type22.Optional(Type22.String({ description: "Path to the latest generated research artifact under research/." })),
|
|
69670
|
+
implementation_notes_path: Type22.Optional(Type22.String({ description: "Durable run-scoped notes file containing decisions, deviations, blockers, and validation notes." })),
|
|
69671
|
+
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." })),
|
|
69672
|
+
pr_report: Type22.Optional(Type22.String({ description: "Pull-request report emitted only when create_pr=true and the final pull-request stage runs." })),
|
|
69673
|
+
approved: Type22.Optional(Type22.Boolean({ description: "Whether the reviewer loop approved before completion or optional final handoff." })),
|
|
69674
|
+
iterations_completed: Type22.Optional(Type22.Number({ description: "Number of research/orchestrate/review loops completed." })),
|
|
69675
|
+
review_report: Type22.Optional(Type22.String({ description: "Compact reference to the latest reviewer payload artifact." })),
|
|
69676
|
+
review_report_path: Type22.Optional(Type22.String({ description: "JSON artifact path for the latest review round." }))
|
|
69314
69677
|
},
|
|
69315
69678
|
worktreeFromInputs: {
|
|
69316
69679
|
gitWorktreeDir: "git_worktree_dir",
|
|
@@ -69510,9 +69873,9 @@ var init_tournament_prompts = __esm(() => {
|
|
|
69510
69873
|
});
|
|
69511
69874
|
|
|
69512
69875
|
// dist/builtin/workflows/builtin/tournament-runner.ts
|
|
69513
|
-
import { mkdir as
|
|
69514
|
-
import { join as
|
|
69515
|
-
import { Type as
|
|
69876
|
+
import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile10 } from "node:fs/promises";
|
|
69877
|
+
import { join as join29, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve14 } from "node:path";
|
|
69878
|
+
import { Type as Type23 } from "typebox";
|
|
69516
69879
|
function serializableObject2(value2) {
|
|
69517
69880
|
if (value2 === null || Array.isArray(value2) || typeof value2 !== "object")
|
|
69518
69881
|
return;
|
|
@@ -69550,7 +69913,7 @@ function judgeArtifactPath(judgesDir, job, criterionIndex) {
|
|
|
69550
69913
|
const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
|
|
69551
69914
|
const root = resolve14(judgesDir);
|
|
69552
69915
|
const path = resolve14(judgesDir, filename);
|
|
69553
|
-
const fromRoot =
|
|
69916
|
+
const fromRoot = relative9(root, path);
|
|
69554
69917
|
if (fromRoot.startsWith("..") || isAbsolute12(fromRoot)) {
|
|
69555
69918
|
throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
|
|
69556
69919
|
}
|
|
@@ -69600,16 +69963,16 @@ function combineUsage(totals) {
|
|
|
69600
69963
|
}
|
|
69601
69964
|
async function runTournament(ctx) {
|
|
69602
69965
|
const artifactDir = await stableArtifactRoot(ctx, "tournament");
|
|
69603
|
-
const attemptsDir =
|
|
69966
|
+
const attemptsDir = join29(artifactDir, "attempts");
|
|
69604
69967
|
const numAttempts = ctx.inputs.num_attempts ?? 4;
|
|
69605
69968
|
const maxConcurrency = ctx.inputs.max_concurrency ?? 4;
|
|
69606
69969
|
const nEvaluations = ctx.inputs.n_evaluations ?? 2;
|
|
69607
69970
|
const pivotCount = ctx.inputs.pivots ?? 1;
|
|
69608
69971
|
const seed = ctx.inputs.seed ?? 0;
|
|
69609
|
-
const judgesDir =
|
|
69610
|
-
await
|
|
69611
|
-
await
|
|
69612
|
-
const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) =>
|
|
69972
|
+
const judgesDir = join29(artifactDir, "judges");
|
|
69973
|
+
await mkdir6(attemptsDir, { recursive: true });
|
|
69974
|
+
await mkdir6(judgesDir, { recursive: true });
|
|
69975
|
+
const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) => join29(attemptsDir, `attempt-${index + 1}.md`));
|
|
69613
69976
|
const models = ctx.inputs.models;
|
|
69614
69977
|
const attemptResults = await ctx.parallel(attemptArtifactPaths.map((path, index) => ({
|
|
69615
69978
|
name: `attempt-${index + 1}`,
|
|
@@ -69622,7 +69985,7 @@ async function runTournament(ctx) {
|
|
|
69622
69985
|
const entrants = await Promise.all(attemptArtifactPaths.map(async (path, index) => ({
|
|
69623
69986
|
label: `attempt-${index + 1}`,
|
|
69624
69987
|
path,
|
|
69625
|
-
body: await
|
|
69988
|
+
body: await readFile6(path, "utf8")
|
|
69626
69989
|
})));
|
|
69627
69990
|
const criteria = tournamentCriteria(ctx.inputs.criteria);
|
|
69628
69991
|
const criterionIds = criteria.map((criterion) => criterion.id);
|
|
@@ -69693,7 +70056,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69693
70056
|
report = judgeReport(retried.structured);
|
|
69694
70057
|
}
|
|
69695
70058
|
if (report === undefined) {
|
|
69696
|
-
await
|
|
70059
|
+
await writeFile10(stage.path, `${JSON.stringify({ invalid: true }, null, 2)}
|
|
69697
70060
|
`);
|
|
69698
70061
|
comparisons.push({
|
|
69699
70062
|
a: stage.job.a,
|
|
@@ -69707,7 +70070,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69707
70070
|
});
|
|
69708
70071
|
continue;
|
|
69709
70072
|
}
|
|
69710
|
-
await
|
|
70073
|
+
await writeFile10(stage.path, `${JSON.stringify(report, null, 2)}
|
|
69711
70074
|
`);
|
|
69712
70075
|
const scoreA = stage.job.swapped ? report.score_b : report.score_a;
|
|
69713
70076
|
const scoreB = stage.job.swapped ? report.score_a : report.score_b;
|
|
@@ -69774,7 +70137,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69774
70137
|
const outputRanking = ranking.map(({ label, meanPreference }) => ({ label, meanPreference }));
|
|
69775
70138
|
const budgetPivots = Math.min(pivotCount, entrants.length);
|
|
69776
70139
|
const comparisonBudget = (entrants.length + budgetPivots * (entrants.length - budgetPivots) + budgetPivots * (budgetPivots - 1) / 2) * criteria.length * nEvaluations;
|
|
69777
|
-
const comparisonPath =
|
|
70140
|
+
const comparisonPath = join29(artifactDir, "comparisons.json");
|
|
69778
70141
|
const assignment = modelAssignment(entrants, models);
|
|
69779
70142
|
const phaseUsage = {
|
|
69780
70143
|
attempts: fold_usage(attemptResults),
|
|
@@ -69804,13 +70167,13 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
|
|
|
69804
70167
|
reducer: reducerUsage,
|
|
69805
70168
|
total: combineUsage([phaseUsage.attempts, phaseUsage.ring, phaseUsage.pivots, reducerUsage])
|
|
69806
70169
|
};
|
|
69807
|
-
await
|
|
70170
|
+
await writeFile10(comparisonPath, `${JSON.stringify({ ...baseLedger, usage }, null, 2)}
|
|
69808
70171
|
`);
|
|
69809
70172
|
};
|
|
69810
70173
|
await writeLedger(fold_usage([]));
|
|
69811
70174
|
const winner = ranking[0];
|
|
69812
70175
|
const winnerEntrant = entrants[winner.index];
|
|
69813
|
-
const resultPath =
|
|
70176
|
+
const resultPath = join29(artifactDir, "winner.md");
|
|
69814
70177
|
const reducer = await ctx.task("comparisons-reducer", {
|
|
69815
70178
|
prompt: renderComparisonsReducerPrompt({
|
|
69816
70179
|
task: ctx.inputs.prompt,
|
|
@@ -69845,16 +70208,16 @@ var init_tournament_runner = __esm(() => {
|
|
|
69845
70208
|
init_verification_criteria();
|
|
69846
70209
|
init_tournament_prompts();
|
|
69847
70210
|
init_pattern_artifact_root();
|
|
69848
|
-
judgeScoreSchema =
|
|
69849
|
-
criterion_id:
|
|
69850
|
-
score_a:
|
|
69851
|
-
score_b:
|
|
69852
|
-
evidence:
|
|
70211
|
+
judgeScoreSchema = Type23.Object({
|
|
70212
|
+
criterion_id: Type23.String(),
|
|
70213
|
+
score_a: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
|
|
70214
|
+
score_b: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
|
|
70215
|
+
evidence: Type23.Array(Type23.String())
|
|
69853
70216
|
}, { additionalProperties: false });
|
|
69854
70217
|
});
|
|
69855
70218
|
|
|
69856
70219
|
// dist/builtin/workflows/builtin/tournament.ts
|
|
69857
|
-
import { Type as
|
|
70220
|
+
import { Type as Type24 } from "typebox";
|
|
69858
70221
|
var tournament_default;
|
|
69859
70222
|
var init_tournament = __esm(() => {
|
|
69860
70223
|
init_workflow();
|
|
@@ -69865,63 +70228,63 @@ var init_tournament = __esm(() => {
|
|
|
69865
70228
|
description: "Run independent whole-task attempts through a soft-scored pivot-pairing schedule and return an auditable ranking.",
|
|
69866
70229
|
heartbeatIntervalMinutes: 15,
|
|
69867
70230
|
inputs: {
|
|
69868
|
-
prompt:
|
|
69869
|
-
num_attempts:
|
|
70231
|
+
prompt: Type24.String({ description: "Task every competing agent must attempt independently." }),
|
|
70232
|
+
num_attempts: Type24.Integer({
|
|
69870
70233
|
minimum: 2,
|
|
69871
70234
|
maximum: 8,
|
|
69872
70235
|
default: 4,
|
|
69873
70236
|
description: "Number of independent whole-task attempts (2-8)."
|
|
69874
70237
|
}),
|
|
69875
|
-
max_concurrency:
|
|
70238
|
+
max_concurrency: Type24.Integer({
|
|
69876
70239
|
minimum: 1,
|
|
69877
70240
|
maximum: 8,
|
|
69878
70241
|
default: 4,
|
|
69879
70242
|
description: "Maximum simultaneously active attempts or pairwise judges (1-8)."
|
|
69880
70243
|
}),
|
|
69881
|
-
n_evaluations:
|
|
70244
|
+
n_evaluations: Type24.Integer({
|
|
69882
70245
|
minimum: 1,
|
|
69883
70246
|
default: 2,
|
|
69884
70247
|
description: "Number of repeated evaluations per criterion and directed pair."
|
|
69885
70248
|
}),
|
|
69886
|
-
pivots:
|
|
70249
|
+
pivots: Type24.Integer({
|
|
69887
70250
|
minimum: 1,
|
|
69888
70251
|
default: 1,
|
|
69889
70252
|
description: "Number of pivot candidates used for the second comparison phase."
|
|
69890
70253
|
}),
|
|
69891
|
-
seed:
|
|
70254
|
+
seed: Type24.Integer({
|
|
69892
70255
|
default: 0,
|
|
69893
70256
|
description: "Seed for the deterministic comparison schedule."
|
|
69894
70257
|
}),
|
|
69895
|
-
criteria:
|
|
69896
|
-
|
|
69897
|
-
|
|
69898
|
-
|
|
69899
|
-
|
|
69900
|
-
id:
|
|
69901
|
-
name:
|
|
69902
|
-
description:
|
|
70258
|
+
criteria: Type24.Optional(Type24.Union([
|
|
70259
|
+
Type24.String(),
|
|
70260
|
+
Type24.Record(Type24.String(), Type24.String()),
|
|
70261
|
+
Type24.Array(Type24.String()),
|
|
70262
|
+
Type24.Array(Type24.Object({
|
|
70263
|
+
id: Type24.Optional(Type24.String()),
|
|
70264
|
+
name: Type24.Optional(Type24.String()),
|
|
70265
|
+
description: Type24.String()
|
|
69903
70266
|
}, { additionalProperties: true }))
|
|
69904
70267
|
], {
|
|
69905
70268
|
description: "Optional V1 judge criteria; accepts a markdown rubric, record, string list, or CriterionInput list; omitted uses the default three-criterion rubric."
|
|
69906
70269
|
})),
|
|
69907
|
-
models:
|
|
70270
|
+
models: Type24.Optional(Type24.Array(Type24.String(), {
|
|
69908
70271
|
description: "Optional ordered model ids assigned round-robin to attempt slots."
|
|
69909
70272
|
}))
|
|
69910
70273
|
},
|
|
69911
70274
|
outputs: {
|
|
69912
|
-
result:
|
|
69913
|
-
winner:
|
|
69914
|
-
winner_artifact_path:
|
|
69915
|
-
result_path:
|
|
69916
|
-
attempt_artifact_paths:
|
|
69917
|
-
judge_artifact_paths:
|
|
69918
|
-
comparisons_path:
|
|
69919
|
-
ranking:
|
|
69920
|
-
label:
|
|
69921
|
-
meanPreference:
|
|
70275
|
+
result: Type24.String({ description: "Compact reference to the final reducer report; read `result_path` for the full report." }),
|
|
70276
|
+
winner: Type24.String({ description: "Stable attempt label selected as the top-ranked tournament winner." }),
|
|
70277
|
+
winner_artifact_path: Type24.String({ description: "Path to the original winning attempt artifact." }),
|
|
70278
|
+
result_path: Type24.String({ description: "Path to the final reducer report artifact." }),
|
|
70279
|
+
attempt_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to every independent attempt artifact." }),
|
|
70280
|
+
judge_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to all per-job structured judge artifacts." }),
|
|
70281
|
+
comparisons_path: Type24.String({ description: "Path to the durable JSON soft-scored comparisons ledger." }),
|
|
70282
|
+
ranking: Type24.Array(Type24.Object({
|
|
70283
|
+
label: Type24.String(),
|
|
70284
|
+
meanPreference: Type24.Number()
|
|
69922
70285
|
}, { additionalProperties: false }), { description: "All attempts ordered by mean preference." }),
|
|
69923
|
-
seed:
|
|
69924
|
-
artifact_dir:
|
|
70286
|
+
seed: Type24.Integer({ description: "Seed used for the deterministic comparison schedule." }),
|
|
70287
|
+
artifact_dir: Type24.String({ description: "Run-specific directory containing tournament artifacts." })
|
|
69925
70288
|
},
|
|
69926
70289
|
run: async (ctx) => await runTournament(withBuiltinContext(ctx))
|
|
69927
70290
|
});
|
|
@@ -70070,7 +70433,7 @@ var init_workflow_module_loader = __esm(() => {
|
|
|
70070
70433
|
|
|
70071
70434
|
// dist/builtin/workflows/src/workers/definitions.ts
|
|
70072
70435
|
import { createHash as createHash5 } from "node:crypto";
|
|
70073
|
-
import { readFile as
|
|
70436
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
70074
70437
|
import { isAbsolute as isAbsolute13 } from "node:path";
|
|
70075
70438
|
async function loadWorkerDefinition(source) {
|
|
70076
70439
|
if (!isAbsolute13(source.path) || await definitionDigest(source.path) !== source.digest)
|
|
@@ -70087,7 +70450,7 @@ async function loadWorkerWorkflow(path, exportName = "default") {
|
|
|
70087
70450
|
return loadWorkerDefinition({ path, exportName, digest: await definitionDigest(path) });
|
|
70088
70451
|
}
|
|
70089
70452
|
async function definitionDigest(path) {
|
|
70090
|
-
return createHash5("sha256").update(await
|
|
70453
|
+
return createHash5("sha256").update(await readFile7(path)).digest("hex");
|
|
70091
70454
|
}
|
|
70092
70455
|
var workerDefinitionSources;
|
|
70093
70456
|
var init_definitions = __esm(() => {
|
|
@@ -70488,7 +70851,7 @@ var init_pending_stage_status = __esm(() => {
|
|
|
70488
70851
|
"awaiting_input",
|
|
70489
70852
|
"paused",
|
|
70490
70853
|
"blocked",
|
|
70491
|
-
"
|
|
70854
|
+
"suspended"
|
|
70492
70855
|
]);
|
|
70493
70856
|
});
|
|
70494
70857
|
|
|
@@ -71378,7 +71741,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71378
71741
|
stageId: stage.id,
|
|
71379
71742
|
stageName: stage.name,
|
|
71380
71743
|
target: stageRouteTarget(lookups.runs, rootRunId, run.id, stage.id, lookups.segments),
|
|
71381
|
-
lifecycle: stage.status === "
|
|
71744
|
+
lifecycle: stage.status === "suspended" || stage.sessionId === undefined && stage.sessionFile === undefined ? "pending" : "running",
|
|
71382
71745
|
routeEligible: stage.pendingStageDeliveryAvailable === true && isAddressableStageStatus(stage.status),
|
|
71383
71746
|
group: stage.intercomGroup ?? workflowInvocationIntercomGroup(rootRunId)
|
|
71384
71747
|
})),
|
|
@@ -71657,7 +72020,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71657
72020
|
target: payload.target
|
|
71658
72021
|
};
|
|
71659
72022
|
const stage = destination.stage;
|
|
71660
|
-
const live = stage.status !== "
|
|
72023
|
+
const live = stage.status !== "suspended" && (stage.sessionId !== undefined || stage.sessionFile !== undefined);
|
|
71661
72024
|
const stageTerminal = stage.status === "completed" || stage.status === "skipped" || stage.status === "failed";
|
|
71662
72025
|
if (payload.live !== true && live && !stageTerminal && externalRunRouteOwner(activeStore, destination.run.id)?.deliversQueued(destination.run.id, stage.id) === true) {
|
|
71663
72026
|
payload.handled = true;
|
|
@@ -71665,7 +72028,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
71665
72028
|
payload.completion = refusal === undefined ? queueAndPersist(activeStore, resolvedEvent, workflowInvocationIntercomGroup(rootRunId), true) : Promise.resolve({ outcome: "refused", reason: refusal });
|
|
71666
72029
|
return;
|
|
71667
72030
|
}
|
|
71668
|
-
if (payload.live === true && stage.status !== "
|
|
72031
|
+
if (payload.live === true && stage.status !== "suspended" || live && !stageTerminal) {
|
|
71669
72032
|
payload.handled = true;
|
|
71670
72033
|
payload.completion = validateLiveDelivery(activeStore, resolvedEvent).then((result) => result.outcome === "forward" ? {
|
|
71671
72034
|
outcome: "forward",
|
|
@@ -72017,7 +72380,7 @@ function knownUninitializedStage(run, stageKey) {
|
|
|
72017
72380
|
if (candidates.length !== 1)
|
|
72018
72381
|
return;
|
|
72019
72382
|
const stage = candidates[0];
|
|
72020
|
-
if (stage.status === "
|
|
72383
|
+
if (stage.status === "suspended")
|
|
72021
72384
|
return stage;
|
|
72022
72385
|
return isAddressableStageStatus(stage.status) && stage.sessionId === undefined && stage.sessionFile === undefined ? stage : undefined;
|
|
72023
72386
|
}
|
|
@@ -72261,7 +72624,7 @@ var init_broker_status = __esm(() => {
|
|
|
72261
72624
|
|
|
72262
72625
|
// dist/builtin/intercom/broker/paths.ts
|
|
72263
72626
|
import { homedir as homedir2 } from "os";
|
|
72264
|
-
import { join as
|
|
72627
|
+
import { join as join30 } from "path";
|
|
72265
72628
|
function getHomeDir() {
|
|
72266
72629
|
if (process.platform === "win32") {
|
|
72267
72630
|
if (process.env.USERPROFILE)
|
|
@@ -72278,42 +72641,42 @@ function expandTildePath(path) {
|
|
|
72278
72641
|
if (path === "~")
|
|
72279
72642
|
return getHomeDir();
|
|
72280
72643
|
if (path.startsWith("~/") || process.platform === "win32" && path.startsWith("~\\")) {
|
|
72281
|
-
return
|
|
72644
|
+
return join30(getHomeDir(), path.slice(2));
|
|
72282
72645
|
}
|
|
72283
72646
|
return path;
|
|
72284
72647
|
}
|
|
72285
|
-
function
|
|
72648
|
+
function getAgentDir6() {
|
|
72286
72649
|
const atomicAgentDir = process.env.ATOMIC_CODING_AGENT_DIR;
|
|
72287
72650
|
if (atomicAgentDir)
|
|
72288
72651
|
return expandTildePath(atomicAgentDir);
|
|
72289
72652
|
const piAgentDir = process.env.PI_CODING_AGENT_DIR;
|
|
72290
72653
|
if (piAgentDir)
|
|
72291
72654
|
return expandTildePath(piAgentDir);
|
|
72292
|
-
return
|
|
72655
|
+
return join30(getHomeDir(), ".atomic", "agent");
|
|
72293
72656
|
}
|
|
72294
72657
|
function sanitizePipeSegment(value2) {
|
|
72295
72658
|
return value2.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "default";
|
|
72296
72659
|
}
|
|
72297
|
-
function getIntercomDirPath(agentDir =
|
|
72298
|
-
return
|
|
72660
|
+
function getIntercomDirPath(agentDir = getAgentDir6()) {
|
|
72661
|
+
return join30(agentDir, "intercom");
|
|
72299
72662
|
}
|
|
72300
|
-
function getBrokerPidPath(agentDir =
|
|
72301
|
-
return
|
|
72663
|
+
function getBrokerPidPath(agentDir = getAgentDir6()) {
|
|
72664
|
+
return join30(getIntercomDirPath(agentDir), "broker.pid");
|
|
72302
72665
|
}
|
|
72303
|
-
function getBrokerSpawnLockPath(agentDir =
|
|
72304
|
-
return
|
|
72666
|
+
function getBrokerSpawnLockPath(agentDir = getAgentDir6()) {
|
|
72667
|
+
return join30(getIntercomDirPath(agentDir), "broker.spawn.lock");
|
|
72305
72668
|
}
|
|
72306
|
-
function getBrokerLogPath(agentDir =
|
|
72307
|
-
return
|
|
72669
|
+
function getBrokerLogPath(agentDir = getAgentDir6()) {
|
|
72670
|
+
return join30(getIntercomDirPath(agentDir), "broker.log");
|
|
72308
72671
|
}
|
|
72309
|
-
function getBrokerStartAnnouncementPath(agentDir =
|
|
72310
|
-
return
|
|
72672
|
+
function getBrokerStartAnnouncementPath(agentDir = getAgentDir6()) {
|
|
72673
|
+
return join30(getIntercomDirPath(agentDir), "broker.starting");
|
|
72311
72674
|
}
|
|
72312
|
-
function getBrokerSocketPath(platform = process.platform, agentDir =
|
|
72675
|
+
function getBrokerSocketPath(platform = process.platform, agentDir = getAgentDir6()) {
|
|
72313
72676
|
if (platform === "win32") {
|
|
72314
72677
|
return `\\\\.\\pipe\\pi-intercom-${sanitizePipeSegment(agentDir)}`;
|
|
72315
72678
|
}
|
|
72316
|
-
return
|
|
72679
|
+
return join30(getIntercomDirPath(agentDir), "broker.sock");
|
|
72317
72680
|
}
|
|
72318
72681
|
var BROKER_STORAGE_ENV = "ATOMIC_STORAGE";
|
|
72319
72682
|
var init_paths = () => {};
|
|
@@ -74487,8 +74850,8 @@ var init_shared_storage_setting = __esm(() => {
|
|
|
74487
74850
|
// dist/builtin/intercom/broker/spawn.ts
|
|
74488
74851
|
import { spawn } from "child_process";
|
|
74489
74852
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
74490
|
-
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as
|
|
74491
|
-
import { join as
|
|
74853
|
+
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as existsSync9, mkdirSync as mkdirSync8, openSync as openSync3, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync5, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
74854
|
+
import { join as join31, dirname as dirname16 } from "path";
|
|
74492
74855
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
74493
74856
|
import { createRequire as createRequire3 } from "module";
|
|
74494
74857
|
import {
|
|
@@ -74499,17 +74862,17 @@ import {
|
|
|
74499
74862
|
processSharedStorageSelection
|
|
74500
74863
|
} from "@bastani/atomic";
|
|
74501
74864
|
function isIntercomPackageRoot(dir) {
|
|
74502
|
-
return
|
|
74865
|
+
return existsSync9(join31(dir, "package.json")) && existsSync9(join31(dir, "broker"));
|
|
74503
74866
|
}
|
|
74504
74867
|
function resolveIntercomPackageRoot(moduleHref) {
|
|
74505
|
-
const here =
|
|
74868
|
+
const here = dirname16(fileURLToPath5(moduleHref));
|
|
74506
74869
|
if (isIntercomPackageRoot(here))
|
|
74507
74870
|
return here;
|
|
74508
|
-
return
|
|
74871
|
+
return join31(here, "..");
|
|
74509
74872
|
}
|
|
74510
74873
|
function resolveBrokerEntrypoint(packageRoot) {
|
|
74511
|
-
const bundled =
|
|
74512
|
-
return
|
|
74874
|
+
const bundled = join31(packageRoot, "broker", "broker.bundle.mjs");
|
|
74875
|
+
return existsSync9(bundled) ? bundled : join31(packageRoot, "broker", "broker.ts");
|
|
74513
74876
|
}
|
|
74514
74877
|
function ensurePrivateDirectory(path) {
|
|
74515
74878
|
mkdirSync8(path, { recursive: true, mode: 448 });
|
|
@@ -74525,14 +74888,14 @@ function getCurrentBrokerRuntime() {
|
|
|
74525
74888
|
return isBunBinary ? "bun-binary" : "bun-source";
|
|
74526
74889
|
}
|
|
74527
74890
|
function requireFromExtensionDir(extensionDir) {
|
|
74528
|
-
return createRequire3(
|
|
74891
|
+
return createRequire3(join31(extensionDir, "package.json"));
|
|
74529
74892
|
}
|
|
74530
74893
|
function getJitiCliPath(extensionDir = EXTENSION_DIR) {
|
|
74531
74894
|
try {
|
|
74532
74895
|
const jitiPackage = requireFromExtensionDir(extensionDir).resolve("jiti/package.json");
|
|
74533
|
-
return
|
|
74896
|
+
return join31(dirname16(jitiPackage), "lib", "jiti-cli.mjs");
|
|
74534
74897
|
} catch {
|
|
74535
|
-
return
|
|
74898
|
+
return join31(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
|
|
74536
74899
|
}
|
|
74537
74900
|
}
|
|
74538
74901
|
function getDefaultBrokerRunnerPath(extensionDir) {
|
|
@@ -74554,7 +74917,7 @@ function quoteWindowsArg(value2) {
|
|
|
74554
74917
|
return `"${value2.replace(/"/g, '""')}"`;
|
|
74555
74918
|
}
|
|
74556
74919
|
function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
|
|
74557
|
-
return
|
|
74920
|
+
return join31(intercomDir, "broker-launch.vbs");
|
|
74558
74921
|
}
|
|
74559
74922
|
function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
|
|
74560
74923
|
return brokerCommand === "npx" && brokerArgs.length === 2 && brokerArgs[0] === "--no-install" && brokerArgs[1] === "tsx";
|
|
@@ -74581,7 +74944,7 @@ function getWindowsHiddenLauncherScript(commandLine) {
|
|
|
74581
74944
|
`);
|
|
74582
74945
|
}
|
|
74583
74946
|
function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHiddenLauncherPath()) {
|
|
74584
|
-
ensurePrivateDirectory(
|
|
74947
|
+
ensurePrivateDirectory(dirname16(launcherPath));
|
|
74585
74948
|
writeFileSync6(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
|
|
74586
74949
|
return launcherPath;
|
|
74587
74950
|
}
|
|
@@ -74625,7 +74988,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
|
|
|
74625
74988
|
};
|
|
74626
74989
|
}
|
|
74627
74990
|
function resetBrokerLog(logPath = getBrokerLogPath()) {
|
|
74628
|
-
ensurePrivateDirectory(
|
|
74991
|
+
ensurePrivateDirectory(dirname16(logPath));
|
|
74629
74992
|
try {
|
|
74630
74993
|
const previous = readBrokerLogTail(logPath);
|
|
74631
74994
|
closeSync3(openSync3(logPath, "w"));
|
|
@@ -74776,7 +75139,7 @@ async function isBrokerRunning() {
|
|
|
74776
75139
|
if (await checkSocketConnectable()) {
|
|
74777
75140
|
return true;
|
|
74778
75141
|
}
|
|
74779
|
-
if (!
|
|
75142
|
+
if (!existsSync9(getBrokerPidPath()))
|
|
74780
75143
|
return false;
|
|
74781
75144
|
try {
|
|
74782
75145
|
const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
|
|
@@ -74842,7 +75205,7 @@ function isProcessAlive(pid) {
|
|
|
74842
75205
|
}
|
|
74843
75206
|
}
|
|
74844
75207
|
function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
|
|
74845
|
-
if (!
|
|
75208
|
+
if (!existsSync9(lockPath)) {
|
|
74846
75209
|
return false;
|
|
74847
75210
|
}
|
|
74848
75211
|
try {
|
|
@@ -74969,10 +75332,10 @@ var init_reply_waiter = __esm(() => {
|
|
|
74969
75332
|
});
|
|
74970
75333
|
|
|
74971
75334
|
// dist/builtin/intercom/config.ts
|
|
74972
|
-
import { existsSync as
|
|
75335
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8 } from "fs";
|
|
74973
75336
|
import { getAgentConfigPaths } from "@bastani/atomic";
|
|
74974
75337
|
function loadConfig() {
|
|
74975
|
-
if (!
|
|
75338
|
+
if (!existsSync10(CONFIG_PATH)) {
|
|
74976
75339
|
return { ...defaults };
|
|
74977
75340
|
}
|
|
74978
75341
|
try {
|
|
@@ -75054,7 +75417,7 @@ var init_config = __esm(() => {
|
|
|
75054
75417
|
init_diagnostics();
|
|
75055
75418
|
init_reply_waiter();
|
|
75056
75419
|
CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
|
|
75057
|
-
CONFIG_PATH = CONFIG_PATHS.find((path) =>
|
|
75420
|
+
CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync10(path)) ?? CONFIG_PATHS[0];
|
|
75058
75421
|
DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
|
|
75059
75422
|
defaults = {
|
|
75060
75423
|
brokerCommand: DEFAULT_BROKER_COMMAND,
|
|
@@ -76411,6 +76774,17 @@ var init_stage_queued_user_messages = __esm(() => {
|
|
|
76411
76774
|
});
|
|
76412
76775
|
});
|
|
76413
76776
|
|
|
76777
|
+
// dist/builtin/workflows/src/shared/legacy-waiting-status.ts
|
|
76778
|
+
function isLegacyWaiting(status) {
|
|
76779
|
+
return status === "waiting";
|
|
76780
|
+
}
|
|
76781
|
+
function stageStatusFromRecord(status) {
|
|
76782
|
+
return status === "waiting" ? "suspended" : status;
|
|
76783
|
+
}
|
|
76784
|
+
function runSnapshotsFromRecord(runs) {
|
|
76785
|
+
return runs.map((run) => run.stages.some((stage) => isLegacyWaiting(stage.status)) ? { ...run, stages: run.stages.map((stage) => ({ ...stage, status: stageStatusFromRecord(stage.status) })) } : run);
|
|
76786
|
+
}
|
|
76787
|
+
|
|
76414
76788
|
// dist/builtin/workflows/src/workers/ended-watches.ts
|
|
76415
76789
|
var EndedWatches;
|
|
76416
76790
|
var init_ended_watches = __esm(() => {
|
|
@@ -76467,14 +76841,14 @@ var UNATTRIBUTED_WRITE = "other";
|
|
|
76467
76841
|
var init_pool_coordination_stats = () => {};
|
|
76468
76842
|
|
|
76469
76843
|
// dist/builtin/workflows/src/workers/pooled-watch-trace.ts
|
|
76470
|
-
import { dirname as
|
|
76844
|
+
import { dirname as dirname17, join as join32, resolve as resolve15 } from "node:path";
|
|
76471
76845
|
import { appendDebugRecord, isDebugEnabled as isDebugEnabled2, reportDebug } from "@bastani/atomic";
|
|
76472
76846
|
function configurePooledWatchTrace(journal, processRole) {
|
|
76473
76847
|
journalPath = journal;
|
|
76474
76848
|
role = processRole;
|
|
76475
76849
|
}
|
|
76476
76850
|
function ownTraceFile(journal, setting) {
|
|
76477
|
-
return setting === "1" ?
|
|
76851
|
+
return setting === "1" ? join32(dirname17(resolve15(journal)), "pooled-watch-trace.jsonl") : resolve15(setting);
|
|
76478
76852
|
}
|
|
76479
76853
|
function tracePooledWatch(step, detail) {
|
|
76480
76854
|
if (!isDebugEnabled2("pooled-watch"))
|
|
@@ -76495,7 +76869,7 @@ var init_pooled_watch_trace = () => {};
|
|
|
76495
76869
|
// dist/builtin/workflows/src/workers/process-log.ts
|
|
76496
76870
|
import { createWriteStream, mkdirSync as mkdirSync9 } from "node:fs";
|
|
76497
76871
|
import { rm as rm3, rmdir } from "node:fs/promises";
|
|
76498
|
-
import { dirname as
|
|
76872
|
+
import { dirname as dirname18 } from "node:path";
|
|
76499
76873
|
function logFailureOf(error) {
|
|
76500
76874
|
const code = error.code;
|
|
76501
76875
|
return typeof code === "string" ? code : error.name;
|
|
@@ -76532,7 +76906,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
|
|
|
76532
76906
|
return { close };
|
|
76533
76907
|
stderr.on("error", fail);
|
|
76534
76908
|
try {
|
|
76535
|
-
mkdirSync9(
|
|
76909
|
+
mkdirSync9(dirname18(logPath), { recursive: true });
|
|
76536
76910
|
} catch (error) {
|
|
76537
76911
|
fail(asError(error));
|
|
76538
76912
|
return { close };
|
|
@@ -76544,7 +76918,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
|
|
|
76544
76918
|
}
|
|
76545
76919
|
async function removeProcessLog(logPath) {
|
|
76546
76920
|
await rm3(logPath, { force: true });
|
|
76547
|
-
await rmdir(
|
|
76921
|
+
await rmdir(dirname18(logPath)).catch((error) => {
|
|
76548
76922
|
const code = error.code;
|
|
76549
76923
|
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
|
|
76550
76924
|
throw error;
|
|
@@ -77275,9 +77649,9 @@ var init_worker_timing = __esm(() => {
|
|
|
77275
77649
|
// dist/builtin/workflows/src/workers/pool-coordinator.ts
|
|
77276
77650
|
import { fork } from "node:child_process";
|
|
77277
77651
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
77278
|
-
import { existsSync as
|
|
77279
|
-
import { appendFile, mkdir as
|
|
77280
|
-
import { delimiter, dirname as
|
|
77652
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
77653
|
+
import { appendFile, mkdir as mkdir7, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
|
|
77654
|
+
import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join33, resolve as resolve16 } from "node:path";
|
|
77281
77655
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
77282
77656
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
77283
77657
|
import { setDebugSetting } from "@bastani/atomic";
|
|
@@ -77286,10 +77660,10 @@ function unconfirmedCleanup(groups) {
|
|
|
77286
77660
|
return new WorkerCleanupUnconfirmedError({ processGroups: groups });
|
|
77287
77661
|
}
|
|
77288
77662
|
function workerLogDirectory(journalPath, root) {
|
|
77289
|
-
return
|
|
77663
|
+
return join33(dirname19(resolve16(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
|
|
77290
77664
|
}
|
|
77291
77665
|
function traceAnchor(options) {
|
|
77292
|
-
return options.shared === undefined ? options.journalPath :
|
|
77666
|
+
return options.shared === undefined ? options.journalPath : join33(options.shared.stateDirectory, "shared-pool");
|
|
77293
77667
|
}
|
|
77294
77668
|
function token(work) {
|
|
77295
77669
|
return {
|
|
@@ -77737,7 +78111,7 @@ class PoolCoordinator {
|
|
|
77737
78111
|
if (options.shared !== undefined)
|
|
77738
78112
|
this.journal ??= await this.countedJournal(await openDurableJournal(options.durable));
|
|
77739
78113
|
else {
|
|
77740
|
-
if (options.journalShard !== undefined && !
|
|
78114
|
+
if (options.journalShard !== undefined && !existsSync11(options.journalPath))
|
|
77741
78115
|
throw new JournalShardUnavailableError2({
|
|
77742
78116
|
code: "shard-missing",
|
|
77743
78117
|
shardId: options.journalShard,
|
|
@@ -77972,7 +78346,7 @@ class PoolCoordinator {
|
|
|
77972
78346
|
crossHost: true
|
|
77973
78347
|
});
|
|
77974
78348
|
this.logDirectory = workerLogDirectory(traceAnchor(this.options), root);
|
|
77975
|
-
await
|
|
78349
|
+
await mkdir7(this.logDirectory, { recursive: true });
|
|
77976
78350
|
if (this.closed)
|
|
77977
78351
|
return;
|
|
77978
78352
|
this.starting = Promise.resolve();
|
|
@@ -78083,7 +78457,7 @@ class PoolCoordinator {
|
|
|
78083
78457
|
this.activityCursor = Math.max(this.activityCursor, entry.version);
|
|
78084
78458
|
if (local.has(entry.work.id) || !this.attemptBase.has(entry.work.id))
|
|
78085
78459
|
continue;
|
|
78086
|
-
const runs = JSON.parse(entry.runs);
|
|
78460
|
+
const runs = runSnapshotsFromRecord(JSON.parse(entry.runs));
|
|
78087
78461
|
this.pendingActivity.set(entry.work.id, { work: entry.work, runs });
|
|
78088
78462
|
for (const [id, reason] of this.remoteWatches.relayed(entry.work, runs))
|
|
78089
78463
|
this.endRemoteWatch(id, reason);
|
|
@@ -78710,7 +79084,7 @@ class PoolCoordinator {
|
|
|
78710
79084
|
let ready = false;
|
|
78711
79085
|
const lanes = new WorkerRequestLanes;
|
|
78712
79086
|
const extensions = new AttemptLeaseExtensions(slot, (attempt) => this.queue.extend(this.lease, attempt, options.leaseMs));
|
|
78713
|
-
const logPath =
|
|
79087
|
+
const logPath = join33(this.logDirectory, `${id}.log`);
|
|
78714
79088
|
this.logs.set(child, logPath);
|
|
78715
79089
|
appendProcessLog(child.stderr, logPath, (failure) => this.logUnwritable(logPath, failure));
|
|
78716
79090
|
const startupTimeoutMs = options.startupTimeoutMs;
|
|
@@ -79503,7 +79877,7 @@ function withHostGit(env, git) {
|
|
|
79503
79877
|
return {
|
|
79504
79878
|
...env,
|
|
79505
79879
|
...git.env,
|
|
79506
|
-
...isAbsolute14(git.path) ? { [pathKey]: [
|
|
79880
|
+
...isAbsolute14(git.path) ? { [pathKey]: [dirname19(git.path), env[pathKey]].filter(Boolean).join(delimiter) } : {}
|
|
79507
79881
|
};
|
|
79508
79882
|
}
|
|
79509
79883
|
function processPort() {
|
|
@@ -79643,7 +80017,7 @@ function remoteStageDrainTargets(generation, runs, queueOf, rootQueue) {
|
|
|
79643
80017
|
for (const stage of run.stages) {
|
|
79644
80018
|
const target = { runId: run.id, stageId: stage.id };
|
|
79645
80019
|
const { sessionId } = stage;
|
|
79646
|
-
if (sessionId === undefined || stage.status === "
|
|
80020
|
+
if (sessionId === undefined || stage.status === "suspended" || stage.pendingStageDeliveryAvailable !== true || isTerminalStageStatus(stage.status))
|
|
79647
80021
|
forget.push(target);
|
|
79648
80022
|
else
|
|
79649
80023
|
drain.push({ target: { ...target, sessionId, generation, queues }, stageName: stage.name });
|
|
@@ -81894,14 +82268,14 @@ class PooledStageRegistrations {
|
|
|
81894
82268
|
var LIVE;
|
|
81895
82269
|
var init_pooled_stage_registry = __esm(() => {
|
|
81896
82270
|
init_stage_queued_user_messages();
|
|
81897
|
-
LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "
|
|
82271
|
+
LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "suspended"]);
|
|
81898
82272
|
});
|
|
81899
82273
|
|
|
81900
82274
|
// dist/builtin/workflows/src/workers/local-pool.ts
|
|
81901
82275
|
import { fork as fork2 } from "node:child_process";
|
|
81902
82276
|
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
81903
|
-
import { existsSync as
|
|
81904
|
-
import { join as
|
|
82277
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
82278
|
+
import { join as join34, resolve as resolve17 } from "node:path";
|
|
81905
82279
|
import { setTimeout as delay5 } from "node:timers/promises";
|
|
81906
82280
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
81907
82281
|
import {
|
|
@@ -82107,7 +82481,7 @@ class LocalWorkerPool {
|
|
|
82107
82481
|
this.options = options;
|
|
82108
82482
|
if (options.shared === undefined ? options.journalPath === undefined : options.durable === undefined)
|
|
82109
82483
|
throw new WorkerPlacementConfigError("sdk", options.shared === undefined ? "journalPath" : "durable", "invalid-option", "a local worker pool needs the database its tables are in");
|
|
82110
|
-
configurePooledWatchTrace(options.shared === undefined ? options.journalPath :
|
|
82484
|
+
configurePooledWatchTrace(options.shared === undefined ? options.journalPath : join34(options.shared.stateDirectory, "shared-pool"), "root");
|
|
82111
82485
|
if (!Number.isSafeInteger(options.workers) || options.workers < 1)
|
|
82112
82486
|
throw new Error("Invalid local worker count");
|
|
82113
82487
|
if (options.startupTimeoutMs !== undefined && (!Number.isSafeInteger(options.startupTimeoutMs) || options.startupTimeoutMs < 1 || options.startupTimeoutMs > MAX_TIMER_DELAY_MS))
|
|
@@ -82145,7 +82519,7 @@ class LocalWorkerPool {
|
|
|
82145
82519
|
async prepare(root, store) {
|
|
82146
82520
|
if (this.closed)
|
|
82147
82521
|
throw new Error("Local worker pool is closed");
|
|
82148
|
-
if (this.options.journalShard !== undefined && !
|
|
82522
|
+
if (this.options.journalShard !== undefined && !existsSync12(this.options.journalPath))
|
|
82149
82523
|
throw new JournalShardUnavailableError3({
|
|
82150
82524
|
code: "shard-missing",
|
|
82151
82525
|
shardId: this.options.journalShard,
|
|
@@ -82927,7 +83301,7 @@ class LocalWorkerPool {
|
|
|
82927
83301
|
const root = this.root;
|
|
82928
83302
|
if (root === undefined)
|
|
82929
83303
|
throw new PoolNotInitializedError({});
|
|
82930
|
-
const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(
|
|
83304
|
+
const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(join34(workerLogDirectory(traceAnchor(this.options), root), "coordinator.log"));
|
|
82931
83305
|
this.coordinator = coordinator;
|
|
82932
83306
|
const outbox = new RateLimitObservationOutbox((observations) => coordinator.port.send({ kind: "rate-limits", observations }));
|
|
82933
83307
|
const unobserve = observeProviderRateLimits((observation) => outbox.offer(observation));
|
|
@@ -83606,8 +83980,8 @@ var init_public_pool = __esm(() => {
|
|
|
83606
83980
|
// dist/builtin/workflows/src/workers/shared-setup.ts
|
|
83607
83981
|
import { constants } from "node:fs";
|
|
83608
83982
|
import { access } from "node:fs/promises";
|
|
83609
|
-
import { dirname as
|
|
83610
|
-
import { getAgentDir as
|
|
83983
|
+
import { dirname as dirname20, isAbsolute as isAbsolute15, join as join35 } from "node:path";
|
|
83984
|
+
import { getAgentDir as getAgentDir7, SettingsManager as SettingsManager2 } from "@bastani/atomic";
|
|
83611
83985
|
import {
|
|
83612
83986
|
loadStorageAdapter,
|
|
83613
83987
|
StorageAdapterLoadError,
|
|
@@ -83643,13 +84017,13 @@ async function sharedSelectionProblems(selection, agentDir) {
|
|
|
83643
84017
|
if ("env" in ref) {
|
|
83644
84018
|
if (process.env[ref.env] === undefined)
|
|
83645
84019
|
problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
|
|
83646
|
-
} else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file :
|
|
84020
|
+
} else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file : join35(dirname20(agentDir), ref.file)))
|
|
83647
84021
|
problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
|
|
83648
84022
|
}
|
|
83649
84023
|
return problems;
|
|
83650
84024
|
}
|
|
83651
84025
|
async function checkSharedPlacementSetup(journal, options = {}) {
|
|
83652
|
-
const agentDir = options.agentDir ??
|
|
84026
|
+
const agentDir = options.agentDir ?? getAgentDir7();
|
|
83653
84027
|
const problems = await sharedSelectionProblems(sharedJournalSelection(journal, { agentDir, ...options.cwd === undefined ? {} : { cwd: options.cwd } }), agentDir);
|
|
83654
84028
|
if (!await processContainmentAvailable())
|
|
83655
84029
|
problems.push(sharedPoolProblems.processContainmentUnavailable());
|
|
@@ -85801,7 +86175,7 @@ function waitForStageStartup(operation, signal) {
|
|
|
85801
86175
|
import {
|
|
85802
86176
|
AutoRoutingInferenceError,
|
|
85803
86177
|
convertToLlm,
|
|
85804
|
-
currentWorktreeRootMappings,
|
|
86178
|
+
currentWorktreeRootMappings as currentWorktreeRootMappings2,
|
|
85805
86179
|
findToolDetachmentError,
|
|
85806
86180
|
isExtensionStartupFailure,
|
|
85807
86181
|
isTaskCleanupError as isTaskCleanupError2,
|
|
@@ -85952,7 +86326,7 @@ class StageSessionController {
|
|
|
85952
86326
|
pauseControl = new StageSessionPause(() => this.session ?? this.residencyState?.replacement.retiringSession);
|
|
85953
86327
|
residencyState;
|
|
85954
86328
|
hasExplicitModelFallbackConfig;
|
|
85955
|
-
runWorktreeRootMappings =
|
|
86329
|
+
runWorktreeRootMappings = currentWorktreeRootMappings2();
|
|
85956
86330
|
candidatesPromise;
|
|
85957
86331
|
scopedModelsPromise;
|
|
85958
86332
|
modelRoute;
|
|
@@ -88395,8 +88769,8 @@ var init_stage_runner_controller = __esm(() => {
|
|
|
88395
88769
|
|
|
88396
88770
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
|
|
88397
88771
|
import { createHash as createHash6 } from "node:crypto";
|
|
88398
|
-
import { mkdir as
|
|
88399
|
-
import { basename as basename5, dirname as
|
|
88772
|
+
import { mkdir as mkdir8, writeFile as writeFile11 } from "node:fs/promises";
|
|
88773
|
+
import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join36, resolve as resolve19 } from "node:path";
|
|
88400
88774
|
function normalizeMaxOutput2(maxOutput) {
|
|
88401
88775
|
return {
|
|
88402
88776
|
bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
@@ -88459,7 +88833,7 @@ function formatByteSize(bytes) {
|
|
|
88459
88833
|
}
|
|
88460
88834
|
function transcriptPath(runId, outputPath) {
|
|
88461
88835
|
const digest = createHash6("sha256").update(outputPath).digest("hex").slice(0, 16);
|
|
88462
|
-
return
|
|
88836
|
+
return join36(workflowArtifactRunPath(runId), "transcripts", `${digest}-${basename5(outputPath)}.transcript.md`);
|
|
88463
88837
|
}
|
|
88464
88838
|
function appendContent(lines, content) {
|
|
88465
88839
|
if (typeof content === "string") {
|
|
@@ -88580,8 +88954,8 @@ async function finalizePromptOutput(fullOutput, outputOptions, runtimeCwd, runId
|
|
|
88580
88954
|
const transcriptFile = transcriptPath(runId, outputPath);
|
|
88581
88955
|
const transcript = renderTranscript(messages, fullOutput);
|
|
88582
88956
|
try {
|
|
88583
|
-
await
|
|
88584
|
-
await
|
|
88957
|
+
await mkdir8(dirname21(outputPath), { recursive: true });
|
|
88958
|
+
await writeFile11(outputPath, fullOutput, "utf8");
|
|
88585
88959
|
} catch (err) {
|
|
88586
88960
|
return `${displayOutput}
|
|
88587
88961
|
|
|
@@ -88592,8 +88966,8 @@ ${err instanceof Error ? err.message : String(err)}`;
|
|
|
88592
88966
|
let transcriptError;
|
|
88593
88967
|
try {
|
|
88594
88968
|
await ensureWorkflowArtifactRunDirectory(runId);
|
|
88595
|
-
await
|
|
88596
|
-
await
|
|
88969
|
+
await mkdir8(dirname21(transcriptFile), { recursive: true });
|
|
88970
|
+
await writeFile11(transcriptFile, transcript, "utf8");
|
|
88597
88971
|
transcriptAvailable = true;
|
|
88598
88972
|
} catch (err) {
|
|
88599
88973
|
transcriptError = err instanceof Error ? err.message : String(err);
|
|
@@ -89808,7 +90182,7 @@ var init_child_workflow_failure_message = __esm(() => {
|
|
|
89808
90182
|
});
|
|
89809
90183
|
|
|
89810
90184
|
// dist/builtin/workflows/src/engine/primitives/workflow.ts
|
|
89811
|
-
import { existsSync as
|
|
90185
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
89812
90186
|
import {
|
|
89813
90187
|
acquireWorkspaceWriterLease,
|
|
89814
90188
|
isBoundWorkspace as isBoundWorkspace4,
|
|
@@ -90000,7 +90374,7 @@ async function bindChildWorkspace(workspace, invocation, signal, owner, restored
|
|
|
90000
90374
|
binding = recorded;
|
|
90001
90375
|
} catch (error) {
|
|
90002
90376
|
const worktree = mapWorkflowWorktreePath(recorded.worktree, restored);
|
|
90003
|
-
if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree ||
|
|
90377
|
+
if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree || existsSync13(recorded.worktree))
|
|
90004
90378
|
throw error;
|
|
90005
90379
|
binding = { ...recorded, worktree };
|
|
90006
90380
|
}
|
|
@@ -92325,7 +92699,7 @@ function runSnapshotsFromCheckpoints(checkpoints, rootRunId, rootRunName, fallba
|
|
|
92325
92699
|
return runs;
|
|
92326
92700
|
}
|
|
92327
92701
|
function stageSnapshotFromDraft(draft, id, parentIds) {
|
|
92328
|
-
const status = draft.topology?.status ?? "completed";
|
|
92702
|
+
const status = stageStatusFromRecord(draft.topology?.status ?? "completed");
|
|
92329
92703
|
const startedAt = draft.startedAt ?? draft.firstCompletedAt;
|
|
92330
92704
|
const endedAt = draft.endedAt ?? (status === "running" ? undefined : draft.firstCompletedAt);
|
|
92331
92705
|
const workflowChild = workflowChildFromDraft(draft);
|
|
@@ -94981,7 +95355,7 @@ function createStageControlHandle(runtime) {
|
|
|
94981
95355
|
readinessPauseVersion = (runtime.state.readinessPauseVersion ?? 0) + 1;
|
|
94982
95356
|
runtime.state.readinessPauseVersion = readinessPauseVersion;
|
|
94983
95357
|
}
|
|
94984
|
-
if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "
|
|
95358
|
+
if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "suspended" || runtime.innerCtx.isStreaming) {
|
|
94985
95359
|
try {
|
|
94986
95360
|
await runtime.innerCtx.__requestPause();
|
|
94987
95361
|
} catch (error) {
|
|
@@ -95446,14 +95820,14 @@ function createWorkflowStageFactory(input) {
|
|
|
95446
95820
|
return;
|
|
95447
95821
|
statusBeforeRelease = wait.kind !== "tool" || stageSnapshot.status === "completed" || stageSnapshot.status === "failed" ? stageSnapshot.status : undefined;
|
|
95448
95822
|
if (stageSnapshot.status !== "paused")
|
|
95449
|
-
stageSnapshot.status = "
|
|
95823
|
+
stageSnapshot.status = "suspended";
|
|
95450
95824
|
if (wait.kind !== "tool")
|
|
95451
95825
|
idleReleaser.trackReleased(stageId, settleReleased);
|
|
95452
95826
|
};
|
|
95453
95827
|
const settleReleased = () => {
|
|
95454
95828
|
shownWait = undefined;
|
|
95455
95829
|
delete stageSnapshot.wait;
|
|
95456
|
-
if (stageSnapshot.status === "
|
|
95830
|
+
if (stageSnapshot.status === "suspended")
|
|
95457
95831
|
stageSnapshot.status = statusBeforeRelease ?? "completed";
|
|
95458
95832
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
95459
95833
|
};
|
|
@@ -95535,7 +95909,7 @@ function createWorkflowStageFactory(input) {
|
|
|
95535
95909
|
}
|
|
95536
95910
|
runtime.abortListeners.attach();
|
|
95537
95911
|
delete stageSnapshot.wait;
|
|
95538
|
-
if (stageSnapshot.status === "
|
|
95912
|
+
if (stageSnapshot.status === "suspended")
|
|
95539
95913
|
stageSnapshot.status = statusBeforeRelease ?? "running";
|
|
95540
95914
|
statusBeforeRelease = undefined;
|
|
95541
95915
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
@@ -95839,7 +96213,7 @@ function createWorkflowStageFactory(input) {
|
|
|
95839
96213
|
await dropStageControlForCompletion();
|
|
95840
96214
|
if (shownWait !== undefined) {
|
|
95841
96215
|
statusBeforeRelease = "completed";
|
|
95842
|
-
stageSnapshot.status = "
|
|
96216
|
+
stageSnapshot.status = "suspended";
|
|
95843
96217
|
input.activeStore.recordStageStart(input.runId, stageSnapshot);
|
|
95844
96218
|
}
|
|
95845
96219
|
return recorded;
|
|
@@ -96244,7 +96618,7 @@ import {
|
|
|
96244
96618
|
formatWorktreeRestoreWarning,
|
|
96245
96619
|
resolveWorktreeSnapshotSettings as resolveWorktreeSnapshotSettings2,
|
|
96246
96620
|
scheduleSnapshotCollection,
|
|
96247
|
-
|
|
96621
|
+
setUpResumedRunWorktrees,
|
|
96248
96622
|
withWorktreeRootMappings as withWorktreeRootMappings3
|
|
96249
96623
|
} from "@bastani/atomic";
|
|
96250
96624
|
async function run(def, inputs, opts = {}) {
|
|
@@ -96309,15 +96683,27 @@ async function run(def, inputs, opts = {}) {
|
|
|
96309
96683
|
createdAt: Date.now()
|
|
96310
96684
|
})
|
|
96311
96685
|
});
|
|
96312
|
-
if (restored.length > 0) {
|
|
96686
|
+
if (mappings.length > 0 || restored.length > 0) {
|
|
96313
96687
|
const snapshots = new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
|
|
96314
96688
|
boundary.snapshot.id,
|
|
96315
96689
|
boundary.snapshot
|
|
96316
96690
|
]));
|
|
96317
|
-
|
|
96318
|
-
|
|
96319
|
-
|
|
96320
|
-
|
|
96691
|
+
const resumeToken = crypto.randomUUID();
|
|
96692
|
+
let blueprintNoticeCount = 0;
|
|
96693
|
+
await setUpResumedRunWorktrees({ restored, mappings, snapshots }, {
|
|
96694
|
+
signal: opts.signal,
|
|
96695
|
+
onNotices: (notices) => {
|
|
96696
|
+
for (const notice of notices) {
|
|
96697
|
+
activeStore.recordNotice({
|
|
96698
|
+
id: `workflow-blueprint:${runId}:${resumeToken}:${blueprintNoticeCount++}`,
|
|
96699
|
+
runId,
|
|
96700
|
+
level: notice.type,
|
|
96701
|
+
message: notice.message,
|
|
96702
|
+
createdAt: Date.now()
|
|
96703
|
+
});
|
|
96704
|
+
}
|
|
96705
|
+
}
|
|
96706
|
+
});
|
|
96321
96707
|
}
|
|
96322
96708
|
const allMappings = [...mappings, ...restored];
|
|
96323
96709
|
if (restored.length > 0) {
|
|
@@ -97859,12 +98245,12 @@ var init_registry = () => {};
|
|
|
97859
98245
|
|
|
97860
98246
|
// dist/builtin/workflows/src/extension/discovery-loaders.ts
|
|
97861
98247
|
import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
97862
|
-
import { extname, isAbsolute as isAbsolute18, join as
|
|
98248
|
+
import { extname, isAbsolute as isAbsolute18, join as join37, resolve as resolve21 } from "node:path";
|
|
97863
98249
|
async function scanWorkflowDir(dir) {
|
|
97864
98250
|
try {
|
|
97865
98251
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
97866
98252
|
const WORKFLOW_EXTS = new Set([".ts", ".js", ".mjs", ".cjs"]);
|
|
97867
|
-
return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) =>
|
|
98253
|
+
return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) => join37(dir, e.name)).sort();
|
|
97868
98254
|
} catch {
|
|
97869
98255
|
return null;
|
|
97870
98256
|
}
|
|
@@ -97931,16 +98317,16 @@ var init_discovery_loaders = __esm(() => {
|
|
|
97931
98317
|
});
|
|
97932
98318
|
|
|
97933
98319
|
// dist/builtin/workflows/src/extension/discovery.ts
|
|
97934
|
-
import { join as
|
|
97935
|
-
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as
|
|
98320
|
+
import { join as join38 } from "node:path";
|
|
98321
|
+
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as getAgentDir8 } from "@bastani/atomic";
|
|
97936
98322
|
function workflowAgentDirs(options) {
|
|
97937
98323
|
if (options?.agentDirs !== undefined)
|
|
97938
98324
|
return options.agentDirs;
|
|
97939
98325
|
if (options?.homeDir !== undefined) {
|
|
97940
98326
|
const homeDir = options.homeDir;
|
|
97941
|
-
return [
|
|
98327
|
+
return [join38(homeDir, CONFIG_DIR_NAME2, "agent")];
|
|
97942
98328
|
}
|
|
97943
|
-
return [
|
|
98329
|
+
return [getAgentDir8()];
|
|
97944
98330
|
}
|
|
97945
98331
|
function validateConfig(config) {
|
|
97946
98332
|
if (config === null || typeof config !== "object") {
|
|
@@ -98094,7 +98480,7 @@ async function discoverWorkflows(options) {
|
|
|
98094
98480
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98095
98481
|
}
|
|
98096
98482
|
}
|
|
98097
|
-
for (const dir of [
|
|
98483
|
+
for (const dir of [join38(cwd, CONFIG_DIR_NAME2, "workflows")]) {
|
|
98098
98484
|
const candidates = await loadFromDir(dir, "project-local", diagnostics, getWorkflowHostModules);
|
|
98099
98485
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98100
98486
|
}
|
|
@@ -98106,7 +98492,7 @@ async function discoverWorkflows(options) {
|
|
|
98106
98492
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98107
98493
|
}
|
|
98108
98494
|
}
|
|
98109
|
-
for (const dir of agentDirs.map((agentDir) =>
|
|
98495
|
+
for (const dir of agentDirs.map((agentDir) => join38(agentDir, "workflows")).reverse()) {
|
|
98110
98496
|
const candidates = await loadFromDir(dir, "user-global", diagnostics, getWorkflowHostModules);
|
|
98111
98497
|
registry = await applyBatch(candidates, registry, sources, diagnostics);
|
|
98112
98498
|
}
|
|
@@ -98410,10 +98796,10 @@ var init_snapshot_restore = __esm(() => {
|
|
|
98410
98796
|
|
|
98411
98797
|
// dist/builtin/workflows/src/workers/worker-host.ts
|
|
98412
98798
|
import { execFile as execFile2 } from "node:child_process";
|
|
98413
|
-
import { existsSync as
|
|
98414
|
-
import { join as
|
|
98799
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
98800
|
+
import { join as join39 } from "node:path";
|
|
98415
98801
|
import {
|
|
98416
|
-
getAgentDir as
|
|
98802
|
+
getAgentDir as getAgentDir9,
|
|
98417
98803
|
isGitProvisionError as isGitProvisionError4,
|
|
98418
98804
|
resolveGit as resolveGit2,
|
|
98419
98805
|
resolveGitSync as resolveGitSync2,
|
|
@@ -98488,7 +98874,7 @@ function probeGit(git) {
|
|
|
98488
98874
|
async function runnableSources(root) {
|
|
98489
98875
|
const sources = [];
|
|
98490
98876
|
for (const source of root.config.definitions) {
|
|
98491
|
-
if (!
|
|
98877
|
+
if (!existsSync14(source.path))
|
|
98492
98878
|
continue;
|
|
98493
98879
|
const digest = await definitionDigest(source.path);
|
|
98494
98880
|
if (digest === source.digest)
|
|
@@ -98759,17 +99145,21 @@ function hostRestorePort(options, git, shared, journal, agentDir) {
|
|
|
98759
99145
|
const restore = snapshotRestore({
|
|
98760
99146
|
recorded: (binding) => shared.recordedSnapshots(binding),
|
|
98761
99147
|
blobs: journal.snapshotBlobs,
|
|
98762
|
-
storeDir:
|
|
99148
|
+
storeDir: join39(agentDir, "worktree-snapshots"),
|
|
98763
99149
|
git
|
|
98764
99150
|
});
|
|
98765
|
-
return (binding, hook) => restoreRunWorktree(hook.snapshot?.
|
|
99151
|
+
return (binding, hook) => restoreRunWorktree(hook.snapshot?.remotes, () => restore(binding, hook), {
|
|
98766
99152
|
signal: hook.signal,
|
|
98767
|
-
agentDir
|
|
99153
|
+
agentDir,
|
|
99154
|
+
onNotices: (notices) => {
|
|
99155
|
+
for (const notice of notices)
|
|
99156
|
+
console.warn(`atomic-workflows: ${notice.message}`);
|
|
99157
|
+
}
|
|
98768
99158
|
});
|
|
98769
99159
|
}
|
|
98770
99160
|
async function startWorkflowWorkerHost(options) {
|
|
98771
99161
|
validated(options);
|
|
98772
|
-
const agentDir = options.agentDir ??
|
|
99162
|
+
const agentDir = options.agentDir ?? getAgentDir9();
|
|
98773
99163
|
const { selection, git, gitCommand } = await checkHostSetup(options, agentDir);
|
|
98774
99164
|
const journal = await openSelectedRunJournal(selection, agentDir);
|
|
98775
99165
|
try {
|
|
@@ -99247,8 +99637,8 @@ var init_workflows_host_module = __esm(() => {
|
|
|
99247
99637
|
|
|
99248
99638
|
// dist/builtin/workflows/src/workers/pool-journal.ts
|
|
99249
99639
|
import { createHash as createHash7, randomUUID as randomUUID24 } from "node:crypto";
|
|
99250
|
-
import { existsSync as
|
|
99251
|
-
import { basename as basename6, dirname as
|
|
99640
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
|
|
99641
|
+
import { basename as basename6, dirname as dirname22, join as join40, resolve as resolve23 } from "node:path";
|
|
99252
99642
|
import { createChildProcessEnvironment as createChildProcessEnvironment6 } from "@bastani/atomic";
|
|
99253
99643
|
import { storageSelectionKey as storageSelectionKey2 } from "@bastani/atomic/storage";
|
|
99254
99644
|
function poolWorkerEnvironment(durable) {
|
|
@@ -99308,7 +99698,7 @@ function openDurableJournal(durable) {
|
|
|
99308
99698
|
return openSelectedRunJournal(decodeSelection(durable.selection), durable.agentDir);
|
|
99309
99699
|
}
|
|
99310
99700
|
function poolStateDirectory(agentDir) {
|
|
99311
|
-
return
|
|
99701
|
+
return join40(dirname22(agentDir), "workflows", "pool");
|
|
99312
99702
|
}
|
|
99313
99703
|
function databaseIdentity(selection, agentDir) {
|
|
99314
99704
|
return storageSelectionKey2(selection.kind === "adapter" ? { ...selection, secrets: undefined } : selection, agentDir);
|
|
@@ -99316,7 +99706,7 @@ function databaseIdentity(selection, agentDir) {
|
|
|
99316
99706
|
function coordinationPath(durable) {
|
|
99317
99707
|
const selection = decodeSelection(durable.selection);
|
|
99318
99708
|
const identity = createHash7("sha256").update(databaseIdentity(selection, durable.agentDir)).digest("hex");
|
|
99319
|
-
return
|
|
99709
|
+
return join40(poolStateDirectory(durable.agentDir), `${identity.slice(0, 24)}.sqlite`);
|
|
99320
99710
|
}
|
|
99321
99711
|
function coordinationDatabase(durable) {
|
|
99322
99712
|
return basename6(coordinationPath(durable), ".sqlite");
|
|
@@ -99325,7 +99715,7 @@ function openCoordinationJournal(path) {
|
|
|
99325
99715
|
const file = resolve23(path);
|
|
99326
99716
|
let opened = coordinationJournals.get(file);
|
|
99327
99717
|
if (opened === undefined) {
|
|
99328
|
-
mkdirSync10(
|
|
99718
|
+
mkdirSync10(dirname22(file), { recursive: true });
|
|
99329
99719
|
opened = resolveRunJournal({ journal: { path: file } });
|
|
99330
99720
|
coordinationJournals.set(file, opened);
|
|
99331
99721
|
opened.catch(() => {
|
|
@@ -99350,13 +99740,13 @@ function poolJournalForRoot(journal, root) {
|
|
|
99350
99740
|
return sharedRoots.get(journal)?.has(root) === true ? journal : poolJournalFor(journal);
|
|
99351
99741
|
}
|
|
99352
99742
|
function poolHostId(agentDir) {
|
|
99353
|
-
const file =
|
|
99743
|
+
const file = join40(poolStateDirectory(agentDir), "host-id");
|
|
99354
99744
|
try {
|
|
99355
99745
|
const existing = readFileSync9(file, "utf8").trim();
|
|
99356
99746
|
if (existing !== "")
|
|
99357
99747
|
return existing;
|
|
99358
99748
|
} catch {}
|
|
99359
|
-
mkdirSync10(
|
|
99749
|
+
mkdirSync10(dirname22(file), { recursive: true });
|
|
99360
99750
|
const id = randomUUID24();
|
|
99361
99751
|
try {
|
|
99362
99752
|
writeFileSync7(file, `${id}
|
|
@@ -99374,7 +99764,7 @@ async function poolJournalOf(journal) {
|
|
|
99374
99764
|
if (origin === undefined || !isReopenableSelection(origin.selection))
|
|
99375
99765
|
return journal;
|
|
99376
99766
|
const path = coordinationPath(poolDurableJournal(journal));
|
|
99377
|
-
if (!
|
|
99767
|
+
if (!existsSync15(path))
|
|
99378
99768
|
return journal;
|
|
99379
99769
|
const coordination = await openCoordinationJournal(path);
|
|
99380
99770
|
registerPoolJournal(journal, coordination);
|
|
@@ -99410,7 +99800,7 @@ init_store();
|
|
|
99410
99800
|
init_worker_pool_errors();
|
|
99411
99801
|
init_admission_binding();
|
|
99412
99802
|
import { randomUUID as randomUUID26 } from "node:crypto";
|
|
99413
|
-
import { join as
|
|
99803
|
+
import { join as join41 } from "node:path";
|
|
99414
99804
|
import { setTimeout as delay6 } from "node:timers/promises";
|
|
99415
99805
|
import {
|
|
99416
99806
|
applyProviderRateLimitObservation as applyProviderRateLimitObservation2,
|
|
@@ -100895,7 +101285,7 @@ async function runWorker(start) {
|
|
|
100895
101285
|
});
|
|
100896
101286
|
const reader = await JournalDurableBackend.open(readOnlyJournal, { runs: [] });
|
|
100897
101287
|
await reader.retainCheckpoints(start.root, NO_CHECKPOINTS);
|
|
100898
|
-
configurePooledWatchTrace(start.journalPath ??
|
|
101288
|
+
configurePooledWatchTrace(start.journalPath ?? join41(process.cwd(), "shared-pool"), `worker:${process.pid}`);
|
|
100899
101289
|
const commit = poolWorkerCommit({
|
|
100900
101290
|
send: async (mutation) => await request({ kind: "commit", operation: randomUUID26(), mutation }),
|
|
100901
101291
|
catchUp: () => reader.catchUpWorkflow(start.root)
|