@trazum/cli 1.70.0 → 1.71.1
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/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +22 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +40 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +15 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/en.ts +23 -0
- package/src/i18n/es.ts +41 -0
- package/src/i18n/types.ts +16 -0
- package/src/index.ts +68 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trazum/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.71.1",
|
|
4
4
|
"description": "Trazum CLI: find where your LLM bill goes, price every finding per month, and enforce token budgets in CI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Mu\u00f1oz Rey",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build && npm test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@trazum/core": "1.
|
|
40
|
+
"@trazum/core": "1.71.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26.2.0",
|
package/src/i18n/en.ts
CHANGED
|
@@ -60,6 +60,7 @@ ${bold('USAGE')}
|
|
|
60
60
|
trazum rollup <document...|dir> [--json] [--html-out <file>]
|
|
61
61
|
trazum position <usage.jsonl>
|
|
62
62
|
trazum from-claude-code <file|dir> [--label <name>] [-o <file>]
|
|
63
|
+
trazum from-otel <file|dir> [--label-from-service] [-o <file>]
|
|
63
64
|
trazum pulse [--max-stale-hours <n>]
|
|
64
65
|
trazum bench [--workload <id>] [--record <file>] [--against <file> --max-ratio <n>] [--json]
|
|
65
66
|
trazum write [--answers <file>] [--json] [-o <file>]
|
|
@@ -137,6 +138,17 @@ ${bold('OPTIONS FOR write')}
|
|
|
137
138
|
--calls <n> Calls per month, for the estimate.
|
|
138
139
|
--avg-output <n> Average output tokens per call, for the estimate.
|
|
139
140
|
|
|
141
|
+
${bold('OPTIONS FOR from-otel')}
|
|
142
|
+
--label-from-service Label each record with its span's service name,
|
|
143
|
+
so a per-service bill falls out.
|
|
144
|
+
-o, --out <file> Write the usage log there instead of stdout.
|
|
145
|
+
|
|
146
|
+
OpenTelemetry GenAI spans, read as a usage log: model, timestamp, label and
|
|
147
|
+
the token counts from each gen_ai.* span — and nothing else. Prompt content
|
|
148
|
+
and trace ids stay in the span. OTel has no cache TTL split, so cache
|
|
149
|
+
verdicts read "cannot tell" rather than a guessed one. Non-LLM spans are
|
|
150
|
+
counted and skipped, said on stderr.
|
|
151
|
+
|
|
140
152
|
${bold('OPTIONS FOR from-claude-code')}
|
|
141
153
|
--label <name> Stamp every record with one label.
|
|
142
154
|
--label-from-project Label each record with its transcript's project
|
|
@@ -1613,6 +1625,17 @@ ${bold('EXAMPLES')}
|
|
|
1613
1625
|
},
|
|
1614
1626
|
},
|
|
1615
1627
|
|
|
1628
|
+
fromOtel: {
|
|
1629
|
+
noPath: () => 'from-otel needs an OTLP file or directory: trazum from-otel spans.json',
|
|
1630
|
+
notFound: (path) => `${path}: not found`,
|
|
1631
|
+
noExports: (path) => `${path}: no .json/.jsonl/.ndjson OTLP exports under it.`,
|
|
1632
|
+
summary: (files, llmSpans) => `${files} file(s), ${llmSpans} LLM span(s) priced.`,
|
|
1633
|
+
skipped: (otherSpans) => `${otherSpans} non-LLM span(s) skipped — the trace's other work, not a bill.`,
|
|
1634
|
+
noCache: (count) => `${count} span(s) carried no cache data. OpenTelemetry has not standardised the cache TTL split, so the cache verdicts read "cannot tell" on this log rather than a fabricated one.`,
|
|
1635
|
+
unparseable: (count) => `${count} line(s) did not parse as JSON.`,
|
|
1636
|
+
written: (file) => `Wrote ${file}.`,
|
|
1637
|
+
},
|
|
1638
|
+
|
|
1616
1639
|
fromClaudeCode: {
|
|
1617
1640
|
noPath: () => 'from-claude-code needs a transcript file or directory: trazum from-claude-code ~/.claude/projects',
|
|
1618
1641
|
notFound: (path) => `${path}: not found`,
|
package/src/i18n/es.ts
CHANGED
|
@@ -46,6 +46,8 @@ ${bold('USO')}
|
|
|
46
46
|
trazum schema <contrato>
|
|
47
47
|
trazum rollup <documento...|dir> [--json] [--html-out <fichero>]
|
|
48
48
|
trazum position <uso.jsonl>
|
|
49
|
+
trazum from-claude-code <fichero|dir> [--label <nombre>] [-o <fichero>]
|
|
50
|
+
trazum from-otel <fichero|dir> [--label-from-service] [-o <fichero>]
|
|
49
51
|
trazum pulse [--max-stale-hours <n>]
|
|
50
52
|
trazum bench [--workload <id>] [--record <fichero>] [--against <fichero> --max-ratio <n>] [--json]
|
|
51
53
|
trazum write [--answers <fichero>] [--json] [-o <fichero>]
|
|
@@ -138,6 +140,34 @@ ${bold('OPCIONES DE position')}
|
|
|
138
140
|
siete días, con un techo superado o con tasa cero: nunca un pronóstico, y
|
|
139
141
|
ningún campo del documento nombra una fecha.
|
|
140
142
|
|
|
143
|
+
${bold('OPCIONES DE from-otel')}
|
|
144
|
+
--label-from-service Etiqueta cada registro con el nombre de servicio
|
|
145
|
+
de su span, para que salga una factura por
|
|
146
|
+
servicio.
|
|
147
|
+
-o, --out <fichero> Escribe el log de uso ahí en vez de en stdout.
|
|
148
|
+
|
|
149
|
+
Spans GenAI de OpenTelemetry, leídos como un log de uso: modelo, marca de
|
|
150
|
+
tiempo, etiqueta y los recuentos de tokens de cada span gen_ai.*, y nada
|
|
151
|
+
más. El contenido del prompt y los trace ids se quedan en el span. OTel no
|
|
152
|
+
tiene reparto de TTL de caché, así que los veredictos de caché dicen "no se
|
|
153
|
+
puede saber" en vez de uno inventado. Los spans que no son de LLM se cuentan
|
|
154
|
+
y se omiten, dicho en stderr.
|
|
155
|
+
|
|
156
|
+
${bold('OPCIONES DE from-claude-code')}
|
|
157
|
+
--label <nombre> Marca cada registro con una etiqueta.
|
|
158
|
+
--label-from-project Etiqueta cada registro con el nombre del
|
|
159
|
+
directorio de proyecto de su transcript, tal
|
|
160
|
+
cual; mapéalo a un nombre de workload con el
|
|
161
|
+
bloque \`labels\` de la config.
|
|
162
|
+
-o, --out <fichero> Escribe el log de uso ahí en vez de en stdout.
|
|
163
|
+
|
|
164
|
+
Los transcripts de Claude Code, leídos como un log de uso: modelo, marca de
|
|
165
|
+
tiempo, sesión y el propio objeto usage de la API, con el reparto de TTL de
|
|
166
|
+
caché incluido, y nada más. Ni texto de mensajes, ni rutas, ni ramas cruzan
|
|
167
|
+
la conversión. Una llamada a la API se escribe como una línea por bloque de
|
|
168
|
+
contenido, así que las líneas se colapsan por id de petición; lo colapsado o
|
|
169
|
+
descartado se dice en stderr, nunca en silencio.
|
|
170
|
+
|
|
141
171
|
${bold('OPCIONES DE pulse')}
|
|
142
172
|
--max-stale-hours <n> Sale con 1 cuando algo que corre aquí lleva más
|
|
143
173
|
de n horas sin correr. Sin esto, se informan las
|
|
@@ -1612,6 +1642,17 @@ ${bold('EJEMPLOS')}
|
|
|
1612
1642
|
},
|
|
1613
1643
|
},
|
|
1614
1644
|
|
|
1645
|
+
fromOtel: {
|
|
1646
|
+
noPath: () => 'from-otel necesita un archivo o directorio OTLP: trazum from-otel spans.json',
|
|
1647
|
+
notFound: (path) => `${path}: no existe`,
|
|
1648
|
+
noExports: (path) => `${path}: no hay exports OTLP .json/.jsonl/.ndjson debajo.`,
|
|
1649
|
+
summary: (files, llmSpans) => `${files} archivo(s), ${llmSpans} span(s) LLM tasados.`,
|
|
1650
|
+
skipped: (otherSpans) => `${otherSpans} span(s) no-LLM omitidos — el resto del trabajo de la traza, no una factura.`,
|
|
1651
|
+
noCache: (count) => `${count} span(s) sin datos de caché. OpenTelemetry no ha estandarizado el reparto del TTL de caché, así que los veredictos de caché dicen «no se puede saber» en este log en vez de uno inventado.`,
|
|
1652
|
+
unparseable: (count) => `${count} línea(s) no se pudieron parsear como JSON.`,
|
|
1653
|
+
written: (file) => `Escrito ${file}.`,
|
|
1654
|
+
},
|
|
1655
|
+
|
|
1615
1656
|
fromClaudeCode: {
|
|
1616
1657
|
noPath: () => 'from-claude-code necesita un archivo o directorio de transcripts: trazum from-claude-code ~/.claude/projects',
|
|
1617
1658
|
notFound: (path) => `${path}: no existe`,
|
package/src/i18n/types.ts
CHANGED
|
@@ -523,6 +523,22 @@ export interface CliMessages {
|
|
|
523
523
|
* the command's honesty: what was priced, what was collapsed (one API
|
|
524
524
|
* call arrives as one line per content block), and what was passed over.
|
|
525
525
|
*/
|
|
526
|
+
/**
|
|
527
|
+
* `trazum from-otel` — OpenTelemetry GenAI spans as a usage log. The summary
|
|
528
|
+
* is the command's honesty: LLM spans converted, non-LLM spans skipped, and
|
|
529
|
+
* how many carried no cache data (OTel has no TTL split to give).
|
|
530
|
+
*/
|
|
531
|
+
fromOtel: {
|
|
532
|
+
noPath(): string;
|
|
533
|
+
notFound(path: string): string;
|
|
534
|
+
noExports(path: string): string;
|
|
535
|
+
summary(files: number, llmSpans: number): string;
|
|
536
|
+
skipped(otherSpans: number): string;
|
|
537
|
+
noCache(count: number): string;
|
|
538
|
+
unparseable(count: number): string;
|
|
539
|
+
written(file: string): string;
|
|
540
|
+
};
|
|
541
|
+
|
|
526
542
|
fromClaudeCode: {
|
|
527
543
|
noPath(): string;
|
|
528
544
|
notFound(path: string): string;
|
package/src/index.ts
CHANGED
|
@@ -111,6 +111,7 @@ import {
|
|
|
111
111
|
parseUsageLine,
|
|
112
112
|
plannedCalls,
|
|
113
113
|
claudeCodeRecords,
|
|
114
|
+
otelRecords,
|
|
114
115
|
positionAt,
|
|
115
116
|
positionReport,
|
|
116
117
|
PRICING_LAST_REVIEWED,
|
|
@@ -670,6 +671,7 @@ const COMMAND_FLAGS: Record<string, string[]> = {
|
|
|
670
671
|
rollup: ['json', 'html-out'],
|
|
671
672
|
position: ['json', 'html-out', 'pricing', 'pricing-live'],
|
|
672
673
|
'from-claude-code': ['label', 'label-from-project', 'out', 'o'],
|
|
674
|
+
'from-otel': ['label-from-service', 'out', 'o'],
|
|
673
675
|
pulse: ['json', 'max-stale-hours'],
|
|
674
676
|
bench: ['workload', 'json', 'record', 'against', 'max-ratio'],
|
|
675
677
|
write: ['answers', 'json', 'out', 'o', 'calls', 'avg-output'],
|
|
@@ -2635,6 +2637,69 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
|
|
|
2635
2637
|
console.error(t.fromClaudeCode.skipped(otherLines, unparseable, withoutUsage));
|
|
2636
2638
|
}
|
|
2637
2639
|
|
|
2640
|
+
/**
|
|
2641
|
+
* `trazum from-otel <file|dir>` — OpenTelemetry GenAI spans as a usage log.
|
|
2642
|
+
*
|
|
2643
|
+
* The 1.71 move: the same pure-converter pattern generalised to the standard
|
|
2644
|
+
* the ecosystem is converging on, so Trazum prices whatever telemetry a team
|
|
2645
|
+
* already emits. `otelRecords` in core does the reading; this is the walk and
|
|
2646
|
+
* the honesty — how many spans were LLM calls, how many were skipped as
|
|
2647
|
+
* non-LLM, how many carried no cache data (the OTel norm, since it has not
|
|
2648
|
+
* standardised the TTL split). Prompt content, trace ids and every other span
|
|
2649
|
+
* attribute stay in the span; a fixture greps the whole output to prove it.
|
|
2650
|
+
*/
|
|
2651
|
+
async function commandFromOtel(args: Args, t: CliMessages): Promise<void> {
|
|
2652
|
+
const target = args.positional[0];
|
|
2653
|
+
if (target === undefined) throw new Error(t.fromOtel.noPath());
|
|
2654
|
+
|
|
2655
|
+
let info;
|
|
2656
|
+
try {
|
|
2657
|
+
info = await stat(target);
|
|
2658
|
+
} catch {
|
|
2659
|
+
throw new Error(t.fromOtel.notFound(target));
|
|
2660
|
+
}
|
|
2661
|
+
const files: string[] = [];
|
|
2662
|
+
if (info.isDirectory()) {
|
|
2663
|
+
const entries = await readdir(target, { recursive: true, withFileTypes: true });
|
|
2664
|
+
for (const entry of entries) {
|
|
2665
|
+
if (entry.isFile() && /\.(json|jsonl|ndjson)$/i.test(entry.name)) {
|
|
2666
|
+
files.push(join(entry.parentPath, entry.name));
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
files.sort();
|
|
2670
|
+
if (files.length === 0) throw new Error(t.fromOtel.noExports(target));
|
|
2671
|
+
} else {
|
|
2672
|
+
files.push(target);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
const lines: string[] = [];
|
|
2676
|
+
let llmSpans = 0;
|
|
2677
|
+
let otherSpans = 0;
|
|
2678
|
+
let noCacheData = 0;
|
|
2679
|
+
let unparseable = 0;
|
|
2680
|
+
for (const file of files) {
|
|
2681
|
+
const conversion = otelRecords(await readFile(file, 'utf8'));
|
|
2682
|
+
for (const record of conversion.records) lines.push(JSON.stringify(record));
|
|
2683
|
+
llmSpans += conversion.llmSpans;
|
|
2684
|
+
otherSpans += conversion.otherSpans;
|
|
2685
|
+
noCacheData += conversion.noCacheData;
|
|
2686
|
+
unparseable += conversion.unparseable;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
const out = stringFlag(args, 'out') ?? stringFlag(args, 'o');
|
|
2690
|
+
if (out !== undefined) {
|
|
2691
|
+
await writeFile(out, lines.join('\n') + (lines.length > 0 ? '\n' : ''), 'utf8');
|
|
2692
|
+
console.error(t.fromOtel.written(out));
|
|
2693
|
+
} else {
|
|
2694
|
+
for (const line of lines) console.log(line);
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
console.error(t.fromOtel.summary(files.length, llmSpans));
|
|
2698
|
+
if (otherSpans > 0) console.error(t.fromOtel.skipped(otherSpans));
|
|
2699
|
+
if (noCacheData > 0) console.error(t.fromOtel.noCache(noCacheData));
|
|
2700
|
+
if (unparseable > 0) console.error(t.fromOtel.unparseable(unparseable));
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2638
2703
|
/**
|
|
2639
2704
|
* `trazum position <usage.jsonl>` — where the month stands, measured.
|
|
2640
2705
|
*
|
|
@@ -11029,6 +11094,9 @@ async function main(): Promise<void> {
|
|
|
11029
11094
|
case 'from-claude-code':
|
|
11030
11095
|
await commandFromClaudeCode(args, t);
|
|
11031
11096
|
break;
|
|
11097
|
+
case 'from-otel':
|
|
11098
|
+
await commandFromOtel(args, t);
|
|
11099
|
+
break;
|
|
11032
11100
|
case 'pulse':
|
|
11033
11101
|
await commandPulse(args, t);
|
|
11034
11102
|
break;
|