dsh-image-gen 0.9.3 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ export interface ConversationImageRevision {
5
5
  attachment: ImageAttachmentRef;
6
6
  prompt: string;
7
7
  provider: StudioProvider;
8
+ channel?: string;
8
9
  model: string;
9
10
  output: string;
10
11
  createdAt: number;
@@ -1,6 +1,7 @@
1
1
  import { type StudioGenerateRequest, type StudioWatermark } from '../shared.js';
2
2
  export interface RegeneratableImage {
3
3
  provider: string;
4
+ channel?: string | undefined;
4
5
  model: string;
5
6
  output?: string | undefined;
6
7
  }
@@ -11,6 +11,7 @@ export interface GalleryItem {
11
11
  prompt: string;
12
12
  /** Generation provider, or 'import' for user-uploaded images. */
13
13
  provider: ImageProvider | 'import';
14
+ channel?: string | undefined;
14
15
  model: string;
15
16
  createdAt: number;
16
17
  aspectRatio?: string | undefined;
@@ -5,6 +5,7 @@ export interface ImageResultPresentation {
5
5
  readonly attachment: ImageAttachmentRef;
6
6
  readonly prompt: string;
7
7
  readonly provider: string;
8
+ readonly channel?: string;
8
9
  readonly model: string;
9
10
  readonly output: string;
10
11
  readonly savedTo?: string;
@@ -9,20 +9,25 @@ export interface SettingsScope<T> {
9
9
  set(field: string, value: unknown): Promise<boolean | void>;
10
10
  }
11
11
  import type { InjectFace, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
12
- import { type ComfyUIWorkflowEntry, type ImageProvider } from '../shared.js';
12
+ import { type ComfyUIWorkflowEntry, type OpenAICompatChannel, type ImageProvider } from '../shared.js';
13
13
  import { type LocaleService } from './gallery-view.js';
14
14
  import { type ImageResultPresentation } from './image-result-node.js';
15
15
  type Provider = ImageProvider;
16
16
  interface ImageSettings {
17
17
  provider?: Provider;
18
+ cloudTimeoutMs?: number;
18
19
  googleModel?: string;
19
20
  googleEndpoint?: string;
20
21
  googleNative?: boolean;
21
22
  openaiBaseURL?: string;
22
23
  openaiModel?: string;
23
24
  openaiSizes?: Record<string, Record<string, string>>;
25
+ openaiCompatLabel?: string;
24
26
  openaiCompatBaseURL?: string;
25
27
  openaiCompatModel?: string;
28
+ openaiCompatModels?: string[];
29
+ openaiCompatChannels?: OpenAICompatChannel[];
30
+ openaiCompatActiveChannel?: string;
26
31
  openaiCompatEditModel?: string;
27
32
  openaiCompatSizes?: Record<string, Record<string, string>>;
28
33
  openaiCompatQuality?: string;
@@ -1,4 +1,4 @@
1
- import type { StudioOption, StudioProvider, StudioProviderProfile } from '../shared.js';
1
+ import { type StudioOption, type StudioProvider, type StudioProviderProfile } from '../shared.js';
2
2
  export interface ComparisonTarget {
3
3
  profile: StudioProviderProfile;
4
4
  ratio: string;
@@ -8,13 +8,13 @@ export interface ComparisonTarget {
8
8
  generationQuality?: string;
9
9
  }
10
10
  /** Map one shared output intent to settings accepted by every target model. */
11
- export declare function buildComparisonTargets(profiles: readonly StudioProviderProfile[], selectedProviders: readonly StudioProvider[], ratio: string, quality: string, output?: {
11
+ export declare function buildComparisonTargets(profiles: readonly StudioProviderProfile[], selectedTargets: readonly string[], ratio: string, quality: string, output?: {
12
12
  resolution: string;
13
13
  generationQuality: string;
14
14
  }): ComparisonTarget[];
15
15
  /** Keep pixel tiers separate from upstream quality values in comparison mode. */
16
16
  export declare function comparisonOutputOptions(profiles: readonly StudioProviderProfile[], ratio: string, kind: 'resolution' | 'generationQuality'): StudioOption[];
17
17
  /** Start with two models, not every configured API, to avoid surprise spend. */
18
- export declare function initialComparisonProviders(profiles: readonly StudioProviderProfile[], activeProvider: StudioProvider): StudioProvider[];
18
+ export declare function initialComparisonProviders(profiles: readonly StudioProviderProfile[], activeProvider: StudioProvider, activeChannel?: string): string[];
19
19
  /** Union of every configured profile's options, for the shared comparison pickers. */
20
20
  export declare function comparisonOptionUnion(profiles: readonly StudioProviderProfile[], key: 'ratioOptions' | 'qualityOptions'): StudioOption[];
@@ -1,4 +1,4 @@
1
- import { type ComfyUIWorkflowEntry, type ImageProvider } from '../shared.js';
1
+ import { type ComfyUIWorkflowEntry, type OpenAICompatChannel, type ImageProvider } from '../shared.js';
2
2
  import type { SettingsScope } from './index.js';
3
3
  import type { LocaleService } from './gallery-view.js';
4
4
  /** Settings fields the pill reads; a structural subset of the full settings shape. */
@@ -6,7 +6,11 @@ export interface PillSettings {
6
6
  provider?: ImageProvider;
7
7
  googleModel?: string;
8
8
  openaiModel?: string;
9
+ openaiCompatLabel?: string;
9
10
  openaiCompatModel?: string;
11
+ openaiCompatModels?: readonly string[];
12
+ openaiCompatChannels?: readonly OpenAICompatChannel[];
13
+ openaiCompatActiveChannel?: string;
10
14
  seedreamModel?: string;
11
15
  dashscopeModel?: string;
12
16
  xaiModel?: string;
@@ -41,9 +45,11 @@ export interface ProviderPillFace {
41
45
  /** Whether the user opted into the composer pill; hidden (not merely inert) when off. */
42
46
  export declare function pillVisible(value: PillSettings | undefined): boolean;
43
47
  /** Model (or ComfyUI workflow) a provider row will use with the persisted settings. */
44
- export declare function pillModelOf(provider: ImageProvider, value: PillSettings | undefined): string;
48
+ export declare function pillModelOf(provider: ImageProvider, value: PillSettings | undefined, channelId?: string): string;
49
+ /** Optional model choices exposed by a provider; single-model providers return an empty list. */
50
+ export declare function pillModelOptionsOf(provider: ImageProvider, value: PillSettings | undefined, channelId?: string): string[];
45
51
  /** One fixed-position provider menu anchored to the pill button. */
46
52
  export declare function ImageProviderPill(props: ProviderPillFace): import("react").JSX.Element | null;
47
53
  /** Styles for the pill and its fixed-position menu; injected by the client entry. */
48
- export declare const PROVIDER_PILL_STYLE = "\n.dsh-ig-pill-root{position:relative;display:inline-flex;align-items:center;height:28px}\n.dsh-ig-pill-button{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 9px 0 8px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:14px;background:var(--dsw-alias-bg-layer-3,#fff);color:var(--dsw-alias-label-secondary,#4b5563);font:inherit;font-size:13px;line-height:20px;cursor:pointer;transition:border-color .15s,background .15s,color .15s;-webkit-user-select:none;user-select:none}\n.dsh-ig-pill-button:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#9ca3af);color:var(--dsw-alias-label-primary,#111827)}\n.dsh-ig-pill-button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4c78ff);outline-offset:1px}\n.dsh-ig-pill-button:disabled{opacity:.5;cursor:not-allowed}\n.dsh-ig-pill-button-open{border-color:var(--dsw-alias-brand-primary,#4c78ff);color:var(--dsw-alias-label-primary,#111827)}\n.dsh-ig-pill-icon{flex:none;color:var(--dsw-alias-brand-primary,#4c78ff)}\n.dsh-ig-pill-provider{max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dsh-ig-pill-caret{display:inline-flex;flex:none;transition:transform .15s}\n.dsh-ig-pill-caret-open{transform:rotate(180deg)}\n@container (max-width:700px){\n .dsh-ig-pill-caret{display:none}\n .dsh-ig-pill-button{padding:0 7px 0 6px}\n}\n.dsh-ig-pill-menu{position:fixed;z-index:1000;min-width:264px;max-width:min(320px,calc(100vw - 24px));padding:6px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:12px;background:var(--dsw-alias-bg-layer-3,#fff);box-shadow:0 12px 32px rgba(0,0,0,.16),0 2px 8px rgba(0,0,0,.08);max-height:min(320px,calc(100vh - 48px));overflow-y:auto}\n.dsh-ig-pill-menu-title{padding:6px 8px 4px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary,#6b7280)}\n.dsh-ig-pill-option{display:flex;width:100%;align-items:center;gap:9px;padding:7px 8px;border:0;border-radius:8px;background:none;font:inherit;color:inherit;text-align:left;cursor:pointer}\n.dsh-ig-pill-option:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2,#f3f4f6)}\n.dsh-ig-pill-option:disabled{opacity:.6;cursor:default}\n.dsh-ig-pill-option:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4c78ff);outline-offset:-2px}\n.dsh-ig-pill-option-active{background:var(--dsw-alias-brand-primary-soft,rgba(76,120,255,.10))}\n.dsh-ig-pill-dot{flex:none;width:7px;height:7px;border-radius:50%}\n.dsh-ig-pill-dot-ok{background:#22c55e}\n.dsh-ig-pill-dot-missing{background:#9ca3af}\n.dsh-ig-pill-dot-neutral{background:#4c78ff}\n.dsh-ig-pill-option-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}\n.dsh-ig-pill-option-name{font-size:12.5px;font-weight:500;color:var(--dsw-alias-label-primary,#111827);line-height:1.2}\n.dsh-ig-pill-option-sub{font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7280);line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dsh-ig-pill-check{flex:none;color:var(--dsw-alias-brand-primary,#4c78ff)}\n.dsh-ig-pill-error{margin-top:4px;padding:6px 8px;border-radius:8px;background:rgba(239,68,68,.08);color:#ef4444;font-size:11.5px;line-height:1.4;word-break:break-all}\n";
54
+ export declare const PROVIDER_PILL_STYLE = "\n.dsh-ig-pill-root{position:relative;display:inline-flex;align-items:center;height:28px}\n.dsh-ig-pill-button{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 9px 0 8px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:14px;background:var(--dsw-alias-bg-layer-3,#fff);color:var(--dsw-alias-label-secondary,#4b5563);font:inherit;font-size:13px;line-height:20px;cursor:pointer;transition:border-color .15s,background .15s,color .15s;-webkit-user-select:none;user-select:none}\n.dsh-ig-pill-button:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#9ca3af);color:var(--dsw-alias-label-primary,#111827)}\n.dsh-ig-pill-button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4c78ff);outline-offset:1px}\n.dsh-ig-pill-button:disabled{opacity:.5;cursor:not-allowed}\n.dsh-ig-pill-button-open{border-color:var(--dsw-alias-brand-primary,#4c78ff);color:var(--dsw-alias-label-primary,#111827)}\n.dsh-ig-pill-icon{flex:none;color:var(--dsw-alias-brand-primary,#4c78ff)}\n.dsh-ig-pill-provider{max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dsh-ig-pill-caret{display:inline-flex;flex:none;transition:transform .15s}\n.dsh-ig-pill-caret-open{transform:rotate(180deg)}\n@container (max-width:700px){\n .dsh-ig-pill-caret{display:none}\n .dsh-ig-pill-button{padding:0 7px 0 6px}\n}\n.dsh-ig-pill-menu{position:fixed;z-index:1000;min-width:264px;max-width:min(320px,calc(100vw - 24px));padding:6px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:12px;background:var(--dsw-alias-bg-layer-3,#fff);box-shadow:0 12px 32px rgba(0,0,0,.16),0 2px 8px rgba(0,0,0,.08);max-height:min(320px,calc(100vh - 48px));overflow-y:auto}\n.dsh-ig-pill-menu-title{padding:6px 8px 4px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary,#6b7280)}\n.dsh-ig-pill-option{display:flex;width:100%;align-items:center;gap:9px;padding:7px 8px;border:0;border-radius:8px;background:none;font:inherit;color:inherit;text-align:left;cursor:pointer}\n.dsh-ig-pill-option:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2,#f3f4f6)}\n.dsh-ig-pill-option:disabled{opacity:.6;cursor:default}\n.dsh-ig-pill-option:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4c78ff);outline-offset:-2px}\n.dsh-ig-pill-option-active{background:var(--dsw-alias-brand-primary-soft,rgba(76,120,255,.10))}\n.dsh-ig-pill-dot{flex:none;width:7px;height:7px;border-radius:50%}\n.dsh-ig-pill-dot-ok{background:#22c55e}\n.dsh-ig-pill-dot-missing{background:#9ca3af}\n.dsh-ig-pill-dot-neutral{background:#4c78ff}\n.dsh-ig-pill-option-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}\n.dsh-ig-pill-option-name{font-size:12.5px;font-weight:500;color:var(--dsw-alias-label-primary,#111827);line-height:1.2}\n.dsh-ig-pill-option-sub{font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7280);line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dsh-ig-pill-model-option{padding-left:24px}\n.dsh-ig-pill-model-name{flex:1;min-width:0;font-size:12px;color:var(--dsw-alias-label-secondary,#4b5563);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dsh-ig-pill-check{flex:none;color:var(--dsw-alias-brand-primary,#4c78ff)}\n.dsh-ig-pill-error{margin-top:4px;padding:6px 8px;border-radius:8px;background:rgba(239,68,68,.08);color:#ef4444;font-size:11.5px;line-height:1.4;word-break:break-all}\n";
49
55
  export {};
@@ -40,6 +40,7 @@ export declare const StudioView: FC<{
40
40
  onInitialReferenceApplied?(): void;
41
41
  onOpenInspiration?(): void;
42
42
  }>;
43
+ export declare function useInView<T extends HTMLElement>(): [(node: T | null) => void, boolean];
43
44
  export declare function useAttachmentImage(attachment: ImageAttachmentRef | undefined, shouldLoad?: boolean): {
44
45
  url: string | null;
45
46
  blob: Blob | null;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Delivery of a drawing plan to the workbench canvases.
3
+ *
4
+ * The `draw_reference` tool cannot put path data inline: the plan is tens of
5
+ * kilobytes and the conversation is persisted, so the tool result carries only
6
+ * a `traceId` (see presentationMeta) and this bridge hands that id to whichever
7
+ * canvas is mounted. The canvas then fetches the plan from the trace-plan route
8
+ * and plays it.
9
+ *
10
+ * A trace that arrives while no canvas is mounted is held, not dropped: the
11
+ * canvas surfaces are tab-scoped and unmount when the user looks elsewhere, so
12
+ * dropping on absence would mean the drawing only ever plays if the user
13
+ * happened to be staring at the infinite canvas at that exact second. The
14
+ * queue holds the newest trace only — a drawing is a one-shot show, and an
15
+ * older plan is stale by the time a newer one exists.
16
+ */
17
+ /** The identifying part of a trace result, as it arrives on a tool event. */
18
+ export interface TlTraceItem {
19
+ traceId: string;
20
+ /** Source pixel size, for the overlay's initial aspect box. */
21
+ sourceWidth: number;
22
+ sourceHeight: number;
23
+ /** Region count, for the "N blocks" caption. */
24
+ steps: number;
25
+ }
26
+ type TlTraceConsumer = (item: TlTraceItem) => void;
27
+ /** Whether any canvas is mounted to play a plan. */
28
+ export declare function hasTlTraceConsumer(): boolean;
29
+ /** The trace waiting for a canvas, if any. */
30
+ export declare function pendingTlTrace(): TlTraceItem | null;
31
+ /**
32
+ * Register a canvas surface; returns its disposer. A trace that arrived while
33
+ * nothing was mounted plays immediately, so opening the canvas after asking
34
+ * for a drawing still shows it.
35
+ */
36
+ export declare function registerTlTraceConsumer(consumer: TlTraceConsumer): () => void;
37
+ /** Hand a plan to every mounted canvas, or hold the newest one until one is. */
38
+ export declare function pushTlTrace(item: TlTraceItem): void;
39
+ /** Test seam: clear every consumer and the pending slot. */
40
+ export declare function resetTlTraceBridge(): void;
41
+ /**
42
+ * Parse the plugin-owned trace metadata off a Tool result. Returns undefined
43
+ * for anything that is not a draw_reference result, so callers can share one
44
+ * event subscription with the image landings.
45
+ */
46
+ export declare function traceResultFromMeta(value: unknown): TlTraceItem | undefined;
47
+ /**
48
+ * Recover a trace from a `tool/ptc-dispatch` event, when the model called
49
+ * draw_reference through run_code instead of directly.
50
+ */
51
+ export declare function traceResultFromPtcDispatch(event: {
52
+ readonly type: string;
53
+ readonly data: Record<string, unknown>;
54
+ }): TlTraceItem | undefined;
55
+ export {};
@@ -0,0 +1,101 @@
1
+ import type { Editor } from 'tldraw';
2
+ import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
3
+ interface TraceStep {
4
+ layer: number;
5
+ d: string;
6
+ area: number;
7
+ }
8
+ interface TracePlan {
9
+ viewBox: [number, number, number, number];
10
+ fills: string[];
11
+ steps: TraceStep[];
12
+ }
13
+ export interface CanvasTraceProps {
14
+ editor: Editor;
15
+ traceId: string;
16
+ /** Region count reported by the tool, shown before the plan arrives. */
17
+ steps: number;
18
+ /**
19
+ * The absolutely-positioned host the surface is rendered into. Its rect is
20
+ * the origin this component must subtract from tldraw's window-relative
21
+ * screen coordinates.
22
+ */
23
+ hostRef?: {
24
+ readonly current: HTMLDivElement | null;
25
+ };
26
+ /**
27
+ * Receives the finished drawing as a rail image plus the page rectangle it
28
+ * was drawn in, so the canvas can place it exactly where the playback was.
29
+ */
30
+ onLand?: ((attachment: ImageAttachmentRef, placement: {
31
+ x: number;
32
+ y: number;
33
+ w: number;
34
+ h: number;
35
+ }) => void | Promise<void>) | undefined;
36
+ onClose: () => void;
37
+ lang?: 'zh' | 'en';
38
+ }
39
+ /**
40
+ * Revealed region count at elapsed time `t`. Squaring the normalised time
41
+ * gives the first (largest) regions most of the screen time and then speeds up
42
+ * through the tiny ones, which is the same curve the drawai workbench uses.
43
+ */
44
+ export declare function traceRevealCount(total: number, elapsedMs: number, durationMs: number): number;
45
+ /** Total playback time for a plan: short plans stay readable, long ones stay bounded. */
46
+ export declare function tracePlaybackDuration(total: number): number;
47
+ /** Paint order prefix: the first `count` steps accumulated per colour layer. */
48
+ export declare function traceLayerPaths(plan: TracePlan, count: number): string[];
49
+ /** Rebuild the finished SVG document from the plan, for download. */
50
+ export declare function tracePlanToSvg(plan: TracePlan): string;
51
+ /**
52
+ * Draw the finished SVG into a canvas and encode it as PNG.
53
+ *
54
+ * SVG reaches the document as a bitmap because tldraw's image shapes render
55
+ * through `<img>`, where an SVG with only a viewBox has no intrinsic size and
56
+ * collapses to the 300x150 default. Width and height are injected for the same
57
+ * reason: without them the browser has nothing to scale from.
58
+ */
59
+ export declare function rasterizeSvg(svg: string, width: number, height: number): Promise<Blob>;
60
+ /** Upload rasterised bytes as a durable attachment so the canvas can land them. */
61
+ export declare function uploadDrawing(blob: Blob, name: string): Promise<ImageAttachmentRef>;
62
+ /** Rasterise one plan at a bounded resolution, then store it as an attachment. */
63
+ export declare function realizeDrawing(plan: TracePlan, name: string): Promise<ImageAttachmentRef>;
64
+ /** Page-space rectangle the drawing occupies, frozen when the trace starts. */
65
+ export interface TraceAnchor {
66
+ x: number;
67
+ y: number;
68
+ w: number;
69
+ h: number;
70
+ }
71
+ /**
72
+ * Pick the page rectangle for a drawing of `aspect` (w/h): centred on what the
73
+ * user is looking at right now, at 72% of the viewport. Frozen in page space so
74
+ * later panning and zooming move it like canvas content instead of resizing it
75
+ * to the window.
76
+ */
77
+ export declare function anchorTraceInViewport(viewport: {
78
+ center: {
79
+ x: number;
80
+ y: number;
81
+ };
82
+ w: number;
83
+ h: number;
84
+ }, aspect: number): TraceAnchor;
85
+ export declare function CanvasTrace({ editor, traceId, steps, hostRef, onLand, onClose, lang }: CanvasTraceProps): import("react").JSX.Element;
86
+ /**
87
+ * Map a page rectangle into the surface's own coordinate space.
88
+ *
89
+ * tldraw's screen space is window-relative (`pageToScreen` returns client
90
+ * coordinates, which is why collaborator cursors need no offset), while the
91
+ * surface is an absolutely positioned child of the canvas host. Subtracting the
92
+ * host's own rect is what turns one into the other; without it the drawing is
93
+ * pushed off the panel and clipped.
94
+ */
95
+ export declare function projectAnchor(editor: Editor, anchor: TraceAnchor, host: HTMLElement | null): {
96
+ left: number;
97
+ top: number;
98
+ width: number;
99
+ height: number;
100
+ };
101
+ export {};
@@ -1,8 +1,8 @@
1
1
  /** User-facing configuration for supported image providers. */
2
2
  import z from '@deepseek-ai/schemastery';
3
3
  import type { CompatEditFormat } from './openai-compatible.js';
4
- import { ARK_BACKGROUND_MODES, ARK_OUTPUT_FORMATS, DEFAULT_DASHSCOPE_ENDPOINT, DEFAULT_DASHSCOPE_MODEL, DEFAULT_COMFYUI_BASE_URL, DEFAULT_COMFYUI_TIMEOUT_MS, DEFAULT_COMFYUI_WORKFLOW_LABEL, DEFAULT_GOOGLE_ENDPOINT, DEFAULT_GOOGLE_MODEL, DEFAULT_OPENAI_BASE_URL, DEFAULT_OPENAI_MODEL, DEFAULT_SEEDREAM_BASE_URL, DEFAULT_SEEDREAM_MODEL, DEFAULT_XAI_BASE_URL, DEFAULT_XAI_MODEL, DEFAULT_ZHIPU_BASE_URL, DEFAULT_ZHIPU_MODEL, DASHSCOPE_API_KEY_ENV, GOOGLE_API_KEY_ENV, IMAGE_PROVIDERS, OPENAI_API_KEY_ENV, OPENAI_COMPAT_API_KEY_ENV, SEEDREAM_API_KEY_ENV, XAI_API_KEY_ENV, ZHIPU_API_KEY_ENV, activeComfyUIWorkflow, resolveComfyUIWorkflows, type ArkBackgroundMode, type ArkOutputFormat, type ArkOutputOptions, type ComfyUIWorkflowEntry, type ImageProvider } from './shared.js';
5
- export { ARK_BACKGROUND_MODES, ARK_OUTPUT_FORMATS, DEFAULT_DASHSCOPE_ENDPOINT, DEFAULT_DASHSCOPE_MODEL, DEFAULT_COMFYUI_BASE_URL, DEFAULT_COMFYUI_TIMEOUT_MS, DEFAULT_COMFYUI_WORKFLOW_LABEL, DEFAULT_GOOGLE_ENDPOINT, DEFAULT_GOOGLE_MODEL, DEFAULT_OPENAI_BASE_URL, DEFAULT_OPENAI_MODEL, DEFAULT_SEEDREAM_BASE_URL, DEFAULT_SEEDREAM_MODEL, DEFAULT_XAI_BASE_URL, DEFAULT_XAI_MODEL, DEFAULT_ZHIPU_BASE_URL, DEFAULT_ZHIPU_MODEL, DASHSCOPE_API_KEY_ENV, GOOGLE_API_KEY_ENV, IMAGE_PROVIDERS, OPENAI_API_KEY_ENV, OPENAI_COMPAT_API_KEY_ENV, SEEDREAM_API_KEY_ENV, XAI_API_KEY_ENV, ZHIPU_API_KEY_ENV, activeComfyUIWorkflow, resolveComfyUIWorkflows, type ArkBackgroundMode, type ArkOutputFormat, type ArkOutputOptions, type ComfyUIWorkflowEntry, type ImageProvider, };
4
+ import { ARK_BACKGROUND_MODES, ARK_OUTPUT_FORMATS, DEFAULT_CLOUD_TIMEOUT_MS, DEFAULT_DASHSCOPE_ENDPOINT, DEFAULT_DASHSCOPE_MODEL, DEFAULT_COMFYUI_BASE_URL, DEFAULT_COMFYUI_TIMEOUT_MS, DEFAULT_COMFYUI_WORKFLOW_LABEL, DEFAULT_GOOGLE_ENDPOINT, DEFAULT_GOOGLE_MODEL, DEFAULT_OPENAI_BASE_URL, DEFAULT_OPENAI_MODEL, DEFAULT_SEEDREAM_BASE_URL, DEFAULT_SEEDREAM_MODEL, DEFAULT_XAI_BASE_URL, DEFAULT_XAI_MODEL, DEFAULT_ZHIPU_BASE_URL, DEFAULT_ZHIPU_MODEL, DASHSCOPE_API_KEY_ENV, GOOGLE_API_KEY_ENV, IMAGE_PROVIDERS, OPENAI_API_KEY_ENV, OPENAI_COMPAT_API_KEY_ENV, SEEDREAM_API_KEY_ENV, XAI_API_KEY_ENV, ZHIPU_API_KEY_ENV, activeComfyUIWorkflow, resolveComfyUIWorkflows, type OpenAICompatChannel, type ArkBackgroundMode, type ArkOutputFormat, type ArkOutputOptions, type ComfyUIWorkflowEntry, type ImageProvider } from './shared.js';
5
+ export { ARK_BACKGROUND_MODES, ARK_OUTPUT_FORMATS, DEFAULT_CLOUD_TIMEOUT_MS, DEFAULT_DASHSCOPE_ENDPOINT, DEFAULT_DASHSCOPE_MODEL, DEFAULT_COMFYUI_BASE_URL, DEFAULT_COMFYUI_TIMEOUT_MS, DEFAULT_COMFYUI_WORKFLOW_LABEL, DEFAULT_GOOGLE_ENDPOINT, DEFAULT_GOOGLE_MODEL, DEFAULT_OPENAI_BASE_URL, DEFAULT_OPENAI_MODEL, DEFAULT_SEEDREAM_BASE_URL, DEFAULT_SEEDREAM_MODEL, DEFAULT_XAI_BASE_URL, DEFAULT_XAI_MODEL, DEFAULT_ZHIPU_BASE_URL, DEFAULT_ZHIPU_MODEL, DASHSCOPE_API_KEY_ENV, GOOGLE_API_KEY_ENV, IMAGE_PROVIDERS, OPENAI_API_KEY_ENV, OPENAI_COMPAT_API_KEY_ENV, SEEDREAM_API_KEY_ENV, XAI_API_KEY_ENV, ZHIPU_API_KEY_ENV, activeComfyUIWorkflow, resolveComfyUIWorkflows, type ArkBackgroundMode, type ArkOutputFormat, type ArkOutputOptions, type ComfyUIWorkflowEntry, type ImageProvider, };
6
6
  /** Default workspace subfolder that receives generated image files. */
7
7
  export declare const DEFAULT_WORKSPACE_FOLDER = "dsh-image-gen";
8
8
  /** Google tool-level controls. Aligned with gemini-3.1-flash-image's common set. */
@@ -13,6 +13,7 @@ export type ImageSize = typeof IMAGE_SIZES[number];
13
13
  /** Bundle configuration from the profile patch and the Web settings page. */
14
14
  export interface Config {
15
15
  provider?: ImageProvider;
16
+ cloudTimeoutMs?: number;
16
17
  googleModel?: string;
17
18
  googleEndpoint?: string;
18
19
  /** Use Gemini generateContent instead of Interactions; opt-in for native-only gateways. */
@@ -22,8 +23,14 @@ export interface Config {
22
23
  /** Official model size table: ratio -> resolution tier -> pixels. Empty uses model presets. */
23
24
  openaiSizes?: Record<string, Record<string, string>>;
24
25
  /** OpenAI-compatible relay settings; independent from the official OpenAI row. */
26
+ openaiCompatLabel?: string;
25
27
  openaiCompatBaseURL?: string;
26
28
  openaiCompatModel?: string;
29
+ /** Models offered by the workbench for the legacy default channel. */
30
+ openaiCompatModels?: string[];
31
+ /** Additional named relay channels; the flat fields above remain the default channel. */
32
+ openaiCompatChannels?: OpenAICompatChannel[];
33
+ openaiCompatActiveChannel?: string;
27
34
  /** Editing model; empty reuses the generation model. */
28
35
  openaiCompatEditModel?: string;
29
36
  /** Default quality; empty preserves the upstream default by omitting the field. */
@@ -171,6 +178,8 @@ export declare function resolveProvider(config: Config): {
171
178
  provider: 'google-sub';
172
179
  model: string;
173
180
  };
181
+ /** Project one named relay channel onto the legacy flat fields used by all provider adapters. */
182
+ export declare function withOpenAICompatChannel(config: Config, channelId?: string): Config;
174
183
  /**
175
184
  * Apply a per-call provider and/or model override on top of the saved config.
176
185
  * `model` is ignored for ComfyUI, whose per-call equivalent is `workflow`.
@@ -5,11 +5,11 @@ import { type CloudImageProvider } from './shared.js';
5
5
  * never count as configured: the host treats an empty stored value as absent,
6
6
  * and a whitespace-only key is never sent to a provider.
7
7
  */
8
- export declare function resolveApiKey(ctx: Context, provider: CloudImageProvider): Promise<string | undefined>;
8
+ export declare function resolveApiKey(ctx: Context, provider: CloudImageProvider, keyRef?: string): Promise<string | undefined>;
9
9
  /**
10
10
  * Resolve one provider's API key or fail with a user-facing message that says
11
11
  * where to configure it. Passing `tool` selects the Agent-facing English
12
12
  * wording; without it the message is the browser-facing Chinese one used by
13
13
  * the Studio route.
14
14
  */
15
- export declare function requireApiKey(ctx: Context, provider: CloudImageProvider, tool?: string): Promise<string>;
15
+ export declare function requireApiKey(ctx: Context, provider: CloudImageProvider, tool?: string, keyRef?: string): Promise<string>;
@@ -0,0 +1,5 @@
1
+ export declare const UPSTREAM_TIMEOUT_HINT = "\u4E0A\u6E38\u53EF\u80FD\u5DF2\u6263\u8D39\u6216\u4ECD\u5728\u751F\u6210\uFF0C\u8BF7\u5230\u670D\u52A1\u5546\u540E\u53F0\u786E\u8BA4";
2
+ export declare class GenerationTimeoutError extends Error {
3
+ constructor(timeoutMs: number);
4
+ }
5
+ export declare function withGenerationTimeout<T>(timeoutMs: number, signal: AbortSignal, operation: (signal: AbortSignal) => Promise<T>): Promise<T>;
@@ -1,3 +1,3 @@
1
1
  /** Live, credential-free instructions for the conversation model's image tools. */
2
2
  import { type Config } from './config.js';
3
- export declare function imageToolContext(config: Config): string;
3
+ export declare function imageToolContext(config: Config, configuredProviders?: readonly string[]): string;
@@ -141,6 +141,48 @@ export declare function isSubscriptionProvider(provider: ImageProvider): provide
141
141
  /** Providers supported by the first browser workbench release. */
142
142
  export declare const CLOUD_IMAGE_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu"];
143
143
  export type CloudImageProvider = typeof CLOUD_IMAGE_PROVIDERS[number];
144
+ /** Normalize the relay model list while keeping the legacy default model selectable. */
145
+ export declare function resolveOpenAICompatModels(config: {
146
+ openaiCompatModel?: string;
147
+ openaiCompatModels?: readonly string[];
148
+ }): string[];
149
+ export declare const DEFAULT_OPENAI_COMPAT_CHANNEL_ID = "default";
150
+ export interface OpenAICompatChannel {
151
+ id: string;
152
+ label: string;
153
+ keyRef: string;
154
+ baseURL: string;
155
+ model: string;
156
+ models?: string[];
157
+ editModel?: string;
158
+ quality?: string;
159
+ qualityOptions?: string[];
160
+ extraBody?: Record<string, unknown>;
161
+ editSizeMode?: 'auto' | 'selected';
162
+ editFormat?: 'multipart' | 'jsonImageUrlArray' | 'formReferenceImages' | 'siliconflowJson';
163
+ editExtra?: Record<string, unknown>;
164
+ sizes?: Record<string, Record<string, string>>;
165
+ }
166
+ export interface OpenAICompatChannelSource {
167
+ openaiCompatLabel?: string;
168
+ openaiCompatBaseURL?: string;
169
+ openaiCompatModel?: string;
170
+ openaiCompatModels?: readonly string[];
171
+ openaiCompatEditModel?: string;
172
+ openaiCompatQuality?: string;
173
+ openaiCompatQualityOptions?: readonly string[];
174
+ openaiCompatExtraBody?: Record<string, unknown>;
175
+ openaiCompatEditSizeMode?: 'auto' | 'selected';
176
+ openaiCompatEditFormat?: 'multipart' | 'jsonImageUrlArray' | 'formReferenceImages' | 'siliconflowJson';
177
+ openaiCompatEditExtra?: Record<string, unknown>;
178
+ openaiCompatSizes?: Record<string, Record<string, string>>;
179
+ openaiCompatChannels?: readonly OpenAICompatChannel[];
180
+ openaiCompatActiveChannel?: string;
181
+ }
182
+ export declare function openAICompatKeyRef(channelId: string): string;
183
+ /** The legacy flat fields remain the first channel; additional entries are fully independent. */
184
+ export declare function resolveOpenAICompatChannels(source: OpenAICompatChannelSource): OpenAICompatChannel[];
185
+ export declare function resolveOpenAICompatChannel(source: OpenAICompatChannelSource, channelId?: string): OpenAICompatChannel;
144
186
  /**
145
187
  * Providers the browser workbench can drive: the BYOK cloud set plus the
146
188
  * logged-in subscription channels. ComfyUI stays out; it has its own workflow
@@ -148,8 +190,11 @@ export type CloudImageProvider = typeof CLOUD_IMAGE_PROVIDERS[number];
148
190
  */
149
191
  export declare const STUDIO_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu", "chatgpt-sub", "grok-sub", "google-sub"];
150
192
  export type StudioProvider = CloudImageProvider | SubscriptionProvider;
193
+ export declare function studioTargetKey(provider: StudioProvider, channel?: string): string;
151
194
  /** True when the provider is selectable in the browser workbench. */
152
195
  export declare function isStudioProvider(provider: ImageProvider): provider is StudioProvider;
196
+ /** Default timeout for API-key cloud generation in the browser workbench. */
197
+ export declare const DEFAULT_CLOUD_TIMEOUT_MS = 150000;
153
198
  /** Timeout for one subscription image call, shared by the tool path and the
154
199
  * studio route so neither drifts from the other. */
155
200
  export declare const SUBSCRIPTION_TIMEOUT_MS = 300000;
@@ -198,10 +243,14 @@ export interface StudioWatermarkCapability {
198
243
  /** Browser-safe provider description. Credentials and endpoints never cross this boundary. */
199
244
  export interface StudioProviderProfile {
200
245
  provider: StudioProvider;
246
+ /** OpenAI-compatible channel id; absent for every other provider. */
247
+ channel?: string;
201
248
  label: string;
202
249
  model: string;
203
250
  /** Separate configured edit model; absent preserves the generation model. */
204
251
  editModel?: string;
252
+ /** Selectable generation models; absent means the single default model. */
253
+ modelOptions?: StudioOption[];
205
254
  configured: boolean;
206
255
  supportsEditing: boolean;
207
256
  ratioOptions: StudioOption[];
@@ -220,6 +269,7 @@ export interface StudioProviderProfile {
220
269
  }
221
270
  /** A model picker/request must use the same operation-specific default. */
222
271
  export declare function studioModelForMode(profile: StudioProviderProfile, mode: 'generate' | 'edit'): string;
272
+ export declare function studioModelOptionsForMode(profile: StudioProviderProfile, mode: 'generate' | 'edit'): StudioOption[];
223
273
  export declare function studioWatermarkCapability(profile: StudioProviderProfile | undefined, mode: 'generate' | 'edit'): StudioWatermarkCapability;
224
274
  /** Lightweight workspace description exposed to the client for scoping. */
225
275
  export interface StudioWorkspaceInfo {
@@ -232,6 +282,7 @@ export interface StudioWorkspaceInfo {
232
282
  export interface StudioConfigResponse {
233
283
  providers: StudioProviderProfile[];
234
284
  activeProvider: StudioProvider;
285
+ activeChannel?: string;
235
286
  workspaceRoot?: string | undefined;
236
287
  workspaces?: StudioWorkspaceInfo[] | undefined;
237
288
  }
@@ -250,6 +301,7 @@ export type StudioReference = StudioEncodedReference | StudioAttachmentReference
250
301
  export interface StudioGenerateRequest {
251
302
  mode: 'generate' | 'edit';
252
303
  provider: StudioProvider;
304
+ channel?: string;
253
305
  model: string;
254
306
  prompt: string;
255
307
  ratio: string;
@@ -272,6 +324,7 @@ export interface StudioGeneratedItem {
272
324
  /** One completed workbench request. */
273
325
  export interface StudioGenerateResponse extends StudioGeneratedItem {
274
326
  provider: StudioProvider;
327
+ channel?: string;
275
328
  model: string;
276
329
  prompt: string;
277
330
  createdAt: number;
@@ -5,6 +5,7 @@ export interface StudioRouteDeps {
5
5
  describe(): Promise<StudioConfigResponse>;
6
6
  generate(input: StudioGenerateRequest, signal: AbortSignal): Promise<StudioGenerateResponse>;
7
7
  maxBodyBytes: number;
8
+ timeoutMs?: number;
8
9
  /** Heartbeat cadence for the streaming generation response; tests shrink it. */
9
10
  heartbeatMs?: number;
10
11
  }
@@ -31,4 +31,4 @@ export declare function describeStudio(ctx: Context, config: Config, subscriptio
31
31
  /** Execute one validated browser workbench request using the existing provider adapters. */
32
32
  export declare function generateFromStudio(ctx: Context, config: Config, input: StudioGenerateRequest, signal: AbortSignal, fallbackWorkspaceRoot?: string | undefined, subscriptions?: SubscriptionManager | undefined): Promise<StudioGenerateResponse>;
33
33
  export declare function runPool<T>(tasks: Array<() => Promise<T>>, concurrency?: number): Promise<PromiseSettledResult<T>[]>;
34
- export declare function studioProfile(config: Config, provider: CloudImageProvider, configured: boolean): StudioProviderProfile;
34
+ export declare function studioProfile(config: Config, provider: CloudImageProvider, configured: boolean, channelId?: string): StudioProviderProfile;
@@ -1,6 +1,6 @@
1
1
  /** Same-origin connection probe the settings card runs per provider. */
2
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
- import type { Config, ImageProvider } from './config.js';
3
+ import { type Config, type ImageProvider } from './config.js';
4
4
  import type { SubscriptionManager } from './subscription.js';
5
5
  import { type CloudImageProvider } from './shared.js';
6
6
  export { TEST_CONNECTION_ROUTE } from './shared.js';
@@ -71,8 +71,8 @@ export declare function probeComfyUIConnection(config: Config, signal?: AbortSig
71
71
  export declare function probeSubscriptionConnection(provider: 'chatgpt-sub' | 'grok-sub' | 'google-sub', manager: SubscriptionManager): Promise<ProbeResult>;
72
72
  /** Dependencies the test route needs from the plugin entry. */
73
73
  export interface TestRouteDeps {
74
- /** The credential each cloud provider probes with, when one is stored. */
75
- resolveKey(provider: CloudImageProvider): Promise<string | undefined>;
74
+ /** The credential each cloud provider or named relay channel probes with, when one is stored. */
75
+ resolveKey(provider: CloudImageProvider, channel?: string): Promise<string | undefined>;
76
76
  /** The currently authoritative config, including unsaved defaults. */
77
77
  config(): Config;
78
78
  /** The internal subscription account manager for the login-state probes. */
@@ -0,0 +1,102 @@
1
+ /** Named trace styles exposed by the tool. */
2
+ export declare const TRACE_PRESET_NAMES: readonly ["default", "lineart", "photo", "simple"];
3
+ export type TracePresetName = (typeof TRACE_PRESET_NAMES)[number];
4
+ /** Fragment density tiers, mirroring the workbench's three calibrated档. */
5
+ export declare const TRACE_FRAGMENT_NAMES: readonly ["low", "medium", "high"];
6
+ export type TraceFragments = (typeof TRACE_FRAGMENT_NAMES)[number];
7
+ /** One connected region of one colour: a self-contained path plus its area. */
8
+ export interface TraceDrawingStep {
9
+ /** Index into `fills`; steps sharing a layer share a fill colour. */
10
+ layer: number;
11
+ /** SVG path data for this region, including its holes (nonzero winding). */
12
+ d: string;
13
+ /** Signed pixel area used for ordering; steps arrive largest first. */
14
+ area: number;
15
+ }
16
+ /** The replayable drawing: paint `steps` in order, grouped by `fills`. */
17
+ export interface TraceDrawingPlan {
18
+ viewBox: [number, number, number, number];
19
+ fills: string[];
20
+ steps: TraceDrawingStep[];
21
+ }
22
+ /** Numbers the model gets instead of the path data. */
23
+ export interface TraceSummary {
24
+ width: number;
25
+ height: number;
26
+ colors: number;
27
+ paths: number;
28
+ loops: number;
29
+ steps: number;
30
+ svgChars: number;
31
+ budget: number;
32
+ attempts: number;
33
+ drawnPixels: number | null;
34
+ exactPixelCoverage: boolean;
35
+ sourceWidth: number;
36
+ sourceHeight: number;
37
+ }
38
+ /** Everything one trace produces. */
39
+ export interface TraceOutcome {
40
+ /** Full SVG document, for export — never sent to the model verbatim. */
41
+ svg: string;
42
+ plan: TraceDrawingPlan;
43
+ /**
44
+ * Optional pencil pass derived from the same source, played before `plan`.
45
+ * Null when the caller asked for no sketch or the edge pass found nothing.
46
+ */
47
+ sketch: TraceDrawingPlan | null;
48
+ summary: TraceSummary;
49
+ /** One-line tuning advice from upstream's own heuristics. */
50
+ hint: string;
51
+ }
52
+ /**
53
+ * One complete drawing session: the contour pass an illustrator starts with,
54
+ * then the colour pass that fills it in.
55
+ */
56
+ export interface TraceShow {
57
+ sketch?: TraceDrawingPlan;
58
+ colour: TraceDrawingPlan;
59
+ }
60
+ /** Trace knobs shared by the decoded-pixels and encoded-bytes entry points. */
61
+ export interface TraceOptions {
62
+ /** Required: keep or drop the background. There is no automatic answer. */
63
+ removeBg: boolean;
64
+ preset?: TracePresetName;
65
+ fragments?: TraceFragments;
66
+ /** Palette size, 2–24. Also caps the number of visible colour layers. */
67
+ colors?: number;
68
+ /** RDP tolerance in work pixels; lower keeps more contour fidelity. */
69
+ epsilon?: number;
70
+ /** Regions under this area are merged into a neighbour. */
71
+ minArea?: number;
72
+ /** Long side cap for the work image; defaults to the calibrated 887. */
73
+ maxLongSide?: number;
74
+ /** SVG character budget; upstream default is 248000. */
75
+ budget?: number;
76
+ /** Derive a pencil sketch to play first; defaults to true. */
77
+ sketch?: boolean;
78
+ }
79
+ /** One trace over an encoded image. */
80
+ export interface TraceRequest extends TraceOptions {
81
+ /** Encoded image bytes (PNG is dependency free; JPEG/WebP need sharp). */
82
+ bytes: Uint8Array;
83
+ }
84
+ /**
85
+ * Trace an encoded raster into an SVG plus its replayable drawing plan.
86
+ * @param request - image bytes and trace knobs.
87
+ * @returns the SVG, the ordered plan, a model-facing summary and a tuning hint.
88
+ */
89
+ export declare function traceImageToDrawing(request: TraceRequest): Promise<TraceOutcome>;
90
+ /**
91
+ * Trace an already-decoded RGBA8 raster. Split out from `traceImageToDrawing`
92
+ * so tests can exercise the pipeline without encoding a PNG first.
93
+ *
94
+ * Produces the colour pass plus, unless disabled, a pencil pass derived from
95
+ * the same pixels. The sketch is best-effort: a picture with no edges worth
96
+ * drawing simply plays the colour pass alone.
97
+ */
98
+ export declare function traceRasterToDrawing(raster: {
99
+ width: number;
100
+ height: number;
101
+ data: Uint8Array;
102
+ }, options: TraceOptions): TraceOutcome;
@@ -0,0 +1,12 @@
1
+ /** Read-only route that hands one stored trace plan to the canvas. */
2
+ import type { IncomingMessage, ServerResponse } from 'node:http';
3
+ import type { TracePlanStore } from './trace-store.js';
4
+ export interface TraceRouteDeps {
5
+ store: TracePlanStore;
6
+ }
7
+ /**
8
+ * Serve one drawing plan by id. GET only: the plan is produced by the
9
+ * `draw_reference` tool and never written from the browser, so there is
10
+ * nothing to accept here.
11
+ */
12
+ export declare function serveTracePlan(req: IncomingMessage, res: ServerResponse, deps: TraceRouteDeps): Promise<void>;