minimal-agent 0.13.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 +60 -4
- 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 +197 -206
- package/plugins/workflow-runner/src/index.ts +248 -249
- 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 +400 -489
- package/plugins/workflow-runner/src/runner.ts +488 -560
- 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 +151 -307
- package/plugins/workflow-runner/src/taskIdentity.ts +207 -355
- 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 -211
- package/plugins/workflow-runner/src/types.ts +154 -623
- 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 +474 -802
- package/plugins/workflow-runner/src/workflowState.ts +575 -970
- 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/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 +27 -6
- package/src/cli/print.ts +48 -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 +419 -74
- package/src/config/configService.ts +703 -145
- 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 +34 -5
- package/src/infra/verification.ts +39 -4
- 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 +139 -7
- package/src/plugins/pluginRunner.ts +173 -9
- package/src/plugins/slashFallback.js +113 -0
- package/src/plugins/slashFallback.ts +137 -0
- package/src/prompts/policyRegistry.js +12 -32
- package/src/prompts/policyRegistry.ts +15 -32
- 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 +90 -46
- package/src/tools/advisor/advisor.ts +100 -47
- 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 +22 -15
- package/src/tools/bash/bash.ts +23 -17
- 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/presentresult/presentresult.js +6 -15
- package/src/tools/presentresult/presentresult.ts +6 -15
- package/src/tools/read/read.js +62 -9
- package/src/tools/read/read.ts +63 -9
- package/src/tools/shared/fileUtils.js +1 -2
- package/src/tools/shared/fileUtils.ts +1 -2
- 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 -34
- package/src/tools/webbrowser/browserControl.ts +210 -56
- 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 +679 -144
- package/src/tools/webbrowser/webbrowser.ts +975 -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 +440 -38
- 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/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 -639
- package/plugins/workflow-runner/src/expressions.ts +0 -640
- 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 -126
- package/plugins/workflow-runner/src/recovery.ts +0 -156
- 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 -42
- package/plugins/workflow-runner/src/stepExecutors/assert.ts +0 -52
- 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 -227
- package/plugins/workflow-runner/src/stepExecutors/tool.ts +0 -274
- package/plugins/workflow-runner/src/stepExecutors/verify.js +0 -61
- package/plugins/workflow-runner/src/stepExecutors/verify.ts +0 -72
- 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 -167
- 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/e2eNewLayout.test.ts +0 -314
- package/plugins/workflow-runner/test/engineRobustness.test.ts +0 -234
- package/plugins/workflow-runner/test/expressions.test.ts +0 -439
- 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 -106
- 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 -221
- package/plugins/workflow-runner/test/recovery.test.ts +0 -265
- package/plugins/workflow-runner/test/research.load.test.ts +0 -328
- package/plugins/workflow-runner/test/runner.test.ts +0 -911
- package/plugins/workflow-runner/test/runnerPreflight.test.ts +0 -436
- package/plugins/workflow-runner/test/skillTurnDone.test.ts +0 -71
- package/plugins/workflow-runner/test/stateLifecycle.test.ts +0 -198
- package/plugins/workflow-runner/test/stepPipeline.test.ts +0 -114
- package/plugins/workflow-runner/test/taskArbitration.test.ts +0 -354
- package/plugins/workflow-runner/test/taskLifecycle.test.ts +0 -324
- 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 -201
- package/workflows/research.yaml +0 -873
- 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
- /package/workflows/{research.md → research/DESIGN.md} +0 -0
package/src/types.ts
CHANGED
|
@@ -73,6 +73,19 @@ export interface ImageInputSpec {
|
|
|
73
73
|
maxLongSidePixel?: number;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** Host-authorized file supplied for the current workflow invocation. */
|
|
77
|
+
export interface InvocationResource {
|
|
78
|
+
id: string;
|
|
79
|
+
origin: 'path' | 'attachment';
|
|
80
|
+
name: string;
|
|
81
|
+
mime: string;
|
|
82
|
+
size?: number;
|
|
83
|
+
sha256?: string;
|
|
84
|
+
localPath: string;
|
|
85
|
+
visionPath?: string;
|
|
86
|
+
kind: 'file' | 'directory';
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
/**
|
|
77
90
|
* 用户消息关联的附件展示元数据。
|
|
78
91
|
*
|
|
@@ -105,6 +118,18 @@ export interface MessageBrowserReference {
|
|
|
105
118
|
capturedAt: number;
|
|
106
119
|
}
|
|
107
120
|
|
|
121
|
+
/** Local-only origin metadata used to keep one Session safe across private and group turns. */
|
|
122
|
+
export interface ConversationProvenance {
|
|
123
|
+
mode: 'private' | 'group';
|
|
124
|
+
visibility: 'owner-private' | 'group-public';
|
|
125
|
+
groupId?: string;
|
|
126
|
+
groupMessageId?: string;
|
|
127
|
+
senderId?: string;
|
|
128
|
+
senderName?: string;
|
|
129
|
+
taskId?: string;
|
|
130
|
+
grantId?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
108
133
|
/**
|
|
109
134
|
* 所有 Message variant 共享的可选字段。
|
|
110
135
|
*
|
|
@@ -124,8 +149,7 @@ export type Message = (
|
|
|
124
149
|
*
|
|
125
150
|
* - saveContext(persistContext.ts)写盘前过滤掉 _ephemeral=true 的 system 消息
|
|
126
151
|
* - MessageList 识别此标记走暗灰单行样式(其他 system 消息保持 hide)
|
|
127
|
-
* -
|
|
128
|
-
* - 已知限制:本期 LLM 收到 ephemeral 消息(不影响功能,仅噪声)
|
|
152
|
+
* - provider 请求(包括本地与团队网关)会过滤掉这类消息
|
|
129
153
|
*/
|
|
130
154
|
_ephemeral?: true;
|
|
131
155
|
}
|
|
@@ -168,6 +192,8 @@ export type Message = (
|
|
|
168
192
|
tool_call_id: string;
|
|
169
193
|
/** 本地展示元数据;发送 Provider 前会剥离。 */
|
|
170
194
|
display_metadata?: ToolResultMetadata;
|
|
195
|
+
/** 本地压缩策略;发送 Provider 前会剥离。 */
|
|
196
|
+
tool_result_policy?: ToolResultPolicy;
|
|
171
197
|
timestamp?: number;
|
|
172
198
|
}
|
|
173
199
|
) & {
|
|
@@ -177,6 +203,8 @@ export type Message = (
|
|
|
177
203
|
* - 不发给 LLM:client.ts 在发送给 LLM 序列化消息前自动剔除。
|
|
178
204
|
*/
|
|
179
205
|
id?: string;
|
|
206
|
+
/** Persisted locally, rendered as a trusted label for the model, never sent as a raw provider field. */
|
|
207
|
+
provenance?: ConversationProvenance;
|
|
180
208
|
};
|
|
181
209
|
|
|
182
210
|
// ---------------- 2. 工具 (Tool) ----------------
|
|
@@ -213,7 +241,12 @@ export interface AgentResultMetadata {
|
|
|
213
241
|
};
|
|
214
242
|
}
|
|
215
243
|
|
|
216
|
-
export type FileActivityKind =
|
|
244
|
+
export type FileActivityKind =
|
|
245
|
+
| 'read'
|
|
246
|
+
| 'created'
|
|
247
|
+
| 'modified'
|
|
248
|
+
| 'generated'
|
|
249
|
+
| 'deleted';
|
|
217
250
|
export type FileVerification = 'passed' | 'failed' | 'not_run';
|
|
218
251
|
export type ConversationFilePurpose = 'source' | 'deliverable' | 'support';
|
|
219
252
|
export interface FilePatchSummary {
|
|
@@ -257,7 +290,11 @@ export interface DeliverableManifest {
|
|
|
257
290
|
purpose: 'deliverable';
|
|
258
291
|
}>;
|
|
259
292
|
links?: Array<{ url: string; title?: string }>;
|
|
260
|
-
browserEvidence?: Array<{
|
|
293
|
+
browserEvidence?: Array<{
|
|
294
|
+
tabId: string;
|
|
295
|
+
url: string;
|
|
296
|
+
screenshotId?: string;
|
|
297
|
+
}>;
|
|
261
298
|
warnings: string[];
|
|
262
299
|
}
|
|
263
300
|
|
|
@@ -277,8 +314,18 @@ export interface ResultManifestMetadata {
|
|
|
277
314
|
manifest: DeliverableManifest;
|
|
278
315
|
}
|
|
279
316
|
|
|
280
|
-
export type ProcessCommandKind =
|
|
281
|
-
|
|
317
|
+
export type ProcessCommandKind =
|
|
318
|
+
| 'test'
|
|
319
|
+
| 'typecheck'
|
|
320
|
+
| 'build'
|
|
321
|
+
| 'check'
|
|
322
|
+
| 'other';
|
|
323
|
+
export type ProcessExecutionStatus =
|
|
324
|
+
| 'started'
|
|
325
|
+
| 'running'
|
|
326
|
+
| 'completed'
|
|
327
|
+
| 'failed'
|
|
328
|
+
| 'stopped';
|
|
282
329
|
|
|
283
330
|
/** Structured process state shared by Bash, PowerShell, TaskOutput and the evidence ledger. */
|
|
284
331
|
export interface ProcessExecutionMetadata {
|
|
@@ -291,10 +338,55 @@ export interface ProcessExecutionMetadata {
|
|
|
291
338
|
exitCode?: number | null;
|
|
292
339
|
}
|
|
293
340
|
|
|
341
|
+
export type AdvisorCheckpoint =
|
|
342
|
+
| 'pre-execution'
|
|
343
|
+
| 'stalled'
|
|
344
|
+
| 'high-risk'
|
|
345
|
+
| 'pre-delivery';
|
|
346
|
+
|
|
347
|
+
export interface AdvisorVersions {
|
|
348
|
+
taskVersion: number;
|
|
349
|
+
workVersion: number;
|
|
350
|
+
evidenceVersion: number;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface AdvisorCheckpointMetadata extends AdvisorVersions {
|
|
354
|
+
kind: 'advisor_checkpoint';
|
|
355
|
+
checkpoint: AdvisorCheckpoint;
|
|
356
|
+
checkpointKey: string;
|
|
357
|
+
status: 'required' | 'attempted-unavailable';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface AdvisorConsultationMetadata extends AdvisorVersions {
|
|
361
|
+
kind: 'advisor_consultation';
|
|
362
|
+
consultationId: string;
|
|
363
|
+
checkpoint: AdvisorCheckpoint;
|
|
364
|
+
checkpointKey: string;
|
|
365
|
+
status: 'completed' | 'failed';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface AdvisorDecisionMetadata extends AdvisorVersions {
|
|
369
|
+
kind: 'advisor_decision';
|
|
370
|
+
consultationId: string;
|
|
371
|
+
checkpoint: AdvisorCheckpoint;
|
|
372
|
+
checkpointKey: string;
|
|
373
|
+
decision: 'accept' | 'partial' | 'reject';
|
|
374
|
+
rationale: string;
|
|
375
|
+
acceptedPoints: string[];
|
|
376
|
+
rejectedPoints: string[];
|
|
377
|
+
verificationPlan: string[];
|
|
378
|
+
}
|
|
379
|
+
|
|
294
380
|
/** Agent 子任务的结构化阶段进度;仅供宿主展示,不写入会话历史或发送给 LLM。 */
|
|
295
381
|
export interface SubagentProgress {
|
|
296
382
|
kind: 'subagent';
|
|
297
|
-
phase:
|
|
383
|
+
phase:
|
|
384
|
+
| 'queued'
|
|
385
|
+
| 'preparing'
|
|
386
|
+
| 'analyzing'
|
|
387
|
+
| 'using_tool'
|
|
388
|
+
| 'drafting'
|
|
389
|
+
| 'waiting_owner';
|
|
298
390
|
queuePosition?: number;
|
|
299
391
|
activeCount?: number;
|
|
300
392
|
maxConcurrent?: number;
|
|
@@ -306,32 +398,73 @@ export interface SubagentProgress {
|
|
|
306
398
|
|
|
307
399
|
export type ToolProgressDetail = SubagentProgress;
|
|
308
400
|
|
|
401
|
+
/** A browser download lives under the agent state root, not the workspace. */
|
|
402
|
+
export interface BrowserDownloadMetadata {
|
|
403
|
+
kind: 'browser_download';
|
|
404
|
+
downloads: Array<{
|
|
405
|
+
id: string;
|
|
406
|
+
url: string;
|
|
407
|
+
filename: string;
|
|
408
|
+
path: string;
|
|
409
|
+
state: 'start' | 'progress' | 'complete' | 'failed' | 'canceled';
|
|
410
|
+
mime?: string;
|
|
411
|
+
receivedBytes?: number;
|
|
412
|
+
totalBytes?: number;
|
|
413
|
+
error?: string;
|
|
414
|
+
}>;
|
|
415
|
+
/** Present when the batch requested `artifact.save_as`; the download is
|
|
416
|
+
* copied into the workspace and can be committed by the host as a normal
|
|
417
|
+
* conversation delivery. */
|
|
418
|
+
artifact?: DeliverableManifest;
|
|
419
|
+
}
|
|
420
|
+
|
|
309
421
|
export type ToolResultMetadata =
|
|
310
422
|
| AgentResultMetadata
|
|
311
423
|
| FileActivityMetadata
|
|
312
424
|
| FileDiscoveryMetadata
|
|
313
425
|
| ResultManifestMetadata
|
|
314
|
-
| ProcessExecutionMetadata
|
|
426
|
+
| ProcessExecutionMetadata
|
|
427
|
+
| AdvisorCheckpointMetadata
|
|
428
|
+
| AdvisorConsultationMetadata
|
|
429
|
+
| AdvisorDecisionMetadata
|
|
430
|
+
| BrowserDownloadMetadata;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* 本地工具结果压缩策略;只用于 history 决策和 UI 诊断,发送 provider 前剥离。
|
|
434
|
+
* highValue 优先级高于 reclaimable:高价值结果不会被 Path C 回收或中段截断。
|
|
435
|
+
*/
|
|
436
|
+
export interface ToolResultPolicy {
|
|
437
|
+
reclaimable: boolean;
|
|
438
|
+
highValue: boolean;
|
|
439
|
+
archiveRef?: string;
|
|
440
|
+
originalChars?: number;
|
|
441
|
+
}
|
|
315
442
|
|
|
316
443
|
export type ToolResult =
|
|
317
444
|
| {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
445
|
+
ok: true;
|
|
446
|
+
content: string;
|
|
447
|
+
metadata?: ToolResultMetadata;
|
|
448
|
+
/** 可选的本地上下文压缩策略;未提供时由工具名策略兜底。 */
|
|
449
|
+
policy?: ToolResultPolicy;
|
|
450
|
+
recovery?: 'none' | 'retry' | 'change-input' | 'user-action';
|
|
451
|
+
sensitivity?: 'public' | 'local' | 'sensitive';
|
|
452
|
+
visionImages?: ImageInputSpec[];
|
|
453
|
+
visionNote?: string;
|
|
454
|
+
}
|
|
326
455
|
| {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
456
|
+
ok: false;
|
|
457
|
+
error: string;
|
|
458
|
+
/** deferred 是宿主检查点暂缓,不是工具失败;失败统计与 stall guard 必须忽略。 */
|
|
459
|
+
disposition?: 'error' | 'deferred';
|
|
460
|
+
metadata?: ToolResultMetadata;
|
|
461
|
+
/** 可选的本地上下文压缩策略;未提供时由工具名策略兜底。 */
|
|
462
|
+
policy?: ToolResultPolicy;
|
|
463
|
+
recovery?: 'none' | 'retry' | 'change-input' | 'user-action';
|
|
464
|
+
sensitivity?: 'public' | 'local' | 'sensitive';
|
|
465
|
+
visionImages?: ImageInputSpec[];
|
|
466
|
+
visionNote?: string;
|
|
467
|
+
};
|
|
335
468
|
|
|
336
469
|
// visionImages:工具想让(视觉)模型「亲眼看一下」的图像(如浏览器关键节点实况截图)。
|
|
337
470
|
// 主循环在回填工具结果后,把它们组装成一条带图的 user 消息喂给模型自我核验(见 loop.ts)。
|
|
@@ -364,6 +497,8 @@ export interface ToolCallContext {
|
|
|
364
497
|
advisorCalls?: { used: number; max: number };
|
|
365
498
|
/** 区分主模型自动咨询与用户显式 /advisor ask。 */
|
|
366
499
|
advisorInvocation?: 'agent' | 'manual';
|
|
500
|
+
/** Advisor 协调器运行时桥;只存在于主循环,不暴露给模型或持久化。 */
|
|
501
|
+
advisorRuntime?: AdvisorRuntimeBridge;
|
|
367
502
|
/**
|
|
368
503
|
* 主循环使用的 provider —— Agent 等「工具内部再起子查询」的派生工具用它
|
|
369
504
|
* 跑嵌套 runQuery(子 agent 与主 agent 同一模型,不另配凭据)。
|
|
@@ -399,6 +534,8 @@ export interface ToolCallContext {
|
|
|
399
534
|
cwd?: string;
|
|
400
535
|
/** 本机记忆权限由宿主明确声明;不可信宿主必须为 denied。 */
|
|
401
536
|
memoryAccess?: import('./runtime/agentRuntimeContext.js').MemoryAccessInput;
|
|
537
|
+
conversationMode?: import('./runtime/agentRuntimeContext.js').ConversationMode;
|
|
538
|
+
surface?: import('./runtime/agentRuntimeContext.js').AgentSurface;
|
|
402
539
|
/**
|
|
403
540
|
* Browser actions are scoped to the owning conversation/run by the host.
|
|
404
541
|
* `supervised` 由宿主声明「存在可见浏览器 + 真人可接管/resume」(仅 Desktop 置 true):
|
|
@@ -459,6 +596,68 @@ export interface ToolCallContext {
|
|
|
459
596
|
};
|
|
460
597
|
}
|
|
461
598
|
|
|
599
|
+
export interface AdvisorContextPacket {
|
|
600
|
+
objective: string;
|
|
601
|
+
currentRequest: string;
|
|
602
|
+
checkpoint: AdvisorCheckpoint;
|
|
603
|
+
versions: AdvisorVersions;
|
|
604
|
+
changedFiles: string[];
|
|
605
|
+
evidence: string[];
|
|
606
|
+
previousAdvice?: string;
|
|
607
|
+
actionsAfterPreviousAdvice: string[];
|
|
608
|
+
openQuestions: string[];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export interface AdvisorRuntimeBridge {
|
|
612
|
+
/**
|
|
613
|
+
* 有值 = 存在一次已成功、但还没被 AdvisorDecision 结清的咨询——下一次
|
|
614
|
+
* Advisor 调用是对它的复核,而不是一次全新检查点的咨询。`advisor.ts`
|
|
615
|
+
* 用它判断复核调用是否该豁免配额(复核不该因为撞配额墙而被迫放弃、
|
|
616
|
+
* 反而把本该把关的检查点悄悄标记完成)。
|
|
617
|
+
*/
|
|
618
|
+
readonly pendingConsultationId: string | undefined;
|
|
619
|
+
/** 同一检查点最多允许一次不占配额的证据冲突复核。 */
|
|
620
|
+
readonly canReconcileConsultation: boolean;
|
|
621
|
+
beginConsultation(): AdvisorConsultationMetadata;
|
|
622
|
+
finishConsultation(
|
|
623
|
+
metadata: AdvisorConsultationMetadata,
|
|
624
|
+
ok: boolean,
|
|
625
|
+
): AdvisorConsultationMetadata;
|
|
626
|
+
recordDecision(input: {
|
|
627
|
+
consultationId: string;
|
|
628
|
+
decision: 'accept' | 'partial' | 'reject';
|
|
629
|
+
rationale: string;
|
|
630
|
+
acceptedPoints?: string[];
|
|
631
|
+
rejectedPoints?: string[];
|
|
632
|
+
verificationPlan?: string[];
|
|
633
|
+
}): ToolResult;
|
|
634
|
+
contextPacket(note?: string): AdvisorContextPacket;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export type ToolCategory =
|
|
638
|
+
| 'files'
|
|
639
|
+
| 'shell'
|
|
640
|
+
| 'web'
|
|
641
|
+
| 'desktop'
|
|
642
|
+
| 'agents'
|
|
643
|
+
| 'memory'
|
|
644
|
+
| 'media';
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Compact, system-prompt-facing routing guidance.
|
|
648
|
+
*
|
|
649
|
+
* Tool descriptions identify the callable contract and parameter schemas
|
|
650
|
+
* describe fields. Selection boundaries live here so every active tool can
|
|
651
|
+
* be presented once in the system prompt without copying long descriptions.
|
|
652
|
+
*/
|
|
653
|
+
export interface ToolPromptGuide {
|
|
654
|
+
category: ToolCategory;
|
|
655
|
+
useWhen: string;
|
|
656
|
+
method: string;
|
|
657
|
+
avoidWhen?: string;
|
|
658
|
+
priority?: 'preferred' | 'normal' | 'last-resort';
|
|
659
|
+
}
|
|
660
|
+
|
|
462
661
|
export interface Tool<TInput = unknown> {
|
|
463
662
|
/** 工具名,必须和 kakadeai 一致:'Read' / 'Edit' / 'Write' / 'Glob' / 'Grep' */
|
|
464
663
|
name: string;
|
|
@@ -469,6 +668,13 @@ export interface Tool<TInput = unknown> {
|
|
|
469
668
|
*/
|
|
470
669
|
description: string | (() => string);
|
|
471
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Tool-selection guidance rendered into the system prompt. Built-in tools
|
|
673
|
+
* must provide it; optionality preserves compatibility with third-party
|
|
674
|
+
* plugins, whose first description sentence is used as a fallback.
|
|
675
|
+
*/
|
|
676
|
+
promptGuide?: ToolPromptGuide;
|
|
677
|
+
|
|
472
678
|
/** Zod schema:模型返回的 arguments JSON 会用它校验和解析 */
|
|
473
679
|
inputSchema: z.ZodType<TInput>;
|
|
474
680
|
|
|
@@ -490,6 +696,10 @@ export interface Tool<TInput = unknown> {
|
|
|
490
696
|
/** 输出超过这个字符数会被截断(防止把巨大文件灌进上下文) */
|
|
491
697
|
maxResultSizeChars?: number;
|
|
492
698
|
|
|
699
|
+
/** Declarative host gates. Omitted means available in every mode/surface. */
|
|
700
|
+
availableInModes?: import('./runtime/agentRuntimeContext.js').ConversationMode[];
|
|
701
|
+
availableOnSurfaces?: import('./runtime/agentRuntimeContext.js').AgentSurface[];
|
|
702
|
+
|
|
493
703
|
/** Synchronous host/runtime probe used before the tool is shown to the model. */
|
|
494
704
|
resolveAvailability?(
|
|
495
705
|
runtime: import('./runtime/agentRuntimeContext.js').AgentRuntimeContext,
|
|
@@ -518,7 +728,12 @@ export interface Tool<TInput = unknown> {
|
|
|
518
728
|
gateRequest?(
|
|
519
729
|
input: TInput | undefined,
|
|
520
730
|
context: ToolCallContext,
|
|
521
|
-
): Partial<
|
|
731
|
+
): Partial<
|
|
732
|
+
Pick<
|
|
733
|
+
import('./toolGate.js').ToolGateRequest,
|
|
734
|
+
'isReadOnly' | 'runContext' | 'action'
|
|
735
|
+
>
|
|
736
|
+
>;
|
|
522
737
|
|
|
523
738
|
/**
|
|
524
739
|
* 真正干活的函数。
|
|
@@ -550,16 +765,10 @@ export interface ToolAvailability {
|
|
|
550
765
|
// MINIMAL_AGENT_PROVIDER - 友好名称(可选,默认 "env")
|
|
551
766
|
// MINIMAL_AGENT_CONTEXT_WINDOW - 上下文窗口(可选,默认 128000)
|
|
552
767
|
|
|
553
|
-
|
|
768
|
+
interface ProviderCommon {
|
|
554
769
|
/** 友好名(仅展示用),如 "deepseek" */
|
|
555
770
|
name: string;
|
|
556
771
|
|
|
557
|
-
/** API 完整端点 URL,如 "https://api.deepseek.com/v1/chat/completions" */
|
|
558
|
-
baseURL: string;
|
|
559
|
-
|
|
560
|
-
/** API key(敏感信息,用户自己填) */
|
|
561
|
-
apiKey: string;
|
|
562
|
-
|
|
563
772
|
/** 模型 id,如 "deepseek-chat" */
|
|
564
773
|
model: string;
|
|
565
774
|
|
|
@@ -603,7 +812,91 @@ export interface Provider {
|
|
|
603
812
|
* 保守地不给可能非视觉的端点发图(免触发 400),并优雅降级(不截、不假装核验)。
|
|
604
813
|
*/
|
|
605
814
|
supportsVision?: boolean;
|
|
815
|
+
/** Explicit provider declaration for reliable native JSON Schema output. */
|
|
816
|
+
supportsJsonSchema?: boolean;
|
|
606
817
|
promptCache?: PromptCacheConfig;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* 是否对 Anthropic 格式端点启用 cache_edits 式回收(对齐 kakadeai Cached MC)。
|
|
821
|
+
*
|
|
822
|
+
* **为什么默认关闭**:`cache_edits` content block(edits: [{type:'delete', cache_reference}])
|
|
823
|
+
* 不在 Anthropic 公开 Messages API 文档里(2023-06-01 版协议无此字段)——kakadeai 主项目
|
|
824
|
+
* 依赖其自建网关(Mycro)的服务端 KV 原地编辑能力。对着不支持的自定义/官方端点发送
|
|
825
|
+
* 未知 block 类型会 400。仅当 baseURL 指向支持该协议的网关时显式开启。
|
|
826
|
+
*
|
|
827
|
+
* 开启后(须同时 apiFormat === 'anthropic'):
|
|
828
|
+
* - reclaimOldToolResults 进入 cacheEdits 模式:**本地 history 不再被改写**,
|
|
829
|
+
* 回收决策只记入 pending 删除清单(CacheEditsState)。
|
|
830
|
+
* - anthropicFormat 请求组装时发送 cache_edits block,服务端在 KV 缓存内原地
|
|
831
|
+
* 删除这些 tool_result——模型实际看到的上下文变短,但前缀 hash 不变、
|
|
832
|
+
* 缓存命中完整保留(这是与 inline 占位符模式的本质区别)。
|
|
833
|
+
* - wire 上完整内容仍然发送(省的是服务端 KV 驻留与模型注意力窗口,不是请求体积)。
|
|
834
|
+
*/
|
|
835
|
+
cacheEdits?: boolean;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/** Direct local provider descriptor. Vendor endpoint and key exist only here. */
|
|
839
|
+
export interface LocalProvider extends ProviderCommon {
|
|
840
|
+
source?: 'local';
|
|
841
|
+
/** API 完整端点 URL;仅本地 Provider 可拥有。 */
|
|
842
|
+
baseURL: string;
|
|
843
|
+
/** 本地模型 API key。 */
|
|
844
|
+
apiKey: string;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/** Runtime-only remote descriptor. It intentionally has no vendor endpoint or
|
|
848
|
+
* vendor credential fields; those exist only inside minimal-server. */
|
|
849
|
+
export interface GatewayProvider extends ProviderCommon {
|
|
850
|
+
source: 'gateway';
|
|
851
|
+
remoteModelId: string;
|
|
852
|
+
gatewayUrl: string;
|
|
853
|
+
gatewayToken: string;
|
|
854
|
+
/** Server-enforced upper bound for this remote model. */
|
|
855
|
+
gatewayMaxToolCategories?: string[];
|
|
856
|
+
/** Server-provided initial Session selection. */
|
|
857
|
+
gatewayDefaultToolCategories?: string[];
|
|
858
|
+
/** Server-declared provider capabilities used for local preflight UX. */
|
|
859
|
+
gatewayCapabilities?: {
|
|
860
|
+
vision: boolean;
|
|
861
|
+
tools: boolean;
|
|
862
|
+
structuredOutput: boolean;
|
|
863
|
+
};
|
|
864
|
+
/** Effective categories for the current turn; retained as the wire-facing
|
|
865
|
+
* compatibility field while callers migrate to the explicit fields. */
|
|
866
|
+
gatewayToolCategories?: string[];
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
export type Provider = LocalProvider | GatewayProvider;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* cache_edits 式回收的运行时状态(Anthropic 格式 + provider.cacheEdits 开启时使用)。
|
|
873
|
+
*
|
|
874
|
+
* 放在 types.ts 而非 context/ 或 llm/ 的原因:context 层(microCompactLite,决策方)
|
|
875
|
+
* 与 llm 层(anthropicFormat,协议组装方)都要消费,放中立位置避免反向依赖。
|
|
876
|
+
*
|
|
877
|
+
* **下标稳定性契约**:pinned[].userMessageIndex 是 toAnthropicMessages() 翻译后数组
|
|
878
|
+
* 的下标。该契约依赖两个事实:history append-only(compact 时必须 resetCacheEdits),
|
|
879
|
+
* 且 toAnthropicMessages 是纯函数(同一份 history 翻译结果恒定)。旧消息的翻译后
|
|
880
|
+
* 下标因此跨轮稳定——cache_edits block 每轮必须重发在**原位置**,否则请求前缀
|
|
881
|
+
* 变化会破坏它本要保护的缓存(服务端无状态,指令须随每个请求重申)。
|
|
882
|
+
*/
|
|
883
|
+
export interface CacheEditsState {
|
|
884
|
+
/** 已标记删除的 tool_call_id 集合(幂等:重复标记自动忽略) */
|
|
885
|
+
deletedToolIds: Set<string>;
|
|
886
|
+
/** 已 pin 的编辑批次:每轮请求在原 userMessageIndex 位置重发的删除指令 */
|
|
887
|
+
pinned: Array<{ userMessageIndex: number; toolUseIds: string[] }>;
|
|
888
|
+
/** 本轮新增、尚未随请求发送过的删除目标(发送即清空,发送后转入 pinned) */
|
|
889
|
+
pendingNew: string[];
|
|
890
|
+
/**
|
|
891
|
+
* 当前有效删除量(token 估算):服务端已删除、但本地 history 里仍完整存在的
|
|
892
|
+
* 工具结果内容的 token 总量。用于校正 autoCompact 的本地估算判据--cacheEdits
|
|
893
|
+
* 模式下 history 不瘦身,countMessagesTokens 会把这些已删内容重复计入,判据
|
|
894
|
+
* 虚高会导致压缩过早触发(压缩本身会重建整个前缀缓存,抵消 cacheEdits 的收益)。
|
|
895
|
+
*
|
|
896
|
+
* 生命周期:随每批删除累加;resetCacheEdits(compact/snip 后)清零--历史被
|
|
897
|
+
* 重写后旧账对应的已删内容可能已不在新历史里,继续减会过度校正。
|
|
898
|
+
*/
|
|
899
|
+
activeDeletedTokens: number;
|
|
607
900
|
}
|
|
608
901
|
|
|
609
902
|
export type PromptCacheMode = 'auto' | 'session-key' | 'disabled';
|
|
@@ -694,6 +987,9 @@ export type LlmStreamEvent =
|
|
|
694
987
|
/** 数组增量(reasoning_details) */
|
|
695
988
|
items?: unknown[];
|
|
696
989
|
}
|
|
990
|
+
/** Provider usage may arrive before the terminal event (not persisted in history). */
|
|
991
|
+
| { type: 'usage'; promptTokens?: number; outputTokens?: number }
|
|
992
|
+
// TurnResourceUsage 的定义在文件末尾附近(与 LoopEvent 同区),此处只是引用。
|
|
697
993
|
/**
|
|
698
994
|
* 流结束。
|
|
699
995
|
*
|
|
@@ -716,6 +1012,17 @@ export type LlmStreamEvent =
|
|
|
716
1012
|
type: 'done';
|
|
717
1013
|
stopReason: 'stop' | 'tool_calls' | 'length' | 'unknown' | 'aborted';
|
|
718
1014
|
promptTokens?: number;
|
|
1015
|
+
/**
|
|
1016
|
+
* 本轮**真实**输出 token 数(OpenAI `completion_tokens` / Anthropic `output_tokens`)。
|
|
1017
|
+
*
|
|
1018
|
+
* 与 promptTokens 同一条纪律:**provider 不报就是 undefined,绝不填 0**。
|
|
1019
|
+
* 填 0 会被上层预算刻度读成「这轮没花钱」,于是预算闸永远不触发 ——
|
|
1020
|
+
* 那比没有预算更危险,因为它看起来在工作。
|
|
1021
|
+
*
|
|
1022
|
+
* 用途:喂给回合级资源账本(`TurnResourceUsage`),再由 Goal 的轮次边界预算闸消费。
|
|
1023
|
+
* ⚠️ 它**不参与**自动压缩判定 —— 压缩只看 prompt 侧。
|
|
1024
|
+
*/
|
|
1025
|
+
outputTokens?: number;
|
|
719
1026
|
cachedPromptTokens?: number;
|
|
720
1027
|
cacheMissTokens?: number;
|
|
721
1028
|
cacheWriteTokens?: number;
|
|
@@ -780,6 +1087,35 @@ export interface ToolStatusState {
|
|
|
780
1087
|
progressDetail?: ToolProgressDetail;
|
|
781
1088
|
}
|
|
782
1089
|
|
|
1090
|
+
/**
|
|
1091
|
+
* 一个**用户回合**(不是一个 TAOR 迭代)累计消耗的资源。
|
|
1092
|
+
*
|
|
1093
|
+
* 语义边界,改之前先读:
|
|
1094
|
+
* - 「一回合」= 从用户输入到模型不再调工具为止,中间可能有几十次 LLM 请求。
|
|
1095
|
+
* - 它是**账本**不是闸门。loop 只负责记账,**绝不因为它中断进行中的工具循环** ——
|
|
1096
|
+
* 预算判定一律发生在「要不要开新一轮」的边界上(goal / ralph-loop 这类多轮工作流
|
|
1097
|
+
* 在循环开头调 `budget()`)。这条是产品决策:宁可超一点预算,也不能把 agent
|
|
1098
|
+
* 停在半成品状态。
|
|
1099
|
+
*
|
|
1100
|
+
* ⚠️ **消费前必须先看 `trustworthy`**。不是所有 provider 都回报 usage
|
|
1101
|
+
* (OpenAI 需要 `stream_options.include_usage`,部分兼容实现直接不发)。
|
|
1102
|
+
* 少报会让预算闸永远不触发 —— 那比没有预算更危险,因为它看起来在工作。
|
|
1103
|
+
* 所以这里如实区分「真的是 0」与「没人告诉我」:不报的调用不计入,
|
|
1104
|
+
* 由 `reportedCalls / totalCalls` 暴露这份账本的覆盖率。
|
|
1105
|
+
*/
|
|
1106
|
+
export interface TurnResourceUsage {
|
|
1107
|
+
/** 累计输入 token(仅统计真实报告了 usage 的那些调用)。 */
|
|
1108
|
+
inputTokens: number;
|
|
1109
|
+
/** 累计输出 token(同上)。 */
|
|
1110
|
+
outputTokens: number;
|
|
1111
|
+
/** 本回合发出的 LLM 请求总数。 */
|
|
1112
|
+
totalCalls: number;
|
|
1113
|
+
/** 其中真实回报了 usage 的次数。 */
|
|
1114
|
+
reportedCalls: number;
|
|
1115
|
+
/** `totalCalls > 0 && reportedCalls === totalCalls` —— 只有全报了才算这份账可信。 */
|
|
1116
|
+
trustworthy: boolean;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
783
1119
|
export type LoopEvent =
|
|
784
1120
|
/** 文本流(同 LlmStreamEvent.text_delta) */
|
|
785
1121
|
| { type: 'text'; delta: string }
|
|
@@ -792,9 +1128,24 @@ export type LoopEvent =
|
|
|
792
1128
|
* <Static> 直到整轮落定才一次性 commit「用户消息+reasoning+答案」,用户输入无法第一时间置顶。
|
|
793
1129
|
* UI 收到此事件立即 bump,让 <Static> 马上把用户消息 commit 进 scrollback(符合 T-A-O-R 顺序)。
|
|
794
1130
|
*/
|
|
795
|
-
| {
|
|
1131
|
+
| {
|
|
1132
|
+
type: 'user_message_committed';
|
|
1133
|
+
message?: Extract<Message, { role: 'user' }>;
|
|
1134
|
+
}
|
|
796
1135
|
/** 一轮 assistant 消息已完整组装(含可能的 tool_calls) */
|
|
797
|
-
| {
|
|
1136
|
+
| {
|
|
1137
|
+
type: 'assistant_message';
|
|
1138
|
+
message: Extract<Message, { role: 'assistant' }>;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* 模型已经流出了一份正文/思考草稿,但宿主确定它还不能成为本轮回答。
|
|
1142
|
+
* 消费方应清掉 live 草稿;该草稿不会写入会话 history。
|
|
1143
|
+
*/
|
|
1144
|
+
| {
|
|
1145
|
+
type: 'assistant_draft_discarded';
|
|
1146
|
+
reason: 'formal_delivery' | 'advisor_checkpoint' | 'empty_response';
|
|
1147
|
+
textLength: number;
|
|
1148
|
+
}
|
|
798
1149
|
/**
|
|
799
1150
|
* 主循环在工具结果之后注入的「带外上下文消息」(当前用于浏览器关键节点实况截图回填)。
|
|
800
1151
|
* 宿主收到后应把它当作一条消息追加进对话展示;模型也会在下一轮看到它(已 push 进 history)。
|
|
@@ -871,8 +1222,25 @@ export type LoopEvent =
|
|
|
871
1222
|
/** 整轮交互结束(模型不再调工具) */
|
|
872
1223
|
| {
|
|
873
1224
|
type: 'turn_done';
|
|
874
|
-
completionStatus?:
|
|
1225
|
+
completionStatus?:
|
|
1226
|
+
| 'completed'
|
|
1227
|
+
| 'delivery_incomplete'
|
|
1228
|
+
| 'delivery_unverified'
|
|
1229
|
+
| 'claims_unverified';
|
|
875
1230
|
warning?: string;
|
|
1231
|
+
/** 本回合的资源账本。见 TurnResourceUsage —— 消费方务必先看 `trustworthy`。 */
|
|
1232
|
+
usage?: TurnResourceUsage;
|
|
1233
|
+
/**
|
|
1234
|
+
* 托管运行时(`meta.managedRuntime`,目前只有 goal)的生命周期状态。
|
|
1235
|
+
*
|
|
1236
|
+
* ⚠️ 它与 `completionStatus` 回答的**不是同一个问题**,别合并:
|
|
1237
|
+
* · completionStatus = 模型宣称的事做没做(交付判定)
|
|
1238
|
+
* · managedStatus = 这件事**有没有被人验收**(生命周期事实源)
|
|
1239
|
+
* `completionStatus:'completed'` + `managedStatus:'ready_for_acceptance'`
|
|
1240
|
+
* 是正常且重要的组合:机器自检通过,但还没有人点头。
|
|
1241
|
+
* 取值与映射见 `src/goal/statusMapping.ts`。
|
|
1242
|
+
*/
|
|
1243
|
+
managedStatus?: string;
|
|
876
1244
|
}
|
|
877
1245
|
/**
|
|
878
1246
|
* 中断事件
|
|
@@ -900,7 +1268,13 @@ export type LoopEvent =
|
|
|
900
1268
|
| {
|
|
901
1269
|
type: 'error';
|
|
902
1270
|
error: string;
|
|
903
|
-
code?:
|
|
1271
|
+
code?:
|
|
1272
|
+
| 'llm_error'
|
|
1273
|
+
| 'max_turns'
|
|
1274
|
+
| 'compact_failed'
|
|
1275
|
+
| 'aborted'
|
|
1276
|
+
| 'stalled'
|
|
1277
|
+
| 'context_overflow';
|
|
904
1278
|
}
|
|
905
1279
|
/**
|
|
906
1280
|
* 非致命警告:需冒泡给用户但不终止执行。
|
|
@@ -929,6 +1303,23 @@ export type LoopEvent =
|
|
|
929
1303
|
max?: number;
|
|
930
1304
|
message?: string;
|
|
931
1305
|
}
|
|
1306
|
+
| {
|
|
1307
|
+
type: 'workflow_progress';
|
|
1308
|
+
workflow: string;
|
|
1309
|
+
runId: string;
|
|
1310
|
+
rootRunId: string;
|
|
1311
|
+
parentRunId?: string;
|
|
1312
|
+
depth?: number;
|
|
1313
|
+
phase: string;
|
|
1314
|
+
status: 'start' | 'update' | 'complete' | 'warning';
|
|
1315
|
+
current?: number;
|
|
1316
|
+
total?: number;
|
|
1317
|
+
succeeded?: number;
|
|
1318
|
+
failed?: number;
|
|
1319
|
+
message?: string;
|
|
1320
|
+
queuedMs?: number;
|
|
1321
|
+
elapsedMs?: number;
|
|
1322
|
+
}
|
|
932
1323
|
/**
|
|
933
1324
|
* 思维链流式片段。
|
|
934
1325
|
*
|
|
@@ -959,8 +1350,19 @@ export type LoopEvent =
|
|
|
959
1350
|
* 让远程通道(webchat / 网关)收到问题、渲染选择、把答案经 stdin 的 `ask_answer` 回灌。
|
|
960
1351
|
* requestId 用于关联问题与答案(一轮内可多次提问)。
|
|
961
1352
|
*/
|
|
962
|
-
| {
|
|
1353
|
+
| {
|
|
1354
|
+
type: 'ask';
|
|
1355
|
+
requestId: string;
|
|
1356
|
+
questions: AskQuestionSpec[];
|
|
1357
|
+
source?: AskSource;
|
|
1358
|
+
}
|
|
963
1359
|
/** 问题在本回合所有者队列中的状态;不写入 Session 历史。 */
|
|
964
|
-
| {
|
|
1360
|
+
| {
|
|
1361
|
+
type: 'ask_status';
|
|
1362
|
+
source: AskSource;
|
|
1363
|
+
state: AskQueueState;
|
|
1364
|
+
queuePosition?: number;
|
|
1365
|
+
queuedCount?: number;
|
|
1366
|
+
};
|
|
965
1367
|
// 注:插件私有事件(如 workflow-runner 的 workflow_*)不再写在这里。
|
|
966
1368
|
// 插件通过 PluginEvent 开放契约 yield 任意 type 字符串的事件,UI 静默忽略未识别项。
|