@dbx-tools/shared-model 0.9.31 → 0.9.36

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/src/contracts.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  /** Browser-safe model contracts owned by the TypeScript model runtime. */
2
2
 
3
+ /** Intent-oriented endpoint class slug. */
4
+ export type ModelClass = "chat-thinking" | "chat-balanced" | "chat-fast" | "embedding";
5
+
3
6
  export const ModelClass = {
4
7
  ChatThinking: "chat-thinking",
5
8
  ChatBalanced: "chat-balanced",
6
9
  ChatFast: "chat-fast",
7
10
  Embedding: "embedding",
8
- } as const;
9
- /** Intent-oriented endpoint class slug. */
10
- export type ModelClass = (typeof ModelClass)[keyof typeof ModelClass];
11
+ } as const satisfies Record<string, ModelClass>;
12
+
13
+ /** Reasoning effort value accepted by compatible model endpoints. */
14
+ export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
11
15
 
12
16
  export const ReasoningEffort = {
13
17
  None: "none",
@@ -17,9 +21,7 @@ export const ReasoningEffort = {
17
21
  High: "high",
18
22
  Xhigh: "xhigh",
19
23
  Max: "max",
20
- } as const;
21
- /** Reasoning effort value accepted by compatible model endpoints. */
22
- export type ReasoningEffort = (typeof ReasoningEffort)[keyof typeof ReasoningEffort];
24
+ } as const satisfies Record<string, ReasoningEffort>;
23
25
 
24
26
  /** Relative quality, speed, and cost scores for an endpoint. */
25
27
  export interface ModelProfile {
@@ -33,7 +35,11 @@ export interface ModelProfile {
33
35
 
34
36
  /** Model retirement status. */
35
37
  export interface ModelStatus {
36
- /** Whether Databricks lists the model as retired or deprecated. */
38
+ /**
39
+ * Whether Databricks lists the model as retired or deprecated.
40
+ *
41
+ * @default false
42
+ */
37
43
  readonly deprecated: boolean;
38
44
  }
39
45
 
@@ -58,11 +64,11 @@ export interface ServingEndpointSummary {
58
64
  /** Intent-oriented endpoint class. */
59
65
  readonly class?: ModelClass;
60
66
  /** Provider names mapped to provider-specific model names. */
61
- readonly serviceNames?: Readonly<Record<string, string>>;
67
+ readonly serviceNames?: Record<string, string>;
62
68
  /** Foundation model name reported by the served entity. */
63
69
  readonly modelServiceName?: string;
64
70
  /** Reasoning effort values accepted by the endpoint. */
65
- readonly reasoningEfforts?: readonly ReasoningEffort[];
71
+ readonly reasoningEfforts?: ReasoningEffort[];
66
72
  /** Retirement status for the served model. */
67
73
  readonly status?: ModelStatus;
68
74
  /** Embedding vector dimension measured by the caller, when available. */
@@ -79,9 +85,18 @@ export interface ModelQuery {
79
85
  readonly requiresTools?: boolean;
80
86
  /** Whether retired models remain eligible. */
81
87
  readonly includeDeprecated?: boolean;
82
- /** Maximum number of results. */
88
+ /**
89
+ * Maximum number of results.
90
+ *
91
+ * @schema number().int().min(1).max(50).optional()
92
+ */
83
93
  readonly limit?: number;
84
- /** Maximum fuzzy-match distance. */
94
+ /**
95
+ * Maximum fuzzy-match distance.
96
+ *
97
+ * @minimum 0
98
+ * @maximum 1
99
+ */
85
100
  readonly threshold?: number;
86
101
  }
87
102
 
@@ -91,6 +106,113 @@ export interface RankedModel {
91
106
  readonly endpoint: ServingEndpointSummary;
92
107
  /** Intent-oriented endpoint class. */
93
108
  readonly modelClass: ModelClass;
94
- /** Fuzzy-match distance, where lower values are closer. */
109
+ /**
110
+ * Fuzzy-match distance, where lower values are closer.
111
+ *
112
+ * @minimum 0
113
+ * @maximum 1
114
+ */
115
+ readonly score?: number;
116
+ }
117
+
118
+ /** Capabilities derived from one normalized serving endpoint. */
119
+ export interface EndpointCapabilities {
120
+ /** Whether the endpoint accepts chat or Responses requests. */
121
+ readonly chat: boolean;
122
+ /** Whether the endpoint produces embedding vectors. */
123
+ readonly embedding: boolean;
124
+ /** Whether the endpoint supports a complete function-tool round trip. */
125
+ readonly tools: boolean;
126
+ }
127
+
128
+ /** Fallback class and rank for an unscored recognized model family. */
129
+ export interface FamilyClass {
130
+ /** Chat capability band assigned to the family. */
131
+ readonly class: ModelClass;
132
+ /**
133
+ * Intra-family ordering hint.
134
+ *
135
+ * @minimum 0
136
+ */
137
+ readonly rank: number;
138
+ }
139
+
140
+ /** Documented capabilities resolved for one model identity. */
141
+ export interface ModelCapabilities {
142
+ readonly responses: boolean;
143
+ readonly imageInput: boolean;
144
+ readonly applyPatch: boolean;
145
+ readonly webSearch: boolean;
146
+ }
147
+
148
+ /** Published pay-per-token limits for one model. */
149
+ export interface ModelRateLimits {
150
+ /** @schema number().int().min(0).nullable() */
151
+ readonly inputTokensPerMinute: number | null;
152
+ /** @schema number().int().min(0).nullable() */
153
+ readonly outputTokensPerMinute: number | null;
154
+ /** @schema number().int().min(0).nullable() */
155
+ readonly queriesPerHour: number | null;
156
+ }
157
+
158
+ /** Combined retirement, capability, and rate-limit metadata. */
159
+ export interface ModelMetadata {
160
+ readonly status: ModelStatus;
161
+ readonly capabilities: ModelCapabilities;
162
+ readonly rateLimits?: ModelRateLimits;
163
+ }
164
+
165
+ /** Result of resolving a fuzzy model identifier. */
166
+ export interface ResolvedModel {
167
+ readonly modelId: string;
168
+ readonly matched: boolean;
169
+ /**
170
+ * @minimum 0
171
+ * @maximum 1
172
+ */
95
173
  readonly score?: number;
96
174
  }
175
+
176
+ /** Pure controls for fuzzy endpoint resolution. */
177
+ export interface ResolveModelOptions {
178
+ /**
179
+ * Maximum fuzzy-match distance.
180
+ *
181
+ * @minimum 0
182
+ * @maximum 1
183
+ */
184
+ readonly threshold?: number;
185
+ /** Whether candidates must support tool calling. */
186
+ readonly requiresTools?: boolean;
187
+ }
188
+
189
+ /** One endpoint paired with its fuzzy-match distance. */
190
+ export interface ScoredEndpoint {
191
+ readonly endpoint: ServingEndpointSummary;
192
+ /**
193
+ * @minimum 0
194
+ * @maximum 1
195
+ */
196
+ readonly score: number;
197
+ }
198
+
199
+ /** Caller intent used to resolve one model from a catalogue. */
200
+ export interface ResolveModelInput {
201
+ readonly explicit?: string;
202
+ readonly fuzzy?: boolean;
203
+ /**
204
+ * @minimum 0
205
+ * @maximum 1
206
+ */
207
+ readonly threshold?: number;
208
+ readonly requiresTools?: boolean;
209
+ readonly modelClass?: ModelClass;
210
+ readonly fallbacks?: string[];
211
+ readonly liveOnly?: boolean;
212
+ }
213
+
214
+ /** Selected model identifier and the policy branch that selected it. */
215
+ export interface ResolvedModelSelection {
216
+ readonly modelId: string;
217
+ readonly source: "explicit" | "fuzzy-match" | "class" | "fallback";
218
+ }
@@ -1,136 +1,127 @@
1
1
  // Generated by ts-to-zod
2
2
  import { z } from "zod";
3
3
 
4
+ /** Browser-safe model contracts owned by the TypeScript model runtime. */
5
+ /** Intent-oriented endpoint class slug. */
4
6
  export const modelClassSchema = z.union([z.literal("chat-thinking"), z.literal("chat-balanced"), z.literal("chat-fast"), z.literal("embedding")]);
5
7
 
8
+ /** Reasoning effort value accepted by compatible model endpoints. */
6
9
  export const reasoningEffortSchema = z.union([z.literal("none"), z.literal("minimal"), z.literal("low"), z.literal("medium"), z.literal("high"), z.literal("xhigh"), z.literal("max")]);
7
10
 
11
+ /** Relative quality, speed, and cost scores for an endpoint. */
8
12
  export const modelProfileSchema = z.object({
9
- /**
10
- * Relative model quality score.
11
- */
12
13
  quality: z.number().optional(),
13
- /**
14
- * Relative model speed score.
15
- */
16
14
  speed: z.number().optional(),
17
- /**
18
- * Relative model cost score.
19
- */
20
15
  cost: z.number().optional()
21
16
  });
22
17
 
18
+ /** Model retirement status. */
23
19
  export const modelStatusSchema = z.object({
24
- /**
25
- * Whether Databricks lists the model as retired or deprecated.
26
- *
27
- * @default false
28
- */
29
20
  deprecated: z.boolean().default(false)
30
21
  });
31
22
 
23
+ /** Browser-safe normalized Model Serving endpoint metadata. */
32
24
  export const servingEndpointSummarySchema = z.object({
33
- /**
34
- * Model Serving endpoint name used for invocation.
35
- */
36
25
  name: z.string(),
37
- /**
38
- * Human-readable endpoint or model name.
39
- */
40
26
  displayName: z.string().optional(),
41
- /**
42
- * Normalized model family parsed from the endpoint identities.
43
- */
44
27
  family: z.string().optional(),
45
- /**
46
- * Endpoint task, such as chat or embeddings.
47
- */
48
28
  task: z.string().optional(),
49
- /**
50
- * Endpoint readiness state.
51
- */
52
29
  state: z.string().optional(),
53
- /**
54
- * Endpoint description supplied by Databricks.
55
- */
56
30
  description: z.string().optional(),
57
- /**
58
- * Whether the endpoint supports tool calling.
59
- */
60
31
  supportsTools: z.boolean().optional(),
61
- /**
62
- * AI Gateway model profile scores.
63
- */
64
32
  profile: modelProfileSchema.optional(),
65
- /**
66
- * Intent-oriented endpoint class.
67
- */
68
33
  class: modelClassSchema.optional(),
69
- /**
70
- * Provider names mapped to provider-specific model names.
71
- */
72
34
  serviceNames: z.record(z.string(), z.string()).optional(),
73
- /**
74
- * Foundation model name reported by the served entity.
75
- */
76
35
  modelServiceName: z.string().optional(),
77
- /**
78
- * Reasoning effort values accepted by the endpoint.
79
- */
80
36
  reasoningEfforts: z.array(reasoningEffortSchema).optional(),
81
- /**
82
- * Retirement status for the served model.
83
- */
84
37
  status: modelStatusSchema.optional(),
85
- /**
86
- * Embedding vector dimension measured by the caller, when available.
87
- */
88
38
  dimension: z.number().optional()
89
39
  });
90
40
 
41
+ /** Browser-safe model catalogue search and ranking controls. */
91
42
  export const modelQuerySchema = z.object({
92
- /**
93
- * Optional fuzzy model-name search.
94
- */
95
43
  search: z.string().optional(),
96
- /**
97
- * Requested model-class ceiling, or the exact embedding class.
98
- */
99
44
  modelClass: modelClassSchema.optional(),
100
- /**
101
- * Whether candidates must support tool calling.
102
- */
103
45
  requiresTools: z.boolean().optional(),
104
- /**
105
- * Whether retired models remain eligible.
106
- */
107
46
  includeDeprecated: z.boolean().optional(),
108
- /**
109
- * Maximum number of results.
110
- *
111
- * @schema number().int().min(1).max(50).optional()
112
- */
113
47
  limit: z.number().int().min(1).max(50).optional(),
114
- /**
115
- * Maximum fuzzy-match distance.
116
- *
117
- * @minimum 0
118
- * @maximum 1
119
- */
120
48
  threshold: z.number().min(0).max(1).optional()
121
49
  });
122
50
 
51
+ /** One ranked model-search result. */
123
52
  export const rankedModelSchema = z.object({
124
- /**
125
- * Matching endpoint metadata.
126
- */
127
53
  endpoint: servingEndpointSummarySchema,
128
- /**
129
- * Intent-oriented endpoint class.
130
- */
131
54
  modelClass: modelClassSchema,
132
- /**
133
- * Fuzzy-match distance, where lower values are closer.
134
- */
135
- score: z.number().optional()
55
+ score: z.number().min(0).max(1).optional()
56
+ });
57
+
58
+ /** Capabilities derived from one normalized serving endpoint. */
59
+ export const endpointCapabilitiesSchema = z.object({
60
+ chat: z.boolean(),
61
+ embedding: z.boolean(),
62
+ tools: z.boolean()
63
+ });
64
+
65
+ /** Fallback class and rank for an unscored recognized model family. */
66
+ export const familyClassSchema = z.object({
67
+ class: modelClassSchema,
68
+ rank: z.number().min(0)
69
+ });
70
+
71
+ /** Documented capabilities resolved for one model identity. */
72
+ export const modelCapabilitiesSchema = z.object({
73
+ responses: z.boolean(),
74
+ imageInput: z.boolean(),
75
+ applyPatch: z.boolean(),
76
+ webSearch: z.boolean()
77
+ });
78
+
79
+ /** Published pay-per-token limits for one model. */
80
+ export const modelRateLimitsSchema = z.object({
81
+ inputTokensPerMinute: z.number().int().min(0).nullable(),
82
+ outputTokensPerMinute: z.number().int().min(0).nullable(),
83
+ queriesPerHour: z.number().int().min(0).nullable()
84
+ });
85
+
86
+ /** Combined retirement, capability, and rate-limit metadata. */
87
+ export const modelMetadataSchema = z.object({
88
+ status: modelStatusSchema,
89
+ capabilities: modelCapabilitiesSchema,
90
+ rateLimits: modelRateLimitsSchema.optional()
91
+ });
92
+
93
+ /** Result of resolving a fuzzy model identifier. */
94
+ export const resolvedModelSchema = z.object({
95
+ modelId: z.string(),
96
+ matched: z.boolean(),
97
+ score: z.number().min(0).max(1).optional()
98
+ });
99
+
100
+ /** Pure controls for fuzzy endpoint resolution. */
101
+ export const resolveModelOptionsSchema = z.object({
102
+ threshold: z.number().min(0).max(1).optional(),
103
+ requiresTools: z.boolean().optional()
104
+ });
105
+
106
+ /** One endpoint paired with its fuzzy-match distance. */
107
+ export const scoredEndpointSchema = z.object({
108
+ endpoint: servingEndpointSummarySchema,
109
+ score: z.number().min(0).max(1)
110
+ });
111
+
112
+ /** Caller intent used to resolve one model from a catalogue. */
113
+ export const resolveModelInputSchema = z.object({
114
+ explicit: z.string().optional(),
115
+ fuzzy: z.boolean().optional(),
116
+ threshold: z.number().min(0).max(1).optional(),
117
+ requiresTools: z.boolean().optional(),
118
+ modelClass: modelClassSchema.optional(),
119
+ fallbacks: z.array(z.string()).optional(),
120
+ liveOnly: z.boolean().optional()
121
+ });
122
+
123
+ /** Selected model identifier and the policy branch that selected it. */
124
+ export const resolvedModelSelectionSchema = z.object({
125
+ modelId: z.string(),
126
+ source: z.union([z.literal("explicit"), z.literal("fuzzy-match"), z.literal("class"), z.literal("fallback")])
136
127
  });
package/src/model.ts CHANGED
@@ -5,26 +5,50 @@
5
5
  */
6
6
 
7
7
  import {
8
+ type EndpointCapabilities as GeneratedEndpointCapabilities,
9
+ type FamilyClass as GeneratedFamilyClass,
8
10
  ModelClass as GeneratedModelClass,
11
+ type ModelCapabilities as GeneratedModelCapabilities,
12
+ type ModelMetadata as GeneratedModelMetadata,
9
13
  ReasoningEffort as GeneratedReasoningEffort,
10
14
  type ModelClass as GeneratedModelClassType,
11
15
  type ModelProfile as GeneratedModelProfile,
12
16
  type ModelQuery as GeneratedModelQuery,
17
+ type ModelRateLimits as GeneratedModelRateLimits,
13
18
  type ModelStatus as GeneratedModelStatus,
14
19
  type RankedModel as GeneratedRankedModel,
15
20
  type ReasoningEffort as GeneratedReasoningEffortType,
21
+ type ResolvedModel as GeneratedResolvedModel,
22
+ type ResolvedModelSelection as GeneratedResolvedModelSelection,
23
+ type ResolveModelInput as GeneratedResolveModelInput,
24
+ type ResolveModelOptions as GeneratedResolveModelOptions,
25
+ type ScoredEndpoint as GeneratedScoredEndpoint,
16
26
  type ServingEndpointSummary as GeneratedServingEndpointSummary,
17
27
  } from "./contracts.ts";
18
28
  import {
29
+ endpointCapabilitiesSchema,
30
+ familyClassSchema,
19
31
  modelClassSchema,
32
+ modelCapabilitiesSchema,
33
+ modelMetadataSchema,
20
34
  modelProfileSchema,
21
35
  modelQuerySchema,
36
+ modelRateLimitsSchema,
22
37
  modelStatusSchema,
23
38
  rankedModelSchema,
24
39
  reasoningEffortSchema,
40
+ resolvedModelSchema,
41
+ resolvedModelSelectionSchema,
42
+ resolveModelInputSchema,
43
+ resolveModelOptionsSchema,
44
+ scoredEndpointSchema,
25
45
  servingEndpointSummarySchema,
26
46
  } from "./generated/_schemas.ts";
27
47
 
48
+ /** Capabilities derived from one normalized endpoint. */
49
+ export type EndpointCapabilities = GeneratedEndpointCapabilities;
50
+ /** Family fallback classification for an unscored model. */
51
+ export type FamilyClass = GeneratedFamilyClass;
28
52
  /** Runtime values for the model class contract. */
29
53
  export const ModelClass = GeneratedModelClass;
30
54
  /** Class of a Databricks Model Serving endpoint. */
@@ -35,12 +59,28 @@ export const ReasoningEffortValues = GeneratedReasoningEffort;
35
59
  export type ModelProfile = GeneratedModelProfile;
36
60
  /** Model catalogue query controls. */
37
61
  export type ModelQuery = GeneratedModelQuery;
62
+ /** Published model capability metadata. */
63
+ export type ModelCapabilities = GeneratedModelCapabilities;
64
+ /** Combined model metadata. */
65
+ export type ModelMetadata = GeneratedModelMetadata;
66
+ /** Published model rate limits. */
67
+ export type ModelRateLimits = GeneratedModelRateLimits;
38
68
  /** Model lifecycle status. */
39
69
  export type ModelStatus = GeneratedModelStatus;
40
70
  /** A ranked endpoint result. */
41
71
  export type RankedModel = GeneratedRankedModel;
42
72
  /** Provider wire value accepted as a reasoning effort. */
43
73
  export type ReasoningEffort = GeneratedReasoningEffortType;
74
+ /** Fuzzy endpoint resolution result. */
75
+ export type ResolvedModel = GeneratedResolvedModel;
76
+ /** Selected model and policy source. */
77
+ export type ResolvedModelSelection = GeneratedResolvedModelSelection;
78
+ /** Model selection intent. */
79
+ export type ResolveModelInput = GeneratedResolveModelInput;
80
+ /** Fuzzy endpoint resolution controls. */
81
+ export type ResolveModelOptions = GeneratedResolveModelOptions;
82
+ /** Endpoint plus fuzzy-match score. */
83
+ export type ScoredEndpoint = GeneratedScoredEndpoint;
44
84
  /** Normalized metadata for a Databricks Model Serving endpoint. */
45
85
  export type ServingEndpointSummary = GeneratedServingEndpointSummary;
46
86
 
@@ -66,3 +106,24 @@ export const ModelQuerySchema = modelQuerySchema;
66
106
 
67
107
  /** Runtime schema for a ranked endpoint result. */
68
108
  export const RankedModelSchema = rankedModelSchema;
109
+
110
+ /** Runtime schema for endpoint capabilities. */
111
+ export const EndpointCapabilitiesSchema = endpointCapabilitiesSchema;
112
+ /** Runtime schema for a family fallback classification. */
113
+ export const FamilyClassSchema = familyClassSchema;
114
+ /** Runtime schema for documented model capabilities. */
115
+ export const ModelCapabilitiesSchema = modelCapabilitiesSchema;
116
+ /** Runtime schema for combined model metadata. */
117
+ export const ModelMetadataSchema = modelMetadataSchema;
118
+ /** Runtime schema for published model rate limits. */
119
+ export const ModelRateLimitsSchema = modelRateLimitsSchema;
120
+ /** Runtime schema for a fuzzy endpoint resolution result. */
121
+ export const ResolvedModelSchema = resolvedModelSchema;
122
+ /** Runtime schema for fuzzy endpoint resolution controls. */
123
+ export const ResolveModelOptionsSchema = resolveModelOptionsSchema;
124
+ /** Runtime schema for an endpoint plus fuzzy score. */
125
+ export const ScoredEndpointSchema = scoredEndpointSchema;
126
+ /** Runtime schema for model selection intent. */
127
+ export const ResolveModelInputSchema = resolveModelInputSchema;
128
+ /** Runtime schema for a selected model and policy source. */
129
+ export const ResolvedModelSelectionSchema = resolvedModelSelectionSchema;