@theokit/sdk 4.12.2 → 4.13.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.
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
+ import { type CatalogModel } from "./catalog-schema.js";
9
10
  import type { ApiMode, AuthType } from "./types.js";
10
11
  export interface ProviderCapabilities {
11
12
  supportsToolUse: boolean;
@@ -29,6 +30,13 @@ export interface CatalogEntry {
29
30
  modelsUrl?: string;
30
31
  hostname?: string;
31
32
  extraHeaders?: Record<string, string>;
33
+ /**
34
+ * M44 — OPTIONAL per-model data (models.dev shape, snake_case — see `catalog-schema.ts`), keyed by the
35
+ * BARE model id. Additive: entries without it behave byte-identically to before. The loader indexes this
36
+ * into the model-info index (`getCatalogModelInfo`) rather than onto `ProviderProfile` (ADR D2 — the
37
+ * builtins-first registration skip means profile-attached data would never reach builtin providers).
38
+ */
39
+ models?: Record<string, CatalogModel>;
32
40
  }
33
41
  interface LoadOptions {
34
42
  _testInjectMalformed?: boolean;
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ export type Modality = (typeof MODALITIES)[number];
3
+ declare const costSchema: z.ZodObject<{
4
+ input: z.ZodNumber;
5
+ output: z.ZodNumber;
6
+ cache_read: z.ZodOptional<z.ZodNumber>;
7
+ cache_write: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$loose>;
9
+ export declare const catalogModelSchema: z.ZodObject<{
10
+ name: z.ZodOptional<z.ZodString>;
11
+ release_date: z.ZodOptional<z.ZodString>;
12
+ attachment: z.ZodOptional<z.ZodBoolean>;
13
+ reasoning: z.ZodOptional<z.ZodBoolean>;
14
+ temperature: z.ZodOptional<z.ZodBoolean>;
15
+ tool_call: z.ZodOptional<z.ZodBoolean>;
16
+ structured_output: z.ZodOptional<z.ZodBoolean>;
17
+ cache_control: z.ZodOptional<z.ZodBoolean>;
18
+ cost: z.ZodOptional<z.ZodObject<{
19
+ input: z.ZodNumber;
20
+ output: z.ZodNumber;
21
+ cache_read: z.ZodOptional<z.ZodNumber>;
22
+ cache_write: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$loose>>;
24
+ limit: z.ZodOptional<z.ZodObject<{
25
+ context: z.ZodNumber;
26
+ input: z.ZodOptional<z.ZodNumber>;
27
+ output: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$loose>>;
29
+ modalities: z.ZodOptional<z.ZodObject<{
30
+ input: z.ZodOptional<z.ZodArray<z.ZodEnum<{
31
+ text: "text";
32
+ image: "image";
33
+ audio: "audio";
34
+ video: "video";
35
+ pdf: "pdf";
36
+ }>>>;
37
+ output: z.ZodOptional<z.ZodArray<z.ZodEnum<{
38
+ text: "text";
39
+ image: "image";
40
+ audio: "audio";
41
+ video: "video";
42
+ pdf: "pdf";
43
+ }>>>;
44
+ }, z.core.$loose>>;
45
+ status: z.ZodOptional<z.ZodEnum<{
46
+ alpha: "alpha";
47
+ beta: "beta";
48
+ deprecated: "deprecated";
49
+ }>>;
50
+ }, z.core.$loose>;
51
+ export type CatalogModel = z.infer<typeof catalogModelSchema>;
52
+ export type CatalogModelCost = z.infer<typeof costSchema>;
53
+ export {};
@@ -0,0 +1,33 @@
1
+ import { getCatalogModelInfo } from "./catalog-loader.js";
2
+ export interface RefreshModelCatalogOptions {
3
+ /** Override the source URL (`THEOKIT_MODELS_URL` env also honored). */
4
+ url?: string;
5
+ /** Bypass the TTL freshness gate. */
6
+ force?: boolean;
7
+ /** Injected for tests. */
8
+ deps?: {
9
+ fetch?: typeof fetch;
10
+ now?: () => number;
11
+ };
12
+ }
13
+ export interface RefreshModelCatalogResult {
14
+ /** Where the data came from: a fresh network fetch, the still-fresh disk cache, or skipped entirely. */
15
+ source: "network" | "cache" | "skipped";
16
+ /** How many models were patched into the index. */
17
+ models: number;
18
+ }
19
+ /** The cache file for a source URL (custom URLs get a hash-suffixed name, mirroring OpenCode). */
20
+ export declare function cachePathFor(url: string): string;
21
+ /**
22
+ * Load an existing disk cache into the index (called by refresh when fresh, or opportunistically by a
23
+ * consumer at startup — NEVER fetches). Corrupt cache → delete + fall through to vendored data.
24
+ */
25
+ export declare function loadCacheIntoIndex(url?: string): number;
26
+ /**
27
+ * Explicitly refresh the model catalog from models.dev (the ONLY network trigger in the subsystem).
28
+ * Fail-closed: any failure keeps serving the current index (cache or vendored). Kill-switch:
29
+ * `THEOKIT_DISABLE_MODELS_FETCH`.
30
+ */
31
+ export declare function refreshModelCatalog(opts?: RefreshModelCatalogOptions): Promise<RefreshModelCatalogResult>;
32
+ /** The enriched per-model view (public via `@theokit/sdk/models`): index lookup by (possibly prefixed) id. */
33
+ export declare function getModelInfo(modelId: string): ReturnType<typeof getCatalogModelInfo>;