@fungi.computer/darkroom 0.7.0 → 0.8.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/README.md +49 -0
- package/dist/app-media-contracts.d.ts +103 -12
- package/dist/audio-providers/elevenlabs.d.ts +40 -0
- package/dist/audio-providers/elevenlabs.js +69 -0
- package/dist/audio-reference-types.d.ts +28 -0
- package/dist/audio-reference-types.js +16 -0
- package/dist/audio-references.d.ts +14 -0
- package/dist/audio-references.js +69 -0
- package/dist/cloudflare/provider.d.ts +6 -4
- package/dist/cloudflare/provider.js +37 -19
- package/dist/gateway-models.d.ts +12 -8
- package/dist/gateway-models.js +38 -17
- package/dist/index.d.ts +70 -15
- package/dist/index.js +118 -7
- package/dist/media-binding.d.ts +60 -7
- package/dist/media-binding.js +41 -19
- package/dist/media-generation.js +12 -3
- package/dist/media-operation-contract.d.ts +7 -3
- package/dist/media-operation-contract.js +6 -4
- package/dist/media-operation-owner.d.ts +2 -2
- package/dist/media-operation-owner.js +48 -6
- package/dist/media-operation.js +4 -2
- package/dist/model-catalog.d.ts +169 -4
- package/dist/model-catalog.js +180 -4
- package/dist/server.d.ts +14 -7
- package/dist/server.js +9 -4
- package/dist/video-providers/reference-encoding.d.ts +7 -2
- package/dist/video-providers/reference-encoding.js +14 -3
- package/dist/video-providers/types.d.ts +2 -2
- package/dist/video-providers/unified.d.ts +1 -0
- package/dist/video-providers/unified.js +4 -2
- package/docs/api/app-media-contracts.md +46 -10
- package/docs/api/cloudflare.md +3 -3
- package/docs/api/index.md +598 -84
- package/docs/api/server.md +129 -62
- package/package.json +3 -2
|
@@ -23,6 +23,11 @@ const referenceMetadataSchema = z.lazy(() => z.object({
|
|
|
23
23
|
height: z.coerce.number().int().positive(),
|
|
24
24
|
}));
|
|
25
25
|
const referenceKey = (operationId, index) => `media-reference/v1/${operationId}/${String(index)}`;
|
|
26
|
+
const audioReferenceMetadataSchema = z.lazy(() => z.object({
|
|
27
|
+
mimeType: z.enum(["audio/mpeg", "audio/mp4", "audio/wav", "audio/ogg"]),
|
|
28
|
+
durationSeconds: z.coerce.number().positive(),
|
|
29
|
+
}));
|
|
30
|
+
const audioReferenceKey = (operationId, index) => `media-audio-reference/v1/${operationId}/${String(index)}`;
|
|
26
31
|
/** Fixed generation destination captured before provider dispatch. */
|
|
27
32
|
export const mediaOperationDestinationSchema = z.lazy(() => z.strictObject({
|
|
28
33
|
/** Host-admitted destination or reference identity. */
|
|
@@ -66,13 +71,21 @@ export const mediaImageSchema = z.lazy(() => z.strictObject({
|
|
|
66
71
|
format: text,
|
|
67
72
|
}));
|
|
68
73
|
const retainedFormatSchema = z.lazy(() => z
|
|
69
|
-
.enum([
|
|
74
|
+
.enum([
|
|
75
|
+
"image/png",
|
|
76
|
+
"image/jpeg",
|
|
77
|
+
"image/gif",
|
|
78
|
+
"image/webp",
|
|
79
|
+
"video/mp4",
|
|
80
|
+
"audio/mpeg",
|
|
81
|
+
])
|
|
70
82
|
.transform((mime) => ({
|
|
71
83
|
"image/png": "png",
|
|
72
84
|
"image/jpeg": "jpeg",
|
|
73
85
|
"image/gif": "gif",
|
|
74
86
|
"image/webp": "webp",
|
|
75
87
|
"video/mp4": "mp4",
|
|
88
|
+
"audio/mpeg": "mp3",
|
|
76
89
|
})[mime]));
|
|
77
90
|
const outputSchema = z.lazy(() => z.strictObject({
|
|
78
91
|
key: text,
|
|
@@ -102,7 +115,11 @@ class MediaOperationError extends Error {
|
|
|
102
115
|
}
|
|
103
116
|
}
|
|
104
117
|
/** Stored media type for an output format. */
|
|
105
|
-
const outputMime = (format) => format === "mp4"
|
|
118
|
+
const outputMime = (format) => format === "mp4"
|
|
119
|
+
? "video/mp4"
|
|
120
|
+
: format === "mp3"
|
|
121
|
+
? "audio/mpeg"
|
|
122
|
+
: `image/${format}`;
|
|
106
123
|
const operationRowSchema = z.lazy(() => z.object({
|
|
107
124
|
operation_id: z.string(),
|
|
108
125
|
request_id: z.string(),
|
|
@@ -361,7 +378,11 @@ export class MediaOperationOwner {
|
|
|
361
378
|
const record = this.readRecord();
|
|
362
379
|
if (record?.namespace !== namespace ||
|
|
363
380
|
record.state !== "succeeded" ||
|
|
364
|
-
record.output === null
|
|
381
|
+
record.output === null ||
|
|
382
|
+
// Public sharing covers pictures and video; audio has no dimensions to
|
|
383
|
+
// show and no public page yet.
|
|
384
|
+
record.input.width === undefined ||
|
|
385
|
+
record.input.height === undefined)
|
|
365
386
|
return null;
|
|
366
387
|
return Object.freeze({
|
|
367
388
|
requestId: record.requestId,
|
|
@@ -652,7 +673,7 @@ export class MediaOperationOwner {
|
|
|
652
673
|
* returns at once; the alarm dispatches the provider exactly once, retains
|
|
653
674
|
* the output, and releases the lease so a later retry saves and charges it.
|
|
654
675
|
*/
|
|
655
|
-
async dispatchInBackground(leaseId, references) {
|
|
676
|
+
async dispatchInBackground(leaseId, references, audioReferences) {
|
|
656
677
|
const record = this.requireRecord();
|
|
657
678
|
if (record.state !== "generating" || record.leaseId !== leaseId)
|
|
658
679
|
throw new MediaOperationError("lease_lost");
|
|
@@ -665,6 +686,14 @@ export class MediaOperationOwner {
|
|
|
665
686
|
},
|
|
666
687
|
});
|
|
667
688
|
}
|
|
689
|
+
for (const [index, clip] of audioReferences.entries()) {
|
|
690
|
+
await this.env.APP_ARTIFACTS.put(audioReferenceKey(record.operationId, index), clip.bytes, {
|
|
691
|
+
customMetadata: {
|
|
692
|
+
mimeType: clip.mimeType,
|
|
693
|
+
durationSeconds: String(clip.durationSeconds),
|
|
694
|
+
},
|
|
695
|
+
});
|
|
696
|
+
}
|
|
668
697
|
const timestamp = Date.now();
|
|
669
698
|
this.ctx.storage.sql.exec("UPDATE hub_media_operation SET background=1, lease_expires_at=?, updated_at=? WHERE singleton=1 AND state='generating' AND lease_id=?", timestamp + this.backgroundLeaseMs, timestamp, leaseId);
|
|
670
699
|
await this.ctx.storage.setAlarm(timestamp);
|
|
@@ -711,9 +740,19 @@ export class MediaOperationOwner {
|
|
|
711
740
|
bytes: new Uint8Array(await object.arrayBuffer()),
|
|
712
741
|
};
|
|
713
742
|
}));
|
|
743
|
+
const audioReferences = await Promise.all((record.input.audioReferences ?? []).map(async (_reference, index) => {
|
|
744
|
+
const object = await this.env.APP_ARTIFACTS.get(audioReferenceKey(record.operationId, index));
|
|
745
|
+
if (object === null)
|
|
746
|
+
throw new Error("Media audio reference is unavailable");
|
|
747
|
+
const metadata = audioReferenceMetadataSchema.parse(object.customMetadata);
|
|
748
|
+
return {
|
|
749
|
+
...metadata,
|
|
750
|
+
bytes: new Uint8Array(await object.arrayBuffer()),
|
|
751
|
+
};
|
|
752
|
+
}));
|
|
714
753
|
// The captured request includes destination authority; providers receive settings only.
|
|
715
754
|
const settings = validateMediaGenerationSettings(mediaGenerationSettingsSchema.strip().parse(record.input), this.catalogue());
|
|
716
|
-
output = await provider(settings, references, undefined, record.input.outputFormat);
|
|
755
|
+
output = await provider(settings, references, undefined, record.input.outputFormat, audioReferences);
|
|
717
756
|
}
|
|
718
757
|
catch (cause) {
|
|
719
758
|
reportCatchFailure("media-operation-provider", cause);
|
|
@@ -736,7 +775,10 @@ export class MediaOperationOwner {
|
|
|
736
775
|
return;
|
|
737
776
|
}
|
|
738
777
|
await this.recordGenerated(leaseId, output.bytes, output.format);
|
|
739
|
-
await Promise.all(
|
|
778
|
+
await Promise.all([
|
|
779
|
+
...(record.input.references ?? []).map((_reference, index) => this.env.APP_ARTIFACTS.delete(referenceKey(record.operationId, index))),
|
|
780
|
+
...(record.input.audioReferences ?? []).map((_reference, index) => this.env.APP_ARTIFACTS.delete(audioReferenceKey(record.operationId, index))),
|
|
781
|
+
]).catch((cause) => {
|
|
740
782
|
reportCatchFailure("media-reference-cleanup", cause);
|
|
741
783
|
});
|
|
742
784
|
// Release the lease: the next retry of this request claims the save.
|
package/dist/media-operation.js
CHANGED
|
@@ -59,7 +59,8 @@ export function executeMediaOperation(input) {
|
|
|
59
59
|
const metering = input.metering === "unmetered" ? null : input.metering;
|
|
60
60
|
const operationId = admission.operation.operationId;
|
|
61
61
|
const billed = mediaUnits(validateMediaGenerationSettings(mediaGenerationSettingsSchema.strip().parse(input.request), input.catalogue), input.catalogue);
|
|
62
|
-
|
|
62
|
+
// Video and audio run through the durable alarm; only an image is inline.
|
|
63
|
+
const background = getMediaModel(input.request.model, input.catalogue)?.kind !== "image";
|
|
63
64
|
/** Best-effort release; true proves customer settlement, not supplier billing. */
|
|
64
65
|
const settleNothing = () => metering === null
|
|
65
66
|
? Effect.succeed(false)
|
|
@@ -138,7 +139,7 @@ export function executeMediaOperation(input) {
|
|
|
138
139
|
if (background) {
|
|
139
140
|
// Video outlives one request: the owner's alarm generates, and a
|
|
140
141
|
// retry of this request id saves and charges the retained output.
|
|
141
|
-
yield* call(() => input.operation.dispatchInBackground(leaseId, prepared.references), "operation").pipe(Effect.tapError(() => call(() => input.operation.interruptGeneration(leaseId), "operation").pipe(Effect.andThen(settleNothing()), Effect.ignore)));
|
|
142
|
+
yield* call(() => input.operation.dispatchInBackground(leaseId, prepared.references, prepared.audioReferences), "operation").pipe(Effect.tapError(() => call(() => input.operation.interruptGeneration(leaseId), "operation").pipe(Effect.andThen(settleNothing()), Effect.ignore)));
|
|
142
143
|
return { kind: "accepted" };
|
|
143
144
|
}
|
|
144
145
|
const generation = yield* call(async () => {
|
|
@@ -204,6 +205,7 @@ export function executeMediaOperation(input) {
|
|
|
204
205
|
// retry writes byte-identical output. A charged generation is never
|
|
205
206
|
// failed over metadata, so a malformed or truncated provider image is
|
|
206
207
|
// written as-is; embedProvenance never throws.
|
|
208
|
+
// MP3 is not listed: audio carries no embedded provenance, like MP4.
|
|
207
209
|
const format = z
|
|
208
210
|
.enum(["png", "jpeg", "gif", "webp", "mp4"])
|
|
209
211
|
.safeParse(output.format);
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const mediaModelTierSchema: z.ZodEnum<{
|
|
|
25
25
|
}>;
|
|
26
26
|
/** A model selection tier, independent of billing price. */
|
|
27
27
|
export type MediaModelTier = z.output<typeof mediaModelTierSchema>;
|
|
28
|
-
/** Media's provider catalog: Workers AI images plus gateway image and
|
|
28
|
+
/** Media's provider catalog: Workers AI images plus gateway image, video and audio models. */
|
|
29
29
|
export declare const mediaModelInputSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
30
30
|
transport: z.ZodEnum<{
|
|
31
31
|
/** JSON provider input. */
|
|
@@ -264,6 +264,10 @@ export declare const mediaVideoSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
|
264
264
|
/** 4k, admitted only by Seedance 2.0. */
|
|
265
265
|
readonly p4k: "4k";
|
|
266
266
|
}>>>;
|
|
267
|
+
audioReferences: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
268
|
+
max: z.ZodNumber;
|
|
269
|
+
totalSeconds: z.ZodNumber;
|
|
270
|
+
}, z.core.$strict>>>;
|
|
267
271
|
prices: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
268
272
|
resolution: z.ZodEnum<{
|
|
269
273
|
/** 480p. */
|
|
@@ -283,6 +287,56 @@ export declare const mediaVideoSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
|
283
287
|
}, z.core.$strict>>>;
|
|
284
288
|
/** Immutable video capability and price metadata. */
|
|
285
289
|
export type MediaVideoModel = z.output<typeof mediaVideoSchema>;
|
|
290
|
+
/**
|
|
291
|
+
* Verified ElevenLabs model identifiers on Cloudflare's Unified Billing, from
|
|
292
|
+
* the model pages under https://developers.cloudflare.com/ai/models/elevenlabs/
|
|
293
|
+
* (checked 2026-11-13). Cloudflare offers no sound-effects model. Eleven Flash
|
|
294
|
+
* v2.5 and Turbo v2.5 are listed there but a live Unified Billing call to Flash
|
|
295
|
+
* answered 403 code 2047 ("not available via unified billing. Please use
|
|
296
|
+
* BYOK"), so they are not offered. Multilingual v2 is the default voice model.
|
|
297
|
+
*/
|
|
298
|
+
export declare const mediaAudioModelIdSchema: z.ZodEnum<{
|
|
299
|
+
/** Eleven Multilingual v2 text to speech. */
|
|
300
|
+
readonly multilingual: "elevenlabs/eleven-multilingual-v2";
|
|
301
|
+
/** Eleven v3 expressive text to speech. */
|
|
302
|
+
readonly v3: "elevenlabs/eleven-v3";
|
|
303
|
+
/** Eleven Music v2. */
|
|
304
|
+
readonly music: "elevenlabs/music-v2";
|
|
305
|
+
}>;
|
|
306
|
+
/** Verified audio model identifier. */
|
|
307
|
+
export type MediaAudioModelId = z.output<typeof mediaAudioModelIdSchema>;
|
|
308
|
+
/** One premade voice a speech model may speak with. */
|
|
309
|
+
export declare const mediaAudioVoiceSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
310
|
+
id: z.ZodString;
|
|
311
|
+
label: z.ZodString;
|
|
312
|
+
}, z.core.$strict>>>;
|
|
313
|
+
/** One premade speech voice. */
|
|
314
|
+
export type MediaAudioVoice = z.output<typeof mediaAudioVoiceSchema>;
|
|
315
|
+
/** Verified audio parameters and provider cost, checked 2026-11-13. */
|
|
316
|
+
export declare const mediaAudioSchema: z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
317
|
+
provider: z.ZodLiteral<"elevenlabs">;
|
|
318
|
+
mode: z.ZodEnum<{
|
|
319
|
+
/** Text to speech: the prompt is the spoken text. */
|
|
320
|
+
readonly speech: "speech";
|
|
321
|
+
/** Music: the prompt describes the track. */
|
|
322
|
+
readonly music: "music";
|
|
323
|
+
}>;
|
|
324
|
+
voices: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
325
|
+
id: z.ZodString;
|
|
326
|
+
label: z.ZodString;
|
|
327
|
+
}, z.core.$strict>>>>>;
|
|
328
|
+
defaultVoiceId: z.ZodNullable<z.ZodString>;
|
|
329
|
+
seconds: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
330
|
+
min: z.ZodNumber;
|
|
331
|
+
max: z.ZodNumber;
|
|
332
|
+
default: z.ZodNumber;
|
|
333
|
+
}, z.core.$strict>>>;
|
|
334
|
+
milliunitsPerUnit: z.ZodNumber;
|
|
335
|
+
}, z.core.$strict>>>;
|
|
336
|
+
/** Immutable audio capability and price metadata. */
|
|
337
|
+
export type MediaAudioModel = z.output<typeof mediaAudioSchema>;
|
|
338
|
+
/** Characters one speech billing block covers. */
|
|
339
|
+
export declare const AUDIO_CHARACTER_BLOCK = 100;
|
|
286
340
|
/**
|
|
287
341
|
* Structural ceiling for any prompt on the wire. Each model's own
|
|
288
342
|
* `maxPromptLength` is the real bound; no model may exceed this ceiling.
|
|
@@ -297,6 +351,8 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
297
351
|
readonly image: "image";
|
|
298
352
|
/** Video generation. */
|
|
299
353
|
readonly video: "video";
|
|
354
|
+
/** Speech or music generation. */
|
|
355
|
+
readonly audio: "audio";
|
|
300
356
|
}>;
|
|
301
357
|
tier: z.ZodEnum<{
|
|
302
358
|
/** Cheap, fast draft model. */
|
|
@@ -451,6 +507,10 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
451
507
|
/** 4k, admitted only by Seedance 2.0. */
|
|
452
508
|
readonly p4k: "4k";
|
|
453
509
|
}>>>;
|
|
510
|
+
audioReferences: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
511
|
+
max: z.ZodNumber;
|
|
512
|
+
totalSeconds: z.ZodNumber;
|
|
513
|
+
}, z.core.$strict>>>;
|
|
454
514
|
prices: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
455
515
|
resolution: z.ZodEnum<{
|
|
456
516
|
/** 480p. */
|
|
@@ -468,12 +528,32 @@ export declare const mediaModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
468
528
|
audioMilliunitsPerSecond: z.ZodNumber;
|
|
469
529
|
}, z.core.$strict>>>>;
|
|
470
530
|
}, z.core.$strict>>>>;
|
|
531
|
+
audio: z.ZodNullable<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
532
|
+
provider: z.ZodLiteral<"elevenlabs">;
|
|
533
|
+
mode: z.ZodEnum<{
|
|
534
|
+
/** Text to speech: the prompt is the spoken text. */
|
|
535
|
+
readonly speech: "speech";
|
|
536
|
+
/** Music: the prompt describes the track. */
|
|
537
|
+
readonly music: "music";
|
|
538
|
+
}>;
|
|
539
|
+
voices: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
540
|
+
id: z.ZodString;
|
|
541
|
+
label: z.ZodString;
|
|
542
|
+
}, z.core.$strict>>>>>;
|
|
543
|
+
defaultVoiceId: z.ZodNullable<z.ZodString>;
|
|
544
|
+
seconds: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
545
|
+
min: z.ZodNumber;
|
|
546
|
+
max: z.ZodNumber;
|
|
547
|
+
default: z.ZodNumber;
|
|
548
|
+
}, z.core.$strict>>>;
|
|
549
|
+
milliunitsPerUnit: z.ZodNumber;
|
|
550
|
+
}, z.core.$strict>>>>;
|
|
471
551
|
}, z.core.$strict>>;
|
|
472
552
|
/** Model-specific dimensions, steps, transport and reference limits. */
|
|
473
553
|
export type MediaModelInput = z.output<typeof mediaModelInputSchema>;
|
|
474
554
|
/** One immutable provider catalog entry. */
|
|
475
555
|
export type MediaModel = z.output<typeof mediaModelSchema>;
|
|
476
|
-
/** The Fungi gateway provider's own immutable image and
|
|
556
|
+
/** The Fungi gateway provider's own immutable image, video and audio model catalog. */
|
|
477
557
|
export declare const mediaModels: readonly MediaModel[];
|
|
478
558
|
/**
|
|
479
559
|
* One catalogue entry. Same grammar as the gateway's wire entry, except that a
|
|
@@ -488,6 +568,8 @@ export declare const mediaCatalogueModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
488
568
|
readonly image: "image";
|
|
489
569
|
/** Video generation. */
|
|
490
570
|
readonly video: "video";
|
|
571
|
+
/** Speech or music generation. */
|
|
572
|
+
readonly audio: "audio";
|
|
491
573
|
}>;
|
|
492
574
|
tier: z.ZodEnum<{
|
|
493
575
|
/** Cheap, fast draft model. */
|
|
@@ -546,6 +628,26 @@ export declare const mediaCatalogueModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
546
628
|
}>;
|
|
547
629
|
}, z.core.$strict>>>;
|
|
548
630
|
sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
631
|
+
audio: z.ZodDefault<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
632
|
+
provider: z.ZodLiteral<"elevenlabs">;
|
|
633
|
+
mode: z.ZodEnum<{
|
|
634
|
+
/** Text to speech: the prompt is the spoken text. */
|
|
635
|
+
readonly speech: "speech";
|
|
636
|
+
/** Music: the prompt describes the track. */
|
|
637
|
+
readonly music: "music";
|
|
638
|
+
}>;
|
|
639
|
+
voices: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
640
|
+
id: z.ZodString;
|
|
641
|
+
label: z.ZodString;
|
|
642
|
+
}, z.core.$strict>>>>>;
|
|
643
|
+
defaultVoiceId: z.ZodNullable<z.ZodString>;
|
|
644
|
+
seconds: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
645
|
+
min: z.ZodNumber;
|
|
646
|
+
max: z.ZodNumber;
|
|
647
|
+
default: z.ZodNumber;
|
|
648
|
+
}, z.core.$strict>>>;
|
|
649
|
+
milliunitsPerUnit: z.ZodNumber;
|
|
650
|
+
}, z.core.$strict>>>>;
|
|
549
651
|
video: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
550
652
|
minSeconds: z.ZodNumber;
|
|
551
653
|
maxSeconds: z.ZodNumber;
|
|
@@ -650,6 +752,10 @@ export declare const mediaCatalogueModelSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
650
752
|
silentMilliunitsPerSecond: z.ZodNumber;
|
|
651
753
|
audioMilliunitsPerSecond: z.ZodNumber;
|
|
652
754
|
}, z.core.$strict>>>>;
|
|
755
|
+
audioReferences: z.ZodDefault<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
756
|
+
max: z.ZodNumber;
|
|
757
|
+
totalSeconds: z.ZodNumber;
|
|
758
|
+
}, z.core.$strict>>>>;
|
|
653
759
|
provider: z.ZodEnum<{
|
|
654
760
|
/** Seedance integer duration and data-URI image fields. */
|
|
655
761
|
readonly seedance: "seedance";
|
|
@@ -680,6 +786,8 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
680
786
|
readonly image: "image";
|
|
681
787
|
/** Video generation. */
|
|
682
788
|
readonly video: "video";
|
|
789
|
+
/** Speech or music generation. */
|
|
790
|
+
readonly audio: "audio";
|
|
683
791
|
}>;
|
|
684
792
|
tier: z.ZodEnum<{
|
|
685
793
|
/** Cheap, fast draft model. */
|
|
@@ -738,6 +846,26 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
738
846
|
}>;
|
|
739
847
|
}, z.core.$strict>>>;
|
|
740
848
|
sizes: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
849
|
+
audio: z.ZodDefault<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
850
|
+
provider: z.ZodLiteral<"elevenlabs">;
|
|
851
|
+
mode: z.ZodEnum<{
|
|
852
|
+
/** Text to speech: the prompt is the spoken text. */
|
|
853
|
+
readonly speech: "speech";
|
|
854
|
+
/** Music: the prompt describes the track. */
|
|
855
|
+
readonly music: "music";
|
|
856
|
+
}>;
|
|
857
|
+
voices: z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
858
|
+
id: z.ZodString;
|
|
859
|
+
label: z.ZodString;
|
|
860
|
+
}, z.core.$strict>>>>>;
|
|
861
|
+
defaultVoiceId: z.ZodNullable<z.ZodString>;
|
|
862
|
+
seconds: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
863
|
+
min: z.ZodNumber;
|
|
864
|
+
max: z.ZodNumber;
|
|
865
|
+
default: z.ZodNumber;
|
|
866
|
+
}, z.core.$strict>>>;
|
|
867
|
+
milliunitsPerUnit: z.ZodNumber;
|
|
868
|
+
}, z.core.$strict>>>>;
|
|
741
869
|
video: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
742
870
|
minSeconds: z.ZodNumber;
|
|
743
871
|
maxSeconds: z.ZodNumber;
|
|
@@ -842,6 +970,10 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
842
970
|
silentMilliunitsPerSecond: z.ZodNumber;
|
|
843
971
|
audioMilliunitsPerSecond: z.ZodNumber;
|
|
844
972
|
}, z.core.$strict>>>>;
|
|
973
|
+
audioReferences: z.ZodDefault<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
974
|
+
max: z.ZodNumber;
|
|
975
|
+
totalSeconds: z.ZodNumber;
|
|
976
|
+
}, z.core.$strict>>>>;
|
|
845
977
|
provider: z.ZodEnum<{
|
|
846
978
|
/** Seedance integer duration and data-URI image fields. */
|
|
847
979
|
readonly seedance: "seedance";
|
|
@@ -856,7 +988,7 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
856
988
|
}, z.core.$strict>>>, z.ZodTransform<MediaCatalogue, Readonly<{
|
|
857
989
|
id: string;
|
|
858
990
|
label: string;
|
|
859
|
-
kind: "image" | "video";
|
|
991
|
+
kind: "image" | "video" | "audio";
|
|
860
992
|
tier: "draft" | "balanced" | "premium" | "max";
|
|
861
993
|
outputFormats: readonly ("png" | "jpeg" | "webp")[];
|
|
862
994
|
maxPromptLength: number;
|
|
@@ -876,6 +1008,21 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
876
1008
|
referenceFormat: "png" | "webp";
|
|
877
1009
|
}>;
|
|
878
1010
|
sizes: readonly string[] | null;
|
|
1011
|
+
audio: Readonly<{
|
|
1012
|
+
provider: "elevenlabs";
|
|
1013
|
+
mode: "music" | "speech";
|
|
1014
|
+
voices: readonly Readonly<{
|
|
1015
|
+
id: string;
|
|
1016
|
+
label: string;
|
|
1017
|
+
}>[];
|
|
1018
|
+
defaultVoiceId: string | null;
|
|
1019
|
+
seconds: Readonly<{
|
|
1020
|
+
min: number;
|
|
1021
|
+
max: number;
|
|
1022
|
+
default: number;
|
|
1023
|
+
}> | null;
|
|
1024
|
+
milliunitsPerUnit: number;
|
|
1025
|
+
}> | null;
|
|
879
1026
|
video: Readonly<{
|
|
880
1027
|
minSeconds: number;
|
|
881
1028
|
maxSeconds: number;
|
|
@@ -899,6 +1046,10 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
899
1046
|
silentMilliunitsPerSecond: number;
|
|
900
1047
|
audioMilliunitsPerSecond: number;
|
|
901
1048
|
}>[];
|
|
1049
|
+
audioReferences: Readonly<{
|
|
1050
|
+
max: number;
|
|
1051
|
+
totalSeconds: number;
|
|
1052
|
+
}> | null;
|
|
902
1053
|
provider: "seedance" | "veo" | "minimax" | "host";
|
|
903
1054
|
}> | null;
|
|
904
1055
|
}>[]>>;
|
|
@@ -906,11 +1057,25 @@ export declare const mediaCatalogueSchema: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.
|
|
|
906
1057
|
export declare const parseMediaCatalogue: (raw: unknown) => MediaCatalogue;
|
|
907
1058
|
/** List the gateway provider's models in catalog order. */
|
|
908
1059
|
export declare const listMediaModels: () => readonly MediaModel[];
|
|
1060
|
+
/** A catalog entry that is a picture or video model. */
|
|
1061
|
+
export type MediaPictureModel = Omit<MediaModel, "kind" | "audio"> & {
|
|
1062
|
+
/** Still-image or video generation; never audio. */
|
|
1063
|
+
readonly kind: "image" | "video";
|
|
1064
|
+
/** Always null for a picture or video model. */
|
|
1065
|
+
readonly audio: null;
|
|
1066
|
+
};
|
|
1067
|
+
/**
|
|
1068
|
+
* The gateway models Apps and browsers list and pick from: pictures and video.
|
|
1069
|
+
* The Agar and Prints catalog decoders know no `audio` kind yet, and one unknown
|
|
1070
|
+
* row fails the whole list, so audio models are generated by id until the
|
|
1071
|
+
* Prints audio UI lands and lists them.
|
|
1072
|
+
*/
|
|
1073
|
+
export declare const listPictureMediaModels: () => readonly MediaPictureModel[];
|
|
909
1074
|
/** Find a model in the Fungi gateway's own catalogue; gateway-internal code never sees a custom provider's models. */
|
|
910
1075
|
export declare const getGatewayModel: (id: string) => MediaModel | undefined;
|
|
911
1076
|
/** Find a model in `catalogue` (the gateway's by default), or undefined when absent. */
|
|
912
1077
|
export declare const getMediaModel: (id: string, catalogue?: MediaCatalogue) => MediaCatalogueModel | undefined;
|
|
913
1078
|
/** Invalid generation settings or unsupported model parameters. */
|
|
914
1079
|
export declare class MediaSettingsError extends Error {
|
|
915
|
-
constructor(message: string);
|
|
1080
|
+
constructor(message: string, options?: ErrorOptions);
|
|
916
1081
|
}
|