@dvmkit/dvm-cli 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-ESQ6DCS3.js → chunk-3NXAIRFF.js} +2 -2
  3. package/dist/{chunk-REIUNZQX.js → chunk-B5KW2TPR.js} +2 -2
  4. package/dist/{chunk-DGA5EFKU.js → chunk-DF2OWCRY.js} +6 -6
  5. package/dist/{chunk-R6FZT6S2.js → chunk-DJDONOMG.js} +9 -5
  6. package/dist/{chunk-DE7TEOUR.js → chunk-J3HYNDMI.js} +424 -51
  7. package/dist/{chunk-OEWENVJ7.js → chunk-MM646MFM.js} +4 -4
  8. package/dist/{chunk-VLD7OKSH.js → chunk-NKD4NEUF.js} +3 -3
  9. package/dist/{chunk-ZGBCVQF2.js → chunk-OCVRCWBL.js} +3 -3
  10. package/dist/{chunk-IK7RI645.js → chunk-W4ADV3HW.js} +449 -5
  11. package/dist/{chunk-UFMAHF6T.js → chunk-WCX4PNEF.js} +127 -40
  12. package/dist/{chunk-THTPKBZX.js → chunk-X6BETQ7V.js} +1252 -737
  13. package/dist/{chunk-A2B7QDMS.js → chunk-ZZCYSYXR.js} +2 -2
  14. package/dist/{client-3JOMNAIQ.js → client-S3FEXAWD.js} +6 -6
  15. package/dist/dvm.js +687 -249
  16. package/dist/{internal-L362ZUWL.js → internal-WAQ3LZN4.js} +10 -8
  17. package/dist/{lifecycle-BH4OA5I3.js → lifecycle-NOK3MKL4.js} +6 -6
  18. package/dist/{payout-reporter-F5LFV5W4-EJ7E5ALO.js → payout-reporter-5PH53T44-7IA4NGIN.js} +2 -2
  19. package/dist/{pocket-refill-5BEM22UM.js → pocket-refill-KUBHM7MR.js} +10 -10
  20. package/dist/{revenue-reporter-2U55YH2I-EUB6PBRN.js → revenue-reporter-4XV3OO5O-RYHS3M34.js} +2 -2
  21. package/dist/{tempo-lifecycle-WGTX6MJR.js → tempo-lifecycle-QGJ4JEHN.js} +8 -8
  22. package/dist/{tempo-wallet-OTB2YSWE.js → tempo-wallet-GDDZZP5S.js} +7 -7
  23. package/dist/{wallet-73EJBUSO.js → wallet-2M3H75UP.js} +7 -7
  24. package/dist/{x402-G6C4N2BN-TAJEBQGU.js → x402-FHHB3V4V-CM6OMLHE.js} +2 -2
  25. package/package.json +2 -2
  26. package/skills/dvm/calling.md +13 -2
  27. package/skills/dvm/credit.md +5 -1
  28. package/skills/dvm/recovery.md +2 -0
  29. package/skills/dvm/wallets.md +2 -0
@@ -4,14 +4,14 @@ const require = __dvmCreateRequire(import.meta.url);
4
4
  import {
5
5
  loadConfig,
6
6
  updateConfig
7
- } from "./chunk-ESQ6DCS3.js";
7
+ } from "./chunk-3NXAIRFF.js";
8
8
  import {
9
9
  tempoAccountFromConfig,
10
10
  tryResolveTempoAsset
11
- } from "./chunk-THTPKBZX.js";
11
+ } from "./chunk-X6BETQ7V.js";
12
12
  import {
13
13
  DvmError
14
- } from "./chunk-DGA5EFKU.js";
14
+ } from "./chunk-DF2OWCRY.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-WGTX6MJR.js");
49
+ const { assertTempoWalletIdle } = await import("./tempo-lifecycle-QGJ4JEHN.js");
50
50
  await assertTempoWalletIdle("replace");
51
51
  }
52
52
  const { privateKeyToAccount, generatePrivateKey } = await import("./accounts-2WZE4N5F.js");
@@ -5,11 +5,11 @@ import {
5
5
  authorizeProtectedRemoval,
6
6
  loadConfig,
7
7
  updateConfig
8
- } from "./chunk-ESQ6DCS3.js";
8
+ } from "./chunk-3NXAIRFF.js";
9
9
  import {
10
10
  withX402ChannelLock,
11
11
  x402WalletFromConfig
12
- } from "./chunk-THTPKBZX.js";
12
+ } from "./chunk-X6BETQ7V.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-DGA5EFKU.js";
20
+ } from "./chunk-DF2OWCRY.js";
21
21
 
22
22
  // src/lib/x402/networks.ts
23
23
  function x402NetworkLabel(network) {
@@ -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-OEWENVJ7.js";
6
+ } from "./chunk-MM646MFM.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-THTPKBZX.js";
16
+ } from "./chunk-X6BETQ7V.js";
17
17
  import {
18
18
  DvmError
19
- } from "./chunk-DGA5EFKU.js";
19
+ } from "./chunk-DF2OWCRY.js";
20
20
 
21
21
  // src/lib/cli-identity-resolve.ts
22
22
  function resolveSigningIdentity(opts) {
@@ -6,9 +6,441 @@ import {
6
6
  } from "./chunk-R2DSAZBO.js";
7
7
  import {
8
8
  diagnosticConsole
9
- } from "./chunk-UFMAHF6T.js";
9
+ } from "./chunk-WCX4PNEF.js";
10
10
 
11
- // node_modules/@dvmkit/sdk/dist/chunk-YO6VWXWF.js
11
+ // node_modules/@dvmkit/sdk/dist/chunk-CXPSMXNH.js
12
+ import { AsyncLocalStorage } from "async_hooks";
13
+ var postgresRecovery = new AsyncLocalStorage();
14
+ var queryingPool = new AsyncLocalStorage();
15
+ function withPostgresRecoveryContext(context, operation) {
16
+ return postgresRecovery.run(context, operation);
17
+ }
18
+ var checkoutCancellation = new AsyncLocalStorage();
19
+ function withPostgresCheckoutCancellation(signal, operation, pool) {
20
+ if (pool) installCheckoutCancellation(pool);
21
+ return checkoutCancellation.run(signal, operation);
22
+ }
23
+ var cancellablePools = /* @__PURE__ */ new WeakSet();
24
+ function installCheckoutCancellation(candidate) {
25
+ if (cancellablePools.has(candidate)) return;
26
+ const pool = candidate;
27
+ if (typeof pool.Client !== "function" || typeof pool.newClient !== "function" || !Array.isArray(pool._pendingQueue) || typeof pool._remove !== "function" || typeof pool._pulseQueue !== "function") return;
28
+ cancellablePools.add(pool);
29
+ const queued = /* @__PURE__ */ new WeakMap();
30
+ let entering;
31
+ let constructing;
32
+ pool.Client = new Proxy(pool.Client, {
33
+ construct(target, args, newTarget) {
34
+ const client = Reflect.construct(target, args, newTarget);
35
+ constructing?.(client);
36
+ return client;
37
+ }
38
+ });
39
+ const newClient = pool.newClient.bind(pool);
40
+ pool.newClient = (pending) => {
41
+ const ticket = queued.get(pending) ?? entering;
42
+ if (!ticket?.signal) {
43
+ const previous2 = constructing;
44
+ constructing = void 0;
45
+ try {
46
+ newClient(pending);
47
+ } finally {
48
+ constructing = previous2;
49
+ }
50
+ return;
51
+ }
52
+ const signal = ticket.signal;
53
+ if (ticket.settled || signal.aborted) {
54
+ pending.callback(asError(signal.reason));
55
+ queueMicrotask(() => pool._pulseQueue());
56
+ return;
57
+ }
58
+ let client;
59
+ let rejectHandshake;
60
+ let cancelled = false;
61
+ ticket.cancel = (error) => {
62
+ if (cancelled) return;
63
+ cancelled = true;
64
+ pending.timedOut = true;
65
+ const connecting = rejectHandshake?.(error);
66
+ if (client) {
67
+ if (client.connection) client.connection.stream.destroy();
68
+ else client.end();
69
+ if (!connecting) pool._remove(client, () => pool._pulseQueue());
70
+ }
71
+ pending.callback(error);
72
+ };
73
+ const previous = constructing;
74
+ constructing = (created) => {
75
+ client = created;
76
+ const connect2 = client.connect.bind(client);
77
+ client.connect = (callback) => {
78
+ let called = false;
79
+ const complete = (error) => {
80
+ if (called) return false;
81
+ called = true;
82
+ callback(error);
83
+ return true;
84
+ };
85
+ rejectHandshake = complete;
86
+ if (signal.aborted) ticket.cancel?.(asError(signal.reason));
87
+ else connect2(complete);
88
+ };
89
+ };
90
+ try {
91
+ newClient(pending);
92
+ } finally {
93
+ constructing = previous;
94
+ }
95
+ };
96
+ const connect = pool.connect.bind(pool);
97
+ pool.connect = ((callback) => {
98
+ const signal = checkoutCancellation.getStore();
99
+ const ticket = { signal, settled: false };
100
+ const pending = new Promise((resolve, reject) => {
101
+ const complete = (error, client) => {
102
+ if (ticket.settled) return;
103
+ ticket.settled = true;
104
+ signal?.removeEventListener("abort", abort);
105
+ if (error) {
106
+ ticket.cancel?.(error);
107
+ reject(error);
108
+ } else {
109
+ ticket.cancel = void 0;
110
+ resolve(client);
111
+ }
112
+ };
113
+ const abort = () => {
114
+ if (ticket.settled) return;
115
+ const error = asError(signal?.reason);
116
+ if (ticket.cancel) ticket.cancel(error);
117
+ else {
118
+ const item = ticket.pending;
119
+ if (item) {
120
+ const index = pool._pendingQueue.indexOf(item);
121
+ if (index !== -1) pool._pendingQueue.splice(index, 1);
122
+ item.timedOut = true;
123
+ item.callback(error);
124
+ pool._pulseQueue();
125
+ } else complete(error);
126
+ }
127
+ };
128
+ if (signal?.aborted) {
129
+ complete(asError(signal.reason));
130
+ return;
131
+ }
132
+ signal?.addEventListener("abort", abort, { once: true });
133
+ const previous = entering;
134
+ const before = new Set(pool._pendingQueue);
135
+ entering = ticket;
136
+ try {
137
+ const returned = connect(complete);
138
+ if (returned && typeof returned.then === "function") {
139
+ void Promise.resolve(returned).then(
140
+ (client) => complete(void 0, client),
141
+ (error) => complete(asError(error))
142
+ );
143
+ }
144
+ } catch (error) {
145
+ complete(asError(error));
146
+ } finally {
147
+ entering = previous;
148
+ }
149
+ for (const item of pool._pendingQueue) {
150
+ if (!before.has(item) && !queued.has(item)) {
151
+ queued.set(item, ticket);
152
+ ticket.pending = item;
153
+ }
154
+ }
155
+ if (signal?.aborted) abort();
156
+ });
157
+ if (!callback) return pending;
158
+ void pending.then(
159
+ (client) => callback(void 0, client, client.release),
160
+ (error) => callback(asError(error), void 0, () => void 0)
161
+ );
162
+ });
163
+ }
164
+ async function probeCheckedOutClient(client, probe) {
165
+ const signal = checkoutCancellation.getStore();
166
+ if (!signal) {
167
+ await client.query(probe);
168
+ return;
169
+ }
170
+ signal.throwIfAborted();
171
+ await new Promise((resolve, reject) => {
172
+ const abort = () => reject(signal.reason);
173
+ signal.addEventListener("abort", abort, { once: true });
174
+ client.query(probe).then(() => resolve(), reject).finally(() => signal.removeEventListener("abort", abort));
175
+ });
176
+ }
177
+ function isTransportError(err) {
178
+ if (err === null || typeof err !== "object") return false;
179
+ const code = err.code;
180
+ const msg = err.message;
181
+ if (typeof code === "string" && /^[0-9A-Z]{5}$/.test(code)) return false;
182
+ return typeof msg === "string" && msg.includes("Connection terminated") || code === "ECONNRESET" || code === "ENOTFOUND";
183
+ }
184
+ async function withInitRetry(fn, label, delays = [1e3, 4e3, 15e3]) {
185
+ for (let attempt = 0; ; attempt++) {
186
+ try {
187
+ await fn();
188
+ return;
189
+ } catch (err) {
190
+ if (!isTransportError(err) || attempt >= delays.length) throw err;
191
+ const wait = delays[attempt];
192
+ diagnosticConsole.warn();
193
+ await new Promise((resolve) => setTimeout(resolve, wait));
194
+ }
195
+ }
196
+ }
197
+ var POSTGRES_APPLICATION_NAME_MAX_BYTES = 63;
198
+ function formatPostgresApplicationName(label, machineId = process.env.FLY_MACHINE_ID) {
199
+ const machineSuffix = machineId ? `@${machineId}` : "";
200
+ const boundedMachineSuffix = truncateUtf8(machineSuffix, POSTGRES_APPLICATION_NAME_MAX_BYTES);
201
+ const labelBudget = POSTGRES_APPLICATION_NAME_MAX_BYTES - Buffer.byteLength(boundedMachineSuffix, "utf8");
202
+ return `${truncateUtf8(label, labelBudget)}${boundedMachineSuffix}`;
203
+ }
204
+ var patchedPools = /* @__PURE__ */ new WeakSet();
205
+ var guardedClients = /* @__PURE__ */ new WeakSet();
206
+ function applyRetryToPool(pool, label = "pg-pool") {
207
+ if (patchedPools.has(pool)) return;
208
+ patchedPools.add(pool);
209
+ installCheckoutCancellation(pool);
210
+ pool.options.application_name = formatPostgresApplicationName(label);
211
+ pool.on("error", (err) => {
212
+ diagnosticConsole.error({ event: "postgres_pool_error", error_code: postgresErrorCode(err) });
213
+ });
214
+ const p = pool;
215
+ const origQuery = p.query.bind(pool);
216
+ p.query = (...args) => withTransportRecovery(
217
+ pool,
218
+ label,
219
+ "pool.query",
220
+ () => queryingPool.run(pool, () => origQuery(...args))
221
+ );
222
+ const origConnect = pool.connect.bind(pool);
223
+ pool.connect = ((callback) => {
224
+ if (queryingPool.getStore() === pool) {
225
+ return queryingPool.exit(() => callback ? origConnect(callback) : origConnect());
226
+ }
227
+ const pending = withTransportRecovery(pool, label, "pool.connect", async () => {
228
+ checkoutCancellation.getStore()?.throwIfAborted();
229
+ const client = await origConnect();
230
+ guardCheckedOutClient(client, label);
231
+ const remainingMs = (postgresRecovery.getStore()?.deadlineMs ?? Infinity) - Date.now();
232
+ const probe = {
233
+ text: "SELECT 1",
234
+ query_timeout: Math.max(1, Math.min(connectionTimeoutMs(pool), remainingMs))
235
+ };
236
+ try {
237
+ await probeCheckedOutClient(client, probe);
238
+ return client;
239
+ } catch (error) {
240
+ client.release(asError(error));
241
+ throw error;
242
+ }
243
+ });
244
+ if (!callback) return pending;
245
+ void pending.then(
246
+ (client) => callback(void 0, client, client.release),
247
+ (error) => callback(asError(error), void 0, () => void 0)
248
+ );
249
+ });
250
+ }
251
+ function withPostgresTransactionRecovery(pool, label, operation, callback) {
252
+ return withTransportRecovery(pool, label, operation, async () => {
253
+ const client = await pool.connect();
254
+ let releaseError;
255
+ try {
256
+ await client.query("BEGIN");
257
+ const value = await callback(client);
258
+ await client.query("COMMIT");
259
+ return value;
260
+ } catch (error) {
261
+ await client.query("ROLLBACK").catch(() => void 0);
262
+ if (isTransportError(error)) releaseError = asError(error);
263
+ throw error;
264
+ } finally {
265
+ client.release(releaseError);
266
+ }
267
+ });
268
+ }
269
+ async function withTransportRecovery(pool, label, operation, callback) {
270
+ const context = postgresRecovery.getStore();
271
+ const maxAttempts = context?.drainPool === false ? 2 : hostPoolSize(pool) + 1;
272
+ const startedAt = Date.now();
273
+ const deadlineMs = context?.deadlineMs ?? startedAt + connectionTimeoutMs(pool);
274
+ let firstError;
275
+ for (let attempt = 1; ; attempt += 1) {
276
+ try {
277
+ const value = await callback();
278
+ if (firstError) {
279
+ logTransportRecovery({
280
+ context,
281
+ label,
282
+ operation,
283
+ attempts: attempt,
284
+ elapsedMs: Date.now() - startedAt,
285
+ outcome: "recovered",
286
+ error: firstError.message
287
+ });
288
+ }
289
+ return value;
290
+ } catch (error) {
291
+ if (!isTransportError(error)) throw error;
292
+ firstError ??= asError(error);
293
+ const elapsedMs = Date.now() - startedAt;
294
+ if (attempt >= maxAttempts || Date.now() >= deadlineMs) {
295
+ logTransportRecovery({
296
+ context,
297
+ label,
298
+ operation,
299
+ attempts: attempt,
300
+ elapsedMs,
301
+ outcome: "exhausted",
302
+ error: asError(error).message
303
+ });
304
+ throw error;
305
+ }
306
+ }
307
+ }
308
+ }
309
+ function connectionTimeoutMs(pool) {
310
+ const configured = pool.options.connectionTimeoutMillis;
311
+ return typeof configured === "number" && Number.isFinite(configured) && configured > 0 ? configured : 1e4;
312
+ }
313
+ function hostPoolSize(pool) {
314
+ const configured = pool.options.max;
315
+ return typeof configured === "number" && Number.isSafeInteger(configured) && configured > 0 ? configured : 10;
316
+ }
317
+ function logTransportRecovery(args) {
318
+ diagnosticConsole.warn(
319
+ {
320
+ level: "postgres_transport_recovery",
321
+ label: args.label,
322
+ route: args.context?.route,
323
+ channel_id: args.context?.channelId,
324
+ operation: args.operation,
325
+ attempts: args.attempts,
326
+ elapsed_ms: args.elapsedMs,
327
+ outcome: args.outcome,
328
+ error: void 0
329
+ }
330
+ );
331
+ }
332
+ function asError(error) {
333
+ return error instanceof Error ? error : new Error(String(error));
334
+ }
335
+ function guardCheckedOutClient(client, _label) {
336
+ if (client === null || typeof client !== "object") return;
337
+ const emitter = client;
338
+ if (typeof emitter.on !== "function" || guardedClients.has(client)) return;
339
+ guardedClients.add(client);
340
+ emitter.on("error", (err) => {
341
+ diagnosticConsole.error({ event: "postgres_client_error", error_code: postgresErrorCode(err) });
342
+ });
343
+ }
344
+ function postgresErrorCode(error) {
345
+ try {
346
+ if (error !== null && typeof error === "object") {
347
+ const descriptor = Object.getOwnPropertyDescriptor(error, "code");
348
+ const code = descriptor && "value" in descriptor ? descriptor.value : void 0;
349
+ if (typeof code === "string") return code;
350
+ }
351
+ } catch {
352
+ }
353
+ return "unknown_error";
354
+ }
355
+ function truncateUtf8(value, maxBytes) {
356
+ if (maxBytes <= 0) return "";
357
+ if (Buffer.byteLength(value, "utf8") <= maxBytes) return value;
358
+ let result = "";
359
+ for (const character of value) {
360
+ const next = result + character;
361
+ if (Buffer.byteLength(next, "utf8") > maxBytes) break;
362
+ result = next;
363
+ }
364
+ return result;
365
+ }
366
+
367
+ // node_modules/@dvmkit/sdk/dist/chunk-NEM7HABE.js
368
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
369
+ var x402ShutdownClaimEnvironment = new AsyncLocalStorage2();
370
+ var x402ShutdownClaimSignal = new AsyncLocalStorage2();
371
+ function waitForX402ShutdownClaim(operation) {
372
+ const signal = x402ShutdownClaimSignal.getStore();
373
+ if (!signal) return operation();
374
+ if (signal.aborted) return Promise.reject(signal.reason);
375
+ return new Promise((resolve, reject) => {
376
+ const abort = () => reject(signal.reason);
377
+ signal.addEventListener("abort", abort, { once: true });
378
+ Promise.resolve().then(() => {
379
+ signal.throwIfAborted();
380
+ return operation();
381
+ }).then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
382
+ });
383
+ }
384
+ function withX402ShutdownClaimBudget(target) {
385
+ return new Proxy(target, {
386
+ get(object, property) {
387
+ const value = Reflect.get(object, property);
388
+ return typeof value === "function" ? (...args) => waitForX402ShutdownClaim(() => Reflect.apply(value, object, args)) : value;
389
+ }
390
+ });
391
+ }
392
+ async function connectForX402ShutdownClaim(pool) {
393
+ const signal = x402ShutdownClaimSignal.getStore();
394
+ if (!signal) return pool.connect();
395
+ signal.throwIfAborted();
396
+ const pending = withPostgresCheckoutCancellation(signal, () => pool.connect(), pool);
397
+ let client;
398
+ try {
399
+ client = await waitForX402ShutdownClaim(() => pending);
400
+ } catch (error) {
401
+ void pending.then((late) => late.release(true), () => void 0);
402
+ throw error;
403
+ }
404
+ let released = false;
405
+ const release = (destroy) => {
406
+ if (released) return;
407
+ released = true;
408
+ signal.removeEventListener("abort", abort);
409
+ client.release(destroy);
410
+ };
411
+ const abort = () => release(true);
412
+ signal.addEventListener("abort", abort, { once: true });
413
+ if (signal.aborted) abort();
414
+ return new Proxy(client, {
415
+ get(object, property) {
416
+ if (property === "release") return release;
417
+ if (property === "query") {
418
+ return (...args) => waitForX402ShutdownClaim(() => Reflect.apply(object.query, object, args));
419
+ }
420
+ return Reflect.get(object, property);
421
+ }
422
+ });
423
+ }
424
+ function poolForX402ShutdownClaim(pool) {
425
+ if (!x402ShutdownClaimSignal.getStore()) return pool;
426
+ return new Proxy(pool, {
427
+ get(object, property) {
428
+ if (property === "query") {
429
+ return async (...args) => {
430
+ const client = await connectForX402ShutdownClaim(object);
431
+ try {
432
+ return await Reflect.apply(client.query, client, args);
433
+ } finally {
434
+ client.release();
435
+ }
436
+ };
437
+ }
438
+ return Reflect.get(object, property);
439
+ }
440
+ });
441
+ }
442
+
443
+ // node_modules/@dvmkit/sdk/dist/chunk-3WKXNGXX.js
12
444
  import { createHash, randomUUID } from "crypto";
13
445
  async function x402EarnedCeiling(channel, earnedNative) {
14
446
  let earned;
@@ -77,7 +509,7 @@ var PostgresX402BatchStore = class {
77
509
  });
78
510
  }
79
511
  async get(scope) {
80
- const { rows } = await this.db.query("SELECT * FROM payout_x402_batches WHERE scope = $1", [scope]);
512
+ const { rows } = await poolForX402ShutdownClaim(this.db).query("SELECT * FROM payout_x402_batches WHERE scope = $1", [scope]);
81
513
  const row = rows.at(0);
82
514
  if (!row) return void 0;
83
515
  return {
@@ -95,7 +527,7 @@ var PostgresX402BatchStore = class {
95
527
  };
96
528
  }
97
529
  async put(batch) {
98
- await this.db.query(
530
+ await poolForX402ShutdownClaim(this.db).query(
99
531
  `INSERT INTO payout_x402_batches (
100
532
  scope, batch_id, claimed_native, voucher_count, claims, opened_at,
101
533
  attempts, first_failed_at, last_error, next_retry_at, obligation_ids, updated_at
@@ -499,7 +931,7 @@ var PayoutReporter = class {
499
931
  vouchers: results.reduce((sum, r) => sum + r.vouchers, 0),
500
932
  transactions: results.map((result) => result.transaction)
501
933
  });
502
- void this.snapshotX402();
934
+ if (!x402ShutdownClaimSignal.getStore()) void this.snapshotX402();
503
935
  }
504
936
  return results;
505
937
  };
@@ -935,6 +1367,18 @@ function warn(level, fields) {
935
1367
  }
936
1368
 
937
1369
  export {
1370
+ withPostgresRecoveryContext,
1371
+ isTransportError,
1372
+ withInitRetry,
1373
+ applyRetryToPool,
1374
+ withPostgresTransactionRecovery,
1375
+ postgresErrorCode,
1376
+ x402ShutdownClaimEnvironment,
1377
+ x402ShutdownClaimSignal,
1378
+ waitForX402ShutdownClaim,
1379
+ withX402ShutdownClaimBudget,
1380
+ connectForX402ShutdownClaim,
1381
+ poolForX402ShutdownClaim,
938
1382
  x402EarnedCeiling,
939
1383
  MemoryX402BatchStore,
940
1384
  PostgresX402BatchStore,