import type { FileAsset, NewSessionDraft, NewSessionSelectionHistory, OpenGeniClient, ResourceRef, SaveNewSessionDraftRequest } from "@opengeni/sdk"; export type NewSessionDraftEditable = Omit; export type UseNewSessionDraftOptions = { workspaceId: string; client: Pick; /** The complete browser-visible value. It must contain ready file refs only. */ value: NewSessionDraftEditable; /** Apply a remote value to the controlled text/model/tool/options state. */ onApplyRemote: (value: NewSessionDraftEditable, selectionHistory: NewSessionSelectionHistory) => void; /** Replace finalized attachments with freshly revalidated server assets. */ restoreReadyFiles: (files: Iterable) => void; /** Revalidate non-file resource identities against the current UI catalog. */ hydrateResources?: (resources: ResourceRef[]) => ResourceRef[] | Promise; /** Keep the first read pending until catalogs needed for hydration are ready. */ resourceHydrationReady?: boolean; /** A create in flight owns the exact clicked snapshot; resume autosave on settlement. */ suspendAutosave?: boolean; /** Test seam for the quiet retry backoff and the background reconnect pace. */ transientRetry?: { delaysMs?: readonly number[]; reconnectIntervalMs?: number; }; }; export type FlushedNewSessionDraft = { revision: number; /** Signature of the exact local snapshot acknowledged by this revision. */ signature: string; }; export type AcknowledgeConsumedNewSessionDraftResult = { kind: "consumed"; } | { kind: "preserved"; flushed: FlushedNewSessionDraft; }; export type UseNewSessionDraftResult = { draft: NewSessionDraft | null; revision: number; loading: boolean; saving: boolean; conflict: Error | null; error: Error | null; /** * `error` only says Opengeni was briefly unreachable (a deploy or database * restart). Show the calm updating notice instead of the error; the hook * keeps reconnecting in the background and clears this on success. */ unavailable: boolean; /** The latest failure, readable right after an awaited call (state lags a render). */ currentError: () => Error | null; /** Mark Opengeni unreachable after a transient failure elsewhere in the send path. */ reportUnavailable: (cause: unknown) => boolean; flush: () => Promise; /** Send the visible snapshot, rebasing a stale draft revision without replacing the composer. */ flushForSend: (snapshot?: NewSessionDraftEditable) => Promise; isCurrentSignature: (signature: string) => boolean; /** * Fence the exact acknowledged snapshot after session creation consumes it, * preserving a genuinely newer local value against the safe-seed row. */ acknowledgeConsumed: (flushed: FlushedNewSessionDraft, visibleSignature?: string) => Promise; reload: () => Promise; /** Surface a create-time OCC rejection through the ordinary draft recovery UI. */ captureConflict: (cause: unknown) => boolean; resolveConflict: (choice: "keep_mine" | "use_remote") => Promise; clearError: () => void; }; /** * Actor-private, server-authoritative state for the composer shown before a * session exists. Reads and writes are fenced to one client/workspace target; * writes serialize and acquire the latest acknowledged revision at execution * time, so a stale closure can never invent its own OCC base. */ export declare function useNewSessionDraft(options: UseNewSessionDraftOptions): UseNewSessionDraftResult; export declare function isNewSessionDraftConflict(cause: unknown): boolean;