@trazum/cli 2.7.2 → 2.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/cli",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "What your AI agents cost, per project, offline: one bill across Claude Code, Codex and Gemini CLI sessions, plus Anthropic, OpenAI, Gemini, OpenRouter, OTel and LiteLLM usage, written as PDF, HTML or CSV, with budgets enforced in CI.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
@@ -53,7 +53,7 @@
53
53
  "prepublishOnly": "npm run build && npm test"
54
54
  },
55
55
  "dependencies": {
56
- "@trazum/core": "2.7.2"
56
+ "@trazum/core": "2.7.3"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^26.6.6",
package/src/connect.ts CHANGED
@@ -103,12 +103,23 @@ function urlFor(provider: string, fromMs: number, toMs: number, page: string | n
103
103
  url.searchParams.set('starting_at', new Date(fromMs).toISOString());
104
104
  url.searchParams.set('ending_at', new Date(toMs).toISOString());
105
105
  url.searchParams.set('bucket_width', '1d');
106
- url.searchParams.append('group_by[]', 'model');
106
+ /*
107
+ * Model, and the three groupings that change what a token costs: the
108
+ * service tier (batch is billed at a discount), the speed (fast mode at a
109
+ * multiple) and the geography (US-only inference at 1.1x on Claude 4.6
110
+ * and later). Without them every row sums all of those at one rate.
111
+ */
112
+ for (const group of ['model', 'service_tier', 'speed', 'inference_geo']) {
113
+ url.searchParams.append('group_by[]', group);
114
+ }
107
115
  } else {
108
116
  url.searchParams.set('start_time', String(Math.floor(fromMs / 1000)));
109
117
  url.searchParams.set('end_time', String(Math.floor(toMs / 1000)));
110
118
  url.searchParams.set('bucket_width', '1d');
111
- url.searchParams.append('group_by[]', 'model');
119
+ // Model, batch (billed at a discount) and service tier (Flex, Fast, each its own table).
120
+ for (const group of ['model', 'batch', 'service_tier']) {
121
+ url.searchParams.append('group_by[]', group);
122
+ }
112
123
  url.searchParams.set('limit', '31');
113
124
  }
114
125
  if (page !== null) url.searchParams.set('page', page);
@@ -368,6 +368,7 @@ function describe(body: string, provider: string, modelFromPath: string | null):
368
368
  session: string | null;
369
369
  speed: string | null;
370
370
  serviceTier: string | null;
371
+ inferenceGeo: string | null;
371
372
  } | null {
372
373
  let parsed: unknown;
373
374
  try {
@@ -439,6 +440,13 @@ function describe(body: string, provider: string, modelFromPath: string | null):
439
440
  * is judged by has to know it.
440
441
  */
441
442
  speed: typeof request.speed === 'string' && request.speed !== '' ? request.speed : null,
443
+ /**
444
+ * Anthropic's `inference_geo: "us"`: a setting, not content, and one that
445
+ * bills the call at 1.1x on Claude 4.6 and later, so the estimate a budget
446
+ * is judged by has to know it. The response says which geography ran.
447
+ */
448
+ inferenceGeo:
449
+ typeof request.inference_geo === 'string' && request.inference_geo !== '' ? request.inference_geo : null,
442
450
  /**
443
451
  * OpenAI's `service_tier`: Flex bills about half the standard rate and
444
452
  * Fast up to twice, so the estimate a budget is judged by has to know it.
@@ -106,6 +106,8 @@ export class GatewaySpend {
106
106
  ...(usage.speed === undefined ? {} : { speed: usage.speed }),
107
107
  // So does OpenAI's service tier, each priced from its own table.
108
108
  ...(usage.serviceTier === undefined ? {} : { service_tier: usage.serviceTier }),
109
+ // And US-only inference, 1.1x on Claude 4.6 and later.
110
+ ...(usage.inferenceGeo === undefined ? {} : { inference_geo: usage.inferenceGeo }),
109
111
  }));
110
112
  const index = record === null ? null : indexUsage([record], { catalogue: this.catalogue, on: new Date(now) });
111
113
  if (index === null || index.unpriced > 0 || index.dayUsd === null) {
package/src/i18n/en.ts CHANGED
@@ -2037,6 +2037,18 @@ ${bold('EXAMPLES')}
2037
2037
  `${count} row(s) were billed at a tier a catalogue rate is not the rate for (batch, priority, flex) and are not in the output. Pricing them from the standard rate would overstate the bill and look right doing it.`,
2038
2038
  tierUnknown: () =>
2039
2039
  'The report never named a service tier, so a batch row and a standard row are indistinguishable here. Everything was read as standard. Add group_by[]=service_tier if any of this usage is batched.',
2040
+ fastPriced: (count) =>
2041
+ `${count} row(s) ran in fast mode and are priced from the model's own fast rate, as a logged response with usage.speed "fast" would be.`,
2042
+ fastUnpriced: (count, models) =>
2043
+ `${count} row(s) ran in fast mode on a model Trazum has no fast rate for (${models}) and are not in the output. The standard rate is well under fast mode's, so pricing them at it would understate the bill.`,
2044
+ speedUnknown: (count) =>
2045
+ `The report never named a speed, and ${count} row(s) are on a model with a fast mode, which bills at a higher rate. They were read as standard. Add group_by[]=speed if any of this usage ran fast.`,
2046
+ usOnly: (count) =>
2047
+ `${count} row(s) ran with inference_geo "us" and are priced at the published 1.1x that US-only inference bills on Claude 4.6 and later.`,
2048
+ usOnlyFloor: (count) =>
2049
+ `${count} row(s) ran with inference_geo "us" on a model Trazum has no US-only multiplier for. They are priced at the global rate, so their figure is a floor.`,
2050
+ geoUnknown: (count) =>
2051
+ `The report never named an inference geography, and ${count} row(s) are on a model that bills US-only inference at 1.1x. They were read as global. Add group_by[]=inference_geo if any workspace pins inference to the US.`,
2040
2052
  webSearch: (count) =>
2041
2053
  `${count} web search request(s) are in this report and in no line of the output: server tools are billed per request, not per token, so no token rate reaches them.`,
2042
2054
  truncated: () =>
@@ -2071,7 +2083,9 @@ ${bold('EXAMPLES')}
2071
2083
  batchUnknown: () =>
2072
2084
  'The report never said whether anything was batch, so a batch row and a standard row are indistinguishable here. Everything was read as standard. Add group_by[]=batch if any of this usage is batched.',
2073
2085
  nonDefaultTier: (count, tiers) =>
2074
- `${count} row(s) were at a service tier a catalogue rate is not the rate for (${tiers}) and are not in the output. The schema does not list the tiers, so they are named rather than guessed at.`,
2086
+ `${count} row(s) were at a service tier Trazum has no table for on that model (${tiers}) and are not in the output. The standard rate is not that tier's rate, and the schema does not list the tiers, so they are named rather than guessed at.`,
2087
+ serviceTierPriced: (count, tiers) =>
2088
+ `${count} row(s) ran at another service tier (${tiers}) and are priced from that tier's own table, as a logged response naming it would be.`,
2075
2089
  tierUnknown: () =>
2076
2090
  'The report never named a service tier. Everything was read as the default tier. Add group_by[]=service_tier if any of this usage runs on another.',
2077
2091
  mixed: (rows, tokens, cacheWrites) =>
package/src/i18n/es.ts CHANGED
@@ -2067,6 +2067,18 @@ ${bold('EJEMPLOS')}
2067
2067
  `${count} fila(s) se facturaron en un tramo para el que una tarifa de catálogo no es la tarifa (batch, priority, flex) y no están en la salida. Cobrarlas a la tarifa estándar inflaría la factura y parecería correcto.`,
2068
2068
  tierUnknown: () =>
2069
2069
  'El informe no nombró ningún tramo de servicio, así que una fila batch y una estándar son indistinguibles aquí. Todo se leyó como estándar. Añade group_by[]=service_tier si parte de este uso va por lotes.',
2070
+ fastPriced: (count) =>
2071
+ `${count} fila(s) corrieron en modo rápido y se cobran con la tarifa rápida del propio modelo, como se cobraría una respuesta registrada con usage.speed "fast".`,
2072
+ fastUnpriced: (count, models) =>
2073
+ `${count} fila(s) corrieron en modo rápido en un modelo para el que Trazum no tiene tarifa rápida (${models}) y no están en la salida. La tarifa estándar queda muy por debajo de la del modo rápido, así que cobrarlas con ella dejaría la factura corta.`,
2074
+ speedUnknown: (count) =>
2075
+ `El informe no nombró ninguna velocidad, y ${count} fila(s) son de un modelo con modo rápido, que se factura más caro. Se leyeron como estándar. Añade group_by[]=speed si parte de este uso corrió en modo rápido.`,
2076
+ usOnly: (count) =>
2077
+ `${count} fila(s) corrieron con inference_geo "us" y se cobran al 1,1x publicado que la inferencia solo en EE. UU. factura en Claude 4.6 y posteriores.`,
2078
+ usOnlyFloor: (count) =>
2079
+ `${count} fila(s) corrieron con inference_geo "us" en un modelo para el que Trazum no tiene multiplicador de EE. UU. Se cobran a la tarifa global, así que su cifra es un suelo.`,
2080
+ geoUnknown: (count) =>
2081
+ `El informe no nombró ninguna geografía de inferencia, y ${count} fila(s) son de un modelo que factura la inferencia solo en EE. UU. a 1,1x. Se leyeron como globales. Añade group_by[]=inference_geo si algún workspace fija la inferencia en EE. UU.`,
2070
2082
  webSearch: (count) =>
2071
2083
  `${count} petición(es) de búsqueda web están en el informe y en ninguna línea de la salida: las herramientas de servidor se facturan por petición, no por token, así que ninguna tarifa por token llega a ellas.`,
2072
2084
  truncated: () =>
@@ -2101,7 +2113,9 @@ ${bold('EJEMPLOS')}
2101
2113
  batchUnknown: () =>
2102
2114
  'El informe nunca dijo si algo fue batch, así que una fila por lotes y una estándar son indistinguibles aquí. Todo se leyó como estándar. Añade group_by[]=batch si parte de este uso va por lotes.',
2103
2115
  nonDefaultTier: (count, tiers) =>
2104
- `${count} fila(s) estaban en un tramo de servicio para el que una tarifa de catálogo no es la tarifa (${tiers}) y no están en la salida. El esquema no lista los tramos, así que se nombran en vez de adivinarse.`,
2116
+ `${count} fila(s) estaban en un tramo de servicio para el que Trazum no tiene tabla en ese modelo (${tiers}) y no están en la salida. La tarifa estándar no es la de ese tramo, y el esquema no lista los tramos, así que se nombran en vez de adivinarse.`,
2117
+ serviceTierPriced: (count, tiers) =>
2118
+ `${count} fila(s) corrieron en otro tramo de servicio (${tiers}) y se cobran con la tabla propia de ese tramo, como se cobraría una respuesta registrada que lo nombre.`,
2105
2119
  tierUnknown: () =>
2106
2120
  'El informe no nombró ningún tramo de servicio. Todo se leyó como el tramo por defecto. Añade group_by[]=service_tier si parte de este uso corre en otro.',
2107
2121
  mixed: (rows, tokens, cacheWrites) =>
package/src/i18n/types.ts CHANGED
@@ -709,6 +709,12 @@ export interface CliMessages {
709
709
  /** Said when the report never named a tier: the question was not asked. */
710
710
  tierUnknown(): string;
711
711
  /** Server tools are billed per request, and no token rate reaches them. */
712
+ fastPriced(count: number): string;
713
+ fastUnpriced(count: number, models: string): string;
714
+ speedUnknown(count: number): string;
715
+ usOnly(count: number): string;
716
+ usOnlyFloor(count: number): string;
717
+ geoUnknown(count: number): string;
712
718
  webSearch(count: number): string;
713
719
  /** One page of several: the bill from it is understated. */
714
720
  truncated(): string;
@@ -735,6 +741,7 @@ export interface CliMessages {
735
741
  batchUnknown(): string;
736
742
  /** Any tier but default, named rather than counted. */
737
743
  nonDefaultTier(count: number, tiers: string): string;
744
+ serviceTierPriced(count: number, tiers: string): string;
738
745
  tierUnknown(): string;
739
746
  /** Rows reduced to their text part; audio and image tokens set aside. */
740
747
  mixed(rows: number, tokens: number, cacheWrites: number): string;
package/src/index.ts CHANGED
@@ -3762,7 +3762,7 @@ async function commandBill(args: Args, pricing: PricingCatalogue, t: CliMessages
3762
3762
  case 'anthropic-usage': {
3763
3763
  const c = anthropicUsageRecords(text, withLabel);
3764
3764
  records = c.records;
3765
- leftOut = c.unnamedModel + c.nonStandardTier;
3765
+ leftOut = c.unnamedModel + c.nonStandardTier + c.fastUnpriced;
3766
3766
  break;
3767
3767
  }
3768
3768
  case 'openai-usage': {
@@ -4727,6 +4727,18 @@ async function commandFromAnthropic(args: Args, t: CliMessages): Promise<void> {
4727
4727
  console.error(t.fromAnthropic.nonStandardTier(conversion.nonStandardTier));
4728
4728
  }
4729
4729
  if (!conversion.tierNamed && conversion.rows > 0) console.error(t.fromAnthropic.tierUnknown());
4730
+ if (conversion.fastRows > 0) console.error(t.fromAnthropic.fastPriced(conversion.fastRows));
4731
+ if (conversion.fastUnpriced > 0) {
4732
+ console.error(t.fromAnthropic.fastUnpriced(conversion.fastUnpriced, conversion.fastUnpricedModels.join(', ')));
4733
+ }
4734
+ if (!conversion.speedNamed && conversion.speedUnknownFastCapable > 0) {
4735
+ console.error(t.fromAnthropic.speedUnknown(conversion.speedUnknownFastCapable));
4736
+ }
4737
+ if (conversion.usOnlyRows > 0) console.error(t.fromAnthropic.usOnly(conversion.usOnlyRows));
4738
+ if (conversion.usOnlyFloor > 0) console.error(t.fromAnthropic.usOnlyFloor(conversion.usOnlyFloor));
4739
+ if (!conversion.geoNamed && conversion.geoUnknownMultiplied > 0) {
4740
+ console.error(t.fromAnthropic.geoUnknown(conversion.geoUnknownMultiplied));
4741
+ }
4730
4742
  if (conversion.webSearchRequests > 0) console.error(t.fromAnthropic.webSearch(conversion.webSearchRequests));
4731
4743
  if (conversion.labelledByWorkspace > 0) {
4732
4744
  console.error(t.fromAnthropic.labelledByWorkspace(conversion.labelledByWorkspace));
@@ -4780,6 +4792,9 @@ async function commandFromOpenai(args: Args, t: CliMessages): Promise<void> {
4780
4792
  if (conversion.unnamedModel > 0) console.error(t.fromOpenai.unnamedModel(conversion.unnamedModel));
4781
4793
  if (conversion.batch > 0) console.error(t.fromOpenai.batch(conversion.batch));
4782
4794
  if (!conversion.batchNamed && conversion.rows > 0) console.error(t.fromOpenai.batchUnknown());
4795
+ if (conversion.serviceTierRows > 0) {
4796
+ console.error(t.fromOpenai.serviceTierPriced(conversion.serviceTierRows, conversion.tiersPriced.join(', ')));
4797
+ }
4783
4798
  if (conversion.nonDefaultTier > 0) {
4784
4799
  console.error(t.fromOpenai.nonDefaultTier(conversion.nonDefaultTier, conversion.tiersRefused.join(', ')));
4785
4800
  }