dsh-image-gen 0.6.5 → 0.6.8

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.
@@ -1,29 +1,14 @@
1
1
  /**
2
- * Landing bus between studio generation results and the tldraw canvases.
3
- *
4
- * Generation paths (single, multi-image, multi-model comparison, chat tool
5
- * cards) push items here; every mounted tldraw surface reconciles against the
6
- * full list. More than one canvas can be mounted at once (the conversation-view
7
- * gallery tab and the right-sidebar studio tab), so the bus broadcasts instead
8
- * of draining: each canvas lands the items its own page does not carry yet
9
- * (per-canvas galleryId dedupe) and re-reads on every push. If no canvas is
10
- * mounted, items wait in memory and land on the next mount. Nothing here or on
11
- * any canvas survives a restart: the tldraw surfaces run without
12
- * persistenceKey, so unsaved generations vanish on reload - the gallery
13
- * remains the only durable store (save-first philosophy).
2
+ * One-shot delivery into the persistent canvas document. The first mounted
3
+ * editor handles a batch; tldraw synchronizes the document to other editors.
4
+ * Delivered items are removed, so deleting a shape never triggers a replay.
14
5
  */
15
6
  import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
16
7
  export interface TlLandingItem {
17
8
  /** Gallery item id; also used to dedupe shapes via shape.meta.galleryId. */
18
9
  galleryId: string;
19
10
  attachment: ImageAttachmentRef;
20
- /**
21
- * True when this attachment is part of the current conversation messages
22
- * (chat tool results): the host can then resolve its full-resolution
23
- * original directly, and a canvas screenshot of it would be redundant.
24
- * Form generations never enter the conversation, so their selections must
25
- * keep the screenshot fallback — the host has no other way to see them.
26
- */
11
+ /** Live conversation delivery; discard unfinished delivery when all canvases close. */
27
12
  fromConversation?: boolean;
28
13
  /**
29
14
  * Generation provenance copied onto the landed shape's meta: the canvas
@@ -35,19 +20,14 @@ export interface TlLandingItem {
35
20
  provider?: string;
36
21
  model?: string;
37
22
  }
38
- type TlLandingListener = () => void;
23
+ type TlLandingConsumer = (items: readonly TlLandingItem[]) => Promise<boolean>;
24
+ /** Invalidates async landings that started before the user cleared the canvas. */
25
+ export declare function getTlLandingGeneration(): number;
26
+ export declare function clearTlLandings(): void;
39
27
  /** Queue freshly generated images for the tldraw canvases. Safe to call anywhere. */
40
28
  export declare function pushTlLandings(newItems: readonly TlLandingItem[]): void;
41
- /**
42
- * Read every item landed so far in this browser session.
43
- *
44
- * The list is the in-memory session-scratch record shared by all canvases:
45
- * reading never removes items, so a canvas mounted later (or a second canvas
46
- * mounted beside the first) reconciles the same set. The list dies with the
47
- * page, which is exactly the "unsaved content does not survive a restart"
48
- * semantic the studio canvas keeps.
49
- */
50
- export declare function getTlLandings(): readonly TlLandingItem[];
51
- /** Subscribe to queue pushes. Returns an unsubscribe function. */
52
- export declare function subscribeTlLandings(listener: TlLandingListener): () => void;
29
+ /** Conversation results are admitted only while a canvas is mounted. */
30
+ export declare function pushTlLandingsLive(items: readonly TlLandingItem[]): void;
31
+ /** Register a ready editor. False means it unmounted before committing. */
32
+ export declare function registerTlLandingConsumer(consumer: TlLandingConsumer): () => void;
53
33
  export {};
@@ -117,6 +117,18 @@ export declare function isSubscriptionProvider(provider: ImageProvider): provide
117
117
  /** Providers supported by the first browser workbench release. */
118
118
  export declare const CLOUD_IMAGE_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu"];
119
119
  export type CloudImageProvider = typeof CLOUD_IMAGE_PROVIDERS[number];
120
+ /**
121
+ * Providers the browser workbench can drive: the BYOK cloud set plus the
122
+ * logged-in subscription channels. ComfyUI stays out; it has its own workflow
123
+ * pipeline and no shared request shape.
124
+ */
125
+ export declare const STUDIO_PROVIDERS: readonly ["google", "openai", "openai-compat", "seedream", "dashscope", "xai", "zhipu", "chatgpt-sub", "grok-sub", "google-sub"];
126
+ export type StudioProvider = CloudImageProvider | SubscriptionProvider;
127
+ /** True when the provider is selectable in the browser workbench. */
128
+ export declare function isStudioProvider(provider: ImageProvider): provider is StudioProvider;
129
+ /** Timeout for one subscription image call, shared by the tool path and the
130
+ * studio route so neither drifts from the other. */
131
+ export declare const SUBSCRIPTION_TIMEOUT_MS = 300000;
120
132
  /**
121
133
  * Credential references resolved through the DSH Credentials service (BYOK).
122
134
  * These are POSIX-style reference names, not environment variables: the host
@@ -155,7 +167,7 @@ export interface StudioOption {
155
167
  }
156
168
  /** Browser-safe provider description. Credentials and endpoints never cross this boundary. */
157
169
  export interface StudioProviderProfile {
158
- provider: CloudImageProvider;
170
+ provider: StudioProvider;
159
171
  label: string;
160
172
  model: string;
161
173
  configured: boolean;
@@ -175,7 +187,7 @@ export interface StudioWorkspaceInfo {
175
187
  /** Read model and capability state for the workbench without exposing secrets. */
176
188
  export interface StudioConfigResponse {
177
189
  providers: StudioProviderProfile[];
178
- activeProvider: CloudImageProvider;
190
+ activeProvider: StudioProvider;
179
191
  workspaceRoot?: string | undefined;
180
192
  workspaces?: StudioWorkspaceInfo[] | undefined;
181
193
  }
@@ -193,7 +205,7 @@ export type StudioReference = StudioEncodedReference | StudioAttachmentReference
193
205
  /** One browser workbench generation or editing request. */
194
206
  export interface StudioGenerateRequest {
195
207
  mode: 'generate' | 'edit';
196
- provider: CloudImageProvider;
208
+ provider: StudioProvider;
197
209
  model: string;
198
210
  prompt: string;
199
211
  ratio: string;
@@ -211,7 +223,7 @@ export interface StudioGeneratedItem {
211
223
  }
212
224
  /** One completed workbench request. */
213
225
  export interface StudioGenerateResponse extends StudioGeneratedItem {
214
- provider: CloudImageProvider;
226
+ provider: StudioProvider;
215
227
  model: string;
216
228
  prompt: string;
217
229
  createdAt: number;
@@ -1,9 +1,10 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type Config } from './config.js';
3
+ import { type SubscriptionManager } from './subscription.js';
3
4
  import { type CloudImageProvider, type StudioConfigResponse, type StudioGenerateRequest, type StudioGenerateResponse, type StudioProviderProfile } from './shared.js';
4
5
  /** Return only browser-safe capability data. */
5
- export declare function describeStudio(ctx: Context, config: Config): Promise<StudioConfigResponse>;
6
+ export declare function describeStudio(ctx: Context, config: Config, subscriptions?: SubscriptionManager | undefined): Promise<StudioConfigResponse>;
6
7
  /** Execute one validated browser workbench request using the existing provider adapters. */
7
- export declare function generateFromStudio(ctx: Context, config: Config, input: StudioGenerateRequest, signal: AbortSignal, fallbackWorkspaceRoot?: string | undefined): Promise<StudioGenerateResponse>;
8
+ export declare function generateFromStudio(ctx: Context, config: Config, input: StudioGenerateRequest, signal: AbortSignal, fallbackWorkspaceRoot?: string | undefined, subscriptions?: SubscriptionManager | undefined): Promise<StudioGenerateResponse>;
8
9
  export declare function runPool<T>(tasks: Array<() => Promise<T>>, concurrency?: number): Promise<PromiseSettledResult<T>[]>;
9
10
  export declare function studioProfile(config: Config, provider: CloudImageProvider, configured: boolean): StudioProviderProfile;
@@ -21,12 +21,26 @@ import { type SubscriptionBlob } from './blob.js';
21
21
  import { type SubscriptionProvider } from '../shared.js';
22
22
  /** Vendor ids used by the credential refs and the wire calls. */
23
23
  export type SubscriptionVendor = 'codex' | 'grok' | 'antigravity';
24
+ /**
25
+ * Reference image passed to edit calls. Structural so callers can pass their
26
+ * own resolved types without importing from the plugin root.
27
+ */
28
+ export interface SubscriptionReferenceImage {
29
+ data: Uint8Array;
30
+ mediaType: string;
31
+ }
24
32
  /** The vendor each dsh-image-gen subscription provider maps onto. */
25
33
  export declare function vendorOf(provider: SubscriptionProvider): SubscriptionVendor;
26
34
  /** Credential ref one vendor's OAuth blob is stored under (index fixed at 1). */
27
35
  export declare function subscriptionOauthRef(vendor: SubscriptionVendor): CredentialRef;
28
36
  /** Sizes both vendors understand. */
29
37
  export declare const SUBSCRIPTION_SIZES: readonly ["1024x1024", "1024x1536", "1536x1024", "auto"];
38
+ /**
39
+ * Reference images per edit call. Every subscription channel accepts at
40
+ * least this many (Codex edits up to 16, Grok up to 5, Antigravity up to 10),
41
+ * so 5 keeps one shared guard in line with the Studio UI's upload cap.
42
+ */
43
+ export declare const SUBSCRIPTION_MAX_REFERENCE_IMAGES = 5;
30
44
  /** Login status the settings card renders as a badge. */
31
45
  export type SubscriptionLoginStatus = {
32
46
  state: 'logged-in';
@@ -80,6 +94,7 @@ export declare class SubscriptionManager {
80
94
  prompt: string;
81
95
  size?: string;
82
96
  quality?: string;
97
+ referenceImages?: ReadonlyArray<SubscriptionReferenceImage>;
83
98
  signal?: AbortSignal;
84
99
  }): Promise<Array<{
85
100
  b64_json: string;
@@ -37,12 +37,17 @@ export declare function antigravityResolveProject(blob: SubscriptionBlob): Promi
37
37
  * Build the streamGenerateContent request body for one image generation.
38
38
  * Ported from the reference buildImageRequest + the wrapping envelope: no
39
39
  * tools, no systemInstruction, no thinkingConfig; responseModalities asks
40
- * for TEXT+IMAGE.
40
+ * for TEXT+IMAGE. Reference images (edits) ride along as inlineData parts
41
+ * before the text part, mirroring the reference implementation.
41
42
  */
42
43
  export declare function antigravityImageBody(options: {
43
44
  prompt: string;
44
45
  aspectRatio?: string;
45
46
  hd?: boolean;
47
+ referenceImages?: ReadonlyArray<{
48
+ data: Uint8Array;
49
+ mediaType: string;
50
+ }>;
46
51
  }): Record<string, unknown>;
47
52
  /** Wrap the inner request in the Antigravity agent envelope. */
48
53
  export declare function antigravityEnvelope(projectId: string, request: Record<string, unknown>): Record<string, unknown>;
@@ -62,5 +67,9 @@ export declare function antigravityGenerateImage(options: {
62
67
  prompt: string;
63
68
  aspectRatio?: string;
64
69
  hd?: boolean;
70
+ referenceImages?: ReadonlyArray<{
71
+ data: Uint8Array;
72
+ mediaType: string;
73
+ }>;
65
74
  signal?: AbortSignal;
66
75
  }): Promise<AntigravityImageResult>;
@@ -12,6 +12,8 @@ export declare const CODEX_AUTH = "https://auth.openai.com/oauth/authorize";
12
12
  export declare const CODEX_TOKEN = "https://auth.openai.com/oauth/token";
13
13
  /** Where the ChatGPT subscription image request goes. */
14
14
  export declare const CODEX_IMAGE_URL = "https://chatgpt.com/backend-api/codex/images/generations";
15
+ /** Where the ChatGPT subscription image edit request goes. */
16
+ export declare const CODEX_IMAGE_EDIT_URL = "https://chatgpt.com/backend-api/codex/images/edits";
15
17
  /** The model served by this endpoint (probed live: gpt-image-2.5-flare works
16
18
  * on the ChatGPT internal generations route as of 2026-09-14). */
17
19
  export declare const CODEX_IMAGE_MODEL = "gpt-image-2.5-flare";
@@ -10,6 +10,8 @@ import { type Pkce } from '../oauth.js';
10
10
  import type { SubscriptionBlob } from '../blob.js';
11
11
  /** Where the Grok subscription image request goes. */
12
12
  export declare const GROK_IMAGE_URL = "https://api.x.ai/v1/images/generations";
13
+ /** Where the Grok subscription image edit request goes. */
14
+ export declare const GROK_IMAGE_EDIT_URL = "https://api.x.ai/v1/images/edits";
13
15
  /** The model served by this endpoint. */
14
16
  export declare const GROK_IMAGE_MODEL = "grok-imagine-image-2.0";
15
17
  /** Public client id of the grok-cli; vendor-fixed redirect on 127.0.0.1:56121. */
@@ -18,12 +18,12 @@ import { SubscriptionManager } from './subscription/manager.js';
18
18
  import { type SubscriptionProvider } from './shared.js';
19
19
  export { SubscriptionManager, vendorOf } from './subscription/manager.js';
20
20
  export { registerSubscriptionRoutes } from './subscription/subscription-route.js';
21
- /** Timeout for one subscription image call, mirroring the other adapters. */
22
- export declare const SUBSCRIPTION_TIMEOUT_MS = 300000;
21
+ export { SUBSCRIPTION_TIMEOUT_MS } from './shared.js';
23
22
  /**
24
23
  * Generate one image through a logged-in subscription account. Returns the
25
24
  * same `{ data, mediaType }` contract as the API-key adapters so the caller
26
- * can feed it straight into `saveGenerated`.
25
+ * can feed it straight into `saveGenerated`. With sourceImages the call is
26
+ * an edit: the vendor layer picks the channel's edit endpoint.
27
27
  */
28
28
  export declare function generateSubscriptionImage(options: {
29
29
  manager: SubscriptionManager;
@@ -31,6 +31,10 @@ export declare function generateSubscriptionImage(options: {
31
31
  prompt: string;
32
32
  size?: string;
33
33
  quality?: string;
34
+ sourceImages?: ReadonlyArray<{
35
+ data: Uint8Array;
36
+ mediaType: ImageMediaType;
37
+ }>;
34
38
  maxBytes: number;
35
39
  signal: AbortSignal;
36
40
  }): Promise<{
@@ -38,5 +42,3 @@ export declare function generateSubscriptionImage(options: {
38
42
  mediaType: ImageMediaType;
39
43
  revisedPrompt?: string;
40
44
  }>;
41
- /** Subscription channels are prompt-only today; edit_image is rejected outright. */
42
- export declare function assertSubscriptionEditUnsupported(provider: SubscriptionProvider): never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-image-gen",
3
- "version": "0.6.5",
3
+ "version": "0.6.8",
4
4
  "description": "Bring ChatGPT-like image generation to DeepSeek Harness — Gemini, OpenAI, Seedream, DashScope, local ComfyUI & more.",
5
5
  "type": "module",
6
6
  "author": "shanliuling",