import type { ImageAttachmentReference, StoredImageAttachment } from '../../shared/types/image-attachments.js'; import type { InteractiveModeResult } from './interactive.js'; import type { ImagePasteHandler } from './inlineImagePaste.js'; export type InteractiveImageAttachment = StoredImageAttachment; export interface ImageAttachmentStore { saveImage(data: Buffer, mimeType: string): Promise; listAttachments(): InteractiveImageAttachment[]; cleanup(): void; /** * Stop accepting images. A capture that was still running when the run ended * would otherwise write its file after the owner enumerated and cleaned up, * leaving a temp file behind; already saved images are untouched. */ seal(): void; } export interface ImageAttachmentCleanupOwner { cleanupAttachments?: () => void; } export interface ImageAttachmentStoreOptions { tmpRoot: string; sessionId: string; initialAttachments?: readonly InteractiveImageAttachment[]; initialAttachmentIndex?: number; } export declare function cleanupImageAttachmentStore(attachmentStore: ImageAttachmentStore): void; /** * Cleans the store up if the process ends before its owner can. * * A readline selector ends the process itself when the user interrupts it * (`shared/prompt/select.ts` calls `process.exit(130)`), so a run that is * waiting on one never reaches its own teardown and the files a paste left in * the temp directory would survive it. `exit` handlers can only do synchronous * work, which is exactly what sealing and removing the directory need. * * Returns the release for the owner to call once it has taken the files back. */ export declare function cleanupImageAttachmentStoreOnProcessExit(attachmentStore: ImageAttachmentStore): () => void; export declare function attachImageAttachmentCleanup(result: T, cleanupAttachments: (() => void) | undefined): T & ImageAttachmentCleanupOwner; export declare function cleanupInteractiveResultAttachments(result: ImageAttachmentCleanupOwner): void; export declare function buildInteractiveResultWithAttachments(result: InteractiveModeResult, attachmentStore: ImageAttachmentStore, attachmentsOverride?: readonly InteractiveImageAttachment[]): InteractiveModeResult; export declare function createImageAttachmentStore(options: ImageAttachmentStoreOptions): ImageAttachmentStore; /** * A pasted image has to be readable by the provider that is asked to look at * it, and a provider that sandboxes its file access can only reach the project * it was pointed at — the OS temp directory is outside every such sandbox. The * files therefore live under the project's own `.takt/`, which `.takt/.gitignore` * already keeps out of version control, and are deleted when the run ends. */ export declare function createSessionImageAttachmentStore(cwd: string, initialAttachments?: readonly InteractiveImageAttachment[], initialAttachmentIndex?: number): ImageAttachmentStore; export declare function createImagePasteHandler(attachmentStore: ImageAttachmentStore): ImagePasteHandler; export declare function createClipboardImagePasteHandler(attachmentStore: ImageAttachmentStore): (abortSignal?: AbortSignal) => Promise; export declare function resolvePromptImageAttachments(prompt: string, attachments: readonly InteractiveImageAttachment[]): ImageAttachmentReference[]; //# sourceMappingURL=imageAttachments.d.ts.map