@shop-os/modelkit 0.2.19 → 0.2.20
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/CHANGELOG.md +14 -0
- package/dist/catalog.cjs +281 -161
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +25 -1
- package/dist/catalog.d.ts +25 -1
- package/dist/catalog.js +281 -161
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +380 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +380 -268
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -173,7 +173,9 @@ function geminiImage(id, label, aliases, sizes, display, exposure, references) {
|
|
|
173
173
|
const constraints = {
|
|
174
174
|
aspectRatios: [...GEMINI_RATIOS],
|
|
175
175
|
sizes,
|
|
176
|
-
supports: ["safetySettings", "temperature"]
|
|
176
|
+
supports: ["safetySettings", "temperature"],
|
|
177
|
+
// google-image sends MediaRef.label as a text part beside each reference.
|
|
178
|
+
prompt: { referenceSyntax: "caption" }
|
|
177
179
|
};
|
|
178
180
|
if (references !== void 0) constraints.references = references;
|
|
179
181
|
const model = {
|
|
@@ -460,6 +462,7 @@ var IMAGE_MODELS = [
|
|
|
460
462
|
constraints: {
|
|
461
463
|
aspectRatios: ["1:1", "2:3", "3:2", "16:9", "9:16", "4:3", "3:4", "4:5", "5:4", "21:9"],
|
|
462
464
|
sizes: ["1K"],
|
|
465
|
+
references: { images: 8 },
|
|
463
466
|
// flux-2-pro's job type always returns image/png; only the seed is forwarded.
|
|
464
467
|
supports: ["seed"]
|
|
465
468
|
},
|
|
@@ -1283,7 +1286,8 @@ var VIDEO_MODELS = [
|
|
|
1283
1286
|
resolutions: ["720p", "1080p", "4k"],
|
|
1284
1287
|
durations: [8],
|
|
1285
1288
|
references: { images: 3 },
|
|
1286
|
-
supports: ["lastFrame", "seed"]
|
|
1289
|
+
supports: ["lastFrame", "seed"],
|
|
1290
|
+
audio: "always"
|
|
1287
1291
|
},
|
|
1288
1292
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
1289
1293
|
usage: { ...VIDEO_USAGE, slug: "veo" },
|
|
@@ -1313,7 +1317,8 @@ var VIDEO_MODELS = [
|
|
|
1313
1317
|
resolutions: ["720p", "1080p", "4k"],
|
|
1314
1318
|
durations: [4, 6, 8],
|
|
1315
1319
|
references: { images: 3 },
|
|
1316
|
-
supports: ["lastFrame", "seed"]
|
|
1320
|
+
supports: ["lastFrame", "seed"],
|
|
1321
|
+
audio: "always"
|
|
1317
1322
|
},
|
|
1318
1323
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
1319
1324
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1341,7 +1346,8 @@ var VIDEO_MODELS = [
|
|
|
1341
1346
|
aspectRatios: [...OMNI_RATIOS],
|
|
1342
1347
|
resolutions: ["720p", "1080p"],
|
|
1343
1348
|
durations: [4, 6, 8],
|
|
1344
|
-
supports: ["lastFrame", "seed"]
|
|
1349
|
+
supports: ["lastFrame", "seed"],
|
|
1350
|
+
audio: "always"
|
|
1345
1351
|
},
|
|
1346
1352
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
1347
1353
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1375,7 +1381,10 @@ var VIDEO_MODELS = [
|
|
|
1375
1381
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1376
1382
|
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
1377
1383
|
sourceVideoSeconds: { max: 10 },
|
|
1378
|
-
supports: []
|
|
1384
|
+
supports: [],
|
|
1385
|
+
// generateOmniVideo sends MediaRef.label as a text part beside each image.
|
|
1386
|
+
prompt: { referenceSyntax: "caption" },
|
|
1387
|
+
audio: "always"
|
|
1379
1388
|
},
|
|
1380
1389
|
defaults: {},
|
|
1381
1390
|
usage: { ...VIDEO_USAGE, slug: "gemini_omni" },
|
|
@@ -1409,7 +1418,10 @@ var VIDEO_MODELS = [
|
|
|
1409
1418
|
// chain by `previousInteractionId` (the API rejects the id together
|
|
1410
1419
|
// with a video task, so those calls carry the prompt alone).
|
|
1411
1420
|
supports: ["videoExtension"],
|
|
1412
|
-
extension: { segmentSeconds: 10, maxTotalSeconds: 40 }
|
|
1421
|
+
extension: { segmentSeconds: 10, maxTotalSeconds: 40 },
|
|
1422
|
+
// generateOmniVideo sends MediaRef.label as a text part beside each image.
|
|
1423
|
+
prompt: { referenceSyntax: "caption" },
|
|
1424
|
+
audio: "always"
|
|
1413
1425
|
},
|
|
1414
1426
|
defaults: {},
|
|
1415
1427
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1445,7 +1457,8 @@ var VIDEO_MODELS = [
|
|
|
1445
1457
|
},
|
|
1446
1458
|
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1447
1459
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1448
|
-
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1460
|
+
supports: ["generateAudio", "seed", "lastFrame", "watermark"],
|
|
1461
|
+
audio: "optional"
|
|
1449
1462
|
},
|
|
1450
1463
|
defaults: {
|
|
1451
1464
|
durationSeconds: 5,
|
|
@@ -1484,7 +1497,8 @@ var VIDEO_MODELS = [
|
|
|
1484
1497
|
},
|
|
1485
1498
|
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1486
1499
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1487
|
-
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1500
|
+
supports: ["generateAudio", "seed", "lastFrame", "watermark"],
|
|
1501
|
+
audio: "optional"
|
|
1488
1502
|
},
|
|
1489
1503
|
defaults: {
|
|
1490
1504
|
durationSeconds: 5,
|
|
@@ -1524,7 +1538,8 @@ var VIDEO_MODELS = [
|
|
|
1524
1538
|
},
|
|
1525
1539
|
sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
|
|
1526
1540
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1527
|
-
supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
|
|
1541
|
+
supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"],
|
|
1542
|
+
audio: "optional"
|
|
1528
1543
|
},
|
|
1529
1544
|
defaults: {
|
|
1530
1545
|
durationSeconds: 5,
|
|
@@ -1557,7 +1572,9 @@ var VIDEO_MODELS = [
|
|
|
1557
1572
|
durations: { min: 1, max: 15 },
|
|
1558
1573
|
durationPresets: [4, 6, 8, 10],
|
|
1559
1574
|
references: { images: 5 },
|
|
1560
|
-
supports: []
|
|
1575
|
+
supports: [],
|
|
1576
|
+
// xAI can switch sound off (generate_audio); xai-video.ts never sends it.
|
|
1577
|
+
audio: "always"
|
|
1561
1578
|
},
|
|
1562
1579
|
// No resolution default: xAI picks its own unless the caller asks.
|
|
1563
1580
|
defaults: { durationSeconds: 8, aspectRatio: "16:9" },
|
|
@@ -1583,7 +1600,8 @@ var VIDEO_MODELS = [
|
|
|
1583
1600
|
aspectRatios: [...KLING_RATIOS],
|
|
1584
1601
|
durations: [5, 10],
|
|
1585
1602
|
requires: ["firstFrame"],
|
|
1586
|
-
supports: ["cfgScale", "negativePrompt", "lastFrame"]
|
|
1603
|
+
supports: ["cfgScale", "negativePrompt", "lastFrame"],
|
|
1604
|
+
audio: "never"
|
|
1587
1605
|
},
|
|
1588
1606
|
defaults: {
|
|
1589
1607
|
durationSeconds: 5,
|
|
@@ -1614,7 +1632,9 @@ var VIDEO_MODELS = [
|
|
|
1614
1632
|
aspectRatios: [...KLING_RATIOS],
|
|
1615
1633
|
durations: { min: 3, max: 15 },
|
|
1616
1634
|
requires: ["firstFrame"],
|
|
1617
|
-
supports: ["cfgScale", "negativePrompt", "lastFrame"]
|
|
1635
|
+
supports: ["cfgScale", "negativePrompt", "lastFrame"],
|
|
1636
|
+
// Higgsfield has a `sound` switch (default on); KlingCreate doesn't send it.
|
|
1637
|
+
audio: "always"
|
|
1618
1638
|
},
|
|
1619
1639
|
defaults: {
|
|
1620
1640
|
durationSeconds: 5,
|
|
@@ -1649,7 +1669,8 @@ var VIDEO_MODELS = [
|
|
|
1649
1669
|
resolutions: ["720p", "1080p"],
|
|
1650
1670
|
durations: { min: 3, max: 15 },
|
|
1651
1671
|
references: { images: 7, imagesWithVideo: 4 },
|
|
1652
|
-
supports: ["generateAudio", "lastFrame"]
|
|
1672
|
+
supports: ["generateAudio", "lastFrame"],
|
|
1673
|
+
audio: "optional"
|
|
1653
1674
|
},
|
|
1654
1675
|
defaults: { durationSeconds: 5, aspectRatio: "16:9", generateAudio: false, mode: "pro" },
|
|
1655
1676
|
usage: { unit: "compute_seconds" },
|
|
@@ -1674,7 +1695,8 @@ var VIDEO_MODELS = [
|
|
|
1674
1695
|
aspectRatios: [...H3_RATIOS],
|
|
1675
1696
|
resolutions: ["480p", "768p", "2k", "4k"],
|
|
1676
1697
|
durations: { min: 5, max: 15 },
|
|
1677
|
-
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"]
|
|
1698
|
+
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
|
|
1699
|
+
audio: "always"
|
|
1678
1700
|
},
|
|
1679
1701
|
defaults: {
|
|
1680
1702
|
durationSeconds: 5,
|
|
@@ -1704,7 +1726,8 @@ var VIDEO_MODELS = [
|
|
|
1704
1726
|
aspectRatios: [...H3_RATIOS],
|
|
1705
1727
|
resolutions: ["480p", "768p"],
|
|
1706
1728
|
durations: { min: 5, max: 15 },
|
|
1707
|
-
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"]
|
|
1729
|
+
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
|
|
1730
|
+
audio: "always"
|
|
1708
1731
|
},
|
|
1709
1732
|
defaults: {
|
|
1710
1733
|
durationSeconds: 5,
|
|
@@ -1742,7 +1765,8 @@ var VIDEO_MODELS = [
|
|
|
1742
1765
|
audioOnly: false,
|
|
1743
1766
|
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1744
1767
|
},
|
|
1745
|
-
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1768
|
+
supports: ["seed", "promptExpansion", "safetyChecker"],
|
|
1769
|
+
audio: "always"
|
|
1746
1770
|
},
|
|
1747
1771
|
defaults: {
|
|
1748
1772
|
durationSeconds: 5,
|
|
@@ -1757,7 +1781,9 @@ var VIDEO_MODELS = [
|
|
|
1757
1781
|
logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
|
|
1758
1782
|
description: "MiniMax H3 reference-to-video mode guided by up to 9 reference images, 3 reference videos, and 3 audio clips; reference and image-to-video inputs cannot be mixed."
|
|
1759
1783
|
},
|
|
1760
|
-
|
|
1784
|
+
// fal's reference-to-video endpoint never reads a frame; the resolver must drop the
|
|
1785
|
+
// references instead of the adapter silently dropping the frame.
|
|
1786
|
+
capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
|
|
1761
1787
|
},
|
|
1762
1788
|
{
|
|
1763
1789
|
id: "minimax-h3-max-reference",
|
|
@@ -1780,7 +1806,8 @@ var VIDEO_MODELS = [
|
|
|
1780
1806
|
audioOnly: false,
|
|
1781
1807
|
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1782
1808
|
},
|
|
1783
|
-
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1809
|
+
supports: ["seed", "promptExpansion", "safetyChecker"],
|
|
1810
|
+
audio: "always"
|
|
1784
1811
|
},
|
|
1785
1812
|
defaults: {
|
|
1786
1813
|
durationSeconds: 5,
|
|
@@ -1795,7 +1822,9 @@ var VIDEO_MODELS = [
|
|
|
1795
1822
|
logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
|
|
1796
1823
|
description: "MiniMax H3 Max reference-to-video on fal; conditions on reference images, videos, and audio. MiniMax's own docs do not list a reference mode for H3 Max."
|
|
1797
1824
|
},
|
|
1798
|
-
|
|
1825
|
+
// fal's reference-to-video endpoint never reads a frame; the resolver must drop the
|
|
1826
|
+
// references instead of the adapter silently dropping the frame.
|
|
1827
|
+
capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
|
|
1799
1828
|
},
|
|
1800
1829
|
{
|
|
1801
1830
|
// Duration 3-10s per trigger-workflows mapDuration; the endpoint takes no resolution.
|
|
@@ -1812,7 +1841,8 @@ var VIDEO_MODELS = [
|
|
|
1812
1841
|
durations: { min: 3, max: 10 },
|
|
1813
1842
|
requires: ["sourceVideo"],
|
|
1814
1843
|
sourceVideoSeconds: { min: 3, max: 10.05 },
|
|
1815
|
-
supports: []
|
|
1844
|
+
supports: [],
|
|
1845
|
+
audio: "never"
|
|
1816
1846
|
},
|
|
1817
1847
|
defaults: { durationSeconds: 5, aspectRatio: "16:9" },
|
|
1818
1848
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1836,7 +1866,8 @@ var VIDEO_MODELS = [
|
|
|
1836
1866
|
constraints: {
|
|
1837
1867
|
resolutions: ["768p"],
|
|
1838
1868
|
durations: [6, 10],
|
|
1839
|
-
supports: ["lastFrame"]
|
|
1869
|
+
supports: ["lastFrame"],
|
|
1870
|
+
audio: "never"
|
|
1840
1871
|
},
|
|
1841
1872
|
defaults: { durationSeconds: 6, resolution: "768p" },
|
|
1842
1873
|
usage: { unit: "compute_seconds" },
|
|
@@ -1859,7 +1890,8 @@ var VIDEO_MODELS = [
|
|
|
1859
1890
|
exposure: [],
|
|
1860
1891
|
constraints: {
|
|
1861
1892
|
requires: ["firstFrame"],
|
|
1862
|
-
supports: ["seed", "lastFrame"]
|
|
1893
|
+
supports: ["seed", "lastFrame"],
|
|
1894
|
+
audio: "never"
|
|
1863
1895
|
},
|
|
1864
1896
|
defaults: {},
|
|
1865
1897
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1881,7 +1913,7 @@ var MODELS = [
|
|
|
1881
1913
|
];
|
|
1882
1914
|
|
|
1883
1915
|
// src/catalog/schema.ts
|
|
1884
|
-
import { z as
|
|
1916
|
+
import { z as z3 } from "zod";
|
|
1885
1917
|
|
|
1886
1918
|
// src/catalog/collisions.ts
|
|
1887
1919
|
function collisionIssues(rows) {
|
|
@@ -1928,8 +1960,57 @@ function collisionIssues(rows) {
|
|
|
1928
1960
|
return issues;
|
|
1929
1961
|
}
|
|
1930
1962
|
|
|
1931
|
-
// src/catalog/
|
|
1963
|
+
// src/catalog/conventions.ts
|
|
1932
1964
|
import { z } from "zod";
|
|
1965
|
+
var AudioOutputSchema = z.enum(["always", "optional", "never"]);
|
|
1966
|
+
var ReferenceSyntaxSchema = z.enum(["numbered", "caption", "descriptive"]);
|
|
1967
|
+
var MaxCharsSchema = z.number().int().positive();
|
|
1968
|
+
var PromptConventionsSchema = z.strictObject({
|
|
1969
|
+
referenceSyntax: ReferenceSyntaxSchema,
|
|
1970
|
+
maxChars: MaxCharsSchema.optional()
|
|
1971
|
+
});
|
|
1972
|
+
var AUDIO_OUTPUTS = AudioOutputSchema.options;
|
|
1973
|
+
var REFERENCE_SYNTAXES = ReferenceSyntaxSchema.options;
|
|
1974
|
+
var ConstraintsReadView = z.looseObject({
|
|
1975
|
+
audio: AudioOutputSchema.optional().catch(void 0),
|
|
1976
|
+
prompt: z.looseObject({
|
|
1977
|
+
referenceSyntax: ReferenceSyntaxSchema.catch("numbered"),
|
|
1978
|
+
maxChars: MaxCharsSchema.optional().catch(void 0)
|
|
1979
|
+
}).optional().catch(void 0)
|
|
1980
|
+
});
|
|
1981
|
+
var DEFAULT_CONVENTIONS = { referenceSyntax: "numbered" };
|
|
1982
|
+
function promptConventions(row) {
|
|
1983
|
+
const view = ConstraintsReadView.safeParse(row.constraints);
|
|
1984
|
+
const prompt = view.success ? view.data.prompt : void 0;
|
|
1985
|
+
if (prompt === void 0) return { ...DEFAULT_CONVENTIONS };
|
|
1986
|
+
const result = { referenceSyntax: prompt.referenceSyntax };
|
|
1987
|
+
if (prompt.maxChars !== void 0) result.maxChars = prompt.maxChars;
|
|
1988
|
+
return result;
|
|
1989
|
+
}
|
|
1990
|
+
var RawConventionsView = z.looseObject({
|
|
1991
|
+
audio: z.unknown().optional(),
|
|
1992
|
+
prompt: z.unknown().optional()
|
|
1993
|
+
});
|
|
1994
|
+
function normaliseConventions(row) {
|
|
1995
|
+
const view = RawConventionsView.safeParse(row.constraints);
|
|
1996
|
+
if (!view.success) return { row, invalidKeys: [] };
|
|
1997
|
+
const { audio, prompt } = view.data;
|
|
1998
|
+
const badAudio = audio !== void 0 && !AudioOutputSchema.safeParse(audio).success;
|
|
1999
|
+
const badPrompt = prompt !== void 0 && !PromptConventionsSchema.safeParse(prompt).success;
|
|
2000
|
+
if (!badAudio && !badPrompt) return { row, invalidKeys: [] };
|
|
2001
|
+
const invalidKeys = [];
|
|
2002
|
+
if (badAudio) invalidKeys.push("constraints.audio");
|
|
2003
|
+
if (badPrompt) invalidKeys.push("constraints.prompt");
|
|
2004
|
+
const entries = Object.entries(row.constraints).flatMap(([key, value]) => {
|
|
2005
|
+
if (key === "audio" && badAudio) return [];
|
|
2006
|
+
if (key === "prompt" && badPrompt) return [[key, promptConventions(row)]];
|
|
2007
|
+
return [[key, value]];
|
|
2008
|
+
});
|
|
2009
|
+
return { row: { ...row, constraints: Object.fromEntries(entries) }, invalidKeys };
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
// src/catalog/input-spec.ts
|
|
2013
|
+
import { z as z2 } from "zod";
|
|
1933
2014
|
var VIDEO_INPUT_SPEC_KEYS = [
|
|
1934
2015
|
"prompt",
|
|
1935
2016
|
"durationSeconds",
|
|
@@ -1968,8 +2049,8 @@ var ALL_KEY_SET = /* @__PURE__ */ new Set([
|
|
|
1968
2049
|
...VIDEO_INPUT_SPEC_KEYS,
|
|
1969
2050
|
...AUDIO_INPUT_SPEC_KEYS
|
|
1970
2051
|
]);
|
|
1971
|
-
var ProviderScalarSchema =
|
|
1972
|
-
var FieldsSchema =
|
|
2052
|
+
var ProviderScalarSchema = z2.union([z2.string(), z2.number(), z2.boolean()]);
|
|
2053
|
+
var FieldsSchema = z2.record(z2.string(), z2.string().min(1)).superRefine((fields, ctx) => {
|
|
1973
2054
|
const keys = Object.keys(fields);
|
|
1974
2055
|
if (keys.length === 0) {
|
|
1975
2056
|
ctx.addIssue({
|
|
@@ -1987,7 +2068,7 @@ var FieldsSchema = z.record(z.string(), z.string().min(1)).superRefine((fields,
|
|
|
1987
2068
|
}
|
|
1988
2069
|
}
|
|
1989
2070
|
});
|
|
1990
|
-
var ValuesSchema =
|
|
2071
|
+
var ValuesSchema = z2.record(z2.string(), z2.record(z2.string(), ProviderScalarSchema)).superRefine((values, ctx) => {
|
|
1991
2072
|
for (const key of Object.keys(values)) {
|
|
1992
2073
|
if (!ALL_KEY_SET.has(key)) {
|
|
1993
2074
|
ctx.addIssue({
|
|
@@ -1997,8 +2078,8 @@ var ValuesSchema = z.record(z.string(), z.record(z.string(), ProviderScalarSchem
|
|
|
1997
2078
|
}
|
|
1998
2079
|
}
|
|
1999
2080
|
});
|
|
2000
|
-
var StaticSchema =
|
|
2001
|
-
var InputSpecSchema =
|
|
2081
|
+
var StaticSchema = z2.record(z2.string(), ProviderScalarSchema);
|
|
2082
|
+
var InputSpecSchema = z2.strictObject({
|
|
2002
2083
|
fields: FieldsSchema,
|
|
2003
2084
|
values: ValuesSchema.optional(),
|
|
2004
2085
|
static: StaticSchema.optional()
|
|
@@ -2105,16 +2186,16 @@ var ADAPTER_IDS = [
|
|
|
2105
2186
|
"higgsfield",
|
|
2106
2187
|
"xai-video"
|
|
2107
2188
|
];
|
|
2108
|
-
var ModelTypeSchema =
|
|
2109
|
-
var LifecycleSchema =
|
|
2110
|
-
var SurfaceSchema =
|
|
2189
|
+
var ModelTypeSchema = z3.enum(["text", "image", "video", "audio", "upscale", "bg-remove"]);
|
|
2190
|
+
var LifecycleSchema = z3.enum(["active", "deprecated", "retired"]);
|
|
2191
|
+
var SurfaceSchema = z3.enum(["cowork", "space_builder"]);
|
|
2111
2192
|
var SURFACES2 = SurfaceSchema.options;
|
|
2112
|
-
var ExposureSchema =
|
|
2193
|
+
var ExposureSchema = z3.preprocess(
|
|
2113
2194
|
normalizeExposure,
|
|
2114
|
-
|
|
2195
|
+
z3.array(SurfaceSchema)
|
|
2115
2196
|
);
|
|
2116
|
-
var AdapterSchema =
|
|
2117
|
-
var AspectRatioSchema =
|
|
2197
|
+
var AdapterSchema = z3.enum(ADAPTER_IDS);
|
|
2198
|
+
var AspectRatioSchema = z3.enum([
|
|
2118
2199
|
"1:1",
|
|
2119
2200
|
"16:9",
|
|
2120
2201
|
"9:16",
|
|
@@ -2129,12 +2210,12 @@ var AspectRatioSchema = z2.enum([
|
|
|
2129
2210
|
"97:30",
|
|
2130
2211
|
"adaptive"
|
|
2131
2212
|
]);
|
|
2132
|
-
var ImageSizeSchema =
|
|
2133
|
-
var VideoResolutionSchema =
|
|
2134
|
-
var ImageQualitySchema =
|
|
2135
|
-
var OutputFormatSchema =
|
|
2136
|
-
var RequiredInputSchema =
|
|
2137
|
-
var SupportedOptionSchema =
|
|
2213
|
+
var ImageSizeSchema = z3.enum(["512", "1K", "2K", "4K"]);
|
|
2214
|
+
var VideoResolutionSchema = z3.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
|
|
2215
|
+
var ImageQualitySchema = z3.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
|
|
2216
|
+
var OutputFormatSchema = z3.enum(["png", "jpeg", "webp"]);
|
|
2217
|
+
var RequiredInputSchema = z3.enum(["firstFrame", "sourceVideo", "references"]);
|
|
2218
|
+
var SupportedOptionSchema = z3.enum([
|
|
2138
2219
|
"seed",
|
|
2139
2220
|
"quality",
|
|
2140
2221
|
"negativePrompt",
|
|
@@ -2154,142 +2235,146 @@ var SupportedOptionSchema = z2.enum([
|
|
|
2154
2235
|
"videoExtension",
|
|
2155
2236
|
"instrumental"
|
|
2156
2237
|
]);
|
|
2157
|
-
var UsageUnitSchema =
|
|
2238
|
+
var UsageUnitSchema = z3.enum([
|
|
2158
2239
|
"tokens",
|
|
2159
2240
|
"images",
|
|
2160
2241
|
"seconds",
|
|
2161
2242
|
"reported_cost_usd",
|
|
2162
2243
|
"compute_seconds"
|
|
2163
2244
|
]);
|
|
2164
|
-
var PricingKindSchema =
|
|
2165
|
-
var ProviderOptionValueSchema =
|
|
2166
|
-
() =>
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2245
|
+
var PricingKindSchema = z3.enum(["token", "image_size", "video_per_second", "flat"]);
|
|
2246
|
+
var ProviderOptionValueSchema = z3.lazy(
|
|
2247
|
+
() => z3.union([
|
|
2248
|
+
z3.string(),
|
|
2249
|
+
z3.number(),
|
|
2250
|
+
z3.boolean(),
|
|
2251
|
+
z3.array(ProviderOptionValueSchema),
|
|
2252
|
+
z3.record(z3.string(), ProviderOptionValueSchema)
|
|
2172
2253
|
])
|
|
2173
2254
|
);
|
|
2174
|
-
var ProviderOptionsSchema =
|
|
2175
|
-
var VideoSecondsLimitsSchema =
|
|
2176
|
-
min:
|
|
2177
|
-
max:
|
|
2178
|
-
total:
|
|
2179
|
-
editMin:
|
|
2255
|
+
var ProviderOptionsSchema = z3.record(z3.string(), z3.record(z3.string(), ProviderOptionValueSchema));
|
|
2256
|
+
var VideoSecondsLimitsSchema = z3.looseObject({
|
|
2257
|
+
min: z3.number().optional(),
|
|
2258
|
+
max: z3.number().optional(),
|
|
2259
|
+
total: z3.number().optional(),
|
|
2260
|
+
editMin: z3.number().optional()
|
|
2180
2261
|
});
|
|
2181
|
-
var ReferenceLimitsSchema =
|
|
2182
|
-
images:
|
|
2183
|
-
imagesWithVideo:
|
|
2184
|
-
videos:
|
|
2185
|
-
audios:
|
|
2186
|
-
total:
|
|
2187
|
-
audioOnly:
|
|
2262
|
+
var ReferenceLimitsSchema = z3.looseObject({
|
|
2263
|
+
images: z3.number().optional(),
|
|
2264
|
+
imagesWithVideo: z3.number().optional(),
|
|
2265
|
+
videos: z3.number().optional(),
|
|
2266
|
+
audios: z3.number().optional(),
|
|
2267
|
+
total: z3.number().optional(),
|
|
2268
|
+
audioOnly: z3.boolean().optional(),
|
|
2188
2269
|
videoSeconds: VideoSecondsLimitsSchema.optional()
|
|
2189
2270
|
});
|
|
2190
|
-
var ModelConstraintsSchema =
|
|
2191
|
-
aspectRatios:
|
|
2192
|
-
sizes:
|
|
2193
|
-
resolutions:
|
|
2194
|
-
durations:
|
|
2195
|
-
durationPresets:
|
|
2196
|
-
qualityOptions:
|
|
2197
|
-
exactSizes:
|
|
2271
|
+
var ModelConstraintsSchema = z3.looseObject({
|
|
2272
|
+
aspectRatios: z3.array(AspectRatioSchema).optional(),
|
|
2273
|
+
sizes: z3.array(ImageSizeSchema).optional(),
|
|
2274
|
+
resolutions: z3.array(VideoResolutionSchema).optional(),
|
|
2275
|
+
durations: z3.union([z3.looseObject({ min: z3.number(), max: z3.number() }), z3.array(z3.number())]).optional(),
|
|
2276
|
+
durationPresets: z3.array(z3.number()).optional(),
|
|
2277
|
+
qualityOptions: z3.array(z3.string()).optional(),
|
|
2278
|
+
exactSizes: z3.record(z3.string(), z3.string()).optional(),
|
|
2198
2279
|
references: ReferenceLimitsSchema.optional(),
|
|
2199
|
-
requires:
|
|
2200
|
-
supports:
|
|
2201
|
-
ratioIgnoredWith:
|
|
2202
|
-
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal:
|
|
2203
|
-
extension:
|
|
2280
|
+
requires: z3.array(RequiredInputSchema).optional(),
|
|
2281
|
+
supports: z3.array(SupportedOptionSchema).optional(),
|
|
2282
|
+
ratioIgnoredWith: z3.array(z3.enum(["firstFrame", "sourceVideo"])).optional(),
|
|
2283
|
+
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: z3.boolean().optional() }).optional(),
|
|
2284
|
+
extension: z3.looseObject({ segmentSeconds: z3.number(), maxTotalSeconds: z3.number() }).optional(),
|
|
2285
|
+
// Loose on purpose: the read path keeps a row whose value is invalid (the accessors in
|
|
2286
|
+
// conventions.ts read it as "not set"); CatalogModelSchema below rejects it on write.
|
|
2287
|
+
audio: z3.unknown().optional(),
|
|
2288
|
+
prompt: z3.unknown().optional()
|
|
2204
2289
|
});
|
|
2205
|
-
var MediaRefSchema =
|
|
2206
|
-
|
|
2207
|
-
url:
|
|
2208
|
-
label:
|
|
2209
|
-
durationSeconds:
|
|
2290
|
+
var MediaRefSchema = z3.union([
|
|
2291
|
+
z3.looseObject({
|
|
2292
|
+
url: z3.string(),
|
|
2293
|
+
label: z3.string().optional(),
|
|
2294
|
+
durationSeconds: z3.number().optional()
|
|
2210
2295
|
}),
|
|
2211
|
-
|
|
2212
|
-
bytes:
|
|
2213
|
-
mime:
|
|
2214
|
-
label:
|
|
2215
|
-
durationSeconds:
|
|
2296
|
+
z3.looseObject({
|
|
2297
|
+
bytes: z3.instanceof(Uint8Array),
|
|
2298
|
+
mime: z3.string(),
|
|
2299
|
+
label: z3.string().optional(),
|
|
2300
|
+
durationSeconds: z3.number().optional()
|
|
2216
2301
|
})
|
|
2217
2302
|
]);
|
|
2218
|
-
var ImageSafetySettingSchema =
|
|
2219
|
-
var UpscaleOptionsSchema =
|
|
2220
|
-
enhanceModel:
|
|
2221
|
-
subjectDetection:
|
|
2222
|
-
faceEnhancement:
|
|
2223
|
-
faceEnhancementCreativity:
|
|
2224
|
-
faceEnhancementStrength:
|
|
2303
|
+
var ImageSafetySettingSchema = z3.looseObject({ category: z3.string(), threshold: z3.string() });
|
|
2304
|
+
var UpscaleOptionsSchema = z3.looseObject({
|
|
2305
|
+
enhanceModel: z3.string().optional(),
|
|
2306
|
+
subjectDetection: z3.string().optional(),
|
|
2307
|
+
faceEnhancement: z3.boolean().optional(),
|
|
2308
|
+
faceEnhancementCreativity: z3.number().optional(),
|
|
2309
|
+
faceEnhancementStrength: z3.number().optional()
|
|
2225
2310
|
});
|
|
2226
|
-
var DefaultsSchema =
|
|
2227
|
-
references:
|
|
2311
|
+
var DefaultsSchema = z3.looseObject({
|
|
2312
|
+
references: z3.array(MediaRefSchema).optional(),
|
|
2228
2313
|
aspectRatio: AspectRatioSchema.optional(),
|
|
2229
2314
|
size: ImageSizeSchema.optional(),
|
|
2230
|
-
exactSize:
|
|
2315
|
+
exactSize: z3.string().optional(),
|
|
2231
2316
|
quality: ImageQualitySchema.optional(),
|
|
2232
|
-
seed:
|
|
2233
|
-
count:
|
|
2317
|
+
seed: z3.number().optional(),
|
|
2318
|
+
count: z3.number().optional(),
|
|
2234
2319
|
outputFormat: OutputFormatSchema.optional(),
|
|
2235
|
-
scaleFactor:
|
|
2236
|
-
safetySettings:
|
|
2237
|
-
temperature:
|
|
2320
|
+
scaleFactor: z3.number().optional(),
|
|
2321
|
+
safetySettings: z3.array(ImageSafetySettingSchema).optional(),
|
|
2322
|
+
temperature: z3.number().optional(),
|
|
2238
2323
|
upscale: UpscaleOptionsSchema.optional(),
|
|
2239
2324
|
firstFrame: MediaRefSchema.optional(),
|
|
2240
2325
|
lastFrame: MediaRefSchema.optional(),
|
|
2241
2326
|
sourceVideo: MediaRefSchema.optional(),
|
|
2242
|
-
referenceImages:
|
|
2243
|
-
referenceVideos:
|
|
2244
|
-
referenceAudios:
|
|
2327
|
+
referenceImages: z3.array(MediaRefSchema).optional(),
|
|
2328
|
+
referenceVideos: z3.array(MediaRefSchema).optional(),
|
|
2329
|
+
referenceAudios: z3.array(MediaRefSchema).optional(),
|
|
2245
2330
|
resolution: VideoResolutionSchema.optional(),
|
|
2246
|
-
durationSeconds:
|
|
2247
|
-
generateAudio:
|
|
2248
|
-
negativePrompt:
|
|
2249
|
-
cfgScale:
|
|
2250
|
-
promptExpansion:
|
|
2251
|
-
watermark:
|
|
2252
|
-
safetyChecker:
|
|
2253
|
-
taskType:
|
|
2254
|
-
mode:
|
|
2255
|
-
instrumental:
|
|
2331
|
+
durationSeconds: z3.number().optional(),
|
|
2332
|
+
generateAudio: z3.boolean().optional(),
|
|
2333
|
+
negativePrompt: z3.string().optional(),
|
|
2334
|
+
cfgScale: z3.number().optional(),
|
|
2335
|
+
promptExpansion: z3.enum(["fast", "balanced", "quality"]).optional(),
|
|
2336
|
+
watermark: z3.boolean().optional(),
|
|
2337
|
+
safetyChecker: z3.boolean().optional(),
|
|
2338
|
+
taskType: z3.enum(["reference", "edit", "extend"]).optional(),
|
|
2339
|
+
mode: z3.enum(["standard", "pro"]).optional(),
|
|
2340
|
+
instrumental: z3.boolean().optional()
|
|
2256
2341
|
});
|
|
2257
|
-
var CatalogDisplaySchema =
|
|
2258
|
-
provider:
|
|
2259
|
-
description:
|
|
2260
|
-
logo:
|
|
2261
|
-
costTier:
|
|
2262
|
-
recommended:
|
|
2263
|
-
sortOrder:
|
|
2264
|
-
chat:
|
|
2342
|
+
var CatalogDisplaySchema = z3.looseObject({
|
|
2343
|
+
provider: z3.string(),
|
|
2344
|
+
description: z3.string(),
|
|
2345
|
+
logo: z3.string().optional(),
|
|
2346
|
+
costTier: z3.union([z3.literal(1), z3.literal(2), z3.literal(3)]).optional(),
|
|
2347
|
+
recommended: z3.boolean().optional(),
|
|
2348
|
+
sortOrder: z3.number().optional(),
|
|
2349
|
+
chat: z3.looseObject({
|
|
2265
2350
|
providerOptions: ProviderOptionsSchema.optional(),
|
|
2266
|
-
temperature:
|
|
2351
|
+
temperature: z3.number().optional()
|
|
2267
2352
|
}).optional()
|
|
2268
2353
|
});
|
|
2269
|
-
var CatalogCapabilitiesSchema =
|
|
2270
|
-
acceptsSourceVideo:
|
|
2271
|
-
framesExcludeReferences:
|
|
2272
|
-
reasoning:
|
|
2273
|
-
vision:
|
|
2274
|
-
contextWindow:
|
|
2354
|
+
var CatalogCapabilitiesSchema = z3.looseObject({
|
|
2355
|
+
acceptsSourceVideo: z3.boolean().optional(),
|
|
2356
|
+
framesExcludeReferences: z3.boolean().optional(),
|
|
2357
|
+
reasoning: z3.boolean().optional(),
|
|
2358
|
+
vision: z3.boolean().optional(),
|
|
2359
|
+
contextWindow: z3.number().optional()
|
|
2275
2360
|
});
|
|
2276
|
-
var CatalogModelSchemaBase =
|
|
2277
|
-
id:
|
|
2278
|
-
aliases:
|
|
2279
|
-
label:
|
|
2361
|
+
var CatalogModelSchemaBase = z3.looseObject({
|
|
2362
|
+
id: z3.string().min(1),
|
|
2363
|
+
aliases: z3.array(z3.string()).default([]),
|
|
2364
|
+
label: z3.string().min(1),
|
|
2280
2365
|
type: ModelTypeSchema,
|
|
2281
2366
|
adapter: AdapterSchema,
|
|
2282
|
-
providerModelId:
|
|
2367
|
+
providerModelId: z3.string().min(1),
|
|
2283
2368
|
lifecycle: LifecycleSchema,
|
|
2284
|
-
replacedBy:
|
|
2369
|
+
replacedBy: z3.string().optional(),
|
|
2285
2370
|
exposure: ExposureSchema,
|
|
2286
2371
|
constraints: ModelConstraintsSchema,
|
|
2287
2372
|
defaults: DefaultsSchema,
|
|
2288
2373
|
providerOptions: ProviderOptionsSchema.optional(),
|
|
2289
|
-
usage:
|
|
2374
|
+
usage: z3.looseObject({
|
|
2290
2375
|
unit: UsageUnitSchema,
|
|
2291
|
-
slug:
|
|
2292
|
-
providerLabel:
|
|
2376
|
+
slug: z3.string().optional(),
|
|
2377
|
+
providerLabel: z3.string().optional()
|
|
2293
2378
|
}),
|
|
2294
2379
|
pricingKind: PricingKindSchema,
|
|
2295
2380
|
display: CatalogDisplaySchema.optional(),
|
|
@@ -2340,9 +2425,30 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
|
2340
2425
|
}
|
|
2341
2426
|
}
|
|
2342
2427
|
}
|
|
2428
|
+
const audio = row.constraints.audio;
|
|
2429
|
+
if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
|
|
2430
|
+
ctx.addIssue({
|
|
2431
|
+
code: "custom",
|
|
2432
|
+
path: ["constraints", "audio"],
|
|
2433
|
+
message: 'audio must be "always", "optional" or "never"'
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
const prompt = row.constraints.prompt;
|
|
2437
|
+
if (prompt !== void 0) {
|
|
2438
|
+
const parsed = PromptConventionsSchema.safeParse(prompt);
|
|
2439
|
+
if (!parsed.success) {
|
|
2440
|
+
for (const issue of parsed.error.issues) {
|
|
2441
|
+
ctx.addIssue({
|
|
2442
|
+
code: "custom",
|
|
2443
|
+
path: ["constraints", "prompt", ...issue.path.map(String)],
|
|
2444
|
+
message: issue.message
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2343
2449
|
}
|
|
2344
2450
|
);
|
|
2345
|
-
var CatalogSchema =
|
|
2451
|
+
var CatalogSchema = z3.array(CatalogModelSchemaBase.transform((row) => normaliseConventions(row).row)).superRefine((rows, ctx) => {
|
|
2346
2452
|
for (const issue of collisionIssues(rows)) {
|
|
2347
2453
|
ctx.addIssue({
|
|
2348
2454
|
code: "custom",
|
|
@@ -2363,7 +2469,7 @@ import { createXai } from "@ai-sdk/xai";
|
|
|
2363
2469
|
import { createDeepSeek } from "@ai-sdk/deepseek";
|
|
2364
2470
|
import { createMoonshotAI } from "@ai-sdk/moonshotai";
|
|
2365
2471
|
import { extractReasoningMiddleware, wrapLanguageModel } from "ai";
|
|
2366
|
-
import { z as
|
|
2472
|
+
import { z as z4 } from "zod";
|
|
2367
2473
|
var TEXT_PROVIDERS = [
|
|
2368
2474
|
"openai",
|
|
2369
2475
|
"anthropic",
|
|
@@ -2374,7 +2480,7 @@ var TEXT_PROVIDERS = [
|
|
|
2374
2480
|
"moonshot",
|
|
2375
2481
|
"minimax"
|
|
2376
2482
|
];
|
|
2377
|
-
var textProviderSchema =
|
|
2483
|
+
var textProviderSchema = z4.enum(TEXT_PROVIDERS);
|
|
2378
2484
|
function isTextProvider(value) {
|
|
2379
2485
|
return textProviderSchema.safeParse(value).success;
|
|
2380
2486
|
}
|
|
@@ -2667,24 +2773,24 @@ var aiSdkTextAdapter = {
|
|
|
2667
2773
|
};
|
|
2668
2774
|
|
|
2669
2775
|
// src/adapters/ark.ts
|
|
2670
|
-
import { z as
|
|
2776
|
+
import { z as z7 } from "zod";
|
|
2671
2777
|
|
|
2672
2778
|
// src/retry.ts
|
|
2673
|
-
import { z as
|
|
2779
|
+
import { z as z6 } from "zod";
|
|
2674
2780
|
|
|
2675
2781
|
// src/json.ts
|
|
2676
|
-
import { z as
|
|
2677
|
-
var JsonValueSchema =
|
|
2678
|
-
() =>
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2782
|
+
import { z as z5 } from "zod";
|
|
2783
|
+
var JsonValueSchema = z5.lazy(
|
|
2784
|
+
() => z5.union([
|
|
2785
|
+
z5.string(),
|
|
2786
|
+
z5.number(),
|
|
2787
|
+
z5.boolean(),
|
|
2788
|
+
z5.null(),
|
|
2789
|
+
z5.array(JsonValueSchema),
|
|
2790
|
+
z5.record(z5.string(), JsonValueSchema)
|
|
2685
2791
|
])
|
|
2686
2792
|
);
|
|
2687
|
-
var JsonObjectSchema =
|
|
2793
|
+
var JsonObjectSchema = z5.record(z5.string(), JsonValueSchema);
|
|
2688
2794
|
async function readErrorBody(res) {
|
|
2689
2795
|
const text2 = await res.text().catch(() => "");
|
|
2690
2796
|
try {
|
|
@@ -2693,11 +2799,11 @@ async function readErrorBody(res) {
|
|
|
2693
2799
|
return text2;
|
|
2694
2800
|
}
|
|
2695
2801
|
}
|
|
2696
|
-
var thrownErrorSchema =
|
|
2697
|
-
message:
|
|
2698
|
-
status:
|
|
2699
|
-
statusCode:
|
|
2700
|
-
responseBody:
|
|
2802
|
+
var thrownErrorSchema = z5.object({
|
|
2803
|
+
message: z5.string().optional(),
|
|
2804
|
+
status: z5.number().optional(),
|
|
2805
|
+
statusCode: z5.number().optional(),
|
|
2806
|
+
responseBody: z5.string().optional()
|
|
2701
2807
|
});
|
|
2702
2808
|
function describeThrown(cause) {
|
|
2703
2809
|
const parsed = thrownErrorSchema.safeParse(cause);
|
|
@@ -2708,7 +2814,7 @@ function describeThrown(cause) {
|
|
|
2708
2814
|
}
|
|
2709
2815
|
|
|
2710
2816
|
// src/retry.ts
|
|
2711
|
-
var textBody =
|
|
2817
|
+
var textBody = z6.string();
|
|
2712
2818
|
function classifyHttpError(status, body, provider, model) {
|
|
2713
2819
|
const asText = textBody.safeParse(body);
|
|
2714
2820
|
const text2 = asText.success ? asText.data : JSON.stringify(body);
|
|
@@ -2967,7 +3073,7 @@ function arkKey(ctx) {
|
|
|
2967
3073
|
return key;
|
|
2968
3074
|
}
|
|
2969
3075
|
function throwArkError(status, body, model) {
|
|
2970
|
-
const parsed =
|
|
3076
|
+
const parsed = z7.string().safeParse(body);
|
|
2971
3077
|
const text2 = parsed.success ? parsed.data : JSON.stringify(body ?? "");
|
|
2972
3078
|
if (/sensitive.?content|human.?face/i.test(text2)) {
|
|
2973
3079
|
const init = {
|
|
@@ -3005,13 +3111,13 @@ function sniffedImageMime(bytes) {
|
|
|
3005
3111
|
return "image/webp";
|
|
3006
3112
|
return "image/jpeg";
|
|
3007
3113
|
}
|
|
3008
|
-
var SeedreamImageSchema =
|
|
3009
|
-
url:
|
|
3010
|
-
b64_json:
|
|
3114
|
+
var SeedreamImageSchema = z7.object({
|
|
3115
|
+
url: z7.string().optional(),
|
|
3116
|
+
b64_json: z7.string().optional()
|
|
3011
3117
|
});
|
|
3012
|
-
var SeedreamResponseSchema =
|
|
3013
|
-
data:
|
|
3014
|
-
error:
|
|
3118
|
+
var SeedreamResponseSchema = z7.object({
|
|
3119
|
+
data: z7.array(SeedreamImageSchema).optional(),
|
|
3120
|
+
error: z7.object({ message: z7.string().optional(), code: z7.string().optional() }).optional()
|
|
3015
3121
|
});
|
|
3016
3122
|
function fetchInitFor(ctx, init) {
|
|
3017
3123
|
if (ctx.signal !== void 0) init.signal = ctx.signal;
|
|
@@ -3093,21 +3199,21 @@ async function generateSeedreamImage(req, ctx) {
|
|
|
3093
3199
|
if (req.quality !== void 0) usage2.imageQuality = req.quality;
|
|
3094
3200
|
return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage: usage2, raw: data };
|
|
3095
3201
|
}
|
|
3096
|
-
var SeedanceUsageSchema =
|
|
3097
|
-
total_tokens:
|
|
3098
|
-
completion_tokens:
|
|
3202
|
+
var SeedanceUsageSchema = z7.object({
|
|
3203
|
+
total_tokens: z7.number().optional(),
|
|
3204
|
+
completion_tokens: z7.number().optional()
|
|
3099
3205
|
});
|
|
3100
|
-
var SeedanceResponseSchema =
|
|
3101
|
-
id:
|
|
3102
|
-
status:
|
|
3103
|
-
content:
|
|
3206
|
+
var SeedanceResponseSchema = z7.object({
|
|
3207
|
+
id: z7.string().optional(),
|
|
3208
|
+
status: z7.string().optional(),
|
|
3209
|
+
content: z7.object({ video_url: z7.string().optional() }).optional(),
|
|
3104
3210
|
usage: SeedanceUsageSchema.optional(),
|
|
3105
|
-
duration:
|
|
3106
|
-
framespersecond:
|
|
3107
|
-
resolution:
|
|
3108
|
-
error:
|
|
3211
|
+
duration: z7.number().optional(),
|
|
3212
|
+
framespersecond: z7.number().optional(),
|
|
3213
|
+
resolution: z7.string().optional(),
|
|
3214
|
+
error: z7.union([z7.string(), z7.object({ message: z7.string().optional() })]).optional()
|
|
3109
3215
|
});
|
|
3110
|
-
var SeedanceErrorMessageSchema =
|
|
3216
|
+
var SeedanceErrorMessageSchema = z7.object({ message: z7.string().optional() });
|
|
3111
3217
|
function seedanceUsage(ctx, req, duration) {
|
|
3112
3218
|
const usage2 = {
|
|
3113
3219
|
model: ctx.model.id,
|
|
@@ -3121,7 +3227,7 @@ function seedanceUsage(ctx, req, duration) {
|
|
|
3121
3227
|
return usage2;
|
|
3122
3228
|
}
|
|
3123
3229
|
function seedanceErrorMessage(error, status) {
|
|
3124
|
-
const asString =
|
|
3230
|
+
const asString = z7.string().safeParse(error);
|
|
3125
3231
|
if (asString.success) return asString.data;
|
|
3126
3232
|
const asObject = SeedanceErrorMessageSchema.safeParse(error);
|
|
3127
3233
|
if (asObject.success && asObject.data.message !== void 0) return asObject.data.message;
|
|
@@ -3294,18 +3400,18 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
3294
3400
|
}
|
|
3295
3401
|
|
|
3296
3402
|
// src/adapters/fal.ts
|
|
3297
|
-
import { z as
|
|
3403
|
+
import { z as z9 } from "zod";
|
|
3298
3404
|
import { createFalClient } from "@fal-ai/client";
|
|
3299
3405
|
|
|
3300
3406
|
// src/adapters/fal-http.ts
|
|
3301
|
-
import { z as
|
|
3302
|
-
var queueUrl =
|
|
3303
|
-
var submissionSchema =
|
|
3304
|
-
request_id:
|
|
3407
|
+
import { z as z8 } from "zod";
|
|
3408
|
+
var queueUrl = z8.url().refine((value) => new URL(value).origin === "https://queue.fal.run");
|
|
3409
|
+
var submissionSchema = z8.object({
|
|
3410
|
+
request_id: z8.string(),
|
|
3305
3411
|
status_url: queueUrl,
|
|
3306
3412
|
response_url: queueUrl
|
|
3307
3413
|
});
|
|
3308
|
-
var statusSchema =
|
|
3414
|
+
var statusSchema = z8.object({ status: z8.string() });
|
|
3309
3415
|
function createFalHttpClient(opts) {
|
|
3310
3416
|
const jobs = /* @__PURE__ */ new Map();
|
|
3311
3417
|
async function request(url, input, signal) {
|
|
@@ -3389,7 +3495,7 @@ var KLING_O1_ENDPOINT = "fal-ai/kling-video/o1/video-to-video/reference";
|
|
|
3389
3495
|
var FAL_QUEUE_HOST = "https://queue.fal.run";
|
|
3390
3496
|
var PASSTHROUGH_POLL_MS = 2e3;
|
|
3391
3497
|
var PASSTHROUGH_MAX_WAIT_MS = 18e4;
|
|
3392
|
-
var falSubscribePayloadSchema =
|
|
3498
|
+
var falSubscribePayloadSchema = z9.object({ data: JsonValueSchema });
|
|
3393
3499
|
function defaultCreateFalClient(opts) {
|
|
3394
3500
|
if (opts.maxRetries !== void 0)
|
|
3395
3501
|
return createFalHttpClient({
|
|
@@ -3445,7 +3551,7 @@ function createFalAdapter(deps = defaultDeps) {
|
|
|
3445
3551
|
};
|
|
3446
3552
|
}
|
|
3447
3553
|
var falAdapter = createFalAdapter();
|
|
3448
|
-
var falDetailSchema =
|
|
3554
|
+
var falDetailSchema = z9.object({ detail: JsonValueSchema });
|
|
3449
3555
|
function liftDetail(body) {
|
|
3450
3556
|
const parsed = falDetailSchema.safeParse(body);
|
|
3451
3557
|
const detail = parsed.success ? parsed.data.detail : void 0;
|
|
@@ -3454,11 +3560,11 @@ function liftDetail(body) {
|
|
|
3454
3560
|
function falError(status, body, model) {
|
|
3455
3561
|
return classifyHttpError(status, liftDetail(body), "fal", model);
|
|
3456
3562
|
}
|
|
3457
|
-
var falSdkThrownSchema =
|
|
3458
|
-
status:
|
|
3459
|
-
statusCode:
|
|
3563
|
+
var falSdkThrownSchema = z9.object({
|
|
3564
|
+
status: z9.number().optional(),
|
|
3565
|
+
statusCode: z9.number().optional(),
|
|
3460
3566
|
body: JsonValueSchema.optional(),
|
|
3461
|
-
message:
|
|
3567
|
+
message: z9.string().optional()
|
|
3462
3568
|
});
|
|
3463
3569
|
function falSdkError(cause, model) {
|
|
3464
3570
|
const parsed = falSdkThrownSchema.safeParse(cause);
|
|
@@ -3506,12 +3612,12 @@ async function gatewayFetch(cfg, fetchImpl, targetUrl, init) {
|
|
|
3506
3612
|
if (init.body !== void 0) request.body = init.body;
|
|
3507
3613
|
return fetchImpl(cfg.baseUrl, request);
|
|
3508
3614
|
}
|
|
3509
|
-
var falQueueSubmitSchema =
|
|
3510
|
-
request_id:
|
|
3511
|
-
status_url:
|
|
3512
|
-
response_url:
|
|
3615
|
+
var falQueueSubmitSchema = z9.object({
|
|
3616
|
+
request_id: z9.string(),
|
|
3617
|
+
status_url: z9.string(),
|
|
3618
|
+
response_url: z9.string()
|
|
3513
3619
|
});
|
|
3514
|
-
var falQueueStatusSchema =
|
|
3620
|
+
var falQueueStatusSchema = z9.object({ status: z9.string() });
|
|
3515
3621
|
async function passthroughRequest(ctx, endpoint, input) {
|
|
3516
3622
|
const cfg = gatewayConfig(ctx);
|
|
3517
3623
|
const submitRes = await gatewayFetch(cfg, ctx.fetch, `${FAL_QUEUE_HOST}/${endpoint}`, {
|
|
@@ -3644,11 +3750,11 @@ async function decodeImage(ctx, url, contentType) {
|
|
|
3644
3750
|
const mime = res.headers.get("content-type") ?? contentType ?? "image/png";
|
|
3645
3751
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
3646
3752
|
}
|
|
3647
|
-
var museImageResultSchema =
|
|
3648
|
-
images:
|
|
3649
|
-
|
|
3650
|
-
url:
|
|
3651
|
-
content_type:
|
|
3753
|
+
var museImageResultSchema = z9.object({
|
|
3754
|
+
images: z9.array(
|
|
3755
|
+
z9.object({
|
|
3756
|
+
url: z9.string().optional(),
|
|
3757
|
+
content_type: z9.string().nullable().optional()
|
|
3652
3758
|
})
|
|
3653
3759
|
).optional()
|
|
3654
3760
|
});
|
|
@@ -3752,8 +3858,8 @@ function klingO1Input(req) {
|
|
|
3752
3858
|
if (refs.length > 0) input.image_urls = refs;
|
|
3753
3859
|
return input;
|
|
3754
3860
|
}
|
|
3755
|
-
var falVideoResultSchema =
|
|
3756
|
-
video:
|
|
3861
|
+
var falVideoResultSchema = z9.object({
|
|
3862
|
+
video: z9.object({ url: z9.string().optional() }).optional()
|
|
3757
3863
|
});
|
|
3758
3864
|
function extractVideoUrl(result, endpoint, model) {
|
|
3759
3865
|
const parsed = falVideoResultSchema.safeParse(result);
|
|
@@ -3954,13 +4060,13 @@ async function passthroughVideoJob(ctx, req, endpoint, input) {
|
|
|
3954
4060
|
}
|
|
3955
4061
|
|
|
3956
4062
|
// src/adapters/google-genai.ts
|
|
3957
|
-
import { z as
|
|
4063
|
+
import { z as z11 } from "zod";
|
|
3958
4064
|
import {
|
|
3959
4065
|
GoogleGenAI
|
|
3960
4066
|
} from "@google/genai";
|
|
3961
4067
|
|
|
3962
4068
|
// src/adapters/google-files.ts
|
|
3963
|
-
import { z as
|
|
4069
|
+
import { z as z10 } from "zod";
|
|
3964
4070
|
var GOOGLE_FILES_BASE = "https://generativelanguage.googleapis.com";
|
|
3965
4071
|
var GOOGLE_FILES_POLL_INTERVAL_MS = 2e3;
|
|
3966
4072
|
var GOOGLE_FILES_POLL_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
@@ -3970,17 +4076,17 @@ var GENERIC_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
|
3970
4076
|
"binary/octet-stream",
|
|
3971
4077
|
"application/binary"
|
|
3972
4078
|
]);
|
|
3973
|
-
var uploadedFileSchema =
|
|
3974
|
-
file:
|
|
3975
|
-
uri:
|
|
3976
|
-
name:
|
|
3977
|
-
state:
|
|
3978
|
-
mimeType:
|
|
4079
|
+
var uploadedFileSchema = z10.object({
|
|
4080
|
+
file: z10.object({
|
|
4081
|
+
uri: z10.string().optional(),
|
|
4082
|
+
name: z10.string().optional(),
|
|
4083
|
+
state: z10.string().optional(),
|
|
4084
|
+
mimeType: z10.string().optional()
|
|
3979
4085
|
}).optional()
|
|
3980
4086
|
});
|
|
3981
|
-
var fileStateSchema =
|
|
3982
|
-
state:
|
|
3983
|
-
error:
|
|
4087
|
+
var fileStateSchema = z10.object({
|
|
4088
|
+
state: z10.string().optional(),
|
|
4089
|
+
error: z10.object({ message: z10.string().optional() }).optional()
|
|
3984
4090
|
});
|
|
3985
4091
|
function resolveMime(declared, fallback) {
|
|
3986
4092
|
const clean = declared?.split(";")[0]?.trim().toLowerCase();
|
|
@@ -4197,7 +4303,7 @@ var OMNI_POLL_INTERVAL_MS = 1e4;
|
|
|
4197
4303
|
var RESULT_TIMEOUT_MS2 = 15 * 60 * 1e3;
|
|
4198
4304
|
var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
4199
4305
|
var MEDIA_PART_INLINE_LIMIT_BYTES = 20 * 1024 * 1024;
|
|
4200
|
-
var errorTextSchema =
|
|
4306
|
+
var errorTextSchema = z11.string();
|
|
4201
4307
|
function isGoogleGenaiVideoKnown(providerModelId) {
|
|
4202
4308
|
return providerModelId.startsWith("veo-") || providerModelId.startsWith("gemini-omni");
|
|
4203
4309
|
}
|
|
@@ -4806,15 +4912,15 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
4806
4912
|
// src/adapters/google-image.ts
|
|
4807
4913
|
import { createGoogleGenerativeAI as createGoogleGenerativeAI2 } from "@ai-sdk/google";
|
|
4808
4914
|
import { generateText } from "ai";
|
|
4809
|
-
import { z as
|
|
4915
|
+
import { z as z12 } from "zod";
|
|
4810
4916
|
var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
|
|
4811
4917
|
var defaultGoogleImageDeps = {
|
|
4812
4918
|
createGoogleClient: (opts) => createGoogleGenerativeAI2(opts),
|
|
4813
4919
|
runTextGeneration: (opts) => generateText(opts)
|
|
4814
4920
|
};
|
|
4815
|
-
var causeChainNodeSchema =
|
|
4816
|
-
message:
|
|
4817
|
-
cause:
|
|
4921
|
+
var causeChainNodeSchema = z12.object({
|
|
4922
|
+
message: z12.string().optional(),
|
|
4923
|
+
cause: z12.unknown().optional()
|
|
4818
4924
|
});
|
|
4819
4925
|
function extractBlockReason(cause) {
|
|
4820
4926
|
let current = cause;
|
|
@@ -4934,7 +5040,7 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
|
|
|
4934
5040
|
var googleImageAdapter = createGoogleImageAdapter();
|
|
4935
5041
|
|
|
4936
5042
|
// src/adapters/higgsfield.ts
|
|
4937
|
-
import { z as
|
|
5043
|
+
import { z as z13 } from "zod";
|
|
4938
5044
|
|
|
4939
5045
|
// src/adapters/higgsfield-motions.ts
|
|
4940
5046
|
var MOTION_MAP = {
|
|
@@ -5133,14 +5239,14 @@ function videoUsage3(ctx, req, duration) {
|
|
|
5133
5239
|
if (req.durationSeconds !== void 0) event.durationSeconds = req.durationSeconds;
|
|
5134
5240
|
return event;
|
|
5135
5241
|
}
|
|
5136
|
-
var klingCreateSchema =
|
|
5137
|
-
var klingStatusSchema =
|
|
5138
|
-
status:
|
|
5139
|
-
video:
|
|
5242
|
+
var klingCreateSchema = z13.object({ status_url: z13.string() });
|
|
5243
|
+
var klingStatusSchema = z13.object({
|
|
5244
|
+
status: z13.string().optional(),
|
|
5245
|
+
video: z13.object({ url: z13.string().optional() }).optional(),
|
|
5140
5246
|
error: JsonValueSchema.optional()
|
|
5141
5247
|
});
|
|
5142
|
-
var errorMessageSchema =
|
|
5143
|
-
var textValueSchema =
|
|
5248
|
+
var errorMessageSchema = z13.object({ message: z13.string().optional() });
|
|
5249
|
+
var textValueSchema = z13.string();
|
|
5144
5250
|
function klingErrorDetail(error) {
|
|
5145
5251
|
if (error === void 0) return "unknown_error";
|
|
5146
5252
|
const asText = textValueSchema.safeParse(error);
|
|
@@ -5276,8 +5382,8 @@ async function generateKlingVideo(req, ctx) {
|
|
|
5276
5382
|
}
|
|
5277
5383
|
};
|
|
5278
5384
|
}
|
|
5279
|
-
var dopMotionOptionsSchema =
|
|
5280
|
-
modelkit:
|
|
5385
|
+
var dopMotionOptionsSchema = z13.object({
|
|
5386
|
+
modelkit: z13.object({ motion: z13.string().optional() }).optional()
|
|
5281
5387
|
});
|
|
5282
5388
|
function dopMotionId(ctx) {
|
|
5283
5389
|
const parsed = dopMotionOptionsSchema.safeParse(ctx.model.providerOptions);
|
|
@@ -5293,7 +5399,7 @@ function dopMotionId(ctx) {
|
|
|
5293
5399
|
});
|
|
5294
5400
|
return id;
|
|
5295
5401
|
}
|
|
5296
|
-
var jsonRecordSchema =
|
|
5402
|
+
var jsonRecordSchema = z13.record(z13.string(), JsonValueSchema);
|
|
5297
5403
|
var DOP_URL_KEYS = ["url", "video_url", "output_url", "result_url", "download_url"];
|
|
5298
5404
|
var DOP_NESTED_KEYS = ["video", "result", "results"];
|
|
5299
5405
|
function dopUrl(body) {
|
|
@@ -5321,8 +5427,8 @@ function dopUrl(body) {
|
|
|
5321
5427
|
}
|
|
5322
5428
|
return void 0;
|
|
5323
5429
|
}
|
|
5324
|
-
var dopCreateSchema =
|
|
5325
|
-
var dopStatusSchema =
|
|
5430
|
+
var dopCreateSchema = z13.object({ id: z13.string() });
|
|
5431
|
+
var dopStatusSchema = z13.object({ status: z13.string().optional() });
|
|
5326
5432
|
async function generateDopVideo(req, ctx) {
|
|
5327
5433
|
const firstFrame = req.firstFrame ? refToUrl(req.firstFrame) : void 0;
|
|
5328
5434
|
if (!firstFrame) {
|
|
@@ -5450,7 +5556,7 @@ var higgsfieldAdapter = {
|
|
|
5450
5556
|
|
|
5451
5557
|
// src/adapters/openai-image.ts
|
|
5452
5558
|
import OpenAI from "openai";
|
|
5453
|
-
import { z as
|
|
5559
|
+
import { z as z14 } from "zod";
|
|
5454
5560
|
var MAX_EDIT_REFERENCES = 16;
|
|
5455
5561
|
function aspectRatioToSize(ratio, tier) {
|
|
5456
5562
|
const TIER_LONG_EDGE = {
|
|
@@ -5533,9 +5639,9 @@ function toProviderError2(cause, ctx) {
|
|
|
5533
5639
|
ctx.model.id
|
|
5534
5640
|
);
|
|
5535
5641
|
}
|
|
5536
|
-
var openaiUsageSchema =
|
|
5537
|
-
input_tokens:
|
|
5538
|
-
output_tokens:
|
|
5642
|
+
var openaiUsageSchema = z14.object({
|
|
5643
|
+
input_tokens: z14.number().optional(),
|
|
5644
|
+
output_tokens: z14.number().optional()
|
|
5539
5645
|
});
|
|
5540
5646
|
var openaiImageAdapter = {
|
|
5541
5647
|
id: "openai-image",
|
|
@@ -5946,13 +6052,13 @@ var prodiaAdapter = {
|
|
|
5946
6052
|
import Replicate from "replicate";
|
|
5947
6053
|
|
|
5948
6054
|
// src/adapters/replicate-http.ts
|
|
5949
|
-
import { z as
|
|
5950
|
-
var predictionSchema =
|
|
5951
|
-
id:
|
|
5952
|
-
status:
|
|
6055
|
+
import { z as z15 } from "zod";
|
|
6056
|
+
var predictionSchema = z15.object({
|
|
6057
|
+
id: z15.string(),
|
|
6058
|
+
status: z15.string(),
|
|
5953
6059
|
output: JsonValueSchema.optional(),
|
|
5954
6060
|
error: JsonValueSchema.optional(),
|
|
5955
|
-
metrics:
|
|
6061
|
+
metrics: z15.object({ predict_time: z15.number().optional() }).optional()
|
|
5956
6062
|
});
|
|
5957
6063
|
function createReplicateHttpClient(opts) {
|
|
5958
6064
|
async function request(path, body, signal) {
|
|
@@ -6003,7 +6109,7 @@ function createReplicateHttpClient(opts) {
|
|
|
6003
6109
|
}
|
|
6004
6110
|
|
|
6005
6111
|
// src/adapters/replicate.ts
|
|
6006
|
-
import { z as
|
|
6112
|
+
import { z as z16 } from "zod";
|
|
6007
6113
|
|
|
6008
6114
|
// src/adapters/input-spec-mapper.ts
|
|
6009
6115
|
function canonicalValue(req, key) {
|
|
@@ -6078,8 +6184,8 @@ function route(providerModelId) {
|
|
|
6078
6184
|
if (!providerModelId.includes("/")) return { version: providerModelId };
|
|
6079
6185
|
return { model: providerModelId };
|
|
6080
6186
|
}
|
|
6081
|
-
var replicateResponseStatusSchema =
|
|
6082
|
-
response:
|
|
6187
|
+
var replicateResponseStatusSchema = z16.object({
|
|
6188
|
+
response: z16.object({ status: z16.number() }).partial()
|
|
6083
6189
|
});
|
|
6084
6190
|
function replicateError(cause, ctx) {
|
|
6085
6191
|
if (isModelKitError(cause)) return cause;
|
|
@@ -6106,7 +6212,7 @@ function isUrlFn(value) {
|
|
|
6106
6212
|
function extractOutputUrl(output) {
|
|
6107
6213
|
const root = Array.isArray(output) ? output[0] : output;
|
|
6108
6214
|
if (root === void 0) throw noOutput();
|
|
6109
|
-
const asString =
|
|
6215
|
+
const asString = z16.string().safeParse(root);
|
|
6110
6216
|
if (asString.success && asString.data) return asString.data;
|
|
6111
6217
|
if (root instanceof URL) return root.href;
|
|
6112
6218
|
if (isObjectOutput(root)) {
|
|
@@ -6115,15 +6221,15 @@ function extractOutputUrl(output) {
|
|
|
6115
6221
|
if (urlValue !== void 0 && isUrlFn(urlValue)) {
|
|
6116
6222
|
const called = urlValue();
|
|
6117
6223
|
if (called instanceof URL) return called.href;
|
|
6118
|
-
const calledString =
|
|
6224
|
+
const calledString = z16.string().safeParse(called);
|
|
6119
6225
|
if (calledString.success && calledString.data) return calledString.data;
|
|
6120
6226
|
} else {
|
|
6121
|
-
const direct =
|
|
6227
|
+
const direct = z16.string().safeParse(urlValue);
|
|
6122
6228
|
if (direct.success && direct.data) return direct.data;
|
|
6123
6229
|
}
|
|
6124
6230
|
}
|
|
6125
6231
|
if ("default" in root) {
|
|
6126
|
-
const fallback =
|
|
6232
|
+
const fallback = z16.string().safeParse(root.default);
|
|
6127
6233
|
if (fallback.success && fallback.data) return fallback.data;
|
|
6128
6234
|
}
|
|
6129
6235
|
}
|
|
@@ -6184,7 +6290,7 @@ async function runPrediction(ctx, input, deps) {
|
|
|
6184
6290
|
}
|
|
6185
6291
|
return void 0;
|
|
6186
6292
|
}, pollOpts);
|
|
6187
|
-
const predictTime =
|
|
6293
|
+
const predictTime = z16.number().safeParse(done.metrics?.predict_time);
|
|
6188
6294
|
if (done.output === void 0) throw noOutput();
|
|
6189
6295
|
return {
|
|
6190
6296
|
url: extractOutputUrl(done.output),
|
|
@@ -6569,7 +6675,7 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
6569
6675
|
throw replicateError(cause, ctx);
|
|
6570
6676
|
}
|
|
6571
6677
|
if (current.status === "succeeded") {
|
|
6572
|
-
const predictTime =
|
|
6678
|
+
const predictTime = z16.number().safeParse(current.metrics?.predict_time);
|
|
6573
6679
|
if (current.output === void 0) throw noOutput();
|
|
6574
6680
|
return {
|
|
6575
6681
|
url: extractOutputUrl(current.output),
|
|
@@ -6710,7 +6816,7 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
6710
6816
|
// src/adapters/xai-video.ts
|
|
6711
6817
|
import { experimental_generateVideo } from "ai";
|
|
6712
6818
|
import { createXai as createXai2 } from "@ai-sdk/xai";
|
|
6713
|
-
import { z as
|
|
6819
|
+
import { z as z17 } from "zod";
|
|
6714
6820
|
var POLL_INTERVAL_MS2 = 1e4;
|
|
6715
6821
|
var POLL_TIMEOUT_MS2 = 15 * 6e4;
|
|
6716
6822
|
var defaultXaiDeps = {
|
|
@@ -6723,8 +6829,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
|
|
|
6723
6829
|
};
|
|
6724
6830
|
}
|
|
6725
6831
|
var xaiVideoAdapter = createXaiVideoAdapter();
|
|
6726
|
-
var xaiResponseStatusSchema =
|
|
6727
|
-
response:
|
|
6832
|
+
var xaiResponseStatusSchema = z17.object({
|
|
6833
|
+
response: z17.object({ status: z17.number() }).partial()
|
|
6728
6834
|
});
|
|
6729
6835
|
function xaiError(cause, ctx) {
|
|
6730
6836
|
const info = describeThrown(cause);
|
|
@@ -6732,12 +6838,12 @@ function xaiError(cause, ctx) {
|
|
|
6732
6838
|
const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
|
|
6733
6839
|
return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
|
|
6734
6840
|
}
|
|
6735
|
-
var xaiMetaSchema =
|
|
6841
|
+
var xaiMetaSchema = z17.object({
|
|
6736
6842
|
videoUrl: JsonValueSchema.optional(),
|
|
6737
6843
|
costInUsdTicks: JsonValueSchema.optional(),
|
|
6738
6844
|
duration: JsonValueSchema.optional()
|
|
6739
6845
|
});
|
|
6740
|
-
var xaiProviderMetadataSchema =
|
|
6846
|
+
var xaiProviderMetadataSchema = z17.object({ xai: xaiMetaSchema });
|
|
6741
6847
|
function metaOf(result) {
|
|
6742
6848
|
const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
|
|
6743
6849
|
if (!parsed.success) return {};
|
|
@@ -6845,7 +6951,7 @@ async function mapResult(ctx, req, result) {
|
|
|
6845
6951
|
};
|
|
6846
6952
|
}
|
|
6847
6953
|
const meta = metaOf(result);
|
|
6848
|
-
const videoUrl =
|
|
6954
|
+
const videoUrl = z17.string().safeParse(meta.videoUrl);
|
|
6849
6955
|
if (videoUrl.success && videoUrl.data) {
|
|
6850
6956
|
const res = await ctx.fetch(videoUrl.data);
|
|
6851
6957
|
if (!res.ok) {
|
|
@@ -6868,7 +6974,7 @@ async function mapResult(ctx, req, result) {
|
|
|
6868
6974
|
});
|
|
6869
6975
|
}
|
|
6870
6976
|
function usage(ctx, req, meta) {
|
|
6871
|
-
const costTicks =
|
|
6977
|
+
const costTicks = z17.number().safeParse(meta.costInUsdTicks);
|
|
6872
6978
|
const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
|
|
6873
6979
|
const event = {
|
|
6874
6980
|
model: ctx.model.id,
|
|
@@ -7001,22 +7107,22 @@ var liveState = store[KEY] ??= {
|
|
|
7001
7107
|
var liveCatalog = liveState.catalog;
|
|
7002
7108
|
|
|
7003
7109
|
// src/catalog/load.ts
|
|
7004
|
-
import { z as
|
|
7110
|
+
import { z as z18 } from "zod";
|
|
7005
7111
|
function rowCount() {
|
|
7006
7112
|
return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
|
|
7007
7113
|
}
|
|
7008
7114
|
function authHeaders(auth) {
|
|
7009
7115
|
return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
|
|
7010
7116
|
}
|
|
7011
|
-
var EnvelopeSchema =
|
|
7012
|
-
rows:
|
|
7013
|
-
revision:
|
|
7117
|
+
var EnvelopeSchema = z18.object({
|
|
7118
|
+
rows: z18.array(JsonValueSchema),
|
|
7119
|
+
revision: z18.string().optional()
|
|
7014
7120
|
});
|
|
7015
7121
|
function dropReason(path, message) {
|
|
7016
7122
|
return path.length === 0 ? message : `${path.map((part) => String(part)).join(".")} ${message}`;
|
|
7017
7123
|
}
|
|
7018
7124
|
function rowId(raw) {
|
|
7019
|
-
const parsed =
|
|
7125
|
+
const parsed = z18.object({ id: z18.string().min(1) }).loose().safeParse(raw);
|
|
7020
7126
|
if (!parsed.success) return "?";
|
|
7021
7127
|
return parsed.data.id;
|
|
7022
7128
|
}
|
|
@@ -7044,7 +7150,13 @@ function quarantine(rawRows, logger) {
|
|
|
7044
7150
|
);
|
|
7045
7151
|
}
|
|
7046
7152
|
}
|
|
7047
|
-
|
|
7153
|
+
const normalised = normaliseConventions(row);
|
|
7154
|
+
if (normalised.invalidKeys.length > 0) {
|
|
7155
|
+
logger.warn(
|
|
7156
|
+
`[modelkit] catalog row ${row.id} has an invalid ${normalised.invalidKeys.join(", ")}; read as not set`
|
|
7157
|
+
);
|
|
7158
|
+
}
|
|
7159
|
+
valid.push(normalised.row);
|
|
7048
7160
|
}
|
|
7049
7161
|
let kept = valid;
|
|
7050
7162
|
for (; ; ) {
|
|
@@ -7844,7 +7956,7 @@ import {
|
|
|
7844
7956
|
streamObject as aiStreamObject2,
|
|
7845
7957
|
streamText as aiStreamText2
|
|
7846
7958
|
} from "ai";
|
|
7847
|
-
import { z as
|
|
7959
|
+
import { z as z19 } from "zod";
|
|
7848
7960
|
|
|
7849
7961
|
// src/generated-image.ts
|
|
7850
7962
|
function toGeneratedImage(image) {
|
|
@@ -7919,10 +8031,10 @@ function textAbortOptions(sdk, context) {
|
|
|
7919
8031
|
if (abortSignal) return { abortSignal };
|
|
7920
8032
|
return {};
|
|
7921
8033
|
}
|
|
7922
|
-
var catalogId =
|
|
7923
|
-
var exactSize =
|
|
7924
|
-
var sdkRatio =
|
|
7925
|
-
var sizeTier =
|
|
8034
|
+
var catalogId = z19.string();
|
|
8035
|
+
var exactSize = z19.templateLiteral([z19.number(), "x", z19.number()]);
|
|
8036
|
+
var sdkRatio = z19.templateLiteral([z19.number(), ":", z19.number()]);
|
|
8037
|
+
var sizeTier = z19.enum(["512", "1K", "2K", "4K"]);
|
|
7926
8038
|
function isCatalogId(model) {
|
|
7927
8039
|
return catalogId.safeParse(model).success;
|
|
7928
8040
|
}
|