/** * One path from finished bytes to a conversation attachment plus a workspace * file, shared by every image source (ComfyUI, HTML render, SVG render). * * Keeping this in one place is what makes a rendered PNG indistinguishable * from a generated one: same attachment store, same workspace folder, same * provenance line, same save-failure behaviour. * * @module dsh-arya-image-gen/save-generated */ import type { Context } from '@deepseek-ai/cordis'; import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'; import type { ComfyUIJobTimings } from './comfyui.js'; import type { Config } from './config.js'; import type { ImageProvider } from './shared.js'; /** One finished image as the tools report it. */ export interface GeneratedValue { attachment: ImageAttachmentRef; provider: ImageProvider; model: string; output: string; savedTo?: string; saveError?: string; /** Concrete workflow seed, exposed by the ComfyUI provider for provenance. */ seed?: number; /** Pixel dimensions and encoded size of the attached image. */ width?: number; height?: number; bytes?: number; /** Timing split reported by the ComfyUI job, in milliseconds. */ queueMs?: number; execMs?: number; totalMs?: number; /** Jobs queued ahead of this one at submission. */ queueAhead?: number; comfyVersion?: string; } /** Bytes a provider finished with, before they become an attachment. */ export interface GeneratedBytes { data: Uint8Array; mediaType: ImageAttachmentRef['mediaType']; seed?: number; timings?: ComfyUIJobTimings; comfyVersion?: string; } /** * Attach one image and, when enabled, write it into the session workspace. * * @param ctx - host context providing the attachment store. * @param generated - finished bytes and their provenance. * @param provider - which source produced them. * @param model - workflow or renderer name. * @param outputPrefix - first word of the provenance line. * @param config - plugin configuration (workspace folder, save toggle). * @param exec - tool execution context (session cwd, abort signal). * @param knownRoots - workspace roots seen so far. * @returns the finished value the tool returns. */ export declare function saveGenerated(ctx: Context, generated: GeneratedBytes, provider: ImageProvider, model: string, outputPrefix: string, config: Config, exec: { agent?: { session: { header: { cwd?: string; }; }; }; signal: AbortSignal; }, knownRoots?: Set): Promise; /** Attachment fields the chat card stores in presentation metadata. */ export declare function attachmentMeta(ref: ImageAttachmentRef): { originalDimensions?: { width: number; height: number; }; name?: string; attachmentId: string; mediaType: import("@deepseek-ai/dsh-attachment").ImageMediaType; bytes: number; width: number; height: number; }; /** Model- and user-visible provenance for one finished image. */ export declare function provenanceLine(prefix: string, attachment: ImageAttachmentRef, seed?: number, timings?: ComfyUIJobTimings, comfyVersion?: string): string;