openzoo 0.50.96 → 0.50.97

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/lib/models.js CHANGED
@@ -168,9 +168,39 @@ const tokensOf = (id) => id.toLowerCase().split(/[^a-z0-9.]+/).filter((t) => t &
168
168
  * the id is already servable (no rewrite), otherwise the closest zoo id.
169
169
  * OPENZOO_DEFAULT_MODEL is an explicit user override, not a fallback tier.
170
170
  */
171
+ /**
172
+ * UNOPENROUTER. OpenRouter is not an upstream any more (gateway, 2026-09-02):
173
+ * every completion is bought from an x402 door, and doors publish BARE ids
174
+ * (`grok-4.3`, `claude-sonnet-5`, `gemini-2.5-flash`). A harness that still
175
+ * sends the OpenRouter spelling (`x-ai/grok-4.3`, `anthropic/claude-sonnet-5`)
176
+ * is rewritten to the bare id whenever the live catalog serves that bare id.
177
+ *
178
+ * OPENZOO_UNOPENROUTER=1 strip the vendor prefix ALWAYS, catalog or not
179
+ * OPENZOO_UNOPENROUTER=0 never strip
180
+ * unset strip when the bare id is in the catalog
181
+ *
182
+ * Router aliases and `openzoo-` twins are never touched: their slash is not a
183
+ * vendor.
184
+ */
185
+ export function unopenrouter(requested, ids) {
186
+ const mode = process.env.OPENZOO_UNOPENROUTER;
187
+ if (mode === '0') return null;
188
+ const s = String(requested || '');
189
+ if (!s || isAutoModel(s) || /^openzoo[-/]/i.test(s)) return null;
190
+ const slash = s.indexOf('/');
191
+ if (slash <= 0) return null;
192
+ const bare = s.slice(slash + 1);
193
+ if (!bare || bare.includes('/')) return null;
194
+ if (mode === '1') return bare;
195
+ return Array.isArray(ids) && ids.includes(bare) ? bare : null;
196
+ }
197
+
171
198
  export function resolveModel(requested, ids) {
172
199
  // Virtual router id — never family-match, never steal via OPENZOO_DEFAULT_MODEL.
173
200
  if (isAutoModel(requested)) return null;
201
+ // Vendor-prefixed OpenRouter spelling → the bare id the doors serve.
202
+ const bareVendor = unopenrouter(requested, ids);
203
+ if (bareVendor) return bareVendor;
174
204
  // Bare Anthropic / Claude Code ids are never live on Fly/OpenRouter
175
205
  // (`claude-opus-5` → 500 unknown model). Rewrite even on a catalog miss
176
206
  // or if a gateway row lists the bare name — the request must not leave