@paperclipai/plugin-sdk 2026.3.17-canary.0
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/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/bundlers.d.ts +57 -0
- package/dist/bundlers.d.ts.map +1 -0
- package/dist/bundlers.js +105 -0
- package/dist/bundlers.js.map +1 -0
- package/dist/define-plugin.d.ts +218 -0
- package/dist/define-plugin.d.ts.map +1 -0
- package/dist/define-plugin.js +85 -0
- package/dist/define-plugin.js.map +1 -0
- package/dist/dev-cli.d.ts +3 -0
- package/dist/dev-cli.d.ts.map +1 -0
- package/dist/dev-cli.js +49 -0
- package/dist/dev-cli.js.map +1 -0
- package/dist/dev-server.d.ts +34 -0
- package/dist/dev-server.d.ts.map +1 -0
- package/dist/dev-server.js +194 -0
- package/dist/dev-server.js.map +1 -0
- package/dist/host-client-factory.d.ts +229 -0
- package/dist/host-client-factory.d.ts.map +1 -0
- package/dist/host-client-factory.js +353 -0
- package/dist/host-client-factory.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +881 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +297 -0
- package/dist/protocol.js.map +1 -0
- package/dist/testing.d.ts +63 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +700 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +982 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/components.d.ts +257 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +97 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/hooks.d.ts +120 -0
- package/dist/ui/hooks.d.ts.map +1 -0
- package/dist/ui/hooks.js +148 -0
- package/dist/ui/hooks.js.map +1 -0
- package/dist/ui/index.d.ts +50 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +48 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/runtime.d.ts +3 -0
- package/dist/ui/runtime.d.ts.map +1 -0
- package/dist/ui/runtime.js +30 -0
- package/dist/ui/runtime.js.map +1 -0
- package/dist/ui/types.d.ts +308 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +17 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/worker-rpc-host.d.ts +127 -0
- package/dist/worker-rpc-host.d.ts.map +1 -0
- package/dist/worker-rpc-host.js +941 -0
- package/dist/worker-rpc-host.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 message types and protocol helpers for the host ↔ worker IPC
|
|
3
|
+
* channel.
|
|
4
|
+
*
|
|
5
|
+
* The Paperclip plugin runtime uses JSON-RPC 2.0 over stdio to communicate
|
|
6
|
+
* between the host process and each plugin worker process. This module defines:
|
|
7
|
+
*
|
|
8
|
+
* - Core JSON-RPC 2.0 envelope types (request, response, notification, error)
|
|
9
|
+
* - Standard and plugin-specific error codes
|
|
10
|
+
* - Typed method maps for host→worker and worker→host calls
|
|
11
|
+
* - Helper functions for creating well-formed messages
|
|
12
|
+
*
|
|
13
|
+
* @see PLUGIN_SPEC.md §12.1 — Process Model
|
|
14
|
+
* @see PLUGIN_SPEC.md §13 — Host-Worker Protocol
|
|
15
|
+
* @see https://www.jsonrpc.org/specification
|
|
16
|
+
*/
|
|
17
|
+
import type { PaperclipPluginManifestV1, PluginLauncherBounds, PluginLauncherRenderContextSnapshot, PluginStateScopeKind, Company, Project, Issue, IssueComment, IssueDocument, IssueDocumentSummary, Agent, Goal } from "@paperclipai/shared";
|
|
18
|
+
export type { PluginLauncherRenderContextSnapshot } from "@paperclipai/shared";
|
|
19
|
+
import type { PluginEvent, PluginJobContext, PluginWorkspace, ToolRunContext, ToolResult } from "./types.js";
|
|
20
|
+
import type { PluginHealthDiagnostics, PluginConfigValidationResult, PluginWebhookInput } from "./define-plugin.js";
|
|
21
|
+
/** The JSON-RPC protocol version. Always `"2.0"`. */
|
|
22
|
+
export declare const JSONRPC_VERSION: "2.0";
|
|
23
|
+
/**
|
|
24
|
+
* A unique request identifier. JSON-RPC 2.0 allows strings or numbers;
|
|
25
|
+
* we use strings (UUIDs or monotonic counters) for all Paperclip messages.
|
|
26
|
+
*/
|
|
27
|
+
export type JsonRpcId = string | number;
|
|
28
|
+
/**
|
|
29
|
+
* A JSON-RPC 2.0 request message.
|
|
30
|
+
*
|
|
31
|
+
* The host sends requests to the worker (or vice versa) and expects a
|
|
32
|
+
* matching response with the same `id`.
|
|
33
|
+
*/
|
|
34
|
+
export interface JsonRpcRequest<TMethod extends string = string, TParams = unknown> {
|
|
35
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
36
|
+
/** Unique request identifier. Must be echoed in the response. */
|
|
37
|
+
readonly id: JsonRpcId;
|
|
38
|
+
/** The RPC method name to invoke. */
|
|
39
|
+
readonly method: TMethod;
|
|
40
|
+
/** Structured parameters for the method call. */
|
|
41
|
+
readonly params: TParams;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A JSON-RPC 2.0 success response.
|
|
45
|
+
*/
|
|
46
|
+
export interface JsonRpcSuccessResponse<TResult = unknown> {
|
|
47
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
48
|
+
/** Echoed request identifier. */
|
|
49
|
+
readonly id: JsonRpcId;
|
|
50
|
+
/** The method return value. */
|
|
51
|
+
readonly result: TResult;
|
|
52
|
+
readonly error?: never;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A JSON-RPC 2.0 error object embedded in an error response.
|
|
56
|
+
*/
|
|
57
|
+
export interface JsonRpcError<TData = unknown> {
|
|
58
|
+
/** Machine-readable error code. */
|
|
59
|
+
readonly code: number;
|
|
60
|
+
/** Human-readable error message. */
|
|
61
|
+
readonly message: string;
|
|
62
|
+
/** Optional structured error data. */
|
|
63
|
+
readonly data?: TData;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A JSON-RPC 2.0 error response.
|
|
67
|
+
*/
|
|
68
|
+
export interface JsonRpcErrorResponse<TData = unknown> {
|
|
69
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
70
|
+
/** Echoed request identifier. */
|
|
71
|
+
readonly id: JsonRpcId | null;
|
|
72
|
+
readonly result?: never;
|
|
73
|
+
/** The error object. */
|
|
74
|
+
readonly error: JsonRpcError<TData>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A JSON-RPC 2.0 response — either success or error.
|
|
78
|
+
*/
|
|
79
|
+
export type JsonRpcResponse<TResult = unknown, TData = unknown> = JsonRpcSuccessResponse<TResult> | JsonRpcErrorResponse<TData>;
|
|
80
|
+
/**
|
|
81
|
+
* A JSON-RPC 2.0 notification (a request with no `id`).
|
|
82
|
+
*
|
|
83
|
+
* Notifications are fire-and-forget — no response is expected.
|
|
84
|
+
*/
|
|
85
|
+
export interface JsonRpcNotification<TMethod extends string = string, TParams = unknown> {
|
|
86
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
87
|
+
readonly id?: never;
|
|
88
|
+
/** The notification method name. */
|
|
89
|
+
readonly method: TMethod;
|
|
90
|
+
/** Structured parameters for the notification. */
|
|
91
|
+
readonly params: TParams;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Any well-formed JSON-RPC 2.0 message (request, response, or notification).
|
|
95
|
+
*/
|
|
96
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse | JsonRpcNotification;
|
|
97
|
+
/**
|
|
98
|
+
* Standard JSON-RPC 2.0 error codes.
|
|
99
|
+
*
|
|
100
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
101
|
+
*/
|
|
102
|
+
export declare const JSONRPC_ERROR_CODES: {
|
|
103
|
+
/** Invalid JSON was received by the server. */
|
|
104
|
+
readonly PARSE_ERROR: -32700;
|
|
105
|
+
/** The JSON sent is not a valid Request object. */
|
|
106
|
+
readonly INVALID_REQUEST: -32600;
|
|
107
|
+
/** The method does not exist or is not available. */
|
|
108
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
109
|
+
/** Invalid method parameter(s). */
|
|
110
|
+
readonly INVALID_PARAMS: -32602;
|
|
111
|
+
/** Internal JSON-RPC error. */
|
|
112
|
+
readonly INTERNAL_ERROR: -32603;
|
|
113
|
+
};
|
|
114
|
+
export type JsonRpcErrorCode = (typeof JSONRPC_ERROR_CODES)[keyof typeof JSONRPC_ERROR_CODES];
|
|
115
|
+
/**
|
|
116
|
+
* Paperclip plugin-specific error codes.
|
|
117
|
+
*
|
|
118
|
+
* These live in the JSON-RPC "server error" reserved range (-32000 to -32099)
|
|
119
|
+
* as specified by JSON-RPC 2.0 for implementation-defined server errors.
|
|
120
|
+
*
|
|
121
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
122
|
+
*/
|
|
123
|
+
export declare const PLUGIN_RPC_ERROR_CODES: {
|
|
124
|
+
/** The worker process is not running or not reachable. */
|
|
125
|
+
readonly WORKER_UNAVAILABLE: -32000;
|
|
126
|
+
/** The plugin does not have the required capability for this operation. */
|
|
127
|
+
readonly CAPABILITY_DENIED: -32001;
|
|
128
|
+
/** The worker reported an unhandled error during method execution. */
|
|
129
|
+
readonly WORKER_ERROR: -32002;
|
|
130
|
+
/** The method call timed out waiting for the worker response. */
|
|
131
|
+
readonly TIMEOUT: -32003;
|
|
132
|
+
/** The worker does not implement the requested optional method. */
|
|
133
|
+
readonly METHOD_NOT_IMPLEMENTED: -32004;
|
|
134
|
+
/** A catch-all for errors that do not fit other categories. */
|
|
135
|
+
readonly UNKNOWN: -32099;
|
|
136
|
+
};
|
|
137
|
+
export type PluginRpcErrorCode = (typeof PLUGIN_RPC_ERROR_CODES)[keyof typeof PLUGIN_RPC_ERROR_CODES];
|
|
138
|
+
/**
|
|
139
|
+
* Input for the `initialize` RPC method.
|
|
140
|
+
*
|
|
141
|
+
* @see PLUGIN_SPEC.md §13.1 — `initialize`
|
|
142
|
+
*/
|
|
143
|
+
export interface InitializeParams {
|
|
144
|
+
/** Full plugin manifest snapshot. */
|
|
145
|
+
manifest: PaperclipPluginManifestV1;
|
|
146
|
+
/** Resolved operator configuration (validated against `instanceConfigSchema`). */
|
|
147
|
+
config: Record<string, unknown>;
|
|
148
|
+
/** Instance-level metadata. */
|
|
149
|
+
instanceInfo: {
|
|
150
|
+
/** UUID of this Paperclip instance. */
|
|
151
|
+
instanceId: string;
|
|
152
|
+
/** Semver version of the running Paperclip host. */
|
|
153
|
+
hostVersion: string;
|
|
154
|
+
};
|
|
155
|
+
/** Host API version. */
|
|
156
|
+
apiVersion: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Result returned by the `initialize` RPC method.
|
|
160
|
+
*/
|
|
161
|
+
export interface InitializeResult {
|
|
162
|
+
/** Whether initialization succeeded. */
|
|
163
|
+
ok: boolean;
|
|
164
|
+
/** Optional methods the worker has implemented (e.g. "validateConfig", "onEvent"). */
|
|
165
|
+
supportedMethods?: string[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Input for the `configChanged` RPC method.
|
|
169
|
+
*
|
|
170
|
+
* @see PLUGIN_SPEC.md §13.4 — `configChanged`
|
|
171
|
+
*/
|
|
172
|
+
export interface ConfigChangedParams {
|
|
173
|
+
/** The newly resolved configuration. */
|
|
174
|
+
config: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Input for the `validateConfig` RPC method.
|
|
178
|
+
*
|
|
179
|
+
* @see PLUGIN_SPEC.md §13.3 — `validateConfig`
|
|
180
|
+
*/
|
|
181
|
+
export interface ValidateConfigParams {
|
|
182
|
+
/** The configuration to validate. */
|
|
183
|
+
config: Record<string, unknown>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Input for the `onEvent` RPC method.
|
|
187
|
+
*
|
|
188
|
+
* @see PLUGIN_SPEC.md §13.5 — `onEvent`
|
|
189
|
+
*/
|
|
190
|
+
export interface OnEventParams {
|
|
191
|
+
/** The domain event to deliver. */
|
|
192
|
+
event: PluginEvent;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Input for the `runJob` RPC method.
|
|
196
|
+
*
|
|
197
|
+
* @see PLUGIN_SPEC.md §13.6 — `runJob`
|
|
198
|
+
*/
|
|
199
|
+
export interface RunJobParams {
|
|
200
|
+
/** Job execution context. */
|
|
201
|
+
job: PluginJobContext;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Input for the `getData` RPC method.
|
|
205
|
+
*
|
|
206
|
+
* @see PLUGIN_SPEC.md §13.8 — `getData`
|
|
207
|
+
*/
|
|
208
|
+
export interface GetDataParams {
|
|
209
|
+
/** Plugin-defined data key (e.g. `"sync-health"`). */
|
|
210
|
+
key: string;
|
|
211
|
+
/** Context and query parameters from the UI. */
|
|
212
|
+
params: Record<string, unknown>;
|
|
213
|
+
/** Optional launcher/container metadata from the host render environment. */
|
|
214
|
+
renderEnvironment?: PluginLauncherRenderContextSnapshot | null;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Input for the `performAction` RPC method.
|
|
218
|
+
*
|
|
219
|
+
* @see PLUGIN_SPEC.md §13.9 — `performAction`
|
|
220
|
+
*/
|
|
221
|
+
export interface PerformActionParams {
|
|
222
|
+
/** Plugin-defined action key (e.g. `"resync"`). */
|
|
223
|
+
key: string;
|
|
224
|
+
/** Action parameters from the UI. */
|
|
225
|
+
params: Record<string, unknown>;
|
|
226
|
+
/** Optional launcher/container metadata from the host render environment. */
|
|
227
|
+
renderEnvironment?: PluginLauncherRenderContextSnapshot | null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Input for the `executeTool` RPC method.
|
|
231
|
+
*
|
|
232
|
+
* @see PLUGIN_SPEC.md §13.10 — `executeTool`
|
|
233
|
+
*/
|
|
234
|
+
export interface ExecuteToolParams {
|
|
235
|
+
/** Tool name (without plugin namespace prefix). */
|
|
236
|
+
toolName: string;
|
|
237
|
+
/** Parsed parameters matching the tool's declared schema. */
|
|
238
|
+
parameters: unknown;
|
|
239
|
+
/** Agent run context. */
|
|
240
|
+
runContext: ToolRunContext;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Bounds request issued by a plugin UI running inside a host-managed launcher
|
|
244
|
+
* container such as a modal, drawer, or popover.
|
|
245
|
+
*/
|
|
246
|
+
export interface PluginModalBoundsRequest {
|
|
247
|
+
/** High-level size preset requested from the host. */
|
|
248
|
+
bounds: PluginLauncherBounds;
|
|
249
|
+
/** Optional explicit width override in CSS pixels. */
|
|
250
|
+
width?: number;
|
|
251
|
+
/** Optional explicit height override in CSS pixels. */
|
|
252
|
+
height?: number;
|
|
253
|
+
/** Optional lower bounds for host resizing decisions. */
|
|
254
|
+
minWidth?: number;
|
|
255
|
+
minHeight?: number;
|
|
256
|
+
/** Optional upper bounds for host resizing decisions. */
|
|
257
|
+
maxWidth?: number;
|
|
258
|
+
maxHeight?: number;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Reason metadata supplied by host-managed close lifecycle callbacks.
|
|
262
|
+
*/
|
|
263
|
+
export interface PluginRenderCloseEvent {
|
|
264
|
+
reason: "escapeKey" | "backdrop" | "hostNavigation" | "programmatic" | "submit" | "unknown";
|
|
265
|
+
nativeEvent?: unknown;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Map of host→worker RPC method names to their `[params, result]` types.
|
|
269
|
+
*
|
|
270
|
+
* This type is the single source of truth for all methods the host can call
|
|
271
|
+
* on a worker. Used by both the host dispatcher and the worker handler to
|
|
272
|
+
* ensure type safety across the IPC boundary.
|
|
273
|
+
*/
|
|
274
|
+
export interface HostToWorkerMethods {
|
|
275
|
+
/** @see PLUGIN_SPEC.md §13.1 */
|
|
276
|
+
initialize: [params: InitializeParams, result: InitializeResult];
|
|
277
|
+
/** @see PLUGIN_SPEC.md §13.2 */
|
|
278
|
+
health: [params: Record<string, never>, result: PluginHealthDiagnostics];
|
|
279
|
+
/** @see PLUGIN_SPEC.md §12.5 */
|
|
280
|
+
shutdown: [params: Record<string, never>, result: void];
|
|
281
|
+
/** @see PLUGIN_SPEC.md §13.3 */
|
|
282
|
+
validateConfig: [params: ValidateConfigParams, result: PluginConfigValidationResult];
|
|
283
|
+
/** @see PLUGIN_SPEC.md §13.4 */
|
|
284
|
+
configChanged: [params: ConfigChangedParams, result: void];
|
|
285
|
+
/** @see PLUGIN_SPEC.md §13.5 */
|
|
286
|
+
onEvent: [params: OnEventParams, result: void];
|
|
287
|
+
/** @see PLUGIN_SPEC.md §13.6 */
|
|
288
|
+
runJob: [params: RunJobParams, result: void];
|
|
289
|
+
/** @see PLUGIN_SPEC.md §13.7 */
|
|
290
|
+
handleWebhook: [params: PluginWebhookInput, result: void];
|
|
291
|
+
/** @see PLUGIN_SPEC.md §13.8 */
|
|
292
|
+
getData: [params: GetDataParams, result: unknown];
|
|
293
|
+
/** @see PLUGIN_SPEC.md §13.9 */
|
|
294
|
+
performAction: [params: PerformActionParams, result: unknown];
|
|
295
|
+
/** @see PLUGIN_SPEC.md §13.10 */
|
|
296
|
+
executeTool: [params: ExecuteToolParams, result: ToolResult];
|
|
297
|
+
}
|
|
298
|
+
/** Union of all host→worker method names. */
|
|
299
|
+
export type HostToWorkerMethodName = keyof HostToWorkerMethods;
|
|
300
|
+
/** Required methods the worker MUST implement. */
|
|
301
|
+
export declare const HOST_TO_WORKER_REQUIRED_METHODS: readonly HostToWorkerMethodName[];
|
|
302
|
+
/** Optional methods the worker MAY implement. */
|
|
303
|
+
export declare const HOST_TO_WORKER_OPTIONAL_METHODS: readonly HostToWorkerMethodName[];
|
|
304
|
+
/**
|
|
305
|
+
* Map of worker→host RPC method names to their `[params, result]` types.
|
|
306
|
+
*
|
|
307
|
+
* These represent the SDK client calls that the worker makes back to the
|
|
308
|
+
* host to access platform services (state, entities, config, etc.).
|
|
309
|
+
*/
|
|
310
|
+
export interface WorkerToHostMethods {
|
|
311
|
+
"config.get": [params: Record<string, never>, result: Record<string, unknown>];
|
|
312
|
+
"state.get": [
|
|
313
|
+
params: {
|
|
314
|
+
scopeKind: string;
|
|
315
|
+
scopeId?: string;
|
|
316
|
+
namespace?: string;
|
|
317
|
+
stateKey: string;
|
|
318
|
+
},
|
|
319
|
+
result: unknown
|
|
320
|
+
];
|
|
321
|
+
"state.set": [
|
|
322
|
+
params: {
|
|
323
|
+
scopeKind: string;
|
|
324
|
+
scopeId?: string;
|
|
325
|
+
namespace?: string;
|
|
326
|
+
stateKey: string;
|
|
327
|
+
value: unknown;
|
|
328
|
+
},
|
|
329
|
+
result: void
|
|
330
|
+
];
|
|
331
|
+
"state.delete": [
|
|
332
|
+
params: {
|
|
333
|
+
scopeKind: string;
|
|
334
|
+
scopeId?: string;
|
|
335
|
+
namespace?: string;
|
|
336
|
+
stateKey: string;
|
|
337
|
+
},
|
|
338
|
+
result: void
|
|
339
|
+
];
|
|
340
|
+
"entities.upsert": [
|
|
341
|
+
params: {
|
|
342
|
+
entityType: string;
|
|
343
|
+
scopeKind: PluginStateScopeKind;
|
|
344
|
+
scopeId?: string;
|
|
345
|
+
externalId?: string;
|
|
346
|
+
title?: string;
|
|
347
|
+
status?: string;
|
|
348
|
+
data: Record<string, unknown>;
|
|
349
|
+
},
|
|
350
|
+
result: {
|
|
351
|
+
id: string;
|
|
352
|
+
entityType: string;
|
|
353
|
+
scopeKind: PluginStateScopeKind;
|
|
354
|
+
scopeId: string | null;
|
|
355
|
+
externalId: string | null;
|
|
356
|
+
title: string | null;
|
|
357
|
+
status: string | null;
|
|
358
|
+
data: Record<string, unknown>;
|
|
359
|
+
createdAt: string;
|
|
360
|
+
updatedAt: string;
|
|
361
|
+
}
|
|
362
|
+
];
|
|
363
|
+
"entities.list": [
|
|
364
|
+
params: {
|
|
365
|
+
entityType?: string;
|
|
366
|
+
scopeKind?: PluginStateScopeKind;
|
|
367
|
+
scopeId?: string;
|
|
368
|
+
externalId?: string;
|
|
369
|
+
limit?: number;
|
|
370
|
+
offset?: number;
|
|
371
|
+
},
|
|
372
|
+
result: Array<{
|
|
373
|
+
id: string;
|
|
374
|
+
entityType: string;
|
|
375
|
+
scopeKind: PluginStateScopeKind;
|
|
376
|
+
scopeId: string | null;
|
|
377
|
+
externalId: string | null;
|
|
378
|
+
title: string | null;
|
|
379
|
+
status: string | null;
|
|
380
|
+
data: Record<string, unknown>;
|
|
381
|
+
createdAt: string;
|
|
382
|
+
updatedAt: string;
|
|
383
|
+
}>
|
|
384
|
+
];
|
|
385
|
+
"events.emit": [
|
|
386
|
+
params: {
|
|
387
|
+
name: string;
|
|
388
|
+
companyId: string;
|
|
389
|
+
payload: unknown;
|
|
390
|
+
},
|
|
391
|
+
result: void
|
|
392
|
+
];
|
|
393
|
+
"events.subscribe": [
|
|
394
|
+
params: {
|
|
395
|
+
eventPattern: string;
|
|
396
|
+
filter?: Record<string, unknown> | null;
|
|
397
|
+
},
|
|
398
|
+
result: void
|
|
399
|
+
];
|
|
400
|
+
"http.fetch": [
|
|
401
|
+
params: {
|
|
402
|
+
url: string;
|
|
403
|
+
init?: Record<string, unknown>;
|
|
404
|
+
},
|
|
405
|
+
result: {
|
|
406
|
+
status: number;
|
|
407
|
+
statusText: string;
|
|
408
|
+
headers: Record<string, string>;
|
|
409
|
+
body: string;
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
"secrets.resolve": [
|
|
413
|
+
params: {
|
|
414
|
+
secretRef: string;
|
|
415
|
+
},
|
|
416
|
+
result: string
|
|
417
|
+
];
|
|
418
|
+
"activity.log": [
|
|
419
|
+
params: {
|
|
420
|
+
companyId: string;
|
|
421
|
+
message: string;
|
|
422
|
+
entityType?: string;
|
|
423
|
+
entityId?: string;
|
|
424
|
+
metadata?: Record<string, unknown>;
|
|
425
|
+
},
|
|
426
|
+
result: void
|
|
427
|
+
];
|
|
428
|
+
"metrics.write": [
|
|
429
|
+
params: {
|
|
430
|
+
name: string;
|
|
431
|
+
value: number;
|
|
432
|
+
tags?: Record<string, string>;
|
|
433
|
+
},
|
|
434
|
+
result: void
|
|
435
|
+
];
|
|
436
|
+
"log": [
|
|
437
|
+
params: {
|
|
438
|
+
level: "info" | "warn" | "error" | "debug";
|
|
439
|
+
message: string;
|
|
440
|
+
meta?: Record<string, unknown>;
|
|
441
|
+
},
|
|
442
|
+
result: void
|
|
443
|
+
];
|
|
444
|
+
"companies.list": [
|
|
445
|
+
params: {
|
|
446
|
+
limit?: number;
|
|
447
|
+
offset?: number;
|
|
448
|
+
},
|
|
449
|
+
result: Company[]
|
|
450
|
+
];
|
|
451
|
+
"companies.get": [
|
|
452
|
+
params: {
|
|
453
|
+
companyId: string;
|
|
454
|
+
},
|
|
455
|
+
result: Company | null
|
|
456
|
+
];
|
|
457
|
+
"projects.list": [
|
|
458
|
+
params: {
|
|
459
|
+
companyId: string;
|
|
460
|
+
limit?: number;
|
|
461
|
+
offset?: number;
|
|
462
|
+
},
|
|
463
|
+
result: Project[]
|
|
464
|
+
];
|
|
465
|
+
"projects.get": [
|
|
466
|
+
params: {
|
|
467
|
+
projectId: string;
|
|
468
|
+
companyId: string;
|
|
469
|
+
},
|
|
470
|
+
result: Project | null
|
|
471
|
+
];
|
|
472
|
+
"projects.listWorkspaces": [
|
|
473
|
+
params: {
|
|
474
|
+
projectId: string;
|
|
475
|
+
companyId: string;
|
|
476
|
+
},
|
|
477
|
+
result: PluginWorkspace[]
|
|
478
|
+
];
|
|
479
|
+
"projects.getPrimaryWorkspace": [
|
|
480
|
+
params: {
|
|
481
|
+
projectId: string;
|
|
482
|
+
companyId: string;
|
|
483
|
+
},
|
|
484
|
+
result: PluginWorkspace | null
|
|
485
|
+
];
|
|
486
|
+
"projects.getWorkspaceForIssue": [
|
|
487
|
+
params: {
|
|
488
|
+
issueId: string;
|
|
489
|
+
companyId: string;
|
|
490
|
+
},
|
|
491
|
+
result: PluginWorkspace | null
|
|
492
|
+
];
|
|
493
|
+
"issues.list": [
|
|
494
|
+
params: {
|
|
495
|
+
companyId: string;
|
|
496
|
+
projectId?: string;
|
|
497
|
+
assigneeAgentId?: string;
|
|
498
|
+
status?: string;
|
|
499
|
+
limit?: number;
|
|
500
|
+
offset?: number;
|
|
501
|
+
},
|
|
502
|
+
result: Issue[]
|
|
503
|
+
];
|
|
504
|
+
"issues.get": [
|
|
505
|
+
params: {
|
|
506
|
+
issueId: string;
|
|
507
|
+
companyId: string;
|
|
508
|
+
},
|
|
509
|
+
result: Issue | null
|
|
510
|
+
];
|
|
511
|
+
"issues.create": [
|
|
512
|
+
params: {
|
|
513
|
+
companyId: string;
|
|
514
|
+
projectId?: string;
|
|
515
|
+
goalId?: string;
|
|
516
|
+
parentId?: string;
|
|
517
|
+
title: string;
|
|
518
|
+
description?: string;
|
|
519
|
+
priority?: string;
|
|
520
|
+
assigneeAgentId?: string;
|
|
521
|
+
},
|
|
522
|
+
result: Issue
|
|
523
|
+
];
|
|
524
|
+
"issues.update": [
|
|
525
|
+
params: {
|
|
526
|
+
issueId: string;
|
|
527
|
+
patch: Record<string, unknown>;
|
|
528
|
+
companyId: string;
|
|
529
|
+
},
|
|
530
|
+
result: Issue
|
|
531
|
+
];
|
|
532
|
+
"issues.listComments": [
|
|
533
|
+
params: {
|
|
534
|
+
issueId: string;
|
|
535
|
+
companyId: string;
|
|
536
|
+
},
|
|
537
|
+
result: IssueComment[]
|
|
538
|
+
];
|
|
539
|
+
"issues.createComment": [
|
|
540
|
+
params: {
|
|
541
|
+
issueId: string;
|
|
542
|
+
body: string;
|
|
543
|
+
companyId: string;
|
|
544
|
+
},
|
|
545
|
+
result: IssueComment
|
|
546
|
+
];
|
|
547
|
+
"issues.documents.list": [
|
|
548
|
+
params: {
|
|
549
|
+
issueId: string;
|
|
550
|
+
companyId: string;
|
|
551
|
+
},
|
|
552
|
+
result: IssueDocumentSummary[]
|
|
553
|
+
];
|
|
554
|
+
"issues.documents.get": [
|
|
555
|
+
params: {
|
|
556
|
+
issueId: string;
|
|
557
|
+
key: string;
|
|
558
|
+
companyId: string;
|
|
559
|
+
},
|
|
560
|
+
result: IssueDocument | null
|
|
561
|
+
];
|
|
562
|
+
"issues.documents.upsert": [
|
|
563
|
+
params: {
|
|
564
|
+
issueId: string;
|
|
565
|
+
key: string;
|
|
566
|
+
body: string;
|
|
567
|
+
companyId: string;
|
|
568
|
+
title?: string;
|
|
569
|
+
format?: string;
|
|
570
|
+
changeSummary?: string;
|
|
571
|
+
},
|
|
572
|
+
result: IssueDocument
|
|
573
|
+
];
|
|
574
|
+
"issues.documents.delete": [
|
|
575
|
+
params: {
|
|
576
|
+
issueId: string;
|
|
577
|
+
key: string;
|
|
578
|
+
companyId: string;
|
|
579
|
+
},
|
|
580
|
+
result: void
|
|
581
|
+
];
|
|
582
|
+
"agents.list": [
|
|
583
|
+
params: {
|
|
584
|
+
companyId: string;
|
|
585
|
+
status?: string;
|
|
586
|
+
limit?: number;
|
|
587
|
+
offset?: number;
|
|
588
|
+
},
|
|
589
|
+
result: Agent[]
|
|
590
|
+
];
|
|
591
|
+
"agents.get": [
|
|
592
|
+
params: {
|
|
593
|
+
agentId: string;
|
|
594
|
+
companyId: string;
|
|
595
|
+
},
|
|
596
|
+
result: Agent | null
|
|
597
|
+
];
|
|
598
|
+
"agents.pause": [
|
|
599
|
+
params: {
|
|
600
|
+
agentId: string;
|
|
601
|
+
companyId: string;
|
|
602
|
+
},
|
|
603
|
+
result: Agent
|
|
604
|
+
];
|
|
605
|
+
"agents.resume": [
|
|
606
|
+
params: {
|
|
607
|
+
agentId: string;
|
|
608
|
+
companyId: string;
|
|
609
|
+
},
|
|
610
|
+
result: Agent
|
|
611
|
+
];
|
|
612
|
+
"agents.invoke": [
|
|
613
|
+
params: {
|
|
614
|
+
agentId: string;
|
|
615
|
+
companyId: string;
|
|
616
|
+
prompt: string;
|
|
617
|
+
reason?: string;
|
|
618
|
+
},
|
|
619
|
+
result: {
|
|
620
|
+
runId: string;
|
|
621
|
+
}
|
|
622
|
+
];
|
|
623
|
+
"agents.sessions.create": [
|
|
624
|
+
params: {
|
|
625
|
+
agentId: string;
|
|
626
|
+
companyId: string;
|
|
627
|
+
taskKey?: string;
|
|
628
|
+
reason?: string;
|
|
629
|
+
},
|
|
630
|
+
result: {
|
|
631
|
+
sessionId: string;
|
|
632
|
+
agentId: string;
|
|
633
|
+
companyId: string;
|
|
634
|
+
status: "active" | "closed";
|
|
635
|
+
createdAt: string;
|
|
636
|
+
}
|
|
637
|
+
];
|
|
638
|
+
"agents.sessions.list": [
|
|
639
|
+
params: {
|
|
640
|
+
agentId: string;
|
|
641
|
+
companyId: string;
|
|
642
|
+
},
|
|
643
|
+
result: Array<{
|
|
644
|
+
sessionId: string;
|
|
645
|
+
agentId: string;
|
|
646
|
+
companyId: string;
|
|
647
|
+
status: "active" | "closed";
|
|
648
|
+
createdAt: string;
|
|
649
|
+
}>
|
|
650
|
+
];
|
|
651
|
+
"agents.sessions.sendMessage": [
|
|
652
|
+
params: {
|
|
653
|
+
sessionId: string;
|
|
654
|
+
companyId: string;
|
|
655
|
+
prompt: string;
|
|
656
|
+
reason?: string;
|
|
657
|
+
},
|
|
658
|
+
result: {
|
|
659
|
+
runId: string;
|
|
660
|
+
}
|
|
661
|
+
];
|
|
662
|
+
"agents.sessions.close": [
|
|
663
|
+
params: {
|
|
664
|
+
sessionId: string;
|
|
665
|
+
companyId: string;
|
|
666
|
+
},
|
|
667
|
+
result: void
|
|
668
|
+
];
|
|
669
|
+
"goals.list": [
|
|
670
|
+
params: {
|
|
671
|
+
companyId: string;
|
|
672
|
+
level?: string;
|
|
673
|
+
status?: string;
|
|
674
|
+
limit?: number;
|
|
675
|
+
offset?: number;
|
|
676
|
+
},
|
|
677
|
+
result: Goal[]
|
|
678
|
+
];
|
|
679
|
+
"goals.get": [
|
|
680
|
+
params: {
|
|
681
|
+
goalId: string;
|
|
682
|
+
companyId: string;
|
|
683
|
+
},
|
|
684
|
+
result: Goal | null
|
|
685
|
+
];
|
|
686
|
+
"goals.create": [
|
|
687
|
+
params: {
|
|
688
|
+
companyId: string;
|
|
689
|
+
title: string;
|
|
690
|
+
description?: string;
|
|
691
|
+
level?: string;
|
|
692
|
+
status?: string;
|
|
693
|
+
parentId?: string;
|
|
694
|
+
ownerAgentId?: string;
|
|
695
|
+
},
|
|
696
|
+
result: Goal
|
|
697
|
+
];
|
|
698
|
+
"goals.update": [
|
|
699
|
+
params: {
|
|
700
|
+
goalId: string;
|
|
701
|
+
patch: Record<string, unknown>;
|
|
702
|
+
companyId: string;
|
|
703
|
+
},
|
|
704
|
+
result: Goal
|
|
705
|
+
];
|
|
706
|
+
}
|
|
707
|
+
/** Union of all worker→host method names. */
|
|
708
|
+
export type WorkerToHostMethodName = keyof WorkerToHostMethods;
|
|
709
|
+
/**
|
|
710
|
+
* Typed parameter shapes for worker→host JSON-RPC notifications.
|
|
711
|
+
*
|
|
712
|
+
* Notifications are fire-and-forget — the worker does not wait for a response.
|
|
713
|
+
* These are used for streaming events and logging, not for request-response RPCs.
|
|
714
|
+
*/
|
|
715
|
+
export interface WorkerToHostNotifications {
|
|
716
|
+
/**
|
|
717
|
+
* Forward a stream event to connected SSE clients.
|
|
718
|
+
*
|
|
719
|
+
* Emitted by the worker for each event on a stream channel. The host
|
|
720
|
+
* publishes to the PluginStreamBus, which fans out to all SSE clients
|
|
721
|
+
* subscribed to the (pluginId, channel, companyId) tuple.
|
|
722
|
+
*
|
|
723
|
+
* The `event` payload is JSON-serializable and sent as SSE `data:`.
|
|
724
|
+
* The default SSE event type is `"message"`.
|
|
725
|
+
*/
|
|
726
|
+
"streams.emit": {
|
|
727
|
+
channel: string;
|
|
728
|
+
companyId: string;
|
|
729
|
+
event: unknown;
|
|
730
|
+
};
|
|
731
|
+
/**
|
|
732
|
+
* Signal that a stream channel has been opened.
|
|
733
|
+
*
|
|
734
|
+
* Emitted when the worker calls `ctx.streams.open(channel, companyId)`.
|
|
735
|
+
* UI clients may use this to display a "connected" indicator or begin
|
|
736
|
+
* buffering input. The host tracks open channels so it can emit synthetic
|
|
737
|
+
* close events if the worker crashes.
|
|
738
|
+
*/
|
|
739
|
+
"streams.open": {
|
|
740
|
+
channel: string;
|
|
741
|
+
companyId: string;
|
|
742
|
+
};
|
|
743
|
+
/**
|
|
744
|
+
* Signal that a stream channel has been closed.
|
|
745
|
+
*
|
|
746
|
+
* Emitted when the worker calls `ctx.streams.close(channel)`, or
|
|
747
|
+
* synthetically by the host when a worker process exits with channels
|
|
748
|
+
* still open. UI clients should treat this as terminal and disconnect
|
|
749
|
+
* the SSE connection.
|
|
750
|
+
*/
|
|
751
|
+
"streams.close": {
|
|
752
|
+
channel: string;
|
|
753
|
+
companyId: string;
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
/** Union of all worker→host notification method names. */
|
|
757
|
+
export type WorkerToHostNotificationName = keyof WorkerToHostNotifications;
|
|
758
|
+
/**
|
|
759
|
+
* A typed JSON-RPC request for a specific host→worker method.
|
|
760
|
+
*/
|
|
761
|
+
export type HostToWorkerRequest<M extends HostToWorkerMethodName> = JsonRpcRequest<M, HostToWorkerMethods[M][0]>;
|
|
762
|
+
/**
|
|
763
|
+
* A typed JSON-RPC success response for a specific host→worker method.
|
|
764
|
+
*/
|
|
765
|
+
export type HostToWorkerResponse<M extends HostToWorkerMethodName> = JsonRpcSuccessResponse<HostToWorkerMethods[M][1]>;
|
|
766
|
+
/**
|
|
767
|
+
* A typed JSON-RPC request for a specific worker→host method.
|
|
768
|
+
*/
|
|
769
|
+
export type WorkerToHostRequest<M extends WorkerToHostMethodName> = JsonRpcRequest<M, WorkerToHostMethods[M][0]>;
|
|
770
|
+
/**
|
|
771
|
+
* A typed JSON-RPC success response for a specific worker→host method.
|
|
772
|
+
*/
|
|
773
|
+
export type WorkerToHostResponse<M extends WorkerToHostMethodName> = JsonRpcSuccessResponse<WorkerToHostMethods[M][1]>;
|
|
774
|
+
/**
|
|
775
|
+
* Create a JSON-RPC 2.0 request message.
|
|
776
|
+
*
|
|
777
|
+
* @param method - The RPC method name
|
|
778
|
+
* @param params - Structured parameters
|
|
779
|
+
* @param id - Optional explicit request ID (auto-generated if omitted)
|
|
780
|
+
*/
|
|
781
|
+
export declare function createRequest<TMethod extends string>(method: TMethod, params: unknown, id?: JsonRpcId): JsonRpcRequest<TMethod>;
|
|
782
|
+
/**
|
|
783
|
+
* Create a JSON-RPC 2.0 success response.
|
|
784
|
+
*
|
|
785
|
+
* @param id - The request ID being responded to
|
|
786
|
+
* @param result - The result value
|
|
787
|
+
*/
|
|
788
|
+
export declare function createSuccessResponse<TResult>(id: JsonRpcId, result: TResult): JsonRpcSuccessResponse<TResult>;
|
|
789
|
+
/**
|
|
790
|
+
* Create a JSON-RPC 2.0 error response.
|
|
791
|
+
*
|
|
792
|
+
* @param id - The request ID being responded to (null if the request ID could not be determined)
|
|
793
|
+
* @param code - Machine-readable error code
|
|
794
|
+
* @param message - Human-readable error message
|
|
795
|
+
* @param data - Optional structured error data
|
|
796
|
+
*/
|
|
797
|
+
export declare function createErrorResponse<TData = unknown>(id: JsonRpcId | null, code: number, message: string, data?: TData): JsonRpcErrorResponse<TData>;
|
|
798
|
+
/**
|
|
799
|
+
* Create a JSON-RPC 2.0 notification (fire-and-forget, no response expected).
|
|
800
|
+
*
|
|
801
|
+
* @param method - The notification method name
|
|
802
|
+
* @param params - Structured parameters
|
|
803
|
+
*/
|
|
804
|
+
export declare function createNotification<TMethod extends string>(method: TMethod, params: unknown): JsonRpcNotification<TMethod>;
|
|
805
|
+
/**
|
|
806
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 request.
|
|
807
|
+
*
|
|
808
|
+
* A request has `jsonrpc: "2.0"`, a string `method`, and an `id`.
|
|
809
|
+
*/
|
|
810
|
+
export declare function isJsonRpcRequest(value: unknown): value is JsonRpcRequest;
|
|
811
|
+
/**
|
|
812
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 notification.
|
|
813
|
+
*
|
|
814
|
+
* A notification has `jsonrpc: "2.0"`, a string `method`, but no `id`.
|
|
815
|
+
*/
|
|
816
|
+
export declare function isJsonRpcNotification(value: unknown): value is JsonRpcNotification;
|
|
817
|
+
/**
|
|
818
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 response (success or error).
|
|
819
|
+
*/
|
|
820
|
+
export declare function isJsonRpcResponse(value: unknown): value is JsonRpcResponse;
|
|
821
|
+
/**
|
|
822
|
+
* Check whether a JSON-RPC response is a success response.
|
|
823
|
+
*/
|
|
824
|
+
export declare function isJsonRpcSuccessResponse(response: JsonRpcResponse): response is JsonRpcSuccessResponse;
|
|
825
|
+
/**
|
|
826
|
+
* Check whether a JSON-RPC response is an error response.
|
|
827
|
+
*/
|
|
828
|
+
export declare function isJsonRpcErrorResponse(response: JsonRpcResponse): response is JsonRpcErrorResponse;
|
|
829
|
+
/**
|
|
830
|
+
* Line delimiter for JSON-RPC messages over stdio.
|
|
831
|
+
*
|
|
832
|
+
* Each message is a single line of JSON terminated by a newline character.
|
|
833
|
+
* This follows the newline-delimited JSON (NDJSON) convention.
|
|
834
|
+
*/
|
|
835
|
+
export declare const MESSAGE_DELIMITER: "\n";
|
|
836
|
+
/**
|
|
837
|
+
* Serialize a JSON-RPC message to a newline-delimited string for transmission
|
|
838
|
+
* over stdio.
|
|
839
|
+
*
|
|
840
|
+
* @param message - Any JSON-RPC message (request, response, or notification)
|
|
841
|
+
* @returns The JSON string terminated with a newline
|
|
842
|
+
*/
|
|
843
|
+
export declare function serializeMessage(message: JsonRpcMessage): string;
|
|
844
|
+
/**
|
|
845
|
+
* Parse a JSON string into a JSON-RPC message.
|
|
846
|
+
*
|
|
847
|
+
* Returns the parsed message or throws a `JsonRpcParseError` if the input
|
|
848
|
+
* is not valid JSON or does not conform to the JSON-RPC 2.0 structure.
|
|
849
|
+
*
|
|
850
|
+
* @param line - A single line of JSON text (with or without trailing newline)
|
|
851
|
+
* @returns The parsed JSON-RPC message
|
|
852
|
+
* @throws {JsonRpcParseError} If parsing fails
|
|
853
|
+
*/
|
|
854
|
+
export declare function parseMessage(line: string): JsonRpcMessage;
|
|
855
|
+
/**
|
|
856
|
+
* Error thrown when a JSON-RPC message cannot be parsed.
|
|
857
|
+
*/
|
|
858
|
+
export declare class JsonRpcParseError extends Error {
|
|
859
|
+
readonly name = "JsonRpcParseError";
|
|
860
|
+
constructor(message: string);
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Error thrown when a JSON-RPC call fails with a structured error response.
|
|
864
|
+
*
|
|
865
|
+
* Captures the full `JsonRpcError` so callers can inspect the code and data.
|
|
866
|
+
*/
|
|
867
|
+
export declare class JsonRpcCallError extends Error {
|
|
868
|
+
readonly name = "JsonRpcCallError";
|
|
869
|
+
/** The JSON-RPC error code. */
|
|
870
|
+
readonly code: number;
|
|
871
|
+
/** Optional structured error data from the response. */
|
|
872
|
+
readonly data: unknown;
|
|
873
|
+
constructor(error: JsonRpcError);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Reset the internal request ID counter. **For testing only.**
|
|
877
|
+
*
|
|
878
|
+
* @internal
|
|
879
|
+
*/
|
|
880
|
+
export declare function _resetIdCounter(): void;
|
|
881
|
+
//# sourceMappingURL=protocol.d.ts.map
|