@cjhyy/code-shell-core 0.5.0-rc.1 → 0.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/dist/agent/agent-definition-registry.d.ts +21 -3
- package/dist/agent/agent-definition-registry.js +49 -18
- package/dist/agent/agent-definition.d.ts +32 -0
- package/dist/agent/agent-definition.js +49 -4
- package/dist/arena/arena.js +11 -12
- package/dist/arena/context/context-tools.js +47 -6
- package/dist/arena/context/within-root.d.ts +7 -0
- package/dist/arena/context/within-root.js +15 -0
- package/dist/arena/iterate/phases/argue.js +8 -2
- package/dist/arena/iterate/phases/revise.js +1 -1
- package/dist/arena/iterate/phases/tournament.js +3 -3
- package/dist/arena/ledger.js +9 -1
- package/dist/arena/phases/adjudication.js +1 -4
- package/dist/arena/phases/build-consensus.js +1 -4
- package/dist/arena/phases/cross-review.js +2 -8
- package/dist/arena/phases/debate-rounds.js +1 -4
- package/dist/arena/phases/participant-research.js +1 -4
- package/dist/arena/phases/planning-detail-expansion.js +8 -10
- package/dist/arena/planner.js +0 -1
- package/dist/arena/providers/docs.d.ts +1 -0
- package/dist/arena/providers/docs.js +5 -2
- package/dist/arena/providers/repo.d.ts +1 -0
- package/dist/arena/providers/repo.js +5 -2
- package/dist/arena/strategies/utils.d.ts +1 -4
- package/dist/arena/strategies/utils.js +7 -51
- package/dist/arena/transitions.d.ts +7 -2
- package/dist/arena/transitions.js +9 -4
- package/dist/arena/types.d.ts +8 -2
- package/dist/automation/cron-expr.d.ts +41 -0
- package/dist/automation/cron-expr.js +169 -0
- package/dist/automation/index.d.ts +41 -0
- package/dist/automation/index.js +39 -0
- package/dist/automation/runner.d.ts +84 -0
- package/dist/automation/runner.js +92 -0
- package/dist/automation/scheduler.d.ts +194 -0
- package/dist/automation/scheduler.js +623 -0
- package/dist/automation/store.d.ts +39 -0
- package/dist/automation/store.js +122 -0
- package/dist/automation/write-policy.d.ts +34 -0
- package/dist/automation/write-policy.js +113 -0
- package/dist/automation/write-run.d.ts +51 -0
- package/dist/automation/write-run.js +38 -0
- package/dist/capability-control/disabled-lists.d.ts +25 -0
- package/dist/capability-control/disabled-lists.js +57 -0
- package/dist/capability-control/index.d.ts +5 -0
- package/dist/capability-control/index.js +3 -0
- package/dist/capability-control/overlay.d.ts +64 -0
- package/dist/capability-control/overlay.js +116 -0
- package/dist/capability-control/project.d.ts +65 -0
- package/dist/capability-control/project.js +147 -0
- package/dist/capability-control/service.d.ts +70 -0
- package/dist/capability-control/service.js +147 -0
- package/dist/capability-control/types.d.ts +62 -0
- package/dist/capability-control/types.js +17 -0
- package/dist/cc-orchestrator/agent-adapter.d.ts +50 -0
- package/dist/cc-orchestrator/agent-adapter.js +133 -0
- package/dist/cc-orchestrator/cc-capability.d.ts +19 -0
- package/dist/cc-orchestrator/cc-capability.js +53 -0
- package/dist/cc-orchestrator/codex-session-discovery.d.ts +24 -0
- package/dist/cc-orchestrator/codex-session-discovery.js +191 -0
- package/dist/cc-orchestrator/codex-session-history.d.ts +25 -0
- package/dist/cc-orchestrator/codex-session-history.js +187 -0
- package/dist/cc-orchestrator/external-agent-changes.d.ts +19 -0
- package/dist/cc-orchestrator/external-agent-changes.js +214 -0
- package/dist/cc-orchestrator/external-agent-driver.d.ts +18 -0
- package/dist/cc-orchestrator/external-agent-driver.js +69 -0
- package/dist/cc-orchestrator/index.d.ts +8 -0
- package/dist/cc-orchestrator/index.js +8 -0
- package/dist/cc-orchestrator/relevance-judge.d.ts +15 -0
- package/dist/cc-orchestrator/relevance-judge.js +29 -0
- package/dist/cc-orchestrator/session-discovery.d.ts +46 -0
- package/dist/cc-orchestrator/session-discovery.js +125 -0
- package/dist/cc-orchestrator/session-history.d.ts +19 -0
- package/dist/cc-orchestrator/session-history.js +67 -0
- package/dist/cli/agent-server-stdio.d.ts +26 -1
- package/dist/cli/agent-server-stdio.js +221 -28
- package/dist/cli/agent-server-tcp.d.ts +20 -0
- package/dist/cli/agent-server-tcp.js +134 -0
- package/dist/cli/graceful-shutdown.d.ts +27 -0
- package/dist/cli/graceful-shutdown.js +30 -0
- package/dist/context/compaction.d.ts +56 -0
- package/dist/context/compaction.js +209 -15
- package/dist/context/manager.d.ts +0 -20
- package/dist/context/manager.js +25 -41
- package/dist/cost-tracker.js +5 -61
- package/dist/credentials/cipher.d.ts +49 -0
- package/dist/credentials/cipher.js +45 -0
- package/dist/credentials/cookie-jar.d.ts +24 -0
- package/dist/credentials/cookie-jar.js +40 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/inject-credential-tool.d.ts +20 -0
- package/dist/credentials/inject-credential-tool.js +130 -0
- package/dist/credentials/store.d.ts +72 -0
- package/dist/credentials/store.js +184 -0
- package/dist/credentials/types.d.ts +56 -0
- package/dist/credentials/use-credential-tool.d.ts +29 -0
- package/dist/credentials/use-credential-tool.js +205 -0
- package/dist/credentials/use-gate.d.ts +56 -0
- package/dist/credentials/use-gate.js +52 -0
- package/dist/cron/cron-runtime.d.ts +2 -0
- package/dist/cron/cron-runtime.js +2 -0
- package/dist/cron/cron-store.d.ts +2 -0
- package/dist/cron/cron-store.js +2 -0
- package/dist/cron/scheduler.d.ts +5 -32
- package/dist/cron/scheduler.js +5 -113
- package/dist/data/model-metadata.d.ts +77 -0
- package/dist/data/model-metadata.js +56 -0
- package/dist/data/model-metadata.json +216 -0
- package/dist/data/openrouter-models.d.ts +18 -7
- package/dist/data/openrouter-models.js +35 -8
- package/dist/data/openrouter-sync.js +1 -1
- package/dist/engine/aux-key.d.ts +10 -0
- package/dist/engine/aux-key.js +11 -0
- package/dist/engine/dynamic-tool-defs.d.ts +19 -0
- package/dist/engine/dynamic-tool-defs.js +36 -0
- package/dist/engine/engine.d.ts +431 -108
- package/dist/engine/engine.js +1630 -279
- package/dist/engine/friendly-error.d.ts +18 -0
- package/dist/engine/friendly-error.js +63 -0
- package/dist/engine/goal.d.ts +187 -0
- package/dist/engine/goal.js +196 -0
- package/dist/engine/image-compression.d.ts +81 -0
- package/dist/engine/image-compression.js +186 -0
- package/dist/engine/image-policy.d.ts +165 -0
- package/dist/engine/image-policy.js +189 -0
- package/dist/engine/model-connections-pool.d.ts +17 -0
- package/dist/engine/model-connections-pool.js +66 -0
- package/dist/engine/model-facade.d.ts +10 -0
- package/dist/engine/model-facade.js +25 -0
- package/dist/engine/patch-orphaned-tools.js +3 -0
- package/dist/engine/reactive-threshold.d.ts +13 -0
- package/dist/engine/reactive-threshold.js +17 -0
- package/dist/engine/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.js +9 -1
- package/dist/engine/sandbox-cache-key.d.ts +10 -0
- package/dist/engine/sandbox-cache-key.js +9 -0
- package/dist/engine/sandbox-config.d.ts +31 -0
- package/dist/engine/sandbox-config.js +38 -0
- package/dist/engine/session-title.d.ts +13 -0
- package/dist/engine/session-title.js +34 -0
- package/dist/engine/session-usage.d.ts +19 -0
- package/dist/engine/session-usage.js +25 -0
- package/dist/engine/steer-queue.d.ts +32 -0
- package/dist/engine/steer-queue.js +26 -0
- package/dist/engine/streaming-tool-queue.d.ts +12 -0
- package/dist/engine/streaming-tool-queue.js +50 -10
- package/dist/engine/turn-loop.d.ts +94 -9
- package/dist/engine/turn-loop.js +775 -342
- package/dist/engine/types.d.ts +175 -0
- package/dist/engine/types.js +13 -0
- package/dist/external-agents/config.d.ts +2 -0
- package/dist/external-agents/config.js +15 -0
- package/dist/external-agents/types.d.ts +31 -0
- package/dist/external-agents/types.js +1 -0
- package/dist/git/parse-log.d.ts +13 -0
- package/dist/git/parse-log.js +21 -0
- package/dist/git/utils.d.ts +8 -6
- package/dist/git/utils.js +62 -26
- package/dist/git/worktree.d.ts +48 -0
- package/dist/git/worktree.js +111 -20
- package/dist/hooks/events.d.ts +23 -1
- package/dist/hooks/goal-stop-hook.d.ts +58 -0
- package/dist/hooks/goal-stop-hook.js +279 -0
- package/dist/hooks/hook-output.d.ts +33 -0
- package/dist/hooks/hook-output.js +79 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +57 -1
- package/dist/hooks/shell-runner.d.ts +2 -0
- package/dist/hooks/shell-runner.js +48 -18
- package/dist/index.d.ts +79 -11
- package/dist/index.js +89 -6
- package/dist/llm/capabilities/param-specs.d.ts +14 -0
- package/dist/llm/capabilities/param-specs.js +62 -0
- package/dist/llm/capabilities/reasoning-control.d.ts +24 -0
- package/dist/llm/capabilities/reasoning-control.js +38 -0
- package/dist/llm/capabilities/rules.js +37 -3
- package/dist/llm/capabilities/types.d.ts +32 -2
- package/dist/llm/clamp-max-tokens.d.ts +11 -0
- package/dist/llm/clamp-max-tokens.js +17 -0
- package/dist/llm/client-base.d.ts +69 -5
- package/dist/llm/client-base.js +185 -25
- package/dist/llm/client-factory.d.ts +3 -3
- package/dist/llm/client-factory.js +2 -2
- package/dist/llm/model-cache.js +4 -2
- package/dist/llm/model-pool.d.ts +29 -11
- package/dist/llm/model-pool.js +36 -20
- package/dist/llm/provider-auth.d.ts +41 -0
- package/dist/llm/provider-auth.js +76 -0
- package/dist/llm/provider-catalog.d.ts +6 -2
- package/dist/llm/providers/anthropic.d.ts +32 -2
- package/dist/llm/providers/anthropic.js +207 -18
- package/dist/llm/providers/openai.d.ts +47 -2
- package/dist/llm/providers/openai.js +478 -71
- package/dist/llm/reasoning-setting.d.ts +51 -0
- package/dist/llm/reasoning-setting.js +40 -0
- package/dist/llm/stop-reason.d.ts +13 -0
- package/dist/llm/stop-reason.js +21 -0
- package/dist/llm/stream-watchdog.js +5 -1
- package/dist/llm/strip-vision.d.ts +32 -0
- package/dist/llm/strip-vision.js +94 -0
- package/dist/llm/token-counter.js +9 -2
- package/dist/llm/types.d.ts +9 -6
- package/dist/logging/logger.js +18 -4
- package/dist/logging/sanitize-messages.d.ts +10 -0
- package/dist/logging/sanitize-messages.js +112 -0
- package/dist/lsp/client.js +28 -8
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +42 -11
- package/dist/lsp/root-path.d.ts +9 -0
- package/dist/lsp/root-path.js +12 -0
- package/dist/model-catalog/builtin.d.ts +12 -0
- package/dist/model-catalog/builtin.js +407 -0
- package/dist/model-catalog/gen-connections.d.ts +20 -0
- package/dist/model-catalog/gen-connections.js +28 -0
- package/dist/model-catalog/index.d.ts +41 -0
- package/dist/model-catalog/index.js +90 -0
- package/dist/model-catalog/params.d.ts +20 -0
- package/dist/model-catalog/params.js +45 -0
- package/dist/model-catalog/resolve.d.ts +48 -0
- package/dist/model-catalog/resolve.js +33 -0
- package/dist/model-catalog/save-entry.d.ts +32 -0
- package/dist/model-catalog/save-entry.js +104 -0
- package/dist/model-catalog/types.d.ts +561 -0
- package/dist/model-catalog/types.js +93 -0
- package/dist/model-catalog/upsert.d.ts +9 -0
- package/dist/model-catalog/upsert.js +8 -0
- package/dist/onboarding.d.ts +12 -82
- package/dist/onboarding.js +75 -333
- package/dist/plugins/gitOps.d.ts +53 -0
- package/dist/plugins/gitOps.js +130 -5
- package/dist/plugins/installer/checkUpdate.d.ts +16 -0
- package/dist/plugins/installer/checkUpdate.js +32 -0
- package/dist/plugins/installer/codex/convertAgents.d.ts +7 -0
- package/dist/plugins/installer/codex/convertAgents.js +55 -0
- package/dist/plugins/installer/codex/convertCommands.d.ts +19 -0
- package/dist/plugins/installer/codex/convertCommands.js +46 -0
- package/dist/plugins/installer/codex/convertMcp.d.ts +11 -0
- package/dist/plugins/installer/codex/convertMcp.js +85 -0
- package/dist/plugins/installer/codex/convertSkills.d.ts +12 -0
- package/dist/plugins/installer/codex/convertSkills.js +33 -0
- package/dist/plugins/installer/detectFormat.d.ts +2 -0
- package/dist/plugins/installer/detectFormat.js +6 -0
- package/dist/plugins/installer/install.d.ts +7 -0
- package/dist/plugins/installer/install.js +123 -0
- package/dist/plugins/installer/installFromArchive.d.ts +43 -0
- package/dist/plugins/installer/installFromArchive.js +134 -0
- package/dist/plugins/installer/installFromSource.d.ts +13 -0
- package/dist/plugins/installer/installFromSource.js +51 -0
- package/dist/plugins/installer/list.d.ts +9 -0
- package/dist/plugins/installer/list.js +30 -0
- package/dist/plugins/installer/loadPluginAgents.d.ts +3 -0
- package/dist/plugins/installer/loadPluginAgents.js +27 -0
- package/dist/plugins/installer/loadPluginMcp.d.ts +14 -0
- package/dist/plugins/installer/loadPluginMcp.js +107 -0
- package/dist/plugins/installer/parseSource.d.ts +20 -0
- package/dist/plugins/installer/parseSource.js +74 -0
- package/dist/plugins/installer/paths.d.ts +5 -0
- package/dist/plugins/installer/paths.js +25 -0
- package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
- package/dist/plugins/installer/pruneDisabled.js +73 -0
- package/dist/plugins/installer/types.d.ts +52 -0
- package/dist/plugins/installer/types.js +28 -0
- package/dist/plugins/installer/uninstall.d.ts +2 -0
- package/dist/plugins/installer/uninstall.js +18 -0
- package/dist/plugins/installer/unzip.d.ts +14 -0
- package/dist/plugins/installer/unzip.js +82 -0
- package/dist/plugins/installer/update.d.ts +28 -0
- package/dist/plugins/installer/update.js +97 -0
- package/dist/plugins/loadPluginHooks.d.ts +54 -1
- package/dist/plugins/loadPluginHooks.js +83 -1
- package/dist/plugins/marketplaceManager.d.ts +15 -1
- package/dist/plugins/marketplaceManager.js +58 -4
- package/dist/plugins/pluginCommandHook.js +34 -14
- package/dist/plugins/pluginContent.d.ts +30 -0
- package/dist/plugins/pluginContent.js +83 -0
- package/dist/plugins/pluginInstaller.d.ts +34 -0
- package/dist/plugins/pluginInstaller.js +168 -35
- package/dist/plugins/schemas.js +41 -6
- package/dist/plugins/types.d.ts +10 -0
- package/dist/preset/index.d.ts +7 -1
- package/dist/preset/index.js +112 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +31 -0
- package/dist/prompt/composer.js +95 -25
- package/dist/prompt/instruction-scanner.js +5 -3
- package/dist/prompt/section-loader.js +1 -0
- package/dist/prompt/sections/base.md +1 -0
- package/dist/prompt/sections/browser.md +10 -0
- package/dist/prompt/sections/coding.md +4 -0
- package/dist/prompt/sections/orchestration.md +8 -0
- package/dist/protocol/chat-session-manager.d.ts +15 -2
- package/dist/protocol/chat-session-manager.js +46 -0
- package/dist/protocol/chat-session.d.ts +82 -0
- package/dist/protocol/chat-session.js +121 -1
- package/dist/protocol/client.d.ts +27 -0
- package/dist/protocol/client.js +38 -0
- package/dist/protocol/redact.d.ts +50 -0
- package/dist/protocol/redact.js +71 -0
- package/dist/protocol/server.d.ts +153 -2
- package/dist/protocol/server.js +807 -39
- package/dist/protocol/tcp-transport.d.ts +45 -0
- package/dist/protocol/tcp-transport.js +74 -0
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +69 -0
- package/dist/protocol/types.js +22 -0
- package/dist/quota/credentials.d.ts +3 -0
- package/dist/quota/credentials.js +80 -0
- package/dist/quota/index.d.ts +36 -0
- package/dist/quota/index.js +155 -0
- package/dist/quota/types.d.ts +48 -0
- package/dist/quota/types.js +13 -0
- package/dist/remote/bridge.d.ts +11 -2
- package/dist/remote/bridge.js +61 -33
- package/dist/review/review-prompt.d.ts +28 -0
- package/dist/review/review-prompt.js +81 -0
- package/dist/run/ArtifactTracker.js +5 -4
- package/dist/run/EngineRunner.d.ts +27 -1
- package/dist/run/EngineRunner.js +46 -8
- package/dist/run/FileRunStore.js +40 -11
- package/dist/run/RunApprovalBackend.js +25 -5
- package/dist/run/RunLock.d.ts +28 -2
- package/dist/run/RunLock.js +49 -7
- package/dist/run/RunManager.d.ts +12 -0
- package/dist/run/RunManager.js +86 -3
- package/dist/run/RunQueue.d.ts +1 -0
- package/dist/run/RunQueue.js +8 -2
- package/dist/run/factory.d.ts +8 -1
- package/dist/run/factory.js +1 -0
- package/dist/run/index.d.ts +2 -2
- package/dist/run/index.js +1 -1
- package/dist/run/redirect-target.d.ts +7 -0
- package/dist/run/redirect-target.js +13 -0
- package/dist/run/types.js +1 -1
- package/dist/runtime/background-shell.d.ts +139 -0
- package/dist/runtime/background-shell.js +495 -0
- package/dist/runtime/output-clean.d.ts +24 -0
- package/dist/runtime/output-clean.js +41 -0
- package/dist/runtime/ring-file.d.ts +64 -0
- package/dist/runtime/ring-file.js +174 -0
- package/dist/runtime/safe-spawn.js +15 -34
- package/dist/runtime/spawn-common.d.ts +148 -0
- package/dist/runtime/spawn-common.js +303 -0
- package/dist/runtime/truncate-output.d.ts +22 -0
- package/dist/runtime/truncate-output.js +49 -0
- package/dist/runtime/utf8-cut.d.ts +11 -0
- package/dist/runtime/utf8-cut.js +23 -0
- package/dist/services/auto-dream.d.ts +4 -0
- package/dist/services/auto-dream.js +26 -26
- package/dist/services/browser-open.d.ts +13 -0
- package/dist/services/browser-open.js +16 -0
- package/dist/services/diagnostics.d.ts +1 -2
- package/dist/services/diagnostics.js +12 -7
- package/dist/services/dream-consolidation.d.ts +57 -0
- package/dist/services/dream-consolidation.js +151 -0
- package/dist/services/extract-memories.d.ts +14 -1
- package/dist/services/extract-memories.js +45 -6
- package/dist/services/memory-orchestrator.d.ts +21 -0
- package/dist/services/memory-orchestrator.js +125 -32
- package/dist/services/notifier.d.ts +8 -0
- package/dist/services/notifier.js +39 -25
- package/dist/services/oauth.js +5 -7
- package/dist/services/session-memory-sort.d.ts +8 -0
- package/dist/services/session-memory-sort.js +9 -0
- package/dist/services/session-memory.js +30 -19
- package/dist/session/file-history.d.ts +124 -1
- package/dist/session/file-history.js +232 -9
- package/dist/session/memory.d.ts +116 -2
- package/dist/session/memory.js +250 -28
- package/dist/session/session-manager.d.ts +63 -1
- package/dist/session/session-manager.js +186 -5
- package/dist/session/simple-diff.d.ts +23 -0
- package/dist/session/simple-diff.js +84 -0
- package/dist/session/transcript.d.ts +25 -1
- package/dist/session/transcript.js +35 -2
- package/dist/session/undo-target.d.ts +67 -0
- package/dist/session/undo-target.js +144 -0
- package/dist/settings/disk-defaults.d.ts +42 -0
- package/dist/settings/disk-defaults.js +33 -0
- package/dist/settings/feature-flags.d.ts +64 -0
- package/dist/settings/feature-flags.js +61 -0
- package/dist/settings/manager.d.ts +101 -1
- package/dist/settings/manager.js +345 -15
- package/dist/settings/migrate-config.d.ts +45 -0
- package/dist/settings/migrate-config.js +125 -0
- package/dist/settings/personalization.d.ts +19 -0
- package/dist/settings/personalization.js +7 -0
- package/dist/settings/schema-export.d.ts +25 -0
- package/dist/settings/schema-export.js +38 -0
- package/dist/settings/schema.d.ts +1827 -396
- package/dist/settings/schema.js +361 -81
- package/dist/skills/scanner.d.ts +9 -0
- package/dist/skills/scanner.js +30 -2
- package/dist/stt/resolve-transcribe.d.ts +31 -0
- package/dist/stt/resolve-transcribe.js +108 -0
- package/dist/stt/transcribe.d.ts +51 -0
- package/dist/stt/transcribe.js +65 -0
- package/dist/tool-system/browser-bridge.d.ts +226 -0
- package/dist/tool-system/browser-bridge.js +163 -0
- package/dist/tool-system/builtin/add-marketplace.d.ts +12 -0
- package/dist/tool-system/builtin/add-marketplace.js +76 -0
- package/dist/tool-system/builtin/agent-heartbeat.d.ts +49 -0
- package/dist/tool-system/builtin/agent-heartbeat.js +89 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +12 -3
- package/dist/tool-system/builtin/agent-notifications.js +9 -3
- package/dist/tool-system/builtin/agent-output-file.d.ts +38 -0
- package/dist/tool-system/builtin/agent-output-file.js +72 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +23 -0
- package/dist/tool-system/builtin/agent-registry.js +16 -4
- package/dist/tool-system/builtin/agent.d.ts +50 -11
- package/dist/tool-system/builtin/agent.js +576 -73
- package/dist/tool-system/builtin/apply-patch/applier.js +66 -8
- package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +10 -0
- package/dist/tool-system/builtin/apply-patch/backup-targets.js +30 -0
- package/dist/tool-system/builtin/apply-patch/index.js +7 -3
- package/dist/tool-system/builtin/arena.js +6 -7
- package/dist/tool-system/builtin/background-jobs.d.ts +76 -0
- package/dist/tool-system/builtin/background-jobs.js +124 -0
- package/dist/tool-system/builtin/background-shell-tools.d.ts +20 -0
- package/dist/tool-system/builtin/background-shell-tools.js +108 -0
- package/dist/tool-system/builtin/background-work.d.ts +67 -0
- package/dist/tool-system/builtin/background-work.js +86 -0
- package/dist/tool-system/builtin/bash-output-style.d.ts +32 -0
- package/dist/tool-system/builtin/bash-output-style.js +40 -0
- package/dist/tool-system/builtin/bash.d.ts +5 -2
- package/dist/tool-system/builtin/bash.js +98 -62
- package/dist/tool-system/builtin/browser-tools.d.ts +33 -0
- package/dist/tool-system/builtin/browser-tools.js +312 -0
- package/dist/tool-system/builtin/cancel-goal.d.ts +31 -0
- package/dist/tool-system/builtin/cancel-goal.js +64 -0
- package/dist/tool-system/builtin/check-quota.d.ts +15 -0
- package/dist/tool-system/builtin/check-quota.js +34 -0
- package/dist/tool-system/builtin/complete-goal.d.ts +25 -0
- package/dist/tool-system/builtin/complete-goal.js +45 -0
- package/dist/tool-system/builtin/config.js +7 -0
- package/dist/tool-system/builtin/cron.d.ts +7 -0
- package/dist/tool-system/builtin/cron.js +105 -9
- package/dist/tool-system/builtin/drive-claude-code.d.ts +30 -0
- package/dist/tool-system/builtin/drive-claude-code.js +157 -0
- package/dist/tool-system/builtin/edit-model-catalog.d.ts +3 -0
- package/dist/tool-system/builtin/edit-model-catalog.js +94 -0
- package/dist/tool-system/builtin/edit.d.ts +2 -1
- package/dist/tool-system/builtin/edit.js +21 -12
- package/dist/tool-system/builtin/eol.d.ts +29 -0
- package/dist/tool-system/builtin/eol.js +37 -0
- package/dist/tool-system/builtin/file-cache.d.ts +6 -0
- package/dist/tool-system/builtin/file-cache.js +8 -0
- package/dist/tool-system/builtin/generate-image.d.ts +60 -0
- package/dist/tool-system/builtin/generate-image.js +374 -0
- package/dist/tool-system/builtin/generate-video.d.ts +55 -0
- package/dist/tool-system/builtin/generate-video.js +361 -0
- package/dist/tool-system/builtin/grep.js +6 -2
- package/dist/tool-system/builtin/image-providers.d.ts +86 -0
- package/dist/tool-system/builtin/image-providers.js +190 -0
- package/dist/tool-system/builtin/image-uploader.d.ts +33 -0
- package/dist/tool-system/builtin/image-uploader.js +74 -0
- package/dist/tool-system/builtin/index.d.ts +24 -1
- package/dist/tool-system/builtin/index.js +310 -25
- package/dist/tool-system/builtin/mcp-tools.js +23 -3
- package/dist/tool-system/builtin/memory.js +45 -7
- package/dist/tool-system/builtin/notebook-edit.d.ts +2 -1
- package/dist/tool-system/builtin/notebook-edit.js +1 -1
- package/dist/tool-system/builtin/powershell.js +4 -1
- package/dist/tool-system/builtin/read.d.ts +2 -1
- package/dist/tool-system/builtin/read.js +11 -3
- package/dist/tool-system/builtin/repl.js +4 -1
- package/dist/tool-system/builtin/skill.js +9 -0
- package/dist/tool-system/builtin/sleep.js +12 -5
- package/dist/tool-system/builtin/task.js +4 -1
- package/dist/tool-system/builtin/tool-search.js +25 -7
- package/dist/tool-system/builtin/update-automation-memory.d.ts +24 -0
- package/dist/tool-system/builtin/update-automation-memory.js +60 -0
- package/dist/tool-system/builtin/video-providers.d.ts +154 -0
- package/dist/tool-system/builtin/video-providers.js +235 -0
- package/dist/tool-system/builtin/view-image.d.ts +18 -0
- package/dist/tool-system/builtin/view-image.js +96 -0
- package/dist/tool-system/builtin/web-fetch.js +12 -2
- package/dist/tool-system/builtin/web-search.d.ts +4 -1
- package/dist/tool-system/builtin/web-search.js +57 -10
- package/dist/tool-system/builtin/worktree.d.ts +2 -1
- package/dist/tool-system/builtin/worktree.js +31 -4
- package/dist/tool-system/builtin/write.d.ts +2 -1
- package/dist/tool-system/builtin/write.js +1 -1
- package/dist/tool-system/context.d.ts +166 -6
- package/dist/tool-system/executor.d.ts +3 -2
- package/dist/tool-system/executor.js +197 -119
- package/dist/tool-system/investigation-guard.d.ts +4 -1
- package/dist/tool-system/investigation-guard.js +20 -4
- package/dist/tool-system/mcp-manager.d.ts +78 -16
- package/dist/tool-system/mcp-manager.js +357 -28
- package/dist/tool-system/path-policy.d.ts +99 -0
- package/dist/tool-system/path-policy.js +578 -0
- package/dist/tool-system/permission.d.ts +36 -1
- package/dist/tool-system/permission.js +322 -117
- package/dist/tool-system/plan-mode-allowlist.d.ts +32 -0
- package/dist/tool-system/plan-mode-allowlist.js +65 -0
- package/dist/tool-system/registry.d.ts +1 -0
- package/dist/tool-system/registry.js +26 -1
- package/dist/tool-system/sandbox/index.d.ts +8 -0
- package/dist/tool-system/sandbox/index.js +7 -2
- package/dist/tool-system/validate-tool-metadata.d.ts +36 -0
- package/dist/tool-system/validate-tool-metadata.js +63 -0
- package/dist/tool-system/validation.d.ts +10 -0
- package/dist/tool-system/validation.js +16 -3
- package/dist/types.d.ts +301 -15
- package/dist/updater.js +20 -9
- package/dist/utils/envUtils.d.ts +0 -9
- package/dist/utils/envUtils.js +3 -28
- package/dist/utils/exec.d.ts +40 -0
- package/dist/utils/exec.js +144 -0
- package/dist/utils/format.js +4 -2
- package/dist/utils/json.d.ts +12 -0
- package/dist/utils/json.js +92 -0
- package/dist/utils/lockfile.js +9 -2
- package/dist/utils/theme.d.ts +7 -1
- package/dist/utils/theme.js +5 -3
- package/dist/utils/toolDisplay.js +0 -1
- package/package.json +14 -7
- package/dist/agent/coordinator.d.ts +0 -49
- package/dist/agent/coordinator.js +0 -77
- package/dist/settings/manager.test.js +0 -73
- package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
- package/dist/tool-system/builtin/remote-trigger.js +0 -54
- package/dist/tool-system/builtin/send-message.d.ts +0 -6
- package/dist/tool-system/builtin/send-message.js +0 -47
- /package/dist/{settings/manager.test.d.ts → credentials/types.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API exports.
|
|
5
5
|
*/
|
|
6
|
-
export const VERSION = "0.5.0-rc.
|
|
6
|
+
export const VERSION = "0.5.0-rc.2";
|
|
7
7
|
// ─── Exceptions ──────────────────────────────────────────────────
|
|
8
8
|
export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, SandboxUnavailableError, } from "./exceptions.js";
|
|
9
9
|
// ─── Engine (primary API) ────────────────────────────────────────
|
|
10
|
-
export { Engine } from "./engine/engine.js";
|
|
10
|
+
export { Engine, loadAgentDefinitionsForCwd } from "./engine/engine.js";
|
|
11
|
+
export { resolveLLMConfigForTag } from "./engine/resolve-llm-config.js";
|
|
12
|
+
export { resolveAuxKey } from "./engine/aux-key.js";
|
|
13
|
+
export { parseAgentDefinition, serializeAgentDefinition, } from "./agent/agent-definition.js";
|
|
14
|
+
export { AgentDefinitionRegistry, } from "./agent/agent-definition-registry.js";
|
|
11
15
|
export { EngineRuntime } from "./engine/runtime.js";
|
|
12
16
|
export { ChatSessionManager } from "./protocol/chat-session-manager.js";
|
|
13
17
|
// ─── LLM ─────────────────────────────────────────────────────────
|
|
@@ -16,12 +20,14 @@ export { createLLMClient, registerProvider } from "./llm/client-factory.js";
|
|
|
16
20
|
export { AnthropicClient } from "./llm/providers/anthropic.js";
|
|
17
21
|
export { OpenAIClient } from "./llm/providers/openai.js";
|
|
18
22
|
export { ModelPool } from "./llm/model-pool.js";
|
|
23
|
+
export { modelEntriesFromConnections } from "./engine/model-connections-pool.js";
|
|
19
24
|
// ─── Tools ───────────────────────────────────────────────────────
|
|
20
25
|
export { ToolRegistry } from "./tool-system/registry.js";
|
|
21
26
|
export { ToolExecutor } from "./tool-system/executor.js";
|
|
22
27
|
export { PermissionClassifier, HeadlessApprovalBackend, AutoApprovalBackend } from "./tool-system/permission.js";
|
|
23
28
|
export { BUILTIN_TOOLS } from "./tool-system/builtin/index.js";
|
|
24
|
-
export {
|
|
29
|
+
export { makeUpdateAutomationMemoryTool } from "./tool-system/builtin/update-automation-memory.js";
|
|
30
|
+
export { MCPManager, buildHttpHeaders, buildStdioEnv } from "./tool-system/mcp-manager.js";
|
|
25
31
|
// ─── Hooks ───────────────────────────────────────────────────────
|
|
26
32
|
export { HookRegistry } from "./hooks/registry.js";
|
|
27
33
|
export { wrapHookMessages } from "./hooks/inject.js";
|
|
@@ -29,6 +35,7 @@ export { wrapHookMessages } from "./hooks/inject.js";
|
|
|
29
35
|
export { AgentServer } from "./protocol/server.js";
|
|
30
36
|
export { AgentClient } from "./protocol/client.js";
|
|
31
37
|
export { createInProcessTransport, StdioTransport, } from "./protocol/transport.js";
|
|
38
|
+
export { SocketTransport, listenTcp, } from "./protocol/tcp-transport.js";
|
|
32
39
|
// Recommended public factories — see protocol/factories.ts for the
|
|
33
40
|
// stable construction contract referenced by standard §7.
|
|
34
41
|
export { createServer, createClient, } from "./protocol/factories.js";
|
|
@@ -37,7 +44,10 @@ export { Methods, ErrorCodes, } from "./protocol/types.js";
|
|
|
37
44
|
export { Transcript } from "./session/transcript.js";
|
|
38
45
|
export { SessionManager } from "./session/session-manager.js";
|
|
39
46
|
export { FileHistory } from "./session/file-history.js";
|
|
47
|
+
export { latestUndoTarget, earliestSnapshotsPerFile, latestTurnUndoTargets, latestRedoTargets, } from "./session/undo-target.js";
|
|
48
|
+
export { diffLines, renderDiffPreview } from "./session/simple-diff.js";
|
|
40
49
|
export { MemoryManager } from "./session/memory.js";
|
|
50
|
+
export { runDreamConsolidation, } from "./services/dream-consolidation.js";
|
|
41
51
|
// ─── Prompt ──────────────────────────────────────────────────────
|
|
42
52
|
export { PromptComposer } from "./prompt/composer.js";
|
|
43
53
|
export { SectionCache } from "./prompt/section-cache.js";
|
|
@@ -51,6 +61,26 @@ export { estimateTokens, microcompact, windowCompact, truncateToolResult, buildS
|
|
|
51
61
|
export { applyToolResultPersistence, createContentReplacementState, reconstructContentReplacementState, resolveToolResultsDir, isPersistedReplacement, DEFAULT_PERSIST_THRESHOLD, PER_MESSAGE_AGGREGATE_CAP, PREVIEW_SIZE, } from "./context/tool-result-storage.js";
|
|
52
62
|
// ─── Skills ──────────────────────────────────────────────────────
|
|
53
63
|
export { scanSkills, invalidateSkillCache } from "./skills/index.js";
|
|
64
|
+
// ─── Capability control (扩展能力 backend) ───────────────────────
|
|
65
|
+
export { CapabilityService, CapabilityNotFoundError, projectBuiltin, projectMcp, projectSkills, projectPlugins, } from "./capability-control/index.js";
|
|
66
|
+
export { readInstalledPlugins } from "./plugins/installedPlugins.js";
|
|
67
|
+
export { computeEffectiveDisabledLists, } from "./capability-control/disabled-lists.js";
|
|
68
|
+
// ─── Plugin installer (CC + Codex) ───────────────────────────────
|
|
69
|
+
export { installPluginFromPath } from "./plugins/installer/install.js";
|
|
70
|
+
export { installPluginFromSource } from "./plugins/installer/installFromSource.js";
|
|
71
|
+
export { installLocalPlugin, installPluginFromArchive, } from "./plugins/installer/installFromArchive.js";
|
|
72
|
+
export { parseSource } from "./plugins/installer/parseSource.js";
|
|
73
|
+
export { detectPluginFormat } from "./plugins/installer/detectFormat.js";
|
|
74
|
+
export { CodexPluginManifest, CSMeta, PluginInstallError, } from "./plugins/installer/types.js";
|
|
75
|
+
export { mergePluginMcpServers } from "./plugins/installer/loadPluginMcp.js";
|
|
76
|
+
export { listPluginHooks, pluginHookKey } from "./plugins/loadPluginHooks.js";
|
|
77
|
+
export { describePluginContent } from "./plugins/pluginContent.js";
|
|
78
|
+
export { pluginAgentDirs } from "./plugins/installer/loadPluginAgents.js";
|
|
79
|
+
export { appendInstallEntry, pluginInstallKey, removeInstallEntries, } from "./plugins/installedPlugins.js";
|
|
80
|
+
export { uninstallPluginByName } from "./plugins/installer/uninstall.js";
|
|
81
|
+
export { listInstalledPlugins } from "./plugins/installer/list.js";
|
|
82
|
+
export { updatePluginByName } from "./plugins/installer/update.js";
|
|
83
|
+
export { checkPluginUpdate } from "./plugins/installer/checkUpdate.js";
|
|
54
84
|
// ─── Arena ───────────────────────────────────────────────────────
|
|
55
85
|
export { Arena } from "./arena/arena.js";
|
|
56
86
|
export { MODEL_PRESETS, getMaxOutputTokens } from "./arena/model-presets.js";
|
|
@@ -75,7 +105,7 @@ RunManager, FileRunStore,
|
|
|
75
105
|
// Queue
|
|
76
106
|
RunQueue,
|
|
77
107
|
// Runner
|
|
78
|
-
EngineRunner,
|
|
108
|
+
EngineRunner, AUTOMATION_PROMPT_NOTE, AUTOMATION_RUN_SOURCE,
|
|
79
109
|
// Approval / Input adapters
|
|
80
110
|
RunApprovalBackend, createRunAskUserFn,
|
|
81
111
|
// Checkpoint & Artifacts
|
|
@@ -92,23 +122,37 @@ export { defineProduct, } from "./product/index.js";
|
|
|
92
122
|
export { logger } from "./logging/logger.js";
|
|
93
123
|
// ─── Settings ────────────────────────────────────────────────────
|
|
94
124
|
export { SettingsManager } from "./settings/manager.js";
|
|
125
|
+
export { migrateConfig, configVersionOf, CURRENT_CONFIG_VERSION, } from "./settings/migrate-config.js";
|
|
95
126
|
export { SettingsSchema, validateSettings } from "./settings/schema.js";
|
|
127
|
+
export { settingsJsonSchema, writeSettingsSchemaFile } from "./settings/schema-export.js";
|
|
128
|
+
export { personalizationFrom } from "./settings/personalization.js";
|
|
129
|
+
export { CredentialStore, formatNetscapeCookies, parseCookieJar, useCredentialToolDef, useCredentialToolDefFor, sweepStaleCredentialCookies, PlaintextCipher, setDefaultCredentialCipher, getDefaultCredentialCipher, } from "./credentials/index.js";
|
|
96
130
|
// ─── State (runtime singletons shared with TUI) ──────────────────
|
|
131
|
+
/** @internal Shared with the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
97
132
|
export { getSessionId, switchSession, getOriginalCwd, setOriginalCwd, getProjectRoot, setProjectRoot, getCwdState, getIsInteractive, updateLastInteractionTime, flushInteractionTime, markScrollActivity, } from "./state.js";
|
|
98
133
|
// ─── Utils (shared primitives used by TUI) ───────────────────────
|
|
134
|
+
/** @internal Shared primitives for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
99
135
|
export { getGraphemeSegmenter, firstGrapheme, lastGrapheme, getWordSegmenter, getRelativeTimeFormat, getTimeZone, getSystemLocaleLanguage, } from "./utils/intl.js";
|
|
100
136
|
export { env } from "./utils/env.js";
|
|
101
137
|
export { default as sliceAnsi } from "./utils/sliceAnsi.js";
|
|
102
138
|
export { execFileNoThrow } from "./utils/execFileNoThrow.js";
|
|
139
|
+
export { findExecutable, resolveExecutable, setGitPathOverride, resolveGit, isGitAvailable, } from "./utils/exec.js";
|
|
103
140
|
export { gte } from "./utils/semver.js";
|
|
141
|
+
// Cross-process file lock (proper-lockfile via createRequire, ESM-safe). Used by
|
|
142
|
+
// RunLock / CronStore internally; exported so other writers of shared files
|
|
143
|
+
// (e.g. desktop settings-service writing the same settings.json as the worker)
|
|
144
|
+
// can take the same advisory lock.
|
|
145
|
+
export { lock, lockSync, unlock, check } from "./utils/lockfile.js";
|
|
104
146
|
export { logForDebugging } from "./utils/debug.js";
|
|
105
|
-
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir,
|
|
147
|
+
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir, getAWSRegion, getDefaultVertexRegion, getVertexRegionForModel, } from "./utils/envUtils.js";
|
|
106
148
|
export { startCapturingEarlyInput, stopCapturingEarlyInput, consumeEarlyInput, hasEarlyInput, seedEarlyInput, isCapturingEarlyInput, } from "./utils/earlyInput.js";
|
|
107
149
|
export { formatBytes, formatToolArgs, singleLine, MAX_LINE_WIDTH, TOOL_DOT_COLORS, } from "./utils/toolDisplay.js";
|
|
150
|
+
export { classifyBashLines, } from "./tool-system/builtin/bash-output-style.js";
|
|
108
151
|
export { formatDuration, formatTokens } from "./utils/format.js";
|
|
109
152
|
export { getTheme, } from "./utils/theme.js";
|
|
110
153
|
export { resolveThemeSetting } from "./utils/systemTheme.js";
|
|
111
154
|
// ─── Logging (extended) ──────────────────────────────────────────
|
|
155
|
+
/** @internal Host-lifecycle logging hooks for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
112
156
|
export { rotateLogs } from "./logging/logger.js";
|
|
113
157
|
export { recordUIEvent } from "./logging/session-recorder.js";
|
|
114
158
|
// ─── Cost Tracker ────────────────────────────────────────────────
|
|
@@ -120,26 +164,65 @@ export { hasApiKey, resolveApiKey, appendOnboardingResult, detectEnvKeys, saveAr
|
|
|
120
164
|
export { getCurrentVersion, checkForUpdate, scheduleAutoInstallOnExit, getUpdateAvailable, getAutoUpdateDisabledReason, } from "./updater.js";
|
|
121
165
|
// ─── Git Utilities ───────────────────────────────────────────────
|
|
122
166
|
export { isGitRepo, getCurrentBranch, getGitStatus, getGitDiff, getGitDiffStat, getGitLog, gitAdd, gitCommit, gitListBranches, gitCheckout, ghAvailable, ghPrComments, } from "./git/utils.js";
|
|
167
|
+
// ─── Code review (TODO 7.3) ─────────────────────────────────────
|
|
168
|
+
export { buildReviewPrompt, parseDimensions, ALL_DIMENSIONS, } from "./review/review-prompt.js";
|
|
123
169
|
// ─── Tool-system (extended for TUI) ─────────────────────────────
|
|
170
|
+
/**
|
|
171
|
+
* @internal Exports below are consumed by the in-repo TUI/desktop hosts, not
|
|
172
|
+
* part of the stable `@cjhyy/code-shell-core` SDK surface. They may change or
|
|
173
|
+
* move to a `/tui` subpath without a major bump. External SDK users: prefer the
|
|
174
|
+
* primary Engine/Protocol API above.
|
|
175
|
+
*/
|
|
124
176
|
export { getInteractiveApprovalBackend } from "./tool-system/permission.js";
|
|
125
177
|
export { defaultSandboxConfig, } from "./tool-system/sandbox/index.js";
|
|
126
178
|
export { buildNotificationMessage, buildNotificationSummary, notificationQueue, agentNotificationBus, notificationItemToStreamEvent, } from "./tool-system/builtin/agent-notifications.js";
|
|
179
|
+
// Automation — zero-env-dependency scheduling module (startAutomation facade
|
|
180
|
+
// + scheduler/store/runner). Hosts (Electron main, future CLI server) load
|
|
181
|
+
// this and inject store + runner. See docs/automation-plan-2026-05-31.md.
|
|
182
|
+
export { startAutomation, CronScheduler, cronScheduler, CronStore, defaultCronStorePath, bindCronToEngine, bindCronToRunManager, isCronExpression, parseCronExpression, nextCronTime, resolveWritePolicy, wrapUntrustedInput, runWriteJobInWorktree, } from "./automation/index.js";
|
|
183
|
+
// CC orchestrator (external claude-cli rooms + CC-aware scheduling).
|
|
184
|
+
export * from "./cc-orchestrator/index.js";
|
|
185
|
+
// Quota — remaining CC/Codex subscription usage (self-contained, plugin-liftable).
|
|
186
|
+
export { checkQuota, formatQuota } from "./quota/index.js";
|
|
187
|
+
export { resolveQuotaCredentials } from "./quota/credentials.js";
|
|
127
188
|
export { asyncAgentRegistry, } from "./tool-system/builtin/agent-registry.js";
|
|
189
|
+
export { backgroundShellManager, BackgroundShellManager, } from "./runtime/background-shell.js";
|
|
190
|
+
export { getImageProvider, DEFAULT_IMAGE_MODEL, } from "./tool-system/builtin/image-providers.js";
|
|
191
|
+
// ─── Speech-to-text (voice input / 听写) ────────────────────────
|
|
192
|
+
export { transcribe, } from "./stt/transcribe.js";
|
|
193
|
+
export { resolveTranscribeProvider, isTranscribeAvailable, describeTranscribe, } from "./stt/resolve-transcribe.js";
|
|
194
|
+
export { BUILTIN_CATALOG, getMergedCatalog, loadUserCatalog, userCatalogPath, findCatalogEntry, saveCatalogEntry, deleteUserCatalogEntry, catalogEntryOrigins, } from "./model-catalog/index.js";
|
|
128
195
|
// ─── Protocol (extended for TUI) ────────────────────────────────
|
|
196
|
+
/** @internal Extended protocol surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
129
197
|
export { createInProcessClient } from "./protocol/helpers.js";
|
|
130
198
|
// ─── Arena (extended for TUI) ───────────────────────────────────
|
|
199
|
+
/** @internal Extended Arena surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
131
200
|
export { formatArenaResult, printArenaResult, renderProgress, createProgressRenderer, } from "./arena/render/terminal.js";
|
|
132
201
|
export { formatArenaResultForSession } from "./arena/render/session.js";
|
|
133
202
|
// ─── Plugins ─────────────────────────────────────────────────────
|
|
134
203
|
export { installPlugin, uninstallPlugin, listInstalled, } from "./plugins/pluginInstaller.js";
|
|
135
|
-
export { addMarketplace, removeMarketplace, listMarketplaces, } from "./plugins/marketplaceManager.js";
|
|
204
|
+
export { addMarketplace, refreshMarketplace, removeMarketplace, listMarketplaces, loadMarketplace, } from "./plugins/marketplaceManager.js";
|
|
136
205
|
export { parseMarketplaceInput, deriveMarketplaceName, } from "./plugins/parseMarketplaceInput.js";
|
|
137
206
|
export { scanPluginCommands, } from "./plugins/pluginCommandsLoader.js";
|
|
138
207
|
// ─── LLM (extended for TUI) ─────────────────────────────────────
|
|
208
|
+
/** @internal Extended LLM surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
139
209
|
export { defaultCacheDir, } from "./llm/model-cache.js";
|
|
140
210
|
export { fetchModelList, } from "./llm/model-fetcher.js";
|
|
141
211
|
export { sanitizeApiKey, hasNonAsciiPrintable, } from "./llm/api-key-sanitize.js";
|
|
142
212
|
export { PROVIDER_KINDS, } from "./llm/provider-kinds.js";
|
|
143
213
|
export { capabilitiesFor, } from "./llm/capabilities/index.js";
|
|
214
|
+
export { reasoningControlFor, } from "./llm/capabilities/reasoning-control.js";
|
|
215
|
+
export { REASONING_EFFORTS, } from "./llm/reasoning-setting.js";
|
|
144
216
|
// ─── Data ────────────────────────────────────────────────────────
|
|
145
217
|
export { syncOpenRouterCatalog, getOpenRouterSnapshot, } from "./data/openrouter-sync.js";
|
|
218
|
+
// ─── External agent config (Mobile Web Remote Rooms) ─────────────
|
|
219
|
+
// Resolves the externalAgents settings block (notably claudeCode.trustedWorkspaces),
|
|
220
|
+
// the source of truth for a Room's permission mode. The former /cc & /codex
|
|
221
|
+
// managed-job path was removed — the phone now talks to resident Rooms only.
|
|
222
|
+
export { resolveExternalAgentConfig } from "./external-agents/config.js";
|
|
223
|
+
// ─── Browser automation bridge ───────────────────────────────────
|
|
224
|
+
// Driver-agnostic contract + the pure a11y-tree flattener. The desktop host's
|
|
225
|
+
// browser-driver module implements BrowserBridge on top of webContents.debugger
|
|
226
|
+
// (CDP), reusing flattenAxTree. See the MVP spec
|
|
227
|
+
// docs/superpowers/specs/2026-06-16-browser-automation-mvp.md.
|
|
228
|
+
export { flattenAxTree, renderElementList, cleanPageText, CONTENT_CHAR_CAP, buildExtractLinksScript, EXTRACT_LINK_CAP, } from "./tool-system/browser-bridge.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* paramSpecsFromCapability — bridge the capability layer (rules.ts, the vetted
|
|
3
|
+
* single source of truth) into the unified catalog's ParamSpec[]. The catalog
|
|
4
|
+
* reuses this knowledge instead of re-hand-writing reasoning/vision per model.
|
|
5
|
+
* See docs/superpowers/specs/2026-06-15-unified-model-catalog-design.md §4.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProviderKindName } from "../provider-kinds.js";
|
|
8
|
+
import type { ParamSpec } from "../../model-catalog/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Project a (kind, model)'s capabilities into catalog ParamSpec[]. Currently
|
|
11
|
+
* covers reasoning (the param that diverges most across models); image
|
|
12
|
+
* size/quality live in their own catalog entries. Adaptive / none → no spec.
|
|
13
|
+
*/
|
|
14
|
+
export declare function paramSpecsFromCapability(kind: ProviderKindName, model: string): ParamSpec[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { reasoningControlFor } from "./reasoning-control.js";
|
|
2
|
+
/** Where each provider kind's reasoning knob lands on the request body. */
|
|
3
|
+
function reasoningWireField(kind) {
|
|
4
|
+
switch (kind) {
|
|
5
|
+
case "anthropic":
|
|
6
|
+
return "thinking.budget_tokens";
|
|
7
|
+
case "deepseek":
|
|
8
|
+
case "zai":
|
|
9
|
+
return "thinking.type";
|
|
10
|
+
default:
|
|
11
|
+
// OpenAI-compat (openai/google/openrouter/xai/mistral/groq) use reasoning_effort.
|
|
12
|
+
return "reasoning_effort";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Project a (kind, model)'s capabilities into catalog ParamSpec[]. Currently
|
|
17
|
+
* covers reasoning (the param that diverges most across models); image
|
|
18
|
+
* size/quality live in their own catalog entries. Adaptive / none → no spec.
|
|
19
|
+
*/
|
|
20
|
+
export function paramSpecsFromCapability(kind, model) {
|
|
21
|
+
const specs = [];
|
|
22
|
+
const control = reasoningControlFor(kind, model);
|
|
23
|
+
const wire = { field: reasoningWireField(kind) };
|
|
24
|
+
switch (control.kind) {
|
|
25
|
+
case "effort":
|
|
26
|
+
specs.push({
|
|
27
|
+
name: "reasoning",
|
|
28
|
+
label: "思考强度",
|
|
29
|
+
control: "enum",
|
|
30
|
+
options: control.options,
|
|
31
|
+
default: control.default,
|
|
32
|
+
doc: "Reasoning effort — how hard the model thinks before answering.",
|
|
33
|
+
wire,
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case "budget":
|
|
37
|
+
specs.push({
|
|
38
|
+
name: "reasoning",
|
|
39
|
+
label: "思考预算",
|
|
40
|
+
control: "number",
|
|
41
|
+
min: control.min,
|
|
42
|
+
default: control.default,
|
|
43
|
+
doc: "Thinking token budget — higher = more deliberate reasoning.",
|
|
44
|
+
wire,
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case "toggle":
|
|
48
|
+
specs.push({
|
|
49
|
+
name: "reasoning",
|
|
50
|
+
label: "思考",
|
|
51
|
+
control: "toggle",
|
|
52
|
+
default: control.default,
|
|
53
|
+
doc: "Toggle the model's thinking mode on/off.",
|
|
54
|
+
wire,
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
case "adaptive":
|
|
58
|
+
case "none":
|
|
59
|
+
break; // nothing to set
|
|
60
|
+
}
|
|
61
|
+
return specs;
|
|
62
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reasoningControlFor — projects a model's ReasoningShape into "what control
|
|
3
|
+
* the UI should render". The UI never branches on provider; it switches on
|
|
4
|
+
* ReasoningControl.kind. Mirrors the capability-control descriptor pattern.
|
|
5
|
+
*/
|
|
6
|
+
import type { ProviderKindName } from "../provider-kinds.js";
|
|
7
|
+
import type { ReasoningEffort } from "./types.js";
|
|
8
|
+
export type ReasoningControl = {
|
|
9
|
+
kind: "none";
|
|
10
|
+
} | {
|
|
11
|
+
kind: "toggle";
|
|
12
|
+
default: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "effort";
|
|
15
|
+
options: ReasoningEffort[];
|
|
16
|
+
default: ReasoningEffort;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "budget";
|
|
19
|
+
min: number;
|
|
20
|
+
default: number;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "adaptive";
|
|
23
|
+
};
|
|
24
|
+
export declare function reasoningControlFor(kind: ProviderKindName, model: string): ReasoningControl;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { capabilitiesFor } from "./index.js";
|
|
2
|
+
const FULL_EFFORTS = ["minimal", "low", "medium", "high"];
|
|
3
|
+
export function reasoningControlFor(kind, model) {
|
|
4
|
+
const cap = capabilitiesFor(kind, model);
|
|
5
|
+
const r = cap.reasoning;
|
|
6
|
+
switch (r.kind) {
|
|
7
|
+
case "none":
|
|
8
|
+
return { kind: "none" };
|
|
9
|
+
case "deepseek-thinking":
|
|
10
|
+
return { kind: "toggle", default: true };
|
|
11
|
+
case "anthropic-adaptive":
|
|
12
|
+
return { kind: "adaptive" };
|
|
13
|
+
case "anthropic-budget":
|
|
14
|
+
return {
|
|
15
|
+
kind: "budget",
|
|
16
|
+
min: r.minBudgetTokens,
|
|
17
|
+
default: Math.max(r.minBudgetTokens, 4096),
|
|
18
|
+
};
|
|
19
|
+
case "openrouter-reasoning":
|
|
20
|
+
// OpenRouter normalizes to minimal..high (no xhigh passthrough).
|
|
21
|
+
return { kind: "effort", options: FULL_EFFORTS, default: "medium" };
|
|
22
|
+
case "openai-effort": {
|
|
23
|
+
// Prefer the capability's first-class supportedEfforts list (gpt-5.5 →
|
|
24
|
+
// low..xhigh, magistral → [high]). Fall back to the default four levels
|
|
25
|
+
// when a rule didn't specify one. We no longer infer the level set from
|
|
26
|
+
// disabledEffort — that's a wire-detail two vendors can coincidentally
|
|
27
|
+
// share (gpt-5.5 and magistral both use "none"), so inferring misrendered
|
|
28
|
+
// magistral as a gpt-5.5-style control.
|
|
29
|
+
const options = r.supportedEfforts && r.supportedEfforts.length > 0
|
|
30
|
+
? r.supportedEfforts
|
|
31
|
+
: FULL_EFFORTS;
|
|
32
|
+
// Default to "medium" if available, else the first offered level
|
|
33
|
+
// (magistral has only "high", so its default is "high").
|
|
34
|
+
const def = options.includes("medium") ? "medium" : options[0];
|
|
35
|
+
return { kind: "effort", options, default: def };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -39,10 +39,22 @@ export const RULES = [
|
|
|
39
39
|
"temperature", "top_p", "presence_penalty",
|
|
40
40
|
"frequency_penalty", "logit_bias", "logprobs", "top_logprobs",
|
|
41
41
|
]),
|
|
42
|
-
reasoning: {
|
|
42
|
+
reasoning: {
|
|
43
|
+
kind: "openai-effort",
|
|
44
|
+
disabledEffort: "none",
|
|
45
|
+
supportedEfforts: ["low", "medium", "high", "xhigh"], // no "minimal"; adds "xhigh"
|
|
46
|
+
// gpt-5.5 400s when `reasoning_effort` rides alongside `tools` on
|
|
47
|
+
// /v1/chat/completions — drop the field up-front on tool turns instead
|
|
48
|
+
// of eating the 400 + 1s-backoff retry on every tool-using turn.
|
|
49
|
+
noEffortWithTools: true,
|
|
50
|
+
},
|
|
43
51
|
echoReasoning: "optional",
|
|
52
|
+
// 400s on `max_tokens is too large: ... at most 128000`. Clamp here so a
|
|
53
|
+
// stale 384000 (copied from a DeepSeek/OpenRouter entry on a prior model)
|
|
54
|
+
// can't bleed in after a hot switch.
|
|
55
|
+
maxOutputTokens: 128_000,
|
|
44
56
|
},
|
|
45
|
-
why: "OpenAI gpt-5.5+ accepts reasoning_effort none|low|medium|high|xhigh (no `minimal`).",
|
|
57
|
+
why: "OpenAI gpt-5.5+ accepts reasoning_effort none|low|medium|high|xhigh (no `minimal`); output cap 128k.",
|
|
46
58
|
},
|
|
47
59
|
// ─── OpenAI native — o-series + gpt-5 through gpt-5.4 ──────────
|
|
48
60
|
{
|
|
@@ -63,6 +75,24 @@ export const RULES = [
|
|
|
63
75
|
},
|
|
64
76
|
why: "OpenAI o-series + gpt-5..5.4 reject classic sampling params; use max_completion_tokens + reasoning_effort.",
|
|
65
77
|
},
|
|
78
|
+
// ─── OpenAI native — gpt-4o / gpt-4-turbo (multimodal, non-reasoning) ──
|
|
79
|
+
// The famous vision models. They are NOT reasoning models, so they keep
|
|
80
|
+
// classic sampling params + max_tokens — only `supportsVision` differs
|
|
81
|
+
// from DEFAULT_CAPABILITY. Listed AFTER the gpt-5+ rules (those anchor on
|
|
82
|
+
// gpt-[5-9]) so neither family masks the other. Without this rule gpt-4o
|
|
83
|
+
// falls through to DEFAULT_CAPABILITY (supportsVision:false) and a famous
|
|
84
|
+
// vision model gets its history images stripped / new attachments rejected.
|
|
85
|
+
{
|
|
86
|
+
kind: "openai",
|
|
87
|
+
// gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4-vision-preview, gpt-4.1*.
|
|
88
|
+
// gpt-4o has no separator before the "o"; the rest are `-`/`.`-separated.
|
|
89
|
+
// Stays clear of gpt-3.5-turbo (no vision) and gpt-5+ (handled above).
|
|
90
|
+
match: /^gpt-4o(?:[-.]|$)|^gpt-4(?:\.1|-turbo|-vision)(?:[-.]|$)/i,
|
|
91
|
+
capability: {
|
|
92
|
+
supportsVision: true,
|
|
93
|
+
},
|
|
94
|
+
why: "OpenAI gpt-4o / gpt-4o-mini / gpt-4-turbo / gpt-4.1 are multimodal but non-reasoning; only vision differs from default.",
|
|
95
|
+
},
|
|
66
96
|
// ─── DeepSeek ──────────────────────────────────────────────────
|
|
67
97
|
{
|
|
68
98
|
kind: "deepseek",
|
|
@@ -196,7 +226,11 @@ export const RULES = [
|
|
|
196
226
|
// Magistral series exposes reasoning_effort: high|none — no minimal/low/medium.
|
|
197
227
|
match: /^magistral/i,
|
|
198
228
|
capability: {
|
|
199
|
-
reasoning: {
|
|
229
|
+
reasoning: {
|
|
230
|
+
kind: "openai-effort",
|
|
231
|
+
disabledEffort: "none",
|
|
232
|
+
supportedEfforts: ["high"], // magistral: only high|none — "none" is the off value
|
|
233
|
+
},
|
|
200
234
|
},
|
|
201
235
|
why: "Mistral magistral models accept only reasoning_effort `high` or `none`.",
|
|
202
236
|
},
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
* `rules.ts` — vendor docs, not folklore.
|
|
10
10
|
*/
|
|
11
11
|
import type { ProviderKindName } from "../provider-kinds.js";
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* OpenAI-style reasoning effort levels — shared by several vendors.
|
|
14
|
+
* `xhigh` is gpt-5.5+ only (which also drops `minimal`); see rules.ts.
|
|
15
|
+
*/
|
|
16
|
+
export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
14
17
|
/** A binary thinking switch, like DeepSeek V4 and Z.AI GLM use. */
|
|
15
18
|
export type ThinkingSwitch = "enabled" | "disabled";
|
|
16
19
|
/**
|
|
@@ -31,10 +34,29 @@ export type ReasoningShape = {
|
|
|
31
34
|
* "disabled" — defaults to `"minimal"` (OpenAI), but vendors with a
|
|
32
35
|
* narrower vocabulary override it (e.g. xAI Grok 4.3 has no `"minimal"`;
|
|
33
36
|
* Mistral Magistral only accepts `"high"` and `"none"`).
|
|
37
|
+
*
|
|
38
|
+
* `supportedEfforts` is the FIRST-CLASS list of levels a UI may offer for
|
|
39
|
+
* this model. Set it whenever the vocabulary differs from the default
|
|
40
|
+
* `["minimal","low","medium","high"]` — e.g. gpt-5.5 is
|
|
41
|
+
* `["low","medium","high","xhigh"]`, Mistral magistral is `["high"]`. The UI
|
|
42
|
+
* (reasoningControlFor) reads this directly instead of inferring the
|
|
43
|
+
* level set from `disabledEffort`, which is a wire-detail, not a
|
|
44
|
+
* capability marker (two unrelated vendors can share `disabledEffort:"none"`).
|
|
34
45
|
*/
|
|
35
46
|
| {
|
|
36
47
|
kind: "openai-effort";
|
|
37
48
|
disabledEffort?: ReasoningEffort | "none";
|
|
49
|
+
supportedEfforts?: ReasoningEffort[];
|
|
50
|
+
/**
|
|
51
|
+
* gpt-5.5+ rejects `reasoning_effort` whenever `tools` are also present on
|
|
52
|
+
* `/v1/chat/completions` ("Function tools with reasoning_effort are not
|
|
53
|
+
* supported … Please use /v1/responses instead"), 400-ing the request.
|
|
54
|
+
* When set, the OpenAI client OMITS `reasoning_effort` on any tool-bearing
|
|
55
|
+
* request up-front — so we never eat the 400 + retry on every tool turn.
|
|
56
|
+
* The reactive `_dropReasoningEffort` sticky still covers any variant we
|
|
57
|
+
* haven't tagged here.
|
|
58
|
+
*/
|
|
59
|
+
noEffortWithTools?: boolean;
|
|
38
60
|
}
|
|
39
61
|
/** Anthropic Claude 4.x ≤ 4.5 — `{thinking: {type: "enabled", budget_tokens: N}}`. */
|
|
40
62
|
| {
|
|
@@ -95,6 +117,14 @@ export interface Capability {
|
|
|
95
117
|
parallelToolCalls: ParallelToolCallsShape;
|
|
96
118
|
/** Streaming usage reporting shape. */
|
|
97
119
|
streamUsage: StreamUsageShape;
|
|
120
|
+
/**
|
|
121
|
+
* Known hard ceiling for max-output-tokens, when the vendor publishes one
|
|
122
|
+
* and exceeding it 400s. Used to clamp a requested/inherited max_tokens so
|
|
123
|
+
* a stale catalog value (e.g. 384000 copied from a DeepSeek/OpenRouter
|
|
124
|
+
* entry) can't bleed onto a smaller-cap model after a hot switch. Undefined
|
|
125
|
+
* = no known cap → send the request value unclamped.
|
|
126
|
+
*/
|
|
127
|
+
maxOutputTokens?: number;
|
|
98
128
|
}
|
|
99
129
|
/**
|
|
100
130
|
* Conservative default — used when no rule matches. Picks "send everything
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp a requested max-output-tokens value to a model's known output cap.
|
|
3
|
+
*
|
|
4
|
+
* Background: model-pool copies a catalog `maxOutputTokens` straight into
|
|
5
|
+
* LLMConfig.maxTokens. For some OpenRouter/DeepSeek entries that value is huge
|
|
6
|
+
* (e.g. 384000) and bleeds onto a model with a much smaller cap after a hot
|
|
7
|
+
* switch, producing `max_tokens is too large` 400s. When the capability layer
|
|
8
|
+
* knows the model's real ceiling we clamp to it; when it doesn't we pass the
|
|
9
|
+
* value through (or omit it entirely when there is no request value).
|
|
10
|
+
*/
|
|
11
|
+
export declare function clampMaxTokens(requested: number | undefined, cap: number | undefined): number | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp a requested max-output-tokens value to a model's known output cap.
|
|
3
|
+
*
|
|
4
|
+
* Background: model-pool copies a catalog `maxOutputTokens` straight into
|
|
5
|
+
* LLMConfig.maxTokens. For some OpenRouter/DeepSeek entries that value is huge
|
|
6
|
+
* (e.g. 384000) and bleeds onto a model with a much smaller cap after a hot
|
|
7
|
+
* switch, producing `max_tokens is too large` 400s. When the capability layer
|
|
8
|
+
* knows the model's real ceiling we clamp to it; when it doesn't we pass the
|
|
9
|
+
* value through (or omit it entirely when there is no request value).
|
|
10
|
+
*/
|
|
11
|
+
export function clampMaxTokens(requested, cap) {
|
|
12
|
+
if (requested === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (cap === undefined)
|
|
15
|
+
return requested;
|
|
16
|
+
return Math.min(requested, cap);
|
|
17
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Abstract base class for all LLM provider clients.
|
|
3
3
|
*/
|
|
4
|
-
import type { LLMConfig, LLMResponse, TokenUsage } from "../types.js";
|
|
4
|
+
import type { ClientDefaults, LLMConfig, LLMResponse, TokenUsage } from "../types.js";
|
|
5
5
|
import type { CreateMessageOptions, LLMUsageTracker } from "./types.js";
|
|
6
6
|
export declare abstract class LLMClientBase {
|
|
7
7
|
protected readonly config: LLMConfig;
|
|
8
8
|
readonly provider: string;
|
|
9
9
|
readonly model: string;
|
|
10
|
+
readonly maxTokens: number | undefined;
|
|
10
11
|
readonly temperature: number;
|
|
11
|
-
readonly maxTokens: number;
|
|
12
12
|
readonly timeout: number;
|
|
13
13
|
readonly retryMaxAttempts: number;
|
|
14
|
-
readonly
|
|
14
|
+
readonly imageDetail?: ClientDefaults["imageDetail"];
|
|
15
15
|
/**
|
|
16
16
|
* Process-wide hook fired on every LLM response. The CLI installs this in
|
|
17
17
|
* main.ts to feed the cost tracker; lives on the base class so every code
|
|
@@ -20,10 +20,74 @@ export declare abstract class LLMClientBase {
|
|
|
20
20
|
*/
|
|
21
21
|
static onUsage?: (model: string, usage: TokenUsage) => void;
|
|
22
22
|
protected usage: LLMUsageTracker;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `config` carries model identity (provider/model/apiKey/baseUrl/maxTokens/
|
|
25
|
+
* thinking/providerKind). `defaults` carries cross-model runtime knobs
|
|
26
|
+
* (temperature/timeout/retryMaxAttempts/imageDetail) — those are owned by
|
|
27
|
+
* the Engine and stay stable across hot model switches.
|
|
28
|
+
*/
|
|
29
|
+
constructor(config: LLMConfig, defaults?: ClientDefaults);
|
|
24
30
|
protected abstract initClient(): void;
|
|
25
31
|
abstract createMessage(options: CreateMessageOptions): Promise<LLMResponse>;
|
|
26
32
|
protected recordUsage(usage: TokenUsage, options?: CreateMessageOptions): void;
|
|
27
33
|
getUsage(): LLMUsageTracker;
|
|
28
|
-
|
|
34
|
+
/** Zero all accumulated usage. Used when starting a fresh accounting window
|
|
35
|
+
* (e.g. after a model switch, where the prior model's cache stats no longer
|
|
36
|
+
* apply). */
|
|
37
|
+
resetUsage(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Compose the caller's AbortSignal with a hard per-request deadline.
|
|
40
|
+
*
|
|
41
|
+
* The provider SDKs accept a `timeout`, but in practice it does NOT fire for
|
|
42
|
+
* a *half-dead socket* (TCP connected, keep-alives flowing, but no response
|
|
43
|
+
* bytes) — we have observed real requests hang 15–33 minutes before the SDK
|
|
44
|
+
* finally surfaced "Socket timeout". The streaming idle-watchdog only covers
|
|
45
|
+
* the gap BETWEEN chunks, not connection setup / first byte, and non-stream
|
|
46
|
+
* calls don't go through it at all. An explicit AbortSignal.timeout is the
|
|
47
|
+
* one mechanism that reliably tears such a request down.
|
|
48
|
+
*
|
|
49
|
+
* Returns a signal to hand the SDK (`{ signal }`) plus a `cleanup()` to clear
|
|
50
|
+
* the timer once the request settles. The deadline is generous (default 2×
|
|
51
|
+
* the SDK timeout, min 120s) — long enough for slow-but-alive generations,
|
|
52
|
+
* short enough that a wedged socket can't burn half an hour.
|
|
53
|
+
*/
|
|
54
|
+
protected withRequestDeadline(callerSignal?: AbortSignal): {
|
|
55
|
+
signal: AbortSignal;
|
|
56
|
+
cleanup: () => void;
|
|
57
|
+
};
|
|
58
|
+
protected withRetry<T>(fn: (requestSignal?: AbortSignal) => Promise<T>, opts?: {
|
|
59
|
+
maxAttempts?: number;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
}): Promise<T>;
|
|
29
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Detect HTTP 4xx errors from provider SDKs so withRetry can bail
|
|
65
|
+
* without burning backoff time. OpenAI/Anthropic SDKs attach a numeric
|
|
66
|
+
* `status` to their error objects; we treat 400-499 as non-retryable
|
|
67
|
+
* (429 is handled separately above as a rate-limit).
|
|
68
|
+
*
|
|
69
|
+
* The provider clients also wrap SDK errors into `new LLMError(msg,
|
|
70
|
+
* provider, { status })`, where the status lands in
|
|
71
|
+
* `FrameworkError.details.status` rather than a top-level `.status`.
|
|
72
|
+
* We read both so a wrapped 400/401/404 isn't retried 3× (~9 s wasted)
|
|
73
|
+
* before finally surfacing.
|
|
74
|
+
*
|
|
75
|
+
* Network errors and 5xx fall through and remain retryable.
|
|
76
|
+
*
|
|
77
|
+
* Exported for unit testing.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isClientError(err: unknown): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Detect a user/run cancellation. The OpenAI and Anthropic SDKs throw
|
|
82
|
+
* `APIUserAbortError` when a request's AbortSignal fires mid-flight; the
|
|
83
|
+
* providers rethrow it unchanged (see handleApiError). It carries no HTTP
|
|
84
|
+
* `status`, so `isClientError` can't recognise it — without an explicit
|
|
85
|
+
* check it falls through to `withRetry`'s generic branch and gets retried.
|
|
86
|
+
*
|
|
87
|
+
* We match by error name rather than `instanceof` to avoid importing the
|
|
88
|
+
* provider SDKs into the base class: `APIUserAbortError` from the SDKs, and
|
|
89
|
+
* the WHATWG `AbortError` from `fetch`/AbortController, both surface here.
|
|
90
|
+
*
|
|
91
|
+
* Exported for unit testing.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isAbortError(err: unknown): boolean;
|