@cline/core 0.0.42 → 0.0.43-nightly.1780629505
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/cron/service/schedule-service.d.ts +1 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts +4 -0
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts +3 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +1 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +7 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -1
- package/dist/extensions/tools/helpers.d.ts +4 -1
- package/dist/extensions/tools/schemas.d.ts +8 -0
- package/dist/hub/daemon/entry.js +164 -163
- package/dist/hub/discovery/index.d.ts +1 -0
- package/dist/hub/index.js +163 -163
- package/dist/index.d.ts +4 -2
- package/dist/index.js +163 -163
- package/dist/runtime/host/runtime-host.d.ts +7 -0
- package/dist/runtime/orchestration/session-runtime.d.ts +1 -0
- package/dist/services/llms/apihandler-agent-model-adapter.d.ts +26 -0
- package/dist/services/plugin-uninstall.d.ts +13 -0
- package/dist/services/providers/provider-config-fields.d.ts +1 -1
- package/dist/services/telemetry/core-events.d.ts +18 -0
- package/dist/services/telemetry/index.js +1 -1
- package/dist/services/telemetry/tool-context.d.ts +3 -0
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
|
@@ -86,6 +86,7 @@ export declare class HubScheduleService {
|
|
|
86
86
|
pauseSchedule(scheduleId: string): ScheduleRecord | undefined;
|
|
87
87
|
resumeSchedule(scheduleId: string): ScheduleRecord | undefined;
|
|
88
88
|
triggerScheduleNow(scheduleId: string): Promise<ScheduleExecutionRecord | undefined>;
|
|
89
|
+
triggerScheduleNowDetached(scheduleId: string): ScheduleExecutionRecord | undefined;
|
|
89
90
|
listScheduleExecutions(options: ListScheduleExecutionsOptions): ScheduleExecutionRecord[];
|
|
90
91
|
getScheduleStats(scheduleId: string): ScheduleExecutionStats;
|
|
91
92
|
getActiveExecutions(): ActiveScheduledExecution[];
|
|
@@ -38,6 +38,10 @@ export interface CreateInstructionWatcherOptions {
|
|
|
38
38
|
export interface CreateSkillsConfigDefinitionOptions {
|
|
39
39
|
directories?: ReadonlyArray<string>;
|
|
40
40
|
workspacePath?: string;
|
|
41
|
+
includePluginSkills?: boolean;
|
|
42
|
+
pluginSkillDirectories?: ReadonlyArray<string>;
|
|
43
|
+
pluginPaths?: ReadonlyArray<string>;
|
|
44
|
+
cwd?: string;
|
|
41
45
|
}
|
|
42
46
|
export interface CreateRulesConfigDefinitionOptions {
|
|
43
47
|
directories?: ReadonlyArray<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ResolveAgentPluginPathsOptions } from "./plugin/plugin-config-loader";
|
|
2
|
-
export { discoverPluginModulePaths, resolveAgentPluginPaths, resolveAndLoadAgentPlugins, resolvePluginConfigSearchPaths, } from "./plugin/plugin-config-loader";
|
|
2
|
+
export { discoverPluginModulePaths, resolveAgentPluginPaths, resolveAndLoadAgentPlugins, resolvePluginConfigSearchPaths, resolvePluginSkillDirectoriesFromPaths, } from "./plugin/plugin-config-loader";
|
|
3
3
|
export type { PluginInitializationFailure, PluginInitializationWarning, PluginLoadDiagnostics, } from "./plugin/plugin-load-report";
|
|
4
4
|
export type { LoadAgentPluginFromPathOptions } from "./plugin/plugin-loader";
|
|
5
5
|
export { loadAgentPluginFromPath, loadAgentPluginsFromPaths, loadAgentPluginsFromPathsWithDiagnostics, } from "./plugin/plugin-loader";
|
|
@@ -10,6 +10,8 @@ export interface ResolveAgentPluginPathsOptions {
|
|
|
10
10
|
cwd?: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function resolveAgentPluginPaths(options?: ResolveAgentPluginPathsOptions): string[];
|
|
13
|
+
export declare function resolvePluginSkillDirectoriesFromPaths(pluginPaths: ReadonlyArray<string>): string[];
|
|
14
|
+
export declare function resolveAgentPluginSkillDirectories(options?: ResolveAgentPluginPathsOptions): string[];
|
|
13
15
|
export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPathsOptions, PluginTargeting {
|
|
14
16
|
mode?: "sandbox" | "in_process";
|
|
15
17
|
exportName?: string;
|
|
@@ -35,6 +37,7 @@ export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPat
|
|
|
35
37
|
}
|
|
36
38
|
export declare function resolveAndLoadAgentPlugins(options?: ResolveAndLoadAgentPluginsOptions): Promise<{
|
|
37
39
|
extensions: AgentPlugin[];
|
|
40
|
+
pluginPaths: string[];
|
|
38
41
|
shutdown?: () => Promise<void>;
|
|
39
42
|
} & PluginLoadDiagnostics>;
|
|
40
43
|
export {};
|
|
@@ -17,6 +17,7 @@ export declare function loadAgentPluginFromPath(pluginPath: string, options?: Lo
|
|
|
17
17
|
export declare function loadAgentPluginsFromPaths(pluginPaths: string[], options?: LoadAgentPluginFromPathOptions & PluginTargeting): Promise<AgentExtension[]>;
|
|
18
18
|
export declare function loadAgentPluginsFromPathsWithDiagnostics(pluginPaths: string[], options?: LoadAgentPluginFromPathOptions & PluginTargeting): Promise<{
|
|
19
19
|
plugins: AgentExtension[];
|
|
20
|
+
pluginPaths: string[];
|
|
20
21
|
failures: PluginInitializationFailure[];
|
|
21
22
|
warnings: PluginInitializationWarning[];
|
|
22
23
|
}>;
|
|
@@ -5,6 +5,12 @@ export type SandboxedPluginSetupContext = Pick<PluginSetupContext, "session" | "
|
|
|
5
5
|
export interface PluginSandboxOptions extends PluginTargeting {
|
|
6
6
|
pluginPaths: string[];
|
|
7
7
|
exportName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Max wall time for plugin module imports. Defaults to 4000 ms; falls back
|
|
10
|
+
* to the `CLINE_PLUGIN_IMPORT_TIMEOUT_MS` env var when this option is not
|
|
11
|
+
* set, allowing slower hosts (Windows cold-start, CI without warm caches)
|
|
12
|
+
* to raise the ceiling without touching code.
|
|
13
|
+
*/
|
|
8
14
|
importTimeoutMs?: number;
|
|
9
15
|
hookTimeoutMs?: number;
|
|
10
16
|
contributionTimeoutMs?: number;
|
|
@@ -32,5 +38,6 @@ export interface PluginSandboxOptions extends PluginTargeting {
|
|
|
32
38
|
}
|
|
33
39
|
export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{
|
|
34
40
|
extensions: AgentConfig["extensions"];
|
|
41
|
+
pluginPaths: string[];
|
|
35
42
|
shutdown: () => Promise<void>;
|
|
36
43
|
} & PluginLoadDiagnostics>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as GG}from"node:module";var QG=GG(import.meta.url);import{normalizePluginManifest as jG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as UG,createRequire as b}from"node:module";import{dirname as M,extname as O,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 h=M(P(import.meta.url)),ZG=b(import.meta.url),$G=K(h,"..","..","..","..",".."),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"],y=new Set(UG.flatMap((G)=>[G,G.replace(/^node:/,"")])),I=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=m(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 m(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 D(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,...m(U,q).filter((L)=>L!==w)];for(let L of A)if(_(L))return L;return null}catch{return null}}function zG(){let G=[h],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 l(G,Q){let U=Q.startsWith("file:")?P(Q):XG(Q)?Q:K(M(G),Q);if(_(U)&&I.has(O(U)))return U;for(let Y of I){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of I){let Z=K(U,`index${Y}`);if(_(Z))return Z}return null}function c(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 O(G)!==".ts"}function g(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!I.has(O(G)))return;let Y=C(G,"utf8"),Z=JG(G);for(let $ of c(Y)){if($.startsWith("node:")||y.has($))continue;if(D($)){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=l(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),!I.has(O(G)))return U;let Y=C(G,"utf8");for(let Z of c(Y)){if(U.add(Z),D(Z))continue;let $=l(G,Z);if($)n($,Q,U)}return U}function CG(G,Q){let U=b(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(D(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(!D(X)||Object.hasOwn(Y,X)||V(G,X)||X.startsWith("node:")||y.has(X))continue;let q=T(X);if(q)Y[X]=q}return Y}function IG(G){let Q=O(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var F;function OG(){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=b(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])=>IG(W)).map(([W])=>W),w=OG(),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:[...y],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,H=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 j(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 N(G){let Q=H.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=jG(Q.manifest),!p(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],messageBuilders:[],providers:[],automationEventTypes:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let q=j(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=j(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})},registerMessageBuilder:(X)=>{let q=j(G.pluginId,"builder");Z.messageBuilders.set(q,X.build),Y.messageBuilders.push({id:q,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:j(G.pluginId,"provider"),name:X.name,description:X.description,metadata:i(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:j(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(H.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 B=U[E];if(!B)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:B.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${B.pluginPath}`}),H.delete(B.pluginId),U.splice(E,1),X.clear();for(let[a,e]of U.entries())X.set(e.name,a)}}H.set(W.pluginId,r),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function bG(G){let U=N(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function yG(G){let U=N(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=N(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function kG(G){let U=N(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}var vG={initialize:TG,invokeHook:bG,executeTool:yG,executeCommand:RG,buildMessages:kG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=vG[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:[],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))}});
|
|
@@ -7,8 +7,11 @@ export declare function getEditorSizeError(input: EditFileInput): string | null;
|
|
|
7
7
|
/**
|
|
8
8
|
* Create a timeout-wrapped promise
|
|
9
9
|
*/
|
|
10
|
+
export declare class TimeoutError extends Error {
|
|
11
|
+
readonly timeoutMs: number;
|
|
12
|
+
constructor(message: string, timeoutMs: number);
|
|
13
|
+
}
|
|
10
14
|
export declare function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T>;
|
|
11
|
-
export declare function normalizeReadFileRequests(input: unknown): ReadFileRequest[];
|
|
12
15
|
export declare function formatReadFileQuery(request: ReadFileRequest): string;
|
|
13
16
|
export declare function getReadFileRangeError(request: ReadFileRequest): string | null;
|
|
14
17
|
export declare function normalizeRunCommandsInput(input: unknown): Array<string | StructuredCommandInput>;
|
|
@@ -43,11 +43,19 @@ export declare const ReadFilesInputUnionSchema: z.ZodUnion<readonly [z.ZodObject
|
|
|
43
43
|
start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
44
|
end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
45
|
}, z.core.$strip>>, z.ZodArray<z.ZodString>, z.ZodString, z.ZodObject<{
|
|
46
|
+
files: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
47
|
+
path: z.ZodString;
|
|
48
|
+
start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
49
|
+
end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
|
+
}, z.core.$strip>]>>;
|
|
51
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
52
|
files: z.ZodObject<{
|
|
47
53
|
path: z.ZodString;
|
|
48
54
|
start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
49
55
|
end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
56
|
}, z.core.$strip>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
files: z.ZodString;
|
|
51
59
|
}, z.core.$strip>, z.ZodObject<{
|
|
52
60
|
file_paths: z.ZodArray<z.ZodString>;
|
|
53
61
|
}, z.core.$strip>, z.ZodObject<{
|