@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.
Files changed (80) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/THIRD-PARTY-NOTICES.txt +14 -0
  3. package/dist/types/compat/anthropic.d.ts +20 -0
  4. package/dist/types/compat/behavior.d.ts +2 -0
  5. package/dist/types/compat/catalog-policy.d.ts +2 -2
  6. package/dist/types/compat/collapse.d.ts +10 -0
  7. package/dist/types/compat/factory-droid.d.ts +2 -0
  8. package/dist/types/compat/resolve.d.ts +2 -2
  9. package/dist/types/compat/types.d.ts +2 -0
  10. package/dist/types/discovery/antigravity.d.ts +7 -2
  11. package/dist/types/discovery/devin.d.ts +1 -1
  12. package/dist/types/provider-models/google.d.ts +2 -0
  13. package/dist/types/provider-models/openai-compat.d.ts +16 -3
  14. package/dist/types/types.d.ts +58 -3
  15. package/dist/types/wire/devin.d.ts +2 -2
  16. package/dist/types/wire/gemini-headers.d.ts +41 -22
  17. package/dist/types/wire/xiaomi-token-plan.d.ts +2 -0
  18. package/package.json +4 -4
  19. package/src/build.ts +47 -1
  20. package/src/compat/anthropic.d.ts +20 -0
  21. package/src/compat/anthropic.ts +47 -0
  22. package/src/compat/axes.ts +10 -3
  23. package/src/compat/behavior.d.ts +2 -0
  24. package/src/compat/behavior.ts +5 -0
  25. package/src/compat/catalog-policy.ts +10 -8
  26. package/src/compat/collapse.d.ts +10 -0
  27. package/src/compat/collapse.ts +63 -2
  28. package/src/compat/factory-droid.d.ts +2 -0
  29. package/src/compat/factory-droid.ts +3 -0
  30. package/src/compat/resolve.d.ts +2 -2
  31. package/src/compat/resolve.ts +7 -5
  32. package/src/compat/rules/README.md +13 -5
  33. package/src/compat/rules/auth/google-antigravity.kdl +2 -1
  34. package/src/compat/rules/auth/llama.cpp.kdl +1 -1
  35. package/src/compat/rules/auth/xiaomi-token-plan-ams.kdl +1 -1
  36. package/src/compat/rules/auth/xiaomi-token-plan-cn.kdl +1 -1
  37. package/src/compat/rules/auth/xiaomi-token-plan-sgp.kdl +1 -1
  38. package/src/compat/rules/classes/anthropic.kdl +6 -1
  39. package/src/compat/rules/classes/minimax.kdl +10 -0
  40. package/src/compat/rules/providers/anthropic.kdl +15 -1
  41. package/src/compat/rules/providers/deepseek.kdl +13 -10
  42. package/src/compat/rules/providers/factory-droid.kdl +48 -0
  43. package/src/compat/rules/providers/google-antigravity.kdl +7 -0
  44. package/src/compat/rules/providers/kimi-code.kdl +20 -0
  45. package/src/compat/rules/providers/moonshot.kdl +25 -0
  46. package/src/compat/rules/providers/muse-code.kdl +1 -1
  47. package/src/compat/rules/providers/openai-codex.kdl +17 -4
  48. package/src/compat/rules/providers/openai.kdl +23 -2
  49. package/src/compat/rules/providers/opencode-go.kdl +38 -3
  50. package/src/compat/rules/providers/opencode-zen.kdl +7 -0
  51. package/src/compat/rules/providers/xiaomi-token-plan-ams.kdl +1 -1
  52. package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +1 -1
  53. package/src/compat/rules/providers/xiaomi-token-plan-sgp.kdl +1 -1
  54. package/src/compat/rules/providers/xiaomi.kdl +1 -1
  55. package/src/compat/rules/runtime/behavior.kdl +30 -14
  56. package/src/compat/rules/taxonomy/kimi.kdl +7 -0
  57. package/src/compat/rules.json +1 -1
  58. package/src/compat/types.d.ts +2 -0
  59. package/src/compat/types.ts +2 -0
  60. package/src/discovery/antigravity.d.ts +7 -2
  61. package/src/discovery/antigravity.ts +41 -6
  62. package/src/discovery/cursor.ts +0 -6
  63. package/src/discovery/devin.d.ts +1 -1
  64. package/src/discovery/devin.ts +9 -3
  65. package/src/discovery/factory-droid.ts +38 -6
  66. package/src/model-cache.ts +4 -2
  67. package/src/models.json +1 -1
  68. package/src/provider-models/cache-provider-id.ts +5 -2
  69. package/src/provider-models/google.d.ts +2 -0
  70. package/src/provider-models/google.ts +13 -1
  71. package/src/provider-models/openai-compat.d.ts +16 -3
  72. package/src/provider-models/openai-compat.ts +127 -38
  73. package/src/types.d.ts +58 -3
  74. package/src/types.ts +63 -1
  75. package/src/wire/devin.d.ts +2 -2
  76. package/src/wire/devin.ts +2 -2
  77. package/src/wire/gemini-headers.d.ts +41 -22
  78. package/src/wire/gemini-headers.ts +68 -24
  79. package/src/wire/xiaomi-token-plan.d.ts +2 -0
  80. package/src/wire/xiaomi-token-plan.ts +4 -0
@@ -160,6 +160,7 @@ export function resolveModelCacheProviderId(providerId: string, options: ModelCa
160
160
  }
161
161
  case "litellm": {
162
162
  const baseUrl = options.baseUrl ?? getDefaultModelDiscoveryBaseUrl(providerId)!;
163
+ // rich-v13 moves `mode: decisions` groups off chat onto the Decisions runner.
163
164
  // rich-v12 invalidates namespaced ids that missed bare catalog references.
164
165
  // rich-v11 excluded ClinePass gateway metadata (issue #10932). rich-v10
165
166
  // filtered known non-conversational LiteLLM modes, unioned compat across
@@ -167,7 +168,7 @@ export function resolveModelCacheProviderId(providerId: string, options: ModelCa
167
168
  // declaration into it; earlier versions invalidated rows whose
168
169
  // `compatConfig` retained a colliding bundled model's provider-specific
169
170
  // transport (e.g. Fireworks `wireModelIdMode`) (issue #9938).
170
- return `litellm:rich-v12:${Bun.hash(baseUrl).toString(36)}`;
171
+ return `litellm:rich-v13:${Bun.hash(baseUrl).toString(36)}`;
171
172
  }
172
173
  case "gmi-cloud":
173
174
  case "siliconflow":
@@ -211,7 +212,9 @@ export function resolveModelCacheProviderId(providerId: string, options: ModelCa
211
212
  // v2: rows cached before Fusion pairings carried their lead uid as
212
213
  // `requestModelId` send the composite uid and fail with
213
214
  // `permission_denied: no API providers are available`.
214
- return "devin:models-v2";
215
+ // v3: rows cached before discovery read `ModelInfo.maxTokens` hold a
216
+ // 200K window on every model.
217
+ return "devin:models-v3";
215
218
  default:
216
219
  return providerId;
217
220
  }
@@ -21,6 +21,8 @@ export interface GoogleAntigravityAccount {
21
21
  * When any account lacks one, no model records per-account access.
22
22
  */
23
23
  accountKey?: string;
24
+ /** Cloud Code Assist project of the credential, sent with roster discovery like the native client. */
25
+ projectId?: string;
24
26
  }
25
27
  export interface GoogleAntigravityModelManagerConfig {
26
28
  /**
@@ -33,6 +33,8 @@ export interface GoogleAntigravityAccount {
33
33
  * When any account lacks one, no model records per-account access.
34
34
  */
35
35
  accountKey?: string;
36
+ /** Cloud Code Assist project of the credential, sent with roster discovery like the native client. */
37
+ projectId?: string;
36
38
  }
37
39
 
38
40
  export interface GoogleAntigravityModelManagerConfig {
@@ -113,6 +115,7 @@ export function googleAntigravityModelManagerOptions(
113
115
  result: await fetchAntigravityDiscoveryModels({
114
116
  token: account.accessToken,
115
117
  endpoint: config?.endpoint,
118
+ projectId: account.projectId,
116
119
  fetcher,
117
120
  }),
118
121
  })),
@@ -140,7 +143,15 @@ export function googleAntigravityModelManagerOptions(
140
143
  return unionAccountCatalogs(
141
144
  catalogs.map(({ accountKey, models }) =>
142
145
  tagAccess && accountKey !== undefined
143
- ? models.map(model => ({ ...model, accountAccess: { [accountKey]: {} } }))
146
+ ? models.map(model => ({
147
+ ...model,
148
+ accountAccess: {
149
+ [accountKey]:
150
+ model.antigravityWireProfiles === undefined
151
+ ? {}
152
+ : { antigravityWireProfiles: model.antigravityWireProfiles },
153
+ },
154
+ }))
144
155
  : models,
145
156
  ),
146
157
  );
@@ -167,6 +178,7 @@ export function googleGeminiCliModelManagerOptions(
167
178
  }
168
179
  const result = await fetchAntigravityDiscoveryModels({
169
180
  token,
181
+ projectId: config?.projectId,
170
182
  fetcher,
171
183
  collapseTable,
172
184
  });
@@ -377,24 +377,32 @@ export declare const KIMI_CODE_DEFAULT_MAX_TOKENS = 32000;
377
377
  export declare function kimiCodeMaxTokens(modelId: string, fallback?: number): number;
378
378
  export declare function kimiCodeMaxTokens(modelId: string, fallback: number | null): number | null;
379
379
  export declare function kimiCodeModelManagerOptions(config?: KimiCodeModelManagerConfig): ModelManagerOptions<"openai-completions">;
380
- /** Native LM Studio metadata keyed by model id from `/api/v0/models`. */
380
+ /** Native LM Studio metadata keyed by model id from `/api/v0/models` and `/api/v1/models`. */
381
381
  export interface LmStudioNativeModelMetadata {
382
382
  input: ("text" | "image")[];
383
383
  contextWindow?: number;
384
+ /**
385
+ * LM Studio reports a decision model (`type: "decision"`): it answers typed
386
+ * questions on `/v1/decisions` and rejects chat completions.
387
+ */
388
+ decision?: true;
384
389
  }
385
390
  /** Options for LM Studio's optional native metadata probe. */
386
391
  export interface LmStudioNativeModelMetadataOptions {
387
392
  headers?: Record<string, string>;
388
393
  signal?: AbortSignal;
389
394
  }
390
- /** Fetches LM Studio native model metadata used to mark VLM models as image-capable. */
395
+ /**
396
+ * Fetches LM Studio native model metadata used to mark VLM models as
397
+ * image-capable and decision models as judges.
398
+ */
391
399
  export declare function fetchLmStudioNativeModelMetadata(baseUrl: string, fetchImpl?: FetchImpl, options?: LmStudioNativeModelMetadataOptions): Promise<Map<string, LmStudioNativeModelMetadata> | null>;
392
400
  export interface LmStudioModelManagerConfig {
393
401
  apiKey?: string;
394
402
  baseUrl?: string;
395
403
  fetch?: FetchImpl;
396
404
  }
397
- export declare function lmStudioModelManagerOptions(config?: LmStudioModelManagerConfig): ModelManagerOptions<"openai-completions">;
405
+ export declare function lmStudioModelManagerOptions(config?: LmStudioModelManagerConfig): ModelManagerOptions<Api>;
398
406
  export interface SyntheticModelManagerConfig {
399
407
  apiKey?: string;
400
408
  baseUrl?: string;
@@ -560,6 +568,11 @@ export declare const OPENAI_COMPAT_DISCOVERY_DEFAULT_MAX_TOKENS = 32768;
560
568
  /** Exclude only known non-conversational modes; unknown and non-string modes remain selectable for aliases. */
561
569
  export declare function isSelectableLiteLLMModelMode(mode: unknown): boolean;
562
570
  export declare function normalizeLiteLLMManagementBaseUrl(baseUrl: string): string;
571
+ /**
572
+ * Transport for a LiteLLM model group: `mode: "decisions"` answers only on the
573
+ * proxy's `/v1/decisions` route, OpenAI-backed groups use Responses, and every
574
+ * other group uses `fallbackApi`.
575
+ */
563
576
  export declare function resolveLiteLLMApi(entry: Record<string, unknown> | undefined, id: string, fallbackApi?: Api): Api;
564
577
  export declare function fetchLiteLLMRichModels<TApi extends Api>(options: FetchLiteLLMRichModelsOptions<TApi>): Promise<ModelSpec<TApi>[] | null>;
565
578
  export declare function litellmModelManagerOptions(config?: LiteLLMModelManagerConfig): ModelManagerOptions<Api>;
@@ -10,6 +10,7 @@ import {
10
10
  isLikelyOpenAIResponsesId,
11
11
  modelLimitsFor,
12
12
  } from "../compat/behavior";
13
+ import { resolveAnthropicApiVersion } from "../compat/anthropic";
13
14
  import { xaiResponsesReasoningEffortMap } from "../compat/openai";
14
15
  import { hasModelScopedEffortLadder, resolveModelPolicy } from "../compat/resolve";
15
16
  import { compareRevision, parseRevision } from "../compat/revision";
@@ -40,6 +41,7 @@ import {
40
41
  type Provider,
41
42
  type ThinkingConfig,
42
43
  type TokenCost,
44
+ runnerApiKind,
43
45
  } from "../types";
44
46
  import {
45
47
  discoveryFetch,
@@ -69,6 +71,7 @@ import {
69
71
  SINGULARITYAPI_TECH_API_BASE_URL,
70
72
  normalizeSingularityApiBaseUrl,
71
73
  } from "../wire/singularityapi";
74
+ import { isXiaomiTokenPlanKey } from "../wire/xiaomi-token-plan";
72
75
  import { createBundledReferenceMap, createReferenceResolver, toModelSpec } from "./bundled-references";
73
76
  import { getDefaultModelDiscoveryBaseUrl, resolveModelCacheProviderId } from "./cache-provider-id";
74
77
  import { getClinePassModelMetadata } from "./cline-pass";
@@ -499,10 +502,10 @@ function mapAnthropicModelsDev(payload: unknown, baseUrl: string): ModelSpec<"an
499
502
  return models;
500
503
  }
501
504
 
502
- function buildAnthropicDiscoveryHeaders(apiKey: string): Record<string, string> {
505
+ function buildAnthropicDiscoveryHeaders(apiKey: string, baseUrl: string): Record<string, string> {
503
506
  const oauthToken = isAnthropicOAuthToken(apiKey);
504
507
  const headers: Record<string, string> = {
505
- "anthropic-version": "2023-06-01",
508
+ "anthropic-version": resolveAnthropicApiVersion(baseUrl),
506
509
  "anthropic-dangerous-direct-browser-access": "true",
507
510
  "anthropic-beta": ANTHROPIC_OAUTH_BETA,
508
511
  };
@@ -913,7 +916,7 @@ function createSimpleAnthropicProviderOptions(
913
916
  api: "anthropic-messages",
914
917
  provider: providerId,
915
918
  baseUrl: discoveryBaseUrl,
916
- headers: buildAnthropicDiscoveryHeaders(apiKey),
919
+ headers: buildAnthropicDiscoveryHeaders(apiKey, discoveryBaseUrl),
917
920
  mapModel: (entry, defaults) => {
918
921
  const reference = references.get(defaults.id);
919
922
  const model = mapWithBundledReference(entry, defaults, reference);
@@ -4269,10 +4272,15 @@ export function kimiCodeModelManagerOptions(
4269
4272
  // 12.5. LM Studio
4270
4273
  // ---------------------------------------------------------------------------
4271
4274
 
4272
- /** Native LM Studio metadata keyed by model id from `/api/v0/models`. */
4275
+ /** Native LM Studio metadata keyed by model id from `/api/v0/models` and `/api/v1/models`. */
4273
4276
  export interface LmStudioNativeModelMetadata {
4274
4277
  input: ("text" | "image")[];
4275
4278
  contextWindow?: number;
4279
+ /**
4280
+ * LM Studio reports a decision model (`type: "decision"`): it answers typed
4281
+ * questions on `/v1/decisions` and rejects chat completions.
4282
+ */
4283
+ decision?: true;
4276
4284
  }
4277
4285
 
4278
4286
  /** Options for LM Studio's optional native metadata probe. */
@@ -4296,13 +4304,56 @@ function getLmStudioCapabilityNames(value: unknown): string[] {
4296
4304
  return value.flatMap(item => (typeof item === "string" ? [item.toLowerCase()] : []));
4297
4305
  }
4298
4306
 
4307
+ function getLmStudioModelType(entry: Record<string, unknown>): string {
4308
+ return typeof entry.type === "string" ? entry.type.toLowerCase() : "";
4309
+ }
4310
+
4299
4311
  function getLmStudioNativeInput(entry: Record<string, unknown>): ("text" | "image")[] {
4300
- const modelType = typeof entry.type === "string" ? entry.type.toLowerCase() : "";
4312
+ const modelType = getLmStudioModelType(entry);
4313
+ // A decision model stays `type: "decision"` when it reads images; LM Studio
4314
+ // says so through `has_vision_adapter` instead.
4315
+ if (modelType === "decision") {
4316
+ return entry.has_vision_adapter === true ? ["text", "image"] : ["text"];
4317
+ }
4301
4318
  const capabilities = getLmStudioCapabilityNames(entry.capabilities);
4302
4319
  const supportsImage = modelType === "vlm" || capabilities.includes("vision") || capabilities.includes("image");
4303
4320
  return supportsImage ? ["text", "image"] : ["text"];
4304
4321
  }
4305
4322
 
4323
+ /**
4324
+ * Decision models from LM Studio's v1 listing (`GET /api/v1/models`), keyed by
4325
+ * model key and by every loaded instance id. The v0 listing predates decision
4326
+ * models, so this is where `type: "decision"` is reported.
4327
+ */
4328
+ function getLmStudioV1DecisionModels(payload: unknown): Map<string, LmStudioNativeModelMetadata> {
4329
+ const metadata = new Map<string, LmStudioNativeModelMetadata>();
4330
+ if (!isRecord(payload) || !Array.isArray(payload.models)) {
4331
+ return metadata;
4332
+ }
4333
+ for (const entry of payload.models) {
4334
+ if (!isRecord(entry) || getLmStudioModelType(entry) !== "decision") {
4335
+ continue;
4336
+ }
4337
+ const instances = Array.isArray(entry.loaded_instances) ? entry.loaded_instances.filter(isRecord) : [];
4338
+ const loadedContextWindow = instances
4339
+ .map(instance => (isRecord(instance.config) ? toPositiveNumber(instance.config.context_length, null) : null))
4340
+ .find(window => window !== null);
4341
+ const contextWindow = loadedContextWindow ?? toPositiveNumber(entry.max_context_length, null) ?? undefined;
4342
+ const model: LmStudioNativeModelMetadata = {
4343
+ input: getLmStudioNativeInput(entry),
4344
+ ...(contextWindow === undefined ? {} : { contextWindow }),
4345
+ decision: true,
4346
+ };
4347
+ const ids = [entry.key, ...instances.map(instance => instance.id)];
4348
+ for (const id of ids) {
4349
+ if (typeof id === "string" && id.length > 0) {
4350
+ metadata.set(id, model);
4351
+ }
4352
+ }
4353
+ }
4354
+ return metadata;
4355
+ }
4356
+
4306
4357
  function getLmStudioNativeContextWindow(entry: Record<string, unknown>): number | undefined {
4307
4358
  // LM Studio serves `loaded_context_length` (the window the running instance
4308
4359
  // actually accepts) alongside `max_context_length` (the architectural
@@ -4321,43 +4372,52 @@ function getLmStudioNativeContextWindow(entry: Record<string, unknown>): number
4321
4372
  );
4322
4373
  }
4323
4374
 
4324
- /** Fetches LM Studio native model metadata used to mark VLM models as image-capable. */
4375
+ /**
4376
+ * Fetches LM Studio native model metadata used to mark VLM models as
4377
+ * image-capable and decision models as judges.
4378
+ */
4325
4379
  export async function fetchLmStudioNativeModelMetadata(
4326
4380
  baseUrl: string,
4327
4381
  fetchImpl: FetchImpl = fetch,
4328
4382
  options?: LmStudioNativeModelMetadataOptions,
4329
4383
  ): Promise<Map<string, LmStudioNativeModelMetadata> | null> {
4330
4384
  const nativeBaseUrl = toLmStudioNativeBaseUrl(baseUrl);
4331
- const fetchMetadata = async (signal?: AbortSignal): Promise<Map<string, LmStudioNativeModelMetadata> | null> => {
4385
+ const fetchJson = async (path: string, signal?: AbortSignal): Promise<unknown> => {
4332
4386
  try {
4333
- const response = await fetchImpl(`${nativeBaseUrl}/api/v0/models`, {
4387
+ const response = await fetchImpl(`${nativeBaseUrl}${path}`, {
4334
4388
  method: "GET",
4335
4389
  headers: { Accept: "application/json", ...options?.headers },
4336
4390
  signal,
4337
4391
  });
4338
- if (!response.ok) {
4339
- return null;
4340
- }
4341
- const payload = await response.json();
4342
- if (!isRecord(payload) || !Array.isArray(payload.data)) {
4343
- return null;
4344
- }
4345
- const metadata = new Map<string, LmStudioNativeModelMetadata>();
4346
- for (const entry of payload.data) {
4347
- if (!isRecord(entry) || typeof entry.id !== "string" || entry.id.length === 0) {
4348
- continue;
4349
- }
4350
- const contextWindow = getLmStudioNativeContextWindow(entry);
4351
- metadata.set(entry.id, {
4352
- input: getLmStudioNativeInput(entry),
4353
- ...(contextWindow === undefined ? {} : { contextWindow }),
4354
- });
4355
- }
4356
- return metadata;
4392
+ return response.ok ? await response.json() : null;
4357
4393
  } catch {
4358
4394
  return null;
4359
4395
  }
4360
4396
  };
4397
+ const fetchMetadata = async (signal?: AbortSignal): Promise<Map<string, LmStudioNativeModelMetadata> | null> => {
4398
+ // Builds without the v1 listing answer 404 there and keep v0 metadata alone.
4399
+ const [v0, v1] = await Promise.all([fetchJson("/api/v0/models", signal), fetchJson("/api/v1/models", signal)]);
4400
+ const decisions = getLmStudioV1DecisionModels(v1);
4401
+ if ((!isRecord(v0) || !Array.isArray(v0.data)) && decisions.size === 0) {
4402
+ return null;
4403
+ }
4404
+ const metadata = new Map<string, LmStudioNativeModelMetadata>();
4405
+ for (const entry of isRecord(v0) && Array.isArray(v0.data) ? v0.data : []) {
4406
+ if (!isRecord(entry) || typeof entry.id !== "string" || entry.id.length === 0) {
4407
+ continue;
4408
+ }
4409
+ const contextWindow = getLmStudioNativeContextWindow(entry);
4410
+ metadata.set(entry.id, {
4411
+ input: getLmStudioNativeInput(entry),
4412
+ ...(contextWindow === undefined ? {} : { contextWindow }),
4413
+ ...(getLmStudioModelType(entry) === "decision" ? { decision: true as const } : {}),
4414
+ });
4415
+ }
4416
+ for (const [id, model] of decisions) {
4417
+ metadata.set(id, model);
4418
+ }
4419
+ return metadata;
4420
+ };
4361
4421
  if (options?.signal !== undefined) {
4362
4422
  return fetchMetadata(options.signal);
4363
4423
  }
@@ -4370,9 +4430,7 @@ export interface LmStudioModelManagerConfig {
4370
4430
  fetch?: FetchImpl;
4371
4431
  }
4372
4432
 
4373
- export function lmStudioModelManagerOptions(
4374
- config?: LmStudioModelManagerConfig,
4375
- ): ModelManagerOptions<"openai-completions"> {
4433
+ export function lmStudioModelManagerOptions(config?: LmStudioModelManagerConfig): ModelManagerOptions<Api> {
4376
4434
  const apiKey = config?.apiKey;
4377
4435
  const baseUrl = config?.baseUrl ?? Bun.env.LM_STUDIO_BASE_URL ?? "http://127.0.0.1:1234/v1";
4378
4436
  const references = createBundledReferenceMap<"openai-completions">("lm-studio" as any);
@@ -4400,13 +4458,17 @@ export function lmStudioModelManagerOptions(
4400
4458
  if (!nativeMetadata) {
4401
4459
  return models;
4402
4460
  }
4403
- return models.map(model => {
4461
+ return models.map((model): ModelSpec<Api> => {
4404
4462
  const metadata = nativeMetadata.get(model.id);
4405
4463
  if (!metadata) {
4406
4464
  return model;
4407
4465
  }
4408
4466
  return {
4409
4467
  ...model,
4468
+ // Decision models answer only on `/v1/decisions` (OpenAI's Decisions API).
4469
+ ...(metadata.decision
4470
+ ? { api: "openai-decisions", kind: "judge", reasoning: false, supportsTools: false }
4471
+ : {}),
4410
4472
  input: metadata.input,
4411
4473
  contextWindow: metadata.contextWindow ?? model.contextWindow,
4412
4474
  };
@@ -5532,7 +5594,7 @@ export function xiaomiModelManagerOptions(
5532
5594
  : XIAOMI_TOKEN_PLAN_FALLBACK_BASE_URLS;
5533
5595
  const XIAOMI_STANDARD_BASE_URL = "https://api.xiaomimimo.com/v1";
5534
5596
  const isTokenPlanProvider = config?.tokenPlanRegion !== undefined || providerId.startsWith("xiaomi-token-plan-");
5535
- const isTokenPlanKey = isTokenPlanProvider || apiKey?.startsWith("tp-");
5597
+ const isTokenPlanKey = isTokenPlanProvider || (apiKey !== undefined && isXiaomiTokenPlanKey(apiKey));
5536
5598
  // Token-plan keys always use a TP cluster; config?.baseUrl (from catalog)
5537
5599
  // would incorrectly pin to the standard endpoint (api.xiaomimimo.com).
5538
5600
  const baseUrl = isTokenPlanKey ? tokenPlanBaseUrls[0] : (config?.baseUrl ?? XIAOMI_STANDARD_BASE_URL);
@@ -5611,6 +5673,8 @@ type LiteLLMRichEndpointModel<TApi extends Api> = {
5611
5673
  hasToolMetadata: boolean;
5612
5674
  hasSupportedOpenAIParams: boolean;
5613
5675
  hasCost: boolean;
5676
+ /** Whether an endpoint reported a string `mode`, the only signal that selects a runner api. */
5677
+ hasMode: boolean;
5614
5678
  reportedCost: Partial<ModelSpec<Api>["cost"]>;
5615
5679
  };
5616
5680
  type LiteLLMRichEndpointFailure = {
@@ -5703,9 +5767,11 @@ function mapLiteLLMOpenAICompatibleModel(
5703
5767
  return null;
5704
5768
  }
5705
5769
  const model = mapWithBundledReference(entry, defaults, reference);
5770
+ const api = resolveLiteLLMApi(entry, model.id);
5706
5771
  return {
5707
5772
  ...model,
5708
- api: resolveLiteLLMApi(undefined, model.id),
5773
+ api,
5774
+ ...liteLLMRunnerKind(api),
5709
5775
  name: stripLiteLLMResellerUsageSuffix(model.name),
5710
5776
  };
5711
5777
  }
@@ -5839,14 +5905,28 @@ function classifyLiteLLMApiRoute(entry: LiteLLMRichModelEntry | undefined, id: s
5839
5905
  return isLikelyOpenAIResponsesModelId(modelId) ? "openai" : "unknown";
5840
5906
  }
5841
5907
 
5908
+ /**
5909
+ * Transport for a LiteLLM model group: `mode: "decisions"` answers only on the
5910
+ * proxy's `/v1/decisions` route, OpenAI-backed groups use Responses, and every
5911
+ * other group uses `fallbackApi`.
5912
+ */
5842
5913
  export function resolveLiteLLMApi(
5843
5914
  entry: Record<string, unknown> | undefined,
5844
5915
  id: string,
5845
5916
  fallbackApi: Api = "openai-completions",
5846
5917
  ): Api {
5918
+ if (entry && getLiteLLMMetadataValue(entry, "mode") === "decisions") {
5919
+ return "openai-decisions";
5920
+ }
5847
5921
  return classifyLiteLLMApiRoute(entry, id) === "openai" ? "openai-responses" : fallbackApi;
5848
5922
  }
5849
5923
 
5924
+ /** `kind` a LiteLLM row takes on `api`: runner apis (Decisions → judge) leave the chat roster; chat transports add nothing. */
5925
+ function liteLLMRunnerKind(api: Api): { kind?: ModelKind } {
5926
+ const kind = runnerApiKind(api);
5927
+ return kind ? { kind } : {};
5928
+ }
5929
+
5850
5930
  function isLiteLLMUnusableSentinelPlaceholder(entry: LiteLLMRichModelEntry): boolean {
5851
5931
  const modelGroup = toNonEmptyString(entry.model_group);
5852
5932
  const id = toNonEmptyString(entry.id);
@@ -5969,10 +6049,12 @@ function mapLiteLLMRichEntry<TApi extends Api>(
5969
6049
  // compat merge (issue #11982).
5970
6050
  ...(supportsVision === true ? { stripImageInput: false } : {}),
5971
6051
  };
6052
+ const api = options.resolveApi?.(entry, id) ?? options.api;
5972
6053
  return {
5973
6054
  id,
5974
6055
  name: toLiteLLMDisplayName(modelName, reference?.name, id),
5975
- api: options.resolveApi?.(entry, id) ?? options.api,
6056
+ api,
6057
+ ...liteLLMRunnerKind(api),
5976
6058
  provider: options.provider,
5977
6059
  baseUrl: runtimeBaseUrl,
5978
6060
  contextWindow,
@@ -6038,10 +6120,14 @@ function mergeLiteLLMRichEndpointModels<TApi extends Api>(
6038
6120
  : existing.apiRoute === "openai" || next.apiRoute === "openai"
6039
6121
  ? "openai"
6040
6122
  : "unknown";
6041
- const api = next.apiRoute === apiRoute ? next.model.api : existing.model.api;
6123
+ // Only a group's `mode` selects a runner api, and an endpoint omitting the
6124
+ // mode carries no news for it, so a runner api reported by either side wins.
6125
+ const runnerApi = [next.model.api, existing.model.api].find(api => runnerApiKind(api) !== undefined);
6126
+ const api = runnerApi ?? (next.apiRoute === apiRoute ? next.model.api : existing.model.api);
6042
6127
  const model: ModelSpec<TApi> = {
6043
6128
  ...existing.model,
6044
6129
  api,
6130
+ ...liteLLMRunnerKind(api),
6045
6131
  name: next.model.name === next.model.id ? existing.model.name : next.model.name,
6046
6132
  contextWindow: next.hasContextWindow ? next.model.contextWindow : existing.model.contextWindow,
6047
6133
  maxTokens: next.hasMaxTokens ? next.model.maxTokens : existing.model.maxTokens,
@@ -6066,6 +6152,7 @@ function mergeLiteLLMRichEndpointModels<TApi extends Api>(
6066
6152
  hasToolMetadata: existing.hasToolMetadata || next.hasToolMetadata,
6067
6153
  hasSupportedOpenAIParams: existing.hasSupportedOpenAIParams || next.hasSupportedOpenAIParams,
6068
6154
  hasCost: existing.hasCost || next.hasCost,
6155
+ hasMode: existing.hasMode || next.hasMode,
6069
6156
  };
6070
6157
  }
6071
6158
 
@@ -6143,6 +6230,7 @@ async function fetchLiteLLMRichEndpoint<TApi extends Api>(
6143
6230
  supportedOpenAIParams !== undefined,
6144
6231
  hasSupportedOpenAIParams: supportedOpenAIParams !== undefined,
6145
6232
  hasCost: getLiteLLMCost(entry) !== undefined,
6233
+ hasMode: typeof getLiteLLMMetadataValue(entry, "mode") === "string",
6146
6234
  reportedCost: getLiteLLMReportedCost(entry),
6147
6235
  };
6148
6236
  const existing = deduped.get(model.id);
@@ -6217,7 +6305,7 @@ async function fetchLiteLLMRichModelsInternal<TApi extends Api>(
6217
6305
  for (const entry of deduped.values()) {
6218
6306
  if (
6219
6307
  (entry.supportsVision !== true && entry.supportsVision !== false) ||
6220
- (options.resolveApi !== undefined && entry.apiRoute === "unknown") ||
6308
+ (options.resolveApi !== undefined && (entry.apiRoute === "unknown" || !entry.hasMode)) ||
6221
6309
  (Object.keys(entry.reportedCost).length > 0 &&
6222
6310
  (entry.reportedCost.input === undefined ||
6223
6311
  entry.reportedCost.output === undefined ||
@@ -6262,7 +6350,8 @@ export function litellmModelManagerOptions(config?: LiteLLMModelManagerConfig):
6262
6350
  const baseUrl = config?.baseUrl ?? getDefaultModelDiscoveryBaseUrl("litellm")!;
6263
6351
  return {
6264
6352
  providerId: "litellm",
6265
- // rich-v12 invalidates namespaced proxy ids that missed bare catalog
6353
+ // rich-v13 routes `mode: decisions` groups to the Decisions runner as judge
6354
+ // rows. rich-v12 invalidates namespaced proxy ids that missed bare catalog
6266
6355
  // references. rich-v11 excluded ClinePass gateway metadata (issue #10932).
6267
6356
  // rich-v10 filtered known non-conversational LiteLLM modes, keyed the
6268
6357
  // deployment's `supports_vision` declaration into cached compat, and
@@ -6854,7 +6943,7 @@ export function anthropicModelManagerOptions(
6854
6943
  api: "anthropic-messages",
6855
6944
  provider: "anthropic",
6856
6945
  baseUrl: discoveryBaseUrl,
6857
- headers: buildAnthropicDiscoveryHeaders(apiKey),
6946
+ headers: buildAnthropicDiscoveryHeaders(apiKey, discoveryBaseUrl),
6858
6947
  mapModel: (
6859
6948
  entry: OpenAICompatibleModelRecord,
6860
6949
  defaults: ModelSpec<"anthropic-messages">,
package/src/types.d.ts CHANGED
@@ -20,12 +20,12 @@ export declare const RUNNER_API_KINDS: Record<Exclude<(typeof RUNNER_APIS)[numbe
20
20
  /** Kind a runner API serves; `undefined` for chat transports and multi-kind `local-inference`. */
21
21
  export declare function runnerApiKind(api: Api): ModelKind | undefined;
22
22
  /** Catalog APIs `generate_image` runs through a pi-ai image client; the hosted Responses pair needs a carrier model. */
23
- export declare const IMAGE_GENERATION_APIS: readonly ["openai-images", "openrouter-images", "google-generative-ai", "google-gemini-cli", "openai-responses", "openai-codex-responses"];
23
+ export declare const IMAGE_GENERATION_APIS: readonly ["openai-images", "openrouter-images", "google-generative-ai", "google-gemini-cli", "openai-responses", "openai-codex-responses", "factory-droid-agent"];
24
24
  export type ImageGenerationApi = (typeof IMAGE_GENERATION_APIS)[number];
25
25
  /**
26
26
  * Kinds a model on `api` may declare: a runner api serves its own kind; a chat
27
27
  * transport serves `chat` and `tiny`, plus `image` when `generate_image` runs it
28
- * (hosted Responses image tool, Gemini image models). `undefined` for
28
+ * (hosted Responses image tool, Gemini and Factory Droid image models). `undefined` for
29
29
  * `local-inference`, which hosts several kinds chosen by the model itself.
30
30
  */
31
31
  export declare function servedKinds(api: Api): readonly ModelKind[] | undefined;
@@ -550,6 +550,8 @@ export interface AnthropicCompat {
550
550
  supportsEagerToolInputStreaming?: boolean;
551
551
  /** Whether long prompt-cache retention (`ttl: "1h"`) is supported. Default: true for canonical Anthropic API. */
552
552
  supportsLongCacheRetention?: boolean;
553
+ /** Whether a `ttl: "1h"` breakpoint on API-key requests adds the `extended-cache-ttl-2025-04-11` beta. Unset: true (Vertex rawPredict URLs never send it). */
554
+ extendedCacheTtlBeta?: boolean;
553
555
  /**
554
556
  * Whether mid-conversation `role: "system"` messages are accepted in the
555
557
  * `messages` array. When unset, auto-detected from model and deployment policy.
@@ -608,6 +610,21 @@ export interface AnthropicCompat {
608
610
  * Default: auto-detected from provider/baseUrl and `model.reasoning`.
609
611
  */
610
612
  replayUnsignedThinking?: boolean;
613
+ /**
614
+ * Whether a thinking-mode history must carry a `thinking` block on EVERY
615
+ * assistant turn of the current turn. DeepSeek's Anthropic endpoint rejects
616
+ * the whole request (`The content[].thinking in the thinking mode must be
617
+ * passed back to the API.`) when any assistant turn after the last user text
618
+ * lacks one, including turns another upstream in the same gateway model group
619
+ * produced without reasoning. Presence is all it validates (the block text may
620
+ * be a placeholder, the signature may be empty), and only `thinking` counts —
621
+ * `redacted_thinking` does not, and that endpoint rejects the block outright.
622
+ * A model group that may fail over to such an endpoint must set this: the
623
+ * stricter member defines the replay contract for the group.
624
+ * Default: false (official Anthropic and lax proxies tolerate a turn without
625
+ * thinking and the block is not invented for them).
626
+ */
627
+ requiresThinkingPresence?: boolean;
611
628
  /**
612
629
  * Whether the endpoint requires `thinking.type: "enabled"` whenever the
613
630
  * model reasons. Use for models that reject omitted or disabled thinking.
@@ -975,9 +992,11 @@ export interface ResolvedOpenAIResponsesCompat extends ResolvedOpenAISharedCompa
975
992
  */
976
993
  export type ResolvedOpenRouterCompat = ResolvedOpenAICompat & ResolvedOpenAIResponsesCompat;
977
994
  /** Fully-resolved anthropic-messages compat view (same contract as `ResolvedOpenAICompat`). */
978
- export type ResolvedAnthropicCompat = Required<Omit<AnthropicCompat, "streamIdleTimeoutMs" | "thinkingLoopGuard" | "bedrockMessagesApi" | "effortBeta" | "disabledThinking" | "betweenToolsEffort" | "stripThinkingHistory" | "fastMode" | "maxImageDimension" | "maxImagePayloadBytes">> & {
995
+ export type ResolvedAnthropicCompat = Required<Omit<AnthropicCompat, "streamIdleTimeoutMs" | "thinkingLoopGuard" | "bedrockMessagesApi" | "effortBeta" | "extendedCacheTtlBeta" | "disabledThinking" | "betweenToolsEffort" | "stripThinkingHistory" | "fastMode" | "maxImageDimension" | "maxImagePayloadBytes">> & {
979
996
  /** Effort-beta override; undefined keeps the transport's legacy heuristic. */
980
997
  effortBeta?: AnthropicCompat["effortBeta"];
998
+ /** Extended-cache-ttl beta opt-out; undefined sends it where a 1h breakpoint needs it. */
999
+ extendedCacheTtlBeta?: AnthropicCompat["extendedCacheTtlBeta"];
981
1000
  /** Disabled-thinking wire form; undefined keeps the direct-provider behavior. */
982
1001
  disabledThinking?: AnthropicCompat["disabledThinking"];
983
1002
  /** Effort pinned on `between_tools` turns; undefined leaves effort untouched. */
@@ -1204,6 +1223,13 @@ export interface ModelAccountAccess {
1204
1223
  * Absent when the backend reported no program metadata.
1205
1224
  */
1206
1225
  cyberPrograms?: readonly string[];
1226
+ /**
1227
+ * Antigravity request constants this account's `fetchAvailableModels`
1228
+ * roster advertised, keyed by upstream SKU id. Takes precedence over
1229
+ * {@link Model.antigravityWireProfiles}, which keeps only the first
1230
+ * account's values when multi-account rosters are unioned.
1231
+ */
1232
+ antigravityWireProfiles?: Readonly<Record<string, AntigravityModelWireProfile>>;
1207
1233
  }
1208
1234
  /** One Cursor `RequestedModel.parameters` entry recovered from rich discovery. */
1209
1235
  export interface CursorModelParameter {
@@ -1216,6 +1242,20 @@ export interface CursorModelRoute {
1216
1242
  parameters: readonly CursorModelParameter[];
1217
1243
  maxMode?: boolean;
1218
1244
  }
1245
+ /**
1246
+ * Antigravity Cloud Code Assist request constants for one upstream SKU, as the
1247
+ * native client sends them; see {@link Model.antigravityWireProfiles}.
1248
+ */
1249
+ export interface AntigravityModelWireProfile {
1250
+ /** Opaque `labels.model_enum` token (`fetchAvailableModels` `model`). */
1251
+ modelEnum?: string;
1252
+ /** Fixed `generationConfig.maxOutputTokens` the client always sends. */
1253
+ maxOutputTokens?: number;
1254
+ /** SKU thinking level; the native client sends it in preference to a budget. */
1255
+ thinkingLevel?: "LOW" | "MEDIUM" | "HIGH";
1256
+ /** SKU thinking budget (`-1` is dynamic), sent when no level is advertised. */
1257
+ thinkingBudget?: number;
1258
+ }
1219
1259
  export interface Model<TApi extends Api = Api> {
1220
1260
  id: string;
1221
1261
  /** Role-specific runner capability; omitted for ordinary chat models. */
@@ -1329,6 +1369,13 @@ export interface Model<TApi extends Api = Api> {
1329
1369
  * their single wire id) and on bundled snapshots that predate discovery.
1330
1370
  */
1331
1371
  cursorMaxModeRoutes?: Readonly<Record<string, boolean>>;
1372
+ /**
1373
+ * Per-wire-id Antigravity request constants recorded from the account's
1374
+ * `fetchAvailableModels` roster, keyed by upstream SKU id. A collapsed row
1375
+ * carries one entry per member it routes to; a raw row carries its own.
1376
+ * Absent on bundled snapshots that predate discovery.
1377
+ */
1378
+ antigravityWireProfiles?: Readonly<Record<string, AntigravityModelWireProfile>>;
1332
1379
  /**
1333
1380
  * Per-account availability recorded by multi-account discovery: provider
1334
1381
  * account key (Codex: ChatGPT `chatgpt_account_id`; Antigravity: login
@@ -1525,3 +1572,11 @@ export interface ModelSpec<TApi extends Api = Api> extends Omit<Model<TApi>, "co
1525
1572
  /** Sparse compatibility overrides; resolved into `Model.compat` by `buildModel`. */
1526
1573
  compat?: CompatConfigOf<TApi>;
1527
1574
  }
1575
+ /**
1576
+ * The model facts the catalog policy cascade reads: the resolve-target inputs
1577
+ * (`providerType ?? provider`, the request adapter, the wire model id, the
1578
+ * reasoning flag) plus the unverified-thinking correction applied before the
1579
+ * cascade. Callers holding a reduced model view — request adapters that only
1580
+ * need policy — supply exactly these instead of asserting a full `Model`.
1581
+ */
1582
+ export type CatalogPolicyInputs = Pick<ModelSpec<Api>, "provider" | "providerType" | "api" | "id" | "reasoning" | "requestModelId" | "thinking">;