import { PiClientEventBody, PiContextUsage, PiModelInfo, PiRuntimeReadiness, PiThreadMetadata, PiThreadStatus, PiTranscriptMessage } from "../types.js"; import { AgentSessionEvent, ModelRegistry, SessionEntry, SessionInfo } from "@earendil-works/pi-coding-agent"; //#region src/node/mapping.d.ts /** A model as the `ModelRegistry` reports it (a Pi `Model`), derived from the * SDK so this module names it only at the type boundary. */ export type PiRegistryModel = ReturnType[number]; /** * The real Pi `AgentMessage` / `AssistantMessageEvent`, derived from the event * union so we depend only on the declared `@earendil-works/pi-coding-agent` * package (not its transitive `pi-agent-core` / `pi-ai`). */ type PiSdkMessage = Extract["message"]; /** Cast a real Pi message into the mirror. The shapes are structurally faithful * (verified), so this is a type-boundary identity — never a conversion. */ export declare const toPiMessage: (message: PiSdkMessage) => PiTranscriptMessage; export declare const toPiMessages: (messages: readonly PiSdkMessage[]) => PiTranscriptMessage[]; /** * Map Pi's session-level event stream (`AgentSession.subscribe`) onto the * JSON-safe `PiClientEventBody`. `agent_start` / `tool_execution_*` / `message_*` * carry through unchanged; the variants Pi renamed or enriched are normalized * here. `turn_start` / `turn_end` carry no index in the SDK — the supervisor * derives and passes one via `ctx.turnIndex`. * * Note: `error`, `context_usage`, and `extension_ui_request` / `_resolved` are * NOT in this stream — the supervisor synthesizes them (from caught errors, * `getContextUsage()`, and the extension-UI bridge respectively). */ export declare const mapSessionEvent: (event: AgentSessionEvent, ctx: { turnIndex: number; }) => PiClientEventBody; /** Map a `SessionManager` catalog entry onto thread-list metadata. Live status * (from the supervisor's running records) is merged over the catalog default. */ export declare const mapSessionInfo: (info: SessionInfo, opts?: { liveStatus?: PiThreadStatus; }) => PiThreadMetadata; /** * Derive model/credential readiness. Only the two cheaply-knowable states are * surfaced: a model is selected (`ready`) or none is (`missing-model`). * `missing-credentials` / `unavailable-model` are detected lazily when a send * fails and routed into `lastError` — we do not probe the provider eagerly. */ export declare const deriveReadiness: (input: { model?: { provider: string; id: string; } | undefined; source?: "env" | "session" | "pi-default"; }) => PiRuntimeReadiness; /** Map a registry model onto the JSON-safe `PiModelInfo`. */ export declare const mapModelInfo: (model: PiRegistryModel) => PiModelInfo; /** The readonly view a `SessionManager` exposes for a cold (non-live) thread. */ export type ReadonlySessionContext = { messages: readonly unknown[]; thinkingLevel: string; model: { provider: string; modelId: string; } | null; }; /** Latest session name from the branch (newest `session_info` entry wins). */ export declare const latestSessionName: (branch: readonly SessionEntry[]) => string | undefined; /** Readiness for a cold thread, from its persisted model selection. */ export declare const readinessFromSessionContext: (context: Pick) => PiRuntimeReadiness; /** * Metadata for a cold (non-live) thread, derived from its session file. The * supervisor injects what only it can know: whether the file is archived, and * the context usage (which needs the model registry's context window). */ export declare const mapReadonlyMetadata: (info: SessionInfo, branch: readonly SessionEntry[], context: ReadonlySessionContext, opts: { archived: boolean; contextUsage?: PiContextUsage | undefined; }) => PiThreadMetadata; //#endregion //# sourceMappingURL=mapping.d.ts.map