@broberg/ai-sdk 0.55.3 → 0.56.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.
@@ -1,91 +1 @@
1
- type AvailabilityStatus = "available" | "suspended" | "unknown";
2
- /** Where a model's current availability came from: the curated default seed,
3
- * or a live provider refresh (Anthropic GET /v1/models). */
4
- type AvailabilitySource = "default" | "refresh";
5
- /** One row of the shared status read — what a UI model-picker renders. */
6
- interface ModelStatus {
7
- /** Canonical provider model id, e.g. "claude-fable-5". */
8
- id: string;
9
- /** Short/tier alias, e.g. "fable" (the first registered alias). */
10
- alias?: string;
11
- /** "anthropic" | "openai" | "gemini" | "mistral" | … */
12
- provider: string;
13
- available: boolean;
14
- status: AvailabilityStatus;
15
- /** Friendly reason, e.g. "suspended — US export-control directive (2026-06-12)". */
16
- note?: string;
17
- source: AvailabilitySource;
18
- }
19
- /** Result of resolveModel — the spawn / call path consumes this synchronously. */
20
- interface ResolveResult {
21
- /** True when the requested model itself is available. */
22
- ok: boolean;
23
- /** The id to actually use: `requested` when ok, else the first available fallback. */
24
- model: string;
25
- /** What the caller asked for (id or alias, normalized to the canonical id). */
26
- requested: string;
27
- provider?: string;
28
- /** True when `model` differs from `requested` because we fell back. */
29
- fellBack: boolean;
30
- status: AvailabilityStatus;
31
- /** Why it degraded / why it is unavailable. */
32
- reason?: string;
33
- /** The registry row's caveat, surfaced on the SUCCESS path too (F057.2).
34
- *
35
- * `reason` only ever appears when a model is unavailable, so a caveat written
36
- * on an AVAILABLE row — "documented to deprecate 2026-07-24", "preview", a
37
- * known rate limit — was reachable through listModels() and invisible to the
38
- * one caller who most needs it: the gate. A consumer passing requireKnown got
39
- * a clean green with the warning sitting one call away, unread. Carrying it
40
- * here costs an optional field and makes `ok:true` able to say "yes, but". */
41
- note?: string;
42
- }
43
- /** Thrown by resolveModel when the requested model is unavailable, no usable
44
- * fallback exists, and the caller passed `throwIfUnavailable`. Callers flag on
45
- * `.code === "model_unavailable"`. */
46
- declare class ModelUnavailableError extends Error {
47
- readonly code = "model_unavailable";
48
- readonly requested: string;
49
- readonly provider?: string;
50
- readonly note?: string;
51
- constructor(requested: string, note?: string, provider?: string);
52
- }
53
-
54
- interface ResolveOptions {
55
- /** One id/alias or an ordered chain to try when `requested` is unavailable. */
56
- fallback?: string | string[];
57
- /** Scope hint (passed through to the result); does not gate lookup. */
58
- provider?: string;
59
- /** Throw ModelUnavailableError instead of returning ok:false when there is no
60
- * usable fallback. For callers that want to flag rather than degrade. */
61
- throwIfUnavailable?: boolean;
62
- /** Treat an id we do not track as UNUSABLE instead of fail-open.
63
- *
64
- * Default is fail-open: we never block a model we simply do not track. That is
65
- * right for liveness, and wrong for a caller who is GATING — cms measured the
66
- * consequence: resolveModel("cheap") answered {ok:true, model:"cheap"}, so a
67
- * consumer following our own instruction to gate on `ok` passed the gate and
68
- * then sent the literal string "cheap" to a provider as a model id. A
69
- * success-shaped non-answer is worse than an error, because an error gets
70
- * handled and a shape does not.
71
- *
72
- * Set this when you need "a model you actually know about". Off by default so
73
- * no existing caller changes behaviour. */
74
- requireKnown?: boolean;
75
- }
76
- /** The shared status read — UI pickers grey out `available:false` rows. */
77
- declare function listModels(opts?: {
78
- provider?: string;
79
- }): ModelStatus[];
80
- /**
81
- * Resolve a requested model (id or alias) to one that is actually usable.
82
- * Synchronous + offline by contract (cardmem #4842) — reads the registry only.
83
- *
84
- * - Available → pass through ({ ok:true, fellBack:false }).
85
- * - Unavailable + a fallback that IS available → swap ({ ok:false, fellBack:true }).
86
- * - Unavailable + no usable fallback → throw (throwIfUnavailable) or return ok:false.
87
- * - Unknown id → treated available (never block a model we do not track).
88
- */
89
- declare function resolveModel(requested: string, opts?: ResolveOptions): ResolveResult;
90
-
91
- export { type AvailabilitySource, type AvailabilityStatus, type ModelStatus, ModelUnavailableError, type ResolveOptions, type ResolveResult, listModels, resolveModel };
1
+ export { q as AvailabilitySource, r as AvailabilityStatus, Q as ModelStatus, S as ModelUnavailableError, Z as ResolveOptions, _ as ResolveResult, a0 as TierDescription, a7 as describeTier, a8 as listModels, ab as resolveModel } from './registry-U66vzTm0.js';
package/dist/registry.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  ModelUnavailableError,
3
+ describeTier,
3
4
  listModels,
4
5
  resolveModel
5
- } from "./chunk-PDGFAD66.js";
6
+ } from "./chunk-VMQSIO3J.js";
7
+ import "./chunk-QVMGFHCF.js";
6
8
  export {
7
9
  ModelUnavailableError,
10
+ describeTier,
8
11
  listModels,
9
12
  resolveModel
10
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broberg/ai-sdk",
3
- "version": "0.55.3",
3
+ "version": "0.56.1",
4
4
  "description": "Unified AI/LLM SDK — one facade, all providers, all capabilities, first-class cost control on every call.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",