@dbx-tools/model 0.9.40 → 0.9.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/policy.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  type ServingEndpointSummary,
7
7
  } from "@dbx-tools/shared-model/contracts";
8
8
 
9
- import { supportsToolsByFamily } from "./classify.ts";
9
+ import { compareVersionTuples, supportsToolsByFamily, versionTuple } from "./classify.ts";
10
10
 
11
11
  const FAMILIES = [
12
12
  "claude",
@@ -54,6 +54,50 @@ export function modelSearchQuery(name: string): string | undefined {
54
54
  return [parsed.family, ...parsed.version.map(String), ...parsed.model].join(" ");
55
55
  }
56
56
 
57
+ /**
58
+ * Return whether `name` has native web search: an exact documented identity, or
59
+ * a later {@link versionTuple} in the same family as a documented native
60
+ * web-search model. Intra-family floors use the name digit parser so identities
61
+ * like `databricks-claude-opus-4-8` and `system.ai.gpt-6-1-sol` compare.
62
+ * Hosted GPT-OSS weights never inherit.
63
+ */
64
+ export function inheritsNativeWebSearch(name: string, documented: Iterable<string>): boolean {
65
+ const documentedKeys = documented instanceof Set ? documented : new Set(documented);
66
+ const key = modelSearchQuery(name)?.replaceAll(" ", "-");
67
+ if (key && documentedKeys.has(key)) return true;
68
+ const family = modelFamily(name);
69
+ if (!family || isOpenWeightsGpt(name)) return false;
70
+ const version = versionTuple(name);
71
+ if (isZeroVersion(version)) return false;
72
+ let floor: readonly number[] | undefined;
73
+ for (const entry of documentedKeys) {
74
+ if (modelFamily(entry) !== family || isOpenWeightsGpt(entry)) continue;
75
+ const documentedVersion = versionTuple(entry);
76
+ if (isZeroVersion(documentedVersion)) continue;
77
+ if (!floor || compareVersionTuples(documentedVersion, floor) < 0) {
78
+ floor = documentedVersion;
79
+ }
80
+ }
81
+ return floor !== undefined && compareVersionTuples(version, floor) >= 0;
82
+ }
83
+
84
+ /**
85
+ * Return whether an identity names a Databricks-hosted foundation model
86
+ * (`databricks-*` endpoint or `system.ai.*` model service). Custom and
87
+ * external endpoints use arbitrary names, so their digits are not versions.
88
+ */
89
+ export function isFoundationModelIdentity(name: string): boolean {
90
+ return /^(?:databricks-|system\.ai\.)/i.test(name.trim());
91
+ }
92
+
93
+ function isOpenWeightsGpt(name: string): boolean {
94
+ return modelFamily(name) === "gpt" && /(?:^|[-_.])oss(?:[-_.]|$)/i.test(name);
95
+ }
96
+
97
+ function isZeroVersion(version: readonly number[]): boolean {
98
+ return version.every((part) => (part ?? 0) === 0);
99
+ }
100
+
57
101
  /** Return the reasoning efforts accepted by a model family. */
58
102
  export function modelReasoningEfforts(name: string): ReasoningEffort[] {
59
103
  const normalized = name.toLowerCase();
@@ -129,9 +129,10 @@ interface AliasDocument {
129
129
  readonly level: ReasoningLevel;
130
130
  }
131
131
 
132
- const aliasDocuments: readonly AliasDocument[] = Object.entries(ALIASES).map(
133
- ([token, level]) => ({ token, level }),
134
- );
132
+ const aliasDocuments: readonly AliasDocument[] = Object.entries(ALIASES).map(([token, level]) => ({
133
+ token,
134
+ level,
135
+ }));
135
136
 
136
137
  const aliasFuse = new Fuse(aliasDocuments, {
137
138
  keys: ["token"],
@@ -384,7 +385,9 @@ export function adaptRequestReasoning(
384
385
  }
385
386
  }
386
387
 
387
- return changed ? { body: next, changed: true, wireEffort: wire } : { body, changed: false, wireEffort: wire };
388
+ return changed
389
+ ? { body: next, changed: true, wireEffort: wire }
390
+ : { body, changed: false, wireEffort: wire };
388
391
  }
389
392
 
390
393
  /** Normalize labels for alias lookup (`Extra High` → `extra-high`). */