@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration-time guard for tool path-policy metadata.
|
|
3
|
+
*
|
|
4
|
+
* A tool's `pathPolicy[].arg` names the input field that carries a file path
|
|
5
|
+
* (or, for apply_patch, the patch text). ToolExecutor reads `args[policy.arg]`
|
|
6
|
+
* to find the targets it must run through the path-permission layer. If that
|
|
7
|
+
* arg name is a typo (e.g. `"pat"` instead of `"path"`), the lookup yields
|
|
8
|
+
* `undefined`, the executor finds zero targets, and the tool runs with NO path
|
|
9
|
+
* protection and no error — a silent security failure (assessment §4.1).
|
|
10
|
+
*
|
|
11
|
+
* This validator catches that drift at registration time by asserting every
|
|
12
|
+
* declared `pathPolicy.arg` exists in the tool's `inputSchema.properties`.
|
|
13
|
+
*/
|
|
14
|
+
import type { RegisteredTool, ToolDefinition } from "../types.js";
|
|
15
|
+
/** A tool-shaped object carrying the fields this validator inspects. */
|
|
16
|
+
type ToolLike = Pick<RegisteredTool, "name" | "inputSchema"> & Partial<Pick<RegisteredTool, "pathPolicy">>;
|
|
17
|
+
export interface ToolMetadataIssue {
|
|
18
|
+
tool: string;
|
|
19
|
+
arg: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check a single tool's path-policy metadata against its schema. Returns one
|
|
24
|
+
* issue per `pathPolicy.arg` that is not a declared input property. Tools
|
|
25
|
+
* without a pathPolicy produce no issues.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findToolMetadataIssues(tool: ToolLike): ToolMetadataIssue[];
|
|
28
|
+
/**
|
|
29
|
+
* Assert a tool's path-policy metadata is consistent with its schema. Throws on
|
|
30
|
+
* the first drift. Call at registration time so a typo fails loud instead of
|
|
31
|
+
* silently disabling path protection.
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateToolMetadata(tool: ToolLike): void;
|
|
34
|
+
/** Validate a batch; returns every issue across all tools (does not throw). */
|
|
35
|
+
export declare function collectToolMetadataIssues(tools: ReadonlyArray<ToolLike | ToolDefinition>): ToolMetadataIssue[];
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration-time guard for tool path-policy metadata.
|
|
3
|
+
*
|
|
4
|
+
* A tool's `pathPolicy[].arg` names the input field that carries a file path
|
|
5
|
+
* (or, for apply_patch, the patch text). ToolExecutor reads `args[policy.arg]`
|
|
6
|
+
* to find the targets it must run through the path-permission layer. If that
|
|
7
|
+
* arg name is a typo (e.g. `"pat"` instead of `"path"`), the lookup yields
|
|
8
|
+
* `undefined`, the executor finds zero targets, and the tool runs with NO path
|
|
9
|
+
* protection and no error — a silent security failure (assessment §4.1).
|
|
10
|
+
*
|
|
11
|
+
* This validator catches that drift at registration time by asserting every
|
|
12
|
+
* declared `pathPolicy.arg` exists in the tool's `inputSchema.properties`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Return the set of property names declared in a JSON-schema-ish object's
|
|
16
|
+
* `properties`. Tolerant of missing/malformed schema (returns empty set), so a
|
|
17
|
+
* tool with no declared properties is treated as "declares nothing" rather
|
|
18
|
+
* than throwing — the caller decides how to react.
|
|
19
|
+
*/
|
|
20
|
+
function schemaPropertyNames(inputSchema) {
|
|
21
|
+
const props = inputSchema?.properties;
|
|
22
|
+
if (!props || typeof props !== "object")
|
|
23
|
+
return new Set();
|
|
24
|
+
return new Set(Object.keys(props));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check a single tool's path-policy metadata against its schema. Returns one
|
|
28
|
+
* issue per `pathPolicy.arg` that is not a declared input property. Tools
|
|
29
|
+
* without a pathPolicy produce no issues.
|
|
30
|
+
*/
|
|
31
|
+
export function findToolMetadataIssues(tool) {
|
|
32
|
+
const policies = tool.pathPolicy;
|
|
33
|
+
if (!policies || policies.length === 0)
|
|
34
|
+
return [];
|
|
35
|
+
const declared = schemaPropertyNames(tool.inputSchema);
|
|
36
|
+
const issues = [];
|
|
37
|
+
for (const policy of policies) {
|
|
38
|
+
if (!declared.has(policy.arg)) {
|
|
39
|
+
issues.push({
|
|
40
|
+
tool: tool.name,
|
|
41
|
+
arg: policy.arg,
|
|
42
|
+
reason: `pathPolicy.arg "${policy.arg}" is not a property of inputSchema (path-permission enforcement would silently no-op)`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return issues;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Assert a tool's path-policy metadata is consistent with its schema. Throws on
|
|
50
|
+
* the first drift. Call at registration time so a typo fails loud instead of
|
|
51
|
+
* silently disabling path protection.
|
|
52
|
+
*/
|
|
53
|
+
export function validateToolMetadata(tool) {
|
|
54
|
+
const issues = findToolMetadataIssues(tool);
|
|
55
|
+
if (issues.length > 0) {
|
|
56
|
+
const first = issues[0];
|
|
57
|
+
throw new Error(`Invalid tool metadata for "${first.tool}": ${first.reason}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Validate a batch; returns every issue across all tools (does not throw). */
|
|
61
|
+
export function collectToolMetadataIssues(tools) {
|
|
62
|
+
return tools.flatMap((t) => findToolMetadataIssues(t));
|
|
63
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core type definitions for the code-shell orchestration framework.
|
|
3
3
|
*/
|
|
4
|
+
import type { GoalConfig } from "./engine/goal.js";
|
|
4
5
|
export interface ContentBlock {
|
|
5
6
|
type: "text" | "tool_use" | "tool_result" | "image" | "reasoning";
|
|
6
7
|
text?: string;
|
|
@@ -52,8 +53,44 @@ export interface ToolResult {
|
|
|
52
53
|
contentBlocks?: ContentBlock[];
|
|
53
54
|
error?: string;
|
|
54
55
|
isError?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Set by tools that execute under the sandbox (Bash / background shell /
|
|
58
|
+
* worktree) so the UI can show whether THIS call was isolated. `backend`
|
|
59
|
+
* "off" means the command ran un-sandboxed (we surface it explicitly so the
|
|
60
|
+
* user sees "未隔离" rather than guessing from an absent badge); "seatbelt"
|
|
61
|
+
* / "bwrap" mean OS-level isolation applied. `network` is the policy that
|
|
62
|
+
* was in force (absent when off). Tools that don't touch the sandbox leave
|
|
63
|
+
* this undefined and the UI renders no badge.
|
|
64
|
+
*/
|
|
65
|
+
sandbox?: {
|
|
66
|
+
backend: "off" | "seatbelt" | "bwrap";
|
|
67
|
+
network?: "allow" | "deny";
|
|
68
|
+
};
|
|
55
69
|
}
|
|
56
70
|
export type ToolSource = "builtin" | "mcp";
|
|
71
|
+
export type ToolPathPolicyOperation = "read" | "write" | {
|
|
72
|
+
/** Argument whose value decides whether this invocation reads or writes. */
|
|
73
|
+
fromArg: string;
|
|
74
|
+
/** Values that classify the operation as a read. */
|
|
75
|
+
readValues?: string[];
|
|
76
|
+
/** Values that classify the operation as a write. */
|
|
77
|
+
writeValues?: string[];
|
|
78
|
+
/** Fallback when the argument is absent or does not match either list. */
|
|
79
|
+
default: "read" | "write";
|
|
80
|
+
};
|
|
81
|
+
export type ToolPathPolicy = {
|
|
82
|
+
kind: "arg";
|
|
83
|
+
/** Argument containing a file or directory path. */
|
|
84
|
+
arg: string;
|
|
85
|
+
operation: ToolPathPolicyOperation;
|
|
86
|
+
/** Use ctx.cwd when the argument is omitted. Useful for Glob/Grep roots. */
|
|
87
|
+
defaultToCwd?: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
kind: "apply_patch";
|
|
90
|
+
/** Argument containing the V4A patch text. */
|
|
91
|
+
arg: string;
|
|
92
|
+
operation: "write";
|
|
93
|
+
};
|
|
57
94
|
export interface RegisteredTool {
|
|
58
95
|
name: string;
|
|
59
96
|
description: string;
|
|
@@ -63,6 +100,18 @@ export interface RegisteredTool {
|
|
|
63
100
|
permissionDefault: PermissionDecision;
|
|
64
101
|
isConcurrencySafe?: boolean;
|
|
65
102
|
isReadOnly?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Declarative file-path safety metadata. ToolExecutor enforces this before
|
|
105
|
+
* dispatching the tool, so file access cannot depend on each tool handler
|
|
106
|
+
* remembering to call path-policy manually.
|
|
107
|
+
*/
|
|
108
|
+
pathPolicy?: ToolPathPolicy[];
|
|
109
|
+
/**
|
|
110
|
+
* Explicitly marks a path-looking tool as intentionally outside the file
|
|
111
|
+
* policy layer. Used by tests/audits so new file tools fail closed unless
|
|
112
|
+
* they either declare pathPolicy or document an exemption.
|
|
113
|
+
*/
|
|
114
|
+
pathPolicyExempt?: boolean;
|
|
66
115
|
/**
|
|
67
116
|
* Override the default tool execution timeout (ms).
|
|
68
117
|
* Falls back to DEFAULT_TOOL_TIMEOUT_MS (120s) if unset.
|
|
@@ -70,7 +119,7 @@ export interface RegisteredTool {
|
|
|
70
119
|
*/
|
|
71
120
|
timeoutMs?: number;
|
|
72
121
|
}
|
|
73
|
-
export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "turn_boundary" | "goal_progress" | "error";
|
|
122
|
+
export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "subagent" | "turn_boundary" | "goal_progress" | "turn_stopped" | "error";
|
|
74
123
|
export interface TranscriptEvent {
|
|
75
124
|
id: string;
|
|
76
125
|
type: TranscriptEventType;
|
|
@@ -98,6 +147,14 @@ export interface SessionState {
|
|
|
98
147
|
provider: string;
|
|
99
148
|
tokenUsage: TokenUsage;
|
|
100
149
|
turnCount: number;
|
|
150
|
+
/**
|
|
151
|
+
* Conversation-turn counter where ONE user message = one turn (incremented in
|
|
152
|
+
* engine.run before the message hits the LLM). Distinct from `turnCount`,
|
|
153
|
+
* which counts turn-loop iterations (a single user message can span many).
|
|
154
|
+
* Tags file-history snapshots so turn-level `/undo` can revert exactly what
|
|
155
|
+
* the last user message changed. Absent on legacy sessions → treated as 0.
|
|
156
|
+
*/
|
|
157
|
+
turnSeq?: number;
|
|
101
158
|
invokedSkills: string[];
|
|
102
159
|
/**
|
|
103
160
|
* Owning parent session for a sub-agent run; `null` explicitly marks a
|
|
@@ -114,8 +171,25 @@ export interface SessionState {
|
|
|
114
171
|
status: SessionStatus;
|
|
115
172
|
/** Short summary derived from the first user message */
|
|
116
173
|
summary?: string;
|
|
174
|
+
/**
|
|
175
|
+
* LLM-generated one-line title (auxModel, after the first turn). Distinct from
|
|
176
|
+
* `summary` (the raw first-message fallback). Persisted so the sidebar shows
|
|
177
|
+
* it after a localStorage wipe / disk rebuild — without this it lived only in
|
|
178
|
+
* the renderer's localStorage index and was lost on reset.
|
|
179
|
+
*/
|
|
180
|
+
title?: string;
|
|
117
181
|
/** Persisted cost tracking state (survives process restart). */
|
|
118
182
|
costState?: Record<string, unknown>;
|
|
183
|
+
/**
|
|
184
|
+
* Active persistent goal (CC `/goal` style). Set once, it survives across
|
|
185
|
+
* messages AND manual interrupts until the judge says it's met or the user
|
|
186
|
+
* clears it. Absent → no active goal. When a run supplies a new goal it
|
|
187
|
+
* REPLACES this (one active goal per session). The judge's `met` verdict and
|
|
188
|
+
* `agent/goalClear` both clear it. Persisted so it survives resume/refresh;
|
|
189
|
+
* on resume the objective carries over but the run-scoped turn/token/time
|
|
190
|
+
* baselines reset (matching CC). See engine.run goal-resolution.
|
|
191
|
+
*/
|
|
192
|
+
activeGoal?: GoalConfig;
|
|
119
193
|
}
|
|
120
194
|
export interface TokenUsage {
|
|
121
195
|
promptTokens: number;
|
|
@@ -168,11 +242,22 @@ export interface ApprovalRequest {
|
|
|
168
242
|
* survives restart for the current project. Not committed.
|
|
169
243
|
*/
|
|
170
244
|
export type ApprovalScope = "once" | "session" | "project";
|
|
245
|
+
/**
|
|
246
|
+
* Path granularity for a remembered file-tool grant (Write/Edit). Narrows the
|
|
247
|
+
* remembered rule so "allow Write src/foo.ts for this session" doesn't become
|
|
248
|
+
* "allow Write to ANY path".
|
|
249
|
+
* "file" — only this exact file
|
|
250
|
+
* "dir" — this file's directory and its subdirectories
|
|
251
|
+
* "tool" — every path (the legacy tool-wide behavior)
|
|
252
|
+
* Omitted → "tool" (back-compat). Ignored for non-file tools.
|
|
253
|
+
*/
|
|
254
|
+
export type ApprovalPathScope = "file" | "dir" | "tool";
|
|
171
255
|
export type ApprovalResult = {
|
|
172
256
|
approved: true;
|
|
173
257
|
permanent?: boolean;
|
|
174
258
|
always?: boolean;
|
|
175
259
|
scope?: ApprovalScope;
|
|
260
|
+
pathScope?: ApprovalPathScope;
|
|
176
261
|
/** Used by AskUserQuestion to carry the user's free-text answer. */ answer?: string;
|
|
177
262
|
} | {
|
|
178
263
|
approved: false;
|
|
@@ -206,6 +291,10 @@ export type StreamEvent = {
|
|
|
206
291
|
type: "stream_request_start";
|
|
207
292
|
turnNumber: number;
|
|
208
293
|
agentId?: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: "steer_injected";
|
|
296
|
+
text: string;
|
|
297
|
+
id?: string;
|
|
209
298
|
} | {
|
|
210
299
|
type: "text_delta";
|
|
211
300
|
text: string;
|
|
@@ -234,10 +323,22 @@ export type StreamEvent = {
|
|
|
234
323
|
agentId?: string;
|
|
235
324
|
} | {
|
|
236
325
|
type: "goal_progress";
|
|
237
|
-
status: "not_met" | "met" | "exhausted";
|
|
326
|
+
status: "not_met" | "met" | "exhausted" | "approaching_limit";
|
|
238
327
|
round: number;
|
|
239
328
|
gaps?: string;
|
|
329
|
+
/** For "approaching_limit": turns left before the maxTurns cap (TODO 3.1). */
|
|
330
|
+
turnsRemaining?: number;
|
|
331
|
+
/** For "approaching_limit": consecutive blocks left before maxStopBlocks (TODO 3.1). */
|
|
332
|
+
stopBlocksRemaining?: number;
|
|
333
|
+
/** For "approaching_limit": which ceiling is closest — drives UI copy + extend default. */
|
|
334
|
+
nearest?: "turns" | "stopBlocks";
|
|
240
335
|
agentId?: string;
|
|
336
|
+
} | {
|
|
337
|
+
type: "goal_set";
|
|
338
|
+
objective: string;
|
|
339
|
+
replaced: boolean;
|
|
340
|
+
} | {
|
|
341
|
+
type: "goal_cleared";
|
|
241
342
|
} | {
|
|
242
343
|
type: "error";
|
|
243
344
|
error: string;
|
|
@@ -249,6 +350,12 @@ export type StreamEvent = {
|
|
|
249
350
|
type: "task_update";
|
|
250
351
|
tasks: TaskInfo[];
|
|
251
352
|
agentId?: string;
|
|
353
|
+
} | {
|
|
354
|
+
type: "memory_recalled";
|
|
355
|
+
name: string;
|
|
356
|
+
scope: "user" | "dream";
|
|
357
|
+
location: "global" | "project";
|
|
358
|
+
agentId?: string;
|
|
252
359
|
} | {
|
|
253
360
|
type: "thinking_delta";
|
|
254
361
|
text: string;
|
|
@@ -259,6 +366,12 @@ export type StreamEvent = {
|
|
|
259
366
|
name?: string;
|
|
260
367
|
description: string;
|
|
261
368
|
agentType?: string;
|
|
369
|
+
} | {
|
|
370
|
+
type: "agent_backgrounded";
|
|
371
|
+
agentId: string;
|
|
372
|
+
name?: string;
|
|
373
|
+
description: string;
|
|
374
|
+
agentType?: string;
|
|
262
375
|
} | {
|
|
263
376
|
type: "agent_end";
|
|
264
377
|
agentId: string;
|
|
@@ -267,6 +380,10 @@ export type StreamEvent = {
|
|
|
267
380
|
text?: string;
|
|
268
381
|
error?: string;
|
|
269
382
|
agentType?: string;
|
|
383
|
+
} | {
|
|
384
|
+
type: "agent_heartbeat";
|
|
385
|
+
agentIds: string[];
|
|
386
|
+
ts: number;
|
|
270
387
|
} | {
|
|
271
388
|
type: "tool_summary";
|
|
272
389
|
summary: string;
|
|
@@ -279,6 +396,27 @@ export type StreamEvent = {
|
|
|
279
396
|
} | {
|
|
280
397
|
type: "usage_update";
|
|
281
398
|
promptTokens: number;
|
|
399
|
+
/**
|
|
400
|
+
* Provider-reported prompt-cache counts, forwarded so the UI can show a
|
|
401
|
+
* cache hit rate in the context-ring tooltip. Present only when the LLM
|
|
402
|
+
* response carried them (authoritative-usage emits); omitted on the
|
|
403
|
+
* message-estimate emits that fire between LLM calls. See
|
|
404
|
+
* docs/todo/prompt-cache-optimization.md.
|
|
405
|
+
*/
|
|
406
|
+
cacheReadTokens?: number;
|
|
407
|
+
cacheCreationTokens?: number;
|
|
408
|
+
/**
|
|
409
|
+
* SESSION-CUMULATIVE cache counts (sum across every LLM response this
|
|
410
|
+
* session, across runs and turns), emitted from the engine's turn
|
|
411
|
+
* boundary off the persisted session.state.tokenUsage. Distinct from the
|
|
412
|
+
* per-response cacheReadTokens/cacheCreationTokens above: those drive the
|
|
413
|
+
* live context reading, these drive the "本会话累计命中率" tooltip. Reset
|
|
414
|
+
* to 0 on a model switch. Present only on the cumulative (turn-boundary)
|
|
415
|
+
* emit; omitted on per-response / estimate emits.
|
|
416
|
+
*/
|
|
417
|
+
sessionCacheReadTokens?: number;
|
|
418
|
+
sessionCacheCreationTokens?: number;
|
|
419
|
+
sessionPromptTokens?: number;
|
|
282
420
|
agentId?: string;
|
|
283
421
|
} | {
|
|
284
422
|
type: "background_agent_completed";
|
|
@@ -286,6 +424,15 @@ export type StreamEvent = {
|
|
|
286
424
|
name?: string;
|
|
287
425
|
description: string;
|
|
288
426
|
status: "completed" | "failed";
|
|
427
|
+
/**
|
|
428
|
+
* What kind of background work this was. Lets UIs localize the
|
|
429
|
+
* completion toast (e.g. a shell shows "命令完成" not the raw English
|
|
430
|
+
* description, which is written for the agent's wakeup notification).
|
|
431
|
+
* Absent for legacy sub-agent notifications (treated as "agent").
|
|
432
|
+
*/
|
|
433
|
+
workKind?: "agent" | "shell" | "video" | "cc";
|
|
434
|
+
/** For workKind === "shell": the command that ran (for a friendly label). */
|
|
435
|
+
command?: string;
|
|
289
436
|
/** Final assistant text (status === "completed" only). */
|
|
290
437
|
finalText?: string;
|
|
291
438
|
/** Error message (status === "failed" only). */
|
|
@@ -317,6 +464,21 @@ export interface LLMConfig {
|
|
|
317
464
|
apiKey?: string;
|
|
318
465
|
baseUrl?: string;
|
|
319
466
|
maxTokens?: number;
|
|
467
|
+
/**
|
|
468
|
+
* Shell command whose stdout is the auth token (TODO 7.2). Resolved at
|
|
469
|
+
* client-build time when `apiKey` is absent. The trimmed first line of
|
|
470
|
+
* stdout becomes the bearer token.
|
|
471
|
+
*/
|
|
472
|
+
authCommand?: string;
|
|
473
|
+
/**
|
|
474
|
+
* Extra HTTP headers for every request to this model's provider (TODO 7.2).
|
|
475
|
+
* A value `$ENV_VAR` is resolved from the environment at build time.
|
|
476
|
+
*/
|
|
477
|
+
httpHeaders?: Record<string, string>;
|
|
478
|
+
/** OpenAI `service_tier` request param, passed through verbatim (TODO 7.2). */
|
|
479
|
+
serviceTier?: string;
|
|
480
|
+
/** OpenAI reasoning `summary` control ("auto"|"concise"|"detailed") (TODO 7.2). */
|
|
481
|
+
reasoningSummary?: string;
|
|
320
482
|
/**
|
|
321
483
|
* Default reasoning/thinking setting for this model. Per-call
|
|
322
484
|
* `options.reasoning` (e.g. summarize sub-calls) overrides this.
|
|
@@ -331,6 +493,12 @@ export interface LLMConfig {
|
|
|
331
493
|
* ("openai" or "anthropic") that picks which client class to use.
|
|
332
494
|
*/
|
|
333
495
|
providerKind?: string;
|
|
496
|
+
/**
|
|
497
|
+
* Catalog-driven extra request-body fields (temperature/top_p/thinking etc),
|
|
498
|
+
* already wire-mapped from the connection's paramValues. Merged into the
|
|
499
|
+
* request body, each key filtered by the model's rejectedParams.
|
|
500
|
+
*/
|
|
501
|
+
extraBody?: Record<string, unknown>;
|
|
334
502
|
}
|
|
335
503
|
/**
|
|
336
504
|
* ClientDefaults — runtime knobs that apply regardless of which model is
|
|
@@ -347,11 +515,16 @@ export interface ClientDefaults {
|
|
|
347
515
|
/** Max retry attempts for transient errors. Default 3. */
|
|
348
516
|
retryMaxAttempts?: number;
|
|
349
517
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
518
|
+
* Provider-agnostic image clarity level. Drives the renderer-side
|
|
519
|
+
* downscale (long-edge cap: low→~1024 / standard→~1568 / high→~2576)
|
|
520
|
+
* so BOTH providers save tokens before send. On the OpenAI path it
|
|
521
|
+
* also maps to the wire `detail` hint (low→low, standard/high→high);
|
|
522
|
+
* Anthropic has no such param and saves purely via the downscale.
|
|
523
|
+
* Defaults to "high" (full fidelity) when unset.
|
|
524
|
+
*
|
|
525
|
+
* Legacy "original" values from older settings are migrated to "high".
|
|
353
526
|
*/
|
|
354
|
-
imageDetail?: "low" | "
|
|
527
|
+
imageDetail?: "low" | "standard" | "high";
|
|
355
528
|
}
|
|
356
529
|
export interface LLMResponse {
|
|
357
530
|
text: string;
|
|
@@ -377,6 +550,28 @@ export interface MCPServerConfig {
|
|
|
377
550
|
url?: string;
|
|
378
551
|
transport?: MCPTransport;
|
|
379
552
|
headers?: Record<string, string>;
|
|
553
|
+
/**
|
|
554
|
+
* (stdio) NAMES of env vars to forward from the parent process to the
|
|
555
|
+
* spawned server. The value is read from `process.env` at connect time —
|
|
556
|
+
* the secret itself is never stored in config. Explicit `env` overrides.
|
|
557
|
+
*/
|
|
558
|
+
envVars?: string[];
|
|
559
|
+
/**
|
|
560
|
+
* (HTTP) NAME of an env var whose value is sent as
|
|
561
|
+
* `Authorization: Bearer <value>`. Read from `process.env` at connect time.
|
|
562
|
+
*/
|
|
563
|
+
bearerTokenEnvVar?: string;
|
|
564
|
+
/**
|
|
565
|
+
* (HTTP) Map of header-name → env-var-NAME. Each header's value is read
|
|
566
|
+
* from the named env var at connect time, keeping secrets out of config.
|
|
567
|
+
*/
|
|
568
|
+
envHeaders?: Record<string, string>;
|
|
569
|
+
/**
|
|
570
|
+
* (HTTP) id of a stored credential (CredentialStore) to use as the Bearer
|
|
571
|
+
* token. Resolved at connect time via a resolver passed to buildHttpHeaders;
|
|
572
|
+
* the secret is never stored in the MCP config. Wins over bearerTokenEnvVar.
|
|
573
|
+
*/
|
|
574
|
+
credentialRef?: string;
|
|
380
575
|
/**
|
|
381
576
|
* Toggle a server off without deleting its config (mirrors Codex's
|
|
382
577
|
* `enabled` field). Absent or `true` → connected; only the literal
|
|
@@ -386,6 +581,21 @@ export interface MCPServerConfig {
|
|
|
386
581
|
*/
|
|
387
582
|
enabled?: boolean;
|
|
388
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* User-supplied supplement for a PLUGIN-provided MCP server, keyed by the
|
|
586
|
+
* server's `<plugin>:<server>` name. Stored globally under
|
|
587
|
+
* `settings.mcpServerOverrides` and layered onto the plugin's config at merge
|
|
588
|
+
* time (see mergePluginMcpServers). Only env/credential fields are allowed —
|
|
589
|
+
* command/args/url/transport stay owned by the plugin manifest so a plugin
|
|
590
|
+
* update is never shadowed by a stale user copy.
|
|
591
|
+
*/
|
|
592
|
+
export interface MCPServerOverride {
|
|
593
|
+
env?: Record<string, string>;
|
|
594
|
+
envVars?: string[];
|
|
595
|
+
credentialRef?: string;
|
|
596
|
+
bearerTokenEnvVar?: string;
|
|
597
|
+
envHeaders?: Record<string, string>;
|
|
598
|
+
}
|
|
389
599
|
/**
|
|
390
600
|
* Shell-hook configuration entry from settings.json. Each entry binds
|
|
391
601
|
* a hook event to a shell command. The command runs as a child process
|
|
@@ -429,6 +639,7 @@ export interface Settings {
|
|
|
429
639
|
maxTokens: number;
|
|
430
640
|
compactAtRatio: number;
|
|
431
641
|
summarizeAtRatio: number;
|
|
642
|
+
microcompactFloorRatio: number;
|
|
432
643
|
};
|
|
433
644
|
session: {
|
|
434
645
|
storageDir: string;
|
package/dist/updater.js
CHANGED
|
@@ -33,6 +33,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
33
33
|
import { readFileSync } from "node:fs";
|
|
34
34
|
import { fileURLToPath } from "node:url";
|
|
35
35
|
import { promisify } from "node:util";
|
|
36
|
+
import { resolveShellInvocation } from "./runtime/spawn-common.js";
|
|
36
37
|
import { gt } from "./utils/semver.js";
|
|
37
38
|
const execFileAsync = promisify(execFile);
|
|
38
39
|
const PACKAGE_NAME = "@cjhyy/code-shell";
|
|
@@ -282,7 +283,7 @@ function launchDetachedInstall(version) {
|
|
|
282
283
|
try {
|
|
283
284
|
// Avoid `mkdirSync recursive` failures if dir exists.
|
|
284
285
|
try {
|
|
285
|
-
const fs =
|
|
286
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
286
287
|
fs.mkdirSync(configDir(), { recursive: true });
|
|
287
288
|
fs.writeFileSync(lockPath, String(process.pid), { encoding: "utf8", flag: "wx" });
|
|
288
289
|
}
|
|
@@ -290,7 +291,7 @@ function launchDetachedInstall(version) {
|
|
|
290
291
|
if (errnoCode(err) === "EEXIST") {
|
|
291
292
|
// Lock held — check freshness; if stale, take over.
|
|
292
293
|
try {
|
|
293
|
-
const fs =
|
|
294
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
294
295
|
const s = fs.statSync(lockPath);
|
|
295
296
|
if (Date.now() - s.mtimeMs < LOCK_TIMEOUT_MS)
|
|
296
297
|
return; // fresh — back off
|
|
@@ -309,7 +310,7 @@ function launchDetachedInstall(version) {
|
|
|
309
310
|
catch {
|
|
310
311
|
return;
|
|
311
312
|
}
|
|
312
|
-
const fs =
|
|
313
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
313
314
|
const logFd = fs.openSync(getUpdateLogPath(), "a");
|
|
314
315
|
try {
|
|
315
316
|
fs.writeSync(logFd, `\n[${new Date().toISOString()}] code-shell auto-update: installing ${PACKAGE_NAME}@${version} (pid=${process.pid})\n`);
|
|
@@ -318,13 +319,23 @@ function launchDetachedInstall(version) {
|
|
|
318
319
|
// ignore
|
|
319
320
|
}
|
|
320
321
|
// Wrap install + lock cleanup in a tiny shell so the lock file is removed
|
|
321
|
-
// even if npm fails.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
// even if npm fails. Cross-platform: POSIX sequences with `; rm -f`, Windows
|
|
323
|
+
// cmd.exe with `& del /f /q` (no `sh`/`rm` there). resolveShellInvocation
|
|
324
|
+
// picks the shell binary + flag (/c vs -c) per platform.
|
|
325
|
+
const isWin = process.platform === "win32";
|
|
326
|
+
// cmd.exe doesn't understand POSIX single-quote escaping. version is a semver
|
|
327
|
+
// from npm (no shell metachars) so it needs no quoting on cmd; the lock path
|
|
328
|
+
// gets double quotes (cmd-native). POSIX keeps shellEscape on both.
|
|
329
|
+
const installPkg = isWin
|
|
330
|
+
? `npm install -g ${PACKAGE_NAME}@${version}`
|
|
331
|
+
: `npm install -g ${PACKAGE_NAME}@${shellEscape(version)}`;
|
|
332
|
+
const cleanup = isWin
|
|
333
|
+
? `& del /f /q "${lockPath}"`
|
|
334
|
+
: `; rm -f ${shellEscape(lockPath)}`;
|
|
335
|
+
const cmd = `${installPkg} ${cleanup}`;
|
|
336
|
+
const { file: shellFile, args: shellArgs } = resolveShellInvocation(cmd);
|
|
326
337
|
try {
|
|
327
|
-
const child = spawn(
|
|
338
|
+
const child = spawn(shellFile, shellArgs, {
|
|
328
339
|
detached: true,
|
|
329
340
|
stdio: ["ignore", logFd, logFd],
|
|
330
341
|
cwd: homedir(),
|
package/dist/utils/envUtils.d.ts
CHANGED
|
@@ -36,16 +36,7 @@ export declare function getDefaultVertexRegion(): string;
|
|
|
36
36
|
* Check if bash commands should maintain project working directory.
|
|
37
37
|
*/
|
|
38
38
|
export declare function shouldMaintainProjectWorkingDir(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Check if running on Homespace (ant-internal cloud environment).
|
|
41
|
-
*/
|
|
42
|
-
export declare function isRunningOnHomespace(): boolean;
|
|
43
39
|
/**
|
|
44
40
|
* Get the Vertex AI region for a specific model.
|
|
45
41
|
*/
|
|
46
42
|
export declare function getVertexRegionForModel(model: string | undefined): string | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Stub: Check if running inside a protected namespace.
|
|
49
|
-
* Always returns false in Code Shell (Anthropic-internal feature).
|
|
50
|
-
*/
|
|
51
|
-
export declare function isInProtectedNamespace(): boolean;
|
package/dist/utils/envUtils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
+
import { VERTEX_REGION_OVERRIDES } from '../data/model-metadata.js';
|
|
6
7
|
// Memoize cache for getClaudeConfigHomeDir
|
|
7
8
|
let _configHomeDirCache = null;
|
|
8
9
|
let _configHomeDirCacheKey = undefined;
|
|
@@ -93,27 +94,8 @@ export function getDefaultVertexRegion() {
|
|
|
93
94
|
export function shouldMaintainProjectWorkingDir() {
|
|
94
95
|
return isEnvTruthy(process.env.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR);
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
export function isRunningOnHomespace() {
|
|
100
|
-
return (process.env.USER_TYPE === 'ant' &&
|
|
101
|
-
isEnvTruthy(process.env.COO_RUNNING_ON_HOMESPACE));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Model prefix → env var for Vertex region overrides.
|
|
105
|
-
*/
|
|
106
|
-
const VERTEX_REGION_OVERRIDES = [
|
|
107
|
-
['claude-haiku-4-5', 'VERTEX_REGION_CLAUDE_HAIKU_4_5'],
|
|
108
|
-
['claude-3-5-haiku', 'VERTEX_REGION_CLAUDE_3_5_HAIKU'],
|
|
109
|
-
['claude-3-5-sonnet', 'VERTEX_REGION_CLAUDE_3_5_SONNET'],
|
|
110
|
-
['claude-3-7-sonnet', 'VERTEX_REGION_CLAUDE_3_7_SONNET'],
|
|
111
|
-
['claude-opus-4-1', 'VERTEX_REGION_CLAUDE_4_1_OPUS'],
|
|
112
|
-
['claude-opus-4', 'VERTEX_REGION_CLAUDE_4_0_OPUS'],
|
|
113
|
-
['claude-sonnet-4-6', 'VERTEX_REGION_CLAUDE_4_6_SONNET'],
|
|
114
|
-
['claude-sonnet-4-5', 'VERTEX_REGION_CLAUDE_4_5_SONNET'],
|
|
115
|
-
['claude-sonnet-4', 'VERTEX_REGION_CLAUDE_4_0_SONNET'],
|
|
116
|
-
];
|
|
97
|
+
// VERTEX_REGION_OVERRIDES now lives in data/model-metadata.json (imported above)
|
|
98
|
+
// so adding a model's region env var is a data edit, not a code change.
|
|
117
99
|
/**
|
|
118
100
|
* Get the Vertex AI region for a specific model.
|
|
119
101
|
*/
|
|
@@ -126,10 +108,3 @@ export function getVertexRegionForModel(model) {
|
|
|
126
108
|
}
|
|
127
109
|
return getDefaultVertexRegion();
|
|
128
110
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Stub: Check if running inside a protected namespace.
|
|
131
|
-
* Always returns false in Code Shell (Anthropic-internal feature).
|
|
132
|
-
*/
|
|
133
|
-
export function isInProtectedNamespace() {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform executable resolution.
|
|
3
|
+
*
|
|
4
|
+
* Node's `child_process.spawn`/`execFile` on Windows do NOT walk PATHEXT for a
|
|
5
|
+
* bare command name unless `shell:true` — so `execFile("git", …)` finds
|
|
6
|
+
* `git.exe` but NOT a `git.cmd`/`gh.cmd` shim (common for tools installed via
|
|
7
|
+
* scoop/npm/chocolatey). On POSIX a bare name in PATH works fine.
|
|
8
|
+
*
|
|
9
|
+
* `resolveExecutable` does an explicit PATH × PATHEXT lookup on Windows and
|
|
10
|
+
* returns the first existing match's absolute path; on POSIX (or when nothing
|
|
11
|
+
* is found) it returns the command unchanged, so callers can always pass the
|
|
12
|
+
* result straight to execFile/spawn.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The names to probe for `command` on the current platform: the bare name on
|
|
16
|
+
* POSIX (or when it already has an extension), plus each PATHEXT variant
|
|
17
|
+
* (command.exe / .cmd / .bat …) on Windows.
|
|
18
|
+
*/
|
|
19
|
+
export declare function commandCandidateNames(command: string, env?: NodeJS.ProcessEnv): string[];
|
|
20
|
+
export declare function resolveExecutable(command: string, env?: NodeJS.ProcessEnv): string;
|
|
21
|
+
/** Test seam: drop the resolution cache. */
|
|
22
|
+
export declare function _clearExecutableCache(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Find `command` as a real, runnable executable. Unlike {@link resolveExecutable}
|
|
25
|
+
* (which returns the bare name unchanged when nothing is found, so spawn can
|
|
26
|
+
* surface its own ENOENT), this returns the absolute path if a binary exists or
|
|
27
|
+
* `null` if it genuinely cannot be found — works on POSIX too (probes PATH).
|
|
28
|
+
* Use it to *detect* a missing tool up front (e.g. is git installed?).
|
|
29
|
+
*/
|
|
30
|
+
export declare function findExecutable(command: string, env?: NodeJS.ProcessEnv): string | null;
|
|
31
|
+
/** Set (or clear, with null/"") the user-configured git binary path. */
|
|
32
|
+
export declare function setGitPathOverride(path: string | null | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* The git command to spawn: the user override if set, else `git` resolved
|
|
35
|
+
* through PATH×PATHEXT. Always returns something spawnable (callers still get
|
|
36
|
+
* a structured spawn-failure if it's wrong).
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveGit(env?: NodeJS.ProcessEnv): string;
|
|
39
|
+
/** Is a usable git binary available (override path, or git on PATH)? */
|
|
40
|
+
export declare function isGitAvailable(env?: NodeJS.ProcessEnv): boolean;
|