@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.
Files changed (36) hide show
  1. package/README.md +49 -0
  2. package/dist/app-media-contracts.d.ts +103 -12
  3. package/dist/audio-providers/elevenlabs.d.ts +40 -0
  4. package/dist/audio-providers/elevenlabs.js +69 -0
  5. package/dist/audio-reference-types.d.ts +28 -0
  6. package/dist/audio-reference-types.js +16 -0
  7. package/dist/audio-references.d.ts +14 -0
  8. package/dist/audio-references.js +69 -0
  9. package/dist/cloudflare/provider.d.ts +6 -4
  10. package/dist/cloudflare/provider.js +37 -19
  11. package/dist/gateway-models.d.ts +12 -8
  12. package/dist/gateway-models.js +38 -17
  13. package/dist/index.d.ts +70 -15
  14. package/dist/index.js +118 -7
  15. package/dist/media-binding.d.ts +60 -7
  16. package/dist/media-binding.js +41 -19
  17. package/dist/media-generation.js +12 -3
  18. package/dist/media-operation-contract.d.ts +7 -3
  19. package/dist/media-operation-contract.js +6 -4
  20. package/dist/media-operation-owner.d.ts +2 -2
  21. package/dist/media-operation-owner.js +48 -6
  22. package/dist/media-operation.js +4 -2
  23. package/dist/model-catalog.d.ts +169 -4
  24. package/dist/model-catalog.js +180 -4
  25. package/dist/server.d.ts +14 -7
  26. package/dist/server.js +9 -4
  27. package/dist/video-providers/reference-encoding.d.ts +7 -2
  28. package/dist/video-providers/reference-encoding.js +14 -3
  29. package/dist/video-providers/types.d.ts +2 -2
  30. package/dist/video-providers/unified.d.ts +1 -0
  31. package/dist/video-providers/unified.js +4 -2
  32. package/docs/api/app-media-contracts.md +46 -10
  33. package/docs/api/cloudflare.md +3 -3
  34. package/docs/api/index.md +598 -84
  35. package/docs/api/server.md +129 -62
  36. package/package.json +3 -2
@@ -1,20 +1,23 @@
1
1
  import { z } from "zod";
2
2
  import * as Redacted from "effect/Redacted";
3
- import { buildProviderInput, getGatewayModel, estimateImageMilliunits, normalizeMediaProviderOutput, mediaProviderWireSchema, validateMediaGenerationSettings, } from "../index.js";
3
+ import { buildProviderInput, getGatewayModel, estimateImageMilliunits, normalizeMediaProviderOutput, mediaProviderWireSchema, validateMediaGenerationSettings, MediaSettingsError, } from "../index.js";
4
4
  import { MediaExecutionError, MediaSafetyFilterRefusal, } from "../execution-error.js";
5
5
  import { decodeMediaProviderErrorCategory, } from "@fungi.computer/agar/errors";
6
6
  import { estimateGatewayMilliunits, gatewayInput, isGatewayModel, } from "../gateway-models.js";
7
7
  import { GATEWAY_VIDEO_MAX_BYTES, gatewayOutputSchema, isMp4, } from "../gateway-wire.js";
8
8
  import { videoProviderAdapters } from "../video-providers/index.js";
9
+ import { decodeElevenLabsResultUrl, ELEVENLABS_MAX_BYTES, } from "../audio-providers/elevenlabs.js";
9
10
  import { readResponseBytes } from "../index.js";
10
11
  /** Quote the catalog defaults through the exact estimator used before dispatch. */
11
12
  export function estimateMediaModel(model) {
12
- const settings = validateMediaGenerationSettings({
13
- model: model.id,
14
- prompt: "x",
15
- width: model.input.defaultWidth,
16
- height: model.input.defaultHeight,
17
- });
13
+ const settings = validateMediaGenerationSettings(model.kind === "audio"
14
+ ? { model: model.id, prompt: "x" }
15
+ : {
16
+ model: model.id,
17
+ prompt: "x",
18
+ width: model.input.defaultWidth,
19
+ height: model.input.defaultHeight,
20
+ });
18
21
  return {
19
22
  /** An indicative quote, not an admitted generation receipt. */
20
23
  kind: "estimate",
@@ -27,16 +30,18 @@ export function estimateMediaModel(model) {
27
30
  };
28
31
  }
29
32
  export function estimate(settings, references) {
30
- const params = {
31
- width: settings.width,
32
- height: settings.height,
33
- references: references.map(({ width, height }) => ({ width, height })),
34
- };
35
- if (settings.steps !== undefined)
36
- params.steps = settings.steps;
37
33
  try {
38
34
  if (isGatewayModel(settings.model))
39
35
  return estimateGatewayMilliunits(settings, references);
36
+ if (settings.width === undefined || settings.height === undefined)
37
+ throw new MediaSettingsError("image cost needs a width and a height");
38
+ const params = {
39
+ width: settings.width,
40
+ height: settings.height,
41
+ references: references.map(({ width, height }) => ({ width, height })),
42
+ };
43
+ if (settings.steps !== undefined)
44
+ params.steps = settings.steps;
40
45
  return estimateImageMilliunits(settings.model, params);
41
46
  }
42
47
  catch (cause) {
@@ -132,10 +137,10 @@ function providerFailure(model, cause) {
132
137
  : new MediaExecutionError("provider", { cause, provider });
133
138
  }
134
139
  /** Run a gateway model and fetch its result URL within the byte bound. */
135
- async function generateThroughGateway(ai, settings, references, signal, options, fetchResult, outputFormat) {
140
+ async function generateThroughGateway(ai, settings, references, signal, options, fetchResult, outputFormat, audioReferences) {
136
141
  let providerValue;
137
142
  try {
138
- const input = gatewayInput(settings, references, outputFormat);
143
+ const input = gatewayInput(settings, references, outputFormat, audioReferences);
139
144
  providerValue = await ai.run(settings.model, input, routedOptions(options, signal, {
140
145
  stream: false,
141
146
  images: references.length,
@@ -147,6 +152,19 @@ async function generateThroughGateway(ai, settings, references, signal, options,
147
152
  const model = getGatewayModel(settings.model);
148
153
  const video = model?.kind === "video";
149
154
  try {
155
+ if (model?.kind === "audio") {
156
+ const response = await fetchResult(decodeElevenLabsResultUrl(providerValue), { signal: signal ?? null });
157
+ if (!response.ok)
158
+ throw new MediaExecutionError("normalization", {
159
+ provider: { category: "result_download", status: response.status },
160
+ });
161
+ // The result URL is the gateway's own output object; the bytes are
162
+ // retained as fetched, within the size bound.
163
+ return {
164
+ bytes: await readResponseBytes(response, ELEVENLABS_MAX_BYTES),
165
+ format: "mp3",
166
+ };
167
+ }
150
168
  if (video) {
151
169
  if (model.video === null)
152
170
  throw new Error("video model is missing its catalog video metadata");
@@ -172,9 +190,9 @@ async function generateThroughGateway(ai, settings, references, signal, options,
172
190
  throw new MediaExecutionError("normalization", { cause });
173
191
  }
174
192
  }
175
- export async function generate(ai, settings, references, signal, options, fetchResult = (input, init) => fetch(input, init), outputFormat) {
193
+ export async function generate(ai, settings, references, signal, options, fetchResult = (input, init) => fetch(input, init), outputFormat, audioReferences = []) {
176
194
  if (isGatewayModel(settings.model))
177
- return generateThroughGateway(ai, settings, references, signal, options, fetchResult, outputFormat);
195
+ return generateThroughGateway(ai, settings, references, signal, options, fetchResult, outputFormat, audioReferences);
178
196
  let providerInput;
179
197
  try {
180
198
  providerInput = buildProviderInput(settings, references);
@@ -217,5 +235,5 @@ export async function generate(ai, settings, references, signal, options, fetchR
217
235
  }
218
236
  /** Media's provider port on the Workers AI binding, with fixed options such as the AI Gateway route. */
219
237
  export function createWorkersAiMediaProvider(ai, options) {
220
- return (settings, references, signal, outputFormat) => generate(ai, settings, references, signal, options, undefined, outputFormat);
238
+ return (settings, references, signal, outputFormat, audioReferences) => generate(ai, settings, references, signal, options, undefined, outputFormat, audioReferences);
221
239
  }
@@ -1,13 +1,17 @@
1
1
  import { type MediaCatalogue } from "./model-catalog.js";
2
- import { type MediaGenerationSettings, type MediaReferenceBytes } from "./index.js";
3
- import type { MediaVideoModelId } from "./model-catalog.js";
4
- /** Gateway images and the verified catalog's video families share Unified billing. */
5
- export type GatewayModelId = "openai/gpt-image-2" | "bytedance/seedream-5-pro" | MediaVideoModelId;
2
+ import { type MediaAudioReferenceBytes, type MediaGenerationSettings, type MediaReferenceBytes } from "./index.js";
3
+ import type { MediaAudioModelId, MediaVideoModelId } from "./model-catalog.js";
4
+ /** Gateway images and the verified catalog's video and audio families share Unified billing. */
5
+ export type GatewayModelId = "openai/gpt-image-2" | "bytedance/seedream-5-pro" | MediaVideoModelId | MediaAudioModelId;
6
6
  export declare const isGatewayModel: (id: string) => id is GatewayModelId;
7
- /** What one generation bills: whole images, or seconds of video. */
7
+ /**
8
+ * What one generation bills: whole images, seconds of video or music, or
9
+ * blocks of {@link AUDIO_CHARACTER_BLOCK} speech characters (so a per-character
10
+ * provider rate is marked up once per block, not rounded up per character).
11
+ */
8
12
  export type MediaUnits = Readonly<{
9
- /** One image or one whole video second. */
10
- unit: "image" | "video_second";
13
+ /** One image, one whole video or music second, or one speech character block. */
14
+ unit: "image" | "video_second" | "audio_second" | "audio_character_block";
11
15
  /** Number of delivered or admitted units. */
12
16
  units: number;
13
17
  }>;
@@ -19,7 +23,7 @@ export declare function estimateGatewayMilliunits(settings: MediaGenerationSetti
19
23
  height: number;
20
24
  }>[]): number;
21
25
  /** The provider JSON body for one validated gateway generation. */
22
- export declare function gatewayInput(settings: MediaGenerationSettings, references?: readonly MediaReferenceBytes[], outputFormat?: "png" | "jpeg" | "webp"): import("./video-providers/minimax.js").MinimaxGatewayInput | import("./video-providers/unified.js").UnifiedGatewayInput | {
26
+ export declare function gatewayInput(settings: MediaGenerationSettings, references?: readonly MediaReferenceBytes[], outputFormat?: "png" | "jpeg" | "webp", audioReferences?: readonly MediaAudioReferenceBytes[]): import("./audio-providers/elevenlabs.js").ElevenLabsSpeechInput | import("./audio-providers/elevenlabs.js").ElevenLabsMusicInput | import("./video-providers/minimax.js").MinimaxGatewayInput | import("./video-providers/unified.js").UnifiedGatewayInput | {
23
27
  prompt: string;
24
28
  size: string;
25
29
  quality: string;
@@ -1,24 +1,39 @@
1
1
  import { getGatewayModel, getMediaModel, mediaModels, MediaSettingsError, } from "./model-catalog.js";
2
- import { validateMediaGenerationSettings, estimateVideoMilliunits, } from "./index.js";
2
+ import { validateMediaGenerationSettings, mediaSettingsInput, estimateVideoMilliunits, } from "./index.js";
3
+ import { AUDIO_CHARACTER_BLOCK } from "./model-catalog.js";
4
+ import { buildElevenLabsInput, estimateElevenLabsMilliunits, } from "./audio-providers/elevenlabs.js";
3
5
  import { imageDataUri } from "./video-providers/reference-encoding.js";
4
6
  import { videoProviderAdapters, } from "./video-providers/index.js";
5
- export const isGatewayModel = (id) => id === "openai/gpt-image-2" ||
6
- id === "bytedance/seedream-5-pro" ||
7
- getGatewayModel(id)?.kind === "video";
7
+ export const isGatewayModel = (id) => {
8
+ if (id === "openai/gpt-image-2" || id === "bytedance/seedream-5-pro")
9
+ return true;
10
+ const kind = getGatewayModel(id)?.kind;
11
+ return kind === "video" || kind === "audio";
12
+ };
13
+ /** Re-run the settings grammar over already-normalized settings. */
14
+ const revalidate = (settings, catalogue = mediaModels) => validateMediaGenerationSettings(mediaSettingsInput(settings), catalogue);
8
15
  /** Billing units for validated settings; video bills its requested length. */
9
16
  export function mediaUnits(settings, catalogue = mediaModels) {
10
17
  const model = getMediaModel(settings.model, catalogue);
11
18
  if (model === undefined)
12
19
  throw new MediaSettingsError("billing units require a known Media model");
13
20
  if (model.kind === "video") {
14
- const checked = validateMediaGenerationSettings({
15
- ...settings,
16
- references: settings.references?.map((reference) => ({ ...reference })),
17
- }, catalogue);
21
+ const checked = revalidate(settings, catalogue);
18
22
  if (checked.durationSeconds === undefined)
19
23
  throw new MediaSettingsError("video settings need a duration");
20
24
  return { unit: "video_second", units: checked.durationSeconds };
21
25
  }
26
+ if (model.kind === "audio") {
27
+ const checked = revalidate(settings, catalogue);
28
+ if (model.audio?.mode === "speech")
29
+ return {
30
+ unit: "audio_character_block",
31
+ units: Math.ceil(checked.prompt.length / AUDIO_CHARACTER_BLOCK),
32
+ };
33
+ if (checked.durationSeconds === undefined)
34
+ throw new MediaSettingsError("music settings need a length");
35
+ return { unit: "audio_second", units: checked.durationSeconds };
36
+ }
22
37
  return { unit: "image", units: 1 };
23
38
  }
24
39
  /**
@@ -37,9 +52,11 @@ const gptImageOutputTokens = new Map([
37
52
  ]);
38
53
  const gptImageTokensPerMegapixel = 1_056 / 1_048_576;
39
54
  function gptImageOutputTokenCount(settings) {
55
+ const { width, height } = settings;
56
+ if (width === undefined || height === undefined)
57
+ throw new MediaSettingsError("an image needs a width and a height");
40
58
  const known = gptImageOutputTokens.get(sizeOf(settings));
41
- return (known ??
42
- Math.ceil(settings.width * settings.height * gptImageTokensPerMegapixel));
59
+ return known ?? Math.ceil(width * height * gptImageTokensPerMegapixel);
43
60
  }
44
61
  /**
45
62
  * USD per million tokens: text input, image input and image output, as
@@ -90,8 +107,11 @@ export function estimateGatewayMilliunits(settings, references) {
90
107
  // https://developers.cloudflare.com/ai/models/bytedance/seedream-5-pro/
91
108
  if (settings.model === "bytedance/seedream-5-pro")
92
109
  return 4_500;
93
- if (getGatewayModel(settings.model)?.kind === "video")
110
+ const model = getGatewayModel(settings.model);
111
+ if (model?.kind === "video")
94
112
  return estimateVideoMilliunits(settings);
113
+ if (model?.kind === "audio")
114
+ return estimateElevenLabsMilliunits(revalidate(settings), model);
95
115
  throw new MediaSettingsError(`${settings.model} is not a gateway model`);
96
116
  }
97
117
  /**
@@ -105,7 +125,7 @@ function gptImageReference(reference) {
105
125
  return imageDataUri(reference);
106
126
  }
107
127
  /** The provider JSON body for one validated gateway generation. */
108
- export function gatewayInput(settings, references = [], outputFormat = "png") {
128
+ export function gatewayInput(settings, references = [], outputFormat = "png", audioReferences = []) {
109
129
  if (settings.model === "openai/gpt-image-2") {
110
130
  const body = {
111
131
  prompt: settings.prompt,
@@ -129,11 +149,10 @@ export function gatewayInput(settings, references = [], outputFormat = "png") {
129
149
  watermark: false,
130
150
  };
131
151
  }
132
- const checked = validateMediaGenerationSettings({
133
- ...settings,
134
- references: settings.references?.map((reference) => ({ ...reference })),
135
- });
152
+ const checked = revalidate(settings);
136
153
  const model = getGatewayModel(checked.model);
154
+ if (model?.audio != null)
155
+ return buildElevenLabsInput(checked, model);
137
156
  if (model?.video == null ||
138
157
  checked.resolution === undefined ||
139
158
  checked.aspectRatio === undefined ||
@@ -141,11 +160,13 @@ export function gatewayInput(settings, references = [], outputFormat = "png") {
141
160
  throw new MediaSettingsError("not a video gateway model");
142
161
  if (references.length !== (checked.references?.length ?? 0))
143
162
  throw new MediaSettingsError("resolved video references must match every admitted reference");
163
+ if (audioReferences.length !== (checked.audioReferences?.length ?? 0))
164
+ throw new MediaSettingsError("resolved audio references must match every admitted audio reference");
144
165
  const videoSettings = {
145
166
  ...checked,
146
167
  resolution: checked.resolution,
147
168
  aspectRatio: checked.aspectRatio,
148
169
  durationSeconds: checked.durationSeconds,
149
170
  };
150
- return videoProviderAdapters[model.video.provider].buildInput(videoSettings, references, model);
171
+ return videoProviderAdapters[model.video.provider].buildInput(videoSettings, references, model, audioReferences);
151
172
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import * as z from "zod";
2
+ import type { MediaAudioReferenceBytes } from "./audio-reference-types.js";
2
3
  import { type MediaVideoReferenceRole, type MediaCatalogue, type MediaVideoResolution, type MediaVideoAspectRatio } from "./model-catalog.js";
3
4
  export { mediaFailureStageSchema } from "./execution-error.js";
4
- export { MAX_MEDIA_PROMPT_LENGTH, getMediaModel, getGatewayModel, MAX_REFERENCE_COUNT, listMediaModels, mediaCatalogueSchema, mediaCatalogueModelSchema, parseMediaCatalogue, mediaModelInputSchema, mediaModelSchema, mediaRequestedImageFormatSchema, mediaModels, mediaModelTierSchema, MediaSettingsError, mediaVideoModelIdSchema, mediaVideoResolutionSchema, mediaVideoAspectRatioSchema, mediaVideoReferenceRoleSchema, mediaVideoFormatSchema, mediaVideoSchema, } from "./model-catalog.js";
5
- export type { MediaCatalogue, MediaCatalogueModel, MediaModel, MediaModelInput, MediaModelTier, MediaVideoModelId, MediaVideoResolution, MediaVideoAspectRatio, MediaVideoReferenceRole, MediaVideoModel, MediaVideoFormat, } from "./model-catalog.js";
5
+ export { MAX_AUDIO_REFERENCE_BODY_BYTES, MAX_AUDIO_REFERENCE_BYTES, } from "./audio-reference-types.js";
6
+ export type { AudioReferenceMimeType, MediaAudioReferenceBytes, } from "./audio-reference-types.js";
7
+ export { MAX_MEDIA_PROMPT_LENGTH, getMediaModel, getGatewayModel, MAX_REFERENCE_COUNT, listMediaModels, listPictureMediaModels, mediaCatalogueSchema, mediaCatalogueModelSchema, parseMediaCatalogue, mediaModelInputSchema, mediaModelSchema, mediaRequestedImageFormatSchema, mediaModels, mediaModelTierSchema, MediaSettingsError, mediaVideoModelIdSchema, mediaVideoResolutionSchema, mediaVideoAspectRatioSchema, mediaVideoReferenceRoleSchema, mediaVideoFormatSchema, mediaVideoSchema, mediaAudioModelIdSchema, mediaAudioSchema, mediaAudioVoiceSchema, AUDIO_CHARACTER_BLOCK, } from "./model-catalog.js";
8
+ export type { MediaCatalogue, MediaCatalogueModel, MediaModel, MediaPictureModel, MediaModelInput, MediaModelTier, MediaVideoModelId, MediaVideoResolution, MediaVideoAspectRatio, MediaVideoReferenceRole, MediaVideoModel, MediaVideoFormat, MediaAudioModelId, MediaAudioModel, MediaAudioVoice, } from "./model-catalog.js";
6
9
  /** A reference file selected by the host, with its destination identity and path. */
7
10
  export type MediaReference = Readonly<{
8
11
  /** Host-admitted destination or reference identity. */
@@ -16,8 +19,8 @@ export type MediaReference = Readonly<{
16
19
  export type ImageFormat = "png" | "jpeg" | "gif" | "webp";
17
20
  /** MIME type corresponding to a supported image encoding. */
18
21
  export type ImageMimeType = `image/${ImageFormat}`;
19
- /** A saved generation: an image, or an MP4 from a video model. */
20
- export type MediaOutputFormat = ImageFormat | "mp4";
22
+ /** A saved generation: an image, an MP4 from a video model, or an MP3 from an audio model. */
23
+ export type MediaOutputFormat = ImageFormat | "mp4" | "mp3";
21
24
  /** Decoded reference bytes and the dimensions sent to the provider. */
22
25
  export type MediaReferenceBytes = Readonly<{
23
26
  /** Decoded reference image bytes. */
@@ -37,14 +40,16 @@ export type MediaGenerationSettings = Readonly<{
37
40
  model: string;
38
41
  /** Trimmed generation prompt. */
39
42
  prompt: string;
40
- /** Requested image width or nominal video resolution/aspect selector. */
41
- width: number;
42
- /** Requested image height or nominal video resolution/aspect selector. */
43
- height: number;
43
+ /** Requested image width or nominal video resolution/aspect selector; absent for audio. */
44
+ width?: number;
45
+ /** Requested image height or nominal video resolution/aspect selector; absent for audio. */
46
+ height?: number;
44
47
  /** Model-specific inference steps. */
45
48
  steps?: number;
46
- /** Video models only: output length in whole seconds. */
49
+ /** Video and music models only: output length in whole seconds. */
47
50
  durationSeconds?: number;
51
+ /** Speech models only: the catalog voice that reads the prompt. */
52
+ voiceId?: string;
48
53
  /** Video resolution selector, normalized from the catalog. */
49
54
  resolution?: MediaVideoResolution;
50
55
  /** Requested video aspect; a first image may override it upstream. */
@@ -53,12 +58,14 @@ export type MediaGenerationSettings = Readonly<{
53
58
  generateAudio?: boolean;
54
59
  /** Host-authorized reference files. */
55
60
  references?: readonly MediaReference[];
61
+ /** Host-authorized reference audio clips; video models declaring `audioReferences` only. */
62
+ audioReferences?: readonly MediaReference[];
56
63
  }>;
57
64
  /**
58
65
  * One Media provider call: validated settings and reference bytes in, output
59
66
  * bytes out. Hosts may bind it to Workers AI or their own transport.
60
67
  */
61
- export type MediaProvider = (settings: MediaGenerationSettings, references: readonly MediaReferenceBytes[], signal?: AbortSignal, outputFormat?: "png" | "jpeg" | "webp") => Promise<Readonly<{
68
+ export type MediaProvider = (settings: MediaGenerationSettings, references: readonly MediaReferenceBytes[], signal?: AbortSignal, outputFormat?: "png" | "jpeg" | "webp", audioReferences?: readonly MediaAudioReferenceBytes[]) => Promise<Readonly<{
62
69
  /** Generated output bytes. */
63
70
  bytes: Uint8Array;
64
71
  /** Actual output encoding. */
@@ -91,14 +98,17 @@ export declare const MAX_REFERENCE_BYTES: number;
91
98
  export declare const MAX_REFERENCE_BODY_BYTES: number;
92
99
  /** Maximum retained still-image output bytes. */
93
100
  export declare const MAX_OUTPUT_BYTES: number;
101
+ /** Schema ceiling for audio reference lists; each model's own `audioReferences.max` is enforced after parsing. */
102
+ export declare const MAX_AUDIO_REFERENCE_COUNT = 10;
94
103
  /** Structural wire grammar for one Media generation request. */
95
104
  export declare const mediaGenerationSettingsSchema: z.ZodObject<{
96
105
  model: z.ZodString;
97
106
  prompt: z.ZodString;
98
- width: z.ZodNumber;
99
- height: z.ZodNumber;
107
+ width: z.ZodOptional<z.ZodNumber>;
108
+ height: z.ZodOptional<z.ZodNumber>;
100
109
  steps: z.ZodOptional<z.ZodNumber>;
101
110
  durationSeconds: z.ZodOptional<z.ZodNumber>;
111
+ voiceId: z.ZodOptional<z.ZodString>;
102
112
  resolution: z.ZodOptional<z.ZodEnum<{
103
113
  readonly p480: "480p";
104
114
  readonly p720: "720p";
@@ -125,6 +135,10 @@ export declare const mediaGenerationSettingsSchema: z.ZodObject<{
125
135
  readonly reference: "reference";
126
136
  }>>;
127
137
  }, z.core.$strict>>>;
138
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
139
+ computerId: z.ZodString;
140
+ path: z.ZodString;
141
+ }, z.core.$strict>>>;
128
142
  }, z.core.$strict>;
129
143
  /** Caller settings before model defaults and refinements are applied. */
130
144
  export type MediaGenerationSettingsInput = z.input<typeof mediaGenerationSettingsSchema>;
@@ -132,10 +146,11 @@ export type MediaGenerationSettingsInput = z.input<typeof mediaGenerationSetting
132
146
  export declare const mediaGenerationSelectionSchema: z.ZodObject<{
133
147
  model: z.ZodString;
134
148
  prompt: z.ZodString;
135
- width: z.ZodNumber;
136
- height: z.ZodNumber;
149
+ width: z.ZodOptional<z.ZodNumber>;
150
+ height: z.ZodOptional<z.ZodNumber>;
137
151
  steps: z.ZodOptional<z.ZodNumber>;
138
152
  durationSeconds: z.ZodOptional<z.ZodNumber>;
153
+ voiceId: z.ZodOptional<z.ZodString>;
139
154
  resolution: z.ZodOptional<z.ZodEnum<{
140
155
  readonly p480: "480p";
141
156
  readonly p720: "720p";
@@ -162,16 +177,22 @@ export declare const mediaGenerationSelectionSchema: z.ZodObject<{
162
177
  readonly reference: "reference";
163
178
  }>>;
164
179
  }, z.core.$strict>>>;
180
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
181
+ computerId: z.ZodOptional<z.ZodString>;
182
+ path: z.ZodString;
183
+ }, z.core.$strict>>>;
165
184
  }, z.core.$strict>;
166
185
  /** Generation settings with reference paths resolved by an admitting host. */
167
186
  export type MediaGenerationSelection = z.output<typeof mediaGenerationSelectionSchema>;
187
+ /** Mutable caller input for already-normalized settings, so they can be validated again. */
188
+ export declare const mediaSettingsInput: (settings: MediaGenerationSettings) => MediaGenerationSettingsInput;
168
189
  /**
169
190
  * Validate caller settings against `catalogue`, the active provider's model
170
191
  * list (the Fungi gateway's by default), and apply that model's defaults.
171
192
  */
172
193
  export declare const validateMediaGenerationSettings: (raw: MediaGenerationSettingsInput, catalogue?: MediaCatalogue) => MediaGenerationSettings;
173
194
  /** Validate selections without granting Computer authority. */
174
- export declare const validateMediaGenerationSelection: (raw: z.input<typeof mediaGenerationSelectionSchema>, catalogue?: MediaCatalogue) => Readonly<Omit<MediaGenerationSettings, "references"> & {
195
+ export declare const validateMediaGenerationSelection: (raw: z.input<typeof mediaGenerationSelectionSchema>, catalogue?: MediaCatalogue) => Readonly<Omit<MediaGenerationSettings, "references" | "audioReferences"> & {
175
196
  /** Host-authorized reference images. */
176
197
  references?: readonly Readonly<{
177
198
  /** Fixed destination or reference file path. */
@@ -181,6 +202,13 @@ export declare const validateMediaGenerationSelection: (raw: z.input<typeof medi
181
202
  /** Video-only reference role. */
182
203
  role?: MediaVideoReferenceRole;
183
204
  }>[];
205
+ /** Host-authorized reference audio clips. */
206
+ audioReferences?: readonly Readonly<{
207
+ /** Fixed reference file path. */
208
+ path: string;
209
+ /** Optional reference Computer; authorization remains host-owned. */
210
+ computerId?: string;
211
+ }>[];
184
212
  }>;
185
213
  /** Path-only video reference; the host supplies authority and reads its bytes. */
186
214
  export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
@@ -193,6 +221,12 @@ export declare const mediaVideoReferenceSchema: z.ZodLazy<z.ZodObject<{
193
221
  }, z.core.$strict>>;
194
222
  /** One path-only video reference. */
195
223
  export type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
224
+ /** Path-only audio reference; the host supplies authority and reads its bytes. */
225
+ export declare const mediaAudioReferenceSelectionSchema: z.ZodLazy<z.ZodObject<{
226
+ path: z.ZodString;
227
+ }, z.core.$strict>>;
228
+ /** One path-only audio reference. */
229
+ export type MediaAudioReferenceSelection = z.output<typeof mediaAudioReferenceSelectionSchema>;
196
230
  /** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
197
231
  export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
198
232
  model: z.ZodEnum<{
@@ -231,6 +265,9 @@ export declare const mediaVideoSelectionSchema: z.ZodLazy<z.ZodObject<{
231
265
  readonly reference: "reference";
232
266
  }>;
233
267
  }, z.core.$strict>>>>;
268
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
269
+ path: z.ZodString;
270
+ }, z.core.$strict>>>>;
234
271
  }, z.core.$strict>>;
235
272
  /**
236
273
  * The same selection for a host's own catalogue: the model is any id that
@@ -264,6 +301,9 @@ declare const catalogueVideoSelectionSchema: z.ZodObject<{
264
301
  readonly reference: "reference";
265
302
  }>;
266
303
  }, z.core.$strict>>>>;
304
+ audioReferences: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
305
+ path: z.ZodString;
306
+ }, z.core.$strict>>>>;
267
307
  model: z.ZodString;
268
308
  }, z.core.$strict>;
269
309
  /** Caller video selection before defaults and model-specific refinements. */
@@ -288,9 +328,24 @@ export type MediaVideoSelection = Readonly<{
288
328
  generateAudio?: boolean;
289
329
  /** Normalized paths and required frame/reference roles. */
290
330
  references?: readonly Readonly<MediaVideoReference>[];
331
+ /** Normalized reference audio paths. */
332
+ audioReferences?: readonly Readonly<MediaAudioReferenceSelection>[];
291
333
  }>;
292
334
  /** Validate supported model/size/duration/reference combinations before authority or billing admission. */
293
335
  export declare function validateMediaVideoSelection(raw: z.input<typeof catalogueVideoSelectionSchema>, catalogue?: MediaCatalogue): MediaVideoSelection;
336
+ /** Neutral audio selection: speech takes a voice, music a length; model-specific limits are checked by validateMediaGenerationSettings. */
337
+ export declare const mediaAudioSelectionSchema: z.ZodLazy<z.ZodObject<{
338
+ model: z.ZodEnum<{
339
+ readonly multilingual: "elevenlabs/eleven-multilingual-v2";
340
+ readonly v3: "elevenlabs/eleven-v3";
341
+ readonly music: "elevenlabs/music-v2";
342
+ }>;
343
+ prompt: z.ZodString;
344
+ voiceId: z.ZodOptional<z.ZodString>;
345
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
346
+ }, z.core.$strict>>;
347
+ /** Caller audio selection before defaults and model-specific refinements. */
348
+ export type MediaAudioSelectionInput = z.input<typeof mediaAudioSelectionSchema>;
294
349
  /** Host-authorized reader for decoded reference images. */
295
350
  export type MediaReferenceReader = Readonly<{
296
351
  /** Authorize and fit one reference for the selected catalog model. */