@dbx-tools/dbx-model-catalog 0.2.0 → 0.3.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.
Files changed (54) hide show
  1. package/README.md +294 -57
  2. package/dist/_generated/channels.d.ts +4 -3
  3. package/dist/_generated/json-schema.d.ts +6527 -175
  4. package/dist/_generated/schemas.d.ts +154 -0
  5. package/dist/_generated/workspace-rules.d.ts +133 -0
  6. package/dist/browser.d.ts +34 -17
  7. package/dist/browser.js +1192 -149
  8. package/dist/catalog-index.d.ts +15 -2
  9. package/dist/chunk-engbh7tj.js +39 -0
  10. package/dist/chunk-gzjer0mc.js +1797 -0
  11. package/dist/chunk-pp7fw379.js +51 -0
  12. package/dist/chunk-pwssxaq0.js +39 -0
  13. package/dist/cli.js +9 -654
  14. package/dist/effective.d.ts +31 -0
  15. package/dist/index.d.ts +33 -16
  16. package/dist/index.js +60 -660
  17. package/dist/local-client.d.ts +16 -3
  18. package/dist/pynect.d.ts +6 -3
  19. package/dist/search.d.ts +7 -1
  20. package/dist/serving-endpoints.d.ts +15 -0
  21. package/dist/sources.d.ts +30 -0
  22. package/dist/types.d.ts +31 -3
  23. package/dist/validation.d.ts +15 -1
  24. package/dist/workspace-cache.d.ts +68 -0
  25. package/dist/workspace-client.d.ts +49 -0
  26. package/dist/workspace-connection.d.ts +67 -0
  27. package/dist/workspace-file-cache.d.ts +11 -0
  28. package/dist/workspace-identity.d.ts +27 -0
  29. package/dist/workspace-overlay.d.ts +71 -0
  30. package/package.json +5 -6
  31. package/src/_generated/channels.ts +5 -2
  32. package/src/_generated/json-schema.ts +4 -2
  33. package/src/_generated/schemas.ts +177 -0
  34. package/src/_generated/workspace-rules.ts +285 -0
  35. package/src/browser.ts +105 -54
  36. package/src/catalog-index.ts +46 -19
  37. package/src/cli.ts +8 -11
  38. package/src/effective.ts +200 -0
  39. package/src/identity.ts +3 -26
  40. package/src/index.ts +155 -82
  41. package/src/local-client.ts +94 -18
  42. package/src/pynect.ts +28 -65
  43. package/src/search.ts +48 -0
  44. package/src/serving-endpoints.ts +157 -0
  45. package/src/sources.ts +107 -0
  46. package/src/types.ts +32 -2
  47. package/src/validation.ts +33 -0
  48. package/src/workspace-cache.ts +234 -0
  49. package/src/workspace-client.ts +134 -0
  50. package/src/workspace-connection.ts +160 -0
  51. package/src/workspace-file-cache.ts +45 -0
  52. package/src/workspace-identity.ts +77 -0
  53. package/src/workspace-overlay.ts +200 -0
  54. package/dist/pynect.js +0 -557
@@ -0,0 +1,1797 @@
1
+ // src/index.ts
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, resolve as resolve2 } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ // src/_generated/workspace-rules.ts
7
+ var WORKSPACE_OVERLAY_RULES = {
8
+ contract_version: 1,
9
+ serving_endpoints_path: "/api/2.0/serving-endpoints",
10
+ principal: {
11
+ path: "/api/2.0/preview/scim/v2/Me",
12
+ fields: [
13
+ "id",
14
+ "userName"
15
+ ]
16
+ },
17
+ cache: {
18
+ refresh_interval_seconds: 300,
19
+ stale_ttl_seconds: 604800
20
+ },
21
+ identity_fields: [
22
+ {
23
+ kind: "endpoint_name",
24
+ path: [
25
+ "name"
26
+ ]
27
+ },
28
+ {
29
+ kind: "served_entity",
30
+ path: [
31
+ "config",
32
+ "served_entities",
33
+ "*",
34
+ "entity_name"
35
+ ]
36
+ },
37
+ {
38
+ kind: "served_entity",
39
+ path: [
40
+ "config",
41
+ "served_models",
42
+ "*",
43
+ "model_name"
44
+ ]
45
+ },
46
+ {
47
+ kind: "foundation_model",
48
+ path: [
49
+ "config",
50
+ "served_entities",
51
+ "*",
52
+ "foundation_model",
53
+ "name"
54
+ ]
55
+ },
56
+ {
57
+ kind: "external_model",
58
+ path: [
59
+ "config",
60
+ "served_entities",
61
+ "*",
62
+ "external_model",
63
+ "name"
64
+ ]
65
+ },
66
+ {
67
+ kind: "external_model",
68
+ path: [
69
+ "config",
70
+ "served_entities",
71
+ "*",
72
+ "external_model"
73
+ ],
74
+ join: [
75
+ "provider",
76
+ "name"
77
+ ]
78
+ }
79
+ ],
80
+ model_service_prefixes: [
81
+ "system.ai."
82
+ ],
83
+ display_name_fields: [
84
+ [
85
+ "config",
86
+ "served_entities",
87
+ "*",
88
+ "foundation_model",
89
+ "display_name"
90
+ ]
91
+ ],
92
+ display_name_tag_keys: [
93
+ "display_name",
94
+ "displayName"
95
+ ],
96
+ description_fields: [
97
+ [
98
+ "description"
99
+ ],
100
+ [
101
+ "config",
102
+ "served_entities",
103
+ "*",
104
+ "foundation_model",
105
+ "description"
106
+ ]
107
+ ],
108
+ family_fields: [
109
+ [
110
+ "config",
111
+ "served_entities",
112
+ "*",
113
+ "foundation_model",
114
+ "model_class"
115
+ ]
116
+ ],
117
+ profile_fields: [
118
+ [
119
+ "config",
120
+ "served_entities",
121
+ "*",
122
+ "foundation_model",
123
+ "ai_gateway_model_profile"
124
+ ]
125
+ ],
126
+ profile_keys: [
127
+ "quality",
128
+ "speed",
129
+ "cost"
130
+ ],
131
+ capability_fields: {
132
+ function_calling: [
133
+ "capabilities",
134
+ "function_calling"
135
+ ]
136
+ },
137
+ task_types: {
138
+ "llm/v1/chat": {
139
+ type: "chat",
140
+ modalities: {
141
+ input: [
142
+ "text"
143
+ ],
144
+ output: [
145
+ "text"
146
+ ]
147
+ }
148
+ },
149
+ "llm/v1/completions": {
150
+ type: "chat",
151
+ modalities: {
152
+ input: [
153
+ "text"
154
+ ],
155
+ output: [
156
+ "text"
157
+ ]
158
+ }
159
+ },
160
+ "llm/v1/embeddings": {
161
+ type: "embedding",
162
+ modalities: {
163
+ input: [
164
+ "text"
165
+ ],
166
+ output: [
167
+ "embedding"
168
+ ]
169
+ }
170
+ },
171
+ "agent/v1/chat": {
172
+ type: "chat",
173
+ modalities: {
174
+ input: [
175
+ "text"
176
+ ],
177
+ output: [
178
+ "text"
179
+ ]
180
+ }
181
+ },
182
+ "agent/v2/chat": {
183
+ type: "chat",
184
+ modalities: {
185
+ input: [
186
+ "text"
187
+ ],
188
+ output: [
189
+ "text"
190
+ ]
191
+ }
192
+ },
193
+ "agent/v1/responses": {
194
+ type: "chat",
195
+ modalities: {
196
+ input: [
197
+ "text"
198
+ ],
199
+ output: [
200
+ "text"
201
+ ]
202
+ }
203
+ }
204
+ },
205
+ overlay_fields: [
206
+ {
207
+ target: "name",
208
+ source: "display_name"
209
+ },
210
+ {
211
+ target: "description",
212
+ source: "description"
213
+ },
214
+ {
215
+ target: "family",
216
+ source: "family"
217
+ },
218
+ {
219
+ target: "capabilities.tools",
220
+ source: "capabilities.function_calling"
221
+ },
222
+ {
223
+ target: "type",
224
+ source: "type",
225
+ unmatched_only: true
226
+ },
227
+ {
228
+ target: "modalities",
229
+ source: "modalities",
230
+ unmatched_only: true
231
+ }
232
+ ],
233
+ placeholders: {
234
+ description: "",
235
+ type: "chat",
236
+ status: "active",
237
+ modalities: {
238
+ input: [],
239
+ output: []
240
+ },
241
+ "capabilities.responses": false,
242
+ "capabilities.apply_patch": false,
243
+ "capabilities.web_search": false
244
+ },
245
+ runtime_search_quality: {
246
+ leaderboard: 50,
247
+ benchmark: 50,
248
+ version: 50,
249
+ freshness: 50,
250
+ lifecycle: 100
251
+ },
252
+ provider_prefixes: [
253
+ "alibaba",
254
+ "anthropic",
255
+ "deepseek",
256
+ "google",
257
+ "meta",
258
+ "moonshot",
259
+ "openai",
260
+ "xai",
261
+ "zhipu"
262
+ ],
263
+ provider_families: [
264
+ "claude",
265
+ "deepseek",
266
+ "gemini",
267
+ "gemma",
268
+ "glm",
269
+ "gpt",
270
+ "grok",
271
+ "gte",
272
+ "bge",
273
+ "kimi",
274
+ "llama",
275
+ "qwen"
276
+ ],
277
+ workspace_identity: {
278
+ header_names: [
279
+ "x-databricks-org-id",
280
+ "x-databricks-workspace-id"
281
+ ],
282
+ host_patterns: [
283
+ "^adb-(\\d+)\\.\\d+\\.azuredatabricks\\.net$",
284
+ "^(\\d+)\\.\\d+\\.gcp\\.databricks\\.com$"
285
+ ],
286
+ query_parameters: [
287
+ "o"
288
+ ]
289
+ }
290
+ };
291
+
292
+ // src/identity.ts
293
+ var providerPrefixes = new Set(WORKSPACE_OVERLAY_RULES.provider_prefixes);
294
+ var providerFamilies = WORKSPACE_OVERLAY_RULES.provider_families;
295
+ function normalizeModelIdentity(value) {
296
+ return value.trim().toLowerCase().replace(/^system\.ai[.-]/, "").replace(/^databricks-/, "").replace(/([a-z])(\d)/g, "$1-$2").replace(/(\d)([a-z])/g, "$1-$2").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
297
+ }
298
+ function modelIdentities(record) {
299
+ const identities = [record.id, ...record.aliases];
300
+ return identities.map((value, index) => {
301
+ if (index === 0 || value.startsWith("databricks-"))
302
+ return { kind: "endpoint", value };
303
+ if (value.startsWith("system.ai."))
304
+ return { kind: "model-service", value };
305
+ const separator = value.indexOf("/");
306
+ if (separator > 0 && providerPrefixes.has(value.slice(0, separator).toLowerCase())) {
307
+ return {
308
+ kind: "provider",
309
+ provider: value.slice(0, separator).toLowerCase(),
310
+ value
311
+ };
312
+ }
313
+ return { kind: "alias", value };
314
+ });
315
+ }
316
+
317
+ // src/search.ts
318
+ var neutralScore = 50;
319
+ var statusPriority = new Map([
320
+ "active",
321
+ "preview",
322
+ "beta",
323
+ "alpha",
324
+ "legacy",
325
+ "deprecated",
326
+ "retired"
327
+ ].map((status, index) => [status, index]));
328
+ var tokenPattern = /[a-z]+|\d+/g;
329
+ var versionPattern = /(?:^|[^a-z0-9])(\d+)(?:[.\-_](\d+))?(?:[.\-_](\d+))?(?![a-z0-9])/i;
330
+ function searchCatalogRecords(index, models, query, limit = 50) {
331
+ return searchCatalogMatches(index, models, query, limit).map((match) => match.record);
332
+ }
333
+ function searchCatalogMatches(index, models, query, limit = 50) {
334
+ const normalizedQuery = normalizeSearch(query);
335
+ if (!normalizedQuery || limit === 0)
336
+ return [];
337
+ const queryTokens = tokens(normalizedQuery).filter((token) => !/^\d+$/.test(token));
338
+ const requestedVersion = version(query);
339
+ const documentById = new Map(index.documents.map((document) => [document.id, document]));
340
+ const referenceDate = index.updated_at.slice(0, 10);
341
+ const scored = models.flatMap((model) => {
342
+ const document = documentById.get(model.id);
343
+ if (!document)
344
+ return [];
345
+ const candidate = scoreRecord(model, document, index, normalizedQuery, queryTokens, requestedVersion, referenceDate);
346
+ return candidate ? [candidate] : [];
347
+ });
348
+ scored.sort((left, right) => compareScored(left, right, requestedVersion));
349
+ const results = scored.map(({ identityExact: _identityExact, releaseDate: _releaseDate, version: _version, ...candidate }) => candidate);
350
+ return limit === null ? results : results.slice(0, limit);
351
+ }
352
+ var qualityFields = ["leaderboard", "benchmark", "version", "freshness", "lifecycle"];
353
+ var documentDescriptionFields = new Set(["description", "notice"]);
354
+ var documentExactFields = new Set(["id", "name", "alias"]);
355
+ function catalogSearchQuality(scores, weights) {
356
+ let weighted = 0;
357
+ let total = 0;
358
+ for (const name of qualityFields) {
359
+ weighted += scores[name] * weights[name];
360
+ total += weights[name];
361
+ }
362
+ return {
363
+ quality_score: round3(weighted / total),
364
+ scores: Object.fromEntries(qualityFields.map((name) => [name, round3(scores[name])]))
365
+ };
366
+ }
367
+ function catalogSearchDocument(record, quality) {
368
+ const fields = searchFields(record);
369
+ const unique = (values) => [...new Set(values)];
370
+ const recordVersion = version(record.name);
371
+ return {
372
+ id: record.id,
373
+ exact_identities: unique(fields.filter((item) => documentExactFields.has(item.name)).map((item) => item.value)),
374
+ identities: unique(fields.filter((item) => item.identity).map((item) => item.value)),
375
+ keywords: unique(fields.filter((item) => !documentDescriptionFields.has(item.name)).map((item) => item.value)).join(" "),
376
+ description: unique(fields.filter((item) => documentDescriptionFields.has(item.name)).map((item) => item.value)).join(" "),
377
+ tokens: [...new Set(fields.flatMap((item) => tokens(item.value)))].sort(),
378
+ ...record.family == null ? {} : { family: record.family },
379
+ version: recordVersion.length ? recordVersion : version(record.id),
380
+ quality_score: quality.quality_score,
381
+ scores: { ...quality.scores }
382
+ };
383
+ }
384
+ function scoreRecord(record, document, index, query, queryTokens, requestedVersion, referenceDate) {
385
+ const fields = searchFields(record);
386
+ const fieldScores = fields.map((field) => scoreField(field, query, new Set(queryTokens)));
387
+ const tokenScores = queryTokenScores(queryTokens, document.tokens);
388
+ if (!passesTokenGate(queryTokens, tokenScores, document.identities, requestedVersion.length > 0)) {
389
+ return;
390
+ }
391
+ const relevance = Math.max(...fieldScores.map((item) => item.score), tokenScores.length ? mean(tokenScores) * 0.94 : 0);
392
+ if (relevance < 58)
393
+ return;
394
+ const leading = fieldScores.filter((item) => item.score >= relevance - 8);
395
+ const identityMatch = queryTokens.length > 0 && queryTokens.every((token) => document.identities.some((identity) => tokens(identity).includes(token))) || leading.some((item) => item.field.identity);
396
+ const identityExact = leading.some((item) => item.kind === "exact" && ["id", "name", "alias"].includes(item.field.name));
397
+ const quality = {
398
+ leaderboard: leaderboardScore(record, queryTokens, referenceDate),
399
+ benchmark: benchmarkScore(record, queryTokens, referenceDate),
400
+ version: requestedVersion.length ? requestedVersionScore(document.version, requestedVersion) : identityMatch ? document.scores.version : neutralScore,
401
+ freshness: document.scores.freshness,
402
+ lifecycle: document.scores.lifecycle
403
+ };
404
+ const combined = round3(relevance * index.weights.relevance + quality.leaderboard * index.weights.leaderboard + quality.benchmark * index.weights.benchmark + quality.version * index.weights.version + quality.freshness * index.weights.freshness + quality.lifecycle * index.weights.lifecycle);
405
+ return {
406
+ exact: identityExact,
407
+ identityExact,
408
+ kind: identityExact ? "exact" : leading.some((item) => item.kind === "token") ? "token" : "fuzzy",
409
+ record,
410
+ relevance: round3(relevance),
411
+ releaseDate: record.release_date ?? null,
412
+ score: combined,
413
+ version: document.version
414
+ };
415
+ }
416
+ function scoreField(field, query, requestedTokens) {
417
+ const weighted = Math.max(weightedRatio(query, field.value), tokenSetRatio(query, field.value)) * field.weight;
418
+ if (query === field.value)
419
+ return { field, kind: "exact", score: 100 };
420
+ if (field.value.includes(query)) {
421
+ return { field, kind: "token", score: Math.max(weighted, 96 * field.weight) };
422
+ }
423
+ const fieldTokens = new Set(tokens(field.value));
424
+ if (requestedTokens.size > 0 && [...requestedTokens].every((token) => fieldTokens.has(token))) {
425
+ return { field, kind: "token", score: Math.max(weighted, 94 * field.weight) };
426
+ }
427
+ return { field, kind: "fuzzy", score: weighted };
428
+ }
429
+ function passesTokenGate(queryTokens, tokenScores, identities, requireIdentity) {
430
+ if (queryTokens.some((token, index) => (tokenScores[index] ?? 0) < (token.length <= 3 ? 80 : 65))) {
431
+ return false;
432
+ }
433
+ if (!requireIdentity || queryTokens.length === 0)
434
+ return true;
435
+ const identityTokens = new Set(identities.flatMap((identity) => tokens(identity)));
436
+ return Math.min(...queryTokenScores(queryTokens, [...identityTokens])) >= 75;
437
+ }
438
+ function queryTokenScores(queryTokens, candidateTokens) {
439
+ return queryTokens.map((token) => Math.max(0, ...candidateTokens.map((candidate) => ratio(token, candidate))));
440
+ }
441
+ function compareScored(left, right, requestedVersion) {
442
+ if (left.identityExact !== right.identityExact)
443
+ return left.identityExact ? -1 : 1;
444
+ if (requestedVersion.length) {
445
+ const distance = compareNumbers(versionDistance(left.version, requestedVersion), versionDistance(right.version, requestedVersion));
446
+ if (distance)
447
+ return distance;
448
+ }
449
+ return right.score - left.score || right.relevance - left.relevance || (statusPriority.get(left.record.status) ?? statusPriority.size) - (statusPriority.get(right.record.status) ?? statusPriority.size) || compareOptionalDateDescending(left.releaseDate, right.releaseDate) || compareText(left.record.name, right.record.name) || compareText(left.record.id, right.record.id);
450
+ }
451
+ function searchFields(record) {
452
+ const fields = [
453
+ field("id", record.id, 1, true),
454
+ field("name", record.name, 1, true),
455
+ ...record.aliases.map((value) => field("alias", value, 1, true)),
456
+ field("publisher", record.publisher ?? "", 0.98, true),
457
+ field("family", record.family ?? "", 0.98, true),
458
+ field("type", record.type, 0.9),
459
+ field("status", record.status, 0.86),
460
+ field("license", record.license ?? "", 0.84),
461
+ ...record.tasks.map((value) => field("task", value, 0.94)),
462
+ ...record.use_cases.map((value) => field("use case", value, 0.94)),
463
+ ...record.modalities.input.map((value) => field("input modality", value, 0.9)),
464
+ ...record.modalities.output.map((value) => field("output modality", value, 0.9)),
465
+ ...record.rankings.map((value) => field("leaderboard domain", value.domain, 0.92)),
466
+ ...record.rankings.map((value) => field("leaderboard category", value.category, 0.88)),
467
+ ...record.benchmarks.map((value) => field("benchmark", value.name, 0.92)),
468
+ field("description", record.description, 0.76)
469
+ ];
470
+ for (const [name, value] of Object.entries(record.capabilities)) {
471
+ const objectValue = isRecord(value) ? value : undefined;
472
+ if (value === true || objectValue?.supported === true) {
473
+ fields.push(field("capability", name.replaceAll("_", " "), 0.94));
474
+ }
475
+ if (name === "reasoning" && objectValue) {
476
+ const effort = Array.isArray(objectValue.effort) ? objectValue.effort : [];
477
+ for (const level of effort)
478
+ fields.push(field("reasoning effort", `${String(level)} reasoning`, 0.94));
479
+ if (objectValue.toggle === true)
480
+ fields.push(field("reasoning control", "reasoning toggle", 0.92));
481
+ if (objectValue.budget)
482
+ fields.push(field("reasoning control", "reasoning token budget", 0.92));
483
+ if (typeof objectValue.description === "string") {
484
+ fields.push(field("reasoning description", objectValue.description, 0.8));
485
+ }
486
+ }
487
+ }
488
+ for (const [cloud, availability] of Object.entries(record.availability)) {
489
+ fields.push(field("cloud", cloud, 0.9));
490
+ fields.push(field("availability", availability.status, 0.82));
491
+ fields.push(...availability.serving_modes.map((mode) => field("serving mode", mode, 0.9)));
492
+ if (availability.details)
493
+ fields.push(field("availability details", availability.details, 0.72));
494
+ }
495
+ for (const notice of record.notices) {
496
+ fields.push(field("notice", notice.kind, 0.74));
497
+ fields.push(field("notice", notice.title ?? "", 0.74));
498
+ fields.push(field("notice", notice.text, 0.7));
499
+ }
500
+ return fields.map((value) => ({ ...value, value: normalizeSearch(value.value) })).filter((value) => value.value.length > 0);
501
+ }
502
+ function field(name, value, weight, identity = false) {
503
+ return { identity, name, value, weight };
504
+ }
505
+ function leaderboardScore(record, queryTokens, referenceDate) {
506
+ const matched = record.rankings.filter((ranking) => evidenceMatches(queryTokens, ranking.domain, ranking.category));
507
+ const selected = matched.length ? matched : record.rankings.filter((ranking) => ranking.category.toLowerCase() === "overall");
508
+ if (!selected.length)
509
+ return neutralScore;
510
+ return aggregateEvidence(selected.map((ranking) => ageAdjustedScore(rankScore(ranking.rank, 20), ranking.published_at ?? null, referenceDate, 180, "votes" in ranking ? ranking.votes : ranking.observations, 5000)));
511
+ }
512
+ function benchmarkScore(record, queryTokens, referenceDate) {
513
+ const matched = record.benchmarks.filter((benchmark) => evidenceMatches(queryTokens, benchmark.name));
514
+ const selected = matched.length ? matched : record.benchmarks;
515
+ if (!selected.length)
516
+ return neutralScore;
517
+ return aggregateEvidence(selected.map((benchmark) => ageAdjustedScore(rankScore(benchmark.rank, 10), benchmark.published_at ?? null, referenceDate, 365, benchmark.task_count, 20)));
518
+ }
519
+ function evidenceMatches(queryTokens, ...values) {
520
+ if (!queryTokens.length)
521
+ return false;
522
+ const evidence = new Set(tokens(normalizeSearch(values.join(" "))));
523
+ return queryTokens.some((token) => evidence.has(token));
524
+ }
525
+ function ageAdjustedScore(score, publishedAt, referenceDate, halfLifeDays, confidenceCount, confidenceTarget) {
526
+ const ageDays = publishedAt ? Math.max(0, dateDays(referenceDate) - dateDays(publishedAt)) : halfLifeDays;
527
+ const ageFactor = 0.5 ** (ageDays / halfLifeDays);
528
+ const confidence = confidenceCount === null || confidenceCount === undefined ? 0 : Math.min(1, Math.log1p(confidenceCount) / Math.log1p(confidenceTarget));
529
+ const evidenceFactor = ageFactor * (0.75 + confidence * 0.25);
530
+ return neutralScore + (score - neutralScore) * evidenceFactor;
531
+ }
532
+ function aggregateEvidence(scores) {
533
+ if (!scores.length)
534
+ return neutralScore;
535
+ const aggregate = median(scores) * 0.6 + mean(scores) * 0.4;
536
+ const coverageFactor = 0.85 + Math.min(scores.length, 5) / 5 * 0.15;
537
+ return neutralScore + (aggregate - neutralScore) * coverageFactor;
538
+ }
539
+ function requestedVersionScore(candidate, requested) {
540
+ if (!candidate.length)
541
+ return 0;
542
+ const [candidateMajor = 0, candidateMinor = 0, candidatePatch = 0] = candidate;
543
+ const [requestedMajor = 0, requestedMinor = 0, requestedPatch = 0] = requested;
544
+ if (candidateMajor !== requestedMajor) {
545
+ return Math.max(0, 40 - Math.abs(candidateMajor - requestedMajor) * 15);
546
+ }
547
+ return Math.max(0, 100 - Math.abs(candidateMinor - requestedMinor) * 15 - Math.abs(candidatePatch - requestedPatch) * 5);
548
+ }
549
+ function versionDistance(candidate, requested) {
550
+ if (!candidate.length)
551
+ return [1, 1, 1000, 1000, 1000];
552
+ const [candidateMajor = 0, candidateMinor = 0, candidatePatch = 0] = candidate;
553
+ const [requestedMajor = 0, requestedMinor = 0, requestedPatch = 0] = requested;
554
+ return [
555
+ 0,
556
+ candidateMajor === requestedMajor ? 0 : 1,
557
+ Math.abs(candidateMajor - requestedMajor),
558
+ Math.abs(candidateMinor - requestedMinor),
559
+ Math.abs(candidatePatch - requestedPatch)
560
+ ];
561
+ }
562
+ function weightedRatio(left, right) {
563
+ if (!left || !right)
564
+ return 0;
565
+ const lengthRatio = Math.max(left.length, right.length) / Math.min(left.length, right.length);
566
+ const base = ratio(left, right);
567
+ if (lengthRatio < 1.5) {
568
+ return Math.max(base, tokenRatio(left, right) * 0.95);
569
+ }
570
+ const partialScale = lengthRatio <= 8 ? 0.9 : 0.6;
571
+ return Math.max(base, partialRatio(left, right) * partialScale, partialTokenRatio(left, right) * 0.95 * partialScale);
572
+ }
573
+ function tokenRatio(left, right) {
574
+ return Math.max(tokenSetRatio(left, right), ratio(sortTokens(left), sortTokens(right)));
575
+ }
576
+ function partialTokenRatio(left, right) {
577
+ const leftTokens = left.split(/\s+/).filter(Boolean);
578
+ const rightTokens = right.split(/\s+/).filter(Boolean);
579
+ const leftSet = new Set(leftTokens);
580
+ const rightSet = new Set(rightTokens);
581
+ if ([...leftSet].some((token) => rightSet.has(token)))
582
+ return 100;
583
+ const base = partialRatio([...leftTokens].sort().join(" "), [...rightTokens].sort().join(" "));
584
+ const leftDiff = [...leftSet].filter((token) => !rightSet.has(token));
585
+ const rightDiff = [...rightSet].filter((token) => !leftSet.has(token));
586
+ if (leftTokens.length === leftDiff.length && rightTokens.length === rightDiff.length)
587
+ return base;
588
+ return Math.max(base, partialRatio(leftDiff.sort().join(" "), rightDiff.sort().join(" ")));
589
+ }
590
+ function tokenSetRatio(left, right) {
591
+ const leftSet = new Set(left.split(/\s+/).filter(Boolean));
592
+ const rightSet = new Set(right.split(/\s+/).filter(Boolean));
593
+ if (!leftSet.size || !rightSet.size)
594
+ return 0;
595
+ const intersection = [...leftSet].filter((token) => rightSet.has(token));
596
+ const leftDiff = [...leftSet].filter((token) => !rightSet.has(token)).sort().join(" ");
597
+ const rightDiff = [...rightSet].filter((token) => !leftSet.has(token)).sort().join(" ");
598
+ if (intersection.length && (!leftDiff || !rightDiff))
599
+ return 100;
600
+ const intersectionLength = intersection.join(" ").length;
601
+ const leftLength = intersectionLength + (intersectionLength ? 1 : 0) + leftDiff.length;
602
+ const rightLength = intersectionLength + (intersectionLength ? 1 : 0) + rightDiff.length;
603
+ const distance = indelDistance(leftDiff, rightDiff);
604
+ const differenceScore = normalizedDistanceScore(distance, leftLength + rightLength);
605
+ if (!intersectionLength)
606
+ return differenceScore;
607
+ const leftIntersectionScore = normalizedDistanceScore(1 + leftDiff.length, intersectionLength + leftLength);
608
+ const rightIntersectionScore = normalizedDistanceScore(1 + rightDiff.length, intersectionLength + rightLength);
609
+ return Math.max(differenceScore, leftIntersectionScore, rightIntersectionScore);
610
+ }
611
+ function partialRatio(left, right) {
612
+ if (!left && !right)
613
+ return 100;
614
+ if (!left || !right)
615
+ return 0;
616
+ const shorter = left.length <= right.length ? left : right;
617
+ const longer = left.length <= right.length ? right : left;
618
+ let best = 0;
619
+ for (let end = 1;end < shorter.length; end += 1) {
620
+ best = Math.max(best, ratio(shorter, longer.slice(0, end)));
621
+ }
622
+ for (let start = 0;start <= longer.length - shorter.length; start += 1) {
623
+ best = Math.max(best, ratio(shorter, longer.slice(start, start + shorter.length)));
624
+ }
625
+ for (let start = Math.max(0, longer.length - shorter.length + 1);start < longer.length; start += 1) {
626
+ best = Math.max(best, ratio(shorter, longer.slice(start)));
627
+ }
628
+ return best;
629
+ }
630
+ function ratio(left, right) {
631
+ const total = left.length + right.length;
632
+ return total ? 2 * longestCommonSubsequence(left, right) / total * 100 : 100;
633
+ }
634
+ function indelDistance(left, right) {
635
+ return left.length + right.length - 2 * longestCommonSubsequence(left, right);
636
+ }
637
+ function longestCommonSubsequence(left, right) {
638
+ if (!left || !right)
639
+ return 0;
640
+ const needle = left.length <= right.length ? left : right;
641
+ const haystack = left.length <= right.length ? right : left;
642
+ const blocks = new Map;
643
+ let bit = 1n;
644
+ for (const character of needle) {
645
+ blocks.set(character, (blocks.get(character) ?? 0n) | bit);
646
+ bit <<= 1n;
647
+ }
648
+ let state = (1n << BigInt(needle.length)) - 1n;
649
+ for (const character of haystack) {
650
+ const matches = blocks.get(character) ?? 0n;
651
+ const overlap = state & matches;
652
+ state = state + overlap | state - overlap;
653
+ }
654
+ const mask = (1n << BigInt(needle.length)) - 1n;
655
+ return needle.length - popCount(state & mask);
656
+ }
657
+ function popCount(value) {
658
+ let count = 0;
659
+ let current = value;
660
+ while (current) {
661
+ current &= current - 1n;
662
+ count += 1;
663
+ }
664
+ return count;
665
+ }
666
+ function normalizedDistanceScore(distance, lengthSum) {
667
+ return lengthSum ? 100 - 100 * distance / lengthSum : 100;
668
+ }
669
+ function sortTokens(value) {
670
+ return value.split(/\s+/).filter(Boolean).sort().join(" ");
671
+ }
672
+ function normalizeSearch(value) {
673
+ return (value.normalize("NFKC").toLowerCase().match(tokenPattern) ?? []).join(" ");
674
+ }
675
+ function tokens(value) {
676
+ return value.match(tokenPattern) ?? [];
677
+ }
678
+ function version(value) {
679
+ const match = versionPattern.exec(value.toLowerCase());
680
+ return match ? match.slice(1).filter((part) => Boolean(part)).map(Number) : [];
681
+ }
682
+ function rankScore(rank, offset) {
683
+ return (offset + 1) / (offset + rank) * 100;
684
+ }
685
+ function dateDays(value) {
686
+ return Math.floor(Date.parse(`${value.slice(0, 10)}T00:00:00Z`) / 86400000);
687
+ }
688
+ function median(values) {
689
+ const sorted = [...values].sort((left, right) => left - right);
690
+ const middle = Math.floor(sorted.length / 2);
691
+ return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
692
+ }
693
+ function mean(values) {
694
+ return values.reduce((total, value) => total + value, 0) / values.length;
695
+ }
696
+ function round3(value) {
697
+ return Math.round(value * 1000) / 1000;
698
+ }
699
+ function compareNumbers(left, right) {
700
+ for (let index = 0;index < Math.max(left.length, right.length); index += 1) {
701
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
702
+ if (difference)
703
+ return difference;
704
+ }
705
+ return 0;
706
+ }
707
+ function compareOptionalDateDescending(left, right) {
708
+ if (left === right)
709
+ return 0;
710
+ if (left === null)
711
+ return 1;
712
+ if (right === null)
713
+ return -1;
714
+ return right.localeCompare(left);
715
+ }
716
+ function compareText(left, right) {
717
+ const normalizedLeft = left.toLowerCase();
718
+ const normalizedRight = right.toLowerCase();
719
+ return normalizedLeft < normalizedRight ? -1 : normalizedLeft > normalizedRight ? 1 : 0;
720
+ }
721
+ function isRecord(value) {
722
+ return typeof value === "object" && value !== null && !Array.isArray(value);
723
+ }
724
+
725
+ // src/filter.ts
726
+ function filterCatalogRecords(records, searchIndex, filters = {}) {
727
+ const limit = filters.limit === undefined ? 50 : filters.limit;
728
+ if (limit !== null && (!Number.isSafeInteger(limit) || limit < 0 || limit > 1000)) {
729
+ throw new RangeError("limit must be an integer between 0 and 1000, or null");
730
+ }
731
+ const filtered = records.filter((record) => includes(filters.status, record.status) && includes(filters.type, record.type) && includes(filters.publisher, record.publisher) && (filters.task ?? []).every((task) => record.tasks.includes(task)) && (filters.capability ?? []).every((capability) => hasCapability(record, capability)));
732
+ const query = filters.query?.trim();
733
+ if (query)
734
+ return searchCatalogRecords(searchIndex, filtered, query, limit);
735
+ filtered.sort((left, right) => compareText2(left.name, right.name) || compareText2(left.id, right.id));
736
+ return limit === null ? filtered : filtered.slice(0, limit);
737
+ }
738
+ function includes(expected, actual) {
739
+ return !expected?.length || actual !== null && actual !== undefined && expected.includes(actual);
740
+ }
741
+ function hasCapability(record, capability) {
742
+ const field = capability.replaceAll("-", "_");
743
+ const value = record.capabilities[field];
744
+ return capability === "reasoning" ? value !== null && value !== undefined : value === true;
745
+ }
746
+ function compareText2(left, right) {
747
+ const normalizedLeft = left.toLowerCase();
748
+ const normalizedRight = right.toLowerCase();
749
+ return normalizedLeft < normalizedRight ? -1 : normalizedLeft > normalizedRight ? 1 : 0;
750
+ }
751
+
752
+ // src/catalog-index.ts
753
+ class CatalogIdentityIndex {
754
+ exact = new Map;
755
+ normalized = new Map;
756
+ constructor(records) {
757
+ for (const record of records) {
758
+ for (const identity of modelIdentities(record)) {
759
+ this.exact.set(identity.value.toLowerCase(), { identity, record });
760
+ const key = normalizeModelIdentity(identity.value);
761
+ const current = this.normalized.get(key);
762
+ if (current === undefined)
763
+ this.normalized.set(key, { identity, record });
764
+ else if (current !== null && current.record.id !== record.id)
765
+ this.normalized.set(key, null);
766
+ }
767
+ }
768
+ }
769
+ resolve(value) {
770
+ const exact = this.exact.get(value.trim().toLowerCase());
771
+ if (exact)
772
+ return exact;
773
+ return this.normalized.get(normalizeModelIdentity(value)) ?? undefined;
774
+ }
775
+ matchAny(values) {
776
+ for (const value of values) {
777
+ const match = this.resolve(value);
778
+ if (match)
779
+ return match;
780
+ }
781
+ return;
782
+ }
783
+ }
784
+
785
+ class ModelCatalogIndex {
786
+ catalog;
787
+ searchIndex;
788
+ records;
789
+ identities;
790
+ constructor(catalog, searchIndex) {
791
+ this.catalog = catalog;
792
+ this.searchIndex = searchIndex;
793
+ if (catalog.schema_version !== searchIndex.catalog_schema_version) {
794
+ throw new Error(`Catalog schema v${catalog.schema_version} does not match search index schema v${searchIndex.catalog_schema_version}`);
795
+ }
796
+ if (catalog.updated_at !== searchIndex.updated_at) {
797
+ throw new Error("Catalog and search index timestamps do not match");
798
+ }
799
+ this.records = catalogRecords(catalog);
800
+ this.identities = new CatalogIdentityIndex(this.records);
801
+ }
802
+ get(id) {
803
+ return this.catalog.models[id] ? { ...this.catalog.models[id], id } : undefined;
804
+ }
805
+ resolve(value) {
806
+ return this.identities.resolve(value);
807
+ }
808
+ matchAny(values) {
809
+ return this.identities.matchAny(values);
810
+ }
811
+ list(filters = {}) {
812
+ return filterCatalogRecords(this.records, this.searchIndex, filters);
813
+ }
814
+ search(query, limit = 50) {
815
+ return searchCatalogMatches(this.searchIndex, this.records, query, limit);
816
+ }
817
+ }
818
+ function catalogRecords(catalog) {
819
+ return Object.entries(catalog.models).map(([id, model]) => ({ ...model, id }));
820
+ }
821
+
822
+ // src/validation.ts
823
+ import { z } from "zod";
824
+
825
+ // src/_generated/json-schema.ts
826
+ var MODEL_CATALOG_JSON_SCHEMA = { additionalProperties: false, description: "Published Databricks model catalog with identity, capabilities, availability, pricing, lifecycle, rankings, and benchmarks.", properties: { schema_version: { const: 16, title: "Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, models: { additionalProperties: { $ref: "#/$defs/CatalogModel" }, propertyNames: { minLength: 1 }, title: "Models", type: "object" } }, required: ["schema_version", "updated_at", "models"], title: "ModelCatalog", type: "object", $defs: { AiGatewayModelProfile: { description: "AI Gateway relative quality, speed, and cost profile.", properties: { quality: { anyOf: [{ type: "number" }, { type: "null" }], title: "Quality" }, speed: { anyOf: [{ type: "number" }, { type: "null" }], title: "Speed" }, cost: { anyOf: [{ type: "number" }, { type: "null" }], title: "Cost" } }, title: "AiGatewayModelProfile", type: "object" }, Availability: { additionalProperties: false, description: "Model availability on one Databricks cloud provider.", properties: { status: { $ref: "#/$defs/Status1" }, serving_modes: { items: { $ref: "#/$defs/ServingMode" }, title: "Serving Modes", type: "array" }, details: { anyOf: [{ type: "string" }, { type: "null" }], title: "Details" } }, required: ["status", "serving_modes"], title: "Availability", type: "object" }, AveragePrice: { additionalProperties: false, description: "Normalized Databricks price in one currency.", properties: { unit: { $ref: "#/$defs/Unit" }, rates: { additionalProperties: { minimum: 0, type: "number" }, propertyNames: { minLength: 1 }, title: "Rates", type: "object" } }, required: ["unit", "rates"], title: "AveragePrice", type: "object" }, Benchmark: { additionalProperties: false, description: "Task-suite benchmark result.", properties: { name: { title: "Name", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, score: { title: "Score", type: "number" }, task_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Task Count", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant2" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" } }, required: ["name", "rank", "score", "task_count", "sources"], title: "Benchmark", type: "object" }, Budget: { additionalProperties: false, description: "Supported reasoning-token budget range.", properties: { min: { anyOf: [{ maximum: 9007199254740991, minimum: -9007199254740991, type: "integer" }, { type: "null" }], title: "Min" }, max: { anyOf: [{ maximum: 9007199254740991, minimum: -9007199254740991, type: "integer" }, { type: "null" }], title: "Max" } }, title: "Budget", type: "object" }, Capabilities: { additionalProperties: false, description: "Capabilities used to select the model for a workload.", properties: { attachments: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Attachments" }, tools: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Tools" }, structured_output: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Structured Output" }, temperature: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Temperature" }, interleaved_reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Interleaved Reasoning" }, responses: { title: "Responses", type: "boolean" }, apply_patch: { title: "Apply Patch", type: "boolean" }, web_search: { title: "Web Search", type: "boolean" }, reasoning: { anyOf: [{ $ref: "#/$defs/Reasoning" }, { $ref: "#/$defs/Reasoning1" }, { type: "null" }], title: "Reasoning" } }, required: ["responses", "apply_patch", "web_search"], title: "Capabilities", type: "object" }, CatalogFilters: { additionalProperties: false, properties: { query: { anyOf: [{ type: "string" }, { type: "null" }], title: "Query" }, status: { items: { $ref: "#/$defs/Status" }, title: "Status", type: "array" }, type: { items: { $ref: "#/$defs/Type" }, title: "Type", type: "array" }, publisher: { items: { type: "string" }, title: "Publisher", type: "array" }, task: { items: { type: "string" }, title: "Task", type: "array" }, capability: { items: { enum: ["apply-patch", "attachments", "reasoning", "responses", "structured-output", "tools", "web-search"], type: "string" }, title: "Capability", type: "array" }, limit: { anyOf: [{ maximum: 1000, minimum: 0, type: "integer" }, { type: "null" }], default: 50, title: "Limit" } }, title: "CatalogFilters", type: "object" }, CatalogModel: { additionalProperties: false, description: "Published statistics for one Databricks model.", properties: { name: { title: "Name", type: "string" }, description: { title: "Description", type: "string" }, aliases: { items: { type: "string" }, title: "Aliases", type: "array" }, type: { $ref: "#/$defs/Type" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, publisher: { anyOf: [{ type: "string" }, { type: "null" }], title: "Publisher" }, license: { anyOf: [{ type: "string" }, { type: "null" }], title: "License" }, open_weights: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Open Weights" }, status: { $ref: "#/$defs/Status" }, release_date: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Release Date" }, last_updated: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Last Updated" }, knowledge_cutoff: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Knowledge Cutoff" }, retirement: { anyOf: [{ $ref: "#/$defs/Retirement" }, { type: "null" }] }, modalities: { $ref: "#/$defs/Modalities" }, capabilities: { $ref: "#/$defs/Capabilities" }, limits: { anyOf: [{ $ref: "#/$defs/Limits" }, { type: "null" }] }, rate_limits: { anyOf: [{ $ref: "#/$defs/RateLimits" }, { type: "null" }] }, latency: { anyOf: [{ $ref: "#/$defs/Latency" }, { type: "null" }] }, tasks: { items: { type: "string" }, title: "Tasks", type: "array" }, use_cases: { items: { type: "string" }, title: "Use Cases", type: "array" }, availability: { additionalProperties: { $ref: "#/$defs/Availability" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Availability", type: "object" }, price: { additionalProperties: { additionalProperties: { $ref: "#/$defs/Price" }, propertyNames: { enum: ["DBU", "USD"] }, type: "object" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Price", type: "object" }, average_price: { additionalProperties: { $ref: "#/$defs/AveragePrice" }, propertyNames: { enum: ["DBU", "USD"] }, title: "Average Price", type: "object" }, sources: { additionalProperties: { items: { $ref: "#/$defs/SourceLink" }, type: "array" }, propertyNames: { minLength: 1 }, title: "Sources", type: "object" }, notices: { items: { $ref: "#/$defs/Notice" }, title: "Notices", type: "array" }, rankings: { items: { anyOf: [{ $ref: "#/$defs/Rankings" }, { $ref: "#/$defs/Rankings1" }] }, title: "Rankings", type: "array" }, benchmarks: { items: { $ref: "#/$defs/Benchmark" }, title: "Benchmarks", type: "array" } }, required: ["name", "description", "aliases", "type", "status", "modalities", "capabilities", "tasks", "use_cases", "availability", "price", "average_price", "sources", "notices", "rankings", "benchmarks"], title: "CatalogModel", type: "object" }, CatalogModelRecord: { additionalProperties: false, properties: { name: { title: "Name", type: "string" }, description: { title: "Description", type: "string" }, aliases: { items: { type: "string" }, title: "Aliases", type: "array" }, type: { $ref: "#/$defs/Type" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, publisher: { anyOf: [{ type: "string" }, { type: "null" }], title: "Publisher" }, license: { anyOf: [{ type: "string" }, { type: "null" }], title: "License" }, open_weights: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Open Weights" }, status: { $ref: "#/$defs/Status" }, release_date: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Release Date" }, last_updated: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Last Updated" }, knowledge_cutoff: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Knowledge Cutoff" }, retirement: { anyOf: [{ $ref: "#/$defs/Retirement" }, { type: "null" }] }, modalities: { $ref: "#/$defs/Modalities" }, capabilities: { $ref: "#/$defs/Capabilities" }, limits: { anyOf: [{ $ref: "#/$defs/Limits" }, { type: "null" }] }, rate_limits: { anyOf: [{ $ref: "#/$defs/RateLimits" }, { type: "null" }] }, latency: { anyOf: [{ $ref: "#/$defs/Latency" }, { type: "null" }] }, tasks: { items: { type: "string" }, title: "Tasks", type: "array" }, use_cases: { items: { type: "string" }, title: "Use Cases", type: "array" }, availability: { additionalProperties: { $ref: "#/$defs/Availability" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Availability", type: "object" }, price: { additionalProperties: { additionalProperties: { $ref: "#/$defs/Price" }, propertyNames: { enum: ["DBU", "USD"] }, type: "object" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Price", type: "object" }, average_price: { additionalProperties: { $ref: "#/$defs/AveragePrice" }, propertyNames: { enum: ["DBU", "USD"] }, title: "Average Price", type: "object" }, sources: { additionalProperties: { items: { $ref: "#/$defs/SourceLink" }, type: "array" }, propertyNames: { minLength: 1 }, title: "Sources", type: "object" }, notices: { items: { $ref: "#/$defs/Notice" }, title: "Notices", type: "array" }, rankings: { items: { anyOf: [{ $ref: "#/$defs/Rankings" }, { $ref: "#/$defs/Rankings1" }] }, title: "Rankings", type: "array" }, benchmarks: { items: { $ref: "#/$defs/Benchmark" }, title: "Benchmarks", type: "array" }, id: { minLength: 1, title: "Id", type: "string" } }, required: ["name", "description", "aliases", "type", "status", "modalities", "capabilities", "tasks", "use_cases", "availability", "price", "average_price", "sources", "notices", "rankings", "benchmarks", "id"], title: "CatalogModelRecord", type: "object" }, CatalogSearchIndexDocument: { additionalProperties: false, properties: { id: { title: "Id", type: "string" }, exact_identities: { items: { type: "string" }, title: "Exact Identities", type: "array" }, identities: { items: { type: "string" }, title: "Identities", type: "array" }, keywords: { title: "Keywords", type: "string" }, description: { title: "Description", type: "string" }, tokens: { items: { type: "string" }, title: "Tokens", type: "array" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, version: { items: { type: "integer" }, title: "Version", type: "array" }, quality_score: { maximum: 100, minimum: 0, title: "Quality Score", type: "number" }, scores: { $ref: "#/$defs/CatalogSearchQualityScores" } }, required: ["id", "exact_identities", "identities", "keywords", "description", "tokens", "version", "quality_score", "scores"], title: "CatalogSearchIndexDocument", type: "object" }, CatalogSearchIndexPayload: { additionalProperties: false, properties: { schema_version: { title: "Schema Version", type: "integer" }, catalog_schema_version: { title: "Catalog Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, weights: { $ref: "#/$defs/CatalogSearchWeights" }, documents: { items: { $ref: "#/$defs/CatalogSearchIndexDocument" }, title: "Documents", type: "array" } }, required: ["schema_version", "catalog_schema_version", "updated_at", "weights", "documents"], title: "CatalogSearchIndexPayload", type: "object" }, CatalogSearchQualityScores: { additionalProperties: false, properties: { leaderboard: { maximum: 100, minimum: 0, title: "Leaderboard", type: "number" }, benchmark: { maximum: 100, minimum: 0, title: "Benchmark", type: "number" }, version: { maximum: 100, minimum: 0, title: "Version", type: "number" }, freshness: { maximum: 100, minimum: 0, title: "Freshness", type: "number" }, lifecycle: { maximum: 100, minimum: 0, title: "Lifecycle", type: "number" } }, required: ["leaderboard", "benchmark", "version", "freshness", "lifecycle"], title: "CatalogSearchQualityScores", type: "object" }, CatalogSearchWeights: { additionalProperties: false, properties: { relevance: { title: "Relevance", type: "number" }, leaderboard: { title: "Leaderboard", type: "number" }, benchmark: { title: "Benchmark", type: "number" }, version: { title: "Version", type: "number" }, freshness: { title: "Freshness", type: "number" }, lifecycle: { title: "Lifecycle", type: "number" } }, required: ["relevance", "leaderboard", "benchmark", "version", "freshness", "lifecycle"], title: "CatalogSearchWeights", type: "object" }, DefaultEffort: { description: "Default reasoning effort when no level is specified.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "DefaultEffort", type: "string" }, EffectiveEndpoint: { additionalProperties: false, description: "Accessible endpoint: normalized live metadata, public match, and field provenance.", properties: { name: { description: "Invocable serving endpoint name.", minLength: 1, title: "Name", type: "string" }, display_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Display Name" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, task: { anyOf: [{ type: "string" }, { type: "null" }], description: "Databricks serving task, such as llm/v1/chat.", title: "Task" }, type: { anyOf: [{ $ref: "#/$defs/Type" }, { type: "null" }], description: "Catalog type mapped from a known task." }, modalities: { anyOf: [{ $ref: "#/$defs/Modalities" }, { type: "null" }], description: "Modalities mapped from a known task." }, state: { anyOf: [{ type: "string" }, { type: "null" }], description: "Endpoint readiness, such as READY.", title: "State" }, source: { $ref: "#/$defs/WorkspaceEndpointSource" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, capabilities: { $ref: "#/$defs/WorkspaceEndpointCapabilities" }, profile: { anyOf: [{ $ref: "#/$defs/WorkspaceModelProfile" }, { type: "null" }] }, identities: { items: { $ref: "#/$defs/IdentityCandidate" }, title: "Identities", type: "array" }, match: { anyOf: [{ $ref: "#/$defs/MatchedPublicIdentity" }, { type: "null" }] }, fields: { additionalProperties: { $ref: "#/$defs/FieldOrigin" }, description: "Origin of each overlay or placeholder field (dotted path). Matched records inherit every unlisted field from the public record, attributed by the record's sources; placeholder values are schema-required, not facts.", title: "Fields", type: "object" } }, required: ["name", "source", "capabilities", "identities", "fields"], title: "EffectiveEndpoint", type: "object" }, EffectiveModelCatalog: { additionalProperties: false, description: "Public catalog merged with one workspace's accessible endpoints.", properties: { contract_version: { title: "Contract Version", type: "integer" }, catalog: { $ref: "#/$defs/ModelCatalog" }, workspace: { $ref: "#/$defs/WorkspaceRefresh" }, endpoints: { additionalProperties: { $ref: "#/$defs/EffectiveEndpoint" }, description: "Accessible endpoints keyed by invocable endpoint name, which is also the record id in catalog.models when the endpoint has a record. An unmatched endpoint whose task maps to no catalog type is listed here only. Records without an entry are public references not confirmed accessible in the workspace.", title: "Endpoints", type: "object" } }, required: ["contract_version", "catalog", "workspace", "endpoints"], title: "EffectiveModelCatalog", type: "object" }, EffortEnum: { description: "Normalized reasoning effort level.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "EffortEnum", type: "string" }, ExternalModel: { description: "External model provider and name reported for a served entity.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, provider: { anyOf: [{ type: "string" }, { type: "null" }], title: "Provider" }, task: { anyOf: [{ type: "string" }, { type: "null" }], title: "Task" } }, title: "ExternalModel", type: "object" }, FieldOrigin: { description: "Where an effective record field value came from.", enum: ["workspace", "public", "placeholder"], title: "FieldOrigin", type: "string" }, FoundationModel: { description: "Foundation model metadata reported for a served entity.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, display_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Display Name" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, docs: { anyOf: [{ type: "string" }, { type: "null" }], title: "Docs" }, model_class: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Class" }, ai_gateway_model_profile: { anyOf: [{ $ref: "#/$defs/AiGatewayModelProfile" }, { type: "null" }] } }, title: "FoundationModel", type: "object" }, GetCatalogRequest: { properties: { action: { const: "get_catalog", default: "get_catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "GetCatalogRequest", type: "object" }, GetCatalogResponse: { properties: { action: { const: "catalog", default: "catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/ModelCatalog" } }, required: ["payload"], title: "GetCatalogResponse", type: "object" }, GetSearchIndexRequest: { properties: { action: { const: "get_search_index", default: "get_search_index", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "GetSearchIndexRequest", type: "object" }, GetSearchIndexResponse: { properties: { action: { const: "search_index", default: "search_index", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogSearchIndexPayload" } }, required: ["payload"], title: "GetSearchIndexResponse", type: "object" }, IdentityCandidate: { additionalProperties: false, description: "One exact identity reported for an endpoint.", properties: { kind: { enum: ["endpoint_name", "served_entity", "foundation_model", "external_model", "model_service"], title: "Kind", type: "string" }, value: { title: "Value", type: "string" } }, required: ["kind", "value"], title: "IdentityCandidate", type: "object" }, Input: { description: "Known model input and output modalities.", enum: ["text", "image", "audio", "video", "application/pdf", "embedding", "reranking", "decision"], title: "Input", type: "string" }, Kind: { description: "Known Databricks documentation notice kinds.", enum: ["note", "important", "warning", "tip", "caution", "info"], title: "Kind", type: "string" }, Latency: { additionalProperties: false, description: "Normalized response-time score and public benchmark measurements.", properties: { score: { exclusiveMinimum: 0, title: "Score", type: "number" }, measurements: { $ref: "#/$defs/LatencyMeasurements" } }, required: ["score", "measurements"], title: "Latency", type: "object" }, LatencyMeasurements: { additionalProperties: false, description: "Public benchmark measurements underlying one latency score.", properties: { time_to_first_token_ms: { minimum: 0, title: "Time To First Token Ms", type: "number" }, output_tokens_per_second: { exclusiveMinimum: 0, title: "Output Tokens Per Second", type: "number" }, successful_run_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Successful Run Count", type: "integer" }, completion_token_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Completion Token Count", type: "integer" }, measured_at: { format: "date-time", title: "Measured At", type: "string" } }, required: ["time_to_first_token_ms", "output_tokens_per_second", "successful_run_count", "completion_token_count", "measured_at"], title: "LatencyMeasurements", type: "object" }, Limits: { additionalProperties: false, description: "Documented token limits.", properties: { context: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Context" }, input: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Input" }, output: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Output" } }, title: "Limits", type: "object" }, ListModelsRequest: { properties: { action: { const: "list_models", default: "list_models", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "ListModelsRequest", type: "object" }, ListModelsResponse: { properties: { action: { const: "models", default: "models", title: "Action", type: "string" }, payload: { items: { $ref: "#/$defs/CatalogModelRecord" }, title: "Payload", type: "array" } }, required: ["payload"], title: "ListModelsResponse", type: "object" }, MatchedPublicIdentity: { additionalProperties: false, description: "Public catalog record an endpoint matched, and the endpoint identity that matched it.", properties: { id: { description: "Public catalog record id.", minLength: 1, title: "Id", type: "string" }, kind: { enum: ["endpoint_name", "served_entity", "foundation_model", "external_model", "model_service"], title: "Kind", type: "string" }, value: { description: "Endpoint identity that matched exactly.", minLength: 1, title: "Value", type: "string" } }, required: ["id", "kind", "value"], title: "MatchedPublicIdentity", type: "object" }, Modalities: { additionalProperties: false, description: "Model input and output modalities.", properties: { input: { items: { anyOf: [{ $ref: "#/$defs/Input" }, { pattern: "^(text|image|audio|video|application)\\/[A-Za-z0-9.+-]+$", type: "string" }] }, title: "Input", type: "array" }, output: { items: { anyOf: [{ $ref: "#/$defs/Output" }, { pattern: "^(text|image|audio|video|application)\\/[A-Za-z0-9.+-]+$", type: "string" }] }, title: "Output", type: "array" } }, required: ["input", "output"], title: "Modalities", type: "object" }, ModelCatalog: { additionalProperties: false, description: "Published Databricks model catalog with identity, capabilities, availability, pricing, lifecycle, rankings, and benchmarks.", properties: { schema_version: { const: 16, title: "Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, models: { additionalProperties: { $ref: "#/$defs/CatalogModel" }, propertyNames: { minLength: 1 }, title: "Models", type: "object" } }, required: ["schema_version", "updated_at", "models"], title: "ModelCatalog", type: "object" }, Notice: { additionalProperties: false, description: "Important Databricks documentation notice.", properties: { kind: { anyOf: [{ $ref: "#/$defs/Kind" }, { minLength: 1, type: "string" }], title: "Kind" }, title: { anyOf: [{ type: "string" }, { type: "null" }], title: "Title" }, text: { title: "Text", type: "string" }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" } }, required: ["kind", "text", "sources"], title: "Notice", type: "object" }, Output: { description: "Known model input and output modalities.", enum: ["text", "image", "audio", "video", "application/pdf", "embedding", "reranking", "decision"], title: "Output", type: "string" }, OverlayServingEndpointsRequest: { properties: { action: { const: "overlay_serving_endpoints", default: "overlay_serving_endpoints", title: "Action", type: "string" }, payload: { $ref: "#/$defs/ServingEndpointsResponse" } }, required: ["payload"], title: "OverlayServingEndpointsRequest", type: "object" }, OverlayServingEndpointsResponse: { properties: { action: { const: "effective_catalog", default: "effective_catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/EffectiveModelCatalog" } }, required: ["payload"], title: "OverlayServingEndpointsResponse", type: "object" }, Price: { additionalProperties: false, description: "Normalized Databricks price in one currency.", properties: { unit: { $ref: "#/$defs/Unit" }, rates: { additionalProperties: { minimum: 0, type: "number" }, propertyNames: { minLength: 1 }, title: "Rates", type: "object" } }, required: ["unit", "rates"], title: "Price", type: "object" }, ProblemDetails: { description: "An RFC 9457 problem details object, the payload of an error frame. See https://python.chanx.dev/en/latest/protocol.html#protocol-errors", properties: { type: { description: "A URI reference that identifies the problem type.", format: "uri-reference", type: "string" }, title: { description: "A short, human-readable summary of the problem type.", type: "string" }, status: { description: "The HTTP status code generated by the origin server for this occurrence of the problem.", maximum: 599, minimum: 100, type: "integer" }, detail: { description: "A human-readable explanation specific to this occurrence of the problem.", type: "string" }, instance: { description: "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.", format: "uri-reference", type: "string" }, errors: { description: "The validation failures, when type is validation-failed.", items: { $ref: "#/$defs/ValidationFailure" }, type: "array" } }, required: ["type", "title", "detail"], title: "ProblemDetails", type: "object" }, Rankings: { additionalProperties: false, description: "Competitive ranking based on human preference ratings.", properties: { domain: { title: "Domain", type: "string" }, category: { title: "Category", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" }, metric: { const: "rating", title: "Metric", type: "string" }, rating: { title: "Rating", type: "number" }, lower: { title: "Lower", type: "number" }, upper: { title: "Upper", type: "number" }, variance: { minimum: 0, title: "Variance", type: "number" }, votes: { maximum: 9007199254740991, minimum: 0, title: "Votes", type: "integer" } }, required: ["domain", "category", "rank", "sources", "metric", "rating", "lower", "upper", "variance", "votes"], title: "Rankings", type: "object" }, Rankings1: { additionalProperties: false, description: "Competitive ranking based on a scored evaluation.", properties: { domain: { title: "Domain", type: "string" }, category: { title: "Category", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant1" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" }, metric: { const: "score", title: "Metric", type: "string" }, score: { title: "Score", type: "number" }, lower: { title: "Lower", type: "number" }, upper: { title: "Upper", type: "number" }, observations: { maximum: 9007199254740991, minimum: 0, title: "Observations", type: "integer" }, sessions: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Sessions" } }, required: ["domain", "category", "rank", "sources", "metric", "score", "lower", "upper", "observations", "sessions"], title: "Rankings1", type: "object" }, RateLimits: { additionalProperties: false, description: "Published pay-per-token limits for one model.", properties: { input_tokens_per_minute: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Input Tokens Per Minute" }, output_tokens_per_minute: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Output Tokens Per Minute" }, queries_per_hour: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Queries Per Hour" } }, required: ["input_tokens_per_minute", "output_tokens_per_minute", "queries_per_hour"], title: "RateLimits", type: "object" }, Reasoning: { additionalProperties: false, description: "Reasoning support and controls when known.", properties: { supported: { const: false, title: "Supported", type: "boolean" } }, required: ["supported"], title: "Reasoning", type: "object" }, Reasoning1: { additionalProperties: false, description: "Reasoning support and controls when known.", properties: { supported: { const: true, title: "Supported", type: "boolean" }, effort: { anyOf: [{ items: { $ref: "#/$defs/EffortEnum" }, type: "array" }, { type: "null" }], title: "Effort" }, default_effort: { anyOf: [{ $ref: "#/$defs/DefaultEffort" }, { type: "null" }] }, toggle: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Toggle" }, budget: { anyOf: [{ $ref: "#/$defs/Budget" }, { type: "null" }] }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" } }, required: ["supported"], title: "Reasoning1", type: "object" }, ReasoningEffort: { description: "Reasoning effort used by the evaluated variant.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "ReasoningEffort", type: "string" }, ReasoningMode: { description: "Reasoning execution mode used by the evaluated variant.", enum: ["auto", "thinking"], title: "ReasoningMode", type: "string" }, Retirement: { additionalProperties: false, description: "Databricks retirement and replacement information.", properties: { schedules: { items: { $ref: "#/$defs/Schedule" }, title: "Schedules", type: "array" }, replacement: { anyOf: [{ minLength: 1, type: "string" }, { type: "null" }], title: "Replacement" }, replacement_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Replacement Name" } }, required: ["schedules"], title: "Retirement", type: "object" }, Schedule: { additionalProperties: false, description: "Retirement dates for one serving offering.", properties: { offering: { title: "Offering", type: "string" }, dates: { items: { format: "date", type: "string" }, title: "Dates", type: "array" } }, required: ["offering", "dates"], title: "Schedule", type: "object" }, ServedEntity: { description: "One served entity in a Serving Endpoints configuration.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, entity_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Entity Name" }, entity_version: { anyOf: [{ type: "string" }, { type: "null" }], title: "Entity Version" }, foundation_model: { anyOf: [{ $ref: "#/$defs/FoundationModel" }, { type: "null" }] }, external_model: { anyOf: [{ $ref: "#/$defs/ExternalModel" }, { type: "null" }] } }, title: "ServedEntity", type: "object" }, ServedModel: { description: "Legacy served model in a Serving Endpoints configuration.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, model_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Name" }, model_version: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Version" } }, title: "ServedModel", type: "object" }, ServingEndpoint: { description: "One serving endpoint from ``GET /api/2.0/serving-endpoints``.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, id: { anyOf: [{ type: "string" }, { type: "null" }], title: "Id" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, task: { anyOf: [{ type: "string" }, { type: "null" }], title: "Task" }, state: { anyOf: [{ $ref: "#/$defs/ServingEndpointState" }, { type: "null" }] }, config: { anyOf: [{ $ref: "#/$defs/ServingEndpointConfig" }, { type: "null" }] }, tags: { default: [], items: { $ref: "#/$defs/ServingEndpointTag" }, title: "Tags", type: "array" }, capabilities: { anyOf: [{ $ref: "#/$defs/ServingEndpointCapabilities" }, { type: "null" }] } }, title: "ServingEndpoint", type: "object" }, ServingEndpointCapabilities: { description: "Explicit endpoint capabilities reported by the workspace.", properties: { function_calling: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Function Calling" } }, title: "ServingEndpointCapabilities", type: "object" }, ServingEndpointConfig: { description: "Served entities and legacy served models for one endpoint.", properties: { served_entities: { default: [], items: { $ref: "#/$defs/ServedEntity" }, title: "Served Entities", type: "array" }, served_models: { default: [], items: { $ref: "#/$defs/ServedModel" }, title: "Served Models", type: "array" } }, title: "ServingEndpointConfig", type: "object" }, ServingEndpointState: { description: "Serving endpoint readiness and configuration update state.", properties: { ready: { anyOf: [{ type: "string" }, { type: "null" }], title: "Ready" }, config_update: { anyOf: [{ type: "string" }, { type: "null" }], title: "Config Update" } }, title: "ServingEndpointState", type: "object" }, ServingEndpointTag: { description: "User-defined serving endpoint tag.", properties: { key: { title: "Key", type: "string" }, value: { anyOf: [{ type: "string" }, { type: "null" }], title: "Value" } }, required: ["key"], title: "ServingEndpointTag", type: "object" }, ServingEndpointsResponse: { description: "Raw ``GET /api/2.0/serving-endpoints`` response body.", properties: { endpoints: { default: [], items: { $ref: "#/$defs/ServingEndpoint" }, title: "Endpoints", type: "array" } }, title: "ServingEndpointsResponse", type: "object" }, ServingMode: { description: "Databricks serving mode available for the model.", enum: ["pay_per_token", "priority_pay_per_token", "provisioned_throughput", "batch"], title: "ServingMode", type: "string" }, SourceLink: { additionalProperties: false, description: "Openable attribution for published catalog data.", properties: { label: { minLength: 1, title: "Label", type: "string" }, url: { minLength: 1, pattern: "^https?://", title: "Url", type: "string" } }, required: ["label", "url"], title: "SourceLink", type: "object" }, Status: { description: "Current normalized lifecycle state.", enum: ["active", "preview", "alpha", "beta", "legacy", "deprecated", "retired"], title: "Status", type: "string" }, Status1: { description: "Lifecycle state for this cloud-provider deployment.", enum: ["active", "preview", "alpha", "beta", "legacy", "deprecated", "retired"], title: "Status1", type: "string" }, StreamModelsRequest: { properties: { action: { const: "stream_models", default: "stream_models", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "StreamModelsRequest", type: "object" }, StreamModelsResponse: { properties: { action: { const: "model", default: "model", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogModelRecord" } }, required: ["payload"], title: "StreamModelsResponse", type: "object" }, Type: { description: "Normalized model type.", enum: ["chat", "image", "video", "embedding", "reranking", "decision", "transcription", "speech", "realtime", "extraction", "audio"], title: "Type", type: "string" }, Unit: { description: "Quantity to which the rates apply.", enum: ["per_million_tokens", "per_hour", "per_hour_per_50_model_units"], title: "Unit", type: "string" }, ValidationFailure: { description: "One validation failure, shaped like RFC 9457's validation example.", properties: { keyword: { description: "The JSON Schema keyword that failed, or custom.", type: "string" }, pointer: { description: "A JSON Pointer to the failing value in the frame; for required, the object lacking the member.", type: "string" }, detail: { description: "A human-readable message.", type: "string" }, property: { anyOf: [{ type: "string" }, { type: "integer" }], description: "For required only: the missing member." } }, required: ["keyword", "pointer", "detail"], title: "ValidationFailure", type: "object" }, Variant: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant", type: "object" }, Variant1: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant1", type: "object" }, Variant2: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant2", type: "object" }, WorkspaceEndpointCapabilities: { additionalProperties: false, description: "Capabilities the workspace states explicitly; ``None`` means unknown.", properties: { function_calling: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Function Calling" } }, title: "WorkspaceEndpointCapabilities", type: "object" }, WorkspaceEndpointSource: { description: "How the workspace serves the endpoint's model.", enum: ["foundation", "external", "custom"], title: "WorkspaceEndpointSource", type: "string" }, WorkspaceModelProfile: { additionalProperties: false, description: "AI Gateway relative quality, speed, and cost scores.", properties: { quality: { anyOf: [{ type: "number" }, { type: "null" }], title: "Quality" }, speed: { anyOf: [{ type: "number" }, { type: "null" }], title: "Speed" }, cost: { anyOf: [{ type: "number" }, { type: "null" }], title: "Cost" } }, title: "WorkspaceModelProfile", type: "object" }, WorkspaceRefresh: { additionalProperties: false, description: "Workspace overlay refresh state for one effective catalog.", properties: { status: { $ref: "#/$defs/WorkspaceRefreshStatus", description: "disabled: no workspace connection. current: overlay refreshed within the refresh interval. stale: a cached overlay served after a failed refresh. unavailable: discovery failed with no eligible cached overlay, so no workspace access is claimed." }, workspace: { anyOf: [{ type: "string" }, { type: "null" }], description: "Normalized workspace identity: id:<workspace id> or host:<host[/path]>.", title: "Workspace" }, persistent: { default: false, description: "True when the overlay is stored in the shared persistent cache.", title: "Persistent", type: "boolean" }, refreshed_at: { anyOf: [{ format: "date-time", type: "string" }, { type: "null" }], description: "When the served endpoint inventory was fetched.", title: "Refreshed At" }, attempted_at: { anyOf: [{ format: "date-time", type: "string" }, { type: "null" }], description: "When the most recent refresh was attempted.", title: "Attempted At" }, age_seconds: { anyOf: [{ minimum: 0, type: "number" }, { type: "null" }], description: "Age of the served inventory when this catalog was built.", title: "Age Seconds" }, error: { anyOf: [{ type: "string" }, { type: "null" }], description: "Most recent refresh error.", title: "Error" } }, required: ["status"], title: "WorkspaceRefresh", type: "object" }, WorkspaceRefreshStatus: { description: "Whether, and how currently, workspace enrichment applies.", enum: ["disabled", "current", "stale", "unavailable"], title: "WorkspaceRefreshStatus", type: "string" } } };
827
+ var CATALOG_SEARCH_INDEX_JSON_SCHEMA = { additionalProperties: false, properties: { schema_version: { title: "Schema Version", type: "integer" }, catalog_schema_version: { title: "Catalog Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, weights: { $ref: "#/$defs/CatalogSearchWeights" }, documents: { items: { $ref: "#/$defs/CatalogSearchIndexDocument" }, title: "Documents", type: "array" } }, required: ["schema_version", "catalog_schema_version", "updated_at", "weights", "documents"], title: "CatalogSearchIndexPayload", type: "object", $defs: { AiGatewayModelProfile: { description: "AI Gateway relative quality, speed, and cost profile.", properties: { quality: { anyOf: [{ type: "number" }, { type: "null" }], title: "Quality" }, speed: { anyOf: [{ type: "number" }, { type: "null" }], title: "Speed" }, cost: { anyOf: [{ type: "number" }, { type: "null" }], title: "Cost" } }, title: "AiGatewayModelProfile", type: "object" }, Availability: { additionalProperties: false, description: "Model availability on one Databricks cloud provider.", properties: { status: { $ref: "#/$defs/Status1" }, serving_modes: { items: { $ref: "#/$defs/ServingMode" }, title: "Serving Modes", type: "array" }, details: { anyOf: [{ type: "string" }, { type: "null" }], title: "Details" } }, required: ["status", "serving_modes"], title: "Availability", type: "object" }, AveragePrice: { additionalProperties: false, description: "Normalized Databricks price in one currency.", properties: { unit: { $ref: "#/$defs/Unit" }, rates: { additionalProperties: { minimum: 0, type: "number" }, propertyNames: { minLength: 1 }, title: "Rates", type: "object" } }, required: ["unit", "rates"], title: "AveragePrice", type: "object" }, Benchmark: { additionalProperties: false, description: "Task-suite benchmark result.", properties: { name: { title: "Name", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, score: { title: "Score", type: "number" }, task_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Task Count", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant2" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" } }, required: ["name", "rank", "score", "task_count", "sources"], title: "Benchmark", type: "object" }, Budget: { additionalProperties: false, description: "Supported reasoning-token budget range.", properties: { min: { anyOf: [{ maximum: 9007199254740991, minimum: -9007199254740991, type: "integer" }, { type: "null" }], title: "Min" }, max: { anyOf: [{ maximum: 9007199254740991, minimum: -9007199254740991, type: "integer" }, { type: "null" }], title: "Max" } }, title: "Budget", type: "object" }, Capabilities: { additionalProperties: false, description: "Capabilities used to select the model for a workload.", properties: { attachments: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Attachments" }, tools: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Tools" }, structured_output: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Structured Output" }, temperature: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Temperature" }, interleaved_reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Interleaved Reasoning" }, responses: { title: "Responses", type: "boolean" }, apply_patch: { title: "Apply Patch", type: "boolean" }, web_search: { title: "Web Search", type: "boolean" }, reasoning: { anyOf: [{ $ref: "#/$defs/Reasoning" }, { $ref: "#/$defs/Reasoning1" }, { type: "null" }], title: "Reasoning" } }, required: ["responses", "apply_patch", "web_search"], title: "Capabilities", type: "object" }, CatalogFilters: { additionalProperties: false, properties: { query: { anyOf: [{ type: "string" }, { type: "null" }], title: "Query" }, status: { items: { $ref: "#/$defs/Status" }, title: "Status", type: "array" }, type: { items: { $ref: "#/$defs/Type" }, title: "Type", type: "array" }, publisher: { items: { type: "string" }, title: "Publisher", type: "array" }, task: { items: { type: "string" }, title: "Task", type: "array" }, capability: { items: { enum: ["apply-patch", "attachments", "reasoning", "responses", "structured-output", "tools", "web-search"], type: "string" }, title: "Capability", type: "array" }, limit: { anyOf: [{ maximum: 1000, minimum: 0, type: "integer" }, { type: "null" }], default: 50, title: "Limit" } }, title: "CatalogFilters", type: "object" }, CatalogModel: { additionalProperties: false, description: "Published statistics for one Databricks model.", properties: { name: { title: "Name", type: "string" }, description: { title: "Description", type: "string" }, aliases: { items: { type: "string" }, title: "Aliases", type: "array" }, type: { $ref: "#/$defs/Type" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, publisher: { anyOf: [{ type: "string" }, { type: "null" }], title: "Publisher" }, license: { anyOf: [{ type: "string" }, { type: "null" }], title: "License" }, open_weights: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Open Weights" }, status: { $ref: "#/$defs/Status" }, release_date: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Release Date" }, last_updated: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Last Updated" }, knowledge_cutoff: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Knowledge Cutoff" }, retirement: { anyOf: [{ $ref: "#/$defs/Retirement" }, { type: "null" }] }, modalities: { $ref: "#/$defs/Modalities" }, capabilities: { $ref: "#/$defs/Capabilities" }, limits: { anyOf: [{ $ref: "#/$defs/Limits" }, { type: "null" }] }, rate_limits: { anyOf: [{ $ref: "#/$defs/RateLimits" }, { type: "null" }] }, latency: { anyOf: [{ $ref: "#/$defs/Latency" }, { type: "null" }] }, tasks: { items: { type: "string" }, title: "Tasks", type: "array" }, use_cases: { items: { type: "string" }, title: "Use Cases", type: "array" }, availability: { additionalProperties: { $ref: "#/$defs/Availability" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Availability", type: "object" }, price: { additionalProperties: { additionalProperties: { $ref: "#/$defs/Price" }, propertyNames: { enum: ["DBU", "USD"] }, type: "object" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Price", type: "object" }, average_price: { additionalProperties: { $ref: "#/$defs/AveragePrice" }, propertyNames: { enum: ["DBU", "USD"] }, title: "Average Price", type: "object" }, sources: { additionalProperties: { items: { $ref: "#/$defs/SourceLink" }, type: "array" }, propertyNames: { minLength: 1 }, title: "Sources", type: "object" }, notices: { items: { $ref: "#/$defs/Notice" }, title: "Notices", type: "array" }, rankings: { items: { anyOf: [{ $ref: "#/$defs/Rankings" }, { $ref: "#/$defs/Rankings1" }] }, title: "Rankings", type: "array" }, benchmarks: { items: { $ref: "#/$defs/Benchmark" }, title: "Benchmarks", type: "array" } }, required: ["name", "description", "aliases", "type", "status", "modalities", "capabilities", "tasks", "use_cases", "availability", "price", "average_price", "sources", "notices", "rankings", "benchmarks"], title: "CatalogModel", type: "object" }, CatalogModelRecord: { additionalProperties: false, properties: { name: { title: "Name", type: "string" }, description: { title: "Description", type: "string" }, aliases: { items: { type: "string" }, title: "Aliases", type: "array" }, type: { $ref: "#/$defs/Type" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, publisher: { anyOf: [{ type: "string" }, { type: "null" }], title: "Publisher" }, license: { anyOf: [{ type: "string" }, { type: "null" }], title: "License" }, open_weights: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Open Weights" }, status: { $ref: "#/$defs/Status" }, release_date: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Release Date" }, last_updated: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Last Updated" }, knowledge_cutoff: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Knowledge Cutoff" }, retirement: { anyOf: [{ $ref: "#/$defs/Retirement" }, { type: "null" }] }, modalities: { $ref: "#/$defs/Modalities" }, capabilities: { $ref: "#/$defs/Capabilities" }, limits: { anyOf: [{ $ref: "#/$defs/Limits" }, { type: "null" }] }, rate_limits: { anyOf: [{ $ref: "#/$defs/RateLimits" }, { type: "null" }] }, latency: { anyOf: [{ $ref: "#/$defs/Latency" }, { type: "null" }] }, tasks: { items: { type: "string" }, title: "Tasks", type: "array" }, use_cases: { items: { type: "string" }, title: "Use Cases", type: "array" }, availability: { additionalProperties: { $ref: "#/$defs/Availability" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Availability", type: "object" }, price: { additionalProperties: { additionalProperties: { $ref: "#/$defs/Price" }, propertyNames: { enum: ["DBU", "USD"] }, type: "object" }, propertyNames: { enum: ["aws", "azure", "gcp"] }, title: "Price", type: "object" }, average_price: { additionalProperties: { $ref: "#/$defs/AveragePrice" }, propertyNames: { enum: ["DBU", "USD"] }, title: "Average Price", type: "object" }, sources: { additionalProperties: { items: { $ref: "#/$defs/SourceLink" }, type: "array" }, propertyNames: { minLength: 1 }, title: "Sources", type: "object" }, notices: { items: { $ref: "#/$defs/Notice" }, title: "Notices", type: "array" }, rankings: { items: { anyOf: [{ $ref: "#/$defs/Rankings" }, { $ref: "#/$defs/Rankings1" }] }, title: "Rankings", type: "array" }, benchmarks: { items: { $ref: "#/$defs/Benchmark" }, title: "Benchmarks", type: "array" }, id: { minLength: 1, title: "Id", type: "string" } }, required: ["name", "description", "aliases", "type", "status", "modalities", "capabilities", "tasks", "use_cases", "availability", "price", "average_price", "sources", "notices", "rankings", "benchmarks", "id"], title: "CatalogModelRecord", type: "object" }, CatalogSearchIndexDocument: { additionalProperties: false, properties: { id: { title: "Id", type: "string" }, exact_identities: { items: { type: "string" }, title: "Exact Identities", type: "array" }, identities: { items: { type: "string" }, title: "Identities", type: "array" }, keywords: { title: "Keywords", type: "string" }, description: { title: "Description", type: "string" }, tokens: { items: { type: "string" }, title: "Tokens", type: "array" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, version: { items: { type: "integer" }, title: "Version", type: "array" }, quality_score: { maximum: 100, minimum: 0, title: "Quality Score", type: "number" }, scores: { $ref: "#/$defs/CatalogSearchQualityScores" } }, required: ["id", "exact_identities", "identities", "keywords", "description", "tokens", "version", "quality_score", "scores"], title: "CatalogSearchIndexDocument", type: "object" }, CatalogSearchIndexPayload: { additionalProperties: false, properties: { schema_version: { title: "Schema Version", type: "integer" }, catalog_schema_version: { title: "Catalog Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, weights: { $ref: "#/$defs/CatalogSearchWeights" }, documents: { items: { $ref: "#/$defs/CatalogSearchIndexDocument" }, title: "Documents", type: "array" } }, required: ["schema_version", "catalog_schema_version", "updated_at", "weights", "documents"], title: "CatalogSearchIndexPayload", type: "object" }, CatalogSearchQualityScores: { additionalProperties: false, properties: { leaderboard: { maximum: 100, minimum: 0, title: "Leaderboard", type: "number" }, benchmark: { maximum: 100, minimum: 0, title: "Benchmark", type: "number" }, version: { maximum: 100, minimum: 0, title: "Version", type: "number" }, freshness: { maximum: 100, minimum: 0, title: "Freshness", type: "number" }, lifecycle: { maximum: 100, minimum: 0, title: "Lifecycle", type: "number" } }, required: ["leaderboard", "benchmark", "version", "freshness", "lifecycle"], title: "CatalogSearchQualityScores", type: "object" }, CatalogSearchWeights: { additionalProperties: false, properties: { relevance: { title: "Relevance", type: "number" }, leaderboard: { title: "Leaderboard", type: "number" }, benchmark: { title: "Benchmark", type: "number" }, version: { title: "Version", type: "number" }, freshness: { title: "Freshness", type: "number" }, lifecycle: { title: "Lifecycle", type: "number" } }, required: ["relevance", "leaderboard", "benchmark", "version", "freshness", "lifecycle"], title: "CatalogSearchWeights", type: "object" }, DefaultEffort: { description: "Default reasoning effort when no level is specified.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "DefaultEffort", type: "string" }, EffectiveEndpoint: { additionalProperties: false, description: "Accessible endpoint: normalized live metadata, public match, and field provenance.", properties: { name: { description: "Invocable serving endpoint name.", minLength: 1, title: "Name", type: "string" }, display_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Display Name" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, task: { anyOf: [{ type: "string" }, { type: "null" }], description: "Databricks serving task, such as llm/v1/chat.", title: "Task" }, type: { anyOf: [{ $ref: "#/$defs/Type" }, { type: "null" }], description: "Catalog type mapped from a known task." }, modalities: { anyOf: [{ $ref: "#/$defs/Modalities" }, { type: "null" }], description: "Modalities mapped from a known task." }, state: { anyOf: [{ type: "string" }, { type: "null" }], description: "Endpoint readiness, such as READY.", title: "State" }, source: { $ref: "#/$defs/WorkspaceEndpointSource" }, family: { anyOf: [{ type: "string" }, { type: "null" }], title: "Family" }, capabilities: { $ref: "#/$defs/WorkspaceEndpointCapabilities" }, profile: { anyOf: [{ $ref: "#/$defs/WorkspaceModelProfile" }, { type: "null" }] }, identities: { items: { $ref: "#/$defs/IdentityCandidate" }, title: "Identities", type: "array" }, match: { anyOf: [{ $ref: "#/$defs/MatchedPublicIdentity" }, { type: "null" }] }, fields: { additionalProperties: { $ref: "#/$defs/FieldOrigin" }, description: "Origin of each overlay or placeholder field (dotted path). Matched records inherit every unlisted field from the public record, attributed by the record's sources; placeholder values are schema-required, not facts.", title: "Fields", type: "object" } }, required: ["name", "source", "capabilities", "identities", "fields"], title: "EffectiveEndpoint", type: "object" }, EffectiveModelCatalog: { additionalProperties: false, description: "Public catalog merged with one workspace's accessible endpoints.", properties: { contract_version: { title: "Contract Version", type: "integer" }, catalog: { $ref: "#/$defs/ModelCatalog" }, workspace: { $ref: "#/$defs/WorkspaceRefresh" }, endpoints: { additionalProperties: { $ref: "#/$defs/EffectiveEndpoint" }, description: "Accessible endpoints keyed by invocable endpoint name, which is also the record id in catalog.models when the endpoint has a record. An unmatched endpoint whose task maps to no catalog type is listed here only. Records without an entry are public references not confirmed accessible in the workspace.", title: "Endpoints", type: "object" } }, required: ["contract_version", "catalog", "workspace", "endpoints"], title: "EffectiveModelCatalog", type: "object" }, EffortEnum: { description: "Normalized reasoning effort level.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "EffortEnum", type: "string" }, ExternalModel: { description: "External model provider and name reported for a served entity.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, provider: { anyOf: [{ type: "string" }, { type: "null" }], title: "Provider" }, task: { anyOf: [{ type: "string" }, { type: "null" }], title: "Task" } }, title: "ExternalModel", type: "object" }, FieldOrigin: { description: "Where an effective record field value came from.", enum: ["workspace", "public", "placeholder"], title: "FieldOrigin", type: "string" }, FoundationModel: { description: "Foundation model metadata reported for a served entity.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, display_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Display Name" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, docs: { anyOf: [{ type: "string" }, { type: "null" }], title: "Docs" }, model_class: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Class" }, ai_gateway_model_profile: { anyOf: [{ $ref: "#/$defs/AiGatewayModelProfile" }, { type: "null" }] } }, title: "FoundationModel", type: "object" }, GetCatalogRequest: { properties: { action: { const: "get_catalog", default: "get_catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "GetCatalogRequest", type: "object" }, GetCatalogResponse: { properties: { action: { const: "catalog", default: "catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/ModelCatalog" } }, required: ["payload"], title: "GetCatalogResponse", type: "object" }, GetSearchIndexRequest: { properties: { action: { const: "get_search_index", default: "get_search_index", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "GetSearchIndexRequest", type: "object" }, GetSearchIndexResponse: { properties: { action: { const: "search_index", default: "search_index", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogSearchIndexPayload" } }, required: ["payload"], title: "GetSearchIndexResponse", type: "object" }, IdentityCandidate: { additionalProperties: false, description: "One exact identity reported for an endpoint.", properties: { kind: { enum: ["endpoint_name", "served_entity", "foundation_model", "external_model", "model_service"], title: "Kind", type: "string" }, value: { title: "Value", type: "string" } }, required: ["kind", "value"], title: "IdentityCandidate", type: "object" }, Input: { description: "Known model input and output modalities.", enum: ["text", "image", "audio", "video", "application/pdf", "embedding", "reranking", "decision"], title: "Input", type: "string" }, Kind: { description: "Known Databricks documentation notice kinds.", enum: ["note", "important", "warning", "tip", "caution", "info"], title: "Kind", type: "string" }, Latency: { additionalProperties: false, description: "Normalized response-time score and public benchmark measurements.", properties: { score: { exclusiveMinimum: 0, title: "Score", type: "number" }, measurements: { $ref: "#/$defs/LatencyMeasurements" } }, required: ["score", "measurements"], title: "Latency", type: "object" }, LatencyMeasurements: { additionalProperties: false, description: "Public benchmark measurements underlying one latency score.", properties: { time_to_first_token_ms: { minimum: 0, title: "Time To First Token Ms", type: "number" }, output_tokens_per_second: { exclusiveMinimum: 0, title: "Output Tokens Per Second", type: "number" }, successful_run_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Successful Run Count", type: "integer" }, completion_token_count: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Completion Token Count", type: "integer" }, measured_at: { format: "date-time", title: "Measured At", type: "string" } }, required: ["time_to_first_token_ms", "output_tokens_per_second", "successful_run_count", "completion_token_count", "measured_at"], title: "LatencyMeasurements", type: "object" }, Limits: { additionalProperties: false, description: "Documented token limits.", properties: { context: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Context" }, input: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Input" }, output: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Output" } }, title: "Limits", type: "object" }, ListModelsRequest: { properties: { action: { const: "list_models", default: "list_models", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "ListModelsRequest", type: "object" }, ListModelsResponse: { properties: { action: { const: "models", default: "models", title: "Action", type: "string" }, payload: { items: { $ref: "#/$defs/CatalogModelRecord" }, title: "Payload", type: "array" } }, required: ["payload"], title: "ListModelsResponse", type: "object" }, MatchedPublicIdentity: { additionalProperties: false, description: "Public catalog record an endpoint matched, and the endpoint identity that matched it.", properties: { id: { description: "Public catalog record id.", minLength: 1, title: "Id", type: "string" }, kind: { enum: ["endpoint_name", "served_entity", "foundation_model", "external_model", "model_service"], title: "Kind", type: "string" }, value: { description: "Endpoint identity that matched exactly.", minLength: 1, title: "Value", type: "string" } }, required: ["id", "kind", "value"], title: "MatchedPublicIdentity", type: "object" }, Modalities: { additionalProperties: false, description: "Model input and output modalities.", properties: { input: { items: { anyOf: [{ $ref: "#/$defs/Input" }, { pattern: "^(text|image|audio|video|application)\\/[A-Za-z0-9.+-]+$", type: "string" }] }, title: "Input", type: "array" }, output: { items: { anyOf: [{ $ref: "#/$defs/Output" }, { pattern: "^(text|image|audio|video|application)\\/[A-Za-z0-9.+-]+$", type: "string" }] }, title: "Output", type: "array" } }, required: ["input", "output"], title: "Modalities", type: "object" }, ModelCatalog: { additionalProperties: false, description: "Published Databricks model catalog with identity, capabilities, availability, pricing, lifecycle, rankings, and benchmarks.", properties: { schema_version: { const: 16, title: "Schema Version", type: "integer" }, updated_at: { format: "date-time", title: "Updated At", type: "string" }, models: { additionalProperties: { $ref: "#/$defs/CatalogModel" }, propertyNames: { minLength: 1 }, title: "Models", type: "object" } }, required: ["schema_version", "updated_at", "models"], title: "ModelCatalog", type: "object" }, Notice: { additionalProperties: false, description: "Important Databricks documentation notice.", properties: { kind: { anyOf: [{ $ref: "#/$defs/Kind" }, { minLength: 1, type: "string" }], title: "Kind" }, title: { anyOf: [{ type: "string" }, { type: "null" }], title: "Title" }, text: { title: "Text", type: "string" }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" } }, required: ["kind", "text", "sources"], title: "Notice", type: "object" }, Output: { description: "Known model input and output modalities.", enum: ["text", "image", "audio", "video", "application/pdf", "embedding", "reranking", "decision"], title: "Output", type: "string" }, OverlayServingEndpointsRequest: { properties: { action: { const: "overlay_serving_endpoints", default: "overlay_serving_endpoints", title: "Action", type: "string" }, payload: { $ref: "#/$defs/ServingEndpointsResponse" } }, required: ["payload"], title: "OverlayServingEndpointsRequest", type: "object" }, OverlayServingEndpointsResponse: { properties: { action: { const: "effective_catalog", default: "effective_catalog", title: "Action", type: "string" }, payload: { $ref: "#/$defs/EffectiveModelCatalog" } }, required: ["payload"], title: "OverlayServingEndpointsResponse", type: "object" }, Price: { additionalProperties: false, description: "Normalized Databricks price in one currency.", properties: { unit: { $ref: "#/$defs/Unit" }, rates: { additionalProperties: { minimum: 0, type: "number" }, propertyNames: { minLength: 1 }, title: "Rates", type: "object" } }, required: ["unit", "rates"], title: "Price", type: "object" }, ProblemDetails: { description: "An RFC 9457 problem details object, the payload of an error frame. See https://python.chanx.dev/en/latest/protocol.html#protocol-errors", properties: { type: { description: "A URI reference that identifies the problem type.", format: "uri-reference", type: "string" }, title: { description: "A short, human-readable summary of the problem type.", type: "string" }, status: { description: "The HTTP status code generated by the origin server for this occurrence of the problem.", maximum: 599, minimum: 100, type: "integer" }, detail: { description: "A human-readable explanation specific to this occurrence of the problem.", type: "string" }, instance: { description: "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.", format: "uri-reference", type: "string" }, errors: { description: "The validation failures, when type is validation-failed.", items: { $ref: "#/$defs/ValidationFailure" }, type: "array" } }, required: ["type", "title", "detail"], title: "ProblemDetails", type: "object" }, Rankings: { additionalProperties: false, description: "Competitive ranking based on human preference ratings.", properties: { domain: { title: "Domain", type: "string" }, category: { title: "Category", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" }, metric: { const: "rating", title: "Metric", type: "string" }, rating: { title: "Rating", type: "number" }, lower: { title: "Lower", type: "number" }, upper: { title: "Upper", type: "number" }, variance: { minimum: 0, title: "Variance", type: "number" }, votes: { maximum: 9007199254740991, minimum: 0, title: "Votes", type: "integer" } }, required: ["domain", "category", "rank", "sources", "metric", "rating", "lower", "upper", "variance", "votes"], title: "Rankings", type: "object" }, Rankings1: { additionalProperties: false, description: "Competitive ranking based on a scored evaluation.", properties: { domain: { title: "Domain", type: "string" }, category: { title: "Category", type: "string" }, rank: { exclusiveMinimum: 0, maximum: 9007199254740991, title: "Rank", type: "integer" }, published_at: { anyOf: [{ format: "date", type: "string" }, { type: "null" }], title: "Published At" }, variant: { anyOf: [{ $ref: "#/$defs/Variant1" }, { type: "null" }] }, sources: { items: { $ref: "#/$defs/SourceLink" }, title: "Sources", type: "array" }, metric: { const: "score", title: "Metric", type: "string" }, score: { title: "Score", type: "number" }, lower: { title: "Lower", type: "number" }, upper: { title: "Upper", type: "number" }, observations: { maximum: 9007199254740991, minimum: 0, title: "Observations", type: "integer" }, sessions: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Sessions" } }, required: ["domain", "category", "rank", "sources", "metric", "score", "lower", "upper", "observations", "sessions"], title: "Rankings1", type: "object" }, RateLimits: { additionalProperties: false, description: "Published pay-per-token limits for one model.", properties: { input_tokens_per_minute: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Input Tokens Per Minute" }, output_tokens_per_minute: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Output Tokens Per Minute" }, queries_per_hour: { anyOf: [{ maximum: 9007199254740991, minimum: 0, type: "integer" }, { type: "null" }], title: "Queries Per Hour" } }, required: ["input_tokens_per_minute", "output_tokens_per_minute", "queries_per_hour"], title: "RateLimits", type: "object" }, Reasoning: { additionalProperties: false, description: "Reasoning support and controls when known.", properties: { supported: { const: false, title: "Supported", type: "boolean" } }, required: ["supported"], title: "Reasoning", type: "object" }, Reasoning1: { additionalProperties: false, description: "Reasoning support and controls when known.", properties: { supported: { const: true, title: "Supported", type: "boolean" }, effort: { anyOf: [{ items: { $ref: "#/$defs/EffortEnum" }, type: "array" }, { type: "null" }], title: "Effort" }, default_effort: { anyOf: [{ $ref: "#/$defs/DefaultEffort" }, { type: "null" }] }, toggle: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Toggle" }, budget: { anyOf: [{ $ref: "#/$defs/Budget" }, { type: "null" }] }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" } }, required: ["supported"], title: "Reasoning1", type: "object" }, ReasoningEffort: { description: "Reasoning effort used by the evaluated variant.", enum: ["none", "minimal", "low", "medium", "high", "xhigh", "max", "default"], title: "ReasoningEffort", type: "string" }, ReasoningMode: { description: "Reasoning execution mode used by the evaluated variant.", enum: ["auto", "thinking"], title: "ReasoningMode", type: "string" }, Retirement: { additionalProperties: false, description: "Databricks retirement and replacement information.", properties: { schedules: { items: { $ref: "#/$defs/Schedule" }, title: "Schedules", type: "array" }, replacement: { anyOf: [{ minLength: 1, type: "string" }, { type: "null" }], title: "Replacement" }, replacement_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Replacement Name" } }, required: ["schedules"], title: "Retirement", type: "object" }, Schedule: { additionalProperties: false, description: "Retirement dates for one serving offering.", properties: { offering: { title: "Offering", type: "string" }, dates: { items: { format: "date", type: "string" }, title: "Dates", type: "array" } }, required: ["offering", "dates"], title: "Schedule", type: "object" }, ServedEntity: { description: "One served entity in a Serving Endpoints configuration.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, entity_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Entity Name" }, entity_version: { anyOf: [{ type: "string" }, { type: "null" }], title: "Entity Version" }, foundation_model: { anyOf: [{ $ref: "#/$defs/FoundationModel" }, { type: "null" }] }, external_model: { anyOf: [{ $ref: "#/$defs/ExternalModel" }, { type: "null" }] } }, title: "ServedEntity", type: "object" }, ServedModel: { description: "Legacy served model in a Serving Endpoints configuration.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, model_name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Name" }, model_version: { anyOf: [{ type: "string" }, { type: "null" }], title: "Model Version" } }, title: "ServedModel", type: "object" }, ServingEndpoint: { description: "One serving endpoint from ``GET /api/2.0/serving-endpoints``.", properties: { name: { anyOf: [{ type: "string" }, { type: "null" }], title: "Name" }, id: { anyOf: [{ type: "string" }, { type: "null" }], title: "Id" }, description: { anyOf: [{ type: "string" }, { type: "null" }], title: "Description" }, task: { anyOf: [{ type: "string" }, { type: "null" }], title: "Task" }, state: { anyOf: [{ $ref: "#/$defs/ServingEndpointState" }, { type: "null" }] }, config: { anyOf: [{ $ref: "#/$defs/ServingEndpointConfig" }, { type: "null" }] }, tags: { default: [], items: { $ref: "#/$defs/ServingEndpointTag" }, title: "Tags", type: "array" }, capabilities: { anyOf: [{ $ref: "#/$defs/ServingEndpointCapabilities" }, { type: "null" }] } }, title: "ServingEndpoint", type: "object" }, ServingEndpointCapabilities: { description: "Explicit endpoint capabilities reported by the workspace.", properties: { function_calling: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Function Calling" } }, title: "ServingEndpointCapabilities", type: "object" }, ServingEndpointConfig: { description: "Served entities and legacy served models for one endpoint.", properties: { served_entities: { default: [], items: { $ref: "#/$defs/ServedEntity" }, title: "Served Entities", type: "array" }, served_models: { default: [], items: { $ref: "#/$defs/ServedModel" }, title: "Served Models", type: "array" } }, title: "ServingEndpointConfig", type: "object" }, ServingEndpointState: { description: "Serving endpoint readiness and configuration update state.", properties: { ready: { anyOf: [{ type: "string" }, { type: "null" }], title: "Ready" }, config_update: { anyOf: [{ type: "string" }, { type: "null" }], title: "Config Update" } }, title: "ServingEndpointState", type: "object" }, ServingEndpointTag: { description: "User-defined serving endpoint tag.", properties: { key: { title: "Key", type: "string" }, value: { anyOf: [{ type: "string" }, { type: "null" }], title: "Value" } }, required: ["key"], title: "ServingEndpointTag", type: "object" }, ServingEndpointsResponse: { description: "Raw ``GET /api/2.0/serving-endpoints`` response body.", properties: { endpoints: { default: [], items: { $ref: "#/$defs/ServingEndpoint" }, title: "Endpoints", type: "array" } }, title: "ServingEndpointsResponse", type: "object" }, ServingMode: { description: "Databricks serving mode available for the model.", enum: ["pay_per_token", "priority_pay_per_token", "provisioned_throughput", "batch"], title: "ServingMode", type: "string" }, SourceLink: { additionalProperties: false, description: "Openable attribution for published catalog data.", properties: { label: { minLength: 1, title: "Label", type: "string" }, url: { minLength: 1, pattern: "^https?://", title: "Url", type: "string" } }, required: ["label", "url"], title: "SourceLink", type: "object" }, Status: { description: "Current normalized lifecycle state.", enum: ["active", "preview", "alpha", "beta", "legacy", "deprecated", "retired"], title: "Status", type: "string" }, Status1: { description: "Lifecycle state for this cloud-provider deployment.", enum: ["active", "preview", "alpha", "beta", "legacy", "deprecated", "retired"], title: "Status1", type: "string" }, StreamModelsRequest: { properties: { action: { const: "stream_models", default: "stream_models", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogFilters" } }, required: ["payload"], title: "StreamModelsRequest", type: "object" }, StreamModelsResponse: { properties: { action: { const: "model", default: "model", title: "Action", type: "string" }, payload: { $ref: "#/$defs/CatalogModelRecord" } }, required: ["payload"], title: "StreamModelsResponse", type: "object" }, Type: { description: "Normalized model type.", enum: ["chat", "image", "video", "embedding", "reranking", "decision", "transcription", "speech", "realtime", "extraction", "audio"], title: "Type", type: "string" }, Unit: { description: "Quantity to which the rates apply.", enum: ["per_million_tokens", "per_hour", "per_hour_per_50_model_units"], title: "Unit", type: "string" }, ValidationFailure: { description: "One validation failure, shaped like RFC 9457's validation example.", properties: { keyword: { description: "The JSON Schema keyword that failed, or custom.", type: "string" }, pointer: { description: "A JSON Pointer to the failing value in the frame; for required, the object lacking the member.", type: "string" }, detail: { description: "A human-readable message.", type: "string" }, property: { anyOf: [{ type: "string" }, { type: "integer" }], description: "For required only: the missing member." } }, required: ["keyword", "pointer", "detail"], title: "ValidationFailure", type: "object" }, Variant: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant", type: "object" }, Variant1: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant1", type: "object" }, Variant2: { additionalProperties: false, description: "Evaluated model variant when it differs from the base model.", properties: { reasoning: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Reasoning" }, reasoning_effort: { anyOf: [{ $ref: "#/$defs/ReasoningEffort" }, { type: "null" }] }, reasoning_mode: { anyOf: [{ $ref: "#/$defs/ReasoningMode" }, { type: "null" }] }, harness: { anyOf: [{ type: "string" }, { type: "null" }], title: "Harness" }, context: { anyOf: [{ exclusiveMinimum: 0, maximum: 9007199254740991, type: "integer" }, { type: "null" }], title: "Context" } }, title: "Variant2", type: "object" }, WorkspaceEndpointCapabilities: { additionalProperties: false, description: "Capabilities the workspace states explicitly; ``None`` means unknown.", properties: { function_calling: { anyOf: [{ type: "boolean" }, { type: "null" }], title: "Function Calling" } }, title: "WorkspaceEndpointCapabilities", type: "object" }, WorkspaceEndpointSource: { description: "How the workspace serves the endpoint's model.", enum: ["foundation", "external", "custom"], title: "WorkspaceEndpointSource", type: "string" }, WorkspaceModelProfile: { additionalProperties: false, description: "AI Gateway relative quality, speed, and cost scores.", properties: { quality: { anyOf: [{ type: "number" }, { type: "null" }], title: "Quality" }, speed: { anyOf: [{ type: "number" }, { type: "null" }], title: "Speed" }, cost: { anyOf: [{ type: "number" }, { type: "null" }], title: "Cost" } }, title: "WorkspaceModelProfile", type: "object" }, WorkspaceRefresh: { additionalProperties: false, description: "Workspace overlay refresh state for one effective catalog.", properties: { status: { $ref: "#/$defs/WorkspaceRefreshStatus", description: "disabled: no workspace connection. current: overlay refreshed within the refresh interval. stale: a cached overlay served after a failed refresh. unavailable: discovery failed with no eligible cached overlay, so no workspace access is claimed." }, workspace: { anyOf: [{ type: "string" }, { type: "null" }], description: "Normalized workspace identity: id:<workspace id> or host:<host[/path]>.", title: "Workspace" }, persistent: { default: false, description: "True when the overlay is stored in the shared persistent cache.", title: "Persistent", type: "boolean" }, refreshed_at: { anyOf: [{ format: "date-time", type: "string" }, { type: "null" }], description: "When the served endpoint inventory was fetched.", title: "Refreshed At" }, attempted_at: { anyOf: [{ format: "date-time", type: "string" }, { type: "null" }], description: "When the most recent refresh was attempted.", title: "Attempted At" }, age_seconds: { anyOf: [{ minimum: 0, type: "number" }, { type: "null" }], description: "Age of the served inventory when this catalog was built.", title: "Age Seconds" }, error: { anyOf: [{ type: "string" }, { type: "null" }], description: "Most recent refresh error.", title: "Error" } }, required: ["status"], title: "WorkspaceRefresh", type: "object" }, WorkspaceRefreshStatus: { description: "Whether, and how currently, workspace enrichment applies.", enum: ["disabled", "current", "stale", "unavailable"], title: "WorkspaceRefreshStatus", type: "string" } } };
828
+
829
+ // src/validation.ts
830
+ function modelCatalogDefinitionSchema(definition) {
831
+ return z.fromJSONSchema({
832
+ ...MODEL_CATALOG_JSON_SCHEMA.$defs[definition],
833
+ $defs: MODEL_CATALOG_JSON_SCHEMA.$defs
834
+ });
835
+ }
836
+ var ModelCatalogSchema2 = z.fromJSONSchema(MODEL_CATALOG_JSON_SCHEMA);
837
+ var CatalogSearchIndexSchema2 = z.fromJSONSchema(CATALOG_SEARCH_INDEX_JSON_SCHEMA);
838
+ var CatalogModelSchema2 = modelCatalogDefinitionSchema("CatalogModel");
839
+ var CatalogModelRecordSchema2 = modelCatalogDefinitionSchema("CatalogModelRecord");
840
+ var CatalogCapabilitiesSchema2 = modelCatalogDefinitionSchema("Capabilities");
841
+ var CatalogRateLimitsSchema2 = modelCatalogDefinitionSchema("RateLimits");
842
+ var CatalogLatencySchema2 = modelCatalogDefinitionSchema("Latency");
843
+ var CatalogPriceSchema2 = modelCatalogDefinitionSchema("Price");
844
+ var CatalogAveragePriceSchema2 = modelCatalogDefinitionSchema("AveragePrice");
845
+ var CatalogPreferenceRankingSchema2 = modelCatalogDefinitionSchema("Rankings");
846
+ var CatalogScoreRankingSchema2 = modelCatalogDefinitionSchema("Rankings1");
847
+ var CatalogRankingSchema2 = z.union([
848
+ CatalogPreferenceRankingSchema2,
849
+ CatalogScoreRankingSchema2
850
+ ]);
851
+ var CatalogStatusSchema2 = modelCatalogDefinitionSchema("Status");
852
+ var EffectiveModelCatalogSchema2 = modelCatalogDefinitionSchema("EffectiveModelCatalog");
853
+ var WorkspaceRefreshSchema2 = modelCatalogDefinitionSchema("WorkspaceRefresh");
854
+ var ServingEndpointsResponseSchema = modelCatalogDefinitionSchema("ServingEndpointsResponse");
855
+ var ServingEndpointSchema = modelCatalogDefinitionSchema("ServingEndpoint");
856
+ function parseModelCatalog2(value) {
857
+ return ModelCatalogSchema2.parse(value);
858
+ }
859
+ function parseCatalogSearchIndex2(value) {
860
+ return CatalogSearchIndexSchema2.parse(value);
861
+ }
862
+ function parseCatalogModelRecord2(value) {
863
+ return CatalogModelRecordSchema2.parse(value);
864
+ }
865
+ function parseEffectiveModelCatalog2(value) {
866
+ return EffectiveModelCatalogSchema2.parse(value);
867
+ }
868
+ function parseServingEndpointsResponse(value) {
869
+ return ServingEndpointsResponseSchema.parse(value ?? {});
870
+ }
871
+
872
+ // src/serving-endpoints.ts
873
+ var RULES = WORKSPACE_OVERLAY_RULES;
874
+ var MODEL_SERVICE_KINDS = new Set(["served_entity", "foundation_model"]);
875
+ function normalizeServingEndpoints(response) {
876
+ const endpoints = new Map;
877
+ for (const endpoint of parseServingEndpointsResponse(response).endpoints ?? []) {
878
+ const name = text(endpoint.name);
879
+ if (name && !endpoints.has(name))
880
+ endpoints.set(name, normalizeEndpoint(endpoint));
881
+ }
882
+ return [...endpoints.keys()].sort(compareCodePoints).map((name) => endpoints.get(name));
883
+ }
884
+ function normalizeFamily(value) {
885
+ return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || undefined;
886
+ }
887
+ function normalizeEndpoint(endpoint) {
888
+ const entities = endpoint.config?.served_entities ?? [];
889
+ const task = text(endpoint.task);
890
+ const taskType = task === undefined ? undefined : RULES.task_types[task];
891
+ const family = firstText(endpoint, RULES.family_fields);
892
+ const capabilities = {};
893
+ for (const [name, path] of Object.entries(RULES.capability_fields)) {
894
+ const value = values(endpoint, path).find((item) => typeof item === "boolean");
895
+ if (value !== undefined)
896
+ capabilities[name] = value;
897
+ }
898
+ return compact({
899
+ name: text(endpoint.name) ?? "",
900
+ display_name: firstText(endpoint, RULES.display_name_fields) ?? tagDisplayName(endpoint),
901
+ description: firstText(endpoint, RULES.description_fields),
902
+ task,
903
+ type: taskType?.type,
904
+ modalities: taskType ? structuredClone(taskType.modalities) : undefined,
905
+ state: text(endpoint.state?.ready),
906
+ source: entities.some((entity) => entity.foundation_model != null) ? "foundation" : entities.some((entity) => entity.external_model != null) ? "external" : "custom",
907
+ family: family === undefined ? undefined : normalizeFamily(family),
908
+ capabilities,
909
+ profile: profile(endpoint),
910
+ identities: identityCandidates(endpoint)
911
+ });
912
+ }
913
+ function identityCandidates(endpoint) {
914
+ const seen = new Set;
915
+ const candidates = [];
916
+ for (const rule of RULES.identity_fields) {
917
+ const join = "join" in rule ? rule.join : undefined;
918
+ for (const node of values(endpoint, rule.path)) {
919
+ let value;
920
+ if (join) {
921
+ const parts = isObject(node) ? join.map((key) => text(node[key])) : [undefined];
922
+ value = parts.every(Boolean) ? parts.join("/") : undefined;
923
+ } else {
924
+ value = text(node);
925
+ }
926
+ if (!value || seen.has(value))
927
+ continue;
928
+ seen.add(value);
929
+ const service = MODEL_SERVICE_KINDS.has(rule.kind) && RULES.model_service_prefixes.some((prefix) => value.startsWith(prefix));
930
+ candidates.push({ kind: service ? "model_service" : rule.kind, value });
931
+ }
932
+ }
933
+ return candidates;
934
+ }
935
+ function profile(endpoint) {
936
+ for (const path of RULES.profile_fields) {
937
+ for (const node of values(endpoint, path)) {
938
+ if (!isObject(node))
939
+ continue;
940
+ const scores = {};
941
+ for (const key of RULES.profile_keys) {
942
+ const value = node[key];
943
+ if (typeof value === "number" && Number.isFinite(value))
944
+ scores[key] = value;
945
+ }
946
+ if (Object.keys(scores).length)
947
+ return scores;
948
+ }
949
+ }
950
+ return;
951
+ }
952
+ function tagDisplayName(endpoint) {
953
+ const keys = RULES.display_name_tag_keys;
954
+ for (const tag of endpoint.tags ?? []) {
955
+ const value = keys.includes(tag.key) ? text(tag.value) : undefined;
956
+ if (value)
957
+ return value;
958
+ }
959
+ return;
960
+ }
961
+ function firstText(node, paths) {
962
+ for (const path of paths) {
963
+ for (const value of values(node, path)) {
964
+ const result = text(value);
965
+ if (result)
966
+ return result;
967
+ }
968
+ }
969
+ return;
970
+ }
971
+ function values(node, path) {
972
+ if (!path.length)
973
+ return [node];
974
+ const [head, ...rest] = path;
975
+ if (head === "*")
976
+ return Array.isArray(node) ? node.flatMap((item) => values(item, rest)) : [];
977
+ return isObject(node) && head in node ? values(node[head], rest) : [];
978
+ }
979
+ function text(value) {
980
+ return typeof value === "string" ? value.trim() || undefined : undefined;
981
+ }
982
+ function isObject(value) {
983
+ return typeof value === "object" && value !== null && !Array.isArray(value);
984
+ }
985
+ function compact(value) {
986
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
987
+ }
988
+ function compareCodePoints(left, right) {
989
+ return left < right ? -1 : left > right ? 1 : 0;
990
+ }
991
+
992
+ // src/effective.ts
993
+ var EFFECTIVE_CATALOG_CONTRACT_VERSION2 = WORKSPACE_OVERLAY_RULES.contract_version;
994
+ var RULES2 = WORKSPACE_OVERLAY_RULES;
995
+ function buildEffectiveCatalog(publicCatalog, endpoints = [], workspace = { status: "disabled" }) {
996
+ const index = new CatalogIdentityIndex(catalogRecords(publicCatalog));
997
+ const unique = new Map;
998
+ for (const endpoint of endpoints)
999
+ if (!unique.has(endpoint.name))
1000
+ unique.set(endpoint.name, endpoint);
1001
+ const claimed = new Set([
1002
+ ...Object.entries(publicCatalog.models).flatMap(([id, model]) => [id, ...model.aliases]),
1003
+ ...unique.keys()
1004
+ ].map((value) => value.toLowerCase()));
1005
+ const overlays = {};
1006
+ const endpointModels = new Map;
1007
+ for (const name of [...unique.keys()].sort(compareCodePoints)) {
1008
+ const endpoint = unique.get(name);
1009
+ const match = matchEndpoint(endpoint, index);
1010
+ if (!match && endpoint.type == null) {
1011
+ overlays[name] = { ...structuredClone(endpoint), fields: {} };
1012
+ continue;
1013
+ }
1014
+ const matched = match ? publicCatalog.models[match.id] : undefined;
1015
+ const { data, fields } = overlay(endpoint, matched);
1016
+ const extra = [];
1017
+ for (const candidate of endpoint.identities) {
1018
+ const key = candidate.value.toLowerCase();
1019
+ if (candidate.value !== name && !claimed.has(key) && !index.resolve(candidate.value)) {
1020
+ claimed.add(key);
1021
+ extra.push(candidate.value);
1022
+ }
1023
+ }
1024
+ data.aliases = [...match?.id === name ? data.aliases : [], ...extra];
1025
+ endpointModels.set(name, CatalogModelSchema2.parse(data));
1026
+ overlays[name] = { ...structuredClone(endpoint), ...match ? { match } : {}, fields };
1027
+ }
1028
+ if (!endpointModels.size) {
1029
+ return { contract_version: EFFECTIVE_CATALOG_CONTRACT_VERSION2, catalog: publicCatalog, workspace: refreshState(workspace), endpoints: overlays };
1030
+ }
1031
+ const models = {};
1032
+ for (const [id, model] of Object.entries(publicCatalog.models))
1033
+ models[id] = endpointModels.get(id) ?? model;
1034
+ for (const name of [...endpointModels.keys()].sort(compareCodePoints))
1035
+ models[name] ??= endpointModels.get(name);
1036
+ return {
1037
+ contract_version: EFFECTIVE_CATALOG_CONTRACT_VERSION2,
1038
+ catalog: { schema_version: publicCatalog.schema_version, updated_at: publicCatalog.updated_at, models },
1039
+ workspace: refreshState(workspace),
1040
+ endpoints: overlays
1041
+ };
1042
+ }
1043
+ function isEffectiveModelAccessible(effective, id) {
1044
+ return Object.hasOwn(effective.endpoints, id);
1045
+ }
1046
+ function buildEffectiveSearchIndex(effective, publicIndex) {
1047
+ const publicDocuments = new Map(publicIndex.documents.map((document) => [document.id, document]));
1048
+ const runtime = catalogSearchQuality(RULES2.runtime_search_quality, publicIndex.weights);
1049
+ const documents = catalogRecords(effective.catalog).map((record) => {
1050
+ const endpoint = effective.endpoints[record.id];
1051
+ const own = endpoint ? undefined : publicDocuments.get(record.id);
1052
+ if (own)
1053
+ return own;
1054
+ const source = endpoint?.match ? publicDocuments.get(endpoint.match.id) : undefined;
1055
+ const quality = source ?? runtime;
1056
+ return catalogSearchDocument(record, quality);
1057
+ });
1058
+ return {
1059
+ schema_version: publicIndex.schema_version,
1060
+ catalog_schema_version: effective.catalog.schema_version,
1061
+ updated_at: effective.catalog.updated_at,
1062
+ weights: publicIndex.weights,
1063
+ documents
1064
+ };
1065
+ }
1066
+ function refreshState(workspace) {
1067
+ return { persistent: false, ...workspace };
1068
+ }
1069
+ function matchEndpoint(endpoint, index) {
1070
+ for (const candidate of endpoint.identities) {
1071
+ const resolved = index.resolve(candidate.value);
1072
+ if (resolved)
1073
+ return { id: resolved.record.id, kind: candidate.kind, value: candidate.value };
1074
+ }
1075
+ return;
1076
+ }
1077
+ function overlay(endpoint, matched) {
1078
+ const fields = {};
1079
+ let data;
1080
+ if (matched) {
1081
+ data = structuredClone(matched);
1082
+ } else {
1083
+ data = {
1084
+ name: endpoint.name,
1085
+ aliases: [],
1086
+ capabilities: {},
1087
+ tasks: [],
1088
+ use_cases: [],
1089
+ availability: {},
1090
+ price: {},
1091
+ average_price: {},
1092
+ sources: {},
1093
+ notices: [],
1094
+ rankings: [],
1095
+ benchmarks: []
1096
+ };
1097
+ fields.name = "workspace";
1098
+ for (const [target, value] of Object.entries(RULES2.placeholders)) {
1099
+ setPath(data, target, structuredClone(value));
1100
+ fields[target] = "placeholder";
1101
+ }
1102
+ }
1103
+ const sources = data.sources;
1104
+ for (const rule of RULES2.overlay_fields) {
1105
+ if ("unmatched_only" in rule && rule.unmatched_only && matched)
1106
+ continue;
1107
+ const value = getPath(endpoint, rule.source);
1108
+ if (value != null) {
1109
+ setPath(data, rule.target, structuredClone(value));
1110
+ delete sources[rule.target];
1111
+ fields[rule.target] = "workspace";
1112
+ } else if (matched && getPath(data, rule.target) != null) {
1113
+ fields[rule.target] = "public";
1114
+ }
1115
+ }
1116
+ return {
1117
+ data,
1118
+ fields: Object.fromEntries(Object.entries(fields).sort(([left], [right]) => compareCodePoints(left, right)))
1119
+ };
1120
+ }
1121
+ function getPath(data, path) {
1122
+ let node = data;
1123
+ for (const part of path.split(".")) {
1124
+ if (typeof node !== "object" || node === null || Array.isArray(node))
1125
+ return;
1126
+ node = node[part];
1127
+ }
1128
+ return node;
1129
+ }
1130
+ function setPath(data, path, value) {
1131
+ const parts = path.split(".");
1132
+ const leaf = parts.pop();
1133
+ let node = data;
1134
+ for (const part of parts)
1135
+ node = node[part] ??= {};
1136
+ node[leaf] = value;
1137
+ }
1138
+
1139
+ // src/workspace-cache.ts
1140
+ var DEFAULT_WORKSPACE_REFRESH_AFTER_MS = WORKSPACE_OVERLAY_RULES.cache.refresh_interval_seconds * 1000;
1141
+ var DEFAULT_WORKSPACE_STALE_ON_ERROR_MS = WORKSPACE_OVERLAY_RULES.cache.stale_ttl_seconds * 1000;
1142
+ var sharedMemoryStore = createMemoryWorkspaceCacheStore();
1143
+ var storeStates = new WeakMap;
1144
+ async function workspaceCacheKey(input) {
1145
+ const principal = input.workspace ? input.principal?.trim() : undefined;
1146
+ const scope = principal ? await sha256(principal) : "session";
1147
+ const workspace = input.workspace ? `${input.workspace.kind}:${encodeURIComponent(input.workspace.value)}` : "unknown";
1148
+ return {
1149
+ id: `workspace-catalog/v${input.contractVersion}/${workspace}/${scope}`,
1150
+ shared: Boolean(principal)
1151
+ };
1152
+ }
1153
+ function createMemoryWorkspaceCacheStore(now = Date.now) {
1154
+ const entries = new Map;
1155
+ return {
1156
+ async get(key) {
1157
+ const entry = entries.get(key);
1158
+ if (entry?.expires !== undefined && entry.expires <= now())
1159
+ entries.delete(key);
1160
+ return entries.get(key)?.value;
1161
+ },
1162
+ async set(key, value, ttl) {
1163
+ entries.set(key, ttl ? { value, expires: now() + ttl } : { value });
1164
+ return true;
1165
+ },
1166
+ async delete(key) {
1167
+ return entries.delete(key);
1168
+ },
1169
+ async clear() {
1170
+ entries.clear();
1171
+ }
1172
+ };
1173
+ }
1174
+ function createWorkspaceCatalogCache(options = {}) {
1175
+ const now = options.now ?? Date.now;
1176
+ const refreshAfterMs = options.refreshAfterMs ?? DEFAULT_WORKSPACE_REFRESH_AFTER_MS;
1177
+ const staleOnErrorMs = options.staleOnErrorMs ?? DEFAULT_WORKSPACE_STALE_ON_ERROR_MS;
1178
+ const shared = options.store ?? sharedMemoryStore;
1179
+ const session = createMemoryWorkspaceCacheStore(now);
1180
+ const background = new Set;
1181
+ const storeFor = (key) => key.shared ? shared : session;
1182
+ const read = async (key) => {
1183
+ const entry = await storeFor(key).get(key.id);
1184
+ if (!entry || typeof entry.writtenAt !== "number")
1185
+ return;
1186
+ return now() - entry.writtenAt < staleOnErrorMs ? entry : undefined;
1187
+ };
1188
+ const load = (key, loader) => {
1189
+ const store = storeFor(key);
1190
+ const state = stateFor(store);
1191
+ const existing = state.inflight.get(key.id);
1192
+ if (existing)
1193
+ return existing;
1194
+ const pending = (async () => {
1195
+ try {
1196
+ const entry = { value: await loader(), writtenAt: now() };
1197
+ await store.set(key.id, entry, staleOnErrorMs);
1198
+ state.failures.delete(key.id);
1199
+ return entry;
1200
+ } catch (error) {
1201
+ state.failures.set(key.id, { error, at: now() });
1202
+ throw error;
1203
+ } finally {
1204
+ state.inflight.delete(key.id);
1205
+ }
1206
+ })();
1207
+ state.inflight.set(key.id, pending);
1208
+ return pending;
1209
+ };
1210
+ const result = (key, entry, status, error) => ({
1211
+ value: entry.value,
1212
+ status,
1213
+ writtenAt: entry.writtenAt,
1214
+ ageMs: Math.max(0, now() - entry.writtenAt),
1215
+ shared: key.shared,
1216
+ ...status === "stale" ? { error } : {}
1217
+ });
1218
+ return {
1219
+ async get(key, loader) {
1220
+ const entry = await read(key);
1221
+ if (!entry)
1222
+ return result(key, await load(key, loader), "fresh");
1223
+ if (now() - entry.writtenAt < refreshAfterMs)
1224
+ return result(key, entry, "fresh");
1225
+ const failure = stateFor(storeFor(key)).failures.get(key.id);
1226
+ const failed = failure !== undefined && failure.at >= entry.writtenAt;
1227
+ if (!failed || now() - failure.at >= refreshAfterMs) {
1228
+ const refresh = load(key, loader).catch(() => {
1229
+ return;
1230
+ });
1231
+ background.add(refresh);
1232
+ refresh.finally(() => background.delete(refresh));
1233
+ }
1234
+ return failed ? result(key, entry, "stale", failure.error) : result(key, entry, "refreshing");
1235
+ },
1236
+ async refresh(key, loader) {
1237
+ try {
1238
+ return result(key, await load(key, loader), "fresh");
1239
+ } catch (error) {
1240
+ const entry = await read(key);
1241
+ if (!entry)
1242
+ throw error;
1243
+ return result(key, entry, "stale", error);
1244
+ }
1245
+ },
1246
+ async evict(key) {
1247
+ const store = storeFor(key);
1248
+ stateFor(store).failures.delete(key.id);
1249
+ return store.delete(key.id);
1250
+ },
1251
+ async clear() {
1252
+ stateFor(shared).failures.clear();
1253
+ stateFor(session).failures.clear();
1254
+ await Promise.all([shared.clear(), session.clear()]);
1255
+ },
1256
+ async settle() {
1257
+ while (background.size > 0)
1258
+ await Promise.all([...background]);
1259
+ }
1260
+ };
1261
+ }
1262
+ function stateFor(store) {
1263
+ let state = storeStates.get(store);
1264
+ if (!state) {
1265
+ state = { inflight: new Map, failures: new Map };
1266
+ storeStates.set(store, state);
1267
+ }
1268
+ return state;
1269
+ }
1270
+ async function sha256(value) {
1271
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
1272
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
1273
+ }
1274
+
1275
+ // src/workspace-identity.ts
1276
+ var RULES3 = WORKSPACE_OVERLAY_RULES.workspace_identity;
1277
+ var HOST_PATTERNS = RULES3.host_patterns.map((pattern) => new RegExp(pattern));
1278
+ var SCHEME = /^[a-z][a-z\d+.-]*:\/\//i;
1279
+
1280
+ class WorkspaceConnectionError extends TypeError {
1281
+ name = "WorkspaceConnectionError";
1282
+ }
1283
+ function parseWorkspaceUrl(host) {
1284
+ const trimmed = typeof host === "string" ? host.trim() : "";
1285
+ if (!trimmed)
1286
+ throw new WorkspaceConnectionError("Workspace host is required");
1287
+ try {
1288
+ return new URL(SCHEME.test(trimmed) ? trimmed : `https://${trimmed}`);
1289
+ } catch {
1290
+ throw new WorkspaceConnectionError(`Workspace host is not a valid host or URL: ${trimmed}`);
1291
+ }
1292
+ }
1293
+ function normalizeWorkspaceHost(host) {
1294
+ const url = parseWorkspaceUrl(host);
1295
+ return `${url.hostname.toLowerCase()}${url.port ? `:${url.port}` : ""}${url.pathname.replace(/\/+$/, "")}`;
1296
+ }
1297
+ function formatWorkspaceIdentity(identity) {
1298
+ return `${identity.kind === "workspace_id" ? "id" : "host"}:${identity.value}`;
1299
+ }
1300
+ function resolveWorkspaceIdentity(host, headers) {
1301
+ const url = parseWorkspaceUrl(host);
1302
+ const resolvedHeaders = new Headers(headers);
1303
+ for (const name of RULES3.header_names) {
1304
+ const value = resolvedHeaders.get(name)?.trim();
1305
+ if (value)
1306
+ return { kind: "workspace_id", value };
1307
+ }
1308
+ const hostname = url.hostname.toLowerCase();
1309
+ for (const pattern of HOST_PATTERNS) {
1310
+ const value = pattern.exec(hostname)?.[1];
1311
+ if (value)
1312
+ return { kind: "workspace_id", value };
1313
+ }
1314
+ for (const name of RULES3.query_parameters) {
1315
+ const value = url.searchParams.get(name)?.trim();
1316
+ if (value)
1317
+ return { kind: "workspace_id", value };
1318
+ }
1319
+ return { kind: "host", value: normalizeWorkspaceHost(host) };
1320
+ }
1321
+ function principalIdentity(user) {
1322
+ if (!user || typeof user !== "object")
1323
+ return;
1324
+ for (const field of ["id", "userName"]) {
1325
+ const value = user[field];
1326
+ if (typeof value === "string" && value.trim())
1327
+ return value.trim();
1328
+ }
1329
+ return;
1330
+ }
1331
+
1332
+ // src/workspace-overlay.ts
1333
+ class WorkspaceOverlaySession {
1334
+ modelServing;
1335
+ cache;
1336
+ now;
1337
+ persistent;
1338
+ refreshAfterMs;
1339
+ staleOnErrorMs;
1340
+ attemptedAt;
1341
+ entry;
1342
+ inflight;
1343
+ key;
1344
+ state;
1345
+ workspace;
1346
+ constructor(modelServing, options = {}) {
1347
+ this.modelServing = modelServing;
1348
+ this.now = options.now ?? Date.now;
1349
+ this.refreshAfterMs = options.refreshAfterMs ?? DEFAULT_WORKSPACE_REFRESH_AFTER_MS;
1350
+ this.staleOnErrorMs = options.staleOnErrorMs ?? DEFAULT_WORKSPACE_STALE_ON_ERROR_MS;
1351
+ this.persistent = options.persistent ?? false;
1352
+ this.cache = options.cache ?? createWorkspaceCatalogCache({
1353
+ refreshAfterMs: this.refreshAfterMs,
1354
+ staleOnErrorMs: this.staleOnErrorMs,
1355
+ now: this.now,
1356
+ ...options.store === undefined ? {} : { store: options.store }
1357
+ });
1358
+ }
1359
+ load(options = {}) {
1360
+ if (this.inflight)
1361
+ return this.inflight;
1362
+ const now = this.now();
1363
+ if (!options.force && this.state && this.attemptedAt !== undefined && now - this.attemptedAt < this.refreshAfterMs) {
1364
+ return Promise.resolve(this.state);
1365
+ }
1366
+ const attempt = this.attempt(Boolean(options.force), now).catch((error) => this.failed(error, now, this.workspace));
1367
+ this.inflight = attempt.finally(() => {
1368
+ this.inflight = undefined;
1369
+ });
1370
+ return this.inflight;
1371
+ }
1372
+ async evict(options = {}) {
1373
+ await this.inflight;
1374
+ if (options.all)
1375
+ await this.cache.clear();
1376
+ else if (this.key)
1377
+ await this.cache.evict(this.key);
1378
+ this.attemptedAt = this.entry = this.key = this.state = undefined;
1379
+ }
1380
+ async settle() {
1381
+ await this.inflight;
1382
+ await this.cache.settle();
1383
+ }
1384
+ async attempt(force, now) {
1385
+ this.attemptedAt = now;
1386
+ let snapshot;
1387
+ try {
1388
+ snapshot = await this.modelServing.snapshot();
1389
+ } catch (error) {
1390
+ return this.failed(error, now, this.workspace);
1391
+ }
1392
+ const scoped = snapshot;
1393
+ const workspace = scoped.workspace && formatWorkspaceIdentity(scoped.workspace);
1394
+ const principal = await Promise.resolve().then(() => scoped.principal()).catch(() => {
1395
+ return;
1396
+ });
1397
+ const key = await workspaceCacheKey({
1398
+ workspace: scoped.workspace,
1399
+ contractVersion: EFFECTIVE_CATALOG_CONTRACT_VERSION2,
1400
+ principal
1401
+ });
1402
+ if (workspace !== this.workspace || key.id !== this.key?.id)
1403
+ this.entry = undefined;
1404
+ this.workspace = workspace;
1405
+ this.key = key;
1406
+ const loader = async () => ({
1407
+ endpoints: normalizeServingEndpoints(await scoped.listServingEndpoints())
1408
+ });
1409
+ try {
1410
+ let result = force ? await this.cache.refresh(key, loader) : await this.cache.get(key, loader);
1411
+ if (result.status !== "fresh")
1412
+ result = await this.cache.refresh(key, loader);
1413
+ return this.succeeded(result, now);
1414
+ } catch (error) {
1415
+ return this.failed(error, now, workspace);
1416
+ }
1417
+ }
1418
+ succeeded(result, now) {
1419
+ this.entry = { endpoints: result.value.endpoints, writtenAt: result.writtenAt };
1420
+ const stale = result.status === "stale";
1421
+ return this.serve(this.entry, now, {
1422
+ status: stale ? "stale" : "current",
1423
+ persistent: this.persistent && result.shared,
1424
+ ...stale ? { error: describeError(result.error) } : {}
1425
+ });
1426
+ }
1427
+ failed(error, now, workspace) {
1428
+ const fallback = this.entry && now - this.entry.writtenAt <= this.staleOnErrorMs ? this.entry : undefined;
1429
+ this.entry = fallback;
1430
+ this.workspace = workspace;
1431
+ return this.serve(fallback, now, {
1432
+ status: fallback ? "stale" : "unavailable",
1433
+ persistent: Boolean(fallback) && this.persistent && Boolean(this.key?.shared),
1434
+ error: describeError(error)
1435
+ });
1436
+ }
1437
+ serve(entry, now, refresh) {
1438
+ this.state = {
1439
+ ...entry && refresh.status !== "unavailable" ? { endpoints: entry.endpoints } : {},
1440
+ refresh: {
1441
+ status: refresh.status,
1442
+ ...this.workspace === undefined ? {} : { workspace: this.workspace },
1443
+ persistent: refresh.persistent ?? false,
1444
+ ...entry ? { refreshed_at: new Date(entry.writtenAt).toISOString() } : {},
1445
+ attempted_at: new Date(now).toISOString(),
1446
+ ...entry ? { age_seconds: Math.max(0, (now - entry.writtenAt) / 1000) } : {},
1447
+ ...refresh.error ? { error: refresh.error } : {}
1448
+ }
1449
+ };
1450
+ return this.state;
1451
+ }
1452
+ }
1453
+ function describeError(error) {
1454
+ return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
1455
+ }
1456
+
1457
+ // src/local-client.ts
1458
+ function workspaceOverlay(connector, cache) {
1459
+ return connector && new WorkspaceOverlaySession(connector, cache);
1460
+ }
1461
+ function createCatalogClient({ catalog, searchIndex, source }, overlay) {
1462
+ const publicView = catalogView(buildEffectiveCatalog(catalog), searchIndex);
1463
+ let view = publicView;
1464
+ let state;
1465
+ const current = async (force = false) => {
1466
+ if (!overlay)
1467
+ return publicView;
1468
+ const next = await overlay.load({ force });
1469
+ if (next !== state) {
1470
+ state = next;
1471
+ view = catalogView(buildEffectiveCatalog(catalog, next.endpoints ?? [], next.refresh), searchIndex);
1472
+ }
1473
+ return view;
1474
+ };
1475
+ const close = async () => {
1476
+ await overlay?.settle();
1477
+ };
1478
+ return {
1479
+ source,
1480
+ async catalog() {
1481
+ return (await current()).effective.catalog;
1482
+ },
1483
+ async searchIndex() {
1484
+ return (await current()).index.searchIndex;
1485
+ },
1486
+ async list(filters = {}) {
1487
+ return (await current()).index.list(filters);
1488
+ },
1489
+ async get(identity) {
1490
+ return (await current()).index.resolve(identity)?.record;
1491
+ },
1492
+ async resolve(identity) {
1493
+ return (await current()).index.resolve(identity);
1494
+ },
1495
+ async search(query, limit = 50) {
1496
+ return (await current()).index.search(query, limit);
1497
+ },
1498
+ async* stream(filters = {}) {
1499
+ for (const record of (await current()).index.list(filters))
1500
+ yield record;
1501
+ },
1502
+ async effectiveCatalog() {
1503
+ return (await current()).effective;
1504
+ },
1505
+ async workspaceStatus() {
1506
+ return (await current()).effective.workspace;
1507
+ },
1508
+ async isAccessible(id) {
1509
+ return isEffectiveModelAccessible((await current()).effective, id);
1510
+ },
1511
+ async refreshWorkspace() {
1512
+ return (await current(true)).effective.workspace;
1513
+ },
1514
+ async evictWorkspace(evict = {}) {
1515
+ await overlay?.evict(evict);
1516
+ },
1517
+ close,
1518
+ [Symbol.asyncDispose]: close
1519
+ };
1520
+ }
1521
+ function catalogView(effective, publicIndex) {
1522
+ const searchIndex = Object.keys(effective.endpoints).length ? buildEffectiveSearchIndex(effective, publicIndex) : publicIndex;
1523
+ return { effective, index: new ModelCatalogIndex(effective.catalog, searchIndex) };
1524
+ }
1525
+
1526
+ // src/_generated/published.ts
1527
+ var PUBLISHED_CATALOG_SCHEMA_VERSION2 = 16;
1528
+ var PUBLISHED_CATALOG_ROOT_URL2 = "https://raw.githubusercontent.com/reggie-db/dbx-model-catalog/main/packages/js/web";
1529
+ var PUBLISHED_CATALOG_INDEX_URL2 = `${PUBLISHED_CATALOG_ROOT_URL2}/catalog/index.json`;
1530
+ var PUBLISHED_CATALOG_SCHEMA_URL2 = `${PUBLISHED_CATALOG_ROOT_URL2}/catalog/v${PUBLISHED_CATALOG_SCHEMA_VERSION2}`;
1531
+ var PUBLISHED_CATALOG_URL2 = `${PUBLISHED_CATALOG_SCHEMA_URL2}/catalog.json`;
1532
+ var PUBLISHED_CATALOG_SEARCH_INDEX_URL2 = `${PUBLISHED_CATALOG_SCHEMA_URL2}/search-index.json`;
1533
+ var PUBLISHED_CATALOG_DATABASE_URL2 = `${PUBLISHED_CATALOG_SCHEMA_URL2}/catalog.sqlite`;
1534
+
1535
+ // src/sources.ts
1536
+ function isWebSocketUrl(value) {
1537
+ return /^wss?:/i.test(value);
1538
+ }
1539
+ function isHttpUrl(value) {
1540
+ return /^https?:/i.test(value);
1541
+ }
1542
+ async function loadBrowserSource(source, options) {
1543
+ if (source === undefined)
1544
+ return loadPublished(options);
1545
+ if (typeof source === "string" || source instanceof URL) {
1546
+ const location = source.toString();
1547
+ if (isWebSocketUrl(location))
1548
+ return loadWebSocket(location);
1549
+ return loadUrl(new URL(location, documentUrl()).toString(), options);
1550
+ }
1551
+ return loadMemory(source, options);
1552
+ }
1553
+ function documentUrl() {
1554
+ return globalThis.location?.href;
1555
+ }
1556
+ function loadPublished(options) {
1557
+ return download(PUBLISHED_CATALOG_URL2, options.searchIndex ?? PUBLISHED_CATALOG_SEARCH_INDEX_URL2, options, "published");
1558
+ }
1559
+ function loadUrl(url, options) {
1560
+ return download(url, options.searchIndex ?? new URL("search-index.json", url).toString(), options, "url");
1561
+ }
1562
+ function loadMemory(catalog, options) {
1563
+ if (options.searchIndex === undefined || typeof options.searchIndex === "string") {
1564
+ throw new TypeError("An in-memory catalog needs its search index payload as options.searchIndex");
1565
+ }
1566
+ return { catalog, searchIndex: options.searchIndex, source: { kind: "memory" } };
1567
+ }
1568
+ async function loadWebSocket(url) {
1569
+ let transport;
1570
+ try {
1571
+ transport = await import("./chunk-pwssxaq0.js");
1572
+ } catch (cause) {
1573
+ throw new Error("WebSocket catalog sources need the optional peers pynect and @chanx-js/client; install them with `bun add pynect @chanx-js/client`", { cause });
1574
+ }
1575
+ return { ...await transport.downloadWebSocketCatalog(url), source: { kind: "websocket", location: url } };
1576
+ }
1577
+ async function download(catalogUrl, searchIndex, options, kind) {
1578
+ const fetcher = options.fetch ?? globalThis.fetch;
1579
+ const [catalog, index] = await Promise.all([
1580
+ fetchJson(fetcher, catalogUrl, "Catalog").then(parseModelCatalog2),
1581
+ typeof searchIndex === "string" ? fetchJson(fetcher, searchIndex, "Search index").then(parseCatalogSearchIndex2) : searchIndex
1582
+ ]);
1583
+ return { catalog, searchIndex: index, source: { kind, location: catalogUrl } };
1584
+ }
1585
+ async function fetchJson(fetcher, url, label) {
1586
+ const response = await fetcher(url);
1587
+ if (!response.ok)
1588
+ throw new Error(`${label} request failed with ${response.status}`);
1589
+ return response.json();
1590
+ }
1591
+
1592
+ // src/workspace-connection.ts
1593
+ var SERVING_ENDPOINTS_PATH = WORKSPACE_OVERLAY_RULES.serving_endpoints_path;
1594
+ var CURRENT_USER_PATH = WORKSPACE_OVERLAY_RULES.principal.path;
1595
+
1596
+ class WorkspaceRequestError extends Error {
1597
+ path;
1598
+ status;
1599
+ name = "WorkspaceRequestError";
1600
+ constructor(path, status) {
1601
+ super(`Workspace request ${path} failed with ${status}`);
1602
+ this.path = path;
1603
+ this.status = status;
1604
+ }
1605
+ }
1606
+ var BROWSER_MODEL_SERVING_FORMS = "a { host, headers } connection or a function returning one";
1607
+ function connectBrowserModelServing(source, options = {}, supportedForms = BROWSER_MODEL_SERVING_FORMS) {
1608
+ if (typeof source === "function") {
1609
+ return {
1610
+ kind: "generator",
1611
+ snapshot: async () => restSnapshot(validateConnection(await source(), "Model serving connection generator returned no host"), options.fetch)
1612
+ };
1613
+ }
1614
+ if (source && typeof source === "object" && (("host" in source) || ("headers" in source))) {
1615
+ const resolved = validateConnection(source, "Model serving connection requires a host");
1616
+ return { kind: "connection", snapshot: async () => restSnapshot(resolved, options.fetch) };
1617
+ }
1618
+ throw new WorkspaceConnectionError(`Unsupported modelServingClient; expected ${supportedForms}`);
1619
+ }
1620
+ function requesterSnapshot(workspace, get) {
1621
+ return {
1622
+ ...workspace === undefined ? {} : { workspace },
1623
+ listServingEndpoints: () => collectPages(async (pageToken) => {
1624
+ const page = await get(SERVING_ENDPOINTS_PATH, pageToken === undefined ? undefined : { page_token: pageToken });
1625
+ if (!page || typeof page !== "object")
1626
+ throw new TypeError("Serving Endpoints response is not a JSON object");
1627
+ const { endpoints, next_page_token: next } = page;
1628
+ return { endpoints: Array.isArray(endpoints) ? endpoints : [], next };
1629
+ }),
1630
+ principal: async () => principalIdentity(await get(CURRENT_USER_PATH))
1631
+ };
1632
+ }
1633
+ async function collectPages(page) {
1634
+ const endpoints = [];
1635
+ const seen = new Set;
1636
+ let pageToken;
1637
+ do {
1638
+ const { endpoints: items, next } = await page(pageToken);
1639
+ endpoints.push(...items);
1640
+ pageToken = typeof next === "string" && next && !seen.has(next) ? next : undefined;
1641
+ if (pageToken)
1642
+ seen.add(pageToken);
1643
+ } while (pageToken);
1644
+ return { endpoints };
1645
+ }
1646
+ function restSnapshot({ host, headers }, fetcher) {
1647
+ const origin = parseWorkspaceUrl(host).origin;
1648
+ return requesterSnapshot(resolveWorkspaceIdentity(host, headers), async (path, query) => {
1649
+ const url = new URL(path, origin);
1650
+ for (const [name, value] of Object.entries(query ?? {}))
1651
+ url.searchParams.set(name, value);
1652
+ const requestHeaders = new Headers(headers);
1653
+ if (!requestHeaders.has("accept"))
1654
+ requestHeaders.set("accept", "application/json");
1655
+ const response = await (fetcher ?? globalThis.fetch)(url, { headers: requestHeaders });
1656
+ if (!response.ok)
1657
+ throw new WorkspaceRequestError(path, response.status);
1658
+ return response.json();
1659
+ });
1660
+ }
1661
+ function validateConnection(value, message) {
1662
+ const host = value && typeof value === "object" && typeof value.host === "string" ? value.host.trim() : "";
1663
+ if (!host)
1664
+ throw new WorkspaceConnectionError(message);
1665
+ parseWorkspaceUrl(host);
1666
+ return { host, headers: new Headers(value?.headers) };
1667
+ }
1668
+
1669
+ // src/workspace-client.ts
1670
+ var NODE_MODEL_SERVING_FORMS = "a @databricks/sdk-experimental WorkspaceClient, a @databricks/sdk-modelserving ModelServingClient, " + "a { host, headers } connection, or a function returning one";
1671
+ function connectModelServing(source, options = {}) {
1672
+ if (isWorkspaceClient(source))
1673
+ return workspaceClientConnector(source);
1674
+ if (isModelServingSdkClient(source)) {
1675
+ return {
1676
+ kind: "model_serving_client",
1677
+ snapshot: async () => ({
1678
+ listServingEndpoints: () => listInferenceEndpoints(source),
1679
+ principal: async () => {
1680
+ return;
1681
+ }
1682
+ })
1683
+ };
1684
+ }
1685
+ return connectBrowserModelServing(source, options, NODE_MODEL_SERVING_FORMS);
1686
+ }
1687
+ function workspaceClientConnector(client) {
1688
+ return {
1689
+ kind: "workspace_client",
1690
+ snapshot: async () => {
1691
+ const headers = new Headers;
1692
+ await client.config.authenticate(headers);
1693
+ const host = (await client.config.getHost()).toString();
1694
+ return requesterSnapshot(resolveWorkspaceIdentity(host, headers), (path, query) => client.apiClient.request({
1695
+ path,
1696
+ method: "GET",
1697
+ headers: new Headers({ accept: "application/json" }),
1698
+ raw: false,
1699
+ ...query === undefined ? {} : { query: { ...query } }
1700
+ }));
1701
+ }
1702
+ };
1703
+ }
1704
+ function toServingEndpointsWire(value) {
1705
+ if (typeof value === "bigint")
1706
+ return Number(value);
1707
+ if (Array.isArray(value))
1708
+ return value.map(toServingEndpointsWire);
1709
+ if (!value || typeof value !== "object")
1710
+ return value;
1711
+ const prototype = Object.getPrototypeOf(value);
1712
+ if (prototype !== Object.prototype && prototype !== null)
1713
+ return value;
1714
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined).map(([key, item]) => [key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), toServingEndpointsWire(item)]));
1715
+ }
1716
+ function listInferenceEndpoints(client) {
1717
+ return collectPages(async (pageToken) => {
1718
+ const page = await client.listInferenceEndpoints(pageToken === undefined ? {} : { pageToken });
1719
+ return { endpoints: (page.endpoints ?? []).map(toServingEndpointsWire), next: page.nextPageToken };
1720
+ });
1721
+ }
1722
+ function isWorkspaceClient(source) {
1723
+ const candidate = source;
1724
+ return typeof candidate === "object" && candidate !== null && typeof candidate.apiClient?.request === "function" && typeof candidate.config?.authenticate === "function" && typeof candidate.config.getHost === "function";
1725
+ }
1726
+ function isModelServingSdkClient(source) {
1727
+ return typeof source === "object" && source !== null && typeof source.listInferenceEndpoints === "function";
1728
+ }
1729
+
1730
+ // src/workspace-file-cache.ts
1731
+ import { join, resolve } from "node:path";
1732
+ import envPaths from "env-paths";
1733
+ import { KeyvFile } from "keyv-file";
1734
+ var fileStores = new Map;
1735
+ function defaultWorkspaceCacheFile() {
1736
+ return join(envPaths("dbx-model-catalog", { suffix: "" }).cache, "workspace-catalog.json");
1737
+ }
1738
+ function createFileWorkspaceCacheStore(options = {}) {
1739
+ const filename = resolve(options.filename ?? defaultWorkspaceCacheFile());
1740
+ let store = fileStores.get(filename);
1741
+ if (!store) {
1742
+ store = new KeyvFile({ filename, writeDelay: 50 });
1743
+ fileStores.set(filename, store);
1744
+ }
1745
+ return store;
1746
+ }
1747
+ function createPersistentWorkspaceCatalogCache2(options = {}) {
1748
+ const { filename, ...cacheOptions } = options;
1749
+ return createWorkspaceCatalogCache({
1750
+ ...cacheOptions,
1751
+ store: createFileWorkspaceCacheStore(filename === undefined ? {} : { filename })
1752
+ });
1753
+ }
1754
+ // src/index.ts
1755
+ async function createModelCatalogClient2(source, options = {}) {
1756
+ const connector = options.modelServingClient === undefined ? undefined : connectModelServing(options.modelServingClient, { fetch: options.fetch });
1757
+ const loaded = await loadSource(source, options);
1758
+ return createCatalogClient(loaded, workspaceOverlay(connector, nodeWorkspaceCache(options.workspaceCache)));
1759
+ }
1760
+ function loadSource(source, options) {
1761
+ if (source === undefined) {
1762
+ const configured = process.env.DBX_MODEL_CATALOG_PATH?.trim();
1763
+ return configured ? loadFiles(configured, options.searchIndex) : loadPublished(options);
1764
+ }
1765
+ if (typeof source !== "string" && !(source instanceof URL))
1766
+ return Promise.resolve(loadMemory(source, options));
1767
+ const location = source.toString();
1768
+ if (isHttpUrl(location) || isWebSocketUrl(location))
1769
+ return loadBrowserSource(location, options);
1770
+ return loadFiles(location.startsWith("file:") ? fileURLToPath(location) : location, options.searchIndex);
1771
+ }
1772
+ async function loadFiles(catalogPath, searchIndex) {
1773
+ const location = resolve2(catalogPath);
1774
+ const indexPath = typeof searchIndex === "string" ? resolve2(searchIndex) : resolve2(dirname(location), "search-index.json");
1775
+ const [catalog, index] = await Promise.all([
1776
+ readFile(location, "utf8").then((value) => parseModelCatalog2(JSON.parse(value))),
1777
+ typeof searchIndex === "object" ? searchIndex : readFile(indexPath, "utf8").then((value) => parseCatalogSearchIndex2(JSON.parse(value)))
1778
+ ]);
1779
+ return { catalog, searchIndex: index, source: { kind: "file", location } };
1780
+ }
1781
+ function nodeWorkspaceCache(options = {}) {
1782
+ const { filename, ...cache } = options;
1783
+ if (cache.cache !== undefined || cache.store !== undefined || cache.persistent === false)
1784
+ return cache;
1785
+ return {
1786
+ ...cache,
1787
+ persistent: true,
1788
+ cache: createPersistentWorkspaceCatalogCache2({
1789
+ ...cache.refreshAfterMs === undefined ? {} : { refreshAfterMs: cache.refreshAfterMs },
1790
+ ...cache.staleOnErrorMs === undefined ? {} : { staleOnErrorMs: cache.staleOnErrorMs },
1791
+ ...cache.now === undefined ? {} : { now: cache.now },
1792
+ ...filename === undefined ? {} : { filename }
1793
+ })
1794
+ };
1795
+ }
1796
+
1797
+ export { ModelCatalogSchema2, CatalogSearchIndexSchema2, CatalogModelSchema2, CatalogModelRecordSchema2, CatalogCapabilitiesSchema2, CatalogRateLimitsSchema2, CatalogLatencySchema2, CatalogPriceSchema2, CatalogAveragePriceSchema2, CatalogPreferenceRankingSchema2, CatalogScoreRankingSchema2, CatalogRankingSchema2, CatalogStatusSchema2, EffectiveModelCatalogSchema2, WorkspaceRefreshSchema2, parseModelCatalog2, parseCatalogSearchIndex2, parseCatalogModelRecord2, parseEffectiveModelCatalog2, EFFECTIVE_CATALOG_CONTRACT_VERSION2, PUBLISHED_CATALOG_SCHEMA_VERSION2, PUBLISHED_CATALOG_ROOT_URL2, PUBLISHED_CATALOG_INDEX_URL2, PUBLISHED_CATALOG_SCHEMA_URL2, PUBLISHED_CATALOG_URL2, PUBLISHED_CATALOG_SEARCH_INDEX_URL2, PUBLISHED_CATALOG_DATABASE_URL2, createPersistentWorkspaceCatalogCache2, createModelCatalogClient2 };