@fungi.computer/darkroom 0.11.33 → 0.11.35
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/app-media-contracts.js +27 -22
- package/dist/index.js +53 -43
- package/dist/media-binding.js +23 -21
- package/dist/model-catalog.js +77 -64
- package/package.json +2 -2
- package/src/app-media-contracts.ts +35 -30
- package/src/index.ts +48 -43
- package/src/media-binding.ts +37 -33
- package/src/model-catalog.ts +89 -68
package/dist/model-catalog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
/** An explicitly requested image encoding; video is outside this contract. */
|
|
3
|
-
export const mediaRequestedImageFormatSchema = z.enum({
|
|
3
|
+
export const mediaRequestedImageFormatSchema = /* @__PURE__ */ z.enum({
|
|
4
4
|
/** PNG image encoding. */
|
|
5
5
|
png: "png",
|
|
6
6
|
/** JPEG image encoding. */
|
|
@@ -13,7 +13,7 @@ export const mediaRequestedImageFormatSchema = z.enum({
|
|
|
13
13
|
* premium for art the user will see, and max for the most expensive models.
|
|
14
14
|
* One value per model; never a price.
|
|
15
15
|
*/
|
|
16
|
-
export const mediaModelTierSchema = z.enum({
|
|
16
|
+
export const mediaModelTierSchema = /* @__PURE__ */ z.enum({
|
|
17
17
|
/** Cheap, fast draft model. */
|
|
18
18
|
draft: "draft",
|
|
19
19
|
/** Balanced model selection. */
|
|
@@ -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, video and audio models. */
|
|
27
|
-
export const mediaModelInputSchema = z.lazy(() => z
|
|
27
|
+
export const mediaModelInputSchema = /* @__PURE__ */ z.lazy(() => z
|
|
28
28
|
.strictObject({
|
|
29
29
|
/**
|
|
30
30
|
* Provider input transport. Multipart is the binding's documented
|
|
@@ -104,7 +104,7 @@ export const mediaModelInputSchema = z.lazy(() => z
|
|
|
104
104
|
*/
|
|
105
105
|
export const MAX_REFERENCE_COUNT = 30;
|
|
106
106
|
/** Verified Unified AI video identifiers; no inferred family aliases. */
|
|
107
|
-
export const mediaVideoModelIdSchema = z.enum({
|
|
107
|
+
export const mediaVideoModelIdSchema = /* @__PURE__ */ z.enum({
|
|
108
108
|
/** Seedance 2.5. */
|
|
109
109
|
seedance25: "bytedance/seedance-2.5",
|
|
110
110
|
/** Seedance 2.0. */
|
|
@@ -121,7 +121,7 @@ export const mediaVideoModelIdSchema = z.enum({
|
|
|
121
121
|
minimaxH3Max: "minimax/h3-max",
|
|
122
122
|
});
|
|
123
123
|
/** Provider resolution selectors, refined against the selected catalog entry. */
|
|
124
|
-
export const mediaVideoResolutionSchema = z.enum({
|
|
124
|
+
export const mediaVideoResolutionSchema = /* @__PURE__ */ z.enum({
|
|
125
125
|
/** 480p. */
|
|
126
126
|
p480: "480p",
|
|
127
127
|
/** 720p. */
|
|
@@ -134,7 +134,7 @@ export const mediaVideoResolutionSchema = z.enum({
|
|
|
134
134
|
p4k: "4k",
|
|
135
135
|
});
|
|
136
136
|
/** Documented video aspect selectors, refined per model. */
|
|
137
|
-
export const mediaVideoAspectRatioSchema = z.enum({
|
|
137
|
+
export const mediaVideoAspectRatioSchema = /* @__PURE__ */ z.enum({
|
|
138
138
|
/** Landscape widescreen. */
|
|
139
139
|
wide: "16:9",
|
|
140
140
|
/** Landscape standard. */
|
|
@@ -151,7 +151,7 @@ export const mediaVideoAspectRatioSchema = z.enum({
|
|
|
151
151
|
ultratall: "9:21",
|
|
152
152
|
});
|
|
153
153
|
/** Explicit reference meaning; frame mode and reference mode are exclusive. */
|
|
154
|
-
export const mediaVideoReferenceRoleSchema = z.enum({
|
|
154
|
+
export const mediaVideoReferenceRoleSchema = /* @__PURE__ */ z.enum({
|
|
155
155
|
/** First frame; required when a last frame is supplied. */
|
|
156
156
|
first: "first-frame",
|
|
157
157
|
/** Last frame, supported by Seedance only (`last_frame_image`). */
|
|
@@ -160,7 +160,7 @@ export const mediaVideoReferenceRoleSchema = z.enum({
|
|
|
160
160
|
reference: "reference",
|
|
161
161
|
});
|
|
162
162
|
/** One nominal size used to select provider resolution and aspect. */
|
|
163
|
-
export const mediaVideoFormatSchema = z.lazy(() => z
|
|
163
|
+
export const mediaVideoFormatSchema = /* @__PURE__ */ z.lazy(() => z
|
|
164
164
|
.strictObject({
|
|
165
165
|
/** Provider resolution. */
|
|
166
166
|
resolution: mediaVideoResolutionSchema,
|
|
@@ -173,7 +173,7 @@ export const mediaVideoFormatSchema = z.lazy(() => z
|
|
|
173
173
|
})
|
|
174
174
|
.readonly());
|
|
175
175
|
/** Verified video parameters and provider costs, checked 2026-10-11. */
|
|
176
|
-
export const mediaVideoSchema = z.lazy(() => z
|
|
176
|
+
export const mediaVideoSchema = /* @__PURE__ */ z.lazy(() => z
|
|
177
177
|
.strictObject({
|
|
178
178
|
/** Minimum duration, for callers displaying bounds. */
|
|
179
179
|
minSeconds: z.number().int().positive(),
|
|
@@ -245,7 +245,7 @@ export const mediaVideoSchema = z.lazy(() => z
|
|
|
245
245
|
* answered 403 code 2047 ("not available via unified billing. Please use
|
|
246
246
|
* BYOK"), so they are not offered. Multilingual v2 is the default voice model.
|
|
247
247
|
*/
|
|
248
|
-
export const mediaAudioModelIdSchema = z.enum({
|
|
248
|
+
export const mediaAudioModelIdSchema = /* @__PURE__ */ z.enum({
|
|
249
249
|
/** Eleven Multilingual v2 text to speech. */
|
|
250
250
|
multilingual: "elevenlabs/eleven-multilingual-v2",
|
|
251
251
|
/** Eleven v3 expressive text to speech. */
|
|
@@ -254,7 +254,7 @@ export const mediaAudioModelIdSchema = z.enum({
|
|
|
254
254
|
music: "elevenlabs/music-v2",
|
|
255
255
|
});
|
|
256
256
|
/** One premade voice a speech model may speak with. */
|
|
257
|
-
export const mediaAudioVoiceSchema = z.lazy(() => z
|
|
257
|
+
export const mediaAudioVoiceSchema = /* @__PURE__ */ z.lazy(() => z
|
|
258
258
|
.strictObject({
|
|
259
259
|
/** ElevenLabs voice identifier, exactly as Cloudflare's docs list it. */
|
|
260
260
|
id: z.string().min(1).max(64),
|
|
@@ -263,7 +263,7 @@ export const mediaAudioVoiceSchema = z.lazy(() => z
|
|
|
263
263
|
})
|
|
264
264
|
.readonly());
|
|
265
265
|
/** Verified audio parameters and provider cost, checked 2026-11-13. */
|
|
266
|
-
export const mediaAudioSchema = z.lazy(() => z
|
|
266
|
+
export const mediaAudioSchema = /* @__PURE__ */ z.lazy(() => z
|
|
267
267
|
.strictObject({
|
|
268
268
|
/** Provider translation family. */
|
|
269
269
|
provider: z.literal("elevenlabs"),
|
|
@@ -307,7 +307,7 @@ const UNDOCUMENTED_PROMPT_LENGTH = 2_048;
|
|
|
307
307
|
* What a source-image operation does to its one reference image. Both write a
|
|
308
308
|
* new image and never touch the source.
|
|
309
309
|
*/
|
|
310
|
-
export const mediaTransformOperationSchema = z.enum({
|
|
310
|
+
export const mediaTransformOperationSchema = /* @__PURE__ */ z.enum({
|
|
311
311
|
/** Cut the foreground out onto a transparent PNG. */
|
|
312
312
|
remove_background: "remove_background",
|
|
313
313
|
/** Enlarge the image to a chosen output size in megapixels. */
|
|
@@ -318,7 +318,7 @@ export const mediaTransformOperationSchema = z.enum({
|
|
|
318
318
|
* from a prompt. The source limits are Botanical's own conservative bounds, not
|
|
319
319
|
* Cloudflare's: neither model page publishes an input size limit.
|
|
320
320
|
*/
|
|
321
|
-
export const mediaTransformSchema = z.lazy(() => z
|
|
321
|
+
export const mediaTransformSchema = /* @__PURE__ */ z.lazy(() => z
|
|
322
322
|
.strictObject({
|
|
323
323
|
/** What the operation does. */
|
|
324
324
|
operation: mediaTransformOperationSchema,
|
|
@@ -379,7 +379,7 @@ const TRANSFORM_SOURCE_MAX_PIXELS = 25_000_000;
|
|
|
379
379
|
* blocks of {@link AUDIO_CHARACTER_BLOCK} speech characters (so a per-character
|
|
380
380
|
* provider rate is marked up once per block, not rounded up per character).
|
|
381
381
|
*/
|
|
382
|
-
export const mediaBillingUnitSchema = z.enum({
|
|
382
|
+
export const mediaBillingUnitSchema = /* @__PURE__ */ z.enum({
|
|
383
383
|
/** One image. */
|
|
384
384
|
image: "image",
|
|
385
385
|
/** One whole second of video. */
|
|
@@ -400,14 +400,14 @@ export const mediaBillingUnit = (model) => {
|
|
|
400
400
|
return "image";
|
|
401
401
|
};
|
|
402
402
|
/** Public wire grammar for a catalog entry returned by the Media owner. */
|
|
403
|
-
export const mediaModelSchema = z
|
|
403
|
+
export const mediaModelSchema = /* @__PURE__ */ z
|
|
404
404
|
.strictObject({
|
|
405
405
|
/** Provider model identifier. */
|
|
406
|
-
id: z.string().min(1).max(256),
|
|
406
|
+
id: /* @__PURE__ */ z.string().min(1).max(256),
|
|
407
407
|
/** Customer-visible model label. */
|
|
408
|
-
label: z.string().min(1).max(512),
|
|
408
|
+
label: /* @__PURE__ */ z.string().min(1).max(512),
|
|
409
409
|
/** Outcome or model-kind discriminant. */
|
|
410
|
-
kind: z.enum({
|
|
410
|
+
kind: /* @__PURE__ */ z.enum({
|
|
411
411
|
/** Still-image generation. */
|
|
412
412
|
image: "image",
|
|
413
413
|
/** Video generation. */
|
|
@@ -418,26 +418,33 @@ export const mediaModelSchema = z
|
|
|
418
418
|
/** Model selection tier, independent of price. */
|
|
419
419
|
tier: mediaModelTierSchema,
|
|
420
420
|
/** Verified provider encodings; an empty list refuses pinned formats. */
|
|
421
|
-
outputFormats: z
|
|
421
|
+
outputFormats: /* @__PURE__ */ z
|
|
422
|
+
.array(mediaRequestedImageFormatSchema)
|
|
423
|
+
.max(3)
|
|
424
|
+
.readonly(),
|
|
422
425
|
/**
|
|
423
426
|
* Maximum prompt length in characters for this model: the provider's
|
|
424
427
|
* documented limit, or the retained 2,048 host cap where none is documented.
|
|
425
428
|
*/
|
|
426
|
-
maxPromptLength: z
|
|
429
|
+
maxPromptLength: /* @__PURE__ */ z
|
|
430
|
+
.number()
|
|
431
|
+
.int()
|
|
432
|
+
.positive()
|
|
433
|
+
.max(MAX_MEDIA_PROMPT_LENGTH),
|
|
427
434
|
/** Model-native input options and reference limits. */
|
|
428
435
|
input: mediaModelInputSchema,
|
|
429
436
|
/**
|
|
430
437
|
* Image output sizes or nominal video selectors, as `WIDTHxHEIGHT`; null means
|
|
431
438
|
* any size within the input bounds.
|
|
432
439
|
*/
|
|
433
|
-
sizes: z
|
|
434
|
-
.array(z.string().regex(/^\d+x\d+$/u))
|
|
440
|
+
sizes: /* @__PURE__ */ z
|
|
441
|
+
.array(/* @__PURE__ */ z.string().regex(/^\d+x\d+$/u))
|
|
435
442
|
.readonly()
|
|
436
443
|
.nullable(),
|
|
437
444
|
/** Video length constraints, or null for a still-image model. */
|
|
438
|
-
video: mediaVideoSchema.nullable(),
|
|
445
|
+
video: /* @__PURE__ */ mediaVideoSchema.nullable(),
|
|
439
446
|
/** Speech or music constraints, or null for an image or video model. */
|
|
440
|
-
audio: mediaAudioSchema.nullable(),
|
|
447
|
+
audio: /* @__PURE__ */ mediaAudioSchema.nullable(),
|
|
441
448
|
/**
|
|
442
449
|
* Price basis: the unit one generation bills in. The cost of those units
|
|
443
450
|
* depends on the settings (size, steps, resolution, sound, references), so
|
|
@@ -446,7 +453,7 @@ export const mediaModelSchema = z
|
|
|
446
453
|
*/
|
|
447
454
|
billingUnit: mediaBillingUnitSchema,
|
|
448
455
|
/** Source-image operation facts, or null for a model that generates from a prompt. */
|
|
449
|
-
transform: mediaTransformSchema.nullable(),
|
|
456
|
+
transform: /* @__PURE__ */ mediaTransformSchema.nullable(),
|
|
450
457
|
})
|
|
451
458
|
.readonly();
|
|
452
459
|
const freezeModel = (model) => {
|
|
@@ -488,7 +495,7 @@ const COMMON_IMAGE_RATIOS = [
|
|
|
488
495
|
[9, 16],
|
|
489
496
|
[21, 9],
|
|
490
497
|
];
|
|
491
|
-
const gptImageSizes = (() => {
|
|
498
|
+
const gptImageSizes = /* @__PURE__ */ (() => {
|
|
492
499
|
const keep = new Set(["1024x1024", "1024x1536", "1536x1024"]);
|
|
493
500
|
const standard = [];
|
|
494
501
|
const largest = [];
|
|
@@ -533,7 +540,7 @@ const commonRatioSizes = (area) => Object.freeze(COMMON_IMAGE_RATIOS.map(([acros
|
|
|
533
540
|
* https://developers.cloudflare.com/ai/models/bytedance/seedream-5-pro/
|
|
534
541
|
* https://developers.cloudflare.com/ai/models/bytedance/seedream-5-pro/schema-input.json
|
|
535
542
|
*/
|
|
536
|
-
const seedreamSizes = commonRatioSizes(1536 * 864);
|
|
543
|
+
const seedreamSizes = /* @__PURE__ */ commonRatioSizes(1536 * 864);
|
|
537
544
|
const videoShortEdges = {
|
|
538
545
|
"480p": 480,
|
|
539
546
|
"720p": 720,
|
|
@@ -566,7 +573,7 @@ const seedance25 = {
|
|
|
566
573
|
audioReferences: { max: 10, totalSeconds: 30 },
|
|
567
574
|
maxPromptLength: 25_000,
|
|
568
575
|
resolutions: ["480p", "720p"],
|
|
569
|
-
aspects: mediaVideoAspectRatioSchema.options.filter((aspectRatio) => aspectRatio !== mediaVideoAspectRatioSchema.enum.ultratall),
|
|
576
|
+
aspects: /* @__PURE__ */ mediaVideoAspectRatioSchema.options.filter((aspectRatio) => aspectRatio !== mediaVideoAspectRatioSchema.enum.ultratall),
|
|
570
577
|
};
|
|
571
578
|
function videoModel(id, label, tier, provider, rates, bounds) {
|
|
572
579
|
const seedance = provider === "seedance";
|
|
@@ -772,8 +779,11 @@ function minimaxVideoModel() {
|
|
|
772
779
|
* lists them.
|
|
773
780
|
* https://developers.cloudflare.com/ai/models/elevenlabs/eleven-v3/
|
|
774
781
|
*/
|
|
775
|
-
const premadeVoices = Object.freeze([
|
|
776
|
-
Object.freeze({
|
|
782
|
+
const premadeVoices = /* @__PURE__ */ Object.freeze([
|
|
783
|
+
/* @__PURE__ */ Object.freeze({
|
|
784
|
+
id: "JBFqnCBsd6RMkjVDRZzb",
|
|
785
|
+
label: "Default voice",
|
|
786
|
+
}),
|
|
777
787
|
]);
|
|
778
788
|
/**
|
|
779
789
|
* An ElevenLabs speech model. Text is at most 10,000 characters and a
|
|
@@ -890,12 +900,12 @@ function transformModel(input) {
|
|
|
890
900
|
},
|
|
891
901
|
});
|
|
892
902
|
}
|
|
893
|
-
const models = Object.freeze([
|
|
894
|
-
freezeModel({
|
|
903
|
+
const models = /* @__PURE__ */ Object.freeze([
|
|
904
|
+
/* @__PURE__ */ freezeModel({
|
|
895
905
|
id: "@cf/black-forest-labs/flux-1-schnell",
|
|
896
906
|
// 2,048 characters: input schema maxLength at developers.cloudflare.com/workers-ai/models/flux-1-schnell/.
|
|
897
907
|
maxPromptLength: 2_048,
|
|
898
|
-
outputFormats: Object.freeze(["jpeg"]),
|
|
908
|
+
outputFormats: /* @__PURE__ */ Object.freeze(["jpeg"]),
|
|
899
909
|
tier: "draft",
|
|
900
910
|
label: "Flux 1 Schnell — cheap/fast sketches",
|
|
901
911
|
input: {
|
|
@@ -916,7 +926,7 @@ const models = Object.freeze([
|
|
|
916
926
|
referenceFormat: "png",
|
|
917
927
|
},
|
|
918
928
|
}),
|
|
919
|
-
freezeModel({
|
|
929
|
+
/* @__PURE__ */ freezeModel({
|
|
920
930
|
id: "@cf/black-forest-labs/flux-2-klein-4b",
|
|
921
931
|
// Workers AI documents no prompt maxLength for this model; keep the 2,048 host cap.
|
|
922
932
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
@@ -940,7 +950,7 @@ const models = Object.freeze([
|
|
|
940
950
|
referenceFormat: "png",
|
|
941
951
|
},
|
|
942
952
|
}),
|
|
943
|
-
freezeModel({
|
|
953
|
+
/* @__PURE__ */ freezeModel({
|
|
944
954
|
id: "@cf/black-forest-labs/flux-2-klein-9b",
|
|
945
955
|
// Workers AI documents no prompt maxLength for this model; keep the 2,048 host cap.
|
|
946
956
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
@@ -964,7 +974,7 @@ const models = Object.freeze([
|
|
|
964
974
|
referenceFormat: "png",
|
|
965
975
|
},
|
|
966
976
|
}),
|
|
967
|
-
freezeModel({
|
|
977
|
+
/* @__PURE__ */ freezeModel({
|
|
968
978
|
id: "@cf/black-forest-labs/flux-2-dev",
|
|
969
979
|
// Workers AI documents no prompt maxLength for this model; keep the 2,048 host cap.
|
|
970
980
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
@@ -988,7 +998,7 @@ const models = Object.freeze([
|
|
|
988
998
|
referenceFormat: "png",
|
|
989
999
|
},
|
|
990
1000
|
}),
|
|
991
|
-
freezeModel({
|
|
1001
|
+
/* @__PURE__ */ freezeModel({
|
|
992
1002
|
id: "@cf/leonardo/lucid-origin",
|
|
993
1003
|
// Workers AI documents no prompt maxLength for this model; keep the 2,048 host cap.
|
|
994
1004
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
@@ -1015,7 +1025,7 @@ const models = Object.freeze([
|
|
|
1015
1025
|
referenceFormat: "png",
|
|
1016
1026
|
},
|
|
1017
1027
|
}),
|
|
1018
|
-
freezeModel({
|
|
1028
|
+
/* @__PURE__ */ freezeModel({
|
|
1019
1029
|
id: "@cf/leonardo/phoenix-1.0",
|
|
1020
1030
|
// Workers AI documents no prompt maxLength for this model; keep the 2,048 host cap.
|
|
1021
1031
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
@@ -1044,11 +1054,11 @@ const models = Object.freeze([
|
|
|
1044
1054
|
}),
|
|
1045
1055
|
// Third-party models run through the AI Gateway (Unified Billing): OpenAI's
|
|
1046
1056
|
// image model and ByteDance's video model return a result URL, not bytes.
|
|
1047
|
-
freezeModel({
|
|
1057
|
+
/* @__PURE__ */ freezeModel({
|
|
1048
1058
|
id: "openai/gpt-image-2",
|
|
1049
1059
|
// 32,000 characters: OpenAI's Images API reference gives GPT image models a 32000-character prompt limit.
|
|
1050
1060
|
maxPromptLength: 32_000,
|
|
1051
|
-
outputFormats: Object.freeze(["png", "jpeg", "webp"]),
|
|
1061
|
+
outputFormats: /* @__PURE__ */ Object.freeze(["png", "jpeg", "webp"]),
|
|
1052
1062
|
tier: "premium",
|
|
1053
1063
|
label: "GPT Image 2 — strong text and layout, premium",
|
|
1054
1064
|
sizes: gptImageSizes,
|
|
@@ -1080,13 +1090,13 @@ const models = Object.freeze([
|
|
|
1080
1090
|
referenceFormat: "webp",
|
|
1081
1091
|
},
|
|
1082
1092
|
}),
|
|
1083
|
-
freezeModel({
|
|
1093
|
+
/* @__PURE__ */ freezeModel({
|
|
1084
1094
|
id: "bytedance/seedream-5-pro",
|
|
1085
1095
|
// The page documents no prompt maxLength (schema-input.json has none):
|
|
1086
1096
|
// keep the 2,048 host cap.
|
|
1087
1097
|
maxPromptLength: UNDOCUMENTED_PROMPT_LENGTH,
|
|
1088
1098
|
// The page's example results are .jpeg URLs; the schema has no format field.
|
|
1089
|
-
outputFormats: Object.freeze(["jpeg"]),
|
|
1099
|
+
outputFormats: /* @__PURE__ */ Object.freeze(["jpeg"]),
|
|
1090
1100
|
tier: "premium",
|
|
1091
1101
|
label: "Seedream 5 Pro — ByteDance, high-quality images",
|
|
1092
1102
|
sizes: seedreamSizes,
|
|
@@ -1111,7 +1121,7 @@ const models = Object.freeze([
|
|
|
1111
1121
|
referenceFormat: "png",
|
|
1112
1122
|
},
|
|
1113
1123
|
}),
|
|
1114
|
-
transformModel({
|
|
1124
|
+
/* @__PURE__ */ transformModel({
|
|
1115
1125
|
id: "bria/remove-background",
|
|
1116
1126
|
label: "Remove background — Bria RMBG 2.0",
|
|
1117
1127
|
tier: "draft",
|
|
@@ -1121,7 +1131,7 @@ const models = Object.freeze([
|
|
|
1121
1131
|
sizes: [],
|
|
1122
1132
|
defaultMegapixels: null,
|
|
1123
1133
|
}),
|
|
1124
|
-
transformModel({
|
|
1134
|
+
/* @__PURE__ */ transformModel({
|
|
1125
1135
|
id: "pruna/p-image-upscale",
|
|
1126
1136
|
label: "Upscale — Pruna P-Image-Upscale",
|
|
1127
1137
|
tier: "draft",
|
|
@@ -1130,43 +1140,43 @@ const models = Object.freeze([
|
|
|
1130
1140
|
// WebP keeps transparency.
|
|
1131
1141
|
outputFormat: "webp",
|
|
1132
1142
|
flatUsd: null,
|
|
1133
|
-
sizes: UPSCALE_TARGET_MEGAPIXELS.map((megapixels) => ({
|
|
1143
|
+
sizes: /* @__PURE__ */ UPSCALE_TARGET_MEGAPIXELS.map((megapixels) => ({
|
|
1134
1144
|
megapixels,
|
|
1135
1145
|
usd: upscaleTierUsd(megapixels),
|
|
1136
1146
|
})),
|
|
1137
1147
|
defaultMegapixels: 4,
|
|
1138
1148
|
}),
|
|
1139
|
-
videoModel(mediaVideoModelIdSchema.enum.seedance25, "Seedance 2.5", "balanced", "seedance", [
|
|
1149
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.seedance25, "Seedance 2.5", "balanced", "seedance", [
|
|
1140
1150
|
["480p", 10_280, 10_280],
|
|
1141
1151
|
["720p", 23_120, 23_120],
|
|
1142
1152
|
], seedance25),
|
|
1143
|
-
videoModel(mediaVideoModelIdSchema.enum.seedance, "Seedance 2.0", "balanced", "seedance", [
|
|
1153
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.seedance, "Seedance 2.0", "balanced", "seedance", [
|
|
1144
1154
|
["480p", 7_000, 7_000],
|
|
1145
1155
|
["720p", 15_000, 15_000],
|
|
1146
1156
|
["1080p", 37_000, 37_000],
|
|
1147
1157
|
["4k", 78_000, 78_000],
|
|
1148
1158
|
]),
|
|
1149
|
-
videoModel(mediaVideoModelIdSchema.enum.seedanceFast, "Seedance 2.0 Fast", "draft", "seedance", [
|
|
1159
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.seedanceFast, "Seedance 2.0 Fast", "draft", "seedance", [
|
|
1150
1160
|
["480p", 6_000, 6_000],
|
|
1151
1161
|
["720p", 12_000, 12_000],
|
|
1152
1162
|
]),
|
|
1153
|
-
videoModel(mediaVideoModelIdSchema.enum.seedanceMini, "Seedance 2.0 Mini", "draft", "seedance", [
|
|
1163
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.seedanceMini, "Seedance 2.0 Mini", "draft", "seedance", [
|
|
1154
1164
|
["480p", 4_000, 4_000],
|
|
1155
1165
|
["720p", 9_000, 9_000],
|
|
1156
1166
|
]),
|
|
1157
|
-
videoModel(mediaVideoModelIdSchema.enum.veo, "Veo 3.1", "premium", "veo", [
|
|
1167
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.veo, "Veo 3.1", "premium", "veo", [
|
|
1158
1168
|
["720p", 20_000, 40_000],
|
|
1159
1169
|
["1080p", 20_000, 40_000],
|
|
1160
1170
|
]),
|
|
1161
|
-
videoModel(mediaVideoModelIdSchema.enum.veoFast, "Veo 3.1 Fast", "balanced", "veo", [
|
|
1171
|
+
/* @__PURE__ */ videoModel(mediaVideoModelIdSchema.enum.veoFast, "Veo 3.1 Fast", "balanced", "veo", [
|
|
1162
1172
|
["720p", 8_000, 10_000],
|
|
1163
1173
|
["1080p", 10_000, 12_000],
|
|
1164
1174
|
]),
|
|
1165
|
-
minimaxVideoModel(),
|
|
1175
|
+
/* @__PURE__ */ minimaxVideoModel(),
|
|
1166
1176
|
// ElevenLabs on Unified Billing: URL results, like the video models.
|
|
1167
|
-
speechModel(mediaAudioModelIdSchema.enum.multilingual, "Eleven Multilingual v2 — natural speech", "balanced", 10),
|
|
1168
|
-
speechModel(mediaAudioModelIdSchema.enum.v3, "Eleven v3 — expressive speech", "premium", 10),
|
|
1169
|
-
musicModel(),
|
|
1177
|
+
/* @__PURE__ */ speechModel(mediaAudioModelIdSchema.enum.multilingual, "Eleven Multilingual v2 — natural speech", "balanced", 10),
|
|
1178
|
+
/* @__PURE__ */ speechModel(mediaAudioModelIdSchema.enum.v3, "Eleven v3 — expressive speech", "premium", 10),
|
|
1179
|
+
/* @__PURE__ */ musicModel(),
|
|
1170
1180
|
]);
|
|
1171
1181
|
/** The Fungi gateway provider's own immutable image, video and audio model catalog. */
|
|
1172
1182
|
export const mediaModels = models;
|
|
@@ -1175,27 +1185,30 @@ export const mediaModels = models;
|
|
|
1175
1185
|
* video model may name `host` as its provider family: the injected provider
|
|
1176
1186
|
* owns that model's wire grammar and Darkroom builds no gateway request for it.
|
|
1177
1187
|
*/
|
|
1178
|
-
export const mediaCatalogueModelSchema = mediaModelSchema
|
|
1188
|
+
export const mediaCatalogueModelSchema = /* @__PURE__ */ mediaModelSchema
|
|
1179
1189
|
.unwrap()
|
|
1180
1190
|
.extend({
|
|
1181
1191
|
/** Optional on a host's entry because Darkroom derives it; a stated value must match. */
|
|
1182
|
-
billingUnit: mediaBillingUnitSchema.optional(),
|
|
1192
|
+
billingUnit: /* @__PURE__ */ mediaBillingUnitSchema.optional(),
|
|
1183
1193
|
/** Speech or music constraints; a host's catalogue omits it unless it lists audio models. */
|
|
1184
|
-
audio: mediaAudioSchema.unwrap().nullable().default(null),
|
|
1194
|
+
audio: /* @__PURE__ */ mediaAudioSchema.unwrap().nullable().default(null),
|
|
1185
1195
|
/** Source-image operation facts; a host's catalogue omits it unless it lists such models. */
|
|
1186
|
-
transform: mediaTransformSchema
|
|
1196
|
+
transform: /* @__PURE__ */ mediaTransformSchema
|
|
1197
|
+
.unwrap()
|
|
1198
|
+
.nullable()
|
|
1199
|
+
.default(null),
|
|
1187
1200
|
/** Video length constraints, or null for a still-image model. */
|
|
1188
|
-
video: mediaVideoSchema
|
|
1201
|
+
video: /* @__PURE__ */ mediaVideoSchema
|
|
1189
1202
|
.unwrap()
|
|
1190
1203
|
.unwrap()
|
|
1191
1204
|
.extend({
|
|
1192
1205
|
/** Audio reference limits; a host's catalogue omits it unless its model takes audio references. */
|
|
1193
|
-
audioReferences: mediaVideoSchema
|
|
1206
|
+
audioReferences: /* @__PURE__ */ mediaVideoSchema
|
|
1194
1207
|
.unwrap()
|
|
1195
1208
|
.unwrap()
|
|
1196
1209
|
.shape.audioReferences.default(null),
|
|
1197
1210
|
/** Provider translation family, or `host` for a host-injected provider. */
|
|
1198
|
-
provider: z.enum({
|
|
1211
|
+
provider: /* @__PURE__ */ z.enum({
|
|
1199
1212
|
/** Seedance integer duration and data-URI image fields. */
|
|
1200
1213
|
seedance: "seedance",
|
|
1201
1214
|
/** Veo duration string and base64 image_input. */
|
|
@@ -1218,7 +1231,7 @@ const MAX_CATALOGUE_MODELS = 256;
|
|
|
1218
1231
|
* validator relies on (unique ids, video metadata iff `kind` is video, defaults
|
|
1219
1232
|
* inside their own bounds).
|
|
1220
1233
|
*/
|
|
1221
|
-
export const mediaCatalogueSchema = z
|
|
1234
|
+
export const mediaCatalogueSchema = /* @__PURE__ */ z
|
|
1222
1235
|
.array(mediaCatalogueModelSchema)
|
|
1223
1236
|
.min(1)
|
|
1224
1237
|
.max(MAX_CATALOGUE_MODELS)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/darkroom",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.35",
|
|
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",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"exifreader": "4.46.0",
|
|
67
67
|
"@fungi.computer/ts-webp": "0.1.6",
|
|
68
68
|
"@xmldom/xmldom": "0.9.12",
|
|
69
|
-
"@fungi.computer/agar": "0.
|
|
69
|
+
"@fungi.computer/agar": "0.31.0",
|
|
70
70
|
"@fungi.computer/capnweb": "0.12.0-fungi.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
@@ -6,45 +6,49 @@ import { mediaFailureSchema } from "./browser-failure.js";
|
|
|
6
6
|
import { mediaGenerationSettingsSchema } from "./index.js";
|
|
7
7
|
|
|
8
8
|
/** A labelled estimate for one explicitly described generation, never a receipt. */
|
|
9
|
-
export const mediaModelPriceEstimateSchema = z.strictObject({
|
|
9
|
+
export const mediaModelPriceEstimateSchema = /* @__PURE__ */ z.strictObject({
|
|
10
10
|
/** Quotes are indicative; the admitted generation owns its charge. */
|
|
11
|
-
kind: z.literal("estimate"),
|
|
11
|
+
kind: /* @__PURE__ */ z.literal("estimate"),
|
|
12
12
|
/** Unmetered hosts pay provider cost; funded hosts apply their billing policy. */
|
|
13
|
-
basis: z.enum({
|
|
13
|
+
basis: /* @__PURE__ */ z.enum({
|
|
14
14
|
/** Provider cost before the host's billing policy. */
|
|
15
15
|
"provider-cost": "provider-cost",
|
|
16
16
|
/** Team charge estimate after the host's billing policy. */
|
|
17
17
|
"team-price": "team-price",
|
|
18
18
|
}),
|
|
19
19
|
/** Milliunits of a cent, at the quoted settings. */
|
|
20
|
-
costMilliunits: z
|
|
20
|
+
costMilliunits: /* @__PURE__ */ z
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.nonnegative()
|
|
24
|
+
.max(Number.MAX_SAFE_INTEGER),
|
|
21
25
|
/** Defaults, a one-character prompt and no references; varying these changes cost. */
|
|
22
26
|
settings: mediaGenerationSettingsSchema,
|
|
23
27
|
});
|
|
24
28
|
/** Host catalog projection; provider metadata remains owned by the sole catalog. */
|
|
25
|
-
export const mediaCatalogModelSchema = mediaModelSchema
|
|
29
|
+
export const mediaCatalogModelSchema = /* @__PURE__ */ mediaModelSchema
|
|
26
30
|
.unwrap()
|
|
27
31
|
.extend({
|
|
28
32
|
/** Optional host estimate with explicit assumptions and funding basis. */
|
|
29
|
-
priceEstimate: mediaModelPriceEstimateSchema.optional(),
|
|
33
|
+
priceEstimate: /* @__PURE__ */ mediaModelPriceEstimateSchema.optional(),
|
|
30
34
|
})
|
|
31
35
|
.readonly();
|
|
32
36
|
|
|
33
37
|
/** Bounded catalog decoded by the App media broker before host filtering. */
|
|
34
|
-
export const mediaModelsSchema = z.lazy(() =>
|
|
38
|
+
export const mediaModelsSchema = /* @__PURE__ */ z.lazy(() =>
|
|
35
39
|
z.array(mediaCatalogModelSchema).max(listMediaModels().length),
|
|
36
40
|
);
|
|
37
41
|
|
|
38
42
|
/** An absolute output path on the Computer admitted by the App host. */
|
|
39
|
-
export const destinationSchema = z.strictObject({
|
|
43
|
+
export const destinationSchema = /* @__PURE__ */ z.strictObject({
|
|
40
44
|
/** Computer admitted by the host. */
|
|
41
|
-
computerId: z.string().min(1).max(256),
|
|
45
|
+
computerId: /* @__PURE__ */ z.string().min(1).max(256),
|
|
42
46
|
/** Absolute Computer output path. */
|
|
43
|
-
path: z.string().startsWith("/").max(1_024),
|
|
47
|
+
path: /* @__PURE__ */ z.string().startsWith("/").max(1_024),
|
|
44
48
|
});
|
|
45
49
|
|
|
46
50
|
/** Completed App generation output, with its admitted Computer destination. */
|
|
47
|
-
export const appMediaGenerationResultSchema = mediaResultSchema
|
|
51
|
+
export const appMediaGenerationResultSchema = /* @__PURE__ */ mediaResultSchema
|
|
48
52
|
.omit({ path: true })
|
|
49
53
|
.extend({
|
|
50
54
|
/** Admitted Computer and absolute output path. */
|
|
@@ -52,9 +56,9 @@ export const appMediaGenerationResultSchema = mediaResultSchema
|
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
/** Authority refusals emitted by Media admission before a host call. */
|
|
55
|
-
export const appMediaAdmissionErrorSchema = z.strictObject({
|
|
59
|
+
export const appMediaAdmissionErrorSchema = /* @__PURE__ */ z.strictObject({
|
|
56
60
|
/** Existing admission refusal code. */
|
|
57
|
-
error: z.enum({
|
|
61
|
+
error: /* @__PURE__ */ z.enum({
|
|
58
62
|
/** The captured App selection or attachment changed. */
|
|
59
63
|
revoked: "revoked",
|
|
60
64
|
/** The caller does not hold this Media grant. */
|
|
@@ -67,7 +71,7 @@ export const appMediaAdmissionErrorSchema = z.strictObject({
|
|
|
67
71
|
});
|
|
68
72
|
|
|
69
73
|
/** Attachment budget refusal emitted by the Media reservation owner. */
|
|
70
|
-
export const appMediaBudgetRefusalSchema = z.lazy(() =>
|
|
74
|
+
export const appMediaBudgetRefusalSchema = /* @__PURE__ */ z.lazy(() =>
|
|
71
75
|
z.strictObject({
|
|
72
76
|
/** The attachment's operation budget refused this request. */
|
|
73
77
|
error: z.literal("attachment_budget_exceeded"),
|
|
@@ -79,25 +83,26 @@ export const appMediaBudgetRefusalSchema = z.lazy(() =>
|
|
|
79
83
|
);
|
|
80
84
|
|
|
81
85
|
/** Existing Media admission refusals, without an admitted selector or callable. */
|
|
82
|
-
export const appMediaAdmissionRefusalSchema = z.union([
|
|
86
|
+
export const appMediaAdmissionRefusalSchema = /* @__PURE__ */ z.union([
|
|
83
87
|
appMediaAdmissionErrorSchema,
|
|
84
88
|
appMediaBudgetRefusalSchema,
|
|
85
89
|
]);
|
|
86
90
|
|
|
87
91
|
/** Admission errors plus invalid/oversized inputs emitted directly by the broker. */
|
|
88
|
-
export const appMediaBrokerErrorSchema =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
92
|
+
export const appMediaBrokerErrorSchema =
|
|
93
|
+
/* @__PURE__ */ appMediaAdmissionErrorSchema.extend({
|
|
94
|
+
/** Existing broker refusal code. */
|
|
95
|
+
error: /* @__PURE__ */ z.enum({
|
|
96
|
+
...appMediaAdmissionErrorSchema.shape.error.enum,
|
|
97
|
+
/** The broker refused the input representation or selection. */
|
|
98
|
+
invalid: "invalid",
|
|
99
|
+
/** The input exceeds the existing broker byte ceiling. */
|
|
100
|
+
too_large: "too_large",
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
98
103
|
|
|
99
104
|
/** Missing-library refusal decoded and returned by the App media broker. */
|
|
100
|
-
export const agentAppMediaLibraryFailureSchema = z.lazy(() =>
|
|
105
|
+
export const agentAppMediaLibraryFailureSchema = /* @__PURE__ */ z.lazy(() =>
|
|
101
106
|
z.strictObject({
|
|
102
107
|
/** The calling Installation's library is unavailable. */
|
|
103
108
|
error: z.literal("library_unavailable"),
|
|
@@ -107,7 +112,7 @@ export const agentAppMediaLibraryFailureSchema = z.lazy(() =>
|
|
|
107
112
|
);
|
|
108
113
|
|
|
109
114
|
/** Broker projection of an HTTP failure: code becomes error and error becomes message. */
|
|
110
|
-
export const appMediaBrokerFailureSchema = z.strictObject({
|
|
115
|
+
export const appMediaBrokerFailureSchema = /* @__PURE__ */ z.strictObject({
|
|
111
116
|
/** Original typed HTTP failure code. */
|
|
112
117
|
error: mediaFailureSchema.shape.code,
|
|
113
118
|
/** Original HTTP failure presentation copy. */
|
|
@@ -121,7 +126,7 @@ export const appMediaBrokerFailureSchema = z.strictObject({
|
|
|
121
126
|
});
|
|
122
127
|
|
|
123
128
|
/** Refusal payloads emitted by the App media broker, separate from transport errors. */
|
|
124
|
-
export const appMediaRefusalSchema = z.union([
|
|
129
|
+
export const appMediaRefusalSchema = /* @__PURE__ */ z.union([
|
|
125
130
|
appMediaBrokerErrorSchema,
|
|
126
131
|
appMediaBudgetRefusalSchema,
|
|
127
132
|
agentAppMediaLibraryFailureSchema,
|
|
@@ -129,13 +134,13 @@ export const appMediaRefusalSchema = z.union([
|
|
|
129
134
|
]);
|
|
130
135
|
|
|
131
136
|
/** Model-list payload or an existing broker refusal. */
|
|
132
|
-
export const appMediaModelsOutcomeSchema = z.union([
|
|
137
|
+
export const appMediaModelsOutcomeSchema = /* @__PURE__ */ z.union([
|
|
133
138
|
mediaModelsSchema,
|
|
134
139
|
appMediaRefusalSchema,
|
|
135
140
|
]);
|
|
136
141
|
|
|
137
142
|
/** Completed generation, Agar polling result, or an existing broker refusal. */
|
|
138
|
-
export const appMediaGenerationOutcomeSchema = z.union([
|
|
143
|
+
export const appMediaGenerationOutcomeSchema = /* @__PURE__ */ z.union([
|
|
139
144
|
appMediaGenerationResultSchema,
|
|
140
145
|
pendingSchema,
|
|
141
146
|
appMediaRefusalSchema,
|