@dvmkit/dvm-cli 0.1.4 → 0.2.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.
Files changed (60) hide show
  1. package/README.md +14 -0
  2. package/dist/{_esm-M2HUAA3B.js → _esm-MN4BUYV6.js} +56 -54
  3. package/dist/{accounts-S747UW3A.js → accounts-2WZE4N5F.js} +5 -5
  4. package/dist/actions-LR65XILR.js +244 -0
  5. package/dist/{ccip-XZ5F5J6R.js → ccip-JXYJSXTW.js} +3 -3
  6. package/dist/{chains-PINFXYUE.js → chains-LJ7XK6H3.js} +8 -8
  7. package/dist/{chunk-YZUBKHHA.js → chunk-2VVVWBQA.js} +471 -471
  8. package/dist/chunk-3SWX5BQP.js +66 -0
  9. package/dist/chunk-4JXFXP4Y.js +757 -0
  10. package/dist/{chunk-GIDSTROG.js → chunk-4NWEJTAW.js} +160 -158
  11. package/dist/{chunk-UXQCP26E.js → chunk-65EY7CT4.js} +2 -2
  12. package/dist/{chunk-6UGZAFIR.js → chunk-6CC6JGEU.js} +348 -18
  13. package/dist/{chunk-PHZHPRQE.js → chunk-6O27TEXD.js} +173 -173
  14. package/dist/{chunk-HPRIQEJS.js → chunk-7OK7MBT6.js} +19 -19
  15. package/dist/{chunk-7UPZZGC5.js → chunk-BECPI5H5.js} +193 -193
  16. package/dist/chunk-CJTE5TS3.js +1298 -0
  17. package/dist/{chunk-RWBYCM47.js → chunk-ECEM3ZAS.js} +10 -10
  18. package/dist/{chunk-ACNNU5RY.js → chunk-ECK465AY.js} +694 -565
  19. package/dist/{chunk-XGABM4H5.js → chunk-EGY4KDBW.js} +3822 -2012
  20. package/dist/{chunk-SLDVIXCS.js → chunk-EVQERRCP.js} +12 -12
  21. package/dist/{chunk-4AQ4G7L5.js → chunk-EZHT2RLJ.js} +383 -383
  22. package/dist/{chunk-IC6OXFYW.js → chunk-F55NNH2F.js} +63 -63
  23. package/dist/chunk-G5C6E6PJ.js +9063 -0
  24. package/dist/{chunk-6AJ7H2VX.js → chunk-GZWKCIYN.js} +213 -1281
  25. package/dist/{chunk-ZGXCK43G.js → chunk-LH3QPVN6.js} +8499 -8498
  26. package/dist/{chunk-MMJR6N3J.js → chunk-MLDUKBU3.js} +1368 -1368
  27. package/dist/chunk-N3UJT2NJ.js +3 -0
  28. package/dist/chunk-N7MGIK2U.js +61408 -0
  29. package/dist/{chunk-BZNZWRBB.js → chunk-OWJZYYMG.js} +11 -15
  30. package/dist/chunk-ZJYO7OLO.js +514 -0
  31. package/dist/{client-D3XFLWOK.js → client-OWIOFBKS.js} +18 -16
  32. package/dist/{dist-7MMV3EZA.js → dist-2G3QBGID.js} +11 -10
  33. package/dist/dvm.js +27046 -4414
  34. package/dist/esm-RQLHAH2K.js +5183 -0
  35. package/dist/internal-JDG52DJH.js +1230 -0
  36. package/dist/payout-reporter-3UB5WRCV-XTVZFIAO.js +17 -0
  37. package/dist/{pocket-refill-GDYSTECR.js → pocket-refill-QJMMD6QN.js} +29 -30
  38. package/dist/revenue-reporter-JIKUPXOK-TYUBTF4P.js +11 -0
  39. package/dist/{secp256k1-4YWQEMGF.js → secp256k1-JLZEQ2H7.js} +2 -2
  40. package/dist/tempo-lifecycle-SQL3KLEZ-AATA2SKI.js +28 -0
  41. package/dist/{tempo-wallet-5FEOI4CF.js → tempo-wallet-QOLEIPCV-SWCXRBDS.js} +2 -4
  42. package/dist/{x402-VNFA3DBY.js → x402-FTG2GRAQ-UGAUMUL6.js} +13 -24
  43. package/package.json +2 -10
  44. package/skills/dvm/SKILL.md +2 -1
  45. package/dist/channel-store-GOV7TEDN.js +0 -62
  46. package/dist/chunk-3PPOU55E.js +0 -312
  47. package/dist/chunk-3TBULV3F.js +0 -551
  48. package/dist/chunk-5BUV73FO.js +0 -2351
  49. package/dist/chunk-EY5K4BM3.js +0 -1780
  50. package/dist/chunk-G3RLVJF5.js +0 -19
  51. package/dist/chunk-KC4UPK44.js +0 -113
  52. package/dist/chunk-MTBCEXJ6.js +0 -4602
  53. package/dist/chunk-ONQMRWY3.js +0 -83
  54. package/dist/chunk-TO47XRK7.js +0 -24890
  55. package/dist/chunk-U5TNSUYW.js +0 -1757
  56. package/dist/chunk-UU6QMSTQ.js +0 -171
  57. package/dist/chunk-ZELLQI7F.js +0 -248
  58. package/dist/lifecycle-5RLM5JMN.js +0 -29
  59. package/dist/tempo-lifecycle-DHZPQTSB.js +0 -31
  60. package/dist/wallet-G3VOUCL4.js +0 -30
@@ -1,171 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __dvmCreateRequire } from "node:module";
3
- const require = __dvmCreateRequire(import.meta.url);
4
- import {
5
- findSigningIdentityByPubkey,
6
- listTempoChannelAssociations,
7
- loadTempoChannelController,
8
- reconcileTempoChannelOnChain,
9
- shellQuoteArg,
10
- tempoChannelControlledBy
11
- } from "./chunk-ACNNU5RY.js";
12
- import {
13
- connectedTempoAccount
14
- } from "./chunk-BZNZWRBB.js";
15
- import {
16
- formatUsdcMicrounits
17
- } from "./chunk-ZELLQI7F.js";
18
- import {
19
- DvmError
20
- } from "./chunk-U5TNSUYW.js";
21
-
22
- // src/lib/payment-rails/tempo-lifecycle.ts
23
- async function assertTempoWalletIdle(intent) {
24
- const connected = await connectedTempoAccount();
25
- if (!connected) return;
26
- const records = await ownedTempoChannelRecords(connected.address);
27
- const verdicts = await Promise.all(
28
- records.map(async (association) => ({
29
- association,
30
- chain: await reconcileTempoChannelOnChain({ association })
31
- }))
32
- );
33
- let blocker;
34
- for (const status of BLOCKING_ORDER) {
35
- blocker = verdicts.find((verdict) => verdict.chain.status === status);
36
- if (blocker) break;
37
- }
38
- if (!blocker) return;
39
- const blocking = verdicts.filter((verdict) => verdict.chain.status !== "closed").length;
40
- throw blocker.chain.status === "unreadable" ? blocker.chain.error?.code === "tempo_channel_not_found" ? descriptorlessChannelError(blocker.association, blocker.chain, intent, blocking) : unreadableChainError(blocker.association, blocker.chain, intent, blocking) : liveChannelError(blocker.association, blocker.chain, intent, blocking);
41
- }
42
- async function ownedTempoChannelRecords(address) {
43
- const records = listTempoChannelAssociations();
44
- const controlled = await Promise.all(
45
- records.map(
46
- async (association) => tempoChannelControlledBy(
47
- await loadTempoChannelController(association).catch(() => void 0),
48
- address
49
- )
50
- )
51
- );
52
- return records.filter((_, index) => controlled[index]);
53
- }
54
- var BLOCKING_ORDER = ["open", "closing", "unconfirmed", "unreadable"];
55
- function liveChannelError(association, chain, intent, blocking) {
56
- const depositMicro = chain.status === "unconfirmed" ? Number(association.deposit) : chain.depositMicro;
57
- const amount = `$${formatUsdcMicrounits(BigInt(depositMicro))}`;
58
- const message = chain.status === "open" ? `The connected Tempo key still holds ${amount} of collateral in an open channel with ${association.endpoint}.` : chain.status === "closing" ? `The connected Tempo key has ${amount} still escrowed on its channel with ${association.endpoint}, where a close has been requested on-chain and is in its 15-minute grace period.` : `The connected Tempo key signed an open committing ${amount} to a channel with ${association.endpoint} that the escrow has no record of, so that collateral may or may not be locked.`;
59
- const caller = findSigningIdentityByPubkey(association.callerPubkey);
60
- if (!caller) {
61
- return new DvmError(
62
- "tempo_channels_active",
63
- message,
64
- `Only this key can close that channel, but its caller identity (${association.callerPubkey}) is no longer configured. Restore that identity first, then retry the wallet ${intent === "replace" ? "replacement" : "disconnect"}; the key and channel record were left untouched.${remainingClause(blocking)}`,
65
- channelData(association, chain, depositMicro, blocking)
66
- );
67
- }
68
- const identityName = caller.source.kind === "env" ? void 0 : caller.source.name;
69
- const selectors = { creditId: association.creditId, identityName };
70
- const exit = tempoExitCommand(association.endpoint, selectors);
71
- const abandon = tempoExitCommand(association.endpoint, selectors, true);
72
- const fund = creditCommand("fund", association.endpoint, selectors);
73
- const remedy = chain.status === "open" ? (
74
- // The endpoint can hold several credits and caller identities. Both
75
- // selectors keep every remedy pointed at the channel just named.
76
- `Empty the channel first \u2014 '${creditCommand("drain", association.endpoint, selectors)}' for the cooperative exit, or '${exit}' if the DVM is unavailable`
77
- ) : chain.status === "closing" ? `'${exit}' withdraws what remains once the grace period ends` : `'${exit}' reads the chain and says which it is, and '${fund}' resumes a funding still pending for it. Once that open is known never to have landed, '${abandon}' retires the record`;
78
- return new DvmError(
79
- "tempo_channels_active",
80
- message,
81
- `Only this key can close that channel. ${remedy} \u2014 and ${intentClause(intent)}.${remainingClause(blocking)}`,
82
- channelData(association, chain, depositMicro, blocking)
83
- );
84
- }
85
- function tempoExitCommand(endpoint, selectors, abandon = false) {
86
- const parts = [
87
- "dvm wallet tempo-exit",
88
- shellQuoteArg(endpoint),
89
- "--credit-id",
90
- shellQuoteArg(selectors.creditId)
91
- ];
92
- if (selectors.identityName !== void 0) {
93
- parts.push("--as", shellQuoteArg(selectors.identityName));
94
- }
95
- if (abandon) parts.push("--abandon");
96
- return parts.join(" ");
97
- }
98
- function creditCommand(verb, endpoint, selectors) {
99
- const parts = [
100
- `dvm credit ${verb}`,
101
- shellQuoteArg(endpoint),
102
- "--credit-id",
103
- shellQuoteArg(selectors.creditId)
104
- ];
105
- if (selectors.identityName !== void 0) {
106
- parts.push("--as", shellQuoteArg(selectors.identityName));
107
- }
108
- return parts.join(" ");
109
- }
110
- function unreadableChainError(association, chain, intent, blocking) {
111
- const cause = chain.error;
112
- return new DvmError(
113
- cause?.code ?? "tempo_chain_read_failed",
114
- `The Tempo channel with ${association.endpoint} could not be read, so there is no way to show it is empty: ${cause?.message ?? "the chain read failed"}`,
115
- `The Tempo key is untouched, and the local channel record was kept \u2014 it is the only route back to any collateral the escrow does hold. ${cause?.hint ? `${cause.hint} Then ${intentClause(intent)}.` : `Restore the chain read, then ${intentClause(intent)}.`}${remainingClause(blocking)}`,
116
- channelData(association, chain, Number(association.deposit), blocking)
117
- );
118
- }
119
- function descriptorlessChannelError(association, chain, intent, blocking) {
120
- const message = `The saved Tempo channel with ${association.endpoint} has no stored descriptor, so its escrow state cannot be read or closed from this machine.`;
121
- const data = {
122
- ...channelData(association, chain, Number(association.deposit), blocking),
123
- anchor: "tempo_channel_descriptor_missing"
124
- };
125
- const caller = findSigningIdentityByPubkey(association.callerPubkey);
126
- if (!caller) {
127
- return new DvmError(
128
- "tempo_channel_not_found",
129
- message,
130
- `The caller identity that owns this record (${association.callerPubkey}) is no longer configured. Restore that identity first, then retire the descriptor-less record; the Tempo key and record were left untouched.${remainingClause(blocking)}`,
131
- data
132
- );
133
- }
134
- const identityName = caller.source.kind === "env" ? void 0 : caller.source.name;
135
- const abandon = tempoExitCommand(
136
- association.endpoint,
137
- { creditId: association.creditId, identityName },
138
- true
139
- );
140
- return new DvmError(
141
- "tempo_channel_not_found",
142
- message,
143
- `Run '${abandon}' to retire this unusable local record without broadcasting anything, then ${intentClause(intent)}.${remainingClause(blocking)}`,
144
- data
145
- );
146
- }
147
- function channelData(association, chain, depositMicro, blocking) {
148
- return {
149
- anchor: "tempo_channel_live",
150
- endpoint: association.endpoint,
151
- credit_id: association.creditId,
152
- channel_id: association.channelId,
153
- chain_id: association.chainId,
154
- chain_status: chain.status,
155
- deposit_micro: depositMicro,
156
- ...chain.status === "unreadable" ? {} : { settled_micro: chain.settledMicro },
157
- // How many records are still in the way, so an agent knows whether clearing
158
- // the one named above is the whole job.
159
- blocking_channels: blocking
160
- };
161
- }
162
- function remainingClause(blocking) {
163
- return blocking > 1 ? ` ${blocking - 1} other recorded channel${blocking > 2 ? "s" : ""} still ${blocking > 2 ? "block" : "blocks"} this too \u2014 'dvm wallet balance' lists them all with what the escrow says about each.` : "";
164
- }
165
- function intentClause(intent) {
166
- return intent === "replace" ? "retry the replacement" : "retry 'dvm wallet tempo-disconnect'";
167
- }
168
-
169
- export {
170
- assertTempoWalletIdle
171
- };
@@ -1,248 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __dvmCreateRequire } from "node:module";
3
- const require = __dvmCreateRequire(import.meta.url);
4
- import {
5
- BTC_RATE_FILE,
6
- ensureConfigSubdir
7
- } from "./chunk-U5TNSUYW.js";
8
-
9
- // src/lib/currency.ts
10
- import { existsSync, readFileSync, writeFileSync } from "fs";
11
- import { dirname } from "path";
12
-
13
- // src/sdk/pricing/usd.ts
14
- function formatFiat(amount, currency) {
15
- const code = currency.toUpperCase();
16
- const symbol = FIAT_SYMBOLS[currency] ?? "";
17
- const digits = currency === "jpy" ? 0 : amount >= 0.01 || amount === 0 ? 2 : 4;
18
- const body = `${amount.toFixed(digits)} ${code}`;
19
- return symbol ? `${symbol}${body}` : body;
20
- }
21
- var FIAT_SYMBOLS = {
22
- usd: "$",
23
- eur: "\u20AC",
24
- gbp: "\xA3",
25
- jpy: "\xA5"
26
- };
27
-
28
- // src/lib/fx-coingecko.ts
29
- var COINGECKO_SIMPLE_PRICE_URL = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,usd-coin&vs_currencies=usd";
30
- var COINGECKO_BTC_USD_URL = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd";
31
- var DEFAULT_TIMEOUT_MS = 5e3;
32
- var DEFAULT_USER_AGENT = "dvmkit-platform/1.0 (+https://dvmkit.com)";
33
- async function fetchCoinGeckoSpot(opts) {
34
- const body = await fetchCoinGeckoBody(opts, COINGECKO_SIMPLE_PRICE_URL);
35
- const btc = body.bitcoin?.usd;
36
- const usdc = body["usd-coin"]?.usd;
37
- if (!isPositiveNumber(btc)) {
38
- throw new Error("coingecko response missing bitcoin.usd");
39
- }
40
- if (!isPositiveNumber(usdc)) {
41
- throw new Error("coingecko response missing usd-coin.usd");
42
- }
43
- return { btc_usd: btc, usdc_usd: usdc, as_of: (/* @__PURE__ */ new Date()).toISOString() };
44
- }
45
- async function fetchCoinGeckoBtcUsd(opts) {
46
- const body = await fetchCoinGeckoBody(opts, COINGECKO_BTC_USD_URL);
47
- const btc = body.bitcoin?.usd;
48
- if (!isPositiveNumber(btc)) {
49
- throw new Error("coingecko response missing bitcoin.usd");
50
- }
51
- return { btc_usd: btc, as_of: (/* @__PURE__ */ new Date()).toISOString() };
52
- }
53
- async function fetchCoinGeckoBody(opts, defaultUrl) {
54
- const url = opts?.url ?? defaultUrl;
55
- const fetchImpl = opts?.fetchImpl ?? fetch;
56
- const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
57
- const userAgent = opts?.userAgent ?? DEFAULT_USER_AGENT;
58
- const res = await fetchImpl(url, {
59
- headers: { "User-Agent": userAgent, Accept: "application/json" },
60
- signal: AbortSignal.timeout(timeoutMs)
61
- });
62
- if (!res.ok) {
63
- throw new Error(`coingecko returned HTTP ${res.status.toString()}`);
64
- }
65
- return await res.json();
66
- }
67
- function isPositiveNumber(v) {
68
- return typeof v === "number" && Number.isFinite(v) && v > 0;
69
- }
70
-
71
- // src/lib/currency.ts
72
- function msatsToUsd(msats, rate) {
73
- return msats / 1e11 * rate;
74
- }
75
- function usdToMsats(usd, rate) {
76
- return Math.round(usd / rate * 1e11);
77
- }
78
- function msatsToUsdc(msats, btcUsdRate) {
79
- const usd = msatsToUsd(msats, btcUsdRate);
80
- return Math.ceil(usd * 1e6);
81
- }
82
- function usdcToMsats(usdc, btcUsdRate) {
83
- return usdToMsats(usdc, btcUsdRate);
84
- }
85
- function formatSats(msats) {
86
- if (msats === 0) return "0 sats";
87
- if (msats < 1e3) return `${msats.toLocaleString("en-US")} msats`;
88
- if (msats % 1e3 === 0) return `${(msats / 1e3).toLocaleString("en-US")} sats`;
89
- return `${Math.round(msats / 1e3 * 100) / 100} sats`;
90
- }
91
- function formatAmount(msats, rate, opts) {
92
- const usd = msatsToUsd(msats, rate);
93
- const base = `~$${formatUsd(usd)} (${formatSats(msats)})`;
94
- return opts?.anchor === false ? base : `${base} \u2014 ${costAnchor(usd)}`;
95
- }
96
- function formatPaymentAmount(msats, fiat, opts) {
97
- if (!fiat || fiat.amount <= 0) return formatAmountBestEffort(msats, opts);
98
- const base = `${formatFiat(fiat.amount, fiat.currency)} (${formatSats(msats)})`;
99
- return opts?.anchor === false ? base : `${base} \u2014 ${costAnchor(fiat.amount, fiat.currency)}`;
100
- }
101
- var COST_ANCHOR_BANDS = {
102
- usd: [0.01, 0.1, 1, 10],
103
- eur: [0.01, 0.1, 1, 10],
104
- gbp: [0.01, 0.1, 1, 10],
105
- jpy: [1, 10, 100, 1500]
106
- };
107
- function costAnchor(amount, currency = "usd") {
108
- const bands = COST_ANCHOR_BANDS[currency] ?? COST_ANCHOR_BANDS.usd;
109
- if (amount < bands[0]) return "fraction of a cent";
110
- if (amount <= bands[1]) return "comparable to an API call";
111
- if (amount <= bands[2]) return "comparable to a ChatGPT query";
112
- if (amount <= bands[3]) return "comparable to a coffee";
113
- return "significant purchase \u2014 review carefully";
114
- }
115
- function monetaryJson(msats, rate) {
116
- const usd = msatsToUsd(msats, rate);
117
- return {
118
- msats,
119
- usd: Math.round(usd * 100) / 100,
120
- anchor: costAnchor(usd),
121
- display: formatAmount(msats, rate)
122
- };
123
- }
124
- function formatUsd(usd) {
125
- if (usd === 0) return "0.00";
126
- if (usd >= 0.01) return usd.toFixed(2);
127
- const digits = Math.max(2, -Math.floor(Math.log10(usd)) + 1);
128
- return usd.toFixed(digits);
129
- }
130
- function formatUsdcMicrounits(microunits) {
131
- const value = typeof microunits === "bigint" ? microunits : BigInt(microunits);
132
- const whole = value / 1000000n;
133
- const fraction = (value % 1000000n).toString().padStart(6, "0").replace(/0+$/, "");
134
- return `${whole}.${fraction.padEnd(2, "0") || "00"}`;
135
- }
136
- function parseBudget(budget, rate) {
137
- const value = assertValidBudget(budget);
138
- return budget.startsWith("$") ? usdToMsats(value, rate) : value;
139
- }
140
- function assertValidBudget(budget) {
141
- const value = budget.startsWith("$") ? parseFloat(budget.slice(1)) : parseInt(budget, 10);
142
- if (isNaN(value)) throw new Error(`Invalid budget: ${budget}`);
143
- return value;
144
- }
145
- async function fetchBtcUsdRate() {
146
- if (memRate && Date.now() - memTime < CACHE_TTL) {
147
- return memRate;
148
- }
149
- const disk = readDiskCache();
150
- if (disk) {
151
- memRate = disk;
152
- memTime = Date.now();
153
- return disk;
154
- }
155
- const rate = await fetchFromApi();
156
- memRate = rate;
157
- memTime = Date.now();
158
- writeDiskCache(rate);
159
- return rate;
160
- }
161
- function getLastKnownBtcRate() {
162
- if (memRate && memTime > 0) return { rate: memRate, cachedAt: memTime };
163
- return readDiskCacheStale();
164
- }
165
- function formatStaleness(cachedAt, now = Date.now()) {
166
- const ageMs = Math.max(0, now - cachedAt);
167
- const seconds = Math.floor(ageMs / 1e3);
168
- if (seconds < 60) return `${seconds}s ago`;
169
- const minutes = Math.floor(seconds / 60);
170
- if (minutes < 60) return `${minutes} min ago`;
171
- const hours = Math.floor(minutes / 60);
172
- if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
173
- const days = Math.floor(hours / 24);
174
- return `${days} day${days === 1 ? "" : "s"} ago`;
175
- }
176
- function formatAmountBestEffort(msats, opts) {
177
- const m = msats ?? 0;
178
- const cached = getLastKnownBtcRate();
179
- if (cached === null) return `${Math.round(m / 1e3)} sats`;
180
- const base = formatAmount(m, cached.rate, opts);
181
- if (Date.now() - cached.cachedAt < CACHE_TTL) return base;
182
- return `${base} (rate cached ${formatStaleness(cached.cachedAt)})`;
183
- }
184
- var CACHE_TTL = 5 * 60 * 1e3;
185
- var CACHE_FILE = BTC_RATE_FILE;
186
- var memRate = null;
187
- var memTime = 0;
188
- function readDiskCache() {
189
- try {
190
- if (!existsSync(CACHE_FILE)) return null;
191
- const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
192
- if (Date.now() - data.timestamp >= CACHE_TTL) return null;
193
- if (!isPlausibleBtcUsdRate(data.rate)) return null;
194
- return data.rate;
195
- } catch {
196
- return null;
197
- }
198
- }
199
- function readDiskCacheStale() {
200
- try {
201
- if (!existsSync(CACHE_FILE)) return null;
202
- const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
203
- if (!isPlausibleBtcUsdRate(data.rate)) return null;
204
- return { rate: data.rate, cachedAt: data.timestamp };
205
- } catch {
206
- return null;
207
- }
208
- }
209
- function writeDiskCache(rate) {
210
- try {
211
- ensureConfigSubdir(dirname(CACHE_FILE));
212
- writeFileSync(CACHE_FILE, JSON.stringify({ rate, timestamp: Date.now() }));
213
- } catch {
214
- }
215
- }
216
- var MAX_PLAUSIBLE_BTC_USD = 1e7;
217
- function isPlausibleBtcUsdRate(rate) {
218
- return typeof rate === "number" && Number.isFinite(rate) && rate > 0 && rate < MAX_PLAUSIBLE_BTC_USD;
219
- }
220
- async function fetchFromApi() {
221
- const spot = await fetchCoinGeckoBtcUsd();
222
- const rate = spot.btc_usd;
223
- if (!isPlausibleBtcUsdRate(rate)) {
224
- throw new Error(`implausible BTC/USD rate from upstream: ${String(rate)}`);
225
- }
226
- return rate;
227
- }
228
-
229
- export {
230
- formatFiat,
231
- fetchCoinGeckoSpot,
232
- msatsToUsd,
233
- usdToMsats,
234
- msatsToUsdc,
235
- usdcToMsats,
236
- formatAmount,
237
- formatPaymentAmount,
238
- costAnchor,
239
- monetaryJson,
240
- formatUsd,
241
- formatUsdcMicrounits,
242
- parseBudget,
243
- assertValidBudget,
244
- fetchBtcUsdRate,
245
- getLastKnownBtcRate,
246
- formatStaleness,
247
- formatAmountBestEffort
248
- };
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __dvmCreateRequire } from "node:module";
3
- const require = __dvmCreateRequire(import.meta.url);
4
- import {
5
- assertX402ChannelPayer,
6
- assertX402WalletIdle,
7
- readX402ChannelOnChain,
8
- x402ChannelControlledBy
9
- } from "./chunk-5BUV73FO.js";
10
- import "./chunk-ZELLQI7F.js";
11
- import "./chunk-MTBCEXJ6.js";
12
- import "./chunk-ONQMRWY3.js";
13
- import "./chunk-3TBULV3F.js";
14
- import "./chunk-6UGZAFIR.js";
15
- import "./chunk-U5TNSUYW.js";
16
- import "./chunk-6AJ7H2VX.js";
17
- import "./chunk-ZGXCK43G.js";
18
- import "./chunk-IC6OXFYW.js";
19
- import "./chunk-PHZHPRQE.js";
20
- import "./chunk-UXQCP26E.js";
21
- import "./chunk-MMJR6N3J.js";
22
- import "./chunk-HPRIQEJS.js";
23
- import "./chunk-IYHTITNZ.js";
24
- export {
25
- assertX402ChannelPayer,
26
- assertX402WalletIdle,
27
- readX402ChannelOnChain,
28
- x402ChannelControlledBy
29
- };
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __dvmCreateRequire } from "node:module";
3
- const require = __dvmCreateRequire(import.meta.url);
4
- import {
5
- assertTempoWalletIdle
6
- } from "./chunk-UU6QMSTQ.js";
7
- import "./chunk-ACNNU5RY.js";
8
- import "./chunk-GIDSTROG.js";
9
- import "./chunk-RWBYCM47.js";
10
- import "./chunk-YZUBKHHA.js";
11
- import "./chunk-BZNZWRBB.js";
12
- import "./chunk-G3RLVJF5.js";
13
- import "./chunk-ZELLQI7F.js";
14
- import "./chunk-XGABM4H5.js";
15
- import "./chunk-ONQMRWY3.js";
16
- import "./chunk-6UGZAFIR.js";
17
- import "./chunk-U5TNSUYW.js";
18
- import "./chunk-6AJ7H2VX.js";
19
- import "./chunk-SLDVIXCS.js";
20
- import "./chunk-7UPZZGC5.js";
21
- import "./chunk-4AQ4G7L5.js";
22
- import "./chunk-ZGXCK43G.js";
23
- import "./chunk-IC6OXFYW.js";
24
- import "./chunk-PHZHPRQE.js";
25
- import "./chunk-UXQCP26E.js";
26
- import "./chunk-MMJR6N3J.js";
27
- import "./chunk-HPRIQEJS.js";
28
- import "./chunk-IYHTITNZ.js";
29
- export {
30
- assertTempoWalletIdle
31
- };
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __dvmCreateRequire } from "node:module";
3
- const require = __dvmCreateRequire(import.meta.url);
4
- import {
5
- connectedX402Payer,
6
- ensureAddress,
7
- generateX402PrivateKey,
8
- getX402Balance,
9
- loadX402Wallet,
10
- removeX402Wallet,
11
- repinX402WalletNetwork,
12
- saveX402Wallet
13
- } from "./chunk-EY5K4BM3.js";
14
- import "./chunk-XGABM4H5.js";
15
- import "./chunk-MTBCEXJ6.js";
16
- import "./chunk-ONQMRWY3.js";
17
- import "./chunk-3TBULV3F.js";
18
- import "./chunk-6UGZAFIR.js";
19
- import "./chunk-U5TNSUYW.js";
20
- import "./chunk-IYHTITNZ.js";
21
- export {
22
- connectedX402Payer,
23
- ensureAddress,
24
- generateX402PrivateKey,
25
- getX402Balance,
26
- loadX402Wallet,
27
- removeX402Wallet,
28
- repinX402WalletNetwork,
29
- saveX402Wallet
30
- };