@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
|
@@ -21,7 +21,7 @@ import { notificationQueue } from "./agent-notifications.js";
|
|
|
21
21
|
import { backgroundJobRegistry } from "./background-jobs.js";
|
|
22
22
|
import { logger } from "../../logging/logger.js";
|
|
23
23
|
import { getVideoProvider, DEFAULT_VIDEO_MODEL, } from "./video-providers.js";
|
|
24
|
-
import { getImageUploader, isHttpUrl } from "./image-uploader.js";
|
|
24
|
+
import { getImageUploader, isHttpUrl, } from "./image-uploader.js";
|
|
25
25
|
import { effectiveApiKey } from "./generate-image.js";
|
|
26
26
|
import { getMergedCatalog, findCatalogEntry } from "../../model-catalog/index.js";
|
|
27
27
|
import { genInstancesFromConnections } from "../../model-catalog/gen-connections.js";
|
|
@@ -55,7 +55,14 @@ export async function __normalizeImagesForTests(images, image, uploader, creds,
|
|
|
55
55
|
const VIDEO_PROVIDER_KINDS = ["fal"];
|
|
56
56
|
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
57
57
|
/** Safety cap so a stuck job's background loop can't poll forever. */
|
|
58
|
-
const
|
|
58
|
+
const DEFAULT_MAX_POLL_MS = 15 * 60 * 1000;
|
|
59
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
60
|
+
let maxPollMs = DEFAULT_MAX_POLL_MS;
|
|
61
|
+
let requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT_MS;
|
|
62
|
+
export function __setVideoPollingLimitsForTests(limits) {
|
|
63
|
+
maxPollMs = limits?.maxPollMs ?? DEFAULT_MAX_POLL_MS;
|
|
64
|
+
requestTimeoutMs = limits?.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
65
|
+
}
|
|
59
66
|
export const generateVideoToolDef = {
|
|
60
67
|
name: "GenerateVideo",
|
|
61
68
|
description: "Generate a video from a text prompt. The job runs in the background (video generation is " +
|
|
@@ -71,7 +78,10 @@ export const generateVideoToolDef = {
|
|
|
71
78
|
description: "Video provider kind to use. Defaults to the first configured video provider.",
|
|
72
79
|
},
|
|
73
80
|
model: { type: "string", description: "Video model id. Defaults to the provider's default." },
|
|
74
|
-
image: {
|
|
81
|
+
image: {
|
|
82
|
+
type: "string",
|
|
83
|
+
description: "Image URL (http/https) for image-to-video. When set, an image-to-video model is used.",
|
|
84
|
+
},
|
|
75
85
|
images: {
|
|
76
86
|
type: "array",
|
|
77
87
|
items: { type: "string" },
|
|
@@ -80,7 +90,7 @@ export const generateVideoToolDef = {
|
|
|
80
90
|
videos: {
|
|
81
91
|
type: "array",
|
|
82
92
|
items: { type: "string" },
|
|
83
|
-
description:
|
|
93
|
+
description: 'Reference/continuation video URLs (http/https only — NOT local paths) for video extension. Forces reference-to-video (Seedance model required). Up to 3. Refer to them in prompt as @Video1, @Video2 (e.g. "continue from @Video1").',
|
|
84
94
|
},
|
|
85
95
|
},
|
|
86
96
|
required: ["prompt"],
|
|
@@ -177,7 +187,10 @@ function resolveVideoProvider(cwd, preferKind) {
|
|
|
177
187
|
const list = genInstancesFromConnections(conns, (Array.isArray(creds) ? creds : []), getMergedCatalog(), "video");
|
|
178
188
|
const def = settings.defaults?.video;
|
|
179
189
|
const usable = (p) => !!p.apiKey && getVideoProvider(p.kind) !== null;
|
|
180
|
-
const credsOf = (p) => ({
|
|
190
|
+
const credsOf = (p) => ({
|
|
191
|
+
baseUrl: p.baseUrl,
|
|
192
|
+
apiKey: p.apiKey,
|
|
193
|
+
});
|
|
181
194
|
if (preferKind) {
|
|
182
195
|
const chosen = list.find((p) => (p.id === preferKind || p.kind === preferKind) && usable(p));
|
|
183
196
|
if (chosen)
|
|
@@ -195,7 +208,10 @@ function resolveVideoProvider(cwd, preferKind) {
|
|
|
195
208
|
if (videoGen?.providers?.length) {
|
|
196
209
|
const list = videoGen.providers;
|
|
197
210
|
const usable = (p) => !!effectiveApiKey(p, list) && getVideoProvider(p.kind) !== null;
|
|
198
|
-
const credsOf = (p) => ({
|
|
211
|
+
const credsOf = (p) => ({
|
|
212
|
+
baseUrl: p.baseUrl,
|
|
213
|
+
apiKey: effectiveApiKey(p, list),
|
|
214
|
+
});
|
|
199
215
|
if (preferKind) {
|
|
200
216
|
const chosen = list.find((p) => (p.id === preferKind || p.kind === preferKind) && usable(p));
|
|
201
217
|
if (chosen)
|
|
@@ -213,7 +229,8 @@ function resolveVideoProvider(cwd, preferKind) {
|
|
|
213
229
|
// Back-compat: scan legacy LLM providers[] for a video-capable kind. The
|
|
214
230
|
// field was dropped from the schema; un-migrated settings.json still carry it
|
|
215
231
|
// via .passthrough(), so read it through an inline cast.
|
|
216
|
-
const legacyProviders = settings
|
|
232
|
+
const legacyProviders = settings
|
|
233
|
+
.providers ?? [];
|
|
217
234
|
const kinds = preferKind ? [preferKind] : VIDEO_PROVIDER_KINDS;
|
|
218
235
|
for (const kind of kinds) {
|
|
219
236
|
const provider = legacyProviders.find((p) => p.kind === kind);
|
|
@@ -283,7 +300,15 @@ export async function generateVideoTool(args, ctx) {
|
|
|
283
300
|
const norm = await __normalizeImagesForTests(imagesArg, image, uploader, { baseUrl: creds.baseUrl, apiKey: creds.apiKey }, ctx?.signal);
|
|
284
301
|
if (!norm.ok)
|
|
285
302
|
return `Error: ${norm.error}`;
|
|
286
|
-
const submit = await adapter.submit({
|
|
303
|
+
const submit = await adapter.submit({
|
|
304
|
+
prompt,
|
|
305
|
+
model,
|
|
306
|
+
image: undefined,
|
|
307
|
+
images: norm.urls,
|
|
308
|
+
videos: videosArg,
|
|
309
|
+
creds,
|
|
310
|
+
signal: ctx?.signal,
|
|
311
|
+
});
|
|
287
312
|
if (!submit.ok) {
|
|
288
313
|
return `Error submitting video job: ${submit.error}`;
|
|
289
314
|
}
|
|
@@ -297,10 +322,36 @@ export async function generateVideoTool(args, ctx) {
|
|
|
297
322
|
// two providers can't collide.
|
|
298
323
|
const jobKey = `video-${jobId}`;
|
|
299
324
|
const promptPreview = prompt.length > 80 ? `${prompt.slice(0, 80)}…` : prompt;
|
|
300
|
-
|
|
301
|
-
|
|
325
|
+
const controller = new AbortController();
|
|
326
|
+
let abortKind;
|
|
327
|
+
const abortTask = (kind) => {
|
|
328
|
+
if (controller.signal.aborted)
|
|
329
|
+
return;
|
|
330
|
+
abortKind = kind;
|
|
331
|
+
controller.abort();
|
|
332
|
+
};
|
|
333
|
+
const onTurnAbort = () => abortTask("cancelled");
|
|
334
|
+
if (ctx?.signal?.aborted)
|
|
335
|
+
onTurnAbort();
|
|
336
|
+
else
|
|
337
|
+
ctx?.signal?.addEventListener("abort", onTurnAbort, { once: true });
|
|
338
|
+
const totalTimer = setTimeout(() => abortTask("timeout"), maxPollMs);
|
|
339
|
+
const polling = pollToCompletion(adapter, jobId, creds, cwd, sessionId, prompt, pollIntervalMs, controller.signal, () => abortKind, maxPollMs, requestTimeoutMs);
|
|
340
|
+
backgroundJobRegistry.start(jobKey, sessionId ?? "", `生成视频中:${promptPreview}`, {
|
|
341
|
+
kind: "video",
|
|
342
|
+
abort: async () => {
|
|
343
|
+
abortTask("cancelled");
|
|
344
|
+
return await polling;
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
void polling
|
|
302
348
|
.then((outcome) => backgroundJobRegistry.finish(jobKey, outcome))
|
|
303
|
-
.catch((err) => backgroundJobRegistry.finish(jobKey, { status: "failed", finalText: err.message }))
|
|
349
|
+
.catch((err) => backgroundJobRegistry.finish(jobKey, { status: "failed", finalText: err.message }))
|
|
350
|
+
.finally(() => {
|
|
351
|
+
clearTimeout(totalTimer);
|
|
352
|
+
ctx?.signal?.removeEventListener("abort", onTurnAbort);
|
|
353
|
+
});
|
|
354
|
+
ctx?.runYield?.request("background_notification");
|
|
304
355
|
return [
|
|
305
356
|
`Video generation started in the background.`,
|
|
306
357
|
`job_id: ${jobId} (internal — do not show to user)`,
|
|
@@ -310,16 +361,36 @@ export async function generateVideoTool(args, ctx) {
|
|
|
310
361
|
`If you have no other work right now, END YOUR TURN — the system wakes you when the video is ready. NEVER run \`sleep\` or poll the provider yourself.`,
|
|
311
362
|
].join("\n");
|
|
312
363
|
}
|
|
313
|
-
async function pollToCompletion(adapter, jobId, creds, cwd, sessionId, prompt, pollIntervalMs) {
|
|
314
|
-
|
|
364
|
+
async function pollToCompletion(adapter, jobId, creds, cwd, sessionId, prompt, pollIntervalMs, signal, getAbortKind, totalTimeoutMs, perRequestTimeoutMs) {
|
|
365
|
+
let knownVideoUrl;
|
|
366
|
+
const retainedUrlOutcome = () => {
|
|
367
|
+
if (!knownVideoUrl)
|
|
368
|
+
return undefined;
|
|
369
|
+
const msg = `Video rendered successfully, but the local download did not finish. Download it from ${knownVideoUrl}`;
|
|
370
|
+
notifyVideo(sessionId, "completed", prompt, undefined, undefined, knownVideoUrl);
|
|
371
|
+
return { status: "completed", finalText: msg };
|
|
372
|
+
};
|
|
373
|
+
const abortOutcome = () => {
|
|
374
|
+
const retained = retainedUrlOutcome();
|
|
375
|
+
if (retained) {
|
|
376
|
+
return retained;
|
|
377
|
+
}
|
|
378
|
+
if (getAbortKind() === "timeout") {
|
|
379
|
+
const msg = `video job ${jobId} timed out after ${Math.round(totalTimeoutMs / 1000)}s`;
|
|
380
|
+
notifyVideo(sessionId, "failed", prompt, undefined, msg);
|
|
381
|
+
return { status: "failed", finalText: msg };
|
|
382
|
+
}
|
|
383
|
+
const msg = "Local waiting stopped; the remote service may still be rendering the video.";
|
|
384
|
+
notifyVideo(sessionId, "cancelled", prompt, undefined, msg);
|
|
385
|
+
return { status: "cancelled", finalText: msg };
|
|
386
|
+
};
|
|
315
387
|
try {
|
|
316
388
|
for (;;) {
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const res = await adapter.poll({ jobId, creds });
|
|
389
|
+
if (signal.aborted)
|
|
390
|
+
return abortOutcome();
|
|
391
|
+
const res = await runVideoRequest((requestSignal) => adapter.poll({ jobId, creds, signal: requestSignal }), signal, perRequestTimeoutMs);
|
|
392
|
+
if (signal.aborted)
|
|
393
|
+
return abortOutcome();
|
|
323
394
|
if (!res.ok) {
|
|
324
395
|
notifyVideo(sessionId, "failed", prompt, undefined, res.error);
|
|
325
396
|
return { status: "failed", finalText: res.error };
|
|
@@ -328,27 +399,84 @@ async function pollToCompletion(adapter, jobId, creds, cwd, sessionId, prompt, p
|
|
|
328
399
|
notifyVideo(sessionId, "failed", prompt, undefined, res.error);
|
|
329
400
|
return { status: "failed", finalText: res.error };
|
|
330
401
|
}
|
|
331
|
-
if (res.status === "succeeded")
|
|
402
|
+
if (res.status === "succeeded") {
|
|
403
|
+
knownVideoUrl = res.url;
|
|
332
404
|
break;
|
|
333
|
-
|
|
405
|
+
}
|
|
406
|
+
await abortableDelay(pollIntervalMs, signal);
|
|
334
407
|
}
|
|
335
|
-
const dl = await adapter.download({
|
|
408
|
+
const dl = await runVideoRequest((requestSignal) => adapter.download({
|
|
409
|
+
jobId,
|
|
410
|
+
creds,
|
|
411
|
+
signal: requestSignal,
|
|
412
|
+
onUrl: (url) => {
|
|
413
|
+
knownVideoUrl = url;
|
|
414
|
+
},
|
|
415
|
+
}), signal, perRequestTimeoutMs);
|
|
416
|
+
if (signal.aborted)
|
|
417
|
+
return abortOutcome();
|
|
336
418
|
if (!dl.ok) {
|
|
419
|
+
const retained = retainedUrlOutcome();
|
|
420
|
+
if (retained)
|
|
421
|
+
return retained;
|
|
337
422
|
notifyVideo(sessionId, "failed", prompt, undefined, dl.error);
|
|
338
423
|
return { status: "failed", finalText: dl.error };
|
|
339
424
|
}
|
|
425
|
+
knownVideoUrl = dl.url ?? knownVideoUrl;
|
|
340
426
|
const dir = join(cwd, ".code-shell", "generated_videos");
|
|
341
427
|
await mkdir(dir, { recursive: true });
|
|
428
|
+
if (signal.aborted)
|
|
429
|
+
return abortOutcome();
|
|
342
430
|
const path = join(dir, `${Date.now()}.${dl.ext || "mp4"}`);
|
|
343
|
-
await writeFile(path, dl.bytes);
|
|
344
|
-
notifyVideo(sessionId, "completed", prompt, path, undefined,
|
|
431
|
+
await writeFile(path, dl.bytes, { signal });
|
|
432
|
+
notifyVideo(sessionId, "completed", prompt, path, undefined, knownVideoUrl);
|
|
345
433
|
return { status: "completed", finalText: path };
|
|
346
434
|
}
|
|
347
435
|
catch (err) {
|
|
436
|
+
const retained = retainedUrlOutcome();
|
|
437
|
+
if (retained)
|
|
438
|
+
return retained;
|
|
439
|
+
if (signal.aborted)
|
|
440
|
+
return abortOutcome();
|
|
348
441
|
notifyVideo(sessionId, "failed", prompt, undefined, err.message);
|
|
349
442
|
return { status: "failed", finalText: err.message };
|
|
350
443
|
}
|
|
351
444
|
}
|
|
445
|
+
async function runVideoRequest(request, taskSignal, timeoutMs) {
|
|
446
|
+
const requestSignal = AbortSignal.any([taskSignal, AbortSignal.timeout(timeoutMs)]);
|
|
447
|
+
const promise = request(requestSignal);
|
|
448
|
+
if (requestSignal.aborted)
|
|
449
|
+
throw requestSignal.reason;
|
|
450
|
+
return await new Promise((resolve, reject) => {
|
|
451
|
+
const onAbort = () => reject(requestSignal.reason);
|
|
452
|
+
const cleanup = () => requestSignal.removeEventListener("abort", onAbort);
|
|
453
|
+
requestSignal.addEventListener("abort", onAbort, { once: true });
|
|
454
|
+
promise.then((value) => {
|
|
455
|
+
cleanup();
|
|
456
|
+
resolve(value);
|
|
457
|
+
}, (error) => {
|
|
458
|
+
cleanup();
|
|
459
|
+
reject(error);
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
async function abortableDelay(ms, signal) {
|
|
464
|
+
if (signal.aborted)
|
|
465
|
+
throw signal.reason;
|
|
466
|
+
await new Promise((resolve, reject) => {
|
|
467
|
+
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
468
|
+
const timer = setTimeout(() => {
|
|
469
|
+
cleanup();
|
|
470
|
+
resolve();
|
|
471
|
+
}, ms);
|
|
472
|
+
const onAbort = () => {
|
|
473
|
+
clearTimeout(timer);
|
|
474
|
+
cleanup();
|
|
475
|
+
reject(signal.reason);
|
|
476
|
+
};
|
|
477
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
478
|
+
});
|
|
479
|
+
}
|
|
352
480
|
function notifyVideo(sessionId, status, prompt, path, error, url) {
|
|
353
481
|
if (!sessionId) {
|
|
354
482
|
logger.warn("video_completion_without_session", { status });
|
|
@@ -363,11 +491,19 @@ function notifyVideo(sessionId, status, prompt, path, error, url) {
|
|
|
363
491
|
agentId: `video-${Date.now()}`,
|
|
364
492
|
name: "video generation",
|
|
365
493
|
description: status === "completed"
|
|
366
|
-
?
|
|
367
|
-
|
|
494
|
+
? path
|
|
495
|
+
? `Video generated: ${path} (prompt: ${prompt})`
|
|
496
|
+
: `Video rendered: ${url} (local download stopped; prompt: ${prompt})`
|
|
497
|
+
: status === "cancelled"
|
|
498
|
+
? `Stopped waiting for video generation (prompt: ${prompt})`
|
|
499
|
+
: `Video generation failed (prompt: ${prompt})`,
|
|
368
500
|
status,
|
|
369
|
-
finalText: status === "completed"
|
|
370
|
-
|
|
501
|
+
finalText: status === "completed"
|
|
502
|
+
? path
|
|
503
|
+
? `Video saved to ${path}.${extendHint}`
|
|
504
|
+
: `Video rendered successfully. Download it from ${url}.${extendHint}`
|
|
505
|
+
: undefined,
|
|
506
|
+
error: status === "failed" || status === "cancelled" ? error : undefined,
|
|
371
507
|
enqueuedAt: Date.now(),
|
|
372
508
|
}, sessionId);
|
|
373
509
|
}
|
|
@@ -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 globToolDef: ToolDefinition;
|
|
7
|
-
export declare function globTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string>;
|
|
8
|
+
export declare function globTool(args: Record<string, unknown>, ctx?: ToolContext): Promise<string | ToolFailure>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in Glob file search tool.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { Glob } from "glob";
|
|
5
5
|
import { stat } from "node:fs/promises";
|
|
6
6
|
import * as path from "node:path";
|
|
7
|
+
import { classifyPath } from "../path-policy.js";
|
|
7
8
|
export const globToolDef = {
|
|
8
9
|
name: "Glob",
|
|
9
10
|
description: "Fast file pattern matching. Returns matching file paths sorted by modification time. " +
|
|
@@ -32,13 +33,37 @@ export async function globTool(args, ctx) {
|
|
|
32
33
|
: path.resolve(baseDir, argPath)
|
|
33
34
|
: baseDir;
|
|
34
35
|
try {
|
|
35
|
-
const
|
|
36
|
+
const matcher = new Glob(pattern, {
|
|
36
37
|
cwd,
|
|
37
38
|
absolute: true,
|
|
38
39
|
nodir: true,
|
|
39
40
|
dot: false,
|
|
41
|
+
follow: false,
|
|
40
42
|
ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/.next/**", "**/coverage/**"],
|
|
41
43
|
});
|
|
44
|
+
for (const parsedPattern of matcher.patterns) {
|
|
45
|
+
const expandedPattern = parsedPattern.globString();
|
|
46
|
+
if (parsedPattern.isAbsolute() ||
|
|
47
|
+
path.posix.isAbsolute(expandedPattern) ||
|
|
48
|
+
path.win32.isAbsolute(expandedPattern)) {
|
|
49
|
+
return "Error: Glob pattern must be relative to the search path.";
|
|
50
|
+
}
|
|
51
|
+
if (expandedPattern.split(/[\\/]/).includes("..")) {
|
|
52
|
+
return "Error: Glob pattern cannot contain a '..' path segment.";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const searchRoot = classifyPath(cwd, { workspaceRoot: cwd, operation: "read" }).resolvedPath;
|
|
56
|
+
const matches = (await matcher.walk()).filter((filePath) => {
|
|
57
|
+
const resolved = classifyPath(filePath, {
|
|
58
|
+
workspaceRoot: cwd,
|
|
59
|
+
operation: "read",
|
|
60
|
+
}).resolvedPath;
|
|
61
|
+
const relativeToRoot = path.relative(searchRoot, resolved);
|
|
62
|
+
return (relativeToRoot === "" ||
|
|
63
|
+
(relativeToRoot !== ".." &&
|
|
64
|
+
!relativeToRoot.startsWith(`..${path.sep}`) &&
|
|
65
|
+
!path.isAbsolute(relativeToRoot)));
|
|
66
|
+
});
|
|
42
67
|
if (matches.length === 0) {
|
|
43
68
|
return "No files matched the pattern.";
|
|
44
69
|
}
|
|
@@ -71,6 +96,6 @@ export async function globTool(args, ctx) {
|
|
|
71
96
|
return result;
|
|
72
97
|
}
|
|
73
98
|
catch (err) {
|
|
74
|
-
return `Error in glob: ${err.message}
|
|
99
|
+
return { ok: false, error: `Error in glob: ${err.message}` };
|
|
75
100
|
}
|
|
76
101
|
}
|
|
@@ -3,12 +3,56 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
6
|
-
import { promisify } from "node:util";
|
|
7
6
|
import { basename, join, relative, resolve, sep, isAbsolute } from "node:path";
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { killChildTree } from "../../runtime/spawn-common.js";
|
|
8
|
+
function abortError() {
|
|
9
|
+
return Object.assign(new Error("Search aborted"), { name: "AbortError" });
|
|
10
|
+
}
|
|
11
|
+
const execFileAbortable = (file, args, options) => new Promise((resolvePromise, reject) => {
|
|
12
|
+
if (options.signal?.aborted) {
|
|
13
|
+
reject(abortError());
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let settled = false;
|
|
17
|
+
const child = execFile(file, [...args], { encoding: "utf8", maxBuffer: options.maxBuffer }, (error, stdout, stderr) => {
|
|
18
|
+
if (settled)
|
|
19
|
+
return;
|
|
20
|
+
settled = true;
|
|
21
|
+
cleanup();
|
|
22
|
+
if (error) {
|
|
23
|
+
Object.assign(error, { stdout, stderr });
|
|
24
|
+
reject(error);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
resolvePromise({ stdout, stderr });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const finishWithKill = (error) => {
|
|
31
|
+
if (settled)
|
|
32
|
+
return;
|
|
33
|
+
settled = true;
|
|
34
|
+
cleanup();
|
|
35
|
+
killChildTree(child, 1000);
|
|
36
|
+
reject(error);
|
|
37
|
+
};
|
|
38
|
+
const onAbort = () => finishWithKill(abortError());
|
|
39
|
+
const timer = setTimeout(() => {
|
|
40
|
+
const error = Object.assign(new Error(`Search timed out after ${options.timeout}ms`), {
|
|
41
|
+
code: "ETIMEDOUT",
|
|
42
|
+
});
|
|
43
|
+
finishWithKill(error);
|
|
44
|
+
}, options.timeout);
|
|
45
|
+
const cleanup = () => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
48
|
+
};
|
|
49
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
50
|
+
if (options.signal?.aborted)
|
|
51
|
+
onAbort();
|
|
52
|
+
});
|
|
53
|
+
let execFileForTest = execFileAbortable;
|
|
10
54
|
export function _setGrepExecFileForTest(fn) {
|
|
11
|
-
execFileForTest = fn ??
|
|
55
|
+
execFileForTest = fn ?? execFileAbortable;
|
|
12
56
|
}
|
|
13
57
|
/**
|
|
14
58
|
* Strip the cwd prefix from each line so results display as relative
|
|
@@ -39,7 +83,10 @@ export const grepToolDef = {
|
|
|
39
83
|
pattern: { type: "string", description: "Regular expression pattern to search for" },
|
|
40
84
|
path: { type: "string", description: "File or directory to search in (default: cwd)" },
|
|
41
85
|
glob: { type: "string", description: 'Glob pattern to filter files (e.g. "*.ts")' },
|
|
42
|
-
context: {
|
|
86
|
+
context: {
|
|
87
|
+
type: "number",
|
|
88
|
+
description: "Lines of context around matches (only with output_mode content)",
|
|
89
|
+
},
|
|
43
90
|
max_results: { type: "number", description: "Maximum number of results (default: 50)" },
|
|
44
91
|
output_mode: {
|
|
45
92
|
type: "string",
|
|
@@ -69,29 +116,36 @@ export async function grepTool(args, ctx) {
|
|
|
69
116
|
const outputMode = args.output_mode || "files_with_matches";
|
|
70
117
|
const caseInsensitive = args.case_insensitive || false;
|
|
71
118
|
try {
|
|
72
|
-
return await runRipgrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive);
|
|
119
|
+
return await runRipgrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive, ctx?.signal);
|
|
73
120
|
}
|
|
74
121
|
catch (rgErr) {
|
|
122
|
+
if (isAbort(rgErr, ctx?.signal))
|
|
123
|
+
throw rgErr;
|
|
75
124
|
// rg/grep exit code 1 = no matches (not an error)
|
|
76
125
|
if (isNoMatchExit(rgErr))
|
|
77
126
|
return "No matches found.";
|
|
78
127
|
try {
|
|
79
|
-
return await runGrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive);
|
|
128
|
+
return await runGrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive, ctx?.signal);
|
|
80
129
|
}
|
|
81
130
|
catch (grepErr) {
|
|
131
|
+
if (isAbort(grepErr, ctx?.signal))
|
|
132
|
+
throw grepErr;
|
|
82
133
|
if (isNoMatchExit(grepErr))
|
|
83
134
|
return "No matches found.";
|
|
84
135
|
if (isCommandNotFound(rgErr) || isCommandNotFound(grepErr)) {
|
|
85
|
-
return await runNodeGrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive);
|
|
136
|
+
return await runNodeGrep(pattern, searchPath, fileGlob, context, maxResults, outputMode, caseInsensitive, ctx?.signal);
|
|
86
137
|
}
|
|
87
|
-
|
|
138
|
+
throw new Error(`Error in search: ${grepErr.message}`, { cause: grepErr });
|
|
88
139
|
}
|
|
89
140
|
}
|
|
90
141
|
}
|
|
142
|
+
function isAbort(error, signal) {
|
|
143
|
+
return signal?.aborted === true || error?.name === "AbortError";
|
|
144
|
+
}
|
|
91
145
|
function isCommandNotFound(err) {
|
|
92
146
|
return err?.code === "ENOENT";
|
|
93
147
|
}
|
|
94
|
-
async function runRipgrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive) {
|
|
148
|
+
async function runRipgrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive, signal) {
|
|
95
149
|
const args = ["--color=never"];
|
|
96
150
|
if (caseInsensitive)
|
|
97
151
|
args.push("-i");
|
|
@@ -116,6 +170,7 @@ async function runRipgrep(pattern, path, fileGlob, context, maxResults, outputMo
|
|
|
116
170
|
const { stdout } = await execFileForTest("rg", args, {
|
|
117
171
|
maxBuffer: 10 * 1024 * 1024,
|
|
118
172
|
timeout: 30_000,
|
|
173
|
+
signal,
|
|
119
174
|
});
|
|
120
175
|
const result = relativizeOutput(stdout, path).trim();
|
|
121
176
|
if (!result)
|
|
@@ -127,7 +182,7 @@ async function runRipgrep(pattern, path, fileGlob, context, maxResults, outputMo
|
|
|
127
182
|
}
|
|
128
183
|
return result;
|
|
129
184
|
}
|
|
130
|
-
async function runGrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive) {
|
|
185
|
+
async function runGrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive, signal) {
|
|
131
186
|
const args = ["-r", "--color=never"];
|
|
132
187
|
if (caseInsensitive)
|
|
133
188
|
args.push("-i");
|
|
@@ -153,6 +208,7 @@ async function runGrep(pattern, path, fileGlob, context, maxResults, outputMode,
|
|
|
153
208
|
const { stdout } = await execFileForTest("grep", args, {
|
|
154
209
|
maxBuffer: 10 * 1024 * 1024,
|
|
155
210
|
timeout: 30_000,
|
|
211
|
+
signal,
|
|
156
212
|
});
|
|
157
213
|
const result = relativizeOutput(stdout, path).trim();
|
|
158
214
|
if (!result)
|
|
@@ -164,16 +220,18 @@ async function runGrep(pattern, path, fileGlob, context, maxResults, outputMode,
|
|
|
164
220
|
return result;
|
|
165
221
|
}
|
|
166
222
|
const IGNORED_DIRS = new Set(["node_modules", ".git", "dist", "coverage"]);
|
|
167
|
-
async function runNodeGrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive) {
|
|
223
|
+
async function runNodeGrep(pattern, path, fileGlob, context, maxResults, outputMode, caseInsensitive, signal) {
|
|
224
|
+
signal?.throwIfAborted();
|
|
168
225
|
let regex;
|
|
169
226
|
try {
|
|
170
227
|
regex = new RegExp(pattern, caseInsensitive ? "i" : "");
|
|
171
228
|
}
|
|
172
229
|
catch (err) {
|
|
173
|
-
|
|
230
|
+
throw new Error(`Error in search: ${err.message}`, { cause: err });
|
|
174
231
|
}
|
|
175
232
|
const matches = [];
|
|
176
233
|
await walkTextFiles(path, fileGlob, async (file) => {
|
|
234
|
+
signal?.throwIfAborted();
|
|
177
235
|
if (matches.length >= maxResults)
|
|
178
236
|
return;
|
|
179
237
|
let text;
|
|
@@ -214,15 +272,17 @@ async function runNodeGrep(pattern, path, fileGlob, context, maxResults, outputM
|
|
|
214
272
|
}
|
|
215
273
|
}
|
|
216
274
|
}
|
|
217
|
-
});
|
|
275
|
+
}, signal);
|
|
218
276
|
if (matches.length === 0)
|
|
219
277
|
return "No matches found.";
|
|
220
278
|
if (matches.length > 200)
|
|
221
279
|
return matches.slice(0, 200).join("\n") + `\n\n... ${matches.length - 200} more results`;
|
|
222
280
|
return matches.join("\n");
|
|
223
281
|
}
|
|
224
|
-
async function walkTextFiles(root, fileGlob, visit) {
|
|
282
|
+
async function walkTextFiles(root, fileGlob, visit, signal) {
|
|
283
|
+
signal?.throwIfAborted();
|
|
225
284
|
const info = await stat(root).catch(() => null);
|
|
285
|
+
signal?.throwIfAborted();
|
|
226
286
|
if (!info)
|
|
227
287
|
return;
|
|
228
288
|
if (info.isFile()) {
|
|
@@ -233,11 +293,13 @@ async function walkTextFiles(root, fileGlob, visit) {
|
|
|
233
293
|
if (!info.isDirectory())
|
|
234
294
|
return;
|
|
235
295
|
const entries = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
296
|
+
signal?.throwIfAborted();
|
|
236
297
|
for (const entry of entries) {
|
|
298
|
+
signal?.throwIfAborted();
|
|
237
299
|
if (entry.isDirectory()) {
|
|
238
300
|
if (IGNORED_DIRS.has(entry.name))
|
|
239
301
|
continue;
|
|
240
|
-
await walkTextFiles(join(root, entry.name), fileGlob, visit);
|
|
302
|
+
await walkTextFiles(join(root, entry.name), fileGlob, visit, signal);
|
|
241
303
|
}
|
|
242
304
|
else if (entry.isFile()) {
|
|
243
305
|
if (!fileGlob || matchesSimpleGlob(entry.name, fileGlob))
|
|
@@ -246,6 +308,9 @@ async function walkTextFiles(root, fileGlob, visit) {
|
|
|
246
308
|
}
|
|
247
309
|
}
|
|
248
310
|
function matchesSimpleGlob(name, glob) {
|
|
249
|
-
const escaped = glob
|
|
311
|
+
const escaped = glob
|
|
312
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
313
|
+
.replace(/\*/g, ".*")
|
|
314
|
+
.replace(/\?/g, ".");
|
|
250
315
|
return new RegExp(`^${escaped}$`).test(name);
|
|
251
316
|
}
|
|
@@ -10,7 +10,13 @@ export function isHttpUrl(s) {
|
|
|
10
10
|
}
|
|
11
11
|
function mimeFromName(name) {
|
|
12
12
|
const ext = name.toLowerCase().split(".").pop() ?? "";
|
|
13
|
-
const map = {
|
|
13
|
+
const map = {
|
|
14
|
+
png: "image/png",
|
|
15
|
+
jpg: "image/jpeg",
|
|
16
|
+
jpeg: "image/jpeg",
|
|
17
|
+
webp: "image/webp",
|
|
18
|
+
gif: "image/gif",
|
|
19
|
+
};
|
|
14
20
|
return map[ext] ?? "application/octet-stream";
|
|
15
21
|
}
|
|
16
22
|
export class FalStorageUploader {
|