@dvmkit/sdk 0.1.5-rc.9 → 0.2.1-rc.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.
Files changed (67) hide show
  1. package/README.md +14 -0
  2. package/dist/{chunk-MLRCSJYX.js → chunk-2D75MNNG.js} +178 -550
  3. package/dist/{chunk-BIFLRKMO.js → chunk-2KGG5ORW.js} +1 -1
  4. package/dist/{chunk-27V2ILSR.js → chunk-4A2RAKCW.js} +2 -2
  5. package/dist/{chunk-5URG56JJ.js → chunk-A4CM2BD3.js} +18 -2
  6. package/dist/{chunk-L4OYF4DQ.js → chunk-AJNFXR7J.js} +2 -2
  7. package/dist/{chunk-S3XAHZQY.js → chunk-COYKJRMM.js} +24 -3
  8. package/dist/{chunk-UP2F5RRT.js → chunk-D7YQYLLM.js} +1 -4
  9. package/dist/{chunk-CEOAHV2I.js → chunk-FDKRXOZO.js} +0 -5
  10. package/dist/{chunk-TQWGQCNV.js → chunk-FPOLJRBF.js} +5 -5
  11. package/dist/{chunk-BTZY7VPH.js → chunk-GAIPXGM3.js} +1 -1
  12. package/dist/{chunk-SSSZUVWM.js → chunk-JAHRF5X3.js} +89 -39
  13. package/dist/{chunk-5PBOA25N.js → chunk-JNKQZVZX.js} +472 -617
  14. package/dist/{chunk-U6M3ATSG.js → chunk-MD3H3BF7.js} +40 -6
  15. package/dist/{chunk-CGKZDODG.js → chunk-MG67KXU7.js} +0 -5
  16. package/dist/{chunk-KSQEFVFJ.js → chunk-MMCE7XSR.js} +1 -1
  17. package/dist/{chunk-JZWELPFH.js → chunk-N5B66UOS.js} +4 -16
  18. package/dist/{chunk-BIP6G74V.js → chunk-O6D72KYA.js} +10 -10
  19. package/dist/{chunk-KXCKFIJI.js → chunk-QX52F6IB.js} +1 -1
  20. package/dist/{chunk-RW5LP57K.js → chunk-SDK6KDJN.js} +0 -1
  21. package/dist/{chunk-KVEHHC7W.js → chunk-U5VNEALI.js} +24 -13
  22. package/dist/{chunk-FROTD5XQ.js → chunk-V5ZRATJH.js} +2 -3
  23. package/dist/{chunk-EVBK675R.js → chunk-VA7GT6C6.js} +31 -37
  24. package/dist/{chunk-2UUXIIOC.js → chunk-VIVXB4CD.js} +3 -3
  25. package/dist/{chunk-6BQM7TOW.js → chunk-XMDQOXHO.js} +11 -38
  26. package/dist/{chunk-DMNLFNTW.js → chunk-XRLKGCAW.js} +2 -2
  27. package/dist/{chunk-M7LHFJ5K.js → chunk-XZ7LW4S5.js} +2 -3
  28. package/dist/{chunk-E4EVGPDX.js → chunk-YO56VCTQ.js} +0 -6
  29. package/dist/{credit-ledger-2DFQHNLB.js → credit-ledger-MHA652TV.js} +2 -2
  30. package/dist/{credit-menu-enwMbn55.d.ts → credit-menu-kDA9RVzD.d.ts} +524 -1077
  31. package/dist/{fx-D860pZvP.d.ts → fx-DhyT1Cjh.d.ts} +38 -82
  32. package/dist/index.d.ts +11 -26
  33. package/dist/index.js +2 -2
  34. package/dist/internal/caller.d.ts +644 -2140
  35. package/dist/internal/caller.js +32 -66
  36. package/dist/internal/server.d.ts +40 -90
  37. package/dist/internal/server.js +16 -16
  38. package/dist/{job-store-BUGqvCfL.d.ts → job-store-D3CcZp_g.d.ts} +73 -66
  39. package/dist/{lightning-backend-BozcevPZ.d.ts → lightning-backend-BhsyrBLa.d.ts} +19 -41
  40. package/dist/{memory-credit-ledger-MNUOTQO5.js → memory-credit-ledger-BYBATRN3.js} +3 -3
  41. package/dist/{mpp-secret-state-WNAQQ6K4.js → mpp-secret-state-B5GCILVH.js} +1 -1
  42. package/dist/{mpp-setup-4FJD6ZHV.js → mpp-setup-MPP3ST5X.js} +1 -1
  43. package/dist/{payout-reporter-RG6XNGPI.js → payout-reporter-KEMUXEUO.js} +2 -2
  44. package/dist/{postgres-consumed-credential-store-VHBT4KEA.js → postgres-consumed-credential-store-6N2V5MJN.js} +2 -2
  45. package/dist/postgres-job-store-MZZZMS2B.js +7 -0
  46. package/dist/postgres-kv-store-DXGTKXLU.js +7 -0
  47. package/dist/{postgres-replay-store-UJXRT6VO.js → postgres-replay-store-ZF4JNZOW.js} +2 -2
  48. package/dist/{pricing-4CEB34RM.js → pricing-MU5GNUJZ.js} +1 -1
  49. package/dist/{processed-payment-store-HAA4SFNK.js → processed-payment-store-GKMAWOM3.js} +2 -2
  50. package/dist/revenue-reporter-O75BGYFK.js +7 -0
  51. package/dist/server/index.d.ts +47 -159
  52. package/dist/server/index.js +67 -138
  53. package/dist/{ssrf-DbFkpDv0.d.ts → ssrf-dMooihtY.d.ts} +1 -2
  54. package/dist/{step-cache-5dljDqrQ.d.ts → step-cache-v2yhyhSZ.d.ts} +617 -1532
  55. package/dist/{tempo-charge-store-RIFTALZK.js → tempo-charge-store-SDTUNTKA.js} +2 -2
  56. package/dist/{tempo-lifecycle-DFIXQ54Q.js → tempo-lifecycle-G5SB4HFC.js} +5 -5
  57. package/dist/{tempo-session-store-2JNOKJGX.js → tempo-session-store-WF3VZXNF.js} +2 -2
  58. package/dist/{tempo-wallet-4QKSV65O.js → tempo-wallet-ZFNUDFVO.js} +2 -2
  59. package/dist/testing/index.d.ts +5 -15
  60. package/dist/testing/index.js +4 -11
  61. package/dist/{usd-DoRuAckA.d.ts → usd-Cu9G6xv2.d.ts} +14 -16
  62. package/dist/{wallet-CJC8lwxx.d.ts → wallet-Dwjs5n_M.d.ts} +1 -1
  63. package/dist/{x402-5H27DCBE.js → x402-CI6PSHNO.js} +5 -5
  64. package/package.json +3 -2
  65. package/dist/postgres-job-store-3RAXMNSY.js +0 -7
  66. package/dist/postgres-kv-store-JFBDP5IP.js +0 -7
  67. package/dist/revenue-reporter-ASZ7SHHH.js +0 -7
@@ -2,7 +2,7 @@ import {
2
2
  isValidEvmPrivateKey,
3
3
  loadConfig,
4
4
  updateConfig
5
- } from "./chunk-CGKZDODG.js";
5
+ } from "./chunk-MG67KXU7.js";
6
6
  import {
7
7
  DvmError,
8
8
  resolveRpcHttpTransportOptions,
@@ -101,7 +101,7 @@ async function generateTempoKey(opts = {}) {
101
101
  );
102
102
  }
103
103
  if (existing && opts.force) {
104
- const { assertTempoWalletIdle } = await import("./tempo-lifecycle-DFIXQ54Q.js");
104
+ const { assertTempoWalletIdle } = await import("./tempo-lifecycle-G5SB4HFC.js");
105
105
  await assertTempoWalletIdle("replace");
106
106
  }
107
107
  const { privateKeyToAccount, generatePrivateKey } = await import("viem/accounts");
@@ -155,7 +155,7 @@ async function getTempoUsdcBalance(account) {
155
155
  usdc: Number(raw) / 1e6,
156
156
  tokenAddress,
157
157
  chainId: network.chainId,
158
- // internal-review: redacted here rather than at a display surface, so the clear
158
+ // redacted here rather than at a display surface, so the clear
159
159
  // endpoint never leaves this function on the success path either.
160
160
  rpcUrlRedacted: redactUrl(rpcUrl),
161
161
  rpcSource,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withSdkInitLock
3
- } from "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-COYKJRMM.js";
4
4
 
5
5
  // src/sdk/server/payout-reporter.ts
6
6
  import { createHash, randomUUID } from "crypto";
@@ -35,7 +35,6 @@ var PostgresX402BatchStore = class {
35
35
  this.db = db;
36
36
  }
37
37
  db;
38
- /** Create the table (idempotent), under the SDK init lock like every other boot DDL. */
39
38
  async init() {
40
39
  await withSdkInitLock(this.db, async () => {
41
40
  await this.db.query(`
@@ -155,7 +154,6 @@ var PayoutReporter = class {
155
154
  this.intervalMs = opts.snapshotIntervalMs ?? PAYOUT_SNAPSHOT_INTERVAL_MS;
156
155
  this.now = opts.now ?? Date.now;
157
156
  }
158
- /** Boot DDL for the durable batch store, when this reporter owns one. */
159
157
  async init() {
160
158
  if (this.ownsBatchStore && this.batches instanceof PostgresX402BatchStore) {
161
159
  await this.batches.init();
@@ -200,8 +198,6 @@ var PayoutReporter = class {
200
198
  warn("payout_flush_failed", { error: message(err) });
201
199
  }
202
200
  }
203
- // ── cashu ─────────────────────────────────────────────────────────────
204
- /** The hook `mark-melted` runs inside its transaction: the mark and its payout commit together. */
205
201
  meltHook() {
206
202
  return {
207
203
  enqueue: (event, tx) => this.cashuMelted(event, tx),
@@ -212,17 +208,9 @@ var PayoutReporter = class {
212
208
  };
213
209
  }
214
210
  /**
215
- * A melt completed: the accumulator rows are SPENT at the mint and the
216
- * Lightning payment reached the builder's destination. One payout per mint
217
- * in the call — a `mark-melted` normally names one, since a melt quote
218
- * belongs to one mint. The amount is the face value melted; the mint's fee
219
- * and the Lightning amount received are builder-machine facts this DVM does
220
- * not see.
221
- *
222
- * Queued through `tx` when the caller is inside the transaction that marks
223
- * the rows, and a failure is thrown rather than swallowed so that mark rolls
224
- * back with it — see {@link TransactionalPayoutHook}. Without `tx` the rows
225
- * are queued on their own and delivered at once.
211
+ * Report melted face value per mint, not the Lightning amount received after fees. Hash the
212
+ * payment preimage; do not publish it. With tx, propagate enqueue failures and defer
213
+ * delivery until commit. Without tx, enqueue independently and start delivery.
226
214
  */
227
215
  async cashuMelted(event, tx) {
228
216
  const byMint = /* @__PURE__ */ new Map();
@@ -262,8 +250,6 @@ var PayoutReporter = class {
262
250
  void this.snapshotCashu();
263
251
  }
264
252
  }
265
- // ── tempo ─────────────────────────────────────────────────────────────
266
- /** The host attaches the session store and ledger readers once they exist. */
267
253
  attachTempo(reader) {
268
254
  this.tempo = reader;
269
255
  }
@@ -296,7 +282,6 @@ var PayoutReporter = class {
296
282
  }
297
283
  void this.snapshotTempo();
298
284
  }
299
- /** The hook `reconcile-tempo-drain` runs inside its transaction: the booking and its payout commit together. */
300
285
  tempoRepairHook() {
301
286
  return {
302
287
  enqueue: (event, tx) => this.tempoCloseReconciled(event, tx),
@@ -307,14 +292,9 @@ var PayoutReporter = class {
307
292
  };
308
293
  }
309
294
  /**
310
- * The operator repaired a wedged cooperative close (internal-review). The close's
311
- * payee side landed on chain when the close did; if the live hook reported
312
- * it, this upgrades that row to `repair`, otherwise it is the row. The
313
- * figure is the receipt's payee total for the channel.
314
- *
315
- * Queued through `tx` when the caller is inside the transaction that books
316
- * the drain, and thrown rather than swallowed so that booking rolls back
317
- * with it — see {@link TransactionalPayoutHook}.
295
+ * Report the receipt’s payee total under the live close’s transaction ID, flagged repaired.
296
+ * The platform upgrades a live row if one exists. Join tx and propagate enqueue failures;
297
+ * this does not report the caller refund.
318
298
  */
319
299
  async tempoCloseReconciled(event, tx) {
320
300
  const settled = BigInt(event.settledToPayee);
@@ -345,8 +325,6 @@ var PayoutReporter = class {
345
325
  void this.snapshotTempo();
346
326
  }
347
327
  }
348
- // ── x402 ──────────────────────────────────────────────────────────────
349
- /** The observer the batch-settlement server attaches to and routes its manager through. */
350
328
  x402Observer() {
351
329
  return {
352
330
  attach: (ctx) => {
@@ -366,13 +344,9 @@ var PayoutReporter = class {
366
344
  };
367
345
  }
368
346
  /**
369
- * Wrap the upstream channel manager so every claim grows the open batch and
370
- * every settle closes it. The claim delta is read off storage rather than
371
- * off upstream's result, which carries only a voucher count; under the
372
- * fleet lock the before/after read is consistent. A channel the claim
373
- * removed on its way through — a refund's claim-then-delete (internal-review) —
374
- * moved whatever it still owed before it went, and that value reaches
375
- * `pay_to` in this batch too, so it counts at its pre-claim figure.
347
+ * Read claim deltas from storage because upstream returns voucher counts. Under the fleet
348
+ * lock, before/after reads are consistent. A deleted channel contributes its pre-claim
349
+ * unclaimed value, including refund claim-then-delete.
376
350
  */
377
351
  trackX402Manager(manager) {
378
352
  const claim = async (...args) => {
@@ -502,7 +476,6 @@ var PayoutReporter = class {
502
476
  warn("payout_batch_track_failed", { scope: ctx.scope, error: message(trackErr) });
503
477
  }
504
478
  }
505
- // ── snapshots ─────────────────────────────────────────────────────────
506
479
  /** Every rail this reporter can read, each on its own failure boundary. */
507
480
  async snapshot() {
508
481
  await this.snapshotCashu();
@@ -639,7 +612,7 @@ var PayoutReporter = class {
639
612
  /**
640
613
  * Tempo: each active channel's spent-but-unsettled balance — earned, not
641
614
  * yet paid to the recipient — and the cooperative closes wedged between
642
- * chain and ledger (internal-review), aged past the same floor the repair queue
615
+ * chain and ledger, aged past the same floor the repair queue
643
616
  * uses so an in-flight close is not reported as stuck.
644
617
  */
645
618
  async snapshotTempo() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withSdkInitLock
3
- } from "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-COYKJRMM.js";
4
4
 
5
5
  // src/sdk/server/processed-payment-store.ts
6
6
  var ProcessedPaymentReplayError = class extends Error {
@@ -39,7 +39,7 @@ var PostgresProcessedPaymentStore = class {
39
39
  async init() {
40
40
  await withSdkInitLock(this.pool, () => this.createTables());
41
41
  }
42
- /** The boot DDL itself — always runs under {@link withSdkInitLock} (internal-review). */
42
+ /** The boot DDL itself — always runs under {@link withSdkInitLock}. */
43
43
  async createTables() {
44
44
  await this.pool.query(`
45
45
  CREATE TABLE IF NOT EXISTS processed_payments (
@@ -75,7 +75,6 @@ var TempoSettlementReadiness = class {
75
75
  if (this.timer) clearInterval(this.timer);
76
76
  this.timer = void 0;
77
77
  }
78
- /** Read and report the configured fee-token balance now. */
79
78
  async checkBalance(opts) {
80
79
  if (this.inFlight) {
81
80
  const current = await this.inFlight;
@@ -454,7 +453,7 @@ function buildMppMethods(opts, env) {
454
453
  // Without this mppx installs `Store.memory()`, so the consumed-hash
455
454
  // guard is per-process and a credential replayed onto a sibling machine
456
455
  // (or after a restart) reaches a broadcast the chain then rejects
457
- // instead of a cheap refusal (internal-review).
456
+ // instead of a cheap refusal.
458
457
  ...opts.tempoCharge && { store: opts.tempoCharge.store }
459
458
  })
460
459
  );
@@ -468,7 +467,7 @@ function buildMppMethods(opts, env) {
468
467
  // A server-driven settle/close must spend fees from the same TIP-20
469
468
  // token the channel carries. Leaving this implicit lets an account's
470
469
  // stale fee preference win even when that token has too little left
471
- // to broadcast, while the channel token is funded (internal-review).
470
+ // to broadcast, while the channel token is funded.
472
471
  feeToken: tempoCurrency,
473
472
  decimals: 6,
474
473
  unitType: "request",
@@ -5,21 +5,17 @@ import {
5
5
  // src/sdk/step-cache.ts
6
6
  var StepCache = class _StepCache {
7
7
  cache = /* @__PURE__ */ new Map();
8
- /** Check if a step result is cached. */
9
8
  has(id) {
10
9
  return this.cache.has(id);
11
10
  }
12
- /** Get a cached step result. Throws if not present. */
13
11
  get(id) {
14
12
  return this.getRecord(id).value;
15
13
  }
16
- /** Get a cached step record, including replay metadata. Throws if not present. */
17
14
  getRecord(id) {
18
15
  const record = this.cache.get(id);
19
16
  if (record === void 0) throw new Error(`StepCache: no cached result for step "${id}"`);
20
17
  return record;
21
18
  }
22
- /** Cache a step result. */
23
19
  set(id, value, costs) {
24
20
  this.cache.set(id, {
25
21
  id,
@@ -27,11 +23,9 @@ var StepCache = class _StepCache {
27
23
  ...costs !== void 0 && costs.length > 0 ? { costs: costs.map(({ amount, currency }) => ({ amount, currency })) } : {}
28
24
  });
29
25
  }
30
- /** Export all cached steps for persistence. */
31
26
  serialize() {
32
27
  return [...this.cache.values()];
33
28
  }
34
- /** Restore a StepCache from persisted records. */
35
29
  static deserialize(records) {
36
30
  const cache = new _StepCache();
37
31
  for (const { id, value, costs } of records) {
@@ -10,8 +10,8 @@ import {
10
10
  isDrainMethod,
11
11
  isFundingRail,
12
12
  x402SettlementPending
13
- } from "./chunk-MLRCSJYX.js";
14
- import "./chunk-S3XAHZQY.js";
13
+ } from "./chunk-2D75MNNG.js";
14
+ import "./chunk-COYKJRMM.js";
15
15
  import "./chunk-C3MTFLC6.js";
16
16
  export {
17
17
  CreditLedger,