import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import type { ServerFrame, TimelineEvent } from "../protocol/v2/index.js"; import type { Correlation, TimelineStarted } from "./runtime.js"; import type { TimelineV2Service } from "./v2_service.js"; export declare const USER_DELIVERY_START_TIMEOUT_MS = 30000; export declare const MAX_USER_DELIVERY_ENTRIES = 32; export declare const MAX_USER_DELIVERY_BYTES: number; type UserMessageContent = Parameters[0]; type UserMessageOptions = Parameters[1]; export type QueuedMessageItem = Extract["items"][number]; export type UserDeliveryPayload = Readonly<{ text: string; images?: readonly Readonly<{ data: string; mime: string; }>[]; }>; export type UserDeliveryScope = { readonly ownerId: string; readonly sessionId: string; readonly generation: string; readonly service: TimelineV2Service; readonly clientRequestId: string; readonly deliveryToken: string; }; export type UserDeliveryScopeInput = Omit; export type UserDeliveryEnqueueResult = "queued" | "duplicate" | "conflict" | "rejected" | false; export type UserDeliverySteerResult = { kind: "sent"; scope: UserDeliveryScope; } | { kind: "failed"; scope: UserDeliveryScope; } | { kind: "missing"; }; export type UserDeliveryQueueOptions = { isIdle: () => boolean; isCurrent: (scope: UserDeliveryScope) => boolean; send: (content: UserMessageContent, correlation: Correlation, options?: UserMessageOptions) => void; onUnknownDelivery: (scope: UserDeliveryScope) => void; onQueueChanged?: (scope: UserDeliveryScope) => void; canQueueItem?: (scope: UserDeliveryScopeInput, item: QueuedMessageItem) => boolean; clock?: () => number; startTimeoutMs?: number; maxEntries?: number; maxBytes?: number; }; export declare class UserDeliveryQueue { private readonly isIdle; private readonly isCurrent; private readonly send; private readonly onUnknownDelivery; private readonly onQueueChanged?; private readonly canQueueItem; private readonly clock; private readonly startTimeoutMs; private readonly maxEntries; private readonly maxBytes; private readonly jobs; private queue; private lateTokens; private active; private scheduled; private queuedPayloadCount; private queuedPayloadBytes; constructor(options: UserDeliveryQueueOptions); enqueue(content: UserMessageContent, correlation: Correlation, scope: UserDeliveryScopeInput, payload?: UserDeliveryPayload): UserDeliveryEnqueueResult; snapshot(ownerId: string, service: TimelineV2Service): QueuedMessageItem[]; clearQueued(ownerId: string, service: TimelineV2Service, targetId?: string): UserDeliveryScope[]; steer(ownerId: string, service: TimelineV2Service, targetId: string): UserDeliverySteerResult; scheduleDrain(): void; onUserStarted(started: TimelineStarted): UserDeliveryScope | null; onUserPublished(event: TimelineEvent, correlation: Correlation): UserDeliveryScope | null; clearOwner(ownerId: string, service?: TimelineV2Service): void; clearAll(): void; private drain; private startTimer; private failBeforeStart; private trimLateRecords; private clearWhere; private rescheduleAfterMutation; private findTarget; private matches; private itemFor; private jobFor; private isCurrentScope; private releasePayload; private clearTimer; private remove; private notifyQueueChanged; private cancelScheduledDrain; } export {};