@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/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core type definitions for the code-shell orchestration framework.
|
|
3
3
|
*/
|
|
4
|
+
import type { GoalConfig } from "./engine/goal.js";
|
|
4
5
|
export interface ContentBlock {
|
|
5
6
|
type: "text" | "tool_use" | "tool_result" | "image" | "reasoning";
|
|
6
7
|
text?: string;
|
|
@@ -9,6 +10,12 @@ export interface ContentBlock {
|
|
|
9
10
|
input?: Record<string, unknown>;
|
|
10
11
|
content?: string | ContentBlock[];
|
|
11
12
|
tool_use_id?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 标记 tool_result 为出错,让 provider 据此设置 wire 层错误标志
|
|
15
|
+
* (Anthropic 的 `is_error: true`)。不设的话,出错的工具只会以普通
|
|
16
|
+
* content 文字回传,模型可能把超时/中断误当成成功。
|
|
17
|
+
*/
|
|
18
|
+
is_error?: boolean;
|
|
12
19
|
source?: {
|
|
13
20
|
type: "base64";
|
|
14
21
|
media_type: string;
|
|
@@ -37,10 +44,53 @@ export interface ToolResult {
|
|
|
37
44
|
id: string;
|
|
38
45
|
toolName: string;
|
|
39
46
|
result?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 结构化结果块(目前仅图片)。存在时优先于 `result` 用作发给 LLM 的
|
|
49
|
+
* tool_result content —— view_image 用它把本地图片以 image ContentBlock
|
|
50
|
+
* 回传,让 vision 模型能「看」自己生成的图。非视觉模型由 provider 的
|
|
51
|
+
* stripVisionFromHistory 自动剥离,所以这里照常带图也安全。
|
|
52
|
+
*/
|
|
53
|
+
contentBlocks?: ContentBlock[];
|
|
40
54
|
error?: string;
|
|
41
55
|
isError?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Set by tools that execute under the sandbox (Bash / background shell /
|
|
58
|
+
* worktree) so the UI can show whether THIS call was isolated. `backend`
|
|
59
|
+
* "off" means the command ran un-sandboxed (we surface it explicitly so the
|
|
60
|
+
* user sees "未隔离" rather than guessing from an absent badge); "seatbelt"
|
|
61
|
+
* / "bwrap" mean OS-level isolation applied. `network` is the policy that
|
|
62
|
+
* was in force (absent when off). Tools that don't touch the sandbox leave
|
|
63
|
+
* this undefined and the UI renders no badge.
|
|
64
|
+
*/
|
|
65
|
+
sandbox?: {
|
|
66
|
+
backend: "off" | "seatbelt" | "bwrap";
|
|
67
|
+
network?: "allow" | "deny";
|
|
68
|
+
};
|
|
42
69
|
}
|
|
43
70
|
export type ToolSource = "builtin" | "mcp";
|
|
71
|
+
export type ToolPathPolicyOperation = "read" | "write" | {
|
|
72
|
+
/** Argument whose value decides whether this invocation reads or writes. */
|
|
73
|
+
fromArg: string;
|
|
74
|
+
/** Values that classify the operation as a read. */
|
|
75
|
+
readValues?: string[];
|
|
76
|
+
/** Values that classify the operation as a write. */
|
|
77
|
+
writeValues?: string[];
|
|
78
|
+
/** Fallback when the argument is absent or does not match either list. */
|
|
79
|
+
default: "read" | "write";
|
|
80
|
+
};
|
|
81
|
+
export type ToolPathPolicy = {
|
|
82
|
+
kind: "arg";
|
|
83
|
+
/** Argument containing a file or directory path. */
|
|
84
|
+
arg: string;
|
|
85
|
+
operation: ToolPathPolicyOperation;
|
|
86
|
+
/** Use ctx.cwd when the argument is omitted. Useful for Glob/Grep roots. */
|
|
87
|
+
defaultToCwd?: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
kind: "apply_patch";
|
|
90
|
+
/** Argument containing the V4A patch text. */
|
|
91
|
+
arg: string;
|
|
92
|
+
operation: "write";
|
|
93
|
+
};
|
|
44
94
|
export interface RegisteredTool {
|
|
45
95
|
name: string;
|
|
46
96
|
description: string;
|
|
@@ -50,6 +100,18 @@ export interface RegisteredTool {
|
|
|
50
100
|
permissionDefault: PermissionDecision;
|
|
51
101
|
isConcurrencySafe?: boolean;
|
|
52
102
|
isReadOnly?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Declarative file-path safety metadata. ToolExecutor enforces this before
|
|
105
|
+
* dispatching the tool, so file access cannot depend on each tool handler
|
|
106
|
+
* remembering to call path-policy manually.
|
|
107
|
+
*/
|
|
108
|
+
pathPolicy?: ToolPathPolicy[];
|
|
109
|
+
/**
|
|
110
|
+
* Explicitly marks a path-looking tool as intentionally outside the file
|
|
111
|
+
* policy layer. Used by tests/audits so new file tools fail closed unless
|
|
112
|
+
* they either declare pathPolicy or document an exemption.
|
|
113
|
+
*/
|
|
114
|
+
pathPolicyExempt?: boolean;
|
|
53
115
|
/**
|
|
54
116
|
* Override the default tool execution timeout (ms).
|
|
55
117
|
* Falls back to DEFAULT_TOOL_TIMEOUT_MS (120s) if unset.
|
|
@@ -57,7 +119,7 @@ export interface RegisteredTool {
|
|
|
57
119
|
*/
|
|
58
120
|
timeoutMs?: number;
|
|
59
121
|
}
|
|
60
|
-
export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "turn_boundary" | "error";
|
|
122
|
+
export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "subagent" | "turn_boundary" | "goal_progress" | "turn_stopped" | "error";
|
|
61
123
|
export interface TranscriptEvent {
|
|
62
124
|
id: string;
|
|
63
125
|
type: TranscriptEventType;
|
|
@@ -67,12 +129,16 @@ export interface TranscriptEvent {
|
|
|
67
129
|
}
|
|
68
130
|
/**
|
|
69
131
|
* Session lifecycle state persisted in state.json. `"active"` means a run is
|
|
70
|
-
* currently in flight (or was, at the moment of the last heartbeat)
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
132
|
+
* currently in flight (or was, at the moment of the last heartbeat);
|
|
133
|
+
* `"paused"` is a non-terminal hold (not a {@link TerminalReason}). Every
|
|
134
|
+
* other value matches the TerminalReason the last run returned, so callers can
|
|
135
|
+
* distinguish a user-cancelled session (`"aborted_streaming"`) from an actual
|
|
136
|
+
* error (`"model_error"`, `"prompt_too_long"`, ...).
|
|
74
137
|
*/
|
|
75
138
|
export type SessionStatus = "active" | "paused" | TerminalReason;
|
|
139
|
+
/** Which host/context created a session — used by the desktop disk-rebuild to
|
|
140
|
+
* filter the sidebar (only `desktop` + `automation` are shown). */
|
|
141
|
+
export type SessionOrigin = "desktop" | "tui" | "automation" | "subagent";
|
|
76
142
|
export interface SessionState {
|
|
77
143
|
sessionId: string;
|
|
78
144
|
cwd: string;
|
|
@@ -81,13 +147,49 @@ export interface SessionState {
|
|
|
81
147
|
provider: string;
|
|
82
148
|
tokenUsage: TokenUsage;
|
|
83
149
|
turnCount: number;
|
|
150
|
+
/**
|
|
151
|
+
* Conversation-turn counter where ONE user message = one turn (incremented in
|
|
152
|
+
* engine.run before the message hits the LLM). Distinct from `turnCount`,
|
|
153
|
+
* which counts turn-loop iterations (a single user message can span many).
|
|
154
|
+
* Tags file-history snapshots so turn-level `/undo` can revert exactly what
|
|
155
|
+
* the last user message changed. Absent on legacy sessions → treated as 0.
|
|
156
|
+
*/
|
|
157
|
+
turnSeq?: number;
|
|
84
158
|
invokedSkills: string[];
|
|
85
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Owning parent session for a sub-agent run; `null` explicitly marks a
|
|
161
|
+
* top-level session (post-create marker). Absent only on legacy sessions
|
|
162
|
+
* written before this field existed — the desktop disk-rebuild uses
|
|
163
|
+
* "key present && null" to tell a new top-level session apart from legacy.
|
|
164
|
+
*/
|
|
165
|
+
parentSessionId?: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Which host/context created this session. Desktop disk-rebuild shows only
|
|
168
|
+
* `desktop` + `automation`. Absent on legacy sessions.
|
|
169
|
+
*/
|
|
170
|
+
origin?: SessionOrigin;
|
|
86
171
|
status: SessionStatus;
|
|
87
172
|
/** Short summary derived from the first user message */
|
|
88
173
|
summary?: string;
|
|
174
|
+
/**
|
|
175
|
+
* LLM-generated one-line title (auxModel, after the first turn). Distinct from
|
|
176
|
+
* `summary` (the raw first-message fallback). Persisted so the sidebar shows
|
|
177
|
+
* it after a localStorage wipe / disk rebuild — without this it lived only in
|
|
178
|
+
* the renderer's localStorage index and was lost on reset.
|
|
179
|
+
*/
|
|
180
|
+
title?: string;
|
|
89
181
|
/** Persisted cost tracking state (survives process restart). */
|
|
90
182
|
costState?: Record<string, unknown>;
|
|
183
|
+
/**
|
|
184
|
+
* Active persistent goal (CC `/goal` style). Set once, it survives across
|
|
185
|
+
* messages AND manual interrupts until the judge says it's met or the user
|
|
186
|
+
* clears it. Absent → no active goal. When a run supplies a new goal it
|
|
187
|
+
* REPLACES this (one active goal per session). The judge's `met` verdict and
|
|
188
|
+
* `agent/goalClear` both clear it. Persisted so it survives resume/refresh;
|
|
189
|
+
* on resume the objective carries over but the run-scoped turn/token/time
|
|
190
|
+
* baselines reset (matching CC). See engine.run goal-resolution.
|
|
191
|
+
*/
|
|
192
|
+
activeGoal?: GoalConfig;
|
|
91
193
|
}
|
|
92
194
|
export interface TokenUsage {
|
|
93
195
|
promptTokens: number;
|
|
@@ -140,11 +242,22 @@ export interface ApprovalRequest {
|
|
|
140
242
|
* survives restart for the current project. Not committed.
|
|
141
243
|
*/
|
|
142
244
|
export type ApprovalScope = "once" | "session" | "project";
|
|
245
|
+
/**
|
|
246
|
+
* Path granularity for a remembered file-tool grant (Write/Edit). Narrows the
|
|
247
|
+
* remembered rule so "allow Write src/foo.ts for this session" doesn't become
|
|
248
|
+
* "allow Write to ANY path".
|
|
249
|
+
* "file" — only this exact file
|
|
250
|
+
* "dir" — this file's directory and its subdirectories
|
|
251
|
+
* "tool" — every path (the legacy tool-wide behavior)
|
|
252
|
+
* Omitted → "tool" (back-compat). Ignored for non-file tools.
|
|
253
|
+
*/
|
|
254
|
+
export type ApprovalPathScope = "file" | "dir" | "tool";
|
|
143
255
|
export type ApprovalResult = {
|
|
144
256
|
approved: true;
|
|
145
257
|
permanent?: boolean;
|
|
146
258
|
always?: boolean;
|
|
147
259
|
scope?: ApprovalScope;
|
|
260
|
+
pathScope?: ApprovalPathScope;
|
|
148
261
|
/** Used by AskUserQuestion to carry the user's free-text answer. */ answer?: string;
|
|
149
262
|
} | {
|
|
150
263
|
approved: false;
|
|
@@ -159,7 +272,7 @@ export interface TurnResult {
|
|
|
159
272
|
status: "completed" | "tool_use" | "error" | "max_turns" | "aborted";
|
|
160
273
|
error?: string;
|
|
161
274
|
}
|
|
162
|
-
export type TerminalReason = "completed" | "stop_hook_prevented" | "hook_stopped" | "prompt_too_long" | "model_error" | "aborted_streaming" | "aborted_tools" | "max_turns" | "image_error";
|
|
275
|
+
export type TerminalReason = "completed" | "stop_hook_prevented" | "hook_stopped" | "prompt_too_long" | "model_error" | "aborted_streaming" | "aborted_tools" | "max_turns" | "goal_budget_exhausted" | "image_error";
|
|
163
276
|
export interface TaskInfo {
|
|
164
277
|
id: string;
|
|
165
278
|
subject: string;
|
|
@@ -170,10 +283,18 @@ export type StreamEvent = {
|
|
|
170
283
|
type: "session_started";
|
|
171
284
|
sessionId: string;
|
|
172
285
|
promptTokens: number;
|
|
286
|
+
} | {
|
|
287
|
+
type: "session_title";
|
|
288
|
+
sessionId: string;
|
|
289
|
+
title: string;
|
|
173
290
|
} | {
|
|
174
291
|
type: "stream_request_start";
|
|
175
292
|
turnNumber: number;
|
|
176
293
|
agentId?: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: "steer_injected";
|
|
296
|
+
text: string;
|
|
297
|
+
id?: string;
|
|
177
298
|
} | {
|
|
178
299
|
type: "text_delta";
|
|
179
300
|
text: string;
|
|
@@ -200,6 +321,24 @@ export type StreamEvent = {
|
|
|
200
321
|
type: "turn_complete";
|
|
201
322
|
reason: TerminalReason;
|
|
202
323
|
agentId?: string;
|
|
324
|
+
} | {
|
|
325
|
+
type: "goal_progress";
|
|
326
|
+
status: "not_met" | "met" | "exhausted" | "approaching_limit";
|
|
327
|
+
round: number;
|
|
328
|
+
gaps?: string;
|
|
329
|
+
/** For "approaching_limit": turns left before the maxTurns cap (TODO 3.1). */
|
|
330
|
+
turnsRemaining?: number;
|
|
331
|
+
/** For "approaching_limit": consecutive blocks left before maxStopBlocks (TODO 3.1). */
|
|
332
|
+
stopBlocksRemaining?: number;
|
|
333
|
+
/** For "approaching_limit": which ceiling is closest — drives UI copy + extend default. */
|
|
334
|
+
nearest?: "turns" | "stopBlocks";
|
|
335
|
+
agentId?: string;
|
|
336
|
+
} | {
|
|
337
|
+
type: "goal_set";
|
|
338
|
+
objective: string;
|
|
339
|
+
replaced: boolean;
|
|
340
|
+
} | {
|
|
341
|
+
type: "goal_cleared";
|
|
203
342
|
} | {
|
|
204
343
|
type: "error";
|
|
205
344
|
error: string;
|
|
@@ -210,6 +349,13 @@ export type StreamEvent = {
|
|
|
210
349
|
} | {
|
|
211
350
|
type: "task_update";
|
|
212
351
|
tasks: TaskInfo[];
|
|
352
|
+
agentId?: string;
|
|
353
|
+
} | {
|
|
354
|
+
type: "memory_recalled";
|
|
355
|
+
name: string;
|
|
356
|
+
scope: "user" | "dream";
|
|
357
|
+
location: "global" | "project";
|
|
358
|
+
agentId?: string;
|
|
213
359
|
} | {
|
|
214
360
|
type: "thinking_delta";
|
|
215
361
|
text: string;
|
|
@@ -219,6 +365,13 @@ export type StreamEvent = {
|
|
|
219
365
|
agentId: string;
|
|
220
366
|
name?: string;
|
|
221
367
|
description: string;
|
|
368
|
+
agentType?: string;
|
|
369
|
+
} | {
|
|
370
|
+
type: "agent_backgrounded";
|
|
371
|
+
agentId: string;
|
|
372
|
+
name?: string;
|
|
373
|
+
description: string;
|
|
374
|
+
agentType?: string;
|
|
222
375
|
} | {
|
|
223
376
|
type: "agent_end";
|
|
224
377
|
agentId: string;
|
|
@@ -226,6 +379,11 @@ export type StreamEvent = {
|
|
|
226
379
|
description: string;
|
|
227
380
|
text?: string;
|
|
228
381
|
error?: string;
|
|
382
|
+
agentType?: string;
|
|
383
|
+
} | {
|
|
384
|
+
type: "agent_heartbeat";
|
|
385
|
+
agentIds: string[];
|
|
386
|
+
ts: number;
|
|
229
387
|
} | {
|
|
230
388
|
type: "tool_summary";
|
|
231
389
|
summary: string;
|
|
@@ -238,6 +396,27 @@ export type StreamEvent = {
|
|
|
238
396
|
} | {
|
|
239
397
|
type: "usage_update";
|
|
240
398
|
promptTokens: number;
|
|
399
|
+
/**
|
|
400
|
+
* Provider-reported prompt-cache counts, forwarded so the UI can show a
|
|
401
|
+
* cache hit rate in the context-ring tooltip. Present only when the LLM
|
|
402
|
+
* response carried them (authoritative-usage emits); omitted on the
|
|
403
|
+
* message-estimate emits that fire between LLM calls. See
|
|
404
|
+
* docs/todo/prompt-cache-optimization.md.
|
|
405
|
+
*/
|
|
406
|
+
cacheReadTokens?: number;
|
|
407
|
+
cacheCreationTokens?: number;
|
|
408
|
+
/**
|
|
409
|
+
* SESSION-CUMULATIVE cache counts (sum across every LLM response this
|
|
410
|
+
* session, across runs and turns), emitted from the engine's turn
|
|
411
|
+
* boundary off the persisted session.state.tokenUsage. Distinct from the
|
|
412
|
+
* per-response cacheReadTokens/cacheCreationTokens above: those drive the
|
|
413
|
+
* live context reading, these drive the "本会话累计命中率" tooltip. Reset
|
|
414
|
+
* to 0 on a model switch. Present only on the cumulative (turn-boundary)
|
|
415
|
+
* emit; omitted on per-response / estimate emits.
|
|
416
|
+
*/
|
|
417
|
+
sessionCacheReadTokens?: number;
|
|
418
|
+
sessionCacheCreationTokens?: number;
|
|
419
|
+
sessionPromptTokens?: number;
|
|
241
420
|
agentId?: string;
|
|
242
421
|
} | {
|
|
243
422
|
type: "background_agent_completed";
|
|
@@ -245,6 +424,15 @@ export type StreamEvent = {
|
|
|
245
424
|
name?: string;
|
|
246
425
|
description: string;
|
|
247
426
|
status: "completed" | "failed";
|
|
427
|
+
/**
|
|
428
|
+
* What kind of background work this was. Lets UIs localize the
|
|
429
|
+
* completion toast (e.g. a shell shows "命令完成" not the raw English
|
|
430
|
+
* description, which is written for the agent's wakeup notification).
|
|
431
|
+
* Absent for legacy sub-agent notifications (treated as "agent").
|
|
432
|
+
*/
|
|
433
|
+
workKind?: "agent" | "shell" | "video" | "cc";
|
|
434
|
+
/** For workKind === "shell": the command that ran (for a friendly label). */
|
|
435
|
+
command?: string;
|
|
248
436
|
/** Final assistant text (status === "completed" only). */
|
|
249
437
|
finalText?: string;
|
|
250
438
|
/** Error message (status === "failed" only). */
|
|
@@ -261,22 +449,42 @@ export type BackgroundAgentCompletedEvent = Extract<StreamEvent, {
|
|
|
261
449
|
type: "background_agent_completed";
|
|
262
450
|
}>;
|
|
263
451
|
export type StreamCallback = (event: StreamEvent) => void | Promise<void>;
|
|
452
|
+
/**
|
|
453
|
+
* LLMConfig — model identity only. Everything in this object describes
|
|
454
|
+
* "which model and how to reach it", nothing about user preferences or
|
|
455
|
+
* client wiring. Hot-switching models replaces this object wholesale.
|
|
456
|
+
*
|
|
457
|
+
* For cross-model preferences (temperature, timeouts, image detail) see
|
|
458
|
+
* ClientDefaults — those live on the Engine and feed every LLMClient
|
|
459
|
+
* independently of model identity.
|
|
460
|
+
*/
|
|
264
461
|
export interface LLMConfig {
|
|
265
462
|
provider: string;
|
|
266
463
|
model: string;
|
|
267
464
|
apiKey?: string;
|
|
268
465
|
baseUrl?: string;
|
|
269
|
-
temperature?: number;
|
|
270
|
-
topP?: number;
|
|
271
466
|
maxTokens?: number;
|
|
272
|
-
timeout?: number;
|
|
273
|
-
retryMaxAttempts?: number;
|
|
274
|
-
enableStreaming?: boolean;
|
|
275
467
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
468
|
+
* Shell command whose stdout is the auth token (TODO 7.2). Resolved at
|
|
469
|
+
* client-build time when `apiKey` is absent. The trimmed first line of
|
|
470
|
+
* stdout becomes the bearer token.
|
|
471
|
+
*/
|
|
472
|
+
authCommand?: string;
|
|
473
|
+
/**
|
|
474
|
+
* Extra HTTP headers for every request to this model's provider (TODO 7.2).
|
|
475
|
+
* A value `$ENV_VAR` is resolved from the environment at build time.
|
|
278
476
|
*/
|
|
279
|
-
|
|
477
|
+
httpHeaders?: Record<string, string>;
|
|
478
|
+
/** OpenAI `service_tier` request param, passed through verbatim (TODO 7.2). */
|
|
479
|
+
serviceTier?: string;
|
|
480
|
+
/** OpenAI reasoning `summary` control ("auto"|"concise"|"detailed") (TODO 7.2). */
|
|
481
|
+
reasoningSummary?: string;
|
|
482
|
+
/**
|
|
483
|
+
* Default reasoning/thinking setting for this model. Per-call
|
|
484
|
+
* `options.reasoning` (e.g. summarize sub-calls) overrides this.
|
|
485
|
+
* Translated to the per-vendor wire form by the client's capability layer.
|
|
486
|
+
*/
|
|
487
|
+
reasoning?: import("./llm/reasoning-setting.js").ReasoningSetting;
|
|
280
488
|
/**
|
|
281
489
|
* The provider's `kind` (deepseek/openai/zai/openrouter/...). Used by
|
|
282
490
|
* the capability layer to look up per-(kind, model) request-shape rules
|
|
@@ -285,6 +493,38 @@ export interface LLMConfig {
|
|
|
285
493
|
* ("openai" or "anthropic") that picks which client class to use.
|
|
286
494
|
*/
|
|
287
495
|
providerKind?: string;
|
|
496
|
+
/**
|
|
497
|
+
* Catalog-driven extra request-body fields (temperature/top_p/thinking etc),
|
|
498
|
+
* already wire-mapped from the connection's paramValues. Merged into the
|
|
499
|
+
* request body, each key filtered by the model's rejectedParams.
|
|
500
|
+
*/
|
|
501
|
+
extraBody?: Record<string, unknown>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* ClientDefaults — runtime knobs that apply regardless of which model is
|
|
505
|
+
* active. Settings/UI source these once at boot (or when settings change);
|
|
506
|
+
* model hot-switching never alters them.
|
|
507
|
+
*
|
|
508
|
+
* Anything model-specific belongs in LLMConfig instead.
|
|
509
|
+
*/
|
|
510
|
+
export interface ClientDefaults {
|
|
511
|
+
/** Sampling temperature. Default 0.3. Per-call options.temperature overrides. */
|
|
512
|
+
temperature?: number;
|
|
513
|
+
/** HTTP timeout in ms for LLM requests. Default 120_000. */
|
|
514
|
+
timeout?: number;
|
|
515
|
+
/** Max retry attempts for transient errors. Default 3. */
|
|
516
|
+
retryMaxAttempts?: number;
|
|
517
|
+
/**
|
|
518
|
+
* Provider-agnostic image clarity level. Drives the renderer-side
|
|
519
|
+
* downscale (long-edge cap: low→~1024 / standard→~1568 / high→~2576)
|
|
520
|
+
* so BOTH providers save tokens before send. On the OpenAI path it
|
|
521
|
+
* also maps to the wire `detail` hint (low→low, standard/high→high);
|
|
522
|
+
* Anthropic has no such param and saves purely via the downscale.
|
|
523
|
+
* Defaults to "high" (full fidelity) when unset.
|
|
524
|
+
*
|
|
525
|
+
* Legacy "original" values from older settings are migrated to "high".
|
|
526
|
+
*/
|
|
527
|
+
imageDetail?: "low" | "standard" | "high";
|
|
288
528
|
}
|
|
289
529
|
export interface LLMResponse {
|
|
290
530
|
text: string;
|
|
@@ -310,6 +550,51 @@ export interface MCPServerConfig {
|
|
|
310
550
|
url?: string;
|
|
311
551
|
transport?: MCPTransport;
|
|
312
552
|
headers?: Record<string, string>;
|
|
553
|
+
/**
|
|
554
|
+
* (stdio) NAMES of env vars to forward from the parent process to the
|
|
555
|
+
* spawned server. The value is read from `process.env` at connect time —
|
|
556
|
+
* the secret itself is never stored in config. Explicit `env` overrides.
|
|
557
|
+
*/
|
|
558
|
+
envVars?: string[];
|
|
559
|
+
/**
|
|
560
|
+
* (HTTP) NAME of an env var whose value is sent as
|
|
561
|
+
* `Authorization: Bearer <value>`. Read from `process.env` at connect time.
|
|
562
|
+
*/
|
|
563
|
+
bearerTokenEnvVar?: string;
|
|
564
|
+
/**
|
|
565
|
+
* (HTTP) Map of header-name → env-var-NAME. Each header's value is read
|
|
566
|
+
* from the named env var at connect time, keeping secrets out of config.
|
|
567
|
+
*/
|
|
568
|
+
envHeaders?: Record<string, string>;
|
|
569
|
+
/**
|
|
570
|
+
* (HTTP) id of a stored credential (CredentialStore) to use as the Bearer
|
|
571
|
+
* token. Resolved at connect time via a resolver passed to buildHttpHeaders;
|
|
572
|
+
* the secret is never stored in the MCP config. Wins over bearerTokenEnvVar.
|
|
573
|
+
*/
|
|
574
|
+
credentialRef?: string;
|
|
575
|
+
/**
|
|
576
|
+
* Toggle a server off without deleting its config (mirrors Codex's
|
|
577
|
+
* `enabled` field). Absent or `true` → connected; only the literal
|
|
578
|
+
* `false` disables it. Filtered in MCPManager.connectAll so the
|
|
579
|
+
* connection is never attempted; the entry stays in settings so the
|
|
580
|
+
* UI toggle can flip it back on. See connectAll().
|
|
581
|
+
*/
|
|
582
|
+
enabled?: boolean;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* User-supplied supplement for a PLUGIN-provided MCP server, keyed by the
|
|
586
|
+
* server's `<plugin>:<server>` name. Stored globally under
|
|
587
|
+
* `settings.mcpServerOverrides` and layered onto the plugin's config at merge
|
|
588
|
+
* time (see mergePluginMcpServers). Only env/credential fields are allowed —
|
|
589
|
+
* command/args/url/transport stay owned by the plugin manifest so a plugin
|
|
590
|
+
* update is never shadowed by a stale user copy.
|
|
591
|
+
*/
|
|
592
|
+
export interface MCPServerOverride {
|
|
593
|
+
env?: Record<string, string>;
|
|
594
|
+
envVars?: string[];
|
|
595
|
+
credentialRef?: string;
|
|
596
|
+
bearerTokenEnvVar?: string;
|
|
597
|
+
envHeaders?: Record<string, string>;
|
|
313
598
|
}
|
|
314
599
|
/**
|
|
315
600
|
* Shell-hook configuration entry from settings.json. Each entry binds
|
|
@@ -354,6 +639,7 @@ export interface Settings {
|
|
|
354
639
|
maxTokens: number;
|
|
355
640
|
compactAtRatio: number;
|
|
356
641
|
summarizeAtRatio: number;
|
|
642
|
+
microcompactFloorRatio: number;
|
|
357
643
|
};
|
|
358
644
|
session: {
|
|
359
645
|
storageDir: string;
|
package/dist/updater.js
CHANGED
|
@@ -33,6 +33,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
33
33
|
import { readFileSync } from "node:fs";
|
|
34
34
|
import { fileURLToPath } from "node:url";
|
|
35
35
|
import { promisify } from "node:util";
|
|
36
|
+
import { resolveShellInvocation } from "./runtime/spawn-common.js";
|
|
36
37
|
import { gt } from "./utils/semver.js";
|
|
37
38
|
const execFileAsync = promisify(execFile);
|
|
38
39
|
const PACKAGE_NAME = "@cjhyy/code-shell";
|
|
@@ -282,7 +283,7 @@ function launchDetachedInstall(version) {
|
|
|
282
283
|
try {
|
|
283
284
|
// Avoid `mkdirSync recursive` failures if dir exists.
|
|
284
285
|
try {
|
|
285
|
-
const fs =
|
|
286
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
286
287
|
fs.mkdirSync(configDir(), { recursive: true });
|
|
287
288
|
fs.writeFileSync(lockPath, String(process.pid), { encoding: "utf8", flag: "wx" });
|
|
288
289
|
}
|
|
@@ -290,7 +291,7 @@ function launchDetachedInstall(version) {
|
|
|
290
291
|
if (errnoCode(err) === "EEXIST") {
|
|
291
292
|
// Lock held — check freshness; if stale, take over.
|
|
292
293
|
try {
|
|
293
|
-
const fs =
|
|
294
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
294
295
|
const s = fs.statSync(lockPath);
|
|
295
296
|
if (Date.now() - s.mtimeMs < LOCK_TIMEOUT_MS)
|
|
296
297
|
return; // fresh — back off
|
|
@@ -309,7 +310,7 @@ function launchDetachedInstall(version) {
|
|
|
309
310
|
catch {
|
|
310
311
|
return;
|
|
311
312
|
}
|
|
312
|
-
const fs =
|
|
313
|
+
const fs = createRequire(import.meta.url ?? __filename)("node:fs");
|
|
313
314
|
const logFd = fs.openSync(getUpdateLogPath(), "a");
|
|
314
315
|
try {
|
|
315
316
|
fs.writeSync(logFd, `\n[${new Date().toISOString()}] code-shell auto-update: installing ${PACKAGE_NAME}@${version} (pid=${process.pid})\n`);
|
|
@@ -318,13 +319,23 @@ function launchDetachedInstall(version) {
|
|
|
318
319
|
// ignore
|
|
319
320
|
}
|
|
320
321
|
// Wrap install + lock cleanup in a tiny shell so the lock file is removed
|
|
321
|
-
// even if npm fails.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
// even if npm fails. Cross-platform: POSIX sequences with `; rm -f`, Windows
|
|
323
|
+
// cmd.exe with `& del /f /q` (no `sh`/`rm` there). resolveShellInvocation
|
|
324
|
+
// picks the shell binary + flag (/c vs -c) per platform.
|
|
325
|
+
const isWin = process.platform === "win32";
|
|
326
|
+
// cmd.exe doesn't understand POSIX single-quote escaping. version is a semver
|
|
327
|
+
// from npm (no shell metachars) so it needs no quoting on cmd; the lock path
|
|
328
|
+
// gets double quotes (cmd-native). POSIX keeps shellEscape on both.
|
|
329
|
+
const installPkg = isWin
|
|
330
|
+
? `npm install -g ${PACKAGE_NAME}@${version}`
|
|
331
|
+
: `npm install -g ${PACKAGE_NAME}@${shellEscape(version)}`;
|
|
332
|
+
const cleanup = isWin
|
|
333
|
+
? `& del /f /q "${lockPath}"`
|
|
334
|
+
: `; rm -f ${shellEscape(lockPath)}`;
|
|
335
|
+
const cmd = `${installPkg} ${cleanup}`;
|
|
336
|
+
const { file: shellFile, args: shellArgs } = resolveShellInvocation(cmd);
|
|
326
337
|
try {
|
|
327
|
-
const child = spawn(
|
|
338
|
+
const child = spawn(shellFile, shellArgs, {
|
|
328
339
|
detached: true,
|
|
329
340
|
stdio: ["ignore", logFd, logFd],
|
|
330
341
|
cwd: homedir(),
|
package/dist/utils/envUtils.d.ts
CHANGED
|
@@ -36,16 +36,7 @@ export declare function getDefaultVertexRegion(): string;
|
|
|
36
36
|
* Check if bash commands should maintain project working directory.
|
|
37
37
|
*/
|
|
38
38
|
export declare function shouldMaintainProjectWorkingDir(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Check if running on Homespace (ant-internal cloud environment).
|
|
41
|
-
*/
|
|
42
|
-
export declare function isRunningOnHomespace(): boolean;
|
|
43
39
|
/**
|
|
44
40
|
* Get the Vertex AI region for a specific model.
|
|
45
41
|
*/
|
|
46
42
|
export declare function getVertexRegionForModel(model: string | undefined): string | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Stub: Check if running inside a protected namespace.
|
|
49
|
-
* Always returns false in Code Shell (Anthropic-internal feature).
|
|
50
|
-
*/
|
|
51
|
-
export declare function isInProtectedNamespace(): boolean;
|
package/dist/utils/envUtils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
+
import { VERTEX_REGION_OVERRIDES } from '../data/model-metadata.js';
|
|
6
7
|
// Memoize cache for getClaudeConfigHomeDir
|
|
7
8
|
let _configHomeDirCache = null;
|
|
8
9
|
let _configHomeDirCacheKey = undefined;
|
|
@@ -93,27 +94,8 @@ export function getDefaultVertexRegion() {
|
|
|
93
94
|
export function shouldMaintainProjectWorkingDir() {
|
|
94
95
|
return isEnvTruthy(process.env.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR);
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
export function isRunningOnHomespace() {
|
|
100
|
-
return (process.env.USER_TYPE === 'ant' &&
|
|
101
|
-
isEnvTruthy(process.env.COO_RUNNING_ON_HOMESPACE));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Model prefix → env var for Vertex region overrides.
|
|
105
|
-
*/
|
|
106
|
-
const VERTEX_REGION_OVERRIDES = [
|
|
107
|
-
['claude-haiku-4-5', 'VERTEX_REGION_CLAUDE_HAIKU_4_5'],
|
|
108
|
-
['claude-3-5-haiku', 'VERTEX_REGION_CLAUDE_3_5_HAIKU'],
|
|
109
|
-
['claude-3-5-sonnet', 'VERTEX_REGION_CLAUDE_3_5_SONNET'],
|
|
110
|
-
['claude-3-7-sonnet', 'VERTEX_REGION_CLAUDE_3_7_SONNET'],
|
|
111
|
-
['claude-opus-4-1', 'VERTEX_REGION_CLAUDE_4_1_OPUS'],
|
|
112
|
-
['claude-opus-4', 'VERTEX_REGION_CLAUDE_4_0_OPUS'],
|
|
113
|
-
['claude-sonnet-4-6', 'VERTEX_REGION_CLAUDE_4_6_SONNET'],
|
|
114
|
-
['claude-sonnet-4-5', 'VERTEX_REGION_CLAUDE_4_5_SONNET'],
|
|
115
|
-
['claude-sonnet-4', 'VERTEX_REGION_CLAUDE_4_0_SONNET'],
|
|
116
|
-
];
|
|
97
|
+
// VERTEX_REGION_OVERRIDES now lives in data/model-metadata.json (imported above)
|
|
98
|
+
// so adding a model's region env var is a data edit, not a code change.
|
|
117
99
|
/**
|
|
118
100
|
* Get the Vertex AI region for a specific model.
|
|
119
101
|
*/
|
|
@@ -126,10 +108,3 @@ export function getVertexRegionForModel(model) {
|
|
|
126
108
|
}
|
|
127
109
|
return getDefaultVertexRegion();
|
|
128
110
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Stub: Check if running inside a protected namespace.
|
|
131
|
-
* Always returns false in Code Shell (Anthropic-internal feature).
|
|
132
|
-
*/
|
|
133
|
-
export function isInProtectedNamespace() {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform executable resolution.
|
|
3
|
+
*
|
|
4
|
+
* Node's `child_process.spawn`/`execFile` on Windows do NOT walk PATHEXT for a
|
|
5
|
+
* bare command name unless `shell:true` — so `execFile("git", …)` finds
|
|
6
|
+
* `git.exe` but NOT a `git.cmd`/`gh.cmd` shim (common for tools installed via
|
|
7
|
+
* scoop/npm/chocolatey). On POSIX a bare name in PATH works fine.
|
|
8
|
+
*
|
|
9
|
+
* `resolveExecutable` does an explicit PATH × PATHEXT lookup on Windows and
|
|
10
|
+
* returns the first existing match's absolute path; on POSIX (or when nothing
|
|
11
|
+
* is found) it returns the command unchanged, so callers can always pass the
|
|
12
|
+
* result straight to execFile/spawn.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The names to probe for `command` on the current platform: the bare name on
|
|
16
|
+
* POSIX (or when it already has an extension), plus each PATHEXT variant
|
|
17
|
+
* (command.exe / .cmd / .bat …) on Windows.
|
|
18
|
+
*/
|
|
19
|
+
export declare function commandCandidateNames(command: string, env?: NodeJS.ProcessEnv): string[];
|
|
20
|
+
export declare function resolveExecutable(command: string, env?: NodeJS.ProcessEnv): string;
|
|
21
|
+
/** Test seam: drop the resolution cache. */
|
|
22
|
+
export declare function _clearExecutableCache(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Find `command` as a real, runnable executable. Unlike {@link resolveExecutable}
|
|
25
|
+
* (which returns the bare name unchanged when nothing is found, so spawn can
|
|
26
|
+
* surface its own ENOENT), this returns the absolute path if a binary exists or
|
|
27
|
+
* `null` if it genuinely cannot be found — works on POSIX too (probes PATH).
|
|
28
|
+
* Use it to *detect* a missing tool up front (e.g. is git installed?).
|
|
29
|
+
*/
|
|
30
|
+
export declare function findExecutable(command: string, env?: NodeJS.ProcessEnv): string | null;
|
|
31
|
+
/** Set (or clear, with null/"") the user-configured git binary path. */
|
|
32
|
+
export declare function setGitPathOverride(path: string | null | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* The git command to spawn: the user override if set, else `git` resolved
|
|
35
|
+
* through PATH×PATHEXT. Always returns something spawnable (callers still get
|
|
36
|
+
* a structured spawn-failure if it's wrong).
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveGit(env?: NodeJS.ProcessEnv): string;
|
|
39
|
+
/** Is a usable git binary available (override path, or git on PATH)? */
|
|
40
|
+
export declare function isGitAvailable(env?: NodeJS.ProcessEnv): boolean;
|