@fungi.computer/darkroom 0.0.0-stage → 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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +315 -2
  3. package/dist/app-media-contracts.d.ts +499 -0
  4. package/dist/app-media-contracts.js +96 -0
  5. package/dist/browser-failure.d.ts +40 -0
  6. package/dist/browser-failure.js +39 -0
  7. package/dist/browser.d.ts +2 -0
  8. package/dist/browser.js +1 -0
  9. package/dist/cloudflare/provider.d.ts +13 -0
  10. package/dist/cloudflare/provider.js +140 -0
  11. package/dist/cloudflare/reference-images.d.ts +42 -0
  12. package/dist/cloudflare/reference-images.js +102 -0
  13. package/dist/cloudflare.d.ts +6 -0
  14. package/dist/cloudflare.js +4 -0
  15. package/dist/cost-estimate.d.ts +22 -0
  16. package/dist/cost-estimate.js +76 -0
  17. package/dist/effect.d.ts +2 -0
  18. package/dist/effect.js +2 -0
  19. package/dist/execution-error.d.ts +54 -0
  20. package/dist/execution-error.js +62 -0
  21. package/dist/failure.d.ts +2 -0
  22. package/dist/failure.js +8 -0
  23. package/dist/gateway-models.d.ts +23 -0
  24. package/dist/gateway-models.js +77 -0
  25. package/dist/gateway-wire.d.ts +16 -0
  26. package/dist/gateway-wire.js +22 -0
  27. package/dist/index.d.ts +361 -0
  28. package/dist/index.js +607 -0
  29. package/dist/media-binding.d.ts +291 -0
  30. package/dist/media-binding.js +149 -0
  31. package/dist/media-generation.d.ts +10 -0
  32. package/dist/media-generation.js +110 -0
  33. package/dist/media-operation-contract.d.ts +104 -0
  34. package/dist/media-operation-contract.js +29 -0
  35. package/dist/media-operation-do.d.ts +55 -0
  36. package/dist/media-operation-do.js +105 -0
  37. package/dist/media-operation-owner.d.ts +301 -0
  38. package/dist/media-operation-owner.js +903 -0
  39. package/dist/media-operation-storage.d.ts +81 -0
  40. package/dist/media-operation-storage.js +1 -0
  41. package/dist/media-operation.d.ts +33 -0
  42. package/dist/media-operation.js +230 -0
  43. package/dist/model-catalog.d.ts +456 -0
  44. package/dist/model-catalog.js +565 -0
  45. package/dist/neurons.d.ts +4 -0
  46. package/dist/neurons.js +4 -0
  47. package/dist/provenance-bytes.d.ts +3 -0
  48. package/dist/provenance-bytes.js +15 -0
  49. package/dist/provenance-export.d.ts +23 -0
  50. package/dist/provenance-export.js +103 -0
  51. package/dist/provenance-jpeg.d.ts +3 -0
  52. package/dist/provenance-jpeg.js +76 -0
  53. package/dist/provenance-png.d.ts +1 -0
  54. package/dist/provenance-png.js +21 -0
  55. package/dist/provenance-xmp.d.ts +2 -0
  56. package/dist/provenance-xmp.js +54 -0
  57. package/dist/provenance.d.ts +20 -0
  58. package/dist/provenance.js +58 -0
  59. package/dist/server.d.ts +158 -0
  60. package/dist/server.js +207 -0
  61. package/dist/video-providers/index.d.ts +14 -0
  62. package/dist/video-providers/index.js +14 -0
  63. package/dist/video-providers/minimax.d.ts +25 -0
  64. package/dist/video-providers/minimax.js +63 -0
  65. package/dist/video-providers/reference-encoding.d.ts +4 -0
  66. package/dist/video-providers/reference-encoding.js +11 -0
  67. package/dist/video-providers/types.d.ts +28 -0
  68. package/dist/video-providers/types.js +1 -0
  69. package/dist/video-providers/unified.d.ts +18 -0
  70. package/dist/video-providers/unified.js +52 -0
  71. package/docs/api/README.md +16 -0
  72. package/docs/api/app-media-contracts.md +507 -0
  73. package/docs/api/browser.md +126 -0
  74. package/docs/api/cloudflare.md +678 -0
  75. package/docs/api/effect.md +39 -0
  76. package/docs/api/index.md +1775 -0
  77. package/docs/api/modules.md +19 -0
  78. package/docs/api/provenance-export.md +114 -0
  79. package/docs/api/server.md +1672 -0
  80. package/package.json +110 -3
@@ -0,0 +1,499 @@
1
+ import * as z from "zod";
2
+ /** Bounded catalog decoded by the App media broker before host filtering. */
3
+ export declare const mediaModelsSchema: z.ZodLazy<z.ZodArray<z.ZodReadonly<z.ZodObject<{
4
+ id: z.ZodString;
5
+ label: z.ZodString;
6
+ kind: z.ZodEnum<{
7
+ readonly image: "image";
8
+ readonly video: "video";
9
+ }>;
10
+ tier: z.ZodEnum<{
11
+ readonly draft: "draft";
12
+ readonly balanced: "balanced";
13
+ readonly premium: "premium";
14
+ readonly max: "max";
15
+ }>;
16
+ outputFormats: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
17
+ readonly png: "png";
18
+ readonly jpeg: "jpeg";
19
+ readonly webp: "webp";
20
+ }>>>;
21
+ input: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
22
+ transport: z.ZodEnum<{
23
+ readonly json: "json";
24
+ readonly multipart: "multipart";
25
+ }>;
26
+ dimensions: z.ZodEnum<{
27
+ readonly none: "none";
28
+ readonly own: "own";
29
+ }>;
30
+ maxDimension: z.ZodNullable<z.ZodNumber>;
31
+ defaultWidth: z.ZodNumber;
32
+ defaultHeight: z.ZodNumber;
33
+ steps: z.ZodEnum<{
34
+ readonly steps: "steps";
35
+ readonly num_steps: "num_steps";
36
+ readonly fixed: "fixed";
37
+ }>;
38
+ maxSteps: z.ZodNullable<z.ZodNumber>;
39
+ defaultSteps: z.ZodNullable<z.ZodNumber>;
40
+ referenceField: z.ZodNullable<z.ZodString>;
41
+ maxReferences: z.ZodNumber;
42
+ }, z.core.$strict>>>;
43
+ sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
44
+ video: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
45
+ minSeconds: z.ZodNumber;
46
+ maxSeconds: z.ZodNumber;
47
+ defaultSeconds: z.ZodNumber;
48
+ durations: z.ZodReadonly<z.ZodArray<z.ZodNumber>>;
49
+ provider: z.ZodEnum<{
50
+ readonly seedance: "seedance";
51
+ readonly veo: "veo";
52
+ readonly minimax: "minimax";
53
+ }>;
54
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
55
+ resolution: z.ZodEnum<{
56
+ readonly p480: "480p";
57
+ readonly p720: "720p";
58
+ readonly p768: "768p";
59
+ readonly p1080: "1080p";
60
+ readonly p4k: "4k";
61
+ }>;
62
+ aspectRatio: z.ZodEnum<{
63
+ readonly wide: "16:9";
64
+ readonly landscape: "4:3";
65
+ readonly square: "1:1";
66
+ readonly portrait: "3:4";
67
+ readonly tall: "9:16";
68
+ readonly ultrawide: "21:9";
69
+ readonly ultratall: "9:21";
70
+ }>;
71
+ width: z.ZodNumber;
72
+ height: z.ZodNumber;
73
+ }, z.core.$strict>>>>>;
74
+ defaultResolution: z.ZodEnum<{
75
+ readonly p480: "480p";
76
+ readonly p720: "720p";
77
+ readonly p768: "768p";
78
+ readonly p1080: "1080p";
79
+ readonly p4k: "4k";
80
+ }>;
81
+ defaultAspectRatio: z.ZodEnum<{
82
+ readonly wide: "16:9";
83
+ readonly landscape: "4:3";
84
+ readonly square: "1:1";
85
+ readonly portrait: "3:4";
86
+ readonly tall: "9:16";
87
+ readonly ultrawide: "21:9";
88
+ readonly ultratall: "9:21";
89
+ }>;
90
+ defaultGenerateAudio: z.ZodNullable<z.ZodBoolean>;
91
+ maxPromptLength: z.ZodNumber;
92
+ referenceRoles: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
93
+ readonly first: "first-frame";
94
+ readonly last: "last-frame";
95
+ readonly reference: "reference";
96
+ }>>>;
97
+ maxReferenceImages: z.ZodNumber;
98
+ referenceResolutions: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
99
+ readonly p480: "480p";
100
+ readonly p720: "720p";
101
+ readonly p768: "768p";
102
+ readonly p1080: "1080p";
103
+ readonly p4k: "4k";
104
+ }>>>;
105
+ prices: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
106
+ resolution: z.ZodEnum<{
107
+ readonly p480: "480p";
108
+ readonly p720: "720p";
109
+ readonly p768: "768p";
110
+ readonly p1080: "1080p";
111
+ readonly p4k: "4k";
112
+ }>;
113
+ silentMilliunitsPerSecond: z.ZodNumber;
114
+ audioMilliunitsPerSecond: z.ZodNumber;
115
+ }, z.core.$strict>>>>;
116
+ }, z.core.$strict>>>>;
117
+ }, z.core.$strict>>>>;
118
+ /** An absolute output path on the Computer admitted by the App host. */
119
+ export declare const destinationSchema: z.ZodObject<{
120
+ computerId: z.ZodString;
121
+ path: z.ZodString;
122
+ }, z.core.$strict>;
123
+ /** Completed App generation output, with its admitted Computer destination. */
124
+ export declare const appMediaGenerationResultSchema: z.ZodObject<{
125
+ format: z.ZodEnum<{
126
+ readonly png: "png";
127
+ readonly jpeg: "jpeg";
128
+ readonly gif: "gif";
129
+ readonly webp: "webp";
130
+ readonly mp4: "mp4";
131
+ }>;
132
+ width: z.ZodNumber;
133
+ height: z.ZodNumber;
134
+ bytes: z.ZodNumber;
135
+ model: z.ZodString;
136
+ costMilliunits: z.ZodNumber;
137
+ destination: z.ZodObject<{
138
+ computerId: z.ZodString;
139
+ path: z.ZodString;
140
+ }, z.core.$strict>;
141
+ }, z.core.$strict>;
142
+ /** Authority refusals emitted by Media admission before a host call. */
143
+ export declare const appMediaAdmissionErrorSchema: z.ZodObject<{
144
+ error: z.ZodEnum<{
145
+ /** The captured App selection or attachment changed. */
146
+ readonly revoked: "revoked";
147
+ /** The caller does not hold this Media grant. */
148
+ readonly not_granted: "not_granted";
149
+ /** The attachment's grantor no longer holds authority. */
150
+ readonly grantor_lost_authority: "grantor_lost_authority";
151
+ /** Admission could not resolve the current resource. */
152
+ readonly unavailable: "unavailable";
153
+ }>;
154
+ }, z.core.$strict>;
155
+ /** Attachment budget refusal emitted by the Media reservation owner. */
156
+ export declare const appMediaBudgetRefusalSchema: z.ZodLazy<z.ZodObject<{
157
+ error: z.ZodLiteral<"attachment_budget_exceeded">;
158
+ kind: z.ZodLiteral<"media">;
159
+ retryAfterMs: z.ZodNumber;
160
+ }, z.core.$strict>>;
161
+ /** Existing Media admission refusals, without an admitted selector or callable. */
162
+ export declare const appMediaAdmissionRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
163
+ error: z.ZodEnum<{
164
+ /** The captured App selection or attachment changed. */
165
+ readonly revoked: "revoked";
166
+ /** The caller does not hold this Media grant. */
167
+ readonly not_granted: "not_granted";
168
+ /** The attachment's grantor no longer holds authority. */
169
+ readonly grantor_lost_authority: "grantor_lost_authority";
170
+ /** Admission could not resolve the current resource. */
171
+ readonly unavailable: "unavailable";
172
+ }>;
173
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
174
+ error: z.ZodLiteral<"attachment_budget_exceeded">;
175
+ kind: z.ZodLiteral<"media">;
176
+ retryAfterMs: z.ZodNumber;
177
+ }, z.core.$strict>>]>;
178
+ /** Admission errors plus invalid/oversized inputs emitted directly by the broker. */
179
+ export declare const appMediaBrokerErrorSchema: z.ZodObject<{
180
+ error: z.ZodEnum<{
181
+ /** The broker refused the input representation or selection. */
182
+ readonly invalid: "invalid";
183
+ /** The input exceeds the existing broker byte ceiling. */
184
+ readonly too_large: "too_large";
185
+ /** The captured App selection or attachment changed. */
186
+ readonly revoked: "revoked";
187
+ /** The caller does not hold this Media grant. */
188
+ readonly not_granted: "not_granted";
189
+ /** The attachment's grantor no longer holds authority. */
190
+ readonly grantor_lost_authority: "grantor_lost_authority";
191
+ /** Admission could not resolve the current resource. */
192
+ readonly unavailable: "unavailable";
193
+ }>;
194
+ }, z.core.$strict>;
195
+ /** Missing-library refusal decoded and returned by the App media broker. */
196
+ export declare const agentAppMediaLibraryFailureSchema: z.ZodLazy<z.ZodObject<{
197
+ error: z.ZodLiteral<"library_unavailable">;
198
+ message: z.ZodString;
199
+ }, z.core.$strict>>;
200
+ /** Broker projection of an HTTP failure: code becomes error and error becomes message. */
201
+ export declare const appMediaBrokerFailureSchema: z.ZodObject<{
202
+ error: z.ZodEnum<{
203
+ readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
204
+ readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
205
+ readonly HOST_FAILURE: "HOST_FAILURE";
206
+ readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
207
+ readonly SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
208
+ }>;
209
+ message: z.ZodString;
210
+ stage: z.ZodEnum<{
211
+ readonly admission: "admission";
212
+ readonly "generation-authorization": "generation-authorization";
213
+ readonly settings: "settings";
214
+ readonly estimate: "estimate";
215
+ readonly billing: "billing";
216
+ readonly operation: "operation";
217
+ readonly provider: "provider";
218
+ readonly normalization: "normalization";
219
+ readonly artifact: "artifact";
220
+ readonly "destination-authorization": "destination-authorization";
221
+ readonly "destination-write": "destination-write";
222
+ }>;
223
+ retryable: z.ZodBoolean;
224
+ }, z.core.$strict>;
225
+ /** Refusal payloads emitted by the App media broker, separate from transport errors. */
226
+ export declare const appMediaRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
227
+ error: z.ZodEnum<{
228
+ /** The broker refused the input representation or selection. */
229
+ readonly invalid: "invalid";
230
+ /** The input exceeds the existing broker byte ceiling. */
231
+ readonly too_large: "too_large";
232
+ /** The captured App selection or attachment changed. */
233
+ readonly revoked: "revoked";
234
+ /** The caller does not hold this Media grant. */
235
+ readonly not_granted: "not_granted";
236
+ /** The attachment's grantor no longer holds authority. */
237
+ readonly grantor_lost_authority: "grantor_lost_authority";
238
+ /** Admission could not resolve the current resource. */
239
+ readonly unavailable: "unavailable";
240
+ }>;
241
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
242
+ error: z.ZodLiteral<"attachment_budget_exceeded">;
243
+ kind: z.ZodLiteral<"media">;
244
+ retryAfterMs: z.ZodNumber;
245
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
246
+ error: z.ZodLiteral<"library_unavailable">;
247
+ message: z.ZodString;
248
+ }, z.core.$strict>>, z.ZodObject<{
249
+ error: z.ZodEnum<{
250
+ readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
251
+ readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
252
+ readonly HOST_FAILURE: "HOST_FAILURE";
253
+ readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
254
+ readonly SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
255
+ }>;
256
+ message: z.ZodString;
257
+ stage: z.ZodEnum<{
258
+ readonly admission: "admission";
259
+ readonly "generation-authorization": "generation-authorization";
260
+ readonly settings: "settings";
261
+ readonly estimate: "estimate";
262
+ readonly billing: "billing";
263
+ readonly operation: "operation";
264
+ readonly provider: "provider";
265
+ readonly normalization: "normalization";
266
+ readonly artifact: "artifact";
267
+ readonly "destination-authorization": "destination-authorization";
268
+ readonly "destination-write": "destination-write";
269
+ }>;
270
+ retryable: z.ZodBoolean;
271
+ }, z.core.$strict>]>;
272
+ /** Model-list payload or an existing broker refusal. */
273
+ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodLazy<z.ZodArray<z.ZodReadonly<z.ZodObject<{
274
+ id: z.ZodString;
275
+ label: z.ZodString;
276
+ kind: z.ZodEnum<{
277
+ readonly image: "image";
278
+ readonly video: "video";
279
+ }>;
280
+ tier: z.ZodEnum<{
281
+ readonly draft: "draft";
282
+ readonly balanced: "balanced";
283
+ readonly premium: "premium";
284
+ readonly max: "max";
285
+ }>;
286
+ outputFormats: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
287
+ readonly png: "png";
288
+ readonly jpeg: "jpeg";
289
+ readonly webp: "webp";
290
+ }>>>;
291
+ input: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
292
+ transport: z.ZodEnum<{
293
+ readonly json: "json";
294
+ readonly multipart: "multipart";
295
+ }>;
296
+ dimensions: z.ZodEnum<{
297
+ readonly none: "none";
298
+ readonly own: "own";
299
+ }>;
300
+ maxDimension: z.ZodNullable<z.ZodNumber>;
301
+ defaultWidth: z.ZodNumber;
302
+ defaultHeight: z.ZodNumber;
303
+ steps: z.ZodEnum<{
304
+ readonly steps: "steps";
305
+ readonly num_steps: "num_steps";
306
+ readonly fixed: "fixed";
307
+ }>;
308
+ maxSteps: z.ZodNullable<z.ZodNumber>;
309
+ defaultSteps: z.ZodNullable<z.ZodNumber>;
310
+ referenceField: z.ZodNullable<z.ZodString>;
311
+ maxReferences: z.ZodNumber;
312
+ }, z.core.$strict>>>;
313
+ sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
314
+ video: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
315
+ minSeconds: z.ZodNumber;
316
+ maxSeconds: z.ZodNumber;
317
+ defaultSeconds: z.ZodNumber;
318
+ durations: z.ZodReadonly<z.ZodArray<z.ZodNumber>>;
319
+ provider: z.ZodEnum<{
320
+ readonly seedance: "seedance";
321
+ readonly veo: "veo";
322
+ readonly minimax: "minimax";
323
+ }>;
324
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
325
+ resolution: z.ZodEnum<{
326
+ readonly p480: "480p";
327
+ readonly p720: "720p";
328
+ readonly p768: "768p";
329
+ readonly p1080: "1080p";
330
+ readonly p4k: "4k";
331
+ }>;
332
+ aspectRatio: z.ZodEnum<{
333
+ readonly wide: "16:9";
334
+ readonly landscape: "4:3";
335
+ readonly square: "1:1";
336
+ readonly portrait: "3:4";
337
+ readonly tall: "9:16";
338
+ readonly ultrawide: "21:9";
339
+ readonly ultratall: "9:21";
340
+ }>;
341
+ width: z.ZodNumber;
342
+ height: z.ZodNumber;
343
+ }, z.core.$strict>>>>>;
344
+ defaultResolution: z.ZodEnum<{
345
+ readonly p480: "480p";
346
+ readonly p720: "720p";
347
+ readonly p768: "768p";
348
+ readonly p1080: "1080p";
349
+ readonly p4k: "4k";
350
+ }>;
351
+ defaultAspectRatio: z.ZodEnum<{
352
+ readonly wide: "16:9";
353
+ readonly landscape: "4:3";
354
+ readonly square: "1:1";
355
+ readonly portrait: "3:4";
356
+ readonly tall: "9:16";
357
+ readonly ultrawide: "21:9";
358
+ readonly ultratall: "9:21";
359
+ }>;
360
+ defaultGenerateAudio: z.ZodNullable<z.ZodBoolean>;
361
+ maxPromptLength: z.ZodNumber;
362
+ referenceRoles: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
363
+ readonly first: "first-frame";
364
+ readonly last: "last-frame";
365
+ readonly reference: "reference";
366
+ }>>>;
367
+ maxReferenceImages: z.ZodNumber;
368
+ referenceResolutions: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
369
+ readonly p480: "480p";
370
+ readonly p720: "720p";
371
+ readonly p768: "768p";
372
+ readonly p1080: "1080p";
373
+ readonly p4k: "4k";
374
+ }>>>;
375
+ prices: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
376
+ resolution: z.ZodEnum<{
377
+ readonly p480: "480p";
378
+ readonly p720: "720p";
379
+ readonly p768: "768p";
380
+ readonly p1080: "1080p";
381
+ readonly p4k: "4k";
382
+ }>;
383
+ silentMilliunitsPerSecond: z.ZodNumber;
384
+ audioMilliunitsPerSecond: z.ZodNumber;
385
+ }, z.core.$strict>>>>;
386
+ }, z.core.$strict>>>>;
387
+ }, z.core.$strict>>>>, z.ZodUnion<readonly [z.ZodObject<{
388
+ error: z.ZodEnum<{
389
+ /** The broker refused the input representation or selection. */
390
+ readonly invalid: "invalid";
391
+ /** The input exceeds the existing broker byte ceiling. */
392
+ readonly too_large: "too_large";
393
+ /** The captured App selection or attachment changed. */
394
+ readonly revoked: "revoked";
395
+ /** The caller does not hold this Media grant. */
396
+ readonly not_granted: "not_granted";
397
+ /** The attachment's grantor no longer holds authority. */
398
+ readonly grantor_lost_authority: "grantor_lost_authority";
399
+ /** Admission could not resolve the current resource. */
400
+ readonly unavailable: "unavailable";
401
+ }>;
402
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
403
+ error: z.ZodLiteral<"attachment_budget_exceeded">;
404
+ kind: z.ZodLiteral<"media">;
405
+ retryAfterMs: z.ZodNumber;
406
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
407
+ error: z.ZodLiteral<"library_unavailable">;
408
+ message: z.ZodString;
409
+ }, z.core.$strict>>, z.ZodObject<{
410
+ error: z.ZodEnum<{
411
+ readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
412
+ readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
413
+ readonly HOST_FAILURE: "HOST_FAILURE";
414
+ readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
415
+ readonly SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
416
+ }>;
417
+ message: z.ZodString;
418
+ stage: z.ZodEnum<{
419
+ readonly admission: "admission";
420
+ readonly "generation-authorization": "generation-authorization";
421
+ readonly settings: "settings";
422
+ readonly estimate: "estimate";
423
+ readonly billing: "billing";
424
+ readonly operation: "operation";
425
+ readonly provider: "provider";
426
+ readonly normalization: "normalization";
427
+ readonly artifact: "artifact";
428
+ readonly "destination-authorization": "destination-authorization";
429
+ readonly "destination-write": "destination-write";
430
+ }>;
431
+ retryable: z.ZodBoolean;
432
+ }, z.core.$strict>]>]>;
433
+ /** Completed generation, Agar polling result, or an existing broker refusal. */
434
+ export declare const appMediaGenerationOutcomeSchema: z.ZodUnion<readonly [z.ZodObject<{
435
+ format: z.ZodEnum<{
436
+ readonly png: "png";
437
+ readonly jpeg: "jpeg";
438
+ readonly gif: "gif";
439
+ readonly webp: "webp";
440
+ readonly mp4: "mp4";
441
+ }>;
442
+ width: z.ZodNumber;
443
+ height: z.ZodNumber;
444
+ bytes: z.ZodNumber;
445
+ model: z.ZodString;
446
+ costMilliunits: z.ZodNumber;
447
+ destination: z.ZodObject<{
448
+ computerId: z.ZodString;
449
+ path: z.ZodString;
450
+ }, z.core.$strict>;
451
+ }, z.core.$strict>, z.ZodObject<{
452
+ kind: z.ZodLiteral<"pending">;
453
+ retryAfterMs: z.ZodNumber;
454
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
455
+ error: z.ZodEnum<{
456
+ /** The broker refused the input representation or selection. */
457
+ readonly invalid: "invalid";
458
+ /** The input exceeds the existing broker byte ceiling. */
459
+ readonly too_large: "too_large";
460
+ /** The captured App selection or attachment changed. */
461
+ readonly revoked: "revoked";
462
+ /** The caller does not hold this Media grant. */
463
+ readonly not_granted: "not_granted";
464
+ /** The attachment's grantor no longer holds authority. */
465
+ readonly grantor_lost_authority: "grantor_lost_authority";
466
+ /** Admission could not resolve the current resource. */
467
+ readonly unavailable: "unavailable";
468
+ }>;
469
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
470
+ error: z.ZodLiteral<"attachment_budget_exceeded">;
471
+ kind: z.ZodLiteral<"media">;
472
+ retryAfterMs: z.ZodNumber;
473
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
474
+ error: z.ZodLiteral<"library_unavailable">;
475
+ message: z.ZodString;
476
+ }, z.core.$strict>>, z.ZodObject<{
477
+ error: z.ZodEnum<{
478
+ readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
479
+ readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
480
+ readonly HOST_FAILURE: "HOST_FAILURE";
481
+ readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
482
+ readonly SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
483
+ }>;
484
+ message: z.ZodString;
485
+ stage: z.ZodEnum<{
486
+ readonly admission: "admission";
487
+ readonly "generation-authorization": "generation-authorization";
488
+ readonly settings: "settings";
489
+ readonly estimate: "estimate";
490
+ readonly billing: "billing";
491
+ readonly operation: "operation";
492
+ readonly provider: "provider";
493
+ readonly normalization: "normalization";
494
+ readonly artifact: "artifact";
495
+ readonly "destination-authorization": "destination-authorization";
496
+ readonly "destination-write": "destination-write";
497
+ }>;
498
+ retryable: z.ZodBoolean;
499
+ }, z.core.$strict>]>]>;
@@ -0,0 +1,96 @@
1
+ import * as z from "zod";
2
+ import { listMediaModels, mediaModelSchema } from "./model-catalog.js";
3
+ import { mediaResultSchema } from "./media-operation-contract.js";
4
+ import { pendingSchema } from "@fungi.computer/agar/backend-definition";
5
+ import { mediaFailureSchema } from "./browser-failure.js";
6
+ /** Bounded catalog decoded by the App media broker before host filtering. */
7
+ export const mediaModelsSchema = z.lazy(() => z.array(mediaModelSchema).max(listMediaModels().length));
8
+ /** An absolute output path on the Computer admitted by the App host. */
9
+ export const destinationSchema = z.strictObject({
10
+ /** Computer admitted by the host. */
11
+ computerId: z.string().min(1).max(256),
12
+ /** Absolute Computer output path. */
13
+ path: z.string().startsWith("/").max(1_024),
14
+ });
15
+ /** Completed App generation output, with its admitted Computer destination. */
16
+ export const appMediaGenerationResultSchema = mediaResultSchema
17
+ .omit({ path: true })
18
+ .extend({
19
+ /** Admitted Computer and absolute output path. */
20
+ destination: destinationSchema,
21
+ });
22
+ /** Authority refusals emitted by Media admission before a host call. */
23
+ export const appMediaAdmissionErrorSchema = z.strictObject({
24
+ /** Existing admission refusal code. */
25
+ error: z.enum({
26
+ /** The captured App selection or attachment changed. */
27
+ revoked: "revoked",
28
+ /** The caller does not hold this Media grant. */
29
+ not_granted: "not_granted",
30
+ /** The attachment's grantor no longer holds authority. */
31
+ grantor_lost_authority: "grantor_lost_authority",
32
+ /** Admission could not resolve the current resource. */
33
+ unavailable: "unavailable",
34
+ }),
35
+ });
36
+ /** Attachment budget refusal emitted by the Media reservation owner. */
37
+ export const appMediaBudgetRefusalSchema = z.lazy(() => z.strictObject({
38
+ /** The attachment's operation budget refused this request. */
39
+ error: z.literal("attachment_budget_exceeded"),
40
+ /** Media reservations use the Media budget, not exec or write. */
41
+ kind: z.literal("media"),
42
+ /** Delay emitted by the reservation owner. */
43
+ retryAfterMs: z.number(),
44
+ }));
45
+ /** Existing Media admission refusals, without an admitted selector or callable. */
46
+ export const appMediaAdmissionRefusalSchema = z.union([
47
+ appMediaAdmissionErrorSchema,
48
+ appMediaBudgetRefusalSchema,
49
+ ]);
50
+ /** Admission errors plus invalid/oversized inputs emitted directly by the broker. */
51
+ export const appMediaBrokerErrorSchema = appMediaAdmissionErrorSchema.extend({
52
+ /** Existing broker refusal code. */
53
+ error: z.enum({
54
+ ...appMediaAdmissionErrorSchema.shape.error.enum,
55
+ /** The broker refused the input representation or selection. */
56
+ invalid: "invalid",
57
+ /** The input exceeds the existing broker byte ceiling. */
58
+ too_large: "too_large",
59
+ }),
60
+ });
61
+ /** Missing-library refusal decoded and returned by the App media broker. */
62
+ export const agentAppMediaLibraryFailureSchema = z.lazy(() => z.strictObject({
63
+ /** The calling Installation's library is unavailable. */
64
+ error: z.literal("library_unavailable"),
65
+ /** Existing library-owner presentation copy. */
66
+ message: z.string().max(4096),
67
+ }));
68
+ /** Broker projection of an HTTP failure: code becomes error and error becomes message. */
69
+ export const appMediaBrokerFailureSchema = z.strictObject({
70
+ /** Original typed HTTP failure code. */
71
+ error: mediaFailureSchema.shape.code,
72
+ /** Original HTTP failure presentation copy. */
73
+ message: mediaFailureSchema.shape.error,
74
+ /** Original failure stage. */
75
+ stage: mediaFailureSchema.shape.stage,
76
+ /** Original retry truth. */
77
+ retryable: mediaFailureSchema.shape.retryable,
78
+ });
79
+ /** Refusal payloads emitted by the App media broker, separate from transport errors. */
80
+ export const appMediaRefusalSchema = z.union([
81
+ appMediaBrokerErrorSchema,
82
+ appMediaBudgetRefusalSchema,
83
+ agentAppMediaLibraryFailureSchema,
84
+ appMediaBrokerFailureSchema,
85
+ ]);
86
+ /** Model-list payload or an existing broker refusal. */
87
+ export const appMediaModelsOutcomeSchema = z.union([
88
+ mediaModelsSchema,
89
+ appMediaRefusalSchema,
90
+ ]);
91
+ /** Completed generation, Agar polling result, or an existing broker refusal. */
92
+ export const appMediaGenerationOutcomeSchema = z.union([
93
+ appMediaGenerationResultSchema,
94
+ pendingSchema,
95
+ appMediaRefusalSchema,
96
+ ]);
@@ -0,0 +1,40 @@
1
+ import * as z from "zod";
2
+ /** Host diagnostic sink; generation errors and retry truth remain transport-owned. */
3
+ export type MediaGenerationDiagnostic = (operation: "app_media_pending_response_unavailable" | "media_failure_body_read_failed", cause: unknown, details?: Readonly<{
4
+ /** HTTP response status when the diagnostic concerns a response. */
5
+ status: number;
6
+ }>) => void;
7
+ /** Sanitized HTTP refusal emitted by a Media host and decoded at the browser boundary. */
8
+ export declare const mediaFailureSchema: z.ZodObject<{
9
+ error: z.ZodString;
10
+ stage: z.ZodEnum<{
11
+ readonly admission: "admission";
12
+ readonly "generation-authorization": "generation-authorization";
13
+ readonly settings: "settings";
14
+ readonly estimate: "estimate";
15
+ readonly billing: "billing";
16
+ readonly operation: "operation";
17
+ readonly provider: "provider";
18
+ readonly normalization: "normalization";
19
+ readonly artifact: "artifact";
20
+ readonly "destination-authorization": "destination-authorization";
21
+ readonly "destination-write": "destination-write";
22
+ }>;
23
+ code: z.ZodEnum<{
24
+ /** Host admission or Computer access was denied. */
25
+ readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
26
+ /** Host billing did not admit this attempt. */
27
+ readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
28
+ /** The host could not complete generation or saving. */
29
+ readonly HOST_FAILURE: "HOST_FAILURE";
30
+ /** The host refused the selected input. */
31
+ readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
32
+ /** The model's safety filter refused generation. */
33
+ readonly SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED";
34
+ }>;
35
+ retryable: z.ZodBoolean;
36
+ }, z.core.$strict>;
37
+ /** Sanitized Media failure carried from the authenticated host to Agar. */
38
+ export type MediaFailure = z.output<typeof mediaFailureSchema>;
39
+ /** Read and decode one Media host failure at the browser HTTP boundary. */
40
+ export declare function readMediaFailure(response: Response, diagnostic?: MediaGenerationDiagnostic): Promise<MediaFailure | null>;
@@ -0,0 +1,39 @@
1
+ import * as z from "zod";
2
+ import { mediaFailureStageSchema } from "./execution-error.js";
3
+ import { Option, Schema } from "effect";
4
+ import { reportCatchFailure } from "./failure.js";
5
+ /** Sanitized HTTP refusal emitted by a Media host and decoded at the browser boundary. */
6
+ export const mediaFailureSchema = z.strictObject({
7
+ /** Host-supplied presentation copy. */
8
+ error: z.string().min(1).max(512),
9
+ /** The failed generation or save stage. */
10
+ stage: mediaFailureStageSchema,
11
+ /** Typed refusal reason; the host retains retry truth. */
12
+ code: z.enum({
13
+ /** Host admission or Computer access was denied. */
14
+ CAPABILITY_DENIED: "CAPABILITY_DENIED",
15
+ /** Host billing did not admit this attempt. */
16
+ INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT",
17
+ /** The host could not complete generation or saving. */
18
+ HOST_FAILURE: "HOST_FAILURE",
19
+ /** The host refused the selected input. */
20
+ INVALID_ARGUMENT: "INVALID_ARGUMENT",
21
+ /** The model's safety filter refused generation. */
22
+ SAFETY_FILTER_REFUSED: "SAFETY_FILTER_REFUSED",
23
+ }),
24
+ /** Whether repeating this exact attempt may recover. */
25
+ retryable: z.boolean(),
26
+ });
27
+ const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Json));
28
+ function parseMediaFailureJson(json) {
29
+ const parsed = mediaFailureSchema.safeParse(Option.getOrUndefined(decodeJson(json)));
30
+ return parsed.success ? parsed.data : null;
31
+ }
32
+ /** Read and decode one Media host failure at the browser HTTP boundary. */
33
+ export async function readMediaFailure(response, diagnostic = reportCatchFailure) {
34
+ const json = await response.text().catch((cause) => {
35
+ diagnostic("media_failure_body_read_failed", cause);
36
+ return null;
37
+ });
38
+ return json === null ? null : parseMediaFailureJson(json);
39
+ }
@@ -0,0 +1,2 @@
1
+ export { mediaFailureSchema, readMediaFailure } from "./browser-failure.js";
2
+ export type { MediaFailure, MediaGenerationDiagnostic, } from "./browser-failure.js";
@@ -0,0 +1 @@
1
+ export { mediaFailureSchema, readMediaFailure } from "./browser-failure.js";