@shop-os/modelkit 0.20.0 → 0.21.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/dist/index.cjs CHANGED
@@ -43,6 +43,7 @@ __export(index_exports, {
43
43
  DEFAULT_ADAPTERS: () => DEFAULT_ADAPTERS,
44
44
  ExposureSchema: () => ExposureSchema,
45
45
  IMAGE_INPUT_SPEC_KEYS: () => IMAGE_INPUT_SPEC_KEYS,
46
+ INPUT_BILLINGS: () => INPUT_BILLINGS,
46
47
  INPUT_SPEC_SUPPORTS_KEYS: () => INPUT_SPEC_SUPPORTS_KEYS,
47
48
  InputSpecSchema: () => InputSpecSchema,
48
49
  JsonObjectSchema: () => JsonObjectSchema,
@@ -87,6 +88,7 @@ __export(index_exports, {
87
88
  hasAwsCredentials: () => hasAwsCredentials,
88
89
  higgsfieldAdapter: () => higgsfieldAdapter,
89
90
  imageOutputFormats: () => imageOutputFormats,
91
+ inputBillingOf: () => inputBillingOf,
90
92
  isArrayInputSpecKey: () => isArrayInputSpecKey,
91
93
  isInputSpecKey: () => isInputSpecKey,
92
94
  isListed: () => isListed,
@@ -5528,6 +5530,7 @@ var VIDEO_FAMILY_MODELS = [
5528
5530
  lifecycle: "active",
5529
5531
  exposure: ["cowork", "space_builder"],
5530
5532
  constraints: {
5533
+ inputBilling: "kling-v4",
5531
5534
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5532
5535
  resolutions: ["720p", "1080p"],
5533
5536
  durations: { min: 3, max: 30 },
@@ -5567,6 +5570,7 @@ var VIDEO_FAMILY_MODELS = [
5567
5570
  lifecycle: "active",
5568
5571
  exposure: ["cowork", "space_builder"],
5569
5572
  constraints: {
5573
+ inputBilling: "kling-v4",
5570
5574
  resolutions: ["720p", "1080p"],
5571
5575
  durations: { min: 3, max: 30 },
5572
5576
  references: { ...NO_REFERENCES, images: 10 },
@@ -5602,6 +5606,7 @@ var VIDEO_FAMILY_MODELS = [
5602
5606
  lifecycle: "active",
5603
5607
  exposure: ["cowork", "space_builder"],
5604
5608
  constraints: {
5609
+ inputBilling: "kling-v4",
5605
5610
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5606
5611
  resolutions: ["720p"],
5607
5612
  durations: { min: 3, max: 20 },
@@ -5640,6 +5645,7 @@ var VIDEO_FAMILY_MODELS = [
5640
5645
  lifecycle: "active",
5641
5646
  exposure: ["cowork", "space_builder"],
5642
5647
  constraints: {
5648
+ inputBilling: "kling-v4",
5643
5649
  resolutions: ["720p"],
5644
5650
  durations: { min: 3, max: 20 },
5645
5651
  references: {
@@ -5721,6 +5727,7 @@ var VIDEO_FAMILY_MODELS = [
5721
5727
  lifecycle: "active",
5722
5728
  exposure: ["cowork", "space_builder"],
5723
5729
  constraints: {
5730
+ inputBilling: "h3-max-reference",
5724
5731
  resolutions: ["480p", "768p"],
5725
5732
  durations: { min: 5, max: 13 },
5726
5733
  references: { images: 9, videos: 3, audios: 0 },
@@ -5958,6 +5965,7 @@ var VIDEO_FAMILY_MODELS = [
5958
5965
  lifecycle: "active",
5959
5966
  exposure: ["cowork", "space_builder"],
5960
5967
  constraints: {
5968
+ inputBilling: "grok-input-image",
5961
5969
  aspectRatios: [...GROK_15_RATIOS],
5962
5970
  resolutions: ["480p", "720p", "1080p"],
5963
5971
  durations: { min: 1, max: 15 },
@@ -6235,6 +6243,7 @@ var VIDEO_MODELS = [
6235
6243
  replacedBy: "gemini-omni-1.1-flash",
6236
6244
  exposure: [],
6237
6245
  constraints: {
6246
+ inputBilling: "omni",
6238
6247
  // 1.0 rejects `resolution`; it renders 720p. No defaults: the adapter
6239
6248
  // sends ratio and duration only when the caller set them, so a
6240
6249
  // reference clip keeps its own framing.
@@ -6266,6 +6275,7 @@ var VIDEO_MODELS = [
6266
6275
  lifecycle: "active",
6267
6276
  exposure: ["cowork", "space_builder"],
6268
6277
  constraints: {
6278
+ inputBilling: "omni",
6269
6279
  aspectRatios: [...OMNI_RATIOS],
6270
6280
  resolutions: ["360p", "720p", "1080p", "4k"],
6271
6281
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
@@ -6310,6 +6320,7 @@ var VIDEO_MODELS = [
6310
6320
  lifecycle: "active",
6311
6321
  exposure: ["cowork", "space_builder"],
6312
6322
  constraints: {
6323
+ inputBilling: "omni",
6313
6324
  aspectRatios: [...OMNI_RATIOS],
6314
6325
  resolutions: ["360p", "720p", "1080p", "4k"],
6315
6326
  durations: { min: 3, max: 15 },
@@ -6486,6 +6497,7 @@ var VIDEO_MODELS = [
6486
6497
  lifecycle: "active",
6487
6498
  exposure: ["cowork", "space_builder"],
6488
6499
  constraints: {
6500
+ inputBilling: "grok-input-image",
6489
6501
  aspectRatios: [...GROK_RATIOS],
6490
6502
  resolutions: ["480p", "720p"],
6491
6503
  durations: { min: 1, max: 15 },
@@ -6687,6 +6699,7 @@ var VIDEO_MODELS = [
6687
6699
  lifecycle: "active",
6688
6700
  exposure: ["cowork", "space_builder"],
6689
6701
  constraints: {
6702
+ inputBilling: "h3-reference",
6690
6703
  aspectRatios: [...H3_REFERENCE_RATIOS],
6691
6704
  resolutions: ["480p", "768p", "2k", "4k"],
6692
6705
  durations: { min: 5, max: 15 },
@@ -6731,6 +6744,7 @@ var VIDEO_MODELS = [
6731
6744
  lifecycle: "active",
6732
6745
  exposure: ["cowork", "space_builder"],
6733
6746
  constraints: {
6747
+ inputBilling: "h3-max-reference",
6734
6748
  aspectRatios: [...H3_REFERENCE_RATIOS],
6735
6749
  resolutions: ["480p", "768p", "1080p"],
6736
6750
  durations: { min: 5, max: 15 },
@@ -6778,6 +6792,7 @@ var VIDEO_MODELS = [
6778
6792
  lifecycle: "active",
6779
6793
  exposure: ["cowork", "space_builder"],
6780
6794
  constraints: {
6795
+ inputBilling: "input-plus-output",
6781
6796
  aspectRatios: [...WAN_RATIOS],
6782
6797
  resolutions: ["480p", "720p", "1080p"],
6783
6798
  durations: { min: 2, max: 30 },
@@ -6819,6 +6834,7 @@ var VIDEO_MODELS = [
6819
6834
  lifecycle: "active",
6820
6835
  exposure: ["cowork", "space_builder"],
6821
6836
  constraints: {
6837
+ inputBilling: "input-plus-output",
6822
6838
  aspectRatios: [...WAN_RATIOS],
6823
6839
  resolutions: ["480p", "720p", "1080p"],
6824
6840
  durations: { min: 2, max: 30 },
@@ -7482,7 +7498,18 @@ var PromptConventionsSchema = import_zod.z.strictObject({
7482
7498
  referenceSyntax: ReferenceSyntaxSchema,
7483
7499
  maxChars: MaxCharsSchema.optional()
7484
7500
  });
7501
+ var InputBillingSchema = import_zod.z.enum([
7502
+ "seedance",
7503
+ "omni",
7504
+ "h3-max-reference",
7505
+ "h3-reference",
7506
+ "grok-input-image",
7507
+ "source-video-rate",
7508
+ "kling-v4",
7509
+ "input-plus-output"
7510
+ ]);
7485
7511
  var AUDIO_OUTPUTS = AudioOutputSchema.options;
7512
+ var INPUT_BILLINGS = InputBillingSchema.options;
7486
7513
  var REFERENCE_SYNTAXES = ReferenceSyntaxSchema.options;
7487
7514
  var ConstraintsReadView = import_zod.z.looseObject({
7488
7515
  audio: AudioOutputSchema.optional().catch(void 0),
@@ -8395,6 +8422,7 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
8395
8422
  // Loose on purpose: the read path keeps a row whose value is invalid (the accessors in
8396
8423
  // conventions.ts read it as "not set"); CatalogModelSchema below rejects it on write.
8397
8424
  audio: import_zod3.z.unknown().optional(),
8425
+ inputBilling: import_zod3.z.unknown().optional(),
8398
8426
  prompt: import_zod3.z.unknown().optional()
8399
8427
  });
8400
8428
  var MediaRefSchema = import_zod3.z.union([
@@ -8587,6 +8615,14 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
8587
8615
  message: 'audio must be "always", "optional" or "never"'
8588
8616
  });
8589
8617
  }
8618
+ const inputBilling = row2.constraints.inputBilling;
8619
+ if (inputBilling !== void 0 && !InputBillingSchema.safeParse(inputBilling).success) {
8620
+ ctx.addIssue({
8621
+ code: "custom",
8622
+ path: ["constraints", "inputBilling"],
8623
+ message: `inputBilling must be one of ${INPUT_BILLINGS.join(", ")}`
8624
+ });
8625
+ }
8590
8626
  const refs = row2.constraints.references;
8591
8627
  for (const kind of ["images", "videos", "audios"]) {
8592
8628
  const least = refs?.min?.[kind];
@@ -18434,6 +18470,25 @@ function fileCatalogCache(path) {
18434
18470
  };
18435
18471
  }
18436
18472
 
18473
+ // src/catalog/input-billing.ts
18474
+ var import_zod36 = require("zod");
18475
+ var DATA_ONLY_INPUT_BILLING = /* @__PURE__ */ new Map([
18476
+ ["flux-3", "source-video-rate"]
18477
+ ]);
18478
+ var KIT_INPUT_BILLING = new Map(
18479
+ MODELS.flatMap(
18480
+ (row2) => row2.constraints.inputBilling ? [[row2.id, row2.constraints.inputBilling]] : []
18481
+ )
18482
+ );
18483
+ var ConstraintsReadView2 = import_zod36.z.looseObject({
18484
+ inputBilling: InputBillingSchema.optional().catch(void 0)
18485
+ });
18486
+ function inputBillingOf(row2) {
18487
+ const view = ConstraintsReadView2.safeParse(row2.constraints);
18488
+ const own = view.success ? view.data.inputBilling : void 0;
18489
+ return own ?? KIT_INPUT_BILLING.get(row2.id) ?? (row2.adapter === "ark" ? "seedance" : void 0) ?? DATA_ONLY_INPUT_BILLING.get(row2.id) ?? null;
18490
+ }
18491
+
18437
18492
  // src/resolve-image-output.ts
18438
18493
  var BASE_FORMATS = ["png", "jpeg", "webp"];
18439
18494
  var ONE_K_FRAME_PIXELS = 288 * 512;
@@ -19885,7 +19940,7 @@ async function testProviderKey(provider, secret, opts = {}) {
19885
19940
 
19886
19941
  // src/text.ts
19887
19942
  var import_ai4 = require("ai");
19888
- var import_zod36 = require("zod");
19943
+ var import_zod37 = require("zod");
19889
19944
  function mergeTextProviderOptions(catalog, caller) {
19890
19945
  const merged = {};
19891
19946
  const catalogOptions = catalog.providerOptions ?? {};
@@ -19924,8 +19979,8 @@ function passthroughTextModel(model) {
19924
19979
  pricingKind: "token"
19925
19980
  };
19926
19981
  }
19927
- var perplexityCostSchema = import_zod36.z.object({
19928
- perplexity: import_zod36.z.object({ cost: import_zod36.z.object({ totalCost: import_zod36.z.number().finite().nonnegative() }) })
19982
+ var perplexityCostSchema = import_zod37.z.object({
19983
+ perplexity: import_zod37.z.object({ cost: import_zod37.z.object({ totalCost: import_zod37.z.number().finite().nonnegative() }) })
19929
19984
  });
19930
19985
  function reportedCostUsd(metadata) {
19931
19986
  const parsed = perplexityCostSchema.safeParse(metadata);
@@ -19996,7 +20051,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
19996
20051
 
19997
20052
  // src/client.ts
19998
20053
  var import_ai5 = require("ai");
19999
- var import_zod37 = require("zod");
20054
+ var import_zod38 = require("zod");
20000
20055
 
20001
20056
  // src/generated-image.ts
20002
20057
  function toGeneratedImage(image) {
@@ -20415,10 +20470,10 @@ function textAbortOptions(sdk, context) {
20415
20470
  if (abortSignal) return { abortSignal };
20416
20471
  return {};
20417
20472
  }
20418
- var catalogId = import_zod37.z.string();
20419
- var exactSize = import_zod37.z.templateLiteral([import_zod37.z.number(), "x", import_zod37.z.number()]);
20420
- var sdkRatio = import_zod37.z.templateLiteral([import_zod37.z.number(), ":", import_zod37.z.number()]);
20421
- var sizeTier = import_zod37.z.enum(["512", "1K", "2K", "4K"]);
20473
+ var catalogId = import_zod38.z.string();
20474
+ var exactSize = import_zod38.z.templateLiteral([import_zod38.z.number(), "x", import_zod38.z.number()]);
20475
+ var sdkRatio = import_zod38.z.templateLiteral([import_zod38.z.number(), ":", import_zod38.z.number()]);
20476
+ var sizeTier = import_zod38.z.enum(["512", "1K", "2K", "4K"]);
20422
20477
  function isCatalogId(model) {
20423
20478
  return catalogId.safeParse(model).success;
20424
20479
  }
@@ -21141,6 +21196,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
21141
21196
  DEFAULT_ADAPTERS,
21142
21197
  ExposureSchema,
21143
21198
  IMAGE_INPUT_SPEC_KEYS,
21199
+ INPUT_BILLINGS,
21144
21200
  INPUT_SPEC_SUPPORTS_KEYS,
21145
21201
  InputSpecSchema,
21146
21202
  JsonObjectSchema,
@@ -21185,6 +21241,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
21185
21241
  hasAwsCredentials,
21186
21242
  higgsfieldAdapter,
21187
21243
  imageOutputFormats,
21244
+ inputBillingOf,
21188
21245
  isArrayInputSpecKey,
21189
21246
  isInputSpecKey,
21190
21247
  isListed,