@microvac/plugin-sdk 0.0.0-stage → 0.1.0-rc.15

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