@cline/core 0.0.92 → 0.0.93-nightly.1792117748
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/api.d.ts +3 -0
- package/dist/cloud/controller.d.ts +3 -0
- package/dist/cloud/index.js +16 -16
- 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 +47 -6
- 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 +172 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +47 -1
- package/dist/extensions/plugin-sandbox-bootstrap.js +563 -1
- package/dist/extensions/tools/definitions.d.ts +1 -1
- package/dist/extensions/tools/schemas.d.ts +1 -1
- package/dist/extensions/tools/types.d.ts +3 -2
- package/dist/hub/daemon/entry.js +242 -231
- package/dist/hub/daemon/index.d.ts +24 -0
- package/dist/hub/daemon/runtime-handlers.d.ts +2 -0
- package/dist/hub/discovery/index.d.ts +8 -1
- package/dist/hub/index.js +229 -220
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +3 -0
- 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-environments.d.ts +1 -0
- 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/services/telemetry/index.js +1 -1
- package/dist/types/chat-schema.d.ts +2 -2
- package/dist/types.d.ts +2 -0
- package/package.json +8 -12
- package/dist/remote/remote-helper-entry.d.ts +0 -1
- package/dist/remote/remote-helper-entry.js +0 -5
- package/dist/remote/remote-helper.d.ts +0 -29
- package/dist/remote/remote-helper.js +0 -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";
|
|
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
|
+
* - `sandbox`: the previous per-session `node`/`bun` subprocess.
|
|
40
|
+
*
|
|
41
|
+
* Plugin code never runs on a host's main thread. Both modes need the
|
|
42
|
+
* sandbox bootstrap; a build that ships none fails every plugin load with
|
|
43
|
+
* `PluginBootstrapMissingError` rather than importing plugins into the host.
|
|
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;
|
|
@@ -25,9 +54,8 @@ export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPat
|
|
|
25
54
|
payload?: unknown;
|
|
26
55
|
}) => void;
|
|
27
56
|
/**
|
|
28
|
-
* Structured workspace and git metadata
|
|
29
|
-
*
|
|
30
|
-
* in the extension context.
|
|
57
|
+
* Structured workspace and git metadata, forwarded to plugins via
|
|
58
|
+
* PluginSetupCtx.workspaceInfo.
|
|
31
59
|
*/
|
|
32
60
|
workspaceInfo?: WorkspaceInfo;
|
|
33
61
|
session?: PluginSetupContext["session"];
|
|
@@ -36,9 +64,22 @@ export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPat
|
|
|
36
64
|
automation?: PluginSetupContext["automation"];
|
|
37
65
|
logger?: PluginSetupContext["logger"];
|
|
38
66
|
telemetry?: PluginSetupContext["telemetry"];
|
|
67
|
+
/**
|
|
68
|
+
* Per-session plugin selection (`"*"` default plus per-plugin overrides).
|
|
69
|
+
* Worker mode only; the subprocess sandbox loads every discovered plugin.
|
|
70
|
+
*/
|
|
71
|
+
policy?: PluginPolicies;
|
|
72
|
+
/** How a failing plugin hook affects the run. Defaults to `"ignore"`. */
|
|
73
|
+
hookErrorMode?: PluginHookErrorMode;
|
|
74
|
+
/** Worker mode: the registry to load through. Defaults to the process-wide one. */
|
|
75
|
+
registry?: PluginRegistry;
|
|
76
|
+
/** Worker mode only: a plugin this session uses became degraded or failed. */
|
|
77
|
+
onIssue?: (issue: SessionPluginIssue) => void;
|
|
39
78
|
}
|
|
40
79
|
export declare function resolveAndLoadAgentPlugins(options?: ResolveAndLoadAgentPluginsOptions): Promise<{
|
|
41
80
|
extensions: AgentPlugin[];
|
|
42
81
|
pluginPaths: string[];
|
|
82
|
+
/** Plugins the session asked for but does not have (failed, disabled). */
|
|
83
|
+
issues: SessionPluginIssue[];
|
|
43
84
|
shutdown?: () => Promise<void>;
|
|
44
85
|
} & 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's workers, so
|
|
40
|
+
* failures are recorded there like any other, or through the subprocess
|
|
41
|
+
* 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,172 @@
|
|
|
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
|
+
export interface PluginSessionLoadInput extends PluginTargeting {
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
/** Resolved, enabled plugin module paths, in load order. */
|
|
28
|
+
pluginPaths: ReadonlyArray<string>;
|
|
29
|
+
/** Plugin paths turned off in settings; reported as `disabled`. */
|
|
30
|
+
disabledPluginPaths?: ReadonlyArray<string>;
|
|
31
|
+
/** Configured paths that could not be resolved to a module. */
|
|
32
|
+
discoveryFailures?: ReadonlyArray<{
|
|
33
|
+
pluginPath: string;
|
|
34
|
+
error: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
policy?: PluginPolicies;
|
|
37
|
+
exportName?: string;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
hookErrorMode?: PluginHookErrorMode;
|
|
40
|
+
setupContext?: PluginSetupContext;
|
|
41
|
+
emitEvent?: (event: {
|
|
42
|
+
name: string;
|
|
43
|
+
payload?: unknown;
|
|
44
|
+
}) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Called when a call made for this session moves a plugin to `degraded`
|
|
47
|
+
* or `failed`. Setup runs lazily on the first turn, after the session
|
|
48
|
+
* start payload went out, so this is how those failures reach the user.
|
|
49
|
+
*/
|
|
50
|
+
onIssue?: (issue: SessionPluginIssue) => void;
|
|
51
|
+
/** Per-session overrides of the registry's default timeouts. */
|
|
52
|
+
importTimeoutMs?: number;
|
|
53
|
+
hookTimeoutMs?: number;
|
|
54
|
+
/** Tools (without their own `timeoutMs`), commands, rules, builders. */
|
|
55
|
+
callTimeoutMs?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface PluginSessionLoadResult {
|
|
58
|
+
extensions: AgentExtension[];
|
|
59
|
+
pluginPaths: string[];
|
|
60
|
+
failures: PluginInitializationFailure[];
|
|
61
|
+
warnings: PluginInitializationWarning[];
|
|
62
|
+
issues: SessionPluginIssue[];
|
|
63
|
+
/**
|
|
64
|
+
* Ends the session's use of its plugin copies: runs `ctx.onDispose`
|
|
65
|
+
* cleanup and stops further calls.
|
|
66
|
+
*/
|
|
67
|
+
release: () => Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export type PluginStatusListener = (status: PluginStatusRecord) => void;
|
|
70
|
+
/** The name a plugin is known by before its module is imported. */
|
|
71
|
+
export declare function derivePluginNameFromPath(pluginPath: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Tracks plugins for the whole process and hands each session a guarded copy
|
|
74
|
+
* of the plugins it enabled. Each copy runs in its own worker thread, so
|
|
75
|
+
* module state is per session and plugin code never runs on the host's main
|
|
76
|
+
* thread. Every import, setup, hook, tool, command, rule, and message-builder
|
|
77
|
+
* call is wrapped with a timeout and error capture, and the result is
|
|
78
|
+
* recorded per plugin so failures are visible instead of silently dropping
|
|
79
|
+
* the plugin's tools.
|
|
80
|
+
*/
|
|
81
|
+
export declare class PluginRegistry {
|
|
82
|
+
private readonly entries;
|
|
83
|
+
private readonly listeners;
|
|
84
|
+
private logger;
|
|
85
|
+
private readonly defaults;
|
|
86
|
+
private readonly failureThreshold;
|
|
87
|
+
constructor(options?: PluginRegistryOptions);
|
|
88
|
+
setLogger(logger: BasicLogger | undefined): void;
|
|
89
|
+
subscribe(listener: PluginStatusListener): () => void;
|
|
90
|
+
list(): PluginStatusRecord[];
|
|
91
|
+
get(nameOrPath: string): PluginStatusRecord[];
|
|
92
|
+
/**
|
|
93
|
+
* Re-validates the matching plugins' current code in throwaway workers and
|
|
94
|
+
* resets their status. Sessions started afterwards use the new code;
|
|
95
|
+
* running sessions keep the copy they set up, which stays callable unless
|
|
96
|
+
* the re-import fails (the plugin is then turned off for every session,
|
|
97
|
+
* failing closed).
|
|
98
|
+
*/
|
|
99
|
+
reload(nameOrPath: string): Promise<PluginStatusRecord[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Loads each plugin in a throwaway worker without attaching it to a
|
|
102
|
+
* session, so the Hub can discover plugins at startup and report status
|
|
103
|
+
* (including import errors) before any session exists.
|
|
104
|
+
*/
|
|
105
|
+
preload(input: Pick<PluginSessionLoadInput, "pluginPaths" | "disabledPluginPaths" | "discoveryFailures" | "exportName" | "importTimeoutMs">): Promise<PluginStatusRecord[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Each plugin loads in its own worker for this session, and the copy
|
|
108
|
+
* handed to the session is a proxy whose calls go to that worker. The host
|
|
109
|
+
* never imports plugin code. Every setup, hook, tool, command, rule, and
|
|
110
|
+
* message-builder call is wrapped with a timeout and error capture, and
|
|
111
|
+
* the result is recorded per plugin.
|
|
112
|
+
*/
|
|
113
|
+
loadForSession(input: PluginSessionLoadInput): Promise<PluginSessionLoadResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Every worker imports the module fresh, so new code needs no host
|
|
116
|
+
* re-import. A source change (or re-enabling) still starts a new import
|
|
117
|
+
* id: the plugin gets a clean slate, and copies of the old code go stale.
|
|
118
|
+
*/
|
|
119
|
+
private refreshEntry;
|
|
120
|
+
private startWorkerCopy;
|
|
121
|
+
/** Re-validates a plugin's current code in a throwaway worker. */
|
|
122
|
+
private reloadEntry;
|
|
123
|
+
private staleIssue;
|
|
124
|
+
/**
|
|
125
|
+
* Records discovery failures and settings-disabled plugins. Settings-
|
|
126
|
+
* disabled plugins the session would otherwise use are reported as issues
|
|
127
|
+
* with `reason: "settings"`. Returns the entries that failed discovery.
|
|
128
|
+
*/
|
|
129
|
+
private recordDiscovery;
|
|
130
|
+
private isEnabledForSession;
|
|
131
|
+
private policyIssue;
|
|
132
|
+
private resolveTimeouts;
|
|
133
|
+
private match;
|
|
134
|
+
private ensureEntry;
|
|
135
|
+
private wrapForSession;
|
|
136
|
+
private runSetup;
|
|
137
|
+
private wrapHooks;
|
|
138
|
+
private wrapTool;
|
|
139
|
+
private wrapCommand;
|
|
140
|
+
/** A failing rule contributes no text rather than breaking the prompt. */
|
|
141
|
+
private wrapRule;
|
|
142
|
+
/** A failing builder leaves the message unchanged. */
|
|
143
|
+
private wrapMessageBuilder;
|
|
144
|
+
/**
|
|
145
|
+
* Runs one plugin call with a timeout, records the outcome against the
|
|
146
|
+
* plugin, and rethrows failures.
|
|
147
|
+
*/
|
|
148
|
+
private guardedCall;
|
|
149
|
+
/**
|
|
150
|
+
* Whether a session's copy may still be called: the plugin is not turned
|
|
151
|
+
* off, its setup did not fail, and its session has not ended.
|
|
152
|
+
*/
|
|
153
|
+
private isUsable;
|
|
154
|
+
private assertUsable;
|
|
155
|
+
private releaseInstance;
|
|
156
|
+
private recordFailure;
|
|
157
|
+
private setState;
|
|
158
|
+
private warnIfSlow;
|
|
159
|
+
private log;
|
|
160
|
+
private toStatus;
|
|
161
|
+
private toIssue;
|
|
162
|
+
private toInitializationFailure;
|
|
163
|
+
}
|
|
164
|
+
/** One-line, user-facing description of a plugin a session cannot fully use. */
|
|
165
|
+
export declare function formatSessionPluginIssue(issue: SessionPluginIssue): string;
|
|
166
|
+
/**
|
|
167
|
+
* The registry shared by every session in this process. The Hub daemon reads
|
|
168
|
+
* it for `plugins.*` requests and to attribute stray plugin errors.
|
|
169
|
+
*/
|
|
170
|
+
export declare function getProcessPluginRegistry(): PluginRegistry;
|
|
171
|
+
/** @internal Test hook. */
|
|
172
|
+
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
|
|
@@ -74,9 +106,23 @@ export declare function selectBootstrapCandidate(options: {
|
|
|
74
106
|
file: string;
|
|
75
107
|
} | {
|
|
76
108
|
sourcePath: string;
|
|
77
|
-
};
|
|
109
|
+
} | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* @internal Test hook: behave as a host that ships no bootstrap. Tests run
|
|
112
|
+
* from source, where the `.ts` bootstrap always resolves.
|
|
113
|
+
*/
|
|
114
|
+
export declare function setPluginBootstrapUnavailableForTests(unavailable: boolean): void;
|
|
115
|
+
/** This build ships no `plugin-sandbox-bootstrap.js`, so no plugin can run. */
|
|
116
|
+
export declare class PluginBootstrapMissingError extends Error {
|
|
117
|
+
constructor();
|
|
118
|
+
}
|
|
78
119
|
export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{
|
|
79
120
|
extensions: AgentConfig["extensions"];
|
|
80
121
|
pluginPaths: string[];
|
|
122
|
+
/** Plugins the `policy` turned off; their setup did not run. */
|
|
123
|
+
disabledByPolicy: Array<{
|
|
124
|
+
pluginPath: string;
|
|
125
|
+
name: string;
|
|
126
|
+
}>;
|
|
81
127
|
shutdown: () => Promise<void>;
|
|
82
128
|
} & PluginLoadDiagnostics>;
|