@fungi.computer/darkroom 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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)
@@ -1,11 +1,10 @@
1
1
  import * as z from "zod";
2
- import * as Schema from "effect/Schema";
3
2
  import { mediaRequestedImageFormatSchema, type MediaGenerationSettings } from "./index.js";
4
3
  export { mediaResultSchema } from "./media-operation-contract.js";
5
4
  /** Image settings and path references crossing a scoped MEDIA binding. */
6
5
  export declare const mediaImageBindingInputSchema: z.ZodObject<{
7
6
  kind: z.ZodLiteral<"image">;
8
- requestId: z.ZodString;
7
+ requestId: z.ZodLazy<z.ZodString>;
9
8
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
10
9
  settings: z.ZodObject<{
11
10
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -48,9 +47,9 @@ export declare const mediaImageBindingInputSchema: z.ZodObject<{
48
47
  /** Video settings and path references crossing the same scoped binding. */
49
48
  export declare const mediaVideoBindingInputSchema: z.ZodObject<{
50
49
  kind: z.ZodLiteral<"video">;
51
- requestId: z.ZodString;
50
+ requestId: z.ZodLazy<z.ZodString>;
52
51
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
53
- settings: z.ZodObject<{
52
+ settings: z.ZodLazy<z.ZodObject<{
54
53
  model: z.ZodEnum<{
55
54
  readonly seedance: "bytedance/seedance-2.0";
56
55
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -78,20 +77,20 @@ export declare const mediaVideoBindingInputSchema: z.ZodObject<{
78
77
  }>>;
79
78
  durationSeconds: z.ZodOptional<z.ZodNumber>;
80
79
  generateAudio: z.ZodOptional<z.ZodBoolean>;
81
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
80
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
82
81
  path: z.ZodString;
83
82
  role: z.ZodEnum<{
84
83
  readonly first: "first-frame";
85
84
  readonly last: "last-frame";
86
85
  readonly reference: "reference";
87
86
  }>;
88
- }, z.core.$strict>>>;
89
- }, z.core.$strict>;
87
+ }, z.core.$strict>>>>;
88
+ }, z.core.$strict>>;
90
89
  }, z.core.$strict>;
91
90
  /** One generation identity, including the App-owned folder captured for replay. */
92
91
  export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
93
92
  kind: z.ZodLiteral<"image">;
94
- requestId: z.ZodString;
93
+ requestId: z.ZodLazy<z.ZodString>;
95
94
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
96
95
  settings: z.ZodObject<{
97
96
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -132,9 +131,9 @@ export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.Zo
132
131
  }>>;
133
132
  }, z.core.$strict>, z.ZodObject<{
134
133
  kind: z.ZodLiteral<"video">;
135
- requestId: z.ZodString;
134
+ requestId: z.ZodLazy<z.ZodString>;
136
135
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
137
- settings: z.ZodObject<{
136
+ settings: z.ZodLazy<z.ZodObject<{
138
137
  model: z.ZodEnum<{
139
138
  readonly seedance: "bytedance/seedance-2.0";
140
139
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -162,15 +161,15 @@ export declare const mediaBindingGenerationSchema: z.ZodDiscriminatedUnion<[z.Zo
162
161
  }>>;
163
162
  durationSeconds: z.ZodOptional<z.ZodNumber>;
164
163
  generateAudio: z.ZodOptional<z.ZodBoolean>;
165
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
164
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
166
165
  path: z.ZodString;
167
166
  role: z.ZodEnum<{
168
167
  readonly first: "first-frame";
169
168
  readonly last: "last-frame";
170
169
  readonly reference: "reference";
171
170
  }>;
172
- }, z.core.$strict>>>;
173
- }, z.core.$strict>;
171
+ }, z.core.$strict>>>>;
172
+ }, z.core.$strict>>;
174
173
  }, z.core.$strict>], "kind">;
175
174
  /** Parsed generation command consumed by either host. */
176
175
  export type MediaBindingGeneration = z.output<typeof mediaBindingGenerationSchema>;
@@ -182,7 +181,7 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
182
181
  operation: z.ZodLiteral<"generate">;
183
182
  input: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
183
  kind: z.ZodLiteral<"image">;
185
- requestId: z.ZodString;
184
+ requestId: z.ZodLazy<z.ZodString>;
186
185
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
187
186
  settings: z.ZodObject<{
188
187
  resolution: z.ZodOptional<z.ZodEnum<{
@@ -223,9 +222,9 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
223
222
  }>>;
224
223
  }, z.core.$strict>, z.ZodObject<{
225
224
  kind: z.ZodLiteral<"video">;
226
- requestId: z.ZodString;
225
+ requestId: z.ZodLazy<z.ZodString>;
227
226
  libraryPath: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
228
- settings: z.ZodObject<{
227
+ settings: z.ZodLazy<z.ZodObject<{
229
228
  model: z.ZodEnum<{
230
229
  readonly seedance: "bytedance/seedance-2.0";
231
230
  readonly seedanceFast: "bytedance/seedance-2.0-fast";
@@ -253,36 +252,43 @@ export declare const mediaBindingCallSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
253
252
  }>>;
254
253
  durationSeconds: z.ZodOptional<z.ZodNumber>;
255
254
  generateAudio: z.ZodOptional<z.ZodBoolean>;
256
- references: z.ZodOptional<z.ZodArray<z.ZodObject<{
255
+ references: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
257
256
  path: z.ZodString;
258
257
  role: z.ZodEnum<{
259
258
  readonly first: "first-frame";
260
259
  readonly last: "last-frame";
261
260
  readonly reference: "reference";
262
261
  }>;
263
- }, z.core.$strict>>>;
264
- }, z.core.$strict>;
262
+ }, z.core.$strict>>>>;
263
+ }, z.core.$strict>>;
265
264
  }, z.core.$strict>], "kind">;
266
265
  }, z.core.$strict>], "operation">;
267
266
  /** Parsed call consumed by host admission and transport. */
268
267
  export type MediaBindingCall = z.output<typeof mediaBindingCallSchema>;
269
268
  /** Background-generation reply emitted by the durable service. */
270
- export declare const mediaPendingSchema: z.ZodObject<{
269
+ export declare const mediaPendingSchema: z.ZodLazy<z.ZodObject<{
271
270
  status: z.ZodLiteral<"pending">;
272
271
  retryAfterSeconds: z.ZodNumber;
273
- }, z.core.$strict>;
272
+ }, z.core.$strict>>;
274
273
  /** Parsing and model refusal stay shared; authorization remains host-owned. */
275
- export declare function parseMediaBindingCall(raw: Schema.Json): Readonly<{
274
+ export declare function parseMediaBindingCall(raw: z.core.util.JSONType): Readonly<{
275
+ /** The binding input passed its shared grammar. */
276
276
  kind: "parsed";
277
+ /** Validated command for host admission. */
277
278
  call: MediaBindingCall;
278
279
  }> | Readonly<{
280
+ /** Input size, grammar or model selection was refused. */
279
281
  kind: "refused";
282
+ /** Safe refusal returned without provider dispatch. */
280
283
  result: z.core.util.JSONType;
281
284
  }>;
282
285
  /** Relative service input after the host attaches its trusted Computer to references. */
283
286
  export type MediaBindingRequest = Readonly<{
287
+ /** Host-selected output filename within the App's library folder. */
284
288
  path: string;
289
+ /** Validated selection with the host's Computer attached to references. */
285
290
  settings: MediaGenerationSettings;
291
+ /** Optional image encoding; video output remains MP4. */
286
292
  outputFormat?: z.output<typeof mediaRequestedImageFormatSchema>;
287
293
  }>;
288
294
  /** Choose the same fixed filename on both hosts without a recursive App lookup. */
@@ -13,12 +13,17 @@ const mediaBindingLibraryPathSchema = z
13
13
  .refine(Schema.is(mediaLibraryPathSchema), "Select an absolute library folder");
14
14
  /** Image settings and path references crossing a scoped MEDIA binding. */
15
15
  export const mediaImageBindingInputSchema = z.strictObject({
16
+ /** Select image generation rather than video. */
16
17
  kind: z.literal("image"),
18
+ /** Attempt identity retained through polling and replay. */
17
19
  requestId: mediaRequestIdSchema,
20
+ /** App-owned absolute folder; the host supplies Computer authority. */
18
21
  libraryPath: mediaBindingLibraryPathSchema,
22
+ /** Image model selection, references and inference settings. */
19
23
  settings: mediaGenerationSelectionSchema
20
24
  .omit({ durationSeconds: true })
21
25
  .extend({
26
+ /** Optional inference-step count for models that support it. */
22
27
  steps: z
23
28
  .number()
24
29
  .int()
@@ -27,13 +32,18 @@ export const mediaImageBindingInputSchema = z.strictObject({
27
32
  .optional(),
28
33
  })
29
34
  .refine((settings) => getMediaModel(settings.model)?.kind === "image", "Select an image model from listModels"),
35
+ /** Requested image encoding, validated against the selected model. */
30
36
  outputFormat: mediaRequestedImageFormatSchema.optional(),
31
37
  });
32
38
  /** Video settings and path references crossing the same scoped binding. */
33
39
  export const mediaVideoBindingInputSchema = z.strictObject({
40
+ /** Select video generation rather than an image. */
34
41
  kind: z.literal("video"),
42
+ /** Attempt identity retained through polling and replay. */
35
43
  requestId: mediaRequestIdSchema,
44
+ /** App-owned absolute folder; the host supplies Computer authority. */
36
45
  libraryPath: mediaBindingLibraryPathSchema,
46
+ /** Catalog-backed video model, size, duration and references. */
37
47
  settings: mediaVideoSelectionSchema,
38
48
  });
39
49
  /** One generation identity, including the App-owned folder captured for replay. */
@@ -43,17 +53,26 @@ export const mediaBindingGenerationSchema = z.discriminatedUnion("kind", [
43
53
  ]);
44
54
  /** Maintained MEDIA method grammar; guest input carries no principal or Computer. */
45
55
  export const mediaBindingCallSchema = z.discriminatedUnion("operation", [
46
- z.strictObject({ operation: z.literal("models"), input: z.strictObject({}) }),
47
56
  z.strictObject({
57
+ /** Read the model catalog without dispatching generation. */
58
+ operation: z.literal("models"),
59
+ /** Catalog reads carry no guest authority or generation settings. */
60
+ input: z.strictObject({}),
61
+ }),
62
+ z.strictObject({
63
+ /** Execute or poll one admitted generation identity. */
48
64
  operation: z.literal("generate"),
65
+ /** The App's captured generation selection and library folder. */
49
66
  input: mediaBindingGenerationSchema,
50
67
  }),
51
68
  ]);
52
69
  /** Background-generation reply emitted by the durable service. */
53
- export const mediaPendingSchema = z.strictObject({
70
+ export const mediaPendingSchema = z.lazy(() => z.strictObject({
71
+ /** Background work has been accepted but is not yet delivered. */
54
72
  status: z.literal("pending"),
73
+ /** Host-supplied delay before polling the same attempt again. */
55
74
  retryAfterSeconds: z.number().int().positive(),
56
- });
75
+ }));
57
76
  /** Parsing and model refusal stay shared; authorization remains host-owned. */
58
77
  export function parseMediaBindingCall(raw) {
59
78
  if (new TextEncoder().encode(JSON.stringify(raw)).byteLength > 64 * 1024)
@@ -119,12 +138,15 @@ export async function readMediaBindingReply(input, computerId, response) {
119
138
  const failure = mediaFailureSchema.safeParse(value);
120
139
  if (!failure.success)
121
140
  return { error: "unavailable" };
122
- return z.json().parse(appMediaBrokerFailureSchema.parse({
141
+ const projected = {
123
142
  error: failure.data.code,
124
143
  message: failure.data.error,
125
144
  stage: failure.data.stage,
126
145
  retryable: failure.data.retryable,
127
- }));
146
+ };
147
+ if (failure.data.provider !== undefined)
148
+ projected.provider = failure.data.provider;
149
+ return z.json().parse(appMediaBrokerFailureSchema.parse(projected));
128
150
  }
129
151
  if (input.operation === "models")
130
152
  return z.json().parse(mediaModelsSchema.parse(value));
@@ -2,8 +2,10 @@ import { type MediaGenerationSettings } from "./index.js";
2
2
  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
+ import { type MediaFailureStage } from "./execution-error.js";
6
+ import { type MediaProviderDiagnostic } from "@fungi.computer/agar/errors";
5
7
  /** Fixed generation destination captured before provider dispatch. */
6
- export declare const mediaOperationDestinationSchema: z.ZodObject<{
8
+ export declare const mediaOperationDestinationSchema: z.ZodLazy<z.ZodObject<{
7
9
  computerId: z.ZodString;
8
10
  path: z.ZodString;
9
11
  outputFormat: z.ZodOptional<z.ZodEnum<{
@@ -11,7 +13,7 @@ export declare const mediaOperationDestinationSchema: z.ZodObject<{
11
13
  readonly jpeg: "jpeg";
12
14
  readonly webp: "webp";
13
15
  }>>;
14
- }, z.core.$strict>;
16
+ }, z.core.$strict>>;
15
17
  /** Normalized generation and its fixed destination, captured for exact replay. */
16
18
  export type MediaOperationRequest = MediaGenerationSettings & z.output<typeof mediaOperationDestinationSchema>;
17
19
  /** Decode host namespace and owner identity. */
@@ -43,19 +45,19 @@ export declare const mediaOperationStateSchema: z.ZodEnum<{
43
45
  /** Durable generation, save and settlement states. */
44
46
  export type MediaOperationState = z.output<typeof mediaOperationStateSchema>;
45
47
  /** Decode retained or saved output size and encoding. */
46
- export declare const mediaImageSchema: z.ZodObject<{
48
+ export declare const mediaImageSchema: z.ZodLazy<z.ZodObject<{
47
49
  bytes: z.ZodNumber;
48
50
  format: z.ZodString;
49
- }, z.core.$strict>;
51
+ }, z.core.$strict>>;
50
52
  /** Byte length and encoding of generated or saved output. */
51
53
  export type MediaImage = z.output<typeof mediaImageSchema>;
52
54
  /** Decode the settled receipt, including the host-admitted customer price. */
53
- export declare const mediaOperationResultSchema: z.ZodObject<{
55
+ export declare const mediaOperationResultSchema: z.ZodLazy<z.ZodObject<{
54
56
  generationId: z.ZodString;
55
57
  bytes: z.ZodNumber;
56
58
  format: z.ZodString;
57
59
  costMilliunits: z.ZodNumber;
58
- }, z.core.$strict>;
60
+ }, z.core.$strict>>;
59
61
  /** Settled generation receipt with the host-admitted customer price. */
60
62
  export type MediaOperationResult = z.output<typeof mediaOperationResultSchema>;
61
63
  /** The only operation shape safe to return outside the owner. */
@@ -72,8 +74,15 @@ export type MediaOperationProjection = Readonly<{
72
74
  state: MediaOperationState;
73
75
  /** Terminal format mismatch after provider execution. */
74
76
  spentFailure: "output_format_mismatch" | null;
75
- /** Definitive provider refusal with no delivered or billable output. */
76
- providerRefusal: "safety_filter_refused" | null;
77
+ /** Safe terminal provider failure; no original cause or provider message. */
78
+ providerFailure: Readonly<{
79
+ /** Provider dispatch or output normalization, not a save failure. */
80
+ stage: Extract<MediaFailureStage, "provider" | "normalization">;
81
+ /** Preserve the model's safety refusal classification on replay. */
82
+ safetyRefused: boolean;
83
+ /** Allowlisted facts only; never the original error message or cause. */
84
+ provider?: MediaProviderDiagnostic | undefined;
85
+ }> | null;
77
86
  /** Pinned host price or unmetered quote. */
78
87
  estimatedCostMilliunits: number | null;
79
88
  /** Retained or saved image metadata. */
@@ -182,8 +191,15 @@ export declare class MediaOperationOwner {
182
191
  state: MediaOperationState;
183
192
  /** Terminal format mismatch after provider execution. */
184
193
  spentFailure: "output_format_mismatch" | null;
185
- /** Definitive provider refusal with no delivered or billable output. */
186
- providerRefusal: "safety_filter_refused" | null;
194
+ /** Safe terminal provider failure; no original cause or provider message. */
195
+ providerFailure: Readonly<{
196
+ /** Provider dispatch or output normalization, not a save failure. */
197
+ stage: Extract<MediaFailureStage, "provider" | "normalization">;
198
+ /** Preserve the model's safety refusal classification on replay. */
199
+ safetyRefused: boolean;
200
+ /** Allowlisted facts only; never the original error message or cause. */
201
+ provider?: MediaProviderDiagnostic | undefined;
202
+ }> | null;
187
203
  /** Pinned host price or unmetered quote. */
188
204
  estimatedCostMilliunits: number | null;
189
205
  /** Retained or saved image metadata. */
@@ -204,7 +220,7 @@ export declare class MediaOperationOwner {
204
220
  /** Run a background generation once; a retried alarm never redispatches. */
205
221
  alarm(): Promise<void>;
206
222
  /** An aborted in-flight provider call is terminal for this request ID. */
207
- interruptGeneration(leaseId: string, refusalInput?: NonNullable<MediaOperationProjection["providerRefusal"]>): MediaOperationProjection;
223
+ interruptGeneration(leaseId: string, failureInput?: NonNullable<MediaOperationProjection["providerFailure"]>): MediaOperationProjection;
208
224
  /** Retain immutable provider output before making the save state visible. */
209
225
  recordGenerated(leaseId: string, bytes: Uint8Array, formatInput: string): Promise<MediaRetentionResult>;
210
226
  /** Read exact retained bytes under the current save lease. */
@@ -225,8 +241,15 @@ export declare class MediaOperationOwner {
225
241
  state: MediaOperationState;
226
242
  /** Terminal format mismatch after provider execution. */
227
243
  spentFailure: "output_format_mismatch" | null;
228
- /** Definitive provider refusal with no delivered or billable output. */
229
- providerRefusal: "safety_filter_refused" | null;
244
+ /** Safe terminal provider failure; no original cause or provider message. */
245
+ providerFailure: Readonly<{
246
+ /** Provider dispatch or output normalization, not a save failure. */
247
+ stage: Extract<MediaFailureStage, "provider" | "normalization">;
248
+ /** Preserve the model's safety refusal classification on replay. */
249
+ safetyRefused: boolean;
250
+ /** Allowlisted facts only; never the original error message or cause. */
251
+ provider?: MediaProviderDiagnostic | undefined;
252
+ }> | null;
230
253
  /** Pinned host price or unmetered quote. */
231
254
  estimatedCostMilliunits: number | null;
232
255
  /** Retained or saved image metadata. */
@@ -256,8 +279,15 @@ export declare class MediaOperationOwner {
256
279
  state: MediaOperationState;
257
280
  /** Terminal format mismatch after provider execution. */
258
281
  spentFailure: "output_format_mismatch" | null;
259
- /** Definitive provider refusal with no delivered or billable output. */
260
- providerRefusal: "safety_filter_refused" | null;
282
+ /** Safe terminal provider failure; no original cause or provider message. */
283
+ providerFailure: Readonly<{
284
+ /** Provider dispatch or output normalization, not a save failure. */
285
+ stage: Extract<MediaFailureStage, "provider" | "normalization">;
286
+ /** Preserve the model's safety refusal classification on replay. */
287
+ safetyRefused: boolean;
288
+ /** Allowlisted facts only; never the original error message or cause. */
289
+ provider?: MediaProviderDiagnostic | undefined;
290
+ }> | null;
261
291
  /** Pinned host price or unmetered quote. */
262
292
  estimatedCostMilliunits: number | null;
263
293
  /** Retained or saved image metadata. */
@@ -283,8 +313,15 @@ export declare class MediaOperationOwner {
283
313
  state: MediaOperationState;
284
314
  /** Terminal format mismatch after provider execution. */
285
315
  spentFailure: "output_format_mismatch" | null;
286
- /** Definitive provider refusal with no delivered or billable output. */
287
- providerRefusal: "safety_filter_refused" | null;
316
+ /** Safe terminal provider failure; no original cause or provider message. */
317
+ providerFailure: Readonly<{
318
+ /** Provider dispatch or output normalization, not a save failure. */
319
+ stage: Extract<MediaFailureStage, "provider" | "normalization">;
320
+ /** Preserve the model's safety refusal classification on replay. */
321
+ safetyRefused: boolean;
322
+ /** Allowlisted facts only; never the original error message or cause. */
323
+ provider?: MediaProviderDiagnostic | undefined;
324
+ }> | null;
288
325
  /** Pinned host price or unmetered quote. */
289
326
  estimatedCostMilliunits: number | null;
290
327
  /** Retained or saved image metadata. */