@cjhyy/code-shell-core 0.5.0-rc.2 → 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 +3 -0
- package/dist/agent/agent-definition-registry.js +3 -1
- package/dist/agent/agent-definition.d.ts +15 -0
- package/dist/agent/agent-definition.js +27 -3
- package/dist/arena/context/context-tools.js +47 -4
- package/dist/arena/ledger.js +9 -1
- package/dist/arena/strategies/utils.d.ts +1 -4
- package/dist/arena/strategies/utils.js +7 -84
- package/dist/automation/cron-expr.d.ts +10 -0
- package/dist/automation/cron-expr.js +23 -5
- package/dist/automation/runner.d.ts +21 -4
- package/dist/automation/runner.js +48 -12
- package/dist/automation/scheduler.d.ts +38 -0
- package/dist/automation/scheduler.js +89 -12
- package/dist/automation/store.js +5 -2
- package/dist/capability-control/disabled-lists.d.ts +25 -0
- package/dist/capability-control/disabled-lists.js +57 -0
- package/dist/capability-control/overlay.d.ts +15 -0
- package/dist/capability-control/overlay.js +27 -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 +15 -1
- package/dist/cli/agent-server-stdio.js +115 -17
- package/dist/cli/agent-server-tcp.js +40 -26
- package/dist/context/compaction.d.ts +56 -0
- package/dist/context/compaction.js +186 -0
- package/dist/context/manager.js +25 -4
- 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/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/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 +267 -138
- package/dist/engine/engine.js +957 -191
- package/dist/engine/friendly-error.d.ts +18 -0
- package/dist/engine/friendly-error.js +63 -0
- package/dist/engine/goal.d.ts +145 -0
- package/dist/engine/goal.js +144 -0
- package/dist/engine/image-policy.d.ts +13 -0
- package/dist/engine/image-policy.js +24 -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/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.js +2 -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-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 +67 -3
- package/dist/engine/turn-loop.js +292 -41
- 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/utils.js +11 -6
- package/dist/git/worktree.d.ts +48 -0
- package/dist/git/worktree.js +86 -10
- package/dist/hooks/goal-stop-hook.d.ts +28 -0
- package/dist/hooks/goal-stop-hook.js +186 -9
- package/dist/hooks/registry.d.ts +8 -0
- package/dist/hooks/registry.js +19 -0
- package/dist/hooks/shell-runner.js +10 -21
- package/dist/index.d.ts +49 -6
- package/dist/index.js +60 -4
- package/dist/llm/capabilities/param-specs.d.ts +14 -0
- package/dist/llm/capabilities/param-specs.js +62 -0
- package/dist/llm/capabilities/rules.js +4 -0
- package/dist/llm/capabilities/types.d.ts +10 -0
- package/dist/llm/client-base.d.ts +28 -1
- package/dist/llm/client-base.js +119 -13
- package/dist/llm/model-cache.js +4 -2
- package/dist/llm/model-pool.d.ts +14 -0
- package/dist/llm/model-pool.js +13 -0
- package/dist/llm/provider-auth.d.ts +41 -0
- package/dist/llm/provider-auth.js +76 -0
- package/dist/llm/provider-catalog.d.ts +4 -0
- package/dist/llm/providers/anthropic.js +64 -14
- package/dist/llm/providers/openai.d.ts +36 -0
- package/dist/llm/providers/openai.js +257 -51
- package/dist/llm/reasoning-setting.d.ts +3 -3
- package/dist/llm/reasoning-setting.js +9 -1
- package/dist/llm/stream-watchdog.js +5 -1
- package/dist/llm/token-counter.js +9 -2
- package/dist/llm/types.d.ts +4 -0
- package/dist/logging/sanitize-messages.js +22 -0
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +40 -10
- 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 +61 -326
- package/dist/plugins/gitOps.d.ts +19 -0
- package/dist/plugins/gitOps.js +73 -4
- package/dist/plugins/installer/checkUpdate.d.ts +16 -0
- package/dist/plugins/installer/checkUpdate.js +32 -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 +5 -2
- package/dist/plugins/installer/codex/convertMcp.js +45 -5
- package/dist/plugins/installer/install.js +25 -1
- package/dist/plugins/installer/installFromArchive.d.ts +43 -0
- package/dist/plugins/installer/installFromArchive.js +134 -0
- package/dist/plugins/installer/installFromSource.js +8 -2
- package/dist/plugins/installer/loadPluginAgents.js +6 -2
- package/dist/plugins/installer/loadPluginMcp.d.ts +9 -2
- package/dist/plugins/installer/loadPluginMcp.js +35 -2
- package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
- package/dist/plugins/installer/pruneDisabled.js +73 -0
- package/dist/plugins/installer/types.d.ts +5 -2
- package/dist/plugins/installer/types.js +1 -0
- package/dist/plugins/installer/uninstall.js +4 -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 +14 -0
- package/dist/plugins/installer/update.js +53 -21
- package/dist/plugins/loadPluginHooks.d.ts +47 -1
- package/dist/plugins/loadPluginHooks.js +73 -1
- package/dist/plugins/marketplaceManager.d.ts +7 -0
- package/dist/plugins/marketplaceManager.js +20 -0
- package/dist/plugins/pluginCommandHook.js +4 -18
- package/dist/plugins/pluginContent.d.ts +30 -0
- package/dist/plugins/pluginContent.js +83 -0
- package/dist/plugins/pluginInstaller.d.ts +13 -0
- package/dist/plugins/pluginInstaller.js +42 -8
- package/dist/plugins/schemas.js +1 -0
- package/dist/plugins/types.d.ts +6 -0
- package/dist/preset/index.d.ts +7 -1
- package/dist/preset/index.js +96 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +27 -0
- package/dist/prompt/composer.js +67 -21
- 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/protocol/chat-session-manager.d.ts +8 -2
- package/dist/protocol/chat-session-manager.js +36 -0
- package/dist/protocol/chat-session.d.ts +65 -0
- package/dist/protocol/chat-session.js +94 -2
- package/dist/protocol/client.d.ts +27 -0
- package/dist/protocol/client.js +38 -0
- package/dist/protocol/server.d.ts +112 -0
- package/dist/protocol/server.js +586 -16
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +46 -0
- package/dist/protocol/types.js +16 -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/review/review-prompt.d.ts +28 -0
- package/dist/review/review-prompt.js +81 -0
- package/dist/run/FileRunStore.js +8 -3
- package/dist/run/RunApprovalBackend.js +25 -5
- package/dist/run/RunManager.d.ts +12 -0
- package/dist/run/RunManager.js +35 -0
- package/dist/run/factory.d.ts +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/diagnostics.d.ts +1 -2
- package/dist/services/diagnostics.js +12 -7
- 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 -50
- package/dist/services/session-memory.js +24 -12
- package/dist/session/file-history.d.ts +124 -1
- package/dist/session/file-history.js +222 -6
- package/dist/session/memory.d.ts +116 -2
- package/dist/session/memory.js +250 -28
- package/dist/session/session-manager.d.ts +40 -0
- package/dist/session/session-manager.js +113 -3
- 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 +9 -2
- package/dist/settings/disk-defaults.js +11 -2
- package/dist/settings/feature-flags.d.ts +64 -0
- package/dist/settings/feature-flags.js +61 -0
- package/dist/settings/manager.d.ts +68 -1
- package/dist/settings/manager.js +266 -29
- package/dist/settings/migrate-config.d.ts +45 -0
- package/dist/settings/migrate-config.js +125 -0
- package/dist/settings/schema-export.d.ts +25 -0
- package/dist/settings/schema-export.js +38 -0
- package/dist/settings/schema.d.ts +1186 -771
- package/dist/settings/schema.js +268 -97
- 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/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 +12 -0
- package/dist/tool-system/builtin/agent-registry.js +8 -0
- package/dist/tool-system/builtin/agent.d.ts +21 -1
- package/dist/tool-system/builtin/agent.js +489 -42
- 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 +0 -15
- 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/config.js +7 -0
- package/dist/tool-system/builtin/cron.d.ts +7 -0
- package/dist/tool-system/builtin/cron.js +55 -3
- 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.js +20 -16
- 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 +35 -0
- package/dist/tool-system/builtin/generate-image.js +278 -50
- 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/glob.js +0 -7
- package/dist/tool-system/builtin/grep.js +6 -8
- 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 +7 -1
- package/dist/tool-system/builtin/index.js +249 -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.js +0 -7
- package/dist/tool-system/builtin/powershell.js +4 -1
- package/dist/tool-system/builtin/read.js +10 -10
- 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 +3 -2
- package/dist/tool-system/builtin/tool-search.js +25 -7
- 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/web-fetch.js +12 -2
- package/dist/tool-system/builtin/web-search.js +21 -7
- 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.js +0 -6
- package/dist/tool-system/context.d.ts +154 -6
- package/dist/tool-system/executor.d.ts +3 -1
- package/dist/tool-system/executor.js +172 -88
- package/dist/tool-system/investigation-guard.js +1 -1
- package/dist/tool-system/mcp-manager.d.ts +42 -4
- package/dist/tool-system/mcp-manager.js +186 -20
- package/dist/tool-system/path-policy.d.ts +5 -0
- package/dist/tool-system/path-policy.js +307 -8
- package/dist/tool-system/permission.d.ts +36 -1
- package/dist/tool-system/permission.js +281 -69
- package/dist/tool-system/plan-mode-allowlist.d.ts +13 -2
- package/dist/tool-system/plan-mode-allowlist.js +24 -2
- package/dist/tool-system/registry.d.ts +1 -0
- package/dist/tool-system/registry.js +16 -2
- 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/types.d.ts +217 -6
- 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/json.d.ts +12 -0
- package/dist/utils/json.js +92 -0
- package/dist/utils/theme.d.ts +1 -1
- package/dist/utils/theme.js +1 -1
- package/dist/utils/toolDisplay.js +0 -1
- package/package.json +13 -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
|
@@ -6,6 +6,36 @@
|
|
|
6
6
|
import type { Tool as McpTool } from "@modelcontextprotocol/sdk/types.js";
|
|
7
7
|
import type { MCPServerConfig, RegisteredTool } from "../types.js";
|
|
8
8
|
import { ToolRegistry } from "./registry.js";
|
|
9
|
+
/**
|
|
10
|
+
* Read a required secret from `process.env` by NAME (Codex-style env-secret
|
|
11
|
+
* handling — the value is never persisted in MCP config). A referenced env var
|
|
12
|
+
* that is undefined OR empty string is treated as missing so the connection
|
|
13
|
+
* fails with a clear, actionable error naming the server, the config field,
|
|
14
|
+
* and the env var.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readRequiredEnv(serverName: string, field: string, envName: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build the spawned stdio server's environment. Priority (lowest → highest):
|
|
19
|
+
* a minimal inherited allowlist < forwarded `envVars` (read from process.env by
|
|
20
|
+
* name) < explicit plaintext `config.env`. Returns `undefined` when neither
|
|
21
|
+
* `env` nor `envVars` is present, preserving the old "inherit nothing extra"
|
|
22
|
+
* behavior (transport gets `env: undefined`). Pure + exported for unit testing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildStdioEnv(serverName: string, config: MCPServerConfig): Record<string, string> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Build the HTTP transport's request headers. Static `config.headers` form the
|
|
27
|
+
* base; env-sourced secrets (`bearerTokenEnvVar`, `envHeaders`) layer on top
|
|
28
|
+
* and win on conflict. Pure + exported for unit testing.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildHttpHeaders(serverName: string, config: MCPServerConfig, resolveCredential?: (id: string) => string | undefined): Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Infer the transport when the config doesn't name one: a url-only entry is
|
|
33
|
+
* HTTP, everything else stdio. This is the CC `.mcp.json` convention —
|
|
34
|
+
* plugin-bundled servers commonly write just `{ "url": "..." }`, and the old
|
|
35
|
+
* blind `?? "stdio"` default then failed them with "command is required for
|
|
36
|
+
* stdio transport" despite a perfectly good url. Pure + exported for testing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function inferTransportType(config: MCPServerConfig): NonNullable<MCPServerConfig["transport"]>;
|
|
9
39
|
/**
|
|
10
40
|
* Persist an MCP-returned image to disk and return the textual
|
|
11
41
|
* reference the LLM should see. Images larger than
|
|
@@ -27,6 +57,8 @@ export declare class MCPManager {
|
|
|
27
57
|
private readonly toolRegistry;
|
|
28
58
|
private static instance;
|
|
29
59
|
private connections;
|
|
60
|
+
private registeredToolsByServer;
|
|
61
|
+
private desiredServerNames;
|
|
30
62
|
/**
|
|
31
63
|
* In-flight connect()s keyed by server name. When the broadcast config
|
|
32
64
|
* reload (server.ts forEachSession → every session's refreshRuntimeConfig)
|
|
@@ -39,12 +71,17 @@ export declare class MCPManager {
|
|
|
39
71
|
* connect can be retried later.
|
|
40
72
|
*/
|
|
41
73
|
private connecting;
|
|
74
|
+
/** Per-owner (engine) desired server sets — see reconcile()'s shared-pool note. */
|
|
75
|
+
private desiredByOwner;
|
|
42
76
|
constructor(toolRegistry: ToolRegistry);
|
|
43
77
|
static getInstance(): MCPManager;
|
|
44
78
|
/**
|
|
45
79
|
* Connect to all configured MCP servers and register their tools.
|
|
46
80
|
*/
|
|
47
|
-
connectAll(servers: Record<string, MCPServerConfig
|
|
81
|
+
connectAll(servers: Record<string, MCPServerConfig>, owner?: unknown): Promise<void>;
|
|
82
|
+
reconcile(servers: Record<string, MCPServerConfig>, owner?: unknown): Promise<void>;
|
|
83
|
+
/** Union of every registered owner's desired set; null when none registered. */
|
|
84
|
+
private unionDesired;
|
|
48
85
|
/**
|
|
49
86
|
* Connect to a single MCP server.
|
|
50
87
|
*
|
|
@@ -68,6 +105,7 @@ export declare class MCPManager {
|
|
|
68
105
|
* Disconnect all MCP servers.
|
|
69
106
|
*/
|
|
70
107
|
disconnectAll(): Promise<void>;
|
|
108
|
+
disconnect(name: string): Promise<void>;
|
|
71
109
|
/**
|
|
72
110
|
* List connected servers.
|
|
73
111
|
*/
|
|
@@ -75,11 +113,11 @@ export declare class MCPManager {
|
|
|
75
113
|
/**
|
|
76
114
|
* Call a tool on a specific MCP server.
|
|
77
115
|
*/
|
|
78
|
-
callTool(serverName: string, toolName: string, args: Record<string, unknown
|
|
116
|
+
callTool(serverName: string, toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<unknown>;
|
|
79
117
|
/**
|
|
80
118
|
* List resources from MCP servers.
|
|
81
119
|
*/
|
|
82
|
-
listResources(serverName?: string): Promise<Array<{
|
|
120
|
+
listResources(serverName?: string, signal?: AbortSignal): Promise<Array<{
|
|
83
121
|
uri: string;
|
|
84
122
|
name: string;
|
|
85
123
|
description?: string;
|
|
@@ -87,5 +125,5 @@ export declare class MCPManager {
|
|
|
87
125
|
/**
|
|
88
126
|
* Read a resource from an MCP server.
|
|
89
127
|
*/
|
|
90
|
-
readResource(serverName: string, uri: string): Promise<string>;
|
|
128
|
+
readResource(serverName: string, uri: string, signal?: AbortSignal): Promise<string>;
|
|
91
129
|
}
|
|
@@ -7,8 +7,97 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
7
7
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
8
8
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
9
9
|
import { logger } from "../logging/logger.js";
|
|
10
|
+
import { CredentialStore } from "../credentials/index.js";
|
|
11
|
+
import { ENV_ALLOWLIST } from "../runtime/spawn-common.js";
|
|
10
12
|
import { writeFile, mkdir } from "node:fs/promises";
|
|
11
13
|
import { join } from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* Read a required secret from `process.env` by NAME (Codex-style env-secret
|
|
16
|
+
* handling — the value is never persisted in MCP config). A referenced env var
|
|
17
|
+
* that is undefined OR empty string is treated as missing so the connection
|
|
18
|
+
* fails with a clear, actionable error naming the server, the config field,
|
|
19
|
+
* and the env var.
|
|
20
|
+
*/
|
|
21
|
+
export function readRequiredEnv(serverName, field, envName) {
|
|
22
|
+
const v = process.env[envName];
|
|
23
|
+
if (v === undefined || v === "") {
|
|
24
|
+
throw new Error(`MCP server "${serverName}": env var "${envName}" (from ${field}) is not set`);
|
|
25
|
+
}
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Minimal set of host env vars a spawned stdio MCP server inherits by default.
|
|
30
|
+
* Allowlist, not blacklist — aligned with CC/Codex's env-secret-by-name model:
|
|
31
|
+
* a server gets only the runtime basics (PATH/HOME/LANG/…), and ANYTHING else
|
|
32
|
+
* it needs (an API key, a custom config dir) must be declared explicitly via
|
|
33
|
+
* `envVars` (forward by name) or `config.env` (literal). This avoids the
|
|
34
|
+
* fragile "guess which key looks like a secret" regex and its two failure
|
|
35
|
+
* modes (a bespoke key name leaks; a benign `FOO_TOKENIZER` gets stripped).
|
|
36
|
+
*
|
|
37
|
+
* Reuses the sandboxed-shell {@link ENV_ALLOWLIST} so the two spawn paths share
|
|
38
|
+
* one source of truth for "what's safe to forward".
|
|
39
|
+
*/
|
|
40
|
+
function inheritAllowlistedEnv(source) {
|
|
41
|
+
const out = {};
|
|
42
|
+
for (const name of ENV_ALLOWLIST) {
|
|
43
|
+
const v = source[name];
|
|
44
|
+
if (v !== undefined)
|
|
45
|
+
out[name] = v;
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build the spawned stdio server's environment. Priority (lowest → highest):
|
|
51
|
+
* a minimal inherited allowlist < forwarded `envVars` (read from process.env by
|
|
52
|
+
* name) < explicit plaintext `config.env`. Returns `undefined` when neither
|
|
53
|
+
* `env` nor `envVars` is present, preserving the old "inherit nothing extra"
|
|
54
|
+
* behavior (transport gets `env: undefined`). Pure + exported for unit testing.
|
|
55
|
+
*/
|
|
56
|
+
export function buildStdioEnv(serverName, config) {
|
|
57
|
+
if (!config.env && !config.envVars?.length)
|
|
58
|
+
return undefined;
|
|
59
|
+
const forwarded = {};
|
|
60
|
+
for (const en of config.envVars ?? []) {
|
|
61
|
+
forwarded[en] = readRequiredEnv(serverName, "envVars", en);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...inheritAllowlistedEnv(process.env),
|
|
65
|
+
...forwarded,
|
|
66
|
+
...(config.env ?? {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build the HTTP transport's request headers. Static `config.headers` form the
|
|
71
|
+
* base; env-sourced secrets (`bearerTokenEnvVar`, `envHeaders`) layer on top
|
|
72
|
+
* and win on conflict. Pure + exported for unit testing.
|
|
73
|
+
*/
|
|
74
|
+
export function buildHttpHeaders(serverName, config, resolveCredential) {
|
|
75
|
+
const headers = { ...(config.headers ?? {}) };
|
|
76
|
+
if (config.credentialRef) {
|
|
77
|
+
const secret = resolveCredential?.(config.credentialRef);
|
|
78
|
+
if (secret === undefined || secret === "") {
|
|
79
|
+
throw new Error(`MCP server "${serverName}": credential "${config.credentialRef}" not found or empty`);
|
|
80
|
+
}
|
|
81
|
+
headers["Authorization"] = `Bearer ${secret}`;
|
|
82
|
+
}
|
|
83
|
+
else if (config.bearerTokenEnvVar) {
|
|
84
|
+
headers["Authorization"] = `Bearer ${readRequiredEnv(serverName, "bearerTokenEnvVar", config.bearerTokenEnvVar)}`;
|
|
85
|
+
}
|
|
86
|
+
for (const [hName, envName] of Object.entries(config.envHeaders ?? {})) {
|
|
87
|
+
headers[hName] = readRequiredEnv(serverName, "envHeaders", envName);
|
|
88
|
+
}
|
|
89
|
+
return headers;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Infer the transport when the config doesn't name one: a url-only entry is
|
|
93
|
+
* HTTP, everything else stdio. This is the CC `.mcp.json` convention —
|
|
94
|
+
* plugin-bundled servers commonly write just `{ "url": "..." }`, and the old
|
|
95
|
+
* blind `?? "stdio"` default then failed them with "command is required for
|
|
96
|
+
* stdio transport" despite a perfectly good url. Pure + exported for testing.
|
|
97
|
+
*/
|
|
98
|
+
export function inferTransportType(config) {
|
|
99
|
+
return config.transport ?? (config.url && !config.command ? "streamable-http" : "stdio");
|
|
100
|
+
}
|
|
12
101
|
/**
|
|
13
102
|
* Wrap raw MCP server output with an explicit untrusted-content marker
|
|
14
103
|
* before it reaches the LLM. The wrapper does two things:
|
|
@@ -87,7 +176,9 @@ export function wrapMcpOutput(serverName, toolName, body) {
|
|
|
87
176
|
].join("\n");
|
|
88
177
|
}
|
|
89
178
|
export function stripInternalToolArgs(args) {
|
|
90
|
-
|
|
179
|
+
// Drop executor-injected internal fields so they never reach the MCP server as
|
|
180
|
+
// tool arguments: __signal (abort) and __allowedMcpServers (auth allowlist).
|
|
181
|
+
const { __signal: _signal, __allowedMcpServers: _allowed, ...toolArgs } = args;
|
|
91
182
|
return toolArgs;
|
|
92
183
|
}
|
|
93
184
|
/**
|
|
@@ -125,6 +216,8 @@ export class MCPManager {
|
|
|
125
216
|
toolRegistry;
|
|
126
217
|
static instance = null;
|
|
127
218
|
connections = new Map();
|
|
219
|
+
registeredToolsByServer = new Map();
|
|
220
|
+
desiredServerNames = null;
|
|
128
221
|
/**
|
|
129
222
|
* In-flight connect()s keyed by server name. When the broadcast config
|
|
130
223
|
* reload (server.ts forEachSession → every session's refreshRuntimeConfig)
|
|
@@ -137,6 +230,8 @@ export class MCPManager {
|
|
|
137
230
|
* connect can be retried later.
|
|
138
231
|
*/
|
|
139
232
|
connecting = new Map();
|
|
233
|
+
/** Per-owner (engine) desired server sets — see reconcile()'s shared-pool note. */
|
|
234
|
+
desiredByOwner = new Map();
|
|
140
235
|
constructor(toolRegistry) {
|
|
141
236
|
this.toolRegistry = toolRegistry;
|
|
142
237
|
MCPManager.instance = this;
|
|
@@ -150,7 +245,15 @@ export class MCPManager {
|
|
|
150
245
|
/**
|
|
151
246
|
* Connect to all configured MCP servers and register their tools.
|
|
152
247
|
*/
|
|
153
|
-
async connectAll(servers) {
|
|
248
|
+
async connectAll(servers, owner) {
|
|
249
|
+
// Register this owner's desired set up front (see reconcile's shared-pool
|
|
250
|
+
// note) so a later reconcile from ANOTHER session can't disconnect servers
|
|
251
|
+
// this session connected at run start.
|
|
252
|
+
if (owner !== undefined) {
|
|
253
|
+
this.desiredByOwner.set(owner, new Set(Object.entries(servers)
|
|
254
|
+
.filter(([, c]) => c.enabled !== false)
|
|
255
|
+
.map(([n]) => n)));
|
|
256
|
+
}
|
|
154
257
|
// Codex-style toggle: skip servers explicitly disabled in settings.
|
|
155
258
|
// Only the literal `false` disables — absent / true / any other value
|
|
156
259
|
// stays connected, matching the schema default semantics.
|
|
@@ -174,6 +277,37 @@ export class MCPManager {
|
|
|
174
277
|
}
|
|
175
278
|
}
|
|
176
279
|
}
|
|
280
|
+
async reconcile(servers, owner) {
|
|
281
|
+
const enabledNames = new Set(Object.entries(servers)
|
|
282
|
+
.filter(([, config]) => config.enabled !== false)
|
|
283
|
+
.map(([name]) => name));
|
|
284
|
+
this.desiredServerNames = enabledNames;
|
|
285
|
+
// Shared-pool semantics: this ONE pool serves every session in the worker,
|
|
286
|
+
// and sessions in different projects legitimately want DIFFERENT server
|
|
287
|
+
// sets (per-project capabilityOverrides). Disconnect only servers that NO
|
|
288
|
+
// registered owner wants — otherwise the per-session hot-reload patches
|
|
289
|
+
// would thrash each other's connections (last reconcile wins, killing a
|
|
290
|
+
// server another project's session is using). Owners are engines; a
|
|
291
|
+
// closed session's desires linger (no engine-teardown hook), which merely
|
|
292
|
+
// over-RETAINS idle connections — per-session tool visibility keeps
|
|
293
|
+
// correctness regardless.
|
|
294
|
+
if (owner !== undefined)
|
|
295
|
+
this.desiredByOwner.set(owner, enabledNames);
|
|
296
|
+
const union = this.unionDesired() ?? enabledNames;
|
|
297
|
+
const stale = this.listServers().filter((name) => !union.has(name));
|
|
298
|
+
await Promise.all(stale.map((name) => this.disconnect(name)));
|
|
299
|
+
await this.connectAll(servers, owner);
|
|
300
|
+
}
|
|
301
|
+
/** Union of every registered owner's desired set; null when none registered. */
|
|
302
|
+
unionDesired() {
|
|
303
|
+
if (this.desiredByOwner.size === 0)
|
|
304
|
+
return null;
|
|
305
|
+
const u = new Set();
|
|
306
|
+
for (const names of this.desiredByOwner.values())
|
|
307
|
+
for (const n of names)
|
|
308
|
+
u.add(n);
|
|
309
|
+
return u;
|
|
310
|
+
}
|
|
177
311
|
/**
|
|
178
312
|
* Connect to a single MCP server.
|
|
179
313
|
*
|
|
@@ -208,10 +342,10 @@ export class MCPManager {
|
|
|
208
342
|
logger.info("mcp.already_connected", { server: name });
|
|
209
343
|
return;
|
|
210
344
|
}
|
|
211
|
-
|
|
345
|
+
const transportType = inferTransportType(config);
|
|
346
|
+
logger.info("mcp.connecting", { server: name, transport: transportType });
|
|
212
347
|
const client = new Client({ name: "code-shell", version: "0.1.0" }, { capabilities: {} });
|
|
213
348
|
let transport;
|
|
214
|
-
const transportType = config.transport ?? "stdio";
|
|
215
349
|
if (transportType === "stdio") {
|
|
216
350
|
if (!config.command) {
|
|
217
351
|
throw new Error(`MCP server "${name}": command is required for stdio transport`);
|
|
@@ -219,15 +353,21 @@ export class MCPManager {
|
|
|
219
353
|
transport = new StdioClientTransport({
|
|
220
354
|
command: config.command,
|
|
221
355
|
args: config.args,
|
|
222
|
-
env:
|
|
356
|
+
env: buildStdioEnv(name, config),
|
|
223
357
|
});
|
|
224
358
|
}
|
|
225
359
|
else if (transportType === "streamable-http" || transportType === "sse") {
|
|
226
360
|
if (!config.url) {
|
|
227
361
|
throw new Error(`MCP server "${name}": url is required for ${transportType} transport`);
|
|
228
362
|
}
|
|
363
|
+
// credentialRef resolves against the user-scope CredentialStore. The
|
|
364
|
+
// shared MCPManager pool has no per-session cwd (see desiredByOwner note),
|
|
365
|
+
// and MCP-referenced credentials (e.g. a Figma token) are user-global by
|
|
366
|
+
// nature, so user scope is the right resolution surface here.
|
|
367
|
+
const credStore = new CredentialStore(undefined);
|
|
368
|
+
const headers = buildHttpHeaders(name, config, (id) => credStore.resolve(id)?.secret);
|
|
229
369
|
transport = new StreamableHTTPClientTransport(new URL(config.url), {
|
|
230
|
-
requestInit:
|
|
370
|
+
requestInit: Object.keys(headers).length ? { headers } : undefined,
|
|
231
371
|
});
|
|
232
372
|
}
|
|
233
373
|
else {
|
|
@@ -262,6 +402,10 @@ export class MCPManager {
|
|
|
262
402
|
this.connections.set(name, { client, serverName: name, transport });
|
|
263
403
|
// Discover and register tools
|
|
264
404
|
await this.discoverTools(name, client);
|
|
405
|
+
if (this.desiredServerNames && !this.desiredServerNames.has(name)) {
|
|
406
|
+
await this.disconnect(name);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
265
409
|
logger.info("mcp.connected", { server: name });
|
|
266
410
|
}
|
|
267
411
|
/**
|
|
@@ -317,6 +461,9 @@ export class MCPManager {
|
|
|
317
461
|
// strings can't fake their way out.
|
|
318
462
|
return wrapMcpOutput(serverName, tool.name, body);
|
|
319
463
|
});
|
|
464
|
+
const set = this.registeredToolsByServer.get(serverName) ?? new Set();
|
|
465
|
+
set.add(registered.name);
|
|
466
|
+
this.registeredToolsByServer.set(serverName, set);
|
|
320
467
|
logger.info("mcp.tool_registered", { server: serverName, tool: registered.name });
|
|
321
468
|
}
|
|
322
469
|
}
|
|
@@ -324,16 +471,27 @@ export class MCPManager {
|
|
|
324
471
|
* Disconnect all MCP servers.
|
|
325
472
|
*/
|
|
326
473
|
async disconnectAll() {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
474
|
+
await Promise.all([...this.connections.keys()].map((name) => this.disconnect(name)));
|
|
475
|
+
}
|
|
476
|
+
async disconnect(name) {
|
|
477
|
+
const conn = this.connections.get(name);
|
|
478
|
+
if (!conn)
|
|
479
|
+
return;
|
|
480
|
+
try {
|
|
481
|
+
await conn.client.close();
|
|
482
|
+
logger.info("mcp.disconnected", { server: name });
|
|
483
|
+
}
|
|
484
|
+
catch (err) {
|
|
485
|
+
logger.warn("mcp.disconnect_error", { server: name, error: err.message });
|
|
486
|
+
}
|
|
487
|
+
finally {
|
|
488
|
+
this.connections.delete(name);
|
|
489
|
+
for (const toolName of this.registeredToolsByServer.get(name) ?? []) {
|
|
490
|
+
this.toolRegistry.unregisterTool(toolName);
|
|
491
|
+
logger.info("mcp.tool_unregistered", { server: name, tool: toolName });
|
|
334
492
|
}
|
|
493
|
+
this.registeredToolsByServer.delete(name);
|
|
335
494
|
}
|
|
336
|
-
this.connections.clear();
|
|
337
495
|
}
|
|
338
496
|
/**
|
|
339
497
|
* List connected servers.
|
|
@@ -344,12 +502,15 @@ export class MCPManager {
|
|
|
344
502
|
/**
|
|
345
503
|
* Call a tool on a specific MCP server.
|
|
346
504
|
*/
|
|
347
|
-
async callTool(serverName, toolName, args) {
|
|
505
|
+
async callTool(serverName, toolName, args, signal) {
|
|
348
506
|
const conn = this.connections.get(serverName);
|
|
349
507
|
if (!conn) {
|
|
350
508
|
throw new Error(`MCP server "${serverName}" is not connected.`);
|
|
351
509
|
}
|
|
352
|
-
|
|
510
|
+
// Forward the run's abort signal so a user Stop cancels an in-flight MCP
|
|
511
|
+
// call promptly instead of blocking until the SDK's default request timeout.
|
|
512
|
+
// (The SDK still enforces its default timeout when no signal is provided.)
|
|
513
|
+
const result = await conn.client.callTool({ name: toolName, arguments: stripInternalToolArgs(args) }, undefined, signal ? { signal } : undefined);
|
|
353
514
|
const parts = [];
|
|
354
515
|
if (Array.isArray(result.content)) {
|
|
355
516
|
for (const item of result.content) {
|
|
@@ -367,7 +528,7 @@ export class MCPManager {
|
|
|
367
528
|
/**
|
|
368
529
|
* List resources from MCP servers.
|
|
369
530
|
*/
|
|
370
|
-
async listResources(serverName) {
|
|
531
|
+
async listResources(serverName, signal) {
|
|
371
532
|
const results = [];
|
|
372
533
|
const servers = serverName ? [serverName] : [...this.connections.keys()];
|
|
373
534
|
for (const name of servers) {
|
|
@@ -375,7 +536,10 @@ export class MCPManager {
|
|
|
375
536
|
if (!conn)
|
|
376
537
|
continue;
|
|
377
538
|
try {
|
|
378
|
-
|
|
539
|
+
// Forward the run's abort signal so a user Stop cancels promptly
|
|
540
|
+
// instead of waiting out the SDK's default request timeout (same as
|
|
541
|
+
// callTool). The SDK still enforces its default timeout when no signal.
|
|
542
|
+
const res = await conn.client.listResources(undefined, signal ? { signal } : undefined);
|
|
379
543
|
for (const r of res.resources) {
|
|
380
544
|
results.push({
|
|
381
545
|
uri: r.uri,
|
|
@@ -393,12 +557,14 @@ export class MCPManager {
|
|
|
393
557
|
/**
|
|
394
558
|
* Read a resource from an MCP server.
|
|
395
559
|
*/
|
|
396
|
-
async readResource(serverName, uri) {
|
|
560
|
+
async readResource(serverName, uri, signal) {
|
|
397
561
|
const conn = this.connections.get(serverName);
|
|
398
562
|
if (!conn) {
|
|
399
563
|
throw new Error(`MCP server "${serverName}" is not connected.`);
|
|
400
564
|
}
|
|
401
|
-
|
|
565
|
+
// Forward the run's abort signal so a user Stop cancels promptly (same as
|
|
566
|
+
// callTool); the SDK still enforces its default timeout when no signal.
|
|
567
|
+
const result = await conn.client.readResource({ uri }, signal ? { signal } : undefined);
|
|
402
568
|
const parts = [];
|
|
403
569
|
if (Array.isArray(result.contents)) {
|
|
404
570
|
for (const item of result.contents) {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* approval round-trip; it is not an authority to write anywhere on disk.
|
|
30
30
|
* Callers must consult classifyPath before honoring acceptEdits.
|
|
31
31
|
*/
|
|
32
|
+
import type { ToolContext } from "./context.js";
|
|
32
33
|
export type PathDecision = "allow" | "ask" | "deny";
|
|
33
34
|
export type PathOperation = "read" | "write";
|
|
34
35
|
export interface PathClassification {
|
|
@@ -48,6 +49,9 @@ export interface ClassifyOptions {
|
|
|
48
49
|
/** "read" or "write" — different defaults for sensitive paths. */
|
|
49
50
|
operation: PathOperation;
|
|
50
51
|
}
|
|
52
|
+
export type PathApprovalScope = "once" | "session" | "project";
|
|
53
|
+
/** Test seam: clear the in-memory session grants. */
|
|
54
|
+
export declare function _resetSessionPathGrants(): void;
|
|
51
55
|
/**
|
|
52
56
|
* Classify a file path against the workspace + sensitive-path policy.
|
|
53
57
|
*
|
|
@@ -86,6 +90,7 @@ export declare function classifyPath(rawPath: string, opts: ClassifyOptions): Pa
|
|
|
86
90
|
* remains the rollback knob for the LLM-driven path.
|
|
87
91
|
*/
|
|
88
92
|
export declare function enforcePathPolicy(filePath: string, operation: PathOperation, workspaceRoot?: string): string | null;
|
|
93
|
+
export declare function enforcePathPolicyWithApproval(filePath: string, operation: PathOperation, ctx?: ToolContext): Promise<string | null>;
|
|
89
94
|
/**
|
|
90
95
|
* Internal: reset the "disabled warning" latch. Tests flip the env var
|
|
91
96
|
* between cases and need each one to be able to re-trigger the warning.
|