@gtrabanco/pi-nan-provider 1.6.0 → 1.6.3

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.
@@ -0,0 +1,247 @@
1
+ /**
2
+ * MODEL_FACTS — the manual layer of the exported model-facts catalog
3
+ * (issue #47).
4
+ *
5
+ * Same posture as `MANUAL_OVERRIDES`: this is the place a hand-maintained fact
6
+ * enters the build, with provenance, instead of being transcribed from README
7
+ * prose by a consumer. `scripts/generate-models.ts` validates these
8
+ * declarations against the catalog it just generated (every catalog id
9
+ * declared, no ghost ids, every value inside its documented union, every cell
10
+ * sourced), and `src/model-facts.ts` projects them into the frozen public
11
+ * record.
12
+ *
13
+ * The carried capabilities (context window, max tokens, cost, modalities,
14
+ * reasoning map, compat) are NOT repeated here — they are read from the
15
+ * generated catalog entry, which already carries its own provenance notes.
16
+ * Only the eight facts this issue promotes out of prose are declared.
17
+ *
18
+ * Sources (`sources` ids) resolve through `NAN_FACT_SOURCES` in
19
+ * `src/model-facts-core.ts`:
20
+ * - `docs` / `docs-reasoning` / `docs-cross-model`: https://nan.builders/docs/models
21
+ * (checked 2026-11-23). `docs-cross-model` marks a statement made on the
22
+ * deepseek-v4-flash card about the GLM models, qwen3.6 and gemma4.
23
+ * - `model-guide`: https://nan.builders/model-guide (the NaN community guide
24
+ * that publishes a cache rate per model).
25
+ * - `measured-36`: the qwen3.8-flash 2026-11-18 probe recorded in issue #36 —
26
+ * a measurement beats the docs, which still describe the pre-fix exception.
27
+ * - `none`: no positive claim (the `unmeasured` sentinel, or a field the
28
+ * catalog does not declare).
29
+ *
30
+ * Per-model evidence, all from the sources above:
31
+ * - Tool protocol: the docs spell it on every card — "Tool calling (XML
32
+ * format)" on qwen3.8-flash, qwen3.6 and gemma4, "Tool calling (function
33
+ * calling)" on the other ten.
34
+ * - `max_tokens` semantics: the docs' reasoning section says the output budget
35
+ * "is used exactly as you send it on every model … Reasoning tokens are spent
36
+ * from that same budget", and names qwen3.8-max as the model where
37
+ * "`max_tokens` only bounds the visible answer". qwen3.8-flash is the same
38
+ * exception on paper, but the 2026-11-18 probe (max_tokens=64 →
39
+ * completion_tokens=64, all reasoning) measured the fixed behaviour, so that
40
+ * cell follows the measurement.
41
+ * - Thinking budget: the docs make `thinking_budget`/`thinking_token_budget` a
42
+ * hard 1–32768 cap on qwen3.6, gemma4 and qwen3.8-flash, state it "is not
43
+ * honoured on this model" for qwen3.8-max, and keep every other model out of
44
+ * the contract ("depending on the model it is rejected with a 400 or
45
+ * ignored") — which is `unmeasured`, not `ignored`.
46
+ * - Cache mode: the model guide publishes a cache rate for eleven models and no
47
+ * opt-in parameter is documented anywhere, so the cache engages
48
+ * automatically; qwen3.6 and gemma4 have no published rate and stay
49
+ * `unmeasured`.
50
+ * - Billing class: the docs' Billing row reads "credits · larger model" on the
51
+ * six larger models and "credits" on the rest; no chat model is quota-billed.
52
+ * - Structured output: documented per model (json_object and/or json_schema);
53
+ * silence is `unmeasured`, never a guessed `true`.
54
+ * - Parallel tool calls: nothing documents or measures several tool calls per
55
+ * assistant turn, so every cell is `unmeasured`.
56
+ * - Cold ceiling: the only measurement is endpoint-wide, so every model carries
57
+ * `unmeasured` and the number ships as `NAN_ENDPOINT_FACTS`.
58
+ */
59
+
60
+ import type { ModelFactsDeclaration, ModelFactsDeclarations, NanFactSource, NanNewFactCell } from "../src/model-facts-core.ts";
61
+
62
+ /**
63
+ * Default provenance per cell. A model overrides only the cells whose evidence
64
+ * differs from "documented on its own card, with a published cache rate".
65
+ */
66
+ const BASE_SOURCES: Readonly<Record<NanNewFactCell, NanFactSource>> = {
67
+ toolCalling: "docs",
68
+ maxTokensSemantics: "docs",
69
+ thinkingBudget: "none",
70
+ coldCeilingTokens: "none",
71
+ cacheMode: "model-guide",
72
+ billingClass: "docs",
73
+ parallelToolCalls: "none",
74
+ structuredOutput: "none",
75
+ };
76
+
77
+ /** Compact declaration: the eight values, with provenance defaulting to BASE_SOURCES. */
78
+ function declaration(
79
+ facts: Omit<ModelFactsDeclaration, "sources">,
80
+ sources: Partial<Record<NanNewFactCell, NanFactSource>> = {},
81
+ ): ModelFactsDeclaration {
82
+ return { ...facts, sources: { ...BASE_SOURCES, ...sources } };
83
+ }
84
+
85
+ /**
86
+ * Per-model declarations, keyed by catalog id. A model missing here fails the
87
+ * build (`bun run generate-models`) and the test corpus.
88
+ */
89
+ export const MODEL_FACTS: ModelFactsDeclarations = {
90
+ "deepseek-v4-flash": declaration(
91
+ {
92
+ toolCalling: "openai-tools",
93
+ maxTokensSemantics: "bounds-total",
94
+ thinkingBudget: "unmeasured",
95
+ coldCeilingTokens: "unmeasured",
96
+ cacheMode: "automatic",
97
+ billingClass: "credit-standard",
98
+ parallelToolCalls: "unmeasured",
99
+ structuredOutput: true,
100
+ },
101
+ { structuredOutput: "docs" },
102
+ ),
103
+ "deepseek-v4-pro": declaration({
104
+ toolCalling: "openai-tools",
105
+ maxTokensSemantics: "bounds-total",
106
+ thinkingBudget: "unmeasured",
107
+ coldCeilingTokens: "unmeasured",
108
+ cacheMode: "automatic",
109
+ billingClass: "credit-larger",
110
+ parallelToolCalls: "unmeasured",
111
+ structuredOutput: "unmeasured",
112
+ }),
113
+ gemma4: declaration(
114
+ {
115
+ toolCalling: "xml",
116
+ maxTokensSemantics: "bounds-total",
117
+ thinkingBudget: "honoured",
118
+ coldCeilingTokens: "unmeasured",
119
+ cacheMode: "unmeasured",
120
+ billingClass: "credit-standard",
121
+ parallelToolCalls: "unmeasured",
122
+ structuredOutput: true,
123
+ },
124
+ { thinkingBudget: "docs-reasoning", cacheMode: "none", structuredOutput: "docs-cross-model" },
125
+ ),
126
+ "glm5.3": declaration(
127
+ {
128
+ toolCalling: "openai-tools",
129
+ maxTokensSemantics: "bounds-total",
130
+ thinkingBudget: "unmeasured",
131
+ coldCeilingTokens: "unmeasured",
132
+ cacheMode: "automatic",
133
+ billingClass: "credit-larger",
134
+ parallelToolCalls: "unmeasured",
135
+ structuredOutput: true,
136
+ },
137
+ { structuredOutput: "docs-cross-model" },
138
+ ),
139
+ "glm5.3-flash": declaration(
140
+ {
141
+ toolCalling: "openai-tools",
142
+ maxTokensSemantics: "bounds-total",
143
+ thinkingBudget: "unmeasured",
144
+ coldCeilingTokens: "unmeasured",
145
+ cacheMode: "automatic",
146
+ billingClass: "credit-standard",
147
+ parallelToolCalls: "unmeasured",
148
+ structuredOutput: true,
149
+ },
150
+ { structuredOutput: "docs-cross-model" },
151
+ ),
152
+ hy4: declaration({
153
+ toolCalling: "openai-tools",
154
+ maxTokensSemantics: "bounds-total",
155
+ thinkingBudget: "unmeasured",
156
+ coldCeilingTokens: "unmeasured",
157
+ cacheMode: "automatic",
158
+ billingClass: "credit-larger",
159
+ parallelToolCalls: "unmeasured",
160
+ structuredOutput: "unmeasured",
161
+ }),
162
+ "hy4-flash": declaration(
163
+ {
164
+ toolCalling: "openai-tools",
165
+ maxTokensSemantics: "bounds-total",
166
+ thinkingBudget: "unmeasured",
167
+ coldCeilingTokens: "unmeasured",
168
+ cacheMode: "automatic",
169
+ billingClass: "credit-standard",
170
+ parallelToolCalls: "unmeasured",
171
+ structuredOutput: true,
172
+ },
173
+ { structuredOutput: "docs" },
174
+ ),
175
+ "kimi-k3.1-pro": declaration({
176
+ toolCalling: "openai-tools",
177
+ maxTokensSemantics: "bounds-total",
178
+ thinkingBudget: "unmeasured",
179
+ coldCeilingTokens: "unmeasured",
180
+ cacheMode: "automatic",
181
+ billingClass: "credit-larger",
182
+ parallelToolCalls: "unmeasured",
183
+ structuredOutput: "unmeasured",
184
+ }),
185
+ "mimo-v2.6-flash": declaration({
186
+ toolCalling: "openai-tools",
187
+ maxTokensSemantics: "bounds-total",
188
+ thinkingBudget: "unmeasured",
189
+ coldCeilingTokens: "unmeasured",
190
+ cacheMode: "automatic",
191
+ billingClass: "credit-standard",
192
+ parallelToolCalls: "unmeasured",
193
+ structuredOutput: "unmeasured",
194
+ }),
195
+ "qwen3.6": declaration(
196
+ {
197
+ toolCalling: "xml",
198
+ maxTokensSemantics: "bounds-total",
199
+ thinkingBudget: "honoured",
200
+ coldCeilingTokens: "unmeasured",
201
+ cacheMode: "unmeasured",
202
+ billingClass: "credit-standard",
203
+ parallelToolCalls: "unmeasured",
204
+ structuredOutput: true,
205
+ },
206
+ { thinkingBudget: "docs-reasoning", cacheMode: "none", structuredOutput: "docs-cross-model" },
207
+ ),
208
+ "qwen3.8-flash": declaration(
209
+ {
210
+ toolCalling: "xml",
211
+ maxTokensSemantics: "bounds-total",
212
+ thinkingBudget: "honoured",
213
+ coldCeilingTokens: "unmeasured",
214
+ cacheMode: "automatic",
215
+ billingClass: "credit-standard",
216
+ parallelToolCalls: "unmeasured",
217
+ structuredOutput: "unmeasured",
218
+ },
219
+ { thinkingBudget: "docs-reasoning", maxTokensSemantics: "measured-36" },
220
+ ),
221
+ "qwen3.8-max": declaration(
222
+ {
223
+ toolCalling: "openai-tools",
224
+ maxTokensSemantics: "bounds-visible-answer",
225
+ thinkingBudget: "ignored",
226
+ coldCeilingTokens: "unmeasured",
227
+ cacheMode: "automatic",
228
+ billingClass: "credit-larger",
229
+ parallelToolCalls: "unmeasured",
230
+ structuredOutput: "unmeasured",
231
+ },
232
+ { maxTokensSemantics: "docs-reasoning", thinkingBudget: "docs-reasoning" },
233
+ ),
234
+ "qwen4-max": declaration(
235
+ {
236
+ toolCalling: "openai-tools",
237
+ maxTokensSemantics: "bounds-total",
238
+ thinkingBudget: "unmeasured",
239
+ coldCeilingTokens: "unmeasured",
240
+ cacheMode: "automatic",
241
+ billingClass: "credit-larger",
242
+ parallelToolCalls: "unmeasured",
243
+ structuredOutput: true,
244
+ },
245
+ { structuredOutput: "docs" },
246
+ ),
247
+ };
@@ -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-21T10:25:10.741Z
4
+ // Source: https://models.dev/api.json (provider "nan"), fetched 2026-11-25T10:55:49.540Z
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.
@@ -506,10 +506,10 @@ export const NAN_GENERATED_MODELS: readonly GeneratedModelEntry[] = [
506
506
  "text"
507
507
  ]
508
508
  },
509
- "open_weights": false,
509
+ "open_weights": true,
510
510
  "limit": {
511
511
  "context": 1048576,
512
- "input": 983010,
512
+ "input": 983040,
513
513
  "output": 65536
514
514
  },
515
515
  "cost": {
@@ -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-21T10:25:10.741Z",
1030
+ fetchedAt: "2026-11-25T10:55:49.540Z",
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: [
@@ -15,9 +15,9 @@ import { getAgentDir } from "@earendil-works/pi-coding-agent";
15
15
  import { NAN_API_KEY_ENV, resolveStoredNanApiKey, tryResolveNanApiKeyViaRegistry } from "./mcp/api-key.ts";
16
16
  import {
17
17
  DEBUG_USAGE_LINE,
18
- NAN_DEBUG_REPORT_DIR,
19
- NAN_DEBUG_ZIP,
20
18
  buildDebugReport,
19
+ debugReportDirName,
20
+ debugReportZipName,
21
21
  fetchDebugUsageWindow,
22
22
  parseDebugArgs,
23
23
  renderDebugReport,
@@ -91,7 +91,10 @@ export function registerNanDebugCommand(pi: ExtensionAPI, deps: NanDebugCommandD
91
91
  fetchUsage: parsed.args.windowProvided ? (deps.fetchUsage ?? fetchDebugUsageWindow) : undefined,
92
92
  sessionsDir,
93
93
  });
94
- rendered = renderDebugReport(report, sessionsDir);
94
+ rendered = renderDebugReport(report, sessionsDir, {
95
+ includePrompts: parsed.args.includePrompts,
96
+ includeTools: parsed.args.includeTools,
97
+ });
95
98
  } catch (error) {
96
99
  ctx.ui.notify(
97
100
  `nan-debug failed to collect the report: ${error instanceof Error ? error.message : String(error)}`,
@@ -102,14 +105,16 @@ export function registerNanDebugCommand(pi: ExtensionAPI, deps: NanDebugCommandD
102
105
 
103
106
  const explicitZipTarget = parsed.args.out ? expandHomePath(parsed.args.out, deps.homedir ?? osHomedir()) : undefined;
104
107
  const explicitZip = explicitZipTarget?.endsWith(".zip") ? explicitZipTarget : undefined;
108
+ // Default names carry the emission timestamp (UTC) so consecutive runs
109
+ // never overwrite each other; an explicit `--out` is respected verbatim.
105
110
  const outDir = explicitZip
106
111
  ? explicitZip.replace(/\.zip$/, "")
107
- : (explicitZipTarget ?? join(agentDir, NAN_DEBUG_REPORT_DIR));
108
- const zipPath = explicitZip ?? (explicitZipTarget ? `${explicitZipTarget}.zip` : join(agentDir, NAN_DEBUG_ZIP));
112
+ : (explicitZipTarget ?? join(agentDir, debugReportDirName(now)));
113
+ const zipPath = explicitZip ?? (explicitZipTarget ? `${explicitZipTarget}.zip` : join(agentDir, debugReportZipName(now)));
109
114
 
110
115
  try {
111
116
  writeDebugReport(rendered.files, outDir);
112
- if (parsed.args.emit) writeDebugZip(rendered.files, zipPath);
117
+ if (parsed.args.emit) writeDebugZip(rendered.files, zipPath, { includeUsageWindow: parsed.args.all });
113
118
  } catch (error) {
114
119
  ctx.ui.notify(
115
120
  `nan-debug wrote nothing: ${error instanceof Error ? error.message : String(error)}`,