/** Values shared by the Host and browser Bundle faces. */ import type { ImageAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment'; /** Browser route used by the generated-image card. */ export declare const IMAGE_ROUTE = "/plugins/dsh-image-gen/image"; /** Browser route used for deleting generated images and workspace files. */ export declare const DELETE_ROUTE = "/plugins/dsh-image-gen/delete"; /** Same-origin route used by the browser image workbench. */ export declare const STUDIO_ROUTE = "/plugins/dsh-image-gen/studio"; /** Same-origin route for built-in prompt inspiration metadata and images. */ export declare const INSPIRATION_ROUTE = "/plugins/dsh-image-gen/inspiration"; /** Browser route used for saving generated images to workspace on demand. */ export declare const SAVE_WORKSPACE_ROUTE = "/plugins/dsh-image-gen/save-workspace"; /** Browser route the settings card probes provider connectivity through. */ export declare const TEST_CONNECTION_ROUTE = "/plugins/dsh-image-gen/test"; /** Browser route the workbench infinite canvas pushes live state through. */ export declare const CANVAS_STATE_ROUTE = "/plugins/dsh-image-gen/canvas-state"; /** Upload a selected canvas original to the host attachment store. */ export declare const CANVAS_ASSET_ROUTE = "/plugins/dsh-image-gen/canvas-asset"; export declare const SUBSCRIPTION_LOGIN_ROUTE = "/plugins/dsh-image-gen/subscription-login"; export declare const SUBSCRIPTION_STATUS_ROUTE = "/plugins/dsh-image-gen/subscription-status"; /** Coarse model-facing kind of one shape on the workbench infinite canvas. */ export type CanvasNodeKind = 'image' | 'draw' | 'text' | 'note' | 'geo' | 'arrow' | 'frame' | 'other'; /** Every accepted canvas node kind, for validating untrusted pushes. */ export declare const CANVAS_NODE_KINDS: readonly CanvasNodeKind[]; /** * Cap on the selection identity list: the client trims `selection.items` to * this size and the canvas-state route rejects pushes carrying more, so the * two ends can never drift apart. */ export declare const CANVAS_MAX_SELECTION_ITEMS = 16; /** * Cap on the node inventory: the client trims `nodes` to this size and the * canvas-state route rejects pushes carrying more, so the two ends can never * drift apart. Sized to keep the model-facing digest compact. */ export declare const CANVAS_MAX_NODES = 48; /** Same shared-cap contract as CANVAS_MAX_NODES, for the selection kind list. */ export declare const CANVAS_MAX_SELECTION_KINDS = 8; /** * Cap on the generation prompt copied onto canvas image shapes and into the * model-facing summaries. The landing path truncates to this and the * canvas-state route rejects longer values, so the two ends can never drift. * The gallery keeps the full prompt; this is only the canvas-side digest view. */ export declare const CANVAS_MAX_PROMPT_CHARS = 120; /** One shape on the workbench infinite canvas, summarized for the model. */ export interface CanvasNodeSummary { kind: CanvasNodeKind; /** Gallery id when the shape is a generated image landed from the bus. */ galleryId?: string; /** Conversation attachment id for generated images; edit_image can target it directly. */ attachmentId?: string; /** Complete host reference; remains usable after switching conversations. */ attachment?: ImageAttachmentRef; /** Human-facing label: image name, geo variant, or similar. */ name?: string; width?: number; height?: number; /** Short text preview for text-bearing shapes. */ text?: string; /** * Truncated generation prompt for landed generated images: the model can * reproduce or precisely vary a canvas image instead of guessing from pixels. */ prompt?: string; /** Provider id (e.g. "google") the landed image was generated with. */ provider?: string; /** Model (or ComfyUI workflow label) the landed image was generated with. */ model?: string; } /** What is currently selected on the canvas. */ export interface CanvasSelectionSummary { count: number; kinds: readonly CanvasNodeKind[]; /** * Capped identity list of the selected shapes, using the same summary shape * as canvas nodes: the model learns WHICH images or strokes are selected * (name, attachment id, dimensions), not just how many. Without this, two * selections of the same size and kind are indistinguishable. */ items?: readonly CanvasNodeSummary[]; } /** * One live state push from a browser tldraw instance of the workbench canvas. * The browser owns the canvas; the host keeps only this compact mirror, so * the conversation agent can reason about (and look at) what the user sees. */ export interface CanvasStatePush { /** Tldraw editor id; distinguishes simultaneously mounted canvases. */ clientInstance: string; /** False on the final push right before a canvas unmounts. */ connected: boolean; /** Total shape count on the current page (the node list may be capped). */ nodeCount: number; /** Capped shape inventory, capped client-side before transport. */ nodes?: readonly CanvasNodeSummary[]; selection?: CanvasSelectionSummary; /** * PNG data-URL screenshot of the current selection, pushed whenever a * selection settles. It shows the selection as it looks on the canvas — * including annotations drawn over generated images — so the model sees the * live canvas state, not just the original conversation attachment. */ selectionImage?: string; /** Changes whenever the selection or its contents change. */ selectionRevision?: string; selectionStatus?: 'preparing' | 'ready' | 'error'; selectionError?: string; /** Monotonic per mounted editor, including its final disconnect. */ sequence?: number; updatedAt: number; } /** Namespace persisted through DSH Settings. */ export declare const IMAGE_GENERATION_NAMESPACE = "image-generation"; /** * Loader entry id of this plugin's composition entry (see cordis.patch.yml). * DSH 0.1.7 serves a plugin's settings under its entry id as the namespace, * so browser-side reads/writes bind `configForms` to this id. */ export declare const IMAGE_GENERATION_ENTRY_ID = "image-gen"; /** Supported providers. */ export declare const IMAGE_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu", "comfyui", "chatgpt-sub", "grok-sub", "google-sub"]; export type ImageProvider = typeof IMAGE_PROVIDERS[number]; /** * Providers that generate through a logged-in subscription account instead * of an API key. They use no credential reference and never join the * cloud/BYOK sets. */ export declare const SUBSCRIPTION_PROVIDERS: readonly ["chatgpt-sub", "grok-sub", "google-sub"]; export type SubscriptionProvider = typeof SUBSCRIPTION_PROVIDERS[number]; /** True when the provider generates through a logged-in subscription account. */ export declare function isSubscriptionProvider(provider: ImageProvider): provider is SubscriptionProvider; /** Providers supported by the first browser workbench release. */ export declare const CLOUD_IMAGE_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu"]; export type CloudImageProvider = typeof CLOUD_IMAGE_PROVIDERS[number]; /** * Providers the browser workbench can drive: the BYOK cloud set plus the * logged-in subscription channels. ComfyUI stays out; it has its own workflow * pipeline and no shared request shape. */ export declare const STUDIO_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu", "chatgpt-sub", "grok-sub", "google-sub"]; export type StudioProvider = CloudImageProvider | SubscriptionProvider; /** True when the provider is selectable in the browser workbench. */ export declare function isStudioProvider(provider: ImageProvider): provider is StudioProvider; /** Timeout for one subscription image call, shared by the tool path and the * studio route so neither drifts from the other. */ export declare const SUBSCRIPTION_TIMEOUT_MS = 300000; /** * Credential references resolved through the DSH Credentials service (BYOK). * These are POSIX-style reference names, not environment variables: the host * layers the process environment and its managed store behind them, so a name * like OPENAI_API_KEY is shared with any other plugin resolving the same ref. */ export declare const GOOGLE_API_KEY_ENV = "GEMINI_API_KEY"; /** OpenAI Platform credential reference. */ export declare const OPENAI_API_KEY_ENV = "OPENAI_API_KEY"; /** * OpenAI-compatible relay credential reference. Deliberately distinct from * OPENAI_API_KEY so an official key and a relay key can coexist without * overwriting each other. */ export declare const OPENAI_COMPAT_API_KEY_ENV = "DSH_IMAGE_GEN_OPENAI_COMPAT_KEY"; /** Volcengine Ark credential reference. */ export declare const SEEDREAM_API_KEY_ENV = "ARK_API_KEY"; /** DashScope credential reference. */ export declare const DASHSCOPE_API_KEY_ENV = "DASHSCOPE_API_KEY"; /** xAI credential reference; matches the official xAI SDK environment name. */ export declare const XAI_API_KEY_ENV = "XAI_API_KEY"; /** Zhipu credential reference; matches the official Zhipu SDK environment name. */ export declare const ZHIPU_API_KEY_ENV = "ZHIPUAI_API_KEY"; /** The credential reference each cloud provider's API key is stored under. */ export declare const CLOUD_CREDENTIAL_REFS: Record; /** The credential reference storing this provider's API key, when it uses one. */ export declare function cloudCredentialRef(provider: ImageProvider): string | undefined; /** Locale-neutral provider names for user-facing errors and status lines. */ export declare const PROVIDER_DISPLAY_NAMES: Record; /** Display names for the subscription providers, separate from the BYOK table. */ export declare const SUBSCRIPTION_PROVIDER_DISPLAY_NAMES: Record; /** One selectable output option exposed by a provider profile. */ export interface StudioOption { value: string; label: string; } /** Browser-safe provider description. Credentials and endpoints never cross this boundary. */ export interface StudioProviderProfile { provider: StudioProvider; label: string; model: string; configured: boolean; supportsEditing: boolean; ratioOptions: StudioOption[]; qualityOptions: StudioOption[]; defaultRatio: string; defaultQuality: string; } /** Lightweight workspace description exposed to the client for scoping. */ export interface StudioWorkspaceInfo { workspaceId: string; path: string; title: string; sessionIds: string[]; } /** Read model and capability state for the workbench without exposing secrets. */ export interface StudioConfigResponse { providers: StudioProviderProfile[]; activeProvider: StudioProvider; workspaceRoot?: string | undefined; workspaces?: StudioWorkspaceInfo[] | undefined; } /** A browser-uploaded reference image used for one editing request. */ export interface StudioEncodedReference { mediaType: ImageMediaType; data: string; name?: string; } /** A durable image reference selected from the existing gallery. */ export interface StudioAttachmentReference { attachment: ImageAttachmentRef; } export type StudioReference = StudioEncodedReference | StudioAttachmentReference; /** One browser workbench generation or editing request. */ export interface StudioGenerateRequest { mode: 'generate' | 'edit'; provider: StudioProvider; model: string; prompt: string; ratio: string; quality: string; reference?: StudioReference; references?: StudioReference[]; count?: number | undefined; workspaceRoot?: string | undefined; } /** One individual generated image item in a workbench batch. */ export interface StudioGeneratedItem { attachment: ImageAttachmentRef; output: string; savedTo?: string | undefined; } /** One completed workbench request. */ export interface StudioGenerateResponse extends StudioGeneratedItem { provider: StudioProvider; model: string; prompt: string; createdAt: number; elapsedMs: number; items?: StudioGeneratedItem[] | undefined; requestedCount?: number | undefined; failedCount?: number | undefined; errors?: Array<{ index: number; message: string; }> | undefined; } /** Default endpoints and base URLs. */ export declare const DEFAULT_GOOGLE_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/interactions"; export declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1"; export declare const DEFAULT_SEEDREAM_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3"; export declare const DEFAULT_DASHSCOPE_ENDPOINT = "https://dashscope.aliyuncs.com/api/v1"; export declare const DEFAULT_XAI_BASE_URL = "https://api.x.ai/v1"; export declare const DEFAULT_ZHIPU_BASE_URL = "https://open.bigmodel.cn/api/paas/v4"; export declare const DEFAULT_COMFYUI_BASE_URL = "http://127.0.0.1:8188"; export declare const DEFAULT_COMFYUI_TIMEOUT_MS = 300000; export declare const DEFAULT_COMFYUI_WORKFLOW_LABEL = "API workflow"; export declare const MAX_COMFYUI_WORKFLOW_BYTES: number; /** Content types Ark's Seedream endpoint can return. */ export declare const ARK_OUTPUT_FORMATS: readonly ["png", "jpeg"]; /** Whether Ark stamps an "AI generated" watermark on the result. */ export declare const ARK_BACKGROUND_MODES: readonly ["opaque", "transparent"]; export type ArkOutputFormat = typeof ARK_OUTPUT_FORMATS[number]; export type ArkBackgroundMode = typeof ARK_BACKGROUND_MODES[number]; /** * Ark (Seedream) output controls, shared by the generate and edit paths. * * Every field mirrors an Ark request-body field of the same meaning, and every * default below reproduces Ark's own default — so an untouched configuration * sends exactly what it sent before these options existed. */ export interface ArkOutputOptions { /** `output_format`. Ark defaults to `jpeg`; `png` is lossless and keeps an alpha channel. */ outputFormat?: ArkOutputFormat; /** `watermark`. Ark defaults to `true`, which bakes an "AI generated" mark into the image. */ watermark?: boolean; /** `background`. Ark defaults to `opaque`. */ background?: ArkBackgroundMode; } /** * Map the Ark output controls onto request-body fields. * * `background` is opt-in per call site because Ark restricts `transparent` to * image-to-image with a single alpha-bearing reference and rejects the whole * request otherwise: * * text-to-image + transparent → 400 InvalidParameter * "transparent background requires exactly one input image" * * So the generation endpoint must never carry it, and that caller passes * `{ background: false }`. `background: opaque` is never emitted anywhere: it * is already Ark's default, so sending it would change nothing while adding a * field only the edit path can act on. */ export declare function arkOutputBody(options: ArkOutputOptions | undefined, { background }?: { background?: boolean; }): Record; /** Default model names. */ export declare const DEFAULT_GOOGLE_MODEL = "gemini-3.1-flash-image"; export declare const DEFAULT_OPENAI_MODEL = "gpt-image-2"; export declare const DEFAULT_SEEDREAM_MODEL = "doubao-seedream-5-0-260128"; export declare const DEFAULT_DASHSCOPE_MODEL = "qwen-image-3.0"; export declare const DEFAULT_XAI_MODEL = "grok-imagine-image"; export declare const DEFAULT_ZHIPU_MODEL = "glm-image"; /** One named ComfyUI API-format workflow imported through settings. */ export interface ComfyUIWorkflowEntry { /** Unique human-readable label; used as the result model and by tool calls. */ name: string; /** API-format workflow JSON with {{prompt}} / {{seed}} and optional {{image}} placeholders. */ json: string; /** Optional preset prepended to the user prompt on every call of this workflow. */ presetPrompt?: string; } /** Raw ComfyUI workflow fields as persisted through DSH Settings. */ export interface ComfyUIWorkflowSource { /** Named workflows managed by the Web settings page. */ comfyuiWorkflows?: readonly ComfyUIWorkflowEntry[]; /** Name of the entry ComfyUI calls use by default. */ comfyuiActiveWorkflow?: string; /** Legacy single-workflow storage; synced to the active entry for downgrades. */ comfyuiWorkflowJson?: string; comfyuiWorkflowName?: string; } /** Named workflows, falling back to the legacy single-workflow fields when the list is empty. */ export declare function resolveComfyUIWorkflows(source: ComfyUIWorkflowSource): ComfyUIWorkflowEntry[]; /** The workflow ComfyUI calls use by default: the configured active name, else the first entry. */ export declare function activeComfyUIWorkflow(source: ComfyUIWorkflowSource): ComfyUIWorkflowEntry | undefined; /** Derive a workflow label that does not collide with the given existing names. */ export declare function uniqueComfyUIWorkflowName(name: string, existing: readonly string[]): string; /** * Combine a workflow's preset with the user prompt: preset first, user second, * joined by one comma — never doubled when the preset already ends in a * separator, and reduced to the non-empty side when the other is blank. */ export declare function mergeComfyUIPrompt(preset: string | undefined, user: string): string; /** Default models for the subscription channels; fixed by the bridge protocol. */ export declare const DEFAULT_SUBSCRIPTION_MODELS: Record; export declare const DEFAULT_MODELS: Record; export declare const DEFAULT_BASE_URLS: Record;