@cjhyy/code-shell-core 0.5.0-rc.2 → 0.6.0-rc.10
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 +86 -0
- package/dist/context/compaction.js +279 -0
- package/dist/context/manager.d.ts +18 -0
- package/dist/context/manager.js +181 -48
- package/dist/context/token-counter.js +13 -0
- 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 +280 -141
- package/dist/engine/engine.js +1193 -245
- 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 +67 -0
- package/dist/engine/model-facade.d.ts +10 -0
- package/dist/engine/model-facade.js +15 -0
- package/dist/engine/patch-orphaned-tools.js +3 -0
- package/dist/engine/query.js +2 -0
- package/dist/engine/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.d.ts +2 -0
- package/dist/engine/runtime.js +27 -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 +31 -0
- package/dist/engine/session-usage.js +81 -0
- package/dist/engine/steer-queue.d.ts +33 -0
- package/dist/engine/steer-queue.js +26 -0
- package/dist/engine/streaming-tool-queue.d.ts +12 -0
- package/dist/engine/streaming-tool-queue.js +50 -10
- package/dist/engine/turn-loop.d.ts +94 -4
- package/dist/engine/turn-loop.js +432 -54
- 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.d.ts +12 -0
- package/dist/git/utils.js +38 -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 +51 -7
- package/dist/index.js +62 -5
- 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 +5 -1
- 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 +21 -0
- package/dist/llm/model-pool.js +21 -1
- 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 +412 -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 +11 -1
- package/dist/preset/index.js +115 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +32 -0
- package/dist/prompt/composer.js +75 -21
- package/dist/prompt/instruction-scanner.js +5 -3
- package/dist/prompt/section-loader.js +1 -0
- package/dist/prompt/sections/base.md +2 -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 +9 -2
- package/dist/protocol/chat-session-manager.js +38 -0
- package/dist/protocol/chat-session.d.ts +69 -1
- package/dist/protocol/chat-session.js +102 -4
- package/dist/protocol/client.d.ts +31 -0
- package/dist/protocol/client.js +44 -0
- package/dist/protocol/server.d.ts +120 -7
- package/dist/protocol/server.js +753 -51
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +60 -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 +509 -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 +98 -39
- package/dist/runtime/spawn-common.d.ts +159 -0
- package/dist/runtime/spawn-common.js +404 -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 +119 -3
- package/dist/session/simple-diff.d.ts +23 -0
- package/dist/session/simple-diff.js +84 -0
- package/dist/session/transcript.d.ts +29 -1
- package/dist/session/transcript.js +56 -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 +101 -64
- 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 +64 -4
- 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 +104 -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 +364 -0
- package/dist/tool-system/builtin/glob.js +0 -7
- package/dist/tool-system/builtin/grep.d.ts +9 -0
- package/dist/tool-system/builtin/grep.js +106 -11
- 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 +10 -2
- package/dist/tool-system/builtin/index.js +251 -27
- 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 +8 -2
- 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 +8 -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 +164 -6
- package/dist/tool-system/executor.d.ts +3 -1
- package/dist/tool-system/executor.js +197 -90
- 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 +203 -20
- package/dist/tool-system/mcp-stdio-diagnostics.d.ts +9 -0
- package/dist/tool-system/mcp-stdio-diagnostics.js +93 -0
- 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 +39 -2
- package/dist/tool-system/permission.js +283 -70
- 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/sandbox/off.js +7 -1
- 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 +252 -7
- 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 +48 -0
- package/dist/utils/exec.js +154 -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
package/dist/index.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API exports.
|
|
5
5
|
*/
|
|
6
|
-
export const VERSION = "0.
|
|
6
|
+
export const VERSION = "0.6.0-rc.8";
|
|
7
7
|
// ─── Exceptions ──────────────────────────────────────────────────
|
|
8
8
|
export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, SandboxUnavailableError, } from "./exceptions.js";
|
|
9
9
|
// ─── Engine (primary API) ────────────────────────────────────────
|
|
10
10
|
export { Engine, loadAgentDefinitionsForCwd } from "./engine/engine.js";
|
|
11
|
+
export { resolveLLMConfigForTag } from "./engine/resolve-llm-config.js";
|
|
12
|
+
export { resolveAuxKey } from "./engine/aux-key.js";
|
|
11
13
|
export { parseAgentDefinition, serializeAgentDefinition, } from "./agent/agent-definition.js";
|
|
12
14
|
export { AgentDefinitionRegistry, } from "./agent/agent-definition-registry.js";
|
|
13
15
|
export { EngineRuntime } from "./engine/runtime.js";
|
|
@@ -18,13 +20,14 @@ export { createLLMClient, registerProvider } from "./llm/client-factory.js";
|
|
|
18
20
|
export { AnthropicClient } from "./llm/providers/anthropic.js";
|
|
19
21
|
export { OpenAIClient } from "./llm/providers/openai.js";
|
|
20
22
|
export { ModelPool } from "./llm/model-pool.js";
|
|
23
|
+
export { modelEntriesFromConnections } from "./engine/model-connections-pool.js";
|
|
21
24
|
// ─── Tools ───────────────────────────────────────────────────────
|
|
22
25
|
export { ToolRegistry } from "./tool-system/registry.js";
|
|
23
26
|
export { ToolExecutor } from "./tool-system/executor.js";
|
|
24
27
|
export { PermissionClassifier, HeadlessApprovalBackend, AutoApprovalBackend } from "./tool-system/permission.js";
|
|
25
28
|
export { BUILTIN_TOOLS } from "./tool-system/builtin/index.js";
|
|
26
29
|
export { makeUpdateAutomationMemoryTool } from "./tool-system/builtin/update-automation-memory.js";
|
|
27
|
-
export { MCPManager } from "./tool-system/mcp-manager.js";
|
|
30
|
+
export { MCPManager, buildHttpHeaders, buildStdioEnv } from "./tool-system/mcp-manager.js";
|
|
28
31
|
// ─── Hooks ───────────────────────────────────────────────────────
|
|
29
32
|
export { HookRegistry } from "./hooks/registry.js";
|
|
30
33
|
export { wrapHookMessages } from "./hooks/inject.js";
|
|
@@ -41,6 +44,8 @@ export { Methods, ErrorCodes, } from "./protocol/types.js";
|
|
|
41
44
|
export { Transcript } from "./session/transcript.js";
|
|
42
45
|
export { SessionManager } from "./session/session-manager.js";
|
|
43
46
|
export { FileHistory } from "./session/file-history.js";
|
|
47
|
+
export { latestUndoTarget, earliestSnapshotsPerFile, latestTurnUndoTargets, latestRedoTargets, } from "./session/undo-target.js";
|
|
48
|
+
export { diffLines, renderDiffPreview } from "./session/simple-diff.js";
|
|
44
49
|
export { MemoryManager } from "./session/memory.js";
|
|
45
50
|
export { runDreamConsolidation, } from "./services/dream-consolidation.js";
|
|
46
51
|
// ─── Prompt ──────────────────────────────────────────────────────
|
|
@@ -59,18 +64,23 @@ export { scanSkills, invalidateSkillCache } from "./skills/index.js";
|
|
|
59
64
|
// ─── Capability control (扩展能力 backend) ───────────────────────
|
|
60
65
|
export { CapabilityService, CapabilityNotFoundError, projectBuiltin, projectMcp, projectSkills, projectPlugins, } from "./capability-control/index.js";
|
|
61
66
|
export { readInstalledPlugins } from "./plugins/installedPlugins.js";
|
|
67
|
+
export { computeEffectiveDisabledLists, } from "./capability-control/disabled-lists.js";
|
|
62
68
|
// ─── Plugin installer (CC + Codex) ───────────────────────────────
|
|
63
69
|
export { installPluginFromPath } from "./plugins/installer/install.js";
|
|
64
70
|
export { installPluginFromSource } from "./plugins/installer/installFromSource.js";
|
|
71
|
+
export { installLocalPlugin, installPluginFromArchive, } from "./plugins/installer/installFromArchive.js";
|
|
65
72
|
export { parseSource } from "./plugins/installer/parseSource.js";
|
|
66
73
|
export { detectPluginFormat } from "./plugins/installer/detectFormat.js";
|
|
67
74
|
export { CodexPluginManifest, CSMeta, PluginInstallError, } from "./plugins/installer/types.js";
|
|
68
75
|
export { mergePluginMcpServers } from "./plugins/installer/loadPluginMcp.js";
|
|
76
|
+
export { listPluginHooks, pluginHookKey } from "./plugins/loadPluginHooks.js";
|
|
77
|
+
export { describePluginContent } from "./plugins/pluginContent.js";
|
|
69
78
|
export { pluginAgentDirs } from "./plugins/installer/loadPluginAgents.js";
|
|
70
79
|
export { appendInstallEntry, pluginInstallKey, removeInstallEntries, } from "./plugins/installedPlugins.js";
|
|
71
80
|
export { uninstallPluginByName } from "./plugins/installer/uninstall.js";
|
|
72
81
|
export { listInstalledPlugins } from "./plugins/installer/list.js";
|
|
73
82
|
export { updatePluginByName } from "./plugins/installer/update.js";
|
|
83
|
+
export { checkPluginUpdate } from "./plugins/installer/checkUpdate.js";
|
|
74
84
|
// ─── Arena ───────────────────────────────────────────────────────
|
|
75
85
|
export { Arena } from "./arena/arena.js";
|
|
76
86
|
export { MODEL_PRESETS, getMaxOutputTokens } from "./arena/model-presets.js";
|
|
@@ -112,24 +122,37 @@ export { defineProduct, } from "./product/index.js";
|
|
|
112
122
|
export { logger } from "./logging/logger.js";
|
|
113
123
|
// ─── Settings ────────────────────────────────────────────────────
|
|
114
124
|
export { SettingsManager } from "./settings/manager.js";
|
|
125
|
+
export { migrateConfig, configVersionOf, CURRENT_CONFIG_VERSION, } from "./settings/migrate-config.js";
|
|
115
126
|
export { SettingsSchema, validateSettings } from "./settings/schema.js";
|
|
127
|
+
export { settingsJsonSchema, writeSettingsSchemaFile } from "./settings/schema-export.js";
|
|
116
128
|
export { personalizationFrom } from "./settings/personalization.js";
|
|
129
|
+
export { CredentialStore, formatNetscapeCookies, parseCookieJar, useCredentialToolDef, useCredentialToolDefFor, sweepStaleCredentialCookies, PlaintextCipher, setDefaultCredentialCipher, getDefaultCredentialCipher, } from "./credentials/index.js";
|
|
117
130
|
// ─── State (runtime singletons shared with TUI) ──────────────────
|
|
131
|
+
/** @internal Shared with the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
118
132
|
export { getSessionId, switchSession, getOriginalCwd, setOriginalCwd, getProjectRoot, setProjectRoot, getCwdState, getIsInteractive, updateLastInteractionTime, flushInteractionTime, markScrollActivity, } from "./state.js";
|
|
119
133
|
// ─── Utils (shared primitives used by TUI) ───────────────────────
|
|
134
|
+
/** @internal Shared primitives for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
120
135
|
export { getGraphemeSegmenter, firstGrapheme, lastGrapheme, getWordSegmenter, getRelativeTimeFormat, getTimeZone, getSystemLocaleLanguage, } from "./utils/intl.js";
|
|
121
136
|
export { env } from "./utils/env.js";
|
|
122
137
|
export { default as sliceAnsi } from "./utils/sliceAnsi.js";
|
|
123
138
|
export { execFileNoThrow } from "./utils/execFileNoThrow.js";
|
|
139
|
+
export { findExecutable, resolveExecutable, setGitPathOverride, resolveGit, isGitAvailable, resolveGitPath, } from "./utils/exec.js";
|
|
124
140
|
export { gte } from "./utils/semver.js";
|
|
141
|
+
// Cross-process file lock (proper-lockfile via createRequire, ESM-safe). Used by
|
|
142
|
+
// RunLock / CronStore internally; exported so other writers of shared files
|
|
143
|
+
// (e.g. desktop settings-service writing the same settings.json as the worker)
|
|
144
|
+
// can take the same advisory lock.
|
|
145
|
+
export { lock, lockSync, unlock, check } from "./utils/lockfile.js";
|
|
125
146
|
export { logForDebugging } from "./utils/debug.js";
|
|
126
|
-
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir,
|
|
147
|
+
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir, getAWSRegion, getDefaultVertexRegion, getVertexRegionForModel, } from "./utils/envUtils.js";
|
|
127
148
|
export { startCapturingEarlyInput, stopCapturingEarlyInput, consumeEarlyInput, hasEarlyInput, seedEarlyInput, isCapturingEarlyInput, } from "./utils/earlyInput.js";
|
|
128
149
|
export { formatBytes, formatToolArgs, singleLine, MAX_LINE_WIDTH, TOOL_DOT_COLORS, } from "./utils/toolDisplay.js";
|
|
150
|
+
export { classifyBashLines, } from "./tool-system/builtin/bash-output-style.js";
|
|
129
151
|
export { formatDuration, formatTokens } from "./utils/format.js";
|
|
130
152
|
export { getTheme, } from "./utils/theme.js";
|
|
131
153
|
export { resolveThemeSetting } from "./utils/systemTheme.js";
|
|
132
154
|
// ─── Logging (extended) ──────────────────────────────────────────
|
|
155
|
+
/** @internal Host-lifecycle logging hooks for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
133
156
|
export { rotateLogs } from "./logging/logger.js";
|
|
134
157
|
export { recordUIEvent } from "./logging/session-recorder.js";
|
|
135
158
|
// ─── Cost Tracker ────────────────────────────────────────────────
|
|
@@ -140,8 +163,16 @@ export { hasApiKey, resolveApiKey, appendOnboardingResult, detectEnvKeys, saveAr
|
|
|
140
163
|
// ─── Updater ─────────────────────────────────────────────────────
|
|
141
164
|
export { getCurrentVersion, checkForUpdate, scheduleAutoInstallOnExit, getUpdateAvailable, getAutoUpdateDisabledReason, } from "./updater.js";
|
|
142
165
|
// ─── Git Utilities ───────────────────────────────────────────────
|
|
143
|
-
export { isGitRepo, getCurrentBranch, getGitStatus, getGitDiff, getGitDiffStat, getGitLog, gitAdd, gitCommit, gitListBranches, gitCheckout, ghAvailable, ghPrComments, } from "./git/utils.js";
|
|
166
|
+
export { isGitRepo, resolveProjectRoot, getCurrentBranch, getGitStatus, getGitDiff, getGitDiffStat, getGitLog, gitAdd, gitCommit, gitListBranches, gitCheckout, ghAvailable, ghPrComments, } from "./git/utils.js";
|
|
167
|
+
// ─── Code review (TODO 7.3) ─────────────────────────────────────
|
|
168
|
+
export { buildReviewPrompt, parseDimensions, ALL_DIMENSIONS, } from "./review/review-prompt.js";
|
|
144
169
|
// ─── Tool-system (extended for TUI) ─────────────────────────────
|
|
170
|
+
/**
|
|
171
|
+
* @internal Exports below are consumed by the in-repo TUI/desktop hosts, not
|
|
172
|
+
* part of the stable `@cjhyy/code-shell-core` SDK surface. They may change or
|
|
173
|
+
* move to a `/tui` subpath without a major bump. External SDK users: prefer the
|
|
174
|
+
* primary Engine/Protocol API above.
|
|
175
|
+
*/
|
|
145
176
|
export { getInteractiveApprovalBackend } from "./tool-system/permission.js";
|
|
146
177
|
export { defaultSandboxConfig, } from "./tool-system/sandbox/index.js";
|
|
147
178
|
export { buildNotificationMessage, buildNotificationSummary, notificationQueue, agentNotificationBus, notificationItemToStreamEvent, } from "./tool-system/builtin/agent-notifications.js";
|
|
@@ -149,18 +180,33 @@ export { buildNotificationMessage, buildNotificationSummary, notificationQueue,
|
|
|
149
180
|
// + scheduler/store/runner). Hosts (Electron main, future CLI server) load
|
|
150
181
|
// this and inject store + runner. See docs/automation-plan-2026-05-31.md.
|
|
151
182
|
export { startAutomation, CronScheduler, cronScheduler, CronStore, defaultCronStorePath, bindCronToEngine, bindCronToRunManager, isCronExpression, parseCronExpression, nextCronTime, resolveWritePolicy, wrapUntrustedInput, runWriteJobInWorktree, } from "./automation/index.js";
|
|
183
|
+
// CC orchestrator (external claude-cli rooms + CC-aware scheduling).
|
|
184
|
+
export * from "./cc-orchestrator/index.js";
|
|
185
|
+
// Quota — remaining CC/Codex subscription usage (self-contained, plugin-liftable).
|
|
186
|
+
export { checkQuota, formatQuota } from "./quota/index.js";
|
|
187
|
+
export { resolveQuotaCredentials } from "./quota/credentials.js";
|
|
152
188
|
export { asyncAgentRegistry, } from "./tool-system/builtin/agent-registry.js";
|
|
189
|
+
export { backgroundShellManager, BackgroundShellManager, } from "./runtime/background-shell.js";
|
|
190
|
+
export { ENV_DENY_REGEX, ENV_ALLOWLIST } from "./runtime/spawn-common.js";
|
|
191
|
+
export { getImageProvider, DEFAULT_IMAGE_MODEL, } from "./tool-system/builtin/image-providers.js";
|
|
192
|
+
// ─── Speech-to-text (voice input / 听写) ────────────────────────
|
|
193
|
+
export { transcribe, } from "./stt/transcribe.js";
|
|
194
|
+
export { resolveTranscribeProvider, isTranscribeAvailable, describeTranscribe, } from "./stt/resolve-transcribe.js";
|
|
195
|
+
export { BUILTIN_CATALOG, getMergedCatalog, loadUserCatalog, userCatalogPath, findCatalogEntry, saveCatalogEntry, deleteUserCatalogEntry, catalogEntryOrigins, } from "./model-catalog/index.js";
|
|
153
196
|
// ─── Protocol (extended for TUI) ────────────────────────────────
|
|
197
|
+
/** @internal Extended protocol surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
154
198
|
export { createInProcessClient } from "./protocol/helpers.js";
|
|
155
199
|
// ─── Arena (extended for TUI) ───────────────────────────────────
|
|
200
|
+
/** @internal Extended Arena surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
156
201
|
export { formatArenaResult, printArenaResult, renderProgress, createProgressRenderer, } from "./arena/render/terminal.js";
|
|
157
202
|
export { formatArenaResultForSession } from "./arena/render/session.js";
|
|
158
203
|
// ─── Plugins ─────────────────────────────────────────────────────
|
|
159
204
|
export { installPlugin, uninstallPlugin, listInstalled, } from "./plugins/pluginInstaller.js";
|
|
160
|
-
export { addMarketplace, removeMarketplace, listMarketplaces, loadMarketplace, } from "./plugins/marketplaceManager.js";
|
|
205
|
+
export { addMarketplace, refreshMarketplace, removeMarketplace, listMarketplaces, loadMarketplace, } from "./plugins/marketplaceManager.js";
|
|
161
206
|
export { parseMarketplaceInput, deriveMarketplaceName, } from "./plugins/parseMarketplaceInput.js";
|
|
162
207
|
export { scanPluginCommands, } from "./plugins/pluginCommandsLoader.js";
|
|
163
208
|
// ─── LLM (extended for TUI) ─────────────────────────────────────
|
|
209
|
+
/** @internal Extended LLM surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
164
210
|
export { defaultCacheDir, } from "./llm/model-cache.js";
|
|
165
211
|
export { fetchModelList, } from "./llm/model-fetcher.js";
|
|
166
212
|
export { sanitizeApiKey, hasNonAsciiPrintable, } from "./llm/api-key-sanitize.js";
|
|
@@ -170,3 +216,14 @@ export { reasoningControlFor, } from "./llm/capabilities/reasoning-control.js";
|
|
|
170
216
|
export { REASONING_EFFORTS, } from "./llm/reasoning-setting.js";
|
|
171
217
|
// ─── Data ────────────────────────────────────────────────────────
|
|
172
218
|
export { syncOpenRouterCatalog, getOpenRouterSnapshot, } from "./data/openrouter-sync.js";
|
|
219
|
+
// ─── External agent config (Mobile Web Remote Rooms) ─────────────
|
|
220
|
+
// Resolves the externalAgents settings block (notably claudeCode.trustedWorkspaces),
|
|
221
|
+
// the source of truth for a Room's permission mode. The former /cc & /codex
|
|
222
|
+
// managed-job path was removed — the phone now talks to resident Rooms only.
|
|
223
|
+
export { resolveExternalAgentConfig } from "./external-agents/config.js";
|
|
224
|
+
// ─── Browser automation bridge ───────────────────────────────────
|
|
225
|
+
// Driver-agnostic contract + the pure a11y-tree flattener. The desktop host's
|
|
226
|
+
// browser-driver module implements BrowserBridge on top of webContents.debugger
|
|
227
|
+
// (CDP), reusing flattenAxTree. See the MVP spec
|
|
228
|
+
// docs/superpowers/specs/2026-06-16-browser-automation-mvp.md.
|
|
229
|
+
export { flattenAxTree, renderElementList, cleanPageText, CONTENT_CHAR_CAP, buildExtractLinksScript, EXTRACT_LINK_CAP, } from "./tool-system/browser-bridge.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* paramSpecsFromCapability — bridge the capability layer (rules.ts, the vetted
|
|
3
|
+
* single source of truth) into the unified catalog's ParamSpec[]. The catalog
|
|
4
|
+
* reuses this knowledge instead of re-hand-writing reasoning/vision per model.
|
|
5
|
+
* See docs/superpowers/specs/2026-06-15-unified-model-catalog-design.md §4.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProviderKindName } from "../provider-kinds.js";
|
|
8
|
+
import type { ParamSpec } from "../../model-catalog/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Project a (kind, model)'s capabilities into catalog ParamSpec[]. Currently
|
|
11
|
+
* covers reasoning (the param that diverges most across models); image
|
|
12
|
+
* size/quality live in their own catalog entries. Adaptive / none → no spec.
|
|
13
|
+
*/
|
|
14
|
+
export declare function paramSpecsFromCapability(kind: ProviderKindName, model: string): ParamSpec[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { reasoningControlFor } from "./reasoning-control.js";
|
|
2
|
+
/** Where each provider kind's reasoning knob lands on the request body. */
|
|
3
|
+
function reasoningWireField(kind) {
|
|
4
|
+
switch (kind) {
|
|
5
|
+
case "anthropic":
|
|
6
|
+
return "thinking.budget_tokens";
|
|
7
|
+
case "deepseek":
|
|
8
|
+
case "zai":
|
|
9
|
+
return "thinking.type";
|
|
10
|
+
default:
|
|
11
|
+
// OpenAI-compat (openai/google/openrouter/xai/mistral/groq) use reasoning_effort.
|
|
12
|
+
return "reasoning_effort";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Project a (kind, model)'s capabilities into catalog ParamSpec[]. Currently
|
|
17
|
+
* covers reasoning (the param that diverges most across models); image
|
|
18
|
+
* size/quality live in their own catalog entries. Adaptive / none → no spec.
|
|
19
|
+
*/
|
|
20
|
+
export function paramSpecsFromCapability(kind, model) {
|
|
21
|
+
const specs = [];
|
|
22
|
+
const control = reasoningControlFor(kind, model);
|
|
23
|
+
const wire = { field: reasoningWireField(kind) };
|
|
24
|
+
switch (control.kind) {
|
|
25
|
+
case "effort":
|
|
26
|
+
specs.push({
|
|
27
|
+
name: "reasoning",
|
|
28
|
+
label: "思考强度",
|
|
29
|
+
control: "enum",
|
|
30
|
+
options: control.options,
|
|
31
|
+
default: control.default,
|
|
32
|
+
doc: "Reasoning effort — how hard the model thinks before answering.",
|
|
33
|
+
wire,
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case "budget":
|
|
37
|
+
specs.push({
|
|
38
|
+
name: "reasoning",
|
|
39
|
+
label: "思考预算",
|
|
40
|
+
control: "number",
|
|
41
|
+
min: control.min,
|
|
42
|
+
default: control.default,
|
|
43
|
+
doc: "Thinking token budget — higher = more deliberate reasoning.",
|
|
44
|
+
wire,
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case "toggle":
|
|
48
|
+
specs.push({
|
|
49
|
+
name: "reasoning",
|
|
50
|
+
label: "思考",
|
|
51
|
+
control: "toggle",
|
|
52
|
+
default: control.default,
|
|
53
|
+
doc: "Toggle the model's thinking mode on/off.",
|
|
54
|
+
wire,
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
case "adaptive":
|
|
58
|
+
case "none":
|
|
59
|
+
break; // nothing to set
|
|
60
|
+
}
|
|
61
|
+
return specs;
|
|
62
|
+
}
|
|
@@ -43,6 +43,10 @@ export const RULES = [
|
|
|
43
43
|
kind: "openai-effort",
|
|
44
44
|
disabledEffort: "none",
|
|
45
45
|
supportedEfforts: ["low", "medium", "high", "xhigh"], // no "minimal"; adds "xhigh"
|
|
46
|
+
// gpt-5.5 400s when `reasoning_effort` rides alongside `tools` on
|
|
47
|
+
// /v1/chat/completions — drop the field up-front on tool turns instead
|
|
48
|
+
// of eating the 400 + 1s-backoff retry on every tool-using turn.
|
|
49
|
+
noEffortWithTools: true,
|
|
46
50
|
},
|
|
47
51
|
echoReasoning: "optional",
|
|
48
52
|
// 400s on `max_tokens is too large: ... at most 128000`. Clamp here so a
|
|
@@ -186,7 +190,7 @@ export const RULES = [
|
|
|
186
190
|
// Most modern frontier models on OpenRouter are multimodal; flag the
|
|
187
191
|
// big families explicitly. The catch-all below stays vision=false so
|
|
188
192
|
// older/text-only routes don't get a green checkmark they don't earn.
|
|
189
|
-
match:
|
|
193
|
+
match: /^~?(?:openai\/(?:gpt-4o|gpt-5|o[1-9])|anthropic\/claude-(?:3|4|opus|sonnet|haiku|fable)|google\/gemini-(?:[2-9]|pro)|x-ai\/grok-[4-9]|qwen\/qwen-?vl|meta\/llama-(?:3\.2|4))/i,
|
|
190
194
|
capability: {
|
|
191
195
|
supportsVision: true,
|
|
192
196
|
reasoning: { kind: "openrouter-reasoning" },
|
|
@@ -47,6 +47,16 @@ export type ReasoningShape = {
|
|
|
47
47
|
kind: "openai-effort";
|
|
48
48
|
disabledEffort?: ReasoningEffort | "none";
|
|
49
49
|
supportedEfforts?: ReasoningEffort[];
|
|
50
|
+
/**
|
|
51
|
+
* gpt-5.5+ rejects `reasoning_effort` whenever `tools` are also present on
|
|
52
|
+
* `/v1/chat/completions` ("Function tools with reasoning_effort are not
|
|
53
|
+
* supported … Please use /v1/responses instead"), 400-ing the request.
|
|
54
|
+
* When set, the OpenAI client OMITS `reasoning_effort` on any tool-bearing
|
|
55
|
+
* request up-front — so we never eat the 400 + retry on every tool turn.
|
|
56
|
+
* The reactive `_dropReasoningEffort` sticky still covers any variant we
|
|
57
|
+
* haven't tagged here.
|
|
58
|
+
*/
|
|
59
|
+
noEffortWithTools?: boolean;
|
|
50
60
|
}
|
|
51
61
|
/** Anthropic Claude 4.x ≤ 4.5 — `{thinking: {type: "enabled", budget_tokens: N}}`. */
|
|
52
62
|
| {
|
|
@@ -31,7 +31,34 @@ export declare abstract class LLMClientBase {
|
|
|
31
31
|
abstract createMessage(options: CreateMessageOptions): Promise<LLMResponse>;
|
|
32
32
|
protected recordUsage(usage: TokenUsage, options?: CreateMessageOptions): void;
|
|
33
33
|
getUsage(): LLMUsageTracker;
|
|
34
|
-
|
|
34
|
+
/** Zero all accumulated usage. Used when starting a fresh accounting window
|
|
35
|
+
* (e.g. after a model switch, where the prior model's cache stats no longer
|
|
36
|
+
* apply). */
|
|
37
|
+
resetUsage(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Compose the caller's AbortSignal with a hard per-request deadline.
|
|
40
|
+
*
|
|
41
|
+
* The provider SDKs accept a `timeout`, but in practice it does NOT fire for
|
|
42
|
+
* a *half-dead socket* (TCP connected, keep-alives flowing, but no response
|
|
43
|
+
* bytes) — we have observed real requests hang 15–33 minutes before the SDK
|
|
44
|
+
* finally surfaced "Socket timeout". The streaming idle-watchdog only covers
|
|
45
|
+
* the gap BETWEEN chunks, not connection setup / first byte, and non-stream
|
|
46
|
+
* calls don't go through it at all. An explicit AbortSignal.timeout is the
|
|
47
|
+
* one mechanism that reliably tears such a request down.
|
|
48
|
+
*
|
|
49
|
+
* Returns a signal to hand the SDK (`{ signal }`) plus a `cleanup()` to clear
|
|
50
|
+
* the timer once the request settles. The deadline is generous (default 2×
|
|
51
|
+
* the SDK timeout, min 120s) — long enough for slow-but-alive generations,
|
|
52
|
+
* short enough that a wedged socket can't burn half an hour.
|
|
53
|
+
*/
|
|
54
|
+
protected withRequestDeadline(callerSignal?: AbortSignal): {
|
|
55
|
+
signal: AbortSignal;
|
|
56
|
+
cleanup: () => void;
|
|
57
|
+
};
|
|
58
|
+
protected withRetry<T>(fn: (requestSignal?: AbortSignal) => Promise<T>, opts?: {
|
|
59
|
+
maxAttempts?: number;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
}): Promise<T>;
|
|
35
62
|
}
|
|
36
63
|
/**
|
|
37
64
|
* Detect HTTP 4xx errors from provider SDKs so withRetry can bail
|
package/dist/llm/client-base.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LLMError, ContextLimitError, LLMRateLimitError } from "../exceptions.js";
|
|
5
5
|
import { logger } from "../logging/logger.js";
|
|
6
|
+
function emptyUsageTracker() {
|
|
7
|
+
return {
|
|
8
|
+
records: [],
|
|
9
|
+
totalPromptTokens: 0,
|
|
10
|
+
totalCompletionTokens: 0,
|
|
11
|
+
totalTokens: 0,
|
|
12
|
+
totalCacheReadTokens: 0,
|
|
13
|
+
totalCacheCreationTokens: 0,
|
|
14
|
+
requestCount: 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
export class LLMClientBase {
|
|
7
18
|
config;
|
|
8
19
|
provider;
|
|
@@ -19,13 +30,7 @@ export class LLMClientBase {
|
|
|
19
30
|
* each call site needing to remember.
|
|
20
31
|
*/
|
|
21
32
|
static onUsage;
|
|
22
|
-
usage =
|
|
23
|
-
records: [],
|
|
24
|
-
totalPromptTokens: 0,
|
|
25
|
-
totalCompletionTokens: 0,
|
|
26
|
-
totalTokens: 0,
|
|
27
|
-
requestCount: 0,
|
|
28
|
-
};
|
|
33
|
+
usage = emptyUsageTracker();
|
|
29
34
|
/**
|
|
30
35
|
* `config` carries model identity (provider/model/apiKey/baseUrl/maxTokens/
|
|
31
36
|
* thinking/providerKind). `defaults` carries cross-model runtime knobs
|
|
@@ -55,29 +60,104 @@ export class LLMClientBase {
|
|
|
55
60
|
this.usage.totalPromptTokens += usage.promptTokens;
|
|
56
61
|
this.usage.totalCompletionTokens += usage.completionTokens;
|
|
57
62
|
this.usage.totalTokens += usage.totalTokens;
|
|
63
|
+
this.usage.totalCacheReadTokens += usage.cacheReadTokens ?? 0;
|
|
64
|
+
this.usage.totalCacheCreationTokens += usage.cacheCreationTokens ?? 0;
|
|
58
65
|
this.usage.requestCount++;
|
|
59
66
|
LLMClientBase.onUsage?.(this.model, usage);
|
|
60
67
|
}
|
|
61
68
|
getUsage() {
|
|
62
69
|
return { ...this.usage };
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
/** Zero all accumulated usage. Used when starting a fresh accounting window
|
|
72
|
+
* (e.g. after a model switch, where the prior model's cache stats no longer
|
|
73
|
+
* apply). */
|
|
74
|
+
resetUsage() {
|
|
75
|
+
this.usage = emptyUsageTracker();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Compose the caller's AbortSignal with a hard per-request deadline.
|
|
79
|
+
*
|
|
80
|
+
* The provider SDKs accept a `timeout`, but in practice it does NOT fire for
|
|
81
|
+
* a *half-dead socket* (TCP connected, keep-alives flowing, but no response
|
|
82
|
+
* bytes) — we have observed real requests hang 15–33 minutes before the SDK
|
|
83
|
+
* finally surfaced "Socket timeout". The streaming idle-watchdog only covers
|
|
84
|
+
* the gap BETWEEN chunks, not connection setup / first byte, and non-stream
|
|
85
|
+
* calls don't go through it at all. An explicit AbortSignal.timeout is the
|
|
86
|
+
* one mechanism that reliably tears such a request down.
|
|
87
|
+
*
|
|
88
|
+
* Returns a signal to hand the SDK (`{ signal }`) plus a `cleanup()` to clear
|
|
89
|
+
* the timer once the request settles. The deadline is generous (default 2×
|
|
90
|
+
* the SDK timeout, min 120s) — long enough for slow-but-alive generations,
|
|
91
|
+
* short enough that a wedged socket can't burn half an hour.
|
|
92
|
+
*/
|
|
93
|
+
withRequestDeadline(callerSignal) {
|
|
94
|
+
const deadlineMs = Math.max(this.timeout * 2, 120_000);
|
|
95
|
+
const deadline = AbortSignal.timeout(deadlineMs);
|
|
96
|
+
// AbortSignal.any is available in Node ≥20 / Bun; combine so EITHER the
|
|
97
|
+
// user's cancel OR the deadline aborts the request.
|
|
98
|
+
const signal = callerSignal
|
|
99
|
+
? AbortSignal.any([callerSignal, deadline])
|
|
100
|
+
: deadline;
|
|
101
|
+
// AbortSignal.timeout's timer is unref'd by the runtime; no manual clear is
|
|
102
|
+
// strictly required, but expose cleanup for symmetry / future tightening.
|
|
103
|
+
return { signal, cleanup: () => { } };
|
|
104
|
+
}
|
|
105
|
+
async withRetry(fn, opts) {
|
|
106
|
+
const attempts = opts?.maxAttempts ?? this.retryMaxAttempts;
|
|
107
|
+
const signal = opts?.signal;
|
|
66
108
|
let lastError;
|
|
67
109
|
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
110
|
+
// Bail BEFORE issuing (or re-issuing) the request if the run was
|
|
111
|
+
// cancelled. Without this, a cancel that lands during a backoff sleep —
|
|
112
|
+
// or while a flaky connection hangs — still re-fires the same doomed
|
|
113
|
+
// request, so the user's Stop "does nothing" until all attempts +
|
|
114
|
+
// backoffs drain (~50 s for a 3× Connection-error loop). Checking here
|
|
115
|
+
// makes Cancel take effect at the next retry boundary.
|
|
116
|
+
if (signal?.aborted) {
|
|
117
|
+
throw new DOMException("Request cancelled", "AbortError");
|
|
118
|
+
}
|
|
119
|
+
// Per-attempt hard deadline composed with the caller's cancel signal.
|
|
120
|
+
// A half-dead socket that ignores the SDK timeout is torn down here.
|
|
121
|
+
const { signal: requestSignal, cleanup } = this.withRequestDeadline(signal);
|
|
68
122
|
try {
|
|
69
|
-
return await fn();
|
|
123
|
+
return await fn(requestSignal);
|
|
70
124
|
}
|
|
71
125
|
catch (err) {
|
|
72
126
|
lastError = err;
|
|
73
127
|
if (err instanceof ContextLimitError)
|
|
74
128
|
throw err;
|
|
129
|
+
// Distinguish a deadline tear-down from a user cancel. When the caller
|
|
130
|
+
// did NOT abort but the request signal did, the per-request deadline
|
|
131
|
+
// fired (wedged socket). That is RETRYABLE — fall through to the normal
|
|
132
|
+
// retry/backoff path rather than the abort-no-retry guard below, since
|
|
133
|
+
// the upstream may have just recovered.
|
|
134
|
+
const deadlineFired = !signal?.aborted && requestSignal.aborted;
|
|
135
|
+
if (deadlineFired) {
|
|
136
|
+
logger.warn("llm.request_deadline", {
|
|
137
|
+
cat: "llm",
|
|
138
|
+
provider: this.provider,
|
|
139
|
+
model: this.model,
|
|
140
|
+
attempt,
|
|
141
|
+
of: attempts,
|
|
142
|
+
});
|
|
143
|
+
if (attempt < attempts) {
|
|
144
|
+
const backoff = Math.min(1000 * Math.pow(2, attempt - 1), 30_000);
|
|
145
|
+
if (await abortableSleep(backoff, signal)) {
|
|
146
|
+
throw new DOMException("Request cancelled during retry backoff", "AbortError");
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
throw new LLMError(`request exceeded deadline (${Math.max(this.timeout * 2, 120_000)}ms) — connection wedged`, this.provider);
|
|
151
|
+
}
|
|
75
152
|
// User pressed ESC / Stop, or the run's AbortSignal fired. The SDK
|
|
76
153
|
// throws APIUserAbortError (no HTTP status, so isClientError below
|
|
77
154
|
// can't catch it). Retrying re-issues the same aborted request 3×
|
|
78
155
|
// with growing backoff — ~40 s of dead time ending in llm.exhausted,
|
|
79
156
|
// for work the user explicitly cancelled. Surface immediately.
|
|
80
|
-
|
|
157
|
+
// Also catch the case where the run aborted but the underlying error
|
|
158
|
+
// surfaced as a generic Connection error (not an SDK abort): the
|
|
159
|
+
// signal is the authoritative "user cancelled" source.
|
|
160
|
+
if (isAbortError(err) || signal?.aborted) {
|
|
81
161
|
logger.warn("llm.abort_no_retry", {
|
|
82
162
|
cat: "llm",
|
|
83
163
|
provider: this.provider,
|
|
@@ -97,7 +177,9 @@ export class LLMClientBase {
|
|
|
97
177
|
reason: "rate_limit",
|
|
98
178
|
waitMs,
|
|
99
179
|
});
|
|
100
|
-
|
|
180
|
+
if (await abortableSleep(waitMs, signal)) {
|
|
181
|
+
throw new DOMException("Request cancelled during retry backoff", "AbortError");
|
|
182
|
+
}
|
|
101
183
|
continue;
|
|
102
184
|
}
|
|
103
185
|
// 4xx (except 429, handled above as LLMRateLimitError) is a
|
|
@@ -136,12 +218,36 @@ export class LLMClientBase {
|
|
|
136
218
|
error: err.message,
|
|
137
219
|
backoffMs: backoff,
|
|
138
220
|
});
|
|
139
|
-
|
|
221
|
+
if (await abortableSleep(backoff, signal)) {
|
|
222
|
+
throw new DOMException("Request cancelled during retry backoff", "AbortError");
|
|
223
|
+
}
|
|
140
224
|
}
|
|
141
225
|
}
|
|
142
226
|
throw lastError ?? new LLMError("Unknown LLM error");
|
|
143
227
|
}
|
|
144
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Sleep `ms`, but wake immediately if `signal` aborts. Returns true when it
|
|
231
|
+
* woke due to an abort (caller should bail), false on a normal timeout.
|
|
232
|
+
* Without this an abort during a retry backoff is invisible until the timer
|
|
233
|
+
* fires — the root cause of "Stop does nothing" during a flaky-connection
|
|
234
|
+
* retry loop.
|
|
235
|
+
*/
|
|
236
|
+
function abortableSleep(ms, signal) {
|
|
237
|
+
if (signal?.aborted)
|
|
238
|
+
return Promise.resolve(true);
|
|
239
|
+
return new Promise((resolve) => {
|
|
240
|
+
const timer = setTimeout(() => {
|
|
241
|
+
signal?.removeEventListener("abort", onAbort);
|
|
242
|
+
resolve(false);
|
|
243
|
+
}, ms);
|
|
244
|
+
const onAbort = () => {
|
|
245
|
+
clearTimeout(timer);
|
|
246
|
+
resolve(true);
|
|
247
|
+
};
|
|
248
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
249
|
+
});
|
|
250
|
+
}
|
|
145
251
|
/**
|
|
146
252
|
* Detect HTTP 4xx errors from provider SDKs so withRetry can bail
|
|
147
253
|
* without burning backoff time. OpenAI/Anthropic SDKs attach a numeric
|
package/dist/llm/model-cache.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* reads, isStale just checks. Malformed/missing files yield undefined.
|
|
7
7
|
*/
|
|
8
8
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
9
|
-
import { homedir } from "node:os";
|
|
10
9
|
import { join } from "node:path";
|
|
10
|
+
import { userHome } from "../settings/manager.js";
|
|
11
11
|
const TTL_MS = 7 * 24 * 3600 * 1000;
|
|
12
12
|
export function readCache(cacheDir, providerKey) {
|
|
13
13
|
const path = join(cacheDir, `${providerKey}.json`);
|
|
@@ -42,5 +42,7 @@ export function isStale(file, now = Date.now()) {
|
|
|
42
42
|
return now - ts > TTL_MS;
|
|
43
43
|
}
|
|
44
44
|
export function defaultCacheDir() {
|
|
45
|
-
|
|
45
|
+
// userHome() (not raw homedir(), which bun caches at process start) so a
|
|
46
|
+
// relocated/test HOME redirects the cache dir instead of writing real ~/.code-shell.
|
|
47
|
+
return join(userHome(), ".code-shell", "cache", "models");
|
|
46
48
|
}
|
package/dist/llm/model-pool.d.ts
CHANGED
|
@@ -21,20 +21,39 @@ export interface ModelEntry {
|
|
|
21
21
|
provider: string;
|
|
22
22
|
/** Full model path: "anthropic/claude-opus-4-6" */
|
|
23
23
|
model: string;
|
|
24
|
+
/**
|
|
25
|
+
* Catalog/provider kind used by capability rules. This can differ from
|
|
26
|
+
* `provider`, which only selects the client protocol family.
|
|
27
|
+
*/
|
|
28
|
+
providerKind?: string;
|
|
24
29
|
baseUrl?: string;
|
|
25
30
|
apiKey?: string;
|
|
31
|
+
/** Whether the catalog template requires a key (default true; false = local/
|
|
32
|
+
* no-auth provider). Used by resolveLLMConfigForTag to reject a key-needing
|
|
33
|
+
* connection that has no resolved key with a clear error rather than a 401. */
|
|
34
|
+
needsKey?: boolean;
|
|
26
35
|
maxOutputTokens?: number;
|
|
27
36
|
/** Per-model context window size. Falls back to config.maxContextTokens → 200_000. */
|
|
28
37
|
maxContextTokens?: number;
|
|
29
38
|
/** Optional reference into ProviderCatalog. When set, baseUrl/apiKey
|
|
30
39
|
* come from the catalog unless the entry overrides them. */
|
|
31
40
|
providerKey?: string;
|
|
41
|
+
/** Per-model external token command; overrides provider-level (TODO 7.2). */
|
|
42
|
+
authCommand?: string;
|
|
43
|
+
/** Per-model extra HTTP headers; merged over provider-level (TODO 7.2). */
|
|
44
|
+
httpHeaders?: Record<string, string>;
|
|
45
|
+
/** OpenAI `service_tier` request param (TODO 7.2). */
|
|
46
|
+
serviceTier?: string;
|
|
47
|
+
/** OpenAI reasoning `summary` control (TODO 7.2). */
|
|
48
|
+
reasoningSummary?: string;
|
|
32
49
|
/**
|
|
33
50
|
* Per-model reasoning override. Wins over the provider-level setting
|
|
34
51
|
* (ProviderCatalog entry's `reasoning`). Useful when models in the same
|
|
35
52
|
* provider need different defaults — e.g. one model off but another on.
|
|
36
53
|
*/
|
|
37
54
|
reasoning?: import("./reasoning-setting.js").ReasoningSetting;
|
|
55
|
+
/** Catalog-driven extra request-body fields (wire-mapped paramValues). */
|
|
56
|
+
extraBody?: Record<string, unknown>;
|
|
38
57
|
}
|
|
39
58
|
export declare class ModelPool {
|
|
40
59
|
private models;
|
|
@@ -65,6 +84,8 @@ export declare class ModelPool {
|
|
|
65
84
|
* The first entry (or the one matching `defaultKey`) becomes active.
|
|
66
85
|
*/
|
|
67
86
|
constructor(entries?: ModelEntry[], defaultKey?: string);
|
|
87
|
+
/** Clear all registered models and active selection. */
|
|
88
|
+
clear(): void;
|
|
68
89
|
/** Register a model at runtime. */
|
|
69
90
|
register(entry: ModelEntry): void;
|
|
70
91
|
/** Fill in known defaults (e.g. context window for DeepSeek V4) when the entry doesn't specify them. */
|
package/dist/llm/model-pool.js
CHANGED
|
@@ -142,6 +142,11 @@ export class ModelPool {
|
|
|
142
142
|
this.activeKey = entries[0].key;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
/** Clear all registered models and active selection. */
|
|
146
|
+
clear() {
|
|
147
|
+
this.models.clear();
|
|
148
|
+
this.activeKey = undefined;
|
|
149
|
+
}
|
|
145
150
|
/** Register a model at runtime. */
|
|
146
151
|
register(entry) {
|
|
147
152
|
this.models.set(entry.key, this.withBuiltinDefaults(entry));
|
|
@@ -216,6 +221,7 @@ export class ModelPool {
|
|
|
216
221
|
return "anthropic";
|
|
217
222
|
return "openai";
|
|
218
223
|
};
|
|
224
|
+
const providerKind = entry.providerKind ?? fromCat?.kind;
|
|
219
225
|
return {
|
|
220
226
|
provider: entry.provider ||
|
|
221
227
|
kindToClientProvider(fromCat?.kind) ||
|
|
@@ -228,13 +234,27 @@ export class ModelPool {
|
|
|
228
234
|
// instead of fabricating 8192, which silently truncates long outputs and
|
|
229
235
|
// masks the real per-model cap.
|
|
230
236
|
maxTokens: entry.maxOutputTokens,
|
|
237
|
+
...(entry.maxContextTokens !== undefined ? { maxContextTokens: entry.maxContextTokens } : {}),
|
|
231
238
|
// reasoning: entry overrides catalog. No base fallback — see class doc.
|
|
232
239
|
...(entry.reasoning ?? fromCat?.reasoning
|
|
233
240
|
? { reasoning: entry.reasoning ?? fromCat?.reasoning }
|
|
234
241
|
: {}),
|
|
242
|
+
// Auth command: entry overrides catalog. (TODO 7.2)
|
|
243
|
+
...(entry.authCommand ?? fromCat?.authCommand
|
|
244
|
+
? { authCommand: entry.authCommand ?? fromCat?.authCommand }
|
|
245
|
+
: {}),
|
|
246
|
+
// HTTP headers: merge catalog (base) then entry (override). (TODO 7.2)
|
|
247
|
+
...(fromCat?.httpHeaders || entry.httpHeaders
|
|
248
|
+
? { httpHeaders: { ...fromCat?.httpHeaders, ...entry.httpHeaders } }
|
|
249
|
+
: {}),
|
|
250
|
+
...(entry.serviceTier ? { serviceTier: entry.serviceTier } : {}),
|
|
251
|
+
...(entry.reasoningSummary ? { reasoningSummary: entry.reasoningSummary } : {}),
|
|
235
252
|
// Carry the catalog kind through so the capability layer can pick
|
|
236
253
|
// per-(kind, model) request-shape rules.
|
|
237
|
-
...(
|
|
254
|
+
...(providerKind ? { providerKind } : {}),
|
|
255
|
+
...(entry.extraBody && Object.keys(entry.extraBody).length > 0
|
|
256
|
+
? { extraBody: entry.extraBody }
|
|
257
|
+
: {}),
|
|
238
258
|
};
|
|
239
259
|
}
|
|
240
260
|
/**
|