@cjhyy/code-shell-core 0.5.0-rc.1 → 0.6.0-rc.1
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 +13 -10
- package/dist/agent/agent-definition-registry.d.ts +21 -3
- package/dist/agent/agent-definition-registry.js +49 -18
- package/dist/agent/agent-definition.d.ts +32 -0
- package/dist/agent/agent-definition.js +49 -4
- package/dist/arena/arena.js +11 -12
- package/dist/arena/context/context-tools.js +47 -6
- package/dist/arena/context/within-root.d.ts +7 -0
- package/dist/arena/context/within-root.js +15 -0
- package/dist/arena/iterate/phases/argue.js +8 -2
- package/dist/arena/iterate/phases/revise.js +1 -1
- package/dist/arena/iterate/phases/tournament.js +3 -3
- package/dist/arena/ledger.js +9 -1
- package/dist/arena/phases/adjudication.js +1 -4
- package/dist/arena/phases/build-consensus.js +1 -4
- package/dist/arena/phases/cross-review.js +2 -8
- package/dist/arena/phases/debate-rounds.js +1 -4
- package/dist/arena/phases/participant-research.js +1 -4
- package/dist/arena/phases/planning-detail-expansion.js +8 -10
- package/dist/arena/planner.js +0 -1
- package/dist/arena/providers/docs.d.ts +1 -0
- package/dist/arena/providers/docs.js +5 -2
- package/dist/arena/providers/repo.d.ts +1 -0
- package/dist/arena/providers/repo.js +5 -2
- package/dist/arena/strategies/utils.d.ts +1 -4
- package/dist/arena/strategies/utils.js +7 -51
- package/dist/arena/transitions.d.ts +7 -2
- package/dist/arena/transitions.js +9 -4
- package/dist/arena/types.d.ts +8 -2
- package/dist/automation/cron-expr.d.ts +41 -0
- package/dist/automation/cron-expr.js +169 -0
- package/dist/automation/index.d.ts +41 -0
- package/dist/automation/index.js +39 -0
- package/dist/automation/runner.d.ts +84 -0
- package/dist/automation/runner.js +92 -0
- package/dist/automation/scheduler.d.ts +194 -0
- package/dist/automation/scheduler.js +623 -0
- package/dist/automation/store.d.ts +39 -0
- package/dist/automation/store.js +122 -0
- package/dist/automation/write-policy.d.ts +34 -0
- package/dist/automation/write-policy.js +113 -0
- package/dist/automation/write-run.d.ts +51 -0
- package/dist/automation/write-run.js +38 -0
- package/dist/capability-control/disabled-lists.d.ts +25 -0
- package/dist/capability-control/disabled-lists.js +57 -0
- package/dist/capability-control/index.d.ts +5 -0
- package/dist/capability-control/index.js +3 -0
- package/dist/capability-control/overlay.d.ts +64 -0
- package/dist/capability-control/overlay.js +116 -0
- package/dist/capability-control/project.d.ts +65 -0
- package/dist/capability-control/project.js +147 -0
- package/dist/capability-control/service.d.ts +70 -0
- package/dist/capability-control/service.js +147 -0
- package/dist/capability-control/types.d.ts +62 -0
- package/dist/capability-control/types.js +17 -0
- package/dist/cc-orchestrator/agent-adapter.d.ts +50 -0
- package/dist/cc-orchestrator/agent-adapter.js +133 -0
- package/dist/cc-orchestrator/cc-capability.d.ts +19 -0
- package/dist/cc-orchestrator/cc-capability.js +53 -0
- package/dist/cc-orchestrator/codex-session-discovery.d.ts +24 -0
- package/dist/cc-orchestrator/codex-session-discovery.js +191 -0
- package/dist/cc-orchestrator/codex-session-history.d.ts +25 -0
- package/dist/cc-orchestrator/codex-session-history.js +187 -0
- package/dist/cc-orchestrator/external-agent-changes.d.ts +19 -0
- package/dist/cc-orchestrator/external-agent-changes.js +214 -0
- package/dist/cc-orchestrator/external-agent-driver.d.ts +18 -0
- package/dist/cc-orchestrator/external-agent-driver.js +69 -0
- package/dist/cc-orchestrator/index.d.ts +8 -0
- package/dist/cc-orchestrator/index.js +8 -0
- package/dist/cc-orchestrator/relevance-judge.d.ts +15 -0
- package/dist/cc-orchestrator/relevance-judge.js +29 -0
- package/dist/cc-orchestrator/session-discovery.d.ts +46 -0
- package/dist/cc-orchestrator/session-discovery.js +125 -0
- package/dist/cc-orchestrator/session-history.d.ts +19 -0
- package/dist/cc-orchestrator/session-history.js +67 -0
- package/dist/cli/agent-server-stdio.d.ts +26 -1
- package/dist/cli/agent-server-stdio.js +221 -28
- package/dist/cli/agent-server-tcp.d.ts +20 -0
- package/dist/cli/agent-server-tcp.js +134 -0
- package/dist/cli/graceful-shutdown.d.ts +27 -0
- package/dist/cli/graceful-shutdown.js +30 -0
- package/dist/context/compaction.d.ts +56 -0
- package/dist/context/compaction.js +209 -15
- package/dist/context/manager.d.ts +0 -20
- package/dist/context/manager.js +25 -41
- package/dist/cost-tracker.js +5 -61
- package/dist/credentials/cipher.d.ts +49 -0
- package/dist/credentials/cipher.js +45 -0
- package/dist/credentials/cookie-jar.d.ts +24 -0
- package/dist/credentials/cookie-jar.js +40 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/inject-credential-tool.d.ts +20 -0
- package/dist/credentials/inject-credential-tool.js +130 -0
- package/dist/credentials/store.d.ts +72 -0
- package/dist/credentials/store.js +184 -0
- package/dist/credentials/types.d.ts +56 -0
- package/dist/credentials/use-credential-tool.d.ts +29 -0
- package/dist/credentials/use-credential-tool.js +205 -0
- package/dist/credentials/use-gate.d.ts +56 -0
- package/dist/credentials/use-gate.js +52 -0
- package/dist/cron/cron-runtime.d.ts +2 -0
- package/dist/cron/cron-runtime.js +2 -0
- package/dist/cron/cron-store.d.ts +2 -0
- package/dist/cron/cron-store.js +2 -0
- package/dist/cron/scheduler.d.ts +5 -32
- package/dist/cron/scheduler.js +5 -113
- package/dist/data/model-metadata.d.ts +77 -0
- package/dist/data/model-metadata.js +56 -0
- package/dist/data/model-metadata.json +216 -0
- package/dist/data/openrouter-models.d.ts +18 -7
- package/dist/data/openrouter-models.js +35 -8
- package/dist/data/openrouter-sync.js +1 -1
- package/dist/engine/aux-key.d.ts +10 -0
- package/dist/engine/aux-key.js +11 -0
- package/dist/engine/dynamic-tool-defs.d.ts +19 -0
- package/dist/engine/dynamic-tool-defs.js +36 -0
- package/dist/engine/engine.d.ts +431 -108
- package/dist/engine/engine.js +1630 -279
- package/dist/engine/friendly-error.d.ts +18 -0
- package/dist/engine/friendly-error.js +63 -0
- package/dist/engine/goal.d.ts +187 -0
- package/dist/engine/goal.js +196 -0
- package/dist/engine/image-compression.d.ts +81 -0
- package/dist/engine/image-compression.js +186 -0
- package/dist/engine/image-policy.d.ts +165 -0
- package/dist/engine/image-policy.js +189 -0
- package/dist/engine/model-connections-pool.d.ts +17 -0
- package/dist/engine/model-connections-pool.js +66 -0
- package/dist/engine/model-facade.d.ts +10 -0
- package/dist/engine/model-facade.js +25 -0
- package/dist/engine/patch-orphaned-tools.js +3 -0
- package/dist/engine/reactive-threshold.d.ts +13 -0
- package/dist/engine/reactive-threshold.js +17 -0
- package/dist/engine/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.js +9 -1
- package/dist/engine/sandbox-cache-key.d.ts +10 -0
- package/dist/engine/sandbox-cache-key.js +9 -0
- package/dist/engine/sandbox-config.d.ts +31 -0
- package/dist/engine/sandbox-config.js +38 -0
- package/dist/engine/session-title.d.ts +13 -0
- package/dist/engine/session-title.js +34 -0
- package/dist/engine/session-usage.d.ts +19 -0
- package/dist/engine/session-usage.js +25 -0
- package/dist/engine/steer-queue.d.ts +32 -0
- package/dist/engine/steer-queue.js +26 -0
- package/dist/engine/streaming-tool-queue.d.ts +12 -0
- package/dist/engine/streaming-tool-queue.js +50 -10
- package/dist/engine/turn-loop.d.ts +94 -9
- package/dist/engine/turn-loop.js +775 -342
- package/dist/engine/types.d.ts +175 -0
- package/dist/engine/types.js +13 -0
- package/dist/external-agents/config.d.ts +2 -0
- package/dist/external-agents/config.js +15 -0
- package/dist/external-agents/types.d.ts +31 -0
- package/dist/external-agents/types.js +1 -0
- package/dist/git/parse-log.d.ts +13 -0
- package/dist/git/parse-log.js +21 -0
- package/dist/git/utils.d.ts +8 -6
- package/dist/git/utils.js +62 -26
- package/dist/git/worktree.d.ts +48 -0
- package/dist/git/worktree.js +111 -20
- package/dist/hooks/events.d.ts +23 -1
- package/dist/hooks/goal-stop-hook.d.ts +58 -0
- package/dist/hooks/goal-stop-hook.js +279 -0
- package/dist/hooks/hook-output.d.ts +33 -0
- package/dist/hooks/hook-output.js +79 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +57 -1
- package/dist/hooks/shell-runner.d.ts +2 -0
- package/dist/hooks/shell-runner.js +48 -18
- package/dist/index.d.ts +79 -11
- package/dist/index.js +89 -6
- package/dist/llm/capabilities/param-specs.d.ts +14 -0
- package/dist/llm/capabilities/param-specs.js +62 -0
- package/dist/llm/capabilities/reasoning-control.d.ts +24 -0
- package/dist/llm/capabilities/reasoning-control.js +38 -0
- package/dist/llm/capabilities/rules.js +37 -3
- package/dist/llm/capabilities/types.d.ts +32 -2
- package/dist/llm/clamp-max-tokens.d.ts +11 -0
- package/dist/llm/clamp-max-tokens.js +17 -0
- package/dist/llm/client-base.d.ts +69 -5
- package/dist/llm/client-base.js +185 -25
- package/dist/llm/client-factory.d.ts +3 -3
- package/dist/llm/client-factory.js +2 -2
- package/dist/llm/model-cache.js +4 -2
- package/dist/llm/model-pool.d.ts +29 -11
- package/dist/llm/model-pool.js +36 -20
- package/dist/llm/provider-auth.d.ts +41 -0
- package/dist/llm/provider-auth.js +76 -0
- package/dist/llm/provider-catalog.d.ts +6 -2
- package/dist/llm/providers/anthropic.d.ts +32 -2
- package/dist/llm/providers/anthropic.js +207 -18
- package/dist/llm/providers/openai.d.ts +47 -2
- package/dist/llm/providers/openai.js +478 -71
- package/dist/llm/reasoning-setting.d.ts +51 -0
- package/dist/llm/reasoning-setting.js +40 -0
- package/dist/llm/stop-reason.d.ts +13 -0
- package/dist/llm/stop-reason.js +21 -0
- package/dist/llm/stream-watchdog.js +5 -1
- package/dist/llm/strip-vision.d.ts +32 -0
- package/dist/llm/strip-vision.js +94 -0
- package/dist/llm/token-counter.js +9 -2
- package/dist/llm/types.d.ts +9 -6
- package/dist/logging/logger.js +18 -4
- package/dist/logging/sanitize-messages.d.ts +10 -0
- package/dist/logging/sanitize-messages.js +112 -0
- package/dist/lsp/client.js +28 -8
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +42 -11
- package/dist/lsp/root-path.d.ts +9 -0
- package/dist/lsp/root-path.js +12 -0
- package/dist/model-catalog/builtin.d.ts +12 -0
- package/dist/model-catalog/builtin.js +407 -0
- package/dist/model-catalog/gen-connections.d.ts +20 -0
- package/dist/model-catalog/gen-connections.js +28 -0
- package/dist/model-catalog/index.d.ts +41 -0
- package/dist/model-catalog/index.js +90 -0
- package/dist/model-catalog/params.d.ts +20 -0
- package/dist/model-catalog/params.js +45 -0
- package/dist/model-catalog/resolve.d.ts +48 -0
- package/dist/model-catalog/resolve.js +33 -0
- package/dist/model-catalog/save-entry.d.ts +32 -0
- package/dist/model-catalog/save-entry.js +104 -0
- package/dist/model-catalog/types.d.ts +561 -0
- package/dist/model-catalog/types.js +93 -0
- package/dist/model-catalog/upsert.d.ts +9 -0
- package/dist/model-catalog/upsert.js +8 -0
- package/dist/onboarding.d.ts +12 -82
- package/dist/onboarding.js +75 -333
- package/dist/plugins/gitOps.d.ts +53 -0
- package/dist/plugins/gitOps.js +130 -5
- package/dist/plugins/installer/checkUpdate.d.ts +16 -0
- package/dist/plugins/installer/checkUpdate.js +32 -0
- package/dist/plugins/installer/codex/convertAgents.d.ts +7 -0
- package/dist/plugins/installer/codex/convertAgents.js +55 -0
- package/dist/plugins/installer/codex/convertCommands.d.ts +19 -0
- package/dist/plugins/installer/codex/convertCommands.js +46 -0
- package/dist/plugins/installer/codex/convertMcp.d.ts +11 -0
- package/dist/plugins/installer/codex/convertMcp.js +85 -0
- package/dist/plugins/installer/codex/convertSkills.d.ts +12 -0
- package/dist/plugins/installer/codex/convertSkills.js +33 -0
- package/dist/plugins/installer/detectFormat.d.ts +2 -0
- package/dist/plugins/installer/detectFormat.js +6 -0
- package/dist/plugins/installer/install.d.ts +7 -0
- package/dist/plugins/installer/install.js +123 -0
- package/dist/plugins/installer/installFromArchive.d.ts +43 -0
- package/dist/plugins/installer/installFromArchive.js +134 -0
- package/dist/plugins/installer/installFromSource.d.ts +13 -0
- package/dist/plugins/installer/installFromSource.js +51 -0
- package/dist/plugins/installer/list.d.ts +9 -0
- package/dist/plugins/installer/list.js +30 -0
- package/dist/plugins/installer/loadPluginAgents.d.ts +3 -0
- package/dist/plugins/installer/loadPluginAgents.js +27 -0
- package/dist/plugins/installer/loadPluginMcp.d.ts +14 -0
- package/dist/plugins/installer/loadPluginMcp.js +107 -0
- package/dist/plugins/installer/parseSource.d.ts +20 -0
- package/dist/plugins/installer/parseSource.js +74 -0
- package/dist/plugins/installer/paths.d.ts +5 -0
- package/dist/plugins/installer/paths.js +25 -0
- package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
- package/dist/plugins/installer/pruneDisabled.js +73 -0
- package/dist/plugins/installer/types.d.ts +52 -0
- package/dist/plugins/installer/types.js +28 -0
- package/dist/plugins/installer/uninstall.d.ts +2 -0
- package/dist/plugins/installer/uninstall.js +18 -0
- package/dist/plugins/installer/unzip.d.ts +14 -0
- package/dist/plugins/installer/unzip.js +82 -0
- package/dist/plugins/installer/update.d.ts +28 -0
- package/dist/plugins/installer/update.js +97 -0
- package/dist/plugins/loadPluginHooks.d.ts +54 -1
- package/dist/plugins/loadPluginHooks.js +83 -1
- package/dist/plugins/marketplaceManager.d.ts +15 -1
- package/dist/plugins/marketplaceManager.js +58 -4
- package/dist/plugins/pluginCommandHook.js +34 -14
- package/dist/plugins/pluginContent.d.ts +30 -0
- package/dist/plugins/pluginContent.js +83 -0
- package/dist/plugins/pluginInstaller.d.ts +34 -0
- package/dist/plugins/pluginInstaller.js +168 -35
- package/dist/plugins/schemas.js +41 -6
- package/dist/plugins/types.d.ts +10 -0
- package/dist/preset/index.d.ts +7 -1
- package/dist/preset/index.js +112 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +31 -0
- package/dist/prompt/composer.js +95 -25
- package/dist/prompt/instruction-scanner.js +5 -3
- package/dist/prompt/section-loader.js +1 -0
- package/dist/prompt/sections/base.md +1 -0
- package/dist/prompt/sections/browser.md +10 -0
- package/dist/prompt/sections/coding.md +4 -0
- package/dist/prompt/sections/orchestration.md +8 -0
- package/dist/protocol/chat-session-manager.d.ts +15 -2
- package/dist/protocol/chat-session-manager.js +46 -0
- package/dist/protocol/chat-session.d.ts +82 -0
- package/dist/protocol/chat-session.js +121 -1
- package/dist/protocol/client.d.ts +27 -0
- package/dist/protocol/client.js +38 -0
- package/dist/protocol/redact.d.ts +50 -0
- package/dist/protocol/redact.js +71 -0
- package/dist/protocol/server.d.ts +153 -2
- package/dist/protocol/server.js +807 -39
- package/dist/protocol/tcp-transport.d.ts +45 -0
- package/dist/protocol/tcp-transport.js +74 -0
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +69 -0
- package/dist/protocol/types.js +22 -0
- package/dist/quota/credentials.d.ts +3 -0
- package/dist/quota/credentials.js +80 -0
- package/dist/quota/index.d.ts +36 -0
- package/dist/quota/index.js +155 -0
- package/dist/quota/types.d.ts +48 -0
- package/dist/quota/types.js +13 -0
- package/dist/remote/bridge.d.ts +11 -2
- package/dist/remote/bridge.js +61 -33
- package/dist/review/review-prompt.d.ts +28 -0
- package/dist/review/review-prompt.js +81 -0
- package/dist/run/ArtifactTracker.js +5 -4
- package/dist/run/EngineRunner.d.ts +27 -1
- package/dist/run/EngineRunner.js +46 -8
- package/dist/run/FileRunStore.js +40 -11
- package/dist/run/RunApprovalBackend.js +25 -5
- package/dist/run/RunLock.d.ts +28 -2
- package/dist/run/RunLock.js +49 -7
- package/dist/run/RunManager.d.ts +12 -0
- package/dist/run/RunManager.js +86 -3
- package/dist/run/RunQueue.d.ts +1 -0
- package/dist/run/RunQueue.js +8 -2
- package/dist/run/factory.d.ts +8 -1
- package/dist/run/factory.js +1 -0
- package/dist/run/index.d.ts +2 -2
- package/dist/run/index.js +1 -1
- package/dist/run/redirect-target.d.ts +7 -0
- package/dist/run/redirect-target.js +13 -0
- package/dist/run/types.js +1 -1
- package/dist/runtime/background-shell.d.ts +139 -0
- package/dist/runtime/background-shell.js +495 -0
- package/dist/runtime/output-clean.d.ts +24 -0
- package/dist/runtime/output-clean.js +41 -0
- package/dist/runtime/ring-file.d.ts +64 -0
- package/dist/runtime/ring-file.js +174 -0
- package/dist/runtime/safe-spawn.js +15 -34
- package/dist/runtime/spawn-common.d.ts +148 -0
- package/dist/runtime/spawn-common.js +303 -0
- package/dist/runtime/truncate-output.d.ts +22 -0
- package/dist/runtime/truncate-output.js +49 -0
- package/dist/runtime/utf8-cut.d.ts +11 -0
- package/dist/runtime/utf8-cut.js +23 -0
- package/dist/services/auto-dream.d.ts +4 -0
- package/dist/services/auto-dream.js +26 -26
- package/dist/services/browser-open.d.ts +13 -0
- package/dist/services/browser-open.js +16 -0
- package/dist/services/diagnostics.d.ts +1 -2
- package/dist/services/diagnostics.js +12 -7
- package/dist/services/dream-consolidation.d.ts +57 -0
- package/dist/services/dream-consolidation.js +151 -0
- package/dist/services/extract-memories.d.ts +14 -1
- package/dist/services/extract-memories.js +45 -6
- package/dist/services/memory-orchestrator.d.ts +21 -0
- package/dist/services/memory-orchestrator.js +125 -32
- package/dist/services/notifier.d.ts +8 -0
- package/dist/services/notifier.js +39 -25
- package/dist/services/oauth.js +5 -7
- package/dist/services/session-memory-sort.d.ts +8 -0
- package/dist/services/session-memory-sort.js +9 -0
- package/dist/services/session-memory.js +30 -19
- package/dist/session/file-history.d.ts +124 -1
- package/dist/session/file-history.js +232 -9
- package/dist/session/memory.d.ts +116 -2
- package/dist/session/memory.js +250 -28
- package/dist/session/session-manager.d.ts +63 -1
- package/dist/session/session-manager.js +186 -5
- package/dist/session/simple-diff.d.ts +23 -0
- package/dist/session/simple-diff.js +84 -0
- package/dist/session/transcript.d.ts +25 -1
- package/dist/session/transcript.js +35 -2
- package/dist/session/undo-target.d.ts +67 -0
- package/dist/session/undo-target.js +144 -0
- package/dist/settings/disk-defaults.d.ts +42 -0
- package/dist/settings/disk-defaults.js +33 -0
- package/dist/settings/feature-flags.d.ts +64 -0
- package/dist/settings/feature-flags.js +61 -0
- package/dist/settings/manager.d.ts +101 -1
- package/dist/settings/manager.js +345 -15
- package/dist/settings/migrate-config.d.ts +45 -0
- package/dist/settings/migrate-config.js +125 -0
- package/dist/settings/personalization.d.ts +19 -0
- package/dist/settings/personalization.js +7 -0
- package/dist/settings/schema-export.d.ts +25 -0
- package/dist/settings/schema-export.js +38 -0
- package/dist/settings/schema.d.ts +1827 -396
- package/dist/settings/schema.js +361 -81
- package/dist/skills/scanner.d.ts +9 -0
- package/dist/skills/scanner.js +30 -2
- package/dist/stt/resolve-transcribe.d.ts +31 -0
- package/dist/stt/resolve-transcribe.js +108 -0
- package/dist/stt/transcribe.d.ts +51 -0
- package/dist/stt/transcribe.js +65 -0
- package/dist/tool-system/browser-bridge.d.ts +226 -0
- package/dist/tool-system/browser-bridge.js +163 -0
- package/dist/tool-system/builtin/add-marketplace.d.ts +12 -0
- package/dist/tool-system/builtin/add-marketplace.js +76 -0
- package/dist/tool-system/builtin/agent-heartbeat.d.ts +49 -0
- package/dist/tool-system/builtin/agent-heartbeat.js +89 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +12 -3
- package/dist/tool-system/builtin/agent-notifications.js +9 -3
- package/dist/tool-system/builtin/agent-output-file.d.ts +38 -0
- package/dist/tool-system/builtin/agent-output-file.js +72 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +23 -0
- package/dist/tool-system/builtin/agent-registry.js +16 -4
- package/dist/tool-system/builtin/agent.d.ts +50 -11
- package/dist/tool-system/builtin/agent.js +576 -73
- package/dist/tool-system/builtin/apply-patch/applier.js +66 -8
- package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +10 -0
- package/dist/tool-system/builtin/apply-patch/backup-targets.js +30 -0
- package/dist/tool-system/builtin/apply-patch/index.js +7 -3
- package/dist/tool-system/builtin/arena.js +6 -7
- package/dist/tool-system/builtin/background-jobs.d.ts +76 -0
- package/dist/tool-system/builtin/background-jobs.js +124 -0
- package/dist/tool-system/builtin/background-shell-tools.d.ts +20 -0
- package/dist/tool-system/builtin/background-shell-tools.js +108 -0
- package/dist/tool-system/builtin/background-work.d.ts +67 -0
- package/dist/tool-system/builtin/background-work.js +86 -0
- package/dist/tool-system/builtin/bash-output-style.d.ts +32 -0
- package/dist/tool-system/builtin/bash-output-style.js +40 -0
- package/dist/tool-system/builtin/bash.d.ts +5 -2
- package/dist/tool-system/builtin/bash.js +98 -62
- package/dist/tool-system/builtin/browser-tools.d.ts +33 -0
- package/dist/tool-system/builtin/browser-tools.js +312 -0
- package/dist/tool-system/builtin/cancel-goal.d.ts +31 -0
- package/dist/tool-system/builtin/cancel-goal.js +64 -0
- package/dist/tool-system/builtin/check-quota.d.ts +15 -0
- package/dist/tool-system/builtin/check-quota.js +34 -0
- package/dist/tool-system/builtin/complete-goal.d.ts +25 -0
- package/dist/tool-system/builtin/complete-goal.js +45 -0
- package/dist/tool-system/builtin/config.js +7 -0
- package/dist/tool-system/builtin/cron.d.ts +7 -0
- package/dist/tool-system/builtin/cron.js +105 -9
- package/dist/tool-system/builtin/drive-claude-code.d.ts +30 -0
- package/dist/tool-system/builtin/drive-claude-code.js +157 -0
- package/dist/tool-system/builtin/edit-model-catalog.d.ts +3 -0
- package/dist/tool-system/builtin/edit-model-catalog.js +94 -0
- package/dist/tool-system/builtin/edit.d.ts +2 -1
- package/dist/tool-system/builtin/edit.js +21 -12
- package/dist/tool-system/builtin/eol.d.ts +29 -0
- package/dist/tool-system/builtin/eol.js +37 -0
- package/dist/tool-system/builtin/file-cache.d.ts +6 -0
- package/dist/tool-system/builtin/file-cache.js +8 -0
- package/dist/tool-system/builtin/generate-image.d.ts +60 -0
- package/dist/tool-system/builtin/generate-image.js +374 -0
- package/dist/tool-system/builtin/generate-video.d.ts +55 -0
- package/dist/tool-system/builtin/generate-video.js +361 -0
- package/dist/tool-system/builtin/grep.js +6 -2
- package/dist/tool-system/builtin/image-providers.d.ts +86 -0
- package/dist/tool-system/builtin/image-providers.js +190 -0
- package/dist/tool-system/builtin/image-uploader.d.ts +33 -0
- package/dist/tool-system/builtin/image-uploader.js +74 -0
- package/dist/tool-system/builtin/index.d.ts +24 -1
- package/dist/tool-system/builtin/index.js +310 -25
- package/dist/tool-system/builtin/mcp-tools.js +23 -3
- package/dist/tool-system/builtin/memory.js +45 -7
- package/dist/tool-system/builtin/notebook-edit.d.ts +2 -1
- package/dist/tool-system/builtin/notebook-edit.js +1 -1
- package/dist/tool-system/builtin/powershell.js +4 -1
- package/dist/tool-system/builtin/read.d.ts +2 -1
- package/dist/tool-system/builtin/read.js +11 -3
- package/dist/tool-system/builtin/repl.js +4 -1
- package/dist/tool-system/builtin/skill.js +9 -0
- package/dist/tool-system/builtin/sleep.js +12 -5
- package/dist/tool-system/builtin/task.js +4 -1
- package/dist/tool-system/builtin/tool-search.js +25 -7
- package/dist/tool-system/builtin/update-automation-memory.d.ts +24 -0
- package/dist/tool-system/builtin/update-automation-memory.js +60 -0
- package/dist/tool-system/builtin/video-providers.d.ts +154 -0
- package/dist/tool-system/builtin/video-providers.js +235 -0
- package/dist/tool-system/builtin/view-image.d.ts +18 -0
- package/dist/tool-system/builtin/view-image.js +96 -0
- package/dist/tool-system/builtin/web-fetch.js +12 -2
- package/dist/tool-system/builtin/web-search.d.ts +4 -1
- package/dist/tool-system/builtin/web-search.js +57 -10
- package/dist/tool-system/builtin/worktree.d.ts +2 -1
- package/dist/tool-system/builtin/worktree.js +31 -4
- package/dist/tool-system/builtin/write.d.ts +2 -1
- package/dist/tool-system/builtin/write.js +1 -1
- package/dist/tool-system/context.d.ts +166 -6
- package/dist/tool-system/executor.d.ts +3 -2
- package/dist/tool-system/executor.js +197 -119
- package/dist/tool-system/investigation-guard.d.ts +4 -1
- package/dist/tool-system/investigation-guard.js +20 -4
- package/dist/tool-system/mcp-manager.d.ts +78 -16
- package/dist/tool-system/mcp-manager.js +357 -28
- package/dist/tool-system/path-policy.d.ts +99 -0
- package/dist/tool-system/path-policy.js +578 -0
- package/dist/tool-system/permission.d.ts +36 -1
- package/dist/tool-system/permission.js +322 -117
- package/dist/tool-system/plan-mode-allowlist.d.ts +32 -0
- package/dist/tool-system/plan-mode-allowlist.js +65 -0
- package/dist/tool-system/registry.d.ts +1 -0
- package/dist/tool-system/registry.js +26 -1
- package/dist/tool-system/sandbox/index.d.ts +8 -0
- package/dist/tool-system/sandbox/index.js +7 -2
- package/dist/tool-system/validate-tool-metadata.d.ts +36 -0
- package/dist/tool-system/validate-tool-metadata.js +63 -0
- package/dist/tool-system/validation.d.ts +10 -0
- package/dist/tool-system/validation.js +16 -3
- package/dist/types.d.ts +301 -15
- package/dist/updater.js +20 -9
- package/dist/utils/envUtils.d.ts +0 -9
- package/dist/utils/envUtils.js +3 -28
- package/dist/utils/exec.d.ts +40 -0
- package/dist/utils/exec.js +144 -0
- package/dist/utils/format.js +4 -2
- package/dist/utils/json.d.ts +12 -0
- package/dist/utils/json.js +92 -0
- package/dist/utils/lockfile.js +9 -2
- package/dist/utils/theme.d.ts +7 -1
- package/dist/utils/theme.js +5 -3
- package/dist/utils/toolDisplay.js +0 -1
- package/package.json +14 -7
- package/dist/agent/coordinator.d.ts +0 -49
- package/dist/agent/coordinator.js +0 -77
- package/dist/settings/manager.test.js +0 -73
- package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
- package/dist/tool-system/builtin/remote-trigger.js +0 -54
- package/dist/tool-system/builtin/send-message.d.ts +0 -6
- package/dist/tool-system/builtin/send-message.js +0 -47
- /package/dist/{settings/manager.test.d.ts → credentials/types.js} +0 -0
|
@@ -25,9 +25,23 @@ function parseScope(raw) {
|
|
|
25
25
|
}
|
|
26
26
|
return raw;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** Location: "global" → cross-project store (no projectDir); "project"
|
|
29
|
+
* (default, back-compat) → this repo's store. Anything else → "project". */
|
|
30
|
+
function parseLocation(raw) {
|
|
31
|
+
return raw === "global" ? "global" : "project";
|
|
30
32
|
}
|
|
33
|
+
function mmFor(ctx, scope, location = "project") {
|
|
34
|
+
// location=global → omit projectDir so the manager points at the global store.
|
|
35
|
+
return new MemoryManager({
|
|
36
|
+
projectDir: location === "global" ? undefined : ctx?.cwd,
|
|
37
|
+
scope,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const LOCATION_SCHEMA = {
|
|
41
|
+
type: "string",
|
|
42
|
+
enum: ["global", "project"],
|
|
43
|
+
description: 'Which store: "global" (applies across all projects) or "project" (this repo only). Defaults to "project".',
|
|
44
|
+
};
|
|
31
45
|
// ─── MemoryList ────────────────────────────────────────────────────────────
|
|
32
46
|
export const memoryListToolDef = {
|
|
33
47
|
name: "MemoryList",
|
|
@@ -43,6 +57,7 @@ export const memoryListToolDef = {
|
|
|
43
57
|
enum: ["user", "dream"],
|
|
44
58
|
description: "Which scope to list",
|
|
45
59
|
},
|
|
60
|
+
location: LOCATION_SCHEMA,
|
|
46
61
|
},
|
|
47
62
|
required: ["scope"],
|
|
48
63
|
},
|
|
@@ -53,7 +68,7 @@ export async function memoryListTool(args, ctx) {
|
|
|
53
68
|
return scope;
|
|
54
69
|
}
|
|
55
70
|
try {
|
|
56
|
-
const mm = mmFor(ctx, scope);
|
|
71
|
+
const mm = mmFor(ctx, scope, parseLocation(args.location));
|
|
57
72
|
const entries = mm.loadAll();
|
|
58
73
|
if (entries.length === 0)
|
|
59
74
|
return `(no memories in scope "${scope}")`;
|
|
@@ -78,6 +93,7 @@ export const memoryReadToolDef = {
|
|
|
78
93
|
enum: ["user", "dream"],
|
|
79
94
|
description: "Which scope to read from",
|
|
80
95
|
},
|
|
96
|
+
location: LOCATION_SCHEMA,
|
|
81
97
|
name: {
|
|
82
98
|
type: "string",
|
|
83
99
|
description: "The memory entry's name (from MemoryList output)",
|
|
@@ -91,15 +107,32 @@ export async function memoryReadTool(args, ctx) {
|
|
|
91
107
|
if (typeof scope !== "string" || !VALID_SCOPES.includes(scope)) {
|
|
92
108
|
return scope;
|
|
93
109
|
}
|
|
110
|
+
const location = parseLocation(args.location);
|
|
94
111
|
const name = args.name;
|
|
95
112
|
if (typeof name !== "string" || !name)
|
|
96
113
|
return "Error: name is required";
|
|
97
114
|
try {
|
|
98
|
-
const mm = mmFor(ctx, scope);
|
|
115
|
+
const mm = mmFor(ctx, scope, location);
|
|
99
116
|
const entries = mm.loadAll();
|
|
100
117
|
const entry = entries.find((e) => e.name === name || e.fileName === name);
|
|
101
118
|
if (!entry)
|
|
102
119
|
return `Error: no memory named "${name}" in scope "${scope}"`;
|
|
120
|
+
// Recall signal (用户拍板 C + 可见性): reading a memory bumps its usage so
|
|
121
|
+
// the recall-TTL sweep keeps frequently-read memories alive, and emits a
|
|
122
|
+
// stream event so the UI can show the user this memory was actually used.
|
|
123
|
+
// Best-effort — never let accounting failure break the read.
|
|
124
|
+
try {
|
|
125
|
+
mm.recordRecall(entry.name);
|
|
126
|
+
const cb = ctx?.streamCallback;
|
|
127
|
+
if (cb) {
|
|
128
|
+
// scope here is always "user"|"dream" (validated above); pending is
|
|
129
|
+
// never tool-readable, so the narrower event type is correct.
|
|
130
|
+
void cb({ type: "memory_recalled", name: entry.name, scope: scope, location });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// ignore — the read result below is what matters
|
|
135
|
+
}
|
|
103
136
|
return (`name: ${entry.name}\n` +
|
|
104
137
|
`description: ${entry.description}\n` +
|
|
105
138
|
`type: ${entry.type}\n` +
|
|
@@ -120,6 +153,8 @@ export const memorySaveToolDef = {
|
|
|
120
153
|
"feedback (how to approach work), " +
|
|
121
154
|
"project (non-obvious facts about ongoing work), " +
|
|
122
155
|
"reference (pointers to external resources). " +
|
|
156
|
+
"Pick `location`: global (a lesson/preference true in ANY project) vs project (this repo only). " +
|
|
157
|
+
"If a memory in the injected index is now stale or wrong, overwrite it (same name) or MemoryDelete it — keep the store correct rather than letting contradictions pile up. " +
|
|
123
158
|
"The `description` is a one-line summary shown in the index; the `content` is the full body.",
|
|
124
159
|
inputSchema: {
|
|
125
160
|
type: "object",
|
|
@@ -129,6 +164,7 @@ export const memorySaveToolDef = {
|
|
|
129
164
|
enum: ["user", "dream"],
|
|
130
165
|
description: "Which scope to save to",
|
|
131
166
|
},
|
|
167
|
+
location: LOCATION_SCHEMA,
|
|
132
168
|
name: {
|
|
133
169
|
type: "string",
|
|
134
170
|
description: "Short kebab-case identifier (also becomes the filename slug)",
|
|
@@ -169,14 +205,15 @@ export async function memorySaveTool(args, ctx) {
|
|
|
169
205
|
return `Error: type must be one of ${VALID_TYPES.join(", ")}`;
|
|
170
206
|
}
|
|
171
207
|
try {
|
|
172
|
-
const
|
|
208
|
+
const location = parseLocation(args.location);
|
|
209
|
+
const mm = mmFor(ctx, scope, location);
|
|
173
210
|
const fileName = mm.save({
|
|
174
211
|
name,
|
|
175
212
|
description,
|
|
176
213
|
type: type,
|
|
177
214
|
content,
|
|
178
215
|
});
|
|
179
|
-
return `Saved memory "${name}" → ${scope}/${fileName}`;
|
|
216
|
+
return `Saved memory "${name}" → ${location}/${scope}/${fileName}`;
|
|
180
217
|
}
|
|
181
218
|
catch (err) {
|
|
182
219
|
return `Error saving memory: ${err.message}`;
|
|
@@ -197,6 +234,7 @@ export const memoryDeleteToolDef = {
|
|
|
197
234
|
enum: ["user", "dream"],
|
|
198
235
|
description: "Which scope to delete from",
|
|
199
236
|
},
|
|
237
|
+
location: LOCATION_SCHEMA,
|
|
200
238
|
name: {
|
|
201
239
|
type: "string",
|
|
202
240
|
description: "The memory entry's name (from MemoryList output)",
|
|
@@ -214,7 +252,7 @@ export async function memoryDeleteTool(args, ctx) {
|
|
|
214
252
|
if (typeof name !== "string" || !name)
|
|
215
253
|
return "Error: name is required";
|
|
216
254
|
try {
|
|
217
|
-
const mm = mmFor(ctx, scope);
|
|
255
|
+
const mm = mmFor(ctx, scope, parseLocation(args.location));
|
|
218
256
|
const ok = mm.delete(name);
|
|
219
257
|
return ok
|
|
220
258
|
? `Deleted memory "${name}" from scope "${scope}" (moved to memory-trash/)`
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* NotebookEditTool — read and edit Jupyter notebook (.ipynb) cells.
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolDefinition } from "../../types.js";
|
|
5
|
+
import type { ToolContext } from "../context.js";
|
|
5
6
|
export declare const notebookEditToolDef: ToolDefinition;
|
|
6
|
-
export declare function notebookEditTool(args: Record<string, unknown
|
|
7
|
+
export declare function notebookEditTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
@@ -36,7 +36,7 @@ export const notebookEditToolDef = {
|
|
|
36
36
|
required: ["file_path", "action"],
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
|
-
export async function notebookEditTool(args) {
|
|
39
|
+
export async function notebookEditTool(args, ctx) {
|
|
40
40
|
const filePath = args.file_path;
|
|
41
41
|
const action = args.action;
|
|
42
42
|
if (!filePath)
|
|
@@ -27,7 +27,10 @@ export const powershellToolDef = {
|
|
|
27
27
|
const PS_MAX_BUFFER = 5 * 1024 * 1024;
|
|
28
28
|
export async function powershellTool(args, ctx) {
|
|
29
29
|
const command = args.command;
|
|
30
|
-
|
|
30
|
+
// `??` only catches null/undefined — a non-positive timeout (0/-5) would slip
|
|
31
|
+
// through to setTimeout (clamped to 0 → near-instant kill). Floor to default.
|
|
32
|
+
const rawTimeout = args.timeout;
|
|
33
|
+
const timeout = typeof rawTimeout === "number" && rawTimeout > 0 ? rawTimeout : 120_000;
|
|
31
34
|
if (!command.trim()) {
|
|
32
35
|
return "Error: command is required.";
|
|
33
36
|
}
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Built-in Read file tool.
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolDefinition } from "../../types.js";
|
|
5
|
+
import type { ToolContext } from "../context.js";
|
|
5
6
|
export declare const readToolDef: ToolDefinition;
|
|
6
|
-
export declare function readTool(args: Record<string, unknown
|
|
7
|
+
export declare function readTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { readFile, stat } from "node:fs/promises";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { fileCache } from "./file-cache.js";
|
|
7
|
+
import { toLf } from "./eol.js";
|
|
7
8
|
export const readToolDef = {
|
|
8
9
|
name: "Read",
|
|
9
10
|
description: "Read a file from the local filesystem. Returns the file content with line numbers. " +
|
|
@@ -26,7 +27,7 @@ export const readToolDef = {
|
|
|
26
27
|
},
|
|
27
28
|
};
|
|
28
29
|
const MAX_CONTENT_CHARS = 200_000;
|
|
29
|
-
export async function readTool(args) {
|
|
30
|
+
export async function readTool(args, ctx) {
|
|
30
31
|
const filePath = args.file_path;
|
|
31
32
|
if (!filePath)
|
|
32
33
|
return "Error: file_path is required";
|
|
@@ -46,10 +47,17 @@ export async function readTool(args) {
|
|
|
46
47
|
content = await readFile(filePath, "utf-8");
|
|
47
48
|
fileCache.set(filePath, content, fileInfo.mtimeMs);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
// Split on LF after normalizing CRLF → LF so a Windows (CRLF) file doesn't
|
|
51
|
+
// render a trailing ^M on every line. Display-only; the file isn't written.
|
|
52
|
+
const lines = toLf(content).split("\n");
|
|
50
53
|
const totalLines = lines.length;
|
|
51
54
|
const offset = Math.max(1, args.offset || 1);
|
|
52
|
-
|
|
55
|
+
// A non-positive limit (a misbehaving caller passing 0 / -5 / NaN) falls back
|
|
56
|
+
// to the default page size — NOT through to `lines.slice(start, start+limit)`
|
|
57
|
+
// with a NEGATIVE end, which JS reads as "all but the last N" and would
|
|
58
|
+
// silently return the wrong window. `|| 2000` only caught 0/NaN, not negatives.
|
|
59
|
+
const rawLimit = args.limit;
|
|
60
|
+
const limit = typeof rawLimit === "number" && rawLimit > 0 ? rawLimit : 2000;
|
|
53
61
|
const end = Math.min(totalLines, offset - 1 + limit);
|
|
54
62
|
const selected = lines.slice(offset - 1, end);
|
|
55
63
|
let numbered = selected.map((line, i) => `${offset + i}\t${line}`).join("\n");
|
|
@@ -34,7 +34,10 @@ const REPL_MAX_BUFFER = 1024 * 1024;
|
|
|
34
34
|
export async function replTool(args, ctx) {
|
|
35
35
|
const language = args.language;
|
|
36
36
|
const code = args.code;
|
|
37
|
-
|
|
37
|
+
// `??` only catches null/undefined — a non-positive timeout (0/-5) would slip
|
|
38
|
+
// through to setTimeout (clamped to 0 → near-instant kill). Floor to default.
|
|
39
|
+
const rawTimeout = args.timeout;
|
|
40
|
+
const timeout = typeof rawTimeout === "number" && rawTimeout > 0 ? rawTimeout : 30_000;
|
|
38
41
|
// A4: child process runs in the Engine's cwd, not the host process cwd.
|
|
39
42
|
const cwd = ctx?.cwd ?? process.cwd();
|
|
40
43
|
if (!code.trim()) {
|
|
@@ -42,6 +42,14 @@ export async function skillTool(args, ctx) {
|
|
|
42
42
|
// ordering is observable but not load-bearing.
|
|
43
43
|
const disabledSkills = ctx?.disabledSkills;
|
|
44
44
|
const disabledPlugins = ctx?.disabledPlugins;
|
|
45
|
+
const skillAllowlist = ctx?.skillAllowlist;
|
|
46
|
+
// Sub-agent skill isolation: when this agent has an allowlist, a skill
|
|
47
|
+
// outside it must be refused — even invoking it by exact name. The scan
|
|
48
|
+
// below also drops it, but an explicit message beats a misleading "not
|
|
49
|
+
// found" for a skill that exists in the project but isn't this agent's.
|
|
50
|
+
if (skillAllowlist !== undefined && !skillAllowlist.includes(skillName)) {
|
|
51
|
+
return `Skill "${skillName}" is not available to this sub-agent. This agent's role restricts it to: ${skillAllowlist.length > 0 ? skillAllowlist.join(", ") : "(no skills)"}.`;
|
|
52
|
+
}
|
|
45
53
|
if (disabledSkills && disabledSkills.includes(skillName)) {
|
|
46
54
|
return `Skill "${skillName}" is disabled. Enable it in Customize or remove it from settings.disabledSkills.`;
|
|
47
55
|
}
|
|
@@ -58,6 +66,7 @@ export async function skillTool(args, ctx) {
|
|
|
58
66
|
const skills = scanSkills(ctx?.cwd ?? process.cwd(), {
|
|
59
67
|
disabledSkills,
|
|
60
68
|
disabledPlugins,
|
|
69
|
+
skillAllowlist,
|
|
61
70
|
});
|
|
62
71
|
const found = skills.find((s) => s.name === skillName);
|
|
63
72
|
if (!found) {
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const sleepToolDef = {
|
|
5
5
|
name: "Sleep",
|
|
6
|
-
description: "Pause execution for a
|
|
7
|
-
"
|
|
6
|
+
description: "Pause execution for a brief, deterministic wait (e.g. letting a just-started service settle for a few seconds). " +
|
|
7
|
+
"Do NOT use Sleep to poll for or wait on background work (background shells, async sub-agents, video generation): " +
|
|
8
|
+
"the system wakes you automatically when that work completes — just end your turn instead of looping Sleep. " +
|
|
8
9
|
"Maximum duration is 300 seconds (5 minutes).",
|
|
9
10
|
inputSchema: {
|
|
10
11
|
type: "object",
|
|
@@ -23,11 +24,17 @@ export async function sleepTool(args) {
|
|
|
23
24
|
if (signal?.aborted)
|
|
24
25
|
return "Sleep aborted.";
|
|
25
26
|
await new Promise((resolve, reject) => {
|
|
26
|
-
const
|
|
27
|
-
signal?.addEventListener("abort", () => {
|
|
27
|
+
const onAbort = () => {
|
|
28
28
|
clearTimeout(timer);
|
|
29
29
|
reject(new Error("Sleep aborted"));
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
// Remove the abort listener on normal completion — otherwise every Sleep
|
|
33
|
+
// call leaks a listener on the (shared, per-turn) signal.
|
|
34
|
+
signal?.removeEventListener("abort", onAbort);
|
|
35
|
+
resolve();
|
|
36
|
+
}, seconds * 1000);
|
|
37
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
31
38
|
}).catch(() => { });
|
|
32
39
|
return `Slept for ${seconds} seconds.`;
|
|
33
40
|
}
|
|
@@ -30,7 +30,10 @@ export const todoWriteToolDef = {
|
|
|
30
30
|
name: "TodoWrite",
|
|
31
31
|
description: "Manage the session todo list. Pass the COMPLETE list each call — there's no per-item update API, you rewrite the entire snapshot. " +
|
|
32
32
|
"Use proactively for tasks with 3+ steps. Exactly one item should be in_progress at a time. " +
|
|
33
|
-
"Always provide both `content` (imperative) and `activeForm` (present continuous) so the UI can show what's happening right now."
|
|
33
|
+
"Always provide both `content` (imperative) and `activeForm` (present continuous) so the UI can show what's happening right now. " +
|
|
34
|
+
"Skip the todo list for straightforward tasks (roughly the easiest 25%) and don't make single-step lists. " +
|
|
35
|
+
"Update the list immediately after finishing a sub-task — mark it completed in the same turn you completed it, don't batch updates across turns. " +
|
|
36
|
+
"If you change direction and a planned item will no longer be done, rewrite the list with that item dropped rather than leaving it pending; the list must reflect what you're actually going to do next.",
|
|
34
37
|
inputSchema: {
|
|
35
38
|
type: "object",
|
|
36
39
|
properties: {
|
|
@@ -31,20 +31,38 @@ export async function toolSearchTool(args, ctx) {
|
|
|
31
31
|
return "Error: query is required";
|
|
32
32
|
if (!ctx?.toolRegistry)
|
|
33
33
|
return "Error: ToolSearch is not configured (no registry in ctx)";
|
|
34
|
-
|
|
34
|
+
// Floor to default on non-positive: a negative max_results would reach
|
|
35
|
+
// `.slice(0, maxResults)` with a negative end (= all but the last N), silently
|
|
36
|
+
// returning the wrong tool set. `|| 5` only caught 0/NaN, not negatives.
|
|
37
|
+
const rawMax = args.max_results;
|
|
38
|
+
const maxResults = Math.min(typeof rawMax === "number" && rawMax > 0 ? rawMax : 5, 20);
|
|
39
|
+
// The tool registry is worker-SHARED (B1): it holds MCP tools registered by
|
|
40
|
+
// every session, including servers another project enabled. ToolSearch is a
|
|
41
|
+
// side door around the per-turn toolDefs filter — without this gate it would
|
|
42
|
+
// surface (and let the model `select:` into) MCP tools from a server THIS
|
|
43
|
+
// session never enabled, which is exactly the chrome-devtools-in-writeflow
|
|
44
|
+
// leak. Mirror the engine's toolDefs visibility: keep an MCP tool only when
|
|
45
|
+
// its server is in this session's allowedMcpServers. Undefined set = no
|
|
46
|
+
// gating (sub-agents / hosts that don't populate it).
|
|
47
|
+
const visible = (tool) => {
|
|
48
|
+
if (tool.source !== "mcp")
|
|
49
|
+
return true;
|
|
50
|
+
const allowed = ctx.allowedMcpServers;
|
|
51
|
+
return !allowed || allowed.has(tool.serverName ?? "");
|
|
52
|
+
};
|
|
35
53
|
// "select:Name1,Name2" → exact match
|
|
36
54
|
if (query.startsWith("select:")) {
|
|
37
55
|
const names = query.slice(7).split(",").map((n) => n.trim());
|
|
38
|
-
return matchExact(ctx.toolRegistry, names);
|
|
56
|
+
return matchExact(ctx.toolRegistry, names, visible);
|
|
39
57
|
}
|
|
40
58
|
// Keyword search
|
|
41
|
-
return searchByKeyword(ctx.toolRegistry, query, maxResults);
|
|
59
|
+
return searchByKeyword(ctx.toolRegistry, query, maxResults, visible);
|
|
42
60
|
}
|
|
43
|
-
function matchExact(registry, names) {
|
|
61
|
+
function matchExact(registry, names, visible) {
|
|
44
62
|
const results = [];
|
|
45
63
|
for (const name of names) {
|
|
46
64
|
const tool = registry.getTool(name);
|
|
47
|
-
if (tool) {
|
|
65
|
+
if (tool && visible(tool)) {
|
|
48
66
|
results.push(formatTool(tool));
|
|
49
67
|
}
|
|
50
68
|
else {
|
|
@@ -53,8 +71,8 @@ function matchExact(registry, names) {
|
|
|
53
71
|
}
|
|
54
72
|
return results.join("\n\n---\n\n");
|
|
55
73
|
}
|
|
56
|
-
function searchByKeyword(registry, query, maxResults) {
|
|
57
|
-
const allTools = registry.listToolsDetailed();
|
|
74
|
+
function searchByKeyword(registry, query, maxResults, visible) {
|
|
75
|
+
const allTools = registry.listToolsDetailed().filter(visible);
|
|
58
76
|
const queryLower = query.toLowerCase();
|
|
59
77
|
const keywords = queryLower.split(/\s+/);
|
|
60
78
|
// Score each tool
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UpdateAutomationMemory — lets an automation (cron/scheduled) run persist a
|
|
3
|
+
* one-paragraph summary of what it did, so the NEXT run starts with context.
|
|
4
|
+
*
|
|
5
|
+
* This is a FACTORY: core must not depend on desktop's filesystem layer, so the
|
|
6
|
+
* actual persistence is supplied by an injected `sink` callback. A later task
|
|
7
|
+
* (the desktop automation runner) injects a sink that appends to the task's
|
|
8
|
+
* memory.md; this module only builds the tool + validates input.
|
|
9
|
+
*/
|
|
10
|
+
import type { BuiltinTool } from "./index.js";
|
|
11
|
+
import type { ToolDefinition } from "../../types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Bare tool definition (name/description/inputSchema) — mirrors the export
|
|
14
|
+
* style of the other builtin tool defs (e.g. cron.ts). The factory below wraps
|
|
15
|
+
* this into a registry-ready RegisteredTool.
|
|
16
|
+
*/
|
|
17
|
+
export declare const updateAutomationMemoryToolDef: ToolDefinition;
|
|
18
|
+
/**
|
|
19
|
+
* Build an UpdateAutomationMemory tool bound to a persistence `sink`.
|
|
20
|
+
*
|
|
21
|
+
* @param sink Called with the trimmed summary when a non-empty summary is given.
|
|
22
|
+
* The caller decides where/how to persist it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function makeUpdateAutomationMemoryTool(sink: (summary: string) => void): BuiltinTool;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UpdateAutomationMemory — lets an automation (cron/scheduled) run persist a
|
|
3
|
+
* one-paragraph summary of what it did, so the NEXT run starts with context.
|
|
4
|
+
*
|
|
5
|
+
* This is a FACTORY: core must not depend on desktop's filesystem layer, so the
|
|
6
|
+
* actual persistence is supplied by an injected `sink` callback. A later task
|
|
7
|
+
* (the desktop automation runner) injects a sink that appends to the task's
|
|
8
|
+
* memory.md; this module only builds the tool + validates input.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Bare tool definition (name/description/inputSchema) — mirrors the export
|
|
12
|
+
* style of the other builtin tool defs (e.g. cron.ts). The factory below wraps
|
|
13
|
+
* this into a registry-ready RegisteredTool.
|
|
14
|
+
*/
|
|
15
|
+
export const updateAutomationMemoryToolDef = {
|
|
16
|
+
name: "UpdateAutomationMemory",
|
|
17
|
+
description: "Persist a short memory note for this automation task so your NEXT scheduled run " +
|
|
18
|
+
"starts with context. Call this EXACTLY ONCE, at the very end of the run, with a " +
|
|
19
|
+
"concise one-paragraph summary of what you did, what you found, and anything the " +
|
|
20
|
+
"next run should know or continue (e.g. items processed, last cursor/timestamp, " +
|
|
21
|
+
"open issues). Keep it to a few sentences — it is prepended to your future prompts.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
summary: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "A concise one-paragraph summary of this run for the next run to build on.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ["summary"],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Build an UpdateAutomationMemory tool bound to a persistence `sink`.
|
|
35
|
+
*
|
|
36
|
+
* @param sink Called with the trimmed summary when a non-empty summary is given.
|
|
37
|
+
* The caller decides where/how to persist it.
|
|
38
|
+
*/
|
|
39
|
+
export function makeUpdateAutomationMemoryTool(sink) {
|
|
40
|
+
return {
|
|
41
|
+
definition: {
|
|
42
|
+
...updateAutomationMemoryToolDef,
|
|
43
|
+
source: "builtin",
|
|
44
|
+
// The summary is automation-internal bookkeeping (not user code); no prompt.
|
|
45
|
+
permissionDefault: "allow",
|
|
46
|
+
// Writes (via the injected sink), so not read-only / not concurrency-safe.
|
|
47
|
+
isReadOnly: false,
|
|
48
|
+
isConcurrencySafe: false,
|
|
49
|
+
},
|
|
50
|
+
execute: async (args) => {
|
|
51
|
+
const raw = typeof args.summary === "string" ? args.summary : "";
|
|
52
|
+
const summary = raw.trim();
|
|
53
|
+
if (!summary) {
|
|
54
|
+
return "Error: summary is required and must not be empty";
|
|
55
|
+
}
|
|
56
|
+
sink(summary);
|
|
57
|
+
return "Automation memory saved for the next run.";
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VideoProvider — adapter interface for text-to-video generation (TODO 7.1).
|
|
3
|
+
*
|
|
4
|
+
* Unlike images (one request → bytes), video generation is asynchronous and
|
|
5
|
+
* long: SUBMIT a job → POLL its status until it finishes → DOWNLOAD the bytes.
|
|
6
|
+
* The interface captures exactly those three steps so the GenerateVideo tool's
|
|
7
|
+
* background polling loop is provider-agnostic, and concrete adapters
|
|
8
|
+
* (Seedance/Kling — filled in once their private API docs are available) only
|
|
9
|
+
* implement submit/poll/download.
|
|
10
|
+
*
|
|
11
|
+
* Credentials are resolved by the tool layer from settings; adapters are pure
|
|
12
|
+
* "creds + request → job lifecycle". `fetch` is injected for testability.
|
|
13
|
+
*/
|
|
14
|
+
export interface VideoProviderCreds {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VideoSubmitRequest {
|
|
19
|
+
prompt: string;
|
|
20
|
+
model: string;
|
|
21
|
+
creds: VideoProviderCreds;
|
|
22
|
+
/** Single image URL (http/https) — image-to-video. Back-compat. */
|
|
23
|
+
image?: string;
|
|
24
|
+
/** Multiple image URLs — ≥2 triggers reference-to-video. Takes precedence over `image`. */
|
|
25
|
+
images?: string[];
|
|
26
|
+
/** Reference/continuation video URLs (http/https) — passed through to fal's `video_urls`. Reference them in the prompt as @Video1/@Video2. Forces reference-to-video. */
|
|
27
|
+
videos?: string[];
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
export type VideoSubmitResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
jobId: string;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
error: string;
|
|
36
|
+
};
|
|
37
|
+
export type VideoPollResult = {
|
|
38
|
+
ok: true;
|
|
39
|
+
status: "running";
|
|
40
|
+
} | {
|
|
41
|
+
ok: true;
|
|
42
|
+
status: "succeeded";
|
|
43
|
+
} | {
|
|
44
|
+
ok: true;
|
|
45
|
+
status: "failed";
|
|
46
|
+
error: string;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
error: string;
|
|
50
|
+
};
|
|
51
|
+
export type VideoDownloadResult = {
|
|
52
|
+
ok: true;
|
|
53
|
+
bytes: Uint8Array;
|
|
54
|
+
ext: string;
|
|
55
|
+
url?: string;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
error: string;
|
|
59
|
+
};
|
|
60
|
+
export interface VideoProvider {
|
|
61
|
+
readonly kind: string;
|
|
62
|
+
submit(req: VideoSubmitRequest): Promise<VideoSubmitResult>;
|
|
63
|
+
poll(req: {
|
|
64
|
+
jobId: string;
|
|
65
|
+
creds: VideoProviderCreds;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}): Promise<VideoPollResult>;
|
|
68
|
+
download(req: {
|
|
69
|
+
jobId: string;
|
|
70
|
+
creds: VideoProviderCreds;
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
}): Promise<VideoDownloadResult>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Deterministic in-memory adapter for tests and local dev — no network. Models
|
|
76
|
+
* the three-step lifecycle: submit mints a job; poll returns `running` for the
|
|
77
|
+
* first N calls then `succeeded` (or `failed` after M); download returns the
|
|
78
|
+
* configured bytes. Lets the GenerateVideo background loop be tested end-to-end
|
|
79
|
+
* before any real (Seedance/Kling) adapter exists.
|
|
80
|
+
*/
|
|
81
|
+
export declare class FakeVideoProvider implements VideoProvider {
|
|
82
|
+
private readonly opts;
|
|
83
|
+
readonly kind = "fake";
|
|
84
|
+
private polls;
|
|
85
|
+
private counter;
|
|
86
|
+
constructor(opts?: {
|
|
87
|
+
succeedAfterPolls?: number;
|
|
88
|
+
failAfterPolls?: number;
|
|
89
|
+
failMessage?: string;
|
|
90
|
+
bytes?: string;
|
|
91
|
+
});
|
|
92
|
+
submit(_req: VideoSubmitRequest): Promise<VideoSubmitResult>;
|
|
93
|
+
poll(req: {
|
|
94
|
+
jobId: string;
|
|
95
|
+
creds?: VideoProviderCreds;
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}): Promise<VideoPollResult>;
|
|
98
|
+
download(_req: {
|
|
99
|
+
jobId: string;
|
|
100
|
+
creds?: VideoProviderCreds;
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}): Promise<VideoDownloadResult>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* fal.ai video adapter — submit/poll/download against the fal queue API
|
|
106
|
+
* (https://queue.fal.run). model id selects the underlying model
|
|
107
|
+
* (e.g. fal-ai/kling-video/v3/pro/text-to-video). When `image` is present we
|
|
108
|
+
* switch a `...text-to-video` model to `...image-to-video` and send image_url,
|
|
109
|
+
* so callers only need to pass an image to get i2v.
|
|
110
|
+
*
|
|
111
|
+
* IMPORTANT: fal's status/result URLs use a model-FAMILY prefix
|
|
112
|
+
* (`fal-ai/kling-video/requests/<id>`), NOT the full submit path
|
|
113
|
+
* (`.../v3/pro/text-to-video/requests/<id>` → HTTP 405). So we never
|
|
114
|
+
* reconstruct those URLs; we encode the `status_url` + `response_url` that
|
|
115
|
+
* submit returns into the jobId (`<status_url>|<response_url>`) and use them
|
|
116
|
+
* verbatim in poll/download. Verified against the live API 2026-06-10.
|
|
117
|
+
*/
|
|
118
|
+
export declare class FalVideoProvider implements VideoProvider {
|
|
119
|
+
private readonly fetchImpl;
|
|
120
|
+
readonly kind = "fal";
|
|
121
|
+
constructor(fetchImpl?: typeof fetch);
|
|
122
|
+
/** Effective image list: images[] wins; else single image; else []. */
|
|
123
|
+
private imageList;
|
|
124
|
+
/**
|
|
125
|
+
* Does this model family support reference-to-video (multi-image)? Verified
|
|
126
|
+
* 2026-06-10 against the live API: Seedance has it; Kling does NOT (routing a
|
|
127
|
+
* Kling model to `.../reference-to-video` 404s at result fetch). Keep this a
|
|
128
|
+
* conservative allowlist — only families confirmed to expose the endpoint.
|
|
129
|
+
*/
|
|
130
|
+
private supportsReference;
|
|
131
|
+
/** Route model suffix by image count: 0→text, 1→image, ≥2→reference. */
|
|
132
|
+
private resolveModel;
|
|
133
|
+
/** jobId = `${statusUrl}|${responseUrl}` (fal returns both from submit). */
|
|
134
|
+
private split;
|
|
135
|
+
submit(req: VideoSubmitRequest): Promise<VideoSubmitResult>;
|
|
136
|
+
poll(req: {
|
|
137
|
+
jobId: string;
|
|
138
|
+
creds: VideoProviderCreds;
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}): Promise<VideoPollResult>;
|
|
141
|
+
download(req: {
|
|
142
|
+
jobId: string;
|
|
143
|
+
creds: VideoProviderCreds;
|
|
144
|
+
signal?: AbortSignal;
|
|
145
|
+
}): Promise<VideoDownloadResult>;
|
|
146
|
+
}
|
|
147
|
+
/** Default model per video provider kind (filled in with real adapters). */
|
|
148
|
+
export declare const DEFAULT_VIDEO_MODEL: Record<string, string>;
|
|
149
|
+
/**
|
|
150
|
+
* Registry of video-provider adapters, keyed by `kind`. Only `fake` exists
|
|
151
|
+
* today (test/dev). Real adapters (seedance, kling) are intentionally absent
|
|
152
|
+
* until their private API contracts are confirmed — see TODO 7.1 块3.
|
|
153
|
+
*/
|
|
154
|
+
export declare function getVideoProvider(kind: string, fetchImpl?: typeof fetch): VideoProvider | null;
|