@gtrabanco/pi-nan-provider 1.5.7 → 1.6.0
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 +51 -4
- package/README.es.md +38 -12
- package/README.md +34 -11
- package/package.json +3 -3
- package/scripts/models.generated.ts +8 -8
- package/src/cache-anomaly.ts +26 -2
- package/src/debug-command.ts +4 -1
- package/src/debug-report.ts +465 -18
- package/src/provider-factory.ts +9 -2
- package/src/response-rays.ts +140 -0
package/AGENTS.md
CHANGED
|
@@ -416,8 +416,44 @@ Since 1.0.0 the package version **aligns its MAJOR.MINOR with the pi release lin
|
|
|
416
416
|
`src/reasoning-only-stream-guard.ts` (issue #21) keys on that marker;
|
|
417
417
|
earlier comment/message text said "60,000 characters" and was corrected to
|
|
418
418
|
the documented figures.
|
|
419
|
-
- **pi 1.
|
|
420
|
-
baseline
|
|
419
|
+
- **pi 1.6.0 / pi-ai 1.6.0 compat** (verified 2026-11-21, the current verified
|
|
420
|
+
baseline; devDependencies 1.5.1 → 1.6.0, package 1.5.8 → 1.6.0, peer range
|
|
421
|
+
unchanged at `^1.4.0` because nothing here needs 1.6.0). **No `src/` change:** pi-ai
|
|
422
|
+
`dist/index.d.ts`, `dist/compat.d.ts`, `dist/api/openai-completions.d.ts` and
|
|
423
|
+
pi-coding-agent `dist/index.d.ts` are byte-identical to 1.5.1, and a base-vs-change
|
|
424
|
+
capture of every catalog model × `off`/`low`/`max` (tool history + thinking blocks
|
|
425
|
+
included) is byte-identical on the wire. What DID move, and why it does or does not
|
|
426
|
+
touch this package:
|
|
427
|
+
- `detectCompat()` now defaults `supportsDeveloperRole` to **true only for
|
|
428
|
+
api.openai.com** (#10741), sending `system` everywhere else. The generated catalog
|
|
429
|
+
pins `supportsDeveloperRole: false` per entry, so NaN's wire never moved — pinned by
|
|
430
|
+
`test/pi-ai-1-6-0-contract.test.ts`.
|
|
431
|
+
- `parseChunkUsage` falls back to a **top-level `usage.reasoning_tokens`** when
|
|
432
|
+
`completion_tokens_details.reasoning_tokens` is absent (0 on 1.5.1). NaN reports the
|
|
433
|
+
nested field, so this is tolerance only.
|
|
434
|
+
- `RETRYABLE_PROVIDER_ERROR_PATTERN` gains `connection.?closed`, bare
|
|
435
|
+
`ECONNRESET|ECONNABORTED|ECONNREFUSED|ETIMEDOUT|EPIPE` (lookaround-guarded),
|
|
436
|
+
`connection reset by peer` and the Codex websocket lifetime text (#12064, #12128,
|
|
437
|
+
#12124). Directly relevant to NaN's LiteLLM gateway, which closes SSE streams
|
|
438
|
+
mid-turn (issue #2): those drops are now retried with no package change. The
|
|
439
|
+
deterministic NaN 400 stays non-retryable.
|
|
440
|
+
- `constrained-sampling.js` rejects schema nodes without `type` in strict mode
|
|
441
|
+
(#12049). Unreachable for NaN: `openai-completions` keeps
|
|
442
|
+
`supportsStrictMode: false` in `detectCompat()`, so no `strict` field is ever sent
|
|
443
|
+
(pinned by the same contract test). The `supportsStrictMode` compat key itself is
|
|
444
|
+
documented and added to the Mistral schema only.
|
|
445
|
+
- pi-coding-agent: the **breaking** change (extension components `render()` returning
|
|
446
|
+
`readonly string[]`) does not apply — this package registers no TUI components;
|
|
447
|
+
`core/model-resolver.d.ts` drops `resolveModelScope` / `restoreModelFromSession`
|
|
448
|
+
(never imported); `ExtensionRuntime.reportError` is additive. Upstream fixes that
|
|
449
|
+
help NaN users: MCP `tool_search` tools survive resume/`/reload`, and
|
|
450
|
+
`AgentSession.reload()` emits `session_start` again under
|
|
451
|
+
`bindExtensions({})`, so the media MCP server reconnects.
|
|
452
|
+
- `env-api-keys.js` gains the Qwen Token Plan per-plan variables; `PI_AI_VERSION` is
|
|
453
|
+
`1.6.0`. Neither is used by this package.
|
|
454
|
+
Regression test: `test/pi-ai-1-6-0-contract.test.ts` (RED on 1.5.1 for the flat
|
|
455
|
+
reasoning-token and retry-coverage groups, green on 1.6.0). Issue #45.
|
|
456
|
+
- **pi 1.4.0 / pi-ai 1.4.0 compat** (verified 2026-10-24): devDependencies bumped 1.3.0 → 1.4.0; **the peer range floor rose to
|
|
421
457
|
`"^1.3.0"`** and the version-gated cross-model thinking guard plus
|
|
422
458
|
`src/pi-ai-version.ts` were REMOVED as scheduled (pi-ai >= 1.3.0 drops
|
|
423
459
|
cross-model thinking itself). The pi-ai 1.4.0 type surface only ADDS exports
|
|
@@ -544,7 +580,18 @@ Since 1.0.0 the package version **aligns its MAJOR.MINOR with the pi release lin
|
|
|
544
580
|
only network path in `/nan-debug` and stays behind the explicit flag.
|
|
545
581
|
`src/debug-report.ts` reads `<agentDir>/sessions/**/*.jsonl` (filename date
|
|
546
582
|
prefix, else mtime), extracts only assistant `provider: "nan"` turns, and
|
|
547
|
-
renders the 2026-11-10 report shape plus `turns.jsonl`.
|
|
583
|
+
renders the 2026-11-10 report shape plus `turns.jsonl`. PR #44 (2026-11-18)
|
|
584
|
+
adds `errors.jsonl` rows and `error_summary` in `metadata.json`, embeds the
|
|
585
|
+
window-filtered raw transcripts under `sessions/` (their `cwd` header is
|
|
586
|
+
MD5-hashed; root files stay redacted — the transcripts are the owner's
|
|
587
|
+
explicit ask, issue #44), and adds `--interval` (day-granular windows capped
|
|
588
|
+
at 90 days, mutually exclusive with `--window`; its value joins tokens up to
|
|
589
|
+
the next `--` flag because pi passes slash-command args raw). Since 1.5.9
|
|
590
|
+
every response's `cf-ray` is appended by the same wrapper to
|
|
591
|
+
`<agentDir>/nan-response-rays.jsonl` (`{response_id, cf_ray, model,
|
|
592
|
+
observed_at}`, newest 50,000 lines, best-effort — `src/response-rays.ts`)
|
|
593
|
+
and joined into `turns.jsonl` as `cf_ray` (issue #35 S11, owner order
|
|
594
|
+
2026-11-18; null when uncaptured). The zip is built by
|
|
548
595
|
`src/zip.ts` (store method, sorted entries, fixed 1980-01-01 timestamps)
|
|
549
596
|
because `Bun.Archive` is Bun-only and pi also runs on Node. Session/worktree
|
|
550
597
|
labels are MD5[:12]; `errorMessage` maps to
|
|
@@ -576,7 +623,7 @@ uno cite una versión o requisito que el otro no lleve.
|
|
|
576
623
|
5. **Cita el peer floor real, no la historia.** El peer range se actualiza con cada
|
|
577
624
|
release de pi: lee `package.json` peerDependencies, no AGENTS.md (que documenta
|
|
578
625
|
releases históricos y puede quedar obsoleto). Para este paquete: el floor es
|
|
579
|
-
`^1.4.0` (desde package 1.5.0), verificado contra pi 1.
|
|
626
|
+
`^1.4.0` (desde package 1.5.0), verificado contra pi 1.6.0 / pi-ai 1.6.0.
|
|
580
627
|
6. **Las cifras de catálogo van contra `scripts/models.generated.ts`, no contra AGENTS.md.**
|
|
581
628
|
AGENTS.md es documentación de releases y puede contener floor o ranges ya antiguos;
|
|
582
629
|
el catálogo generado es la fuente viva de `contextWindow`/`maxTokens`/`reasoningEffortValues`
|
package/README.es.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @gtrabanco/𝜋-nan-provider
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://github.com/gtrabanco/pi-nan-provider/releases)
|
|
5
5
|
[](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).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Registra el proveedor `nan` vía `pi.registerProvider()` usando la API OpenAI-compatible de NaN (`https://api.nan.builders/v1`), y registra el servidor MCP de media de la comunidad con `pi.registerMcpServer()`.
|
|
10
10
|
|
|
11
11
|
> [!NOTE]
|
|
12
|
-
> **Requisitos:** pi **≥ 1.4.0** (rango peer `^1.4.0`). El paquete está verificado contra **pi 1.
|
|
12
|
+
> **Requisitos:** pi **≥ 1.4.0** (rango peer `^1.4.0`). El paquete está verificado contra **pi 1.6.0 / pi-ai 1.6.0**; el floor del rango peer solo sube con los re-aligns de menor de pi.
|
|
13
13
|
|
|
14
14
|
## ✨ Funciones
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ Registra el proveedor `nan` vía `pi.registerProvider()` usando la API OpenAI-co
|
|
|
27
27
|
| **Modelos de imagen nativos** | `flux-2-klein` y `qwen-image-2.1` registrados como modelos de pi `type: "image"`, accesibles desde codemode y extensiones. |
|
|
28
28
|
| **Puente MCP nativo de media** | El servidor `nan-media` (10 herramientas) registrado con `pi.registerMcpServer()`, gestionado con `/nan-mcp`. |
|
|
29
29
|
| **Informe de créditos** | `/nan-usage` muestra saldo de créditos con barra de progreso, desglose por modelo (input / cached / output en M, créditos consumidos) y periodo de facturación — todo desde `GET /v1/usage` ([#37](https://github.com/gtrabanco/pi-nan-provider/issues/37)). |
|
|
30
|
-
| **Evidencia de anomalías de caché** | Captura de `cf-ray` sobre la firma repetida `id` + `created` del gateway ([#17](https://github.com/gtrabanco/pi-nan-provider/issues/17)) más el recolector determinista `/nan-debug` ([#35](https://github.com/gtrabanco/pi-nan-provider/issues/35)). |
|
|
30
|
+
| **Evidencia de anomalías de caché** | Captura de `cf-ray` sobre la firma repetida `id` + `created` del gateway ([#17](https://github.com/gtrabanco/pi-nan-provider/issues/17)) más el recolector determinista `/nan-debug` ([#35](https://github.com/gtrabanco/pi-nan-provider/issues/35)) con evidencia de errores por turno, el `cf-ray` de cada respuesta unido a `turns.jsonl` (S11) y ventanas flexibles `--interval` ([#44](https://github.com/gtrabanco/pi-nan-provider/issues/44)). |
|
|
31
31
|
| **Integración con pi** | Refresco de modelos dirigido por el runtime Models de pi, overrides por modelo en `models.json` y el changelog de la extensión (`pi.changelogPath`) que pi muestra tras una actualización. |
|
|
32
32
|
|
|
33
33
|
Comandos:
|
|
@@ -36,7 +36,7 @@ Comandos:
|
|
|
36
36
|
| :--- | :--- |
|
|
37
37
|
| `/nan-mcp` | Gestionar el puente MCP de media (`status` / `enable` / `disable`) |
|
|
38
38
|
| `/nan-usage [1-90]` | Saldo de créditos con barra de uso, desglose por modelo (in / cached / out en M · créditos cr) y totales históricos |
|
|
39
|
-
| `/nan-debug [tema] [--window N] [--out ruta] [--emit]` | Paquete de evidencia reproducible y redactado para NaN |
|
|
39
|
+
| `/nan-debug [tema] [--window N] [--interval FLEX] [--out ruta] [--emit]` | Paquete de evidencia reproducible y redactado para NaN |
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -120,7 +120,7 @@ Puedes sobrescribir el `compat` de cualquier modelo en `~/.pi/agent/models.json`
|
|
|
120
120
|
|
|
121
121
|
> Poner `supportsFinishReason: false` restaura el antiguo stall silencioso — no recomendado.
|
|
122
122
|
|
|
123
|
-
**Escape hatches de compatibilidad de pi-ai 1.5.1
|
|
123
|
+
**Escape hatches de compatibilidad de pi-ai 1.5.1+** (`~/.pi/agent/models.json`, por modelo, sin cambios en 1.6.0): `compat.requiresToolsWithToolHistory: true` restaura el envío de `tools: []` en conversaciones con historial de tools (pi-ai 1.5.1 lo omite por defecto, arreglando los rechazos `tools must not be an empty array` de vLLM 0.20+ detrás de LiteLLM); `compat.requiresNonNullAssistantContent: true` envía `""` en vez de `null` en mensajes de asistente que solo llevan tool calls; `compat.promptCacheKeyMode: "disabled"` garantiza que nunca se envíe `prompt_cache_key` al gateway (el valor por defecto `auto` ya nunca lo activa para NaN).
|
|
124
124
|
|
|
125
125
|
**Uso de tokens en streaming:** `supportsUsageInStreaming` es `true` por defecto. El esquema publicado de NaN no documenta `stream_options`, pero el gateway real lo acepta y lo aplica — medido el 2026-09-16 ([#7](https://github.com/gtrabanco/pi-nan-provider/issues/7)): dos llamadas de streaming idénticas por modelo, 0 chunks de usage sin el flag y exactamente 1 con él, en `deepseek-v4-flash`, `glm5.3-flash`, `qwen3.6`, `gemma4` y `mimo-v2.5` (ya eliminado). Por eso pi muestra tokens reales de entrada/salida/reasoning/caché en lugar de ceros. Si un modelo resulta no devolver el usage en streaming, desactívalo por modelo — el sanitizer entonces elimina `stream_options` y el payload vuelve a ser estricto:
|
|
126
126
|
|
|
@@ -402,6 +402,13 @@ añade una línea JSON a `<agentDir>/nan-cache-anomalies.jsonl` — `model`, el
|
|
|
402
402
|
petición. Es **solo local**: ni contenido de prompt/respuesta, ni credenciales,
|
|
403
403
|
ni rutas, ni subida remota. Un fallo de escritura nunca rompe un stream.
|
|
404
404
|
|
|
405
|
+
Independientemente de cualquier anomalía, el `cf-ray` de cada respuesta se
|
|
406
|
+
guarda en `<agentDir>/nan-response-rays.jsonl` — `response_id`, `cf_ray`,
|
|
407
|
+
`model`, `observed_at`, las 50.000 líneas más recientes, solo local (issue
|
|
408
|
+
#35 S11) — y el informe lo une en `turns.jsonl` como `cf_ray`, así que
|
|
409
|
+
soporte tiene los rays de cualquier par de llamadas sin esperar a una
|
|
410
|
+
recurrencia.
|
|
411
|
+
|
|
405
412
|
`/nan-debug` convierte ese fichero y tus transcripts en un paquete de evidencia
|
|
406
413
|
redactado y reproducible para NaN:
|
|
407
414
|
|
|
@@ -410,11 +417,20 @@ redactado y reproducible para NaN:
|
|
|
410
417
|
/nan-debug cache --window 2 # etiqueta de tema + ventana de 2 días
|
|
411
418
|
/nan-debug --window 2 --emit # además escribe <agentDir>/nan-debug-report.zip
|
|
412
419
|
/nan-debug cache --out ~/evidence --emit
|
|
420
|
+
/nan-debug --interval 5min # intervalos relativos: 5min, 2h, 3d, 1mes
|
|
421
|
+
/nan-debug --interval "2026-11-10 - 2026-11-11 17:30" # rangos, extremos abiertos y puntos únicos también
|
|
413
422
|
```
|
|
414
423
|
|
|
415
424
|
- `--window N` (1–90 días) consulta además `GET /v1/usage` para el mismo periodo
|
|
416
425
|
con tu clave guardada y escribe `usage_window.json`; sin el flag no se hace
|
|
417
426
|
ninguna petición. Esa llamada en vivo consume el límite de peticiones.
|
|
427
|
+
- `--interval <desc>` sustituye a `--window` (usar ambos es un error) y acepta
|
|
428
|
+
intervalos relativos (`5min`, `2h`, `3d`, `1mes`), rangos fecha/hora
|
|
429
|
+
(`2026-11-10 - 2026-11-11 17:30`, `10:30 - 11:00`, cruce de medianoche
|
|
430
|
+
`23:00 - 01:00`), extremos abiertos (`2026-11-10 -`, `- 2026-11-10`),
|
|
431
|
+
año-mes (`2026-11 - 2026-12`) y puntos únicos (`2026-11-10`,
|
|
432
|
+
`2026-11-10T10:00:00Z`). El span máximo es de 90 días y el parseo es
|
|
433
|
+
determinista — sin llamadas a LLM. El tema, si usas uno, va antes del flag.
|
|
418
434
|
- El zip se escribe **solo** con `--emit`; la ejecución por defecto escribe el
|
|
419
435
|
informe local e imprime un resumen.
|
|
420
436
|
- `--out <ruta>` escribe el informe donde lo indiques (y, con `--emit`,
|
|
@@ -423,13 +439,23 @@ redactado y reproducible para NaN:
|
|
|
423
439
|
como ruta.
|
|
424
440
|
- El informe contiene `README.md`, `anonymized_usage.jsonl` (totales por
|
|
425
441
|
fecha/sesión/modelo, conteo de `stopReason`, tasa de acierto de caché),
|
|
426
|
-
`turns.jsonl` (uso por turno, `stopReason`, clase de error, `responseId
|
|
427
|
-
`
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
`
|
|
431
|
-
|
|
432
|
-
|
|
442
|
+
`turns.jsonl` (uso por turno, `stopReason`, clase de error, `responseId`,
|
|
443
|
+
`cf_ray`),
|
|
444
|
+
`errors.jsonl` (una fila por turno con error: clase, fragmento de 200
|
|
445
|
+
caracteres del mensaje, hash MD5 del mensaje completo, tokens de entrada/
|
|
446
|
+
salida, `responseId`), `anomalies.jsonl` (par de `cf-ray`), `sessions/` (los
|
|
447
|
+
JSONL de sesión en bruto filtrados por la ventana) y `metadata.json`
|
|
448
|
+
(versiones de paquete, pi-ai y pi; procedencia del catálogo;
|
|
449
|
+
`error_summary`).
|
|
450
|
+
- Las etiquetas de sesión y worktree son MD5 truncado a 12 caracteres (incluida
|
|
451
|
+
la cabecera `cwd` dentro de `sessions/`); `errorMessage` se reduce a
|
|
452
|
+
`overflow | rate_limited | invalid_request | transport | other`, y
|
|
453
|
+
`errors.jsonl` conserva como mucho 200 caracteres del mensaje en bruto más
|
|
454
|
+
un hash MD5. Las credenciales nunca se recogen en ningún sitio; el contenido
|
|
455
|
+
de prompt/respuesta nunca se recoge en los ficheros raíz — `sessions/` es la
|
|
456
|
+
excepción: transcripts en bruto incluidos a petición
|
|
457
|
+
([#44](https://github.com/gtrabanco/pi-nan-provider/issues/44)), solo con
|
|
458
|
+
`cwd` hasheado. Entradas idénticas producen bytes de zip idénticos.
|
|
433
459
|
|
|
434
460
|
## 📊 Modelos
|
|
435
461
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @gtrabanco/𝜋-nan-provider
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://github.com/gtrabanco/pi-nan-provider/releases)
|
|
5
5
|
[](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).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Registers the `nan` provider via `pi.registerProvider()` using NaN's OpenAI-compatible API (`https://api.nan.builders/v1`), and registers the community media MCP server via pi's native `pi.registerMcpServer()`.
|
|
10
10
|
|
|
11
11
|
> [!NOTE]
|
|
12
|
-
> **Requirements:** pi **≥ 1.4.0** (peer range `^1.4.0`). The package is verified against **pi 1.
|
|
12
|
+
> **Requirements:** pi **≥ 1.4.0** (peer range `^1.4.0`). The package is verified against **pi 1.6.0 / pi-ai 1.6.0**; the peer floor only rises on pi minor realigns.
|
|
13
13
|
|
|
14
14
|
## ✨ Features
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ Registers the `nan` provider via `pi.registerProvider()` using NaN's OpenAI-comp
|
|
|
27
27
|
| **Native image models** | `flux-2-klein` and `qwen-image-2.1` registered as pi `type: "image"` models, reachable from codemode and extensions. |
|
|
28
28
|
| **Native MCP media bridge** | The `nan-media` server (10 tools) registered through `pi.registerMcpServer()`, managed with `/nan-mcp`. |
|
|
29
29
|
| **Credits reporting** | `/nan-usage` shows credits balance with a progress bar, per-model breakdown (input / cached / output in M, credits consumed), and billing period — all from `GET /v1/usage` ([#37](https://github.com/gtrabanco/pi-nan-provider/issues/37)). |
|
|
30
|
-
| **Cache-anomaly evidence** | `cf-ray` capture on the repeated `id` + `created` gateway signature ([#17](https://github.com/gtrabanco/pi-nan-provider/issues/17)) plus the deterministic `/nan-debug` collector ([#35](https://github.com/gtrabanco/pi-nan-provider/issues/35)). |
|
|
30
|
+
| **Cache-anomaly evidence** | `cf-ray` capture on the repeated `id` + `created` gateway signature ([#17](https://github.com/gtrabanco/pi-nan-provider/issues/17)) plus the deterministic `/nan-debug` collector ([#35](https://github.com/gtrabanco/pi-nan-provider/issues/35)) with per-error evidence, every response's `cf-ray` joined into `turns.jsonl` (S11), and flexible `--interval` windows ([#44](https://github.com/gtrabanco/pi-nan-provider/issues/44)). |
|
|
31
31
|
| **pi integration** | Model refresh driven by pi's Models runtime, per-model `models.json` overrides, and the extension changelog (`pi.changelogPath`) that pi shows after an update. |
|
|
32
32
|
|
|
33
33
|
Commands:
|
|
@@ -36,7 +36,7 @@ Commands:
|
|
|
36
36
|
| :--- | :--- |
|
|
37
37
|
| `/nan-mcp` | Manage the media MCP bridge (`status` / `enable` / `disable`) |
|
|
38
38
|
| `/nan-usage [1-90]` | Credits balance with usage bar, per-model breakdown (in / cached / out in M · credits cr), and all-time totals |
|
|
39
|
-
| `/nan-debug [topic] [--window N] [--out path] [--emit]` | Redacted, reproducible evidence package for NaN |
|
|
39
|
+
| `/nan-debug [topic] [--window N] [--interval FLEX] [--out path] [--emit]` | Redacted, reproducible evidence package for NaN |
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -120,7 +120,7 @@ You can override any model's `compat` per-model in `~/.pi/agent/models.json` (pi
|
|
|
120
120
|
|
|
121
121
|
> Setting `supportsFinishReason: false` restores the old silent-stall behavior — not recommended.
|
|
122
122
|
|
|
123
|
-
**pi-ai 1.5.1 compat escape hatches** (`~/.pi/agent/models.json`, per model): `compat.requiresToolsWithToolHistory: true` restores sending `tools: []` in conversations with tool history (pi-ai 1.5.1 omits it by default, fixing vLLM 0.20+ `tools must not be an empty array` rejections behind LiteLLM); `compat.requiresNonNullAssistantContent: true` sends `""` instead of `null` in assistant messages that only carry tool calls; `compat.promptCacheKeyMode: "disabled"` guarantees `prompt_cache_key` is never sent to the gateway (the default `auto` already never enables it for NaN).
|
|
123
|
+
**pi-ai 1.5.1+ compat escape hatches** (`~/.pi/agent/models.json`, per model, unchanged in 1.6.0): `compat.requiresToolsWithToolHistory: true` restores sending `tools: []` in conversations with tool history (pi-ai 1.5.1 omits it by default, fixing vLLM 0.20+ `tools must not be an empty array` rejections behind LiteLLM); `compat.requiresNonNullAssistantContent: true` sends `""` instead of `null` in assistant messages that only carry tool calls; `compat.promptCacheKeyMode: "disabled"` guarantees `prompt_cache_key` is never sent to the gateway (the default `auto` already never enables it for NaN).
|
|
124
124
|
|
|
125
125
|
**Streaming token usage:** `supportsUsageInStreaming` is `true` by default. NaN's published schema does not document `stream_options`, but the live gateway honors it — measured 2026-09-16 ([#7](https://github.com/gtrabanco/pi-nan-provider/issues/7)): two identical streaming calls per model, 0 usage chunks without the flag and exactly 1 with it, on `deepseek-v4-flash`, `glm5.3-flash`, `qwen3.6`, `gemma4` and `mimo-v2.5` (since removed). pi therefore reports real input/output/reasoning/cache token counts instead of zeros. If a model turns out not to report streaming usage, opt out per model — the request sanitizer then strips `stream_options` and the payload stays strict:
|
|
126
126
|
|
|
@@ -400,6 +400,12 @@ SHA-256 of the request payload. It is **local-only**: no prompt or response
|
|
|
400
400
|
content, no credentials, no paths, no upload. A write failure never breaks a
|
|
401
401
|
stream.
|
|
402
402
|
|
|
403
|
+
Independently of any anomaly, every response's `cf-ray` is kept in
|
|
404
|
+
`<agentDir>/nan-response-rays.jsonl` — `response_id`, `cf_ray`, `model`,
|
|
405
|
+
`observed_at`, newest 50,000 lines, local-only (issue #35 S11) — and the
|
|
406
|
+
report joins it into `turns.jsonl` as `cf_ray`, so support gets the rays of
|
|
407
|
+
any pair of calls without waiting for a recurrence.
|
|
408
|
+
|
|
403
409
|
`/nan-debug` turns that file plus your session transcripts into a redacted,
|
|
404
410
|
reproducible evidence package for NaN:
|
|
405
411
|
|
|
@@ -408,11 +414,20 @@ reproducible evidence package for NaN:
|
|
|
408
414
|
/nan-debug cache --window 2 # topic label + a 2-day window
|
|
409
415
|
/nan-debug --window 2 --emit # also writes <agentDir>/nan-debug-report.zip
|
|
410
416
|
/nan-debug cache --out ~/evidence --emit
|
|
417
|
+
/nan-debug --interval 5min # relative spans: 5min, 2h, 3d, 1mes
|
|
418
|
+
/nan-debug --interval "2026-11-10 - 2026-11-11 17:30" # ranges, open ends, single points too
|
|
411
419
|
```
|
|
412
420
|
|
|
413
421
|
- `--window N` (1–90 days) also fetches `GET /v1/usage` for the same period with
|
|
414
422
|
your stored key and writes `usage_window.json`; without the flag nothing is
|
|
415
423
|
fetched. That live call counts against your quota's request rate.
|
|
424
|
+
- `--interval <desc>` replaces `--window` (using both is an error) and accepts
|
|
425
|
+
relative spans (`5min`, `2h`, `3d`, `1mes`), date/time ranges
|
|
426
|
+
(`2026-11-10 - 2026-11-11 17:30`, `10:30 - 11:00`, cross-midnight
|
|
427
|
+
`23:00 - 01:00`), open ends (`2026-11-10 -`, `- 2026-11-10`), year-months
|
|
428
|
+
(`2026-11 - 2026-12`) and single points (`2026-11-10`,
|
|
429
|
+
`2026-11-10T10:00:00Z`). The span is capped at 90 days and parsing is fully
|
|
430
|
+
deterministic — no LLM calls. The topic, when you use one, goes before the flag.
|
|
416
431
|
- The zip is written **only** with `--emit`; the default run writes the local
|
|
417
432
|
report and prints a preview.
|
|
418
433
|
- `--out <path>` writes the report anywhere you name it (and, with `--emit`,
|
|
@@ -420,12 +435,20 @@ reproducible evidence package for NaN:
|
|
|
420
435
|
above write where they say. A flag token is never accepted as the path.
|
|
421
436
|
- The report contains `README.md`, `anonymized_usage.jsonl` (per date/session/
|
|
422
437
|
model totals, stop-reason counts, cache-hit rate), `turns.jsonl` (per-turn
|
|
423
|
-
usage, stop reason, error class, response id), `
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
438
|
+
usage, stop reason, error class, response id, `cf_ray`), `errors.jsonl` (one row per
|
|
439
|
+
errored turn: class, 200-char message fragment, MD5 hash of the full message,
|
|
440
|
+
input/output tokens, response id), `anomalies.jsonl` (`cf-ray` pair),
|
|
441
|
+
`sessions/` (the raw session JSONL files filtered to the window) and
|
|
442
|
+
`metadata.json` (package/pi-ai/pi versions, catalog provenance,
|
|
443
|
+
`error_summary`).
|
|
444
|
+
- Session and worktree labels are MD5-truncated to 12 chars (including the
|
|
445
|
+
`cwd` header inside `sessions/`); `errorMessage` is reduced to `overflow |
|
|
446
|
+
rate_limited | invalid_request | transport | other`, and `errors.jsonl` keeps
|
|
447
|
+
at most 200 characters of the raw message plus an MD5 hash. Credentials are
|
|
448
|
+
never collected anywhere; prompt/response content is never collected in the
|
|
449
|
+
root files — `sessions/` is the exception, raw transcripts included on
|
|
450
|
+
request ([#44](https://github.com/gtrabanco/pi-nan-provider/issues/44)), with
|
|
451
|
+
only `cwd` hashed. Identical inputs produce byte-identical zip bytes.
|
|
429
452
|
|
|
430
453
|
## 📊 Models
|
|
431
454
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtrabanco/pi-nan-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@earendil-works/pi-coding-agent": "^1.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@earendil-works/pi-ai": "1.
|
|
51
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
50
|
+
"@earendil-works/pi-ai": "1.6.0",
|
|
51
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
52
52
|
"@types/bun": "1.4",
|
|
53
53
|
"typescript": "7"
|
|
54
54
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by scripts/generate-models.ts
|
|
2
2
|
// Do not edit manually — run `bun run generate-models` to update.
|
|
3
3
|
//
|
|
4
|
-
// Source: https://models.dev/api.json (provider "nan"), fetched 2026-11-
|
|
4
|
+
// Source: https://models.dev/api.json (provider "nan"), fetched 2026-11-21T10:25:10.741Z
|
|
5
5
|
// Provenance: every contextWindow/maxTokens/input/cost value traces to
|
|
6
6
|
// models.dev or to the per-entry notes below. Nothing is invented; entries
|
|
7
7
|
// models.dev documents incompletely are omitted and flagged instead.
|
|
@@ -136,7 +136,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
136
136
|
"id": "deepseek-v4-pro",
|
|
137
137
|
"name": "DeepSeek V4 Pro 0813",
|
|
138
138
|
"description": "DeepSeek V4 Pro snapshot with million-token context and support for thinking and non-thinking modes",
|
|
139
|
-
"family": "deepseek-
|
|
139
|
+
"family": "deepseek-pro",
|
|
140
140
|
"attachment": false,
|
|
141
141
|
"reasoning": true,
|
|
142
142
|
"reasoning_options": [
|
|
@@ -480,7 +480,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
480
480
|
"id": "hy4",
|
|
481
481
|
"name": "Hy4",
|
|
482
482
|
"description": "A next-generation multimodal productivity model with significantly enhanced Agent and complex task execution capabilities.",
|
|
483
|
-
"family": "
|
|
483
|
+
"family": "hy",
|
|
484
484
|
"attachment": true,
|
|
485
485
|
"reasoning": true,
|
|
486
486
|
"reasoning_options": [
|
|
@@ -591,7 +591,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
591
591
|
"id": "kimi-k3.1-pro",
|
|
592
592
|
"name": "Kimi K3.1 Pro",
|
|
593
593
|
"description": "Multimodal Kimi model with a 1M-token context window and always-on reasoning, for coding, 3D creation and financial research",
|
|
594
|
-
"family": "kimi-
|
|
594
|
+
"family": "kimi-pro",
|
|
595
595
|
"attachment": true,
|
|
596
596
|
"reasoning": true,
|
|
597
597
|
"reasoning_options": [
|
|
@@ -676,7 +676,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
676
676
|
"id": "mimo-v2.6-flash",
|
|
677
677
|
"name": "MiMo-V2.6-Flash",
|
|
678
678
|
"description": "MiMo Flash model for multimodal coding agents and long-context automation",
|
|
679
|
-
"family": "mimo",
|
|
679
|
+
"family": "mimo-flash",
|
|
680
680
|
"attachment": true,
|
|
681
681
|
"reasoning": true,
|
|
682
682
|
"reasoning_options": [
|
|
@@ -849,7 +849,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
849
849
|
"id": "qwen3.8-flash",
|
|
850
850
|
"name": "Qwen3.8 Flash",
|
|
851
851
|
"description": "Qwen vision-language model for visual reasoning, documents, and agent tasks",
|
|
852
|
-
"family": "qwen",
|
|
852
|
+
"family": "qwen-flash",
|
|
853
853
|
"attachment": true,
|
|
854
854
|
"reasoning": true,
|
|
855
855
|
"reasoning_options": [
|
|
@@ -937,7 +937,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
937
937
|
"id": "qwen3.8-max",
|
|
938
938
|
"name": "Qwen3.8 Max",
|
|
939
939
|
"description": "2.4-trillion-parameter MoE flagship for coding, professional work, multimodal understanding, and long-horizon agentic workflows",
|
|
940
|
-
"family": "qwen",
|
|
940
|
+
"family": "qwen-max",
|
|
941
941
|
"attachment": true,
|
|
942
942
|
"reasoning": true,
|
|
943
943
|
"reasoning_options": [
|
|
@@ -1027,7 +1027,7 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
|
|
|
1027
1027
|
export const GENERATED_CATALOG_META = {
|
|
1028
1028
|
source: "https://models.dev/api.json",
|
|
1029
1029
|
modelsDevProvider: "nan",
|
|
1030
|
-
fetchedAt: "2026-11-
|
|
1030
|
+
fetchedAt: "2026-11-21T10:25:10.741Z",
|
|
1031
1031
|
modelCount: 13,
|
|
1032
1032
|
models: ["deepseek-v4-flash","deepseek-v4-pro","gemma4","glm5.3","glm5.3-flash","hy4","hy4-flash","kimi-k3.1-pro","mimo-v2.6-flash","qwen3.6","qwen3.8-flash","qwen3.8-max","qwen4-max"],
|
|
1033
1033
|
notes: [
|
package/src/cache-anomaly.ts
CHANGED
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* chunks (pi-ai only persists `id` as `AssistantMessage.responseId`),
|
|
15
15
|
* - compares each completed stream with the previous one for the same model,
|
|
16
16
|
* and when both `id` and `created` repeat, appends one JSONL record to
|
|
17
|
-
* `<agentDir>/nan-cache-anomalies.jsonl
|
|
17
|
+
* `<agentDir>/nan-cache-anomalies.jsonl`,
|
|
18
|
+
* - appends every observed response's `cf-ray` to the response-ray sidecar
|
|
19
|
+
* (`<agentDir>/nan-response-rays.jsonl`, issue #35 S11, owner-ordered
|
|
20
|
+
* 2026-11-18) when a `raySink` is wired — capture for the report join,
|
|
21
|
+
* independent of anomaly detection.
|
|
18
22
|
*
|
|
19
23
|
* The record deliberately carries no prompt or response content, no
|
|
20
24
|
* credentials and no paths: only the model, the gateway pair, both `cf-ray`
|
|
@@ -32,6 +36,7 @@ import { appendFileSync, mkdirSync } from "node:fs";
|
|
|
32
36
|
import { dirname, join } from "node:path";
|
|
33
37
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
34
38
|
import type { AssistantMessage, ProviderStreams } from "@earendil-works/pi-ai";
|
|
39
|
+
import type { ResponseRaySink } from "./response-rays.ts";
|
|
35
40
|
|
|
36
41
|
/** Default file name inside pi's agent dir. */
|
|
37
42
|
export const CACHE_ANOMALY_FILE = "nan-cache-anomalies.jsonl";
|
|
@@ -98,6 +103,8 @@ export function createCacheAnomalyFileSink(filePath?: string): CacheAnomalySink
|
|
|
98
103
|
|
|
99
104
|
export interface CacheAnomalyCaptureOptions {
|
|
100
105
|
sink: CacheAnomalySink;
|
|
106
|
+
/** Per-response ray sidecar (issue #35 S11); when omitted, no rays are captured. */
|
|
107
|
+
raySink?: ResponseRaySink;
|
|
101
108
|
/** Injectable clock for deterministic tests. */
|
|
102
109
|
now?: () => Date;
|
|
103
110
|
}
|
|
@@ -209,10 +216,25 @@ export function withCacheAnomalyCapture(api: ProviderStreams, options: CacheAnom
|
|
|
209
216
|
|
|
210
217
|
const stream = run(opts as T);
|
|
211
218
|
|
|
219
|
+
const captureRay = (id?: string): void => {
|
|
220
|
+
if (!options.raySink || !id || state.cfRay === null) return;
|
|
221
|
+
try {
|
|
222
|
+
options.raySink.record({
|
|
223
|
+
response_id: id,
|
|
224
|
+
cf_ray: state.cfRay,
|
|
225
|
+
model: modelId,
|
|
226
|
+
observed_at: state.observedAt,
|
|
227
|
+
});
|
|
228
|
+
} catch {
|
|
229
|
+
// Ray capture is best-effort; never break the turn.
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
212
233
|
const complete = (message: AssistantMessage | undefined) => {
|
|
213
234
|
// pi-ai persists only the id; keep it as a fallback when the raw
|
|
214
235
|
// chunks did not carry one.
|
|
215
236
|
const id = state.id ?? message?.responseId;
|
|
237
|
+
captureRay(id);
|
|
216
238
|
if (!id || state.created === undefined) return;
|
|
217
239
|
|
|
218
240
|
const current: LastResponse = {
|
|
@@ -262,7 +284,9 @@ export function withCacheAnomalyCapture(api: ProviderStreams, options: CacheAnom
|
|
|
262
284
|
};
|
|
263
285
|
|
|
264
286
|
stream.result().then(complete, () => {
|
|
265
|
-
// A failed stream has no gateway pair worth comparing
|
|
287
|
+
// A failed stream has no gateway pair worth comparing — but when the
|
|
288
|
+
// response already produced an id, its ray is still evidence (S11).
|
|
289
|
+
captureRay(state.id);
|
|
266
290
|
});
|
|
267
291
|
return stream;
|
|
268
292
|
};
|
package/src/debug-command.ts
CHANGED
|
@@ -73,6 +73,7 @@ export function registerNanDebugCommand(pi: ExtensionAPI, deps: NanDebugCommandD
|
|
|
73
73
|
|
|
74
74
|
const now = deps.now?.() ?? new Date();
|
|
75
75
|
const agentDir = deps.agentDir ?? getAgentDir();
|
|
76
|
+
const sessionsDir = join(agentDir, "sessions");
|
|
76
77
|
const apiKey = parsed.args.windowProvided
|
|
77
78
|
? await (deps.resolveApiKey ?? defaultResolveApiKey)(ctx)
|
|
78
79
|
: undefined;
|
|
@@ -83,12 +84,14 @@ export function registerNanDebugCommand(pi: ExtensionAPI, deps: NanDebugCommandD
|
|
|
83
84
|
agentDir,
|
|
84
85
|
now,
|
|
85
86
|
windowDays: parsed.args.windowDays,
|
|
87
|
+
interval: parsed.args.interval,
|
|
86
88
|
topic: parsed.args.topic,
|
|
87
89
|
apiKey,
|
|
88
90
|
includeUsage: parsed.args.windowProvided,
|
|
89
91
|
fetchUsage: parsed.args.windowProvided ? (deps.fetchUsage ?? fetchDebugUsageWindow) : undefined,
|
|
92
|
+
sessionsDir,
|
|
90
93
|
});
|
|
91
|
-
rendered = renderDebugReport(report);
|
|
94
|
+
rendered = renderDebugReport(report, sessionsDir);
|
|
92
95
|
} catch (error) {
|
|
93
96
|
ctx.ui.notify(
|
|
94
97
|
`nan-debug failed to collect the report: ${error instanceof Error ? error.message : String(error)}`,
|