@broberg/ai-sdk 0.11.0 → 0.13.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.
@@ -0,0 +1,69 @@
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
+ }
34
+ /** Thrown by resolveModel when the requested model is unavailable, no usable
35
+ * fallback exists, and the caller passed `throwIfUnavailable`. Callers flag on
36
+ * `.code === "model_unavailable"`. */
37
+ declare class ModelUnavailableError extends Error {
38
+ readonly code = "model_unavailable";
39
+ readonly requested: string;
40
+ readonly provider?: string;
41
+ readonly note?: string;
42
+ constructor(requested: string, note?: string, provider?: string);
43
+ }
44
+
45
+ interface ResolveOptions {
46
+ /** One id/alias or an ordered chain to try when `requested` is unavailable. */
47
+ fallback?: string | string[];
48
+ /** Scope hint (passed through to the result); does not gate lookup. */
49
+ provider?: string;
50
+ /** Throw ModelUnavailableError instead of returning ok:false when there is no
51
+ * usable fallback. For callers that want to flag rather than degrade. */
52
+ throwIfUnavailable?: boolean;
53
+ }
54
+ /** The shared status read — UI pickers grey out `available:false` rows. */
55
+ declare function listModels(opts?: {
56
+ provider?: string;
57
+ }): ModelStatus[];
58
+ /**
59
+ * Resolve a requested model (id or alias) to one that is actually usable.
60
+ * Synchronous + offline by contract (cardmem #4842) — reads the registry only.
61
+ *
62
+ * - Available → pass through ({ ok:true, fellBack:false }).
63
+ * - Unavailable + a fallback that IS available → swap ({ ok:false, fellBack:true }).
64
+ * - Unavailable + no usable fallback → throw (throwIfUnavailable) or return ok:false.
65
+ * - Unknown id → treated available (never block a model we do not track).
66
+ */
67
+ declare function resolveModel(requested: string, opts?: ResolveOptions): ResolveResult;
68
+
69
+ export { type AvailabilitySource, type AvailabilityStatus, type ModelStatus, ModelUnavailableError, type ResolveOptions, type ResolveResult, listModels, resolveModel };
@@ -0,0 +1,11 @@
1
+ import {
2
+ ModelUnavailableError,
3
+ listModels,
4
+ resolveModel
5
+ } from "./chunk-HVZSYNZ5.js";
6
+ export {
7
+ ModelUnavailableError,
8
+ listModels,
9
+ resolveModel
10
+ };
11
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broberg/ai-sdk",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
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",
@@ -20,6 +20,10 @@
20
20
  ".": {
21
21
  "types": "./dist/index.d.ts",
22
22
  "import": "./dist/index.js"
23
+ },
24
+ "./registry": {
25
+ "types": "./dist/registry.d.ts",
26
+ "import": "./dist/registry.js"
23
27
  }
24
28
  },
25
29
  "scripts": {