@trazum/cli 3.0.0 → 3.0.2

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 (109) hide show
  1. package/README.md +4 -1
  2. package/assets/trazum-statusline.sh +45 -0
  3. package/dist/base-cost.d.ts +173 -0
  4. package/dist/base-cost.d.ts.map +1 -0
  5. package/dist/base-cost.js +244 -0
  6. package/dist/base-cost.js.map +1 -0
  7. package/dist/bill-range.d.ts +118 -0
  8. package/dist/bill-range.d.ts.map +1 -0
  9. package/dist/bill-range.js +122 -0
  10. package/dist/bill-range.js.map +1 -0
  11. package/dist/command-help.d.ts +17 -0
  12. package/dist/command-help.d.ts.map +1 -0
  13. package/dist/command-help.js +69 -0
  14. package/dist/command-help.js.map +1 -0
  15. package/dist/filter.d.ts +7 -1
  16. package/dist/filter.d.ts.map +1 -1
  17. package/dist/filter.js +10 -18
  18. package/dist/filter.js.map +1 -1
  19. package/dist/gateway-metrics.d.ts +83 -0
  20. package/dist/gateway-metrics.d.ts.map +1 -0
  21. package/dist/gateway-metrics.js +181 -0
  22. package/dist/gateway-metrics.js.map +1 -0
  23. package/dist/gateway-server.d.ts +23 -5
  24. package/dist/gateway-server.d.ts.map +1 -1
  25. package/dist/gateway-server.js +26 -1
  26. package/dist/gateway-server.js.map +1 -1
  27. package/dist/gateway-spend.d.ts +11 -1
  28. package/dist/gateway-spend.d.ts.map +1 -1
  29. package/dist/gateway-spend.js +44 -32
  30. package/dist/gateway-spend.js.map +1 -1
  31. package/dist/git.d.ts +70 -0
  32. package/dist/git.d.ts.map +1 -1
  33. package/dist/git.js +145 -0
  34. package/dist/git.js.map +1 -1
  35. package/dist/i18n/en.d.ts.map +1 -1
  36. package/dist/i18n/en.js +358 -6
  37. package/dist/i18n/en.js.map +1 -1
  38. package/dist/i18n/es.d.ts +0 -1
  39. package/dist/i18n/es.d.ts.map +1 -1
  40. package/dist/i18n/es.js +456 -35
  41. package/dist/i18n/es.js.map +1 -1
  42. package/dist/i18n/types.d.ts +205 -0
  43. package/dist/i18n/types.d.ts.map +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +942 -59
  46. package/dist/index.js.map +1 -1
  47. package/dist/loopback-guard.d.ts +37 -0
  48. package/dist/loopback-guard.d.ts.map +1 -0
  49. package/dist/loopback-guard.js +65 -0
  50. package/dist/loopback-guard.js.map +1 -0
  51. package/dist/markdown.d.ts +23 -0
  52. package/dist/markdown.d.ts.map +1 -1
  53. package/dist/markdown.js +105 -0
  54. package/dist/markdown.js.map +1 -1
  55. package/dist/plan-edits.d.ts +63 -0
  56. package/dist/plan-edits.d.ts.map +1 -0
  57. package/dist/plan-edits.js +96 -0
  58. package/dist/plan-edits.js.map +1 -0
  59. package/dist/proactive.d.ts +17 -2
  60. package/dist/proactive.d.ts.map +1 -1
  61. package/dist/proactive.js +16 -9
  62. package/dist/proactive.js.map +1 -1
  63. package/dist/receipt-send.d.ts +44 -0
  64. package/dist/receipt-send.d.ts.map +1 -0
  65. package/dist/receipt-send.js +71 -0
  66. package/dist/receipt-send.js.map +1 -0
  67. package/dist/serve.d.ts +7 -0
  68. package/dist/serve.d.ts.map +1 -1
  69. package/dist/serve.js +22 -1
  70. package/dist/serve.js.map +1 -1
  71. package/dist/session-guard.d.ts +210 -0
  72. package/dist/session-guard.d.ts.map +1 -0
  73. package/dist/session-guard.js +463 -0
  74. package/dist/session-guard.js.map +1 -0
  75. package/dist/task.d.ts +7 -1
  76. package/dist/task.d.ts.map +1 -1
  77. package/dist/task.js +7 -26
  78. package/dist/task.js.map +1 -1
  79. package/dist/waste.d.ts +25 -0
  80. package/dist/waste.d.ts.map +1 -0
  81. package/dist/waste.js +39 -0
  82. package/dist/waste.js.map +1 -0
  83. package/dist/zone.d.ts +27 -0
  84. package/dist/zone.d.ts.map +1 -0
  85. package/dist/zone.js +96 -0
  86. package/dist/zone.js.map +1 -0
  87. package/package.json +2 -2
  88. package/src/base-cost.ts +384 -0
  89. package/src/bill-range.ts +206 -0
  90. package/src/command-help.ts +65 -0
  91. package/src/filter.ts +11 -18
  92. package/src/gateway-metrics.ts +209 -0
  93. package/src/gateway-server.ts +43 -6
  94. package/src/gateway-spend.ts +45 -33
  95. package/src/git.ts +158 -0
  96. package/src/i18n/en.ts +424 -6
  97. package/src/i18n/es.ts +542 -35
  98. package/src/i18n/types.ts +208 -0
  99. package/src/index.ts +952 -58
  100. package/src/loopback-guard.ts +74 -0
  101. package/src/markdown.ts +117 -0
  102. package/src/plan-edits.ts +120 -0
  103. package/src/proactive.ts +22 -13
  104. package/src/receipt-send.ts +89 -0
  105. package/src/serve.ts +23 -1
  106. package/src/session-guard.ts +541 -0
  107. package/src/task.ts +8 -26
  108. package/src/waste.ts +42 -0
  109. package/src/zone.ts +95 -0
@@ -0,0 +1,122 @@
1
+ import { profileUsage } from '@trazum/core';
2
+ /**
3
+ * The span from the earliest author or commit time to the latest.
4
+ *
5
+ * Both times, because they differ exactly when it matters: a commit rebased
6
+ * onto `main` yesterday was written last week, and the work happened last week.
7
+ * `null` for an empty range, which has no span.
8
+ */
9
+ export function windowOf(times) {
10
+ if (times.length === 0)
11
+ return null;
12
+ const all = times.flatMap((t) => [t.authorMs, t.committerMs]);
13
+ return { fromMs: Math.min(...all), toMs: Math.max(...all), commits: times.length };
14
+ }
15
+ /**
16
+ * The name Claude Code gives a project folder for a repository at `root`, less
17
+ * the leading dashes the label shows without (see `projectLabelFor`). It is an
18
+ * encoding of a path that git supplied; it is never decoded back.
19
+ */
20
+ export function projectLabelOfRoot(root) {
21
+ const encoded = root.replace(/[^A-Za-z0-9]/g, '-');
22
+ const trimmed = encoded.replace(/^-+/, '');
23
+ return trimmed !== '' ? trimmed : encoded;
24
+ }
25
+ const priced = (lines, catalogue) => {
26
+ if (lines.length === 0)
27
+ return { usd: 0, calls: 0, unpriced: 0 };
28
+ const report = profileUsage(lines.join('\n'), { catalogue });
29
+ return { usd: report.total.totalUsd, calls: report.total.calls, unpriced: report.unpriced.calls };
30
+ };
31
+ /**
32
+ * Splits the records of one project against the window and prices each part.
33
+ *
34
+ * `claudeCodeLines` are the usage-log records of the Claude Code transcripts,
35
+ * each carrying the label of its project folder. A record whose label is not
36
+ * `project` is another project's and is counted out, not read further.
37
+ * `otherSources` is how many records came from anywhere else (Codex, Gemini
38
+ * CLI, a log): they carry no project folder this can match, so they are named
39
+ * as left out and never guessed at.
40
+ */
41
+ export function billRange(input) {
42
+ const { window, catalogue } = input;
43
+ const leftOut = { otherProjects: 0, otherSources: input.otherSources, undated: 0 };
44
+ const bySession = new Map();
45
+ let anonymous = 0;
46
+ let projectRecords = 0;
47
+ for (const line of input.claudeCodeLines) {
48
+ let record;
49
+ try {
50
+ record = JSON.parse(line);
51
+ }
52
+ catch {
53
+ continue;
54
+ }
55
+ if (record.label !== input.project) {
56
+ leftOut.otherProjects += 1;
57
+ continue;
58
+ }
59
+ projectRecords += 1;
60
+ const ms = typeof record.ts === 'string' ? Date.parse(record.ts) : Number.NaN;
61
+ if (Number.isNaN(ms)) {
62
+ leftOut.undated += 1;
63
+ continue;
64
+ }
65
+ /* A call that names no session is a session of one call: it cannot cross an edge. */
66
+ const session = typeof record.session === 'string' && record.session !== '' ? record.session : `\u0000${anonymous++}`;
67
+ const own = bySession.get(session) ?? [];
68
+ own.push({ line, ms, session });
69
+ bySession.set(session, own);
70
+ }
71
+ const insideLines = [];
72
+ let insideSessions = 0;
73
+ let outsideCalls = 0;
74
+ const straddling = [];
75
+ const within = (ms) => ms >= window.fromMs && ms <= window.toMs;
76
+ for (const [session, records] of bySession) {
77
+ const firstMs = Math.min(...records.map((r) => r.ms));
78
+ const lastMs = Math.max(...records.map((r) => r.ms));
79
+ if (within(firstMs) && within(lastMs)) {
80
+ insideSessions += 1;
81
+ for (const r of records)
82
+ insideLines.push(r.line);
83
+ }
84
+ else if (lastMs < window.fromMs || firstMs > window.toMs) {
85
+ outsideCalls += records.length;
86
+ }
87
+ else {
88
+ const inside = priced(records.filter((r) => within(r.ms)).map((r) => r.line), catalogue);
89
+ const outside = priced(records.filter((r) => !within(r.ms)).map((r) => r.line), catalogue);
90
+ straddling.push({
91
+ session,
92
+ firstMs,
93
+ lastMs,
94
+ insideUsd: inside.usd,
95
+ insideCalls: inside.calls + inside.unpriced,
96
+ outsideUsd: outside.usd,
97
+ outsideCalls: outside.calls + outside.unpriced,
98
+ });
99
+ }
100
+ }
101
+ straddling.sort((a, b) => a.firstMs - b.firstMs || (a.session < b.session ? -1 : 1));
102
+ const total = priced(insideLines, catalogue);
103
+ return {
104
+ window,
105
+ projectRecords,
106
+ inside: { usd: total.usd, calls: total.calls, sessions: insideSessions, unpricedCalls: total.unpriced },
107
+ straddling,
108
+ outsideCalls,
109
+ leftOut,
110
+ };
111
+ }
112
+ /**
113
+ * The recorded figure divided by each delivery count (#825): the arithmetic and
114
+ * nothing else. `null` where the count is zero, so a figure is never divided by
115
+ * nothing and never printed as $0. It is an average over the span: it says
116
+ * nothing about what any one commit, pull request or day was worth or cost.
117
+ */
118
+ export function perDelivery(usd, delivery) {
119
+ const per = (count) => (count > 0 ? usd / count : null);
120
+ return { perCommit: per(delivery.commits), perPullRequest: per(delivery.pullRequests), perDay: per(delivery.days) };
121
+ }
122
+ //# sourceMappingURL=bill-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bill-range.js","sourceRoot":"","sources":["../src/bill-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6C5C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA6B;IACpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAA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AK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/E,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;AACtH,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The help for one command, cut from the help for all of them (#865).
3
+ *
4
+ * The README promises that `trazum <command> --help` explains that command's
5
+ * flags. It printed the whole help, 1,332 lines, for every command but `task`.
6
+ * The help already carries each command's flags in a section of its own
7
+ * ("OPTIONS FOR bill", "OPCIONES DE bill"), so the answer is cut from it
8
+ * rather than written a second time: one text, in every language, and a
9
+ * section that cannot drift from the full help because it is the full help.
10
+ *
11
+ * What is cut: the command's lines from the usage section (with the lines that
12
+ * continue them), every section whose heading ends in the command's name, and
13
+ * a closing line saying where the rest is. A command that appears in neither
14
+ * gets `undefined`, and the caller prints the whole help as before.
15
+ */
16
+ export declare function commandHelp(rendered: string, plain: string, command: string, more: string): string | undefined;
17
+ //# sourceMappingURL=command-help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-help.d.ts","sourceRoot":"","sources":["../src/command-help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA6C9G"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The help for one command, cut from the help for all of them (#865).
3
+ *
4
+ * The README promises that `trazum <command> --help` explains that command's
5
+ * flags. It printed the whole help, 1,332 lines, for every command but `task`.
6
+ * The help already carries each command's flags in a section of its own
7
+ * ("OPTIONS FOR bill", "OPCIONES DE bill"), so the answer is cut from it
8
+ * rather than written a second time: one text, in every language, and a
9
+ * section that cannot drift from the full help because it is the full help.
10
+ *
11
+ * What is cut: the command's lines from the usage section (with the lines that
12
+ * continue them), every section whose heading ends in the command's name, and
13
+ * a closing line saying where the rest is. A command that appears in neither
14
+ * gets `undefined`, and the caller prints the whole help as before.
15
+ */
16
+ /** A heading starts at column 0; everything under it is indented. */
17
+ const isHeading = (line) => line.length > 0 && !/^\s/.test(line);
18
+ export function commandHelp(rendered, plain, command, more) {
19
+ const lines = plain.split('\n');
20
+ const shown = rendered.split('\n');
21
+ // Rendering only wraps words in escape codes, so the two have the same lines.
22
+ if (lines.length !== shown.length)
23
+ return undefined;
24
+ // A section runs from its heading to the next heading, or to the end.
25
+ const headings = lines.flatMap((line, index) => (isHeading(line) ? [index] : []));
26
+ const sections = headings.map((start, k) => ({ start, end: headings.at(k + 1) ?? lines.length }));
27
+ const opensWith = (line) => line === ` trazum ${command}` || line.startsWith(` trazum ${command} `);
28
+ // The usage section is the one with the most lines that open with `trazum`.
29
+ const usage = sections.reduce((best, section) => {
30
+ const count = (s) => lines.slice(s.start + 1, s.end).filter((line) => line.startsWith(' trazum ')).length;
31
+ return best === undefined || count(section) > count(best) ? section : best;
32
+ }, undefined);
33
+ const out = [];
34
+ if (usage !== undefined) {
35
+ const picked = [];
36
+ const shownBody = shown.slice(usage.start + 1, usage.end);
37
+ let taking = false;
38
+ lines.slice(usage.start + 1, usage.end).forEach((line, index) => {
39
+ // A long usage line continues on lines indented past the command: three
40
+ // spaces or more, then text. Said without a regular expression, which a
41
+ // scanner reads as one a visitor's input could make slow.
42
+ if (opensWith(line))
43
+ taking = true;
44
+ else if (!(line.startsWith(' ') && line.trim().length > 0))
45
+ taking = false;
46
+ if (taking)
47
+ picked.push(shownBody.at(index) ?? '');
48
+ });
49
+ if (picked.length > 0)
50
+ out.push(shown.at(usage.start) ?? '', ...picked);
51
+ }
52
+ for (const section of sections) {
53
+ if (section === usage)
54
+ continue;
55
+ const heading = lines.at(section.start) ?? '';
56
+ if (!(heading.endsWith(` ${command}`) || heading === `trazum ${command}`))
57
+ continue;
58
+ const body = shown.slice(section.start, section.end);
59
+ while (body.length > 0 && (body.at(-1) ?? '').trim() === '')
60
+ body.pop();
61
+ if (out.length > 0)
62
+ out.push('');
63
+ out.push(...body);
64
+ }
65
+ if (out.length === 0)
66
+ return undefined;
67
+ return [...out, '', more].join('\n');
68
+ }
69
+ //# sourceMappingURL=command-help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-help.js","sourceRoot":"","sources":["../src/command-help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qEAAqE;AACrE,MAAM,SAAS,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAElF,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,KAAa,EAAE,OAAe,EAAE,IAAY;IACxF,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,8EAA8E;IAC9E,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAEpD,sEAAsE;IACtE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,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GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACvC,OAAO,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
package/dist/filter.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- export declare function runFilter(args: string[]): Promise<void>;
1
+ import type { CliMessages } from './i18n/types.js';
2
+ /**
3
+ * `trazum filter`. Its help comes from the reader's catalogue; its errors are
4
+ * raised in English and said in the reader's language where `main` reports
5
+ * them (#871).
6
+ */
7
+ export declare function runFilter(args: string[], messages: CliMessages['taskFilter']): Promise<void>;
2
8
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAyHA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B7D"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsGnD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BlG"}
package/dist/filter.js CHANGED
@@ -6,19 +6,6 @@ import { resolve, join } from 'node:path';
6
6
  import { once } from 'node:events';
7
7
  import { compactToolOutput, EFFICIENT_OUTPUT_INSTRUCTIONS } from '@trazum/core';
8
8
  const MAX_BYTES = 1024 * 1024;
9
- const HELP = `Usage:
10
- trazum filter compact --recovery-dir <private-directory> [--stats]
11
- trazum filter restore <sha256> --recovery-dir <private-directory>
12
- trazum filter instructions print optional output guidance
13
-
14
- Experimental, opt-in display filter. Only consecutive repeated log lines are
15
- compacted. Errors and unique lines are kept. Not for source files or data pipes.
16
- Use Bash pipefail to preserve the producing command's failure status.
17
- Original logs may contain sensitive data: --recovery-dir explicitly opts into local
18
- retention. Delete that directory when the originals are no longer needed.
19
- Token counts are estimates, not billing or subscription-quota measurements.
20
- --stats writes one JSON record to stderr, without log content or recovery paths.
21
- `;
22
9
  /** Report only the view actually emitted, including recovery-instruction overhead. */
23
10
  function reportStats(inputBytes, outputBytes, view, reason, applied = false) {
24
11
  const before = view?.estimatedTokensBefore ?? null;
@@ -87,7 +74,7 @@ async function saveOriginal(store, key, bytes) {
87
74
  await file.close();
88
75
  }
89
76
  }
90
- async function compact(store, stats) {
77
+ async function compact(store, stats, messages) {
91
78
  const chunks = [];
92
79
  let size = 0;
93
80
  let passthrough = false;
@@ -137,7 +124,7 @@ async function compact(store, stats) {
137
124
  catch {
138
125
  // A filter must not swallow a tool's output because local persistence failed.
139
126
  if (!stats)
140
- process.stderr.write('Trazum: original could not be retained; passing log through unchanged.\n');
127
+ process.stderr.write(`${messages.say('Trazum: original could not be retained; passing log through unchanged.')}\n`);
141
128
  await emit(bytes);
142
129
  if (stats)
143
130
  reportStats(size, size, view, 'storage-failed');
@@ -147,7 +134,12 @@ async function compact(store, stats) {
147
134
  if (stats)
148
135
  reportStats(size, Buffer.byteLength(view.text), view, view.reason, true);
149
136
  }
150
- export async function runFilter(args) {
137
+ /**
138
+ * `trazum filter`. Its help comes from the reader's catalogue; its errors are
139
+ * raised in English and said in the reader's language where `main` reports
140
+ * them (#871).
141
+ */
142
+ export async function runFilter(args, messages) {
151
143
  let stats = false;
152
144
  if (args[0] === 'compact' && args.length === 4) {
153
145
  const index = args[1] === '--stats' ? 1 : args[3] === '--stats' ? 3 : -1;
@@ -157,7 +149,7 @@ export async function runFilter(args) {
157
149
  }
158
150
  }
159
151
  if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0]))) {
160
- await emit(HELP);
152
+ await emit(messages.filterHelp);
161
153
  return;
162
154
  }
163
155
  if (args.length === 1 && args[0] === 'instructions') {
@@ -181,7 +173,7 @@ export async function runFilter(args) {
181
173
  else {
182
174
  if (process.stdin.isTTY)
183
175
  throw new Error('Pipe a tool log into stdin; interactive tools are not supported.');
184
- await compact(store, stats);
176
+ await compact(store, stats, messages);
185
177
  }
186
178
  }
187
179
  //# sourceMappingURL=filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAuB,MAAM,cAAc,CAAC;AAErG,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9B,MAAM,IAAI,GAAG;;;;;;;;;;;;CAYZ,CAAC;AAEF,sFAAsF;AACtF,SAAS,WAAW,CAAC,UAAkB,EAAE,WAAmB,EAAE,IAA2B,EACvF,MAAc,EAAE,OAAO,GAAG,KAAK;IAC/B,MAAM,MAAM,GAAG,IAAI,EAAE,qBAAqB,IAAI,IAAI,CAAC;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,oBAAoB,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,MAAM,KAAK,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;IACxE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;Q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CAAC,CAAC,CAAE,CAAC;QACrB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC5F,MAAM,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,IAAI,CAAC,MAAM,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC7G,MAAM,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * What the gateway has counted since it started, for Prometheus to scrape.
3
+ *
4
+ * **A second port, not a path on the first.** The proxy's port answers the
5
+ * paths `UPSTREAMS` names and nothing else, and `route` is the one reader of a
6
+ * caller's URL there. A `/metrics` beside `/v1/messages` would be a second
7
+ * opinion about what that port does. So the counts are served on their own
8
+ * loopback port, given with `--metrics-port`, and that port forwards nothing:
9
+ * it has no upstream, no `fetch` and no credential in reach.
10
+ *
11
+ * **Counts only.** Every value here is a number the gateway already had: the
12
+ * provider's own token counts, a call's cost at the catalogue's list rates, and
13
+ * how many calls were refused, substituted, forwarded free or left unmeasured.
14
+ * The labels are the provider, the model, the caller's own `trazum_label`, a
15
+ * refusal's reason and an unmeasured call's cause. No prompt, no response and
16
+ * no session reach this module: `trazum_session` is used to judge and is never
17
+ * recorded, and it is not recorded here either.
18
+ *
19
+ * **Counters reset when the gateway restarts.** They are this process's, as
20
+ * the live budget is. Prometheus reads a fall in a counter as a reset, and
21
+ * `trazum_gateway_start_time_seconds` says when this process began.
22
+ *
23
+ * **The label set is bounded.** A model name and a `trazum_label` are both the
24
+ * caller's text, so a caller sending a new one on every call would grow the
25
+ * series without limit, in this process and in Prometheus. Past
26
+ * `MAX_SERIES_KEYS` distinct model and label pairs, and as many substitution
27
+ * pairs, a call with a new one is left out of every figure whole and counted in
28
+ * `trazum_gateway_calls_dropped_total` instead, so the totals say they are
29
+ * short rather than look complete.
30
+ */
31
+ import type { Server } from 'node:http';
32
+ import type { GatewayCount, UnmeasuredCause } from './gateway-server.js';
33
+ /** Distinct model and label pairs kept, and as many substitution pairs, before a call with a new one is left out. */
34
+ export declare const MAX_SERIES_KEYS = 1000;
35
+ /** What every cost sample says about itself: the list rates, not an invoice. */
36
+ export declare const COST_BASIS = "api-equivalent";
37
+ /** A call the gateway forwarded and measured, as `record` receives it: counts, no text. */
38
+ export interface MeasuredCall {
39
+ model: string;
40
+ label: string | null;
41
+ inputTokens: number;
42
+ outputTokens: number;
43
+ cacheReadTokens: number;
44
+ cacheWriteTokens: number;
45
+ substituted: boolean;
46
+ }
47
+ export declare class GatewayMetrics {
48
+ private dropped;
49
+ private readonly seen;
50
+ private readonly swaps;
51
+ private readonly calls;
52
+ private readonly tokens;
53
+ private readonly cost;
54
+ private readonly unpriced;
55
+ private readonly unmeasuredCalls;
56
+ private readonly refused;
57
+ private readonly substituted;
58
+ private readonly free;
59
+ private readonly unreachable;
60
+ private readonly provider;
61
+ private readonly startedMs;
62
+ constructor(provider: string, startedMs: number);
63
+ /**
64
+ * Whether a call with this key may be counted: a key already held, or room
65
+ * for a new one. A call refused here is counted only as dropped.
66
+ */
67
+ private admit;
68
+ /** A measured call, and its cost at list rates, or `null` when the catalogue does not price it. */
69
+ measured(call: MeasuredCall, usd: number | null): void;
70
+ unmeasured(cause: UnmeasuredCause): void;
71
+ count(event: GatewayCount): void;
72
+ /** The Prometheus text exposition, ending with a line break as the format requires. */
73
+ text(): string;
74
+ }
75
+ /**
76
+ * The scrape server: `GET /metrics` and nothing else.
77
+ *
78
+ * Behind the same host and origin guard as the proxy and `serve`, so a page
79
+ * that rebound its own hostname to 127.0.0.1 cannot read which models and
80
+ * labels this gateway has seen.
81
+ */
82
+ export declare function buildMetricsServer(metrics: GatewayMetrics): Server;
83
+ //# sourceMappingURL=gateway-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-metrics.d.ts","sourceRoot":"","sources":["../src/gateway-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,WAAW,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE,qHAAqH;AACrH,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,gFAAgF;AAChF,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAI3C,2FAA2F;AAC3F,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB;AAmCD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4G;IAClI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwF;IAC/G,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgI;IACrJ,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqM;IAC9N,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsJ;IACtL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyG;IACjI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmH;IAC/I,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA+H;IACpJ,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0H;IAEtJ,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,YAAY,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAM9C;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK;IAUb,mGAAmG;IACnG,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAarD;IAED,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAEvC;IAED,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAU/B;IAED,uFAAuF;IACvF,IAAI,IAAI,MAAM,CAeb;CACF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAsBlE"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * What the gateway has counted since it started, for Prometheus to scrape.
3
+ *
4
+ * **A second port, not a path on the first.** The proxy's port answers the
5
+ * paths `UPSTREAMS` names and nothing else, and `route` is the one reader of a
6
+ * caller's URL there. A `/metrics` beside `/v1/messages` would be a second
7
+ * opinion about what that port does. So the counts are served on their own
8
+ * loopback port, given with `--metrics-port`, and that port forwards nothing:
9
+ * it has no upstream, no `fetch` and no credential in reach.
10
+ *
11
+ * **Counts only.** Every value here is a number the gateway already had: the
12
+ * provider's own token counts, a call's cost at the catalogue's list rates, and
13
+ * how many calls were refused, substituted, forwarded free or left unmeasured.
14
+ * The labels are the provider, the model, the caller's own `trazum_label`, a
15
+ * refusal's reason and an unmeasured call's cause. No prompt, no response and
16
+ * no session reach this module: `trazum_session` is used to judge and is never
17
+ * recorded, and it is not recorded here either.
18
+ *
19
+ * **Counters reset when the gateway restarts.** They are this process's, as
20
+ * the live budget is. Prometheus reads a fall in a counter as a reset, and
21
+ * `trazum_gateway_start_time_seconds` says when this process began.
22
+ *
23
+ * **The label set is bounded.** A model name and a `trazum_label` are both the
24
+ * caller's text, so a caller sending a new one on every call would grow the
25
+ * series without limit, in this process and in Prometheus. Past
26
+ * `MAX_SERIES_KEYS` distinct model and label pairs, and as many substitution
27
+ * pairs, a call with a new one is left out of every figure whole and counted in
28
+ * `trazum_gateway_calls_dropped_total` instead, so the totals say they are
29
+ * short rather than look complete.
30
+ */
31
+ import { createServer } from 'node:http';
32
+ import { prometheusLabelValue } from '@trazum/core';
33
+ import { refuseHost } from './loopback-guard.js';
34
+ /** Distinct model and label pairs kept, and as many substitution pairs, before a call with a new one is left out. */
35
+ export const MAX_SERIES_KEYS = 1000;
36
+ /** What every cost sample says about itself: the list rates, not an invoice. */
37
+ export const COST_BASIS = 'api-equivalent';
38
+ const UNMEASURED_CAUSES = ['stream-broke', 'no-usage-event', 'no-usage-in-body'];
39
+ /** One counter: a value per label set. The bound is `GatewayMetrics.admit`'s. */
40
+ class Counter {
41
+ values = new Map();
42
+ name;
43
+ help;
44
+ constructor(name, help) {
45
+ this.name = name;
46
+ this.help = help;
47
+ }
48
+ add(labels, by) {
49
+ const key = JSON.stringify(labels);
50
+ const entry = this.values.get(key);
51
+ if (entry === undefined)
52
+ this.values.set(key, { labels, value: by });
53
+ else
54
+ entry.value += by;
55
+ }
56
+ lines() {
57
+ const out = [`# HELP ${this.name} ${this.help}`, `# TYPE ${this.name} counter`];
58
+ for (const { labels, value } of this.values.values())
59
+ out.push(`${this.name}${render(labels)} ${value}`);
60
+ return out;
61
+ }
62
+ }
63
+ const render = (labels) => {
64
+ const pairs = Object.entries(labels);
65
+ return pairs.length === 0 ? '' : `{${pairs.map(([key, value]) => `${key}="${prometheusLabelValue(value)}"`).join(',')}}`;
66
+ };
67
+ export class GatewayMetrics {
68
+ dropped = 0;
69
+ seen = new Set();
70
+ swaps = new Set();
71
+ calls = new Counter('trazum_gateway_calls_measured_total', 'Calls forwarded whose usage the provider reported.');
72
+ tokens = new Counter('trazum_gateway_tokens_total', 'Tokens the provider reported, by kind.');
73
+ cost = new Counter('trazum_gateway_cost_usd_total', 'Cost of measured calls at the catalogue list rates (API-equivalent), in USD.');
74
+ unpriced = new Counter('trazum_gateway_calls_unpriced_total', 'Measured calls that could not be priced at list rates (a model the catalogue does not carry, or counts it cannot price); in no cost sample.');
75
+ unmeasuredCalls = new Counter('trazum_gateway_calls_unmeasured_total', 'Calls forwarded whose cost could not be measured, by cause. Spent, and in no other figure.');
76
+ refused = new Counter('trazum_gateway_calls_refused_total', 'Calls answered 402 and not forwarded, by reason.');
77
+ substituted = new Counter('trazum_gateway_calls_substituted_total', 'Calls forwarded with the model the config substitutes.');
78
+ free = new Counter('trazum_gateway_calls_free_total', 'Calls to a path that spends nothing, forwarded without a budget decision.');
79
+ unreachable = new Counter('trazum_gateway_upstream_unreachable_total', 'Calls the provider could not be reached for, answered 502.');
80
+ provider;
81
+ startedMs;
82
+ constructor(provider, startedMs) {
83
+ this.provider = provider;
84
+ this.startedMs = startedMs;
85
+ // Present at zero: nothing went wrong and nothing was counted are different statements.
86
+ for (const cause of UNMEASURED_CAUSES)
87
+ this.unmeasuredCalls.add({ trazum_provider: provider, cause }, 0);
88
+ this.unreachable.add({ trazum_provider: provider }, 0);
89
+ }
90
+ /**
91
+ * Whether a call with this key may be counted: a key already held, or room
92
+ * for a new one. A call refused here is counted only as dropped.
93
+ */
94
+ admit(keys, key) {
95
+ if (keys.has(key))
96
+ return true;
97
+ if (keys.size >= MAX_SERIES_KEYS) {
98
+ this.dropped += 1;
99
+ return false;
100
+ }
101
+ keys.add(key);
102
+ return true;
103
+ }
104
+ /** A measured call, and its cost at list rates, or `null` when the catalogue does not price it. */
105
+ measured(call, usd) {
106
+ const series = { trazum_provider: this.provider, trazum_model: call.model, trazum_label: call.label ?? '' };
107
+ if (!this.admit(this.seen, JSON.stringify([call.model, call.label])))
108
+ return;
109
+ this.calls.add({ ...series, substituted: String(call.substituted) }, 1);
110
+ const kinds = [
111
+ ['input', call.inputTokens],
112
+ ['output', call.outputTokens],
113
+ ['cache_read', call.cacheReadTokens],
114
+ ['cache_write', call.cacheWriteTokens],
115
+ ];
116
+ for (const [kind, count] of kinds)
117
+ this.tokens.add({ ...series, kind }, count);
118
+ if (usd === null)
119
+ this.unpriced.add(series, 1);
120
+ else
121
+ this.cost.add({ ...series, trazum_cost_basis: COST_BASIS }, usd);
122
+ }
123
+ unmeasured(cause) {
124
+ this.unmeasuredCalls.add({ trazum_provider: this.provider, cause }, 1);
125
+ }
126
+ count(event) {
127
+ const provider = { trazum_provider: this.provider };
128
+ if (event.kind === 'refused')
129
+ this.refused.add({ ...provider, reason: event.reason }, 1);
130
+ else if (event.kind === 'substituted') {
131
+ if (this.admit(this.swaps, JSON.stringify([event.from, event.to]))) {
132
+ this.substituted.add({ ...provider, from_model: event.from, to_model: event.to }, 1);
133
+ }
134
+ }
135
+ else if (event.kind === 'free')
136
+ this.free.add({ ...provider, path: event.path }, 1);
137
+ else
138
+ this.unreachable.add(provider, 1);
139
+ }
140
+ /** The Prometheus text exposition, ending with a line break as the format requires. */
141
+ text() {
142
+ const counters = [
143
+ this.calls, this.tokens, this.cost, this.unpriced, this.unmeasuredCalls,
144
+ this.refused, this.substituted, this.free, this.unreachable,
145
+ ];
146
+ const out = counters.flatMap((counter) => counter.lines());
147
+ out.push('# HELP trazum_gateway_calls_dropped_total Calls left out of every other figure here because they named a new model, label or substitution past the limit.', '# TYPE trazum_gateway_calls_dropped_total counter', `trazum_gateway_calls_dropped_total${render({ trazum_provider: this.provider })} ${this.dropped}`, '# HELP trazum_gateway_start_time_seconds When this gateway process started; every counter here begins there.', '# TYPE trazum_gateway_start_time_seconds gauge', `trazum_gateway_start_time_seconds${render({ trazum_provider: this.provider })} ${this.startedMs / 1000}`);
148
+ return `${out.join('\n')}\n`;
149
+ }
150
+ }
151
+ /**
152
+ * The scrape server: `GET /metrics` and nothing else.
153
+ *
154
+ * Behind the same host and origin guard as the proxy and `serve`, so a page
155
+ * that rebound its own hostname to 127.0.0.1 cannot read which models and
156
+ * labels this gateway has seen.
157
+ */
158
+ export function buildMetricsServer(metrics) {
159
+ const server = createServer((request, response) => {
160
+ const refused = refuseHost(server, request);
161
+ if (refused !== null) {
162
+ response.writeHead(refused.status, { 'content-type': 'application/json', 'cache-control': 'no-store' });
163
+ response.end(`${JSON.stringify({ error: refused.error, detail: refused.detail })}\n`);
164
+ return;
165
+ }
166
+ if (request.url !== '/metrics') {
167
+ response.writeHead(404, { 'content-type': 'application/json' });
168
+ response.end(`${JSON.stringify({ error: 'this port serves GET /metrics and nothing else' })}\n`);
169
+ return;
170
+ }
171
+ if (request.method !== 'GET' && request.method !== 'HEAD') {
172
+ response.writeHead(405, { 'content-type': 'application/json', allow: 'GET, HEAD' });
173
+ response.end(`${JSON.stringify({ error: 'this port serves GET /metrics and nothing else' })}\n`);
174
+ return;
175
+ }
176
+ response.writeHead(200, { 'content-type': 'text/plain; version=0.0.4; charset=utf-8', 'cache-control': 'no-store' });
177
+ response.end(request.method === 'HEAD' ? undefined : metrics.text());
178
+ });
179
+ return server;
180
+ }
181
+ //# sourceMappingURL=gateway-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-metrics.js","sourceRoot":"","sources":["../src/gateway-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,qHAAqH;AACrH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE3C,MAAM,iBAAiB,GAA+B,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAe7G,iFAAiF;AACjF,MAAM,OAAO;I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