@paperclipai/plugin-sdk 2026.3.17-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/bundlers.d.ts +57 -0
- package/dist/bundlers.d.ts.map +1 -0
- package/dist/bundlers.js +105 -0
- package/dist/bundlers.js.map +1 -0
- package/dist/define-plugin.d.ts +218 -0
- package/dist/define-plugin.d.ts.map +1 -0
- package/dist/define-plugin.js +85 -0
- package/dist/define-plugin.js.map +1 -0
- package/dist/dev-cli.d.ts +3 -0
- package/dist/dev-cli.d.ts.map +1 -0
- package/dist/dev-cli.js +49 -0
- package/dist/dev-cli.js.map +1 -0
- package/dist/dev-server.d.ts +34 -0
- package/dist/dev-server.d.ts.map +1 -0
- package/dist/dev-server.js +194 -0
- package/dist/dev-server.js.map +1 -0
- package/dist/host-client-factory.d.ts +229 -0
- package/dist/host-client-factory.d.ts.map +1 -0
- package/dist/host-client-factory.js +353 -0
- package/dist/host-client-factory.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +881 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +297 -0
- package/dist/protocol.js.map +1 -0
- package/dist/testing.d.ts +63 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +700 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +982 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/components.d.ts +257 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +97 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/hooks.d.ts +120 -0
- package/dist/ui/hooks.d.ts.map +1 -0
- package/dist/ui/hooks.js +148 -0
- package/dist/ui/hooks.js.map +1 -0
- package/dist/ui/index.d.ts +50 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +48 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/runtime.d.ts +3 -0
- package/dist/ui/runtime.d.ts.map +1 -0
- package/dist/ui/runtime.js +30 -0
- package/dist/ui/runtime.js.map +1 -0
- package/dist/ui/types.d.ts +308 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +17 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/worker-rpc-host.d.ts +127 -0
- package/dist/worker-rpc-host.d.ts.map +1 -0
- package/dist/worker-rpc-host.js +941 -0
- package/dist/worker-rpc-host.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side client factory — creates capability-gated handler maps for
|
|
3
|
+
* servicing worker→host JSON-RPC calls.
|
|
4
|
+
*
|
|
5
|
+
* When a plugin worker calls `ctx.state.get(...)` inside its process, the
|
|
6
|
+
* SDK serializes the call as a JSON-RPC request over stdio. On the host side,
|
|
7
|
+
* the `PluginWorkerManager` receives the request and dispatches it to the
|
|
8
|
+
* handler registered for that method. This module provides a factory that
|
|
9
|
+
* creates those handlers for all `WorkerToHostMethods`, with automatic
|
|
10
|
+
* capability enforcement.
|
|
11
|
+
*
|
|
12
|
+
* ## Design
|
|
13
|
+
*
|
|
14
|
+
* 1. **Capability gating**: Each handler checks the plugin's declared
|
|
15
|
+
* capabilities before executing. If the plugin lacks a required capability,
|
|
16
|
+
* the handler throws a `CapabilityDeniedError` (which the worker manager
|
|
17
|
+
* translates into a JSON-RPC error response with code
|
|
18
|
+
* `CAPABILITY_DENIED`).
|
|
19
|
+
*
|
|
20
|
+
* 2. **Service adapters**: The caller provides a `HostServices` object with
|
|
21
|
+
* concrete implementations of each platform service. The factory wires
|
|
22
|
+
* each handler to the appropriate service method.
|
|
23
|
+
*
|
|
24
|
+
* 3. **Type safety**: The returned handler map is typed as
|
|
25
|
+
* `WorkerToHostHandlers` (from `plugin-worker-manager.ts`) so it plugs
|
|
26
|
+
* directly into `WorkerStartOptions.hostHandlers`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const handlers = createHostClientHandlers({
|
|
31
|
+
* pluginId: "acme.linear",
|
|
32
|
+
* capabilities: manifest.capabilities,
|
|
33
|
+
* services: {
|
|
34
|
+
* config: { get: () => registry.getConfig(pluginId) },
|
|
35
|
+
* state: { get: ..., set: ..., delete: ... },
|
|
36
|
+
* entities: { upsert: ..., list: ... },
|
|
37
|
+
* // ... all services
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* await workerManager.startWorker("acme.linear", {
|
|
42
|
+
* // ...
|
|
43
|
+
* hostHandlers: handlers,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @see PLUGIN_SPEC.md §13 — Host-Worker Protocol
|
|
48
|
+
* @see PLUGIN_SPEC.md §15 — Capability Model
|
|
49
|
+
*/
|
|
50
|
+
import { PLUGIN_RPC_ERROR_CODES } from "./protocol.js";
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Error types
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Thrown when a plugin calls a host method it does not have the capability for.
|
|
56
|
+
*
|
|
57
|
+
* The `code` field is set to `PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED` so
|
|
58
|
+
* the worker manager can propagate it as the correct JSON-RPC error code.
|
|
59
|
+
*/
|
|
60
|
+
export class CapabilityDeniedError extends Error {
|
|
61
|
+
name = "CapabilityDeniedError";
|
|
62
|
+
code = PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED;
|
|
63
|
+
constructor(pluginId, method, capability) {
|
|
64
|
+
super(`Plugin "${pluginId}" is missing required capability "${capability}" for method "${method}"`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Capability → method mapping
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Maps each worker→host RPC method to the capability required to invoke it.
|
|
72
|
+
* Methods without a capability requirement (e.g. `config.get`, `log`) are
|
|
73
|
+
* mapped to `null`.
|
|
74
|
+
*
|
|
75
|
+
* @see PLUGIN_SPEC.md §15 — Capability Model
|
|
76
|
+
*/
|
|
77
|
+
const METHOD_CAPABILITY_MAP = {
|
|
78
|
+
// Config — always allowed
|
|
79
|
+
"config.get": null,
|
|
80
|
+
// State
|
|
81
|
+
"state.get": "plugin.state.read",
|
|
82
|
+
"state.set": "plugin.state.write",
|
|
83
|
+
"state.delete": "plugin.state.write",
|
|
84
|
+
// Entities — no specific capability required (plugin-scoped by design)
|
|
85
|
+
"entities.upsert": null,
|
|
86
|
+
"entities.list": null,
|
|
87
|
+
// Events
|
|
88
|
+
"events.emit": "events.emit",
|
|
89
|
+
"events.subscribe": "events.subscribe",
|
|
90
|
+
// HTTP
|
|
91
|
+
"http.fetch": "http.outbound",
|
|
92
|
+
// Secrets
|
|
93
|
+
"secrets.resolve": "secrets.read-ref",
|
|
94
|
+
// Activity
|
|
95
|
+
"activity.log": "activity.log.write",
|
|
96
|
+
// Metrics
|
|
97
|
+
"metrics.write": "metrics.write",
|
|
98
|
+
// Logger — always allowed
|
|
99
|
+
"log": null,
|
|
100
|
+
// Companies
|
|
101
|
+
"companies.list": "companies.read",
|
|
102
|
+
"companies.get": "companies.read",
|
|
103
|
+
// Projects
|
|
104
|
+
"projects.list": "projects.read",
|
|
105
|
+
"projects.get": "projects.read",
|
|
106
|
+
"projects.listWorkspaces": "project.workspaces.read",
|
|
107
|
+
"projects.getPrimaryWorkspace": "project.workspaces.read",
|
|
108
|
+
"projects.getWorkspaceForIssue": "project.workspaces.read",
|
|
109
|
+
// Issues
|
|
110
|
+
"issues.list": "issues.read",
|
|
111
|
+
"issues.get": "issues.read",
|
|
112
|
+
"issues.create": "issues.create",
|
|
113
|
+
"issues.update": "issues.update",
|
|
114
|
+
"issues.listComments": "issue.comments.read",
|
|
115
|
+
"issues.createComment": "issue.comments.create",
|
|
116
|
+
// Issue Documents
|
|
117
|
+
"issues.documents.list": "issue.documents.read",
|
|
118
|
+
"issues.documents.get": "issue.documents.read",
|
|
119
|
+
"issues.documents.upsert": "issue.documents.write",
|
|
120
|
+
"issues.documents.delete": "issue.documents.write",
|
|
121
|
+
// Agents
|
|
122
|
+
"agents.list": "agents.read",
|
|
123
|
+
"agents.get": "agents.read",
|
|
124
|
+
"agents.pause": "agents.pause",
|
|
125
|
+
"agents.resume": "agents.resume",
|
|
126
|
+
"agents.invoke": "agents.invoke",
|
|
127
|
+
// Agent Sessions
|
|
128
|
+
"agents.sessions.create": "agent.sessions.create",
|
|
129
|
+
"agents.sessions.list": "agent.sessions.list",
|
|
130
|
+
"agents.sessions.sendMessage": "agent.sessions.send",
|
|
131
|
+
"agents.sessions.close": "agent.sessions.close",
|
|
132
|
+
// Goals
|
|
133
|
+
"goals.list": "goals.read",
|
|
134
|
+
"goals.get": "goals.read",
|
|
135
|
+
"goals.create": "goals.create",
|
|
136
|
+
"goals.update": "goals.update",
|
|
137
|
+
};
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// Factory
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
/**
|
|
142
|
+
* Create a complete handler map for all worker→host JSON-RPC methods.
|
|
143
|
+
*
|
|
144
|
+
* Each handler:
|
|
145
|
+
* 1. Checks the plugin's declared capabilities against the required capability
|
|
146
|
+
* for the method (if any).
|
|
147
|
+
* 2. Delegates to the corresponding service adapter method.
|
|
148
|
+
* 3. Returns the service result, which is serialized as the JSON-RPC response
|
|
149
|
+
* by the worker manager.
|
|
150
|
+
*
|
|
151
|
+
* If a capability check fails, the handler throws a `CapabilityDeniedError`
|
|
152
|
+
* with code `CAPABILITY_DENIED`. The worker manager catches this and sends a
|
|
153
|
+
* JSON-RPC error response to the worker, which surfaces as a `JsonRpcCallError`
|
|
154
|
+
* in the plugin's SDK client.
|
|
155
|
+
*
|
|
156
|
+
* @param options - Plugin ID, capabilities, and service adapters
|
|
157
|
+
* @returns A handler map suitable for `WorkerStartOptions.hostHandlers`
|
|
158
|
+
*/
|
|
159
|
+
export function createHostClientHandlers(options) {
|
|
160
|
+
const { pluginId, services } = options;
|
|
161
|
+
const capabilitySet = new Set(options.capabilities);
|
|
162
|
+
/**
|
|
163
|
+
* Assert that the plugin has the required capability for a method.
|
|
164
|
+
* Throws `CapabilityDeniedError` if the capability is missing.
|
|
165
|
+
*/
|
|
166
|
+
function requireCapability(method) {
|
|
167
|
+
const required = METHOD_CAPABILITY_MAP[method];
|
|
168
|
+
if (required === null)
|
|
169
|
+
return; // No capability required
|
|
170
|
+
if (capabilitySet.has(required))
|
|
171
|
+
return;
|
|
172
|
+
throw new CapabilityDeniedError(pluginId, method, required);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Create a capability-gated proxy handler for a method.
|
|
176
|
+
*
|
|
177
|
+
* @param method - The RPC method name (used for capability lookup)
|
|
178
|
+
* @param handler - The actual handler implementation
|
|
179
|
+
* @returns A wrapper that checks capabilities before delegating
|
|
180
|
+
*/
|
|
181
|
+
function gated(method, handler) {
|
|
182
|
+
return async (params) => {
|
|
183
|
+
requireCapability(method);
|
|
184
|
+
return handler(params);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// -------------------------------------------------------------------------
|
|
188
|
+
// Build the complete handler map
|
|
189
|
+
// -------------------------------------------------------------------------
|
|
190
|
+
return {
|
|
191
|
+
// Config
|
|
192
|
+
"config.get": gated("config.get", async () => {
|
|
193
|
+
return services.config.get();
|
|
194
|
+
}),
|
|
195
|
+
// State
|
|
196
|
+
"state.get": gated("state.get", async (params) => {
|
|
197
|
+
return services.state.get(params);
|
|
198
|
+
}),
|
|
199
|
+
"state.set": gated("state.set", async (params) => {
|
|
200
|
+
return services.state.set(params);
|
|
201
|
+
}),
|
|
202
|
+
"state.delete": gated("state.delete", async (params) => {
|
|
203
|
+
return services.state.delete(params);
|
|
204
|
+
}),
|
|
205
|
+
// Entities
|
|
206
|
+
"entities.upsert": gated("entities.upsert", async (params) => {
|
|
207
|
+
return services.entities.upsert(params);
|
|
208
|
+
}),
|
|
209
|
+
"entities.list": gated("entities.list", async (params) => {
|
|
210
|
+
return services.entities.list(params);
|
|
211
|
+
}),
|
|
212
|
+
// Events
|
|
213
|
+
"events.emit": gated("events.emit", async (params) => {
|
|
214
|
+
return services.events.emit(params);
|
|
215
|
+
}),
|
|
216
|
+
"events.subscribe": gated("events.subscribe", async (params) => {
|
|
217
|
+
return services.events.subscribe(params);
|
|
218
|
+
}),
|
|
219
|
+
// HTTP
|
|
220
|
+
"http.fetch": gated("http.fetch", async (params) => {
|
|
221
|
+
return services.http.fetch(params);
|
|
222
|
+
}),
|
|
223
|
+
// Secrets
|
|
224
|
+
"secrets.resolve": gated("secrets.resolve", async (params) => {
|
|
225
|
+
return services.secrets.resolve(params);
|
|
226
|
+
}),
|
|
227
|
+
// Activity
|
|
228
|
+
"activity.log": gated("activity.log", async (params) => {
|
|
229
|
+
return services.activity.log(params);
|
|
230
|
+
}),
|
|
231
|
+
// Metrics
|
|
232
|
+
"metrics.write": gated("metrics.write", async (params) => {
|
|
233
|
+
return services.metrics.write(params);
|
|
234
|
+
}),
|
|
235
|
+
// Logger
|
|
236
|
+
"log": gated("log", async (params) => {
|
|
237
|
+
return services.logger.log(params);
|
|
238
|
+
}),
|
|
239
|
+
// Companies
|
|
240
|
+
"companies.list": gated("companies.list", async (params) => {
|
|
241
|
+
return services.companies.list(params);
|
|
242
|
+
}),
|
|
243
|
+
"companies.get": gated("companies.get", async (params) => {
|
|
244
|
+
return services.companies.get(params);
|
|
245
|
+
}),
|
|
246
|
+
// Projects
|
|
247
|
+
"projects.list": gated("projects.list", async (params) => {
|
|
248
|
+
return services.projects.list(params);
|
|
249
|
+
}),
|
|
250
|
+
"projects.get": gated("projects.get", async (params) => {
|
|
251
|
+
return services.projects.get(params);
|
|
252
|
+
}),
|
|
253
|
+
"projects.listWorkspaces": gated("projects.listWorkspaces", async (params) => {
|
|
254
|
+
return services.projects.listWorkspaces(params);
|
|
255
|
+
}),
|
|
256
|
+
"projects.getPrimaryWorkspace": gated("projects.getPrimaryWorkspace", async (params) => {
|
|
257
|
+
return services.projects.getPrimaryWorkspace(params);
|
|
258
|
+
}),
|
|
259
|
+
"projects.getWorkspaceForIssue": gated("projects.getWorkspaceForIssue", async (params) => {
|
|
260
|
+
return services.projects.getWorkspaceForIssue(params);
|
|
261
|
+
}),
|
|
262
|
+
// Issues
|
|
263
|
+
"issues.list": gated("issues.list", async (params) => {
|
|
264
|
+
return services.issues.list(params);
|
|
265
|
+
}),
|
|
266
|
+
"issues.get": gated("issues.get", async (params) => {
|
|
267
|
+
return services.issues.get(params);
|
|
268
|
+
}),
|
|
269
|
+
"issues.create": gated("issues.create", async (params) => {
|
|
270
|
+
return services.issues.create(params);
|
|
271
|
+
}),
|
|
272
|
+
"issues.update": gated("issues.update", async (params) => {
|
|
273
|
+
return services.issues.update(params);
|
|
274
|
+
}),
|
|
275
|
+
"issues.listComments": gated("issues.listComments", async (params) => {
|
|
276
|
+
return services.issues.listComments(params);
|
|
277
|
+
}),
|
|
278
|
+
"issues.createComment": gated("issues.createComment", async (params) => {
|
|
279
|
+
return services.issues.createComment(params);
|
|
280
|
+
}),
|
|
281
|
+
// Issue Documents
|
|
282
|
+
"issues.documents.list": gated("issues.documents.list", async (params) => {
|
|
283
|
+
return services.issueDocuments.list(params);
|
|
284
|
+
}),
|
|
285
|
+
"issues.documents.get": gated("issues.documents.get", async (params) => {
|
|
286
|
+
return services.issueDocuments.get(params);
|
|
287
|
+
}),
|
|
288
|
+
"issues.documents.upsert": gated("issues.documents.upsert", async (params) => {
|
|
289
|
+
return services.issueDocuments.upsert(params);
|
|
290
|
+
}),
|
|
291
|
+
"issues.documents.delete": gated("issues.documents.delete", async (params) => {
|
|
292
|
+
return services.issueDocuments.delete(params);
|
|
293
|
+
}),
|
|
294
|
+
// Agents
|
|
295
|
+
"agents.list": gated("agents.list", async (params) => {
|
|
296
|
+
return services.agents.list(params);
|
|
297
|
+
}),
|
|
298
|
+
"agents.get": gated("agents.get", async (params) => {
|
|
299
|
+
return services.agents.get(params);
|
|
300
|
+
}),
|
|
301
|
+
"agents.pause": gated("agents.pause", async (params) => {
|
|
302
|
+
return services.agents.pause(params);
|
|
303
|
+
}),
|
|
304
|
+
"agents.resume": gated("agents.resume", async (params) => {
|
|
305
|
+
return services.agents.resume(params);
|
|
306
|
+
}),
|
|
307
|
+
"agents.invoke": gated("agents.invoke", async (params) => {
|
|
308
|
+
return services.agents.invoke(params);
|
|
309
|
+
}),
|
|
310
|
+
// Agent Sessions
|
|
311
|
+
"agents.sessions.create": gated("agents.sessions.create", async (params) => {
|
|
312
|
+
return services.agentSessions.create(params);
|
|
313
|
+
}),
|
|
314
|
+
"agents.sessions.list": gated("agents.sessions.list", async (params) => {
|
|
315
|
+
return services.agentSessions.list(params);
|
|
316
|
+
}),
|
|
317
|
+
"agents.sessions.sendMessage": gated("agents.sessions.sendMessage", async (params) => {
|
|
318
|
+
return services.agentSessions.sendMessage(params);
|
|
319
|
+
}),
|
|
320
|
+
"agents.sessions.close": gated("agents.sessions.close", async (params) => {
|
|
321
|
+
return services.agentSessions.close(params);
|
|
322
|
+
}),
|
|
323
|
+
// Goals
|
|
324
|
+
"goals.list": gated("goals.list", async (params) => {
|
|
325
|
+
return services.goals.list(params);
|
|
326
|
+
}),
|
|
327
|
+
"goals.get": gated("goals.get", async (params) => {
|
|
328
|
+
return services.goals.get(params);
|
|
329
|
+
}),
|
|
330
|
+
"goals.create": gated("goals.create", async (params) => {
|
|
331
|
+
return services.goals.create(params);
|
|
332
|
+
}),
|
|
333
|
+
"goals.update": gated("goals.update", async (params) => {
|
|
334
|
+
return services.goals.update(params);
|
|
335
|
+
}),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
// Utility: getRequiredCapability
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
/**
|
|
342
|
+
* Get the capability required for a given worker→host method, or `null` if
|
|
343
|
+
* no capability is required.
|
|
344
|
+
*
|
|
345
|
+
* Useful for inspecting capability requirements without calling the factory.
|
|
346
|
+
*
|
|
347
|
+
* @param method - The worker→host method name
|
|
348
|
+
* @returns The required capability, or `null`
|
|
349
|
+
*/
|
|
350
|
+
export function getRequiredCapability(method) {
|
|
351
|
+
return METHOD_CAPABILITY_MAP[method];
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=host-client-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-client-factory.js","sourceRoot":"","sources":["../src/host-client-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5B,IAAI,GAAG,uBAAuB,CAAC;IACxC,IAAI,GAAG,sBAAsB,CAAC,iBAAiB,CAAC;IAEzD,YAAY,QAAgB,EAAE,MAAc,EAAE,UAA4B;QACxE,KAAK,CACH,WAAW,QAAQ,qCAAqC,UAAU,iBAAiB,MAAM,GAAG,CAC7F,CAAC;IACJ,CAAC;CACF;AA6KD,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,qBAAqB,GAA4D;IACrF,0BAA0B;IAC1B,YAAY,EAAE,IAAI;IAElB,QAAQ;IACR,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,oBAAoB;IACjC,cAAc,EAAE,oBAAoB;IAEpC,uEAAuE;IACvE,iBAAi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AC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC/C,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC,CAAC;QACF,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACrD,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC;QACF,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACrD,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA8B;IAE9B,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@paperclipai/plugin-sdk` — Paperclip plugin worker-side SDK.
|
|
3
|
+
*
|
|
4
|
+
* This is the main entrypoint for plugin worker code. For plugin UI bundles,
|
|
5
|
+
* import from `@paperclipai/plugin-sdk/ui` instead.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Plugin worker entrypoint (dist/worker.ts)
|
|
10
|
+
* import { definePlugin, runWorker, z } from "@paperclipai/plugin-sdk";
|
|
11
|
+
*
|
|
12
|
+
* const plugin = definePlugin({
|
|
13
|
+
* async setup(ctx) {
|
|
14
|
+
* ctx.logger.info("Plugin starting up");
|
|
15
|
+
*
|
|
16
|
+
* ctx.events.on("issue.created", async (event) => {
|
|
17
|
+
* ctx.logger.info("Issue created", { issueId: event.entityId });
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* ctx.jobs.register("full-sync", async (job) => {
|
|
21
|
+
* ctx.logger.info("Starting full sync", { runId: job.runId });
|
|
22
|
+
* // ... sync implementation
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* ctx.data.register("sync-health", async ({ companyId }) => {
|
|
26
|
+
* const state = await ctx.state.get({
|
|
27
|
+
* scopeKind: "company",
|
|
28
|
+
* scopeId: String(companyId),
|
|
29
|
+
* stateKey: "last-sync-at",
|
|
30
|
+
* });
|
|
31
|
+
* return { lastSync: state };
|
|
32
|
+
* });
|
|
33
|
+
* },
|
|
34
|
+
*
|
|
35
|
+
* async onHealth() {
|
|
36
|
+
* return { status: "ok" };
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* export default plugin;
|
|
41
|
+
* runWorker(plugin, import.meta.url);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see PLUGIN_SPEC.md §14 — SDK Surface
|
|
45
|
+
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
|
|
46
|
+
*/
|
|
47
|
+
export { definePlugin } from "./define-plugin.js";
|
|
48
|
+
export { createTestHarness } from "./testing.js";
|
|
49
|
+
export { createPluginBundlerPresets } from "./bundlers.js";
|
|
50
|
+
export { startPluginDevServer, getUiBuildSnapshot } from "./dev-server.js";
|
|
51
|
+
export { startWorkerRpcHost, runWorker } from "./worker-rpc-host.js";
|
|
52
|
+
export { createHostClientHandlers, getRequiredCapability, CapabilityDeniedError, } from "./host-client-factory.js";
|
|
53
|
+
export { JSONRPC_VERSION, JSONRPC_ERROR_CODES, PLUGIN_RPC_ERROR_CODES, HOST_TO_WORKER_REQUIRED_METHODS, HOST_TO_WORKER_OPTIONAL_METHODS, MESSAGE_DELIMITER, createRequest, createSuccessResponse, createErrorResponse, createNotification, isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, serializeMessage, parseMessage, JsonRpcParseError, JsonRpcCallError, _resetIdCounter, } from "./protocol.js";
|
|
54
|
+
export type { PluginDefinition, PaperclipPlugin, PluginHealthDiagnostics, PluginConfigValidationResult, PluginWebhookInput, } from "./define-plugin.js";
|
|
55
|
+
export type { TestHarness, TestHarnessOptions, TestHarnessLogEntry, } from "./testing.js";
|
|
56
|
+
export type { PluginBundlerPresetInput, PluginBundlerPresets, EsbuildLikeOptions, RollupLikeConfig, } from "./bundlers.js";
|
|
57
|
+
export type { PluginDevServer, PluginDevServerOptions } from "./dev-server.js";
|
|
58
|
+
export type { WorkerRpcHostOptions, WorkerRpcHost, RunWorkerOptions, } from "./worker-rpc-host.js";
|
|
59
|
+
export type { HostServices, HostClientFactoryOptions, HostClientHandlers, } from "./host-client-factory.js";
|
|
60
|
+
export type { JsonRpcId, JsonRpcRequest, JsonRpcSuccessResponse, JsonRpcError, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcNotification, JsonRpcMessage, JsonRpcErrorCode, PluginRpcErrorCode, InitializeParams, InitializeResult, ConfigChangedParams, ValidateConfigParams, OnEventParams, RunJobParams, GetDataParams, PerformActionParams, ExecuteToolParams, PluginModalBoundsRequest, PluginRenderCloseEvent, PluginLauncherRenderContextSnapshot, HostToWorkerMethods, HostToWorkerMethodName, WorkerToHostMethods, WorkerToHostMethodName, HostToWorkerRequest, HostToWorkerResponse, WorkerToHostRequest, WorkerToHostResponse, WorkerToHostNotifications, WorkerToHostNotificationName, } from "./protocol.js";
|
|
61
|
+
export type { PluginContext, PluginConfigClient, PluginEventsClient, PluginJobsClient, PluginLaunchersClient, PluginHttpClient, PluginSecretsClient, PluginActivityClient, PluginActivityLogEntry, PluginStateClient, PluginEntitiesClient, PluginProjectsClient, PluginCompaniesClient, PluginIssuesClient, PluginAgentsClient, PluginAgentSessionsClient, AgentSession, AgentSessionEvent, AgentSessionSendResult, PluginGoalsClient, PluginDataClient, PluginActionsClient, PluginStreamsClient, PluginToolsClient, PluginMetricsClient, PluginLogger, } from "./types.js";
|
|
62
|
+
export type { ScopeKey, EventFilter, PluginEvent, PluginJobContext, PluginLauncherRegistration, ToolRunContext, ToolResult, PluginEntityUpsert, PluginEntityRecord, PluginEntityQuery, PluginWorkspace, Company, Project, Issue, IssueComment, Agent, Goal, } from "./types.js";
|
|
63
|
+
export type { PaperclipPluginManifestV1, PluginJobDeclaration, PluginWebhookDeclaration, PluginToolDeclaration, PluginUiSlotDeclaration, PluginUiDeclaration, PluginLauncherActionDeclaration, PluginLauncherRenderDeclaration, PluginLauncherDeclaration, PluginMinimumHostVersion, PluginRecord, PluginConfig, JsonSchema, PluginStatus, PluginCategory, PluginCapability, PluginUiSlotType, PluginUiSlotEntityType, PluginLauncherPlacementZone, PluginLauncherAction, PluginLauncherBounds, PluginLauncherRenderEnvironment, PluginStateScopeKind, PluginJobStatus, PluginJobRunStatus, PluginJobRunTrigger, PluginWebhookDeliveryStatus, PluginEventType, PluginBridgeErrorCode, } from "./types.js";
|
|
64
|
+
/**
|
|
65
|
+
* Zod is re-exported for plugin authors to use when defining their
|
|
66
|
+
* `instanceConfigSchema` and tool `parametersSchema`.
|
|
67
|
+
*
|
|
68
|
+
* Plugin authors do not need to add a separate `zod` dependency.
|
|
69
|
+
*
|
|
70
|
+
* @see PLUGIN_SPEC.md §14.1 — Example SDK Shape
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { z } from "@paperclipai/plugin-sdk";
|
|
75
|
+
*
|
|
76
|
+
* const configSchema = z.object({
|
|
77
|
+
* apiKey: z.string().describe("Your API key"),
|
|
78
|
+
* workspace: z.string().optional(),
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export { z } from "zod";
|
|
83
|
+
export { PLUGIN_API_VERSION, PLUGIN_STATUSES, PLUGIN_CATEGORIES, PLUGIN_CAPABILITIES, PLUGIN_UI_SLOT_TYPES, PLUGIN_UI_SLOT_ENTITY_TYPES, PLUGIN_STATE_SCOPE_KINDS, PLUGIN_JOB_STATUSES, PLUGIN_JOB_RUN_STATUSES, PLUGIN_JOB_RUN_TRIGGERS, PLUGIN_WEBHOOK_DELIVERY_STATUSES, PLUGIN_EVENT_TYPES, PLUGIN_BRIDGE_ERROR_CODES, } from "@paperclipai/shared";
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,EAC/B,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AAOvB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CA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X,WAAW,EACX,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,OAAO,EACP,KAAK,EACL,YAAY,EACZ,KAAK,EACL,IAAI,GACL,MAAM,YAAY,CAAC;AAKpB,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,+BAA+B,EAC/B,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,+BAA+B,EAC/B,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAMpB;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,gCAAgC,EAChC,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@paperclipai/plugin-sdk` — Paperclip plugin worker-side SDK.
|
|
3
|
+
*
|
|
4
|
+
* This is the main entrypoint for plugin worker code. For plugin UI bundles,
|
|
5
|
+
* import from `@paperclipai/plugin-sdk/ui` instead.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Plugin worker entrypoint (dist/worker.ts)
|
|
10
|
+
* import { definePlugin, runWorker, z } from "@paperclipai/plugin-sdk";
|
|
11
|
+
*
|
|
12
|
+
* const plugin = definePlugin({
|
|
13
|
+
* async setup(ctx) {
|
|
14
|
+
* ctx.logger.info("Plugin starting up");
|
|
15
|
+
*
|
|
16
|
+
* ctx.events.on("issue.created", async (event) => {
|
|
17
|
+
* ctx.logger.info("Issue created", { issueId: event.entityId });
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* ctx.jobs.register("full-sync", async (job) => {
|
|
21
|
+
* ctx.logger.info("Starting full sync", { runId: job.runId });
|
|
22
|
+
* // ... sync implementation
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* ctx.data.register("sync-health", async ({ companyId }) => {
|
|
26
|
+
* const state = await ctx.state.get({
|
|
27
|
+
* scopeKind: "company",
|
|
28
|
+
* scopeId: String(companyId),
|
|
29
|
+
* stateKey: "last-sync-at",
|
|
30
|
+
* });
|
|
31
|
+
* return { lastSync: state };
|
|
32
|
+
* });
|
|
33
|
+
* },
|
|
34
|
+
*
|
|
35
|
+
* async onHealth() {
|
|
36
|
+
* return { status: "ok" };
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* export default plugin;
|
|
41
|
+
* runWorker(plugin, import.meta.url);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see PLUGIN_SPEC.md §14 — SDK Surface
|
|
45
|
+
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
|
|
46
|
+
*/
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Main factory
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
export { definePlugin } from "./define-plugin.js";
|
|
51
|
+
export { createTestHarness } from "./testing.js";
|
|
52
|
+
export { createPluginBundlerPresets } from "./bundlers.js";
|
|
53
|
+
export { startPluginDevServer, getUiBuildSnapshot } from "./dev-server.js";
|
|
54
|
+
export { startWorkerRpcHost, runWorker } from "./worker-rpc-host.js";
|
|
55
|
+
export { createHostClientHandlers, getRequiredCapability, CapabilityDeniedError, } from "./host-client-factory.js";
|
|
56
|
+
// JSON-RPC protocol helpers and constants
|
|
57
|
+
export { JSONRPC_VERSION, JSONRPC_ERROR_CODES, PLUGIN_RPC_ERROR_CODES, HOST_TO_WORKER_REQUIRED_METHODS, HOST_TO_WORKER_OPTIONAL_METHODS, MESSAGE_DELIMITER, createRequest, createSuccessResponse, createErrorResponse, createNotification, isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, serializeMessage, parseMessage, JsonRpcParseError, JsonRpcCallError, _resetIdCounter, } from "./protocol.js";
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Zod re-export
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
/**
|
|
62
|
+
* Zod is re-exported for plugin authors to use when defining their
|
|
63
|
+
* `instanceConfigSchema` and tool `parametersSchema`.
|
|
64
|
+
*
|
|
65
|
+
* Plugin authors do not need to add a separate `zod` dependency.
|
|
66
|
+
*
|
|
67
|
+
* @see PLUGIN_SPEC.md §14.1 — Example SDK Shape
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { z } from "@paperclipai/plugin-sdk";
|
|
72
|
+
*
|
|
73
|
+
* const configSchema = z.object({
|
|
74
|
+
* apiKey: z.string().describe("Your API key"),
|
|
75
|
+
* workspace: z.string().optional(),
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export { z } from "zod";
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Constants re-exports (for plugin code that needs to check values at runtime)
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
export { PLUGIN_API_VERSION, PLUGIN_STATUSES, PLUGIN_CATEGORIES, PLUGIN_CAPABILITIES, PLUGIN_UI_SLOT_TYPES, PLUGIN_UI_SLOT_ENTITY_TYPES, PLUGIN_STATE_SCOPE_KINDS, PLUGIN_JOB_STATUSES, PLUGIN_JOB_RUN_STATUSES, PLUGIN_JOB_RUN_TRIGGERS, PLUGIN_WEBHOOK_DELIVERY_STATUSES, PLUGIN_EVENT_TYPES, PLUGIN_BRIDGE_ERROR_CODES, } from "@paperclipai/shared";
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,0CAA0C;AAC1C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,EAC/B,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AA+JvB,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;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