llm-relay 0.72.0 → 0.72.2

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/cli.js CHANGED
@@ -1647,6 +1647,15 @@ ${lane} — ${entry.models.length} models, probed ${entry.probedAt} via \`${entr
1647
1647
  process.stdout.write("These are removed from the ladder and their command is withheld.\n");
1648
1648
  }
1649
1649
  }
1650
+ function setupDispatchCatalog(cfg) {
1651
+ const catalog = new ModelCatalog();
1652
+ try {
1653
+ materializeDynamicPools(cfg, catalog);
1654
+ }
1655
+ catch {
1656
+ }
1657
+ return contextWindowResolver((provider, model) => catalog.cachedLimits(provider, model)?.contextLength ?? null, snapshotContextWindow, observedContextLimit);
1658
+ }
1650
1659
  export async function resolveDispatchView(opts) {
1651
1660
  const cfg = opts.cfg ?? loadOrExit();
1652
1661
  const qs = new URLSearchParams();
@@ -1657,13 +1666,7 @@ export async function resolveDispatchView(opts) {
1657
1666
  if (opts.client)
1658
1667
  qs.set("client", opts.client);
1659
1668
  qs.set("host", "bypassed");
1660
- const catalog = new ModelCatalog();
1661
- try {
1662
- materializeDynamicPools(cfg, catalog);
1663
- }
1664
- catch {
1665
- }
1666
- const cachedContextWindow = contextWindowResolver((provider, model) => catalog.cachedLimits(provider, model)?.contextLength ?? null, snapshotContextWindow, observedContextLimit);
1669
+ const cachedContextWindow = setupDispatchCatalog(cfg);
1667
1670
  const liveRaw = (await tryServer(cfg, `/dispatch?${qs}`));
1668
1671
  const live = liveRaw !== null && liveRaw.host === "bypassed" ? liveRaw : null;
1669
1672
  restoreExhaustedRows(cfg, loadExhaustedRows());
@@ -1703,9 +1706,7 @@ export async function runMcp() {
1703
1706
  process.stdin.on("end", stop);
1704
1707
  process.stdin.on("close", stop);
1705
1708
  process.stdin.setEncoding("utf8");
1706
- for await (const chunk of process.stdin) {
1707
- await server.ingest(chunk);
1708
- }
1709
+ await server.serve(process.stdin);
1709
1710
  server.shutdown();
1710
1711
  }
1711
1712
  async function recordSpentDispatchLane(cfg, spent, options) {
@@ -1778,13 +1779,7 @@ export async function runDispatch(arg) {
1778
1779
  if (hostRouting.entrypoint)
1779
1780
  qs.set("entrypoint", hostRouting.entrypoint);
1780
1781
  const path = `/dispatch${qs.toString() ? `?${qs}` : ""}`;
1781
- const catalog = new ModelCatalog();
1782
- try {
1783
- materializeDynamicPools(cfg, catalog);
1784
- }
1785
- catch {
1786
- }
1787
- const cachedContextWindow = contextWindowResolver((provider, model) => catalog.cachedLimits(provider, model)?.contextLength ?? null, snapshotContextWindow, observedContextLimit);
1782
+ const cachedContextWindow = setupDispatchCatalog(cfg);
1788
1783
  const liveRaw = (await tryServer(cfg, path));
1789
1784
  const hostStale = liveRaw !== null && hostRouting.state !== "unknown" && liveRaw.host !== hostRouting.state;
1790
1785
  const windowStale = liveRaw !== null &&