minimal-agent 0.10.0 → 0.12.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 +11 -3
- package/package.json +52 -5
- package/plugins/computer_use/.claude-plugin/plugin.json +6 -0
- package/plugins/computer_use/README.md +94 -0
- package/plugins/computer_use/app/_template.md +142 -0
- package/plugins/computer_use/app/chrome.md +165 -0
- package/plugins/computer_use/app/finder.md +76 -0
- package/plugins/computer_use/app/macos-system-settings.md +81 -0
- package/plugins/computer_use/app/microsoft-excel.md +80 -0
- package/plugins/computer_use/app/microsoft-powerpoint.md +80 -0
- package/plugins/computer_use/app/microsoft-word.md +79 -0
- package/plugins/computer_use/app/wechat.md +413 -0
- package/plugins/computer_use/app/weread.md +319 -0
- package/plugins/computer_use/commands/computeruse.md +25 -0
- package/plugins/computer_use/commands/cu.md +9 -0
- package/plugins/computer_use/plugin.js +26 -0
- package/plugins/computer_use/plugin.ts +30 -0
- package/plugins/computer_use/src/capture.js +90 -0
- package/plugins/computer_use/src/capture.ts +104 -0
- package/plugins/computer_use/src/commands.js +91 -0
- package/plugins/computer_use/src/commands.ts +103 -0
- package/plugins/computer_use/src/daemon.js +134 -0
- package/plugins/computer_use/src/daemon.ts +161 -0
- package/plugins/computer_use/src/manuals.js +135 -0
- package/plugins/computer_use/src/manuals.ts +159 -0
- package/plugins/computer_use/src/verify.js +168 -0
- package/plugins/computer_use/src/verify.ts +219 -0
- package/plugins/computer_use/test/commands.test.ts +73 -0
- package/plugins/cron-runner/plugin.ts +38 -0
- package/plugins/cron-runner/src/commands.ts +373 -0
- package/plugins/cron-runner/src/cronTime.ts +155 -0
- package/plugins/cron-runner/src/lock.ts +79 -0
- package/plugins/cron-runner/src/runs.ts +99 -0
- package/plugins/cron-runner/src/scheduleEngine.ts +76 -0
- package/plugins/cron-runner/src/scheduler.ts +376 -0
- package/plugins/cron-runner/src/schema.ts +139 -0
- package/plugins/cron-runner/src/service.ts +193 -0
- package/plugins/cron-runner/src/store.ts +333 -0
- package/plugins/cron-runner/src/types.ts +141 -0
- package/plugins/cron-runner/test/cronTime.test.ts +41 -0
- package/plugins/cron-runner/test/plugin-integration.test.ts +47 -0
- package/plugins/cron-runner/test/scheduleEngine.test.ts +41 -0
- package/plugins/cron-runner/test/service.test.ts +76 -0
- package/plugins/cron-runner/test/store-and-scheduler.test.ts +501 -0
- package/plugins/workflow-runner/plugin.js +56 -2
- package/plugins/workflow-runner/plugin.ts +113 -0
- package/plugins/workflow-runner/src/agentCommon.js +43 -4
- package/plugins/workflow-runner/src/agentCommon.ts +435 -0
- package/plugins/workflow-runner/src/controlFlow/branch.js +40 -0
- package/plugins/workflow-runner/src/controlFlow/branch.ts +46 -0
- package/plugins/workflow-runner/src/controlFlow/loop.js +211 -0
- package/plugins/workflow-runner/src/controlFlow/loop.ts +248 -0
- package/plugins/workflow-runner/src/controlFlow/pause.js +129 -0
- package/plugins/workflow-runner/src/controlFlow/pause.ts +141 -0
- package/plugins/workflow-runner/src/controlFlow/signal.js +21 -0
- package/plugins/workflow-runner/src/controlFlow/signal.ts +29 -0
- package/plugins/workflow-runner/src/controlFlow/types.js +18 -0
- package/plugins/workflow-runner/src/controlFlow/types.ts +63 -0
- package/plugins/workflow-runner/src/dslManifest.ts +127 -0
- package/plugins/workflow-runner/src/expressions.ts +622 -0
- package/plugins/workflow-runner/src/index.js +13 -4
- package/plugins/workflow-runner/src/index.ts +338 -0
- package/plugins/workflow-runner/src/jsonPayload.ts +84 -0
- package/plugins/workflow-runner/src/loader.js +23 -0
- package/plugins/workflow-runner/src/loader.ts +721 -0
- package/plugins/workflow-runner/src/multimodal.js +2 -1
- package/plugins/workflow-runner/src/multimodal.ts +64 -0
- package/plugins/workflow-runner/src/recovery.ts +149 -0
- package/plugins/workflow-runner/src/runner.js +75 -659
- package/plugins/workflow-runner/src/runner.ts +604 -0
- package/plugins/workflow-runner/src/stepExecutors/agent.ts +234 -0
- package/plugins/workflow-runner/src/stepExecutors/assert.ts +50 -0
- package/plugins/workflow-runner/src/stepExecutors/echo.js +31 -0
- package/plugins/workflow-runner/src/stepExecutors/echo.ts +38 -0
- package/plugins/workflow-runner/src/stepExecutors/llm.ts +133 -0
- package/plugins/workflow-runner/src/stepExecutors/set.js +49 -0
- package/plugins/workflow-runner/src/stepExecutors/set.ts +56 -0
- package/plugins/workflow-runner/src/stepExecutors/skill.js +5 -6
- package/plugins/workflow-runner/src/stepExecutors/skill.ts +140 -0
- package/plugins/workflow-runner/src/stepExecutors/tool.js +80 -8
- package/plugins/workflow-runner/src/stepExecutors/tool.ts +256 -0
- package/plugins/workflow-runner/src/stepExecutors/verify.ts +68 -0
- package/plugins/workflow-runner/src/stepPipeline.js +277 -0
- package/plugins/workflow-runner/src/stepPipeline.ts +366 -0
- package/plugins/workflow-runner/src/taskIdentity.ts +405 -0
- package/plugins/workflow-runner/src/toolRuntime.js +48 -0
- package/plugins/workflow-runner/src/toolRuntime.ts +64 -0
- package/plugins/workflow-runner/src/types.js +37 -1
- package/plugins/workflow-runner/src/types.ts +602 -0
- package/plugins/workflow-runner/src/workflowState.ts +733 -0
- package/plugins/workflow-runner/test/agent.test.ts +587 -0
- package/plugins/workflow-runner/test/agentLlmError.test.ts +373 -0
- package/plugins/workflow-runner/test/bashBlacklist.sweep.test.ts +65 -0
- package/plugins/workflow-runner/test/captureMisbind.test.ts +99 -0
- package/plugins/workflow-runner/test/cli.e2e.test.ts +147 -0
- package/plugins/workflow-runner/test/context-files.test.ts +320 -0
- package/plugins/workflow-runner/test/e2e.test.ts +370 -0
- package/plugins/workflow-runner/test/engineRobustness.test.ts +226 -0
- package/plugins/workflow-runner/test/expressions.test.ts +397 -0
- package/plugins/workflow-runner/test/foundation.test.ts +126 -0
- package/plugins/workflow-runner/test/graceful.test.ts +139 -0
- package/plugins/workflow-runner/test/greedyInputs.load.test.ts +47 -0
- package/plugins/workflow-runner/test/hostCapability.test.ts +108 -0
- package/plugins/workflow-runner/test/illustrate.load.test.ts +183 -0
- package/plugins/workflow-runner/test/jsonPayload.test.ts +83 -0
- package/plugins/workflow-runner/test/loader.test.ts +617 -0
- package/plugins/workflow-runner/test/maxTurnsRetryDelay.test.ts +33 -0
- package/plugins/workflow-runner/test/multimodal.test.ts +342 -0
- package/plugins/workflow-runner/test/output-schema.test.ts +213 -0
- package/plugins/workflow-runner/test/parseWorkflowArgs.test.ts +87 -0
- package/plugins/workflow-runner/test/pluginRunner.isolation.test.ts +269 -0
- package/plugins/workflow-runner/test/ppt.load.test.ts +1220 -0
- package/plugins/workflow-runner/test/ralphLoop.e2e.test.ts +220 -0
- package/plugins/workflow-runner/test/recovery.test.ts +265 -0
- package/plugins/workflow-runner/test/runner.test.ts +911 -0
- package/plugins/workflow-runner/test/runnerPreflight.test.ts +379 -0
- package/plugins/workflow-runner/test/skillTurnDone.test.ts +71 -0
- package/plugins/workflow-runner/test/stateLifecycle.test.ts +150 -0
- package/plugins/workflow-runner/test/stepPipeline.test.ts +114 -0
- package/plugins/workflow-runner/test/taskArbitration.test.ts +338 -0
- package/plugins/workflow-runner/test/taskIdentity.test.ts +237 -0
- package/plugins/workflow-runner/test/taskLifecycle.test.ts +270 -0
- package/plugins/workflow-runner/test/toolArtifactOverwrite.test.ts +221 -0
- package/plugins/workflow-runner/test/toolCapabilityBoundary.test.ts +29 -0
- package/plugins/workflow-runner/test/toolRuntimeIntegration.test.ts +168 -0
- package/plugins/workflow-runner/test/webppt.load.test.ts +250 -0
- package/plugins/workflow-runner/test/word.load.test.ts +208 -0
- package/plugins/workflow-runner/test/workflows.smoke.test.ts +76 -0
- package/plugins/workflow-runner/test/yamlGuardConditions.test.ts +207 -0
- package/skills/browser-automation/SKILL.md +9 -19
- package/skills/web-crawler/SKILL.md +9 -11
- package/src/askBridge.ts +249 -0
- package/src/bootstrap/cwdArg.js +10 -3
- package/src/bootstrap/cwdArg.ts +31 -0
- package/src/bootstrap/workingDir.ts +48 -0
- package/src/cli/args.js +70 -7
- package/src/cli/args.ts +146 -0
- package/src/cli/computerUse.js +185 -0
- package/src/cli/computerUse.ts +221 -0
- package/src/cli/configMenu.js +274 -202
- package/src/cli/configMenu.tsx +521 -0
- package/src/cli/memoryAccess.js +45 -0
- package/src/cli/memoryAccess.ts +53 -0
- package/src/cli/print.js +119 -5
- package/src/cli/print.ts +597 -0
- package/src/cli/quickModelSetup.js +60 -0
- package/src/cli/quickModelSetup.tsx +96 -0
- package/src/cli/streamJson.js +80 -4
- package/src/cli/streamJson.ts +433 -0
- package/src/cli/wizards/advisorWizard.js +1 -0
- package/src/cli/wizards/advisorWizard.tsx +195 -0
- package/src/cli/wizards/agentRuntimeWizard.js +84 -0
- package/src/cli/wizards/agentRuntimeWizard.tsx +134 -0
- package/src/cli/wizards/browserWizard.js +55 -0
- package/src/cli/wizards/browserWizard.tsx +77 -0
- package/src/cli/wizards/contextAdvisorWizard.js +84 -0
- package/src/cli/wizards/contextAdvisorWizard.tsx +124 -0
- package/src/cli/wizards/fieldForm.js +7 -4
- package/src/cli/wizards/fieldForm.tsx +250 -0
- package/src/cli/wizards/imageWizard.js +4 -5
- package/src/cli/wizards/imageWizard.tsx +96 -0
- package/src/cli/wizards/openRouterWizard.tsx +48 -0
- package/src/cli/wizards/providerPresets.js +1 -8
- package/src/cli/wizards/providerPresets.ts +106 -0
- package/src/cli/wizards/providerWizard.js +152 -205
- package/src/cli/wizards/providerWizard.tsx +266 -0
- package/src/cli/wizards/searchWizard.tsx +47 -0
- package/src/cli/wizards/ttsWizard.js +4 -3
- package/src/cli/wizards/ttsWizard.tsx +61 -0
- package/src/config/configDefaults.js +25 -0
- package/src/config/configDefaults.ts +33 -0
- package/src/config/configDiagnostics.js +117 -0
- package/src/config/configDiagnostics.ts +166 -0
- package/src/config/configFile.js +52 -32
- package/src/config/configFile.ts +633 -0
- package/src/config/configManagement.js +126 -0
- package/src/config/configManagement.ts +159 -0
- package/src/config/configService.js +66 -11
- package/src/config/configService.ts +554 -0
- package/src/config/numericLimits.js +61 -0
- package/src/config/numericLimits.ts +80 -0
- package/src/config.ts +109 -0
- package/src/context/agentHome.ts +11 -0
- package/src/context/archive.ts +144 -0
- package/src/context/budgetPlan.js +54 -0
- package/src/context/budgetPlan.ts +88 -0
- package/src/context/compact.js +179 -106
- package/src/context/compact.ts +584 -0
- package/src/context/contextBundle.js +119 -0
- package/src/context/contextBundle.ts +176 -0
- package/src/context/contextLock.ts +84 -0
- package/src/context/microCompactLite.ts +218 -0
- package/src/context/persistContext.ts +177 -0
- package/src/context/reactiveCompact.js +19 -4
- package/src/context/reactiveCompact.ts +240 -0
- package/src/context/recentDirs.ts +42 -0
- package/src/context/sessionPath.ts +206 -0
- package/src/context/sessionRegistry.js +8 -2
- package/src/context/sessionRegistry.ts +414 -0
- package/src/context/snipCompact.ts +163 -0
- package/src/context/tokenCounter.ts +106 -0
- package/src/context/workspaceIndex.js +2 -2
- package/src/context/workspaceIndex.ts +751 -0
- package/src/entry.compiled.tsx +20 -0
- package/src/harness/claimValidation.js +9 -0
- package/src/harness/claimValidation.ts +22 -0
- package/src/harness/evidenceLedger.js +92 -0
- package/src/harness/evidenceLedger.ts +96 -0
- package/src/harness/stallGuard.js +60 -0
- package/src/harness/stallGuard.ts +81 -0
- package/src/humanIntervention.js +129 -0
- package/src/humanIntervention.ts +216 -0
- package/src/infra/verification.ts +295 -0
- package/src/irreversible/rules.js +216 -0
- package/src/irreversible/rules.ts +261 -0
- package/src/llm/client.js +40 -3
- package/src/llm/client.ts +621 -0
- package/src/llm/promptCache.js +27 -0
- package/src/llm/promptCache.ts +41 -0
- package/src/llm/providers/anthropicFormat.js +41 -5
- package/src/llm/providers/anthropicFormat.ts +290 -0
- package/src/llm/providers/openaiFormat.js +186 -8
- package/src/llm/providers/openaiFormat.ts +428 -0
- package/src/loop.js +614 -63
- package/src/loop.ts +1454 -0
- package/src/main.js +67 -10
- package/src/main.tsx +344 -0
- package/src/memory/codec.js +204 -0
- package/src/memory/codec.ts +249 -0
- package/src/memory/constants.js +34 -0
- package/src/memory/constants.ts +50 -0
- package/src/memory/episodicMemory.js +684 -0
- package/src/memory/episodicMemory.ts +815 -0
- package/src/memory/fileStore.js +148 -0
- package/src/memory/fileStore.ts +184 -0
- package/src/memory/memoryService.js +570 -0
- package/src/memory/memoryService.ts +859 -0
- package/src/memory/migration.js +128 -0
- package/src/memory/migration.ts +160 -0
- package/src/memory/repository.js +789 -0
- package/src/memory/repository.ts +893 -0
- package/src/memory/retrieval.js +108 -0
- package/src/memory/retrieval.ts +145 -0
- package/src/memory/searchIndex.js +107 -0
- package/src/memory/searchIndex.ts +153 -0
- package/src/memory/topicView.js +82 -0
- package/src/memory/topicView.ts +95 -0
- package/src/memory/turnJournal.js +95 -0
- package/src/memory/turnJournal.ts +120 -0
- package/src/memory/types.js +2 -0
- package/src/memory/types.ts +186 -0
- package/src/messageQueue.ts +123 -0
- package/src/multimodal.js +128 -46
- package/src/multimodal.ts +349 -0
- package/src/plugin-sdk.js +21 -1
- package/src/plugin-sdk.ts +134 -0
- package/src/plugins/builtinPluginIds.js +47 -0
- package/src/plugins/builtinPluginIds.ts +51 -0
- package/src/plugins/builtinRegistry.ts +43 -0
- package/src/plugins/commandRouter.js +40 -26
- package/src/plugins/commandRouter.ts +261 -0
- package/src/plugins/hookEngine.ts +341 -0
- package/src/plugins/pluginApi.ts +133 -0
- package/src/plugins/pluginLifecycle.ts +34 -0
- package/src/plugins/pluginLoader.ts +147 -0
- package/src/plugins/pluginManifest.js +127 -0
- package/src/plugins/pluginManifest.ts +152 -0
- package/src/plugins/pluginRunner.js +47 -2
- package/src/plugins/pluginRunner.ts +207 -0
- package/src/plugins/transcript.ts +208 -0
- package/src/prompts/lint.js +169 -0
- package/src/prompts/lint.ts +220 -0
- package/src/prompts/pluginList.js +32 -16
- package/src/prompts/pluginList.ts +86 -0
- package/src/prompts/policyRegistry.js +318 -0
- package/src/prompts/policyRegistry.ts +358 -0
- package/src/prompts/projectInstructions.js +24 -0
- package/src/prompts/projectInstructions.ts +81 -0
- package/src/prompts/promptAssembly.js +311 -202
- package/src/prompts/promptAssembly.ts +510 -0
- package/src/prompts/skillList.js +106 -45
- package/src/prompts/skillList.ts +198 -0
- package/src/prompts/system.js +31 -6
- package/src/prompts/system.ts +81 -0
- package/src/runtime/agentRuntimeContext.js +53 -0
- package/src/runtime/agentRuntimeContext.ts +112 -0
- package/src/session/runAgentTurn.js +71 -12
- package/src/session/runAgentTurn.ts +181 -0
- package/src/session/runTurn.js +29 -0
- package/src/session/runTurn.ts +160 -0
- package/src/session/runtimeStore.js +149 -0
- package/src/session/runtimeStore.ts +197 -0
- package/src/session/sessionState.js +79 -3
- package/src/session/sessionState.ts +134 -0
- package/src/toolGate.ts +50 -0
- package/src/tools/advisor/advisor.js +76 -15
- package/src/tools/advisor/advisor.ts +512 -0
- package/src/tools/agent/agent.js +245 -29
- package/src/tools/agent/agent.ts +837 -0
- package/src/tools/agent/agentTaskService.js +60 -0
- package/src/tools/agent/agentTaskService.ts +113 -0
- package/src/tools/agent/agentTypes.js +20 -8
- package/src/tools/agent/agentTypes.ts +94 -0
- package/src/tools/agent/coordinator.ts +111 -0
- package/src/tools/agent/worktree.ts +296 -0
- package/src/tools/ask/ask.js +17 -0
- package/src/tools/ask/ask.ts +122 -0
- package/src/tools/bash/attachImage.js +223 -0
- package/src/tools/bash/attachImage.ts +281 -0
- package/src/tools/bash/bash.js +132 -14
- package/src/tools/bash/bash.ts +642 -0
- package/src/tools/bash/semantics.ts +103 -0
- package/src/tools/bash/warnings.js +17 -11
- package/src/tools/bash/warnings.ts +117 -0
- package/src/tools/capabilities.js +42 -0
- package/src/tools/capabilities.ts +69 -0
- package/src/tools/computeruse/accessibilityPermission.js +261 -0
- package/src/tools/computeruse/accessibilityPermission.ts +294 -0
- package/src/tools/computeruse/axSearch.js +96 -0
- package/src/tools/computeruse/axSearch.ts +120 -0
- package/src/tools/computeruse/axSnap.js +272 -0
- package/src/tools/computeruse/axSnap.ts +349 -0
- package/src/tools/computeruse/capabilityLabels.js +95 -0
- package/src/tools/computeruse/capabilityLabels.ts +115 -0
- package/src/tools/computeruse/computerUseService.js +2235 -0
- package/src/tools/computeruse/computerUseService.ts +2686 -0
- package/src/tools/computeruse/computeruse.js +2742 -0
- package/src/tools/computeruse/computeruse.ts +3265 -0
- package/src/tools/computeruse/diagnosticTrace.js +154 -0
- package/src/tools/computeruse/diagnosticTrace.ts +195 -0
- package/src/tools/computeruse/diagnostics.js +369 -0
- package/src/tools/computeruse/diagnostics.ts +453 -0
- package/src/tools/computeruse/grants.js +53 -0
- package/src/tools/computeruse/grants.ts +70 -0
- package/src/tools/computeruse/humanBoundary.js +159 -0
- package/src/tools/computeruse/humanBoundary.ts +199 -0
- package/src/tools/computeruse/intervention.js +77 -0
- package/src/tools/computeruse/intervention.ts +110 -0
- package/src/tools/computeruse/manualSchema.js +709 -0
- package/src/tools/computeruse/manualSchema.ts +916 -0
- package/src/tools/computeruse/observationImages.js +705 -0
- package/src/tools/computeruse/observationImages.ts +889 -0
- package/src/tools/computeruse/protocol.js +60 -0
- package/src/tools/computeruse/protocol.ts +515 -0
- package/src/tools/computeruse/telemetryLog.js +57 -0
- package/src/tools/computeruse/telemetryLog.ts +67 -0
- package/src/tools/computeruse/vision/appGuide.js +325 -0
- package/src/tools/computeruse/vision/appGuide.ts +482 -0
- package/src/tools/computeruse/vision/focus.js +291 -0
- package/src/tools/computeruse/vision/focus.ts +382 -0
- package/src/tools/computeruse/vision/frames.js +248 -0
- package/src/tools/computeruse/vision/frames.ts +329 -0
- package/src/tools/computeruse/vision/geometry.js +131 -0
- package/src/tools/computeruse/vision/geometry.ts +163 -0
- package/src/tools/computeruse/vision/imaging.js +201 -0
- package/src/tools/computeruse/vision/imaging.ts +281 -0
- package/src/tools/computeruse/vision/png.js +274 -0
- package/src/tools/computeruse/vision/png.ts +317 -0
- package/src/tools/computeruse/vision/raster.js +320 -0
- package/src/tools/computeruse/vision/raster.ts +408 -0
- package/src/tools/computeruse/vision/settle.js +131 -0
- package/src/tools/computeruse/vision/settle.ts +220 -0
- package/src/tools/computeruse/vision/telemetry.js +196 -0
- package/src/tools/computeruse/vision/telemetry.ts +241 -0
- package/src/tools/computeruse/visionOcr.js +115 -0
- package/src/tools/computeruse/visionOcr.ts +128 -0
- package/src/tools/computeruse/waitFor.js +237 -0
- package/src/tools/computeruse/waitFor.ts +291 -0
- package/src/tools/download/download.js +10 -6
- package/src/tools/download/download.ts +187 -0
- package/src/tools/edit/edit.js +30 -18
- package/src/tools/edit/edit.ts +349 -0
- package/src/tools/edit/multi-edit.js +25 -14
- package/src/tools/edit/multi-edit.ts +223 -0
- package/src/tools/effectiveToolSet.js +73 -0
- package/src/tools/effectiveToolSet.ts +91 -0
- package/src/tools/genimage/genimage.ts +257 -0
- package/src/tools/genspeech/genspeech.ts +83 -0
- package/src/tools/glob/glob.js +176 -29
- package/src/tools/glob/glob.ts +283 -0
- package/src/tools/grep/grep.js +61 -19
- package/src/tools/grep/grep.ts +239 -0
- package/src/tools/grep/rgPath.ts +206 -0
- package/src/tools/index.js +99 -5
- package/src/tools/index.ts +293 -0
- package/src/tools/lsp/config.js +113 -0
- package/src/tools/lsp/config.ts +113 -0
- package/src/tools/lsp/lsp.js +256 -0
- package/src/tools/lsp/lsp.ts +274 -0
- package/src/tools/lsp/service.js +303 -0
- package/src/tools/lsp/service.ts +296 -0
- package/src/tools/memory/memory.js +520 -0
- package/src/tools/memory/memory.ts +625 -0
- package/src/tools/memory/policy.js +53 -0
- package/src/tools/memory/policy.ts +72 -0
- package/src/tools/notebook/notebookEdit.js +114 -0
- package/src/tools/notebook/notebookEdit.ts +126 -0
- package/src/tools/powershell/powershell.js +210 -0
- package/src/tools/powershell/powershell.ts +239 -0
- package/src/tools/presentresult/presentresult.js +145 -0
- package/src/tools/presentresult/presentresult.ts +156 -0
- package/src/tools/read/read.js +371 -163
- package/src/tools/read/read.ts +558 -0
- package/src/tools/shared/diffSummary.js +44 -0
- package/src/tools/shared/diffSummary.ts +63 -0
- package/src/tools/shared/fileActivity.js +51 -0
- package/src/tools/shared/fileActivity.ts +66 -0
- package/src/tools/shared/fileMutationBus.js +13 -0
- package/src/tools/shared/fileMutationBus.ts +14 -0
- package/src/tools/shared/fileState.js +73 -65
- package/src/tools/shared/fileState.ts +145 -0
- package/src/tools/shared/fileUtils.js +81 -4
- package/src/tools/shared/fileUtils.ts +504 -0
- package/src/tools/shared/killTree.ts +50 -0
- package/src/tools/shared/permanentDeleteGuard.js +26 -0
- package/src/tools/shared/permanentDeleteGuard.ts +34 -0
- package/src/tools/shared/schemas.ts +20 -0
- package/src/tools/shared/toolOutputStore.js +97 -0
- package/src/tools/shared/toolOutputStore.ts +110 -0
- package/src/tools/skill/skill.js +86 -0
- package/src/tools/skill/skill.ts +94 -0
- package/src/tools/snip/snip.js +67 -0
- package/src/tools/snip/snip.ts +80 -0
- package/src/tools/tasks/backgroundTaskService.js +275 -0
- package/src/tools/tasks/backgroundTaskService.ts +369 -0
- package/src/tools/tasks/processEvidence.js +24 -0
- package/src/tools/tasks/processEvidence.ts +34 -0
- package/src/tools/tasks/taskManagement.js +163 -0
- package/src/tools/tasks/taskManagement.ts +180 -0
- package/src/tools/tasks/taskOutput.js +113 -0
- package/src/tools/tasks/taskOutput.ts +145 -0
- package/src/tools/tasks/taskStop.js +74 -0
- package/src/tools/tasks/taskStop.ts +99 -0
- package/src/tools/tasks/taskStore.js +46 -0
- package/src/tools/tasks/taskStore.ts +77 -0
- package/src/tools/terminal/terminalCapture.js +167 -0
- package/src/tools/terminal/terminalCapture.ts +179 -0
- package/src/tools/trash/trash.js +233 -0
- package/src/tools/trash/trash.ts +283 -0
- package/src/tools/types.js +1 -1
- package/src/tools/types.ts +24 -0
- package/src/tools/webbrowser/agentBrowserPath.ts +286 -0
- package/src/tools/webbrowser/browser.js +214 -11
- package/src/tools/webbrowser/browser.ts +293 -0
- package/src/tools/webbrowser/browserControl.js +153 -48
- package/src/tools/webbrowser/browserControl.ts +262 -0
- package/src/tools/webbrowser/browserDaemon.js +147 -39
- package/src/tools/webbrowser/browserDaemon.ts +270 -0
- package/src/tools/webbrowser/browserOutcome.js +273 -0
- package/src/tools/webbrowser/browserOutcome.ts +306 -0
- package/src/tools/webbrowser/browserRunRegistry.js +150 -0
- package/src/tools/webbrowser/browserRunRegistry.ts +179 -0
- package/src/tools/webbrowser/browserService.js +20 -6
- package/src/tools/webbrowser/browserService.ts +56 -0
- package/src/tools/webbrowser/browserStream.js +30 -1
- package/src/tools/webbrowser/browserStream.ts +216 -0
- package/src/tools/webbrowser/browserTabs.js +143 -0
- package/src/tools/webbrowser/browserTabs.ts +210 -0
- package/src/tools/webbrowser/webbrowser.js +831 -150
- package/src/tools/webbrowser/webbrowser.ts +1537 -0
- package/src/tools/webfetch/preapproved.ts +274 -0
- package/src/tools/webfetch/webfetch.js +24 -23
- package/src/tools/webfetch/webfetch.ts +383 -0
- package/src/tools/websearch/websearch.js +12 -11
- package/src/tools/websearch/websearch.ts +292 -0
- package/src/tools/worktree/sessionWorktree.js +128 -0
- package/src/tools/worktree/sessionWorktree.ts +158 -0
- package/src/tools/write/write.js +27 -44
- package/src/tools/write/write.ts +136 -0
- package/src/types.ts +960 -0
- package/src/ui/App.js +216 -12
- package/src/ui/App.tsx +879 -0
- package/src/ui/AskQuestion.tsx +300 -0
- package/src/ui/InputBox.js +77 -1
- package/src/ui/InputBox.tsx +567 -0
- package/src/ui/LiveArea.tsx +344 -0
- package/src/ui/MessageList.js +27 -6
- package/src/ui/MessageList.tsx +559 -0
- package/src/ui/ModelPicker.tsx +107 -0
- package/src/ui/QueuedMessagesBanner.tsx +51 -0
- package/src/ui/Root.js +6 -8
- package/src/ui/Root.tsx +100 -0
- package/src/ui/SessionPicker.tsx +169 -0
- package/src/ui/StatusLine.js +22 -1
- package/src/ui/StatusLine.tsx +145 -0
- package/src/ui/WorkspacePicker.tsx +84 -0
- package/src/ui/advisorCommand.js +54 -0
- package/src/ui/advisorCommand.ts +63 -0
- package/src/ui/computerCommand.js +19 -0
- package/src/ui/computerCommand.ts +35 -0
- package/src/ui/figures.ts +45 -0
- package/src/ui/hooks/askSlot.ts +112 -0
- package/src/ui/hooks/useChat.js +271 -7
- package/src/ui/hooks/useChat.ts +1578 -0
- package/src/ui/hooks/useInputHistory.ts +235 -0
- package/src/ui/hooks/usePasteHandler.ts +220 -0
- package/src/ui/hooks/useTerminalSize.ts +41 -0
- package/src/ui/hooks/useTextBuffer.ts +108 -0
- package/src/ui/hooks/useTokenUsage.ts +44 -0
- package/src/ui/liveViewport.ts +189 -0
- package/src/ui/markdown.ts +230 -0
- package/src/ui/textBuffer.ts +239 -0
- package/src/ui/theme.ts +35 -0
- package/src/utils/clipboardImage.js +358 -0
- package/src/utils/clipboardImage.ts +420 -0
- package/src/utils/debugLog.ts +50 -0
- package/src/utils/greenRoot.ts +35 -0
- package/src/utils/packageRoot.ts +40 -0
- package/src/utils/pathContains.js +28 -0
- package/src/utils/pathContains.ts +31 -0
- package/src/utils/resourcePaths.ts +71 -0
- package/src/utils/stripThink.ts +49 -0
- package/src/utils/zodToJson.ts +73 -0
- package/src/web/browserBridge.js +365 -66
- package/src/web/browserBridge.ts +672 -0
- package/src/web/protocol.ts +1804 -0
- package/vendor/computer-use/arm64-darwin/cu-helperd +0 -0
- package/workflows/ppt.yaml +13 -2
- package/workflows/wechat-reading-shots.yaml +315 -0
- package/workflows/word.yaml +11 -1
- package/skills/docx/scripts/office/helpers/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/merge_runs.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/simplify_redlines.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/base.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/docx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/pptx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/redlining.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/__pycache__/image_stats.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/__pycache__/image_stats_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/chart_sanity_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_language_policy.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact_pptx_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/draft_coverage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/scaffold_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/text_readability_pixel.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate_test.cpython-314.pyc +0 -0
- /package/skills/ai-image/scripts/{generate_test.mjs → generate.selftest.mjs} +0 -0
- /package/skills/ai-image/scripts/{generate_from_plan_test.mjs → generate_from_plan.selftest.mjs} +0 -0
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* plugins/workflow-runner/src/types.ts —— workflow runner 核心类型
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 外层确定性 step 列表驱动执行,LLM 只在 llm: / skill: / agent: 节点出场。
|
|
6
|
+
* 后的内存形态(WorkflowDef / StepDef),以及运行时上下文(VarStack /
|
|
7
|
+
* RunContext)和 UI 事件(WorkflowEvent)。
|
|
8
|
+
*
|
|
9
|
+
* 与 src/types.ts 关系:WorkflowEvent 是插件**私有**事件,结构上满足
|
|
10
|
+
* framework 的 PluginEvent 开放契约(type: string + 任意 payload),
|
|
11
|
+
* 经 plugin.ts -> pluginRunner 原样透传给 UI;UI 不识别即静默忽略。
|
|
12
|
+
* src/types.ts 的 LoopEvent union **不**包含 workflow_*,框架零插件耦合。
|
|
13
|
+
* ============================================================
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
ImageDetail,
|
|
18
|
+
Message,
|
|
19
|
+
PluginContext,
|
|
20
|
+
Provider,
|
|
21
|
+
SessionState,
|
|
22
|
+
Tool,
|
|
23
|
+
ToolCallContext,
|
|
24
|
+
} from '../../../src/plugin-sdk.js';
|
|
25
|
+
|
|
26
|
+
// ---------------- 1. Workflow / Step 定义 ----------------
|
|
27
|
+
|
|
28
|
+
export type InputType = 'string' | 'number' | 'enum';
|
|
29
|
+
|
|
30
|
+
export interface InputDef {
|
|
31
|
+
name: string;
|
|
32
|
+
type: InputType;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
default?: unknown;
|
|
35
|
+
/** type=enum 时必填 */
|
|
36
|
+
values?: string[];
|
|
37
|
+
description?: string;
|
|
38
|
+
/**
|
|
39
|
+
* 贪婪首参(只许标在 inputs[0]):命令行里名称之后的【全部】位置参数用空格 join
|
|
40
|
+
* 成整句写进这个 input,不再逐位 posN↔inputs[N] 映射。让用户「打一句话自然语言」
|
|
41
|
+
* 即可(句子里的空格不会被拆碎、也不会撞上后面的 number/enum 输入)。其余 input
|
|
42
|
+
* 只接受 --input k=v。无 greedy 时保持严格 1:1 映射(见 index.ts::runWorkflowFromCommand)。
|
|
43
|
+
*/
|
|
44
|
+
greedy?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type StepKind =
|
|
48
|
+
| 'tool'
|
|
49
|
+
| 'llm'
|
|
50
|
+
| 'skill'
|
|
51
|
+
| 'agent'
|
|
52
|
+
| 'assert'
|
|
53
|
+
| 'verify'
|
|
54
|
+
| 'set'
|
|
55
|
+
| 'branch'
|
|
56
|
+
| 'loop'
|
|
57
|
+
| 'break'
|
|
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
|
+
|
|
122
|
+
/**
|
|
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 **响亮报错**,而不是跑到一半才发现。
|
|
135
|
+
*
|
|
136
|
+
* 为什么不默认全给:工作流是**无人值守**跑的。给一份 yaml 隐式的完整机器控制权,
|
|
137
|
+
* 等于让任何人写的脚本都能在没人看着的时候点任何东西。显式声明还有个副作用是
|
|
138
|
+
* 好的 —— yaml 自文档化,读一眼就知道哪些步会碰这台机器。
|
|
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 等不应污染后续上下文的步骤。
|
|
171
|
+
*/
|
|
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
|
+
artifacts?: string[];
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 自愈:此步骤失败时的额外 in-run 重试次数(总尝试 = 1 + max_retries)。
|
|
261
|
+
* 缺省继承 WorkflowDef.self_heal.max_retries(经 RunContext.selfHealMaxRetries)。
|
|
262
|
+
* runner 已实装:失败先确定性重跑同一步,retry 用尽才落 onError(recover/continue/halt)。
|
|
263
|
+
*/
|
|
264
|
+
max_retries?: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface WorkflowDef {
|
|
268
|
+
name: string;
|
|
269
|
+
description: string;
|
|
270
|
+
version?: string;
|
|
271
|
+
inputs?: InputDef[];
|
|
272
|
+
steps: StepDef[];
|
|
273
|
+
/** 编辑器布局信息;runner 严格忽略 */
|
|
274
|
+
__meta?: unknown;
|
|
275
|
+
/** loader 写入:yaml 来源(cwd / packageRoot),便于排错 */
|
|
276
|
+
__source?: string;
|
|
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[];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ---------------- 2. 变量栈(loop scope 用) ----------------
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 简单的多帧变量栈:
|
|
318
|
+
* - 最外层(frame 0)放 inputs + 全局变量
|
|
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
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* 把 yaml 的 capture 归一化成 { resultField: varName } map。支持两种写法
|
|
405
|
+
* (通用 DSL,根治「裸字符串 capture 被 Object.entries/values 迭代成单字符」的静默 footgun):
|
|
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;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// ---------------- 3. 运行上下文 ----------------
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* runner 内部传递的运行时上下文。
|
|
425
|
+
*
|
|
426
|
+
* 设计:不让 step executors 直接拿 PluginRunnerOptions,避免把"插件运行机制"
|
|
427
|
+
* 暴露到 workflow 层。RunContext 只暴露 executors 真正需要的东西。
|
|
428
|
+
*/
|
|
429
|
+
export interface RunContext {
|
|
430
|
+
provider: Provider;
|
|
431
|
+
runtimeContext?: import('../../../src/plugin-sdk.js').AgentRuntimeContext;
|
|
432
|
+
signal?: AbortSignal;
|
|
433
|
+
/**
|
|
434
|
+
* 宿主授权上下文。**按 `StepDef.uses` 切片后**才转给工具,不整份下发。
|
|
435
|
+
* 切片逻辑在 `stepExecutors/tool.ts::hostContextFor`(单一出处)。
|
|
436
|
+
*/
|
|
437
|
+
host?: import('../../../src/plugin-sdk.js').PluginContext['host'];
|
|
438
|
+
/** 当前工作目录(用于 skill/plugin 扫描和文件操作) */
|
|
439
|
+
cwd: string;
|
|
440
|
+
/**
|
|
441
|
+
* 可用工具列表。
|
|
442
|
+
* agent/llm/skill 与确定性 tool 步都以此列表为宿主授权上限。
|
|
443
|
+
* plugin.ts 先按 runtime 和父宿主白名单过滤,再把同一列表交给提示词、
|
|
444
|
+
* Schema 和真实执行,任何工作流节点都不能从 ALL_TOOLS 恢复隐藏能力。
|
|
445
|
+
*/
|
|
446
|
+
tools: Tool[];
|
|
447
|
+
transientContext?: string;
|
|
448
|
+
transientBundle?: import('../../../src/plugin-sdk.js').ContextBundle;
|
|
449
|
+
promptCache?: import('../../../src/plugin-sdk.js').PromptCacheContext;
|
|
450
|
+
/**
|
|
451
|
+
* 共享 TAOR history 引用(来自 pluginRunner.runWithPlugins 的 baseHistory)。
|
|
452
|
+
*
|
|
453
|
+
* v0.9 起:agent/llm/skill/recover 步通过 runQuery(TAOR) 写入此 history。
|
|
454
|
+
* v0.9 后:agent/llm/skill 步通过 runQuery 直接写入此 history,
|
|
455
|
+
* 实现上下文自然积累——workflow 每步执行过程对后续对话完全可见。
|
|
456
|
+
*/
|
|
457
|
+
history: Message[];
|
|
458
|
+
/**
|
|
459
|
+
* 工作流总目标(= WorkflowDef.description),由 runWorkflow 注入。
|
|
460
|
+
* 仅 onError:'recover' 的恢复 agent 用,给它「这条工作流到底想干什么」的大局观。
|
|
461
|
+
*/
|
|
462
|
+
goal?: string;
|
|
463
|
+
/**
|
|
464
|
+
* 通用目标锚定字符串(由 runWorkflow 从 inputs 中自动提取)。
|
|
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}`。
|
|
474
|
+
*
|
|
475
|
+
* 为空时(无 string 类型 inputs / 无法识别目标)executor 自动跳过注入。
|
|
476
|
+
*/
|
|
477
|
+
goalAnchor?: string;
|
|
478
|
+
/**
|
|
479
|
+
* 用户补充要求(贯穿目标的活载体)。来源三类,引擎自动累加:
|
|
480
|
+
* 1. pause 审批闸门的自由输入(free_text:'approve' 放行 + 非空反馈)
|
|
481
|
+
* 2. 声明 goal_supplement:true 的步骤产出(如 stage0 澄清问答结论)
|
|
482
|
+
* 3. 仲裁延续 resume 时的新输入(「继续,但改成 12 页」的修改意见)
|
|
483
|
+
* 渲染:agentCommon.effectiveGoalAnchor 把它们以「📌 用户补充要求」逐条
|
|
484
|
+
* 追加在 goalAnchor 之后注入每步 prompt——补充要求与原始目标同等贯穿始终。
|
|
485
|
+
* 持久化:runner 同步写状态目录 supplements.json,跨进程 resume 不丢。
|
|
486
|
+
*/
|
|
487
|
+
goalSupplements?: string[];
|
|
488
|
+
/**
|
|
489
|
+
* DI:chat 实现(仅测试用)。生产不传 → runQuery 用默认 llm/client.ts。
|
|
490
|
+
* 测试传 stub → 零污染 mock。
|
|
491
|
+
*/
|
|
492
|
+
chat?: (args: {
|
|
493
|
+
provider: import('../../../src/plugin-sdk.js').Provider;
|
|
494
|
+
messages: import('../../../src/plugin-sdk.js').Message[];
|
|
495
|
+
tools: import('../../../src/plugin-sdk.js').Tool[];
|
|
496
|
+
signal?: AbortSignal;
|
|
497
|
+
promptCache?: import('../../../src/plugin-sdk.js').PromptCacheContext;
|
|
498
|
+
}) => AsyncGenerator<
|
|
499
|
+
import('../../../src/plugin-sdk.js').LlmStreamEvent,
|
|
500
|
+
void,
|
|
501
|
+
undefined
|
|
502
|
+
>;
|
|
503
|
+
/**
|
|
504
|
+
* DI:executeTool 实现(仅测试用)。同上。
|
|
505
|
+
*/
|
|
506
|
+
executeTool?: PluginContext['executeTool'];
|
|
507
|
+
/**
|
|
508
|
+
* Canonical non-model-visible context shared by deterministic tool nodes.
|
|
509
|
+
* Browser/computer capabilities are deliberately excluded here and are only
|
|
510
|
+
* added by the step-level `uses` slicer.
|
|
511
|
+
*/
|
|
512
|
+
toolContext?: Omit<
|
|
513
|
+
ToolCallContext,
|
|
514
|
+
| 'browserRun'
|
|
515
|
+
| 'computerRun'
|
|
516
|
+
| 'computerIntervention'
|
|
517
|
+
| 'reportProgress'
|
|
518
|
+
| 'toolCallId'
|
|
519
|
+
| 'cwd'
|
|
520
|
+
>;
|
|
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
|
+
}
|
|
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> };
|