@dvmkit/dvm-cli 0.12.1 → 0.14.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 (28) hide show
  1. package/dist/{chunk-MMXHV3KC.js → chunk-2MCZ4QOK.js} +2 -2
  2. package/dist/{chunk-GHNF2I5C.js → chunk-57PXJ56K.js} +56 -54
  3. package/dist/{chunk-RMYEB2WG.js → chunk-CO2TD5RO.js} +2 -2
  4. package/dist/{chunk-3R2GM6AD.js → chunk-D5CGDS3V.js} +2 -2
  5. package/dist/{chunk-WPTJM5A7.js → chunk-DU7YCGCQ.js} +1422 -100
  6. package/dist/{chunk-HWWW7JEM.js → chunk-EZL4IVCU.js} +3 -3
  7. package/dist/{chunk-7N3HQJKE.js → chunk-HJ2JYBTT.js} +4 -4
  8. package/dist/{chunk-K562SFVD.js → chunk-HXTASGHL.js} +2 -2
  9. package/dist/{chunk-6EYBCGGD.js → chunk-I7ZBID4L.js} +2 -2
  10. package/dist/{chunk-UVFFMKU4.js → chunk-UCCT5IKU.js} +76 -4
  11. package/dist/{chunk-GEZVSJDM.js → chunk-UWVMG4VG.js} +3 -3
  12. package/dist/{chunk-MBSCP52L.js → chunk-YQJRKWNT.js} +32838 -11936
  13. package/dist/{client-V7KAPCAG.js → client-DC7TVYNU.js} +6 -6
  14. package/dist/dvm.js +4651 -2091
  15. package/dist/{internal-ZZHCUKOM.js → internal-O7IQD6EQ.js} +5 -5
  16. package/dist/{lifecycle-XGNIMPTB.js → lifecycle-MIJH3JE4.js} +6 -6
  17. package/dist/{payout-reporter-DDQ7FGRC-OKICJCC2.js → payout-reporter-Y6OW3FYD-K6MRWQXK.js} +2 -2
  18. package/dist/{pocket-refill-Z4YT7CHW.js → pocket-refill-HEVLAMKN.js} +10 -10
  19. package/dist/{revenue-reporter-RIEHBKRA-75BDPVVX.js → revenue-reporter-CIG2MEDN-ZXMO6NWG.js} +2 -2
  20. package/dist/{tempo-lifecycle-LGGBDCKK.js → tempo-lifecycle-FMBCHD2M.js} +8 -8
  21. package/dist/{tempo-wallet-PLFC443A.js → tempo-wallet-U3WBWIIH.js} +7 -7
  22. package/dist/{wallet-UJ7EJNQA.js → wallet-Z3FDX43V.js} +7 -7
  23. package/dist/{x402-AY6P5KV4-SIZF7YNW.js → x402-ARXZQ5BD-H6PNJYYT.js} +2 -2
  24. package/package.json +2 -2
  25. package/skills/dvm/SKILL.md +2 -0
  26. package/skills/dvm/calling.md +12 -1
  27. package/skills/dvm/credit.md +8 -0
  28. package/skills/dvm/recovery.md +3 -0
@@ -8,10 +8,10 @@ import {
8
8
  CONFIG_PINNED_FILE,
9
9
  ensureConfigDir,
10
10
  require_proper_lockfile
11
- } from "./chunk-MBSCP52L.js";
11
+ } from "./chunk-YQJRKWNT.js";
12
12
  import {
13
13
  DvmError
14
- } from "./chunk-GHNF2I5C.js";
14
+ } from "./chunk-57PXJ56K.js";
15
15
  import {
16
16
  __toESM
17
17
  } from "./chunk-IYHTITNZ.js";
@@ -3,7 +3,7 @@ import { createRequire as __dvmCreateRequire } from "node:module";
3
3
  const require = __dvmCreateRequire(import.meta.url);
4
4
  import {
5
5
  diagnosticConsole
6
- } from "./chunk-UVFFMKU4.js";
6
+ } from "./chunk-UCCT5IKU.js";
7
7
  import {
8
8
  __export
9
9
  } from "./chunk-IYHTITNZ.js";
@@ -149,15 +149,56 @@ function x402SupportedNetworksHint() {
149
149
  var BY_CAIP2 = new Map(X402_NETWORKS.map((n) => [n.caip2, n]));
150
150
  var BY_SLUG = new Map(X402_NETWORKS.map((n) => [n.slug, n]));
151
151
 
152
- // node_modules/@dvmkit/sdk/dist/chunk-62FI3NJF.js
152
+ // node_modules/@dvmkit/sdk/dist/chunk-LABJSMSJ.js
153
+ function msatsToUsd(msats, rate) {
154
+ return msats / 1e11 * rate;
155
+ }
156
+ function usdToMsats(usd, rate) {
157
+ return Math.round(usd / rate * 1e11);
158
+ }
159
+ function msatsToUsdCents(msats, btcPriceUsd) {
160
+ const usd = msatsToUsd(msats, btcPriceUsd);
161
+ return Math.round(usd * 100);
162
+ }
163
+ function msatsToUsdc(msats, btcUsdRate) {
164
+ if (!Number.isSafeInteger(msats) || msats < 0) {
165
+ throw new RangeError("msats must be a non-negative safe integer");
166
+ }
167
+ if (!Number.isFinite(btcUsdRate) || btcUsdRate <= 0) {
168
+ throw new RangeError("BTC/USD rate must be finite and positive");
169
+ }
170
+ const [mantissa, exponent = "0"] = btcUsdRate.toString().split("e");
171
+ const decimalPlaces = mantissa.split(".")[1]?.length ?? 0;
172
+ const shift = Number(exponent) - decimalPlaces;
173
+ let numerator = BigInt(msats) * BigInt(mantissa.replace(".", ""));
174
+ let denominator = 100000n;
175
+ if (shift > 0) numerator *= 10n ** BigInt(shift);
176
+ else if (shift < 0) denominator *= 10n ** BigInt(-shift);
177
+ const micro = (numerator + denominator - 1n) / denominator;
178
+ if (micro > BigInt(Number.MAX_SAFE_INTEGER)) {
179
+ throw new RangeError("USDC micro-unit amount exceeds the safe integer range");
180
+ }
181
+ return Number(micro);
182
+ }
183
+ function usdcToMsats(usdc, btcUsdRate) {
184
+ return usdToMsats(usdc, btcUsdRate);
185
+ }
186
+ function msatsToMicro(msats, btcRate) {
187
+ return Math.round(msatsToUsd(msats, btcRate) * 1e6);
188
+ }
189
+ function microToSats(micro, btcRate) {
190
+ return Math.ceil(usdToMsats(micro / 1e6, btcRate) / 1e3);
191
+ }
153
192
  var X402_DEFAULT_FACILITATOR = "https://x402.org/facilitator";
154
193
  var X402_VERSION = 2;
155
194
  var X402_V1_VERSION = 1;
195
+ var DEFAULT_MAX_TIMEOUT_SECONDS = 60;
156
196
  var X402_DEFAULT_NETWORK = "eip155:8453";
157
197
  var X402_EXACT_SCHEME = "exact";
158
198
  var X402_BATCH_SETTLEMENT_SCHEME = "batch-settlement";
159
199
  function buildPaymentRequirements(opts) {
160
200
  const { x402Config, requiredUsdcMicro, resource, description, mimeType } = opts;
201
+ const maxTimeoutSeconds = opts.maxTimeoutSeconds ?? DEFAULT_MAX_TIMEOUT_SECONDS;
161
202
  const version = opts.version ?? X402_VERSION;
162
203
  const network = version === X402_V1_VERSION ? caip2ToX402Network(x402Config.network) : x402Config.network;
163
204
  const usdcContract = usdcContractByCaip2(x402Config.network);
@@ -171,7 +212,7 @@ function buildPaymentRequirements(opts) {
171
212
  amount: requiredUsdcMicro.toString(),
172
213
  payTo: x402Config.payTo,
173
214
  asset,
174
- maxTimeoutSeconds: 60,
215
+ maxTimeoutSeconds,
175
216
  extra
176
217
  };
177
218
  }
@@ -184,7 +225,7 @@ function buildPaymentRequirements(opts) {
184
225
  mimeType: mimeType ?? "application/json",
185
226
  payTo: x402Config.payTo,
186
227
  asset,
187
- maxTimeoutSeconds: 60,
228
+ maxTimeoutSeconds,
188
229
  ...Object.keys(extra).length > 0 ? { extra } : {}
189
230
  };
190
231
  }
@@ -347,45 +388,6 @@ function isRecord(value) {
347
388
  function isOptionalRecord(value) {
348
389
  return value === void 0 || value === null || isRecord(value);
349
390
  }
350
- function msatsToUsd(msats, rate) {
351
- return msats / 1e11 * rate;
352
- }
353
- function usdToMsats(usd, rate) {
354
- return Math.round(usd / rate * 1e11);
355
- }
356
- function msatsToUsdCents(msats, btcPriceUsd) {
357
- const usd = msatsToUsd(msats, btcPriceUsd);
358
- return Math.round(usd * 100);
359
- }
360
- function msatsToUsdc(msats, btcUsdRate) {
361
- if (!Number.isSafeInteger(msats) || msats < 0) {
362
- throw new RangeError("msats must be a non-negative safe integer");
363
- }
364
- if (!Number.isFinite(btcUsdRate) || btcUsdRate <= 0) {
365
- throw new RangeError("BTC/USD rate must be finite and positive");
366
- }
367
- const [mantissa, exponent = "0"] = btcUsdRate.toString().split("e");
368
- const decimalPlaces = mantissa.split(".")[1]?.length ?? 0;
369
- const shift = Number(exponent) - decimalPlaces;
370
- let numerator = BigInt(msats) * BigInt(mantissa.replace(".", ""));
371
- let denominator = 100000n;
372
- if (shift > 0) numerator *= 10n ** BigInt(shift);
373
- else if (shift < 0) denominator *= 10n ** BigInt(-shift);
374
- const micro = (numerator + denominator - 1n) / denominator;
375
- if (micro > BigInt(Number.MAX_SAFE_INTEGER)) {
376
- throw new RangeError("USDC micro-unit amount exceeds the safe integer range");
377
- }
378
- return Number(micro);
379
- }
380
- function usdcToMsats(usdc, btcUsdRate) {
381
- return usdToMsats(usdc, btcUsdRate);
382
- }
383
- function msatsToMicro(msats, btcRate) {
384
- return Math.round(msatsToUsd(msats, btcRate) * 1e6);
385
- }
386
- function microToSats(micro, btcRate) {
387
- return Math.ceil(usdToMsats(micro / 1e6, btcRate) / 1e3);
388
- }
389
391
  function resolveRpcOverride(envValue, bundled) {
390
392
  const override = envValue?.trim() ?? "";
391
393
  return override.length > 0 ? { url: override, source: "override" } : { url: bundled, source: "bundled" };
@@ -2992,7 +2994,7 @@ var schnorr = /* @__PURE__ */ (() => {
2992
2994
  };
2993
2995
  })();
2994
2996
 
2995
- // node_modules/@dvmkit/sdk/dist/chunk-WMGXJQI3.js
2997
+ // node_modules/@dvmkit/sdk/dist/chunk-XB644VN3.js
2996
2998
  function resolveX402Asset(network = X402_DEFAULT_NETWORK) {
2997
2999
  const spec = x402NetworkByCaip2(network);
2998
3000
  if (!spec) return null;
@@ -3105,7 +3107,7 @@ function buildNoopLoggers() {
3105
3107
  };
3106
3108
  }
3107
3109
 
3108
- // node_modules/@dvmkit/sdk/dist/chunk-I2H2XYQV.js
3110
+ // node_modules/@dvmkit/sdk/dist/chunk-EIL7VIVM.js
3109
3111
  import { AsyncLocalStorage } from "async_hooks";
3110
3112
  import { createPrivateKey, randomBytes as randomBytes2 } from "crypto";
3111
3113
 
@@ -10597,7 +10599,7 @@ var SignJWT = class {
10597
10599
  }
10598
10600
  };
10599
10601
 
10600
- // node_modules/@dvmkit/sdk/dist/chunk-I2H2XYQV.js
10602
+ // node_modules/@dvmkit/sdk/dist/chunk-EIL7VIVM.js
10601
10603
  var scopes = new AsyncLocalStorage();
10602
10604
  function withPaymentDiagnostics(fn) {
10603
10605
  return scopes.run({}, fn);
@@ -10772,7 +10774,7 @@ function logRejected(stage) {
10772
10774
  });
10773
10775
  }
10774
10776
 
10775
- // node_modules/@dvmkit/sdk/dist/chunk-IUODXRQN.js
10777
+ // node_modules/@dvmkit/sdk/dist/chunk-E4EXYTEO.js
10776
10778
  async function verifyX402Payment(paymentHeader, config, requiredUsdcMicro, resource, btcUsdRate, exactVersions = { v1: true, v2: true }) {
10777
10779
  return callerLoggers.x402.span(
10778
10780
  "x402.verify_payment",
@@ -10860,6 +10862,13 @@ export {
10860
10862
  x402NetworkListForCopy,
10861
10863
  assertSupportedX402Network,
10862
10864
  x402SupportedNetworksHint,
10865
+ msatsToUsd,
10866
+ usdToMsats,
10867
+ msatsToUsdCents,
10868
+ msatsToUsdc,
10869
+ usdcToMsats,
10870
+ msatsToMicro,
10871
+ microToSats,
10863
10872
  X402_DEFAULT_FACILITATOR,
10864
10873
  X402_VERSION,
10865
10874
  X402_V1_VERSION,
@@ -10882,13 +10891,6 @@ export {
10882
10891
  decodePaymentRequiredHeader,
10883
10892
  exactEvmAuthorization,
10884
10893
  encodeSettleResponseHeader,
10885
- msatsToUsd,
10886
- usdToMsats,
10887
- msatsToUsdCents,
10888
- msatsToUsdc,
10889
- usdcToMsats,
10890
- msatsToMicro,
10891
- microToSats,
10892
10894
  resolveRpcOverride,
10893
10895
  resolveRpcHttpTransportOptions,
10894
10896
  redactUrl,
@@ -12,7 +12,7 @@ import {
12
12
  isSignableExactRequirement,
13
13
  maxAdvertisedMicro,
14
14
  withinAdvertisedTolerance
15
- } from "./chunk-MBSCP52L.js";
15
+ } from "./chunk-YQJRKWNT.js";
16
16
  import {
17
17
  DvmError,
18
18
  X402_V1_VERSION,
@@ -30,7 +30,7 @@ import {
30
30
  usdcToMsats,
31
31
  x402NetworkByCaip2,
32
32
  x402NetworkToCaip2
33
- } from "./chunk-GHNF2I5C.js";
33
+ } from "./chunk-57PXJ56K.js";
34
34
 
35
35
  // src/lib/x402/client.ts
36
36
  import { randomBytes } from "crypto";
@@ -6,9 +6,9 @@ import {
6
6
  } from "./chunk-R2DSAZBO.js";
7
7
  import {
8
8
  diagnosticConsole
9
- } from "./chunk-UVFFMKU4.js";
9
+ } from "./chunk-UCCT5IKU.js";
10
10
 
11
- // node_modules/@dvmkit/sdk/dist/chunk-2I6NXIPG.js
11
+ // node_modules/@dvmkit/sdk/dist/chunk-PDWVERRC.js
12
12
  import { createHash, randomUUID } from "crypto";
13
13
  async function x402EarnedCeiling(channel, earnedNative) {
14
14
  let earned;