@cjhyy/code-shell-core 0.5.0-rc.0
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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/agent/coordinator.d.ts +49 -0
- package/dist/agent/coordinator.js +77 -0
- package/dist/arena/arena.d.ts +43 -0
- package/dist/arena/arena.js +334 -0
- package/dist/arena/context/context-tools.d.ts +16 -0
- package/dist/arena/context/context-tools.js +231 -0
- package/dist/arena/detect-mode.d.ts +20 -0
- package/dist/arena/detect-mode.js +78 -0
- package/dist/arena/digest-builder.d.ts +25 -0
- package/dist/arena/digest-builder.js +120 -0
- package/dist/arena/index.d.ts +29 -0
- package/dist/arena/index.js +29 -0
- package/dist/arena/iterate/convergence.d.ts +25 -0
- package/dist/arena/iterate/convergence.js +103 -0
- package/dist/arena/iterate/formats/index.d.ts +22 -0
- package/dist/arena/iterate/formats/index.js +283 -0
- package/dist/arena/iterate/index.d.ts +11 -0
- package/dist/arena/iterate/index.js +9 -0
- package/dist/arena/iterate/iterative-arena.d.ts +23 -0
- package/dist/arena/iterate/iterative-arena.js +237 -0
- package/dist/arena/iterate/parse.d.ts +42 -0
- package/dist/arena/iterate/parse.js +123 -0
- package/dist/arena/iterate/phases/argue.d.ts +22 -0
- package/dist/arena/iterate/phases/argue.js +159 -0
- package/dist/arena/iterate/phases/revise.d.ts +16 -0
- package/dist/arena/iterate/phases/revise.js +62 -0
- package/dist/arena/iterate/phases/tournament.d.ts +34 -0
- package/dist/arena/iterate/phases/tournament.js +113 -0
- package/dist/arena/iterate/tools/web-tools.d.ts +13 -0
- package/dist/arena/iterate/tools/web-tools.js +54 -0
- package/dist/arena/iterate/types.d.ts +152 -0
- package/dist/arena/iterate/types.js +8 -0
- package/dist/arena/ledger.d.ts +47 -0
- package/dist/arena/ledger.js +151 -0
- package/dist/arena/lenses/architecture.d.ts +5 -0
- package/dist/arena/lenses/architecture.js +22 -0
- package/dist/arena/lenses/engineering.d.ts +5 -0
- package/dist/arena/lenses/engineering.js +22 -0
- package/dist/arena/lenses/general.d.ts +5 -0
- package/dist/arena/lenses/general.js +20 -0
- package/dist/arena/lenses/index.d.ts +16 -0
- package/dist/arena/lenses/index.js +47 -0
- package/dist/arena/lenses/product.d.ts +5 -0
- package/dist/arena/lenses/product.js +22 -0
- package/dist/arena/model-presets.d.ts +23 -0
- package/dist/arena/model-presets.js +44 -0
- package/dist/arena/phases/adjudication.d.ts +24 -0
- package/dist/arena/phases/adjudication.js +144 -0
- package/dist/arena/phases/build-consensus.d.ts +29 -0
- package/dist/arena/phases/build-consensus.js +86 -0
- package/dist/arena/phases/claim-registry.d.ts +26 -0
- package/dist/arena/phases/claim-registry.js +60 -0
- package/dist/arena/phases/cross-review.d.ts +45 -0
- package/dist/arena/phases/cross-review.js +224 -0
- package/dist/arena/phases/debate-rounds.d.ts +27 -0
- package/dist/arena/phases/debate-rounds.js +162 -0
- package/dist/arena/phases/participant-research.d.ts +38 -0
- package/dist/arena/phases/participant-research.js +317 -0
- package/dist/arena/phases/planning-detail-expansion.d.ts +38 -0
- package/dist/arena/phases/planning-detail-expansion.js +121 -0
- package/dist/arena/planner.d.ts +27 -0
- package/dist/arena/planner.js +312 -0
- package/dist/arena/providers/docs.d.ts +6 -0
- package/dist/arena/providers/docs.js +108 -0
- package/dist/arena/providers/git.d.ts +8 -0
- package/dist/arena/providers/git.js +174 -0
- package/dist/arena/providers/index.d.ts +32 -0
- package/dist/arena/providers/index.js +132 -0
- package/dist/arena/providers/none.d.ts +7 -0
- package/dist/arena/providers/none.js +11 -0
- package/dist/arena/providers/repo.d.ts +6 -0
- package/dist/arena/providers/repo.js +255 -0
- package/dist/arena/render/session.d.ts +17 -0
- package/dist/arena/render/session.js +190 -0
- package/dist/arena/render/terminal.d.ts +34 -0
- package/dist/arena/render/terminal.js +286 -0
- package/dist/arena/strategies/discussion.d.ts +25 -0
- package/dist/arena/strategies/discussion.js +143 -0
- package/dist/arena/strategies/index.d.ts +15 -0
- package/dist/arena/strategies/index.js +28 -0
- package/dist/arena/strategies/language-wrapper.d.ts +17 -0
- package/dist/arena/strategies/language-wrapper.js +102 -0
- package/dist/arena/strategies/lens-wrapper.d.ts +16 -0
- package/dist/arena/strategies/lens-wrapper.js +236 -0
- package/dist/arena/strategies/planning.d.ts +30 -0
- package/dist/arena/strategies/planning.js +225 -0
- package/dist/arena/strategies/review.d.ts +26 -0
- package/dist/arena/strategies/review.js +168 -0
- package/dist/arena/strategies/utils.d.ts +39 -0
- package/dist/arena/strategies/utils.js +647 -0
- package/dist/arena/tools/selector.d.ts +17 -0
- package/dist/arena/tools/selector.js +61 -0
- package/dist/arena/transitions.d.ts +48 -0
- package/dist/arena/transitions.js +92 -0
- package/dist/arena/types.d.ts +508 -0
- package/dist/arena/types.js +27 -0
- package/dist/cli/agent-server-stdio.d.ts +32 -0
- package/dist/cli/agent-server-stdio.js +116 -0
- package/dist/colorizer.d.ts +23 -0
- package/dist/colorizer.js +12 -0
- package/dist/context/compaction.d.ts +116 -0
- package/dist/context/compaction.js +534 -0
- package/dist/context/manager.d.ts +145 -0
- package/dist/context/manager.js +423 -0
- package/dist/context/token-counter.d.ts +27 -0
- package/dist/context/token-counter.js +91 -0
- package/dist/context/tool-result-storage.d.ts +96 -0
- package/dist/context/tool-result-storage.js +296 -0
- package/dist/cost-tracker.d.ts +64 -0
- package/dist/cost-tracker.js +314 -0
- package/dist/cron/scheduler.d.ts +34 -0
- package/dist/cron/scheduler.js +115 -0
- package/dist/data/deepseek-models.json +46 -0
- package/dist/data/gemini-models.json +67 -0
- package/dist/data/openai-models.json +175 -0
- package/dist/data/openrouter-models.d.ts +35 -0
- package/dist/data/openrouter-models.js +36 -0
- package/dist/data/openrouter-models.json +4626 -0
- package/dist/data/openrouter-sync.d.ts +16 -0
- package/dist/data/openrouter-sync.js +53 -0
- package/dist/data/static-catalogs.d.ts +25 -0
- package/dist/data/static-catalogs.js +26 -0
- package/dist/data/zai-models.json +56 -0
- package/dist/engine/cost-store.d.ts +22 -0
- package/dist/engine/cost-store.js +15 -0
- package/dist/engine/engine.d.ts +295 -0
- package/dist/engine/engine.js +1467 -0
- package/dist/engine/model-facade.d.ts +24 -0
- package/dist/engine/model-facade.js +194 -0
- package/dist/engine/parse-task.d.ts +59 -0
- package/dist/engine/parse-task.js +135 -0
- package/dist/engine/patch-orphaned-tools.d.ts +52 -0
- package/dist/engine/patch-orphaned-tools.js +95 -0
- package/dist/engine/query.d.ts +50 -0
- package/dist/engine/query.js +107 -0
- package/dist/engine/runtime.d.ts +50 -0
- package/dist/engine/runtime.js +59 -0
- package/dist/engine/streaming-tool-queue.d.ts +34 -0
- package/dist/engine/streaming-tool-queue.js +61 -0
- package/dist/engine/token-budget.d.ts +22 -0
- package/dist/engine/token-budget.js +40 -0
- package/dist/engine/tool-summary.d.ts +13 -0
- package/dist/engine/tool-summary.js +35 -0
- package/dist/engine/turn-loop.d.ts +122 -0
- package/dist/engine/turn-loop.js +602 -0
- package/dist/engine/turn-state.d.ts +20 -0
- package/dist/engine/turn-state.js +17 -0
- package/dist/exceptions.d.ts +61 -0
- package/dist/exceptions.js +116 -0
- package/dist/git/utils.d.ts +35 -0
- package/dist/git/utils.js +98 -0
- package/dist/git/worktree.d.ts +36 -0
- package/dist/git/worktree.js +139 -0
- package/dist/hooks/events.d.ts +114 -0
- package/dist/hooks/events.js +4 -0
- package/dist/hooks/inject.d.ts +19 -0
- package/dist/hooks/inject.js +29 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +84 -0
- package/dist/hooks/shell-runner.d.ts +45 -0
- package/dist/hooks/shell-runner.js +173 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +145 -0
- package/dist/llm/api-key-sanitize.d.ts +22 -0
- package/dist/llm/api-key-sanitize.js +81 -0
- package/dist/llm/capabilities/index.d.ts +20 -0
- package/dist/llm/capabilities/index.js +39 -0
- package/dist/llm/capabilities/rules.d.ts +26 -0
- package/dist/llm/capabilities/rules.js +215 -0
- package/dist/llm/capabilities/types.d.ts +114 -0
- package/dist/llm/capabilities/types.js +24 -0
- package/dist/llm/client-base.d.ts +29 -0
- package/dist/llm/client-base.js +137 -0
- package/dist/llm/client-factory.d.ts +10 -0
- package/dist/llm/client-factory.js +29 -0
- package/dist/llm/model-cache.d.ts +21 -0
- package/dist/llm/model-cache.js +46 -0
- package/dist/llm/model-fetcher.d.ts +29 -0
- package/dist/llm/model-fetcher.js +282 -0
- package/dist/llm/model-pool.d.ts +95 -0
- package/dist/llm/model-pool.js +246 -0
- package/dist/llm/provider-catalog.d.ts +32 -0
- package/dist/llm/provider-catalog.js +50 -0
- package/dist/llm/provider-kinds.d.ts +21 -0
- package/dist/llm/provider-kinds.js +132 -0
- package/dist/llm/providers/anthropic.d.ts +19 -0
- package/dist/llm/providers/anthropic.js +267 -0
- package/dist/llm/providers/openai.d.ts +64 -0
- package/dist/llm/providers/openai.js +606 -0
- package/dist/llm/retry.d.ts +12 -0
- package/dist/llm/retry.js +17 -0
- package/dist/llm/stream-watchdog.d.ts +42 -0
- package/dist/llm/stream-watchdog.js +70 -0
- package/dist/llm/token-counter.d.ts +17 -0
- package/dist/llm/token-counter.js +36 -0
- package/dist/llm/types.d.ts +37 -0
- package/dist/llm/types.js +4 -0
- package/dist/logging/logger.d.ts +109 -0
- package/dist/logging/logger.js +390 -0
- package/dist/logging/sanitize-messages.d.ts +42 -0
- package/dist/logging/sanitize-messages.js +150 -0
- package/dist/logging/session-recorder.d.ts +90 -0
- package/dist/logging/session-recorder.js +304 -0
- package/dist/lsp/client.d.ts +41 -0
- package/dist/lsp/client.js +166 -0
- package/dist/lsp/manager.d.ts +40 -0
- package/dist/lsp/manager.js +124 -0
- package/dist/lsp/servers.d.ts +16 -0
- package/dist/lsp/servers.js +60 -0
- package/dist/migrate-models.d.ts +45 -0
- package/dist/migrate-models.js +179 -0
- package/dist/onboarding.d.ts +189 -0
- package/dist/onboarding.js +625 -0
- package/dist/plugins/gitOps.d.ts +32 -0
- package/dist/plugins/gitOps.js +62 -0
- package/dist/plugins/installedPlugins.d.ts +15 -0
- package/dist/plugins/installedPlugins.js +56 -0
- package/dist/plugins/knownMarketplaces.d.ts +10 -0
- package/dist/plugins/knownMarketplaces.js +46 -0
- package/dist/plugins/loadPluginHooks.d.ts +52 -0
- package/dist/plugins/loadPluginHooks.js +162 -0
- package/dist/plugins/marketplaceManager.d.ts +49 -0
- package/dist/plugins/marketplaceManager.js +142 -0
- package/dist/plugins/parseMarketplaceInput.d.ts +16 -0
- package/dist/plugins/parseMarketplaceInput.js +73 -0
- package/dist/plugins/pluginCommandHook.d.ts +54 -0
- package/dist/plugins/pluginCommandHook.js +180 -0
- package/dist/plugins/pluginCommandsLoader.d.ts +25 -0
- package/dist/plugins/pluginCommandsLoader.js +114 -0
- package/dist/plugins/pluginInstaller.d.ts +36 -0
- package/dist/plugins/pluginInstaller.js +228 -0
- package/dist/plugins/schemas.d.ts +9 -0
- package/dist/plugins/schemas.js +136 -0
- package/dist/plugins/types.d.ts +75 -0
- package/dist/plugins/types.js +7 -0
- package/dist/plugins/varRewrite.d.ts +42 -0
- package/dist/plugins/varRewrite.js +129 -0
- package/dist/preset/index.d.ts +60 -0
- package/dist/preset/index.js +159 -0
- package/dist/product/define.d.ts +60 -0
- package/dist/product/define.js +123 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.js +4 -0
- package/dist/product/types.d.ts +111 -0
- package/dist/product/types.js +21 -0
- package/dist/prompt/composer.d.ts +49 -0
- package/dist/prompt/composer.js +168 -0
- package/dist/prompt/instruction-scanner.d.ts +54 -0
- package/dist/prompt/instruction-scanner.js +187 -0
- package/dist/prompt/section-cache.d.ts +15 -0
- package/dist/prompt/section-cache.js +31 -0
- package/dist/prompt/section-loader.d.ts +26 -0
- package/dist/prompt/section-loader.js +53 -0
- package/dist/prompt/sections/base.md +35 -0
- package/dist/prompt/sections/coding.md +31 -0
- package/dist/prompt/sections/orchestration.md +16 -0
- package/dist/prompt/sections/tone.md +9 -0
- package/dist/protocol/chat-session-manager.d.ts +33 -0
- package/dist/protocol/chat-session-manager.js +65 -0
- package/dist/protocol/chat-session.d.ts +49 -0
- package/dist/protocol/chat-session.js +86 -0
- package/dist/protocol/client.d.ts +104 -0
- package/dist/protocol/client.js +260 -0
- package/dist/protocol/factories.d.ts +93 -0
- package/dist/protocol/factories.js +64 -0
- package/dist/protocol/helpers.d.ts +42 -0
- package/dist/protocol/helpers.js +55 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +4 -0
- package/dist/protocol/server.d.ts +80 -0
- package/dist/protocol/server.js +855 -0
- package/dist/protocol/transport.d.ts +37 -0
- package/dist/protocol/transport.js +85 -0
- package/dist/protocol/types.d.ts +221 -0
- package/dist/protocol/types.js +61 -0
- package/dist/remote/bridge.d.ts +37 -0
- package/dist/remote/bridge.js +103 -0
- package/dist/run/ArtifactTracker.d.ts +38 -0
- package/dist/run/ArtifactTracker.js +132 -0
- package/dist/run/CheckpointWriter.d.ts +53 -0
- package/dist/run/CheckpointWriter.js +135 -0
- package/dist/run/EngineRunner.d.ts +72 -0
- package/dist/run/EngineRunner.js +119 -0
- package/dist/run/Evaluator.d.ts +56 -0
- package/dist/run/Evaluator.js +62 -0
- package/dist/run/FileRunStore.d.ts +39 -0
- package/dist/run/FileRunStore.js +176 -0
- package/dist/run/Heartbeat.d.ts +54 -0
- package/dist/run/Heartbeat.js +123 -0
- package/dist/run/RunApprovalBackend.d.ts +53 -0
- package/dist/run/RunApprovalBackend.js +85 -0
- package/dist/run/RunLock.d.ts +40 -0
- package/dist/run/RunLock.js +98 -0
- package/dist/run/RunManager.d.ts +82 -0
- package/dist/run/RunManager.js +587 -0
- package/dist/run/RunQueue.d.ts +27 -0
- package/dist/run/RunQueue.js +73 -0
- package/dist/run/RunStore.d.ts +25 -0
- package/dist/run/RunStore.js +9 -0
- package/dist/run/factory.d.ts +63 -0
- package/dist/run/factory.js +51 -0
- package/dist/run/index.d.ts +17 -0
- package/dist/run/index.js +23 -0
- package/dist/run/types.d.ts +136 -0
- package/dist/run/types.js +28 -0
- package/dist/runtime/safe-spawn.d.ts +118 -0
- package/dist/runtime/safe-spawn.js +268 -0
- package/dist/services/analytics.d.ts +29 -0
- package/dist/services/analytics.js +84 -0
- package/dist/services/auto-dream.d.ts +49 -0
- package/dist/services/auto-dream.js +124 -0
- package/dist/services/diagnostics.d.ts +41 -0
- package/dist/services/diagnostics.js +99 -0
- package/dist/services/extract-memories.d.ts +31 -0
- package/dist/services/extract-memories.js +71 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +17 -0
- package/dist/services/memory-orchestrator.d.ts +60 -0
- package/dist/services/memory-orchestrator.js +133 -0
- package/dist/services/notifier.d.ts +25 -0
- package/dist/services/notifier.js +69 -0
- package/dist/services/oauth.d.ts +27 -0
- package/dist/services/oauth.js +153 -0
- package/dist/services/session-memory.d.ts +37 -0
- package/dist/services/session-memory.js +81 -0
- package/dist/session/file-history.d.ts +41 -0
- package/dist/session/file-history.js +115 -0
- package/dist/session/memory.d.ts +104 -0
- package/dist/session/memory.js +310 -0
- package/dist/session/session-manager.d.ts +41 -0
- package/dist/session/session-manager.js +261 -0
- package/dist/session/transcript.d.ts +39 -0
- package/dist/session/transcript.js +186 -0
- package/dist/settings/manager.d.ts +36 -0
- package/dist/settings/manager.js +187 -0
- package/dist/settings/schema.d.ts +1219 -0
- package/dist/settings/schema.js +246 -0
- package/dist/skills/frontmatter.d.ts +13 -0
- package/dist/skills/frontmatter.js +70 -0
- package/dist/skills/index.d.ts +7 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/scanner.d.ts +31 -0
- package/dist/skills/scanner.js +171 -0
- package/dist/state.d.ts +160 -0
- package/dist/state.js +267 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +84 -0
- package/dist/tool-system/builtin/agent-notifications.js +197 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +67 -0
- package/dist/tool-system/builtin/agent-registry.js +126 -0
- package/dist/tool-system/builtin/agent-transcript-translator.d.ts +22 -0
- package/dist/tool-system/builtin/agent-transcript-translator.js +160 -0
- package/dist/tool-system/builtin/agent.d.ts +16 -0
- package/dist/tool-system/builtin/agent.js +364 -0
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
- package/dist/tool-system/builtin/apply-patch/applier.js +250 -0
- package/dist/tool-system/builtin/apply-patch/index.d.ts +20 -0
- package/dist/tool-system/builtin/apply-patch/index.js +101 -0
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
- package/dist/tool-system/builtin/apply-patch/parser.js +212 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.js +123 -0
- package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
- package/dist/tool-system/builtin/apply-patch/types.js +13 -0
- package/dist/tool-system/builtin/arena.d.ts +31 -0
- package/dist/tool-system/builtin/arena.js +416 -0
- package/dist/tool-system/builtin/ask-user.d.ts +20 -0
- package/dist/tool-system/builtin/ask-user.js +99 -0
- package/dist/tool-system/builtin/bash.d.ts +21 -0
- package/dist/tool-system/builtin/bash.js +149 -0
- package/dist/tool-system/builtin/brief.d.ts +6 -0
- package/dist/tool-system/builtin/brief.js +41 -0
- package/dist/tool-system/builtin/config.d.ts +6 -0
- package/dist/tool-system/builtin/config.js +67 -0
- package/dist/tool-system/builtin/cron.d.ts +10 -0
- package/dist/tool-system/builtin/cron.js +61 -0
- package/dist/tool-system/builtin/edit.d.ts +6 -0
- package/dist/tool-system/builtin/edit.js +100 -0
- package/dist/tool-system/builtin/file-cache.d.ts +11 -0
- package/dist/tool-system/builtin/file-cache.js +39 -0
- package/dist/tool-system/builtin/glob.d.ts +7 -0
- package/dist/tool-system/builtin/glob.js +76 -0
- package/dist/tool-system/builtin/grep.d.ts +7 -0
- package/dist/tool-system/builtin/grep.js +150 -0
- package/dist/tool-system/builtin/index.d.ts +20 -0
- package/dist/tool-system/builtin/index.js +449 -0
- package/dist/tool-system/builtin/lsp.d.ts +6 -0
- package/dist/tool-system/builtin/lsp.js +141 -0
- package/dist/tool-system/builtin/mcp-tools.d.ts +10 -0
- package/dist/tool-system/builtin/mcp-tools.js +102 -0
- package/dist/tool-system/builtin/memory.d.ts +26 -0
- package/dist/tool-system/builtin/memory.js +226 -0
- package/dist/tool-system/builtin/notebook-edit.d.ts +6 -0
- package/dist/tool-system/builtin/notebook-edit.js +124 -0
- package/dist/tool-system/builtin/plan.d.ts +15 -0
- package/dist/tool-system/builtin/plan.js +55 -0
- package/dist/tool-system/builtin/powershell.d.ts +11 -0
- package/dist/tool-system/builtin/powershell.js +64 -0
- package/dist/tool-system/builtin/read.d.ts +6 -0
- package/dist/tool-system/builtin/read.js +70 -0
- package/dist/tool-system/builtin/remote-trigger.d.ts +6 -0
- package/dist/tool-system/builtin/remote-trigger.js +54 -0
- package/dist/tool-system/builtin/repl.d.ts +11 -0
- package/dist/tool-system/builtin/repl.js +82 -0
- package/dist/tool-system/builtin/send-message.d.ts +6 -0
- package/dist/tool-system/builtin/send-message.js +47 -0
- package/dist/tool-system/builtin/skill-prompt.d.ts +20 -0
- package/dist/tool-system/builtin/skill-prompt.js +52 -0
- package/dist/tool-system/builtin/skill.d.ts +9 -0
- package/dist/tool-system/builtin/skill.js +55 -0
- package/dist/tool-system/builtin/sleep.d.ts +6 -0
- package/dist/tool-system/builtin/sleep.js +33 -0
- package/dist/tool-system/builtin/task.d.ts +48 -0
- package/dist/tool-system/builtin/task.js +139 -0
- package/dist/tool-system/builtin/tool-search.d.ts +11 -0
- package/dist/tool-system/builtin/tool-search.js +90 -0
- package/dist/tool-system/builtin/web-fetch.d.ts +10 -0
- package/dist/tool-system/builtin/web-fetch.js +328 -0
- package/dist/tool-system/builtin/web-search.d.ts +25 -0
- package/dist/tool-system/builtin/web-search.js +174 -0
- package/dist/tool-system/builtin/worktree.d.ts +10 -0
- package/dist/tool-system/builtin/worktree.js +95 -0
- package/dist/tool-system/builtin/write.d.ts +6 -0
- package/dist/tool-system/builtin/write.js +36 -0
- package/dist/tool-system/context.d.ts +165 -0
- package/dist/tool-system/context.js +18 -0
- package/dist/tool-system/executor.d.ts +49 -0
- package/dist/tool-system/executor.js +495 -0
- package/dist/tool-system/investigation-guard.d.ts +46 -0
- package/dist/tool-system/investigation-guard.js +155 -0
- package/dist/tool-system/mcp-manager.d.ts +67 -0
- package/dist/tool-system/mcp-manager.js +249 -0
- package/dist/tool-system/permission.d.ts +111 -0
- package/dist/tool-system/permission.js +774 -0
- package/dist/tool-system/registry.d.ts +32 -0
- package/dist/tool-system/registry.js +131 -0
- package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
- package/dist/tool-system/sandbox/bwrap.js +63 -0
- package/dist/tool-system/sandbox/index.d.ts +78 -0
- package/dist/tool-system/sandbox/index.js +222 -0
- package/dist/tool-system/sandbox/off.d.ts +2 -0
- package/dist/tool-system/sandbox/off.js +8 -0
- package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
- package/dist/tool-system/sandbox/seatbelt.js +109 -0
- package/dist/tool-system/task-guard.d.ts +29 -0
- package/dist/tool-system/task-guard.js +70 -0
- package/dist/tool-system/validation.d.ts +5 -0
- package/dist/tool-system/validation.js +39 -0
- package/dist/types.d.ts +376 -0
- package/dist/types.js +4 -0
- package/dist/updater.d.ts +65 -0
- package/dist/updater.js +405 -0
- package/dist/utils/debug.d.ts +41 -0
- package/dist/utils/debug.js +110 -0
- package/dist/utils/earlyInput.d.ts +43 -0
- package/dist/utils/earlyInput.js +166 -0
- package/dist/utils/env.d.ts +24 -0
- package/dist/utils/env.js +104 -0
- package/dist/utils/envUtils.d.ts +51 -0
- package/dist/utils/envUtils.js +135 -0
- package/dist/utils/execFileNoThrow.d.ts +39 -0
- package/dist/utils/execFileNoThrow.js +74 -0
- package/dist/utils/format.d.ts +44 -0
- package/dist/utils/format.js +236 -0
- package/dist/utils/intl.d.ts +22 -0
- package/dist/utils/intl.js +83 -0
- package/dist/utils/lockfile.d.ts +15 -0
- package/dist/utils/lockfile.js +30 -0
- package/dist/utils/memoize.d.ts +19 -0
- package/dist/utils/memoize.js +14 -0
- package/dist/utils/semver.d.ts +6 -0
- package/dist/utils/semver.js +13 -0
- package/dist/utils/sliceAnsi.d.ts +12 -0
- package/dist/utils/sliceAnsi.js +62 -0
- package/dist/utils/systemTheme.d.ts +40 -0
- package/dist/utils/systemTheme.js +108 -0
- package/dist/utils/task-sanitizer.d.ts +6 -0
- package/dist/utils/task-sanitizer.js +24 -0
- package/dist/utils/theme.d.ts +93 -0
- package/dist/utils/theme.js +544 -0
- package/dist/utils/toolDisplay.d.ts +31 -0
- package/dist/utils/toolDisplay.js +188 -0
- package/package.json +72 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModelPool — runtime model registry.
|
|
3
|
+
*
|
|
4
|
+
* Holds all available models loaded from settings. Provides:
|
|
5
|
+
* - `get(key?)` — retrieve a model config by key, or the active one
|
|
6
|
+
* - `switch(key)` — change the active model
|
|
7
|
+
* - `list()` — list all available models
|
|
8
|
+
* - `register(entry)` — add a model at runtime
|
|
9
|
+
*
|
|
10
|
+
* Consumers:
|
|
11
|
+
* - Engine/TurnLoop: `pool.get()` for the active model
|
|
12
|
+
* - Arena: `pool.get("sonnet")` to resolve participants by key
|
|
13
|
+
* - /model command: `pool.switch("haiku")` for hot-swap
|
|
14
|
+
*/
|
|
15
|
+
import { readCache } from "./model-cache.js";
|
|
16
|
+
import { findOpenRouterModel } from "../data/openrouter-models.js";
|
|
17
|
+
/**
|
|
18
|
+
* Last-resort context window when neither the provider's cached
|
|
19
|
+
* model list nor the OpenRouter snapshot knows the size. Picked
|
|
20
|
+
* to match the most common chat-model default in 2024–2026; better
|
|
21
|
+
* to truncate than to send a request the model will reject.
|
|
22
|
+
*/
|
|
23
|
+
const FALLBACK_CONTEXT_WINDOW = 200_000;
|
|
24
|
+
/**
|
|
25
|
+
* Provider kind → OpenRouter vendor prefix. Mirrors the table in
|
|
26
|
+
* model-fetcher.ts so a missing context window on a direct-provider
|
|
27
|
+
* entry (e.g. OpenAI's `gpt-5.5`) can be patched from the bundled
|
|
28
|
+
* OpenRouter snapshot (`openai/gpt-5.5`). Kinds outside this map
|
|
29
|
+
* (groq/ollama/openrouter/custom) skip the snapshot lookup — the
|
|
30
|
+
* openrouter kind is handled separately since its ids already carry
|
|
31
|
+
* the vendor prefix.
|
|
32
|
+
*/
|
|
33
|
+
const OPENROUTER_VENDOR_BY_KIND = {
|
|
34
|
+
openai: "openai",
|
|
35
|
+
anthropic: "anthropic",
|
|
36
|
+
deepseek: "deepseek",
|
|
37
|
+
google: "google",
|
|
38
|
+
zai: "z-ai",
|
|
39
|
+
xai: "x-ai",
|
|
40
|
+
mistral: "mistralai",
|
|
41
|
+
};
|
|
42
|
+
// ─── Built-in context windows ────────────────────────────────────
|
|
43
|
+
// Known max input tokens for well-known model names. Used as a fallback
|
|
44
|
+
// when a settings entry doesn't specify maxContextTokens, so users don't
|
|
45
|
+
// have to hand-fill it for common models.
|
|
46
|
+
//
|
|
47
|
+
// Patterns are matched against the full `model` string (case-insensitive).
|
|
48
|
+
// First match wins — order from most specific to most generic.
|
|
49
|
+
const BUILTIN_CONTEXT_WINDOWS = [
|
|
50
|
+
// DeepSeek V4 family — 1M context (api-docs.deepseek.com)
|
|
51
|
+
[/^deepseek-v4(?:-|$)/i, 1_000_000],
|
|
52
|
+
[/(?:^|\/)deepseek-v4(?:-|$)/i, 1_000_000],
|
|
53
|
+
];
|
|
54
|
+
function lookupBuiltinContextWindow(model) {
|
|
55
|
+
for (const [re, tokens] of BUILTIN_CONTEXT_WINDOWS) {
|
|
56
|
+
if (re.test(model))
|
|
57
|
+
return tokens;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
// ─── ModelPool ───────────────────────────────────────────────────
|
|
62
|
+
export class ModelPool {
|
|
63
|
+
models = new Map();
|
|
64
|
+
activeKey;
|
|
65
|
+
providerCatalog;
|
|
66
|
+
cacheDir;
|
|
67
|
+
setProviderCatalog(cat) {
|
|
68
|
+
this.providerCatalog = cat;
|
|
69
|
+
}
|
|
70
|
+
setCacheDir(dir) {
|
|
71
|
+
this.cacheDir = dir;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* For each entry that lacks an explicit maxContextTokens but has a
|
|
75
|
+
* providerKey, fill it in. Lookup order:
|
|
76
|
+
* 1. The provider's cached /v1/models response (most authoritative —
|
|
77
|
+
* it's what the vendor itself returned at last sync).
|
|
78
|
+
* 2. The bundled OpenRouter snapshot, keyed by `<vendor>/<id>` — covers
|
|
79
|
+
* the common case where a direct-provider model (e.g. `gpt-5.5`)
|
|
80
|
+
* is also published on OpenRouter with full metadata.
|
|
81
|
+
* 3. A final 200k floor so unknown models still get *some* context
|
|
82
|
+
* window rather than tripping max-token math downstream.
|
|
83
|
+
*
|
|
84
|
+
* Entries with an explicit maxContextTokens (set by the user in settings
|
|
85
|
+
* or by a prior code path) are left alone — we never overwrite what the
|
|
86
|
+
* user typed in.
|
|
87
|
+
*/
|
|
88
|
+
reloadCachedContextWindows() {
|
|
89
|
+
for (const [key, entry] of this.models) {
|
|
90
|
+
if (entry.maxContextTokens != null)
|
|
91
|
+
continue;
|
|
92
|
+
const resolved = this.resolveContextWindow(entry);
|
|
93
|
+
if (resolved != null) {
|
|
94
|
+
this.models.set(key, { ...entry, maxContextTokens: resolved });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
resolveContextWindow(entry) {
|
|
99
|
+
// 1. Per-provider /v1/models cache.
|
|
100
|
+
if (this.cacheDir && entry.providerKey) {
|
|
101
|
+
const file = readCache(this.cacheDir, entry.providerKey);
|
|
102
|
+
const match = file?.models.find((m) => m.id === entry.model);
|
|
103
|
+
if (match?.contextLength)
|
|
104
|
+
return match.contextLength;
|
|
105
|
+
}
|
|
106
|
+
// 2. OpenRouter snapshot — translate the entry's provider kind to the
|
|
107
|
+
// snapshot's `<vendor>/<id>` form.
|
|
108
|
+
const kind = entry.providerKey
|
|
109
|
+
? this.providerCatalog?.get(entry.providerKey)?.kind
|
|
110
|
+
: undefined;
|
|
111
|
+
if (kind === "openrouter") {
|
|
112
|
+
const hit = findOpenRouterModel(entry.model);
|
|
113
|
+
if (hit?.contextLength)
|
|
114
|
+
return hit.contextLength;
|
|
115
|
+
}
|
|
116
|
+
else if (kind) {
|
|
117
|
+
const vendor = OPENROUTER_VENDOR_BY_KIND[kind];
|
|
118
|
+
if (vendor) {
|
|
119
|
+
const hit = findOpenRouterModel(`${vendor}/${entry.model}`);
|
|
120
|
+
if (hit?.contextLength)
|
|
121
|
+
return hit.contextLength;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// 3. Final floor — better than leaving it undefined and reading
|
|
125
|
+
// config.maxContextTokens (which may itself be unset).
|
|
126
|
+
return FALLBACK_CONTEXT_WINDOW;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a pool from an array of model entries.
|
|
130
|
+
* The first entry (or the one matching `defaultKey`) becomes active.
|
|
131
|
+
*/
|
|
132
|
+
constructor(entries, defaultKey) {
|
|
133
|
+
if (entries) {
|
|
134
|
+
for (const e of entries) {
|
|
135
|
+
this.models.set(e.key, this.withBuiltinDefaults(e));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (defaultKey && this.models.has(defaultKey)) {
|
|
139
|
+
this.activeKey = defaultKey;
|
|
140
|
+
}
|
|
141
|
+
else if (entries?.length) {
|
|
142
|
+
this.activeKey = entries[0].key;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Register a model at runtime. */
|
|
146
|
+
register(entry) {
|
|
147
|
+
this.models.set(entry.key, this.withBuiltinDefaults(entry));
|
|
148
|
+
if (!this.activeKey) {
|
|
149
|
+
this.activeKey = entry.key;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** Fill in known defaults (e.g. context window for DeepSeek V4) when the entry doesn't specify them. */
|
|
153
|
+
withBuiltinDefaults(entry) {
|
|
154
|
+
if (entry.maxContextTokens != null)
|
|
155
|
+
return entry;
|
|
156
|
+
const builtin = lookupBuiltinContextWindow(entry.model);
|
|
157
|
+
if (builtin == null)
|
|
158
|
+
return entry;
|
|
159
|
+
return { ...entry, maxContextTokens: builtin };
|
|
160
|
+
}
|
|
161
|
+
/** Switch the active model. Throws if key not found. */
|
|
162
|
+
switch(key) {
|
|
163
|
+
const entry = this.models.get(key);
|
|
164
|
+
if (!entry) {
|
|
165
|
+
const available = [...this.models.keys()].join(", ");
|
|
166
|
+
throw new Error(`Model "${key}" not found. Available: ${available}`);
|
|
167
|
+
}
|
|
168
|
+
this.activeKey = key;
|
|
169
|
+
return entry;
|
|
170
|
+
}
|
|
171
|
+
/** Get a model by key. No key = active model. Returns undefined if not found. */
|
|
172
|
+
get(key) {
|
|
173
|
+
if (key)
|
|
174
|
+
return this.models.get(key);
|
|
175
|
+
if (this.activeKey)
|
|
176
|
+
return this.models.get(this.activeKey);
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
/** Get the active model key. */
|
|
180
|
+
getActiveKey() {
|
|
181
|
+
return this.activeKey;
|
|
182
|
+
}
|
|
183
|
+
/** List all registered models. */
|
|
184
|
+
list() {
|
|
185
|
+
return [...this.models.values()];
|
|
186
|
+
}
|
|
187
|
+
/** Number of registered models. */
|
|
188
|
+
get size() {
|
|
189
|
+
return this.models.size;
|
|
190
|
+
}
|
|
191
|
+
/** Check if a key exists. */
|
|
192
|
+
has(key) {
|
|
193
|
+
return this.models.has(key);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Build an LLMConfig for a given model entry, merging with a base config
|
|
197
|
+
* (inherits apiKey, baseUrl, etc. from the base if not set on the entry).
|
|
198
|
+
*/
|
|
199
|
+
toLLMConfig(entry, base) {
|
|
200
|
+
const fromCat = entry.providerKey && this.providerCatalog
|
|
201
|
+
? this.providerCatalog.get(entry.providerKey)
|
|
202
|
+
: undefined;
|
|
203
|
+
// Map provider-kind → client-factory name. client-factory only registers
|
|
204
|
+
// "anthropic" and "openai" (everything else is anthropic- or openai-
|
|
205
|
+
// compatible), so kinds outside that pair must collapse to one of them.
|
|
206
|
+
const kindToClientProvider = (kind) => {
|
|
207
|
+
if (!kind)
|
|
208
|
+
return "openai";
|
|
209
|
+
if (kind === "anthropic")
|
|
210
|
+
return "anthropic";
|
|
211
|
+
return "openai";
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
provider: entry.provider ||
|
|
215
|
+
kindToClientProvider(fromCat?.kind) ||
|
|
216
|
+
"openai",
|
|
217
|
+
model: entry.model,
|
|
218
|
+
apiKey: entry.apiKey ?? fromCat?.apiKey ?? base?.apiKey,
|
|
219
|
+
baseUrl: entry.baseUrl ?? fromCat?.baseUrl ?? base?.baseUrl,
|
|
220
|
+
temperature: base?.temperature ?? 0.3,
|
|
221
|
+
maxTokens: entry.maxOutputTokens ?? base?.maxTokens ?? 8192,
|
|
222
|
+
enableStreaming: base?.enableStreaming ?? true,
|
|
223
|
+
// thinking precedence: model entry > provider catalog > base.
|
|
224
|
+
// Model-level wins so users can hold one default for "deepseek"
|
|
225
|
+
// and still override a single model (e.g. v4-pro off).
|
|
226
|
+
...(entry.thinking || fromCat?.thinking || base?.thinking
|
|
227
|
+
? { thinking: entry.thinking ?? fromCat?.thinking ?? base?.thinking }
|
|
228
|
+
: {}),
|
|
229
|
+
// Carry the catalog kind through so the capability layer can pick
|
|
230
|
+
// per-(kind, model) request-shape rules. Defaults below cover the
|
|
231
|
+
// unusual case where an entry has a provider but no providerKey
|
|
232
|
+
// (legacy / arena-injected models).
|
|
233
|
+
...(fromCat?.kind ? { providerKind: fromCat.kind } : {}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Build an LLMConfig for the active model (or a specific key),
|
|
238
|
+
* merging with a base config.
|
|
239
|
+
*/
|
|
240
|
+
resolveLLMConfig(key, base) {
|
|
241
|
+
const entry = this.get(key);
|
|
242
|
+
if (!entry)
|
|
243
|
+
return undefined;
|
|
244
|
+
return this.toLLMConfig(entry, base);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory catalog of provider credentials. Mirrors settings.providers[]
|
|
3
|
+
* but offers a small API for add/update/remove that validates uniqueness
|
|
4
|
+
* and (for remove) refuses to delete a provider still referenced by a
|
|
5
|
+
* model entry. The caller persists changes back to settings.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProviderKindName } from "./provider-kinds.js";
|
|
8
|
+
export interface ProviderConfig {
|
|
9
|
+
key: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
kind: ProviderKindName;
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
protocol?: "openai-compat" | "anthropic-style";
|
|
15
|
+
modelsPath?: string;
|
|
16
|
+
/** Default DeepSeek V4 thinking-mode for this provider. See LLMConfig. */
|
|
17
|
+
thinking?: "enabled" | "disabled";
|
|
18
|
+
}
|
|
19
|
+
export declare class ProviderCatalog {
|
|
20
|
+
private byKey;
|
|
21
|
+
constructor(entries?: ProviderConfig[]);
|
|
22
|
+
list(): ProviderConfig[];
|
|
23
|
+
get(key: string): ProviderConfig | undefined;
|
|
24
|
+
has(key: string): boolean;
|
|
25
|
+
add(entry: ProviderConfig): void;
|
|
26
|
+
update(key: string, patch: Partial<ProviderConfig>): void;
|
|
27
|
+
remove(key: string, opts: {
|
|
28
|
+
referencedBy: string[];
|
|
29
|
+
}): void;
|
|
30
|
+
/** Compute an unused key for a new provider, given a desired base. */
|
|
31
|
+
deriveKey(base: string): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory catalog of provider credentials. Mirrors settings.providers[]
|
|
3
|
+
* but offers a small API for add/update/remove that validates uniqueness
|
|
4
|
+
* and (for remove) refuses to delete a provider still referenced by a
|
|
5
|
+
* model entry. The caller persists changes back to settings.
|
|
6
|
+
*/
|
|
7
|
+
export class ProviderCatalog {
|
|
8
|
+
byKey = new Map();
|
|
9
|
+
constructor(entries) {
|
|
10
|
+
for (const e of entries ?? [])
|
|
11
|
+
this.byKey.set(e.key, e);
|
|
12
|
+
}
|
|
13
|
+
list() {
|
|
14
|
+
return [...this.byKey.values()];
|
|
15
|
+
}
|
|
16
|
+
get(key) {
|
|
17
|
+
return this.byKey.get(key);
|
|
18
|
+
}
|
|
19
|
+
has(key) {
|
|
20
|
+
return this.byKey.has(key);
|
|
21
|
+
}
|
|
22
|
+
add(entry) {
|
|
23
|
+
if (this.byKey.has(entry.key)) {
|
|
24
|
+
throw new Error(`duplicate provider key: ${entry.key}`);
|
|
25
|
+
}
|
|
26
|
+
this.byKey.set(entry.key, entry);
|
|
27
|
+
}
|
|
28
|
+
update(key, patch) {
|
|
29
|
+
const cur = this.byKey.get(key);
|
|
30
|
+
if (!cur)
|
|
31
|
+
throw new Error(`no such provider: ${key}`);
|
|
32
|
+
this.byKey.set(key, { ...cur, ...patch, key: cur.key });
|
|
33
|
+
}
|
|
34
|
+
remove(key, opts) {
|
|
35
|
+
if (opts.referencedBy.length) {
|
|
36
|
+
throw new Error(`provider ${key} still referenced by models: ${opts.referencedBy.join(", ")}`);
|
|
37
|
+
}
|
|
38
|
+
this.byKey.delete(key);
|
|
39
|
+
}
|
|
40
|
+
/** Compute an unused key for a new provider, given a desired base. */
|
|
41
|
+
deriveKey(base) {
|
|
42
|
+
if (!this.byKey.has(base))
|
|
43
|
+
return base;
|
|
44
|
+
for (let i = 2;; i++) {
|
|
45
|
+
const candidate = `${base}-${i}`;
|
|
46
|
+
if (!this.byKey.has(candidate))
|
|
47
|
+
return candidate;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in provider kind metadata.
|
|
3
|
+
*
|
|
4
|
+
* Each kind defines how to talk to that provider family: where its
|
|
5
|
+
* model list lives, what auth header to send, which model IDs to keep
|
|
6
|
+
* (chat-completion only — embeddings / TTS / image generation are
|
|
7
|
+
* filtered out so they don't show up in the model picker).
|
|
8
|
+
*/
|
|
9
|
+
export type ProviderKindName = "openai" | "anthropic" | "deepseek" | "zai" | "xai" | "mistral" | "groq" | "google" | "openrouter" | "ollama" | "custom";
|
|
10
|
+
export type ProviderProtocol = "openai-compat" | "anthropic-style" | "gemini" | "ollama";
|
|
11
|
+
export interface ProviderKindMeta {
|
|
12
|
+
label: string;
|
|
13
|
+
defaultBaseUrl: string;
|
|
14
|
+
modelsPath: string;
|
|
15
|
+
protocol: ProviderProtocol;
|
|
16
|
+
authHeader: (apiKey: string) => Record<string, string>;
|
|
17
|
+
chatFilter: (id: string) => boolean;
|
|
18
|
+
authQuery?: (apiKey: string) => Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
export declare const PROVIDER_KINDS: Record<ProviderKindName, ProviderKindMeta>;
|
|
21
|
+
export declare function getKindMeta(kind: string): ProviderKindMeta;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in provider kind metadata.
|
|
3
|
+
*
|
|
4
|
+
* Each kind defines how to talk to that provider family: where its
|
|
5
|
+
* model list lives, what auth header to send, which model IDs to keep
|
|
6
|
+
* (chat-completion only — embeddings / TTS / image generation are
|
|
7
|
+
* filtered out so they don't show up in the model picker).
|
|
8
|
+
*/
|
|
9
|
+
// Models we want to hide from the picker — none of these speak the
|
|
10
|
+
// vanilla chat-completions protocol the engine uses:
|
|
11
|
+
// embedding / whisper / tts / audio / image / dall-e / moderation
|
|
12
|
+
// rerank / guard / vision-only — non-text outputs
|
|
13
|
+
// realtime / transcribe — different endpoints (WS / audio)
|
|
14
|
+
// search-preview / search-api — web-search wrappers
|
|
15
|
+
// sora / computer-use — non-chat task APIs
|
|
16
|
+
// deep-research — async research API
|
|
17
|
+
// codex — IDE-integration specific
|
|
18
|
+
// chat-latest — moving alias (we'd rather pin a version)
|
|
19
|
+
const NON_CHAT_PATTERNS = /(?:^|[-_/])(?:embed(?:ding)?|whisper|tts|audio|image|dall-?e|moderation|rerank|guard|vision-only|realtime|transcribe|search-preview|search-api|sora|computer-use|deep-research|codex|chat-latest)(?:$|[-_/])/i;
|
|
20
|
+
// User-specific fine-tuned ids look like "ft:<base>:<org>::<hash>" —
|
|
21
|
+
// keeping them out of the default picker; people who want them can
|
|
22
|
+
// add manually.
|
|
23
|
+
const isFineTunedId = (id) => id.startsWith("ft:");
|
|
24
|
+
// "Dated snapshot" ids end with -YYYY-MM-DD. They're the immutable
|
|
25
|
+
// pin behind the floating alias (`gpt-5.4` ⇨ `gpt-5.4-2026-03-05`).
|
|
26
|
+
// Hide them by default — the floating alias covers the same model
|
|
27
|
+
// and avoids picker noise.
|
|
28
|
+
const isDatedSnapshotId = (id) => /-\d{4}-\d{2}-\d{2}$/.test(id);
|
|
29
|
+
const isChatLike = (id) => !NON_CHAT_PATTERNS.test(id) && !isFineTunedId(id) && !isDatedSnapshotId(id);
|
|
30
|
+
const bearer = (k) => (k ? { Authorization: `Bearer ${k}` } : {});
|
|
31
|
+
export const PROVIDER_KINDS = {
|
|
32
|
+
openai: {
|
|
33
|
+
label: "OpenAI",
|
|
34
|
+
defaultBaseUrl: "https://api.openai.com/v1",
|
|
35
|
+
modelsPath: "/models",
|
|
36
|
+
protocol: "openai-compat",
|
|
37
|
+
authHeader: bearer,
|
|
38
|
+
chatFilter: isChatLike,
|
|
39
|
+
},
|
|
40
|
+
anthropic: {
|
|
41
|
+
label: "Anthropic",
|
|
42
|
+
defaultBaseUrl: "https://api.anthropic.com/v1",
|
|
43
|
+
modelsPath: "/models",
|
|
44
|
+
protocol: "anthropic-style",
|
|
45
|
+
authHeader: (k) => k
|
|
46
|
+
? { "x-api-key": k, "anthropic-version": "2023-06-01" }
|
|
47
|
+
: { "anthropic-version": "2023-06-01" },
|
|
48
|
+
chatFilter: isChatLike,
|
|
49
|
+
},
|
|
50
|
+
deepseek: {
|
|
51
|
+
label: "DeepSeek",
|
|
52
|
+
defaultBaseUrl: "https://api.deepseek.com/v1",
|
|
53
|
+
modelsPath: "/models",
|
|
54
|
+
protocol: "openai-compat",
|
|
55
|
+
authHeader: bearer,
|
|
56
|
+
chatFilter: isChatLike,
|
|
57
|
+
},
|
|
58
|
+
zai: {
|
|
59
|
+
label: "Z.AI (GLM)",
|
|
60
|
+
defaultBaseUrl: "https://api.z.ai/api/paas/v4",
|
|
61
|
+
modelsPath: "/models",
|
|
62
|
+
protocol: "openai-compat",
|
|
63
|
+
authHeader: bearer,
|
|
64
|
+
chatFilter: isChatLike,
|
|
65
|
+
},
|
|
66
|
+
xai: {
|
|
67
|
+
label: "xAI (Grok)",
|
|
68
|
+
defaultBaseUrl: "https://api.x.ai/v1",
|
|
69
|
+
modelsPath: "/models",
|
|
70
|
+
protocol: "openai-compat",
|
|
71
|
+
authHeader: bearer,
|
|
72
|
+
chatFilter: isChatLike,
|
|
73
|
+
},
|
|
74
|
+
mistral: {
|
|
75
|
+
label: "Mistral",
|
|
76
|
+
defaultBaseUrl: "https://api.mistral.ai/v1",
|
|
77
|
+
modelsPath: "/models",
|
|
78
|
+
protocol: "openai-compat",
|
|
79
|
+
authHeader: bearer,
|
|
80
|
+
chatFilter: isChatLike,
|
|
81
|
+
},
|
|
82
|
+
groq: {
|
|
83
|
+
label: "Groq",
|
|
84
|
+
defaultBaseUrl: "https://api.groq.com/openai/v1",
|
|
85
|
+
modelsPath: "/models",
|
|
86
|
+
protocol: "openai-compat",
|
|
87
|
+
authHeader: bearer,
|
|
88
|
+
chatFilter: isChatLike,
|
|
89
|
+
},
|
|
90
|
+
google: {
|
|
91
|
+
label: "Google Gemini",
|
|
92
|
+
// OpenAI-compat endpoint — chat completions go to `<baseUrl>/chat/completions`.
|
|
93
|
+
// For the model list we override the path to escape back to /v1beta/models,
|
|
94
|
+
// which is where the native (key=...) listing lives.
|
|
95
|
+
defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
96
|
+
// Absolute URL — escape the /openai segment so /models hits the
|
|
97
|
+
// native listing endpoint (the OpenAI-compat /openai/models exists
|
|
98
|
+
// but returns a thinner response).
|
|
99
|
+
modelsPath: "https://generativelanguage.googleapis.com/v1beta/models",
|
|
100
|
+
protocol: "gemini",
|
|
101
|
+
authHeader: bearer,
|
|
102
|
+
authQuery: (k) => (k ? { key: k } : {}),
|
|
103
|
+
chatFilter: (id) => isChatLike(id) && /gemini/i.test(id),
|
|
104
|
+
},
|
|
105
|
+
openrouter: {
|
|
106
|
+
label: "OpenRouter",
|
|
107
|
+
defaultBaseUrl: "https://openrouter.ai/api/v1",
|
|
108
|
+
modelsPath: "/models",
|
|
109
|
+
protocol: "openai-compat",
|
|
110
|
+
authHeader: bearer,
|
|
111
|
+
chatFilter: isChatLike,
|
|
112
|
+
},
|
|
113
|
+
ollama: {
|
|
114
|
+
label: "Ollama (local)",
|
|
115
|
+
defaultBaseUrl: "http://localhost:11434",
|
|
116
|
+
modelsPath: "/api/tags",
|
|
117
|
+
protocol: "ollama",
|
|
118
|
+
authHeader: () => ({}),
|
|
119
|
+
chatFilter: isChatLike,
|
|
120
|
+
},
|
|
121
|
+
custom: {
|
|
122
|
+
label: "Custom",
|
|
123
|
+
defaultBaseUrl: "",
|
|
124
|
+
modelsPath: "/models",
|
|
125
|
+
protocol: "openai-compat",
|
|
126
|
+
authHeader: bearer,
|
|
127
|
+
chatFilter: isChatLike,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
export function getKindMeta(kind) {
|
|
131
|
+
return PROVIDER_KINDS[kind] ?? PROVIDER_KINDS.custom;
|
|
132
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Claude provider using @anthropic-ai/sdk.
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMConfig, LLMResponse } from "../../types.js";
|
|
5
|
+
import type { CreateMessageOptions } from "../types.js";
|
|
6
|
+
import { LLMClientBase } from "../client-base.js";
|
|
7
|
+
export declare class AnthropicClient extends LLMClientBase {
|
|
8
|
+
private _client;
|
|
9
|
+
constructor(config: LLMConfig);
|
|
10
|
+
protected initClient(): void;
|
|
11
|
+
private get client();
|
|
12
|
+
createMessage(options: CreateMessageOptions): Promise<LLMResponse>;
|
|
13
|
+
private nonStreamMessage;
|
|
14
|
+
private streamMessage;
|
|
15
|
+
private processResponse;
|
|
16
|
+
private buildMessages;
|
|
17
|
+
private convertTools;
|
|
18
|
+
private handleApiError;
|
|
19
|
+
}
|