@cline/core 0.0.92 → 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 +14 -14
- package/dist/cron/store/sqlite-cron-store.d.ts +6 -0
- package/dist/extensions/composio/composio-meta-tools.d.ts +37 -0
- 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 +242 -230
- package/dist/hub/daemon/runtime-handlers.d.ts +2 -0
- package/dist/hub/index.js +230 -221
- 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 +263 -254
- 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
|
@@ -244,6 +244,12 @@ export declare class SqliteCronStore {
|
|
|
244
244
|
hasConsumedOneOffRevision(specId: string, revision: number): boolean;
|
|
245
245
|
enqueueRun(input: EnqueueRunInput): CronRunRecord;
|
|
246
246
|
cancelQueuedRunsForSpec(specId: string): number;
|
|
247
|
+
/**
|
|
248
|
+
* Cancels queued cron occurrences superseded by a newer queued occurrence
|
|
249
|
+
* of the same spec, so a backlog runs once instead of replaying every
|
|
250
|
+
* missed slot back to back.
|
|
251
|
+
*/
|
|
252
|
+
cancelSupersededScheduleRuns(): number;
|
|
247
253
|
private cancelQueuedOneOffRunsForSpec;
|
|
248
254
|
claimDueRuns(options: ClaimRunOptions): ClaimedCronRun[];
|
|
249
255
|
renewClaim(runId: string, claimToken: string, leaseUntilAt: string): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-chat authentication for Composio connectors.
|
|
3
|
+
*
|
|
4
|
+
* The Cline API creates a per-user Composio tool-router session scoped to the
|
|
5
|
+
* project's enabled auth configs (`POST /api/v1/connectors/meta-tools/sessions`)
|
|
6
|
+
* and returns the schemas of its allowlisted meta tools: COMPOSIO_SEARCH_TOOLS
|
|
7
|
+
* finds tools across those toolkits, COMPOSIO_MANAGE_CONNECTIONS returns a
|
|
8
|
+
* hosted Connect Link the agent surfaces in chat, COMPOSIO_WAIT_FOR_CONNECTIONS
|
|
9
|
+
* blocks until the user finishes, and COMPOSIO_MULTI_EXECUTE_TOOL runs the
|
|
10
|
+
* tools search found — no new session needed after connecting.
|
|
11
|
+
* Credentials never pass through Cline or the model — only the link does.
|
|
12
|
+
* Executions go back through the proxy with the session id
|
|
13
|
+
* (`POST /api/v1/connectors/meta-tools/{slug}/execute`), which checks that the
|
|
14
|
+
* session belongs to the caller.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CONNECTORS_API_PATH = "/api/v1/connectors";
|
|
17
|
+
/** The host owns the API origin and user authentication for connector requests. */
|
|
18
|
+
export type ConnectorsRequest = (path: string, init: RequestInit) => Promise<Response>;
|
|
19
|
+
export type ComposioMetaTool = {
|
|
20
|
+
slug: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
input_parameters?: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export type ComposioMetaToolSession = {
|
|
26
|
+
sessionId: string;
|
|
27
|
+
tools: ComposioMetaTool[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates a meta-tool session, or returns undefined when in-chat auth is
|
|
31
|
+
* unavailable: no connectable toolkits (404), a proxy without the endpoint, or
|
|
32
|
+
* any network failure. Callers then run without the meta tools.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createComposioMetaToolSession(request: ConnectorsRequest, options?: {
|
|
35
|
+
log?: (message: string) => void;
|
|
36
|
+
}): Promise<ComposioMetaToolSession | undefined>;
|
|
37
|
+
export declare function executeComposioMetaTool(request: ConnectorsRequest, sessionId: string, slug: string, input: unknown): Promise<unknown>;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { AgentExtension, BasicLogger } from "@cline/shared";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* there is nothing to register (no state file, or no connected toolkit with
|
|
6
|
-
* tools) — sessions without connectors pay one file read.
|
|
7
|
-
*
|
|
8
|
-
* The state is read once here, at session-bootstrap time, so a session's
|
|
9
|
-
* tool set is frozen at start exactly like the previous plugin's was.
|
|
10
|
-
*/
|
|
2
|
+
import { type ConnectorsRequest } from "./composio-meta-tools";
|
|
3
|
+
export declare function resolveComposioConnectionStatePath(accountId: string): string;
|
|
4
|
+
/** Builds the meta-tool extension independently of saved connections. */
|
|
11
5
|
export declare function createComposioToolsExtension(options?: {
|
|
6
|
+
request?: ConnectorsRequest;
|
|
12
7
|
logger?: BasicLogger;
|
|
13
8
|
}): Promise<AgentExtension | undefined>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export type { AgentPluginPackageDiagnostic, AgentPluginPackageDiagnosticScope, AgentPluginPackageLoadReport, AgentPluginPackageManifest, AgentPluginPackageMcpServer, AgentPluginPackageSkill, AgentSkillMetadata, LoadAgentPluginPackagesOptions, LoadedAgentPluginPackage, ParsedAgentSkill, } from "./agent-plugin";
|
|
2
2
|
export { AGENT_PLUGINS_V1_MANIFEST_SCHEMA, AGENT_PLUGINS_V1_MCP_SCHEMA, loadAgentPluginPackages, parseAgentSkillMarkdown, } from "./agent-plugin";
|
|
3
|
-
export type { ResolveAgentPluginPathsOptions } from "./plugin/plugin-config-loader";
|
|
4
|
-
export { discoverPluginModulePaths, getPluginDisplayName, resolveAgentPluginPaths, resolveAndLoadAgentPlugins, resolvePluginConfigSearchPaths, resolvePluginSkillDirectoriesFromPaths, } from "./plugin/plugin-config-loader";
|
|
3
|
+
export type { PluginExecutionMode, ResolveAgentPluginPathsOptions, } from "./plugin/plugin-config-loader";
|
|
4
|
+
export { CLINE_PLUGIN_MODE_ENV, discoverPluginModulePaths, getPluginDisplayName, resolveAgentPluginPaths, resolveAgentPluginPathsWithDiagnostics, resolveAndLoadAgentPlugins, resolvePluginConfigSearchPaths, resolvePluginExecutionMode, resolvePluginSkillDirectoriesFromPaths, } from "./plugin/plugin-config-loader";
|
|
5
5
|
export type { PluginInitializationFailure, PluginInitializationWarning, PluginLoadDiagnostics, } from "./plugin/plugin-load-report";
|
|
6
6
|
export type { LoadAgentPluginFromPathOptions } from "./plugin/plugin-loader";
|
|
7
7
|
export { loadAgentPluginFromPath, loadAgentPluginsFromPaths, loadAgentPluginsFromPathsWithDiagnostics, } from "./plugin/plugin-loader";
|
|
8
|
+
export type { PluginHookErrorMode, PluginRegistryOptions, PluginSessionLoadInput, PluginSessionLoadResult, PluginStatusListener, } from "./plugin/plugin-registry";
|
|
9
|
+
export { DEFAULT_PLUGIN_FAILURE_THRESHOLD, DEFAULT_PLUGIN_HOOK_TIMEOUT_MS, DEFAULT_PLUGIN_IMPORT_TIMEOUT_MS, DEFAULT_PLUGIN_SETUP_TIMEOUT_MS, DEFAULT_PLUGIN_TOOL_TIMEOUT_MS, formatSessionPluginIssue, getProcessPluginRegistry, PluginCallTimeoutError, PluginRegistry, } from "./plugin/plugin-registry";
|
|
10
|
+
export { CLINE_PLUGIN_BOOTSTRAP_PATH_ENV } from "./plugin/plugin-sandbox";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { AgentConfig, PluginSetupContext, WorkspaceInfo } from "@cline/shared";
|
|
1
|
+
import type { AgentConfig, PluginPolicies, PluginSetupContext, SessionPluginIssue, WorkspaceInfo } from "@cline/shared";
|
|
2
|
+
import { getPluginDisplayName } from "@cline/shared/storage";
|
|
2
3
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
4
|
+
import { type PluginHookErrorMode, type PluginRegistry } from "./plugin-registry";
|
|
3
5
|
import type { PluginTargeting } from "./plugin-targeting";
|
|
4
|
-
export { getPluginDisplayName }
|
|
6
|
+
export { getPluginDisplayName };
|
|
5
7
|
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
6
8
|
export declare function resolvePluginConfigSearchPaths(workspacePath?: string): string[];
|
|
7
9
|
export declare function discoverPluginModulePaths(directoryPath: string): string[];
|
|
@@ -11,11 +13,38 @@ export interface ResolveAgentPluginPathsOptions {
|
|
|
11
13
|
cwd?: string;
|
|
12
14
|
includeDisabled?: boolean;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Like {@link resolveAgentPluginPaths}, but never throws: configured paths
|
|
18
|
+
* that cannot be resolved come back as `discoveryFailures`, and paths turned
|
|
19
|
+
* off in settings come back as `disabledPaths`, so callers can report both.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAgentPluginPathsWithDiagnostics(options?: ResolveAgentPluginPathsOptions): {
|
|
22
|
+
paths: string[];
|
|
23
|
+
disabledPaths: string[];
|
|
24
|
+
discoveryFailures: Array<{
|
|
25
|
+
pluginPath: string;
|
|
26
|
+
error: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
14
29
|
export declare function resolveAgentPluginPaths(options?: ResolveAgentPluginPathsOptions): string[];
|
|
15
30
|
export declare function resolvePluginSkillDirectoriesFromPaths(pluginPaths: ReadonlyArray<string>): string[];
|
|
16
31
|
export declare function resolveAgentPluginSkillDirectories(options?: ResolveAgentPluginPathsOptions): string[];
|
|
32
|
+
export type PluginExecutionMode = "sandbox" | "worker" | "in_process";
|
|
33
|
+
export declare const CLINE_PLUGIN_MODE_ENV = "CLINE_PLUGIN_MODE";
|
|
34
|
+
/**
|
|
35
|
+
* Where plugins run (`CLINE_PLUGIN_MODE`, or `mode`):
|
|
36
|
+
* - `worker` (default): each plugin runs in its own worker thread per
|
|
37
|
+
* session, inside the host runtime. A plugin crash, `process.exit()`, or
|
|
38
|
+
* hung loop ends only its worker, and no `node`/`bun` is needed on PATH.
|
|
39
|
+
* - `in_process`: plugins are imported into the host process.
|
|
40
|
+
* - `sandbox`: the previous per-session `node`/`bun` subprocess.
|
|
41
|
+
*
|
|
42
|
+
* Builds that do not ship the sandbox bootstrap (a host bundle without it)
|
|
43
|
+
* cannot start workers and fall back to `in_process`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolvePluginExecutionMode(mode?: PluginExecutionMode): PluginExecutionMode;
|
|
17
46
|
export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPathsOptions, PluginTargeting {
|
|
18
|
-
mode?:
|
|
47
|
+
mode?: PluginExecutionMode;
|
|
19
48
|
exportName?: string;
|
|
20
49
|
importTimeoutMs?: number;
|
|
21
50
|
hookTimeoutMs?: number;
|
|
@@ -36,9 +65,22 @@ export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPat
|
|
|
36
65
|
automation?: PluginSetupContext["automation"];
|
|
37
66
|
logger?: PluginSetupContext["logger"];
|
|
38
67
|
telemetry?: PluginSetupContext["telemetry"];
|
|
68
|
+
/**
|
|
69
|
+
* Per-session plugin selection (`"*"` default plus per-plugin overrides).
|
|
70
|
+
* In-process only; the sandbox loads every discovered plugin.
|
|
71
|
+
*/
|
|
72
|
+
policy?: PluginPolicies;
|
|
73
|
+
/** How a failing plugin hook affects the run. Defaults to `"ignore"`. */
|
|
74
|
+
hookErrorMode?: PluginHookErrorMode;
|
|
75
|
+
/** In-process registry. Defaults to the process-wide registry. */
|
|
76
|
+
registry?: PluginRegistry;
|
|
77
|
+
/** In-process only: a plugin this session uses became degraded or failed. */
|
|
78
|
+
onIssue?: (issue: SessionPluginIssue) => void;
|
|
39
79
|
}
|
|
40
80
|
export declare function resolveAndLoadAgentPlugins(options?: ResolveAndLoadAgentPluginsOptions): Promise<{
|
|
41
81
|
extensions: AgentPlugin[];
|
|
42
82
|
pluginPaths: string[];
|
|
83
|
+
/** Plugins the session asked for but does not have (failed, disabled). */
|
|
84
|
+
issues: SessionPluginIssue[];
|
|
43
85
|
shutdown?: () => Promise<void>;
|
|
44
86
|
} & PluginLoadDiagnostics>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentExtension, AgentExtensionCommand, AgentExtensionMcpServer, AgentExtensionProvider, AgentExtensionRule, AgentTool, PluginStatusRecord } from "@cline/shared";
|
|
2
|
+
import { type PluginExecutionMode } from "./plugin-config-loader";
|
|
3
|
+
import type { PluginInitializationFailure, PluginInitializationWarning } from "./plugin-load-report";
|
|
4
|
+
import { type PluginRegistry } from "./plugin-registry";
|
|
5
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
6
|
+
export interface CollectedPluginContributions {
|
|
7
|
+
pluginName: string;
|
|
8
|
+
pluginPath: string;
|
|
9
|
+
extension: AgentExtension;
|
|
10
|
+
tools: AgentTool[];
|
|
11
|
+
rules: AgentExtensionRule[];
|
|
12
|
+
commands: AgentExtensionCommand[];
|
|
13
|
+
mcpServers: AgentExtensionMcpServer[];
|
|
14
|
+
providers: AgentExtensionProvider[];
|
|
15
|
+
}
|
|
16
|
+
export interface CollectPluginContributionsInput extends PluginTargeting {
|
|
17
|
+
pluginPaths: ReadonlyArray<string>;
|
|
18
|
+
disabledPluginPaths?: ReadonlyArray<string>;
|
|
19
|
+
discoveryFailures?: ReadonlyArray<{
|
|
20
|
+
pluginPath: string;
|
|
21
|
+
error: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
cwd?: string;
|
|
24
|
+
workspacePath?: string;
|
|
25
|
+
registry?: PluginRegistry;
|
|
26
|
+
/** Defaults to the configured execution mode (`CLINE_PLUGIN_MODE`). */
|
|
27
|
+
mode?: PluginExecutionMode;
|
|
28
|
+
}
|
|
29
|
+
export interface CollectPluginContributionsResult {
|
|
30
|
+
plugins: CollectedPluginContributions[];
|
|
31
|
+
/** Status of every plugin that failed to import or set up. */
|
|
32
|
+
failed: PluginStatusRecord[];
|
|
33
|
+
failures: PluginInitializationFailure[];
|
|
34
|
+
warnings: PluginInitializationWarning[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Runs each plugin's `setup` with a collecting API, for settings surfaces
|
|
38
|
+
* that list what plugins contribute without starting a session. Plugins load
|
|
39
|
+
* the same way sessions load them: through the shared registry (in workers
|
|
40
|
+
* by default, or in-process), so failures are recorded there like any
|
|
41
|
+
* other, or through the subprocess sandbox when `CLINE_PLUGIN_MODE=sandbox`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function collectPluginContributions(input: CollectPluginContributionsInput): Promise<CollectPluginContributionsResult>;
|
|
@@ -5,6 +5,8 @@ export interface LoadAgentPluginFromPathOptions {
|
|
|
5
5
|
exportName?: string;
|
|
6
6
|
cwd?: string;
|
|
7
7
|
useCache?: boolean;
|
|
8
|
+
/** Fresh module evaluation that still reuses the transform cache. */
|
|
9
|
+
freshModule?: boolean;
|
|
8
10
|
session?: PluginSetupContext["session"];
|
|
9
11
|
client?: PluginSetupContext["client"];
|
|
10
12
|
user?: PluginSetupContext["user"];
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
export interface ImportPluginModuleOptions {
|
|
2
2
|
useCache?: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate the module again (no module cache) but reuse jiti's on-disk
|
|
5
|
+
* transform cache, so a fresh per-session copy skips the babel transform.
|
|
6
|
+
*/
|
|
7
|
+
freshModule?: boolean;
|
|
3
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Content fingerprint of a plugin's own source: the entry file plus every
|
|
11
|
+
* file it reaches through relative static imports (`node_modules` and other
|
|
12
|
+
* bare imports are not included). Used to tell whether a plugin changed since
|
|
13
|
+
* it was last imported, including edits outside the entry file and edits that
|
|
14
|
+
* keep the same size within one clock tick.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fingerprintPluginSources(pluginPath: string): string;
|
|
4
17
|
export declare function importPluginModule(pluginPath: string, options?: ImportPluginModuleOptions): Promise<Record<string, unknown>>;
|
|
@@ -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>;
|