@fungi.computer/darkroom 0.0.1 → 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.
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod";
2
2
  /** Bounded catalog decoded by the App media broker before host filtering. */
3
- export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
3
+ export declare const mediaModelsSchema: z.ZodLazy<z.ZodArray<z.ZodReadonly<z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  label: z.ZodString;
6
6
  kind: z.ZodEnum<{
@@ -18,7 +18,7 @@ export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
18
18
  readonly jpeg: "jpeg";
19
19
  readonly webp: "webp";
20
20
  }>>>;
21
- input: z.ZodReadonly<z.ZodObject<{
21
+ input: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
22
22
  transport: z.ZodEnum<{
23
23
  readonly json: "json";
24
24
  readonly multipart: "multipart";
@@ -39,9 +39,9 @@ export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
39
39
  defaultSteps: z.ZodNullable<z.ZodNumber>;
40
40
  referenceField: z.ZodNullable<z.ZodString>;
41
41
  maxReferences: z.ZodNumber;
42
- }, z.core.$strict>>;
42
+ }, z.core.$strict>>>;
43
43
  sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
44
- video: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
44
+ video: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
45
45
  minSeconds: z.ZodNumber;
46
46
  maxSeconds: z.ZodNumber;
47
47
  defaultSeconds: z.ZodNumber;
@@ -51,7 +51,7 @@ export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
51
51
  readonly veo: "veo";
52
52
  readonly minimax: "minimax";
53
53
  }>;
54
- formats: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
54
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
55
55
  resolution: z.ZodEnum<{
56
56
  readonly p480: "480p";
57
57
  readonly p720: "720p";
@@ -70,7 +70,7 @@ export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
70
70
  }>;
71
71
  width: z.ZodNumber;
72
72
  height: z.ZodNumber;
73
- }, z.core.$strict>>>>;
73
+ }, z.core.$strict>>>>>;
74
74
  defaultResolution: z.ZodEnum<{
75
75
  readonly p480: "480p";
76
76
  readonly p720: "720p";
@@ -113,8 +113,8 @@ export declare const mediaModelsSchema: z.ZodArray<z.ZodReadonly<z.ZodObject<{
113
113
  silentMilliunitsPerSecond: z.ZodNumber;
114
114
  audioMilliunitsPerSecond: z.ZodNumber;
115
115
  }, z.core.$strict>>>>;
116
- }, z.core.$strict>>>;
117
- }, z.core.$strict>>>;
116
+ }, z.core.$strict>>>>;
117
+ }, z.core.$strict>>>>;
118
118
  /** An absolute output path on the Computer admitted by the App host. */
119
119
  export declare const destinationSchema: z.ZodObject<{
120
120
  computerId: z.ZodString;
@@ -153,11 +153,11 @@ export declare const appMediaAdmissionErrorSchema: z.ZodObject<{
153
153
  }>;
154
154
  }, z.core.$strict>;
155
155
  /** Attachment budget refusal emitted by the Media reservation owner. */
156
- export declare const appMediaBudgetRefusalSchema: z.ZodObject<{
156
+ export declare const appMediaBudgetRefusalSchema: z.ZodLazy<z.ZodObject<{
157
157
  error: z.ZodLiteral<"attachment_budget_exceeded">;
158
158
  kind: z.ZodLiteral<"media">;
159
159
  retryAfterMs: z.ZodNumber;
160
- }, z.core.$strict>;
160
+ }, z.core.$strict>>;
161
161
  /** Existing Media admission refusals, without an admitted selector or callable. */
162
162
  export declare const appMediaAdmissionRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
163
163
  error: z.ZodEnum<{
@@ -170,11 +170,11 @@ export declare const appMediaAdmissionRefusalSchema: z.ZodUnion<readonly [z.ZodO
170
170
  /** Admission could not resolve the current resource. */
171
171
  readonly unavailable: "unavailable";
172
172
  }>;
173
- }, z.core.$strict>, z.ZodObject<{
173
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
174
174
  error: z.ZodLiteral<"attachment_budget_exceeded">;
175
175
  kind: z.ZodLiteral<"media">;
176
176
  retryAfterMs: z.ZodNumber;
177
- }, z.core.$strict>]>;
177
+ }, z.core.$strict>>]>;
178
178
  /** Admission errors plus invalid/oversized inputs emitted directly by the broker. */
179
179
  export declare const appMediaBrokerErrorSchema: z.ZodObject<{
180
180
  error: z.ZodEnum<{
@@ -193,10 +193,10 @@ export declare const appMediaBrokerErrorSchema: z.ZodObject<{
193
193
  }>;
194
194
  }, z.core.$strict>;
195
195
  /** Missing-library refusal decoded and returned by the App media broker. */
196
- export declare const agentAppMediaLibraryFailureSchema: z.ZodObject<{
196
+ export declare const agentAppMediaLibraryFailureSchema: z.ZodLazy<z.ZodObject<{
197
197
  error: z.ZodLiteral<"library_unavailable">;
198
198
  message: z.ZodString;
199
- }, z.core.$strict>;
199
+ }, z.core.$strict>>;
200
200
  /** Broker projection of an HTTP failure: code becomes error and error becomes message. */
201
201
  export declare const appMediaBrokerFailureSchema: z.ZodObject<{
202
202
  error: z.ZodEnum<{
@@ -238,14 +238,14 @@ export declare const appMediaRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
238
238
  /** Admission could not resolve the current resource. */
239
239
  readonly unavailable: "unavailable";
240
240
  }>;
241
- }, z.core.$strict>, z.ZodObject<{
241
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
242
242
  error: z.ZodLiteral<"attachment_budget_exceeded">;
243
243
  kind: z.ZodLiteral<"media">;
244
244
  retryAfterMs: z.ZodNumber;
245
- }, z.core.$strict>, z.ZodObject<{
245
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
246
246
  error: z.ZodLiteral<"library_unavailable">;
247
247
  message: z.ZodString;
248
- }, z.core.$strict>, z.ZodObject<{
248
+ }, z.core.$strict>>, z.ZodObject<{
249
249
  error: z.ZodEnum<{
250
250
  readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
251
251
  readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -270,7 +270,7 @@ export declare const appMediaRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
270
270
  retryable: z.ZodBoolean;
271
271
  }, z.core.$strict>]>;
272
272
  /** Model-list payload or an existing broker refusal. */
273
- export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodReadonly<z.ZodObject<{
273
+ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodLazy<z.ZodArray<z.ZodReadonly<z.ZodObject<{
274
274
  id: z.ZodString;
275
275
  label: z.ZodString;
276
276
  kind: z.ZodEnum<{
@@ -288,7 +288,7 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
288
288
  readonly jpeg: "jpeg";
289
289
  readonly webp: "webp";
290
290
  }>>>;
291
- input: z.ZodReadonly<z.ZodObject<{
291
+ input: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
292
292
  transport: z.ZodEnum<{
293
293
  readonly json: "json";
294
294
  readonly multipart: "multipart";
@@ -309,9 +309,9 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
309
309
  defaultSteps: z.ZodNullable<z.ZodNumber>;
310
310
  referenceField: z.ZodNullable<z.ZodString>;
311
311
  maxReferences: z.ZodNumber;
312
- }, z.core.$strict>>;
312
+ }, z.core.$strict>>>;
313
313
  sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
314
- video: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
314
+ video: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
315
315
  minSeconds: z.ZodNumber;
316
316
  maxSeconds: z.ZodNumber;
317
317
  defaultSeconds: z.ZodNumber;
@@ -321,7 +321,7 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
321
321
  readonly veo: "veo";
322
322
  readonly minimax: "minimax";
323
323
  }>;
324
- formats: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
324
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
325
325
  resolution: z.ZodEnum<{
326
326
  readonly p480: "480p";
327
327
  readonly p720: "720p";
@@ -340,7 +340,7 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
340
340
  }>;
341
341
  width: z.ZodNumber;
342
342
  height: z.ZodNumber;
343
- }, z.core.$strict>>>>;
343
+ }, z.core.$strict>>>>>;
344
344
  defaultResolution: z.ZodEnum<{
345
345
  readonly p480: "480p";
346
346
  readonly p720: "720p";
@@ -383,8 +383,8 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
383
383
  silentMilliunitsPerSecond: z.ZodNumber;
384
384
  audioMilliunitsPerSecond: z.ZodNumber;
385
385
  }, z.core.$strict>>>>;
386
- }, z.core.$strict>>>;
387
- }, z.core.$strict>>>, z.ZodUnion<readonly [z.ZodObject<{
386
+ }, z.core.$strict>>>>;
387
+ }, z.core.$strict>>>>, z.ZodUnion<readonly [z.ZodObject<{
388
388
  error: z.ZodEnum<{
389
389
  /** The broker refused the input representation or selection. */
390
390
  readonly invalid: "invalid";
@@ -399,14 +399,14 @@ export declare const appMediaModelsOutcomeSchema: z.ZodUnion<readonly [z.ZodArra
399
399
  /** Admission could not resolve the current resource. */
400
400
  readonly unavailable: "unavailable";
401
401
  }>;
402
- }, z.core.$strict>, z.ZodObject<{
402
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
403
403
  error: z.ZodLiteral<"attachment_budget_exceeded">;
404
404
  kind: z.ZodLiteral<"media">;
405
405
  retryAfterMs: z.ZodNumber;
406
- }, z.core.$strict>, z.ZodObject<{
406
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
407
407
  error: z.ZodLiteral<"library_unavailable">;
408
408
  message: z.ZodString;
409
- }, z.core.$strict>, z.ZodObject<{
409
+ }, z.core.$strict>>, z.ZodObject<{
410
410
  error: z.ZodEnum<{
411
411
  readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
412
412
  readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -466,14 +466,14 @@ export declare const appMediaGenerationOutcomeSchema: z.ZodUnion<readonly [z.Zod
466
466
  /** Admission could not resolve the current resource. */
467
467
  readonly unavailable: "unavailable";
468
468
  }>;
469
- }, z.core.$strict>, z.ZodObject<{
469
+ }, z.core.$strict>, z.ZodLazy<z.ZodObject<{
470
470
  error: z.ZodLiteral<"attachment_budget_exceeded">;
471
471
  kind: z.ZodLiteral<"media">;
472
472
  retryAfterMs: z.ZodNumber;
473
- }, z.core.$strict>, z.ZodObject<{
473
+ }, z.core.$strict>>, z.ZodLazy<z.ZodObject<{
474
474
  error: z.ZodLiteral<"library_unavailable">;
475
475
  message: z.ZodString;
476
- }, z.core.$strict>, z.ZodObject<{
476
+ }, z.core.$strict>>, z.ZodObject<{
477
477
  error: z.ZodEnum<{
478
478
  readonly CAPABILITY_DENIED: "CAPABILITY_DENIED";
479
479
  readonly INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
@@ -4,9 +4,7 @@ import { mediaResultSchema } from "./media-operation-contract.js";
4
4
  import { pendingSchema } from "@fungi.computer/agar/backend-definition";
5
5
  import { mediaFailureSchema } from "./browser-failure.js";
6
6
  /** Bounded catalog decoded by the App media broker before host filtering. */
7
- export const mediaModelsSchema = z
8
- .array(mediaModelSchema)
9
- .max(listMediaModels().length);
7
+ export const mediaModelsSchema = z.lazy(() => z.array(mediaModelSchema).max(listMediaModels().length));
10
8
  /** An absolute output path on the Computer admitted by the App host. */
11
9
  export const destinationSchema = z.strictObject({
12
10
  /** Computer admitted by the host. */
@@ -36,14 +34,14 @@ export const appMediaAdmissionErrorSchema = z.strictObject({
36
34
  }),
37
35
  });
38
36
  /** Attachment budget refusal emitted by the Media reservation owner. */
39
- export const appMediaBudgetRefusalSchema = z.strictObject({
37
+ export const appMediaBudgetRefusalSchema = z.lazy(() => z.strictObject({
40
38
  /** The attachment's operation budget refused this request. */
41
39
  error: z.literal("attachment_budget_exceeded"),
42
40
  /** Media reservations use the Media budget, not exec or write. */
43
41
  kind: z.literal("media"),
44
42
  /** Delay emitted by the reservation owner. */
45
43
  retryAfterMs: z.number(),
46
- });
44
+ }));
47
45
  /** Existing Media admission refusals, without an admitted selector or callable. */
48
46
  export const appMediaAdmissionRefusalSchema = z.union([
49
47
  appMediaAdmissionErrorSchema,
@@ -61,12 +59,12 @@ export const appMediaBrokerErrorSchema = appMediaAdmissionErrorSchema.extend({
61
59
  }),
62
60
  });
63
61
  /** Missing-library refusal decoded and returned by the App media broker. */
64
- export const agentAppMediaLibraryFailureSchema = z.strictObject({
62
+ export const agentAppMediaLibraryFailureSchema = z.lazy(() => z.strictObject({
65
63
  /** The calling Installation's library is unavailable. */
66
64
  error: z.literal("library_unavailable"),
67
65
  /** Existing library-owner presentation copy. */
68
66
  message: z.string().max(4096),
69
- });
67
+ }));
70
68
  /** Broker projection of an HTTP failure: code becomes error and error becomes message. */
71
69
  export const appMediaBrokerFailureSchema = z.strictObject({
72
70
  /** Original typed HTTP failure code. */
@@ -25,13 +25,13 @@ export function estimate(settings, references) {
25
25
  }
26
26
  // Workers AI prefixes upstream error messages with its numeric internal code.
27
27
  // Parse only that bounded identifier; the remaining message is never logged.
28
- const providerFailureCode = z
28
+ const providerFailureCode = z.lazy(() => z
29
29
  .string()
30
30
  .regex(/^\d{4,5}: /u)
31
31
  .transform((message) => Number(message.split(":", 1)[0]))
32
32
  .nullable()
33
- .catch(null);
34
- const providerFailureCategory = z
33
+ .catch(null));
34
+ const providerFailureCategory = z.lazy(() => z
35
35
  .enum([
36
36
  "InferenceUpstreamError",
37
37
  "AiInternalError",
@@ -40,16 +40,16 @@ const providerFailureCategory = z
40
40
  "TimeoutError",
41
41
  "Error",
42
42
  ])
43
- .catch("Error");
43
+ .catch("Error"));
44
44
  // Recognize the refusal, not the generic Workers AI error number or prompt text.
45
- const safetyFilterMessage = z.union([
45
+ const safetyFilterMessage = z.lazy(() => z.union([
46
46
  z
47
47
  .string()
48
48
  .regex(/(?:^|:\s)(?:AiError:\s)?Input prompt contains NSFW content\b/iu),
49
49
  // Veo's documented input-policy refusal; keep its details private as well.
50
50
  // https://docs.cloud.google.com/vertex-ai/generative-ai/docs/video/responsible-ai-and-usage-guidelines
51
51
  z.string().regex(/\bit might violate our policies\b/iu),
52
- ]);
52
+ ]));
53
53
  /** Encode multipart once with the platform's boundary, as required by AI.run. */
54
54
  function workersAiInput(payload) {
55
55
  if (payload.transport === "json")
@@ -2,11 +2,11 @@ import { z } from "zod";
2
2
  import { MAX_REFERENCE_BYTES, MAX_REFERENCE_DIMENSION, MediaSettingsError, viewDimensionSchema, } from "../index.js";
3
3
  /** The retained `read_image` encoding: JPEG at quality 80. */
4
4
  const VIEW_JPEG_QUALITY = 80;
5
- const metadata = z.object({
5
+ const metadata = z.lazy(() => z.object({
6
6
  format: z.enum(["image/png", "image/jpeg", "image/gif", "image/webp"]),
7
7
  width: z.number().int().positive(),
8
8
  height: z.number().int().positive(),
9
- });
9
+ }));
10
10
  const formats = {
11
11
  "image/png": "png",
12
12
  "image/jpeg": "jpeg",
@@ -4,7 +4,7 @@ import * as z from "zod";
4
4
  const TILE = 512;
5
5
  const MAX_DIMENSION = 4_096;
6
6
  const MAX_REFERENCES = 4;
7
- const imageParamsSchema = z
7
+ const imageParamsSchema = z.lazy(() => z
8
8
  .object({
9
9
  width: z.number().int().min(1).max(MAX_DIMENSION),
10
10
  height: z.number().int().min(1).max(MAX_DIMENSION),
@@ -19,7 +19,7 @@ const imageParamsSchema = z
19
19
  .max(MAX_REFERENCES)
20
20
  .optional(),
21
21
  })
22
- .strict();
22
+ .strict());
23
23
  const invalid = (message) => {
24
24
  throw new MediaSettingsError(`image cost parameters are invalid: ${message}`);
25
25
  };
@@ -1,15 +1,15 @@
1
1
  import { z } from "zod";
2
2
  /** A result URL every gateway provider must return as plain HTTPS. */
3
- export declare const resultUrl: z.ZodURL;
3
+ export declare const resultUrl: z.ZodLazy<z.ZodURL>;
4
4
  /** The Unified AI gateway's normalized answer: a completed state and one
5
5
  * result URL. Seedance and Veo answer this way; MiniMax does not. */
6
- export declare const gatewayOutputSchema: z.ZodObject<{
6
+ export declare const gatewayOutputSchema: z.ZodLazy<z.ZodObject<{
7
7
  state: z.ZodOptional<z.ZodLiteral<"Completed">>;
8
8
  result: z.ZodObject<{
9
- image: z.ZodOptional<z.ZodURL>;
10
- video: z.ZodOptional<z.ZodURL>;
9
+ image: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
10
+ video: z.ZodOptional<z.ZodLazy<z.ZodURL>>;
11
11
  }, z.core.$loose>;
12
- }, z.core.$loose>;
12
+ }, z.core.$loose>>;
13
13
  /** Byte ceilings for fetched results; video stays within Worker memory. */
14
14
  export declare const GATEWAY_VIDEO_MAX_BYTES: number;
15
15
  /** An MP4 carries an `ftyp` box at byte 4. */
@@ -1,17 +1,17 @@
1
1
  import { z } from "zod";
2
2
  /** A result URL every gateway provider must return as plain HTTPS. */
3
- export const resultUrl = z
3
+ export const resultUrl = z.lazy(() => z
4
4
  .url()
5
- .refine((value) => value.startsWith("https://"), "result URLs must be HTTPS");
5
+ .refine((value) => value.startsWith("https://"), "result URLs must be HTTPS"));
6
6
  /** The Unified AI gateway's normalized answer: a completed state and one
7
7
  * result URL. Seedance and Veo answer this way; MiniMax does not. */
8
- export const gatewayOutputSchema = z.looseObject({
8
+ export const gatewayOutputSchema = z.lazy(() => z.looseObject({
9
9
  state: z.literal("Completed").optional(),
10
10
  result: z.looseObject({
11
11
  image: resultUrl.optional(),
12
12
  video: resultUrl.optional(),
13
13
  }),
14
- });
14
+ }));
15
15
  /** Byte ceilings for fetched results; video stays within Worker memory. */
16
16
  export const GATEWAY_VIDEO_MAX_BYTES = 64 * 1024 * 1024;
17
17
  /** An MP4 carries an `ftyp` box at byte 4. */
package/dist/index.d.ts CHANGED
@@ -73,7 +73,7 @@ export declare const MIN_VIEW_DIMENSION = 256;
73
73
  /** Maximum long-edge size accepted by an image viewer, in pixels. */
74
74
  export declare const MAX_VIEW_DIMENSION = 512;
75
75
  /** Decode a viewer long-edge size within the supported pixel bounds. */
76
- export declare const viewDimensionSchema: z.ZodNumber;
76
+ export declare const viewDimensionSchema: z.ZodLazy<z.ZodNumber>;
77
77
  /**
78
78
  * Decode one image and re-encode it for a model to look at: scaled within
79
79
  * `maxDimension` on the long edge (bounded by {@link viewDimensionSchema}) as
@@ -174,18 +174,18 @@ export declare const validateMediaGenerationSelection: (raw: z.input<typeof medi
174
174
  }>[];
175
175
  }>;
176
176
  /** Path-only video reference; the host supplies authority and reads its bytes. */
177
- export declare const mediaVideoReferenceSchema: z.ZodObject<{
177
+ export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
178
178
  path: z.ZodString;
179
179
  role: z.ZodEnum<{
180
180
  readonly first: "first-frame";
181
181
  readonly last: "last-frame";
182
182
  readonly reference: "reference";
183
183
  }>;
184
- }, z.core.$strict>;
184
+ }, z.core.$strict>>;
185
185
  /** One path-only video reference. */
186
186
  export type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
187
187
  /** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
188
- export declare const mediaVideoSelectionSchema: z.ZodObject<{
188
+ export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
189
189
  model: z.ZodEnum<{
190
190
  readonly seedance: "bytedance/seedance-2.0";
191
191
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -213,15 +213,15 @@ export declare const mediaVideoSelectionSchema: z.ZodObject<{
213
213
  }>>;
214
214
  durationSeconds: z.ZodOptional<z.ZodNumber>;
215
215
  generateAudio: z.ZodOptional<z.ZodBoolean>;
216
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
216
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
217
217
  path: z.ZodString;
218
218
  role: z.ZodEnum<{
219
219
  readonly first: "first-frame";
220
220
  readonly last: "last-frame";
221
221
  readonly reference: "reference";
222
222
  }>;
223
- }, z.core.$strict>>>;
224
- }, z.core.$strict>;
223
+ }, z.core.$strict>>>>;
224
+ }, z.core.$strict>>;
225
225
  /** Caller video selection before defaults and model-specific refinements. */
226
226
  export type MediaVideoSelectionInput = z.input<typeof mediaVideoSelectionSchema>;
227
227
  /** Normalized path-only video settings, ready for host-authorized reference hydration. */
@@ -313,21 +313,21 @@ export type MediaProviderOutput = Readonly<{
313
313
  entries: readonly MediaProviderImageEntry[];
314
314
  }>;
315
315
  /** Decode the Workers AI binding's raw output at the provider boundary. */
316
- export declare const mediaProviderWireSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
316
+ export declare const mediaProviderWireSchema: z.ZodLazy<z.ZodUnion<readonly [z.ZodLazy<z.ZodUnion<readonly [z.ZodObject<{
317
317
  image: z.ZodString;
318
318
  }, z.core.$strip>, z.ZodObject<{
319
- image: z.ZodArray<z.ZodObject<{
319
+ image: z.ZodArray<z.ZodLazy<z.ZodObject<{
320
320
  base64: z.ZodOptional<z.ZodString>;
321
321
  data: z.ZodOptional<z.ZodString>;
322
322
  url: z.ZodOptional<z.ZodURL>;
323
- }, z.core.$strict>>;
323
+ }, z.core.$strict>>>;
324
324
  }, z.core.$strip>, z.ZodObject<{
325
- images: z.ZodArray<z.ZodObject<{
325
+ images: z.ZodArray<z.ZodLazy<z.ZodObject<{
326
326
  base64: z.ZodOptional<z.ZodString>;
327
327
  data: z.ZodOptional<z.ZodString>;
328
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>>>]>;
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
331
  /** Supported raw provider representations, decoded by mediaProviderWireSchema. */
332
332
  export type MediaProviderWire = z.output<typeof mediaProviderWireSchema>;
333
333
  /** Native Workers AI output or an already decoded provider representation. */
package/dist/index.js CHANGED
@@ -8,11 +8,7 @@ export const MIN_VIEW_DIMENSION = 256;
8
8
  /** Maximum long-edge size accepted by an image viewer, in pixels. */
9
9
  export const MAX_VIEW_DIMENSION = 512;
10
10
  /** Decode a viewer long-edge size within the supported pixel bounds. */
11
- export const viewDimensionSchema = z
12
- .number()
13
- .int()
14
- .min(MIN_VIEW_DIMENSION)
15
- .max(MAX_VIEW_DIMENSION);
11
+ export const viewDimensionSchema = z.lazy(() => z.number().int().min(MIN_VIEW_DIMENSION).max(MAX_VIEW_DIMENSION));
16
12
  /** Maximum reference files in one generation request. */
17
13
  export const MAX_REFERENCE_COUNT = 4;
18
14
  /** Maximum reference width and height sent to inference, in pixels. */
@@ -219,14 +215,14 @@ function normalizeGenerationSettings(input, normalize) {
219
215
  return Object.freeze(normalized);
220
216
  }
221
217
  /** Path-only video reference; the host supplies authority and reads its bytes. */
222
- export const mediaVideoReferenceSchema = z.strictObject({
218
+ export const mediaVideoReferenceSchema = z.lazy(() => z.strictObject({
223
219
  /** Selected image path, trimmed and nonblank after validation. */
224
220
  path: z.string().min(1).max(4_096),
225
221
  /** Explicit first frame, last frame, or reference-image role. */
226
222
  role: mediaVideoReferenceRoleSchema,
227
- });
223
+ }));
228
224
  /** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
229
- export const mediaVideoSelectionSchema = z.strictObject({
225
+ export const mediaVideoSelectionSchema = z.lazy(() => z.strictObject({
230
226
  /** Verified catalog model identifier. */
231
227
  model: mediaVideoModelIdSchema,
232
228
  /** Trimmed prompt; Seedance allows 2,000 characters, Veo uses the retained host cap of 2,048. */
@@ -245,7 +241,7 @@ export const mediaVideoSelectionSchema = z.strictObject({
245
241
  .array(mediaVideoReferenceSchema)
246
242
  .max(MAX_REFERENCE_COUNT)
247
243
  .optional(),
248
- });
244
+ }));
249
245
  /** Validate supported model/size/duration/reference combinations before authority or billing admission. */
250
246
  export function validateMediaVideoSelection(raw) {
251
247
  const parsed = mediaVideoSelectionSchema.safeParse(raw);
@@ -352,7 +348,7 @@ export const buildProviderInput = (settings, references = []) => {
352
348
  body,
353
349
  });
354
350
  };
355
- const providerEntrySchema = z
351
+ const providerEntrySchema = z.lazy(() => z
356
352
  .object({
357
353
  /** Base64-encoded image data. */
358
354
  base64: z.string().optional(),
@@ -364,8 +360,8 @@ const providerEntrySchema = z
364
360
  .refine((value) => /^https?:\/\//iu.test(value), "provider image URLs must use HTTP(S)")
365
361
  .optional(),
366
362
  })
367
- .strict();
368
- const providerEnvelopeSchema = z.union([
363
+ .strict());
364
+ const providerEnvelopeSchema = z.lazy(() => z.union([
369
365
  z.object({
370
366
  /** Encoded provider image. */
371
367
  image: z.string().min(1),
@@ -378,14 +374,14 @@ const providerEnvelopeSchema = z.union([
378
374
  /** Provider output image entries. */
379
375
  images: z.array(providerEntrySchema),
380
376
  }),
381
- ]);
377
+ ]));
382
378
  /** Decode the Workers AI binding's raw output at the provider boundary. */
383
- export const mediaProviderWireSchema = z.union([
379
+ export const mediaProviderWireSchema = z.lazy(() => z.union([
384
380
  providerEnvelopeSchema,
385
381
  z.instanceof(Uint8Array),
386
382
  z.instanceof(Response),
387
383
  z.custom((value) => value instanceof ReadableStream),
388
- ]);
384
+ ]));
389
385
  /** Parse the provider wire envelope before normalization. */
390
386
  export const parseMediaProviderOutput = (value) => {
391
387
  if (value instanceof Uint8Array)
@@ -5,7 +5,7 @@ export { mediaResultSchema } from "./media-operation-contract.js";
5
5
  /** Image settings and path references crossing a scoped MEDIA binding. */
6
6
  export declare const mediaImageBindingInputSchema: z.ZodObject<{
7
7
  kind: z.ZodLiteral<"image">;
8
- requestId: z.ZodString;
8
+ requestId: z.ZodLazy<z.ZodString>;
9
9
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
10
10
  settings: z.ZodObject<{
11
11
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -48,9 +48,9 @@ export declare const mediaImageBindingInputSchema: z.ZodObject<{
48
48
  /** Video settings and path references crossing the same scoped binding. */
49
49
  export declare const mediaVideoBindingInputSchema: z.ZodObject<{
50
50
  kind: z.ZodLiteral<"video">;
51
- requestId: z.ZodString;
51
+ requestId: z.ZodLazy<z.ZodString>;
52
52
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
53
- settings: z.ZodObject<{
53
+ settings: z.ZodLazy<z.ZodObject<{
54
54
  model: z.ZodEnum<{
55
55
  readonly seedance: "bytedance/seedance-2.0";
56
56
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -78,20 +78,20 @@ export declare const mediaVideoBindingInputSchema: z.ZodObject<{
78
78
  }>>;
79
79
  durationSeconds: z.ZodOptional<z.ZodNumber>;
80
80
  generateAudio: z.ZodOptional<z.ZodBoolean>;
81
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
81
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
82
82
  path: z.ZodString;
83
83
  role: z.ZodEnum<{
84
84
  readonly first: "first-frame";
85
85
  readonly last: "last-frame";
86
86
  readonly reference: "reference";
87
87
  }>;
88
- }, z.core.$strict>>>;
89
- }, z.core.$strict>;
88
+ }, z.core.$strict>>>>;
89
+ }, z.core.$strict>>;
90
90
  }, z.core.$strict>;
91
91
  /** One generation identity, including the App-owned folder captured for replay. */
92
92
  export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
93
93
  kind: z.ZodLiteral<"image">;
94
- requestId: z.ZodString;
94
+ requestId: z.ZodLazy<z.ZodString>;
95
95
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
96
96
  settings: z.ZodObject<{
97
97
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -132,9 +132,9 @@ export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.Zo
132
132
  }>>;
133
133
  }, z.core.$strict>, z.ZodObject<{
134
134
  kind: z.ZodLiteral<"video">;
135
- requestId: z.ZodString;
135
+ requestId: z.ZodLazy<z.ZodString>;
136
136
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
137
- settings: z.ZodObject<{
137
+ settings: z.ZodLazy<z.ZodObject<{
138
138
  model: z.ZodEnum<{
139
139
  readonly seedance: "bytedance/seedance-2.0";
140
140
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -162,15 +162,15 @@ export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.Zo
162
162
  }>>;
163
163
  durationSeconds: z.ZodOptional<z.ZodNumber>;
164
164
  generateAudio: z.ZodOptional<z.ZodBoolean>;
165
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
165
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
166
166
  path: z.ZodString;
167
167
  role: z.ZodEnum<{
168
168
  readonly first: "first-frame";
169
169
  readonly last: "last-frame";
170
170
  readonly reference: "reference";
171
171
  }>;
172
- }, z.core.$strict>>>;
173
- }, z.core.$strict>;
172
+ }, z.core.$strict>>>>;
173
+ }, z.core.$strict>>;
174
174
  }, z.core.$strict>], "kind">;
175
175
  /** Parsed generation command consumed by either host. */
176
176
  export type MediaBindingGeneration = z.output<typeof mediaBindingGenerationSchema>;
@@ -182,7 +182,7 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
182
182
  operation: z.ZodLiteral<"generate">;
183
183
  input: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
184
  kind: z.ZodLiteral<"image">;
185
- requestId: z.ZodString;
185
+ requestId: z.ZodLazy<z.ZodString>;
186
186
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
187
187
  settings: z.ZodObject<{
188
188
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -223,9 +223,9 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
223
223
  }>>;
224
224
  }, z.core.$strict>, z.ZodObject<{
225
225
  kind: z.ZodLiteral<"video">;
226
- requestId: z.ZodString;
226
+ requestId: z.ZodLazy<z.ZodString>;
227
227
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
228
- settings: z.ZodObject<{
228
+ settings: z.ZodLazy<z.ZodObject<{
229
229
  model: z.ZodEnum<{
230
230
  readonly seedance: "bytedance/seedance-2.0";
231
231
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -253,24 +253,24 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
253
253
  }>>;
254
254
  durationSeconds: z.ZodOptional<z.ZodNumber>;
255
255
  generateAudio: z.ZodOptional<z.ZodBoolean>;
256
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
256
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
257
257
  path: z.ZodString;
258
258
  role: z.ZodEnum<{
259
259
  readonly first: "first-frame";
260
260
  readonly last: "last-frame";
261
261
  readonly reference: "reference";
262
262
  }>;
263
- }, z.core.$strict>>>;
264
- }, z.core.$strict>;
263
+ }, z.core.$strict>>>>;
264
+ }, z.core.$strict>>;
265
265
  }, z.core.$strict>], "kind">;
266
266
  }, z.core.$strict>], "operation">;
267
267
  /** Parsed call consumed by host admission and transport. */
268
268
  export type MediaBindingCall = z.output<typeof mediaBindingCallSchema>;
269
269
  /** Background-generation reply emitted by the durable service. */
270
- export declare const mediaPendingSchema: z.ZodObject<{
270
+ export declare const mediaPendingSchema: z.ZodLazy<z.ZodObject<{
271
271
  status: z.ZodLiteral<"pending">;
272
272
  retryAfterSeconds: z.ZodNumber;
273
- }, z.core.$strict>;
273
+ }, z.core.$strict>>;
274
274
  /** Parsing and model refusal stay shared; authorization remains host-owned. */
275
275
  export declare function parseMediaBindingCall(raw: Schema.Json): Readonly<{
276
276
  kind: "parsed";
@@ -43,17 +43,20 @@ export const mediaBindingGenerationSchema = z.discriminatedUnion("kind", [
43
43
  ]);
44
44
  /** Maintained MEDIA method grammar; guest input carries no principal or Computer. */
45
45
  export const mediaBindingCallSchema = z.discriminatedUnion("operation", [
46
- z.strictObject({ operation: z.literal("models"), input: z.strictObject({}) }),
46
+ z.strictObject({
47
+ operation: z.literal("models"),
48
+ input: z.strictObject({}),
49
+ }),
47
50
  z.strictObject({
48
51
  operation: z.literal("generate"),
49
52
  input: mediaBindingGenerationSchema,
50
53
  }),
51
54
  ]);
52
55
  /** Background-generation reply emitted by the durable service. */
53
- export const mediaPendingSchema = z.strictObject({
56
+ export const mediaPendingSchema = z.lazy(() => z.strictObject({
54
57
  status: z.literal("pending"),
55
58
  retryAfterSeconds: z.number().int().positive(),
56
- });
59
+ }));
57
60
  /** Parsing and model refusal stay shared; authorization remains host-owned. */
58
61
  export function parseMediaBindingCall(raw) {
59
62
  if (new TextEncoder().encode(JSON.stringify(raw)).byteLength > 64 * 1024)
@@ -3,7 +3,7 @@ import { z } from "zod";
3
3
  import type { MediaOperationContext, MediaOperationBucket } from "./media-operation-storage.js";
4
4
  import type { MediaProvider, MediaReferenceBytes } from "./index.js";
5
5
  /** Fixed generation destination captured before provider dispatch. */
6
- export declare const mediaOperationDestinationSchema: z.ZodObject<{
6
+ export declare const mediaOperationDestinationSchema: z.ZodLazy<z.ZodObject<{
7
7
  computerId: z.ZodString;
8
8
  path: z.ZodString;
9
9
  outputFormat: z.ZodOptional<z.ZodEnum<{
@@ -11,7 +11,7 @@ export declare const mediaOperationDestinationSchema: z.ZodObject<{
11
11
  readonly jpeg: "jpeg";
12
12
  readonly webp: "webp";
13
13
  }>>;
14
- }, z.core.$strict>;
14
+ }, z.core.$strict>>;
15
15
  /** Normalized generation and its fixed destination, captured for exact replay. */
16
16
  export type MediaOperationRequest = MediaGenerationSettings & z.output<typeof mediaOperationDestinationSchema>;
17
17
  /** Decode host namespace and owner identity. */
@@ -43,19 +43,19 @@ export declare const mediaOperationStateSchema: z.ZodEnum<{
43
43
  /** Durable generation, save and settlement states. */
44
44
  export type MediaOperationState = z.output<typeof mediaOperationStateSchema>;
45
45
  /** Decode retained or saved output size and encoding. */
46
- export declare const mediaImageSchema: z.ZodObject<{
46
+ export declare const mediaImageSchema: z.ZodLazy<z.ZodObject<{
47
47
  bytes: z.ZodNumber;
48
48
  format: z.ZodString;
49
- }, z.core.$strict>;
49
+ }, z.core.$strict>>;
50
50
  /** Byte length and encoding of generated or saved output. */
51
51
  export type MediaImage = z.output<typeof mediaImageSchema>;
52
52
  /** Decode the settled receipt, including the host-admitted customer price. */
53
- export declare const mediaOperationResultSchema: z.ZodObject<{
53
+ export declare const mediaOperationResultSchema: z.ZodLazy<z.ZodObject<{
54
54
  generationId: z.ZodString;
55
55
  bytes: z.ZodNumber;
56
56
  format: z.ZodString;
57
57
  costMilliunits: z.ZodNumber;
58
- }, z.core.$strict>;
58
+ }, z.core.$strict>>;
59
59
  /** Settled generation receipt with the host-admitted customer price. */
60
60
  export type MediaOperationResult = z.output<typeof mediaOperationResultSchema>;
61
61
  /** The only operation shape safe to return outside the owner. */
@@ -12,21 +12,21 @@ const ids = defineIdFamily({
12
12
  });
13
13
  const text = z.string().min(1).max(256);
14
14
  const path = z.string().min(1).max(1_024);
15
- const referenceMetadataSchema = z.object({
15
+ const referenceMetadataSchema = z.lazy(() => z.object({
16
16
  format: z.enum(["png", "jpeg", "gif", "webp"]),
17
17
  width: z.coerce.number().int().positive(),
18
18
  height: z.coerce.number().int().positive(),
19
- });
19
+ }));
20
20
  const referenceKey = (operationId, index) => `media-reference/v1/${operationId}/${String(index)}`;
21
21
  /** Fixed generation destination captured before provider dispatch. */
22
- export const mediaOperationDestinationSchema = z.strictObject({
22
+ export const mediaOperationDestinationSchema = z.lazy(() => z.strictObject({
23
23
  /** Host-admitted destination or reference identity. */
24
24
  computerId: text,
25
25
  /** Fixed relative path in the admitted destination. */
26
26
  path,
27
27
  /** Optional verified image encoding pin. */
28
28
  outputFormat: mediaRequestedImageFormatSchema.optional(),
29
- });
29
+ }));
30
30
  /** Decode host namespace and owner identity. */
31
31
  export const mediaOperationCoordinatesSchema = z.strictObject({
32
32
  /** Host isolation namespace. */
@@ -54,13 +54,13 @@ export const mediaOperationStateSchema = z.enum({
54
54
  interrupted: "interrupted",
55
55
  });
56
56
  /** Decode retained or saved output size and encoding. */
57
- export const mediaImageSchema = z.strictObject({
57
+ export const mediaImageSchema = z.lazy(() => z.strictObject({
58
58
  /** Output byte length. */
59
59
  bytes: z.number().int().positive(),
60
60
  /** Actual output encoding. */
61
61
  format: text,
62
- });
63
- const retainedFormatSchema = z
62
+ }));
63
+ const retainedFormatSchema = z.lazy(() => z
64
64
  .enum(["image/png", "image/jpeg", "image/gif", "image/webp", "video/mp4"])
65
65
  .transform((mime) => ({
66
66
  "image/png": "png",
@@ -68,15 +68,15 @@ const retainedFormatSchema = z
68
68
  "image/gif": "gif",
69
69
  "image/webp": "webp",
70
70
  "video/mp4": "mp4",
71
- })[mime]);
72
- const outputSchema = z.strictObject({
71
+ })[mime]));
72
+ const outputSchema = z.lazy(() => z.strictObject({
73
73
  key: text,
74
74
  version: text,
75
75
  bytes: z.number().int().positive(),
76
76
  format: text,
77
- });
77
+ }));
78
78
  /** Decode the settled receipt, including the host-admitted customer price. */
79
- export const mediaOperationResultSchema = z.strictObject({
79
+ export const mediaOperationResultSchema = z.lazy(() => z.strictObject({
80
80
  /** Durable operation identifier. */
81
81
  generationId: text,
82
82
  /** Output byte length. */
@@ -85,7 +85,7 @@ export const mediaOperationResultSchema = z.strictObject({
85
85
  format: text,
86
86
  /** Admitted price in milliunits, where 1 cent is 1,000 milliunits. */
87
87
  costMilliunits: z.number().int().nonnegative(),
88
- });
88
+ }));
89
89
  class MediaOperationError extends Error {
90
90
  code;
91
91
  constructor(
@@ -98,7 +98,7 @@ class MediaOperationError extends Error {
98
98
  }
99
99
  /** Stored media type for an output format. */
100
100
  const outputMime = (format) => format === "mp4" ? "video/mp4" : `image/${format}`;
101
- const operationRowSchema = z.object({
101
+ const operationRowSchema = z.lazy(() => z.object({
102
102
  operation_id: z.string(),
103
103
  request_id: z.string(),
104
104
  actor_user_id: z.string(),
@@ -118,7 +118,7 @@ const operationRowSchema = z.object({
118
118
  updated_at: z.number(),
119
119
  background: z.number(),
120
120
  dispatched_at: z.number().nullable(),
121
- });
121
+ }));
122
122
  const schemaStatements = [
123
123
  `CREATE TABLE hub_media_operation (
124
124
  singleton INTEGER PRIMARY KEY CHECK(singleton=1),
@@ -148,7 +148,7 @@ const schemaStatements = [
148
148
  function fingerprint(input) {
149
149
  return JSON.stringify(input);
150
150
  }
151
- const objectSchema = z.record(z.string(), z.unknown());
151
+ const objectSchema = z.lazy(() => z.record(z.string(), z.unknown()));
152
152
  function decodeStoredRequest(serialized) {
153
153
  let raw;
154
154
  try {
@@ -26,7 +26,7 @@ export declare const mediaModelTierSchema: z.ZodEnum<{
26
26
  /** A model selection tier, independent of billing price. */
27
27
  export type MediaModelTier = z.output<typeof mediaModelTierSchema>;
28
28
  /** Media's provider catalog: Workers AI images plus gateway image and video models. */
29
- export declare const mediaModelInputSchema: z.ZodReadonly<z.ZodObject<{
29
+ export declare const mediaModelInputSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
30
30
  transport: z.ZodEnum<{
31
31
  /** JSON provider input. */
32
32
  readonly json: "json";
@@ -54,7 +54,7 @@ export declare const mediaModelInputSchema: z.ZodReadonly<z.ZodObject<{
54
54
  defaultSteps: z.ZodNullable<z.ZodNumber>;
55
55
  referenceField: z.ZodNullable<z.ZodString>;
56
56
  maxReferences: z.ZodNumber;
57
- }, z.core.$strict>>;
57
+ }, z.core.$strict>>>;
58
58
  /** Verified Unified AI video identifiers; no inferred family aliases. */
59
59
  export declare const mediaVideoModelIdSchema: z.ZodEnum<{
60
60
  /** Seedance 2.0. */
@@ -118,7 +118,7 @@ export declare const mediaVideoReferenceRoleSchema: z.ZodEnum<{
118
118
  /** The role of a selected reference image in a video request. */
119
119
  export type MediaVideoReferenceRole = z.output<typeof mediaVideoReferenceRoleSchema>;
120
120
  /** One nominal size used to select provider resolution and aspect. */
121
- export declare const mediaVideoFormatSchema: z.ZodReadonly<z.ZodObject<{
121
+ export declare const mediaVideoFormatSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
122
122
  resolution: z.ZodEnum<{
123
123
  /** 480p. */
124
124
  readonly p480: "480p";
@@ -149,11 +149,11 @@ export declare const mediaVideoFormatSchema: z.ZodReadonly<z.ZodObject<{
149
149
  }>;
150
150
  width: z.ZodNumber;
151
151
  height: z.ZodNumber;
152
- }, z.core.$strict>>;
152
+ }, z.core.$strict>>>;
153
153
  /** One immutable nominal video format. */
154
154
  export type MediaVideoFormat = z.output<typeof mediaVideoFormatSchema>;
155
155
  /** Verified video parameters and provider costs, checked 2026-10-11. */
156
- export declare const mediaVideoSchema: z.ZodReadonly<z.ZodObject<{
156
+ export declare const mediaVideoSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
157
157
  minSeconds: z.ZodNumber;
158
158
  maxSeconds: z.ZodNumber;
159
159
  defaultSeconds: z.ZodNumber;
@@ -166,7 +166,7 @@ export declare const mediaVideoSchema: z.ZodReadonly<z.ZodObject<{
166
166
  /** MiniMax multimodal `content[]` array and uppercase resolution. */
167
167
  readonly minimax: "minimax";
168
168
  }>;
169
- formats: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
169
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
170
170
  resolution: z.ZodEnum<{
171
171
  /** 480p. */
172
172
  readonly p480: "480p";
@@ -197,7 +197,7 @@ export declare const mediaVideoSchema: z.ZodReadonly<z.ZodObject<{
197
197
  }>;
198
198
  width: z.ZodNumber;
199
199
  height: z.ZodNumber;
200
- }, z.core.$strict>>>>;
200
+ }, z.core.$strict>>>>>;
201
201
  defaultResolution: z.ZodEnum<{
202
202
  /** 480p. */
203
203
  readonly p480: "480p";
@@ -265,7 +265,7 @@ export declare const mediaVideoSchema: z.ZodReadonly<z.ZodObject<{
265
265
  silentMilliunitsPerSecond: z.ZodNumber;
266
266
  audioMilliunitsPerSecond: z.ZodNumber;
267
267
  }, z.core.$strict>>>>;
268
- }, z.core.$strict>>;
268
+ }, z.core.$strict>>>;
269
269
  /** Immutable video capability and price metadata. */
270
270
  export type MediaVideoModel = z.output<typeof mediaVideoSchema>;
271
271
  /** Public wire grammar for a catalog entry returned by the Media owner. */
@@ -296,7 +296,7 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
296
296
  /** WebP image encoding. */
297
297
  readonly webp: "webp";
298
298
  }>>>;
299
- input: z.ZodReadonly<z.ZodObject<{
299
+ input: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
300
300
  transport: z.ZodEnum<{
301
301
  /** JSON provider input. */
302
302
  readonly json: "json";
@@ -324,9 +324,9 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
324
324
  defaultSteps: z.ZodNullable<z.ZodNumber>;
325
325
  referenceField: z.ZodNullable<z.ZodString>;
326
326
  maxReferences: z.ZodNumber;
327
- }, z.core.$strict>>;
327
+ }, z.core.$strict>>>;
328
328
  sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
329
- video: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
329
+ video: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
330
330
  minSeconds: z.ZodNumber;
331
331
  maxSeconds: z.ZodNumber;
332
332
  defaultSeconds: z.ZodNumber;
@@ -339,7 +339,7 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
339
339
  /** MiniMax multimodal `content[]` array and uppercase resolution. */
340
340
  readonly minimax: "minimax";
341
341
  }>;
342
- formats: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
342
+ formats: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
343
343
  resolution: z.ZodEnum<{
344
344
  /** 480p. */
345
345
  readonly p480: "480p";
@@ -370,7 +370,7 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
370
370
  }>;
371
371
  width: z.ZodNumber;
372
372
  height: z.ZodNumber;
373
- }, z.core.$strict>>>>;
373
+ }, z.core.$strict>>>>>;
374
374
  defaultResolution: z.ZodEnum<{
375
375
  /** 480p. */
376
376
  readonly p480: "480p";
@@ -438,7 +438,7 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
438
438
  silentMilliunitsPerSecond: z.ZodNumber;
439
439
  audioMilliunitsPerSecond: z.ZodNumber;
440
440
  }, z.core.$strict>>>>;
441
- }, z.core.$strict>>>;
441
+ }, z.core.$strict>>>>;
442
442
  }, z.core.$strict>>;
443
443
  /** Model-specific dimensions, steps, transport and reference limits. */
444
444
  export type MediaModelInput = z.output<typeof mediaModelInputSchema>;
@@ -24,7 +24,7 @@ export const mediaModelTierSchema = z.enum({
24
24
  max: "max",
25
25
  });
26
26
  /** Media's provider catalog: Workers AI images plus gateway image and video models. */
27
- export const mediaModelInputSchema = z
27
+ export const mediaModelInputSchema = z.lazy(() => z
28
28
  .strictObject({
29
29
  /** Provider input transport. */
30
30
  transport: z.enum({
@@ -64,7 +64,7 @@ export const mediaModelInputSchema = z
64
64
  /** Maximum references accepted by this model. */
65
65
  maxReferences: z.number().int().nonnegative(),
66
66
  })
67
- .readonly();
67
+ .readonly());
68
68
  /** Verified Unified AI video identifiers; no inferred family aliases. */
69
69
  export const mediaVideoModelIdSchema = z.enum({
70
70
  /** Seedance 2.0. */
@@ -120,7 +120,7 @@ export const mediaVideoReferenceRoleSchema = z.enum({
120
120
  reference: "reference",
121
121
  });
122
122
  /** One nominal size used to select provider resolution and aspect. */
123
- export const mediaVideoFormatSchema = z
123
+ export const mediaVideoFormatSchema = z.lazy(() => z
124
124
  .strictObject({
125
125
  /** Provider resolution. */
126
126
  resolution: mediaVideoResolutionSchema,
@@ -131,9 +131,9 @@ export const mediaVideoFormatSchema = z
131
131
  /** Nominal height; actual MP4 dimensions are not decoded. */
132
132
  height: z.number().int().positive(),
133
133
  })
134
- .readonly();
134
+ .readonly());
135
135
  /** Verified video parameters and provider costs, checked 2026-10-11. */
136
- export const mediaVideoSchema = z
136
+ export const mediaVideoSchema = z.lazy(() => z
137
137
  .strictObject({
138
138
  /** Minimum duration, for callers displaying bounds. */
139
139
  minSeconds: z.number().int().positive(),
@@ -182,7 +182,7 @@ export const mediaVideoSchema = z
182
182
  .readonly())
183
183
  .readonly(),
184
184
  })
185
- .readonly();
185
+ .readonly());
186
186
  /** Public wire grammar for a catalog entry returned by the Media owner. */
187
187
  export const mediaModelSchema = z
188
188
  .strictObject({
package/dist/server.js CHANGED
@@ -11,7 +11,7 @@ import { MediaOutputFormatMismatch, MediaBillingRefusal, MediaExecutionError, Me
11
11
  export { MediaBillingRefusal, MediaExecutionError, } from "./execution-error.js";
12
12
  export { mediaUnits } from "./gateway-models.js";
13
13
  export { MediaOperationOwner, mediaOperationDestinationSchema, mediaOperationCoordinatesSchema, mediaOperationStateSchema, mediaImageSchema, mediaOperationResultSchema, } from "./media-operation-owner.js";
14
- const identifier = z.string().min(1).max(256);
14
+ const identifier = z.lazy(() => z.string().min(1).max(256));
15
15
  /** Decode relative service generation input. Identity comes from the host. */
16
16
  export const mediaRequestSchema = z.strictObject({
17
17
  /** Fixed destination or reference file path. */
@@ -19,12 +19,12 @@ const minimaxRoleWire = {
19
19
  /** MiniMax's documented task wrapper: `{task: {status, content: {url}}}`,
20
20
  * distinct from the Unified gateway's `{state, result}` shape Seedance and
21
21
  * Veo normalize into. https://developers.cloudflare.com/ai/models/minimax/h3-max/ */
22
- const minimaxTaskOutputSchema = z.looseObject({
22
+ const minimaxTaskOutputSchema = z.lazy(() => z.looseObject({
23
23
  task: z.looseObject({
24
24
  status: z.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
25
25
  content: z.looseObject({ url: resultUrl.optional() }).optional(),
26
26
  }),
27
- });
27
+ }));
28
28
  export const minimaxVideoAdapter = {
29
29
  buildInput(checked, references, model) {
30
30
  if (checked.generateAudio !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/darkroom",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Media generation, durable output retention and provenance with host-owned authority and billing",
6
6
  "type": "module",
@@ -59,7 +59,7 @@
59
59
  "exifreader": "4.46.0",
60
60
  "@fungi.computer/ts-webp": "0.1.6",
61
61
  "@xmldom/xmldom": "0.9.12",
62
- "@fungi.computer/agar": "0.1.0",
62
+ "@fungi.computer/agar": "0.2.0",
63
63
  "@fungi.computer/capnweb": "0.12.0"
64
64
  },
65
65
  "devDependencies": {