@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface UploaderCreds {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
export type UploadResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
url: string;
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
export interface ImageUploader {
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
/** http/https → unchanged; local path → upload, return public URL. */
|
|
15
|
+
toUrl(pathOrUrl: string, creds: UploaderCreds, signal?: AbortSignal): Promise<UploadResult>;
|
|
16
|
+
}
|
|
17
|
+
export declare function isHttpUrl(s: string): boolean;
|
|
18
|
+
export declare class FalStorageUploader implements ImageUploader {
|
|
19
|
+
private readonly fetchImpl;
|
|
20
|
+
readonly kind = "fal";
|
|
21
|
+
private static readonly UPLOAD_BASE;
|
|
22
|
+
constructor(fetchImpl?: typeof fetch);
|
|
23
|
+
toUrl(pathOrUrl: string, creds: UploaderCreds, signal?: AbortSignal): Promise<UploadResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Upload raw bytes to fal storage, return the public URL. Two-step flow
|
|
26
|
+
* (verified against live API 2026-06-10):
|
|
27
|
+
* 1. POST {UPLOAD_BASE}/storage/upload/initiate → { file_url, upload_url }
|
|
28
|
+
* 2. PUT <upload_url> with the bytes (signed URL, no Authorization)
|
|
29
|
+
* 3. file_url is the final public URL.
|
|
30
|
+
*/
|
|
31
|
+
private uploadBytes;
|
|
32
|
+
}
|
|
33
|
+
export declare function getImageUploader(kind: string, fetchImpl?: typeof fetch): ImageUploader | null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageUploader — pluggable "local path → public URL" so image-to-video /
|
|
3
|
+
* reference-to-video can accept local files, not just URLs. fal storage is the
|
|
4
|
+
* first impl; swapping in another image host = another impl, no provider change.
|
|
5
|
+
*/
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { basename } from "node:path";
|
|
8
|
+
export function isHttpUrl(s) {
|
|
9
|
+
return /^https?:\/\//i.test(s);
|
|
10
|
+
}
|
|
11
|
+
function mimeFromName(name) {
|
|
12
|
+
const ext = name.toLowerCase().split(".").pop() ?? "";
|
|
13
|
+
const map = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", webp: "image/webp", gif: "image/gif" };
|
|
14
|
+
return map[ext] ?? "application/octet-stream";
|
|
15
|
+
}
|
|
16
|
+
export class FalStorageUploader {
|
|
17
|
+
fetchImpl;
|
|
18
|
+
kind = "fal";
|
|
19
|
+
// fal upload lives on a different host than queue.fal.run.
|
|
20
|
+
static UPLOAD_BASE = "https://rest.alpha.fal.ai";
|
|
21
|
+
constructor(fetchImpl = fetch) {
|
|
22
|
+
this.fetchImpl = fetchImpl;
|
|
23
|
+
}
|
|
24
|
+
async toUrl(pathOrUrl, creds, signal) {
|
|
25
|
+
if (isHttpUrl(pathOrUrl))
|
|
26
|
+
return { ok: true, url: pathOrUrl };
|
|
27
|
+
try {
|
|
28
|
+
const bytes = await readFile(pathOrUrl);
|
|
29
|
+
const url = await this.uploadBytes(bytes, basename(pathOrUrl), creds, signal);
|
|
30
|
+
return { ok: true, url };
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
return { ok: false, error: `fal upload error for ${pathOrUrl}: ${err.message}` };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Upload raw bytes to fal storage, return the public URL. Two-step flow
|
|
38
|
+
* (verified against live API 2026-06-10):
|
|
39
|
+
* 1. POST {UPLOAD_BASE}/storage/upload/initiate → { file_url, upload_url }
|
|
40
|
+
* 2. PUT <upload_url> with the bytes (signed URL, no Authorization)
|
|
41
|
+
* 3. file_url is the final public URL.
|
|
42
|
+
*/
|
|
43
|
+
async uploadBytes(bytes, name, creds, signal) {
|
|
44
|
+
const mime = mimeFromName(name);
|
|
45
|
+
const ini = await this.fetchImpl(`${FalStorageUploader.UPLOAD_BASE}/storage/upload/initiate`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { Authorization: `Key ${creds.apiKey}`, "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify({ content_type: mime, file_name: name }),
|
|
49
|
+
signal,
|
|
50
|
+
});
|
|
51
|
+
if (!ini.ok)
|
|
52
|
+
throw new Error(`initiate failed: HTTP ${ini.status}`);
|
|
53
|
+
const { file_url, upload_url } = (await ini.json());
|
|
54
|
+
if (!file_url || !upload_url)
|
|
55
|
+
throw new Error("initiate: missing file_url/upload_url");
|
|
56
|
+
const put = await this.fetchImpl(upload_url, {
|
|
57
|
+
method: "PUT",
|
|
58
|
+
headers: { "Content-Type": mime },
|
|
59
|
+
body: bytes,
|
|
60
|
+
signal,
|
|
61
|
+
});
|
|
62
|
+
if (!put.ok)
|
|
63
|
+
throw new Error(`upload PUT failed: HTTP ${put.status}`);
|
|
64
|
+
return file_url;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function getImageUploader(kind, fetchImpl = fetch) {
|
|
68
|
+
switch (kind) {
|
|
69
|
+
case "fal":
|
|
70
|
+
return new FalStorageUploader(fetchImpl);
|
|
71
|
+
default:
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -12,9 +12,32 @@ import type { RegisteredTool } from "../../types.js";
|
|
|
12
12
|
* ctx is optional in the signature so legacy call sites (and tests) that
|
|
13
13
|
* pass only args still type-check; ToolRegistry always passes ctx at runtime.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 内置工具返回值:大多数返回纯文本字符串。需要回传图片(或其它结构化
|
|
17
|
+
* 内容块)的工具(view_image)可改为返回 `{ contentBlocks }`;此时
|
|
18
|
+
* registry 会把它放进 ToolResult.contentBlocks。可选的 `result` 字段是给
|
|
19
|
+
* transcript / 摘要用的纯文本镜像。沙箱执行类工具(Bash 等)可返回
|
|
20
|
+
* `{ result, sandbox }`,registry 把 sandbox 透传到 ToolResult.sandbox 供 UI 显示。
|
|
21
|
+
*/
|
|
22
|
+
export type BuiltinToolResult = string | {
|
|
23
|
+
contentBlocks: import("../../types.js").ContentBlock[];
|
|
24
|
+
result?: string;
|
|
25
|
+
} | {
|
|
26
|
+
result: string;
|
|
27
|
+
sandbox: import("../../types.js").ToolResult["sandbox"];
|
|
28
|
+
};
|
|
29
|
+
export type BuiltinToolFn = (args: Record<string, unknown>, ctx?: import("../context.js").ToolContext) => Promise<BuiltinToolResult>;
|
|
16
30
|
export interface BuiltinTool {
|
|
17
31
|
definition: RegisteredTool;
|
|
18
32
|
execute: BuiltinToolFn;
|
|
19
33
|
}
|
|
20
34
|
export declare const BUILTIN_TOOLS: BuiltinTool[];
|
|
35
|
+
/**
|
|
36
|
+
* Per-tool availability predicates. A tool listed here is filtered OUT of the
|
|
37
|
+
* exposed toolDefs when its predicate returns false for the active cwd (see
|
|
38
|
+
* engine.ts toolDefs assembly). Tools NOT listed here are always visible.
|
|
39
|
+
* Keyed by the tool's `name` (must match the toolDef name).
|
|
40
|
+
*/
|
|
41
|
+
export declare const BUILTIN_TOOL_GUARDS: Map<string, (cwd: string) => boolean>;
|
|
42
|
+
/** UseCredential is available when the cwd's CredentialStore has ≥1 credential. */
|
|
43
|
+
export declare function isUseCredentialAvailable(cwd: string): boolean;
|
|
@@ -3,33 +3,45 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { readToolDef, readTool } from "./read.js";
|
|
5
5
|
import { writeToolDef, writeTool } from "./write.js";
|
|
6
|
+
import { generateImageToolDef, generateImageTool, isGenerateImageAvailable } from "./generate-image.js";
|
|
7
|
+
import { editModelCatalogToolDef, editModelCatalogTool } from "./edit-model-catalog.js";
|
|
8
|
+
import { generateVideoToolDef, generateVideoTool, isGenerateVideoAvailable } from "./generate-video.js";
|
|
9
|
+
import { viewImageToolDef, viewImageTool } from "./view-image.js";
|
|
6
10
|
import { editToolDef, editTool } from "./edit.js";
|
|
7
11
|
import { applyPatchToolDef, applyPatchTool } from "./apply-patch/index.js";
|
|
8
12
|
import { globToolDef, globTool } from "./glob.js";
|
|
9
13
|
import { grepToolDef, grepTool } from "./grep.js";
|
|
10
14
|
import { bashToolDef, bashTool } from "./bash.js";
|
|
11
|
-
import { webSearchToolDef, webSearchTool } from "./web-search.js";
|
|
15
|
+
import { webSearchToolDef, webSearchTool, isWebSearchAvailable } from "./web-search.js";
|
|
12
16
|
import { webFetchToolDef, webFetchTool } from "./web-fetch.js";
|
|
13
17
|
import { askUserToolDef, askUserTool } from "./ask-user.js";
|
|
14
|
-
import { agentToolDef, agentTool, agentStatusToolDef, agentStatusTool, agentCancelToolDef, agentCancelTool, } from "./agent.js";
|
|
18
|
+
import { agentToolDef, agentTool, agentStatusToolDef, agentStatusTool, agentCancelToolDef, agentCancelTool, agentSendInputToolDef, agentSendInputTool, } from "./agent.js";
|
|
15
19
|
import { enterPlanModeToolDef, enterPlanModeTool, exitPlanModeToolDef, exitPlanModeTool } from "./plan.js";
|
|
16
20
|
import { toolSearchToolDef, toolSearchTool } from "./tool-search.js";
|
|
17
21
|
import { todoWriteToolDef, todoWriteTool } from "./task.js";
|
|
18
22
|
import { enterWorktreeToolDef, enterWorktreeTool, exitWorktreeToolDef, exitWorktreeTool } from "./worktree.js";
|
|
19
|
-
import { sendMessageToolDef, sendMessageTool } from "./send-message.js";
|
|
20
23
|
import { sleepToolDef, sleepTool } from "./sleep.js";
|
|
21
24
|
import { configToolDef, configTool } from "./config.js";
|
|
22
25
|
import { notebookEditToolDef, notebookEditTool } from "./notebook-edit.js";
|
|
23
26
|
import { lspToolDef, lspTool } from "./lsp.js";
|
|
24
27
|
import { cronCreateToolDef, cronCreateTool, cronDeleteToolDef, cronDeleteTool, cronListToolDef, cronListTool } from "./cron.js";
|
|
28
|
+
import { driveClaudeCodeToolDef, driveClaudeCodeTool, driveAgentToolDef, driveAgentTool } from "./drive-claude-code.js";
|
|
29
|
+
import { checkQuotaToolDef, checkQuotaTool } from "./check-quota.js";
|
|
25
30
|
import { skillToolDef, skillTool } from "./skill.js";
|
|
26
31
|
import { mcpToolDef, mcpToolExecute, listMcpResourcesToolDef, listMcpResourcesTool, readMcpResourceToolDef, readMcpResourceTool } from "./mcp-tools.js";
|
|
27
|
-
import { remoteTriggerToolDef, remoteTriggerTool } from "./remote-trigger.js";
|
|
28
32
|
import { replToolDef, replTool } from "./repl.js";
|
|
29
33
|
import { briefToolDef, briefTool } from "./brief.js";
|
|
30
34
|
import { powershellToolDef, powershellTool } from "./powershell.js";
|
|
31
35
|
import { arenaToolDef, arenaTool } from "./arena.js";
|
|
32
36
|
import { memoryListToolDef, memoryListTool, memoryReadToolDef, memoryReadTool, memorySaveToolDef, memorySaveTool, memoryDeleteToolDef, memoryDeleteTool, } from "./memory.js";
|
|
37
|
+
import { completeGoalToolDef, completeGoalTool } from "./complete-goal.js";
|
|
38
|
+
import { cancelGoalToolDef, cancelGoalTool } from "./cancel-goal.js";
|
|
39
|
+
import { addMarketplaceToolDef, addMarketplaceTool } from "./add-marketplace.js";
|
|
40
|
+
import { bashOutputToolDef, bashOutputTool, killShellToolDef, killShellTool, listShellsToolDef, listShellsTool, } from "./background-shell-tools.js";
|
|
41
|
+
import { browserObserveToolDef, browserObserveTool, browserActToolDef, browserActTool, browserNavigateToolDef, browserNavigateTool, } from "./browser-tools.js";
|
|
42
|
+
import { useCredentialToolDef, useCredentialTool } from "../../credentials/use-credential-tool.js";
|
|
43
|
+
import { injectCredentialToolDef, injectCredentialTool, isInjectCredentialAvailable, } from "../../credentials/inject-credential-tool.js";
|
|
44
|
+
import { CredentialStore } from "../../credentials/store.js";
|
|
33
45
|
export const BUILTIN_TOOLS = [
|
|
34
46
|
{
|
|
35
47
|
definition: {
|
|
@@ -38,6 +50,7 @@ export const BUILTIN_TOOLS = [
|
|
|
38
50
|
permissionDefault: "allow",
|
|
39
51
|
isReadOnly: true,
|
|
40
52
|
isConcurrencySafe: true,
|
|
53
|
+
pathPolicy: [{ kind: "arg", arg: "file_path", operation: "read" }],
|
|
41
54
|
},
|
|
42
55
|
execute: readTool,
|
|
43
56
|
},
|
|
@@ -48,9 +61,69 @@ export const BUILTIN_TOOLS = [
|
|
|
48
61
|
permissionDefault: "ask",
|
|
49
62
|
isReadOnly: false,
|
|
50
63
|
isConcurrencySafe: false,
|
|
64
|
+
pathPolicy: [{ kind: "arg", arg: "file_path", operation: "write" }],
|
|
51
65
|
},
|
|
52
66
|
execute: writeTool,
|
|
53
67
|
},
|
|
68
|
+
{
|
|
69
|
+
definition: {
|
|
70
|
+
...editModelCatalogToolDef,
|
|
71
|
+
source: "builtin",
|
|
72
|
+
permissionDefault: "ask", // writes user config — confirm before each write
|
|
73
|
+
isReadOnly: false,
|
|
74
|
+
isConcurrencySafe: false, // serializes writes to the single catalog file
|
|
75
|
+
},
|
|
76
|
+
execute: editModelCatalogTool,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
definition: {
|
|
80
|
+
...generateImageToolDef,
|
|
81
|
+
source: "builtin",
|
|
82
|
+
permissionDefault: "ask",
|
|
83
|
+
isReadOnly: false,
|
|
84
|
+
// Independent external I/O with no shared state — same class as WebFetch/GenerateVideo.
|
|
85
|
+
// Each call writes its own collision-free file (Date.now()+random suffix), so N images
|
|
86
|
+
// in one turn run concurrently (~3min for 6 instead of ~15min serial). Dependent chains
|
|
87
|
+
// (image → video) are forced across turns and serialize naturally via the drain barrier.
|
|
88
|
+
isConcurrencySafe: true,
|
|
89
|
+
timeoutMs: 600_000, // 10min — high-quality / large image generation routinely exceeds the 120s default; give slow renders ample room while still bounding a hung request (Stop / ctx.signal cancels sooner)
|
|
90
|
+
// `referenceImages` are local files read off disk and shipped to the
|
|
91
|
+
// provider — gate them through the path-policy layer like Read, so an
|
|
92
|
+
// out-of-workspace ref ("../../etc/passwd") prompts for approval instead
|
|
93
|
+
// of silently leaking. (array arg → executor enforces each element)
|
|
94
|
+
pathPolicy: [{ kind: "arg", arg: "referenceImages", operation: "read" }],
|
|
95
|
+
},
|
|
96
|
+
execute: generateImageTool,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
definition: {
|
|
100
|
+
...generateVideoToolDef,
|
|
101
|
+
source: "builtin",
|
|
102
|
+
permissionDefault: "ask",
|
|
103
|
+
isReadOnly: false,
|
|
104
|
+
isConcurrencySafe: true,
|
|
105
|
+
// Returns fast (fire-and-forget: submits + backgrounds the poll loop),
|
|
106
|
+
// so the default timeout is plenty — the long poll runs detached.
|
|
107
|
+
// `images`/`image` may be local files (uploaded to the provider) — same
|
|
108
|
+
// path-policy gating as GenerateImage's referenceImages.
|
|
109
|
+
pathPolicy: [
|
|
110
|
+
{ kind: "arg", arg: "images", operation: "read" },
|
|
111
|
+
{ kind: "arg", arg: "image", operation: "read" },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
execute: generateVideoTool,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
definition: {
|
|
118
|
+
...viewImageToolDef,
|
|
119
|
+
source: "builtin",
|
|
120
|
+
permissionDefault: "allow",
|
|
121
|
+
isReadOnly: true,
|
|
122
|
+
isConcurrencySafe: true,
|
|
123
|
+
pathPolicy: [{ kind: "arg", arg: "path", operation: "read" }],
|
|
124
|
+
},
|
|
125
|
+
execute: viewImageTool,
|
|
126
|
+
},
|
|
54
127
|
{
|
|
55
128
|
definition: {
|
|
56
129
|
...editToolDef,
|
|
@@ -58,6 +131,7 @@ export const BUILTIN_TOOLS = [
|
|
|
58
131
|
permissionDefault: "ask",
|
|
59
132
|
isReadOnly: false,
|
|
60
133
|
isConcurrencySafe: false,
|
|
134
|
+
pathPolicy: [{ kind: "arg", arg: "file_path", operation: "write" }],
|
|
61
135
|
},
|
|
62
136
|
execute: editTool,
|
|
63
137
|
},
|
|
@@ -68,6 +142,7 @@ export const BUILTIN_TOOLS = [
|
|
|
68
142
|
permissionDefault: "ask",
|
|
69
143
|
isReadOnly: false,
|
|
70
144
|
isConcurrencySafe: false,
|
|
145
|
+
pathPolicy: [{ kind: "apply_patch", arg: "patch", operation: "write" }],
|
|
71
146
|
},
|
|
72
147
|
execute: applyPatchTool,
|
|
73
148
|
},
|
|
@@ -78,6 +153,7 @@ export const BUILTIN_TOOLS = [
|
|
|
78
153
|
permissionDefault: "allow",
|
|
79
154
|
isReadOnly: true,
|
|
80
155
|
isConcurrencySafe: true,
|
|
156
|
+
pathPolicy: [{ kind: "arg", arg: "path", operation: "read", defaultToCwd: true }],
|
|
81
157
|
},
|
|
82
158
|
execute: globTool,
|
|
83
159
|
},
|
|
@@ -88,6 +164,7 @@ export const BUILTIN_TOOLS = [
|
|
|
88
164
|
permissionDefault: "allow",
|
|
89
165
|
isReadOnly: true,
|
|
90
166
|
isConcurrencySafe: true,
|
|
167
|
+
pathPolicy: [{ kind: "arg", arg: "path", operation: "read", defaultToCwd: true }],
|
|
91
168
|
},
|
|
92
169
|
execute: grepTool,
|
|
93
170
|
},
|
|
@@ -102,6 +179,37 @@ export const BUILTIN_TOOLS = [
|
|
|
102
179
|
},
|
|
103
180
|
execute: bashTool,
|
|
104
181
|
},
|
|
182
|
+
// ─── Background shells (Bash run_in_background companions) ──────
|
|
183
|
+
{
|
|
184
|
+
definition: {
|
|
185
|
+
...bashOutputToolDef,
|
|
186
|
+
source: "builtin",
|
|
187
|
+
permissionDefault: "allow",
|
|
188
|
+
isReadOnly: true,
|
|
189
|
+
isConcurrencySafe: true,
|
|
190
|
+
},
|
|
191
|
+
execute: bashOutputTool,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
definition: {
|
|
195
|
+
...killShellToolDef,
|
|
196
|
+
source: "builtin",
|
|
197
|
+
permissionDefault: "allow",
|
|
198
|
+
isReadOnly: false,
|
|
199
|
+
isConcurrencySafe: false,
|
|
200
|
+
},
|
|
201
|
+
execute: killShellTool,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
definition: {
|
|
205
|
+
...listShellsToolDef,
|
|
206
|
+
source: "builtin",
|
|
207
|
+
permissionDefault: "allow",
|
|
208
|
+
isReadOnly: true,
|
|
209
|
+
isConcurrencySafe: true,
|
|
210
|
+
},
|
|
211
|
+
execute: listShellsTool,
|
|
212
|
+
},
|
|
105
213
|
{
|
|
106
214
|
definition: {
|
|
107
215
|
...webSearchToolDef,
|
|
@@ -164,6 +272,17 @@ export const BUILTIN_TOOLS = [
|
|
|
164
272
|
},
|
|
165
273
|
execute: agentCancelTool,
|
|
166
274
|
},
|
|
275
|
+
{
|
|
276
|
+
definition: {
|
|
277
|
+
...agentSendInputToolDef,
|
|
278
|
+
source: "builtin",
|
|
279
|
+
permissionDefault: "allow",
|
|
280
|
+
isReadOnly: true,
|
|
281
|
+
isConcurrencySafe: true,
|
|
282
|
+
timeoutMs: 1_800_000, // 30min — a continuation may execute many tool calls, like Agent
|
|
283
|
+
},
|
|
284
|
+
execute: agentSendInputTool,
|
|
285
|
+
},
|
|
167
286
|
{
|
|
168
287
|
definition: {
|
|
169
288
|
...enterPlanModeToolDef,
|
|
@@ -225,16 +344,6 @@ export const BUILTIN_TOOLS = [
|
|
|
225
344
|
},
|
|
226
345
|
execute: exitWorktreeTool,
|
|
227
346
|
},
|
|
228
|
-
{
|
|
229
|
-
definition: {
|
|
230
|
-
...sendMessageToolDef,
|
|
231
|
-
source: "builtin",
|
|
232
|
-
permissionDefault: "allow",
|
|
233
|
-
isReadOnly: false,
|
|
234
|
-
isConcurrencySafe: true,
|
|
235
|
-
},
|
|
236
|
-
execute: sendMessageTool,
|
|
237
|
-
},
|
|
238
347
|
// ─── Phase 5: Utility Tools ────────────────────────────────────
|
|
239
348
|
{
|
|
240
349
|
definition: {
|
|
@@ -263,6 +372,13 @@ export const BUILTIN_TOOLS = [
|
|
|
263
372
|
permissionDefault: "ask",
|
|
264
373
|
isReadOnly: false,
|
|
265
374
|
isConcurrencySafe: false,
|
|
375
|
+
pathPolicy: [
|
|
376
|
+
{
|
|
377
|
+
kind: "arg",
|
|
378
|
+
arg: "file_path",
|
|
379
|
+
operation: { fromArg: "action", readValues: ["read"], default: "write" },
|
|
380
|
+
},
|
|
381
|
+
],
|
|
266
382
|
},
|
|
267
383
|
execute: notebookEditTool,
|
|
268
384
|
},
|
|
@@ -274,6 +390,7 @@ export const BUILTIN_TOOLS = [
|
|
|
274
390
|
permissionDefault: "allow",
|
|
275
391
|
isReadOnly: true,
|
|
276
392
|
isConcurrencySafe: true,
|
|
393
|
+
pathPolicy: [{ kind: "arg", arg: "file_path", operation: "read" }],
|
|
277
394
|
},
|
|
278
395
|
execute: lspTool,
|
|
279
396
|
},
|
|
@@ -308,6 +425,43 @@ export const BUILTIN_TOOLS = [
|
|
|
308
425
|
},
|
|
309
426
|
execute: cronListTool,
|
|
310
427
|
},
|
|
428
|
+
// ─── Drive external coding-agent CLI (claude / codex) ──────────
|
|
429
|
+
{
|
|
430
|
+
definition: {
|
|
431
|
+
...driveAgentToolDef,
|
|
432
|
+
source: "builtin",
|
|
433
|
+
permissionDefault: "ask",
|
|
434
|
+
isReadOnly: false,
|
|
435
|
+
isConcurrencySafe: false,
|
|
436
|
+
},
|
|
437
|
+
execute: driveAgentTool,
|
|
438
|
+
},
|
|
439
|
+
// Back-compat alias: DriveClaudeCode = DriveAgent pinned to cli:claude. Kept
|
|
440
|
+
// registered so old prompts/memories that name DriveClaudeCode still resolve.
|
|
441
|
+
{
|
|
442
|
+
definition: {
|
|
443
|
+
...driveClaudeCodeToolDef,
|
|
444
|
+
source: "builtin",
|
|
445
|
+
permissionDefault: "ask",
|
|
446
|
+
isReadOnly: false,
|
|
447
|
+
isConcurrencySafe: false,
|
|
448
|
+
},
|
|
449
|
+
execute: driveClaudeCodeTool,
|
|
450
|
+
},
|
|
451
|
+
// ─── Check remaining CC/Codex subscription quota ──────────────
|
|
452
|
+
{
|
|
453
|
+
definition: {
|
|
454
|
+
...checkQuotaToolDef,
|
|
455
|
+
source: "builtin",
|
|
456
|
+
// Read-only intent (reports quota, mutates nothing). Note: the "claude"
|
|
457
|
+
// path sends a 1-token probe (Anthropic exposes quota only via response
|
|
458
|
+
// headers) — that tiny cost is documented in the tool description.
|
|
459
|
+
permissionDefault: "allow",
|
|
460
|
+
isReadOnly: true,
|
|
461
|
+
isConcurrencySafe: true,
|
|
462
|
+
},
|
|
463
|
+
execute: checkQuotaTool,
|
|
464
|
+
},
|
|
311
465
|
// ─── Phase 7: Missing tools from restored-src ─────────────────
|
|
312
466
|
{
|
|
313
467
|
definition: {
|
|
@@ -343,22 +497,17 @@ export const BUILTIN_TOOLS = [
|
|
|
343
497
|
definition: {
|
|
344
498
|
...readMcpResourceToolDef,
|
|
345
499
|
source: "builtin",
|
|
346
|
-
|
|
500
|
+
// Reading resource CONTENT (unlike enumerating names) can pull arbitrary
|
|
501
|
+
// data — potentially secrets — from a connected MCP server. Default to ask
|
|
502
|
+
// rather than the old unconditional allow so a default-mode session
|
|
503
|
+
// confirms the read; the executor also gates the target server against the
|
|
504
|
+
// session's allowedMcpServers.
|
|
505
|
+
permissionDefault: "ask",
|
|
347
506
|
isReadOnly: true,
|
|
348
507
|
isConcurrencySafe: true,
|
|
349
508
|
},
|
|
350
509
|
execute: readMcpResourceTool,
|
|
351
510
|
},
|
|
352
|
-
{
|
|
353
|
-
definition: {
|
|
354
|
-
...remoteTriggerToolDef,
|
|
355
|
-
source: "builtin",
|
|
356
|
-
permissionDefault: "ask",
|
|
357
|
-
isReadOnly: false,
|
|
358
|
-
isConcurrencySafe: false,
|
|
359
|
-
},
|
|
360
|
-
execute: remoteTriggerTool,
|
|
361
|
-
},
|
|
362
511
|
{
|
|
363
512
|
definition: {
|
|
364
513
|
...replToolDef,
|
|
@@ -446,4 +595,140 @@ export const BUILTIN_TOOLS = [
|
|
|
446
595
|
},
|
|
447
596
|
execute: memoryDeleteTool,
|
|
448
597
|
},
|
|
598
|
+
// ─── Goal mode: model-declared completion ──────────────────────
|
|
599
|
+
// Lets the model explicitly declare the active goal complete. The
|
|
600
|
+
// turn-loop short-circuits on this call; the tool itself only records an
|
|
601
|
+
// acknowledgement string, so it's read-only and concurrency-safe.
|
|
602
|
+
{
|
|
603
|
+
definition: {
|
|
604
|
+
...completeGoalToolDef,
|
|
605
|
+
source: "builtin",
|
|
606
|
+
permissionDefault: "allow",
|
|
607
|
+
isReadOnly: true,
|
|
608
|
+
isConcurrencySafe: true,
|
|
609
|
+
},
|
|
610
|
+
execute: completeGoalTool,
|
|
611
|
+
},
|
|
612
|
+
// ─── Goal mode: user-initiated cancellation ────────────────────
|
|
613
|
+
// Distinct from complete_goal — the user explicitly asked to abandon the
|
|
614
|
+
// goal. The turn-loop short-circuits on this call (only when confirm===true)
|
|
615
|
+
// AND clears the persisted goal. The tool itself only records an
|
|
616
|
+
// acknowledgement string, so it's read-only and concurrency-safe.
|
|
617
|
+
{
|
|
618
|
+
definition: {
|
|
619
|
+
...cancelGoalToolDef,
|
|
620
|
+
source: "builtin",
|
|
621
|
+
permissionDefault: "allow",
|
|
622
|
+
isReadOnly: true,
|
|
623
|
+
isConcurrencySafe: true,
|
|
624
|
+
},
|
|
625
|
+
execute: cancelGoalTool,
|
|
626
|
+
},
|
|
627
|
+
// ─── Plugin marketplace: model-driven source registration ──────
|
|
628
|
+
{
|
|
629
|
+
definition: {
|
|
630
|
+
...addMarketplaceToolDef,
|
|
631
|
+
source: "builtin",
|
|
632
|
+
permissionDefault: "ask",
|
|
633
|
+
isReadOnly: false,
|
|
634
|
+
isConcurrencySafe: false,
|
|
635
|
+
timeoutMs: 120_000, // git clone over network
|
|
636
|
+
},
|
|
637
|
+
execute: addMarketplaceTool,
|
|
638
|
+
},
|
|
639
|
+
// Browser automation — 3 semantic tools driving the in-app webview via the
|
|
640
|
+
// BrowserBridge (CDP). All serial on one webview (isConcurrencySafe:false).
|
|
641
|
+
// browser_observe is read-only. browser_act is permissionDefault "allow"; its
|
|
642
|
+
// sensitive actions (click/type/select) are escalated to "ask" by a preset
|
|
643
|
+
// PermissionRule keyed on argsPattern { action } (see preset/index.ts §4.6) —
|
|
644
|
+
// so one tool carries per-action gating. Sensitive-action + domain-whitelist
|
|
645
|
+
// enforcement also lives main-side in the bridge. Tools self-gate to
|
|
646
|
+
// unavailable when no bridge is wired (headless).
|
|
647
|
+
{
|
|
648
|
+
definition: {
|
|
649
|
+
...browserObserveToolDef,
|
|
650
|
+
source: "builtin",
|
|
651
|
+
permissionDefault: "allow",
|
|
652
|
+
isReadOnly: true,
|
|
653
|
+
isConcurrencySafe: false,
|
|
654
|
+
timeoutMs: 30_000, // wait/observe can sit through a load; RPC headroom
|
|
655
|
+
},
|
|
656
|
+
execute: browserObserveTool,
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
definition: {
|
|
660
|
+
...browserActToolDef,
|
|
661
|
+
source: "builtin",
|
|
662
|
+
permissionDefault: "allow", // per-action gating via preset rule (argsPattern.action)
|
|
663
|
+
isReadOnly: false,
|
|
664
|
+
isConcurrencySafe: false,
|
|
665
|
+
timeoutMs: 30_000, // the wait action internally bounds; give RPC headroom
|
|
666
|
+
},
|
|
667
|
+
execute: browserActTool,
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
definition: {
|
|
671
|
+
...browserNavigateToolDef,
|
|
672
|
+
source: "builtin",
|
|
673
|
+
permissionDefault: "allow",
|
|
674
|
+
isReadOnly: false,
|
|
675
|
+
isConcurrencySafe: false,
|
|
676
|
+
},
|
|
677
|
+
execute: browserNavigateTool,
|
|
678
|
+
},
|
|
679
|
+
// ─── Credentials: AI 取用已存凭证(token/link/cookie) ──────────
|
|
680
|
+
// permissionDefault:"allow" —— 取用审批由工具内部的 CredentialUseGate 负责
|
|
681
|
+
// (默认问/本会话记住/全自动),不走工具级权限层,避免双重弹窗。
|
|
682
|
+
// 读取凭证库本身不写文件(cookie 物化成临时 cookies.txt 是用完即弃的副产物)。
|
|
683
|
+
{
|
|
684
|
+
definition: {
|
|
685
|
+
...useCredentialToolDef,
|
|
686
|
+
source: "builtin",
|
|
687
|
+
permissionDefault: "allow",
|
|
688
|
+
isReadOnly: true,
|
|
689
|
+
isConcurrencySafe: true,
|
|
690
|
+
},
|
|
691
|
+
execute: useCredentialTool,
|
|
692
|
+
},
|
|
693
|
+
// InjectCredential:把 cookie 凭证注入内置浏览器(恢复登录态)。审批由工具内部
|
|
694
|
+
// CredentialUseGate 负责(逐条 autoInjectByAI),故 permissionDefault:"allow"。
|
|
695
|
+
// 改浏览器登录态有副作用 → 非 read-only。
|
|
696
|
+
{
|
|
697
|
+
definition: {
|
|
698
|
+
...injectCredentialToolDef,
|
|
699
|
+
source: "builtin",
|
|
700
|
+
permissionDefault: "allow",
|
|
701
|
+
isReadOnly: false,
|
|
702
|
+
isConcurrencySafe: false,
|
|
703
|
+
},
|
|
704
|
+
execute: injectCredentialTool,
|
|
705
|
+
},
|
|
449
706
|
];
|
|
707
|
+
/**
|
|
708
|
+
* Per-tool availability predicates. A tool listed here is filtered OUT of the
|
|
709
|
+
* exposed toolDefs when its predicate returns false for the active cwd (see
|
|
710
|
+
* engine.ts toolDefs assembly). Tools NOT listed here are always visible.
|
|
711
|
+
* Keyed by the tool's `name` (must match the toolDef name).
|
|
712
|
+
*/
|
|
713
|
+
export const BUILTIN_TOOL_GUARDS = new Map([
|
|
714
|
+
[webSearchToolDef.name, isWebSearchAvailable],
|
|
715
|
+
[generateImageToolDef.name, isGenerateImageAvailable],
|
|
716
|
+
[generateVideoToolDef.name, isGenerateVideoAvailable],
|
|
717
|
+
// UseCredential is hidden until at least one credential exists — keeps it out
|
|
718
|
+
// of the tool list (and the context) for the common no-credentials case,
|
|
719
|
+
// matching the spec's "quiet when empty" intent (true ToolSearch-deferral for
|
|
720
|
+
// builtins isn't wired in the engine).
|
|
721
|
+
[useCredentialToolDef.name, isUseCredentialAvailable],
|
|
722
|
+
// InjectCredential hidden until ≥1 cookie credential exists (browser injection
|
|
723
|
+
// is cookie-only). Also degrades at call time if no browser bridge is wired.
|
|
724
|
+
[injectCredentialToolDef.name, isInjectCredentialAvailable],
|
|
725
|
+
]);
|
|
726
|
+
/** UseCredential is available when the cwd's CredentialStore has ≥1 credential. */
|
|
727
|
+
export function isUseCredentialAvailable(cwd) {
|
|
728
|
+
try {
|
|
729
|
+
return new CredentialStore(cwd).listMasked().length > 0;
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
@@ -28,10 +28,13 @@ export async function mcpToolExecute(args) {
|
|
|
28
28
|
const server = args.server;
|
|
29
29
|
const tool = args.tool;
|
|
30
30
|
const toolArgs = args.arguments ?? {};
|
|
31
|
+
// Forward the run's abort signal (registry injects __signal) so Stop cancels
|
|
32
|
+
// an in-flight MCP call instead of waiting out the SDK's default timeout.
|
|
33
|
+
const signal = args.__signal;
|
|
31
34
|
try {
|
|
32
35
|
const { MCPManager } = await import("../mcp-manager.js");
|
|
33
36
|
const manager = MCPManager.getInstance();
|
|
34
|
-
const result = await manager.callTool(server, tool, toolArgs);
|
|
37
|
+
const result = await manager.callTool(server, tool, toolArgs, signal);
|
|
35
38
|
return typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
36
39
|
}
|
|
37
40
|
catch (err) {
|
|
@@ -54,10 +57,26 @@ export const listMcpResourcesToolDef = {
|
|
|
54
57
|
};
|
|
55
58
|
export async function listMcpResourcesTool(args) {
|
|
56
59
|
const server = args.server ?? "";
|
|
60
|
+
// The executor injects the session's allowed-server set (see executor.ts).
|
|
61
|
+
// When no explicit server filter is given, we must only enumerate resources
|
|
62
|
+
// from servers THIS session enabled — otherwise a shared worker leaks another
|
|
63
|
+
// session's MCP resources. An undefined set means "no gating" (legacy/sub-agent).
|
|
64
|
+
const allowed = args.__allowedMcpServers;
|
|
57
65
|
try {
|
|
58
66
|
const { MCPManager } = await import("../mcp-manager.js");
|
|
59
67
|
const manager = MCPManager.getInstance();
|
|
60
|
-
|
|
68
|
+
// Forward the run's abort signal (registry injects __signal) so Stop cancels
|
|
69
|
+
// promptly instead of waiting out the SDK's default request timeout.
|
|
70
|
+
const signal = args.__signal;
|
|
71
|
+
let resources = await manager.listResources(server || undefined, signal);
|
|
72
|
+
if (allowed && resources) {
|
|
73
|
+
resources = resources.filter((r) => {
|
|
74
|
+
// Resource entries may carry the owning server on `serverName`/`server`;
|
|
75
|
+
// when unknown, drop it under gating rather than risk a cross-session leak.
|
|
76
|
+
const owner = (r.serverName ?? r.server);
|
|
77
|
+
return owner ? allowed.has(owner) : false;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
61
80
|
if (!resources || resources.length === 0) {
|
|
62
81
|
return "No MCP resources available.";
|
|
63
82
|
}
|
|
@@ -93,7 +112,8 @@ export async function readMcpResourceTool(args) {
|
|
|
93
112
|
try {
|
|
94
113
|
const { MCPManager } = await import("../mcp-manager.js");
|
|
95
114
|
const manager = MCPManager.getInstance();
|
|
96
|
-
const
|
|
115
|
+
const signal = args.__signal;
|
|
116
|
+
const content = await manager.readResource(server, uri, signal);
|
|
97
117
|
return typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
98
118
|
}
|
|
99
119
|
catch (err) {
|