import { MAX_COMPOSER_IMAGE_BYTES, MAX_COMPOSER_TEXT_BYTES, validateComposerCapture } from "../lib/composerCapture.mjs"; import { ComposerCapture, TransientTab, WebPluginContextItem } from "@agimon-ai/po-core/web"; import { Store } from "@tanstack/store"; //#region src/web/stores/composerStore.d.ts export interface ComposerImageAttachment { id: string; kind: 'image'; name: string; size: number; dataUrl: string; data: string; mimeType: string; /** Where the host stored a copy, when the best-effort upload succeeded. */ path?: string; } export interface ComposerTextAttachment { id: string; kind: 'text'; name: string; size: number; content: string; /** Where the host stored a copy, when the best-effort upload succeeded. */ path?: string; } /** Any other file: stored on the host and referenced by path, never inlined. */ export interface ComposerFileAttachment { id: string; kind: 'file'; name: string; size: number; mimeType: string; path: string; } export interface ComposerContextAttachment { id: string; kind: 'context'; name: string; size: number; content: string; source: string; contextId: string; contextKind: string; url?: string; } export type ComposerAttachment = ComposerContextAttachment | ComposerFileAttachment | ComposerImageAttachment | ComposerTextAttachment; export declare const MAX_COMPOSER_ATTACHMENTS = 8; export declare const MAX_COMPOSER_TOTAL_IMAGE_BYTES: number; export declare const MAX_COMPOSER_TOTAL_TEXT_BYTES: number; /** The host's upload limit for one stored attachment. */ export declare const MAX_COMPOSER_UPLOAD_BYTES: number; /** Bytes counted against the inline text budget: stored files and images travel separately. */ export declare function inlineTextBytes(attachments: ComposerAttachment[]): number; export interface ComposerSessionState { draft: string; caret: number; dismissedToken: number | null; attachments: ComposerAttachment[]; attachmentError: string; nextAttachmentId: number; /** File batches still being read or uploaded; sending waits until they are staged. */ pendingAttachments: number; } /** Browser-only composer state, retained independently for each live session. */ export declare const composerStore: Store>, never>; export declare function useComposerState(sessionId: string | null): ComposerSessionState; export declare function updateComposerState(sessionId: string | null, update: (state: ComposerSessionState) => ComposerSessionState): void; /** Appends non-empty text to the latest draft for one session. */ export declare function appendComposerDraft(sessionId: string | null, text: string): void; /** Empties one session's draft and returns what it held. */ export declare function takeComposerDraft(sessionId: string | null): string; /** The open tab's context for one message. Slash commands, invalid items and failing reads send without it. */ export declare function tabComposerContext(read: TransientTab['composerContext'], sessionId: string, draft: string): WebPluginContextItem | undefined; /** Adds structured plugin context without changing the visible composer draft. */ export declare function attachComposerContext(sessionId: string | null, item: WebPluginContextItem): void; /** * Stages a capture as one image and one context chip in a single store update. * Nothing is transported until the reader explicitly submits or queues it. */ export declare function attachComposerCapture(sessionId: string | null, capture: ComposerCapture): void; /** Adds message text as a Markdown blockquote and leaves the caret ready for an instruction. */ export declare function appendComposerQuote(sessionId: string | null, text: string): number | null; /** Empties the composer but keeps the id counter and pending batches, so a batch still uploading lands with a fresh id. */ export declare function clearComposerState(sessionId: string | null): void; /** A session that left takes its unfinished composer state with it. */ export declare function dropComposerState(sessionId: string): void; /** * Holds unsent text across a reload the person did not ask for. * * A verified bundle update reloads the page underneath whoever is typing, so * the text has to outlive the document. Only the draft and the caret travel: * attachments carry base64 image payloads that would not fit a storage quota, * and re-attaching a file is a smaller loss than losing a written message. */ export declare function saveComposerDrafts(): void; /** Seeds the store from the last save, then forgets it so a later reload starts clean. */ export declare function restoreComposerDrafts(): void; /** Test seam. */ export declare function resetComposerStore(): void; //#endregion export { MAX_COMPOSER_IMAGE_BYTES, MAX_COMPOSER_TEXT_BYTES, validateComposerCapture }; //# sourceMappingURL=composerStore.d.mts.map