import { PiAgentMessage, PiClientEvent, PiContextUsage, PiHostUiRequest, PiRuntimeReadiness, PiThreadMetadata } from "../types.js"; //#region src/runtime/threadState.d.ts export type PiRunStatus = "idle" | "running" | "failed"; export type PiLoadState = "pending" | "loading" | "loaded"; export interface PiToolExecutionState { toolCallId: string; toolName?: string; args?: unknown; /** Latest streaming partial result (same shape as the final tool result: * `{ content: [{ type: "text", text }], details? }`). Superseded by the * `toolResult` message once it lands in the transcript. */ partialResult?: unknown; status: "running" | "complete" | "error"; } export interface PiThreadState { threadId: string; metadata: PiThreadMetadata; /** Canonical transcript — source of truth for projection. */ messages: readonly PiAgentMessage[]; /** Index into `messages` of the assistant message currently streaming, or * `undefined` when not streaming. */ streamingMessageIndex: number | undefined; /** Live streaming tool output, keyed by `toolCallId`. */ toolExecutions: Readonly>; runStatus: PiRunStatus; queue: { steering: readonly string[]; followUp: readonly string[]; }; contextUsage: PiContextUsage | undefined; compaction: { active: boolean; reason?: "manual" | "threshold" | "overflow"; }; retry: { active: boolean; attempt: number; }; /** Pending blocking host-UI requests (Pi's approval surface). */ hostUiRequests: readonly PiHostUiRequest[]; readiness: PiRuntimeReadiness | undefined; lastError: string | undefined; loadState: PiLoadState; /** Monotonic seq of the last applied event (for ordering/dedup). */ lastSeq: number; } export declare const createPiThreadState: (threadId: string) => PiThreadState; export declare const removeHostUiRequest: (state: PiThreadState, requestId: string) => PiThreadState; /** * Apply a single client event. Pure: returns a new state (or the same reference * when nothing changed). Non-snapshot events older than `lastSeq` are ignored; * snapshots always apply (they are authoritative). */ export declare const reducePiThreadState: (state: PiThreadState, event: PiClientEvent) => PiThreadState; //#endregion //# sourceMappingURL=threadState.d.ts.map