@cline/shared 0.0.39 → 0.0.40-nightly.1778642379
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/agent.d.ts +2 -11
- package/dist/agents/types.d.ts +2 -0
- package/dist/index.browser.d.ts +6 -4
- package/dist/index.browser.js +15 -15
- package/dist/index.d.ts +4 -2
- package/dist/index.js +31 -31
- package/dist/llms/ai-sdk-format.d.ts +13 -0
- package/dist/llms/gateway.d.ts +30 -2
- package/dist/llms/model-info.d.ts +1 -0
- package/dist/llms/tokens.d.ts +7 -0
- package/dist/rpc/runtime.d.ts +2 -0
- package/dist/services/telemetry.d.ts +16 -0
- package/dist/storage/index.js +1 -1
- package/dist/vcr.d.ts +3 -3
- package/package.json +3 -4
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes unpaired/lone Unicode surrogates in text content.
|
|
3
|
+
*
|
|
4
|
+
* Lone surrogates (high surrogates without matching low surrogates, or vice versa)
|
|
5
|
+
* can cause JSON serialization issues and downstream processing errors when sending
|
|
6
|
+
* text to LLM providers. This function replaces them with the Unicode replacement
|
|
7
|
+
* character (U+FFFD).
|
|
8
|
+
*
|
|
9
|
+
* @param content - The string to sanitize
|
|
10
|
+
* @returns The string with lone surrogates replaced by U+FFFD
|
|
11
|
+
*/
|
|
12
|
+
export declare function sanitizeSurrogates(content: string): string;
|
|
1
13
|
export type AiSdkFormatterMessageRole = "user" | "assistant" | "tool";
|
|
2
14
|
export type AiSdkFormatterPart = {
|
|
3
15
|
type: "text";
|
|
4
16
|
text: string;
|
|
17
|
+
providerOptions?: Record<string, Record<string, unknown>>;
|
|
5
18
|
} | {
|
|
6
19
|
type: "reasoning";
|
|
7
20
|
text: string;
|
package/dist/llms/gateway.d.ts
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
import type { AgentMessage, AgentModelEvent, AgentToolDefinition } from "../agent";
|
|
2
2
|
import type { BasicLogger } from "../logging/logger";
|
|
3
3
|
import type { ProviderCapability } from "../rpc/runtime";
|
|
4
|
+
import type { ITelemetryService } from "../services/telemetry";
|
|
4
5
|
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
5
6
|
[key: string]: JsonValue | undefined;
|
|
6
7
|
};
|
|
7
|
-
export type GatewayModelCapability = "text" | "tools" | "reasoning" | "images" | "audio" | "structured-output";
|
|
8
|
+
export type GatewayModelCapability = "text" | "tools" | "reasoning" | "prompt-cache" | "images" | "audio" | "structured-output";
|
|
8
9
|
export type GatewayPromptCacheStrategy = "anthropic-automatic";
|
|
9
10
|
export type GatewayUsageCostDisplay = "show" | "hide";
|
|
11
|
+
export type GatewayPromptCacheFormat = "anthropic-cache-control";
|
|
12
|
+
export type GatewayReasoningFormat = "anthropic-thinking";
|
|
13
|
+
export type GatewayModelRoute = {
|
|
14
|
+
matcher: "anthropic-compatible";
|
|
15
|
+
} | {
|
|
16
|
+
matcher: "model-family";
|
|
17
|
+
family: string;
|
|
18
|
+
requiredCapability?: GatewayModelCapability;
|
|
19
|
+
} | {
|
|
20
|
+
matcher: "model-id";
|
|
21
|
+
modelId: string;
|
|
22
|
+
requiredCapability?: GatewayModelCapability;
|
|
23
|
+
};
|
|
24
|
+
export interface GatewayProviderRouting {
|
|
25
|
+
promptCache?: {
|
|
26
|
+
format: GatewayPromptCacheFormat;
|
|
27
|
+
routes: GatewayModelRoute[];
|
|
28
|
+
};
|
|
29
|
+
reasoning?: {
|
|
30
|
+
format: GatewayReasoningFormat;
|
|
31
|
+
routes: GatewayModelRoute[];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
10
34
|
export interface GatewayProviderMetadata {
|
|
11
35
|
promptCacheStrategy?: GatewayPromptCacheStrategy;
|
|
12
36
|
usageCostDisplay?: GatewayUsageCostDisplay;
|
|
13
|
-
|
|
37
|
+
routing?: GatewayProviderRouting;
|
|
38
|
+
[key: string]: JsonValue | GatewayProviderRouting | undefined;
|
|
14
39
|
}
|
|
15
40
|
export interface GatewayModelDefinition {
|
|
16
41
|
id: string;
|
|
@@ -18,6 +43,7 @@ export interface GatewayModelDefinition {
|
|
|
18
43
|
providerId: string;
|
|
19
44
|
description?: string;
|
|
20
45
|
contextWindow?: number;
|
|
46
|
+
maxInputTokens?: number;
|
|
21
47
|
maxOutputTokens?: number;
|
|
22
48
|
capabilities?: readonly GatewayModelCapability[];
|
|
23
49
|
metadata?: Record<string, JsonValue | undefined>;
|
|
@@ -69,6 +95,7 @@ export interface GatewayProviderContext {
|
|
|
69
95
|
config: GatewayResolvedProviderConfig;
|
|
70
96
|
signal?: AbortSignal;
|
|
71
97
|
logger?: BasicLogger;
|
|
98
|
+
telemetry?: ITelemetryService;
|
|
72
99
|
}
|
|
73
100
|
export interface GatewayStreamRequest {
|
|
74
101
|
providerId: string;
|
|
@@ -114,4 +141,5 @@ export interface GatewayConfig {
|
|
|
114
141
|
providerConfigs?: readonly GatewayProviderConfig[];
|
|
115
142
|
fetch?: typeof fetch;
|
|
116
143
|
logger?: BasicLogger;
|
|
144
|
+
telemetry?: ITelemetryService;
|
|
117
145
|
}
|
|
@@ -60,6 +60,7 @@ export declare const ModelInfoSchema: z.ZodObject<{
|
|
|
60
60
|
description: z.ZodOptional<z.ZodString>;
|
|
61
61
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
62
62
|
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
maxInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
63
64
|
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
64
65
|
images: "images";
|
|
65
66
|
tools: "tools";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conservative chars-per-token approximation used for compaction triggering
|
|
3
|
+
* and request-size diagnostics. Uses 3 chars/token (slightly over-counts vs
|
|
4
|
+
* the conventional 4) so trigger thresholds fire before provider rejection
|
|
5
|
+
* rather than after.
|
|
6
|
+
*/
|
|
7
|
+
export declare function estimateTokens(chars: number): number;
|
package/dist/rpc/runtime.d.ts
CHANGED
|
@@ -139,6 +139,7 @@ export interface ProviderListItem {
|
|
|
139
139
|
defaultModelId?: string;
|
|
140
140
|
protocol?: ProviderProtocol;
|
|
141
141
|
client?: ProviderClient;
|
|
142
|
+
capabilities?: ProviderCapability[];
|
|
142
143
|
authDescription: string;
|
|
143
144
|
baseUrlDescription: string;
|
|
144
145
|
modelList?: ProviderModel[];
|
|
@@ -165,6 +166,7 @@ export declare const ProviderCapabilitySchema: z.ZodEnum<{
|
|
|
165
166
|
oauth: "oauth";
|
|
166
167
|
vision: "vision";
|
|
167
168
|
"local-auth": "local-auth";
|
|
169
|
+
popular: "popular";
|
|
168
170
|
}>;
|
|
169
171
|
export type ProviderCapability = z.infer<typeof ProviderCapabilitySchema>;
|
|
170
172
|
export declare const ProviderProtocolSchema: z.ZodEnum<{
|
|
@@ -5,6 +5,18 @@ export type TelemetryObject = {
|
|
|
5
5
|
};
|
|
6
6
|
export type TelemetryArray = Array<TelemetryValue>;
|
|
7
7
|
export type TelemetryProperties = TelemetryObject;
|
|
8
|
+
export type SdkTelemetryErrorComponent = "shared" | "llms" | "agents" | "core" | "cli" | "vscode" | "desktop" | (string & {});
|
|
9
|
+
export type SdkTelemetryErrorSeverity = "debug" | "info" | "warn" | "error" | "fatal";
|
|
10
|
+
export interface CaptureSdkErrorInput {
|
|
11
|
+
component: SdkTelemetryErrorComponent;
|
|
12
|
+
operation: string;
|
|
13
|
+
error: unknown;
|
|
14
|
+
severity?: SdkTelemetryErrorSeverity;
|
|
15
|
+
handled?: boolean;
|
|
16
|
+
context?: TelemetryProperties;
|
|
17
|
+
event?: string;
|
|
18
|
+
messageLimit?: number;
|
|
19
|
+
}
|
|
8
20
|
export interface TelemetryMetadata {
|
|
9
21
|
extension_version: string;
|
|
10
22
|
cline_type: string;
|
|
@@ -33,6 +45,10 @@ export interface ITelemetryService {
|
|
|
33
45
|
flush(): Promise<void>;
|
|
34
46
|
dispose(): Promise<void>;
|
|
35
47
|
}
|
|
48
|
+
export declare const SDK_ERROR_TELEMETRY_EVENT = "sdk.error";
|
|
49
|
+
export declare function captureSdkError(telemetry: ITelemetryService | undefined, input: CaptureSdkErrorInput): void;
|
|
50
|
+
export declare function buildSdkErrorProperties(input: CaptureSdkErrorInput): TelemetryProperties;
|
|
51
|
+
export declare function normalizeSdkError(error: unknown, messageLimit?: number): TelemetryProperties;
|
|
36
52
|
export interface OpenTelemetryClientConfig {
|
|
37
53
|
/**
|
|
38
54
|
* Whether telemetry is enabled via OTEL_TELEMETRY_ENABLED
|
package/dist/storage/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Object.defineProperty;var e=(C)=>C;function a(C,S){this[C]=e.bind(null,S)}var $C=(C,S)=>{for(var M in S)i(C,M,{get:S[M],enumerable:!0,configurable:!0,set:a.bind(S,M)})};import{appendFileSync as t,existsSync as F,mkdirSync as
|
|
1
|
+
var i=Object.defineProperty;var e=(C)=>C;function a(C,S){this[C]=e.bind(null,S)}var $C=(C,S)=>{for(var M in S)i(C,M,{get:S[M],enumerable:!0,configurable:!0,set:a.bind(S,M)})};import{appendFileSync as t,existsSync as F,mkdirSync as Z,readdirSync as CC,readFileSync as SC,statSync as I}from"node:fs";import{homedir as OC}from"node:os";import{dirname as $,join as O,resolve as R}from"node:path";var U=".clinerules",Q=".cline",J=".agents",X="agents",z="hooks",E="skills",V="rules",B="workflows",H="plugins",x="cline_mcp_settings.json";function MC(){let C=process?.env?.HOME?.trim();if(C&&C!=="~")return C;let S=process?.env?.USERPROFILE?.trim();if(S)return S;let M=process?.env?.HOMEDRIVE?.trim(),D=process?.env?.HOMEPATH?.trim();if(M&&D)return`${M}${D}`;let N=OC().trim();if(N&&N!=="~")return N;return"~"}var j=MC(),u=!1;function NC(C){let S=C.trim();if(!S)return;j=S,u=!0}function GC(C){if(u)return;let S=C.trim();if(!S)return;j=S}var L,y=!1;function DC(C){let S=C.trim();if(!S)return;L=S,y=!0}function FC(C){if(y)return;let S=C.trim();if(!S)return;L=S}function W(){if(L)return L;let C=process.env.CLINE_DIR?.trim();if(C)return C;return O(j,".cline")}function m(){return O(j,"Documents","Cline")}function q(C){return O(m(),C)}function g(){let C=process.env.CLINE_DATA_DIR?.trim();if(C)return C;return O(W(),"data")}function WC(){let C=process.env.CLINE_SESSION_DATA_DIR?.trim();if(C)return C;return O(g(),"sessions")}function _C(){let C=process.env.CLINE_TEAM_DATA_DIR?.trim();if(C)return C;return O(g(),"teams")}function w(){let C=process.env.CLINE_DB_DATA_DIR?.trim();if(C)return C;return O(g(),"db")}function gC(){let C=process.env.CLINE_CRON_DB_PATH?.trim();if(C)return C;return O(w(),"cron.db")}function s(){return O(W(),"cron")}function Y(C){return O(C,".cline","cron")}function b(C){if(typeof C==="string")return Y(C);if(C?.cronSpecsDir?.trim())return C.cronSpecsDir.trim();if(C?.scope==="workspace"){let S=C.workspaceRoot?.trim();if(!S)throw Error("workspaceRoot is required for workspace cron scope");return Y(S)}return s()}function vC(C){return O(b(C),"reports")}function AC(C){return O(b(C),"events")}function KC(){let C=process.env.CLINE_PROVIDER_SETTINGS_PATH?.trim();if(C)return C;return O(g(),"settings","providers.json")}function IC(){let C=process.env.CLINE_GLOBAL_SETTINGS_PATH?.trim();if(C)return C;return O(g(),"settings","global-settings.json")}function RC(){let C=process.env.CLINE_MCP_SETTINGS_PATH?.trim();if(C)return C;return O(g(),"settings",x)}function v(C){let S=new Set,M=[];for(let D of C){if(!D||S.has(D))continue;S.add(D),M.push(D)}return M}function TC(C){if(!C)return[];return[U,Q,J].map((S)=>O(C,S,E))}function k(){return O(W(),X)}function jC(C){return v([C?O(C,Q,X):"",k()])}function qC(C){let S=[q("Hooks"),O(W(),z)];if(C)S.push(O(C,U,z),O(C,Q,z));return v(S)}function zC(C){return v([...TC(C),O(W(),E),O(j,J,E)])}function BC(C){let S=C?[O(C,U),O(C,Q,V)]:[],M=C?[O(C,"AGENTS.md")]:[];return v([...M,...S,O(W(),V),q("Rules")])}function EC(C){return v([C?O(C,".clinerules",B):"",q("Workflows"),O(W(),B),C?O(C,".cline",B):""])}function LC(C){return v([C?O(C,".cline",H):"",O(W(),H),q("Plugins")])}var o=new Set([".js",".ts"]),d="package.json",QC=["index.ts","index.js"];function T(C){let S=C.lastIndexOf(".");if(S===-1)return!1;return o.has(C.slice(S))}function n(C){try{let S=JSON.parse(SC(C,"utf8"));if(!S.cline||typeof S.cline!=="object")return null;return S.cline}catch{return null}}function c(C){let S=C?.plugins;if(!Array.isArray(S))return[];return S.flatMap((M)=>M.paths??[])}function r(C){let S=R(C);if(!F(S)||!I(S).isDirectory())return null;let M=O(S,d);if(F(M)){let D=n(M),N=c(D).map((G)=>R(S,G)).filter((G)=>F(G)&&I(G).isFile()&&T(G));if(N.length>0)return N}for(let D of QC){let N=O(S,D);if(F(N)&&I(N).isFile())return[N]}return null}function p(C){let S=R(C);if(!F(S))return[];let M=[],D=[S];while(D.length>0){let N=D.pop();if(!N)continue;let G;try{G=CC(N,{withFileTypes:!0})}catch{continue}for(let A of G){let _=O(N,A.name);if(A.isDirectory()){let l=O(_,d);if(F(l)){let h=n(l),f=c(h).map((K)=>R(_,K)).filter((K)=>F(K)&&I(K).isFile()&&T(K));if(f.length>0){M.push(...f);continue}}D.push(_);continue}if(A.name.startsWith("."))continue;if(A.isFile()&&T(_))M.push(_)}}return M.sort((N,G)=>N.localeCompare(G))}function VC(C,S){let M=[];for(let D of C){let N=D.trim();if(!N)continue;let G=R(S,N);if(!F(G))throw Error(`Plugin path does not exist: ${G}`);if(I(G).isDirectory()){let _=r(G);if(_){M.push(..._);continue}M.push(...p(G));continue}if(!T(G))throw Error(`Plugin file must use a supported extension (${[...o].join(", ")}): ${G}`);M.push(G)}return M}function P(C){let S=$(C);if(!F(S))Z(S,{recursive:!0})}function YC(C){Z($(C),{recursive:!0}),t(C,"")}function ZC(C){if(C?.trim())return P(C),$(C);let S=O(g(),"logs");if(!F(S))Z(S,{recursive:!0});return S}export{GC as setHomeDirIfUnset,NC as setHomeDir,FC as setClineDirIfUnset,DC as setClineDir,Y as resolveWorkspaceCronSpecsDir,EC as resolveWorkflowsConfigSearchPaths,_C as resolveTeamDataDir,zC as resolveSkillsConfigSearchPaths,WC as resolveSessionDataDir,BC as resolveRulesConfigSearchPaths,KC as resolveProviderSettingsPath,r as resolvePluginModuleEntries,LC as resolvePluginConfigSearchPaths,RC as resolveMcpSettingsPath,qC as resolveHooksConfigSearchPaths,IC as resolveGlobalSettingsPath,s as resolveGlobalCronSpecsDir,q as resolveDocumentsExtensionPath,m as resolveDocumentsClineDirectoryPath,w as resolveDbDataDir,b as resolveCronSpecsDir,vC as resolveCronReportsDir,AC as resolveCronEventsDir,gC as resolveCronDbPath,VC as resolveConfiguredPluginModulePaths,W as resolveClineDir,g as resolveClineDataDir,k as resolveAgentsConfigDirPath,jC as resolveAgentConfigSearchPaths,T as isPluginModulePath,P as ensureParentDir,ZC as ensureHookLogDir,YC as ensureFileExists,p as discoverPluginModulePaths,B as WORKFLOWS_CONFIG_DIRECTORY_NAME,E as SKILLS_CONFIG_DIRECTORY_NAME,V as RULES_CONFIG_DIRECTORY_NAME,z as HOOKS_CONFIG_DIRECTORY_NAME,x as CLINE_MCP_SETTINGS_FILE_NAME,X as AGENT_CONFIG_DIRECTORY_NAME};
|
package/dist/vcr.d.ts
CHANGED
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
*
|
|
23
23
|
* Usage:
|
|
24
24
|
* # Record only inference requests
|
|
25
|
-
* CLINE_VCR=record CLINE_VCR_CASSETTE=./fixtures/my-test.json
|
|
25
|
+
* CLINE_VCR=record CLINE_VCR_CASSETTE=./fixtures/my-test.json cline task "hello"
|
|
26
26
|
*
|
|
27
27
|
* # Replay — auth/S3/etc. requests go through normally, only inference is mocked
|
|
28
|
-
* CLINE_VCR=playback CLINE_VCR_CASSETTE=./fixtures/my-test.json
|
|
28
|
+
* CLINE_VCR=playback CLINE_VCR_CASSETTE=./fixtures/my-test.json cline task "hello"
|
|
29
29
|
*
|
|
30
30
|
* # Record everything (no filter)
|
|
31
|
-
* CLINE_VCR=record CLINE_VCR_FILTER="" CLINE_VCR_CASSETTE=./fixtures/all.json
|
|
31
|
+
* CLINE_VCR=record CLINE_VCR_FILTER="" CLINE_VCR_CASSETTE=./fixtures/all.json cline task "hello"
|
|
32
32
|
*/
|
|
33
33
|
/**
|
|
34
34
|
* Initialize VCR mode based on environment variables.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cline/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40-nightly.1778642379",
|
|
4
4
|
"description": "Shared utilities, types, and schemas for Cline packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/cline/
|
|
8
|
-
"directory": "packages/shared"
|
|
7
|
+
"url": "https://github.com/cline/cline",
|
|
8
|
+
"directory": "sdk/packages/shared"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "dist/index.js",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "BUILD_MODE=package bun bun.mts",
|
|
50
|
-
"clean": "rm -rf dist node_modules",
|
|
51
50
|
"typecheck": "bun tsc --noEmit",
|
|
52
51
|
"test": "bun run test:unit",
|
|
53
52
|
"test:unit": "vitest run --config vitest.config.ts"
|