@trazum/cli 2.5.2 → 2.7.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/README.md +4 -2
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.js +43 -7
- package/dist/filter.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +66 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +67 -7
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +22 -1
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -20
- package/dist/index.js.map +1 -1
- package/dist/serve-import-schema.d.ts +34 -0
- package/dist/serve-import-schema.d.ts.map +1 -0
- package/dist/serve-import-schema.js +32 -0
- package/dist/serve-import-schema.js.map +1 -0
- package/dist/serve-import.d.ts +49 -0
- package/dist/serve-import.d.ts.map +1 -0
- package/dist/serve-import.js +52 -0
- package/dist/serve-import.js.map +1 -0
- package/dist/serve-schema.d.ts +70 -0
- package/dist/serve-schema.d.ts.map +1 -1
- package/dist/serve-schema.js +9 -0
- package/dist/serve-schema.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +9 -2
- package/dist/serve.js.map +1 -1
- package/dist/task-files.d.ts +9 -0
- package/dist/task-files.d.ts.map +1 -0
- package/dist/task-files.js +136 -0
- package/dist/task-files.js.map +1 -0
- package/dist/task.d.ts +2 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +137 -0
- package/dist/task.js.map +1 -0
- package/package.json +7 -4
- package/src/filter.ts +46 -10
- package/src/i18n/en.ts +72 -7
- package/src/i18n/es.ts +75 -7
- package/src/i18n/types.ts +23 -1
- package/src/index.ts +259 -16
- package/src/serve-import-schema.ts +32 -0
- package/src/serve-import.ts +60 -0
- package/src/serve-schema.ts +9 -0
- package/src/serve.ts +9 -2
- package/src/task-files.ts +114 -0
- package/src/task.ts +119 -0
package/README.md
CHANGED
|
@@ -15,8 +15,10 @@ Requires Node.js 20 or newer. No global install or provider key needed;
|
|
|
15
15
|
npx @trazum/cli bill
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
With no path, reads local Claude Code
|
|
19
|
-
|
|
18
|
+
With no path, reads the local sessions of **Claude Code, Codex and Gemini
|
|
19
|
+
CLI**, names each folder before reading it, and groups costs by agent, project
|
|
20
|
+
and model; `--by day|week|month` adds the period you ask for.
|
|
21
|
+
**Subscription sessions are priced at API-equivalent rates, not
|
|
20
22
|
presented as your subscription invoice.** Unknown models remain pricing gaps.
|
|
21
23
|
Local analysis does not upload your files.
|
|
22
24
|
|
package/dist/filter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/filter.js
CHANGED
|
@@ -7,7 +7,7 @@ import { once } from 'node:events';
|
|
|
7
7
|
import { compactToolOutput, EFFICIENT_OUTPUT_INSTRUCTIONS } from '@trazum/core';
|
|
8
8
|
const MAX_BYTES = 1024 * 1024;
|
|
9
9
|
const HELP = `Usage:
|
|
10
|
-
trazum filter compact --recovery-dir <private-directory>
|
|
10
|
+
trazum filter compact --recovery-dir <private-directory> [--stats]
|
|
11
11
|
trazum filter restore <sha256> --recovery-dir <private-directory>
|
|
12
12
|
trazum filter instructions print optional output guidance
|
|
13
13
|
|
|
@@ -17,7 +17,22 @@ Use Bash pipefail to preserve the producing command's failure status.
|
|
|
17
17
|
Original logs may contain sensitive data: --recovery-dir explicitly opts into local
|
|
18
18
|
retention. Delete that directory when the originals are no longer needed.
|
|
19
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.
|
|
20
21
|
`;
|
|
22
|
+
/** Report only the view actually emitted, including recovery-instruction overhead. */
|
|
23
|
+
function reportStats(inputBytes, outputBytes, view, reason, applied = false) {
|
|
24
|
+
const before = view?.estimatedTokensBefore ?? null;
|
|
25
|
+
const after = applied ? view?.estimatedTokensAfter ?? null : before;
|
|
26
|
+
const saved = before === null || after === null ? null : before - after;
|
|
27
|
+
process.stderr.write(`${JSON.stringify({
|
|
28
|
+
schemaVersion: 1, kind: 'trazum-tool-filter', estimateOnly: true, applied, reason,
|
|
29
|
+
inputBytes, outputBytes, estimatedTokensBefore: before, estimatedTokensAfter: after,
|
|
30
|
+
estimatedTokensSaved: saved,
|
|
31
|
+
estimatedReductionPercent: saved === null || before === null ? null
|
|
32
|
+
: before === 0 ? 0 : Math.round(saved / before * 10000) / 100,
|
|
33
|
+
repeatedLines: applied ? view?.repeatedLines ?? 0 : 0,
|
|
34
|
+
})}\n`);
|
|
35
|
+
}
|
|
21
36
|
const digest = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
22
37
|
const quote = (text) => `'${text.replaceAll("'", "'\\''")}'`;
|
|
23
38
|
async function emit(bytes) {
|
|
@@ -35,7 +50,8 @@ async function privateDirectory(path, create) {
|
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
async function readOriginal(store, key) {
|
|
38
|
-
|
|
53
|
+
// Opening a FIFO must not block before the regular-file check can reject it.
|
|
54
|
+
const file = await open(join(store, `${key}.log`), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
39
55
|
try {
|
|
40
56
|
const stat = await file.stat();
|
|
41
57
|
if (!stat.isFile() || stat.size > MAX_BYTES)
|
|
@@ -71,17 +87,17 @@ async function saveOriginal(store, key, bytes) {
|
|
|
71
87
|
await file.close();
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
|
-
async function compact(store) {
|
|
90
|
+
async function compact(store, stats) {
|
|
75
91
|
const chunks = [];
|
|
76
92
|
let size = 0;
|
|
77
93
|
let passthrough = false;
|
|
78
94
|
for await (const value of process.stdin) {
|
|
79
95
|
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
96
|
+
size += chunk.length;
|
|
80
97
|
if (passthrough) {
|
|
81
98
|
await emit(chunk);
|
|
82
99
|
continue;
|
|
83
100
|
}
|
|
84
|
-
size += chunk.length;
|
|
85
101
|
if (size > MAX_BYTES) {
|
|
86
102
|
passthrough = true;
|
|
87
103
|
for (const buffered of chunks)
|
|
@@ -93,19 +109,26 @@ async function compact(store) {
|
|
|
93
109
|
chunks.push(chunk);
|
|
94
110
|
}
|
|
95
111
|
}
|
|
96
|
-
if (passthrough)
|
|
112
|
+
if (passthrough) {
|
|
113
|
+
if (stats)
|
|
114
|
+
reportStats(size, size, null, 'stream-limit');
|
|
97
115
|
return;
|
|
116
|
+
}
|
|
98
117
|
const bytes = Buffer.concat(chunks);
|
|
99
118
|
const input = bytes.toString('utf8');
|
|
100
119
|
// Invalid UTF-8 must pass byte-for-byte rather than acquire replacement chars.
|
|
101
120
|
if (!Buffer.from(input).equals(bytes)) {
|
|
102
121
|
await emit(bytes);
|
|
122
|
+
if (stats)
|
|
123
|
+
reportStats(size, size, null, 'invalid-utf8');
|
|
103
124
|
return;
|
|
104
125
|
}
|
|
105
126
|
const key = digest(bytes);
|
|
106
127
|
const view = compactToolOutput(input, `trazum filter restore ${key} --recovery-dir ${quote(store)}`);
|
|
107
128
|
if (!view.applied) {
|
|
108
129
|
await emit(bytes);
|
|
130
|
+
if (stats)
|
|
131
|
+
reportStats(size, size, view, view.reason);
|
|
109
132
|
return;
|
|
110
133
|
}
|
|
111
134
|
try {
|
|
@@ -113,13 +136,26 @@ async function compact(store) {
|
|
|
113
136
|
}
|
|
114
137
|
catch {
|
|
115
138
|
// A filter must not swallow a tool's output because local persistence failed.
|
|
116
|
-
|
|
139
|
+
if (!stats)
|
|
140
|
+
process.stderr.write('Trazum: original could not be retained; passing log through unchanged.\n');
|
|
117
141
|
await emit(bytes);
|
|
142
|
+
if (stats)
|
|
143
|
+
reportStats(size, size, view, 'storage-failed');
|
|
118
144
|
return;
|
|
119
145
|
}
|
|
120
146
|
await emit(view.text);
|
|
147
|
+
if (stats)
|
|
148
|
+
reportStats(size, Buffer.byteLength(view.text), view, view.reason, true);
|
|
121
149
|
}
|
|
122
150
|
export async function runFilter(args) {
|
|
151
|
+
let stats = false;
|
|
152
|
+
if (args[0] === 'compact' && args.length === 4) {
|
|
153
|
+
const index = args[1] === '--stats' ? 1 : args[3] === '--stats' ? 3 : -1;
|
|
154
|
+
if (index !== -1) {
|
|
155
|
+
stats = true;
|
|
156
|
+
args = args.filter((_, i) => i !== index);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
123
159
|
if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0]))) {
|
|
124
160
|
await emit(HELP);
|
|
125
161
|
return;
|
|
@@ -145,7 +181,7 @@ export async function runFilter(args) {
|
|
|
145
181
|
else {
|
|
146
182
|
if (process.stdin.isTTY)
|
|
147
183
|
throw new Error('Pipe a tool log into stdin; interactive tools are not supported.');
|
|
148
|
-
await compact(store);
|
|
184
|
+
await compact(store, stats);
|
|
149
185
|
}
|
|
150
186
|
}
|
|
151
187
|
//# sourceMappingURL=filter.js.map
|
package/dist/filter.js.map
CHANGED
|
@@ -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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C,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,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/dist/i18n/en.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9C;;;;;;GAMG;AACH,eAAO,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9C;;;;;;GAMG;AACH,eAAO,MAAM,EAAE,EAAE,WA4iHhB,CAAC"}
|
package/dist/i18n/en.js
CHANGED
|
@@ -21,7 +21,13 @@ const ago = (days) => days === null ? '' : days === 0 ? ' (today)' : days === 1
|
|
|
21
21
|
export const en = {
|
|
22
22
|
locale: 'en',
|
|
23
23
|
numberLocale: 'en-US',
|
|
24
|
-
help: (d, bold) => `${bold('trazum')},
|
|
24
|
+
help: (d, bold) => `${bold('trazum')}, what your AI agents and API calls cost, read from logs on this machine.
|
|
25
|
+
|
|
26
|
+
${bold('START HERE')}
|
|
27
|
+
trazum bill Every Claude Code, Codex and Gemini CLI session on
|
|
28
|
+
this machine, by agent, project and model
|
|
29
|
+
trazum bill <log|dir> Any usage log or provider export it recognises
|
|
30
|
+
trazum bill --by month The same bill, month by month (or day, week)
|
|
25
31
|
|
|
26
32
|
${bold('USAGE')}
|
|
27
33
|
trazum init [dir] [--dry-run | --yes]
|
|
@@ -52,9 +58,10 @@ ${bold('USAGE')}
|
|
|
52
58
|
trazum position <usage.jsonl>
|
|
53
59
|
trazum receipt <usage.jsonl|dir> [--stamp] [--since <when>] [--until <when>] [-o <file>]
|
|
54
60
|
trazum bill [<file|dir>...] [--label <name>] [--no-label-from-project] [--receipt|--table] [--stamp] [-o <file>]
|
|
55
|
-
[--since <when>] [--until <when>] [--pdf-out|--html-out|--markdown-out|--csv-out <file>]
|
|
61
|
+
[--since <when>] [--until <when>] [--by day|week|month] [--pdf-out|--html-out|--markdown-out|--csv-out <file>]
|
|
56
62
|
trazum from-claude-code <file|dir> [--label <name>] [-o <file>]
|
|
57
63
|
trazum from-codex <file|dir> [--label <name>] [-o <file>]
|
|
64
|
+
trazum from-gemini-cli <file|dir> [--label <name>] [-o <file>]
|
|
58
65
|
trazum from-otel <file|dir> [--label-from-service] [-o <file>]
|
|
59
66
|
trazum from-litellm <file|dir> [-o <file>]
|
|
60
67
|
trazum from-anthropic <usage.json> [--label <name>] [--label-by-workspace <file>] [-o <file>]
|
|
@@ -80,6 +87,7 @@ ${bold('USAGE')}
|
|
|
80
87
|
trazum ladder <log>
|
|
81
88
|
trazum feedback
|
|
82
89
|
trazum filter compact|restore|instructions [--recovery-dir <directory>]
|
|
90
|
+
trazum task analyze|policy|apply|revert|compare [--help]
|
|
83
91
|
trazum --version
|
|
84
92
|
|
|
85
93
|
${bold('OPTIONS FOR init')}
|
|
@@ -225,11 +233,19 @@ ${bold('OPTIONS FOR bill')}
|
|
|
225
233
|
means the whole of it. Calls with no timestamp
|
|
226
234
|
cannot be placed and are left out, counted on
|
|
227
235
|
the receipt as a gap, never dropped silently.
|
|
236
|
+
--by <day|week|month> Split the statement by UTC day, ISO week (Monday
|
|
237
|
+
to Sunday) or month. Without it, a bill spanning
|
|
238
|
+
two months or more is split by month.
|
|
228
239
|
--stamp Stamp the receipt with the time it was written.
|
|
229
240
|
-o, --out <file> Write the receipt there instead of stdout.
|
|
230
241
|
|
|
242
|
+
With no path, reads every coding agent's own session folders it finds:
|
|
243
|
+
Claude Code (~/.claude/projects), Codex ($CODEX_HOME/sessions and
|
|
244
|
+
archived_sessions) and Gemini CLI (~/.gemini/tmp/*/chats), each named on
|
|
245
|
+
stderr, and adds a By agent table once more than one spent money.
|
|
246
|
+
|
|
231
247
|
One door. Reads a file or a directory, tells each file's shape from its own
|
|
232
|
-
text - a Claude Code
|
|
248
|
+
text - a Claude Code, Codex or Gemini CLI session, OTel spans, a LiteLLM, Helicone or LangSmith
|
|
233
249
|
export, an Anthropic, OpenAI or OpenRouter report, or a plain usage log -
|
|
234
250
|
converts it with the same converter the dedicated command uses, prices it,
|
|
235
251
|
and ends on the receipt. A file no shape claims is named, not guessed; a
|
|
@@ -307,6 +323,17 @@ ${bold('OPTIONS FOR from-codex')}
|
|
|
307
323
|
Conversion gaps are reported on stderr. Prices are API equivalents,
|
|
308
324
|
never your subscription invoice. Prompt content is discarded.
|
|
309
325
|
|
|
326
|
+
${bold('OPTIONS FOR from-gemini-cli')}
|
|
327
|
+
--label <name> Stamp every record with one label.
|
|
328
|
+
-o, --out <file> Write normalized usage instead of stdout.
|
|
329
|
+
|
|
330
|
+
Read Gemini CLI session files (~/.gemini/tmp/<project>/chats, .jsonl, and
|
|
331
|
+
the older single-document .json), locally. One record per reply that
|
|
332
|
+
carried token counts; a reply the recorder rewrote is read once. Reasoning
|
|
333
|
+
tokens are priced as output and tool results fed back as input, as Google
|
|
334
|
+
bills them. Prices are API equivalents, not a free-tier or plan invoice.
|
|
335
|
+
Prompts, replies, thoughts and tool content are discarded.
|
|
336
|
+
|
|
310
337
|
${bold('OPTIONS FOR from-claude-code')}
|
|
311
338
|
--label <name> Stamp every record with one label.
|
|
312
339
|
--label-from-project Label each record with its transcript's project
|
|
@@ -419,8 +446,23 @@ ${bold('OPTIONS FOR rules')}
|
|
|
419
446
|
"Inert" is always said about the corpus. A rule that finds nothing in these
|
|
420
447
|
files has not been shown to find nothing anywhere.
|
|
421
448
|
|
|
449
|
+
${bold('OPTIONS FOR task')}
|
|
450
|
+
--id <id> --type <type> Identify a task and its comparable task type.
|
|
451
|
+
--criterion <text> Declare the acceptance criterion before a change.
|
|
452
|
+
--claude-code <file> Add an explicit Claude Code task transcript; repeatable.
|
|
453
|
+
--codex <file> Add an explicit Codex task transcript; repeatable.
|
|
454
|
+
--outcome <value> accepted, rejected or unknown (default unknown).
|
|
455
|
+
--assessor <label> Required for a declared accepted or rejected outcome.
|
|
456
|
+
--policy <id> baseline (default) or repeat-review-v1.
|
|
457
|
+
--instructions <file> Existing local instruction file for apply or revert.
|
|
458
|
+
-o, --out <new-file> Create a private report or policy; never overwrite.
|
|
459
|
+
--json Reports and comparisons are already JSON by default.
|
|
460
|
+
Run task --help for analyze, policy, apply, revert and compare syntax.
|
|
461
|
+
Sources total at most 400,000 characters. Task success is never inferred.
|
|
462
|
+
|
|
422
463
|
${bold('OPTIONS FOR filter')}
|
|
423
464
|
--recovery-dir <directory> Private recovery directory; required for compact/restore.
|
|
465
|
+
--stats Compact only: emit net estimated savings as JSON on stderr.
|
|
424
466
|
Run trazum filter --help for the opt-in stdin log-filter workflow.
|
|
425
467
|
|
|
426
468
|
${bold('OPTIONS FOR feedback')}
|
|
@@ -1700,6 +1742,17 @@ ${bold('EXAMPLES')}
|
|
|
1700
1742
|
caveat: () => 'Codex telemetry is priced at catalogue API rates, not your subscription invoice. Restored totals, counter resets and ambiguous deltas are excluded, not guessed.',
|
|
1701
1743
|
written: (file) => `Wrote normalized usage to ${file}`,
|
|
1702
1744
|
},
|
|
1745
|
+
fromGeminiCli: {
|
|
1746
|
+
noPath: () => 'from-gemini-cli needs a session file or a directory: trazum from-gemini-cli ~/.gemini/tmp',
|
|
1747
|
+
notFound: (path) => `Cannot read ${path}`,
|
|
1748
|
+
noFiles: (path) => `No Gemini CLI session files (.jsonl or .json) in ${path}`,
|
|
1749
|
+
noUsage: () => 'No Gemini CLI reply carried token counts. Inspect the named gaps; no zero-cost log was written.',
|
|
1750
|
+
summary: (files, records, repeats) => `${files} Gemini CLI file(s), ${records} reply record(s) with token counts, ${repeats} rewritten line(s) read once.`,
|
|
1751
|
+
gaps: (missingModel, unsupported, unparseable) => `Gemini CLI gaps: ${missingModel} reply(ies) without a model, ${unsupported} with impossible token counts, ${unparseable} unreadable line(s). These are not zero-cost calls.`,
|
|
1752
|
+
remainder: (replies) => `${replies} Gemini CLI reply(ies) from an older recorder kept a total larger than its parts; the remainder is priced as output, the dearer side, rather than dropped.`,
|
|
1753
|
+
caveat: () => 'Gemini CLI sessions are priced at catalogue API rates. On a free tier or a Code Assist plan that is an equivalent, not what you paid. Reasoning tokens are priced as output and tool results fed back as input, as Google bills them.',
|
|
1754
|
+
written: (file) => `Wrote normalized usage to ${file}`,
|
|
1755
|
+
},
|
|
1703
1756
|
fromOtel: {
|
|
1704
1757
|
noPath: () => 'from-otel needs an OTLP file or directory: trazum from-otel spans.json',
|
|
1705
1758
|
notFound: (path) => `${path}: not found`,
|
|
@@ -1773,9 +1826,9 @@ ${bold('EXAMPLES')}
|
|
|
1773
1826
|
written: (file) => `Wrote ${file}.`,
|
|
1774
1827
|
},
|
|
1775
1828
|
bill: {
|
|
1776
|
-
noPath: (tried) => `bill needs a file or a directory to read, and found no Claude Code
|
|
1777
|
-
|
|
1778
|
-
labelledByProject: (files) => `${files}
|
|
1829
|
+
noPath: (tried) => `bill needs a file or a directory to read, and found no Claude Code, Codex or Gemini CLI sessions at ${tried}. Name one: trazum bill ~/.claude/projects, or trazum bill usage.jsonl.`,
|
|
1830
|
+
defaultPathFor: (agent, dir) => `No path given, so reading ${agent}'s own folder: ${dir}`,
|
|
1831
|
+
labelledByProject: (files) => `${files} session file(s) labelled by their project folder. --label sets one label instead, --no-label-from-project leaves them unlabelled.`,
|
|
1779
1832
|
unknownMore: (count) => `${count} more file(s) no shape claims, not guessed at and not in the bill.`,
|
|
1780
1833
|
shapeSummary: (shape, files, records, leftOut) => `${files} file(s): ${shape}${records === null ? ', read as they are' : `, ${records} record(s)`}${leftOut > 0 ? `, ${leftOut} row(s) left out. trazum from-${shape} on a file says why.` : '.'}`,
|
|
1781
1834
|
statementHeading: () => 'Your bill',
|
|
@@ -1783,6 +1836,12 @@ ${bold('EXAMPLES')}
|
|
|
1783
1836
|
colProject: () => 'project',
|
|
1784
1837
|
colWorkload: () => 'workload',
|
|
1785
1838
|
colModel: () => 'model',
|
|
1839
|
+
colAgent: () => 'agent',
|
|
1840
|
+
colPeriod: (unit) => unit,
|
|
1841
|
+
earlierPeriods: (count, unit) => `… and ${count} earlier ${unit}(s)`,
|
|
1842
|
+
periodsUndated: (calls, usd, unit) => `${usd} from ${calls} call(s) with no timestamp is in the total and in no ${unit}.`,
|
|
1843
|
+
periodHint: (since, until, unit) => `One ${unit} on its own: --since ${since} --until ${until}.`,
|
|
1844
|
+
badBy: (value) => `--by takes day, week or month, not "${value}".`,
|
|
1786
1845
|
colCalls: () => 'calls',
|
|
1787
1846
|
colShare: () => 'share',
|
|
1788
1847
|
moreRows: (count) => `… and ${count} more`,
|
|
@@ -1802,7 +1861,7 @@ ${bold('EXAMPLES')}
|
|
|
1802
1861
|
nothingRead: () => 'Nothing here was a usage source this tool reads, so there is nothing to bill.',
|
|
1803
1862
|
sources: (read, seen) => `${read} of ${seen} file(s) read as usage.`,
|
|
1804
1863
|
pricingLiveHint: (count) => `${count} unpriced model id(s) carry a provider prefix, the way OpenRouter and LiteLLM name models, and the bundled catalogue does not carry those. Run again with --pricing-live to price OpenRouter's slugs from its own list.`,
|
|
1805
|
-
apiEquivalent: () => 'Claude Code
|
|
1864
|
+
apiEquivalent: () => 'Agent sessions (Claude Code, Codex, Gemini CLI) are priced at catalogue API rates. On a subscription you paid the plan, not this API-equivalent estimate; missing telemetry and custom rates can change the result.',
|
|
1806
1865
|
prefixedKnown: (ids) => `${ids}: the model after the slash is priced here under its own name. The prefix is not stripped for you, because the same model through a router can bill differently. If those calls went straight to the provider, log the model without the prefix.`,
|
|
1807
1866
|
windowMatchesNothing: (from, to) => `No call falls inside this period. What was read covers ${from} → ${to}. A period with nothing in it is not a $0 bill: check the dates, or leave --since/--until off to bill everything.`,
|
|
1808
1867
|
written: (file) => `Wrote ${file}.`,
|