@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
package/src/ClineCore.ts
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AgentConfig,
|
|
3
|
+
BasicLogger,
|
|
3
4
|
ITelemetryService,
|
|
4
5
|
ToolApprovalRequest,
|
|
5
6
|
ToolApprovalResult,
|
|
6
7
|
} from "@clinebot/shared";
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
import type { ToolExecutors } from "./extensions/tools";
|
|
9
|
+
import { hydrateSessionHistory } from "./runtime/history";
|
|
10
|
+
import type { SessionBackend } from "./runtime/host";
|
|
11
|
+
import { createRuntimeHost } from "./runtime/host";
|
|
12
|
+
import type {
|
|
13
|
+
LocalRuntimeStartOptions,
|
|
14
|
+
RuntimeHost,
|
|
15
|
+
RuntimeHostMode,
|
|
16
|
+
RuntimeHostSubscribeOptions,
|
|
17
|
+
StartSessionInput,
|
|
18
|
+
StartSessionResult,
|
|
19
|
+
} from "./runtime/runtime-host";
|
|
20
|
+
import { splitCoreSessionConfig } from "./runtime/runtime-host";
|
|
21
|
+
import type { CoreSessionConfig } from "./types/config";
|
|
22
|
+
import type { CoreSessionEvent } from "./types/events";
|
|
23
|
+
import type { SessionMessagesArtifactUploader } from "./types/session";
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
export interface HubOptions {
|
|
26
|
+
endpoint?: string;
|
|
27
|
+
authToken?: string;
|
|
28
|
+
strategy?: "prefer-hub" | "require-hub";
|
|
29
|
+
clientType?: string;
|
|
30
|
+
displayName?: string;
|
|
31
|
+
workspaceRoot?: string;
|
|
32
|
+
cwd?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RemoteOptions {
|
|
36
|
+
endpoint: string;
|
|
37
|
+
authToken?: string;
|
|
38
|
+
clientType?: string;
|
|
39
|
+
displayName?: string;
|
|
40
|
+
workspaceRoot?: string;
|
|
41
|
+
cwd?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type { RuntimeHostMode };
|
|
45
|
+
|
|
46
|
+
export interface ClineCoreStartInput
|
|
47
|
+
extends Omit<StartSessionInput, "config" | "localRuntime"> {
|
|
48
|
+
config: CoreSessionConfig;
|
|
49
|
+
localRuntime?: LocalRuntimeStartOptions;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
export interface ClineCoreOptions {
|
|
@@ -49,17 +62,23 @@ export interface ClineCoreOptions {
|
|
|
49
62
|
*/
|
|
50
63
|
distinctId?: string;
|
|
51
64
|
/**
|
|
52
|
-
* Controls how the
|
|
53
|
-
* - `"auto"` (default) —
|
|
54
|
-
*
|
|
55
|
-
* - `"
|
|
56
|
-
* - `"
|
|
65
|
+
* Controls how the runtime host is selected:
|
|
66
|
+
* - `"auto"` (default) — prefers a compatible local hub when one is available and falls
|
|
67
|
+
* back to local in-process execution when not.
|
|
68
|
+
* - `"hub"` — requires a compatible websocket hub runtime; throws if one is not reachable.
|
|
69
|
+
* - `"remote"` — requires an explicit remote websocket hub endpoint.
|
|
70
|
+
* - `"local"` — always uses local in-process execution and local SQLite/file storage.
|
|
57
71
|
*/
|
|
58
|
-
backendMode?:
|
|
72
|
+
backendMode?: RuntimeHostMode;
|
|
59
73
|
/**
|
|
60
|
-
*
|
|
74
|
+
* Hub runtime connection options. Used when `backendMode` is `"hub"` or when `"auto"`
|
|
75
|
+
* should prefer a shared local hub if available.
|
|
61
76
|
*/
|
|
62
|
-
|
|
77
|
+
hub?: HubOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Remote hub connection options. Only relevant when `backendMode` is `"remote"`.
|
|
80
|
+
*/
|
|
81
|
+
remote?: RemoteOptions;
|
|
63
82
|
/**
|
|
64
83
|
* Override one or more default tool executors (e.g. file I/O, shell, browser).
|
|
65
84
|
* Partial — only the keys you supply are replaced; the rest use built-in implementations.
|
|
@@ -70,6 +89,11 @@ export interface ClineCoreOptions {
|
|
|
70
89
|
* If omitted, telemetry is a no-op.
|
|
71
90
|
*/
|
|
72
91
|
telemetry?: ITelemetryService;
|
|
92
|
+
/**
|
|
93
|
+
* Optional structured logger for core-side operational diagnostics such as
|
|
94
|
+
* runtime-host selection and fallback decisions.
|
|
95
|
+
*/
|
|
96
|
+
logger?: BasicLogger;
|
|
73
97
|
/**
|
|
74
98
|
* Per-tool approval policies that control whether a tool runs automatically,
|
|
75
99
|
* requires user confirmation, or is blocked entirely.
|
|
@@ -83,29 +107,45 @@ export interface ClineCoreOptions {
|
|
|
83
107
|
requestToolApproval?: (
|
|
84
108
|
request: ToolApprovalRequest,
|
|
85
109
|
) => Promise<ToolApprovalResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Optional hook invoked after `messages.json` is persisted to disk.
|
|
112
|
+
* Consumers can use this to mirror session transcripts into remote storage.
|
|
113
|
+
*/
|
|
114
|
+
messagesArtifactUploader?: SessionMessagesArtifactUploader;
|
|
115
|
+
/**
|
|
116
|
+
* Custom `fetch` implementation forwarded to the AI gateway providers used
|
|
117
|
+
* by local sessions. When supplied, it is threaded into each
|
|
118
|
+
* `ProviderConfig.fetch` built during session bootstrap, which in turn
|
|
119
|
+
* populates `GatewayProviderSettings.fetch` (and the top-level
|
|
120
|
+
* `GatewayConfig.fetch` fallback) so hosts can inject custom HTTP behavior
|
|
121
|
+
* such as proxies, retries, tracing, or test doubles.
|
|
122
|
+
*
|
|
123
|
+
* Per-session or per-provider overrides still win: an explicit
|
|
124
|
+
* `config.fetch` on `CoreSessionConfig` or a stored provider-level `fetch`
|
|
125
|
+
* takes precedence over this default.
|
|
126
|
+
*
|
|
127
|
+
* Applies only to sessions executed in this process (local and fallback-
|
|
128
|
+
* to-local auto mode). For hub and remote runtimes the HTTP call happens
|
|
129
|
+
* inside the process that owns the gateway, so configure `fetch` there:
|
|
130
|
+
* - `startHubServer({ fetch })` / `ensureHubServer({ fetch })` from
|
|
131
|
+
* `@clinebot/hub`
|
|
132
|
+
* - `createLocalHubScheduleRuntimeHandlers({ fetch })` from
|
|
133
|
+
* `@clinebot/core/hub` for the scheduler
|
|
134
|
+
*/
|
|
135
|
+
fetch?: typeof fetch;
|
|
86
136
|
/**
|
|
87
137
|
* An already-constructed session backend to use instead of resolving one automatically.
|
|
88
138
|
* Intended for testing or embedding a custom persistence layer.
|
|
89
139
|
* @internal
|
|
90
140
|
*/
|
|
91
141
|
sessionService?: SessionBackend;
|
|
92
|
-
/**
|
|
93
|
-
* Factory that creates team management tools for the multi-agent team system.
|
|
94
|
-
* When provided, team tools are registered whenever `enableAgentTeams` is `true`
|
|
95
|
-
* on a session config.
|
|
96
|
-
*
|
|
97
|
-
* Consumers that depend on `@clinebot/enterprise` can pass
|
|
98
|
-
* `bootstrapAgentTeams` here directly.
|
|
99
|
-
*/
|
|
100
|
-
teamToolsFactory?: TeamToolsFactory;
|
|
101
142
|
/**
|
|
102
143
|
* Optional hook invoked before each session starts.
|
|
103
144
|
* Use this to prepare workspace-scoped runtime state and then return an
|
|
104
|
-
* adapter that mutates the
|
|
105
|
-
* builds the runtime.
|
|
145
|
+
* adapter that mutates the shared session input before core starts the run.
|
|
106
146
|
*/
|
|
107
147
|
prepare?: (
|
|
108
|
-
input:
|
|
148
|
+
input: ClineCoreStartInput,
|
|
109
149
|
) =>
|
|
110
150
|
| Promise<StartSessionBootstrap | undefined>
|
|
111
151
|
| StartSessionBootstrap
|
|
@@ -114,8 +154,8 @@ export interface ClineCoreOptions {
|
|
|
114
154
|
|
|
115
155
|
export interface StartSessionBootstrap {
|
|
116
156
|
applyToStartSessionInput(
|
|
117
|
-
input:
|
|
118
|
-
): Promise<
|
|
157
|
+
input: ClineCoreStartInput,
|
|
158
|
+
): Promise<ClineCoreStartInput> | ClineCoreStartInput;
|
|
119
159
|
dispose?(): Promise<void> | void;
|
|
120
160
|
}
|
|
121
161
|
|
|
@@ -130,11 +170,12 @@ export interface StartSessionBootstrap {
|
|
|
130
170
|
* const session = await cline.start({ ... });
|
|
131
171
|
* ```
|
|
132
172
|
*/
|
|
133
|
-
export class ClineCore implements
|
|
173
|
+
export class ClineCore implements RuntimeHost {
|
|
134
174
|
readonly clientName: string | undefined;
|
|
135
|
-
|
|
175
|
+
readonly runtimeAddress: string | undefined;
|
|
176
|
+
private readonly host: RuntimeHost;
|
|
136
177
|
private readonly prepare: ClineCoreOptions["prepare"] | undefined;
|
|
137
|
-
private readonly
|
|
178
|
+
private readonly defaultToolExecutors: Partial<ToolExecutors> | undefined;
|
|
138
179
|
private readonly activeSessionBootstraps = new Map<
|
|
139
180
|
string,
|
|
140
181
|
StartSessionBootstrap
|
|
@@ -142,15 +183,17 @@ export class ClineCore implements SessionHost {
|
|
|
142
183
|
private readonly unsubscribeBootstrapCleanup: () => void;
|
|
143
184
|
|
|
144
185
|
private constructor(
|
|
145
|
-
host:
|
|
186
|
+
host: RuntimeHost,
|
|
146
187
|
clientName: string | undefined,
|
|
188
|
+
runtimeAddress: string | undefined,
|
|
147
189
|
prepare: ClineCoreOptions["prepare"],
|
|
148
|
-
|
|
190
|
+
defaultToolExecutors: Partial<ToolExecutors> | undefined,
|
|
149
191
|
) {
|
|
150
192
|
this.clientName = clientName;
|
|
193
|
+
this.runtimeAddress = runtimeAddress;
|
|
151
194
|
this.host = host;
|
|
152
195
|
this.prepare = prepare;
|
|
153
|
-
this.
|
|
196
|
+
this.defaultToolExecutors = defaultToolExecutors;
|
|
154
197
|
this.unsubscribeBootstrapCleanup = this.host.subscribe((event) => {
|
|
155
198
|
if (event.type !== "ended") {
|
|
156
199
|
return;
|
|
@@ -160,12 +203,13 @@ export class ClineCore implements SessionHost {
|
|
|
160
203
|
}
|
|
161
204
|
|
|
162
205
|
static async create(options: ClineCoreOptions = {}): Promise<ClineCore> {
|
|
163
|
-
const host = await
|
|
206
|
+
const host = await createRuntimeHost(options);
|
|
164
207
|
return new ClineCore(
|
|
165
208
|
host,
|
|
166
209
|
options.clientName,
|
|
210
|
+
host.runtimeAddress,
|
|
167
211
|
options.prepare,
|
|
168
|
-
options.
|
|
212
|
+
options.defaultToolExecutors,
|
|
169
213
|
);
|
|
170
214
|
}
|
|
171
215
|
|
|
@@ -178,16 +222,66 @@ export class ClineCore implements SessionHost {
|
|
|
178
222
|
await Promise.resolve(bootstrap.dispose?.());
|
|
179
223
|
}
|
|
180
224
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
225
|
+
private toClineCoreStartInput(
|
|
226
|
+
input: StartSessionInput | ClineCoreStartInput,
|
|
227
|
+
): ClineCoreStartInput {
|
|
228
|
+
const config = input.config as CoreSessionConfig;
|
|
229
|
+
return "providerId" in config
|
|
230
|
+
? {
|
|
231
|
+
...input,
|
|
232
|
+
config: {
|
|
233
|
+
...config,
|
|
234
|
+
...(input.localRuntime?.configOverrides ?? {}),
|
|
235
|
+
},
|
|
236
|
+
localRuntime: input.localRuntime
|
|
237
|
+
? {
|
|
238
|
+
...input.localRuntime,
|
|
239
|
+
configOverrides: input.localRuntime.configOverrides,
|
|
240
|
+
}
|
|
241
|
+
: undefined,
|
|
242
|
+
}
|
|
243
|
+
: (input as ClineCoreStartInput);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private normalizeStartInput(input: ClineCoreStartInput): StartSessionInput {
|
|
247
|
+
const split = splitCoreSessionConfig(input.config);
|
|
248
|
+
const localRuntime =
|
|
249
|
+
split.localRuntime || input.localRuntime || this.defaultToolExecutors
|
|
250
|
+
? {
|
|
251
|
+
...(split.localRuntime ?? {}),
|
|
252
|
+
...(input.localRuntime ?? {}),
|
|
253
|
+
configOverrides: {
|
|
254
|
+
...(split.localRuntime?.configOverrides ?? {}),
|
|
255
|
+
...(input.localRuntime?.configOverrides ?? {}),
|
|
256
|
+
},
|
|
257
|
+
defaultToolExecutors: {
|
|
258
|
+
...(this.defaultToolExecutors ?? {}),
|
|
259
|
+
...(split.localRuntime?.defaultToolExecutors ?? {}),
|
|
260
|
+
...(input.localRuntime?.defaultToolExecutors ?? {}),
|
|
261
|
+
},
|
|
262
|
+
}
|
|
263
|
+
: undefined;
|
|
264
|
+
return {
|
|
265
|
+
...input,
|
|
266
|
+
...split,
|
|
267
|
+
...(localRuntime ? { localRuntime } : {}),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
start(input: StartSessionInput): Promise<StartSessionResult>;
|
|
272
|
+
start(input: ClineCoreStartInput): Promise<StartSessionResult>;
|
|
273
|
+
async start(
|
|
274
|
+
input: StartSessionInput | ClineCoreStartInput,
|
|
275
|
+
): Promise<StartSessionResult> {
|
|
276
|
+
const clineCoreInput = this.toClineCoreStartInput(input);
|
|
277
|
+
const bootstrap = await this.prepare?.(clineCoreInput);
|
|
186
278
|
try {
|
|
187
|
-
const
|
|
188
|
-
? await bootstrap.applyToStartSessionInput(
|
|
189
|
-
:
|
|
190
|
-
const result = await this.host.start(
|
|
279
|
+
const preparedInput = bootstrap
|
|
280
|
+
? await bootstrap.applyToStartSessionInput(clineCoreInput)
|
|
281
|
+
: clineCoreInput;
|
|
282
|
+
const result = await this.host.start(
|
|
283
|
+
this.normalizeStartInput(preparedInput),
|
|
284
|
+
);
|
|
191
285
|
if (bootstrap) {
|
|
192
286
|
const activeSession = await this.host.get(result.sessionId);
|
|
193
287
|
if (activeSession) {
|
|
@@ -201,16 +295,16 @@ export class ClineCore implements SessionHost {
|
|
|
201
295
|
await Promise.resolve(bootstrap?.dispose?.());
|
|
202
296
|
throw error;
|
|
203
297
|
}
|
|
204
|
-
}
|
|
205
|
-
send:
|
|
206
|
-
getAccumulatedUsage:
|
|
298
|
+
}
|
|
299
|
+
send: RuntimeHost["send"] = (...args) => this.host.send(...args);
|
|
300
|
+
getAccumulatedUsage: RuntimeHost["getAccumulatedUsage"] = (...args) =>
|
|
207
301
|
this.host.getAccumulatedUsage(...args);
|
|
208
|
-
abort:
|
|
209
|
-
stop:
|
|
302
|
+
abort: RuntimeHost["abort"] = (...args) => this.host.abort(...args);
|
|
303
|
+
stop: RuntimeHost["stop"] = async (sessionId) => {
|
|
210
304
|
await this.host.stop(sessionId);
|
|
211
305
|
await this.disposeSessionBootstrap(sessionId);
|
|
212
306
|
};
|
|
213
|
-
dispose:
|
|
307
|
+
dispose: RuntimeHost["dispose"] = async (...args) => {
|
|
214
308
|
try {
|
|
215
309
|
await this.host.dispose(...args);
|
|
216
310
|
} finally {
|
|
@@ -221,23 +315,27 @@ export class ClineCore implements SessionHost {
|
|
|
221
315
|
);
|
|
222
316
|
}
|
|
223
317
|
};
|
|
224
|
-
get:
|
|
225
|
-
list:
|
|
226
|
-
|
|
318
|
+
get: RuntimeHost["get"] = (...args) => this.host.get(...args);
|
|
319
|
+
list: RuntimeHost["list"] = async (limit = 200) =>
|
|
320
|
+
await hydrateSessionHistory(this.host, await this.host.list(limit));
|
|
321
|
+
delete: RuntimeHost["delete"] = async (sessionId) => {
|
|
227
322
|
const deleted = await this.host.delete(sessionId);
|
|
228
323
|
if (deleted) {
|
|
229
324
|
await this.disposeSessionBootstrap(sessionId);
|
|
230
325
|
}
|
|
231
326
|
return deleted;
|
|
232
327
|
};
|
|
233
|
-
|
|
328
|
+
update: RuntimeHost["update"] = (...args) => this.host.update(...args);
|
|
329
|
+
readMessages: RuntimeHost["readMessages"] = (...args) =>
|
|
234
330
|
this.host.readMessages(...args);
|
|
235
|
-
|
|
236
|
-
this.host.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
331
|
+
handleHookEvent: RuntimeHost["handleHookEvent"] = (...args) =>
|
|
332
|
+
this.host.handleHookEvent(...args);
|
|
333
|
+
subscribe(
|
|
334
|
+
listener: (event: CoreSessionEvent) => void,
|
|
335
|
+
options?: RuntimeHostSubscribeOptions,
|
|
336
|
+
): () => void {
|
|
337
|
+
return this.host.subscribe(listener, options);
|
|
338
|
+
}
|
|
339
|
+
updateSessionModel: RuntimeHost["updateSessionModel"] = (...args) =>
|
|
242
340
|
this.host.updateSessionModel?.(...args) ?? Promise.resolve();
|
|
243
341
|
}
|
package/src/account/index.ts
CHANGED
|
@@ -4,10 +4,10 @@ export {
|
|
|
4
4
|
} from "./cline-account-service";
|
|
5
5
|
export {
|
|
6
6
|
type ClineAccountOperations,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
executeClineAccountAction,
|
|
8
|
+
isClineAccountActionRequest,
|
|
9
|
+
type ProviderActionExecutor,
|
|
9
10
|
RpcClineAccountService,
|
|
10
|
-
type RpcProviderActionExecutor,
|
|
11
11
|
} from "./rpc";
|
|
12
12
|
export type {
|
|
13
13
|
ClineAccountBalance,
|
package/src/account/rpc.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ClineAccountActionRequest,
|
|
3
|
+
ProviderActionRequest,
|
|
4
4
|
} from "@clinebot/shared";
|
|
5
5
|
import type {
|
|
6
6
|
ClineAccountBalance,
|
|
@@ -34,14 +34,14 @@ export interface ClineAccountOperations {
|
|
|
34
34
|
fetchFeaturebaseToken?(): Promise<FeaturebaseTokenResponse | undefined>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function
|
|
38
|
-
request:
|
|
39
|
-
): request is
|
|
37
|
+
export function isClineAccountActionRequest(
|
|
38
|
+
request: ProviderActionRequest,
|
|
39
|
+
): request is ClineAccountActionRequest {
|
|
40
40
|
return request.action === "clineAccount";
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export async function
|
|
44
|
-
request:
|
|
43
|
+
export async function executeClineAccountAction(
|
|
44
|
+
request: ClineAccountActionRequest,
|
|
45
45
|
service: ClineAccountOperations,
|
|
46
46
|
): Promise<unknown> {
|
|
47
47
|
switch (request.operation) {
|
|
@@ -76,16 +76,16 @@ export async function executeRpcClineAccountAction(
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export interface
|
|
80
|
-
runProviderAction(request:
|
|
79
|
+
export interface ProviderActionExecutor {
|
|
80
|
+
runProviderAction(request: ProviderActionRequest): Promise<{
|
|
81
81
|
result: unknown;
|
|
82
82
|
}>;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export class RpcClineAccountService implements ClineAccountOperations {
|
|
86
|
-
private readonly executor:
|
|
86
|
+
private readonly executor: ProviderActionExecutor;
|
|
87
87
|
|
|
88
|
-
constructor(executor:
|
|
88
|
+
constructor(executor: ProviderActionExecutor) {
|
|
89
89
|
this.executor = executor;
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -178,7 +178,7 @@ export class RpcClineAccountService implements ClineAccountOperations {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
private async request<T>(request:
|
|
181
|
+
private async request<T>(request: ClineAccountActionRequest): Promise<T> {
|
|
182
182
|
const response = await this.executor.runProviderAction(request);
|
|
183
183
|
return response.result as T;
|
|
184
184
|
}
|
package/src/auth/cline.ts
CHANGED
package/src/auth/codex.ts
CHANGED
package/src/auth/oca.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
captureAuthStarted,
|
|
7
7
|
captureAuthSucceeded,
|
|
8
8
|
identifyAccount,
|
|
9
|
-
} from "../telemetry/core-events";
|
|
9
|
+
} from "../services/telemetry/core-events";
|
|
10
10
|
import { BoundedTtlCache } from "./bounded-ttl-cache";
|
|
11
11
|
import { startLocalOAuthServer } from "./server";
|
|
12
12
|
import type {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class ResourceLimiter {
|
|
2
|
+
private readonly globalMaxConcurrency: number;
|
|
3
|
+
private readonly activeExecutions = new Map<string, Set<string>>();
|
|
4
|
+
|
|
5
|
+
constructor(globalMaxConcurrency: number) {
|
|
6
|
+
this.globalMaxConcurrency = Math.max(1, Math.floor(globalMaxConcurrency));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public acquire(
|
|
10
|
+
scheduleId: string,
|
|
11
|
+
executionId: string,
|
|
12
|
+
maxParallel: number,
|
|
13
|
+
): boolean {
|
|
14
|
+
if (this.getGlobalActiveCount() >= this.globalMaxConcurrency) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const perScheduleLimit = Math.max(1, Math.floor(maxParallel));
|
|
18
|
+
const scheduleExecutions =
|
|
19
|
+
this.activeExecutions.get(scheduleId) ?? new Set<string>();
|
|
20
|
+
if (scheduleExecutions.size >= perScheduleLimit) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
scheduleExecutions.add(executionId);
|
|
24
|
+
this.activeExecutions.set(scheduleId, scheduleExecutions);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public release(scheduleId: string, executionId: string): void {
|
|
29
|
+
const executions = this.activeExecutions.get(scheduleId);
|
|
30
|
+
if (!executions) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
executions.delete(executionId);
|
|
34
|
+
if (executions.size === 0) {
|
|
35
|
+
this.activeExecutions.delete(scheduleId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public getGlobalActiveCount(): number {
|
|
40
|
+
let total = 0;
|
|
41
|
+
for (const executions of this.activeExecutions.values()) {
|
|
42
|
+
total += executions.size;
|
|
43
|
+
}
|
|
44
|
+
return total;
|
|
45
|
+
}
|
|
46
|
+
}
|