@cline/core 0.0.38-nightly.1778113663
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 +108 -0
- package/dist/ClineCore.d.ts +282 -0
- package/dist/account/cline-account-service.d.ts +37 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +40 -0
- package/dist/account/types.d.ts +98 -0
- package/dist/auth/bounded-ttl-cache.d.ts +13 -0
- package/dist/auth/client.d.ts +30 -0
- package/dist/auth/cline.d.ts +64 -0
- package/dist/auth/codex.d.ts +43 -0
- package/dist/auth/oca.d.ts +28 -0
- package/dist/auth/server.d.ts +54 -0
- package/dist/auth/types.d.ts +103 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/cline-core/automation.d.ts +34 -0
- package/dist/cline-core/runtime-services.d.ts +5 -0
- package/dist/cline-core/start-input.d.ts +10 -0
- package/dist/cline-core/telemetry.d.ts +10 -0
- package/dist/cline-core/types.d.ts +221 -0
- package/dist/cron/events/cron-event-ingress.d.ts +37 -0
- package/dist/cron/reports/cron-report-writer.d.ts +40 -0
- package/dist/cron/runner/cron-materializer.d.ts +35 -0
- package/dist/cron/runner/cron-runner.d.ts +45 -0
- package/dist/cron/runner/resource-limiter.d.ts +8 -0
- package/dist/cron/schedule/scheduler.d.ts +12 -0
- package/dist/cron/service/cron-service.d.ts +56 -0
- package/dist/cron/service/schedule-command-service.d.ts +9 -0
- package/dist/cron/service/schedule-service.d.ts +98 -0
- package/dist/cron/specs/cron-reconciler.d.ts +61 -0
- package/dist/cron/specs/cron-spec-parser.d.ts +26 -0
- package/dist/cron/specs/cron-watcher.d.ts +22 -0
- package/dist/cron/store/cron-schema.d.ts +2 -0
- package/dist/cron/store/sqlite-cron-store.d.ts +240 -0
- package/dist/extensions/config/index.d.ts +7 -0
- package/dist/extensions/config/runtime-commands.d.ts +11 -0
- package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts +77 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts +64 -0
- package/dist/extensions/config/user-instruction-plugin.d.ts +25 -0
- package/dist/extensions/config/user-instruction-service.d.ts +23 -0
- package/dist/extensions/context/agentic-compaction.d.ts +12 -0
- package/dist/extensions/context/basic-compaction.d.ts +8 -0
- package/dist/extensions/context/compaction-shared.d.ts +60 -0
- package/dist/extensions/context/compaction.d.ts +24 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/mcp/client.d.ts +2 -0
- package/dist/extensions/mcp/config-loader.d.ts +15 -0
- package/dist/extensions/mcp/index.d.ts +8 -0
- package/dist/extensions/mcp/manager.d.ts +23 -0
- package/dist/extensions/mcp/name-transform.d.ts +2 -0
- package/dist/extensions/mcp/policies.d.ts +14 -0
- package/dist/extensions/mcp/tools.d.ts +3 -0
- package/dist/extensions/mcp/types.d.ts +94 -0
- package/dist/extensions/plugin/plugin-config-loader.d.ts +40 -0
- package/dist/extensions/plugin/plugin-load-report.d.ts +18 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +22 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +4 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +36 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts +6 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -0
- package/dist/extensions/tools/constants.d.ts +24 -0
- package/dist/extensions/tools/definitions.d.ts +102 -0
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/extensions/tools/executors/apply-patch.d.ts +28 -0
- package/dist/extensions/tools/executors/bash.d.ts +49 -0
- package/dist/extensions/tools/executors/editor.d.ts +31 -0
- package/dist/extensions/tools/executors/file-read.d.ts +40 -0
- package/dist/extensions/tools/executors/index.d.ts +50 -0
- package/dist/extensions/tools/executors/search.d.ts +50 -0
- package/dist/extensions/tools/executors/web-fetch.d.ts +58 -0
- package/dist/extensions/tools/helpers.d.ts +15 -0
- package/dist/extensions/tools/index.d.ts +59 -0
- package/dist/extensions/tools/model-tool-routing.d.ts +33 -0
- package/dist/extensions/tools/presets.d.ts +132 -0
- package/dist/extensions/tools/runtime.d.ts +24 -0
- package/dist/extensions/tools/schemas.d.ts +241 -0
- package/dist/extensions/tools/team/delegated-agent.d.ts +43 -0
- package/dist/extensions/tools/team/index.d.ts +2 -0
- package/dist/extensions/tools/team/multi-agent.d.ts +230 -0
- package/dist/extensions/tools/team/projections.d.ts +8 -0
- package/dist/extensions/tools/team/runtime.d.ts +4 -0
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts +83 -0
- package/dist/extensions/tools/team/subagent-prompts.d.ts +3 -0
- package/dist/extensions/tools/team/team-tools.d.ts +35 -0
- package/dist/extensions/tools/types.d.ts +254 -0
- package/dist/hooks/checkpoint-hooks.d.ts +45 -0
- package/dist/hooks/hook-extension.d.ts +2 -0
- package/dist/hooks/hook-file-config.d.ts +24 -0
- package/dist/hooks/hook-file-hooks.d.ts +21 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/subprocess-runner.d.ts +21 -0
- package/dist/hooks/subprocess.d.ts +68 -0
- package/dist/hub/client/connect.d.ts +14 -0
- package/dist/hub/client/index.d.ts +88 -0
- package/dist/hub/client/session-client.d.ts +118 -0
- package/dist/hub/client/ui-client.d.ts +45 -0
- package/dist/hub/daemon/entry.d.ts +1 -0
- package/dist/hub/daemon/entry.js +720 -0
- package/dist/hub/daemon/index.d.ts +8 -0
- package/dist/hub/daemon/runtime-handlers.d.ts +12 -0
- package/dist/hub/daemon/start-shared-server.d.ts +18 -0
- package/dist/hub/discovery/defaults.d.ts +16 -0
- package/dist/hub/discovery/index.d.ts +30 -0
- package/dist/hub/discovery/workspace.d.ts +3 -0
- package/dist/hub/index.d.ts +32 -0
- package/dist/hub/index.js +717 -0
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +73 -0
- package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
- package/dist/hub/server/browser-websocket.d.ts +17 -0
- package/dist/hub/server/command-transport.d.ts +7 -0
- package/dist/hub/server/handlers/approval-handlers.d.ts +17 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
- package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/context.d.ts +56 -0
- package/dist/hub/server/handlers/run-handlers.d.ts +5 -0
- package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
- package/dist/hub/server/handlers/session-handlers.d.ts +20 -0
- package/dist/hub/server/hub-client-contributions.d.ts +19 -0
- package/dist/hub/server/hub-notifications.d.ts +7 -0
- package/dist/hub/server/hub-schedule-events.d.ts +2 -0
- package/dist/hub/server/hub-server-logging.d.ts +2 -0
- package/dist/hub/server/hub-server-options.d.ts +55 -0
- package/dist/hub/server/hub-server-transport.d.ts +34 -0
- package/dist/hub/server/hub-session-records.d.ts +8 -0
- package/dist/hub/server/hub-websocket-server.d.ts +6 -0
- package/dist/hub/server/index.d.ts +4 -0
- package/dist/hub/server/native-transport.d.ts +16 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +715 -0
- package/dist/runtime/capabilities/index.d.ts +2 -0
- package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
- package/dist/runtime/capabilities/runtime-capabilities.d.ts +6 -0
- package/dist/runtime/config/agent-message-codec.d.ts +6 -0
- package/dist/runtime/config/agent-runtime-config-builder.d.ts +87 -0
- package/dist/runtime/host/history.d.ts +18 -0
- package/dist/runtime/host/host.d.ts +7 -0
- package/dist/runtime/host/local/agent-event-bridge.d.ts +29 -0
- package/dist/runtime/host/local/session-record.d.ts +6 -0
- package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
- package/dist/runtime/host/local/spawn-tool.d.ts +15 -0
- package/dist/runtime/host/local/user-files.d.ts +1 -0
- package/dist/runtime/host/local-runtime-host.d.ts +119 -0
- package/dist/runtime/host/runtime-host-support.d.ts +20 -0
- package/dist/runtime/host/runtime-host.d.ts +163 -0
- package/dist/runtime/orchestration/runtime-builder.d.ts +6 -0
- package/dist/runtime/orchestration/runtime-event-adapter.d.ts +101 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +30 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +218 -0
- package/dist/runtime/orchestration/session-runtime.d.ts +58 -0
- package/dist/runtime/orchestration/user-input-builder.d.ts +15 -0
- package/dist/runtime/safety/loop-detection.d.ts +58 -0
- package/dist/runtime/safety/mistake-tracker.d.ts +68 -0
- package/dist/runtime/safety/rules.d.ts +6 -0
- package/dist/runtime/tools/subprocess-sandbox.d.ts +43 -0
- package/dist/runtime/tools/tool-approval.d.ts +9 -0
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +64 -0
- package/dist/services/agent-events.d.ts +33 -0
- package/dist/services/config.d.ts +2 -0
- package/dist/services/global-settings.d.ts +34 -0
- package/dist/services/llms/cline-recommended-models.d.ts +19 -0
- package/dist/services/llms/configured-provider-registry.d.ts +27 -0
- package/dist/services/llms/handler-factory.d.ts +3 -0
- package/dist/services/llms/provider-defaults.d.ts +28 -0
- package/dist/services/llms/provider-settings.d.ts +247 -0
- package/dist/services/llms/runtime-config.d.ts +3 -0
- package/dist/services/llms/runtime-registry.d.ts +19 -0
- package/dist/services/llms/runtime-types.d.ts +84 -0
- package/dist/services/local-runtime-bootstrap.d.ts +45 -0
- package/dist/services/plugin-tools.d.ts +15 -0
- package/dist/services/providers/local-provider-registry.d.ts +218 -0
- package/dist/services/providers/local-provider-service.d.ts +99 -0
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/session-artifacts.d.ts +17 -0
- package/dist/services/session-data.d.ts +51 -0
- package/dist/services/session-telemetry.d.ts +15 -0
- package/dist/services/storage/file-team-store.d.ts +28 -0
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +38 -0
- package/dist/services/storage/provider-settings-manager.d.ts +23 -0
- package/dist/services/storage/sqlite-session-store.d.ts +30 -0
- package/dist/services/storage/sqlite-team-store.d.ts +34 -0
- package/dist/services/storage/team-store.d.ts +15 -0
- package/dist/services/telemetry/ITelemetryAdapter.d.ts +54 -0
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +43 -0
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts +83 -0
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts +27 -0
- package/dist/services/telemetry/TelemetryService.d.ts +34 -0
- package/dist/services/telemetry/core-events.d.ts +198 -0
- package/dist/services/telemetry/distinct-id.d.ts +1 -0
- package/dist/services/telemetry/index.d.ts +3 -0
- package/dist/services/telemetry/index.js +1 -0
- package/dist/services/usage.d.ts +18 -0
- package/dist/services/workspace/file-indexer.d.ts +5 -0
- package/dist/services/workspace/index.d.ts +4 -0
- package/dist/services/workspace/mention-enricher.d.ts +13 -0
- package/dist/services/workspace/workspace-manager.d.ts +27 -0
- package/dist/services/workspace/workspace-manifest.d.ts +31 -0
- package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
- package/dist/session/checkpoint-restore.d.ts +20 -0
- package/dist/session/models/session-graph.d.ts +15 -0
- package/dist/session/models/session-manifest.d.ts +29 -0
- package/dist/session/models/session-row.d.ts +92 -0
- package/dist/session/services/file-session-service.d.ts +8 -0
- package/dist/session/services/message-builder.d.ts +66 -0
- package/dist/session/services/persistence-service.d.ts +58 -0
- package/dist/session/services/session-service.d.ts +13 -0
- package/dist/session/session-snapshot.d.ts +57 -0
- package/dist/session/session-versioning-service.d.ts +48 -0
- package/dist/session/stores/conversation-store.d.ts +29 -0
- package/dist/session/stores/session-manifest-store.d.ts +21 -0
- package/dist/session/stores/team-persistence-store.d.ts +23 -0
- package/dist/session/team/index.d.ts +2 -0
- package/dist/session/team/team-child-session-manager.d.ts +35 -0
- package/dist/session/team/team-session-coordinator.d.ts +13 -0
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/settings-service.d.ts +6 -0
- package/dist/settings/types.d.ts +42 -0
- package/dist/types/chat-schema.d.ts +161 -0
- package/dist/types/common.d.ts +19 -0
- package/dist/types/config.d.ts +167 -0
- package/dist/types/events.d.ts +89 -0
- package/dist/types/provider-settings.d.ts +19 -0
- package/dist/types/session.d.ts +116 -0
- package/dist/types/sessions.d.ts +28 -0
- package/dist/types/storage.d.ts +36 -0
- package/dist/types.d.ts +32 -0
- package/dist/version.d.ts +1 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# [experimental] @cline/core
|
|
2
|
+
|
|
3
|
+
`@cline/core` is the stateful orchestration layer of the Cline SDK. It
|
|
4
|
+
connects the agent runtime, provider settings, storage, default tools, and
|
|
5
|
+
session lifecycle into a host-ready runtime.
|
|
6
|
+
|
|
7
|
+
## What You Get
|
|
8
|
+
|
|
9
|
+
- session lifecycle and orchestration primitives
|
|
10
|
+
- provider settings and account services
|
|
11
|
+
- default runtime tools and MCP integration
|
|
12
|
+
- storage-backed session and team state helpers
|
|
13
|
+
- host-facing Node helpers through `@cline/core`
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @cline/core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Entry Points
|
|
22
|
+
|
|
23
|
+
- `@cline/core`: core contracts, shared utilities, and Node/server helpers for building hosts and runtimes
|
|
24
|
+
|
|
25
|
+
## Typical Usage
|
|
26
|
+
|
|
27
|
+
Most host apps should start with `@cline/core`.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { ClineCore } from "@cline/core";
|
|
31
|
+
|
|
32
|
+
const cline = await ClineCore.create({});
|
|
33
|
+
|
|
34
|
+
const result = await cline.start({
|
|
35
|
+
config: {
|
|
36
|
+
providerId: "anthropic",
|
|
37
|
+
modelId: "claude-sonnet-4-6",
|
|
38
|
+
apiKey: process.env.ANTHROPIC_API_KEY ?? "",
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
mode: "act",
|
|
41
|
+
enableTools: true,
|
|
42
|
+
enableSpawnAgent: false,
|
|
43
|
+
enableAgentTeams: false,
|
|
44
|
+
systemPrompt: "You are a concise assistant.",
|
|
45
|
+
},
|
|
46
|
+
prompt: "Summarize this project.",
|
|
47
|
+
interactive: false,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log(result.result?.text);
|
|
51
|
+
await cline.dispose();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Session Bootstrap
|
|
55
|
+
|
|
56
|
+
`ClineCore.create(...)` also accepts `prepare(input)`.
|
|
57
|
+
|
|
58
|
+
Use it when a host needs to prepare workspace-scoped runtime state before each
|
|
59
|
+
session starts, then apply watcher/extensions/telemetry inputs through
|
|
60
|
+
explicit `localRuntime` bootstrap fields without widening the shared host
|
|
61
|
+
contract.
|
|
62
|
+
|
|
63
|
+
## Main APIs
|
|
64
|
+
|
|
65
|
+
### Runtime and Sessions
|
|
66
|
+
|
|
67
|
+
Use `@cline/core` for host-facing runtime assembly:
|
|
68
|
+
|
|
69
|
+
- `ClineCore.create(...)`
|
|
70
|
+
- `createRuntimeHost(...)`
|
|
71
|
+
- `LocalRuntimeHost`
|
|
72
|
+
- `HubRuntimeHost` and `RemoteRuntimeHost`
|
|
73
|
+
- `DefaultRuntimeBuilder`
|
|
74
|
+
|
|
75
|
+
`ClineCore` is the app-facing session API. The lower-level `RuntimeHost`
|
|
76
|
+
boundary uses runtime-primitive names such as `startSession` and `runTurn` so
|
|
77
|
+
transport adapters stay distinct from product methods like `start` and `send`.
|
|
78
|
+
Service-style operations such as pending prompt edits, accumulated usage lookup,
|
|
79
|
+
and active-session model switching are exposed through `ClineCore` when the
|
|
80
|
+
selected transport supports them rather than being part of the minimal host
|
|
81
|
+
primitive vocabulary.
|
|
82
|
+
|
|
83
|
+
### Default Tools
|
|
84
|
+
|
|
85
|
+
`@cline/core` owns the built-in host tools and executors:
|
|
86
|
+
|
|
87
|
+
- `createBuiltinTools(...)`
|
|
88
|
+
- `createDefaultTools(...)`
|
|
89
|
+
- `createDefaultExecutors(...)`
|
|
90
|
+
|
|
91
|
+
### Storage and Settings
|
|
92
|
+
|
|
93
|
+
The package also exports storage and settings helpers such as:
|
|
94
|
+
|
|
95
|
+
- `ProviderSettingsManager`
|
|
96
|
+
- `SqliteTeamStore`
|
|
97
|
+
- SQLite-backed local session stores and artifacts through `@cline/core`
|
|
98
|
+
|
|
99
|
+
## Related Packages
|
|
100
|
+
|
|
101
|
+
- `@cline/agents`: stateless agent loop and tool primitives
|
|
102
|
+
- `@cline/llms`: provider/model configuration and handlers
|
|
103
|
+
|
|
104
|
+
## More Examples
|
|
105
|
+
|
|
106
|
+
- Repo examples: [apps/examples/cline-sdk](https://github.com/cline/cline/tree/main/apps/examples/cline-sdk)
|
|
107
|
+
- Workspace overview: [README.md](https://github.com/cline/cline/blob/main/README.md)
|
|
108
|
+
- API and architecture references: [DOC.md](https://github.com/cline/cline/blob/main/DOC.md), [ARCHITECTURE.md](https://github.com/cline/cline/blob/main/ARCHITECTURE.md)
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { ClineCoreAutomationApi, ClineCoreListHistoryOptions, ClineCoreOptions, ClineCoreSettingsApi, ClineCoreStartInput, RestoreInput, RestoreResult } from "./cline-core/types";
|
|
2
|
+
import type { PendingPromptsServiceApi, RuntimeHost, RuntimeHostSubscribeOptions, SessionModelRuntimeService, SessionUsageRuntimeService, StartSessionInput, StartSessionResult } from "./runtime/host/runtime-host";
|
|
3
|
+
import type { CoreSessionEvent } from "./types/events";
|
|
4
|
+
import type { SessionHistoryRecord } from "./types/sessions";
|
|
5
|
+
export type { ClineAutomationEventIngressResult, ClineAutomationEventLog, ClineAutomationEventSuppression, ClineAutomationListEventsOptions, ClineAutomationListRunsOptions, ClineAutomationListSpecsOptions, ClineAutomationRun, ClineAutomationRunStatus, ClineAutomationSpec, ClineCoreAutomationApi, ClineCoreAutomationOptions, ClineCoreListHistoryOptions, ClineCoreOptions, ClineCoreSettingsApi, ClineCoreStartInput, HubOptions, RemoteOptions, RestoreInput, RestoreOptions, RestoreResult, RuntimeHostMode, StartSessionBootstrap, } from "./cline-core/types";
|
|
6
|
+
/**
|
|
7
|
+
* The primary entry point for the Cline Core SDK.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { ClineCore } from "@cline/core";
|
|
12
|
+
*
|
|
13
|
+
* const cline = await ClineCore.create({ clientName: "my-app" });
|
|
14
|
+
* const session = await cline.start({ ... });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class ClineCore {
|
|
18
|
+
readonly clientName: string | undefined;
|
|
19
|
+
readonly runtimeAddress: string | undefined;
|
|
20
|
+
readonly automation: ClineCoreAutomationApi;
|
|
21
|
+
readonly settings: ClineCoreSettingsApi;
|
|
22
|
+
readonly pendingPrompts: PendingPromptsServiceApi;
|
|
23
|
+
private readonly host;
|
|
24
|
+
private readonly prepare;
|
|
25
|
+
private readonly capabilities;
|
|
26
|
+
private readonly logger;
|
|
27
|
+
private readonly telemetry;
|
|
28
|
+
private readonly distinctId;
|
|
29
|
+
private readonly automationService;
|
|
30
|
+
private readonly activeSessionBootstraps;
|
|
31
|
+
private readonly unsubscribeBootstrapCleanup;
|
|
32
|
+
private constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new ClineCore instance.
|
|
35
|
+
*
|
|
36
|
+
* This is the primary factory method for initializing the SDK. It sets up the runtime
|
|
37
|
+
* host (local, hub, or remote) based on the provided options and prepares the SDK for
|
|
38
|
+
* starting sessions.
|
|
39
|
+
*
|
|
40
|
+
* @param options Configuration options for the SDK instance
|
|
41
|
+
* @returns A promise that resolves to a new ClineCore instance
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const cline = await ClineCore.create({
|
|
46
|
+
* clientName: "my-app",
|
|
47
|
+
* backendMode: "local",
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static create(options?: ClineCoreOptions): Promise<ClineCore>;
|
|
52
|
+
private disposeSessionBootstrap;
|
|
53
|
+
/**
|
|
54
|
+
* Starts a new Cline session with the provided configuration.
|
|
55
|
+
*
|
|
56
|
+
* This method initializes and begins a new agent session. It handles session setup,
|
|
57
|
+
* runs any preparation hooks, and returns session metadata along with event streams.
|
|
58
|
+
* The session continues to run until explicitly stopped or aborted.
|
|
59
|
+
*
|
|
60
|
+
* @param input The session configuration and startup parameters
|
|
61
|
+
* @returns A promise that resolves to session metadata and event stream
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const result = await cline.start({
|
|
66
|
+
* config: {
|
|
67
|
+
* providerId: "anthropic",
|
|
68
|
+
* modelId: "claude-opus-4-1",
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Subscribe to session events
|
|
73
|
+
* result.subscribe((event) => {
|
|
74
|
+
* console.log("Session event:", event);
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
start(input: StartSessionInput): Promise<StartSessionResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Starts a new Cline session with extended core-specific configuration.
|
|
81
|
+
* This overload allows specifying local runtime options and config overrides.
|
|
82
|
+
*/
|
|
83
|
+
start(input: ClineCoreStartInput): Promise<StartSessionResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Sends a message or command to an active session.
|
|
86
|
+
*
|
|
87
|
+
* This method communicates with a running session, allowing you to send user messages,
|
|
88
|
+
* tool responses, or other session input while the session is in progress.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* await cline.send(sessionId, {
|
|
93
|
+
* type: "user_message",
|
|
94
|
+
* text: "Please implement the login feature",
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
send: RuntimeHost["runTurn"];
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves accumulated token and cost usage for a session.
|
|
101
|
+
*
|
|
102
|
+
* Returns metrics about the session's resource consumption, including tokens used
|
|
103
|
+
* across different API providers and associated costs. Useful for monitoring and billing.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const usage = await cline.getAccumulatedUsage(sessionId);
|
|
108
|
+
* console.log(`Total cost: $${usage.totalCost}`);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
getAccumulatedUsage: SessionUsageRuntimeService["getAccumulatedUsage"];
|
|
112
|
+
/**
|
|
113
|
+
* Aborts an in-flight tool execution without stopping the session.
|
|
114
|
+
*
|
|
115
|
+
* Interrupts the current tool operation (e.g., file read, shell command) while keeping
|
|
116
|
+
* the session alive. The session can continue processing after the abort. Use this for
|
|
117
|
+
* cancelling long-running operations.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* // Stop the current operation but keep the session running
|
|
122
|
+
* await cline.abort(sessionId);
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
abort: RuntimeHost["abort"];
|
|
126
|
+
/**
|
|
127
|
+
* Stops an active session gracefully.
|
|
128
|
+
*
|
|
129
|
+
* Terminates the session and cleans up associated resources. Unlike abort, this
|
|
130
|
+
* completely ends the session. The session cannot be resumed after stopping.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* // Cleanly shutdown the session
|
|
135
|
+
* await cline.stop(sessionId);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
stop: RuntimeHost["stopSession"];
|
|
139
|
+
/**
|
|
140
|
+
* Disposes the ClineCore instance and all associated resources.
|
|
141
|
+
*
|
|
142
|
+
* Shuts down the runtime host, closes connections, and cleans up all active sessions
|
|
143
|
+
* and bootstraps. Call this when you're done using the SDK instance, typically at
|
|
144
|
+
* application shutdown. After calling dispose, the instance cannot be reused.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* // Clean up when done
|
|
149
|
+
* await cline.dispose();
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
dispose: RuntimeHost["dispose"];
|
|
153
|
+
/**
|
|
154
|
+
* Retrieves information about a specific session by ID.
|
|
155
|
+
*
|
|
156
|
+
* Fetches the current metadata and state of a session, including configuration,
|
|
157
|
+
* status, and other session details.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const session = await cline.get(sessionId);
|
|
162
|
+
* console.log("Session status:", session?.status);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
get: RuntimeHost["getSession"];
|
|
166
|
+
/**
|
|
167
|
+
* Lists recent sessions through the shared history-listing path.
|
|
168
|
+
*/
|
|
169
|
+
listHistory: (options?: ClineCoreListHistoryOptions) => Promise<SessionHistoryRecord[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Lists recent sessions with inferred history display metadata.
|
|
172
|
+
*
|
|
173
|
+
* Retrieves a paginated list of recent sessions, optionally limited by the
|
|
174
|
+
* provided count.
|
|
175
|
+
*
|
|
176
|
+
* @param limit Maximum number of sessions to return (defaults to 200)
|
|
177
|
+
* @returns A promise resolving to an array of session history records
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* const sessions = await cline.list(50);
|
|
182
|
+
* sessions.forEach((session) => {
|
|
183
|
+
* console.log(`Session ${session.sessionId}: ${session.metadata?.title}`);
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
list: (limit?: number, options?: Omit<ClineCoreListHistoryOptions, "limit">) => Promise<SessionHistoryRecord[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Permanently deletes a session and all its associated data.
|
|
190
|
+
*
|
|
191
|
+
* Removes the session from storage and cleans up any related resources. This is
|
|
192
|
+
* a destructive operation that cannot be undone.
|
|
193
|
+
*
|
|
194
|
+
* @param sessionId The ID of the session to delete
|
|
195
|
+
* @returns A promise that resolves to true if the session was deleted, false if not found
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const deleted = await cline.delete(sessionId);
|
|
200
|
+
* if (deleted) {
|
|
201
|
+
* console.log("Session deleted successfully");
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
delete: RuntimeHost["deleteSession"];
|
|
206
|
+
/**
|
|
207
|
+
* Updates an existing session's metadata.
|
|
208
|
+
*
|
|
209
|
+
* Modifies session properties like title or other mutable metadata while preserving
|
|
210
|
+
* message history and other session data.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* await cline.update(sessionId, {
|
|
215
|
+
* title: "Updated session title",
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
update: RuntimeHost["updateSession"];
|
|
220
|
+
/**
|
|
221
|
+
* Reads message history for a session.
|
|
222
|
+
*
|
|
223
|
+
* Retrieves the full message transcript for a specific session, including all
|
|
224
|
+
* user messages, agent responses, and tool interactions.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const messages = await cline.readMessages(sessionId);
|
|
229
|
+
* messages.forEach((msg) => {
|
|
230
|
+
* console.log(`${msg.role}: ${msg.content}`);
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
readMessages: RuntimeHost["readSessionMessages"];
|
|
235
|
+
restore(input: RestoreInput): Promise<RestoreResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Handles hook events from the runtime environment.
|
|
238
|
+
*
|
|
239
|
+
* Processes system or environment events (e.g., workspace changes, external signals)
|
|
240
|
+
* that may affect the current session. This is typically called by the host environment
|
|
241
|
+
* rather than directly by consumer code.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
ingestHookEvent: RuntimeHost["dispatchHookEvent"];
|
|
246
|
+
/**
|
|
247
|
+
* Subscribes to session events.
|
|
248
|
+
*
|
|
249
|
+
* Registers a listener for all session events (messages, state changes, errors, etc.).
|
|
250
|
+
* Returns an unsubscribe function to stop listening.
|
|
251
|
+
*
|
|
252
|
+
* @param listener Callback function invoked for each event
|
|
253
|
+
* @param options Optional configuration for the subscription
|
|
254
|
+
* @returns An unsubscribe function
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const unsubscribe = cline.subscribe((event) => {
|
|
259
|
+
* if (event.type === "message") {
|
|
260
|
+
* console.log("New message:", event.payload.message);
|
|
261
|
+
* }
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* // Later, stop listening
|
|
265
|
+
* unsubscribe();
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
subscribe(listener: (event: CoreSessionEvent) => void, options?: RuntimeHostSubscribeOptions): () => void;
|
|
269
|
+
/**
|
|
270
|
+
* Updates the AI model used by an active session.
|
|
271
|
+
*
|
|
272
|
+
* Switches the session to use a different AI model while maintaining the session state
|
|
273
|
+
* and message history. This allows you to continue a conversation with a different model.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* // Switch to a different model mid-session
|
|
278
|
+
* await cline.updateSessionModel(sessionId, "claude-opus-4-1");
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
updateSessionModel: SessionModelRuntimeService["updateSessionModel"];
|
|
282
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser, ClineOrganization, FeaturebaseTokenResponse, UserRemoteConfigResponse } from "./types";
|
|
2
|
+
export interface ClineAccountServiceOptions {
|
|
3
|
+
apiBaseUrl: string;
|
|
4
|
+
getAuthToken: () => Promise<string | undefined | null>;
|
|
5
|
+
getCurrentUserId?: () => Promise<string | undefined | null> | string | undefined | null;
|
|
6
|
+
getOrganizationMemberId?: (organizationId: string) => Promise<string | undefined | null> | string | undefined | null;
|
|
7
|
+
getHeaders?: () => Promise<Record<string, string> | undefined> | Record<string, string> | undefined;
|
|
8
|
+
requestTimeoutMs?: number;
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export declare class ClineAccountService {
|
|
12
|
+
private readonly apiBaseUrl;
|
|
13
|
+
private readonly getAuthTokenFn;
|
|
14
|
+
private readonly getCurrentUserIdFn;
|
|
15
|
+
private readonly getOrganizationMemberIdFn;
|
|
16
|
+
private readonly getHeadersFn;
|
|
17
|
+
private readonly requestTimeoutMs;
|
|
18
|
+
private readonly fetchImpl;
|
|
19
|
+
constructor(options: ClineAccountServiceOptions);
|
|
20
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
21
|
+
fetchRemoteConfig(): Promise<UserRemoteConfigResponse | null>;
|
|
22
|
+
fetchFeaturebaseToken(): Promise<FeaturebaseTokenResponse | undefined>;
|
|
23
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
24
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
25
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
26
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
27
|
+
fetchOrganization(organizationId: string): Promise<ClineOrganization>;
|
|
28
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
29
|
+
fetchOrganizationUsageTransactions(input: {
|
|
30
|
+
organizationId: string;
|
|
31
|
+
memberId?: string;
|
|
32
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
33
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
34
|
+
private resolveUserId;
|
|
35
|
+
private resolveOrganizationMemberId;
|
|
36
|
+
private request;
|
|
37
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ClineAccountService, type ClineAccountServiceOptions, } from "./cline-account-service";
|
|
2
|
+
export { type ClineAccountOperations, executeClineAccountAction, isClineAccountActionRequest, type ProviderActionExecutor, RpcClineAccountService, } from "./rpc";
|
|
3
|
+
export type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser, ClineOrganization, FeaturebaseTokenResponse, UserRemoteConfigOrganization, UserRemoteConfigResponse, } from "./types";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ClineAccountActionRequest, ProviderActionRequest } from "@cline/shared";
|
|
2
|
+
import type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser, FeaturebaseTokenResponse } from "./types";
|
|
3
|
+
export interface ClineAccountOperations {
|
|
4
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
5
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
6
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
7
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
8
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
9
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
10
|
+
fetchOrganizationUsageTransactions(input: {
|
|
11
|
+
organizationId: string;
|
|
12
|
+
memberId?: string;
|
|
13
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
14
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
15
|
+
fetchFeaturebaseToken?(): Promise<FeaturebaseTokenResponse | undefined>;
|
|
16
|
+
}
|
|
17
|
+
export declare function isClineAccountActionRequest(request: ProviderActionRequest): request is ClineAccountActionRequest;
|
|
18
|
+
export declare function executeClineAccountAction(request: ClineAccountActionRequest, service: ClineAccountOperations): Promise<unknown>;
|
|
19
|
+
export interface ProviderActionExecutor {
|
|
20
|
+
runProviderAction(request: ProviderActionRequest): Promise<{
|
|
21
|
+
result: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare class RpcClineAccountService implements ClineAccountOperations {
|
|
25
|
+
private readonly executor;
|
|
26
|
+
constructor(executor: ProviderActionExecutor);
|
|
27
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
28
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
29
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
30
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
31
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
32
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
33
|
+
fetchOrganizationUsageTransactions(input: {
|
|
34
|
+
organizationId: string;
|
|
35
|
+
memberId?: string;
|
|
36
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
37
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
38
|
+
fetchFeaturebaseToken(): Promise<FeaturebaseTokenResponse | undefined>;
|
|
39
|
+
private request;
|
|
40
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface ClineAccountOrganization {
|
|
2
|
+
active: boolean;
|
|
3
|
+
memberId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
organizationId: string;
|
|
6
|
+
roles: Array<"admin" | "member" | "owner">;
|
|
7
|
+
}
|
|
8
|
+
export interface ClineAccountUser {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
photoUrl: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
organizations: ClineAccountOrganization[];
|
|
16
|
+
}
|
|
17
|
+
export interface UserRemoteConfigOrganization {
|
|
18
|
+
organizationId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UserRemoteConfigResponse {
|
|
22
|
+
organizationId: string;
|
|
23
|
+
value: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
organizations?: UserRemoteConfigOrganization[];
|
|
26
|
+
}
|
|
27
|
+
export interface ClineAccountBalance {
|
|
28
|
+
balance: number;
|
|
29
|
+
userId: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ClineAccountUsageTransaction {
|
|
32
|
+
aiInferenceProviderName: string;
|
|
33
|
+
aiModelName: string;
|
|
34
|
+
aiModelTypeName: string;
|
|
35
|
+
completionTokens: number;
|
|
36
|
+
costUsd: number;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
creditsUsed: number;
|
|
39
|
+
generationId: string;
|
|
40
|
+
id: string;
|
|
41
|
+
metadata: {
|
|
42
|
+
additionalProp1: string;
|
|
43
|
+
additionalProp2: string;
|
|
44
|
+
additionalProp3: string;
|
|
45
|
+
};
|
|
46
|
+
operation?: string;
|
|
47
|
+
organizationId: string;
|
|
48
|
+
promptTokens: number;
|
|
49
|
+
totalTokens: number;
|
|
50
|
+
userId: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ClineAccountPaymentTransaction {
|
|
53
|
+
paidAt: string;
|
|
54
|
+
creatorId: string;
|
|
55
|
+
amountCents: number;
|
|
56
|
+
credits: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ClineOrganization {
|
|
59
|
+
createdAt: string;
|
|
60
|
+
defaultRemoteConfig?: string;
|
|
61
|
+
deletedAt?: string;
|
|
62
|
+
externalOrganizationId?: string;
|
|
63
|
+
id: string;
|
|
64
|
+
memberCount?: number;
|
|
65
|
+
name: string;
|
|
66
|
+
remoteConfigEnabled: boolean;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ClineAccountOrganizationBalance {
|
|
70
|
+
balance: number;
|
|
71
|
+
organizationId: string;
|
|
72
|
+
}
|
|
73
|
+
export interface FeaturebaseTokenResponse {
|
|
74
|
+
featurebaseJwt: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ClineAccountOrganizationUsageTransaction {
|
|
77
|
+
aiInferenceProviderName: string;
|
|
78
|
+
aiModelName: string;
|
|
79
|
+
aiModelTypeName: string;
|
|
80
|
+
completionTokens: number;
|
|
81
|
+
costUsd: number;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
creditsUsed: number;
|
|
84
|
+
generationId: string;
|
|
85
|
+
id: string;
|
|
86
|
+
memberDisplayName: string;
|
|
87
|
+
memberEmail: string;
|
|
88
|
+
metadata: {
|
|
89
|
+
additionalProp1: string;
|
|
90
|
+
additionalProp2: string;
|
|
91
|
+
additionalProp3: string;
|
|
92
|
+
};
|
|
93
|
+
operation?: string;
|
|
94
|
+
organizationId: string;
|
|
95
|
+
promptTokens: number;
|
|
96
|
+
totalTokens: number;
|
|
97
|
+
userId: string;
|
|
98
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small process-local string cache with TTL expiry and a hard entry cap.
|
|
3
|
+
* Used where unbounded Maps would grow without bound in long-running processes.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BoundedTtlCache {
|
|
6
|
+
private readonly ttlMs;
|
|
7
|
+
private readonly maxEntries;
|
|
8
|
+
private readonly entries;
|
|
9
|
+
constructor(ttlMs: number, maxEntries: number);
|
|
10
|
+
get(key: string, now?: number): string | undefined;
|
|
11
|
+
set(key: string, value: string, now?: number, ttlMsOverride?: number): void;
|
|
12
|
+
private pruneExpired;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OAuthServerCloseInfo, OAuthServerListeningInfo } from "./server";
|
|
2
|
+
import type { OAuthLoginCallbacks, OAuthPrompt } from "./types";
|
|
3
|
+
export interface OAuthClientCallbacksOptions {
|
|
4
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
5
|
+
onOutput?: (message: string) => void;
|
|
6
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
7
|
+
onOpenUrlError?: (context: {
|
|
8
|
+
url: string;
|
|
9
|
+
error: unknown;
|
|
10
|
+
}) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Called when the local OAuth redirect server successfully binds to a port
|
|
13
|
+
* and is ready to receive the browser callback.
|
|
14
|
+
*
|
|
15
|
+
* Forwarded directly from `OAuthLoginCallbacks.onServerListening`.
|
|
16
|
+
* Use this to show a "waiting for OAuth callback on :::1 port N" status
|
|
17
|
+
* message or, in remote-development environments (e.g. JetBrains Gateway),
|
|
18
|
+
* to set up a port-forward from the remote machine to the local one.
|
|
19
|
+
*/
|
|
20
|
+
onServerListening?: (info: OAuthServerListeningInfo) => void | Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Called when the local OAuth redirect server closes.
|
|
23
|
+
*
|
|
24
|
+
* Forwarded directly from `OAuthLoginCallbacks.onServerClose`.
|
|
25
|
+
* Use this to tear down port-forwards and clear any status UI set up in
|
|
26
|
+
* `onServerListening`.
|
|
27
|
+
*/
|
|
28
|
+
onServerClose?: (info: OAuthServerCloseInfo) => void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createOAuthClientCallbacks(options: OAuthClientCallbacksOptions): OAuthLoginCallbacks;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ITelemetryService } from "@cline/shared";
|
|
2
|
+
import type { OAuthCredentials, OAuthLoginCallbacks, OAuthProviderInterface } from "./types";
|
|
3
|
+
export type ClineTokenResolution = {
|
|
4
|
+
forceRefresh?: boolean;
|
|
5
|
+
refreshBufferMs?: number;
|
|
6
|
+
retryableTokenGraceMs?: number;
|
|
7
|
+
};
|
|
8
|
+
interface ClineAuthApiUser {
|
|
9
|
+
subject: string | null;
|
|
10
|
+
email: string;
|
|
11
|
+
name: string;
|
|
12
|
+
clineUserId: string | null;
|
|
13
|
+
accounts: string[] | null;
|
|
14
|
+
}
|
|
15
|
+
type HeaderMap = Record<string, string>;
|
|
16
|
+
type HeaderInput = HeaderMap | (() => Promise<HeaderMap> | HeaderMap);
|
|
17
|
+
export interface ClineOAuthProviderOptions {
|
|
18
|
+
apiBaseUrl: string;
|
|
19
|
+
headers?: HeaderInput;
|
|
20
|
+
requestTimeoutMs?: number;
|
|
21
|
+
telemetry?: ITelemetryService;
|
|
22
|
+
useWorkOSDeviceAuth?: boolean;
|
|
23
|
+
callbackPath?: string;
|
|
24
|
+
callbackPorts?: number[];
|
|
25
|
+
/**
|
|
26
|
+
* Optional identity provider name for token exchange.
|
|
27
|
+
*/
|
|
28
|
+
provider?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ClineOAuthCredentials extends OAuthCredentials {
|
|
31
|
+
metadata?: {
|
|
32
|
+
provider?: string;
|
|
33
|
+
tokenType?: string;
|
|
34
|
+
userInfo?: ClineAuthApiUser;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function loginClineOAuth(options: ClineOAuthProviderOptions & {
|
|
39
|
+
callbacks: OAuthLoginCallbacks;
|
|
40
|
+
}): Promise<ClineOAuthCredentials>;
|
|
41
|
+
export declare function startClineDeviceAuth(options?: {
|
|
42
|
+
requestTimeoutMs?: number;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
deviceCode: string;
|
|
45
|
+
userCode: string;
|
|
46
|
+
verificationUri: string;
|
|
47
|
+
verificationUriComplete?: string;
|
|
48
|
+
expiresInSeconds: number;
|
|
49
|
+
pollIntervalSeconds: number;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function completeClineDeviceAuth(options: {
|
|
52
|
+
deviceCode: string;
|
|
53
|
+
expiresInSeconds: number;
|
|
54
|
+
pollIntervalSeconds: number;
|
|
55
|
+
apiBaseUrl: string;
|
|
56
|
+
provider?: string;
|
|
57
|
+
headers?: HeaderInput;
|
|
58
|
+
requestTimeoutMs?: number;
|
|
59
|
+
telemetry?: ITelemetryService;
|
|
60
|
+
}): Promise<ClineOAuthCredentials>;
|
|
61
|
+
export declare function refreshClineToken(current: ClineOAuthCredentials, options: ClineOAuthProviderOptions): Promise<ClineOAuthCredentials>;
|
|
62
|
+
export declare function getValidClineCredentials(currentCredentials: ClineOAuthCredentials | null, providerOptions: ClineOAuthProviderOptions, options?: ClineTokenResolution): Promise<ClineOAuthCredentials | null>;
|
|
63
|
+
export declare function createClineOAuthProvider(options: ClineOAuthProviderOptions): OAuthProviderInterface;
|
|
64
|
+
export {};
|