Repository Public
1/**2 * Runtime plugin registry. `main.ts` (runtime-core) builds the Fastify instance (unix socket,3 * bearer-token auth hook, @fastify/websocket, error handler producing `{error:{code,message}}`)4 * and then registers every plugin listed here with `{ config }`.5 *6 * runtime-core owns: sessions, tasks, hooks, events, metrics (+ /health)7 * runtime-fs owns: fs, git, claude, skills, mcp8 *9 * Each module default-exports a `RuntimePlugin`. Keep modules independent of each other;10 * shared helpers live in `paths.ts` (runtime-fs) and `tmux.ts` (runtime-core).11 */12import type { FastifyInstance } from 'fastify';13import type { RuntimeConfig } from './config.js';1415export interface RuntimePluginOptions {16 config: RuntimeConfig;17}18export type RuntimePlugin = (app: FastifyInstance, opts: RuntimePluginOptions) => Promise<void>;1920/** Thrown anywhere in a handler; the error handler maps it to an HTTP status + `{error}` body. */21export class RtError extends Error {22 constructor(23 public readonly status: number,24 public readonly code: string,25 message: string,26 ) {27 super(message);28 }29}3031export async function loadPlugins(): Promise<RuntimePlugin[]> {32 const mods = await Promise.all([33 import('./sessions.js'),34 import('./tasks.js'),35 import('./hooks.js'),36 import('./events.js'),37 import('./metrics.js'),38 import('./fs.js'),39 import('./git.js'),40 import('./claude.js'),41 import('./skills.js'),42 import('./mcp.js'),43 ]);44 return mods.map((m) => m.default as RuntimePlugin);45}46