@cline/core 0.0.38 → 0.0.39

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.
@@ -0,0 +1,17 @@
1
+ import { type AgentExtension, buildRemoteConfigSessionBlobUploadMetadata, type ITelemetryService, type OpenTelemetryClientConfig, type PreparedRemoteConfigRuntime, type PrepareRemoteConfigRuntimeOptions, REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY, readRemoteConfigSessionBlobUploadMetadata, registerRemoteConfigSessionBlobUpload } from "@cline/shared";
2
+ import type { ClineCoreStartInput } from "../cline-core/types";
3
+ import type { CreateOpenTelemetryTelemetryServiceOptions } from "../services/telemetry/OpenTelemetryProvider";
4
+ import type { SessionMessagesArtifactUploader } from "../types/session";
5
+ export interface PrepareRemoteConfigCoreIntegrationOptions extends PrepareRemoteConfigRuntimeOptions {
6
+ telemetryService?: Omit<CreateOpenTelemetryTelemetryServiceOptions, keyof OpenTelemetryClientConfig>;
7
+ }
8
+ export interface PreparedRemoteConfigCoreIntegration {
9
+ prepared: PreparedRemoteConfigRuntime;
10
+ extensions: AgentExtension[];
11
+ telemetry?: ITelemetryService;
12
+ applyToStartSessionInput(input: ClineCoreStartInput): ClineCoreStartInput;
13
+ dispose(): Promise<void>;
14
+ }
15
+ export declare function createRemoteConfigSessionMessagesArtifactUploader(): SessionMessagesArtifactUploader;
16
+ export declare function prepareRemoteConfigCoreIntegration(options: PrepareRemoteConfigCoreIntegrationOptions): Promise<PreparedRemoteConfigCoreIntegration>;
17
+ export { buildRemoteConfigSessionBlobUploadMetadata, REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY, readRemoteConfigSessionBlobUploadMetadata, registerRemoteConfigSessionBlobUpload, };
@@ -8,6 +8,7 @@ import type { SessionAccumulatedUsage } from "../runtime-host";
8
8
  export interface AgentEventBridgeDeps {
9
9
  getSession(sessionId: string): ActiveSession | undefined;
10
10
  usageBySession: Map<string, SessionAccumulatedUsage>;
11
+ aggregateUsageBySession: Map<string, SessionAccumulatedUsage>;
11
12
  emit(event: CoreSessionEvent): void;
12
13
  persistMessages: AgentEventContext["persistMessages"];
13
14
  enqueuePendingPrompt(sessionId: string, entry: {
@@ -10,7 +10,7 @@ import { RuntimeOAuthTokenManager } from "../orchestration/runtime-oauth-token-m
10
10
  import type { RuntimeBuilder } from "../orchestration/session-runtime";
11
11
  import { SessionRuntime } from "../orchestration/session-runtime-orchestrator";
12
12
  import { type SessionBackend } from "./local/session-record";
13
- import type { PendingPromptsServiceApi, RestoreSessionInput, RestoreSessionResult, RuntimeHost, RuntimeHostSubscribeOptions, SendSessionInput, SessionAccumulatedUsage, StartSessionInput, StartSessionResult } from "./runtime-host";
13
+ import type { PendingPromptsServiceApi, RestoreSessionInput, RestoreSessionResult, RuntimeHost, RuntimeHostSubscribeOptions, SendSessionInput, SessionUsageSummary, StartSessionInput, StartSessionResult } from "./runtime-host";
14
14
  export interface LocalRuntimeHostOptions {
15
15
  distinctId?: string;
16
16
  sessionService: SessionBackend;
@@ -44,6 +44,7 @@ export declare class LocalRuntimeHost implements RuntimeHost {
44
44
  private readonly events;
45
45
  private readonly sessions;
46
46
  private readonly usageBySession;
47
+ private readonly aggregateUsageBySession;
47
48
  private readonly subAgentStarts;
48
49
  private readonly pendingPromptsController;
49
50
  private readonly eventBridge;
@@ -52,7 +53,7 @@ export declare class LocalRuntimeHost implements RuntimeHost {
52
53
  startSession(input: StartSessionInput): Promise<StartSessionResult>;
53
54
  restoreSession(input: RestoreSessionInput): Promise<RestoreSessionResult>;
54
55
  runTurn(input: SendSessionInput): Promise<AgentResult | undefined>;
55
- getAccumulatedUsage(sessionId: string): Promise<SessionAccumulatedUsage | undefined>;
56
+ getAccumulatedUsage(sessionId: string): Promise<SessionUsageSummary | undefined>;
56
57
  abort(sessionId: string, reason?: unknown): Promise<void>;
57
58
  stopSession(sessionId: string): Promise<void>;
58
59
  dispose(reason?: string): Promise<void>;
@@ -107,6 +108,9 @@ export declare class LocalRuntimeHost implements RuntimeHost {
107
108
  private getSessionOrThrow;
108
109
  private resolveAbsoluteFilePaths;
109
110
  private getSessionAgentTelemetryIdentity;
111
+ private seedAggregateUsageFromArtifacts;
112
+ private summarizePersistedTeammateUsage;
113
+ private withPersistedAggregateUsageFloor;
110
114
  private emitStatus;
111
115
  private emitSessionSnapshot;
112
116
  private emit;
@@ -78,6 +78,10 @@ export interface SessionAccumulatedUsage {
78
78
  cacheWriteTokens: number;
79
79
  totalCost: number;
80
80
  }
81
+ export interface SessionUsageSummary {
82
+ usage?: SessionAccumulatedUsage;
83
+ aggregateUsage?: SessionAccumulatedUsage;
84
+ }
81
85
  export interface PendingPromptMutationResult {
82
86
  sessionId: string;
83
87
  prompts: SessionPendingPrompt[];
@@ -107,7 +111,7 @@ export interface PendingPromptsRuntimeService {
107
111
  readonly pendingPrompts: PendingPromptsServiceApi;
108
112
  }
109
113
  export interface SessionUsageRuntimeService {
110
- getAccumulatedUsage(sessionId: string): Promise<SessionAccumulatedUsage | undefined>;
114
+ getAccumulatedUsage(sessionId: string): Promise<SessionUsageSummary | undefined>;
111
115
  }
112
116
  export interface SessionModelRuntimeService {
113
117
  updateSessionModel(sessionId: string, modelId: string): Promise<void>;
@@ -10,6 +10,7 @@ export interface AgentEventContext {
10
10
  config: CoreSessionConfig;
11
11
  liveSession: ActiveSession | undefined;
12
12
  usageBySession: Map<string, SessionAccumulatedUsage>;
13
+ aggregateUsageBySession: Map<string, SessionAccumulatedUsage>;
13
14
  persistMessages: (sessionId: string, messages: unknown[], systemPrompt?: string) => void;
14
15
  emit: (event: CoreSessionEvent) => void;
15
16
  }
@@ -18,22 +18,22 @@ export declare const ProviderProtocolSchema: z.ZodEnum<{
18
18
  "openai-responses": "openai-responses";
19
19
  anthropic: "anthropic";
20
20
  gemini: "gemini";
21
- "openai-chat": "openai-chat";
22
21
  "openai-r1": "openai-r1";
23
22
  "ai-sdk": "ai-sdk";
23
+ "openai-chat": "openai-chat";
24
24
  }>;
25
25
  export declare const ProviderClientSchema: z.ZodEnum<{
26
26
  custom: "custom";
27
27
  anthropic: "anthropic";
28
+ bedrock: "bedrock";
28
29
  gemini: "gemini";
30
+ vertex: "vertex";
31
+ openai: "openai";
29
32
  "openai-r1": "openai-r1";
30
33
  "ai-sdk": "ai-sdk";
31
34
  "ai-sdk-community": "ai-sdk-community";
32
- openai: "openai";
33
35
  "openai-compatible": "openai-compatible";
34
- bedrock: "bedrock";
35
36
  fetch: "fetch";
36
- vertex: "vertex";
37
37
  }>;
38
38
  export declare const AuthSettingsSchema: z.ZodObject<{
39
39
  apiKey: z.ZodOptional<z.ZodString>;
@@ -47,8 +47,8 @@ export declare const ReasoningSettingsSchema: z.ZodObject<{
47
47
  enabled: z.ZodOptional<z.ZodBoolean>;
48
48
  effort: z.ZodOptional<z.ZodEnum<{
49
49
  low: "low";
50
- high: "high";
51
50
  medium: "medium";
51
+ high: "high";
52
52
  xhigh: "xhigh";
53
53
  none: "none";
54
54
  }>>;
@@ -62,9 +62,9 @@ export declare const AwsSettingsSchema: z.ZodObject<{
62
62
  region: z.ZodOptional<z.ZodString>;
63
63
  profile: z.ZodOptional<z.ZodString>;
64
64
  authentication: z.ZodOptional<z.ZodEnum<{
65
- iam: "iam";
66
65
  "api-key": "api-key";
67
66
  profile: "profile";
67
+ iam: "iam";
68
68
  }>>;
69
69
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
70
70
  useCrossRegionInference: z.ZodOptional<z.ZodBoolean>;
@@ -99,8 +99,8 @@ export declare const SapSettingsSchema: z.ZodObject<{
99
99
  export type SapSettings = z.infer<typeof SapSettingsSchema>;
100
100
  export declare const OcaSettingsSchema: z.ZodObject<{
101
101
  mode: z.ZodOptional<z.ZodEnum<{
102
- external: "external";
103
102
  internal: "internal";
103
+ external: "external";
104
104
  }>>;
105
105
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
106
106
  }, z.core.$strip>;
@@ -129,22 +129,22 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
129
129
  "openai-responses": "openai-responses";
130
130
  anthropic: "anthropic";
131
131
  gemini: "gemini";
132
- "openai-chat": "openai-chat";
133
132
  "openai-r1": "openai-r1";
134
133
  "ai-sdk": "ai-sdk";
134
+ "openai-chat": "openai-chat";
135
135
  }>>;
136
136
  client: z.ZodOptional<z.ZodEnum<{
137
137
  custom: "custom";
138
138
  anthropic: "anthropic";
139
+ bedrock: "bedrock";
139
140
  gemini: "gemini";
141
+ vertex: "vertex";
142
+ openai: "openai";
140
143
  "openai-r1": "openai-r1";
141
144
  "ai-sdk": "ai-sdk";
142
145
  "ai-sdk-community": "ai-sdk-community";
143
- openai: "openai";
144
146
  "openai-compatible": "openai-compatible";
145
- bedrock: "bedrock";
146
147
  fetch: "fetch";
147
- vertex: "vertex";
148
148
  }>>;
149
149
  routingProviderId: z.ZodOptional<z.ZodString>;
150
150
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -156,8 +156,8 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
156
156
  enabled: z.ZodOptional<z.ZodBoolean>;
157
157
  effort: z.ZodOptional<z.ZodEnum<{
158
158
  low: "low";
159
- high: "high";
160
159
  medium: "medium";
160
+ high: "high";
161
161
  xhigh: "xhigh";
162
162
  none: "none";
163
163
  }>>;
@@ -170,9 +170,9 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
170
170
  region: z.ZodOptional<z.ZodString>;
171
171
  profile: z.ZodOptional<z.ZodString>;
172
172
  authentication: z.ZodOptional<z.ZodEnum<{
173
- iam: "iam";
174
173
  "api-key": "api-key";
175
174
  profile: "profile";
175
+ iam: "iam";
176
176
  }>>;
177
177
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
178
178
  useCrossRegionInference: z.ZodOptional<z.ZodBoolean>;
@@ -203,8 +203,8 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
203
203
  }, z.core.$strip>>;
204
204
  oca: z.ZodOptional<z.ZodObject<{
205
205
  mode: z.ZodOptional<z.ZodEnum<{
206
- external: "external";
207
206
  internal: "internal";
207
+ external: "external";
208
208
  }>>;
209
209
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
210
210
  }, z.core.$strip>>;
@@ -215,9 +215,9 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
215
215
  }>>;
216
216
  capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
217
217
  tools: "tools";
218
+ reasoning: "reasoning";
218
219
  streaming: "streaming";
219
220
  "prompt-cache": "prompt-cache";
220
- reasoning: "reasoning";
221
221
  "computer-use": "computer-use";
222
222
  oauth: "oauth";
223
223
  vision: "vision";
@@ -8,6 +8,7 @@ export declare function accumulateUsageTotals(baseline: SessionAccumulatedUsage,
8
8
  cacheWriteTokens?: number;
9
9
  totalCost?: number;
10
10
  }): SessionAccumulatedUsage;
11
+ export declare function sumUsageTotals(usages: Iterable<SessionAccumulatedUsage>): SessionAccumulatedUsage;
11
12
  export declare function summarizeUsageFromMessages(messages: LlmsProviders.Message[]): SessionAccumulatedUsage;
12
13
  /**
13
14
  * Current model context-window usage, derived from the latest assistant LLM
@@ -8,10 +8,10 @@ export declare const SessionManifestSchema: z.ZodObject<{
8
8
  ended_at: z.ZodOptional<z.ZodString>;
9
9
  exit_code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
10
  status: z.ZodEnum<{
11
- running: "running";
12
- completed: "completed";
13
11
  failed: "failed";
12
+ running: "running";
14
13
  cancelled: "cancelled";
14
+ completed: "completed";
15
15
  }>;
16
16
  interactive: z.ZodBoolean;
17
17
  provider: z.ZodString;
@@ -47,11 +47,13 @@ export interface CoreSessionSnapshot {
47
47
  };
48
48
  messages?: LlmsProviders.Message[];
49
49
  usage?: SessionAccumulatedUsage;
50
+ aggregateUsage?: SessionAccumulatedUsage;
50
51
  checkpoint?: CoreSessionCheckpointSnapshot;
51
52
  }
52
53
  export declare function createCoreSessionSnapshot(input: {
53
54
  session: SessionRecord;
54
55
  messages?: LlmsProviders.Message[];
55
56
  usage?: SessionAccumulatedUsage;
57
+ aggregateUsage?: SessionAccumulatedUsage;
56
58
  }): CoreSessionSnapshot;
57
59
  export declare function coreSessionSnapshotToRecord(snapshot: CoreSessionSnapshot): SessionRecord;
@@ -21,32 +21,32 @@ export declare const ChatSessionConfigSchema: z.ZodObject<{
21
21
  }, z.core.$strip>;
22
22
  export declare const ChatSessionStatusSchema: z.ZodEnum<{
23
23
  error: "error";
24
- idle: "idle";
24
+ failed: "failed";
25
25
  running: "running";
26
+ cancelled: "cancelled";
26
27
  completed: "completed";
27
- failed: "failed";
28
+ idle: "idle";
28
29
  starting: "starting";
29
30
  stopping: "stopping";
30
- cancelled: "cancelled";
31
31
  }>;
32
32
  export declare const ChatMessageRoleSchema: z.ZodEnum<{
33
- system: "system";
34
- status: "status";
35
33
  error: "error";
36
34
  user: "user";
37
35
  assistant: "assistant";
38
36
  tool: "tool";
37
+ status: "status";
38
+ system: "system";
39
39
  }>;
40
40
  export declare const ChatMessageSchema: z.ZodObject<{
41
41
  id: z.ZodString;
42
42
  sessionId: z.ZodNullable<z.ZodString>;
43
43
  role: z.ZodEnum<{
44
- system: "system";
45
- status: "status";
46
44
  error: "error";
47
45
  user: "user";
48
46
  assistant: "assistant";
49
47
  tool: "tool";
48
+ status: "status";
49
+ system: "system";
50
50
  }>;
51
51
  content: z.ZodString;
52
52
  createdAt: z.ZodNumber;
@@ -82,13 +82,13 @@ export declare const ChatViewStateSchema: z.ZodObject<{
82
82
  sessionId: z.ZodNullable<z.ZodString>;
83
83
  status: z.ZodEnum<{
84
84
  error: "error";
85
- idle: "idle";
85
+ failed: "failed";
86
86
  running: "running";
87
+ cancelled: "cancelled";
87
88
  completed: "completed";
88
- failed: "failed";
89
+ idle: "idle";
89
90
  starting: "starting";
90
91
  stopping: "stopping";
91
- cancelled: "cancelled";
92
92
  }>;
93
93
  config: z.ZodObject<{
94
94
  workspaceRoot: z.ZodString;
@@ -114,12 +114,12 @@ export declare const ChatViewStateSchema: z.ZodObject<{
114
114
  id: z.ZodString;
115
115
  sessionId: z.ZodNullable<z.ZodString>;
116
116
  role: z.ZodEnum<{
117
- system: "system";
118
- status: "status";
119
117
  error: "error";
120
118
  user: "user";
121
119
  assistant: "assistant";
122
120
  tool: "tool";
121
+ status: "status";
122
+ system: "system";
123
123
  }>;
124
124
  content: z.ZodString;
125
125
  createdAt: z.ZodNumber;
@@ -31,6 +31,9 @@ export type ActiveSession = {
31
31
  drainingPendingPrompts: boolean;
32
32
  pluginSandboxShutdown?: () => Promise<void>;
33
33
  turnUsageBaseline?: SessionAccumulatedUsage;
34
+ turnAggregateUsageBaseline?: SessionAccumulatedUsage;
35
+ turnPrimaryUsage?: SessionAccumulatedUsage;
36
+ turnUsageByAgent?: Map<string, SessionAccumulatedUsage>;
34
37
  /**
35
38
  * Set to `true` once the assistant successfully invoked the canonical
36
39
  * completion tool (`submit_and_exit`) for this session. Used to:
@@ -1,5 +1,12 @@
1
1
  import type { SessionLineage, SessionRuntimeRecordShape } from "@cline/shared";
2
2
  import type { SessionSource, SessionStatus } from "./common";
3
+ export interface SessionUsageMetadata {
4
+ inputTokens: number;
5
+ outputTokens: number;
6
+ cacheReadTokens: number;
7
+ cacheWriteTokens: number;
8
+ totalCost: number;
9
+ }
3
10
  export interface SessionRef extends SessionLineage {
4
11
  sessionId: string;
5
12
  }
@@ -10,6 +17,9 @@ export interface SessionRecord extends SessionRef, Omit<SessionRuntimeRecordShap
10
17
  export interface SessionHistoryMetadata extends Record<string, unknown> {
11
18
  title?: string;
12
19
  totalCost?: number;
20
+ aggregatedAgentsCost?: number;
21
+ usage?: SessionUsageMetadata;
22
+ aggregateUsage?: SessionUsageMetadata;
13
23
  checkpoint?: {
14
24
  latest?: {
15
25
  ref?: string;
package/dist/types.d.ts CHANGED
@@ -9,7 +9,7 @@ export type { BuiltinToolAvailabilityContext, ToolCatalogEntry, } from "./extens
9
9
  export { getCoreAcpToolNames, getCoreBuiltinToolCatalog, getCoreDefaultEnabledToolIds, getCoreHeadlessToolNames, resolveCoreSelectedToolIds, TEAM_TOOL_NAMES, } from "./extensions/tools";
10
10
  export type { RuntimeCapabilities } from "./runtime/capabilities";
11
11
  export type { SessionBackend } from "./runtime/host/host";
12
- export type { PendingPromptMutationResult, PendingPromptsDeleteInput, PendingPromptsListInput, PendingPromptsRuntimeService, PendingPromptsServiceApi, PendingPromptsUpdateInput, RuntimeHost, RuntimeHost as SessionHost, RuntimeHostMode, SendSessionInput, SessionAccumulatedUsage, StartSessionInput, StartSessionResult, } from "./runtime/host/runtime-host";
12
+ export type { PendingPromptMutationResult, PendingPromptsDeleteInput, PendingPromptsListInput, PendingPromptsRuntimeService, PendingPromptsServiceApi, PendingPromptsUpdateInput, RuntimeHost, RuntimeHost as SessionHost, RuntimeHostMode, SendSessionInput, SessionAccumulatedUsage, SessionUsageSummary, StartSessionInput, StartSessionResult, } from "./runtime/host/runtime-host";
13
13
  export type { BuiltRuntime as RuntimeEnvironment, RuntimeBuilder, RuntimeBuilderInput, SessionRuntime, } from "./runtime/orchestration/session-runtime";
14
14
  export type { SandboxCallOptions, SubprocessSandboxOptions, } from "./runtime/tools/subprocess-sandbox";
15
15
  export { SubprocessSandbox } from "./runtime/tools/subprocess-sandbox";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cline/core",
3
3
  "description": "Cline Core SDK for Node Runtime",
4
- "version": "0.0.38",
4
+ "version": "0.0.39",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/cline/sdk",
@@ -16,22 +16,18 @@
16
16
  },
17
17
  "exports": {
18
18
  ".": {
19
- "development": "./src/index.ts",
20
19
  "types": "./dist/index.d.ts",
21
20
  "import": "./dist/index.js"
22
21
  },
23
22
  "./hub": {
24
- "development": "./src/hub/index.ts",
25
23
  "types": "./dist/hub/index.d.ts",
26
24
  "import": "./dist/hub/index.js"
27
25
  },
28
26
  "./hub/daemon-entry": {
29
- "development": "./src/hub/daemon/entry.ts",
30
27
  "types": "./dist/hub/daemon/entry.d.ts",
31
28
  "import": "./dist/hub/daemon/entry.js"
32
29
  },
33
30
  "./telemetry": {
34
- "development": "./src/services/telemetry/index.ts",
35
31
  "types": "./dist/services/telemetry/index.d.ts",
36
32
  "import": "./dist/services/telemetry/index.js"
37
33
  }
@@ -48,9 +44,9 @@
48
44
  "test:watch": "vitest --config vitest.config.ts"
49
45
  },
50
46
  "dependencies": {
51
- "@cline/agents": "workspace:*",
52
- "@cline/shared": "workspace:*",
53
- "@cline/llms": "workspace:*",
47
+ "@cline/agents": "0.0.39",
48
+ "@cline/shared": "0.0.39",
49
+ "@cline/llms": "0.0.39",
54
50
  "@opentelemetry/api": "^1.9.0",
55
51
  "@opentelemetry/api-logs": "^0.214.0",
56
52
  "@opentelemetry/exporter-logs-otlp-http": "^0.214.0",