@cline/core 0.0.95 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ClineCore.d.ts +6 -1
- package/dist/account/rpc.d.ts +3 -1
- package/dist/cline-core/runtime-services.d.ts +4 -2
- package/dist/cloud/controller.d.ts +5 -2
- package/dist/cloud/hub-client.d.ts +51 -0
- package/dist/cloud/hub-protocol.d.ts +18 -0
- package/dist/cloud/index.d.ts +2 -0
- package/dist/cloud/index.js +16 -16
- package/dist/cloud/types.d.ts +4 -1
- package/dist/extensions/context/compaction-shared.d.ts +1 -0
- package/dist/extensions/context/compaction.d.ts +7 -0
- package/dist/extensions/context/summarize-conversation.d.ts +7 -0
- package/dist/extensions/context/summary-generation.d.ts +14 -0
- package/dist/extensions/mcp/apps.d.ts +16 -0
- package/dist/extensions/mcp/client.d.ts +1 -0
- package/dist/extensions/mcp/index.d.ts +5 -1
- package/dist/extensions/mcp/manager.d.ts +2 -1
- package/dist/extensions/mcp/session-apps.d.ts +28 -0
- package/dist/extensions/mcp/types.d.ts +22 -0
- package/dist/extensions/plugin/plugin-command-origin.d.ts +8 -0
- package/dist/extensions/plugin/plugin-registry.d.ts +1 -0
- package/dist/extensions/plugin/plugin-runtime.d.ts +7 -0
- package/dist/hub/client/index.d.ts +6 -0
- package/dist/hub/client/managed-hub-build-watcher.d.ts +2 -0
- package/dist/hub/client/plugin-commands.d.ts +4 -0
- package/dist/hub/client/session-client.d.ts +2 -0
- package/dist/hub/daemon/entry.js +241 -228
- package/dist/hub/index.d.ts +1 -0
- package/dist/hub/index.js +231 -218
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +6 -0
- package/dist/hub/server/cloud-session-service.d.ts +50 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +18 -1
- package/dist/hub/server/handlers/context.d.ts +13 -2
- package/dist/hub/server/handlers/mcp-apps-handlers.d.ts +5 -0
- package/dist/hub/server/hub-server-options.d.ts +3 -0
- package/dist/hub/server/hub-server-transport.d.ts +2 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +278 -258
- package/dist/plugin-runtime/node_modules/@cline/agents/dist/index.js +76 -0
- package/dist/plugin-runtime/node_modules/@cline/agents/package.json +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/ai-sdk-b1d8eb67.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/anthropic-33qvrctr.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/bedrock-paabhz8w.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/cline-yhsfqcy1.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/cloud/index.js +21 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/community-gqgs7446.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/foundation-models-embedding-model-strategy-SAVQFBF4-822304b0.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/foundation-models-language-model-strategy-BPQO66W7-hky2m2yx.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-bsd-sqf1kd37.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-bsd-tx1kp6xn.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-darwin-6cpgjxme.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-darwin-fxchqbze.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-linux-m3bzwmzc.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-linux-pr9sb5fr.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-unsupported-nckraycx.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-unsupported-w91yq3tm.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-win-xdyxc2tf.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/getMachineId-win-yxsvs11a.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/google-pgdk2dm9.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/hub/daemon/entry.js +1160 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/hub/index.js +1147 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-02jpyn9y.js +85 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-0cb4390m.js +137 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-0f8xrhgt.js +209 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-1f8vb421.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-28c7m0fv.js +16 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-2em3jg4q.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-4n1zpzbe.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-54eea0ex.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-5j92dtg5.js +16 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-6akf3a5d.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-6k6ep10s.js +136 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-71ym4q6s.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-91p1ghfk.js +14 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-9qkpjy7x.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-9swk4nej.js +3 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-aa2s5myc.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-ae0ajw38.js +13 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-bxvyzjhc.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-bzy863k0.js +6 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-d96n0s70.js +20 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-dsd6vt8c.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-e2q4azd9.js +119 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-egd18jj2.js +4 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-eh83hr16.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-ev9r2dy3.js +1204 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-f2mvvryf.js +190 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-h7gn5v3f.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-h7s1a560.js +12 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-hkhq3jtz.js +21 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-j8r18nfg.js +15 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-jhny555h.js +6 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-m1gpa2eg.js +146 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-m2ad6tgj.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-m7mks2jq.js +4 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-mcnngj50.js +62 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-n2srkkh0.js +39 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-nbs1tsny.js +142 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-nqjnz7m4.js +9 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-rmhzyxr8.js +3 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-rtzf3vvk.js +6 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-sw74pcm3.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-t3eanyjj.js +3 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-tseksj1v.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-v0ctpcdr.js +12 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-v4-dx8bd4wq.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-v695918t.js +14 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-v96yy1pw.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-vfm7r9wk.js +65 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-xecthgrg.js +9 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-xn1xhp06.js +9 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-yfdscfdx.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index-yrnwqsdt.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/jiti-static-3mgy2y9y.js +473 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/jiti-w1xrs0vd.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/langfuse-stream-telemetry-9tppg77c.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/langfuse-telemetry-y658kpzy.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/mistral-cmhqd91b.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/multipart-parser-qkjjf8mm.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/ollama-8z6y9d1h.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/openai-cfmja1ez.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/openai-compatible-1t7n5sxj.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/orchestration-embedding-model-strategy-GT27AFII-k6yqgnyd.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/orchestration-language-model-strategy-YEQPUCOT-6rdyebbq.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/services/feature-flags/posthog.js +2 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/services/telemetry/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/token-1h068py9.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/token-util-7jchft51.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/dist/vertex-qfxfsrn4.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/core/package.json +1 -0
- package/dist/plugin-runtime/node_modules/@cline/llms/dist/index.browser.js +16 -0
- package/dist/plugin-runtime/node_modules/@cline/llms/dist/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/llms/package.json +1 -0
- package/dist/plugin-runtime/node_modules/@cline/sdk/dist/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/sdk/package.json +1 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/automation/index.js +57 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/db/index.js +127 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/index.browser.js +110 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/node.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/remote-config/index.js +68 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/storage/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/dist/types/index.js +1 -0
- package/dist/plugin-runtime/node_modules/@cline/shared/package.json +1 -0
- package/dist/plugin-runtime/package.json +1 -0
- package/dist/{extensions → plugin-runtime}/plugin-sandbox-bootstrap.js +129 -129
- package/dist/remote/remote-environments.d.ts +1 -0
- package/dist/runtime/config/agent-runtime-config-builder.d.ts +2 -0
- package/dist/runtime/host/local-runtime-host.d.ts +10 -0
- package/dist/runtime/host/runtime-host.d.ts +6 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +3 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +10 -1
- package/dist/runtime/orchestration/session-runtime.d.ts +2 -0
- package/dist/runtime/tools/subprocess-sandbox.d.ts +22 -0
- package/dist/services/llms/cline-recommended-models.d.ts +2 -0
- package/dist/services/local-runtime-bootstrap.d.ts +1 -0
- package/dist/services/plugin-command-api.d.ts +47 -0
- package/dist/services/plugin-commands.d.ts +25 -27
- package/dist/services/skills-cli.d.ts +2 -0
- package/dist/services/telemetry/core-events.d.ts +26 -0
- package/dist/services/telemetry/index.js +1 -1
- package/dist/services/telemetry/run-health.d.ts +40 -0
- package/dist/services/telemetry/stall-signals.d.ts +12 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/session.d.ts +7 -0
- package/package.json +6 -5
|
@@ -47,6 +47,8 @@ export interface CreateAgentRuntimeConfigInput {
|
|
|
47
47
|
readonly hooks?: Partial<AgentRuntimeHooks>;
|
|
48
48
|
/** Host-owned context pipeline invoked before runtime model hooks. */
|
|
49
49
|
readonly prepareTurn?: (context: AgentRuntimePrepareTurnContext) => Promise<AgentRuntimePrepareTurnResult | undefined> | AgentRuntimePrepareTurnResult | undefined;
|
|
50
|
+
/** Host-derived diagnostics merged into the run-end telemetry. */
|
|
51
|
+
readonly runEndTelemetryProperties?: AgentRuntimeConfig["runEndTelemetryProperties"];
|
|
50
52
|
/** Seed messages (usually `session.conversation.getMessages()`). */
|
|
51
53
|
readonly initialMessages?: readonly AgentMessage[];
|
|
52
54
|
/**
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type * as LlmsProviders from "@cline/llms";
|
|
2
2
|
import { type AgentConfig, type AgentResult, type BasicLogger, type ITelemetryService } from "@cline/shared";
|
|
3
3
|
import type { ConnectorsRequest } from "../../extensions/composio/composio-meta-tools";
|
|
4
|
+
import type { McpAppResourceReadRequest, McpAppToolBinding, McpAppToolCallRequest, McpResourceReadResult, McpToolCallResult } from "../../extensions/mcp";
|
|
4
5
|
import type { HookEventPayload } from "../../hooks";
|
|
6
|
+
import { type PluginCommandsApi } from "../../services/plugin-command-api";
|
|
5
7
|
import { ProviderSettingsManager } from "../../services/storage/provider-settings-manager";
|
|
6
8
|
import { type SessionCompactionState } from "../../session/models/session-compaction";
|
|
7
9
|
import type { CoreSessionConfig } from "../../types/config";
|
|
@@ -35,6 +37,8 @@ export interface LocalRuntimeHostOptions {
|
|
|
35
37
|
export declare class LocalRuntimeHost implements RuntimeHost {
|
|
36
38
|
readonly runtimeAddress: undefined;
|
|
37
39
|
readonly pendingPrompts: PendingPromptsServiceApi;
|
|
40
|
+
readonly pluginCommands: PluginCommandsApi;
|
|
41
|
+
private readonly pluginCommandManager;
|
|
38
42
|
private readonly sessionService;
|
|
39
43
|
private readonly runtimeBuilder;
|
|
40
44
|
private readonly createAgentInstance;
|
|
@@ -61,11 +65,16 @@ export declare class LocalRuntimeHost implements RuntimeHost {
|
|
|
61
65
|
constructor(options: LocalRuntimeHostOptions);
|
|
62
66
|
private applyInitialOAuthCredentials;
|
|
63
67
|
startSession(input: StartSessionInput): Promise<StartSessionResult>;
|
|
68
|
+
private liveSessionStartResult;
|
|
64
69
|
private startResolvedSession;
|
|
65
70
|
restoreSession(input: RestoreSessionInput): Promise<RestoreSessionResult>;
|
|
66
71
|
runTurn(input: SendSessionInput): Promise<AgentResult | undefined>;
|
|
67
72
|
getAccumulatedUsage(sessionId: string): Promise<SessionUsageSummary | undefined>;
|
|
68
73
|
abort(sessionId: string, reason?: unknown): Promise<void>;
|
|
74
|
+
resolveMcpAppTool(sessionId: string, toolName: string): Promise<McpAppToolBinding | undefined>;
|
|
75
|
+
readMcpAppResource(sessionId: string, request: McpAppResourceReadRequest): Promise<McpResourceReadResult>;
|
|
76
|
+
callMcpAppTool(sessionId: string, request: McpAppToolCallRequest): Promise<McpToolCallResult>;
|
|
77
|
+
private requireMcpApps;
|
|
69
78
|
proceedWhileRunning(sessionId: string, toolCallId?: string): Promise<number>;
|
|
70
79
|
stopSession(sessionId: string): Promise<void>;
|
|
71
80
|
dispose(reason?: string): Promise<void>;
|
|
@@ -168,6 +177,7 @@ export declare class LocalRuntimeHost implements RuntimeHost {
|
|
|
168
177
|
private updateStatus;
|
|
169
178
|
private runWithAuthRetry;
|
|
170
179
|
private syncOAuthCredentials;
|
|
180
|
+
private withSessionPluginCommands;
|
|
171
181
|
private getSessionOrThrow;
|
|
172
182
|
private resolveAbsoluteFilePaths;
|
|
173
183
|
private getSessionAgentTelemetryIdentity;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as LlmsProviders from "@cline/llms";
|
|
2
2
|
import type { AgentMode, AgentResult, RuntimeConfigExtensionKind } from "@cline/shared";
|
|
3
|
+
import type { McpAppResourceReadRequest, McpAppToolBinding, McpAppToolCallRequest, McpResourceReadResult, McpToolCallResult } from "../../extensions/mcp";
|
|
3
4
|
import type { HookEventPayload } from "../../hooks";
|
|
4
5
|
import type { CheckpointEntry } from "../../hooks/checkpoint-hooks";
|
|
5
6
|
import type { ProviderSettings } from "../../services/llms/provider-settings";
|
|
@@ -170,6 +171,11 @@ export interface SessionModelRuntimeService {
|
|
|
170
171
|
export interface SessionConnectionRuntimeService {
|
|
171
172
|
updateSessionConnection(sessionId: string, updates: SessionConnectionUpdate): Promise<void>;
|
|
172
173
|
}
|
|
174
|
+
export interface McpAppsRuntimeService {
|
|
175
|
+
resolveMcpAppTool(sessionId: string, toolName: string): Promise<McpAppToolBinding | undefined>;
|
|
176
|
+
readMcpAppResource(sessionId: string, request: McpAppResourceReadRequest): Promise<McpResourceReadResult>;
|
|
177
|
+
callMcpAppTool(sessionId: string, request: McpAppToolCallRequest): Promise<McpToolCallResult>;
|
|
178
|
+
}
|
|
173
179
|
export interface CommandExecutionRuntimeService {
|
|
174
180
|
proceedWhileRunning(sessionId: string, toolCallId?: string): Promise<number>;
|
|
175
181
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ITelemetryService } from "@cline/shared";
|
|
2
2
|
import { ProviderSettingsManager } from "../../services/storage/provider-settings-manager";
|
|
3
|
+
import type { ProviderSettings } from "../../types/provider-settings";
|
|
3
4
|
type ManagedOAuthProviderId = string;
|
|
4
5
|
export declare class OAuthReauthRequiredError extends Error {
|
|
5
6
|
readonly providerId: ManagedOAuthProviderId;
|
|
@@ -13,10 +14,12 @@ export type RuntimeOAuthResolution = {
|
|
|
13
14
|
export declare class RuntimeOAuthTokenManager {
|
|
14
15
|
private readonly providerSettingsManager;
|
|
15
16
|
private readonly telemetry?;
|
|
17
|
+
private readonly onCredentialsRefreshed?;
|
|
16
18
|
private readonly refreshInFlight;
|
|
17
19
|
constructor(options?: {
|
|
18
20
|
providerSettingsManager?: ProviderSettingsManager;
|
|
19
21
|
telemetry?: ITelemetryService;
|
|
22
|
+
onCredentialsRefreshed?: (previous: ProviderSettings, next: ProviderSettings) => void;
|
|
20
23
|
});
|
|
21
24
|
resolveProviderApiKey(input: {
|
|
22
25
|
providerId: string;
|
|
@@ -135,6 +135,8 @@ export declare class SessionRuntime {
|
|
|
135
135
|
private activeTrackerWork;
|
|
136
136
|
/** True when tracker logic has issued an abort for the active run. */
|
|
137
137
|
private trackerAbortInFlight;
|
|
138
|
+
/** Why the tracker stopped the run; returned as stop control from the hooks. */
|
|
139
|
+
private trackerStopReason;
|
|
138
140
|
private readonly handleExternalAbort;
|
|
139
141
|
constructor(config: AgentConfig, deps?: SessionRuntimeOrchestratorDeps);
|
|
140
142
|
getAgentId(): string;
|
|
@@ -203,11 +205,18 @@ export declare class SessionRuntime {
|
|
|
203
205
|
* Idempotent: subsequent calls are no-ops once the registry has
|
|
204
206
|
* been activated.
|
|
205
207
|
*/
|
|
208
|
+
private extensionInitialization?;
|
|
209
|
+
initializeExtensions(): Promise<void>;
|
|
206
210
|
private ensureExtensionsInitialized;
|
|
207
211
|
private createRuntimeHooks;
|
|
208
212
|
private createRuntimePrepareTurn;
|
|
209
213
|
private prepareMessagesForModelRequest;
|
|
210
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Projects canonical messages into the provider-request shape: extension
|
|
216
|
+
* message builders, then `MessageBuilder.buildForApi` (tool-result
|
|
217
|
+
* truncation, repairs). Produces the `apiMessages` given to `prepareTurn`.
|
|
218
|
+
*/
|
|
219
|
+
prepareProviderMessagesForApi(messages: MessageWithMetadata[]): Promise<MessageWithMetadata[]>;
|
|
211
220
|
private handleRuntimeEvent;
|
|
212
221
|
private syncConversationFromRuntimeMessage;
|
|
213
222
|
private emitLegacyEvent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentConfig, AgentEvent, AgentHooks, AgentResult, AgentTool, BasicLogger, ITelemetryService, ModelTool, RuntimeConfigExtensionKind, ToolApprovalRequest, ToolApprovalResult } from "@cline/shared";
|
|
2
2
|
import type { AgentPluginPackageMcpServer, AgentPluginPackageSkill } from "../../extensions/agent-plugin";
|
|
3
3
|
import type { UserInstructionConfigService } from "../../extensions/config";
|
|
4
|
+
import type { McpAppsRuntime } from "../../extensions/mcp";
|
|
4
5
|
import type { RunCommandExecutionController, ToolExecutors } from "../../extensions/tools";
|
|
5
6
|
import type { AgentTeamsRuntime, DelegatedAgentConfigProvider, SubAgentEndContext, SubAgentStartContext, TeamEvent } from "../../extensions/tools/team";
|
|
6
7
|
import type { WorkspaceManager } from "../../services/workspace/workspace-manager";
|
|
@@ -29,6 +30,7 @@ export interface BuiltRuntime {
|
|
|
29
30
|
extensions?: AgentConfig["extensions"];
|
|
30
31
|
completionPolicy?: AgentConfig["completionPolicy"];
|
|
31
32
|
registerLeadAgent?: (agent: LeadAgentHandle) => void;
|
|
33
|
+
mcpApps?: McpAppsRuntime;
|
|
32
34
|
shutdown: (reason: string) => Promise<void> | void;
|
|
33
35
|
}
|
|
34
36
|
export interface RuntimeBuilderInput {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export interface SubprocessSandboxLauncher {
|
|
2
|
+
command: string;
|
|
3
|
+
/** Host-specific arguments placed before the bootstrap file path. */
|
|
4
|
+
argsPrefix: string[];
|
|
5
|
+
}
|
|
1
6
|
export interface SubprocessSandboxOptions {
|
|
7
|
+
/** A compiled host can dispatch a bootstrap with its embedded filesystem mounted. */
|
|
8
|
+
launcher?: SubprocessSandboxLauncher;
|
|
2
9
|
/** Inline script to execute via `node -e`. Mutually exclusive with {@link bootstrapFile}. */
|
|
3
10
|
bootstrapScript?: string;
|
|
4
11
|
/** Path to a JavaScript file to execute via `node <file>`. Mutually exclusive with {@link bootstrapScript}. */
|
|
@@ -20,10 +27,24 @@ export interface SandboxCallOptions {
|
|
|
20
27
|
timeoutMs?: number;
|
|
21
28
|
}
|
|
22
29
|
export declare const CLINE_JS_RUNTIME_PATH_ENV = "CLINE_JS_RUNTIME_PATH";
|
|
30
|
+
/**
|
|
31
|
+
* Whether `execPath` is this process's own `bun build --compile` executable.
|
|
32
|
+
* Such a binary can still act as the plain `bun` runtime for a child process
|
|
33
|
+
* when spawned with `BUN_BE_BUN=1`, so packaged hosts (the desktop sidecar, a
|
|
34
|
+
* compiled CLI) need neither node nor bun installed on the user's machine.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isCompiledBunExecutable(execPath: string | undefined, host?: {
|
|
37
|
+
isBunRuntime?: boolean;
|
|
38
|
+
selfExecPath?: string;
|
|
39
|
+
}): boolean;
|
|
23
40
|
export declare function resolveSubprocessRuntimeExecutable(options?: {
|
|
24
41
|
env?: NodeJS.ProcessEnv;
|
|
25
42
|
execPath?: string;
|
|
26
43
|
runtimeExecutable?: string;
|
|
44
|
+
host?: {
|
|
45
|
+
isBunRuntime?: boolean;
|
|
46
|
+
selfExecPath?: string;
|
|
47
|
+
};
|
|
27
48
|
}): string;
|
|
28
49
|
export declare function buildSubprocessSandboxCommand(args: string[], options?: {
|
|
29
50
|
env?: NodeJS.ProcessEnv;
|
|
@@ -31,6 +52,7 @@ export declare function buildSubprocessSandboxCommand(args: string[], options?:
|
|
|
31
52
|
name?: string;
|
|
32
53
|
execPath?: string;
|
|
33
54
|
runtimeExecutable?: string;
|
|
55
|
+
launcher?: SubprocessSandboxLauncher;
|
|
34
56
|
}): string[];
|
|
35
57
|
export declare class SubprocessSandbox {
|
|
36
58
|
private readonly options;
|
|
@@ -12,6 +12,8 @@ export interface ClineRecommendedModelsData {
|
|
|
12
12
|
recommended: ClineRecommendedModel[];
|
|
13
13
|
free: ClineRecommendedModel[];
|
|
14
14
|
clinePass: ClineRecommendedModel[];
|
|
15
|
+
/** Free models offered only to cloud sessions (ClineFree). */
|
|
16
|
+
clineCloud?: ClineRecommendedModel[];
|
|
15
17
|
}
|
|
16
18
|
type ModelsCatalog = Record<string, Record<string, ModelInfo>>;
|
|
17
19
|
export interface FetchClineRecommendedModelsOptions {
|
|
@@ -61,6 +61,7 @@ export interface LocalRuntimeBootstrap {
|
|
|
61
61
|
pluginSandboxShutdown?: () => Promise<void>;
|
|
62
62
|
/** Plugins the session asked for but does not have (failed or disabled). */
|
|
63
63
|
pluginIssues: SessionPluginIssue[];
|
|
64
|
+
pluginCommandError?: string;
|
|
64
65
|
runtimeBuilderInput: RuntimeBuilderInput;
|
|
65
66
|
}
|
|
66
67
|
export declare function prepareLocalRuntimeBootstrap(options: PrepareLocalRuntimeBootstrapOptions): Promise<LocalRuntimeBootstrap>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AgentExtensionCommand, AgentExtensionCommandResult, ITelemetryService } from "@cline/shared";
|
|
2
|
+
import { type TelemetryAgentIdentityProperties } from "./telemetry/core-events";
|
|
3
|
+
export interface PluginSlashCommand {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PluginCommandResult {
|
|
8
|
+
reply?: string;
|
|
9
|
+
submitPrompt?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginCommandTarget {
|
|
12
|
+
workspacePath: string;
|
|
13
|
+
/** Use the resident session's plugins, including their session-local state. */
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginCommandCatalog extends PluginCommandTarget {
|
|
17
|
+
status: "ready" | "error";
|
|
18
|
+
commands: PluginSlashCommand[];
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Owned by the runtime. Clients neither load plugins nor own their sandboxes.
|
|
23
|
+
* Every call checks plugin sources, so re-listing is how clients stay current.
|
|
24
|
+
*/
|
|
25
|
+
export interface PluginCommandsApi {
|
|
26
|
+
list(target: PluginCommandTarget): Promise<PluginCommandCatalog>;
|
|
27
|
+
run(input: PluginCommandTarget & {
|
|
28
|
+
prompt: string;
|
|
29
|
+
}): Promise<PluginCommandResult | undefined>;
|
|
30
|
+
}
|
|
31
|
+
export interface PluginCommandsRuntimeService {
|
|
32
|
+
readonly pluginCommands: PluginCommandsApi;
|
|
33
|
+
}
|
|
34
|
+
export declare function normalizePluginCommandName(name: string): string;
|
|
35
|
+
export declare function parsePluginCommand(input: string): {
|
|
36
|
+
name: string;
|
|
37
|
+
input: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
export declare function normalizePluginCommandResult(result: AgentExtensionCommandResult | undefined): PluginCommandResult;
|
|
40
|
+
export declare function listPluginCommands(commands: readonly AgentExtensionCommand[]): PluginSlashCommand[];
|
|
41
|
+
export declare function executePluginCommand(commands: readonly AgentExtensionCommand[], prompt: string, context?: {
|
|
42
|
+
telemetry?: ITelemetryService;
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
modelId?: string;
|
|
45
|
+
provider?: string;
|
|
46
|
+
agentIdentity?: TelemetryAgentIdentityProperties;
|
|
47
|
+
}): Promise<PluginCommandResult | undefined>;
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { type BasicLogger } from "@cline/shared";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type BasicLogger, type ITelemetryService } from "@cline/shared";
|
|
2
|
+
import { resolveAndLoadAgentPlugins } from "../extensions/plugin/plugin-config-loader";
|
|
3
|
+
import { type PluginCommandCatalog, type PluginCommandResult, type PluginCommandTarget } from "./plugin-command-api";
|
|
4
|
+
/** Runtime-owned workspace catalogs. Session execution uses the session registry instead. */
|
|
5
|
+
export declare class PluginCommandManager {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly entries;
|
|
8
|
+
private disposed;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
logger?: BasicLogger;
|
|
11
|
+
telemetry?: ITelemetryService;
|
|
12
|
+
load?: typeof resolveAndLoadAgentPlugins;
|
|
13
|
+
});
|
|
14
|
+
list(target: PluginCommandTarget): Promise<PluginCommandCatalog>;
|
|
15
|
+
run(input: PluginCommandTarget & {
|
|
16
|
+
prompt: string;
|
|
17
|
+
}): Promise<PluginCommandResult | undefined>;
|
|
18
|
+
dispose(): Promise<void>;
|
|
19
|
+
private withEntry;
|
|
20
|
+
private release;
|
|
21
|
+
/** Fingerprint discoverable entries and their import graphs. The entry list
|
|
22
|
+
* already excludes plugins disabled in settings, so other settings do not
|
|
23
|
+
* participate. Runtime output beside a plugin is not source either. */
|
|
24
|
+
private fingerprint;
|
|
25
|
+
private refresh;
|
|
6
26
|
}
|
|
7
|
-
export interface PluginCommandResult {
|
|
8
|
-
reply?: string;
|
|
9
|
-
submitPrompt?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Executes plugin-registered slash commands (`api.registerCommand`) for one
|
|
13
|
-
* workspace. Plugins are loaded on first use and kept alive so repeated
|
|
14
|
-
* commands answer instantly; the loaded set is refreshed when plugin module
|
|
15
|
-
* paths or mtimes change (installs, updates, toggles).
|
|
16
|
-
*/
|
|
17
|
-
export interface PluginCommandService {
|
|
18
|
-
listCommands(): Promise<PluginSlashCommand[]>;
|
|
19
|
-
/** Runs `/name input`. Resolves undefined when no plugin declares `name`. */
|
|
20
|
-
run(name: string, input: string): Promise<PluginCommandResult | undefined>;
|
|
21
|
-
shutdown(): Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export declare function normalizePluginCommandName(name: string): string;
|
|
24
|
-
export declare function createPluginCommandService(options: {
|
|
25
|
-
cwd: string;
|
|
26
|
-
workspacePath?: string;
|
|
27
|
-
logger?: BasicLogger;
|
|
28
|
-
}): PluginCommandService;
|
|
@@ -52,12 +52,14 @@ export declare const CORE_TELEMETRY_EVENTS: {
|
|
|
52
52
|
readonly DIFF_EDIT_FAILED: "task.diff_edit_failed";
|
|
53
53
|
readonly PROVIDER_API_ERROR: "task.provider_api_error";
|
|
54
54
|
readonly MISTAKE_LIMIT_REACHED: "task.mistake_limit_reached";
|
|
55
|
+
readonly CAPABILITY_OWNER_GONE: "task.capability_owner_gone";
|
|
55
56
|
readonly PROVIDER_REQUEST_STARTED: "task.provider_request_started";
|
|
56
57
|
readonly PROVIDER_STREAM_STARTED: "task.provider_stream_started";
|
|
57
58
|
readonly FIRST_CHUNK_RECEIVED: "task.first_chunk_received";
|
|
58
59
|
readonly PROVIDER_STREAM_FAILED: "task.provider_stream_failed";
|
|
59
60
|
readonly MAX_TOKENS_RECOVERY: "task.max_tokens_recovery";
|
|
60
61
|
readonly CANCELLED: "task.cancelled";
|
|
62
|
+
readonly RUN_IDLE: "task.run_idle";
|
|
61
63
|
readonly MENTION_USED: "task.mention_used";
|
|
62
64
|
readonly MENTION_FAILED: "task.mention_failed";
|
|
63
65
|
readonly MENTION_SEARCH_RESULTS: "task.mention_search_results";
|
|
@@ -334,6 +336,30 @@ export declare function captureMistakeLimitReached(telemetry: ITelemetryService
|
|
|
334
336
|
consecutiveMistakes: number;
|
|
335
337
|
maxConsecutiveMistakes: number;
|
|
336
338
|
} & Partial<TelemetryAgentIdentityProperties>): void;
|
|
339
|
+
/**
|
|
340
|
+
* Records when a run's hook, client tool, or other client callback fails
|
|
341
|
+
* because the app that owns it disconnected or left the task.
|
|
342
|
+
*/
|
|
343
|
+
export declare function captureCapabilityOwnerGone(telemetry: ITelemetryService | undefined, properties: {
|
|
344
|
+
sessionId: string;
|
|
345
|
+
capabilityName: string;
|
|
346
|
+
/** disconnected / detached: failed before asking; cancelled_while_waiting: the app left mid-request. */
|
|
347
|
+
reason: "disconnected" | "detached" | "cancelled_while_waiting";
|
|
348
|
+
}): void;
|
|
349
|
+
/**
|
|
350
|
+
* At most once per agent run, while it is still running and has emitted no
|
|
351
|
+
* runtime event (stream deltas included) for `idleMs`. Sent while stuck so
|
|
352
|
+
* hangs the user escapes by quitting the app are still counted.
|
|
353
|
+
*/
|
|
354
|
+
export declare function captureRunIdle(telemetry: ITelemetryService | undefined, properties: {
|
|
355
|
+
ulid?: string;
|
|
356
|
+
agentId: string;
|
|
357
|
+
runId: string;
|
|
358
|
+
idleMs: number;
|
|
359
|
+
/** Runtime event type that preceded the silence. */
|
|
360
|
+
lastEventType: string;
|
|
361
|
+
isSubagent: boolean;
|
|
362
|
+
}): void;
|
|
337
363
|
export declare function captureRunCommandsTimeout(telemetry: ITelemetryService | undefined, properties: RunCommandsTimeoutTelemetryProperties): void;
|
|
338
364
|
export interface PlanModeCommandBlockedTelemetryProperties {
|
|
339
365
|
tool_name: "run_commands";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as F,mkdirSync as H,readFileSync as V,writeFileSync as B}from"node:fs";import{resolve as z}from"node:path";import{resolveSessionDataDir as j}from"@cline/shared/storage";import{nanoid as W}from"nanoid";import*as q from"node-machine-id";var Y="machine-id",O,C=!1;function v(){if(!C)O=x(),C=!0;return O??R()}function f(e){let t=e?.trim();if(t)return t;let r=x();if(r)return r;return R()}function X(){let e=q;return e.machineIdSync??e.default?.machineIdSync}function x(){try{let e=X();if(!e)return;return e().trim()||void 0}catch{return}}function R(){let e=j(),t=z(e,Y);try{if(F(t)){let i=V(t,"utf8").trim();if(i.length>0)return i}}catch{}let r=`cl-${W()}`;try{H(e,{recursive:!0}),B(t,r,"utf8")}catch{}return r}import{SeverityNumber as g}from"@opentelemetry/api-logs";class y{name;metadata;meter;logger;enabled;distinctId;commonProperties;counters=new Map;histograms=new Map;gauges=new Map;gaugeValues=new Map;meterProvider;loggerProvider;constructor(e){this.name=e.name??"OpenTelemetryAdapter",this.metadata={...e.metadata},this.meterProvider=e.meterProvider,this.loggerProvider=e.loggerProvider,this.meter=e.meterProvider?.getMeter("cline")??null,this.logger=e.loggerProvider?.getLogger("cline")??null,this.enabled=e.enabled??!0,this.distinctId=e.distinctId,this.commonProperties=e.commonProperties?{...e.commonProperties}:{}}emit(e,t){if(!this.isEnabled())return;this.emitLog(e,t,!1)}emitRequired(e,t){this.emitLog(e,t,!0)}recordCounter(e,t,r,i,o=!1){if(!this.meter||!o&&!this.isEnabled())return;let s=this.counters.get(e);if(!s)s=this.meter.createCounter(e,i?{description:i}:void 0),this.counters.set(e,s);s.add(t,this.flattenProperties(this.buildAttributes(r)))}recordHistogram(e,t,r,i,o=!1){if(!this.meter||!o&&!this.isEnabled())return;let s=this.histograms.get(e);if(!s)s=this.meter.createHistogram(e,i?{description:i}:void 0),this.histograms.set(e,s);s.record(t,this.flattenProperties(this.buildAttributes(r)))}recordGauge(e,t,r,i,o=!1){if(!this.meter||!o&&!this.isEnabled())return;let s=this.buildAttributes(r),n=JSON.stringify(s),d=this.gaugeValues.get(e);if(t===null){if(d){if(d.delete(n),d.size===0)this.gaugeValues.delete(e),this.gauges.delete(e)}return}let a=d;if(!a)a=new Map,this.gaugeValues.set(e,a);if(!this.gauges.has(e)){let l=this.meter.createObservableGauge(e,i?{description:i}:void 0);l.addCallback((m)=>{for(let A of this.snapshotGaugeSeries(e))m.observe(A.value,this.flattenProperties(A.attributes))}),this.gauges.set(e,l)}a.set(n,{value:t,attributes:s})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}setDistinctId(e){this.distinctId=e}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}async flush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.()])}emitLog(e,t,r){if(!this.logger)return;let i=this.flattenProperties(this.buildAttributes(t,r)),o=J(i.severity);this.logger.emit({severityText:o.text,severityNumber:o.number,body:e,attributes:i})}buildAttributes(e,t=!1){return{...this.commonProperties,...this.metadata,...e,...this.distinctId?{distinct_id:this.distinctId}:{},...t?{_required:!0}:{}}}snapshotGaugeSeries(e){let t=this.gaugeValues.get(e);if(!t)return[];return Array.from(t.values(),(r)=>({value:r.value,attributes:r.attributes?{...r.attributes}:void 0}))}flattenProperties(e,t="",r=new WeakSet,i=0){if(!e)return{};let o={},s=100,n=10;for(let[d,a]of Object.entries(e)){if(d==="__proto__"||d==="constructor"||d==="prototype")continue;let l=t?`${t}.${d}`:d;if(a===null||a===void 0){o[l]=String(a);continue}if(Array.isArray(a)){let m=a.length>s?a.slice(0,s):a;try{o[l]=JSON.stringify(m)}catch{o[l]="[UnserializableArray]"}if(a.length>s)o[`${l}_truncated`]=!0,o[`${l}_original_length`]=a.length;continue}if(typeof a==="object"){if(a instanceof Date){o[l]=a.toISOString();continue}if(a instanceof Error){o[l]=a.message;continue}if(r.has(a)){o[l]="[Circular]";continue}if(i>=n){o[l]="[MaxDepthExceeded]";continue}r.add(a),Object.assign(o,this.flattenProperties(a,l,r,i+1));continue}if(Q(a)){o[l]=a;continue}try{o[l]=JSON.stringify(a)}catch{o[l]=String(a)}}return o}}function J(e){switch(typeof e==="string"?e.toLowerCase():e){case"trace":return{text:"TRACE",number:g.TRACE};case"debug":return{text:"DEBUG",number:g.DEBUG};case"warn":case"warning":return{text:"WARN",number:g.WARN};case"error":return{text:"ERROR",number:g.ERROR};case"fatal":return{text:"FATAL",number:g.FATAL};default:return{text:"INFO",number:g.INFO}}}function Q(e){return typeof e==="string"||typeof e==="number"||typeof e==="boolean"}import{LangfuseAttributesSpanProcessor as ce}from"@cline/llms";import{markOtlpTraceRelayProvider as ue}from"@cline/shared";import{metrics as me,trace as pe}from"@opentelemetry/api";import{logs as ge}from"@opentelemetry/api-logs";import{OTLPLogExporter as fe}from"@opentelemetry/exporter-logs-otlp-http";import{OTLPMetricExporter as ye}from"@opentelemetry/exporter-metrics-otlp-http";import{OTLPTraceExporter as Te}from"@opentelemetry/exporter-trace-otlp-http";import{resourceFromAttributes as Se}from"@opentelemetry/resources";import{BatchLogRecordProcessor as ve,ConsoleLogRecordExporter as be,LoggerProvider as Ee}from"@opentelemetry/sdk-logs";import{ConsoleMetricExporter as he,MeterProvider as Pe,PeriodicExportingMetricReader as N}from"@opentelemetry/sdk-metrics";import{BatchSpanProcessor as _e,ConsoleSpanExporter as Ie,SimpleSpanProcessor as Ae}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as Oe}from"@opentelemetry/sdk-trace-node";import{ATTR_SERVICE_NAME as Ce,ATTR_SERVICE_VERSION as xe}from"@opentelemetry/semantic-conventions";import{mkdirSync as rt,readFileSync as Z,statSync as ee,writeFileSync as it}from"node:fs";import{CONFIGURABLE_MODEL_TOOL_NAMES as te}from"@cline/shared";import{resolveGlobalSettingsPath as re}from"@cline/shared/storage";import{z as c}from"zod";import{AGENT_UNEXPECTED_REASONING_TOKENS_EVENT as Be,captureAgentUnexpectedReasoningTokens as ze,captureTaskLifecycleEvent as je,SDK_ERROR_TELEMETRY_EVENT as We,TASK_CANCELLED_EVENT as qe,TASK_FIRST_CHUNK_RECEIVED_EVENT as Ye,TASK_MAX_TOKENS_RECOVERY_EVENT as Xe,TASK_PROVIDER_REQUEST_STARTED_EVENT as $e,TASK_PROVIDER_STREAM_FAILED_EVENT as Je,TASK_PROVIDER_STREAM_STARTED_EVENT as Qe}from"@cline/shared";var b=c.preprocess((e)=>Array.isArray(e)?e.filter((t)=>typeof t==="string").map((t)=>t.trim()).filter(Boolean):void 0,c.array(c.string()).optional()).transform((e)=>{if(!e)return;let t=[...new Set(e)].sort((r,i)=>r.localeCompare(i));return t.length>0?t:void 0}),ie=c.enum(["basic","agentic"]).catch("agentic"),oe=c.partialRecord(c.enum(te),c.object({enabled:c.boolean()}).strip()).optional(),ne=c.enum(["plan","act"]),M=c.object({telemetryOptOut:c.boolean().default(!1).catch(!1),autoUpdateEnabled:c.boolean().default(!0).catch(!0),compactionStrategy:ie.optional(),compactionEnabled:c.boolean().optional().catch(void 0),planActMode:ne.optional().catch(void 0),toolAutoApprove:c.boolean().optional().catch(void 0),tuiTheme:c.string().optional().catch(void 0),disabledTools:b.optional(),tools:oe,disabledPlugins:b.optional(),disabledAgentPlugins:b.optional()}).strip().transform((e)=>{let t={autoUpdateEnabled:e.autoUpdateEnabled,telemetryOptOut:e.telemetryOptOut};if(e.compactionStrategy)t.compactionStrategy=e.compactionStrategy;if(e.compactionEnabled!==void 0)t.compactionEnabled=e.compactionEnabled;if(e.planActMode)t.planActMode=e.planActMode;if(e.toolAutoApprove!==void 0)t.toolAutoApprove=e.toolAutoApprove;if(e.tuiTheme?.trim())t.tuiTheme=e.tuiTheme.trim();if(e.disabledTools?.length)t.disabledTools=e.disabledTools;if(e.tools&&Object.keys(e.tools).length>0)t.tools=e.tools;if(e.disabledPlugins?.length)t.disabledPlugins=e.disabledPlugins;if(e.disabledAgentPlugins?.length)t.disabledAgentPlugins=e.disabledAgentPlugins;return t});function T(){return M.parse({})}var E;function se(e){if(e.disabledTools)Object.freeze(e.disabledTools);if(e.tools){for(let t of Object.values(e.tools))Object.freeze(t);Object.freeze(e.tools)}if(e.disabledPlugins)Object.freeze(e.disabledPlugins);if(e.disabledAgentPlugins)Object.freeze(e.disabledAgentPlugins);return Object.freeze(e)}function ae(e){let t;try{t=Z(e,"utf8")}catch{return{value:T(),loadFailed:!0}}try{let r=M.safeParse(JSON.parse(t));return r.success?{value:r.data,loadFailed:!1}:{value:T(),loadFailed:!0}}catch{return{value:T(),loadFailed:!0}}}function de(){let e=re(),t=ee(e,{throwIfNoEntry:!1}),r=t?.mtimeMs??0,i=t?.size??0,o=E;if(o&&o.path===e&&o.mtimeMs===r&&o.size===i)return o;let s=t?ae(e):{value:T(),loadFailed:!1},n=se(s.value);return E={path:e,mtimeMs:r,size:i,value:n,loadFailed:s.loadFailed},E}function le(){return de().value}function D(){return le().telemetryOptOut}class h{name;logger;enabled;constructor(e={}){this.name=e.name??"TelemetryLoggerSink",this.logger=e.logger,this.enabled=e.enabled??!0}emit(e,t){if(!this.isEnabled())return;this.logger?.log("telemetry.event",{telemetrySink:this.name,event:e,properties:t})}emitRequired(e,t){this.logger?.log("telemetry.required_event",{telemetrySink:this.name,severity:"warn",event:e,properties:t})}recordCounter(e,t,r,i,o){if(!o&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"counter",name:e,value:t,attributes:r,description:i,required:o===!0})}recordHistogram(e,t,r,i,o){if(!o&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"histogram",name:e,value:t,attributes:r,description:i,required:o===!0})}recordGauge(e,t,r,i,o){if(!o&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"gauge",name:e,value:t,attributes:r,description:i,required:o===!0})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}async flush(){}async dispose(){}}class S{adapters;metadata;distinctId;deviceId;commonProperties;constructor(e={}){if(this.adapters=[...e.adapters??[]],e.logger)this.adapters.push(new h({logger:e.logger}));this.metadata={...e.metadata??{}},this.distinctId=e.distinctId,this.deviceId=e.deviceId??v(),this.commonProperties={...e.commonProperties??{}}}addAdapter(e){this.adapters.push(e)}setDistinctId(e){this.distinctId=e}setMetadata(e){this.metadata={...e}}updateMetadata(e){this.metadata={...this.metadata,...e}}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}isEnabled(){return this.adapters.some((e)=>e.isEnabled())}capture(e){let t=this.buildAttributes(e.properties);for(let r of this.adapters)r.emit(e.event,t)}captureRequired(e,t){let r=this.buildAttributes(t);for(let i of this.adapters)i.emitRequired(e,r)}recordCounter(e,t,r,i,o=!1){let s=this.buildAttributes(r);for(let n of this.adapters)n.recordCounter(e,t,s,i,o)}recordHistogram(e,t,r,i,o=!1){let s=this.buildAttributes(r);for(let n of this.adapters)n.recordHistogram(e,t,s,i,o)}recordGauge(e,t,r,i,o=!1){let s=this.buildAttributes(r);for(let n of this.adapters)n.recordGauge(e,t,s,i,o)}async flush(){await Promise.all(this.adapters.map((e)=>e.flush()))}async dispose(){await Promise.all(this.adapters.map((e)=>e.dispose()))}buildAttributes(e){let t=typeof e?.distinct_id==="string"&&e.distinct_id.trim()?e.distinct_id.trim():this.distinctId,r={...this.commonProperties,...this.metadata,...e,...t?{distinct_id:t}:{},device_id:this.deviceId};return Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0))}}class k{distinctId;metadata;commonProperties;constructor(e={}){this.distinctId=e.distinctId,this.metadata={...e.metadata??{}},this.commonProperties={...e.commonProperties??{}}}setDistinctId(e){this.distinctId=e}setMetadata(e){this.metadata={...e}}updateMetadata(e){this.metadata={...this.metadata,...e}}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}isEnabled(){return!1}capture(e){this.resolveProperties(e.properties)}captureRequired(e,t){this.resolveProperties(t)}recordCounter(){}recordHistogram(){}recordGauge(){}async flush(){}async dispose(){}resolveProperties(e){let t=typeof e?.distinct_id==="string"&&e.distinct_id.trim()?e.distinct_id.trim():this.distinctId,r={...this.commonProperties,...this.metadata,...e,...t?{distinct_id:t}:{}};return Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0))}}class _{meterProvider;loggerProvider;tracerProvider;options;constructor(e={}){this.options=e;let t=Se({...e.resourceAttributes,[Ce]:e.serviceName??"cline",...e.serviceVersion?{[xe]:e.serviceVersion}:{}});if(this.meterProvider=this.createMeterProvider(t),this.loggerProvider=this.createLoggerProvider(t),this.tracerProvider=this.createTracerProvider(t),this.meterProvider)me.setGlobalMeterProvider(this.meterProvider);if(this.loggerProvider)ge.setGlobalLoggerProvider(this.loggerProvider);if(this.tracerProvider)this.tracerProvider.register()}getTracer(e="cline",t){return pe.getTracer(e,t??this.options.serviceVersion)}createAdapter(e){return new y({...e,meterProvider:this.meterProvider,loggerProvider:this.loggerProvider})}createTelemetryService(e){let t=this.createAdapter({name:e.name,enabled:this.options.enabled,metadata:e.metadata});return new S({...e,adapters:[t],distinctId:f(e.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(e){let t=P(this.options.metricsExporter);if(t.length===0)return null;let r=Math.max(1000,this.options.metricExportIntervalMs??this.options.metricExportInterval??60000),i=Math.min(30000,Math.floor(r*0.8)),o=t.map((s)=>Ne(s,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json",interval:r,timeout:i})).filter((s)=>s!==null);if(o.length===0)return null;return new Pe({resource:e,readers:o})}createTracerProvider(e){let t=P(this.options.tracesExporter);if(t.length===0)return null;let r=this.options.otlpTracesEndpoint??this.options.otlpEndpoint,i=this.options.otlpTracesHeaders??this.options.otlpHeaders,o=[],s=!1;for(let d of t){let a=De(d,{endpoint:r,headers:i,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(a){if(o.push(a),d!=="console")s=!0}}if(o.length===0)return null;let n=new Oe({resource:e,spanProcessors:s?[new ce,...o]:o});if(s)ue(n);return n}createLoggerProvider(e){let t=P(this.options.logsExporter);if(t.length===0)return null;let r=t.map((i)=>{let o=Me(i,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(!o)return null;return new ve(o,{maxQueueSize:this.options.logMaxQueueSize??2048,maxExportBatchSize:this.options.logBatchSize??512,scheduledDelayMillis:this.options.logBatchTimeoutMs??this.options.logBatchTimeout??5000})}).filter((i)=>i!==null);if(r.length===0)return null;return new Ee({resource:e,processors:r})}}function L(e){let t=new _(e),r=t.createTelemetryService(e),i=()=>{r.captureRequired("telemetry.provider_created",{provider:"opentelemetry",enabled:e.enabled??!0,logsExporter:Array.isArray(e.logsExporter)?e.logsExporter.join(","):e.logsExporter,metricsExporter:Array.isArray(e.metricsExporter)?e.metricsExporter.join(","):e.metricsExporter,tracesExporter:Array.isArray(e.tracesExporter)?e.tracesExporter.join(","):e.tracesExporter,otlpProtocol:e.otlpProtocol,hasOtlpEndpoint:Boolean(e.otlpEndpoint),serviceName:e.serviceName,serviceVersion:e.serviceVersion})};if(!e.deferProviderCreatedEvent)i();return{provider:t,telemetry:r,emitProviderCreated:i}}function w(e){if(D())return{telemetry:new k(e)};if(e.enabled!==!0)return{telemetry:new S({...e,distinctId:f(e.distinctId)})};return L(e)}function Re(e){let{telemetry:t,provider:r,emitProviderCreated:i}=w(e);return{telemetry:t,provider:r,flush:async()=>{let n=r;if(n&&typeof n.forceFlush==="function")try{await n.forceFlush()}catch{}},dispose:async()=>{await Promise.allSettled([t.dispose(),r?.dispose()])},...e.deferProviderCreatedEvent&&i?{emitProviderCreated:i}:{}}}function P(e){if(!e)return[];return(Array.isArray(e)?e:e.split(",")).map((r)=>r.trim()).filter((r)=>r==="console"||r==="otlp")}function Me(e,t){if(e==="console")return new be;if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/logs");return new fe({url:r,headers:t.headers})}function De(e,t){if(e==="console")return new Ae(new Ie);if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/traces");return new _e(new Te({url:r,headers:t.headers}))}function Ne(e,t){if(e==="console")return new N({exporter:new he,exportIntervalMillis:t.interval,exportTimeoutMillis:t.timeout});if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/metrics");return new N({exporter:new ye({url:r,headers:t.headers}),exportIntervalMillis:t.interval,exportTimeoutMillis:t.timeout})}function I(e,t){let r=new URL(e),i=r.pathname.endsWith("/")?r.pathname.slice(0,-1):r.pathname;return r.pathname=i.endsWith(t)?i:`${i}${t}`,r.toString()}import{SESSION_STATUS_VALUES as Dt}from"@cline/shared";var p={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 G(e){let t=[e?.name,e?.platform].filter((r)=>typeof r==="string").join(" ").toLowerCase();if(!t)return;if(t.includes("vscode")||t.includes("visual studio code"))return p.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 p.JETBRAINS;if(t.includes("neovim"))return p.NEOVIM;if(t.includes("kanban"))return p.KANBAN;if(t.includes("desktop"))return p.DESKTOP;if(t.includes("cline-platform"))return p.WEB;if(t.includes("cline-cli")||t.includes("cline-acp"))return p.CLI;if(t.includes("cline-sdk")||t.includes("cline-core"))return p.CORE;return}function u(e){let t=e?.trim();return t?t:void 0}function U(e){let t=e.client,r=G(t)??u(e.source),i=u(t.version),o=u(t.platform)??u(t.name),s=u(t.platformVersion)??i,n={cline_type:r,extension_version:i,platform:o,platform_version:s};if(e.user?.accountId===void 0)return n;let d=typeof e.user.accountId==="string"?u(e.user.accountId):void 0;return{...n,distinct_id:d??u(e.user.distinctId),user_id:d,account_id:d,account_email:d?u(e.user.email):void 0,organization_id:d?u(e.user.organizationId):void 0}}function K(e,t){let r={},i={},o,s=(n)=>({...t,...i,...r,...n,...o?{distinct_id:o}:{}});return{setDistinctId(n){o=u(n)},setMetadata(n){r={...n}},updateMetadata(n){r={...r,...n}},setCommonProperties(n){i={...n}},updateCommonProperties(n){i={...i,...n}},isEnabled:()=>e.isEnabled(),capture:(n)=>e.capture({event:n.event,properties:s(n.properties)}),captureRequired:(n,d)=>e.captureRequired(n,s(d)),recordCounter:(n,d,a,l,m)=>e.recordCounter(n,d,s(a),l,m),recordHistogram:(n,d,a,l,m)=>e.recordHistogram(n,d,s(a),l,m),recordGauge:(n,d,a,l,m)=>e.recordGauge(n,d,s(a),l,m),flush:()=>e.flush(),dispose:async()=>{}}}function ke(e,t){return K(e,U(t))}export{y as OpenTelemetryAdapter,_ as OpenTelemetryProvider,ke as createClientScopedTelemetryService,Re as createConfiguredTelemetryHandle,w as createConfiguredTelemetryService,L as createOpenTelemetryTelemetryService,K as createScopedTelemetryService,U as resolveClientTelemetryProperties,v as resolveCoreDeviceId,f as resolveCoreDistinctId};
|
|
1
|
+
import{existsSync as F,mkdirSync as H,readFileSync as V,writeFileSync as B}from"node:fs";import{resolve as z}from"node:path";import{resolveSessionDataDir as j}from"@cline/shared/storage";import{nanoid as W}from"nanoid";import*as q from"node-machine-id";var Y="machine-id",O,C=!1;function v(){if(!C)O=R(),C=!0;return O??x()}function f(e){let t=e?.trim();if(t)return t;let r=R();if(r)return r;return x()}function X(){let e=q;return e.machineIdSync??e.default?.machineIdSync}function R(){try{let e=X();if(!e)return;return e().trim()||void 0}catch{return}}function x(){let e=j(),t=z(e,Y);try{if(F(t)){let i=V(t,"utf8").trim();if(i.length>0)return i}}catch{}let r=`cl-${W()}`;try{H(e,{recursive:!0}),B(t,r,"utf8")}catch{}return r}import{SeverityNumber as g}from"@opentelemetry/api-logs";class y{name;metadata;meter;logger;enabled;distinctId;commonProperties;counters=new Map;histograms=new Map;gauges=new Map;gaugeValues=new Map;meterProvider;loggerProvider;constructor(e){this.name=e.name??"OpenTelemetryAdapter",this.metadata={...e.metadata},this.meterProvider=e.meterProvider,this.loggerProvider=e.loggerProvider,this.meter=e.meterProvider?.getMeter("cline")??null,this.logger=e.loggerProvider?.getLogger("cline")??null,this.enabled=e.enabled??!0,this.distinctId=e.distinctId,this.commonProperties=e.commonProperties?{...e.commonProperties}:{}}emit(e,t){if(!this.isEnabled())return;this.emitLog(e,t,!1)}emitRequired(e,t){this.emitLog(e,t,!0)}recordCounter(e,t,r,i,n=!1){if(!this.meter||!n&&!this.isEnabled())return;let s=this.counters.get(e);if(!s)s=this.meter.createCounter(e,i?{description:i}:void 0),this.counters.set(e,s);s.add(t,this.flattenProperties(this.buildAttributes(r)))}recordHistogram(e,t,r,i,n=!1){if(!this.meter||!n&&!this.isEnabled())return;let s=this.histograms.get(e);if(!s)s=this.meter.createHistogram(e,i?{description:i}:void 0),this.histograms.set(e,s);s.record(t,this.flattenProperties(this.buildAttributes(r)))}recordGauge(e,t,r,i,n=!1){if(!this.meter||!n&&!this.isEnabled())return;let s=this.buildAttributes(r),o=JSON.stringify(s),d=this.gaugeValues.get(e);if(t===null){if(d){if(d.delete(o),d.size===0)this.gaugeValues.delete(e),this.gauges.delete(e)}return}let a=d;if(!a)a=new Map,this.gaugeValues.set(e,a);if(!this.gauges.has(e)){let l=this.meter.createObservableGauge(e,i?{description:i}:void 0);l.addCallback((m)=>{for(let A of this.snapshotGaugeSeries(e))m.observe(A.value,this.flattenProperties(A.attributes))}),this.gauges.set(e,l)}a.set(o,{value:t,attributes:s})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}setDistinctId(e){this.distinctId=e}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}async flush(){await Promise.all([this.meterProvider?.forceFlush?.(),this.loggerProvider?.forceFlush?.()])}async dispose(){await Promise.all([this.meterProvider?.shutdown?.(),this.loggerProvider?.shutdown?.()])}emitLog(e,t,r){if(!this.logger)return;let i=this.flattenProperties(this.buildAttributes(t,r)),n=J(i.severity);this.logger.emit({severityText:n.text,severityNumber:n.number,body:e,attributes:i})}buildAttributes(e,t=!1){return{...this.commonProperties,...this.metadata,...e,...this.distinctId?{distinct_id:this.distinctId}:{},...t?{_required:!0}:{}}}snapshotGaugeSeries(e){let t=this.gaugeValues.get(e);if(!t)return[];return Array.from(t.values(),(r)=>({value:r.value,attributes:r.attributes?{...r.attributes}:void 0}))}flattenProperties(e,t="",r=new WeakSet,i=0){if(!e)return{};let n={},s=100,o=10;for(let[d,a]of Object.entries(e)){if(d==="__proto__"||d==="constructor"||d==="prototype")continue;let l=t?`${t}.${d}`:d;if(a===null||a===void 0){n[l]=String(a);continue}if(Array.isArray(a)){let m=a.length>s?a.slice(0,s):a;try{n[l]=JSON.stringify(m)}catch{n[l]="[UnserializableArray]"}if(a.length>s)n[`${l}_truncated`]=!0,n[`${l}_original_length`]=a.length;continue}if(typeof a==="object"){if(a instanceof Date){n[l]=a.toISOString();continue}if(a instanceof Error){n[l]=a.message;continue}if(r.has(a)){n[l]="[Circular]";continue}if(i>=o){n[l]="[MaxDepthExceeded]";continue}r.add(a),Object.assign(n,this.flattenProperties(a,l,r,i+1));continue}if(Q(a)){n[l]=a;continue}try{n[l]=JSON.stringify(a)}catch{n[l]=String(a)}}return n}}function J(e){switch(typeof e==="string"?e.toLowerCase():e){case"trace":return{text:"TRACE",number:g.TRACE};case"debug":return{text:"DEBUG",number:g.DEBUG};case"warn":case"warning":return{text:"WARN",number:g.WARN};case"error":return{text:"ERROR",number:g.ERROR};case"fatal":return{text:"FATAL",number:g.FATAL};default:return{text:"INFO",number:g.INFO}}}function Q(e){return typeof e==="string"||typeof e==="number"||typeof e==="boolean"}import{LangfuseAttributesSpanProcessor as ce}from"@cline/llms";import{markOtlpTraceRelayProvider as ue}from"@cline/shared";import{metrics as me,trace as pe}from"@opentelemetry/api";import{logs as ge}from"@opentelemetry/api-logs";import{OTLPLogExporter as fe}from"@opentelemetry/exporter-logs-otlp-http";import{OTLPMetricExporter as ye}from"@opentelemetry/exporter-metrics-otlp-http";import{OTLPTraceExporter as Te}from"@opentelemetry/exporter-trace-otlp-http";import{resourceFromAttributes as Se}from"@opentelemetry/resources";import{BatchLogRecordProcessor as ve,ConsoleLogRecordExporter as be,LoggerProvider as Ee}from"@opentelemetry/sdk-logs";import{ConsoleMetricExporter as he,MeterProvider as Pe,PeriodicExportingMetricReader as N}from"@opentelemetry/sdk-metrics";import{BatchSpanProcessor as _e,ConsoleSpanExporter as Ie,SimpleSpanProcessor as Ae}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as Oe}from"@opentelemetry/sdk-trace-node";import{ATTR_SERVICE_NAME as Ce,ATTR_SERVICE_VERSION as Re}from"@opentelemetry/semantic-conventions";import{mkdirSync as rt,readFileSync as Z,statSync as ee,writeFileSync as it}from"node:fs";import{CONFIGURABLE_MODEL_TOOL_NAMES as te}from"@cline/shared";import{resolveGlobalSettingsPath as re}from"@cline/shared/storage";import{z as c}from"zod";import{AGENT_UNEXPECTED_REASONING_TOKENS_EVENT as Be,captureAgentUnexpectedReasoningTokens as ze,captureTaskLifecycleEvent as je,SDK_ERROR_TELEMETRY_EVENT as We,TASK_CANCELLED_EVENT as qe,TASK_FIRST_CHUNK_RECEIVED_EVENT as Ye,TASK_MAX_TOKENS_RECOVERY_EVENT as Xe,TASK_PROVIDER_REQUEST_STARTED_EVENT as $e,TASK_PROVIDER_STREAM_FAILED_EVENT as Je,TASK_PROVIDER_STREAM_STARTED_EVENT as Qe}from"@cline/shared";var b=c.preprocess((e)=>Array.isArray(e)?e.filter((t)=>typeof t==="string").map((t)=>t.trim()).filter(Boolean):void 0,c.array(c.string()).optional()).transform((e)=>{if(!e)return;let t=[...new Set(e)].sort((r,i)=>r.localeCompare(i));return t.length>0?t:void 0}),ie=c.enum(["basic","agentic"]).catch("agentic"),ne=c.partialRecord(c.enum(te),c.object({enabled:c.boolean()}).strip()).optional(),oe=c.enum(["plan","act"]),M=c.object({telemetryOptOut:c.boolean().default(!1).catch(!1),autoUpdateEnabled:c.boolean().default(!0).catch(!0),compactionStrategy:ie.optional(),compactionEnabled:c.boolean().optional().catch(void 0),planActMode:oe.optional().catch(void 0),toolAutoApprove:c.boolean().optional().catch(void 0),tuiTheme:c.string().optional().catch(void 0),disabledTools:b.optional(),tools:ne,disabledPlugins:b.optional(),disabledAgentPlugins:b.optional()}).strip().transform((e)=>{let t={autoUpdateEnabled:e.autoUpdateEnabled,telemetryOptOut:e.telemetryOptOut};if(e.compactionStrategy)t.compactionStrategy=e.compactionStrategy;if(e.compactionEnabled!==void 0)t.compactionEnabled=e.compactionEnabled;if(e.planActMode)t.planActMode=e.planActMode;if(e.toolAutoApprove!==void 0)t.toolAutoApprove=e.toolAutoApprove;if(e.tuiTheme?.trim())t.tuiTheme=e.tuiTheme.trim();if(e.disabledTools?.length)t.disabledTools=e.disabledTools;if(e.tools&&Object.keys(e.tools).length>0)t.tools=e.tools;if(e.disabledPlugins?.length)t.disabledPlugins=e.disabledPlugins;if(e.disabledAgentPlugins?.length)t.disabledAgentPlugins=e.disabledAgentPlugins;return t});function T(){return M.parse({})}var E;function se(e){if(e.disabledTools)Object.freeze(e.disabledTools);if(e.tools){for(let t of Object.values(e.tools))Object.freeze(t);Object.freeze(e.tools)}if(e.disabledPlugins)Object.freeze(e.disabledPlugins);if(e.disabledAgentPlugins)Object.freeze(e.disabledAgentPlugins);return Object.freeze(e)}function ae(e){let t;try{t=Z(e,"utf8")}catch{return{value:T(),loadFailed:!0}}try{let r=M.safeParse(JSON.parse(t));return r.success?{value:r.data,loadFailed:!1}:{value:T(),loadFailed:!0}}catch{return{value:T(),loadFailed:!0}}}function de(){let e=re(),t=ee(e,{throwIfNoEntry:!1}),r=t?.mtimeMs??0,i=t?.size??0,n=E;if(n&&n.path===e&&n.mtimeMs===r&&n.size===i)return n;let s=t?ae(e):{value:T(),loadFailed:!1},o=se(s.value);return E={path:e,mtimeMs:r,size:i,value:o,loadFailed:s.loadFailed},E}function le(){return de().value}function D(){return le().telemetryOptOut}class h{name;logger;enabled;constructor(e={}){this.name=e.name??"TelemetryLoggerSink",this.logger=e.logger,this.enabled=e.enabled??!0}emit(e,t){if(!this.isEnabled())return;this.logger?.log("telemetry.event",{telemetrySink:this.name,event:e,properties:t})}emitRequired(e,t){this.logger?.log("telemetry.required_event",{telemetrySink:this.name,severity:"warn",event:e,properties:t})}recordCounter(e,t,r,i,n){if(!n&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"counter",name:e,value:t,attributes:r,description:i,required:n===!0})}recordHistogram(e,t,r,i,n){if(!n&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"histogram",name:e,value:t,attributes:r,description:i,required:n===!0})}recordGauge(e,t,r,i,n){if(!n&&!this.isEnabled())return;this.logger?.debug("telemetry.metric",{telemetrySink:this.name,instrument:"gauge",name:e,value:t,attributes:r,description:i,required:n===!0})}isEnabled(){return typeof this.enabled==="function"?this.enabled():this.enabled}async flush(){}async dispose(){}}class S{adapters;metadata;distinctId;deviceId;commonProperties;constructor(e={}){if(this.adapters=[...e.adapters??[]],e.logger)this.adapters.push(new h({logger:e.logger}));this.metadata={...e.metadata??{}},this.distinctId=e.distinctId,this.deviceId=e.deviceId??v(),this.commonProperties={...e.commonProperties??{}}}addAdapter(e){this.adapters.push(e)}setDistinctId(e){this.distinctId=e}setMetadata(e){this.metadata={...e}}updateMetadata(e){this.metadata={...this.metadata,...e}}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}isEnabled(){return this.adapters.some((e)=>e.isEnabled())}capture(e){let t=this.buildAttributes(e.properties);for(let r of this.adapters)r.emit(e.event,t)}captureRequired(e,t){let r=this.buildAttributes(t);for(let i of this.adapters)i.emitRequired(e,r)}recordCounter(e,t,r,i,n=!1){let s=this.buildAttributes(r);for(let o of this.adapters)o.recordCounter(e,t,s,i,n)}recordHistogram(e,t,r,i,n=!1){let s=this.buildAttributes(r);for(let o of this.adapters)o.recordHistogram(e,t,s,i,n)}recordGauge(e,t,r,i,n=!1){let s=this.buildAttributes(r);for(let o of this.adapters)o.recordGauge(e,t,s,i,n)}async flush(){await Promise.all(this.adapters.map((e)=>e.flush()))}async dispose(){await Promise.all(this.adapters.map((e)=>e.dispose()))}buildAttributes(e){let t=typeof e?.distinct_id==="string"&&e.distinct_id.trim()?e.distinct_id.trim():this.distinctId,r={...this.commonProperties,...this.metadata,...e,...t?{distinct_id:t}:{},device_id:this.deviceId};return Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0))}}class k{distinctId;metadata;commonProperties;constructor(e={}){this.distinctId=e.distinctId,this.metadata={...e.metadata??{}},this.commonProperties={...e.commonProperties??{}}}setDistinctId(e){this.distinctId=e}setMetadata(e){this.metadata={...e}}updateMetadata(e){this.metadata={...this.metadata,...e}}setCommonProperties(e){this.commonProperties={...e}}updateCommonProperties(e){this.commonProperties={...this.commonProperties,...e}}isEnabled(){return!1}capture(e){this.resolveProperties(e.properties)}captureRequired(e,t){this.resolveProperties(t)}recordCounter(){}recordHistogram(){}recordGauge(){}async flush(){}async dispose(){}resolveProperties(e){let t=typeof e?.distinct_id==="string"&&e.distinct_id.trim()?e.distinct_id.trim():this.distinctId,r={...this.commonProperties,...this.metadata,...e,...t?{distinct_id:t}:{}};return Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0))}}class _{meterProvider;loggerProvider;tracerProvider;options;constructor(e={}){this.options=e;let t=Se({...e.resourceAttributes,[Ce]:e.serviceName??"cline",...e.serviceVersion?{[Re]:e.serviceVersion}:{}});if(this.meterProvider=this.createMeterProvider(t),this.loggerProvider=this.createLoggerProvider(t),this.tracerProvider=this.createTracerProvider(t),this.meterProvider)me.setGlobalMeterProvider(this.meterProvider);if(this.loggerProvider)ge.setGlobalLoggerProvider(this.loggerProvider);if(this.tracerProvider)this.tracerProvider.register()}getTracer(e="cline",t){return pe.getTracer(e,t??this.options.serviceVersion)}createAdapter(e){return new y({...e,meterProvider:this.meterProvider,loggerProvider:this.loggerProvider})}createTelemetryService(e){let t=this.createAdapter({name:e.name,enabled:this.options.enabled,metadata:e.metadata});return new S({...e,adapters:[t],distinctId:f(e.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(e){let t=P(this.options.metricsExporter);if(t.length===0)return null;let r=Math.max(1000,this.options.metricExportIntervalMs??this.options.metricExportInterval??60000),i=Math.min(30000,Math.floor(r*0.8)),n=t.map((s)=>Ne(s,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json",interval:r,timeout:i})).filter((s)=>s!==null);if(n.length===0)return null;return new Pe({resource:e,readers:n})}createTracerProvider(e){let t=P(this.options.tracesExporter);if(t.length===0)return null;let r=this.options.otlpTracesEndpoint??this.options.otlpEndpoint,i=this.options.otlpTracesHeaders??this.options.otlpHeaders,n=[],s=!1;for(let d of t){let a=De(d,{endpoint:r,headers:i,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(a){if(n.push(a),d!=="console")s=!0}}if(n.length===0)return null;let o=new Oe({resource:e,spanProcessors:s?[new ce,...n]:n});if(s)ue(o);return o}createLoggerProvider(e){let t=P(this.options.logsExporter);if(t.length===0)return null;let r=t.map((i)=>{let n=Me(i,{endpoint:this.options.otlpEndpoint,headers:this.options.otlpHeaders,insecure:this.options.otlpInsecure??!1,protocol:"http/json"});if(!n)return null;return new ve(n,{maxQueueSize:this.options.logMaxQueueSize??2048,maxExportBatchSize:this.options.logBatchSize??512,scheduledDelayMillis:this.options.logBatchTimeoutMs??this.options.logBatchTimeout??5000})}).filter((i)=>i!==null);if(r.length===0)return null;return new Ee({resource:e,processors:r})}}function L(e){let t=new _(e),r=t.createTelemetryService(e),i=()=>{r.captureRequired("telemetry.provider_created",{provider:"opentelemetry",enabled:e.enabled??!0,logsExporter:Array.isArray(e.logsExporter)?e.logsExporter.join(","):e.logsExporter,metricsExporter:Array.isArray(e.metricsExporter)?e.metricsExporter.join(","):e.metricsExporter,tracesExporter:Array.isArray(e.tracesExporter)?e.tracesExporter.join(","):e.tracesExporter,otlpProtocol:e.otlpProtocol,hasOtlpEndpoint:Boolean(e.otlpEndpoint),serviceName:e.serviceName,serviceVersion:e.serviceVersion})};if(!e.deferProviderCreatedEvent)i();return{provider:t,telemetry:r,emitProviderCreated:i}}function w(e){if(D())return{telemetry:new k(e)};if(e.enabled!==!0)return{telemetry:new S({...e,distinctId:f(e.distinctId)})};return L(e)}function xe(e){let{telemetry:t,provider:r,emitProviderCreated:i}=w(e);return{telemetry:t,provider:r,flush:async()=>{let o=r;if(o&&typeof o.forceFlush==="function")try{await o.forceFlush()}catch{}},dispose:async()=>{await Promise.allSettled([t.dispose(),r?.dispose()])},...e.deferProviderCreatedEvent&&i?{emitProviderCreated:i}:{}}}function P(e){if(!e)return[];return(Array.isArray(e)?e:e.split(",")).map((r)=>r.trim()).filter((r)=>r==="console"||r==="otlp")}function Me(e,t){if(e==="console")return new be;if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/logs");return new fe({url:r,headers:t.headers})}function De(e,t){if(e==="console")return new Ae(new Ie);if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/traces");return new _e(new Te({url:r,headers:t.headers}))}function Ne(e,t){if(e==="console")return new N({exporter:new he,exportIntervalMillis:t.interval,exportTimeoutMillis:t.timeout});if(!t.endpoint)return null;let r=I(t.endpoint,"/v1/metrics");return new N({exporter:new ye({url:r,headers:t.headers}),exportIntervalMillis:t.interval,exportTimeoutMillis:t.timeout})}function I(e,t){let r=new URL(e),i=r.pathname.endsWith("/")?r.pathname.slice(0,-1):r.pathname;return r.pathname=i.endsWith(t)?i:`${i}${t}`,r.toString()}import{SESSION_STATUS_VALUES as Dt}from"@cline/shared";var p={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 G(e){let t=[e?.name,e?.platform].filter((r)=>typeof r==="string").join(" ").toLowerCase();if(!t)return;if(t.includes("vscode")||t.includes("visual studio code"))return p.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 p.JETBRAINS;if(t.includes("neovim"))return p.NEOVIM;if(t.includes("kanban"))return p.KANBAN;if(t.includes("desktop"))return p.DESKTOP;if(t.includes("cline-platform"))return p.WEB;if(t.includes("cline-cli")||t.includes("cline-acp"))return p.CLI;if(t.includes("cline-sdk")||t.includes("cline-core"))return p.CORE;return}function u(e){let t=e?.trim();return t?t:void 0}function U(e){let t=e.client,r=G(t)??u(e.source),i=u(t.version),n=u(t.platform)??u(t.name),s=u(t.platformVersion)??i,o={cline_type:r,extension_version:i,platform:n,platform_version:s};if(e.user?.accountId===void 0)return o;let d=typeof e.user.accountId==="string"?u(e.user.accountId):void 0;return{...o,distinct_id:d??u(e.user.distinctId),user_id:d,account_id:d,account_email:d?u(e.user.email):void 0,organization_id:d?u(e.user.organizationId):void 0}}function K(e,t){let r={},i={},n,s=(o)=>({...t,...i,...r,...o,...n?{distinct_id:n}:{}});return{setDistinctId(o){n=u(o)},setMetadata(o){r={...o}},updateMetadata(o){r={...r,...o}},setCommonProperties(o){i={...o}},updateCommonProperties(o){i={...i,...o}},isEnabled:()=>e.isEnabled(),capture:(o)=>e.capture({event:o.event,properties:s(o.properties)}),captureRequired:(o,d)=>e.captureRequired(o,s(d)),recordCounter:(o,d,a,l,m)=>e.recordCounter(o,d,s(a),l,m),recordHistogram:(o,d,a,l,m)=>e.recordHistogram(o,d,s(a),l,m),recordGauge:(o,d,a,l,m)=>e.recordGauge(o,d,s(a),l,m),flush:()=>e.flush(),dispose:async()=>{}}}function ke(e,t){return K(e,U(t))}export{y as OpenTelemetryAdapter,_ as OpenTelemetryProvider,ke as createClientScopedTelemetryService,xe as createConfiguredTelemetryHandle,w as createConfiguredTelemetryService,L as createOpenTelemetryTelemetryService,K as createScopedTelemetryService,U as resolveClientTelemetryProperties,v as resolveCoreDeviceId,f as resolveCoreDistinctId};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AgentRuntimeEvent, ITelemetryService, TelemetryProperties } from "@cline/shared";
|
|
2
|
+
/** Silence (no runtime event, stream deltas included) before a run reports `task.run_idle`. */
|
|
3
|
+
export declare const RUN_IDLE_REPORT_MS = 60000;
|
|
4
|
+
/**
|
|
5
|
+
* Stall diagnostics for one agent run, derived only from its runtime events.
|
|
6
|
+
* `endProperties()` enriches the run's `agent.run-finished` /
|
|
7
|
+
* `agent.run-failed` telemetry; `task.run_idle` is sent while the run is
|
|
8
|
+
* still stuck.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RunHealthObserver {
|
|
11
|
+
private readonly telemetry;
|
|
12
|
+
private readonly context;
|
|
13
|
+
private lastEventAt;
|
|
14
|
+
private lastEventType;
|
|
15
|
+
private maxIdleMs;
|
|
16
|
+
private maxIdleAfter;
|
|
17
|
+
private idleReported;
|
|
18
|
+
private agentId;
|
|
19
|
+
private runId;
|
|
20
|
+
private finishReason?;
|
|
21
|
+
private turnStarted;
|
|
22
|
+
/** The current turn streamed something but has no assistant message yet. */
|
|
23
|
+
private turnHadOutput;
|
|
24
|
+
/** The current turn's assistant message, once the runtime accepts one. */
|
|
25
|
+
private turnMessage?;
|
|
26
|
+
private idleTimer?;
|
|
27
|
+
constructor(telemetry: ITelemetryService, context: {
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
isSubagent: boolean;
|
|
30
|
+
providerId?: string;
|
|
31
|
+
modelId?: string;
|
|
32
|
+
});
|
|
33
|
+
observe(event: AgentRuntimeEvent): void;
|
|
34
|
+
/** Read once when the run ends; stops the idle check. */
|
|
35
|
+
endProperties(): TelemetryProperties;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
private recordGap;
|
|
38
|
+
/** One pending timer per run, re-armed from the last event rather than per event. */
|
|
39
|
+
private scheduleIdleCheck;
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stall signals ported from the offline (Python) stall detector, so the harness
|
|
3
|
+
* can label runs live and send only the verdict, never the text.
|
|
4
|
+
*
|
|
5
|
+
* Python's `\w`/`\b` match letters in any script; JS's match ASCII only, even
|
|
6
|
+
* with the `u` flag, so spots that meet non-ASCII words use `\p{L}` instead.
|
|
7
|
+
*/
|
|
8
|
+
export type StallBumpKind = "probe" | "nudge" | "greeting" | "none";
|
|
9
|
+
export type StallTextSignature = "empty_turn" | "api_error" | "truncated_text" | "async_promise" | "intent_without_action" | "none";
|
|
10
|
+
export declare function classifyBumpText(prompt: string): StallBumpKind;
|
|
11
|
+
/** Signature of a run's final text-only assistant turn. */
|
|
12
|
+
export declare function classifyFinalTurnText(rawText: string): StallTextSignature;
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/session.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type ActiveSession = {
|
|
|
24
24
|
agent: SessionRuntime;
|
|
25
25
|
started: boolean;
|
|
26
26
|
aborting: boolean;
|
|
27
|
+
/** Epoch ms the last turn ended; labels the next input for stall analysis. */
|
|
28
|
+
lastTurnEndedAt?: number;
|
|
27
29
|
interactive: boolean;
|
|
28
30
|
persistedMessages?: LlmsProviders.MessageWithMetadata[];
|
|
29
31
|
compactionState?: SessionCompactionState;
|
|
@@ -33,7 +35,12 @@ export type ActiveSession = {
|
|
|
33
35
|
teamRunWaiters: Array<() => void>;
|
|
34
36
|
pendingPrompts: PendingPrompt[];
|
|
35
37
|
drainingPendingPrompts: boolean;
|
|
38
|
+
/** Set by the queue drain on the one input it replays; consumed by runTurn. */
|
|
39
|
+
replayingQueuedPrompt?: boolean;
|
|
36
40
|
pluginSandboxShutdown?: () => Promise<void>;
|
|
41
|
+
pluginCommandError?: string;
|
|
42
|
+
pluginCommandTail?: Promise<unknown>;
|
|
43
|
+
pluginCommandsClosing?: boolean;
|
|
37
44
|
turnUsageBaseline?: SessionAccumulatedUsage;
|
|
38
45
|
turnAggregateUsageBaseline?: SessionAccumulatedUsage;
|
|
39
46
|
turnPrimaryUsage?: SessionAccumulatedUsage;
|
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
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/cline/cline",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"test:watch": "vitest --config vitest.config.ts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@cline/agents": "0.0
|
|
57
|
-
"@cline/shared": "0.0
|
|
58
|
-
"@cline/llms": "0.0
|
|
56
|
+
"@cline/agents": "0.2.0",
|
|
57
|
+
"@cline/shared": "0.2.0",
|
|
58
|
+
"@cline/llms": "0.2.0",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
60
60
|
"@opentelemetry/api": "^1.9.0",
|
|
61
61
|
"@opentelemetry/api-logs": "^0.214.0",
|
|
@@ -90,7 +90,8 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/proxy-from-env": "^1.0.4",
|
|
92
92
|
"@types/ws": "^8.18.1",
|
|
93
|
-
"posthog-node": "^5.8.0"
|
|
93
|
+
"posthog-node": "^5.8.0",
|
|
94
|
+
"skills": "1.7.2"
|
|
94
95
|
},
|
|
95
96
|
"engines": {
|
|
96
97
|
"node": ">=22"
|