@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
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { BoundedTtlCache } from "./bounded-ttl-cache";
|
|
3
|
-
|
|
4
|
-
describe("BoundedTtlCache", () => {
|
|
5
|
-
it("returns undefined after TTL", () => {
|
|
6
|
-
const cache = new BoundedTtlCache(1_000, 10);
|
|
7
|
-
cache.set("a", "one", 0);
|
|
8
|
-
expect(cache.get("a", 500)).toBe("one");
|
|
9
|
-
expect(cache.get("a", 1_500)).toBeUndefined();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("evicts oldest entries when over max size", () => {
|
|
13
|
-
const cache = new BoundedTtlCache(60_000, 2);
|
|
14
|
-
cache.set("a", "1", 0);
|
|
15
|
-
cache.set("b", "2", 0);
|
|
16
|
-
cache.set("c", "3", 0);
|
|
17
|
-
expect(cache.get("a", 0)).toBeUndefined();
|
|
18
|
-
expect(cache.get("b", 0)).toBe("2");
|
|
19
|
-
expect(cache.get("c", 0)).toBe("3");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("refreshes recency on get so hot keys survive eviction", () => {
|
|
23
|
-
const cache = new BoundedTtlCache(60_000, 2);
|
|
24
|
-
cache.set("a", "1", 0);
|
|
25
|
-
cache.set("b", "2", 0);
|
|
26
|
-
expect(cache.get("a", 0)).toBe("1");
|
|
27
|
-
cache.set("c", "3", 0);
|
|
28
|
-
expect(cache.get("a", 0)).toBe("1");
|
|
29
|
-
expect(cache.get("b", 0)).toBeUndefined();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("supports per-entry TTL override", () => {
|
|
33
|
-
const cache = new BoundedTtlCache(60_000, 2);
|
|
34
|
-
cache.set("short", "v", 0, 1_000);
|
|
35
|
-
expect(cache.get("short", 500)).toBe("v");
|
|
36
|
-
expect(cache.get("short", 1_500)).toBeUndefined();
|
|
37
|
-
});
|
|
38
|
-
});
|
package/src/auth/client.test.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { createOAuthClientCallbacks } from "./client";
|
|
3
|
-
|
|
4
|
-
describe("auth/client createOAuthClientCallbacks", () => {
|
|
5
|
-
it("emits instructions and URL and forwards prompts", async () => {
|
|
6
|
-
const onOutput = vi.fn();
|
|
7
|
-
const onPrompt = vi.fn().mockResolvedValue("value");
|
|
8
|
-
const callbacks = createOAuthClientCallbacks({ onOutput, onPrompt });
|
|
9
|
-
|
|
10
|
-
callbacks.onAuth({
|
|
11
|
-
url: "https://example.com/auth",
|
|
12
|
-
instructions: "Open your browser",
|
|
13
|
-
});
|
|
14
|
-
const answer = await callbacks.onPrompt({ message: "Enter code" });
|
|
15
|
-
|
|
16
|
-
expect(answer).toBe("value");
|
|
17
|
-
expect(onPrompt).toHaveBeenCalledWith({ message: "Enter code" });
|
|
18
|
-
expect(onOutput).toHaveBeenNthCalledWith(1, "Open your browser");
|
|
19
|
-
expect(onOutput).toHaveBeenNthCalledWith(2, "https://example.com/auth");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("tries opening URL and reports opener errors", async () => {
|
|
23
|
-
const openUrl = vi.fn().mockRejectedValue(new Error("failed"));
|
|
24
|
-
const onOpenUrlError = vi.fn();
|
|
25
|
-
const callbacks = createOAuthClientCallbacks({
|
|
26
|
-
onPrompt: vi.fn().mockResolvedValue(""),
|
|
27
|
-
openUrl,
|
|
28
|
-
onOpenUrlError,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
callbacks.onAuth({ url: "https://example.com/auth" });
|
|
32
|
-
await Promise.resolve();
|
|
33
|
-
|
|
34
|
-
expect(openUrl).toHaveBeenCalledWith("https://example.com/auth");
|
|
35
|
-
expect(onOpenUrlError).toHaveBeenCalledTimes(1);
|
|
36
|
-
expect(onOpenUrlError.mock.calls[0]?.[0]).toMatchObject({
|
|
37
|
-
url: "https://example.com/auth",
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("forwards onServerListening to the returned callbacks", () => {
|
|
42
|
-
const onServerListening = vi.fn();
|
|
43
|
-
const callbacks = createOAuthClientCallbacks({
|
|
44
|
-
onPrompt: vi.fn().mockResolvedValue(""),
|
|
45
|
-
onServerListening,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
expect(callbacks.onServerListening).toBe(onServerListening);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("forwards onServerClose to the returned callbacks", () => {
|
|
52
|
-
const onServerClose = vi.fn();
|
|
53
|
-
const callbacks = createOAuthClientCallbacks({
|
|
54
|
-
onPrompt: vi.fn().mockResolvedValue(""),
|
|
55
|
-
onServerClose,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
expect(callbacks.onServerClose).toBe(onServerClose);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("leaves onServerListening and onServerClose undefined when not provided", () => {
|
|
62
|
-
const callbacks = createOAuthClientCallbacks({
|
|
63
|
-
onPrompt: vi.fn().mockResolvedValue(""),
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
expect(callbacks.onServerListening).toBeUndefined();
|
|
67
|
-
expect(callbacks.onServerClose).toBeUndefined();
|
|
68
|
-
});
|
|
69
|
-
});
|
package/src/auth/cline.test.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { ClineOAuthCredentials } from "./cline";
|
|
3
|
-
import { getValidClineCredentials, loginClineOAuth } from "./cline";
|
|
4
|
-
|
|
5
|
-
const PROVIDER_OPTIONS = {
|
|
6
|
-
apiBaseUrl: "https://auth.example.com",
|
|
7
|
-
};
|
|
8
|
-
const ORIGINAL_FETCH = globalThis.fetch;
|
|
9
|
-
|
|
10
|
-
function createCredentials(
|
|
11
|
-
overrides: Partial<ClineOAuthCredentials> = {},
|
|
12
|
-
): ClineOAuthCredentials {
|
|
13
|
-
return {
|
|
14
|
-
access: "access-old",
|
|
15
|
-
refresh: "refresh-old",
|
|
16
|
-
expires: 0,
|
|
17
|
-
accountId: "acct-1",
|
|
18
|
-
email: "user@example.com",
|
|
19
|
-
metadata: { provider: "google" },
|
|
20
|
-
...overrides,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
describe("auth/cline getValidClineCredentials", () => {
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
vi.restoreAllMocks();
|
|
27
|
-
globalThis.fetch = ORIGINAL_FETCH;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("returns existing credentials when not expired", async () => {
|
|
31
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(10_000);
|
|
32
|
-
const current = createCredentials({ expires: 400_000 });
|
|
33
|
-
const fetchMock = vi.fn();
|
|
34
|
-
globalThis.fetch = fetchMock as unknown as typeof fetch;
|
|
35
|
-
|
|
36
|
-
const result = await getValidClineCredentials(current, PROVIDER_OPTIONS);
|
|
37
|
-
expect(result).toBe(current);
|
|
38
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
39
|
-
nowSpy.mockRestore();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("refreshes expired credentials", async () => {
|
|
43
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
44
|
-
const current = createCredentials({ expires: 101_000 });
|
|
45
|
-
const fetchMock = vi.fn(
|
|
46
|
-
async () =>
|
|
47
|
-
new Response(
|
|
48
|
-
JSON.stringify({
|
|
49
|
-
success: true,
|
|
50
|
-
data: {
|
|
51
|
-
accessToken: "access-new",
|
|
52
|
-
refreshToken: "refresh-new",
|
|
53
|
-
tokenType: "Bearer",
|
|
54
|
-
expiresAt: "2030-01-01T00:00:00.000Z",
|
|
55
|
-
userInfo: {
|
|
56
|
-
subject: "sub-1",
|
|
57
|
-
email: "new@example.com",
|
|
58
|
-
name: "New User",
|
|
59
|
-
clineUserId: "acct-2",
|
|
60
|
-
accounts: [],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
65
|
-
),
|
|
66
|
-
);
|
|
67
|
-
globalThis.fetch = fetchMock as unknown as typeof fetch;
|
|
68
|
-
|
|
69
|
-
const result = await getValidClineCredentials(current, PROVIDER_OPTIONS);
|
|
70
|
-
expect(result).toMatchObject({
|
|
71
|
-
access: "access-new",
|
|
72
|
-
refresh: "refresh-new",
|
|
73
|
-
accountId: "acct-2",
|
|
74
|
-
email: "new@example.com",
|
|
75
|
-
});
|
|
76
|
-
nowSpy.mockRestore();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("returns null when refresh fails with invalid_grant", async () => {
|
|
80
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
81
|
-
const current = createCredentials({ expires: 101_000 });
|
|
82
|
-
globalThis.fetch = vi.fn(
|
|
83
|
-
async () =>
|
|
84
|
-
new Response(
|
|
85
|
-
JSON.stringify({
|
|
86
|
-
error: "invalid_grant",
|
|
87
|
-
error_description: "refresh expired",
|
|
88
|
-
}),
|
|
89
|
-
{
|
|
90
|
-
status: 401,
|
|
91
|
-
headers: { "Content-Type": "application/json" },
|
|
92
|
-
},
|
|
93
|
-
),
|
|
94
|
-
) as unknown as typeof fetch;
|
|
95
|
-
|
|
96
|
-
const result = await getValidClineCredentials(current, PROVIDER_OPTIONS);
|
|
97
|
-
expect(result).toBeNull();
|
|
98
|
-
nowSpy.mockRestore();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("keeps current credentials on transient refresh error while token remains valid", async () => {
|
|
102
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
103
|
-
const current = createCredentials({ expires: 150_000 });
|
|
104
|
-
globalThis.fetch = vi.fn(
|
|
105
|
-
async () =>
|
|
106
|
-
new Response(
|
|
107
|
-
JSON.stringify({
|
|
108
|
-
error: "server_error",
|
|
109
|
-
error_description: "temporary issue",
|
|
110
|
-
}),
|
|
111
|
-
{
|
|
112
|
-
status: 500,
|
|
113
|
-
headers: { "Content-Type": "application/json" },
|
|
114
|
-
},
|
|
115
|
-
),
|
|
116
|
-
) as unknown as typeof fetch;
|
|
117
|
-
|
|
118
|
-
const result = await getValidClineCredentials(current, PROVIDER_OPTIONS, {
|
|
119
|
-
refreshBufferMs: 60_000,
|
|
120
|
-
retryableTokenGraceMs: 30_000,
|
|
121
|
-
});
|
|
122
|
-
expect(result).toBe(current);
|
|
123
|
-
nowSpy.mockRestore();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("auth/cline loginClineOAuth", () => {
|
|
128
|
-
afterEach(() => {
|
|
129
|
-
vi.restoreAllMocks();
|
|
130
|
-
globalThis.fetch = ORIGINAL_FETCH;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("completes WorkOS device auth and registers tokens", async () => {
|
|
134
|
-
const fetchMock = vi
|
|
135
|
-
.fn()
|
|
136
|
-
.mockResolvedValueOnce(
|
|
137
|
-
new Response(
|
|
138
|
-
JSON.stringify({
|
|
139
|
-
device_code: "dev-code-1",
|
|
140
|
-
user_code: "ABCD-EFGH",
|
|
141
|
-
verification_uri: "https://example.com/device",
|
|
142
|
-
verification_uri_complete:
|
|
143
|
-
"https://example.com/device?user_code=ABCD-EFGH",
|
|
144
|
-
expires_in: 300,
|
|
145
|
-
interval: 1,
|
|
146
|
-
}),
|
|
147
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
148
|
-
),
|
|
149
|
-
)
|
|
150
|
-
.mockResolvedValueOnce(
|
|
151
|
-
new Response(
|
|
152
|
-
JSON.stringify({
|
|
153
|
-
access_token: "workos-access",
|
|
154
|
-
refresh_token: "workos-refresh",
|
|
155
|
-
token_type: "Bearer",
|
|
156
|
-
expires_in: 3600,
|
|
157
|
-
}),
|
|
158
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
159
|
-
),
|
|
160
|
-
)
|
|
161
|
-
.mockResolvedValueOnce(
|
|
162
|
-
new Response(
|
|
163
|
-
JSON.stringify({
|
|
164
|
-
success: true,
|
|
165
|
-
data: {
|
|
166
|
-
accessToken: "cline-access",
|
|
167
|
-
refreshToken: "cline-refresh",
|
|
168
|
-
tokenType: "Bearer",
|
|
169
|
-
expiresAt: "2030-01-01T00:00:00.000Z",
|
|
170
|
-
userInfo: {
|
|
171
|
-
subject: "sub-1",
|
|
172
|
-
email: "user@example.com",
|
|
173
|
-
name: "User",
|
|
174
|
-
clineUserId: "acct-1",
|
|
175
|
-
accounts: ["acct-1"],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
}),
|
|
179
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
180
|
-
),
|
|
181
|
-
);
|
|
182
|
-
globalThis.fetch = fetchMock as unknown as typeof fetch;
|
|
183
|
-
|
|
184
|
-
const onAuth = vi.fn();
|
|
185
|
-
const credentials = await loginClineOAuth({
|
|
186
|
-
apiBaseUrl: "https://api.cline.bot",
|
|
187
|
-
useWorkOSDeviceAuth: true,
|
|
188
|
-
callbacks: {
|
|
189
|
-
onAuth,
|
|
190
|
-
onPrompt: async () => "",
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(onAuth).toHaveBeenCalledTimes(1);
|
|
195
|
-
expect(onAuth.mock.calls[0]?.[0]).toMatchObject({
|
|
196
|
-
url: "https://example.com/device?user_code=ABCD-EFGH",
|
|
197
|
-
});
|
|
198
|
-
expect(credentials).toMatchObject({
|
|
199
|
-
access: "cline-access",
|
|
200
|
-
refresh: "cline-refresh",
|
|
201
|
-
accountId: "acct-1",
|
|
202
|
-
email: "user@example.com",
|
|
203
|
-
});
|
|
204
|
-
expect(fetchMock).toHaveBeenCalledTimes(3);
|
|
205
|
-
const registerCallBody = JSON.parse(
|
|
206
|
-
String(fetchMock.mock.calls[2]?.[1]?.body ?? "{}"),
|
|
207
|
-
);
|
|
208
|
-
const deviceAuthBody = String(fetchMock.mock.calls[0]?.[1]?.body ?? "");
|
|
209
|
-
const deviceAuthParams = new URLSearchParams(deviceAuthBody);
|
|
210
|
-
expect(deviceAuthParams.get("client_id")).toMatch(/client_.*/);
|
|
211
|
-
expect(registerCallBody).toMatchObject({
|
|
212
|
-
accessToken: "workos-access",
|
|
213
|
-
refreshToken: "workos-refresh",
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("uses legacy callback OAuth flow by default", async () => {
|
|
218
|
-
const fetchMock = vi.fn(async (_url: string, init?: RequestInit) => {
|
|
219
|
-
const body =
|
|
220
|
-
typeof init?.body === "string"
|
|
221
|
-
? (JSON.parse(init.body) as Record<string, unknown>)
|
|
222
|
-
: {};
|
|
223
|
-
if (body.grant_type === "authorization_code") {
|
|
224
|
-
return new Response(
|
|
225
|
-
JSON.stringify({
|
|
226
|
-
success: true,
|
|
227
|
-
data: {
|
|
228
|
-
accessToken: "legacy-access",
|
|
229
|
-
refreshToken: "legacy-refresh",
|
|
230
|
-
tokenType: "Bearer",
|
|
231
|
-
expiresAt: "2030-01-01T00:00:00.000Z",
|
|
232
|
-
userInfo: {
|
|
233
|
-
subject: "sub-legacy",
|
|
234
|
-
email: "legacy@example.com",
|
|
235
|
-
name: "Legacy User",
|
|
236
|
-
clineUserId: "acct-legacy",
|
|
237
|
-
accounts: ["acct-legacy"],
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
}),
|
|
241
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
return new Response("not-found", { status: 404 });
|
|
245
|
-
});
|
|
246
|
-
globalThis.fetch = fetchMock as unknown as typeof fetch;
|
|
247
|
-
|
|
248
|
-
const credentials = await loginClineOAuth({
|
|
249
|
-
apiBaseUrl: "https://api.cline.bot",
|
|
250
|
-
callbackPorts: [48801],
|
|
251
|
-
callbacks: {
|
|
252
|
-
onAuth: () => {},
|
|
253
|
-
onPrompt: async () => "http://127.0.0.1:48801/auth?code=legacy-code",
|
|
254
|
-
onManualCodeInput: async () =>
|
|
255
|
-
"http://127.0.0.1:48801/auth?code=legacy-code",
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
expect(credentials).toMatchObject({
|
|
260
|
-
access: "legacy-access",
|
|
261
|
-
refresh: "legacy-refresh",
|
|
262
|
-
accountId: "acct-legacy",
|
|
263
|
-
email: "legacy@example.com",
|
|
264
|
-
});
|
|
265
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
266
|
-
});
|
|
267
|
-
});
|
package/src/auth/codex.test.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
getValidOpenAICodexCredentials,
|
|
4
|
-
normalizeOpenAICodexCredentials,
|
|
5
|
-
refreshOpenAICodexToken,
|
|
6
|
-
} from "./codex";
|
|
7
|
-
import type { OAuthCredentials } from "./types";
|
|
8
|
-
|
|
9
|
-
function toBase64Url(value: string): string {
|
|
10
|
-
return Buffer.from(value, "utf8").toString("base64url");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function createJwt(payload: Record<string, unknown>): string {
|
|
14
|
-
return `${toBase64Url(JSON.stringify({ alg: "none", typ: "JWT" }))}.${toBase64Url(JSON.stringify(payload))}.sig`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function createCredentials(
|
|
18
|
-
overrides: Partial<OAuthCredentials> = {},
|
|
19
|
-
): OAuthCredentials {
|
|
20
|
-
return {
|
|
21
|
-
access: "access-old",
|
|
22
|
-
refresh: "refresh-old",
|
|
23
|
-
expires: 0,
|
|
24
|
-
accountId: "acct-old",
|
|
25
|
-
email: "old@example.com",
|
|
26
|
-
metadata: { provider: "openai-codex" },
|
|
27
|
-
...overrides,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe("auth/codex token lifecycle", () => {
|
|
32
|
-
afterEach(() => {
|
|
33
|
-
vi.unstubAllGlobals();
|
|
34
|
-
vi.restoreAllMocks();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns current credentials when not expired", async () => {
|
|
38
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(10_000);
|
|
39
|
-
const current = createCredentials({ expires: 400_000 });
|
|
40
|
-
const fetchMock = vi.fn();
|
|
41
|
-
vi.stubGlobal("fetch", fetchMock);
|
|
42
|
-
|
|
43
|
-
const result = await getValidOpenAICodexCredentials(current);
|
|
44
|
-
expect(result).toBe(current);
|
|
45
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
46
|
-
nowSpy.mockRestore();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("refreshes expired credentials and preserves provider metadata", async () => {
|
|
50
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
51
|
-
const idToken = createJwt({
|
|
52
|
-
"https://api.openai.com/auth": { chatgpt_account_id: "acct-new" },
|
|
53
|
-
email: "new@example.com",
|
|
54
|
-
});
|
|
55
|
-
const accessToken = createJwt({
|
|
56
|
-
"https://api.openai.com/auth": { chatgpt_account_id: "acct-new" },
|
|
57
|
-
});
|
|
58
|
-
vi.stubGlobal(
|
|
59
|
-
"fetch",
|
|
60
|
-
vi.fn(
|
|
61
|
-
async () =>
|
|
62
|
-
new Response(
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
access_token: accessToken,
|
|
65
|
-
refresh_token: "refresh-new",
|
|
66
|
-
expires_in: 3600,
|
|
67
|
-
email: "new@example.com",
|
|
68
|
-
id_token: idToken,
|
|
69
|
-
}),
|
|
70
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
71
|
-
),
|
|
72
|
-
),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const current = createCredentials({ expires: 110_000 });
|
|
76
|
-
const result = await getValidOpenAICodexCredentials(current);
|
|
77
|
-
expect(result).toMatchObject({
|
|
78
|
-
access: accessToken,
|
|
79
|
-
refresh: "refresh-new",
|
|
80
|
-
accountId: "acct-new",
|
|
81
|
-
email: "new@example.com",
|
|
82
|
-
metadata: { provider: "openai-codex" },
|
|
83
|
-
});
|
|
84
|
-
nowSpy.mockRestore();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("returns null on invalid_grant refresh errors", async () => {
|
|
88
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
89
|
-
vi.stubGlobal(
|
|
90
|
-
"fetch",
|
|
91
|
-
vi.fn(
|
|
92
|
-
async () =>
|
|
93
|
-
new Response(
|
|
94
|
-
JSON.stringify({
|
|
95
|
-
error: "invalid_grant",
|
|
96
|
-
error_description: "token revoked",
|
|
97
|
-
}),
|
|
98
|
-
{
|
|
99
|
-
status: 400,
|
|
100
|
-
headers: { "Content-Type": "application/json" },
|
|
101
|
-
},
|
|
102
|
-
),
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const result = await getValidOpenAICodexCredentials(
|
|
107
|
-
createCredentials({ expires: 120_000 }),
|
|
108
|
-
);
|
|
109
|
-
expect(result).toBeNull();
|
|
110
|
-
nowSpy.mockRestore();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("keeps current credentials on non-invalid transient refresh failures when still valid", async () => {
|
|
114
|
-
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(100_000);
|
|
115
|
-
vi.stubGlobal(
|
|
116
|
-
"fetch",
|
|
117
|
-
vi.fn(
|
|
118
|
-
async () =>
|
|
119
|
-
new Response(
|
|
120
|
-
JSON.stringify({
|
|
121
|
-
error: "server_error",
|
|
122
|
-
error_description: "try again",
|
|
123
|
-
}),
|
|
124
|
-
{
|
|
125
|
-
status: 500,
|
|
126
|
-
headers: { "Content-Type": "application/json" },
|
|
127
|
-
},
|
|
128
|
-
),
|
|
129
|
-
),
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const current = createCredentials({ expires: 150_000 });
|
|
133
|
-
const result = await getValidOpenAICodexCredentials(current, {
|
|
134
|
-
refreshBufferMs: 60_000,
|
|
135
|
-
retryableTokenGraceMs: 30_000,
|
|
136
|
-
});
|
|
137
|
-
expect(result).toBe(current);
|
|
138
|
-
nowSpy.mockRestore();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("normalizes credentials by deriving accountId from access token", () => {
|
|
142
|
-
const accessToken = createJwt({
|
|
143
|
-
"https://api.openai.com/auth": { chatgpt_account_id: "acct-derived" },
|
|
144
|
-
});
|
|
145
|
-
const normalized = normalizeOpenAICodexCredentials({
|
|
146
|
-
access: accessToken,
|
|
147
|
-
refresh: "refresh",
|
|
148
|
-
expires: 1,
|
|
149
|
-
});
|
|
150
|
-
expect(normalized.accountId).toBe("acct-derived");
|
|
151
|
-
expect(normalized.metadata).toMatchObject({ provider: "openai-codex" });
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("refreshOpenAICodexToken throws when response is structurally invalid", async () => {
|
|
155
|
-
vi.stubGlobal(
|
|
156
|
-
"fetch",
|
|
157
|
-
vi.fn(
|
|
158
|
-
async () =>
|
|
159
|
-
new Response(JSON.stringify({ access_token: "only-access" }), {
|
|
160
|
-
status: 200,
|
|
161
|
-
headers: { "Content-Type": "application/json" },
|
|
162
|
-
}),
|
|
163
|
-
),
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
await expect(refreshOpenAICodexToken("refresh")).rejects.toThrow(
|
|
167
|
-
"Failed to refresh OpenAI Codex token",
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
});
|