@clinebot/core 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/dist/ClineCore.d.ts +96 -63
- package/dist/ClineCore.d.ts.map +1 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/rpc.d.ts +6 -6
- package/dist/account/rpc.d.ts.map +1 -1
- package/dist/cron/index.d.ts +6 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/resource-limiter.d.ts +9 -0
- package/dist/cron/resource-limiter.d.ts.map +1 -0
- package/dist/cron/schedule-command-service.d.ts +10 -0
- package/dist/cron/schedule-command-service.d.ts.map +1 -0
- package/dist/cron/schedule-service.d.ts +100 -0
- package/dist/cron/schedule-service.d.ts.map +1 -0
- package/dist/cron/scheduler.d.ts +66 -0
- package/dist/cron/scheduler.d.ts.map +1 -0
- package/dist/cron/sqlite-schedule-store.d.ts +52 -0
- package/dist/cron/sqlite-schedule-store.d.ts.map +1 -0
- package/dist/extensions/config/agent-config-loader.d.ts +6 -5
- package/dist/extensions/config/agent-config-loader.d.ts.map +1 -1
- package/dist/extensions/config/agent-config-parser.d.ts +1 -1
- package/dist/extensions/config/agent-config-parser.d.ts.map +1 -1
- package/dist/extensions/config/hooks-config-loader.d.ts +2 -2
- package/dist/extensions/config/hooks-config-loader.d.ts.map +1 -1
- package/dist/extensions/config/index.d.ts +3 -3
- package/dist/extensions/config/index.d.ts.map +1 -1
- package/dist/extensions/config/runtime-commands.d.ts +1 -0
- package/dist/extensions/config/runtime-commands.d.ts.map +1 -1
- package/dist/extensions/config/user-instruction-config-loader.d.ts +3 -2
- package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -1
- package/dist/extensions/context/agentic-compaction.d.ts +2 -2
- package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
- package/dist/extensions/context/compaction-shared.d.ts +5 -4
- package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
- package/dist/extensions/context/compaction.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts +9 -2
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +5 -3
- package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts +15 -2
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-targeting.d.ts +7 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts.map +1 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +253 -253
- package/dist/extensions/tools/constants.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/definitions.d.ts +1 -1
- package/dist/extensions/tools/definitions.d.ts.map +1 -0
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/executors/apply-patch.d.ts +3 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts.map +1 -0
- package/dist/extensions/tools/executors/bash.d.ts.map +1 -0
- package/dist/extensions/tools/executors/editor.d.ts.map +1 -0
- package/dist/extensions/tools/executors/file-read.d.ts.map +1 -0
- package/dist/extensions/tools/executors/index.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/executors/search.d.ts +1 -1
- package/dist/extensions/tools/executors/search.d.ts.map +1 -0
- package/dist/extensions/tools/executors/web-fetch.d.ts.map +1 -0
- package/dist/extensions/tools/helpers.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/index.d.ts +2 -0
- package/dist/extensions/tools/index.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/model-tool-routing.d.ts +1 -1
- package/dist/extensions/tools/model-tool-routing.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/presets.d.ts +26 -44
- package/dist/extensions/tools/presets.d.ts.map +1 -0
- package/dist/extensions/tools/runtime.d.ts +25 -0
- package/dist/extensions/tools/runtime.d.ts.map +1 -0
- package/dist/extensions/tools/schemas.d.ts.map +1 -0
- package/dist/extensions/tools/team/delegated-agent.d.ts.map +1 -0
- package/dist/extensions/tools/team/index.d.ts.map +1 -0
- package/dist/{team → extensions/tools/team}/multi-agent.d.ts +1 -3
- package/dist/extensions/tools/team/multi-agent.d.ts.map +1 -0
- package/dist/extensions/tools/team/projections.d.ts.map +1 -0
- package/dist/extensions/tools/team/runtime.d.ts.map +1 -0
- package/dist/{team → extensions/tools/team}/spawn-agent-tool.d.ts +0 -1
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts.map +1 -0
- package/dist/extensions/tools/team/subagent-prompts.d.ts.map +1 -0
- package/dist/{team → extensions/tools/team}/team-tools.d.ts +1 -0
- package/dist/extensions/tools/team/team-tools.d.ts.map +1 -0
- package/dist/{tools → extensions/tools}/types.d.ts +4 -3
- package/dist/extensions/tools/types.d.ts.map +1 -0
- package/dist/{runtime → hooks}/checkpoint-hooks.d.ts +7 -0
- package/dist/hooks/checkpoint-hooks.d.ts.map +1 -0
- package/dist/{runtime → hooks}/hook-file-hooks.d.ts +4 -3
- package/dist/hooks/hook-file-hooks.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/subprocess.d.ts +10 -130
- package/dist/hooks/subprocess.d.ts.map +1 -1
- package/dist/hub/browser-websocket.d.ts +18 -0
- package/dist/hub/browser-websocket.d.ts.map +1 -0
- package/dist/hub/client.d.ts +45 -0
- package/dist/hub/client.d.ts.map +1 -0
- package/dist/hub/connect.d.ts +15 -0
- package/dist/hub/connect.d.ts.map +1 -0
- package/dist/hub/daemon-entry.d.ts +2 -0
- package/dist/hub/daemon-entry.d.ts.map +1 -0
- package/dist/hub/daemon-entry.js +1045 -0
- package/dist/hub/daemon.d.ts +5 -0
- package/dist/hub/daemon.d.ts.map +1 -0
- package/dist/hub/defaults.d.ts +13 -0
- package/dist/hub/defaults.d.ts.map +1 -0
- package/dist/hub/discovery.d.ts +29 -0
- package/dist/hub/discovery.d.ts.map +1 -0
- package/dist/hub/index.d.ts +15 -0
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +1044 -0
- package/dist/hub/native-transport.d.ts +17 -0
- package/dist/hub/native-transport.d.ts.map +1 -0
- package/dist/hub/runtime-handlers.d.ts +11 -0
- package/dist/hub/runtime-handlers.d.ts.map +1 -0
- package/dist/hub/server.d.ts +86 -0
- package/dist/hub/server.d.ts.map +1 -0
- package/dist/hub/session-client.d.ts +87 -0
- package/dist/hub/session-client.d.ts.map +1 -0
- package/dist/hub/start-shared-server.d.ts +19 -0
- package/dist/hub/start-shared-server.d.ts.map +1 -0
- package/dist/hub/transport.d.ts +8 -0
- package/dist/hub/transport.d.ts.map +1 -0
- package/dist/hub/ui-client.d.ts +44 -0
- package/dist/hub/ui-client.d.ts.map +1 -0
- package/dist/hub/workspace.d.ts +4 -0
- package/dist/hub/workspace.d.ts.map +1 -0
- package/dist/index.d.ts +52 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +557 -533
- package/dist/llms/configured-provider-registry.d.ts +28 -0
- package/dist/llms/configured-provider-registry.d.ts.map +1 -0
- package/dist/llms/provider-defaults.d.ts +27 -0
- package/dist/llms/provider-defaults.d.ts.map +1 -0
- package/dist/llms/provider-settings.d.ts +202 -0
- package/dist/llms/provider-settings.d.ts.map +1 -0
- package/dist/llms/runtime-config.d.ts +4 -0
- package/dist/llms/runtime-config.d.ts.map +1 -0
- package/dist/llms/runtime-registry.d.ts +20 -0
- package/dist/llms/runtime-registry.d.ts.map +1 -0
- package/dist/llms/runtime-types.d.ts +85 -0
- package/dist/llms/runtime-types.d.ts.map +1 -0
- package/dist/runtime/history.d.ts +4 -0
- package/dist/runtime/history.d.ts.map +1 -0
- package/dist/runtime/host.d.ts +8 -0
- package/dist/runtime/host.d.ts.map +1 -0
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/runtime-host.d.ts +103 -0
- package/dist/runtime/runtime-host.d.ts.map +1 -0
- package/dist/{session → runtime}/runtime-oauth-token-manager.d.ts +1 -1
- package/dist/{session → runtime}/runtime-oauth-token-manager.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +3 -21
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/{session/session-agent-events.d.ts → services/agent-events.d.ts} +4 -4
- package/dist/services/agent-events.d.ts.map +1 -0
- package/dist/services/config.d.ts +3 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/global-settings.d.ts +12 -0
- package/dist/services/global-settings.d.ts.map +1 -0
- package/dist/services/local-runtime-bootstrap.d.ts +47 -0
- package/dist/services/local-runtime-bootstrap.d.ts.map +1 -0
- package/dist/services/plugin-tools.d.ts +16 -0
- package/dist/services/plugin-tools.d.ts.map +1 -0
- package/dist/{providers → services/providers}/local-provider-registry.d.ts +4 -4
- package/dist/services/providers/local-provider-registry.d.ts.map +1 -0
- package/dist/{providers → services/providers}/local-provider-service.d.ts +13 -13
- package/dist/services/providers/local-provider-service.d.ts.map +1 -0
- package/dist/{session → services}/session-artifacts.d.ts +0 -4
- package/dist/services/session-artifacts.d.ts.map +1 -0
- package/dist/{session/utils/helpers.d.ts → services/session-data.d.ts} +19 -27
- package/dist/services/session-data.d.ts.map +1 -0
- package/dist/{session → services}/session-telemetry.d.ts +2 -2
- package/dist/services/session-telemetry.d.ts.map +1 -0
- package/dist/{storage → services/storage}/file-team-store.d.ts +2 -2
- package/dist/services/storage/file-team-store.d.ts.map +1 -0
- package/dist/{storage → services/storage}/provider-settings-legacy-migration.d.ts +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -0
- package/dist/{storage → services/storage}/provider-settings-manager.d.ts +1 -1
- package/dist/services/storage/provider-settings-manager.d.ts.map +1 -0
- package/dist/{storage → services/storage}/sqlite-session-store.d.ts +3 -3
- package/dist/services/storage/sqlite-session-store.d.ts.map +1 -0
- package/dist/{storage → services/storage}/sqlite-team-store.d.ts +2 -2
- package/dist/services/storage/sqlite-team-store.d.ts.map +1 -0
- package/dist/{storage → services/storage}/team-store.d.ts +1 -1
- package/dist/services/storage/team-store.d.ts.map +1 -0
- package/dist/services/telemetry/ITelemetryAdapter.d.ts.map +1 -0
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts.map +1 -0
- package/dist/services/telemetry/TelemetryService.d.ts.map +1 -0
- package/dist/services/telemetry/core-events.d.ts.map +1 -0
- package/dist/services/telemetry/distinct-id.d.ts.map +1 -0
- package/dist/services/telemetry/index.d.ts.map +1 -0
- package/dist/services/telemetry/index.js +28 -0
- package/dist/{session/utils → services}/usage.d.ts +1 -1
- package/dist/services/usage.d.ts.map +1 -0
- package/dist/services/workspace/file-indexer.d.ts.map +1 -0
- package/dist/services/workspace/index.d.ts.map +1 -0
- package/dist/services/workspace/mention-enricher.d.ts.map +1 -0
- package/dist/services/workspace-manifest.d.ts +16 -0
- package/dist/services/workspace-manifest.d.ts.map +1 -0
- package/dist/session/file-session-service.d.ts +4 -1
- package/dist/session/file-session-service.d.ts.map +1 -1
- package/dist/session/persistence-service.d.ts +15 -25
- package/dist/session/persistence-service.d.ts.map +1 -1
- package/dist/session/session-manifest-store.d.ts +22 -0
- package/dist/session/session-manifest-store.d.ts.map +1 -0
- package/dist/session/session-row.d.ts +93 -0
- package/dist/session/session-row.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +8 -109
- package/dist/session/session-service.d.ts.map +1 -1
- package/dist/session/session-team-coordination.d.ts +4 -4
- package/dist/session/session-team-coordination.d.ts.map +1 -1
- package/dist/session/subagent-session-manager.d.ts +36 -0
- package/dist/session/subagent-session-manager.d.ts.map +1 -0
- package/dist/session/team-persistence-store.d.ts +24 -0
- package/dist/session/team-persistence-store.d.ts.map +1 -0
- package/dist/transports/hub.d.ts +47 -0
- package/dist/transports/hub.d.ts.map +1 -0
- package/dist/{session/default-session-manager.d.ts → transports/local.d.ts} +30 -16
- package/dist/transports/local.d.ts.map +1 -0
- package/dist/transports/remote.d.ts +10 -0
- package/dist/transports/remote.d.ts.map +1 -0
- package/dist/transports/runtime-host-support.d.ts +22 -0
- package/dist/transports/runtime-host-support.d.ts.map +1 -0
- package/dist/{chat → types}/chat-schema.d.ts +10 -12
- package/dist/types/chat-schema.d.ts.map +1 -0
- package/dist/types/config.d.ts +10 -9
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +4 -5
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/{session/utils/types.d.ts → types/session.d.ts} +16 -6
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/sessions.d.ts +19 -0
- package/dist/types/sessions.d.ts.map +1 -1
- package/dist/types/storage.d.ts +1 -3
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types.d.ts +14 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -13
- package/src/ClineCore.ts +183 -85
- package/src/account/index.ts +3 -3
- package/src/account/rpc.ts +12 -12
- package/src/auth/cline.ts +1 -1
- package/src/auth/codex.ts +1 -1
- package/src/auth/oca.ts +1 -1
- package/src/cron/index.ts +5 -0
- package/src/cron/resource-limiter.ts +46 -0
- package/src/cron/schedule-command-service.ts +193 -0
- package/src/cron/schedule-service.ts +703 -0
- package/src/cron/scheduler.ts +637 -0
- package/src/cron/sqlite-schedule-store.ts +708 -0
- package/src/extensions/config/agent-config-loader.ts +18 -12
- package/src/extensions/config/agent-config-parser.ts +1 -1
- package/src/extensions/config/hooks-config-loader.ts +1 -2
- package/src/extensions/config/index.ts +0 -4
- package/src/extensions/config/runtime-commands.ts +6 -0
- package/src/extensions/config/user-instruction-config-loader.ts +1 -4
- package/src/extensions/context/agentic-compaction.ts +3 -3
- package/src/extensions/context/basic-compaction.ts +2 -2
- package/src/extensions/context/compaction-shared.ts +5 -4
- package/src/extensions/context/compaction.ts +3 -3
- package/src/extensions/plugin/plugin-config-loader.ts +17 -2
- package/src/extensions/plugin/plugin-loader.ts +48 -4
- package/src/extensions/plugin/plugin-module-import.ts +0 -2
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +93 -39
- package/src/extensions/plugin/plugin-sandbox.ts +47 -27
- package/src/extensions/plugin/plugin-targeting.ts +32 -0
- package/src/{tools → extensions/tools}/definitions.ts +31 -50
- package/src/{tools → extensions/tools}/executors/apply-patch.ts +69 -80
- package/src/{tools → extensions/tools}/executors/file-read.ts +29 -4
- package/src/{tools → extensions/tools}/executors/search.ts +196 -4
- package/src/{tools → extensions/tools}/index.ts +10 -0
- package/src/{tools → extensions/tools}/model-tool-routing.ts +1 -1
- package/src/{tools → extensions/tools}/presets.ts +31 -47
- package/src/extensions/tools/runtime.ts +261 -0
- package/src/{tools → extensions/tools}/schemas.ts +4 -2
- package/src/{team → extensions/tools/team}/multi-agent.ts +80 -17
- package/src/{team → extensions/tools/team}/spawn-agent-tool.ts +1 -7
- package/src/{team → extensions/tools/team}/subagent-prompts.ts +2 -2
- package/src/{team → extensions/tools/team}/team-tools.ts +84 -53
- package/src/{tools → extensions/tools}/types.ts +5 -3
- package/src/{runtime → hooks}/checkpoint-hooks.ts +27 -0
- package/src/{runtime → hooks}/hook-file-hooks.ts +14 -13
- package/src/hooks/index.ts +0 -7
- package/src/hooks/subprocess-runner.ts +1 -1
- package/src/hooks/subprocess.ts +57 -257
- package/src/hub/browser-websocket.ts +137 -0
- package/src/hub/client.ts +574 -0
- package/src/hub/connect.ts +156 -0
- package/src/hub/daemon-entry.ts +87 -0
- package/src/hub/daemon.ts +181 -0
- package/src/hub/defaults.ts +43 -0
- package/src/hub/discovery.ts +247 -0
- package/src/hub/index.ts +14 -0
- package/src/hub/native-transport.ts +31 -0
- package/src/hub/runtime-handlers.ts +140 -0
- package/src/hub/server.ts +1888 -0
- package/src/hub/session-client.ts +460 -0
- package/src/hub/start-shared-server.ts +58 -0
- package/src/hub/transport.ts +14 -0
- package/src/hub/ui-client.ts +122 -0
- package/src/hub/workspace.ts +19 -0
- package/src/index.ts +264 -199
- package/src/llms/configured-provider-registry.ts +193 -0
- package/src/llms/provider-defaults.ts +637 -0
- package/src/llms/provider-settings.ts +263 -0
- package/src/llms/runtime-config.ts +43 -0
- package/src/llms/runtime-registry.ts +171 -0
- package/src/llms/runtime-types.ts +121 -0
- package/src/runtime/history.ts +237 -0
- package/src/runtime/host.ts +200 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/rules.ts +12 -0
- package/src/runtime/runtime-builder.ts +37 -29
- package/src/runtime/runtime-host.ts +206 -0
- package/src/{session → runtime}/runtime-oauth-token-manager.ts +12 -16
- package/src/runtime/session-runtime.ts +2 -26
- package/src/{session/session-agent-events.ts → services/agent-events.ts} +7 -7
- package/src/services/config.ts +5 -0
- package/src/services/global-settings.ts +122 -0
- package/src/services/local-runtime-bootstrap.ts +318 -0
- package/src/services/plugin-tools.ts +85 -0
- package/src/{providers → services/providers}/local-provider-registry.ts +6 -6
- package/src/{providers → services/providers}/local-provider-service.ts +46 -41
- package/src/{session → services}/session-artifacts.ts +7 -19
- package/src/{session/utils/helpers.ts → services/session-data.ts} +90 -80
- package/src/{session → services}/session-telemetry.ts +7 -9
- package/src/services/storage/artifact-store.ts +1 -0
- package/src/{storage → services/storage}/file-team-store.ts +2 -2
- package/src/{storage → services/storage}/provider-settings-legacy-migration.ts +6 -4
- package/src/{storage → services/storage}/provider-settings-manager.ts +3 -3
- package/src/services/storage/session-store.ts +1 -0
- package/src/{storage → services/storage}/sqlite-session-store.ts +7 -12
- package/src/{storage → services/storage}/sqlite-team-store.ts +4 -4
- package/src/{storage → services/storage}/team-store.ts +1 -1
- package/src/{session/utils → services}/usage.ts +1 -1
- package/src/{input → services/workspace}/file-indexer.ts +26 -2
- package/src/{input → services/workspace}/mention-enricher.ts +1 -1
- package/src/{session → services}/workspace-manifest.ts +18 -0
- package/src/session/file-session-service.ts +10 -8
- package/src/session/index.ts +10 -23
- package/src/session/persistence-service.ts +144 -528
- package/src/session/session-manifest-store.ts +158 -0
- package/src/session/session-row.ts +199 -0
- package/src/session/session-service.ts +43 -389
- package/src/session/session-team-coordination.ts +14 -7
- package/src/session/subagent-session-manager.ts +397 -0
- package/src/session/team-persistence-store.ts +176 -0
- package/src/session/workspace-manager.ts +1 -1
- package/src/transports/hub.ts +656 -0
- package/src/{session/default-session-manager.ts → transports/local.ts} +263 -200
- package/src/transports/remote.ts +26 -0
- package/src/transports/runtime-host-support.ts +140 -0
- package/src/{chat → types}/chat-schema.ts +4 -5
- package/src/types/config.ts +10 -9
- package/src/types/provider-settings.ts +11 -7
- package/src/{session/utils/types.ts → types/session.ts} +16 -5
- package/src/types/sessions.ts +21 -0
- package/src/types/storage.ts +1 -6
- package/src/types.ts +52 -19
- package/dist/chat/chat-schema.d.ts.map +0 -1
- package/dist/hooks/persistent.d.ts +0 -64
- package/dist/hooks/persistent.d.ts.map +0 -1
- package/dist/input/file-indexer.d.ts.map +0 -1
- package/dist/input/index.d.ts.map +0 -1
- package/dist/input/mention-enricher.d.ts.map +0 -1
- package/dist/prompt/default-system.d.ts +0 -2
- package/dist/prompt/default-system.d.ts.map +0 -1
- package/dist/providers/local-provider-registry.d.ts.map +0 -1
- package/dist/providers/local-provider-service.d.ts.map +0 -1
- package/dist/runtime/checkpoint-hooks.d.ts.map +0 -1
- package/dist/runtime/hook-file-hooks.d.ts.map +0 -1
- package/dist/session/default-session-manager.d.ts.map +0 -1
- package/dist/session/rpc-runtime-ensure.d.ts +0 -53
- package/dist/session/rpc-runtime-ensure.d.ts.map +0 -1
- package/dist/session/rpc-session-service.d.ts +0 -13
- package/dist/session/rpc-session-service.d.ts.map +0 -1
- package/dist/session/rpc-spawn-lease.d.ts +0 -8
- package/dist/session/rpc-spawn-lease.d.ts.map +0 -1
- package/dist/session/session-agent-events.d.ts.map +0 -1
- package/dist/session/session-artifacts.d.ts.map +0 -1
- package/dist/session/session-config-builder.d.ts +0 -16
- package/dist/session/session-config-builder.d.ts.map +0 -1
- package/dist/session/session-host.d.ts +0 -15
- package/dist/session/session-host.d.ts.map +0 -1
- package/dist/session/session-manager.d.ts +0 -62
- package/dist/session/session-manager.d.ts.map +0 -1
- package/dist/session/session-telemetry.d.ts.map +0 -1
- package/dist/session/sqlite-rpc-session-backend.d.ts +0 -31
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +0 -1
- package/dist/session/utils/helpers.d.ts.map +0 -1
- package/dist/session/utils/types.d.ts.map +0 -1
- package/dist/session/utils/usage.d.ts.map +0 -1
- package/dist/session/workspace-manifest.d.ts +0 -5
- package/dist/session/workspace-manifest.d.ts.map +0 -1
- package/dist/storage/file-team-store.d.ts.map +0 -1
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +0 -1
- package/dist/storage/provider-settings-manager.d.ts.map +0 -1
- package/dist/storage/sqlite-session-store.d.ts.map +0 -1
- package/dist/storage/sqlite-team-store.d.ts.map +0 -1
- package/dist/storage/team-store.d.ts.map +0 -1
- package/dist/team/delegated-agent.d.ts.map +0 -1
- package/dist/team/index.d.ts.map +0 -1
- package/dist/team/multi-agent.d.ts.map +0 -1
- package/dist/team/projections.d.ts.map +0 -1
- package/dist/team/runtime.d.ts.map +0 -1
- package/dist/team/spawn-agent-tool.d.ts.map +0 -1
- package/dist/team/subagent-prompts.d.ts.map +0 -1
- package/dist/team/team-tools.d.ts.map +0 -1
- package/dist/telemetry/ITelemetryAdapter.d.ts.map +0 -1
- package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +0 -1
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +0 -1
- package/dist/telemetry/TelemetryLoggerSink.d.ts.map +0 -1
- package/dist/telemetry/TelemetryService.d.ts.map +0 -1
- package/dist/telemetry/core-events.d.ts.map +0 -1
- package/dist/telemetry/distinct-id.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -15
- package/dist/tools/constants.d.ts.map +0 -1
- package/dist/tools/definitions.d.ts.map +0 -1
- package/dist/tools/executors/apply-patch-parser.d.ts.map +0 -1
- package/dist/tools/executors/apply-patch.d.ts.map +0 -1
- package/dist/tools/executors/bash.d.ts.map +0 -1
- package/dist/tools/executors/editor.d.ts.map +0 -1
- package/dist/tools/executors/file-read.d.ts.map +0 -1
- package/dist/tools/executors/index.d.ts.map +0 -1
- package/dist/tools/executors/search.d.ts.map +0 -1
- package/dist/tools/executors/web-fetch.d.ts.map +0 -1
- package/dist/tools/helpers.d.ts.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/model-tool-routing.d.ts.map +0 -1
- package/dist/tools/presets.d.ts.map +0 -1
- package/dist/tools/schemas.d.ts.map +0 -1
- package/dist/tools/types.d.ts.map +0 -1
- package/src/ClineCore.test.ts +0 -150
- package/src/account/cline-account-service.test.ts +0 -185
- package/src/account/featurebase-token.test.ts +0 -175
- package/src/account/rpc.test.ts +0 -63
- package/src/auth/bounded-ttl-cache.test.ts +0 -38
- package/src/auth/client.test.ts +0 -69
- package/src/auth/cline.test.ts +0 -267
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/oca.test.ts +0 -340
- package/src/auth/server.test.ts +0 -287
- package/src/auth/utils.test.ts +0 -128
- package/src/extensions/config/agent-config-loader.test.ts +0 -236
- package/src/extensions/config/hooks-config-loader.test.ts +0 -20
- package/src/extensions/config/runtime-commands.test.ts +0 -115
- package/src/extensions/config/unified-config-file-watcher.test.ts +0 -196
- package/src/extensions/config/user-instruction-config-loader.test.ts +0 -246
- package/src/extensions/context/compaction.test.ts +0 -483
- package/src/extensions/mcp/config-loader.test.ts +0 -238
- package/src/extensions/mcp/manager.test.ts +0 -105
- package/src/extensions/plugin/plugin-config-loader.test.ts +0 -182
- package/src/extensions/plugin/plugin-loader.test.ts +0 -292
- package/src/extensions/plugin/plugin-sandbox.test.ts +0 -423
- package/src/hooks/persistent.ts +0 -661
- package/src/input/file-indexer.d.ts +0 -11
- package/src/input/file-indexer.test.ts +0 -127
- package/src/input/mention-enricher.test.ts +0 -85
- package/src/prompt/default-system.ts +0 -21
- package/src/providers/local-provider-service.test.ts +0 -1062
- package/src/runtime/checkpoint-hooks.test.ts +0 -168
- package/src/runtime/hook-file-hooks.test.ts +0 -311
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -242
- package/src/runtime/runtime-builder.test.ts +0 -616
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/session/default-session-manager.e2e.test.ts +0 -384
- package/src/session/default-session-manager.test.ts +0 -2473
- package/src/session/persistence-service.test.ts +0 -241
- package/src/session/rpc-runtime-ensure.ts +0 -521
- package/src/session/rpc-session-service.ts +0 -107
- package/src/session/rpc-spawn-lease.test.ts +0 -49
- package/src/session/rpc-spawn-lease.ts +0 -122
- package/src/session/runtime-oauth-token-manager.test.ts +0 -137
- package/src/session/session-config-builder.ts +0 -172
- package/src/session/session-host.test.ts +0 -89
- package/src/session/session-host.ts +0 -213
- package/src/session/session-manager.ts +0 -74
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/sqlite-rpc-session-backend.ts +0 -303
- package/src/session/utils/helpers.test.ts +0 -160
- package/src/storage/artifact-store.ts +0 -1
- package/src/storage/provider-settings-legacy-migration.test.ts +0 -424
- package/src/storage/provider-settings-manager.test.ts +0 -191
- package/src/storage/session-store.ts +0 -1
- package/src/team/multi-agent.lifecycle.test.ts +0 -201
- package/src/team/spawn-agent-tool.test.ts +0 -387
- package/src/team/team-tools.test.ts +0 -906
- package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/telemetry/OpenTelemetryProvider.test.ts +0 -326
- package/src/telemetry/TelemetryLoggerSink.test.ts +0 -42
- package/src/telemetry/TelemetryService.test.ts +0 -134
- package/src/telemetry/distinct-id.test.ts +0 -57
- package/src/tools/definitions.test.ts +0 -780
- package/src/tools/executors/bash.test.ts +0 -87
- package/src/tools/executors/editor.test.ts +0 -35
- package/src/tools/executors/file-read.test.ts +0 -49
- package/src/tools/model-tool-routing.test.ts +0 -86
- package/src/tools/presets.test.ts +0 -70
- /package/dist/{tools → extensions/tools}/constants.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/apply-patch-parser.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/bash.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/editor.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/file-read.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/index.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/executors/web-fetch.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/helpers.d.ts +0 -0
- /package/dist/{tools → extensions/tools}/schemas.d.ts +0 -0
- /package/dist/{team → extensions/tools/team}/delegated-agent.d.ts +0 -0
- /package/dist/{team → extensions/tools/team}/index.d.ts +0 -0
- /package/dist/{team → extensions/tools/team}/projections.d.ts +0 -0
- /package/dist/{team → extensions/tools/team}/runtime.d.ts +0 -0
- /package/dist/{team → extensions/tools/team}/subagent-prompts.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/ITelemetryAdapter.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/OpenTelemetryAdapter.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/OpenTelemetryProvider.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/TelemetryLoggerSink.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/TelemetryService.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/core-events.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/distinct-id.d.ts +0 -0
- /package/dist/{telemetry → services/telemetry}/index.d.ts +0 -0
- /package/dist/{input → services/workspace}/file-indexer.d.ts +0 -0
- /package/dist/{input → services/workspace}/index.d.ts +0 -0
- /package/dist/{input → services/workspace}/mention-enricher.d.ts +0 -0
- /package/src/{tools → extensions/tools}/constants.ts +0 -0
- /package/src/{tools → extensions/tools}/executors/apply-patch-parser.ts +0 -0
- /package/src/{tools → extensions/tools}/executors/bash.ts +0 -0
- /package/src/{tools → extensions/tools}/executors/editor.ts +0 -0
- /package/src/{tools → extensions/tools}/executors/index.ts +0 -0
- /package/src/{tools → extensions/tools}/executors/web-fetch.ts +0 -0
- /package/src/{tools → extensions/tools}/helpers.ts +0 -0
- /package/src/{team → extensions/tools/team}/delegated-agent.ts +0 -0
- /package/src/{team → extensions/tools/team}/index.ts +0 -0
- /package/src/{team → extensions/tools/team}/projections.ts +0 -0
- /package/src/{team → extensions/tools/team}/runtime.ts +0 -0
- /package/src/{storage → services/storage}/index.ts +0 -0
- /package/src/{telemetry → services/telemetry}/ITelemetryAdapter.ts +0 -0
- /package/src/{telemetry → services/telemetry}/OpenTelemetryAdapter.ts +0 -0
- /package/src/{telemetry → services/telemetry}/OpenTelemetryProvider.ts +0 -0
- /package/src/{telemetry → services/telemetry}/TelemetryLoggerSink.ts +0 -0
- /package/src/{telemetry → services/telemetry}/TelemetryService.ts +0 -0
- /package/src/{telemetry → services/telemetry}/core-events.ts +0 -0
- /package/src/{telemetry → services/telemetry}/distinct-id.ts +0 -0
- /package/src/{telemetry → services/telemetry}/index.ts +0 -0
- /package/src/{input → services/workspace}/index.ts +0 -0
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
* This file runs inside an isolated Node.js child process spawned by
|
|
5
5
|
* {@link SubprocessSandbox}. It receives RPC calls over IPC and dynamically
|
|
6
6
|
* imports plugin modules, wiring up their contributions (tools, commands,
|
|
7
|
-
*
|
|
7
|
+
* message builders, providers) and lifecycle hooks.
|
|
8
8
|
*
|
|
9
9
|
* Because it executes in a separate process it must stay bundle-safe and only
|
|
10
10
|
* depend on local helpers that can be inlined into the sandbox build.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { normalizePluginManifest, type PluginManifest } from "@clinebot/shared";
|
|
13
14
|
import { importPluginModule } from "./plugin-module-import";
|
|
15
|
+
import {
|
|
16
|
+
matchesPluginManifestTargeting,
|
|
17
|
+
type PluginTargeting,
|
|
18
|
+
} from "./plugin-targeting";
|
|
14
19
|
|
|
15
20
|
// ---------------------------------------------------------------------------
|
|
16
21
|
// Types (intentionally minimal – mirrors only what the RPC protocol needs)
|
|
@@ -31,18 +36,6 @@ interface PluginCommand {
|
|
|
31
36
|
handler?: (input: string) => Promise<string>;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
interface PluginShortcut {
|
|
35
|
-
name: string;
|
|
36
|
-
value: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface PluginFlag {
|
|
41
|
-
name: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
defaultValue?: boolean | string | number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
39
|
interface PluginMessageBuilder {
|
|
47
40
|
name: string;
|
|
48
41
|
build: (message: unknown[]) => unknown[]; // Message[]
|
|
@@ -57,16 +50,18 @@ interface PluginProvider {
|
|
|
57
50
|
interface PluginApi {
|
|
58
51
|
registerTool(tool: PluginTool): void;
|
|
59
52
|
registerCommand(command: PluginCommand): void;
|
|
60
|
-
registerShortcut(shortcut: PluginShortcut): void;
|
|
61
|
-
registerFlag(flag: PluginFlag): void;
|
|
62
53
|
registerMessageBuilder(builder: PluginMessageBuilder): void;
|
|
63
54
|
registerProvider(provider: PluginProvider): void;
|
|
64
55
|
}
|
|
65
56
|
|
|
57
|
+
interface PluginSetupCtx {
|
|
58
|
+
workspaceInfo?: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
66
61
|
interface PluginModule {
|
|
67
62
|
name: string;
|
|
68
|
-
manifest:
|
|
69
|
-
setup?: (api: PluginApi) => void | Promise<void>;
|
|
63
|
+
manifest: PluginManifest;
|
|
64
|
+
setup?: (api: PluginApi, ctx: PluginSetupCtx) => void | Promise<void>;
|
|
70
65
|
[hookName: string]: unknown;
|
|
71
66
|
}
|
|
72
67
|
|
|
@@ -86,14 +81,14 @@ interface PluginDescriptor {
|
|
|
86
81
|
pluginId: string;
|
|
87
82
|
pluginPath: string;
|
|
88
83
|
name: string;
|
|
89
|
-
manifest:
|
|
84
|
+
manifest: PluginManifest;
|
|
90
85
|
contributions: {
|
|
91
86
|
tools: ContributionDescriptor[];
|
|
92
87
|
commands: ContributionDescriptor[];
|
|
93
|
-
shortcuts: ContributionDescriptor[];
|
|
94
|
-
flags: ContributionDescriptor[];
|
|
95
88
|
messageBuilders: ContributionDescriptor[];
|
|
96
89
|
providers: ContributionDescriptor[];
|
|
90
|
+
shortcuts?: ContributionDescriptor[];
|
|
91
|
+
flags?: ContributionDescriptor[];
|
|
97
92
|
};
|
|
98
93
|
}
|
|
99
94
|
|
|
@@ -132,6 +127,12 @@ function isObject(value: unknown): value is Record<string, unknown> {
|
|
|
132
127
|
return typeof value === "object" && value !== null;
|
|
133
128
|
}
|
|
134
129
|
|
|
130
|
+
function hasValidStringArray(value: unknown): value is string[] {
|
|
131
|
+
return (
|
|
132
|
+
Array.isArray(value) && value.every((entry) => typeof entry === "string")
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
135
136
|
function assertValidPluginModule(
|
|
136
137
|
plugin: unknown,
|
|
137
138
|
pluginPath: string,
|
|
@@ -145,6 +146,29 @@ function assertValidPluginModule(
|
|
|
145
146
|
if (!isObject(plugin.manifest)) {
|
|
146
147
|
throw new Error(`Invalid plugin manifest: ${pluginPath}`);
|
|
147
148
|
}
|
|
149
|
+
if (
|
|
150
|
+
Object.hasOwn(plugin.manifest, "providerIds") &&
|
|
151
|
+
!hasValidStringArray(plugin.manifest.providerIds)
|
|
152
|
+
) {
|
|
153
|
+
throw new Error(`Invalid plugin manifest.providerIds: ${pluginPath}`);
|
|
154
|
+
}
|
|
155
|
+
if (
|
|
156
|
+
Object.hasOwn(plugin.manifest, "modelIds") &&
|
|
157
|
+
!hasValidStringArray(plugin.manifest.modelIds)
|
|
158
|
+
) {
|
|
159
|
+
throw new Error(`Invalid plugin manifest.modelIds: ${pluginPath}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function assertValidPluginSetupCtx(
|
|
164
|
+
ctx: unknown,
|
|
165
|
+
): asserts ctx is PluginSetupCtx {
|
|
166
|
+
if (!isObject(ctx)) {
|
|
167
|
+
throw new Error("Plugin setup context must be an object");
|
|
168
|
+
}
|
|
169
|
+
if (ctx.workspaceInfo !== undefined && !isObject(ctx.workspaceInfo)) {
|
|
170
|
+
throw new Error("Plugin setup context workspaceInfo must be an object");
|
|
171
|
+
}
|
|
148
172
|
}
|
|
149
173
|
|
|
150
174
|
// ---------------------------------------------------------------------------
|
|
@@ -183,6 +207,16 @@ function emitEvent(name: string, payload?: unknown): void {
|
|
|
183
207
|
// Expose event emitter to plugins.
|
|
184
208
|
(globalThis as Record<string, unknown>).__clinePluginHost = { emitEvent };
|
|
185
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Session workspace env — populated by `initialize()` and available to any
|
|
212
|
+
* plugin code that executes before the setup hook, or cannot use hook context.
|
|
213
|
+
* Prefer using PluginSetupCtx from the setup function when possible.
|
|
214
|
+
*/
|
|
215
|
+
(globalThis as Record<string, unknown>).__clineSessionEnv = {
|
|
216
|
+
cwd: undefined as string | undefined,
|
|
217
|
+
workspaceInfo: undefined as unknown,
|
|
218
|
+
};
|
|
219
|
+
|
|
186
220
|
// ---------------------------------------------------------------------------
|
|
187
221
|
// Helpers
|
|
188
222
|
// ---------------------------------------------------------------------------
|
|
@@ -214,16 +248,44 @@ function getPlugin(pluginId: string): PluginState {
|
|
|
214
248
|
async function initialize(args: {
|
|
215
249
|
pluginPaths?: string[];
|
|
216
250
|
exportName?: string;
|
|
251
|
+
providerId?: string;
|
|
252
|
+
modelId?: string;
|
|
253
|
+
cwd?: string;
|
|
254
|
+
workspaceInfo?: unknown;
|
|
217
255
|
}): Promise<InitializeResult> {
|
|
218
256
|
pluginState.clear();
|
|
219
257
|
pluginCounter = 0;
|
|
220
258
|
contributionCounters.clear();
|
|
221
259
|
|
|
260
|
+
// Apply the session's working directory so that process.cwd() and relative
|
|
261
|
+
// path resolution inside plugins reflect the correct workspace, not the
|
|
262
|
+
// host process's cwd (which may differ when --cwd was used without calling
|
|
263
|
+
// process.chdir() on the host side).
|
|
264
|
+
if (args.cwd) {
|
|
265
|
+
try {
|
|
266
|
+
process.chdir(args.cwd);
|
|
267
|
+
} catch {
|
|
268
|
+
// Ignore — best-effort; path may not exist in unusual environments.
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Keep the global escape-hatch in sync with the active session.
|
|
273
|
+
const sessionEnv = (globalThis as Record<string, unknown>)
|
|
274
|
+
.__clineSessionEnv as Record<string, unknown>;
|
|
275
|
+
if (sessionEnv) {
|
|
276
|
+
sessionEnv.cwd = args.cwd;
|
|
277
|
+
sessionEnv.workspaceInfo = args.workspaceInfo;
|
|
278
|
+
}
|
|
279
|
+
|
|
222
280
|
const descriptors: PluginDescriptor[] = [];
|
|
223
281
|
const failures: PluginInitializationFailure[] = [];
|
|
224
282
|
const warnings: PluginInitializationWarning[] = [];
|
|
225
283
|
const exportName = args.exportName || "plugin";
|
|
226
284
|
const pluginIndexByName = new Map<string, number>();
|
|
285
|
+
const targeting: PluginTargeting = {
|
|
286
|
+
providerId: args.providerId,
|
|
287
|
+
modelId: args.modelId,
|
|
288
|
+
};
|
|
227
289
|
|
|
228
290
|
for (const pluginPath of args.pluginPaths || []) {
|
|
229
291
|
let plugin: PluginModule | undefined;
|
|
@@ -232,15 +294,19 @@ async function initialize(args: {
|
|
|
232
294
|
plugin = (moduleExports.default ??
|
|
233
295
|
moduleExports[exportName]) as unknown as PluginModule;
|
|
234
296
|
assertValidPluginModule(plugin, pluginPath);
|
|
297
|
+
plugin.manifest = normalizePluginManifest(plugin.manifest);
|
|
298
|
+
if (!matchesPluginManifestTargeting(plugin.manifest, targeting)) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
235
301
|
|
|
236
302
|
const pluginId = `plugin_${++pluginCounter}`;
|
|
237
303
|
const contributions: PluginDescriptor["contributions"] = {
|
|
238
304
|
tools: [],
|
|
239
305
|
commands: [],
|
|
240
|
-
shortcuts: [],
|
|
241
|
-
flags: [],
|
|
242
306
|
messageBuilders: [],
|
|
243
307
|
providers: [],
|
|
308
|
+
shortcuts: [],
|
|
309
|
+
flags: [],
|
|
244
310
|
};
|
|
245
311
|
const handlers: PluginState["handlers"] = {
|
|
246
312
|
tools: new Map(),
|
|
@@ -272,22 +338,6 @@ async function initialize(args: {
|
|
|
272
338
|
description: command.description,
|
|
273
339
|
});
|
|
274
340
|
},
|
|
275
|
-
registerShortcut: (shortcut) => {
|
|
276
|
-
contributions.shortcuts.push({
|
|
277
|
-
id: makeId(pluginId, "shortcut"),
|
|
278
|
-
name: shortcut.name,
|
|
279
|
-
value: shortcut.value,
|
|
280
|
-
description: shortcut.description,
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
registerFlag: (flag) => {
|
|
284
|
-
contributions.flags.push({
|
|
285
|
-
id: makeId(pluginId, "flag"),
|
|
286
|
-
name: flag.name,
|
|
287
|
-
description: flag.description,
|
|
288
|
-
defaultValue: flag.defaultValue,
|
|
289
|
-
});
|
|
290
|
-
},
|
|
291
341
|
registerMessageBuilder: (builder) => {
|
|
292
342
|
const id = makeId(pluginId, "builder");
|
|
293
343
|
handlers.messageBuilders.set(id, builder.build);
|
|
@@ -305,7 +355,11 @@ async function initialize(args: {
|
|
|
305
355
|
|
|
306
356
|
if (typeof plugin.setup === "function") {
|
|
307
357
|
try {
|
|
308
|
-
|
|
358
|
+
const setupCtx = {
|
|
359
|
+
workspaceInfo: args.workspaceInfo,
|
|
360
|
+
};
|
|
361
|
+
assertValidPluginSetupCtx(setupCtx);
|
|
362
|
+
await plugin.setup(api, setupCtx);
|
|
309
363
|
} catch (error) {
|
|
310
364
|
failures.push({
|
|
311
365
|
pluginPath,
|
|
@@ -2,17 +2,35 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
AgentConfig,
|
|
7
|
+
HookStage,
|
|
8
|
+
Tool,
|
|
9
|
+
WorkspaceInfo,
|
|
10
|
+
} from "@clinebot/shared";
|
|
6
11
|
import { SubprocessSandbox } from "../../runtime/subprocess-sandbox";
|
|
7
12
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
13
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
8
14
|
|
|
9
|
-
export interface PluginSandboxOptions {
|
|
15
|
+
export interface PluginSandboxOptions extends PluginTargeting {
|
|
10
16
|
pluginPaths: string[];
|
|
11
17
|
exportName?: string;
|
|
12
18
|
importTimeoutMs?: number;
|
|
13
19
|
hookTimeoutMs?: number;
|
|
14
20
|
contributionTimeoutMs?: number;
|
|
15
21
|
onEvent?: (event: { name: string; payload?: unknown }) => void;
|
|
22
|
+
/**
|
|
23
|
+
* The session's working directory. Forwarded to the sandbox subprocess so
|
|
24
|
+
* that `process.cwd()` returns the correct path inside the sandbox even
|
|
25
|
+
* when `--cwd` was passed without calling `process.chdir()` on the host.
|
|
26
|
+
*/
|
|
27
|
+
cwd?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Structured workspace and git metadata (branch, commit, remotes) generated
|
|
30
|
+
* at session startup. Forwarded to plugins via PluginSetupCtx.workspaceInfo
|
|
31
|
+
* so they can inspect git state without running their own commands.
|
|
32
|
+
*/
|
|
33
|
+
workspaceInfo?: WorkspaceInfo;
|
|
16
34
|
}
|
|
17
35
|
|
|
18
36
|
type AgentExtension = NonNullable<AgentConfig["extensions"]>[number];
|
|
@@ -25,8 +43,6 @@ type SandboxedContributionDescriptor = {
|
|
|
25
43
|
inputSchema?: unknown;
|
|
26
44
|
timeoutMs?: number;
|
|
27
45
|
retryable?: boolean;
|
|
28
|
-
value?: string;
|
|
29
|
-
defaultValue?: boolean | string | number;
|
|
30
46
|
metadata?: Record<string, unknown>;
|
|
31
47
|
};
|
|
32
48
|
|
|
@@ -38,10 +54,10 @@ type SandboxedPluginDescriptor = {
|
|
|
38
54
|
contributions: {
|
|
39
55
|
tools: SandboxedContributionDescriptor[];
|
|
40
56
|
commands: SandboxedContributionDescriptor[];
|
|
41
|
-
shortcuts: SandboxedContributionDescriptor[];
|
|
42
|
-
flags: SandboxedContributionDescriptor[];
|
|
43
57
|
messageBuilders: SandboxedContributionDescriptor[];
|
|
44
58
|
providers: SandboxedContributionDescriptor[];
|
|
59
|
+
shortcuts?: SandboxedContributionDescriptor[];
|
|
60
|
+
flags?: SandboxedContributionDescriptor[];
|
|
45
61
|
};
|
|
46
62
|
};
|
|
47
63
|
|
|
@@ -49,6 +65,22 @@ type SandboxedInitializeResult = {
|
|
|
49
65
|
plugins: SandboxedPluginDescriptor[];
|
|
50
66
|
} & PluginLoadDiagnostics;
|
|
51
67
|
|
|
68
|
+
function normalizeDescriptor(
|
|
69
|
+
descriptor: SandboxedPluginDescriptor,
|
|
70
|
+
): SandboxedPluginDescriptor {
|
|
71
|
+
return {
|
|
72
|
+
...descriptor,
|
|
73
|
+
contributions: {
|
|
74
|
+
tools: descriptor.contributions?.tools ?? [],
|
|
75
|
+
commands: descriptor.contributions?.commands ?? [],
|
|
76
|
+
messageBuilders: descriptor.contributions?.messageBuilders ?? [],
|
|
77
|
+
providers: descriptor.contributions?.providers ?? [],
|
|
78
|
+
shortcuts: descriptor.contributions?.shortcuts ?? [],
|
|
79
|
+
flags: descriptor.contributions?.flags ?? [],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
52
84
|
function isUnknownPluginIdError(error: unknown): boolean {
|
|
53
85
|
const message = error instanceof Error ? error.message : String(error);
|
|
54
86
|
return message.includes("Unknown sandbox plugin id:");
|
|
@@ -181,6 +213,10 @@ export async function loadSandboxedPlugins(
|
|
|
181
213
|
const initArgs = {
|
|
182
214
|
pluginPaths: options.pluginPaths,
|
|
183
215
|
exportName: options.exportName,
|
|
216
|
+
providerId: options.providerId,
|
|
217
|
+
modelId: options.modelId,
|
|
218
|
+
cwd: options.cwd,
|
|
219
|
+
workspaceInfo: options.workspaceInfo,
|
|
184
220
|
};
|
|
185
221
|
|
|
186
222
|
// Guard against concurrent re-initialization when multiple tools/hooks
|
|
@@ -208,7 +244,7 @@ export async function loadSandboxedPlugins(
|
|
|
208
244
|
});
|
|
209
245
|
throw error;
|
|
210
246
|
}
|
|
211
|
-
const descriptors = initialized.plugins;
|
|
247
|
+
const descriptors = initialized.plugins.map(normalizeDescriptor);
|
|
212
248
|
|
|
213
249
|
const extensions: NonNullable<AgentConfig["extensions"]> = descriptors.map(
|
|
214
250
|
(descriptor) => {
|
|
@@ -267,7 +303,7 @@ function registerTools(
|
|
|
267
303
|
timeoutMs: number,
|
|
268
304
|
reinitialize: () => Promise<void>,
|
|
269
305
|
): void {
|
|
270
|
-
for (const td of descriptor.contributions
|
|
306
|
+
for (const td of descriptor.contributions?.tools ?? []) {
|
|
271
307
|
const tool: Tool = {
|
|
272
308
|
name: td.name,
|
|
273
309
|
description: td.description ?? "",
|
|
@@ -318,7 +354,7 @@ function registerCommands(
|
|
|
318
354
|
timeoutMs: number,
|
|
319
355
|
reinitialize: () => Promise<void>,
|
|
320
356
|
): void {
|
|
321
|
-
for (const cd of descriptor.contributions
|
|
357
|
+
for (const cd of descriptor.contributions?.commands ?? []) {
|
|
322
358
|
api.registerCommand({
|
|
323
359
|
name: cd.name,
|
|
324
360
|
description: cd.description,
|
|
@@ -357,30 +393,14 @@ function registerSimpleContributions(
|
|
|
357
393
|
api: AgentExtensionApi,
|
|
358
394
|
descriptor: SandboxedPluginDescriptor,
|
|
359
395
|
): void {
|
|
360
|
-
for (const
|
|
361
|
-
api.registerShortcut({
|
|
362
|
-
name: sd.name,
|
|
363
|
-
value: sd.value ?? "",
|
|
364
|
-
description: sd.description,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
for (const fd of descriptor.contributions.flags) {
|
|
369
|
-
api.registerFlag({
|
|
370
|
-
name: fd.name,
|
|
371
|
-
description: fd.description,
|
|
372
|
-
defaultValue: fd.defaultValue,
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
for (const rd of descriptor.contributions.messageBuilders) {
|
|
396
|
+
for (const rd of descriptor.contributions?.messageBuilders ?? []) {
|
|
377
397
|
api.registerMessageBuilder({
|
|
378
398
|
name: rd.name,
|
|
379
399
|
build: (m) => m,
|
|
380
400
|
});
|
|
381
401
|
}
|
|
382
402
|
|
|
383
|
-
for (const pd of descriptor.contributions
|
|
403
|
+
for (const pd of descriptor.contributions?.providers ?? []) {
|
|
384
404
|
api.registerProvider({
|
|
385
405
|
name: pd.name,
|
|
386
406
|
description: pd.description,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PluginManifest } from "@clinebot/shared";
|
|
2
|
+
|
|
3
|
+
export interface PluginTargeting {
|
|
4
|
+
providerId?: string;
|
|
5
|
+
modelId?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function matchesPluginManifestTargeting(
|
|
9
|
+
manifest: PluginManifest | undefined,
|
|
10
|
+
targeting: PluginTargeting | undefined,
|
|
11
|
+
): boolean {
|
|
12
|
+
if (!manifest) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (manifest.providerIds?.length) {
|
|
17
|
+
if (
|
|
18
|
+
!targeting?.providerId ||
|
|
19
|
+
!manifest.providerIds.includes(targeting.providerId)
|
|
20
|
+
) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (manifest.modelIds?.length) {
|
|
26
|
+
if (!targeting?.modelId || !manifest.modelIds.includes(targeting.modelId)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
@@ -81,7 +81,7 @@ export function createReadFilesTool(
|
|
|
81
81
|
return createTool<ReadFilesInput, ToolOperationResult[]>({
|
|
82
82
|
name: "read_files",
|
|
83
83
|
description:
|
|
84
|
-
"Read the full content of text files at the provided absolute paths, or return only an inclusive one-based line range when start_line/end_line are provided. " +
|
|
84
|
+
"Read the full content of text or image files at the provided absolute paths, or return only an inclusive one-based line range when start_line/end_line are provided. " +
|
|
85
85
|
"Returns file contents or error messages for each path.",
|
|
86
86
|
inputSchema: zodToJsonSchema(ReadFilesInputSchema),
|
|
87
87
|
timeoutMs: timeoutMs * 2, // Account for multiple files
|
|
@@ -350,67 +350,48 @@ export function createWebFetchTool(
|
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
const APPLY_PATCH_TOOL_DESC = `
|
|
353
|
+
const APPLY_PATCH_TOOL_DESC = `Use \`apply_patch\` to edit files with the canonical freeform patch grammar. Pass the patch text directly as the \`input\` string. Prefer the exact format below:
|
|
354
354
|
|
|
355
|
-
%%bash
|
|
356
|
-
apply_patch <<"EOF"
|
|
357
355
|
*** Begin Patch
|
|
358
|
-
|
|
356
|
+
*** Update File: path/to/file.ts
|
|
357
|
+
@@ optional section marker
|
|
358
|
+
[context before]
|
|
359
|
+
-[old line]
|
|
360
|
+
+[new line]
|
|
361
|
+
[context after]
|
|
359
362
|
*** End Patch
|
|
360
|
-
EOF
|
|
361
363
|
|
|
362
|
-
|
|
364
|
+
Supported actions:
|
|
365
|
+
- \`*** Add File: <path>\`
|
|
366
|
+
- \`*** Update File: <path>\`
|
|
367
|
+
- \`*** Delete File: <path>\`
|
|
368
|
+
- optional \`*** Move to: <new path>\` immediately after an Update File header
|
|
363
369
|
|
|
364
|
-
|
|
370
|
+
Rules:
|
|
371
|
+
- In an Add File section, every file-content line must start with \`+\`.
|
|
372
|
+
- In an Update section, use context lines plus \`-\` and \`+\` lines to describe the change.
|
|
373
|
+
- Use \`@@\` markers when extra context is needed to disambiguate repeated code blocks.
|
|
374
|
+
- Do not use line numbers; this format is context-based.
|
|
375
|
+
- Prefer sending the patch body directly. Legacy shell wrappers such as \`%%bash\` and \`apply_patch <<"EOF"\` are accepted for compatibility but are not preferred.
|
|
365
376
|
|
|
366
|
-
|
|
367
|
-
In a Update/Delete section, repeat the following for each snippet of code that needs to be changed:
|
|
368
|
-
[context_before] -> See below for further instructions on context.
|
|
369
|
-
- [old_code] -> Precede the old code with a minus sign.
|
|
370
|
-
+ [new_code] -> Precede the new, replacement code with a plus sign.
|
|
371
|
-
[context_after] -> See below for further instructions on context.
|
|
377
|
+
Example:
|
|
372
378
|
|
|
373
|
-
For instructions on [context_before] and [context_after]:
|
|
374
|
-
- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
|
|
375
|
-
- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
|
|
376
|
-
@@ class BaseClass
|
|
377
|
-
[3 lines of pre-context]
|
|
378
|
-
- [old_code]
|
|
379
|
-
+ [new_code]
|
|
380
|
-
[3 lines of post-context]
|
|
381
|
-
|
|
382
|
-
- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple \`@@\` statements to jump to the right context. For instance:
|
|
383
|
-
|
|
384
|
-
@@ class BaseClass
|
|
385
|
-
@@ def method():
|
|
386
|
-
[3 lines of pre-context]
|
|
387
|
-
- [old_code]
|
|
388
|
-
+ [new_code]
|
|
389
|
-
[3 lines of post-context]
|
|
390
|
-
|
|
391
|
-
Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
|
|
392
|
-
|
|
393
|
-
%%bash
|
|
394
|
-
apply_patch <<"EOF"
|
|
395
379
|
*** Begin Patch
|
|
396
|
-
*** Update File:
|
|
397
|
-
@@
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
*** End Patch
|
|
408
|
-
EOF`;
|
|
380
|
+
*** Update File: src/page.tsx
|
|
381
|
+
@@
|
|
382
|
+
return (
|
|
383
|
+
<div>
|
|
384
|
+
<button onClick={() => console.log("clicked")}>Click me</button>
|
|
385
|
+
+ <button onClick={() => console.log("cancel clicked")}>Cancel</button>
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
*** End Patch`;
|
|
409
390
|
|
|
410
391
|
/**
|
|
411
392
|
* Create the apply_patch tool
|
|
412
393
|
*
|
|
413
|
-
* Applies the
|
|
394
|
+
* Applies the canonical apply_patch format to one or more files.
|
|
414
395
|
*/
|
|
415
396
|
export function createApplyPatchTool(
|
|
416
397
|
executor: ApplyPatchExecutor,
|