@fungi.computer/darkroom 0.1.0 → 0.2.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.
@@ -13,7 +13,7 @@
13
13
  ### mediaModelsSchema
14
14
 
15
15
  ```ts
16
- const mediaModelsSchema: ZodArray<ZodReadonly<ZodObject<{
16
+ const mediaModelsSchema: ZodLazy<ZodArray<ZodReadonly<ZodObject<{
17
17
  id: ZodString;
18
18
  label: ZodString;
19
19
  kind: ZodEnum<{
@@ -31,62 +31,46 @@ const mediaModelsSchema: ZodArray<ZodReadonly<ZodObject<{
31
31
  jpeg: "jpeg";
32
32
  webp: "webp";
33
33
  }>>>;
34
- input: ZodReadonly<ZodObject<{
34
+ input: ZodLazy<ZodReadonly<ZodObject<{
35
35
  transport: ZodEnum<{
36
- json: "json";
37
- multipart: "multipart";
36
+ json: ...;
37
+ multipart: ...;
38
38
  }>;
39
39
  dimensions: ZodEnum<{
40
- none: "none";
41
- own: "own";
40
+ none: ...;
41
+ own: ...;
42
42
  }>;
43
43
  maxDimension: ZodNullable<ZodNumber>;
44
44
  defaultWidth: ZodNumber;
45
45
  defaultHeight: ZodNumber;
46
46
  steps: ZodEnum<{
47
- steps: "steps";
48
- num_steps: "num_steps";
49
- fixed: "fixed";
47
+ steps: ...;
48
+ num_steps: ...;
49
+ fixed: ...;
50
50
  }>;
51
51
  maxSteps: ZodNullable<ZodNumber>;
52
52
  defaultSteps: ZodNullable<ZodNumber>;
53
53
  referenceField: ZodNullable<ZodString>;
54
54
  maxReferences: ZodNumber;
55
- }, $strict>>;
55
+ }, $strict>>>;
56
56
  sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
57
- video: ZodNullable<ZodReadonly<ZodObject<{
57
+ video: ZodNullable<ZodLazy<ZodReadonly<ZodObject<{
58
58
  minSeconds: ZodNumber;
59
59
  maxSeconds: ZodNumber;
60
60
  defaultSeconds: ZodNumber;
61
- durations: ZodReadonly<ZodArray<ZodNumber>>;
62
- provider: ZodEnum<{
63
- seedance: "seedance";
64
- veo: "veo";
65
- }>;
66
- formats: ZodReadonly<ZodArray<ZodReadonly<...>>>;
67
- defaultResolution: ZodEnum<{
68
- p480: "480p";
69
- p720: "720p";
70
- p1080: "1080p";
71
- p4k: "4k";
72
- }>;
73
- defaultAspectRatio: ZodEnum<{
74
- wide: "16:9";
75
- landscape: "4:3";
76
- square: "1:1";
77
- portrait: "3:4";
78
- tall: "9:16";
79
- ultrawide: "21:9";
80
- ultratall: "9:21";
81
- }>;
82
- defaultGenerateAudio: ZodNullable<ZodBoolean>;
61
+ durations: ZodReadonly<...>;
62
+ provider: ZodEnum<...>;
63
+ formats: ZodReadonly<...>;
64
+ defaultResolution: ZodEnum<...>;
65
+ defaultAspectRatio: ZodEnum<...>;
66
+ defaultGenerateAudio: ZodNullable<...>;
83
67
  maxPromptLength: ZodNumber;
84
- referenceRoles: ZodReadonly<ZodArray<ZodEnum<...>>>;
68
+ referenceRoles: ZodReadonly<...>;
85
69
  maxReferenceImages: ZodNumber;
86
- referenceResolutions: ZodReadonly<ZodArray<ZodEnum<...>>>;
87
- prices: ZodReadonly<ZodArray<ZodReadonly<...>>>;
88
- }, $strict>>>;
89
- }, $strict>>>;
70
+ referenceResolutions: ZodReadonly<...>;
71
+ prices: ZodReadonly<...>;
72
+ }, $strict>>>>;
73
+ }, $strict>>>>;
90
74
  ```
91
75
 
92
76
  Bounded catalog decoded by the App media broker before host filtering.
@@ -165,13 +149,15 @@ Authority refusals emitted by Media admission before a host call.
165
149
  ### appMediaBudgetRefusalSchema
166
150
 
167
151
  ```ts
168
- const appMediaBudgetRefusalSchema: ZodObject<
169
- {
170
- error: ZodLiteral<"attachment_budget_exceeded">;
171
- kind: ZodLiteral<"media">;
172
- retryAfterMs: ZodNumber;
173
- },
174
- $strict
152
+ const appMediaBudgetRefusalSchema: ZodLazy<
153
+ ZodObject<
154
+ {
155
+ error: ZodLiteral<"attachment_budget_exceeded">;
156
+ kind: ZodLiteral<"media">;
157
+ retryAfterMs: ZodNumber;
158
+ },
159
+ $strict
160
+ >
175
161
  >;
176
162
  ```
177
163
 
@@ -195,13 +181,15 @@ const appMediaAdmissionRefusalSchema: ZodUnion<
195
181
  },
196
182
  $strict
197
183
  >,
198
- ZodObject<
199
- {
200
- error: ZodLiteral<"attachment_budget_exceeded">;
201
- kind: ZodLiteral<"media">;
202
- retryAfterMs: ZodNumber;
203
- },
204
- $strict
184
+ ZodLazy<
185
+ ZodObject<
186
+ {
187
+ error: ZodLiteral<"attachment_budget_exceeded">;
188
+ kind: ZodLiteral<"media">;
189
+ retryAfterMs: ZodNumber;
190
+ },
191
+ $strict
192
+ >
205
193
  >,
206
194
  ]
207
195
  >;
@@ -236,12 +224,14 @@ Admission errors plus invalid/oversized inputs emitted directly by the broker.
236
224
  ### agentAppMediaLibraryFailureSchema
237
225
 
238
226
  ```ts
239
- const agentAppMediaLibraryFailureSchema: ZodObject<
240
- {
241
- error: ZodLiteral<"library_unavailable">;
242
- message: ZodString;
243
- },
244
- $strict
227
+ const agentAppMediaLibraryFailureSchema: ZodLazy<
228
+ ZodObject<
229
+ {
230
+ error: ZodLiteral<"library_unavailable">;
231
+ message: ZodString;
232
+ },
233
+ $strict
234
+ >
245
235
  >;
246
236
  ```
247
237
 
@@ -275,6 +265,20 @@ const appMediaBrokerFailureSchema: ZodObject<{
275
265
  destination-write: "destination-write";
276
266
  }>;
277
267
  retryable: ZodBoolean;
268
+ provider: ZodOptional<ZodPipe<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, ZodTransform<
269
+ | Readonly<{
270
+ category: | "InferenceUpstreamError"
271
+ | "AiInternalError"
272
+ | "TypeError"
273
+ | "AbortError"
274
+ | "TimeoutError"
275
+ | "Error";
276
+ code: number | null;
277
+ }>
278
+ | Readonly<{
279
+ category: "result_download";
280
+ status: number;
281
+ }>, unknown>>>;
278
282
  }, $strict>;
279
283
  ```
280
284
 
@@ -295,14 +299,14 @@ const appMediaRefusalSchema: ZodUnion<readonly [ZodObject<{
295
299
  invalid: "invalid";
296
300
  too_large: "too_large";
297
301
  }>;
298
- }, $strict>, ZodObject<{
302
+ }, $strict>, ZodLazy<ZodObject<{
299
303
  error: ZodLiteral<"attachment_budget_exceeded">;
300
304
  kind: ZodLiteral<"media">;
301
305
  retryAfterMs: ZodNumber;
302
- }, $strict>, ZodObject<{
306
+ }, $strict>>, ZodLazy<ZodObject<{
303
307
  error: ZodLiteral<"library_unavailable">;
304
308
  message: ZodString;
305
- }, $strict>, ZodObject<{
309
+ }, $strict>>, ZodObject<{
306
310
  error: ZodEnum<{
307
311
  CAPABILITY_DENIED: "CAPABILITY_DENIED";
308
312
  INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -325,6 +329,15 @@ const appMediaRefusalSchema: ZodUnion<readonly [ZodObject<{
325
329
  destination-write: "destination-write";
326
330
  }>;
327
331
  retryable: ZodBoolean;
332
+ provider: ZodOptional<ZodPipe<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, ZodTransform<
333
+ | Readonly<{
334
+ category: ... | ... | ... | ... | ... | ...;
335
+ code: ... | ...;
336
+ }>
337
+ | Readonly<{
338
+ category: "result_download";
339
+ status: number;
340
+ }>, unknown>>>;
328
341
  }, $strict>]>;
329
342
  ```
330
343
 
@@ -336,7 +349,7 @@ errors.
336
349
  ### appMediaModelsOutcomeSchema
337
350
 
338
351
  ```ts
339
- const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodArray<ZodReadonly<ZodObject<{
352
+ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodLazy<ZodArray<ZodReadonly<ZodObject<{
340
353
  id: ZodString;
341
354
  label: ZodString;
342
355
  kind: ZodEnum<{
@@ -350,50 +363,25 @@ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodArray<ZodReadonly<ZodOb
350
363
  max: "max";
351
364
  }>;
352
365
  outputFormats: ZodReadonly<ZodArray<ZodEnum<{
353
- png: "png";
354
- jpeg: "jpeg";
355
- webp: "webp";
366
+ png: ...;
367
+ jpeg: ...;
368
+ webp: ...;
356
369
  }>>>;
357
- input: ZodReadonly<ZodObject<{
358
- transport: ZodEnum<{
359
- json: ...;
360
- multipart: ...;
361
- }>;
362
- dimensions: ZodEnum<{
363
- none: ...;
364
- own: ...;
365
- }>;
366
- maxDimension: ZodNullable<ZodNumber>;
367
- defaultWidth: ZodNumber;
368
- defaultHeight: ZodNumber;
369
- steps: ZodEnum<{
370
- steps: ...;
371
- num_steps: ...;
372
- fixed: ...;
373
- }>;
374
- maxSteps: ZodNullable<ZodNumber>;
375
- defaultSteps: ZodNullable<ZodNumber>;
376
- referenceField: ZodNullable<ZodString>;
377
- maxReferences: ZodNumber;
378
- }, $strict>>;
379
- sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
380
- video: ZodNullable<ZodReadonly<ZodObject<{
381
- minSeconds: ZodNumber;
382
- maxSeconds: ZodNumber;
383
- defaultSeconds: ZodNumber;
384
- durations: ZodReadonly<...>;
385
- provider: ZodEnum<...>;
386
- formats: ZodReadonly<...>;
387
- defaultResolution: ZodEnum<...>;
388
- defaultAspectRatio: ZodEnum<...>;
389
- defaultGenerateAudio: ZodNullable<...>;
390
- maxPromptLength: ZodNumber;
391
- referenceRoles: ZodReadonly<...>;
392
- maxReferenceImages: ZodNumber;
393
- referenceResolutions: ZodReadonly<...>;
394
- prices: ZodReadonly<...>;
370
+ input: ZodLazy<ZodReadonly<ZodObject<{
371
+ transport: ...;
372
+ dimensions: ...;
373
+ maxDimension: ...;
374
+ defaultWidth: ...;
375
+ defaultHeight: ...;
376
+ steps: ...;
377
+ maxSteps: ...;
378
+ defaultSteps: ...;
379
+ referenceField: ...;
380
+ maxReferences: ...;
395
381
  }, $strict>>>;
396
- }, $strict>>>, ZodUnion<readonly [ZodObject<{
382
+ sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
383
+ video: ZodNullable<ZodLazy<ZodReadonly<ZodObject<..., ...>>>>;
384
+ }, $strict>>>>, ZodUnion<readonly [ZodObject<{
397
385
  error: ZodEnum<{
398
386
  revoked: "revoked";
399
387
  not_granted: "not_granted";
@@ -402,14 +390,14 @@ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodArray<ZodReadonly<ZodOb
402
390
  invalid: "invalid";
403
391
  too_large: "too_large";
404
392
  }>;
405
- }, $strict>, ZodObject<{
393
+ }, $strict>, ZodLazy<ZodObject<{
406
394
  error: ZodLiteral<"attachment_budget_exceeded">;
407
395
  kind: ZodLiteral<"media">;
408
396
  retryAfterMs: ZodNumber;
409
- }, $strict>, ZodObject<{
397
+ }, $strict>>, ZodLazy<ZodObject<{
410
398
  error: ZodLiteral<"library_unavailable">;
411
399
  message: ZodString;
412
- }, $strict>, ZodObject<{
400
+ }, $strict>>, ZodObject<{
413
401
  error: ZodEnum<{
414
402
  CAPABILITY_DENIED: "CAPABILITY_DENIED";
415
403
  INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -432,6 +420,7 @@ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodArray<ZodReadonly<ZodOb
432
420
  destination-write: "destination-write";
433
421
  }>;
434
422
  retryable: ZodBoolean;
423
+ provider: ZodOptional<ZodPipe<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, ZodTransform<Readonly<...> | Readonly<...>, unknown>>>;
435
424
  }, $strict>]>]>;
436
425
  ```
437
426
 
@@ -471,14 +460,14 @@ const appMediaGenerationOutcomeSchema: ZodUnion<readonly [ZodObject<{
471
460
  invalid: "invalid";
472
461
  too_large: "too_large";
473
462
  }>;
474
- }, $strict>, ZodObject<{
463
+ }, $strict>, ZodLazy<ZodObject<{
475
464
  error: ZodLiteral<"attachment_budget_exceeded">;
476
465
  kind: ZodLiteral<"media">;
477
466
  retryAfterMs: ZodNumber;
478
- }, $strict>, ZodObject<{
467
+ }, $strict>>, ZodLazy<ZodObject<{
479
468
  error: ZodLiteral<"library_unavailable">;
480
469
  message: ZodString;
481
- }, $strict>, ZodObject<{
470
+ }, $strict>>, ZodObject<{
482
471
  error: ZodEnum<{
483
472
  CAPABILITY_DENIED: "CAPABILITY_DENIED";
484
473
  INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -501,6 +490,7 @@ const appMediaGenerationOutcomeSchema: ZodUnion<readonly [ZodObject<{
501
490
  destination-write: "destination-write";
502
491
  }>;
503
492
  retryable: ZodBoolean;
493
+ provider: ZodOptional<ZodPipe<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, ZodTransform<Readonly<...> | Readonly<...>, unknown>>>;
504
494
  }, $strict>]>]>;
505
495
  ```
506
496
 
@@ -68,6 +68,20 @@ const mediaFailureSchema: ZodObject<{
68
68
  SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
69
69
  }>;
70
70
  retryable: ZodBoolean;
71
+ provider: ZodOptional<ZodPipe<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, ZodTransform<
72
+ | Readonly<{
73
+ category: | "InferenceUpstreamError"
74
+ | "AiInternalError"
75
+ | "TypeError"
76
+ | "AbortError"
77
+ | "TimeoutError"
78
+ | "Error";
79
+ code: number | null;
80
+ }>
81
+ | Readonly<{
82
+ category: "result_download";
83
+ status: number;
84
+ }>, unknown>>>;
71
85
  }, $strict>;
72
86
  ```
73
87
 
@@ -103,6 +117,21 @@ function readMediaFailure(
103
117
  | "INVALID_ARGUMENT"
104
118
  | "SAFETY_FILTER_REFUSED";
105
119
  retryable: boolean;
120
+ provider?:
121
+ | Readonly<{
122
+ category:
123
+ | "InferenceUpstreamError"
124
+ | "AiInternalError"
125
+ | "TypeError"
126
+ | "AbortError"
127
+ | "TimeoutError"
128
+ | "Error";
129
+ code: number | null;
130
+ }>
131
+ | Readonly<{
132
+ category: "result_download";
133
+ status: number;
134
+ }>;
106
135
  } | null>;
107
136
  ```
108
137
 
@@ -122,5 +151,8 @@ Read and decode one Media host failure at the browser HTTP boundary.
122
151
  \| `"operation"` \| `"normalization"` \| `"artifact"` \|
123
152
  `"destination-authorization"` \| `"destination-write"`; `code`: \|
124
153
  `"CAPABILITY_DENIED"` \| `"INSUFFICIENT_CREDIT"` \| `"HOST_FAILURE"` \|
125
- `"INVALID_ARGUMENT"` \| `"SAFETY_FILTER_REFUSED"`; `retryable`: `boolean`; \} \|
126
- `null`\>
154
+ `"INVALID_ARGUMENT"` \| `"SAFETY_FILTER_REFUSED"`; `retryable`: `boolean`;
155
+ `provider?`: \| `Readonly`\<\{ `category`: \| `"InferenceUpstreamError"` \|
156
+ `"AiInternalError"` \| `"TypeError"` \| `"AbortError"` \| `"TimeoutError"` \|
157
+ `"Error"`; `code`: `number` \| `null`; \}\> \| `Readonly`\<\{ `category`:
158
+ `"result_download"`; `status`: `number`; \}\>; \} \| `null`\>
@@ -63,7 +63,12 @@ read(...input):
63
63
  | "succeeded"
64
64
  | "interrupted";
65
65
  spentFailure: "output_format_mismatch" | null;
66
- providerRefusal: "safety_filter_refused" | null;
66
+ providerFailure: | Readonly<{
67
+ stage: "provider" | "normalization";
68
+ safetyRefused: boolean;
69
+ provider?: MediaProviderDiagnostic;
70
+ }>
71
+ | null;
67
72
  estimatedCostMilliunits: number | null;
68
73
  image: | {
69
74
  bytes: number;
@@ -98,11 +103,12 @@ erasure.
98
103
  `string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
99
104
  `"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
100
105
  `"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
101
- `providerRefusal`: `"safety_filter_refused"` \| `null`;
102
- `estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
103
- `format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
104
- `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
105
- `createdAt`: `number`; `updatedAt`: `number`; \}\> \| `null`
106
+ `providerFailure`: \| `Readonly`\<\{ `stage`: `"provider"` \| `"normalization"`;
107
+ `safetyRefused`: `boolean`; `provider?`: `MediaProviderDiagnostic`; \}\> \|
108
+ `null`; `estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`:
109
+ `number`; `format`: `string`; \} \| `null`; `result`: \| \{ `generationId`:
110
+ `string`; `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \}
111
+ \| `null`; `createdAt`: `number`; `updatedAt`: `number`; \}\> \| `null`
106
112
 
107
113
  ##### preflightErasure()
108
114
 
@@ -248,7 +254,12 @@ dispatchInBackground(...input): Promise<Readonly<{
248
254
  | "succeeded"
249
255
  | "interrupted";
250
256
  spentFailure: "output_format_mismatch" | null;
251
- providerRefusal: "safety_filter_refused" | null;
257
+ providerFailure: | Readonly<{
258
+ stage: "provider" | "normalization";
259
+ safetyRefused: boolean;
260
+ provider?: MediaProviderDiagnostic;
261
+ }>
262
+ | null;
252
263
  estimatedCostMilliunits: number | null;
253
264
  image: | {
254
265
  bytes: number;
@@ -283,11 +294,13 @@ output, and releases the lease so a later retry saves and charges it.
283
294
  `namespace`: `string`; `owner`: `string`; `state`: \| `"admitted"` \|
284
295
  `"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
285
296
  \| `"succeeded"` \| `"interrupted"`; `spentFailure`: `"output_format_mismatch"`
286
- \| `null`; `providerRefusal`: `"safety_filter_refused"` \| `null`;
287
- `estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
288
- `format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
289
- `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
290
- `createdAt`: `number`; `updatedAt`: `number`; \}\>\>
297
+ \| `null`; `providerFailure`: \| `Readonly`\<\{ `stage`: `"provider"` \|
298
+ `"normalization"`; `safetyRefused`: `boolean`; `provider?`:
299
+ `MediaProviderDiagnostic`; \}\> \| `null`; `estimatedCostMilliunits`: `number`
300
+ \| `null`; `image`: \| \{ `bytes`: `number`; `format`: `string`; \} \| `null`;
301
+ `result`: \| \{ `generationId`: `string`; `bytes`: `number`; `format`: `string`;
302
+ `costMilliunits`: `number`; \} \| `null`; `createdAt`: `number`; `updatedAt`:
303
+ `number`; \}\>\>
291
304
 
292
305
  ##### alarm()
293
306
 
@@ -323,9 +336,9 @@ An aborted in-flight provider call is terminal for this request ID.
323
336
 
324
337
  ###### Parameters
325
338
 
326
- | Parameter | Type | Description |
327
- | ---------- | --------------------------------------- | ----------- |
328
- | ...`input` | \[`string`, `"safety_filter_refused"`\] | - |
339
+ | Parameter | Type | Description |
340
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
341
+ | ...`input` | \[`string`, `Readonly`\<\{ `stage`: `"provider"` \| `"normalization"`; `safetyRefused`: `boolean`; `provider?`: `MediaProviderDiagnostic`; \}\>\] | - |
329
342
 
330
343
  ###### Returns
331
344
 
@@ -461,16 +474,6 @@ Release preparation or refused admission so the same request can retry.
461
474
 
462
475
  ## Type Aliases
463
476
 
464
- ### MediaAiResult
465
-
466
- ```ts
467
- type MediaAiResult = Awaited<ReturnType<Ai["run"]>> | MediaProviderWire;
468
- ```
469
-
470
- Native Workers AI output or an already decoded provider representation.
471
-
472
- ---
473
-
474
477
  ### MediaAiPort
475
478
 
476
479
  ```ts
@@ -503,7 +506,7 @@ Dispatch to the native Workers AI binding.
503
506
 
504
507
  ###### Returns
505
508
 
506
- `Promise`\<[`MediaAiResult`](#mediaairesult)\>
509
+ `Promise`\<[`MediaAiResult`](index.md#mediaairesult)\>
507
510
 
508
511
  ---
509
512
 
@@ -649,6 +652,12 @@ Re-exports [MediaOperationRequest](server.md#mediaoperationrequest)
649
652
 
650
653
  ---
651
654
 
655
+ ### MediaAiResult
656
+
657
+ Re-exports [MediaAiResult](index.md#mediaairesult)
658
+
659
+ ---
660
+
652
661
  ### MediaOperationOwner
653
662
 
654
663
  Re-exports [MediaOperationOwner](server.md#mediaoperationowner)