import type { AgentConfig, PluginSetupContext, WorkspaceInfo } from "@cline/shared"; import type { PluginLoadDiagnostics } from "./plugin-load-report"; import type { PluginTargeting } from "./plugin-targeting"; export type SandboxedPluginSetupContext = Pick; export interface PluginSandboxOptions extends PluginTargeting { pluginPaths: string[]; exportName?: string; /** * Max wall time for plugin module imports. Defaults to 4000 ms; falls back * to the `CLINE_PLUGIN_IMPORT_TIMEOUT_MS` env var when this option is not * set, allowing slower hosts (Windows cold-start, CI without warm caches) * to raise the ceiling without touching code. */ importTimeoutMs?: number; hookTimeoutMs?: number; contributionTimeoutMs?: number; onEvent?: (event: { name: string; payload?: unknown; }) => void; /** * The session's working directory. Forwarded to the sandbox subprocess so * that `process.cwd()` returns the correct path inside the sandbox even * when `--cwd` was passed without calling `process.chdir()` on the host. */ cwd?: string; /** * Structured workspace and git metadata (branch, commit, remotes) generated * at session startup. Forwarded to plugins via PluginSetupCtx.workspaceInfo * so they can inspect git state without running their own commands. */ workspaceInfo?: WorkspaceInfo; session?: SandboxedPluginSetupContext["session"]; client?: SandboxedPluginSetupContext["client"]; user?: SandboxedPluginSetupContext["user"]; /** Enables a logger bridge that forwards sandbox log calls to the host. */ logger?: SandboxedPluginSetupContext["logger"]; /** * Enables the telemetry bridge (`ctx.telemetry`) for sandboxed plugins. * Set only when the host has a live telemetry service to route * `plugin_telemetry` events into, so plugin feature-detection of * `ctx.telemetry` means "someone is listening" in both execution modes. */ telemetryAvailable?: boolean; } /** * Pick the bootstrap the sandbox subprocess should run. * * Sibling compiled candidates always match the running host build, so they * win. When the host runs from source (the `.ts` bootstrap exists next to * this module), the sandbox must run that SAME source bootstrap: the * wrapper/executable fallbacks locate compiled bootstraps from a separately * installed CLI package (e.g. a published version in the package-manager * cache), and mixing that code with a source host silently breaks plugin * loading because its module resolution points at the other installation's * layout. Those fallbacks exist only for compiled hosts * (`bun build --compile`) where import.meta points inside the binary and no * sibling file exists on real disk. */ export declare function selectBootstrapCandidate(options: { siblingCandidates: string[]; sourceBootstrapPath: string; installedCandidates: Array; exists?: (path: string) => boolean; }): { file: string; } | { sourcePath: string; }; export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{ extensions: AgentConfig["extensions"]; pluginPaths: string[]; shutdown: () => Promise; } & PluginLoadDiagnostics>;