@cjhyy/code-shell-core 0.5.0-rc.2 → 0.6.0-rc.2
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 +3 -0
- package/dist/agent/agent-definition-registry.js +3 -1
- package/dist/agent/agent-definition.d.ts +15 -0
- package/dist/agent/agent-definition.js +27 -3
- package/dist/arena/context/context-tools.js +47 -4
- package/dist/arena/ledger.js +9 -1
- package/dist/arena/strategies/utils.d.ts +1 -4
- package/dist/arena/strategies/utils.js +7 -84
- package/dist/automation/cron-expr.d.ts +10 -0
- package/dist/automation/cron-expr.js +23 -5
- package/dist/automation/runner.d.ts +21 -4
- package/dist/automation/runner.js +48 -12
- package/dist/automation/scheduler.d.ts +38 -0
- package/dist/automation/scheduler.js +89 -12
- package/dist/automation/store.js +5 -2
- package/dist/capability-control/disabled-lists.d.ts +25 -0
- package/dist/capability-control/disabled-lists.js +57 -0
- package/dist/capability-control/overlay.d.ts +15 -0
- package/dist/capability-control/overlay.js +27 -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 +15 -1
- package/dist/cli/agent-server-stdio.js +115 -17
- package/dist/cli/agent-server-tcp.js +40 -26
- package/dist/context/compaction.d.ts +56 -0
- package/dist/context/compaction.js +186 -0
- package/dist/context/manager.js +25 -4
- 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/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/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 +267 -138
- package/dist/engine/engine.js +957 -191
- package/dist/engine/friendly-error.d.ts +18 -0
- package/dist/engine/friendly-error.js +63 -0
- package/dist/engine/goal.d.ts +145 -0
- package/dist/engine/goal.js +144 -0
- package/dist/engine/image-policy.d.ts +13 -0
- package/dist/engine/image-policy.js +24 -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/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.js +2 -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-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 +67 -3
- package/dist/engine/turn-loop.js +292 -41
- 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/utils.js +11 -6
- package/dist/git/worktree.d.ts +48 -0
- package/dist/git/worktree.js +86 -10
- package/dist/hooks/goal-stop-hook.d.ts +28 -0
- package/dist/hooks/goal-stop-hook.js +186 -9
- package/dist/hooks/registry.d.ts +8 -0
- package/dist/hooks/registry.js +19 -0
- package/dist/hooks/shell-runner.js +10 -21
- package/dist/index.d.ts +49 -6
- package/dist/index.js +60 -4
- package/dist/llm/capabilities/param-specs.d.ts +14 -0
- package/dist/llm/capabilities/param-specs.js +62 -0
- package/dist/llm/capabilities/rules.js +4 -0
- package/dist/llm/capabilities/types.d.ts +10 -0
- package/dist/llm/client-base.d.ts +28 -1
- package/dist/llm/client-base.js +119 -13
- package/dist/llm/model-cache.js +4 -2
- package/dist/llm/model-pool.d.ts +14 -0
- package/dist/llm/model-pool.js +13 -0
- package/dist/llm/provider-auth.d.ts +41 -0
- package/dist/llm/provider-auth.js +76 -0
- package/dist/llm/provider-catalog.d.ts +4 -0
- package/dist/llm/providers/anthropic.js +64 -14
- package/dist/llm/providers/openai.d.ts +36 -0
- package/dist/llm/providers/openai.js +257 -51
- package/dist/llm/reasoning-setting.d.ts +3 -3
- package/dist/llm/reasoning-setting.js +9 -1
- package/dist/llm/stream-watchdog.js +5 -1
- package/dist/llm/token-counter.js +9 -2
- package/dist/llm/types.d.ts +4 -0
- package/dist/logging/sanitize-messages.js +22 -0
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +40 -10
- 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 +61 -326
- package/dist/plugins/gitOps.d.ts +19 -0
- package/dist/plugins/gitOps.js +73 -4
- package/dist/plugins/installer/checkUpdate.d.ts +16 -0
- package/dist/plugins/installer/checkUpdate.js +32 -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 +5 -2
- package/dist/plugins/installer/codex/convertMcp.js +45 -5
- package/dist/plugins/installer/install.js +25 -1
- package/dist/plugins/installer/installFromArchive.d.ts +43 -0
- package/dist/plugins/installer/installFromArchive.js +134 -0
- package/dist/plugins/installer/installFromSource.js +8 -2
- package/dist/plugins/installer/loadPluginAgents.js +6 -2
- package/dist/plugins/installer/loadPluginMcp.d.ts +9 -2
- package/dist/plugins/installer/loadPluginMcp.js +35 -2
- package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
- package/dist/plugins/installer/pruneDisabled.js +73 -0
- package/dist/plugins/installer/types.d.ts +5 -2
- package/dist/plugins/installer/types.js +1 -0
- package/dist/plugins/installer/uninstall.js +4 -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 +14 -0
- package/dist/plugins/installer/update.js +53 -21
- package/dist/plugins/loadPluginHooks.d.ts +47 -1
- package/dist/plugins/loadPluginHooks.js +73 -1
- package/dist/plugins/marketplaceManager.d.ts +7 -0
- package/dist/plugins/marketplaceManager.js +20 -0
- package/dist/plugins/pluginCommandHook.js +4 -18
- package/dist/plugins/pluginContent.d.ts +30 -0
- package/dist/plugins/pluginContent.js +83 -0
- package/dist/plugins/pluginInstaller.d.ts +13 -0
- package/dist/plugins/pluginInstaller.js +42 -8
- package/dist/plugins/schemas.js +1 -0
- package/dist/plugins/types.d.ts +6 -0
- package/dist/preset/index.d.ts +7 -1
- package/dist/preset/index.js +96 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +27 -0
- package/dist/prompt/composer.js +67 -21
- 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/protocol/chat-session-manager.d.ts +8 -2
- package/dist/protocol/chat-session-manager.js +36 -0
- package/dist/protocol/chat-session.d.ts +65 -0
- package/dist/protocol/chat-session.js +94 -2
- package/dist/protocol/client.d.ts +27 -0
- package/dist/protocol/client.js +38 -0
- package/dist/protocol/server.d.ts +112 -0
- package/dist/protocol/server.js +586 -16
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +46 -0
- package/dist/protocol/types.js +16 -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/review/review-prompt.d.ts +28 -0
- package/dist/review/review-prompt.js +81 -0
- package/dist/run/FileRunStore.js +8 -3
- package/dist/run/RunApprovalBackend.js +25 -5
- package/dist/run/RunManager.d.ts +12 -0
- package/dist/run/RunManager.js +35 -0
- package/dist/run/factory.d.ts +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/diagnostics.d.ts +1 -2
- package/dist/services/diagnostics.js +12 -7
- 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 -50
- package/dist/services/session-memory.js +24 -12
- package/dist/session/file-history.d.ts +124 -1
- package/dist/session/file-history.js +222 -6
- package/dist/session/memory.d.ts +116 -2
- package/dist/session/memory.js +250 -28
- package/dist/session/session-manager.d.ts +40 -0
- package/dist/session/session-manager.js +113 -3
- 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 +9 -2
- package/dist/settings/disk-defaults.js +11 -2
- package/dist/settings/feature-flags.d.ts +64 -0
- package/dist/settings/feature-flags.js +61 -0
- package/dist/settings/manager.d.ts +68 -1
- package/dist/settings/manager.js +266 -29
- package/dist/settings/migrate-config.d.ts +45 -0
- package/dist/settings/migrate-config.js +125 -0
- package/dist/settings/schema-export.d.ts +25 -0
- package/dist/settings/schema-export.js +38 -0
- package/dist/settings/schema.d.ts +1186 -771
- package/dist/settings/schema.js +268 -97
- 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/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 +12 -0
- package/dist/tool-system/builtin/agent-registry.js +8 -0
- package/dist/tool-system/builtin/agent.d.ts +21 -1
- package/dist/tool-system/builtin/agent.js +489 -42
- 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 +0 -15
- 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/config.js +7 -0
- package/dist/tool-system/builtin/cron.d.ts +7 -0
- package/dist/tool-system/builtin/cron.js +55 -3
- 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.js +20 -16
- 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 +35 -0
- package/dist/tool-system/builtin/generate-image.js +278 -50
- 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/glob.js +0 -7
- package/dist/tool-system/builtin/grep.js +6 -8
- 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 +7 -1
- package/dist/tool-system/builtin/index.js +249 -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.js +0 -7
- package/dist/tool-system/builtin/powershell.js +4 -1
- package/dist/tool-system/builtin/read.js +10 -10
- 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 +3 -2
- package/dist/tool-system/builtin/tool-search.js +25 -7
- 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/web-fetch.js +12 -2
- package/dist/tool-system/builtin/web-search.js +21 -7
- 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.js +0 -6
- package/dist/tool-system/context.d.ts +154 -6
- package/dist/tool-system/executor.d.ts +3 -1
- package/dist/tool-system/executor.js +172 -88
- package/dist/tool-system/investigation-guard.js +1 -1
- package/dist/tool-system/mcp-manager.d.ts +42 -4
- package/dist/tool-system/mcp-manager.js +186 -20
- package/dist/tool-system/path-policy.d.ts +5 -0
- package/dist/tool-system/path-policy.js +307 -8
- package/dist/tool-system/permission.d.ts +36 -1
- package/dist/tool-system/permission.js +281 -69
- package/dist/tool-system/plan-mode-allowlist.d.ts +13 -2
- package/dist/tool-system/plan-mode-allowlist.js +24 -2
- package/dist/tool-system/registry.d.ts +1 -0
- package/dist/tool-system/registry.js +16 -2
- 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/types.d.ts +217 -6
- 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/json.d.ts +12 -0
- package/dist/utils/json.js +92 -0
- package/dist/utils/theme.d.ts +1 -1
- package/dist/utils/theme.js +1 -1
- package/dist/utils/toolDisplay.js +0 -1
- package/package.json +13 -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
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
import { normalizeGoal } from "../engine/goal.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { listRunningBackgroundWork } from "../tool-system/builtin/background-work.js";
|
|
3
|
+
/**
|
|
4
|
+
* Render the current instant for the judge: a human-readable local time plus
|
|
5
|
+
* the numeric UTC offset and IANA zone, so the judge can reason about a
|
|
6
|
+
* wall-clock deadline written into the objective (e.g. "until 12:00"). An LLM
|
|
7
|
+
* has no clock — without this line it can never tell whether a time cutoff has
|
|
8
|
+
* passed. Falls back gracefully if Intl is unavailable.
|
|
9
|
+
*/
|
|
10
|
+
function renderNow(now) {
|
|
11
|
+
const iso = now.toISOString(); // unambiguous UTC anchor
|
|
12
|
+
try {
|
|
13
|
+
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
14
|
+
// e.g. "2026-07-01 12:11:32 GMT+8"
|
|
15
|
+
const local = now.toLocaleString("sv-SE", {
|
|
16
|
+
timeZoneName: "short",
|
|
17
|
+
});
|
|
18
|
+
return `${local} (时区 ${zone};UTC 基准 ${iso})`;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return iso;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const JUDGE_SYSTEM = "你是一个目标完成度裁判。给定一个目标、agent 最近的输出,以及当前在后台运行的任务清单," +
|
|
25
|
+
"判断目标状态。只返回一个 JSON 对象,形如 " +
|
|
26
|
+
'{"met": true|false, "waiting": true|false, "gaps": "若未达成,简述还差什么;达成则空串"}。' +
|
|
27
|
+
"三态语义:" +
|
|
28
|
+
"(1) met:true —— 目标已完全达成。" +
|
|
29
|
+
"(2) waiting:true —— 目标尚未达成,但剩下唯一要做的事就是等一个【会结束的】后台任务完成" +
|
|
30
|
+
"(如下载、视频渲染、会退出的脚本),它完成后系统会自动唤醒你继续。此时应允许停下来等。" +
|
|
31
|
+
"(3) 两者皆 false —— 目标未达成,且还有你能【主动去做】的事。" +
|
|
32
|
+
"关键:【常驻服务】(如 dev server、watch、`npm run dev`/`bun run dev` 这类永不退出的进程)" +
|
|
33
|
+
"不算‘在等的任务’——它永远在跑,目标若不依赖它就照常判断达成与否,绝不要因为它而返回 waiting。" +
|
|
34
|
+
"时间截止:若目标里写了明确的时间截止(如“到 12:00 停”“until 15:00”“干到今晚 22 点”)," +
|
|
35
|
+
"你会拿到【当前时间】(含时区),据此自行判断截止时刻是否已到、目标是否应当结束;解读截止以【当前时间】所在时区为准。" +
|
|
36
|
+
"关键——解读【相对/不完整的时间】(如只说“3点”“今晚”而没写日期):以【目标设定时间】为基准," +
|
|
37
|
+
"取其之后【最近的那个】时点。例如目标设定于 07-01 23:00、说“做到3点”,那就是 07-02 03:00;" +
|
|
38
|
+
"设定于 10:00、说“做到3点”,那就是当天 15:00(下午3点,设定后最近的3点)。" +
|
|
39
|
+
"绝不要因为“当前时间已过那个钟点”就把它顺延到第二天——只要当前时间已过【据设定时间算出的】截止时刻,就应当结束。" +
|
|
40
|
+
"(未提供【目标设定时间】时,退回仅凭当前时间按常理推断。)" +
|
|
41
|
+
"目标没有时间截止时,忽略当前时间,照常按内容判断。" +
|
|
5
42
|
"不要输出任何额外文字。宁可严格:只有确信目标已完全完成时才返回 met:true。";
|
|
6
43
|
/** Pull the first balanced JSON object out of possibly-prose text. */
|
|
7
44
|
function extractJson(text) {
|
|
@@ -18,14 +55,43 @@ function extractJson(text) {
|
|
|
18
55
|
if (typeof p.met !== "boolean")
|
|
19
56
|
return null;
|
|
20
57
|
const gaps = typeof p.gaps === "string" ? p.gaps : "";
|
|
21
|
-
|
|
58
|
+
const waiting = typeof p.waiting === "boolean" ? p.waiting : false;
|
|
59
|
+
return { met: p.met, waiting, gaps };
|
|
22
60
|
}
|
|
23
61
|
catch {
|
|
24
62
|
return null;
|
|
25
63
|
}
|
|
26
64
|
}
|
|
65
|
+
/** Render the running background tasks for the judge prompt. */
|
|
66
|
+
function renderBackgroundTasks(items) {
|
|
67
|
+
if (items.length === 0)
|
|
68
|
+
return "(无)";
|
|
69
|
+
const kindLabel = {
|
|
70
|
+
subagent: "后台子代理",
|
|
71
|
+
job: "后台任务",
|
|
72
|
+
shell: "后台命令",
|
|
73
|
+
};
|
|
74
|
+
return items
|
|
75
|
+
.map((i) => {
|
|
76
|
+
// A listening port strongly implies a long-lived service (dev server) —
|
|
77
|
+
// tell the judge so it doesn't classify it as a finite task to wait on.
|
|
78
|
+
const portNote = i.detectedPort != null
|
|
79
|
+
? `(在 :${i.detectedPort} 监听端口,疑似常驻服务)`
|
|
80
|
+
: "";
|
|
81
|
+
return `- [${kindLabel[i.kind] ?? i.kind}] ${i.description}${portNote}`;
|
|
82
|
+
})
|
|
83
|
+
.join("\n");
|
|
84
|
+
}
|
|
27
85
|
export function createGoalStopHook(opts) {
|
|
28
86
|
const { llm, log } = opts;
|
|
87
|
+
const now = opts.now ?? (() => new Date());
|
|
88
|
+
// Per-run cache: if the model emits the same final text with the same set of
|
|
89
|
+
// running background tasks twice in a row (it stalls repeating itself), the
|
|
90
|
+
// verdict can't have changed — reuse it instead of paying for another judge
|
|
91
|
+
// call. Keyed on (finalText + rendered task list); a `met` verdict is never
|
|
92
|
+
// cached (it ends the run anyway and triggers the onMet side-effect).
|
|
93
|
+
let lastKey = null;
|
|
94
|
+
let lastResult = null;
|
|
29
95
|
return async (ctx) => {
|
|
30
96
|
// Accept string or GoalConfig from either the override or ctx.data.goal.
|
|
31
97
|
const g = normalizeGoal(opts.goal ?? ctx.data.goal);
|
|
@@ -33,8 +99,56 @@ export function createGoalStopHook(opts) {
|
|
|
33
99
|
if (!g)
|
|
34
100
|
return {};
|
|
35
101
|
const goal = g.objective;
|
|
102
|
+
const sessionId = ctx.data.sessionId;
|
|
103
|
+
// Re-check the LIVE goal each turn. `goal` above is frozen at hook creation,
|
|
104
|
+
// so a goal cleared mid-run (清除) on a long-lived run (automation / resumed)
|
|
105
|
+
// would keep being judged off the stale copy — Engine.clearGoal's unregister
|
|
106
|
+
// only reaches the single in-flight hook it tracks. If the persisted goal is
|
|
107
|
+
// gone, allow the stop now and skip the judge call entirely.
|
|
108
|
+
if (opts.isGoalActive &&
|
|
109
|
+
typeof sessionId === "string" &&
|
|
110
|
+
sessionId.length > 0 &&
|
|
111
|
+
!opts.isGoalActive(sessionId)) {
|
|
112
|
+
log.info("goal_stop.cleared_midrun", { cat: "goal" });
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
// Background work is no longer a mechanical short-circuit. Instead we list
|
|
116
|
+
// what's running and let the judge decide (s-mqe0ox7n-a8d11c26 bug): a
|
|
117
|
+
// boolean "has background work" can't tell a finite download/render (→ wait
|
|
118
|
+
// for the wakeup, allow stop) from a never-ending dev server (→ judge the
|
|
119
|
+
// goal normally). The judge sees each task's kind + command and returns a
|
|
120
|
+
// three-state verdict; `waiting:true` allows the stop without pushing.
|
|
121
|
+
const runningWork = typeof sessionId === "string" && sessionId.length > 0
|
|
122
|
+
? listRunningBackgroundWork(sessionId)
|
|
123
|
+
: [];
|
|
124
|
+
const backgroundTasks = renderBackgroundTasks(runningWork);
|
|
36
125
|
const finalText = typeof ctx.data.finalText === "string" ? ctx.data.finalText : "";
|
|
126
|
+
const nowDate = now();
|
|
127
|
+
const nowLabel = renderNow(nowDate);
|
|
128
|
+
// The goal-set instant (when the user last set/replaced this goal), used by
|
|
129
|
+
// the judge to anchor relative deadlines ("做到3点"). renderNow renders any
|
|
130
|
+
// instant, not just "now". Absent for pre-field goals → line omitted, judge
|
|
131
|
+
// falls back to reasoning from current time alone.
|
|
132
|
+
const setAtLabel = typeof g.setAtMs === "number" && g.setAtMs > 0
|
|
133
|
+
? renderNow(new Date(g.setAtMs))
|
|
134
|
+
: undefined;
|
|
135
|
+
// Verdict cache key: same goal + same final text + same running tasks +
|
|
136
|
+
// same MINUTE ⇒ verdict unchanged; skip the LLM call and replay it.
|
|
137
|
+
// The minute bucket is in the key on purpose: if a goal has a wall-clock
|
|
138
|
+
// deadline and the model stalls repeating identical output, a time-blind
|
|
139
|
+
// key would replay a stale "not met" forever and the deadline would never
|
|
140
|
+
// fire. Bucketing to the minute still absorbs same-minute repeats while
|
|
141
|
+
// re-judging once the clock advances past a cutoff.
|
|
142
|
+
const minuteBucket = nowDate.toISOString().slice(0, 16);
|
|
143
|
+
const cacheKey = `${goal} ${finalText} ${backgroundTasks} ${minuteBucket}`;
|
|
144
|
+
if (lastKey === cacheKey && lastResult) {
|
|
145
|
+
log.info("goal_stop.verdict_cache_hit", { cat: "goal" });
|
|
146
|
+
return lastResult;
|
|
147
|
+
}
|
|
148
|
+
const signal = ctx.data.signal;
|
|
37
149
|
let verdict = null;
|
|
150
|
+
let respText = "";
|
|
151
|
+
let respStopReason;
|
|
38
152
|
try {
|
|
39
153
|
const resp = await llm.createMessage({
|
|
40
154
|
systemPrompt: JUDGE_SYSTEM,
|
|
@@ -42,16 +156,36 @@ export function createGoalStopHook(opts) {
|
|
|
42
156
|
{
|
|
43
157
|
role: "user",
|
|
44
158
|
content: `目标:\n${goal}\n\n` +
|
|
159
|
+
(setAtLabel ? `目标设定于:${setAtLabel}\n\n` : "") +
|
|
160
|
+
`当前时间:${nowLabel}\n\n` +
|
|
45
161
|
`agent 最近的输出:\n${finalText || "(无文本输出)"}\n\n` +
|
|
46
|
-
|
|
162
|
+
`当前在后台运行的任务:\n${backgroundTasks}\n\n` +
|
|
163
|
+
"判断目标状态,按要求只返回 JSON(met / waiting / gaps)。",
|
|
47
164
|
},
|
|
48
165
|
],
|
|
49
166
|
stream: false,
|
|
50
|
-
|
|
167
|
+
// Headroom, not 400. A reasoning-capable aux model (e.g. DeepSeek V4)
|
|
168
|
+
// shares this budget between hidden reasoning tokens and the visible
|
|
169
|
+
// JSON. At 400 the reasoning ate the budget and the JSON got truncated
|
|
170
|
+
// (stopReason:"length") → extractJson returned null → the P0
|
|
171
|
+
// "unparseable" branch kept the run going forever, so a wall-clock
|
|
172
|
+
// deadline in the goal never fired. `reasoning:off` below is the real
|
|
173
|
+
// fix; 1500 is the belt-and-suspenders for models that ignore it.
|
|
174
|
+
maxTokens: 1500,
|
|
51
175
|
// Auxiliary sub-call — keep it out of the session cost/turn stats.
|
|
52
176
|
recordUsage: false,
|
|
177
|
+
// Turn thinking OFF. The judge only emits a tiny JSON verdict; reasoning
|
|
178
|
+
// tokens are pure waste here and (per above) actively caused truncation.
|
|
179
|
+
// On DeepSeek V4 / Anthropic-budget this genuinely disables thinking; on
|
|
180
|
+
// effort/adaptive/unknown models the field is a no-op (never a 400), so
|
|
181
|
+
// it is safe to always send — matching the aux summary/memory calls.
|
|
182
|
+
reasoning: { mode: "off" },
|
|
183
|
+
// Let a user Stop mid-judge abort this call rather than block on it.
|
|
184
|
+
signal,
|
|
53
185
|
});
|
|
54
|
-
|
|
186
|
+
respText = resp.text ?? "";
|
|
187
|
+
respStopReason = resp.stopReason;
|
|
188
|
+
verdict = extractJson(respText);
|
|
55
189
|
}
|
|
56
190
|
catch (err) {
|
|
57
191
|
log.warn("goal_stop.judge_failed", {
|
|
@@ -70,7 +204,15 @@ export function createGoalStopHook(opts) {
|
|
|
70
204
|
};
|
|
71
205
|
}
|
|
72
206
|
if (!verdict) {
|
|
73
|
-
|
|
207
|
+
// Record enough to diagnose WHY the verdict didn't parse without having to
|
|
208
|
+
// reproduce it live: stopReason ("length" ⇒ the reply was truncated, the
|
|
209
|
+
// most common cause) plus a short preview of the raw text. Preview is
|
|
210
|
+
// capped so a runaway reply can't bloat the log line.
|
|
211
|
+
log.warn("goal_stop.unparseable", {
|
|
212
|
+
cat: "goal",
|
|
213
|
+
stopReason: respStopReason,
|
|
214
|
+
preview: respText.slice(0, 200),
|
|
215
|
+
});
|
|
74
216
|
// P0: same as the throw path — unparseable judge output must not be
|
|
75
217
|
// treated as "done". Continue instead of silently allowing the stop.
|
|
76
218
|
return {
|
|
@@ -82,12 +224,44 @@ export function createGoalStopHook(opts) {
|
|
|
82
224
|
}
|
|
83
225
|
if (verdict.met) {
|
|
84
226
|
log.info("goal_stop.met", { cat: "goal" });
|
|
227
|
+
// Clear the persisted active goal (engine side-effect) so a later bare
|
|
228
|
+
// send doesn't re-inherit a satisfied goal. Isolated so a throwing
|
|
229
|
+
// callback can't block the stop.
|
|
230
|
+
try {
|
|
231
|
+
opts.onMet?.();
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
/* ignore */
|
|
235
|
+
}
|
|
85
236
|
// Surface the verdict so the loop can emit a goal_progress(met) event.
|
|
86
237
|
return { data: { goalVerdict: { met: true, gaps: "" } } };
|
|
87
238
|
}
|
|
239
|
+
// waiting: goal not met, but the only remaining work is a FINITE background
|
|
240
|
+
// task that will wake the session on completion. Allow the stop (no push) —
|
|
241
|
+
// forcing continueSession here is exactly the busy-loop bug. The completion
|
|
242
|
+
// notification wakes the idle session (server maybeWakeIdleSession) and the
|
|
243
|
+
// goal is re-judged on that woken turn.
|
|
244
|
+
//
|
|
245
|
+
// GUARD: only honor `waiting` when real background work is actually running.
|
|
246
|
+
// If the judge hallucinates waiting:true with an empty task list, allowing
|
|
247
|
+
// the stop would silently abandon the goal — NOTHING would ever wake the
|
|
248
|
+
// session (no notification to drain). So a baseless `waiting` falls through
|
|
249
|
+
// to not_met (continueSession), where the model is nudged to keep working.
|
|
250
|
+
if (verdict.waiting && runningWork.length > 0) {
|
|
251
|
+
log.info("goal_stop.waiting_on_background_task", { cat: "goal", sessionId });
|
|
252
|
+
const result = {
|
|
253
|
+
data: { goalVerdict: { met: false, gaps: verdict.gaps.trim() } },
|
|
254
|
+
};
|
|
255
|
+
lastKey = cacheKey;
|
|
256
|
+
lastResult = result;
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
if (verdict.waiting) {
|
|
260
|
+
log.warn("goal_stop.waiting_without_background_work", { cat: "goal", sessionId });
|
|
261
|
+
}
|
|
88
262
|
log.info("goal_stop.not_met", { cat: "goal", gaps: verdict.gaps });
|
|
89
263
|
const gaps = verdict.gaps.trim();
|
|
90
|
-
|
|
264
|
+
const result = {
|
|
91
265
|
continueSession: true,
|
|
92
266
|
messages: [
|
|
93
267
|
gaps
|
|
@@ -98,5 +272,8 @@ export function createGoalStopHook(opts) {
|
|
|
98
272
|
// with this `gaps` instead of re-running the judge.
|
|
99
273
|
data: { goalVerdict: { met: false, gaps } },
|
|
100
274
|
};
|
|
275
|
+
lastKey = cacheKey;
|
|
276
|
+
lastResult = result;
|
|
277
|
+
return result;
|
|
101
278
|
};
|
|
102
279
|
}
|
package/dist/hooks/registry.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export declare class HookRegistry {
|
|
|
13
13
|
* the handler isn't registered for that event.
|
|
14
14
|
*/
|
|
15
15
|
unregister(eventName: HookEventName, handler: HookHandler): void;
|
|
16
|
+
/**
|
|
17
|
+
* Remove every registered hook whose `name` starts with `prefix`, across all
|
|
18
|
+
* events. Used to drop a whole source's hooks by naming convention (e.g.
|
|
19
|
+
* `plugin:` handlers) when that source is reloaded mid-session — so disabling
|
|
20
|
+
* a plugin stops its hooks on the live session, not just on new sessions.
|
|
21
|
+
* Returns the number removed.
|
|
22
|
+
*/
|
|
23
|
+
removeByNamePrefix(prefix: string): number;
|
|
16
24
|
emit(eventName: HookEventName, data?: Record<string, unknown>): Promise<HookResult>;
|
|
17
25
|
hasHooks(eventName: HookEventName): boolean;
|
|
18
26
|
clear(eventName?: HookEventName): void;
|
package/dist/hooks/registry.js
CHANGED
|
@@ -41,6 +41,25 @@ export class HookRegistry {
|
|
|
41
41
|
else
|
|
42
42
|
this.hooks.set(eventName, next);
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Remove every registered hook whose `name` starts with `prefix`, across all
|
|
46
|
+
* events. Used to drop a whole source's hooks by naming convention (e.g.
|
|
47
|
+
* `plugin:` handlers) when that source is reloaded mid-session — so disabling
|
|
48
|
+
* a plugin stops its hooks on the live session, not just on new sessions.
|
|
49
|
+
* Returns the number removed.
|
|
50
|
+
*/
|
|
51
|
+
removeByNamePrefix(prefix) {
|
|
52
|
+
let removed = 0;
|
|
53
|
+
for (const [event, list] of this.hooks) {
|
|
54
|
+
const next = list.filter((h) => !(h.name && h.name.startsWith(prefix)));
|
|
55
|
+
removed += list.length - next.length;
|
|
56
|
+
if (next.length === 0)
|
|
57
|
+
this.hooks.delete(event);
|
|
58
|
+
else
|
|
59
|
+
this.hooks.set(event, next);
|
|
60
|
+
}
|
|
61
|
+
return removed;
|
|
62
|
+
}
|
|
44
63
|
async emit(eventName, data = {}) {
|
|
45
64
|
const handlers = this.hooks.get(eventName);
|
|
46
65
|
if (!handlers?.length)
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { spawn } from "node:child_process";
|
|
32
32
|
import { MAX_HOOK_OUTPUT_BYTES, validateHookResult } from "./hook-output.js";
|
|
33
|
+
import { killChildTree } from "../runtime/spawn-common.js";
|
|
33
34
|
// Re-export so existing call sites that import { validateHookResult } from
|
|
34
35
|
// "./shell-runner.js" (e.g. tests) keep compiling.
|
|
35
36
|
export { validateHookResult };
|
|
@@ -72,22 +73,9 @@ export async function runShellHook(config, ctx) {
|
|
|
72
73
|
const timer = setTimeout(() => {
|
|
73
74
|
// eslint-disable-next-line no-console
|
|
74
75
|
console.warn(`[hooks] ${config.event} hook timed out after ${timeoutMs}ms: ${config.command}`);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// a graceful-shutdown handler in the child has a moment to flush.
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
try {
|
|
81
|
-
child.kill("SIGKILL");
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
/* already exited */
|
|
85
|
-
}
|
|
86
|
-
}, 1000);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
/* already exited */
|
|
90
|
-
}
|
|
76
|
+
// win32: taskkill /T reaps the shell tree; POSIX: SIGTERM → grace →
|
|
77
|
+
// SIGKILL (a graceful handler gets a moment to flush). See killChildTree.
|
|
78
|
+
killChildTree(child, 1000);
|
|
91
79
|
settle({});
|
|
92
80
|
}, timeoutMs);
|
|
93
81
|
// Byte cap: once we cross MAX_HOOK_OUTPUT_BYTES on stdout, kill the
|
|
@@ -96,6 +84,7 @@ export async function runShellHook(config, ctx) {
|
|
|
96
84
|
// its output. Stderr is also capped but treated more leniently —
|
|
97
85
|
// truncated, not fatal — since stderr is just diagnostic chatter.
|
|
98
86
|
let stdoutBytes = 0;
|
|
87
|
+
let stderrBytes = 0;
|
|
99
88
|
let stdoutCapped = false;
|
|
100
89
|
let stderrCapped = false;
|
|
101
90
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -105,17 +94,17 @@ export async function runShellHook(config, ctx) {
|
|
|
105
94
|
stdoutCapped = true;
|
|
106
95
|
// eslint-disable-next-line no-console
|
|
107
96
|
console.warn(`[hooks] ${config.event} hook stdout exceeded ${MAX_HOOK_OUTPUT_BYTES} bytes — killing`);
|
|
108
|
-
|
|
109
|
-
child.kill("SIGTERM");
|
|
110
|
-
}
|
|
111
|
-
catch { /* already exited */ }
|
|
97
|
+
killChildTree(child, 1000);
|
|
112
98
|
}
|
|
113
99
|
return;
|
|
114
100
|
}
|
|
115
101
|
stdout += chunk.toString("utf8");
|
|
116
102
|
});
|
|
117
103
|
child.stderr?.on("data", (chunk) => {
|
|
118
|
-
|
|
104
|
+
// Count raw bytes (not decoded string length) so multibyte UTF-8 output
|
|
105
|
+
// can't slip past the cap — matches the stdout accounting above.
|
|
106
|
+
stderrBytes += chunk.length;
|
|
107
|
+
if (stderrBytes > MAX_HOOK_OUTPUT_BYTES) {
|
|
119
108
|
if (!stderrCapped) {
|
|
120
109
|
stderrCapped = true;
|
|
121
110
|
stderr += "\n…[stderr truncated]";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API exports.
|
|
5
5
|
*/
|
|
6
|
-
export declare const VERSION = "0.5.0-rc.
|
|
6
|
+
export declare const VERSION = "0.5.0-rc.2";
|
|
7
7
|
export type { Message, ContentBlock, ToolDefinition, ToolCall, ToolResult, RegisteredTool, TranscriptEvent, TranscriptEventType, SessionState, SessionStatus, TokenUsage, CompiledInput, PermissionDecision, PermissionMode, PermissionRule, TurnPhase, TurnResult, TerminalReason, StreamEvent, StreamCallback, LLMConfig, ClientDefaults, LLMResponse, Settings, MCPServerConfig, } from "./types.js";
|
|
8
8
|
export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, SandboxUnavailableError, } from "./exceptions.js";
|
|
9
9
|
export { Engine, loadAgentDefinitionsForCwd } from "./engine/engine.js";
|
|
10
|
-
export type { EngineConfig, EngineHookConfig, EngineResult } from "./engine/
|
|
10
|
+
export type { EngineConfig, EngineHookConfig, EngineResult } from "./engine/types.js";
|
|
11
|
+
export { resolveLLMConfigForTag } from "./engine/resolve-llm-config.js";
|
|
12
|
+
export { resolveAuxKey } from "./engine/aux-key.js";
|
|
11
13
|
export { parseAgentDefinition, serializeAgentDefinition, type AgentDefinition, } from "./agent/agent-definition.js";
|
|
12
14
|
export { AgentDefinitionRegistry, type AgentSourceDir, } from "./agent/agent-definition-registry.js";
|
|
13
15
|
export type { CostStateStore, CostStateSnapshot } from "./engine/cost-store.js";
|
|
@@ -20,6 +22,7 @@ export { createLLMClient, registerProvider } from "./llm/client-factory.js";
|
|
|
20
22
|
export { AnthropicClient } from "./llm/providers/anthropic.js";
|
|
21
23
|
export { OpenAIClient } from "./llm/providers/openai.js";
|
|
22
24
|
export { ModelPool, type ModelEntry } from "./llm/model-pool.js";
|
|
25
|
+
export { modelEntriesFromConnections } from "./engine/model-connections-pool.js";
|
|
23
26
|
export { ToolRegistry } from "./tool-system/registry.js";
|
|
24
27
|
export { ToolExecutor } from "./tool-system/executor.js";
|
|
25
28
|
export { PermissionClassifier, HeadlessApprovalBackend, AutoApprovalBackend } from "./tool-system/permission.js";
|
|
@@ -27,7 +30,7 @@ export type { ApprovalBackend } from "./tool-system/permission.js";
|
|
|
27
30
|
export { BUILTIN_TOOLS } from "./tool-system/builtin/index.js";
|
|
28
31
|
export type { BuiltinTool, BuiltinToolFn } from "./tool-system/builtin/index.js";
|
|
29
32
|
export { makeUpdateAutomationMemoryTool } from "./tool-system/builtin/update-automation-memory.js";
|
|
30
|
-
export { MCPManager } from "./tool-system/mcp-manager.js";
|
|
33
|
+
export { MCPManager, buildHttpHeaders, buildStdioEnv } from "./tool-system/mcp-manager.js";
|
|
31
34
|
export type { AskUserFn } from "./tool-system/builtin/ask-user.js";
|
|
32
35
|
export type { Task, TaskStatus } from "./tool-system/builtin/task.js";
|
|
33
36
|
export { HookRegistry } from "./hooks/registry.js";
|
|
@@ -42,10 +45,12 @@ export { Methods, ErrorCodes, type RpcMessage, type RunResult, } from "./protoco
|
|
|
42
45
|
export { Transcript } from "./session/transcript.js";
|
|
43
46
|
export { SessionManager } from "./session/session-manager.js";
|
|
44
47
|
export { FileHistory } from "./session/file-history.js";
|
|
48
|
+
export { latestUndoTarget, earliestSnapshotsPerFile, latestTurnUndoTargets, latestRedoTargets, } from "./session/undo-target.js";
|
|
49
|
+
export { diffLines, renderDiffPreview, type DiffLine } from "./session/simple-diff.js";
|
|
45
50
|
export { MemoryManager } from "./session/memory.js";
|
|
46
51
|
export type { MemoryEntry, MemoryScope } from "./session/memory.js";
|
|
47
52
|
export { runDreamConsolidation, type DreamConsolidationInput, type DreamConsolidationResult, } from "./services/dream-consolidation.js";
|
|
48
|
-
export type { FileSnapshot } from "./session/file-history.js";
|
|
53
|
+
export type { FileSnapshot, RedoRecord } from "./session/file-history.js";
|
|
49
54
|
export { PromptComposer } from "./prompt/composer.js";
|
|
50
55
|
export { SectionCache } from "./prompt/section-cache.js";
|
|
51
56
|
export { scanInstructions, combineInstructions } from "./prompt/instruction-scanner.js";
|
|
@@ -63,18 +68,23 @@ export type { SkillDefinition } from "./skills/index.js";
|
|
|
63
68
|
export { CapabilityService, CapabilityNotFoundError, projectBuiltin, projectMcp, projectSkills, projectPlugins, } from "./capability-control/index.js";
|
|
64
69
|
export type { CapabilityServiceDeps, CapabilityDescriptor, CapabilityControl, } from "./capability-control/index.js";
|
|
65
70
|
export { readInstalledPlugins } from "./plugins/installedPlugins.js";
|
|
71
|
+
export { computeEffectiveDisabledLists, type EffectiveDisabledLists, } from "./capability-control/disabled-lists.js";
|
|
66
72
|
export type { InstalledPluginsV2 } from "./plugins/types.js";
|
|
67
73
|
export { installPluginFromPath } from "./plugins/installer/install.js";
|
|
68
74
|
export { installPluginFromSource } from "./plugins/installer/installFromSource.js";
|
|
75
|
+
export { installLocalPlugin, installPluginFromArchive, } from "./plugins/installer/installFromArchive.js";
|
|
69
76
|
export { parseSource, type ParsedSource } from "./plugins/installer/parseSource.js";
|
|
70
77
|
export { detectPluginFormat } from "./plugins/installer/detectFormat.js";
|
|
71
78
|
export { CodexPluginManifest, CSMeta, PluginInstallError, } from "./plugins/installer/types.js";
|
|
72
79
|
export { mergePluginMcpServers } from "./plugins/installer/loadPluginMcp.js";
|
|
80
|
+
export { listPluginHooks, pluginHookKey, type PluginHookEntry } from "./plugins/loadPluginHooks.js";
|
|
81
|
+
export { describePluginContent, type PluginContentInventory } from "./plugins/pluginContent.js";
|
|
73
82
|
export { pluginAgentDirs } from "./plugins/installer/loadPluginAgents.js";
|
|
74
83
|
export { appendInstallEntry, pluginInstallKey, removeInstallEntries, } from "./plugins/installedPlugins.js";
|
|
75
84
|
export { uninstallPluginByName } from "./plugins/installer/uninstall.js";
|
|
76
85
|
export { listInstalledPlugins, type PluginListRow } from "./plugins/installer/list.js";
|
|
77
86
|
export { updatePluginByName, type UpdateResult } from "./plugins/installer/update.js";
|
|
87
|
+
export { checkPluginUpdate, type UpdateCheck } from "./plugins/installer/checkUpdate.js";
|
|
78
88
|
export { Arena } from "./arena/arena.js";
|
|
79
89
|
export { MODEL_PRESETS, getMaxOutputTokens } from "./arena/model-presets.js";
|
|
80
90
|
export type { ModelPreset } from "./arena/model-presets.js";
|
|
@@ -94,21 +104,30 @@ export { RunManager, type RunManagerConfig, type RunStore, FileRunStore, RunQueu
|
|
|
94
104
|
export { defineProduct, type ProductDefinition, type ProductPreset, type ProductAdapter, type ProductContract, type CustomTool, type ProductRuntimeOptions, type ProductInstance, } from "./product/index.js";
|
|
95
105
|
export { logger } from "./logging/logger.js";
|
|
96
106
|
export { SettingsManager, type SettingsScope } from "./settings/manager.js";
|
|
107
|
+
export { migrateConfig, configVersionOf, CURRENT_CONFIG_VERSION, type MigrationStep, } from "./settings/migrate-config.js";
|
|
97
108
|
export { SettingsSchema, validateSettings } from "./settings/schema.js";
|
|
109
|
+
export { settingsJsonSchema, writeSettingsSchemaFile } from "./settings/schema-export.js";
|
|
98
110
|
export { personalizationFrom, type PersonalizationConfig } from "./settings/personalization.js";
|
|
111
|
+
export { CredentialStore, type CredentialScope, type MaskedCredential, type Credential, type CredentialType, type CredentialStoreFile, formatNetscapeCookies, parseCookieJar, type CookieLike, useCredentialToolDef, useCredentialToolDefFor, sweepStaleCredentialCookies, type EncryptionCipher, PlaintextCipher, setDefaultCredentialCipher, getDefaultCredentialCipher, } from "./credentials/index.js";
|
|
112
|
+
/** @internal Shared with the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
99
113
|
export { getSessionId, switchSession, getOriginalCwd, setOriginalCwd, getProjectRoot, setProjectRoot, getCwdState, getIsInteractive, updateLastInteractionTime, flushInteractionTime, markScrollActivity, type AttributedCounter, type ChannelEntry, } from "./state.js";
|
|
114
|
+
/** @internal Shared primitives for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
100
115
|
export { getGraphemeSegmenter, firstGrapheme, lastGrapheme, getWordSegmenter, getRelativeTimeFormat, getTimeZone, getSystemLocaleLanguage, } from "./utils/intl.js";
|
|
101
116
|
export { env } from "./utils/env.js";
|
|
102
117
|
export { default as sliceAnsi } from "./utils/sliceAnsi.js";
|
|
103
118
|
export { execFileNoThrow } from "./utils/execFileNoThrow.js";
|
|
119
|
+
export { findExecutable, resolveExecutable, setGitPathOverride, resolveGit, isGitAvailable, } from "./utils/exec.js";
|
|
104
120
|
export { gte } from "./utils/semver.js";
|
|
121
|
+
export { lock, lockSync, unlock, check } from "./utils/lockfile.js";
|
|
105
122
|
export { logForDebugging } from "./utils/debug.js";
|
|
106
|
-
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir,
|
|
123
|
+
export { isEnvTruthy, isEnvDefinedFalsy, getClaudeConfigHomeDir, isBareMode, parseEnvVars, shouldMaintainProjectWorkingDir, getAWSRegion, getDefaultVertexRegion, getVertexRegionForModel, } from "./utils/envUtils.js";
|
|
107
124
|
export { startCapturingEarlyInput, stopCapturingEarlyInput, consumeEarlyInput, hasEarlyInput, seedEarlyInput, isCapturingEarlyInput, } from "./utils/earlyInput.js";
|
|
108
125
|
export { formatBytes, formatToolArgs, singleLine, MAX_LINE_WIDTH, TOOL_DOT_COLORS, } from "./utils/toolDisplay.js";
|
|
126
|
+
export { classifyBashLines, type BashLineKind, type ClassifiedBashLine, } from "./tool-system/builtin/bash-output-style.js";
|
|
109
127
|
export { formatDuration, formatTokens } from "./utils/format.js";
|
|
110
128
|
export { getTheme, type Theme, type ThemeName, type ThemeSetting, } from "./utils/theme.js";
|
|
111
129
|
export { resolveThemeSetting, type SystemTheme } from "./utils/systemTheme.js";
|
|
130
|
+
/** @internal Host-lifecycle logging hooks for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
112
131
|
export { rotateLogs } from "./logging/logger.js";
|
|
113
132
|
export { recordUIEvent } from "./logging/session-recorder.js";
|
|
114
133
|
export { CostTracker, costTracker, installCostTracking } from "./cost-tracker.js";
|
|
@@ -116,20 +135,39 @@ export { NOOP_COLORIZER, type Colorizer } from "./colorizer.js";
|
|
|
116
135
|
export { hasApiKey, resolveApiKey, appendOnboardingResult, detectEnvKeys, saveArenaSettingsByKeys, type OnboardingResult, } from "./onboarding.js";
|
|
117
136
|
export { getCurrentVersion, checkForUpdate, scheduleAutoInstallOnExit, getUpdateAvailable, getAutoUpdateDisabledReason, type UpdateInfo, } from "./updater.js";
|
|
118
137
|
export { isGitRepo, getCurrentBranch, getGitStatus, getGitDiff, getGitDiffStat, getGitLog, gitAdd, gitCommit, gitListBranches, gitCheckout, ghAvailable, ghPrComments, } from "./git/utils.js";
|
|
138
|
+
export { buildReviewPrompt, parseDimensions, ALL_DIMENSIONS, type ReviewDimension, type ReviewPromptOptions, } from "./review/review-prompt.js";
|
|
139
|
+
/**
|
|
140
|
+
* @internal Exports below are consumed by the in-repo TUI/desktop hosts, not
|
|
141
|
+
* part of the stable `@cjhyy/code-shell-core` SDK surface. They may change or
|
|
142
|
+
* move to a `/tui` subpath without a major bump. External SDK users: prefer the
|
|
143
|
+
* primary Engine/Protocol API above.
|
|
144
|
+
*/
|
|
119
145
|
export { getInteractiveApprovalBackend } from "./tool-system/permission.js";
|
|
120
146
|
export { defaultSandboxConfig, type SandboxConfig, } from "./tool-system/sandbox/index.js";
|
|
121
147
|
export { buildNotificationMessage, buildNotificationSummary, notificationQueue, agentNotificationBus, notificationItemToStreamEvent, type NotificationItem, } from "./tool-system/builtin/agent-notifications.js";
|
|
122
148
|
export type { BackgroundAgentCompletedEvent } from "./types.js";
|
|
123
149
|
export { startAutomation, type StartAutomationDeps, type AutomationHandle, CronScheduler, cronScheduler, type CronJob, type CronPermissionLevel, type CreateJobOptions, type UpdateJobPatch, CronStore, defaultCronStorePath, bindCronToEngine, bindCronToRunManager, type CronRunner, type CronRunRequest, type CronRunResult, type RunSubmitter, isCronExpression, parseCronExpression, nextCronTime, type ParsedCron, resolveWritePolicy, wrapUntrustedInput, type WritePolicy, runWriteJobInWorktree, type WriteJobGitOps, type RunWriteJobInput, type RunWriteJobResult, } from "./automation/index.js";
|
|
150
|
+
export * from "./cc-orchestrator/index.js";
|
|
151
|
+
export { checkQuota, formatQuota } from "./quota/index.js";
|
|
152
|
+
export { resolveQuotaCredentials } from "./quota/credentials.js";
|
|
153
|
+
export type { QuotaResult, ProviderQuota, QuotaWindow, QuotaCredentials } from "./quota/types.js";
|
|
124
154
|
export { asyncAgentRegistry, type AsyncAgentEntry, } from "./tool-system/builtin/agent-registry.js";
|
|
155
|
+
export { backgroundShellManager, BackgroundShellManager, type BgShell, type BgShellStatus, } from "./runtime/background-shell.js";
|
|
156
|
+
export { getImageProvider, DEFAULT_IMAGE_MODEL, type ImageProvider, type ImageProviderCreds, type ImageGenerateRequest, type ImageGenerateResult, } from "./tool-system/builtin/image-providers.js";
|
|
157
|
+
export { transcribe, type TranscribeCreds, type TranscribeRequest, type TranscribeResult, } from "./stt/transcribe.js";
|
|
158
|
+
export { resolveTranscribeProvider, isTranscribeAvailable, describeTranscribe, type ResolvedTranscribeProvider, type TranscribeDescription, } from "./stt/resolve-transcribe.js";
|
|
159
|
+
export { BUILTIN_CATALOG, getMergedCatalog, loadUserCatalog, userCatalogPath, findCatalogEntry, saveCatalogEntry, deleteUserCatalogEntry, catalogEntryOrigins, type CatalogEntry, } from "./model-catalog/index.js";
|
|
160
|
+
/** @internal Extended protocol surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
125
161
|
export { createInProcessClient } from "./protocol/helpers.js";
|
|
126
162
|
export type { ProtocolModelEntry } from "./protocol/types.js";
|
|
163
|
+
/** @internal Extended Arena surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
127
164
|
export { formatArenaResult, printArenaResult, renderProgress, createProgressRenderer, type OutputSink, } from "./arena/render/terminal.js";
|
|
128
165
|
export { formatArenaResultForSession } from "./arena/render/session.js";
|
|
129
166
|
export { installPlugin, uninstallPlugin, listInstalled, } from "./plugins/pluginInstaller.js";
|
|
130
|
-
export { addMarketplace, removeMarketplace, listMarketplaces, loadMarketplace, } from "./plugins/marketplaceManager.js";
|
|
167
|
+
export { addMarketplace, refreshMarketplace, removeMarketplace, listMarketplaces, loadMarketplace, } from "./plugins/marketplaceManager.js";
|
|
131
168
|
export { parseMarketplaceInput, deriveMarketplaceName, } from "./plugins/parseMarketplaceInput.js";
|
|
132
169
|
export { scanPluginCommands, type PluginCommand, } from "./plugins/pluginCommandsLoader.js";
|
|
170
|
+
/** @internal Extended LLM surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
133
171
|
export { type CachedModel, defaultCacheDir, } from "./llm/model-cache.js";
|
|
134
172
|
export { fetchModelList, type FetchResult, } from "./llm/model-fetcher.js";
|
|
135
173
|
export { sanitizeApiKey, hasNonAsciiPrintable, } from "./llm/api-key-sanitize.js";
|
|
@@ -139,4 +177,9 @@ export { reasoningControlFor, type ReasoningControl, } from "./llm/capabilities/
|
|
|
139
177
|
export { REASONING_EFFORTS, type ReasoningSetting, } from "./llm/reasoning-setting.js";
|
|
140
178
|
export { type ProviderConfig } from "./llm/provider-catalog.js";
|
|
141
179
|
export { syncOpenRouterCatalog, getOpenRouterSnapshot, } from "./data/openrouter-sync.js";
|
|
180
|
+
/** @internal Extended type surface for the in-repo TUI/desktop hosts; not stable SDK surface. */
|
|
142
181
|
export type { ApprovalRequest, ApprovalResult, ApprovalScope, TaskInfo, } from "./types.js";
|
|
182
|
+
export { resolveExternalAgentConfig } from "./external-agents/config.js";
|
|
183
|
+
export type { ExternalAgentMode, ExternalAgentsSettings, ResolvedExternalAgentsConfig, ResolvedClaudeCodeSettings, ResolvedCodexSettings, } from "./external-agents/types.js";
|
|
184
|
+
export { flattenAxTree, renderElementList, cleanPageText, CONTENT_CHAR_CAP, buildExtractLinksScript, EXTRACT_LINK_CAP, } from "./tool-system/browser-bridge.js";
|
|
185
|
+
export type { BrowserBridge, BrowserElement, BrowserSnapshot, BrowserResult, BrowserContent, BrowserExtract, BrowserLink, BrowserImage, BrowserVideo, BrowserImageData, BrowserTab, AXNode, } from "./tool-system/browser-bridge.js";
|