@tickernelz/paperclip-pro-plugin-sdk 2026.925.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 +22 -0
- package/README.md +1307 -0
- package/dist/.paperclip-build-complete +1 -0
- package/dist/bundlers.d.ts +57 -0
- package/dist/bundlers.d.ts.map +1 -0
- package/dist/bundlers.js +106 -0
- package/dist/bundlers.js.map +1 -0
- package/dist/define-plugin.d.ts +396 -0
- package/dist/define-plugin.d.ts.map +1 -0
- package/dist/define-plugin.js +87 -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 +326 -0
- package/dist/host-client-factory.d.ts.map +1 -0
- package/dist/host-client-factory.js +688 -0
- package/dist/host-client-factory.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +2333 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.duplex-channel.test.d.ts +2 -0
- package/dist/protocol.duplex-channel.test.d.ts.map +1 -0
- package/dist/protocol.duplex-channel.test.js +229 -0
- package/dist/protocol.duplex-channel.test.js.map +1 -0
- package/dist/protocol.js +364 -0
- package/dist/protocol.js.map +1 -0
- package/dist/testing.d.ts +203 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +2475 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +1837 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/clipboard.d.ts +8 -0
- package/dist/ui/clipboard.d.ts.map +1 -0
- package/dist/ui/clipboard.js +12 -0
- package/dist/ui/clipboard.js.map +1 -0
- package/dist/ui/components.d.ts +518 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +135 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/hooks.d.ts +155 -0
- package/dist/ui/hooks.d.ts.map +1 -0
- package/dist/ui/hooks.js +195 -0
- package/dist/ui/hooks.js.map +1 -0
- package/dist/ui/index.d.ts +55 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +52 -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 +423 -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 +128 -0
- package/dist/worker-rpc-host.d.ts.map +1 -0
- package/dist/worker-rpc-host.js +1877 -0
- package/dist/worker-rpc-host.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,2333 @@
|
|
|
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, IssueAssigneeAdapterOverrides, IssueAttachment, IssueThreadInteraction, CreateIssueThreadInteraction, Approval, PluginManagedAgentResolution, PluginManagedProjectResolution, PluginManagedRoutineResolution, PluginManagedSkillResolution, Routine, RoutineRun, Agent, Goal, PluginLocalFolderDeclaration, PrincipalPermissionGrant, ExternalObjectStatusCategory, ExternalObjectStatusTone, ExternalObjectLivenessState, ExternalObjectMentionConfidence, ExternalObjectMentionSourceKind, EnvSecretRefBinding } from "@tickernelz/paperclip-pro-shared";
|
|
18
|
+
export type { PluginLauncherRenderContextSnapshot } from "@tickernelz/paperclip-pro-shared";
|
|
19
|
+
import type { PluginEvent, PluginIssueCheckoutOwnership, PluginIssueOrchestrationSummary, PluginIssueRelationSummary, PluginIssueSubtree, PluginIssueAttachmentContent, PluginIssueWakeupBatchResult, PluginIssueWakeupResult, PluginJobContext, PluginExecutionWorkspaceMetadata, PluginWorkspace, ToolRunContext, ToolResult, PluginLocalFolderListing, PluginLocalFolderStatus, PluginAccessInvite, PluginAccessMember, PluginAssignmentPreviewInput, PluginAuthorizationAuditEntry, PluginAuthorizationDecisionResult, PluginAuthorizationPolicyRecord, PluginAuthorizationPolicySummary } from "./types.js";
|
|
20
|
+
import type { PluginHealthDiagnostics, PluginApiRequestInput, PluginApiResponse, 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
|
+
* Host-owned scope attached to a host→worker invocation. Workers may echo the
|
|
30
|
+
* invocation id on nested worker→host calls, but they never author this scope.
|
|
31
|
+
*/
|
|
32
|
+
export interface JsonRpcInvocationScope {
|
|
33
|
+
readonly companyId?: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface JsonRpcInvocationContext {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly scope: JsonRpcInvocationScope;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A JSON-RPC 2.0 request message.
|
|
41
|
+
*
|
|
42
|
+
* The host sends requests to the worker (or vice versa) and expects a
|
|
43
|
+
* matching response with the same `id`.
|
|
44
|
+
*/
|
|
45
|
+
export interface JsonRpcRequest<TMethod extends string = string, TParams = unknown> {
|
|
46
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
47
|
+
/** Unique request identifier. Must be echoed in the response. */
|
|
48
|
+
readonly id: JsonRpcId;
|
|
49
|
+
/** The RPC method name to invoke. */
|
|
50
|
+
readonly method: TMethod;
|
|
51
|
+
/** Structured parameters for the method call. */
|
|
52
|
+
readonly params: TParams;
|
|
53
|
+
/**
|
|
54
|
+
* Host-issued metadata for the top-level plugin invocation that is currently
|
|
55
|
+
* executing. The worker treats this as opaque and echoes only the id on
|
|
56
|
+
* worker→host calls made from the same async execution context.
|
|
57
|
+
*/
|
|
58
|
+
readonly paperclipInvocation?: PluginInvocationContext;
|
|
59
|
+
/** Opaque top-level invocation id echoed by worker→host requests. */
|
|
60
|
+
readonly paperclipInvocationId?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A JSON-RPC 2.0 success response.
|
|
64
|
+
*/
|
|
65
|
+
export interface JsonRpcSuccessResponse<TResult = unknown> {
|
|
66
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
67
|
+
/** Echoed request identifier. */
|
|
68
|
+
readonly id: JsonRpcId;
|
|
69
|
+
/** The method return value. */
|
|
70
|
+
readonly result: TResult;
|
|
71
|
+
readonly error?: never;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A JSON-RPC 2.0 error object embedded in an error response.
|
|
75
|
+
*/
|
|
76
|
+
export interface JsonRpcError<TData = unknown> {
|
|
77
|
+
/** Machine-readable error code. */
|
|
78
|
+
readonly code: number;
|
|
79
|
+
/** Human-readable error message. */
|
|
80
|
+
readonly message: string;
|
|
81
|
+
/** Optional structured error data. */
|
|
82
|
+
readonly data?: TData;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A JSON-RPC 2.0 error response.
|
|
86
|
+
*/
|
|
87
|
+
export interface JsonRpcErrorResponse<TData = unknown> {
|
|
88
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
89
|
+
/** Echoed request identifier. */
|
|
90
|
+
readonly id: JsonRpcId | null;
|
|
91
|
+
readonly result?: never;
|
|
92
|
+
/** The error object. */
|
|
93
|
+
readonly error: JsonRpcError<TData>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A JSON-RPC 2.0 response — either success or error.
|
|
97
|
+
*/
|
|
98
|
+
export type JsonRpcResponse<TResult = unknown, TData = unknown> = JsonRpcSuccessResponse<TResult> | JsonRpcErrorResponse<TData>;
|
|
99
|
+
/**
|
|
100
|
+
* A JSON-RPC 2.0 notification (a request with no `id`).
|
|
101
|
+
*
|
|
102
|
+
* Notifications are fire-and-forget — no response is expected.
|
|
103
|
+
*/
|
|
104
|
+
export interface JsonRpcNotification<TMethod extends string = string, TParams = unknown> {
|
|
105
|
+
readonly jsonrpc: typeof JSONRPC_VERSION;
|
|
106
|
+
readonly id?: never;
|
|
107
|
+
/** The notification method name. */
|
|
108
|
+
readonly method: TMethod;
|
|
109
|
+
/** Structured parameters for the notification. */
|
|
110
|
+
readonly params: TParams;
|
|
111
|
+
/**
|
|
112
|
+
* Host-issued metadata for host→worker push notifications such as events.
|
|
113
|
+
* Worker→host notifications echo only `paperclipInvocationId`.
|
|
114
|
+
*/
|
|
115
|
+
readonly paperclipInvocation?: PluginInvocationContext;
|
|
116
|
+
/** Opaque top-level invocation id echoed by worker→host notifications. */
|
|
117
|
+
readonly paperclipInvocationId?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Any well-formed JSON-RPC 2.0 message (request, response, or notification).
|
|
121
|
+
*/
|
|
122
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse | JsonRpcNotification;
|
|
123
|
+
/**
|
|
124
|
+
* Standard JSON-RPC 2.0 error codes.
|
|
125
|
+
*
|
|
126
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
127
|
+
*/
|
|
128
|
+
export declare const JSONRPC_ERROR_CODES: {
|
|
129
|
+
/** Invalid JSON was received by the server. */
|
|
130
|
+
readonly PARSE_ERROR: -32700;
|
|
131
|
+
/** The JSON sent is not a valid Request object. */
|
|
132
|
+
readonly INVALID_REQUEST: -32600;
|
|
133
|
+
/** The method does not exist or is not available. */
|
|
134
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
135
|
+
/** Invalid method parameter(s). */
|
|
136
|
+
readonly INVALID_PARAMS: -32602;
|
|
137
|
+
/** Internal JSON-RPC error. */
|
|
138
|
+
readonly INTERNAL_ERROR: -32603;
|
|
139
|
+
};
|
|
140
|
+
export type JsonRpcErrorCode = (typeof JSONRPC_ERROR_CODES)[keyof typeof JSONRPC_ERROR_CODES];
|
|
141
|
+
/**
|
|
142
|
+
* Paperclip plugin-specific error codes.
|
|
143
|
+
*
|
|
144
|
+
* These live in the JSON-RPC "server error" reserved range (-32000 to -32099)
|
|
145
|
+
* as specified by JSON-RPC 2.0 for implementation-defined server errors.
|
|
146
|
+
*
|
|
147
|
+
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
|
|
148
|
+
*/
|
|
149
|
+
export declare const PLUGIN_RPC_ERROR_CODES: {
|
|
150
|
+
/** The worker process is not running or not reachable. */
|
|
151
|
+
readonly WORKER_UNAVAILABLE: -32000;
|
|
152
|
+
/** The plugin does not have the required capability for this operation. */
|
|
153
|
+
readonly CAPABILITY_DENIED: -32001;
|
|
154
|
+
/** The worker reported an unhandled error during method execution. */
|
|
155
|
+
readonly WORKER_ERROR: -32002;
|
|
156
|
+
/** The method call timed out waiting for the worker response. */
|
|
157
|
+
readonly TIMEOUT: -32003;
|
|
158
|
+
/** The worker does not implement the requested optional method. */
|
|
159
|
+
readonly METHOD_NOT_IMPLEMENTED: -32004;
|
|
160
|
+
/** The worker→host call attempted to escape the current invocation company scope. */
|
|
161
|
+
readonly INVOCATION_SCOPE_DENIED: -32005;
|
|
162
|
+
/**
|
|
163
|
+
* A `configChanged` delivery would have collapsed a single-tenant worker onto
|
|
164
|
+
* a second, distinct company's configuration. The worker fails closed instead
|
|
165
|
+
* of silently overwriting the already-applied tenant's config. A plugin that
|
|
166
|
+
* genuinely serves multiple companies from one worker must opt in via
|
|
167
|
+
* `multiCompanyConfig: true` on its definition.
|
|
168
|
+
*/
|
|
169
|
+
readonly CROSS_TENANT_CONFIG: -32006;
|
|
170
|
+
/** A catch-all for errors that do not fit other categories. */
|
|
171
|
+
readonly UNKNOWN: -32099;
|
|
172
|
+
};
|
|
173
|
+
export type PluginRpcErrorCode = (typeof PLUGIN_RPC_ERROR_CODES)[keyof typeof PLUGIN_RPC_ERROR_CODES];
|
|
174
|
+
/**
|
|
175
|
+
* Company scope attached by the host to one top-level plugin invocation.
|
|
176
|
+
* Absence of this metadata means the invocation is instance/global scoped.
|
|
177
|
+
*/
|
|
178
|
+
export interface PluginInvocationScope {
|
|
179
|
+
companyId: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Opaque invocation metadata generated by the host. Workers must not derive or
|
|
183
|
+
* mutate this. They only echo the id on nested worker→host RPC calls.
|
|
184
|
+
*/
|
|
185
|
+
export interface PluginInvocationContext {
|
|
186
|
+
id: string;
|
|
187
|
+
scope: PluginInvocationScope;
|
|
188
|
+
/**
|
|
189
|
+
* An optional W3C `traceparent` for the active host span. The host mints it
|
|
190
|
+
* per call from the active startup span. The worker treats it as opaque: it
|
|
191
|
+
* tags its provider span with it and never derives parentage from it. The host
|
|
192
|
+
* mints the parentage from its own invocation record, so a worker can never
|
|
193
|
+
* forge a parent.
|
|
194
|
+
*/
|
|
195
|
+
traceparent?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Context provided to host-side worker→host handlers after the worker echoes a
|
|
199
|
+
* host-issued invocation id.
|
|
200
|
+
*/
|
|
201
|
+
export interface WorkerHostCallContext {
|
|
202
|
+
invocationScope?: PluginInvocationScope | null;
|
|
203
|
+
invalidInvocationScope?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* The W3C `traceparent` the host minted for the echoed invocation. The host
|
|
206
|
+
* recovers it from its own invocation record, not from the worker, so a worker
|
|
207
|
+
* can never forge a span parent. The span host handler validates and uses it.
|
|
208
|
+
*/
|
|
209
|
+
traceparent?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Input for the `initialize` RPC method.
|
|
213
|
+
*
|
|
214
|
+
* @see PLUGIN_SPEC.md §13.1 — `initialize`
|
|
215
|
+
*/
|
|
216
|
+
export interface InitializeParams {
|
|
217
|
+
/** Full plugin manifest snapshot. */
|
|
218
|
+
manifest: PaperclipPluginManifestV1;
|
|
219
|
+
/** Bootstrap configuration. Company-scoped config is read via `ctx.config.get(companyId)`. */
|
|
220
|
+
config: Record<string, unknown>;
|
|
221
|
+
/** Instance-level metadata. */
|
|
222
|
+
instanceInfo: {
|
|
223
|
+
/** UUID of this Paperclip instance. */
|
|
224
|
+
instanceId: string;
|
|
225
|
+
/** Semver version of the running Paperclip host. */
|
|
226
|
+
hostVersion: string;
|
|
227
|
+
};
|
|
228
|
+
/** Host API version. */
|
|
229
|
+
apiVersion: number;
|
|
230
|
+
/** Host-derived plugin database namespace, when the manifest declares database access. */
|
|
231
|
+
databaseNamespace?: string | null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Result returned by the `initialize` RPC method.
|
|
235
|
+
*/
|
|
236
|
+
export interface InitializeResult {
|
|
237
|
+
/** Whether initialization succeeded. */
|
|
238
|
+
ok: boolean;
|
|
239
|
+
/** Optional methods the worker has implemented (e.g. "validateConfig", "onEvent"). */
|
|
240
|
+
supportedMethods?: string[];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Input for the `configChanged` RPC method.
|
|
244
|
+
*
|
|
245
|
+
* @see PLUGIN_SPEC.md §13.4 — `configChanged`
|
|
246
|
+
*/
|
|
247
|
+
export interface ConfigChangedParams {
|
|
248
|
+
/** The newly resolved company-scoped configuration. */
|
|
249
|
+
config: Record<string, unknown>;
|
|
250
|
+
/** Company whose plugin config changed. */
|
|
251
|
+
companyId?: string | null;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Input for the `validateConfig` RPC method.
|
|
255
|
+
*
|
|
256
|
+
* @see PLUGIN_SPEC.md §13.3 — `validateConfig`
|
|
257
|
+
*/
|
|
258
|
+
export interface ValidateConfigParams {
|
|
259
|
+
/** The configuration to validate. */
|
|
260
|
+
config: Record<string, unknown>;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Input for the `onEvent` RPC method.
|
|
264
|
+
*
|
|
265
|
+
* @see PLUGIN_SPEC.md §13.5 — `onEvent`
|
|
266
|
+
*/
|
|
267
|
+
export interface OnEventParams {
|
|
268
|
+
/** The domain event to deliver. */
|
|
269
|
+
event: PluginEvent;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Input for the `runJob` RPC method.
|
|
273
|
+
*
|
|
274
|
+
* @see PLUGIN_SPEC.md §13.6 — `runJob`
|
|
275
|
+
*/
|
|
276
|
+
export interface RunJobParams {
|
|
277
|
+
/** Job execution context. */
|
|
278
|
+
job: PluginJobContext;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Input for the `getData` RPC method.
|
|
282
|
+
*
|
|
283
|
+
* @see PLUGIN_SPEC.md §13.8 — `getData`
|
|
284
|
+
*/
|
|
285
|
+
export interface GetDataParams {
|
|
286
|
+
/** Plugin-defined data key (e.g. `"sync-health"`). */
|
|
287
|
+
key: string;
|
|
288
|
+
/** Host-authorized active company scope, when this bridge call is company-scoped. */
|
|
289
|
+
companyId?: string | null;
|
|
290
|
+
/** Context and query parameters from the UI. */
|
|
291
|
+
params: Record<string, unknown>;
|
|
292
|
+
/** Optional launcher/container metadata from the host render environment. */
|
|
293
|
+
renderEnvironment?: PluginLauncherRenderContextSnapshot | null;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Input for the `performAction` RPC method.
|
|
297
|
+
*
|
|
298
|
+
* @see PLUGIN_SPEC.md §13.9 — `performAction`
|
|
299
|
+
*/
|
|
300
|
+
export type PluginPerformActionActorType = "user" | "agent" | "system";
|
|
301
|
+
export interface PluginPerformActionActorContext {
|
|
302
|
+
/** Authenticated principal type resolved by the Paperclip host. */
|
|
303
|
+
type: PluginPerformActionActorType;
|
|
304
|
+
/** Authenticated board user id when `type === "user"`, otherwise null. */
|
|
305
|
+
userId: string | null;
|
|
306
|
+
/** Authenticated agent id when `type === "agent"`, otherwise null. */
|
|
307
|
+
agentId: string | null;
|
|
308
|
+
/** Authenticated heartbeat/run id when available. */
|
|
309
|
+
runId: string | null;
|
|
310
|
+
/** Company id authorized by the host bridge for this action, when applicable. */
|
|
311
|
+
companyId: string | null;
|
|
312
|
+
}
|
|
313
|
+
export interface PluginPerformActionContext {
|
|
314
|
+
/** Immutable authenticated actor context supplied by the host. */
|
|
315
|
+
actor: Readonly<PluginPerformActionActorContext>;
|
|
316
|
+
/** Convenience alias for `actor.companyId`. */
|
|
317
|
+
companyId: string | null;
|
|
318
|
+
}
|
|
319
|
+
export interface PerformActionParams {
|
|
320
|
+
/** Plugin-defined action key (e.g. `"resync"`). */
|
|
321
|
+
key: string;
|
|
322
|
+
/** Host-authorized active company scope, when this bridge call is company-scoped. */
|
|
323
|
+
companyId?: string | null;
|
|
324
|
+
/** Action parameters from the UI. */
|
|
325
|
+
params: Record<string, unknown>;
|
|
326
|
+
/** Authenticated actor context resolved by the host, never by caller params. */
|
|
327
|
+
actorContext?: PluginPerformActionActorContext | null;
|
|
328
|
+
/** Optional launcher/container metadata from the host render environment. */
|
|
329
|
+
renderEnvironment?: PluginLauncherRenderContextSnapshot | null;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Input for the `executeTool` RPC method.
|
|
333
|
+
*
|
|
334
|
+
* @see PLUGIN_SPEC.md §13.10 — `executeTool`
|
|
335
|
+
*/
|
|
336
|
+
export interface ExecuteToolParams {
|
|
337
|
+
/** Tool name (without plugin namespace prefix). */
|
|
338
|
+
toolName: string;
|
|
339
|
+
/** Parsed parameters matching the tool's declared schema. */
|
|
340
|
+
parameters: unknown;
|
|
341
|
+
/** Agent run context. */
|
|
342
|
+
runContext: ToolRunContext;
|
|
343
|
+
}
|
|
344
|
+
export interface PluginExternalObjectUrlCandidate {
|
|
345
|
+
sanitizedCanonicalUrl: string;
|
|
346
|
+
sanitizedDisplayUrl: string;
|
|
347
|
+
canonicalIdentityHash: string;
|
|
348
|
+
canonicalIdentity: Record<string, unknown>;
|
|
349
|
+
redactedMatchedText: string;
|
|
350
|
+
}
|
|
351
|
+
export interface PluginExternalObjectSourceContext {
|
|
352
|
+
companyId: string;
|
|
353
|
+
sourceIssueId: string;
|
|
354
|
+
sourceKind: ExternalObjectMentionSourceKind;
|
|
355
|
+
sourceRecordId: string | null;
|
|
356
|
+
documentKey: string | null;
|
|
357
|
+
propertyKey: string | null;
|
|
358
|
+
}
|
|
359
|
+
export interface DetectExternalObjectsParams {
|
|
360
|
+
companyId: string;
|
|
361
|
+
urls: PluginExternalObjectUrlCandidate[];
|
|
362
|
+
sourceContext: PluginExternalObjectSourceContext;
|
|
363
|
+
}
|
|
364
|
+
export interface PluginExternalObjectDetection {
|
|
365
|
+
urlIdentityHash: string;
|
|
366
|
+
providerKey: string;
|
|
367
|
+
objectType: string;
|
|
368
|
+
externalId: string;
|
|
369
|
+
displayKey?: string | null;
|
|
370
|
+
iconKey?: string | null;
|
|
371
|
+
displayTitle?: string | null;
|
|
372
|
+
confidence?: ExternalObjectMentionConfidence;
|
|
373
|
+
}
|
|
374
|
+
export interface DetectExternalObjectsResult {
|
|
375
|
+
detections: PluginExternalObjectDetection[];
|
|
376
|
+
}
|
|
377
|
+
export interface PluginExternalObjectRecordSnapshot {
|
|
378
|
+
id: string;
|
|
379
|
+
companyId: string;
|
|
380
|
+
providerKey: string;
|
|
381
|
+
objectType: string;
|
|
382
|
+
externalId: string;
|
|
383
|
+
sanitizedCanonicalUrl: string | null;
|
|
384
|
+
canonicalIdentityHash: string | null;
|
|
385
|
+
displayKey: string | null;
|
|
386
|
+
iconKey: string | null;
|
|
387
|
+
displayTitle: string | null;
|
|
388
|
+
statusKey: string | null;
|
|
389
|
+
statusLabel: string | null;
|
|
390
|
+
statusIconKey: string | null;
|
|
391
|
+
statusCategory: ExternalObjectStatusCategory;
|
|
392
|
+
statusTone: ExternalObjectStatusTone;
|
|
393
|
+
liveness: ExternalObjectLivenessState;
|
|
394
|
+
isTerminal: boolean;
|
|
395
|
+
data: Record<string, unknown>;
|
|
396
|
+
remoteVersion: string | null;
|
|
397
|
+
etag: string | null;
|
|
398
|
+
}
|
|
399
|
+
export interface ResolveExternalObjectParams {
|
|
400
|
+
companyId: string;
|
|
401
|
+
providerKey: string;
|
|
402
|
+
objectType: string;
|
|
403
|
+
externalId: string;
|
|
404
|
+
object: PluginExternalObjectRecordSnapshot;
|
|
405
|
+
}
|
|
406
|
+
export interface PluginExternalObjectResolvedSnapshot {
|
|
407
|
+
displayKey?: string | null;
|
|
408
|
+
iconKey?: string | null;
|
|
409
|
+
displayTitle?: string | null;
|
|
410
|
+
statusKey?: string | null;
|
|
411
|
+
statusLabel?: string | null;
|
|
412
|
+
statusIconKey?: string | null;
|
|
413
|
+
statusCategory: ExternalObjectStatusCategory;
|
|
414
|
+
statusTone: ExternalObjectStatusTone;
|
|
415
|
+
isTerminal?: boolean;
|
|
416
|
+
data?: Record<string, unknown>;
|
|
417
|
+
remoteVersion?: string | null;
|
|
418
|
+
etag?: string | null;
|
|
419
|
+
ttlSeconds?: number;
|
|
420
|
+
}
|
|
421
|
+
export type PluginExternalObjectResolveResult = {
|
|
422
|
+
ok: true;
|
|
423
|
+
snapshot: PluginExternalObjectResolvedSnapshot;
|
|
424
|
+
} | {
|
|
425
|
+
ok: false;
|
|
426
|
+
liveness: Extract<ExternalObjectLivenessState, "auth_required" | "unreachable">;
|
|
427
|
+
errorCode: string;
|
|
428
|
+
errorMessage?: string | null;
|
|
429
|
+
retryAfterSeconds?: number;
|
|
430
|
+
};
|
|
431
|
+
export interface RefreshExternalObjectsParams {
|
|
432
|
+
companyId: string;
|
|
433
|
+
objects: PluginExternalObjectRecordSnapshot[];
|
|
434
|
+
}
|
|
435
|
+
export interface RefreshExternalObjectsResult {
|
|
436
|
+
results: Array<{
|
|
437
|
+
objectId: string;
|
|
438
|
+
result: PluginExternalObjectResolveResult;
|
|
439
|
+
}>;
|
|
440
|
+
}
|
|
441
|
+
export interface PluginEnvironmentDiagnostic {
|
|
442
|
+
severity: "info" | "warning" | "error";
|
|
443
|
+
message: string;
|
|
444
|
+
code?: string;
|
|
445
|
+
details?: Record<string, unknown>;
|
|
446
|
+
}
|
|
447
|
+
export interface PluginEnvironmentDriverBaseParams {
|
|
448
|
+
driverKey: string;
|
|
449
|
+
companyId: string;
|
|
450
|
+
environmentId: string;
|
|
451
|
+
issueId?: string | null;
|
|
452
|
+
config: Record<string, unknown>;
|
|
453
|
+
}
|
|
454
|
+
export interface PluginEnvironmentValidateConfigParams {
|
|
455
|
+
driverKey: string;
|
|
456
|
+
config: Record<string, unknown>;
|
|
457
|
+
}
|
|
458
|
+
export interface PluginEnvironmentValidationResult {
|
|
459
|
+
ok: boolean;
|
|
460
|
+
warnings?: string[];
|
|
461
|
+
errors?: string[];
|
|
462
|
+
normalizedConfig?: Record<string, unknown>;
|
|
463
|
+
}
|
|
464
|
+
export interface PluginEnvironmentProbeParams extends PluginEnvironmentDriverBaseParams {
|
|
465
|
+
}
|
|
466
|
+
export interface PluginEnvironmentProbeResult {
|
|
467
|
+
ok: boolean;
|
|
468
|
+
summary?: string;
|
|
469
|
+
diagnostics?: PluginEnvironmentDiagnostic[];
|
|
470
|
+
metadata?: Record<string, unknown>;
|
|
471
|
+
}
|
|
472
|
+
export interface PluginEnvironmentLease {
|
|
473
|
+
providerLeaseId: string | null;
|
|
474
|
+
metadata?: Record<string, unknown>;
|
|
475
|
+
expiresAt?: string | null;
|
|
476
|
+
}
|
|
477
|
+
/** Serializable provider result. The host adds refresh/close lifecycle methods. */
|
|
478
|
+
export interface PluginEnvironmentRunnerIngressEndpoint {
|
|
479
|
+
kind: "authenticated_websocket";
|
|
480
|
+
websocketUrl: string;
|
|
481
|
+
secretHeaders: Array<{
|
|
482
|
+
name: string;
|
|
483
|
+
value: string;
|
|
484
|
+
}>;
|
|
485
|
+
generation: string;
|
|
486
|
+
}
|
|
487
|
+
export interface PluginEnvironmentRunnerIngressEndpointParams extends PluginEnvironmentDriverBaseParams {
|
|
488
|
+
lease: PluginEnvironmentLease;
|
|
489
|
+
port: number;
|
|
490
|
+
path: string;
|
|
491
|
+
}
|
|
492
|
+
export interface PluginEnvironmentAcquireLeaseParams extends PluginEnvironmentDriverBaseParams {
|
|
493
|
+
runId: string;
|
|
494
|
+
workspaceMode?: string;
|
|
495
|
+
requestedCwd?: string;
|
|
496
|
+
agentId?: string;
|
|
497
|
+
executionWorkspaceId?: string | null;
|
|
498
|
+
/**
|
|
499
|
+
* The harness/adapter type for THIS run (the agent's adapter), so a single
|
|
500
|
+
* environment can serve mixed harnesses. When omitted, the driver falls back to
|
|
501
|
+
* the environment's configured default adapter. A provider that materializes a
|
|
502
|
+
* per-run sandbox should use this to select the runtime image and per-run env.
|
|
503
|
+
*/
|
|
504
|
+
adapterType?: string;
|
|
505
|
+
executionWorkspaceSettings?: Record<string, unknown> | null;
|
|
506
|
+
/**
|
|
507
|
+
* The absolute latest time the acquired lease may stay active, as an ISO 8601
|
|
508
|
+
* timestamp. A caller with an independent deadline (for example the setup-token
|
|
509
|
+
* login session) sets it. A provider that materializes a sandbox must configure
|
|
510
|
+
* a provider-side expiry at or before this time, and return the real provider
|
|
511
|
+
* expiry in `PluginEnvironmentLease.expiresAt`. When the provider cannot bound
|
|
512
|
+
* the sandbox at or before this time, it returns no expiry, so the server fails
|
|
513
|
+
* closed and releases the lease. When omitted, the provider keeps its default
|
|
514
|
+
* lifetime.
|
|
515
|
+
*/
|
|
516
|
+
requestedExpiresAt?: string | null;
|
|
517
|
+
}
|
|
518
|
+
export interface PluginEnvironmentResumeLeaseParams extends PluginEnvironmentDriverBaseParams {
|
|
519
|
+
providerLeaseId: string;
|
|
520
|
+
leaseMetadata?: Record<string, unknown>;
|
|
521
|
+
}
|
|
522
|
+
export interface PluginEnvironmentReleaseLeaseParams extends PluginEnvironmentDriverBaseParams {
|
|
523
|
+
/** Explicit operator cancellation: terminate active work instead of waiting
|
|
524
|
+
* for command/sync activity to drain. Still requires a provider receipt. */
|
|
525
|
+
cancelActiveWork?: boolean;
|
|
526
|
+
providerLeaseId: string | null;
|
|
527
|
+
leaseMetadata?: Record<string, unknown>;
|
|
528
|
+
}
|
|
529
|
+
/** Returned only after the provider confirms that execution has ended. A queued
|
|
530
|
+
* stop request or successful local cleanup is not a termination receipt. */
|
|
531
|
+
export interface PluginEnvironmentTerminationReceipt {
|
|
532
|
+
providerLeaseId: string;
|
|
533
|
+
state: "stopped" | "destroyed";
|
|
534
|
+
}
|
|
535
|
+
export interface PluginEnvironmentDestroyLeaseParams extends PluginEnvironmentReleaseLeaseParams {
|
|
536
|
+
}
|
|
537
|
+
export interface PluginEnvironmentRealizeWorkspaceParams extends PluginEnvironmentDriverBaseParams {
|
|
538
|
+
lease: PluginEnvironmentLease;
|
|
539
|
+
workspace: {
|
|
540
|
+
localPath?: string;
|
|
541
|
+
remotePath?: string;
|
|
542
|
+
mode?: string;
|
|
543
|
+
metadata?: Record<string, unknown>;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* A plugin `environmentRealizeWorkspace` handler returns only the realized cwd and provider
|
|
548
|
+
* metadata. The server, not the plugin, builds the full workspace-realization record from the run
|
|
549
|
+
* request and merges this cwd and metadata into it. Do not return a `workspaceRealization` record
|
|
550
|
+
* here; the server owns that record, so the referenced (mentioned) project sources reach the adapter.
|
|
551
|
+
*/
|
|
552
|
+
export interface PluginEnvironmentRealizeWorkspaceResult {
|
|
553
|
+
cwd: string;
|
|
554
|
+
metadata?: Record<string, unknown>;
|
|
555
|
+
}
|
|
556
|
+
export interface PluginEnvironmentExecuteParams extends PluginEnvironmentDriverBaseParams {
|
|
557
|
+
lease: PluginEnvironmentLease;
|
|
558
|
+
command: string;
|
|
559
|
+
args?: string[];
|
|
560
|
+
cwd?: string;
|
|
561
|
+
env?: Record<string, string>;
|
|
562
|
+
stdin?: string;
|
|
563
|
+
timeoutMs?: number;
|
|
564
|
+
/**
|
|
565
|
+
* Run this command outside the lease's persistent session.
|
|
566
|
+
*
|
|
567
|
+
* The host sets this flag on a command that runs before the run's agent work,
|
|
568
|
+
* for example the workspace provision command. A provider that opens a
|
|
569
|
+
* persistent session on the first command must NOT open the session for such a
|
|
570
|
+
* command; it runs the command one-shot and leaves the session closed. The
|
|
571
|
+
* session then opens on the first in-run command instead. A provider that does
|
|
572
|
+
* not use a persistent session ignores this flag.
|
|
573
|
+
*
|
|
574
|
+
* The default (absent or `false`) keeps the session path, so a normal in-run
|
|
575
|
+
* command opens and reuses the session as before.
|
|
576
|
+
*/
|
|
577
|
+
bypassSession?: boolean;
|
|
578
|
+
}
|
|
579
|
+
export interface PluginEnvironmentExecuteResult {
|
|
580
|
+
exitCode: number | null;
|
|
581
|
+
signal?: string | null;
|
|
582
|
+
timedOut: boolean;
|
|
583
|
+
stdout: string;
|
|
584
|
+
stderr: string;
|
|
585
|
+
metadata?: Record<string, unknown>;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* A single source→target file or directory transfer within a sync operation.
|
|
589
|
+
*
|
|
590
|
+
* For `environmentSyncIn`, `sourcePath` is a host path and `targetPath` is a
|
|
591
|
+
* sandbox path; for `environmentSyncOut` the direction is reversed. All sandbox
|
|
592
|
+
* paths are POSIX. The contract is provider-agnostic: a provider may transfer a
|
|
593
|
+
* directory by whatever native mechanism it prefers (bulk upload, internal tar,
|
|
594
|
+
* per-file enumeration) as long as the observable result matches this mapping.
|
|
595
|
+
*/
|
|
596
|
+
export interface PluginSyncFileMapping {
|
|
597
|
+
/** Absolute path of the transfer source (host for syncIn, sandbox for syncOut). */
|
|
598
|
+
sourcePath: string;
|
|
599
|
+
/** Absolute path of the transfer target (sandbox for syncIn, host for syncOut). */
|
|
600
|
+
targetPath: string;
|
|
601
|
+
/** Whether the mapping transfers a single regular file or a directory tree. */
|
|
602
|
+
kind: "file" | "directory";
|
|
603
|
+
/**
|
|
604
|
+
* POSIX file mode to apply at the target (e.g. `0o600` for secret material).
|
|
605
|
+
* The target MUST carry this mode when the transfer completes.
|
|
606
|
+
*
|
|
607
|
+
* For a transfer to a host target, providers MUST apply the mode with no
|
|
608
|
+
* world-readable window: create the target with the mode, or apply the mode
|
|
609
|
+
* before the bytes arrive at the target path. A host file sits outside the
|
|
610
|
+
* sandbox boundary, so an open window shows the bytes to other host
|
|
611
|
+
* processes.
|
|
612
|
+
*
|
|
613
|
+
* For a transfer to a sandbox target, providers MAY apply the mode after
|
|
614
|
+
* they write the bytes. The sandbox is the trust boundary, so a short window
|
|
615
|
+
* shows the bytes only to code that already runs in that sandbox.
|
|
616
|
+
*/
|
|
617
|
+
mode?: number;
|
|
618
|
+
/** Glob patterns to exclude when `kind` is `"directory"`. */
|
|
619
|
+
exclude?: string[];
|
|
620
|
+
/**
|
|
621
|
+
* Symlink handling for `kind: "directory"` transfers. Falsy preserves symlinks
|
|
622
|
+
* as links; `true` dereferences them to their target bytes. Mirrors tar's `-h`.
|
|
623
|
+
*/
|
|
624
|
+
followSymlinks?: boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Advisory read-write intent for the sandbox target. `"rw"` means the author
|
|
627
|
+
* expects the agent to change the bytes at the target and keep the change.
|
|
628
|
+
* `"ro"` means the target is a read-only tree. An absent value defaults to
|
|
629
|
+
* `"ro"` (read-only is the safe default for an advisory signal).
|
|
630
|
+
*
|
|
631
|
+
* This field is advisory metadata for an optional sandbox feedback wrapper. It
|
|
632
|
+
* does not change the transfer and adds no security. A provider may read it to
|
|
633
|
+
* bind the read-write targets read-write under the wrapper, but the ephemeral
|
|
634
|
+
* sandbox stays the only security boundary.
|
|
635
|
+
*/
|
|
636
|
+
access?: "rw" | "ro";
|
|
637
|
+
/**
|
|
638
|
+
* The sandbox directory that becomes read-write when `access` is `"rw"` and a
|
|
639
|
+
* post-upload command extracts `targetPath` into a different directory. A
|
|
640
|
+
* workspace, git-history, or asset mapping uploads a tar archive, so its
|
|
641
|
+
* `targetPath` is the staging archive under the runtime root, not the directory
|
|
642
|
+
* that the extract command fills. This field names that final destination
|
|
643
|
+
* directory, so a consumer records the real read-write destination, not the
|
|
644
|
+
* staging parent. When absent, the read-write destination is the parent
|
|
645
|
+
* directory of `targetPath`. This field is advisory and ignored when `access`
|
|
646
|
+
* is not `"rw"`.
|
|
647
|
+
*/
|
|
648
|
+
writablePath?: string;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* A single control command run against the sandbox after a sync operation's
|
|
652
|
+
* files have landed. Ordered within {@link PluginSyncOperation.postUploadCommands}
|
|
653
|
+
* and executed in array order, fail-fast (the first non-zero exit or timeout
|
|
654
|
+
* aborts the operation).
|
|
655
|
+
*
|
|
656
|
+
* SECURITY — command origin (Stage-1 design review, condition C1). `command` is
|
|
657
|
+
* a **Paperclip/adapter-authored control operation**: it may be supplied ONLY by
|
|
658
|
+
* core/adapter code. No server route, issue/comment content, project/workspace
|
|
659
|
+
* file content, provider-plugin callback, or arbitrary adapter config may supply
|
|
660
|
+
* a raw `command` string, and any path embedded in it MUST be built by
|
|
661
|
+
* adapter/core helpers from already-confined paths and shell-quoted (C3). A
|
|
662
|
+
* provider MUST treat the command as **opaque**: it may execute or reject it, but
|
|
663
|
+
* MUST NOT rewrite, concatenate, or append provider-decided shell fragments to
|
|
664
|
+
* it.
|
|
665
|
+
*/
|
|
666
|
+
export interface PluginPostUploadCommand {
|
|
667
|
+
/**
|
|
668
|
+
* The opaque, adapter-authored shell command to run after upload. Executed
|
|
669
|
+
* verbatim by the provider (never rewritten/concatenated). See the security
|
|
670
|
+
* note above.
|
|
671
|
+
*/
|
|
672
|
+
command: string;
|
|
673
|
+
/**
|
|
674
|
+
* Working directory for the command. When present, MUST be an absolute POSIX
|
|
675
|
+
* path confined under the operation's allowed sandbox target root (condition
|
|
676
|
+
* C2); providers re-validate it before exec. When absent, the provider
|
|
677
|
+
* defaults to the resolved sync remote/runtime root — never a process default
|
|
678
|
+
* cwd.
|
|
679
|
+
*/
|
|
680
|
+
cwd?: string;
|
|
681
|
+
/** Optional per-command timeout in milliseconds. */
|
|
682
|
+
timeoutMs?: number;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* An ordered, opaque unit of work handed to a sync hook. The `operationId` is an
|
|
686
|
+
* opaque, non-sensitive token authored by the orchestrator; a provider MUST NOT
|
|
687
|
+
* interpret it. Operations are applied in array order.
|
|
688
|
+
*/
|
|
689
|
+
export interface PluginSyncOperation {
|
|
690
|
+
operationId: string;
|
|
691
|
+
files: PluginSyncFileMapping[];
|
|
692
|
+
/**
|
|
693
|
+
* Optional ordered control commands run after this operation's files land, in
|
|
694
|
+
* array order, fail-fast. Absent means "no commands" — byte-identical to a
|
|
695
|
+
* pre-contract operation. See {@link PluginPostUploadCommand} for the command
|
|
696
|
+
* origin/confinement security contract (C1–C4).
|
|
697
|
+
*/
|
|
698
|
+
postUploadCommands?: PluginPostUploadCommand[];
|
|
699
|
+
}
|
|
700
|
+
export interface PluginEnvironmentSyncInParams extends PluginEnvironmentDriverBaseParams {
|
|
701
|
+
lease: PluginEnvironmentLease;
|
|
702
|
+
operations: PluginSyncOperation[];
|
|
703
|
+
}
|
|
704
|
+
export interface PluginEnvironmentSyncOutParams extends PluginEnvironmentDriverBaseParams {
|
|
705
|
+
lease: PluginEnvironmentLease;
|
|
706
|
+
operations: PluginSyncOperation[];
|
|
707
|
+
}
|
|
708
|
+
/** Per-operation transfer accounting returned by a sync hook, for observability. */
|
|
709
|
+
export interface PluginEnvironmentSyncResult {
|
|
710
|
+
operations: {
|
|
711
|
+
operationId: string;
|
|
712
|
+
filesTransferred: number;
|
|
713
|
+
bytesTransferred: number;
|
|
714
|
+
}[];
|
|
715
|
+
}
|
|
716
|
+
export type PluginEnvironmentInteractiveSetupStatus = "starting" | "waiting_for_user" | "capturing" | "promoted" | "cancelled" | "timed_out" | "failed" | "missing";
|
|
717
|
+
export type PluginEnvironmentInteractiveSetupConnectionType = "ssh" | (string & {});
|
|
718
|
+
export type PluginEnvironmentTemplateRefKind = "snapshot" | "image" | "provider_template" | "unknown" | (string & {});
|
|
719
|
+
export interface PluginEnvironmentInteractiveSetupConnectionSummary {
|
|
720
|
+
type: PluginEnvironmentInteractiveSetupConnectionType;
|
|
721
|
+
username?: string | null;
|
|
722
|
+
hostRedacted: boolean;
|
|
723
|
+
portRedacted: boolean;
|
|
724
|
+
commandRedacted?: boolean;
|
|
725
|
+
expiresAt?: string | null;
|
|
726
|
+
metadata?: Record<string, unknown>;
|
|
727
|
+
}
|
|
728
|
+
export interface PluginEnvironmentInteractiveSetupConnectionPayload {
|
|
729
|
+
type: PluginEnvironmentInteractiveSetupConnectionType;
|
|
730
|
+
command?: string | null;
|
|
731
|
+
token?: string | null;
|
|
732
|
+
expiresAt?: string | null;
|
|
733
|
+
metadata?: Record<string, unknown>;
|
|
734
|
+
}
|
|
735
|
+
export interface PluginEnvironmentInteractiveSetupSession {
|
|
736
|
+
providerLeaseId: string | null;
|
|
737
|
+
status: PluginEnvironmentInteractiveSetupStatus;
|
|
738
|
+
connectionSummary: PluginEnvironmentInteractiveSetupConnectionSummary | null;
|
|
739
|
+
connectionPayload?: PluginEnvironmentInteractiveSetupConnectionPayload | null;
|
|
740
|
+
expiresAt?: string | null;
|
|
741
|
+
metadata?: Record<string, unknown>;
|
|
742
|
+
}
|
|
743
|
+
export interface PluginEnvironmentStartInteractiveSetupParams extends PluginEnvironmentDriverBaseParams {
|
|
744
|
+
sessionId: string;
|
|
745
|
+
sourceTemplateRef?: string | null;
|
|
746
|
+
sourceTemplateKind?: PluginEnvironmentTemplateRefKind | null;
|
|
747
|
+
connectionExpiresInMinutes?: number | null;
|
|
748
|
+
expiresAt?: string | null;
|
|
749
|
+
}
|
|
750
|
+
export interface PluginEnvironmentGetInteractiveSetupParams extends PluginEnvironmentDriverBaseParams {
|
|
751
|
+
providerLeaseId: string | null;
|
|
752
|
+
setupMetadata?: Record<string, unknown>;
|
|
753
|
+
includeConnectionPayload?: boolean;
|
|
754
|
+
connectionExpiresInMinutes?: number | null;
|
|
755
|
+
}
|
|
756
|
+
export interface PluginEnvironmentCaptureTemplateParams extends PluginEnvironmentDriverBaseParams {
|
|
757
|
+
providerLeaseId: string | null;
|
|
758
|
+
setupMetadata?: Record<string, unknown>;
|
|
759
|
+
sourceTemplateRef?: string | null;
|
|
760
|
+
previousTemplateRef?: string | null;
|
|
761
|
+
templateLabel?: string | null;
|
|
762
|
+
timeoutMs?: number | null;
|
|
763
|
+
}
|
|
764
|
+
export interface PluginEnvironmentCaptureTemplateResult {
|
|
765
|
+
templateRef: string;
|
|
766
|
+
templateKind: PluginEnvironmentTemplateRefKind;
|
|
767
|
+
metadata?: Record<string, unknown>;
|
|
768
|
+
}
|
|
769
|
+
export interface PluginEnvironmentCancelInteractiveSetupParams extends PluginEnvironmentDriverBaseParams {
|
|
770
|
+
providerLeaseId: string | null;
|
|
771
|
+
setupMetadata?: Record<string, unknown>;
|
|
772
|
+
reason?: string | null;
|
|
773
|
+
}
|
|
774
|
+
export interface PluginEnvironmentCancelInteractiveSetupResult {
|
|
775
|
+
status: Extract<PluginEnvironmentInteractiveSetupStatus, "cancelled" | "timed_out" | "failed" | "missing">;
|
|
776
|
+
metadata?: Record<string, unknown>;
|
|
777
|
+
}
|
|
778
|
+
export interface PluginEnvironmentDeleteTemplateParams extends PluginEnvironmentDriverBaseParams {
|
|
779
|
+
templateRef: string;
|
|
780
|
+
templateKind?: PluginEnvironmentTemplateRefKind;
|
|
781
|
+
metadata?: Record<string, unknown>;
|
|
782
|
+
reason?: string | null;
|
|
783
|
+
}
|
|
784
|
+
export interface PluginEnvironmentDeleteTemplateResult {
|
|
785
|
+
deleted: boolean;
|
|
786
|
+
metadata?: Record<string, unknown>;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Bounds request issued by a plugin UI running inside a host-managed launcher
|
|
790
|
+
* container such as a modal, drawer, or popover.
|
|
791
|
+
*/
|
|
792
|
+
export interface PluginModalBoundsRequest {
|
|
793
|
+
/** High-level size preset requested from the host. */
|
|
794
|
+
bounds: PluginLauncherBounds;
|
|
795
|
+
/** Optional explicit width override in CSS pixels. */
|
|
796
|
+
width?: number;
|
|
797
|
+
/** Optional explicit height override in CSS pixels. */
|
|
798
|
+
height?: number;
|
|
799
|
+
/** Optional lower bounds for host resizing decisions. */
|
|
800
|
+
minWidth?: number;
|
|
801
|
+
minHeight?: number;
|
|
802
|
+
/** Optional upper bounds for host resizing decisions. */
|
|
803
|
+
maxWidth?: number;
|
|
804
|
+
maxHeight?: number;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Reason metadata supplied by host-managed close lifecycle callbacks.
|
|
808
|
+
*/
|
|
809
|
+
export interface PluginRenderCloseEvent {
|
|
810
|
+
reason: "escapeKey" | "backdrop" | "hostNavigation" | "programmatic" | "submit" | "unknown";
|
|
811
|
+
nativeEvent?: unknown;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* The closed set of login command identities. The host resolves the key from the
|
|
815
|
+
* trusted adapter type and carries it in the open request. The worker maps the
|
|
816
|
+
* key to a compile-time command. The open request carries no command string, so a
|
|
817
|
+
* caller cannot select or override the command.
|
|
818
|
+
*/
|
|
819
|
+
export type PluginLoginCommandKey = "claude" | "codex" | "grok";
|
|
820
|
+
/** The open request for one live login pseudo-terminal. The worker registers the terminal by `hostRouteId`. */
|
|
821
|
+
export interface PluginLoginPtyOpenParams {
|
|
822
|
+
/** The host-owned opaque route identifier. The worker registers the terminal by it. */
|
|
823
|
+
hostRouteId: string;
|
|
824
|
+
/** The environment driver key, for the worker sandbox scope. It routes the worker; it confers no command authority. */
|
|
825
|
+
driverKey: string;
|
|
826
|
+
/** The company that owns the login session. */
|
|
827
|
+
companyId: string;
|
|
828
|
+
/** The environment the login session runs in. */
|
|
829
|
+
environmentId: string;
|
|
830
|
+
/** The provider lease the sandbox is cached under. The worker resolves the sandbox by it. */
|
|
831
|
+
providerLeaseId: string;
|
|
832
|
+
/**
|
|
833
|
+
* The host-resolved fixed command identity. The worker maps it to a
|
|
834
|
+
* compile-time command. The open request carries no command string.
|
|
835
|
+
*/
|
|
836
|
+
loginCommandKey: PluginLoginCommandKey;
|
|
837
|
+
/**
|
|
838
|
+
* The server-controlled, validated session home. The shape is exact:
|
|
839
|
+
* `/tmp/paperclip-adapter-login/<uuid>`. The worker revalidates the shape
|
|
840
|
+
* before it touches the filesystem.
|
|
841
|
+
*/
|
|
842
|
+
sessionHome: string;
|
|
843
|
+
}
|
|
844
|
+
/** The open reply. It returns the worker session identifier for output binding only. */
|
|
845
|
+
export interface PluginLoginPtyOpenResult {
|
|
846
|
+
/** The worker session identifier. It binds the output and the exit notification only. */
|
|
847
|
+
workerSessionId: string;
|
|
848
|
+
}
|
|
849
|
+
/** The input request. It carries the worker session identifier and the raw input bytes. */
|
|
850
|
+
export interface PluginLoginPtyInputParams {
|
|
851
|
+
/** The worker session identifier that the open reply returned. */
|
|
852
|
+
workerSessionId: string;
|
|
853
|
+
/** The raw input bytes to write to the terminal. */
|
|
854
|
+
data: string;
|
|
855
|
+
}
|
|
856
|
+
/** The stop request. It carries the worker session identifier. */
|
|
857
|
+
export interface PluginLoginPtyStopParams {
|
|
858
|
+
/** The worker session identifier that the open reply returned. */
|
|
859
|
+
workerSessionId: string;
|
|
860
|
+
}
|
|
861
|
+
/** The close request. The host route identifier is the authoritative key. */
|
|
862
|
+
export interface PluginLoginPtyCloseParams {
|
|
863
|
+
/**
|
|
864
|
+
* The host-owned opaque route identifier. This is the authoritative close key,
|
|
865
|
+
* so the host closes the terminal even when no worker session identifier
|
|
866
|
+
* arrived after a lost open reply.
|
|
867
|
+
*/
|
|
868
|
+
hostRouteId: string;
|
|
869
|
+
/**
|
|
870
|
+
* A non-authoritative worker session identifier. The worker never keys the
|
|
871
|
+
* close on it. The field is optional, so a close with only the host route
|
|
872
|
+
* identifier is a valid request for this lifecycle.
|
|
873
|
+
*/
|
|
874
|
+
workerSessionId?: string;
|
|
875
|
+
}
|
|
876
|
+
/** The close reply. It acknowledges the close and carries the same host route identifier. */
|
|
877
|
+
export interface PluginLoginPtyCloseResult {
|
|
878
|
+
/** The close acknowledgement. It carries the same host route identifier the close sent. */
|
|
879
|
+
hostRouteId: string;
|
|
880
|
+
}
|
|
881
|
+
/** The worker→host pseudo-terminal output notification parameters. Modeled on `execute.log`. */
|
|
882
|
+
export interface PluginLoginPtyOutputParams {
|
|
883
|
+
/**
|
|
884
|
+
* The host route identifier the open request carried. The worker echoes it,
|
|
885
|
+
* so the host can hold more than one concurrent login pseudo-terminal per
|
|
886
|
+
* worker and route each chunk to its own route.
|
|
887
|
+
*/
|
|
888
|
+
hostRouteId: string;
|
|
889
|
+
/** The worker session identifier that the open reply returned. */
|
|
890
|
+
workerSessionId: string;
|
|
891
|
+
/** The raw terminal output bytes. */
|
|
892
|
+
chunk: string;
|
|
893
|
+
}
|
|
894
|
+
/** The worker→host pseudo-terminal exit notification parameters. */
|
|
895
|
+
export interface PluginLoginPtyExitParams {
|
|
896
|
+
/**
|
|
897
|
+
* The host route identifier the open request carried. The worker echoes it,
|
|
898
|
+
* so the host can hold more than one concurrent login pseudo-terminal per
|
|
899
|
+
* worker and resolve the exit against its own route.
|
|
900
|
+
*/
|
|
901
|
+
hostRouteId: string;
|
|
902
|
+
/** The worker session identifier that the open reply returned. */
|
|
903
|
+
workerSessionId: string;
|
|
904
|
+
/** The child exit code, or null when the child ended with no code. */
|
|
905
|
+
exitCode: number | null;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* One live login pseudo-terminal session in the worker. The worker opener returns
|
|
909
|
+
* it. The shape matches the sandbox provider login pseudo-terminal session,
|
|
910
|
+
* so a provider passes its session with no adapter.
|
|
911
|
+
*/
|
|
912
|
+
export interface PluginLoginPtyWorkerSession {
|
|
913
|
+
/** Registers the one output listener. The session streams each raw chunk in order. */
|
|
914
|
+
onData(listener: (chunk: string) => void): void;
|
|
915
|
+
/** Writes raw input bytes to the pseudo-terminal. */
|
|
916
|
+
write(data: string): void;
|
|
917
|
+
/** Resolves with the child exit code when the command ends. */
|
|
918
|
+
wait(): Promise<{
|
|
919
|
+
exitCode: number | null;
|
|
920
|
+
}>;
|
|
921
|
+
/** Stops the child process. Safe to call more than one time. */
|
|
922
|
+
kill(): void;
|
|
923
|
+
/** Releases the session resources. Safe to call more than one time. */
|
|
924
|
+
close(): Promise<void>;
|
|
925
|
+
}
|
|
926
|
+
/** The worker→host notification method for one pseudo-terminal output chunk. */
|
|
927
|
+
export declare const LOGIN_PTY_OUTPUT_NOTIFICATION = "loginPty.output";
|
|
928
|
+
/** The worker→host notification method for one pseudo-terminal exit. */
|
|
929
|
+
export declare const LOGIN_PTY_EXIT_NOTIFICATION = "loginPty.exit";
|
|
930
|
+
/** The wire-safe JSON-RPC form of one duplex channel byte chunk: a base64 string. */
|
|
931
|
+
export type ChannelBytesWireValue = string;
|
|
932
|
+
/** Encodes raw channel bytes into the wire-safe JSON-RPC representation. */
|
|
933
|
+
export declare function encodeChannelBytes(bytes: Uint8Array): ChannelBytesWireValue;
|
|
934
|
+
/**
|
|
935
|
+
* Decodes the wire-safe JSON-RPC representation back to raw channel bytes.
|
|
936
|
+
* Returns `null` for a value that is not a well-formed base64 string, so a
|
|
937
|
+
* caller on the trust boundary treats a malformed frame as a protocol error
|
|
938
|
+
* instead of silently substituting the empty byte array.
|
|
939
|
+
*/
|
|
940
|
+
export declare function decodeChannelBytes(value: unknown): Uint8Array | null;
|
|
941
|
+
/** The open request for one persistent duplex channel. The worker registers the channel by `hostRouteId`. */
|
|
942
|
+
export interface PluginDuplexChannelOpenParams {
|
|
943
|
+
/** The host-owned opaque route identifier. The worker registers the channel by it. */
|
|
944
|
+
hostRouteId: string;
|
|
945
|
+
/** The environment driver key, for the worker sandbox scope. */
|
|
946
|
+
driverKey: string;
|
|
947
|
+
/** The company that owns the channel. */
|
|
948
|
+
companyId: string;
|
|
949
|
+
/** The environment the channel runs in. */
|
|
950
|
+
environmentId: string;
|
|
951
|
+
/** The provider lease the sandbox is cached under. The worker resolves the sandbox by it. */
|
|
952
|
+
providerLeaseId: string;
|
|
953
|
+
/**
|
|
954
|
+
* The command argument vector the worker runs on the channel. Element 0 is the
|
|
955
|
+
* program and the rest are its arguments. The worker quotes each element for the
|
|
956
|
+
* shell, so a shell metacharacter in an element cannot inject a shell command.
|
|
957
|
+
*/
|
|
958
|
+
command: readonly string[];
|
|
959
|
+
}
|
|
960
|
+
/** The open reply. It echoes the host route identifier and returns the worker session identifier. */
|
|
961
|
+
export interface PluginDuplexChannelOpenResult {
|
|
962
|
+
/** The host route identifier the open request carried. The worker echoes it, so the host binds the exact pair. */
|
|
963
|
+
hostRouteId: string;
|
|
964
|
+
/** The worker session identifier. It binds the data and the exit notification only. */
|
|
965
|
+
workerSessionId: string;
|
|
966
|
+
}
|
|
967
|
+
/** The write request. It carries the exact route pair and the raw input bytes. */
|
|
968
|
+
export interface PluginDuplexChannelWriteParams {
|
|
969
|
+
/** The host route identifier the open request carried. The worker acts only on the exact live pair. */
|
|
970
|
+
hostRouteId: string;
|
|
971
|
+
/** The worker session identifier that the open reply returned. */
|
|
972
|
+
workerSessionId: string;
|
|
973
|
+
/** The raw input bytes to write to the channel, in the {@link ChannelBytesWireValue} wire form. */
|
|
974
|
+
data: ChannelBytesWireValue;
|
|
975
|
+
}
|
|
976
|
+
/** The stop request. It carries the exact route pair. */
|
|
977
|
+
export interface PluginDuplexChannelStopParams {
|
|
978
|
+
/** The host route identifier the open request carried. The worker acts only on the exact live pair. */
|
|
979
|
+
hostRouteId: string;
|
|
980
|
+
/** The worker session identifier that the open reply returned. */
|
|
981
|
+
workerSessionId: string;
|
|
982
|
+
}
|
|
983
|
+
/** The close request. The host route identifier is the authoritative key. */
|
|
984
|
+
export interface PluginDuplexChannelCloseParams {
|
|
985
|
+
/**
|
|
986
|
+
* The host-owned opaque route identifier. This is the authoritative close key,
|
|
987
|
+
* so the host closes the channel even when no worker session identifier arrived
|
|
988
|
+
* after a lost open reply.
|
|
989
|
+
*/
|
|
990
|
+
hostRouteId: string;
|
|
991
|
+
/**
|
|
992
|
+
* A non-authoritative worker session identifier. The worker never keys the
|
|
993
|
+
* close on it. The field is optional, so a close with only the host route
|
|
994
|
+
* identifier is a valid request for this lifecycle.
|
|
995
|
+
*/
|
|
996
|
+
workerSessionId?: string;
|
|
997
|
+
}
|
|
998
|
+
/** The close reply. It acknowledges the close and echoes the route identifiers. */
|
|
999
|
+
export interface PluginDuplexChannelCloseResult {
|
|
1000
|
+
/** The close acknowledgement. It carries the same host route identifier the close sent. */
|
|
1001
|
+
hostRouteId: string;
|
|
1002
|
+
/**
|
|
1003
|
+
* The bound worker session identifier. The worker echoes it on a bound close,
|
|
1004
|
+
* so the host verifies the exact pair. It is absent on a pre-bind route-only
|
|
1005
|
+
* close, where no session bound yet.
|
|
1006
|
+
*/
|
|
1007
|
+
workerSessionId?: string;
|
|
1008
|
+
}
|
|
1009
|
+
/** The worker→host duplex channel data notification parameters. */
|
|
1010
|
+
export interface PluginDuplexChannelDataParams {
|
|
1011
|
+
/** The host route identifier the open request carried. The worker echoes it, so the host routes the exact pair. */
|
|
1012
|
+
hostRouteId: string;
|
|
1013
|
+
/** The worker session identifier that the open reply returned. */
|
|
1014
|
+
workerSessionId: string;
|
|
1015
|
+
/** The raw channel output bytes, in the {@link ChannelBytesWireValue} wire form. */
|
|
1016
|
+
chunk: ChannelBytesWireValue;
|
|
1017
|
+
}
|
|
1018
|
+
/** The worker→host duplex channel exit notification parameters. */
|
|
1019
|
+
export interface PluginDuplexChannelExitParams {
|
|
1020
|
+
/** The host route identifier the open request carried. The worker echoes it, so the host routes the exact pair. */
|
|
1021
|
+
hostRouteId: string;
|
|
1022
|
+
/** The worker session identifier that the open reply returned. */
|
|
1023
|
+
workerSessionId: string;
|
|
1024
|
+
/** The child exit code, or null when the child ended with no code. */
|
|
1025
|
+
exitCode: number | null;
|
|
1026
|
+
/**
|
|
1027
|
+
* True when the provider transport closed with no exit data, so the exit is a
|
|
1028
|
+
* reason-less transport close, not a process exit. Absent or false marks a real
|
|
1029
|
+
* process exit. The host maps a transport close to a distinct loss reason.
|
|
1030
|
+
*/
|
|
1031
|
+
transportClosed?: boolean;
|
|
1032
|
+
}
|
|
1033
|
+
/** The worker→host notification method for one duplex channel data chunk. */
|
|
1034
|
+
export declare const DUPLEX_CHANNEL_DATA_NOTIFICATION = "duplexChannel.data";
|
|
1035
|
+
/** The worker→host notification method for one duplex channel exit. */
|
|
1036
|
+
export declare const DUPLEX_CHANNEL_EXIT_NOTIFICATION = "duplexChannel.exit";
|
|
1037
|
+
/**
|
|
1038
|
+
* Map of host→worker RPC method names to their `[params, result]` types.
|
|
1039
|
+
*
|
|
1040
|
+
* This type is the single source of truth for all methods the host can call
|
|
1041
|
+
* on a worker. Used by both the host dispatcher and the worker handler to
|
|
1042
|
+
* ensure type safety across the IPC boundary.
|
|
1043
|
+
*/
|
|
1044
|
+
export interface HostToWorkerMethods {
|
|
1045
|
+
/** @see PLUGIN_SPEC.md §13.1 */
|
|
1046
|
+
initialize: [params: InitializeParams, result: InitializeResult];
|
|
1047
|
+
/** @see PLUGIN_SPEC.md §13.2 */
|
|
1048
|
+
health: [params: Record<string, never>, result: PluginHealthDiagnostics];
|
|
1049
|
+
/** @see PLUGIN_SPEC.md §12.5 */
|
|
1050
|
+
shutdown: [params: Record<string, never>, result: void];
|
|
1051
|
+
/** @see PLUGIN_SPEC.md §13.3 */
|
|
1052
|
+
validateConfig: [params: ValidateConfigParams, result: PluginConfigValidationResult];
|
|
1053
|
+
/** @see PLUGIN_SPEC.md §13.4 */
|
|
1054
|
+
configChanged: [params: ConfigChangedParams, result: void];
|
|
1055
|
+
/** @see PLUGIN_SPEC.md §13.5 */
|
|
1056
|
+
onEvent: [params: OnEventParams, result: void];
|
|
1057
|
+
/** @see PLUGIN_SPEC.md §13.6 */
|
|
1058
|
+
runJob: [params: RunJobParams, result: void];
|
|
1059
|
+
/** @see PLUGIN_SPEC.md §13.7 */
|
|
1060
|
+
handleWebhook: [params: PluginWebhookInput, result: void];
|
|
1061
|
+
/** Scoped plugin API route dispatch. */
|
|
1062
|
+
handleApiRequest: [params: PluginApiRequestInput, result: PluginApiResponse];
|
|
1063
|
+
/** @see PLUGIN_SPEC.md §13.8 */
|
|
1064
|
+
getData: [params: GetDataParams, result: unknown];
|
|
1065
|
+
/** @see PLUGIN_SPEC.md §13.9 */
|
|
1066
|
+
performAction: [params: PerformActionParams, result: unknown];
|
|
1067
|
+
/** @see PLUGIN_SPEC.md §13.10 */
|
|
1068
|
+
executeTool: [params: ExecuteToolParams, result: ToolResult];
|
|
1069
|
+
detectExternalObjects: [
|
|
1070
|
+
params: DetectExternalObjectsParams,
|
|
1071
|
+
result: DetectExternalObjectsResult
|
|
1072
|
+
];
|
|
1073
|
+
resolveExternalObject: [
|
|
1074
|
+
params: ResolveExternalObjectParams,
|
|
1075
|
+
result: PluginExternalObjectResolveResult
|
|
1076
|
+
];
|
|
1077
|
+
refreshExternalObjects: [
|
|
1078
|
+
params: RefreshExternalObjectsParams,
|
|
1079
|
+
result: RefreshExternalObjectsResult
|
|
1080
|
+
];
|
|
1081
|
+
environmentValidateConfig: [
|
|
1082
|
+
params: PluginEnvironmentValidateConfigParams,
|
|
1083
|
+
result: PluginEnvironmentValidationResult
|
|
1084
|
+
];
|
|
1085
|
+
environmentProbe: [
|
|
1086
|
+
params: PluginEnvironmentProbeParams,
|
|
1087
|
+
result: PluginEnvironmentProbeResult
|
|
1088
|
+
];
|
|
1089
|
+
environmentAcquireLease: [
|
|
1090
|
+
params: PluginEnvironmentAcquireLeaseParams,
|
|
1091
|
+
result: PluginEnvironmentLease
|
|
1092
|
+
];
|
|
1093
|
+
environmentResumeLease: [
|
|
1094
|
+
params: PluginEnvironmentResumeLeaseParams,
|
|
1095
|
+
result: PluginEnvironmentLease
|
|
1096
|
+
];
|
|
1097
|
+
environmentReleaseLease: [
|
|
1098
|
+
params: PluginEnvironmentReleaseLeaseParams,
|
|
1099
|
+
result: PluginEnvironmentTerminationReceipt | void
|
|
1100
|
+
];
|
|
1101
|
+
environmentDestroyLease: [
|
|
1102
|
+
params: PluginEnvironmentDestroyLeaseParams,
|
|
1103
|
+
result: PluginEnvironmentTerminationReceipt | void
|
|
1104
|
+
];
|
|
1105
|
+
environmentRealizeWorkspace: [
|
|
1106
|
+
params: PluginEnvironmentRealizeWorkspaceParams,
|
|
1107
|
+
result: PluginEnvironmentRealizeWorkspaceResult
|
|
1108
|
+
];
|
|
1109
|
+
environmentExecute: [
|
|
1110
|
+
params: PluginEnvironmentExecuteParams,
|
|
1111
|
+
result: PluginEnvironmentExecuteResult
|
|
1112
|
+
];
|
|
1113
|
+
environmentRunnerIngressEndpoint: [
|
|
1114
|
+
params: PluginEnvironmentRunnerIngressEndpointParams,
|
|
1115
|
+
result: PluginEnvironmentRunnerIngressEndpoint
|
|
1116
|
+
];
|
|
1117
|
+
environmentSyncIn: [
|
|
1118
|
+
params: PluginEnvironmentSyncInParams,
|
|
1119
|
+
result: PluginEnvironmentSyncResult
|
|
1120
|
+
];
|
|
1121
|
+
environmentSyncOut: [
|
|
1122
|
+
params: PluginEnvironmentSyncOutParams,
|
|
1123
|
+
result: PluginEnvironmentSyncResult
|
|
1124
|
+
];
|
|
1125
|
+
environmentStartInteractiveSetup: [
|
|
1126
|
+
params: PluginEnvironmentStartInteractiveSetupParams,
|
|
1127
|
+
result: PluginEnvironmentInteractiveSetupSession
|
|
1128
|
+
];
|
|
1129
|
+
environmentGetInteractiveSetup: [
|
|
1130
|
+
params: PluginEnvironmentGetInteractiveSetupParams,
|
|
1131
|
+
result: PluginEnvironmentInteractiveSetupSession
|
|
1132
|
+
];
|
|
1133
|
+
environmentCaptureTemplate: [
|
|
1134
|
+
params: PluginEnvironmentCaptureTemplateParams,
|
|
1135
|
+
result: PluginEnvironmentCaptureTemplateResult
|
|
1136
|
+
];
|
|
1137
|
+
environmentCancelInteractiveSetup: [
|
|
1138
|
+
params: PluginEnvironmentCancelInteractiveSetupParams,
|
|
1139
|
+
result: PluginEnvironmentCancelInteractiveSetupResult
|
|
1140
|
+
];
|
|
1141
|
+
environmentDeleteTemplate: [
|
|
1142
|
+
params: PluginEnvironmentDeleteTemplateParams,
|
|
1143
|
+
result: PluginEnvironmentDeleteTemplateResult
|
|
1144
|
+
];
|
|
1145
|
+
/** Open one live login pseudo-terminal keyed by a host-owned route identifier. */
|
|
1146
|
+
loginPtyOpen: [
|
|
1147
|
+
params: PluginLoginPtyOpenParams,
|
|
1148
|
+
result: PluginLoginPtyOpenResult
|
|
1149
|
+
];
|
|
1150
|
+
/** Write delayed input to a live login pseudo-terminal, keyed by the worker session identifier. */
|
|
1151
|
+
loginPtyInput: [params: PluginLoginPtyInputParams, result: void];
|
|
1152
|
+
/** Stop a live login pseudo-terminal child, keyed by the worker session identifier. */
|
|
1153
|
+
loginPtyStop: [params: PluginLoginPtyStopParams, result: void];
|
|
1154
|
+
/** Close a live login pseudo-terminal by the host route identifier and return a bound acknowledgement. */
|
|
1155
|
+
loginPtyClose: [
|
|
1156
|
+
params: PluginLoginPtyCloseParams,
|
|
1157
|
+
result: PluginLoginPtyCloseResult
|
|
1158
|
+
];
|
|
1159
|
+
/** Open one persistent duplex channel keyed by a host-owned route identifier. */
|
|
1160
|
+
duplexChannelOpen: [
|
|
1161
|
+
params: PluginDuplexChannelOpenParams,
|
|
1162
|
+
result: PluginDuplexChannelOpenResult
|
|
1163
|
+
];
|
|
1164
|
+
/** Write raw input to a persistent duplex channel, keyed by the worker session identifier. */
|
|
1165
|
+
duplexChannelWrite: [params: PluginDuplexChannelWriteParams, result: void];
|
|
1166
|
+
/** Stop a persistent duplex channel child, keyed by the worker session identifier. */
|
|
1167
|
+
duplexChannelStop: [params: PluginDuplexChannelStopParams, result: void];
|
|
1168
|
+
/** Close a persistent duplex channel by the host route identifier and return a bound acknowledgement. */
|
|
1169
|
+
duplexChannelClose: [
|
|
1170
|
+
params: PluginDuplexChannelCloseParams,
|
|
1171
|
+
result: PluginDuplexChannelCloseResult
|
|
1172
|
+
];
|
|
1173
|
+
}
|
|
1174
|
+
/** Union of all host→worker method names. */
|
|
1175
|
+
export type HostToWorkerMethodName = keyof HostToWorkerMethods;
|
|
1176
|
+
/** Required methods the worker MUST implement. */
|
|
1177
|
+
export declare const HOST_TO_WORKER_REQUIRED_METHODS: readonly HostToWorkerMethodName[];
|
|
1178
|
+
/** Optional methods the worker MAY implement. */
|
|
1179
|
+
export declare const HOST_TO_WORKER_OPTIONAL_METHODS: readonly HostToWorkerMethodName[];
|
|
1180
|
+
/**
|
|
1181
|
+
* Map of worker→host RPC method names to their `[params, result]` types.
|
|
1182
|
+
*
|
|
1183
|
+
* These represent the SDK client calls that the worker makes back to the
|
|
1184
|
+
* host to access platform services (state, entities, config, etc.).
|
|
1185
|
+
*/
|
|
1186
|
+
export interface WorkerToHostMethods {
|
|
1187
|
+
"config.get": [params: {
|
|
1188
|
+
companyId?: string;
|
|
1189
|
+
}, result: Record<string, unknown>];
|
|
1190
|
+
"localFolders.declarations": [
|
|
1191
|
+
params: Record<string, never>,
|
|
1192
|
+
result: PluginLocalFolderDeclaration[]
|
|
1193
|
+
];
|
|
1194
|
+
"localFolders.configure": [
|
|
1195
|
+
params: {
|
|
1196
|
+
companyId: string;
|
|
1197
|
+
folderKey: string;
|
|
1198
|
+
path: string;
|
|
1199
|
+
access?: "read" | "readWrite";
|
|
1200
|
+
requiredDirectories?: string[];
|
|
1201
|
+
requiredFiles?: string[];
|
|
1202
|
+
},
|
|
1203
|
+
result: PluginLocalFolderStatus
|
|
1204
|
+
];
|
|
1205
|
+
"localFolders.status": [
|
|
1206
|
+
params: {
|
|
1207
|
+
companyId: string;
|
|
1208
|
+
folderKey: string;
|
|
1209
|
+
},
|
|
1210
|
+
result: PluginLocalFolderStatus
|
|
1211
|
+
];
|
|
1212
|
+
"localFolders.list": [
|
|
1213
|
+
params: {
|
|
1214
|
+
companyId: string;
|
|
1215
|
+
folderKey: string;
|
|
1216
|
+
relativePath?: string | null;
|
|
1217
|
+
recursive?: boolean;
|
|
1218
|
+
maxEntries?: number;
|
|
1219
|
+
},
|
|
1220
|
+
result: PluginLocalFolderListing
|
|
1221
|
+
];
|
|
1222
|
+
"localFolders.readText": [
|
|
1223
|
+
params: {
|
|
1224
|
+
companyId: string;
|
|
1225
|
+
folderKey: string;
|
|
1226
|
+
relativePath: string;
|
|
1227
|
+
},
|
|
1228
|
+
result: string
|
|
1229
|
+
];
|
|
1230
|
+
"localFolders.writeTextAtomic": [
|
|
1231
|
+
params: {
|
|
1232
|
+
companyId: string;
|
|
1233
|
+
folderKey: string;
|
|
1234
|
+
relativePath: string;
|
|
1235
|
+
contents: string;
|
|
1236
|
+
},
|
|
1237
|
+
result: PluginLocalFolderStatus
|
|
1238
|
+
];
|
|
1239
|
+
"localFolders.deleteFile": [
|
|
1240
|
+
params: {
|
|
1241
|
+
companyId: string;
|
|
1242
|
+
folderKey: string;
|
|
1243
|
+
relativePath: string;
|
|
1244
|
+
},
|
|
1245
|
+
result: PluginLocalFolderStatus
|
|
1246
|
+
];
|
|
1247
|
+
"state.get": [
|
|
1248
|
+
params: {
|
|
1249
|
+
scopeKind: string;
|
|
1250
|
+
scopeId?: string;
|
|
1251
|
+
namespace?: string;
|
|
1252
|
+
stateKey: string;
|
|
1253
|
+
},
|
|
1254
|
+
result: unknown
|
|
1255
|
+
];
|
|
1256
|
+
"state.set": [
|
|
1257
|
+
params: {
|
|
1258
|
+
scopeKind: string;
|
|
1259
|
+
scopeId?: string;
|
|
1260
|
+
namespace?: string;
|
|
1261
|
+
stateKey: string;
|
|
1262
|
+
value: unknown;
|
|
1263
|
+
},
|
|
1264
|
+
result: void
|
|
1265
|
+
];
|
|
1266
|
+
"state.delete": [
|
|
1267
|
+
params: {
|
|
1268
|
+
scopeKind: string;
|
|
1269
|
+
scopeId?: string;
|
|
1270
|
+
namespace?: string;
|
|
1271
|
+
stateKey: string;
|
|
1272
|
+
},
|
|
1273
|
+
result: void
|
|
1274
|
+
];
|
|
1275
|
+
"db.namespace": [
|
|
1276
|
+
params: Record<string, never>,
|
|
1277
|
+
result: string
|
|
1278
|
+
];
|
|
1279
|
+
"db.query": [
|
|
1280
|
+
params: {
|
|
1281
|
+
sql: string;
|
|
1282
|
+
params?: unknown[];
|
|
1283
|
+
},
|
|
1284
|
+
result: unknown[]
|
|
1285
|
+
];
|
|
1286
|
+
"db.execute": [
|
|
1287
|
+
params: {
|
|
1288
|
+
sql: string;
|
|
1289
|
+
params?: unknown[];
|
|
1290
|
+
},
|
|
1291
|
+
result: {
|
|
1292
|
+
rowCount: number;
|
|
1293
|
+
}
|
|
1294
|
+
];
|
|
1295
|
+
"entities.upsert": [
|
|
1296
|
+
params: {
|
|
1297
|
+
entityType: string;
|
|
1298
|
+
scopeKind: PluginStateScopeKind;
|
|
1299
|
+
scopeId?: string;
|
|
1300
|
+
externalId?: string;
|
|
1301
|
+
title?: string;
|
|
1302
|
+
status?: string;
|
|
1303
|
+
data: Record<string, unknown>;
|
|
1304
|
+
},
|
|
1305
|
+
result: {
|
|
1306
|
+
id: string;
|
|
1307
|
+
entityType: string;
|
|
1308
|
+
scopeKind: PluginStateScopeKind;
|
|
1309
|
+
scopeId: string | null;
|
|
1310
|
+
externalId: string | null;
|
|
1311
|
+
title: string | null;
|
|
1312
|
+
status: string | null;
|
|
1313
|
+
data: Record<string, unknown>;
|
|
1314
|
+
createdAt: string;
|
|
1315
|
+
updatedAt: string;
|
|
1316
|
+
}
|
|
1317
|
+
];
|
|
1318
|
+
"entities.list": [
|
|
1319
|
+
params: {
|
|
1320
|
+
entityType?: string;
|
|
1321
|
+
scopeKind?: PluginStateScopeKind;
|
|
1322
|
+
scopeId?: string;
|
|
1323
|
+
externalId?: string;
|
|
1324
|
+
limit?: number;
|
|
1325
|
+
offset?: number;
|
|
1326
|
+
},
|
|
1327
|
+
result: Array<{
|
|
1328
|
+
id: string;
|
|
1329
|
+
entityType: string;
|
|
1330
|
+
scopeKind: PluginStateScopeKind;
|
|
1331
|
+
scopeId: string | null;
|
|
1332
|
+
externalId: string | null;
|
|
1333
|
+
title: string | null;
|
|
1334
|
+
status: string | null;
|
|
1335
|
+
data: Record<string, unknown>;
|
|
1336
|
+
createdAt: string;
|
|
1337
|
+
updatedAt: string;
|
|
1338
|
+
}>
|
|
1339
|
+
];
|
|
1340
|
+
"events.emit": [
|
|
1341
|
+
params: {
|
|
1342
|
+
name: string;
|
|
1343
|
+
companyId: string;
|
|
1344
|
+
payload: unknown;
|
|
1345
|
+
},
|
|
1346
|
+
result: void
|
|
1347
|
+
];
|
|
1348
|
+
"events.subscribe": [
|
|
1349
|
+
params: {
|
|
1350
|
+
eventPattern: string;
|
|
1351
|
+
filter?: Record<string, unknown> | null;
|
|
1352
|
+
},
|
|
1353
|
+
result: void
|
|
1354
|
+
];
|
|
1355
|
+
"http.fetch": [
|
|
1356
|
+
params: {
|
|
1357
|
+
url: string;
|
|
1358
|
+
init?: Record<string, unknown>;
|
|
1359
|
+
},
|
|
1360
|
+
result: {
|
|
1361
|
+
status: number;
|
|
1362
|
+
statusText: string;
|
|
1363
|
+
headers: Record<string, string>;
|
|
1364
|
+
body: string;
|
|
1365
|
+
}
|
|
1366
|
+
];
|
|
1367
|
+
"secrets.resolve": [
|
|
1368
|
+
params: {
|
|
1369
|
+
secretRef: string | EnvSecretRefBinding;
|
|
1370
|
+
companyId?: string;
|
|
1371
|
+
configPath?: string;
|
|
1372
|
+
},
|
|
1373
|
+
result: string
|
|
1374
|
+
];
|
|
1375
|
+
"activity.log": [
|
|
1376
|
+
params: {
|
|
1377
|
+
companyId: string;
|
|
1378
|
+
message: string;
|
|
1379
|
+
entityType?: string;
|
|
1380
|
+
entityId?: string;
|
|
1381
|
+
metadata?: Record<string, unknown>;
|
|
1382
|
+
},
|
|
1383
|
+
result: void
|
|
1384
|
+
];
|
|
1385
|
+
"metrics.write": [
|
|
1386
|
+
params: {
|
|
1387
|
+
name: string;
|
|
1388
|
+
value: number;
|
|
1389
|
+
tags?: Record<string, string>;
|
|
1390
|
+
/** Owning tenant for `plugin_logs.company_id` (cascade-delete scope). `null`/omitted = instance-scope. */
|
|
1391
|
+
companyId?: string | null;
|
|
1392
|
+
},
|
|
1393
|
+
result: void
|
|
1394
|
+
];
|
|
1395
|
+
"telemetry.track": [
|
|
1396
|
+
params: {
|
|
1397
|
+
eventName: string;
|
|
1398
|
+
dimensions?: Record<string, string | number | boolean>;
|
|
1399
|
+
},
|
|
1400
|
+
result: void
|
|
1401
|
+
];
|
|
1402
|
+
"log": [
|
|
1403
|
+
params: {
|
|
1404
|
+
level: "info" | "warn" | "error" | "debug";
|
|
1405
|
+
message: string;
|
|
1406
|
+
meta?: Record<string, unknown>;
|
|
1407
|
+
/** Owning tenant for `plugin_logs.company_id` (cascade-delete scope). `null`/omitted = instance-scope. */
|
|
1408
|
+
companyId?: string | null;
|
|
1409
|
+
},
|
|
1410
|
+
result: void
|
|
1411
|
+
];
|
|
1412
|
+
"span.record": [
|
|
1413
|
+
params: {
|
|
1414
|
+
/** The bounded span name (for example `pack` or `transfer`). The host
|
|
1415
|
+
* clamps it to a closed set, so a name never carries free-form data. */
|
|
1416
|
+
name: string;
|
|
1417
|
+
/** The span attributes. The host drops every key that is not on the closed
|
|
1418
|
+
* plugin-span allowlist and re-clamps each remaining value. */
|
|
1419
|
+
attributes?: Record<string, string | number | boolean>;
|
|
1420
|
+
/** The optional span status. */
|
|
1421
|
+
status?: {
|
|
1422
|
+
code: number;
|
|
1423
|
+
message?: string;
|
|
1424
|
+
};
|
|
1425
|
+
/** The optional span start time as epoch milliseconds (`Date.now()`).
|
|
1426
|
+
* The worker captures it when it opens the span. The host validates the
|
|
1427
|
+
* pair and records the span with its true native width. An omitted value
|
|
1428
|
+
* makes the host fall back to a synchronous open-and-end. */
|
|
1429
|
+
startTimeMs?: number;
|
|
1430
|
+
/** The optional span end time as epoch milliseconds (`Date.now()`). The
|
|
1431
|
+
* worker captures it when it ends the span. The host uses it as the span
|
|
1432
|
+
* end time when the pair passes the clock-safety check. */
|
|
1433
|
+
endTimeMs?: number;
|
|
1434
|
+
},
|
|
1435
|
+
result: void
|
|
1436
|
+
];
|
|
1437
|
+
"companies.list": [
|
|
1438
|
+
params: {
|
|
1439
|
+
limit?: number;
|
|
1440
|
+
offset?: number;
|
|
1441
|
+
},
|
|
1442
|
+
result: Company[]
|
|
1443
|
+
];
|
|
1444
|
+
"companies.get": [
|
|
1445
|
+
params: {
|
|
1446
|
+
companyId: string;
|
|
1447
|
+
},
|
|
1448
|
+
result: Company | null
|
|
1449
|
+
];
|
|
1450
|
+
"projects.list": [
|
|
1451
|
+
params: {
|
|
1452
|
+
companyId: string;
|
|
1453
|
+
limit?: number;
|
|
1454
|
+
offset?: number;
|
|
1455
|
+
},
|
|
1456
|
+
result: Project[]
|
|
1457
|
+
];
|
|
1458
|
+
"projects.get": [
|
|
1459
|
+
params: {
|
|
1460
|
+
projectId: string;
|
|
1461
|
+
companyId: string;
|
|
1462
|
+
},
|
|
1463
|
+
result: Project | null
|
|
1464
|
+
];
|
|
1465
|
+
"projects.listWorkspaces": [
|
|
1466
|
+
params: {
|
|
1467
|
+
projectId: string;
|
|
1468
|
+
companyId: string;
|
|
1469
|
+
},
|
|
1470
|
+
result: PluginWorkspace[]
|
|
1471
|
+
];
|
|
1472
|
+
"projects.getPrimaryWorkspace": [
|
|
1473
|
+
params: {
|
|
1474
|
+
projectId: string;
|
|
1475
|
+
companyId: string;
|
|
1476
|
+
},
|
|
1477
|
+
result: PluginWorkspace | null
|
|
1478
|
+
];
|
|
1479
|
+
"projects.getWorkspaceForIssue": [
|
|
1480
|
+
params: {
|
|
1481
|
+
issueId: string;
|
|
1482
|
+
companyId: string;
|
|
1483
|
+
},
|
|
1484
|
+
result: PluginWorkspace | null
|
|
1485
|
+
];
|
|
1486
|
+
"executionWorkspaces.get": [
|
|
1487
|
+
params: {
|
|
1488
|
+
workspaceId: string;
|
|
1489
|
+
companyId: string;
|
|
1490
|
+
},
|
|
1491
|
+
result: PluginExecutionWorkspaceMetadata | null
|
|
1492
|
+
];
|
|
1493
|
+
"projects.managed.get": [
|
|
1494
|
+
params: {
|
|
1495
|
+
projectKey: string;
|
|
1496
|
+
companyId: string;
|
|
1497
|
+
},
|
|
1498
|
+
result: PluginManagedProjectResolution
|
|
1499
|
+
];
|
|
1500
|
+
"projects.managed.reconcile": [
|
|
1501
|
+
params: {
|
|
1502
|
+
projectKey: string;
|
|
1503
|
+
companyId: string;
|
|
1504
|
+
},
|
|
1505
|
+
result: PluginManagedProjectResolution
|
|
1506
|
+
];
|
|
1507
|
+
"projects.managed.reset": [
|
|
1508
|
+
params: {
|
|
1509
|
+
projectKey: string;
|
|
1510
|
+
companyId: string;
|
|
1511
|
+
},
|
|
1512
|
+
result: PluginManagedProjectResolution
|
|
1513
|
+
];
|
|
1514
|
+
"routines.managed.get": [
|
|
1515
|
+
params: {
|
|
1516
|
+
routineKey: string;
|
|
1517
|
+
companyId: string;
|
|
1518
|
+
},
|
|
1519
|
+
result: PluginManagedRoutineResolution
|
|
1520
|
+
];
|
|
1521
|
+
"routines.managed.reconcile": [
|
|
1522
|
+
params: {
|
|
1523
|
+
routineKey: string;
|
|
1524
|
+
companyId: string;
|
|
1525
|
+
assigneeAgentId?: string | null;
|
|
1526
|
+
projectId?: string | null;
|
|
1527
|
+
},
|
|
1528
|
+
result: PluginManagedRoutineResolution
|
|
1529
|
+
];
|
|
1530
|
+
"routines.managed.reset": [
|
|
1531
|
+
params: {
|
|
1532
|
+
routineKey: string;
|
|
1533
|
+
companyId: string;
|
|
1534
|
+
assigneeAgentId?: string | null;
|
|
1535
|
+
projectId?: string | null;
|
|
1536
|
+
},
|
|
1537
|
+
result: PluginManagedRoutineResolution
|
|
1538
|
+
];
|
|
1539
|
+
"routines.managed.update": [
|
|
1540
|
+
params: {
|
|
1541
|
+
routineKey: string;
|
|
1542
|
+
companyId: string;
|
|
1543
|
+
status?: string;
|
|
1544
|
+
},
|
|
1545
|
+
result: Routine
|
|
1546
|
+
];
|
|
1547
|
+
"routines.managed.run": [
|
|
1548
|
+
params: {
|
|
1549
|
+
routineKey: string;
|
|
1550
|
+
companyId: string;
|
|
1551
|
+
assigneeAgentId?: string | null;
|
|
1552
|
+
projectId?: string | null;
|
|
1553
|
+
},
|
|
1554
|
+
result: RoutineRun
|
|
1555
|
+
];
|
|
1556
|
+
"skills.managed.get": [
|
|
1557
|
+
params: {
|
|
1558
|
+
skillKey: string;
|
|
1559
|
+
companyId: string;
|
|
1560
|
+
},
|
|
1561
|
+
result: PluginManagedSkillResolution
|
|
1562
|
+
];
|
|
1563
|
+
"skills.managed.reconcile": [
|
|
1564
|
+
params: {
|
|
1565
|
+
skillKey: string;
|
|
1566
|
+
companyId: string;
|
|
1567
|
+
},
|
|
1568
|
+
result: PluginManagedSkillResolution
|
|
1569
|
+
];
|
|
1570
|
+
"skills.managed.reset": [
|
|
1571
|
+
params: {
|
|
1572
|
+
skillKey: string;
|
|
1573
|
+
companyId: string;
|
|
1574
|
+
},
|
|
1575
|
+
result: PluginManagedSkillResolution
|
|
1576
|
+
];
|
|
1577
|
+
"issues.list": [
|
|
1578
|
+
params: {
|
|
1579
|
+
companyId: string;
|
|
1580
|
+
projectId?: string;
|
|
1581
|
+
assigneeAgentId?: string;
|
|
1582
|
+
originKind?: string;
|
|
1583
|
+
originKindPrefix?: string;
|
|
1584
|
+
originId?: string;
|
|
1585
|
+
status?: string;
|
|
1586
|
+
includePluginOperations?: boolean;
|
|
1587
|
+
limit?: number;
|
|
1588
|
+
offset?: number;
|
|
1589
|
+
},
|
|
1590
|
+
result: Issue[]
|
|
1591
|
+
];
|
|
1592
|
+
"issues.get": [
|
|
1593
|
+
params: {
|
|
1594
|
+
issueId: string;
|
|
1595
|
+
companyId: string;
|
|
1596
|
+
},
|
|
1597
|
+
result: Issue | null
|
|
1598
|
+
];
|
|
1599
|
+
"issues.create": [
|
|
1600
|
+
params: {
|
|
1601
|
+
companyId: string;
|
|
1602
|
+
projectId?: string;
|
|
1603
|
+
goalId?: string;
|
|
1604
|
+
parentId?: string;
|
|
1605
|
+
inheritExecutionWorkspaceFromIssueId?: string;
|
|
1606
|
+
title: string;
|
|
1607
|
+
description?: string;
|
|
1608
|
+
status?: string;
|
|
1609
|
+
priority?: string;
|
|
1610
|
+
assigneeAgentId?: string;
|
|
1611
|
+
assigneeUserId?: string | null;
|
|
1612
|
+
requestDepth?: number;
|
|
1613
|
+
billingCode?: string | null;
|
|
1614
|
+
assigneeAdapterOverrides?: IssueAssigneeAdapterOverrides | null;
|
|
1615
|
+
surfaceVisibility?: string | null;
|
|
1616
|
+
originKind?: string | null;
|
|
1617
|
+
originId?: string | null;
|
|
1618
|
+
originRunId?: string | null;
|
|
1619
|
+
blockedByIssueIds?: string[];
|
|
1620
|
+
labelIds?: string[];
|
|
1621
|
+
executionWorkspaceId?: string | null;
|
|
1622
|
+
executionWorkspacePreference?: string | null;
|
|
1623
|
+
executionWorkspaceSettings?: Record<string, unknown> | null;
|
|
1624
|
+
actorAgentId?: string | null;
|
|
1625
|
+
actorUserId?: string | null;
|
|
1626
|
+
actorRunId?: string | null;
|
|
1627
|
+
},
|
|
1628
|
+
result: Issue
|
|
1629
|
+
];
|
|
1630
|
+
"issues.update": [
|
|
1631
|
+
params: {
|
|
1632
|
+
issueId: string;
|
|
1633
|
+
patch: Record<string, unknown>;
|
|
1634
|
+
companyId: string;
|
|
1635
|
+
},
|
|
1636
|
+
result: Issue
|
|
1637
|
+
];
|
|
1638
|
+
"issues.relations.get": [
|
|
1639
|
+
params: {
|
|
1640
|
+
issueId: string;
|
|
1641
|
+
companyId: string;
|
|
1642
|
+
},
|
|
1643
|
+
result: PluginIssueRelationSummary
|
|
1644
|
+
];
|
|
1645
|
+
"issues.relations.setBlockedBy": [
|
|
1646
|
+
params: {
|
|
1647
|
+
issueId: string;
|
|
1648
|
+
companyId: string;
|
|
1649
|
+
blockedByIssueIds: string[];
|
|
1650
|
+
actorAgentId?: string | null;
|
|
1651
|
+
actorUserId?: string | null;
|
|
1652
|
+
actorRunId?: string | null;
|
|
1653
|
+
},
|
|
1654
|
+
result: PluginIssueRelationSummary
|
|
1655
|
+
];
|
|
1656
|
+
"issues.relations.addBlockers": [
|
|
1657
|
+
params: {
|
|
1658
|
+
issueId: string;
|
|
1659
|
+
companyId: string;
|
|
1660
|
+
blockerIssueIds: string[];
|
|
1661
|
+
actorAgentId?: string | null;
|
|
1662
|
+
actorUserId?: string | null;
|
|
1663
|
+
actorRunId?: string | null;
|
|
1664
|
+
},
|
|
1665
|
+
result: PluginIssueRelationSummary
|
|
1666
|
+
];
|
|
1667
|
+
"issues.relations.removeBlockers": [
|
|
1668
|
+
params: {
|
|
1669
|
+
issueId: string;
|
|
1670
|
+
companyId: string;
|
|
1671
|
+
blockerIssueIds: string[];
|
|
1672
|
+
actorAgentId?: string | null;
|
|
1673
|
+
actorUserId?: string | null;
|
|
1674
|
+
actorRunId?: string | null;
|
|
1675
|
+
},
|
|
1676
|
+
result: PluginIssueRelationSummary
|
|
1677
|
+
];
|
|
1678
|
+
"issues.assertCheckoutOwner": [
|
|
1679
|
+
params: {
|
|
1680
|
+
issueId: string;
|
|
1681
|
+
companyId: string;
|
|
1682
|
+
actorAgentId: string;
|
|
1683
|
+
actorRunId: string;
|
|
1684
|
+
},
|
|
1685
|
+
result: PluginIssueCheckoutOwnership
|
|
1686
|
+
];
|
|
1687
|
+
"issues.getSubtree": [
|
|
1688
|
+
params: {
|
|
1689
|
+
issueId: string;
|
|
1690
|
+
companyId: string;
|
|
1691
|
+
includeRoot?: boolean;
|
|
1692
|
+
includeRelations?: boolean;
|
|
1693
|
+
includeDocuments?: boolean;
|
|
1694
|
+
includeActiveRuns?: boolean;
|
|
1695
|
+
includeAssignees?: boolean;
|
|
1696
|
+
},
|
|
1697
|
+
result: PluginIssueSubtree
|
|
1698
|
+
];
|
|
1699
|
+
"issues.requestWakeup": [
|
|
1700
|
+
params: {
|
|
1701
|
+
issueId: string;
|
|
1702
|
+
companyId: string;
|
|
1703
|
+
reason?: string;
|
|
1704
|
+
contextSource?: string;
|
|
1705
|
+
idempotencyKey?: string | null;
|
|
1706
|
+
actorAgentId?: string | null;
|
|
1707
|
+
actorUserId?: string | null;
|
|
1708
|
+
actorRunId?: string | null;
|
|
1709
|
+
},
|
|
1710
|
+
result: PluginIssueWakeupResult
|
|
1711
|
+
];
|
|
1712
|
+
"issues.requestWakeups": [
|
|
1713
|
+
params: {
|
|
1714
|
+
issueIds: string[];
|
|
1715
|
+
companyId: string;
|
|
1716
|
+
reason?: string;
|
|
1717
|
+
contextSource?: string;
|
|
1718
|
+
idempotencyKeyPrefix?: string | null;
|
|
1719
|
+
actorAgentId?: string | null;
|
|
1720
|
+
actorUserId?: string | null;
|
|
1721
|
+
actorRunId?: string | null;
|
|
1722
|
+
},
|
|
1723
|
+
result: PluginIssueWakeupBatchResult[]
|
|
1724
|
+
];
|
|
1725
|
+
"issues.summaries.getOrchestration": [
|
|
1726
|
+
params: {
|
|
1727
|
+
issueId: string;
|
|
1728
|
+
companyId: string;
|
|
1729
|
+
includeSubtree?: boolean;
|
|
1730
|
+
billingCode?: string | null;
|
|
1731
|
+
},
|
|
1732
|
+
result: PluginIssueOrchestrationSummary
|
|
1733
|
+
];
|
|
1734
|
+
"issues.listComments": [
|
|
1735
|
+
params: {
|
|
1736
|
+
issueId: string;
|
|
1737
|
+
companyId: string;
|
|
1738
|
+
},
|
|
1739
|
+
result: IssueComment[]
|
|
1740
|
+
];
|
|
1741
|
+
"issues.createComment": [
|
|
1742
|
+
params: {
|
|
1743
|
+
issueId: string;
|
|
1744
|
+
body: string;
|
|
1745
|
+
companyId: string;
|
|
1746
|
+
authorAgentId?: string;
|
|
1747
|
+
/** Active human company member the comment is attributed to. Requires `issue.comments.create_human_attributed`. */
|
|
1748
|
+
actorUserId?: string;
|
|
1749
|
+
},
|
|
1750
|
+
result: IssueComment
|
|
1751
|
+
];
|
|
1752
|
+
"issues.createInteraction": [
|
|
1753
|
+
params: {
|
|
1754
|
+
issueId: string;
|
|
1755
|
+
companyId: string;
|
|
1756
|
+
interaction: CreateIssueThreadInteraction;
|
|
1757
|
+
authorAgentId?: string | null;
|
|
1758
|
+
},
|
|
1759
|
+
result: IssueThreadInteraction
|
|
1760
|
+
];
|
|
1761
|
+
"issues.listInteractions": [
|
|
1762
|
+
params: {
|
|
1763
|
+
issueId: string;
|
|
1764
|
+
companyId: string;
|
|
1765
|
+
},
|
|
1766
|
+
result: IssueThreadInteraction[]
|
|
1767
|
+
];
|
|
1768
|
+
"issues.respondInteraction": [
|
|
1769
|
+
params: {
|
|
1770
|
+
issueId: string;
|
|
1771
|
+
interactionId: string;
|
|
1772
|
+
companyId: string;
|
|
1773
|
+
action: "accept" | "reject";
|
|
1774
|
+
/**
|
|
1775
|
+
* Active human company member the decision is attributed to. Required —
|
|
1776
|
+
* resolving an interaction is a board-user action; the host re-verifies
|
|
1777
|
+
* active membership at apply time and never trusts this value blindly.
|
|
1778
|
+
*/
|
|
1779
|
+
actorUserId?: string;
|
|
1780
|
+
reason?: string | null;
|
|
1781
|
+
},
|
|
1782
|
+
result: {
|
|
1783
|
+
interaction: IssueThreadInteraction;
|
|
1784
|
+
applied: boolean;
|
|
1785
|
+
}
|
|
1786
|
+
];
|
|
1787
|
+
"issues.listAttachments": [
|
|
1788
|
+
params: {
|
|
1789
|
+
issueId: string;
|
|
1790
|
+
companyId: string;
|
|
1791
|
+
},
|
|
1792
|
+
result: IssueAttachment[]
|
|
1793
|
+
];
|
|
1794
|
+
"issues.getAttachmentContent": [
|
|
1795
|
+
params: {
|
|
1796
|
+
attachmentId: string;
|
|
1797
|
+
companyId: string;
|
|
1798
|
+
maxBytes?: number | null;
|
|
1799
|
+
},
|
|
1800
|
+
result: PluginIssueAttachmentContent | null
|
|
1801
|
+
];
|
|
1802
|
+
"issues.documents.list": [
|
|
1803
|
+
params: {
|
|
1804
|
+
issueId: string;
|
|
1805
|
+
companyId: string;
|
|
1806
|
+
},
|
|
1807
|
+
result: IssueDocumentSummary[]
|
|
1808
|
+
];
|
|
1809
|
+
"issues.documents.get": [
|
|
1810
|
+
params: {
|
|
1811
|
+
issueId: string;
|
|
1812
|
+
key: string;
|
|
1813
|
+
companyId: string;
|
|
1814
|
+
},
|
|
1815
|
+
result: IssueDocument | null
|
|
1816
|
+
];
|
|
1817
|
+
"issues.documents.upsert": [
|
|
1818
|
+
params: {
|
|
1819
|
+
issueId: string;
|
|
1820
|
+
key: string;
|
|
1821
|
+
body: string;
|
|
1822
|
+
companyId: string;
|
|
1823
|
+
title?: string;
|
|
1824
|
+
format?: string;
|
|
1825
|
+
changeSummary?: string;
|
|
1826
|
+
},
|
|
1827
|
+
result: IssueDocument
|
|
1828
|
+
];
|
|
1829
|
+
"issues.documents.delete": [
|
|
1830
|
+
params: {
|
|
1831
|
+
issueId: string;
|
|
1832
|
+
key: string;
|
|
1833
|
+
companyId: string;
|
|
1834
|
+
},
|
|
1835
|
+
result: void
|
|
1836
|
+
];
|
|
1837
|
+
"approvals.list": [
|
|
1838
|
+
params: {
|
|
1839
|
+
companyId: string;
|
|
1840
|
+
status?: string | null;
|
|
1841
|
+
},
|
|
1842
|
+
result: Approval[]
|
|
1843
|
+
];
|
|
1844
|
+
"approvals.get": [
|
|
1845
|
+
params: {
|
|
1846
|
+
approvalId: string;
|
|
1847
|
+
companyId: string;
|
|
1848
|
+
},
|
|
1849
|
+
result: Approval | null
|
|
1850
|
+
];
|
|
1851
|
+
"approvals.decide": [
|
|
1852
|
+
params: {
|
|
1853
|
+
approvalId: string;
|
|
1854
|
+
companyId: string;
|
|
1855
|
+
action: "approve" | "reject";
|
|
1856
|
+
/**
|
|
1857
|
+
* Active human company member the decision is attributed to. Required —
|
|
1858
|
+
* deciding an approval is a board-user action; the host re-verifies
|
|
1859
|
+
* active membership at apply time and never trusts this value blindly.
|
|
1860
|
+
*/
|
|
1861
|
+
actorUserId?: string;
|
|
1862
|
+
decisionNote?: string | null;
|
|
1863
|
+
},
|
|
1864
|
+
result: {
|
|
1865
|
+
approval: Approval;
|
|
1866
|
+
applied: boolean;
|
|
1867
|
+
}
|
|
1868
|
+
];
|
|
1869
|
+
"agents.list": [
|
|
1870
|
+
params: {
|
|
1871
|
+
companyId: string;
|
|
1872
|
+
status?: string;
|
|
1873
|
+
limit?: number;
|
|
1874
|
+
offset?: number;
|
|
1875
|
+
},
|
|
1876
|
+
result: Agent[]
|
|
1877
|
+
];
|
|
1878
|
+
"agents.get": [
|
|
1879
|
+
params: {
|
|
1880
|
+
agentId: string;
|
|
1881
|
+
companyId: string;
|
|
1882
|
+
},
|
|
1883
|
+
result: Agent | null
|
|
1884
|
+
];
|
|
1885
|
+
"agents.pause": [
|
|
1886
|
+
params: {
|
|
1887
|
+
agentId: string;
|
|
1888
|
+
companyId: string;
|
|
1889
|
+
},
|
|
1890
|
+
result: Agent
|
|
1891
|
+
];
|
|
1892
|
+
"agents.resume": [
|
|
1893
|
+
params: {
|
|
1894
|
+
agentId: string;
|
|
1895
|
+
companyId: string;
|
|
1896
|
+
},
|
|
1897
|
+
result: Agent
|
|
1898
|
+
];
|
|
1899
|
+
"agents.invoke": [
|
|
1900
|
+
params: {
|
|
1901
|
+
agentId: string;
|
|
1902
|
+
companyId: string;
|
|
1903
|
+
prompt: string;
|
|
1904
|
+
reason?: string;
|
|
1905
|
+
},
|
|
1906
|
+
result: {
|
|
1907
|
+
runId: string;
|
|
1908
|
+
}
|
|
1909
|
+
];
|
|
1910
|
+
"agents.managed.get": [
|
|
1911
|
+
params: {
|
|
1912
|
+
agentKey: string;
|
|
1913
|
+
companyId: string;
|
|
1914
|
+
},
|
|
1915
|
+
result: PluginManagedAgentResolution
|
|
1916
|
+
];
|
|
1917
|
+
"agents.managed.reconcile": [
|
|
1918
|
+
params: {
|
|
1919
|
+
agentKey: string;
|
|
1920
|
+
companyId: string;
|
|
1921
|
+
},
|
|
1922
|
+
result: PluginManagedAgentResolution
|
|
1923
|
+
];
|
|
1924
|
+
"agents.managed.reset": [
|
|
1925
|
+
params: {
|
|
1926
|
+
agentKey: string;
|
|
1927
|
+
companyId: string;
|
|
1928
|
+
},
|
|
1929
|
+
result: PluginManagedAgentResolution
|
|
1930
|
+
];
|
|
1931
|
+
"agents.sessions.create": [
|
|
1932
|
+
params: {
|
|
1933
|
+
agentId: string;
|
|
1934
|
+
companyId: string;
|
|
1935
|
+
taskKey?: string;
|
|
1936
|
+
reason?: string;
|
|
1937
|
+
},
|
|
1938
|
+
result: {
|
|
1939
|
+
sessionId: string;
|
|
1940
|
+
agentId: string;
|
|
1941
|
+
companyId: string;
|
|
1942
|
+
status: "active" | "closed";
|
|
1943
|
+
createdAt: string;
|
|
1944
|
+
}
|
|
1945
|
+
];
|
|
1946
|
+
"agents.sessions.list": [
|
|
1947
|
+
params: {
|
|
1948
|
+
agentId: string;
|
|
1949
|
+
companyId: string;
|
|
1950
|
+
},
|
|
1951
|
+
result: Array<{
|
|
1952
|
+
sessionId: string;
|
|
1953
|
+
agentId: string;
|
|
1954
|
+
companyId: string;
|
|
1955
|
+
status: "active" | "closed";
|
|
1956
|
+
createdAt: string;
|
|
1957
|
+
}>
|
|
1958
|
+
];
|
|
1959
|
+
"agents.sessions.sendMessage": [
|
|
1960
|
+
params: {
|
|
1961
|
+
sessionId: string;
|
|
1962
|
+
companyId: string;
|
|
1963
|
+
prompt: string;
|
|
1964
|
+
reason?: string;
|
|
1965
|
+
},
|
|
1966
|
+
result: {
|
|
1967
|
+
runId: string;
|
|
1968
|
+
}
|
|
1969
|
+
];
|
|
1970
|
+
"agents.sessions.close": [
|
|
1971
|
+
params: {
|
|
1972
|
+
sessionId: string;
|
|
1973
|
+
companyId: string;
|
|
1974
|
+
},
|
|
1975
|
+
result: void
|
|
1976
|
+
];
|
|
1977
|
+
"goals.list": [
|
|
1978
|
+
params: {
|
|
1979
|
+
companyId: string;
|
|
1980
|
+
level?: string;
|
|
1981
|
+
status?: string;
|
|
1982
|
+
limit?: number;
|
|
1983
|
+
offset?: number;
|
|
1984
|
+
},
|
|
1985
|
+
result: Goal[]
|
|
1986
|
+
];
|
|
1987
|
+
"goals.get": [
|
|
1988
|
+
params: {
|
|
1989
|
+
goalId: string;
|
|
1990
|
+
companyId: string;
|
|
1991
|
+
},
|
|
1992
|
+
result: Goal | null
|
|
1993
|
+
];
|
|
1994
|
+
"goals.create": [
|
|
1995
|
+
params: {
|
|
1996
|
+
companyId: string;
|
|
1997
|
+
title: string;
|
|
1998
|
+
description?: string;
|
|
1999
|
+
level?: string;
|
|
2000
|
+
status?: string;
|
|
2001
|
+
parentId?: string;
|
|
2002
|
+
ownerAgentId?: string;
|
|
2003
|
+
},
|
|
2004
|
+
result: Goal
|
|
2005
|
+
];
|
|
2006
|
+
"goals.update": [
|
|
2007
|
+
params: {
|
|
2008
|
+
goalId: string;
|
|
2009
|
+
patch: Record<string, unknown>;
|
|
2010
|
+
companyId: string;
|
|
2011
|
+
},
|
|
2012
|
+
result: Goal
|
|
2013
|
+
];
|
|
2014
|
+
"access.members.list": [
|
|
2015
|
+
params: {
|
|
2016
|
+
companyId: string;
|
|
2017
|
+
includeArchived?: boolean;
|
|
2018
|
+
},
|
|
2019
|
+
result: PluginAccessMember[]
|
|
2020
|
+
];
|
|
2021
|
+
"access.members.get": [
|
|
2022
|
+
params: {
|
|
2023
|
+
memberId: string;
|
|
2024
|
+
companyId: string;
|
|
2025
|
+
},
|
|
2026
|
+
result: PluginAccessMember | null
|
|
2027
|
+
];
|
|
2028
|
+
"access.members.update": [
|
|
2029
|
+
params: {
|
|
2030
|
+
memberId: string;
|
|
2031
|
+
companyId: string;
|
|
2032
|
+
patch: {
|
|
2033
|
+
membershipRole?: string | null;
|
|
2034
|
+
status?: "pending" | "active" | "suspended";
|
|
2035
|
+
};
|
|
2036
|
+
},
|
|
2037
|
+
result: PluginAccessMember
|
|
2038
|
+
];
|
|
2039
|
+
"access.invites.list": [
|
|
2040
|
+
params: {
|
|
2041
|
+
companyId: string;
|
|
2042
|
+
state?: "active" | "revoked" | "accepted" | "expired";
|
|
2043
|
+
limit?: number;
|
|
2044
|
+
offset?: number;
|
|
2045
|
+
},
|
|
2046
|
+
result: {
|
|
2047
|
+
invites: PluginAccessInvite[];
|
|
2048
|
+
nextOffset: number | null;
|
|
2049
|
+
}
|
|
2050
|
+
];
|
|
2051
|
+
"access.invites.create": [
|
|
2052
|
+
params: {
|
|
2053
|
+
companyId: string;
|
|
2054
|
+
allowedJoinTypes?: "human" | "agent" | "both";
|
|
2055
|
+
humanRole?: string | null;
|
|
2056
|
+
defaultsPayload?: Record<string, unknown> | null;
|
|
2057
|
+
agentMessage?: string | null;
|
|
2058
|
+
},
|
|
2059
|
+
result: PluginAccessInvite & {
|
|
2060
|
+
token: string;
|
|
2061
|
+
}
|
|
2062
|
+
];
|
|
2063
|
+
"access.invites.revoke": [
|
|
2064
|
+
params: {
|
|
2065
|
+
inviteId: string;
|
|
2066
|
+
companyId: string;
|
|
2067
|
+
},
|
|
2068
|
+
result: PluginAccessInvite
|
|
2069
|
+
];
|
|
2070
|
+
"authorization.grants.list": [
|
|
2071
|
+
params: {
|
|
2072
|
+
companyId: string;
|
|
2073
|
+
principalType?: string;
|
|
2074
|
+
principalId?: string;
|
|
2075
|
+
},
|
|
2076
|
+
result: PrincipalPermissionGrant[]
|
|
2077
|
+
];
|
|
2078
|
+
"authorization.grants.set": [
|
|
2079
|
+
params: {
|
|
2080
|
+
companyId: string;
|
|
2081
|
+
principalType: string;
|
|
2082
|
+
principalId: string;
|
|
2083
|
+
grants: Array<{
|
|
2084
|
+
permissionKey: string;
|
|
2085
|
+
scope?: Record<string, unknown> | null;
|
|
2086
|
+
}>;
|
|
2087
|
+
grantedByUserId?: string | null;
|
|
2088
|
+
},
|
|
2089
|
+
result: PrincipalPermissionGrant[]
|
|
2090
|
+
];
|
|
2091
|
+
"authorization.policies.summary": [
|
|
2092
|
+
params: {
|
|
2093
|
+
companyId: string;
|
|
2094
|
+
},
|
|
2095
|
+
result: PluginAuthorizationPolicySummary
|
|
2096
|
+
];
|
|
2097
|
+
"authorization.policies.get": [
|
|
2098
|
+
params: {
|
|
2099
|
+
companyId: string;
|
|
2100
|
+
resourceType: "company" | "agent" | "project" | "issue";
|
|
2101
|
+
resourceId: string;
|
|
2102
|
+
},
|
|
2103
|
+
result: PluginAuthorizationPolicyRecord | null
|
|
2104
|
+
];
|
|
2105
|
+
"authorization.policies.update": [
|
|
2106
|
+
params: {
|
|
2107
|
+
companyId: string;
|
|
2108
|
+
resourceType: "company" | "agent" | "project" | "issue";
|
|
2109
|
+
resourceId: string;
|
|
2110
|
+
policy: Record<string, unknown> | null;
|
|
2111
|
+
},
|
|
2112
|
+
result: PluginAuthorizationPolicyRecord
|
|
2113
|
+
];
|
|
2114
|
+
"authorization.policies.previewAssignment": [
|
|
2115
|
+
params: PluginAssignmentPreviewInput,
|
|
2116
|
+
result: PluginAuthorizationDecisionResult
|
|
2117
|
+
];
|
|
2118
|
+
"authorization.policies.explainAssignment": [
|
|
2119
|
+
params: PluginAssignmentPreviewInput,
|
|
2120
|
+
result: PluginAuthorizationDecisionResult
|
|
2121
|
+
];
|
|
2122
|
+
"authorization.audit.search": [
|
|
2123
|
+
params: {
|
|
2124
|
+
companyId: string;
|
|
2125
|
+
action?: string;
|
|
2126
|
+
actorType?: string;
|
|
2127
|
+
actorId?: string;
|
|
2128
|
+
entityType?: string;
|
|
2129
|
+
entityId?: string;
|
|
2130
|
+
decision?: string;
|
|
2131
|
+
limit?: number;
|
|
2132
|
+
offset?: number;
|
|
2133
|
+
},
|
|
2134
|
+
result: PluginAuthorizationAuditEntry[]
|
|
2135
|
+
];
|
|
2136
|
+
}
|
|
2137
|
+
/** Union of all worker→host method names. */
|
|
2138
|
+
export type WorkerToHostMethodName = keyof WorkerToHostMethods;
|
|
2139
|
+
/**
|
|
2140
|
+
* Typed parameter shapes for worker→host JSON-RPC notifications.
|
|
2141
|
+
*
|
|
2142
|
+
* Notifications are fire-and-forget — the worker does not wait for a response.
|
|
2143
|
+
* These are used for streaming events and logging, not for request-response RPCs.
|
|
2144
|
+
*/
|
|
2145
|
+
export interface WorkerToHostNotifications {
|
|
2146
|
+
/**
|
|
2147
|
+
* Forward a stream event to connected SSE clients.
|
|
2148
|
+
*
|
|
2149
|
+
* Emitted by the worker for each event on a stream channel. The host
|
|
2150
|
+
* publishes to the PluginStreamBus, which fans out to all SSE clients
|
|
2151
|
+
* subscribed to the (pluginId, channel, companyId) tuple.
|
|
2152
|
+
*
|
|
2153
|
+
* The `event` payload is JSON-serializable and sent as SSE `data:`.
|
|
2154
|
+
* The default SSE event type is `"message"`.
|
|
2155
|
+
*/
|
|
2156
|
+
"streams.emit": {
|
|
2157
|
+
channel: string;
|
|
2158
|
+
companyId: string;
|
|
2159
|
+
event: unknown;
|
|
2160
|
+
};
|
|
2161
|
+
/**
|
|
2162
|
+
* Signal that a stream channel has been opened.
|
|
2163
|
+
*
|
|
2164
|
+
* Emitted when the worker calls `ctx.streams.open(channel, companyId)`.
|
|
2165
|
+
* UI clients may use this to display a "connected" indicator or begin
|
|
2166
|
+
* buffering input. The host tracks open channels so it can emit synthetic
|
|
2167
|
+
* close events if the worker crashes.
|
|
2168
|
+
*/
|
|
2169
|
+
"streams.open": {
|
|
2170
|
+
channel: string;
|
|
2171
|
+
companyId: string;
|
|
2172
|
+
};
|
|
2173
|
+
/**
|
|
2174
|
+
* Signal that a stream channel has been closed.
|
|
2175
|
+
*
|
|
2176
|
+
* Emitted when the worker calls `ctx.streams.close(channel)`, or
|
|
2177
|
+
* synthetically by the host when a worker process exits with channels
|
|
2178
|
+
* still open. UI clients should treat this as terminal and disconnect
|
|
2179
|
+
* the SSE connection.
|
|
2180
|
+
*/
|
|
2181
|
+
"streams.close": {
|
|
2182
|
+
channel: string;
|
|
2183
|
+
companyId: string;
|
|
2184
|
+
};
|
|
2185
|
+
/**
|
|
2186
|
+
* Deliver one incremental output chunk of the active `environmentExecute`
|
|
2187
|
+
* call to the host runner log sink.
|
|
2188
|
+
*
|
|
2189
|
+
* The worker emits this notification for each new `stdout` or `stderr` chunk
|
|
2190
|
+
* while one execute call runs. The host reads the active invocation id from
|
|
2191
|
+
* the envelope field `paperclipInvocationId`, which the worker RPC host stamps
|
|
2192
|
+
* from the active invocation context. The host correlates the chunk to the
|
|
2193
|
+
* host-owned execute route for that id and delivers it to that route's
|
|
2194
|
+
* `onLog` callback.
|
|
2195
|
+
*
|
|
2196
|
+
* Security: the notification carries no company id on purpose. The
|
|
2197
|
+
* invocation-to-company binding on the host execute route is authoritative.
|
|
2198
|
+
* The host never reads a company id from this payload to select the route or
|
|
2199
|
+
* to grant access. The `chunk` is a text string, because JSON-RPC cannot
|
|
2200
|
+
* carry raw bytes; the host drops a chunk that is not a bounded non-empty
|
|
2201
|
+
* string or whose stream name is not exactly `stdout` or `stderr`.
|
|
2202
|
+
*/
|
|
2203
|
+
"execute.log": {
|
|
2204
|
+
stream: "stdout" | "stderr";
|
|
2205
|
+
chunk: string;
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
/** Union of all worker→host notification method names. */
|
|
2209
|
+
export type WorkerToHostNotificationName = keyof WorkerToHostNotifications;
|
|
2210
|
+
/**
|
|
2211
|
+
* A typed JSON-RPC request for a specific host→worker method.
|
|
2212
|
+
*/
|
|
2213
|
+
export type HostToWorkerRequest<M extends HostToWorkerMethodName> = JsonRpcRequest<M, HostToWorkerMethods[M][0]>;
|
|
2214
|
+
/**
|
|
2215
|
+
* A typed JSON-RPC success response for a specific host→worker method.
|
|
2216
|
+
*/
|
|
2217
|
+
export type HostToWorkerResponse<M extends HostToWorkerMethodName> = JsonRpcSuccessResponse<HostToWorkerMethods[M][1]>;
|
|
2218
|
+
/**
|
|
2219
|
+
* A typed JSON-RPC request for a specific worker→host method.
|
|
2220
|
+
*/
|
|
2221
|
+
export type WorkerToHostRequest<M extends WorkerToHostMethodName> = JsonRpcRequest<M, WorkerToHostMethods[M][0]>;
|
|
2222
|
+
/**
|
|
2223
|
+
* A typed JSON-RPC success response for a specific worker→host method.
|
|
2224
|
+
*/
|
|
2225
|
+
export type WorkerToHostResponse<M extends WorkerToHostMethodName> = JsonRpcSuccessResponse<WorkerToHostMethods[M][1]>;
|
|
2226
|
+
/**
|
|
2227
|
+
* Create a JSON-RPC 2.0 request message.
|
|
2228
|
+
*
|
|
2229
|
+
* @param method - The RPC method name
|
|
2230
|
+
* @param params - Structured parameters
|
|
2231
|
+
* @param id - Optional explicit request ID (auto-generated if omitted)
|
|
2232
|
+
*/
|
|
2233
|
+
export declare function createRequest<TMethod extends string>(method: TMethod, params: unknown, id?: JsonRpcId): JsonRpcRequest<TMethod>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Create a JSON-RPC 2.0 success response.
|
|
2236
|
+
*
|
|
2237
|
+
* @param id - The request ID being responded to
|
|
2238
|
+
* @param result - The result value
|
|
2239
|
+
*/
|
|
2240
|
+
export declare function createSuccessResponse<TResult>(id: JsonRpcId, result: TResult): JsonRpcSuccessResponse<TResult>;
|
|
2241
|
+
/**
|
|
2242
|
+
* Create a JSON-RPC 2.0 error response.
|
|
2243
|
+
*
|
|
2244
|
+
* @param id - The request ID being responded to (null if the request ID could not be determined)
|
|
2245
|
+
* @param code - Machine-readable error code
|
|
2246
|
+
* @param message - Human-readable error message
|
|
2247
|
+
* @param data - Optional structured error data
|
|
2248
|
+
*/
|
|
2249
|
+
export declare function createErrorResponse<TData = unknown>(id: JsonRpcId | null, code: number, message: string, data?: TData): JsonRpcErrorResponse<TData>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Create a JSON-RPC 2.0 notification (fire-and-forget, no response expected).
|
|
2252
|
+
*
|
|
2253
|
+
* @param method - The notification method name
|
|
2254
|
+
* @param params - Structured parameters
|
|
2255
|
+
*/
|
|
2256
|
+
export declare function createNotification<TMethod extends string>(method: TMethod, params: unknown): JsonRpcNotification<TMethod>;
|
|
2257
|
+
/**
|
|
2258
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 request.
|
|
2259
|
+
*
|
|
2260
|
+
* A request has `jsonrpc: "2.0"`, a string `method`, and an `id`.
|
|
2261
|
+
*/
|
|
2262
|
+
export declare function isJsonRpcRequest(value: unknown): value is JsonRpcRequest;
|
|
2263
|
+
/**
|
|
2264
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 notification.
|
|
2265
|
+
*
|
|
2266
|
+
* A notification has `jsonrpc: "2.0"`, a string `method`, but no `id`.
|
|
2267
|
+
*/
|
|
2268
|
+
export declare function isJsonRpcNotification(value: unknown): value is JsonRpcNotification;
|
|
2269
|
+
/**
|
|
2270
|
+
* Check whether a value is a well-formed JSON-RPC 2.0 response (success or error).
|
|
2271
|
+
*/
|
|
2272
|
+
export declare function isJsonRpcResponse(value: unknown): value is JsonRpcResponse;
|
|
2273
|
+
/**
|
|
2274
|
+
* Check whether a JSON-RPC response is a success response.
|
|
2275
|
+
*/
|
|
2276
|
+
export declare function isJsonRpcSuccessResponse(response: JsonRpcResponse): response is JsonRpcSuccessResponse;
|
|
2277
|
+
/**
|
|
2278
|
+
* Check whether a JSON-RPC response is an error response.
|
|
2279
|
+
*/
|
|
2280
|
+
export declare function isJsonRpcErrorResponse(response: JsonRpcResponse): response is JsonRpcErrorResponse;
|
|
2281
|
+
/**
|
|
2282
|
+
* Line delimiter for JSON-RPC messages over stdio.
|
|
2283
|
+
*
|
|
2284
|
+
* Each message is a single line of JSON terminated by a newline character.
|
|
2285
|
+
* This follows the newline-delimited JSON (NDJSON) convention.
|
|
2286
|
+
*/
|
|
2287
|
+
export declare const MESSAGE_DELIMITER: "\n";
|
|
2288
|
+
/**
|
|
2289
|
+
* Serialize a JSON-RPC message to a newline-delimited string for transmission
|
|
2290
|
+
* over stdio.
|
|
2291
|
+
*
|
|
2292
|
+
* @param message - Any JSON-RPC message (request, response, or notification)
|
|
2293
|
+
* @returns The JSON string terminated with a newline
|
|
2294
|
+
*/
|
|
2295
|
+
export declare function serializeMessage(message: JsonRpcMessage): string;
|
|
2296
|
+
/**
|
|
2297
|
+
* Parse a JSON string into a JSON-RPC message.
|
|
2298
|
+
*
|
|
2299
|
+
* Returns the parsed message or throws a `JsonRpcParseError` if the input
|
|
2300
|
+
* is not valid JSON or does not conform to the JSON-RPC 2.0 structure.
|
|
2301
|
+
*
|
|
2302
|
+
* @param line - A single line of JSON text (with or without trailing newline)
|
|
2303
|
+
* @returns The parsed JSON-RPC message
|
|
2304
|
+
* @throws {JsonRpcParseError} If parsing fails
|
|
2305
|
+
*/
|
|
2306
|
+
export declare function parseMessage(line: string): JsonRpcMessage;
|
|
2307
|
+
/**
|
|
2308
|
+
* Error thrown when a JSON-RPC message cannot be parsed.
|
|
2309
|
+
*/
|
|
2310
|
+
export declare class JsonRpcParseError extends Error {
|
|
2311
|
+
readonly name = "JsonRpcParseError";
|
|
2312
|
+
constructor(message: string);
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* Error thrown when a JSON-RPC call fails with a structured error response.
|
|
2316
|
+
*
|
|
2317
|
+
* Captures the full `JsonRpcError` so callers can inspect the code and data.
|
|
2318
|
+
*/
|
|
2319
|
+
export declare class JsonRpcCallError extends Error {
|
|
2320
|
+
readonly name = "JsonRpcCallError";
|
|
2321
|
+
/** The JSON-RPC error code. */
|
|
2322
|
+
readonly code: number;
|
|
2323
|
+
/** Optional structured error data from the response. */
|
|
2324
|
+
readonly data: unknown;
|
|
2325
|
+
constructor(error: JsonRpcError);
|
|
2326
|
+
}
|
|
2327
|
+
/**
|
|
2328
|
+
* Reset the internal request ID counter. **For testing only.**
|
|
2329
|
+
*
|
|
2330
|
+
* @internal
|
|
2331
|
+
*/
|
|
2332
|
+
export declare function _resetIdCounter(): void;
|
|
2333
|
+
//# sourceMappingURL=protocol.d.ts.map
|