import type { ImageContent } from "@earendil-works/pi-ai"; import type { QueuedMessage, QueueLane } from "./queue-state.ts"; import type { QueueModes } from "./queue-policy.ts"; export declare const QUEUE_PROTOCOL_VERSION: 1; export declare const QUEUE_CONTROL_EVENT = "queue-steer:control:v1"; export type QueueRow = QueuedMessage; export type DispatchOutcome = "accepted" | "completed" | "rejected" | "uncertain"; export type QueueBoundary = "idle" | "turn-end" | "agent-end" | "settled"; export interface RowPatch { text?: string; images?: ImageContent[]; lane?: QueueLane; paused?: boolean; removed?: boolean; } export type QueueOperation = { type: "snapshot"; } | { type: "enqueue"; lane: QueueLane; text: string; images?: ImageContent[]; paused?: boolean; tail?: boolean; } | { type: "edit-begin" | "edit-select"; id: string; } | { type: "edit-patch"; patch: RowPatch; } | { type: "edit-save" | "edit-cancel"; } | { type: "remove"; id: string; } | { type: "reorder"; id: string; direction: -1 | 1; } | { type: "lane"; id: string; lane: QueueLane; } | { type: "hold"; id: string; paused: boolean; } | { type: "pause" | "resume" | "graceful-pause" | "cancel-gate"; }; export interface QueueRequest { version: 1; requestId: string; expectedRevision?: number; operation: QueueOperation; } export interface QueueCheckpoint { version: 1; sessionId: string; revision: number; rows: QueueRow[]; identity: { nextIdNumber: number; nextSequence: number; }; /** Reserved rows are still in rows; never prepend them again on restore. */ uncertainRowIds: string[]; } export interface QueueView extends QueueCheckpoint { paused: boolean; errorHold: boolean; modes: QueueModes; editing?: { selectedId: string; rows: (QueueRow & { removed: boolean; })[]; }; inFlight?: { attemptId: string; rowIds: string[]; }; compaction?: "manual" | "threshold" | "overflow"; gracefulPausePending: boolean; } export type QueueReply = { version: 1; requestId: string; snapshot: QueueView; } & ({ ok: true; } | { ok: false; error: string; }); export interface QueueEvent { version: 1; type: "snapshot" | "dispatch"; snapshot: QueueView; ack?: { attemptId: string; rowId: string; outcome: DispatchOutcome; error?: string; }; } export declare function isQueueImages(v: unknown): v is ImageContent[]; export declare function readQueueRequest(value: unknown): QueueRequest | undefined; export declare function isQueueCheckpoint(v: unknown): v is QueueCheckpoint;