@dvmkit/sdk 0.3.1-rc.10 → 0.3.2-rc.10

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 (47) hide show
  1. package/dist/{chunk-MD3H3BF7.js → chunk-2A33VHYM.js} +1 -1
  2. package/dist/{chunk-AJNFXR7J.js → chunk-3KYLYVY4.js} +4 -1
  3. package/dist/{chunk-YO56VCTQ.js → chunk-BWGRKGKG.js} +190 -75
  4. package/dist/{chunk-MMCE7XSR.js → chunk-C2AGARLM.js} +1 -13
  5. package/dist/chunk-D42FMCLJ.js +1423 -0
  6. package/dist/{chunk-QX52F6IB.js → chunk-DSVGYW3B.js} +7 -4
  7. package/dist/{chunk-CC3UY6OS.js → chunk-HNIKSOI2.js} +378 -373
  8. package/dist/{chunk-4A2RAKCW.js → chunk-IBDDIG4K.js} +7 -3
  9. package/dist/{chunk-D7YQYLLM.js → chunk-J7PW2U6P.js} +1 -1
  10. package/dist/{chunk-FDKRXOZO.js → chunk-KL4C3LQV.js} +57 -49
  11. package/dist/{chunk-VA7GT6C6.js → chunk-LHN75BTX.js} +56 -53
  12. package/dist/{chunk-C3MTFLC6.js → chunk-M4RSKQAV.js} +14 -12
  13. package/dist/{chunk-U5VNEALI.js → chunk-PPHE7XUU.js} +1 -1
  14. package/dist/{chunk-GAIPXGM3.js → chunk-SP42AI5T.js} +1 -1
  15. package/dist/{chunk-N5B66UOS.js → chunk-U2EYIPFX.js} +4 -1
  16. package/dist/{chunk-H2MEFVH6.js → chunk-UQCK5VMA.js} +7 -4
  17. package/dist/{chunk-XMDQOXHO.js → chunk-Y7JZLO5J.js} +4 -1
  18. package/dist/{chunk-HHTL3ZFT.js → chunk-YEO5GW7U.js} +16 -13
  19. package/dist/{chunk-O6D72KYA.js → chunk-YRDA7EWN.js} +1 -1
  20. package/dist/{chunk-VIVXB4CD.js → chunk-YYQG4R7T.js} +1 -1
  21. package/dist/{chunk-FPOLJRBF.js → chunk-Z3EHBW2G.js} +2 -2
  22. package/dist/{chunk-2D75MNNG.js → chunk-ZHTUITDW.js} +8 -5
  23. package/dist/{chunk-XZ7LW4S5.js → chunk-ZUTI56L7.js} +20 -16
  24. package/dist/{credit-ledger-MHA652TV.js → credit-ledger-4CCHRJE2.js} +3 -2
  25. package/dist/index.js +4 -3
  26. package/dist/internal/caller.d.ts +32 -3
  27. package/dist/internal/caller.js +22 -12
  28. package/dist/internal/index.js +1 -1
  29. package/dist/internal/server.js +16 -15
  30. package/dist/memory-credit-ledger-TERNM5T6.js +10 -0
  31. package/dist/{mpp-setup-MPP3ST5X.js → mpp-setup-OQ4OV7A5.js} +2 -1
  32. package/dist/{payout-reporter-KEMUXEUO.js → payout-reporter-TQ3YIFLZ.js} +2 -1
  33. package/dist/{postgres-consumed-credential-store-6N2V5MJN.js → postgres-consumed-credential-store-LFQNC7LD.js} +4 -1
  34. package/dist/{postgres-job-store-VE2JRUEC.js → postgres-job-store-FGOJ7UIX.js} +2 -1
  35. package/dist/{postgres-replay-store-ZF4JNZOW.js → postgres-replay-store-DFQSXPCG.js} +2 -1
  36. package/dist/{pricing-MU5GNUJZ.js → pricing-UJAPJLOM.js} +2 -1
  37. package/dist/{revenue-reporter-O75BGYFK.js → revenue-reporter-VN4WYN74.js} +2 -1
  38. package/dist/server/index.d.ts +1 -1
  39. package/dist/server/index.js +112 -112
  40. package/dist/{tempo-charge-store-SDTUNTKA.js → tempo-charge-store-EA66LSVJ.js} +2 -1
  41. package/dist/{tempo-lifecycle-G5SB4HFC.js → tempo-lifecycle-TJ62A7UX.js} +3 -3
  42. package/dist/{tempo-session-store-WF3VZXNF.js → tempo-session-store-65NA77KJ.js} +3 -2
  43. package/dist/{tempo-wallet-ZFNUDFVO.js → tempo-wallet-RCGBBAJH.js} +1 -1
  44. package/dist/testing/index.js +4 -3
  45. package/dist/{x402-CI6PSHNO.js → x402-S47Q77UE.js} +2 -2
  46. package/package.json +1 -1
  47. package/dist/memory-credit-ledger-BYBATRN3.js +0 -9
@@ -10,10 +10,10 @@ import {
10
10
  } from "./chunk-BQ2NMWKE.js";
11
11
  import {
12
12
  MemoryCreditLedger
13
- } from "./chunk-U5VNEALI.js";
13
+ } from "./chunk-PPHE7XUU.js";
14
14
  import {
15
15
  PostgresJobStore
16
- } from "./chunk-HHTL3ZFT.js";
16
+ } from "./chunk-YEO5GW7U.js";
17
17
  import {
18
18
  SIGNED_ENVELOPE_FIELDS,
19
19
  SignedRequestError,
@@ -21,7 +21,7 @@ import {
21
21
  humanizeZodIssues,
22
22
  signedRequestInput,
23
23
  zodIssuesOf
24
- } from "./chunk-H2MEFVH6.js";
24
+ } from "./chunk-UQCK5VMA.js";
25
25
  import {
26
26
  JobCancelledError,
27
27
  MemoryJobStore,
@@ -38,7 +38,7 @@ import {
38
38
  localMessage,
39
39
  providerMessage,
40
40
  toJobRecord
41
- } from "./chunk-MD3H3BF7.js";
41
+ } from "./chunk-2A33VHYM.js";
42
42
  import {
43
43
  ADMIN_AUTH_CLOCK_SKEW_SECONDS,
44
44
  ADMIN_AUTH_NONCE_TTL_SECONDS,
@@ -63,7 +63,7 @@ import {
63
63
  toLockPubkey,
64
64
  verifyCashuToken,
65
65
  verifyChallenge
66
- } from "./chunk-QX52F6IB.js";
66
+ } from "./chunk-DSVGYW3B.js";
67
67
  import {
68
68
  X402_BATCH_SETTLEMENT_SCHEME,
69
69
  X402_DEFAULT_FACILITATOR,
@@ -103,7 +103,7 @@ import {
103
103
  pinDimension,
104
104
  withSpan,
105
105
  withTraceContext
106
- } from "./chunk-YO56VCTQ.js";
106
+ } from "./chunk-BWGRKGKG.js";
107
107
  import {
108
108
  FxRateUnavailableError,
109
109
  InvalidCurrencyError,
@@ -112,7 +112,7 @@ import {
112
112
  fxRateFor,
113
113
  resolveFxSourceFromEnv,
114
114
  validateCurrency
115
- } from "./chunk-4A2RAKCW.js";
115
+ } from "./chunk-IBDDIG4K.js";
116
116
  import {
117
117
  fiatToSatsCeil,
118
118
  parseUsdPrice,
@@ -133,18 +133,22 @@ import {
133
133
  isNonChannelBitcoinRail,
134
134
  netOwedSats,
135
135
  x402SettlementPending
136
- } from "./chunk-2D75MNNG.js";
136
+ } from "./chunk-ZHTUITDW.js";
137
137
  import {
138
138
  withSdkInitLock
139
139
  } from "./chunk-COYKJRMM.js";
140
140
  import {
141
141
  withPostgresRecoveryContext
142
- } from "./chunk-C3MTFLC6.js";
142
+ } from "./chunk-M4RSKQAV.js";
143
143
  import {
144
144
  advertisedMethods,
145
145
  challengeMeta,
146
146
  isTempoInsufficientFundsError
147
- } from "./chunk-XZ7LW4S5.js";
147
+ } from "./chunk-ZUTI56L7.js";
148
+ import {
149
+ createDiagnosticCapabilityAuthority,
150
+ diagnosticConsole
151
+ } from "./chunk-D42FMCLJ.js";
148
152
 
149
153
  // src/sdk/server/lock-pubkey-store.ts
150
154
  async function initLockPubkeyTable(db) {
@@ -1010,7 +1014,7 @@ var warned = /* @__PURE__ */ new Set();
1010
1014
  function warnOnce(event, message) {
1011
1015
  if (warned.has(event)) return;
1012
1016
  warned.add(event);
1013
- console.warn(JSON.stringify({ level: "warn", event, message }));
1017
+ diagnosticConsole.warn({ level: "warn", event, message });
1014
1018
  }
1015
1019
 
1016
1020
  // src/sdk/server/funding.ts
@@ -1198,26 +1202,26 @@ function usableCachedRate(fx) {
1198
1202
  function warnStaleRate(cachedAt) {
1199
1203
  if (staleEpisode) return;
1200
1204
  staleEpisode = true;
1201
- console.warn(
1202
- JSON.stringify({
1205
+ diagnosticConsole.warn(
1206
+ {
1203
1207
  level: "btc_rate_stale_fallback",
1204
- message: "BTC/USD rate provider unreachable \u2014 pricing off the last rate this process saw. Amounts may have drifted.",
1208
+ message: void 0,
1205
1209
  cached_at: new Date(cachedAt).toISOString(),
1206
1210
  age: formatStaleness(cachedAt)
1207
- })
1211
+ }
1208
1212
  );
1209
1213
  }
1210
1214
  function warnKnownStaleRefusal(knownStale) {
1211
1215
  if (staleRefusalEpisode) return;
1212
1216
  staleRefusalEpisode = true;
1213
- console.warn(
1214
- JSON.stringify({
1217
+ diagnosticConsole.warn(
1218
+ {
1215
1219
  level: "btc_rate_stale_refused",
1216
- message: "Platform refused a known-stale FX snapshot \u2014 refusing to price x402/mppx off it rather than degrading to the last-known rate.",
1220
+ message: void 0,
1217
1221
  stale_days: knownStale.staleDays,
1218
1222
  stale_source: knownStale.staleSource,
1219
1223
  threshold_days: knownStale.thresholdDays
1220
- })
1224
+ }
1221
1225
  );
1222
1226
  }
1223
1227
  function rateStaleRefused(knownStale) {
@@ -1332,15 +1336,15 @@ function createX402SelfRelay(opts) {
1332
1336
  lowBalanceWei,
1333
1337
  checkedAt
1334
1338
  };
1335
- console.info(
1336
- JSON.stringify({
1339
+ diagnosticConsole.info(
1340
+ {
1337
1341
  level: "info",
1338
1342
  event: "x402_self_relay_gas_balance",
1339
1343
  address: observation.address,
1340
1344
  network: observation.network,
1341
1345
  balance_wei: observation.balanceWei.toString(),
1342
1346
  low_balance_wei: observation.lowBalanceWei.toString()
1343
- })
1347
+ }
1344
1348
  );
1345
1349
  await Promise.all([
1346
1350
  opts.config.onBalance?.(observation),
@@ -1417,8 +1421,8 @@ function createSubmissionLock(lock, network, address) {
1417
1421
  };
1418
1422
  }
1419
1423
  function logSubmissionLockTimeout(error) {
1420
- console.warn(
1421
- JSON.stringify({
1424
+ diagnosticConsole.warn(
1425
+ {
1422
1426
  level: "warn",
1423
1427
  event: "x402_self_relay_submission_lock_timeout",
1424
1428
  lock_key: error.lockKey,
@@ -1430,16 +1434,16 @@ function logSubmissionLockTimeout(error) {
1430
1434
  ...error.holder.state ? { holder_state: error.holder.state } : {},
1431
1435
  ...error.holder.heldSeconds !== void 0 ? { holder_held_seconds: error.holder.heldSeconds } : {}
1432
1436
  } : {}
1433
- })
1437
+ }
1434
1438
  );
1435
1439
  }
1436
- function logBalanceFailure(error) {
1437
- console.warn(
1438
- JSON.stringify({
1440
+ function logBalanceFailure(_error) {
1441
+ diagnosticConsole.warn(
1442
+ {
1439
1443
  level: "warn",
1440
1444
  event: "x402_self_relay_gas_balance_failed",
1441
- error_name: error instanceof Error ? error.name : "unknown"
1442
- })
1445
+ error_name: void 0
1446
+ }
1443
1447
  );
1444
1448
  }
1445
1449
  function classifyX402SelfRelayRpcFailure(error) {
@@ -1470,24 +1474,24 @@ async function reportRpcFailure(config, address, network, reason, checkedAt = Da
1470
1474
  reason,
1471
1475
  checkedAt
1472
1476
  };
1473
- console.warn(
1474
- JSON.stringify({
1477
+ diagnosticConsole.warn(
1478
+ {
1475
1479
  level: "warn",
1476
1480
  event: "x402_self_relay_rpc_failed",
1477
1481
  address,
1478
1482
  network,
1479
1483
  reason
1480
- })
1484
+ }
1481
1485
  );
1482
1486
  await Promise.resolve(config.onRpcHealth?.(observation)).catch(() => {
1483
- console.warn(
1484
- JSON.stringify({
1487
+ diagnosticConsole.warn(
1488
+ {
1485
1489
  level: "warn",
1486
1490
  event: "x402_self_relay_rpc_health_report_failed",
1487
1491
  address,
1488
1492
  network,
1489
1493
  reason
1490
- })
1494
+ }
1491
1495
  );
1492
1496
  });
1493
1497
  }
@@ -1749,7 +1753,7 @@ function createX402FleetSettlementScheduler(opts) {
1749
1753
  });
1750
1754
  const report = (error) => {
1751
1755
  if (config.onError) config.onError(error);
1752
- else console.error("x402 batch-settlement scheduler failed", error);
1756
+ else diagnosticConsole.error("x402 batch-settlement scheduler failed", error);
1753
1757
  };
1754
1758
  const runClaim = async () => {
1755
1759
  const results = await manager.claim({
@@ -1896,13 +1900,13 @@ async function createX402BatchSettlementServer(opts) {
1896
1900
  const selfRelayActive = selfRelayEnabled && !opts.config.facilitatorClient;
1897
1901
  const relayLockOwner = selfRelayActive ? postgres ?? (opts.db ? new PostgresX402ChannelStorage(opts.db) : void 0) : void 0;
1898
1902
  if (selfRelayActive && !relayLockOwner && !opts.allowInMemory) {
1899
- console.warn(
1900
- JSON.stringify({
1903
+ diagnosticConsole.warn(
1904
+ {
1901
1905
  level: "warn",
1902
1906
  event: "x402_self_relay_unserialized",
1903
1907
  network: opts.network,
1904
1908
  detail: "no database for the fleet-wide submission lock; this relay's gas EOA is serialized in-process only"
1905
- })
1909
+ }
1906
1910
  );
1907
1911
  }
1908
1912
  const selfRelay = opts.config.selfRelay && selfRelayActive ? createX402SelfRelay({
@@ -2278,15 +2282,15 @@ async function createX402BatchSettlementServer(opts) {
2278
2282
  const settlement = await resource.settlePayment(payload, matched);
2279
2283
  if (!settlement.success) {
2280
2284
  const operatorErrorMessage = selfRelayEnabled ? void 0 : settlement.errorMessage;
2281
- console.warn(
2282
- JSON.stringify({
2285
+ diagnosticConsole.warn(
2286
+ {
2283
2287
  level: "warn",
2284
2288
  event: "x402_settlement_submission_failed",
2285
2289
  network: settlement.network,
2286
2290
  settlement_id: intent?.settlementId,
2287
2291
  error_reason: settlement.errorReason,
2288
- ...operatorErrorMessage ? { error_message: operatorErrorMessage } : {}
2289
- })
2292
+ ...operatorErrorMessage ? { error_message: void 0 } : {}
2293
+ }
2290
2294
  );
2291
2295
  throw new X402SettlementSubmissionError(
2292
2296
  settlement.errorReason ?? "batch_settlement_failed",
@@ -2329,7 +2333,7 @@ async function createX402BatchSettlementServer(opts) {
2329
2333
  if (postgres) await postgres.withFleetSettlementLock(claim);
2330
2334
  else await claim();
2331
2335
  } catch (error) {
2332
- console.error("x402 batch-settlement withdrawal claim failed", error);
2336
+ diagnosticConsole.error("x402 batch-settlement withdrawal claim failed", error);
2333
2337
  } finally {
2334
2338
  await restoreReservation(storage, funding.channelId, pendingId, channelBeforeVerify);
2335
2339
  }
@@ -3651,7 +3655,7 @@ async function verifyUpfrontPayment(opts) {
3651
3655
  x402Requirements
3652
3656
  });
3653
3657
  }
3654
- const { verifyX402Payment } = await import("./x402-CI6PSHNO.js");
3658
+ const { verifyX402Payment } = await import("./x402-S47Q77UE.js");
3655
3659
  const receipt = await verifyX402Payment(
3656
3660
  x402Payment,
3657
3661
  x402Config,
@@ -3764,16 +3768,16 @@ async function verifyUpfrontPayment(opts) {
3764
3768
  const channelId = mppSessionChannelId(cred);
3765
3769
  const known = channelId ? await mpp.getTempoSessionBinding?.(channelId).catch(() => null) : null;
3766
3770
  if (!known) {
3767
- console.warn(
3768
- JSON.stringify({
3771
+ diagnosticConsole.warn(
3772
+ {
3769
3773
  level: "warn",
3770
3774
  event: "tempo_session_open_refused",
3771
- message: sessionUnavailable.message,
3775
+ message: void 0,
3772
3776
  channel_id: channelId,
3773
3777
  // True means the credit is bound to some *other* channel — a
3774
3778
  // stale client, not a caller trying to open a fresh one.
3775
3779
  credit_channel_bound: sessionIssuable
3776
- })
3780
+ }
3777
3781
  );
3778
3782
  return {
3779
3783
  paidMsats: 0,
@@ -4585,7 +4589,7 @@ async function verifyIncomingPayment(body, opts, snapshot) {
4585
4589
  snapshot
4586
4590
  });
4587
4591
  }
4588
- const { verifyX402Payment } = await import("./x402-CI6PSHNO.js");
4592
+ const { verifyX402Payment } = await import("./x402-S47Q77UE.js");
4589
4593
  const receipt = await verifyX402Payment(
4590
4594
  body.content.x402_payment,
4591
4595
  opts.x402Config,
@@ -5002,7 +5006,7 @@ async function processIncomingPayment(job, body, opts) {
5002
5006
  try {
5003
5007
  const requiredMsats = job.pendingPaymentMsats ?? 0;
5004
5008
  const requiredUsdcMicro = job.pendingX402AmountUsdcMicro !== void 0 ? BigInt(job.pendingX402AmountUsdcMicro) : BigInt(msatsToUsdc(requiredMsats, rate));
5005
- const { verifyX402Payment } = await import("./x402-CI6PSHNO.js");
5009
+ const { verifyX402Payment } = await import("./x402-S47Q77UE.js");
5006
5010
  const receipt = await verifyX402Payment(
5007
5011
  body.content.x402_payment,
5008
5012
  opts.x402Config,
@@ -5373,8 +5377,8 @@ async function resolveTopUpLedgerContext(opts, snapshot, binding) {
5373
5377
  if (askSatisfied && !(snapshot.creditId && snapshot.drawId)) return void 0;
5374
5378
  const dvmId = opts.dvmId ?? "";
5375
5379
  const logTopUp = (event, extra) => {
5376
- console.warn(
5377
- JSON.stringify({
5380
+ diagnosticConsole.warn(
5381
+ {
5378
5382
  level: "warn",
5379
5383
  event,
5380
5384
  rail,
@@ -5382,7 +5386,7 @@ async function resolveTopUpLedgerContext(opts, snapshot, binding) {
5382
5386
  credit_id: snapshot.creditId,
5383
5387
  draw_id: snapshot.drawId,
5384
5388
  ...extra
5385
- })
5389
+ }
5386
5390
  );
5387
5391
  };
5388
5392
  const logSkip = (reason, extra) => {
@@ -6326,25 +6330,25 @@ function oneShotCreditRefusal(instrument) {
6326
6330
  );
6327
6331
  }
6328
6332
  function logCreditRejected(reason, creditId, extra) {
6329
- console.warn(
6330
- JSON.stringify({
6333
+ diagnosticConsole.warn(
6334
+ {
6331
6335
  level: "warn",
6332
6336
  event: "credit_rejected",
6333
6337
  reason,
6334
6338
  credit_id: creditId,
6335
6339
  ...extra
6336
- })
6340
+ }
6337
6341
  );
6338
6342
  }
6339
6343
  function logTempoBindingUnavailable(args) {
6340
- console.warn(
6341
- JSON.stringify({
6344
+ diagnosticConsole.warn(
6345
+ {
6342
6346
  level: "warn",
6343
6347
  event: "tempo_channel_binding_unavailable",
6344
6348
  channel_id: args.channelId,
6345
6349
  credit_id: args.creditId,
6346
6350
  dvm_id: args.dvmId
6347
- })
6351
+ }
6348
6352
  );
6349
6353
  }
6350
6354
  async function resolveRateOrNull(fetcher) {
@@ -6372,16 +6376,16 @@ function x402NotOfferedResult(currency) {
6372
6376
  error: x402NotOfferedPaymentError(currency)
6373
6377
  };
6374
6378
  }
6375
- function logCredentialRejected(rail, phase, err) {
6376
- console.warn(
6377
- JSON.stringify({
6379
+ function logCredentialRejected(rail, phase, _err) {
6380
+ diagnosticConsole.warn(
6381
+ {
6378
6382
  level: "warn",
6379
6383
  event: `${rail}_credential_rejected`,
6380
6384
  phase,
6381
6385
  rail,
6382
- error_name: err instanceof Error ? err.name : void 0,
6383
- error_message: err instanceof Error ? err.message : String(err)
6384
- })
6386
+ error_name: void 0,
6387
+ error_message: void 0
6388
+ }
6385
6389
  );
6386
6390
  }
6387
6391
 
@@ -7978,14 +7982,14 @@ async function lightningIssue(c, deps, args) {
7978
7982
  }
7979
7983
  });
7980
7984
  }
7981
- console.warn(
7982
- JSON.stringify({
7985
+ diagnosticConsole.warn(
7986
+ {
7983
7987
  level: "warn",
7984
7988
  event: "lightning_invoice_issue_failed",
7985
7989
  credit_id: args.creditId,
7986
7990
  fund_id: args.fundId,
7987
- error: err instanceof Error ? err.message : String(err)
7988
- })
7991
+ error: void 0
7992
+ }
7989
7993
  );
7990
7994
  return lightningUnavailable(c, args.menu);
7991
7995
  }
@@ -8238,15 +8242,15 @@ async function replayedFunding(c, deps, args) {
8238
8242
  });
8239
8243
  }
8240
8244
  function creditFundingUnrecorded(c, args) {
8241
- console.warn(
8242
- JSON.stringify({
8245
+ diagnosticConsole.warn(
8246
+ {
8243
8247
  level: "warn",
8244
8248
  event: "credit_funding_unrecorded",
8245
8249
  credit_id: args.creditId,
8246
8250
  fund_id: args.fundId,
8247
8251
  requested_micro: args.requestedMicro,
8248
8252
  ...args.invoiceStatus ? { invoice_status: args.invoiceStatus } : {}
8249
- })
8253
+ }
8250
8254
  );
8251
8255
  return c.json(
8252
8256
  {
@@ -8431,17 +8435,17 @@ async function loadAdminLockPubkeyState(c, opts) {
8431
8435
  return { state: await opts.getLockPubkeyState() };
8432
8436
  } catch (error) {
8433
8437
  const errorCode = safeErrorCode(error);
8434
- console.error(
8435
- JSON.stringify({
8438
+ diagnosticConsole.error(
8439
+ {
8436
8440
  level: "error",
8437
8441
  event: "admin_lock_state_unavailable",
8438
- message: "Admin authentication state could not be loaded; the request failed closed.",
8442
+ message: void 0,
8439
8443
  dvm_id: opts.dvmId,
8440
8444
  method: c.req.method,
8441
8445
  route: c.req.path,
8442
8446
  error_kind: error instanceof Error ? "Error" : typeof error,
8443
8447
  ...errorCode ? { error_code: errorCode } : {}
8444
- })
8448
+ }
8445
8449
  );
8446
8450
  return {
8447
8451
  response: c.json(
@@ -10223,13 +10227,13 @@ function startAccumulatorMonitor(opts) {
10223
10227
  lockKey,
10224
10228
  graceSeconds: opts.lockPubkeyGraceSeconds ?? DEFAULT_LOCK_PUBKEY_GRACE_SECONDS
10225
10229
  });
10226
- } catch (err) {
10227
- console.error(
10228
- JSON.stringify({
10230
+ } catch (_err) {
10231
+ diagnosticConsole.error(
10232
+ {
10229
10233
  level: "wallet_accumulator_tick_error",
10230
10234
  dvmId: opts.dvmId,
10231
- error: err instanceof Error ? err.message : String(err)
10232
- })
10235
+ error: void 0
10236
+ }
10233
10237
  );
10234
10238
  } finally {
10235
10239
  inFlight = null;
@@ -10265,13 +10269,13 @@ async function runTick(opts) {
10265
10269
  try {
10266
10270
  await pruneRetired(client, opts.dvmId, opts.graceSeconds * 1e3, opts.now());
10267
10271
  activeState = await opts.getLockPubkeyState();
10268
- } catch (err) {
10269
- console.error(
10270
- JSON.stringify({
10272
+ } catch (_err) {
10273
+ diagnosticConsole.error(
10274
+ {
10271
10275
  level: "wallet_accumulator_lock_pubkey_prune_failed",
10272
10276
  dvmId: opts.dvmId,
10273
- error: err instanceof Error ? err.message : String(err)
10274
- })
10277
+ error: void 0
10278
+ }
10275
10279
  );
10276
10280
  }
10277
10281
  }
@@ -10315,8 +10319,8 @@ async function emitExpiryEvents(opts, db, activeState) {
10315
10319
  }
10316
10320
  }
10317
10321
  function emitRetiredLockPubkey(dvmId, batch, retiredAtMs) {
10318
- console.log(
10319
- JSON.stringify({
10322
+ diagnosticConsole.log(
10323
+ {
10320
10324
  level: "wallet_accumulator_batch_retired_lock_pubkey",
10321
10325
  dvmId,
10322
10326
  mintUrl: batch.mintUrl,
@@ -10324,24 +10328,24 @@ function emitRetiredLockPubkey(dvmId, batch, retiredAtMs) {
10324
10328
  retiredAtMs,
10325
10329
  totalSats: batch.totalSats,
10326
10330
  rowIds: batch.rowIds
10327
- })
10331
+ }
10328
10332
  );
10329
10333
  }
10330
10334
  function emitOrphanBatch(dvmId, batch) {
10331
- console.log(
10332
- JSON.stringify({
10335
+ diagnosticConsole.log(
10336
+ {
10333
10337
  level: "wallet_accumulator_batch_orphan_lock_pubkey",
10334
10338
  dvmId,
10335
10339
  mintUrl: batch.mintUrl,
10336
10340
  lockPubkey: batch.lockPubkey,
10337
10341
  totalSats: batch.totalSats,
10338
10342
  rowIds: batch.rowIds
10339
- })
10343
+ }
10340
10344
  );
10341
10345
  }
10342
10346
  function emitExpired(dvmId, batch, tExpiredAgoMs) {
10343
- console.log(
10344
- JSON.stringify({
10347
+ diagnosticConsole.log(
10348
+ {
10345
10349
  level: "wallet_accumulator_batch_expired",
10346
10350
  dvmId,
10347
10351
  mintUrl: batch.mintUrl,
@@ -10349,12 +10353,12 @@ function emitExpired(dvmId, batch, tExpiredAgoMs) {
10349
10353
  totalSats: batch.totalSats,
10350
10354
  rowIds: batch.rowIds,
10351
10355
  tExpiredAgoMs
10352
- })
10356
+ }
10353
10357
  );
10354
10358
  }
10355
10359
  function emitExpiringSoon(dvmId, batch, timeToExpireMs) {
10356
- console.log(
10357
- JSON.stringify({
10360
+ diagnosticConsole.log(
10361
+ {
10358
10362
  level: "wallet_accumulator_batch_expiring_soon",
10359
10363
  dvmId,
10360
10364
  mintUrl: batch.mintUrl,
@@ -10362,7 +10366,7 @@ function emitExpiringSoon(dvmId, batch, timeToExpireMs) {
10362
10366
  totalSats: batch.totalSats,
10363
10367
  rowIds: batch.rowIds,
10364
10368
  timeToExpireMs
10365
- })
10369
+ }
10366
10370
  );
10367
10371
  }
10368
10372
  async function reapExpiredKeysetRows(opts, db) {
@@ -10383,15 +10387,15 @@ async function reapExpiredKeysetRows(opts, db) {
10383
10387
  [opts.dvmId, mint_url, proof_keyset_id]
10384
10388
  );
10385
10389
  if ((rowCount ?? 0) > 0) {
10386
- console.log(
10387
- JSON.stringify({
10390
+ diagnosticConsole.log(
10391
+ {
10388
10392
  level: "wallet_accumulator_reaped_expired_keyset",
10389
10393
  dvmId: opts.dvmId,
10390
10394
  mintUrl: mint_url,
10391
10395
  keysetId: proof_keyset_id,
10392
10396
  finalExpiry,
10393
10397
  rowCount
10394
- })
10398
+ }
10395
10399
  );
10396
10400
  }
10397
10401
  }
@@ -10505,12 +10509,12 @@ var JobManager = class {
10505
10509
  );
10506
10510
  }
10507
10511
  if (opts.receiptIssuer && !isReceiptIssuingStore(this.jobStore)) {
10508
- console.warn(
10509
- JSON.stringify({
10512
+ diagnosticConsole.warn(
10513
+ {
10510
10514
  level: "warn",
10511
10515
  event: "receipts_disabled_store_unsupported",
10512
- message: "DVMKIT_RECEIPT_KEY is set but the configured jobStore does not implement ReceiptIssuingStore (claimReceiptSeq / saveReceipt), so no receipts will be issued and /v1/info will not advertise them. Use PostgresJobStore, MemoryJobStore, or implement both methods."
10513
- })
10516
+ message: void 0
10517
+ }
10514
10518
  );
10515
10519
  }
10516
10520
  if (opts.cashuMode === "p2pk-accumulator" && opts.db && opts.dvmId) {
@@ -10519,12 +10523,12 @@ var JobManager = class {
10519
10523
  pool: opts.db,
10520
10524
  dvmId: opts.dvmId
10521
10525
  });
10522
- } catch (err) {
10523
- console.error(
10524
- JSON.stringify({
10526
+ } catch (_err) {
10527
+ diagnosticConsole.error(
10528
+ {
10525
10529
  level: "wallet_accumulator_monitor_start_failed",
10526
- error: err instanceof Error ? err.message : String(err)
10527
- })
10530
+ error: void 0
10531
+ }
10528
10532
  );
10529
10533
  }
10530
10534
  }
@@ -10540,24 +10544,24 @@ var JobManager = class {
10540
10544
  );
10541
10545
  const intervalMs = opts.staleJobSweepIntervalMs ?? Math.min(6e4, Math.max(15e3, Math.floor(tightest / 4)));
10542
10546
  this.staleSweepTimer = setInterval(() => {
10543
- void this.sweepStaleJobs().catch((err) => {
10544
- console.error(
10545
- JSON.stringify({
10547
+ void this.sweepStaleJobs().catch((_err) => {
10548
+ diagnosticConsole.error(
10549
+ {
10546
10550
  level: "stale_job_sweep_failed",
10547
- error: err instanceof Error ? err.message : String(err)
10548
- })
10551
+ error: void 0
10552
+ }
10549
10553
  );
10550
10554
  });
10551
10555
  }, intervalMs);
10552
10556
  this.staleSweepTimer.unref();
10553
10557
  if (this.processingWatchdogMs > 0 && this.heartbeatIntervalMs > 0) {
10554
10558
  this.heartbeatTimer = setInterval(() => {
10555
- void this.heartbeatActiveJobs().catch((err) => {
10556
- console.error(
10557
- JSON.stringify({
10559
+ void this.heartbeatActiveJobs().catch((_err) => {
10560
+ diagnosticConsole.error(
10561
+ {
10558
10562
  level: "job_heartbeat_failed",
10559
- error: err instanceof Error ? err.message : String(err)
10560
- })
10563
+ error: void 0
10564
+ }
10561
10565
  );
10562
10566
  });
10563
10567
  }, this.heartbeatIntervalMs);
@@ -10571,12 +10575,12 @@ var JobManager = class {
10571
10575
  ORPHAN_SWEEP_CLAIMS.add(opts.creditLedger);
10572
10576
  this.orphanSweepClaimed = true;
10573
10577
  this.orphanDrawSweepTimer = setInterval(() => {
10574
- void this.sweepOrphanDraws().catch((err) => {
10575
- console.error(
10576
- JSON.stringify({
10578
+ void this.sweepOrphanDraws().catch((_err) => {
10579
+ diagnosticConsole.error(
10580
+ {
10577
10581
  level: "orphan_draw_sweep_failed",
10578
- error: err instanceof Error ? err.message : String(err)
10579
- })
10582
+ error: void 0
10583
+ }
10580
10584
  );
10581
10585
  });
10582
10586
  }, orphanIntervalMs);
@@ -10584,13 +10588,13 @@ var JobManager = class {
10584
10588
  }
10585
10589
  if (descriptor.jobRetentionDays > 0) {
10586
10590
  if (!isJobRetentionStore(this.jobStore)) {
10587
- console.warn(
10588
- JSON.stringify({
10591
+ diagnosticConsole.warn(
10592
+ {
10589
10593
  level: "warn",
10590
10594
  event: "job_retention_store_unsupported",
10591
10595
  dvm: descriptor.name,
10592
10596
  retentionDays: descriptor.jobRetentionDays
10593
- })
10597
+ }
10594
10598
  );
10595
10599
  } else {
10596
10600
  const pass = () => {
@@ -10610,12 +10614,12 @@ var JobManager = class {
10610
10614
  }
10611
10615
  if (opts.dvmId && (opts.onJobCost || opts.onJobTerminal) && isTerminalCostRecoveryStore(this.jobStore)) {
10612
10616
  this.terminalCostRecoveryTimer = setInterval(() => {
10613
- void this.recoverTerminalCosts().catch((err) => {
10614
- console.error(
10615
- JSON.stringify({
10617
+ void this.recoverTerminalCosts().catch((_err) => {
10618
+ diagnosticConsole.error(
10619
+ {
10616
10620
  level: "terminal_cost_recovery_failed",
10617
- error: err instanceof Error ? err.message : String(err)
10618
- })
10621
+ error: void 0
10622
+ }
10619
10623
  );
10620
10624
  });
10621
10625
  }, TERMINAL_COST_RECOVERY_INTERVAL_MS);
@@ -10987,13 +10991,13 @@ var JobManager = class {
10987
10991
  if (!counters || !isTerminal(counters.status) || counters.status === job.status) return false;
10988
10992
  const durable = await this.jobStore.get(job.id);
10989
10993
  if (!durable) return false;
10990
- console.warn(
10991
- JSON.stringify({
10994
+ diagnosticConsole.warn(
10995
+ {
10992
10996
  level: "job_terminal_elsewhere",
10993
10997
  jobId: job.id,
10994
10998
  durableStatus: durable.status,
10995
10999
  localStatus: job.status
10996
- })
11000
+ }
10997
11001
  );
10998
11002
  job.status = durable.status;
10999
11003
  job.summary = durable.summary;
@@ -11017,7 +11021,7 @@ var JobManager = class {
11017
11021
  const ctx = job.sdkCtx;
11018
11022
  const onCancel = cap.onCancel;
11019
11023
  void Promise.resolve(onCancel(ctx, { reason })).catch((err) => {
11020
- console.error(`[${job.id}] onCancel hook failed after cross-machine cancel:`, err);
11024
+ diagnosticConsole.error(`[${job.id}] onCancel hook failed after cross-machine cancel:`, err);
11021
11025
  });
11022
11026
  }
11023
11027
  this.clearIdleTimer(job.id);
@@ -11042,20 +11046,20 @@ var JobManager = class {
11042
11046
  }
11043
11047
  }
11044
11048
  /** Retry outside the status watcher, which correctly stops once the job is terminal. */
11045
- scheduleTerminalCostHandoffRetry(job, attempt, err) {
11049
+ scheduleTerminalCostHandoffRetry(job, attempt, _err) {
11046
11050
  if (this.terminalCostHandoffRetryTimers.has(job.id)) return;
11047
11051
  const delayMs = Math.min(
11048
11052
  TERMINAL_COST_HANDOFF_RETRY_INITIAL_MS * 2 ** Math.min(attempt - 1, 8),
11049
11053
  TERMINAL_COST_HANDOFF_RETRY_MAX_MS
11050
11054
  );
11051
- console.error(
11052
- JSON.stringify({
11055
+ diagnosticConsole.error(
11056
+ {
11053
11057
  level: "terminal_cost_handoff_retry_scheduled",
11054
11058
  jobId: job.id,
11055
11059
  attempt,
11056
11060
  delayMs,
11057
- error: err instanceof Error ? err.message : String(err)
11058
- })
11061
+ error: void 0
11062
+ }
11059
11063
  );
11060
11064
  const timer = setTimeout(() => {
11061
11065
  this.terminalCostHandoffRetryTimers.delete(job.id);
@@ -11126,13 +11130,13 @@ var JobManager = class {
11126
11130
  return;
11127
11131
  }
11128
11132
  this.statusWatchers.set(jobId, unsubscribe);
11129
- }).catch((err) => {
11130
- console.error(
11131
- JSON.stringify({
11133
+ }).catch((_err) => {
11134
+ diagnosticConsole.error(
11135
+ {
11132
11136
  level: "job_status_watch_subscribe_failed",
11133
11137
  jobId,
11134
- error: err instanceof Error ? err.message : String(err)
11135
- })
11138
+ error: void 0
11139
+ }
11136
11140
  );
11137
11141
  this.statusWatchers.delete(jobId);
11138
11142
  });
@@ -11169,13 +11173,13 @@ var JobManager = class {
11169
11173
  if (isTerminal(job.status)) return;
11170
11174
  if (await this.adoptDurableTerminal(job)) return;
11171
11175
  } while (this.statusChecksQueued.has(job.id));
11172
- } catch (err) {
11173
- console.error(
11174
- JSON.stringify({
11176
+ } catch (_err) {
11177
+ diagnosticConsole.error(
11178
+ {
11175
11179
  level: "job_status_watch_check_failed",
11176
11180
  jobId: job.id,
11177
- error: err instanceof Error ? err.message : String(err)
11178
- })
11181
+ error: void 0
11182
+ }
11179
11183
  );
11180
11184
  } finally {
11181
11185
  this.statusChecksInFlight.delete(job.id);
@@ -11217,9 +11221,9 @@ var JobManager = class {
11217
11221
  content: msg.content
11218
11222
  },
11219
11223
  opts
11220
- ).catch((err) => {
11221
- console.error(
11222
- JSON.stringify({
11224
+ ).catch((_err) => {
11225
+ diagnosticConsole.error(
11226
+ {
11223
11227
  level: "job_message_append_failed",
11224
11228
  jobId,
11225
11229
  // In-memory counter, NOT the authoritative DB-allocated seq:
@@ -11227,9 +11231,9 @@ var JobManager = class {
11227
11231
  // RETURNING` inside the transaction that just failed, so no DB
11228
11232
  // seq was assigned for this message.
11229
11233
  localSeq: msg.seq,
11230
- note: "localSeq is the in-process counter; the DB-allocated seq was never assigned (append rolled back)",
11231
- error: err instanceof Error ? err.message : String(err)
11232
- })
11234
+ note: void 0,
11235
+ error: void 0
11236
+ }
11233
11237
  );
11234
11238
  })
11235
11239
  );
@@ -11369,8 +11373,8 @@ var JobManager = class {
11369
11373
  if (claimed) {
11370
11374
  swept++;
11371
11375
  await this.finalizeStoredTerminal(record.id);
11372
- console.warn(
11373
- JSON.stringify({
11376
+ diagnosticConsole.warn(
11377
+ {
11374
11378
  level: awaiting ? "stale_job_cancelled" : "stale_job_failed",
11375
11379
  jobId: record.id,
11376
11380
  capability: record.capability,
@@ -11388,7 +11392,7 @@ var JobManager = class {
11388
11392
  skewMs: skewMs > 0 ? skewMs : void 0,
11389
11393
  paidMsats: record.paidMsats,
11390
11394
  paymentRail: record.paymentRail
11391
- })
11395
+ }
11392
11396
  );
11393
11397
  if (record.paidMsats > 0 && record.paymentRail && this.opts.onPaidJobDeath) {
11394
11398
  try {
@@ -11405,10 +11409,10 @@ var JobManager = class {
11405
11409
  paymentMint: record.paymentMint
11406
11410
  })
11407
11411
  ).catch((err) => {
11408
- console.error(`[${record.id}] paid-job-death report failed:`, err);
11412
+ diagnosticConsole.error(`[${record.id}] paid-job-death report failed:`, err);
11409
11413
  });
11410
11414
  } catch (err) {
11411
- console.error(`[${record.id}] paid-job-death report failed:`, err);
11415
+ diagnosticConsole.error(`[${record.id}] paid-job-death report failed:`, err);
11412
11416
  }
11413
11417
  }
11414
11418
  const active = this._activeJobs.get(record.id);
@@ -11421,15 +11425,15 @@ var JobManager = class {
11421
11425
  }
11422
11426
  }
11423
11427
  if (skewMs > 0) {
11424
- console.warn(
11425
- JSON.stringify({
11428
+ diagnosticConsole.warn(
11429
+ {
11426
11430
  level: "stale_job_sweep_clock_skew",
11427
11431
  skewMs,
11428
11432
  processingCompensatedMs: this.processingWatchdogMs > 0 ? processingCompensationMs : void 0,
11429
11433
  awaitingCompensatedMs: this.staleJobTimeoutMs > 0 ? awaitingCompensationMs : void 0,
11430
11434
  examined: stale.length,
11431
11435
  swept
11432
- })
11436
+ }
11433
11437
  );
11434
11438
  }
11435
11439
  return { swept };
@@ -11522,13 +11526,13 @@ var JobManager = class {
11522
11526
  } catch (err) {
11523
11527
  const failure = err instanceof Error ? err : new Error(String(err));
11524
11528
  failures.push(failure);
11525
- console.error(
11526
- JSON.stringify({
11529
+ diagnosticConsole.error(
11530
+ {
11527
11531
  level: "error",
11528
11532
  event: "job_retention_candidate_failed",
11529
11533
  jobId: record.id,
11530
- error: failure.message
11531
- })
11534
+ error: void 0
11535
+ }
11532
11536
  );
11533
11537
  }
11534
11538
  }
@@ -11542,8 +11546,8 @@ var JobManager = class {
11542
11546
  throw new AggregateError(failures, `${failures.length} job retention candidate(s) failed`);
11543
11547
  }
11544
11548
  this.jobRetentionResumeFrom = complete ? void 0 : cursor;
11545
- console.log(
11546
- JSON.stringify({
11549
+ diagnosticConsole.log(
11550
+ {
11547
11551
  level: "info",
11548
11552
  event: "job_retention_swept",
11549
11553
  retentionDays: this.descriptor.jobRetentionDays,
@@ -11551,7 +11555,7 @@ var JobManager = class {
11551
11555
  examined,
11552
11556
  redacted,
11553
11557
  complete
11554
- })
11558
+ }
11555
11559
  );
11556
11560
  if (complete) {
11557
11561
  await this.notifyJobRetentionRecovered({ examined, redacted });
@@ -11560,15 +11564,15 @@ var JobManager = class {
11560
11564
  } catch (err) {
11561
11565
  this.jobRetentionResumeFrom = void 0;
11562
11566
  const error = err instanceof Error ? err.message : String(err);
11563
- console.error(
11564
- JSON.stringify({
11567
+ diagnosticConsole.error(
11568
+ {
11565
11569
  level: "error",
11566
11570
  event: "job_retention_sweep_failed",
11567
11571
  retentionDays: this.descriptor.jobRetentionDays,
11568
11572
  examined,
11569
11573
  redacted,
11570
11574
  error
11571
- })
11575
+ }
11572
11576
  );
11573
11577
  await this.notifyJobRetentionFailed(error);
11574
11578
  throw err;
@@ -11612,13 +11616,13 @@ var JobManager = class {
11612
11616
  retentionDays: this.descriptor.jobRetentionDays,
11613
11617
  error
11614
11618
  });
11615
- } catch (callbackError) {
11616
- console.error(
11617
- JSON.stringify({
11619
+ } catch (_callbackError) {
11620
+ diagnosticConsole.error(
11621
+ {
11618
11622
  level: "error",
11619
11623
  event: "job_retention_alert_failed",
11620
- error: callbackError instanceof Error ? callbackError.message : String(callbackError)
11621
- })
11624
+ error: void 0
11625
+ }
11622
11626
  );
11623
11627
  }
11624
11628
  }
@@ -11632,13 +11636,13 @@ var JobManager = class {
11632
11636
  retentionDays: this.descriptor.jobRetentionDays,
11633
11637
  ...result
11634
11638
  });
11635
- } catch (callbackError) {
11636
- console.error(
11637
- JSON.stringify({
11639
+ } catch (_callbackError) {
11640
+ diagnosticConsole.error(
11641
+ {
11638
11642
  level: "error",
11639
11643
  event: "job_retention_recovery_alert_failed",
11640
- error: callbackError instanceof Error ? callbackError.message : String(callbackError)
11641
- })
11644
+ error: void 0
11645
+ }
11642
11646
  );
11643
11647
  }
11644
11648
  }
@@ -11731,8 +11735,8 @@ var JobManager = class {
11731
11735
  this.drawResolutionArgs(draw.creditId, draw.drawId)
11732
11736
  );
11733
11737
  if (!resolution.replayed) released++;
11734
- console.warn(
11735
- JSON.stringify({
11738
+ diagnosticConsole.warn(
11739
+ {
11736
11740
  level: "orphan_draw_released",
11737
11741
  creditId: draw.creditId,
11738
11742
  drawId: draw.drawId,
@@ -11743,18 +11747,18 @@ var JobManager = class {
11743
11747
  reason,
11744
11748
  replayed: resolution.replayed,
11745
11749
  availableMicro: resolution.availableMicro
11746
- })
11750
+ }
11747
11751
  );
11748
11752
  } catch (err) {
11749
- console.warn(
11750
- JSON.stringify({
11753
+ diagnosticConsole.warn(
11754
+ {
11751
11755
  level: "orphan_draw_release_failed",
11752
11756
  creditId: draw.creditId,
11753
11757
  drawId: draw.drawId,
11754
11758
  jobId: draw.jobId,
11755
11759
  code: err instanceof CreditLedgerError ? err.code : void 0,
11756
- error: err instanceof Error ? err.message : String(err)
11757
- })
11760
+ error: void 0
11761
+ }
11758
11762
  );
11759
11763
  }
11760
11764
  }
@@ -11771,8 +11775,8 @@ var JobManager = class {
11771
11775
  }
11772
11776
  }
11773
11777
  this.orphanSweepResumeFrom = cursor;
11774
- console.warn(
11775
- JSON.stringify({
11778
+ diagnosticConsole.warn(
11779
+ {
11776
11780
  level: "orphan_draw_sweep_truncated",
11777
11781
  examined,
11778
11782
  skipped,
@@ -11781,7 +11785,7 @@ var JobManager = class {
11781
11785
  reconciled,
11782
11786
  maxPages: ORPHAN_DRAW_SWEEP_MAX_PAGES,
11783
11787
  resumeAfterCreatedAt: cursor?.createdAt
11784
- })
11788
+ }
11785
11789
  );
11786
11790
  return { released, reconciled };
11787
11791
  } finally {
@@ -11834,8 +11838,8 @@ var JobManager = class {
11834
11838
  }
11835
11839
  }
11836
11840
  const clockSkewMs = nowMs - Date.now();
11837
- console.warn(
11838
- JSON.stringify({
11841
+ diagnosticConsole.warn(
11842
+ {
11839
11843
  level: "orphan_draw_sweep_no_progress",
11840
11844
  examined: tally.examined,
11841
11845
  skipped: tally.skipped,
@@ -11847,7 +11851,7 @@ var JobManager = class {
11847
11851
  oldestPendingAgeMs,
11848
11852
  clockSkewMs: clockSkewMs > 0 ? clockSkewMs : void 0,
11849
11853
  probeError
11850
- })
11854
+ }
11851
11855
  );
11852
11856
  }
11853
11857
  /**
@@ -11888,8 +11892,8 @@ var JobManager = class {
11888
11892
  try {
11889
11893
  const resolution = settle ? await ledger.settle(args) : await ledger.release(args);
11890
11894
  const booked = settle && !resolution.replayed ? await this.bookRevenue(record) : false;
11891
- console.warn(
11892
- JSON.stringify({
11895
+ diagnosticConsole.warn(
11896
+ {
11893
11897
  level: "credit_draw_reconciled",
11894
11898
  creditId: draw.creditId,
11895
11899
  drawId: draw.drawId,
@@ -11903,20 +11907,20 @@ var JobManager = class {
11903
11907
  replayed: resolution.replayed,
11904
11908
  availableMicro: resolution.availableMicro,
11905
11909
  booked
11906
- })
11910
+ }
11907
11911
  );
11908
11912
  return !resolution.replayed;
11909
11913
  } catch (err) {
11910
- console.warn(
11911
- JSON.stringify({
11914
+ diagnosticConsole.warn(
11915
+ {
11912
11916
  level: "credit_draw_reconcile_failed",
11913
11917
  creditId: draw.creditId,
11914
11918
  drawId: draw.drawId,
11915
11919
  jobId: draw.jobId,
11916
11920
  jobStatus: record.status,
11917
11921
  code: err instanceof CreditLedgerError ? err.code : void 0,
11918
- error: err instanceof Error ? err.message : String(err)
11919
- })
11922
+ error: void 0
11923
+ }
11920
11924
  );
11921
11925
  return false;
11922
11926
  }
@@ -12064,13 +12068,13 @@ var JobManager = class {
12064
12068
  domain
12065
12069
  );
12066
12070
  } catch (err) {
12067
- console.warn(
12068
- JSON.stringify({
12071
+ diagnosticConsole.warn(
12072
+ {
12069
12073
  level: "auth_reverify_failed",
12070
12074
  jobId: record.id,
12071
12075
  capability: record.capability,
12072
12076
  sub_reason: err instanceof SignedRequestError ? err.sub_reason : "unknown"
12073
- })
12077
+ }
12074
12078
  );
12075
12079
  throw err;
12076
12080
  }
@@ -12225,8 +12229,8 @@ var JobManager = class {
12225
12229
  job.drawId = result.drawId;
12226
12230
  if (info.creditId && result.creditId !== info.creditId) {
12227
12231
  unappliedCredit = this.unappliedCredit(info.funding, info.creditId, "unbound");
12228
- console.warn(
12229
- JSON.stringify({
12232
+ diagnosticConsole.warn(
12233
+ {
12230
12234
  level: "warn",
12231
12235
  event: "credit_topup_unbound",
12232
12236
  job_id: job.id,
@@ -12234,7 +12238,7 @@ var JobManager = class {
12234
12238
  draw_id: info.drawId,
12235
12239
  bound_credit_id: result.creditId,
12236
12240
  bound_draw_id: result.drawId
12237
- })
12241
+ }
12238
12242
  );
12239
12243
  }
12240
12244
  } else {
@@ -12269,8 +12273,8 @@ var JobManager = class {
12269
12273
  unappliedCredit = this.unappliedCredit(info.funding, info.funding?.creditId, "over_ask", {
12270
12274
  creditedMicro: info.unappliedMicro
12271
12275
  });
12272
- console.warn(
12273
- JSON.stringify({
12276
+ diagnosticConsole.warn(
12277
+ {
12274
12278
  level: "warn",
12275
12279
  event: "credit_topup_over_ask",
12276
12280
  job_id: job.id,
@@ -12278,7 +12282,7 @@ var JobManager = class {
12278
12282
  draw_id: info.drawId,
12279
12283
  unapplied_micro: info.unappliedMicro,
12280
12284
  funded_micro: info.funding?.amountMicro
12281
- })
12285
+ }
12282
12286
  );
12283
12287
  }
12284
12288
  this.reportCreditDeposit(info.funding);
@@ -12328,15 +12332,15 @@ var JobManager = class {
12328
12332
  } catch (err) {
12329
12333
  lastErr = err;
12330
12334
  if (attempt === CREDIT_INBOUND_ATTEMPTS) break;
12331
- console.warn(
12332
- JSON.stringify({
12335
+ diagnosticConsole.warn(
12336
+ {
12333
12337
  level: "warn",
12334
12338
  event: "credit_job_row_retry",
12335
12339
  job_id: jobId,
12336
12340
  seq,
12337
12341
  attempt,
12338
- error: errText(err)
12339
- })
12342
+ error: void 0
12343
+ }
12340
12344
  );
12341
12345
  await new Promise((resolve) => setTimeout(resolve, CREDIT_INBOUND_BACKOFF_MS * attempt));
12342
12346
  }
@@ -12355,16 +12359,16 @@ var JobManager = class {
12355
12359
  }
12356
12360
  }
12357
12361
  if (landed) {
12358
- console.warn(
12359
- JSON.stringify({
12362
+ diagnosticConsole.warn(
12363
+ {
12360
12364
  level: "warn",
12361
12365
  event: "credit_job_row_recovered",
12362
12366
  job_id: jobId,
12363
12367
  seq,
12364
12368
  credit_id: landed.creditId,
12365
12369
  draw_id: landed.drawId,
12366
- error: errText(lastErr)
12367
- })
12370
+ error: void 0
12371
+ }
12368
12372
  );
12369
12373
  return landed;
12370
12374
  }
@@ -12405,8 +12409,8 @@ var JobManager = class {
12405
12409
  const funding = info.funding;
12406
12410
  const readErr = err instanceof CreditInboundExhaustedError ? err.readError : void 0;
12407
12411
  const rowChecked = err instanceof CreditInboundExhaustedError && readErr === void 0;
12408
- console.error(
12409
- JSON.stringify({
12412
+ diagnosticConsole.error(
12413
+ {
12410
12414
  level: "error",
12411
12415
  event: "credit_job_row_unwritten",
12412
12416
  job_id: job.id,
@@ -12415,13 +12419,13 @@ var JobManager = class {
12415
12419
  paid_msats: info.paidMsats,
12416
12420
  credit_id: funding?.creditId ?? info.creditId,
12417
12421
  draw_id: info.drawId,
12418
- error: errText(err),
12422
+ error: void 0,
12419
12423
  // `false` means the job row's credit state is unknown, not that it is
12420
12424
  // clean — the difference between a payment that provably didn't land and
12421
12425
  // one nobody could ask about.
12422
12426
  row_checked: rowChecked,
12423
12427
  ...readErr !== void 0 && { read_error: errText(readErr) }
12424
- })
12428
+ }
12425
12429
  );
12426
12430
  if (isStreamableJobStore(this.jobStore)) {
12427
12431
  await this.jobStore.markInboundFailed(job.id, inboundSeq, "payment_unapplied").catch(() => void 0);
@@ -12468,7 +12472,7 @@ var JobManager = class {
12468
12472
  if (!funding || !onCreditFunded || !this.opts.dvmId) return;
12469
12473
  Promise.resolve(onCreditFunded(creditDepositPayload(this.opts.dvmId, funding))).catch(
12470
12474
  (err) => {
12471
- console.error(`[${funding.creditId}] Deposit reporting failed:`, err);
12475
+ diagnosticConsole.error(`[${funding.creditId}] Deposit reporting failed:`, err);
12472
12476
  }
12473
12477
  );
12474
12478
  }
@@ -12567,8 +12571,8 @@ var JobManager = class {
12567
12571
  }
12568
12572
  /** Internal: structured warn for the one path that can't price a drawn job's pool. */
12569
12573
  warnDrawPool(job, reason, error) {
12570
- console.warn(
12571
- JSON.stringify({
12574
+ diagnosticConsole.warn(
12575
+ {
12572
12576
  level: "warn",
12573
12577
  event: "draw_pool_unpriced",
12574
12578
  reason,
@@ -12576,7 +12580,7 @@ var JobManager = class {
12576
12580
  creditId: job.creditId,
12577
12581
  drawId: job.drawId,
12578
12582
  ...error !== void 0 && { error }
12579
- })
12583
+ }
12580
12584
  );
12581
12585
  }
12582
12586
  /**
@@ -12603,7 +12607,7 @@ var JobManager = class {
12603
12607
  try {
12604
12608
  await callback({ jobId: record.id, rail, amountMicro: draw.amountMicro, currency, testFunds });
12605
12609
  } catch (error) {
12606
- console.error(`[${record.id}] Paid completion observer failed:`, error);
12610
+ diagnosticConsole.error(`[${record.id}] Paid completion observer failed:`, error);
12607
12611
  }
12608
12612
  }
12609
12613
  async issueReceipt(record) {
@@ -12615,17 +12619,17 @@ var JobManager = class {
12615
12619
  let credit;
12616
12620
  try {
12617
12621
  credit = await this.resolveCreditDraw(record);
12618
- } catch (err) {
12619
- console.error(
12620
- JSON.stringify({
12622
+ } catch (_err) {
12623
+ diagnosticConsole.error(
12624
+ {
12621
12625
  level: "error",
12622
12626
  event: "credit_resolve_failed",
12623
12627
  jobId: record.id,
12624
12628
  creditId: record.creditId,
12625
12629
  drawId: record.drawId,
12626
12630
  status: record.status,
12627
- error: err instanceof Error ? err.message : String(err)
12628
- })
12631
+ error: void 0
12632
+ }
12629
12633
  );
12630
12634
  return void 0;
12631
12635
  }
@@ -12642,15 +12646,15 @@ var JobManager = class {
12642
12646
  const saved = await store.saveReceipt(record.id, receipt) ?? receipt;
12643
12647
  await this.observePaidCompletion(record);
12644
12648
  return saved;
12645
- } catch (err) {
12646
- console.error(
12647
- JSON.stringify({
12649
+ } catch (_err) {
12650
+ diagnosticConsole.error(
12651
+ {
12648
12652
  level: "error",
12649
12653
  event: "receipt_issue_failed",
12650
12654
  jobId: record.id,
12651
12655
  status: record.status,
12652
- error: err instanceof Error ? err.message : String(err)
12653
- })
12656
+ error: void 0
12657
+ }
12654
12658
  );
12655
12659
  return void 0;
12656
12660
  }
@@ -12692,8 +12696,8 @@ var JobManager = class {
12692
12696
  if (err instanceof CreditLedgerError && err.code === "invalid_draw_state") {
12693
12697
  const rec = await ledger.getDraw(args);
12694
12698
  if (!rec) return void 0;
12695
- console.warn(
12696
- JSON.stringify({
12699
+ diagnosticConsole.warn(
12700
+ {
12697
12701
  level: "warn",
12698
12702
  event: "credit_resolve_state_mismatch",
12699
12703
  jobId: record.id,
@@ -12701,7 +12705,7 @@ var JobManager = class {
12701
12705
  drawId: record.drawId,
12702
12706
  jobStatus: record.status,
12703
12707
  drawStatus: rec.status
12704
- })
12708
+ }
12705
12709
  );
12706
12710
  return {
12707
12711
  credit_id: rec.creditId,
@@ -12829,7 +12833,7 @@ var JobManager = class {
12829
12833
  await this.jobStore.markTerminalReported(jobId);
12830
12834
  }
12831
12835
  } catch (error) {
12832
- console.error(`[${jobId}] Terminal reporting failed:`, error);
12836
+ diagnosticConsole.error(`[${jobId}] Terminal reporting failed:`, error);
12833
12837
  }
12834
12838
  }
12835
12839
  terminalReportRecoveryCursor;
@@ -12889,28 +12893,28 @@ var JobManager = class {
12889
12893
  if (candidates.length < TERMINAL_COST_RECOVERY_BATCH) {
12890
12894
  this.terminalCostRecoveryResumeAfter = void 0;
12891
12895
  if (examined > 0) {
12892
- console.log(
12893
- JSON.stringify({
12896
+ diagnosticConsole.log(
12897
+ {
12894
12898
  level: "info",
12895
12899
  event: "terminal_cost_recovery_complete",
12896
12900
  dvmId,
12897
12901
  examined,
12898
12902
  queued
12899
- })
12903
+ }
12900
12904
  );
12901
12905
  }
12902
12906
  return { examined, queued, complete: true };
12903
12907
  }
12904
12908
  }
12905
12909
  this.terminalCostRecoveryResumeAfter = cursor;
12906
- console.warn(
12907
- JSON.stringify({
12910
+ diagnosticConsole.warn(
12911
+ {
12908
12912
  level: "terminal_cost_recovery_truncated",
12909
12913
  dvmId,
12910
12914
  examined,
12911
12915
  queued,
12912
12916
  resumeAfterJobId: cursor
12913
- })
12917
+ }
12914
12918
  );
12915
12919
  return { examined, queued, complete: false };
12916
12920
  } finally {
@@ -12942,7 +12946,7 @@ var JobManager = class {
12942
12946
  }
12943
12947
  }
12944
12948
  } catch (err) {
12945
- console.error(`[${job.id}] Job cost reporting failed:`, err);
12949
+ diagnosticConsole.error(`[${job.id}] Job cost reporting failed:`, err);
12946
12950
  return false;
12947
12951
  }
12948
12952
  return true;
@@ -13003,15 +13007,15 @@ var JobManager = class {
13003
13007
  const args = { creditId: job.creditId, drawId: job.drawId };
13004
13008
  const draw = await this.opts.creditLedger.getDraw(args).catch(() => void 0);
13005
13009
  if (draw?.status !== "settled") {
13006
- console.warn(
13007
- JSON.stringify({
13010
+ diagnosticConsole.warn(
13011
+ {
13008
13012
  level: "warn",
13009
13013
  event: "revenue_skipped_unsettled_draw",
13010
13014
  jobId: job.id,
13011
13015
  creditId: job.creditId,
13012
13016
  drawId: job.drawId,
13013
13017
  drawStatus: draw?.status ?? "missing"
13014
- })
13018
+ }
13015
13019
  );
13016
13020
  return false;
13017
13021
  }
@@ -13035,8 +13039,8 @@ var JobManager = class {
13035
13039
  if (job.creditId && job.drawId) {
13036
13040
  const creditCurrency = typeof credit.creditCurrency === "string" ? credit.creditCurrency : void 0;
13037
13041
  const reason = creditRail === void 0 ? "ledger_not_configured" : creditRail === null ? "credit_rail_null" : isFundingRail(creditRail) ? "job_rail_missing" : "credit_rail_unrecognized";
13038
- console.warn(
13039
- JSON.stringify({
13042
+ diagnosticConsole.warn(
13043
+ {
13040
13044
  level: "warn",
13041
13045
  event: "revenue_skipped_no_rail",
13042
13046
  jobId: job.id,
@@ -13058,7 +13062,7 @@ var JobManager = class {
13058
13062
  // database one, and the only arm where the debit is reported on
13059
13063
  // the job row's word rather than the ledger's.
13060
13064
  reason
13061
- })
13065
+ }
13062
13066
  );
13063
13067
  if (onRevenueSkippedNoRail) {
13064
13068
  Promise.resolve(
@@ -13074,7 +13078,7 @@ var JobManager = class {
13074
13078
  reason
13075
13079
  })
13076
13080
  ).catch((err) => {
13077
- console.error(`[${job.id}] Revenue skip alert reporting failed:`, err);
13081
+ diagnosticConsole.error(`[${job.id}] Revenue skip alert reporting failed:`, err);
13078
13082
  });
13079
13083
  }
13080
13084
  }
@@ -13103,7 +13107,7 @@ var JobManager = class {
13103
13107
  ...credit
13104
13108
  })
13105
13109
  ).catch((err) => {
13106
- console.error(`[${job.id}] Revenue reporting failed:`, err);
13110
+ diagnosticConsole.error(`[${job.id}] Revenue reporting failed:`, err);
13107
13111
  });
13108
13112
  return true;
13109
13113
  }
@@ -13376,14 +13380,14 @@ var MintHealthTracker = class {
13376
13380
  };
13377
13381
  this.state.set(key, next);
13378
13382
  if (previous.sick) {
13379
- console.log(
13380
- JSON.stringify({
13383
+ diagnosticConsole.log(
13384
+ {
13381
13385
  level: "cashu_mint_runtime_recovered",
13382
13386
  mintUrl,
13383
13387
  latencyMs: result.latencyMs,
13384
13388
  version: result.version,
13385
13389
  observedAt: this.nowFn()
13386
- })
13390
+ }
13387
13391
  );
13388
13392
  }
13389
13393
  return;
@@ -13400,21 +13404,19 @@ var MintHealthTracker = class {
13400
13404
  errorCode: nutIncompatible ? "nut_support_missing" : result.error?.code
13401
13405
  });
13402
13406
  if (!previous.sick && sick) {
13403
- console.log(
13404
- JSON.stringify(
13405
- nutIncompatible ? {
13406
- level: "cashu_mint_nut_incompatible",
13407
- mintUrl,
13408
- version: result.version,
13409
- observedAt: this.nowFn()
13410
- } : {
13411
- level: "cashu_mint_runtime_sick",
13412
- mintUrl,
13413
- consecutiveFailures,
13414
- error: result.error,
13415
- observedAt: this.nowFn()
13416
- }
13417
- )
13407
+ diagnosticConsole.log(
13408
+ nutIncompatible ? {
13409
+ level: "cashu_mint_nut_incompatible",
13410
+ mintUrl,
13411
+ version: result.version,
13412
+ observedAt: this.nowFn()
13413
+ } : {
13414
+ level: "cashu_mint_runtime_sick",
13415
+ mintUrl,
13416
+ consecutiveFailures,
13417
+ error: void 0,
13418
+ observedAt: this.nowFn()
13419
+ }
13418
13420
  );
13419
13421
  }
13420
13422
  }
@@ -13429,8 +13431,8 @@ var MintHealthTracker = class {
13429
13431
  errorCode: s.errorCode
13430
13432
  }));
13431
13433
  const healthy = mints.filter((m) => m.probeOk).length;
13432
- console.log(
13433
- JSON.stringify({
13434
+ diagnosticConsole.log(
13435
+ {
13434
13436
  level: healthy === 0 && mints.length > 0 ? "warn" : "cashu_mint_boot_health",
13435
13437
  event: "cashu_mint_boot_health",
13436
13438
  healthyMints: healthy,
@@ -13438,7 +13440,7 @@ var MintHealthTracker = class {
13438
13440
  allUnhealthy: healthy === 0 && mints.length > 0,
13439
13441
  mints,
13440
13442
  observedAt: this.nowFn()
13441
- })
13443
+ }
13442
13444
  );
13443
13445
  }
13444
13446
  };
@@ -14117,16 +14119,16 @@ var X402FacilitatorHealth = class {
14117
14119
  if (ageMs >= this.maxStalenessMs) {
14118
14120
  if (this.ceilingLoggedForMs !== observedAtMs) {
14119
14121
  this.ceilingLoggedForMs = observedAtMs;
14120
- console.warn(
14121
- JSON.stringify({
14122
+ diagnosticConsole.warn(
14123
+ {
14122
14124
  level: "warn",
14123
14125
  event: "x402_facilitator_staleness_ceiling",
14124
14126
  facilitator: this.facilitator,
14125
14127
  network: this.network,
14126
14128
  age_ms: ageMs,
14127
14129
  staleness_ceiling_ms: this.maxStalenessMs,
14128
- message: "x402 removed from the payment menu because the facilitator capability observation is too old."
14129
- })
14130
+ message: void 0
14131
+ }
14130
14132
  );
14131
14133
  }
14132
14134
  return unavailableSupport(
@@ -14152,17 +14154,17 @@ var X402FacilitatorHealth = class {
14152
14154
  const { support } = read;
14153
14155
  if (support.reason === "probe_failed") {
14154
14156
  const observedAtMs = this.observation?.observedAtMs ?? this.startedAtMs;
14155
- console.warn(
14156
- JSON.stringify({
14157
+ diagnosticConsole.warn(
14158
+ {
14157
14159
  level: "warn",
14158
14160
  event: "x402_facilitator_fallback",
14159
14161
  facilitator: support.facilitator,
14160
14162
  network: support.network,
14161
- error: support.error,
14163
+ error: void 0,
14162
14164
  age_ms: Math.max(0, this.now() - observedAtMs),
14163
14165
  staleness_ceiling_ms: this.maxStalenessMs,
14164
- message: "Facilitator capability probe failed; x402 keeps its last exact support until the staleness ceiling."
14165
- })
14166
+ message: void 0
14167
+ }
14166
14168
  );
14167
14169
  return;
14168
14170
  }
@@ -14170,19 +14172,19 @@ var X402FacilitatorHealth = class {
14170
14172
  this.lastSupportedResponse = read.response;
14171
14173
  this.ceilingLoggedForMs = void 0;
14172
14174
  if (!support.available) {
14173
- console.warn(
14174
- JSON.stringify({
14175
+ diagnosticConsole.warn(
14176
+ {
14175
14177
  level: "warn",
14176
14178
  event: "x402_facilitator_unavailable",
14177
14179
  facilitator: support.facilitator,
14178
14180
  network: support.network,
14179
14181
  reason: support.reason,
14180
- message: "Exact x402 is unavailable because the configured facilitator advertises no supported exact generation on this network. Configured batch settlement is evaluated separately; other rails are unaffected."
14181
- })
14182
+ message: void 0
14183
+ }
14182
14184
  );
14183
14185
  } else if (!support.exact.v1 || !support.exact.v2 || this.config.batchSettlement && !support.batchSettlement) {
14184
- console.warn(
14185
- JSON.stringify({
14186
+ diagnosticConsole.warn(
14187
+ {
14186
14188
  level: "warn",
14187
14189
  event: "x402_facilitator_capability_degraded",
14188
14190
  facilitator: support.facilitator,
@@ -14190,8 +14192,8 @@ var X402FacilitatorHealth = class {
14190
14192
  exact_v1: support.exact.v1,
14191
14193
  exact_v2: support.exact.v2,
14192
14194
  batch_settlement: support.batchSettlement,
14193
- message: "x402 is serving only the protocol generations and channel scheme advertised by the facilitator."
14194
- })
14195
+ message: void 0
14196
+ }
14195
14197
  );
14196
14198
  }
14197
14199
  }
@@ -15070,11 +15072,11 @@ async function handleWriteOffInvoice(c, opts) {
15070
15072
  );
15071
15073
  }
15072
15074
  if (outcome.written) {
15073
- console.warn(
15074
- JSON.stringify({
15075
+ diagnosticConsole.warn(
15076
+ {
15075
15077
  level: "warn",
15076
15078
  event: "lightning_invoice_written_off",
15077
- message: "An operator closed a blocked Lightning funding invoice without crediting it. The received sats stay in the wallet and no caller balance was created for them.",
15079
+ message: void 0,
15078
15080
  payment_hash: written.paymentHash,
15079
15081
  credit_id: written.creditId,
15080
15082
  fund_id: written.fundId,
@@ -15082,8 +15084,8 @@ async function handleWriteOffInvoice(c, opts) {
15082
15084
  amount_msats: written.amountMsats,
15083
15085
  amount_micro: written.amountMicro,
15084
15086
  currency: written.currency,
15085
- note: written.writeOffNote
15086
- })
15087
+ note: void 0
15088
+ }
15087
15089
  );
15088
15090
  }
15089
15091
  return c.json({
@@ -15263,19 +15265,19 @@ async function handleWriteOffX402(c, opts) {
15263
15265
  if ("refusal" in outcome) return x402RefusalResponse(c, outcome);
15264
15266
  if (outcome.written) {
15265
15267
  const credit = await opts.ledger.getCreditByX402Channel(outcome.intent.channelId);
15266
- console.warn(
15267
- JSON.stringify({
15268
+ diagnosticConsole.warn(
15269
+ {
15268
15270
  level: "warn",
15269
15271
  event: "x402_settlement_written_off",
15270
- message: "An operator closed a wedged x402 settlement without booking it. If the refund did reach the chain, the caller's credit balance is still on this ledger and is reclaimable with a fresh drain id.",
15272
+ message: void 0,
15271
15273
  settlement_id: outcome.intent.settlementId,
15272
15274
  channel_id: outcome.intent.channelId,
15273
15275
  operation: outcome.intent.operation,
15274
15276
  effect_id: outcome.intent.effectId,
15275
15277
  credit_id: credit?.creditId ?? null,
15276
15278
  settled_amount: outcome.intent.response?.amount ?? null,
15277
- note: outcome.intent.writeOffNote
15278
- })
15279
+ note: void 0
15280
+ }
15279
15281
  );
15280
15282
  }
15281
15283
  return c.json({
@@ -15454,19 +15456,19 @@ async function handleWriteOffTempo(c, opts) {
15454
15456
  return tempoNotWedgedRefusal(c, parsed, outcome.drain.status);
15455
15457
  }
15456
15458
  if (outcome.written) {
15457
- console.warn(
15458
- JSON.stringify({
15459
+ diagnosticConsole.warn(
15460
+ {
15459
15461
  level: "warn",
15460
15462
  event: "tempo_drain_written_off",
15461
- message: "An operator closed a wedged Tempo cooperative close without booking it. The caller's on-chain refund landed short of the balance this ledger extinguished; that difference is not expressible in any dvmkit row and must be made good out of band.",
15463
+ message: void 0,
15462
15464
  credit_id: outcome.drain.creditId,
15463
15465
  drain_id: outcome.drain.drainId,
15464
15466
  channel_id: outcome.drain.channelId,
15465
15467
  amount_micro: outcome.drain.amountMicro,
15466
15468
  amount_native: outcome.drain.drainedNative,
15467
15469
  currency: outcome.drain.currency,
15468
- note: outcome.drain.writeOffNote
15469
- })
15470
+ note: void 0
15471
+ }
15470
15472
  );
15471
15473
  }
15472
15474
  return c.json({
@@ -16100,19 +16102,19 @@ function startCreditExpirySweep(ledger, opts = {}) {
16100
16102
  if (stopped) return;
16101
16103
  void runOnce().then(({ released }) => {
16102
16104
  if (released.length === 0) return;
16103
- console.log(
16104
- JSON.stringify({
16105
+ diagnosticConsole.log(
16106
+ {
16105
16107
  level: "credit_expiry_released",
16106
16108
  count: released.length,
16107
16109
  credits: released.map((r) => r.creditId)
16108
- })
16110
+ }
16109
16111
  );
16110
- }).catch((err) => {
16111
- console.error(
16112
- JSON.stringify({
16112
+ }).catch((_err) => {
16113
+ diagnosticConsole.error(
16114
+ {
16113
16115
  level: "credit_expiry_sweep_failed",
16114
- error: err instanceof Error ? err.message : String(err)
16115
- })
16116
+ error: void 0
16117
+ }
16116
16118
  );
16117
16119
  });
16118
16120
  };
@@ -17094,7 +17096,7 @@ function assertRevenueReporterReady(opts) {
17094
17096
  const missing = Object.entries(pieces).filter(([, v]) => !v).map(([k]) => k);
17095
17097
  if (missing.length === 0) return;
17096
17098
  const msg = `[FATAL] Platform-hosted DVM with incomplete revenue-reporter wiring. DVMKIT_PLATFORM_URL is set but missing: ${missing.join(", ")}. Either complete the configuration or unset DVMKIT_PLATFORM_URL to opt out.`;
17097
- console.error(msg);
17099
+ diagnosticConsole.error(msg);
17098
17100
  throw new Error(msg);
17099
17101
  }
17100
17102
  function revenueReporterBannerState(s) {
@@ -17150,11 +17152,11 @@ async function createDVMServer(descriptor, opts) {
17150
17152
  })();
17151
17153
  try {
17152
17154
  if (opts.env.DVMKIT_CASHU_MINTS && opts.cashuMode === void 0) {
17153
- console.warn(
17154
- JSON.stringify({
17155
+ diagnosticConsole.warn(
17156
+ {
17155
17157
  level: "cashu_opts_env_ignored",
17156
- message: "DVMKIT_CASHU_MINTS is set in env but cashuMode opt is undefined \u2014 cashu is NOT active. Pass cashuMode, lockPubkey, and db via createDVMHost to enable it."
17157
- })
17158
+ message: void 0
17159
+ }
17158
17160
  );
17159
17161
  }
17160
17162
  const envMaybe = opts.env;
@@ -17162,12 +17164,12 @@ async function createDVMServer(descriptor, opts) {
17162
17164
  const platformUrl = opts.platformUrl ?? envMaybe.DVMKIT_PLATFORM_URL;
17163
17165
  const dvmId = opts.dvmId;
17164
17166
  if (!opts.onJobCompleted && platformToken && platformUrl && dvmId && opts.db) {
17165
- const { RevenueReporter } = await import("./revenue-reporter-O75BGYFK.js");
17167
+ const { RevenueReporter } = await import("./revenue-reporter-VN4WYN74.js");
17166
17168
  const reporter = new RevenueReporter(opts.db, platformUrl, platformToken);
17167
17169
  revenueReporter = reporter;
17168
17170
  await reporter.init();
17169
17171
  reporter.startRetryLoop();
17170
- const { MemoryX402BatchStore, PayoutReporter } = await import("./payout-reporter-KEMUXEUO.js");
17172
+ const { MemoryX402BatchStore, PayoutReporter } = await import("./payout-reporter-TQ3YIFLZ.js");
17171
17173
  payoutReporter = new PayoutReporter({
17172
17174
  dvmId,
17173
17175
  db: opts.db,
@@ -17394,8 +17396,12 @@ var DVMServer = class {
17394
17396
  /** Withdraws this mount's Tempo session capability from the poll. */
17395
17397
  undeclareSessionCapability;
17396
17398
  hostingSweepTimer;
17399
+ diagnosticCapabilityAuthority;
17397
17400
  constructor(descriptor, opts) {
17398
17401
  this.descriptor = descriptor;
17402
+ this.diagnosticCapabilityAuthority = createDiagnosticCapabilityAuthority(
17403
+ Object.keys(descriptor.capabilities)
17404
+ );
17399
17405
  this.pricingCurrency = descriptor.currency ?? "usd";
17400
17406
  this.opts = opts;
17401
17407
  this.publicOrigin = resolvePublicOrigin(opts.env.DVMKIT_PUBLIC_URL);
@@ -17480,12 +17486,12 @@ var DVMServer = class {
17480
17486
  if (opts.hostingControlInstance) {
17481
17487
  this.hostingSweepTimer = setInterval(() => {
17482
17488
  void this.sweepHostingDeadline().catch((error) => {
17483
- console.error("Hosting deadline sweep failed:", error);
17489
+ diagnosticConsole.error("Hosting deadline sweep failed:", error);
17484
17490
  });
17485
17491
  }, 1e3);
17486
17492
  this.hostingSweepTimer.unref();
17487
17493
  void this.sweepHostingDeadline().catch((error) => {
17488
- console.error("Hosting deadline sweep failed:", error);
17494
+ diagnosticConsole.error("Hosting deadline sweep failed:", error);
17489
17495
  });
17490
17496
  }
17491
17497
  if (this.ownsMintHealthTracker) this.mintHealthTracker?.start();
@@ -17566,7 +17572,6 @@ var DVMServer = class {
17566
17572
  }
17567
17573
  registerRoutes() {
17568
17574
  const dvmSlug = this.descriptor.name;
17569
- const builderPubkey = this.opts.builder?.pubkey;
17570
17575
  this.app.use("*", async (c, next) => {
17571
17576
  const raw = c.req.header("traceparent");
17572
17577
  const parsed = raw ? parseTraceparent(raw) : null;
@@ -17575,12 +17580,12 @@ var DVMServer = class {
17575
17580
  spanId: parsed ? parsed.parentSpanId : null,
17576
17581
  dimensions: {},
17577
17582
  service: `isolate-${dvmSlug}`,
17578
- flags: parsed?.flags ?? 1
17583
+ flags: parsed?.flags ?? 1,
17584
+ diagnosticCapabilityAuthority: this.diagnosticCapabilityAuthority
17579
17585
  };
17580
17586
  return withTraceContext(traceCtx, async () => {
17581
17587
  if (this.opts.dvmId) pinDimension("dvm_id", this.opts.dvmId);
17582
17588
  pinDimension("dvm_slug", dvmSlug);
17583
- if (builderPubkey) pinDimension("builder_id", builderPubkey);
17584
17589
  await next();
17585
17590
  });
17586
17591
  });
@@ -17789,21 +17794,21 @@ var DVMServer = class {
17789
17794
  this.tempoSweepInFlight = true;
17790
17795
  void sweep().then((result) => {
17791
17796
  if (result.settled > 0 || result.closeRequested > 0 || result.inFlight > 0) {
17792
- console.info(
17793
- JSON.stringify({
17797
+ diagnosticConsole.info(
17798
+ {
17794
17799
  level: "tempo_routine_sweep",
17795
17800
  dvm_id: this.opts.dvmId,
17796
17801
  ...result
17797
- })
17802
+ }
17798
17803
  );
17799
17804
  }
17800
- }).catch((err) => {
17801
- console.warn(
17802
- JSON.stringify({
17805
+ }).catch((_err) => {
17806
+ diagnosticConsole.warn(
17807
+ {
17803
17808
  level: "tempo_routine_sweep_failed",
17804
17809
  dvm_id: this.opts.dvmId,
17805
- error: err instanceof Error ? err.message : String(err)
17806
- })
17810
+ error: void 0
17811
+ }
17807
17812
  );
17808
17813
  }).finally(() => {
17809
17814
  this.tempoSweepInFlight = false;
@@ -17895,8 +17900,8 @@ var DVMServer = class {
17895
17900
  getBinding: (channelId) => recoverPostgres(channelId, () => getBinding(channelId)),
17896
17901
  settle: (channelId) => recoverPostgres(channelId, () => settle(channelId))
17897
17902
  });
17898
- console.info(
17899
- JSON.stringify({
17903
+ diagnosticConsole.info(
17904
+ {
17900
17905
  level: "tempo_close_event",
17901
17906
  dvm_id: this.opts.dvmId,
17902
17907
  chain_id: locator.chainId,
@@ -17906,10 +17911,10 @@ var DVMServer = class {
17906
17911
  outcome: result.outcome.outcome,
17907
17912
  channel_id: result.outcome.channelId,
17908
17913
  ...result.outcome.outcome === "retryable_failure" && {
17909
- error: result.outcome.error.slice(0, 500)
17914
+ error: void 0
17910
17915
  }
17911
17916
  } : { outcome: result.status, reason: result.reason }
17912
- })
17917
+ }
17913
17918
  );
17914
17919
  return c.json(
17915
17920
  result.status === "ok" ? { status: "ok", ...serializeTempoSettlementOutcome(result.outcome) } : {
@@ -18616,11 +18621,11 @@ var DVMServer = class {
18616
18621
  return c.json(res2);
18617
18622
  } catch (err) {
18618
18623
  if (err instanceof InvalidQuoteResultError) {
18619
- console.error("invalid QuoteResult from onQuote:", err);
18624
+ diagnosticConsole.error("invalid QuoteResult from onQuote:", err);
18620
18625
  return c.json({ error: { code: err.code, message: err.message } }, 500);
18621
18626
  }
18622
18627
  if (err instanceof QuoteCurrencyMismatchError) {
18623
- console.error("quote currency mismatch:", err);
18628
+ diagnosticConsole.error("quote currency mismatch:", err);
18624
18629
  return c.json({ error: { code: err.code, message: err.message } }, 500);
18625
18630
  }
18626
18631
  if (err instanceof InvalidCurrencyError) {
@@ -18631,7 +18636,7 @@ var DVMServer = class {
18631
18636
  const structured = pickStructuredError(err);
18632
18637
  if (structured) return c.json({ error: structured }, 400);
18633
18638
  const message = err instanceof Error ? err.message : String(err);
18634
- console.error("quote handler failed:", err);
18639
+ diagnosticConsole.error("quote handler failed:", err);
18635
18640
  return c.json({ error: { code: "internal", message } }, 500);
18636
18641
  }
18637
18642
  }
@@ -19355,7 +19360,7 @@ var DVMServer = class {
19355
19360
  if (!funding || !onCreditFunded || !this.opts.dvmId) return;
19356
19361
  Promise.resolve(onCreditFunded(creditDepositPayload(this.opts.dvmId, funding))).catch(
19357
19362
  (err) => {
19358
- console.error(`[${funding.creditId}] Deposit reporting failed:`, err);
19363
+ diagnosticConsole.error(`[${funding.creditId}] Deposit reporting failed:`, err);
19359
19364
  }
19360
19365
  );
19361
19366
  }
@@ -19386,7 +19391,7 @@ var DVMServer = class {
19386
19391
  kind: "short_pay_forfeit"
19387
19392
  })
19388
19393
  ).catch((err) => {
19389
- console.error(`[${forfeit.paymentId}] Short-pay forfeit reporting failed:`, err);
19394
+ diagnosticConsole.error(`[${forfeit.paymentId}] Short-pay forfeit reporting failed:`, err);
19390
19395
  });
19391
19396
  }
19392
19397
  /**
@@ -19402,13 +19407,13 @@ var DVMServer = class {
19402
19407
  const pubkeyMatches = this.descriptor.auth === void 0 || prior.requesterPubkey !== void 0 && prior.requesterPubkey === opts.callerPubkey;
19403
19408
  const requesterMatches = prior.requesterId === c.get("requesterId");
19404
19409
  if (!bodyMatches || !pubkeyMatches || !requesterMatches) {
19405
- console.warn(
19406
- JSON.stringify({
19410
+ diagnosticConsole.warn(
19411
+ {
19407
19412
  level: "paid_submit_replay_refused",
19408
19413
  jobId: prior.id,
19409
19414
  requestId: opts.requestId,
19410
19415
  reason: !bodyMatches ? "fingerprint_mismatch" : !pubkeyMatches ? "pubkey_mismatch" : "requester_mismatch"
19411
- })
19416
+ }
19412
19417
  );
19413
19418
  return void 0;
19414
19419
  }
@@ -19431,14 +19436,14 @@ var DVMServer = class {
19431
19436
  }
19432
19437
  const prior = jobId ? await this.jobManager.store.get(jobId) : void 0;
19433
19438
  if (!prior) {
19434
- console.warn(
19435
- JSON.stringify({
19439
+ diagnosticConsole.warn(
19440
+ {
19436
19441
  level: "drawn_job_recovery_refused",
19437
19442
  creditId: opts.creditId,
19438
19443
  drawId: opts.drawId,
19439
19444
  jobId,
19440
19445
  reason: "job_not_found"
19441
- })
19446
+ }
19442
19447
  );
19443
19448
  return void 0;
19444
19449
  }
@@ -19446,14 +19451,14 @@ var DVMServer = class {
19446
19451
  const pubkeyMatches = prior.requesterPubkey !== void 0 && prior.requesterPubkey === opts.callerPubkey;
19447
19452
  const requesterMatches = prior.requesterId === c.get("requesterId");
19448
19453
  if (!bodyMatches || !pubkeyMatches || !requesterMatches) {
19449
- console.warn(
19450
- JSON.stringify({
19454
+ diagnosticConsole.warn(
19455
+ {
19451
19456
  level: "paid_submit_replay_refused",
19452
19457
  jobId: prior.id,
19453
19458
  creditId: opts.creditId,
19454
19459
  drawId: opts.drawId,
19455
19460
  reason: !bodyMatches ? "fingerprint_mismatch" : !pubkeyMatches ? "pubkey_mismatch" : "requester_mismatch"
19456
- })
19461
+ }
19457
19462
  );
19458
19463
  return void 0;
19459
19464
  }
@@ -19476,15 +19481,15 @@ var DVMServer = class {
19476
19481
  });
19477
19482
  if (!marker) continue;
19478
19483
  if (marker.jobId !== opts.jobId) {
19479
- console.warn(
19480
- JSON.stringify({
19484
+ diagnosticConsole.warn(
19485
+ {
19481
19486
  level: "request_acceptance_recovery_refused",
19482
19487
  rail,
19483
19488
  paymentId: opts.paymentId,
19484
19489
  expectedJobId: opts.jobId,
19485
19490
  recordedJobId: marker.jobId,
19486
19491
  reason: "job_id_mismatch"
19487
- })
19492
+ }
19488
19493
  );
19489
19494
  return void 0;
19490
19495
  }
@@ -19515,14 +19520,14 @@ var DVMServer = class {
19515
19520
  paymentId: opts.paymentId
19516
19521
  });
19517
19522
  if (payment) {
19518
- console.warn(
19519
- JSON.stringify({
19523
+ diagnosticConsole.warn(
19524
+ {
19520
19525
  level: "request_acceptance_recovered",
19521
19526
  jobId: opts.expectedJobId,
19522
19527
  creditId: opts.creditId,
19523
19528
  drawId: opts.drawId,
19524
19529
  rail: payment.paymentRail
19525
- })
19530
+ }
19526
19531
  );
19527
19532
  }
19528
19533
  return payment;
@@ -19583,7 +19588,7 @@ var DVMServer = class {
19583
19588
  };
19584
19589
  }
19585
19590
  if (err instanceof QuoteCurrencyMismatchError) {
19586
- console.error("quote currency mismatch:", err);
19591
+ diagnosticConsole.error("quote currency mismatch:", err);
19587
19592
  return {
19588
19593
  error: { body: { error: err.code, message: err.message }, status: 500 }
19589
19594
  };
@@ -20345,13 +20350,13 @@ var PlatformTempoObserverHealth = class {
20345
20350
  withhold(reason) {
20346
20351
  if (!this.withheldLogged) {
20347
20352
  this.withheldLogged = true;
20348
- console.warn(
20349
- JSON.stringify({
20353
+ diagnosticConsole.warn(
20354
+ {
20350
20355
  level: "warn",
20351
20356
  event: "tempo_session_withheld",
20352
- message: "Tempo session funding withheld: the platform's close observer is not confirmed healthy. tempo/charge is unaffected.",
20357
+ message: void 0,
20353
20358
  reason
20354
- })
20359
+ }
20355
20360
  );
20356
20361
  }
20357
20362
  return false;