@shop-os/modelkit 0.3.0 → 0.3.2

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.
@@ -8,7 +8,7 @@ import { z } from 'zod';
8
8
 
9
9
  /** The AI SDK video model spelling: a catalog id or a provider video model instance. */
10
10
  type VideoModel = Parameters<typeof experimental_generateVideo>[0]["model"];
11
- type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "adaptive";
11
+ type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "1:4" | "4:1" | "1:8" | "8:1" | "adaptive";
12
12
  type ImageSize = "512" | "1K" | "2K" | "4K";
13
13
  type VideoResolution = "360p" | "480p" | "720p" | "768p" | "1080p" | "2k" | "4k";
14
14
  /** "xhigh" and "max" exist only on gpt-image-2.5; gpt-image-2 rejects them at the provider. */
@@ -689,6 +689,10 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
689
689
  "21:9": "21:9";
690
690
  "9:21": "9:21";
691
691
  "97:30": "97:30";
692
+ "1:4": "1:4";
693
+ "4:1": "4:1";
694
+ "1:8": "1:8";
695
+ "8:1": "8:1";
692
696
  adaptive: "adaptive";
693
697
  }>>>;
694
698
  sizes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -824,6 +828,10 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
824
828
  "21:9": "21:9";
825
829
  "9:21": "9:21";
826
830
  "97:30": "97:30";
831
+ "1:4": "1:4";
832
+ "4:1": "4:1";
833
+ "1:8": "1:8";
834
+ "8:1": "8:1";
827
835
  adaptive: "adaptive";
828
836
  }>>;
829
837
  size: z.ZodOptional<z.ZodEnum<{
package/dist/catalog.d.ts CHANGED
@@ -8,7 +8,7 @@ import { z } from 'zod';
8
8
 
9
9
  /** The AI SDK video model spelling: a catalog id or a provider video model instance. */
10
10
  type VideoModel = Parameters<typeof experimental_generateVideo>[0]["model"];
11
- type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "adaptive";
11
+ type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "1:4" | "4:1" | "1:8" | "8:1" | "adaptive";
12
12
  type ImageSize = "512" | "1K" | "2K" | "4K";
13
13
  type VideoResolution = "360p" | "480p" | "720p" | "768p" | "1080p" | "2k" | "4k";
14
14
  /** "xhigh" and "max" exist only on gpt-image-2.5; gpt-image-2 rejects them at the provider. */
@@ -689,6 +689,10 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
689
689
  "21:9": "21:9";
690
690
  "9:21": "9:21";
691
691
  "97:30": "97:30";
692
+ "1:4": "1:4";
693
+ "4:1": "4:1";
694
+ "1:8": "1:8";
695
+ "8:1": "8:1";
692
696
  adaptive: "adaptive";
693
697
  }>>>;
694
698
  sizes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -824,6 +828,10 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
824
828
  "21:9": "21:9";
825
829
  "9:21": "9:21";
826
830
  "97:30": "97:30";
831
+ "1:4": "1:4";
832
+ "4:1": "4:1";
833
+ "1:8": "1:8";
834
+ "8:1": "8:1";
827
835
  adaptive: "adaptive";
828
836
  }>>;
829
837
  size: z.ZodOptional<z.ZodEnum<{
package/dist/catalog.js CHANGED
@@ -158,13 +158,21 @@ var GEMINI_RATIOS = [
158
158
  "5:4",
159
159
  "adaptive"
160
160
  ];
161
+ var NANO_BANANA_2_1_RATIOS = [
162
+ ...GEMINI_RATIOS.filter((r) => r !== "adaptive"),
163
+ "1:4",
164
+ "4:1",
165
+ "1:8",
166
+ "8:1",
167
+ "adaptive"
168
+ ];
161
169
  var GEMINI_PROMPT_MAX_CHARS = 5e4;
162
170
  var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
163
- function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars) {
171
+ function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars, aspectRatios = GEMINI_RATIOS) {
164
172
  const prompt = { referenceSyntax: "caption" };
165
173
  if (promptMaxChars !== void 0) prompt.maxChars = promptMaxChars;
166
174
  const constraints = {
167
- aspectRatios: [...GEMINI_RATIOS],
175
+ aspectRatios: [...aspectRatios],
168
176
  sizes,
169
177
  supports: ["safetySettings", "temperature"],
170
178
  prompt
@@ -188,6 +196,21 @@ function geminiImage(id, label, aliases, sizes, display, exposure, references, p
188
196
  return model;
189
197
  }
190
198
  var IMAGE_MODELS = [
199
+ geminiImage(
200
+ "gemini-nano-banana-2.1",
201
+ "Nano Banana 2.1",
202
+ ["nb-2.1"],
203
+ ["1K", "2K", "4K"],
204
+ {
205
+ provider: "google",
206
+ description: "Latest high-efficiency Nano Banana. Better realism, prompt adherence, text rendering and character consistency at Flash speed. Great for campaigns, infographics, and iterative edits.",
207
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
208
+ },
209
+ ["cowork", "space_builder"],
210
+ { images: 14 },
211
+ GEMINI_PROMPT_MAX_CHARS,
212
+ NANO_BANANA_2_1_RATIOS
213
+ ),
191
214
  geminiImage(
192
215
  "gemini-3-pro-image-preview",
193
216
  "Nano Banana Pro",
@@ -2253,6 +2276,10 @@ var ALL_KEY_SET = /* @__PURE__ */ new Set([
2253
2276
  ...IMAGE_INPUT_SPEC_KEYS,
2254
2277
  ...AUDIO_INPUT_SPEC_KEYS
2255
2278
  ]);
2279
+ var TYPES_BY_ADAPTER = /* @__PURE__ */ new Map([
2280
+ ["replicate", ["video", "image", "audio"]],
2281
+ ["fal", ["image"]]
2282
+ ]);
2256
2283
  var ALLOWED_KEYS_BY_TYPE = /* @__PURE__ */ new Map([
2257
2284
  ["video", VIDEO_KEY_SET],
2258
2285
  ["image", IMAGE_KEY_SET],
@@ -2291,7 +2318,8 @@ var StaticSchema = z2.record(z2.string(), ProviderScalarSchema);
2291
2318
  var InputSpecSchema = z2.strictObject({
2292
2319
  fields: FieldsSchema,
2293
2320
  values: ValuesSchema.optional(),
2294
- static: StaticSchema.optional()
2321
+ static: StaticSchema.optional(),
2322
+ editEndpoint: z2.string().min(1).optional()
2295
2323
  }).superRefine((spec, ctx) => {
2296
2324
  const mappedNames = new Set(Object.values(spec.fields));
2297
2325
  for (const key of Object.keys(spec.static ?? {})) {
@@ -2316,18 +2344,21 @@ function validateInputSpec(raw, row) {
2316
2344
  };
2317
2345
  }
2318
2346
  const spec = parsed.data;
2319
- if (row.adapter !== "replicate") {
2347
+ const supportedTypes = TYPES_BY_ADAPTER.get(row.adapter);
2348
+ if (supportedTypes === void 0) {
2320
2349
  return {
2321
2350
  ok: false,
2322
- issues: [{ path: [], message: "inputSpec is only supported on replicate rows" }]
2351
+ issues: [
2352
+ { path: [], message: "inputSpec is only supported on replicate and fal rows" }
2353
+ ]
2323
2354
  };
2324
2355
  }
2325
2356
  const issues = [];
2326
2357
  const allowed = ALLOWED_KEYS_BY_TYPE.get(row.type);
2327
- if (allowed === void 0) {
2358
+ if (allowed === void 0 || !supportedTypes.includes(row.type)) {
2328
2359
  issues.push({
2329
2360
  path: [],
2330
- message: `inputSpec is not supported for "${row.type}" rows`
2361
+ message: row.adapter === "fal" ? `inputSpec on fal rows is only supported for image rows, not "${row.type}"` : `inputSpec is not supported for "${row.type}" rows`
2331
2362
  });
2332
2363
  } else {
2333
2364
  for (const key of Object.keys(spec.fields)) {
@@ -2347,6 +2378,19 @@ function validateInputSpec(raw, row) {
2347
2378
  }
2348
2379
  }
2349
2380
  }
2381
+ if (spec.editEndpoint !== void 0) {
2382
+ if (row.adapter !== "fal") {
2383
+ issues.push({
2384
+ path: ["editEndpoint"],
2385
+ message: "inputSpec.editEndpoint is only supported on fal rows"
2386
+ });
2387
+ } else if (!("references" in spec.fields)) {
2388
+ issues.push({
2389
+ path: ["editEndpoint"],
2390
+ message: 'inputSpec.editEndpoint needs a "references" entry in inputSpec.fields'
2391
+ });
2392
+ }
2393
+ }
2350
2394
  const seenNames = /* @__PURE__ */ new Map();
2351
2395
  for (const [key, name] of Object.entries(spec.fields)) {
2352
2396
  const first = seenNames.get(name);
@@ -2422,6 +2466,10 @@ var AspectRatioSchema = z3.enum([
2422
2466
  "21:9",
2423
2467
  "9:21",
2424
2468
  "97:30",
2469
+ "1:4",
2470
+ "4:1",
2471
+ "1:8",
2472
+ "8:1",
2425
2473
  "adaptive"
2426
2474
  ]);
2427
2475
  var ImageSizeSchema = z3.enum(["512", "1K", "2K", "4K"]);