@dvmkit/dvm-cli 0.7.0-rc.2 → 0.7.0-rc.3

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 (24) hide show
  1. package/dist/{chunk-6QHVPJNX.js → chunk-2I5XAIQ4.js} +3 -3
  2. package/dist/{chunk-RQYMWLX4.js → chunk-3PV36227.js} +2 -2
  3. package/dist/{chunk-7UAQTHNP.js → chunk-5QO3MGMH.js} +4 -4
  4. package/dist/{chunk-PG7MEKJI.js → chunk-5VOAE2CL.js} +2 -2
  5. package/dist/{chunk-JTMBSEZO.js → chunk-6JP6ZBWW.js} +4 -4
  6. package/dist/{chunk-ZXVOMXT4.js → chunk-7OA2XUM4.js} +2 -2
  7. package/dist/{chunk-VLZ2K7JL.js → chunk-BHJLMVO2.js} +27 -6
  8. package/dist/{chunk-FPWP4S5S.js → chunk-C5XIOTRP.js} +36 -5
  9. package/dist/{chunk-IQV4KG63.js → chunk-EQXNDN5I.js} +2 -2
  10. package/dist/{chunk-U3YRNLZ5.js → chunk-IERBEO4C.js} +3 -3
  11. package/dist/{chunk-VIYUB3XT.js → chunk-LIITTIEN.js} +347 -85
  12. package/dist/{chunk-WN5R367B.js → chunk-ZM5QFHEY.js} +30 -2
  13. package/dist/{client-IDO4IAXG.js → client-PGOH2ION.js} +6 -6
  14. package/dist/dvm.js +1779 -620
  15. package/dist/{internal-7FXJTFBU.js → internal-VIAWW5ED.js} +13 -5
  16. package/dist/{lifecycle-LRS3IBQL.js → lifecycle-VHGTNHHE.js} +6 -6
  17. package/dist/{payout-reporter-WT7XYW42-U2QPDIYC.js → payout-reporter-3UVWPGMO-WWZWXWCG.js} +6 -4
  18. package/dist/{pocket-refill-J5OWRBXH.js → pocket-refill-BHNKMENF.js} +10 -10
  19. package/dist/{revenue-reporter-7UR3W2SD-C5OMRGK3.js → revenue-reporter-E56J3NZK-NZ5H27ZI.js} +2 -2
  20. package/dist/{tempo-lifecycle-HS2NIFKT.js → tempo-lifecycle-NDBO3V3A.js} +8 -8
  21. package/dist/{tempo-wallet-BA2LKR45.js → tempo-wallet-BAU7ASWF.js} +7 -7
  22. package/dist/{wallet-RPPUCQUR.js → wallet-RB2RPWIN.js} +7 -7
  23. package/dist/{x402-ZU4GML7Z-RYEACIIT.js → x402-BN26TQZ6-4MWLNZGT.js} +2 -2
  24. package/package.json +2 -2
@@ -5,11 +5,11 @@ import {
5
5
  authorizeProtectedRemoval,
6
6
  loadConfig,
7
7
  updateConfig
8
- } from "./chunk-ZXVOMXT4.js";
8
+ } from "./chunk-7OA2XUM4.js";
9
9
  import {
10
10
  withX402ChannelLock,
11
11
  x402WalletFromConfig
12
- } from "./chunk-VIYUB3XT.js";
12
+ } from "./chunk-LIITTIEN.js";
13
13
  import {
14
14
  DvmError,
15
15
  X402_DEFAULT_NETWORK,
@@ -17,7 +17,7 @@ import {
17
17
  ensureAddress,
18
18
  isValidEvmPrivateKey,
19
19
  x402NetworkByCaip2
20
- } from "./chunk-JTMBSEZO.js";
20
+ } from "./chunk-6JP6ZBWW.js";
21
21
 
22
22
  // src/lib/x402/networks.ts
23
23
  function x402NetworkLabel(network) {
@@ -12,7 +12,7 @@ import {
12
12
  isSignableExactRequirement,
13
13
  maxAdvertisedMicro,
14
14
  withinAdvertisedTolerance
15
- } from "./chunk-VIYUB3XT.js";
15
+ } from "./chunk-LIITTIEN.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-JTMBSEZO.js";
33
+ } from "./chunk-6JP6ZBWW.js";
34
34
 
35
35
  // src/lib/x402/client.ts
36
36
  import { randomBytes } from "crypto";
@@ -4,14 +4,14 @@ const require = __dvmCreateRequire(import.meta.url);
4
4
  import {
5
5
  loadConfig,
6
6
  updateConfig
7
- } from "./chunk-ZXVOMXT4.js";
7
+ } from "./chunk-7OA2XUM4.js";
8
8
  import {
9
9
  tempoAccountFromConfig,
10
10
  tryResolveTempoAsset
11
- } from "./chunk-VIYUB3XT.js";
11
+ } from "./chunk-LIITTIEN.js";
12
12
  import {
13
13
  DvmError
14
- } from "./chunk-JTMBSEZO.js";
14
+ } from "./chunk-6JP6ZBWW.js";
15
15
 
16
16
  // src/lib/payment-rails/tempo-wallet.ts
17
17
  function tempoBalanceCheckHint(token) {
@@ -46,7 +46,7 @@ async function generateTempoKey(opts = {}) {
46
46
  );
47
47
  }
48
48
  if (existing && opts.force) {
49
- const { assertTempoWalletIdle } = await import("./tempo-lifecycle-HS2NIFKT.js");
49
+ const { assertTempoWalletIdle } = await import("./tempo-lifecycle-NDBO3V3A.js");
50
50
  await assertTempoWalletIdle("replace");
51
51
  }
52
52
  const { privateKeyToAccount, generatePrivateKey } = await import("./accounts-2WZE4N5F.js");
@@ -5,10 +5,10 @@ import {
5
5
  formatUsdcMicrounits,
6
6
  listX402Channels,
7
7
  readX402ChannelGuardFacts
8
- } from "./chunk-VIYUB3XT.js";
8
+ } from "./chunk-LIITTIEN.js";
9
9
  import {
10
10
  DvmError
11
- } from "./chunk-JTMBSEZO.js";
11
+ } from "./chunk-6JP6ZBWW.js";
12
12
 
13
13
  // src/lib/x402/lifecycle.ts
14
14
  async function assertX402WalletIdle(wallet, intent) {
@@ -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-WN5R367B.js";
6
+ } from "./chunk-ZM5QFHEY.js";
7
7
  import {
8
8
  __export
9
9
  } from "./chunk-IYHTITNZ.js";
@@ -3103,7 +3103,7 @@ async function getX402Balance(wallet) {
3103
3103
  }
3104
3104
  }
3105
3105
 
3106
- // node_modules/@dvmkit/sdk/dist/chunk-26W6GPCD.js
3106
+ // node_modules/@dvmkit/sdk/dist/chunk-XEOTTFLH.js
3107
3107
  import { AsyncLocalStorage } from "async_hooks";
3108
3108
  import { createPrivateKey, randomBytes as randomBytes2 } from "crypto";
3109
3109
 
@@ -10595,7 +10595,7 @@ var SignJWT = class {
10595
10595
  }
10596
10596
  };
10597
10597
 
10598
- // node_modules/@dvmkit/sdk/dist/chunk-26W6GPCD.js
10598
+ // node_modules/@dvmkit/sdk/dist/chunk-XEOTTFLH.js
10599
10599
  var scopes = new AsyncLocalStorage();
10600
10600
  function withPaymentDiagnostics(fn) {
10601
10601
  return scopes.run({}, fn);
@@ -10770,7 +10770,7 @@ function logRejected(stage) {
10770
10770
  });
10771
10771
  }
10772
10772
 
10773
- // node_modules/@dvmkit/sdk/dist/chunk-H5FVVEEN.js
10773
+ // node_modules/@dvmkit/sdk/dist/chunk-BIZR5ORK.js
10774
10774
  async function verifyX402Payment(paymentHeader, config, requiredUsdcMicro, resource, btcUsdRate, exactVersions = { v1: true, v2: true }) {
10775
10775
  return callerLoggers.x402.span(
10776
10776
  "x402.verify_payment",
@@ -8,10 +8,10 @@ import {
8
8
  CONFIG_PINNED_FILE,
9
9
  ensureConfigDir,
10
10
  require_proper_lockfile
11
- } from "./chunk-VIYUB3XT.js";
11
+ } from "./chunk-LIITTIEN.js";
12
12
  import {
13
13
  DvmError
14
- } from "./chunk-JTMBSEZO.js";
14
+ } from "./chunk-6JP6ZBWW.js";
15
15
  import {
16
16
  __toESM
17
17
  } from "./chunk-IYHTITNZ.js";
@@ -4,7 +4,7 @@ const require = __dvmCreateRequire(import.meta.url);
4
4
  import {
5
5
  loadX402Wallet,
6
6
  x402NetworkLabel
7
- } from "./chunk-6QHVPJNX.js";
7
+ } from "./chunk-2I5XAIQ4.js";
8
8
  import {
9
9
  costAnchor,
10
10
  info,
@@ -12,14 +12,14 @@ import {
12
12
  resolveBtcUsdRate,
13
13
  tryResolveBtcUsdRate,
14
14
  tryX402Payment
15
- } from "./chunk-RQYMWLX4.js";
15
+ } from "./chunk-3PV36227.js";
16
16
  import {
17
17
  connectedTempoAccount
18
- } from "./chunk-7UAQTHNP.js";
18
+ } from "./chunk-5QO3MGMH.js";
19
19
  import {
20
20
  isCreditPosture,
21
21
  loadConfig
22
- } from "./chunk-ZXVOMXT4.js";
22
+ } from "./chunk-7OA2XUM4.js";
23
23
  import {
24
24
  BUDGET_FILE,
25
25
  JOBS_FILE,
@@ -156,7 +156,7 @@ import {
156
156
  x402PendingUnsettled,
157
157
  x402RequiredFromError,
158
158
  x402VoucherPendingState
159
- } from "./chunk-VIYUB3XT.js";
159
+ } from "./chunk-LIITTIEN.js";
160
160
  import {
161
161
  Challenge_exports,
162
162
  Credential_exports
@@ -173,7 +173,7 @@ import {
173
173
  redactUrlsInText,
174
174
  usdToMsats,
175
175
  x402NetworkToCaip2
176
- } from "./chunk-JTMBSEZO.js";
176
+ } from "./chunk-6JP6ZBWW.js";
177
177
  import {
178
178
  privateKeyToAccount
179
179
  } from "./chunk-EVQERRCP.js";
@@ -1803,6 +1803,24 @@ async function abandonPendingSubmission(args) {
1803
1803
  saveAgentWallet(next);
1804
1804
  });
1805
1805
  }
1806
+ async function markPendingSubmissionUnresolved(args) {
1807
+ await withWalletLock(() => {
1808
+ const wallet = loadAgentWallet();
1809
+ if (!wallet) return;
1810
+ const next = withAcceptedUnresolved(wallet, args.requestId, args.marker);
1811
+ if (next !== wallet) saveAgentWallet(next);
1812
+ });
1813
+ }
1814
+ function withAcceptedUnresolved(wallet, requestId, marker) {
1815
+ const target = wallet.pending_submissions.find((s) => s.request_id === requestId);
1816
+ if (!target || target.accepted_unresolved) return wallet;
1817
+ return {
1818
+ ...wallet,
1819
+ pending_submissions: wallet.pending_submissions.map(
1820
+ (s) => s.request_id === requestId ? { ...s, accepted_unresolved: marker } : s
1821
+ )
1822
+ };
1823
+ }
1806
1824
  function resolveRefundClause(offer, locktimeSecondsOverride, nowMs, opts) {
1807
1825
  const canonicalId = offer.canonical_id;
1808
1826
  if (!canonicalId) return null;
@@ -5401,6 +5419,8 @@ export {
5401
5419
  commitAgentSpend,
5402
5420
  correctPendingFundAmount,
5403
5421
  abandonPendingSubmission,
5422
+ markPendingSubmissionUnresolved,
5423
+ withAcceptedUnresolved,
5404
5424
  drainReceiptsDisplay,
5405
5425
  drainReceiptsHint,
5406
5426
  receiptDisplay,
@@ -5420,6 +5440,7 @@ export {
5420
5440
  loadLedger,
5421
5441
  saveLedger,
5422
5442
  recordSpend,
5443
+ recordSpendOnce,
5423
5444
  enforceGlobalBudget,
5424
5445
  statusSnapshot,
5425
5446
  floatPaymentJson,
@@ -6,10 +6,22 @@ import {
6
6
  } from "./chunk-R2DSAZBO.js";
7
7
  import {
8
8
  diagnosticConsole
9
- } from "./chunk-WN5R367B.js";
9
+ } from "./chunk-ZM5QFHEY.js";
10
10
 
11
- // node_modules/@dvmkit/sdk/dist/chunk-DNG4KGSC.js
11
+ // node_modules/@dvmkit/sdk/dist/chunk-3VFEX2Y3.js
12
12
  import { createHash, randomUUID } from "crypto";
13
+ async function x402EarnedCeiling(channel, earnedNative) {
14
+ let earned;
15
+ try {
16
+ earned = await earnedNative(channel.channelId.toLowerCase());
17
+ } catch (error) {
18
+ return { kind: "unresolved", error };
19
+ }
20
+ if (earned === void 0) return { kind: "unbound" };
21
+ const charged = BigInt(channel.chargedCumulativeAmount);
22
+ const wanted = BigInt(earned);
23
+ return { kind: "ceiling", ceiling: wanted < charged ? wanted : charged };
24
+ }
13
25
  var MemoryX402BatchStore = class {
14
26
  batches = /* @__PURE__ */ new Map();
15
27
  get(scope) {
@@ -722,7 +734,8 @@ var PayoutReporter = class {
722
734
  }
723
735
  /**
724
736
  * x402: the open batch (claimed, not yet transferred) plus every channel's
725
- * unclaimed voucher value; wedged when the settle keeps failing, and the
737
+ * earned value not yet claimed — a channel whose earned figure cannot be
738
+ * read contributes nothing; wedged when the settle keeps failing, and the
726
739
  * refund settlements stuck between chain and ledger beside it.
727
740
  */
728
741
  async snapshotX402() {
@@ -754,12 +767,29 @@ var PayoutReporter = class {
754
767
  }
755
768
  const unclaimed = [];
756
769
  for (const channel of await ctx.storage.list()) {
757
- const owed = BigInt(channel.chargedCumulativeAmount) - BigInt(channel.totalClaimed);
770
+ const claimed = BigInt(channel.totalClaimed);
771
+ if (BigInt(channel.chargedCumulativeAmount) <= claimed) continue;
772
+ let resolved;
773
+ try {
774
+ resolved = await x402EarnedCeiling(channel, ctx.earnedNative);
775
+ } catch (err) {
776
+ resolved = { kind: "unresolved", error: err };
777
+ }
778
+ if (resolved.kind === "unresolved") {
779
+ warn("payout_pending_snapshot_failed", {
780
+ rail: "x402",
781
+ "channel.id": channel.channelId,
782
+ error: message(resolved.error)
783
+ });
784
+ continue;
785
+ }
786
+ if (resolved.kind === "unbound") continue;
787
+ const owed = resolved.ceiling - claimed;
758
788
  if (owed > 0n) {
759
789
  unclaimed.push({
760
790
  id: channel.channelId,
761
791
  native: Number(owed),
762
- label: "unclaimed vouchers"
792
+ label: "earned, awaiting claim"
763
793
  });
764
794
  }
765
795
  }
@@ -905,6 +935,7 @@ function warn(level, fields) {
905
935
  }
906
936
 
907
937
  export {
938
+ x402EarnedCeiling,
908
939
  MemoryX402BatchStore,
909
940
  PostgresX402BatchStore,
910
941
  PAYOUT_SNAPSHOT_INTERVAL_MS,
@@ -6,9 +6,9 @@ import {
6
6
  } from "./chunk-R2DSAZBO.js";
7
7
  import {
8
8
  diagnosticConsole
9
- } from "./chunk-WN5R367B.js";
9
+ } from "./chunk-ZM5QFHEY.js";
10
10
 
11
- // node_modules/@dvmkit/sdk/dist/chunk-GSLS4464.js
11
+ // node_modules/@dvmkit/sdk/dist/chunk-YK54BJ2L.js
12
12
  import { randomUUID } from "crypto";
13
13
  var ENDPOINTS = {
14
14
  job_terminal: "/_internal/job-terminal",
@@ -3,7 +3,7 @@ import { createRequire as __dvmCreateRequire } from "node:module";
3
3
  const require = __dvmCreateRequire(import.meta.url);
4
4
  import {
5
5
  connectedTempoAccount
6
- } from "./chunk-7UAQTHNP.js";
6
+ } from "./chunk-5QO3MGMH.js";
7
7
  import {
8
8
  deriveIdentityFromPrivkey,
9
9
  formatUsdcMicrounits,
@@ -13,10 +13,10 @@ import {
13
13
  reconcileTempoChannelOnChain,
14
14
  shellQuoteArg,
15
15
  tempoChannelControlledBy
16
- } from "./chunk-VIYUB3XT.js";
16
+ } from "./chunk-LIITTIEN.js";
17
17
  import {
18
18
  DvmError
19
- } from "./chunk-JTMBSEZO.js";
19
+ } from "./chunk-6JP6ZBWW.js";
20
20
 
21
21
  // src/lib/cli-identity-resolve.ts
22
22
  function resolveSigningIdentity(opts) {