@trazum/cli 1.52.0 → 1.53.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/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
  /**
@@ -3478,7 +3505,10 @@ async function commandConnect(args, pricing, t) {
3478
3505
  }
3479
3506
  const descriptor = connectorFor(id);
3480
3507
  if (descriptor === null) {
3481
- 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));
3482
3512
  }
3483
3513
  const now = Date.now();
3484
3514
  const since = parseWhen(args, 'since', false, t, now);