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,501 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rm, unlink, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
6
|
+
import type { PluginRuntimeContext, RunAgentTurnResult } from '../../../src/plugin-sdk.js';
|
|
7
|
+
import { sessionFileFor } from '../../../src/context/sessionPath.js';
|
|
8
|
+
import type { CronTask } from '../src/types.js';
|
|
9
|
+
|
|
10
|
+
let root = '';
|
|
11
|
+
let store: typeof import('../src/store.js');
|
|
12
|
+
let commands: typeof import('../src/commands.js');
|
|
13
|
+
let schedulerMod: typeof import('../src/scheduler.js');
|
|
14
|
+
let lockMod: typeof import('../src/lock.js');
|
|
15
|
+
|
|
16
|
+
const provider = {
|
|
17
|
+
name: 'test',
|
|
18
|
+
baseURL: 'https://example.invalid',
|
|
19
|
+
apiKey: 'test',
|
|
20
|
+
model: 'test-model',
|
|
21
|
+
contextWindow: 128000,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('cron-runner store and scheduler', () => {
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
root = await mkdtemp(join(tmpdir(), 'cron-runner-test-'));
|
|
27
|
+
process.env.MINIMAL_AGENT_HOME = root;
|
|
28
|
+
process.env.MINIMAL_AGENT_CRON_RUNNER_HOME = root;
|
|
29
|
+
process.env.MINIMAL_AGENT_CRON_DISABLE_JITTER = '1';
|
|
30
|
+
store = await import('../src/store.js');
|
|
31
|
+
commands = await import('../src/commands.js');
|
|
32
|
+
schedulerMod = await import('../src/scheduler.js');
|
|
33
|
+
lockMod = await import('../src/lock.js');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(async () => {
|
|
37
|
+
delete process.env.MINIMAL_AGENT_HOME;
|
|
38
|
+
delete process.env.MINIMAL_AGENT_CRON_RUNNER_HOME;
|
|
39
|
+
delete process.env.MINIMAL_AGENT_CRON_DISABLE_JITTER;
|
|
40
|
+
if (root) await rm(root, { recursive: true, force: true });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async function createBoundSession(cwd: string, sessionId: string): Promise<void> {
|
|
44
|
+
const sessionFile = sessionFileFor(cwd, sessionId);
|
|
45
|
+
await mkdir(join(sessionFile, '..'), { recursive: true });
|
|
46
|
+
await writeFile(sessionFile, JSON.stringify({ messages: [{ role: 'system', content: 'test' }] }), 'utf8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
test('creates, pauses, resumes, shows, and deletes tasks through command handler', async () => {
|
|
50
|
+
const created = await commands.handleCronCommand(
|
|
51
|
+
'cron',
|
|
52
|
+
'create --name "Morning" --cron "7 6 * * 1" --prompt "hello"',
|
|
53
|
+
null,
|
|
54
|
+
);
|
|
55
|
+
expect(created).toContain('已创建 cron');
|
|
56
|
+
let tasks = await store.listTasks();
|
|
57
|
+
expect(tasks).toHaveLength(1);
|
|
58
|
+
expect(tasks[0]!.name).toBe('Morning');
|
|
59
|
+
expect(tasks[0]!.status).toBe('active');
|
|
60
|
+
|
|
61
|
+
expect(await commands.handleCronCommand('cron', `pause ${tasks[0]!.id}`, null)).toContain('已暂停');
|
|
62
|
+
tasks = await store.listTasks();
|
|
63
|
+
expect(tasks[0]!.status).toBe('paused');
|
|
64
|
+
|
|
65
|
+
expect(await commands.handleCronCommand('cron', `resume ${tasks[0]!.id}`, null)).toContain('已恢复');
|
|
66
|
+
expect(await commands.handleCronCommand('crons', '', null)).toContain('下次运行');
|
|
67
|
+
expect(await commands.handleCronCommand('cron', `show ${tasks[0]!.id}`, null)).toContain('最近运行');
|
|
68
|
+
|
|
69
|
+
expect(await commands.handleCronCommand('cron', `delete ${tasks[0]!.id}`, null)).toContain('已删除');
|
|
70
|
+
expect(await store.listTasks()).toHaveLength(0);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('creates tasks with friendly shortcut syntax', async () => {
|
|
74
|
+
await commands.handleCronCommand('cron', '120m 整理最近 AI 新闻', null);
|
|
75
|
+
await commands.handleCronCommand('cron', '2h 两小时巡检', null);
|
|
76
|
+
await commands.handleCronCommand('cron', '1w 每周素材整理', null);
|
|
77
|
+
await commands.handleCronCommand('cron', '1d 每日国际新闻 /workflow daily-news.yaml 生成中文新闻稿', null);
|
|
78
|
+
await commands.handleCronCommand('cron', '1m 检查学生作业 workflow inspect-homework.yaml camera.jpg', null);
|
|
79
|
+
await commands.handleCronCommand('cron', '每天 6:07 写国际 AI 晨间简报', null);
|
|
80
|
+
await commands.handleCronCommand('cron', '工作日 6:07 写过去 48 小时国际 AI 大事', null);
|
|
81
|
+
await commands.handleCronCommand('cron', '每周一 6:07 整理国际 AI 超级个体创业案例', null);
|
|
82
|
+
const tasks = await store.listTasks();
|
|
83
|
+
expect(tasks.some((t) => t.schedule.type === 'interval' && t.schedule.intervalMs === 120 * 60_000)).toBe(true);
|
|
84
|
+
expect(tasks.some((t) => t.schedule.type === 'interval' && t.schedule.intervalMs === 2 * 60 * 60_000)).toBe(true);
|
|
85
|
+
expect(tasks.some((t) => t.schedule.type === 'interval' && t.schedule.intervalMs === 7 * 24 * 60 * 60_000)).toBe(true);
|
|
86
|
+
expect(tasks.some((t) => t.schedule.type === 'cron' && t.schedule.cron === '7 6 * * *')).toBe(true);
|
|
87
|
+
expect(tasks.some((t) => t.schedule.type === 'cron' && t.schedule.cron === '7 6 * * 1-5')).toBe(true);
|
|
88
|
+
expect(tasks.some((t) => t.schedule.type === 'cron' && t.schedule.cron === '7 6 * * 1')).toBe(true);
|
|
89
|
+
const daily = tasks.find((t) => t.description === '每日国际新闻');
|
|
90
|
+
expect(daily?.action).toEqual({ type: 'workflow', command: 'daily-news.yaml 生成中文新闻稿' });
|
|
91
|
+
expect(daily?.schedule.type).toBe('interval');
|
|
92
|
+
const camera = tasks.find((t) => t.description === '检查学生作业');
|
|
93
|
+
expect(camera?.action).toEqual({ type: 'workflow', command: 'inspect-homework.yaml camera.jpg' });
|
|
94
|
+
expect(camera?.schedule.type === 'interval' && camera.schedule.intervalMs).toBe(60_000);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('friendly shortcuts reject invalid intervals and missing workflow names', async () => {
|
|
98
|
+
expect(await commands.handleCronCommand('cron', '0m inspect', null)).toContain('无效间隔');
|
|
99
|
+
expect(await commands.handleCronCommand('cron', '1x inspect', null)).toContain('无效间隔');
|
|
100
|
+
expect(await commands.handleCronCommand('cron', '1d task /workflow', null)).toContain(
|
|
101
|
+
'缺少 YAML 名称',
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('migrates old task shape and writes tasks atomically', async () => {
|
|
106
|
+
const taskRoot = join(root, 'cron-runner');
|
|
107
|
+
await mkdir(taskRoot, { recursive: true });
|
|
108
|
+
await writeFile(
|
|
109
|
+
join(taskRoot, 'tasks.json'),
|
|
110
|
+
JSON.stringify({
|
|
111
|
+
tasks: [
|
|
112
|
+
{
|
|
113
|
+
id: 'cron-old',
|
|
114
|
+
name: 'Old',
|
|
115
|
+
status: 'active',
|
|
116
|
+
schedule: { cron: '7 6 * * 1', human: 'old' },
|
|
117
|
+
action: { type: 'prompt', prompt: 'hello' },
|
|
118
|
+
runtime: { cwd: process.cwd(), environment: 'project', sessionId: 'cron-old' },
|
|
119
|
+
createdAt: new Date().toISOString(),
|
|
120
|
+
updatedAt: new Date().toISOString(),
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
const tasks = await store.listTasks();
|
|
126
|
+
expect(tasks[0]!.kind).toBe('recurring');
|
|
127
|
+
expect(tasks[0]!.stats.runCount).toBe(0);
|
|
128
|
+
expect(tasks[0]!.stats.skippedCount).toBe(0);
|
|
129
|
+
expect(tasks[0]!.runtime.sessionMode).toBe('persistent');
|
|
130
|
+
expect(tasks[0]!.schedule.type).toBe('cron');
|
|
131
|
+
if (tasks[0]!.schedule.type === 'cron') expect(tasks[0]!.schedule.timezone).toBeTruthy();
|
|
132
|
+
|
|
133
|
+
await store.writeTasks(tasks);
|
|
134
|
+
const raw = await readFile(join(taskRoot, 'tasks.json'), 'utf8');
|
|
135
|
+
expect(JSON.parse(raw).tasks[0].kind).toBe('recurring');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('manual run writes success history and stats', async () => {
|
|
139
|
+
const sessionId = 'manual-run-session';
|
|
140
|
+
await createBoundSession(process.cwd(), sessionId);
|
|
141
|
+
const task = store.createTask({
|
|
142
|
+
name: 'Run me',
|
|
143
|
+
cron: '* * * * *',
|
|
144
|
+
timezone: 'local',
|
|
145
|
+
cwd: process.cwd(),
|
|
146
|
+
sessionId,
|
|
147
|
+
action: { type: 'prompt', prompt: 'hello' },
|
|
148
|
+
});
|
|
149
|
+
await store.upsertTask(task);
|
|
150
|
+
const ctx: PluginRuntimeContext = {
|
|
151
|
+
provider,
|
|
152
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => ({
|
|
153
|
+
ok: true,
|
|
154
|
+
result: 'done',
|
|
155
|
+
numTurns: 1,
|
|
156
|
+
events: [],
|
|
157
|
+
}),
|
|
158
|
+
};
|
|
159
|
+
const scheduler = new schedulerMod.Scheduler(ctx);
|
|
160
|
+
await scheduler.runTaskNow(task.id);
|
|
161
|
+
|
|
162
|
+
const updated = await store.getTask(task.id);
|
|
163
|
+
expect(updated?.stats.runCount).toBe(1);
|
|
164
|
+
expect(updated?.stats.successCount).toBe(1);
|
|
165
|
+
const runs = await store.recentRuns(task.id, 10);
|
|
166
|
+
expect(runs.some((r) => r.status === 'success')).toBe(true);
|
|
167
|
+
expect(runs.filter((r) => r.id === runs[0]!.id)).toHaveLength(1);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('manual run completes once tasks after completion', async () => {
|
|
171
|
+
const sessionId = 'once-run-session';
|
|
172
|
+
await createBoundSession(process.cwd(), sessionId);
|
|
173
|
+
const task = store.createTask({
|
|
174
|
+
name: 'Once',
|
|
175
|
+
cron: '* * * * *',
|
|
176
|
+
timezone: 'local',
|
|
177
|
+
cwd: process.cwd(),
|
|
178
|
+
sessionId,
|
|
179
|
+
kind: 'once',
|
|
180
|
+
action: { type: 'prompt', prompt: 'hello' },
|
|
181
|
+
});
|
|
182
|
+
await store.upsertTask(task);
|
|
183
|
+
const ctx: PluginRuntimeContext = {
|
|
184
|
+
provider,
|
|
185
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => ({
|
|
186
|
+
ok: false,
|
|
187
|
+
result: '',
|
|
188
|
+
error: 'failed',
|
|
189
|
+
numTurns: 1,
|
|
190
|
+
events: [],
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
const scheduler = new schedulerMod.Scheduler(ctx);
|
|
194
|
+
await scheduler.runTaskNow(task.id);
|
|
195
|
+
const updated = await store.getTask(task.id);
|
|
196
|
+
expect(updated?.status).toBe('completed');
|
|
197
|
+
expect(updated?.stats.failureCount).toBe(1);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('missed command lists recorded missed tasks', async () => {
|
|
201
|
+
await store.appendMissed({
|
|
202
|
+
id: 'missed-test',
|
|
203
|
+
taskId: 'cron-missed',
|
|
204
|
+
taskName: 'Missed',
|
|
205
|
+
scheduledFor: new Date().toISOString(),
|
|
206
|
+
detectedAt: new Date().toISOString(),
|
|
207
|
+
actionPreview: 'hello',
|
|
208
|
+
reason: 'offline',
|
|
209
|
+
missedCount: 1,
|
|
210
|
+
});
|
|
211
|
+
const text = await commands.handleCronCommand('cron', 'missed', null);
|
|
212
|
+
expect(text).toContain('错过任务');
|
|
213
|
+
expect(text).toContain('cron-missed');
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('scheduler lock refuses live owners and recovers stale owners', async () => {
|
|
217
|
+
const lockFile = join(root, 'cron-runner', 'test-scheduler.lock');
|
|
218
|
+
await writeFile(
|
|
219
|
+
lockFile,
|
|
220
|
+
JSON.stringify({
|
|
221
|
+
owner: 'live-owner',
|
|
222
|
+
pid: process.pid,
|
|
223
|
+
createdAt: new Date().toISOString(),
|
|
224
|
+
updatedAt: new Date().toISOString(),
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
expect(await lockMod.tryAcquireSchedulerLock(lockFile, 'other-owner')).toBe(false);
|
|
228
|
+
|
|
229
|
+
await writeFile(
|
|
230
|
+
lockFile,
|
|
231
|
+
JSON.stringify({
|
|
232
|
+
owner: 'stale-owner',
|
|
233
|
+
pid: 9_999_999,
|
|
234
|
+
createdAt: new Date().toISOString(),
|
|
235
|
+
updatedAt: new Date().toISOString(),
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
expect(await lockMod.tryAcquireSchedulerLock(lockFile, 'new-owner')).toBe(true);
|
|
239
|
+
await lockMod.releaseSchedulerLock(lockFile, 'new-owner');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test('scheduler stop releases its lock before a replacement starts', async () => {
|
|
243
|
+
await store.writeTasks([]);
|
|
244
|
+
const ctx: PluginRuntimeContext = {
|
|
245
|
+
provider,
|
|
246
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => ({
|
|
247
|
+
ok: true, result: 'ok', numTurns: 1, events: [],
|
|
248
|
+
}),
|
|
249
|
+
};
|
|
250
|
+
const first = new schedulerMod.Scheduler(ctx);
|
|
251
|
+
first.start();
|
|
252
|
+
await waitFor(async () => await first.isActiveScheduler());
|
|
253
|
+
await first.stop();
|
|
254
|
+
const second = new schedulerMod.Scheduler(ctx);
|
|
255
|
+
second.start();
|
|
256
|
+
await waitFor(async () => await second.isActiveScheduler());
|
|
257
|
+
expect(await second.isActiveScheduler()).toBe(true);
|
|
258
|
+
await second.stop();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('scheduler stop aborts and drains an in-flight task', async () => {
|
|
262
|
+
const sessionId = 'long-run-session';
|
|
263
|
+
await createBoundSession(process.cwd(), sessionId);
|
|
264
|
+
const task = store.createTask({
|
|
265
|
+
name: 'Long run', cron: '* * * * *', timezone: 'local', cwd: process.cwd(),
|
|
266
|
+
sessionId,
|
|
267
|
+
action: { type: 'prompt', prompt: 'wait' },
|
|
268
|
+
});
|
|
269
|
+
await store.upsertTask(task);
|
|
270
|
+
let started = false;
|
|
271
|
+
const scheduler = new schedulerMod.Scheduler({
|
|
272
|
+
provider,
|
|
273
|
+
runAgentTurn: async (opts): Promise<RunAgentTurnResult> => {
|
|
274
|
+
started = true;
|
|
275
|
+
await new Promise<void>((resolve) => {
|
|
276
|
+
if (opts.signal?.aborted) resolve();
|
|
277
|
+
else opts.signal?.addEventListener('abort', () => resolve(), { once: true });
|
|
278
|
+
});
|
|
279
|
+
return { ok: false, result: '', error: 'aborted', numTurns: 0, events: [] };
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
const running = scheduler.runTaskNow(task.id);
|
|
283
|
+
await waitFor(async () => started);
|
|
284
|
+
await scheduler.stop();
|
|
285
|
+
await running;
|
|
286
|
+
const updated = await store.getTask(task.id);
|
|
287
|
+
expect(updated?.stats.failureCount).toBe(1);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('nextRunAt is a sane near-future time for every task, never the Unix epoch (map-index regression)', async () => {
|
|
291
|
+
// 真机 e2e 抓到的回归:listTasks/writeTasks 曾写成 .map(refreshNextRun),Array.map 把
|
|
292
|
+
// (element, index, array) 全传进去 → 第二实参 index(0,1,2...) 顶掉了 refreshNextRun 的
|
|
293
|
+
// fromMs=Date.now() 默认值 → nextCronRunMs 从 Unix 纪元(≈0ms)起算 → nextRunAt 恒为
|
|
294
|
+
// 1970-01-01。这里建**多个**任务,断言每一个(尤其 index>0)的 nextRunAt 都落在「现在」
|
|
295
|
+
// 附近的未来,绝不落在 1970——修复前 index=0 那条必 < now,本用例会红。
|
|
296
|
+
const a = store.createTask({ name: 'Every-min A', cron: '* * * * *', timezone: 'local', cwd: process.cwd(), action: { type: 'prompt', prompt: 'a' } });
|
|
297
|
+
const b = store.createTask({ name: 'Every-min B', cron: '* * * * *', timezone: 'local', cwd: process.cwd(), action: { type: 'prompt', prompt: 'b' } });
|
|
298
|
+
await store.upsertTask(a);
|
|
299
|
+
await store.upsertTask(b);
|
|
300
|
+
const now = Date.now();
|
|
301
|
+
const mine = (await store.listTasks()).filter((t) => t.id === a.id || t.id === b.id);
|
|
302
|
+
expect(mine).toHaveLength(2);
|
|
303
|
+
for (const t of mine) {
|
|
304
|
+
const iso = t.schedule.nextRunAt;
|
|
305
|
+
expect(iso).toBeTruthy();
|
|
306
|
+
const ms = Date.parse(iso!);
|
|
307
|
+
expect(Number.isFinite(ms)).toBe(true);
|
|
308
|
+
// 全通配下一次运行必在未来 1 分钟内;留 5s 容差防跨秒抖动。关键:绝不能是 1970。
|
|
309
|
+
expect(ms).toBeGreaterThan(now - 5_000);
|
|
310
|
+
expect(ms).toBeLessThan(now + 65_000);
|
|
311
|
+
expect(new Date(ms).getUTCFullYear()).toBeGreaterThanOrEqual(2025);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test('maxRuns completes the task after N runs (generalizes once)', async () => {
|
|
316
|
+
const sessionId = 'max-runs-session';
|
|
317
|
+
await createBoundSession(process.cwd(), sessionId);
|
|
318
|
+
const task = store.createTask({
|
|
319
|
+
name: 'Twice',
|
|
320
|
+
cron: '* * * * *',
|
|
321
|
+
timezone: 'local',
|
|
322
|
+
cwd: process.cwd(),
|
|
323
|
+
sessionId,
|
|
324
|
+
maxRuns: 2,
|
|
325
|
+
action: { type: 'prompt', prompt: 'hi' },
|
|
326
|
+
});
|
|
327
|
+
await store.upsertTask(task);
|
|
328
|
+
const ctx: PluginRuntimeContext = {
|
|
329
|
+
provider,
|
|
330
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => ({ ok: true, result: 'ok', numTurns: 1, events: [] }),
|
|
331
|
+
};
|
|
332
|
+
const scheduler = new schedulerMod.Scheduler(ctx);
|
|
333
|
+
await scheduler.runTaskNow(task.id);
|
|
334
|
+
expect((await store.getTask(task.id))?.status).toBe('active'); // 1/2 未满,继续
|
|
335
|
+
await scheduler.runTaskNow(task.id);
|
|
336
|
+
const done = await store.getTask(task.id);
|
|
337
|
+
expect(done?.status).toBe('completed'); // 2/2 达到 → 完成
|
|
338
|
+
expect(done?.stats.runCount).toBe(2);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
test('overlapping interval slots are skipped and never queued for catch-up', async () => {
|
|
342
|
+
const now = Date.parse('2026-07-10T10:05:20.000Z');
|
|
343
|
+
const anchor = '2026-07-10T10:00:00.000Z';
|
|
344
|
+
const task = store.createTask({
|
|
345
|
+
name: 'Camera',
|
|
346
|
+
intervalMs: 60_000,
|
|
347
|
+
anchorAt: anchor,
|
|
348
|
+
timezone: 'local',
|
|
349
|
+
cwd: process.cwd(),
|
|
350
|
+
action: { type: 'prompt', prompt: 'inspect' },
|
|
351
|
+
});
|
|
352
|
+
task.createdAt = anchor;
|
|
353
|
+
task.schedule.lastScheduledFor = '2026-07-10T10:01:00.000Z';
|
|
354
|
+
await store.upsertTask(task);
|
|
355
|
+
let calls = 0;
|
|
356
|
+
const scheduler = new schedulerMod.Scheduler({
|
|
357
|
+
provider,
|
|
358
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => {
|
|
359
|
+
calls++;
|
|
360
|
+
return { ok: true, result: 'ok', numTurns: 1, events: [] };
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
const internal = scheduler as unknown as {
|
|
364
|
+
executions: Map<string, Promise<void>>;
|
|
365
|
+
processDueTask(task: CronTask, now: number): Promise<void>;
|
|
366
|
+
};
|
|
367
|
+
internal.executions.set(task.id, new Promise(() => {}));
|
|
368
|
+
await internal.processDueTask((await store.getTask(task.id))!, now);
|
|
369
|
+
internal.executions.delete(task.id);
|
|
370
|
+
await internal.processDueTask((await store.getTask(task.id))!, now);
|
|
371
|
+
const updated = await store.getTask(task.id);
|
|
372
|
+
expect(updated?.stats.skippedCount).toBe(4);
|
|
373
|
+
expect(updated?.stats.runCount).toBe(0);
|
|
374
|
+
expect(updated?.schedule.lastScheduledFor).toBe('2026-07-10T10:05:00.000Z');
|
|
375
|
+
expect(calls).toBe(0);
|
|
376
|
+
const missed = await store.listMissed(20);
|
|
377
|
+
expect(missed.some((item) => item.taskId === task.id && item.reason === 'overlap')).toBe(true);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test('all cron runs reuse the bound original session', async () => {
|
|
381
|
+
const seen: string[] = [];
|
|
382
|
+
const ctx: PluginRuntimeContext = {
|
|
383
|
+
provider,
|
|
384
|
+
runAgentTurn: async (opts): Promise<RunAgentTurnResult> => {
|
|
385
|
+
seen.push(opts.sessionId);
|
|
386
|
+
return { ok: true, result: 'ok', numTurns: 1, events: [] };
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
const firstSessionId = 'persistent-session-a';
|
|
390
|
+
const secondSessionId = 'persistent-session-b';
|
|
391
|
+
await createBoundSession(process.cwd(), firstSessionId);
|
|
392
|
+
await createBoundSession(process.cwd(), secondSessionId);
|
|
393
|
+
const persistent = store.createTask({
|
|
394
|
+
name: 'Persistent', cron: '* * * * *', timezone: 'local', cwd: process.cwd(),
|
|
395
|
+
sessionId: firstSessionId,
|
|
396
|
+
action: { type: 'prompt', prompt: 'x' },
|
|
397
|
+
});
|
|
398
|
+
const second = store.createTask({
|
|
399
|
+
name: 'Second persistent', cron: '* * * * *', timezone: 'local', cwd: process.cwd(),
|
|
400
|
+
sessionId: secondSessionId,
|
|
401
|
+
action: { type: 'prompt', prompt: 'x' },
|
|
402
|
+
});
|
|
403
|
+
await store.upsertTask(persistent);
|
|
404
|
+
await store.upsertTask(second);
|
|
405
|
+
const scheduler = new schedulerMod.Scheduler(ctx);
|
|
406
|
+
await scheduler.runTaskNow(persistent.id);
|
|
407
|
+
await scheduler.runTaskNow(persistent.id);
|
|
408
|
+
await scheduler.runTaskNow(second.id);
|
|
409
|
+
await scheduler.runTaskNow(second.id);
|
|
410
|
+
expect(seen[0]).toBe(seen[1]);
|
|
411
|
+
expect(seen[0]).toBe(persistent.runtime.sessionId);
|
|
412
|
+
expect(seen[2]).toBe(seen[3]);
|
|
413
|
+
expect(seen[2]).toBe(second.runtime.sessionId);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test('deleting a bound session pauses the task instead of silently starting over', async () => {
|
|
417
|
+
const fakeCwd = await mkdtemp(join(tmpdir(), 'cron-runner-session-test-'));
|
|
418
|
+
const sessionId = 'my-bound-session';
|
|
419
|
+
const sessionFile = sessionFileFor(fakeCwd, sessionId);
|
|
420
|
+
await mkdir(join(sessionFile, '..'), { recursive: true });
|
|
421
|
+
await writeFile(sessionFile, JSON.stringify({ messages: [{ role: 'system', content: 'x' }] }), 'utf8');
|
|
422
|
+
|
|
423
|
+
const task = store.createTask({
|
|
424
|
+
name: 'Bound to a real session',
|
|
425
|
+
cron: '* * * * *',
|
|
426
|
+
timezone: 'local',
|
|
427
|
+
cwd: fakeCwd,
|
|
428
|
+
sessionId,
|
|
429
|
+
action: { type: 'prompt', prompt: 'hi' },
|
|
430
|
+
});
|
|
431
|
+
await store.upsertTask(task);
|
|
432
|
+
expect(task.runtime.bindingStatus).toBe('bound');
|
|
433
|
+
|
|
434
|
+
let calls = 0;
|
|
435
|
+
const ctx: PluginRuntimeContext = {
|
|
436
|
+
provider,
|
|
437
|
+
runAgentTurn: async (): Promise<RunAgentTurnResult> => {
|
|
438
|
+
calls++;
|
|
439
|
+
return { ok: true, result: 'ok', numTurns: 1, events: [] };
|
|
440
|
+
},
|
|
441
|
+
};
|
|
442
|
+
const scheduler = new schedulerMod.Scheduler(ctx);
|
|
443
|
+
|
|
444
|
+
// Session still exists: the task runs normally.
|
|
445
|
+
await scheduler.runTaskNow(task.id);
|
|
446
|
+
expect(calls).toBe(1);
|
|
447
|
+
expect((await store.getTask(task.id))?.runtime.bindingStatus).toBe('bound');
|
|
448
|
+
|
|
449
|
+
// Simulate the desktop client deleting this session.
|
|
450
|
+
expect(existsSync(sessionFile)).toBe(true);
|
|
451
|
+
await unlink(sessionFile);
|
|
452
|
+
|
|
453
|
+
await scheduler.runTaskNow(task.id);
|
|
454
|
+
// Must NOT silently start a fresh turn against an empty history.
|
|
455
|
+
expect(calls).toBe(1);
|
|
456
|
+
const updated = await store.getTask(task.id);
|
|
457
|
+
expect(updated?.runtime.bindingStatus).toBe('needs_binding');
|
|
458
|
+
expect(updated?.status).toBe('paused');
|
|
459
|
+
expect(updated?.stats.runCount).toBe(1);
|
|
460
|
+
expect(updated?.stats.failureCount).toBe(0);
|
|
461
|
+
const runs = await store.recentRuns(task.id, 10);
|
|
462
|
+
expect(runs.filter((r) => r.status === 'success')).toHaveLength(1);
|
|
463
|
+
const missed = await store.listMissed();
|
|
464
|
+
expect(missed.some((record) => record.taskId === task.id && record.reason === 'binding_unavailable')).toBe(true);
|
|
465
|
+
|
|
466
|
+
await rm(fakeCwd, { recursive: true, force: true });
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
test('create --max-runs validates and persists the run limit', async () => {
|
|
470
|
+
expect(
|
|
471
|
+
await commands.handleCronCommand('cron', 'create --name Bad --cron "* * * * *" --prompt x --max-runs 0', null),
|
|
472
|
+
).toContain('无效 max-runs');
|
|
473
|
+
expect(
|
|
474
|
+
await commands.handleCronCommand('cron', 'create --name Bad2 --cron "* * * * *" --prompt x --max-runs abc', null),
|
|
475
|
+
).toContain('无效 max-runs');
|
|
476
|
+
await commands.handleCronCommand('cron', 'create --name Good --cron "* * * * *" --prompt x --max-runs 3', null);
|
|
477
|
+
const good = (await store.listTasks()).find((x) => x.name === 'Good');
|
|
478
|
+
expect(good?.maxRuns).toBe(3);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
test('create --workflow schedules a workflow action (cron × workflow-runner 联动路径)', async () => {
|
|
482
|
+
await commands.handleCronCommand(
|
|
483
|
+
'cron',
|
|
484
|
+
'create --name "定时PPT" --cron "0 */2 * * *" --workflow "e2e-write-greet.yaml hello" --max-runs 2 --fresh-session',
|
|
485
|
+
null,
|
|
486
|
+
);
|
|
487
|
+
const t = (await store.listTasks()).find((x) => x.name === '定时PPT');
|
|
488
|
+
expect(t?.action).toEqual({ type: 'workflow', command: 'e2e-write-greet.yaml hello' });
|
|
489
|
+
expect(t?.maxRuns).toBe(2);
|
|
490
|
+
expect(t?.runtime.sessionMode).toBe('fresh');
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
async function waitFor(check: () => Promise<boolean>, timeoutMs = 500): Promise<void> {
|
|
495
|
+
const deadline = Date.now() + timeoutMs;
|
|
496
|
+
while (Date.now() < deadline) {
|
|
497
|
+
if (await check()) return;
|
|
498
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
499
|
+
}
|
|
500
|
+
throw new Error('condition not reached before timeout');
|
|
501
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 缓存这次 import,所以 cold start 后 dynamic import 只跑一次。
|
|
13
13
|
* ============================================================
|
|
14
14
|
*/
|
|
15
|
-
import { ALL_TOOLS, getWorkingDir } from '../../src/plugin-sdk.js';
|
|
15
|
+
import { ALL_TOOLS, buildTransientPromptBundle, createAgentRuntimeContext, derivePromptCacheContext, filterToolsForRuntime, getWorkingDir, } from '../../src/plugin-sdk.js';
|
|
16
16
|
import { runWorkflowFromCommand, runWorkflowsList } from './src/index.js';
|
|
17
17
|
const api = {
|
|
18
18
|
async *runCommand(commandName, args, ctx) {
|
|
@@ -22,13 +22,67 @@ const api = {
|
|
|
22
22
|
}
|
|
23
23
|
if (commandName === 'workflow') {
|
|
24
24
|
const cwd = getWorkingDir();
|
|
25
|
+
const workflowRuntime = createAgentRuntimeContext({
|
|
26
|
+
...(ctx.runtimeContext ?? {
|
|
27
|
+
profile: 'main',
|
|
28
|
+
interactiveAsk: false,
|
|
29
|
+
}),
|
|
30
|
+
// The command runs inside the workflow's async-scoped workspace. A
|
|
31
|
+
// parent Desktop/CLI runtime may have been created before that scope.
|
|
32
|
+
cwd,
|
|
33
|
+
surface: 'workflow',
|
|
34
|
+
owner: ctx.runtimeContext?.owner ?? 'untrusted',
|
|
35
|
+
memoryAccess: ctx.runtimeContext?.memoryAccess === 'denied'
|
|
36
|
+
? 'denied'
|
|
37
|
+
: 'read-only',
|
|
38
|
+
});
|
|
39
|
+
const hostToolNames = ctx.allowedTools
|
|
40
|
+
? new Set(ctx.allowedTools)
|
|
41
|
+
: undefined;
|
|
42
|
+
const hostTools = hostToolNames
|
|
43
|
+
? ALL_TOOLS.filter((tool) => hostToolNames.has(tool.name))
|
|
44
|
+
: ALL_TOOLS;
|
|
45
|
+
const workflowTools = filterToolsForRuntime(hostTools, workflowRuntime);
|
|
46
|
+
const transientBundle = ctx.transientBundle ??
|
|
47
|
+
(await buildTransientPromptBundle({
|
|
48
|
+
cwd,
|
|
49
|
+
tools: workflowTools,
|
|
50
|
+
profile: 'main',
|
|
51
|
+
includeProjectInstructions: true,
|
|
52
|
+
includePlugins: true,
|
|
53
|
+
runtime: {
|
|
54
|
+
surface: 'workflow',
|
|
55
|
+
cwd,
|
|
56
|
+
workspaceId: workflowRuntime.workspaceId,
|
|
57
|
+
interactiveAsk: workflowRuntime.interactiveAsk,
|
|
58
|
+
memoryAccess: workflowRuntime.memoryAccess,
|
|
59
|
+
currentUserInput: args,
|
|
60
|
+
},
|
|
61
|
+
}).catch(() => undefined));
|
|
25
62
|
yield* runWorkflowFromCommand(args, {
|
|
26
63
|
provider: ctx.provider,
|
|
27
64
|
history: ctx.history,
|
|
28
65
|
signal: ctx.signal,
|
|
29
66
|
sessionState: ctx.sessionState,
|
|
30
67
|
cwd,
|
|
31
|
-
tools:
|
|
68
|
+
tools: workflowTools,
|
|
69
|
+
runtimeContext: workflowRuntime,
|
|
70
|
+
executeTool: ctx.executeTool,
|
|
71
|
+
toolContext: {
|
|
72
|
+
history: ctx.history,
|
|
73
|
+
sessionState: ctx.sessionState,
|
|
74
|
+
provider: ctx.provider,
|
|
75
|
+
toolGate: ctx.host?.toolGate,
|
|
76
|
+
promptCache: ctx.promptCache,
|
|
77
|
+
workspaceId: workflowRuntime.workspaceId,
|
|
78
|
+
sessionId: workflowRuntime.sessionId,
|
|
79
|
+
memoryAccess: workflowRuntime.memoryAccess,
|
|
80
|
+
},
|
|
81
|
+
// 宿主授权上下文原样带上;引擎按各步 `uses:` 切片后才转给工具,不整份下发。
|
|
82
|
+
host: ctx.host,
|
|
83
|
+
transientContext: ctx.transientContext,
|
|
84
|
+
transientBundle,
|
|
85
|
+
promptCache: derivePromptCacheContext(ctx.promptCache, `workflow:${args.trim() || 'interactive'}`),
|
|
32
86
|
});
|
|
33
87
|
return;
|
|
34
88
|
}
|