@cline/core 0.0.47 → 0.0.48-nightly.1781666345
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/cline-core/types.d.ts +4 -4
- package/dist/extensions/mcp/index.d.ts +2 -0
- package/dist/extensions/mcp/plugin-server-registration.d.ts +18 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -1
- package/dist/extensions/tools/executors/bash.d.ts +16 -2
- package/dist/extensions/tools/executors/output-limits.d.ts +25 -0
- package/dist/hub/daemon/entry.js +199 -189
- package/dist/hub/index.js +197 -187
- package/dist/index.d.ts +5 -2
- package/dist/index.js +199 -189
- package/dist/runtime/host/local-runtime-host.d.ts +1 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +0 -1
- package/dist/services/feature-flags/FeatureFlagsService.d.ts +20 -1
- package/dist/services/feature-flags/posthog.d.ts +24 -0
- package/dist/services/feature-flags/posthog.js +1 -0
- package/dist/services/llms/cline-recommended-models.d.ts +1 -0
- package/dist/services/plugin-mcp-settings.d.ts +31 -0
- package/dist/services/providers/local-provider-service.d.ts +4 -1
- package/dist/services/storage/provider-settings-manager.d.ts +7 -2
- package/dist/services/telemetry/index.d.ts +1 -0
- package/dist/services/telemetry/index.js +1 -1
- package/dist/session/services/message-builder.d.ts +9 -2
- package/package.json +18 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@cline/llms";
|
|
2
|
-
import type { AgentConfig, AutomationEventEnvelope, BasicLogger,
|
|
2
|
+
import type { AgentConfig, AutomationEventEnvelope, BasicLogger, ITelemetryService } from "@cline/shared";
|
|
3
3
|
import type { CronEventSuppression } from "../cron/events/cron-event-ingress";
|
|
4
4
|
import type { CronEventLogRecord, CronRunRecord, CronSpecRecord } from "../cron/store/sqlite-cron-store";
|
|
5
5
|
import type { CheckpointEntry } from "../hooks/checkpoint-hooks";
|
|
@@ -7,6 +7,7 @@ import type { RuntimeCapabilities } from "../runtime/capabilities";
|
|
|
7
7
|
import type { SessionHistoryListOptions } from "../runtime/host/history";
|
|
8
8
|
import type { SessionBackend } from "../runtime/host/host";
|
|
9
9
|
import type { LocalRuntimeStartOptions, RuntimeHostMode, StartSessionInput, StartSessionResult } from "../runtime/host/runtime-host";
|
|
10
|
+
import type { FeatureFlagsService } from "../services/feature-flags";
|
|
10
11
|
import type { CoreSessionConfig } from "../types/config";
|
|
11
12
|
import type { SessionMessagesArtifactUploader } from "../types/session";
|
|
12
13
|
export type { RuntimeHostMode } from "../runtime/host/runtime-host";
|
|
@@ -161,11 +162,10 @@ export interface ClineCoreOptions {
|
|
|
161
162
|
*/
|
|
162
163
|
telemetry?: ITelemetryService;
|
|
163
164
|
/**
|
|
164
|
-
* Feature flags
|
|
165
|
-
* in a cached FeatureFlagsService and exposes it as `cline.featureFlags`.
|
|
165
|
+
* Feature flags service for this ClineCore instance.
|
|
166
166
|
* If omitted, Core uses a no-op provider with default flag values.
|
|
167
167
|
*/
|
|
168
|
-
featureFlags?:
|
|
168
|
+
featureFlags?: FeatureFlagsService;
|
|
169
169
|
/**
|
|
170
170
|
* Optional structured logger for core-side operational diagnostics such as
|
|
171
171
|
* runtime-host selection and fallback decisions.
|
|
@@ -5,6 +5,8 @@ export { getMcpServerOAuthState, hasMcpSettingsFile, listMcpServerOAuthStatuses,
|
|
|
5
5
|
export { InMemoryMcpManager } from "./manager";
|
|
6
6
|
export type { AuthorizeMcpServerOAuthOptions, AuthorizeMcpServerOAuthResult, CreateMcpOAuthProviderContextOptions, McpOAuthProviderContext, } from "./oauth";
|
|
7
7
|
export { authorizeMcpServerOAuth } from "./oauth";
|
|
8
|
+
export type { PluginMcpServerResolution } from "./plugin-server-registration";
|
|
9
|
+
export { normalizePluginMcpServerRegistration, resolvePluginMcpServerRegistrations, } from "./plugin-server-registration";
|
|
8
10
|
export type { CreateDisabledMcpToolPoliciesOptions, CreateDisabledMcpToolPolicyOptions, } from "./policies";
|
|
9
11
|
export { createDisabledMcpToolPolicies, createDisabledMcpToolPolicy, } from "./policies";
|
|
10
12
|
export { createMcpTools } from "./tools";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentExtensionMcpServer } from "@cline/shared";
|
|
2
|
+
import type { McpServerRegistration } from "./types";
|
|
3
|
+
export interface PluginMcpServerResolution<TOwner> {
|
|
4
|
+
owner: TOwner;
|
|
5
|
+
name: string;
|
|
6
|
+
registration?: McpServerRegistration;
|
|
7
|
+
loadError?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function normalizePluginMcpServerRegistration(server: AgentExtensionMcpServer): {
|
|
10
|
+
name: string;
|
|
11
|
+
registration?: McpServerRegistration;
|
|
12
|
+
loadError?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function resolvePluginMcpServerRegistrations<TOwner>(servers: readonly {
|
|
15
|
+
server: AgentExtensionMcpServer;
|
|
16
|
+
owner: TOwner;
|
|
17
|
+
ownerLabel?: string;
|
|
18
|
+
}[]): PluginMcpServerResolution<TOwner>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as GG}from"node:module";var QG=GG(import.meta.url);import{normalizePluginManifest as IG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as UG,createRequire as y}from"node:module";import{dirname as M,extname as I,isAbsolute as XG,resolve as K}from"node:path";import{fileURLToPath as P}from"node:url";import{PLUGIN_FILE_EXTENSIONS as YG}from"@cline/shared";var m=M(P(import.meta.url)),ZG=y(import.meta.url),$G=K(m,"..","..","..","..",".."),S=WG($G),qG=["@cline/sdk","@cline/agents","@cline/core","@cline/core/hub","@cline/core/hub/daemon-entry","@cline/core/telemetry","@cline/llms","@cline/llms/browser","@cline/shared","@cline/shared/automation","@cline/shared/browser","@cline/shared/storage","@cline/shared/db","@cline/shared/types"],b=new Set(UG.flatMap((G)=>[G,G.replace(/^node:/,"")])),j=new Set(YG),KG=["development","node","import","require","default"];function WG(G){let Q={},U={"@cline/sdk":K(G,"packages/sdk/src/index.ts"),"@cline/agents":K(G,"packages/agents/src/index.ts"),"@cline/core":K(G,"packages/core/src/index.ts"),"@cline/llms":K(G,"packages/llms/src/index.ts"),"@cline/shared":K(G,"packages/shared/src/index.ts"),"@cline/shared/storage":K(G,"packages/shared/src/storage/index.ts"),"@cline/shared/db":K(G,"packages/shared/src/db/index.ts")};for(let[Y,Z]of Object.entries(U))if(_(Z))Q[Y]=Z;for(let Y of["agents","core","llms","shared"]){let Z=K(G,"packages",Y),$=K(Z,"package.json");if(!_($))continue;try{let X=JSON.parse(C($,"utf8"));if(typeof X.name!=="string"||!X.exports)continue;if(typeof X.exports==="string"){let q=K(Z,X.exports);if(_(q))Q[X.name]=q;continue}if(typeof X.exports!=="object")continue;for(let[q,w]of Object.entries(X.exports)){let A=_G(Z,w);if(!A)continue;let L=q==="."?X.name:`${X.name}/${q.replace(/^\.\//,"")}`;Q[L]=A}}catch{}}return Q}function _G(G,Q){let U=R(Q);if(!U)return null;let Y=h(G,U);for(let Z of Y)if(_(Z))return Z;return null}function R(G,Q=new Set){if(typeof G==="string")return G;if(!G||typeof G!=="object")return null;if(Q.has(G))return null;Q.add(G);let U=G;for(let Y of KG){let Z=R(U[Y],Q);if(Z)return Z}return null}function h(G,Q){let U=Q.replace(/^\.\//,""),Y=[K(G,Q)];if(U.startsWith("dist/")){let Z=U.replace(/^dist\//,"src/").replace(/\.(mjs|cjs|js)$/,"");return[K(G,`${Z}.ts`),K(G,`${Z}.tsx`),K(G,`${Z}.mts`),K(G,`${Z}.cts`),...Y]}return Y}function LG(G){return Object.fromEntries(Object.entries(G).sort(([Q],[U])=>U.length-Q.length))}function H(G){return!(G.startsWith(".")||G.startsWith("/")||G.startsWith("file:")||G.startsWith("data:")||G.startsWith("http:")||G.startsWith("https:"))}function J(G){if(G.startsWith("@")){let[Q,U]=G.split("/",3);return U?`${Q}/${U}`:G}return G.split("/",1)[0]??G}function wG(G){let Q=J(G);if(G===Q)return".";return`.${G.slice(Q.length)}`}function d(G){return J(G).startsWith("@cline/")}function V(G,Q){let U=J(Q),Y=M(G);while(!0){let Z=K(Y,"node_modules",U);if(_(Z)||_(K(Z,"package.json")))return!0;let $=K(Y,"..");if($===Y)return!1;Y=$}}function f(G){return T(G)!==null}function T(G){try{return ZG.resolve(G)}catch{}return AG(G)}function AG(G){let Q=J(G),U=u(Q);if(!U)return null;let Y=K(U,"package.json");try{let Z=JSON.parse(C(Y,"utf8")),$=wG(G),X=$==="."&&typeof Z.exports==="string"?Z.exports:Z.exports&&typeof Z.exports==="object"&&Object.hasOwn(Z.exports,$)?Z.exports[$]:void 0,q=R(X)??($==="."&&typeof Z.main==="string"?Z.main:null);if(!q)return null;let w=K(U,q),A=[w,...h(U,q).filter((L)=>L!==w)];for(let L of A)if(_(L))return L;return null}catch{return null}}function zG(){let G=[m],Q=process.env.CLINE_WRAPPER_PATH?.trim();if(Q)G.push(M(M(Q)));let U=process.execPath?.trim();if(U)G.push(M(U));return[...new Set(G.map((Y)=>K(Y)))]}function MG(G,Q){let U=G;while(!0){let Y=K(U,"package.json");if(_(Y))try{if(JSON.parse(C(Y,"utf8")).name===Q)return U}catch{}let Z=K(U,"node_modules",Q,"package.json");if(_(Z))return M(Z);let $=K(U,"..");if($===U)return null;U=$}}function u(G){for(let Q of zG()){let U=MG(Q,G);if(U)return U}return null}function FG(G){let U=M(G);for(let Y=0;Y<4;Y++){let Z=K(U,"package.json");if(_(Z))try{let X=JSON.parse(C(Z,"utf8"));return X!=null&&typeof X==="object"&&"cline"in X}catch{return!1}let $=K(U,"..");if($===U)return!1;U=$}return!1}function c(G,Q){let U=Q.startsWith("file:")?P(Q):XG(Q)?Q:K(M(G),Q);if(_(U)&&j.has(I(U)))return U;for(let Y of j){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of j){let Z=K(U,`index${Y}`);if(_(Z))return Z}return null}function l(G){let Q=new Set,U=[/\bimport\s+(?:type\s+)?[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bexport\s+[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bimport\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g,/\brequire\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g];for(let Y of U)for(let Z of G.matchAll(Y)){let $=Z[1];if($)Q.add($)}return[...Q]}function JG(G){return I(G)!==".ts"}function g(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!j.has(I(G)))return;let Y=C(G,"utf8"),Z=JG(G);for(let $ of l(Y)){if($.startsWith("node:")||b.has($))continue;if(H($)){if(!Z)continue;if(Object.hasOwn(S,$)||Object.hasOwn(S,J($))||V(G,$)||d($)&&f($)||Q&&f($))continue;throw Error(`Cannot find module '${J($)}'`)}let X=c(G,$);if(X)g(X,Q,U)}}function n(G,Q=new Set,U=new Set){if(Q.has(G)||!_(G))return U;if(Q.add(G),!j.has(I(G)))return U;let Y=C(G,"utf8");for(let Z of l(Y)){if(U.add(Z),H(Z))continue;let $=c(G,Z);if($)n($,Q,U)}return U}function CG(G,Q){let U=y(G),Y={},Z=n(G),$=new Set(qG);for(let[X,q]of Object.entries(S)){try{U.resolve(X);continue}catch{}Y[X]=q}for(let X of Z)if(H(X)&&(d(X)||Q))$.add(X);for(let X of $){if(Object.hasOwn(Y,X)||V(G,X))continue;let q=T(X);if(q)Y[X]=q}if(!Q)return Y;for(let X of Z){if(!H(X)||Object.hasOwn(Y,X)||V(G,X)||X.startsWith("node:")||b.has(X))continue;let q=T(X);if(q)Y[X]=q}return Y}function OG(G){let Q=I(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var F;function jG(){if(F!==void 0)return F;let G=u("jiti");if(!G)return F=null,null;let Q=K(G,"dist","babel.cjs");if(!_(Q))return F=null,null;try{let Y=y(Q)(Q);F=typeof Y==="function"?Y:null}catch{F=null}return F}async function o(G,Q={}){let U=!FG(G);g(G,U);let Y=CG(G,U),Z=LG(Y),$=await import("jiti"),X=typeof $==="function"?$:typeof $.default==="function"?$.default:void 0;if(!X)throw Error("Unable to load jiti");let q=Object.entries(Z).filter(([,W])=>OG(W)).map(([W])=>W),w=jG(),A=w?(W)=>w({...W,interopDefault:!0}):void 0;return await X(G,{alias:Z,cache:Q.useCache,requireCache:Q.useCache,esmResolve:!0,interopDefault:!1,nativeModules:[...b],transformModules:q,tryNative:!1,...A?{transform:A}:{}}).import(G,{})}function p(G,Q){if(!G)return!0;if(G.providerIds?.length){if(!Q?.providerId||!G.providerIds.includes(Q.providerId))return!1}if(G.modelIds?.length){if(!Q?.modelId||!G.modelIds.includes(Q.modelId))return!1}return!0}function z(G){return typeof G==="object"&&G!==null}function s(G){return Array.isArray(G)&&G.every((Q)=>typeof Q==="string")}function BG(G,Q){if(!z(G))throw Error(`Invalid plugin module: ${Q}`);if(typeof G.name!=="string"||!G.name)throw Error(`Invalid plugin name: ${Q}`);if(!z(G.manifest))throw Error(`Invalid plugin manifest: ${Q}`);if(Object.hasOwn(G.manifest,"providerIds")&&!s(G.manifest.providerIds))throw Error(`Invalid plugin manifest.providerIds: ${Q}`);if(Object.hasOwn(G.manifest,"modelIds")&&!s(G.manifest.modelIds))throw Error(`Invalid plugin manifest.modelIds: ${Q}`)}function DG(G){if(!z(G))throw Error("Plugin setup context must be an object");if(G.session!==void 0&&!z(G.session))throw Error("Plugin setup context session must be an object");if(G.client!==void 0&&!z(G.client))throw Error("Plugin setup context client must be an object");if(G.user!==void 0&&!z(G.user))throw Error("Plugin setup context user must be an object");if(G.workspaceInfo!==void 0&&!z(G.workspaceInfo))throw Error("Plugin setup context workspaceInfo must be an object");if(G.automation!==void 0&&!z(G.automation))throw Error("Plugin setup context automation must be an object");if(G.automation!==void 0&&typeof G.automation.ingestEvent!=="function")throw Error("Plugin setup context automation.ingestEvent must be a function");if(G.logger!==void 0&&!z(G.logger))throw Error("Plugin setup context logger must be an object")}var t=0,N=new Map,v=new Map;function HG(G){let Q=G instanceof Error?G.message:String(G),U=G instanceof Error?G.stack:void 0;return{message:Q,stack:U}}function k(G,Q,U,Y){if(!process.send)return;process.send({type:"response",id:G,ok:Q,result:U,error:Y})}function x(G,Q){if(!process.send)return;process.send({type:"event",name:G,payload:Q})}globalThis.__clinePluginHost={emitEvent:x};globalThis.__clineSessionEnv={cwd:void 0,workspaceInfo:void 0};function i(G){if(!G||typeof G!=="object")return{};return G}function NG(G){if(!G||typeof G!=="object")return;let Q={...G};if(Q.error instanceof Error)Q.error={name:Q.error.name,message:Q.error.message,stack:Q.error.stack};return Q}function EG(G){let Q=(U,Y,Z)=>{x("plugin_log",{level:U,pluginName:G,message:Y,metadata:NG(Z)})};return{debug:(U,Y)=>Q("debug",U,Y),log:(U,Y)=>Q("log",U,Y),error:(U,Y)=>Q("error",U,Y)}}function O(G,Q){let U=`${G}:${Q}`,Y=(v.get(U)??0)+1;return v.set(U,Y),`${G}_${Q}_${Y}`}function SG(G){let Q=typeof G.eventType==="string"?G.eventType.trim():"",U=typeof G.source==="string"?G.source.trim():"";if(!Q)throw Error("Automation event type contribution requires eventType");if(!U)throw Error("Automation event type contribution requires source");return{...G,eventType:Q,source:U,examples:G.examples?[...G.examples]:void 0,metadata:G.metadata?i(G.metadata):void 0}}function B(G){let Q=N.get(G);if(!Q)throw Error(`Unknown sandbox plugin id: ${G}`);return Q}async function VG(G){let Q;try{let U=await o(G.pluginPath);if(Q=U.default??U[G.exportName],BG(Q,G.pluginPath),Q.manifest=IG(Q.manifest),!p(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],rules:[],messageBuilders:[],providers:[],automationEventTypes:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,rules:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let q=O(G.pluginId,"tool");Z.tools.set(q,X.execute),Y.tools.push({id:q,name:X.name,description:X.description,inputSchema:X.inputSchema,timeoutMs:X.timeoutMs,retryable:X.retryable})},registerCommand:(X)=>{let q=O(G.pluginId,"command");if(typeof X.handler==="function")Z.commands.set(q,X.handler);Y.commands.push({id:q,name:X.name,description:X.description})},registerRule:(X)=>{let q=O(G.pluginId,"rule");if(typeof X.content==="function"){Z.rules.set(q,X.content),Y.rules.push({id:q,ruleId:X.id,source:X.source,hasContentHandler:!0});return}Y.rules.push({id:q,ruleId:X.id,content:X.content,source:X.source})},registerMessageBuilder:(X)=>{let q=O(G.pluginId,"builder");Z.messageBuilders.set(q,X.build),Y.messageBuilders.push({id:q,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:O(G.pluginId,"provider"),name:X.name,description:X.description,metadata:i(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:O(G.pluginId,"automation_event"),...SG(X)})}};if(typeof Q.setup==="function")try{let X={...G.setupCtxBase,...G.loggerEnabled?{logger:EG(Q.name)}:{},...Q.manifest.capabilities.includes("automationEvents")?{automation:{ingestEvent:(q)=>{x("automation_event",q)}}}:{}};DG(X),await Q.setup($,X)}catch(X){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q.name,phase:"setup",message:X instanceof Error?X.message:String(X),stack:X instanceof Error?X.stack:void 0}}}return{type:"loaded",state:{plugin:Q,handlers:Z},descriptor:{pluginId:G.pluginId,pluginPath:G.pluginPath,name:Q.name,manifest:Q.manifest,hooks:Q.hooks?Object.entries(Q.hooks).filter(([,X])=>typeof X==="function").map(([X])=>X):void 0,contributions:Y}}}catch(U){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q?.name,phase:"load",message:U instanceof Error?U.message:String(U),stack:U instanceof Error?U.stack:void 0}}}}async function TG(G){if(N.clear(),t=0,v.clear(),G.cwd)try{process.chdir(G.cwd)}catch{}let Q=globalThis.__clineSessionEnv;if(Q)Q.cwd=G.cwd,Q.workspaceInfo=G.workspaceInfo;let U=[],Y=[],Z=[],$=G.exportName||"plugin",X=new Map,q={providerId:G.providerId,modelId:G.modelId},w={session:G.session,client:G.client,user:G.user,workspaceInfo:G.workspaceInfo},A=await Promise.all((G.pluginPaths||[]).map((L)=>{let W=`plugin_${++t}`;return VG({pluginPath:L,pluginId:W,exportName:$,targeting:q,setupCtxBase:w,loggerEnabled:G.loggerEnabled})}));for(let L of A){if(L.type==="skipped")continue;if(L.type==="failure"){Y.push(L.failure);continue}let{descriptor:W,state:r}=L,E=X.get(W.name);if(E!==void 0){let D=U[E];if(!D)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:D.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${D.pluginPath}`}),N.delete(D.pluginId),U.splice(E,1),X.clear();for(let[a,e]of U.entries())X.set(e.name,a)}}N.set(W.pluginId,r),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function yG(G){let U=B(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function bG(G){let U=B(G.pluginId).handlers.tools.get(G.contributionId);if(typeof U!=="function")throw Error("Unknown sandbox tool contribution");return await U(G.input,G.context)}async function RG(G){let U=B(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function kG(G){let U=B(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}async function vG(G){let U=B(G.pluginId).handlers.rules.get(G.contributionId);if(typeof U!=="function")return"";return await U()}var xG={initialize:TG,invokeHook:yG,executeTool:bG,executeCommand:RG,buildMessages:kG,resolveRuleContent:vG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=xG[G.method];if(!Q){k(G.id,!1,void 0,{message:`Unknown method: ${String(G.method)}`});return}try{let U=await Q(G.args||{});k(G.id,!0,U)}catch(U){k(G.id,!1,void 0,HG(U))}});
|
|
1
|
+
import{createRequire as GG}from"node:module";var QG=GG(import.meta.url);import{normalizePluginManifest as IG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as UG,createRequire as y}from"node:module";import{dirname as M,extname as I,isAbsolute as XG,resolve as K}from"node:path";import{fileURLToPath as P}from"node:url";import{PLUGIN_FILE_EXTENSIONS as YG}from"@cline/shared";var m=M(P(import.meta.url)),ZG=y(import.meta.url),$G=K(m,"..","..","..","..",".."),S=WG($G),qG=["@cline/sdk","@cline/agents","@cline/core","@cline/core/hub","@cline/core/hub/daemon-entry","@cline/core/telemetry","@cline/llms","@cline/llms/browser","@cline/shared","@cline/shared/automation","@cline/shared/browser","@cline/shared/storage","@cline/shared/db","@cline/shared/types"],b=new Set(UG.flatMap((G)=>[G,G.replace(/^node:/,"")])),j=new Set(YG),KG=["development","node","import","require","default"];function WG(G){let Q={},U={"@cline/sdk":K(G,"packages/sdk/src/index.ts"),"@cline/agents":K(G,"packages/agents/src/index.ts"),"@cline/core":K(G,"packages/core/src/index.ts"),"@cline/llms":K(G,"packages/llms/src/index.ts"),"@cline/shared":K(G,"packages/shared/src/index.ts"),"@cline/shared/storage":K(G,"packages/shared/src/storage/index.ts"),"@cline/shared/db":K(G,"packages/shared/src/db/index.ts")};for(let[Y,Z]of Object.entries(U))if(_(Z))Q[Y]=Z;for(let Y of["agents","core","llms","shared"]){let Z=K(G,"packages",Y),$=K(Z,"package.json");if(!_($))continue;try{let X=JSON.parse(C($,"utf8"));if(typeof X.name!=="string"||!X.exports)continue;if(typeof X.exports==="string"){let q=K(Z,X.exports);if(_(q))Q[X.name]=q;continue}if(typeof X.exports!=="object")continue;for(let[q,w]of Object.entries(X.exports)){let A=_G(Z,w);if(!A)continue;let L=q==="."?X.name:`${X.name}/${q.replace(/^\.\//,"")}`;Q[L]=A}}catch{}}return Q}function _G(G,Q){let U=R(Q);if(!U)return null;let Y=h(G,U);for(let Z of Y)if(_(Z))return Z;return null}function R(G,Q=new Set){if(typeof G==="string")return G;if(!G||typeof G!=="object")return null;if(Q.has(G))return null;Q.add(G);let U=G;for(let Y of KG){let Z=R(U[Y],Q);if(Z)return Z}return null}function h(G,Q){let U=Q.replace(/^\.\//,""),Y=[K(G,Q)];if(U.startsWith("dist/")){let Z=U.replace(/^dist\//,"src/").replace(/\.(mjs|cjs|js)$/,"");return[K(G,`${Z}.ts`),K(G,`${Z}.tsx`),K(G,`${Z}.mts`),K(G,`${Z}.cts`),...Y]}return Y}function LG(G){return Object.fromEntries(Object.entries(G).sort(([Q],[U])=>U.length-Q.length))}function H(G){return!(G.startsWith(".")||G.startsWith("/")||G.startsWith("file:")||G.startsWith("data:")||G.startsWith("http:")||G.startsWith("https:"))}function J(G){if(G.startsWith("@")){let[Q,U]=G.split("/",3);return U?`${Q}/${U}`:G}return G.split("/",1)[0]??G}function wG(G){let Q=J(G);if(G===Q)return".";return`.${G.slice(Q.length)}`}function d(G){return J(G).startsWith("@cline/")}function V(G,Q){let U=J(Q),Y=M(G);while(!0){let Z=K(Y,"node_modules",U);if(_(Z)||_(K(Z,"package.json")))return!0;let $=K(Y,"..");if($===Y)return!1;Y=$}}function f(G){return T(G)!==null}function T(G){try{return ZG.resolve(G)}catch{}return AG(G)}function AG(G){let Q=J(G),U=u(Q);if(!U)return null;let Y=K(U,"package.json");try{let Z=JSON.parse(C(Y,"utf8")),$=wG(G),X=$==="."&&typeof Z.exports==="string"?Z.exports:Z.exports&&typeof Z.exports==="object"&&Object.hasOwn(Z.exports,$)?Z.exports[$]:void 0,q=R(X)??($==="."&&typeof Z.main==="string"?Z.main:null);if(!q)return null;let w=K(U,q),A=[w,...h(U,q).filter((L)=>L!==w)];for(let L of A)if(_(L))return L;return null}catch{return null}}function zG(){let G=[m],Q=process.env.CLINE_WRAPPER_PATH?.trim();if(Q)G.push(M(M(Q)));let U=process.execPath?.trim();if(U)G.push(M(U));return[...new Set(G.map((Y)=>K(Y)))]}function MG(G,Q){let U=G;while(!0){let Y=K(U,"package.json");if(_(Y))try{if(JSON.parse(C(Y,"utf8")).name===Q)return U}catch{}let Z=K(U,"node_modules",Q,"package.json");if(_(Z))return M(Z);let $=K(U,"..");if($===U)return null;U=$}}function u(G){for(let Q of zG()){let U=MG(Q,G);if(U)return U}return null}function FG(G){let U=M(G);for(let Y=0;Y<4;Y++){let Z=K(U,"package.json");if(_(Z))try{let X=JSON.parse(C(Z,"utf8"));return X!=null&&typeof X==="object"&&"cline"in X}catch{return!1}let $=K(U,"..");if($===U)return!1;U=$}return!1}function c(G,Q){let U=Q.startsWith("file:")?P(Q):XG(Q)?Q:K(M(G),Q);if(_(U)&&j.has(I(U)))return U;for(let Y of j){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of j){let Z=K(U,`index${Y}`);if(_(Z))return Z}return null}function l(G){let Q=new Set,U=[/\bimport\s+(?:type\s+)?[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bexport\s+[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bimport\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g,/\brequire\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g];for(let Y of U)for(let Z of G.matchAll(Y)){let $=Z[1];if($)Q.add($)}return[...Q]}function JG(G){return I(G)!==".ts"}function g(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!j.has(I(G)))return;let Y=C(G,"utf8"),Z=JG(G);for(let $ of l(Y)){if($.startsWith("node:")||b.has($))continue;if(H($)){if(!Z)continue;if(Object.hasOwn(S,$)||Object.hasOwn(S,J($))||V(G,$)||d($)&&f($)||Q&&f($))continue;throw Error(`Cannot find module '${J($)}'`)}let X=c(G,$);if(X)g(X,Q,U)}}function n(G,Q=new Set,U=new Set){if(Q.has(G)||!_(G))return U;if(Q.add(G),!j.has(I(G)))return U;let Y=C(G,"utf8");for(let Z of l(Y)){if(U.add(Z),H(Z))continue;let $=c(G,Z);if($)n($,Q,U)}return U}function CG(G,Q){let U=y(G),Y={},Z=n(G),$=new Set(qG);for(let[X,q]of Object.entries(S)){try{U.resolve(X);continue}catch{}Y[X]=q}for(let X of Z)if(H(X)&&(d(X)||Q))$.add(X);for(let X of $){if(Object.hasOwn(Y,X)||V(G,X))continue;let q=T(X);if(q)Y[X]=q}if(!Q)return Y;for(let X of Z){if(!H(X)||Object.hasOwn(Y,X)||V(G,X)||X.startsWith("node:")||b.has(X))continue;let q=T(X);if(q)Y[X]=q}return Y}function OG(G){let Q=I(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var F;function jG(){if(F!==void 0)return F;let G=u("jiti");if(!G)return F=null,null;let Q=K(G,"dist","babel.cjs");if(!_(Q))return F=null,null;try{let Y=y(Q)(Q);F=typeof Y==="function"?Y:null}catch{F=null}return F}async function o(G,Q={}){let U=!FG(G);g(G,U);let Y=CG(G,U),Z=LG(Y),$=await import("jiti"),X=typeof $==="function"?$:typeof $.default==="function"?$.default:void 0;if(!X)throw Error("Unable to load jiti");let q=Object.entries(Z).filter(([,W])=>OG(W)).map(([W])=>W),w=jG(),A=w?(W)=>w({...W,interopDefault:!0}):void 0;return await X(G,{alias:Z,cache:Q.useCache,requireCache:Q.useCache,esmResolve:!0,interopDefault:!1,nativeModules:[...b],transformModules:q,tryNative:!1,...A?{transform:A}:{}}).import(G,{})}function p(G,Q){if(!G)return!0;if(G.providerIds?.length){if(!Q?.providerId||!G.providerIds.includes(Q.providerId))return!1}if(G.modelIds?.length){if(!Q?.modelId||!G.modelIds.includes(Q.modelId))return!1}return!0}function z(G){return typeof G==="object"&&G!==null}function s(G){return Array.isArray(G)&&G.every((Q)=>typeof Q==="string")}function BG(G,Q){if(!z(G))throw Error(`Invalid plugin module: ${Q}`);if(typeof G.name!=="string"||!G.name)throw Error(`Invalid plugin name: ${Q}`);if(!z(G.manifest))throw Error(`Invalid plugin manifest: ${Q}`);if(Object.hasOwn(G.manifest,"providerIds")&&!s(G.manifest.providerIds))throw Error(`Invalid plugin manifest.providerIds: ${Q}`);if(Object.hasOwn(G.manifest,"modelIds")&&!s(G.manifest.modelIds))throw Error(`Invalid plugin manifest.modelIds: ${Q}`)}function DG(G){if(!z(G))throw Error("Plugin setup context must be an object");if(G.session!==void 0&&!z(G.session))throw Error("Plugin setup context session must be an object");if(G.client!==void 0&&!z(G.client))throw Error("Plugin setup context client must be an object");if(G.user!==void 0&&!z(G.user))throw Error("Plugin setup context user must be an object");if(G.workspaceInfo!==void 0&&!z(G.workspaceInfo))throw Error("Plugin setup context workspaceInfo must be an object");if(G.automation!==void 0&&!z(G.automation))throw Error("Plugin setup context automation must be an object");if(G.automation!==void 0&&typeof G.automation.ingestEvent!=="function")throw Error("Plugin setup context automation.ingestEvent must be a function");if(G.logger!==void 0&&!z(G.logger))throw Error("Plugin setup context logger must be an object")}var t=0,N=new Map,v=new Map;function HG(G){let Q=G instanceof Error?G.message:String(G),U=G instanceof Error?G.stack:void 0;return{message:Q,stack:U}}function k(G,Q,U,Y){if(!process.send)return;process.send({type:"response",id:G,ok:Q,result:U,error:Y})}function x(G,Q){if(!process.send)return;process.send({type:"event",name:G,payload:Q})}globalThis.__clinePluginHost={emitEvent:x};globalThis.__clineSessionEnv={cwd:void 0,workspaceInfo:void 0};function i(G){if(!G||typeof G!=="object")return{};return G}function NG(G){if(!G||typeof G!=="object")return;let Q={...G};if(Q.error instanceof Error)Q.error={name:Q.error.name,message:Q.error.message,stack:Q.error.stack};return Q}function EG(G){let Q=(U,Y,Z)=>{x("plugin_log",{level:U,pluginName:G,message:Y,metadata:NG(Z)})};return{debug:(U,Y)=>Q("debug",U,Y),log:(U,Y)=>Q("log",U,Y),error:(U,Y)=>Q("error",U,Y)}}function O(G,Q){let U=`${G}:${Q}`,Y=(v.get(U)??0)+1;return v.set(U,Y),`${G}_${Q}_${Y}`}function SG(G){let Q=typeof G.eventType==="string"?G.eventType.trim():"",U=typeof G.source==="string"?G.source.trim():"";if(!Q)throw Error("Automation event type contribution requires eventType");if(!U)throw Error("Automation event type contribution requires source");return{...G,eventType:Q,source:U,examples:G.examples?[...G.examples]:void 0,metadata:G.metadata?i(G.metadata):void 0}}function B(G){let Q=N.get(G);if(!Q)throw Error(`Unknown sandbox plugin id: ${G}`);return Q}async function VG(G){let Q;try{let U=await o(G.pluginPath);if(Q=U.default??U[G.exportName],BG(Q,G.pluginPath),Q.manifest=IG(Q.manifest),!p(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],rules:[],messageBuilders:[],providers:[],automationEventTypes:[],mcpServers:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,rules:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let q=O(G.pluginId,"tool");Z.tools.set(q,X.execute),Y.tools.push({id:q,name:X.name,description:X.description,inputSchema:X.inputSchema,timeoutMs:X.timeoutMs,retryable:X.retryable})},registerCommand:(X)=>{let q=O(G.pluginId,"command");if(typeof X.handler==="function")Z.commands.set(q,X.handler);Y.commands.push({id:q,name:X.name,description:X.description})},registerRule:(X)=>{let q=O(G.pluginId,"rule");if(typeof X.content==="function"){Z.rules.set(q,X.content),Y.rules.push({id:q,ruleId:X.id,source:X.source,hasContentHandler:!0});return}Y.rules.push({id:q,ruleId:X.id,content:X.content,source:X.source})},registerMessageBuilder:(X)=>{let q=O(G.pluginId,"builder");Z.messageBuilders.set(q,X.build),Y.messageBuilders.push({id:q,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:O(G.pluginId,"provider"),name:X.name,description:X.description,metadata:i(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:O(G.pluginId,"automation_event"),...SG(X)})},registerMcpServer:(X)=>{Y.mcpServers.push(X)}};if(typeof Q.setup==="function")try{let X={...G.setupCtxBase,...G.loggerEnabled?{logger:EG(Q.name)}:{},...Q.manifest.capabilities.includes("automationEvents")?{automation:{ingestEvent:(q)=>{x("automation_event",q)}}}:{}};DG(X),await Q.setup($,X)}catch(X){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q.name,phase:"setup",message:X instanceof Error?X.message:String(X),stack:X instanceof Error?X.stack:void 0}}}return{type:"loaded",state:{plugin:Q,handlers:Z},descriptor:{pluginId:G.pluginId,pluginPath:G.pluginPath,name:Q.name,manifest:Q.manifest,hooks:Q.hooks?Object.entries(Q.hooks).filter(([,X])=>typeof X==="function").map(([X])=>X):void 0,contributions:Y}}}catch(U){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q?.name,phase:"load",message:U instanceof Error?U.message:String(U),stack:U instanceof Error?U.stack:void 0}}}}async function TG(G){if(N.clear(),t=0,v.clear(),G.cwd)try{process.chdir(G.cwd)}catch{}let Q=globalThis.__clineSessionEnv;if(Q)Q.cwd=G.cwd,Q.workspaceInfo=G.workspaceInfo;let U=[],Y=[],Z=[],$=G.exportName||"plugin",X=new Map,q={providerId:G.providerId,modelId:G.modelId},w={session:G.session,client:G.client,user:G.user,workspaceInfo:G.workspaceInfo},A=await Promise.all((G.pluginPaths||[]).map((L)=>{let W=`plugin_${++t}`;return VG({pluginPath:L,pluginId:W,exportName:$,targeting:q,setupCtxBase:w,loggerEnabled:G.loggerEnabled})}));for(let L of A){if(L.type==="skipped")continue;if(L.type==="failure"){Y.push(L.failure);continue}let{descriptor:W,state:r}=L,E=X.get(W.name);if(E!==void 0){let D=U[E];if(!D)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:D.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${D.pluginPath}`}),N.delete(D.pluginId),U.splice(E,1),X.clear();for(let[a,e]of U.entries())X.set(e.name,a)}}N.set(W.pluginId,r),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function yG(G){let U=B(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function bG(G){let U=B(G.pluginId).handlers.tools.get(G.contributionId);if(typeof U!=="function")throw Error("Unknown sandbox tool contribution");return await U(G.input,G.context)}async function RG(G){let U=B(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function kG(G){let U=B(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}async function vG(G){let U=B(G.pluginId).handlers.rules.get(G.contributionId);if(typeof U!=="function")return"";return await U()}var xG={initialize:TG,invokeHook:yG,executeTool:bG,executeCommand:RG,buildMessages:kG,resolveRuleContent:vG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=xG[G.method];if(!Q){k(G.id,!1,void 0,{message:`Unknown method: ${String(G.method)}`});return}try{let U=await Q(G.args||{});k(G.id,!0,U)}catch(U){k(G.id,!1,void 0,HG(U))}});
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* Built-in implementation for running shell commands using Node.js spawn.
|
|
5
5
|
*/
|
|
6
6
|
import type { BashExecutor } from "../types";
|
|
7
|
+
export declare class CommandExitError extends Error {
|
|
8
|
+
readonly exitCode: number;
|
|
9
|
+
readonly output: string;
|
|
10
|
+
constructor(exitCode: number, output: string);
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Options for the bash executor
|
|
9
14
|
*/
|
|
@@ -19,8 +24,17 @@ export interface BashExecutorOptions {
|
|
|
19
24
|
*/
|
|
20
25
|
timeoutMs?: number;
|
|
21
26
|
/**
|
|
22
|
-
* Maximum output
|
|
23
|
-
*
|
|
27
|
+
* Maximum output kept, in characters. Output beyond this is
|
|
28
|
+
* middle-truncated: the head and tail are preserved and the middle is
|
|
29
|
+
* elided, since build and test failures usually live at the end of the
|
|
30
|
+
* output.
|
|
31
|
+
* @default 48_000 — see MAX_COMMAND_OUTPUT_CHARS in output-limits.ts
|
|
32
|
+
*/
|
|
33
|
+
maxOutputChars?: number;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Misnamed — the limit was always enforced in characters,
|
|
36
|
+
* not bytes. Use {@link maxOutputChars}; this alias is honored when
|
|
37
|
+
* maxOutputChars is not set.
|
|
24
38
|
*/
|
|
25
39
|
maxOutputBytes?: number;
|
|
26
40
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared caps for how much tool output may enter the conversation. Every
|
|
3
|
+
* character returned by an executor is re-sent to the model on each
|
|
4
|
+
* subsequent request, so oversized outputs cost quadratically over the
|
|
5
|
+
* remaining run. Limits are measured in characters (UTF-16 code units),
|
|
6
|
+
* which tracks token cost more closely than bytes and is what JS strings
|
|
7
|
+
* measure exactly. Executors enforce these caps; tool descriptions
|
|
8
|
+
* reference them so the model pages or narrows instead of retrying.
|
|
9
|
+
*
|
|
10
|
+
* Truncation notices always live in the preserved head/tail of an entry,
|
|
11
|
+
* never in the elided middle. Provider-request building may re-truncate
|
|
12
|
+
* long strings with its own (possibly tighter) middle-cut backstop
|
|
13
|
+
* (session/services/message-builder.ts); keeping the notices at the edges
|
|
14
|
+
* means the recovery guidance survives that cut too.
|
|
15
|
+
*/
|
|
16
|
+
/** Max characters of command output kept; beyond this the middle is elided. */
|
|
17
|
+
export declare const MAX_COMMAND_OUTPUT_CHARS = 48000;
|
|
18
|
+
/** Max lines returned per file read when the range is larger or absent. */
|
|
19
|
+
export declare const MAX_READ_LINES = 2000;
|
|
20
|
+
/** Max characters kept per line in file reads (defangs minified files). */
|
|
21
|
+
export declare const MAX_LINE_CHARS = 2000;
|
|
22
|
+
/** Max characters returned per file read window. */
|
|
23
|
+
export declare const MAX_READ_OUTPUT_CHARS = 48000;
|
|
24
|
+
/** Max characters returned per search query; beyond this the middle is elided. */
|
|
25
|
+
export declare const MAX_SEARCH_OUTPUT_CHARS = 48000;
|