@tempoxyz/patron 0.0.31 → 0.0.32
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/bin.js
CHANGED
|
@@ -12,14 +12,14 @@ if (!process.env.PATRON_HOME) {
|
|
|
12
12
|
if (home) process.env.PATRON_HOME = home;
|
|
13
13
|
}
|
|
14
14
|
if (process.argv[2] === "hook") {
|
|
15
|
-
const { runHookProcess } = await import("./chunks/hook-process-
|
|
15
|
+
const { runHookProcess } = await import("./chunks/hook-process-Y3K3FTXH.js");
|
|
16
16
|
await runHookProcess().catch(() => void 0);
|
|
17
17
|
process.exit(0);
|
|
18
18
|
} else if (process.argv[2] === "pay") {
|
|
19
|
-
const { runPayProcess } = await import("./chunks/hook-process-
|
|
19
|
+
const { runPayProcess } = await import("./chunks/hook-process-Y3K3FTXH.js");
|
|
20
20
|
await runPayProcess().catch(() => void 0);
|
|
21
21
|
process.exit(0);
|
|
22
22
|
} else {
|
|
23
|
-
const { run } = await import("./chunks/-
|
|
23
|
+
const { run } = await import("./chunks/-ZBR7H4YK.js");
|
|
24
24
|
process.exitCode = await run(process.argv.slice(2));
|
|
25
25
|
}
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
awaitRedemptions,
|
|
37
37
|
gatewayTurn,
|
|
38
38
|
startRefill
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-D3IY3ICC.js";
|
|
40
40
|
import {
|
|
41
41
|
inferHome,
|
|
42
42
|
resolveSettings,
|
|
@@ -1430,7 +1430,7 @@ async function changeBudget(deps, input) {
|
|
|
1430
1430
|
output: deps.stdout
|
|
1431
1431
|
});
|
|
1432
1432
|
}
|
|
1433
|
-
await
|
|
1433
|
+
await updateConfigField(settings.home, { monthlyBudgetUsd: budget });
|
|
1434
1434
|
done(deps, `Monthly budget set to $${twoDecimals(String(budget))}.`);
|
|
1435
1435
|
}
|
|
1436
1436
|
async function changePerPage(deps, input) {
|
|
@@ -1624,9 +1624,14 @@ async function setName(deps, name) {
|
|
|
1624
1624
|
deps,
|
|
1625
1625
|
() => setProfile(settings.gatewayUrl, wallet, name, deps.fetch)
|
|
1626
1626
|
);
|
|
1627
|
-
await
|
|
1627
|
+
await updateConfigField(settings.home, { name });
|
|
1628
1628
|
done(deps, `Leaderboard name set to ${name}.`);
|
|
1629
1629
|
}
|
|
1630
|
+
async function updateConfigField(home, fields) {
|
|
1631
|
+
const current = await readConfig(home);
|
|
1632
|
+
if (!current) throw new Error("Patron is not set up. Run npx @tempoxyz/patron.");
|
|
1633
|
+
await writeConfig(home, { ...current, ...fields });
|
|
1634
|
+
}
|
|
1630
1635
|
async function uninstall(deps) {
|
|
1631
1636
|
const config = await readConfig(deps.settings.home);
|
|
1632
1637
|
const removed = await removeAgents(deps.agents);
|
|
@@ -21,7 +21,9 @@ function startRefill(options = {}, script = process.argv[1]) {
|
|
|
21
21
|
const child = spawn(command, args, {
|
|
22
22
|
detached: true,
|
|
23
23
|
env: process.env,
|
|
24
|
-
stdio: "ignore"
|
|
24
|
+
stdio: "ignore",
|
|
25
|
+
// On Windows a detached cmd has no console, so its npx child would open a visible one.
|
|
26
|
+
windowsHide: true
|
|
25
27
|
});
|
|
26
28
|
child.on("error", () => void 0);
|
|
27
29
|
child.unref();
|
|
@@ -151,6 +153,7 @@ function claimGateway(home, now, random = Math.random, want = true) {
|
|
|
151
153
|
}
|
|
152
154
|
var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
153
155
|
var RECHECK_MS = 6e4;
|
|
156
|
+
var CANCEL_CHECK_MS = 2e3;
|
|
154
157
|
async function gatewayTurn(home, fn, options = {}) {
|
|
155
158
|
const sleep = options.sleep ?? defaultSleep;
|
|
156
159
|
let waited = 0;
|
|
@@ -166,9 +169,14 @@ async function gatewayTurn(home, fn, options = {}) {
|
|
|
166
169
|
}
|
|
167
170
|
if (waited + claim > (options.maxWaitMs ?? Number.POSITIVE_INFINITY)) return void 0;
|
|
168
171
|
if (waited === 0) options.onWait?.(claim);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
let remaining = claim + 1e3;
|
|
173
|
+
while (remaining > 0) {
|
|
174
|
+
if (options.cancelled?.()) return void 0;
|
|
175
|
+
const step = Math.min(remaining, CANCEL_CHECK_MS);
|
|
176
|
+
await sleep(step);
|
|
177
|
+
waited += step;
|
|
178
|
+
remaining -= step;
|
|
179
|
+
}
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
async function awaitRedemptions(home, leaseMs, options = {}) {
|