@hachej/boring-workspace 0.1.32 → 0.1.34

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.
@@ -46,11 +46,20 @@ interface BoringPluginListEntry$1 {
46
46
  frontTarget?: BoringPluginFrontTarget$1;
47
47
  }
48
48
 
49
+ type BoringPluginSourceKind = "internal" | "external";
50
+ interface BoringPluginSource {
51
+ rootDir: string;
52
+ kind: BoringPluginSourceKind;
53
+ workspaceId?: string;
54
+ }
55
+ type BoringPluginSourceInput = string | BoringPluginSource;
49
56
  interface BoringServerPluginManifest {
50
57
  id: string;
51
58
  rootDir: string;
52
59
  version: string;
53
60
  boring: BoringPackageBoringField;
61
+ /** True when package.json explicitly declares a boring manifest. Pi-only packages remain valid Pi resources but are not listed as Boring plugins. */
62
+ hasBoring: boolean;
54
63
  pi?: BoringPackagePiField;
55
64
  frontPath?: string;
56
65
  /** Legacy Vite-dev browser import fallback (`/@fs/...`). */
@@ -58,6 +67,7 @@ interface BoringServerPluginManifest {
58
67
  serverPath?: string;
59
68
  extensionPaths?: string[];
60
69
  skillPaths?: string[];
70
+ source: BoringPluginSource;
61
71
  }
62
72
  type BoringPluginNativeFrontTargetTrust = BoringPluginNativeFrontTargetTrust$1;
63
73
  type BoringPluginNativeFrontTarget = BoringPluginNativeFrontTarget$1;
@@ -168,4 +178,4 @@ declare function bootstrapServer(options: ServerBootstrapOptions): ServerBootstr
168
178
 
169
179
  declare function createInMemoryBridge(): UiBridge;
170
180
 
171
- export { type BoringPluginFrontTargetResolver as B, type PluginRestartSurface as P, type ServerBootstrapOptions as S, type WorkspaceServerPlugin as W, type WorkspaceProvisioningContribution as a, type WorkspaceRouteContribution as b, createInMemoryBridge as c, type WorkspaceRuntimeProvisioningInput as d, type WorkspaceServerPluginAsset as e, type BoringServerPluginManifest as f, type BoringPluginListEntry as g, type BoringPluginFrontTarget as h, type BoringPluginEvent as i, type BoringPluginFrontTargetResolverContext as j, type BoringPluginNativeFrontTarget as k, type BoringPluginNativeFrontTargetTrust as l, type ServerBootstrapResult as m, bootstrapServer as n, defineServerPlugin as o, validateServerPlugin as v };
181
+ export { type BoringPluginSourceInput as B, type PluginRestartSurface as P, type ServerBootstrapOptions as S, type WorkspaceServerPlugin as W, type BoringPluginFrontTargetResolver as a, type WorkspaceProvisioningContribution as b, type WorkspaceRouteContribution as c, createInMemoryBridge as d, type WorkspaceRuntimeProvisioningInput as e, type WorkspaceServerPluginAsset as f, type BoringServerPluginManifest as g, type BoringPluginListEntry as h, type BoringPluginFrontTarget as i, type BoringPluginSource as j, type BoringPluginEvent as k, type BoringPluginFrontTargetResolverContext as l, type BoringPluginNativeFrontTarget as m, type BoringPluginNativeFrontTargetTrust as n, type BoringPluginSourceKind as o, type ServerBootstrapResult as p, bootstrapServer as q, defineServerPlugin as r, validateServerPlugin as v };
@@ -0,0 +1,47 @@
1
+ interface PluginLogger {
2
+ debug(fields: Record<string, unknown>, message?: string): void;
3
+ debug(message: string): void;
4
+ info(fields: Record<string, unknown>, message?: string): void;
5
+ info(message: string): void;
6
+ warn(fields: Record<string, unknown>, message?: string): void;
7
+ warn(message: string): void;
8
+ error(fields: Record<string, unknown>, message?: string): void;
9
+ error(message: string): void;
10
+ }
11
+ type ReadonlyHeaders = Pick<Headers, "entries" | "forEach" | "get" | "has" | typeof Symbol.iterator>;
12
+ interface RuntimePluginContext {
13
+ pluginId: string;
14
+ method: string;
15
+ path: string;
16
+ query: URLSearchParams;
17
+ headers: ReadonlyHeaders;
18
+ signal: AbortSignal;
19
+ body: unknown;
20
+ logger: PluginLogger;
21
+ }
22
+ type RuntimePluginHandler = (ctx: RuntimePluginContext) => unknown | Promise<unknown>;
23
+ interface RuntimePluginRouter {
24
+ get(path: string, handler: RuntimePluginHandler): void;
25
+ post(path: string, handler: RuntimePluginHandler): void;
26
+ put(path: string, handler: RuntimePluginHandler): void;
27
+ patch(path: string, handler: RuntimePluginHandler): void;
28
+ delete(path: string, handler: RuntimePluginHandler): void;
29
+ head(path: string, handler: RuntimePluginHandler): void;
30
+ options(path: string, handler: RuntimePluginHandler): void;
31
+ all(path: string, handler: RuntimePluginHandler): void;
32
+ }
33
+ interface RuntimePluginResponse {
34
+ kind: "response";
35
+ status?: number;
36
+ headers?: Record<string, string>;
37
+ body?: unknown;
38
+ }
39
+ interface RuntimeServerPlugin {
40
+ routes(router: RuntimePluginRouter): void | Promise<void>;
41
+ dispose?(): void | Promise<void>;
42
+ }
43
+ declare function defineRuntimeServerPlugin(plugin: RuntimeServerPlugin): RuntimeServerPlugin;
44
+ declare function validateRuntimeServerPlugin(value: unknown): RuntimeServerPlugin;
45
+ declare function isRuntimePluginResponse(value: unknown): value is RuntimePluginResponse;
46
+
47
+ export { type PluginLogger, type ReadonlyHeaders, type RuntimePluginContext, type RuntimePluginHandler, type RuntimePluginResponse, type RuntimePluginRouter, type RuntimeServerPlugin, defineRuntimeServerPlugin, isRuntimePluginResponse, validateRuntimeServerPlugin };
@@ -0,0 +1,32 @@
1
+ // src/server/runtimeBackend/defineRuntimeServerPlugin.ts
2
+ function defineRuntimeServerPlugin(plugin) {
3
+ return plugin;
4
+ }
5
+ function isPlainObject(value) {
6
+ if (typeof value !== "object" || value === null) return false;
7
+ const proto = Object.getPrototypeOf(value);
8
+ return proto === Object.prototype || proto === null;
9
+ }
10
+ function validateRuntimeServerPlugin(value) {
11
+ if (!isPlainObject(value)) {
12
+ throw new Error("runtime server plugin default export must be a plain object");
13
+ }
14
+ if ("id" in value) {
15
+ throw new Error("runtime server plugin must not declare id; the host supplies plugin id from package metadata");
16
+ }
17
+ if (typeof value.routes !== "function") {
18
+ throw new Error("runtime server plugin default export must define routes(router)");
19
+ }
20
+ if (value.dispose !== void 0 && typeof value.dispose !== "function") {
21
+ throw new Error("runtime server plugin dispose must be a function when provided");
22
+ }
23
+ return value;
24
+ }
25
+ function isRuntimePluginResponse(value) {
26
+ return isPlainObject(value) && value.kind === "response";
27
+ }
28
+ export {
29
+ defineRuntimeServerPlugin,
30
+ isRuntimePluginResponse,
31
+ validateRuntimeServerPlugin
32
+ };
package/dist/server.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import { e as WorkspaceServerPluginAsset, f as BoringServerPluginManifest, B as BoringPluginFrontTargetResolver, g as BoringPluginListEntry, h as BoringPluginFrontTarget, i as BoringPluginEvent, P as PluginRestartSurface } from './createInMemoryBridge-HJopAIbo.js';
2
- export { j as BoringPluginFrontTargetResolverContext, k as BoringPluginNativeFrontTarget, l as BoringPluginNativeFrontTargetTrust, S as ServerBootstrapOptions, m as ServerBootstrapResult, a as WorkspaceProvisioningContribution, b as WorkspaceRouteContribution, W as WorkspaceServerPlugin, n as bootstrapServer, c as createInMemoryBridge, o as defineServerPlugin, v as validateServerPlugin } from './createInMemoryBridge-HJopAIbo.js';
1
+ import { f as WorkspaceServerPluginAsset, g as BoringServerPluginManifest, B as BoringPluginSourceInput, a as BoringPluginFrontTargetResolver, h as BoringPluginListEntry, i as BoringPluginFrontTarget, j as BoringPluginSource, k as BoringPluginEvent, P as PluginRestartSurface } from './createInMemoryBridge-zb8MpO60.js';
2
+ export { l as BoringPluginFrontTargetResolverContext, m as BoringPluginNativeFrontTarget, n as BoringPluginNativeFrontTargetTrust, o as BoringPluginSourceKind, S as ServerBootstrapOptions, p as ServerBootstrapResult, b as WorkspaceProvisioningContribution, c as WorkspaceRouteContribution, W as WorkspaceServerPlugin, q as bootstrapServer, d as createInMemoryBridge, r as defineServerPlugin, v as validateServerPlugin } from './createInMemoryBridge-zb8MpO60.js';
3
3
  import { FastifyRequest, FastifyInstance } from 'fastify';
4
4
  import { U as UiBridge, A as AgentTool } from './ui-bridge-DFNem0df.js';
5
5
  export { C as CommandResult, a as UiCommand, b as UiState } from './ui-bridge-DFNem0df.js';
6
6
  import { PiPackageSource } from '@hachej/boring-agent/server';
7
7
  export { PiPackageSource as WorkspacePiPackageSource } from '@hachej/boring-agent/server';
8
+ import { PluginLogger } from './runtime-server.js';
9
+ export { RuntimePluginContext, RuntimePluginHandler, RuntimePluginResponse, RuntimePluginRouter, RuntimeServerPlugin, defineRuntimeServerPlugin, validateRuntimeServerPlugin } from './runtime-server.js';
10
+ import { ErrorCode } from '@hachej/boring-agent/shared';
8
11
  import './manifest-C2vVgH_e.js';
9
12
 
10
13
  declare function definePluginAsset(importMetaUrl: string, name: string, relativeSource: string, options?: {
@@ -171,12 +174,12 @@ interface BoringPluginScanResult {
171
174
  preflight: BoringPluginPreflightResult;
172
175
  plugins: BoringServerPluginManifest[];
173
176
  }
174
- declare function scanBoringPlugins(pluginDirs: string[]): BoringPluginScanResult;
175
- declare function preflightBoringPlugins(pluginDirs: string[]): BoringPluginPreflightResult;
176
- declare function readBoringPlugins(pluginDirs: string[]): BoringServerPluginManifest[];
177
+ declare function scanBoringPlugins(pluginDirs: BoringPluginSourceInput[]): BoringPluginScanResult;
178
+ declare function preflightBoringPlugins(pluginDirs: BoringPluginSourceInput[]): BoringPluginPreflightResult;
179
+ declare function readBoringPlugins(pluginDirs: BoringPluginSourceInput[]): BoringServerPluginManifest[];
177
180
 
178
181
  interface BoringPluginAssetManagerOptions {
179
- pluginDirs: string[];
182
+ pluginDirs: BoringPluginSourceInput[];
180
183
  /**
181
184
  * Root directory for per-plugin `.error` sidecar files written by the
182
185
  * asset manager and read by verify-plugin. Defaults to `<cwd>/.pi/extensions`.
@@ -212,6 +215,8 @@ interface LoadedBoringPluginInspection {
212
215
  rootDir: string;
213
216
  frontPath?: string;
214
217
  frontTarget?: BoringPluginFrontTarget;
218
+ serverPath?: string;
219
+ source: BoringPluginSource;
215
220
  }
216
221
  interface LoadedBoringPluginPiSnapshot {
217
222
  additionalSkillPaths: string[];
@@ -253,14 +258,6 @@ declare class BoringPluginAssetManager {
253
258
  private clearError;
254
259
  }
255
260
 
256
- interface PluginReloadRebuild {
257
- ok: boolean;
258
- diagnostics: {
259
- source: string;
260
- message: string;
261
- pluginId?: string;
262
- }[];
263
- }
264
261
  /**
265
262
  * One per plugin whose load event carried a non-empty
266
263
  * `requiresRestart` field. Surfaced alongside the /reload response so
@@ -281,16 +278,6 @@ interface PluginRestartWarning {
281
278
  declare function collectRestartWarnings(events: BoringPluginEvent[]): PluginRestartWarning[];
282
279
  interface BoringPluginRoutesOptions {
283
280
  manager: BoringPluginAssetManager;
284
- /**
285
- * Server-side plugin rebuild closure (jiti re-import of dir-source
286
- * entries). Called AFTER the asset manager scan. Per-plugin failures
287
- * surface as diagnostics; combined with asset-manager errors into the
288
- * 422 response body so the agent's /reload UI can show them. Optional —
289
- * tests that exercise the route in isolation can omit it.
290
- */
291
- rebuildPlugins?: () => Promise<PluginReloadRebuild>;
292
- /** Register the developer reload endpoint. Static discovery/listing remains available when false. */
293
- enableReloadRoute?: boolean;
294
281
  }
295
282
  declare function boringPluginRoutes(app: FastifyInstance, opts: BoringPluginRoutesOptions): Promise<void>;
296
283
 
@@ -327,4 +314,55 @@ declare function pluginFileSignature(path: string | undefined): string;
327
314
  declare function writePluginSignatureCache(pluginRootDir: string, payload: Omit<PluginSignatureCachePayload, "version" | "loadedAt"> & Partial<Pick<PluginSignatureCachePayload, "loadedAt">>): void;
328
315
  declare function readPluginSignatureCache(pluginRootDir: string): PluginSignatureCachePayload | null;
329
316
 
330
- export { BoringPluginAssetManager, BoringPluginEvent, BoringPluginFrontTarget, BoringPluginFrontTargetResolver, BoringPluginListEntry, type BoringPluginScanResult, BoringServerPluginManifest, type PluginReloadRebuild, type PluginRestartWarning, UiBridge, type UiRoutesOptions, WorkspaceServerPluginAsset, aggregatePluginPrompts, boringPluginRoutes, buildBoringSystemPrompt, collectRestartWarnings, createExecUiTool, createGetUiStateTool, createWorkspaceUiTools, definePluginAsset, pluginFileSignature, preflightBoringPlugins, readBoringPlugins, readPluginSignatureCache, resolvePluginAssetPath, scanBoringPlugins, uiRoutes, writePluginSignatureCache };
317
+ interface RuntimeBackendDiagnostic {
318
+ pluginId?: string;
319
+ source: string;
320
+ code: ErrorCode;
321
+ message: string;
322
+ }
323
+ interface RuntimeBackendReloadResult {
324
+ ok: boolean;
325
+ diagnostics: RuntimeBackendDiagnostic[];
326
+ }
327
+ interface RuntimeBackendDispatchRequest {
328
+ pluginId: string;
329
+ method: string;
330
+ path: string;
331
+ query: URLSearchParams;
332
+ headers: Headers;
333
+ signal: AbortSignal;
334
+ body: unknown;
335
+ logger: PluginLogger;
336
+ workspaceId?: string;
337
+ }
338
+ interface RuntimeBackendDispatchResponse {
339
+ status: number;
340
+ headers: Record<string, string>;
341
+ body?: unknown;
342
+ }
343
+ declare class RuntimeBackendError extends Error {
344
+ readonly code: ErrorCode;
345
+ readonly statusCode: number;
346
+ readonly details?: Record<string, unknown> | undefined;
347
+ constructor(code: ErrorCode, statusCode: number, message: string, details?: Record<string, unknown> | undefined);
348
+ }
349
+ declare class RuntimeBackendRegistry {
350
+ private readonly snapshots;
351
+ private lastDiagnostics;
352
+ private reloadQueue;
353
+ getDiagnostics(): RuntimeBackendDiagnostic[];
354
+ listPluginIds(): string[];
355
+ reloadFromLoadedPlugins(plugins: LoadedBoringPluginInspection[]): Promise<RuntimeBackendReloadResult>;
356
+ close(): Promise<RuntimeBackendReloadResult>;
357
+ dispatch(request: RuntimeBackendDispatchRequest): Promise<RuntimeBackendDispatchResponse>;
358
+ private reloadOnce;
359
+ private closeOnce;
360
+ }
361
+
362
+ interface RuntimeBackendGatewayOptions {
363
+ registry: RuntimeBackendRegistry;
364
+ defaultWorkspaceId?: string;
365
+ }
366
+ declare function runtimeBackendGateway(app: FastifyInstance, opts: RuntimeBackendGatewayOptions): Promise<void>;
367
+
368
+ export { BoringPluginAssetManager, BoringPluginEvent, BoringPluginFrontTarget, BoringPluginFrontTargetResolver, BoringPluginListEntry, type BoringPluginScanResult, BoringPluginSource, BoringPluginSourceInput, BoringServerPluginManifest, type PluginRestartWarning, type RuntimeBackendDiagnostic, type RuntimeBackendDispatchRequest, type RuntimeBackendDispatchResponse, RuntimeBackendError, type RuntimeBackendGatewayOptions, RuntimeBackendRegistry, type RuntimeBackendReloadResult, UiBridge, type UiRoutesOptions, WorkspaceServerPluginAsset, aggregatePluginPrompts, boringPluginRoutes, buildBoringSystemPrompt, collectRestartWarnings, createExecUiTool, createGetUiStateTool, createWorkspaceUiTools, definePluginAsset, pluginFileSignature, preflightBoringPlugins, readBoringPlugins, readPluginSignatureCache, resolvePluginAssetPath, runtimeBackendGateway, scanBoringPlugins, uiRoutes, writePluginSignatureCache };