// Test-only auxiliary extension. // // The owned fixture can only path-load extensions, so the contract test's inline // footer/producer factories are reproduced here as a single extension that // forwards the shared event bus and session lifecycle to hooks the contract // test installs on `globalThis`. This keeps every observed interaction on real // public Pi APIs (`pi.events`, `pi.on`, `ctx.ui`) without reaching fixture or // runner internals. import type { ExtensionAPI, ExtensionContext, } from "@earendil-works/pi-coding-agent"; export type ProbeHooks = { onFooterSegment?: (data: unknown) => void; onSessionStart?: (ctx: ExtensionContext, pi: ExtensionAPI) => void; }; function hooks(): ProbeHooks | undefined { return (globalThis as { __modelInfoProbe?: ProbeHooks }).__modelInfoProbe; } export default function probeExtension(pi: ExtensionAPI): void { pi.events.on("footer:segment", (data: unknown) => { hooks()?.onFooterSegment?.(data); }); pi.on("session_start", (_event, ctx) => { hooks()?.onSessionStart?.(ctx, pi); }); }