@trazum/core 1.80.1 → 1.82.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.
Files changed (70) hide show
  1. package/README.md +34 -18
  2. package/dist/advisories.d.ts +33 -1
  3. package/dist/advisories.d.ts.map +1 -1
  4. package/dist/advisories.js +103 -16
  5. package/dist/advisories.js.map +1 -1
  6. package/dist/band.d.ts +131 -0
  7. package/dist/band.d.ts.map +1 -0
  8. package/dist/band.js +210 -0
  9. package/dist/band.js.map +1 -0
  10. package/dist/claude-code.d.ts +28 -0
  11. package/dist/claude-code.d.ts.map +1 -1
  12. package/dist/claude-code.js +25 -1
  13. package/dist/claude-code.js.map +1 -1
  14. package/dist/conform.d.ts +1 -1
  15. package/dist/conform.d.ts.map +1 -1
  16. package/dist/conform.js +84 -1
  17. package/dist/conform.js.map +1 -1
  18. package/dist/helicone.d.ts +92 -0
  19. package/dist/helicone.d.ts.map +1 -0
  20. package/dist/helicone.js +194 -0
  21. package/dist/helicone.js.map +1 -0
  22. package/dist/i18n/en.d.ts.map +1 -1
  23. package/dist/i18n/en.js +26 -20
  24. package/dist/i18n/en.js.map +1 -1
  25. package/dist/i18n/es.d.ts.map +1 -1
  26. package/dist/i18n/es.js +9 -3
  27. package/dist/i18n/es.js.map +1 -1
  28. package/dist/i18n/types.d.ts +43 -1
  29. package/dist/i18n/types.d.ts.map +1 -1
  30. package/dist/index.d.ts +10 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/litellm.d.ts +98 -0
  35. package/dist/litellm.d.ts.map +1 -0
  36. package/dist/litellm.js +207 -0
  37. package/dist/litellm.js.map +1 -0
  38. package/dist/measured-profile.d.ts +4 -0
  39. package/dist/measured-profile.d.ts.map +1 -1
  40. package/dist/measured-profile.js +22 -1
  41. package/dist/measured-profile.js.map +1 -1
  42. package/dist/schemas.d.ts.map +1 -1
  43. package/dist/schemas.js +36 -0
  44. package/dist/schemas.js.map +1 -1
  45. package/dist/tokenizer.d.ts +45 -49
  46. package/dist/tokenizer.d.ts.map +1 -1
  47. package/dist/tokenizer.js +100 -51
  48. package/dist/tokenizer.js.map +1 -1
  49. package/dist/types.d.ts +1 -1
  50. package/dist/types.d.ts.map +1 -1
  51. package/dist/verdict-bridge.d.ts +113 -0
  52. package/dist/verdict-bridge.d.ts.map +1 -0
  53. package/dist/verdict-bridge.js +127 -0
  54. package/dist/verdict-bridge.js.map +1 -0
  55. package/package.json +1 -1
  56. package/src/advisories.ts +132 -15
  57. package/src/band.ts +213 -0
  58. package/src/claude-code.ts +53 -1
  59. package/src/conform.ts +100 -1
  60. package/src/helicone.ts +227 -0
  61. package/src/i18n/en.ts +27 -20
  62. package/src/i18n/es.ts +10 -3
  63. package/src/i18n/types.ts +45 -1
  64. package/src/index.ts +17 -1
  65. package/src/litellm.ts +243 -0
  66. package/src/measured-profile.ts +26 -2
  67. package/src/schemas.ts +36 -0
  68. package/src/tokenizer.ts +101 -51
  69. package/src/types.ts +1 -0
  70. package/src/verdict-bridge.ts +200 -0
@@ -2,71 +2,67 @@
2
2
  * Dependency-free token estimator.
3
3
  *
4
4
  * This is NOT a real tokenizer: it is a heuristic calibrated per character
5
- * class. It is built to keep the typical error on ordinary text
6
- * (English/Spanish, markdown, code) inside ±10%, which is plenty for comparing
7
- * two versions of the same prompt — but do NOT bill anyone from it.
5
+ * class, built for comparing two versions of the same prompt — but do NOT bill
6
+ * anyone from it.
8
7
  *
9
- * **That band is a design target that has not been measured.** It is printed on
10
- * every report and every dollar figure descends from it, and until
11
- * `scripts/measure-token-band.mjs` has been run against the official counting
12
- * endpoint, nothing in this repository establishes that it holds. It is stated
13
- * as one number for all text, which is a further assumption: the branches below
14
- * treat CJK, digits and punctuation quite differently from words, and there is
15
- * no reason those should land on the same accuracy.
8
+ * **Its accuracy is not one number, and the years it was written as one were
9
+ * the mistake.** The branches below treat CJK, digits and punctuation quite
10
+ * differently from words, and there was never a reason those should land on the
11
+ * same accuracy. Measured over 47 samples against the official counting
12
+ * endpoint they do not: the worst error is 3.2% on CJK, 5.6% on Latin prose,
13
+ * 25.1% on code and quoting, and 32.5% on a digit-dominant table. `band.ts`
14
+ * holds the bands those measurements earn and `bandFor(text)` is what a caller
15
+ * should print; the constant below is only the widest of them, for callers that
16
+ * have no text in hand.
16
17
  *
17
- * `test/token-band.test.js` asserts the band per text type as soon as the ground
18
- * truth exists. Until then it says so rather than passing quietly.
18
+ * `test/token-band.test.js` holds every sample against the band `bandFor` gives
19
+ * it, and a sample edited since it was measured fails rather than passing
20
+ * quietly.
19
21
  *
20
22
  * For exact numbers use `countTokensAnthropic` (the official token-counting
21
23
  * endpoint, which is free) or pass your own `TokenCounter`.
22
24
  */
23
25
  /**
24
- * The error band this estimator is published under, as a percentage.
26
+ * The widest band this estimator is published under, as a percentage.
25
27
  *
26
- * **Measured, not chosen, and it has moved three times.** It was `15` for eight
27
- * releases as a design target nobody had checked; the first measurement found two
28
- * of eight samples outside it and it went to `25`; fixing the digit divisor and
29
- * calibrating per language brought it back to `15`. This is the fourth value and
30
- * the first one that is comfortably above what the corpus actually shows.
28
+ * **A history worth keeping, because each value was believed at the time.** It
29
+ * was `15` for eight releases as a design target nobody had checked; the first
30
+ * measurement found two of eight samples outside it and it went to `25`; fixing
31
+ * the digit divisor and calibrating per language brought it back to `15`, and
32
+ * splitting kana from han — Japanese had been +11.2% and Chinese −3.2% under one
33
+ * rule — brought it to `10`. Four values, each an improvement, and all four
34
+ * wrong in the same way.
31
35
  *
32
- * ```
33
- * worst measured error 6.4% (code-heavy, which nothing is fitted to)
34
- * published band 10%
35
- * ```
36
+ * **The corpus they were measured on was the corpus they were fitted to.**
37
+ * Twenty-one samples held thirteen files of Latin prose and exactly one each of
38
+ * code, numeric and punctuation, and those single files were where the constants
39
+ * came from. The worst error it could show was 6.4%, and 10 looked like a
40
+ * comfortable margin over it. Neither figure was about the estimator.
36
41
  *
37
- * **The margin is deliberate and it is not slack.** 6.4 rounded up is 7, and
38
- * publishing 7 would be a tighter claim than twenty-one samples across six text
39
- * types can support: the corpus has no Korean, no Arabic, no Cyrillic prose, no
40
- * mixed-script document, and a seventh text type could easily land at eight. A
41
- * band that becomes false the first time somebody measures something new is the
42
- * exact fault this whole exercise was fixing. Overstating the uncertainty is the
43
- * safe direction for a tool that reports money.
42
+ * **It is no longer one number, and this one is the widest.** A corpus of
43
+ * thirteen prose files and one each of code, numeric and punctuation put the
44
+ * band at 10, and those single files were the set the constants had been fitted
45
+ * to. Measured on forty-seven, the same estimator is 6% out on prose and 33%
46
+ * out on a CSV ledger. `bandFor` in `band.ts` is what a caller that has the
47
+ * text should use.
44
48
  *
45
- * What earned the drop from 15 was **splitting kana from han**. Every CJK
46
- * character was charged one token, which put Japanese at +11.2% — the worst error
47
- * anywhere in the corpus — while Chinese sat at −3.2% under the same rule. Kana
48
- * measure 0.75 tokens per character and han 1.05, and that pair takes the two
49
- * samples to −1.5% and +1.3%. See `KANA_TOKENS_PER_CHAR`.
50
- *
51
- * **Which samples the band rests on matters more than the number.** Eight of the
52
- * twenty-one had a constant fitted to them — seven Latin divisors and the digit
53
- * divisor — so their residuals are optimistic by construction. The two worst
54
- * errors in the corpus, `code-heavy` at 6.4% and `punctuation-heavy` at 5.7%, are
55
- * fitted to nothing at all, and they are what sets this figure.
56
- *
57
- * Exported so every report, README and tool description reads the same number. It
58
- * was a literal in twenty-four files before this, with the only machine-readable
59
- * copy in a test, and `token-band.test.js` now fails any file that states a
60
- * different one.
49
+ * This stays for the callers that do not have it — a figure covering the whole
50
+ * catalogue of text, which can only be the worst of them. Widening it from 10
51
+ * to 33 makes every claim that reads it true where it had been false, at the
52
+ * cost of understating the estimator on prose. That trade is deliberate: a
53
+ * caller with no text cannot know which it is holding, and there is only one
54
+ * safe direction to guess in.
61
55
  */
62
- export declare const ESTIMATE_ERROR_BAND_PCT = 10;
56
+ export declare const ESTIMATE_ERROR_BAND_PCT = 33;
63
57
  /**
64
58
  * Whose tokenizer that band was measured against.
65
59
  *
66
60
  * The number above is not a property of the estimator; it is a property of the
67
- * estimator **against Claude**. Twenty-one samples, one counting endpoint, one
68
- * family. Trazum prices seven, and until somebody runs the harness against the
69
- * others nobody knows what the error is on a GPT or a Gemini prompt.
61
+ * estimator **against Claude**. Forty-seven samples, one counting endpoint, one
62
+ * family. Trazum prices seven, and the two that have since been run are far
63
+ * outside anything published here: DeepSeek 94.5% at worst, Mistral 103.1%. On
64
+ * a GPT or a Gemini prompt nobody has measured it at all, and
65
+ * `measuredForeignError` answers null rather than the nearest number.
70
66
  *
71
67
  * Exported as a name rather than left implicit in a comment because the band
72
68
  * had already leaked out of its domain in three places: an advisory that told a
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAExE;AAmGD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuHnD;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6BxF"}
1
+ {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAExE;AA+HD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiJnD;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6BxF"}
package/dist/tokenizer.js CHANGED
@@ -2,20 +2,22 @@
2
2
  * Dependency-free token estimator.
3
3
  *
4
4
  * This is NOT a real tokenizer: it is a heuristic calibrated per character
5
- * class. It is built to keep the typical error on ordinary text
6
- * (English/Spanish, markdown, code) inside ±10%, which is plenty for comparing
7
- * two versions of the same prompt — but do NOT bill anyone from it.
5
+ * class, built for comparing two versions of the same prompt — but do NOT bill
6
+ * anyone from it.
8
7
  *
9
- * **That band is a design target that has not been measured.** It is printed on
10
- * every report and every dollar figure descends from it, and until
11
- * `scripts/measure-token-band.mjs` has been run against the official counting
12
- * endpoint, nothing in this repository establishes that it holds. It is stated
13
- * as one number for all text, which is a further assumption: the branches below
14
- * treat CJK, digits and punctuation quite differently from words, and there is
15
- * no reason those should land on the same accuracy.
8
+ * **Its accuracy is not one number, and the years it was written as one were
9
+ * the mistake.** The branches below treat CJK, digits and punctuation quite
10
+ * differently from words, and there was never a reason those should land on the
11
+ * same accuracy. Measured over 47 samples against the official counting
12
+ * endpoint they do not: the worst error is 3.2% on CJK, 5.6% on Latin prose,
13
+ * 25.1% on code and quoting, and 32.5% on a digit-dominant table. `band.ts`
14
+ * holds the bands those measurements earn and `bandFor(text)` is what a caller
15
+ * should print; the constant below is only the widest of them, for callers that
16
+ * have no text in hand.
16
17
  *
17
- * `test/token-band.test.js` asserts the band per text type as soon as the ground
18
- * truth exists. Until then it says so rather than passing quietly.
18
+ * `test/token-band.test.js` holds every sample against the band `bandFor` gives
19
+ * it, and a sample edited since it was measured fails rather than passing
20
+ * quietly.
19
21
  *
20
22
  * For exact numbers use `countTokensAnthropic` (the official token-counting
21
23
  * endpoint, which is free) or pass your own `TokenCounter`.
@@ -23,52 +25,46 @@
23
25
  import { detectTextLanguage } from './language.js';
24
26
  import { SAFE_FETCH_INIT, checkedEndpoint } from './net.js';
25
27
  /**
26
- * The error band this estimator is published under, as a percentage.
28
+ * The widest band this estimator is published under, as a percentage.
27
29
  *
28
- * **Measured, not chosen, and it has moved three times.** It was `15` for eight
29
- * releases as a design target nobody had checked; the first measurement found two
30
- * of eight samples outside it and it went to `25`; fixing the digit divisor and
31
- * calibrating per language brought it back to `15`. This is the fourth value and
32
- * the first one that is comfortably above what the corpus actually shows.
30
+ * **A history worth keeping, because each value was believed at the time.** It
31
+ * was `15` for eight releases as a design target nobody had checked; the first
32
+ * measurement found two of eight samples outside it and it went to `25`; fixing
33
+ * the digit divisor and calibrating per language brought it back to `15`, and
34
+ * splitting kana from han — Japanese had been +11.2% and Chinese −3.2% under one
35
+ * rule — brought it to `10`. Four values, each an improvement, and all four
36
+ * wrong in the same way.
33
37
  *
34
- * ```
35
- * worst measured error 6.4% (code-heavy, which nothing is fitted to)
36
- * published band 10%
37
- * ```
38
+ * **The corpus they were measured on was the corpus they were fitted to.**
39
+ * Twenty-one samples held thirteen files of Latin prose and exactly one each of
40
+ * code, numeric and punctuation, and those single files were where the constants
41
+ * came from. The worst error it could show was 6.4%, and 10 looked like a
42
+ * comfortable margin over it. Neither figure was about the estimator.
38
43
  *
39
- * **The margin is deliberate and it is not slack.** 6.4 rounded up is 7, and
40
- * publishing 7 would be a tighter claim than twenty-one samples across six text
41
- * types can support: the corpus has no Korean, no Arabic, no Cyrillic prose, no
42
- * mixed-script document, and a seventh text type could easily land at eight. A
43
- * band that becomes false the first time somebody measures something new is the
44
- * exact fault this whole exercise was fixing. Overstating the uncertainty is the
45
- * safe direction for a tool that reports money.
44
+ * **It is no longer one number, and this one is the widest.** A corpus of
45
+ * thirteen prose files and one each of code, numeric and punctuation put the
46
+ * band at 10, and those single files were the set the constants had been fitted
47
+ * to. Measured on forty-seven, the same estimator is 6% out on prose and 33%
48
+ * out on a CSV ledger. `bandFor` in `band.ts` is what a caller that has the
49
+ * text should use.
46
50
  *
47
- * What earned the drop from 15 was **splitting kana from han**. Every CJK
48
- * character was charged one token, which put Japanese at +11.2% — the worst error
49
- * anywhere in the corpus — while Chinese sat at −3.2% under the same rule. Kana
50
- * measure 0.75 tokens per character and han 1.05, and that pair takes the two
51
- * samples to −1.5% and +1.3%. See `KANA_TOKENS_PER_CHAR`.
52
- *
53
- * **Which samples the band rests on matters more than the number.** Eight of the
54
- * twenty-one had a constant fitted to them — seven Latin divisors and the digit
55
- * divisor — so their residuals are optimistic by construction. The two worst
56
- * errors in the corpus, `code-heavy` at 6.4% and `punctuation-heavy` at 5.7%, are
57
- * fitted to nothing at all, and they are what sets this figure.
58
- *
59
- * Exported so every report, README and tool description reads the same number. It
60
- * was a literal in twenty-four files before this, with the only machine-readable
61
- * copy in a test, and `token-band.test.js` now fails any file that states a
62
- * different one.
51
+ * This stays for the callers that do not have it — a figure covering the whole
52
+ * catalogue of text, which can only be the worst of them. Widening it from 10
53
+ * to 33 makes every claim that reads it true where it had been false, at the
54
+ * cost of understating the estimator on prose. That trade is deliberate: a
55
+ * caller with no text cannot know which it is holding, and there is only one
56
+ * safe direction to guess in.
63
57
  */
64
- export const ESTIMATE_ERROR_BAND_PCT = 10;
58
+ export const ESTIMATE_ERROR_BAND_PCT = 33;
65
59
  /**
66
60
  * Whose tokenizer that band was measured against.
67
61
  *
68
62
  * The number above is not a property of the estimator; it is a property of the
69
- * estimator **against Claude**. Twenty-one samples, one counting endpoint, one
70
- * family. Trazum prices seven, and until somebody runs the harness against the
71
- * others nobody knows what the error is on a GPT or a Gemini prompt.
63
+ * estimator **against Claude**. Forty-seven samples, one counting endpoint, one
64
+ * family. Trazum prices seven, and the two that have since been run are far
65
+ * outside anything published here: DeepSeek 94.5% at worst, Mistral 103.1%. On
66
+ * a GPT or a Gemini prompt nobody has measured it at all, and
67
+ * `measuredForeignError` answers null rather than the nearest number.
72
68
  *
73
69
  * Exported as a name rather than left implicit in a comment because the band
74
70
  * had already leaked out of its domain in three places: an advisory that told a
@@ -164,6 +160,33 @@ const DIVISOR_BY_LANGUAGE = {
164
160
  */
165
161
  const KANA_TOKENS_PER_CHAR = 0.75;
166
162
  const HAN_TOKENS_PER_CHAR = 1.05;
163
+ /**
164
+ * Hangul, measured at last.
165
+ *
166
+ * The comment above used to end *"Hangul keeps the old cost of 1, because
167
+ * nothing here measures Korean. Guessing it from Japanese would be inventing a
168
+ * figure."* That was right, and it stayed right for exactly as long as nobody
169
+ * measured Korean. `cjk-korean.txt` now does: at 1 token per character the
170
+ * estimate came out **20.0% under** — 232 against 290 — and 1.20 takes it to
171
+ * -10.0%.
172
+ *
173
+ * **1.20 was the one-sample answer and it was wrong by ten points.** A second
174
+ * Korean sample in a different register — a deployment review against support
175
+ * copy — put both at -10.6% and -10.0% under it, and solving the constant on
176
+ * the two together lands on 1.35, where both come out at 0.0%.
177
+ *
178
+ * Two independent texts agreeing to within four tenths of a point across the
179
+ * whole search is what makes this a property of Hangul rather than a fit to a
180
+ * file. Their residuals move in lockstep at every candidate value: -10.6/-10.0
181
+ * at 1.20, -3.5/-3.1 at 1.30, 3.2/3.4 at 1.40. One sample cannot show that and
182
+ * two can, which is the entire argument for measuring more of the thin classes
183
+ * rather than tuning harder on the thin ones.
184
+ *
185
+ * Still in-sample: the honest test is a third Korean prompt, and the corpus
186
+ * grows one at a time.
187
+ */
188
+ const HANGUL_TOKENS_PER_CHAR = 1.35;
189
+ const HANGUL = /[가-힯]/;
167
190
  /**
168
191
  * What a prompt gets when the language could not be told.
169
192
  *
@@ -233,7 +256,11 @@ export function estimateTokens(text) {
233
256
  * where the loop happens to break, not of what the text costs.
234
257
  */
235
258
  while (i < chars.length && CJK.test(chars[i])) {
236
- cjkTokens += KANA.test(chars[i]) ? KANA_TOKENS_PER_CHAR : HAN_TOKENS_PER_CHAR;
259
+ cjkTokens += KANA.test(chars[i])
260
+ ? KANA_TOKENS_PER_CHAR
261
+ : HANGUL.test(chars[i])
262
+ ? HANGUL_TOKENS_PER_CHAR
263
+ : HAN_TOKENS_PER_CHAR;
237
264
  i++;
238
265
  }
239
266
  continue;
@@ -295,7 +322,29 @@ export function estimateTokens(text) {
295
322
  i++;
296
323
  }
297
324
  else {
298
- total += Math.ceil(n / 2);
325
+ /**
326
+ * One token per symbol, not one per two.
327
+ *
328
+ * Two was the shipped value and every symbol-dense sample in the corpus
329
+ * undercounted under it, in the same direction, by amounts that grow with
330
+ * density: punctuation-heavy -5.7%, code-heavy -6.4%,
331
+ * punctuation-markup -11.4%, code-sql -25.6%, code-shell -29.8%. Five
332
+ * samples agreeing on a direction is a shape, not a fit — a merge table
333
+ * covers `, ` and `. ` and covers `${`, `"$`, `--` and `&#8209;` far less
334
+ * well, and shell and SQL are made of the second kind.
335
+ *
336
+ * Searched over the whole corpus rather than the class it helps, so a
337
+ * value that fixed code by wrecking prose could not look like a win: at
338
+ * 1.0 the samples outside the published band drop from five to three and
339
+ * the mean error from 6.6% to 5.1%, with no sample moved more than a
340
+ * point in the wrong direction.
341
+ *
342
+ * The search wanted to go below 1.0 and was not allowed to. Below one is
343
+ * more than a token per symbol, which may well be true of SQL — code-sql
344
+ * is still 24.9% under — but it is a claim about a class this corpus has
345
+ * two samples of, and two samples do not earn a constant.
346
+ */
347
+ total += Math.ceil(n / 1);
299
348
  }
300
349
  }
301
350
  // Rounded once, over the whole document, rather than per run — see the CJK branch.
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,QAAmC;IAC7D,OAAO,QAAQ,KAAK,wBAAwB,CAAC;AAC/C,CAAC;AAED,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,IAAI,GAAG,OAAO,CAAC;AACrB,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,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,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;SAC7E,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA6B,CAAC;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -48,7 +48,7 @@ export interface RuleResult {
48
48
  /** Severity of an advisory: the higher it is, the more money is usually at stake. */
49
49
  export type AdvisorySeverity = 'info' | 'opportunity' | 'warning';
50
50
  /** Every advisory the core can emit. */
51
- export type AdvisoryId = 'context-overflow' | 'context-near-limit' | 'prompt-caching' | 'prompt-caching-not-worth-it' | 'below-cache-minimum' | 'cache-prefix-reorder' | 'batch-api' | 'model-downgrade' | 'output-dominated' | 'promo-pricing' | 'contradictory-instructions' | 'redundant-examples' | 'restated-output-format' | 'movable-output-schema';
51
+ export type AdvisoryId = 'context-overflow' | 'context-near-limit' | 'prompt-caching' | 'prompt-caching-not-worth-it' | 'below-cache-minimum' | 'cache-prefix-reorder' | 'batch-api' | 'model-downgrade' | 'tier-signals-conflict' | 'output-dominated' | 'promo-pricing' | 'contradictory-instructions' | 'redundant-examples' | 'restated-output-format' | 'movable-output-schema';
52
52
  /** A recommendation that does NOT modify the prompt, only informs. */
53
53
  export interface Advisory {
54
54
  id: AdvisoryId;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAi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rB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE;AAED,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Reading a dropped `route --json` verdict, so quality can stand beside cost.
3
+ *
4
+ * The bill is arithmetic: every figure in it comes from records already on
5
+ * disk, and it can say exactly what a cheaper model would have saved. It can
6
+ * say nothing at all about whether that model still does the job. That answer
7
+ * costs provider calls and a credential, which is why `trazum route` exists
8
+ * and why no surface that only reads a log will ever produce it.
9
+ *
10
+ * This is the bridge between the two, and it is deliberately one-directional:
11
+ * the measurement is made where the credential is, written out as the
12
+ * `routing-measurement` contract, and read back here by a pure function that
13
+ * touches no network and holds no key. A reader who has run `route` once can
14
+ * carry the verdict to any surface that prices the same workload.
15
+ *
16
+ * It was not possible to write until the document was worth reading. Before
17
+ * the JSON-text sweep, `route --json` printed the whole `EvalReport` — every
18
+ * case input and three model answers per case — so a bridge would have been a
19
+ * feature for carrying prompt text into a browser. The document carries the
20
+ * measurement and nothing else now, and `conform` is what says so rather than
21
+ * this file's own reading: the contract validates, the bridge only maps.
22
+ */
23
+ import type { EvalVerdict } from './evaluate.js';
24
+ /** What a dropped routing measurement says, mapped onto what a bill can match. */
25
+ export interface DroppedVerdict {
26
+ /** The workload the measurement was made on, or null when it was unlabelled. */
27
+ label: string | null;
28
+ /**
29
+ * The model those calls go to today, from the bill's own slice.
30
+ *
31
+ * Not the model that answered. `route` builds its baseline provider from
32
+ * the environment, so the model in the measurement is whatever
33
+ * `TRAZUM_LLM_MODEL` names, and it is only the log's model when the reader
34
+ * configured it that way. Pairing on it matched nothing on a real run
35
+ * against an OpenAI-compatible endpoint — `evaluation.model` said
36
+ * `stub-strong` while the log said `claude-opus-5` — and the bill would
37
+ * have shown no verdict at all with no explanation.
38
+ */
39
+ model: string;
40
+ /**
41
+ * The model that actually answered, when it is not the one the log records.
42
+ *
43
+ * Null when they agree, which is the ordinary case. Not null is worth
44
+ * saying out loud rather than smoothing over: a verdict measured on a
45
+ * stand-in is a weaker claim about this workload than one measured on the
46
+ * model the workload actually uses, and only this field can tell the
47
+ * difference.
48
+ */
49
+ measuredOn: string | null;
50
+ /** The model measured against it. */
51
+ candidateModel: string;
52
+ verdict: EvalVerdict;
53
+ /** The model's agreement with itself. The yardstick the other rate is read against. */
54
+ selfAgreement: number;
55
+ /** Agreement between the two models, same prompt on both sides. */
56
+ crossAgreement: number;
57
+ /** Cases the measurement covered, so a two-case verdict cannot pose as a hundred. */
58
+ cases: number;
59
+ /** Calls it cost to reach. */
60
+ callsMade: number;
61
+ /**
62
+ * What the measurement's own bill priced the route at, when the document
63
+ * carried it. Null rather than zero when it did not: a saving nobody
64
+ * measured is not a saving of nothing.
65
+ */
66
+ savingUsd: number | null;
67
+ }
68
+ /**
69
+ * What the bridge did with a file.
70
+ *
71
+ * `null` is not a failure: it means the file is not a routing measurement at
72
+ * all, and the caller should go on treating it as whatever else it was. A
73
+ * refusal is the other case — it looked like one and could not be read — and
74
+ * it names what is missing, because a refusal with nothing after it is
75
+ * indistinguishable from a bug.
76
+ */
77
+ export type BridgeReading = {
78
+ kind: 'verdict';
79
+ verdict: DroppedVerdict;
80
+ } | {
81
+ kind: 'refusal';
82
+ because: string;
83
+ };
84
+ /**
85
+ * Reads a dropped `trazum route --json` document.
86
+ *
87
+ * Returns null when the text is something else entirely. Validation is
88
+ * `conform`'s, against the published `routing-measurement` contract, so this
89
+ * function cannot drift from the schema a connector author builds against —
90
+ * and a document that fails carries the contract's own sentences back to the
91
+ * reader rather than a second opinion written here.
92
+ */
93
+ export declare function readDroppedVerdict(text: string): BridgeReading | null;
94
+ /**
95
+ * Whether a verdict describes the route a given slice of the bill is offering.
96
+ *
97
+ * Both halves must agree or the pairing is a lie: the same workload, the same
98
+ * model it goes to now, and the same candidate. A verdict measured on `chat`
99
+ * shown against `summarise`'s saving would be the exact fault this repository
100
+ * keeps finding in itself — a number describing something other than what was
101
+ * measured — and matching on the model alone would produce it on any log with
102
+ * two workloads on one model.
103
+ */
104
+ export declare function verdictMatchesSlice(verdict: DroppedVerdict, slice: {
105
+ label: string;
106
+ model: string;
107
+ route: {
108
+ candidate: {
109
+ id: string;
110
+ };
111
+ } | null;
112
+ }): boolean;
113
+ //# sourceMappingURL=verdict-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict-bridge.d.ts","sourceRoot":"","sources":["../src/verdict-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;;;;;;;OAUG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,uFAAuF;IACvF,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,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