@neta-art/generation 0.1.13 → 0.1.17
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 +5 -0
- package/dist/{builtins-BvtiQicj.js → builtins-BqqqQ7Ib.js} +159 -111
- package/dist/builtins-BqqqQ7Ib.js.map +1 -0
- package/dist/{builtins-H7pH9ppJ.d.ts → builtins-D7Zojd9j.d.ts} +13 -3
- package/dist/builtins-D7Zojd9j.d.ts.map +1 -0
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.js +3 -2
- package/dist/cli/index.js +6 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/{export-config-DccDa5w7.js → export-config-CIZi8HJ8.js} +49 -11
- package/dist/export-config-CIZi8HJ8.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/models/birefnet-general.yaml +6 -2
- package/models/gemini-3.1-flash-image-preview.yaml +1 -2
- package/models/gemini-3.1-flash-lite-image.yaml +50 -0
- package/models/gpt-image-2.yaml +1 -2
- package/models/kling-image-to-video.yaml +1 -2
- package/models/kling-multi-image-to-video.yaml +1 -2
- package/models/kling-omni-video.yaml +1 -2
- package/models/kling-text-to-video.yaml +1 -1
- package/models/krea2.yaml +40 -0
- package/models/noobxl-i2i-ipa-onediff.yaml +7 -6
- package/models/noobxl-t2i-onediff.yaml +7 -5
- package/models/seedance-2-0-fast.yaml +2 -7
- package/models/seedance-2-0.yaml +1 -6
- package/models/suno_image_to_song_chirp_v5.yaml +0 -1
- package/models/suno_music_chirp_fenix.yaml +1 -1
- package/models/suno_upload_audio.yaml +0 -1
- package/models/suno_video_to_song_chirp_v5.yaml +0 -1
- package/models/z-image-turbo.yaml +1 -1
- package/package.json +1 -1
- package/dist/builtins-BvtiQicj.js.map +0 -1
- package/dist/builtins-H7pH9ppJ.d.ts.map +0 -1
- package/dist/export-config-DccDa5w7.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { r as listBuiltinGenerationModels } from "../builtins-BqqqQ7Ib.js";
|
|
3
|
+
import { h as stringifyGenerationModelDeclaration, i as createGenerationClient, n as exportBuiltinModelConfigs, t as exportBuiltinModelConfig } from "../export-config-CIZi8HJ8.js";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
+
|
|
6
7
|
//#region src/cli/index.ts
|
|
7
8
|
function usage() {
|
|
8
9
|
console.log(`neta-generation
|
|
@@ -106,7 +107,7 @@ async function main() {
|
|
|
106
107
|
if (args[0] !== "models") usage();
|
|
107
108
|
switch (args[1]) {
|
|
108
109
|
case "list":
|
|
109
|
-
for (const model of listBuiltinGenerationModels()) console.log(model.model);
|
|
110
|
+
for (const model of listBuiltinGenerationModels()) if (model.hidden !== true) console.log(model.model);
|
|
110
111
|
return;
|
|
111
112
|
case "export": {
|
|
112
113
|
const model = args[2];
|
|
@@ -140,7 +141,7 @@ main().catch((error) => {
|
|
|
140
141
|
console.error(error instanceof Error ? error.message : String(error));
|
|
141
142
|
process.exit(1);
|
|
142
143
|
});
|
|
143
|
-
//#endregion
|
|
144
|
-
export {};
|
|
145
144
|
|
|
145
|
+
//#endregion
|
|
146
|
+
export { };
|
|
146
147
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { listBuiltinGenerationModels } from \"../builtins.js\";\nimport { createGenerationClient } from \"../client.js\";\nimport { stringifyGenerationModelDeclaration } from \"../config.js\";\nimport { exportBuiltinModelConfig, exportBuiltinModelConfigs } from \"../export-config.js\";\nimport type { GenerationContentBlock } from \"../types.js\";\n\nfunction usage(): never {\n console.log(`neta-generation\n\nUsage:\n neta-generation generate <model> --prompt <text> [--param key=value] [--image-url <url>] [--out <directory>] [--debug] [--debug-sensitive] [--no-debug-response-body]\n neta-generation models list\n neta-generation models export <model> --out <file>\n neta-generation models export-all --out <directory>\n\nEnvironment:\n NETA_ROUTER_API_KEY API key used by generate\n`);\n process.exit(1);\n}\n\nfunction readOption(args: string[], name: string): string | null {\n const index = args.indexOf(name);\n if (index < 0) return null;\n return args[index + 1] ?? null;\n}\n\nfunction readOptions(args: string[], name: string): string[] {\n const values: string[] = [];\n for (let index = 0; index < args.length; index += 1) {\n const value = args[index + 1];\n if (args[index] === name && value) values.push(value);\n }\n return values;\n}\n\nfunction hasFlag(args: string[], name: string): boolean {\n return args.includes(name);\n}\n\nfunction parseParameterValue(raw: string): unknown {\n if (raw.startsWith(\"json:\")) return JSON.parse(raw.slice(5));\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n return raw;\n}\n\nfunction parseParameter(value: string): [string, unknown] {\n const separator = value.indexOf(\"=\");\n if (separator <= 0) throw new Error(`Invalid --param value: ${value}`);\n return [value.slice(0, separator), parseParameterValue(value.slice(separator + 1))];\n}\n\nfunction outputSummary(block: GenerationContentBlock): unknown {\n if (block.type === \"text\") return block;\n return {\n type: block.type,\n source:\n block.source.type === \"url\"\n ? block.source\n : {\n type: \"base64\",\n mediaType: block.source.mediaType,\n bytes: Buffer.byteLength(block.source.data, \"base64\"),\n },\n meta: block.meta,\n };\n}\n\nasync function writeOutputFiles(directory: string, output: GenerationContentBlock[]): Promise<void> {\n await mkdir(directory, { recursive: true });\n await Promise.all(\n output.map(async (block, index) => {\n if (\n (block.type !== \"image\" && block.type !== \"video\" && block.type !== \"audio\") ||\n block.source.type !== \"base64\"\n ) {\n return;\n }\n const extension = block.source.mediaType.split(\"/\")[1]?.split(\"+\")[0] || block.type;\n await writeFile(\n join(directory, `${String(index + 1).padStart(2, \"0\")}.${extension}`),\n Buffer.from(block.source.data, \"base64\"),\n );\n }),\n );\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args[0] === \"generate\") {\n const model = args[1];\n const prompt = readOption(args, \"--prompt\");\n const apiKey = process.env.NETA_ROUTER_API_KEY;\n if (!model || !prompt || !apiKey) usage();\n\n const outputDirectory = readOption(args, \"--out\");\n const content: GenerationContentBlock[] = [\n { type: \"text\", text: prompt },\n ...readOptions(args, \"--image-url\").map((url) => ({\n type: \"image\" as const,\n source: { type: \"url\" as const, url },\n })),\n ];\n const parameters = Object.fromEntries(readOptions(args, \"--param\").map(parseParameter));\n const baseUrl = readOption(args, \"--base-url\");\n const debug = hasFlag(args, \"--debug\")\n ? {\n enabled: true,\n includeSensitive: hasFlag(args, \"--debug-sensitive\"),\n includeResponseBody: !hasFlag(args, \"--no-debug-response-body\"),\n }\n : undefined;\n const client = createGenerationClient({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n ...(debug ? { debug } : {}),\n });\n const output = await client.generate({ model, content, parameters });\n if (outputDirectory) await writeOutputFiles(outputDirectory, output);\n console.log(JSON.stringify(output.map(outputSummary), null, 2));\n return;\n }\n\n if (args[0] !== \"models\") usage();\n\n switch (args[1]) {\n case \"list\": {\n for (const model of listBuiltinGenerationModels()) console.log(model.model);\n return;\n }\n case \"export\": {\n const model = args[2];\n const out = readOption(args, \"--out\");\n if (!model || !out) usage();\n await mkdir(dirname(out), { recursive: true });\n await exportBuiltinModelConfig(model, out);\n console.log(out);\n return;\n }\n case \"export-all\": {\n const out = readOption(args, \"--out\");\n if (!out) usage();\n await exportBuiltinModelConfigs(out);\n console.log(out);\n return;\n }\n case \"dump\": {\n const out = readOption(args, \"--out\");\n const models = listBuiltinGenerationModels();\n if (out) {\n await mkdir(out, { recursive: true });\n await Promise.all(\n models.map((model) =>\n writeFile(join(out, `${model.model}.yaml`), stringifyGenerationModelDeclaration(model)),\n ),\n );\n }\n return;\n }\n default:\n usage();\n }\n}\n\nmain().catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["values: string[]","content: GenerationContentBlock[]"],"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { listBuiltinGenerationModels } from \"../builtins.js\";\nimport { createGenerationClient } from \"../client.js\";\nimport { stringifyGenerationModelDeclaration } from \"../config.js\";\nimport { exportBuiltinModelConfig, exportBuiltinModelConfigs } from \"../export-config.js\";\nimport type { GenerationContentBlock } from \"../types.js\";\n\nfunction usage(): never {\n console.log(`neta-generation\n\nUsage:\n neta-generation generate <model> --prompt <text> [--param key=value] [--image-url <url>] [--out <directory>] [--debug] [--debug-sensitive] [--no-debug-response-body]\n neta-generation models list\n neta-generation models export <model> --out <file>\n neta-generation models export-all --out <directory>\n\nEnvironment:\n NETA_ROUTER_API_KEY API key used by generate\n`);\n process.exit(1);\n}\n\nfunction readOption(args: string[], name: string): string | null {\n const index = args.indexOf(name);\n if (index < 0) return null;\n return args[index + 1] ?? null;\n}\n\nfunction readOptions(args: string[], name: string): string[] {\n const values: string[] = [];\n for (let index = 0; index < args.length; index += 1) {\n const value = args[index + 1];\n if (args[index] === name && value) values.push(value);\n }\n return values;\n}\n\nfunction hasFlag(args: string[], name: string): boolean {\n return args.includes(name);\n}\n\nfunction parseParameterValue(raw: string): unknown {\n if (raw.startsWith(\"json:\")) return JSON.parse(raw.slice(5));\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n return raw;\n}\n\nfunction parseParameter(value: string): [string, unknown] {\n const separator = value.indexOf(\"=\");\n if (separator <= 0) throw new Error(`Invalid --param value: ${value}`);\n return [value.slice(0, separator), parseParameterValue(value.slice(separator + 1))];\n}\n\nfunction outputSummary(block: GenerationContentBlock): unknown {\n if (block.type === \"text\") return block;\n return {\n type: block.type,\n source:\n block.source.type === \"url\"\n ? block.source\n : {\n type: \"base64\",\n mediaType: block.source.mediaType,\n bytes: Buffer.byteLength(block.source.data, \"base64\"),\n },\n meta: block.meta,\n };\n}\n\nasync function writeOutputFiles(directory: string, output: GenerationContentBlock[]): Promise<void> {\n await mkdir(directory, { recursive: true });\n await Promise.all(\n output.map(async (block, index) => {\n if (\n (block.type !== \"image\" && block.type !== \"video\" && block.type !== \"audio\") ||\n block.source.type !== \"base64\"\n ) {\n return;\n }\n const extension = block.source.mediaType.split(\"/\")[1]?.split(\"+\")[0] || block.type;\n await writeFile(\n join(directory, `${String(index + 1).padStart(2, \"0\")}.${extension}`),\n Buffer.from(block.source.data, \"base64\"),\n );\n }),\n );\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args[0] === \"generate\") {\n const model = args[1];\n const prompt = readOption(args, \"--prompt\");\n const apiKey = process.env.NETA_ROUTER_API_KEY;\n if (!model || !prompt || !apiKey) usage();\n\n const outputDirectory = readOption(args, \"--out\");\n const content: GenerationContentBlock[] = [\n { type: \"text\", text: prompt },\n ...readOptions(args, \"--image-url\").map((url) => ({\n type: \"image\" as const,\n source: { type: \"url\" as const, url },\n })),\n ];\n const parameters = Object.fromEntries(readOptions(args, \"--param\").map(parseParameter));\n const baseUrl = readOption(args, \"--base-url\");\n const debug = hasFlag(args, \"--debug\")\n ? {\n enabled: true,\n includeSensitive: hasFlag(args, \"--debug-sensitive\"),\n includeResponseBody: !hasFlag(args, \"--no-debug-response-body\"),\n }\n : undefined;\n const client = createGenerationClient({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n ...(debug ? { debug } : {}),\n });\n const output = await client.generate({ model, content, parameters });\n if (outputDirectory) await writeOutputFiles(outputDirectory, output);\n console.log(JSON.stringify(output.map(outputSummary), null, 2));\n return;\n }\n\n if (args[0] !== \"models\") usage();\n\n switch (args[1]) {\n case \"list\": {\n for (const model of listBuiltinGenerationModels()) {\n if (model.hidden !== true) console.log(model.model);\n }\n return;\n }\n case \"export\": {\n const model = args[2];\n const out = readOption(args, \"--out\");\n if (!model || !out) usage();\n await mkdir(dirname(out), { recursive: true });\n await exportBuiltinModelConfig(model, out);\n console.log(out);\n return;\n }\n case \"export-all\": {\n const out = readOption(args, \"--out\");\n if (!out) usage();\n await exportBuiltinModelConfigs(out);\n console.log(out);\n return;\n }\n case \"dump\": {\n const out = readOption(args, \"--out\");\n const models = listBuiltinGenerationModels();\n if (out) {\n await mkdir(out, { recursive: true });\n await Promise.all(\n models.map((model) =>\n writeFile(join(out, `${model.model}.yaml`), stringifyGenerationModelDeclaration(model)),\n ),\n );\n }\n return;\n }\n default:\n usage();\n }\n}\n\nmain().catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;AASA,SAAS,QAAe;AACtB,SAAQ,IAAI;;;;;;;;;;EAUZ;AACA,SAAQ,KAAK,EAAE;;AAGjB,SAAS,WAAW,MAAgB,MAA6B;CAC/D,MAAM,QAAQ,KAAK,QAAQ,KAAK;AAChC,KAAI,QAAQ,EAAG,QAAO;AACtB,QAAO,KAAK,QAAQ,MAAM;;AAG5B,SAAS,YAAY,MAAgB,MAAwB;CAC3D,MAAMA,SAAmB,EAAE;AAC3B,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,QAAQ,KAAK,QAAQ;AAC3B,MAAI,KAAK,WAAW,QAAQ,MAAO,QAAO,KAAK,MAAM;;AAEvD,QAAO;;AAGT,SAAS,QAAQ,MAAgB,MAAuB;AACtD,QAAO,KAAK,SAAS,KAAK;;AAG5B,SAAS,oBAAoB,KAAsB;AACjD,KAAI,IAAI,WAAW,QAAQ,CAAE,QAAO,KAAK,MAAM,IAAI,MAAM,EAAE,CAAC;AAC5D,KAAI,QAAQ,OAAQ,QAAO;AAC3B,KAAI,QAAQ,QAAS,QAAO;AAC5B,QAAO;;AAGT,SAAS,eAAe,OAAkC;CACxD,MAAM,YAAY,MAAM,QAAQ,IAAI;AACpC,K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KAAK,QAAQ;GACX,MAAM,MAAM,WAAW,MAAM,QAAQ;GACrC,MAAM,SAAS,6BAA6B;AAC5C,OAAI,KAAK;AACP,UAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;AACrC,UAAM,QAAQ,IACZ,OAAO,KAAK,UACV,UAAU,KAAK,KAAK,GAAG,MAAM,MAAM,OAAO,EAAE,oCAAoC,MAAM,CAAC,CACxF,CACF;;AAEH;;EAEF,QACE,QAAO;;;AAIb,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;AACrE,SAAQ,KAAK,EAAE;EACf"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as compactArray, c as slugifyFileName, i as cloneJson, l as MODEL_SCHEMA, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels } from "./builtins-BqqqQ7Ib.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";
|
|
5
|
+
|
|
5
6
|
//#region src/errors.ts
|
|
6
7
|
var GenerationError = class extends Error {
|
|
7
8
|
constructor(message) {
|
|
@@ -45,6 +46,7 @@ var GenerationTimeoutError = class extends GenerationProviderError {
|
|
|
45
46
|
this.name = "GenerationTimeoutError";
|
|
46
47
|
}
|
|
47
48
|
};
|
|
49
|
+
|
|
48
50
|
//#endregion
|
|
49
51
|
//#region src/http.ts
|
|
50
52
|
function headersToRecord(headers) {
|
|
@@ -132,6 +134,7 @@ async function fetchWithTimeout(fetchFn, url, init, timeoutMs) {
|
|
|
132
134
|
function joinUrl(baseUrl, path) {
|
|
133
135
|
return `${baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
134
136
|
}
|
|
137
|
+
|
|
135
138
|
//#endregion
|
|
136
139
|
//#region src/validation.ts
|
|
137
140
|
function specsByType(specs) {
|
|
@@ -199,11 +202,22 @@ function mergeMetaFields(target, meta) {
|
|
|
199
202
|
if (value !== void 0 && target[normalizedKey] === void 0) target[normalizedKey] = value;
|
|
200
203
|
}
|
|
201
204
|
}
|
|
205
|
+
function validateDimensions(label, value, spec) {
|
|
206
|
+
const separator = spec.separator ?? "x";
|
|
207
|
+
const parts = value.split(separator);
|
|
208
|
+
if (parts.length !== 2 || parts.some((part) => !/^\d+$/.test(part))) throw new GenerationValidationError(`${label} must be formatted as WIDTH${separator}HEIGHT`);
|
|
209
|
+
const dimensions = parts.map(Number);
|
|
210
|
+
const { min, max, multipleOf } = spec;
|
|
211
|
+
if (min !== void 0 && dimensions.some((dimension) => dimension < min)) throw new GenerationValidationError(`${label} dimensions must be >= ${min}`);
|
|
212
|
+
if (max !== void 0 && dimensions.some((dimension) => dimension > max)) throw new GenerationValidationError(`${label} dimensions must be <= ${max}`);
|
|
213
|
+
if (multipleOf !== void 0 && dimensions.some((dimension) => dimension % multipleOf !== 0)) throw new GenerationValidationError(`${label} dimensions must be multiples of ${multipleOf}`);
|
|
214
|
+
}
|
|
202
215
|
function validateSpecValue(label, spec, value) {
|
|
203
216
|
switch (spec.type) {
|
|
204
217
|
case "string":
|
|
205
218
|
if (typeof value !== "string") throw new GenerationValidationError(`${label} must be a string`);
|
|
206
219
|
if (spec.enum && !spec.enum.includes(value)) throw new GenerationValidationError(`${label} must be one of: ${spec.enum.join(", ")}`);
|
|
220
|
+
if (spec.dimensions) validateDimensions(label, value, spec.dimensions);
|
|
207
221
|
break;
|
|
208
222
|
case "number":
|
|
209
223
|
if (typeof value !== "number" || !Number.isFinite(value)) throw new GenerationValidationError(`${label} must be a number`);
|
|
@@ -253,6 +267,7 @@ function mergeTextBlocks(declaration, content) {
|
|
|
253
267
|
const separator = textSpec?.merge === "space" ? " " : textSpec?.merge === "concat" ? "" : "\n";
|
|
254
268
|
return content.filter((block) => block.type === "text").map((block) => block.text).join(separator).trim();
|
|
255
269
|
}
|
|
270
|
+
|
|
256
271
|
//#endregion
|
|
257
272
|
//#region src/adapters/ark-video-generations.ts
|
|
258
273
|
const REQUEST_TIMEOUT_MS$5 = 186e4;
|
|
@@ -412,7 +427,7 @@ async function arkVideoGenerationsAdapter(input) {
|
|
|
412
427
|
const mode = classifyMedia(inputMedia);
|
|
413
428
|
const media = await resolveMedia(input, inputMedia);
|
|
414
429
|
const resolution = asString$2(input.parameters.resolution) ?? "720p";
|
|
415
|
-
const ratio = asString$2(input.request.parameters?.ratio) ?? asString$2(input.
|
|
430
|
+
const ratio = asString$2(input.request.parameters?.ratio) ?? asString$2(input.parameters.ratio) ?? "16:9";
|
|
416
431
|
const duration = getIntegerParameter(input.parameters, "duration", 5);
|
|
417
432
|
const fps = getIntegerParameter(input.parameters, "fps", 30);
|
|
418
433
|
const pollIntervalSec = getIntegerParameter(input.parameters, "poll_interval", DEFAULT_POLL_INTERVAL_SEC$2);
|
|
@@ -494,6 +509,7 @@ async function arkVideoGenerationsAdapter(input) {
|
|
|
494
509
|
}
|
|
495
510
|
throw new GenerationTimeoutError("Timed out waiting for video generation", { taskId });
|
|
496
511
|
}
|
|
512
|
+
|
|
497
513
|
//#endregion
|
|
498
514
|
//#region src/adapters/gemini-generate-content.ts
|
|
499
515
|
const REQUEST_TIMEOUT_MS$4 = 3e5;
|
|
@@ -625,6 +641,7 @@ async function geminiGenerateContentAdapter(input) {
|
|
|
625
641
|
if (output.length === 0) throw new GenerationProviderError("Gemini generation returned no output", { details: collectGeminiNoOutputDetails(raw) });
|
|
626
642
|
return output;
|
|
627
643
|
}
|
|
644
|
+
|
|
628
645
|
//#endregion
|
|
629
646
|
//#region src/adapters/kling-video-generations.ts
|
|
630
647
|
const REQUEST_TIMEOUT_MS$3 = 186e4;
|
|
@@ -863,6 +880,7 @@ async function klingVideoGenerationsAdapter(input) {
|
|
|
863
880
|
}
|
|
864
881
|
throw new GenerationTimeoutError("Timed out waiting for Kling video generation", { taskId });
|
|
865
882
|
}
|
|
883
|
+
|
|
866
884
|
//#endregion
|
|
867
885
|
//#region src/adapters/openai-image-edits.ts
|
|
868
886
|
const REQUEST_TIMEOUT_MS$2 = 3e5;
|
|
@@ -932,6 +950,7 @@ async function openAiImageEditsAdapter(input) {
|
|
|
932
950
|
if (output.length === 0) throw new GenerationProviderError("Image edit returned no output", { details: collectOpenAiImageEditsNoOutputDetails(raw) });
|
|
933
951
|
return output;
|
|
934
952
|
}
|
|
953
|
+
|
|
935
954
|
//#endregion
|
|
936
955
|
//#region src/adapters/openai-images.ts
|
|
937
956
|
const REQUEST_TIMEOUT_MS$1 = 3e5;
|
|
@@ -1008,6 +1027,7 @@ async function openAiImagesAdapter(input) {
|
|
|
1008
1027
|
if (output.length === 0) throw new GenerationProviderError("Image generation returned no output", { details: collectOpenAiImagesNoOutputDetails(raw) });
|
|
1009
1028
|
return output;
|
|
1010
1029
|
}
|
|
1030
|
+
|
|
1011
1031
|
//#endregion
|
|
1012
1032
|
//#region src/adapters/suno-tasks.ts
|
|
1013
1033
|
const REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -1042,12 +1062,12 @@ const OPERATION_PATHS = {
|
|
|
1042
1062
|
poll: true
|
|
1043
1063
|
}
|
|
1044
1064
|
};
|
|
1045
|
-
const FINAL_SUCCESS_STATUSES =
|
|
1065
|
+
const FINAL_SUCCESS_STATUSES = new Set([
|
|
1046
1066
|
"success",
|
|
1047
1067
|
"succeeded",
|
|
1048
1068
|
"completed"
|
|
1049
1069
|
]);
|
|
1050
|
-
const FINAL_FAILURE_STATUSES =
|
|
1070
|
+
const FINAL_FAILURE_STATUSES = new Set([
|
|
1051
1071
|
"failure",
|
|
1052
1072
|
"failed",
|
|
1053
1073
|
"error",
|
|
@@ -1366,6 +1386,7 @@ async function sunoTasksAdapter(input) {
|
|
|
1366
1386
|
if (!taskId) return buildImmediateResult(operation, data, raw);
|
|
1367
1387
|
return pollSunoTask(input, operation, taskId, asInteger(input.parameters.poll_interval, DEFAULT_POLL_INTERVAL_SEC), asInteger(input.parameters.max_wait, DEFAULT_MAX_WAIT_SEC));
|
|
1368
1388
|
}
|
|
1389
|
+
|
|
1369
1390
|
//#endregion
|
|
1370
1391
|
//#region src/adapters/index.ts
|
|
1371
1392
|
const builtinGenerationAdapters = {
|
|
@@ -1381,9 +1402,10 @@ function getGenerationAdapter(type, adapters = {}) {
|
|
|
1381
1402
|
if (!adapter) throw new GenerationUnsupportedAdapterError(type);
|
|
1382
1403
|
return adapter;
|
|
1383
1404
|
}
|
|
1405
|
+
|
|
1384
1406
|
//#endregion
|
|
1385
1407
|
//#region src/config.ts
|
|
1386
|
-
const DECLARATION_EXTENSIONS =
|
|
1408
|
+
const DECLARATION_EXTENSIONS = new Set([
|
|
1387
1409
|
".yaml",
|
|
1388
1410
|
".yml",
|
|
1389
1411
|
".json"
|
|
@@ -1391,14 +1413,26 @@ const DECLARATION_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
1391
1413
|
function isRecord$1(value) {
|
|
1392
1414
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1393
1415
|
}
|
|
1416
|
+
function isPositiveInteger(value) {
|
|
1417
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
1418
|
+
}
|
|
1419
|
+
function isDimensionsSpec(value) {
|
|
1420
|
+
if (!isRecord$1(value)) return false;
|
|
1421
|
+
if (value.separator !== void 0 && value.separator !== "x" && value.separator !== "*") return false;
|
|
1422
|
+
if (value.min !== void 0 && !isPositiveInteger(value.min)) return false;
|
|
1423
|
+
if (value.max !== void 0 && !isPositiveInteger(value.max)) return false;
|
|
1424
|
+
if (value.multipleOf !== void 0 && !isPositiveInteger(value.multipleOf)) return false;
|
|
1425
|
+
return value.min === void 0 || value.max === void 0 || value.min <= value.max;
|
|
1426
|
+
}
|
|
1394
1427
|
function isParameterSpec(value) {
|
|
1395
1428
|
if (!isRecord$1(value)) return false;
|
|
1396
|
-
|
|
1429
|
+
if (![
|
|
1397
1430
|
"string",
|
|
1398
1431
|
"number",
|
|
1399
1432
|
"integer",
|
|
1400
1433
|
"boolean"
|
|
1401
|
-
].includes(String(value.type));
|
|
1434
|
+
].includes(String(value.type))) return false;
|
|
1435
|
+
return value.type !== "string" || value.dimensions === void 0 || isDimensionsSpec(value.dimensions);
|
|
1402
1436
|
}
|
|
1403
1437
|
function isMetaFieldSpec(value) {
|
|
1404
1438
|
if (!isRecord$1(value)) return false;
|
|
@@ -1419,7 +1453,7 @@ function isGenerationModelDeclaration(value) {
|
|
|
1419
1453
|
const parameters = value.parameters;
|
|
1420
1454
|
const meta = value.meta;
|
|
1421
1455
|
const examples = value.examples;
|
|
1422
|
-
return value.schema ===
|
|
1456
|
+
return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && (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));
|
|
1423
1457
|
}
|
|
1424
1458
|
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
1425
1459
|
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
@@ -1453,6 +1487,7 @@ async function writeGenerationModelDeclarations(declarations, directory, options
|
|
|
1453
1487
|
const ext = options.format === "json" ? "json" : "yaml";
|
|
1454
1488
|
await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
|
|
1455
1489
|
}
|
|
1490
|
+
|
|
1456
1491
|
//#endregion
|
|
1457
1492
|
//#region src/response-fields.ts
|
|
1458
1493
|
function numberValue(value) {
|
|
@@ -1474,6 +1509,7 @@ function extractGenerationResultFields(raw) {
|
|
|
1474
1509
|
if (cost !== void 0) fields.cost = cost;
|
|
1475
1510
|
return Object.keys(fields).length > 0 ? fields : void 0;
|
|
1476
1511
|
}
|
|
1512
|
+
|
|
1477
1513
|
//#endregion
|
|
1478
1514
|
//#region src/source.ts
|
|
1479
1515
|
const defaultGenerationSourceResolver = (source) => {
|
|
@@ -1482,13 +1518,14 @@ const defaultGenerationSourceResolver = (source) => {
|
|
|
1482
1518
|
case "base64": return `data:${source.mediaType};base64,${source.data}`;
|
|
1483
1519
|
}
|
|
1484
1520
|
};
|
|
1521
|
+
|
|
1485
1522
|
//#endregion
|
|
1486
1523
|
//#region src/client.ts
|
|
1487
1524
|
const DEFAULT_BASE_URL = "https://router.neta.art";
|
|
1488
1525
|
const REDACTED = "[REDACTED]";
|
|
1489
1526
|
const SECRET_DEBUG_KEY_PATTERN = /^(authorization|api[-_]?key|token|thoughtSignature)$/i;
|
|
1490
1527
|
const BASE64_DEBUG_KEY_PATTERN = /^(b64_json|data)$/i;
|
|
1491
|
-
const MEDIA_PAYLOAD_KEYS =
|
|
1528
|
+
const MEDIA_PAYLOAD_KEYS = new Set([
|
|
1492
1529
|
"audio",
|
|
1493
1530
|
"audio_url",
|
|
1494
1531
|
"image",
|
|
@@ -1662,6 +1699,7 @@ async function createGenerationClientFromDirectory(directory, options = {}) {
|
|
|
1662
1699
|
async function createGenerationClientFromFile(filePath, options = {}) {
|
|
1663
1700
|
return createGenerationClientFromFiles([filePath], options);
|
|
1664
1701
|
}
|
|
1702
|
+
|
|
1665
1703
|
//#endregion
|
|
1666
1704
|
//#region src/export-config.ts
|
|
1667
1705
|
function stringifyBuiltinModelConfig(model, options = {}) {
|
|
@@ -1677,7 +1715,7 @@ async function exportBuiltinModelConfig(model, filePath) {
|
|
|
1677
1715
|
async function exportBuiltinModelConfigs(directory) {
|
|
1678
1716
|
await writeGenerationModelDeclarations(listBuiltinGenerationModels(), directory);
|
|
1679
1717
|
}
|
|
1718
|
+
|
|
1680
1719
|
//#endregion
|
|
1681
1720
|
export { validateGenerationContent as A, klingVideoGenerationsAdapter as C, mergeTextBlocks as D, mergeGenerationMeta as E, GenerationUnsupportedAdapterError as F, GenerationValidationError as I, GenerationError as M, GenerationProviderError as N, resolveGenerationMeta as O, GenerationTimeoutError as P, openAiImageEditsAdapter as S, arkVideoGenerationsAdapter as T, writeGenerationModelDeclarations as _, createGenerationClientFromDirectory as a, sunoTasksAdapter as b, defaultGenerationSourceResolver as c, parseGenerationModelDeclaration as d, readGenerationModelDeclaration as f, writeGenerationModelDeclaration as g, stringifyGenerationModelDeclaration as h, createGenerationClient as i, GenerationConfigError as j, resolveGenerationParameters 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, geminiGenerateContentAdapter as w, openAiImagesAdapter as x, getGenerationAdapter as y };
|
|
1682
|
-
|
|
1683
|
-
//# sourceMappingURL=export-config-DccDa5w7.js.map
|
|
1721
|
+
//# sourceMappingURL=export-config-CIZi8HJ8.js.map
|