@molecule/api-ai 1.3.6 → 1.5.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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-25T20:03:21.617Z
6
+ Generated: 2026-10-31T03:38:14.444Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-ai
@@ -166,6 +166,15 @@ interface AiRateLimitEvent {
166
166
  retryInMs: number
167
167
  /** The response's parsed `Retry-After` header in seconds, when present and valid. */
168
168
  retryAfterSeconds?: number
169
+ /**
170
+ * The upstream's own explanation from the rejected response body, when it
171
+ * carried one: its error `type` (or `code`) and `message` (at most 500
172
+ * characters). A 429 is not always a rate limit — an account with no balance
173
+ * left is refused with 429 too (Moonshot `exceeded_current_quota_error`,
174
+ * OpenAI `insufficient_quota`) — so this is what tells an operator whether to
175
+ * wait or to recharge.
176
+ */
177
+ upstreamError?: { type?: string; message?: string }
169
178
  }
170
179
  ```
171
180
 
@@ -393,6 +402,27 @@ interface ChatParams {
393
402
  }
394
403
  ```
395
404
 
405
+ #### `ImageInputSize`
406
+
407
+ One image as the caller already knows it when a request is being sized.
408
+
409
+ Deliberately carries no payload: a provider that prices images from its own
410
+ documented rule never needs to decode the pixels, and a caller that has only
411
+ the encoded bytes has nothing a rule could be derived from. Providers whose
412
+ rule depends on the image itself return unknown rather than guess.
413
+
414
+ ```typescript
415
+ interface ImageInputSize {
416
+ /**
417
+ * Canonical catalog model id the caller selected for this request, BEFORE any
418
+ * provider alias mapping — the same id callers pass in `ChatParams.model`.
419
+ */
420
+ model: string
421
+ /** Media (MIME) type of the encoded payload, e.g. `image/png`. */
422
+ mediaType: string
423
+ }
424
+ ```
425
+
396
426
  #### `AIProvider`
397
427
 
398
428
  AI provider interface.
@@ -412,6 +442,27 @@ interface AIProvider {
412
442
  * @returns An async iterable that yields `ChatEvent` objects (text chunks, tool calls, done, or error).
413
443
  */
414
444
  chat(params: ChatParams): AsyncIterable<ChatEvent>
445
+
446
+ /**
447
+ * Price ONE image in input tokens, from this provider's own documented rule.
448
+ *
449
+ * OPTIONAL, and the only supported way to size image input: a caller that has
450
+ * no answer keeps whatever fallback it already used. An implementation must
451
+ * return `{ known: false }` — never a guess — for a model, media type or host
452
+ * the rule does not cover, and must not report a bound it cannot point at
453
+ * documentation for. The bound is per image and independent of how many
454
+ * images a request carries only when the provider's own docs say so.
455
+ *
456
+ * SYNCHRONOUS AND LOCAL BY CONTRACT: no network request (no counting endpoint,
457
+ * no tokenizer download), no image decoding, no dependency on credentials.
458
+ *
459
+ * Adding it to a bond is a capability, not an obligation: providers that omit
460
+ * it stay valid implementations and are treated as unable to price images.
461
+ *
462
+ * @param image - The model the caller selected and the image's media type.
463
+ * @returns A documented ceiling for that image, or an explicit unknown.
464
+ */
465
+ estimateImageInputTokens?(image: ImageInputSize): ImageInputTokenEstimate
415
466
  }
416
467
  ```
417
468
 
@@ -529,6 +580,35 @@ guard it anyway); keep it fast — it runs on the request path.
529
580
  type AiStreamStallCallback = (event: AiStreamStallEvent) => void
530
581
  ```
531
582
 
583
+ #### `ImageInputTokenEstimate`
584
+
585
+ A provider's own answer about what ONE image costs in input tokens.
586
+
587
+ A discriminated union rather than a nullable number: `known: false` is a
588
+ statement ("this provider cannot price this image"), and a caller must keep
589
+ its existing fallback rather than read the absence as a conservative bound.
590
+
591
+ ```typescript
592
+ type ImageInputTokenEstimate =
593
+ | {
594
+ /** The provider priced this image from a rule it documents for this model. */
595
+ known: true
596
+ /**
597
+ * A CEILING on the input tokens this image occupies. A bound, not an exact
598
+ * count — the provider's own usage report is the only exact figure — and
599
+ * documented for one provider/model, never a cross-provider assumption.
600
+ */
601
+ upperBoundTokens: number
602
+ }
603
+ | {
604
+ /**
605
+ * The provider cannot price this image: an unsupported model or media
606
+ * type, or a host whose backend the documented rule does not cover.
607
+ */
608
+ known: false
609
+ }
610
+ ```
611
+
532
612
  ### Functions
533
613
 
534
614
  #### `setProvider(provider)`
@@ -621,6 +701,32 @@ function requireProvider(): AIProvider
621
701
 
622
702
  **Returns:** The bonded AI provider.
623
703
 
704
+ #### `estimateImageInputTokens(provider, image)`
705
+
706
+ Ask the provider that will serve a request what ONE image costs in input
707
+ tokens.
708
+
709
+ This is the accessor consumers should use instead of reaching for the
710
+ optional method themselves, so every caller applies the same three rules:
711
+ a provider that does not implement the capability answers unknown, a bond
712
+ that returns something that is not a usable ceiling (missing, negative, NaN,
713
+ Infinity) is treated as unknown rather than trusted, and a missing provider
714
+ is unknown rather than an exception. Unknown means "this provider cannot
715
+ price the image" — it is NOT a conservative bound, so callers keep whatever
716
+ fallback they already had and must not present it as one.
717
+
718
+ ```typescript
719
+ function estimateImageInputTokens(
720
+ provider: AIProvider | null | undefined,
721
+ image: ImageInputSize,
722
+ ): ImageInputTokenEstimate
723
+ ```
724
+
725
+ - `provider` — The provider selected for this request, or null when none was.
726
+ - `image` — The selected model id and the image's media type.
727
+
728
+ **Returns:** The provider's documented ceiling, or an explicit unknown.
729
+
624
730
  ## Available Providers
625
731
 
626
732
  | Provider | Package |
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @module
10
10
  */
11
- import type { AIProvider } from './types.js';
11
+ import type { AIProvider, ImageInputSize, ImageInputTokenEstimate } from './types.js';
12
12
  /**
13
13
  * Registers an AI provider in singleton mode.
14
14
  *
@@ -94,4 +94,22 @@ export declare function hasProvider(name?: string): boolean;
94
94
  * @returns The bonded AI provider.
95
95
  */
96
96
  export declare function requireProvider(): AIProvider;
97
+ /**
98
+ * Ask the provider that will serve a request what ONE image costs in input
99
+ * tokens.
100
+ *
101
+ * This is the accessor consumers should use instead of reaching for the
102
+ * optional method themselves, so every caller applies the same three rules:
103
+ * a provider that does not implement the capability answers unknown, a bond
104
+ * that returns something that is not a usable ceiling (missing, negative, NaN,
105
+ * Infinity) is treated as unknown rather than trusted, and a missing provider
106
+ * is unknown rather than an exception. Unknown means "this provider cannot
107
+ * price the image" — it is NOT a conservative bound, so callers keep whatever
108
+ * fallback they already had and must not present it as one.
109
+ *
110
+ * @param provider - The provider selected for this request, or null when none was.
111
+ * @param image - The selected model id and the image's media type.
112
+ * @returns The provider's documented ceiling, or an explicit unknown.
113
+ */
114
+ export declare function estimateImageInputTokens(provider: AIProvider | null | undefined, image: ImageInputSize): ImageInputTokenEstimate;
97
115
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAiB5C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAA;AACvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAA;AAoDrE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,IAAI,UAAU,GAAG,IAAI,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAgB5C"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAiBrF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAA;AACvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAA;AAoDrE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,IAAI,UAAU,GAAG,IAAI,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAgB5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACvC,KAAK,EAAE,cAAc,GACpB,uBAAuB,CAWzB"}
package/dist/provider.js CHANGED
@@ -150,3 +150,30 @@ export function requireProvider() {
150
150
  defaultValue: 'AI provider not configured. Bond an AI provider first.',
151
151
  }));
152
152
  }
153
+ /**
154
+ * Ask the provider that will serve a request what ONE image costs in input
155
+ * tokens.
156
+ *
157
+ * This is the accessor consumers should use instead of reaching for the
158
+ * optional method themselves, so every caller applies the same three rules:
159
+ * a provider that does not implement the capability answers unknown, a bond
160
+ * that returns something that is not a usable ceiling (missing, negative, NaN,
161
+ * Infinity) is treated as unknown rather than trusted, and a missing provider
162
+ * is unknown rather than an exception. Unknown means "this provider cannot
163
+ * price the image" — it is NOT a conservative bound, so callers keep whatever
164
+ * fallback they already had and must not present it as one.
165
+ *
166
+ * @param provider - The provider selected for this request, or null when none was.
167
+ * @param image - The selected model id and the image's media type.
168
+ * @returns The provider's documented ceiling, or an explicit unknown.
169
+ */
170
+ export function estimateImageInputTokens(provider, image) {
171
+ const estimate = provider?.estimateImageInputTokens?.(image);
172
+ if (!estimate ||
173
+ estimate.known !== true ||
174
+ !Number.isFinite(estimate.upperBoundTokens) ||
175
+ estimate.upperBoundTokens < 0) {
176
+ return { known: false };
177
+ }
178
+ return estimate;
179
+ }
package/dist/types.d.ts CHANGED
@@ -185,6 +185,18 @@ export interface AiRateLimitEvent {
185
185
  retryInMs: number;
186
186
  /** The response's parsed `Retry-After` header in seconds, when present and valid. */
187
187
  retryAfterSeconds?: number;
188
+ /**
189
+ * The upstream's own explanation from the rejected response body, when it
190
+ * carried one: its error `type` (or `code`) and `message` (at most 500
191
+ * characters). A 429 is not always a rate limit — an account with no balance
192
+ * left is refused with 429 too (Moonshot `exceeded_current_quota_error`,
193
+ * OpenAI `insufficient_quota`) — so this is what tells an operator whether to
194
+ * wait or to recharge.
195
+ */
196
+ upstreamError?: {
197
+ type?: string;
198
+ message?: string;
199
+ };
188
200
  }
189
201
  /**
190
202
  * Callback invoked on each rate-limited/overloaded upstream response. Must not
@@ -409,6 +421,46 @@ export interface ChatParams {
409
421
  */
410
422
  extraBody?: Record<string, unknown>;
411
423
  }
424
+ /**
425
+ * One image as the caller already knows it when a request is being sized.
426
+ *
427
+ * Deliberately carries no payload: a provider that prices images from its own
428
+ * documented rule never needs to decode the pixels, and a caller that has only
429
+ * the encoded bytes has nothing a rule could be derived from. Providers whose
430
+ * rule depends on the image itself return unknown rather than guess.
431
+ */
432
+ export interface ImageInputSize {
433
+ /**
434
+ * Canonical catalog model id the caller selected for this request, BEFORE any
435
+ * provider alias mapping — the same id callers pass in `ChatParams.model`.
436
+ */
437
+ model: string;
438
+ /** Media (MIME) type of the encoded payload, e.g. `image/png`. */
439
+ mediaType: string;
440
+ }
441
+ /**
442
+ * A provider's own answer about what ONE image costs in input tokens.
443
+ *
444
+ * A discriminated union rather than a nullable number: `known: false` is a
445
+ * statement ("this provider cannot price this image"), and a caller must keep
446
+ * its existing fallback rather than read the absence as a conservative bound.
447
+ */
448
+ export type ImageInputTokenEstimate = {
449
+ /** The provider priced this image from a rule it documents for this model. */
450
+ known: true;
451
+ /**
452
+ * A CEILING on the input tokens this image occupies. A bound, not an exact
453
+ * count — the provider's own usage report is the only exact figure — and
454
+ * documented for one provider/model, never a cross-provider assumption.
455
+ */
456
+ upperBoundTokens: number;
457
+ } | {
458
+ /**
459
+ * The provider cannot price this image: an unsupported model or media
460
+ * type, or a host whose backend the documented rule does not cover.
461
+ */
462
+ known: false;
463
+ };
412
464
  /**
413
465
  * AI provider interface.
414
466
  *
@@ -425,6 +477,26 @@ export interface AIProvider {
425
477
  * @returns An async iterable that yields `ChatEvent` objects (text chunks, tool calls, done, or error).
426
478
  */
427
479
  chat(params: ChatParams): AsyncIterable<ChatEvent>;
480
+ /**
481
+ * Price ONE image in input tokens, from this provider's own documented rule.
482
+ *
483
+ * OPTIONAL, and the only supported way to size image input: a caller that has
484
+ * no answer keeps whatever fallback it already used. An implementation must
485
+ * return `{ known: false }` — never a guess — for a model, media type or host
486
+ * the rule does not cover, and must not report a bound it cannot point at
487
+ * documentation for. The bound is per image and independent of how many
488
+ * images a request carries only when the provider's own docs say so.
489
+ *
490
+ * SYNCHRONOUS AND LOCAL BY CONTRACT: no network request (no counting endpoint,
491
+ * no tokenizer download), no image decoding, no dependency on credentials.
492
+ *
493
+ * Adding it to a bond is a capability, not an obligation: providers that omit
494
+ * it stay valid implementations and are treated as unable to price images.
495
+ *
496
+ * @param image - The model the caller selected and the image's media type.
497
+ * @returns A documented ceiling for that image, or an explicit unknown.
498
+ */
499
+ estimateImageInputTokens?(image: ImageInputSize): ImageInputTokenEstimate;
428
500
  }
429
501
  /**
430
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cAAc,GAAG,uBAAuB,CAAA;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai",
3
- "version": "1.3.6",
3
+ "version": "1.5.0",
4
4
  "description": "Model-agnostic AI provider interface with streaming chat and tool use",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "@molecule/api-i18n": "^1.0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/api-bond": "1.0.3",
37
- "@molecule/api-i18n": "1.0.4",
36
+ "@molecule/api-bond": "1.0.4",
37
+ "@molecule/api-i18n": "1.0.5",
38
38
  "@types/node": "26.6.5",
39
39
  "typescript": "6.0.3",
40
40
  "vitest": "4.1.12"