@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in AddMarketplace tool — register a plugin marketplace source so the
|
|
3
|
+
* user can browse/install plugins from it in the UI. The tool only *adds the
|
|
4
|
+
* source* (git clone + validate marketplace.json via core's addMarketplace);
|
|
5
|
+
* which plugin to install is left to the user. Pairs with WebSearch/WebFetch:
|
|
6
|
+
* the model can discover a marketplace repo, then add it.
|
|
7
|
+
*
|
|
8
|
+
* Side effects (network + git clone + disk write) → permissionDefault "ask".
|
|
9
|
+
*/
|
|
10
|
+
import { addMarketplace } from "../../plugins/marketplaceManager.js";
|
|
11
|
+
export const addMarketplaceToolDef = {
|
|
12
|
+
name: "AddMarketplace",
|
|
13
|
+
description: "Register a plugin marketplace source so the user can browse and install " +
|
|
14
|
+
"plugins from it. Provide a short name and a source: either a GitHub repo " +
|
|
15
|
+
"(owner/name) or a git URL. This only ADDS the source — it does not install " +
|
|
16
|
+
"any plugin. Use WebSearch/WebFetch first to find a marketplace repo if you " +
|
|
17
|
+
"don't already have one.",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
name: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Short local name for this marketplace (e.g. 'official').",
|
|
24
|
+
},
|
|
25
|
+
source_type: {
|
|
26
|
+
type: "string",
|
|
27
|
+
enum: ["github", "git"],
|
|
28
|
+
description: "'github' for an owner/name repo, 'git' for a clone URL.",
|
|
29
|
+
},
|
|
30
|
+
repo: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "GitHub repo in owner/name form (required when source_type='github').",
|
|
33
|
+
},
|
|
34
|
+
url: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Git clone URL (required when source_type='git').",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ["name", "source_type"],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export async function addMarketplaceTool(args) {
|
|
43
|
+
const name = args.name;
|
|
44
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
45
|
+
return "Error: name is required";
|
|
46
|
+
}
|
|
47
|
+
const sourceType = args.source_type;
|
|
48
|
+
let source;
|
|
49
|
+
if (sourceType === "github") {
|
|
50
|
+
const repo = args.repo;
|
|
51
|
+
if (typeof repo !== "string" || !repo.includes("/")) {
|
|
52
|
+
return "Error: github source requires repo in owner/name form";
|
|
53
|
+
}
|
|
54
|
+
source = { source: "github", repo };
|
|
55
|
+
}
|
|
56
|
+
else if (sourceType === "git") {
|
|
57
|
+
const url = args.url;
|
|
58
|
+
if (typeof url !== "string" || !url.trim()) {
|
|
59
|
+
return "Error: git source requires a url";
|
|
60
|
+
}
|
|
61
|
+
source = { source: "git", url };
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return "Error: source_type must be 'github' or 'git'";
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const result = await addMarketplace(name, source);
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
return `Error adding marketplace ${name}: ${result.error}`;
|
|
70
|
+
}
|
|
71
|
+
return `Marketplace '${name}' added. The user can now browse and install plugins from it in the Extensions → Market UI.`;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return `Error adding marketplace ${name}: ${err.message}`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentHeartbeatPinger (B: background-agent visibility) — while background
|
|
3
|
+
* sub-agents are running, emit a periodic `agent_heartbeat` per parent session
|
|
4
|
+
* so the UI knows they're alive even during long LLM-request silence (no
|
|
5
|
+
* tool_use / no text for minutes). Decided over mtime/event-stream liveness
|
|
6
|
+
* because the worker KNOWS an agent is mid-request and can keep reporting it,
|
|
7
|
+
* whereas a quiet event stream looks dead.
|
|
8
|
+
*
|
|
9
|
+
* Liveness model deliberately NOT a separate heartbeat-file here — the file +
|
|
10
|
+
* pid (Heartbeat.ts / isProcessAlive) is for cross-restart interrupted
|
|
11
|
+
* detection (phase C). This pinger is the live "still working" UI signal only.
|
|
12
|
+
*
|
|
13
|
+
* Lifecycle (anti-leak): single timer, stored + cleared; `unref()` so it never
|
|
14
|
+
* pins the process open; `start()` idempotent; self-stops emitting when no
|
|
15
|
+
* agent runs but keeps the (unref'd) tick cheap. Mirrors the proven
|
|
16
|
+
* Heartbeat.ts / chat-session-manager sweeper pattern.
|
|
17
|
+
*/
|
|
18
|
+
import type { StreamEvent } from "../../types.js";
|
|
19
|
+
/** Default 30s — user-chosen. Stale threshold downstream is 3× (90s). */
|
|
20
|
+
export declare const DEFAULT_HEARTBEAT_INTERVAL_MS = 30000;
|
|
21
|
+
export interface AgentHeartbeatConfig {
|
|
22
|
+
intervalMs?: number;
|
|
23
|
+
/** Sink for each heartbeat event (server forwards to the client). */
|
|
24
|
+
publish: (sessionId: string, event: StreamEvent) => void;
|
|
25
|
+
/** Injectable clock for tests. */
|
|
26
|
+
now?: () => number;
|
|
27
|
+
}
|
|
28
|
+
export declare class AgentHeartbeatPinger {
|
|
29
|
+
private readonly intervalMs;
|
|
30
|
+
private readonly publish;
|
|
31
|
+
private readonly now;
|
|
32
|
+
private timer;
|
|
33
|
+
constructor(config: AgentHeartbeatConfig);
|
|
34
|
+
/** Begin periodic heartbeats. Idempotent — a second call is a no-op. */
|
|
35
|
+
start(): void;
|
|
36
|
+
stop(): void;
|
|
37
|
+
/** One heartbeat cycle: group running agents by session and publish. */
|
|
38
|
+
private tick;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Process-wide pinger that publishes to the agentNotificationBus (the same
|
|
42
|
+
* channel background-agent completions use → the protocol server forwards each
|
|
43
|
+
* event to the client). `ensureRunning()` is called when an agent backgrounds;
|
|
44
|
+
* the pinger self-stops once no agent is running, so a fresh handoff re-arms it.
|
|
45
|
+
*/
|
|
46
|
+
export declare const agentHeartbeatPinger: AgentHeartbeatPinger;
|
|
47
|
+
/** Start the shared pinger if not already ticking (idempotent). Call when an
|
|
48
|
+
* agent enters the background. */
|
|
49
|
+
export declare function ensureAgentHeartbeat(): void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentHeartbeatPinger (B: background-agent visibility) — while background
|
|
3
|
+
* sub-agents are running, emit a periodic `agent_heartbeat` per parent session
|
|
4
|
+
* so the UI knows they're alive even during long LLM-request silence (no
|
|
5
|
+
* tool_use / no text for minutes). Decided over mtime/event-stream liveness
|
|
6
|
+
* because the worker KNOWS an agent is mid-request and can keep reporting it,
|
|
7
|
+
* whereas a quiet event stream looks dead.
|
|
8
|
+
*
|
|
9
|
+
* Liveness model deliberately NOT a separate heartbeat-file here — the file +
|
|
10
|
+
* pid (Heartbeat.ts / isProcessAlive) is for cross-restart interrupted
|
|
11
|
+
* detection (phase C). This pinger is the live "still working" UI signal only.
|
|
12
|
+
*
|
|
13
|
+
* Lifecycle (anti-leak): single timer, stored + cleared; `unref()` so it never
|
|
14
|
+
* pins the process open; `start()` idempotent; self-stops emitting when no
|
|
15
|
+
* agent runs but keeps the (unref'd) tick cheap. Mirrors the proven
|
|
16
|
+
* Heartbeat.ts / chat-session-manager sweeper pattern.
|
|
17
|
+
*/
|
|
18
|
+
import { asyncAgentRegistry } from "./agent-registry.js";
|
|
19
|
+
import { agentNotificationBus } from "./agent-notifications.js";
|
|
20
|
+
/** Default 30s — user-chosen. Stale threshold downstream is 3× (90s). */
|
|
21
|
+
export const DEFAULT_HEARTBEAT_INTERVAL_MS = 30_000;
|
|
22
|
+
export class AgentHeartbeatPinger {
|
|
23
|
+
intervalMs;
|
|
24
|
+
publish;
|
|
25
|
+
now;
|
|
26
|
+
timer = null;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.intervalMs = config.intervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
|
|
29
|
+
this.publish = config.publish;
|
|
30
|
+
this.now = config.now ?? Date.now;
|
|
31
|
+
}
|
|
32
|
+
/** Begin periodic heartbeats. Idempotent — a second call is a no-op. */
|
|
33
|
+
start() {
|
|
34
|
+
if (this.timer)
|
|
35
|
+
return;
|
|
36
|
+
this.timer = setInterval(() => this.tick(), this.intervalMs);
|
|
37
|
+
// Never keep the process alive just for heartbeats.
|
|
38
|
+
if (typeof this.timer === "object" && "unref" in this.timer) {
|
|
39
|
+
this.timer.unref();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
stop() {
|
|
43
|
+
if (this.timer) {
|
|
44
|
+
clearInterval(this.timer);
|
|
45
|
+
this.timer = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** One heartbeat cycle: group running agents by session and publish. */
|
|
49
|
+
tick() {
|
|
50
|
+
const running = asyncAgentRegistry.getSnapshot().filter((e) => e.status === "running");
|
|
51
|
+
if (running.length === 0) {
|
|
52
|
+
// Nothing left to ping — self-stop so the timer doesn't tick forever
|
|
53
|
+
// after the last background agent finishes. start() re-arms on the next
|
|
54
|
+
// handoff. (Idempotent stop.)
|
|
55
|
+
this.stop();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const bySession = new Map();
|
|
59
|
+
for (const e of running) {
|
|
60
|
+
// Background agents always carry their spawning sessionId; skip any
|
|
61
|
+
// legacy/ad-hoc entry without one (can't address a heartbeat to nobody).
|
|
62
|
+
if (!e.sessionId)
|
|
63
|
+
continue;
|
|
64
|
+
const list = bySession.get(e.sessionId);
|
|
65
|
+
if (list)
|
|
66
|
+
list.push(e.agentId);
|
|
67
|
+
else
|
|
68
|
+
bySession.set(e.sessionId, [e.agentId]);
|
|
69
|
+
}
|
|
70
|
+
const ts = this.now();
|
|
71
|
+
for (const [sessionId, agentIds] of bySession) {
|
|
72
|
+
this.publish(sessionId, { type: "agent_heartbeat", agentIds, ts });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Process-wide pinger that publishes to the agentNotificationBus (the same
|
|
78
|
+
* channel background-agent completions use → the protocol server forwards each
|
|
79
|
+
* event to the client). `ensureRunning()` is called when an agent backgrounds;
|
|
80
|
+
* the pinger self-stops once no agent is running, so a fresh handoff re-arms it.
|
|
81
|
+
*/
|
|
82
|
+
export const agentHeartbeatPinger = new AgentHeartbeatPinger({
|
|
83
|
+
publish: (sessionId, event) => agentNotificationBus.publish(sessionId, event),
|
|
84
|
+
});
|
|
85
|
+
/** Start the shared pinger if not already ticking (idempotent). Call when an
|
|
86
|
+
* agent enters the background. */
|
|
87
|
+
export function ensureAgentHeartbeat() {
|
|
88
|
+
agentHeartbeatPinger.start();
|
|
89
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BackgroundAgentCompletedEvent } from "../../types.js";
|
|
1
|
+
import type { BackgroundAgentCompletedEvent, StreamEvent } from "../../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Background-agent completion notification queue.
|
|
4
4
|
*
|
|
@@ -30,8 +30,17 @@ export type NotificationItem = {
|
|
|
30
30
|
name?: string;
|
|
31
31
|
description: string;
|
|
32
32
|
status: "completed" | "failed";
|
|
33
|
+
/** What kind of background work this was (lets UIs localize the toast). */
|
|
34
|
+
workKind?: "agent" | "shell" | "video" | "cc";
|
|
35
|
+
/** For workKind === "shell": the command that ran. */
|
|
36
|
+
command?: string;
|
|
33
37
|
/** Final assistant text (completed only). */
|
|
34
38
|
finalText?: string;
|
|
39
|
+
/** For workKind === "cc": the external claude session id this drove, so the
|
|
40
|
+
* result is recoverable from ~/.claude/projects/.../<ccSessionId>.jsonl even
|
|
41
|
+
* if this notification is lost, and the user sees a real session id (not just
|
|
42
|
+
* an opaque background jobId). */
|
|
43
|
+
ccSessionId?: string;
|
|
35
44
|
/** Error message (failed only). */
|
|
36
45
|
error?: string;
|
|
37
46
|
enqueuedAt: number;
|
|
@@ -53,10 +62,10 @@ declare class NotificationQueue {
|
|
|
53
62
|
private notify;
|
|
54
63
|
}
|
|
55
64
|
export declare const notificationQueue: NotificationQueue;
|
|
56
|
-
type BusHandler = (sessionId: string, event:
|
|
65
|
+
type BusHandler = (sessionId: string, event: StreamEvent) => void;
|
|
57
66
|
declare class AgentNotificationBus {
|
|
58
67
|
private handlers;
|
|
59
|
-
publish(sessionId: string, event:
|
|
68
|
+
publish(sessionId: string, event: StreamEvent): void;
|
|
60
69
|
subscribe(handler: BusHandler): () => void;
|
|
61
70
|
}
|
|
62
71
|
export declare const agentNotificationBus: AgentNotificationBus;
|
|
@@ -94,8 +94,7 @@ class AgentNotificationBus {
|
|
|
94
94
|
// Mirrors NotificationQueue.enqueue — refuse undefined / "" so the
|
|
95
95
|
// server-side subscriber never has to defend against it.
|
|
96
96
|
logger.warn("agent_notification_bus.invalid_session_id", {
|
|
97
|
-
|
|
98
|
-
status: event.status,
|
|
97
|
+
eventType: event.type,
|
|
99
98
|
sessionIdType: typeof sessionId,
|
|
100
99
|
});
|
|
101
100
|
return;
|
|
@@ -132,6 +131,10 @@ export function notificationItemToStreamEvent(item) {
|
|
|
132
131
|
};
|
|
133
132
|
if (item.name !== undefined)
|
|
134
133
|
event.name = item.name;
|
|
134
|
+
if (item.workKind !== undefined)
|
|
135
|
+
event.workKind = item.workKind;
|
|
136
|
+
if (item.command !== undefined)
|
|
137
|
+
event.command = item.command;
|
|
135
138
|
if (item.finalText !== undefined)
|
|
136
139
|
event.finalText = item.finalText;
|
|
137
140
|
if (item.error !== undefined)
|
|
@@ -163,7 +166,10 @@ export function buildNotificationMessage(items) {
|
|
|
163
166
|
const agents = items
|
|
164
167
|
.map((item) => {
|
|
165
168
|
const nameAttr = item.name ? ` name="${escapeXmlAttr(item.name)}"` : "";
|
|
166
|
-
|
|
169
|
+
// For DriveClaudeCode jobs, expose the real claude session id so the model
|
|
170
|
+
// can cite it / recover the full result from disk if needed.
|
|
171
|
+
const ccAttr = item.ccSessionId ? ` ccSessionId="${escapeXmlAttr(item.ccSessionId)}"` : "";
|
|
172
|
+
const opening = ` <agent id="${escapeXmlAttr(item.agentId)}"${nameAttr} status="${item.status}"${ccAttr}>`;
|
|
167
173
|
const desc = ` <description>${escapeXmlText(item.description)}</description>`;
|
|
168
174
|
const body = item.status === "completed"
|
|
169
175
|
? ` <result>\n${escapeXmlText(item.finalText ?? "")}\n </result>`
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background-agent output files. When an async (run_in_background) agent
|
|
3
|
+
* finishes, we mirror its final text to `~/.code-shell/agents/<agentId>.txt`
|
|
4
|
+
* so it can be tailed from outside the process or read back in a later session
|
|
5
|
+
* — the notificationQueue re-injection remains the PRIMARY path that feeds the
|
|
6
|
+
* result to the parent agent; this file is just an external-readable copy.
|
|
7
|
+
*
|
|
8
|
+
* All writes are best-effort: a failure here must never break the agent
|
|
9
|
+
* completion path, so callers fire-and-forget and we swallow errors (logging
|
|
10
|
+
* via the provided logger when present).
|
|
11
|
+
*/
|
|
12
|
+
/** Directory holding per-agent output files. */
|
|
13
|
+
export declare function agentOutputDir(): string;
|
|
14
|
+
/** Absolute path of a given agent's output file. */
|
|
15
|
+
export declare function agentOutputPath(agentId: string): string;
|
|
16
|
+
interface WriteOpts {
|
|
17
|
+
status: "completed" | "failed";
|
|
18
|
+
/** Final text (completed) or error message (failed). */
|
|
19
|
+
body: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
/** Optional logger.warn for swallowed errors. */
|
|
23
|
+
onError?: (msg: string, meta: Record<string, unknown>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Write (overwrite) an agent's output file. Best-effort: resolves even on
|
|
27
|
+
* failure. The body is prefixed with a small header so a human tailing the
|
|
28
|
+
* file sees what it is.
|
|
29
|
+
*/
|
|
30
|
+
export declare function writeAgentOutputFile(agentId: string, opts: WriteOpts): Promise<void>;
|
|
31
|
+
/** Delete a single agent's output file (best-effort). */
|
|
32
|
+
export declare function removeAgentOutputFile(agentId: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Remove every agent output file. Called on app exit / full registry reset so
|
|
35
|
+
* the directory doesn't accumulate stale files across runs.
|
|
36
|
+
*/
|
|
37
|
+
export declare function clearAgentOutputFiles(): Promise<void>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background-agent output files. When an async (run_in_background) agent
|
|
3
|
+
* finishes, we mirror its final text to `~/.code-shell/agents/<agentId>.txt`
|
|
4
|
+
* so it can be tailed from outside the process or read back in a later session
|
|
5
|
+
* — the notificationQueue re-injection remains the PRIMARY path that feeds the
|
|
6
|
+
* result to the parent agent; this file is just an external-readable copy.
|
|
7
|
+
*
|
|
8
|
+
* All writes are best-effort: a failure here must never break the agent
|
|
9
|
+
* completion path, so callers fire-and-forget and we swallow errors (logging
|
|
10
|
+
* via the provided logger when present).
|
|
11
|
+
*/
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { mkdir, writeFile, rm, readdir } from "node:fs/promises";
|
|
14
|
+
import { userHome } from "../../settings/manager.js";
|
|
15
|
+
/** Directory holding per-agent output files. */
|
|
16
|
+
export function agentOutputDir() {
|
|
17
|
+
return join(userHome(), ".code-shell", "agents");
|
|
18
|
+
}
|
|
19
|
+
/** Absolute path of a given agent's output file. */
|
|
20
|
+
export function agentOutputPath(agentId) {
|
|
21
|
+
// agentId is internally generated (`agent-<n>` / uuid-ish) — no separators —
|
|
22
|
+
// but guard anyway so a hostile id can't escape the directory.
|
|
23
|
+
const safe = agentId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
24
|
+
return join(agentOutputDir(), `${safe}.txt`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Write (overwrite) an agent's output file. Best-effort: resolves even on
|
|
28
|
+
* failure. The body is prefixed with a small header so a human tailing the
|
|
29
|
+
* file sees what it is.
|
|
30
|
+
*/
|
|
31
|
+
export async function writeAgentOutputFile(agentId, opts) {
|
|
32
|
+
try {
|
|
33
|
+
await mkdir(agentOutputDir(), { recursive: true });
|
|
34
|
+
const header = `# agent ${agentId}` +
|
|
35
|
+
(opts.name ? ` (${opts.name})` : "") +
|
|
36
|
+
`\n# status: ${opts.status}` +
|
|
37
|
+
(opts.description ? `\n# task: ${opts.description}` : "") +
|
|
38
|
+
`\n\n`;
|
|
39
|
+
await writeFile(agentOutputPath(agentId), header + (opts.body ?? ""), "utf8");
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
opts.onError?.("agent_output_file_write_failed", {
|
|
43
|
+
agentId,
|
|
44
|
+
error: String(e instanceof Error ? e.message : e),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Delete a single agent's output file (best-effort). */
|
|
49
|
+
export async function removeAgentOutputFile(agentId) {
|
|
50
|
+
try {
|
|
51
|
+
await rm(agentOutputPath(agentId), { force: true });
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// best-effort
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove every agent output file. Called on app exit / full registry reset so
|
|
59
|
+
* the directory doesn't accumulate stale files across runs.
|
|
60
|
+
*/
|
|
61
|
+
export async function clearAgentOutputFiles() {
|
|
62
|
+
try {
|
|
63
|
+
const dir = agentOutputDir();
|
|
64
|
+
const names = await readdir(dir);
|
|
65
|
+
await Promise.all(names
|
|
66
|
+
.filter((n) => n.endsWith(".txt"))
|
|
67
|
+
.map((n) => rm(join(dir, n), { force: true })));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// dir may not exist yet — fine
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -29,7 +29,21 @@ export interface AsyncAgentEntry {
|
|
|
29
29
|
agentId: string;
|
|
30
30
|
/** Short kind label shown in the dock (e.g. "Explore", "Plan"). */
|
|
31
31
|
name?: string;
|
|
32
|
+
/** Dispatched role (e.g. "general-purpose", "explorer"); shown in the dock
|
|
33
|
+
* so you can see what kind of agent is running. */
|
|
34
|
+
agentType?: string;
|
|
32
35
|
description: string;
|
|
36
|
+
/** Session that spawned this background agent. Lets the spawning
|
|
37
|
+
* Engine.run wait only on ITS OWN background agents (hasRunningForSession),
|
|
38
|
+
* not every concurrent session's. Undefined only for legacy/ad-hoc callers
|
|
39
|
+
* outside Engine.run. */
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
/** The sub-agent's OWN child session id (distinct from the parent
|
|
42
|
+
* `sessionId` above). AgentSendInput resumes this to continue the agent
|
|
43
|
+
* with full transcript replay. With the agent_id===childSid convention
|
|
44
|
+
* this equals `agentId`, but it is stored explicitly so the contract is
|
|
45
|
+
* not coupled to that identity. Undefined for legacy entries. */
|
|
46
|
+
childSessionId?: string;
|
|
33
47
|
status: AsyncAgentStatus;
|
|
34
48
|
startedAt: number;
|
|
35
49
|
finishedAt?: number;
|
|
@@ -46,6 +60,9 @@ declare class AsyncAgentRegistry {
|
|
|
46
60
|
subscribe: (cb: () => void) => (() => void);
|
|
47
61
|
getSnapshot: () => AsyncAgentEntry[];
|
|
48
62
|
hasRunning: () => boolean;
|
|
63
|
+
/** True if any background agent spawned by `sessionId` is still running.
|
|
64
|
+
* Drives Engine.run's "wait for my background agents before resolving". */
|
|
65
|
+
hasRunningForSession: (sessionId: string) => boolean;
|
|
49
66
|
/** Count of agents currently in the "running" state (cap enforcement). */
|
|
50
67
|
runningCount(): number;
|
|
51
68
|
private notify;
|
|
@@ -60,6 +77,12 @@ declare class AsyncAgentRegistry {
|
|
|
60
77
|
touchTranscript(agentId: string): void;
|
|
61
78
|
get(agentId: string): AsyncAgentEntry | undefined;
|
|
62
79
|
list(): AsyncAgentEntry[];
|
|
80
|
+
/**
|
|
81
|
+
* Agents spawned by a given session. Drives AgentStatus's default view so a
|
|
82
|
+
* background-agent listing doesn't surface every concurrent session's agents.
|
|
83
|
+
* Legacy entries with no sessionId are excluded from a session-scoped query.
|
|
84
|
+
*/
|
|
85
|
+
listForSession(sessionId: string): AsyncAgentEntry[];
|
|
63
86
|
private markFinished;
|
|
64
87
|
markCompleted(agentId: string): void;
|
|
65
88
|
markFailed(agentId: string): void;
|
|
@@ -30,6 +30,11 @@ class AsyncAgentRegistry {
|
|
|
30
30
|
hasRunning = () => {
|
|
31
31
|
return this.snapshot.some((e) => e.status === "running");
|
|
32
32
|
};
|
|
33
|
+
/** True if any background agent spawned by `sessionId` is still running.
|
|
34
|
+
* Drives Engine.run's "wait for my background agents before resolving". */
|
|
35
|
+
hasRunningForSession = (sessionId) => {
|
|
36
|
+
return this.snapshot.some((e) => e.status === "running" && e.sessionId === sessionId);
|
|
37
|
+
};
|
|
33
38
|
/** Count of agents currently in the "running" state (cap enforcement). */
|
|
34
39
|
runningCount() {
|
|
35
40
|
return this.snapshot.filter((e) => e.status === "running").length;
|
|
@@ -76,6 +81,14 @@ class AsyncAgentRegistry {
|
|
|
76
81
|
list() {
|
|
77
82
|
return [...this.agents.values()];
|
|
78
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Agents spawned by a given session. Drives AgentStatus's default view so a
|
|
86
|
+
* background-agent listing doesn't surface every concurrent session's agents.
|
|
87
|
+
* Legacy entries with no sessionId are excluded from a session-scoped query.
|
|
88
|
+
*/
|
|
89
|
+
listForSession(sessionId) {
|
|
90
|
+
return [...this.agents.values()].filter((e) => e.sessionId === sessionId);
|
|
91
|
+
}
|
|
79
92
|
markFinished(agentId, status) {
|
|
80
93
|
const e = this.agents.get(agentId);
|
|
81
94
|
if (!e)
|
|
@@ -108,10 +121,9 @@ class AsyncAgentRegistry {
|
|
|
108
121
|
catch {
|
|
109
122
|
// ignore abort errors — we still mark cancelled
|
|
110
123
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.notify();
|
|
124
|
+
// Reuse markFinished for the status/timestamp/notify bookkeeping rather
|
|
125
|
+
// than duplicating it (the entry is still "running" after abort()).
|
|
126
|
+
this.markFinished(agentId, "cancelled");
|
|
115
127
|
return true;
|
|
116
128
|
}
|
|
117
129
|
reset() {
|
|
@@ -9,19 +9,64 @@
|
|
|
9
9
|
import type { ToolDefinition } from "../../types.js";
|
|
10
10
|
import type { ToolContext } from "../context.js";
|
|
11
11
|
import type { AgentDefinitionRegistry } from "../../agent/agent-definition-registry.js";
|
|
12
|
+
import type { AgentDefinition } from "../../agent/agent-definition.js";
|
|
12
13
|
import type { HookRegistry } from "../../hooks/registry.js";
|
|
13
14
|
export interface AgentTypeOverrides {
|
|
15
|
+
resolvedType?: string;
|
|
14
16
|
model?: string;
|
|
15
17
|
maxTurns?: number;
|
|
16
18
|
toolAllowlist?: string[];
|
|
19
|
+
skillAllowlist?: string[];
|
|
17
20
|
appendSystemPrompt?: string;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Resolve an `agent_type` against the role registry into spawn overrides.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
24
|
+
*
|
|
25
|
+
* - Omitted type + non-empty registry → fall back to a configured role
|
|
26
|
+
* ("general-purpose" if present, else the first available) instead of
|
|
27
|
+
* running a nameless ephemeral agent. Relaxed from the earlier "throw when
|
|
28
|
+
* agent_type omitted": the model habitually omits it, and a hard error just
|
|
29
|
+
* turned every spawn into a failure. Falling back to a real role keeps the
|
|
30
|
+
* tool-allowlist / system-prompt benefits without breaking the call.
|
|
31
|
+
* - Omitted type + empty registry → empty overrides (true ephemeral; nothing
|
|
32
|
+
* to fall back to).
|
|
33
|
+
* - Unknown explicit type → throw, so the LLM gets a clear correction rather
|
|
34
|
+
* than silently running a generic agent.
|
|
23
35
|
*/
|
|
24
36
|
export declare function resolveAgentTypeOverrides(agentType: string | undefined, registry: AgentDefinitionRegistry | undefined): AgentTypeOverrides;
|
|
37
|
+
/**
|
|
38
|
+
* A plugin-bundled agent's frontmatter lists its own skills by BARE name
|
|
39
|
+
* (`skills: director-skill`), matching Claude Code's convention where a
|
|
40
|
+
* plugin agent references same-plugin skills unqualified. But the skill
|
|
41
|
+
* scanner registers plugin skills under their NAMESPACED name
|
|
42
|
+
* (`mimi-video:director-skill`), and the allowlist filter is an exact match —
|
|
43
|
+
* so a bare entry never matches and the sub-agent reports the skill "not
|
|
44
|
+
* found", forcing it to fall back to reading SKILL.md by hand.
|
|
45
|
+
*
|
|
46
|
+
* Bridge the two conventions: for a plugin-source agent, rewrite each bare
|
|
47
|
+
* skill name to `<pluginName>:<skill>`. Names that already carry a namespace
|
|
48
|
+
* (contain ":") are left untouched, so an agent may still reference another
|
|
49
|
+
* plugin's skill explicitly. undefined (inherit full pool) and [] (no skills)
|
|
50
|
+
* pass through unchanged. Non-plugin agents are never rewritten.
|
|
51
|
+
*/
|
|
52
|
+
export declare function namespacePluginSkills(skills: string[] | undefined, source: AgentDefinition["source"], pluginName: string | undefined): string[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Render the "Available agent types" block injected into the Agent tool's
|
|
55
|
+
* description, listing the roles defined in .code-shell/agents/*.md so the
|
|
56
|
+
* model knows it can pass `agent_type` instead of hand-rolling an ad-hoc
|
|
57
|
+
* agent. Without this the model never sees the registry (it lives per-engine,
|
|
58
|
+
* not in the static tool def) and falls back to nameless ephemeral agents —
|
|
59
|
+
* see the Core A/B/C incident. Returns "" when no roles are defined, so the
|
|
60
|
+
* base description is left untouched.
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildAgentTypesBlock(registry: AgentDefinitionRegistry | undefined): string;
|
|
63
|
+
/**
|
|
64
|
+
* Produce an Agent tool definition whose description ends with the live
|
|
65
|
+
* available-agent-types listing. Pure: takes the registry, returns a new def
|
|
66
|
+
* (the base `agentToolDef` const is never mutated). When no roles exist the
|
|
67
|
+
* base def is returned unchanged.
|
|
68
|
+
*/
|
|
69
|
+
export declare function agentToolDefWithTypes(registry: AgentDefinitionRegistry | undefined): ToolDefinition;
|
|
25
70
|
type SubAgentLifecycle = "subagent_start" | "subagent_finish" | "subagent_error";
|
|
26
71
|
/**
|
|
27
72
|
* Emit a sub-agent lifecycle event via the existing `notification` hook,
|
|
@@ -35,18 +80,12 @@ export declare function emitSubAgentHook(hooks: HookRegistry | undefined, kind:
|
|
|
35
80
|
text?: string;
|
|
36
81
|
error?: string;
|
|
37
82
|
}): void;
|
|
38
|
-
/** Default per-sub-agent wall-clock timeout (5 minutes). */
|
|
39
|
-
export declare const DEFAULT_SUBAGENT_TIMEOUT_MS: number;
|
|
40
|
-
/**
|
|
41
|
-
* Run `work()` with a timeout. On expiry, calls `onTimeout` (to abort the
|
|
42
|
-
* child) and rejects with a timeout error. The child's own abort handling
|
|
43
|
-
* unwinds its resources.
|
|
44
|
-
*/
|
|
45
|
-
export declare function runWithTimeout<T>(work: () => Promise<T>, timeoutMs: number, onTimeout: () => void): Promise<T>;
|
|
46
83
|
export declare const agentToolDef: ToolDefinition;
|
|
47
84
|
export declare function agentTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
48
85
|
export declare const agentStatusToolDef: ToolDefinition;
|
|
49
|
-
export declare function agentStatusTool(args: Record<string, unknown
|
|
86
|
+
export declare function agentStatusTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
50
87
|
export declare const agentCancelToolDef: ToolDefinition;
|
|
51
88
|
export declare function agentCancelTool(args: Record<string, unknown>): Promise<string>;
|
|
89
|
+
export declare const agentSendInputToolDef: ToolDefinition;
|
|
90
|
+
export declare function agentSendInputTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
52
91
|
export {};
|