/** * PI session-lifecycle wiring: `session_start`, `session_shutdown`, and * `session_before_switch` handlers, plus the dedupe tombstone that absorbs * the duplicate session.deleted PI emits for the same logical /new, /resume, * /fork transition. * * Extracted from `adapter.ts` as part of the P0/P1 refactor; behaviour is * unchanged and the registration order matches the original adapter. */ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { getPiHooksLogger } from "../core/logger.js"; import type { HooksRuntime } from "../core/runtime.js"; export interface SessionLifecycleDeps { /** Returns the runtime for `cwd`, lazily constructing it on first use. */ getRuntimeFor(cwd: string): HooksRuntime; /** Records the freshest ExtensionContext for this cwd. */ rememberContext(cwd: string, ctx: ExtensionContext): void; /** Logger reference (already constructed by the caller). */ logger: ReturnType; /** Shared dispatch-failure reporter for adapter handlers. */ reportDispatchFailure(logger: ReturnType, context: { cwd: string; event: string; sessionId?: string; details?: Record; }, error: unknown): void; } /** * Install `session_start`, `session_shutdown`, and `session_before_switch` * handlers on the given `pi`. Returns nothing — registration is the side * effect. */ export declare function installSessionLifecycleHandlers(pi: ExtensionAPI, deps: SessionLifecycleDeps): void;