@neta-art/generation 0.1.30 → 0.1.33
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 +24 -0
- package/dist/{builtins-BWmXzRgG.js → builtins-B2NxMnfx.js} +156 -90
- package/dist/builtins-B2NxMnfx.js.map +1 -0
- package/dist/builtins-jIE_k69Z.d.ts.map +1 -1
- package/dist/builtins.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/{export-config-Ddkc_VC9.js → export-config-CEA_GJEG.js} +196 -81
- package/dist/export-config-CEA_GJEG.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/models/volc.seedasr.auc.yaml +53 -0
- package/package.json +3 -1
- package/dist/builtins-BWmXzRgG.js.map +0 -1
- package/dist/export-config-Ddkc_VC9.js.map +0 -1
|
@@ -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-
|
|
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-B2NxMnfx.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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
778
|
-
const errorRecord = isRecord$
|
|
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$
|
|
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,133 @@ 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 media = input.request.content.filter((block) => block.type !== "text");
|
|
902
|
+
const [audio] = media;
|
|
903
|
+
if (media.length !== 1 || audio?.type !== "audio" || audio.source.type !== "url") throw new GenerationValidationError("Audio transcription requires exactly one audio URL");
|
|
904
|
+
let url;
|
|
905
|
+
try {
|
|
906
|
+
url = new URL(audio.source.url.trim());
|
|
907
|
+
} catch {
|
|
908
|
+
throw new GenerationValidationError("Audio transcription requires a valid HTTP(S) URL");
|
|
909
|
+
}
|
|
910
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new GenerationValidationError("Audio transcription requires an HTTP(S) URL without credentials");
|
|
911
|
+
for (const meta of [
|
|
912
|
+
input.request.meta,
|
|
913
|
+
input.request.metadata,
|
|
914
|
+
audio.meta
|
|
915
|
+
]) if (Object.keys(meta ?? {}).length > 0) throw new GenerationValidationError("Audio transcription does not accept metadata; use parameters");
|
|
916
|
+
const extension = url.pathname.split("/").at(-1)?.split(".").slice(1).at(-1)?.toLowerCase();
|
|
917
|
+
const format = input.parameters.audio_format ?? extension;
|
|
918
|
+
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");
|
|
919
|
+
const language = input.parameters.language;
|
|
920
|
+
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");
|
|
921
|
+
return {
|
|
922
|
+
model: input.declaration.model,
|
|
923
|
+
audio_url: url.href,
|
|
924
|
+
audio_format: format,
|
|
925
|
+
...language !== void 0 ? { language } : {},
|
|
926
|
+
response_format: "verbose_json"
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
function parseAudioTranscriptionResponse(raw) {
|
|
930
|
+
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");
|
|
931
|
+
const segments = [];
|
|
932
|
+
if (raw.segments !== void 0) {
|
|
933
|
+
if (!Array.isArray(raw.segments)) throw new GenerationProviderError("Invalid transcription segments");
|
|
934
|
+
for (const segment of raw.segments) {
|
|
935
|
+
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");
|
|
936
|
+
segments.push({
|
|
937
|
+
start: segment.start,
|
|
938
|
+
end: segment.end,
|
|
939
|
+
text: segment.text
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
type: "text",
|
|
945
|
+
text: raw.text,
|
|
946
|
+
meta: {
|
|
947
|
+
duration: raw.duration,
|
|
948
|
+
segments
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
async function generateAudioTranscription(input) {
|
|
953
|
+
const payload = buildAudioTranscriptionPayload(input);
|
|
954
|
+
const response = await fetchWithTimeout(input.context.fetch, joinUrl(input.context.baseUrl, "/v1/audio/transcriptions"), {
|
|
955
|
+
method: "POST",
|
|
956
|
+
headers: {
|
|
957
|
+
Authorization: `Bearer ${input.context.apiKey}`,
|
|
958
|
+
"Content-Type": "application/json"
|
|
959
|
+
},
|
|
960
|
+
body: JSON.stringify(payload)
|
|
961
|
+
}, Number(input.parameters.max_wait) * 1e3);
|
|
962
|
+
const body = await response.text();
|
|
963
|
+
const headers = extractGenerationResultHeaderFields(response.headers);
|
|
964
|
+
const details = { requestId: headers?.requestId ?? headers?.oneApiRequestId };
|
|
965
|
+
if (!response.ok) throw new GenerationProviderError(`Audio transcription failed (HTTP ${response.status}): ${body}`, {
|
|
966
|
+
status: response.status,
|
|
967
|
+
body,
|
|
968
|
+
details
|
|
969
|
+
});
|
|
970
|
+
let raw;
|
|
971
|
+
try {
|
|
972
|
+
raw = JSON.parse(body);
|
|
973
|
+
} catch {
|
|
974
|
+
throw new GenerationProviderError("Audio transcription returned invalid JSON", {
|
|
975
|
+
status: response.status,
|
|
976
|
+
body,
|
|
977
|
+
details
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
return [parseAudioTranscriptionResponse(raw)];
|
|
981
|
+
}
|
|
982
|
+
const audioTranscriptionAdapter = Object.assign(generateAudioTranscription, { validate(input) {
|
|
983
|
+
buildAudioTranscriptionPayload(input);
|
|
984
|
+
} });
|
|
985
|
+
|
|
842
986
|
//#endregion
|
|
843
987
|
//#region src/adapters/gemini-generate-content.ts
|
|
844
988
|
const REQUEST_TIMEOUT_MS$6 = 3e5;
|
|
@@ -1008,7 +1152,7 @@ function asInteger$2(value, fallback) {
|
|
|
1008
1152
|
function asNumber(value) {
|
|
1009
1153
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1010
1154
|
}
|
|
1011
|
-
function isRecord$
|
|
1155
|
+
function isRecord$4(value) {
|
|
1012
1156
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1013
1157
|
}
|
|
1014
1158
|
function providerMeta(input) {
|
|
@@ -1150,7 +1294,7 @@ async function requestJson$3(input, path, init) {
|
|
|
1150
1294
|
});
|
|
1151
1295
|
}
|
|
1152
1296
|
if (!response.ok) {
|
|
1153
|
-
const details = isRecord$
|
|
1297
|
+
const details = isRecord$4(parsed) ? { details: parsed } : {};
|
|
1154
1298
|
throw new GenerationProviderError("Kling video provider request failed", {
|
|
1155
1299
|
status: response.status,
|
|
1156
1300
|
body,
|
|
@@ -1234,7 +1378,7 @@ function asInteger$1(value, fallback) {
|
|
|
1234
1378
|
function asBoolean(value, fallback) {
|
|
1235
1379
|
return typeof value === "boolean" ? value : fallback;
|
|
1236
1380
|
}
|
|
1237
|
-
function isRecord$
|
|
1381
|
+
function isRecord$3(value) {
|
|
1238
1382
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1239
1383
|
}
|
|
1240
1384
|
function normalizeStatus$2(value) {
|
|
@@ -1347,7 +1491,7 @@ function resolveRatio(value, mode) {
|
|
|
1347
1491
|
return mode === "text" && requested === ADAPTIVE_RATIO ? DEFAULT_RATIO : requested;
|
|
1348
1492
|
}
|
|
1349
1493
|
function extractTaskId$2(response) {
|
|
1350
|
-
const data = isRecord$
|
|
1494
|
+
const data = isRecord$3(response.data) ? response.data : void 0;
|
|
1351
1495
|
const taskId = asString$2(response.task_id) ?? asString$2(response.id) ?? asString$2(data?.task_id) ?? asString$2(data?.id);
|
|
1352
1496
|
if (!taskId) throw new GenerationProviderError("MiniMax H3 provider did not return a task id", { details: { response } });
|
|
1353
1497
|
return taskId;
|
|
@@ -1365,17 +1509,17 @@ function isTaskPayload(value) {
|
|
|
1365
1509
|
].some((key) => key in value);
|
|
1366
1510
|
}
|
|
1367
1511
|
function unwrapTaskPayload$1(response) {
|
|
1368
|
-
const data = isRecord$
|
|
1512
|
+
const data = isRecord$3(response.data) ? response.data : void 0;
|
|
1369
1513
|
return data && !isTaskPayload(response) ? data : response;
|
|
1370
1514
|
}
|
|
1371
1515
|
function extractTaskStatus$1(response) {
|
|
1372
1516
|
const payload = unwrapTaskPayload$1(response);
|
|
1373
|
-
const task = isRecord$
|
|
1374
|
-
const metadata = isRecord$
|
|
1375
|
-
const content = isRecord$
|
|
1517
|
+
const task = isRecord$3(payload.task) ? payload.task : payload;
|
|
1518
|
+
const metadata = isRecord$3(payload.metadata) ? payload.metadata : isRecord$3(task.metadata) ? task.metadata : void 0;
|
|
1519
|
+
const content = isRecord$3(task.content) ? task.content : void 0;
|
|
1376
1520
|
const status = normalizeStatus$2(payload.status ?? task.status);
|
|
1377
1521
|
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$
|
|
1522
|
+
const error = isRecord$3(payload.error) ? payload.error : isRecord$3(task.error) ? task.error : void 0;
|
|
1379
1523
|
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
1524
|
const outputMetadata = compactObject({
|
|
1381
1525
|
progress: payload.progress ?? task.progress,
|
|
@@ -1412,7 +1556,7 @@ async function requestJson$2(input, path, init) {
|
|
|
1412
1556
|
if (!response.ok) throw new GenerationProviderError("MiniMax H3 provider request failed", {
|
|
1413
1557
|
status: response.status,
|
|
1414
1558
|
body,
|
|
1415
|
-
...isRecord$
|
|
1559
|
+
...isRecord$3(parsed) ? { details: parsed } : {}
|
|
1416
1560
|
});
|
|
1417
1561
|
return parsed;
|
|
1418
1562
|
}
|
|
@@ -1676,7 +1820,7 @@ const FINAL_FAILURE_STATUSES = new Set([
|
|
|
1676
1820
|
"canceled",
|
|
1677
1821
|
"expired"
|
|
1678
1822
|
]);
|
|
1679
|
-
function isRecord$
|
|
1823
|
+
function isRecord$2(value) {
|
|
1680
1824
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1681
1825
|
}
|
|
1682
1826
|
function asString$1(value) {
|
|
@@ -1686,7 +1830,7 @@ function asInteger(value, fallback) {
|
|
|
1686
1830
|
return typeof value === "number" && Number.isInteger(value) ? value : fallback;
|
|
1687
1831
|
}
|
|
1688
1832
|
function asRecord(value) {
|
|
1689
|
-
return isRecord$
|
|
1833
|
+
return isRecord$2(value) ? value : {};
|
|
1690
1834
|
}
|
|
1691
1835
|
function successCode(value) {
|
|
1692
1836
|
const code = String(value ?? "").trim().toLowerCase();
|
|
@@ -1702,7 +1846,7 @@ function requireSuccess(response, fallbackMessage) {
|
|
|
1702
1846
|
}
|
|
1703
1847
|
function extractTaskId$1(value) {
|
|
1704
1848
|
if (typeof value === "string" && value.trim()) return value.trim();
|
|
1705
|
-
if (!isRecord$
|
|
1849
|
+
if (!isRecord$2(value)) return void 0;
|
|
1706
1850
|
for (const key of [
|
|
1707
1851
|
"task_id",
|
|
1708
1852
|
"id",
|
|
@@ -1720,7 +1864,7 @@ function normalizeStatus$1(value) {
|
|
|
1720
1864
|
}
|
|
1721
1865
|
function normalizeTask(operation, data) {
|
|
1722
1866
|
if (Array.isArray(data)) return data.length > 0 ? normalizeTask(operation, data[0]) : null;
|
|
1723
|
-
if (!isRecord$
|
|
1867
|
+
if (!isRecord$2(data)) return null;
|
|
1724
1868
|
if ("status" in data || "taskStatus" in data || "task_status" in data || "task_id" in data || "taskBatchId" in data) {
|
|
1725
1869
|
const hasProviderEnvelope = "taskStatus" in data || "task_status" in data || "taskBatchId" in data || "task_batch_id" in data;
|
|
1726
1870
|
return {
|
|
@@ -1796,7 +1940,7 @@ function applyFixedPayload(input, payload, fixed) {
|
|
|
1796
1940
|
}
|
|
1797
1941
|
}
|
|
1798
1942
|
function setMetadataParam(payload, key, value) {
|
|
1799
|
-
const metadataParams = isRecord$
|
|
1943
|
+
const metadataParams = isRecord$2(payload.metadata_params) ? payload.metadata_params : {};
|
|
1800
1944
|
if (metadataParams[key] === void 0) metadataParams[key] = value;
|
|
1801
1945
|
payload.metadata_params = metadataParams;
|
|
1802
1946
|
}
|
|
@@ -1866,8 +2010,8 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1866
2010
|
for (const item of value) appendSunoContent(output, item, meta);
|
|
1867
2011
|
return;
|
|
1868
2012
|
}
|
|
1869
|
-
if (!isRecord$
|
|
1870
|
-
if (isRecord$
|
|
2013
|
+
if (!isRecord$2(value)) return;
|
|
2014
|
+
if (isRecord$2(value.clips)) for (const clip of Object.values(value.clips)) appendSunoContent(output, clip, meta);
|
|
1871
2015
|
if (Array.isArray(value.items)) for (const item of value.items) appendSunoContent(output, item, meta);
|
|
1872
2016
|
const itemMeta = compactObject({
|
|
1873
2017
|
...meta,
|
|
@@ -1877,9 +2021,9 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1877
2021
|
title: value.title,
|
|
1878
2022
|
status: value.status ?? meta.status,
|
|
1879
2023
|
model: value.model_name ?? value.modelName,
|
|
1880
|
-
duration: value.duration ?? (isRecord$
|
|
1881
|
-
tags: value.tags ?? (isRecord$
|
|
1882
|
-
prompt: value.prompt ?? (isRecord$
|
|
2024
|
+
duration: value.duration ?? (isRecord$2(value.metadata) ? value.metadata.duration : void 0),
|
|
2025
|
+
tags: value.tags ?? (isRecord$2(value.metadata) ? value.metadata.tags : void 0),
|
|
2026
|
+
prompt: value.prompt ?? (isRecord$2(value.metadata) ? value.metadata.prompt : void 0),
|
|
1883
2027
|
progress: value.progress ?? meta.progress,
|
|
1884
2028
|
progress_message: value.progressMsg ?? value.progress_msg,
|
|
1885
2029
|
task_batch_id: value.taskBatchId ?? value.task_batch_id,
|
|
@@ -1900,7 +2044,7 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1900
2044
|
text,
|
|
1901
2045
|
meta: itemMeta
|
|
1902
2046
|
});
|
|
1903
|
-
if (isRecord$
|
|
2047
|
+
if (isRecord$2(value.data)) appendSunoContent(output, value.data, itemMeta);
|
|
1904
2048
|
}
|
|
1905
2049
|
function buildImmediateResult(operation, data, raw) {
|
|
1906
2050
|
const output = [];
|
|
@@ -1993,7 +2137,7 @@ async function sunoTasksAdapter(input) {
|
|
|
1993
2137
|
const REQUEST_TIMEOUT_MS = 186e4;
|
|
1994
2138
|
const DEFAULT_POLL_INTERVAL_SEC = 1;
|
|
1995
2139
|
const DEFAULT_MAX_WAIT_SEC = 600;
|
|
1996
|
-
function isRecord$
|
|
2140
|
+
function isRecord$1(value) {
|
|
1997
2141
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1998
2142
|
}
|
|
1999
2143
|
function asString(value) {
|
|
@@ -2026,7 +2170,7 @@ function normalizeStatus(value) {
|
|
|
2026
2170
|
return status || "unknown";
|
|
2027
2171
|
}
|
|
2028
2172
|
function unwrapTaskPayload(response) {
|
|
2029
|
-
const data = isRecord$
|
|
2173
|
+
const data = isRecord$1(response.data) ? response.data : void 0;
|
|
2030
2174
|
const hasTaskFields = [
|
|
2031
2175
|
"status",
|
|
2032
2176
|
"task",
|
|
@@ -2040,19 +2184,19 @@ function unwrapTaskPayload(response) {
|
|
|
2040
2184
|
return data && !hasTaskFields ? data : response;
|
|
2041
2185
|
}
|
|
2042
2186
|
function extractTaskId(response) {
|
|
2043
|
-
const data = isRecord$
|
|
2187
|
+
const data = isRecord$1(response.data) ? response.data : void 0;
|
|
2044
2188
|
const taskId = asString(response.task_id) ?? asString(response.id) ?? asString(data?.task_id) ?? asString(data?.id);
|
|
2045
2189
|
if (!taskId) throw new GenerationProviderError("Video upscale provider did not return a task id", { details: { response } });
|
|
2046
2190
|
return taskId;
|
|
2047
2191
|
}
|
|
2048
2192
|
function extractTaskStatus(response) {
|
|
2049
2193
|
const payload = unwrapTaskPayload(response);
|
|
2050
|
-
const task = isRecord$
|
|
2051
|
-
const metadata = isRecord$
|
|
2052
|
-
const content = isRecord$
|
|
2194
|
+
const task = isRecord$1(payload.task) ? payload.task : payload;
|
|
2195
|
+
const metadata = isRecord$1(payload.metadata) ? payload.metadata : isRecord$1(task.metadata) ? task.metadata : void 0;
|
|
2196
|
+
const content = isRecord$1(task.content) ? task.content : void 0;
|
|
2053
2197
|
const status = normalizeStatus(payload.status ?? task.status);
|
|
2054
2198
|
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$
|
|
2199
|
+
const error = isRecord$1(payload.error) ? payload.error : isRecord$1(task.error) ? task.error : void 0;
|
|
2056
2200
|
const message = asString(error?.message) ?? asString(payload.fail_reason) ?? asString(payload.message) ?? asString(task.fail_reason) ?? asString(task.message) ?? asString(response.message);
|
|
2057
2201
|
const outputMetadata = compactObject({
|
|
2058
2202
|
progress: payload.progress ?? task.progress,
|
|
@@ -2088,7 +2232,7 @@ async function requestJson(input, path, init) {
|
|
|
2088
2232
|
if (!response.ok) throw new GenerationProviderError("Video upscale provider request failed", {
|
|
2089
2233
|
status: response.status,
|
|
2090
2234
|
body,
|
|
2091
|
-
...isRecord$
|
|
2235
|
+
...isRecord$1(parsed) ? { details: parsed } : {}
|
|
2092
2236
|
});
|
|
2093
2237
|
return parsed;
|
|
2094
2238
|
}
|
|
@@ -2149,6 +2293,7 @@ async function videoUpscaleNativeAdapter(input) {
|
|
|
2149
2293
|
//#region src/adapters/index.ts
|
|
2150
2294
|
const builtinGenerationAdapters = {
|
|
2151
2295
|
"ark.videoGenerations": arkVideoGenerationsAdapter,
|
|
2296
|
+
"newapi.audioTranscription": audioTranscriptionAdapter,
|
|
2152
2297
|
"openai.audioSpeech": audioSpeechAdapter,
|
|
2153
2298
|
"gemini.generateContent": geminiGenerateContentAdapter,
|
|
2154
2299
|
"kling.videoGenerations": klingVideoGenerationsAdapter,
|
|
@@ -2174,14 +2319,14 @@ const DECLARATION_EXTENSIONS = new Set([
|
|
|
2174
2319
|
".yml",
|
|
2175
2320
|
".json"
|
|
2176
2321
|
]);
|
|
2177
|
-
function isRecord
|
|
2322
|
+
function isRecord(value) {
|
|
2178
2323
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2179
2324
|
}
|
|
2180
2325
|
function isPositiveInteger(value) {
|
|
2181
2326
|
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
2182
2327
|
}
|
|
2183
2328
|
function isDimensionsSpec(value) {
|
|
2184
|
-
if (!isRecord
|
|
2329
|
+
if (!isRecord(value)) return false;
|
|
2185
2330
|
if (value.separator !== void 0 && value.separator !== "x" && value.separator !== "*") return false;
|
|
2186
2331
|
if (value.min !== void 0 && !isPositiveInteger(value.min)) return false;
|
|
2187
2332
|
if (value.max !== void 0 && !isPositiveInteger(value.max)) return false;
|
|
@@ -2189,7 +2334,7 @@ function isDimensionsSpec(value) {
|
|
|
2189
2334
|
return value.min === void 0 || value.max === void 0 || value.min <= value.max;
|
|
2190
2335
|
}
|
|
2191
2336
|
function isParameterSpec(value) {
|
|
2192
|
-
if (!isRecord
|
|
2337
|
+
if (!isRecord(value)) return false;
|
|
2193
2338
|
if (![
|
|
2194
2339
|
"string",
|
|
2195
2340
|
"number",
|
|
@@ -2199,11 +2344,11 @@ function isParameterSpec(value) {
|
|
|
2199
2344
|
return value.type !== "string" || value.dimensions === void 0 || isDimensionsSpec(value.dimensions);
|
|
2200
2345
|
}
|
|
2201
2346
|
function isMetaFieldSpec(value) {
|
|
2202
|
-
if (!isRecord
|
|
2347
|
+
if (!isRecord(value)) return false;
|
|
2203
2348
|
return isParameterSpec(value) || String(value.type) === "object";
|
|
2204
2349
|
}
|
|
2205
2350
|
function isMetaTaskVariantSpec(value) {
|
|
2206
|
-
if (!isRecord
|
|
2351
|
+
if (!isRecord(value)) return false;
|
|
2207
2352
|
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
2353
|
}
|
|
2209
2354
|
function isGenerationModelCategory(value) {
|
|
@@ -2213,7 +2358,7 @@ function isFiniteNonNegative(value) {
|
|
|
2213
2358
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
2214
2359
|
}
|
|
2215
2360
|
function isGenerationModelPricing(value) {
|
|
2216
|
-
if (!isRecord
|
|
2361
|
+
if (!isRecord(value)) return false;
|
|
2217
2362
|
if (typeof value.unit !== "string" || !GENERATION_PRICING_UNITS.includes(value.unit)) return false;
|
|
2218
2363
|
if (value.note !== void 0 && typeof value.note !== "string") return false;
|
|
2219
2364
|
if (value.amount !== void 0) {
|
|
@@ -2223,17 +2368,17 @@ function isGenerationModelPricing(value) {
|
|
|
2223
2368
|
return isFiniteNonNegative(value.min) && isFiniteNonNegative(value.max) && value.min <= value.max;
|
|
2224
2369
|
}
|
|
2225
2370
|
function isMetaSpec(value) {
|
|
2226
|
-
if (!isRecord
|
|
2227
|
-
return (value.fields === void 0 || isRecord
|
|
2371
|
+
if (!isRecord(value)) return false;
|
|
2372
|
+
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
2373
|
}
|
|
2229
2374
|
function isGenerationModelDeclaration(value) {
|
|
2230
|
-
if (!isRecord
|
|
2375
|
+
if (!isRecord(value)) return false;
|
|
2231
2376
|
const adapter = value.adapter;
|
|
2232
2377
|
const content = value.content;
|
|
2233
2378
|
const parameters = value.parameters;
|
|
2234
2379
|
const meta = value.meta;
|
|
2235
2380
|
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
|
|
2381
|
+
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
2382
|
}
|
|
2238
2383
|
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
2239
2384
|
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
@@ -2268,36 +2413,6 @@ async function writeGenerationModelDeclarations(declarations, directory, options
|
|
|
2268
2413
|
await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
|
|
2269
2414
|
}
|
|
2270
2415
|
|
|
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
2416
|
//#endregion
|
|
2302
2417
|
//#region src/source.ts
|
|
2303
2418
|
const defaultGenerationSourceResolver = (source) => {
|
|
@@ -2523,5 +2638,5 @@ async function exportBuiltinModelConfigs(directory) {
|
|
|
2523
2638
|
}
|
|
2524
2639
|
|
|
2525
2640
|
//#endregion
|
|
2526
|
-
export {
|
|
2527
|
-
//# sourceMappingURL=export-config-
|
|
2641
|
+
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 };
|
|
2642
|
+
//# sourceMappingURL=export-config-CEA_GJEG.js.map
|