@trazum/cli 2.4.3 → 2.5.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/src/markdown.ts CHANGED
@@ -8,7 +8,7 @@ import type {
8
8
  PromptProfile,
9
9
  RuleLevel,
10
10
  } from '@trazum/core';
11
- import { TTL_1H_MS, UNLABELLED, formatSignedUsd, formatUsd, getMessages, getModel, sharesOf } from '@trazum/core';
11
+ import { UNLABELLED, formatSignedUsd, formatUsd, getMessages, getModel, sharesOf } from '@trazum/core';
12
12
  import { dayOf, formatGap, median, spanDays } from './time.js';
13
13
  import type { AgainstDriver, BillLevers, CacheEconomics, ContextPressure, RepriceReport, UsageProfileReport } from '@trazum/core';
14
14
 
@@ -1161,6 +1161,10 @@ export function renderProfileMarkdown(input: ProfileMarkdownInput): string {
1161
1161
  );
1162
1162
  lines.push('');
1163
1163
  // The decision's other half, on the target's rates, never summed.
1164
+ if (whatIf.tierCeiling !== null) {
1165
+ lines.push(`> ⚠️ ${mdText(t.profile.whatIfTierCeiling(whatIf.tierCeiling.slices, whatIf.target.displayName, formatUsd(whatIf.tierCeiling.targetFloorUsd)))}`);
1166
+ lines.push('');
1167
+ }
1164
1168
  if (whatIf.batchOnTarget !== null) {
1165
1169
  lines.push(`_${mdText(t.profile.whatIfBatchOnTarget(formatUsd(whatIf.batchOnTarget.targetUsd), formatUsd(whatIf.targetUsd)))}_`);
1166
1170
  lines.push('');
@@ -1212,9 +1216,11 @@ export function renderProfileMarkdown(input: ProfileMarkdownInput): string {
1212
1216
  const gap = formatGap(fit.medianGapMs);
1213
1217
  const sentence =
1214
1218
  fit.verdict === 'expires-before-reuse'
1215
- ? fit.medianGapMs > TTL_1H_MS
1216
- ? t.profile.ttlFitExpiresBoth(who, fit.modelName, gap)
1217
- : t.profile.ttlFitExpires(who, fit.modelName, gap)
1219
+ ? fit.longerTtlMs === null
1220
+ ? t.profile.ttlFitExpiresOnly(who, fit.modelName, gap, formatGap(fit.entryTtlMs))
1221
+ : fit.medianGapMs > fit.longerTtlMs
1222
+ ? t.profile.ttlFitExpiresBoth(who, fit.modelName, gap)
1223
+ : t.profile.ttlFitExpires(who, fit.modelName, gap)
1218
1224
  : fit.verdict === 'overlong-ttl'
1219
1225
  ? t.profile.ttlFitOverlong(who, fit.modelName, gap, formatUsd(fit.overpayUsd))
1220
1226
  : fit.verdict === 'unsettled'
@@ -1330,6 +1336,10 @@ export function renderProfileMarkdown(input: ProfileMarkdownInput): string {
1330
1336
  lines.push(`> ⚠️ ${mdText(t.profile.unpriced(report.unpricedModels.join(', '), report.unpriced.calls))}`);
1331
1337
  lines.push('');
1332
1338
  }
1339
+ if (report.total.tierCeilingCalls > 0) {
1340
+ lines.push(`> ⚠️ ${mdText(tierCeilingCaveat(report, t))}`);
1341
+ lines.push('');
1342
+ }
1333
1343
  if (report.skippedLines.length > 0) {
1334
1344
  const shown = report.skippedLines.slice(0, 5).join(', ');
1335
1345
  lines.push(`_${mdText(t.profile.skipped(report.skippedLines.length, report.skippedLines.length > 5 ? `${shown}…` : shown))}_`);
@@ -1338,3 +1348,19 @@ export function renderProfileMarkdown(input: ProfileMarkdownInput): string {
1338
1348
 
1339
1349
  return `${lines.join('\n').trimEnd()}\n`;
1340
1350
  }
1351
+
1352
+ /**
1353
+ * The ceiling caveat in words: rows billed at the dearer of two rates because
1354
+ * they sum requests on a model priced by prompt length. One sentence for every
1355
+ * surface that prints a report, so the terminal, the receipt summary and the
1356
+ * exported documents cannot word the range differently.
1357
+ */
1358
+ export function tierCeilingCaveat(report: UsageProfileReport, t: CliMessages): string {
1359
+ const models = report.byModel.filter((row) => row.breakdown.tierCeilingCalls > 0).map((row) => row.model);
1360
+ return t.profile.tierCeiling(
1361
+ report.total.tierCeilingCalls,
1362
+ models.join(', '),
1363
+ formatUsd(report.total.tierCeilingUsd),
1364
+ formatUsd(report.total.tierFloorUsd),
1365
+ );
1366
+ }
package/src/pdf.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PdfDocument, UNLABELLED, formatUsd, pdfFit, pdfWrap, sharesOf } from '@trazum/core';
2
2
  import type { PdfColor, PdfFont, UsageBreakdown } from '@trazum/core';
3
+ import { tierCeilingCaveat } from './markdown.js';
3
4
  import type { ProfileMarkdownInput } from './markdown.js';
4
5
  import { dayOf, spanDays } from './time.js';
5
6
 
@@ -235,6 +236,7 @@ export function renderProfilePdf(input: ProfileMarkdownInput, options: ProfilePd
235
236
  ),
236
237
  );
237
238
  }
239
+ if (report.total.tierCeilingCalls > 0) caveats.push(tierCeilingCaveat(report, t));
238
240
  if (stalePricing !== undefined) caveats.push(t.profile.pricesStale(stalePricing.date, stalePricing.days));
239
241
  if (caveats.length > 0) {
240
242
  box(t.html.caveatsHeading(), caveats, { edge: CAVEAT_EDGE, fill: CAVEAT_FILL, ink: CAVEAT_INK }, true);