@neta-art/generation 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/builtins-BuI-rf8X.d.ts +137 -0
- package/dist/builtins-BuI-rf8X.d.ts.map +1 -0
- package/dist/builtins-hmNIcYXN.js +311 -0
- package/dist/builtins-hmNIcYXN.js.map +1 -0
- package/dist/builtins.d.ts +2 -0
- package/dist/builtins.js +3 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +65 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/export-config-ZxwkQoZ6.js +128 -0
- package/dist/export-config-ZxwkQoZ6.js.map +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +602 -0
- package/dist/index.js.map +1 -0
- package/models/gemini-3.1-flash-image-preview.yaml +62 -0
- package/models/gpt-image-2.yaml +56 -0
- package/models/seedance-2-0-fast.yaml +97 -0
- package/models/seedance-2-0.yaml +97 -0
- package/package.json +74 -0
|
@@ -0,0 +1 @@
|
|
|
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;IAAS;IAAK;GACrC,aAAa;GACd;EACD,cAAc;GACZ,MAAM;GACN,UAAU;GACV,SAAS;GACT,MAAM;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S,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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { r as listBuiltinGenerationModels } from "../builtins-hmNIcYXN.js";
|
|
3
|
+
import { n as exportBuiltinModelConfigs, t as exportBuiltinModelConfig, u as stringifyGenerationModelDeclaration } from "../export-config-ZxwkQoZ6.js";
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/index.ts
|
|
8
|
+
function usage() {
|
|
9
|
+
console.log(`neta-generation
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
neta-generation models list
|
|
13
|
+
neta-generation models export <model> --out <file>
|
|
14
|
+
neta-generation models export-all --out <directory>
|
|
15
|
+
`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
function readOption(args, name) {
|
|
19
|
+
const index = args.indexOf(name);
|
|
20
|
+
if (index < 0) return null;
|
|
21
|
+
return args[index + 1] ?? null;
|
|
22
|
+
}
|
|
23
|
+
async function main() {
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
if (args[0] !== "models") usage();
|
|
26
|
+
switch (args[1]) {
|
|
27
|
+
case "list":
|
|
28
|
+
for (const model of listBuiltinGenerationModels()) console.log(model.model);
|
|
29
|
+
return;
|
|
30
|
+
case "export": {
|
|
31
|
+
const model = args[2];
|
|
32
|
+
const out = readOption(args, "--out");
|
|
33
|
+
if (!model || !out) usage();
|
|
34
|
+
await mkdir(dirname(out), { recursive: true });
|
|
35
|
+
await exportBuiltinModelConfig(model, out);
|
|
36
|
+
console.log(out);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
case "export-all": {
|
|
40
|
+
const out = readOption(args, "--out");
|
|
41
|
+
if (!out) usage();
|
|
42
|
+
await exportBuiltinModelConfigs(out);
|
|
43
|
+
console.log(out);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
case "dump": {
|
|
47
|
+
const out = readOption(args, "--out");
|
|
48
|
+
const models = listBuiltinGenerationModels();
|
|
49
|
+
if (out) {
|
|
50
|
+
await mkdir(out, { recursive: true });
|
|
51
|
+
await Promise.all(models.map((model) => writeFile(join(out, `${model.model}.yaml`), stringifyGenerationModelDeclaration(model))));
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
default: usage();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
main().catch((error) => {
|
|
59
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { };
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { listBuiltinGenerationModels } from \"../builtins.js\";\nimport { stringifyGenerationModelDeclaration } from \"../config.js\";\nimport { exportBuiltinModelConfig, exportBuiltinModelConfigs } from \"../export-config.js\";\n\nfunction usage(): never {\n console.log(`neta-generation\n\nUsage:\n neta-generation models list\n neta-generation models export <model> --out <file>\n neta-generation models export-all --out <directory>\n`);\n process.exit(1);\n}\n\nfunction readOption(args: string[], name: string): string | null {\n const index = args.indexOf(name);\n if (index < 0) return null;\n return args[index + 1] ?? null;\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args[0] !== \"models\") usage();\n\n switch (args[1]) {\n case \"list\": {\n for (const model of listBuiltinGenerationModels()) console.log(model.model);\n return;\n }\n case \"export\": {\n const model = args[2];\n const out = readOption(args, \"--out\");\n if (!model || !out) usage();\n await mkdir(dirname(out), { recursive: true });\n await exportBuiltinModelConfig(model, out);\n console.log(out);\n return;\n }\n case \"export-all\": {\n const out = readOption(args, \"--out\");\n if (!out) usage();\n await exportBuiltinModelConfigs(out);\n console.log(out);\n return;\n }\n case \"dump\": {\n const out = readOption(args, \"--out\");\n const models = listBuiltinGenerationModels();\n if (out) {\n await mkdir(out, { recursive: true });\n await Promise.all(\n models.map((model) =>\n writeFile(join(out, `${model.model}.yaml`), stringifyGenerationModelDeclaration(model)),\n ),\n );\n }\n return;\n }\n default:\n usage();\n }\n}\n\nmain().catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAOA,SAAS,QAAe;AACtB,SAAQ,IAAI;;;;;;EAMZ;AACA,SAAQ,KAAK,EAAE;;AAGjB,SAAS,WAAW,MAAgB,MAA6B;CAC/D,MAAM,QAAQ,KAAK,QAAQ,KAAK;AAChC,KAAI,QAAQ,EAAG,QAAO;AACtB,QAAO,KAAK,QAAQ,MAAM;;AAG5B,eAAe,OAAO;CACpB,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAClC,KAAI,KAAK,OAAO,SAAU,QAAO;AAEjC,SAAQ,KAAK,IAAb;EACE,KAAK;AACH,QAAK,MAAM,SAAS,6BAA6B,CAAE,SAAQ,IAAI,MAAM,MAAM;AAC3E;EAEF,KAAK,UAAU;GACb,MAAM,QAAQ,KAAK;GACnB,MAAM,MAAM,WAAW,MAAM,QAAQ;AACrC,OAAI,CAAC,SAAS,CAAC,IAAK,QAAO;AAC3B,SAAM,MAAM,QAAQ,IAAI,EAAE,EAAE,WAAW,MAAM,CAAC;AAC9C,SAAM,yBAAyB,OAAO,IAAI;AAC1C,WAAQ,IAAI,IAAI;AAChB;;EAEF,KAAK,cAAc;GACjB,MAAM,MAAM,WAAW,MAAM,QAAQ;AACrC,OAAI,CAAC,IAAK,QAAO;AACjB,SAAM,0BAA0B,IAAI;AACpC,WAAQ,IAAI,IAAI;AAChB;;EAEF,KAAK,QAAQ;GACX,MAAM,MAAM,WAAW,MAAM,QAAQ;GACrC,MAAM,SAAS,6BAA6B;AAC5C,OAAI,KAAK;AACP,UAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;AACrC,UAAM,QAAQ,IACZ,OAAO,KAAK,UACV,UAAU,KAAK,KAAK,GAAG,MAAM,MAAM,OAAO,EAAE,oCAAoC,MAAM,CAAC,CACxF,CACF;;AAEH;;EAEF,QACE,QAAO;;;AAIb,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;AACrE,SAAQ,KAAK,EAAE;EACf"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { i as cloneJson, n as getBuiltinGenerationModel, o as slugifyFileName, r as listBuiltinGenerationModels, s as MODEL_SCHEMA } from "./builtins-hmNIcYXN.js";
|
|
2
|
+
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { extname, join } from "node:path";
|
|
4
|
+
import { parse, stringify } from "yaml";
|
|
5
|
+
|
|
6
|
+
//#region src/errors.ts
|
|
7
|
+
var GenerationError = class extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "GenerationError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var GenerationConfigError = class extends GenerationError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "GenerationConfigError";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var GenerationValidationError = class extends GenerationError {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "GenerationValidationError";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var GenerationUnsupportedAdapterError = class extends GenerationError {
|
|
26
|
+
constructor(adapterType) {
|
|
27
|
+
super(`Unsupported generation adapter: ${adapterType}`);
|
|
28
|
+
this.name = "GenerationUnsupportedAdapterError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var GenerationProviderError = class extends GenerationError {
|
|
32
|
+
status;
|
|
33
|
+
body;
|
|
34
|
+
details;
|
|
35
|
+
constructor(message = "Generation provider request failed", options) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = "GenerationProviderError";
|
|
38
|
+
this.status = options?.status;
|
|
39
|
+
this.body = options?.body;
|
|
40
|
+
this.details = options?.details;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var GenerationTimeoutError = class extends GenerationProviderError {
|
|
44
|
+
constructor(message = "Generation request timed out", details) {
|
|
45
|
+
super(message, details ? { details } : void 0);
|
|
46
|
+
this.name = "GenerationTimeoutError";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/config.ts
|
|
52
|
+
const DECLARATION_EXTENSIONS = new Set([
|
|
53
|
+
".yaml",
|
|
54
|
+
".yml",
|
|
55
|
+
".json"
|
|
56
|
+
]);
|
|
57
|
+
function isRecord(value) {
|
|
58
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
59
|
+
}
|
|
60
|
+
function isParameterSpec(value) {
|
|
61
|
+
if (!isRecord(value)) return false;
|
|
62
|
+
return [
|
|
63
|
+
"string",
|
|
64
|
+
"number",
|
|
65
|
+
"integer",
|
|
66
|
+
"boolean"
|
|
67
|
+
].includes(String(value.type));
|
|
68
|
+
}
|
|
69
|
+
function isGenerationModelDeclaration(value) {
|
|
70
|
+
if (!isRecord(value)) return false;
|
|
71
|
+
const adapter = value.adapter;
|
|
72
|
+
const content = value.content;
|
|
73
|
+
const parameters = value.parameters;
|
|
74
|
+
const examples = value.examples;
|
|
75
|
+
return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && isRecord(adapter) && typeof adapter.type === "string" && isRecord(content) && Array.isArray(content.input) && (parameters === void 0 || isRecord(parameters) && Object.values(parameters).every(isParameterSpec)) && (examples === void 0 || Array.isArray(examples));
|
|
76
|
+
}
|
|
77
|
+
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
78
|
+
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
79
|
+
if (!isGenerationModelDeclaration(parsed)) throw new GenerationConfigError(`Invalid model declaration: ${filePath}`);
|
|
80
|
+
return parsed;
|
|
81
|
+
}
|
|
82
|
+
function stringifyGenerationModelDeclaration(declaration, options = {}) {
|
|
83
|
+
const value = cloneJson(declaration);
|
|
84
|
+
if (options.format === "json") return `${JSON.stringify(value, null, 2)}\n`;
|
|
85
|
+
return stringify(value, { lineWidth: 120 });
|
|
86
|
+
}
|
|
87
|
+
async function readGenerationModelDeclaration(filePath) {
|
|
88
|
+
return parseGenerationModelDeclaration(await readFile(filePath, "utf-8"), filePath);
|
|
89
|
+
}
|
|
90
|
+
async function readGenerationModelDeclarationsFromFiles(filePaths) {
|
|
91
|
+
return mergeGenerationModelDeclarations(await Promise.all(filePaths.map((filePath) => readGenerationModelDeclaration(filePath))));
|
|
92
|
+
}
|
|
93
|
+
async function readGenerationModelDeclarationsFromDirectory(directory) {
|
|
94
|
+
return readGenerationModelDeclarationsFromFiles((await readdir(directory)).filter((entry) => DECLARATION_EXTENSIONS.has(extname(entry))).sort().map((entry) => join(directory, entry)));
|
|
95
|
+
}
|
|
96
|
+
function mergeGenerationModelDeclarations(declarations) {
|
|
97
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
98
|
+
for (const declaration of declarations) byModel.set(declaration.model, declaration);
|
|
99
|
+
return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));
|
|
100
|
+
}
|
|
101
|
+
async function writeGenerationModelDeclaration(declaration, filePath, options = {}) {
|
|
102
|
+
await writeFile(filePath, stringifyGenerationModelDeclaration(declaration, options));
|
|
103
|
+
}
|
|
104
|
+
async function writeGenerationModelDeclarations(declarations, directory, options = {}) {
|
|
105
|
+
await mkdir(directory, { recursive: true });
|
|
106
|
+
const ext = options.format === "json" ? "json" : "yaml";
|
|
107
|
+
await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/export-config.ts
|
|
112
|
+
function stringifyBuiltinModelConfig(model, options = {}) {
|
|
113
|
+
const declaration = getBuiltinGenerationModel(model);
|
|
114
|
+
if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);
|
|
115
|
+
return stringifyGenerationModelDeclaration(declaration, options);
|
|
116
|
+
}
|
|
117
|
+
async function exportBuiltinModelConfig(model, filePath) {
|
|
118
|
+
const declaration = getBuiltinGenerationModel(model);
|
|
119
|
+
if (!declaration) throw new GenerationConfigError(`Built-in model is unavailable: ${model}`);
|
|
120
|
+
await writeGenerationModelDeclaration(declaration, filePath);
|
|
121
|
+
}
|
|
122
|
+
async function exportBuiltinModelConfigs(directory) {
|
|
123
|
+
await writeGenerationModelDeclarations(listBuiltinGenerationModels(), directory);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
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-ZxwkQoZ6.js.map
|
|
@@ -0,0 +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<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AAK,MAAM,eAAe,aAAc,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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { _ as MODEL_SCHEMA, a as GenerateRequest, c as GenerationAdapterInput, d as GenerationContentBlockMeta, f as GenerationContentSpec, g as GenerationSourceResolver, h as GenerationSource, i as CreateGenerationClientOptions, l as GenerationClient, m as GenerationParameterSpec, n as getBuiltinGenerationModel, o as GenerationAdapter, p as GenerationModelDeclaration, r as listBuiltinGenerationModels, s as GenerationAdapterContext, t as builtinGenerationModels, u as GenerationContentBlock, v as ResolvedGenerationRequest } from "./builtins-BuI-rf8X.js";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/ark-video-generations.d.ts
|
|
4
|
+
declare function arkVideoGenerationsAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/adapters/gemini-generate-content.d.ts
|
|
7
|
+
declare function geminiGenerateContentAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/adapters/openai-images.d.ts
|
|
10
|
+
declare function openAiImagesAdapter(input: GenerationAdapterInput): Promise<GenerationContentBlock[]>;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/adapters/index.d.ts
|
|
13
|
+
declare const builtinGenerationAdapters: Record<string, GenerationAdapter>;
|
|
14
|
+
declare function getGenerationAdapter(type: string, adapters?: Record<string, GenerationAdapter>): GenerationAdapter;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/client.d.ts
|
|
17
|
+
declare function createGenerationClient(options?: CreateGenerationClientOptions): GenerationClient;
|
|
18
|
+
declare function createGenerationClientFromFiles(filePaths: string[], options?: Omit<CreateGenerationClientOptions, "models">): Promise<GenerationClient>;
|
|
19
|
+
declare function createGenerationClientFromDirectory(directory: string, options?: Omit<CreateGenerationClientOptions, "models">): Promise<GenerationClient>;
|
|
20
|
+
declare function createGenerationClientFromFile(filePath: string, options?: Omit<CreateGenerationClientOptions, "models">): Promise<GenerationClient>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/config.d.ts
|
|
23
|
+
declare function isGenerationModelDeclaration(value: unknown): value is GenerationModelDeclaration;
|
|
24
|
+
declare function parseGenerationModelDeclaration(rawText: string, filePath?: string): GenerationModelDeclaration;
|
|
25
|
+
declare function stringifyGenerationModelDeclaration(declaration: GenerationModelDeclaration, options?: {
|
|
26
|
+
format?: "yaml" | "json";
|
|
27
|
+
}): string;
|
|
28
|
+
declare function readGenerationModelDeclaration(filePath: string): Promise<GenerationModelDeclaration>;
|
|
29
|
+
declare function readGenerationModelDeclarationsFromFiles(filePaths: string[]): Promise<GenerationModelDeclaration[]>;
|
|
30
|
+
declare function readGenerationModelDeclarationsFromDirectory(directory: string): Promise<GenerationModelDeclaration[]>;
|
|
31
|
+
declare function mergeGenerationModelDeclarations(declarations: GenerationModelDeclaration[]): GenerationModelDeclaration[];
|
|
32
|
+
declare function writeGenerationModelDeclaration(declaration: GenerationModelDeclaration, filePath: string, options?: {
|
|
33
|
+
format?: "yaml" | "json";
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
declare function writeGenerationModelDeclarations(declarations: GenerationModelDeclaration[], directory: string, options?: {
|
|
36
|
+
format?: "yaml" | "json";
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/errors.d.ts
|
|
40
|
+
declare class GenerationError extends Error {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
declare class GenerationConfigError extends GenerationError {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
declare class GenerationValidationError extends GenerationError {
|
|
47
|
+
constructor(message: string);
|
|
48
|
+
}
|
|
49
|
+
declare class GenerationUnsupportedAdapterError extends GenerationError {
|
|
50
|
+
constructor(adapterType: string);
|
|
51
|
+
}
|
|
52
|
+
declare class GenerationProviderError extends GenerationError {
|
|
53
|
+
readonly status: number | undefined;
|
|
54
|
+
readonly body: string | undefined;
|
|
55
|
+
readonly details: Record<string, unknown> | undefined;
|
|
56
|
+
constructor(message?: string, options?: {
|
|
57
|
+
status?: number;
|
|
58
|
+
body?: string;
|
|
59
|
+
details?: Record<string, unknown>;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
declare class GenerationTimeoutError extends GenerationProviderError {
|
|
63
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/export-config.d.ts
|
|
67
|
+
declare function stringifyBuiltinModelConfig(model: string, options?: {
|
|
68
|
+
format?: "yaml" | "json";
|
|
69
|
+
}): string;
|
|
70
|
+
declare function exportBuiltinModelConfig(model: string, filePath: string): Promise<void>;
|
|
71
|
+
declare function exportBuiltinModelConfigs(directory: string): Promise<void>;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/source.d.ts
|
|
74
|
+
declare const defaultGenerationSourceResolver: GenerationSourceResolver;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/validation.d.ts
|
|
77
|
+
declare function validateGenerationContent(declaration: GenerationModelDeclaration, content: GenerationContentBlock[]): void;
|
|
78
|
+
declare function resolveGenerationParameters(declaration: GenerationModelDeclaration, parameters: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
79
|
+
declare function mergeTextBlocks(declaration: GenerationModelDeclaration, content: GenerationContentBlock[]): string;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { CreateGenerationClientOptions, GenerateRequest, GenerationAdapter, GenerationAdapterContext, GenerationAdapterInput, GenerationClient, GenerationConfigError, GenerationContentBlock, GenerationContentBlockMeta, GenerationContentSpec, GenerationError, GenerationModelDeclaration, GenerationParameterSpec, GenerationProviderError, GenerationSource, GenerationSourceResolver, GenerationTimeoutError, GenerationUnsupportedAdapterError, GenerationValidationError, MODEL_SCHEMA, ResolvedGenerationRequest, arkVideoGenerationsAdapter, builtinGenerationAdapters, builtinGenerationModels, createGenerationClient, createGenerationClientFromDirectory, createGenerationClientFromFile, createGenerationClientFromFiles, defaultGenerationSourceResolver, exportBuiltinModelConfig, exportBuiltinModelConfigs, geminiGenerateContentAdapter, getBuiltinGenerationModel, getGenerationAdapter, isGenerationModelDeclaration, listBuiltinGenerationModels, mergeGenerationModelDeclarations, mergeTextBlocks, openAiImagesAdapter, parseGenerationModelDeclaration, readGenerationModelDeclaration, readGenerationModelDeclarationsFromDirectory, readGenerationModelDeclarationsFromFiles, resolveGenerationParameters, stringifyBuiltinModelConfig, stringifyGenerationModelDeclaration, validateGenerationContent, writeGenerationModelDeclaration, writeGenerationModelDeclarations };
|
|
82
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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":";;;iBAyLsB,0BAAA,QAAkC,yBAAyB,QAAQ;;;iBClFnE,4BAAA,QAAoC,yBAAyB,QAAQ;;;iBCzFrE,mBAAA,QAA2B,yBAAyB,QAAQ;;;cCRrE,2BAA2B,eAAe;iBAMvC,oBAAA,0BAEJ,eAAe,qBACxB;;;iBCea,sBAAA,WAAgC,gCAAqC;iBA2D/D,+BAAA,gCAEX,KAAK,2CACb,QAAQ;AJ6FW,iBIxFA,mCAAA,CJwF0B,SAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EItFrC,IJsFqC,CItFhC,6BJsFgC,EAAA,QAAA,CAAA,CAAA,EIrF7C,OJqF6C,CIrFrC,gBJqFqC,CAAA;AAAQ,iBIhFlC,8BAAA,CJgFkC,QAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EI9E7C,IJ8E6C,CI9ExC,6BJ8EwC,EAAA,QAAA,CAAA,CAAA,EI7ErD,OJ6EqD,CI7E7C,gBJ6E6C,CAAA;;;iBKvKxC,4BAAA,2BAAuD;iBAmBvD,+BAAA,sCAA2E;ALoJrE,iBK9IN,mCAAA,CL8IgC,WAAA,EK7IjC,0BL6IiC,EAAA,OAAyC,CAAzC,EAAA;EAAQ,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA;CAAiC,CAAA,EAAA,MAAA;AAAR,iBKrI3D,8BAAA,CLqI2D,QAAA,EAAA,MAAA,CAAA,EKrIT,OLqIS,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