@trazum/cli 1.73.1 → 1.74.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/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +56 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +57 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +33 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +146 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/en.ts +70 -0
- package/src/i18n/es.ts +71 -0
- package/src/i18n/types.ts +35 -0
- package/src/index.ts +148 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trazum/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.74.0",
|
|
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.74.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26.2.0",
|
package/src/i18n/en.ts
CHANGED
|
@@ -61,6 +61,8 @@ ${bold('USAGE')}
|
|
|
61
61
|
trazum position <usage.jsonl>
|
|
62
62
|
trazum from-claude-code <file|dir> [--label <name>] [-o <file>]
|
|
63
63
|
trazum from-otel <file|dir> [--label-from-service] [-o <file>]
|
|
64
|
+
trazum switch <usage.jsonl> --to <model> [--migration-usd <n>] [--cases <n>]
|
|
65
|
+
trazum ownrate --gpu-usd-hour <n> --tokens-per-second <n> [--utilization <0-1>]
|
|
64
66
|
trazum pulse [--max-stale-hours <n>]
|
|
65
67
|
trazum bench [--workload <id>] [--record <file>] [--against <file> --max-ratio <n>] [--json]
|
|
66
68
|
trazum write [--answers <file>] [--json] [-o <file>]
|
|
@@ -138,6 +140,33 @@ ${bold('OPTIONS FOR write')}
|
|
|
138
140
|
--calls <n> Calls per month, for the estimate.
|
|
139
141
|
--avg-output <n> Average output tokens per call, for the estimate.
|
|
140
142
|
|
|
143
|
+
${bold('OPTIONS FOR switch')}
|
|
144
|
+
--to <model> The candidate model, by catalogue id.
|
|
145
|
+
--migration-usd <n> What the migration itself would cost, declared
|
|
146
|
+
by you. Unlocks the break-even line.
|
|
147
|
+
--cases <n> How many evaluation cases you would run.
|
|
148
|
+
Unlocks the line pricing that evaluation.
|
|
149
|
+
|
|
150
|
+
The decision every what-if serves, priced: what this measured mix costs on
|
|
151
|
+
the candidate, the saving with its sign stated, and — with a declared
|
|
152
|
+
migration cost — the break-even as division on the measured past, days of
|
|
153
|
+
window attached, never a forecast. The evaluation the switch requires is
|
|
154
|
+
priced at this log's own mean call, two calls on the incumbent and one on
|
|
155
|
+
the candidate per case. What it refuses: any sentence about quality — that
|
|
156
|
+
verdict belongs to trazum route, and the report ends by printing it.
|
|
157
|
+
|
|
158
|
+
${bold('OPTIONS FOR ownrate')}
|
|
159
|
+
--gpu-usd-hour <n> What an hour of your hardware costs you.
|
|
160
|
+
--tokens-per-second <n> Throughput you measured on your own serving.
|
|
161
|
+
--utilization <0-1> Fraction of the hour actually serving.
|
|
162
|
+
Defaults to 1.
|
|
163
|
+
|
|
164
|
+
Your self-hosted model's $/MTok, derived from your own two numbers —
|
|
165
|
+
division, nothing else: no amortisation, no energy model, no guessed
|
|
166
|
+
efficiency. Prints the figure and the pricing-overlay snippet to paste
|
|
167
|
+
into trazum.config.json, so the model you run yourself becomes a
|
|
168
|
+
first-class row in every report, priced by you and marked as such.
|
|
169
|
+
|
|
141
170
|
${bold('OPTIONS FOR from-otel')}
|
|
142
171
|
--label-from-service Label each record with its span's service name,
|
|
143
172
|
so a per-service bill falls out.
|
|
@@ -1625,6 +1654,47 @@ ${bold('EXAMPLES')}
|
|
|
1625
1654
|
},
|
|
1626
1655
|
},
|
|
1627
1656
|
|
|
1657
|
+
switchCmd: {
|
|
1658
|
+
noLog: () => 'Name a usage log: trazum switch <usage.jsonl> --to <model>',
|
|
1659
|
+
noTarget: () => 'Name the candidate: --to <model>. trazum models lists the catalogue.',
|
|
1660
|
+
unknownModel: (id) =>
|
|
1661
|
+
`The catalogue has no price for "${id}", and a comparison against a price nobody has is worse than none. trazum models lists what it knows; a pricing overlay adds what it does not.`,
|
|
1662
|
+
heading: (target) => `Switching this traffic to ${target}, measured`,
|
|
1663
|
+
saves: (current, target, saving) =>
|
|
1664
|
+
`${current} on this log becomes ${target} on the candidate — ${saving} less, on the same tokens.`,
|
|
1665
|
+
costs: (current, target, extra) =>
|
|
1666
|
+
`${current} on this log becomes ${target} on the candidate — ${extra} MORE. This switch loses money before quality is even asked.`,
|
|
1667
|
+
nothingMovable: () => 'Nothing here can move: every slice is already on the candidate or exceeds its context window.',
|
|
1668
|
+
movable: (calls, slices) => `${calls} call(s) across ${slices} slice(s) could move.`,
|
|
1669
|
+
overContext: (slices, usd) =>
|
|
1670
|
+
`${slices} slice(s) worth ${usd} cannot move — at least one call exceeds the candidate's context window. Their money is in none of the figures above.`,
|
|
1671
|
+
alreadyOnTarget: (calls, usd) => `${calls} call(s) worth ${usd} are already on the candidate.`,
|
|
1672
|
+
window: (days) => `Measured over ${days} day(s) of this log — every figure above is arithmetic on that window.`,
|
|
1673
|
+
noWindow: () => 'No record carries a timestamp, so this log has no measured rate.',
|
|
1674
|
+
breakEvenDays: (migration, days, measuredDays) =>
|
|
1675
|
+
`A declared migration cost of ${migration} is recovered after ~${days} day(s) at the saving measured over ${measuredDays} day(s). Division on the past — what next month does is next month's business.`,
|
|
1676
|
+
breakEvenNoSaving: (migration) =>
|
|
1677
|
+
`Break-even refused: the switch saves nothing, so the declared ${migration} has nothing to recover.`,
|
|
1678
|
+
breakEvenNoClock: (migration) =>
|
|
1679
|
+
`Break-even refused for ${migration}: no record carries a timestamp, so there is no measured rate to divide by.`,
|
|
1680
|
+
evalCost: (cases, total) =>
|
|
1681
|
+
`Knowing whether the candidate is good enough costs money too: ${cases} case(s) through trazum route is ~${total} at this log's own mean call (two calls on the incumbent, one on the candidate, per case).`,
|
|
1682
|
+
evalCostHint: () => 'Pass --cases <n> to price the evaluation the switch requires.',
|
|
1683
|
+
quality: (routeCommand) =>
|
|
1684
|
+
`Nothing above says whether the candidate can do the work. That is an evaluation, not arithmetic: ${routeCommand}`,
|
|
1685
|
+
},
|
|
1686
|
+
|
|
1687
|
+
ownrate: {
|
|
1688
|
+
missing: () =>
|
|
1689
|
+
'Both numbers are yours to declare: trazum ownrate --gpu-usd-hour <n> --tokens-per-second <n> [--utilization <0-1>]',
|
|
1690
|
+
invalid: (flag) => `--${flag} must be a positive number (utilization: greater than 0, at most 1).`,
|
|
1691
|
+
result: (usdPerMTok, tokensPerSecond, gpuUsdPerHour, utilizationPct) =>
|
|
1692
|
+
`${usdPerMTok} per million tokens — ${gpuUsdPerHour}/hour over ${tokensPerSecond} tokens/second at ${utilizationPct}% serving.`,
|
|
1693
|
+
declared: () =>
|
|
1694
|
+
'Derived from your declaration, honest only if the throughput was measured. Every report that prices this model will rest on these two numbers.',
|
|
1695
|
+
snippetHeading: () => 'Paste into trazum.config.json (the "pricing" overlay file):',
|
|
1696
|
+
},
|
|
1697
|
+
|
|
1628
1698
|
fromOtel: {
|
|
1629
1699
|
noPath: () => 'from-otel needs an OTLP file or directory: trazum from-otel spans.json',
|
|
1630
1700
|
notFound: (path) => `${path}: not found`,
|
package/src/i18n/es.ts
CHANGED
|
@@ -48,6 +48,8 @@ ${bold('USO')}
|
|
|
48
48
|
trazum position <uso.jsonl>
|
|
49
49
|
trazum from-claude-code <fichero|dir> [--label <nombre>] [-o <fichero>]
|
|
50
50
|
trazum from-otel <fichero|dir> [--label-from-service] [-o <fichero>]
|
|
51
|
+
trazum switch <uso.jsonl> --to <modelo> [--migration-usd <n>] [--cases <n>]
|
|
52
|
+
trazum ownrate --gpu-usd-hour <n> --tokens-per-second <n> [--utilization <0-1>]
|
|
51
53
|
trazum pulse [--max-stale-hours <n>]
|
|
52
54
|
trazum bench [--workload <id>] [--record <fichero>] [--against <fichero> --max-ratio <n>] [--json]
|
|
53
55
|
trazum write [--answers <fichero>] [--json] [-o <fichero>]
|
|
@@ -140,6 +142,34 @@ ${bold('OPCIONES DE position')}
|
|
|
140
142
|
siete días, con un techo superado o con tasa cero: nunca un pronóstico, y
|
|
141
143
|
ningún campo del documento nombra una fecha.
|
|
142
144
|
|
|
145
|
+
${bold('OPCIONES DE switch')}
|
|
146
|
+
--to <modelo> El modelo candidato, por id del catálogo.
|
|
147
|
+
--migration-usd <n> Lo que costaría la migración en sí, declarado
|
|
148
|
+
por ti. Desbloquea la línea de break-even.
|
|
149
|
+
--cases <n> Cuántos casos de evaluación correrías.
|
|
150
|
+
Desbloquea la línea que tasa esa evaluación.
|
|
151
|
+
|
|
152
|
+
La decisión a la que sirve cada what-if, tasada: qué cuesta este mix medido
|
|
153
|
+
en el candidato, el ahorro con su signo dicho, y — con un coste de
|
|
154
|
+
migración declarado — el break-even como división sobre el pasado medido,
|
|
155
|
+
con los días de ventana adjuntos, nunca un pronóstico. La evaluación que el
|
|
156
|
+
cambio exige se tasa a la llamada media de este log: dos llamadas al
|
|
157
|
+
titular y una al candidato por caso. Lo que se niega a decir: nada sobre
|
|
158
|
+
calidad — ese veredicto es de trazum route, y el informe termina
|
|
159
|
+
imprimiéndolo.
|
|
160
|
+
|
|
161
|
+
${bold('OPCIONES DE ownrate')}
|
|
162
|
+
--gpu-usd-hour <n> Lo que te cuesta una hora de tu hardware.
|
|
163
|
+
--tokens-per-second <n> Rendimiento que mediste en tu propio serving.
|
|
164
|
+
--utilization <0-1> Fracción de la hora realmente sirviendo.
|
|
165
|
+
Por defecto 1.
|
|
166
|
+
|
|
167
|
+
El $/MTok de tu modelo self-hosted, derivado de tus dos números — división
|
|
168
|
+
y nada más: sin amortización, sin modelo de energía, sin eficiencia
|
|
169
|
+
supuesta. Imprime la cifra y el snippet de overlay de precios para pegar
|
|
170
|
+
en trazum.config.json, de modo que el modelo que tú mismo sirves sea una
|
|
171
|
+
fila de primera en cada informe, tasado por ti y marcado como tal.
|
|
172
|
+
|
|
143
173
|
${bold('OPCIONES DE from-otel')}
|
|
144
174
|
--label-from-service Etiqueta cada registro con el nombre de servicio
|
|
145
175
|
de su span, para que salga una factura por
|
|
@@ -1642,6 +1672,47 @@ ${bold('EJEMPLOS')}
|
|
|
1642
1672
|
},
|
|
1643
1673
|
},
|
|
1644
1674
|
|
|
1675
|
+
switchCmd: {
|
|
1676
|
+
noLog: () => 'Nombra un log de uso: trazum switch <uso.jsonl> --to <modelo>',
|
|
1677
|
+
noTarget: () => 'Nombra el candidato: --to <modelo>. trazum models lista el catálogo.',
|
|
1678
|
+
unknownModel: (id) =>
|
|
1679
|
+
`El catálogo no tiene precio para «${id}», y una comparación contra un precio que nadie tiene es peor que ninguna. trazum models lista lo que conoce; un overlay de precios añade lo que no.`,
|
|
1680
|
+
heading: (target) => `Cambiar este tráfico a ${target}, medido`,
|
|
1681
|
+
saves: (current, target, saving) =>
|
|
1682
|
+
`${current} en este log se vuelven ${target} en el candidato — ${saving} menos, sobre los mismos tokens.`,
|
|
1683
|
+
costs: (current, target, extra) =>
|
|
1684
|
+
`${current} en este log se vuelven ${target} en el candidato — ${extra} MÁS. Este cambio pierde dinero antes siquiera de preguntar por la calidad.`,
|
|
1685
|
+
nothingMovable: () => 'Aquí no puede moverse nada: cada porción ya está en el candidato o excede su ventana de contexto.',
|
|
1686
|
+
movable: (calls, slices) => `${calls} llamada(s) en ${slices} porción(es) podrían moverse.`,
|
|
1687
|
+
overContext: (slices, usd) =>
|
|
1688
|
+
`${slices} porción(es) por valor de ${usd} no pueden moverse — al menos una llamada excede la ventana de contexto del candidato. Su dinero no está en ninguna cifra de arriba.`,
|
|
1689
|
+
alreadyOnTarget: (calls, usd) => `${calls} llamada(s) por valor de ${usd} ya están en el candidato.`,
|
|
1690
|
+
window: (days) => `Medido sobre ${days} día(s) de este log — cada cifra de arriba es aritmética sobre esa ventana.`,
|
|
1691
|
+
noWindow: () => 'Ningún registro lleva marca de tiempo, así que este log no tiene tasa medida.',
|
|
1692
|
+
breakEvenDays: (migration, days, measuredDays) =>
|
|
1693
|
+
`Un coste de migración declarado de ${migration} se recupera tras ~${days} día(s) al ahorro medido sobre ${measuredDays} día(s). División sobre el pasado — lo que haga el mes que viene es asunto del mes que viene.`,
|
|
1694
|
+
breakEvenNoSaving: (migration) =>
|
|
1695
|
+
`Break-even rechazado: el cambio no ahorra nada, así que los ${migration} declarados no tienen nada que recuperar.`,
|
|
1696
|
+
breakEvenNoClock: (migration) =>
|
|
1697
|
+
`Break-even rechazado para ${migration}: ningún registro lleva marca de tiempo, así que no hay tasa medida por la que dividir.`,
|
|
1698
|
+
evalCost: (cases, total) =>
|
|
1699
|
+
`Saber si el candidato vale también cuesta dinero: ${cases} caso(s) por trazum route son ~${total} a la llamada media de este log (dos llamadas al titular y una al candidato por caso).`,
|
|
1700
|
+
evalCostHint: () => 'Pasa --cases <n> para tasar la evaluación que el cambio exige.',
|
|
1701
|
+
quality: (routeCommand) =>
|
|
1702
|
+
`Nada de lo de arriba dice si el candidato puede hacer el trabajo. Eso es una evaluación, no aritmética: ${routeCommand}`,
|
|
1703
|
+
},
|
|
1704
|
+
|
|
1705
|
+
ownrate: {
|
|
1706
|
+
missing: () =>
|
|
1707
|
+
'Los dos números los declaras tú: trazum ownrate --gpu-usd-hour <n> --tokens-per-second <n> [--utilization <0-1>]',
|
|
1708
|
+
invalid: (flag) => `--${flag} debe ser un número positivo (utilization: mayor que 0, como mucho 1).`,
|
|
1709
|
+
result: (usdPerMTok, tokensPerSecond, gpuUsdPerHour, utilizationPct) =>
|
|
1710
|
+
`${usdPerMTok} por millón de tokens — ${gpuUsdPerHour}/hora entre ${tokensPerSecond} tokens/segundo al ${utilizationPct}% de servicio.`,
|
|
1711
|
+
declared: () =>
|
|
1712
|
+
'Derivado de tu declaración, honesto solo si el rendimiento se midió. Cada informe que tase este modelo descansará sobre estos dos números.',
|
|
1713
|
+
snippetHeading: () => 'Pega en trazum.config.json (el fichero de overlay «pricing»):',
|
|
1714
|
+
},
|
|
1715
|
+
|
|
1645
1716
|
fromOtel: {
|
|
1646
1717
|
noPath: () => 'from-otel necesita un archivo o directorio OTLP: trazum from-otel spans.json',
|
|
1647
1718
|
notFound: (path) => `${path}: no existe`,
|
package/src/i18n/types.ts
CHANGED
|
@@ -528,6 +528,41 @@ export interface CliMessages {
|
|
|
528
528
|
* is the command's honesty: LLM spans converted, non-LLM spans skipped, and
|
|
529
529
|
* how many carried no cache data (OTel has no TTL split to give).
|
|
530
530
|
*/
|
|
531
|
+
/**
|
|
532
|
+
* The 1.74 switching decision. Named `switchCmd` because the command is
|
|
533
|
+
* `switch`, which is a reserved word too load-bearing to fight in every
|
|
534
|
+
* file that touches this section.
|
|
535
|
+
*/
|
|
536
|
+
switchCmd: {
|
|
537
|
+
noLog(): string;
|
|
538
|
+
noTarget(): string;
|
|
539
|
+
unknownModel(id: string): string;
|
|
540
|
+
heading(target: string): string;
|
|
541
|
+
saves(current: string, target: string, saving: string): string;
|
|
542
|
+
costs(current: string, target: string, extra: string): string;
|
|
543
|
+
nothingMovable(): string;
|
|
544
|
+
movable(calls: number, slices: number): string;
|
|
545
|
+
overContext(slices: number, usd: string): string;
|
|
546
|
+
alreadyOnTarget(calls: number, usd: string): string;
|
|
547
|
+
window(days: number): string;
|
|
548
|
+
noWindow(): string;
|
|
549
|
+
breakEvenDays(migration: string, days: number, measuredDays: number): string;
|
|
550
|
+
breakEvenNoSaving(migration: string): string;
|
|
551
|
+
breakEvenNoClock(migration: string): string;
|
|
552
|
+
evalCost(cases: number, total: string): string;
|
|
553
|
+
evalCostHint(): string;
|
|
554
|
+
/** The refusal every rendering ends on: quality is route's verdict. */
|
|
555
|
+
quality(routeCommand: string): string;
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
ownrate: {
|
|
559
|
+
missing(): string;
|
|
560
|
+
invalid(flag: string): string;
|
|
561
|
+
result(usdPerMTok: string, tokensPerSecond: number, gpuUsdPerHour: string, utilizationPct: number): string;
|
|
562
|
+
declared(): string;
|
|
563
|
+
snippetHeading(): string;
|
|
564
|
+
};
|
|
565
|
+
|
|
531
566
|
fromOtel: {
|
|
532
567
|
noPath(): string;
|
|
533
568
|
notFound(path: string): string;
|
package/src/index.ts
CHANGED
|
@@ -112,6 +112,7 @@ import {
|
|
|
112
112
|
plannedCalls,
|
|
113
113
|
claudeCodeRecords,
|
|
114
114
|
otelRecords,
|
|
115
|
+
ownRate,
|
|
115
116
|
positionAt,
|
|
116
117
|
positionReport,
|
|
117
118
|
PRICING_LAST_REVIEWED,
|
|
@@ -125,6 +126,7 @@ import {
|
|
|
125
126
|
rejectionText,
|
|
126
127
|
reorderForCache,
|
|
127
128
|
repriceProfile,
|
|
129
|
+
switchAnalysis,
|
|
128
130
|
reviewAgeDays,
|
|
129
131
|
reviewExamples,
|
|
130
132
|
RULES,
|
|
@@ -348,6 +350,12 @@ const VALUE_FLAGS = new Set([
|
|
|
348
350
|
'prompt',
|
|
349
351
|
'out',
|
|
350
352
|
'o',
|
|
353
|
+
'to',
|
|
354
|
+
'migration-usd',
|
|
355
|
+
'cases',
|
|
356
|
+
'gpu-usd-hour',
|
|
357
|
+
'tokens-per-second',
|
|
358
|
+
'utilization',
|
|
351
359
|
]);
|
|
352
360
|
|
|
353
361
|
function parseArgs(argv: string[], t: CliMessages): Args {
|
|
@@ -672,6 +680,8 @@ const COMMAND_FLAGS: Record<string, string[]> = {
|
|
|
672
680
|
position: ['json', 'html-out', 'pricing', 'pricing-live'],
|
|
673
681
|
'from-claude-code': ['label', 'label-from-project', 'out', 'o'],
|
|
674
682
|
'from-otel': ['label-from-service', 'out', 'o'],
|
|
683
|
+
switch: ['to', 'migration-usd', 'cases'],
|
|
684
|
+
ownrate: ['gpu-usd-hour', 'tokens-per-second', 'utilization'],
|
|
675
685
|
pulse: ['json', 'max-stale-hours'],
|
|
676
686
|
bench: ['workload', 'json', 'record', 'against', 'max-ratio'],
|
|
677
687
|
write: ['answers', 'json', 'out', 'o', 'calls', 'avg-output'],
|
|
@@ -2648,6 +2658,138 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
|
|
|
2648
2658
|
* standardised the TTL split). Prompt content, trace ids and every other span
|
|
2649
2659
|
* attribute stay in the span; a fixture greps the whole output to prove it.
|
|
2650
2660
|
*/
|
|
2661
|
+
/**
|
|
2662
|
+
* `trazum switch` — the forty-first command, from the 1.74 plan: the decision
|
|
2663
|
+
* every what-if serves, priced. Rests on `switchAnalysis`, which rests on
|
|
2664
|
+
* `repriceProfile`, so over-context slices and cache minimums keep their
|
|
2665
|
+
* honesty. Ends, always, on the refusal: quality is `trazum route`'s verdict.
|
|
2666
|
+
*/
|
|
2667
|
+
async function commandSwitch(args: Args, pricing: PricingCatalogue, t: CliMessages): Promise<void> {
|
|
2668
|
+
const file = args.positional[0];
|
|
2669
|
+
if (file === undefined) throw new Error(t.switchCmd.noLog());
|
|
2670
|
+
const target = stringFlag(args, 'to');
|
|
2671
|
+
if (target === undefined) throw new Error(t.switchCmd.noTarget());
|
|
2672
|
+
// Optional numbers: absent stays absent — a defaulted migration cost or
|
|
2673
|
+
// case count would be an invented one.
|
|
2674
|
+
const optional = (name: string): number | undefined => {
|
|
2675
|
+
const raw = stringFlag(args, name);
|
|
2676
|
+
if (raw === undefined) return undefined;
|
|
2677
|
+
const value = Number(raw);
|
|
2678
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(t.errors.mustBeNonNegative(name, raw));
|
|
2679
|
+
return value;
|
|
2680
|
+
};
|
|
2681
|
+
const migrationUsd = optional('migration-usd');
|
|
2682
|
+
const cases = optional('cases');
|
|
2683
|
+
|
|
2684
|
+
const text = await readUsageLog(file, t);
|
|
2685
|
+
const report = profileUsage(text, { catalogue: pricing });
|
|
2686
|
+
const analysis = switchAnalysis(report, target, {
|
|
2687
|
+
catalogue: pricing,
|
|
2688
|
+
...(migrationUsd !== undefined ? { migrationUsd } : {}),
|
|
2689
|
+
...(cases !== undefined ? { evalCases: cases } : {}),
|
|
2690
|
+
});
|
|
2691
|
+
if (analysis === null) throw new Error(t.switchCmd.unknownModel(target));
|
|
2692
|
+
|
|
2693
|
+
const { reprice, savingUsd, measuredDays, breakEven, evalCost } = analysis;
|
|
2694
|
+
console.log();
|
|
2695
|
+
console.log(c.bold(t.switchCmd.heading(reprice.target.displayName)));
|
|
2696
|
+
if (reprice.slices.length === 0) {
|
|
2697
|
+
console.log(` ${wrap(t.switchCmd.nothingMovable(), 74, ' ')}`);
|
|
2698
|
+
} else {
|
|
2699
|
+
const line =
|
|
2700
|
+
savingUsd >= 0
|
|
2701
|
+
? t.switchCmd.saves(formatUsd(reprice.currentUsd), formatUsd(reprice.targetUsd), formatUsd(savingUsd))
|
|
2702
|
+
: t.switchCmd.costs(formatUsd(reprice.currentUsd), formatUsd(reprice.targetUsd), formatUsd(-savingUsd));
|
|
2703
|
+
console.log(` ${savingUsd >= 0 ? c.green('->') : c.red('->')} ${wrap(line, 72, ' ')}`);
|
|
2704
|
+
const movableCalls = reprice.slices.reduce((sum, slice) => sum + slice.calls, 0);
|
|
2705
|
+
console.log(` ${wrap(t.switchCmd.movable(movableCalls, reprice.slices.length), 74, ' ')}`);
|
|
2706
|
+
}
|
|
2707
|
+
if (reprice.overContext.length > 0) {
|
|
2708
|
+
const usd = reprice.overContext.reduce((sum, slice) => sum + slice.currentUsd, 0);
|
|
2709
|
+
console.log(` ${c.yellow('!')} ${wrap(t.switchCmd.overContext(reprice.overContext.length, formatUsd(usd)), 72, ' ')}`);
|
|
2710
|
+
}
|
|
2711
|
+
if (reprice.alreadyOnTarget.calls > 0) {
|
|
2712
|
+
console.log(` ${wrap(t.switchCmd.alreadyOnTarget(reprice.alreadyOnTarget.calls, formatUsd(reprice.alreadyOnTarget.usd)), 74, ' ')}`);
|
|
2713
|
+
}
|
|
2714
|
+
console.log(
|
|
2715
|
+
` ${wrap(measuredDays !== null ? t.switchCmd.window(measuredDays) : t.switchCmd.noWindow(), 74, ' ')}`,
|
|
2716
|
+
);
|
|
2717
|
+
if (breakEven !== null) {
|
|
2718
|
+
const sentence =
|
|
2719
|
+
'days' in breakEven
|
|
2720
|
+
? t.switchCmd.breakEvenDays(formatUsd(breakEven.migrationUsd), Math.ceil(breakEven.days), measuredDays ?? 0)
|
|
2721
|
+
: breakEven.refused === 'no-saving'
|
|
2722
|
+
? t.switchCmd.breakEvenNoSaving(formatUsd(breakEven.migrationUsd))
|
|
2723
|
+
: t.switchCmd.breakEvenNoClock(formatUsd(breakEven.migrationUsd));
|
|
2724
|
+
console.log(` ${wrap(sentence, 74, ' ')}`);
|
|
2725
|
+
}
|
|
2726
|
+
if (evalCost !== null) {
|
|
2727
|
+
console.log(` ${wrap(t.switchCmd.evalCost(evalCost.cases, formatUsd(evalCost.totalUsd)), 74, ' ')}`);
|
|
2728
|
+
} else if (reprice.slices.length > 0) {
|
|
2729
|
+
console.log(` ${c.dim(wrap(t.switchCmd.evalCostHint(), 74, ' '))}`);
|
|
2730
|
+
}
|
|
2731
|
+
console.log();
|
|
2732
|
+
console.log(
|
|
2733
|
+
` ${wrap(t.switchCmd.quality(`trazum route ${file} --prompt-file <prompt> --cases <cases> --yes`), 74, ' ')}`,
|
|
2734
|
+
);
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
/**
|
|
2738
|
+
* `trazum ownrate` — the forty-second: a self-hosted model's $/MTok, derived
|
|
2739
|
+
* from the operator's own declared numbers, with the overlay snippet ready to
|
|
2740
|
+
* paste. Division and a label, nothing modelled.
|
|
2741
|
+
*/
|
|
2742
|
+
function commandOwnrate(args: Args, t: CliMessages): void {
|
|
2743
|
+
const optional = (name: string): number | undefined => {
|
|
2744
|
+
const raw = stringFlag(args, name);
|
|
2745
|
+
if (raw === undefined) return undefined;
|
|
2746
|
+
const value = Number(raw);
|
|
2747
|
+
if (!Number.isFinite(value)) throw new Error(t.ownrate.invalid(name));
|
|
2748
|
+
return value;
|
|
2749
|
+
};
|
|
2750
|
+
const gpuUsdPerHour = optional('gpu-usd-hour');
|
|
2751
|
+
const tokensPerSecond = optional('tokens-per-second');
|
|
2752
|
+
const utilization = optional('utilization');
|
|
2753
|
+
if (gpuUsdPerHour === undefined || tokensPerSecond === undefined) throw new Error(t.ownrate.missing());
|
|
2754
|
+
if (!(gpuUsdPerHour > 0)) throw new Error(t.ownrate.invalid('gpu-usd-hour'));
|
|
2755
|
+
if (!(tokensPerSecond > 0)) throw new Error(t.ownrate.invalid('tokens-per-second'));
|
|
2756
|
+
if (utilization !== undefined && !(utilization > 0 && utilization <= 1))
|
|
2757
|
+
throw new Error(t.ownrate.invalid('utilization'));
|
|
2758
|
+
|
|
2759
|
+
const { usdPerMTok } = ownRate({
|
|
2760
|
+
gpuUsdPerHour,
|
|
2761
|
+
tokensPerSecond,
|
|
2762
|
+
...(utilization !== undefined ? { utilization } : {}),
|
|
2763
|
+
});
|
|
2764
|
+
const pct = Math.round((utilization ?? 1) * 100);
|
|
2765
|
+
console.log();
|
|
2766
|
+
console.log(
|
|
2767
|
+
` ${wrap(t.ownrate.result(formatUsd(usdPerMTok), tokensPerSecond, formatUsd(gpuUsdPerHour), pct), 74, ' ')}`,
|
|
2768
|
+
);
|
|
2769
|
+
console.log(` ${c.dim(wrap(t.ownrate.declared(), 74, ' '))}`);
|
|
2770
|
+
console.log();
|
|
2771
|
+
console.log(` ${t.ownrate.snippetHeading()}`);
|
|
2772
|
+
// Complete on purpose: the overlay parser refuses a new model with fields
|
|
2773
|
+
// missing, and a snippet that does not paste is worse than none. The
|
|
2774
|
+
// honest values for what a self-hosted model has not measured are the
|
|
2775
|
+
// catalogue's own unknowns, never a guess.
|
|
2776
|
+
const snippet = {
|
|
2777
|
+
lastReviewed: new Date().toISOString().slice(0, 10),
|
|
2778
|
+
models: {
|
|
2779
|
+
'my-self-hosted-model': {
|
|
2780
|
+
displayName: 'My self-hosted model',
|
|
2781
|
+
inputPerMTok: Number(usdPerMTok.toFixed(4)),
|
|
2782
|
+
outputPerMTok: Number(usdPerMTok.toFixed(4)),
|
|
2783
|
+
contextWindow: 32768,
|
|
2784
|
+
cacheMinTokens: null,
|
|
2785
|
+
tier: 'unknown',
|
|
2786
|
+
capability: 'unknown',
|
|
2787
|
+
},
|
|
2788
|
+
},
|
|
2789
|
+
};
|
|
2790
|
+
console.log(JSON.stringify(snippet, null, 2));
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2651
2793
|
async function commandFromOtel(args: Args, t: CliMessages): Promise<void> {
|
|
2652
2794
|
const target = args.positional[0];
|
|
2653
2795
|
if (target === undefined) throw new Error(t.fromOtel.noPath());
|
|
@@ -11097,6 +11239,12 @@ async function main(): Promise<void> {
|
|
|
11097
11239
|
case 'from-otel':
|
|
11098
11240
|
await commandFromOtel(args, t);
|
|
11099
11241
|
break;
|
|
11242
|
+
case 'switch':
|
|
11243
|
+
await commandSwitch(args, pricing, t);
|
|
11244
|
+
break;
|
|
11245
|
+
case 'ownrate':
|
|
11246
|
+
commandOwnrate(args, t);
|
|
11247
|
+
break;
|
|
11100
11248
|
case 'pulse':
|
|
11101
11249
|
await commandPulse(args, t);
|
|
11102
11250
|
break;
|