@evermore.work/plugin-sdk 2026.509.0-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.
Files changed (62) hide show
  1. package/README.md +1215 -0
  2. package/dist/bundlers.d.ts +57 -0
  3. package/dist/bundlers.d.ts.map +1 -0
  4. package/dist/bundlers.js +106 -0
  5. package/dist/bundlers.js.map +1 -0
  6. package/dist/define-plugin.d.ts +266 -0
  7. package/dist/define-plugin.d.ts.map +1 -0
  8. package/dist/define-plugin.js +85 -0
  9. package/dist/define-plugin.js.map +1 -0
  10. package/dist/dev-cli.d.ts +3 -0
  11. package/dist/dev-cli.d.ts.map +1 -0
  12. package/dist/dev-cli.js +49 -0
  13. package/dist/dev-cli.js.map +1 -0
  14. package/dist/dev-server.d.ts +34 -0
  15. package/dist/dev-server.d.ts.map +1 -0
  16. package/dist/dev-server.js +194 -0
  17. package/dist/dev-server.js.map +1 -0
  18. package/dist/host-client-factory.d.ts +272 -0
  19. package/dist/host-client-factory.d.ts.map +1 -0
  20. package/dist/host-client-factory.js +481 -0
  21. package/dist/host-client-factory.js.map +1 -0
  22. package/dist/index.d.ts +84 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +84 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/protocol.d.ts +1285 -0
  27. package/dist/protocol.d.ts.map +1 -0
  28. package/dist/protocol.js +306 -0
  29. package/dist/protocol.js.map +1 -0
  30. package/dist/testing.d.ts +166 -0
  31. package/dist/testing.d.ts.map +1 -0
  32. package/dist/testing.js +1766 -0
  33. package/dist/testing.js.map +1 -0
  34. package/dist/types.d.ts +1330 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +12 -0
  37. package/dist/types.js.map +1 -0
  38. package/dist/ui/components.d.ts +511 -0
  39. package/dist/ui/components.d.ts.map +1 -0
  40. package/dist/ui/components.js +135 -0
  41. package/dist/ui/components.js.map +1 -0
  42. package/dist/ui/hooks.d.ts +155 -0
  43. package/dist/ui/hooks.d.ts.map +1 -0
  44. package/dist/ui/hooks.js +195 -0
  45. package/dist/ui/hooks.js.map +1 -0
  46. package/dist/ui/index.d.ts +54 -0
  47. package/dist/ui/index.d.ts.map +1 -0
  48. package/dist/ui/index.js +51 -0
  49. package/dist/ui/index.js.map +1 -0
  50. package/dist/ui/runtime.d.ts +3 -0
  51. package/dist/ui/runtime.d.ts.map +1 -0
  52. package/dist/ui/runtime.js +30 -0
  53. package/dist/ui/runtime.js.map +1 -0
  54. package/dist/ui/types.d.ts +388 -0
  55. package/dist/ui/types.d.ts.map +1 -0
  56. package/dist/ui/types.js +17 -0
  57. package/dist/ui/types.js.map +1 -0
  58. package/dist/worker-rpc-host.d.ts +127 -0
  59. package/dist/worker-rpc-host.d.ts.map +1 -0
  60. package/dist/worker-rpc-host.js +1279 -0
  61. package/dist/worker-rpc-host.js.map +1 -0
  62. package/package.json +88 -0
@@ -0,0 +1,388 @@
1
+ /**
2
+ * Evermore plugin UI SDK — types for plugin frontend components.
3
+ *
4
+ * Plugin UI bundles import from `@evermore.work/plugin-sdk/ui`. This subpath
5
+ * provides the bridge hooks, component prop interfaces, and error types that
6
+ * plugin React components use to communicate with the host.
7
+ *
8
+ * Plugin UI bundles are loaded as ES modules into designated extension slots.
9
+ * All communication with the plugin worker goes through the host bridge — plugin
10
+ * components must NOT access host internals or call host APIs directly.
11
+ *
12
+ * @see PLUGIN_SPEC.md §19 — UI Extension Model
13
+ * @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
14
+ * @see PLUGIN_SPEC.md §29.2 — SDK Versioning
15
+ */
16
+ import type { AnchorHTMLAttributes, MouseEvent as ReactMouseEvent } from "react";
17
+ import type { PluginBridgeErrorCode } from "@evermore.work/shared";
18
+ import type { PluginLauncherRenderContextSnapshot, PluginModalBoundsRequest, PluginRenderCloseEvent } from "../protocol.js";
19
+ export type { PluginBridgeErrorCode, PluginLauncherBounds, PluginLauncherRenderEnvironment, } from "@evermore.work/shared";
20
+ export type { PluginLauncherRenderContextSnapshot, PluginModalBoundsRequest, PluginRenderCloseEvent, } from "../protocol.js";
21
+ /**
22
+ * Structured error returned by the bridge when a UI → worker call fails.
23
+ *
24
+ * Plugin components receive this in `usePluginData()` as the `error` field
25
+ * and may encounter it as a thrown value from `usePluginAction()`.
26
+ *
27
+ * Error codes:
28
+ * - `WORKER_UNAVAILABLE` — plugin worker is not running
29
+ * - `CAPABILITY_DENIED` — plugin lacks the required capability
30
+ * - `WORKER_ERROR` — worker returned an error from its handler
31
+ * - `TIMEOUT` — worker did not respond within the configured timeout
32
+ * - `UNKNOWN` — unexpected bridge-level failure
33
+ *
34
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
35
+ */
36
+ export interface PluginBridgeError {
37
+ /** Machine-readable error code. */
38
+ code: PluginBridgeErrorCode;
39
+ /** Human-readable error message. */
40
+ message: string;
41
+ /**
42
+ * Original error details from the worker, if available.
43
+ * Only present when `code === "WORKER_ERROR"`.
44
+ */
45
+ details?: unknown;
46
+ }
47
+ /**
48
+ * Read-only host context passed to every plugin component via `useHostContext()`.
49
+ *
50
+ * Plugin components use this to know which company, project, or entity is
51
+ * currently active so they can scope their data requests accordingly.
52
+ *
53
+ * @see PLUGIN_SPEC.md §19 — UI Extension Model
54
+ */
55
+ export interface PluginHostContext {
56
+ /** UUID of the currently active company, if any. */
57
+ companyId: string | null;
58
+ /** URL prefix for the current company (e.g. `"my-company"`). */
59
+ companyPrefix: string | null;
60
+ /** UUID of the currently active project, if any. */
61
+ projectId: string | null;
62
+ /** UUID of the current entity (for detail tab contexts), if any. */
63
+ entityId: string | null;
64
+ /** Type of the current entity (e.g. `"issue"`, `"agent"`). */
65
+ entityType: string | null;
66
+ /**
67
+ * UUID of the parent entity when rendering nested slots.
68
+ * For `commentAnnotation` slots this is the issue ID containing the comment.
69
+ */
70
+ parentEntityId?: string | null;
71
+ /** UUID of the current authenticated user. */
72
+ userId: string | null;
73
+ /** Runtime metadata for the host container currently rendering this plugin UI. */
74
+ renderEnvironment?: PluginRenderEnvironmentContext | null;
75
+ }
76
+ /**
77
+ * Async-capable callback invoked during a host-managed close lifecycle.
78
+ */
79
+ export type PluginRenderCloseHandler = (event: PluginRenderCloseEvent) => void | Promise<void>;
80
+ /**
81
+ * Close lifecycle hooks available when the plugin UI is rendered inside a
82
+ * host-managed launcher environment.
83
+ */
84
+ export interface PluginRenderCloseLifecycle {
85
+ /** Register a callback before the host closes the current environment. */
86
+ onBeforeClose?(handler: PluginRenderCloseHandler): () => void;
87
+ /** Register a callback after the host closes the current environment. */
88
+ onClose?(handler: PluginRenderCloseHandler): () => void;
89
+ }
90
+ /**
91
+ * Runtime information about the host container currently rendering a plugin UI.
92
+ */
93
+ export interface PluginRenderEnvironmentContext extends PluginLauncherRenderContextSnapshot {
94
+ /** Optional host callback for requesting new bounds while a modal is open. */
95
+ requestModalBounds?(request: PluginModalBoundsRequest): Promise<void>;
96
+ /** Optional close lifecycle callbacks for host-managed overlays. */
97
+ closeLifecycle?: PluginRenderCloseLifecycle | null;
98
+ }
99
+ /**
100
+ * Options for host-managed Evermore navigation from plugin UI.
101
+ */
102
+ export interface HostNavigationOptions {
103
+ /** Replace the current history entry instead of pushing a new one. */
104
+ replace?: boolean;
105
+ /** Optional state forwarded to the host router. */
106
+ state?: unknown;
107
+ }
108
+ /**
109
+ * Options for `useHostNavigation().linkProps()`.
110
+ */
111
+ export interface HostNavigationLinkOptions extends HostNavigationOptions {
112
+ /** Standard anchor target. Non-`_self` targets are not intercepted. */
113
+ target?: AnchorHTMLAttributes<HTMLAnchorElement>["target"];
114
+ /** Standard anchor rel attribute. */
115
+ rel?: AnchorHTMLAttributes<HTMLAnchorElement>["rel"];
116
+ }
117
+ /**
118
+ * Anchor props returned by `useHostNavigation().linkProps()`.
119
+ *
120
+ * The `href` is always real so browser affordances such as copy-link,
121
+ * modifier-click, middle-click, and open-in-new-tab continue to work.
122
+ */
123
+ export interface HostNavigationLinkProps extends Pick<AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "target" | "rel"> {
124
+ onClick: (event: ReactMouseEvent<HTMLAnchorElement>) => void;
125
+ }
126
+ /**
127
+ * Snapshot of the host router location, exposed to plugin UI through
128
+ * `useHostLocation()`. Mirrors the relevant subset of `Location` from
129
+ * `react-router-dom` so plugins can react to URL changes without importing
130
+ * router internals.
131
+ *
132
+ * @see PLUGIN_SPEC.md §19 — UI Extension Model
133
+ */
134
+ export interface HostLocation {
135
+ /** Current pathname, e.g. `/EVR/wiki`. */
136
+ pathname: string;
137
+ /** Current search string, e.g. `?tab=config` (includes the leading `?`). */
138
+ search: string;
139
+ /** Current hash, e.g. `#document-plan` (includes the leading `#`). */
140
+ hash: string;
141
+ /** Optional state forwarded by the host router for same-tab SPA navigation. */
142
+ state?: unknown;
143
+ }
144
+ /**
145
+ * Host-managed navigation helpers for plugin UI.
146
+ */
147
+ export interface HostNavigation {
148
+ /**
149
+ * Resolve a Evermore-internal path using the active company prefix.
150
+ *
151
+ * For example, in company `EVR`, `resolveHref("/wiki")` returns
152
+ * `"/EVR/wiki"`, while `resolveHref("/EVR/wiki")` stays unchanged.
153
+ */
154
+ resolveHref(to: string): string;
155
+ /** Navigate through the host router without reloading the document. */
156
+ navigate(to: string, options?: HostNavigationOptions): void;
157
+ /**
158
+ * Build anchor props for host-managed links.
159
+ *
160
+ * Plain left-clicks are routed through the host SPA router. Browser-native
161
+ * link gestures are left alone because the returned props include a real
162
+ * `href`.
163
+ */
164
+ linkProps(to: string, options?: HostNavigationLinkOptions): HostNavigationLinkProps;
165
+ }
166
+ /**
167
+ * Props passed to a plugin page component.
168
+ *
169
+ * A page is a full-page extension at `/plugins/:pluginId` or `/:company/plugins/:pluginId`.
170
+ *
171
+ * @see PLUGIN_SPEC.md §19.1 — Global Operator Routes
172
+ * @see PLUGIN_SPEC.md §19.2 — Company-Context Routes
173
+ */
174
+ export interface PluginPageProps {
175
+ /** The current host context. */
176
+ context: PluginHostContext;
177
+ }
178
+ /**
179
+ * Props passed to a plugin dashboard widget component.
180
+ *
181
+ * A dashboard widget is rendered as a card or section on the main dashboard.
182
+ *
183
+ * @see PLUGIN_SPEC.md §19.4 — Dashboard Widgets
184
+ */
185
+ export interface PluginWidgetProps {
186
+ /** The current host context. */
187
+ context: PluginHostContext;
188
+ }
189
+ /**
190
+ * Props passed to a plugin detail tab component.
191
+ *
192
+ * A detail tab is rendered as an additional tab on a project, issue, agent,
193
+ * goal, or run detail page.
194
+ *
195
+ * @see PLUGIN_SPEC.md §19.3 — Detail Tabs
196
+ */
197
+ export interface PluginDetailTabProps {
198
+ /** The current host context, always including `entityId` and `entityType`. */
199
+ context: PluginHostContext & {
200
+ entityId: string;
201
+ entityType: string;
202
+ };
203
+ }
204
+ /**
205
+ * Props passed to a plugin sidebar component.
206
+ *
207
+ * A sidebar entry adds a link or section to the application sidebar.
208
+ *
209
+ * @see PLUGIN_SPEC.md §19.5 — Sidebar Entries
210
+ */
211
+ export interface PluginSidebarProps {
212
+ /** The current host context. */
213
+ context: PluginHostContext;
214
+ }
215
+ /**
216
+ * Props passed to a plugin route sidebar component.
217
+ *
218
+ * A route sidebar replaces the normal company sidebar while the user is on a
219
+ * matching plugin page route declared with the same `routePath`.
220
+ *
221
+ * @see PLUGIN_SPEC.md §19.5 — Sidebar Entries
222
+ */
223
+ export interface PluginRouteSidebarProps {
224
+ /** The current host context. */
225
+ context: PluginHostContext;
226
+ }
227
+ /**
228
+ * Props passed to a plugin project sidebar item component.
229
+ *
230
+ * A project sidebar item is rendered **once per project** under that project's
231
+ * row in the sidebar Projects list. The host passes the current project's id
232
+ * in `context.entityId` and `context.entityType` is `"project"`.
233
+ *
234
+ * Use this slot to add a link (e.g. "Files", "Linear Sync") that navigates to
235
+ * the project detail with a plugin tab selected: `/projects/:projectRef?tab=plugin:key:slotId`.
236
+ *
237
+ * @see PLUGIN_SPEC.md §19.5.1 — Project sidebar items
238
+ */
239
+ export interface PluginProjectSidebarItemProps {
240
+ /** Host context plus entityId (project id) and entityType "project". */
241
+ context: PluginHostContext & {
242
+ entityId: string;
243
+ entityType: "project";
244
+ };
245
+ }
246
+ /**
247
+ * Props passed to a plugin comment annotation component.
248
+ *
249
+ * A comment annotation is rendered below each individual comment in the
250
+ * issue detail timeline. The host passes the comment ID as `entityId`
251
+ * and `"comment"` as `entityType`, plus the parent issue ID as
252
+ * `parentEntityId` so the plugin can scope data fetches to both.
253
+ *
254
+ * Use this slot to augment comments with parsed file links, sentiment
255
+ * badges, inline actions, or any per-comment metadata.
256
+ *
257
+ * @see PLUGIN_SPEC.md §19.6 — Comment Annotations
258
+ */
259
+ export interface PluginCommentAnnotationProps {
260
+ /** Host context with comment and parent issue identifiers. */
261
+ context: PluginHostContext & {
262
+ /** UUID of the comment being annotated. */
263
+ entityId: string;
264
+ /** Always `"comment"` for comment annotation slots. */
265
+ entityType: "comment";
266
+ /** UUID of the parent issue containing this comment. */
267
+ parentEntityId: string;
268
+ };
269
+ }
270
+ /**
271
+ * Props passed to a plugin comment context menu item component.
272
+ *
273
+ * A comment context menu item is rendered in a "more" dropdown menu on
274
+ * each comment in the issue detail timeline. The host passes the comment
275
+ * ID as `entityId` and `"comment"` as `entityType`, plus the parent
276
+ * issue ID as `parentEntityId`.
277
+ *
278
+ * Use this slot to add per-comment actions such as "Create sub-issue from
279
+ * comment", "Translate", "Flag for review", or any custom plugin action.
280
+ *
281
+ * @see PLUGIN_SPEC.md §19.7 — Comment Context Menu Items
282
+ */
283
+ export interface PluginCommentContextMenuItemProps {
284
+ /** Host context with comment and parent issue identifiers. */
285
+ context: PluginHostContext & {
286
+ /** UUID of the comment this menu item acts on. */
287
+ entityId: string;
288
+ /** Always `"comment"` for comment context menu item slots. */
289
+ entityType: "comment";
290
+ /** UUID of the parent issue containing this comment. */
291
+ parentEntityId: string;
292
+ };
293
+ }
294
+ /**
295
+ * Props passed to a plugin settings page component.
296
+ *
297
+ * Overrides the auto-generated JSON Schema form when the plugin declares
298
+ * a `settingsPage` UI slot. The component is responsible for reading and
299
+ * writing config through the bridge.
300
+ *
301
+ * @see PLUGIN_SPEC.md §19.8 — Plugin Settings UI
302
+ */
303
+ export interface PluginSettingsPageProps {
304
+ /** The current host context. */
305
+ context: PluginHostContext;
306
+ }
307
+ /**
308
+ * Return value of `usePluginData(key, params)`.
309
+ *
310
+ * Mirrors a standard async data-fetching hook pattern:
311
+ * exactly one of `data` or `error` is non-null at any time (unless `loading`).
312
+ *
313
+ * @template T The type of the data returned by the worker handler
314
+ *
315
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
316
+ */
317
+ export interface PluginDataResult<T = unknown> {
318
+ /** The data returned by the worker's `getData` handler. `null` while loading or on error. */
319
+ data: T | null;
320
+ /** `true` while the initial request or a refresh is in flight. */
321
+ loading: boolean;
322
+ /** Bridge error if the request failed. `null` on success or while loading. */
323
+ error: PluginBridgeError | null;
324
+ /**
325
+ * Manually trigger a data refresh.
326
+ * Useful for poll-based updates or post-action refreshes.
327
+ */
328
+ refresh(): void;
329
+ }
330
+ export type PluginToastTone = "info" | "success" | "warn" | "error";
331
+ export interface PluginToastAction {
332
+ label: string;
333
+ href: string;
334
+ }
335
+ export interface PluginToastInput {
336
+ id?: string;
337
+ dedupeKey?: string;
338
+ title: string;
339
+ body?: string;
340
+ tone?: PluginToastTone;
341
+ ttlMs?: number;
342
+ action?: PluginToastAction;
343
+ }
344
+ export type PluginToastFn = (input: PluginToastInput) => string | null;
345
+ /**
346
+ * Return value of `usePluginStream<T>(channel)`.
347
+ *
348
+ * Provides a growing array of events pushed from the plugin worker via SSE,
349
+ * plus connection status metadata.
350
+ *
351
+ * @template T The type of each event emitted by the worker
352
+ *
353
+ * @see PLUGIN_SPEC.md §19.8 — Real-Time Streaming
354
+ */
355
+ export interface PluginStreamResult<T = unknown> {
356
+ /** All events received so far, in arrival order. */
357
+ events: T[];
358
+ /** The most recently received event, or `null` if none yet. */
359
+ lastEvent: T | null;
360
+ /** `true` while the SSE connection is being established. */
361
+ connecting: boolean;
362
+ /** `true` once the SSE connection is open and receiving events. */
363
+ connected: boolean;
364
+ /** Error if the SSE connection failed or was interrupted. `null` otherwise. */
365
+ error: Error | null;
366
+ /** Close the SSE connection and stop receiving events. */
367
+ close(): void;
368
+ }
369
+ /**
370
+ * Return value of `usePluginAction(key)`.
371
+ *
372
+ * Returns an async function that, when called, sends an action request
373
+ * to the worker's `performAction` handler and returns the result.
374
+ *
375
+ * On failure, the async function throws a `PluginBridgeError`.
376
+ *
377
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
378
+ *
379
+ * @example
380
+ * ```tsx
381
+ * const resync = usePluginAction("resync");
382
+ * <button onClick={() => resync({ companyId }).catch(err => console.error(err))}>
383
+ * Resync Now
384
+ * </button>
385
+ * ```
386
+ */
387
+ export type PluginActionFn = (params?: Record<string, unknown>) => Promise<unknown>;
388
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,IAAI,eAAe,EAC9B,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,qBAAqB,EAGtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,mCAAmC,EACnC,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,mCAAmC,EACnC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAMxB;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,O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CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Evermore plugin UI SDK — types for plugin frontend components.
3
+ *
4
+ * Plugin UI bundles import from `@evermore.work/plugin-sdk/ui`. This subpath
5
+ * provides the bridge hooks, component prop interfaces, and error types that
6
+ * plugin React components use to communicate with the host.
7
+ *
8
+ * Plugin UI bundles are loaded as ES modules into designated extension slots.
9
+ * All communication with the plugin worker goes through the host bridge — plugin
10
+ * components must NOT access host internals or call host APIs directly.
11
+ *
12
+ * @see PLUGIN_SPEC.md §19 — UI Extension Model
13
+ * @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
14
+ * @see PLUGIN_SPEC.md §29.2 — SDK Versioning
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Worker-side RPC host — runs inside the child process spawned by the host.
3
+ *
4
+ * This module is the worker-side counterpart to the server's
5
+ * `PluginWorkerManager`. It:
6
+ *
7
+ * 1. Reads newline-delimited JSON-RPC 2.0 requests from **stdin**
8
+ * 2. Dispatches them to the appropriate plugin handler (events, jobs, tools, …)
9
+ * 3. Writes JSON-RPC 2.0 responses back on **stdout**
10
+ * 4. Provides a concrete `PluginContext` whose SDK client methods (e.g.
11
+ * `ctx.state.get()`, `ctx.events.emit()`) send JSON-RPC requests to the
12
+ * host on stdout and await responses on stdin.
13
+ *
14
+ * ## Message flow
15
+ *
16
+ * ```
17
+ * Host (parent) Worker (this module)
18
+ * | |
19
+ * |--- request(initialize) -------------> | → calls plugin.setup(ctx)
20
+ * |<-- response(ok:true) ---------------- |
21
+ * | |
22
+ * |--- notification(onEvent) -----------> | → dispatches to registered handler
23
+ * | |
24
+ * |<-- request(state.get) --------------- | ← SDK client call from plugin code
25
+ * |--- response(result) ----------------> |
26
+ * | |
27
+ * |--- request(shutdown) ---------------> | → calls plugin.onShutdown()
28
+ * |<-- response(void) ------------------ |
29
+ * | (process exits)
30
+ * ```
31
+ *
32
+ * @see PLUGIN_SPEC.md §12 — Process Model
33
+ * @see PLUGIN_SPEC.md §13 — Host-Worker Protocol
34
+ * @see PLUGIN_SPEC.md §14 — SDK Surface
35
+ */
36
+ import type { EvermorePlugin } from "./define-plugin.js";
37
+ /**
38
+ * Options for starting the worker-side RPC host.
39
+ */
40
+ export interface WorkerRpcHostOptions {
41
+ /**
42
+ * The plugin definition returned by `definePlugin()`.
43
+ *
44
+ * The worker entrypoint should import its plugin and pass it here.
45
+ */
46
+ plugin: EvermorePlugin;
47
+ /**
48
+ * Input stream to read JSON-RPC messages from.
49
+ * Defaults to `process.stdin`.
50
+ */
51
+ stdin?: NodeJS.ReadableStream;
52
+ /**
53
+ * Output stream to write JSON-RPC messages to.
54
+ * Defaults to `process.stdout`.
55
+ */
56
+ stdout?: NodeJS.WritableStream;
57
+ /**
58
+ * Default timeout (ms) for worker→host RPC calls.
59
+ * Defaults to 30 000 ms.
60
+ */
61
+ rpcTimeoutMs?: number;
62
+ }
63
+ /**
64
+ * A running worker RPC host instance.
65
+ *
66
+ * Returned by `startWorkerRpcHost()`. Callers (usually just the worker
67
+ * bootstrap) hold a reference so they can inspect status or force-stop.
68
+ */
69
+ export interface WorkerRpcHost {
70
+ /** Whether the host is currently running and listening for messages. */
71
+ readonly running: boolean;
72
+ /**
73
+ * Stop the RPC host immediately. Closes readline, rejects pending
74
+ * outbound calls, and does NOT call the plugin's shutdown hook (that
75
+ * should have already been called via the `shutdown` RPC method).
76
+ */
77
+ stop(): void;
78
+ }
79
+ /**
80
+ * Options for runWorker when testing (optional stdio to avoid using process streams).
81
+ * When both stdin and stdout are provided, the "is main module" check is skipped
82
+ * and the host is started with these streams. Used by tests.
83
+ */
84
+ export interface RunWorkerOptions {
85
+ stdin?: NodeJS.ReadableStream;
86
+ stdout?: NodeJS.WritableStream;
87
+ }
88
+ /**
89
+ * Start the worker when this module is the process entrypoint.
90
+ *
91
+ * Call this at the bottom of your worker file so that when the host runs
92
+ * `node dist/worker.js`, the RPC host starts and the process stays alive.
93
+ * When the module is imported (e.g. for re-exports or tests), nothing runs.
94
+ *
95
+ * When `options.stdin` and `options.stdout` are provided (e.g. in tests),
96
+ * the main-module check is skipped and the host is started with those streams.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const plugin = definePlugin({ ... });
101
+ * export default plugin;
102
+ * runWorker(plugin, import.meta.url);
103
+ * ```
104
+ */
105
+ export declare function runWorker(plugin: EvermorePlugin, moduleUrl: string, options?: RunWorkerOptions): WorkerRpcHost | void;
106
+ /**
107
+ * Start the worker-side RPC host.
108
+ *
109
+ * This function is typically called from a thin bootstrap script that is the
110
+ * actual entrypoint of the child process:
111
+ *
112
+ * ```ts
113
+ * // worker-bootstrap.ts
114
+ * import plugin from "./worker.js";
115
+ * import { startWorkerRpcHost } from "@evermore.work/plugin-sdk";
116
+ *
117
+ * startWorkerRpcHost({ plugin });
118
+ * ```
119
+ *
120
+ * The host begins listening on stdin immediately. It does NOT call
121
+ * `plugin.definition.setup()` yet — that happens when the host sends the
122
+ * `initialize` RPC.
123
+ *
124
+ * @returns A handle for inspecting or stopping the RPC host
125
+ */
126
+ export declare function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost;
127
+ //# sourceMappingURL=worker-rpc-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-rpc-host.d.ts","sourceRoot":"","sources":["../src/worker-rpc-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAaH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAiEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAE9B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAE/B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;CACd;AAuBD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,gBAAgB,GACzB,aAAa,GAAG,IAAI,CAkBtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAq4C/E"}