@cjhyy/code-shell-core 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -23
- package/dist/agent/agent-definition-registry.d.ts +2 -2
- package/dist/agent/agent-definition-registry.js +47 -10
- package/dist/agent/agent-definition.d.ts +5 -0
- package/dist/agent/agent-definition.js +14 -0
- package/dist/automation/index.d.ts +7 -4
- package/dist/automation/index.js +4 -2
- package/dist/automation/runner.js +3 -1
- package/dist/automation/scheduler.d.ts +57 -1
- package/dist/automation/scheduler.js +123 -23
- package/dist/automation/store.d.ts +6 -2
- package/dist/automation/store.js +7 -3
- package/dist/capabilities/index.d.ts +109 -0
- package/dist/capabilities/index.js +80 -0
- package/dist/capability-control/disabled-lists.d.ts +2 -1
- package/dist/capability-control/disabled-lists.js +3 -5
- package/dist/capability-control/overlay.d.ts +14 -1
- package/dist/capability-control/overlay.js +40 -0
- package/dist/capability-control/service.js +6 -4
- package/dist/cli/agent-server-stdio.d.ts +1 -1
- package/dist/cli/agent-server-stdio.js +66 -6
- package/dist/cli/agent-server-tcp.js +20 -5
- package/dist/context/compaction.d.ts +39 -3
- package/dist/context/compaction.js +151 -39
- package/dist/context/manager.d.ts +20 -4
- package/dist/context/manager.js +42 -7
- package/dist/context/token-counter.js +5 -3
- package/dist/context/tool-result-storage.d.ts +6 -0
- package/dist/context/tool-result-storage.js +25 -4
- package/dist/credentials/access.d.ts +13 -2
- package/dist/credentials/access.js +99 -4
- package/dist/credentials/index.d.ts +3 -2
- package/dist/credentials/index.js +2 -1
- package/dist/credentials/oauth.d.ts +9 -1
- package/dist/credentials/oauth.js +80 -1
- package/dist/credentials/store.d.ts +16 -2
- package/dist/credentials/store.js +33 -11
- package/dist/credentials/types.d.ts +62 -1
- package/dist/credentials/types.js +16 -1
- package/dist/credentials/use-credential-tool.js +15 -1
- package/dist/engine/auxiliary-pipeline.d.ts +40 -0
- package/dist/engine/auxiliary-pipeline.js +181 -0
- package/dist/{settings → engine}/disk-defaults.d.ts +2 -2
- package/dist/{settings → engine}/disk-defaults.js +5 -2
- package/dist/engine/dynamic-tool-defs.d.ts +4 -0
- package/dist/engine/dynamic-tool-defs.js +4 -0
- package/dist/engine/engine.d.ts +272 -184
- package/dist/engine/engine.js +1869 -1864
- package/dist/engine/file-history-hook.d.ts +11 -0
- package/dist/engine/file-history-hook.js +31 -0
- package/dist/engine/goal-judge-context.d.ts +9 -0
- package/dist/engine/goal-judge-context.js +234 -0
- package/dist/engine/injected-context-cache.d.ts +6 -0
- package/dist/engine/injected-context-cache.js +13 -0
- package/dist/engine/input-attachments.d.ts +1 -1
- package/dist/engine/model-facade.d.ts +3 -3
- package/dist/engine/model-facade.js +15 -14
- package/dist/engine/permission-controller.d.ts +55 -0
- package/dist/engine/permission-controller.js +148 -0
- package/dist/engine/prompt-cache-diagnostics.d.ts +58 -0
- package/dist/engine/prompt-cache-diagnostics.js +178 -0
- package/dist/engine/run-accounting.d.ts +41 -0
- package/dist/engine/run-accounting.js +126 -0
- package/dist/engine/run-context.d.ts +44 -0
- package/dist/engine/run-context.js +88 -0
- package/dist/engine/run-environment.d.ts +30 -0
- package/dist/engine/run-environment.js +77 -0
- package/dist/engine/run-finalize.d.ts +58 -0
- package/dist/engine/run-finalize.js +245 -0
- package/dist/engine/run-goal.d.ts +58 -0
- package/dist/engine/run-goal.js +188 -0
- package/dist/engine/run-image-input.d.ts +1 -1
- package/dist/engine/run-image-input.js +5 -3
- package/dist/engine/run-session-open.d.ts +41 -0
- package/dist/engine/run-session-open.js +186 -0
- package/dist/engine/run-setup.d.ts +42 -0
- package/dist/engine/run-setup.js +58 -0
- package/dist/engine/run-tooling.d.ts +125 -0
- package/dist/engine/run-tooling.js +283 -0
- package/dist/engine/run-types.d.ts +139 -0
- package/dist/engine/run-types.js +12 -0
- package/dist/engine/run-workspace.d.ts +50 -0
- package/dist/engine/run-workspace.js +114 -0
- package/dist/engine/session-title.d.ts +2 -1
- package/dist/engine/session-title.js +4 -1
- package/dist/engine/steer-queue.d.ts +1 -1
- package/dist/engine/subagent-spawner.d.ts +32 -0
- package/dist/engine/subagent-spawner.js +287 -0
- package/dist/engine/tool-summary.d.ts +2 -2
- package/dist/engine/tool-summary.js +2 -2
- package/dist/engine/turn-loop.d.ts +67 -10
- package/dist/engine/turn-loop.js +538 -97
- package/dist/engine/types.d.ts +35 -4
- package/dist/engine/types.js +1 -1
- package/dist/{engine/goal.d.ts → goal/lifecycle.d.ts} +80 -6
- package/dist/goal/lifecycle.js +482 -0
- package/dist/hooks/events.d.ts +26 -9
- package/dist/hooks/events.js +0 -3
- package/dist/hooks/goal-stop-hook.d.ts +28 -29
- package/dist/hooks/goal-stop-hook.js +344 -144
- package/dist/hooks/registry.js +4 -1
- package/dist/hooks/shell-runner.d.ts +12 -1
- package/dist/hooks/shell-runner.js +160 -9
- package/dist/index.d.ts +51 -110
- package/dist/index.extension.d.ts +51 -0
- package/dist/index.extension.js +39 -0
- package/dist/index.internal.d.ts +86 -0
- package/dist/index.internal.js +92 -0
- package/dist/index.js +37 -125
- package/dist/links/cli.d.ts +48 -0
- package/dist/links/cli.js +617 -0
- package/dist/links/http.d.ts +40 -0
- package/dist/links/http.js +166 -0
- package/dist/links/index.d.ts +4 -0
- package/dist/links/index.js +3 -0
- package/dist/links/link-action-tool.d.ts +5 -0
- package/dist/links/link-action-tool.js +241 -0
- package/dist/links/providers.d.ts +8 -0
- package/dist/links/providers.js +665 -0
- package/dist/links/types.d.ts +44 -0
- package/dist/llm/client-base.d.ts +7 -0
- package/dist/llm/client-base.js +72 -10
- package/dist/llm/model-pool.d.ts +1 -1
- package/dist/llm/model-pool.js +1 -1
- package/dist/llm/providers/anthropic.d.ts +1 -0
- package/dist/llm/providers/anthropic.js +9 -0
- package/dist/llm/providers/openai.d.ts +1 -0
- package/dist/llm/providers/openai.js +17 -0
- package/dist/llm/types.d.ts +12 -5
- package/dist/model-catalog/index.js +15 -2
- package/dist/model-catalog/resolve.d.ts +13 -1
- package/dist/model-catalog/resolve.js +37 -2
- package/dist/model-catalog/types.d.ts +74 -48
- package/dist/model-catalog/types.js +16 -5
- package/dist/model-catalog/upsert.d.ts +3 -1
- package/dist/model-catalog/upsert.js +9 -0
- package/dist/onboarding.d.ts +0 -1
- package/dist/onboarding.js +1 -22
- package/dist/panel-apps/bindings.d.ts +24 -0
- package/dist/panel-apps/bindings.js +69 -0
- package/dist/panel-apps/github-archive.d.ts +21 -0
- package/dist/panel-apps/github-archive.js +98 -0
- package/dist/panel-apps/index.d.ts +4 -0
- package/dist/panel-apps/index.js +4 -0
- package/dist/panel-apps/installer.d.ts +68 -0
- package/dist/panel-apps/installer.js +622 -0
- package/dist/panel-apps/manifest.d.ts +364 -0
- package/dist/panel-apps/manifest.js +189 -0
- package/dist/panel-apps/paths.d.ts +13 -0
- package/dist/panel-apps/paths.js +38 -0
- package/dist/panel-apps/registry.d.ts +51 -0
- package/dist/panel-apps/registry.js +99 -0
- package/dist/panel-apps/runtime.d.ts +80 -0
- package/dist/panel-apps/runtime.js +154 -0
- package/dist/plugins/gitOps.js +8 -1
- package/dist/plugins/installedPlugins.d.ts +2 -1
- package/dist/plugins/installedPlugins.js +146 -8
- package/dist/plugins/installer/codex/convertAgents.d.ts +4 -1
- package/dist/plugins/installer/codex/convertAgents.js +62 -8
- package/dist/plugins/installer/codex/convertCommands.d.ts +5 -5
- package/dist/plugins/installer/codex/convertCommands.js +35 -12
- package/dist/plugins/installer/codex/convertHooks.d.ts +10 -0
- package/dist/plugins/installer/codex/convertHooks.js +82 -0
- package/dist/plugins/installer/codex/convertSkills.js +41 -6
- package/dist/plugins/installer/install.d.ts +7 -1
- package/dist/plugins/installer/install.js +21 -87
- package/dist/plugins/installer/installFromArchive.d.ts +26 -4
- package/dist/plugins/installer/installFromArchive.js +44 -27
- package/dist/plugins/installer/installFromNpm.d.ts +31 -0
- package/dist/plugins/installer/installFromNpm.js +273 -0
- package/dist/plugins/installer/loadPluginAgents.js +17 -4
- package/dist/plugins/installer/loadPluginMcp.d.ts +14 -0
- package/dist/plugins/installer/loadPluginMcp.js +245 -35
- package/dist/plugins/installer/normalizeManifest.d.ts +13 -0
- package/dist/plugins/installer/normalizeManifest.js +306 -0
- package/dist/plugins/installer/npmTar.d.ts +13 -0
- package/dist/plugins/installer/npmTar.js +321 -0
- package/dist/plugins/installer/parseSource.d.ts +11 -0
- package/dist/plugins/installer/parseSource.js +48 -0
- package/dist/plugins/installer/preview.d.ts +101 -0
- package/dist/plugins/installer/preview.js +336 -0
- package/dist/plugins/installer/projectPluginSource.d.ts +14 -0
- package/dist/plugins/installer/projectPluginSource.js +140 -0
- package/dist/plugins/installer/types.d.ts +775 -0
- package/dist/plugins/installer/types.js +100 -0
- package/dist/plugins/installer/unzip.d.ts +11 -0
- package/dist/plugins/installer/unzip.js +123 -9
- package/dist/plugins/installer/update.d.ts +2 -2
- package/dist/plugins/installer/update.js +43 -4
- package/dist/plugins/loadPluginHooks.d.ts +19 -2
- package/dist/plugins/loadPluginHooks.js +97 -86
- package/dist/plugins/pluginAutomationTemplates.d.ts +18 -0
- package/dist/plugins/pluginAutomationTemplates.js +50 -0
- package/dist/plugins/pluginCatalog.d.ts +45 -0
- package/dist/plugins/pluginCatalog.js +87 -0
- package/dist/plugins/pluginCommandHook.d.ts +10 -4
- package/dist/plugins/pluginCommandHook.js +133 -18
- package/dist/plugins/pluginCommandsLoader.d.ts +19 -0
- package/dist/plugins/pluginCommandsLoader.js +181 -7
- package/dist/plugins/pluginContent.d.ts +10 -1
- package/dist/plugins/pluginContent.js +87 -30
- package/dist/plugins/pluginHookApproval.d.ts +30 -0
- package/dist/plugins/pluginHookApproval.js +160 -0
- package/dist/plugins/pluginHookIntegrity.d.ts +69 -0
- package/dist/plugins/pluginHookIntegrity.js +361 -0
- package/dist/plugins/pluginInstaller.js +71 -12
- package/dist/plugins/pluginMcpApproval.d.ts +19 -0
- package/dist/plugins/pluginMcpApproval.js +110 -0
- package/dist/plugins/pluginMcpIntegrity.d.ts +21 -0
- package/dist/plugins/pluginMcpIntegrity.js +74 -0
- package/dist/plugins/types.d.ts +30 -0
- package/dist/plugins/varRewrite.d.ts +9 -5
- package/dist/plugins/varRewrite.js +26 -17
- package/dist/preset/index.d.ts +11 -8
- package/dist/preset/index.js +62 -203
- package/dist/product/define.js +9 -3
- package/dist/product/types.d.ts +0 -2
- package/dist/profile/activation.d.ts +36 -0
- package/dist/profile/activation.js +57 -0
- package/dist/profile/catalog-store.d.ts +77 -0
- package/dist/profile/catalog-store.js +346 -0
- package/dist/profile/catalog.d.ts +54 -0
- package/dist/profile/catalog.js +152 -0
- package/dist/profile/index.d.ts +7 -0
- package/dist/profile/index.js +7 -0
- package/dist/profile/requirements.d.ts +76 -0
- package/dist/profile/requirements.js +117 -0
- package/dist/profile/resolve.d.ts +11 -0
- package/dist/profile/resolve.js +41 -0
- package/dist/profile/store.d.ts +17 -0
- package/dist/profile/store.js +167 -0
- package/dist/profile/types.d.ts +321 -0
- package/dist/profile/types.js +104 -0
- package/dist/prompt/composer.d.ts +46 -7
- package/dist/prompt/composer.js +78 -48
- package/dist/prompt/instruction-scanner.d.ts +6 -5
- package/dist/prompt/instruction-scanner.js +8 -23
- package/dist/prompt/section-loader.d.ts +2 -2
- package/dist/prompt/section-loader.js +7 -4
- package/dist/prompt/sections/browser.md +10 -9
- package/dist/prompt/sections/harness-base.md +9 -0
- package/dist/protocol/chat-session-manager.d.ts +77 -3
- package/dist/protocol/chat-session-manager.js +194 -18
- package/dist/protocol/chat-session.d.ts +72 -9
- package/dist/protocol/chat-session.js +151 -16
- package/dist/protocol/client.d.ts +37 -4
- package/dist/protocol/client.js +118 -6
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +2 -2
- package/dist/protocol/mobile-remote-types.d.ts +406 -0
- package/dist/protocol/mobile-remote-types.js +1 -0
- package/dist/protocol/server.d.ts +152 -14
- package/dist/protocol/server.js +1574 -229
- package/dist/protocol/types.d.ts +182 -32
- package/dist/protocol/types.js +18 -0
- package/dist/run/ArtifactTracker.d.ts +6 -1
- package/dist/run/ArtifactTracker.js +29 -21
- package/dist/run/EngineRunner.d.ts +2 -0
- package/dist/run/EngineRunner.js +1 -0
- package/dist/run/RunManager.d.ts +26 -0
- package/dist/run/RunManager.js +82 -11
- package/dist/run/factory.d.ts +3 -0
- package/dist/run/factory.js +2 -0
- package/dist/runtime/safe-spawn.d.ts +6 -0
- package/dist/runtime/safe-spawn.js +8 -13
- package/dist/services/auto-dream.d.ts +13 -1
- package/dist/services/auto-dream.js +56 -8
- package/dist/services/dream-consolidation.d.ts +3 -0
- package/dist/services/dream-consolidation.js +14 -2
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/memory-orchestrator.js +6 -2
- package/dist/services/oauth.d.ts +34 -10
- package/dist/services/oauth.js +236 -98
- package/dist/services/session-memory.d.ts +4 -4
- package/dist/services/session-memory.js +13 -10
- package/dist/session/memory.d.ts +26 -7
- package/dist/session/memory.js +79 -21
- package/dist/session/session-manager.d.ts +208 -25
- package/dist/session/session-manager.js +1232 -116
- package/dist/session/session-message.d.ts +22 -0
- package/dist/session/session-message.js +1 -0
- package/dist/session/transcript.d.ts +76 -6
- package/dist/session/transcript.js +278 -7
- package/dist/settings/feature-flags.d.ts +40 -0
- package/dist/settings/feature-flags.js +40 -0
- package/dist/settings/manager.d.ts +39 -1
- package/dist/settings/manager.js +102 -41
- package/dist/settings/migrate-config.js +4 -2
- package/dist/settings/schema.d.ts +511 -177
- package/dist/settings/schema.js +98 -25
- package/dist/skills/scanner.d.ts +6 -2
- package/dist/skills/scanner.js +160 -9
- package/dist/sources/adapter.d.ts +14 -0
- package/dist/sources/adapter.js +7 -0
- package/dist/sources/adapters/local-files.d.ts +10 -0
- package/dist/sources/adapters/local-files.js +127 -0
- package/dist/sources/adapters/mcp-resource.d.ts +17 -0
- package/dist/sources/adapters/mcp-resource.js +41 -0
- package/dist/sources/adapters/mock.d.ts +3 -0
- package/dist/sources/adapters/mock.js +29 -0
- package/dist/sources/binding.d.ts +6 -0
- package/dist/sources/binding.js +24 -0
- package/dist/sources/catalog.d.ts +6 -0
- package/dist/sources/catalog.js +64 -0
- package/dist/sources/context-summary.d.ts +8 -0
- package/dist/sources/context-summary.js +13 -0
- package/dist/sources/credential-status.d.ts +2 -0
- package/dist/sources/credential-status.js +13 -0
- package/dist/sources/index.d.ts +10 -0
- package/dist/sources/index.js +10 -0
- package/dist/sources/resolve.d.ts +28 -0
- package/dist/sources/resolve.js +47 -0
- package/dist/sources/truncate-utf8.d.ts +7 -0
- package/dist/sources/truncate-utf8.js +18 -0
- package/dist/sources/types.d.ts +71 -0
- package/dist/sources/types.js +26 -0
- package/dist/testing/fetch-stub.d.ts +32 -0
- package/dist/testing/fetch-stub.js +24 -0
- package/dist/themes/image.d.ts +18 -0
- package/dist/themes/image.js +117 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/installer.d.ts +50 -0
- package/dist/themes/installer.js +290 -0
- package/dist/themes/manifest.d.ts +102 -0
- package/dist/themes/manifest.js +86 -0
- package/dist/themes/paths.d.ts +14 -0
- package/dist/themes/paths.js +33 -0
- package/dist/tool-system/browser-bridge.d.ts +53 -11
- package/dist/tool-system/browser-bridge.js +8 -9
- package/dist/tool-system/builtin/agent-heartbeat.d.ts +2 -2
- package/dist/tool-system/builtin/agent-heartbeat.js +20 -6
- package/dist/tool-system/builtin/agent-notifications.d.ts +127 -72
- package/dist/tool-system/builtin/agent-notifications.js +291 -101
- package/dist/tool-system/builtin/agent-output-file.js +1 -3
- package/dist/tool-system/builtin/agent-progress.d.ts +6 -0
- package/dist/tool-system/builtin/agent-progress.js +83 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +38 -2
- package/dist/tool-system/builtin/agent-registry.js +178 -9
- package/dist/tool-system/builtin/agent-transcript-translator.js +1 -1
- package/dist/tool-system/builtin/agent.d.ts +2 -0
- package/dist/tool-system/builtin/agent.js +279 -34
- package/dist/tool-system/builtin/background-jobs.d.ts +63 -7
- package/dist/tool-system/builtin/background-jobs.js +111 -15
- package/dist/tool-system/builtin/background-work.d.ts +12 -1
- package/dist/tool-system/builtin/background-work.js +12 -1
- package/dist/tool-system/builtin/bash.d.ts +3 -5
- package/dist/tool-system/builtin/bash.js +14 -6
- package/dist/tool-system/builtin/browser-tools.d.ts +8 -5
- package/dist/tool-system/builtin/browser-tools.js +89 -23
- package/dist/tool-system/builtin/edit-model-catalog.d.ts +6 -0
- package/dist/tool-system/builtin/edit-model-catalog.js +172 -12
- package/dist/tool-system/builtin/edit.d.ts +2 -1
- package/dist/tool-system/builtin/edit.js +14 -10
- package/dist/tool-system/builtin/file-cache.d.ts +2 -0
- package/dist/tool-system/builtin/file-cache.js +4 -0
- package/dist/tool-system/builtin/generate-image.js +17 -10
- package/dist/tool-system/builtin/generate-video.d.ts +4 -0
- package/dist/tool-system/builtin/generate-video.js +164 -28
- package/dist/tool-system/builtin/glob.d.ts +2 -1
- package/dist/tool-system/builtin/glob.js +28 -3
- package/dist/tool-system/builtin/grep.d.ts +1 -0
- package/dist/tool-system/builtin/grep.js +82 -17
- package/dist/tool-system/builtin/image-uploader.js +7 -1
- package/dist/tool-system/builtin/index.d.ts +57 -18
- package/dist/tool-system/builtin/index.js +280 -167
- package/dist/tool-system/builtin/memory.d.ts +6 -0
- package/dist/tool-system/builtin/memory.js +36 -15
- package/dist/tool-system/builtin/panel.d.ts +9 -0
- package/dist/tool-system/builtin/panel.js +314 -0
- package/dist/tool-system/builtin/read.js +5 -1
- package/dist/tool-system/builtin/send-message-to-session.d.ts +6 -0
- package/dist/tool-system/builtin/send-message-to-session.js +67 -0
- package/dist/tool-system/builtin/sources.d.ts +8 -0
- package/dist/tool-system/builtin/sources.js +137 -0
- package/dist/tool-system/builtin/tool-search.js +7 -2
- package/dist/tool-system/builtin/update-automation-memory.js +2 -0
- package/dist/tool-system/builtin/video-providers.d.ts +12 -15
- package/dist/tool-system/builtin/video-providers.js +1 -0
- package/dist/tool-system/builtin/view-image.d.ts +2 -2
- package/dist/tool-system/builtin/web-fetch.js +60 -15
- package/dist/tool-system/builtin/web-search.js +1 -3
- package/dist/tool-system/builtin/write.d.ts +2 -1
- package/dist/tool-system/builtin/write.js +14 -4
- package/dist/tool-system/capability-module.d.ts +93 -0
- package/dist/tool-system/capability-module.js +53 -0
- package/dist/tool-system/context.d.ts +94 -24
- package/dist/tool-system/executor.js +99 -58
- package/dist/tool-system/external-tool-exposure.d.ts +60 -0
- package/dist/tool-system/external-tool-exposure.js +304 -0
- package/dist/tool-system/mcp-manager.d.ts +17 -1
- package/dist/tool-system/mcp-manager.js +72 -7
- package/dist/tool-system/mcp-tool-policy.d.ts +9 -0
- package/dist/tool-system/mcp-tool-policy.js +34 -0
- package/dist/tool-system/panel-bridge.d.ts +53 -0
- package/dist/tool-system/panel-bridge.js +1 -0
- package/dist/tool-system/path-policy.d.ts +19 -0
- package/dist/tool-system/path-policy.js +62 -1
- package/dist/tool-system/permission.d.ts +69 -3
- package/dist/tool-system/permission.js +429 -30
- package/dist/tool-system/registry.d.ts +15 -3
- package/dist/tool-system/registry.js +82 -40
- package/dist/tool-system/sandbox/index.js +3 -8
- package/dist/tool-system/sandbox/seatbelt.js +2 -6
- package/dist/tool-system/session-tool-host.d.ts +139 -0
- package/dist/tool-system/session-tool-host.js +167 -0
- package/dist/tool-system/testing/tool-registry-harness.d.ts +31 -0
- package/dist/tool-system/testing/tool-registry-harness.js +51 -0
- package/dist/tool-system/validation.d.ts +14 -7
- package/dist/tool-system/validation.js +701 -7
- package/dist/types.d.ts +201 -20
- package/dist/{cc-orchestrator → utils}/cwd-normalize.d.ts +1 -0
- package/dist/{cc-orchestrator → utils}/cwd-normalize.js +1 -0
- package/dist/utils/file-mutex.d.ts +65 -0
- package/dist/utils/file-mutex.js +145 -0
- package/dist/utils/json.d.ts +2 -4
- package/dist/utils/json.js +2 -4
- package/dist/utils/lockfile.d.ts +30 -1
- package/dist/utils/lockfile.js +2 -2
- package/dist/utils/secret-scrubber.d.ts +8 -0
- package/dist/utils/secret-scrubber.js +227 -0
- package/dist/utils/toolDisplay.js +1 -1
- package/package.json +20 -5
- package/THIRD_PARTY_NOTICES.md +0 -206
- package/dist/arena/arena.d.ts +0 -43
- package/dist/arena/arena.js +0 -333
- package/dist/arena/context/context-tools.d.ts +0 -16
- package/dist/arena/context/context-tools.js +0 -272
- package/dist/arena/context/within-root.d.ts +0 -7
- package/dist/arena/context/within-root.js +0 -15
- package/dist/arena/detect-mode.d.ts +0 -20
- package/dist/arena/detect-mode.js +0 -78
- package/dist/arena/digest-builder.d.ts +0 -25
- package/dist/arena/digest-builder.js +0 -120
- package/dist/arena/index.d.ts +0 -29
- package/dist/arena/index.js +0 -29
- package/dist/arena/iterate/convergence.d.ts +0 -25
- package/dist/arena/iterate/convergence.js +0 -103
- package/dist/arena/iterate/formats/index.d.ts +0 -22
- package/dist/arena/iterate/formats/index.js +0 -283
- package/dist/arena/iterate/index.d.ts +0 -11
- package/dist/arena/iterate/index.js +0 -9
- package/dist/arena/iterate/iterative-arena.d.ts +0 -23
- package/dist/arena/iterate/iterative-arena.js +0 -237
- package/dist/arena/iterate/parse.d.ts +0 -42
- package/dist/arena/iterate/parse.js +0 -123
- package/dist/arena/iterate/phases/argue.d.ts +0 -22
- package/dist/arena/iterate/phases/argue.js +0 -165
- package/dist/arena/iterate/phases/revise.d.ts +0 -16
- package/dist/arena/iterate/phases/revise.js +0 -62
- package/dist/arena/iterate/phases/tournament.d.ts +0 -34
- package/dist/arena/iterate/phases/tournament.js +0 -113
- package/dist/arena/iterate/tools/web-tools.d.ts +0 -13
- package/dist/arena/iterate/tools/web-tools.js +0 -54
- package/dist/arena/iterate/types.d.ts +0 -152
- package/dist/arena/iterate/types.js +0 -8
- package/dist/arena/ledger.d.ts +0 -47
- package/dist/arena/ledger.js +0 -159
- package/dist/arena/lenses/architecture.d.ts +0 -5
- package/dist/arena/lenses/architecture.js +0 -22
- package/dist/arena/lenses/engineering.d.ts +0 -5
- package/dist/arena/lenses/engineering.js +0 -22
- package/dist/arena/lenses/general.d.ts +0 -5
- package/dist/arena/lenses/general.js +0 -20
- package/dist/arena/lenses/index.d.ts +0 -16
- package/dist/arena/lenses/index.js +0 -47
- package/dist/arena/lenses/product.d.ts +0 -5
- package/dist/arena/lenses/product.js +0 -22
- package/dist/arena/model-presets.d.ts +0 -23
- package/dist/arena/model-presets.js +0 -44
- package/dist/arena/phases/adjudication.d.ts +0 -24
- package/dist/arena/phases/adjudication.js +0 -141
- package/dist/arena/phases/build-consensus.d.ts +0 -29
- package/dist/arena/phases/build-consensus.js +0 -83
- package/dist/arena/phases/claim-registry.d.ts +0 -26
- package/dist/arena/phases/claim-registry.js +0 -60
- package/dist/arena/phases/cross-review.d.ts +0 -45
- package/dist/arena/phases/cross-review.js +0 -218
- package/dist/arena/phases/debate-rounds.d.ts +0 -27
- package/dist/arena/phases/debate-rounds.js +0 -159
- package/dist/arena/phases/participant-research.d.ts +0 -38
- package/dist/arena/phases/participant-research.js +0 -314
- package/dist/arena/phases/planning-detail-expansion.d.ts +0 -38
- package/dist/arena/phases/planning-detail-expansion.js +0 -119
- package/dist/arena/planner.d.ts +0 -27
- package/dist/arena/planner.js +0 -311
- package/dist/arena/providers/docs.d.ts +0 -7
- package/dist/arena/providers/docs.js +0 -111
- package/dist/arena/providers/git.d.ts +0 -8
- package/dist/arena/providers/git.js +0 -174
- package/dist/arena/providers/index.d.ts +0 -32
- package/dist/arena/providers/index.js +0 -132
- package/dist/arena/providers/none.d.ts +0 -7
- package/dist/arena/providers/none.js +0 -11
- package/dist/arena/providers/repo.d.ts +0 -7
- package/dist/arena/providers/repo.js +0 -258
- package/dist/arena/render/session.d.ts +0 -17
- package/dist/arena/render/session.js +0 -190
- package/dist/arena/render/terminal.d.ts +0 -34
- package/dist/arena/render/terminal.js +0 -286
- package/dist/arena/strategies/discussion.d.ts +0 -25
- package/dist/arena/strategies/discussion.js +0 -143
- package/dist/arena/strategies/index.d.ts +0 -15
- package/dist/arena/strategies/index.js +0 -28
- package/dist/arena/strategies/language-wrapper.d.ts +0 -17
- package/dist/arena/strategies/language-wrapper.js +0 -102
- package/dist/arena/strategies/lens-wrapper.d.ts +0 -16
- package/dist/arena/strategies/lens-wrapper.js +0 -236
- package/dist/arena/strategies/planning.d.ts +0 -30
- package/dist/arena/strategies/planning.js +0 -225
- package/dist/arena/strategies/review.d.ts +0 -26
- package/dist/arena/strategies/review.js +0 -168
- package/dist/arena/strategies/utils.d.ts +0 -36
- package/dist/arena/strategies/utils.js +0 -603
- package/dist/arena/tools/selector.d.ts +0 -17
- package/dist/arena/tools/selector.js +0 -61
- package/dist/arena/transitions.d.ts +0 -53
- package/dist/arena/transitions.js +0 -97
- package/dist/arena/types.d.ts +0 -514
- package/dist/arena/types.js +0 -27
- package/dist/cc-orchestrator/agent-adapter.d.ts +0 -54
- package/dist/cc-orchestrator/agent-adapter.js +0 -143
- package/dist/cc-orchestrator/cc-capability.d.ts +0 -19
- package/dist/cc-orchestrator/cc-capability.js +0 -53
- package/dist/cc-orchestrator/codex-session-discovery.d.ts +0 -24
- package/dist/cc-orchestrator/codex-session-discovery.js +0 -191
- package/dist/cc-orchestrator/codex-session-history.d.ts +0 -38
- package/dist/cc-orchestrator/codex-session-history.js +0 -247
- package/dist/cc-orchestrator/external-agent-bindings.d.ts +0 -27
- package/dist/cc-orchestrator/external-agent-bindings.js +0 -150
- package/dist/cc-orchestrator/external-agent-changes.d.ts +0 -19
- package/dist/cc-orchestrator/external-agent-changes.js +0 -231
- package/dist/cc-orchestrator/external-agent-driver.d.ts +0 -19
- package/dist/cc-orchestrator/external-agent-driver.js +0 -284
- package/dist/cc-orchestrator/external-agent-session-store.d.ts +0 -23
- package/dist/cc-orchestrator/external-agent-session-store.js +0 -146
- package/dist/cc-orchestrator/index.d.ts +0 -8
- package/dist/cc-orchestrator/index.js +0 -8
- package/dist/cc-orchestrator/relevance-judge.d.ts +0 -15
- package/dist/cc-orchestrator/relevance-judge.js +0 -29
- package/dist/cc-orchestrator/session-discovery.d.ts +0 -46
- package/dist/cc-orchestrator/session-discovery.js +0 -125
- package/dist/cc-orchestrator/session-history.d.ts +0 -54
- package/dist/cc-orchestrator/session-history.js +0 -150
- package/dist/cron/cron-runtime.d.ts +0 -2
- package/dist/cron/cron-runtime.js +0 -2
- package/dist/cron/cron-store.d.ts +0 -2
- package/dist/cron/cron-store.js +0 -2
- package/dist/cron/scheduler.d.ts +0 -7
- package/dist/cron/scheduler.js +0 -7
- package/dist/engine/goal.js +0 -206
- package/dist/external-agents/config.d.ts +0 -2
- package/dist/external-agents/config.js +0 -15
- package/dist/external-agents/types.d.ts +0 -31
- package/dist/git/parse-log.d.ts +0 -13
- package/dist/git/parse-log.js +0 -21
- package/dist/git/utils.d.ts +0 -49
- package/dist/git/utils.js +0 -161
- package/dist/git/worktree/crud.d.ts +0 -69
- package/dist/git/worktree/crud.js +0 -206
- package/dist/git/worktree/diff.d.ts +0 -14
- package/dist/git/worktree/diff.js +0 -82
- package/dist/git/worktree/git-exec.d.ts +0 -7
- package/dist/git/worktree/git-exec.js +0 -51
- package/dist/git/worktree/index.d.ts +0 -5
- package/dist/git/worktree/index.js +0 -5
- package/dist/git/worktree/query.d.ts +0 -42
- package/dist/git/worktree/query.js +0 -121
- package/dist/git/worktree/slug.d.ts +0 -11
- package/dist/git/worktree/slug.js +0 -58
- package/dist/git/worktree.d.ts +0 -1
- package/dist/git/worktree.js +0 -5
- package/dist/lsp/client.d.ts +0 -41
- package/dist/lsp/client.js +0 -186
- package/dist/lsp/manager.d.ts +0 -40
- package/dist/lsp/manager.js +0 -155
- package/dist/lsp/root-path.d.ts +0 -9
- package/dist/lsp/root-path.js +0 -12
- package/dist/lsp/servers.d.ts +0 -16
- package/dist/lsp/servers.js +0 -60
- package/dist/prompt/sections/coding.md +0 -35
- package/dist/quota/credentials.d.ts +0 -3
- package/dist/quota/credentials.js +0 -80
- package/dist/quota/index.d.ts +0 -36
- package/dist/quota/index.js +0 -155
- package/dist/quota/types.d.ts +0 -48
- package/dist/quota/types.js +0 -13
- package/dist/review/review-prompt.d.ts +0 -28
- package/dist/review/review-prompt.js +0 -81
- package/dist/state.d.ts +0 -160
- package/dist/state.js +0 -267
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +0 -26
- package/dist/tool-system/builtin/apply-patch/applier.js +0 -308
- package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +0 -10
- package/dist/tool-system/builtin/apply-patch/backup-targets.js +0 -30
- package/dist/tool-system/builtin/apply-patch/index.d.ts +0 -20
- package/dist/tool-system/builtin/apply-patch/index.js +0 -105
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +0 -17
- package/dist/tool-system/builtin/apply-patch/parser.js +0 -212
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +0 -18
- package/dist/tool-system/builtin/apply-patch/seek-sequence.js +0 -123
- package/dist/tool-system/builtin/apply-patch/types.d.ts +0 -49
- package/dist/tool-system/builtin/apply-patch/types.js +0 -13
- package/dist/tool-system/builtin/arena.d.ts +0 -31
- package/dist/tool-system/builtin/arena.js +0 -415
- package/dist/tool-system/builtin/brief.d.ts +0 -6
- package/dist/tool-system/builtin/brief.js +0 -41
- package/dist/tool-system/builtin/check-quota.d.ts +0 -15
- package/dist/tool-system/builtin/check-quota.js +0 -34
- package/dist/tool-system/builtin/drive-claude-code.d.ts +0 -51
- package/dist/tool-system/builtin/drive-claude-code.js +0 -698
- package/dist/tool-system/builtin/lsp.d.ts +0 -7
- package/dist/tool-system/builtin/lsp.js +0 -144
- package/dist/tool-system/builtin/notebook-edit.d.ts +0 -7
- package/dist/tool-system/builtin/notebook-edit.js +0 -127
- package/dist/tool-system/builtin/worktree.d.ts +0 -11
- package/dist/tool-system/builtin/worktree.js +0 -345
- /package/dist/{external-agents → links}/types.js +0 -0
- /package/dist/{engine/session-usage.d.ts → session/usage.d.ts} +0 -0
- /package/dist/{engine/session-usage.js → session/usage.js} +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数据源只读读取面(ADR §5)。ListSources 只出 metadata(自动允许);
|
|
3
|
+
* ReadSource 读内容(permissionDefault: ask,在 index.ts 注册处声明),
|
|
4
|
+
* 执行时对 source/scope/resource 二次校验(防审批后换参),结果带
|
|
5
|
+
* provenance + maxBytes 截断 + secret redaction + untrusted input 包裹。
|
|
6
|
+
*/
|
|
7
|
+
import { SettingsManager } from "../../settings/manager.js";
|
|
8
|
+
import { connectorAdapterFor, registerConnectorAdapter } from "../../sources/adapter.js";
|
|
9
|
+
import { LOCAL_FILES_SOURCE_ID, listLocalFiles, localFilesAdapter, } from "../../sources/adapters/local-files.js";
|
|
10
|
+
import { defaultMcpResourceAdapter } from "../../sources/adapters/mcp-resource.js";
|
|
11
|
+
import { mockAdapter } from "../../sources/adapters/mock.js";
|
|
12
|
+
import { defaultCredentialStatus } from "../../sources/credential-status.js";
|
|
13
|
+
import { resolveEffectiveSourceAccess } from "../../sources/resolve.js";
|
|
14
|
+
import { truncateUtf8Text } from "../../sources/truncate-utf8.js";
|
|
15
|
+
import { scrubSecrets } from "../../utils/secret-scrubber.js";
|
|
16
|
+
import { wrapUntrustedInput } from "../../automation/write-policy.js";
|
|
17
|
+
const DEFAULT_MAX_BYTES = 262_144;
|
|
18
|
+
const mcpResourceAdapter = defaultMcpResourceAdapter();
|
|
19
|
+
/** Registering the same adapter objects is safe to repeat across test/host imports. */
|
|
20
|
+
export function registerBuiltinSourceAdapters() {
|
|
21
|
+
registerConnectorAdapter(mockAdapter);
|
|
22
|
+
registerConnectorAdapter(localFilesAdapter);
|
|
23
|
+
registerConnectorAdapter(mcpResourceAdapter);
|
|
24
|
+
}
|
|
25
|
+
registerBuiltinSourceAdapters();
|
|
26
|
+
function accessFor(cwd) {
|
|
27
|
+
const settings = new SettingsManager(cwd, "full");
|
|
28
|
+
return resolveEffectiveSourceAccess({
|
|
29
|
+
cwd,
|
|
30
|
+
settings,
|
|
31
|
+
credentialStatus: defaultCredentialStatus,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function resourcesFor(access, scope, cwd) {
|
|
35
|
+
if (access.sourceId === LOCAL_FILES_SOURCE_ID)
|
|
36
|
+
return listLocalFiles(cwd);
|
|
37
|
+
if (!access.definition)
|
|
38
|
+
return [];
|
|
39
|
+
return (await connectorAdapterFor(access.kind)?.listResources(access.definition, scope)) ?? [];
|
|
40
|
+
}
|
|
41
|
+
export const listSourcesToolDef = {
|
|
42
|
+
name: "ListSources",
|
|
43
|
+
description: "List the data sources bound to this workspace: names, scopes, availability status and resource names/sizes. Metadata only — use ReadSource to read content (requires approval).",
|
|
44
|
+
inputSchema: { type: "object", properties: {} },
|
|
45
|
+
};
|
|
46
|
+
export async function listSourcesTool(_args, ctx) {
|
|
47
|
+
const cwd = ctx?.cwd ?? process.cwd();
|
|
48
|
+
const access = accessFor(cwd);
|
|
49
|
+
if (access.length === 0)
|
|
50
|
+
return "No data sources are bound to this workspace.";
|
|
51
|
+
const lines = [];
|
|
52
|
+
for (const item of access) {
|
|
53
|
+
lines.push(`## ${item.label} (id: ${item.sourceId}, kind: ${item.kind}, status: ${item.status}, readPolicy: ${item.readPolicy})`);
|
|
54
|
+
if (item.status !== "ok")
|
|
55
|
+
continue;
|
|
56
|
+
for (const scope of item.scopes) {
|
|
57
|
+
let resources = [];
|
|
58
|
+
try {
|
|
59
|
+
resources = await resourcesFor(item, scope, cwd);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Listing is metadata-only and best effort. A temporarily failing scope
|
|
63
|
+
// must not expose content or make the other bound sources disappear.
|
|
64
|
+
}
|
|
65
|
+
lines.push(`### scope: ${scope}`);
|
|
66
|
+
for (const resource of resources.filter((candidate) => candidate.scopeId === scope)) {
|
|
67
|
+
lines.push(`- ${resource.name} (resource: ${resource.id}${resource.sizeBytes === undefined ? "" : `, ${resource.sizeBytes}B`})`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return lines.join("\n");
|
|
72
|
+
}
|
|
73
|
+
export const readSourceToolDef = {
|
|
74
|
+
name: "ReadSource",
|
|
75
|
+
description: "Read the content of one resource from a bound data source. Requires approval. Args must exactly match a bound source/scope and a listed resource id.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
source: { type: "string", description: "Bound source id (from ListSources)" },
|
|
80
|
+
scope: { type: "string", description: "Bound scope id" },
|
|
81
|
+
resource: { type: "string", description: "Resource id within that scope" },
|
|
82
|
+
},
|
|
83
|
+
required: ["source", "scope", "resource"],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export async function readSourceTool(args, ctx) {
|
|
87
|
+
const cwd = ctx?.cwd ?? process.cwd();
|
|
88
|
+
const source = String(args.source ?? "");
|
|
89
|
+
const scope = String(args.scope ?? "");
|
|
90
|
+
const resource = String(args.resource ?? "");
|
|
91
|
+
const signal = args.__signal;
|
|
92
|
+
// Second authorization gate after approval: the source must still be bound
|
|
93
|
+
// and healthy, and the requested scope must still be explicitly selected.
|
|
94
|
+
const access = accessFor(cwd).find((item) => item.sourceId === source);
|
|
95
|
+
if (!access)
|
|
96
|
+
return `Error: source "${source}" is not bound to this workspace.`;
|
|
97
|
+
if (access.status !== "ok")
|
|
98
|
+
return `Error: source "${source}" is ${access.status}.`;
|
|
99
|
+
if (access.readPolicy === "deny") {
|
|
100
|
+
return `Error: source "${source}" is metadata-only in this workspace (readPolicy: deny).`;
|
|
101
|
+
}
|
|
102
|
+
if (!access.scopes.includes(scope)) {
|
|
103
|
+
return `Error: scope "${scope}" is not bound for source "${source}".`;
|
|
104
|
+
}
|
|
105
|
+
if (!access.definition)
|
|
106
|
+
return `Error: source "${source}" is dangling.`;
|
|
107
|
+
const adapter = connectorAdapterFor(access.kind);
|
|
108
|
+
if (!adapter)
|
|
109
|
+
return `Error: no adapter for kind "${access.kind}".`;
|
|
110
|
+
try {
|
|
111
|
+
// Validate resource ownership from the selected scope's metadata before
|
|
112
|
+
// any content read. This prevents a valid id from another scope being used
|
|
113
|
+
// after approval with otherwise unchanged source/scope arguments.
|
|
114
|
+
const resources = await resourcesFor(access, scope, cwd);
|
|
115
|
+
const listed = resources.some((candidate) => candidate.id === resource && candidate.scopeId === scope);
|
|
116
|
+
if (!listed) {
|
|
117
|
+
return `Error: resource "${resource}" is not listed in scope "${scope}" for source "${source}".`;
|
|
118
|
+
}
|
|
119
|
+
const content = await adapter.read(access.definition, resource, {
|
|
120
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
121
|
+
signal,
|
|
122
|
+
cwd,
|
|
123
|
+
});
|
|
124
|
+
if (content.resourceId !== resource) {
|
|
125
|
+
return `Error: source "${source}" returned a different resource id.`;
|
|
126
|
+
}
|
|
127
|
+
// Adapters enforce maxBytes too; keep this boundary-level cap so a future
|
|
128
|
+
// or injected adapter cannot bypass the 256 KiB context limit.
|
|
129
|
+
const capped = truncateUtf8Text(content.text, DEFAULT_MAX_BYTES);
|
|
130
|
+
const truncated = content.truncated || capped.truncated;
|
|
131
|
+
const provenance = `source=${source} scope=${scope} resource=${resource}${truncated ? " (truncated)" : ""}`;
|
|
132
|
+
return wrapUntrustedInput(scrubSecrets(capped.text), provenance);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return `Error: read failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* The model uses ToolSearch to discover full schemas on demand,
|
|
6
6
|
* saving context by not loading all MCP tool schemas upfront.
|
|
7
7
|
*/
|
|
8
|
+
import { isRegisteredMcpToolAllowed } from "../mcp-tool-policy.js";
|
|
8
9
|
export const toolSearchToolDef = {
|
|
9
10
|
name: "ToolSearch",
|
|
10
11
|
description: "Search for and discover available tools by name or keyword. " +
|
|
@@ -48,11 +49,15 @@ export async function toolSearchTool(args, ctx) {
|
|
|
48
49
|
if (tool.source !== "mcp")
|
|
49
50
|
return true;
|
|
50
51
|
const allowed = ctx.allowedMcpServers;
|
|
51
|
-
return !allowed || allowed.has(tool.serverName ?? "")
|
|
52
|
+
return ((!allowed || allowed.has(tool.serverName ?? "")) &&
|
|
53
|
+
isRegisteredMcpToolAllowed(tool, ctx.mcpToolPolicies));
|
|
52
54
|
};
|
|
53
55
|
// "select:Name1,Name2" → exact match
|
|
54
56
|
if (query.startsWith("select:")) {
|
|
55
|
-
const names = query
|
|
57
|
+
const names = query
|
|
58
|
+
.slice(7)
|
|
59
|
+
.split(",")
|
|
60
|
+
.map((n) => n.trim());
|
|
56
61
|
return matchExact(ctx.toolRegistry, names, visible);
|
|
57
62
|
}
|
|
58
63
|
// Keyword search
|
|
@@ -47,6 +47,8 @@ export function makeUpdateAutomationMemoryTool(sink) {
|
|
|
47
47
|
isReadOnly: false,
|
|
48
48
|
isConcurrencySafe: false,
|
|
49
49
|
},
|
|
50
|
+
// Host-injected automation contribution, never part of a default preset.
|
|
51
|
+
exposure: { presetTags: [] },
|
|
50
52
|
execute: async (args) => {
|
|
51
53
|
const raw = typeof args.summary === "string" ? args.summary : "";
|
|
52
54
|
const summary = raw.trim();
|
|
@@ -40,6 +40,7 @@ export type VideoPollResult = {
|
|
|
40
40
|
} | {
|
|
41
41
|
ok: true;
|
|
42
42
|
status: "succeeded";
|
|
43
|
+
url?: string;
|
|
43
44
|
} | {
|
|
44
45
|
ok: true;
|
|
45
46
|
status: "failed";
|
|
@@ -57,6 +58,14 @@ export type VideoDownloadResult = {
|
|
|
57
58
|
ok: false;
|
|
58
59
|
error: string;
|
|
59
60
|
};
|
|
61
|
+
export interface VideoDownloadRequest {
|
|
62
|
+
jobId: string;
|
|
63
|
+
creds: VideoProviderCreds;
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
/** Called as soon as the provider exposes the remote result URL, before the
|
|
66
|
+
* potentially long byte download begins. */
|
|
67
|
+
onUrl?: (url: string) => void;
|
|
68
|
+
}
|
|
60
69
|
export interface VideoProvider {
|
|
61
70
|
readonly kind: string;
|
|
62
71
|
submit(req: VideoSubmitRequest): Promise<VideoSubmitResult>;
|
|
@@ -65,11 +74,7 @@ export interface VideoProvider {
|
|
|
65
74
|
creds: VideoProviderCreds;
|
|
66
75
|
signal?: AbortSignal;
|
|
67
76
|
}): Promise<VideoPollResult>;
|
|
68
|
-
download(req:
|
|
69
|
-
jobId: string;
|
|
70
|
-
creds: VideoProviderCreds;
|
|
71
|
-
signal?: AbortSignal;
|
|
72
|
-
}): Promise<VideoDownloadResult>;
|
|
77
|
+
download(req: VideoDownloadRequest): Promise<VideoDownloadResult>;
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
75
80
|
* Deterministic in-memory adapter for tests and local dev — no network. Models
|
|
@@ -95,11 +100,7 @@ export declare class FakeVideoProvider implements VideoProvider {
|
|
|
95
100
|
creds?: VideoProviderCreds;
|
|
96
101
|
signal?: AbortSignal;
|
|
97
102
|
}): Promise<VideoPollResult>;
|
|
98
|
-
download(_req:
|
|
99
|
-
jobId: string;
|
|
100
|
-
creds?: VideoProviderCreds;
|
|
101
|
-
signal?: AbortSignal;
|
|
102
|
-
}): Promise<VideoDownloadResult>;
|
|
103
|
+
download(_req: VideoDownloadRequest): Promise<VideoDownloadResult>;
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
106
|
* fal.ai video adapter — submit/poll/download against the fal queue API
|
|
@@ -138,11 +139,7 @@ export declare class FalVideoProvider implements VideoProvider {
|
|
|
138
139
|
creds: VideoProviderCreds;
|
|
139
140
|
signal?: AbortSignal;
|
|
140
141
|
}): Promise<VideoPollResult>;
|
|
141
|
-
download(req:
|
|
142
|
-
jobId: string;
|
|
143
|
-
creds: VideoProviderCreds;
|
|
144
|
-
signal?: AbortSignal;
|
|
145
|
-
}): Promise<VideoDownloadResult>;
|
|
142
|
+
download(req: VideoDownloadRequest): Promise<VideoDownloadResult>;
|
|
146
143
|
}
|
|
147
144
|
/** Default model per video provider kind (filled in with real adapters). */
|
|
148
145
|
export declare const DEFAULT_VIDEO_MODEL: Record<string, string>;
|
|
@@ -197,6 +197,7 @@ export class FalVideoProvider {
|
|
|
197
197
|
const videoUrl = j.video?.url;
|
|
198
198
|
if (!videoUrl)
|
|
199
199
|
return { ok: false, error: "fal result: no video.url" };
|
|
200
|
+
req.onUrl?.(videoUrl);
|
|
200
201
|
// hop 2: video bytes
|
|
201
202
|
const vr = await this.fetchImpl(videoUrl, { method: "GET", signal: req.signal });
|
|
202
203
|
if (!vr.ok) {
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { ToolDefinition } from "../../types.js";
|
|
15
15
|
import type { ToolContext } from "../context.js";
|
|
16
|
-
import type {
|
|
16
|
+
import type { BuiltinToolReturn } from "./index.js";
|
|
17
17
|
export declare const viewImageToolDef: ToolDefinition;
|
|
18
|
-
export declare function viewImageTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<
|
|
18
|
+
export declare function viewImageTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<BuiltinToolReturn>;
|
|
@@ -25,10 +25,16 @@ export const webFetchToolDef = {
|
|
|
25
25
|
};
|
|
26
26
|
const MAX_OUTPUT = 100_000;
|
|
27
27
|
const DEFAULT_MAX = 50_000;
|
|
28
|
+
const RAW_BYTE_BUDGET_MULTIPLIER = 4;
|
|
28
29
|
// Header names that must not be overridable via args.headers (SSRF / auth injection)
|
|
29
30
|
const BLOCKED_REQUEST_HEADERS = new Set([
|
|
30
|
-
"host",
|
|
31
|
-
"
|
|
31
|
+
"host",
|
|
32
|
+
"authorization",
|
|
33
|
+
"cookie",
|
|
34
|
+
"proxy-authorization",
|
|
35
|
+
"x-forwarded-for",
|
|
36
|
+
"x-real-ip",
|
|
37
|
+
"x-forwarded-host",
|
|
32
38
|
]);
|
|
33
39
|
// Hostname patterns that block SSRF to internal/metadata services
|
|
34
40
|
const BLOCKED_HOST_PATTERNS = [
|
|
@@ -40,15 +46,14 @@ const BLOCKED_HOST_PATTERNS = [
|
|
|
40
46
|
/^192\.168\./,
|
|
41
47
|
/^172\.(1[6-9]|2[0-9]|3[01])\./, // 172.16.0.0/12
|
|
42
48
|
/^::1$/,
|
|
43
|
-
/^fc00:/i,
|
|
49
|
+
/^fc00:/i,
|
|
50
|
+
/^fd00:/i, // IPv6 ULA
|
|
44
51
|
/^fe80:/i, // IPv6 link-local
|
|
45
52
|
];
|
|
46
53
|
function isBlockedHost(hostname) {
|
|
47
54
|
// `new URL("http://[::1]/").hostname` returns "[::1]" (with brackets);
|
|
48
55
|
// strip them so IPv6 patterns match.
|
|
49
|
-
const stripped = hostname.startsWith("[") && hostname.endsWith("]")
|
|
50
|
-
? hostname.slice(1, -1)
|
|
51
|
-
: hostname;
|
|
56
|
+
const stripped = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
52
57
|
return BLOCKED_HOST_PATTERNS.some((re) => re.test(stripped));
|
|
53
58
|
}
|
|
54
59
|
// A3 hardening: per-IP block list. Used after DNS resolution to catch
|
|
@@ -118,11 +123,7 @@ const MAX_REDIRECTS = 5;
|
|
|
118
123
|
// Headers that must be stripped when a redirect crosses origins.
|
|
119
124
|
// Same policy fetch(... redirect: "follow") applies internally; we
|
|
120
125
|
// re-implement it here because we drive redirects manually.
|
|
121
|
-
const CROSS_ORIGIN_STRIP_HEADERS = new Set([
|
|
122
|
-
"authorization",
|
|
123
|
-
"cookie",
|
|
124
|
-
"proxy-authorization",
|
|
125
|
-
]);
|
|
126
|
+
const CROSS_ORIGIN_STRIP_HEADERS = new Set(["authorization", "cookie", "proxy-authorization"]);
|
|
126
127
|
async function defaultDnsLookup(hostname) {
|
|
127
128
|
// For literal IPs, lookup returns the IP itself (Node behavior),
|
|
128
129
|
// which still flows through the block-list check above.
|
|
@@ -146,7 +147,10 @@ async function validateHopHost(u) {
|
|
|
146
147
|
ips = await dnsLookupImpl(u.hostname);
|
|
147
148
|
}
|
|
148
149
|
catch (err) {
|
|
149
|
-
return {
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
reason: `DNS lookup failed for "${u.hostname}": ${err.message}`,
|
|
153
|
+
};
|
|
150
154
|
}
|
|
151
155
|
if (ips.length === 0) {
|
|
152
156
|
return { ok: false, reason: `DNS returned no addresses for "${u.hostname}"` };
|
|
@@ -252,7 +256,46 @@ export async function webFetchTool(args) {
|
|
|
252
256
|
}
|
|
253
257
|
async function readAndTruncateBody(res, maxLength) {
|
|
254
258
|
const contentType = res.headers.get("content-type") ?? "";
|
|
255
|
-
const
|
|
259
|
+
const maxBytes = maxLength * RAW_BYTE_BUDGET_MULTIPLIER;
|
|
260
|
+
const reader = res.body?.getReader();
|
|
261
|
+
let body;
|
|
262
|
+
let rawTruncated = false;
|
|
263
|
+
if (!reader) {
|
|
264
|
+
body = await res.text();
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
const decoder = new TextDecoder("utf-8");
|
|
268
|
+
const chunks = [];
|
|
269
|
+
let bytesRead = 0;
|
|
270
|
+
try {
|
|
271
|
+
for (;;) {
|
|
272
|
+
const { done, value } = await reader.read();
|
|
273
|
+
if (done)
|
|
274
|
+
break;
|
|
275
|
+
const remaining = maxBytes - bytesRead;
|
|
276
|
+
if (value.byteLength >= remaining) {
|
|
277
|
+
chunks.push(decoder.decode(value.subarray(0, remaining), { stream: true }));
|
|
278
|
+
bytesRead += remaining;
|
|
279
|
+
rawTruncated = true;
|
|
280
|
+
await reader.cancel();
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
284
|
+
bytesRead += value.byteLength;
|
|
285
|
+
}
|
|
286
|
+
const tail = decoder.decode();
|
|
287
|
+
// When the byte budget cuts through a multi-byte code point, flushing
|
|
288
|
+
// the decoder would turn that intentionally incomplete suffix into �.
|
|
289
|
+
// All complete code points were already emitted by stream:true, so the
|
|
290
|
+
// truncated tail is safe to discard.
|
|
291
|
+
if (!rawTruncated)
|
|
292
|
+
chunks.push(tail);
|
|
293
|
+
body = chunks.join("");
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
reader.releaseLock();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
256
299
|
let text;
|
|
257
300
|
if (contentType.includes("text/html") || contentType.includes("application/xhtml")) {
|
|
258
301
|
text = extractTextFromHTML(body);
|
|
@@ -260,8 +303,10 @@ async function readAndTruncateBody(res, maxLength) {
|
|
|
260
303
|
else {
|
|
261
304
|
text = body;
|
|
262
305
|
}
|
|
263
|
-
if (text.length > maxLength) {
|
|
264
|
-
|
|
306
|
+
if (rawTruncated || text.length > maxLength) {
|
|
307
|
+
const shownChars = Math.min(text.length, maxLength);
|
|
308
|
+
text =
|
|
309
|
+
text.slice(0, maxLength) + `\n\n... content truncated (showing first ${shownChars} chars)`;
|
|
265
310
|
}
|
|
266
311
|
return text || "(page returned empty content)";
|
|
267
312
|
}
|
|
@@ -153,9 +153,7 @@ export async function webSearchTool(args, ctx) {
|
|
|
153
153
|
}
|
|
154
154
|
if (results.length === 0)
|
|
155
155
|
return "No results found.";
|
|
156
|
-
return results
|
|
157
|
-
.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}\n ${r.snippet}`)
|
|
158
|
-
.join("\n\n");
|
|
156
|
+
return results.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}\n ${r.snippet}`).join("\n\n");
|
|
159
157
|
}
|
|
160
158
|
catch (err) {
|
|
161
159
|
return `Search error: ${err.message}`;
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolDefinition } from "../../types.js";
|
|
5
5
|
import type { ToolContext } from "../context.js";
|
|
6
|
+
import type { ToolFailure } from "./index.js";
|
|
6
7
|
export declare const writeToolDef: ToolDefinition;
|
|
7
|
-
export declare function writeTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
8
|
+
export declare function writeTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string | ToolFailure>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in Write file tool.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { mkdir } from "node:fs/promises";
|
|
5
5
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
6
6
|
import { fileCache } from "./file-cache.js";
|
|
7
|
+
import { getFinalWritePathSnapshot, revalidateFinalWritePath, writeFileNoFollow, } from "../path-policy.js";
|
|
7
8
|
export const writeToolDef = {
|
|
8
9
|
name: "Write",
|
|
9
10
|
description: "Write content to a file. Creates the file if it doesn't exist, " +
|
|
@@ -27,12 +28,21 @@ export async function writeTool(args, ctx) {
|
|
|
27
28
|
const cwd = ctx?.cwd ?? process.cwd();
|
|
28
29
|
const filePath = isAbsolute(rawPath) ? rawPath : resolve(cwd, rawPath);
|
|
29
30
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const approvedPath = getFinalWritePathSnapshot(args, filePath, cwd);
|
|
32
|
+
const beforeMkdir = revalidateFinalWritePath(filePath, cwd, approvedPath);
|
|
33
|
+
if ("error" in beforeMkdir)
|
|
34
|
+
return { ok: false, error: beforeMkdir.error };
|
|
35
|
+
await mkdir(dirname(beforeMkdir.resolvedPath), { recursive: true });
|
|
36
|
+
// mkdir may have crossed an existing symlink in a missing parent chain;
|
|
37
|
+
// resolve again immediately before opening the final file.
|
|
38
|
+
const beforeWrite = revalidateFinalWritePath(filePath, cwd, approvedPath);
|
|
39
|
+
if ("error" in beforeWrite)
|
|
40
|
+
return { ok: false, error: beforeWrite.error };
|
|
41
|
+
await writeFileNoFollow(beforeWrite.resolvedPath, content);
|
|
32
42
|
fileCache.invalidate(filePath);
|
|
33
43
|
return `Successfully wrote to ${filePath}`;
|
|
34
44
|
}
|
|
35
45
|
catch (err) {
|
|
36
|
-
return `Error writing file: ${err.message}
|
|
46
|
+
return { ok: false, error: `Error writing file: ${err.message}` };
|
|
37
47
|
}
|
|
38
48
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { RegisteredTool, StreamEvent } from "../types.js";
|
|
2
|
+
import type { ToolContext } from "./context.js";
|
|
3
|
+
import type { ToolRegistry } from "./registry.js";
|
|
4
|
+
import type { BuiltinTool } from "./builtin/index.js";
|
|
5
|
+
import type { RunBehaviorProfile } from "../engine/run-types.js";
|
|
6
|
+
import type { PendingApprovalMetadata } from "../protocol/types.js";
|
|
7
|
+
export interface ExtensionTool {
|
|
8
|
+
definition: RegisteredTool;
|
|
9
|
+
execute: (args: Record<string, unknown>, ctx?: ToolContext) => Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
export type ExtensionQueryHandler = (params: Readonly<Record<string, unknown>>) => unknown | Promise<unknown>;
|
|
12
|
+
/** Read-only live-session state exposed to protocol observers. */
|
|
13
|
+
export interface ProtocolLiveSession {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
busy: boolean;
|
|
16
|
+
queueDepth: number;
|
|
17
|
+
lastActivityAt: number;
|
|
18
|
+
kind: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Domain-agnostic protocol lifecycle observer. An extension module can attach
|
|
22
|
+
* one per AgentServer to project protocol activity (runs, stream events,
|
|
23
|
+
* approvals, session/server teardown) into its own state — without the server
|
|
24
|
+
* carrying any domain-specific logic. Observer callbacks must be cheap and
|
|
25
|
+
* must never throw (the server isolates exceptions per observer regardless).
|
|
26
|
+
*/
|
|
27
|
+
export interface ProtocolObserver {
|
|
28
|
+
/** A session was created/attached by agent/run (before the turn is queued). */
|
|
29
|
+
onSessionAttached?: (sessionId: string, lastActivityAt: number) => void;
|
|
30
|
+
/** Every StreamEvent forwarded to the client for a session's run. */
|
|
31
|
+
onSessionStream?: (sessionId: string, event: StreamEvent) => void;
|
|
32
|
+
/** Run lifecycle boundary: turn accepted (start), finished (end) or threw (error). */
|
|
33
|
+
onRunBoundary?: (sessionId: string, phase: "start" | "end" | "error") => void;
|
|
34
|
+
/**
|
|
35
|
+
* A pending approval was registered. May return replacement metadata (e.g.
|
|
36
|
+
* to override `surfaceable`); returning nothing keeps the input metadata.
|
|
37
|
+
*/
|
|
38
|
+
onApprovalCreated?: (metadata: PendingApprovalMetadata) => PendingApprovalMetadata | void;
|
|
39
|
+
/** A pending approval left the pending state (resolved/expired/cancelled/owner-lost). */
|
|
40
|
+
onApprovalTransition?: (metadata: PendingApprovalMetadata, status: string) => void;
|
|
41
|
+
/** A session was explicitly closed (agent/closeSession). */
|
|
42
|
+
onSessionClosed?: (sessionId: string) => void;
|
|
43
|
+
/** The server is shutting down. */
|
|
44
|
+
onServerClose?: () => void;
|
|
45
|
+
/** Resolver-free pending-decision projections for host/debug snapshots. */
|
|
46
|
+
snapshotPendingDecisions?: () => readonly unknown[];
|
|
47
|
+
}
|
|
48
|
+
/** Capabilities the AgentServer lends to a protocol observer. */
|
|
49
|
+
export interface ProtocolObserverHost {
|
|
50
|
+
/** Snapshot of live chat sessions (empty in legacy single-engine mode). */
|
|
51
|
+
getLiveSessionSnapshot: () => readonly ProtocolLiveSession[];
|
|
52
|
+
/** Host lifecycle generation attached to projection snapshots/deltas. */
|
|
53
|
+
projectionGeneration: () => number;
|
|
54
|
+
/** Persisted session kind, when the session is live and its engine knows it. */
|
|
55
|
+
getSessionKind: (sessionId: string) => string | undefined;
|
|
56
|
+
/** True once the server's transport owner disconnected. */
|
|
57
|
+
isTransportDisconnected: () => boolean;
|
|
58
|
+
/** Server → client notification. */
|
|
59
|
+
notify: (method: string, params: Record<string, unknown>) => void;
|
|
60
|
+
/** Register a protocol-method/query alias handled by this extension. */
|
|
61
|
+
registerQuery: (type: string, handler: ExtensionQueryHandler) => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Trusted, in-process product extension. Core owns the registration seam while
|
|
65
|
+
* optional packages own their tools and diagnostic/query surface.
|
|
66
|
+
*/
|
|
67
|
+
export interface ExtensionModule {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly tools?: readonly ExtensionTool[];
|
|
70
|
+
readonly queries?: Readonly<Record<string, ExtensionQueryHandler>>;
|
|
71
|
+
/** Named per-run behavior profiles contributed by this extension. */
|
|
72
|
+
readonly behaviorProfiles?: readonly RunBehaviorProfile[];
|
|
73
|
+
/** Attach a protocol lifecycle observer to an AgentServer. */
|
|
74
|
+
readonly createProtocolObserver?: (host: ProtocolObserverHost) => ProtocolObserver;
|
|
75
|
+
/** Extra agent/run params validation. Returns an error message or null. */
|
|
76
|
+
readonly validateRunParams?: (params: Record<string, unknown>) => string | null;
|
|
77
|
+
/** Session kinds this extension owns that must stay out of generic session lists. */
|
|
78
|
+
readonly hiddenSessionKinds?: readonly string[];
|
|
79
|
+
/**
|
|
80
|
+
* Full-metadata tool contributions (exposure tags, availability guards,
|
|
81
|
+
* per-turn definition rewrites, default permission rules). These join the
|
|
82
|
+
* engine's composed tool catalog exactly like builtin/capability tools do —
|
|
83
|
+
* use this instead of `tools` when the tool needs visibility metadata.
|
|
84
|
+
*/
|
|
85
|
+
readonly catalogTools?: readonly BuiltinTool[];
|
|
86
|
+
}
|
|
87
|
+
export declare function registerExtensionModules(registry: ToolRegistry, modules: readonly ExtensionModule[]): void;
|
|
88
|
+
export declare function queryExtensionModules(modules: readonly ExtensionModule[], type: string, params: Readonly<Record<string, unknown>>): Promise<{
|
|
89
|
+
handled: false;
|
|
90
|
+
} | {
|
|
91
|
+
handled: true;
|
|
92
|
+
data: unknown;
|
|
93
|
+
}>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ConfigError } from "../exceptions.js";
|
|
2
|
+
function validateExtensionModules(modules) {
|
|
3
|
+
const ids = new Set();
|
|
4
|
+
const queries = new Set();
|
|
5
|
+
const tools = new Set();
|
|
6
|
+
for (const module of modules) {
|
|
7
|
+
if (ids.has(module.id)) {
|
|
8
|
+
throw new ConfigError(`Duplicate capability module id: ${module.id}`, {
|
|
9
|
+
duplicateCapabilityId: module.id,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
ids.add(module.id);
|
|
13
|
+
for (const tool of module.tools ?? []) {
|
|
14
|
+
if (tools.has(tool.definition.name)) {
|
|
15
|
+
throw new ConfigError(`Duplicate capability tool: ${tool.definition.name}`, {
|
|
16
|
+
duplicateCapabilityTool: tool.definition.name,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
tools.add(tool.definition.name);
|
|
20
|
+
}
|
|
21
|
+
for (const query of Object.keys(module.queries ?? {})) {
|
|
22
|
+
if (queries.has(query)) {
|
|
23
|
+
throw new ConfigError(`Duplicate capability query: ${query}`, {
|
|
24
|
+
duplicateCapabilityQuery: query,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
queries.add(query);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function registerExtensionModules(registry, modules) {
|
|
32
|
+
validateExtensionModules(modules);
|
|
33
|
+
for (const module of modules) {
|
|
34
|
+
for (const tool of module.tools ?? []) {
|
|
35
|
+
if (registry.hasTool(tool.definition.name)) {
|
|
36
|
+
throw new ConfigError(`Capability tool conflicts with registered tool: ${tool.definition.name}`, {
|
|
37
|
+
duplicateCapabilityTool: tool.definition.name,
|
|
38
|
+
capabilityId: module.id,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
registry.registerTool(tool.definition, tool.execute);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function queryExtensionModules(modules, type, params) {
|
|
46
|
+
validateExtensionModules(modules);
|
|
47
|
+
for (const module of modules) {
|
|
48
|
+
const handler = module.queries?.[type];
|
|
49
|
+
if (handler)
|
|
50
|
+
return { handled: true, data: await handler(params) };
|
|
51
|
+
}
|
|
52
|
+
return { handled: false };
|
|
53
|
+
}
|