/** * PI HostAdapter implementation. Provides the runtime-facing surface that the * core hooks runtime calls into for bash execution, follow-up prompts, UI * notifications, confirmations, and status updates. * * Extracted from the original `adapter.ts` as part of the P0/P1 refactor; the * behaviour is unchanged and the public symbol (`createHostAdapter`) is still * re-exported through `./adapter.ts` so existing import sites continue to work. */ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { HostAdapter } from "../core/types.js"; /** * P3-2: prefer the SDK's `ReadonlySessionManager` shape via the canonical * accessor on `ExtensionContext`. The SDK defines `ReadonlySessionManager` * in `core/session-manager.ts` but does not re-export it from the package * root, and `package.json#exports` blocks deep subpath imports under * `moduleResolution: "NodeNext"`. Indexing `ExtensionContext["sessionManager"]` * is the SDK's only public surface for this type, so we use it directly * rather than maintain a hand-rolled `Pick` mirror. */ export type ReadonlySessionManager = ExtensionContext["sessionManager"]; export interface HostAdapterOptions { readonly scheduleDeadline?: (callback: () => void, delayMs: number) => () => void; } export declare function createHostAdapter(pi: ExtensionAPI, projectDir: string, getSessionManager: () => ReadonlySessionManager | undefined, getContext: () => ExtensionContext | undefined, options?: HostAdapterOptions): HostAdapter; /** * Read a session id from a (possibly missing) PI `ReadonlySessionManager`, * tolerating both throws and empty strings. Used by the adapter handlers and * the host adapter's `sendPrompt` to detect session replacement. */ export declare function safeGetSessionId(sessionManager: ReadonlySessionManager | undefined): string | undefined; /** * Heuristic detection of stale-session errors emitted by the PI SDK when an * extension uses a captured `ctx`/`pi` after `newSession`/`fork`/`switchSession`/`reload`. * Pinned by `adapter.test.ts` against known SDK error messages so it does not * silently drift if the SDK rewrites the wording (P2-9). */ export declare function isStaleSessionBoundError(error: unknown): boolean; export declare function debugLog(message: string): void;