@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,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Claude provider using @anthropic-ai/sdk.
|
|
3
|
+
*/
|
|
4
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
5
|
+
import { LLMClientBase } from "../client-base.js";
|
|
6
|
+
import { ContextLimitError, LLMError, LLMRateLimitError } from "../../exceptions.js";
|
|
7
|
+
import { logger } from "../../logging/logger.js";
|
|
8
|
+
import { countTokens } from "../token-counter.js";
|
|
9
|
+
export class AnthropicClient extends LLMClientBase {
|
|
10
|
+
_client = null;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super(config);
|
|
13
|
+
}
|
|
14
|
+
initClient() {
|
|
15
|
+
// Lazy init
|
|
16
|
+
}
|
|
17
|
+
get client() {
|
|
18
|
+
if (!this._client) {
|
|
19
|
+
this._client = new Anthropic({
|
|
20
|
+
apiKey: this.config.apiKey ?? process.env.ANTHROPIC_API_KEY,
|
|
21
|
+
...(this.config.baseUrl ? { baseURL: this.config.baseUrl } : {}),
|
|
22
|
+
timeout: this.timeout,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return this._client;
|
|
26
|
+
}
|
|
27
|
+
async createMessage(options) {
|
|
28
|
+
return this.withRetry(async () => {
|
|
29
|
+
const messages = this.buildMessages(options.messages);
|
|
30
|
+
const tools = options.tools ? this.convertTools(options.tools) : undefined;
|
|
31
|
+
// One span per outbound LLM request. Begin emits debug-level so the
|
|
32
|
+
// info log isn't spammed during normal operation; end emits info with
|
|
33
|
+
// duration_ms + usage so `--debug=llm` already gives a quick latency
|
|
34
|
+
// histogram even at info level.
|
|
35
|
+
const span = logger.span("llm.request", {
|
|
36
|
+
cat: "llm",
|
|
37
|
+
provider: this.provider,
|
|
38
|
+
model: this.model,
|
|
39
|
+
stream: !!(options.stream && options.onChunk),
|
|
40
|
+
messageCount: messages.length,
|
|
41
|
+
toolCount: tools?.length ?? 0,
|
|
42
|
+
});
|
|
43
|
+
try {
|
|
44
|
+
const response = options.stream && options.onChunk
|
|
45
|
+
? await this.streamMessage(options, messages, tools)
|
|
46
|
+
: await this.nonStreamMessage(options, messages, tools);
|
|
47
|
+
span.end({
|
|
48
|
+
stopReason: response.stopReason,
|
|
49
|
+
promptTokens: response.usage?.promptTokens,
|
|
50
|
+
completionTokens: response.usage?.completionTokens,
|
|
51
|
+
cacheReadTokens: response.usage?.cacheReadTokens,
|
|
52
|
+
cacheCreationTokens: response.usage?.cacheCreationTokens,
|
|
53
|
+
});
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
span.fail(err);
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async nonStreamMessage(options, messages, tools) {
|
|
63
|
+
try {
|
|
64
|
+
const response = await this.client.messages.create({
|
|
65
|
+
model: this.model,
|
|
66
|
+
max_tokens: options.maxTokens ?? this.maxTokens,
|
|
67
|
+
system: [
|
|
68
|
+
{
|
|
69
|
+
type: "text",
|
|
70
|
+
text: options.systemPrompt,
|
|
71
|
+
cache_control: { type: "ephemeral" },
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
messages,
|
|
75
|
+
...(tools?.length ? { tools } : {}),
|
|
76
|
+
...(options.temperature !== undefined
|
|
77
|
+
? { temperature: options.temperature }
|
|
78
|
+
: { temperature: this.temperature }),
|
|
79
|
+
}, { signal: options.signal });
|
|
80
|
+
const usage = {
|
|
81
|
+
promptTokens: response.usage.input_tokens,
|
|
82
|
+
completionTokens: response.usage.output_tokens,
|
|
83
|
+
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
84
|
+
cacheReadTokens: response.usage.cache_read_input_tokens,
|
|
85
|
+
cacheCreationTokens: response.usage.cache_creation_input_tokens,
|
|
86
|
+
};
|
|
87
|
+
this.recordUsage(usage, options);
|
|
88
|
+
return this.processResponse(response, usage);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
this.handleApiError(err);
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async streamMessage(options, messages, tools) {
|
|
96
|
+
try {
|
|
97
|
+
const stream = this.client.messages.stream({
|
|
98
|
+
model: this.model,
|
|
99
|
+
max_tokens: options.maxTokens ?? this.maxTokens,
|
|
100
|
+
system: [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
text: options.systemPrompt,
|
|
104
|
+
cache_control: { type: "ephemeral" },
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
messages,
|
|
108
|
+
...(tools?.length ? { tools } : {}),
|
|
109
|
+
...(options.temperature !== undefined
|
|
110
|
+
? { temperature: options.temperature }
|
|
111
|
+
: { temperature: this.temperature }),
|
|
112
|
+
}, { signal: options.signal });
|
|
113
|
+
let currentText = "";
|
|
114
|
+
let currentToolName = "";
|
|
115
|
+
let currentToolId = "";
|
|
116
|
+
let currentToolInput = "";
|
|
117
|
+
// Time-to-first-byte: log exactly once per stream so streaming-latency
|
|
118
|
+
// questions ("model felt slow tonight") get a clean number per request.
|
|
119
|
+
const streamStartedAt = Date.now();
|
|
120
|
+
let firstByteLogged = false;
|
|
121
|
+
stream.on("text", (text) => {
|
|
122
|
+
if (!firstByteLogged) {
|
|
123
|
+
firstByteLogged = true;
|
|
124
|
+
logger.debug("llm.first_byte", {
|
|
125
|
+
cat: "llm",
|
|
126
|
+
provider: this.provider,
|
|
127
|
+
model: this.model,
|
|
128
|
+
ttft_ms: Date.now() - streamStartedAt,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
currentText += text;
|
|
132
|
+
options.onChunk?.({ type: "text", text, tokens: countTokens(text) });
|
|
133
|
+
});
|
|
134
|
+
stream.on("contentBlock", (block) => {
|
|
135
|
+
if (block.type === "tool_use") {
|
|
136
|
+
currentToolName = block.name;
|
|
137
|
+
currentToolId = block.id;
|
|
138
|
+
currentToolInput = "";
|
|
139
|
+
options.onChunk?.({
|
|
140
|
+
type: "tool_use_start",
|
|
141
|
+
toolCall: { id: block.id, toolName: block.name, args: {} },
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
stream.on("inputJson", (_delta, snapshot) => {
|
|
146
|
+
currentToolInput = JSON.stringify(snapshot);
|
|
147
|
+
if (currentToolId) {
|
|
148
|
+
options.onChunk?.({
|
|
149
|
+
type: "tool_use_delta",
|
|
150
|
+
toolCall: {
|
|
151
|
+
id: currentToolId,
|
|
152
|
+
toolName: currentToolName,
|
|
153
|
+
args: (snapshot ?? {}),
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const finalMessage = await stream.finalMessage();
|
|
159
|
+
const usage = {
|
|
160
|
+
promptTokens: finalMessage.usage.input_tokens,
|
|
161
|
+
completionTokens: finalMessage.usage.output_tokens,
|
|
162
|
+
totalTokens: finalMessage.usage.input_tokens + finalMessage.usage.output_tokens,
|
|
163
|
+
cacheReadTokens: finalMessage.usage.cache_read_input_tokens,
|
|
164
|
+
cacheCreationTokens: finalMessage.usage.cache_creation_input_tokens,
|
|
165
|
+
};
|
|
166
|
+
this.recordUsage(usage, options);
|
|
167
|
+
options.onChunk?.({ type: "stop", stopReason: finalMessage.stop_reason ?? undefined });
|
|
168
|
+
return this.processResponse(finalMessage, usage);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
this.handleApiError(err);
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
processResponse(response, usage) {
|
|
176
|
+
let text = "";
|
|
177
|
+
const toolCalls = [];
|
|
178
|
+
for (const block of response.content) {
|
|
179
|
+
if (block.type === "text") {
|
|
180
|
+
text += block.text;
|
|
181
|
+
}
|
|
182
|
+
else if (block.type === "tool_use") {
|
|
183
|
+
toolCalls.push({
|
|
184
|
+
id: block.id,
|
|
185
|
+
toolName: block.name,
|
|
186
|
+
args: block.input ?? {},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
text,
|
|
192
|
+
toolCalls,
|
|
193
|
+
usage,
|
|
194
|
+
stopReason: response.stop_reason ?? undefined,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
buildMessages(messages) {
|
|
198
|
+
const result = [];
|
|
199
|
+
for (const msg of messages) {
|
|
200
|
+
if (msg.role === "system")
|
|
201
|
+
continue;
|
|
202
|
+
const role = msg.role === "tool" ? "user" : msg.role;
|
|
203
|
+
if (typeof msg.content === "string") {
|
|
204
|
+
result.push({ role: role, content: msg.content });
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const blocks = [];
|
|
208
|
+
for (const block of msg.content) {
|
|
209
|
+
if (block.type === "text" && block.text) {
|
|
210
|
+
blocks.push({ type: "text", text: block.text });
|
|
211
|
+
}
|
|
212
|
+
else if (block.type === "tool_use" && block.id && block.name && block.input) {
|
|
213
|
+
blocks.push({
|
|
214
|
+
type: "tool_use",
|
|
215
|
+
id: block.id,
|
|
216
|
+
name: block.name,
|
|
217
|
+
input: block.input,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else if (block.type === "tool_result" && block.tool_use_id) {
|
|
221
|
+
blocks.push({
|
|
222
|
+
type: "tool_result",
|
|
223
|
+
tool_use_id: block.tool_use_id,
|
|
224
|
+
content: typeof block.content === "string" ? block.content : "",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else if (block.type === "image" && block.source) {
|
|
228
|
+
blocks.push({
|
|
229
|
+
type: "image",
|
|
230
|
+
source: {
|
|
231
|
+
type: "base64",
|
|
232
|
+
media_type: block.source.media_type,
|
|
233
|
+
data: block.source.data,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (blocks.length > 0) {
|
|
239
|
+
result.push({ role: role, content: blocks });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
convertTools(tools) {
|
|
246
|
+
return tools.map((t) => ({
|
|
247
|
+
name: t.name,
|
|
248
|
+
description: t.description,
|
|
249
|
+
input_schema: t.inputSchema,
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
handleApiError(err) {
|
|
253
|
+
if (err instanceof Anthropic.APIError) {
|
|
254
|
+
if (err.status === 429) {
|
|
255
|
+
throw new LLMRateLimitError("anthropic");
|
|
256
|
+
}
|
|
257
|
+
if (err.message?.includes("prompt is too long") ||
|
|
258
|
+
err.message?.includes("context_length_exceeded")) {
|
|
259
|
+
throw new ContextLimitError("anthropic");
|
|
260
|
+
}
|
|
261
|
+
throw new LLMError(`Anthropic API error: ${err.message}`, "anthropic", {
|
|
262
|
+
status: err.status,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
throw err;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI GPT provider using openai SDK.
|
|
3
|
+
*
|
|
4
|
+
* Serves every OpenAI-compatible endpoint we support (OpenAI, DeepSeek,
|
|
5
|
+
* OpenRouter, Z.AI, xAI, Mistral, Groq, Gemini-OpenAI-compat, Ollama,
|
|
6
|
+
* custom). Per-(provider, model) request-shape divergence — token-limit
|
|
7
|
+
* field name, rejected sampling params, thinking knob, reasoning echo —
|
|
8
|
+
* is resolved through `capabilitiesFor()`, not hardcoded.
|
|
9
|
+
*/
|
|
10
|
+
import type { LLMConfig, LLMResponse } from "../../types.js";
|
|
11
|
+
import type { CreateMessageOptions } from "../types.js";
|
|
12
|
+
import { LLMClientBase } from "../client-base.js";
|
|
13
|
+
interface RunStreamOpts {
|
|
14
|
+
idleTimeoutMs?: number;
|
|
15
|
+
requestId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Per-chunk handler — invoked synchronously with the raw chunk for the
|
|
18
|
+
* provider to do its own parsing. Returns the text delta (or "") for
|
|
19
|
+
* the watchdog-side text accumulator used in tests.
|
|
20
|
+
*/
|
|
21
|
+
onChunk?: (chunk: any) => string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Consume an async iterable of stream chunks with an idle watchdog.
|
|
25
|
+
* Returns the accumulated text — either from onChunk return values, or
|
|
26
|
+
* by extracting choices[0].delta.content from raw chunks (useful in tests
|
|
27
|
+
* that call runStreamWithWatchdog directly without an onChunk handler).
|
|
28
|
+
*
|
|
29
|
+
* The watchdog is active whenever opts.idleTimeoutMs is explicitly provided,
|
|
30
|
+
* or when STREAM_WATCHDOG_CONFIG.enabled is true. When active, each call to
|
|
31
|
+
* iterator.next() races against an idle deadline; if the deadline fires first
|
|
32
|
+
* the function rejects with StreamIdleTimeoutError.
|
|
33
|
+
*/
|
|
34
|
+
export declare function runStreamWithWatchdog<T = any>(stream: AsyncIterable<T>, opts?: RunStreamOpts): Promise<string>;
|
|
35
|
+
export declare class OpenAIClient extends LLMClientBase {
|
|
36
|
+
private _client;
|
|
37
|
+
private _forceMaxCompletionTokens;
|
|
38
|
+
constructor(config: LLMConfig);
|
|
39
|
+
protected initClient(): void;
|
|
40
|
+
private get client();
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the capability descriptor for the current (provider kind, model)
|
|
43
|
+
* pair. Cached for the lifetime of the client — model never changes
|
|
44
|
+
* mid-client. `providerKind` defaults to "openai" because legacy LLMConfig
|
|
45
|
+
* paths (arena, env-derived) don't always populate it; for those, the
|
|
46
|
+
* built-in rules table treats them as plain OpenAI.
|
|
47
|
+
*/
|
|
48
|
+
private _capability;
|
|
49
|
+
private get capability();
|
|
50
|
+
createMessage(options: CreateMessageOptions): Promise<LLMResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Build the request body honoring the model's capability descriptor.
|
|
53
|
+
* Centralized so both streaming and non-streaming paths agree on the
|
|
54
|
+
* exact shape.
|
|
55
|
+
*/
|
|
56
|
+
private buildRequestBody;
|
|
57
|
+
private nonStreamMessage;
|
|
58
|
+
private streamMessage;
|
|
59
|
+
private processChoice;
|
|
60
|
+
private buildMessages;
|
|
61
|
+
private convertTools;
|
|
62
|
+
private handleApiError;
|
|
63
|
+
}
|
|
64
|
+
export {};
|