minimal-agent 0.12.0 → 0.14.0
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/README.md +6 -5
- package/package.json +62 -5
- package/plugins/computer_use/.claude-plugin/plugin.json +1 -1
- package/plugins/cron-runner/src/commands.js +4 -4
- package/plugins/cron-runner/src/commands.ts +4 -4
- package/plugins/workflow-runner/.claude-plugin/plugin.json +2 -2
- package/plugins/workflow-runner/commands/workflow.md +57 -90
- package/plugins/workflow-runner/commands/workflows.md +4 -4
- package/plugins/workflow-runner/plugin.js +24 -13
- package/plugins/workflow-runner/plugin.ts +28 -13
- package/plugins/workflow-runner/src/discovery.js +160 -0
- package/plugins/workflow-runner/src/discovery.ts +194 -0
- package/plugins/workflow-runner/src/goalAnchor.js +53 -0
- package/plugins/workflow-runner/src/goalAnchor.ts +59 -0
- package/plugins/workflow-runner/src/index.js +204 -185
- package/plugins/workflow-runner/src/index.ts +249 -224
- package/plugins/workflow-runner/src/inputCoercion.js +40 -0
- package/plugins/workflow-runner/src/inputCoercion.ts +43 -0
- package/plugins/workflow-runner/src/journal.js +224 -0
- package/plugins/workflow-runner/src/journal.ts +274 -0
- package/plugins/workflow-runner/src/jsonSchema.js +132 -0
- package/plugins/workflow-runner/src/jsonSchema.ts +162 -0
- package/plugins/workflow-runner/src/moduleResolution.js +64 -0
- package/plugins/workflow-runner/src/moduleResolution.ts +71 -0
- package/plugins/workflow-runner/src/resourceInputs.js +220 -0
- package/plugins/workflow-runner/src/resourceInputs.ts +300 -0
- package/plugins/workflow-runner/src/runner.js +404 -467
- package/plugins/workflow-runner/src/runner.ts +491 -535
- package/plugins/workflow-runner/src/runtime/config.js +46 -0
- package/plugins/workflow-runner/src/runtime/config.ts +69 -0
- package/plugins/workflow-runner/src/runtime/context.js +1304 -0
- package/plugins/workflow-runner/src/runtime/context.ts +1786 -0
- package/plugins/workflow-runner/src/runtime/exec.js +34 -0
- package/plugins/workflow-runner/src/runtime/exec.ts +53 -0
- package/plugins/workflow-runner/src/runtime/flow.js +8 -0
- package/plugins/workflow-runner/src/runtime/flow.ts +12 -0
- package/plugins/workflow-runner/src/runtime/fs.js +27 -0
- package/plugins/workflow-runner/src/runtime/fs.ts +41 -0
- package/plugins/workflow-runner/src/runtime/model.js +6 -0
- package/plugins/workflow-runner/src/runtime/model.ts +8 -0
- package/plugins/workflow-runner/src/runtime/output.js +7 -0
- package/plugins/workflow-runner/src/runtime/output.ts +21 -0
- package/plugins/workflow-runner/src/runtime/scheduler.js +141 -0
- package/plugins/workflow-runner/src/runtime/scheduler.ts +166 -0
- package/plugins/workflow-runner/src/runtime/state.js +16 -0
- package/plugins/workflow-runner/src/runtime/state.ts +19 -0
- package/plugins/workflow-runner/src/runtime/tools.js +3 -0
- package/plugins/workflow-runner/src/runtime/tools.ts +6 -0
- package/plugins/workflow-runner/src/sandbox.js +141 -0
- package/plugins/workflow-runner/src/sandbox.ts +182 -0
- package/plugins/workflow-runner/src/scriptGuard.d.mts +38 -0
- package/plugins/workflow-runner/src/scriptGuard.mjs +449 -0
- package/plugins/workflow-runner/src/taskIdentity.js +172 -152
- package/plugins/workflow-runner/src/taskIdentity.ts +233 -200
- package/plugins/workflow-runner/src/toolRuntime.js +29 -8
- package/plugins/workflow-runner/src/toolRuntime.ts +36 -11
- package/plugins/workflow-runner/src/types.js +7 -105
- package/plugins/workflow-runner/src/types.ts +155 -520
- package/plugins/workflow-runner/src/util.js +47 -0
- package/plugins/workflow-runner/src/util.ts +51 -0
- package/plugins/workflow-runner/src/workflowContext.js +20 -0
- package/plugins/workflow-runner/src/workflowContext.ts +58 -0
- package/plugins/workflow-runner/src/workflowDependencies.js +36 -0
- package/plugins/workflow-runner/src/workflowDependencies.ts +59 -0
- package/plugins/workflow-runner/src/workflowFingerprint.js +118 -0
- package/plugins/workflow-runner/src/workflowFingerprint.ts +122 -0
- package/plugins/workflow-runner/src/workflowState.js +542 -469
- package/plugins/workflow-runner/src/workflowState.ts +639 -589
- package/plugins/workflow-runner/test/api.test.ts +223 -0
- package/plugins/workflow-runner/test/apiCapabilities.test.ts +614 -0
- package/plugins/workflow-runner/test/apiConcurrencyGate.test.ts +104 -0
- package/plugins/workflow-runner/test/apiEcho.test.ts +210 -0
- package/plugins/workflow-runner/test/apiReadText.test.ts +178 -0
- package/plugins/workflow-runner/test/apiResourceLedger.test.ts +184 -0
- package/plugins/workflow-runner/test/childWorkflow.test.ts +304 -0
- package/plugins/workflow-runner/test/discovery.test.ts +234 -0
- package/plugins/workflow-runner/test/goalAnchor.test.ts +106 -0
- package/plugins/workflow-runner/test/goalController.test.ts +317 -0
- package/plugins/workflow-runner/test/journalLanes.test.ts +198 -0
- package/plugins/workflow-runner/test/listResources.test.ts +106 -0
- package/plugins/workflow-runner/test/resourceInputs.test.ts +294 -0
- package/plugins/workflow-runner/test/sandbox.test.ts +126 -0
- package/plugins/workflow-runner/test/scheduler.test.ts +70 -0
- package/plugins/workflow-runner/test/scriptGuard.test.ts +276 -0
- package/plugins/workflow-runner/test/skillDocSync.test.ts +78 -0
- package/plugins/workflow-runner/test/taskIdentity.test.ts +288 -179
- package/plugins/workflow-runner/test/workflowFingerprint.test.ts +106 -0
- package/plugins/workflow-runner/test/workflowState.test.ts +429 -0
- package/skills/pptx/examples/assets/cover-bg.svg +23 -0
- package/skills/pptx/examples/assets/icon-spark.svg +5 -0
- package/skills/skill-creator/scripts/run_eval.py +3 -2
- package/skills/ui-design/SKILL.md +5 -2
- package/skills/ui-design/references/layout-composition.md +1 -1
- package/skills/workflow-creator/SKILL.md +344 -0
- package/skills/workflow-creator/assets/template/workflow.mjs +48 -0
- package/skills/workflow-creator/references/api.md +216 -0
- package/skills/workflow-creator/references/migration.md +103 -0
- package/skills/workflow-creator/references/patterns.md +779 -0
- package/skills/workflow-creator/scripts/list-resources.mjs +205 -0
- package/skills/workflow-creator/scripts/scaffold.mjs +148 -0
- package/skills/workflow-creator/scripts/validate.mjs +275 -0
- package/skills/workflow-creator/scripts/workflow-creator.test.mjs +82 -0
- package/src/advisor/advisorCoordinator.js +503 -0
- package/src/advisor/advisorCoordinator.ts +657 -0
- package/src/cli/configMenu.tsx +0 -1
- package/src/cli/print.js +44 -6
- package/src/cli/print.ts +73 -4
- package/src/cli/streamJson.js +5 -6
- package/src/cli/streamJson.ts +8 -4
- package/src/cli/wizards/advisorWizard.js +4 -2
- package/src/cli/wizards/advisorWizard.tsx +8 -2
- package/src/cli/wizards/contextAdvisorWizard.js +5 -4
- package/src/cli/wizards/contextAdvisorWizard.tsx +7 -6
- package/src/collaboration/taskFlow.js +115 -0
- package/src/collaboration/taskFlow.ts +169 -0
- package/src/config/configDefaults.js +41 -1
- package/src/config/configDefaults.ts +43 -1
- package/src/config/configDiagnostics.ts +2 -2
- package/src/config/configFile.js +40 -9
- package/src/config/configFile.ts +60 -11
- package/src/config/configService.js +443 -74
- package/src/config/configService.ts +723 -142
- package/src/config/numericLimits.js +22 -0
- package/src/config/numericLimits.ts +24 -0
- package/src/config.js +1 -0
- package/src/config.ts +3 -2
- package/src/context/budgetPlan.js +1 -1
- package/src/context/budgetPlan.ts +1 -1
- package/src/context/compact.js +7 -2
- package/src/context/compact.ts +9 -2
- package/src/context/microCompactLite.js +212 -13
- package/src/context/microCompactLite.ts +261 -12
- package/src/context/sessionRegistry.js +8 -1
- package/src/context/sessionRegistry.ts +18 -5
- package/src/context/toolResultArchive.js +72 -0
- package/src/context/toolResultArchive.ts +95 -0
- package/src/goal/errors.js +8 -0
- package/src/goal/errors.ts +18 -0
- package/src/goal/goalRuntime.js +344 -0
- package/src/goal/goalRuntime.ts +466 -0
- package/src/goal/goalStore.js +200 -0
- package/src/goal/goalStore.ts +219 -0
- package/src/goal/index.js +4 -0
- package/src/goal/index.ts +4 -0
- package/src/goal/statusMapping.js +71 -0
- package/src/goal/statusMapping.ts +95 -0
- package/src/goal/types.js +7 -0
- package/src/goal/types.ts +179 -0
- package/src/goal/workflowController.js +306 -0
- package/src/goal/workflowController.ts +360 -0
- package/src/harness/evidenceLedger.js +2 -0
- package/src/harness/evidenceLedger.ts +1 -0
- package/src/harness/stallGuard.js +9 -3
- package/src/harness/stallGuard.ts +7 -3
- package/src/images/imageResolver.js +161 -0
- package/src/images/imageResolver.ts +189 -0
- package/src/infra/verification.js +56 -20
- package/src/infra/verification.ts +87 -20
- package/src/llm/client.js +79 -21
- package/src/llm/client.ts +182 -35
- package/src/llm/gatewayClient.js +201 -0
- package/src/llm/gatewayClient.ts +299 -0
- package/src/llm/messageProvenance.js +46 -0
- package/src/llm/messageProvenance.ts +58 -0
- package/src/llm/modelProvider.js +1 -0
- package/src/llm/modelProvider.ts +22 -0
- package/src/llm/providers/anthropicFormat.js +108 -1
- package/src/llm/providers/anthropicFormat.ts +115 -4
- package/src/llm/providers/openaiFormat.js +9 -0
- package/src/llm/providers/openaiFormat.ts +12 -3
- package/src/loop.js +319 -54
- package/src/loop.ts +373 -57
- package/src/main.js +4 -1
- package/src/main.tsx +4 -1
- package/src/managedExecution/index.js +2 -0
- package/src/managedExecution/index.ts +2 -0
- package/src/managedExecution/registry.js +15 -0
- package/src/managedExecution/registry.ts +20 -0
- package/src/managedExecution/types.js +1 -0
- package/src/managedExecution/types.ts +86 -0
- package/src/modelRef.js +9 -0
- package/src/modelRef.ts +31 -0
- package/src/multimodal.js +14 -28
- package/src/multimodal.ts +17 -33
- package/src/net/lanDiscovery.js +65 -0
- package/src/net/lanDiscovery.ts +82 -0
- package/src/plugin-sdk.js +28 -3
- package/src/plugin-sdk.ts +39 -6
- package/src/plugins/pluginApi.ts +16 -1
- package/src/plugins/pluginLoader.js +4 -0
- package/src/plugins/pluginLoader.ts +6 -0
- package/src/plugins/pluginRunner.js +152 -9
- package/src/plugins/pluginRunner.ts +186 -8
- package/src/plugins/slashFallback.js +113 -0
- package/src/plugins/slashFallback.ts +137 -0
- package/src/prompts/policyRegistry.js +15 -8
- package/src/prompts/policyRegistry.ts +18 -8
- package/src/prompts/promptAssembly.js +103 -12
- package/src/prompts/promptAssembly.ts +114 -12
- package/src/prompts/skillList.js +21 -3
- package/src/prompts/skillList.ts +27 -2
- package/src/prompts/stableSystemPrompt.js +18 -0
- package/src/prompts/stableSystemPrompt.ts +33 -0
- package/src/runtime/agentRuntimeContext.js +8 -2
- package/src/runtime/agentRuntimeContext.ts +17 -4
- package/src/session/runAgentTurn.js +78 -12
- package/src/session/runAgentTurn.ts +105 -23
- package/src/session/runTurn.js +10 -9
- package/src/session/runTurn.ts +17 -8
- package/src/session/sessionState.ts +2 -0
- package/src/team/auth.js +186 -0
- package/src/team/auth.ts +298 -0
- package/src/team/cli.js +105 -0
- package/src/team/cli.ts +122 -0
- package/src/team/onlineToolContract.js +64 -0
- package/src/team/onlineToolContract.ts +109 -0
- package/src/team/toolPolicy.js +36 -0
- package/src/team/toolPolicy.ts +75 -0
- package/src/tools/advisor/advisor.js +148 -37
- package/src/tools/advisor/advisor.ts +161 -38
- package/src/tools/advisor/advisorDecision.js +71 -0
- package/src/tools/advisor/advisorDecision.ts +85 -0
- package/src/tools/agent/agent.js +18 -5
- package/src/tools/agent/agent.ts +21 -7
- package/src/tools/agent/agentControl.js +246 -0
- package/src/tools/agent/agentControl.ts +284 -0
- package/src/tools/agent/agentTaskService.js +40 -1
- package/src/tools/agent/agentTaskService.ts +44 -1
- package/src/tools/agent/agentTypes.js +14 -2
- package/src/tools/agent/agentTypes.ts +15 -2
- package/src/tools/applypatch/applyPatch.js +362 -0
- package/src/tools/applypatch/applyPatch.ts +428 -0
- package/src/tools/bash/bash.js +70 -18
- package/src/tools/bash/bash.ts +75 -20
- package/src/tools/capabilities.js +10 -5
- package/src/tools/capabilities.ts +10 -5
- package/src/tools/computeruse/computerIntent.js +32 -0
- package/src/tools/computeruse/computerIntent.ts +46 -0
- package/src/tools/computeruse/telemetryLog.js +12 -0
- package/src/tools/computeruse/telemetryLog.ts +16 -0
- package/src/tools/computeruse/vision/telemetry.js +1 -0
- package/src/tools/computeruse/vision/telemetry.ts +1 -0
- package/src/tools/effectiveToolSet.js +4 -0
- package/src/tools/effectiveToolSet.ts +4 -0
- package/src/tools/index.js +21 -2
- package/src/tools/index.ts +33 -2
- package/src/tools/powershell/powershell.js +18 -1
- package/src/tools/powershell/powershell.ts +18 -2
- package/src/tools/presentresult/presentresult.js +6 -15
- package/src/tools/presentresult/presentresult.ts +6 -15
- package/src/tools/read/read.js +69 -11
- package/src/tools/read/read.ts +70 -11
- package/src/tools/shared/fileUtils.js +1 -2
- package/src/tools/shared/fileUtils.ts +1 -2
- package/src/tools/shared/permanentDeleteGuard.js +34 -3
- package/src/tools/shared/permanentDeleteGuard.ts +43 -6
- package/src/tools/shared/toolOutputStore.js +23 -1
- package/src/tools/shared/toolOutputStore.ts +22 -1
- package/src/tools/skill/skill.js +9 -3
- package/src/tools/skill/skill.ts +8 -4
- package/src/tools/toolPromptGuides.js +117 -0
- package/src/tools/toolPromptGuides.ts +137 -0
- package/src/tools/webbrowser/agentBrowserPath.js +19 -9
- package/src/tools/webbrowser/agentBrowserPath.ts +70 -28
- package/src/tools/webbrowser/browser.js +27 -11
- package/src/tools/webbrowser/browser.ts +68 -24
- package/src/tools/webbrowser/browserAutomation.js +329 -0
- package/src/tools/webbrowser/browserAutomation.ts +467 -0
- package/src/tools/webbrowser/browserAxState.js +97 -0
- package/src/tools/webbrowser/browserAxState.ts +142 -0
- package/src/tools/webbrowser/browserBatch.js +1578 -0
- package/src/tools/webbrowser/browserBatch.ts +2382 -0
- package/src/tools/webbrowser/browserCdp.js +208 -0
- package/src/tools/webbrowser/browserCdp.ts +255 -0
- package/src/tools/webbrowser/browserConditions.js +24 -0
- package/src/tools/webbrowser/browserConditions.ts +45 -0
- package/src/tools/webbrowser/browserContent.js +281 -0
- package/src/tools/webbrowser/browserContent.ts +438 -0
- package/src/tools/webbrowser/browserControl.js +131 -30
- package/src/tools/webbrowser/browserControl.ts +210 -50
- package/src/tools/webbrowser/browserDaemon.js +22 -14
- package/src/tools/webbrowser/browserDaemon.ts +54 -21
- package/src/tools/webbrowser/browserFrames.js +47 -0
- package/src/tools/webbrowser/browserFrames.ts +54 -0
- package/src/tools/webbrowser/browserInteractionResolver.js +17 -0
- package/src/tools/webbrowser/browserInteractionResolver.ts +40 -0
- package/src/tools/webbrowser/browserLocator.js +140 -0
- package/src/tools/webbrowser/browserLocator.ts +194 -0
- package/src/tools/webbrowser/browserOutcome.js +10 -17
- package/src/tools/webbrowser/browserOutcome.ts +48 -31
- package/src/tools/webbrowser/browserRecovery.js +58 -0
- package/src/tools/webbrowser/browserRecovery.ts +83 -0
- package/src/tools/webbrowser/browserRunRegistry.js +35 -3
- package/src/tools/webbrowser/browserRunRegistry.ts +91 -15
- package/src/tools/webbrowser/browserService.js +28 -2
- package/src/tools/webbrowser/browserService.ts +49 -9
- package/src/tools/webbrowser/browserStream.js +132 -33
- package/src/tools/webbrowser/browserStream.ts +224 -50
- package/src/tools/webbrowser/browserTabs.js +48 -15
- package/src/tools/webbrowser/browserTabs.ts +178 -96
- package/src/tools/webbrowser/webbrowser.js +683 -144
- package/src/tools/webbrowser/webbrowser.ts +979 -236
- package/src/tools/webfetch/preapproved.js +0 -2
- package/src/tools/webfetch/preapproved.ts +0 -2
- package/src/tools/websearch/websearch.js +129 -8
- package/src/tools/websearch/websearch.ts +138 -6
- package/src/types.ts +450 -42
- package/src/ui/App.js +377 -58
- package/src/ui/App.tsx +576 -111
- package/src/ui/LiveArea.js +14 -8
- package/src/ui/LiveArea.tsx +14 -10
- package/src/ui/MessageList.js +63 -20
- package/src/ui/MessageList.tsx +101 -16
- package/src/ui/ModelPicker.js +7 -4
- package/src/ui/ModelPicker.tsx +55 -8
- package/src/ui/hooks/useChat.js +152 -163
- package/src/ui/hooks/useChat.ts +396 -334
- package/src/ui/loginCommand.js +56 -0
- package/src/ui/loginCommand.ts +63 -0
- package/src/ui/toolProgress.js +41 -0
- package/src/ui/toolProgress.ts +44 -0
- package/src/web/browserBridge.js +20 -2
- package/src/web/browserBridge.ts +20 -2
- package/src/web/protocol.ts +1897 -194
- package/workflows/adaptive-research/workflow.mjs +86 -0
- package/workflows/e2e-capabilities/workflow.mjs +102 -0
- package/workflows/e2e-llm/workflow.mjs +52 -0
- package/workflows/e2e-smoke/workflow.mjs +59 -0
- package/workflows/e2e-vision-schema/README.md +48 -0
- package/workflows/e2e-vision-schema/workflow.mjs +149 -0
- package/workflows/e2e-write-greet/workflow.mjs +37 -0
- package/workflows/file-census/README.md +14 -0
- package/workflows/file-census/scripts/.gitkeep +2 -0
- package/workflows/file-census/workflow.mjs +110 -0
- package/workflows/goal/README.md +166 -0
- package/workflows/goal/prompts/audit.md +57 -0
- package/workflows/goal/prompts/contract.md +56 -0
- package/workflows/goal/prompts/iterate.md +37 -0
- package/workflows/goal/workflow.mjs +501 -0
- package/workflows/illustrate/README.md +90 -0
- package/workflows/illustrate/assets/engines.json +20 -0
- package/workflows/illustrate/assets/extract-baidu.js +21 -0
- package/workflows/illustrate/assets/extract-bing.js +33 -0
- package/workflows/illustrate/assets/extract-google.js +31 -0
- package/workflows/illustrate/workflow.mjs +301 -0
- package/workflows/plan/workflow.mjs +389 -0
- package/workflows/question-crops/README.md +35 -0
- package/workflows/question-crops/prompts/inventory.md +23 -0
- package/workflows/question-crops/scripts/image-ops.mjs +305 -0
- package/workflows/question-crops/scripts/image-ops.test.mjs +95 -0
- package/workflows/question-crops/workflow.mjs +172 -0
- package/workflows/ralph-loop/workflow.mjs +162 -0
- package/workflows/research/DESIGN.md +449 -0
- package/workflows/research/README.md +74 -0
- package/workflows/research/prompts/s0-goal.md +43 -0
- package/workflows/research/prompts/s1-early-exit.md +22 -0
- package/workflows/research/prompts/s1-map.md +58 -0
- package/workflows/research/prompts/s2-options.md +53 -0
- package/workflows/research/prompts/s3-deep-dive.md +56 -0
- package/workflows/research/prompts/s4-verify.md +74 -0
- package/workflows/research/prompts/s5-synthesis.md +81 -0
- package/workflows/research/prompts/s5b-fill-gaps.md +32 -0
- package/workflows/research/prompts/s6-package.md +32 -0
- package/workflows/research/scripts/build-report.mjs +98 -0
- package/workflows/research/workflow.mjs +288 -0
- package/workflows/wechat-reading-shots/prompts/collect-params.md +16 -0
- package/workflows/wechat-reading-shots/prompts/evaluate.md +20 -0
- package/workflows/wechat-reading-shots/prompts/open-book.md +28 -0
- package/workflows/wechat-reading-shots/prompts/read-page.md +13 -0
- package/workflows/wechat-reading-shots/prompts/turn-batch.md +24 -0
- package/workflows/wechat-reading-shots/test/control-flow.test.ts +329 -0
- package/workflows/wechat-reading-shots/workflow.mjs +266 -0
- package/workflows/wrong-question-docx/README.md +55 -0
- package/workflows/wrong-question-docx/prompts/figure-qa.md +8 -0
- package/workflows/wrong-question-docx/prompts/transcribe.md +25 -0
- package/workflows/wrong-question-docx/scripts/workbook.mjs +857 -0
- package/workflows/wrong-question-docx/test/control-flow.test.ts +165 -0
- package/workflows/wrong-question-docx/test/workbook.test.mjs +303 -0
- package/workflows/wrong-question-docx/workflow.mjs +485 -0
- package/plugins/workflow-runner/src/agentCommon.js +0 -354
- package/plugins/workflow-runner/src/agentCommon.ts +0 -435
- package/plugins/workflow-runner/src/controlFlow/branch.js +0 -40
- package/plugins/workflow-runner/src/controlFlow/branch.ts +0 -46
- package/plugins/workflow-runner/src/controlFlow/loop.js +0 -211
- package/plugins/workflow-runner/src/controlFlow/loop.ts +0 -248
- package/plugins/workflow-runner/src/controlFlow/pause.js +0 -129
- package/plugins/workflow-runner/src/controlFlow/pause.ts +0 -141
- package/plugins/workflow-runner/src/controlFlow/signal.js +0 -21
- package/plugins/workflow-runner/src/controlFlow/signal.ts +0 -29
- package/plugins/workflow-runner/src/controlFlow/types.js +0 -18
- package/plugins/workflow-runner/src/controlFlow/types.ts +0 -63
- package/plugins/workflow-runner/src/dslManifest.js +0 -72
- package/plugins/workflow-runner/src/dslManifest.ts +0 -127
- package/plugins/workflow-runner/src/expressions.js +0 -618
- package/plugins/workflow-runner/src/expressions.ts +0 -622
- package/plugins/workflow-runner/src/loader.js +0 -573
- package/plugins/workflow-runner/src/loader.ts +0 -721
- package/plugins/workflow-runner/src/multimodal.js +0 -38
- package/plugins/workflow-runner/src/multimodal.ts +0 -64
- package/plugins/workflow-runner/src/recovery.js +0 -119
- package/plugins/workflow-runner/src/recovery.ts +0 -149
- package/plugins/workflow-runner/src/stepExecutors/agent.js +0 -173
- package/plugins/workflow-runner/src/stepExecutors/agent.ts +0 -234
- package/plugins/workflow-runner/src/stepExecutors/assert.js +0 -41
- package/plugins/workflow-runner/src/stepExecutors/assert.ts +0 -50
- package/plugins/workflow-runner/src/stepExecutors/echo.js +0 -31
- package/plugins/workflow-runner/src/stepExecutors/echo.ts +0 -38
- package/plugins/workflow-runner/src/stepExecutors/llm.js +0 -99
- package/plugins/workflow-runner/src/stepExecutors/llm.ts +0 -133
- package/plugins/workflow-runner/src/stepExecutors/set.js +0 -49
- package/plugins/workflow-runner/src/stepExecutors/set.ts +0 -56
- package/plugins/workflow-runner/src/stepExecutors/skill.js +0 -111
- package/plugins/workflow-runner/src/stepExecutors/skill.ts +0 -140
- package/plugins/workflow-runner/src/stepExecutors/tool.js +0 -208
- package/plugins/workflow-runner/src/stepExecutors/tool.ts +0 -256
- package/plugins/workflow-runner/src/stepExecutors/verify.js +0 -58
- package/plugins/workflow-runner/src/stepExecutors/verify.ts +0 -68
- package/plugins/workflow-runner/src/stepPipeline.js +0 -277
- package/plugins/workflow-runner/src/stepPipeline.ts +0 -366
- package/plugins/workflow-runner/test/agent.test.ts +0 -587
- package/plugins/workflow-runner/test/agentLlmError.test.ts +0 -373
- package/plugins/workflow-runner/test/bashBlacklist.sweep.test.ts +0 -65
- package/plugins/workflow-runner/test/captureMisbind.test.ts +0 -99
- package/plugins/workflow-runner/test/cli.e2e.test.ts +0 -147
- package/plugins/workflow-runner/test/context-files.test.ts +0 -320
- package/plugins/workflow-runner/test/e2e.test.ts +0 -370
- package/plugins/workflow-runner/test/engineRobustness.test.ts +0 -226
- package/plugins/workflow-runner/test/expressions.test.ts +0 -397
- package/plugins/workflow-runner/test/foundation.test.ts +0 -126
- package/plugins/workflow-runner/test/graceful.test.ts +0 -139
- package/plugins/workflow-runner/test/greedyInputs.load.test.ts +0 -47
- package/plugins/workflow-runner/test/hostCapability.test.ts +0 -108
- package/plugins/workflow-runner/test/illustrate.load.test.ts +0 -183
- package/plugins/workflow-runner/test/jsonPayload.test.ts +0 -83
- package/plugins/workflow-runner/test/loader.test.ts +0 -617
- package/plugins/workflow-runner/test/maxTurnsRetryDelay.test.ts +0 -33
- package/plugins/workflow-runner/test/multimodal.test.ts +0 -342
- package/plugins/workflow-runner/test/output-schema.test.ts +0 -213
- package/plugins/workflow-runner/test/parseWorkflowArgs.test.ts +0 -87
- package/plugins/workflow-runner/test/pluginRunner.isolation.test.ts +0 -269
- package/plugins/workflow-runner/test/ppt.load.test.ts +0 -1220
- package/plugins/workflow-runner/test/ralphLoop.e2e.test.ts +0 -220
- package/plugins/workflow-runner/test/recovery.test.ts +0 -265
- package/plugins/workflow-runner/test/runner.test.ts +0 -911
- package/plugins/workflow-runner/test/runnerPreflight.test.ts +0 -379
- package/plugins/workflow-runner/test/skillTurnDone.test.ts +0 -71
- package/plugins/workflow-runner/test/stateLifecycle.test.ts +0 -150
- package/plugins/workflow-runner/test/stepPipeline.test.ts +0 -114
- package/plugins/workflow-runner/test/taskArbitration.test.ts +0 -338
- package/plugins/workflow-runner/test/taskLifecycle.test.ts +0 -270
- package/plugins/workflow-runner/test/toolArtifactOverwrite.test.ts +0 -221
- package/plugins/workflow-runner/test/toolCapabilityBoundary.test.ts +0 -29
- package/plugins/workflow-runner/test/toolRuntimeIntegration.test.ts +0 -168
- package/plugins/workflow-runner/test/webppt.load.test.ts +0 -250
- package/plugins/workflow-runner/test/word.load.test.ts +0 -208
- package/plugins/workflow-runner/test/workflows.smoke.test.ts +0 -76
- package/plugins/workflow-runner/test/yamlGuardConditions.test.ts +0 -207
- package/src/advisorState.js +0 -22
- package/src/cli/configWizard.js +0 -293
- package/src/tools/toolProgressBridge.js +0 -48
- package/workflows/adaptive-research.yaml +0 -50
- package/workflows/book-review-short.yaml +0 -125
- package/workflows/e2e-write-greet.yaml +0 -31
- package/workflows/illustrate.yaml +0 -227
- package/workflows/plan.yaml +0 -470
- package/workflows/ppt.yaml +0 -1670
- package/workflows/ralph-loop.yaml +0 -199
- package/workflows/schema.json +0 -176
- package/workflows/webppt.yaml +0 -496
- package/workflows/wechat-reading-shots.yaml +0 -315
- package/workflows/word.yaml +0 -720
- package/workflows/youtube-shorts.yaml +0 -202
|
@@ -1,513 +1,229 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ============================================================
|
|
3
|
-
* plugins/workflow-runner/src/types.ts ——
|
|
3
|
+
* plugins/workflow-runner/src/types.ts —— 代码编排引擎的核心类型
|
|
4
4
|
* ------------------------------------------------------------
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* RunContext)和 UI 事件(WorkflowEvent)。
|
|
5
|
+
* V2 只定义 ESM 元数据、宿主上下文和运行时边界;业务控制流由 JavaScript 本身
|
|
6
|
+
* 表达,Runner 不维护具体步骤类型。
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* src/types.ts 的 LoopEvent union **不**包含 workflow_*,框架零插件耦合。
|
|
8
|
+
* ⚠️ 这里**没有** name 字段:工作流名恒等于目录名(`workflows/<name>/`)。
|
|
9
|
+
* legacy 时代 yaml 里的 `name:` 与文件名是两处真值,实测漂移过(workflow-evolve
|
|
10
|
+
* 的配置里专门写了「`name` 取 yaml 头部字段,不是文件名」这条注意事项)。
|
|
13
11
|
* ============================================================
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
14
|
import type {
|
|
17
|
-
|
|
15
|
+
ManagedExecutionBridge,
|
|
16
|
+
ManagedExecutionContext,
|
|
17
|
+
} from '../../../src/managedExecution/types.js';
|
|
18
|
+
import type {
|
|
19
|
+
AgentRuntimeContext,
|
|
20
|
+
ContextBundle,
|
|
21
|
+
InvocationResource,
|
|
22
|
+
LlmStreamEvent,
|
|
18
23
|
Message,
|
|
19
24
|
PluginContext,
|
|
25
|
+
PromptCacheContext,
|
|
20
26
|
Provider,
|
|
21
27
|
SessionState,
|
|
22
28
|
Tool,
|
|
23
29
|
ToolCallContext,
|
|
24
30
|
} from '../../../src/plugin-sdk.js';
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export type InputType = 'string' | 'number' | 'enum';
|
|
29
|
-
|
|
32
|
+
/** 一个声明的输入参数。形状沿用 legacy,CLI 位置参数映射语义必须保持一致。 */
|
|
30
33
|
export interface InputDef {
|
|
31
34
|
name: string;
|
|
32
|
-
|
|
35
|
+
description?: string;
|
|
33
36
|
required?: boolean;
|
|
34
37
|
default?: unknown;
|
|
35
|
-
|
|
38
|
+
type?: 'string' | 'number' | 'enum' | 'resource';
|
|
39
|
+
/** MIME globs/extensions accepted by a resource input. */
|
|
40
|
+
accepts?: string[];
|
|
41
|
+
/** Resource input may receive files/directories and multiple attachments. */
|
|
42
|
+
allowFile?: boolean;
|
|
43
|
+
allowDirectory?: boolean;
|
|
44
|
+
multiple?: boolean;
|
|
45
|
+
/** Bind compatible current-turn attachments when no explicit path is given. */
|
|
46
|
+
attachmentFallback?: boolean;
|
|
47
|
+
maxItems?: number;
|
|
48
|
+
/** Task identity basis for resources: stable reference id or content hash. */
|
|
49
|
+
identity?: 'reference' | 'content';
|
|
50
|
+
/** Present attached/explicit files to the workflow as a staged directory. */
|
|
51
|
+
materialize?: 'auto' | 'directory';
|
|
52
|
+
/** type === 'enum' 时的合法取值。 */
|
|
36
53
|
values?: string[];
|
|
37
|
-
description?: string;
|
|
38
54
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
55
|
+
* 贪婪首参:名后**全部**位置参数空格 join 进它,不逐位拆映射。
|
|
56
|
+
*
|
|
57
|
+
* 只许标在第 0 位。存在理由是真实事故:ppt 的 `topic` 不贪婪时,用户打一句
|
|
58
|
+
* 自然语言会被空格拆碎,第二段位置参数撞上 number 类型的 `pages` 报「必须是数字」。
|
|
43
59
|
*/
|
|
44
60
|
greedy?: boolean;
|
|
45
61
|
}
|
|
46
62
|
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
| 'continue'
|
|
59
|
-
| 'echo'
|
|
60
|
-
| 'pause';
|
|
61
|
-
|
|
62
|
-
export type WorkflowImageInput =
|
|
63
|
-
| string
|
|
64
|
-
| {
|
|
65
|
-
source: string;
|
|
66
|
-
detail?: ImageDetail;
|
|
67
|
-
max_long_side_pixel?: number;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type StepHistoryMode = 'shared' | 'isolated';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* StepDef 是 YAML 里 steps[] 元素直接反序列化的形态。
|
|
74
|
-
*
|
|
75
|
-
* 动作字段五选一(互斥优先级 type > tool > skill > agent > llm):
|
|
76
|
-
* - tool: 调原子工具
|
|
77
|
-
* - skill: 跑一个外部 SKILL.md 定义的完整 agent(runQuery)
|
|
78
|
-
* - agent: 跑一个 inline 描述的有界 TAOR agent(runQuery/TAOR)—— 受工作流指导的随机应变
|
|
79
|
-
* - llm: 单轮 LLM 生成(不开工具)
|
|
80
|
-
* - type: 控制流(assert / branch / loop / pause / …)
|
|
81
|
-
*
|
|
82
|
-
* 其它字段按 step 类型选择性使用,未用到的字段静默忽略。
|
|
83
|
-
*/
|
|
84
|
-
/**
|
|
85
|
-
* 宿主能力类别 —— `StepDef.uses` 的取值域。
|
|
86
|
-
*
|
|
87
|
-
* 刻意按**能力**分类(浏览器 / 电脑)而不是按工具名:同一类能力可能对应多个工具,
|
|
88
|
-
* 而 yaml 作者关心的是「这一步会不会碰我的机器」,不是工具叫什么。
|
|
89
|
-
*/
|
|
90
|
-
export type HostCapability = 'browser' | 'computer';
|
|
91
|
-
|
|
92
|
-
export interface StepDef {
|
|
93
|
-
id: string;
|
|
94
|
-
tool?: string;
|
|
95
|
-
skill?: string;
|
|
96
|
-
llm?: string;
|
|
97
|
-
/**
|
|
98
|
-
* inline 开放任务,交给 TAOR 引擎(runQuery)随机应变完成;
|
|
99
|
-
* 与 tool/llm/skill/type 互斥。支持 ${var} 插值。复用 allowed_tools(缺省全量工具)/
|
|
100
|
-
* maxTurns(默认 25)/ output_schema / context_files / capture / onError。
|
|
101
|
-
*/
|
|
102
|
-
agent?: string;
|
|
103
|
-
type?:
|
|
104
|
-
| 'assert'
|
|
105
|
-
| 'verify'
|
|
106
|
-
| 'set'
|
|
107
|
-
| 'branch'
|
|
108
|
-
| 'loop'
|
|
109
|
-
| 'break'
|
|
110
|
-
| 'continue'
|
|
111
|
-
| 'echo'
|
|
112
|
-
| 'pause';
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* type=set 时必填:确定性变量赋值 { 变量名: 值 },值支持 ${} 插值(deep)。
|
|
116
|
-
* 设计动机:曾有 yaml 用 `llm: "PLAN"` 当赋值语句——那是真把 "PLAN" 发给模型、
|
|
117
|
-
* capture 模型的自由回复,变量值非确定。状态机类工作流(ralph-loop 的 phase)
|
|
118
|
-
* 必须用 set 确定性赋值,llm 步只用于真需要模型产文本的场合。
|
|
119
|
-
*/
|
|
120
|
-
set?: Record<string, unknown>;
|
|
121
|
-
|
|
63
|
+
/** `export const meta = {...}` 的形状(执行前静态解析得到)。 */
|
|
64
|
+
export interface WorkflowMeta {
|
|
65
|
+
/** V2真实ESM工作流契约版本。 */
|
|
66
|
+
apiVersion: 2;
|
|
67
|
+
/** Statically declared ordinary child workflows; included in bundle identity. */
|
|
68
|
+
dependencies?: string[];
|
|
69
|
+
/** Bare ESM package imports used by this workflow. node: and relative imports need no declaration. */
|
|
70
|
+
packages?: string[];
|
|
71
|
+
/** 一句话说明,显示在 /workflows 列表里。必填。 */
|
|
72
|
+
description: string;
|
|
73
|
+
inputs?: InputDef[];
|
|
122
74
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* ```yaml
|
|
126
|
-
* - id: open_app
|
|
127
|
-
* tool: ComputerUse
|
|
128
|
-
* uses: [computer]
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* 引擎只把**声明过的那一片**转发给 `executeTool`:
|
|
132
|
-
* · 未声明 → 工具拿不到对应上下文 → 走它自己的清晰报错(ComputerUse 会说
|
|
133
|
-
* 「当前宿主未启用 Computer Use」),不会静默降级成一个看起来成功的空操作;
|
|
134
|
-
* · 声明了但宿主没提供 → runner **响亮报错**,而不是跑到一半才发现。
|
|
75
|
+
* 声明产物(相对工作目录)。**只是种子** —— 逐迭代产物由运行时的
|
|
76
|
+
* `declareArtifact(p)` 追加进同一集合。
|
|
135
77
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*/
|
|
140
|
-
uses?: HostCapability[];
|
|
141
|
-
|
|
142
|
-
args?: Record<string, unknown>;
|
|
143
|
-
input?: string;
|
|
144
|
-
capture?: Record<string, string>;
|
|
145
|
-
when?: string;
|
|
146
|
-
onError?: 'halt' | 'continue' | 'recover';
|
|
147
|
-
/**
|
|
148
|
-
* onError:'recover' 时给恢复 agent 的作者提示(可选,支持 ${var} 插值)。
|
|
149
|
-
* 例如 "端口被占就换 3001 重试" / "先 Read 现有文件再决定怎么改"。
|
|
150
|
-
*/
|
|
151
|
-
recover_hint?: string;
|
|
152
|
-
maxTurns?: number;
|
|
153
|
-
/**
|
|
154
|
-
* 多模态图片输入,仅 llm / agent 节点生效。字符串表示图片路径/URL;
|
|
155
|
-
* 对象形式可覆盖单张图片的 detail / max_long_side_pixel。路径支持 ${} 插值。
|
|
156
|
-
*/
|
|
157
|
-
images?: WorkflowImageInput[];
|
|
158
|
-
/** 是否解析 prompt 文本中的 @./image.png 或图片 URL,仅 llm / agent 节点生效。 */
|
|
159
|
-
parse_inline_images?: boolean;
|
|
160
|
-
/** 本步骤图片 detail 默认值,单张 images[].detail 可覆盖。 */
|
|
161
|
-
image_detail?: ImageDetail;
|
|
162
|
-
/** 本步骤图片最长边默认值,单张 images[].max_long_side_pixel 可覆盖。 */
|
|
163
|
-
image_max_long_side_pixel?: number;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* llm / agent / skill 步的历史使用方式。
|
|
167
|
-
* - shared: 默认,沿用共享 TAOR history,步骤消息会继续留给后续步骤。
|
|
168
|
-
* - isolated: 只带系统提示和当前 step prompt 执行,结果经 capture/文件传递,
|
|
169
|
-
* 不把本步 user/assistant/image 消息写回共享 history。适合多模态验图、
|
|
170
|
-
* 敏感图片复核、长导出 agent 等不应污染后续上下文的步骤。
|
|
78
|
+
* 原因:meta 是执行前静态求值的纯字面量,写不出 `out/${session}/page-${i}.png`
|
|
79
|
+
* 这种带循环下标的路径;而 ppt/illustrate 恰恰是这个形状。只留静态声明会让
|
|
80
|
+
* new-task 清理漏掉它们,且**表现为静默漏档而不是报错**。
|
|
171
81
|
*/
|
|
172
|
-
history_mode?: StepHistoryMode;
|
|
173
|
-
|
|
174
|
-
condition?: string;
|
|
175
|
-
|
|
176
|
-
/** type=verify 时必填:检查项列表(YAML 数组或逗号分隔字符串),每项格式 "type:value"(如 "file_exists:./PLAN.md") */
|
|
177
|
-
checks?: string[] | string;
|
|
178
|
-
|
|
179
|
-
onFail?: string;
|
|
180
|
-
then?: StepDef[];
|
|
181
|
-
else?: StepDef[];
|
|
182
|
-
over?: string;
|
|
183
|
-
as?: string;
|
|
184
|
-
do?: StepDef[];
|
|
185
|
-
|
|
186
|
-
/** type=loop while 模式:最大迭代次数(安全阀,必填)。无 over 时进入 while 循环。
|
|
187
|
-
* 支持 ${} 模板字符串(如 "${inputs.max_iterations}"),runner 插值后 coerce 成数字;
|
|
188
|
-
* 插值结果非正数时**响亮报错**(曾有字符串直接参与 < 比较 → NaN → 静默 0 次迭代的事故)。 */
|
|
189
|
-
max_iterations?: number | string;
|
|
190
|
-
/**
|
|
191
|
-
* type=loop while 模式:每轮迭代前是否重置 history 到循环入口快照(fresh context)。
|
|
192
|
-
* 默认 false。适用于"同一目标反复执行直到完成"的场景(如 ralph-loop),
|
|
193
|
-
* 避免历史无限膨胀导致上下文窗口溢出。
|
|
194
|
-
*/
|
|
195
|
-
fresh_context?: boolean;
|
|
196
|
-
|
|
197
|
-
prompt?: string;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* type=pause 时,用户选择「其他」并输入自由文本的处理方式:
|
|
201
|
-
* - halt: 默认,视为补充指示/修改要求,不放行
|
|
202
|
-
* - approve: 视为带补充要求的放行,可配 capture: { text: varName } 传给后续步骤
|
|
203
|
-
*/
|
|
204
|
-
free_text?: 'halt' | 'approve';
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* type=break / type=continue 的目标循环 id(标签语义)。
|
|
208
|
-
* 缺省 = 最近一层循环;指定后信号会穿透中间层循环向上传播,直到 id 匹配的
|
|
209
|
-
* loop 消费它(如审批反馈是方向性变化时,从审批小循环里 continue 到外层
|
|
210
|
-
* plan_loop 重启整轮规划)。目标 id 不存在时信号冒泡到顶层按正常完成处理。
|
|
211
|
-
*/
|
|
212
|
-
target?: string;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* type=echo 时必填:确定性输出一段话给用户(支持 ${} 插值),不烧 LLM。
|
|
216
|
-
* 设计动机:工作流末尾的「完成报告」此前只能用 llm 步复述(多一次调用且可能
|
|
217
|
-
* 幻觉);产物/裁决已在变量里时,echo 直接插值输出即可。
|
|
218
|
-
*/
|
|
219
|
-
message?: string;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* 动作步(tool/llm/skill/agent)与 pause 可选:本步成功后把产出文本作为
|
|
223
|
-
* 「用户补充要求」追加进 RunContext.goalSupplements,随目标锚定注入后续每一步
|
|
224
|
-
* (如 stage0 澄清问答的结论应贯穿整条工作流)。引擎自动截断保持锚紧凑。
|
|
225
|
-
*/
|
|
226
|
-
goal_supplement?: boolean;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* 任意步可选:人话进度显示名(支持 ${} 插值)。声明后该步在状态行显示这段
|
|
230
|
-
* 文案(如「阶段2/6·起草实现计划」),**不再附块内相对序号**——嵌套块的
|
|
231
|
-
* i/total(顶层 5、循环体 12…)对用户是噪声,阶段语言才是真正的进度。
|
|
232
|
-
* 未声明的步保持 legacy 格式(i/total step <id> (<kind>))。
|
|
233
|
-
*/
|
|
234
|
-
title?: string;
|
|
235
|
-
|
|
236
|
-
/** ADR-05: LLM 输出 JSON Schema 强约束,走 provider-native structured output;仅 llm 节点生效(skill 节点 loader 拒绝)。 */
|
|
237
|
-
output_schema?: Record<string, unknown>;
|
|
238
|
-
|
|
239
|
-
/** ADR-05: 仅 llm 节点声明的上下文文件清单(skill 节点 loader 拒绝);runner 拼 path+hint 进 prompt 并开放 Read 子循环,不 inline 内容。 */
|
|
240
|
-
context_files?: Array<{ path: string; hint?: string }>;
|
|
241
|
-
|
|
242
|
-
/** ADR-05: agent 节点的工具白名单;未声明时继承宿主过滤后的有效工具集。 */
|
|
243
|
-
allowed_tools?: string[];
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 仅 agent 节点可选:确定性完成条件(白名单表达式,如 fileExists('./out/x.pptx'))。
|
|
247
|
-
* 步结束后求值;不满足时引擎自动 nudge 同一 agent 在共享 history 上继续执行
|
|
248
|
-
* (上限 2 次),仍不满足按可重试失败交给 onError/max_retries。
|
|
249
|
-
* 动机:弱模型 announce-not-do 烂尾兜底——对抗逻辑收回引擎单点,yaml 不再写
|
|
250
|
-
* 「每条消息必须含工具调用」这类 prompt 规则。
|
|
251
|
-
*/
|
|
252
|
-
done_when?: string;
|
|
253
|
-
|
|
254
|
-
// ---- 断点续执行 / 自愈(Phase 1)----
|
|
255
|
-
|
|
256
|
-
/** 此步骤产出的文件路径列表(相对 cwd,用于产物生命周期管理) */
|
|
257
82
|
artifacts?: string[];
|
|
258
|
-
|
|
259
83
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* runner 已实装:失败先确定性重跑同一步,retry 用尽才落 onError(recover/continue/halt)。
|
|
84
|
+
* resume 时额外回退的调用数(承接 legacy 的 `self_heal.backoff`)。
|
|
85
|
+
* 缺省 0。用于「最后一次成功调用可能有未完成副作用」的场景。
|
|
263
86
|
*/
|
|
264
|
-
|
|
87
|
+
resumeBackoff?: number;
|
|
88
|
+
/** 可选外层控制器;Runner 只消费其通用执行租约。 */
|
|
89
|
+
managedRuntime?: string;
|
|
265
90
|
}
|
|
266
91
|
|
|
267
|
-
|
|
92
|
+
/** 磁盘上发现的一个工作流。 */
|
|
93
|
+
export interface WorkflowScript {
|
|
94
|
+
/** 工作流名 = 目录名(唯一真值)。 */
|
|
268
95
|
name: string;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// ---- 断点续执行 / 自愈(Phase 1)----
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* 全局自愈配置(runner 已实装两条机制):
|
|
282
|
-
* - max_retries:单步 **in-run** 失败重试(同一次运行内确定性重跑同一步)。
|
|
283
|
-
* - backoff: **跨次** 重跑(同任务中断后再次 /workflow)时,从「已完成步 - backoff」处恢复。
|
|
284
|
-
*
|
|
285
|
-
* checkpoint / resume 范围:顶层 steps[] 全量 + **顶层 loop 的 do[] 一层**
|
|
286
|
-
* (复合 checkpoint「loopId@@迭代号@@stepId」,resume 可恢复到迭代中间,
|
|
287
|
-
* 见 workflowState.ts)。更深嵌套(loop 内的 loop 的 do[] / branch.then[])
|
|
288
|
-
* 仍作为原子单元;resume 只回放 VarStack 变量、不恢复 TAOR history。
|
|
289
|
-
*/
|
|
290
|
-
self_heal?: {
|
|
291
|
-
/** 跨次重跑的回退步数(默认 1 = 从最后一个已完成步重跑;设 2 则再往前一步)。 */
|
|
292
|
-
backoff?: number;
|
|
293
|
-
/** 单步额外 in-run 重试次数(默认 0 = 不重试;总尝试 = 1 + max_retries)。 */
|
|
294
|
-
max_retries?: number;
|
|
295
|
-
/**
|
|
296
|
-
* in-run 重试前的退避等待(毫秒,线性:第 n 次重试等 n × retry_delay_ms)。
|
|
297
|
-
* 默认 0 = 立即重跑。瞬态故障(网络抖动/限流/provider 短暂 5xx)下立即重跑
|
|
298
|
-
* 大概率撞同一个故障窗口,配 2000-5000 给故障留恢复时间。
|
|
299
|
-
*/
|
|
300
|
-
retry_delay_ms?: number;
|
|
301
|
-
/**
|
|
302
|
-
* maxTurns 截断重试前的退避等待(毫秒,线性:第 n 次重试等 n × max_turns_retry_delay_ms)。
|
|
303
|
-
* 默认 0 = 保持旧行为立即续跑;PPT/长文档类高峰期工作流可单独配置,避免模型端拥塞时
|
|
304
|
-
* 连续撞顶刷屏,同时让 UI 明确这是“可重试截断”而不是最终失败。
|
|
305
|
-
*/
|
|
306
|
-
max_turns_retry_delay_ms?: number;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
/** 工作流级声明式产物列表(runner 用于新任务检测时的清理 / 归档时的追踪)。
|
|
310
|
-
* 路径相对于 cwd(getWorkingDir)。step 级 artifacts 是子集。 */
|
|
311
|
-
artifacts?: string[];
|
|
96
|
+
/** 工作流目录绝对路径。 */
|
|
97
|
+
dir: string;
|
|
98
|
+
/** `<dir>/workflow.mjs` 绝对路径。 */
|
|
99
|
+
scriptPath: string;
|
|
100
|
+
/** 脚本全文(journal 的脚本指纹按它算)。 */
|
|
101
|
+
source: string;
|
|
102
|
+
meta: WorkflowMeta;
|
|
103
|
+
/** meta 字面量之后的位置,仅供静态校验器报告源码位置。 */
|
|
104
|
+
bodyOffset: number;
|
|
312
105
|
}
|
|
313
106
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
* - 进入 loop 时 push() 新帧,存当前迭代的 as / as_idx
|
|
320
|
-
* - 退出 loop 时 pop()
|
|
321
|
-
*
|
|
322
|
-
* get(key) 从栈顶往下找第一个匹配的 frame,类似 JS 的 lexical scope。
|
|
323
|
-
*/
|
|
324
|
-
export class VarStack {
|
|
325
|
-
private frames: Record<string, unknown>[] = [{}];
|
|
326
|
-
/**
|
|
327
|
-
* 哪些帧是「循环迭代帧」—— 只为装 `as` / `as_idx` 这类**每轮重置**的迭代变量而生。
|
|
328
|
-
*
|
|
329
|
-
* ⚠️ 区分这个的原因是一个真实 bug:loop 每轮 `push()`…`pop()`,于是循环体里
|
|
330
|
-
* `capture` 出来的变量**随迭代帧一起被弹掉**,循环一结束就没了。
|
|
331
|
-
* 实测代价:seek 循环一路把书翻到第 12 页、`cur_page` 明明是「PAGE=12 13」,
|
|
332
|
-
* 循环外的 `guard_landing` 读到的却是空串,于是报「没能翻到第 12 页(最后读到的
|
|
333
|
-
* 页码:)」—— 一个刚刚成功的任务被判成失败,而且报错文案完全指不向真因。
|
|
334
|
-
*
|
|
335
|
-
* 正确的语义分界:**迭代变量按帧作用域,作者显式命名的变量不按**。
|
|
336
|
-
* yaml 作者写 `capture: { text: cur_page }` 时期待的是「cur_page 存着最后读到的值」,
|
|
337
|
-
* 而不是「它只在这一轮迭代里活着」。
|
|
338
|
-
*/
|
|
339
|
-
private iterationFrames = new Set<number>();
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* 写一个**作者命名**的变量(capture / set 步 / 引擎内部状态)。
|
|
343
|
-
*
|
|
344
|
-
* 穿透所有迭代帧,落到最近的非迭代帧上 —— 这样它在循环结束后依然存在。
|
|
345
|
-
*/
|
|
346
|
-
set(key: string, val: unknown): void {
|
|
347
|
-
for (let i = this.frames.length - 1; i >= 0; i--) {
|
|
348
|
-
if (!this.iterationFrames.has(i)) {
|
|
349
|
-
this.frames[i][key] = val;
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
this.frames[0][key] = val;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/** 写一个**迭代变量**(`as` / `as_idx`):落在当前迭代帧,随 pop 一起消失。 */
|
|
357
|
-
setIteration(key: string, val: unknown): void {
|
|
358
|
-
this.frames[this.frames.length - 1][key] = val;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/** 写到栈底(root frame),用于 inputs / 全局常量 */
|
|
362
|
-
setGlobal(key: string, val: unknown): void {
|
|
363
|
-
this.frames[0][key] = val;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
get(key: string): unknown {
|
|
367
|
-
for (let i = this.frames.length - 1; i >= 0; i--) {
|
|
368
|
-
if (key in this.frames[i]) return this.frames[i][key];
|
|
369
|
-
}
|
|
370
|
-
return undefined;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
has(key: string): boolean {
|
|
374
|
-
for (let i = this.frames.length - 1; i >= 0; i--) {
|
|
375
|
-
if (key in this.frames[i]) return true;
|
|
376
|
-
}
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
push(): void {
|
|
381
|
-
this.frames.push({});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/** 压一个迭代帧:只有 `setIteration` 写进来的东西会随 `pop` 消失。 */
|
|
385
|
-
pushIteration(): void {
|
|
386
|
-
this.frames.push({});
|
|
387
|
-
this.iterationFrames.add(this.frames.length - 1);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
pop(): void {
|
|
391
|
-
if (this.frames.length > 1) {
|
|
392
|
-
this.iterationFrames.delete(this.frames.length - 1);
|
|
393
|
-
this.frames.pop();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/** 合并所有帧为一个普通对象(外层覆盖内层),用于 vars 持久化与事件 */
|
|
398
|
-
snapshot(): Record<string, unknown> {
|
|
399
|
-
return Object.assign({}, ...this.frames);
|
|
400
|
-
}
|
|
107
|
+
/** 发现阶段跳过的坏工作流 —— 静默跳过是不可接受的,必须能报给用户。 */
|
|
108
|
+
export interface WorkflowLoadFailure {
|
|
109
|
+
name: string;
|
|
110
|
+
scriptPath: string;
|
|
111
|
+
errors: string[];
|
|
401
112
|
}
|
|
402
113
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
* - map 形式: capture: { text: foo, args.content: bar }
|
|
407
|
-
* - 简写字符串: capture: foo ≡ capture: { result: foo }
|
|
408
|
-
* 绑 StepResult.raw.result —— llm/agent=文本、tool=回执,各 executor 都提供 result 别名。
|
|
409
|
-
*
|
|
410
|
-
* 放在 types.ts(零依赖)供 runner.ts(bindCapture)与 agentCommon.ts(describeCaptureContract)
|
|
411
|
-
* 共用,避免 runner↔agentCommon 循环引用。
|
|
412
|
-
*/
|
|
413
|
-
export function normalizeCapture(
|
|
414
|
-
cap: Record<string, string> | string | undefined,
|
|
415
|
-
): Record<string, string> {
|
|
416
|
-
if (cap == null) return {};
|
|
417
|
-
if (typeof cap === 'string') return { result: cap };
|
|
418
|
-
return cap;
|
|
114
|
+
export interface DiscoveryResult {
|
|
115
|
+
workflows: WorkflowScript[];
|
|
116
|
+
failures: WorkflowLoadFailure[];
|
|
419
117
|
}
|
|
420
118
|
|
|
421
|
-
//
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// 运行上下文
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
422
122
|
|
|
423
123
|
/**
|
|
424
|
-
*
|
|
124
|
+
* 一次工作流运行需要的全部宿主上下文。
|
|
425
125
|
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
126
|
+
* 相对 legacy 的同名类型删掉了 `selfHealMaxRetries` / `retryDelayMs` /
|
|
127
|
+
* `maxTurnsRetryDelayMs` —— 那三个是 DSL 的 `self_heal:` 声明,代码形态里
|
|
128
|
+
* 「重试三次、每次退避一点」就是一个 `for` 加 `try`,不需要引擎参与。
|
|
428
129
|
*/
|
|
429
130
|
export interface RunContext {
|
|
430
131
|
provider: Provider;
|
|
431
|
-
runtimeContext?:
|
|
132
|
+
runtimeContext?: AgentRuntimeContext;
|
|
432
133
|
signal?: AbortSignal;
|
|
433
134
|
/**
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
135
|
+
* 宿主授权上下文(浏览器 / 电脑操控)。
|
|
136
|
+
*
|
|
137
|
+
* ⚠️ **不整份下发给每次调用** —— 由调用点按显式声明切片。一份无人值守的脚本
|
|
138
|
+
* 隐式拿到全权是危险的,这条从 legacy 原样继承。
|
|
139
|
+
*/
|
|
140
|
+
host?: PluginContext['host'];
|
|
141
|
+
/** Host-authorized resources for this invocation; never persisted or published. */
|
|
142
|
+
inputResources?: readonly InvocationResource[];
|
|
143
|
+
/** Resources bound to declared input names (the public workflow global). */
|
|
144
|
+
inputResourceMap?: Record<string, InvocationResource[]>;
|
|
145
|
+
/** 当前工作目录。注意实际文件操作要走 `effectiveWorkflowCwd`(可能已进 worktree)。 */
|
|
439
146
|
cwd: string;
|
|
440
147
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
148
|
+
* 可用工具列表 —— 宿主授权的上限。
|
|
149
|
+
*
|
|
150
|
+
* 提示词、schema 与真实执行都以这同一份列表为准,脚本不能从 ALL_TOOLS
|
|
151
|
+
* 恢复被宿主藏起来的能力。
|
|
445
152
|
*/
|
|
446
153
|
tools: Tool[];
|
|
447
|
-
transientContext?: string;
|
|
448
|
-
transientBundle?: import('../../../src/plugin-sdk.js').ContextBundle;
|
|
449
|
-
promptCache?: import('../../../src/plugin-sdk.js').PromptCacheContext;
|
|
450
154
|
/**
|
|
451
|
-
* 共享 TAOR history
|
|
155
|
+
* 共享 TAOR history 引用。
|
|
452
156
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
* 实现上下文自然积累——workflow 每步执行过程对后续对话完全可见。
|
|
157
|
+
* agent/llm/skill 调用经 runQuery 直接写进它,上下文自然积累 ——
|
|
158
|
+
* 工作流每步的执行过程对后续对话完全可见(单一上下文原则)。
|
|
456
159
|
*/
|
|
457
160
|
history: Message[];
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
161
|
+
transientContext?: string;
|
|
162
|
+
transientBundle?: ContextBundle;
|
|
163
|
+
promptCache?: PromptCacheContext;
|
|
164
|
+
/** 会话状态:驱动自动压缩,且 `activeWorktree` 决定工具的有效 cwd。 */
|
|
165
|
+
sessionState?: SessionState;
|
|
166
|
+
/** 工作流总目标(取自 meta.description 或首个 required 输入)。 */
|
|
462
167
|
goal?: string;
|
|
463
168
|
/**
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* 设计目的:工作流执行过程中(尤其是多步、长时间、fresh_context 场景),
|
|
467
|
-
* LLM 可能因上下文膨胀或 history 重置而"忘记"用户的原始目标,导致
|
|
468
|
-
* 后续步骤偏离方向(舍本逐末)。
|
|
469
|
-
*
|
|
470
|
-
* runner 在启动时从 inputs 中提取目标(优先取名为 "goal" 的输入,
|
|
471
|
-
* 其次取第一个 required string 输入),构建紧凑的锚定字符串。
|
|
472
|
-
* agent/llm/skill 步骤在构造 prompt 时自动将其前置注入,
|
|
473
|
-
* 确保**每一步 LLM 都能看到原始目标**,无需每个 YAML 手写 `${goal}`。
|
|
169
|
+
* 目标锚定串:每次 agent/llm/skill 调用自动前置注入。
|
|
474
170
|
*
|
|
475
|
-
*
|
|
171
|
+
* 存在理由是真实失效模式:多步长跑(尤其上下文压缩过后),模型会「忘记」
|
|
172
|
+
* 用户的原始目标而逐渐偏航。锚定由引擎注入,**对脚本作者透明** ——
|
|
173
|
+
* 作者不需要在每个 prompt 里手写目标。
|
|
476
174
|
*/
|
|
477
175
|
goalAnchor?: string;
|
|
176
|
+
/** 外层运行时分配的通用执行租约;普通工作流不设置。 */
|
|
177
|
+
managedExecution?: ManagedExecutionContext;
|
|
178
|
+
/** 外层控制器与 Attempt Executor 之间的窄桥。 */
|
|
179
|
+
managedBridge?: ManagedExecutionBridge;
|
|
180
|
+
/** Children may account usage, but never receive the outer lifecycle bridge. */
|
|
181
|
+
usageRecorder?: ManagedExecutionBridge['recordUsage'];
|
|
182
|
+
/**
|
|
183
|
+
* 本次运行的资源账本(`budget()` 的数据源)。
|
|
184
|
+
*
|
|
185
|
+
* ⚠️ 有外层控制器时以**它返回的持久化快照**为准,进程内这份只是没有控制器时的兜底:
|
|
186
|
+
* 断点续跑时账本重放不重新执行 agent/llm,进程内计数会从 0 起,
|
|
187
|
+
* 而 Goal 侧的 `goal.usage` 是跨进程累计的。
|
|
188
|
+
* `trustworthy=false` 表示至少有一次调用的 provider 没回报 usage,这份账偏低。
|
|
189
|
+
*/
|
|
190
|
+
resourceLedger?: {
|
|
191
|
+
inputTokens: number;
|
|
192
|
+
outputTokens: number;
|
|
193
|
+
limit: number | null;
|
|
194
|
+
trustworthy: boolean;
|
|
195
|
+
};
|
|
478
196
|
/**
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
* 持久化:runner 同步写状态目录 supplements.json,跨进程 resume 不丢。
|
|
197
|
+
* 用户补充要求,与原始目标**同等贯穿始终**。三个来源,引擎自动累加:
|
|
198
|
+
* ① `ask()` 审批闸门里用户的自由输入
|
|
199
|
+
* ② 显式调用 `addGoalSupplement()` 的产出(如开头澄清问答的结论)
|
|
200
|
+
* ③ 仲裁判为 resume 时用户给的新指令(「继续,但改成 12 页」)
|
|
201
|
+
* 渲染成「📌 用户补充要求」跟在 goalAnchor 之后。持久化到状态目录,
|
|
202
|
+
* 跨进程 resume 不丢。
|
|
486
203
|
*/
|
|
487
204
|
goalSupplements?: string[];
|
|
488
205
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
206
|
+
* 本次运行声明的产物(相对 cwd)。**运行时可增长** —— `meta.artifacts`
|
|
207
|
+
* 只是种子,循环体里的逐迭代产物经 `declareArtifact()` 加进来。
|
|
208
|
+
*
|
|
209
|
+
* 用途:内核 Write/Edit 有「文件已存在必须先 Read」守卫(进程级状态,
|
|
210
|
+
* 跨进程 resume 必空)。写自家声明产物时引擎自动 pre-Read 解除守卫;
|
|
211
|
+
* 非声明产物的盲写保护原样生效。
|
|
491
212
|
*/
|
|
213
|
+
declaredArtifacts?: Set<string>;
|
|
214
|
+
/** DI:chat 实现,仅测试用。生产不传 → runQuery 走默认 llm/client.ts。 */
|
|
492
215
|
chat?: (args: {
|
|
493
|
-
provider:
|
|
494
|
-
messages:
|
|
495
|
-
tools:
|
|
216
|
+
provider: Provider;
|
|
217
|
+
messages: Message[];
|
|
218
|
+
tools: Tool[];
|
|
496
219
|
signal?: AbortSignal;
|
|
497
|
-
promptCache?:
|
|
498
|
-
}) => AsyncGenerator<
|
|
499
|
-
|
|
500
|
-
void,
|
|
501
|
-
undefined
|
|
502
|
-
>;
|
|
503
|
-
/**
|
|
504
|
-
* DI:executeTool 实现(仅测试用)。同上。
|
|
505
|
-
*/
|
|
220
|
+
promptCache?: PromptCacheContext;
|
|
221
|
+
}) => AsyncGenerator<LlmStreamEvent, void, undefined>;
|
|
222
|
+
/** DI:executeTool 实现,仅测试用。 */
|
|
506
223
|
executeTool?: PluginContext['executeTool'];
|
|
507
224
|
/**
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
* added by the step-level `uses` slicer.
|
|
225
|
+
* 与模型无关的确定性工具上下文。浏览器/电脑能力**刻意排除在外**,
|
|
226
|
+
* 只由调用点按显式声明追加。
|
|
511
227
|
*/
|
|
512
228
|
toolContext?: Omit<
|
|
513
229
|
ToolCallContext,
|
|
@@ -518,85 +234,4 @@ export interface RunContext {
|
|
|
518
234
|
| 'toolCallId'
|
|
519
235
|
| 'cwd'
|
|
520
236
|
>;
|
|
521
|
-
/**
|
|
522
|
-
* 会话状态(驱动 microCompact / reactiveCompact)。
|
|
523
|
-
*
|
|
524
|
-
* v0.9.3:从 pluginRunner 透传过来,在 agent/llm/skill 步调用 runQuery 时
|
|
525
|
-
* 一并传入,确保 workflow 执行期间上下文压缩正常工作(不再只增不减)。
|
|
526
|
-
*/
|
|
527
|
-
sessionState?: SessionState;
|
|
528
|
-
/**
|
|
529
|
-
* self_heal 全局默认重试次数(= WorkflowDef.self_heal.max_retries),由 runWorkflow 注入。
|
|
530
|
-
* runner 普通动作 step 失败时据此做 in-run retry;step.max_retries 优先于此默认。
|
|
531
|
-
*/
|
|
532
|
-
selfHealMaxRetries?: number;
|
|
533
|
-
/** in-run 重试退避基数(= WorkflowDef.self_heal.retry_delay_ms),默认 0 立即重跑。 */
|
|
534
|
-
retryDelayMs?: number;
|
|
535
|
-
/** maxTurns 截断重试退避基数(= WorkflowDef.self_heal.max_turns_retry_delay_ms),默认 0 立即续跑。 */
|
|
536
|
-
maxTurnsRetryDelayMs?: number;
|
|
537
|
-
/**
|
|
538
|
-
* 工作流【声明】的产物路径(def.artifacts + 所有 step.artifacts,相对 cwd),
|
|
539
|
-
* 由 runWorkflow 经 collectDeclaredArtifacts 注入。
|
|
540
|
-
*
|
|
541
|
-
* 用途(tool 步覆盖判定):内核 Write/Edit 工具有「文件已存在必须先 Read」守卫
|
|
542
|
-
* (进程级状态,跨进程/resume 必空)。确定性 tool 步写的目标若是**声明产物**
|
|
543
|
-
* (= 工作流自己拥有、本就要覆盖的文件),执行前自动 pre-Read 解除守卫;
|
|
544
|
-
* 非声明产物的盲写保护原样生效。
|
|
545
|
-
*/
|
|
546
|
-
declaredArtifacts?: string[];
|
|
547
237
|
}
|
|
548
|
-
|
|
549
|
-
// ---------------- 4. step 执行结果 ----------------
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* 每个 step executor 的返回。capture 字段会从 raw 上按 capture map 取值。
|
|
553
|
-
*
|
|
554
|
-
* - raw: 完整结构化结果,给 capture 用
|
|
555
|
-
* - preview: 给 UI 展示的短摘要(≤200 char)
|
|
556
|
-
*/
|
|
557
|
-
export interface StepResult {
|
|
558
|
-
raw: Record<string, unknown>;
|
|
559
|
-
preview: string;
|
|
560
|
-
/**
|
|
561
|
-
* 本步**引入的变量**,resume 跳过它时必须回放这些值。
|
|
562
|
-
*
|
|
563
|
-
* ⚠️ 与 `capture` 是两回事,别合并:
|
|
564
|
-
* · `capture` 是**作者显式声明**「把产出的哪个字段绑到哪个变量」
|
|
565
|
-
* · `replayVars` 是**这一步本身就在写变量**(目前只有 `set`)——
|
|
566
|
-
* 它没有也不需要 `capture`,但 resume 跳过它时那些变量必须还在
|
|
567
|
-
*
|
|
568
|
-
* 实测代价:重构时把 set 的 checkpoint 统一成 `collectCaptured(...)`,
|
|
569
|
-
* 而 set 步没有 `capture:` → 记成 `{}` → resume 后下游 `phase == "PLAN"`
|
|
570
|
-
* 断言直接判假。`engineRobustness.test.ts` 抓住了它。
|
|
571
|
-
*/
|
|
572
|
-
replayVars?: Record<string, unknown>;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// ---------------- 5. workflow 事件(独立类型,便于 step executors 直接 yield) ----------------
|
|
576
|
-
|
|
577
|
-
export type WorkflowEvent =
|
|
578
|
-
| { type: 'workflow_start'; name: string; totalSteps: number }
|
|
579
|
-
| {
|
|
580
|
-
type: 'workflow_step_start';
|
|
581
|
-
id: string;
|
|
582
|
-
kind: StepKind;
|
|
583
|
-
index: number;
|
|
584
|
-
total: number;
|
|
585
|
-
/**
|
|
586
|
-
* 已插值的人话进度名(step.title)。声明了 title 的步骤带此字段,UI 的
|
|
587
|
-
* scrollback 进度行显示它、不再显示块内相对序号(嵌套块的 i/total 各自相对
|
|
588
|
-
* 当前 block,跨层拼在一起会被误读成"跳步"——状态行早已只显示 title,
|
|
589
|
-
* 此前 scrollback 却仍发 legacy 序号格式,两处不一致即用户看到的"残留")。
|
|
590
|
-
* 未声明 title 的步骤省略此字段,UI 回落 legacy "i/total id (kind)"。
|
|
591
|
-
*/
|
|
592
|
-
title?: string;
|
|
593
|
-
}
|
|
594
|
-
| {
|
|
595
|
-
type: 'workflow_step_end';
|
|
596
|
-
id: string;
|
|
597
|
-
ok: boolean;
|
|
598
|
-
output?: string;
|
|
599
|
-
error?: string;
|
|
600
|
-
}
|
|
601
|
-
| { type: 'workflow_step_skipped'; id: string; reason: string }
|
|
602
|
-
| { type: 'workflow_done'; name: string; vars: Record<string, unknown> };
|