@linxiraos/pi-catalog 1.4.3 → 1.4.6
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/CHANGELOG.md +12 -0
- package/THIRD-PARTY-NOTICES.txt +14 -0
- package/dist/types/compat/anthropic.d.ts +20 -0
- package/dist/types/compat/behavior.d.ts +2 -0
- package/dist/types/compat/catalog-policy.d.ts +2 -2
- package/dist/types/compat/collapse.d.ts +10 -0
- package/dist/types/compat/factory-droid.d.ts +2 -0
- package/dist/types/compat/resolve.d.ts +2 -2
- package/dist/types/compat/types.d.ts +2 -0
- package/dist/types/discovery/antigravity.d.ts +7 -2
- package/dist/types/discovery/devin.d.ts +1 -1
- package/dist/types/provider-models/google.d.ts +2 -0
- package/dist/types/provider-models/openai-compat.d.ts +16 -3
- package/dist/types/types.d.ts +58 -3
- package/dist/types/wire/devin.d.ts +2 -2
- package/dist/types/wire/gemini-headers.d.ts +41 -22
- package/dist/types/wire/xiaomi-token-plan.d.ts +2 -0
- package/package.json +4 -4
- package/src/build.ts +47 -1
- package/src/compat/anthropic.d.ts +20 -0
- package/src/compat/anthropic.ts +47 -0
- package/src/compat/axes.ts +10 -3
- package/src/compat/behavior.d.ts +2 -0
- package/src/compat/behavior.ts +5 -0
- package/src/compat/catalog-policy.ts +10 -8
- package/src/compat/collapse.d.ts +10 -0
- package/src/compat/collapse.ts +63 -2
- package/src/compat/factory-droid.d.ts +2 -0
- package/src/compat/factory-droid.ts +3 -0
- package/src/compat/resolve.d.ts +2 -2
- package/src/compat/resolve.ts +7 -5
- package/src/compat/rules/README.md +13 -5
- package/src/compat/rules/auth/google-antigravity.kdl +2 -1
- package/src/compat/rules/auth/llama.cpp.kdl +1 -1
- package/src/compat/rules/auth/xiaomi-token-plan-ams.kdl +1 -1
- package/src/compat/rules/auth/xiaomi-token-plan-cn.kdl +1 -1
- package/src/compat/rules/auth/xiaomi-token-plan-sgp.kdl +1 -1
- package/src/compat/rules/classes/anthropic.kdl +6 -1
- package/src/compat/rules/classes/minimax.kdl +10 -0
- package/src/compat/rules/providers/anthropic.kdl +15 -1
- package/src/compat/rules/providers/deepseek.kdl +13 -10
- package/src/compat/rules/providers/factory-droid.kdl +48 -0
- package/src/compat/rules/providers/google-antigravity.kdl +7 -0
- package/src/compat/rules/providers/kimi-code.kdl +20 -0
- package/src/compat/rules/providers/moonshot.kdl +25 -0
- package/src/compat/rules/providers/muse-code.kdl +1 -1
- package/src/compat/rules/providers/openai-codex.kdl +17 -4
- package/src/compat/rules/providers/openai.kdl +23 -2
- package/src/compat/rules/providers/opencode-go.kdl +38 -3
- package/src/compat/rules/providers/opencode-zen.kdl +7 -0
- package/src/compat/rules/providers/xiaomi-token-plan-ams.kdl +1 -1
- package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +1 -1
- package/src/compat/rules/providers/xiaomi-token-plan-sgp.kdl +1 -1
- package/src/compat/rules/providers/xiaomi.kdl +1 -1
- package/src/compat/rules/runtime/behavior.kdl +30 -14
- package/src/compat/rules/taxonomy/kimi.kdl +7 -0
- package/src/compat/rules.json +1 -1
- package/src/compat/types.d.ts +2 -0
- package/src/compat/types.ts +2 -0
- package/src/discovery/antigravity.d.ts +7 -2
- package/src/discovery/antigravity.ts +41 -6
- package/src/discovery/cursor.ts +0 -6
- package/src/discovery/devin.d.ts +1 -1
- package/src/discovery/devin.ts +9 -3
- package/src/discovery/factory-droid.ts +38 -6
- package/src/model-cache.ts +4 -2
- package/src/models.json +1 -1
- package/src/provider-models/cache-provider-id.ts +5 -2
- package/src/provider-models/google.d.ts +2 -0
- package/src/provider-models/google.ts +13 -1
- package/src/provider-models/openai-compat.d.ts +16 -3
- package/src/provider-models/openai-compat.ts +127 -38
- package/src/types.d.ts +58 -3
- package/src/types.ts +63 -1
- package/src/wire/devin.d.ts +2 -2
- package/src/wire/devin.ts +2 -2
- package/src/wire/gemini-headers.d.ts +41 -22
- package/src/wire/gemini-headers.ts +68 -24
- package/src/wire/xiaomi-token-plan.d.ts +2 -0
- package/src/wire/xiaomi-token-plan.ts +4 -0
package/src/compat/types.d.ts
CHANGED
|
@@ -327,6 +327,8 @@ export interface CompiledBehavior {
|
|
|
327
327
|
pricingPeers: CompiledPricingPeer[];
|
|
328
328
|
retryResetTimezones: CompiledRetryResetTimezone[];
|
|
329
329
|
retiredProviders: string[];
|
|
330
|
+
/** Hosts whose prefix caches benefit from a stable append-only conversation. */
|
|
331
|
+
appendOnlyContextProviders: string[];
|
|
330
332
|
referenceIsolatedProviders: string[];
|
|
331
333
|
/** Built-in model selector chains per agent role, keyed by role in declaration order. */
|
|
332
334
|
roleDefaults: Record<string, string[]>;
|
package/src/compat/types.ts
CHANGED
|
@@ -351,6 +351,8 @@ export interface CompiledBehavior {
|
|
|
351
351
|
pricingPeers: CompiledPricingPeer[];
|
|
352
352
|
retryResetTimezones: CompiledRetryResetTimezone[];
|
|
353
353
|
retiredProviders: string[];
|
|
354
|
+
/** Hosts whose prefix caches benefit from a stable append-only conversation. */
|
|
355
|
+
appendOnlyContextProviders: string[];
|
|
354
356
|
referenceIsolatedProviders: string[];
|
|
355
357
|
/** Built-in model selector chains per agent role, keyed by role in declaration order. */
|
|
356
358
|
roleDefaults: Record<string, string[]>;
|
|
@@ -11,6 +11,8 @@ export interface AntigravityDiscoveryApiModel {
|
|
|
11
11
|
supportsImages?: boolean;
|
|
12
12
|
supportsThinking?: boolean;
|
|
13
13
|
thinkingBudget?: number;
|
|
14
|
+
/** SKU thinking level: 1 low, 2 medium, 3 high. */
|
|
15
|
+
thinkingLevel?: number;
|
|
14
16
|
recommended?: boolean;
|
|
15
17
|
maxTokens?: number;
|
|
16
18
|
maxOutputTokens?: number;
|
|
@@ -55,8 +57,11 @@ export interface FetchAntigravityDiscoveryModelsOptions {
|
|
|
55
57
|
token: string;
|
|
56
58
|
/** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
|
|
57
59
|
endpoint?: string;
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Cloud Code Assist project the account is onboarded to. Sent as the body's
|
|
62
|
+
* `project` field like the native client; the body is `{}` when absent.
|
|
63
|
+
*/
|
|
64
|
+
projectId?: string;
|
|
60
65
|
/** Optional user agent override. */
|
|
61
66
|
userAgent?: string;
|
|
62
67
|
/** Optional abort signal for request cancellation. */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type } from "@linxiraos/pi-omptype";
|
|
2
2
|
import type { FetchImpl } from "@linxiraos/pi-utils";
|
|
3
3
|
import { collapseVariants, type VariantCollapseTable } from "../compat/collapse";
|
|
4
|
-
import type { ModelSpec } from "../types";
|
|
4
|
+
import type { AntigravityModelWireProfile, ModelSpec } from "../types";
|
|
5
5
|
import { discoveryFetch, toPositiveNumber } from "../utils";
|
|
6
|
-
import { ensureAntigravityVersion,
|
|
6
|
+
import { ensureAntigravityVersion, getAntigravityHeaders } from "../wire/gemini-headers";
|
|
7
7
|
|
|
8
8
|
export const ANTIGRAVITY_PRIMARY_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
|
|
9
9
|
export const ANTIGRAVITY_SANDBOX_ENDPOINT = "https://daily-cloudcode-pa.sandbox.googleapis.com";
|
|
@@ -14,6 +14,13 @@ const DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
|
14
14
|
const DEFAULT_MAX_TOKENS = 64_000;
|
|
15
15
|
const ANTIGRAVITY_DISCOVERY_DENYLIST = new Set(["chat_20706", "chat_23310", "gemini-2.5-pro"]);
|
|
16
16
|
|
|
17
|
+
/** `fetchAvailableModels` `thinkingLevel` → wire `thinkingConfig.thinkingLevel` (verified against the native client). */
|
|
18
|
+
const ANTIGRAVITY_THINKING_LEVELS: Readonly<Record<number, AntigravityModelWireProfile["thinkingLevel"]>> = {
|
|
19
|
+
1: "LOW",
|
|
20
|
+
2: "MEDIUM",
|
|
21
|
+
3: "HIGH",
|
|
22
|
+
};
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Raw model metadata returned by Antigravity's `fetchAvailableModels` endpoint.
|
|
19
26
|
*/
|
|
@@ -22,6 +29,8 @@ export interface AntigravityDiscoveryApiModel {
|
|
|
22
29
|
supportsImages?: boolean;
|
|
23
30
|
supportsThinking?: boolean;
|
|
24
31
|
thinkingBudget?: number;
|
|
32
|
+
/** SKU thinking level: 1 low, 2 medium, 3 high. */
|
|
33
|
+
thinkingLevel?: number;
|
|
25
34
|
recommended?: boolean;
|
|
26
35
|
maxTokens?: number;
|
|
27
36
|
maxOutputTokens?: number;
|
|
@@ -68,6 +77,9 @@ const AntigravityDiscoveryApiModelSchema = type({
|
|
|
68
77
|
"thinkingBudget?": type("unknown").pipe(value =>
|
|
69
78
|
typeof value === "number" && Number.isFinite(value) ? value : undefined,
|
|
70
79
|
),
|
|
80
|
+
"thinkingLevel?": type("unknown").pipe(value =>
|
|
81
|
+
typeof value === "number" && Number.isFinite(value) ? value : undefined,
|
|
82
|
+
),
|
|
71
83
|
"recommended?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
|
|
72
84
|
"maxTokens?": type("unknown").pipe(value =>
|
|
73
85
|
typeof value === "number" && Number.isFinite(value) ? value : undefined,
|
|
@@ -145,8 +157,11 @@ export interface FetchAntigravityDiscoveryModelsOptions {
|
|
|
145
157
|
token: string;
|
|
146
158
|
/** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
|
|
147
159
|
endpoint?: string;
|
|
148
|
-
/**
|
|
149
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Cloud Code Assist project the account is onboarded to. Sent as the body's
|
|
162
|
+
* `project` field like the native client; the body is `{}` when absent.
|
|
163
|
+
*/
|
|
164
|
+
projectId?: string;
|
|
150
165
|
/** Optional user agent override. */
|
|
151
166
|
userAgent?: string;
|
|
152
167
|
/** Optional abort signal for request cancellation. */
|
|
@@ -203,6 +218,7 @@ export async function fetchAntigravityDiscoveryModels(
|
|
|
203
218
|
}
|
|
204
219
|
|
|
205
220
|
const supportsImages = model.supportsImages === true;
|
|
221
|
+
const wireProfile = antigravityWireProfileOf(model);
|
|
206
222
|
models.push({
|
|
207
223
|
id: modelId,
|
|
208
224
|
name: model.displayName || modelId,
|
|
@@ -219,6 +235,7 @@ export async function fetchAntigravityDiscoveryModels(
|
|
|
219
235
|
},
|
|
220
236
|
contextWindow: toPositiveNumber(model.maxTokens, DEFAULT_CONTEXT_WINDOW),
|
|
221
237
|
maxTokens: toPositiveNumber(model.maxOutputTokens, DEFAULT_MAX_TOKENS),
|
|
238
|
+
...(wireProfile === undefined ? {} : { antigravityWireProfiles: { [modelId]: wireProfile } }),
|
|
222
239
|
});
|
|
223
240
|
}
|
|
224
241
|
}
|
|
@@ -234,6 +251,24 @@ export async function fetchAntigravityDiscoveryModels(
|
|
|
234
251
|
return { models: collapsed };
|
|
235
252
|
}
|
|
236
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Request constants the native client derives from one roster row: the
|
|
256
|
+
* `model_enum` label, the fixed output cap, and the SKU's thinking setting.
|
|
257
|
+
* Returns `undefined` when the row carries none of them.
|
|
258
|
+
*/
|
|
259
|
+
function antigravityWireProfileOf(model: AntigravityDiscoveryApiModel): AntigravityModelWireProfile | undefined {
|
|
260
|
+
const profile: AntigravityModelWireProfile = {};
|
|
261
|
+
if (model.model) profile.modelEnum = model.model;
|
|
262
|
+
if (model.maxOutputTokens !== undefined && model.maxOutputTokens > 0) {
|
|
263
|
+
profile.maxOutputTokens = model.maxOutputTokens;
|
|
264
|
+
}
|
|
265
|
+
const thinkingLevel =
|
|
266
|
+
model.thinkingLevel === undefined ? undefined : ANTIGRAVITY_THINKING_LEVELS[model.thinkingLevel];
|
|
267
|
+
if (thinkingLevel !== undefined) profile.thinkingLevel = thinkingLevel;
|
|
268
|
+
if (model.thinkingBudget !== undefined) profile.thinkingBudget = model.thinkingBudget;
|
|
269
|
+
return Object.keys(profile).length > 0 ? profile : undefined;
|
|
270
|
+
}
|
|
271
|
+
|
|
237
272
|
/** Advertised image model and serving endpoint for one Antigravity account. */
|
|
238
273
|
export interface AntigravityImageModel {
|
|
239
274
|
id: string;
|
|
@@ -276,9 +311,9 @@ async function fetchAntigravityDiscoveryResponse(
|
|
|
276
311
|
headers: {
|
|
277
312
|
Authorization: `Bearer ${options.token}`,
|
|
278
313
|
"Content-Type": "application/json",
|
|
279
|
-
|
|
314
|
+
...getAntigravityHeaders(options.userAgent),
|
|
280
315
|
},
|
|
281
|
-
body: JSON.stringify({}),
|
|
316
|
+
body: JSON.stringify(options.projectId ? { project: options.projectId } : {}),
|
|
282
317
|
signal: options.signal,
|
|
283
318
|
});
|
|
284
319
|
} catch {
|
package/src/discovery/cursor.ts
CHANGED
|
@@ -516,15 +516,9 @@ function resolveRichCursorCardCost(
|
|
|
516
516
|
function resolveCursorCardAxes(slug: string): { patch?: ModelCost; fallback?: ModelCost } {
|
|
517
517
|
const axes = resolveCatalogAxes({
|
|
518
518
|
id: slug,
|
|
519
|
-
name: slug,
|
|
520
519
|
api: "cursor-agent",
|
|
521
520
|
provider: "cursor",
|
|
522
|
-
baseUrl: CURSOR_DEFAULT_BASE_URL,
|
|
523
521
|
reasoning: false,
|
|
524
|
-
input: ["text"],
|
|
525
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
526
|
-
contextWindow: DEFAULT_CONTEXT_WINDOW,
|
|
527
|
-
maxTokens: DEFAULT_MAX_TOKENS,
|
|
528
522
|
});
|
|
529
523
|
// Dated cards ride along as a schedule, so a lane priced from a sibling
|
|
530
524
|
// slug's card (whose own id no rule matches) still changes price on time.
|
package/src/discovery/devin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface DevinModelDiscoveryOptions {
|
|
|
7
7
|
apiKey?: string;
|
|
8
8
|
/** Optional Codeium API base URL override. */
|
|
9
9
|
baseUrl?: string;
|
|
10
|
-
/** Optional request timeout in milliseconds (default
|
|
10
|
+
/** Optional request timeout in milliseconds (default 15000). */
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
/** Optional caller abort signal, combined with the internal timeout. */
|
|
13
13
|
signal?: AbortSignal;
|
package/src/discovery/devin.ts
CHANGED
|
@@ -296,7 +296,7 @@ export interface DevinModelDiscoveryOptions {
|
|
|
296
296
|
apiKey?: string;
|
|
297
297
|
/** Optional Codeium API base URL override. */
|
|
298
298
|
baseUrl?: string;
|
|
299
|
-
/** Optional request timeout in milliseconds (default
|
|
299
|
+
/** Optional request timeout in milliseconds (default 15000). */
|
|
300
300
|
timeoutMs?: number;
|
|
301
301
|
/** Optional caller abort signal, combined with the internal timeout. */
|
|
302
302
|
signal?: AbortSignal;
|
|
@@ -314,7 +314,10 @@ export interface DevinModelDiscoveryOptions {
|
|
|
314
314
|
export async function fetchDevinModels(
|
|
315
315
|
options: DevinModelDiscoveryOptions,
|
|
316
316
|
): Promise<ModelSpec<"devin-agent">[] | null> {
|
|
317
|
-
|
|
317
|
+
// `GetCliModelConfigs` returns the full per-account catalog (600+ configs)
|
|
318
|
+
// and often takes 7-15s to send headers; 5s silently fell back to the seed.
|
|
319
|
+
// 15s matches coding-agent's runtime discovery bound.
|
|
320
|
+
const timeoutMs = options.timeoutMs ?? 15_000;
|
|
318
321
|
const resolvedBaseUrl = options.baseUrl ?? DEVIN_DEFAULT_BASE_URL;
|
|
319
322
|
const requestUrl = `${resolvedBaseUrl.replace(/\/+$/, "")}${DEVIN_GET_CLI_MODEL_CONFIGS_PATH}`;
|
|
320
323
|
|
|
@@ -389,6 +392,9 @@ function devinModelSpec(
|
|
|
389
392
|
if (isAssignModelRouter) compat.modelRouter = true;
|
|
390
393
|
if (features?.supportsParallelToolCalls === true) compat.supportsParallelToolCalls = true;
|
|
391
394
|
const maxOutputTokens = config.modelInfo?.maxOutputTokens ?? 0;
|
|
395
|
+
// Current catalogs leave `ClientModelConfig.maxTokens` unset and carry each
|
|
396
|
+
// lane's context window on `ModelInfo.maxTokens` (200K vs 1M lanes differ there).
|
|
397
|
+
const contextWindow = config.maxTokens > 0 ? config.maxTokens : (config.modelInfo?.maxTokens ?? 0);
|
|
392
398
|
const spec: ModelSpec<"devin-agent"> = {
|
|
393
399
|
id: uid,
|
|
394
400
|
name: config.label.trim() || uid,
|
|
@@ -402,7 +408,7 @@ function devinModelSpec(
|
|
|
402
408
|
// mean tools are available.
|
|
403
409
|
supportsTools: features !== undefined ? features.supportsToolCalls : true,
|
|
404
410
|
cost: devinModelCost(config),
|
|
405
|
-
contextWindow:
|
|
411
|
+
contextWindow: contextWindow > 0 ? contextWindow : DEFAULT_CONTEXT_WINDOW,
|
|
406
412
|
maxTokens: maxOutputTokens > 0 ? maxOutputTokens : DEFAULT_MAX_TOKENS,
|
|
407
413
|
...(Object.keys(compat).length > 0 ? { compat } : {}),
|
|
408
414
|
};
|
|
@@ -72,6 +72,28 @@ function readModelPolicy(body: unknown): FactoryModelPolicy | null {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Org image-generation settings from `/api/organization/managed-settings`.
|
|
77
|
+
* The CLI gates `generate_image` on these, not on the model policy lists
|
|
78
|
+
* alone: `imageGenerationEnabled: false` withdraws every image model, and an
|
|
79
|
+
* `imageGenerationAllowedModelIds` list (empty allows none) narrows them.
|
|
80
|
+
*/
|
|
81
|
+
interface FactoryImageSettings {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
allowedModelIds?: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function readImageSettings(body: unknown): FactoryImageSettings | null {
|
|
87
|
+
if (!isRecord(body) || !isRecord(body.settings)) return null;
|
|
88
|
+
const { imageGenerationEnabled, imageGenerationAllowedModelIds } = body.settings;
|
|
89
|
+
return {
|
|
90
|
+
enabled: imageGenerationEnabled !== false,
|
|
91
|
+
...(Array.isArray(imageGenerationAllowedModelIds) && {
|
|
92
|
+
allowedModelIds: imageGenerationAllowedModelIds.filter((id): id is string => typeof id === "string"),
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
75
97
|
/**
|
|
76
98
|
* Live `provider_routing` dynamic config from the flags payload: per-model
|
|
77
99
|
* upstream rotations that override the registry's static order.
|
|
@@ -102,15 +124,22 @@ function readProviderRouting(body: Record<string, unknown>): FactoryProviderRout
|
|
|
102
124
|
};
|
|
103
125
|
}
|
|
104
126
|
|
|
105
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Mirrors the client-side model gating: feature flags first, then org model
|
|
129
|
+
* policy; image models also need the org's image-generation settings, so they
|
|
130
|
+
* stay hidden until a managed-settings payload proves them enabled.
|
|
131
|
+
*/
|
|
106
132
|
function isModelAvailable(
|
|
107
133
|
{ spec, policy: registry }: FactoryDroidRegistryModel,
|
|
108
134
|
flags: Record<string, boolean>,
|
|
109
135
|
policy: FactoryModelPolicy | null,
|
|
110
136
|
region: string | undefined,
|
|
137
|
+
images: FactoryImageSettings | null,
|
|
111
138
|
): boolean {
|
|
112
139
|
const gates = registry.entitlement;
|
|
113
140
|
if (resolveFactoryDroidRotation(registry, region).length === 0) return false;
|
|
141
|
+
if (registry.image && (!images?.enabled || (images.allowedModelIds && !images.allowedModelIds.includes(spec.id))))
|
|
142
|
+
return false;
|
|
114
143
|
if (gates.featureFlag !== undefined && flags[gates.featureFlag] !== true) return false;
|
|
115
144
|
if (gates.deprecationFlag !== undefined && flags[gates.deprecationFlag] === true) return false;
|
|
116
145
|
// Fast tiers are withdrawn as a class, not by id: `base-variant` is what
|
|
@@ -138,7 +167,7 @@ export interface FactoryDroidModelDiscoveryOptions extends AccountScope {
|
|
|
138
167
|
export function factoryDroidSeedModels(scope: AccountScope): ModelSpec<"factory-droid-agent">[] {
|
|
139
168
|
const inferenceRegion = resolveFactoryDroidInferenceRegion(scope);
|
|
140
169
|
return factoryDroidRegistry()
|
|
141
|
-
.filter(model => isModelAvailable(model, {}, null, inferenceRegion))
|
|
170
|
+
.filter(model => isModelAvailable(model, {}, null, inferenceRegion, null))
|
|
142
171
|
.map(model =>
|
|
143
172
|
buildFactoryDroidModel(model, {
|
|
144
173
|
region: scope.region,
|
|
@@ -168,6 +197,7 @@ export async function fetchFactoryDroidModels(
|
|
|
168
197
|
let flags: Record<string, boolean>;
|
|
169
198
|
let policy: FactoryModelPolicy | null = null;
|
|
170
199
|
let routing: FactoryProviderRouting | null = null;
|
|
200
|
+
let images: FactoryImageSettings | null = null;
|
|
171
201
|
const servingRegion = resolveFactoryDroidInferenceRegion(options);
|
|
172
202
|
try {
|
|
173
203
|
const [flagsResponse, settingsResponse] = await Promise.all([
|
|
@@ -180,15 +210,17 @@ export async function fetchFactoryDroidModels(
|
|
|
180
210
|
const raw = body.flags;
|
|
181
211
|
if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
182
212
|
flags = Object.fromEntries(Object.entries(raw).map(([key, value]) => [key, value === true]));
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
213
|
+
// An unreadable settings body leaves policy and image settings unknown, so
|
|
214
|
+
// gated rows fail closed instead of the whole refresh keeping stale ones.
|
|
215
|
+
const settings: unknown = settingsResponse?.ok ? await settingsResponse.json().catch(() => null) : null;
|
|
216
|
+
policy = readModelPolicy(settings);
|
|
217
|
+
images = readImageSettings(settings);
|
|
186
218
|
routing = readProviderRouting(body as Record<string, unknown>);
|
|
187
219
|
} catch {
|
|
188
220
|
return null;
|
|
189
221
|
}
|
|
190
222
|
return factoryDroidRegistry().flatMap(model => {
|
|
191
|
-
if (!isModelAvailable(model, flags, policy, servingRegion)) return [];
|
|
223
|
+
if (!isModelAvailable(model, flags, policy, servingRegion, images)) return [];
|
|
192
224
|
const { id } = model.spec;
|
|
193
225
|
const family = model.policy.routingFamily;
|
|
194
226
|
const routed = routing?.models?.[id] ?? (family === undefined ? undefined : routing?.defaults?.[family]);
|
package/src/model-cache.ts
CHANGED
|
@@ -10,7 +10,9 @@ import type { Api, Model } from "./types";
|
|
|
10
10
|
|
|
11
11
|
// Rows persist fully materialized Models so compatible warm-cache reads do not
|
|
12
12
|
// rerun the compat cascade. Request headers are intentionally omitted:
|
|
13
|
-
// arbitrary provider-defined header names can carry credentials.
|
|
13
|
+
// arbitrary provider-defined header names can carry credentials. v14
|
|
14
|
+
// invalidates Antigravity rows predating per-SKU `antigravityWireProfiles`
|
|
15
|
+
// (model_enum label, output cap, SKU thinking). v13 replaces
|
|
14
16
|
// sparse ModelSpec rows with materialized rows and records the exact app/rules/
|
|
15
17
|
// builder policy that produced them. v12 invalidated Kimi Code rows carrying the blanket
|
|
16
18
|
// maxTokens: 32000 that predate per-family output caps (k3/k3-256k -> 131072,
|
|
@@ -25,7 +27,7 @@ import type { Api, Model } from "./types";
|
|
|
25
27
|
// retired unknown-limit sentinels (222222/8888); v5 invalidated rows predating
|
|
26
28
|
// effort-tier variant collapsing (raw `-low`/`-high`/`-thinking` member ids);
|
|
27
29
|
// v4 dropped the pre-efforts ThinkingConfig shape.
|
|
28
|
-
const CACHE_SCHEMA_VERSION =
|
|
30
|
+
const CACHE_SCHEMA_VERSION = 14;
|
|
29
31
|
/** Oldest schema whose rows are guaranteed never to carry request headers. */
|
|
30
32
|
const FIRST_HEADERLESS_SCHEMA_VERSION = 11;
|
|
31
33
|
const HEADER_RESTORE_VERSION = 1;
|