@sctg/cline-shared 3.84.0-beta.20260524130712

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.
Files changed (83) hide show
  1. package/README.md +47 -0
  2. package/dist/agent.d.ts +388 -0
  3. package/dist/agents/index.d.ts +1 -0
  4. package/dist/agents/types.d.ts +967 -0
  5. package/dist/automation/index.d.ts +3 -0
  6. package/dist/automation/index.js +65 -0
  7. package/dist/automation/schemas.d.ts +89 -0
  8. package/dist/automation/types.d.ts +151 -0
  9. package/dist/connectors/events.d.ts +93 -0
  10. package/dist/connectors/options.d.ts +174 -0
  11. package/dist/cron/cron-spec-types.d.ts +94 -0
  12. package/dist/cron/index.d.ts +1 -0
  13. package/dist/db/index.d.ts +2 -0
  14. package/dist/db/index.js +80 -0
  15. package/dist/db/sqlite-db.d.ts +24 -0
  16. package/dist/dispose.d.ts +13 -0
  17. package/dist/extensions/context.d.ts +76 -0
  18. package/dist/extensions/contribution-registry.d.ts +195 -0
  19. package/dist/extensions/plugin.d.ts +1 -0
  20. package/dist/hooks/contracts.d.ts +9 -0
  21. package/dist/hooks/events.d.ts +194 -0
  22. package/dist/hub.d.ts +470 -0
  23. package/dist/index.browser.d.ts +61 -0
  24. package/dist/index.browser.js +76 -0
  25. package/dist/index.d.ts +69 -0
  26. package/dist/index.js +163 -0
  27. package/dist/llms/ai-sdk-format.d.ts +55 -0
  28. package/dist/llms/gateway.d.ts +145 -0
  29. package/dist/llms/messages.d.ts +149 -0
  30. package/dist/llms/model-info.d.ts +120 -0
  31. package/dist/llms/reasoning-effort.d.ts +21 -0
  32. package/dist/llms/requests.d.ts +2 -0
  33. package/dist/llms/tokens.d.ts +7 -0
  34. package/dist/llms/tools.d.ts +86 -0
  35. package/dist/logging/logger.d.ts +37 -0
  36. package/dist/parse/error.d.ts +2 -0
  37. package/dist/parse/headers/utils.d.ts +1 -0
  38. package/dist/parse/json.d.ts +3 -0
  39. package/dist/parse/shell.d.ts +2 -0
  40. package/dist/parse/string.d.ts +4 -0
  41. package/dist/parse/time.d.ts +9 -0
  42. package/dist/parse/zod.d.ts +12 -0
  43. package/dist/prompt/cline.d.ts +24 -0
  44. package/dist/prompt/format.d.ts +11 -0
  45. package/dist/prompt/system.d.ts +2 -0
  46. package/dist/remote-config/artifact-store.d.ts +13 -0
  47. package/dist/remote-config/blob-storage.d.ts +47 -0
  48. package/dist/remote-config/bundle.d.ts +136 -0
  49. package/dist/remote-config/constants.d.ts +5 -0
  50. package/dist/remote-config/index.d.ts +9 -0
  51. package/dist/remote-config/index.js +76 -0
  52. package/dist/remote-config/materializer.d.ts +4 -0
  53. package/dist/remote-config/paths.d.ts +10 -0
  54. package/dist/remote-config/runtime.d.ts +20 -0
  55. package/dist/remote-config/schema.d.ts +408 -0
  56. package/dist/remote-config/telemetry.d.ts +9 -0
  57. package/dist/rpc/index.d.ts +5 -0
  58. package/dist/rpc/runtime.d.ts +322 -0
  59. package/dist/rpc/team-progress.d.ts +53 -0
  60. package/dist/runtime/build-env.d.ts +13 -0
  61. package/dist/runtime/cline-environment.d.ts +17 -0
  62. package/dist/runtime/hub-daemon-env.d.ts +2 -0
  63. package/dist/services/telemetry-config.d.ts +6 -0
  64. package/dist/services/telemetry.d.ts +133 -0
  65. package/dist/session/hook-context.d.ts +12 -0
  66. package/dist/session/index.d.ts +1 -0
  67. package/dist/session/records.d.ts +31 -0
  68. package/dist/session/runtime-config.d.ts +26 -0
  69. package/dist/session/runtime-env.d.ts +8 -0
  70. package/dist/session/workspace.d.ts +28 -0
  71. package/dist/storage/index.d.ts +2 -0
  72. package/dist/storage/index.js +1 -0
  73. package/dist/storage/path-resolution.d.ts +11 -0
  74. package/dist/storage/paths.d.ts +86 -0
  75. package/dist/team/index.d.ts +2 -0
  76. package/dist/team/schema.d.ts +411 -0
  77. package/dist/team/types.d.ts +196 -0
  78. package/dist/tools/create.d.ts +22 -0
  79. package/dist/types/auth.d.ts +20 -0
  80. package/dist/types/index.d.ts +2 -0
  81. package/dist/types/vcr.d.ts +14 -0
  82. package/dist/vcr.d.ts +41 -0
  83. package/package.json +63 -0
@@ -0,0 +1,80 @@
1
+ var V=Object.defineProperty;var X=(x)=>x;function Z(x,f){this[x]=X.bind(null,f)}var S=(x,f)=>{for(var j in f)V(x,j,{get:f[j],enumerable:!0,configurable:!0,set:Z.bind(f,j)})};import{mkdirSync as $}from"node:fs";import{createRequire as H}from"node:module";import{dirname as W}from"node:path";function J(x){if(x instanceof Error)return x.message;return String(x)}function K(x){if(x&&typeof x==="object"&&"code"in x&&typeof x.code==="string")return x.code;return""}var G=3,U=50;function D(){return new Date().toISOString()}function Q(x){return x?1:0}function I(x){return typeof x==="string"?x:""}function N(x){if(typeof x!=="string")return;let f=x.trim();return f.length>0?f:void 0}function A(x){return x===1||x===!0}function L(x){if(x<=0)return;try{let f=new SharedArrayBuffer(4),j=new Int32Array(f);Atomics.wait(j,0,0,x)}catch{}}function M(x){if(!x||typeof x!=="object")return!1;let f=J(x),j=K(x);return j==="SQLITE_BUSY"||j==="SQLITE_LOCKED"||f.includes("SQLITE_BUSY")||f.includes("SQLITE_LOCKED")||f.includes("database is locked")}function z(x){let f=0;for(;;)try{return x()}catch(j){if(!M(j)||f>=G)throw j;f+=1,L(U*2**(f-1))}}function P(x){return{prepare:(f)=>{let j=x.query(f);return{run:(...k)=>z(()=>j.run(...k)),get:(...k)=>z(()=>j.get(...k)),all:(...k)=>z(()=>j.all(...k))}},exec:(f)=>z(()=>x.exec(f)),close:()=>x.close?.()}}function Y(x){return{prepare:(f)=>{let j=x.prepare(f);return{run:(...k)=>z(()=>j.run(...k)),get:(...k)=>z(()=>j.get(...k)??null),all:(...k)=>z(()=>j.all(...k))}},exec:(f)=>z(()=>x.exec(f)),close:()=>x.close?.()}}function C(x){$(W(x),{recursive:!0});let f=H(import.meta.url);if(typeof globalThis.Bun<"u"){let{Database:k}=f("bun:sqlite");return P(new k(x,{create:!0}))}let j=process.emitWarning;process.emitWarning=(k,...O)=>{if((typeof k==="string"?k:k?.message??"").includes("SQLite"))return;return j.call(process,k,...O)};try{let{DatabaseSync:k}=f(["node",":sqlite"].join(""));return Y(new k(x))}finally{process.emitWarning=j}}var c=[`CREATE TABLE IF NOT EXISTS sessions (
2
+ session_id TEXT PRIMARY KEY,
3
+ source TEXT NOT NULL,
4
+ pid INTEGER NOT NULL,
5
+ started_at TEXT NOT NULL,
6
+ ended_at TEXT,
7
+ exit_code INTEGER,
8
+ status TEXT NOT NULL,
9
+ status_lock INTEGER NOT NULL DEFAULT 0,
10
+ interactive INTEGER NOT NULL,
11
+ provider TEXT NOT NULL,
12
+ model TEXT NOT NULL,
13
+ cwd TEXT NOT NULL,
14
+ workspace_root TEXT NOT NULL,
15
+ team_name TEXT,
16
+ enable_tools INTEGER NOT NULL,
17
+ enable_spawn INTEGER NOT NULL,
18
+ enable_teams INTEGER NOT NULL,
19
+ parent_session_id TEXT,
20
+ parent_agent_id TEXT,
21
+ agent_id TEXT,
22
+ conversation_id TEXT,
23
+ is_subagent INTEGER NOT NULL DEFAULT 0,
24
+ prompt TEXT,
25
+ metadata_json TEXT,
26
+ transcript_path TEXT NOT NULL DEFAULT '',
27
+ hook_path TEXT NOT NULL,
28
+ messages_path TEXT,
29
+ updated_at TEXT NOT NULL
30
+ );`,`CREATE TABLE IF NOT EXISTS subagent_spawn_queue (
31
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
32
+ root_session_id TEXT NOT NULL,
33
+ parent_agent_id TEXT NOT NULL,
34
+ task TEXT,
35
+ system_prompt TEXT,
36
+ created_at TEXT NOT NULL,
37
+ consumed_at TEXT
38
+ );`,`CREATE TABLE IF NOT EXISTS schedules (
39
+ schedule_id TEXT PRIMARY KEY,
40
+ name TEXT NOT NULL,
41
+ cron_pattern TEXT NOT NULL,
42
+ prompt TEXT NOT NULL,
43
+ provider TEXT NOT NULL,
44
+ model TEXT NOT NULL,
45
+ mode TEXT NOT NULL DEFAULT 'act',
46
+ workspace_root TEXT,
47
+ cwd TEXT,
48
+ system_prompt TEXT,
49
+ max_iterations INTEGER,
50
+ timeout_seconds INTEGER,
51
+ max_parallel INTEGER NOT NULL DEFAULT 1,
52
+ enabled INTEGER NOT NULL DEFAULT 1,
53
+ created_at TEXT NOT NULL,
54
+ updated_at TEXT NOT NULL,
55
+ last_run_at TEXT,
56
+ next_run_at TEXT,
57
+ claim_token TEXT,
58
+ claim_started_at TEXT,
59
+ claim_until_at TEXT,
60
+ created_by TEXT,
61
+ tags TEXT,
62
+ metadata_json TEXT
63
+ );`,`CREATE TABLE IF NOT EXISTS schedule_executions (
64
+ execution_id TEXT PRIMARY KEY,
65
+ schedule_id TEXT NOT NULL,
66
+ session_id TEXT,
67
+ triggered_at TEXT NOT NULL,
68
+ started_at TEXT,
69
+ ended_at TEXT,
70
+ status TEXT NOT NULL,
71
+ exit_code INTEGER,
72
+ error_message TEXT,
73
+ iterations INTEGER,
74
+ tokens_used INTEGER,
75
+ cost_usd REAL,
76
+ FOREIGN KEY (schedule_id) REFERENCES schedules(schedule_id) ON DELETE CASCADE,
77
+ FOREIGN KEY (session_id) REFERENCES sessions(session_id) ON DELETE SET NULL
78
+ );`,`CREATE INDEX IF NOT EXISTS idx_schedule_executions_schedule
79
+ ON schedule_executions(schedule_id, triggered_at DESC);`,`CREATE INDEX IF NOT EXISTS idx_schedules_next_run
80
+ ON schedules(enabled, next_run_at);`],T=[{table:"sessions",column:"workspace_root",sql:"ALTER TABLE sessions ADD COLUMN workspace_root TEXT;"},{table:"sessions",column:"parent_session_id",sql:"ALTER TABLE sessions ADD COLUMN parent_session_id TEXT;"},{table:"sessions",column:"parent_agent_id",sql:"ALTER TABLE sessions ADD COLUMN parent_agent_id TEXT;"},{table:"sessions",column:"agent_id",sql:"ALTER TABLE sessions ADD COLUMN agent_id TEXT;"},{table:"sessions",column:"conversation_id",sql:"ALTER TABLE sessions ADD COLUMN conversation_id TEXT;"},{table:"sessions",column:"is_subagent",sql:"ALTER TABLE sessions ADD COLUMN is_subagent INTEGER NOT NULL DEFAULT 0;"},{table:"sessions",column:"messages_path",sql:"ALTER TABLE sessions ADD COLUMN messages_path TEXT;"},{table:"sessions",column:"metadata_json",sql:"ALTER TABLE sessions ADD COLUMN metadata_json TEXT;"},{table:"sessions",column:"transcript_path",sql:"ALTER TABLE sessions ADD COLUMN transcript_path TEXT NOT NULL DEFAULT '';"},{table:"schedules",column:"claim_token",sql:"ALTER TABLE schedules ADD COLUMN claim_token TEXT;"},{table:"schedules",column:"claim_started_at",sql:"ALTER TABLE schedules ADD COLUMN claim_started_at TEXT;"},{table:"schedules",column:"claim_until_at",sql:"ALTER TABLE schedules ADD COLUMN claim_until_at TEXT;"}];function _(x,f){return new Set(x.prepare(`PRAGMA table_info(${f});`).all().map((j)=>j.name))}function B(x,f={}){x.exec("PRAGMA journal_mode = WAL;"),x.exec("PRAGMA busy_timeout = 5000;");for(let O of c)x.exec(O);if(!f.includeLegacyMigrations)return;let j=new Map,k=(O)=>{let F=j.get(O);if(!F)F=_(x,O),j.set(O,F);return F};for(let O of T)if(!k(O.table).has(O.column)){if(x.exec(O.sql),O.column==="workspace_root")x.exec("UPDATE sessions SET workspace_root = cwd WHERE workspace_root IS NULL OR workspace_root = '';");j.delete(O.table)}}export{Q as toBoolInt,D as nowIso,C as loadSqliteDb,B as ensureSessionSchema,I as asString,N as asOptionalString,A as asBool};
@@ -0,0 +1,24 @@
1
+ export type SqliteStatement = {
2
+ run: (...params: unknown[]) => {
3
+ changes?: number;
4
+ };
5
+ get: (...params: unknown[]) => Record<string, unknown> | null;
6
+ all: (...params: unknown[]) => Record<string, unknown>[];
7
+ };
8
+ export type SqliteDb = {
9
+ prepare: (sql: string) => SqliteStatement;
10
+ exec: (sql: string) => void;
11
+ close?: () => void;
12
+ };
13
+ export declare function nowIso(): string;
14
+ export declare function toBoolInt(value: boolean): number;
15
+ export declare function asString(value: unknown): string;
16
+ export declare function asOptionalString(value: unknown): string | undefined;
17
+ export declare function asBool(value: unknown): boolean;
18
+ export declare function isSqliteBusyError(error: unknown): boolean;
19
+ export declare function withSqliteBusyRetry<T>(operation: () => T): T;
20
+ export declare function loadSqliteDb(filePath: string): SqliteDb;
21
+ export interface SessionSchemaOptions {
22
+ includeLegacyMigrations?: boolean;
23
+ }
24
+ export declare function ensureSessionSchema(db: SqliteDb, options?: SessionSchemaOptions): void;
@@ -0,0 +1,13 @@
1
+ export type Disposable = (() => void | Promise<void>) | {
2
+ dispose: () => void | Promise<void>;
3
+ };
4
+ /**
5
+ * Register a disposable to be cleaned up when `disposeAll()` is called.
6
+ * Accepts either a function or an object with a `dispose` method.
7
+ */
8
+ export declare function registerDisposable(disposable: Disposable): void;
9
+ /**
10
+ * Dispose all registered disposables in registration order.
11
+ * Errors from individual disposables are suppressed so all run.
12
+ */
13
+ export declare function disposeAll(): Promise<void>;
@@ -0,0 +1,76 @@
1
+ import type { BasicLogger } from "../logging/logger";
2
+ import type { ITelemetryService } from "../services/telemetry";
3
+ import type { WorkspaceInfo } from "../session/workspace";
4
+ import type { AgentExtensionAutomationContext, AgentExtensionSessionContext } from "./contribution-registry";
5
+ /**
6
+ * The IDE or client surface the user is running Cline from.
7
+ */
8
+ export type ClientName = "cline-vscode" | "cline-jetbrains" | "cline-cli" | "cline-sdk" | "cline-kanban" | "cline-acp" | "cline-platform" | (string & {});
9
+ /**
10
+ * Identity of the calling client (surface + version).
11
+ */
12
+ export interface ClientContext {
13
+ /** e.g. "cline-vscode", "cline-cli", "cline-sdk" */
14
+ name: ClientName;
15
+ /** Semver string, e.g. "3.12.0" */
16
+ version?: string;
17
+ }
18
+ /**
19
+ * Identity of the authenticated user.
20
+ */
21
+ export interface UserContext {
22
+ /** PostHog / analytics distinct ID */
23
+ distinctId?: string;
24
+ email?: string;
25
+ organizationId?: string;
26
+ }
27
+ /**
28
+ * Everything needed to describe the workspace and build the system prompt.
29
+ *
30
+ * Extends WorkspaceInfo (rootPath + git fields) with the additional fields
31
+ * required by buildClineSystemPrompt, so callers can spread a WorkspaceInfo
32
+ * and add only what they know.
33
+ */
34
+ export interface WorkspaceContext extends WorkspaceInfo {
35
+ /**
36
+ * Current working directory. May differ from rootPath in multi-root
37
+ * workspaces or when the user cd'd inside the workspace.
38
+ */
39
+ cwd?: string;
40
+ /** Human-readable workspace name shown in the system prompt */
41
+ workspaceName?: string;
42
+ /**
43
+ * Pre-serialized workspace metadata block that replaces {{CLINE_METADATA}}
44
+ * in the system prompt template.
45
+ */
46
+ metadata?: string;
47
+ /** Agent mode: "act" | "plan" | "yolo" */
48
+ mode?: string;
49
+ /** Additional rules/instructions injected into the system prompt */
50
+ rules?: string;
51
+ /** IDE display name, e.g. "VS Code", "JetBrains", "Terminal Shell" */
52
+ ide?: string;
53
+ /** Node process.platform string, e.g. "darwin", "win32", "linux" */
54
+ platform?: string;
55
+ }
56
+ /**
57
+ * Ambient runtime context carried alongside ProviderConfig.
58
+ *
59
+ * Captures who is calling (user + client), where they are (workspace),
60
+ * and which services to use for logging and telemetry. None of these
61
+ * belong in the LLM provider credential config.
62
+ */
63
+ export interface ExtensionContext {
64
+ user?: UserContext;
65
+ client?: ClientContext;
66
+ workspace?: WorkspaceContext;
67
+ /** Core session metadata forwarded into plugin setup context. */
68
+ session?: AgentExtensionSessionContext;
69
+ /**
70
+ * Host-provided automation ingress for plugins. Present when the session is
71
+ * started through a ClineCore instance with automation enabled.
72
+ */
73
+ automation?: AgentExtensionAutomationContext;
74
+ logger?: BasicLogger;
75
+ telemetry?: ITelemetryService;
76
+ }
@@ -0,0 +1,195 @@
1
+ import type { AgentRuntimeHooks, AgentTool } from "../agent";
2
+ import type { AutomationEventEnvelope } from "../cron";
3
+ import type { BasicLogger } from "../logging/logger";
4
+ import type { ITelemetryService } from "../services/telemetry";
5
+ import type { WorkspaceInfo } from "../session/workspace";
6
+ import type { ClientContext, UserContext } from "./context";
7
+ export interface AgentExtensionCommand {
8
+ name: string;
9
+ description?: string;
10
+ handler?: (input: string) => Promise<string> | string;
11
+ }
12
+ export interface AgentExtensionRule {
13
+ id: string;
14
+ content: string | (() => string | Promise<string>);
15
+ source?: string;
16
+ }
17
+ export interface AgentExtensionMessageBuilder<TMessage = unknown> {
18
+ name: string;
19
+ build: (message: TMessage) => TMessage | Promise<TMessage>;
20
+ }
21
+ export interface AgentExtensionProvider {
22
+ name: string;
23
+ description?: string;
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ export interface AgentExtensionAutomationEventType {
27
+ /** Normalized event type a plugin can emit, e.g. `github.pull_request.opened`. */
28
+ eventType: string;
29
+ /** Normalized source identifier, e.g. `github`, `linear`, or `local`. */
30
+ source: string;
31
+ description?: string;
32
+ attributesSchema?: Record<string, unknown>;
33
+ payloadSchema?: Record<string, unknown>;
34
+ examples?: AutomationEventEnvelope[];
35
+ metadata?: Record<string, unknown>;
36
+ }
37
+ export interface AgentExtensionAutomationContext {
38
+ /**
39
+ * Submit a normalized automation event to the host. Raw webhook or connector
40
+ * payloads should be translated into an `AutomationEventEnvelope` first.
41
+ */
42
+ ingestEvent: (event: AutomationEventEnvelope) => void | Promise<void>;
43
+ }
44
+ export interface AgentExtensionSessionContext {
45
+ /** Stable core session id for the root session that loaded the plugin. */
46
+ sessionId?: string;
47
+ }
48
+ /**
49
+ * API surface passed to an extension's `setup()` method.
50
+ *
51
+ * Use it to register the contributions the extension wants to make — tools,
52
+ * commands, message builders, providers, and automation event types. All
53
+ * registrations accumulate into the `ContributionRegistry` and are available to
54
+ * the host after `setup()` completes.
55
+ */
56
+ export interface AgentExtensionApi<TTool = AgentTool, TMessage = unknown> {
57
+ /** Register a tool the agent can invoke during its run. Requires the `tools` capability. */
58
+ registerTool: (tool: TTool) => void;
59
+ /** Register a slash command available in connected chat surfaces. Requires the `commands` capability. */
60
+ registerCommand: (command: AgentExtensionCommand) => void;
61
+ /** Register prompt rules included in the runtime system prompt. Requires the `rules` capability. */
62
+ registerRule: (rule: AgentExtensionRule) => void;
63
+ /** Register a named message builder for transforming messages before they are sent. Requires the `messageBuilders` capability. */
64
+ registerMessageBuilder: (builder: AgentExtensionMessageBuilder<TMessage>) => void;
65
+ /** Register a provider contribution (e.g. a custom model provider). Requires the `providers` capability. */
66
+ registerProvider: (provider: AgentExtensionProvider) => void;
67
+ /** Register a normalized automation event type the plugin can emit. Requires the `automationEvents` capability. */
68
+ registerAutomationEventType: (eventType: AgentExtensionAutomationEventType) => void;
69
+ }
70
+ export type AgentExtensionHooks = Partial<AgentRuntimeHooks>;
71
+ /**
72
+ * Session-scoped workspace context passed as the second argument to an
73
+ * extension's `setup(api, ctx)` method.
74
+ *
75
+ * These values are always sourced from the host session config — never from
76
+ * `process.cwd()`. Use them to resolve paths or build workspace-aware tool
77
+ * schemas at registration time.
78
+ *
79
+ * All fields are optional so `setup()` callers that do not have host context
80
+ * (e.g. unit tests) can omit them without breaking plugins.
81
+ */
82
+ export interface PluginSetupContext {
83
+ /**
84
+ * Core session metadata known before the first agent run starts.
85
+ * Agent-level ids such as `agentId` and `conversationId` are available on
86
+ * lifecycle hook contexts once SessionRuntime creates them.
87
+ */
88
+ session?: AgentExtensionSessionContext;
89
+ /** Host/client identity such as `cline-cli`, `cline-vscode`, or an SDK app. */
90
+ client?: ClientContext;
91
+ /** Authenticated user or organization identity when the host provides it. */
92
+ user?: UserContext;
93
+ /**
94
+ * Structured workspace and git metadata for the session. Contains
95
+ * `rootPath`, `hint`, `associatedRemoteUrls`, `latestGitCommitHash`, and
96
+ * `latestGitBranchName`. Use `rootPath` for workspace-relative paths and
97
+ * the git fields for branch-aware registration or commit attribution at
98
+ * setup time.
99
+ */
100
+ workspaceInfo?: WorkspaceInfo;
101
+ /**
102
+ * Automation ingress made available by hosts that enable ClineCore
103
+ * automation. Plugins should feature-detect this property so the same plugin
104
+ * can run in hosts that do not enable automation.
105
+ */
106
+ automation?: AgentExtensionAutomationContext;
107
+ /** Host-provided logger scoped to this session/plugin setup. */
108
+ logger?: BasicLogger;
109
+ /**
110
+ * Host-provided telemetry service when available in the current process.
111
+ *
112
+ * This service is intentionally not serialized across plugin sandbox process
113
+ * boundaries; sandboxed plugins should feature-detect this property and expect
114
+ * it to be undefined unless a future host adds an explicit telemetry bridge.
115
+ */
116
+ telemetry?: ITelemetryService;
117
+ }
118
+ declare const ExtensionCapabilityOptions: readonly ["hooks", "tools", "commands", "rules", "messageBuilders", "providers", "automationEvents"];
119
+ export type AgentExtensionCapability = (typeof ExtensionCapabilityOptions)[number];
120
+ export interface PluginManifest {
121
+ paths?: string[];
122
+ capabilities: AgentExtensionCapability[];
123
+ providerIds?: string[];
124
+ modelIds?: string[];
125
+ }
126
+ export interface AgentExtensionRegistry<TTool = AgentTool, TMessage = unknown> {
127
+ tools: TTool[];
128
+ commands: AgentExtensionCommand[];
129
+ rules: AgentExtensionRule[];
130
+ messageBuilder: AgentExtensionMessageBuilder<TMessage>[];
131
+ providers: AgentExtensionProvider[];
132
+ automationEventTypes: AgentExtensionAutomationEventType[];
133
+ }
134
+ /**
135
+ * Base shape for a plugin or extension that can be loaded into a
136
+ * `ContributionRegistry`.
137
+ *
138
+ * An extension declares what it does through its `manifest` (capabilities and
139
+ * hook stages) and implements the corresponding handler methods. The registry
140
+ * validates at setup time that every declared stage has a matching handler and
141
+ * that no undeclared handlers are present.
142
+ *
143
+ * Hook handler properties are typed `unknown` here so that the generic base
144
+ * interface stays free of agent-specific imports. Concrete extension types
145
+ * (e.g. `AgentExtension` in `@cline/agents`) narrow them to the correct
146
+ * context and return types.
147
+ */
148
+ export interface ContributionRegistryExtension<TTool = AgentTool, TMessage = unknown> {
149
+ type?: string;
150
+ /** Unique identifier for this extension, used in error messages and hook handler names. */
151
+ name: string;
152
+ /** Declares what capabilities and hook stages this extension uses. Validated before `setup()` runs. */
153
+ manifest: PluginManifest;
154
+ /** Indicates whether this extension is disabled. Disabled extensions are ignored during setup. */
155
+ disabled?: boolean;
156
+ /** Runtime-native hooks consumed directly by `@cline/agents`. */
157
+ hooks?: AgentExtensionHooks;
158
+ /**
159
+ * Called once during registry setup to register tools, commands, and other
160
+ * contributions.
161
+ *
162
+ * The optional second argument provides workspace context that is always
163
+ * sourced from the host session config — never from `process.cwd()`. Use
164
+ * `ctx.workspaceInfo?.rootPath` instead of `process.cwd()` or
165
+ * `import.meta.url` tricks when you need workspace-relative paths.
166
+ */
167
+ setup?: (api: AgentExtensionApi<TTool, TMessage>, ctx: PluginSetupContext) => void | Promise<void>;
168
+ }
169
+ export interface ContributionRegistryOptions<TExtension extends ContributionRegistryExtension<TTool, TMessage>, TTool = AgentTool, TMessage = unknown> {
170
+ extensions?: TExtension[];
171
+ /** Workspace context forwarded to each extension's `setup(api, ctx)` call. */
172
+ setupContext?: PluginSetupContext;
173
+ }
174
+ export declare function normalizePluginManifest(manifest: PluginManifest): PluginManifest;
175
+ export declare class ContributionRegistry<TExtension extends ContributionRegistryExtension<TTool, TMessage>, TTool = AgentTool, TMessage = unknown> {
176
+ private readonly extensions;
177
+ private readonly registry;
178
+ private normalized;
179
+ private phase;
180
+ private readonly setupContext;
181
+ constructor(options?: ContributionRegistryOptions<TExtension, TTool, TMessage>);
182
+ resolve(): void;
183
+ validate(): void;
184
+ setup(): Promise<void>;
185
+ activate(): void;
186
+ initialize(): Promise<void>;
187
+ isActivated(): boolean;
188
+ getRegistrySnapshot(): AgentExtensionRegistry<TTool, TMessage>;
189
+ getRegisteredTools(): TTool[];
190
+ getRegisteredRules(): AgentExtensionRule[];
191
+ getRegisteredAutomationEventTypes(): AgentExtensionAutomationEventType[];
192
+ getValidatedExtensions(): TExtension[];
193
+ }
194
+ export declare function createContributionRegistry<TExtension extends ContributionRegistryExtension<TTool, TMessage>, TTool = AgentTool, TMessage = unknown>(options?: ContributionRegistryOptions<TExtension, TTool, TMessage>): ContributionRegistry<TExtension, TTool, TMessage>;
195
+ export {};
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_FILE_EXTENSIONS: string[];
@@ -0,0 +1,9 @@
1
+ export interface HookControl {
2
+ cancel?: boolean;
3
+ review?: boolean;
4
+ context?: string;
5
+ overrideInput?: unknown;
6
+ systemPrompt?: string;
7
+ appendMessages?: unknown[];
8
+ replaceMessages?: unknown[];
9
+ }
@@ -0,0 +1,194 @@
1
+ import { z } from "zod";
2
+ import type { ToolCallRecord } from "../llms/tools";
3
+ import type { HookSessionContext } from "../session/hook-context";
4
+ import type { WorkspaceInfo } from "../session/workspace";
5
+ import type { HookControl } from "./contracts";
6
+ type AgentHookControl = Omit<HookControl, "appendMessages"> & {
7
+ systemPrompt?: string;
8
+ appendMessages?: unknown[];
9
+ };
10
+ export interface AgentHookRunStartPayload {
11
+ agentId: string;
12
+ conversationId: string;
13
+ parentAgentId: string | null;
14
+ userMessage: string;
15
+ }
16
+ export interface AgentHookToolCallStartPayload {
17
+ agentId: string;
18
+ conversationId: string;
19
+ parentAgentId: string | null;
20
+ iteration: number;
21
+ call: {
22
+ id: string;
23
+ name: string;
24
+ input: unknown;
25
+ };
26
+ }
27
+ export interface AgentHookToolCallEndPayload {
28
+ agentId: string;
29
+ conversationId: string;
30
+ parentAgentId: string | null;
31
+ iteration: number;
32
+ record: ToolCallRecord;
33
+ }
34
+ export interface AgentHookTurnEndPayload {
35
+ agentId: string;
36
+ conversationId: string;
37
+ parentAgentId: string | null;
38
+ iteration: number;
39
+ turn: unknown;
40
+ }
41
+ export interface AgentHookStopErrorPayload {
42
+ agentId: string;
43
+ conversationId: string;
44
+ parentAgentId: string | null;
45
+ iteration: number;
46
+ error: Error;
47
+ }
48
+ export interface AgentHookSessionShutdownPayload {
49
+ agentId: string;
50
+ conversationId: string;
51
+ parentAgentId: string | null;
52
+ reason?: string;
53
+ }
54
+ export declare const HookEventNameSchema: z.ZodEnum<{
55
+ tool_result: "tool_result";
56
+ agent_start: "agent_start";
57
+ agent_resume: "agent_resume";
58
+ agent_abort: "agent_abort";
59
+ agent_end: "agent_end";
60
+ agent_error: "agent_error";
61
+ tool_call: "tool_call";
62
+ prompt_submit: "prompt_submit";
63
+ pre_compact: "pre_compact";
64
+ session_shutdown: "session_shutdown";
65
+ }>;
66
+ export type HookEventName = z.infer<typeof HookEventNameSchema>;
67
+ export interface PreToolUseData {
68
+ toolName: string;
69
+ parameters: Record<string, string>;
70
+ }
71
+ export interface PostToolUseData {
72
+ toolName: string;
73
+ parameters: Record<string, string>;
74
+ result: string;
75
+ success: boolean;
76
+ executionTimeMs: number;
77
+ }
78
+ export interface UserPromptSubmitData {
79
+ prompt: string;
80
+ attachments: string[];
81
+ }
82
+ export interface TaskStartData {
83
+ taskMetadata: Record<string, string>;
84
+ }
85
+ export interface TaskResumeData {
86
+ taskMetadata: Record<string, string>;
87
+ previousState: Record<string, string>;
88
+ }
89
+ export interface TaskCancelData {
90
+ taskMetadata: Record<string, string>;
91
+ }
92
+ export interface TaskCompleteData {
93
+ taskMetadata: Record<string, string>;
94
+ }
95
+ export interface PreCompactData {
96
+ taskId: string;
97
+ ulid: string;
98
+ contextSize: number;
99
+ compactionStrategy: string;
100
+ previousApiReqIndex: number;
101
+ tokensIn: number;
102
+ tokensOut: number;
103
+ tokensInCache: number;
104
+ tokensOutCache: number;
105
+ deletedRangeStart: number;
106
+ deletedRangeEnd: number;
107
+ contextJsonPath: string;
108
+ contextRawPath: string;
109
+ }
110
+ export interface HookEventPayloadBase {
111
+ clineVersion: string;
112
+ hookName: HookEventName;
113
+ timestamp: string;
114
+ taskId: string;
115
+ sessionContext?: HookSessionContext;
116
+ workspaceRoots: string[];
117
+ /**
118
+ * Structured workspace and git metadata for the session.
119
+ *
120
+ * Contains `rootPath`, `hint`, `associatedRemoteUrls`,
121
+ * `latestGitCommitHash`, and `latestGitBranchName` — the same data as
122
+ * `workspaceRoots[0]` plus the git fields. Hook scripts can use this for
123
+ * branch-aware logic or commit attribution without running `git` themselves.
124
+ *
125
+ * `undefined` when the session has no workspace metadata (e.g. unit tests
126
+ * or sessions started without a `cwd`).
127
+ */
128
+ workspaceInfo?: WorkspaceInfo;
129
+ userId: string;
130
+ agent_id: string;
131
+ parent_agent_id: string | null;
132
+ preToolUse?: PreToolUseData | undefined;
133
+ postToolUse?: PostToolUseData | undefined;
134
+ userPromptSubmit?: UserPromptSubmitData | undefined;
135
+ taskStart?: TaskStartData | undefined;
136
+ taskResume?: TaskResumeData | undefined;
137
+ taskCancel?: TaskCancelData | undefined;
138
+ taskComplete?: TaskCompleteData | undefined;
139
+ preCompact?: PreCompactData | undefined;
140
+ }
141
+ export interface ToolCallHookPayload extends HookEventPayloadBase {
142
+ hookName: "tool_call";
143
+ iteration: number;
144
+ tool_call: {
145
+ id: string;
146
+ name: string;
147
+ input: unknown;
148
+ };
149
+ }
150
+ export interface ToolResultHookPayload extends HookEventPayloadBase {
151
+ hookName: "tool_result";
152
+ iteration: number;
153
+ tool_result: ToolCallRecord;
154
+ }
155
+ export interface AgentEndHookPayload extends HookEventPayloadBase {
156
+ hookName: "agent_end";
157
+ iteration: number;
158
+ turn?: unknown;
159
+ }
160
+ export interface AgentErrorHookPayload extends HookEventPayloadBase {
161
+ hookName: "agent_error";
162
+ iteration: number;
163
+ error: {
164
+ name: string;
165
+ message: string;
166
+ stack?: string;
167
+ };
168
+ }
169
+ export interface AgentStartHookPayload extends HookEventPayloadBase {
170
+ hookName: "agent_start";
171
+ }
172
+ export interface AgentResumeHookPayload extends HookEventPayloadBase {
173
+ hookName: "agent_resume";
174
+ }
175
+ export interface AgentAbortHookPayload extends HookEventPayloadBase {
176
+ hookName: "agent_abort";
177
+ reason?: string;
178
+ }
179
+ export interface PromptSubmitHookPayload extends HookEventPayloadBase {
180
+ hookName: "prompt_submit";
181
+ }
182
+ export interface PreCompactHookPayload extends HookEventPayloadBase {
183
+ hookName: "pre_compact";
184
+ preCompact: PreCompactData;
185
+ }
186
+ export interface SessionShutdownHookPayload extends HookEventPayloadBase {
187
+ hookName: "session_shutdown";
188
+ reason?: string;
189
+ }
190
+ export type HookEventPayload = ToolCallHookPayload | ToolResultHookPayload | AgentStartHookPayload | AgentResumeHookPayload | AgentAbortHookPayload | PromptSubmitHookPayload | PreCompactHookPayload | AgentEndHookPayload | AgentErrorHookPayload | SessionShutdownHookPayload;
191
+ export declare const HookEventPayloadSchema: z.ZodType<unknown>;
192
+ export declare function parseHookEventPayload(value: unknown): HookEventPayload | undefined;
193
+ export type SubprocessHookControl = AgentHookControl;
194
+ export {};