/** * Pi Hook Pipeline — `src/platform/adapters/pi/hook-pipeline.ts` * * Constructs the full HookDeps for the Pi platform and routes every canonical * event emitted by the PiEventBridge through the shared event handler * (`src/hooks/event-handler.ts`), mirroring how hook-service.ts wires the * opencode platform: * * - `session` = the Pi notification-wrapped session client * - `roleFunctionsMap` / `roleMap` = derived from the * resolved roles (roleFunctionsMap is the module-scope map shared with * pi-extension.ts) * - `dir` = process.cwd() on Pi * - `dispatchManager` / `loopManager` = the live Pi instances * - `customHooks` = CustomHookRegistry populated from each role's * `config.hooks.custom` declarations (hook-service.ts:92-100 pattern) * - `notificationManager` = the S3-wired Pi NotificationManager * - `builtInHooks` = omitted (the recovery/built-in engine is * opencode-only) * * The persistent stores (functionRuntime, sessionSignalLedger) are pointed at * `dir` and recovered exactly as hook-service.ts:59-66 does, so function and * signal state survives restarts on the Pi platform. * * Because the pipeline subscribes with `PiEventBridge.on()` (a general * handler), it receives every emitted canonical event — including the * synthetic `session.status` events produced by wirePiSessionStatusEvents and * the adapter's `session.idle`/`session.status` emissions. The five ad-hoc * dispatchManager bridge handlers previously wired in pi-extension.ts * (session.idle/status/error/deleted/message.updated) are therefore removed: * `handleEvent` is the single dispatch path, preventing double-handling. * * @module */ import { HookState } from "../../../hooks/state.ts"; import type { HookDeps } from "../../../hooks/deps.ts"; import type { CanonicalEvent } from "../../../platform/types.ts"; import type { ISessionClient } from "../../../platform/ports/session-client.ts"; import type { DispatchManager } from "../../../dispatch/core/manager.ts"; import type { LoopCoordinator } from "../../../loop/coordinator.ts"; import type { NotificationManager } from "../../../notifications/manager.ts"; import type { ResolvedFunction, ResolvedRole } from "../../../types.ts"; import type { PiEventBridge } from "./event-bridge.ts"; export interface PiHookPipelineOptions { /** Canonical bridge whose emitted events route into handleEvent. */ eventBridge: PiEventBridge; /** Session client — the Pi notification-wrapped process adapter. */ session: ISessionClient; /** Resolved roles (source of roleFunctionsMap/roleMap and custom hooks). */ resolvedRoles: ResolvedRole[]; /** Shared role → functions map (the module-scope map from pi-extension.ts). */ roleFunctionsMap: Map; /** Live DispatchManager (completion pipeline). */ dispatchManager: DispatchManager; /** Live LoopCoordinator (loop phase suppression for continuations). */ loopManager: LoopCoordinator; /** S3-wired Pi NotificationManager, if notifications are enabled. */ notificationManager?: NotificationManager; /** * The shared GraphToolSet in-flight query surface (subtask 2) — the SAME * instance backing the `graph_*` tools (exposed by * `PiLightweightServiceStack.getGraphToolSet()`). Lets the auto-continue * path ask whether the invoking session still owns executing graphs before * continuing (same registry as graph_run). Optional for backward * compatibility — absent when the stack was built without a dispatch * manager (no graph tools either). */ graphTools?: HookDeps["graphTools"]; /** * Resolved subagent registry for the copilot LLM-role verdict source * (src/copilot/llm.ts). Threaded from pi-extension's buildSubagentLineage. * Optional — absent → the LLM verdict source is skipped (builtin + rules * still run). */ resolvedSubagents?: Map; /** State persistence directory (process.cwd() on Pi). */ dir: string; } export interface PiHookPipeline { /** The assembled dependency object consumed by the event handlers. */ deps: HookDeps; /** Hook-owned session state (pendingCorrections, sessionAgentRegistry, …). */ state: HookState; /** * Route a single canonical event through the full pipeline. This is what * the bridge subscription invokes; also exposed for direct callers/tests. */ handleEvent: (event: CanonicalEvent) => Promise; /** Remove the bridge subscription (call during shutdown). */ unsubscribe: () => void; /** Dispose the custom-hook registry (call during shutdown). */ dispose: () => Promise; } /** * Build the Pi hook pipeline: wire persistent stores + recovery, assemble the * full HookDeps, populate the custom-hook registry, and subscribe the event * bridge so every emitted canonical event flows through handleEvent. */ export declare function createPiHookPipeline(options: PiHookPipelineOptions): Promise; //# sourceMappingURL=hook-pipeline.d.ts.map