@neta-art/generation 0.1.0 → 0.1.1
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/dist/{builtins-hmNIcYXN.js → builtins-B1AheaEa.js} +9 -2
- package/dist/builtins-B1AheaEa.js.map +1 -0
- package/dist/builtins.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/{export-config-ZxwkQoZ6.js → export-config-Bwqnn7Vs.js} +2 -2
- package/dist/{export-config-ZxwkQoZ6.js.map → export-config-Bwqnn7Vs.js.map} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/builtins-hmNIcYXN.js.map +0 -1
|
@@ -12,6 +12,13 @@ function slugifyFileName(value) {
|
|
|
12
12
|
function getBlockMeta(block) {
|
|
13
13
|
return "meta" in block ? block.meta : void 0;
|
|
14
14
|
}
|
|
15
|
+
function compactArray(values) {
|
|
16
|
+
return values.length > 0 ? values : void 0;
|
|
17
|
+
}
|
|
18
|
+
function compactObject(value) {
|
|
19
|
+
for (const key of Object.keys(value)) if (value[key] === void 0) delete value[key];
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
15
22
|
|
|
16
23
|
//#endregion
|
|
17
24
|
//#region src/builtins.ts
|
|
@@ -307,5 +314,5 @@ function listBuiltinGenerationModels() {
|
|
|
307
314
|
}
|
|
308
315
|
|
|
309
316
|
//#endregion
|
|
310
|
-
export {
|
|
311
|
-
//# sourceMappingURL=builtins-
|
|
317
|
+
export { compactArray as a, slugifyFileName as c, cloneJson as i, MODEL_SCHEMA as l, getBuiltinGenerationModel as n, compactObject as o, listBuiltinGenerationModels as r, getBlockMeta as s, builtinGenerationModels as t };
|
|
318
|
+
//# sourceMappingURL=builtins-B1AheaEa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-B1AheaEa.js","names":["builtinGenerationModels: GenerationModelDeclaration[]"],"sources":["../src/types.ts","../src/utils.ts","../src/builtins.ts"],"sourcesContent":["export const MODEL_SCHEMA = \"neta.generation.model.v1\" as const;\n\nexport type GenerationSource = { type: \"url\"; url: string } | { type: \"base64\"; mediaType: string; data: string };\n\nexport type GenerationContentBlockMeta = Record<string, unknown>;\n\nexport type GenerationContentBlock =\n | { type: \"text\"; text: string; meta?: GenerationContentBlockMeta }\n | { type: \"image\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"video\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"audio\"; source: GenerationSource; meta?: GenerationContentBlockMeta };\n\nexport type GenerationContentSpec = {\n type: \"text\" | \"image\" | \"video\" | \"audio\";\n required?: boolean;\n min?: number;\n max?: number;\n sources?: Array<GenerationSource[\"type\"]>;\n merge?: \"newline\" | \"space\" | \"concat\";\n meta?: Record<string, unknown>;\n description?: string;\n};\n\nexport type GenerationParameterSpec =\n | {\n type: \"string\";\n optional?: boolean;\n default?: string;\n enum?: string[];\n description?: string;\n examples?: string[];\n }\n | {\n type: \"number\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"integer\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"boolean\";\n optional?: boolean;\n default?: boolean;\n description?: string;\n examples?: boolean[];\n };\n\nexport type GenerationModelDeclaration = {\n schema: typeof MODEL_SCHEMA;\n model: string;\n title?: string;\n description?: string;\n adapter: {\n type: string;\n };\n content: {\n input: GenerationContentSpec[];\n };\n parameters?: Record<string, GenerationParameterSpec>;\n examples?: Array<{\n title?: string;\n request: GenerateRequest;\n }>;\n};\n\nexport type GenerateRequest = {\n model: string;\n content: GenerationContentBlock[];\n parameters?: Record<string, unknown>;\n apiKey?: string;\n baseUrl?: string;\n metadata?: Record<string, unknown>;\n};\n\nexport type ResolvedGenerationRequest = {\n declaration: GenerationModelDeclaration;\n request: GenerateRequest;\n parameters: Record<string, unknown>;\n};\n\nexport type GenerationSourceResolver = (source: GenerationSource) => Promise<string> | string;\n\nexport type GenerationAdapterContext = {\n apiKey: string;\n baseUrl: string;\n fetch: typeof fetch;\n resolveSource: GenerationSourceResolver;\n};\n\nexport type GenerationAdapterInput = ResolvedGenerationRequest & {\n context: GenerationAdapterContext;\n};\n\nexport type GenerationAdapter = (input: GenerationAdapterInput) => Promise<GenerationContentBlock[]>;\n\nexport type CreateGenerationClientOptions = {\n apiKey?: string;\n baseUrl?: string;\n models?: GenerationModelDeclaration[];\n includeBuiltinModels?: boolean;\n fetch?: typeof fetch;\n sourceResolver?: GenerationSourceResolver;\n adapters?: Record<string, GenerationAdapter>;\n};\n\nexport type GenerationClient = {\n generate(request: GenerateRequest): Promise<GenerationContentBlock[]>;\n validate(request: GenerateRequest): ResolvedGenerationRequest;\n listModels(): GenerationModelDeclaration[];\n getModel(model: string): GenerationModelDeclaration | null;\n stringifyModelConfig(model: string, options?: { format?: \"yaml\" | \"json\" }): string;\n exportModelConfig(model: string, filePath: string): Promise<void>;\n exportModelConfigs(directory: string): Promise<void>;\n};\n","import type { GenerationContentBlock } from \"./types.js\";\n\nexport function cloneJson<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nexport function slugifyFileName(value: string): string {\n return (\n value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"model\"\n );\n}\n\nexport function getBlockMeta(block: GenerationContentBlock): Record<string, unknown> | undefined {\n return \"meta\" in block ? block.meta : undefined;\n}\n\nexport function compactArray<T>(values: T[]): T[] | undefined {\n return values.length > 0 ? values : undefined;\n}\n\nexport function compactObject<T extends Record<string, unknown>>(value: T): T {\n for (const key of Object.keys(value)) if (value[key] === undefined) delete value[key];\n return value;\n}\n","import type { GenerationModelDeclaration } from \"./types.js\";\nimport { MODEL_SCHEMA } from \"./types.js\";\nimport { cloneJson } from \"./utils.js\";\n\nconst imageSizeParameters = {\n size: {\n type: \"string\",\n optional: true,\n default: \"1024x1024\",\n description: \"Output image size.\",\n examples: [\"auto\", \"1024x1024\", \"1536x1024\", \"1024x1536\", \"2048x2048\", \"2048x1152\", \"3840x2160\", \"2160x3840\"],\n },\n quality: {\n type: \"string\",\n optional: true,\n default: \"auto\",\n enum: [\"auto\", \"low\", \"medium\", \"high\"],\n description: \"Image quality.\",\n },\n} satisfies GenerationModelDeclaration[\"parameters\"];\n\nfunction videoParameters(defaults: { resolution: string; maxWait: number }) {\n return {\n duration: {\n type: \"integer\",\n optional: true,\n default: 5,\n min: 4,\n max: 15,\n description: \"Video duration in seconds.\",\n },\n resolution: {\n type: \"string\",\n optional: true,\n default: defaults.resolution,\n enum: [\"480p\", \"720p\", \"1080p\", \"2K\"],\n description: \"Output video resolution.\",\n },\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"16:9\",\n enum: [\"16:9\", \"9:16\", \"1:1\", \"4:3\", \"3:2\", \"2:3\", \"3:4\", \"21:9\", \"adaptive\"],\n description: \"Output aspect ratio. Use adaptive to let the model choose.\",\n },\n fps: { type: \"integer\", optional: true, default: 30, min: 1, max: 60, description: \"Frames per second.\" },\n seed: { type: \"integer\", optional: true, description: \"Random seed for reproducibility.\" },\n generate_audio: { type: \"boolean\", optional: true, default: true, description: \"Generate synchronized audio.\" },\n return_last_frame: {\n type: \"boolean\",\n optional: true,\n default: true,\n description: \"Return the last frame as an image for chaining video segments.\",\n },\n camera_fixed: {\n type: \"boolean\",\n optional: true,\n default: false,\n description: \"Fix camera position when supported.\",\n },\n watermark: { type: \"boolean\", optional: true, default: false, description: \"Add AI Generated watermark.\" },\n poll_interval: {\n type: \"integer\",\n optional: true,\n default: 2,\n min: 1,\n max: 30,\n description: \"Seconds between task status checks.\",\n },\n max_wait: {\n type: \"integer\",\n optional: true,\n default: defaults.maxWait,\n min: 30,\n max: 1800,\n description: \"Maximum seconds to wait for task completion.\",\n },\n } satisfies GenerationModelDeclaration[\"parameters\"];\n}\n\nconst builtinModels = [\n {\n schema: MODEL_SCHEMA,\n model: \"gpt-image-2\",\n title: \"GPT Image 2\",\n description:\n \"Image generation model with optional reference images. Good for photorealistic scenes, detailed images, and image editing with references.\",\n adapter: { type: \"openai.images\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 16,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: imageSizeParameters,\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gpt-image-2\",\n content: [{ type: \"text\", text: \"a cyberpunk cat in neon rain\" }],\n parameters: { size: \"1024x1024\", quality: \"auto\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"gemini-3.1-flash-image-preview\",\n title: \"Gemini 3.1 Flash Image Preview\",\n description:\n \"Gemini image generation and editing model. Good for text rendering, infographics, style transfer, and iterative image editing with references.\",\n adapter: { type: \"gemini.generateContent\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 14,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: {\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"1:1\",\n enum: [\"1:1\", \"16:9\", \"4:3\", \"3:2\", \"3:4\", \"2:3\", \"9:16\", \"5:4\", \"4:5\", \"21:9\", \"1:4\", \"4:1\", \"1:8\", \"8:1\"],\n description: \"Output aspect ratio.\",\n },\n image_size: {\n type: \"string\",\n optional: true,\n default: \"2K\",\n enum: [\"512\", \"1K\", \"2K\", \"4K\"],\n description: \"Output image resolution.\",\n },\n },\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gemini-3.1-flash-image-preview\",\n content: [\n { type: \"text\", text: \"a vibrant infographic explaining photosynthesis with clear readable labels\" },\n ],\n parameters: { aspect_ratio: \"16:9\", image_size: \"1K\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0\",\n title: \"Seedance 2.0\",\n description: \"Higher quality Ark video generation model for final production outputs.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"1080p\", maxWait: 900 }),\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0-fast\",\n title: \"Seedance 2.0 Fast\",\n description:\n \"Fast Ark video generation model for drafts, rapid iteration, text-to-video, image-to-video, and reference-guided video generation.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"720p\", maxWait: 600 }),\n },\n] satisfies GenerationModelDeclaration[];\n\nexport const builtinGenerationModels: GenerationModelDeclaration[] = cloneJson(builtinModels);\n\nexport function getBuiltinGenerationModel(model: string): GenerationModelDeclaration | null {\n return cloneJson(builtinModels.find((declaration) => declaration.model === model) ?? null);\n}\n\nexport function listBuiltinGenerationModels(): GenerationModelDeclaration[] {\n return cloneJson(builtinModels);\n}\n"],"mappings":";AAAA,MAAa,eAAe;;;;ACE5B,SAAgB,UAAa,OAAa;AACxC,QAAO,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC;;AAG1C,SAAgB,gBAAgB,OAAuB;AACrD,QACE,MACG,MAAM,CACN,aAAa,CACb,QAAQ,kBAAkB,IAAI,CAC9B,QAAQ,YAAY,GAAG,IAAI;;AAIlC,S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AAM;KAAC;KAAO;KAAM;KAAM;KAAK;IAC/B,aAAa;IACd;GACF;EACD,UAAU,CACR;GACE,OAAO;GACP,SAAS;IACP,OAAO;IACP,SAAS,CACP;KAAE,MAAM;KAAQ,MAAM;KAA8E,CACrG;IACD,YAAY;KAAE,cAAc;KAAQ,YAAY;KAAM;IACvD;GACF,CACF;EACF;CACD;EACE,QAAQ;EACR,OAAO;EACP,OAAO;EACP,aAAa;EACb,SAAS,EAAE,MAAM,wBAAwB;EACzC,SAAS,EACP,OAAO,CACL;GAAE,MAAM;GAAQ,UAAU;GAAM,KAAK;GAAG,KAAK;GAAI,OAAO;GAAW,aAAa;GAAiB,EACjG;GACE,MAAM;GACN,UAAU;GACV,KAAK;GACL,SAAS,CAAC,OAAO,SAAS;GAC1B,aAAa;GACd,CACF,EACF;EACD,YAAY,gBAAgB;GAAE,YAAY;GAAS,SAAS;GAAK,CAAC;EACnE;CACD;EACE,QAAQ;EACR,OAAO;EACP,OAAO;EACP,aACE;EACF,SAAS,EAAE,MAAM,wBAAwB;EACzC,SAAS,EACP,OAAO,CACL;GAAE,MAAM;GAAQ,UAAU;GAAM,KAAK;GAAG,KAAK;GAAI,OAAO;GAAW,aAAa;GAAiB,EACjG;GACE,MAAM;GACN,UAAU;GACV,KAAK;GACL,SAAS,CAAC,OAAO,SAAS;GAC1B,aAAa;GACd,CACF,EACF;EACD,YAAY,gBAAgB;GAAE,YAAY;GAAQ,SAAS;GAAK,CAAC;EAClE;CACF;AAED,MAAaA,0BAAwD,UAAU,cAAc;AAE7F,SAAgB,0BAA0B,OAAkD;AAC1F,QAAO,UAAU,cAAc,MAAM,gBAAgB,YAAY,UAAU,MAAM,IAAI,KAAK;;AAG5F,SAAgB,8BAA4D;AAC1E,QAAO,UAAU,cAAc"}
|
package/dist/builtins.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-
|
|
1
|
+
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-B1AheaEa.js";
|
|
2
2
|
|
|
3
3
|
export { builtinGenerationModels, getBuiltinGenerationModel, listBuiltinGenerationModels };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as listBuiltinGenerationModels } from "../builtins-
|
|
3
|
-
import { n as exportBuiltinModelConfigs, t as exportBuiltinModelConfig, u as stringifyGenerationModelDeclaration } from "../export-config-
|
|
2
|
+
import { r as listBuiltinGenerationModels } from "../builtins-B1AheaEa.js";
|
|
3
|
+
import { n as exportBuiltinModelConfigs, t as exportBuiltinModelConfig, u as stringifyGenerationModelDeclaration } from "../export-config-Bwqnn7Vs.js";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as slugifyFileName, i as cloneJson, l as MODEL_SCHEMA, n as getBuiltinGenerationModel, r as listBuiltinGenerationModels } from "./builtins-B1AheaEa.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";
|
|
@@ -125,4 +125,4 @@ async function exportBuiltinModelConfigs(directory) {
|
|
|
125
125
|
|
|
126
126
|
//#endregion
|
|
127
127
|
export { GenerationUnsupportedAdapterError as _, mergeGenerationModelDeclarations as a, readGenerationModelDeclarationsFromDirectory as c, writeGenerationModelDeclaration as d, writeGenerationModelDeclarations as f, GenerationTimeoutError as g, GenerationProviderError as h, isGenerationModelDeclaration as i, readGenerationModelDeclarationsFromFiles as l, GenerationError as m, exportBuiltinModelConfigs as n, parseGenerationModelDeclaration as o, GenerationConfigError as p, stringifyBuiltinModelConfig as r, readGenerationModelDeclaration as s, exportBuiltinModelConfig as t, stringifyGenerationModelDeclaration as u, GenerationValidationError as v };
|
|
128
|
-
//# sourceMappingURL=export-config-
|
|
128
|
+
//# sourceMappingURL=export-config-Bwqnn7Vs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-config-ZxwkQoZ6.js","names":["parseYaml","stringifyYaml"],"sources":["../src/errors.ts","../src/config.ts","../src/export-config.ts"],"sourcesContent":["export class GenerationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationError\";\n }\n}\n\nexport class GenerationConfigError extends GenerationError {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationConfigError\";\n }\n}\n\nexport class GenerationValidationError extends GenerationError {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationValidationError\";\n }\n}\n\nexport class GenerationUnsupportedAdapterError extends GenerationError {\n constructor(adapterType: string) {\n super(`Unsupported generation adapter: ${adapterType}`);\n this.name = \"GenerationUnsupportedAdapterError\";\n }\n}\n\nexport class GenerationProviderError extends GenerationError {\n readonly status: number | undefined;\n readonly body: string | undefined;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(\n message = \"Generation provider request failed\",\n options?: { status?: number; body?: string; details?: Record<string, unknown> },\n ) {\n super(message);\n this.name = \"GenerationProviderError\";\n this.status = options?.status;\n this.body = options?.body;\n this.details = options?.details;\n }\n}\n\nexport class GenerationTimeoutError extends GenerationProviderError {\n constructor(message = \"Generation request timed out\", details?: Record<string, unknown>) {\n super(message, details ? { details } : undefined);\n this.name = \"GenerationTimeoutError\";\n }\n}\n","import { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { extname, join } from \"node:path\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport { GenerationConfigError } from \"./errors.js\";\nimport { type GenerationModelDeclaration, MODEL_SCHEMA } from \"./types.js\";\nimport { cloneJson, slugifyFileName } from \"./utils.js\";\n\nconst DECLARATION_EXTENSIONS = new Set([\".yaml\", \".yml\", \".json\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isParameterSpec(value: unknown): boolean {\n if (!isRecord(value)) return false;\n return [\"string\", \"number\", \"integer\", \"boolean\"].includes(String(value.type));\n}\n\nexport function isGenerationModelDeclaration(value: unknown): value is GenerationModelDeclaration {\n if (!isRecord(value)) return false;\n const adapter = value.adapter;\n const content = value.content;\n const parameters = value.parameters;\n const examples = value.examples;\n return (\n value.schema === MODEL_SCHEMA &&\n typeof value.model === \"string\" &&\n value.model.trim().length > 0 &&\n isRecord(adapter) &&\n typeof adapter.type === \"string\" &&\n isRecord(content) &&\n Array.isArray(content.input) &&\n (parameters === undefined || (isRecord(parameters) && Object.values(parameters).every(isParameterSpec))) &&\n (examples === undefined || Array.isArray(examples))\n );\n}\n\nexport function parseGenerationModelDeclaration(rawText: string, filePath = \"model.yaml\"): GenerationModelDeclaration {\n const parsed = extname(filePath) === \".json\" ? JSON.parse(rawText) : parseYaml(rawText);\n if (!isGenerationModelDeclaration(parsed)) throw new GenerationConfigError(`Invalid model declaration: ${filePath}`);\n return parsed;\n}\n\nexport function stringifyGenerationModelDeclaration(\n declaration: GenerationModelDeclaration,\n options: { format?: \"yaml\" | \"json\" } = {},\n): string {\n const value = cloneJson(declaration);\n if (options.format === \"json\") return `${JSON.stringify(value, null, 2)}\\n`;\n return stringifyYaml(value, { lineWidth: 120 });\n}\n\nexport async function readGenerationModelDeclaration(filePath: string): Promise<GenerationModelDeclaration> {\n return parseGenerationModelDeclaration(await readFile(filePath, \"utf-8\"), filePath);\n}\n\nexport async function readGenerationModelDeclarationsFromFiles(\n filePaths: string[],\n): Promise<GenerationModelDeclaration[]> {\n const declarations = await Promise.all(filePaths.map((filePath) => readGenerationModelDeclaration(filePath)));\n return mergeGenerationModelDeclarations(declarations);\n}\n\nexport async function readGenerationModelDeclarationsFromDirectory(\n directory: string,\n): Promise<GenerationModelDeclaration[]> {\n const entries = await readdir(directory);\n const files = entries\n .filter((entry) => DECLARATION_EXTENSIONS.has(extname(entry)))\n .sort()\n .map((entry) => join(directory, entry));\n return readGenerationModelDeclarationsFromFiles(files);\n}\n\nexport function mergeGenerationModelDeclarations(\n declarations: GenerationModelDeclaration[],\n): GenerationModelDeclaration[] {\n const byModel = new Map<string, GenerationModelDeclaration>();\n for (const declaration of declarations) byModel.set(declaration.model, declaration);\n return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));\n}\n\nexport async function writeGenerationModelDeclaration(\n declaration: GenerationModelDeclaration,\n filePath: string,\n options: { format?: \"yaml\" | \"json\" } = {},\n): Promise<void> {\n await writeFile(filePath, stringifyGenerationModelDeclaration(declaration, options));\n}\n\nexport async function writeGenerationModelDeclarations(\n declarations: GenerationModelDeclaration[],\n directory: string,\n options: { format?: \"yaml\" | \"json\" } = {},\n): Promise<void> {\n await mkdir(directory, { recursive: true });\n const ext = options.format === \"json\" ? \"json\" : \"yaml\";\n await Promise.all(\n declarations.map((declaration) =>\n writeGenerationModelDeclaration(\n declaration,\n join(directory, `${slugifyFileName(declaration.model)}.${ext}`),\n options,\n ),\n ),\n );\n}\n","import { getBuiltinGenerationModel, listBuiltinGenerationModels } from \"./builtins.js\";\nimport {\n stringifyGenerationModelDeclaration,\n writeGenerationModelDeclaration,\n writeGenerationModelDeclarations,\n} from \"./config.js\";\nimport { GenerationConfigError } from \"./errors.js\";\n\nexport function stringifyBuiltinModelConfig(model: string, options: { format?: \"yaml\" | \"json\" } = {}): string {\n const declaration = getBuiltinGenerationModel(model);\n if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);\n return stringifyGenerationModelDeclaration(declaration, options);\n}\n\nexport async function exportBuiltinModelConfig(model: string, filePath: string): Promise<void> {\n const declaration = getBuiltinGenerationModel(model);\n if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);\n await writeGenerationModelDeclaration(declaration, filePath);\n}\n\nexport async function exportBuiltinModelConfigs(directory: string): Promise<void> {\n await writeGenerationModelD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AAc,SAAQ,IAAI,YAAY,OAAO,YAAY;AACnF,QAAO,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,MAAM,CAAC;;AAG7E,eAAsB,gCACpB,aACA,UACA,UAAwC,EAAE,EAC3B;AACf,OAAM,UAAU,UAAU,oCAAoC,aAAa,QAAQ,CAAC;;AAGtF,eAAsB,iCACpB,cACA,WACA,UAAwC,EAAE,EAC3B;AACf,OAAM,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;CAC3C,MAAM,MAAM,QAAQ,WAAW,SAAS,SAAS;AACjD,OAAM,QAAQ,IACZ,aAAa,KAAK,gBAChB,gCACE,aACA,KAAK,WAAW,GAAG,gBAAgB,YAAY,MAAM,CAAC,GAAG,MAAM,EAC/D,QACD,CACF,CACF;;;;;ACjGH,SAAgB,4BAA4B,OAAe,UAAwC,EAAE,EAAU;CAC7G,MAAM,cAAc,0BAA0B,MAAM;AACpD,KAAI,CAAC,YAAa,OAAM,IAAI,sBAAsB,kCAAkC,QAAQ;AAC5F,QAAO,oCAAoC,aAAa,QAAQ;;AAGlE,eAAsB,yBAAyB,OAAe,UAAiC;CAC7F,MAAM,cAAc,0BAA0B,MAAM;AACpD,KAAI,CAAC,YAAa,OAAM,IAAI,sBAAsB,kCAAkC,QAAQ;AAC5F,OAAM,gCAAgC,aAAa,SAAS;;AAG9D,eAAsB,0BAA0B,WAAkC;AAChF,OAAM,iCAAiC,6BAA6B,EAAE,UAAU"}
|
|
1
|
+
{"version":3,"file":"export-config-Bwqnn7Vs.js","names":["parseYaml","stringifyYaml"],"sources":["../src/errors.ts","../src/config.ts","../src/export-config.ts"],"sourcesContent":["export class GenerationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationError\";\n }\n}\n\nexport class GenerationConfigError extends GenerationError {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationConfigError\";\n }\n}\n\nexport class GenerationValidationError extends GenerationError {\n constructor(message: string) {\n super(message);\n this.name = \"GenerationValidationError\";\n }\n}\n\nexport class GenerationUnsupportedAdapterError extends GenerationError {\n constructor(adapterType: string) {\n super(`Unsupported generation adapter: ${adapterType}`);\n this.name = \"GenerationUnsupportedAdapterError\";\n }\n}\n\nexport class GenerationProviderError extends GenerationError {\n readonly status: number | undefined;\n readonly body: string | undefined;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(\n message = \"Generation provider request failed\",\n options?: { status?: number; body?: string; details?: Record<string, unknown> },\n ) {\n super(message);\n this.name = \"GenerationProviderError\";\n this.status = options?.status;\n this.body = options?.body;\n this.details = options?.details;\n }\n}\n\nexport class GenerationTimeoutError extends GenerationProviderError {\n constructor(message = \"Generation request timed out\", details?: Record<string, unknown>) {\n super(message, details ? { details } : undefined);\n this.name = \"GenerationTimeoutError\";\n }\n}\n","import { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { extname, join } from \"node:path\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport { GenerationConfigError } from \"./errors.js\";\nimport { type GenerationModelDeclaration, MODEL_SCHEMA } from \"./types.js\";\nimport { cloneJson, slugifyFileName } from \"./utils.js\";\n\nconst DECLARATION_EXTENSIONS = new Set([\".yaml\", \".yml\", \".json\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isParameterSpec(value: unknown): boolean {\n if (!isRecord(value)) return false;\n return [\"string\", \"number\", \"integer\", \"boolean\"].includes(String(value.type));\n}\n\nexport function isGenerationModelDeclaration(value: unknown): value is GenerationModelDeclaration {\n if (!isRecord(value)) return false;\n const adapter = value.adapter;\n const content = value.content;\n const parameters = value.parameters;\n const examples = value.examples;\n return (\n value.schema === MODEL_SCHEMA &&\n typeof value.model === \"string\" &&\n value.model.trim().length > 0 &&\n isRecord(adapter) &&\n typeof adapter.type === \"string\" &&\n isRecord(content) &&\n Array.isArray(content.input) &&\n (parameters === undefined || (isRecord(parameters) && Object.values(parameters).every(isParameterSpec))) &&\n (examples === undefined || Array.isArray(examples))\n );\n}\n\nexport function parseGenerationModelDeclaration(rawText: string, filePath = \"model.yaml\"): GenerationModelDeclaration {\n const parsed = extname(filePath) === \".json\" ? JSON.parse(rawText) : parseYaml(rawText);\n if (!isGenerationModelDeclaration(parsed)) throw new GenerationConfigError(`Invalid model declaration: ${filePath}`);\n return parsed;\n}\n\nexport function stringifyGenerationModelDeclaration(\n declaration: GenerationModelDeclaration,\n options: { format?: \"yaml\" | \"json\" } = {},\n): string {\n const value = cloneJson(declaration);\n if (options.format === \"json\") return `${JSON.stringify(value, null, 2)}\\n`;\n return stringifyYaml(value, { lineWidth: 120 });\n}\n\nexport async function readGenerationModelDeclaration(filePath: string): Promise<GenerationModelDeclaration> {\n return parseGenerationModelDeclaration(await readFile(filePath, \"utf-8\"), filePath);\n}\n\nexport async function readGenerationModelDeclarationsFromFiles(\n filePaths: string[],\n): Promise<GenerationModelDeclaration[]> {\n const declarations = await Promise.all(filePaths.map((filePath) => readGenerationModelDeclaration(filePath)));\n return mergeGenerationModelDeclarations(declarations);\n}\n\nexport async function readGenerationModelDeclarationsFromDirectory(\n directory: string,\n): Promise<GenerationModelDeclaration[]> {\n const entries = await readdir(directory);\n const files = entries\n .filter((entry) => DECLARATION_EXTENSIONS.has(extname(entry)))\n .sort()\n .map((entry) => join(directory, entry));\n return readGenerationModelDeclarationsFromFiles(files);\n}\n\nexport function mergeGenerationModelDeclarations(\n declarations: GenerationModelDeclaration[],\n): GenerationModelDeclaration[] {\n const byModel = new Map<string, GenerationModelDeclaration>();\n for (const declaration of declarations) byModel.set(declaration.model, declaration);\n return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));\n}\n\nexport async function writeGenerationModelDeclaration(\n declaration: GenerationModelDeclaration,\n filePath: string,\n options: { format?: \"yaml\" | \"json\" } = {},\n): Promise<void> {\n await writeFile(filePath, stringifyGenerationModelDeclaration(declaration, options));\n}\n\nexport async function writeGenerationModelDeclarations(\n declarations: GenerationModelDeclaration[],\n directory: string,\n options: { format?: \"yaml\" | \"json\" } = {},\n): Promise<void> {\n await mkdir(directory, { recursive: true });\n const ext = options.format === \"json\" ? \"json\" : \"yaml\";\n await Promise.all(\n declarations.map((declaration) =>\n writeGenerationModelDeclaration(\n declaration,\n join(directory, `${slugifyFileName(declaration.model)}.${ext}`),\n options,\n ),\n ),\n );\n}\n","import { getBuiltinGenerationModel, listBuiltinGenerationModels } from \"./builtins.js\";\nimport {\n stringifyGenerationModelDeclaration,\n writeGenerationModelDeclaration,\n writeGenerationModelDeclarations,\n} from \"./config.js\";\nimport { GenerationConfigError } from \"./errors.js\";\n\nexport function stringifyBuiltinModelConfig(model: string, options: { format?: \"yaml\" | \"json\" } = {}): string {\n const declaration = getBuiltinGenerationModel(model);\n if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);\n return stringifyGenerationModelDeclaration(declaration, options);\n}\n\nexport async function exportBuiltinModelConfig(model: string, filePath: string): Promise<void> {\n const declaration = getBuiltinGenerationModel(model);\n if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);\n await writeGenerationModelDeclaration(declaration, filePath);\n}\n\nexport async function exportBuiltinModelConfigs(directory: string): Promise<void> {\n await writeGenerationModelDeclarations(listBuiltinGenerationModels(), directory);\n}\n"],"mappings":";;;;;;AAAA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,wBAAb,cAA2C,gBAAgB;CACzD,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,4BAAb,cAA+C,gBAAgB;CAC7D,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,oCAAb,cAAuD,gBAAgB;CACrE,YAAY,aAAqB;AAC/B,QAAM,mCAAmC,cAAc;AACvD,OAAK,OAAO;;;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CACE,aACA,KAAK,WAAW,GAAG,gBAAgB,YAAY,MAAM,CAAC,GAAG,MAAM,EAC/D,QACD,CACF,CACF;;;;;ACjGH,SAAgB,4BAA4B,OAAe,UAAwC,EAAE,EAAU;CAC7G,MAAM,cAAc,0BAA0B,MAAM;AACpD,KAAI,CAAC,YAAa,OAAM,IAAI,sBAAsB,kCAAkC,QAAQ;AAC5F,QAAO,oCAAoC,aAAa,QAAQ;;AAGlE,eAAsB,yBAAyB,OAAe,UAAiC;CAC7F,MAAM,cAAc,0BAA0B,MAAM;AACpD,KAAI,CAAC,YAAa,OAAM,IAAI,sBAAsB,kCAAkC,QAAQ;AAC5F,OAAM,gCAAgC,aAAa,SAAS;;AAG9D,eAAsB,0BAA0B,WAAkC;AAChF,OAAM,iCAAiC,6BAA6B,EAAE,UAAU"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapters/ark-video-generations.ts","../src/adapters/gemini-generate-content.ts","../src/adapters/openai-images.ts","../src/adapters/index.ts","../src/client.ts","../src/config.ts","../src/errors.ts","../src/export-config.ts","../src/source.ts","../src/validation.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapters/ark-video-generations.ts","../src/adapters/gemini-generate-content.ts","../src/adapters/openai-images.ts","../src/adapters/index.ts","../src/client.ts","../src/config.ts","../src/errors.ts","../src/export-config.ts","../src/source.ts","../src/validation.ts"],"sourcesContent":[],"mappings":";;;iBA6LsB,0BAAA,QAAkC,yBAAyB,QAAQ;;;iBCrCnE,4BAAA,QAAoC,yBAAyB,QAAQ;;;iBC5GrE,mBAAA,QAA2B,yBAAyB,QAAQ;;;cCtCrE,2BAA2B,eAAe;iBAMvC,oBAAA,0BAEJ,eAAe,qBACxB;;;iBCea,sBAAA,WAAgC,gCAAqC;iBA2D/D,+BAAA,gCAEX,KAAK,2CACb,QAAQ;AJi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;;AAAyB,cM/KpE,yBAAA,SAAkC,eAAA,CN+KkC;EAAO,WAAA,CAAA,OAAA,EAAA,MAAA;;cMxK3E,iCAAA,SAA0C,eAAA;;ALmIvD;AAA0D,cK5H7C,uBAAA,SAAgC,eAAA,CL4Ha;EAAiC,SAAA,MAAA,EAAA,MAAA,GAAA,SAAA;EAAR,SAAA,IAAA,EAAA,MAAA,GAAA,SAAA;EAAO,SAAA,OAAA,EKzHtE,MLyHsE,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,SAAA;uCC5GzC;;;IAA3B,OAAA,CAAA,EIToC,MJSpC,CAAA,MAAmB,EAAA,OAAA,CAAA;EAAQ,CAAA;;AAAyB,cIC7D,sBAAA,SAA+B,uBAAA,CJD8B;EAAO,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EIEf,MJFe,CAAA,MAAA,EAAA,OAAA,CAAA;;;;iBKpCjE,2BAAA;;;APqLM,iBO/KA,wBAAA,CP+K0B,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EO/KiC,OP+KjC,CAAA,IAAA,CAAA;AAAQ,iBOzKlC,yBAAA,CPyKkC,SAAA,EAAA,MAAA,CAAA,EOzKY,OPyKZ,CAAA,IAAA,CAAA;;;cQ3L3C,iCAAiC;;;iBCO9B,yBAAA,cACD,qCACJ;iBA6BK,2BAAA,cACD,wCACD,sCACX;ATkJmB,iBSlGN,eAAA,CTkGgC,WAAA,ESlGH,0BTkGG,EAAA,OAAA,ESlGkC,sBTkGlC,EAAA,CAAA,EAAA,MAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { _ as GenerationUnsupportedAdapterError, a as mergeGenerationModelDeclarations, c as readGenerationModelDeclarationsFromDirectory, d as writeGenerationModelDeclaration, f as writeGenerationModelDeclarations, g as GenerationTimeoutError, h as GenerationProviderError, i as isGenerationModelDeclaration, l as readGenerationModelDeclarationsFromFiles, m as GenerationError, n as exportBuiltinModelConfigs, o as parseGenerationModelDeclaration, p as GenerationConfigError, r as stringifyBuiltinModelConfig, s as readGenerationModelDeclaration, t as exportBuiltinModelConfig, u as stringifyGenerationModelDeclaration, v as GenerationValidationError } from "./export-config-
|
|
1
|
+
import { a as compactArray, i as cloneJson, l as MODEL_SCHEMA, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels } from "./builtins-B1AheaEa.js";
|
|
2
|
+
import { _ as GenerationUnsupportedAdapterError, a as mergeGenerationModelDeclarations, c as readGenerationModelDeclarationsFromDirectory, d as writeGenerationModelDeclaration, f as writeGenerationModelDeclarations, g as GenerationTimeoutError, h as GenerationProviderError, i as isGenerationModelDeclaration, l as readGenerationModelDeclarationsFromFiles, m as GenerationError, n as exportBuiltinModelConfigs, o as parseGenerationModelDeclaration, p as GenerationConfigError, r as stringifyBuiltinModelConfig, s as readGenerationModelDeclaration, t as exportBuiltinModelConfig, u as stringifyGenerationModelDeclaration, v as GenerationValidationError } from "./export-config-Bwqnn7Vs.js";
|
|
3
3
|
|
|
4
4
|
//#region src/http.ts
|
|
5
5
|
async function fetchWithTimeout(fetchFn, url, init, timeoutMs) {
|
|
@@ -170,7 +170,7 @@ function buildMetadataContent(prompt, images, mode) {
|
|
|
170
170
|
}
|
|
171
171
|
function extractTaskId(response) {
|
|
172
172
|
const taskId = asString(response.task_id) ?? asString(response.id);
|
|
173
|
-
if (!taskId) throw new GenerationProviderError("Video generation provider did not return a task id");
|
|
173
|
+
if (!taskId) throw new GenerationProviderError("Video generation provider did not return a task id", { details: { response } });
|
|
174
174
|
return taskId;
|
|
175
175
|
}
|
|
176
176
|
function normalizeTaskStatus(response) {
|
|
@@ -280,7 +280,11 @@ async function arkVideoGenerationsAdapter(input) {
|
|
|
280
280
|
const rawStatus = await requestJson(input, `/v1/video/generations/${encodeURIComponent(taskId)}`, { method: "GET" });
|
|
281
281
|
const status = normalizeTaskStatus(rawStatus);
|
|
282
282
|
if (status.status === "succeeded") {
|
|
283
|
-
if (!status.videoUrl) throw new GenerationProviderError("Video generation succeeded but returned no video URL"
|
|
283
|
+
if (!status.videoUrl) throw new GenerationProviderError("Video generation succeeded but returned no video URL", { details: compactObject({
|
|
284
|
+
taskId,
|
|
285
|
+
rawStatus,
|
|
286
|
+
metadata: status.metadata
|
|
287
|
+
}) });
|
|
284
288
|
const output = [{
|
|
285
289
|
type: "video",
|
|
286
290
|
source: {
|
|
@@ -371,6 +375,30 @@ function extractMarkdownDataUriImage(text) {
|
|
|
371
375
|
}
|
|
372
376
|
};
|
|
373
377
|
}
|
|
378
|
+
function collectGeminiNoOutputDetails(raw) {
|
|
379
|
+
const candidates = raw.candidates ?? [];
|
|
380
|
+
return compactObject({
|
|
381
|
+
finishReasons: compactArray(candidates.map((candidate) => candidate.finishReason).filter((value) => value !== void 0)),
|
|
382
|
+
finishMessages: compactArray(candidates.map((candidate) => candidate.finishMessage).filter((value) => value !== void 0)),
|
|
383
|
+
safetyRatings: compactArray(candidates.flatMap((candidate) => candidate.safetyRatings ?? [])),
|
|
384
|
+
promptFeedback: raw.promptFeedback,
|
|
385
|
+
usageMetadata: raw.usageMetadata,
|
|
386
|
+
modelVersion: raw.modelVersion,
|
|
387
|
+
responseId: raw.responseId,
|
|
388
|
+
candidateCount: candidates.length,
|
|
389
|
+
candidates: compactArray(candidates.map((candidate) => compactObject({
|
|
390
|
+
index: candidate.index,
|
|
391
|
+
finishReason: candidate.finishReason,
|
|
392
|
+
finishMessage: candidate.finishMessage,
|
|
393
|
+
safetyRatings: candidate.safetyRatings,
|
|
394
|
+
citationMetadata: candidate.citationMetadata,
|
|
395
|
+
groundingMetadata: candidate.groundingMetadata,
|
|
396
|
+
avgLogprobs: candidate.avgLogprobs,
|
|
397
|
+
contentRole: candidate.content?.role,
|
|
398
|
+
partCount: candidate.content?.parts?.length
|
|
399
|
+
})))
|
|
400
|
+
});
|
|
401
|
+
}
|
|
374
402
|
function appendGeminiPartOutput(output, part) {
|
|
375
403
|
if (typeof part.text === "string" && part.text.trim()) {
|
|
376
404
|
const image = extractMarkdownDataUriImage(part.text);
|
|
@@ -442,13 +470,30 @@ async function geminiGenerateContentAdapter(input) {
|
|
|
442
470
|
const raw = await response.json();
|
|
443
471
|
const output = [];
|
|
444
472
|
for (const candidate of raw.candidates ?? []) for (const part of candidate.content?.parts ?? []) appendGeminiPartOutput(output, part);
|
|
445
|
-
if (output.length === 0) throw new GenerationProviderError("Gemini generation returned no output");
|
|
473
|
+
if (output.length === 0) throw new GenerationProviderError("Gemini generation returned no output", { details: collectGeminiNoOutputDetails(raw) });
|
|
446
474
|
return output;
|
|
447
475
|
}
|
|
448
476
|
|
|
449
477
|
//#endregion
|
|
450
478
|
//#region src/adapters/openai-images.ts
|
|
451
479
|
const REQUEST_TIMEOUT_MS = 3e5;
|
|
480
|
+
function collectOpenAiImagesNoOutputDetails(raw) {
|
|
481
|
+
const data = raw.data ?? [];
|
|
482
|
+
return compactObject({
|
|
483
|
+
created: raw.created,
|
|
484
|
+
usage: raw.usage,
|
|
485
|
+
background: raw.background,
|
|
486
|
+
outputFormat: raw.output_format,
|
|
487
|
+
quality: raw.quality,
|
|
488
|
+
size: raw.size,
|
|
489
|
+
dataCount: data.length,
|
|
490
|
+
data: compactArray(data.map((item) => compactObject({
|
|
491
|
+
hasUrl: typeof item.url === "string" && item.url.length > 0,
|
|
492
|
+
hasBase64Json: typeof item.b64_json === "string" && item.b64_json.length > 0,
|
|
493
|
+
revisedPrompt: item.revised_prompt
|
|
494
|
+
})))
|
|
495
|
+
});
|
|
496
|
+
}
|
|
452
497
|
async function openAiImagesAdapter(input) {
|
|
453
498
|
const prompt = mergeTextBlocks(input.declaration, input.request.content);
|
|
454
499
|
if (!prompt) throw new GenerationValidationError("Prompt text is required");
|
|
@@ -484,12 +529,21 @@ async function openAiImagesAdapter(input) {
|
|
|
484
529
|
url: item.url
|
|
485
530
|
}
|
|
486
531
|
});
|
|
532
|
+
if (typeof item.b64_json === "string" && item.b64_json) output.push({
|
|
533
|
+
type: "image",
|
|
534
|
+
source: {
|
|
535
|
+
type: "base64",
|
|
536
|
+
mediaType: "image/png",
|
|
537
|
+
data: item.b64_json
|
|
538
|
+
}
|
|
539
|
+
});
|
|
487
540
|
if (typeof item.revised_prompt === "string" && item.revised_prompt.trim()) output.push({
|
|
488
541
|
type: "text",
|
|
489
542
|
text: item.revised_prompt,
|
|
490
543
|
meta: { role: "revised_prompt" }
|
|
491
544
|
});
|
|
492
545
|
}
|
|
546
|
+
if (output.length === 0) throw new GenerationProviderError("Image generation returned no output", { details: collectOpenAiImagesNoOutputDetails(raw) });
|
|
493
547
|
return output;
|
|
494
548
|
}
|
|
495
549
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["resolved: Record<string, unknown>","REQUEST_TIMEOUT_MS","RESOLUTION_SHORT_EDGE: Record<string, number>","ASPECT_RATIOS: Record<string, [number, number] | null>","content: Array<Record<string, unknown>>","metadata: Record<string, unknown>","payload: Record<string, unknown>","output: GenerationContentBlock[]","REQUEST_TIMEOUT_MS","generationConfig: Record<string, unknown>","image: Record<string, string>","output: GenerationContentBlock[]","payload: Record<string, unknown>","output: GenerationContentBlock[]","builtinGenerationAdapters: Record<string, GenerationAdapter>","defaultGenerationSourceResolver: GenerationSourceResolver"],"sources":["../src/http.ts","../src/validation.ts","../src/adapters/ark-video-generations.ts","../src/adapters/gemini-generate-content.ts","../src/adapters/openai-images.ts","../src/adapters/index.ts","../src/source.ts","../src/client.ts"],"sourcesContent":["import { GenerationTimeoutError } from \"./errors.js\";\n\nexport async function fetchWithTimeout(\n fetchFn: typeof fetch,\n url: string,\n init: RequestInit,\n timeoutMs: number,\n): Promise<Response> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetchFn(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") throw new GenerationTimeoutError();\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n}\n\nexport function joinUrl(baseUrl: string, path: string): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${path.replace(/^\\/+/, \"\")}`;\n}\n","import { GenerationValidationError } from \"./errors.js\";\nimport type { GenerationContentBlock, GenerationContentSpec, GenerationModelDeclaration } from \"./types.js\";\n\nfunction specsByType(specs: GenerationContentSpec[]) {\n const map = new Map<GenerationContentSpec[\"type\"], GenerationContentSpec>();\n for (const spec of specs) map.set(spec.type, spec);\n return map;\n}\n\nexport function validateGenerationContent(\n declaration: GenerationModelDeclaration,\n content: GenerationContentBlock[],\n): void {\n const inputSpecs = specsByType(declaration.content.input);\n const counts = new Map<GenerationContentSpec[\"type\"], number>();\n\n for (const block of content) {\n const spec = inputSpecs.get(block.type);\n if (!spec)\n throw new GenerationValidationError(`Content block type is not supported by ${declaration.model}: ${block.type}`);\n counts.set(block.type, (counts.get(block.type) ?? 0) + 1);\n\n if (\"source\" in block && spec.sources && !spec.sources.includes(block.source.type)) {\n throw new GenerationValidationError(\n `${block.type} source is not supported by ${declaration.model}: ${block.source.type}`,\n );\n }\n }\n\n for (const spec of declaration.content.input) {\n const count = counts.get(spec.type) ?? 0;\n if (spec.required && count === 0)\n throw new GenerationValidationError(`Missing required ${spec.type} content block`);\n if (spec.min !== undefined && count < spec.min)\n throw new GenerationValidationError(`Expected at least ${spec.min} ${spec.type} content block(s)`);\n if (spec.max !== undefined && count > spec.max)\n throw new GenerationValidationError(`Expected at most ${spec.max} ${spec.type} content block(s)`);\n }\n}\n\nexport function resolveGenerationParameters(\n declaration: GenerationModelDeclaration,\n parameters: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n const specs = declaration.parameters ?? {};\n const resolved: Record<string, unknown> = {};\n\n for (const key of Object.keys(parameters ?? {})) {\n if (!specs[key]) throw new GenerationValidationError(`Unknown parameter: ${key}`);\n }\n\n for (const [key, spec] of Object.entries(specs)) {\n const value = parameters?.[key];\n if (value === undefined) {\n if (spec.default !== undefined) resolved[key] = spec.default;\n else if (!spec.optional) throw new GenerationValidationError(`Missing required parameter: ${key}`);\n continue;\n }\n\n switch (spec.type) {\n case \"string\":\n if (typeof value !== \"string\") throw new GenerationValidationError(`Parameter ${key} must be a string`);\n if (spec.enum && !spec.enum.includes(value))\n throw new GenerationValidationError(`Parameter ${key} must be one of: ${spec.enum.join(\", \")}`);\n break;\n case \"number\":\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new GenerationValidationError(`Parameter ${key} must be a number`);\n if (spec.min !== undefined && value < spec.min)\n throw new GenerationValidationError(`Parameter ${key} must be >= ${spec.min}`);\n if (spec.max !== undefined && value > spec.max)\n throw new GenerationValidationError(`Parameter ${key} must be <= ${spec.max}`);\n break;\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value))\n throw new GenerationValidationError(`Parameter ${key} must be an integer`);\n if (spec.min !== undefined && value < spec.min)\n throw new GenerationValidationError(`Parameter ${key} must be >= ${spec.min}`);\n if (spec.max !== undefined && value > spec.max)\n throw new GenerationValidationError(`Parameter ${key} must be <= ${spec.max}`);\n break;\n case \"boolean\":\n if (typeof value !== \"boolean\") throw new GenerationValidationError(`Parameter ${key} must be a boolean`);\n break;\n }\n resolved[key] = value;\n }\n\n return resolved;\n}\n\nexport function mergeTextBlocks(declaration: GenerationModelDeclaration, content: GenerationContentBlock[]): string {\n const textSpec = declaration.content.input.find((spec) => spec.type === \"text\");\n const separator = textSpec?.merge === \"space\" ? \" \" : textSpec?.merge === \"concat\" ? \"\" : \"\\n\";\n return content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"text\" }> => block.type === \"text\")\n .map((block) => block.text)\n .join(separator)\n .trim();\n}\n","import { GenerationProviderError, GenerationTimeoutError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { getBlockMeta } from \"../utils.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 60_000;\nconst DEFAULT_POLL_INTERVAL_SEC = 2;\nconst DEFAULT_MAX_WAIT_SEC = 600;\n\nconst RESOLUTION_SHORT_EDGE: Record<string, number> = {\n \"480p\": 480,\n \"720p\": 720,\n \"1080p\": 1080,\n \"2K\": 1440,\n};\n\nconst ASPECT_RATIOS: Record<string, [number, number] | null> = {\n \"16:9\": [16, 9],\n \"9:16\": [9, 16],\n \"1:1\": [1, 1],\n \"4:3\": [4, 3],\n \"3:2\": [3, 2],\n \"2:3\": [2, 3],\n \"3:4\": [3, 4],\n \"21:9\": [21, 9],\n adaptive: null,\n};\n\ntype ArkCreateTaskResponse = { id?: unknown; task_id?: unknown; status?: unknown };\n\ntype ArkTaskStatusResponse = {\n data?: {\n task_id?: unknown;\n status?: unknown;\n result_url?: unknown;\n progress?: unknown;\n data?: {\n status?: unknown;\n content?: { video_url?: unknown; last_frame_url?: unknown };\n resolution?: unknown;\n ratio?: unknown;\n duration?: unknown;\n framespersecond?: unknown;\n seed?: unknown;\n generate_audio?: unknown;\n model?: unknown;\n usage?: unknown;\n };\n };\n status?: unknown;\n url?: unknown;\n last_frame_url?: unknown;\n metadata?: unknown;\n};\n\ntype ImageMode = \"image\" | \"frame\" | \"reference\";\ntype ResolvedImage = { url: string; role: string | undefined };\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === \"string\" && value ? value : undefined;\n}\n\nfunction asNumber(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\nfunction asBoolean(value: unknown): boolean | undefined {\n return typeof value === \"boolean\" ? value : undefined;\n}\n\nfunction getIntegerParameter(parameters: Record<string, unknown>, key: string, fallback: number): number {\n const value = parameters[key];\n return typeof value === \"number\" && Number.isInteger(value) ? value : fallback;\n}\n\nfunction resolveSize(resolution: string, aspectRatio: string): { width: number; height: number } | null {\n const ratio = ASPECT_RATIOS[aspectRatio];\n if (!ratio) return null;\n\n const shortEdge = RESOLUTION_SHORT_EDGE[resolution];\n if (!shortEdge) throw new GenerationValidationError(`Unsupported resolution: ${resolution}`);\n\n const [wRatio, hRatio] = ratio;\n const width = wRatio >= hRatio ? Math.round((shortEdge * wRatio) / hRatio) : shortEdge;\n const height = wRatio >= hRatio ? shortEdge : Math.round((shortEdge * hRatio) / wRatio);\n return { width: width % 2 === 0 ? width : width + 1, height: height % 2 === 0 ? height : height + 1 };\n}\n\nfunction getImageRole(block: Extract<GenerationContentBlock, { type: \"image\" }>): string | undefined {\n const role = getBlockMeta(block)?.role;\n return typeof role === \"string\" && role ? role : undefined;\n}\n\nfunction classifyImages(images: ResolvedImage[]): ImageMode | null {\n if (images.length === 0) return null;\n const hasFirstOrLast = images.some((image) => image.role === \"first_frame\" || image.role === \"last_frame\");\n const hasReference = images.some((image) => image.role === \"reference_image\");\n const hasPlain = images.some((image) => !image.role);\n const modes = [hasPlain, hasFirstOrLast, hasReference].filter(Boolean).length;\n if (modes > 1)\n throw new GenerationValidationError(\n \"Cannot mix video image modes: use only plain image, first_frame/last_frame, or reference_image\",\n );\n if (hasReference) return \"reference\";\n if (hasFirstOrLast) return \"frame\";\n return \"image\";\n}\n\nfunction buildMetadataContent(prompt: string, images: ResolvedImage[], mode: Exclude<ImageMode, \"image\">) {\n const content: Array<Record<string, unknown>> = [{ type: \"text\", text: prompt }];\n for (const image of images) {\n if (mode === \"frame\" && image.role !== \"first_frame\" && image.role !== \"last_frame\") {\n throw new GenerationValidationError(\"Frame mode images must use meta.role first_frame or last_frame\");\n }\n if (mode === \"reference\" && image.role !== \"reference_image\") {\n throw new GenerationValidationError(\"Reference mode images must use meta.role reference_image\");\n }\n content.push({ type: \"image_url\", image_url: { url: image.url }, role: image.role });\n }\n return content;\n}\n\nfunction extractTaskId(response: ArkCreateTaskResponse): string {\n const taskId = asString(response.task_id) ?? asString(response.id);\n if (!taskId) throw new GenerationProviderError(\"Video generation provider did not return a task id\");\n return taskId;\n}\n\nfunction normalizeTaskStatus(response: ArkTaskStatusResponse) {\n if (response.data) {\n const wrapper = response.data;\n const native = wrapper.data;\n const status = (asString(native?.status) ?? asString(wrapper.status) ?? \"unknown\").toLowerCase();\n const videoUrl = asString(wrapper.result_url) ?? asString(native?.content?.video_url);\n const lastFrameUrl = asString(native?.content?.last_frame_url);\n const metadata: Record<string, unknown> = {\n progress: wrapper.progress,\n resolution: native?.resolution,\n ratio: native?.ratio,\n duration: native?.duration,\n framespersecond: native?.framespersecond,\n seed: native?.seed,\n generate_audio: native?.generate_audio,\n model: native?.model,\n usage: native?.usage,\n };\n for (const key of Object.keys(metadata)) if (metadata[key] === undefined) delete metadata[key];\n return { status, videoUrl, lastFrameUrl, metadata };\n }\n return {\n status: (asString(response.status) ?? \"unknown\").toLowerCase(),\n videoUrl: asString(response.url),\n lastFrameUrl: asString(response.last_frame_url),\n metadata:\n response.metadata && typeof response.metadata === \"object\" ? (response.metadata as Record<string, unknown>) : {},\n };\n}\n\nasync function requestJson(input: GenerationAdapterInput, path: string, init: RequestInit): Promise<unknown> {\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, path),\n {\n ...init,\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...init.headers,\n },\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Video generation provider request failed\", { status: response.status, body });\n }\n return response.json();\n}\n\nexport async function arkVideoGenerationsAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const imageBlocks = input.request.content.filter(\n (block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\",\n );\n const images = await Promise.all(\n imageBlocks.map(async (block) => ({\n url: await input.context.resolveSource(block.source),\n role: getImageRole(block),\n })),\n );\n\n const mode = classifyImages(images);\n const resolution = asString(input.parameters.resolution) ?? \"720p\";\n const aspectRatio = asString(input.parameters.aspect_ratio) ?? \"16:9\";\n const duration = getIntegerParameter(input.parameters, \"duration\", 5);\n const fps = getIntegerParameter(input.parameters, \"fps\", 30);\n const pollIntervalSec = getIntegerParameter(input.parameters, \"poll_interval\", DEFAULT_POLL_INTERVAL_SEC);\n const maxWaitSec = getIntegerParameter(input.parameters, \"max_wait\", DEFAULT_MAX_WAIT_SEC);\n const generateAudio = asBoolean(input.parameters.generate_audio) ?? true;\n const returnLastFrame = asBoolean(input.parameters.return_last_frame) ?? true;\n const cameraFixed = asBoolean(input.parameters.camera_fixed) ?? false;\n const watermark = asBoolean(input.parameters.watermark) ?? false;\n const seed = asNumber(input.parameters.seed);\n\n const payload: Record<string, unknown> = { model: input.declaration.model, prompt };\n const metadata: Record<string, unknown> = { duration, fps, generate_audio: generateAudio };\n if (seed !== undefined) metadata.seed = seed;\n if (returnLastFrame) metadata.return_last_frame = true;\n if (cameraFixed) metadata.camera_fixed = true;\n if (watermark) metadata.watermark = true;\n\n if (mode === \"frame\" || mode === \"reference\") {\n metadata.content = buildMetadataContent(prompt, images, mode);\n metadata.resolution = resolution;\n metadata.ratio = aspectRatio;\n } else {\n const size = resolveSize(resolution, aspectRatio);\n if (size) {\n payload.width = size.width;\n payload.height = size.height;\n }\n if (images[0]) payload.image = images[0].url;\n }\n payload.metadata = metadata;\n\n const task = (await requestJson(input, \"/v1/video/generations\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n })) as ArkCreateTaskResponse;\n const taskId = extractTaskId(task);\n const startedAt = Date.now();\n\n while (Date.now() - startedAt <= maxWaitSec * 1000) {\n await sleep(pollIntervalSec * 1000);\n const rawStatus = (await requestJson(input, `/v1/video/generations/${encodeURIComponent(taskId)}`, {\n method: \"GET\",\n })) as ArkTaskStatusResponse;\n const status = normalizeTaskStatus(rawStatus);\n\n if (status.status === \"succeeded\") {\n if (!status.videoUrl) throw new GenerationProviderError(\"Video generation succeeded but returned no video URL\");\n const output: GenerationContentBlock[] = [\n {\n type: \"video\",\n source: { type: \"url\", url: status.videoUrl },\n meta: { task_id: taskId, status: status.status, ...status.metadata },\n },\n ];\n if (status.lastFrameUrl)\n output.push({\n type: \"image\",\n source: { type: \"url\", url: status.lastFrameUrl },\n meta: { role: \"last_frame\", task_id: taskId },\n });\n return output;\n }\n\n if ([\"failed\", \"expired\", \"cancelled\"].includes(status.status)) {\n throw new GenerationProviderError(`Video generation ${status.status}`, { details: { taskId, rawStatus } });\n }\n }\n\n throw new GenerationTimeoutError(\"Timed out waiting for video generation\", { taskId });\n}\n","import { GenerationProviderError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 300_000;\nconst IMAGE_FETCH_TIMEOUT_MS = 60_000;\nconst MAX_REFERENCE_IMAGE_BYTES = 10 * 1024 * 1024;\n\nconst DATA_URI_PATTERN = /^data:([^;]+);base64,(.+)$/s;\nconst MARKDOWN_IMAGE_DATA_URI_PATTERN = /!\\[[^\\]]*\\]\\(data:([^;]+);base64,([^)]+)\\)/;\n\ntype GeminiPart = { text: string } | { inlineData: { mimeType: string; data: string } };\n\ntype GeminiResponsePart = {\n text?: unknown;\n inlineData?: { mimeType?: unknown; data?: unknown };\n inline_data?: { mime_type?: unknown; mimeType?: unknown; data?: unknown };\n};\n\ntype GeminiGenerateContentResponse = {\n candidates?: Array<{ content?: { parts?: GeminiResponsePart[] } }>;\n};\n\nfunction dataUriToInlineData(value: string): GeminiPart | null {\n const match = DATA_URI_PATTERN.exec(value);\n if (!match) return null;\n const [, mimeType, data] = match;\n if (!mimeType || !data) return null;\n return { inlineData: { mimeType, data } };\n}\n\nasync function urlToInlineData(fetchFn: typeof fetch, url: string): Promise<GeminiPart> {\n const response = await fetchWithTimeout(\n fetchFn,\n url,\n { method: \"GET\", headers: { \"User-Agent\": \"NetaGeneration/1.0\" } },\n IMAGE_FETCH_TIMEOUT_MS,\n );\n if (!response.ok) throw new GenerationProviderError(\"Failed to fetch reference image\", { status: response.status });\n\n const contentLength = response.headers.get(\"content-length\");\n if (contentLength && Number(contentLength) > MAX_REFERENCE_IMAGE_BYTES) {\n throw new GenerationValidationError(\"Reference image is too large\");\n }\n\n const bytes = Buffer.from(await response.arrayBuffer());\n if (bytes.byteLength > MAX_REFERENCE_IMAGE_BYTES) throw new GenerationValidationError(\"Reference image is too large\");\n\n const contentType = response.headers.get(\"content-type\")?.split(\";\")[0]?.trim();\n const mimeType = contentType?.startsWith(\"image/\") ? contentType : \"image/png\";\n return { inlineData: { mimeType, data: bytes.toString(\"base64\") } };\n}\n\nasync function sourceToInlineData(input: GenerationAdapterInput, value: string): Promise<GeminiPart> {\n const inline = dataUriToInlineData(value);\n if (inline) return inline;\n if (value.startsWith(\"http://\") || value.startsWith(\"https://\")) return urlToInlineData(input.context.fetch, value);\n throw new GenerationValidationError(\"Unsupported image source for Gemini image generation\");\n}\n\nfunction extractMarkdownDataUriImage(text: string): GenerationContentBlock | null {\n const match = MARKDOWN_IMAGE_DATA_URI_PATTERN.exec(text);\n if (!match) return null;\n const [, mediaType, data] = match;\n if (!mediaType || !data) return null;\n return { type: \"image\", source: { type: \"base64\", mediaType, data } };\n}\n\nfunction appendGeminiPartOutput(output: GenerationContentBlock[], part: GeminiResponsePart): void {\n if (typeof part.text === \"string\" && part.text.trim()) {\n const image = extractMarkdownDataUriImage(part.text);\n if (image) {\n output.push(image);\n return;\n }\n output.push({ type: \"text\", text: part.text });\n return;\n }\n\n if (part.inlineData && typeof part.inlineData.data === \"string\" && part.inlineData.data) {\n output.push({\n type: \"image\",\n source: {\n type: \"base64\",\n mediaType: typeof part.inlineData.mimeType === \"string\" ? part.inlineData.mimeType : \"image/png\",\n data: part.inlineData.data,\n },\n });\n return;\n }\n\n const inline = part.inline_data;\n if (!inline || typeof inline.data !== \"string\" || !inline.data) return;\n const mediaType =\n typeof inline.mime_type === \"string\"\n ? inline.mime_type\n : typeof inline.mimeType === \"string\"\n ? inline.mimeType\n : \"image/png\";\n output.push({ type: \"image\", source: { type: \"base64\", mediaType, data: inline.data } });\n}\n\nexport async function geminiGenerateContentAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const imageParts = await Promise.all(\n input.request.content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\")\n .map(async (block) => sourceToInlineData(input, await input.context.resolveSource(block.source))),\n );\n\n const generationConfig: Record<string, unknown> = { responseModalities: [\"IMAGE\"] };\n const aspectRatio = input.parameters.aspect_ratio;\n const imageSize = input.parameters.image_size;\n if (typeof aspectRatio === \"string\" || typeof imageSize === \"string\") {\n const image: Record<string, string> = {};\n if (typeof aspectRatio === \"string\") image.aspectRatio = aspectRatio;\n if (typeof imageSize === \"string\") image.imageSize = imageSize;\n generationConfig.responseFormat = { image };\n }\n\n const payload = {\n contents: [{ parts: [{ text: prompt }, ...imageParts] satisfies GeminiPart[] }],\n generationConfig,\n };\n\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, `/v1beta/models/${encodeURIComponent(input.declaration.model)}:generateContent`),\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Gemini generation provider request failed\", { status: response.status, body });\n }\n\n const raw = (await response.json()) as GeminiGenerateContentResponse;\n const output: GenerationContentBlock[] = [];\n for (const candidate of raw.candidates ?? []) {\n for (const part of candidate.content?.parts ?? []) appendGeminiPartOutput(output, part);\n }\n if (output.length === 0) throw new GenerationProviderError(\"Gemini generation returned no output\");\n return output;\n}\n","import { GenerationProviderError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 300_000;\n\ntype OpenAiImagesResponse = {\n data?: Array<{\n url?: unknown;\n revised_prompt?: unknown;\n }>;\n};\n\nexport async function openAiImagesAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const images = await Promise.all(\n input.request.content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\")\n .map((block) => input.context.resolveSource(block.source)),\n );\n\n const payload: Record<string, unknown> = {\n model: input.declaration.model,\n prompt,\n ...input.parameters,\n };\n if (images.length > 0) payload.image = images;\n\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, \"/v1/images/generations\"),\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Image generation provider request failed\", { status: response.status, body });\n }\n\n const raw = (await response.json()) as OpenAiImagesResponse;\n const output: GenerationContentBlock[] = [];\n for (const item of raw.data ?? []) {\n if (typeof item.url === \"string\" && item.url) {\n output.push({ type: \"image\", source: { type: \"url\", url: item.url } });\n }\n if (typeof item.revised_prompt === \"string\" && item.revised_prompt.trim()) {\n output.push({ type: \"text\", text: item.revised_prompt, meta: { role: \"revised_prompt\" } });\n }\n }\n return output;\n}\n","import { GenerationUnsupportedAdapterError } from \"../errors.js\";\nimport type { GenerationAdapter } from \"../types.js\";\nimport { arkVideoGenerationsAdapter } from \"./ark-video-generations.js\";\nimport { geminiGenerateContentAdapter } from \"./gemini-generate-content.js\";\nimport { openAiImagesAdapter } from \"./openai-images.js\";\n\nexport const builtinGenerationAdapters: Record<string, GenerationAdapter> = {\n \"ark.videoGenerations\": arkVideoGenerationsAdapter,\n \"gemini.generateContent\": geminiGenerateContentAdapter,\n \"openai.images\": openAiImagesAdapter,\n};\n\nexport function getGenerationAdapter(\n type: string,\n adapters: Record<string, GenerationAdapter> = {},\n): GenerationAdapter {\n const adapter = adapters[type] ?? builtinGenerationAdapters[type];\n if (!adapter) throw new GenerationUnsupportedAdapterError(type);\n return adapter;\n}\n\nexport * from \"./ark-video-generations.js\";\nexport * from \"./gemini-generate-content.js\";\nexport * from \"./openai-images.js\";\n","import type { GenerationSource, GenerationSourceResolver } from \"./types.js\";\n\nexport const defaultGenerationSourceResolver: GenerationSourceResolver = (source: GenerationSource) => {\n switch (source.type) {\n case \"url\":\n return source.url;\n case \"base64\":\n return `data:${source.mediaType};base64,${source.data}`;\n }\n};\n","import { getGenerationAdapter } from \"./adapters/index.js\";\nimport { builtinGenerationModels } from \"./builtins.js\";\nimport {\n readGenerationModelDeclarationsFromDirectory,\n readGenerationModelDeclarationsFromFiles,\n stringifyGenerationModelDeclaration,\n writeGenerationModelDeclaration,\n writeGenerationModelDeclarations,\n} from \"./config.js\";\nimport { GenerationConfigError } from \"./errors.js\";\nimport { defaultGenerationSourceResolver } from \"./source.js\";\nimport type {\n CreateGenerationClientOptions,\n GenerateRequest,\n GenerationClient,\n GenerationModelDeclaration,\n} from \"./types.js\";\nimport { cloneJson } from \"./utils.js\";\nimport { resolveGenerationParameters, validateGenerationContent } from \"./validation.js\";\n\nconst DEFAULT_BASE_URL = \"https://router.neta.art\";\n\nfunction resolveModels(options: CreateGenerationClientOptions): GenerationModelDeclaration[] {\n const includeBuiltinModels = options.includeBuiltinModels ?? !options.models;\n const models = [...(includeBuiltinModels ? builtinGenerationModels : []), ...(options.models ?? [])];\n const byModel = new Map<string, GenerationModelDeclaration>();\n for (const model of models) byModel.set(model.model, cloneJson(model));\n return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));\n}\n\nexport function createGenerationClient(options: CreateGenerationClientOptions = {}): GenerationClient {\n const models = resolveModels(options);\n const byModel = new Map(models.map((declaration) => [declaration.model, declaration]));\n const fetchFn = options.fetch ?? globalThis.fetch;\n if (!fetchFn) throw new GenerationConfigError(\"A fetch implementation is required\");\n\n function requireModel(model: string): GenerationModelDeclaration {\n const declaration = byModel.get(model);\n if (!declaration) throw new GenerationConfigError(`Generation model is unavailable: ${model}`);\n return declaration;\n }\n\n return {\n validate(request: GenerateRequest) {\n const declaration = requireModel(request.model);\n validateGenerationContent(declaration, request.content);\n const parameters = resolveGenerationParameters(declaration, request.parameters);\n return { declaration: cloneJson(declaration), request: cloneJson(request), parameters };\n },\n\n async generate(request: GenerateRequest) {\n const resolved = this.validate(request);\n const apiKey = request.apiKey ?? options.apiKey;\n if (!apiKey) throw new GenerationConfigError(\"apiKey is required\");\n const adapter = getGenerationAdapter(resolved.declaration.adapter.type, options.adapters);\n return adapter({\n ...resolved,\n context: {\n apiKey,\n baseUrl: request.baseUrl ?? options.baseUrl ?? DEFAULT_BASE_URL,\n fetch: fetchFn,\n resolveSource: options.sourceResolver ?? defaultGenerationSourceResolver,\n },\n });\n },\n\n listModels() {\n return cloneJson(models);\n },\n\n getModel(model: string) {\n const declaration = byModel.get(model);\n return declaration ? cloneJson(declaration) : null;\n },\n\n stringifyModelConfig(model: string, stringifyOptions = {}) {\n return stringifyGenerationModelDeclaration(requireModel(model), stringifyOptions);\n },\n\n exportModelConfig(model: string, filePath: string) {\n return writeGenerationModelDeclaration(requireModel(model), filePath);\n },\n\n exportModelConfigs(directory: string) {\n return writeGenerationModelDeclarations(models, directory);\n },\n };\n}\n\nexport async function createGenerationClientFromFiles(\n filePaths: string[],\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n const models = await readGenerationModelDeclarationsFromFiles(filePaths);\n return createGenerationClient({ ...options, models, includeBuiltinModels: options.includeBuiltinModels ?? true });\n}\n\nexport async function createGenerationClientFromDirectory(\n directory: string,\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n const models = await readGenerationModelDeclarationsFromDirectory(directory);\n return createGenerationClient({ ...options, models, includeBuiltinModels: options.includeBuiltinModels ?? true });\n}\n\nexport async function createGenerationClientFromFile(\n filePath: string,\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n return createGenerationClientFromFiles([filePath], options);\n}\n"],"mappings":";;;;AAEA,eAAsB,iBACpB,SACA,KACA,MACA,WACmB;CACnB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,UAAU,iBAAiB,WAAW,OAAO,EAAE,UAAU;AAC/D,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK;GAAE,GAAG;GAAM,QAAQ,WAAW;GAAQ,CAAC;UAC1D,OAAO;AACd,MAAI,iBAAiB,SAAS,MAAM,SAAS,aAAc,OAAM,IAAI,wBAAwB;AAC7F,QAAM;WACE;AACR,eAAa,QAAQ;;;AAIzB,SAAgB,QAAQ,SAAiB,MAAsB;AAC7D,QAAO,GAAG,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GAAG,KAAK,QAAQ,QAAQ,GAAG;;;;;AClBnE,SAAS,YAAY,OAAgC;CACnD,MAAM,sBAAM,IAAI,KAA2D;AAC3E,MAAK,MAAM,QAAQ,MAAO,KAAI,IAAI,KAAK,MAAM,KAAK;AAClD,QAAO;;AAGT,SAAgB,0BACd,aACA,SACM;CACN,MAAM,aAAa,YAAY,YAAY,QAAQ,MAAM;CACzD,MAAM,yBAAS,IAAI,KAA4C;AAE/D,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,WAAW,IAAI,MAAM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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolved: Record<string, unknown>","REQUEST_TIMEOUT_MS","RESOLUTION_SHORT_EDGE: Record<string, number>","ASPECT_RATIOS: Record<string, [number, number] | null>","content: Array<Record<string, unknown>>","metadata: Record<string, unknown>","payload: Record<string, unknown>","output: GenerationContentBlock[]","REQUEST_TIMEOUT_MS","generationConfig: Record<string, unknown>","image: Record<string, string>","output: GenerationContentBlock[]","payload: Record<string, unknown>","output: GenerationContentBlock[]","builtinGenerationAdapters: Record<string, GenerationAdapter>","defaultGenerationSourceResolver: GenerationSourceResolver"],"sources":["../src/http.ts","../src/validation.ts","../src/adapters/ark-video-generations.ts","../src/adapters/gemini-generate-content.ts","../src/adapters/openai-images.ts","../src/adapters/index.ts","../src/source.ts","../src/client.ts"],"sourcesContent":["import { GenerationTimeoutError } from \"./errors.js\";\n\nexport async function fetchWithTimeout(\n fetchFn: typeof fetch,\n url: string,\n init: RequestInit,\n timeoutMs: number,\n): Promise<Response> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetchFn(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") throw new GenerationTimeoutError();\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n}\n\nexport function joinUrl(baseUrl: string, path: string): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${path.replace(/^\\/+/, \"\")}`;\n}\n","import { GenerationValidationError } from \"./errors.js\";\nimport type { GenerationContentBlock, GenerationContentSpec, GenerationModelDeclaration } from \"./types.js\";\n\nfunction specsByType(specs: GenerationContentSpec[]) {\n const map = new Map<GenerationContentSpec[\"type\"], GenerationContentSpec>();\n for (const spec of specs) map.set(spec.type, spec);\n return map;\n}\n\nexport function validateGenerationContent(\n declaration: GenerationModelDeclaration,\n content: GenerationContentBlock[],\n): void {\n const inputSpecs = specsByType(declaration.content.input);\n const counts = new Map<GenerationContentSpec[\"type\"], number>();\n\n for (const block of content) {\n const spec = inputSpecs.get(block.type);\n if (!spec)\n throw new GenerationValidationError(`Content block type is not supported by ${declaration.model}: ${block.type}`);\n counts.set(block.type, (counts.get(block.type) ?? 0) + 1);\n\n if (\"source\" in block && spec.sources && !spec.sources.includes(block.source.type)) {\n throw new GenerationValidationError(\n `${block.type} source is not supported by ${declaration.model}: ${block.source.type}`,\n );\n }\n }\n\n for (const spec of declaration.content.input) {\n const count = counts.get(spec.type) ?? 0;\n if (spec.required && count === 0)\n throw new GenerationValidationError(`Missing required ${spec.type} content block`);\n if (spec.min !== undefined && count < spec.min)\n throw new GenerationValidationError(`Expected at least ${spec.min} ${spec.type} content block(s)`);\n if (spec.max !== undefined && count > spec.max)\n throw new GenerationValidationError(`Expected at most ${spec.max} ${spec.type} content block(s)`);\n }\n}\n\nexport function resolveGenerationParameters(\n declaration: GenerationModelDeclaration,\n parameters: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n const specs = declaration.parameters ?? {};\n const resolved: Record<string, unknown> = {};\n\n for (const key of Object.keys(parameters ?? {})) {\n if (!specs[key]) throw new GenerationValidationError(`Unknown parameter: ${key}`);\n }\n\n for (const [key, spec] of Object.entries(specs)) {\n const value = parameters?.[key];\n if (value === undefined) {\n if (spec.default !== undefined) resolved[key] = spec.default;\n else if (!spec.optional) throw new GenerationValidationError(`Missing required parameter: ${key}`);\n continue;\n }\n\n switch (spec.type) {\n case \"string\":\n if (typeof value !== \"string\") throw new GenerationValidationError(`Parameter ${key} must be a string`);\n if (spec.enum && !spec.enum.includes(value))\n throw new GenerationValidationError(`Parameter ${key} must be one of: ${spec.enum.join(\", \")}`);\n break;\n case \"number\":\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new GenerationValidationError(`Parameter ${key} must be a number`);\n if (spec.min !== undefined && value < spec.min)\n throw new GenerationValidationError(`Parameter ${key} must be >= ${spec.min}`);\n if (spec.max !== undefined && value > spec.max)\n throw new GenerationValidationError(`Parameter ${key} must be <= ${spec.max}`);\n break;\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value))\n throw new GenerationValidationError(`Parameter ${key} must be an integer`);\n if (spec.min !== undefined && value < spec.min)\n throw new GenerationValidationError(`Parameter ${key} must be >= ${spec.min}`);\n if (spec.max !== undefined && value > spec.max)\n throw new GenerationValidationError(`Parameter ${key} must be <= ${spec.max}`);\n break;\n case \"boolean\":\n if (typeof value !== \"boolean\") throw new GenerationValidationError(`Parameter ${key} must be a boolean`);\n break;\n }\n resolved[key] = value;\n }\n\n return resolved;\n}\n\nexport function mergeTextBlocks(declaration: GenerationModelDeclaration, content: GenerationContentBlock[]): string {\n const textSpec = declaration.content.input.find((spec) => spec.type === \"text\");\n const separator = textSpec?.merge === \"space\" ? \" \" : textSpec?.merge === \"concat\" ? \"\" : \"\\n\";\n return content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"text\" }> => block.type === \"text\")\n .map((block) => block.text)\n .join(separator)\n .trim();\n}\n","import { GenerationProviderError, GenerationTimeoutError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { compactObject, getBlockMeta } from \"../utils.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 60_000;\nconst DEFAULT_POLL_INTERVAL_SEC = 2;\nconst DEFAULT_MAX_WAIT_SEC = 600;\n\nconst RESOLUTION_SHORT_EDGE: Record<string, number> = {\n \"480p\": 480,\n \"720p\": 720,\n \"1080p\": 1080,\n \"2K\": 1440,\n};\n\nconst ASPECT_RATIOS: Record<string, [number, number] | null> = {\n \"16:9\": [16, 9],\n \"9:16\": [9, 16],\n \"1:1\": [1, 1],\n \"4:3\": [4, 3],\n \"3:2\": [3, 2],\n \"2:3\": [2, 3],\n \"3:4\": [3, 4],\n \"21:9\": [21, 9],\n adaptive: null,\n};\n\ntype ArkCreateTaskResponse = { id?: unknown; task_id?: unknown; status?: unknown };\n\ntype ArkTaskStatusResponse = {\n data?: {\n task_id?: unknown;\n status?: unknown;\n result_url?: unknown;\n progress?: unknown;\n data?: {\n status?: unknown;\n content?: { video_url?: unknown; last_frame_url?: unknown };\n resolution?: unknown;\n ratio?: unknown;\n duration?: unknown;\n framespersecond?: unknown;\n seed?: unknown;\n generate_audio?: unknown;\n model?: unknown;\n usage?: unknown;\n };\n };\n status?: unknown;\n url?: unknown;\n last_frame_url?: unknown;\n metadata?: unknown;\n};\n\ntype ImageMode = \"image\" | \"frame\" | \"reference\";\ntype ResolvedImage = { url: string; role: string | undefined };\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === \"string\" && value ? value : undefined;\n}\n\nfunction asNumber(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\nfunction asBoolean(value: unknown): boolean | undefined {\n return typeof value === \"boolean\" ? value : undefined;\n}\n\nfunction getIntegerParameter(parameters: Record<string, unknown>, key: string, fallback: number): number {\n const value = parameters[key];\n return typeof value === \"number\" && Number.isInteger(value) ? value : fallback;\n}\n\nfunction resolveSize(resolution: string, aspectRatio: string): { width: number; height: number } | null {\n const ratio = ASPECT_RATIOS[aspectRatio];\n if (!ratio) return null;\n\n const shortEdge = RESOLUTION_SHORT_EDGE[resolution];\n if (!shortEdge) throw new GenerationValidationError(`Unsupported resolution: ${resolution}`);\n\n const [wRatio, hRatio] = ratio;\n const width = wRatio >= hRatio ? Math.round((shortEdge * wRatio) / hRatio) : shortEdge;\n const height = wRatio >= hRatio ? shortEdge : Math.round((shortEdge * hRatio) / wRatio);\n return { width: width % 2 === 0 ? width : width + 1, height: height % 2 === 0 ? height : height + 1 };\n}\n\nfunction getImageRole(block: Extract<GenerationContentBlock, { type: \"image\" }>): string | undefined {\n const role = getBlockMeta(block)?.role;\n return typeof role === \"string\" && role ? role : undefined;\n}\n\nfunction classifyImages(images: ResolvedImage[]): ImageMode | null {\n if (images.length === 0) return null;\n const hasFirstOrLast = images.some((image) => image.role === \"first_frame\" || image.role === \"last_frame\");\n const hasReference = images.some((image) => image.role === \"reference_image\");\n const hasPlain = images.some((image) => !image.role);\n const modes = [hasPlain, hasFirstOrLast, hasReference].filter(Boolean).length;\n if (modes > 1)\n throw new GenerationValidationError(\n \"Cannot mix video image modes: use only plain image, first_frame/last_frame, or reference_image\",\n );\n if (hasReference) return \"reference\";\n if (hasFirstOrLast) return \"frame\";\n return \"image\";\n}\n\nfunction buildMetadataContent(prompt: string, images: ResolvedImage[], mode: Exclude<ImageMode, \"image\">) {\n const content: Array<Record<string, unknown>> = [{ type: \"text\", text: prompt }];\n for (const image of images) {\n if (mode === \"frame\" && image.role !== \"first_frame\" && image.role !== \"last_frame\") {\n throw new GenerationValidationError(\"Frame mode images must use meta.role first_frame or last_frame\");\n }\n if (mode === \"reference\" && image.role !== \"reference_image\") {\n throw new GenerationValidationError(\"Reference mode images must use meta.role reference_image\");\n }\n content.push({ type: \"image_url\", image_url: { url: image.url }, role: image.role });\n }\n return content;\n}\n\nfunction extractTaskId(response: ArkCreateTaskResponse): string {\n const taskId = asString(response.task_id) ?? asString(response.id);\n if (!taskId) {\n throw new GenerationProviderError(\"Video generation provider did not return a task id\", {\n details: { response },\n });\n }\n return taskId;\n}\n\nfunction normalizeTaskStatus(response: ArkTaskStatusResponse) {\n if (response.data) {\n const wrapper = response.data;\n const native = wrapper.data;\n const status = (asString(native?.status) ?? asString(wrapper.status) ?? \"unknown\").toLowerCase();\n const videoUrl = asString(wrapper.result_url) ?? asString(native?.content?.video_url);\n const lastFrameUrl = asString(native?.content?.last_frame_url);\n const metadata: Record<string, unknown> = {\n progress: wrapper.progress,\n resolution: native?.resolution,\n ratio: native?.ratio,\n duration: native?.duration,\n framespersecond: native?.framespersecond,\n seed: native?.seed,\n generate_audio: native?.generate_audio,\n model: native?.model,\n usage: native?.usage,\n };\n for (const key of Object.keys(metadata)) if (metadata[key] === undefined) delete metadata[key];\n return { status, videoUrl, lastFrameUrl, metadata };\n }\n return {\n status: (asString(response.status) ?? \"unknown\").toLowerCase(),\n videoUrl: asString(response.url),\n lastFrameUrl: asString(response.last_frame_url),\n metadata:\n response.metadata && typeof response.metadata === \"object\" ? (response.metadata as Record<string, unknown>) : {},\n };\n}\n\nasync function requestJson(input: GenerationAdapterInput, path: string, init: RequestInit): Promise<unknown> {\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, path),\n {\n ...init,\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...init.headers,\n },\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Video generation provider request failed\", { status: response.status, body });\n }\n return response.json();\n}\n\nexport async function arkVideoGenerationsAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const imageBlocks = input.request.content.filter(\n (block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\",\n );\n const images = await Promise.all(\n imageBlocks.map(async (block) => ({\n url: await input.context.resolveSource(block.source),\n role: getImageRole(block),\n })),\n );\n\n const mode = classifyImages(images);\n const resolution = asString(input.parameters.resolution) ?? \"720p\";\n const aspectRatio = asString(input.parameters.aspect_ratio) ?? \"16:9\";\n const duration = getIntegerParameter(input.parameters, \"duration\", 5);\n const fps = getIntegerParameter(input.parameters, \"fps\", 30);\n const pollIntervalSec = getIntegerParameter(input.parameters, \"poll_interval\", DEFAULT_POLL_INTERVAL_SEC);\n const maxWaitSec = getIntegerParameter(input.parameters, \"max_wait\", DEFAULT_MAX_WAIT_SEC);\n const generateAudio = asBoolean(input.parameters.generate_audio) ?? true;\n const returnLastFrame = asBoolean(input.parameters.return_last_frame) ?? true;\n const cameraFixed = asBoolean(input.parameters.camera_fixed) ?? false;\n const watermark = asBoolean(input.parameters.watermark) ?? false;\n const seed = asNumber(input.parameters.seed);\n\n const payload: Record<string, unknown> = { model: input.declaration.model, prompt };\n const metadata: Record<string, unknown> = { duration, fps, generate_audio: generateAudio };\n if (seed !== undefined) metadata.seed = seed;\n if (returnLastFrame) metadata.return_last_frame = true;\n if (cameraFixed) metadata.camera_fixed = true;\n if (watermark) metadata.watermark = true;\n\n if (mode === \"frame\" || mode === \"reference\") {\n metadata.content = buildMetadataContent(prompt, images, mode);\n metadata.resolution = resolution;\n metadata.ratio = aspectRatio;\n } else {\n const size = resolveSize(resolution, aspectRatio);\n if (size) {\n payload.width = size.width;\n payload.height = size.height;\n }\n if (images[0]) payload.image = images[0].url;\n }\n payload.metadata = metadata;\n\n const task = (await requestJson(input, \"/v1/video/generations\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n })) as ArkCreateTaskResponse;\n const taskId = extractTaskId(task);\n const startedAt = Date.now();\n\n while (Date.now() - startedAt <= maxWaitSec * 1000) {\n await sleep(pollIntervalSec * 1000);\n const rawStatus = (await requestJson(input, `/v1/video/generations/${encodeURIComponent(taskId)}`, {\n method: \"GET\",\n })) as ArkTaskStatusResponse;\n const status = normalizeTaskStatus(rawStatus);\n\n if (status.status === \"succeeded\") {\n if (!status.videoUrl) {\n throw new GenerationProviderError(\"Video generation succeeded but returned no video URL\", {\n details: compactObject({ taskId, rawStatus, metadata: status.metadata }),\n });\n }\n const output: GenerationContentBlock[] = [\n {\n type: \"video\",\n source: { type: \"url\", url: status.videoUrl },\n meta: { task_id: taskId, status: status.status, ...status.metadata },\n },\n ];\n if (status.lastFrameUrl)\n output.push({\n type: \"image\",\n source: { type: \"url\", url: status.lastFrameUrl },\n meta: { role: \"last_frame\", task_id: taskId },\n });\n return output;\n }\n\n if ([\"failed\", \"expired\", \"cancelled\"].includes(status.status)) {\n throw new GenerationProviderError(`Video generation ${status.status}`, { details: { taskId, rawStatus } });\n }\n }\n\n throw new GenerationTimeoutError(\"Timed out waiting for video generation\", { taskId });\n}\n","import { GenerationProviderError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { compactArray, compactObject } from \"../utils.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 300_000;\nconst IMAGE_FETCH_TIMEOUT_MS = 60_000;\nconst MAX_REFERENCE_IMAGE_BYTES = 10 * 1024 * 1024;\n\nconst DATA_URI_PATTERN = /^data:([^;]+);base64,(.+)$/s;\nconst MARKDOWN_IMAGE_DATA_URI_PATTERN = /!\\[[^\\]]*\\]\\(data:([^;]+);base64,([^)]+)\\)/;\n\ntype GeminiPart = { text: string } | { inlineData: { mimeType: string; data: string } };\n\ntype GeminiResponsePart = {\n text?: unknown;\n inlineData?: { mimeType?: unknown; data?: unknown };\n inline_data?: { mime_type?: unknown; mimeType?: unknown; data?: unknown };\n};\n\ntype GeminiCandidate = {\n content?: { role?: unknown; parts?: GeminiResponsePart[] };\n finishReason?: unknown;\n finishMessage?: unknown;\n safetyRatings?: unknown;\n citationMetadata?: unknown;\n groundingMetadata?: unknown;\n avgLogprobs?: unknown;\n index?: unknown;\n};\n\ntype GeminiGenerateContentResponse = {\n candidates?: GeminiCandidate[];\n promptFeedback?: unknown;\n usageMetadata?: unknown;\n modelVersion?: unknown;\n responseId?: unknown;\n};\n\nfunction dataUriToInlineData(value: string): GeminiPart | null {\n const match = DATA_URI_PATTERN.exec(value);\n if (!match) return null;\n const [, mimeType, data] = match;\n if (!mimeType || !data) return null;\n return { inlineData: { mimeType, data } };\n}\n\nasync function urlToInlineData(fetchFn: typeof fetch, url: string): Promise<GeminiPart> {\n const response = await fetchWithTimeout(\n fetchFn,\n url,\n { method: \"GET\", headers: { \"User-Agent\": \"NetaGeneration/1.0\" } },\n IMAGE_FETCH_TIMEOUT_MS,\n );\n if (!response.ok) throw new GenerationProviderError(\"Failed to fetch reference image\", { status: response.status });\n\n const contentLength = response.headers.get(\"content-length\");\n if (contentLength && Number(contentLength) > MAX_REFERENCE_IMAGE_BYTES) {\n throw new GenerationValidationError(\"Reference image is too large\");\n }\n\n const bytes = Buffer.from(await response.arrayBuffer());\n if (bytes.byteLength > MAX_REFERENCE_IMAGE_BYTES) throw new GenerationValidationError(\"Reference image is too large\");\n\n const contentType = response.headers.get(\"content-type\")?.split(\";\")[0]?.trim();\n const mimeType = contentType?.startsWith(\"image/\") ? contentType : \"image/png\";\n return { inlineData: { mimeType, data: bytes.toString(\"base64\") } };\n}\n\nasync function sourceToInlineData(input: GenerationAdapterInput, value: string): Promise<GeminiPart> {\n const inline = dataUriToInlineData(value);\n if (inline) return inline;\n if (value.startsWith(\"http://\") || value.startsWith(\"https://\")) return urlToInlineData(input.context.fetch, value);\n throw new GenerationValidationError(\"Unsupported image source for Gemini image generation\");\n}\n\nfunction extractMarkdownDataUriImage(text: string): GenerationContentBlock | null {\n const match = MARKDOWN_IMAGE_DATA_URI_PATTERN.exec(text);\n if (!match) return null;\n const [, mediaType, data] = match;\n if (!mediaType || !data) return null;\n return { type: \"image\", source: { type: \"base64\", mediaType, data } };\n}\n\nfunction collectGeminiNoOutputDetails(raw: GeminiGenerateContentResponse): Record<string, unknown> {\n const candidates = raw.candidates ?? [];\n return compactObject({\n finishReasons: compactArray(\n candidates.map((candidate) => candidate.finishReason).filter((value) => value !== undefined),\n ),\n finishMessages: compactArray(\n candidates.map((candidate) => candidate.finishMessage).filter((value) => value !== undefined),\n ),\n safetyRatings: compactArray(candidates.flatMap((candidate) => candidate.safetyRatings ?? [])),\n promptFeedback: raw.promptFeedback,\n usageMetadata: raw.usageMetadata,\n modelVersion: raw.modelVersion,\n responseId: raw.responseId,\n candidateCount: candidates.length,\n candidates: compactArray(\n candidates.map((candidate) =>\n compactObject({\n index: candidate.index,\n finishReason: candidate.finishReason,\n finishMessage: candidate.finishMessage,\n safetyRatings: candidate.safetyRatings,\n citationMetadata: candidate.citationMetadata,\n groundingMetadata: candidate.groundingMetadata,\n avgLogprobs: candidate.avgLogprobs,\n contentRole: candidate.content?.role,\n partCount: candidate.content?.parts?.length,\n }),\n ),\n ),\n });\n}\n\nfunction appendGeminiPartOutput(output: GenerationContentBlock[], part: GeminiResponsePart): void {\n if (typeof part.text === \"string\" && part.text.trim()) {\n const image = extractMarkdownDataUriImage(part.text);\n if (image) {\n output.push(image);\n return;\n }\n output.push({ type: \"text\", text: part.text });\n return;\n }\n\n if (part.inlineData && typeof part.inlineData.data === \"string\" && part.inlineData.data) {\n output.push({\n type: \"image\",\n source: {\n type: \"base64\",\n mediaType: typeof part.inlineData.mimeType === \"string\" ? part.inlineData.mimeType : \"image/png\",\n data: part.inlineData.data,\n },\n });\n return;\n }\n\n const inline = part.inline_data;\n if (!inline || typeof inline.data !== \"string\" || !inline.data) return;\n const mediaType =\n typeof inline.mime_type === \"string\"\n ? inline.mime_type\n : typeof inline.mimeType === \"string\"\n ? inline.mimeType\n : \"image/png\";\n output.push({ type: \"image\", source: { type: \"base64\", mediaType, data: inline.data } });\n}\n\nexport async function geminiGenerateContentAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const imageParts = await Promise.all(\n input.request.content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\")\n .map(async (block) => sourceToInlineData(input, await input.context.resolveSource(block.source))),\n );\n\n const generationConfig: Record<string, unknown> = { responseModalities: [\"IMAGE\"] };\n const aspectRatio = input.parameters.aspect_ratio;\n const imageSize = input.parameters.image_size;\n if (typeof aspectRatio === \"string\" || typeof imageSize === \"string\") {\n const image: Record<string, string> = {};\n if (typeof aspectRatio === \"string\") image.aspectRatio = aspectRatio;\n if (typeof imageSize === \"string\") image.imageSize = imageSize;\n generationConfig.responseFormat = { image };\n }\n\n const payload = {\n contents: [{ parts: [{ text: prompt }, ...imageParts] satisfies GeminiPart[] }],\n generationConfig,\n };\n\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, `/v1beta/models/${encodeURIComponent(input.declaration.model)}:generateContent`),\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Gemini generation provider request failed\", { status: response.status, body });\n }\n\n const raw = (await response.json()) as GeminiGenerateContentResponse;\n const output: GenerationContentBlock[] = [];\n for (const candidate of raw.candidates ?? []) {\n for (const part of candidate.content?.parts ?? []) appendGeminiPartOutput(output, part);\n }\n if (output.length === 0) {\n throw new GenerationProviderError(\"Gemini generation returned no output\", {\n details: collectGeminiNoOutputDetails(raw),\n });\n }\n return output;\n}\n","import { GenerationProviderError, GenerationValidationError } from \"../errors.js\";\nimport { fetchWithTimeout, joinUrl } from \"../http.js\";\nimport type { GenerationAdapterInput, GenerationContentBlock } from \"../types.js\";\nimport { compactArray, compactObject } from \"../utils.js\";\nimport { mergeTextBlocks } from \"../validation.js\";\n\nconst REQUEST_TIMEOUT_MS = 300_000;\n\ntype OpenAiImagesResponse = {\n data?: Array<{\n url?: unknown;\n b64_json?: unknown;\n revised_prompt?: unknown;\n }>;\n created?: unknown;\n usage?: unknown;\n background?: unknown;\n output_format?: unknown;\n quality?: unknown;\n size?: unknown;\n};\n\nfunction collectOpenAiImagesNoOutputDetails(raw: OpenAiImagesResponse): Record<string, unknown> {\n const data = raw.data ?? [];\n return compactObject({\n created: raw.created,\n usage: raw.usage,\n background: raw.background,\n outputFormat: raw.output_format,\n quality: raw.quality,\n size: raw.size,\n dataCount: data.length,\n data: compactArray(\n data.map((item) =>\n compactObject({\n hasUrl: typeof item.url === \"string\" && item.url.length > 0,\n hasBase64Json: typeof item.b64_json === \"string\" && item.b64_json.length > 0,\n revisedPrompt: item.revised_prompt,\n }),\n ),\n ),\n });\n}\n\nexport async function openAiImagesAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]> {\n const prompt = mergeTextBlocks(input.declaration, input.request.content);\n if (!prompt) throw new GenerationValidationError(\"Prompt text is required\");\n\n const images = await Promise.all(\n input.request.content\n .filter((block): block is Extract<GenerationContentBlock, { type: \"image\" }> => block.type === \"image\")\n .map((block) => input.context.resolveSource(block.source)),\n );\n\n const payload: Record<string, unknown> = {\n model: input.declaration.model,\n prompt,\n ...input.parameters,\n };\n if (images.length > 0) payload.image = images;\n\n const response = await fetchWithTimeout(\n input.context.fetch,\n joinUrl(input.context.baseUrl, \"/v1/images/generations\"),\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${input.context.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n },\n REQUEST_TIMEOUT_MS,\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => response.statusText);\n throw new GenerationProviderError(\"Image generation provider request failed\", { status: response.status, body });\n }\n\n const raw = (await response.json()) as OpenAiImagesResponse;\n const output: GenerationContentBlock[] = [];\n for (const item of raw.data ?? []) {\n if (typeof item.url === \"string\" && item.url) {\n output.push({ type: \"image\", source: { type: \"url\", url: item.url } });\n }\n if (typeof item.b64_json === \"string\" && item.b64_json) {\n output.push({ type: \"image\", source: { type: \"base64\", mediaType: \"image/png\", data: item.b64_json } });\n }\n if (typeof item.revised_prompt === \"string\" && item.revised_prompt.trim()) {\n output.push({ type: \"text\", text: item.revised_prompt, meta: { role: \"revised_prompt\" } });\n }\n }\n if (output.length === 0) {\n throw new GenerationProviderError(\"Image generation returned no output\", {\n details: collectOpenAiImagesNoOutputDetails(raw),\n });\n }\n return output;\n}\n","import { GenerationUnsupportedAdapterError } from \"../errors.js\";\nimport type { GenerationAdapter } from \"../types.js\";\nimport { arkVideoGenerationsAdapter } from \"./ark-video-generations.js\";\nimport { geminiGenerateContentAdapter } from \"./gemini-generate-content.js\";\nimport { openAiImagesAdapter } from \"./openai-images.js\";\n\nexport const builtinGenerationAdapters: Record<string, GenerationAdapter> = {\n \"ark.videoGenerations\": arkVideoGenerationsAdapter,\n \"gemini.generateContent\": geminiGenerateContentAdapter,\n \"openai.images\": openAiImagesAdapter,\n};\n\nexport function getGenerationAdapter(\n type: string,\n adapters: Record<string, GenerationAdapter> = {},\n): GenerationAdapter {\n const adapter = adapters[type] ?? builtinGenerationAdapters[type];\n if (!adapter) throw new GenerationUnsupportedAdapterError(type);\n return adapter;\n}\n\nexport * from \"./ark-video-generations.js\";\nexport * from \"./gemini-generate-content.js\";\nexport * from \"./openai-images.js\";\n","import type { GenerationSource, GenerationSourceResolver } from \"./types.js\";\n\nexport const defaultGenerationSourceResolver: GenerationSourceResolver = (source: GenerationSource) => {\n switch (source.type) {\n case \"url\":\n return source.url;\n case \"base64\":\n return `data:${source.mediaType};base64,${source.data}`;\n }\n};\n","import { getGenerationAdapter } from \"./adapters/index.js\";\nimport { builtinGenerationModels } from \"./builtins.js\";\nimport {\n readGenerationModelDeclarationsFromDirectory,\n readGenerationModelDeclarationsFromFiles,\n stringifyGenerationModelDeclaration,\n writeGenerationModelDeclaration,\n writeGenerationModelDeclarations,\n} from \"./config.js\";\nimport { GenerationConfigError } from \"./errors.js\";\nimport { defaultGenerationSourceResolver } from \"./source.js\";\nimport type {\n CreateGenerationClientOptions,\n GenerateRequest,\n GenerationClient,\n GenerationModelDeclaration,\n} from \"./types.js\";\nimport { cloneJson } from \"./utils.js\";\nimport { resolveGenerationParameters, validateGenerationContent } from \"./validation.js\";\n\nconst DEFAULT_BASE_URL = \"https://router.neta.art\";\n\nfunction resolveModels(options: CreateGenerationClientOptions): GenerationModelDeclaration[] {\n const includeBuiltinModels = options.includeBuiltinModels ?? !options.models;\n const models = [...(includeBuiltinModels ? builtinGenerationModels : []), ...(options.models ?? [])];\n const byModel = new Map<string, GenerationModelDeclaration>();\n for (const model of models) byModel.set(model.model, cloneJson(model));\n return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));\n}\n\nexport function createGenerationClient(options: CreateGenerationClientOptions = {}): GenerationClient {\n const models = resolveModels(options);\n const byModel = new Map(models.map((declaration) => [declaration.model, declaration]));\n const fetchFn = options.fetch ?? globalThis.fetch;\n if (!fetchFn) throw new GenerationConfigError(\"A fetch implementation is required\");\n\n function requireModel(model: string): GenerationModelDeclaration {\n const declaration = byModel.get(model);\n if (!declaration) throw new GenerationConfigError(`Generation model is unavailable: ${model}`);\n return declaration;\n }\n\n return {\n validate(request: GenerateRequest) {\n const declaration = requireModel(request.model);\n validateGenerationContent(declaration, request.content);\n const parameters = resolveGenerationParameters(declaration, request.parameters);\n return { declaration: cloneJson(declaration), request: cloneJson(request), parameters };\n },\n\n async generate(request: GenerateRequest) {\n const resolved = this.validate(request);\n const apiKey = request.apiKey ?? options.apiKey;\n if (!apiKey) throw new GenerationConfigError(\"apiKey is required\");\n const adapter = getGenerationAdapter(resolved.declaration.adapter.type, options.adapters);\n return adapter({\n ...resolved,\n context: {\n apiKey,\n baseUrl: request.baseUrl ?? options.baseUrl ?? DEFAULT_BASE_URL,\n fetch: fetchFn,\n resolveSource: options.sourceResolver ?? defaultGenerationSourceResolver,\n },\n });\n },\n\n listModels() {\n return cloneJson(models);\n },\n\n getModel(model: string) {\n const declaration = byModel.get(model);\n return declaration ? cloneJson(declaration) : null;\n },\n\n stringifyModelConfig(model: string, stringifyOptions = {}) {\n return stringifyGenerationModelDeclaration(requireModel(model), stringifyOptions);\n },\n\n exportModelConfig(model: string, filePath: string) {\n return writeGenerationModelDeclaration(requireModel(model), filePath);\n },\n\n exportModelConfigs(directory: string) {\n return writeGenerationModelDeclarations(models, directory);\n },\n };\n}\n\nexport async function createGenerationClientFromFiles(\n filePaths: string[],\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n const models = await readGenerationModelDeclarationsFromFiles(filePaths);\n return createGenerationClient({ ...options, models, includeBuiltinModels: options.includeBuiltinModels ?? true });\n}\n\nexport async function createGenerationClientFromDirectory(\n directory: string,\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n const models = await readGenerationModelDeclarationsFromDirectory(directory);\n return createGenerationClient({ ...options, models, includeBuiltinModels: options.includeBuiltinModels ?? true });\n}\n\nexport async function createGenerationClientFromFile(\n filePath: string,\n options: Omit<CreateGenerationClientOptions, \"models\"> = {},\n): Promise<GenerationClient> {\n return createGenerationClientFromFiles([filePath], options);\n}\n"],"mappings":";;;;AAEA,eAAsB,iBACpB,SACA,KACA,MACA,WACmB;CACnB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,UAAU,iBAAiB,WAAW,OAAO,EAAE,UAAU;AAC/D,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK;GAAE,GAAG;GAAM,QAAQ,WAAW;GAAQ,CAAC;UAC1D,OAAO;AACd,MAAI,iBAAiB,SAAS,MAAM,SAAS,aAAc,OAAM,IAAI,wBAAwB;AAC7F,QAAM;WACE;AACR,eAAa,QAAQ;;;AAIzB,SAAgB,QAAQ,SAAiB,MAAsB;AAC7D,QAAO,GAAG,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GAAG,KAAK,QAAQ,QAAQ,GAAG;;;;;AClBnE,SAAS,YAAY,OAAgC;CACnD,MAAM,sBAAM,IAAI,KAA2D;AAC3E,MAAK,MAAM,QAAQ,MAAO,KAAI,IAAI,KAAK,MAAM,KAAK;AAClD,QAAO;;AAGT,SAAgB,0BACd,aACA,SACM;CACN,MAAM,aAAa,YAAY,YAAY,QAAQ,MAAM;CACzD,MAAM,yBAAS,IAAI,KAA4C;AAE/D,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,WAAW,IAAI,MAAM,KAAK;AACvC,MAAI,CAAC,KACH,OAAM,IAAI,0BAA0B,0CAA0C,YAAY,MAAM,IAAI,MAAM,OAAO;AACnH,SAAO,IAAI,MAAM,OAAO,OAA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;EAAQ,sBAAsB,QAAQ,wBAAwB;EAAM,CAAC;;AAGnH,eAAsB,+BACpB,UACA,UAAyD,EAAE,EAChC;AAC3B,QAAO,gCAAgC,CAAC,SAAS,EAAE,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/generation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A lightweight multimodal generation SDK with built-in model presets and adapter-based provider calls.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"bin": {
|
|
37
|
-
"neta-generation": "
|
|
37
|
+
"neta-generation": "dist/cli/index.js"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"dist",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"packageManager": "pnpm@10.32.1",
|
|
71
71
|
"publishConfig": {
|
|
72
|
-
"access": "public"
|
|
72
|
+
"access": "public",
|
|
73
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builtins-hmNIcYXN.js","names":["builtinGenerationModels: GenerationModelDeclaration[]"],"sources":["../src/types.ts","../src/utils.ts","../src/builtins.ts"],"sourcesContent":["export const MODEL_SCHEMA = \"neta.generation.model.v1\" as const;\n\nexport type GenerationSource = { type: \"url\"; url: string } | { type: \"base64\"; mediaType: string; data: string };\n\nexport type GenerationContentBlockMeta = Record<string, unknown>;\n\nexport type GenerationContentBlock =\n | { type: \"text\"; text: string; meta?: GenerationContentBlockMeta }\n | { type: \"image\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"video\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"audio\"; source: GenerationSource; meta?: GenerationContentBlockMeta };\n\nexport type GenerationContentSpec = {\n type: \"text\" | \"image\" | \"video\" | \"audio\";\n required?: boolean;\n min?: number;\n max?: number;\n sources?: Array<GenerationSource[\"type\"]>;\n merge?: \"newline\" | \"space\" | \"concat\";\n meta?: Record<string, unknown>;\n description?: string;\n};\n\nexport type GenerationParameterSpec =\n | {\n type: \"string\";\n optional?: boolean;\n default?: string;\n enum?: string[];\n description?: string;\n examples?: string[];\n }\n | {\n type: \"number\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"integer\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"boolean\";\n optional?: boolean;\n default?: boolean;\n description?: string;\n examples?: boolean[];\n };\n\nexport type GenerationModelDeclaration = {\n schema: typeof MODEL_SCHEMA;\n model: string;\n title?: string;\n description?: string;\n adapter: {\n type: string;\n };\n content: {\n input: GenerationContentSpec[];\n };\n parameters?: Record<string, GenerationParameterSpec>;\n examples?: Array<{\n title?: string;\n request: GenerateRequest;\n }>;\n};\n\nexport type GenerateRequest = {\n model: string;\n content: GenerationContentBlock[];\n parameters?: Record<string, unknown>;\n apiKey?: string;\n baseUrl?: string;\n metadata?: Record<string, unknown>;\n};\n\nexport type ResolvedGenerationRequest = {\n declaration: GenerationModelDeclaration;\n request: GenerateRequest;\n parameters: Record<string, unknown>;\n};\n\nexport type GenerationSourceResolver = (source: GenerationSource) => Promise<string> | string;\n\nexport type GenerationAdapterContext = {\n apiKey: string;\n baseUrl: string;\n fetch: typeof fetch;\n resolveSource: GenerationSourceResolver;\n};\n\nexport type GenerationAdapterInput = ResolvedGenerationRequest & {\n context: GenerationAdapterContext;\n};\n\nexport type GenerationAdapter = (input: GenerationAdapterInput) => Promise<GenerationContentBlock[]>;\n\nexport type CreateGenerationClientOptions = {\n apiKey?: string;\n baseUrl?: string;\n models?: GenerationModelDeclaration[];\n includeBuiltinModels?: boolean;\n fetch?: typeof fetch;\n sourceResolver?: GenerationSourceResolver;\n adapters?: Record<string, GenerationAdapter>;\n};\n\nexport type GenerationClient = {\n generate(request: GenerateRequest): Promise<GenerationContentBlock[]>;\n validate(request: GenerateRequest): ResolvedGenerationRequest;\n listModels(): GenerationModelDeclaration[];\n getModel(model: string): GenerationModelDeclaration | null;\n stringifyModelConfig(model: string, options?: { format?: \"yaml\" | \"json\" }): string;\n exportModelConfig(model: string, filePath: string): Promise<void>;\n exportModelConfigs(directory: string): Promise<void>;\n};\n","import type { GenerationContentBlock } from \"./types.js\";\n\nexport function cloneJson<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nexport function slugifyFileName(value: string): string {\n return (\n value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"model\"\n );\n}\n\nexport function getBlockMeta(block: GenerationContentBlock): Record<string, unknown> | undefined {\n return \"meta\" in block ? block.meta : undefined;\n}\n","import type { GenerationModelDeclaration } from \"./types.js\";\nimport { MODEL_SCHEMA } from \"./types.js\";\nimport { cloneJson } from \"./utils.js\";\n\nconst imageSizeParameters = {\n size: {\n type: \"string\",\n optional: true,\n default: \"1024x1024\",\n description: \"Output image size.\",\n examples: [\"auto\", \"1024x1024\", \"1536x1024\", \"1024x1536\", \"2048x2048\", \"2048x1152\", \"3840x2160\", \"2160x3840\"],\n },\n quality: {\n type: \"string\",\n optional: true,\n default: \"auto\",\n enum: [\"auto\", \"low\", \"medium\", \"high\"],\n description: \"Image quality.\",\n },\n} satisfies GenerationModelDeclaration[\"parameters\"];\n\nfunction videoParameters(defaults: { resolution: string; maxWait: number }) {\n return {\n duration: {\n type: \"integer\",\n optional: true,\n default: 5,\n min: 4,\n max: 15,\n description: \"Video duration in seconds.\",\n },\n resolution: {\n type: \"string\",\n optional: true,\n default: defaults.resolution,\n enum: [\"480p\", \"720p\", \"1080p\", \"2K\"],\n description: \"Output video resolution.\",\n },\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"16:9\",\n enum: [\"16:9\", \"9:16\", \"1:1\", \"4:3\", \"3:2\", \"2:3\", \"3:4\", \"21:9\", \"adaptive\"],\n description: \"Output aspect ratio. Use adaptive to let the model choose.\",\n },\n fps: { type: \"integer\", optional: true, default: 30, min: 1, max: 60, description: \"Frames per second.\" },\n seed: { type: \"integer\", optional: true, description: \"Random seed for reproducibility.\" },\n generate_audio: { type: \"boolean\", optional: true, default: true, description: \"Generate synchronized audio.\" },\n return_last_frame: {\n type: \"boolean\",\n optional: true,\n default: true,\n description: \"Return the last frame as an image for chaining video segments.\",\n },\n camera_fixed: {\n type: \"boolean\",\n optional: true,\n default: false,\n description: \"Fix camera position when supported.\",\n },\n watermark: { type: \"boolean\", optional: true, default: false, description: \"Add AI Generated watermark.\" },\n poll_interval: {\n type: \"integer\",\n optional: true,\n default: 2,\n min: 1,\n max: 30,\n description: \"Seconds between task status checks.\",\n },\n max_wait: {\n type: \"integer\",\n optional: true,\n default: defaults.maxWait,\n min: 30,\n max: 1800,\n description: \"Maximum seconds to wait for task completion.\",\n },\n } satisfies GenerationModelDeclaration[\"parameters\"];\n}\n\nconst builtinModels = [\n {\n schema: MODEL_SCHEMA,\n model: \"gpt-image-2\",\n title: \"GPT Image 2\",\n description:\n \"Image generation model with optional reference images. Good for photorealistic scenes, detailed images, and image editing with references.\",\n adapter: { type: \"openai.images\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 16,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: imageSizeParameters,\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gpt-image-2\",\n content: [{ type: \"text\", text: \"a cyberpunk cat in neon rain\" }],\n parameters: { size: \"1024x1024\", quality: \"auto\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"gemini-3.1-flash-image-preview\",\n title: \"Gemini 3.1 Flash Image Preview\",\n description:\n \"Gemini image generation and editing model. Good for text rendering, infographics, style transfer, and iterative image editing with references.\",\n adapter: { type: \"gemini.generateContent\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 14,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: {\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"1:1\",\n enum: [\"1:1\", \"16:9\", \"4:3\", \"3:2\", \"3:4\", \"2:3\", \"9:16\", \"5:4\", \"4:5\", \"21:9\", \"1:4\", \"4:1\", \"1:8\", \"8:1\"],\n description: \"Output aspect ratio.\",\n },\n image_size: {\n type: \"string\",\n optional: true,\n default: \"2K\",\n enum: [\"512\", \"1K\", \"2K\", \"4K\"],\n description: \"Output image resolution.\",\n },\n },\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gemini-3.1-flash-image-preview\",\n content: [\n { type: \"text\", text: \"a vibrant infographic explaining photosynthesis with clear readable labels\" },\n ],\n parameters: { aspect_ratio: \"16:9\", image_size: \"1K\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0\",\n title: \"Seedance 2.0\",\n description: \"Higher quality Ark video generation model for final production outputs.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"1080p\", maxWait: 900 }),\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0-fast\",\n title: \"Seedance 2.0 Fast\",\n description:\n \"Fast Ark video generation model for drafts, rapid iteration, text-to-video, image-to-video, and reference-guided video generation.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"720p\", maxWait: 600 }),\n },\n] satisfies GenerationModelDeclaration[];\n\nexport const builtinGenerationModels: GenerationModelDeclaration[] = cloneJson(builtinModels);\n\nexport function getBuiltinGenerationModel(model: string): GenerationModelDeclaration | null {\n return cloneJson(builtinModels.find((declaration) => declaration.model === model) ?? null);\n}\n\nexport function listBuiltinGenerationModels(): GenerationModelDeclaration[] {\n return cloneJson(builtinModels);\n}\n"],"mappings":";AAAA,MAAa,eAAe;;;;ACE5B,SAAgB,UAAa,OAAa;AACxC,QAAO,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC;;AAG1C,SAAgB,gBAAgB,OAAuB;AACrD,QACE,MACG,MAAM,CACN,aAAa,CACb,QAAQ,kBAAkB,IAAI,CAC9B,QAAQ,YAAY,GAAG,IAAI;;AAIlC,SAAgB,aAAa,OAAoE;AAC/F,QAAO,UAAU,QAAQ,MAAM,OAAO;;;;;ACbxC,MAAM,sBAAsB;CAC1B,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,aAAa;EACb,UAAU;GAAC;GAAQ;GAAa;GAAa;GAAa;GAAa;GAAa;GAAa;GAAY;EAC9G;CACD,SAAS;EACP,MAAM;EACN,UAAU;EACV,SAAS;EACT,MAAM;GAAC;GAAQ;GAAO;GAAU;GAAO;EACvC,aAAa;EACd;CACF;AAED,SAAS,gBAAgB,UAAmD;AAC1E,QAAO;EACL,UAAU;GACR,MAAM;GACN,UAAU;GACV,SAAS;GACT,KAAK;GACL,KAAK;GACL,aAAa;GACd;EACD,YAAY;GACV,MAAM;GACN,UAAU;GACV,SAAS,SAAS;GAClB,MAAM;IAAC;IAAQ;IAAQ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