@clinebot/shared 0.0.20 → 0.0.21

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.
@@ -1,263 +0,0 @@
1
- /**
2
- * ═══════════════════════════════════════════════════════════════════════════
3
- * ⚠️ CRITICAL WARNING ⚠️
4
- * ═══════════════════════════════════════════════════════════════════════════
5
- *
6
- * THE API SERVER MUST BE RE-DEPLOYED WHENEVER THIS SCHEMA IS UPDATED!
7
- *
8
- * This schema is used by both the extension and the API server for validation.
9
- * Any changes here require a coordinated deployment to avoid validation errors.
10
- *
11
- * ═══════════════════════════════════════════════════════════════════════════
12
- */
13
-
14
- import { z } from "zod";
15
-
16
- // OpenAI Compatible model schema with per-model settings
17
- export const OpenAiCompatibleModelSchema = z.object({
18
- id: z.string(), // The model ID is required
19
- temperature: z.number().optional(),
20
- isR1FormatRequired: z.boolean().optional(),
21
- maxTokens: z.number().optional(),
22
- contextWindow: z.number().optional(),
23
- inputPrice: z.number().optional(),
24
- outputPrice: z.number().optional(),
25
- supportsImages: z.boolean().optional(),
26
- });
27
-
28
- // OpenAiCompatible specific settings
29
- export const OpenAiCompatibleSchema = z.object({
30
- // A list of the allowed models with their settings
31
- models: z.array(OpenAiCompatibleModelSchema).optional(),
32
- // OpenAiCompatible specific settings:
33
- openAiBaseUrl: z.string().optional(),
34
- openAiHeaders: z.record(z.string(), z.string()).optional(),
35
- azureApiVersion: z.string().optional(),
36
- azureIdentity: z.boolean().optional(),
37
- });
38
-
39
- // AWS Bedrock model schema with per-model settings
40
- export const AwsBedrockModelSchema = z.object({
41
- id: z.string(), // The model ID is required
42
- thinkingBudgetTokens: z.number().optional(),
43
- });
44
-
45
- // AWS Bedrock custom model schema (separate from regular models)
46
- export const AwsBedrockCustomModelSchema = z.object({
47
- name: z.string(), // The model name is required
48
- baseModelId: z.string(), // The base model ID is required
49
- thinkingBudgetTokens: z.number().optional(),
50
- });
51
-
52
- // AWS Bedrock specific settings
53
- export const AwsBedrockSettingsSchema = z.object({
54
- // A list of the allowed models with their settings
55
- models: z.array(AwsBedrockModelSchema).optional(),
56
- // Custom models
57
- customModels: z.array(AwsBedrockCustomModelSchema).optional(),
58
- // AWS Bedrock specific settings:
59
- awsRegion: z.string().optional(),
60
- awsUseCrossRegionInference: z.boolean().optional(),
61
- awsUseGlobalInference: z.boolean().optional(),
62
- awsBedrockUsePromptCache: z.boolean().optional(),
63
- awsBedrockEndpoint: z.string().optional(),
64
- });
65
-
66
- // Cline Provider model schema with per-model settings
67
- export const ClineModelSchema = z.object({
68
- id: z.string(), // The model ID is required
69
- });
70
-
71
- // Cline Provider specific settings
72
- export const ClineSettingsSchema = z.object({
73
- // A list of the allowed models with their settings
74
- models: z.array(ClineModelSchema).optional(),
75
- });
76
-
77
- // Vertex Provider model schema with per-model settings
78
- export const VertexModelSchema = z.object({
79
- id: z.string(), // The model ID is required
80
- thinkingBudgetTokens: z.number().optional(),
81
- });
82
-
83
- // GCP Vertex Provider specific settings
84
- export const VertexSettingsSchema = z.object({
85
- // A list of the allowed models with their settings
86
- models: z.array(VertexModelSchema).optional(),
87
- vertexProjectId: z.string().optional(),
88
- vertexRegion: z.string().optional(),
89
- });
90
-
91
- export const LiteLLMModelSchema = z.object({
92
- id: z.string(),
93
- thinkingBudgetTokens: z.number().optional(),
94
- promptCachingEnabled: z.boolean().optional(),
95
- });
96
-
97
- export const LiteLLMSchema = z.object({
98
- models: z.array(LiteLLMModelSchema).optional(),
99
- baseUrl: z.string().optional(),
100
- });
101
-
102
- export const AnthropicModelSchema = z.object({
103
- id: z.string(),
104
- thinkingBudgetTokens: z.number().optional(),
105
- });
106
-
107
- export const AnthropicSchema = z.object({
108
- models: z.array(AnthropicModelSchema).optional(),
109
- baseUrl: z.string().optional(),
110
- });
111
-
112
- // Provider settings schema
113
- // Each provider becomes an optional field
114
- const ProviderSettingsSchema = z.object({
115
- OpenAiCompatible: OpenAiCompatibleSchema.optional(),
116
- AwsBedrock: AwsBedrockSettingsSchema.optional(),
117
- Cline: ClineSettingsSchema.optional(),
118
- Vertex: VertexSettingsSchema.optional(),
119
- LiteLLM: LiteLLMSchema.optional(),
120
- Anthropic: AnthropicSchema.optional(),
121
- });
122
-
123
- export const AllowedMCPServerSchema = z.object({
124
- // The ID of the MCP is the URL for their github repo.
125
- id: z.string(),
126
- });
127
-
128
- export const RemoteMCPServerSchema = z.object({
129
- // The name of the MCP server
130
- name: z.string(),
131
- // The URL of the MCP server
132
- url: z.string(),
133
- // When this is true, the user cannot disable this MCP server
134
- alwaysEnabled: z.boolean().optional(),
135
- // Headers to allow for custom auth
136
- headers: z.record(z.string(), z.string()).optional(),
137
- });
138
-
139
- // Settings for a global cline rules or workflow file.
140
- export const GlobalInstructionsFileSchema = z.object({
141
- // When this is enabled, the user cannot turn off this rule or workflow.
142
- alwaysEnabled: z.boolean(),
143
- // The name of the rules or workflow file.
144
- name: z.string(),
145
- // The contents of the rules or workflow file
146
- contents: z.string(),
147
- });
148
-
149
- export const S3AccessKeySettingsSchema = z.object({
150
- bucket: z.string(),
151
- accessKeyId: z.string(),
152
- secretAccessKey: z.string(),
153
- region: z.string().optional(),
154
- endpoint: z.string().optional(),
155
- accountId: z.string().optional(),
156
- intervalMs: z.number().optional(),
157
- maxRetries: z.number().optional(),
158
- batchSize: z.number().optional(),
159
- maxQueueSize: z.number().optional(),
160
- maxFailedAgeMs: z.number().optional(),
161
- backfillEnabled: z.boolean().optional(),
162
- });
163
-
164
- export const PromptUploadingSchema = z.object({
165
- enabled: z.boolean().optional(),
166
- type: z
167
- .union([z.literal("s3_access_keys"), z.literal("r2_access_keys")])
168
- .optional(),
169
- s3AccessSettings: S3AccessKeySettingsSchema.optional(),
170
- r2AccessSettings: S3AccessKeySettingsSchema.optional(),
171
- });
172
-
173
- export const EnterpriseTelemetrySchema = z.object({
174
- promptUploading: PromptUploadingSchema.optional(),
175
- });
176
-
177
- export const RemoteConfigSchema = z.object({
178
- // The version of the remote config settings, e.g. v1
179
- // This field is for internal use only, and won't be visible to the administrator in the UI.
180
- version: z.string(),
181
-
182
- // Provider specific settings
183
- providerSettings: ProviderSettingsSchema.optional(),
184
-
185
- // General settings not specific to any provider
186
- telemetryEnabled: z.boolean().optional(),
187
- kanbanEnabled: z.boolean().optional(),
188
-
189
- // MCP settings
190
- // If this is false, the MCP marketplace is disabled in the extension
191
- mcpMarketplaceEnabled: z.boolean().optional(),
192
-
193
- // If this is configured, the users only have access to these allowlisted MCP servers in the marketplace.
194
- allowedMCPServers: z.array(AllowedMCPServerSchema).optional(),
195
-
196
- // A list of pre-configured remote MCP servers.
197
- remoteMCPServers: z.array(RemoteMCPServerSchema).optional(),
198
- // If this is true, users cannot use or configure MCP servers that are not remotely configured.
199
- blockPersonalRemoteMCPServers: z.boolean().optional(),
200
-
201
- // If the user is allowed to enable YOLO mode. Note this is different from the extension setting
202
- // yoloModeEnabled, because we do not want to force YOLO enabled for the user.
203
- yoloModeAllowed: z.boolean().optional(),
204
-
205
- // OpenTelemetry configuration
206
- openTelemetryEnabled: z.boolean().optional(),
207
- openTelemetryMetricsExporter: z.string().optional(),
208
- openTelemetryLogsExporter: z.string().optional(),
209
- openTelemetryOtlpProtocol: z.string().optional(),
210
- openTelemetryOtlpEndpoint: z.string().optional(),
211
- openTelemetryOtlpHeaders: z.record(z.string(), z.string()).optional(),
212
- openTelemetryOtlpMetricsProtocol: z.string().optional(),
213
- openTelemetryOtlpMetricsEndpoint: z.string().optional(),
214
- openTelemetryOtlpMetricsHeaders: z.record(z.string(), z.string()).optional(),
215
- openTelemetryOtlpLogsProtocol: z.string().optional(),
216
- openTelemetryOtlpLogsEndpoint: z.string().optional(),
217
- openTelemetryOtlpLogsHeaders: z.record(z.string(), z.string()).optional(),
218
- openTelemetryMetricExportInterval: z.number().optional(),
219
- openTelemetryOtlpInsecure: z.boolean().optional(),
220
- openTelemetryLogBatchSize: z.number().optional(),
221
- openTelemetryLogBatchTimeout: z.number().optional(),
222
- openTelemetryLogMaxQueueSize: z.number().optional(),
223
-
224
- enterpriseTelemetry: EnterpriseTelemetrySchema.optional(),
225
-
226
- // Rules & Workflows
227
- globalRules: z.array(GlobalInstructionsFileSchema).optional(),
228
- globalWorkflows: z.array(GlobalInstructionsFileSchema).optional(),
229
- });
230
-
231
- export const APIKeySchema = z.record(z.string(), z.string());
232
-
233
- // Type inference from schemas
234
- export type RemoteConfig = z.infer<typeof RemoteConfigSchema>;
235
- export type MCPServer = z.infer<typeof AllowedMCPServerSchema>;
236
- export type RemoteMCPServer = z.infer<typeof RemoteMCPServerSchema>;
237
- export type GlobalInstructionsFile = z.infer<
238
- typeof GlobalInstructionsFileSchema
239
- >;
240
-
241
- export type ProviderSettings = z.infer<typeof ProviderSettingsSchema>;
242
-
243
- export type OpenAiCompatible = z.infer<typeof OpenAiCompatibleSchema>;
244
- export type OpenAiCompatibleModel = z.infer<typeof OpenAiCompatibleModelSchema>;
245
-
246
- export type AwsBedrockSettings = z.infer<typeof AwsBedrockSettingsSchema>;
247
- export type AwsBedrockModel = z.infer<typeof AwsBedrockModelSchema>;
248
- export type AwsBedrockCustomModel = z.infer<typeof AwsBedrockCustomModelSchema>;
249
-
250
- export type VertexSettings = z.infer<typeof VertexSettingsSchema>;
251
- export type VertexModel = z.infer<typeof VertexModelSchema>;
252
-
253
- export type LiteLLMSettings = z.infer<typeof LiteLLMSchema>;
254
- export type LiteLLMModel = z.infer<typeof LiteLLMModelSchema>;
255
-
256
- export type AnthropicSettings = z.infer<typeof AnthropicSchema>;
257
- export type AnthropicModel = z.infer<typeof AnthropicModelSchema>;
258
-
259
- export type APIKeySettings = z.infer<typeof APIKeySchema>;
260
-
261
- export type EnterpriseTelemetry = z.infer<typeof EnterpriseTelemetrySchema>;
262
- export type PromptUploading = z.infer<typeof PromptUploadingSchema>;
263
- export type S3AccessKeySettings = z.infer<typeof S3AccessKeySettingsSchema>;
package/src/rpc/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export const CLINE_RPC_PORT = 25463;
2
- export const CLINE_DEFAULT_RPC_PORT = 4317;
3
- export const RPC_ADDRESS_BASE = "127.0.0.1";
4
- export const CLINE_DEFAULT_RPC_ADDRESS = `${RPC_ADDRESS_BASE}:${CLINE_DEFAULT_RPC_PORT}`;
@@ -1,317 +0,0 @@
1
- import type {
2
- AgentMode,
3
- SessionExecutionConfig,
4
- SessionPromptConfig,
5
- } from "../session/runtime-config";
6
-
7
- export type RpcAgentMode = AgentMode;
8
-
9
- export interface RpcSessionStorageOptions {
10
- homeDir?: string;
11
- }
12
-
13
- export interface RpcChatRuntimeConfigBase extends SessionPromptConfig {
14
- cwd?: string;
15
- apiKey: string;
16
- logger?: RpcChatRuntimeLoggerConfig;
17
- enableTools: boolean;
18
- enableSpawn: boolean;
19
- enableTeams: boolean;
20
- autoApproveTools?: boolean;
21
- teamName: string;
22
- missionStepInterval: number;
23
- missionTimeIntervalMs: number;
24
- toolPolicies?: SessionExecutionConfig["toolPolicies"];
25
- }
26
-
27
- export interface RpcChatRuntimeLoggerConfig {
28
- enabled?: boolean;
29
- level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
30
- destination?: string;
31
- name?: string;
32
- bindings?: Record<string, string | number | boolean>;
33
- }
34
-
35
- export interface RpcChatStartSessionRequest extends RpcChatRuntimeConfigBase {
36
- sessionId?: string;
37
- workspaceRoot: string;
38
- provider: string;
39
- model: string;
40
- sessions?: RpcSessionStorageOptions;
41
- initialMessages?: RpcChatMessage[];
42
- }
43
-
44
- export interface RpcChatStartSessionArtifacts {
45
- sessionId: string;
46
- manifestPath: string;
47
- transcriptPath: string;
48
- hookPath: string;
49
- messagesPath: string;
50
- }
51
-
52
- export interface RpcChatStartSessionResponse {
53
- sessionId: string;
54
- startResult?: RpcChatStartSessionArtifacts;
55
- }
56
-
57
- export interface RpcChatAttachmentFile {
58
- name: string;
59
- content: string;
60
- }
61
-
62
- export interface RpcChatAttachments {
63
- userImages?: string[];
64
- userFiles?: RpcChatAttachmentFile[];
65
- }
66
-
67
- export interface RpcChatMessage {
68
- role?: string;
69
- content?: unknown;
70
- [key: string]: unknown;
71
- }
72
-
73
- export interface RpcChatRunTurnRequest {
74
- config: RpcChatStartSessionRequest;
75
- messages?: RpcChatMessage[];
76
- prompt: string;
77
- attachments?: RpcChatAttachments;
78
- delivery?: "queue" | "steer";
79
- }
80
-
81
- export interface RpcChatToolCallResult {
82
- name: string;
83
- input?: unknown;
84
- output?: unknown;
85
- error?: string;
86
- durationMs?: number;
87
- }
88
-
89
- export interface RpcChatTurnResult {
90
- text: string;
91
- usage: {
92
- inputTokens: number;
93
- outputTokens: number;
94
- cacheReadTokens?: number;
95
- cacheWriteTokens?: number;
96
- totalCost?: number;
97
- };
98
- inputTokens: number;
99
- outputTokens: number;
100
- iterations: number;
101
- finishReason: string;
102
- messages: RpcChatMessage[];
103
- toolCalls: RpcChatToolCallResult[];
104
- }
105
-
106
- export interface RpcProviderModel {
107
- id: string;
108
- name: string;
109
- supportsAttachments?: boolean;
110
- supportsVision?: boolean;
111
- supportsReasoning?: boolean;
112
- }
113
-
114
- export interface RpcProviderListItem {
115
- id: string;
116
- name: string;
117
- models: number | null;
118
- color: string;
119
- letter: string;
120
- enabled: boolean;
121
- apiKey?: string;
122
- oauthAccessTokenPresent?: boolean;
123
- baseUrl?: string;
124
- defaultModelId?: string;
125
- authDescription: string;
126
- baseUrlDescription: string;
127
- modelList?: RpcProviderModel[];
128
- }
129
-
130
- export interface RpcProviderCatalogResponse {
131
- providers: RpcProviderListItem[];
132
- settingsPath: string;
133
- }
134
-
135
- export interface RpcProviderModelsResponse {
136
- providerId: string;
137
- models: RpcProviderModel[];
138
- }
139
-
140
- export interface RpcClineAccountOrganization {
141
- active: boolean;
142
- memberId: string;
143
- name: string;
144
- organizationId: string;
145
- roles: Array<"admin" | "member" | "owner">;
146
- }
147
-
148
- export interface RpcClineAccountUser {
149
- id: string;
150
- email: string;
151
- displayName: string;
152
- photoUrl: string;
153
- createdAt: string;
154
- updatedAt: string;
155
- organizations: RpcClineAccountOrganization[];
156
- }
157
-
158
- export interface RpcClineAccountBalance {
159
- balance: number;
160
- userId: string;
161
- }
162
-
163
- export interface RpcClineAccountUsageTransaction {
164
- aiInferenceProviderName: string;
165
- aiModelName: string;
166
- aiModelTypeName: string;
167
- completionTokens: number;
168
- costUsd: number;
169
- createdAt: string;
170
- creditsUsed: number;
171
- generationId: string;
172
- id: string;
173
- metadata: {
174
- additionalProp1: string;
175
- additionalProp2: string;
176
- additionalProp3: string;
177
- };
178
- operation?: string;
179
- organizationId: string;
180
- promptTokens: number;
181
- totalTokens: number;
182
- userId: string;
183
- }
184
-
185
- export interface RpcClineAccountPaymentTransaction {
186
- paidAt: string;
187
- creatorId: string;
188
- amountCents: number;
189
- credits: number;
190
- }
191
-
192
- export interface RpcClineAccountOrganizationBalance {
193
- balance: number;
194
- organizationId: string;
195
- }
196
-
197
- export interface RpcClineAccountOrganizationUsageTransaction {
198
- aiInferenceProviderName: string;
199
- aiModelName: string;
200
- aiModelTypeName: string;
201
- completionTokens: number;
202
- costUsd: number;
203
- createdAt: string;
204
- creditsUsed: number;
205
- generationId: string;
206
- id: string;
207
- memberDisplayName: string;
208
- memberEmail: string;
209
- metadata: {
210
- additionalProp1: string;
211
- additionalProp2: string;
212
- additionalProp3: string;
213
- };
214
- operation?: string;
215
- organizationId: string;
216
- promptTokens: number;
217
- totalTokens: number;
218
- userId: string;
219
- }
220
-
221
- import type { OAuthProviderId } from "../auth/constants";
222
-
223
- export type RpcOAuthProviderId = OAuthProviderId;
224
-
225
- export type RpcProviderCapability =
226
- | "reasoning"
227
- | "prompt-cache"
228
- | "streaming"
229
- | "tools"
230
- | "vision";
231
-
232
- export interface RpcListProvidersActionRequest {
233
- action: "listProviders";
234
- }
235
-
236
- export interface RpcGetProviderModelsActionRequest {
237
- action: "getProviderModels";
238
- providerId: string;
239
- }
240
-
241
- export interface RpcSaveProviderSettingsActionRequest {
242
- action: "saveProviderSettings";
243
- providerId: string;
244
- enabled?: boolean;
245
- apiKey?: string;
246
- baseUrl?: string;
247
- }
248
-
249
- export interface RpcAddProviderActionRequest {
250
- action: "addProvider";
251
- providerId: string;
252
- name: string;
253
- baseUrl: string;
254
- apiKey?: string;
255
- headers?: Record<string, string>;
256
- timeoutMs?: number;
257
- models?: string[];
258
- defaultModelId?: string;
259
- modelsSourceUrl?: string;
260
- capabilities?: RpcProviderCapability[];
261
- }
262
-
263
- export type RpcProviderSettingsActionRequest =
264
- | RpcListProvidersActionRequest
265
- | RpcGetProviderModelsActionRequest
266
- | RpcSaveProviderSettingsActionRequest
267
- | RpcAddProviderActionRequest;
268
-
269
- export type RpcClineAccountActionRequest =
270
- | {
271
- action: "clineAccount";
272
- operation: "fetchMe";
273
- }
274
- | {
275
- action: "clineAccount";
276
- operation: "fetchBalance";
277
- userId?: string;
278
- }
279
- | {
280
- action: "clineAccount";
281
- operation: "fetchUsageTransactions";
282
- userId?: string;
283
- }
284
- | {
285
- action: "clineAccount";
286
- operation: "fetchPaymentTransactions";
287
- userId?: string;
288
- }
289
- | {
290
- action: "clineAccount";
291
- operation: "fetchUserOrganizations";
292
- }
293
- | {
294
- action: "clineAccount";
295
- operation: "fetchOrganizationBalance";
296
- organizationId: string;
297
- }
298
- | {
299
- action: "clineAccount";
300
- operation: "fetchOrganizationUsageTransactions";
301
- organizationId: string;
302
- memberId?: string;
303
- }
304
- | {
305
- action: "clineAccount";
306
- operation: "switchAccount";
307
- organizationId?: string | null;
308
- };
309
-
310
- export type RpcProviderActionRequest =
311
- | RpcProviderSettingsActionRequest
312
- | RpcClineAccountActionRequest;
313
-
314
- export interface RpcProviderOAuthLoginResponse {
315
- provider: RpcOAuthProviderId;
316
- accessToken: string;
317
- }
@@ -1,71 +0,0 @@
1
- export const RPC_TEAM_PROGRESS_EVENT_TYPE = "runtime.team.progress.v1";
2
- export const RPC_TEAM_LIFECYCLE_EVENT_TYPE = "runtime.team.lifecycle.v1";
3
-
4
- export type TeamProgressMemberRole = "lead" | "teammate";
5
- export type TeamProgressMemberStatus = "idle" | "running" | "stopped";
6
- export type TeamProgressTaskStatus =
7
- | "pending"
8
- | "in_progress"
9
- | "blocked"
10
- | "completed";
11
- export type TeamProgressRunStatus =
12
- | "queued"
13
- | "running"
14
- | "completed"
15
- | "failed"
16
- | "cancelled"
17
- | "interrupted";
18
- export type TeamProgressOutcomeStatus = "draft" | "in_review" | "finalized";
19
- export type TeamProgressOutcomeFragmentStatus =
20
- | "draft"
21
- | "reviewed"
22
- | "rejected";
23
-
24
- export interface TeamProgressCounts<TStatus extends string> {
25
- total: number;
26
- byStatus: Record<TStatus, number>;
27
- }
28
-
29
- export interface TeamProgressSummary {
30
- teamName: string;
31
- updatedAt: string;
32
- members: TeamProgressCounts<TeamProgressMemberStatus> & {
33
- leadCount: number;
34
- teammateCount: number;
35
- };
36
- tasks: TeamProgressCounts<TeamProgressTaskStatus> & {
37
- blockedTaskIds: string[];
38
- readyTaskIds: string[];
39
- completionPct: number;
40
- };
41
- runs: TeamProgressCounts<TeamProgressRunStatus> & {
42
- activeRunIds: string[];
43
- latestRunId?: string;
44
- };
45
- outcomes: TeamProgressCounts<TeamProgressOutcomeStatus> & {
46
- finalizedPct: number;
47
- missingRequiredSections: string[];
48
- };
49
- fragments: TeamProgressCounts<TeamProgressOutcomeFragmentStatus>;
50
- }
51
-
52
- export interface TeamProgressLifecycleEvent {
53
- teamName: string;
54
- sessionId: string;
55
- eventType: string;
56
- ts: string;
57
- agentId?: string;
58
- taskId?: string;
59
- runId?: string;
60
- outcomeId?: string;
61
- fragmentId?: string;
62
- message?: string;
63
- }
64
-
65
- export interface TeamProgressProjectionEvent {
66
- type: "team_progress_projection";
67
- version: 1;
68
- sessionId: string;
69
- summary: TeamProgressSummary;
70
- lastEvent: TeamProgressLifecycleEvent;
71
- }
@@ -1,55 +0,0 @@
1
- import type { OpenTelemetryClientConfig, TelemetryMetadata } from "./telemetry";
2
-
3
- export interface ClineTelemetryServiceConfig extends OpenTelemetryClientConfig {
4
- metadata: TelemetryMetadata;
5
- }
6
-
7
- function getTelemetryBuildTimeConfig(): OpenTelemetryClientConfig {
8
- return {
9
- enabled:
10
- process?.env?.OTEL_TELEMETRY_ENABLED === "1" ||
11
- process?.env?.OTEL_TELEMETRY_ENABLED === "true",
12
- metricsExporter: process?.env?.OTEL_METRICS_EXPORTER || "otlp",
13
- logsExporter: process?.env?.OTEL_LOGS_EXPORTER || "otlp",
14
- otlpProtocol: process?.env?.OTEL_EXPORTER_OTLP_PROTOCOL || "http/json",
15
- otlpEndpoint: process?.env?.OTEL_EXPORTER_OTLP_ENDPOINT,
16
- metricExportInterval: process?.env?.OTEL_METRIC_EXPORT_INTERVAL
17
- ? Number.parseInt(process?.env?.OTEL_METRIC_EXPORT_INTERVAL, 10)
18
- : undefined,
19
- otlpHeaders: process?.env?.OTEL_EXPORTER_OTLP_HEADERS
20
- ? Object.fromEntries(
21
- process?.env?.OTEL_EXPORTER_OTLP_HEADERS.split(",").map((header) => {
22
- const [key, value] = header.split("=");
23
- return [key.trim(), value.trim()];
24
- }),
25
- )
26
- : undefined,
27
- };
28
- }
29
-
30
- export function createClineTelemetryServiceMetadata(
31
- overrides: Partial<TelemetryMetadata> = {},
32
- ): TelemetryMetadata {
33
- return {
34
- extension_version: "unknown",
35
- cline_type: "unknown",
36
- platform: "terminal",
37
- platform_version: process?.version || "unknown",
38
- os_type: process?.platform || "unknown",
39
- os_version:
40
- process?.platform === "win32"
41
- ? (process?.env?.OS ?? "unknown")
42
- : "unknown",
43
- ...overrides,
44
- };
45
- }
46
-
47
- export function createClineTelemetryServiceConfig(
48
- configOverrides: Partial<ClineTelemetryServiceConfig> = {},
49
- ): ClineTelemetryServiceConfig {
50
- return {
51
- ...getTelemetryBuildTimeConfig(),
52
- ...configOverrides,
53
- metadata: createClineTelemetryServiceMetadata(configOverrides.metadata),
54
- };
55
- }