routstrd 0.2.16 → 0.2.17

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.
@@ -37553,6 +37553,7 @@ var createBunSqliteUsageTrackingDriver2 = (options = {}) => {
37553
37553
 
37554
37554
  // src/daemon/wallet/index.ts
37555
37555
  init_cashu_ts_es();
37556
+ init_dist3();
37556
37557
 
37557
37558
  // src/daemon/wallet/cocod-client.ts
37558
37559
  import { createHash } from "crypto";
@@ -37908,6 +37909,9 @@ async function createWalletAdapter(options = {}) {
37908
37909
  await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
37909
37910
  continue;
37910
37911
  }
37912
+ if (errorMessage.includes("Not enough proofs")) {
37913
+ throw new InsufficientBalanceError(amount, 0);
37914
+ }
37911
37915
  logger3.error("Error in walletAdapter sendToken:", error);
37912
37916
  throw error;
37913
37917
  }
@@ -37940,7 +37944,7 @@ async function createWalletAdapter(options = {}) {
37940
37944
  }
37941
37945
 
37942
37946
  // src/daemon/models.ts
37943
- function createModelService(modelManager) {
37947
+ function createModelService(modelManager, store) {
37944
37948
  let providerBootstrapPromise = null;
37945
37949
  const ensureProvidersBootstrapped = () => {
37946
37950
  if (!providerBootstrapPromise) {
@@ -37949,6 +37953,16 @@ function createModelService(modelManager) {
37949
37953
  const providers = await modelManager.bootstrapProviders(false);
37950
37954
  logger3.log(`Bootstrapped ${providers.length} providers`);
37951
37955
  await modelManager.fetchModels(providers);
37956
+ const { baseUrlsList, setBaseUrlsList } = store.getState();
37957
+ const existing = new Set(baseUrlsList);
37958
+ const merged = [
37959
+ ...baseUrlsList,
37960
+ ...providers.filter((url2) => !existing.has(url2))
37961
+ ];
37962
+ if (merged.length !== baseUrlsList.length) {
37963
+ setBaseUrlsList(merged);
37964
+ logger3.log(`Synced ${merged.length - baseUrlsList.length} new provider(s) into store`);
37965
+ }
37952
37966
  logger3.log("Provider bootstrap complete.");
37953
37967
  })().catch((error) => {
37954
37968
  logger3.error("Provider bootstrap failed:", error);
@@ -43349,7 +43363,7 @@ async function main() {
43349
43363
  const storageAdapter = createStorageAdapterFromStore(store);
43350
43364
  const modelManager = new ModelManager(discoveryAdapter);
43351
43365
  const providerManager = new ProviderManager(providerRegistry, store);
43352
- const { ensureProvidersBootstrapped, getRoutstr21Models, getModelProviders } = createModelService(modelManager);
43366
+ const { ensureProvidersBootstrapped, getRoutstr21Models, getModelProviders } = createModelService(modelManager, store);
43353
43367
  const walletClient = createCocodClient({ cocodPath: config.cocodPath });
43354
43368
  const walletAdapter = await createWalletAdapter({
43355
43369
  cocodPath: config.cocodPath,
package/dist/index.js CHANGED
@@ -14456,17 +14456,20 @@ function renderRecent(stats, width) {
14456
14456
  const recentEntries = stats.entries.slice(0, 50);
14457
14457
  if (recentEntries.length === 0)
14458
14458
  return renderBox(["No recent entries"], width, "Recent Requests");
14459
+ const clientCol = 10;
14459
14460
  const lines = [];
14460
- lines.push(`${COLORS.bold}${"TIME".padEnd(10)} ${"MODEL".padEnd(18)} ${"TOKENS".padEnd(10)} ${"COST".padEnd(12)} ${"PROVIDER".slice(0, Math.max(0, width - 60))}${COLORS.reset}`);
14461
+ lines.push(`${COLORS.bold}${"TIME".padEnd(10)} ${"CLIENT".padEnd(clientCol)} ${"MODEL".padEnd(18)} ${"TOKENS".padEnd(10)} ${"COST".padEnd(12)} ${"PROVIDER".slice(0, Math.max(0, width - 70))}${COLORS.reset}`);
14461
14462
  lines.push(COLORS.dim + "\u2500".repeat(width - 4) + COLORS.reset);
14462
14463
  for (const entry of recentEntries) {
14463
14464
  const time = formatTime(entry.timestamp).slice(0, 8);
14465
+ const clientName = (entry.client || "unknown").slice(0, clientCol - 1).padEnd(clientCol);
14466
+ const clientColor = CLIENT_COLORS[entry.client || "unknown"] || CLIENT_COLORS.default || COLORS.white;
14464
14467
  const model = entry.modelId.slice(0, 18).padEnd(18);
14465
14468
  const tokens = `${formatNumber(entry.totalTokens).padEnd(6)} (${formatNumber(entry.promptTokens)}+${formatNumber(entry.completionTokens)})`;
14466
14469
  const cost = `${formatCost(entry.satsCost).padEnd(8)} sats`;
14467
- const provider = (entry.baseUrl || "unknown").replace("https://", "").replace("http://", "").slice(0, Math.max(0, width - 60));
14468
- const color = MODEL_COLORS[entry.modelId] || MODEL_COLORS.default;
14469
- lines.push(`${COLORS.dim}${time}${COLORS.reset} ${color}${model}${COLORS.reset} ${tokens.padEnd(10)} ${COLORS.green}${cost}${COLORS.reset} ${COLORS.dim}${provider}${COLORS.reset}`);
14470
+ const provider = (entry.baseUrl || "unknown").replace("https://", "").replace("http://", "").slice(0, Math.max(0, width - 70));
14471
+ const modelColor = MODEL_COLORS[entry.modelId] || MODEL_COLORS.default;
14472
+ lines.push(`${COLORS.dim}${time}${COLORS.reset} ${clientColor}${clientName}${COLORS.reset} ${modelColor}${model}${COLORS.reset} ${tokens.padEnd(10)} ${COLORS.green}${cost}${COLORS.reset} ${COLORS.dim}${provider}${COLORS.reset}`);
14470
14473
  }
14471
14474
  return renderBox(lines, width, `Recent Requests (${stats.entries.length} shown)`);
14472
14475
  }
@@ -15491,7 +15494,7 @@ async function isCocodInstalled(cocodPath) {
15491
15494
  // package.json
15492
15495
  var package_default = {
15493
15496
  name: "routstrd",
15494
- version: "0.2.16",
15497
+ version: "0.2.17",
15495
15498
  module: "src/index.ts",
15496
15499
  type: "module",
15497
15500
  private: false,
@@ -15515,7 +15518,7 @@ var package_default = {
15515
15518
  },
15516
15519
  dependencies: {
15517
15520
  "@cashu/cashu-ts": "^3.1.1",
15518
- "@routstr/sdk": "^0.3.2",
15521
+ "@routstr/sdk": "^0.3.3",
15519
15522
  "applesauce-core": "^5.1.0",
15520
15523
  "applesauce-relay": "^5.1.0",
15521
15524
  commander: "^14.0.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routstrd",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "private": false,
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@cashu/cashu-ts": "^3.1.1",
27
- "@routstr/sdk": "^0.3.2",
27
+ "@routstr/sdk": "^0.3.3",
28
28
  "applesauce-core": "^5.1.0",
29
29
  "applesauce-relay": "^5.1.0",
30
30
  "commander": "^14.0.2",
@@ -1,4 +1,4 @@
1
- import { ModelManager } from "@routstr/sdk";
1
+ import { ModelManager, type SdkStore } from "@routstr/sdk";
2
2
  import type { ExposedModel } from "./types";
3
3
  import { logger } from "../utils/logger";
4
4
 
@@ -16,7 +16,7 @@ export type ModelWithProviders = ExposedModel & {
16
16
  providers: ModelProviderInfo[];
17
17
  };
18
18
 
19
- export function createModelService(modelManager: ModelManager) {
19
+ export function createModelService(modelManager: ModelManager, store: SdkStore) {
20
20
  let providerBootstrapPromise: Promise<void> | null = null;
21
21
 
22
22
  const ensureProvidersBootstrapped = (): Promise<void> => {
@@ -26,6 +26,22 @@ export function createModelService(modelManager: ModelManager) {
26
26
  const providers = await modelManager.bootstrapProviders(false);
27
27
  logger.log(`Bootstrapped ${providers.length} providers`);
28
28
  await modelManager.fetchModels(providers);
29
+
30
+ // Sync discovered providers into the store so `providers list` reflects
31
+ // the same set that the model manager knows about.
32
+ const { baseUrlsList, setBaseUrlsList } = store.getState();
33
+ const existing = new Set(baseUrlsList);
34
+ const merged = [
35
+ ...baseUrlsList,
36
+ ...providers.filter((url) => !existing.has(url)),
37
+ ];
38
+ if (merged.length !== baseUrlsList.length) {
39
+ setBaseUrlsList(merged);
40
+ logger.log(
41
+ `Synced ${merged.length - baseUrlsList.length} new provider(s) into store`,
42
+ );
43
+ }
44
+
29
45
  logger.log("Provider bootstrap complete.");
30
46
  })().catch((error) => {
31
47
  logger.error("Provider bootstrap failed:", error);
@@ -511,18 +511,21 @@ export function renderRecent(stats: UsageStats, width: number): string {
511
511
  const recentEntries = stats.entries.slice(0, 50);
512
512
  if (recentEntries.length === 0) return renderBox(["No recent entries"], width, "Recent Requests");
513
513
 
514
+ const clientCol = 10;
514
515
  const lines: string[] = [];
515
- lines.push(`${COLORS.bold}${"TIME".padEnd(10)} ${"MODEL".padEnd(18)} ${"TOKENS".padEnd(10)} ${"COST".padEnd(12)} ${"PROVIDER".slice(0, Math.max(0, width - 60))}${COLORS.reset}`);
516
+ lines.push(`${COLORS.bold}${"TIME".padEnd(10)} ${"CLIENT".padEnd(clientCol)} ${"MODEL".padEnd(18)} ${"TOKENS".padEnd(10)} ${"COST".padEnd(12)} ${"PROVIDER".slice(0, Math.max(0, width - 70))}${COLORS.reset}`);
516
517
  lines.push(COLORS.dim + "─".repeat(width - 4) + COLORS.reset);
517
518
 
518
519
  for (const entry of recentEntries) {
519
520
  const time = formatTime(entry.timestamp).slice(0, 8);
521
+ const clientName = (entry.client || "unknown").slice(0, clientCol - 1).padEnd(clientCol);
522
+ const clientColor = CLIENT_COLORS[entry.client || "unknown"] || CLIENT_COLORS.default || COLORS.white;
520
523
  const model = entry.modelId.slice(0, 18).padEnd(18);
521
524
  const tokens = `${formatNumber(entry.totalTokens).padEnd(6)} (${formatNumber(entry.promptTokens)}+${formatNumber(entry.completionTokens)})`;
522
525
  const cost = `${formatCost(entry.satsCost).padEnd(8)} sats`;
523
- const provider = (entry.baseUrl || "unknown").replace("https://", "").replace("http://", "").slice(0, Math.max(0, width - 60));
524
- const color = MODEL_COLORS[entry.modelId] || MODEL_COLORS.default;
525
- lines.push(`${COLORS.dim}${time}${COLORS.reset} ${color}${model}${COLORS.reset} ${tokens.padEnd(10)} ${COLORS.green}${cost}${COLORS.reset} ${COLORS.dim}${provider}${COLORS.reset}`);
526
+ const provider = (entry.baseUrl || "unknown").replace("https://", "").replace("http://", "").slice(0, Math.max(0, width - 70));
527
+ const modelColor = MODEL_COLORS[entry.modelId] || MODEL_COLORS.default;
528
+ lines.push(`${COLORS.dim}${time}${COLORS.reset} ${clientColor}${clientName}${COLORS.reset} ${modelColor}${model}${COLORS.reset} ${tokens.padEnd(10)} ${COLORS.green}${cost}${COLORS.reset} ${COLORS.dim}${provider}${COLORS.reset}`);
526
529
  }
527
530
 
528
531
  return renderBox(lines, width, `Recent Requests (${stats.entries.length} shown)`);