@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,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser automation tools — drive the in-app webview via the BrowserBridge
|
|
3
|
+
* (CDP under the hood). Collapsed into THREE semantic tools (was 9 flat tools)
|
|
4
|
+
* to keep the LLM's tool list lean:
|
|
5
|
+
*
|
|
6
|
+
* browser_observe — observe the page: snapshot (a11y elements) / read (text) /
|
|
7
|
+
* extract (link+image+video URLs). [+ image/vision in P4]
|
|
8
|
+
* browser_act — interact: click / type / select / press_key / hover /
|
|
9
|
+
* scroll / wait / list_tabs / switch_tab (action-dispatched).
|
|
10
|
+
* browser_navigate — load a URL (high-frequency, kept standalone).
|
|
11
|
+
*
|
|
12
|
+
* Spec: docs/superpowers/specs/2026-06-18-browser-module-redesign-design.md §4.1.
|
|
13
|
+
*
|
|
14
|
+
* snapshot returns interactive elements as a compact ref-tagged list (a11y tree,
|
|
15
|
+
* token-economical, no screenshots); act references elements by the ref the
|
|
16
|
+
* latest snapshot assigned. All tools degrade with a clear error when no browser
|
|
17
|
+
* is wired. isConcurrencySafe:false — a single webview is driven serially.
|
|
18
|
+
*
|
|
19
|
+
* Permission: browser_act is permissionDefault "allow"; the sensitive actions
|
|
20
|
+
* (click/type/select) are escalated to "ask" by a preset PermissionRule keyed on
|
|
21
|
+
* argsPattern { action }, so one tool can carry per-action gating (§4.6).
|
|
22
|
+
*/
|
|
23
|
+
import { renderElementList } from "../browser-bridge.js";
|
|
24
|
+
import { capabilitiesFor } from "../../llm/capabilities/index.js";
|
|
25
|
+
const NO_BROWSER = "Error: browser automation is not available (no browser panel in this session). " +
|
|
26
|
+
"It requires the desktop app with an open browser panel.";
|
|
27
|
+
function bridge(ctx) {
|
|
28
|
+
return ctx?.browser;
|
|
29
|
+
}
|
|
30
|
+
const STALE = (ref) => `Error: ref ${ref} is no longer valid (page changed). Re-run browser_observe.`;
|
|
31
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
32
|
+
// browser_observe — observe the page (snapshot / read / extract)
|
|
33
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
34
|
+
export const browserObserveToolDef = {
|
|
35
|
+
name: "browser_observe",
|
|
36
|
+
description: "Observe the current page in the browser panel. Modes:\n" +
|
|
37
|
+
"- snapshot (default): URL/title + a compact list of interactive elements, each " +
|
|
38
|
+
"tagged [ref=eN] for browser_act. ALWAYS snapshot before acting, and re-snapshot " +
|
|
39
|
+
"after navigation/page changes (refs are only valid for the latest snapshot). " +
|
|
40
|
+
"Passwords show as [sensitive] with no value.\n" +
|
|
41
|
+
"- read: the page's main readable text (for summarizing/scraping an article/post; " +
|
|
42
|
+
"long pages truncate — scroll + read again).\n" +
|
|
43
|
+
"- extract: the real URLs on the page (hyperlink hrefs, image srcs, video srcs) " +
|
|
44
|
+
"that snapshot omits — each image/video is tagged [ref=imgN/vidN] for image mode.\n" +
|
|
45
|
+
"- image: SEE the actual pixels of page images (refs from extract, e.g. img3) — for " +
|
|
46
|
+
"reading what a photo/product image/小红书 笔记配图 actually shows. Fetched in-page so " +
|
|
47
|
+
"it works behind hotlink protection. A vidN ref grabs the video's current frame.\n" +
|
|
48
|
+
"- vision: screenshot the rendered page (or one element via ref) — for layout/canvas/" +
|
|
49
|
+
"charts the a11y tree can't convey. Use sparingly (images cost tokens; snapshot first).",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
mode: {
|
|
54
|
+
type: "string",
|
|
55
|
+
enum: ["snapshot", "read", "extract", "image", "vision"],
|
|
56
|
+
description: "What to observe (default: snapshot)",
|
|
57
|
+
},
|
|
58
|
+
refs: {
|
|
59
|
+
type: "array",
|
|
60
|
+
items: { type: "string" },
|
|
61
|
+
description: "image mode: image refs (imgN/vidN from extract) to see, one or more",
|
|
62
|
+
},
|
|
63
|
+
ref: { type: "string", description: "vision mode (optional): screenshot just this element's region" },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
/** Vision gate: only show images to a vision-capable model. Mirrors view_image —
|
|
68
|
+
* no vision → never read pixels into context (your rule: 不支持就不给看). */
|
|
69
|
+
function modelSupportsVision(ctx) {
|
|
70
|
+
if (!ctx?.llmConfig)
|
|
71
|
+
return false;
|
|
72
|
+
const kind = (ctx.llmConfig.providerKind ?? ctx.llmConfig.provider);
|
|
73
|
+
return capabilitiesFor(kind, ctx.llmConfig.model).supportsVision;
|
|
74
|
+
}
|
|
75
|
+
/** Wrap captured image data into a vision ContentBlock (or null if not usable). */
|
|
76
|
+
function toImageBlock(d) {
|
|
77
|
+
if (!d.ok || !d.base64 || !d.mediaType)
|
|
78
|
+
return null;
|
|
79
|
+
return { type: "image", source: { type: "base64", media_type: d.mediaType, data: d.base64 } };
|
|
80
|
+
}
|
|
81
|
+
export async function browserObserveTool(args, ctx) {
|
|
82
|
+
const b = bridge(ctx);
|
|
83
|
+
if (!b)
|
|
84
|
+
return NO_BROWSER;
|
|
85
|
+
const mode = args.mode || "snapshot";
|
|
86
|
+
switch (mode) {
|
|
87
|
+
case "snapshot": {
|
|
88
|
+
const snap = await b.snapshot();
|
|
89
|
+
const header = `URL: ${snap.url}${snap.title ? `\nTitle: ${snap.title}` : ""}`;
|
|
90
|
+
const human = snap.needsHuman
|
|
91
|
+
? `\n\n⚠ ${snap.needsHuman} — please complete it in the browser panel, then continue.`
|
|
92
|
+
: "";
|
|
93
|
+
return `${header}\n\n${renderElementList(snap.elements)}${human}`;
|
|
94
|
+
}
|
|
95
|
+
case "read": {
|
|
96
|
+
const c = await b.readContent();
|
|
97
|
+
if (!c.ok)
|
|
98
|
+
return `Error: ${c.detail ?? "could not read page content"}`;
|
|
99
|
+
const head = `URL: ${c.url}${c.title ? `\nTitle: ${c.title}` : ""}${c.truncated ? "\n(content truncated)" : ""}`;
|
|
100
|
+
return `${head}\n\n${c.text || "(no readable text)"}`;
|
|
101
|
+
}
|
|
102
|
+
case "extract": {
|
|
103
|
+
const r = await b.extractLinks();
|
|
104
|
+
if (!r.ok)
|
|
105
|
+
return `Error: ${r.detail ?? "could not extract URLs"}`;
|
|
106
|
+
const head = `URL: ${r.url}${r.title ? `\nTitle: ${r.title}` : ""}${r.truncated ? "\n(truncated — page had more; narrow it and re-extract)" : ""}`;
|
|
107
|
+
const links = r.links.length > 0
|
|
108
|
+
? "Links:\n" + r.links.map((l) => `- ${l.text ? `${l.text} → ` : ""}${l.url}`).join("\n")
|
|
109
|
+
: "Links: (none)";
|
|
110
|
+
const images = r.images.length > 0
|
|
111
|
+
? "Images (use the ref with browser_observe(image) to SEE one):\n" +
|
|
112
|
+
r.images.map((im) => `- [${im.ref ?? "?"}] ${im.alt ? `${im.alt} → ` : ""}${im.url}`).join("\n")
|
|
113
|
+
: "Images: (none)";
|
|
114
|
+
const videos = r.videos && r.videos.length > 0
|
|
115
|
+
? "Videos:\n" + r.videos.map((v) => `- ${v.url}`).join("\n")
|
|
116
|
+
: "Videos: (none)";
|
|
117
|
+
return `${head}\n\n${links}\n\n${images}\n\n${videos}`;
|
|
118
|
+
}
|
|
119
|
+
case "image": {
|
|
120
|
+
// Vision gate: don't fetch pixels for a non-vision model (your rule).
|
|
121
|
+
if (!modelSupportsVision(ctx)) {
|
|
122
|
+
return "[图片未加载 —— 当前模型不支持视觉输入,已跳过。切换到 vision 模型后再用 browser_observe(image)。]";
|
|
123
|
+
}
|
|
124
|
+
const refs = Array.isArray(args.refs) ? args.refs : [];
|
|
125
|
+
if (refs.length === 0)
|
|
126
|
+
return "Error: refs is required for image mode (image refs from browser_observe(extract), e.g. img3)";
|
|
127
|
+
const datas = await b.fetchImages(refs);
|
|
128
|
+
const blocks = [];
|
|
129
|
+
const notes = [];
|
|
130
|
+
for (const d of datas) {
|
|
131
|
+
const block = toImageBlock(d);
|
|
132
|
+
if (block) {
|
|
133
|
+
blocks.push(block);
|
|
134
|
+
notes.push(`${d.ref ?? "?"}: loaded`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
notes.push(`${d.ref ?? "?"}: ${d.detail ?? "could not load"}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (blocks.length === 0)
|
|
141
|
+
return `Error: no images loaded — ${notes.join("; ")}`;
|
|
142
|
+
return { contentBlocks: blocks, result: `[loaded ${blocks.length} image(s): ${notes.join("; ")}]` };
|
|
143
|
+
}
|
|
144
|
+
case "vision": {
|
|
145
|
+
if (!modelSupportsVision(ctx)) {
|
|
146
|
+
return "[截图未加载 —— 当前模型不支持视觉输入,已跳过。切换到 vision 模型后再用 browser_observe(vision)。]";
|
|
147
|
+
}
|
|
148
|
+
const ref = args.ref;
|
|
149
|
+
const d = await b.screenshot(ref);
|
|
150
|
+
const block = toImageBlock(d);
|
|
151
|
+
if (!block)
|
|
152
|
+
return `Error: ${d.detail ?? "screenshot failed"}`;
|
|
153
|
+
return { contentBlocks: [block], result: `[screenshot loaded${ref ? ` of ${ref}` : ""}]` };
|
|
154
|
+
}
|
|
155
|
+
default:
|
|
156
|
+
return `Error: unknown observe mode "${mode}" (use snapshot | read | extract | image | vision)`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
160
|
+
// browser_act — interact with the page (action-dispatched)
|
|
161
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
162
|
+
export const browserActToolDef = {
|
|
163
|
+
name: "browser_act",
|
|
164
|
+
description: "Act on the page in the browser panel. Use refs (eN) from the latest " +
|
|
165
|
+
"browser_observe(snapshot). Actions:\n" +
|
|
166
|
+
"- click {ref}: click an element.\n" +
|
|
167
|
+
"- type {ref, text}: type text into an input (focuses first).\n" +
|
|
168
|
+
"- select {ref, value}: choose an option in a NATIVE <select> (value = option " +
|
|
169
|
+
"value or visible text). Custom dropdowns: click to expand, then click the option.\n" +
|
|
170
|
+
"- press_key {key, ref?}: press a key/combo (Enter, Tab, Escape, ArrowDown, " +
|
|
171
|
+
"Control+a). Focuses ref first if given.\n" +
|
|
172
|
+
"- hover {ref}: hover to reveal menus/tooltips.\n" +
|
|
173
|
+
"- scroll {direction: up|down, amount?}: scroll the page, then re-observe.\n" +
|
|
174
|
+
"- wait {timeout_ms?}: wait for the page to finish loading before observing.\n" +
|
|
175
|
+
"- list_tabs: list open browser tabs (tabId, url, title, which is active).\n" +
|
|
176
|
+
"- switch_tab {tabId}: make another tab the active one that actions drive.\n" +
|
|
177
|
+
"Pass tabId on any action to target a specific tab (switches to it first). " +
|
|
178
|
+
"Re-observe after navigation/page/tab changes (refs go stale per tab).",
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: "object",
|
|
181
|
+
properties: {
|
|
182
|
+
action: {
|
|
183
|
+
type: "string",
|
|
184
|
+
enum: ["click", "type", "select", "press_key", "hover", "scroll", "wait", "list_tabs", "switch_tab"],
|
|
185
|
+
description: "The interaction to perform",
|
|
186
|
+
},
|
|
187
|
+
ref: { type: "string", description: "Element ref (eN) — click/type/select/hover/press_key" },
|
|
188
|
+
text: { type: "string", description: "Text to type — type" },
|
|
189
|
+
value: { type: "string", description: "Option value or visible text — select" },
|
|
190
|
+
key: { type: "string", description: "Key name or combo (Enter/Tab/Control+a) — press_key" },
|
|
191
|
+
direction: { type: "string", enum: ["up", "down"], description: "Scroll direction — scroll" },
|
|
192
|
+
amount: { type: "number", description: "Pixels to scroll (default one viewport) — scroll" },
|
|
193
|
+
timeout_ms: { type: "number", description: "Max wait in ms (default 10000) — wait" },
|
|
194
|
+
tabId: { type: "string", description: "Target tab — required for switch_tab; optional on others (switches first)" },
|
|
195
|
+
},
|
|
196
|
+
required: ["action"],
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
export async function browserActTool(args, ctx) {
|
|
200
|
+
const b = bridge(ctx);
|
|
201
|
+
if (!b)
|
|
202
|
+
return NO_BROWSER;
|
|
203
|
+
const action = args.action;
|
|
204
|
+
const ref = args.ref;
|
|
205
|
+
const tabId = args.tabId;
|
|
206
|
+
// Optional tabId on a non-tab action → switch to that tab first, then act.
|
|
207
|
+
if (tabId && action !== "switch_tab" && action !== "list_tabs") {
|
|
208
|
+
const sw = await b.switchTab(tabId);
|
|
209
|
+
if (!sw.ok)
|
|
210
|
+
return `Error: could not switch to tab ${tabId} — ${sw.detail ?? "not found"}`;
|
|
211
|
+
}
|
|
212
|
+
switch (action) {
|
|
213
|
+
case "list_tabs": {
|
|
214
|
+
const tabs = await b.listTabs();
|
|
215
|
+
if (tabs.length === 0)
|
|
216
|
+
return "(no open browser tabs)";
|
|
217
|
+
return ("Open tabs:\n" +
|
|
218
|
+
tabs.map((t) => `- [${t.tabId}]${t.active ? " (active)" : ""} ${t.title || "(untitled)"} — ${t.url || "(blank)"}`).join("\n"));
|
|
219
|
+
}
|
|
220
|
+
case "switch_tab": {
|
|
221
|
+
if (!tabId)
|
|
222
|
+
return "Error: tabId is required for switch_tab (see list_tabs)";
|
|
223
|
+
const r = await b.switchTab(tabId);
|
|
224
|
+
return r.ok ? `Switched to tab ${tabId} — re-observe to see it` : `Error: ${r.detail ?? "switch failed"}`;
|
|
225
|
+
}
|
|
226
|
+
case "click": {
|
|
227
|
+
if (!ref)
|
|
228
|
+
return "Error: ref is required for click";
|
|
229
|
+
const r = await b.click(ref);
|
|
230
|
+
if (r.ok)
|
|
231
|
+
return `Clicked ${ref}${r.detail ? ` — ${r.detail}` : ""}`;
|
|
232
|
+
return r.staleRef ? STALE(ref) : `Error: ${r.detail ?? "click failed"}`;
|
|
233
|
+
}
|
|
234
|
+
case "type": {
|
|
235
|
+
const text = args.text;
|
|
236
|
+
if (!ref)
|
|
237
|
+
return "Error: ref is required for type";
|
|
238
|
+
if (typeof text !== "string")
|
|
239
|
+
return "Error: text is required for type";
|
|
240
|
+
const r = await b.type(ref, text);
|
|
241
|
+
if (r.ok)
|
|
242
|
+
return `Typed into ${ref}`;
|
|
243
|
+
return r.staleRef ? STALE(ref) : `Error: ${r.detail ?? "type failed"}`;
|
|
244
|
+
}
|
|
245
|
+
case "select": {
|
|
246
|
+
const value = args.value;
|
|
247
|
+
if (!ref)
|
|
248
|
+
return "Error: ref is required for select";
|
|
249
|
+
if (typeof value !== "string")
|
|
250
|
+
return "Error: value is required for select";
|
|
251
|
+
const r = await b.selectOption(ref, value);
|
|
252
|
+
if (r.ok)
|
|
253
|
+
return `Selected${r.detail ? ` ${r.detail}` : ""} in ${ref}`;
|
|
254
|
+
return r.staleRef ? STALE(ref) : `Error: ${r.detail ?? "select failed"}`;
|
|
255
|
+
}
|
|
256
|
+
case "press_key": {
|
|
257
|
+
const key = args.key || "Enter";
|
|
258
|
+
const r = await b.pressKey(key, ref);
|
|
259
|
+
if (r.ok)
|
|
260
|
+
return `Pressed ${key}`;
|
|
261
|
+
return r.staleRef && ref ? STALE(ref) : `Error: ${r.detail ?? "press_key failed"}`;
|
|
262
|
+
}
|
|
263
|
+
case "hover": {
|
|
264
|
+
if (!ref)
|
|
265
|
+
return "Error: ref is required for hover";
|
|
266
|
+
const r = await b.hover(ref);
|
|
267
|
+
if (r.ok)
|
|
268
|
+
return `Hovered ${ref}`;
|
|
269
|
+
return r.staleRef ? STALE(ref) : `Error: ${r.detail ?? "hover failed"}`;
|
|
270
|
+
}
|
|
271
|
+
case "scroll": {
|
|
272
|
+
const dir = args.direction;
|
|
273
|
+
if (dir !== "up" && dir !== "down")
|
|
274
|
+
return "Error: direction must be 'up' or 'down'";
|
|
275
|
+
const r = await b.scroll(dir, args.amount);
|
|
276
|
+
return r.ok ? `Scrolled ${dir}` : `Error: ${r.detail ?? "scroll failed"}`;
|
|
277
|
+
}
|
|
278
|
+
case "wait": {
|
|
279
|
+
const r = await b.waitForLoad(args.timeout_ms);
|
|
280
|
+
return r.ok ? `Page ready${r.detail ? ` (${r.detail})` : ""}` : `Error: ${r.detail ?? "wait failed"}`;
|
|
281
|
+
}
|
|
282
|
+
default:
|
|
283
|
+
return `Error: unknown action "${action}"`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
287
|
+
// browser_navigate — load a URL (kept standalone: high-frequency, distinct)
|
|
288
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
289
|
+
export const browserNavigateToolDef = {
|
|
290
|
+
name: "browser_navigate",
|
|
291
|
+
description: "Navigate the browser panel to a URL (opens the panel automatically if none " +
|
|
292
|
+
"is open). Then call browser_act(wait) + browser_observe to see the page.",
|
|
293
|
+
inputSchema: {
|
|
294
|
+
type: "object",
|
|
295
|
+
properties: { url: { type: "string", description: "Absolute URL to open" } },
|
|
296
|
+
required: ["url"],
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
export async function browserNavigateTool(args, ctx) {
|
|
300
|
+
const b = bridge(ctx);
|
|
301
|
+
if (!b)
|
|
302
|
+
return NO_BROWSER;
|
|
303
|
+
const url = args.url;
|
|
304
|
+
if (!url)
|
|
305
|
+
return "Error: url is required";
|
|
306
|
+
const r = await b.navigate(url);
|
|
307
|
+
return r.ok ? `Navigated to ${url}` : `Error: ${r.detail ?? "navigation failed"}`;
|
|
308
|
+
}
|
|
309
|
+
/** True when the session has a browser bridge wired (used to gate visibility). */
|
|
310
|
+
export function isBrowserAutomationAvailable(ctx) {
|
|
311
|
+
return bridge(ctx) !== undefined;
|
|
312
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cancel_goal — user-initiated goal ABANDONMENT (distinct from complete_goal).
|
|
3
|
+
*
|
|
4
|
+
* complete_goal = "the goal is fully achieved, stop." cancel_goal = "the user
|
|
5
|
+
* explicitly asked to STOP pursuing this goal even though it isn't done." Both
|
|
6
|
+
* short-circuit the turn loop to a stop and clear the persisted goal so a later
|
|
7
|
+
* bare send won't re-inherit it — but cancel_goal is a controlled escape hatch,
|
|
8
|
+
* NOT a self-judgment the model may make on its own.
|
|
9
|
+
*
|
|
10
|
+
* "Strong intent" guard (the whole point of this tool): the model must NOT
|
|
11
|
+
* cancel a goal on its own initiative — only when the user has clearly asked to
|
|
12
|
+
* stop/abandon it. To make that hard to do accidentally, the schema REQUIRES:
|
|
13
|
+
* - confirm: true — an explicit boolean gate (a bare call is invalid)
|
|
14
|
+
* - reason: string — the user's own words / paraphrase of the request
|
|
15
|
+
* The turn loop only honors the cancellation when confirm === true; anything
|
|
16
|
+
* else records a refusal string and does NOT stop or clear the goal.
|
|
17
|
+
*
|
|
18
|
+
* Shape note: like complete_goal, this is a ToolDefinition + a separate executor
|
|
19
|
+
* returning a string. The loop-level short-circuit lives in turn-loop.ts and
|
|
20
|
+
* keys off CANCEL_GOAL_TOOL_NAME.
|
|
21
|
+
*/
|
|
22
|
+
import type { ToolDefinition } from "../../types.js";
|
|
23
|
+
/** Shared with turn-loop.ts's short-circuit check — the name lives in one place. */
|
|
24
|
+
export declare const CANCEL_GOAL_TOOL_NAME = "cancel_goal";
|
|
25
|
+
export declare const cancelGoalToolDef: ToolDefinition;
|
|
26
|
+
/**
|
|
27
|
+
* Executor. Returns a human-readable acknowledgement. The ACTUAL cancellation
|
|
28
|
+
* (stop + clear persisted goal) is enforced in turn-loop.ts, which re-checks
|
|
29
|
+
* confirm===true — this executor's string is only what lands in the transcript.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cancelGoalTool(args: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cancel_goal — user-initiated goal ABANDONMENT (distinct from complete_goal).
|
|
3
|
+
*
|
|
4
|
+
* complete_goal = "the goal is fully achieved, stop." cancel_goal = "the user
|
|
5
|
+
* explicitly asked to STOP pursuing this goal even though it isn't done." Both
|
|
6
|
+
* short-circuit the turn loop to a stop and clear the persisted goal so a later
|
|
7
|
+
* bare send won't re-inherit it — but cancel_goal is a controlled escape hatch,
|
|
8
|
+
* NOT a self-judgment the model may make on its own.
|
|
9
|
+
*
|
|
10
|
+
* "Strong intent" guard (the whole point of this tool): the model must NOT
|
|
11
|
+
* cancel a goal on its own initiative — only when the user has clearly asked to
|
|
12
|
+
* stop/abandon it. To make that hard to do accidentally, the schema REQUIRES:
|
|
13
|
+
* - confirm: true — an explicit boolean gate (a bare call is invalid)
|
|
14
|
+
* - reason: string — the user's own words / paraphrase of the request
|
|
15
|
+
* The turn loop only honors the cancellation when confirm === true; anything
|
|
16
|
+
* else records a refusal string and does NOT stop or clear the goal.
|
|
17
|
+
*
|
|
18
|
+
* Shape note: like complete_goal, this is a ToolDefinition + a separate executor
|
|
19
|
+
* returning a string. The loop-level short-circuit lives in turn-loop.ts and
|
|
20
|
+
* keys off CANCEL_GOAL_TOOL_NAME.
|
|
21
|
+
*/
|
|
22
|
+
/** Shared with turn-loop.ts's short-circuit check — the name lives in one place. */
|
|
23
|
+
export const CANCEL_GOAL_TOOL_NAME = "cancel_goal";
|
|
24
|
+
export const cancelGoalToolDef = {
|
|
25
|
+
name: CANCEL_GOAL_TOOL_NAME,
|
|
26
|
+
description: "取消(放弃)当前的持久目标。⚠️ 仅当用户明确要求停止/取消/放弃当前目标时才调用本工具;" +
|
|
27
|
+
"绝不要自行判断放弃目标(“目标太难”“暂时做不完”都不是取消理由——那种情况应继续或用 complete_goal)。" +
|
|
28
|
+
"必须传 confirm=true 并在 reason 里复述用户要求取消的原话/意图。调用后目标会被清除,agent 停止。\n" +
|
|
29
|
+
"Cancel (abandon) the current persistent goal. ⚠️ Call this ONLY when the user has EXPLICITLY asked to " +
|
|
30
|
+
"stop/cancel/abandon the goal. NEVER decide to abandon a goal on your own (a hard or unfinished goal is " +
|
|
31
|
+
"NOT a reason to cancel). You MUST pass confirm=true and put the user's own words/intent in `reason`. " +
|
|
32
|
+
"After calling, the goal is cleared and the agent stops.",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
confirm: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
description: "必须为 true 才会真正取消目标。缺省或 false 视为无效调用,不会取消。" +
|
|
39
|
+
"Must be true to actually cancel. Missing/false is treated as an invalid call and cancels nothing.",
|
|
40
|
+
},
|
|
41
|
+
reason: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "用户要求取消目标的原话或意图复述(必填)。Required: the user's own words / paraphrased request to cancel.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ["confirm", "reason"],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Executor. Returns a human-readable acknowledgement. The ACTUAL cancellation
|
|
51
|
+
* (stop + clear persisted goal) is enforced in turn-loop.ts, which re-checks
|
|
52
|
+
* confirm===true — this executor's string is only what lands in the transcript.
|
|
53
|
+
*/
|
|
54
|
+
export async function cancelGoalTool(args) {
|
|
55
|
+
const confirmed = args.confirm === true;
|
|
56
|
+
const reason = typeof args.reason === "string" ? args.reason.trim() : "";
|
|
57
|
+
if (!confirmed) {
|
|
58
|
+
return ("cancel_goal 未生效:confirm 必须为 true 且需说明用户要求取消的原因。" +
|
|
59
|
+
"(cancel_goal ignored: confirm must be true and a reason is required.)");
|
|
60
|
+
}
|
|
61
|
+
return reason
|
|
62
|
+
? `目标已按用户要求取消 (goal cancelled by user). Reason: ${reason}`
|
|
63
|
+
: "目标已按用户要求取消 (goal cancelled by user).";
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckQuota builtin — thin shell over the `quota/` module.
|
|
3
|
+
*
|
|
4
|
+
* Lets an orchestrating agent read how much CC/Codex quota is left before/while
|
|
5
|
+
* delegating work (DriveAgent), so it can plan: how many to spawn, whether to
|
|
6
|
+
* wait for a reset, or switch providers. See quota/index.ts for the sources.
|
|
7
|
+
*
|
|
8
|
+
* NOTE the cost asymmetry (surfaced in the description): Codex is a free GET;
|
|
9
|
+
* Claude costs ~1 output token because Anthropic only returns quota via
|
|
10
|
+
* response headers. So restrict with `provider` when you only need one.
|
|
11
|
+
*/
|
|
12
|
+
import type { ToolDefinition } from "../../types.js";
|
|
13
|
+
import type { ToolContext } from "../context.js";
|
|
14
|
+
export declare const checkQuotaToolDef: ToolDefinition;
|
|
15
|
+
export declare function checkQuotaTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { checkQuota, formatQuota } from "../../quota/index.js";
|
|
2
|
+
import { resolveQuotaCredentials } from "../../quota/credentials.js";
|
|
3
|
+
export const checkQuotaToolDef = {
|
|
4
|
+
name: "CheckQuota",
|
|
5
|
+
description: "Check remaining usage/rate-limit quota for the external coding-agent CLIs (Claude Code and/or " +
|
|
6
|
+
"Codex) — the same 5h/7d subscription windows their status lines show. Use before or during " +
|
|
7
|
+
"orchestration (DriveAgent) to plan how much work to hand off, whether to wait for a reset, or " +
|
|
8
|
+
"which provider to use. Returns each provider's 5h/7d used-% and reset time. " +
|
|
9
|
+
"COST: 'codex' is free (reads a usage endpoint). 'claude' costs ~1 token (Anthropic exposes " +
|
|
10
|
+
"quota only via a response header, so this sends a 1-token probe). Pass `provider` to query " +
|
|
11
|
+
"just one and avoid the other's cost/latency.",
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
provider: {
|
|
16
|
+
type: "string",
|
|
17
|
+
enum: ["claude", "codex", "both"],
|
|
18
|
+
description: "Which to check. 'both' (default) queries Claude Code and Codex. 'claude' sends a 1-token probe; 'codex' is free.",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: [],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export async function checkQuotaTool(args, ctx) {
|
|
25
|
+
const which = args.provider === "claude" ? ["claude"] : args.provider === "codex" ? ["codex"] : ["claude", "codex"];
|
|
26
|
+
const creds = await resolveQuotaCredentials();
|
|
27
|
+
const result = await checkQuota({
|
|
28
|
+
creds,
|
|
29
|
+
providers: which,
|
|
30
|
+
signal: ctx?.signal,
|
|
31
|
+
});
|
|
32
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
33
|
+
return formatQuota(result, nowSec);
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* complete_goal — Goal mode P0.
|
|
3
|
+
*
|
|
4
|
+
* The model calls this to explicitly DECLARE the current goal complete
|
|
5
|
+
* (mirrors Codex's update_goal(status=Complete)). When the turn loop sees
|
|
6
|
+
* this tool call it short-circuits to a "completed" stop WITHOUT running the
|
|
7
|
+
* judge LLM (wired in Task 4). This tool itself just records an
|
|
8
|
+
* acknowledgement string into the transcript; the loop-level short-circuit
|
|
9
|
+
* lives in turn-loop.ts.
|
|
10
|
+
*
|
|
11
|
+
* Shape note: builtin tools in this codebase are a `ToolDefinition`
|
|
12
|
+
* (name/description/inputSchema only — see types.ts) plus a separate executor
|
|
13
|
+
* `(args: Record<string, unknown>) => Promise<string>`. The runtime metadata
|
|
14
|
+
* (source/permissionDefault/isReadOnly/...) is attached in builtin/index.ts at
|
|
15
|
+
* registration time, NOT on the def. Registration is Task 6.
|
|
16
|
+
*/
|
|
17
|
+
import type { ToolDefinition } from "../../types.js";
|
|
18
|
+
/**
|
|
19
|
+
* The tool name, shared with turn-loop.ts's short-circuit check so a rename
|
|
20
|
+
* can't silently break completion detection (the name lives in exactly one
|
|
21
|
+
* place).
|
|
22
|
+
*/
|
|
23
|
+
export declare const COMPLETE_GOAL_TOOL_NAME = "complete_goal";
|
|
24
|
+
export declare const completeGoalToolDef: ToolDefinition;
|
|
25
|
+
export declare function completeGoalTool(args: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* complete_goal — Goal mode P0.
|
|
3
|
+
*
|
|
4
|
+
* The model calls this to explicitly DECLARE the current goal complete
|
|
5
|
+
* (mirrors Codex's update_goal(status=Complete)). When the turn loop sees
|
|
6
|
+
* this tool call it short-circuits to a "completed" stop WITHOUT running the
|
|
7
|
+
* judge LLM (wired in Task 4). This tool itself just records an
|
|
8
|
+
* acknowledgement string into the transcript; the loop-level short-circuit
|
|
9
|
+
* lives in turn-loop.ts.
|
|
10
|
+
*
|
|
11
|
+
* Shape note: builtin tools in this codebase are a `ToolDefinition`
|
|
12
|
+
* (name/description/inputSchema only — see types.ts) plus a separate executor
|
|
13
|
+
* `(args: Record<string, unknown>) => Promise<string>`. The runtime metadata
|
|
14
|
+
* (source/permissionDefault/isReadOnly/...) is attached in builtin/index.ts at
|
|
15
|
+
* registration time, NOT on the def. Registration is Task 6.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The tool name, shared with turn-loop.ts's short-circuit check so a rename
|
|
19
|
+
* can't silently break completion detection (the name lives in exactly one
|
|
20
|
+
* place).
|
|
21
|
+
*/
|
|
22
|
+
export const COMPLETE_GOAL_TOOL_NAME = "complete_goal";
|
|
23
|
+
export const completeGoalToolDef = {
|
|
24
|
+
name: COMPLETE_GOAL_TOOL_NAME,
|
|
25
|
+
description: "声明当前目标已完全达成。仅当目标确实完整完成时才调用本工具(模型在目标完全达成时显式调用以声明完成)。" +
|
|
26
|
+
"调用后应当停止。可选传入 summary 作为一句话完成总结。\n" +
|
|
27
|
+
"Declare the current goal complete. Call this ONLY when the goal is fully achieved. " +
|
|
28
|
+
"After calling, you should stop. Optionally pass a one-line summary of what was accomplished.",
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
summary: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "可选:一句话总结所完成的工作。Optional one-line summary of what was accomplished.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: [],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export async function completeGoalTool(args) {
|
|
41
|
+
const summary = typeof args.summary === "string" ? args.summary.trim() : "";
|
|
42
|
+
return summary
|
|
43
|
+
? `目标已完成 (goal complete). Summary: ${summary}`
|
|
44
|
+
: "目标已完成 (goal complete).";
|
|
45
|
+
}
|
|
@@ -59,6 +59,13 @@ export async function configTool(args) {
|
|
|
59
59
|
obj = obj[parts[i]];
|
|
60
60
|
}
|
|
61
61
|
obj[parts[parts.length - 1]] = value;
|
|
62
|
+
// Never resurrect a deleted project root: a recursive mkdir of
|
|
63
|
+
// <cwd>/.code-shell would recreate `cwd` itself as an empty shell when the
|
|
64
|
+
// directory has been deleted (e.g. a stale session pointing at a removed
|
|
65
|
+
// dir). If the project root is gone, the project is gone — don't write.
|
|
66
|
+
if (!existsSync(cwd)) {
|
|
67
|
+
return `Error: project directory does not exist: ${cwd}`;
|
|
68
|
+
}
|
|
62
69
|
mkdirSync(join(cwd, ".code-shell"), { recursive: true });
|
|
63
70
|
writeFileSync(configPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
64
71
|
return `Updated ${key} = ${JSON.stringify(value)}`;
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
* Cron tools — CronCreate, CronDelete, CronList.
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolDefinition } from "../../types.js";
|
|
5
|
+
/** Sink notified after a cron job is created/deleted, so the host (Electron
|
|
6
|
+
* main) can reload+arm the scheduler that actually executes jobs. The worker
|
|
7
|
+
* process only persists cron jobs (executionEnabled=false); without this the
|
|
8
|
+
* host never learns about an AI-created job until the user opens the UI. */
|
|
9
|
+
type CronChangedSink = () => void;
|
|
10
|
+
export declare function setCronChangedSink(sink: CronChangedSink | null): void;
|
|
5
11
|
export declare const cronCreateToolDef: ToolDefinition;
|
|
6
12
|
export declare function cronCreateTool(args: Record<string, unknown>): Promise<string>;
|
|
7
13
|
export declare const cronDeleteToolDef: ToolDefinition;
|
|
8
14
|
export declare function cronDeleteTool(args: Record<string, unknown>): Promise<string>;
|
|
9
15
|
export declare const cronListToolDef: ToolDefinition;
|
|
10
16
|
export declare function cronListTool(_args: Record<string, unknown>): Promise<string>;
|
|
17
|
+
export {};
|