@trazum/cli 1.51.2 → 1.52.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/index.js CHANGED
@@ -1615,9 +1615,36 @@ function commandFeedback(t) {
1615
1615
  * config, with the operator's own reason, and every substituted call is marked
1616
1616
  * so no later report treats it as the call the caller made.
1617
1617
  */
1618
+ /**
1619
+ * Every provider the catalogue prices.
1620
+ *
1621
+ * `provider` is optional on a model — an overlay may add one without it — so a
1622
+ * missing provider is skipped rather than coerced. A model with no provider
1623
+ * cannot make its provider "supported" by accident.
1624
+ */
1625
+ function pricedProviders(catalogue) {
1626
+ const models = catalogue.models ?? [];
1627
+ return new Set(models.map((m) => m.provider).filter((p) => typeof p === 'string'));
1628
+ }
1618
1629
  async function commandGateway(args, config, configDir, pricing, t) {
1619
1630
  const provider = args.positional[0];
1620
1631
  if (provider === undefined || UPSTREAMS[provider] === undefined) {
1632
+ /**
1633
+ * Three answers, not two.
1634
+ *
1635
+ * A provider Trazum **prices** but does not front is a different situation
1636
+ * from a name it has never heard, and until 1.53 both got the same
1637
+ * sentence. One is a gap in this tool with a workaround; the other is a
1638
+ * typo. Telling them apart is the difference between a user reaching for
1639
+ * `profile` and a user checking their spelling.
1640
+ *
1641
+ * Derived from the catalogue, so a provider added to pricing starts
1642
+ * getting the better answer without anyone remembering to update a list.
1643
+ */
1644
+ const priced = pricedProviders(pricing);
1645
+ if (provider !== undefined && priced.has(provider)) {
1646
+ throw new Error(t.gateway.pricedNotFronted(provider, Object.keys(UPSTREAMS).join(', ')));
1647
+ }
1621
1648
  throw new Error(t.gateway.badProvider(provider ?? '', Object.keys(UPSTREAMS).join(', ')));
1622
1649
  }
1623
1650
  /**
@@ -1651,6 +1678,14 @@ async function commandGateway(args, config, configDir, pricing, t) {
1651
1678
  asOfMs: Date.now(),
1652
1679
  };
1653
1680
  const measured = { calls: 0, usd: 0 };
1681
+ /**
1682
+ * Forwarded calls whose cost this session cannot see.
1683
+ *
1684
+ * Counted separately and never folded into `measured`: the money was spent,
1685
+ * so the two are not interchangeable, and a total that quietly absorbed them
1686
+ * would be the flattering direction.
1687
+ */
1688
+ let unmeasured = 0;
1654
1689
  const server = buildGateway({
1655
1690
  provider,
1656
1691
  catalogue: pricing,
@@ -1663,6 +1698,10 @@ async function commandGateway(args, config, configDir, pricing, t) {
1663
1698
  measured.calls += 1;
1664
1699
  console.error(c.dim(t.gateway.measured(call.model, call.label, call.inputTokens, call.outputTokens, call.substituted)));
1665
1700
  },
1701
+ unmeasured: (cause) => {
1702
+ unmeasured += 1;
1703
+ console.error(c.yellow(` ${t.gateway.unmeasured(cause, unmeasured)}`));
1704
+ },
1666
1705
  note: (line) => {
1667
1706
  console.error(c.yellow(` ${line}`));
1668
1707
  },
@@ -3466,7 +3505,10 @@ async function commandConnect(args, pricing, t) {
3466
3505
  }
3467
3506
  const descriptor = connectorFor(id);
3468
3507
  if (descriptor === null) {
3469
- throw new Error(t.connect.unknownProvider(id, CONNECTORS.map((c) => c.id).join(', ')));
3508
+ // The same three-way split as the gateway, for the same reason.
3509
+ const priced = pricedProviders(pricing);
3510
+ const known = CONNECTORS.map((c) => c.id).join(', ');
3511
+ throw new Error(priced.has(id) ? t.connect.pricedNoConnector(id, known) : t.connect.unknownProvider(id, known));
3470
3512
  }
3471
3513
  const now = Date.now();
3472
3514
  const since = parseWhen(args, 'since', false, t, now);