@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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime sync of the OpenRouter model catalog.
|
|
3
|
+
*
|
|
4
|
+
* Fetches openrouter.ai/api/v1/models and replaces the bundled snapshot
|
|
5
|
+
* in memory for the rest of the process. Used by the /sync-models slash
|
|
6
|
+
* command. To persist a sync across restarts, re-run the build (which
|
|
7
|
+
* re-runs scripts/sync-models.ts).
|
|
8
|
+
*/
|
|
9
|
+
import { getOpenRouterSnapshot } from "./openrouter-models.js";
|
|
10
|
+
export interface SyncResult {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
count: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function syncOpenRouterCatalog(timeoutMs?: number): Promise<SyncResult>;
|
|
16
|
+
export { getOpenRouterSnapshot };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime sync of the OpenRouter model catalog.
|
|
3
|
+
*
|
|
4
|
+
* Fetches openrouter.ai/api/v1/models and replaces the bundled snapshot
|
|
5
|
+
* in memory for the rest of the process. Used by the /sync-models slash
|
|
6
|
+
* command. To persist a sync across restarts, re-run the build (which
|
|
7
|
+
* re-runs scripts/sync-models.ts).
|
|
8
|
+
*/
|
|
9
|
+
import { setOpenRouterSnapshot, getOpenRouterSnapshot, } from "./openrouter-models.js";
|
|
10
|
+
const ENDPOINT = "https://openrouter.ai/api/v1/models";
|
|
11
|
+
function priceToPerMillion(raw) {
|
|
12
|
+
if (!raw)
|
|
13
|
+
return 0;
|
|
14
|
+
const n = Number(raw);
|
|
15
|
+
return Number.isFinite(n) ? n * 1_000_000 : 0;
|
|
16
|
+
}
|
|
17
|
+
function slim(m) {
|
|
18
|
+
return {
|
|
19
|
+
id: m.id,
|
|
20
|
+
name: m.name ?? m.id,
|
|
21
|
+
created: m.created ?? 0,
|
|
22
|
+
contextLength: m.top_provider?.context_length ?? m.context_length ?? 0,
|
|
23
|
+
maxOutputTokens: m.top_provider?.max_completion_tokens ?? 0,
|
|
24
|
+
inputPricePerMillion: priceToPerMillion(m.pricing?.prompt),
|
|
25
|
+
outputPricePerMillion: priceToPerMillion(m.pricing?.completion),
|
|
26
|
+
modalities: m.architecture?.input_modalities ?? [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export async function syncOpenRouterCatalog(timeoutMs = 15_000) {
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetch(ENDPOINT, {
|
|
32
|
+
headers: { Accept: "application/json" },
|
|
33
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
return { ok: false, count: 0, error: `HTTP ${res.status} ${res.statusText}` };
|
|
37
|
+
}
|
|
38
|
+
const payload = (await res.json());
|
|
39
|
+
const raw = payload.data ?? [];
|
|
40
|
+
const models = raw.map(slim).sort((a, b) => b.created - a.created);
|
|
41
|
+
setOpenRouterSnapshot({
|
|
42
|
+
fetchedAt: new Date().toISOString(),
|
|
43
|
+
source: ENDPOINT,
|
|
44
|
+
count: models.length,
|
|
45
|
+
models,
|
|
46
|
+
});
|
|
47
|
+
return { ok: true, count: models.length };
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
return { ok: false, count: 0, error: err.message };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export { getOpenRouterSnapshot };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-maintained static model catalogs for providers whose /v1/models
|
|
3
|
+
* endpoint returns only ids — no context window, max output, or pricing.
|
|
4
|
+
*
|
|
5
|
+
* At runtime we still call the live /models endpoint to discover ids
|
|
6
|
+
* (so newly-released models work without a code update), then left-join
|
|
7
|
+
* this table on `id` to fill in metadata. Edit the JSONs in src/data/
|
|
8
|
+
* when a vendor ships a new model.
|
|
9
|
+
*
|
|
10
|
+
* OpenRouter is NOT here — its catalog is generated at build time by
|
|
11
|
+
* scripts/sync-models.ts because OpenRouter exposes full metadata.
|
|
12
|
+
*/
|
|
13
|
+
import type { ProviderKindName } from "../llm/provider-kinds.js";
|
|
14
|
+
export interface StaticModel {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
contextLength: number;
|
|
18
|
+
maxOutputTokens: number;
|
|
19
|
+
inputPricePerMillion: number;
|
|
20
|
+
outputPricePerMillion: number;
|
|
21
|
+
modalities: string[];
|
|
22
|
+
thinking?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function listStaticModels(kind: ProviderKindName): StaticModel[];
|
|
25
|
+
export declare function hasStaticCatalog(kind: ProviderKindName): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-maintained static model catalogs for providers whose /v1/models
|
|
3
|
+
* endpoint returns only ids — no context window, max output, or pricing.
|
|
4
|
+
*
|
|
5
|
+
* At runtime we still call the live /models endpoint to discover ids
|
|
6
|
+
* (so newly-released models work without a code update), then left-join
|
|
7
|
+
* this table on `id` to fill in metadata. Edit the JSONs in src/data/
|
|
8
|
+
* when a vendor ships a new model.
|
|
9
|
+
*
|
|
10
|
+
* OpenRouter is NOT here — its catalog is generated at build time by
|
|
11
|
+
* scripts/sync-models.ts because OpenRouter exposes full metadata.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
const requireJson = createRequire(import.meta.url);
|
|
15
|
+
const TABLES = {
|
|
16
|
+
deepseek: requireJson("./deepseek-models.json"),
|
|
17
|
+
zai: requireJson("./zai-models.json"),
|
|
18
|
+
openai: requireJson("./openai-models.json"),
|
|
19
|
+
google: requireJson("./gemini-models.json"),
|
|
20
|
+
};
|
|
21
|
+
export function listStaticModels(kind) {
|
|
22
|
+
return TABLES[kind]?.models ?? [];
|
|
23
|
+
}
|
|
24
|
+
export function hasStaticCatalog(kind) {
|
|
25
|
+
return TABLES[kind] !== undefined;
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fetchedAt": "2026-05-14",
|
|
3
|
+
"source": "https://docs.z.ai/guides/llm/glm-5.1 + https://docs.z.ai/guides/overview/pricing",
|
|
4
|
+
"count": 5,
|
|
5
|
+
"models": [
|
|
6
|
+
{
|
|
7
|
+
"id": "glm-5.1",
|
|
8
|
+
"name": "GLM-5.1",
|
|
9
|
+
"contextLength": 200000,
|
|
10
|
+
"maxOutputTokens": 128000,
|
|
11
|
+
"inputPricePerMillion": 1.4,
|
|
12
|
+
"outputPricePerMillion": 4.4,
|
|
13
|
+
"modalities": ["text"],
|
|
14
|
+
"thinking": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "glm-4.6",
|
|
18
|
+
"name": "GLM-4.6",
|
|
19
|
+
"contextLength": 200000,
|
|
20
|
+
"maxOutputTokens": 128000,
|
|
21
|
+
"inputPricePerMillion": 0.6,
|
|
22
|
+
"outputPricePerMillion": 2.2,
|
|
23
|
+
"modalities": ["text"],
|
|
24
|
+
"thinking": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "glm-4.5",
|
|
28
|
+
"name": "GLM-4.5",
|
|
29
|
+
"contextLength": 128000,
|
|
30
|
+
"maxOutputTokens": 96000,
|
|
31
|
+
"inputPricePerMillion": 0.6,
|
|
32
|
+
"outputPricePerMillion": 2.2,
|
|
33
|
+
"modalities": ["text"],
|
|
34
|
+
"thinking": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "glm-4.5-air",
|
|
38
|
+
"name": "GLM-4.5 Air",
|
|
39
|
+
"contextLength": 128000,
|
|
40
|
+
"maxOutputTokens": 96000,
|
|
41
|
+
"inputPricePerMillion": 0.2,
|
|
42
|
+
"outputPricePerMillion": 1.1,
|
|
43
|
+
"modalities": ["text"],
|
|
44
|
+
"thinking": true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "glm-4.5-flash",
|
|
48
|
+
"name": "GLM-4.5 Flash (free tier)",
|
|
49
|
+
"contextLength": 128000,
|
|
50
|
+
"maxOutputTokens": 96000,
|
|
51
|
+
"inputPricePerMillion": 0,
|
|
52
|
+
"outputPricePerMillion": 0,
|
|
53
|
+
"modalities": ["text"]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CostStateStore — an opaque snapshot/restore hook that Engine uses to
|
|
3
|
+
* persist session-level cost state across `run({ sessionId })` calls.
|
|
4
|
+
*
|
|
5
|
+
* Engine itself doesn't compute prices or format summaries; it just hands
|
|
6
|
+
* the state blob to whatever store was injected. The CLI's `costTracker`
|
|
7
|
+
* is one concrete implementation; a SaaS backend might implement this
|
|
8
|
+
* against a database instead.
|
|
9
|
+
*
|
|
10
|
+
* Default: no store is injected, and cost state is not persisted. Engine
|
|
11
|
+
* continues to report per-run token usage via `EngineResult.usage` and
|
|
12
|
+
* `LLMClientBase.getUsage()` — this hook is only for the
|
|
13
|
+
* "resume-and-keep-counting" scenario.
|
|
14
|
+
*/
|
|
15
|
+
/** Arbitrary serializable snapshot — opaque to Engine. */
|
|
16
|
+
export type CostStateSnapshot = unknown;
|
|
17
|
+
export interface CostStateStore {
|
|
18
|
+
/** Serialize current cost state for persistence. */
|
|
19
|
+
serialize(): CostStateSnapshot;
|
|
20
|
+
/** Restore previously-serialized cost state. */
|
|
21
|
+
restore(state: CostStateSnapshot): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CostStateStore — an opaque snapshot/restore hook that Engine uses to
|
|
3
|
+
* persist session-level cost state across `run({ sessionId })` calls.
|
|
4
|
+
*
|
|
5
|
+
* Engine itself doesn't compute prices or format summaries; it just hands
|
|
6
|
+
* the state blob to whatever store was injected. The CLI's `costTracker`
|
|
7
|
+
* is one concrete implementation; a SaaS backend might implement this
|
|
8
|
+
* against a database instead.
|
|
9
|
+
*
|
|
10
|
+
* Default: no store is injected, and cost state is not persisted. Engine
|
|
11
|
+
* continues to report per-run token usage via `EngineResult.usage` and
|
|
12
|
+
* `LLMClientBase.getUsage()` — this hook is only for the
|
|
13
|
+
* "resume-and-keep-counting" scenario.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine — the main facade that wires all components together.
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMConfig, StreamCallback, TerminalReason, TokenUsage } from "../types.js";
|
|
5
|
+
import { ToolRegistry } from "../tool-system/registry.js";
|
|
6
|
+
import { type ApprovalBackend } from "../tool-system/permission.js";
|
|
7
|
+
import { HookRegistry } from "../hooks/registry.js";
|
|
8
|
+
import type { HookEventName } from "../hooks/events.js";
|
|
9
|
+
import type { HookHandler } from "../hooks/registry.js";
|
|
10
|
+
import { SessionManager } from "../session/session-manager.js";
|
|
11
|
+
import type { CostStateStore } from "./cost-store.js";
|
|
12
|
+
import type { AskUserFn } from "../tool-system/builtin/ask-user.js";
|
|
13
|
+
import type { ToolContext } from "../tool-system/context.js";
|
|
14
|
+
import { type SandboxConfig } from "../tool-system/sandbox/index.js";
|
|
15
|
+
import { type AgentPresetName } from "../preset/index.js";
|
|
16
|
+
import { ModelPool, type ModelEntry } from "../llm/model-pool.js";
|
|
17
|
+
import { EngineRuntime } from "./runtime.js";
|
|
18
|
+
export interface EngineConfig {
|
|
19
|
+
llm: LLMConfig;
|
|
20
|
+
cwd?: string;
|
|
21
|
+
maxTurns?: number;
|
|
22
|
+
maxToolCallsPerTurn?: number;
|
|
23
|
+
permissionMode?: "default" | "acceptEdits" | "dontAsk" | "bypassPermissions" | "auto" | "plan";
|
|
24
|
+
preset?: AgentPresetName;
|
|
25
|
+
enabledBuiltinTools?: string[];
|
|
26
|
+
disabledBuiltinTools?: string[];
|
|
27
|
+
customSystemPrompt?: string;
|
|
28
|
+
appendSystemPrompt?: string;
|
|
29
|
+
sessionStorageDir?: string;
|
|
30
|
+
maxContextTokens?: number;
|
|
31
|
+
approvalBackend?: ApprovalBackend;
|
|
32
|
+
hooks?: EngineHookConfig[];
|
|
33
|
+
askUser?: AskUserFn;
|
|
34
|
+
mcpServers?: Record<string, import("../types.js").MCPServerConfig>;
|
|
35
|
+
/**
|
|
36
|
+
* Optional opaque store for per-session cost/usage state. When provided,
|
|
37
|
+
* Engine calls `restore()` on session resume and `serialize()` at the end
|
|
38
|
+
* of each `run()` and stores the blob on the session. Without this the
|
|
39
|
+
* Engine doesn't persist cost state — it's a UI concern.
|
|
40
|
+
*/
|
|
41
|
+
costStore?: CostStateStore;
|
|
42
|
+
/**
|
|
43
|
+
* True when the Engine runs in a no-UI / one-shot context (e.g. the `run`
|
|
44
|
+
* command). Currently controls InvestigationGuard soft-mode: in headless
|
|
45
|
+
* we never hard-block a tool call because there is no human to retry.
|
|
46
|
+
* Defaults to false.
|
|
47
|
+
*/
|
|
48
|
+
headless?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Sandbox configuration for shell-tool execution. When omitted, headless
|
|
51
|
+
* runs default to "auto" (Seatbelt on macOS / bwrap on Linux when
|
|
52
|
+
* available) and interactive runs default to "off" because a human is in
|
|
53
|
+
* the loop to approve commands.
|
|
54
|
+
*/
|
|
55
|
+
sandbox?: SandboxConfig;
|
|
56
|
+
/**
|
|
57
|
+
* True when this Engine is itself a sub-agent (spawned by another
|
|
58
|
+
* Engine's Agent tool). Threaded into ToolContext so the Agent tool can
|
|
59
|
+
* refuse re-entry — defense in depth against the tool-list strip in
|
|
60
|
+
* spawn(): if a tool registry regression ever leaks Agent into a child's
|
|
61
|
+
* pool, the runtime check still blocks the call.
|
|
62
|
+
*/
|
|
63
|
+
isSubAgent?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Optional shared EngineRuntime providing pre-constructed shared resources
|
|
66
|
+
* (modelPool, toolRegistry, etc.). When provided, Engine uses these instead
|
|
67
|
+
* of constructing its own. Existing callers that omit this field continue to
|
|
68
|
+
* work unchanged — T11 will migrate them.
|
|
69
|
+
*/
|
|
70
|
+
runtime?: EngineRuntime;
|
|
71
|
+
}
|
|
72
|
+
export interface EngineHookConfig {
|
|
73
|
+
event: HookEventName;
|
|
74
|
+
handler: HookHandler;
|
|
75
|
+
priority?: number;
|
|
76
|
+
name?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface EngineResult {
|
|
79
|
+
text: string;
|
|
80
|
+
reason: TerminalReason;
|
|
81
|
+
sessionId: string;
|
|
82
|
+
turnCount: number;
|
|
83
|
+
usage: TokenUsage;
|
|
84
|
+
}
|
|
85
|
+
export declare class Engine {
|
|
86
|
+
private config;
|
|
87
|
+
private readonly preset;
|
|
88
|
+
private toolRegistry;
|
|
89
|
+
private hooks;
|
|
90
|
+
private sessionManager;
|
|
91
|
+
private mcpManager;
|
|
92
|
+
private modelPool;
|
|
93
|
+
/** Shared resources supplied at construction (adapter pattern — null when self-constructed). */
|
|
94
|
+
readonly runtime: EngineRuntime | null;
|
|
95
|
+
/** Active permission mode for this Engine instance. */
|
|
96
|
+
permissionMode: NonNullable<EngineConfig["permissionMode"]>;
|
|
97
|
+
/** True when permissionMode === "plan". */
|
|
98
|
+
planMode: boolean;
|
|
99
|
+
private settingsManager;
|
|
100
|
+
private lastContextManager;
|
|
101
|
+
private lastMessages;
|
|
102
|
+
private lastSessionId;
|
|
103
|
+
private compactedMessagesBySession;
|
|
104
|
+
/**
|
|
105
|
+
* SIDs whose ctx-bar seed we've already emitted in this process. The seed
|
|
106
|
+
* is a rough char/4 estimate; only useful before the first real
|
|
107
|
+
* usage_update arrives (cold start or cross-process resume). On subsequent
|
|
108
|
+
* turns the UI already shows the previous turn's accurate ctx — re-seeding
|
|
109
|
+
* would visibly drop the bar on every submit.
|
|
110
|
+
*/
|
|
111
|
+
private ctxSeedSent;
|
|
112
|
+
/**
|
|
113
|
+
* Per-sid cache of "non-messages overhead" (system prompt + tool defs, in
|
|
114
|
+
* tokens). Survives across turns so each fresh TurnLoop instance can seed
|
|
115
|
+
* its first pre-llm emit with the right offset — without this the ctx bar
|
|
116
|
+
* visibly drops on every user submit (e.g. from ~20k → 3k) until the next
|
|
117
|
+
* LLM response arrives.
|
|
118
|
+
*/
|
|
119
|
+
private ctxOverheadBySid;
|
|
120
|
+
private activePermission;
|
|
121
|
+
/** Public accessor so UI/clients can read the resolved per-model window. */
|
|
122
|
+
get maxContextTokens(): number;
|
|
123
|
+
private resolveMaxContextTokens;
|
|
124
|
+
/**
|
|
125
|
+
* Emit a lifecycle hook with isSubAgent auto-merged into data so handlers
|
|
126
|
+
* can skip noisy injections for spawned children. All Engine-side hook
|
|
127
|
+
* emits should go through this wrapper to keep the context envelope
|
|
128
|
+
* uniform with TurnLoop.emitHook.
|
|
129
|
+
*/
|
|
130
|
+
private emitHook;
|
|
131
|
+
/**
|
|
132
|
+
* Read settings.hooks and register a shell-runner wrapper handler per
|
|
133
|
+
* entry. Sub-agents skip shell hooks entirely — spawning child processes
|
|
134
|
+
* per emit for every sub-agent run would multiply token-side overhead
|
|
135
|
+
* for marginal value; explicit users who want sub-agent observability
|
|
136
|
+
* should register SDK-side handlers.
|
|
137
|
+
*/
|
|
138
|
+
private registerSettingsHooks;
|
|
139
|
+
constructor(config: EngineConfig);
|
|
140
|
+
/**
|
|
141
|
+
* Load models[] / providers[] from settings into the active ModelPool and
|
|
142
|
+
* resync this.config.llm with the matching entry. Called from the ctor and
|
|
143
|
+
* from reloadModelPool() (e.g. after onboarding writes new entries to disk).
|
|
144
|
+
*/
|
|
145
|
+
private populateModelPoolFromSettings;
|
|
146
|
+
/**
|
|
147
|
+
* Re-read settings and refresh the model pool. Used after onboarding /login
|
|
148
|
+
* writes new providers[] / models[] to disk so the running engine picks them
|
|
149
|
+
* up without a process restart. Existing pool entries are kept (re-registering
|
|
150
|
+
* the same key overwrites them), so callers don't need to clear first.
|
|
151
|
+
*/
|
|
152
|
+
reloadModelPool(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Auto-populate the model pool when settings.models[] is empty but
|
|
155
|
+
* the user has configured an API key. Detects the provider from the
|
|
156
|
+
* key prefix / baseUrl and registers all its known models.
|
|
157
|
+
*/
|
|
158
|
+
private autoPopulatePool;
|
|
159
|
+
/**
|
|
160
|
+
* Register a custom tool (from product adapter) into the tool registry.
|
|
161
|
+
* Must be called before run().
|
|
162
|
+
*/
|
|
163
|
+
registerCustomTool(definition: import("../types.js").RegisteredTool, executor: (args: Record<string, unknown>) => Promise<string>): void;
|
|
164
|
+
/**
|
|
165
|
+
* Inject the askUser handler after construction. Used by AgentServer
|
|
166
|
+
* to wire its protocol-backed askUser into an Engine that was created
|
|
167
|
+
* before the server existed (chicken-and-egg: server takes engine in ctor).
|
|
168
|
+
*/
|
|
169
|
+
setAskUser(fn: AskUserFn | undefined): void;
|
|
170
|
+
/**
|
|
171
|
+
* Run a task from start to finish.
|
|
172
|
+
*/
|
|
173
|
+
run(task: string, options?: {
|
|
174
|
+
cwd?: string;
|
|
175
|
+
onStream?: StreamCallback;
|
|
176
|
+
signal?: AbortSignal;
|
|
177
|
+
sessionId?: string;
|
|
178
|
+
}): Promise<EngineResult>;
|
|
179
|
+
/**
|
|
180
|
+
* Run the end-of-session memory pipeline as a fire-and-forget background
|
|
181
|
+
* task. Extracts durable memories from the transcript, saves a session
|
|
182
|
+
* summary, and conditionally triggers auto-dream consolidation.
|
|
183
|
+
*/
|
|
184
|
+
private runMemoryPipeline;
|
|
185
|
+
/**
|
|
186
|
+
* Drive the auto-dream tool-call loop.
|
|
187
|
+
*
|
|
188
|
+
* Runs the LLM with a whitelisted subset of memory tools (MemoryList,
|
|
189
|
+
* MemoryRead, MemorySave, MemoryDelete). The loop is intentionally small
|
|
190
|
+
* and offline:
|
|
191
|
+
* - No streaming, no UI events — runs in the background after a session.
|
|
192
|
+
* - No permission prompts — UI isn't attached, so we hard-reject any
|
|
193
|
+
* attempt to Save/Delete in the "user" scope before dispatching. Dream
|
|
194
|
+
* scope is the LLM's workspace and goes through freely.
|
|
195
|
+
* - Capped at MAX_TURNS LLM round-trips and MAX_WRITES total
|
|
196
|
+
* mutations to bound damage on misbehavior.
|
|
197
|
+
*
|
|
198
|
+
* Returns true if the loop ran (with or without writes); false if we
|
|
199
|
+
* bailed before the first LLM call (e.g. registry missing the tools).
|
|
200
|
+
*/
|
|
201
|
+
private runDreamLoop;
|
|
202
|
+
/**
|
|
203
|
+
* Execute one memory tool call inside the dream loop. Enforces the two
|
|
204
|
+
* dream-loop invariants the prompt also states:
|
|
205
|
+
* - Only the 4 memory tools are dispatchable.
|
|
206
|
+
* - Save/Delete in "user" scope is refused (returned as a tool error)
|
|
207
|
+
* because dream runs without an interactive permission backend.
|
|
208
|
+
*/
|
|
209
|
+
private dispatchDreamTool;
|
|
210
|
+
getToolRegistry(): ToolRegistry;
|
|
211
|
+
/**
|
|
212
|
+
* Switch the active model by pool key. Takes effect on the next run() call.
|
|
213
|
+
* Returns the new model entry.
|
|
214
|
+
*
|
|
215
|
+
* Persists settings.activeKey (and a legacy settings.model.* mirror) so the
|
|
216
|
+
* next process startup defaults to the same model — without this, switches
|
|
217
|
+
* only live in memory and every restart reverts to the previously persisted
|
|
218
|
+
* activeKey.
|
|
219
|
+
*/
|
|
220
|
+
switchModel(key: string): ModelEntry;
|
|
221
|
+
/**
|
|
222
|
+
* Write the active model selection to ~/.code-shell/settings.json.
|
|
223
|
+
*
|
|
224
|
+
* We mirror into the legacy settings.model.* block (provider/name/apiKey/
|
|
225
|
+
* baseUrl) because boot paths in cli/main.ts, repl.ts, run.ts still read it.
|
|
226
|
+
* The mirror uses resolved llm values (not raw entry.*) so credentials that
|
|
227
|
+
* live on settings.providers[] flow through correctly — entry.apiKey is
|
|
228
|
+
* undefined when the entry resolves via providerCatalog.
|
|
229
|
+
*/
|
|
230
|
+
private persistActiveModel;
|
|
231
|
+
/** Get the model pool. */
|
|
232
|
+
getModelPool(): ModelPool;
|
|
233
|
+
/** Get the current model name (full path). */
|
|
234
|
+
getCurrentModel(): string;
|
|
235
|
+
getHookRegistry(): HookRegistry;
|
|
236
|
+
getSessionManager(): SessionManager;
|
|
237
|
+
getConfig(): EngineConfig;
|
|
238
|
+
/**
|
|
239
|
+
* Inject context into a session's transcript without triggering a LLM turn.
|
|
240
|
+
* The injected content appears as an assistant message so the LLM can see it
|
|
241
|
+
* in subsequent conversations. The transcript auto-flushes to disk.
|
|
242
|
+
*
|
|
243
|
+
* Also updates the in-memory compacted message cache so the next
|
|
244
|
+
* engine.run() call for this session picks up the injected content
|
|
245
|
+
* instead of a stale snapshot from the previous run.
|
|
246
|
+
*/
|
|
247
|
+
injectContext(sessionId: string, content: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* Force context compaction on the current session.
|
|
250
|
+
* Returns token stats before/after.
|
|
251
|
+
*/
|
|
252
|
+
forceCompact(): {
|
|
253
|
+
before: number;
|
|
254
|
+
after: number;
|
|
255
|
+
strategy: string;
|
|
256
|
+
};
|
|
257
|
+
private stripUserContextMessage;
|
|
258
|
+
private getSettingsManager;
|
|
259
|
+
/**
|
|
260
|
+
* Update a config setting at runtime.
|
|
261
|
+
*/
|
|
262
|
+
updateConfig(key: string, value: unknown): void;
|
|
263
|
+
/**
|
|
264
|
+
* Read a settings value by dotted key (e.g. "arena.participants").
|
|
265
|
+
* Returns undefined if any segment is missing.
|
|
266
|
+
*/
|
|
267
|
+
readSetting(key: string): unknown;
|
|
268
|
+
private buildPermissionConfig;
|
|
269
|
+
/**
|
|
270
|
+
* Switch permission mode at runtime. Takes effect immediately for any
|
|
271
|
+
* in-flight ToolExecutor (which holds a reference to the same classifier),
|
|
272
|
+
* and the new mode is used for any subsequent run() calls.
|
|
273
|
+
* Session-only — does not persist to settings.
|
|
274
|
+
*/
|
|
275
|
+
setPermissionMode(mode: NonNullable<EngineConfig["permissionMode"]>): void;
|
|
276
|
+
getPermissionMode(): NonNullable<EngineConfig["permissionMode"]>;
|
|
277
|
+
/**
|
|
278
|
+
* Toggle plan mode directly. Called by the Plan tool (Task 7) via ToolContext.engine.
|
|
279
|
+
* Also syncs permissionMode to keep both fields consistent.
|
|
280
|
+
*/
|
|
281
|
+
setPlanMode(value: boolean): void;
|
|
282
|
+
/**
|
|
283
|
+
* Build a base ToolContext for this Engine. Used by run() (which then
|
|
284
|
+
* overlays turn-specific fields like sandbox and subAgentSpawner) and
|
|
285
|
+
* by tests that want a ToolContext without a full run() cycle.
|
|
286
|
+
*/
|
|
287
|
+
buildToolContext(): ToolContext;
|
|
288
|
+
/**
|
|
289
|
+
* Read settings.disabledSkills. Sub-agents skip this for the same
|
|
290
|
+
* reason they skip settings.hooks / plugin hooks (registerSettingsHooks
|
|
291
|
+
* at ~line 237): they run with a minimal surface area. Defaults to []
|
|
292
|
+
* so callers don't have to null-check.
|
|
293
|
+
*/
|
|
294
|
+
private readDisabledSkills;
|
|
295
|
+
}
|