@gtrabanco/pi-nan-provider 1.5.5 → 1.5.6

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/AGENTS.md CHANGED
@@ -206,45 +206,59 @@ Since 1.0.0 the package version **aligns its MAJOR.MINOR with the pi release lin
206
206
  truth (maintainer instruction, reaffirmed 2026-09-29), cross-checked against
207
207
  the `model` param description in https://nan.builders/openapi.json, plus
208
208
  (since 2026-11-10) the live `GET /v1/models` for models NaN launches before
209
- the docs catch up (see "2026-11-10 external models" below). The original
209
+ the docs catch up (see "Larger models" below). The original
210
210
  seven documented chat models declare 1M-token windows where the docs say so —
211
211
  `deepseek-v4-flash`, `glm5.3-flash`, `qwen3.8-flash` and `mimo-v2.6-flash` at
212
212
  **1,048,576**, `qwen3.6` and `gemma4` at **262,144** — and the first three
213
213
  carry a `MANUAL_OVERRIDES.contextWindow` because models.dev lagged (rounded
214
214
  1,000,000 for the first two, stale 262,144 for `qwen3.8-flash`; docs checked
215
215
  2026-10-14).
216
- Official chat models (checked 2026-10-14): community `deepseek-v4-flash`,
216
+ Official chat models (checked 2026-11-17): community `deepseek-v4-flash`,
217
217
  `mimo-v2.6-flash`, `qwen3.8-flash`, `glm5.3-flash`, `qwen3.6`, `gemma4`
218
- (all text+image vision) + `glm5.3`
219
- (~753B MoE, multimodal text+image+audio+video input, 1M context).
218
+ (all text+image vision) + `glm5.3` (~753B MoE, **text only** since the
219
+ 2026-11-17 docs — an image, audio, video or file part answers 400, earlier
220
+ turns included; the old card said multimodal, models.dev now says text-only).
220
221
  **glm5.3 is a general catalog model since 2026-11-10** (NaN announced "a
221
222
  partir de ahora ya NO habrá modelos exclusivos por tier"; the live
222
223
  `GET /v1/models` lists it for a non-premium key, checked 2026-11-10). It was
223
224
  premium live-only before (`LIVE_ONLY_MODEL_IDS` in the generator and
224
225
  `LIVE_ONLY_MODEL_DATA` in `src/fetch-models.ts`); both were REMOVED in
225
226
  package 1.5.1 as dead code once nothing was tier-gated. Its values live in
226
- `MANUAL_OVERRIDES["glm5.3"]` (1,048,576 / 131,072, text+image,
227
- reasoningEffortValues low/medium/high/max, `thinkingLevelMap { off: "low" }`,
228
- name "GLM 5.3") over the models.dev entry (text-only, 1,000,000). The
229
- overlay/merge paths now treat it like any catalogued id (issue #19's
230
- invariant is intact: the store decides which ids exist, the generated
231
- catalog decides their capabilities). `src/usage.ts` no longer has a `premium`
232
- flag (removed in 1.5.1 at the maintainer's request); its token windows are a
233
- known follow-up, NaN moved to credits.
234
- **2026-11-10 external models** (ZDR, "EXTERNAL PROVIDER" on NaN's pricing
235
- page): `kimi-k3.1-pro`, `qwen3.8-max`, `deepseek-v4-pro`, `hy4`. Not in
236
- models.dev provider `nan`, the docs, or openapi.json, but listed by the live
237
- `GET /v1/models` (checked 2026-11-10). They enter through
238
- `MANUAL_ONLY_MODEL_IDS` with values in `scripts/manual-overrides.ts`
239
- (`EXTERNAL_MODELS`), each with a provenance note: contextWindow from the
240
- pricing page "1M context" (1,048,576 per the NaN pi docs convention;
241
- `qwen3.8-max` uses the first-party 1,000,000), maxTokens 32,768 per
242
- https://nan.builders/docs/pi, input from first-party vendor modalities on
243
- models.dev restricted to text/image, reasoning true, cost 0 (maintainer
244
- decision), `reasoningEffortValues: []` and NO `thinkingLevelMap` — how the
245
- gateway handles `reasoning_effort` for external providers is unmeasured
246
- (needs a permission-gated live probe). When the docs or models.dev list
247
- them, re-verify the values (docs win).
227
+ `MANUAL_OVERRIDES["glm5.3"]` (1,048,576 / 131,072, **text only**,
228
+ reasoningEffortValues minimal/low/medium/high/xhigh/max,
229
+ `thinkingLevelMap { off: "minimal" }` — GLM cannot stop reasoning and the
230
+ docs apply `none` as `minimal`, name "GLM 5.3") over the models.dev entry
231
+ (text-only, 1,000,000). The overlay/merge paths now treat it like any
232
+ catalogued id (issue #19's invariant is intact: the store decides which ids
233
+ exist, the generated catalog decides their capabilities). `src/usage.ts` no
234
+ longer has a `premium` flag (removed in 1.5.1 at the maintainer's request);
235
+ its token windows are a known follow-up, NaN moved to credits.
236
+ **Larger models — six, all documented since 2026-11-17** (the docs' own
237
+ label; NaN bills them as "larger model" because they use credits faster):
238
+ `kimi-k3.1-pro`, `qwen3.8-max`, `qwen4-max`, `deepseek-v4-pro`, `hy4`,
239
+ `hy4-flash`. They live in `scripts/manual-overrides.ts` as `LARGER_MODELS`
240
+ (renamed from `EXTERNAL_MODELS` in package 1.5.6), each with a provenance
241
+ note citing https://nan.builders/docs/models (checked 2026-11-17):
242
+ contextWindow 1,048,576 per NaN's 1M convention except the two Alibaba
243
+ flagships (1,000,000, the first-party vendor value); maxTokens from the
244
+ card's "Max answer" (kimi 1,048,576, deepseek-v4-pro 393,216, hy4 and
245
+ hy4-flash 65,536, qwen3.8-max 131,072, qwen4-max 131,072) — pi-ai clamps the
246
+ outgoing budget to the context room (`clampMaxTokensToContext`), so a large
247
+ documented ceiling never becomes an over-context request; input from the
248
+ card (`deepseek-v4-pro` is text-only); reasoning true; cost 0 (maintainer
249
+ decision). `qwen4-max` and `hy4-flash` are the two ids the catalog never had
250
+ — models.dev provider `nan` lists neither, so they enter through
251
+ `MANUAL_ONLY_MODEL_IDS`; the other four are models.dev entries corrected by
252
+ the overrides. Reasoning: the docs keep `kimi-k3.1-pro` and
253
+ `deepseek-v4-pro` out of the contract and state their `none` aliases are NOT
254
+ mapped, so they declare no effort values and no `thinkingLevelMap`;
255
+ `qwen3.8-max` gets `maxTokensField: "max_completion_tokens"` because its
256
+ `max_tokens` bounds only the visible answer (issue #34's quota failure
257
+ mode); `qwen4-max`, `qwen3.8-flash`, `hy4`, `hy4-flash` and `qwen3.8-max`
258
+ map `off` to `none`; `hy4` reasons by default with the gateway applying
259
+ `low` when no level is sent.
260
+ When the docs or models.dev change, re-verify the values (docs win; a
261
+ measurement wins over the docs).
248
262
  Removed by the provider: `glm5.2` (2026-09-05) and `mimo-v2.5` (checked
249
263
  2026-09-29 — zero mentions in the docs and in openapi.json, and models.dev
250
264
  dropped it too; superseded by `mimo-v2.6-flash`). models.dev may re-list a
@@ -290,7 +304,16 @@ Since 1.0.0 the package version **aligns its MAJOR.MINOR with the pi release lin
290
304
  `test/issue-2-truncated-stream.test.ts`, `test/issue-4-token-usage.test.ts`,
291
305
  `test/issue-7-streaming-usage-default.test.ts`;
292
306
  issues #2, #4 and #7.
293
- - **Catalog now declares `thinkingLevelMap` for reasoning suppression** (issue #16, measured 2026-09-27 against live gateway, repro script in the issue). `deepseek-v4-flash` → `{ off: "none" }` (0 reasoning tokens, reproducible); `glm5.3-flash` → `{ off: "minimal" }` (38 reasoning tokens + answer; `none` does NOT work on glm5.3 — 13,382 tokens); `qwen3.6` and `gemma4` → `{ off: "none" }` (gap left by the measured-only fix: the NaN docs state that with no parameter both reason by default with a 16,384-token budget and that `none`/`minimal` skip the reasoning phase entirely — https://nan.builders/docs/models#controlling-reasoning, checked 2026-10-01 — so `off` must send `none` explicitly). `reasoningEffortValues` corrected: deepseek-v4-flash from `[]` to `["none"]`; glm5.3-flash from `["low","medium","high","max"]` to include `"minimal"`. README limits table notes that `maxTokens` does NOT bound the reasoning phase (measured: max_tokens=512 still yielded 13,376 reasoning tokens). pi-ai's `buildRequest` (0.99.1) maps `reasoning: "off"` → `reasoningEffort: undefined` → fires the off-branch that checks `model.thinkingLevelMap?.off` (verified in pi-ai source ~line 718-722). A model whose reasoning depth is genuinely not adjustable (`qwen3.8-flash`, `mimo-v2.6-flash`) keeps no `thinkingLevelMap`: `off` sends nothing and the model uses its own default.
307
+ - **The catalog declares `thinkingLevelMap` for reasoning suppression** (issue #16, measured 2026-09-27 against live gateway, repro script in the issue; extended 2026-11-17 from the docs for every model they now document). `deepseek-v4-flash` → `{ off: "none" }` (0 reasoning tokens, reproducible); `glm5.3-flash` and `glm5.3` → `{ off: "minimal" }` (38 reasoning tokens + answer; `none` does NOT work on glm5.3-flash — 13,382 tokens — and the docs state GLM always reasons, so `none` is applied as `minimal`); `qwen3.6`, `gemma4`, `qwen3.8-flash`, `qwen4-max`, `qwen3.8-max`, `hy4`, `hy4-flash` → `{ off: "none" }` (the NaN docs state that with no parameter these models reason by default and that `none` turns reasoning off — https://nan.builders/docs/models#controlling-reasoning, checked 2026-11-17 — so `off` must send `none` explicitly). `kimi-k3.1-pro` and `deepseek-v4-pro` declare NO map: the docs keep them out of the reasoning contract and state their `none` aliases are not mapped, so `off` sends nothing and the model decides. pi-ai's `buildRequest` maps `reasoning: "off"` → `reasoningEffort: undefined` → fires the off-branch that checks `model.thinkingLevelMap?.off` (verified in pi-ai 1.5.1, `api/openai-completions.js` ~line 715). `reasoningEffortValues` is catalog documentation only — pi and pi-ai never read it (`rg reasoningEffortValues node_modules/@earendil-works` → no match on 1.5.1) — and it now lives in ONE place, each model's `MANUAL_OVERRIDES` entry, with no fallback map in the generator. Ladders follow the docs: `deepseek-v4-flash` `none`+minimal…max (the measured fact that only `none` *suppresses* is unchanged and still drives its off map), `mimo-v2.6-flash` `none`/low…max (`minimal` is applied as `low`, `xhigh` as `max`), GLM and the two new models include `xhigh`. `xhigh` and `max` are opt-in in pi-ai: `getSupportedThinkingLevels` only lists them when the map carries a non-null entry for that level, and `clampThinkingLevel` silently degrades a request for either one to `high` otherwise (pi-ai 1.5.1 `dist/models.js:701-713`; its README says both "are opt-in and require a non-null map entry"). NaN accepts both, so every model whose docs declare a ladder up to `max` now carries identity entries `{ xhigh: "xhigh", max: "max" }` — `deepseek-v4-flash`, `gemma4`, `qwen3.6`, `glm5.3`, `glm5.3-flash`, `qwen3.8-flash`, `qwen4-max`, `mimo-v2.6-flash` (the gateway applies `xhigh` as `max` there) — while `hy4`, `hy4-flash` and `qwen3.8-max` (docs document only the off switch) and `kimi-k3.1-pro`/`deepseek-v4-pro` (outside the contract) keep `off` alone and stay at `off`…`high`. Verified end to end: before the entries a `max` request reached the gateway as `reasoning_effort: "high"`; now it reaches it as `"max"`. The README limits table records which models' `maxTokens` DOES bound reasoning plus answer (`qwen4-max`, `hy4`, `hy4-flash`, `mimo-v2.6-flash` per the 2026-11-17 docs) versus the measured case where it does not (max_tokens=512 on deepseek-v4-flash still yielded 13,376 reasoning tokens).
308
+ - **Catalog cost is pinned to 0** (generator constant `NAN_CATALOG_COST`, recorded
309
+ in `GENERATED_CATALOG_META.notes`). NaN bills a credit pool (1 credit ≈ 0.026 €),
310
+ not per-token USD, so pi's per-token cost estimate has nothing to report. models.dev
311
+ provider `nan` started publishing a DERIVED USD conversion on 2026-11-17
312
+ (deepseek-v4-flash 0.29484 / 1.17936, glm5.3 1.37592 / 4.32432, …), which is not a
313
+ price NaN charges; adopting it would make pi display that estimate as real money.
314
+ A model with a confirmed per-token price can still override `cost` through
315
+ `MANUAL_OVERRIDES`; to adopt models.dev's numbers everywhere, delete the constant.
316
+ Regression test: `test/larger-models-2026-11-17.test.ts`.
294
317
  - A NaN request that still exceeds the destination model's context window (the
295
318
  cross-model thinking guard is disabled with `NAN_THINKING_GUARD=0`, the
296
319
  inflation is not a `thinking` block, or the window is smaller) gets NaN's
package/README.es.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @gtrabanco/𝜋-nan-provider
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![Version](https://img.shields.io/badge/version-1.5.5-blue)](https://github.com/gtrabanco/pi-nan-provider/releases)
4
+ [![Version](https://img.shields.io/badge/version-1.5.6-blue)](https://github.com/gtrabanco/pi-nan-provider/releases)
5
5
  [![Built with NaN](https://nan.builders/badge/built-with-nan-compact.svg)](https://cloud.nan.builders/r/7GK06FX8)
6
6
 
7
7
  [NaN Builders](https://cloud.nan.builders/r/7GK06FX8) model provider + MCP nativo para [pi](https://github.com/earendil-works/pi).
@@ -442,17 +442,23 @@ Modelos de chat:
442
442
  | `mimo-v2.6-flash` | 1,048,576 | 131,072 | texto, imagen | ✅ |
443
443
  | `glm5.3-flash` | 1,048,576 | 131,072 | texto, imagen | ✅ |
444
444
  | `qwen3.8-flash` | 1,048,576 | 131,072 | texto, imagen | ✅ |
445
- | `glm5.3` | 1,048,576 | 131,072 | texto, imagen | ✅ |
446
- | `kimi-k3.1-pro` | 1,048,576 | 32,768 | texto, imagen | ✅ |
447
- | `qwen3.8-max` | 1,000,000 | 32,768 | texto, imagen | ✅ |
448
- | `deepseek-v4-pro` | 1,048,576 | 32,768 | texto | ✅ |
449
- | `hy4` | 1,048,576 | 32,768 | texto, imagen | ✅ |
450
-
451
- > Las ventanas de la tabla son las **documentadas** en [los docs de NaN](https://nan.builders/docs/models) (comprobado 2026-10-14), que son la fuente de verdad; models.dev es un espejo que un humano actualiza más tarde y puede ir por detrás. `glm5.3` fue solo-premium y solo-en-vivo hasta que NaN eliminó los modelos exclusivos por tier el 2026-11-10; ahora está en el catálogo estático con los valores que tenía (texto+imagen, 1,048,576 / 131,072).
445
+ | `glm5.3` | 1,048,576 | 131,072 | texto | ✅ |
446
+ | `hy4-flash` | 1,048,576 | 65,536 | texto, imagen | ✅ |
447
+ | `hy4` | 1,048,576 | 65,536 | texto, imagen | ✅ |
448
+ | `kimi-k3.1-pro` | 1,048,576 | 1,048,576 | texto, imagen | ✅ |
449
+ | `qwen3.8-max` | 1,000,000 | 131,072 | texto, imagen | ✅ |
450
+ | `qwen4-max` | 1,000,000 | 131,072 | texto, imagen | ✅ |
451
+ | `deepseek-v4-pro` | 1,048,576 | 393,216 | texto | ✅ |
452
+
453
+ > Las ventanas de contexto y la salida máxima de la tabla son los valores **documentados** en [los docs de NaN](https://nan.builders/docs/models) (comprobado 2026-11-17), que son la fuente de verdad; models.dev es un espejo que un humano actualiza más tarde y puede ir por detrás. `glm5.3` fue solo-premium y solo-en-vivo hasta que NaN eliminó los modelos exclusivos por tier el 2026-11-10; ahora está en el catálogo estático, **solo texto** (una imagen, audio, vídeo o fichero — o un turno anterior que lleve uno — responde `400`, así que empieza sesión nueva o cambia de modelo).
454
+ >
455
+ > Los **modelos grandes** — `kimi-k3.1-pro`, `qwen3.8-max`, `qwen4-max`, `deepseek-v4-pro`, `hy4`, `hy4-flash` — son los que NaN factura como "larger model" (gastan créditos más rápido). Los cuatro que entraron en el catálogo el 2026-11-10 llevaban una salida máxima plana de 32,768 y ningún mapeo de razonamiento porque los docs aún no los documentaban; desde el 2026-11-17 cada uno declara su propio "Max answer" y su comportamiento de razonamiento documentado. `qwen4-max` y `hy4-flash` son ids nuevos que el catálogo no tenía (models.dev, proveedor `nan`, no lista ninguno de los dos; el `/models` en vivo y los docs sí). La salida máxima es un techo, no una petición: pi-ai recorta el presupuesto saliente al hueco que queda en la ventana de contexto (`clampMaxTokensToContext`), así que un techo de 1M tokens en `kimi-k3.1-pro` nunca se convierte en un `max_tokens` fuera de contexto.
456
+ >
457
+ > `qwen3.8-max` envía `max_completion_tokens` en vez de `max_tokens`, y `qwen3.8-flash` hace lo mismo: en esos dos los docs dicen que `max_tokens` solo limita la respuesta visible y el razonamiento se factura por encima, así que el presupuesto del cliente debe cubrir el total (issue #34).
452
458
  >
453
- > `kimi-k3.1-pro`, `qwen3.8-max`, `deepseek-v4-pro` y `hy4` son los modelos de proveedor externo (ZDR) que NaN lanzó el 2026-11-10. Los docs y el OpenAPI de NaN todavía no los listan, pero el `GET /v1/models` en vivo sí (comprobado 2026-11-10). Sus valores salen de la página de precios de NaN ("1M context"), los docs de NaN para pi (`maxTokens` 32,768 en todos los modelos de 1M de contexto) y las entradas de los proveedores originales en models.dev (modalidades; `qwen3.8-max` usa la ventana de 1,000,000 del proveedor); el coste es 0 y no se declara mapeo de `reasoning_effort`, porque no se ha medido cómo lo trata la pasarela con proveedores externos. Cada entrada lleva su nota de procedencia en `scripts/models.generated.ts`.
459
+ > Todos los modelos del catálogo reportan **coste 0**: NaN factura un pool de créditos (1 crédito ≈ 0,026 €), no USD por token, así que la estimación de coste de pi no tiene nada que reportar. models.dev, proveedor `nan`, empezó a publicar una conversión derivada a USD el 2026-11-17; el catálogo no la adopta, porque pi la mostraría como dinero real. Usa `/nan-usage` para el consumo real.
454
460
  >
455
- > `*` El límite de salida de 32,768 en `deepseek-v4-flash` es el techo de los docs oficiales de NaN para pi (https://nan.builders/docs/pi, "the same set the NaN CLI writes", issue #20, 2026-10-02); models.dev sigue listando 384,000, pero la pasarela rechaza `max_tokens` por encima de ~256k con 403.
461
+ > `*` El límite de salida de 32,768 en `deepseek-v4-flash` es el techo de los docs oficiales de NaN para pi (https://nan.builders/docs/pi, "the same set the NaN CLI writes", issue #20, 2026-10-02); models.dev lista 384,000, pero la pasarela rechaza `max_tokens` por encima de ~256k con 403. `gemma4` se queda con los 32,768 de models.dev: los 65,536 de los bloques de pi/OpenCode están descritos ahí como "a client-side budget rather than a server cap", así que se mantiene el valor menor en vez de arriesgar un `400`.
456
462
 
457
463
  > [!NOTE]
458
464
  > **Techo práctico con caché de prompt fría (issue #18).** Las ventanas de contexto de la tabla son las ventanas reales de los modelos, pero el borde de api.nan.builders (Cloudflare) aborta las respuestas que superan su Proxy Read Timeout de 120 s. Medido con peticiones frías directas (relleno único, sin caché de prompt; 2026-10-01): 208.036 tokens (~960 KB de cuerpo) respondió en 12,9 s mientras que ~220k y ~286k tokens devolvieron **HTTP 524 `origin_response_timeout`** a los ~126 s; los mismos tamaños con caché cálida responden en ~10 s. El techo práctico para peticiones frías queda por tanto muy por debajo de las ventanas declaradas. Desde 1.0.0 el provider reclasifica un 524 en una petición estimada por encima de 200.000 tokens (`NAN_COLD_CACHE_CEILING_TOKENS`) como desbordamiento de contexto para que pi compacte y reintente en vez de quedarse colgado; un 524 en una petición menor se deja intacto (timeout transitorio genuino).
@@ -480,16 +486,22 @@ El parámetro `reasoning_effort` de NaN controla cuánto piensa el modelo antes
480
486
 
481
487
  | Modelo | Effort de razonamiento | Cómo funciona |
482
488
  | :--- | :--- | :--- |
483
- | `glm5.3` | `low` · `medium` · `high` · `max` | Completamente controlable — valores más altos permiten al modelo razonar más. `thinking: "off"` envía `low`, el nivel más bajo que listan los docs de NaN, vía el `thinkingLevelMap` del catálogo. `minimal` **no** está entre los valores declarados de este modelo: el issue #16 lo midió solo en `glm5.3-flash`, y `glm5.3` en sí nunca se midió |
484
- | `glm5.3-flash` | `minimal` · `low` · `medium` · `high` · `max` | Completamente controlable — valores más altos permiten al modelo razonar más; `minimal` produce ~38 tokens de razonamiento (issue #16, medido 2026-09-27). `none` NO suprime el razonamiento (13,382 tokens), así que `thinking: "off"` envía `minimal`, el valor efectivo más bajo, vía el `thinkingLevelMap` del catálogo |
485
- | `qwen3.6`, `gemma4` | `none` · `minimal` · `low` · `medium` · `high` · `max` | `none`/`minimal` omiten el razonamiento por completo; otros valores limitan a 2K / 8K / 16K / 32K tokens. `thinking: "off"` envía `reasoning_effort: "none"` automáticamente vía el `thinkingLevelMap` del catálogo — los docs de NaN dicen que sin parámetro estos modelos razonan por defecto (presupuesto de 16,384 tokens), así que `off` debe ser explícito |
486
- | `deepseek-v4-flash` | `none` (el catálogo declara ["none"]) | `none` deshabilita el razonamiento (0 tokens de razonamiento, respuesta completa); cualquier otro valor — incluido `minimal` y omitir el parámetro — lo deja ENCENDIDO (57 / 63 / 109 tokens de razonamiento), así que el catálogo solo declara `none`. Re-sondado en vivo 2026-10-14: los docs de NaN afirman "any value (no effect)", pero gana la medición. `thinking: "off"` envía `reasoning_effort: "none"` automáticamente vía el `thinkingLevelMap` del catálogo — sin él el modelo se descontrola hasta `finish_reason: "length"` sin respuesta (issue #16) |
487
- | `qwen3.8-flash` | *(aceptado pero no ajustable)* | El parámetro es aceptado y nunca rechazado, pero el modelo gestiona su propia profundidad de razonamiento — nunca es un error enviar un valor que este modelo no ajusta |
488
- | `kimi-k3.1-pro`, `qwen3.8-max`, `deepseek-v4-pro`, `hy4` | *(sin mapeo declarado)* | Modelos de proveedor externo lanzados el 2026-11-10; no se ha medido cómo traduce la pasarela `reasoning_effort` para ellos, así que el catálogo no declara valores de effort ni `thinkingLevelMap` (`thinking: "off"` no envía ningún parámetro) |
489
- | `mimo-v2.6-flash` | `none` | Los docs lo llamaban "profundidad no ajustable", pero el gateway en vivo (2026-10-14) muestra que `none` da 0 tokens de razonamiento con respuesta completa mientras `low` da 22 y omitirlo 17 — así que `thinking: "off"` envía `reasoning_effort: "none"` vía el `thinkingLevelMap` del catálogo |
489
+ | `glm5.3`, `glm5.3-flash` | `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | GLM no puede parar de razonar: los docs aplican `none` como `minimal`, su razonamiento más corto (unos pocos tokens), así que `thinking: "off"` envía `minimal` vía el `thinkingLevelMap` del catálogo. Valores más altos razonan más antes de responder. `glm5.3-flash` se midió en ~38 tokens de razonamiento con `minimal` (issue #16, 2026-09-27); `none` no lo suprime |
490
+ | `qwen3.6`, `gemma4` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none`/`minimal` omiten el razonamiento por completo; el resto limita la fase de razonamiento a 2K / 8K / 16K / 32K tokens. `thinking: "off"` envía `reasoning_effort: "none"` automáticamente vía el `thinkingLevelMap` del catálogo — los docs de NaN dicen que sin parámetro estos modelos razonan por defecto (presupuesto de 16,384 tokens), así que `off` debe ser explícito |
491
+ | `deepseek-v4-flash` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none` deshabilita el razonamiento (0 tokens de razonamiento, respuesta completa); cualquier otro valor solo lo dirige — medido: 57 tokens de razonamiento con `low`, 63 omitiendo el parámetro y 109 con `minimal` (issue #16, re-sondado en vivo 2026-10-14). `thinking: "off"` envía `reasoning_effort: "none"` vía el `thinkingLevelMap` del catálogo — sin él el modelo se descontrola hasta `finish_reason: "length"` sin respuesta |
492
+ | `qwen3.8-flash` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | El razonamiento está encendido por defecto (`none` lo apaga, el resto dirige su profundidad). `thinking: "off"` envía `reasoning_effort: "none"`; su presupuesto se limita con `max_completion_tokens` (issue #34), y hay un tope duro de razonamiento vía `thinking_budget` |
493
+ | `qwen4-max` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none` apaga el razonamiento, `minimal` a `max` lo dirigen, y `max_tokens` limita razonamiento **más** respuesta. Los docs recomiendan fijar un presupuesto: una respuesta abierta puede tardar muchos minutos |
494
+ | `mimo-v2.6-flash` | `none` · `low` · `medium` · `high` · `max` | `none` apaga el razonamiento (`minimal` se aplica como `low` y `xhigh` como `max`, así que esos dos no se declaran aparte); el razonamiento cuenta dentro de `max_tokens`. Medido en vivo 2026-10-14: `none` da 0 tokens de razonamiento con respuesta completa |
495
+ | `qwen3.8-max` | `none` | `none` apaga el razonamiento. `max_tokens` solo limita la respuesta visible, así que el catálogo envía `max_completion_tokens` para cubrir el total. Un presupuesto de razonamiento (`thinking_budget`) no se respeta en este modelo |
496
+ | `hy4` | `none` | Razona por defecto — la pasarela aplica `low` cuando la petición no nombra ningún nivel, y tu valor siempre gana. `none` lo apaga. `max_tokens` limita razonamiento más respuesta |
497
+ | `hy4-flash` | `none` | Razona por defecto sin nivel por defecto; `reasoning_effort: "none"` lo apaga (ignora `enable_thinking`). `max_tokens` limita razonamiento más respuesta, así que uno pequeño puede volver vacío |
498
+ | `kimi-k3.1-pro`, `deepseek-v4-pro` | *(sin mapeo declarado)* | Los docs dejan a estos dos fuera del contrato de razonamiento y dicen que los alias de `none` **no están mapeados** en ellos, así que el catálogo no declara valores de effort ni `thinkingLevelMap`: `thinking: "off"` no envía ningún parámetro y decide el modelo |
499
+
500
+ > [!NOTE]
501
+ > **`xhigh` y `max` son opt-in en pi.** pi-ai solo ofrece esos dos niveles a un modelo cuando su `thinkingLevelMap` los declara (`getSupportedThinkingLevels`; si no, una petición de cualquiera de los dos se degrada en silencio a `high`). Por eso el catálogo lleva entradas de identidad (`xhigh: "xhigh"`, `max: "max"`) en todos los modelos cuya doc declara una escalera hasta `max` — los siete modelos de chat más `mimo-v2.6-flash`, donde la pasarela aplica `xhigh` como `max`. `hy4`, `hy4-flash` y `qwen3.8-max` solo documentan su interruptor de apagado, y `kimi-k3.1-pro`/`deepseek-v4-pro` están fuera del contrato, así que esos cinco se quedan en `off`…`high`.
490
502
 
491
503
  > [!NOTE]
492
- > `maxTokens` NO limita la fase de razonamiento en los modelos de NaN. La fase de razonamiento corre hasta completarse (o se corta en el límite de stream solo-razonamiento de NaN: 45.000 caracteres de razonamiento, o 420 s sin salida visible) independientemente de `maxTokens` — medido: `max_tokens=512` en deepseek-v4-flash aún consumió 13,376 tokens de completación, todos de razonamiento (26x el techo). Este es un comportamiento del gateway confirmado por el issue #16 (medido 2026-09-27) y por NaN para `qwen3.8-flash` (issue #34, 2026-11-11 — el exceso además factura contra la cuota). Como límite provisional para `qwen3.8-flash` el catálogo envía `max_completion_tokens`, que NaN confirmó que SÍ se respeta; sobrevive porque la compat de ese modelo desactiva el renombrado a `max_tokens` del sanitizador de esquema (su OpenAPI publicado solo documenta `max_tokens`). Retira ese override cuando NaN publique el arreglo en su gateway — `test/issue-34-max-completion-tokens.test.ts` es el tripwire. Solo el razonamiento aún puede agotar el presupuesto completo y cerrar el turno con contenido vacío; ese corte lleva el marcador `reasoning_only_stream` de NaN y pi-ai reintenta el turno (issue #21).
504
+ > `maxTokens` NO limita la fase de razonamiento en `deepseek-v4-flash`, `glm5.3`, `glm5.3-flash`, `qwen3.8-flash`, `mimo-v2.6-flash`, `qwen3.8-max` ni `kimi-k3.1-pro`. La fase de razonamiento corre hasta completarse (o se corta en el límite de stream solo-razonamiento de NaN: 45.000 caracteres de razonamiento, o 420 s sin salida visible) independientemente del presupuesto — medido: `max_tokens=512` en deepseek-v4-flash aún consumió 13,376 tokens de completación, todos de razonamiento (26x el techo). Este es un comportamiento del gateway confirmado por el issue #16 (medido 2026-09-27) y por NaN para `qwen3.8-flash` (issue #34, 2026-11-11 — el exceso además factura contra la cuota). Los docs del 2026-11-17 añaden los modelos donde el presupuesto **sí** cubre el total, razonamiento más respuesta: `qwen4-max` (hasta 131.000), `hy4-flash` y `hy4` (hasta 64.000), y `mimo-v2.6-flash`. Como límite provisional para `qwen3.8-flash` **y `qwen3.8-max`** el catálogo envía `max_completion_tokens`, que NaN confirmó que SÍ se respeta; sobrevive porque la compat de esos modelos desactiva el renombrado a `max_tokens` del sanitizador de esquema (el OpenAPI publicado solo documenta `max_tokens`). Retira esos overrides cuando NaN publique el arreglo en su gateway — `test/issue-34-max-completion-tokens.test.ts` es el tripwire. Solo el razonamiento aún puede agotar el presupuesto completo y cerrar el turno con contenido vacío; ese corte lleva el marcador `reasoning_only_stream` de NaN y pi-ai reintenta el turno (issue #21).
493
505
 
494
506
  ## 🚀 Desarrollo
495
507
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @gtrabanco/𝜋-nan-provider
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![Version](https://img.shields.io/badge/version-1.5.5-blue)](https://github.com/gtrabanco/pi-nan-provider/releases)
4
+ [![Version](https://img.shields.io/badge/version-1.5.6-blue)](https://github.com/gtrabanco/pi-nan-provider/releases)
5
5
  [![Built with NaN](https://nan.builders/badge/built-with-nan-compact.svg)](https://cloud.nan.builders/r/7GK06FX8)
6
6
 
7
7
  [NaN Builders](https://cloud.nan.builders/r/7GK06FX8) model provider + a native MCP server for [pi](https://github.com/earendil-works/pi).
@@ -438,18 +438,24 @@ Chat models:
438
438
  | `mimo-v2.6-flash` | 1,048,576 | 131,072 | text, image | ✅ |
439
439
  | `glm5.3-flash` | 1,048,576 | 131,072 | text, image | ✅ |
440
440
  | `qwen3.8-flash` | 1,048,576 | 131,072 | text, image | ✅ |
441
- | `glm5.3` | 1,048,576 | 131,072 | text, image | ✅ |
442
- | `kimi-k3.1-pro` | 1,048,576 | 32,768 | text, image | ✅ |
443
- | `qwen3.8-max` | 1,000,000 | 32,768 | text, image | ✅ |
444
- | `deepseek-v4-pro` | 1,048,576 | 32,768 | text | ✅ |
445
- | `hy4` | 1,048,576 | 32,768 | text, image | ✅ |
441
+ | `glm5.3` | 1,048,576 | 131,072 | text | ✅ |
442
+ | `hy4-flash` | 1,048,576 | 65,536 | text, image | ✅ |
443
+ | `hy4` | 1,048,576 | 65,536 | text, image | ✅ |
444
+ | `kimi-k3.1-pro` | 1,048,576 | 1,048,576 | text, image | ✅ |
445
+ | `qwen3.8-max` | 1,000,000 | 131,072 | text, image | ✅ |
446
+ | `qwen4-max` | 1,000,000 | 131,072 | text, image | ✅ |
447
+ | `deepseek-v4-pro` | 1,048,576 | 393,216 | text | ✅ |
446
448
 
447
449
  > [!NOTE]
448
- > Context windows above are the **documented** windows from [the NaN docs](https://nan.builders/docs/models) (checked 2026-10-14), which are the source of truth; models.dev is a downstream mirror a human updates later and may lag. `glm5.3` was premium-only and live-only until NaN removed tier-exclusive models on 2026-11-10; it now ships in the static catalog with the values it carried (text+image, 1,048,576 / 131,072).
450
+ > Context windows and max output above are the **documented** values from [the NaN docs](https://nan.builders/docs/models) (checked 2026-11-17), which are the source of truth; models.dev is a downstream mirror a human updates later and may lag. `glm5.3` was premium-only and live-only until NaN removed tier-exclusive models on 2026-11-10; it now ships in the static catalog, **text only** (an image, audio, video or file part — or an earlier turn carrying one — answers `400`, so start a new session or switch models).
449
451
  >
450
- > `kimi-k3.1-pro`, `qwen3.8-max`, `deepseek-v4-pro` and `hy4` are NaN's external-provider (ZDR) models launched on 2026-11-10. NaN's docs and OpenAPI do not list them yet, but the live `GET /v1/models` does (checked 2026-11-10). Their values come from NaN's pricing page ("1M context"), the NaN pi docs (`maxTokens` 32,768 for every 1M-context model) and the first-party vendor entries on models.dev (modalities; `qwen3.8-max` uses the vendor's 1,000,000 window); cost is 0 and no `reasoning_effort` mapping is declared, because how the gateway handles it for external providers is unmeasured. Each entry carries its provenance note in `scripts/models.generated.ts`.
452
+ > The **larger models** — `kimi-k3.1-pro`, `qwen3.8-max`, `qwen4-max`, `deepseek-v4-pro`, `hy4`, `hy4-flash` — are the ones NaN bills as "larger model" (they use credits faster). The four that entered the catalog on 2026-11-10 were carrying a flat 32,768 max output and no reasoning mapping because the docs did not document them yet; since 2026-11-17 each one declares its own "Max answer" and its documented reasoning behaviour. `qwen4-max` and `hy4-flash` are new ids the catalog did not have (models.dev provider `nan` lists neither; the live `/models` and the docs do). Maximum output is a ceiling, not a request: pi-ai clamps the outgoing budget to the room left in the context window (`clampMaxTokensToContext`), so a 1M-token ceiling on `kimi-k3.1-pro` never turns into an over-context `max_tokens`.
451
453
  >
452
- > `*` deepseek-v4-flash max output 32,768 is the ceiling from the official NaN pi docs (https://nan.builders/docs/pi, "the same set the NaN CLI writes", issue #20, 2026-10-02); models.dev still lists 384,000 but the gateway rejects `max_tokens` above ~256k with 403.
454
+ > `qwen3.8-max` sends `max_completion_tokens` instead of `max_tokens`, and `qwen3.8-flash` does the same: on those two the docs state that `max_tokens` bounds only the visible answer while the reasoning bills on top of it, so the client budget must cap the total (issue #34).
455
+ >
456
+ > Every catalog model reports **cost 0**: NaN bills a credit pool (1 credit ≈ 0.026 €), not per-token USD, so pi's cost estimate has nothing to report. models.dev provider `nan` started publishing a derived USD conversion on 2026-11-17; the catalog does not adopt it, because pi would show that estimate as real money. Use `/nan-usage` for the real consumption.
457
+ >
458
+ > `*` deepseek-v4-flash max output 32,768 is the ceiling from the official NaN pi docs (https://nan.builders/docs/pi, "the same set the NaN CLI writes", issue #20, 2026-10-02); models.dev lists 384,000 but the gateway rejects `max_tokens` above ~256k with 403. `gemma4` keeps models.dev's 32,768: the docs' 65,536 in the pi/OpenCode blocks is described there as "a client-side budget rather than a server cap", so the smaller value stays rather than risking a `400`.
453
459
  >
454
460
  > **Cold prompt cache practical ceiling (issue #18).** The context windows above are the models' real windows, but the api.nan.builders edge (Cloudflare) aborts responses past its 120 s Proxy Read Timeout. Measured with direct cold requests (unique filler, no prompt cache; 2026-10-01): 208,036 tokens (~960 KB body) answered in 12.9 s while ~220k and ~286k tokens returned **HTTP 524 `origin_response_timeout`** at ~126 s; the same sizes with a warm prompt cache answer in ~10 s. The practical ceiling for cold requests is therefore well below the declared windows. Since 1.0.0 the provider reclassifies a 524 on an estimated over-200,000-token request (`NAN_COLD_CACHE_CEILING_TOKENS`) as a context overflow so pi compacts and retries instead of wedging; a 524 on a smaller request is left alone (genuine transient timeout).
455
461
 
@@ -476,15 +482,21 @@ NaN's `reasoning_effort` parameter controls how much the model thinks before ans
476
482
 
477
483
  | Model | Reasoning effort | How it works |
478
484
  | :--- | :--- | :--- |
479
- | `glm5.3` | `low` · `medium` · `high` · `max` | Fully controllable — higher values let the model reason longer. `thinking: "off"` sends `low`, the shallowest level the NaN docs list, via the catalog's `thinkingLevelMap`. `minimal` is **not** in this model's declared values: issue #16 measured it on `glm5.3-flash` only, and `glm5.3` itself was never measured |
480
- | `glm5.3-flash` | `minimal` · `low` · `medium` · `high` · `max` | Fully controllable — higher values let the model reason longer; `minimal` yields ~38 reasoning tokens (issue #16, measured 2026-09-27). `none` does NOT suppress reasoning (13,382 tokens), so `thinking: "off"` sends `minimal`, the shallowest effective value, via the catalog's `thinkingLevelMap` |
481
- | `qwen3.6`, `gemma4` | `none` · `minimal` · `low` · `medium` · `high` · `max` | `none`/`minimal` skip reasoning entirely; others cap at 2K / 8K / 16K / 32K tokens. `thinking: "off"` sends `reasoning_effort: "none"` automatically via the catalog's `thinkingLevelMap` — the NaN docs state that with no parameter these models reason by default (16,384-token budget), so off must be explicit |
482
- | `deepseek-v4-flash` | `none` (catalog declares ["none"]) | `none` disables reasoning (0 reasoning tokens, a full answer); every other value — including `minimal` and omitting the parameter — leaves it ON (57 / 63 / 109 reasoning tokens), so the catalog declares only `none`. Re-probed live 2026-10-14: the NaN docs claim "any value (no effect)", but the measurement wins. `thinking: "off"` sends `reasoning_effort: "none"` automatically via the catalog's `thinkingLevelMap` — without it the model runs away to `finish_reason: "length"` with no answer (issue #16) |
483
- | `qwen3.8-flash` | *(accepted but not adjustable)* | The parameter is accepted and never rejected, but the model manages its own reasoning depth — it is never an error to send a value this model doesn't adjust |
484
- | `kimi-k3.1-pro`, `qwen3.8-max`, `deepseek-v4-pro`, `hy4` | *(no mapping declared)* | External-provider models launched 2026-11-10; how the gateway translates `reasoning_effort` for them is unmeasured, so the catalog declares no effort values and no `thinkingLevelMap` (`thinking: "off"` sends no parameter) |
485
- | `mimo-v2.6-flash` | `none` | The docs called this "depth not adjustable", but the live gateway (2026-10-14) shows `none` gives 0 reasoning tokens with a full answer while `low` gives 22 and omitting the parameter 17 — so `thinking: "off"` sends `reasoning_effort: "none"` via the catalog's `thinkingLevelMap` |
485
+ | `glm5.3`, `glm5.3-flash` | `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | GLM cannot stop reasoning: the docs apply `none` as `minimal`, its shortest reasoning (a few tokens), so `thinking: "off"` sends `minimal` via the catalog's `thinkingLevelMap`. Higher values reason longer before answering. `glm5.3-flash` was measured at ~38 reasoning tokens for `minimal` (issue #16, 2026-09-27); `none` does not suppress it |
486
+ | `qwen3.6`, `gemma4` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none`/`minimal` skip reasoning entirely; the others cap the reasoning phase at 2K / 8K / 16K / 32K tokens. `thinking: "off"` sends `reasoning_effort: "none"` automatically via the catalog's `thinkingLevelMap` — the NaN docs state that with no parameter these models reason by default (16,384-token budget), so off must be explicit |
487
+ | `deepseek-v4-flash` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none` disables reasoning (0 reasoning tokens, a full answer); every other value only steers it — measured 57 reasoning tokens for `low`, 63 for omitting the parameter, 109 for `minimal` (issue #16, re-probed live 2026-10-14). `thinking: "off"` sends `reasoning_effort: "none"` via the catalog's `thinkingLevelMap` — without it the model runs away to `finish_reason: "length"` with no answer |
488
+ | `qwen3.8-flash` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | Reasoning is on by default (`none` turns it off, the rest steer its depth). `thinking: "off"` sends `reasoning_effort: "none"`; its budget is capped with `max_completion_tokens` (issue #34), and a hard reasoning cap is available through `thinking_budget` |
489
+ | `qwen4-max` | `none` · `minimal` · `low` · `medium` · `high` · `xhigh` · `max` | `none` turns reasoning off, `minimal` to `max` steer it, and `max_tokens` bounds reasoning **plus** answer. The docs advise setting a budget: an open-ended answer can run for many minutes |
490
+ | `mimo-v2.6-flash` | `none` · `low` · `medium` · `high` · `max` | `none` turns reasoning off (`minimal` is applied as `low`, `xhigh` as `max`, so those two are not declared separately); reasoning counts inside `max_tokens`. Measured live 2026-10-14: `none` gives 0 reasoning tokens with a full answer |
491
+ | `qwen3.8-max` | `none` | `none` turns reasoning off. `max_tokens` bounds only the visible answer, so the catalog sends `max_completion_tokens` to cap the total. A reasoning budget (`thinking_budget`) is not honoured on this model |
492
+ | `hy4` | `none` | Reasons by default — the gateway applies `low` when the request names no level, and your own value always wins. `none` turns it off. `max_tokens` bounds reasoning plus answer |
493
+ | `hy4-flash` | `none` | Reasons by default with no default level; `reasoning_effort: "none"` turns it off (it ignores `enable_thinking`). `max_tokens` bounds reasoning plus answer, so a small one can come back empty |
494
+ | `kimi-k3.1-pro`, `deepseek-v4-pro` | *(no mapping declared)* | The docs keep these two out of the reasoning contract and state that the `none` aliases are **not mapped** on them, so the catalog declares no effort values and no `thinkingLevelMap`: `thinking: "off"` sends no parameter and the model decides |
495
+
496
+ > [!NOTE]
497
+ > **`xhigh` and `max` are opt-in in pi.** pi-ai only offers a model those two levels when its `thinkingLevelMap` declares them (`getSupportedThinkingLevels`; a request for either one is otherwise silently clamped to `high`). The catalog therefore carries identity entries (`xhigh: "xhigh"`, `max: "max"`) on every model whose docs declare a ladder up to `max` — the seven chat models plus `mimo-v2.6-flash`, where the gateway applies `xhigh` as `max`. `hy4`, `hy4-flash` and `qwen3.8-max` document only their off switch, and `kimi-k3.1-pro`/`deepseek-v4-pro` sit outside the contract, so those five stay at `off`…`high`.
486
498
  > [!NOTE]
487
- > `maxTokens` does NOT bound the reasoning phase on NaN models. The reasoning phase runs to completion (or is cut at NaN's reasoning-only stream limit: 45,000 reasoning characters, or 420 s without visible output) regardless of `maxTokens` — measured: `max_tokens=512` on deepseek-v4-flash still consumed 13,376 completion tokens, all reasoning (26x the ceiling). This is gateway behavior confirmed by issue #16 (measured 2026-09-27) and by NaN for `qwen3.8-flash` (issue #34, 2026-11-11 — the excess also bills against the quota). As an interim bound for `qwen3.8-flash` the catalog sends `max_completion_tokens` instead, which NaN confirmed IS respected; it survives because that model's compat opts out of the schema sanitizer's rename to `max_tokens` (its published OpenAPI schema still documents only `max_tokens`). Remove that override once NaN ships their gateway fix — `test/issue-34-max-completion-tokens.test.ts` is the tripwire. Reasoning alone can still consume the whole budget and end the turn with empty content; that closure carries NaN's `reasoning_only_stream` marker and pi-ai retries the turn (issue #21).
499
+ > `maxTokens` does NOT bound the reasoning phase on `deepseek-v4-flash`, `glm5.3`, `glm5.3-flash`, `qwen3.8-flash`, `mimo-v2.6-flash`, `qwen3.8-max` or `kimi-k3.1-pro`. The reasoning phase runs to completion (or is cut at NaN's reasoning-only stream limit: 45,000 reasoning characters, or 420 s without visible output) regardless of the budget — measured: `max_tokens=512` on deepseek-v4-flash still consumed 13,376 completion tokens, all reasoning (26x the ceiling). This is gateway behavior confirmed by issue #16 (measured 2026-09-27) and by NaN for `qwen3.8-flash` (issue #34, 2026-11-11 — the excess also bills against the quota). The 2026-11-17 docs add the models where the budget **does** bound the total, reasoning plus answer: `qwen4-max` (up to 131,000), `hy4-flash` and `hy4` (up to 64,000), and `mimo-v2.6-flash`. As an interim bound for `qwen3.8-flash` **and `qwen3.8-max`** the catalog sends `max_completion_tokens` instead, which NaN confirmed IS respected; it survives because those models' compat opts out of the schema sanitizer's rename to `max_tokens` (the published OpenAPI schema still documents only `max_tokens`). Remove those overrides once NaN ships their gateway fix — `test/issue-34-max-completion-tokens.test.ts` is the tripwire. Reasoning alone can still consume the whole budget and end the turn with empty content; that closure carries NaN's `reasoning_only_stream` marker and pi-ai retries the turn (issue #21).
488
500
 
489
501
 
490
502
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtrabanco/pi-nan-provider",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "NaN Builders (api.nan.builders) model provider for pi - OpenAI-compatible registration with a models.dev-generated fallback, tier-aware live catalog, and an optional community media MCP bridge",
5
5
  "keywords": [
6
6
  "pi",
@@ -37,27 +37,7 @@
37
37
  import type { GeneratedModelEntry } from "../src/fetch-models.ts";
38
38
  import { NON_CHAT_MODEL_IDS } from "../src/fetch-models.ts";
39
39
  import type { ManualModelOverride } from "./manual-overrides.ts";
40
- import {
41
- MANUAL_OVERRIDES,
42
- MANUAL_ONLY_MODEL_IDS,
43
- REASONING_EFFORT_VALUES,
44
- } from "./manual-overrides.ts";
45
-
46
- /**
47
- * Reasoning effort values sourced from the NaN docs (https://nan.builders/docs/models
48
- * #controlling-reasoning, checked 2026-09-25). models.dev has no reasoning_effort_values
49
- * field — only reasoning_options which is [{type:"toggle"}] or [] — so the actual
50
- * effort levels must be hand-maintained from the docs. An empty array means the
51
- * parameter is accepted but depth is not adjustable by the user.
52
- */
53
- const REASONING_EFFORT_VALUES_FROM_DOCS: Record<string, string[]> = {
54
- ...REASONING_EFFORT_VALUES,
55
- // deepseek-v4-flash: any value (no effect) — model decides per request
56
- "deepseek-v4-flash": [],
57
- // qwen3.8-flash, mimo-v2.6-flash: accepted, depth not adjustable
58
- "qwen3.8-flash": [],
59
- "mimo-v2.6-flash": [],
60
- };
40
+ import { MANUAL_OVERRIDES, MANUAL_ONLY_MODEL_IDS } from "./manual-overrides.ts";
61
41
 
62
42
  const MODELS_DEV_API_URL = "https://models.dev/api.json";
63
43
  const SOURCE_PROVIDER_ID = "nan";
@@ -150,6 +130,22 @@ const NAN_COMPAT = {
150
130
  maxTokensField: "max_tokens" as "max_tokens" | "max_completion_tokens",
151
131
  };
152
132
 
133
+ /**
134
+ * Catalog cost for every chat model: zero, by maintainer decision. NaN bills a
135
+ * credit pool (1 credit ≈ 0.026 €) and not per-token USD, so pi's per-token
136
+ * cost estimate has nothing to report here. models.dev provider "nan" started
137
+ * publishing a DERIVED USD conversion on 2026-11-17 (deepseek-v4-flash
138
+ * 0.29484 / 1.17936, glm5.3 1.37592 / 4.32432, …) which is not a price NaN
139
+ * charges; adopting it would make pi display an estimate as real money for a
140
+ * credit-based gateway. A model with a confirmed per-token price can still
141
+ * override it through MANUAL_OVERRIDES.cost; to adopt models.dev's numbers for
142
+ * everything, delete this constant and read `m.cost` in convertModel.
143
+ */
144
+ const NAN_CATALOG_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } as const;
145
+
146
+ const NAN_COST_NOTE =
147
+ "cost 0 on every model: NaN bills a credit pool (1 credit ≈ 0.026 €) rather than per-token USD, so pi's per-token cost estimate does not apply. models.dev provider nan started publishing a derived USD conversion on 2026-11-17; it is not a price NaN charges, so it is not adopted (delete NAN_CATALOG_COST in scripts/generate-models.ts to adopt it).";
148
+
153
149
  const NAN_COMPAT_NOTE =
154
150
  "compat matches the maintainer's working ~/.pi/agent/models.json LiteLLM config for api.nan.builders (2026-09-04): supportsDeveloperRole false, supportsReasoningEffort true, maxTokensField max_tokens. NaN's docs example sets only supportsDeveloperRole: true and is not battle-tested. supportsFinishReason true (2026-09-13, issue #2): the LiteLLM gateway intermittently closes SSE streams before emitting finish_reason; with true pi-ai raises 'Stream ended without finish_reason', which matches pi-ai's retryable-provider pattern ('ended without') and is retried automatically, whereas false silently synthesized stop/toolUse and stalled the turn mid-answer. supportsUsageInStreaming true (2026-09-16, issue #7): NaN's published schema is silent about stream_options, but the live gateway honors it — two identical streaming calls per model, differing only in stream_options: { include_usage: true }, returned 0 usage chunks without it and exactly 1 with it (prompt/completion/reasoning/cached token counts) on deepseek-v4-flash, glm5.3-flash, qwen3.6, mimo-v2.5 and gemma4, and a real pi session then recorded token counts where it recorded zeros. pi-ai only sends stream_options when this is not false, and the sanitizer forwards it when the model declares true, so chat models opt in by default and usage is reported (issue #4). A model that does not report streaming usage can still opt out per model with a models.json compat override (supportsUsageInStreaming: false); the sanitizer then strips stream_options and the payload stays strict.";
155
151
 
@@ -216,10 +212,7 @@ function buildManualOnlyModelEntry(
216
212
  detail: string,
217
213
  override: ManualModelOverride | undefined,
218
214
  ): GeneratedModel {
219
- const reasoningEffortValues =
220
- override?.reasoningEffortValues ??
221
- REASONING_EFFORT_VALUES_FROM_DOCS[modelId] ??
222
- undefined;
215
+ const reasoningEffortValues = override?.reasoningEffortValues ?? undefined;
223
216
 
224
217
  return {
225
218
  entry: {
@@ -227,7 +220,7 @@ function buildManualOnlyModelEntry(
227
220
  name: override?.name ?? modelId,
228
221
  reasoning: override?.reasoning ?? true,
229
222
  input: override?.input ?? ["text", "image"],
230
- cost: override?.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
223
+ cost: override?.cost ?? { ...NAN_CATALOG_COST },
231
224
  contextWindow: override?.contextWindow ?? 1_048_576,
232
225
  maxTokens: override?.maxTokens ?? 131_072,
233
226
  reasoningEffortValues,
@@ -235,6 +228,7 @@ function buildManualOnlyModelEntry(
235
228
  compat: buildCompat(override),
236
229
  notes: [
237
230
  NAN_COMPAT_NOTE,
231
+ NAN_COST_NOTE,
238
232
  `manual-only: "${modelId}" not yet on models.dev provider nan (${detail}).`,
239
233
  ...(override ? [override.note] : []),
240
234
  ],
@@ -270,11 +264,11 @@ function convertModel(modelId: string, m: ModelsDevModel): GeneratedModel | { sk
270
264
  }
271
265
 
272
266
  // Reasoning effort values sourced from the NaN docs (models.dev does not
273
- // expose them — only reasoning_options: [{type:"toggle"}] or []).
274
- // An empty array means the parameter is accepted but depth is not
275
- // adjustable by the user; the model manages its own reasoning depth.
276
- const reasoningEffortValues =
277
- override?.reasoningEffortValues ?? REASONING_EFFORT_VALUES_FROM_DOCS[modelId] ?? undefined;
267
+ // expose them — only reasoning_options: [{type:"toggle"}] or []). They live
268
+ // on MANUAL_OVERRIDES next to their provenance note: one source, no fallback
269
+ // map in this generator. An empty array means the parameter is accepted but
270
+ // depth is not adjustable by the user; the model manages its own reasoning.
271
+ const reasoningEffortValues = override?.reasoningEffortValues ?? undefined;
278
272
 
279
273
  return {
280
274
  entry: {
@@ -282,12 +276,7 @@ function convertModel(modelId: string, m: ModelsDevModel): GeneratedModel | { sk
282
276
  name: override?.name ?? m.name ?? modelId,
283
277
  reasoning: override?.reasoning ?? m.reasoning === true,
284
278
  input,
285
- cost: override?.cost ?? {
286
- input: m.cost?.input ?? 0,
287
- output: m.cost?.output ?? 0,
288
- cacheRead: m.cost?.cache_read ?? 0,
289
- cacheWrite: m.cost?.cache_write ?? 0,
290
- },
279
+ cost: override?.cost ?? { ...NAN_CATALOG_COST },
291
280
  contextWindow: override?.contextWindow ?? contextWindow,
292
281
  maxTokens: override?.maxTokens ?? maxTokens,
293
282
  reasoningEffortValues,
@@ -295,6 +284,7 @@ function convertModel(modelId: string, m: ModelsDevModel): GeneratedModel | { sk
295
284
  compat: buildCompat(override),
296
285
  notes: [
297
286
  NAN_COMPAT_NOTE,
287
+ NAN_COST_NOTE,
298
288
  ...(override ? [override.note] : []),
299
289
  ...(MANUAL_NOTES[modelId] ? [MANUAL_NOTES[modelId]!] : []),
300
290
  ],