@oh-my-pi/pi-catalog 18.2.7 → 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 (57) hide show
  1. package/CHANGELOG.md +26 -3
  2. package/README.md +18 -18
  3. package/dist/types/compat/auth-ids.d.ts +2 -2
  4. package/dist/types/compat/axes.d.ts +2 -2
  5. package/dist/types/compat/catalog-policy.d.ts +7 -0
  6. package/dist/types/compat/output-limits.d.ts +3 -0
  7. package/dist/types/compat/provider-ids.d.ts +1 -1
  8. package/dist/types/compat/tools.d.ts +5 -0
  9. package/dist/types/compat/types.d.ts +2 -2
  10. package/dist/types/provider-models/openai-compat.d.ts +26 -0
  11. package/dist/types/types.d.ts +5 -2
  12. package/dist/types/wire/singularityapi.d.ts +29 -0
  13. package/package.json +38 -38
  14. package/src/compat/auth-ids.ts +4 -0
  15. package/src/compat/axes.ts +21 -2
  16. package/src/compat/catalog-policy.ts +28 -0
  17. package/src/compat/output-limits.ts +12 -0
  18. package/src/compat/provider-ids.ts +2 -0
  19. package/src/compat/resolve.ts +4 -2
  20. package/src/compat/rules/README.md +34 -33
  21. package/src/compat/rules/auth/_order.kdl +1 -1
  22. package/src/compat/rules/auth/singularityapi-dev.kdl +22 -0
  23. package/src/compat/rules/auth/singularityapi-tech.kdl +23 -0
  24. package/src/compat/rules/classes/gpt-oss.kdl +3 -0
  25. package/src/compat/rules/classes/xai.kdl +3 -3
  26. package/src/compat/rules/providers/amazon-bedrock.kdl +1 -1
  27. package/src/compat/rules/providers/anthropic.kdl +1 -1
  28. package/src/compat/rules/providers/cloudflare-ai-gateway.kdl +1 -1
  29. package/src/compat/rules/providers/commandcode.kdl +1 -1
  30. package/src/compat/rules/providers/cursor.kdl +1 -1
  31. package/src/compat/rules/providers/google-antigravity.kdl +5 -0
  32. package/src/compat/rules/providers/kilo.kdl +1 -1
  33. package/src/compat/rules/providers/litellm.kdl +1 -1
  34. package/src/compat/rules/providers/native-tools.kdl +4 -0
  35. package/src/compat/rules/providers/openai.kdl +58 -0
  36. package/src/compat/rules/providers/opencode-zen.kdl +1 -1
  37. package/src/compat/rules/providers/openrouter.kdl +108 -0
  38. package/src/compat/rules/providers/output-limits.kdl +4 -0
  39. package/src/compat/rules/providers/singularityapi-dev.kdl +92 -0
  40. package/src/compat/rules/providers/singularityapi-tech.kdl +72 -0
  41. package/src/compat/rules/providers/tool-free-history.kdl +6 -0
  42. package/src/compat/rules/providers/vercel-ai-gateway.kdl +1 -1
  43. package/src/compat/rules/providers/xai-oauth.kdl +8 -1
  44. package/src/compat/rules/providers/xai.kdl +4 -4
  45. package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +23 -0
  46. package/src/compat/rules/providers/zenmux.kdl +1 -1
  47. package/src/compat/rules/runtime/behavior.kdl +2 -0
  48. package/src/compat/rules.json +1 -1
  49. package/src/compat/tools.ts +12 -0
  50. package/src/compat/types.ts +2 -2
  51. package/src/discovery/devin.ts +59 -34
  52. package/src/models.json +1 -1
  53. package/src/provider-models/cache-provider-id.ts +31 -0
  54. package/src/provider-models/descriptors.ts +4 -0
  55. package/src/provider-models/openai-compat.ts +390 -119
  56. package/src/types.ts +19 -1
  57. 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
+ }
@@ -5,7 +5,7 @@
5
5
  * `behavior.ts`, `resolve.ts`) exposes to consumers.
6
6
  */
7
7
  import type { Effort } from "../effort";
8
- import type { Api, ThinkingControlMode, TokenCost } from "../types";
8
+ import type { Api, KindApiKind, ThinkingControlMode, TokenCost } from "../types";
9
9
  import type { RevisionOp } from "./revision";
10
10
 
11
11
  /** Class-membership matcher kinds, most to least specific. */
@@ -648,7 +648,7 @@ export interface CompiledProvider {
648
648
  /** Present only for providers enrolled in `generate-models.ts` discovery. */
649
649
  discovery?: CompiledProviderDiscovery;
650
650
  /** Non-chat model kinds mapped to their runtime transport APIs. */
651
- kindApis?: Partial<Record<"image" | "tts" | "stt", Api>>;
651
+ kindApis?: Partial<Record<KindApiKind, Api>>;
652
652
  /** Authored bundled rows, when the provider cannot be discovered at generation time. */
653
653
  seed?: CompiledSeed;
654
654
  }
@@ -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,52 +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
- const body = toBinary(GetCliModelConfigsRequestSchema, request);
335
-
336
- const headers: Record<string, string> = {
337
- "content-type": "application/proto",
338
- "connect-protocol-version": "1",
339
- accept: "*/*",
340
- };
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;
341
346
 
342
- const fetchImpl = discoveryFetch(options.fetch);
343
- const response = await fetchImpl(requestUrl, { method: "POST", headers, body, signal });
344
- 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 {
345
353
  return null;
346
354
  }
355
+ };
347
356
 
348
- const decoded = decodeDevinUnaryMessage(
349
- GetCliModelConfigsResponseSchema,
350
- new Uint8Array(await response.arrayBuffer()),
351
- );
352
- if (!decoded) {
353
- 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;
354
369
  }
355
- const models = normalizeDevinModels(decoded.clientModelConfigs, options.baseUrl);
356
- if (models.length === 0) {
357
- // The backend gates the native catalog on the pinned CLI identity; an
358
- // empty-but-200 response is the failure signature of a stale version
359
- // pin (there is no explicit error). Treat it as failed discovery so
360
- // the static seed survives, and leave a trail for diagnosis. Apply
361
- // this after filtering because a response containing only disabled or
362
- // internal configs is equally unusable.
363
- 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", {
364
391
  metadata: devinDiscoveryMetadata(undefined),
365
392
  });
366
393
  return null;
367
394
  }
368
395
 
369
396
  return models;
370
- } catch {
371
- return null;
372
397
  } finally {
373
398
  clearTimeout(timer);
374
399
  }