@cline/core 0.0.92-nightly.1791773200 → 0.0.93
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/auth/cline.d.ts +2 -0
- package/dist/cloud/index.js +1 -1
- package/dist/extensions/composio/composio-meta-tools.d.ts +4 -6
- package/dist/extensions/composio/composio-tools-extension.d.ts +4 -9
- package/dist/extensions/index.d.ts +5 -2
- package/dist/extensions/plugin/plugin-config-loader.d.ts +45 -3
- package/dist/extensions/plugin/plugin-contributions.d.ts +43 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +2 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +13 -0
- package/dist/extensions/plugin/plugin-registry.d.ts +203 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +43 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +563 -1
- package/dist/extensions/tools/schemas.d.ts +1 -1
- package/dist/hub/daemon/entry.d.ts +8 -0
- package/dist/hub/daemon/entry.js +222 -219
- package/dist/hub/daemon/runtime-handlers.d.ts +2 -0
- package/dist/hub/index.js +209 -209
- package/dist/hub/server/handlers/session-handlers.d.ts +3 -1
- package/dist/hub/server/hub-server-transport.d.ts +3 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +243 -243
- package/dist/remote/remote-helper-entry.js +1 -1
- package/dist/remote/remote-helper.js +3 -3
- package/dist/runtime/host/local-runtime-host.d.ts +3 -0
- package/dist/runtime/host/runtime-host.d.ts +11 -0
- package/dist/runtime/tools/worker-sandbox.d.ts +90 -0
- package/dist/services/local-runtime-bootstrap.d.ts +7 -1
- package/dist/services/plugin-tools.d.ts +4 -0
- package/dist/types/chat-schema.d.ts +2 -2
- package/dist/types.d.ts +2 -0
- package/package.json +4 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { AgentExtension, BasicLogger, PluginPolicies, PluginSetupContext, PluginStatusRecord, SessionPluginIssue } from "@cline/shared";
|
|
2
|
+
import type { PluginInitializationFailure, PluginInitializationWarning } from "./plugin-load-report";
|
|
3
|
+
import { type PluginTargeting } from "./plugin-targeting";
|
|
4
|
+
export declare const DEFAULT_PLUGIN_IMPORT_TIMEOUT_MS = 4000;
|
|
5
|
+
export declare const DEFAULT_PLUGIN_SETUP_TIMEOUT_MS = 4000;
|
|
6
|
+
export declare const DEFAULT_PLUGIN_HOOK_TIMEOUT_MS = 3000;
|
|
7
|
+
/** Tools, commands, rule content, and message builders. */
|
|
8
|
+
export declare const DEFAULT_PLUGIN_TOOL_TIMEOUT_MS = 60000;
|
|
9
|
+
/** Consecutive call failures after which a plugin is turned off. */
|
|
10
|
+
export declare const DEFAULT_PLUGIN_FAILURE_THRESHOLD = 5;
|
|
11
|
+
export type PluginHookErrorMode = "ignore" | "throw";
|
|
12
|
+
export declare class PluginCallTimeoutError extends Error {
|
|
13
|
+
readonly label: string;
|
|
14
|
+
readonly timeoutMs: number;
|
|
15
|
+
constructor(label: string, timeoutMs: number);
|
|
16
|
+
}
|
|
17
|
+
export interface PluginRegistryOptions {
|
|
18
|
+
logger?: BasicLogger;
|
|
19
|
+
importTimeoutMs?: number;
|
|
20
|
+
setupTimeoutMs?: number;
|
|
21
|
+
hookTimeoutMs?: number;
|
|
22
|
+
toolTimeoutMs?: number;
|
|
23
|
+
failureThreshold?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where a session's plugin copies run. `in_process` imports them into the
|
|
27
|
+
* host. `worker` runs each plugin in its own worker thread per session: the
|
|
28
|
+
* host never loads plugin code, and a crash, `process.exit()`, or hung loop
|
|
29
|
+
* ends only that worker.
|
|
30
|
+
*/
|
|
31
|
+
export type PluginIsolation = "in_process" | "worker";
|
|
32
|
+
export interface PluginSessionLoadInput extends PluginTargeting {
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
/** Defaults to `in_process`. */
|
|
35
|
+
isolation?: PluginIsolation;
|
|
36
|
+
/** Resolved, enabled plugin module paths, in load order. */
|
|
37
|
+
pluginPaths: ReadonlyArray<string>;
|
|
38
|
+
/** Plugin paths turned off in settings; reported as `disabled`. */
|
|
39
|
+
disabledPluginPaths?: ReadonlyArray<string>;
|
|
40
|
+
/** Configured paths that could not be resolved to a module. */
|
|
41
|
+
discoveryFailures?: ReadonlyArray<{
|
|
42
|
+
pluginPath: string;
|
|
43
|
+
error: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
policy?: PluginPolicies;
|
|
46
|
+
exportName?: string;
|
|
47
|
+
cwd?: string;
|
|
48
|
+
hookErrorMode?: PluginHookErrorMode;
|
|
49
|
+
setupContext?: PluginSetupContext;
|
|
50
|
+
emitEvent?: (event: {
|
|
51
|
+
name: string;
|
|
52
|
+
payload?: unknown;
|
|
53
|
+
}) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Called when a call made for this session moves a plugin to `degraded`
|
|
56
|
+
* or `failed`. Setup runs lazily on the first turn, after the session
|
|
57
|
+
* start payload went out, so this is how those failures reach the user.
|
|
58
|
+
*/
|
|
59
|
+
onIssue?: (issue: SessionPluginIssue) => void;
|
|
60
|
+
/** Per-session overrides of the registry's default timeouts. */
|
|
61
|
+
importTimeoutMs?: number;
|
|
62
|
+
hookTimeoutMs?: number;
|
|
63
|
+
/** Tools (without their own `timeoutMs`), commands, rules, builders. */
|
|
64
|
+
callTimeoutMs?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface PluginSessionLoadResult {
|
|
67
|
+
extensions: AgentExtension[];
|
|
68
|
+
pluginPaths: string[];
|
|
69
|
+
failures: PluginInitializationFailure[];
|
|
70
|
+
warnings: PluginInitializationWarning[];
|
|
71
|
+
issues: SessionPluginIssue[];
|
|
72
|
+
/**
|
|
73
|
+
* Ends the session's use of its plugin copies: runs `ctx.onDispose`
|
|
74
|
+
* cleanup and stops further calls.
|
|
75
|
+
*/
|
|
76
|
+
release: () => Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export type PluginStatusListener = (status: PluginStatusRecord) => void;
|
|
79
|
+
/** The name a plugin is known by before its module is imported. */
|
|
80
|
+
export declare function derivePluginNameFromPath(pluginPath: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Plugins written for the subprocess sandbox emit events through
|
|
83
|
+
* `globalThis.__clinePluginHost.emitEvent`. In-process, route those calls to
|
|
84
|
+
* the session whose hook or tool is running (async context follows timers and
|
|
85
|
+
* promises the call started), else to the session that last called a plugin.
|
|
86
|
+
*/
|
|
87
|
+
export declare function installPluginHostShim(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Tracks plugins for the whole process and hands each session a guarded copy
|
|
90
|
+
* of the plugins it enabled. Each session gets its own import of the module,
|
|
91
|
+
* matching the per-session sandbox plugins were written for. Every import,
|
|
92
|
+
* setup, hook, tool, command, rule, and message-builder call is wrapped with
|
|
93
|
+
* a timeout and error capture, and the result is recorded per plugin so
|
|
94
|
+
* failures are visible instead of silently dropping the plugin's tools.
|
|
95
|
+
*/
|
|
96
|
+
export declare class PluginRegistry {
|
|
97
|
+
private readonly entries;
|
|
98
|
+
private readonly listeners;
|
|
99
|
+
private logger;
|
|
100
|
+
private readonly defaults;
|
|
101
|
+
private readonly failureThreshold;
|
|
102
|
+
constructor(options?: PluginRegistryOptions);
|
|
103
|
+
setLogger(logger: BasicLogger | undefined): void;
|
|
104
|
+
subscribe(listener: PluginStatusListener): () => void;
|
|
105
|
+
list(): PluginStatusRecord[];
|
|
106
|
+
get(nameOrPath: string): PluginStatusRecord[];
|
|
107
|
+
/**
|
|
108
|
+
* Re-imports the matching plugins and resets their status. Sessions
|
|
109
|
+
* started afterwards use the new module; running sessions keep the copy
|
|
110
|
+
* they set up, which stays callable unless the re-import fails (the plugin
|
|
111
|
+
* is then turned off for every session, failing closed).
|
|
112
|
+
*/
|
|
113
|
+
reload(nameOrPath: string): Promise<PluginStatusRecord[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Finds the plugin whose module root appears in `error`'s stack and turns
|
|
116
|
+
* it off for every session. Used by the Hub daemon so a stray plugin error
|
|
117
|
+
* does not take the process down.
|
|
118
|
+
*/
|
|
119
|
+
attributeUncaughtError(error: unknown, label?: string): PluginStatusRecord | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Imports plugins without attaching them to a session, so the Hub can
|
|
122
|
+
* discover them at startup and report status before any session exists.
|
|
123
|
+
* The imported copy is kept for the first session to claim.
|
|
124
|
+
*/
|
|
125
|
+
preload(input: Pick<PluginSessionLoadInput, "pluginPaths" | "disabledPluginPaths" | "discoveryFailures" | "exportName" | "importTimeoutMs" | "isolation">): Promise<PluginStatusRecord[]>;
|
|
126
|
+
loadForSession(input: PluginSessionLoadInput): Promise<PluginSessionLoadResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Worker isolation: each plugin loads in its own worker for this session,
|
|
129
|
+
* and the copy handed to the session is a proxy whose calls go to that
|
|
130
|
+
* worker. The copy goes through the same wrapping as an in-process one, so
|
|
131
|
+
* status, timeouts, failure counting, policy, and notices are unchanged.
|
|
132
|
+
* What differs is where the code runs: the host never imports it.
|
|
133
|
+
*/
|
|
134
|
+
private loadIsolatedForSession;
|
|
135
|
+
/**
|
|
136
|
+
* Every worker imports the module fresh, so new code needs no host
|
|
137
|
+
* re-import. A source change (or re-enabling) still starts a new import
|
|
138
|
+
* id: the plugin gets a clean slate, and copies of the old code go stale.
|
|
139
|
+
*/
|
|
140
|
+
private refreshIsolatedEntry;
|
|
141
|
+
private startWorkerCopy;
|
|
142
|
+
/** Re-validates a worker plugin's current code in a throwaway worker. */
|
|
143
|
+
private reloadIsolated;
|
|
144
|
+
private staleIssue;
|
|
145
|
+
/**
|
|
146
|
+
* Records discovery failures and settings-disabled plugins. Settings-
|
|
147
|
+
* disabled plugins the session would otherwise use are reported as issues
|
|
148
|
+
* with `reason: "settings"`. Returns the entries that failed discovery.
|
|
149
|
+
*/
|
|
150
|
+
private recordDiscovery;
|
|
151
|
+
private isEnabledForSession;
|
|
152
|
+
private policyIssue;
|
|
153
|
+
private resolveTimeouts;
|
|
154
|
+
private match;
|
|
155
|
+
private ensureEntry;
|
|
156
|
+
private ensureLoaded;
|
|
157
|
+
/** Imports one copy of the module in its own call scope. */
|
|
158
|
+
private importCopy;
|
|
159
|
+
/**
|
|
160
|
+
* Hands a session its own copy of the plugin module. Plugins written for
|
|
161
|
+
* the per-session sandbox keep state at module level (one plugin object
|
|
162
|
+
* per import), so sharing one copy across sessions would break them.
|
|
163
|
+
*/
|
|
164
|
+
private claimInstance;
|
|
165
|
+
private importEntry;
|
|
166
|
+
private wrapForSession;
|
|
167
|
+
private runSetup;
|
|
168
|
+
private wrapHooks;
|
|
169
|
+
private wrapTool;
|
|
170
|
+
private wrapCommand;
|
|
171
|
+
/** A failing rule contributes no text rather than breaking the prompt. */
|
|
172
|
+
private wrapRule;
|
|
173
|
+
/** A failing builder leaves the message unchanged. */
|
|
174
|
+
private wrapMessageBuilder;
|
|
175
|
+
/**
|
|
176
|
+
* Runs one plugin call in its session scope with a timeout, records the
|
|
177
|
+
* outcome against the plugin, and rethrows failures.
|
|
178
|
+
*/
|
|
179
|
+
private guardedCall;
|
|
180
|
+
/**
|
|
181
|
+
* Whether a session's copy may still be called: the plugin is not turned
|
|
182
|
+
* off, its setup did not fail, and its session has not ended.
|
|
183
|
+
*/
|
|
184
|
+
private isUsable;
|
|
185
|
+
private assertUsable;
|
|
186
|
+
private releaseInstance;
|
|
187
|
+
private recordFailure;
|
|
188
|
+
private setState;
|
|
189
|
+
private warnIfSlow;
|
|
190
|
+
private log;
|
|
191
|
+
private toStatus;
|
|
192
|
+
private toIssue;
|
|
193
|
+
private toInitializationFailure;
|
|
194
|
+
}
|
|
195
|
+
/** One-line, user-facing description of a plugin a session cannot fully use. */
|
|
196
|
+
export declare function formatSessionPluginIssue(issue: SessionPluginIssue): string;
|
|
197
|
+
/**
|
|
198
|
+
* The registry shared by every session in this process. The Hub daemon reads
|
|
199
|
+
* it for `plugins.*` requests and to attribute stray plugin errors.
|
|
200
|
+
*/
|
|
201
|
+
export declare function getProcessPluginRegistry(): PluginRegistry;
|
|
202
|
+
/** @internal Test hook. */
|
|
203
|
+
export declare function resetProcessPluginRegistryForTests(registry?: PluginRegistry): void;
|
|
@@ -2,10 +2,23 @@ import type { AgentConfig, PluginSetupContext, WorkspaceInfo } from "@cline/shar
|
|
|
2
2
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
3
3
|
import type { PluginTargeting } from "./plugin-targeting";
|
|
4
4
|
export declare const CLINE_PLUGIN_IDLE_TIMEOUT_MS_ENV = "CLINE_PLUGIN_IDLE_TIMEOUT_MS";
|
|
5
|
+
/**
|
|
6
|
+
* Absolute path to a compiled `plugin-sandbox-bootstrap.js`, for hosts that
|
|
7
|
+
* ship it somewhere this module cannot find on its own (an app bundle's
|
|
8
|
+
* resources directory).
|
|
9
|
+
*/
|
|
10
|
+
export declare const CLINE_PLUGIN_BOOTSTRAP_PATH_ENV = "CLINE_PLUGIN_BOOTSTRAP_PATH";
|
|
5
11
|
export declare const DEFAULT_PLUGIN_SANDBOX_IDLE_TIMEOUT_MS: number;
|
|
6
12
|
export type SandboxedPluginSetupContext = Pick<PluginSetupContext, "session" | "client" | "user" | "workspaceInfo" | "logger">;
|
|
13
|
+
/**
|
|
14
|
+
* Where sandboxed plugins run. `subprocess` spawns a `node`/`bun` child and
|
|
15
|
+
* needs one on PATH; `worker` runs a worker thread inside the host runtime.
|
|
16
|
+
*/
|
|
17
|
+
export type PluginSandboxTransport = "subprocess" | "worker";
|
|
7
18
|
export interface PluginSandboxOptions extends PluginTargeting {
|
|
8
19
|
pluginPaths: string[];
|
|
20
|
+
/** Defaults to `subprocess`. */
|
|
21
|
+
transport?: PluginSandboxTransport;
|
|
9
22
|
exportName?: string;
|
|
10
23
|
/**
|
|
11
24
|
* Max wall time for plugin module imports. Defaults to 4000 ms; falls back
|
|
@@ -26,6 +39,25 @@ export interface PluginSandboxOptions extends PluginTargeting {
|
|
|
26
39
|
name: string;
|
|
27
40
|
payload?: unknown;
|
|
28
41
|
}) => void;
|
|
42
|
+
/** Worker transport only: the worker ended on its own (crash, exit). */
|
|
43
|
+
onUnexpectedExit?: (error: Error) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Limit for each plugin's `setup()`, timed inside the sandbox and
|
|
46
|
+
* separately from the import. When set, the initialize call may take
|
|
47
|
+
* `importTimeoutMs + setupTimeoutMs`.
|
|
48
|
+
*/
|
|
49
|
+
setupTimeoutMs?: number;
|
|
50
|
+
/** A plugin finished importing and its `setup()` is starting. */
|
|
51
|
+
onSetupStarted?: (pluginPath: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Session plugin policy, applied inside the sandbox after each plugin is
|
|
54
|
+
* imported (when its own name is known) and before its `setup()` runs.
|
|
55
|
+
*/
|
|
56
|
+
policy?: Record<string, {
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
} | undefined>;
|
|
59
|
+
/** Per plugin path: other names the policy may use (its file name). */
|
|
60
|
+
policyNames?: Record<string, string[]>;
|
|
29
61
|
/**
|
|
30
62
|
* The session's working directory. Forwarded to the sandbox subprocess so
|
|
31
63
|
* that `process.cwd()` returns the correct path inside the sandbox even
|
|
@@ -75,8 +107,19 @@ export declare function selectBootstrapCandidate(options: {
|
|
|
75
107
|
} | {
|
|
76
108
|
sourcePath: string;
|
|
77
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Whether this build can start the sandbox bootstrap: the compiled file ships
|
|
112
|
+
* beside it, or its TypeScript source exists (running from source). Bundles
|
|
113
|
+
* that ship neither cannot isolate plugins.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isPluginSandboxBootstrapAvailable(): boolean;
|
|
78
116
|
export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{
|
|
79
117
|
extensions: AgentConfig["extensions"];
|
|
80
118
|
pluginPaths: string[];
|
|
119
|
+
/** Plugins the `policy` turned off; their setup did not run. */
|
|
120
|
+
disabledByPolicy: Array<{
|
|
121
|
+
pluginPath: string;
|
|
122
|
+
name: string;
|
|
123
|
+
}>;
|
|
81
124
|
shutdown: () => Promise<void>;
|
|
82
125
|
} & PluginLoadDiagnostics>;
|