@oh-my-pi/pi-catalog 15.10.11

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 (90) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/types/build.d.ts +3 -0
  3. package/dist/types/compat/anthropic.d.ts +11 -0
  4. package/dist/types/compat/apply.d.ts +7 -0
  5. package/dist/types/compat/openai.d.ts +21 -0
  6. package/dist/types/discovery/antigravity.d.ts +61 -0
  7. package/dist/types/discovery/codex.d.ts +38 -0
  8. package/dist/types/discovery/cursor-gen/agent_pb.d.ts +13022 -0
  9. package/dist/types/discovery/cursor.d.ts +23 -0
  10. package/dist/types/discovery/gemini.d.ts +25 -0
  11. package/dist/types/discovery/index.d.ts +4 -0
  12. package/dist/types/discovery/openai-compatible.d.ts +72 -0
  13. package/dist/types/effort.d.ts +9 -0
  14. package/dist/types/fireworks-model-id.d.ts +10 -0
  15. package/dist/types/hosts.d.ts +128 -0
  16. package/dist/types/identity/bundled.d.ts +6 -0
  17. package/dist/types/identity/classify.d.ts +45 -0
  18. package/dist/types/identity/equivalence.d.ts +46 -0
  19. package/dist/types/identity/family.d.ts +45 -0
  20. package/dist/types/identity/id.d.ts +12 -0
  21. package/dist/types/identity/index.d.ts +9 -0
  22. package/dist/types/identity/markers.d.ts +4 -0
  23. package/dist/types/identity/priority.d.ts +1 -0
  24. package/dist/types/identity/reference.d.ts +22 -0
  25. package/dist/types/identity/selection.d.ts +20 -0
  26. package/dist/types/index.d.ts +15 -0
  27. package/dist/types/model-cache.d.ts +17 -0
  28. package/dist/types/model-manager.d.ts +64 -0
  29. package/dist/types/model-thinking.d.ts +67 -0
  30. package/dist/types/models.d.ts +12 -0
  31. package/dist/types/provider-models/bundled-references.d.ts +11 -0
  32. package/dist/types/provider-models/descriptor-types.d.ts +74 -0
  33. package/dist/types/provider-models/descriptors.d.ts +384 -0
  34. package/dist/types/provider-models/discovery-constants.d.ts +11 -0
  35. package/dist/types/provider-models/google.d.ts +27 -0
  36. package/dist/types/provider-models/index.d.ts +6 -0
  37. package/dist/types/provider-models/ollama.d.ts +9 -0
  38. package/dist/types/provider-models/openai-compat.d.ts +385 -0
  39. package/dist/types/provider-models/special.d.ts +16 -0
  40. package/dist/types/types.d.ts +405 -0
  41. package/dist/types/utils.d.ts +5 -0
  42. package/dist/types/wire/codex.d.ts +26 -0
  43. package/dist/types/wire/gemini-headers.d.ts +18 -0
  44. package/dist/types/wire/github-copilot.d.ts +18 -0
  45. package/package.json +100 -0
  46. package/src/build.ts +40 -0
  47. package/src/compat/anthropic.ts +67 -0
  48. package/src/compat/apply.ts +15 -0
  49. package/src/compat/openai.ts +365 -0
  50. package/src/discovery/antigravity.ts +261 -0
  51. package/src/discovery/codex.ts +371 -0
  52. package/src/discovery/cursor-gen/agent_pb.ts +15274 -0
  53. package/src/discovery/cursor.ts +307 -0
  54. package/src/discovery/gemini.ts +249 -0
  55. package/src/discovery/index.ts +4 -0
  56. package/src/discovery/openai-compatible.ts +224 -0
  57. package/src/effort.ts +16 -0
  58. package/src/fireworks-model-id.ts +30 -0
  59. package/src/hosts.ts +114 -0
  60. package/src/identity/bundled.ts +38 -0
  61. package/src/identity/classify.ts +141 -0
  62. package/src/identity/equivalence.ts +870 -0
  63. package/src/identity/family.ts +88 -0
  64. package/src/identity/id.ts +81 -0
  65. package/src/identity/index.ts +9 -0
  66. package/src/identity/markers.ts +49 -0
  67. package/src/identity/priority.ts +56 -0
  68. package/src/identity/reference.ts +134 -0
  69. package/src/identity/selection.ts +65 -0
  70. package/src/index.ts +15 -0
  71. package/src/model-cache.ts +132 -0
  72. package/src/model-manager.ts +472 -0
  73. package/src/model-thinking.ts +407 -0
  74. package/src/models.json +75308 -0
  75. package/src/models.json.d.ts +9 -0
  76. package/src/models.ts +64 -0
  77. package/src/provider-models/bundled-references.ts +54 -0
  78. package/src/provider-models/descriptor-types.ts +79 -0
  79. package/src/provider-models/descriptors.ts +456 -0
  80. package/src/provider-models/discovery-constants.ts +11 -0
  81. package/src/provider-models/google.ts +105 -0
  82. package/src/provider-models/index.ts +6 -0
  83. package/src/provider-models/ollama.ts +154 -0
  84. package/src/provider-models/openai-compat.ts +3106 -0
  85. package/src/provider-models/special.ts +67 -0
  86. package/src/types.ts +470 -0
  87. package/src/utils.ts +27 -0
  88. package/src/wire/codex.ts +43 -0
  89. package/src/wire/gemini-headers.ts +41 -0
  90. package/src/wire/github-copilot.ts +72 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [15.10.11] - 2026-06-10
6
+
7
+ ### Added
8
+
9
+ - Added `hostMatchesUrl`, `modelMatchesHost`, and endpoint-shape helpers in the new `hosts` module for consistent provider/baseUrl matching
10
+ - `buildModel(spec)` (`build.ts`) is now the single Model constructor: it materializes the fully-resolved compat record and canonical thinking metadata exactly once (compat first, thinking derived from identity + resolved compat), so `Model.compat` is a required, complete `CompatOf<TApi>` (`ResolvedOpenAICompat`/`ResolvedOpenAIResponsesCompat`/`ResolvedAnthropicCompat`) and request-path code reads fields with zero URL parsing and zero per-request allocation. Sparse user/config overrides live on the new `ModelSpec<TApi>` input shape and survive on `Model.compatConfig` for introspection.
11
+ - Added `ResolvedAnthropicCompat.supportsSamplingParams` (Opus 4.7+/Fable/Mythos reject `temperature`/`top_p`/`top_k` with a 400), baked at build time from model identity so the request path stops re-parsing model ids.
12
+ - Compat detection gained model-time flags so handlers stop sniffing baseUrl: completions `supportsReasoningParams`, `alwaysSendMaxTokens`, `isOpenRouterHost`, `isVercelGatewayHost`, `streamIdleTimeoutMs`, and a precomputed `whenThinking` alternate view (OpenCode `reasoning_content` gating, #1071/#1484); responses `strictResponsesPairing`, `supportsLongPromptCacheRetention`, `supportsReasoningEffort`; anthropic `officialEndpoint`, `requiresToolResultId`, `replayUnsignedThinking`.
13
+ - New `@oh-my-pi/pi-catalog` package: the model catalog extracted from `@oh-my-pi/pi-ai`. Owns the bundled `models.json` and its generation pipeline (`scripts/generate-models.ts`), the core model data types (`Model`, `Api`, `ThinkingConfig`, `Effort`, `Usage`, compat interfaces), thinking metadata enrichment and generated policies (`model-thinking.ts`), the SQLite model cache and model manager, per-provider discovery factories (`provider-models/`), the discovery protocol clients (`discovery/`), and the new `CATALOG_PROVIDERS` table — the single source of truth for provider ids, default models, and discovery wiring (`KnownProvider`, `PROVIDER_DESCRIPTORS`, and `DEFAULT_MODEL_PER_PROVIDER` are derived from it).
14
+ - New `identity/` module centralizing model-identity concerns that were previously duplicated across packages: family classification and version parsing (`identity/classify.ts`, extracted from pi-ai's `model-thinking` internals), canonical model equivalence with injected reference data (`identity/equivalence.ts`, from coding-agent's `model-equivalence`), proxy/reseller reference lookup (`identity/reference.ts`, from coding-agent's `model-registry`), bracket-affix and id-segment helpers (`identity/id.ts`), a single trailing-marker vocabulary with canonical vs reference flavors (`identity/markers.ts` — `search` stays reference-only so Perplexity's `sonar-pro-search` remains canonical-distinct), and provider priority ordering (`identity/priority.ts`).
15
+ - Memoized bundled-reference accessors (`getBundledCanonicalReferenceData` / `getBundledModelReferenceIndex` in `identity/bundled.ts`): one lazy walk of the bundled catalog feeds both canonical equivalence and proxy-reference lookup, so consumers no longer hand-roll the glue.
16
+ - `identity/selection.ts`: pure canonical-variant selection (`resolveCanonicalVariant`, `buildCanonicalModelOrder`, `CanonicalVariantPreferences`) extracted from the coding-agent registry — provider rank, then exact-id match, variant source, id length, and candidate order.
17
+
18
+ ### Changed
19
+
20
+ - Changed OpenAI compatibility detection to use shared host classifiers (`modelMatchesHost`/`hostMatchesUrl`) with normalized matching instead of raw URL substring checks
21
+ - Changed `hostMatchesUrl`/`modelMatchesHost` usage in compatibility detection to reduce mismatches across case variants and provider alias hosts
22
+ - Provider catalog entries now carry the runtime API-key env fallback as an ordered `envVars` list; `catalogDiscovery.envVars` became an optional generation-time override (only `cursor` and `vercel-ai-gateway` differ) and `PROVIDER_DESCRIPTORS` materializes the resolved list for `generate-models.ts`.
23
+ - `Model`'s api parameter now defaults to `Api` instead of `any` (`Model<TApi extends Api = Api>`), so bare `Model` no longer behaves as `Model<any>` at call sites.
24
+ - `ThinkingConfig` is now explicit and total: an ordered `efforts` array replaces the `minLevel`/`maxLevel`/`levels` range encoding, and the wire facts are baked alongside it — `effortMap` (anthropic-adaptive 4-tier vs 5-tier scale, shared with the OpenRouter completions remap) and `supportsDisplay` (adaptive `display` field support). Explicit spec thinking owns the capability surface (`mode`/`efforts`/`defaultLevel`) and wins over inference; missing wire facts are backfilled from identity so configs never need to know Anthropic's tier tables. Reasoning models that reject the wire effort param (`compat.supportsReasoningEffort: false` on openai-responses*) are encoded as `thinking: undefined` ("thinks, no control surface") instead of the removed `modelOmitsReasoningEffort` special case. `models.json` was re-baked in the new vocabulary behind a 3196-model behavioral parity gate, and the model cache schema bumped to v4 to invalidate old-shape rows.
25
+ - `mapEffortToGoogleThinkingLevel(effort)` is now a static map (model parameter dropped — validation stays at the `requireSupportedEffort` call sites), and `mapEffortToAnthropicAdaptiveEffort` reads the baked `thinking.effortMap` instead of re-classifying the model id per request.
26
+ - Generator-only policy code moved out of the runtime bundle into `scripts/generated-policies.ts`: `applyGeneratedModelPolicies` (now policy fixups + thinking re-bake via the shared deriver), `linkOpenAIPromotionTargets`, the Copilot context-window table, minimax/opencode-go compat fixups, and `CLOUDFLARE_FALLBACK_MODEL`. The anthropic id predicates (`hasOpus47ApiRestrictions`, `supportsMidConversationSystemMessages`, `isAnthropicFableOrMythosModel`) moved to `identity/family` for build-time use by the compat/thinking derivers only.
27
+
28
+ ### Fixed
29
+
30
+ - Fixed Anthropic official-endpoint detection to require strict HTTPS hostname matching so non-official or lookalike URLs are no longer treated as official Anthropic hosts
31
+ - Fixed Ollama Cloud dynamic discovery so same-id matches from other providers no longer supply context-window or max-output-token limits for discovered models.
32
+ - Wired `@oh-my-pi/pi-catalog` into the release publish package list, tarball install smoke test, and root `bun generate-models` script.
33
+ - Fixed `supportsAdaptiveThinkingDisplay` only matching dash-form version ids: dotted ids (`claude-opus-4.7`) now classify through `identity/classify` like every other anthropic predicate, so six bundled dotted Opus 4.7/4.8 entries (github-copilot, vercel-ai-gateway, zenmux) regain adaptive `display` support; bare dated ids (`claude-opus-4-20250514` = Opus 4.0) stay excluded.
34
+ - Fixed the OpenRouter anthropic adaptive-effort map misclassifying bare dated Opus ids (`claude-opus-4-20250514` parsed as version 4.20 → wrongly adaptive); the map now derives from the shared classifier and the shared 4-/5-tier tables.
35
+
36
+ ### Removed
37
+
38
+ - Removed the runtime enrichment layer: `enrichModelThinking` (and its non-enumerable memo-slot cache), `refreshModelThinking`, `modelOmitsReasoningEffort`, and the `model-thinking` re-exports of generator-only policies. Thinking metadata is resolved exactly once inside `buildModel`; runtime helpers (`getSupportedEfforts`, `clampThinkingLevelForModel`, `requireSupportedEffort`, the effort mappers) are pure field reads.
@@ -0,0 +1,3 @@
1
+ import type { Api, CompatOf, Model, ModelSpec } from "./types";
2
+ export declare function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi>;
3
+ export declare function buildCompat(spec: ModelSpec<Api>): CompatOf<Api>;
@@ -0,0 +1,11 @@
1
+ import type { ModelSpec, ResolvedAnthropicCompat } from "../types";
2
+ /**
3
+ * Official first-party Anthropic API. A missing baseUrl is official on purpose:
4
+ * request dispatch falls back to `https://api.anthropic.com`. This is the one
5
+ * auth-sensitive host check — OAuth credentials are attached based on it — so
6
+ * it requires the exact origin or a path boundary (`/`) after it; a bare
7
+ * prefix check would accept lookalikes like `https://api.anthropic.com.evil.com`.
8
+ */
9
+ export declare function isOfficialAnthropicApiUrl(baseUrl?: string): boolean;
10
+ /** Build the resolved anthropic-messages compat record for a model spec. */
11
+ export declare function buildAnthropicCompat(spec: ModelSpec<"anthropic-messages">): ResolvedAnthropicCompat;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Assign defined override values onto a freshly-built resolved compat record,
3
+ * in place. Keys the record doesn't declare are ignored (loosely-typed config
4
+ * may carry junk). `buildModel` is the only intended caller — the record being
5
+ * mutated is the single per-model allocation; nothing here runs per request.
6
+ */
7
+ export declare function applyCompatOverrides(compat: object, overrides: object | undefined): void;
@@ -0,0 +1,21 @@
1
+ import type { ModelSpec, OpenAICompat, ResolvedOpenAICompat, ResolvedOpenAIResponsesCompat } from "../types";
2
+ /**
3
+ * Build the resolved chat-completions compat record for a model spec.
4
+ * Provider takes precedence over URL-based detection since it's explicitly configured.
5
+ */
6
+ export declare function buildOpenAICompat(spec: ModelSpec<"openai-completions">): ResolvedOpenAICompat;
7
+ interface OpenAIResponsesSpecLike {
8
+ provider: string;
9
+ baseUrl: string;
10
+ compat?: OpenAICompat;
11
+ }
12
+ /**
13
+ * Build the resolved Responses-API compat record. The Responses flavor
14
+ * deliberately differs from chat-completions: GitHub Copilot's responses
15
+ * endpoint accepts the `developer` role, while strict tool mode is scoped to
16
+ * first-party OpenAI/Azure/Copilot providers. Developer-role and prompt-cache
17
+ * detection are URL-only on purpose — the historical call sites never
18
+ * consulted the provider id for them.
19
+ */
20
+ export declare function buildOpenAIResponsesCompat(spec: OpenAIResponsesSpecLike): ResolvedOpenAIResponsesCompat;
21
+ export {};
@@ -0,0 +1,61 @@
1
+ import type { ModelSpec } from "../types";
2
+ /**
3
+ * Raw model metadata returned by Antigravity's `fetchAvailableModels` endpoint.
4
+ */
5
+ export interface AntigravityDiscoveryApiModel {
6
+ displayName?: string;
7
+ supportsImages?: boolean;
8
+ supportsThinking?: boolean;
9
+ thinkingBudget?: number;
10
+ recommended?: boolean;
11
+ maxTokens?: number;
12
+ maxOutputTokens?: number;
13
+ model?: string;
14
+ apiProvider?: string;
15
+ modelProvider?: string;
16
+ isInternal?: boolean;
17
+ supportsVideo?: boolean;
18
+ }
19
+ /**
20
+ * Grouping metadata used by Antigravity to surface recommended model ids.
21
+ */
22
+ export interface AntigravityDiscoveryAgentModelGroup {
23
+ modelIds?: string[];
24
+ }
25
+ /**
26
+ * Sort/group metadata used by Antigravity to surface recommended model ids.
27
+ */
28
+ export interface AntigravityDiscoveryAgentModelSort {
29
+ groups?: AntigravityDiscoveryAgentModelGroup[];
30
+ }
31
+ /**
32
+ * Response payload returned by Antigravity's `fetchAvailableModels` endpoint.
33
+ */
34
+ export interface AntigravityDiscoveryApiResponse {
35
+ models?: Record<string, AntigravityDiscoveryApiModel>;
36
+ agentModelSorts?: AntigravityDiscoveryAgentModelSort[];
37
+ }
38
+ /**
39
+ * Options for fetching Antigravity discovery models.
40
+ */
41
+ export interface FetchAntigravityDiscoveryModelsOptions {
42
+ /** OAuth access token used as `Authorization: Bearer <token>`. */
43
+ token: string;
44
+ /** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
45
+ endpoint?: string;
46
+ /** Deprecated and ignored for antigravity discovery parity. */
47
+ project?: string;
48
+ /** Optional user agent override. */
49
+ userAgent?: string;
50
+ /** Optional abort signal for request cancellation. */
51
+ signal?: AbortSignal;
52
+ /** Optional fetch implementation override for tests. */
53
+ fetcher?: typeof fetch;
54
+ }
55
+ /**
56
+ * Fetches discoverable Antigravity models and normalizes them into canonical model entries.
57
+ *
58
+ * Returns `null` on network/payload/auth failures.
59
+ * Returns `[]` only when the endpoint responds successfully with no usable models.
60
+ */
61
+ export declare function fetchAntigravityDiscoveryModels(options: FetchAntigravityDiscoveryModelsOptions): Promise<ModelSpec<"google-gemini-cli">[] | null>;
@@ -0,0 +1,38 @@
1
+ import type { ModelSpec } from "../types";
2
+ /**
3
+ * Fetch options for OpenAI Codex model discovery.
4
+ */
5
+ export interface CodexModelDiscoveryOptions {
6
+ /** OAuth access token used for `Authorization: Bearer ...`. */
7
+ accessToken: string;
8
+ /** ChatGPT account id value used for `chatgpt-account-id` header. */
9
+ accountId?: string;
10
+ /** Base URL for Codex backend. Defaults to `https://chatgpt.com/backend-api`. */
11
+ baseUrl?: string;
12
+ /** Optional client version attached as `client_version` query parameter. */
13
+ clientVersion?: string;
14
+ /** Optional endpoint path candidates. Defaults to `/codex/models`, then `/models`. */
15
+ paths?: readonly string[];
16
+ /** Additional headers merged on top of required Codex headers. */
17
+ headers?: Record<string, string>;
18
+ /** Abort signal for network request cancellation. */
19
+ signal?: AbortSignal;
20
+ /** Optional fetch implementation override for tests. */
21
+ fetchFn?: typeof fetch;
22
+ /** Optional registry fetch implementation override for client version lookup. */
23
+ registryFetchFn?: typeof fetch;
24
+ }
25
+ /**
26
+ * Normalized Codex discovery response.
27
+ */
28
+ export interface CodexModelDiscoveryResult {
29
+ models: ModelSpec<"openai-codex-responses">[];
30
+ etag?: string;
31
+ }
32
+ /**
33
+ * Fetches model metadata from Codex backend and normalizes it for pi model management.
34
+ *
35
+ * Returns `null` when no supported model-list route can be fetched/parsed.
36
+ * Returns `{ models: [] }` when a route succeeds but yields no usable models.
37
+ */
38
+ export declare function fetchCodexModels(options: CodexModelDiscoveryOptions): Promise<CodexModelDiscoveryResult | null>;