@oh-my-pi/pi-catalog 16.0.5 → 16.0.7
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 +26 -0
- package/dist/types/compat/openai.d.ts +3 -1
- package/dist/types/identity/family.d.ts +6 -0
- package/dist/types/model-thinking.d.ts +1 -1
- package/dist/types/provider-models/descriptors.d.ts +1 -1
- package/dist/types/provider-models/openai-compat.d.ts +5 -6
- package/dist/types/types.d.ts +94 -17
- package/package.json +4 -3
- package/src/build.ts +3 -1
- package/src/compat/openai.ts +206 -19
- package/src/discovery/antigravity.ts +76 -92
- package/src/discovery/codex.ts +33 -40
- package/src/discovery/cursor.ts +31 -24
- package/src/discovery/gemini.ts +39 -30
- package/src/discovery/openai-compatible.ts +22 -32
- package/src/identity/family.ts +13 -0
- package/src/model-thinking.ts +52 -8
- package/src/models.json +1474 -477
- package/src/provider-models/ollama.ts +11 -2
- package/src/provider-models/openai-compat.ts +40 -42
- package/src/types.ts +175 -48
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.0.7] - 2026-06-18
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed MiniMax Anthropic-compatible M2/M3 thinking metadata to expose the adaptive transport and keep M2 mandatory reasoning floored ([#2928](https://github.com/can1357/oh-my-pi/issues/2928)).
|
|
10
|
+
|
|
11
|
+
## [16.0.6] - 2026-06-18
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added a dedicated `openrouter` API type and `ResolvedOpenRouterCompat` configuration to support unified chat-completions and Responses-API compatibility for OpenRouter models
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Migrated bundled OpenRouter models in the catalog from `openai-completions` to the new `openrouter` API type
|
|
20
|
+
- Consolidated the resolved OpenAI compat shape: extracted a shared `ResolvedOpenAISharedCompat` core that both `ResolvedOpenAICompat` and `ResolvedOpenAIResponsesCompat` extend (each builder still computes its own per-surface value, preserving chat↔Responses divergence), added internal resolved wire-quirk fields (`wireModelIdMode`, `stripDeepseekSpecialTokens`, `reasoningDeltasMayBeCumulative`, `emptyLengthFinishIsContextError`, `usesOpenAIToolCallIdLimit`, `dropThinkingWhenReasoningEffort`, `supportsObfuscationOptOut`), and replaced `buildOpenRouterCompat`'s cast-and-copy with an exhaustive `pickResponsesOnly` composition that fails to compile if a new Responses-only field is added without handling. The public `OpenAICompat` config vocabulary is unchanged.
|
|
21
|
+
- Expanded `OpenAICompat`/`ResolvedOpenAISharedCompat` with shared reasoning/history/stream/request flags (`reasoningDisableMode`, `omitReasoningEffort`, `includeEncryptedReasoning`, `filterReasoningHistory`, `requiresReasoningContentForAllAssistantTurns`, `streamMarkupHealingPattern`, `promptCacheSessionHeader`, etc.) so model/provider/gateway constraints are declared once in catalog compat and then consumed uniformly by Chat Completions and Responses endpoints.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Changed the default compatibility builder for `openai-completions` to set `requiresAssistantAfterToolResult` to `isMistral`, enabling the synthetic assistant bridge for built-in Mistral and Devstral models.
|
|
26
|
+
- Fixed local Ollama (`provider: "ollama"`) reasoning turns still failing with HTTP 400 `invalid reasoning value: "minimal"` when the model was selected from a stale `~/.omp/models.db` cache row or a hand-written config: the `minimal → low` / `xhigh → max` remap was only stamped during fresh discovery, so cached and custom specs reached the wire unmapped. The remap now lives in the OpenAI chat-completions and Responses compat builders, so every `buildModel` (including cache loads, custom specs, and the `whenThinking` variant) backfills it — no `omp models refresh` required. Custom OpenAI-compatible providers registered under a non-`ollama` provider id still need their own `compat.reasoningEffortMap`.
|
|
27
|
+
- Advertised Ollama Cloud GLM-5.2 reasoning efforts as high/xhigh-only and mapped `xhigh` to native max effort ([#2911](https://github.com/can1357/oh-my-pi/pull/2911) by [@serverinspector](https://github.com/serverinspector))
|
|
28
|
+
- Fixed OpenRouter pseudo-API model construction so bundled OpenRouter models resolve shared OpenAI compatibility metadata instead of an undefined compat record.
|
|
29
|
+
- Fixed custom/direct `xai-oauth` Responses model specs (e.g. `grok-build`) emitting `reasoning.effort` and hitting xAI's HTTP 400: `buildOpenAIResponsesCompat` now defaults `supportsReasoningEffort` to `false` for `xai-oauth` Grok models that are off the effort-capable allowlist (`grok-3-mini`/`grok-4.20-multi-agent`/`grok-4.3`), matching the curated discovery path; explicit `compat.supportsReasoningEffort` still overrides. The allowlist moved to a shared `isGrokReasoningEffortCapable` identity helper consumed by both the compat builder and provider-model curation so the two cannot drift.
|
|
30
|
+
|
|
5
31
|
## [16.0.5] - 2026-06-17
|
|
6
32
|
|
|
7
33
|
### Added
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelSpec, OpenAICompat, ResolvedOpenAICompat, ResolvedOpenAIResponsesCompat } from "../types";
|
|
1
|
+
import type { ModelSpec, OpenAICompat, ResolvedOpenAICompat, ResolvedOpenAIResponsesCompat, ResolvedOpenRouterCompat } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Build the resolved chat-completions compat record for a model spec.
|
|
4
4
|
* Provider takes precedence over URL-based detection since it's explicitly configured.
|
|
@@ -9,6 +9,7 @@ interface OpenAIResponsesSpecLike {
|
|
|
9
9
|
provider: string;
|
|
10
10
|
name: string;
|
|
11
11
|
baseUrl: string;
|
|
12
|
+
reasoning?: boolean;
|
|
12
13
|
compat?: OpenAICompat;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
@@ -23,4 +24,5 @@ interface OpenAIResponsesSpecLike {
|
|
|
23
24
|
* request-time check.
|
|
24
25
|
*/
|
|
25
26
|
export declare function buildOpenAIResponsesCompat(spec: OpenAIResponsesSpecLike): ResolvedOpenAIResponsesCompat;
|
|
27
|
+
export declare function buildOpenRouterCompat(spec: ModelSpec<"openrouter">): ResolvedOpenRouterCompat;
|
|
26
28
|
export {};
|
|
@@ -22,6 +22,12 @@ export declare function isGemmaModelId(modelId: string): boolean;
|
|
|
22
22
|
export declare function isDeepseekModelIdOrName(value: string): boolean;
|
|
23
23
|
/** Xiaomi MiMo family by id or display name. */
|
|
24
24
|
export declare function isMimoModelIdOrName(value: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Grok SKUs that expose the wire `reasoning.effort` dial. Other Grok reasoners
|
|
27
|
+
* (e.g. `grok-build`, `grok-4.20-0309-reasoning`) think natively but reject the
|
|
28
|
+
* param, so callers must omit reasoning effort for them.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isGrokReasoningEffortCapable(modelId: string): boolean;
|
|
25
31
|
/**
|
|
26
32
|
* MiniMax M2-generation family (M2, M2.1, M2.5, M2.7, including `-highspeed`/
|
|
27
33
|
* `-lightning`/`-her`/`-turbo` variants, dotless aliases like `minimax-m21`,
|
|
@@ -63,7 +63,7 @@ export declare function mapEffortToGoogleThinkingLevel(effort: Effort): "MINIMAL
|
|
|
63
63
|
* Maps a normalized thinking effort to Anthropic adaptive effort values via
|
|
64
64
|
* the model's baked `thinking.effortMap` (identity for unmapped efforts).
|
|
65
65
|
*/
|
|
66
|
-
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max";
|
|
66
|
+
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max" | "adaptive";
|
|
67
67
|
/**
|
|
68
68
|
* Resolves the upstream wire model id for a request at the given effort
|
|
69
69
|
* (`undefined` = thinking off). Collapsed effort-tier variants route through
|
|
@@ -233,7 +233,7 @@ export declare const CATALOG_PROVIDERS: readonly [{
|
|
|
233
233
|
readonly id: "openrouter";
|
|
234
234
|
readonly defaultModel: "openai/gpt-5.5";
|
|
235
235
|
readonly envVars: readonly ["OPENROUTER_API_KEY"];
|
|
236
|
-
readonly createModelManagerOptions: (config: ModelManagerConfig) => import("..").ModelManagerOptions<"
|
|
236
|
+
readonly createModelManagerOptions: (config: ModelManagerConfig) => import("..").ModelManagerOptions<"openrouter", unknown>;
|
|
237
237
|
readonly catalogDiscovery: {
|
|
238
238
|
readonly label: "OpenRouter";
|
|
239
239
|
readonly allowUnauthenticated: true;
|
|
@@ -95,11 +95,10 @@ interface XAICuratedModel {
|
|
|
95
95
|
reasoning?: boolean;
|
|
96
96
|
/**
|
|
97
97
|
* Whether xAI accepts the `reasoning.effort` wire param for this model.
|
|
98
|
-
* Default true. When false: picker hides the effort dial (via
|
|
99
|
-
* getSupportedEfforts in model-thinking.ts) AND wire
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* author convention until a follow-up Op: compress unifies them.
|
|
98
|
+
* Default true. When false: the picker hides the effort dial (via
|
|
99
|
+
* getSupportedEfforts in model-thinking.ts) AND the wire omits the param —
|
|
100
|
+
* both derive from `isGrokReasoningEffortCapable` (identity/family.ts), the
|
|
101
|
+
* single allowlist shared by this curated layer and the compat builder.
|
|
103
102
|
*/
|
|
104
103
|
supportsReasoningEffort?: boolean;
|
|
105
104
|
/**
|
|
@@ -235,7 +234,7 @@ export interface OpenRouterModelManagerConfig {
|
|
|
235
234
|
baseUrl?: string;
|
|
236
235
|
fetch?: FetchImpl;
|
|
237
236
|
}
|
|
238
|
-
export declare function openrouterModelManagerOptions(config?: OpenRouterModelManagerConfig): ModelManagerOptions<"
|
|
237
|
+
export declare function openrouterModelManagerOptions(config?: OpenRouterModelManagerConfig): ModelManagerOptions<"openrouter">;
|
|
239
238
|
export interface ZenMuxModelManagerConfig {
|
|
240
239
|
apiKey?: string;
|
|
241
240
|
baseUrl?: string;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Effort } from "./effort";
|
|
2
2
|
export type { KnownProvider } from "./provider-models/descriptors";
|
|
3
|
-
export type KnownApi = "openai-completions" | "openai-responses" | "openai-codex-responses" | "azure-openai-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-gemini-cli" | "google-vertex" | "ollama-chat" | "cursor-agent";
|
|
3
|
+
export type KnownApi = "openai-completions" | "openai-responses" | "openrouter" | "openai-codex-responses" | "azure-openai-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-gemini-cli" | "google-vertex" | "ollama-chat" | "cursor-agent";
|
|
4
4
|
export type Api = KnownApi | (string & {});
|
|
5
5
|
/** Canonical thinking transport used by a model. */
|
|
6
6
|
export type ThinkingControlMode = "effort" | "budget" | "google-level" | "anthropic-adaptive" | "anthropic-budget-effort";
|
|
@@ -117,6 +117,9 @@ export interface Usage {
|
|
|
117
117
|
total: number;
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
+
export type OpenAIReasoningFormat = "openai" | "openrouter" | "zai" | "qwen" | "qwen-chat-template";
|
|
121
|
+
export type OpenAIReasoningDisableMode = "omit" | "lowest-effort" | "openrouter-enabled-false" | "zai-thinking-disabled" | "qwen-enable-thinking-false" | "qwen-template-false" | "juice-zero-developer-message";
|
|
122
|
+
export type OpenAIStreamMarkupHealingPattern = "kimi" | "dsml" | "thinking";
|
|
120
123
|
/**
|
|
121
124
|
* Compatibility settings for openai-completions API.
|
|
122
125
|
* Use this to override URL-based auto-detection for custom providers.
|
|
@@ -163,13 +166,23 @@ export interface OpenAICompat {
|
|
|
163
166
|
/** Whether tool call IDs must be normalized to Mistral format (exactly 9 alphanumeric chars). Default: auto-detected from URL. */
|
|
164
167
|
requiresMistralToolIds?: boolean;
|
|
165
168
|
/** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "openrouter" uses reasoning: { effort }, "zai" uses thinking: { type: "enabled" | "disabled" } (also used by Moonshot Kimi), "qwen" uses top-level enable_thinking, and "qwen-chat-template" uses chat_template_kwargs.enable_thinking. Default: "openai". */
|
|
166
|
-
thinkingFormat?:
|
|
169
|
+
thinkingFormat?: OpenAIReasoningFormat;
|
|
170
|
+
/** Request-time disable encoding for the selected reasoning/thinking format. Default: derived from `thinkingFormat`. */
|
|
171
|
+
reasoningDisableMode?: OpenAIReasoningDisableMode;
|
|
172
|
+
/** Whether the provider rejects `reasoning.effort`/`reasoning_effort` even when the model reasons natively. Default: false unless reasoning effort is unsupported. */
|
|
173
|
+
omitReasoningEffort?: boolean;
|
|
174
|
+
/** Whether Responses requests should ask for encrypted reasoning replay items. Default: true. */
|
|
175
|
+
includeEncryptedReasoning?: boolean;
|
|
176
|
+
/** Whether replayed Responses history should strip native `type: "reasoning"` items before request encoding. Default: false. */
|
|
177
|
+
filterReasoningHistory?: boolean;
|
|
167
178
|
/** Optional `thinking.keep` value for Z.ai/Moonshot-style thinking params. Set false to suppress auto-detected keep. Default: auto-detected. */
|
|
168
179
|
thinkingKeep?: "all" | false;
|
|
169
180
|
/** Which reasoning content field to emit on assistant messages. Default: auto-detected. */
|
|
170
181
|
reasoningContentField?: "reasoning_content" | "reasoning" | "reasoning_text";
|
|
171
182
|
/** Whether assistant tool-call messages must include reasoning content. Default: false. */
|
|
172
183
|
requiresReasoningContentForToolCalls?: boolean;
|
|
184
|
+
/** Whether all assistant messages must include reasoning content. Default: false. */
|
|
185
|
+
requiresReasoningContentForAllAssistantTurns?: boolean;
|
|
173
186
|
/** Whether the provider accepts a synthetic placeholder (e.g. ".") for missing reasoning_content on tool-call turns. Default: true. Set to false for providers like DeepSeek that validate the exact reasoning_content value. */
|
|
174
187
|
allowsSyntheticReasoningContentForToolCalls?: boolean;
|
|
175
188
|
/** Whether assistant tool-call messages must include non-empty content. Default: false. */
|
|
@@ -203,10 +216,22 @@ export interface OpenAICompat {
|
|
|
203
216
|
vercelGatewayRouting?: VercelGatewayRouting;
|
|
204
217
|
/** Extra fields to include in request body (e.g. gateway routing hints for OpenClaw-style proxies). */
|
|
205
218
|
extraBody?: Record<string, unknown>;
|
|
219
|
+
/** Request-session header that should mirror the normalized prompt-cache key. Default: unset. */
|
|
220
|
+
promptCacheSessionHeader?: "x-grok-conv-id";
|
|
206
221
|
/** Whether chat-completions payloads should include provider-specific prompt-cache markers. */
|
|
207
222
|
cacheControlFormat?: "anthropic" | undefined;
|
|
208
223
|
/** Whether the provider supports the `strict` field in tool definitions. Default: auto-detected per provider/baseUrl (conservative for unknown providers). */
|
|
209
224
|
supportsStrictMode?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Tool-schema dialect the endpoint validates `tools.function.parameters`
|
|
227
|
+
* against. `"moonshot-mfjs"` triggers Moonshot Flavored JSON Schema
|
|
228
|
+
* normalization (collapse `const`→`enum`, infer `type` on bare enums, strip
|
|
229
|
+
* unsupported validators/`prefixItems`) because Moonshot/Kimi native hosts
|
|
230
|
+
* reject standard JSON Schema constructs with HTTP 400. Default:
|
|
231
|
+
* auto-detected (`"moonshot-mfjs"` on api.moonshot.ai / api.kimi.com). Set
|
|
232
|
+
* `"none"` to opt a custom Moonshot-compatible host out.
|
|
233
|
+
*/
|
|
234
|
+
toolSchemaFlavor?: "moonshot-mfjs" | "none";
|
|
210
235
|
/**
|
|
211
236
|
* Stream-watchdog idle-timeout floor in ms for slow reasoning hosts.
|
|
212
237
|
* Default: auto-detected (GLM coding-plan hosts, direct DeepSeek reasoning).
|
|
@@ -230,6 +255,16 @@ export interface OpenAICompat {
|
|
|
230
255
|
* Default: auto-detected (GPT-5-family model names).
|
|
231
256
|
*/
|
|
232
257
|
requiresJuiceZeroHack?: boolean;
|
|
258
|
+
/** Whether streamed reasoning deltas for the same field may repeat the full cumulative text snapshot. Default: false. */
|
|
259
|
+
reasoningDeltasMayBeCumulative?: boolean;
|
|
260
|
+
/** Strip leaked DeepSeek chat-template special tokens from visible content deltas. Default: auto-detected. */
|
|
261
|
+
stripDeepseekSpecialTokens?: boolean;
|
|
262
|
+
/** Heal leaked chat-template/tool-call/thinking markup from visible content deltas. Default: auto-detected. */
|
|
263
|
+
streamMarkupHealingPattern?: OpenAIStreamMarkupHealingPattern;
|
|
264
|
+
/** Treat an empty length-finished stream as a context-window error. Default: auto-detected. */
|
|
265
|
+
emptyLengthFinishIsContextError?: boolean;
|
|
266
|
+
/** Normalize tool call ids to OpenAI's 40-character limit. Default: auto-detected. */
|
|
267
|
+
usesOpenAIToolCallIdLimit?: boolean;
|
|
233
268
|
/**
|
|
234
269
|
* Compat deltas applied when a request actually engages thinking mode
|
|
235
270
|
* (reasoning requested and not disabled, model reasoning-capable, and not
|
|
@@ -331,41 +366,83 @@ export interface VercelGatewayRouting {
|
|
|
331
366
|
order?: string[];
|
|
332
367
|
}
|
|
333
368
|
type ResolvedToolStrictMode = NonNullable<OpenAICompat["toolStrictMode"]> | "mixed";
|
|
369
|
+
/**
|
|
370
|
+
* Fields whose meaning is identical across chat-completions and Responses surfaces.
|
|
371
|
+
* Each builder still computes its own per-surface value when defaults diverge.
|
|
372
|
+
*/
|
|
373
|
+
export interface ResolvedOpenAISharedCompat {
|
|
374
|
+
supportsDeveloperRole: boolean;
|
|
375
|
+
supportsStrictMode: boolean;
|
|
376
|
+
supportsReasoningEffort: boolean;
|
|
377
|
+
reasoningEffortMap: Partial<Record<Effort, string>>;
|
|
378
|
+
supportsReasoningParams: boolean;
|
|
379
|
+
thinkingFormat: OpenAIReasoningFormat;
|
|
380
|
+
reasoningDisableMode: OpenAIReasoningDisableMode;
|
|
381
|
+
omitReasoningEffort: boolean;
|
|
382
|
+
includeEncryptedReasoning: boolean;
|
|
383
|
+
filterReasoningHistory: boolean;
|
|
384
|
+
disableReasoningOnForcedToolChoice: boolean;
|
|
385
|
+
disableReasoningOnToolChoice: boolean;
|
|
386
|
+
supportsToolChoice: boolean;
|
|
387
|
+
supportsForcedToolChoice: boolean;
|
|
388
|
+
reasoningContentField?: OpenAICompat["reasoningContentField"];
|
|
389
|
+
requiresReasoningContentForToolCalls: boolean;
|
|
390
|
+
requiresReasoningContentForAllAssistantTurns: boolean;
|
|
391
|
+
allowsSyntheticReasoningContentForToolCalls: boolean;
|
|
392
|
+
requiresThinkingAsText: boolean;
|
|
393
|
+
requiresMistralToolIds: boolean;
|
|
394
|
+
requiresToolResultName: boolean;
|
|
395
|
+
requiresAssistantAfterToolResult: boolean;
|
|
396
|
+
requiresAssistantContentForToolCalls: boolean;
|
|
397
|
+
stripDeepseekSpecialTokens: boolean;
|
|
398
|
+
streamMarkupHealingPattern?: OpenAIStreamMarkupHealingPattern;
|
|
399
|
+
reasoningDeltasMayBeCumulative: boolean;
|
|
400
|
+
emptyLengthFinishIsContextError: boolean;
|
|
401
|
+
usesOpenAIToolCallIdLimit: boolean;
|
|
402
|
+
promptCacheSessionHeader?: OpenAICompat["promptCacheSessionHeader"];
|
|
403
|
+
/** The model sits behind OpenRouter (routing prefs and max-token omission apply). */
|
|
404
|
+
isOpenRouterHost: boolean;
|
|
405
|
+
/** Whether this endpoint needs a max-token field even when caller did not set one. */
|
|
406
|
+
alwaysSendMaxTokens: boolean;
|
|
407
|
+
/** See {@link OpenAICompat.enableGeminiThinkingLoopGuard}. Set by the builder from the family classifier. */
|
|
408
|
+
enableGeminiThinkingLoopGuard?: boolean;
|
|
409
|
+
openRouterRouting?: OpenAICompat["openRouterRouting"];
|
|
410
|
+
/** Provider-specific wire model-id transform applied to the base id. */
|
|
411
|
+
wireModelIdMode: "raw" | "firepass" | "fireworks" | "openrouter";
|
|
412
|
+
}
|
|
334
413
|
/**
|
|
335
414
|
* Fully-resolved chat-completions compat view: every detected default
|
|
336
415
|
* materialized and user overrides applied. Built once per model by
|
|
337
416
|
* `buildModel`; request handlers read fields and never detect, resolve, or
|
|
338
417
|
* allocate.
|
|
339
418
|
*/
|
|
340
|
-
export type ResolvedOpenAICompat = Required<Omit<OpenAICompat, "openRouterRouting" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "
|
|
341
|
-
openRouterRouting?: OpenAICompat["openRouterRouting"];
|
|
419
|
+
export type ResolvedOpenAICompat = ResolvedOpenAISharedCompat & Required<Omit<OpenAICompat, "supportsDeveloperRole" | "supportsReasoningEffort" | "reasoningEffortMap" | "supportsReasoningParams" | "thinkingFormat" | "reasoningDisableMode" | "omitReasoningEffort" | "includeEncryptedReasoning" | "filterReasoningHistory" | "disableReasoningOnForcedToolChoice" | "disableReasoningOnToolChoice" | "supportsToolChoice" | "supportsForcedToolChoice" | "reasoningContentField" | "requiresReasoningContentForToolCalls" | "requiresReasoningContentForAllAssistantTurns" | "allowsSyntheticReasoningContentForToolCalls" | "requiresThinkingAsText" | "requiresMistralToolIds" | "requiresToolResultName" | "requiresAssistantAfterToolResult" | "requiresAssistantContentForToolCalls" | "stripDeepseekSpecialTokens" | "streamMarkupHealingPattern" | "reasoningDeltasMayBeCumulative" | "emptyLengthFinishIsContextError" | "usesOpenAIToolCallIdLimit" | "promptCacheSessionHeader" | "openRouterRouting" | "isOpenRouterHost" | "supportsStrictMode" | "supportsLongPromptCacheRetention" | "alwaysSendMaxTokens" | "wireModelIdMode" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "toolSchemaFlavor" | "streamIdleTimeoutMs" | "cacheControlFormat" | "thinkingKeep" | "strictResponsesPairing" | "requiresJuiceZeroHack" | "enableGeminiThinkingLoopGuard" | "whenThinking">> & {
|
|
342
420
|
vercelGatewayRouting?: OpenAICompat["vercelGatewayRouting"];
|
|
343
421
|
extraBody?: OpenAICompat["extraBody"];
|
|
344
422
|
cacheControlFormat?: OpenAICompat["cacheControlFormat"];
|
|
345
423
|
thinkingKeep?: OpenAICompat["thinkingKeep"];
|
|
346
424
|
streamIdleTimeoutMs?: number;
|
|
347
425
|
toolStrictMode: ResolvedToolStrictMode;
|
|
348
|
-
|
|
349
|
-
isOpenRouterHost: boolean;
|
|
426
|
+
toolSchemaFlavor?: OpenAICompat["toolSchemaFlavor"];
|
|
350
427
|
/** The model sits behind Vercel AI Gateway. */
|
|
351
428
|
isVercelGatewayHost: boolean;
|
|
352
|
-
|
|
353
|
-
enableGeminiThinkingLoopGuard?: boolean;
|
|
429
|
+
dropThinkingWhenReasoningEffort: boolean;
|
|
354
430
|
/** Complete alternate view for thinking-engaged requests; swap pointers, never spread. */
|
|
355
431
|
whenThinking?: ResolvedOpenAICompat;
|
|
356
432
|
};
|
|
357
433
|
/** Fully-resolved Responses-API compat view (same contract as `ResolvedOpenAICompat`). */
|
|
358
|
-
export interface ResolvedOpenAIResponsesCompat {
|
|
359
|
-
supportsDeveloperRole: boolean;
|
|
360
|
-
supportsStrictMode: boolean;
|
|
361
|
-
supportsReasoningEffort: boolean;
|
|
434
|
+
export interface ResolvedOpenAIResponsesCompat extends ResolvedOpenAISharedCompat {
|
|
362
435
|
supportsLongPromptCacheRetention: boolean;
|
|
363
436
|
strictResponsesPairing: boolean;
|
|
364
437
|
requiresJuiceZeroHack: boolean;
|
|
365
|
-
|
|
366
|
-
/** See {@link OpenAICompat.enableGeminiThinkingLoopGuard}. */
|
|
367
|
-
enableGeminiThinkingLoopGuard?: boolean;
|
|
438
|
+
supportsObfuscationOptOut: boolean;
|
|
368
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* OpenRouter is a pseudo API: runtime dispatch can use either Responses
|
|
442
|
+
* (default) or Chat Completions (`PI_OPENROUTER_RESPONSES=0`) with the same
|
|
443
|
+
* model object, so its resolved compat must satisfy both handlers.
|
|
444
|
+
*/
|
|
445
|
+
export type ResolvedOpenRouterCompat = ResolvedOpenAICompat & ResolvedOpenAIResponsesCompat;
|
|
369
446
|
/** Fully-resolved anthropic-messages compat view (same contract as `ResolvedOpenAICompat`). */
|
|
370
447
|
export type ResolvedAnthropicCompat = Required<AnthropicCompat> & {
|
|
371
448
|
/**
|
|
@@ -377,9 +454,9 @@ export type ResolvedAnthropicCompat = Required<AnthropicCompat> & {
|
|
|
377
454
|
officialEndpoint: boolean;
|
|
378
455
|
};
|
|
379
456
|
/** Sparse, user-authored compat overrides for a given API (models.json / config vocabulary). */
|
|
380
|
-
export type CompatConfigOf<TApi extends Api> = TApi extends "openai-completions" | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? OpenAICompat : TApi extends "anthropic-messages" ? AnthropicCompat : undefined;
|
|
457
|
+
export type CompatConfigOf<TApi extends Api> = TApi extends "openai-completions" | "openrouter" | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? OpenAICompat : TApi extends "anthropic-messages" ? AnthropicCompat : undefined;
|
|
381
458
|
/** Resolved compat for a given API: complete record, materialized once by `buildModel`. */
|
|
382
|
-
export type CompatOf<TApi extends Api> = TApi extends "openai-completions" ? ResolvedOpenAICompat : TApi extends "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? ResolvedOpenAIResponsesCompat : TApi extends "anthropic-messages" ? ResolvedAnthropicCompat : undefined;
|
|
459
|
+
export type CompatOf<TApi extends Api> = TApi extends "openrouter" ? ResolvedOpenRouterCompat : TApi extends "openai-completions" ? ResolvedOpenAICompat : TApi extends "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? ResolvedOpenAIResponsesCompat : TApi extends "anthropic-messages" ? ResolvedAnthropicCompat : undefined;
|
|
383
460
|
export interface Model<TApi extends Api = Api> {
|
|
384
461
|
id: string;
|
|
385
462
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-catalog",
|
|
4
|
-
"version": "16.0.
|
|
4
|
+
"version": "16.0.7",
|
|
5
5
|
"description": "Model catalog for omp: bundled model database, provider discovery descriptors, model identity, classification, and equivalence",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@bufbuild/protobuf": "^2.12.0",
|
|
37
|
-
"@oh-my-pi/pi-utils": "16.0.
|
|
37
|
+
"@oh-my-pi/pi-utils": "16.0.7",
|
|
38
|
+
"arktype": "^2.2.0",
|
|
38
39
|
"zod": "^4"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@oh-my-pi/pi-ai": "16.0.
|
|
42
|
+
"@oh-my-pi/pi-ai": "16.0.7",
|
|
42
43
|
"@types/bun": "^1.3.14"
|
|
43
44
|
},
|
|
44
45
|
"engines": {
|
package/src/build.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* compat per request.
|
|
11
11
|
*/
|
|
12
12
|
import { buildAnthropicCompat } from "./compat/anthropic";
|
|
13
|
-
import { buildOpenAICompat, buildOpenAIResponsesCompat } from "./compat/openai";
|
|
13
|
+
import { buildOpenAICompat, buildOpenAIResponsesCompat, buildOpenRouterCompat } from "./compat/openai";
|
|
14
14
|
import { resolveModelThinking } from "./model-thinking";
|
|
15
15
|
import type { Api, CompatOf, Model, ModelSpec } from "./types";
|
|
16
16
|
import { cleanModelName } from "./utils";
|
|
@@ -28,6 +28,8 @@ export function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi>
|
|
|
28
28
|
|
|
29
29
|
export function buildCompat(spec: ModelSpec<Api>): CompatOf<Api> {
|
|
30
30
|
switch (spec.api) {
|
|
31
|
+
case "openrouter":
|
|
32
|
+
return buildOpenRouterCompat(spec as ModelSpec<"openrouter">);
|
|
31
33
|
case "openai-completions":
|
|
32
34
|
return buildOpenAICompat(spec as ModelSpec<"openai-completions">);
|
|
33
35
|
case "openai-responses":
|