@oh-my-pi/pi-catalog 18.2.8 → 18.2.9

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 (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/types/compat/auth-ids.d.ts +2 -2
  3. package/dist/types/compat/axes.d.ts +2 -2
  4. package/dist/types/compat/catalog-policy.d.ts +7 -0
  5. package/dist/types/compat/output-limits.d.ts +3 -0
  6. package/dist/types/compat/provider-ids.d.ts +1 -1
  7. package/dist/types/compat/tools.d.ts +5 -0
  8. package/dist/types/provider-models/openai-compat.d.ts +26 -0
  9. package/dist/types/wire/singularityapi.d.ts +29 -0
  10. package/package.json +4 -4
  11. package/src/compat/auth-ids.ts +4 -0
  12. package/src/compat/axes.ts +21 -2
  13. package/src/compat/catalog-policy.ts +28 -0
  14. package/src/compat/output-limits.ts +12 -0
  15. package/src/compat/provider-ids.ts +2 -0
  16. package/src/compat/resolve.ts +4 -2
  17. package/src/compat/rules/README.md +10 -10
  18. package/src/compat/rules/auth/_order.kdl +1 -1
  19. package/src/compat/rules/auth/singularityapi-dev.kdl +22 -0
  20. package/src/compat/rules/auth/singularityapi-tech.kdl +23 -0
  21. package/src/compat/rules/classes/gpt-oss.kdl +3 -0
  22. package/src/compat/rules/classes/xai.kdl +3 -3
  23. package/src/compat/rules/providers/amazon-bedrock.kdl +1 -1
  24. package/src/compat/rules/providers/anthropic.kdl +1 -1
  25. package/src/compat/rules/providers/cloudflare-ai-gateway.kdl +1 -1
  26. package/src/compat/rules/providers/commandcode.kdl +1 -1
  27. package/src/compat/rules/providers/cursor.kdl +1 -1
  28. package/src/compat/rules/providers/google-antigravity.kdl +5 -0
  29. package/src/compat/rules/providers/kilo.kdl +1 -1
  30. package/src/compat/rules/providers/litellm.kdl +1 -1
  31. package/src/compat/rules/providers/native-tools.kdl +4 -0
  32. package/src/compat/rules/providers/opencode-zen.kdl +1 -1
  33. package/src/compat/rules/providers/output-limits.kdl +4 -0
  34. package/src/compat/rules/providers/singularityapi-dev.kdl +92 -0
  35. package/src/compat/rules/providers/singularityapi-tech.kdl +72 -0
  36. package/src/compat/rules/providers/tool-free-history.kdl +6 -0
  37. package/src/compat/rules/providers/vercel-ai-gateway.kdl +1 -1
  38. package/src/compat/rules/providers/xai-oauth.kdl +8 -1
  39. package/src/compat/rules/providers/xai.kdl +4 -4
  40. package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +23 -0
  41. package/src/compat/rules/providers/zenmux.kdl +1 -1
  42. package/src/compat/rules/runtime/behavior.kdl +2 -0
  43. package/src/compat/rules.json +1 -12526
  44. package/src/compat/tools.ts +12 -0
  45. package/src/discovery/devin.ts +59 -36
  46. package/src/models.json +1 -1
  47. package/src/provider-models/cache-provider-id.ts +31 -0
  48. package/src/provider-models/descriptors.ts +4 -0
  49. package/src/provider-models/openai-compat.ts +159 -0
  50. package/src/wire/singularityapi.ts +34 -0
@@ -0,0 +1,12 @@
1
+ import type { Model } from "../types";
2
+ import { resolveCatalogPolicy } from "./catalog-policy";
3
+
4
+ /** Whether the transport exposes native tools that an empty caller catalog cannot disable. */
5
+ export function requiresNativeTools(model: Model): boolean {
6
+ return resolveCatalogPolicy(model).requiresNativeTools === true;
7
+ }
8
+
9
+ /** Whether disabling tools requires a history without prior tool calls or results. */
10
+ export function requiresToolFreeHistoryForToolOptOut(model: Model): boolean {
11
+ return resolveCatalogPolicy(model).requiresToolFreeHistoryForToolOptOut === true;
12
+ }
@@ -10,6 +10,7 @@ import {
10
10
  DisplayOption,
11
11
  GetCliModelConfigsRequestSchema,
12
12
  GetCliModelConfigsResponseSchema,
13
+ type Metadata,
13
14
  MetadataSchema,
14
15
  ModelDimensionKind,
15
16
  } from "./devin-proto";
@@ -323,54 +324,76 @@ export async function fetchDevinModels(
323
324
  const controller = new AbortController();
324
325
  const timer = setTimeout(() => controller.abort(), timeoutMs);
325
326
  const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
327
+ const fetchImpl = discoveryFetch(options.fetch);
326
328
 
327
- try {
328
- const request = create(GetCliModelConfigsRequestSchema, {
329
- metadata: create(MetadataSchema, {
330
- ...devinDiscoveryMetadata(options.apiKey),
331
- supportedModelDisplays: [...DEVIN_SUPPORTED_MODEL_DISPLAYS],
332
- }),
333
- });
334
- // `toBinary` always allocates a fresh ArrayBuffer-backed view; the DOM
335
- // `BodyInit` typing just cannot see that through its ArrayBufferLike signature.
336
- const body = toBinary(GetCliModelConfigsRequestSchema, request) as Uint8Array<ArrayBuffer>;
337
-
338
- const headers: Record<string, string> = {
339
- "content-type": "application/proto",
340
- "connect-protocol-version": "1",
341
- accept: "*/*",
342
- };
329
+ const fetchCatalog = async (metadata: Metadata): Promise<ModelSpec<"devin-agent">[] | null> => {
330
+ try {
331
+ const request = create(GetCliModelConfigsRequestSchema, { metadata });
332
+ // `toBinary` always allocates a fresh ArrayBuffer-backed view; the DOM
333
+ // `BodyInit` typing just cannot see that through its ArrayBufferLike signature.
334
+ const body = toBinary(GetCliModelConfigsRequestSchema, request) as Uint8Array<ArrayBuffer>;
335
+ const response = await fetchImpl(requestUrl, {
336
+ method: "POST",
337
+ headers: {
338
+ "content-type": "application/proto",
339
+ "connect-protocol-version": "1",
340
+ accept: "*/*",
341
+ },
342
+ body,
343
+ signal,
344
+ });
345
+ if (!response.ok) return null;
343
346
 
344
- const fetchImpl = discoveryFetch(options.fetch);
345
- const response = await fetchImpl(requestUrl, { method: "POST", headers, body, signal });
346
- if (!response.ok) {
347
+ const decoded = decodeDevinUnaryMessage(
348
+ GetCliModelConfigsResponseSchema,
349
+ new Uint8Array(await response.arrayBuffer()),
350
+ );
351
+ return decoded ? normalizeDevinModels(decoded.clientModelConfigs, options.baseUrl) : null;
352
+ } catch {
347
353
  return null;
348
354
  }
355
+ };
349
356
 
350
- const decoded = decodeDevinUnaryMessage(
351
- GetCliModelConfigsResponseSchema,
352
- new Uint8Array(await response.arrayBuffer()),
353
- );
354
- if (!decoded) {
355
- return null;
357
+ try {
358
+ const nativeMetadata = create(MetadataSchema, {
359
+ ...devinDiscoveryMetadata(options.apiKey),
360
+ supportedModelDisplays: [...DEVIN_SUPPORTED_MODEL_DISPLAYS],
361
+ });
362
+ const nativeModels = await fetchCatalog(nativeMetadata);
363
+ const nativeIsSeedOnly =
364
+ nativeModels !== null &&
365
+ nativeModels.length > 0 &&
366
+ nativeModels.every(model => model.id === "swe-1-6" || model.id === "swe-1-6-fast");
367
+ if (nativeModels !== null && nativeModels.length > 0 && !nativeIsSeedOnly) {
368
+ return nativeModels;
356
369
  }
357
- const models = normalizeDevinModels(decoded.clientModelConfigs, options.baseUrl);
358
- if (models.length === 0) {
359
- // The backend gates the native catalog on the pinned CLI identity; an
360
- // empty-but-200 response is the failure signature of a stale version
361
- // pin (there is no explicit error). Treat it as failed discovery so
362
- // the static seed survives, and leave a trail for diagnosis. Apply
363
- // this after filtering because a response containing only disabled or
364
- // internal configs is equally unusable.
365
- logger.warn("Devin returned an empty native model catalog; the pinned CLI identity may be stale", {
370
+
371
+ // Legacy Windsurf Enterprise seats expose their full credential-scoped
372
+ // roster only to the editor identity and raw windsurf_api_key. Native
373
+ // chisel discovery returns the two-row fallback seed for those seats.
374
+ const legacyMetadata = create(MetadataSchema, {
375
+ apiKey: options.apiKey ?? "",
376
+ ideName: "windsurf",
377
+ ideVersion: "3.2.23",
378
+ extensionName: "windsurf",
379
+ extensionVersion: "1.48.2",
380
+ locale: "en",
381
+ });
382
+ const legacyModels = await fetchCatalog(legacyMetadata);
383
+ const models =
384
+ legacyModels !== null && (nativeModels === null || legacyModels.length > nativeModels.length)
385
+ ? legacyModels
386
+ : nativeModels;
387
+ if (models === null || models.length === 0) {
388
+ // The backend gates the native catalog on the pinned client identity;
389
+ // an empty-but-200 response is the failure signature of a stale pin.
390
+ logger.warn("Devin returned an empty model catalog; the pinned client identities may be stale", {
366
391
  metadata: devinDiscoveryMetadata(undefined),
367
392
  });
368
393
  return null;
369
394
  }
370
395
 
371
396
  return models;
372
- } catch {
373
- return null;
374
397
  } finally {
375
398
  clearTimeout(timer);
376
399
  }