routstrd 0.3.7 → 0.3.9
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/bun.lock +2 -2
- package/dist/daemon/index.js +51 -40
- package/dist/index.js +8 -5
- package/package.json +2 -2
- package/src/start-daemon.ts +6 -2
package/bun.lock
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "routstrd",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@cashu/cashu-ts": "^4.3.0",
|
|
8
|
-
"@routstr/sdk": "^0.3.
|
|
8
|
+
"@routstr/sdk": "^0.3.16",
|
|
9
9
|
"applesauce-core": "^5.1.0",
|
|
10
10
|
"applesauce-relay": "^5.1.0",
|
|
11
11
|
"applesauce-wallet-connect": "^6.0.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
"@panva/hpke-noble": ["@panva/hpke-noble@1.1.2", "", { "dependencies": { "@noble/ciphers": "^2.2.0", "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", "@noble/post-quantum": "^0.6.1" }, "peerDependencies": { "hpke": "^1.0.0" } }, "sha512-Gr/jKr/ErpRow8aHK+SAp0sAaWy7iJGHlFsXsdTjD8ULcN4vvsVVWR3fiD6Ogf+VoSB28XY/xWRDUEIGXw+9aA=="],
|
|
89
89
|
|
|
90
|
-
"@routstr/sdk": ["@routstr/sdk@0.3.
|
|
90
|
+
"@routstr/sdk": ["@routstr/sdk@0.3.16", "", { "dependencies": { "@cashu/cashu-ts": "^3.1.1", "applesauce-core": "^5.1.0", "applesauce-relay": "^5.1.0", "applesauce-sqlite": "^6.0.0", "ehbp": "^0.2.3", "rxjs": "^7.8.1", "tinfoil": "^1.1.6", "zustand": "^5.0.5" }, "optionalDependencies": { "better-sqlite3": "^12.10.0" }, "peerDependencies": { "typescript": ">=5.0.0" } }, "sha512-c5DMRcixvs4fghdYvikBAB+xQ4C9BPg71PRsPn8ZJ+ZxBgr9v5Xm1TXHauB/SpgmowccamXJ5Hd0rB9Ke5MsCw=="],
|
|
91
91
|
|
|
92
92
|
"@scure/base": ["@scure/base@2.2.0", "", {}, "sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg=="],
|
|
93
93
|
|
package/dist/daemon/index.js
CHANGED
|
@@ -105450,6 +105450,7 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
105450
105450
|
|
|
105451
105451
|
// src/start-daemon.ts
|
|
105452
105452
|
var DAEMON_STARTUP_LOCK_PATH = `${CONFIG_DIR}/routstrd-startup.lock`;
|
|
105453
|
+
var DEBUG_LOG_PATH = `${CONFIG_DIR}/debug.log`;
|
|
105453
105454
|
|
|
105454
105455
|
// node_modules/nostr-tools/node_modules/@noble/hashes/utils.js
|
|
105455
105456
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -114472,6 +114473,12 @@ function makeSdkLogger2(prefix) {
|
|
|
114472
114473
|
};
|
|
114473
114474
|
}
|
|
114474
114475
|
var daemonSdkLogger = makeSdkLogger2();
|
|
114476
|
+
process.on("uncaughtException", (error53) => {
|
|
114477
|
+
logger5.error("UNCAUGHT EXCEPTION:", error53);
|
|
114478
|
+
});
|
|
114479
|
+
process.on("unhandledRejection", (reason) => {
|
|
114480
|
+
logger5.error("UNHANDLED REJECTION:", reason);
|
|
114481
|
+
});
|
|
114475
114482
|
async function main() {
|
|
114476
114483
|
const args = parseArgs(process.argv);
|
|
114477
114484
|
const config2 = await loadDaemonConfig();
|
|
@@ -114552,19 +114559,21 @@ async function main() {
|
|
|
114552
114559
|
let refreshInterval = null;
|
|
114553
114560
|
const startModelRefreshJob = () => {
|
|
114554
114561
|
logger5.log(`Starting recurring model refresh job (every ${REFRESH_INTERVAL_MS / 1000 / 60 / 60} hours)`);
|
|
114555
|
-
refreshInterval = setInterval(
|
|
114556
|
-
|
|
114557
|
-
|
|
114558
|
-
|
|
114559
|
-
|
|
114560
|
-
|
|
114561
|
-
|
|
114562
|
-
|
|
114563
|
-
|
|
114564
|
-
|
|
114565
|
-
|
|
114566
|
-
|
|
114567
|
-
|
|
114562
|
+
refreshInterval = setInterval(() => {
|
|
114563
|
+
(async () => {
|
|
114564
|
+
logger5.log("Running scheduled Nostr event refresh...");
|
|
114565
|
+
try {
|
|
114566
|
+
await modelManager.refreshNostrEvents();
|
|
114567
|
+
} catch (error53) {
|
|
114568
|
+
logger5.error("Scheduled Nostr event refresh failed:", error53);
|
|
114569
|
+
}
|
|
114570
|
+
logger5.log("Running scheduled model refresh...");
|
|
114571
|
+
try {
|
|
114572
|
+
await refreshModelsAndIntegrations(getRoutstr21Models, updatedConfig, "Scheduled");
|
|
114573
|
+
} catch (error53) {
|
|
114574
|
+
logger5.error("Scheduled model refresh failed:", error53);
|
|
114575
|
+
}
|
|
114576
|
+
})().catch((error53) => logger5.error("Model refresh interval escaped:", error53));
|
|
114568
114577
|
}, REFRESH_INTERVAL_MS);
|
|
114569
114578
|
};
|
|
114570
114579
|
const stopModelRefreshJob = () => {
|
|
@@ -114578,34 +114587,36 @@ async function main() {
|
|
|
114578
114587
|
let refundInterval = null;
|
|
114579
114588
|
const startRefundJob = async () => {
|
|
114580
114589
|
logger5.log(`Starting recurring refund job (every ${REFUND_INTERVAL_MS / 1000 / 60} minutes)`);
|
|
114581
|
-
refundInterval = setInterval(
|
|
114582
|
-
|
|
114583
|
-
|
|
114584
|
-
|
|
114585
|
-
|
|
114586
|
-
|
|
114587
|
-
|
|
114588
|
-
|
|
114589
|
-
|
|
114590
|
-
|
|
114591
|
-
|
|
114592
|
-
|
|
114593
|
-
|
|
114594
|
-
|
|
114595
|
-
|
|
114596
|
-
|
|
114597
|
-
|
|
114598
|
-
|
|
114599
|
-
|
|
114600
|
-
|
|
114590
|
+
refundInterval = setInterval(() => {
|
|
114591
|
+
(async () => {
|
|
114592
|
+
logger5.log("Running scheduled refund...");
|
|
114593
|
+
try {
|
|
114594
|
+
const state = store.getState();
|
|
114595
|
+
const pendingDistribution = (state.cachedTokens || []).map((t) => ({
|
|
114596
|
+
baseUrl: t.baseUrl,
|
|
114597
|
+
amount: t.balance || 0
|
|
114598
|
+
}));
|
|
114599
|
+
const apiKeysStored = (state.apiKeys || []).map((k3) => ({
|
|
114600
|
+
baseUrl: k3.baseUrl,
|
|
114601
|
+
amount: k3.balance || 0
|
|
114602
|
+
}));
|
|
114603
|
+
if (pendingDistribution.length === 0 && apiKeysStored.length === 0) {
|
|
114604
|
+
logger5.log("No pending tokens to refund.");
|
|
114605
|
+
return;
|
|
114606
|
+
}
|
|
114607
|
+
const mintUrl = walletAdapter.getActiveMintUrl();
|
|
114608
|
+
if (!mintUrl) {
|
|
114609
|
+
logger5.log("No active mint URL for refund.");
|
|
114610
|
+
return;
|
|
114611
|
+
}
|
|
114612
|
+
const spender = refundClient.getCashuSpender();
|
|
114613
|
+
const results = await spender.refundProviders(mintUrl);
|
|
114614
|
+
const successCount = results.filter((r) => r.success).length;
|
|
114615
|
+
logger5.log(`Scheduled refund completed: ${successCount}/${results.length} providers refunded.`);
|
|
114616
|
+
} catch (error53) {
|
|
114617
|
+
logger5.error("Scheduled refund failed:", error53);
|
|
114601
114618
|
}
|
|
114602
|
-
|
|
114603
|
-
const results = await spender.refundProviders(mintUrl);
|
|
114604
|
-
const successCount = results.filter((r) => r.success).length;
|
|
114605
|
-
logger5.log(`Scheduled refund completed: ${successCount}/${results.length} providers refunded.`);
|
|
114606
|
-
} catch (error53) {
|
|
114607
|
-
logger5.error("Scheduled refund failed:", error53);
|
|
114608
|
-
}
|
|
114619
|
+
})().catch((error53) => logger5.error("Refund interval escaped:", error53));
|
|
114609
114620
|
}, REFUND_INTERVAL_MS);
|
|
114610
114621
|
};
|
|
114611
114622
|
const stopRefundJob = () => {
|
package/dist/index.js
CHANGED
|
@@ -2301,6 +2301,7 @@ async function withCrossProcessLock(lockDir, fn, options = {}) {
|
|
|
2301
2301
|
var init_process_lock = () => {};
|
|
2302
2302
|
|
|
2303
2303
|
// src/start-daemon.ts
|
|
2304
|
+
import { openSync } from "fs";
|
|
2304
2305
|
async function isDaemonHealthy(port) {
|
|
2305
2306
|
const controller = new AbortController;
|
|
2306
2307
|
const timeoutId = setTimeout(() => controller.abort(), 2000);
|
|
@@ -2332,9 +2333,10 @@ async function startDaemonUnlocked(options) {
|
|
|
2332
2333
|
}
|
|
2333
2334
|
const daemonScript = new URL("./daemon/index.js", import.meta.url).pathname;
|
|
2334
2335
|
const shellCmd = `bun run "${daemonScript}" ${args.map((a) => `'${a}'`).join(" ")}`;
|
|
2336
|
+
const debugLogFd = openSync(DEBUG_LOG_PATH, "a");
|
|
2335
2337
|
const proc = Bun.spawn(["sh", "-c", shellCmd], {
|
|
2336
|
-
stdout:
|
|
2337
|
-
stderr:
|
|
2338
|
+
stdout: debugLogFd,
|
|
2339
|
+
stderr: debugLogFd,
|
|
2338
2340
|
stdin: "ignore",
|
|
2339
2341
|
detached: true
|
|
2340
2342
|
});
|
|
@@ -2371,12 +2373,13 @@ async function startDaemon(options = {}) {
|
|
|
2371
2373
|
log: (message) => logger.debug(message)
|
|
2372
2374
|
});
|
|
2373
2375
|
}
|
|
2374
|
-
var DAEMON_STARTUP_LOCK_PATH;
|
|
2376
|
+
var DAEMON_STARTUP_LOCK_PATH, DEBUG_LOG_PATH;
|
|
2375
2377
|
var init_start_daemon = __esm(() => {
|
|
2376
2378
|
init_logger();
|
|
2377
2379
|
init_config();
|
|
2378
2380
|
init_process_lock();
|
|
2379
2381
|
DAEMON_STARTUP_LOCK_PATH = `${CONFIG_DIR}/routstrd-startup.lock`;
|
|
2382
|
+
DEBUG_LOG_PATH = `${CONFIG_DIR}/debug.log`;
|
|
2380
2383
|
});
|
|
2381
2384
|
|
|
2382
2385
|
// node_modules/nostr-tools/node_modules/@noble/hashes/utils.js
|
|
@@ -15596,7 +15599,7 @@ async function isCocodInstalled(cocodPath) {
|
|
|
15596
15599
|
// package.json
|
|
15597
15600
|
var package_default = {
|
|
15598
15601
|
name: "routstrd",
|
|
15599
|
-
version: "0.3.
|
|
15602
|
+
version: "0.3.9",
|
|
15600
15603
|
module: "src/index.ts",
|
|
15601
15604
|
type: "module",
|
|
15602
15605
|
private: false,
|
|
@@ -15620,7 +15623,7 @@ var package_default = {
|
|
|
15620
15623
|
},
|
|
15621
15624
|
dependencies: {
|
|
15622
15625
|
"@cashu/cashu-ts": "^4.3.0",
|
|
15623
|
-
"@routstr/sdk": "^0.3.
|
|
15626
|
+
"@routstr/sdk": "^0.3.16",
|
|
15624
15627
|
"applesauce-core": "^5.1.0",
|
|
15625
15628
|
"applesauce-relay": "^5.1.0",
|
|
15626
15629
|
"applesauce-wallet-connect": "^6.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "routstrd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
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": "^4.3.0",
|
|
27
|
-
"@routstr/sdk": "^0.3.
|
|
27
|
+
"@routstr/sdk": "^0.3.16",
|
|
28
28
|
"applesauce-core": "^5.1.0",
|
|
29
29
|
"applesauce-relay": "^5.1.0",
|
|
30
30
|
"applesauce-wallet-connect": "^6.0.0",
|
package/src/start-daemon.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { openSync } from "fs";
|
|
1
2
|
import { logger } from "./utils/logger";
|
|
2
3
|
import { CONFIG_DIR, LOGS_DIR } from "./utils/config";
|
|
3
4
|
import { withCrossProcessLock } from "./utils/process-lock";
|
|
4
5
|
|
|
5
6
|
const DAEMON_STARTUP_LOCK_PATH = `${CONFIG_DIR}/routstrd-startup.lock`;
|
|
7
|
+
const DEBUG_LOG_PATH = `${CONFIG_DIR}/debug.log`;
|
|
6
8
|
|
|
7
9
|
async function isDaemonHealthy(port: string): Promise<boolean> {
|
|
8
10
|
const controller = new AbortController();
|
|
@@ -42,9 +44,11 @@ async function startDaemonUnlocked(
|
|
|
42
44
|
const daemonScript = new URL("./daemon/index.js", import.meta.url).pathname;
|
|
43
45
|
const shellCmd = `bun run "${daemonScript}" ${args.map((a) => `'${a}'`).join(" ")}`;
|
|
44
46
|
|
|
47
|
+
const debugLogFd = openSync(DEBUG_LOG_PATH, "a");
|
|
48
|
+
|
|
45
49
|
const proc = Bun.spawn(["sh", "-c", shellCmd], {
|
|
46
|
-
stdout:
|
|
47
|
-
stderr:
|
|
50
|
+
stdout: debugLogFd,
|
|
51
|
+
stderr: debugLogFd,
|
|
48
52
|
stdin: "ignore",
|
|
49
53
|
detached: true,
|
|
50
54
|
});
|