@bastani/atomic 0.9.74-alpha.1 → 0.9.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +80 -0
- package/dist/builtin/workflows/README.md +5 -2
- package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
- package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.d.ts +10 -0
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
- package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
- package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/index.js +685 -295
- package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
- package/dist/bun/app-host-modules.d.ts +1 -1
- package/dist/bun/app-host-modules.d.ts.map +1 -1
- package/dist/bun/app-host-modules.js.map +1 -1
- package/dist/bun/internal-workflow-worker.d.ts +2 -0
- package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
- package/dist/bun/internal-workflow-worker.js +2 -1
- package/dist/bun/internal-workflow-worker.js.map +1 -1
- package/dist/codemode-worker.js +2 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
- package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
- package/dist/core/agent-session-blueprint-environment.js +28 -0
- package/dist/core/agent-session-blueprint-environment.js.map +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +14 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +20 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +55 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +2 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +13 -0
- package/dist/core/async-scope.d.ts.map +1 -0
- package/dist/core/async-scope.js +20 -0
- package/dist/core/async-scope.js.map +1 -0
- package/dist/core/cache-warmer.d.ts +3 -14
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +8 -60
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/extensions/extension-work.js +2 -2
- package/dist/core/extensions/extension-work.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +2 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +1 -1
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +4 -2
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +6 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/preferred-providers.d.ts +19 -0
- package/dist/core/preferred-providers.d.ts.map +1 -0
- package/dist/core/preferred-providers.js +25 -0
- package/dist/core/preferred-providers.js.map +1 -0
- package/dist/core/provider-alias.d.ts.map +1 -1
- package/dist/core/provider-alias.js +4 -0
- package/dist/core/provider-alias.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
- package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/action-expressions.js +389 -0
- package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
- package/dist/core/resume/blueprint/actions.d.ts +90 -0
- package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/actions.js +818 -0
- package/dist/core/resume/blueprint/actions.js.map +1 -0
- package/dist/core/resume/blueprint/build.d.ts +102 -0
- package/dist/core/resume/blueprint/build.d.ts.map +1 -0
- package/dist/core/resume/blueprint/build.js +535 -0
- package/dist/core/resume/blueprint/build.js.map +1 -0
- package/dist/core/resume/blueprint/context.d.ts +11 -0
- package/dist/core/resume/blueprint/context.d.ts.map +1 -0
- package/dist/core/resume/blueprint/context.js +106 -0
- package/dist/core/resume/blueprint/context.js.map +1 -0
- package/dist/core/resume/blueprint/envrc.d.ts +19 -0
- package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
- package/dist/core/resume/blueprint/envrc.js +77 -0
- package/dist/core/resume/blueprint/envrc.js.map +1 -0
- package/dist/core/resume/blueprint/errors.d.ts +179 -0
- package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
- package/dist/core/resume/blueprint/errors.js +169 -0
- package/dist/core/resume/blueprint/errors.js.map +1 -0
- package/dist/core/resume/blueprint/ledger.d.ts +51 -0
- package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
- package/dist/core/resume/blueprint/ledger.js +119 -0
- package/dist/core/resume/blueprint/ledger.js.map +1 -0
- package/dist/core/resume/blueprint/notices.d.ts +14 -0
- package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
- package/dist/core/resume/blueprint/notices.js +44 -0
- package/dist/core/resume/blueprint/notices.js.map +1 -0
- package/dist/core/resume/blueprint/process.d.ts +44 -0
- package/dist/core/resume/blueprint/process.d.ts.map +1 -0
- package/dist/core/resume/blueprint/process.js +142 -0
- package/dist/core/resume/blueprint/process.js.map +1 -0
- package/dist/core/resume/blueprint/resume.d.ts +73 -0
- package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
- package/dist/core/resume/blueprint/resume.js +206 -0
- package/dist/core/resume/blueprint/resume.js.map +1 -0
- package/dist/core/resume/blueprint/schema.d.ts +26 -0
- package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
- package/dist/core/resume/blueprint/schema.js +243 -0
- package/dist/core/resume/blueprint/schema.js.map +1 -0
- package/dist/core/resume/blueprint/steps.d.ts +54 -0
- package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
- package/dist/core/resume/blueprint/steps.js +155 -0
- package/dist/core/resume/blueprint/steps.js.map +1 -0
- package/dist/core/resume/blueprint/types.d.ts +63 -0
- package/dist/core/resume/blueprint/types.d.ts.map +1 -0
- package/dist/core/resume/blueprint/types.js +2 -0
- package/dist/core/resume/blueprint/types.js.map +1 -0
- package/dist/core/resume/errors.d.ts +7 -35
- package/dist/core/resume/errors.d.ts.map +1 -1
- package/dist/core/resume/errors.js +1 -21
- package/dist/core/resume/errors.js.map +1 -1
- package/dist/core/resume/index.d.ts +12 -4
- package/dist/core/resume/index.d.ts.map +1 -1
- package/dist/core/resume/index.js +11 -4
- package/dist/core/resume/index.js.map +1 -1
- package/dist/core/resume/run-setup.d.ts +36 -15
- package/dist/core/resume/run-setup.d.ts.map +1 -1
- package/dist/core/resume/run-setup.js +70 -54
- package/dist/core/resume/run-setup.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +34 -20
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +244 -106
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/retry-policy.d.ts +19 -1
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +26 -1
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts +56 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +94 -4
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +10 -5
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +11 -0
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +10 -4
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +2 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +2 -1
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
- package/dist/core/storage/write-ahead-log.js +27 -6
- package/dist/core/storage/write-ahead-log.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/file-tool-errors.d.ts +1 -1
- package/dist/core/tools/file-tool-errors.js +1 -1
- package/dist/core/tools/file-tool-errors.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +52 -26
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +10 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +2 -2
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +12 -4
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +28 -4
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -8
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +6 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +34 -13
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
- package/dist/modes/interactive/components/provider-brand.js +67 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +8 -6
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +59 -21
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +23 -12
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
- package/dist/modes/interactive/login-provider-options.js +2 -1
- package/dist/modes/interactive/login-provider-options.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +2 -18
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
- package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-error-decoding.js +25 -0
- package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +12 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +12 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/codemode.md +22 -0
- package/docs/extensions/api-reference.md +27 -1
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/ui.md +1 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/guides/resume-on-any-machine.md +72 -19
- package/docs/models/evals.md +85 -17
- package/docs/models/reference.md +1 -1
- package/docs/providers.md +38 -5
- package/docs/reference/cli.md +2 -0
- package/docs/rpc/protocol.md +11 -1
- package/docs/sdk/reference.md +36 -4
- package/docs/sdk.md +2 -2
- package/docs/sessions.md +11 -1
- package/docs/settings.md +7 -2
- package/docs/skills.md +3 -3
- package/docs/storage.md +1 -1
- package/docs/tools.md +3 -1
- package/docs/workflows/api-reference.md +14 -12
- package/docs/workflows/authoring.md +29 -1
- package/docs/workflows/builtins.md +9 -1
- package/docs/workflows/operations.md +8 -8
- package/docs/worktree-snapshots.md +3 -2
- package/npm-shrinkwrap.json +83 -67
- package/package.json +7 -7
- package/schemas/settings.schema.json +3 -2
- package/dist/core/resume/setup-hook.d.ts +0 -69
- package/dist/core/resume/setup-hook.d.ts.map +0 -1
- package/dist/core/resume/setup-hook.js +0 -261
- package/dist/core/resume/setup-hook.js.map +0 -1
|
@@ -0,0 +1,818 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { accessSync, constants, statSync, writeSync } from "node:fs";
|
|
3
|
+
import { appendFile, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
|
|
5
|
+
import { parse } from "yaml";
|
|
6
|
+
import { isBunBinary, isBunRuntime } from "../../../config.js";
|
|
7
|
+
import { getPowerShellConfig, getShellConfig } from "../../../utils/shell.js";
|
|
8
|
+
import { isWorkspaceGitError } from "../../workspace/errors.js";
|
|
9
|
+
import { redactUrlCredentials, runGit } from "../../worktree-snapshot/git.js";
|
|
10
|
+
import { closedObject, ExpressionError, evaluateCondition, interpolate, } from "./action-expressions.js";
|
|
11
|
+
import { bashPath, shellQuote } from "./envrc.js";
|
|
12
|
+
import { BlueprintUsesUnsupportedError, } from "./errors.js";
|
|
13
|
+
import { runLoggedProcess } from "./process.js";
|
|
14
|
+
/** The environment variable that replaces `https://github.com` as the place actions are fetched from. */
|
|
15
|
+
export const ACTIONS_GITHUB_BASE_URL_ENV = "ATOMIC_BLUEPRINT_GITHUB_BASE_URL";
|
|
16
|
+
/** A string is not `github.com/<owner>/<repo>[/<subpath>]@<ref>`. */
|
|
17
|
+
export class ActionReferenceError extends Error {
|
|
18
|
+
name = "ActionReferenceError";
|
|
19
|
+
constructor(uses) {
|
|
20
|
+
super(`"${uses.slice(0, 120)}" is not an action reference: expected github.com/<owner>/<repo>[/<subpath>]@<ref>`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const REFERENCE_PREFIX = "github.com/";
|
|
24
|
+
const OWNER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
25
|
+
const REPOSITORY_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
26
|
+
const FORBIDDEN_REF_CHARACTERS = /[\s\p{Cc}~^:?*[\\]/u;
|
|
27
|
+
/**
|
|
28
|
+
* Splits `github.com/<owner>/<repo>[/<subpath>]@<ref>`. The subpath is returned as written: whether it stays inside
|
|
29
|
+
* the repository is checked when the action runs.
|
|
30
|
+
*/
|
|
31
|
+
export function parseActionReference(uses) {
|
|
32
|
+
const at = uses.indexOf("@");
|
|
33
|
+
if (!uses.startsWith(REFERENCE_PREFIX) || at === -1)
|
|
34
|
+
throw new ActionReferenceError(uses);
|
|
35
|
+
const [owner = "", repo = "", ...subpath] = uses.slice(REFERENCE_PREFIX.length, at).split("/");
|
|
36
|
+
const ref = uses.slice(at + 1);
|
|
37
|
+
if (!OWNER_PATTERN.test(owner) ||
|
|
38
|
+
!REPOSITORY_PATTERN.test(repo) ||
|
|
39
|
+
repo === "." ||
|
|
40
|
+
repo === ".." ||
|
|
41
|
+
ref === "" ||
|
|
42
|
+
ref.startsWith("-") ||
|
|
43
|
+
FORBIDDEN_REF_CHARACTERS.test(ref)) {
|
|
44
|
+
throw new ActionReferenceError(uses);
|
|
45
|
+
}
|
|
46
|
+
return { owner, repo, subpath: subpath.join("/"), ref };
|
|
47
|
+
}
|
|
48
|
+
function describeReference({ owner, repo, subpath, ref }) {
|
|
49
|
+
return `${REFERENCE_PREFIX}${owner}/${repo}${subpath === "" ? "" : `/${subpath}`}@${ref}`;
|
|
50
|
+
}
|
|
51
|
+
class MetadataError extends Error {
|
|
52
|
+
}
|
|
53
|
+
function isMap(value) {
|
|
54
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
55
|
+
}
|
|
56
|
+
function optionalText(value, field) {
|
|
57
|
+
if (value === undefined || value === null)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (typeof value === "string")
|
|
60
|
+
return value;
|
|
61
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
62
|
+
return String(value);
|
|
63
|
+
throw new MetadataError(`${field} must be a string`);
|
|
64
|
+
}
|
|
65
|
+
function requiredText(value, field) {
|
|
66
|
+
const text = optionalText(value, field);
|
|
67
|
+
if (text === undefined)
|
|
68
|
+
throw new MetadataError(`${field} is required`);
|
|
69
|
+
return text;
|
|
70
|
+
}
|
|
71
|
+
function textMap(value, field) {
|
|
72
|
+
if (value === undefined || value === null)
|
|
73
|
+
return {};
|
|
74
|
+
if (!isMap(value))
|
|
75
|
+
throw new MetadataError(`${field} must be a mapping`);
|
|
76
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, optionalText(entry, `${field}.${key}`) ?? ""]));
|
|
77
|
+
}
|
|
78
|
+
const METADATA_FILES = ["action.yml", "action.yaml"];
|
|
79
|
+
const NODE_RUNTIMES = new Set(["node12", "node16", "node20", "node24"]);
|
|
80
|
+
function parseInputs(value) {
|
|
81
|
+
if (value === undefined || value === null)
|
|
82
|
+
return [];
|
|
83
|
+
if (!isMap(value))
|
|
84
|
+
throw new MetadataError("inputs must be a mapping");
|
|
85
|
+
return Object.entries(value).map(([name, definition]) => {
|
|
86
|
+
const fields = isMap(definition) ? definition : {};
|
|
87
|
+
const required = fields.required;
|
|
88
|
+
return {
|
|
89
|
+
name,
|
|
90
|
+
defaultValue: optionalText(fields.default, `inputs.${name}.default`),
|
|
91
|
+
required: required === true || (typeof required === "string" && required.toLowerCase() === "true"),
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function parseCompositeAction(step, field) {
|
|
96
|
+
const run = optionalText(step.run, `${field}.run`);
|
|
97
|
+
const uses = optionalText(step.uses, `${field}.uses`);
|
|
98
|
+
if (run !== undefined && uses !== undefined)
|
|
99
|
+
throw new MetadataError(`${field} cannot have both run and uses`);
|
|
100
|
+
if (run !== undefined) {
|
|
101
|
+
const shell = optionalText(step.shell, `${field}.shell`);
|
|
102
|
+
if (shell === undefined)
|
|
103
|
+
throw new MetadataError(`${field} needs a shell for its run`);
|
|
104
|
+
return { kind: "run", run, shell };
|
|
105
|
+
}
|
|
106
|
+
if (uses === undefined)
|
|
107
|
+
throw new MetadataError(`${field} needs run or uses`);
|
|
108
|
+
return { kind: "uses", uses, inputs: textMap(step.with, `${field}.with`) };
|
|
109
|
+
}
|
|
110
|
+
function parseCompositeStep(value, index) {
|
|
111
|
+
const field = `runs.steps[${index}]`;
|
|
112
|
+
if (!isMap(value))
|
|
113
|
+
throw new MetadataError(`${field} must be a mapping`);
|
|
114
|
+
return {
|
|
115
|
+
id: optionalText(value.id, `${field}.id`),
|
|
116
|
+
name: optionalText(value.name, `${field}.name`),
|
|
117
|
+
condition: optionalText(value.if, `${field}.if`),
|
|
118
|
+
env: textMap(value.env, `${field}.env`),
|
|
119
|
+
workingDirectory: optionalText(value["working-directory"], `${field}.working-directory`),
|
|
120
|
+
continueOnError: optionalText(value["continue-on-error"], `${field}.continue-on-error`),
|
|
121
|
+
action: parseCompositeAction(value, field),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function parseOutputs(value) {
|
|
125
|
+
if (value === undefined || value === null)
|
|
126
|
+
return {};
|
|
127
|
+
if (!isMap(value))
|
|
128
|
+
throw new MetadataError("outputs must be a mapping");
|
|
129
|
+
return Object.fromEntries(Object.entries(value).map(([name, definition]) => [
|
|
130
|
+
name,
|
|
131
|
+
isMap(definition) ? (optionalText(definition.value, `outputs.${name}.value`) ?? "") : "",
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
function parseRuns(root) {
|
|
135
|
+
const runs = root.runs;
|
|
136
|
+
if (!isMap(runs))
|
|
137
|
+
throw new MetadataError("runs is required");
|
|
138
|
+
const using = requiredText(runs.using, "runs.using");
|
|
139
|
+
const kind = using.toLowerCase();
|
|
140
|
+
if (kind === "docker")
|
|
141
|
+
return { kind: "docker" };
|
|
142
|
+
if (NODE_RUNTIMES.has(kind)) {
|
|
143
|
+
return {
|
|
144
|
+
kind: "node",
|
|
145
|
+
main: requiredText(runs.main, "runs.main"),
|
|
146
|
+
pre: optionalText(runs.pre, "runs.pre"),
|
|
147
|
+
preCondition: optionalText(runs["pre-if"], "runs.pre-if"),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (kind !== "composite")
|
|
151
|
+
return { kind: "unknown", using };
|
|
152
|
+
if (!Array.isArray(runs.steps))
|
|
153
|
+
throw new MetadataError("runs.steps is required");
|
|
154
|
+
return {
|
|
155
|
+
kind: "composite",
|
|
156
|
+
steps: runs.steps.map(parseCompositeStep),
|
|
157
|
+
outputs: parseOutputs(root.outputs),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function parseMetadata(text) {
|
|
161
|
+
const root = parse(text);
|
|
162
|
+
if (!isMap(root))
|
|
163
|
+
throw new MetadataError("it is not a mapping");
|
|
164
|
+
return { inputs: parseInputs(root.inputs), runs: parseRuns(root) };
|
|
165
|
+
}
|
|
166
|
+
const GITHUB_CONTEXT_STUBS = [
|
|
167
|
+
["repository", "GITHUB_REPOSITORY", "atomic/blueprint"],
|
|
168
|
+
["repository_owner", "GITHUB_REPOSITORY_OWNER", "atomic"],
|
|
169
|
+
["sha", "GITHUB_SHA", "0000000000000000000000000000000000000000"],
|
|
170
|
+
["ref", "GITHUB_REF", "refs/heads/main"],
|
|
171
|
+
["ref_name", "GITHUB_REF_NAME", "main"],
|
|
172
|
+
["ref_type", "GITHUB_REF_TYPE", "branch"],
|
|
173
|
+
["event_name", "GITHUB_EVENT_NAME", "workflow_dispatch"],
|
|
174
|
+
["run_id", "GITHUB_RUN_ID", "1"],
|
|
175
|
+
["run_number", "GITHUB_RUN_NUMBER", "1"],
|
|
176
|
+
["run_attempt", "GITHUB_RUN_ATTEMPT", "1"],
|
|
177
|
+
["actor", "GITHUB_ACTOR", "atomic"],
|
|
178
|
+
["job", "GITHUB_JOB", "blueprint"],
|
|
179
|
+
["workflow", "GITHUB_WORKFLOW", "blueprint"],
|
|
180
|
+
["server_url", "GITHUB_SERVER_URL", "https://github.com"],
|
|
181
|
+
["api_url", "GITHUB_API_URL", "https://api.github.com"],
|
|
182
|
+
["graphql_url", "GITHUB_GRAPHQL_URL", "https://api.github.com/graphql"],
|
|
183
|
+
];
|
|
184
|
+
const RUNNER_OS_NAMES = { linux: "Linux", darwin: "macOS", win32: "Windows" };
|
|
185
|
+
const RUNNER_ARCH_NAMES = { x64: "X64", arm64: "ARM64", ia32: "X86", arm: "ARM" };
|
|
186
|
+
const MAX_NESTING_DEPTH = 10;
|
|
187
|
+
const ENVIRONMENT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
188
|
+
function defined(env) {
|
|
189
|
+
const result = {};
|
|
190
|
+
for (const [name, value] of Object.entries(env))
|
|
191
|
+
if (value !== undefined)
|
|
192
|
+
result[name] = value;
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
function mapValues(values, map) {
|
|
196
|
+
return Object.fromEntries(Object.entries(values).map(([name, value]) => [name, map(value)]));
|
|
197
|
+
}
|
|
198
|
+
function log(context, text) {
|
|
199
|
+
writeSync(context.options.log.fd, `${text}\n`);
|
|
200
|
+
}
|
|
201
|
+
function failure(context, scope, reason, detail, cause) {
|
|
202
|
+
const prefix = scope.depth === 0 ? "" : `${scope.label}: `;
|
|
203
|
+
return new BlueprintUsesUnsupportedError({
|
|
204
|
+
...context.options.location,
|
|
205
|
+
uses: context.options.step.uses,
|
|
206
|
+
reason,
|
|
207
|
+
detail: `${prefix}${detail}`.slice(0, 300),
|
|
208
|
+
logPath: context.options.log.path,
|
|
209
|
+
}, cause);
|
|
210
|
+
}
|
|
211
|
+
function succeeded(exit) {
|
|
212
|
+
return exit.exitStatus === 0 && exit.signal === null && !exit.timedOut && exit.spawnError === undefined;
|
|
213
|
+
}
|
|
214
|
+
function elapsed(context) {
|
|
215
|
+
return Date.now() - context.startedAt;
|
|
216
|
+
}
|
|
217
|
+
function timedOut(context) {
|
|
218
|
+
return { exitStatus: null, signal: null, timedOut: true, elapsedMs: elapsed(context) };
|
|
219
|
+
}
|
|
220
|
+
function unstartable(context, spawnError) {
|
|
221
|
+
return { exitStatus: null, signal: null, timedOut: false, elapsedMs: elapsed(context), spawnError };
|
|
222
|
+
}
|
|
223
|
+
function isInside(root, candidate) {
|
|
224
|
+
const path = relative(root, candidate);
|
|
225
|
+
return path === "" || (path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path));
|
|
226
|
+
}
|
|
227
|
+
function containedPath(root, requested) {
|
|
228
|
+
if (requested.startsWith("/") ||
|
|
229
|
+
requested.startsWith("\\") ||
|
|
230
|
+
isAbsolute(requested) ||
|
|
231
|
+
win32.isAbsolute(requested)) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
const candidate = resolve(root, requested);
|
|
235
|
+
return isInside(root, candidate) ? candidate : undefined;
|
|
236
|
+
}
|
|
237
|
+
/** The environment variable that holds the search path: `PATH`, or on Windows whatever case the environment spells it. */
|
|
238
|
+
export function pathVariableName(env, platform) {
|
|
239
|
+
if (platform !== "win32")
|
|
240
|
+
return "PATH";
|
|
241
|
+
return Object.keys(env).find((name) => name.toLowerCase() === "path") ?? "Path";
|
|
242
|
+
}
|
|
243
|
+
function prependPath(env, directory) {
|
|
244
|
+
const name = pathVariableName(env, process.platform);
|
|
245
|
+
env[name] = env[name] ? `${directory}${delimiter}${env[name]}` : directory;
|
|
246
|
+
}
|
|
247
|
+
/** The errors that mean a search-path entry holds no usable executable of that name: the search moves on. */
|
|
248
|
+
const NOT_A_CANDIDATE_ERRORS = new Set([
|
|
249
|
+
"ENOENT",
|
|
250
|
+
"ENOTDIR",
|
|
251
|
+
"EACCES",
|
|
252
|
+
"EPERM",
|
|
253
|
+
"ELOOP",
|
|
254
|
+
"ENAMETOOLONG",
|
|
255
|
+
]);
|
|
256
|
+
/** The first executable file called `name` in the directories of the search path in `env`. */
|
|
257
|
+
export function findOnPath(name, env, platform) {
|
|
258
|
+
for (const directory of (env[pathVariableName(env, platform)] ?? "").split(delimiter)) {
|
|
259
|
+
if (directory === "")
|
|
260
|
+
continue;
|
|
261
|
+
const candidate = join(directory, name);
|
|
262
|
+
try {
|
|
263
|
+
if (!statSync(candidate).isFile())
|
|
264
|
+
continue;
|
|
265
|
+
accessSync(candidate, constants.X_OK);
|
|
266
|
+
return candidate;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (!NOT_A_CANDIDATE_ERRORS.has(error.code ?? ""))
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The node that runs a Node.js action: the one running Atomic, or, when Bun hosts it and `process.execPath` is Bun, the
|
|
277
|
+
* one on the action's search path.
|
|
278
|
+
*/
|
|
279
|
+
export function nodeExecutableFor(env, hostedByBun, platform) {
|
|
280
|
+
if (!hostedByBun)
|
|
281
|
+
return process.execPath;
|
|
282
|
+
return findOnPath(platform === "win32" ? "node.exe" : "node", env, platform);
|
|
283
|
+
}
|
|
284
|
+
function nodeExecutable(env) {
|
|
285
|
+
return nodeExecutableFor(env, isBunBinary || isBunRuntime, process.platform);
|
|
286
|
+
}
|
|
287
|
+
async function isDirectory(path) {
|
|
288
|
+
try {
|
|
289
|
+
return (await stat(path)).isDirectory();
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
const code = error.code;
|
|
293
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
294
|
+
return false;
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function readTextIfPresent(path) {
|
|
299
|
+
try {
|
|
300
|
+
return await readFile(path, "utf8");
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
const code = error.code;
|
|
304
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
305
|
+
return undefined;
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
class ActionNotFoundError extends Error {
|
|
310
|
+
}
|
|
311
|
+
const GIT_NOT_FOUND = /couldn't find remote ref|not our ref|repository .* not found|does not appear to be a git repository/i;
|
|
312
|
+
const fetchFromGitHub = async ({ owner, repo, ref, destination, signal }) => {
|
|
313
|
+
const base = (process.env[ACTIONS_GITHUB_BASE_URL_ENV] || "https://github.com").replace(/\/+$/, "");
|
|
314
|
+
const options = { cwd: destination, env: { LC_ALL: "C" }, signal };
|
|
315
|
+
try {
|
|
316
|
+
await runGit(["init", "--quiet"], options);
|
|
317
|
+
await runGit(["fetch", "--quiet", "--depth", "1", "--no-tags", "--", `${base}/${owner}/${repo}.git`, ref], {
|
|
318
|
+
...options,
|
|
319
|
+
nonInteractive: true,
|
|
320
|
+
});
|
|
321
|
+
await runGit(["checkout", "--quiet", "--detach", "FETCH_HEAD"], { ...options, neutral: true });
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
if (isWorkspaceGitError(error) && GIT_NOT_FOUND.test(error.detail)) {
|
|
325
|
+
throw new ActionNotFoundError(`${owner}/${repo}@${ref} does not exist`, { cause: error });
|
|
326
|
+
}
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
await rm(join(destination, ".git"), { recursive: true, force: true, maxRetries: 3 });
|
|
330
|
+
};
|
|
331
|
+
function encodeRef(ref) {
|
|
332
|
+
return encodeURIComponent(ref).replace(/^\./, "%2E");
|
|
333
|
+
}
|
|
334
|
+
async function ensureRepository(context, scope, reference, repositoryDirectory) {
|
|
335
|
+
if (await isDirectory(repositoryDirectory)) {
|
|
336
|
+
log(context, `=== Using the cached ${scope.label} ===`);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
log(context, `=== Fetching ${scope.label} ===`);
|
|
340
|
+
const staging = join(dirname(repositoryDirectory), `.fetch-${randomUUID()}`);
|
|
341
|
+
let primary;
|
|
342
|
+
try {
|
|
343
|
+
await mkdir(staging, { recursive: true });
|
|
344
|
+
await context.fetchAction({
|
|
345
|
+
owner: reference.owner,
|
|
346
|
+
repo: reference.repo,
|
|
347
|
+
ref: reference.ref,
|
|
348
|
+
destination: staging,
|
|
349
|
+
signal: context.options.signal,
|
|
350
|
+
});
|
|
351
|
+
try {
|
|
352
|
+
await rename(staging, repositoryDirectory);
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
if (!(await isDirectory(repositoryDirectory)))
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
primary = fetchFailure(context, scope, reference, error);
|
|
361
|
+
}
|
|
362
|
+
const cleanup = await rm(staging, { recursive: true, force: true, maxRetries: 3 }).then(() => undefined, (reason) => reason);
|
|
363
|
+
if (primary !== undefined) {
|
|
364
|
+
if (cleanup !== undefined && primary instanceof Error) {
|
|
365
|
+
Object.defineProperty(primary, "cleanupCause", { value: cleanup, enumerable: false });
|
|
366
|
+
}
|
|
367
|
+
throw primary;
|
|
368
|
+
}
|
|
369
|
+
if (cleanup !== undefined)
|
|
370
|
+
throw cleanup;
|
|
371
|
+
}
|
|
372
|
+
/** The error a failed fetch ends in: the signal's reason when the run was cancelled, else the typed failure. */
|
|
373
|
+
function fetchFailure(context, scope, reference, error) {
|
|
374
|
+
const signal = context.options.signal;
|
|
375
|
+
if (signal?.aborted)
|
|
376
|
+
return signal.reason;
|
|
377
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
378
|
+
log(context, `could not fetch: ${redactUrlCredentials(cause.message)}`);
|
|
379
|
+
if (cause instanceof ActionNotFoundError)
|
|
380
|
+
return failure(context, scope, "action-not-found", cause.message, cause);
|
|
381
|
+
return failure(context, scope, "action-fetch-failed", `could not fetch ${reference.owner}/${reference.repo}@${reference.ref}`, cause);
|
|
382
|
+
}
|
|
383
|
+
async function locateAction(context, scope, reference) {
|
|
384
|
+
const repositoryDirectory = join(context.options.cacheDir, reference.owner, reference.repo, encodeRef(reference.ref));
|
|
385
|
+
const directory = containedPath(repositoryDirectory, reference.subpath);
|
|
386
|
+
if (directory === undefined) {
|
|
387
|
+
throw failure(context, scope, "action-metadata-invalid", "the action path leaves the repository");
|
|
388
|
+
}
|
|
389
|
+
await ensureRepository(context, scope, reference, repositoryDirectory);
|
|
390
|
+
return directory;
|
|
391
|
+
}
|
|
392
|
+
async function readMetadata(context, scope, directory) {
|
|
393
|
+
for (const fileName of METADATA_FILES) {
|
|
394
|
+
let text;
|
|
395
|
+
try {
|
|
396
|
+
text = await readTextIfPresent(join(directory, fileName));
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
throw failure(context, scope, "action-metadata-invalid", `${fileName} cannot be read`, error);
|
|
400
|
+
}
|
|
401
|
+
if (text === undefined)
|
|
402
|
+
continue;
|
|
403
|
+
try {
|
|
404
|
+
return parseMetadata(text);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
const detail = error instanceof MetadataError ? `${fileName}: ${error.message}` : `${fileName} is not valid YAML`;
|
|
408
|
+
throw failure(context, scope, "action-metadata-invalid", detail, error);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
throw failure(context, scope, "action-not-found", "the repository has no action.yml at that path");
|
|
412
|
+
}
|
|
413
|
+
function inputEnvironment(inputs) {
|
|
414
|
+
return Object.fromEntries(Object.entries(inputs).map(([name, value]) => [`INPUT_${name.replaceAll(" ", "_").toUpperCase()}`, value]));
|
|
415
|
+
}
|
|
416
|
+
function actionEnvironment(frame) {
|
|
417
|
+
return {
|
|
418
|
+
GITHUB_ACTION_PATH: frame.directory,
|
|
419
|
+
GITHUB_ACTION_REPOSITORY: `${frame.reference.owner}/${frame.reference.repo}`,
|
|
420
|
+
GITHUB_ACTION_REF: frame.reference.ref,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function expressionContext(context, frame, inputs, steps, failed) {
|
|
424
|
+
const env = { ...context.env, ...frame.env };
|
|
425
|
+
const github = Object.fromEntries(GITHUB_CONTEXT_STUBS.map(([property, variable]) => [property, env[variable] ?? ""]));
|
|
426
|
+
return {
|
|
427
|
+
failed,
|
|
428
|
+
roots: {
|
|
429
|
+
inputs: { ...inputs },
|
|
430
|
+
env,
|
|
431
|
+
steps,
|
|
432
|
+
github: closedObject("github", {
|
|
433
|
+
...github,
|
|
434
|
+
token: "",
|
|
435
|
+
event: {},
|
|
436
|
+
workspace: context.options.cwd,
|
|
437
|
+
action_path: frame.directory,
|
|
438
|
+
action_repository: `${frame.reference.owner}/${frame.reference.repo}`,
|
|
439
|
+
action_ref: frame.reference.ref,
|
|
440
|
+
}),
|
|
441
|
+
runner: closedObject("runner", {
|
|
442
|
+
os: env.RUNNER_OS ?? "",
|
|
443
|
+
arch: env.RUNNER_ARCH ?? "",
|
|
444
|
+
temp: context.runnerTemp,
|
|
445
|
+
tool_cache: context.toolCache,
|
|
446
|
+
}),
|
|
447
|
+
},
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function resolveInputs(context, frame, metadata, given) {
|
|
451
|
+
const declared = new Map(metadata.inputs.map((input) => [input.name.toLowerCase(), input.name]));
|
|
452
|
+
const inputs = {};
|
|
453
|
+
for (const [name, value] of Object.entries(given))
|
|
454
|
+
inputs[declared.get(name.toLowerCase()) ?? name] = value;
|
|
455
|
+
const defaults = expressionContext(context, frame, {}, {}, false);
|
|
456
|
+
for (const input of metadata.inputs) {
|
|
457
|
+
if (Object.hasOwn(inputs, input.name))
|
|
458
|
+
continue;
|
|
459
|
+
if (input.defaultValue !== undefined)
|
|
460
|
+
inputs[input.name] = interpolate(input.defaultValue, defaults);
|
|
461
|
+
else if (input.required)
|
|
462
|
+
throw failure(context, frame, "required-input-missing", `input "${input.name}" is required`);
|
|
463
|
+
else
|
|
464
|
+
inputs[input.name] = "";
|
|
465
|
+
}
|
|
466
|
+
return inputs;
|
|
467
|
+
}
|
|
468
|
+
async function createFileCommands(runnerTemp) {
|
|
469
|
+
const directory = join(runnerTemp, "_runner_file_commands", randomUUID());
|
|
470
|
+
await mkdir(directory, { recursive: true });
|
|
471
|
+
const files = {
|
|
472
|
+
directory,
|
|
473
|
+
env: join(directory, "set_env"),
|
|
474
|
+
path: join(directory, "add_path"),
|
|
475
|
+
output: join(directory, "set_output"),
|
|
476
|
+
state: join(directory, "save_state"),
|
|
477
|
+
summary: join(directory, "step_summary"),
|
|
478
|
+
};
|
|
479
|
+
await Promise.all([files.env, files.path, files.output, files.state, files.summary].map((file) => writeFile(file, "", { mode: 0o600 })));
|
|
480
|
+
return files;
|
|
481
|
+
}
|
|
482
|
+
/** The `name=value` and `name<<DELIMITER` entries of a GITHUB_ENV, GITHUB_OUTPUT or GITHUB_STATE file. */
|
|
483
|
+
function parseFileEntries(text) {
|
|
484
|
+
const lines = text.split("\n").map((line) => (line.endsWith("\r") ? line.slice(0, -1) : line));
|
|
485
|
+
const entries = [];
|
|
486
|
+
let malformed = 0;
|
|
487
|
+
for (let index = 0; index < lines.length; index++) {
|
|
488
|
+
const line = lines[index] ?? "";
|
|
489
|
+
if (line === "")
|
|
490
|
+
continue;
|
|
491
|
+
const equals = line.indexOf("=");
|
|
492
|
+
const heredoc = line.indexOf("<<");
|
|
493
|
+
if (equals > 0 && (heredoc === -1 || equals < heredoc)) {
|
|
494
|
+
entries.push({ name: line.slice(0, equals), value: line.slice(equals + 1) });
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
const terminator = heredoc > 0 ? line.slice(heredoc + 2) : "";
|
|
498
|
+
if (terminator === "") {
|
|
499
|
+
malformed++;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
const closing = lines.indexOf(terminator, index + 1);
|
|
503
|
+
if (closing === -1) {
|
|
504
|
+
malformed++;
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
entries.push({ name: line.slice(0, heredoc), value: lines.slice(index + 1, closing).join("\n") });
|
|
508
|
+
index = closing;
|
|
509
|
+
}
|
|
510
|
+
return { entries, malformed };
|
|
511
|
+
}
|
|
512
|
+
async function applyFileCommands(context, files) {
|
|
513
|
+
const [envText, pathText, outputText, stateText] = await Promise.all([files.env, files.path, files.output, files.state].map(async (file) => (await readTextIfPresent(file)) ?? ""));
|
|
514
|
+
const variables = parseFileEntries(envText);
|
|
515
|
+
const outputs = parseFileEntries(outputText);
|
|
516
|
+
const state = parseFileEntries(stateText);
|
|
517
|
+
let malformed = variables.malformed + outputs.malformed + state.malformed;
|
|
518
|
+
const lines = [];
|
|
519
|
+
for (const { name, value } of variables.entries) {
|
|
520
|
+
if (!ENVIRONMENT_NAME.test(name)) {
|
|
521
|
+
malformed++;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
context.env[name] = value;
|
|
525
|
+
lines.push(`export ${name}=${shellQuote(value)}`);
|
|
526
|
+
}
|
|
527
|
+
for (const line of pathText.split("\n")) {
|
|
528
|
+
const directory = line.trim();
|
|
529
|
+
if (directory === "")
|
|
530
|
+
continue;
|
|
531
|
+
prependPath(context.env, directory);
|
|
532
|
+
lines.push(`export PATH=${shellQuote(bashPath(directory))}:"$PATH"`);
|
|
533
|
+
}
|
|
534
|
+
if (lines.length > 0)
|
|
535
|
+
await appendFile(context.options.envrcPath, `${lines.join("\n")}\n`);
|
|
536
|
+
if (malformed > 0)
|
|
537
|
+
log(context, `ignored ${malformed} malformed entries written to GITHUB_ENV, GITHUB_OUTPUT or GITHUB_STATE`);
|
|
538
|
+
const toRecord = ({ entries }) => Object.fromEntries(entries.map(({ name, value }) => [name, value]));
|
|
539
|
+
return { outputs: toRecord(outputs), state: toRecord(state) };
|
|
540
|
+
}
|
|
541
|
+
async function runProcess(context, request) {
|
|
542
|
+
context.options.signal?.throwIfAborted();
|
|
543
|
+
const remaining = context.deadline - Date.now();
|
|
544
|
+
if (remaining <= 0)
|
|
545
|
+
return { exit: timedOut(context), outputs: {}, state: {} };
|
|
546
|
+
const files = await createFileCommands(context.runnerTemp);
|
|
547
|
+
try {
|
|
548
|
+
log(context, `=== ${request.title} ===\n$ ${request.shown}`);
|
|
549
|
+
const exit = await runLoggedProcess({
|
|
550
|
+
command: request.executable,
|
|
551
|
+
args: request.args,
|
|
552
|
+
cwd: request.cwd,
|
|
553
|
+
env: {
|
|
554
|
+
...context.env,
|
|
555
|
+
...request.env,
|
|
556
|
+
GITHUB_ENV: files.env,
|
|
557
|
+
GITHUB_PATH: files.path,
|
|
558
|
+
GITHUB_OUTPUT: files.output,
|
|
559
|
+
GITHUB_STATE: files.state,
|
|
560
|
+
GITHUB_STEP_SUMMARY: files.summary,
|
|
561
|
+
},
|
|
562
|
+
...(request.stdin === undefined ? {} : { stdin: request.stdin }),
|
|
563
|
+
}, context.options.log, { timeoutMs: remaining, signal: context.options.signal });
|
|
564
|
+
return { exit, ...(await applyFileCommands(context, files)) };
|
|
565
|
+
}
|
|
566
|
+
finally {
|
|
567
|
+
await rm(files.directory, { recursive: true, force: true, maxRetries: 3 });
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
async function runNodeAction(context, frame, runs, inputs) {
|
|
571
|
+
const node = nodeExecutable(context.env);
|
|
572
|
+
if (node === undefined) {
|
|
573
|
+
throw failure(context, frame, "node-unavailable", "no node executable is available to run a Node.js action");
|
|
574
|
+
}
|
|
575
|
+
const scriptPath = (field, script) => {
|
|
576
|
+
const path = containedPath(frame.directory, script);
|
|
577
|
+
if (path === undefined) {
|
|
578
|
+
throw failure(context, frame, "action-metadata-invalid", `runs.${field} leaves the action directory`);
|
|
579
|
+
}
|
|
580
|
+
return path;
|
|
581
|
+
};
|
|
582
|
+
const phases = [{ name: "main", script: runs.main, path: scriptPath("main", runs.main) }];
|
|
583
|
+
if (runs.pre !== undefined) {
|
|
584
|
+
const pre = { name: "pre", script: runs.pre, path: scriptPath("pre", runs.pre) };
|
|
585
|
+
const wanted = runs.preCondition === undefined ||
|
|
586
|
+
evaluateCondition(runs.preCondition, expressionContext(context, frame, inputs, {}, false));
|
|
587
|
+
if (wanted)
|
|
588
|
+
phases.unshift(pre);
|
|
589
|
+
else
|
|
590
|
+
log(context, `=== Skipping pre of ${frame.label}: its pre-if is false ===`);
|
|
591
|
+
}
|
|
592
|
+
let state = {};
|
|
593
|
+
let outputs = {};
|
|
594
|
+
for (const phase of phases) {
|
|
595
|
+
const result = await runProcess(context, {
|
|
596
|
+
title: `${phase.name} of ${frame.label}`,
|
|
597
|
+
shown: `node ${phase.script}`,
|
|
598
|
+
executable: node,
|
|
599
|
+
args: [phase.path],
|
|
600
|
+
cwd: context.options.cwd,
|
|
601
|
+
env: {
|
|
602
|
+
...frame.env,
|
|
603
|
+
...actionEnvironment(frame),
|
|
604
|
+
...inputEnvironment(inputs),
|
|
605
|
+
...Object.fromEntries(Object.entries(state).map(([name, value]) => [`STATE_${name}`, value])),
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
outputs = { ...outputs, ...result.outputs };
|
|
609
|
+
if (!succeeded(result.exit))
|
|
610
|
+
return { exit: result.exit, outputs };
|
|
611
|
+
state = { ...state, ...result.state };
|
|
612
|
+
}
|
|
613
|
+
return { exit: { exitStatus: 0, signal: null, timedOut: false, elapsedMs: elapsed(context) }, outputs };
|
|
614
|
+
}
|
|
615
|
+
/** How `config`'s bash runs `script` as a `bash` or `sh` step: failing at the first failing command, as GitHub does. */
|
|
616
|
+
export function bashInvocation(config, name, script) {
|
|
617
|
+
const strict = name === "bash" && basename(config.shell).toLowerCase().startsWith("bash") ? "-eo pipefail" : "-e";
|
|
618
|
+
const text = `set ${strict}\n${script}`;
|
|
619
|
+
return config.commandTransport === "stdin"
|
|
620
|
+
? { executable: config.shell, args: config.args, stdin: text }
|
|
621
|
+
: { executable: config.shell, args: [...config.args, text] };
|
|
622
|
+
}
|
|
623
|
+
/** How `config`'s PowerShell runs `script` as a `pwsh` or `powershell` step. */
|
|
624
|
+
export function powerShellInvocation(config, script) {
|
|
625
|
+
const text = `$ErrorActionPreference = 'stop'\n${script}\nif ((Test-Path -LiteralPath variable:\\LASTEXITCODE)) { exit $LASTEXITCODE }`;
|
|
626
|
+
return { executable: config.shell, args: [...config.args, text] };
|
|
627
|
+
}
|
|
628
|
+
function shellInvocation(context, frame, shell, script) {
|
|
629
|
+
const name = shell.toLowerCase();
|
|
630
|
+
if (name === "bash" || name === "sh") {
|
|
631
|
+
try {
|
|
632
|
+
return bashInvocation(getShellConfig(), name, script);
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
return error;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (name === "pwsh" || name === "powershell") {
|
|
639
|
+
if (process.platform !== "win32") {
|
|
640
|
+
throw failure(context, frame, "unsupported-expression", "PowerShell steps are only supported on Windows");
|
|
641
|
+
}
|
|
642
|
+
try {
|
|
643
|
+
return powerShellInvocation(getPowerShellConfig(), script);
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
return error;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
throw failure(context, frame, "unsupported-expression", `the shell "${shell.slice(0, 40)}" is not supported`);
|
|
650
|
+
}
|
|
651
|
+
function stepDirectory(context, frame, requested, expressions) {
|
|
652
|
+
if (requested === undefined)
|
|
653
|
+
return context.options.cwd;
|
|
654
|
+
const directory = resolve(context.options.cwd, interpolate(requested, expressions));
|
|
655
|
+
if (!isInside(context.options.cwd, directory) && !isInside(frame.directory, directory)) {
|
|
656
|
+
throw failure(context, frame, "action-metadata-invalid", "working-directory leaves the workspace and the action");
|
|
657
|
+
}
|
|
658
|
+
return directory;
|
|
659
|
+
}
|
|
660
|
+
function nestedReference(context, frame, uses) {
|
|
661
|
+
if (uses.startsWith("docker://"))
|
|
662
|
+
throw failure(context, frame, "docker-action", "Docker actions are not supported");
|
|
663
|
+
if (uses.startsWith(".") || uses.startsWith("/")) {
|
|
664
|
+
throw failure(context, frame, "action-not-found", "local action paths are not supported");
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
return parseActionReference(uses.startsWith(REFERENCE_PREFIX) ? uses : `${REFERENCE_PREFIX}${uses}`);
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
if (error instanceof ActionReferenceError) {
|
|
671
|
+
throw failure(context, frame, "action-not-found", `"${uses.slice(0, 80)}" is not an action reference`, error);
|
|
672
|
+
}
|
|
673
|
+
throw error;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
async function runCompositeAction(context, frame, runs, inputs) {
|
|
677
|
+
const steps = {};
|
|
678
|
+
let failed;
|
|
679
|
+
for (const [index, step] of runs.steps.entries()) {
|
|
680
|
+
context.options.signal?.throwIfAborted();
|
|
681
|
+
const title = `Step ${index + 1} of ${runs.steps.length}: ${step.name ?? step.id ?? step.action.kind} (${frame.label})`;
|
|
682
|
+
const expressions = expressionContext(context, frame, inputs, steps, failed !== undefined);
|
|
683
|
+
if (!evaluateCondition(step.condition ?? "success()", expressions)) {
|
|
684
|
+
log(context, `=== ${title}: skipped ===`);
|
|
685
|
+
if (step.id !== undefined)
|
|
686
|
+
steps[step.id] = closedObject(`steps.${step.id}`, { outputs: {} });
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
const env = { ...frame.env, ...mapValues(step.env, (value) => interpolate(value, expressions)) };
|
|
690
|
+
let outcome;
|
|
691
|
+
if (step.action.kind === "uses") {
|
|
692
|
+
const reference = nestedReference(context, frame, step.action.uses);
|
|
693
|
+
log(context, `=== ${title} ===\nuses ${step.action.uses}`);
|
|
694
|
+
outcome = await executeAction(context, {
|
|
695
|
+
reference,
|
|
696
|
+
inputs: mapValues(step.action.inputs, (value) => interpolate(value, expressions)),
|
|
697
|
+
env,
|
|
698
|
+
depth: frame.depth + 1,
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
const invocation = shellInvocation(context, frame, interpolate(step.action.shell, expressions).trim(), interpolate(step.action.run, expressions));
|
|
703
|
+
const directory = stepDirectory(context, frame, step.workingDirectory, expressions);
|
|
704
|
+
if (invocation instanceof Error) {
|
|
705
|
+
log(context, `=== ${title} ===\ncould not start: ${invocation.message}`);
|
|
706
|
+
outcome = { exit: unstartable(context, invocation), outputs: {} };
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
const result = await runProcess(context, {
|
|
710
|
+
title,
|
|
711
|
+
shown: step.action.run,
|
|
712
|
+
cwd: directory,
|
|
713
|
+
env: { ...env, ...actionEnvironment(frame) },
|
|
714
|
+
...invocation,
|
|
715
|
+
});
|
|
716
|
+
outcome = { exit: result.exit, outputs: result.outputs };
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
if (step.id !== undefined)
|
|
720
|
+
steps[step.id] = closedObject(`steps.${step.id}`, { outputs: { ...outcome.outputs } });
|
|
721
|
+
if (succeeded(outcome.exit))
|
|
722
|
+
continue;
|
|
723
|
+
const tolerated = step.continueOnError !== undefined &&
|
|
724
|
+
!outcome.exit.timedOut &&
|
|
725
|
+
interpolate(step.continueOnError, expressions).trim().toLowerCase() === "true";
|
|
726
|
+
if (tolerated)
|
|
727
|
+
log(context, `=== ${title}: failed, continuing because of continue-on-error ===`);
|
|
728
|
+
else
|
|
729
|
+
failed ??= outcome.exit;
|
|
730
|
+
}
|
|
731
|
+
if (failed !== undefined)
|
|
732
|
+
return { exit: failed, outputs: {} };
|
|
733
|
+
const finished = expressionContext(context, frame, inputs, steps, false);
|
|
734
|
+
return {
|
|
735
|
+
exit: { exitStatus: 0, signal: null, timedOut: false, elapsedMs: elapsed(context) },
|
|
736
|
+
outputs: mapValues(runs.outputs, (value) => interpolate(value, finished)),
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
async function executeAction(context, request) {
|
|
740
|
+
const scope = { label: describeReference(request.reference), depth: request.depth };
|
|
741
|
+
if (request.depth > MAX_NESTING_DEPTH) {
|
|
742
|
+
throw failure(context, scope, "unsupported-expression", `actions are nested more than ${MAX_NESTING_DEPTH} deep`);
|
|
743
|
+
}
|
|
744
|
+
const directory = await locateAction(context, scope, request.reference);
|
|
745
|
+
const metadata = await readMetadata(context, scope, directory);
|
|
746
|
+
const frame = { ...scope, reference: request.reference, directory, env: request.env };
|
|
747
|
+
const { runs } = metadata;
|
|
748
|
+
if (runs.kind === "docker")
|
|
749
|
+
throw failure(context, scope, "docker-action", "Docker actions are not supported");
|
|
750
|
+
if (runs.kind === "unknown") {
|
|
751
|
+
throw failure(context, scope, "unknown-action-type", `runs.using "${runs.using.slice(0, 40)}" is not supported`);
|
|
752
|
+
}
|
|
753
|
+
try {
|
|
754
|
+
const inputs = resolveInputs(context, frame, metadata, request.inputs);
|
|
755
|
+
return runs.kind === "node"
|
|
756
|
+
? await runNodeAction(context, frame, runs, inputs)
|
|
757
|
+
: await runCompositeAction(context, frame, runs, inputs);
|
|
758
|
+
}
|
|
759
|
+
catch (error) {
|
|
760
|
+
if (error instanceof ExpressionError)
|
|
761
|
+
throw failure(context, scope, "unsupported-expression", error.message, error);
|
|
762
|
+
throw error;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
async function createContext(options, startedAt) {
|
|
766
|
+
const runnerTemp = join(options.cacheDir, "_runner", "temp");
|
|
767
|
+
const toolCache = join(options.cacheDir, "_runner", "tool");
|
|
768
|
+
await mkdir(runnerTemp, { recursive: true });
|
|
769
|
+
await mkdir(toolCache, { recursive: true });
|
|
770
|
+
return {
|
|
771
|
+
options,
|
|
772
|
+
startedAt,
|
|
773
|
+
deadline: startedAt + options.timeoutMs,
|
|
774
|
+
runnerTemp,
|
|
775
|
+
toolCache,
|
|
776
|
+
fetchAction: options.fetchAction ?? fetchFromGitHub,
|
|
777
|
+
env: {
|
|
778
|
+
...Object.fromEntries(GITHUB_CONTEXT_STUBS.map(([, variable, stub]) => [variable, stub])),
|
|
779
|
+
...defined(options.env),
|
|
780
|
+
GITHUB_ACTIONS: "true",
|
|
781
|
+
CI: "true",
|
|
782
|
+
GITHUB_WORKSPACE: options.cwd,
|
|
783
|
+
RUNNER_OS: RUNNER_OS_NAMES[process.platform] ?? "Linux",
|
|
784
|
+
RUNNER_ARCH: RUNNER_ARCH_NAMES[process.arch] ?? process.arch.toUpperCase(),
|
|
785
|
+
RUNNER_TEMP: runnerTemp,
|
|
786
|
+
RUNNER_TOOL_CACHE: toolCache,
|
|
787
|
+
AGENT_TOOLSDIRECTORY: toolCache,
|
|
788
|
+
},
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Runs one `uses` step as Devin does: the action is fetched at its ref (cached per owner, repository and ref), and a
|
|
793
|
+
* Node.js action runs its `pre` and `main`, a composite action its steps. Docker actions and `post` are not run.
|
|
794
|
+
* What the action writes to GITHUB_ENV and GITHUB_PATH is applied to its later processes and appended to
|
|
795
|
+
* `options.envrcPath`.
|
|
796
|
+
*
|
|
797
|
+
* Resolves how the first failing process ended (non-zero exit, signal, timeout or no start), else success. Rejects
|
|
798
|
+
* with a {@link BlueprintUsesUnsupportedError} when the action cannot run at all, and with `signal.reason` when
|
|
799
|
+
* `options.signal` aborts.
|
|
800
|
+
*/
|
|
801
|
+
export async function runAction(options) {
|
|
802
|
+
options.signal?.throwIfAborted();
|
|
803
|
+
const startedAt = Date.now();
|
|
804
|
+
const context = await createContext(options, startedAt);
|
|
805
|
+
let reference;
|
|
806
|
+
try {
|
|
807
|
+
reference = parseActionReference(options.step.uses);
|
|
808
|
+
}
|
|
809
|
+
catch (error) {
|
|
810
|
+
if (error instanceof ActionReferenceError) {
|
|
811
|
+
throw failure(context, { label: options.step.uses, depth: 0 }, "action-not-found", error.message, error);
|
|
812
|
+
}
|
|
813
|
+
throw error;
|
|
814
|
+
}
|
|
815
|
+
const { exit } = await executeAction(context, { reference, inputs: options.step.inputs, env: {}, depth: 0 });
|
|
816
|
+
return { ...exit, elapsedMs: Date.now() - startedAt };
|
|
817
|
+
}
|
|
818
|
+
//# sourceMappingURL=actions.js.map
|