@shop-os/modelkit 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,31 @@ header in the release PR.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.21.1] - Unreleased
13
+
14
+ ### Fixed
15
+ - Fish calls wait out a concurrency 429 (ENG-3951). Fish limits requests in flight per account
16
+ and sends no Retry-After; the default retry (3 attempts, ~3 s) gave up first, so a burst of
17
+ parallel speech failed. With `maxRetries` unset, a `rate_limited` response to TTS, voice clone,
18
+ voice design or voice delete now retries up
19
+ to 6 attempts with jittered backoff from 2 s to 20 s (about 40-50 s in total). Other errors
20
+ keep the default. `RetryOptions.rateLimited` sets that schedule for `withRetry`; rate-limit and
21
+ other failures each keep their own budget and backoff step, whatever order they come in.
22
+
23
+ ## [0.21.0] - Unreleased
24
+
25
+ ### Added
26
+ - `constraints.inputBilling` (ENG-3226): how a video row's provider bills what the request sends,
27
+ on top of what it renders: `seedance`, `omni`, `h3-max-reference`, `h3-reference`,
28
+ `grok-input-image`, `source-video-rate`, `kling-v4` or `input-plus-output`. Set on the Gemini
29
+ Omni, MiniMax H3 reference and insert, Grok Imagine, Kling 4.0 (and Flash, and their edits) and
30
+ Wan 3 rows. The rule only; the apps keep the rates.
31
+ - `inputBillingOf(row)` (also on `@shop-os/modelkit/catalog`) reads it: the row's own value, else
32
+ the kit row of the same id (a live row an older seed wrote), else `seedance` for an `ark` row,
33
+ else the data-only `flux-3` row's `source-video-rate`, else null. An invalid value reads as not
34
+ set. `INPUT_BILLINGS` lists the rules. The write path (`CatalogModelSchema`) rejects an unknown
35
+ rule; the read path keeps the row.
36
+
12
37
  ## [0.20.0] - Unreleased
13
38
 
14
39
  ### Added
package/README.md CHANGED
@@ -222,7 +222,8 @@ const result = await kit.generateImage(
222
222
 
223
223
  `maxRetries` counts retries after the first request. Zero disables adapter and SDK
224
224
  retries, failed status-read retries, and Google's Files-to-inline fallback. Successful
225
- pending-job responses still poll the same job. Unset retains existing adapter defaults.
225
+ pending-job responses still poll the same job. Unset retains existing adapter defaults;
226
+ Fish calls then wait out a concurrency 429 for up to 6 attempts (about 40-50 s, jittered).
226
227
  An explicit nonzero limit allows bounded submission retries; a later read failure never
227
228
  resubmits an already-created fal job. Text calls instead use AI SDK's first-argument
228
229
  `maxRetries: 0` option.
package/dist/catalog.cjs CHANGED
@@ -28,6 +28,7 @@ __export(catalog_entry_exports, {
28
28
  CatalogSchema: () => CatalogSchema,
29
29
  ExposureSchema: () => ExposureSchema,
30
30
  IMAGE_MODELS: () => IMAGE_MODELS,
31
+ INPUT_BILLINGS: () => INPUT_BILLINGS,
31
32
  MEDIA_METHODS: () => MEDIA_METHODS,
32
33
  MEDIA_NODE_MODELS: () => MEDIA_NODE_MODELS,
33
34
  MODEL3D_IMAGE_SLOTS: () => MODEL3D_IMAGE_SLOTS,
@@ -45,6 +46,7 @@ __export(catalog_entry_exports, {
45
46
  VideoResolutionSchema: () => VideoResolutionSchema,
46
47
  billedAudio: () => billedAudio,
47
48
  compareCatalogOrder: () => compareCatalogOrder,
49
+ inputBillingOf: () => inputBillingOf,
48
50
  isListed: () => isListed,
49
51
  isListedOn: () => isListedOn,
50
52
  isModelKitError: () => isModelKitError,
@@ -5452,6 +5454,7 @@ var VIDEO_FAMILY_MODELS = [
5452
5454
  lifecycle: "active",
5453
5455
  exposure: ["cowork", "space_builder"],
5454
5456
  constraints: {
5457
+ inputBilling: "kling-v4",
5455
5458
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5456
5459
  resolutions: ["720p", "1080p"],
5457
5460
  durations: { min: 3, max: 30 },
@@ -5491,6 +5494,7 @@ var VIDEO_FAMILY_MODELS = [
5491
5494
  lifecycle: "active",
5492
5495
  exposure: ["cowork", "space_builder"],
5493
5496
  constraints: {
5497
+ inputBilling: "kling-v4",
5494
5498
  resolutions: ["720p", "1080p"],
5495
5499
  durations: { min: 3, max: 30 },
5496
5500
  references: { ...NO_REFERENCES, images: 10 },
@@ -5526,6 +5530,7 @@ var VIDEO_FAMILY_MODELS = [
5526
5530
  lifecycle: "active",
5527
5531
  exposure: ["cowork", "space_builder"],
5528
5532
  constraints: {
5533
+ inputBilling: "kling-v4",
5529
5534
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5530
5535
  resolutions: ["720p"],
5531
5536
  durations: { min: 3, max: 20 },
@@ -5564,6 +5569,7 @@ var VIDEO_FAMILY_MODELS = [
5564
5569
  lifecycle: "active",
5565
5570
  exposure: ["cowork", "space_builder"],
5566
5571
  constraints: {
5572
+ inputBilling: "kling-v4",
5567
5573
  resolutions: ["720p"],
5568
5574
  durations: { min: 3, max: 20 },
5569
5575
  references: {
@@ -5645,6 +5651,7 @@ var VIDEO_FAMILY_MODELS = [
5645
5651
  lifecycle: "active",
5646
5652
  exposure: ["cowork", "space_builder"],
5647
5653
  constraints: {
5654
+ inputBilling: "h3-max-reference",
5648
5655
  resolutions: ["480p", "768p"],
5649
5656
  durations: { min: 5, max: 13 },
5650
5657
  references: { images: 9, videos: 3, audios: 0 },
@@ -5882,6 +5889,7 @@ var VIDEO_FAMILY_MODELS = [
5882
5889
  lifecycle: "active",
5883
5890
  exposure: ["cowork", "space_builder"],
5884
5891
  constraints: {
5892
+ inputBilling: "grok-input-image",
5885
5893
  aspectRatios: [...GROK_15_RATIOS],
5886
5894
  resolutions: ["480p", "720p", "1080p"],
5887
5895
  durations: { min: 1, max: 15 },
@@ -6159,6 +6167,7 @@ var VIDEO_MODELS = [
6159
6167
  replacedBy: "gemini-omni-1.1-flash",
6160
6168
  exposure: [],
6161
6169
  constraints: {
6170
+ inputBilling: "omni",
6162
6171
  // 1.0 rejects `resolution`; it renders 720p. No defaults: the adapter
6163
6172
  // sends ratio and duration only when the caller set them, so a
6164
6173
  // reference clip keeps its own framing.
@@ -6190,6 +6199,7 @@ var VIDEO_MODELS = [
6190
6199
  lifecycle: "active",
6191
6200
  exposure: ["cowork", "space_builder"],
6192
6201
  constraints: {
6202
+ inputBilling: "omni",
6193
6203
  aspectRatios: [...OMNI_RATIOS],
6194
6204
  resolutions: ["360p", "720p", "1080p", "4k"],
6195
6205
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
@@ -6234,6 +6244,7 @@ var VIDEO_MODELS = [
6234
6244
  lifecycle: "active",
6235
6245
  exposure: ["cowork", "space_builder"],
6236
6246
  constraints: {
6247
+ inputBilling: "omni",
6237
6248
  aspectRatios: [...OMNI_RATIOS],
6238
6249
  resolutions: ["360p", "720p", "1080p", "4k"],
6239
6250
  durations: { min: 3, max: 15 },
@@ -6410,6 +6421,7 @@ var VIDEO_MODELS = [
6410
6421
  lifecycle: "active",
6411
6422
  exposure: ["cowork", "space_builder"],
6412
6423
  constraints: {
6424
+ inputBilling: "grok-input-image",
6413
6425
  aspectRatios: [...GROK_RATIOS],
6414
6426
  resolutions: ["480p", "720p"],
6415
6427
  durations: { min: 1, max: 15 },
@@ -6611,6 +6623,7 @@ var VIDEO_MODELS = [
6611
6623
  lifecycle: "active",
6612
6624
  exposure: ["cowork", "space_builder"],
6613
6625
  constraints: {
6626
+ inputBilling: "h3-reference",
6614
6627
  aspectRatios: [...H3_REFERENCE_RATIOS],
6615
6628
  resolutions: ["480p", "768p", "2k", "4k"],
6616
6629
  durations: { min: 5, max: 15 },
@@ -6655,6 +6668,7 @@ var VIDEO_MODELS = [
6655
6668
  lifecycle: "active",
6656
6669
  exposure: ["cowork", "space_builder"],
6657
6670
  constraints: {
6671
+ inputBilling: "h3-max-reference",
6658
6672
  aspectRatios: [...H3_REFERENCE_RATIOS],
6659
6673
  resolutions: ["480p", "768p", "1080p"],
6660
6674
  durations: { min: 5, max: 15 },
@@ -6702,6 +6716,7 @@ var VIDEO_MODELS = [
6702
6716
  lifecycle: "active",
6703
6717
  exposure: ["cowork", "space_builder"],
6704
6718
  constraints: {
6719
+ inputBilling: "input-plus-output",
6705
6720
  aspectRatios: [...WAN_RATIOS],
6706
6721
  resolutions: ["480p", "720p", "1080p"],
6707
6722
  durations: { min: 2, max: 30 },
@@ -6743,6 +6758,7 @@ var VIDEO_MODELS = [
6743
6758
  lifecycle: "active",
6744
6759
  exposure: ["cowork", "space_builder"],
6745
6760
  constraints: {
6761
+ inputBilling: "input-plus-output",
6746
6762
  aspectRatios: [...WAN_RATIOS],
6747
6763
  resolutions: ["480p", "720p", "1080p"],
6748
6764
  durations: { min: 2, max: 30 },
@@ -7406,7 +7422,18 @@ var PromptConventionsSchema = import_zod.z.strictObject({
7406
7422
  referenceSyntax: ReferenceSyntaxSchema,
7407
7423
  maxChars: MaxCharsSchema.optional()
7408
7424
  });
7425
+ var InputBillingSchema = import_zod.z.enum([
7426
+ "seedance",
7427
+ "omni",
7428
+ "h3-max-reference",
7429
+ "h3-reference",
7430
+ "grok-input-image",
7431
+ "source-video-rate",
7432
+ "kling-v4",
7433
+ "input-plus-output"
7434
+ ]);
7409
7435
  var AUDIO_OUTPUTS = AudioOutputSchema.options;
7436
+ var INPUT_BILLINGS = InputBillingSchema.options;
7410
7437
  var REFERENCE_SYNTAXES = ReferenceSyntaxSchema.options;
7411
7438
  var ConstraintsReadView = import_zod.z.looseObject({
7412
7439
  audio: AudioOutputSchema.optional().catch(void 0),
@@ -8325,6 +8352,7 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
8325
8352
  // Loose on purpose: the read path keeps a row whose value is invalid (the accessors in
8326
8353
  // conventions.ts read it as "not set"); CatalogModelSchema below rejects it on write.
8327
8354
  audio: import_zod3.z.unknown().optional(),
8355
+ inputBilling: import_zod3.z.unknown().optional(),
8328
8356
  prompt: import_zod3.z.unknown().optional()
8329
8357
  });
8330
8358
  var MediaRefSchema = import_zod3.z.union([
@@ -8517,6 +8545,14 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
8517
8545
  message: 'audio must be "always", "optional" or "never"'
8518
8546
  });
8519
8547
  }
8548
+ const inputBilling = row2.constraints.inputBilling;
8549
+ if (inputBilling !== void 0 && !InputBillingSchema.safeParse(inputBilling).success) {
8550
+ ctx.addIssue({
8551
+ code: "custom",
8552
+ path: ["constraints", "inputBilling"],
8553
+ message: `inputBilling must be one of ${INPUT_BILLINGS.join(", ")}`
8554
+ });
8555
+ }
8520
8556
  const refs = row2.constraints.references;
8521
8557
  for (const kind of ["images", "videos", "audios"]) {
8522
8558
  const least = refs?.min?.[kind];
@@ -11010,4 +11046,23 @@ function referenceImageConformPlan(model, probe) {
11010
11046
  } : { ...frame };
11011
11047
  return { ...frame, image, reasons };
11012
11048
  }
11049
+
11050
+ // src/catalog/input-billing.ts
11051
+ var import_zod7 = require("zod");
11052
+ var DATA_ONLY_INPUT_BILLING = /* @__PURE__ */ new Map([
11053
+ ["flux-3", "source-video-rate"]
11054
+ ]);
11055
+ var KIT_INPUT_BILLING = new Map(
11056
+ MODELS.flatMap(
11057
+ (row2) => row2.constraints.inputBilling ? [[row2.id, row2.constraints.inputBilling]] : []
11058
+ )
11059
+ );
11060
+ var ConstraintsReadView2 = import_zod7.z.looseObject({
11061
+ inputBilling: InputBillingSchema.optional().catch(void 0)
11062
+ });
11063
+ function inputBillingOf(row2) {
11064
+ const view = ConstraintsReadView2.safeParse(row2.constraints);
11065
+ const own = view.success ? view.data.inputBilling : void 0;
11066
+ return own ?? KIT_INPUT_BILLING.get(row2.id) ?? (row2.adapter === "ark" ? "seedance" : void 0) ?? DATA_ONLY_INPUT_BILLING.get(row2.id) ?? null;
11067
+ }
11013
11068
  //# sourceMappingURL=catalog.cjs.map