@neta-art/generation 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as compactArray, c as slugifyFileName, d as MODEL_SCHEMA, i as cloneJson, l as GENERATION_MODEL_CATEGORIES, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels, u as GENERATION_PRICING_UNITS } from "./builtins-BWmXzRgG.js";
1
+ import { a as compactArray, c as slugifyFileName, d as MODEL_SCHEMA, i as cloneJson, l as GENERATION_MODEL_CATEGORIES, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels, u as GENERATION_PRICING_UNITS } from "./builtins-BIKiMMUX.js";
2
2
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
3
3
  import { extname, join } from "node:path";
4
4
  import { parse, stringify } from "yaml";
@@ -199,7 +199,7 @@ function transportErrorTarget(rawUrl) {
199
199
  }
200
200
  function transportErrorSummary(error) {
201
201
  const outer = error instanceof Error ? error : new Error(String(error));
202
- const cause = isRecord$7(outer.cause) ? outer.cause : void 0;
202
+ const cause = isRecord$8(outer.cause) ? outer.cause : void 0;
203
203
  return compactObject({
204
204
  name: outer.name,
205
205
  causeName: stringProperty(cause, "name"),
@@ -210,16 +210,16 @@ function transportErrorSummary(error) {
210
210
  });
211
211
  }
212
212
  function stringProperty(value, key) {
213
- if (!isRecord$7(value)) return void 0;
213
+ if (!isRecord$8(value)) return void 0;
214
214
  const item = value[key];
215
215
  return typeof item === "string" && item.trim() ? item.trim() : void 0;
216
216
  }
217
217
  function stringOrNumberProperty(value, key) {
218
- if (!isRecord$7(value)) return void 0;
218
+ if (!isRecord$8(value)) return void 0;
219
219
  const item = value[key];
220
220
  return typeof item === "string" || typeof item === "number" ? item : void 0;
221
221
  }
222
- function isRecord$7(value) {
222
+ function isRecord$8(value) {
223
223
  return typeof value === "object" && value !== null;
224
224
  }
225
225
 
@@ -388,6 +388,23 @@ function asNumber$1(value) {
388
388
  function asBoolean$1(value) {
389
389
  return typeof value === "boolean" ? value : void 0;
390
390
  }
391
+ function isSeedance25Model(model) {
392
+ return /seedance[-_.]?2[-_.]?5/i.test(model);
393
+ }
394
+ function seedance25LockedRatioKind(mode, parameters, requestParameters, meta) {
395
+ if (mode === "frame") return "first/last-frame";
396
+ const taskType = asString$4(requestParameters?.omni_reference_task_type) ?? asString$4(parameters.omni_reference_task_type) ?? asString$4(meta.omni_reference_task_type) ?? asString$4(requestParameters?.task_type) ?? asString$4(parameters.task_type) ?? asString$4(meta.task_type);
397
+ if (taskType === "edit") return "edit";
398
+ if (taskType === "extend") return "extend";
399
+ return null;
400
+ }
401
+ function resolveRatio$1(model, mode, parameters, requestParameters, meta) {
402
+ const requested = asString$4(requestParameters?.ratio);
403
+ const locked = isSeedance25Model(model) ? seedance25LockedRatioKind(mode, parameters, requestParameters, meta) : null;
404
+ if (!locked) return requested ?? asString$4(parameters.ratio) ?? "16:9";
405
+ if (requested !== void 0 && requested !== "adaptive") throw new GenerationValidationError(`Seedance 2.5 ${locked} tasks require ratio=adaptive, got "${requested}"`);
406
+ return "adaptive";
407
+ }
391
408
  function normalizeStatus$4(value) {
392
409
  const status = value.toLowerCase();
393
410
  return status === "success" ? "succeeded" : status;
@@ -557,11 +574,11 @@ async function arkVideoGenerationsAdapter(input) {
557
574
  const visualInput = inputMedia.filter(isVisualMedia);
558
575
  validateAudioInputs(inputMedia.filter((item) => item.kind === "audio"), visualInput);
559
576
  const mode = classifyMedia$1(visualInput);
577
+ const ratio = resolveRatio$1(input.declaration.model, mode, input.parameters, input.request.parameters, input.meta);
560
578
  const media = await resolveMedia$1(input, inputMedia);
561
579
  const visual = media.filter(isVisualResolved);
562
580
  const audio = media.filter((item) => item.kind === "audio");
563
581
  const resolution = asString$4(input.parameters.resolution) ?? "720p";
564
- const ratio = asString$4(input.request.parameters?.ratio) ?? asString$4(input.parameters.ratio) ?? "16:9";
565
582
  const duration = getIntegerParameter(input.parameters, "duration", 5);
566
583
  const fps = getIntegerParameter(input.parameters, "fps", 24);
567
584
  const pollIntervalSec = getIntegerParameter(input.parameters, "poll_interval", DEFAULT_POLL_INTERVAL_SEC$4);
@@ -653,7 +670,7 @@ const QWEN_MODELS = new Set([
653
670
  ]);
654
671
  const QWEN_AUDIO_3_MODELS = new Set(["qwen-audio-3.0-tts-plus", "qwen-audio-3.0-tts-flash"]);
655
672
  const HIGGS_MODEL = "higgs-tts";
656
- function isRecord$6(value) {
673
+ function isRecord$7(value) {
657
674
  return !!value && typeof value === "object" && !Array.isArray(value);
658
675
  }
659
676
  function textBlocks(input) {
@@ -774,8 +791,8 @@ function providerError(response, rawBody) {
774
791
  const requestId = requestIdFromHeaders(response.headers);
775
792
  const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
776
793
  const parsed = contentType.includes("application/json") || contentType.includes("+json") ? parseJson(rawBody) : void 0;
777
- const parsedRecord = isRecord$6(parsed) ? parsed : void 0;
778
- const errorRecord = isRecord$6(parsedRecord?.error) ? parsedRecord.error : void 0;
794
+ const parsedRecord = isRecord$7(parsed) ? parsed : void 0;
795
+ const errorRecord = isRecord$7(parsedRecord?.error) ? parsedRecord.error : void 0;
779
796
  const message = nonEmptyString(errorRecord?.message) ?? (rawBody.trim() ? rawBody : void 0) ?? (response.statusText.trim() ? response.statusText : void 0) ?? "Audio speech provider request failed";
780
797
  const code = nonEmptyString(errorRecord?.code);
781
798
  return new GenerationProviderError(message, {
@@ -798,7 +815,7 @@ function unsupportedSuccessResponse(response, rawBody) {
798
815
  }
799
816
  function parseSuccessResponse(response, rawBody) {
800
817
  const parsed = parseJson(rawBody);
801
- if (!isRecord$6(parsed)) throw unsupportedSuccessResponse(response, rawBody);
818
+ if (!isRecord$7(parsed)) throw unsupportedSuccessResponse(response, rawBody);
802
819
  const urlValue = nonEmptyString(parsed.url);
803
820
  const contentType = nonEmptyString(parsed.content_type);
804
821
  if (!urlValue || parsed.media_type !== "audio" || !contentType || !/^audio\/[^\s/;]+(?:\s*;.*)?$/i.test(contentType)) throw unsupportedSuccessResponse(response, rawBody);
@@ -839,6 +856,132 @@ async function generateAudioSpeech(input) {
839
856
  }
840
857
  const audioSpeechAdapter = Object.assign(generateAudioSpeech, { validate: validateAudioSpeechRequest });
841
858
 
859
+ //#endregion
860
+ //#region src/response-fields.ts
861
+ function numberValue(value) {
862
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
863
+ }
864
+ function stringValue(value) {
865
+ return typeof value === "string" && value ? value : void 0;
866
+ }
867
+ function isRecord$6(value) {
868
+ return !!value && typeof value === "object" && !Array.isArray(value);
869
+ }
870
+ function extractGenerationResultHeaderFields(headers) {
871
+ const requestId = headers.get("x-request-id")?.trim() || void 0;
872
+ const oneApiRequestId = headers.get("x-oneapi-request-id")?.trim() || void 0;
873
+ return requestId || oneApiRequestId ? {
874
+ ...requestId ? { requestId } : {},
875
+ ...oneApiRequestId ? { oneApiRequestId } : {}
876
+ } : void 0;
877
+ }
878
+ function extractGenerationResultFields(raw) {
879
+ if (!isRecord$6(raw)) return void 0;
880
+ const usage = isRecord$6(raw.usage) ? raw.usage : void 0;
881
+ const fields = {};
882
+ const requestId = stringValue(raw.request_id);
883
+ const cost = usage ? numberValue(usage.cost) : void 0;
884
+ if (requestId !== void 0) fields.requestId = requestId;
885
+ if (cost !== void 0) fields.cost = cost;
886
+ return Object.keys(fields).length > 0 ? fields : void 0;
887
+ }
888
+
889
+ //#endregion
890
+ //#region src/adapters/audio-transcription.ts
891
+ const FORMATS = new Set([
892
+ "wav",
893
+ "mp3",
894
+ "ogg",
895
+ "raw"
896
+ ]);
897
+ function isRecord$5(value) {
898
+ return value !== null && typeof value === "object" && !Array.isArray(value);
899
+ }
900
+ function buildAudioTranscriptionPayload(input) {
901
+ const [audio] = input.request.content;
902
+ if (input.request.content.length !== 1 || audio?.type !== "audio" || audio.source.type !== "url") throw new GenerationValidationError("Audio transcription requires exactly one audio URL");
903
+ let url;
904
+ try {
905
+ url = new URL(audio.source.url.trim());
906
+ } catch {
907
+ throw new GenerationValidationError("Audio transcription requires a valid HTTP(S) URL");
908
+ }
909
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new GenerationValidationError("Audio transcription requires an HTTP(S) URL without credentials");
910
+ for (const meta of [
911
+ input.request.meta,
912
+ input.request.metadata,
913
+ audio.meta
914
+ ]) if (Object.keys(meta ?? {}).length > 0) throw new GenerationValidationError("Audio transcription does not accept metadata; use parameters");
915
+ const extension = url.pathname.split("/").at(-1)?.split(".").slice(1).at(-1)?.toLowerCase();
916
+ const format = input.parameters.audio_format ?? extension;
917
+ if (typeof format !== "string" || !FORMATS.has(format)) throw new GenerationValidationError("Specify audio_format as wav, mp3, ogg or raw when the URL has no supported extension");
918
+ const language = input.parameters.language;
919
+ if (language !== void 0 && (typeof language !== "string" || language.trim().length === 0)) throw new GenerationValidationError("language must be a non-empty Volcengine language code, for example zh-CN");
920
+ return {
921
+ model: input.declaration.model,
922
+ audio_url: url.href,
923
+ audio_format: format,
924
+ ...language !== void 0 ? { language } : {},
925
+ response_format: "verbose_json"
926
+ };
927
+ }
928
+ function parseAudioTranscriptionResponse(raw) {
929
+ if (!isRecord$5(raw) || typeof raw.text !== "string" || typeof raw.duration !== "number" || !Number.isFinite(raw.duration) || raw.duration <= 0) throw new GenerationProviderError("Audio transcription response requires text and a positive duration");
930
+ const segments = [];
931
+ if (raw.segments !== void 0) {
932
+ if (!Array.isArray(raw.segments)) throw new GenerationProviderError("Invalid transcription segments");
933
+ for (const segment of raw.segments) {
934
+ if (!isRecord$5(segment) || typeof segment.text !== "string" || typeof segment.start !== "number" || !Number.isFinite(segment.start) || segment.start < 0 || typeof segment.end !== "number" || !Number.isFinite(segment.end) || segment.end < segment.start) throw new GenerationProviderError("Invalid transcription segment text or timestamps");
935
+ segments.push({
936
+ start: segment.start,
937
+ end: segment.end,
938
+ text: segment.text
939
+ });
940
+ }
941
+ }
942
+ return {
943
+ type: "text",
944
+ text: raw.text,
945
+ meta: {
946
+ duration: raw.duration,
947
+ segments
948
+ }
949
+ };
950
+ }
951
+ async function generateAudioTranscription(input) {
952
+ const payload = buildAudioTranscriptionPayload(input);
953
+ const response = await fetchWithTimeout(input.context.fetch, joinUrl(input.context.baseUrl, "/v1/audio/transcriptions"), {
954
+ method: "POST",
955
+ headers: {
956
+ Authorization: `Bearer ${input.context.apiKey}`,
957
+ "Content-Type": "application/json"
958
+ },
959
+ body: JSON.stringify(payload)
960
+ }, Number(input.parameters.max_wait) * 1e3);
961
+ const body = await response.text();
962
+ const headers = extractGenerationResultHeaderFields(response.headers);
963
+ const details = { requestId: headers?.requestId ?? headers?.oneApiRequestId };
964
+ if (!response.ok) throw new GenerationProviderError(`Audio transcription failed (HTTP ${response.status}): ${body}`, {
965
+ status: response.status,
966
+ body,
967
+ details
968
+ });
969
+ let raw;
970
+ try {
971
+ raw = JSON.parse(body);
972
+ } catch {
973
+ throw new GenerationProviderError("Audio transcription returned invalid JSON", {
974
+ status: response.status,
975
+ body,
976
+ details
977
+ });
978
+ }
979
+ return [parseAudioTranscriptionResponse(raw)];
980
+ }
981
+ const audioTranscriptionAdapter = Object.assign(generateAudioTranscription, { validate(input) {
982
+ buildAudioTranscriptionPayload(input);
983
+ } });
984
+
842
985
  //#endregion
843
986
  //#region src/adapters/gemini-generate-content.ts
844
987
  const REQUEST_TIMEOUT_MS$6 = 3e5;
@@ -1008,7 +1151,7 @@ function asInteger$2(value, fallback) {
1008
1151
  function asNumber(value) {
1009
1152
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
1010
1153
  }
1011
- function isRecord$5(value) {
1154
+ function isRecord$4(value) {
1012
1155
  return !!value && typeof value === "object" && !Array.isArray(value);
1013
1156
  }
1014
1157
  function providerMeta(input) {
@@ -1150,7 +1293,7 @@ async function requestJson$3(input, path, init) {
1150
1293
  });
1151
1294
  }
1152
1295
  if (!response.ok) {
1153
- const details = isRecord$5(parsed) ? { details: parsed } : {};
1296
+ const details = isRecord$4(parsed) ? { details: parsed } : {};
1154
1297
  throw new GenerationProviderError("Kling video provider request failed", {
1155
1298
  status: response.status,
1156
1299
  body,
@@ -1234,7 +1377,7 @@ function asInteger$1(value, fallback) {
1234
1377
  function asBoolean(value, fallback) {
1235
1378
  return typeof value === "boolean" ? value : fallback;
1236
1379
  }
1237
- function isRecord$4(value) {
1380
+ function isRecord$3(value) {
1238
1381
  return !!value && typeof value === "object" && !Array.isArray(value);
1239
1382
  }
1240
1383
  function normalizeStatus$2(value) {
@@ -1347,7 +1490,7 @@ function resolveRatio(value, mode) {
1347
1490
  return mode === "text" && requested === ADAPTIVE_RATIO ? DEFAULT_RATIO : requested;
1348
1491
  }
1349
1492
  function extractTaskId$2(response) {
1350
- const data = isRecord$4(response.data) ? response.data : void 0;
1493
+ const data = isRecord$3(response.data) ? response.data : void 0;
1351
1494
  const taskId = asString$2(response.task_id) ?? asString$2(response.id) ?? asString$2(data?.task_id) ?? asString$2(data?.id);
1352
1495
  if (!taskId) throw new GenerationProviderError("MiniMax H3 provider did not return a task id", { details: { response } });
1353
1496
  return taskId;
@@ -1365,17 +1508,17 @@ function isTaskPayload(value) {
1365
1508
  ].some((key) => key in value);
1366
1509
  }
1367
1510
  function unwrapTaskPayload$1(response) {
1368
- const data = isRecord$4(response.data) ? response.data : void 0;
1511
+ const data = isRecord$3(response.data) ? response.data : void 0;
1369
1512
  return data && !isTaskPayload(response) ? data : response;
1370
1513
  }
1371
1514
  function extractTaskStatus$1(response) {
1372
1515
  const payload = unwrapTaskPayload$1(response);
1373
- const task = isRecord$4(payload.task) ? payload.task : payload;
1374
- const metadata = isRecord$4(payload.metadata) ? payload.metadata : isRecord$4(task.metadata) ? task.metadata : void 0;
1375
- const content = isRecord$4(task.content) ? task.content : void 0;
1516
+ const task = isRecord$3(payload.task) ? payload.task : payload;
1517
+ const metadata = isRecord$3(payload.metadata) ? payload.metadata : isRecord$3(task.metadata) ? task.metadata : void 0;
1518
+ const content = isRecord$3(task.content) ? task.content : void 0;
1376
1519
  const status = normalizeStatus$2(payload.status ?? task.status);
1377
1520
  const videoUrl = asString$2(metadata?.url) ?? asString$2(payload.result_url) ?? asString$2(payload.video_url) ?? asString$2(payload.url) ?? asString$2(task.result_url) ?? asString$2(task.video_url) ?? asString$2(task.url) ?? asString$2(content?.video_url) ?? asString$2(content?.url);
1378
- const error = isRecord$4(payload.error) ? payload.error : isRecord$4(task.error) ? task.error : void 0;
1521
+ const error = isRecord$3(payload.error) ? payload.error : isRecord$3(task.error) ? task.error : void 0;
1379
1522
  const message = asString$2(error?.message) ?? asString$2(payload.fail_reason) ?? asString$2(payload.message) ?? asString$2(task.fail_reason) ?? asString$2(task.message) ?? asString$2(response.message);
1380
1523
  const outputMetadata = compactObject({
1381
1524
  progress: payload.progress ?? task.progress,
@@ -1412,7 +1555,7 @@ async function requestJson$2(input, path, init) {
1412
1555
  if (!response.ok) throw new GenerationProviderError("MiniMax H3 provider request failed", {
1413
1556
  status: response.status,
1414
1557
  body,
1415
- ...isRecord$4(parsed) ? { details: parsed } : {}
1558
+ ...isRecord$3(parsed) ? { details: parsed } : {}
1416
1559
  });
1417
1560
  return parsed;
1418
1561
  }
@@ -1676,7 +1819,7 @@ const FINAL_FAILURE_STATUSES = new Set([
1676
1819
  "canceled",
1677
1820
  "expired"
1678
1821
  ]);
1679
- function isRecord$3(value) {
1822
+ function isRecord$2(value) {
1680
1823
  return !!value && typeof value === "object" && !Array.isArray(value);
1681
1824
  }
1682
1825
  function asString$1(value) {
@@ -1686,7 +1829,7 @@ function asInteger(value, fallback) {
1686
1829
  return typeof value === "number" && Number.isInteger(value) ? value : fallback;
1687
1830
  }
1688
1831
  function asRecord(value) {
1689
- return isRecord$3(value) ? value : {};
1832
+ return isRecord$2(value) ? value : {};
1690
1833
  }
1691
1834
  function successCode(value) {
1692
1835
  const code = String(value ?? "").trim().toLowerCase();
@@ -1702,7 +1845,7 @@ function requireSuccess(response, fallbackMessage) {
1702
1845
  }
1703
1846
  function extractTaskId$1(value) {
1704
1847
  if (typeof value === "string" && value.trim()) return value.trim();
1705
- if (!isRecord$3(value)) return void 0;
1848
+ if (!isRecord$2(value)) return void 0;
1706
1849
  for (const key of [
1707
1850
  "task_id",
1708
1851
  "id",
@@ -1720,7 +1863,7 @@ function normalizeStatus$1(value) {
1720
1863
  }
1721
1864
  function normalizeTask(operation, data) {
1722
1865
  if (Array.isArray(data)) return data.length > 0 ? normalizeTask(operation, data[0]) : null;
1723
- if (!isRecord$3(data)) return null;
1866
+ if (!isRecord$2(data)) return null;
1724
1867
  if ("status" in data || "taskStatus" in data || "task_status" in data || "task_id" in data || "taskBatchId" in data) {
1725
1868
  const hasProviderEnvelope = "taskStatus" in data || "task_status" in data || "taskBatchId" in data || "task_batch_id" in data;
1726
1869
  return {
@@ -1796,7 +1939,7 @@ function applyFixedPayload(input, payload, fixed) {
1796
1939
  }
1797
1940
  }
1798
1941
  function setMetadataParam(payload, key, value) {
1799
- const metadataParams = isRecord$3(payload.metadata_params) ? payload.metadata_params : {};
1942
+ const metadataParams = isRecord$2(payload.metadata_params) ? payload.metadata_params : {};
1800
1943
  if (metadataParams[key] === void 0) metadataParams[key] = value;
1801
1944
  payload.metadata_params = metadataParams;
1802
1945
  }
@@ -1866,8 +2009,8 @@ function appendSunoContent(output, value, meta = {}) {
1866
2009
  for (const item of value) appendSunoContent(output, item, meta);
1867
2010
  return;
1868
2011
  }
1869
- if (!isRecord$3(value)) return;
1870
- if (isRecord$3(value.clips)) for (const clip of Object.values(value.clips)) appendSunoContent(output, clip, meta);
2012
+ if (!isRecord$2(value)) return;
2013
+ if (isRecord$2(value.clips)) for (const clip of Object.values(value.clips)) appendSunoContent(output, clip, meta);
1871
2014
  if (Array.isArray(value.items)) for (const item of value.items) appendSunoContent(output, item, meta);
1872
2015
  const itemMeta = compactObject({
1873
2016
  ...meta,
@@ -1877,9 +2020,9 @@ function appendSunoContent(output, value, meta = {}) {
1877
2020
  title: value.title,
1878
2021
  status: value.status ?? meta.status,
1879
2022
  model: value.model_name ?? value.modelName,
1880
- duration: value.duration ?? (isRecord$3(value.metadata) ? value.metadata.duration : void 0),
1881
- tags: value.tags ?? (isRecord$3(value.metadata) ? value.metadata.tags : void 0),
1882
- prompt: value.prompt ?? (isRecord$3(value.metadata) ? value.metadata.prompt : void 0),
2023
+ duration: value.duration ?? (isRecord$2(value.metadata) ? value.metadata.duration : void 0),
2024
+ tags: value.tags ?? (isRecord$2(value.metadata) ? value.metadata.tags : void 0),
2025
+ prompt: value.prompt ?? (isRecord$2(value.metadata) ? value.metadata.prompt : void 0),
1883
2026
  progress: value.progress ?? meta.progress,
1884
2027
  progress_message: value.progressMsg ?? value.progress_msg,
1885
2028
  task_batch_id: value.taskBatchId ?? value.task_batch_id,
@@ -1900,7 +2043,7 @@ function appendSunoContent(output, value, meta = {}) {
1900
2043
  text,
1901
2044
  meta: itemMeta
1902
2045
  });
1903
- if (isRecord$3(value.data)) appendSunoContent(output, value.data, itemMeta);
2046
+ if (isRecord$2(value.data)) appendSunoContent(output, value.data, itemMeta);
1904
2047
  }
1905
2048
  function buildImmediateResult(operation, data, raw) {
1906
2049
  const output = [];
@@ -1993,7 +2136,7 @@ async function sunoTasksAdapter(input) {
1993
2136
  const REQUEST_TIMEOUT_MS = 186e4;
1994
2137
  const DEFAULT_POLL_INTERVAL_SEC = 1;
1995
2138
  const DEFAULT_MAX_WAIT_SEC = 600;
1996
- function isRecord$2(value) {
2139
+ function isRecord$1(value) {
1997
2140
  return !!value && typeof value === "object" && !Array.isArray(value);
1998
2141
  }
1999
2142
  function asString(value) {
@@ -2026,7 +2169,7 @@ function normalizeStatus(value) {
2026
2169
  return status || "unknown";
2027
2170
  }
2028
2171
  function unwrapTaskPayload(response) {
2029
- const data = isRecord$2(response.data) ? response.data : void 0;
2172
+ const data = isRecord$1(response.data) ? response.data : void 0;
2030
2173
  const hasTaskFields = [
2031
2174
  "status",
2032
2175
  "task",
@@ -2040,19 +2183,19 @@ function unwrapTaskPayload(response) {
2040
2183
  return data && !hasTaskFields ? data : response;
2041
2184
  }
2042
2185
  function extractTaskId(response) {
2043
- const data = isRecord$2(response.data) ? response.data : void 0;
2186
+ const data = isRecord$1(response.data) ? response.data : void 0;
2044
2187
  const taskId = asString(response.task_id) ?? asString(response.id) ?? asString(data?.task_id) ?? asString(data?.id);
2045
2188
  if (!taskId) throw new GenerationProviderError("Video upscale provider did not return a task id", { details: { response } });
2046
2189
  return taskId;
2047
2190
  }
2048
2191
  function extractTaskStatus(response) {
2049
2192
  const payload = unwrapTaskPayload(response);
2050
- const task = isRecord$2(payload.task) ? payload.task : payload;
2051
- const metadata = isRecord$2(payload.metadata) ? payload.metadata : isRecord$2(task.metadata) ? task.metadata : void 0;
2052
- const content = isRecord$2(task.content) ? task.content : void 0;
2193
+ const task = isRecord$1(payload.task) ? payload.task : payload;
2194
+ const metadata = isRecord$1(payload.metadata) ? payload.metadata : isRecord$1(task.metadata) ? task.metadata : void 0;
2195
+ const content = isRecord$1(task.content) ? task.content : void 0;
2053
2196
  const status = normalizeStatus(payload.status ?? task.status);
2054
2197
  const videoUrl = asString(metadata?.url) ?? asString(payload.result_url) ?? asString(payload.video_url) ?? asString(payload.url) ?? asString(task.result_url) ?? asString(task.video_url) ?? asString(task.url) ?? asString(content?.video_url) ?? asString(content?.url);
2055
- const error = isRecord$2(payload.error) ? payload.error : isRecord$2(task.error) ? task.error : void 0;
2198
+ const error = isRecord$1(payload.error) ? payload.error : isRecord$1(task.error) ? task.error : void 0;
2056
2199
  const message = asString(error?.message) ?? asString(payload.fail_reason) ?? asString(payload.message) ?? asString(task.fail_reason) ?? asString(task.message) ?? asString(response.message);
2057
2200
  const outputMetadata = compactObject({
2058
2201
  progress: payload.progress ?? task.progress,
@@ -2088,7 +2231,7 @@ async function requestJson(input, path, init) {
2088
2231
  if (!response.ok) throw new GenerationProviderError("Video upscale provider request failed", {
2089
2232
  status: response.status,
2090
2233
  body,
2091
- ...isRecord$2(parsed) ? { details: parsed } : {}
2234
+ ...isRecord$1(parsed) ? { details: parsed } : {}
2092
2235
  });
2093
2236
  return parsed;
2094
2237
  }
@@ -2149,6 +2292,7 @@ async function videoUpscaleNativeAdapter(input) {
2149
2292
  //#region src/adapters/index.ts
2150
2293
  const builtinGenerationAdapters = {
2151
2294
  "ark.videoGenerations": arkVideoGenerationsAdapter,
2295
+ "newapi.audioTranscription": audioTranscriptionAdapter,
2152
2296
  "openai.audioSpeech": audioSpeechAdapter,
2153
2297
  "gemini.generateContent": geminiGenerateContentAdapter,
2154
2298
  "kling.videoGenerations": klingVideoGenerationsAdapter,
@@ -2174,14 +2318,14 @@ const DECLARATION_EXTENSIONS = new Set([
2174
2318
  ".yml",
2175
2319
  ".json"
2176
2320
  ]);
2177
- function isRecord$1(value) {
2321
+ function isRecord(value) {
2178
2322
  return !!value && typeof value === "object" && !Array.isArray(value);
2179
2323
  }
2180
2324
  function isPositiveInteger(value) {
2181
2325
  return typeof value === "number" && Number.isInteger(value) && value > 0;
2182
2326
  }
2183
2327
  function isDimensionsSpec(value) {
2184
- if (!isRecord$1(value)) return false;
2328
+ if (!isRecord(value)) return false;
2185
2329
  if (value.separator !== void 0 && value.separator !== "x" && value.separator !== "*") return false;
2186
2330
  if (value.min !== void 0 && !isPositiveInteger(value.min)) return false;
2187
2331
  if (value.max !== void 0 && !isPositiveInteger(value.max)) return false;
@@ -2189,7 +2333,7 @@ function isDimensionsSpec(value) {
2189
2333
  return value.min === void 0 || value.max === void 0 || value.min <= value.max;
2190
2334
  }
2191
2335
  function isParameterSpec(value) {
2192
- if (!isRecord$1(value)) return false;
2336
+ if (!isRecord(value)) return false;
2193
2337
  if (![
2194
2338
  "string",
2195
2339
  "number",
@@ -2199,11 +2343,11 @@ function isParameterSpec(value) {
2199
2343
  return value.type !== "string" || value.dimensions === void 0 || isDimensionsSpec(value.dimensions);
2200
2344
  }
2201
2345
  function isMetaFieldSpec(value) {
2202
- if (!isRecord$1(value)) return false;
2346
+ if (!isRecord(value)) return false;
2203
2347
  return isParameterSpec(value) || String(value.type) === "object";
2204
2348
  }
2205
2349
  function isMetaTaskVariantSpec(value) {
2206
- if (!isRecord$1(value)) return false;
2350
+ if (!isRecord(value)) return false;
2207
2351
  return (value.description === void 0 || typeof value.description === "string") && (value.required === void 0 || Array.isArray(value.required) && value.required.every((item) => typeof item === "string")) && (value.requiredContent === void 0 || Array.isArray(value.requiredContent) && value.requiredContent.every((item) => typeof item === "string")) && (value.sendTask === void 0 || typeof value.sendTask === "boolean");
2208
2352
  }
2209
2353
  function isGenerationModelCategory(value) {
@@ -2213,7 +2357,7 @@ function isFiniteNonNegative(value) {
2213
2357
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
2214
2358
  }
2215
2359
  function isGenerationModelPricing(value) {
2216
- if (!isRecord$1(value)) return false;
2360
+ if (!isRecord(value)) return false;
2217
2361
  if (typeof value.unit !== "string" || !GENERATION_PRICING_UNITS.includes(value.unit)) return false;
2218
2362
  if (value.note !== void 0 && typeof value.note !== "string") return false;
2219
2363
  if (value.amount !== void 0) {
@@ -2223,17 +2367,17 @@ function isGenerationModelPricing(value) {
2223
2367
  return isFiniteNonNegative(value.min) && isFiniteNonNegative(value.max) && value.min <= value.max;
2224
2368
  }
2225
2369
  function isMetaSpec(value) {
2226
- if (!isRecord$1(value)) return false;
2227
- return (value.fields === void 0 || isRecord$1(value.fields) && Object.values(value.fields).every((field) => isMetaFieldSpec(field))) && (value.taskField === void 0 || typeof value.taskField === "string") && (value.taskVariants === void 0 || isRecord$1(value.taskVariants) && Object.values(value.taskVariants).every((variant) => isMetaTaskVariantSpec(variant)));
2370
+ if (!isRecord(value)) return false;
2371
+ return (value.fields === void 0 || isRecord(value.fields) && Object.values(value.fields).every((field) => isMetaFieldSpec(field))) && (value.taskField === void 0 || typeof value.taskField === "string") && (value.taskVariants === void 0 || isRecord(value.taskVariants) && Object.values(value.taskVariants).every((variant) => isMetaTaskVariantSpec(variant)));
2228
2372
  }
2229
2373
  function isGenerationModelDeclaration(value) {
2230
- if (!isRecord$1(value)) return false;
2374
+ if (!isRecord(value)) return false;
2231
2375
  const adapter = value.adapter;
2232
2376
  const content = value.content;
2233
2377
  const parameters = value.parameters;
2234
2378
  const meta = value.meta;
2235
2379
  const examples = value.examples;
2236
- return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && (value.category === void 0 || isGenerationModelCategory(value.category)) && (value.pricing === void 0 || isGenerationModelPricing(value.pricing)) && (value.hidden === void 0 || typeof value.hidden === "boolean") && (value.allowUnknownParameters === void 0 || typeof value.allowUnknownParameters === "boolean") && isRecord$1(adapter) && typeof adapter.type === "string" && isRecord$1(content) && Array.isArray(content.input) && (parameters === void 0 || isRecord$1(parameters) && Object.values(parameters).every(isParameterSpec)) && (meta === void 0 || isMetaSpec(meta)) && (examples === void 0 || Array.isArray(examples));
2380
+ return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && (value.category === void 0 || isGenerationModelCategory(value.category)) && (value.pricing === void 0 || isGenerationModelPricing(value.pricing)) && (value.hidden === void 0 || typeof value.hidden === "boolean") && (value.allowUnknownParameters === void 0 || typeof value.allowUnknownParameters === "boolean") && isRecord(adapter) && typeof adapter.type === "string" && isRecord(content) && Array.isArray(content.input) && (parameters === void 0 || isRecord(parameters) && Object.values(parameters).every(isParameterSpec)) && (meta === void 0 || isMetaSpec(meta)) && (examples === void 0 || Array.isArray(examples));
2237
2381
  }
2238
2382
  function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
2239
2383
  const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
@@ -2268,36 +2412,6 @@ async function writeGenerationModelDeclarations(declarations, directory, options
2268
2412
  await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
2269
2413
  }
2270
2414
 
2271
- //#endregion
2272
- //#region src/response-fields.ts
2273
- function numberValue(value) {
2274
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
2275
- }
2276
- function stringValue(value) {
2277
- return typeof value === "string" && value ? value : void 0;
2278
- }
2279
- function isRecord(value) {
2280
- return !!value && typeof value === "object" && !Array.isArray(value);
2281
- }
2282
- function extractGenerationResultHeaderFields(headers) {
2283
- const requestId = headers.get("x-request-id")?.trim() || void 0;
2284
- const oneApiRequestId = headers.get("x-oneapi-request-id")?.trim() || void 0;
2285
- return requestId || oneApiRequestId ? {
2286
- ...requestId ? { requestId } : {},
2287
- ...oneApiRequestId ? { oneApiRequestId } : {}
2288
- } : void 0;
2289
- }
2290
- function extractGenerationResultFields(raw) {
2291
- if (!isRecord(raw)) return void 0;
2292
- const usage = isRecord(raw.usage) ? raw.usage : void 0;
2293
- const fields = {};
2294
- const requestId = stringValue(raw.request_id);
2295
- const cost = usage ? numberValue(usage.cost) : void 0;
2296
- if (requestId !== void 0) fields.requestId = requestId;
2297
- if (cost !== void 0) fields.cost = cost;
2298
- return Object.keys(fields).length > 0 ? fields : void 0;
2299
- }
2300
-
2301
2415
  //#endregion
2302
2416
  //#region src/source.ts
2303
2417
  const defaultGenerationSourceResolver = (source) => {
@@ -2523,5 +2637,5 @@ async function exportBuiltinModelConfigs(directory) {
2523
2637
  }
2524
2638
 
2525
2639
  //#endregion
2526
- export { mergeTextBlocks as A, GenerationValidationError as B, openAiImageEditsAdapter as C, audioSpeechAdapter as D, geminiGenerateContentAdapter as E, GenerationError as F, GenerationProviderError as I, GenerationTimeoutError as L, resolveGenerationParameters as M, validateGenerationContent as N, arkVideoGenerationsAdapter as O, GenerationConfigError as P, GenerationTransportError as R, openAiImagesAdapter as S, klingVideoGenerationsAdapter as T, writeGenerationModelDeclarations as _, createGenerationClientFromDirectory as a, videoUpscaleNativeAdapter as b, defaultGenerationSourceResolver as c, parseGenerationModelDeclaration as d, readGenerationModelDeclaration as f, writeGenerationModelDeclaration as g, stringifyGenerationModelDeclaration as h, createGenerationClient as i, resolveGenerationMeta as j, mergeGenerationMeta as k, isGenerationModelDeclaration as l, readGenerationModelDeclarationsFromFiles as m, exportBuiltinModelConfigs as n, createGenerationClientFromFile as o, readGenerationModelDeclarationsFromDirectory as p, stringifyBuiltinModelConfig as r, createGenerationClientFromFiles as s, exportBuiltinModelConfig as t, mergeGenerationModelDeclarations as u, builtinGenerationAdapters as v, minimaxH3VideoGenerationsAdapter as w, sunoTasksAdapter as x, getGenerationAdapter as y, GenerationUnsupportedAdapterError as z };
2527
- //# sourceMappingURL=export-config-Ddkc_VC9.js.map
2640
+ export { mergeGenerationMeta as A, GenerationUnsupportedAdapterError as B, openAiImageEditsAdapter as C, audioTranscriptionAdapter as D, geminiGenerateContentAdapter as E, GenerationConfigError as F, GenerationError as I, GenerationProviderError as L, resolveGenerationMeta as M, resolveGenerationParameters as N, audioSpeechAdapter as O, validateGenerationContent as P, GenerationTimeoutError as R, openAiImagesAdapter as S, klingVideoGenerationsAdapter as T, GenerationValidationError as V, writeGenerationModelDeclarations as _, createGenerationClientFromDirectory as a, videoUpscaleNativeAdapter as b, defaultGenerationSourceResolver as c, parseGenerationModelDeclaration as d, readGenerationModelDeclaration as f, writeGenerationModelDeclaration as g, stringifyGenerationModelDeclaration as h, createGenerationClient as i, mergeTextBlocks as j, arkVideoGenerationsAdapter as k, isGenerationModelDeclaration as l, readGenerationModelDeclarationsFromFiles as m, exportBuiltinModelConfigs as n, createGenerationClientFromFile as o, readGenerationModelDeclarationsFromDirectory as p, stringifyBuiltinModelConfig as r, createGenerationClientFromFiles as s, exportBuiltinModelConfig as t, mergeGenerationModelDeclarations as u, builtinGenerationAdapters as v, minimaxH3VideoGenerationsAdapter as w, sunoTasksAdapter as x, getGenerationAdapter as y, GenerationTransportError as z };
2641
+ //# sourceMappingURL=export-config-DRotzV5u.js.map