@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,16 @@
1
+ import { z } from "zod";
2
+ /** A result URL every gateway provider must return as plain HTTPS. */
3
+ export declare const resultUrl: z.ZodLazy<z.ZodURL>;
4
+ /** The Unified AI gateway's normalized answer: a completed state and one
5
+ * result URL. Seedance and Veo answer this way; MiniMax does not. */
6
+ export declare const gatewayOutputSchema: z.ZodLazy<z.ZodObject<{
7
+ state: z.ZodOptional<z.ZodLiteral<"Completed">>;
8
+ result: z.ZodObject<{
9
+ image: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
10
+ video: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
11
+ }, z.core.$loose>;
12
+ }, z.core.$loose>>;
13
+ /** Byte ceilings for fetched results; video stays within Worker memory. */
14
+ export declare const GATEWAY_VIDEO_MAX_BYTES: number;
15
+ /** An MP4 carries an `ftyp` box at byte 4. */
16
+ export declare const isMp4: (bytes: Uint8Array) => boolean;
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ /** A result URL every gateway provider must return as plain HTTPS. */
3
+ export const resultUrl = z.lazy(() => z
4
+ .url()
5
+ .refine((value) => value.startsWith("https://"), "result URLs must be HTTPS"));
6
+ /** The Unified AI gateway's normalized answer: a completed state and one
7
+ * result URL. Seedance and Veo answer this way; MiniMax does not. */
8
+ export const gatewayOutputSchema = z.lazy(() => z.looseObject({
9
+ state: z.literal("Completed").optional(),
10
+ result: z.looseObject({
11
+ image: resultUrl.optional(),
12
+ video: resultUrl.optional(),
13
+ }),
14
+ }));
15
+ /** Byte ceilings for fetched results; video stays within Worker memory. */
16
+ export const GATEWAY_VIDEO_MAX_BYTES = 64 * 1024 * 1024;
17
+ /** An MP4 carries an `ftyp` box at byte 4. */
18
+ export const isMp4 = (bytes) => bytes.byteLength > 12 &&
19
+ bytes[4] === 0x66 &&
20
+ bytes[5] === 0x74 &&
21
+ bytes[6] === 0x79 &&
22
+ bytes[7] === 0x70;
@@ -0,0 +1,361 @@
1
+ import * as z from "zod";
2
+ import { type MediaVideoReferenceRole, type MediaVideoModelId, type MediaVideoResolution, type MediaVideoAspectRatio } from "./model-catalog.js";
3
+ export { mediaFailureStageSchema } from "./execution-error.js";
4
+ export { getMediaModel, listMediaModels, mediaModelInputSchema, mediaModelSchema, mediaRequestedImageFormatSchema, mediaModels, mediaModelTierSchema, MediaSettingsError, mediaVideoModelIdSchema, mediaVideoResolutionSchema, mediaVideoAspectRatioSchema, mediaVideoReferenceRoleSchema, mediaVideoFormatSchema, mediaVideoSchema, } from "./model-catalog.js";
5
+ export type { MediaModel, MediaModelInput, MediaModelTier, MediaVideoModelId, MediaVideoResolution, MediaVideoAspectRatio, MediaVideoReferenceRole, MediaVideoModel, MediaVideoFormat, } from "./model-catalog.js";
6
+ /** A reference file selected by the host, with its destination identity and path. */
7
+ export type MediaReference = Readonly<{
8
+ /** Host-admitted destination or reference identity. */
9
+ computerId: string;
10
+ /** Fixed destination or reference file path. */
11
+ path: string;
12
+ /** Video reference role; a single untagged host reference means first frame. */
13
+ role?: MediaVideoReferenceRole;
14
+ }>;
15
+ /** Supported still-image encodings. */
16
+ export type ImageFormat = "png" | "jpeg" | "gif" | "webp";
17
+ /** MIME type corresponding to a supported image encoding. */
18
+ export type ImageMimeType = `image/${ImageFormat}`;
19
+ /** A saved generation: an image, or an MP4 from a video model. */
20
+ export type MediaOutputFormat = ImageFormat | "mp4";
21
+ /** Decoded reference bytes and the dimensions sent to the provider. */
22
+ export type MediaReferenceBytes = Readonly<{
23
+ /** Decoded reference image bytes. */
24
+ bytes: Uint8Array;
25
+ /** Actual reference image encoding. */
26
+ format: ImageFormat;
27
+ /** Reference width in pixels. */
28
+ width: number;
29
+ /** Reference height in pixels. */
30
+ height: number;
31
+ /** Optional filename sent with multipart input. */
32
+ filename?: string;
33
+ }>;
34
+ /** Normalized model settings, including bounded host-selected references. */
35
+ export type MediaGenerationSettings = Readonly<{
36
+ /** Catalog model identifier. */
37
+ model: string;
38
+ /** Trimmed generation prompt. */
39
+ prompt: string;
40
+ /** Requested image width or nominal video resolution/aspect selector. */
41
+ width: number;
42
+ /** Requested image height or nominal video resolution/aspect selector. */
43
+ height: number;
44
+ /** Model-specific inference steps. */
45
+ steps?: number;
46
+ /** Video models only: output length in whole seconds. */
47
+ durationSeconds?: number;
48
+ /** Video resolution selector, normalized from the catalog. */
49
+ resolution?: MediaVideoResolution;
50
+ /** Requested video aspect; a first image may override it upstream. */
51
+ aspectRatio?: MediaVideoAspectRatio;
52
+ /** Audio selection; omitted for Seedance when its default is undocumented. */
53
+ generateAudio?: boolean;
54
+ /** Host-authorized reference files. */
55
+ references?: readonly MediaReference[];
56
+ }>;
57
+ /**
58
+ * One Media provider call: validated settings and reference bytes in, output
59
+ * bytes out. Hosts may bind it to Workers AI or their own transport.
60
+ */
61
+ export type MediaProvider = (settings: MediaGenerationSettings, references: readonly MediaReferenceBytes[], signal?: AbortSignal, outputFormat?: "png" | "jpeg" | "webp") => Promise<Readonly<{
62
+ /** Generated output bytes. */
63
+ bytes: Uint8Array;
64
+ /** Actual output encoding. */
65
+ format: string;
66
+ }>>;
67
+ /** A decoded reference image, scaled within MAX_REFERENCE_DIMENSION. */
68
+ export type FittedReferenceImage = Omit<MediaReferenceBytes, "filename">;
69
+ /** Decode one reference image and scale it within Media's dimension bound. */
70
+ export type ReferenceImageFitter = (bytes: Uint8Array) => Promise<FittedReferenceImage>;
71
+ /** The long-edge bounds a viewer may ask for when fitting an image to look at. */
72
+ export declare const MIN_VIEW_DIMENSION = 256;
73
+ /** Maximum long-edge size accepted by an image viewer, in pixels. */
74
+ export declare const MAX_VIEW_DIMENSION = 512;
75
+ /** Decode a viewer long-edge size within the supported pixel bounds. */
76
+ export declare const viewDimensionSchema: z.ZodLazy<z.ZodNumber>;
77
+ /**
78
+ * Decode one image and re-encode it for a model to look at: scaled within
79
+ * `maxDimension` on the long edge (bounded by {@link viewDimensionSchema}) as
80
+ * a lossy JPEG, so a viewer can step the dimension down to meet a byte budget.
81
+ */
82
+ export type ImageViewFitter = (bytes: Uint8Array, maxDimension: number) => Promise<FittedReferenceImage>;
83
+ /** Maximum reference files in one generation request. */
84
+ export declare const MAX_REFERENCE_COUNT = 4;
85
+ /** Maximum reference width and height sent to inference, in pixels. */
86
+ export declare const MAX_REFERENCE_DIMENSION = 512;
87
+ /** Maximum decoded bytes per reference image. */
88
+ export declare const MAX_REFERENCE_BYTES: number;
89
+ /** Maximum retained still-image output bytes. */
90
+ export declare const MAX_OUTPUT_BYTES: number;
91
+ /** Structural wire grammar for one Media generation request. */
92
+ export declare const mediaGenerationSettingsSchema: z.ZodObject<{
93
+ model: z.ZodString;
94
+ prompt: z.ZodString;
95
+ width: z.ZodNumber;
96
+ height: z.ZodNumber;
97
+ steps: z.ZodOptional<z.ZodNumber>;
98
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
99
+ resolution: z.ZodOptional<z.ZodEnum<{
100
+ readonly p480: "480p";
101
+ readonly p720: "720p";
102
+ readonly p768: "768p";
103
+ readonly p1080: "1080p";
104
+ readonly p4k: "4k";
105
+ }>>;
106
+ aspectRatio: z.ZodOptional<z.ZodEnum<{
107
+ readonly wide: "16:9";
108
+ readonly landscape: "4:3";
109
+ readonly square: "1:1";
110
+ readonly portrait: "3:4";
111
+ readonly tall: "9:16";
112
+ readonly ultrawide: "21:9";
113
+ readonly ultratall: "9:21";
114
+ }>>;
115
+ generateAudio: z.ZodOptional<z.ZodBoolean>;
116
+ references: z.ZodOptional<z.ZodArray<z.ZodObject<{
117
+ computerId: z.ZodString;
118
+ path: z.ZodString;
119
+ role: z.ZodOptional<z.ZodEnum<{
120
+ readonly first: "first-frame";
121
+ readonly last: "last-frame";
122
+ readonly reference: "reference";
123
+ }>>;
124
+ }, z.core.$strict>>>;
125
+ }, z.core.$strict>;
126
+ /** Caller settings before model defaults and refinements are applied. */
127
+ export type MediaGenerationSettingsInput = z.input<typeof mediaGenerationSettingsSchema>;
128
+ /** App selections contain paths; the host supplies the admitted Computer. */
129
+ export declare const mediaGenerationSelectionSchema: z.ZodObject<{
130
+ model: z.ZodString;
131
+ prompt: z.ZodString;
132
+ width: z.ZodNumber;
133
+ height: z.ZodNumber;
134
+ steps: z.ZodOptional<z.ZodNumber>;
135
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
136
+ resolution: z.ZodOptional<z.ZodEnum<{
137
+ readonly p480: "480p";
138
+ readonly p720: "720p";
139
+ readonly p768: "768p";
140
+ readonly p1080: "1080p";
141
+ readonly p4k: "4k";
142
+ }>>;
143
+ aspectRatio: z.ZodOptional<z.ZodEnum<{
144
+ readonly wide: "16:9";
145
+ readonly landscape: "4:3";
146
+ readonly square: "1:1";
147
+ readonly portrait: "3:4";
148
+ readonly tall: "9:16";
149
+ readonly ultrawide: "21:9";
150
+ readonly ultratall: "9:21";
151
+ }>>;
152
+ generateAudio: z.ZodOptional<z.ZodBoolean>;
153
+ references: z.ZodOptional<z.ZodArray<z.ZodObject<{
154
+ path: z.ZodString;
155
+ role: z.ZodOptional<z.ZodEnum<{
156
+ readonly first: "first-frame";
157
+ readonly last: "last-frame";
158
+ readonly reference: "reference";
159
+ }>>;
160
+ }, z.core.$strict>>>;
161
+ }, z.core.$strict>;
162
+ /** Generation settings with reference paths resolved by an admitting host. */
163
+ export type MediaGenerationSelection = z.output<typeof mediaGenerationSelectionSchema>;
164
+ /** Validate caller settings and apply retained model defaults. */
165
+ export declare const validateMediaGenerationSettings: (raw: MediaGenerationSettingsInput) => MediaGenerationSettings;
166
+ /** Validate path-only selections without inventing a Computer identity. */
167
+ export declare const validateMediaGenerationSelection: (raw: z.input<typeof mediaGenerationSelectionSchema>) => Readonly<Omit<MediaGenerationSettings, "references"> & {
168
+ /** Host-authorized reference images. */
169
+ references?: readonly Readonly<{
170
+ /** Fixed destination or reference file path. */
171
+ path: string;
172
+ /** Video-only reference role. */
173
+ role?: MediaVideoReferenceRole;
174
+ }>[];
175
+ }>;
176
+ /** Path-only video reference; the host supplies authority and reads its bytes. */
177
+ export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
178
+ path: z.ZodString;
179
+ role: z.ZodEnum<{
180
+ readonly first: "first-frame";
181
+ readonly last: "last-frame";
182
+ readonly reference: "reference";
183
+ }>;
184
+ }, z.core.$strict>>;
185
+ /** One path-only video reference. */
186
+ export type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
187
+ /** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
188
+ export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
189
+ model: z.ZodEnum<{
190
+ readonly seedance: "bytedance/seedance-2.0";
191
+ readonly seedanceFast: "bytedance/seedance-2.0-fast";
192
+ readonly seedanceMini: "bytedance/seedance-2.0-mini";
193
+ readonly veo: "google/veo-3.1";
194
+ readonly veoFast: "google/veo-3.1-fast";
195
+ readonly minimaxH3Max: "minimax/h3-max";
196
+ }>;
197
+ prompt: z.ZodString;
198
+ resolution: z.ZodOptional<z.ZodEnum<{
199
+ readonly p480: "480p";
200
+ readonly p720: "720p";
201
+ readonly p768: "768p";
202
+ readonly p1080: "1080p";
203
+ readonly p4k: "4k";
204
+ }>>;
205
+ aspectRatio: z.ZodOptional<z.ZodEnum<{
206
+ readonly wide: "16:9";
207
+ readonly landscape: "4:3";
208
+ readonly square: "1:1";
209
+ readonly portrait: "3:4";
210
+ readonly tall: "9:16";
211
+ readonly ultrawide: "21:9";
212
+ readonly ultratall: "9:21";
213
+ }>>;
214
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
215
+ generateAudio: z.ZodOptional<z.ZodBoolean>;
216
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
217
+ path: z.ZodString;
218
+ role: z.ZodEnum<{
219
+ readonly first: "first-frame";
220
+ readonly last: "last-frame";
221
+ readonly reference: "reference";
222
+ }>;
223
+ }, z.core.$strict>>>>;
224
+ }, z.core.$strict>>;
225
+ /** Caller video selection before defaults and model-specific refinements. */
226
+ export type MediaVideoSelectionInput = z.input<typeof mediaVideoSelectionSchema>;
227
+ /** Normalized path-only video settings, ready for host-authorized reference hydration. */
228
+ export type MediaVideoSelection = Readonly<{
229
+ /** Verified catalog video identifier. */
230
+ model: MediaVideoModelId;
231
+ /** Trimmed, bounded prompt. */
232
+ prompt: string;
233
+ /** Nominal width selecting resolution/aspect, not decoded MP4 dimensions. */
234
+ width: number;
235
+ /** Nominal height selecting resolution/aspect, not decoded MP4 dimensions. */
236
+ height: number;
237
+ /** Validated provider resolution. */
238
+ resolution: MediaVideoResolution;
239
+ /** Validated requested aspect. */
240
+ aspectRatio: MediaVideoAspectRatio;
241
+ /** Validated output duration in whole seconds. */
242
+ durationSeconds: number;
243
+ /** Explicit audio choice, omitted for Seedance when unset. */
244
+ generateAudio?: boolean;
245
+ /** Normalized paths and required frame/reference roles. */
246
+ references?: readonly Readonly<MediaVideoReference>[];
247
+ }>;
248
+ /** Validate supported model/size/duration/reference combinations before authority or billing admission. */
249
+ export declare function validateMediaVideoSelection(raw: MediaVideoSelectionInput): MediaVideoSelection;
250
+ /** Host-authorized reader for decoded reference images. */
251
+ export type MediaReferenceReader = Readonly<{
252
+ /** Authorize and read one reference into bounded decoded image bytes. */
253
+ read: (reference: MediaReference) => Promise<MediaReferenceBytes>;
254
+ }>;
255
+ /** Resolve only provider-accepted references through the caller's reader. */
256
+ export declare const resolveMediaReferences: (settings: MediaGenerationSettings, reader: MediaReferenceReader) => Promise<readonly MediaReferenceBytes[]>;
257
+ /** Provider JSON image input for models without multipart references. */
258
+ export type MediaJsonBody = Readonly<{
259
+ /** Generation prompt. */
260
+ prompt: string;
261
+ /** Optional model-native output width. */
262
+ width?: number;
263
+ /** Optional model-native output height. */
264
+ height?: number;
265
+ /** Steps for models using the steps field. */
266
+ steps?: number;
267
+ /** Steps for models using the num_steps field. */
268
+ num_steps?: number;
269
+ }>;
270
+ /** A model-specific JSON body or multipart form ready for transport. */
271
+ export type MediaProviderPayload = Readonly<{
272
+ /** Provider input transport. */
273
+ transport: "json";
274
+ /** Model-native JSON input. */
275
+ body: MediaJsonBody;
276
+ }> | Readonly<{
277
+ /** Provider input transport. */
278
+ transport: "multipart";
279
+ /** Platform-encoded multipart image input. */
280
+ body: FormData;
281
+ }>;
282
+ /** Build the exact JSON or multipart payload required by a retained model. */
283
+ export declare const buildProviderInput: (settings: MediaGenerationSettings, references?: readonly MediaReferenceBytes[]) => MediaProviderPayload;
284
+ /** One image in a provider envelope, encoded inline or available at a URL. */
285
+ export type MediaProviderImageEntry = Readonly<{
286
+ /** Inline base64 image data. */
287
+ base64?: string | undefined;
288
+ /** Inline encoded image data. */
289
+ data?: string | undefined;
290
+ /** HTTP image URL fetched through the host. */
291
+ url?: string | undefined;
292
+ }>;
293
+ /** Parsed provider representation before conversion to bounded image bytes. */
294
+ export type MediaProviderOutput = Readonly<{
295
+ /** Outcome or model-kind discriminant. */
296
+ kind: "bytes";
297
+ /** Generated output bytes. */
298
+ bytes: Uint8Array;
299
+ }> | Readonly<{
300
+ /** Outcome or model-kind discriminant. */
301
+ kind: "response";
302
+ /** Provider response or encoded image response. */
303
+ response: Response;
304
+ }> | Readonly<{
305
+ /** Outcome or model-kind discriminant. */
306
+ kind: "encoded";
307
+ /** Inline provider image representation. */
308
+ encoded: string;
309
+ }> | Readonly<{
310
+ /** Outcome or model-kind discriminant. */
311
+ kind: "entries";
312
+ /** Provider output image entries. */
313
+ entries: readonly MediaProviderImageEntry[];
314
+ }>;
315
+ /** Decode the Workers AI binding's raw output at the provider boundary. */
316
+ export declare const mediaProviderWireSchema: z.ZodLazy<z.ZodUnion<readonly [z.ZodLazy<z.ZodUnion<readonly [z.ZodObject<{
317
+ image: z.ZodString;
318
+ }, z.core.$strip>, z.ZodObject<{
319
+ image: z.ZodArray<z.ZodLazy<z.ZodObject<{
320
+ base64: z.ZodOptional<z.ZodString>;
321
+ data: z.ZodOptional<z.ZodString>;
322
+ url: z.ZodOptional<z.ZodURL>;
323
+ }, z.core.$strict>>>;
324
+ }, z.core.$strip>, z.ZodObject<{
325
+ images: z.ZodArray<z.ZodLazy<z.ZodObject<{
326
+ base64: z.ZodOptional<z.ZodString>;
327
+ data: z.ZodOptional<z.ZodString>;
328
+ url: z.ZodOptional<z.ZodURL>;
329
+ }, z.core.$strict>>>;
330
+ }, z.core.$strip>]>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Response, Response>, z.ZodCustom<ReadableStream<Uint8Array<ArrayBufferLike>>, ReadableStream<Uint8Array<ArrayBufferLike>>>]>>;
331
+ /** Supported raw provider representations, decoded by mediaProviderWireSchema. */
332
+ export type MediaProviderWire = z.output<typeof mediaProviderWireSchema>;
333
+ /** Native Workers AI output or an already decoded provider representation. */
334
+ export type MediaAiResult = Awaited<ReturnType<Ai["run"]>> | MediaProviderWire;
335
+ /** Parse the provider wire envelope before normalization. */
336
+ export declare const parseMediaProviderOutput: (value: MediaProviderWire) => MediaProviderOutput;
337
+ /** Read a successful provider response within an explicit byte bound, closing its reader. */
338
+ export declare const readResponseBytes: (response: Response, maximumBytes: number) => Promise<Uint8Array>;
339
+ /** Host-supplied URL fetching and maximum output bytes for normalization. */
340
+ export type MediaProviderOutputOptions = Readonly<{
341
+ /** Fetch a provider image URL through host-owned transport. */
342
+ fetchUrl?: (url: string) => Promise<Response>;
343
+ /** Maximum output bytes, defaulting to MAX_OUTPUT_BYTES. */
344
+ maxBytes?: number;
345
+ }>;
346
+ /** Normalized bytes and their supported still-image encoding. */
347
+ export type MediaImageOutput = Readonly<{
348
+ /** Bounded decoded provider bytes. */
349
+ bytes: Uint8Array;
350
+ /** Detected or explicitly declared image encoding. */
351
+ format: ImageFormat;
352
+ }>;
353
+ /** Normalize all retained provider envelopes into bounded image bytes. */
354
+ export declare const normalizeMediaProviderOutput: (value: MediaProviderWire, options?: MediaProviderOutputOptions) => Promise<MediaImageOutput>;
355
+ export { estimateImageMilliunits, estimateImageNeurons, } from "./cost-estimate.js";
356
+ export { neuronsToMilliunits, USD_PER_1K_NEURONS } from "./neurons.js";
357
+ export type { ImageParams, ImageReference } from "./cost-estimate.js";
358
+ /** Authority-free video quote settings; hydrated host settings are structurally compatible. */
359
+ export type MediaVideoQuoteSettings = ReturnType<typeof validateMediaGenerationSelection>;
360
+ /** Provider video cost from the sole catalog, in milliunits (1 cent = 1,000). Video-input references are unsupported. */
361
+ export declare function estimateVideoMilliunits(settings: MediaVideoQuoteSettings): number;