dsh-draw 0.1.0

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 (104) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +201 -0
  3. package/README.es.md +194 -0
  4. package/README.hi.md +194 -0
  5. package/README.md +194 -0
  6. package/README.pt.md +194 -0
  7. package/README.zh.md +194 -0
  8. package/SECURITY.md +39 -0
  9. package/THIRD_PARTY_NOTICES.md +21 -0
  10. package/cordis.patch.yml +48 -0
  11. package/lib/client.js +4787 -0
  12. package/lib/client.js.map +1 -0
  13. package/lib/index.js +1429 -0
  14. package/lib/typert.host.js +26 -0
  15. package/lib/types/client/DrawResultCard.d.ts +58 -0
  16. package/lib/types/client/DrawResultCard.d.ts.map +1 -0
  17. package/lib/types/client/DrawResultCard.js +48 -0
  18. package/lib/types/client/DrawSettingsTab.d.ts +31 -0
  19. package/lib/types/client/DrawSettingsTab.d.ts.map +1 -0
  20. package/lib/types/client/DrawSettingsTab.js +129 -0
  21. package/lib/types/client/index.d.ts +35 -0
  22. package/lib/types/client/index.d.ts.map +1 -0
  23. package/lib/types/client/index.js +98 -0
  24. package/lib/types/client/locales.d.ts +14 -0
  25. package/lib/types/client/locales.d.ts.map +1 -0
  26. package/lib/types/client/locales.js +57 -0
  27. package/lib/types/client/present.d.ts +80 -0
  28. package/lib/types/client/present.d.ts.map +1 -0
  29. package/lib/types/client/present.js +86 -0
  30. package/lib/types/client/remote.d.ts +268 -0
  31. package/lib/types/client/remote.d.ts.map +1 -0
  32. package/lib/types/client/remote.js +15 -0
  33. package/lib/types/client/styles.d.ts +11 -0
  34. package/lib/types/client/styles.d.ts.map +1 -0
  35. package/lib/types/client/styles.js +43 -0
  36. package/lib/types/config.d.ts +160 -0
  37. package/lib/types/config.d.ts.map +1 -0
  38. package/lib/types/config.js +230 -0
  39. package/lib/types/drawer.d.ts +114 -0
  40. package/lib/types/drawer.d.ts.map +1 -0
  41. package/lib/types/drawer.js +138 -0
  42. package/lib/types/engine.d.ts +58 -0
  43. package/lib/types/engine.d.ts.map +1 -0
  44. package/lib/types/engine.js +135 -0
  45. package/lib/types/http.d.ts +89 -0
  46. package/lib/types/http.d.ts.map +1 -0
  47. package/lib/types/http.js +127 -0
  48. package/lib/types/index.d.ts +43 -0
  49. package/lib/types/index.d.ts.map +1 -0
  50. package/lib/types/index.js +78 -0
  51. package/lib/types/quota.d.ts +69 -0
  52. package/lib/types/quota.d.ts.map +1 -0
  53. package/lib/types/quota.js +56 -0
  54. package/lib/types/router.d.ts +141 -0
  55. package/lib/types/router.d.ts.map +1 -0
  56. package/lib/types/router.js +207 -0
  57. package/lib/types/sanitize.d.ts +40 -0
  58. package/lib/types/sanitize.d.ts.map +1 -0
  59. package/lib/types/sanitize.js +103 -0
  60. package/lib/types/service.d.ts +59 -0
  61. package/lib/types/service.d.ts.map +1 -0
  62. package/lib/types/service.js +131 -0
  63. package/lib/types/session-events.d.ts +66 -0
  64. package/lib/types/session-events.d.ts.map +1 -0
  65. package/lib/types/session-events.js +32 -0
  66. package/lib/types/tool.d.ts +30 -0
  67. package/lib/types/tool.d.ts.map +1 -0
  68. package/lib/types/tool.js +131 -0
  69. package/lib/types/translate.d.ts +64 -0
  70. package/lib/types/translate.d.ts.map +1 -0
  71. package/lib/types/translate.js +56 -0
  72. package/lib/types/typert.host.d.ts +250 -0
  73. package/lib/types/typert.host.d.ts.map +1 -0
  74. package/lib/types/typert.host.js +23 -0
  75. package/lib/types/version.d.ts +10 -0
  76. package/lib/types/version.d.ts.map +1 -0
  77. package/lib/types/version.js +9 -0
  78. package/lib/types/wire.d.ts +699 -0
  79. package/lib/types/wire.d.ts.map +1 -0
  80. package/lib/types/wire.js +273 -0
  81. package/lib/wire-Cc4JZ3jR.js +4370 -0
  82. package/package.json +179 -0
  83. package/src/client/DrawResultCard.tsx +100 -0
  84. package/src/client/DrawSettingsTab.tsx +159 -0
  85. package/src/client/index.ts +123 -0
  86. package/src/client/locales.ts +84 -0
  87. package/src/client/present.ts +137 -0
  88. package/src/client/remote.ts +44 -0
  89. package/src/client/styles.ts +44 -0
  90. package/src/config.ts +358 -0
  91. package/src/drawer.ts +234 -0
  92. package/src/engine.ts +182 -0
  93. package/src/http.ts +161 -0
  94. package/src/index.ts +93 -0
  95. package/src/quota.ts +98 -0
  96. package/src/router.ts +309 -0
  97. package/src/sanitize.ts +113 -0
  98. package/src/service.ts +169 -0
  99. package/src/session-events.ts +70 -0
  100. package/src/tool.ts +145 -0
  101. package/src/translate.ts +101 -0
  102. package/src/typert.host.ts +25 -0
  103. package/src/version.ts +10 -0
  104. package/src/wire.ts +417 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Pure presentation projections for the dsh-draw browser half: the tool
3
+ * result value and the settings snapshot are folded into view models that the
4
+ * React components render without further logic. Everything here is a pure
5
+ * function of its input, so tests pin the projections without a DOM.
6
+ *
7
+ * @module dsh-draw/client/present
8
+ */
9
+ /**
10
+ * Project one settled `image_generate` tool block onto the card model.
11
+ *
12
+ * @param block - the frozen tool-call block (running or settled).
13
+ * @returns the presented model, or `undefined` when the block is not a settled
14
+ * image_generate result.
15
+ */
16
+ export function presentDrawResult(block) {
17
+ if (!('kind' in block) || block.kind !== 'tool-result' || block.isError)
18
+ return undefined;
19
+ if (block.call?.name !== 'image_generate')
20
+ return undefined;
21
+ const value = block.meta ?? {};
22
+ const images = [];
23
+ if (Array.isArray(value.images)) {
24
+ for (const raw of value.images) {
25
+ const image = raw;
26
+ if (typeof image?.attachmentId === 'string') {
27
+ images.push({ attachmentId: image.attachmentId, name: typeof image.name === 'string' ? image.name : 'image' });
28
+ }
29
+ }
30
+ }
31
+ const quota = (value.quota ?? {});
32
+ const limits = (value.limits ?? {});
33
+ let args;
34
+ if (block.call?.argsRaw !== undefined && block.call.argsRaw !== '') {
35
+ try {
36
+ const parsed = JSON.parse(block.call.argsRaw);
37
+ args = typeof parsed === 'object' && parsed !== null ? parsed : undefined;
38
+ }
39
+ catch {
40
+ args = undefined;
41
+ }
42
+ }
43
+ return {
44
+ engine: typeof value.engine === 'string' ? value.engine : 'unknown',
45
+ model: typeof value.model === 'string' ? value.model : 'unknown',
46
+ fallbackUsed: value.fallbackUsed === true,
47
+ images,
48
+ quota: {
49
+ generations: typeof quota.generations === 'number' ? quota.generations : 0,
50
+ bytes: typeof quota.bytes === 'number' ? quota.bytes : 0,
51
+ },
52
+ limits: {
53
+ maxGenerations: typeof limits.maxGenerations === 'number' ? limits.maxGenerations : 0,
54
+ maxBytes: typeof limits.maxBytes === 'number' ? limits.maxBytes : 0,
55
+ },
56
+ args,
57
+ };
58
+ }
59
+ /**
60
+ * Project the panel snapshot onto the settings row model.
61
+ *
62
+ * @param snapshot - the `draw/status` wire snapshot.
63
+ * @returns the presented panel model.
64
+ */
65
+ export function presentDrawPanel(snapshot) {
66
+ return {
67
+ pluginVersion: snapshot.pluginVersion,
68
+ engines: snapshot.engines.map(engine => ({
69
+ id: engine.id,
70
+ model: engine.model,
71
+ baseUrl: engine.baseUrl,
72
+ apiKeyRef: engine.apiKeyRef,
73
+ enabled: engine.enabled,
74
+ preferred: engine.preferred,
75
+ credentialConfigured: engine.credential.configured,
76
+ ...(engine.credential.source !== undefined ? { credentialSource: engine.credential.source } : {}),
77
+ credentialWritable: engine.credential.writable,
78
+ consecutiveFailures: engine.health.consecutiveFailures,
79
+ coolingDown: engine.health.cooldownUntil !== null && engine.health.cooldownUntil > Date.now(),
80
+ lastError: engine.health.lastError,
81
+ })),
82
+ quota: { maxGenerationsPerSession: snapshot.quota.maxGenerationsPerSession, maxBytesPerSession: snapshot.quota.maxBytesPerSession },
83
+ requestTimeoutMs: snapshot.requestTimeoutMs,
84
+ maxImagesPerCall: snapshot.maxImagesPerCall,
85
+ };
86
+ }
@@ -0,0 +1,268 @@
1
+ /**
2
+ * The client-side Remote face of the `draw` namespace: the hand-written
3
+ * `TypertRemoteContribution` mounted through `ctx.remote.$mount`, plus the
4
+ * declaration merging that types `ctx.remote.draw`. The descriptor list is
5
+ * shared with the host `./typert` manifest (`../wire.ts`), so the two faces
6
+ * can never drift.
7
+ *
8
+ * @module dsh-draw/client/remote
9
+ */
10
+ import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
11
+ import type { CredentialActionResult, DrawProbeResult, DrawRegenerateResult, DrawStatusSnapshot } from '../wire.ts';
12
+ declare module '@deepseek-ai/dsh-typert-protocol' {
13
+ interface TypertRemoteNamespace$draw {
14
+ /** Read the panel snapshot (engines, health, credentials, quota). */
15
+ status: () => Promise<RemoteResult<DrawStatusSnapshot>>;
16
+ /** Probe one engine's connectivity. */
17
+ probe: (engineId: string) => Promise<RemoteResult<DrawProbeResult>>;
18
+ /** Store one API key under the engine's credential reference. */
19
+ setCredential: (engineId: string, value: string) => Promise<RemoteResult<CredentialActionResult>>;
20
+ /** Remove a stored API key. */
21
+ unsetCredential: (engineId: string) => Promise<RemoteResult<CredentialActionResult>>;
22
+ /** Re-run a generation from the result card (full drawer path). */
23
+ regenerate: (sessionId: string, args: Record<string, unknown>) => Promise<RemoteResult<DrawRegenerateResult>>;
24
+ }
25
+ interface TypertRemoteMap {
26
+ 'draw/status': () => Promise<RemoteResult<DrawStatusSnapshot>>;
27
+ 'draw/probe': (engineId: string) => Promise<RemoteResult<DrawProbeResult>>;
28
+ 'draw/setCredential': (engineId: string, value: string) => Promise<RemoteResult<CredentialActionResult>>;
29
+ 'draw/unsetCredential': (engineId: string) => Promise<RemoteResult<CredentialActionResult>>;
30
+ 'draw/regenerate': (sessionId: string, args: Record<string, unknown>) => Promise<RemoteResult<DrawRegenerateResult>>;
31
+ }
32
+ interface TypertRemoteNamespaceMap {
33
+ draw: TypertRemoteNamespace$draw;
34
+ }
35
+ }
36
+ /** The client Remote contribution for the `draw` namespace. */
37
+ export declare const DRAW_REMOTE: Readonly<{
38
+ package: string;
39
+ descriptors: readonly (Readonly<{
40
+ readonly id: 'dsh-draw#draw/status';
41
+ readonly service: 'dsh-draw';
42
+ readonly namespace: 'draw';
43
+ readonly method: 'status';
44
+ readonly invocation: Readonly<{
45
+ kind: "direct";
46
+ }>;
47
+ readonly parameters: readonly never[];
48
+ readonly result: Readonly<{
49
+ mode: "strict";
50
+ typeSymbol: "dsh-draw/types#DrawStatusSnapshot";
51
+ schema: import("zod").ZodObject<{
52
+ pluginVersion: import("zod").ZodString;
53
+ engines: import("zod").ZodArray<import("zod").ZodObject<{
54
+ id: import("zod").ZodString;
55
+ model: import("zod").ZodString;
56
+ baseUrl: import("zod").ZodString;
57
+ apiKeyRef: import("zod").ZodString;
58
+ enabled: import("zod").ZodBoolean;
59
+ preferred: import("zod").ZodBoolean;
60
+ credential: import("zod").ZodObject<{
61
+ configured: import("zod").ZodBoolean;
62
+ source: import("zod").ZodOptional<import("zod").ZodString>;
63
+ writable: import("zod").ZodBoolean;
64
+ }, import("zod/v4/core").$strip>;
65
+ health: import("zod").ZodObject<{
66
+ consecutiveFailures: import("zod").ZodNumber;
67
+ cooldownUntil: import("zod").ZodNullable<import("zod").ZodNumber>;
68
+ lastError: import("zod").ZodNullable<import("zod").ZodString>;
69
+ lastStatus: import("zod").ZodNullable<import("zod").ZodNumber>;
70
+ }, import("zod/v4/core").$strip>;
71
+ }, import("zod/v4/core").$strip>>;
72
+ quota: import("zod").ZodObject<{
73
+ maxGenerationsPerSession: import("zod").ZodNumber;
74
+ maxBytesPerSession: import("zod").ZodNumber;
75
+ }, import("zod/v4/core").$strip>;
76
+ requestTimeoutMs: import("zod").ZodNumber;
77
+ maxImagesPerCall: import("zod").ZodNumber;
78
+ }, import("zod/v4/core").$strip>;
79
+ }>;
80
+ readonly sourceLocation: Readonly<{
81
+ file: "src/wire.ts";
82
+ line: 1;
83
+ column: 1;
84
+ }>;
85
+ }> | Readonly<{
86
+ readonly id: 'dsh-draw#draw/probe';
87
+ readonly service: 'dsh-draw';
88
+ readonly namespace: 'draw';
89
+ readonly method: 'probe';
90
+ readonly invocation: Readonly<{
91
+ kind: "direct";
92
+ }>;
93
+ readonly parameters: readonly Readonly<{
94
+ name: string;
95
+ wire: string;
96
+ source: "json";
97
+ codec: Readonly<{
98
+ mode: "strict";
99
+ typeSymbol: "dsh-draw/types#EngineId";
100
+ schema: import("zod").ZodString;
101
+ }>;
102
+ }>[];
103
+ readonly result: Readonly<{
104
+ mode: "strict";
105
+ typeSymbol: "dsh-draw/types#DrawProbeResult";
106
+ schema: import("zod").ZodObject<{
107
+ engineId: import("zod").ZodString;
108
+ reachable: import("zod").ZodBoolean;
109
+ httpStatus: import("zod").ZodNullable<import("zod").ZodNumber>;
110
+ target: import("zod").ZodString;
111
+ note: import("zod").ZodString;
112
+ credentialConfigured: import("zod").ZodBoolean;
113
+ }, import("zod/v4/core").$strip>;
114
+ }>;
115
+ readonly sourceLocation: Readonly<{
116
+ file: "src/wire.ts";
117
+ line: 1;
118
+ column: 1;
119
+ }>;
120
+ }> | Readonly<{
121
+ readonly id: 'dsh-draw#draw/setCredential';
122
+ readonly service: 'dsh-draw';
123
+ readonly namespace: 'draw';
124
+ readonly method: 'setCredential';
125
+ readonly invocation: Readonly<{
126
+ kind: "direct";
127
+ }>;
128
+ readonly parameters: readonly (Readonly<{
129
+ name: string;
130
+ wire: string;
131
+ source: "json";
132
+ codec: Readonly<{
133
+ mode: "strict";
134
+ typeSymbol: "dsh-draw/types#EngineId";
135
+ schema: import("zod").ZodString;
136
+ }>;
137
+ }> | Readonly<{
138
+ name: string;
139
+ wire: string;
140
+ source: "json";
141
+ codec: Readonly<{
142
+ mode: "strict";
143
+ typeSymbol: "dsh-draw/types#CredentialValue";
144
+ schema: import("zod").ZodString;
145
+ }>;
146
+ }>)[];
147
+ readonly result: Readonly<{
148
+ mode: "strict";
149
+ typeSymbol: "dsh-draw/types#CredentialActionResult";
150
+ schema: import("zod").ZodObject<{
151
+ engineId: import("zod").ZodString;
152
+ reference: import("zod").ZodString;
153
+ note: import("zod").ZodString;
154
+ }, import("zod/v4/core").$strip>;
155
+ }>;
156
+ readonly sourceLocation: Readonly<{
157
+ file: "src/wire.ts";
158
+ line: 1;
159
+ column: 1;
160
+ }>;
161
+ }> | Readonly<{
162
+ readonly id: 'dsh-draw#draw/unsetCredential';
163
+ readonly service: 'dsh-draw';
164
+ readonly namespace: 'draw';
165
+ readonly method: 'unsetCredential';
166
+ readonly invocation: Readonly<{
167
+ kind: "direct";
168
+ }>;
169
+ readonly parameters: readonly Readonly<{
170
+ name: string;
171
+ wire: string;
172
+ source: "json";
173
+ codec: Readonly<{
174
+ mode: "strict";
175
+ typeSymbol: "dsh-draw/types#EngineId";
176
+ schema: import("zod").ZodString;
177
+ }>;
178
+ }>[];
179
+ readonly result: Readonly<{
180
+ mode: "strict";
181
+ typeSymbol: "dsh-draw/types#CredentialActionResult";
182
+ schema: import("zod").ZodObject<{
183
+ engineId: import("zod").ZodString;
184
+ reference: import("zod").ZodString;
185
+ note: import("zod").ZodString;
186
+ }, import("zod/v4/core").$strip>;
187
+ }>;
188
+ readonly sourceLocation: Readonly<{
189
+ file: "src/wire.ts";
190
+ line: 1;
191
+ column: 1;
192
+ }>;
193
+ }> | Readonly<{
194
+ readonly id: 'dsh-draw#draw/regenerate';
195
+ readonly service: 'dsh-draw';
196
+ readonly namespace: 'draw';
197
+ readonly method: 'regenerate';
198
+ readonly invocation: Readonly<{
199
+ kind: "direct";
200
+ }>;
201
+ readonly parameters: readonly (Readonly<{
202
+ name: string;
203
+ wire: string;
204
+ source: "json";
205
+ codec: Readonly<{
206
+ mode: "strict";
207
+ typeSymbol: "dsh-draw/types#SessionId";
208
+ schema: import("zod").ZodString;
209
+ }>;
210
+ }> | Readonly<{
211
+ name: string;
212
+ wire: string;
213
+ source: "json";
214
+ codec: Readonly<{
215
+ mode: "strict";
216
+ typeSymbol: "dsh-draw/types#RegenerateArgs";
217
+ schema: import("zod").ZodObject<{
218
+ prompt: import("zod").ZodString;
219
+ size: import("zod").ZodOptional<import("zod").ZodString>;
220
+ count: import("zod").ZodOptional<import("zod").ZodNumber>;
221
+ quality: import("zod").ZodOptional<import("zod").ZodString>;
222
+ style: import("zod").ZodOptional<import("zod").ZodString>;
223
+ engine: import("zod").ZodOptional<import("zod").ZodString>;
224
+ }, import("zod/v4/core").$loose>;
225
+ }>;
226
+ }>)[];
227
+ readonly result: Readonly<{
228
+ mode: "strict";
229
+ typeSymbol: "dsh-draw/types#DrawRegenerateResult";
230
+ schema: import("zod").ZodObject<{
231
+ engine: import("zod").ZodString;
232
+ model: import("zod").ZodString;
233
+ size: import("zod").ZodString;
234
+ images: import("zod").ZodArray<import("zod").ZodObject<{
235
+ attachmentId: import("zod").ZodString;
236
+ mediaType: import("zod").ZodString;
237
+ bytes: import("zod").ZodNumber;
238
+ width: import("zod").ZodNumber;
239
+ height: import("zod").ZodNumber;
240
+ name: import("zod").ZodOptional<import("zod").ZodString>;
241
+ }, import("zod/v4/core").$strip>>;
242
+ quota: import("zod").ZodObject<{
243
+ generations: import("zod").ZodNumber;
244
+ bytes: import("zod").ZodNumber;
245
+ }, import("zod/v4/core").$strip>;
246
+ quotaLimits: import("zod").ZodObject<{
247
+ maxGenerations: import("zod").ZodNumber;
248
+ maxBytes: import("zod").ZodNumber;
249
+ }, import("zod/v4/core").$strip>;
250
+ fallbackUsed: import("zod").ZodBoolean;
251
+ elapsedMs: import("zod").ZodNumber;
252
+ attempts: import("zod").ZodArray<import("zod").ZodObject<{
253
+ engine: import("zod").ZodString;
254
+ phase: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<"credential">, import("zod").ZodLiteral<"request">, import("zod").ZodLiteral<"parse">]>>;
255
+ code: import("zod").ZodString;
256
+ message: import("zod").ZodOptional<import("zod").ZodString>;
257
+ status: import("zod").ZodOptional<import("zod").ZodNumber>;
258
+ }, import("zod/v4/core").$strip>>;
259
+ }, import("zod/v4/core").$strip>;
260
+ }>;
261
+ readonly sourceLocation: Readonly<{
262
+ file: "src/wire.ts";
263
+ line: 1;
264
+ column: 1;
265
+ }>;
266
+ }>)[];
267
+ }>;
268
+ //# sourceMapping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,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACxG,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;QAC3F,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAAA;KACrH;IACD,UAAU,wBAAwB;QAChC,IAAI,EAAE,0BAA0B,CAAA;KACjC;CACF;AAED,+DAA+D;AAC/D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGa,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The client-side Remote face of the `draw` namespace: the hand-written
3
+ * `TypertRemoteContribution` mounted through `ctx.remote.$mount`, plus the
4
+ * declaration merging that types `ctx.remote.draw`. The descriptor list is
5
+ * shared with the host `./typert` manifest (`../wire.ts`), so the two faces
6
+ * can never drift.
7
+ *
8
+ * @module dsh-draw/client/remote
9
+ */
10
+ import { DRAW_INVOCATIONS } from '../wire.js';
11
+ /** The client Remote contribution for the `draw` namespace. */
12
+ export const DRAW_REMOTE = Object.freeze({
13
+ package: 'dsh-draw',
14
+ descriptors: DRAW_INVOCATIONS,
15
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scoped inline stylesheet for the dsh-draw browser half. Standalone client
3
+ * bundles cannot use the in-repo CSS-module pipeline, so the styles live in
4
+ * one scoped `style` element; every class carries the `dshdraw-` prefix and
5
+ * the root node is the only position the stylesheet may leak from.
6
+ *
7
+ * @module dsh-draw/client/styles
8
+ */
9
+ /** Install the scoped stylesheet once; returns the removal disposer. */
10
+ export declare function installDrawStyles(): () => void;
11
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/client/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,wEAAwE;AACxE,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CA+B9C"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Scoped inline stylesheet for the dsh-draw browser half. Standalone client
3
+ * bundles cannot use the in-repo CSS-module pipeline, so the styles live in
4
+ * one scoped `style` element; every class carries the `dshdraw-` prefix and
5
+ * the root node is the only position the stylesheet may leak from.
6
+ *
7
+ * @module dsh-draw/client/styles
8
+ */
9
+ const STYLE_ID = 'dsh-draw-client-styles';
10
+ /** Install the scoped stylesheet once; returns the removal disposer. */
11
+ export function installDrawStyles() {
12
+ if (document.getElementById(STYLE_ID) !== null)
13
+ return () => undefined;
14
+ const style = document.createElement('style');
15
+ style.id = STYLE_ID;
16
+ style.textContent = `
17
+ .dshdraw-card { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
18
+ .dshdraw-grid { display: flex; flex-wrap: wrap; gap: 8px; }
19
+ .dshdraw-figure { display: flex; flex-direction: column; gap: 4px; max-width: 320px; }
20
+ .dshdraw-figure img { max-width: 100%; border-radius: 6px; border: 1px solid var(--dsh-border, #d0d7de); }
21
+ .dshdraw-figure figcaption { font-size: 11px; opacity: 0.75; overflow-wrap: anywhere; }
22
+ .dshdraw-meta { font-size: 12px; opacity: 0.85; display: flex; flex-wrap: wrap; gap: 12px; }
23
+ .dshdraw-actions { display: flex; gap: 8px; }
24
+ .dshdraw-button {
25
+ border: 1px solid var(--dsh-border, #d0d7de); border-radius: 6px; background: transparent;
26
+ padding: 3px 10px; font-size: 12px; cursor: pointer; color: inherit;
27
+ }
28
+ .dshdraw-button:hover { background: var(--dsh-hover, rgba(0, 0, 0, 0.05)); }
29
+ .dshdraw-panel { display: flex; flex-direction: column; gap: 14px; }
30
+ .dshdraw-engine { border: 1px solid var(--dsh-border, #d0d7de); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
31
+ .dshdraw-engine h4 { margin: 0; }
32
+ .dshdraw-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
33
+ .dshdraw-row label { opacity: 0.8; min-width: 110px; }
34
+ .dshdraw-badge { border-radius: 999px; padding: 1px 8px; font-size: 11px; border: 1px solid var(--dsh-border, #d0d7de); }
35
+ .dshdraw-badge.ok { color: #1a7f37; border-color: #1a7f37; }
36
+ .dshdraw-badge.warn { color: #9a6700; border-color: #9a6700; }
37
+ .dshdraw-input { flex: 1; min-width: 180px; border: 1px solid var(--dsh-border, #d0d7de); border-radius: 6px; padding: 4px 8px; font-size: 12px; background: transparent; color: inherit; }
38
+ `;
39
+ document.head.append(style);
40
+ return () => {
41
+ style.remove();
42
+ };
43
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Plugin configuration for `dsh-draw` and its explicit resolve step.
3
+ * `resolveConfig` re-judges every default and bound so programmatic
4
+ * construction that bypasses Schemastery normalization still fails loud
5
+ * instead of running with hidden defaults (the explicit-resolve contract).
6
+ *
7
+ * @module dsh-draw/config
8
+ */
9
+ import z from '@deepseek-ai/schemastery';
10
+ import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
11
+ /** Default per-generation HTTP timeout in milliseconds. */
12
+ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 120000;
13
+ /** Ceiling for one generation call: engines can take minutes per image. */
14
+ export declare const MAX_REQUEST_TIMEOUT_MS = 600000;
15
+ /** Default cap on images a single call may produce. */
16
+ export declare const DEFAULT_MAX_IMAGES_PER_CALL = 4;
17
+ /** Ceiling on images a single call may produce. */
18
+ export declare const MAX_IMAGES_PER_CALL = 10;
19
+ /** Default prompt length cap (characters). */
20
+ export declare const DEFAULT_MAX_PROMPT_LENGTH = 4000;
21
+ /** Ceiling on the prompt length cap. */
22
+ export declare const MAX_PROMPT_LENGTH = 32000;
23
+ /** Default per-session generation-call cap. */
24
+ export declare const DEFAULT_MAX_GENERATIONS_PER_SESSION = 200;
25
+ /** Ceiling on the per-session generation-call cap. */
26
+ export declare const MAX_GENERATIONS_PER_SESSION = 100000;
27
+ /** Default per-session image-byte cap (200 MiB). */
28
+ export declare const DEFAULT_MAX_BYTES_PER_SESSION: number;
29
+ /** Ceiling on the per-session image-byte cap (4 GiB). */
30
+ export declare const MAX_BYTES_PER_SESSION: number;
31
+ /** Default consecutive failures before an engine enters cooldown. */
32
+ export declare const DEFAULT_FAILURE_THRESHOLD = 2;
33
+ /** Ceiling on the consecutive-failure threshold. */
34
+ export declare const MAX_FAILURE_THRESHOLD = 10;
35
+ /** Default engine cooldown after the failure threshold trips (ms). */
36
+ export declare const DEFAULT_COOLDOWN_MS = 60000;
37
+ /** Ceiling on the engine cooldown. */
38
+ export declare const MAX_COOLDOWN_MS = 3600000;
39
+ /** Standard size vocabulary mapped per engine through {@link EngineConfig.sizeMap}. */
40
+ export type StandardSize = 'square' | 'landscape' | 'portrait' | 'auto';
41
+ /** Per-engine mapping from the standard size vocabulary to concrete engine sizes. */
42
+ export interface EngineSizeMap {
43
+ /** Square composition (the default). */
44
+ square: string;
45
+ /** Wider-than-tall composition. */
46
+ landscape: string;
47
+ /** Taller-than-wide composition. */
48
+ portrait: string;
49
+ /** Engine-chosen composition; may alias one of the concrete sizes. */
50
+ auto: string;
51
+ }
52
+ /** Whether generated images arrive as base64 payloads or downloadable URLs. */
53
+ export type EngineResponseFormat = 'b64_json' | 'url';
54
+ /** One OpenAI-compatible image-generation endpoint the router may use. */
55
+ export interface EngineConfig {
56
+ /** Stable engine id used in tool args, results, and the settings panel. */
57
+ id: string;
58
+ /** OpenAI-compatible API root, e.g. `https://api.openai.com/v1`; must not embed credentials. */
59
+ baseUrl: string;
60
+ /** Engine model name sent in the request body, e.g. `gpt-image-1`. */
61
+ model: string;
62
+ /** Credential reference (environment-variable name) the API key resolves from; never a literal key. */
63
+ apiKeyRef: string;
64
+ /** Whether the router may use this engine (default true). */
65
+ enabled?: boolean;
66
+ /** Standard-size → concrete-size translation (default: the OpenAI sizes). */
67
+ sizeMap?: EngineSizeMap;
68
+ /** Whether the engine accepts the `quality` request field (default false). */
69
+ qualitySupported?: boolean;
70
+ /** Whether the engine accepts the `style` request field (default false). */
71
+ styleSupported?: boolean;
72
+ /** How generated bytes arrive: base64 in the response or a URL to download (default `b64_json`). */
73
+ responseFormat?: EngineResponseFormat;
74
+ /** Declared media type of the bytes (default `image/png`). */
75
+ imageMediaType?: ImageMediaType;
76
+ }
77
+ /** Plugin configuration. */
78
+ export interface Config {
79
+ /** Ordered engine chain; the router walks it top-down and falls back on failure. */
80
+ engines?: EngineConfig[];
81
+ /** Engine id the router prefers; defaults to the first configured engine. Must name a configured engine. */
82
+ defaultEngine?: string;
83
+ /** Per-generation HTTP timeout in milliseconds (default 120000). */
84
+ requestTimeoutMs?: number;
85
+ /** Cap on images one call may produce (default 4). */
86
+ maxImagesPerCall?: number;
87
+ /** Prompt length cap in characters (default 4000). */
88
+ maxPromptLength?: number;
89
+ /** Per-session generation-call cap (default 200). */
90
+ maxGenerationsPerSession?: number;
91
+ /** Per-session generated-image byte cap (default 209715200). */
92
+ maxBytesPerSession?: number;
93
+ /** Consecutive failures before an engine enters cooldown (default 2). */
94
+ failureThreshold?: number;
95
+ /** Engine cooldown in milliseconds after the failure threshold trips (default 60000). */
96
+ cooldownMs?: number;
97
+ }
98
+ /** The two shipped engine presets: OpenAI Images and Zhipu CogView. */
99
+ export declare const DEFAULT_ENGINES: ReadonlyArray<Required<EngineConfig>>;
100
+ /** Default size map for user-configured engines (the OpenAI vocabulary). */
101
+ export declare const DEFAULT_SIZE_MAP: Readonly<EngineSizeMap>;
102
+ /** Fully resolved per-engine configuration. */
103
+ export interface ResolvedEngineConfig {
104
+ /** Stable engine id. */
105
+ id: string;
106
+ /** OpenAI-compatible API root without credentials. */
107
+ baseUrl: string;
108
+ /** Engine model name. */
109
+ model: string;
110
+ /** Credential reference the API key resolves from. */
111
+ apiKeyRef: string;
112
+ /** Whether the router may use this engine. */
113
+ enabled: boolean;
114
+ /** Standard-size → concrete-size translation. */
115
+ sizeMap: EngineSizeMap;
116
+ /** Whether the engine accepts the `quality` request field. */
117
+ qualitySupported: boolean;
118
+ /** Whether the engine accepts the `style` request field. */
119
+ styleSupported: boolean;
120
+ /** How generated bytes arrive. */
121
+ responseFormat: EngineResponseFormat;
122
+ /** Declared media type of the bytes. */
123
+ imageMediaType: ImageMediaType;
124
+ }
125
+ /** Fully resolved configuration captured at plugin load. */
126
+ export interface ResolvedConfig {
127
+ /** Ordered engine chain. */
128
+ engines: readonly ResolvedEngineConfig[];
129
+ /** Engine id the router prefers. */
130
+ defaultEngine: string;
131
+ /** Per-generation HTTP timeout in milliseconds. */
132
+ requestTimeoutMs: number;
133
+ /** Cap on images one call may produce. */
134
+ maxImagesPerCall: number;
135
+ /** Prompt length cap in characters. */
136
+ maxPromptLength: number;
137
+ /** Per-session generation-call cap. */
138
+ maxGenerationsPerSession: number;
139
+ /** Per-session generated-image byte cap. */
140
+ maxBytesPerSession: number;
141
+ /** Consecutive failures before an engine enters cooldown. */
142
+ failureThreshold: number;
143
+ /** Engine cooldown in milliseconds after the failure threshold trips. */
144
+ cooldownMs: number;
145
+ }
146
+ /** Schemastery schema for loader-validated configuration. */
147
+ export declare const Config: z<Config>;
148
+ /**
149
+ * Resolve raw config to the runtime policy, re-validating defaults and bounds
150
+ * plus the cross-field facts a per-field schema cannot see (duplicate engine
151
+ * ids, credential-bearing base URLs, an unknown default engine).
152
+ *
153
+ * @param config - raw loader config; `undefined` for a bare row.
154
+ * @returns the frozen resolved config.
155
+ * @throws on any invalid value (fail-loud at load).
156
+ */
157
+ export declare function resolveConfig(config: Config | undefined): ResolvedConfig;
158
+ /** Engine id by which an engine is addressed, or `undefined` for an unknown id. */
159
+ export declare function engineById(config: ResolvedConfig, id: string): ResolvedEngineConfig | undefined;
160
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAEjE,2DAA2D;AAC3D,eAAO,MAAM,0BAA0B,SAAU,CAAA;AAEjD,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,SAAU,CAAA;AAE7C,uDAAuD;AACvD,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,OAAQ,CAAA;AAE9C,wCAAwC;AACxC,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC,+CAA+C;AAC/C,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,SAAU,CAAA;AAElD,oDAAoD;AACpD,eAAO,MAAM,6BAA6B,QAAoB,CAAA;AAE9D,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,QAAyB,CAAA;AAE3D,qEAAqE;AACrE,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAE1C,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAEvC,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,QAAS,CAAA;AAEzC,sCAAsC;AACtC,eAAO,MAAM,eAAe,UAAY,CAAA;AAExC,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAA;AAEvE,qFAAqF;AACrF,MAAM,WAAW,aA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