dsh-image-gen 0.6.1 → 0.6.7

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.
Files changed (47) hide show
  1. package/README.en.md +381 -345
  2. package/README.md +381 -345
  3. package/README.zh-CN.md +3 -3
  4. package/docs/assets/readme/canvas-edit.webp +0 -0
  5. package/docs/assets/readme/canvas-generate.webp +0 -0
  6. package/docs/assets/readme/hero-en.webp +0 -0
  7. package/docs/assets/readme/hero-zh.webp +0 -0
  8. package/docs/assets/readme/workflow-overview-en.webp +0 -0
  9. package/docs/assets/readme/workflow-overview.webp +0 -0
  10. package/lib/client.js +1046 -374
  11. package/lib/client.js.map +1 -1
  12. package/lib/index.js +1421 -103
  13. package/lib/types/client/index.d.ts +4 -0
  14. package/lib/types/client/inspiration-api.d.ts +10 -0
  15. package/lib/types/client/inspiration-detail.d.ts +14 -0
  16. package/lib/types/client/provider-pill.d.ts +1 -1
  17. package/lib/types/client/tl/canvas-sync.d.ts +3 -3
  18. package/lib/types/client/tl/conversation-landings.d.ts +33 -0
  19. package/lib/types/client/tl/studio-tl-canvas.d.ts +2 -0
  20. package/lib/types/client/tl/tl-canvas-bridge.d.ts +12 -32
  21. package/lib/types/client/tldraw/generated/tldraw-assets.d.ts +12 -0
  22. package/lib/types/client/tldraw/generated/tldraw-css.d.ts +1 -0
  23. package/lib/types/client/tldraw/tldraw-style.d.ts +1 -0
  24. package/lib/types/client/tldraw/tldraw-workspace.d.ts +1 -0
  25. package/lib/types/config.d.ts +24 -0
  26. package/lib/types/inspiration/cache.d.ts +20 -0
  27. package/lib/types/inspiration/downloader.d.ts +27 -0
  28. package/lib/types/inspiration/routes.d.ts +13 -0
  29. package/lib/types/inspiration/sources.d.ts +33 -0
  30. package/lib/types/inspiration/types.d.ts +65 -0
  31. package/lib/types/inspiration/updater.d.ts +7 -0
  32. package/lib/types/openai-compatible.d.ts +15 -0
  33. package/lib/types/shared.d.ts +16 -1
  34. package/lib/types/subscription/blob.d.ts +23 -0
  35. package/lib/types/subscription/loopback.d.ts +11 -0
  36. package/lib/types/subscription/manager.d.ts +94 -0
  37. package/lib/types/subscription/oauth.d.ts +25 -0
  38. package/lib/types/subscription/subscription-route.d.ts +5 -0
  39. package/lib/types/subscription/vendors/antigravity.d.ts +66 -0
  40. package/lib/types/subscription/vendors/codex.d.ts +30 -0
  41. package/lib/types/subscription/vendors/grok.d.ts +32 -0
  42. package/lib/types/subscription.d.ts +42 -0
  43. package/lib/types/test-route.d.ts +9 -0
  44. package/package.json +8 -10
  45. package/skills/install-dsh-image-gen/SKILL.md +22 -22
  46. package/lib/types/client/studio-chat-panel.d.ts +0 -23
  47. package/lib/types/studio-chat.d.ts +0 -48
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Subscription account manager: login flows, blob storage through the DSH
3
+ * Credentials service, token refresh with per-account locking, and image
4
+ * generation on the logged-in account.
5
+ *
6
+ * The account store pattern follows @goodandready/dsh-subscriptions (MIT,
7
+ * (c) 2026 GooDAnDReaDY) lib/accounts.js, trimmed to one account per vendor
8
+ * (no rotation, no cooldowns) because this bundle has exactly two vendors
9
+ * and no chat adapter to protect.
10
+ *
11
+ * Isolation invariants (project rules):
12
+ * - OAuth blobs live under SUBSCRIPTION_OAUTH_* refs, never the API-key refs.
13
+ * - Login/logout never touches any other setting or credential.
14
+ * - The browser side never sees a token; it sees the authorize URL and
15
+ * status words only. Generation happens host-side, mirroring every other
16
+ * adapter in this bundle.
17
+ */
18
+ import { type CredentialRef } from '@deepseek-ai/dsh-credentials';
19
+ import type { Context } from '@deepseek-ai/cordis';
20
+ import { type SubscriptionBlob } from './blob.js';
21
+ import { type SubscriptionProvider } from '../shared.js';
22
+ /** Vendor ids used by the credential refs and the wire calls. */
23
+ export type SubscriptionVendor = 'codex' | 'grok' | 'antigravity';
24
+ /** The vendor each dsh-image-gen subscription provider maps onto. */
25
+ export declare function vendorOf(provider: SubscriptionProvider): SubscriptionVendor;
26
+ /** Credential ref one vendor's OAuth blob is stored under (index fixed at 1). */
27
+ export declare function subscriptionOauthRef(vendor: SubscriptionVendor): CredentialRef;
28
+ /** Sizes both vendors understand. */
29
+ export declare const SUBSCRIPTION_SIZES: readonly ["1024x1024", "1024x1536", "1536x1024", "auto"];
30
+ /** Login status the settings card renders as a badge. */
31
+ export type SubscriptionLoginStatus = {
32
+ state: 'logged-in';
33
+ email: string;
34
+ } | {
35
+ state: 'logged-out';
36
+ } | {
37
+ state: 'unknown';
38
+ };
39
+ /** Callback shape the login flow reports to the pending HTTP response. */
40
+ export interface LoginOutcome {
41
+ ok: boolean;
42
+ email?: string;
43
+ message?: string;
44
+ }
45
+ export declare class SubscriptionManager {
46
+ private readonly ctx;
47
+ private readonly pending;
48
+ private readonly refreshLocks;
49
+ /** Cheap in-memory expiry cache so badges do not hit credentials on read. */
50
+ private readonly blobCache;
51
+ /** Antigravity needs a per-account project id on every generation call. */
52
+ private readonly projectCache;
53
+ constructor(ctx: Context);
54
+ /** Read a vendor's stored blob, or undefined when signed out. */
55
+ readBlob(vendor: SubscriptionVendor): Promise<SubscriptionBlob | undefined>;
56
+ /** Login status for the settings card; never throws. */
57
+ loginStatus(vendor: SubscriptionVendor): Promise<SubscriptionLoginStatus>;
58
+ /**
59
+ * Begin a login: registers PKCE state, starts the loopback catch server on
60
+ * the vendor-fixed redirect port, and returns the authorize URL for the
61
+ * browser to open. Completion lands in the loopback callback.
62
+ */
63
+ beginLogin(vendor: SubscriptionVendor): Promise<{
64
+ url: string;
65
+ }>;
66
+ /** Loopback callback: validate state, exchange the code, store the blob. */
67
+ private completeLoginFromCallback;
68
+ /** Sign out: clear the blob and the caches. No other setting changes. */
69
+ logout(vendor: SubscriptionVendor): Promise<void>;
70
+ private saveBlob;
71
+ /**
72
+ * Return a blob whose access token is usable; refreshes first when the
73
+ * stored one is expired (or expiring within the skew window). Single-flight
74
+ * per vendor so concurrent generate calls share one refresh.
75
+ */
76
+ ensureFresh(vendor: SubscriptionVendor): Promise<SubscriptionBlob>;
77
+ /** Generate one image through the logged-in account. b64 reply decoded host-side. */
78
+ generate(options: {
79
+ vendor: SubscriptionVendor;
80
+ prompt: string;
81
+ size?: string;
82
+ quality?: string;
83
+ signal?: AbortSignal;
84
+ }): Promise<Array<{
85
+ b64_json: string;
86
+ revisedPrompt?: string;
87
+ }>>;
88
+ /**
89
+ * Resolve (and cache per refresh token) the managed project id the
90
+ * Antigravity generation envelope needs. Re-resolved when the account
91
+ * signs out or a different account logs in.
92
+ */
93
+ private ensureAntigravityProject;
94
+ }
@@ -0,0 +1,25 @@
1
+ /** A PKCE pair plus the OAuth state binding the callback to this login. */
2
+ export interface Pkce {
3
+ verifier: string;
4
+ challenge: string;
5
+ state: string;
6
+ }
7
+ export declare function createPkce(): Promise<Pkce>;
8
+ /** Build an authorization-code URL with PKCE and optional extra params. */
9
+ export declare function buildAuthorizeUrl(input: {
10
+ authUrl: string;
11
+ clientId: string;
12
+ redirectUri: string;
13
+ challenge: string;
14
+ state: string;
15
+ scope?: string;
16
+ extra?: Record<string, string>;
17
+ }): string;
18
+ /** Decode a JWT payload without signature verification (identity read only). */
19
+ export declare function decodeJwtPayload(token: string): Record<string, unknown> | undefined;
20
+ /** The chatgpt-account-id a Codex API call must carry. */
21
+ export declare function chatgptAccountId(token: string): string;
22
+ /** The account email for badges and login confirmation. */
23
+ export declare function emailFromToken(token: string): string;
24
+ /** POST an OAuth token endpoint with form encoding; 25s cap like the source. */
25
+ export declare function formTokenRequest(url: string, params: Record<string, string>, fetchImpl: typeof fetch): Promise<Record<string, unknown>>;
@@ -0,0 +1,5 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { SubscriptionManager } from './manager.js';
3
+ export { SUBSCRIPTION_LOGIN_ROUTE, SUBSCRIPTION_STATUS_ROUTE } from '../shared.js';
4
+ /** Register the login/status routes on the plugin's web server. */
5
+ export declare function registerSubscriptionRoutes(ctx: Context, manager: SubscriptionManager): void;
@@ -0,0 +1,66 @@
1
+ import { type Pkce } from '../oauth.js';
2
+ import type { SubscriptionBlob } from '../blob.js';
3
+ /** Antigravity CLI's embedded OAuth client, treated as public like Codex's. */
4
+ export declare const ANTIGRAVITY_CLIENT_ID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
5
+ export declare const ANTIGRAVITY_CLIENT_SECRET = "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";
6
+ export declare const ANTIGRAVITY_REDIRECT_URI = "http://localhost:51121/oauth-callback";
7
+ /**
8
+ * Endpoint fallback order for generation, mirroring the reference (daily
9
+ * sandbox first, then autopush, then prod).
10
+ */
11
+ export declare const ANTIGRAVITY_ENDPOINTS: readonly ["https://daily-cloudcode-pa.sandbox.googleapis.com", "https://autopush-cloudcode-pa.sandbox.googleapis.com", "https://cloudcode-pa.googleapis.com"];
12
+ /** The image model served through this channel: Nano Banana Pro. */
13
+ export declare const ANTIGRAVITY_IMAGE_MODEL = "gemini-3-pro-image";
14
+ /** Current client version: the fetched one, or the fallback until fetched. */
15
+ export declare function getAntigravityVersion(): string;
16
+ /** Test seam: pin the version so unit tests never depend on the network. */
17
+ export declare function setAntigravityVersionForTest(version: string | undefined): void;
18
+ /** Fetch and cache the current version once; failures keep the fallback. */
19
+ export declare function initAntigravityVersion(): Promise<void>;
20
+ export interface AntigravityConfig {
21
+ clientId: string;
22
+ clientSecret: string;
23
+ redirectUri: string;
24
+ }
25
+ export declare function antigravityConfig(): AntigravityConfig;
26
+ export declare function antigravityAuthorizeUrl(cfg: AntigravityConfig, pkce: Pkce): string;
27
+ export declare function antigravityExchangeCode(cfg: AntigravityConfig, pkce: Pkce, code: string): Promise<SubscriptionBlob>;
28
+ export declare function antigravityRefresh(blob: SubscriptionBlob): Promise<SubscriptionBlob>;
29
+ /**
30
+ * Resolve the managed project id for the logged-in account. Most accounts
31
+ * have one; when loadCodeAssist reports none, the hardcoded fallback keeps
32
+ * generation working (mirrors the reference's ensureProjectContext).
33
+ * Returns '' only when every endpoint fails, letting generate() throw then.
34
+ */
35
+ export declare function antigravityResolveProject(blob: SubscriptionBlob): Promise<string>;
36
+ /**
37
+ * Build the streamGenerateContent request body for one image generation.
38
+ * Ported from the reference buildImageRequest + the wrapping envelope: no
39
+ * tools, no systemInstruction, no thinkingConfig; responseModalities asks
40
+ * for TEXT+IMAGE.
41
+ */
42
+ export declare function antigravityImageBody(options: {
43
+ prompt: string;
44
+ aspectRatio?: string;
45
+ hd?: boolean;
46
+ }): Record<string, unknown>;
47
+ /** Wrap the inner request in the Antigravity agent envelope. */
48
+ export declare function antigravityEnvelope(projectId: string, request: Record<string, unknown>): Record<string, unknown>;
49
+ export interface AntigravityImageResult {
50
+ b64: string;
51
+ mimeType: string;
52
+ text?: string;
53
+ }
54
+ /**
55
+ * Generate one image on the logged-in Antigravity account: resolve the
56
+ * project, POST the wrapped body to each endpoint in fallback order, and
57
+ * parse the SSE stream for the inlineData image part.
58
+ */
59
+ export declare function antigravityGenerateImage(options: {
60
+ blob: SubscriptionBlob;
61
+ projectId: string;
62
+ prompt: string;
63
+ aspectRatio?: string;
64
+ hd?: boolean;
65
+ signal?: AbortSignal;
66
+ }): Promise<AntigravityImageResult>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * ChatGPT (Codex) subscription image vendor.
3
+ *
4
+ * Adapted from @goodandready/dsh-subscriptions (MIT, (c) 2026 GooDAnDReaDY)
5
+ * lib/vendors/codex.js and lib/images.js — only the pieces the image channel
6
+ * needs: authorize URL, code exchange, refresh, and the generations call.
7
+ * The device-code flow and chat streaming stay out of this bundle.
8
+ */
9
+ import { type Pkce } from '../oauth.js';
10
+ import type { SubscriptionBlob } from '../blob.js';
11
+ export declare const CODEX_AUTH = "https://auth.openai.com/oauth/authorize";
12
+ export declare const CODEX_TOKEN = "https://auth.openai.com/oauth/token";
13
+ /** Where the ChatGPT subscription image request goes. */
14
+ export declare const CODEX_IMAGE_URL = "https://chatgpt.com/backend-api/codex/images/generations";
15
+ /** The model served by this endpoint (probed live: gpt-image-2.5-flare works
16
+ * on the ChatGPT internal generations route as of 2026-09-14). */
17
+ export declare const CODEX_IMAGE_MODEL = "gpt-image-2.5-flare";
18
+ /** Public client id of the Codex CLI; vendor-fixed redirect on port 1455. */
19
+ export declare const CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
20
+ export declare const CODEX_REDIRECT_URI = "http://localhost:1455/auth/callback";
21
+ export interface CodexConfig {
22
+ clientId: string;
23
+ redirectUri: string;
24
+ }
25
+ export declare function codexConfig(): CodexConfig;
26
+ export declare function codexAuthorizeUrl(cfg: CodexConfig, pkce: Pkce): string;
27
+ /** Identity fields every Codex API call must carry. */
28
+ export declare function codexIdentityHeaders(blob: SubscriptionBlob): Record<string, string>;
29
+ export declare function codexExchangeCode(cfg: CodexConfig, pkce: Pkce, code: string): Promise<SubscriptionBlob>;
30
+ export declare function codexRefresh(blob: SubscriptionBlob): Promise<SubscriptionBlob>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Grok subscription image vendor.
3
+ *
4
+ * Adapted from @goodandready/dsh-subscriptions (MIT, (c) 2026 GooDAnDReaDY)
5
+ * lib/vendors/grok.js and lib/images.js — only the pieces the image channel
6
+ * needs: authorize URL, code exchange, refresh, and the generations call
7
+ * (grok-cli token, not an xAI API key).
8
+ */
9
+ import { type Pkce } from '../oauth.js';
10
+ import type { SubscriptionBlob } from '../blob.js';
11
+ /** Where the Grok subscription image request goes. */
12
+ export declare const GROK_IMAGE_URL = "https://api.x.ai/v1/images/generations";
13
+ /** The model served by this endpoint. */
14
+ export declare const GROK_IMAGE_MODEL = "grok-imagine-image-2.0";
15
+ /** Public client id of the grok-cli; vendor-fixed redirect on 127.0.0.1:56121. */
16
+ export declare const GROK_CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
17
+ export declare const GROK_REDIRECT_URI = "http://127.0.0.1:56121/callback";
18
+ export declare function grokConfig(): {
19
+ clientId: string;
20
+ redirectUri: string;
21
+ };
22
+ export declare function grokAuthorizeUrl(cfg: {
23
+ clientId: string;
24
+ redirectUri: string;
25
+ }, pkce: Pkce): string;
26
+ /** Identity fields every grok.com call must carry (the API host ignores them). */
27
+ export declare function grokIdentityHeaders(blob: SubscriptionBlob): Record<string, string>;
28
+ export declare function grokExchangeCode(cfg: {
29
+ clientId: string;
30
+ redirectUri: string;
31
+ }, pkce: Pkce, code: string): Promise<SubscriptionBlob>;
32
+ export declare function grokRefresh(blob: SubscriptionBlob): Promise<SubscriptionBlob>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Subscription-based image generation: the internal, self-contained channel.
3
+ *
4
+ * Login (PKCE loopback), token storage through the DSH Credentials service,
5
+ * refresh and the wire calls all live in `./subscription/` — adapted from
6
+ * @goodandready/dsh-subscriptions (MIT, (c) 2026 GooDAnDReaDY), trimmed to
7
+ * the two image vendors this bundle ships. This file keeps the same
8
+ * `{ data, mediaType }` contract as the API-key adapters so `saveGenerated`
9
+ * and everything downstream is shared.
10
+ *
11
+ * Isolation invariants (project rules):
12
+ * - OAuth blobs live under CODEX_OAUTH_1 / GROK_OAUTH_1 refs — never the
13
+ * API-key refs — and the API-key paths never consult subscription state.
14
+ * - Login/logout changes nothing except one vendor's own blob.
15
+ */
16
+ import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
17
+ import { SubscriptionManager } from './subscription/manager.js';
18
+ import { type SubscriptionProvider } from './shared.js';
19
+ export { SubscriptionManager, vendorOf } from './subscription/manager.js';
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;
23
+ /**
24
+ * Generate one image through a logged-in subscription account. Returns the
25
+ * same `{ data, mediaType }` contract as the API-key adapters so the caller
26
+ * can feed it straight into `saveGenerated`.
27
+ */
28
+ export declare function generateSubscriptionImage(options: {
29
+ manager: SubscriptionManager;
30
+ provider: SubscriptionProvider;
31
+ prompt: string;
32
+ size?: string;
33
+ quality?: string;
34
+ maxBytes: number;
35
+ signal: AbortSignal;
36
+ }): Promise<{
37
+ data: Uint8Array;
38
+ mediaType: ImageMediaType;
39
+ revisedPrompt?: string;
40
+ }>;
41
+ /** Subscription channels are prompt-only today; edit_image is rejected outright. */
42
+ export declare function assertSubscriptionEditUnsupported(provider: SubscriptionProvider): never;
@@ -1,6 +1,7 @@
1
1
  /** Same-origin connection probe the settings card runs per provider. */
2
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
3
  import type { Config, ImageProvider } from './config.js';
4
+ import type { SubscriptionManager } from './subscription.js';
4
5
  import { type CloudImageProvider } from './shared.js';
5
6
  export { TEST_CONNECTION_ROUTE } from './shared.js';
6
7
  /** One probe target a provider resolves to: a URL plus its auth headers. */
@@ -62,12 +63,20 @@ export declare function fetchDashScopeImageModels(config: Config, apiKey: string
62
63
  export declare function probeProviderConnection(provider: CloudImageProvider, config: Config, apiKey: string | undefined, signal?: AbortSignal | undefined): Promise<ProbeResult>;
63
64
  /** Probe the local ComfyUI service without any credential. */
64
65
  export declare function probeComfyUIConnection(config: Config, signal?: AbortSignal | undefined): Promise<ProbeResult>;
66
+ /**
67
+ * Probe a subscription provider: the internal manager's login state for the
68
+ * matching vendor. No network call and no token access; the probe reports
69
+ * signed-in (with the account email) or signed-out guidance.
70
+ */
71
+ export declare function probeSubscriptionConnection(provider: 'chatgpt-sub' | 'grok-sub' | 'google-sub', manager: SubscriptionManager): Promise<ProbeResult>;
65
72
  /** Dependencies the test route needs from the plugin entry. */
66
73
  export interface TestRouteDeps {
67
74
  /** The credential each cloud provider probes with, when one is stored. */
68
75
  resolveKey(provider: CloudImageProvider): Promise<string | undefined>;
69
76
  /** The currently authoritative config, including unsaved defaults. */
70
77
  config(): Config;
78
+ /** The internal subscription account manager for the login-state probes. */
79
+ subscriptionManager: SubscriptionManager;
71
80
  }
72
81
  /** Serve the settings card's per-provider connectivity probe. */
73
82
  export declare function serveTestConnection(req: IncomingMessage, res: ServerResponse, deps: TestRouteDeps): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-image-gen",
3
- "version": "0.6.1",
3
+ "version": "0.6.7",
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",
@@ -56,13 +56,6 @@
56
56
  "platform": "web"
57
57
  }
58
58
  },
59
- "scripts": {
60
- "typecheck": "tsc --noEmit",
61
- "build": "tsc && tsdown",
62
- "prepare": "pnpm run build",
63
- "test": "vitest run",
64
- "pack:check": "pnpm pack --dry-run"
65
- },
66
59
  "engines": {
67
60
  "node": "^22.19.0 || >=24.0.0"
68
61
  },
@@ -134,9 +127,14 @@
134
127
  "unrun": "^0.3.1",
135
128
  "vitest": "^4.1.8"
136
129
  },
137
- "packageManager": "pnpm@11.7.0",
138
130
  "dependencies": {
139
131
  "lucide-react": "^1.38.0",
140
132
  "tldraw": "5.3.0"
133
+ },
134
+ "scripts": {
135
+ "typecheck": "tsc --noEmit",
136
+ "build": "tsc && tsdown",
137
+ "test": "vitest run",
138
+ "pack:check": "pnpm pack --dry-run"
141
139
  }
142
- }
140
+ }
@@ -1,22 +1,22 @@
1
- ---
2
- name: install-dsh-image-gen
3
- description: Install, configure, verify, or remove the dsh-image-gen Bundle in a DeepSeek Harness Web profile. Use when a user wants Google, OpenAI-compatible relay, Seedream, DashScope, or local ComfyUI image generation in DSH, cannot find the Image generation settings card, or needs help testing generate_image.
4
- ---
5
-
6
- # Install DSH Image Gen
7
-
8
- 1. Confirm `dsh` runs and record `dsh --version`.
9
- 2. Ask which Web profile to change if the user did not name one. Default to `web` only when that profile already exists.
10
- 3. Install the pinned package or repository spec the user provides:
11
-
12
- ```sh
13
- dsh plugin --profile <profile> add <package-or-git-spec>
14
- ```
15
-
16
- 4. If pnpm blocks the Git dependency's `prepare` script, explain that the allowance executes repository code during installation. Add only the exact package key pnpm reports to the profile's `pnpm-workspace.yaml`, then retry after the user approves.
17
- 5. Verify `dsh --profile <profile> --dump-config` contains the `dsh-image-gen` layer and `image-gen` row.
18
- 6. Start the profile. If port 3080 is already in use, identify the existing DSH process before stopping anything.
19
- 7. In Settings > Plugins > Plugin configuration > Image generation, select a cloud Provider and save its API key, or select Local ComfyUI, enter its URL, and import a ComfyUI API Format workflow JSON containing `{{prompt}}`. Never print, read back, or commit a key.
20
- 8. Test with “生成一张戴墨镜的赛博朋克猫图片”. Confirm one `generate_image` call succeeds and its image renders in the conversation.
21
-
22
- For removal, run `dsh plugin --profile <profile> remove dsh-image-gen`. Do not delete the user's credentials unless they explicitly request it.
1
+ ---
2
+ name: install-dsh-image-gen
3
+ description: Install, configure, verify, or remove the dsh-image-gen Bundle in a DeepSeek Harness Web profile. Use when a user wants Google, OpenAI-compatible relay, Seedream, DashScope, or local ComfyUI image generation in DSH, cannot find the Image generation settings card, or needs help testing generate_image.
4
+ ---
5
+
6
+ # Install DSH Image Gen
7
+
8
+ 1. Confirm `dsh` runs and record `dsh --version`.
9
+ 2. Ask which Web profile to change if the user did not name one. Default to `web` only when that profile already exists.
10
+ 3. Install the pinned package or repository spec the user provides:
11
+
12
+ ```sh
13
+ dsh plugin --profile <profile> add <package-or-git-spec>
14
+ ```
15
+
16
+ 4. If pnpm blocks the Git dependency's `prepare` script, explain that the allowance executes repository code during installation. Add only the exact package key pnpm reports to the profile's `pnpm-workspace.yaml`, then retry after the user approves.
17
+ 5. Verify `dsh --profile <profile> --dump-config` contains the `dsh-image-gen` layer and `image-gen` row.
18
+ 6. Start the profile. If port 3080 is already in use, identify the existing DSH process before stopping anything.
19
+ 7. In Settings > Plugins > Plugin configuration > Image generation, select a cloud Provider and save its API key, or select Local ComfyUI, enter its URL, and import a ComfyUI API Format workflow JSON containing `{{prompt}}`. Never print, read back, or commit a key.
20
+ 8. Test with “生成一张戴墨镜的赛博朋克猫图片”. Confirm one `generate_image` call succeeds and its image renders in the conversation.
21
+
22
+ For removal, run `dsh plugin --profile <profile> remove dsh-image-gen`. Do not delete the user's credentials unless they explicitly request it.
@@ -1,23 +0,0 @@
1
- /**
2
- * Workbench chat panel: the right-side DSH conversation surface.
3
- *
4
- * A dedicated archived agent session lives on the host side (studio-chat.ts);
5
- * this panel pulls its projected event feed through CHAT_ROUTE with adaptive
6
- * polling (?since=<seq> increments; faster while a turn is running, slower
7
- * when idle, paused while the webview is hidden) and submits user turns with
8
- * POST. Tool-generated images are mirrored onto the tldraw canvas through the
9
- * landing queue and upserted into the gallery (the recent list refreshes via
10
- * its subscription). The panel is intentionally unmount-friendly: re-pulls
11
- * from seq 0 on remount, and both landing and gallery writes are deduped by
12
- * attachmentId, so tab switches are safe.
13
- */
14
- import { type FC } from 'react';
15
- /** Workspace scoping mirrored onto gallery records; shape-compatible with StudioWorkspaceProps. */
16
- export interface ChatWorkspaceScope {
17
- workspaceId?: string | undefined;
18
- path?: string | undefined;
19
- }
20
- export declare const StudioChatPanel: FC<{
21
- lang: 'zh' | 'en';
22
- workspace?: ChatWorkspaceScope | null | undefined;
23
- }>;
@@ -1,48 +0,0 @@
1
- /**
2
- * Dedicated DSH agent session backing the workbench chat panel.
3
- *
4
- * The panel is a real DSH conversation driven from the plugin, not a parallel
5
- * chat implementation: on first use the host creates an agent through
6
- * ctx.agents.create (the same factory the sidebar uses), then archives the
7
- * session through ctx.workspaceRegistry so it never appears in the sidebar
8
- * history list while remaining fully usable. The plugin never calls
9
- * sessions.open - archiving the selected session would clear the user's
10
- * current selection - and drives turns purely through agent.followup().
11
- *
12
- * Session events are projected into a small lossless-enough StudioChatEvent
13
- * feed (text turns, tool summaries, generated-image references) and served to
14
- * the browser through CHAT_ROUTE. The browser pulls increments with
15
- * ?since=<seq>; images land on the tldraw canvas from the browser side via
16
- * the existing IMAGE_ROUTE + landing-queue path.
17
- */
18
- import type { IncomingMessage, ServerResponse } from 'node:http';
19
- import type { Context } from '@deepseek-ai/cordis';
20
- import { type StudioChatEvent } from './shared.js';
21
- /** Wire responses for CHAT_ROUTE. */
22
- export interface StudioChatStateResponse {
23
- ok: true;
24
- latestSeq: number;
25
- events: StudioChatEvent[];
26
- /** Why the backing agent is missing, when creation failed; absent otherwise. */
27
- unavailable?: string;
28
- }
29
- export interface StudioChatSendResponse {
30
- ok: true;
31
- }
32
- export interface StudioChatErrorResponse {
33
- error: string;
34
- }
35
- export interface StudioChatDeps {
36
- maxBodyBytes: number;
37
- }
38
- /**
39
- * Install the studio chat: ensure the dedicated agent session, subscribe to
40
- * its events, and return the CHAT_ROUTE handler plus a disposer. Creation
41
- * failures never break the plugin load - the route reports the error and the
42
- * panel shows it, so a host without agent services degrades visibly instead
43
- * of fatally.
44
- */
45
- export declare function createStudioChat(ctx: Context, deps: StudioChatDeps): {
46
- serve: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
47
- dispose(): void;
48
- };