@cline/core 0.0.83 → 0.0.84

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.
Files changed (35) hide show
  1. package/dist/cron/service/schedule-tool.d.ts +3 -3
  2. package/dist/extensions/composio/composio-tools-extension.d.ts +13 -0
  3. package/dist/extensions/context/compaction-shared.d.ts +9 -1
  4. package/dist/extensions/context/compaction.d.ts +10 -2
  5. package/dist/extensions/tools/team/configured-agent-tool.d.ts +1 -3
  6. package/dist/hooks/hook-file-hooks.d.ts +27 -0
  7. package/dist/hooks/subprocess-runner.d.ts +23 -0
  8. package/dist/hooks/subprocess.d.ts +10 -0
  9. package/dist/hub/client/index.d.ts +7 -3
  10. package/dist/hub/daemon/entry.js +217 -214
  11. package/dist/hub/index.js +208 -205
  12. package/dist/hub/runtime-host/hub-runtime-host.d.ts +1 -0
  13. package/dist/hub/server/handlers/session-handlers.d.ts +1 -0
  14. package/dist/index.d.ts +8 -5
  15. package/dist/index.js +237 -235
  16. package/dist/remote/remote-helper-entry.js +2 -2
  17. package/dist/remote/remote-helper.js +2 -2
  18. package/dist/runtime/host/runtime-host.d.ts +2 -0
  19. package/dist/runtime/orchestration/oauth-refresh-lock.d.ts +6 -0
  20. package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +1 -0
  21. package/dist/runtime/turn-queue/pending-prompt-service.d.ts +1 -0
  22. package/dist/services/feature-flags/FeatureFlagsService.d.ts +2 -0
  23. package/dist/services/feature-flags/cline-account-feature-flags.d.ts +5 -0
  24. package/dist/services/global-settings.d.ts +3 -3
  25. package/dist/services/llms/cline-recommended-models.d.ts +1 -0
  26. package/dist/services/llms/handler-factory.d.ts +12 -0
  27. package/dist/services/llms/provider-settings.d.ts +18 -18
  28. package/dist/services/telemetry/core-events.d.ts +56 -0
  29. package/dist/services/telemetry/index.js +1 -1
  30. package/dist/session/models/session-manifest.d.ts +1 -1
  31. package/dist/session/stores/session-manifest-store.d.ts +2 -4
  32. package/dist/tasks/agenda-task-tool.d.ts +2 -2
  33. package/dist/tasks/task-tool.d.ts +5 -5
  34. package/dist/types/chat-schema.d.ts +7 -7
  35. package/package.json +4 -4
@@ -17,23 +17,23 @@ export declare const ProviderIdSchema: z.ZodString;
17
17
  export declare const ProviderProtocolSchema: z.ZodEnum<{
18
18
  anthropic: "anthropic";
19
19
  gemini: "gemini";
20
+ "openai-chat": "openai-chat";
21
+ "openai-responses": "openai-responses";
20
22
  "openai-r1": "openai-r1";
21
23
  "ai-sdk": "ai-sdk";
22
- "openai-responses": "openai-responses";
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";
29
28
  gemini: "gemini";
30
- vertex: "vertex";
31
- "openai-compatible": "openai-compatible";
32
- openai: "openai";
33
29
  "openai-r1": "openai-r1";
34
30
  "ai-sdk": "ai-sdk";
35
31
  "ai-sdk-community": "ai-sdk-community";
32
+ openai: "openai";
33
+ "openai-compatible": "openai-compatible";
34
+ bedrock: "bedrock";
36
35
  fetch: "fetch";
36
+ vertex: "vertex";
37
37
  }>;
38
38
  export declare const AuthSettingsSchema: z.ZodObject<{
39
39
  apiKey: z.ZodOptional<z.ZodString>;
@@ -68,10 +68,10 @@ export declare const AwsSettingsSchema: z.ZodObject<{
68
68
  region: z.ZodOptional<z.ZodString>;
69
69
  profile: z.ZodOptional<z.ZodString>;
70
70
  authentication: z.ZodOptional<z.ZodEnum<{
71
+ profile: "profile";
71
72
  iam: "iam";
72
73
  "api-key": "api-key";
73
74
  apikey: "apikey";
74
- profile: "profile";
75
75
  }>>;
76
76
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
77
77
  useCrossRegionInference: z.ZodOptional<z.ZodBoolean>;
@@ -106,8 +106,8 @@ export declare const SapSettingsSchema: z.ZodObject<{
106
106
  export type SapSettings = z.infer<typeof SapSettingsSchema>;
107
107
  export declare const OcaSettingsSchema: z.ZodObject<{
108
108
  mode: z.ZodOptional<z.ZodEnum<{
109
- external: "external";
110
109
  internal: "internal";
110
+ external: "external";
111
111
  }>>;
112
112
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
113
113
  }, z.core.$strip>;
@@ -140,23 +140,23 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
140
140
  protocol: z.ZodOptional<z.ZodEnum<{
141
141
  anthropic: "anthropic";
142
142
  gemini: "gemini";
143
+ "openai-chat": "openai-chat";
144
+ "openai-responses": "openai-responses";
143
145
  "openai-r1": "openai-r1";
144
146
  "ai-sdk": "ai-sdk";
145
- "openai-responses": "openai-responses";
146
- "openai-chat": "openai-chat";
147
147
  }>>;
148
148
  client: z.ZodOptional<z.ZodEnum<{
149
149
  custom: "custom";
150
150
  anthropic: "anthropic";
151
- bedrock: "bedrock";
152
151
  gemini: "gemini";
153
- vertex: "vertex";
154
- "openai-compatible": "openai-compatible";
155
- openai: "openai";
156
152
  "openai-r1": "openai-r1";
157
153
  "ai-sdk": "ai-sdk";
158
154
  "ai-sdk-community": "ai-sdk-community";
155
+ openai: "openai";
156
+ "openai-compatible": "openai-compatible";
157
+ bedrock: "bedrock";
159
158
  fetch: "fetch";
159
+ vertex: "vertex";
160
160
  }>>;
161
161
  routingProviderId: z.ZodOptional<z.ZodString>;
162
162
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -184,10 +184,10 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
184
184
  region: z.ZodOptional<z.ZodString>;
185
185
  profile: z.ZodOptional<z.ZodString>;
186
186
  authentication: z.ZodOptional<z.ZodEnum<{
187
+ profile: "profile";
187
188
  iam: "iam";
188
189
  "api-key": "api-key";
189
190
  apikey: "apikey";
190
- profile: "profile";
191
191
  }>>;
192
192
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
193
193
  useCrossRegionInference: z.ZodOptional<z.ZodBoolean>;
@@ -218,8 +218,8 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
218
218
  }, z.core.$strip>>;
219
219
  oca: z.ZodOptional<z.ZodObject<{
220
220
  mode: z.ZodOptional<z.ZodEnum<{
221
- external: "external";
222
221
  internal: "internal";
222
+ external: "external";
223
223
  }>>;
224
224
  usePromptCache: z.ZodOptional<z.ZodBoolean>;
225
225
  }, z.core.$strip>>;
@@ -231,10 +231,10 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
231
231
  capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
232
232
  tools: "tools";
233
233
  reasoning: "reasoning";
234
- streaming: "streaming";
235
234
  "prompt-cache": "prompt-cache";
236
- "computer-use": "computer-use";
235
+ streaming: "streaming";
237
236
  vision: "vision";
237
+ "computer-use": "computer-use";
238
238
  oauth: "oauth";
239
239
  popular: "popular";
240
240
  }>>>;
@@ -42,6 +42,7 @@ export declare const CORE_TELEMETRY_EVENTS: {
42
42
  readonly CREATED: "task.created";
43
43
  readonly RESTARTED: "task.restarted";
44
44
  readonly COMPLETED: "task.completed";
45
+ readonly GIT_SNAPSHOT: "task.git_snapshot";
45
46
  readonly CONVERSATION_TURN: "task.conversation_turn";
46
47
  readonly TOKEN_USAGE: "task.tokens";
47
48
  readonly MODE_SWITCH: "task.mode";
@@ -68,6 +69,7 @@ export declare const CORE_TELEMETRY_EVENTS: {
68
69
  };
69
70
  readonly HOOKS: {
70
71
  readonly DISCOVERY_COMPLETED: "hooks.discovery_completed";
72
+ readonly DETACHED_RUNTIME: "hooks.detached_runtime";
71
73
  };
72
74
  readonly WORKSPACE: {
73
75
  readonly INITIALIZED: "workspace.initialized";
@@ -100,6 +102,46 @@ export interface RunCommandsTimeoutTelemetryProperties {
100
102
  tool_call_id?: string;
101
103
  }
102
104
  export { captureAgentUnexpectedReasoningTokens, captureTaskLifecycleEvent, type CaptureAgentUnexpectedReasoningTokensInput, type CaptureTaskLifecycleEventInput, };
105
+ export interface GitSnapshotProperties {
106
+ schema_version: 1;
107
+ /** Actual Core session ID; ulid duplicates it for existing export consumers. */
108
+ sessionId: string;
109
+ ulid: string;
110
+ providerId: string;
111
+ workspace_id: string;
112
+ /** VS Code workspace-folder count at observation start, not Git repo count; 0 with no folders, even outside Git. */
113
+ workspace_root_count: number;
114
+ observation_window_id: string;
115
+ observation_sequence: number;
116
+ /** ISO observation-start time, after the model response. Git reads are not atomic. */
117
+ observed_at: string;
118
+ /** Background observation triggered by this response; tools may execute during the read. */
119
+ boundary: "model_call";
120
+ runId?: string;
121
+ iteration?: number;
122
+ agentId?: string;
123
+ /** Surfaced response's backend ID, when available; never synthesized or inherited from an earlier request. */
124
+ request_id?: string;
125
+ request_id_status: "present" | "missing";
126
+ git: {
127
+ /** partial: status hit its timeout/output cap but separate reads recovered HEAD and/or branch. */
128
+ state: "ok" | "unborn" | "non_git" | "unavailable" | "partial";
129
+ head_sha?: string;
130
+ branch?: string;
131
+ /** Any staged/unstaged/untracked changes. All four flags are absent for partial/non_git/unavailable, not false. */
132
+ dirty?: boolean;
133
+ /** Index changes, including unmerged entries; does not imply commit readiness. */
134
+ staged?: boolean;
135
+ /** Worktree changes, including unmerged entries. */
136
+ unstaged?: boolean;
137
+ /** Non-ignored untracked files. */
138
+ untracked?: boolean;
139
+ remote_url?: string;
140
+ remote_state?: "ok" | "none" | "unsupported" | "unavailable";
141
+ };
142
+ }
143
+ /** Ordinary telemetry: use a consent-aware service, never captureRequired. */
144
+ export declare function captureGitSnapshot(telemetry: ITelemetryService | undefined, properties: GitSnapshotProperties): void;
103
145
  export interface WorkspaceInitializedProperties {
104
146
  root_count: number;
105
147
  vcs_types: ReadonlyArray<string>;
@@ -328,6 +370,20 @@ export declare function captureSubagentExecution(telemetry: ITelemetryService |
328
370
  errorMessage?: string;
329
371
  type?: "agent" | "team";
330
372
  } & Partial<TelemetryAgentIdentityProperties>): void;
373
+ /**
374
+ * Records how long a fire-and-forget hook ran. Detached hooks are never
375
+ * awaited, so their runtime is otherwise invisible — this is the evidence for
376
+ * whether any of them could safely be made blocking. `exited: false` marks a
377
+ * censored observation: the hook was still running when the observation
378
+ * window closed, so treat `durationMs` as a lower bound and count these
379
+ * separately rather than averaging them in.
380
+ */
381
+ export declare function captureDetachedHookRuntime(telemetry: ITelemetryService | undefined, event: {
382
+ hookName: string;
383
+ durationMs: number;
384
+ exitCode: number | null;
385
+ exited: boolean;
386
+ }): void;
331
387
  export declare function captureHookDiscovery(telemetry: ITelemetryService | undefined, hookName: string, globalCount: number, workspaceCount: number): void;
332
388
  /**
333
389
  * Identifies which compaction implementation produced a
@@ -1 +1 @@
1
- import{existsSync as v,mkdirSync as u,readFileSync as c,writeFileSync as m}from"node:fs";import{resolve as d}from"node:path";import{resolveSessionDataDir as l}from"@cline/shared/storage";import{nanoid as r}from"nanoid";import*as p from"node-machine-id";var n="machine-id",M,w=!1;function Q(){if(!w)M=h(),w=!0;return M??q()}function H(f){let T=f?.trim();if(T)return T;let A=h();if(A)return A;return q()}function a(){let f=p;return f.machineIdSync??f.default?.machineIdSync}function h(){try{let f=a();if(!f)return;return f().trim()||void 0}catch{return}}function q(){let f=l(),T=d(f,n);try{if(v(T)){let O=c(T,"utf8").trim();if(O.length>0)return O}}catch{}let A=`cl-${r()}`;try{u(f,{recursive:!0}),m(T,A,"utf8")}catch{}return A}class X{name;metadata;meter;logger;enabled;distinctId;commonProperties;counters=new Map;histograms=new Map;gauges=new Map;gaugeValues=new Map;meterProvider;loggerProvider;constructor(f){this.name=f.name??"OpenTelemetryAdapter",this.metadata={...f.metadata},this.meterProvider=f.meterProvider,this.loggerProvider=f.loggerProvider,this.meter=f.meterProvider?.getMeter("cline")??null,this.logger=f.loggerProvider?.getLogger("cline")??null,this.enabled=f.enabled??!0,this.distinctId=f.distinctId,this.commonProperties=f.commonProperties?{...f.commonProperties}:{}}emit(f,T){if(!this.isEnabled())return;this.emitLog(f,T,!1)}emitRequired(f,T){this.emitLog(f,T,!0)}recordCounter(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.counters.get(f);if(!J)J=this.meter.createCounter(f,O?{description:O}:void 0),this.counters.set(f,J);J.add(T,this.flattenProperties(this.buildAttributes(A)))}recordHistogram(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.histograms.get(f);if(!J)J=this.meter.createHistogram(f,O?{description:O}:void 0),this.histograms.set(f,J);J.record(T,this.flattenProperties(this.buildAttributes(A)))}recordGauge(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.buildAttributes(A),_=JSON.stringify(J),W=this.gaugeValues.get(f);if(T===null){if(W){if(W.delete(_),W.size===0)this.gaugeValues.delete(f),this.gauges.delete(f)}return}let K=W;if(!K)K=new Map,this.gaugeValues.set(f,K);if(!this.gauges.has(f)){let $=this.meter.createObservableGauge(f,O?{description:O}:void 0);$.addCallback((R)=>{for(let C of this.snapshotGaugeSeries(f))R.observe(C.value,this.flattenProperties(C.attributes))}),this.gauges.set(f,$)}K.set(_,{value:T,attributes:J})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}setDistinctId(f){this.distinctId=f}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}async flush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.()])}emitLog(f,T,A){if(!this.logger)return;let O=this.flattenProperties(this.buildAttributes(T,A));this.logger.emit({severityText:"INFO",body:f,attributes:O})}buildAttributes(f,T=!1){return{...this.commonProperties,...this.metadata,...f,...this.distinctId?{distinct_id:this.distinctId}:{},...T?{_required:!0}:{}}}snapshotGaugeSeries(f){let T=this.gaugeValues.get(f);if(!T)return[];return Array.from(T.values(),(A)=>({value:A.value,attributes:A.attributes?{...A.attributes}:void 0}))}flattenProperties(f,T="",A=new WeakSet,O=0){if(!f)return{};let j={},J=100,_=10;for(let[W,K]of Object.entries(f)){if(W==="__proto__"||W==="constructor"||W==="prototype")continue;let $=T?`${T}.${W}`:W;if(K===null||K===void 0){j[$]=String(K);continue}if(Array.isArray(K)){let R=K.length>J?K.slice(0,J):K;try{j[$]=JSON.stringify(R)}catch{j[$]="[UnserializableArray]"}if(K.length>J)j[`${$}_truncated`]=!0,j[`${$}_original_length`]=K.length;continue}if(typeof K==="object"){if(K instanceof Date){j[$]=K.toISOString();continue}if(K instanceof Error){j[$]=K.message;continue}if(A.has(K)){j[$]="[Circular]";continue}if(O>=_){j[$]="[MaxDepthExceeded]";continue}A.add(K),Object.assign(j,this.flattenProperties(K,$,A,O+1));continue}if(s(K)){j[$]=K;continue}try{j[$]=JSON.stringify(K)}catch{j[$]=String(K)}}return j}}function s(f){return typeof f==="string"||typeof f==="number"||typeof f==="boolean"}import{markOtlpTraceRelayProvider as Kf}from"@cline/shared";import{metrics as Wf,trace as $f}from"@opentelemetry/api";import{logs as Bf}from"@opentelemetry/api-logs";import{OTLPLogExporter as Pf}from"@opentelemetry/exporter-logs-otlp-http";import{OTLPMetricExporter as Rf}from"@opentelemetry/exporter-metrics-otlp-http";import{OTLPTraceExporter as Uf}from"@opentelemetry/exporter-trace-otlp-http";import{resourceFromAttributes as Hf}from"@opentelemetry/resources";import{BatchLogRecordProcessor as Xf,ConsoleLogRecordExporter as Yf,LoggerProvider as Zf}from"@opentelemetry/sdk-logs";import{ConsoleMetricExporter as Qf,MeterProvider as Sf,PeriodicExportingMetricReader as z}from"@opentelemetry/sdk-metrics";import{BatchSpanProcessor as Vf,ConsoleSpanExporter as Lf,SimpleSpanProcessor as Ff}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as kf}from"@opentelemetry/sdk-trace-node";import{ATTR_SERVICE_NAME as Ef,ATTR_SERVICE_VERSION as Cf}from"@opentelemetry/semantic-conventions";import{mkdirSync as of,readFileSync as i,statSync as o,writeFileSync as tf}from"node:fs";import{CONFIGURABLE_MODEL_TOOL_NAMES as t}from"@cline/shared";import{resolveGlobalSettingsPath as e}from"@cline/shared/storage";import{z as B}from"zod";import{AGENT_UNEXPECTED_REASONING_TOKENS_EVENT as gf,captureAgentUnexpectedReasoningTokens as vf,captureTaskLifecycleEvent as uf,SDK_ERROR_TELEMETRY_EVENT as cf,TASK_CANCELLED_EVENT as mf,TASK_FIRST_CHUNK_RECEIVED_EVENT as df,TASK_PROVIDER_REQUEST_STARTED_EVENT as lf,TASK_PROVIDER_STREAM_FAILED_EVENT as rf,TASK_PROVIDER_STREAM_STARTED_EVENT as pf}from"@cline/shared";var S=B.preprocess((f)=>Array.isArray(f)?f.filter((T)=>typeof T==="string").map((T)=>T.trim()).filter(Boolean):void 0,B.array(B.string()).optional()).transform((f)=>{if(!f)return;let T=[...new Set(f)].sort((A,O)=>A.localeCompare(O));return T.length>0?T:void 0}),ff=B.enum(["basic","agentic"]).catch("agentic"),Tf=B.partialRecord(B.enum(t),B.object({enabled:B.boolean()}).strip()).optional(),Af=B.enum(["plan","act"]),I=B.object({telemetryOptOut:B.boolean().default(!1).catch(!1),autoUpdateEnabled:B.boolean().default(!0).catch(!0),compactionStrategy:ff.optional(),compactionEnabled:B.boolean().optional().catch(void 0),planActMode:Af.optional().catch(void 0),toolAutoApprove:B.boolean().optional().catch(void 0),tuiTheme:B.string().optional().catch(void 0),disabledTools:S.optional(),tools:Tf,disabledPlugins:S.optional(),disabledAgentPlugins:S.optional()}).strip().transform((f)=>{let T={autoUpdateEnabled:f.autoUpdateEnabled,telemetryOptOut:f.telemetryOptOut};if(f.compactionStrategy)T.compactionStrategy=f.compactionStrategy;if(f.compactionEnabled!==void 0)T.compactionEnabled=f.compactionEnabled;if(f.planActMode)T.planActMode=f.planActMode;if(f.toolAutoApprove!==void 0)T.toolAutoApprove=f.toolAutoApprove;if(f.tuiTheme?.trim())T.tuiTheme=f.tuiTheme.trim();if(f.disabledTools?.length)T.disabledTools=f.disabledTools;if(f.tools&&Object.keys(f.tools).length>0)T.tools=f.tools;if(f.disabledPlugins?.length)T.disabledPlugins=f.disabledPlugins;if(f.disabledAgentPlugins?.length)T.disabledAgentPlugins=f.disabledAgentPlugins;return T});function Y(){return I.parse({})}var V;function Of(f){if(f.disabledTools)Object.freeze(f.disabledTools);if(f.tools){for(let T of Object.values(f.tools))Object.freeze(T);Object.freeze(f.tools)}if(f.disabledPlugins)Object.freeze(f.disabledPlugins);if(f.disabledAgentPlugins)Object.freeze(f.disabledAgentPlugins);return Object.freeze(f)}function jf(f){let T;try{T=i(f,"utf8")}catch{return{value:Y(),loadFailed:!0}}try{let A=I.safeParse(JSON.parse(T));return A.success?{value:A.data,loadFailed:!1}:{value:Y(),loadFailed:!0}}catch{return{value:Y(),loadFailed:!0}}}function _f(){let f=e(),T=o(f,{throwIfNoEntry:!1}),A=T?.mtimeMs??0,O=T?.size??0,j=V;if(j&&j.path===f&&j.mtimeMs===A&&j.size===O)return j;let J=T?jf(f):{value:Y(),loadFailed:!1},_=Of(J.value);return V={path:f,mtimeMs:A,size:O,value:_,loadFailed:J.loadFailed},V}function Jf(){return _f().value}function N(){return Jf().telemetryOptOut}class L{name;logger;enabled;constructor(f={}){this.name=f.name??"TelemetryLoggerSink",this.logger=f.logger,this.enabled=f.enabled??!0}emit(f,T){if(!this.isEnabled())return;this.logger?.log("telemetry.event",{telemetrySink:this.name,event:f,properties:T})}emitRequired(f,T){this.logger?.log("telemetry.required_event",{telemetrySink:this.name,severity:"warn",event:f,properties:T})}recordCounter(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"counter",name:f,value:T,attributes:A,description:O,required:j===!0})}recordHistogram(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"histogram",name:f,value:T,attributes:A,description:O,required:j===!0})}recordGauge(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"gauge",name:f,value:T,attributes:A,description:O,required:j===!0})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}async flush(){}async dispose(){}}class Z{adapters;metadata;distinctId;deviceId;commonProperties;constructor(f={}){if(this.adapters=[...f.adapters??[]],f.logger)this.adapters.push(new L({logger:f.logger}));this.metadata={...f.metadata??{}},this.distinctId=f.distinctId,this.deviceId=f.deviceId??Q(),this.commonProperties={...f.commonProperties??{}}}addAdapter(f){this.adapters.push(f)}setDistinctId(f){this.distinctId=f}setMetadata(f){this.metadata={...f}}updateMetadata(f){this.metadata={...this.metadata,...f}}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}isEnabled(){return this.adapters.some((f)=>f.isEnabled())}capture(f){let T=this.buildAttributes(f.properties);for(let A of this.adapters)A.emit(f.event,T)}captureRequired(f,T){let A=this.buildAttributes(T);for(let O of this.adapters)O.emitRequired(f,A)}recordCounter(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordCounter(f,T,J,O,j)}recordHistogram(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordHistogram(f,T,J,O,j)}recordGauge(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordGauge(f,T,J,O,j)}async flush(){await Promise.all(this.adapters.map((f)=>f.flush()))}async dispose(){await Promise.all(this.adapters.map((f)=>f.dispose()))}buildAttributes(f){let T=typeof f?.distinct_id==="string"&&f.distinct_id.trim()?f.distinct_id.trim():this.distinctId,A={...this.commonProperties,...this.metadata,...f,...T?{distinct_id:T}:{},device_id:this.deviceId};return Object.fromEntries(Object.entries(A).filter(([,O])=>O!==void 0))}}class D{distinctId;metadata;commonProperties;constructor(f={}){this.distinctId=f.distinctId,this.metadata={...f.metadata??{}},this.commonProperties={...f.commonProperties??{}}}setDistinctId(f){this.distinctId=f}setMetadata(f){this.metadata={...f}}updateMetadata(f){this.metadata={...this.metadata,...f}}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}isEnabled(){return!1}capture(f){this.resolveProperties(f.properties)}captureRequired(f,T){this.resolveProperties(T)}recordCounter(){}recordHistogram(){}recordGauge(){}async flush(){}async dispose(){}resolveProperties(f){let T=typeof f?.distinct_id==="string"&&f.distinct_id.trim()?f.distinct_id.trim():this.distinctId,A={...this.commonProperties,...this.metadata,...f,...T?{distinct_id:T}:{}};return Object.fromEntries(Object.entries(A).filter(([,O])=>O!==void 0))}}class k{meterProvider;loggerProvider;tracerProvider;options;constructor(f={}){this.options=f;let T=Hf({[Ef]:f.serviceName??"cline",...f.serviceVersion?{[Cf]:f.serviceVersion}:{}});if(this.meterProvider=this.createMeterProvider(T),this.loggerProvider=this.createLoggerProvider(T),this.tracerProvider=this.createTracerProvider(T),this.meterProvider)Wf.setGlobalMeterProvider(this.meterProvider);if(this.loggerProvider)Bf.setGlobalLoggerProvider(this.loggerProvider);if(this.tracerProvider)this.tracerProvider.register()}getTracer(f="cline",T){return $f.getTracer(f,T??this.options.serviceVersion)}createAdapter(f){return new X({...f,meterProvider:this.meterProvider,loggerProvider:this.loggerProvider})}createTelemetryService(f){let T=this.createAdapter({name:f.name,enabled:this.options.enabled,metadata:f.metadata});return new Z({...f,adapters:[T],distinctId:H(f.distinctId)})}async forceFlush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.(),this.tracerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.(),this.tracerProvider?.shutdown?.()])}createMeterProvider(f){let T=F(this.options.metricsExporter);if(T.length===0)return null;let A=Math.max(1000,this.options.metricExportIntervalMs??this.options.metricExportInterval??60000),O=Math.min(30000,Math.floor(A*0.8)),j=T.map((J)=>qf(J,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json",interval:A,timeout:O})).filter((J)=>J!==null);if(j.length===0)return null;return new Sf({resource:f,readers:j})}createTracerProvider(f){let T=F(this.options.tracesExporter);if(T.length===0)return null;let A=this.options.otlpTracesEndpoint??this.options.otlpEndpoint,O=this.options.otlpTracesHeaders??this.options.otlpHeaders,j=[],J=!1;for(let W of T){let K=hf(W,{endpoint:A,headers:O,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(K){if(j.push(K),W!=="console")J=!0}}if(j.length===0)return null;let _=new kf({resource:f,spanProcessors:j});if(J)Kf(_);return _}createLoggerProvider(f){let T=F(this.options.logsExporter);if(T.length===0)return null;let A=T.map((O)=>{let j=wf(O,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(!j)return null;return new Xf(j,{maxQueueSize:this.options.logMaxQueueSize??2048,maxExportBatchSize:this.options.logBatchSize??512,scheduledDelayMillis:this.options.logBatchTimeoutMs??this.options.logBatchTimeout??5000})}).filter((O)=>O!==null);if(A.length===0)return null;return new Zf({resource:f,processors:A})}}function x(f){let T=new k(f),A=T.createTelemetryService(f),O=()=>{A.captureRequired("telemetry.provider_created",{provider:"opentelemetry",enabled:f.enabled??!0,logsExporter:Array.isArray(f.logsExporter)?f.logsExporter.join(","):f.logsExporter,metricsExporter:Array.isArray(f.metricsExporter)?f.metricsExporter.join(","):f.metricsExporter,tracesExporter:Array.isArray(f.tracesExporter)?f.tracesExporter.join(","):f.tracesExporter,otlpProtocol:f.otlpProtocol,hasOtlpEndpoint:Boolean(f.otlpEndpoint),serviceName:f.serviceName,serviceVersion:f.serviceVersion})};if(!f.deferProviderCreatedEvent)O();return{provider:T,telemetry:A,emitProviderCreated:O}}function G(f){if(N())return{telemetry:new D(f)};if(f.enabled!==!0)return{telemetry:new Z({...f,distinctId:H(f.distinctId)})};return x(f)}function Mf(f){let{telemetry:T,provider:A,emitProviderCreated:O}=G(f);return{telemetry:T,provider:A,flush:async()=>{let _=A;if(_&&typeof _.forceFlush==="function")try{await _.forceFlush()}catch{}},dispose:async()=>{await Promise.allSettled([T.dispose(),A?.dispose()])},...f.deferProviderCreatedEvent&&O?{emitProviderCreated:O}:{}}}function F(f){if(!f)return[];return(Array.isArray(f)?f:f.split(",")).map((A)=>A.trim()).filter((A)=>A==="console"||A==="otlp")}function wf(f,T){if(f==="console")return new Yf;if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/logs");return new Pf({url:A,headers:T.headers})}function hf(f,T){if(f==="console")return new Ff(new Lf);if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/traces");return new Vf(new Uf({url:A,headers:T.headers}))}function qf(f,T){if(f==="console")return new z({exporter:new Qf,exportIntervalMillis:T.interval,exportTimeoutMillis:T.timeout});if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/metrics");return new z({exporter:new Rf({url:A,headers:T.headers}),exportIntervalMillis:T.interval,exportTimeoutMillis:T.timeout})}function E(f,T){let A=new URL(f),O=A.pathname.endsWith("/")?A.pathname.slice(0,-1):A.pathname;return A.pathname=O.endsWith(T)?O:`${O}${T}`,A.toString()}import{SESSION_STATUS_VALUES as MT}from"@cline/shared";var U={CORE:"core",CLI:"cli",SUBAGENT:"subagent",DESKTOP:"desktop",KANBAN:"kanban",API:"api",WEB:"web",VSCODE:"vscode",ENTERPRISE:"enterprise",IDE:"ide",JETBRAINS:"jetbrains",NEOVIM:"neovim",UNKNOWN:"unknown"};function y(f){let T=[f?.name,f?.platform].filter((A)=>typeof A==="string").join(" ").toLowerCase();if(!T)return;if(T.includes("vscode")||T.includes("visual studio code"))return U.VSCODE;if(T.includes("jetbrains")||T.includes("webstorm")||T.includes("intellij")||T.includes("pycharm")||T.includes("goland")||T.includes("clion")||T.includes("rider")||T.includes("android studio"))return U.JETBRAINS;if(T.includes("neovim"))return U.NEOVIM;if(T.includes("kanban"))return U.KANBAN;if(T.includes("desktop"))return U.DESKTOP;if(T.includes("cline-platform"))return U.WEB;if(T.includes("cline-cli")||T.includes("cline-acp"))return U.CLI;if(T.includes("cline-sdk")||T.includes("cline-core"))return U.CORE;return}function P(f){let T=f?.trim();return T?T:void 0}function b(f){let T=f.client,A=y(T)??P(f.source),O=P(T.version),j=P(T.platform)??P(T.name),J=P(T.platformVersion)??O,_={cline_type:A,extension_version:O,platform:j,platform_version:J};if(f.user?.accountId===void 0)return _;let W=typeof f.user.accountId==="string"?P(f.user.accountId):void 0;return{..._,distinct_id:W??P(f.user.distinctId),user_id:W,account_id:W,account_email:W?P(f.user.email):void 0,organization_id:W?P(f.user.organizationId):void 0}}function g(f,T){let A={},O={},j,J=(_)=>({...T,...O,...A,..._,...j?{distinct_id:j}:{}});return{setDistinctId(_){j=P(_)},setMetadata(_){A={..._}},updateMetadata(_){A={...A,..._}},setCommonProperties(_){O={..._}},updateCommonProperties(_){O={...O,..._}},isEnabled:()=>f.isEnabled(),capture:(_)=>f.capture({event:_.event,properties:J(_.properties)}),captureRequired:(_,W)=>f.captureRequired(_,J(W)),recordCounter:(_,W,K,$,R)=>f.recordCounter(_,W,J(K),$,R),recordHistogram:(_,W,K,$,R)=>f.recordHistogram(_,W,J(K),$,R),recordGauge:(_,W,K,$,R)=>f.recordGauge(_,W,J(K),$,R),flush:()=>f.flush(),dispose:async()=>{}}}function If(f,T){return g(f,b(T))}export{H as resolveCoreDistinctId,Q as resolveCoreDeviceId,b as resolveClientTelemetryProperties,g as createScopedTelemetryService,x as createOpenTelemetryTelemetryService,G as createConfiguredTelemetryService,Mf as createConfiguredTelemetryHandle,If as createClientScopedTelemetryService,k as OpenTelemetryProvider,X as OpenTelemetryAdapter};
1
+ import{existsSync as v,mkdirSync as u,readFileSync as c,writeFileSync as m}from"node:fs";import{resolve as d}from"node:path";import{resolveSessionDataDir as l}from"@cline/shared/storage";import{nanoid as r}from"nanoid";import*as p from"node-machine-id";var n="machine-id",M,w=!1;function Q(){if(!w)M=h(),w=!0;return M??q()}function P(f){let T=f?.trim();if(T)return T;let A=h();if(A)return A;return q()}function a(){let f=p;return f.machineIdSync??f.default?.machineIdSync}function h(){try{let f=a();if(!f)return;return f().trim()||void 0}catch{return}}function q(){let f=l(),T=d(f,n);try{if(v(T)){let O=c(T,"utf8").trim();if(O.length>0)return O}}catch{}let A=`cl-${r()}`;try{u(f,{recursive:!0}),m(T,A,"utf8")}catch{}return A}class X{name;metadata;meter;logger;enabled;distinctId;commonProperties;counters=new Map;histograms=new Map;gauges=new Map;gaugeValues=new Map;meterProvider;loggerProvider;constructor(f){this.name=f.name??"OpenTelemetryAdapter",this.metadata={...f.metadata},this.meterProvider=f.meterProvider,this.loggerProvider=f.loggerProvider,this.meter=f.meterProvider?.getMeter("cline")??null,this.logger=f.loggerProvider?.getLogger("cline")??null,this.enabled=f.enabled??!0,this.distinctId=f.distinctId,this.commonProperties=f.commonProperties?{...f.commonProperties}:{}}emit(f,T){if(!this.isEnabled())return;this.emitLog(f,T,!1)}emitRequired(f,T){this.emitLog(f,T,!0)}recordCounter(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.counters.get(f);if(!J)J=this.meter.createCounter(f,O?{description:O}:void 0),this.counters.set(f,J);J.add(T,this.flattenProperties(this.buildAttributes(A)))}recordHistogram(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.histograms.get(f);if(!J)J=this.meter.createHistogram(f,O?{description:O}:void 0),this.histograms.set(f,J);J.record(T,this.flattenProperties(this.buildAttributes(A)))}recordGauge(f,T,A,O,j=!1){if(!this.meter||!j&&!this.isEnabled())return;let J=this.buildAttributes(A),_=JSON.stringify(J),W=this.gaugeValues.get(f);if(T===null){if(W){if(W.delete(_),W.size===0)this.gaugeValues.delete(f),this.gauges.delete(f)}return}let K=W;if(!K)K=new Map,this.gaugeValues.set(f,K);if(!this.gauges.has(f)){let $=this.meter.createObservableGauge(f,O?{description:O}:void 0);$.addCallback((U)=>{for(let C of this.snapshotGaugeSeries(f))U.observe(C.value,this.flattenProperties(C.attributes))}),this.gauges.set(f,$)}K.set(_,{value:T,attributes:J})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}setDistinctId(f){this.distinctId=f}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}async flush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.()])}emitLog(f,T,A){if(!this.logger)return;let O=this.flattenProperties(this.buildAttributes(T,A));this.logger.emit({severityText:"INFO",body:f,attributes:O})}buildAttributes(f,T=!1){return{...this.commonProperties,...this.metadata,...f,...this.distinctId?{distinct_id:this.distinctId}:{},...T?{_required:!0}:{}}}snapshotGaugeSeries(f){let T=this.gaugeValues.get(f);if(!T)return[];return Array.from(T.values(),(A)=>({value:A.value,attributes:A.attributes?{...A.attributes}:void 0}))}flattenProperties(f,T="",A=new WeakSet,O=0){if(!f)return{};let j={},J=100,_=10;for(let[W,K]of Object.entries(f)){if(W==="__proto__"||W==="constructor"||W==="prototype")continue;let $=T?`${T}.${W}`:W;if(K===null||K===void 0){j[$]=String(K);continue}if(Array.isArray(K)){let U=K.length>J?K.slice(0,J):K;try{j[$]=JSON.stringify(U)}catch{j[$]="[UnserializableArray]"}if(K.length>J)j[`${$}_truncated`]=!0,j[`${$}_original_length`]=K.length;continue}if(typeof K==="object"){if(K instanceof Date){j[$]=K.toISOString();continue}if(K instanceof Error){j[$]=K.message;continue}if(A.has(K)){j[$]="[Circular]";continue}if(O>=_){j[$]="[MaxDepthExceeded]";continue}A.add(K),Object.assign(j,this.flattenProperties(K,$,A,O+1));continue}if(s(K)){j[$]=K;continue}try{j[$]=JSON.stringify(K)}catch{j[$]=String(K)}}return j}}function s(f){return typeof f==="string"||typeof f==="number"||typeof f==="boolean"}import{LangfuseAttributesSpanProcessor as Kf}from"@cline/llms";import{markOtlpTraceRelayProvider as Wf}from"@cline/shared";import{metrics as $f,trace as Bf}from"@opentelemetry/api";import{logs as Rf}from"@opentelemetry/api-logs";import{OTLPLogExporter as Uf}from"@opentelemetry/exporter-logs-otlp-http";import{OTLPMetricExporter as Hf}from"@opentelemetry/exporter-metrics-otlp-http";import{OTLPTraceExporter as Pf}from"@opentelemetry/exporter-trace-otlp-http";import{resourceFromAttributes as Xf}from"@opentelemetry/resources";import{BatchLogRecordProcessor as Yf,ConsoleLogRecordExporter as Zf,LoggerProvider as Qf}from"@opentelemetry/sdk-logs";import{ConsoleMetricExporter as Sf,MeterProvider as Vf,PeriodicExportingMetricReader as z}from"@opentelemetry/sdk-metrics";import{BatchSpanProcessor as Lf,ConsoleSpanExporter as Ff,SimpleSpanProcessor as kf}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as Ef}from"@opentelemetry/sdk-trace-node";import{ATTR_SERVICE_NAME as Cf,ATTR_SERVICE_VERSION as Mf}from"@opentelemetry/semantic-conventions";import{mkdirSync as tf,readFileSync as i,statSync as o,writeFileSync as ef}from"node:fs";import{CONFIGURABLE_MODEL_TOOL_NAMES as t}from"@cline/shared";import{resolveGlobalSettingsPath as e}from"@cline/shared/storage";import{z as B}from"zod";import{AGENT_UNEXPECTED_REASONING_TOKENS_EVENT as vf,captureAgentUnexpectedReasoningTokens as uf,captureTaskLifecycleEvent as cf,SDK_ERROR_TELEMETRY_EVENT as mf,TASK_CANCELLED_EVENT as df,TASK_FIRST_CHUNK_RECEIVED_EVENT as lf,TASK_PROVIDER_REQUEST_STARTED_EVENT as rf,TASK_PROVIDER_STREAM_FAILED_EVENT as pf,TASK_PROVIDER_STREAM_STARTED_EVENT as nf}from"@cline/shared";var S=B.preprocess((f)=>Array.isArray(f)?f.filter((T)=>typeof T==="string").map((T)=>T.trim()).filter(Boolean):void 0,B.array(B.string()).optional()).transform((f)=>{if(!f)return;let T=[...new Set(f)].sort((A,O)=>A.localeCompare(O));return T.length>0?T:void 0}),ff=B.enum(["basic","agentic"]).catch("agentic"),Tf=B.partialRecord(B.enum(t),B.object({enabled:B.boolean()}).strip()).optional(),Af=B.enum(["plan","act"]),I=B.object({telemetryOptOut:B.boolean().default(!1).catch(!1),autoUpdateEnabled:B.boolean().default(!0).catch(!0),compactionStrategy:ff.optional(),compactionEnabled:B.boolean().optional().catch(void 0),planActMode:Af.optional().catch(void 0),toolAutoApprove:B.boolean().optional().catch(void 0),tuiTheme:B.string().optional().catch(void 0),disabledTools:S.optional(),tools:Tf,disabledPlugins:S.optional(),disabledAgentPlugins:S.optional()}).strip().transform((f)=>{let T={autoUpdateEnabled:f.autoUpdateEnabled,telemetryOptOut:f.telemetryOptOut};if(f.compactionStrategy)T.compactionStrategy=f.compactionStrategy;if(f.compactionEnabled!==void 0)T.compactionEnabled=f.compactionEnabled;if(f.planActMode)T.planActMode=f.planActMode;if(f.toolAutoApprove!==void 0)T.toolAutoApprove=f.toolAutoApprove;if(f.tuiTheme?.trim())T.tuiTheme=f.tuiTheme.trim();if(f.disabledTools?.length)T.disabledTools=f.disabledTools;if(f.tools&&Object.keys(f.tools).length>0)T.tools=f.tools;if(f.disabledPlugins?.length)T.disabledPlugins=f.disabledPlugins;if(f.disabledAgentPlugins?.length)T.disabledAgentPlugins=f.disabledAgentPlugins;return T});function Y(){return I.parse({})}var V;function Of(f){if(f.disabledTools)Object.freeze(f.disabledTools);if(f.tools){for(let T of Object.values(f.tools))Object.freeze(T);Object.freeze(f.tools)}if(f.disabledPlugins)Object.freeze(f.disabledPlugins);if(f.disabledAgentPlugins)Object.freeze(f.disabledAgentPlugins);return Object.freeze(f)}function jf(f){let T;try{T=i(f,"utf8")}catch{return{value:Y(),loadFailed:!0}}try{let A=I.safeParse(JSON.parse(T));return A.success?{value:A.data,loadFailed:!1}:{value:Y(),loadFailed:!0}}catch{return{value:Y(),loadFailed:!0}}}function _f(){let f=e(),T=o(f,{throwIfNoEntry:!1}),A=T?.mtimeMs??0,O=T?.size??0,j=V;if(j&&j.path===f&&j.mtimeMs===A&&j.size===O)return j;let J=T?jf(f):{value:Y(),loadFailed:!1},_=Of(J.value);return V={path:f,mtimeMs:A,size:O,value:_,loadFailed:J.loadFailed},V}function Jf(){return _f().value}function N(){return Jf().telemetryOptOut}class L{name;logger;enabled;constructor(f={}){this.name=f.name??"TelemetryLoggerSink",this.logger=f.logger,this.enabled=f.enabled??!0}emit(f,T){if(!this.isEnabled())return;this.logger?.log("telemetry.event",{telemetrySink:this.name,event:f,properties:T})}emitRequired(f,T){this.logger?.log("telemetry.required_event",{telemetrySink:this.name,severity:"warn",event:f,properties:T})}recordCounter(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"counter",name:f,value:T,attributes:A,description:O,required:j===!0})}recordHistogram(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"histogram",name:f,value:T,attributes:A,description:O,required:j===!0})}recordGauge(f,T,A,O,j){if(!j&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"gauge",name:f,value:T,attributes:A,description:O,required:j===!0})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}async flush(){}async dispose(){}}class Z{adapters;metadata;distinctId;deviceId;commonProperties;constructor(f={}){if(this.adapters=[...f.adapters??[]],f.logger)this.adapters.push(new L({logger:f.logger}));this.metadata={...f.metadata??{}},this.distinctId=f.distinctId,this.deviceId=f.deviceId??Q(),this.commonProperties={...f.commonProperties??{}}}addAdapter(f){this.adapters.push(f)}setDistinctId(f){this.distinctId=f}setMetadata(f){this.metadata={...f}}updateMetadata(f){this.metadata={...this.metadata,...f}}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}isEnabled(){return this.adapters.some((f)=>f.isEnabled())}capture(f){let T=this.buildAttributes(f.properties);for(let A of this.adapters)A.emit(f.event,T)}captureRequired(f,T){let A=this.buildAttributes(T);for(let O of this.adapters)O.emitRequired(f,A)}recordCounter(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordCounter(f,T,J,O,j)}recordHistogram(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordHistogram(f,T,J,O,j)}recordGauge(f,T,A,O,j=!1){let J=this.buildAttributes(A);for(let _ of this.adapters)_.recordGauge(f,T,J,O,j)}async flush(){await Promise.all(this.adapters.map((f)=>f.flush()))}async dispose(){await Promise.all(this.adapters.map((f)=>f.dispose()))}buildAttributes(f){let T=typeof f?.distinct_id==="string"&&f.distinct_id.trim()?f.distinct_id.trim():this.distinctId,A={...this.commonProperties,...this.metadata,...f,...T?{distinct_id:T}:{},device_id:this.deviceId};return Object.fromEntries(Object.entries(A).filter(([,O])=>O!==void 0))}}class D{distinctId;metadata;commonProperties;constructor(f={}){this.distinctId=f.distinctId,this.metadata={...f.metadata??{}},this.commonProperties={...f.commonProperties??{}}}setDistinctId(f){this.distinctId=f}setMetadata(f){this.metadata={...f}}updateMetadata(f){this.metadata={...this.metadata,...f}}setCommonProperties(f){this.commonProperties={...f}}updateCommonProperties(f){this.commonProperties={...this.commonProperties,...f}}isEnabled(){return!1}capture(f){this.resolveProperties(f.properties)}captureRequired(f,T){this.resolveProperties(T)}recordCounter(){}recordHistogram(){}recordGauge(){}async flush(){}async dispose(){}resolveProperties(f){let T=typeof f?.distinct_id==="string"&&f.distinct_id.trim()?f.distinct_id.trim():this.distinctId,A={...this.commonProperties,...this.metadata,...f,...T?{distinct_id:T}:{}};return Object.fromEntries(Object.entries(A).filter(([,O])=>O!==void 0))}}class k{meterProvider;loggerProvider;tracerProvider;options;constructor(f={}){this.options=f;let T=Xf({[Cf]:f.serviceName??"cline",...f.serviceVersion?{[Mf]:f.serviceVersion}:{}});if(this.meterProvider=this.createMeterProvider(T),this.loggerProvider=this.createLoggerProvider(T),this.tracerProvider=this.createTracerProvider(T),this.meterProvider)$f.setGlobalMeterProvider(this.meterProvider);if(this.loggerProvider)Rf.setGlobalLoggerProvider(this.loggerProvider);if(this.tracerProvider)this.tracerProvider.register()}getTracer(f="cline",T){return Bf.getTracer(f,T??this.options.serviceVersion)}createAdapter(f){return new X({...f,meterProvider:this.meterProvider,loggerProvider:this.loggerProvider})}createTelemetryService(f){let T=this.createAdapter({name:f.name,enabled:this.options.enabled,metadata:f.metadata});return new Z({...f,adapters:[T],distinctId:P(f.distinctId)})}async forceFlush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.(),this.tracerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.(),this.tracerProvider?.shutdown?.()])}createMeterProvider(f){let T=F(this.options.metricsExporter);if(T.length===0)return null;let A=Math.max(1000,this.options.metricExportIntervalMs??this.options.metricExportInterval??60000),O=Math.min(30000,Math.floor(A*0.8)),j=T.map((J)=>If(J,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json",interval:A,timeout:O})).filter((J)=>J!==null);if(j.length===0)return null;return new Vf({resource:f,readers:j})}createTracerProvider(f){let T=F(this.options.tracesExporter);if(T.length===0)return null;let A=this.options.otlpTracesEndpoint??this.options.otlpEndpoint,O=this.options.otlpTracesHeaders??this.options.otlpHeaders,j=[],J=!1;for(let W of T){let K=qf(W,{endpoint:A,headers:O,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(K){if(j.push(K),W!=="console")J=!0}}if(j.length===0)return null;let _=new Ef({resource:f,spanProcessors:J?[new Kf,...j]:j});if(J)Wf(_);return _}createLoggerProvider(f){let T=F(this.options.logsExporter);if(T.length===0)return null;let A=T.map((O)=>{let j=hf(O,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(!j)return null;return new Yf(j,{maxQueueSize:this.options.logMaxQueueSize??2048,maxExportBatchSize:this.options.logBatchSize??512,scheduledDelayMillis:this.options.logBatchTimeoutMs??this.options.logBatchTimeout??5000})}).filter((O)=>O!==null);if(A.length===0)return null;return new Qf({resource:f,processors:A})}}function x(f){let T=new k(f),A=T.createTelemetryService(f),O=()=>{A.captureRequired("telemetry.provider_created",{provider:"opentelemetry",enabled:f.enabled??!0,logsExporter:Array.isArray(f.logsExporter)?f.logsExporter.join(","):f.logsExporter,metricsExporter:Array.isArray(f.metricsExporter)?f.metricsExporter.join(","):f.metricsExporter,tracesExporter:Array.isArray(f.tracesExporter)?f.tracesExporter.join(","):f.tracesExporter,otlpProtocol:f.otlpProtocol,hasOtlpEndpoint:Boolean(f.otlpEndpoint),serviceName:f.serviceName,serviceVersion:f.serviceVersion})};if(!f.deferProviderCreatedEvent)O();return{provider:T,telemetry:A,emitProviderCreated:O}}function G(f){if(N())return{telemetry:new D(f)};if(f.enabled!==!0)return{telemetry:new Z({...f,distinctId:P(f.distinctId)})};return x(f)}function wf(f){let{telemetry:T,provider:A,emitProviderCreated:O}=G(f);return{telemetry:T,provider:A,flush:async()=>{let _=A;if(_&&typeof _.forceFlush==="function")try{await _.forceFlush()}catch{}},dispose:async()=>{await Promise.allSettled([T.dispose(),A?.dispose()])},...f.deferProviderCreatedEvent&&O?{emitProviderCreated:O}:{}}}function F(f){if(!f)return[];return(Array.isArray(f)?f:f.split(",")).map((A)=>A.trim()).filter((A)=>A==="console"||A==="otlp")}function hf(f,T){if(f==="console")return new Zf;if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/logs");return new Uf({url:A,headers:T.headers})}function qf(f,T){if(f==="console")return new kf(new Ff);if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/traces");return new Lf(new Pf({url:A,headers:T.headers}))}function If(f,T){if(f==="console")return new z({exporter:new Sf,exportIntervalMillis:T.interval,exportTimeoutMillis:T.timeout});if(!T.endpoint)return null;let A=E(T.endpoint,"/v1/metrics");return new z({exporter:new Hf({url:A,headers:T.headers}),exportIntervalMillis:T.interval,exportTimeoutMillis:T.timeout})}function E(f,T){let A=new URL(f),O=A.pathname.endsWith("/")?A.pathname.slice(0,-1):A.pathname;return A.pathname=O.endsWith(T)?O:`${O}${T}`,A.toString()}import{SESSION_STATUS_VALUES as hT}from"@cline/shared";var H={CORE:"core",CLI:"cli",SUBAGENT:"subagent",DESKTOP:"desktop",KANBAN:"kanban",API:"api",WEB:"web",VSCODE:"vscode",ENTERPRISE:"enterprise",IDE:"ide",JETBRAINS:"jetbrains",NEOVIM:"neovim",UNKNOWN:"unknown"};function y(f){let T=[f?.name,f?.platform].filter((A)=>typeof A==="string").join(" ").toLowerCase();if(!T)return;if(T.includes("vscode")||T.includes("visual studio code"))return H.VSCODE;if(T.includes("jetbrains")||T.includes("webstorm")||T.includes("intellij")||T.includes("pycharm")||T.includes("goland")||T.includes("clion")||T.includes("rider")||T.includes("android studio"))return H.JETBRAINS;if(T.includes("neovim"))return H.NEOVIM;if(T.includes("kanban"))return H.KANBAN;if(T.includes("desktop"))return H.DESKTOP;if(T.includes("cline-platform"))return H.WEB;if(T.includes("cline-cli")||T.includes("cline-acp"))return H.CLI;if(T.includes("cline-sdk")||T.includes("cline-core"))return H.CORE;return}function R(f){let T=f?.trim();return T?T:void 0}function b(f){let T=f.client,A=y(T)??R(f.source),O=R(T.version),j=R(T.platform)??R(T.name),J=R(T.platformVersion)??O,_={cline_type:A,extension_version:O,platform:j,platform_version:J};if(f.user?.accountId===void 0)return _;let W=typeof f.user.accountId==="string"?R(f.user.accountId):void 0;return{..._,distinct_id:W??R(f.user.distinctId),user_id:W,account_id:W,account_email:W?R(f.user.email):void 0,organization_id:W?R(f.user.organizationId):void 0}}function g(f,T){let A={},O={},j,J=(_)=>({...T,...O,...A,..._,...j?{distinct_id:j}:{}});return{setDistinctId(_){j=R(_)},setMetadata(_){A={..._}},updateMetadata(_){A={...A,..._}},setCommonProperties(_){O={..._}},updateCommonProperties(_){O={...O,..._}},isEnabled:()=>f.isEnabled(),capture:(_)=>f.capture({event:_.event,properties:J(_.properties)}),captureRequired:(_,W)=>f.captureRequired(_,J(W)),recordCounter:(_,W,K,$,U)=>f.recordCounter(_,W,J(K),$,U),recordHistogram:(_,W,K,$,U)=>f.recordHistogram(_,W,J(K),$,U),recordGauge:(_,W,K,$,U)=>f.recordGauge(_,W,J(K),$,U),flush:()=>f.flush(),dispose:async()=>{}}}function Nf(f,T){return g(f,b(T))}export{P as resolveCoreDistinctId,Q as resolveCoreDeviceId,b as resolveClientTelemetryProperties,g as createScopedTelemetryService,x as createOpenTelemetryTelemetryService,G as createConfiguredTelemetryService,wf as createConfiguredTelemetryHandle,Nf as createClientScopedTelemetryService,k as OpenTelemetryProvider,X as OpenTelemetryAdapter};
@@ -8,8 +8,8 @@ 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
- completed: "completed";
12
11
  failed: "failed";
12
+ completed: "completed";
13
13
  idle: "idle";
14
14
  running: "running";
15
15
  cancelled: "cancelled";
@@ -31,12 +31,10 @@ export declare class SessionManifestStore {
31
31
  path: string;
32
32
  manifest?: SessionManifest;
33
33
  };
34
+ readSessionRowFromManifest(sessionId: string): SessionRow | undefined;
34
35
  /**
35
36
  * Resolve the session row backing a message write, re-adopting it from the
36
- * on-disk manifest when the DB row is missing (session artifacts restored
37
- * or copied while the session DB was rebuilt). Sessions with neither a row
38
- * nor a manifest throw so message writes cannot silently recreate
39
- * orphaned session files.
37
+ * on-disk manifest when the index was rebuilt or the artifacts were restored.
40
38
  */
41
39
  private resolveSessionRow;
42
40
  persistSessionMessages(sessionId: string, messages: LlmsProviders.MessageWithMetadata[], systemPrompt?: string): Promise<void>;
@@ -35,8 +35,8 @@ export declare const TodoTaskInputSchema: z.ZodObject<{
35
35
  model_id: z.ZodOptional<z.ZodString>;
36
36
  }, z.core.$strip>>>;
37
37
  mode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
38
- plan: "plan";
39
38
  act: "act";
39
+ plan: "plan";
40
40
  yolo: "yolo";
41
41
  }>>>;
42
42
  system_prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -46,8 +46,8 @@ export declare const TodoTaskInputSchema: z.ZodObject<{
46
46
  expires_at: z.ZodOptional<z.ZodString>;
47
47
  automation_eligible: z.ZodOptional<z.ZodBoolean>;
48
48
  statuses: z.ZodOptional<z.ZodArray<z.ZodEnum<{
49
- completed: "completed";
50
49
  failed: "failed";
50
+ completed: "completed";
51
51
  cancelled: "cancelled";
52
52
  in_progress: "in_progress";
53
53
  approved: "approved";
@@ -40,8 +40,8 @@ export declare const TasksToolInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
40
40
  model_id: z.ZodOptional<z.ZodString>;
41
41
  }, z.core.$strip>>>;
42
42
  mode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
43
- plan: "plan";
44
43
  act: "act";
44
+ plan: "plan";
45
45
  yolo: "yolo";
46
46
  }>>>;
47
47
  system_prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -51,8 +51,8 @@ export declare const TasksToolInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
51
51
  expires_at: z.ZodOptional<z.ZodString>;
52
52
  automation_eligible: z.ZodOptional<z.ZodBoolean>;
53
53
  statuses: z.ZodOptional<z.ZodArray<z.ZodEnum<{
54
- completed: "completed";
55
54
  failed: "failed";
55
+ completed: "completed";
56
56
  cancelled: "cancelled";
57
57
  in_progress: "in_progress";
58
58
  approved: "approved";
@@ -75,10 +75,10 @@ export declare const TasksToolInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
75
75
  update: "update";
76
76
  create: "create";
77
77
  list: "list";
78
- pause: "pause";
79
- resume: "resume";
80
78
  get: "get";
81
79
  delete: "delete";
80
+ pause: "pause";
81
+ resume: "resume";
82
82
  run_now: "run_now";
83
83
  }>;
84
84
  schedule_id: z.ZodOptional<z.ZodString>;
@@ -93,8 +93,8 @@ export declare const TasksToolInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
93
93
  timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
94
  enabled: z.ZodOptional<z.ZodBoolean>;
95
95
  mode: z.ZodOptional<z.ZodEnum<{
96
- plan: "plan";
97
96
  act: "act";
97
+ plan: "plan";
98
98
  yolo: "yolo";
99
99
  }>>;
100
100
  system_prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -5,8 +5,8 @@ export declare const ChatSessionConfigSchema: z.ZodObject<{
5
5
  provider: z.ZodString;
6
6
  model: z.ZodString;
7
7
  mode: z.ZodDefault<z.ZodEnum<{
8
- plan: "plan";
9
8
  act: "act";
9
+ plan: "plan";
10
10
  }>>;
11
11
  apiKey: z.ZodString;
12
12
  systemPrompt: z.ZodOptional<z.ZodString>;
@@ -21,8 +21,8 @@ export declare const ChatSessionConfigSchema: z.ZodObject<{
21
21
  }, z.core.$strip>;
22
22
  export declare const ChatSessionStatusSchema: z.ZodEnum<{
23
23
  error: "error";
24
- completed: "completed";
25
24
  failed: "failed";
25
+ completed: "completed";
26
26
  idle: "idle";
27
27
  running: "running";
28
28
  cancelled: "cancelled";
@@ -41,9 +41,9 @@ export declare const ChatMessageRoleSchema: z.ZodEnum<{
41
41
  export declare const ChatMessageImageSchema: z.ZodObject<{
42
42
  id: z.ZodString;
43
43
  mediaType: z.ZodEnum<{
44
+ "image/png": "image/png";
44
45
  "image/gif": "image/gif";
45
46
  "image/jpeg": "image/jpeg";
46
- "image/png": "image/png";
47
47
  "image/webp": "image/webp";
48
48
  }>;
49
49
  data: z.ZodString;
@@ -63,9 +63,9 @@ export declare const ChatMessageSchema: z.ZodObject<{
63
63
  images: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
64
  id: z.ZodString;
65
65
  mediaType: z.ZodEnum<{
66
+ "image/png": "image/png";
66
67
  "image/gif": "image/gif";
67
68
  "image/jpeg": "image/jpeg";
68
- "image/png": "image/png";
69
69
  "image/webp": "image/webp";
70
70
  }>;
71
71
  data: z.ZodString;
@@ -103,8 +103,8 @@ export declare const ChatViewStateSchema: z.ZodObject<{
103
103
  sessionId: z.ZodNullable<z.ZodString>;
104
104
  status: z.ZodEnum<{
105
105
  error: "error";
106
- completed: "completed";
107
106
  failed: "failed";
107
+ completed: "completed";
108
108
  idle: "idle";
109
109
  running: "running";
110
110
  cancelled: "cancelled";
@@ -118,8 +118,8 @@ export declare const ChatViewStateSchema: z.ZodObject<{
118
118
  provider: z.ZodString;
119
119
  model: z.ZodString;
120
120
  mode: z.ZodDefault<z.ZodEnum<{
121
- plan: "plan";
122
121
  act: "act";
122
+ plan: "plan";
123
123
  }>>;
124
124
  apiKey: z.ZodString;
125
125
  systemPrompt: z.ZodOptional<z.ZodString>;
@@ -147,9 +147,9 @@ export declare const ChatViewStateSchema: z.ZodObject<{
147
147
  images: z.ZodOptional<z.ZodArray<z.ZodObject<{
148
148
  id: z.ZodString;
149
149
  mediaType: z.ZodEnum<{
150
+ "image/png": "image/png";
150
151
  "image/gif": "image/gif";
151
152
  "image/jpeg": "image/jpeg";
152
- "image/png": "image/png";
153
153
  "image/webp": "image/webp";
154
154
  }>;
155
155
  data: z.ZodString;
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.83",
4
+ "version": "0.0.84",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/cline/cline",
@@ -57,9 +57,9 @@
57
57
  "test:watch": "vitest --config vitest.config.ts"
58
58
  },
59
59
  "dependencies": {
60
- "@cline/agents": "0.0.83",
61
- "@cline/shared": "0.0.83",
62
- "@cline/llms": "0.0.83",
60
+ "@cline/agents": "0.0.84",
61
+ "@cline/shared": "0.0.84",
62
+ "@cline/llms": "0.0.84",
63
63
  "@modelcontextprotocol/sdk": "^1.29.0",
64
64
  "@opentelemetry/api": "^1.9.0",
65
65
  "@opentelemetry/api-logs": "^0.214.0",