@dvmkit/sdk 0.1.2-rc.7 → 0.1.3-rc.7

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 (45) hide show
  1. package/README.md +14 -0
  2. package/dist/chunk-2K7E3N2D.js +1709 -0
  3. package/dist/{chunk-N4VTG3KH.js → chunk-3ZHMQCYP.js} +645 -3027
  4. package/dist/{chunk-TKA6ZP4M.js → chunk-4B56DEEV.js} +50 -426
  5. package/dist/chunk-BIFLRKMO.js +87 -0
  6. package/dist/chunk-BQ2NMWKE.js +160 -0
  7. package/dist/{chunk-LDTWX7JW.js → chunk-BTZY7VPH.js} +13 -1
  8. package/dist/{chunk-FJDCFHW5.js → chunk-C6JHBLMW.js} +3 -81
  9. package/dist/{chunk-EXHBXA4U.js → chunk-DBCLBYHP.js} +13 -1
  10. package/dist/chunk-EPNDZ5DH.js +1010 -0
  11. package/dist/{chunk-P4RUVDU7.js → chunk-H2MEFVH6.js} +12 -141
  12. package/dist/chunk-KXZUCCEY.js +142 -0
  13. package/dist/{chunk-6JZIX5WW.js → chunk-LLXV32HA.js} +82 -5
  14. package/dist/{chunk-LWUR4CGG.js → chunk-MLRCSJYX.js} +11 -3
  15. package/dist/{chunk-2ABMGUDS.js → chunk-NFRM5QYP.js} +83 -10
  16. package/dist/chunk-RW5LP57K.js +44 -0
  17. package/dist/chunk-YDIYXGYL.js +384 -0
  18. package/dist/{chunk-JGGI65I3.js → chunk-Z4BNLUZF.js} +1 -150
  19. package/dist/{credit-ledger-ED6JXKVD.js → credit-ledger-2DFQHNLB.js} +2 -2
  20. package/dist/{credit-menu-BM4qCD5U.d.ts → credit-menu-C7zAJElJ.d.ts} +1632 -1946
  21. package/dist/{fx-C-liI3oY.d.ts → fx-BF_SG2i0.d.ts} +1 -1
  22. package/dist/index.d.ts +7 -6
  23. package/dist/index.js +8 -4
  24. package/dist/internal/caller.d.ts +10429 -0
  25. package/dist/internal/caller.js +9957 -0
  26. package/dist/internal/index.d.ts +2 -10816
  27. package/dist/internal/index.js +2 -10130
  28. package/dist/internal/server.d.ts +404 -0
  29. package/dist/internal/server.js +202 -0
  30. package/dist/job-store-Bn23V3QU.d.ts +576 -0
  31. package/dist/lightning-backend-C04nH94l.d.ts +367 -0
  32. package/dist/{memory-credit-ledger-XJ5VQEVP.js → memory-credit-ledger-OP24Z2KO.js} +3 -3
  33. package/dist/{postgres-job-store-J5F4GUWU.js → postgres-job-store-TAONYLIF.js} +1 -1
  34. package/dist/{revenue-reporter-JIKUPXOK.js → revenue-reporter-XXSU5KVB.js} +1 -1
  35. package/dist/server/index.d.ts +27 -11
  36. package/dist/server/index.js +93 -69
  37. package/dist/{job-store-C53VQ5uu.d.ts → step-cache-3cT4Shk0.d.ts} +31 -585
  38. package/dist/{tempo-session-store-DALMRIWN.js → tempo-session-store-2JNOKJGX.js} +2 -2
  39. package/dist/testing/index.d.ts +16 -4
  40. package/dist/testing/index.js +7 -3
  41. package/dist/{usd-gLcJB1ps.d.ts → usd-BnuXoFl5.d.ts} +1 -1
  42. package/dist/wallet-CJC8lwxx.d.ts +29 -0
  43. package/dist/{x402-FTG2GRAQ.js → x402-T2C5MX3T.js} +6 -3
  44. package/package.json +6 -2
  45. package/dist/{chunk-RU7SXHLO.js → chunk-UP2F5RRT.js} +3 -3
@@ -0,0 +1,367 @@
1
+ import { V as JsonValue } from './step-cache-3cT4Shk0.js';
2
+
3
+ declare const lockPubkeyBrand: unique symbol;
4
+ /**
5
+ * NUT-11 P2PK lock pubkey, lowercase-by-construction. Hex-encoded compressed
6
+ * secp256k1 pubkey (66 chars starting with `02` / `03`), normalised via
7
+ * `toLockPubkey`. The brand exists so any in-memory site that compares
8
+ * lock-pubkeys against each other — receive matching, monitor orphan/retired
9
+ * lookups, melt-pending keypair maps — gets a compile-time guarantee that
10
+ * both sides have been normalised. Raw strings off the wire or out of the DB
11
+ * must pass through `toLockPubkey` before they're treated as one.
12
+ */
13
+ type LockPubkey = string & {
14
+ readonly [lockPubkeyBrand]: never;
15
+ };
16
+ /**
17
+ * Brand a raw lock-pubkey string. Trims surrounding whitespace and lowercases
18
+ * the hex so equality is structural. Idempotent on values that are already
19
+ * lowercase. Does not validate the curve point — assertions about hex shape
20
+ * live at the wire-validation layer (e.g. the `/admin/cashu/rotate-lock-pubkey`
21
+ * regex in `admin-cashu.ts`).
22
+ */
23
+ declare function toLockPubkey(raw: string): LockPubkey;
24
+
25
+ /**
26
+ * Canonical deploy-time attestation payload (internal-review). One signature serves
27
+ * both auth-on-deploy and the `/v1/info#builder` attestation — the bytes the
28
+ * builder signs are the canonical JSON of this object. Making a field required
29
+ * also requires the coordinated fleet-before-caller release note in
30
+ * `public compatibility guide`.
31
+ */
32
+ interface AttestationPayload {
33
+ /** Immutable platform or self-hosted DVM identifier this attestation applies to. */
34
+ dvm_id: string;
35
+ /** DVM slug the attestation applies to (must match the deploy request's slug). */
36
+ slug: string;
37
+ /** sha256(`canonicaliseForSigning(capabilities)`) hex. Binds the attestation
38
+ * to the capability shape declared at deploy time. */
39
+ capabilities_hash: string;
40
+ /** Builder identity x-only secp256k1 pubkey, hex (32 bytes / 64 chars). */
41
+ builder_pubkey: string;
42
+ /**
43
+ * Per-DVM receipt-signing x-only pubkey, hex (internal-review). Binds the key the
44
+ * deployed DVM signs job receipts with to the cold builder identity: the
45
+ * builder signs this payload, so a receipt verifying under
46
+ * `receipt_pubkey` inherits the builder's authority.
47
+ *
48
+ * Optional: attestations signed before receipts shipped omit it and still
49
+ * verify byte-for-byte (canonical JSON drops absent keys), and deploy paths
50
+ * that can't provision the matching secret leave it unset rather than
51
+ * attesting a key the running process doesn't hold.
52
+ */
53
+ receipt_pubkey?: string;
54
+ /** Unix seconds at which the attestation was signed. */
55
+ deployed_at: number;
56
+ }
57
+ /** Result of {@link generateIdentity}: hex pubkey + hex secret. */
58
+ interface BuilderIdentityKeypair {
59
+ /** secp256k1 BIP-340 x-only pubkey, 32 bytes hex (64 chars). */
60
+ pubkey: string;
61
+ /** secp256k1 secret, 32 bytes hex (64 chars). */
62
+ secret: string;
63
+ }
64
+ /** Generate a fresh BIP-340 Schnorr keypair for builder identity. */
65
+ declare function generateIdentity(): BuilderIdentityKeypair;
66
+ /**
67
+ * Read the builder identity secret from `~/.dvmkit/builder.key`. Returns
68
+ * `null` when absent so callers can surface an `identity_required` error.
69
+ *
70
+ * `writeIdentity` persists the key `0o600`, but a destination mode survives
71
+ * `cp`/`scp`/git-checkout intact only by luck — those can land it `0o644`,
72
+ * leaving the signing key world-readable on a multi-user box. On POSIX we
73
+ * detect loose group/other bits, warn, and best-effort re-tighten to `0o600`
74
+ * (same self-heal posture as `writeIdentity`) rather than throw — a hard
75
+ * failure would brick a CLI whose key got widened in transit.
76
+ */
77
+ declare function loadIdentitySecret(): string | null;
78
+ /**
79
+ * Persist a builder identity keypair: pubkey into `~/.dvmkit/builder.json`
80
+ * (top-level), secret into `~/.dvmkit/builder.key` (mode 0600 on POSIX).
81
+ * Atomic tmp+rename on the secret file so a crash mid-write never leaves a
82
+ * truncated key on disk — a torn write here is unrecoverable; the operator
83
+ * loses the ability to re-sign attestations for every DVM under this key.
84
+ *
85
+ * Refuses to overwrite when an identity already exists unless `force` is
86
+ * passed; the force path warns that any DVMs deployed under the old key
87
+ * need to be re-deployed to refresh their attestations.
88
+ */
89
+ declare function writeIdentity(keypair: BuilderIdentityKeypair, opts?: {
90
+ force?: boolean;
91
+ }): void;
92
+ /**
93
+ * Compute the canonical `capabilities_hash` (sha256-hex of canonical JSON)
94
+ * for the supplied capabilities block. Shared between the CLI signer and any
95
+ * future verifier so both compute identical bytes.
96
+ */
97
+ declare function hashCapabilities(capabilities: JsonValue): string;
98
+ /**
99
+ * Assemble the deploy-time attestation payload (internal-review). `deployedAt`
100
+ * defaults to the current Unix second; tests can pin it for reproducibility.
101
+ */
102
+ declare function buildAttestation(args: {
103
+ dvmId: string;
104
+ slug: string;
105
+ capabilities: JsonValue;
106
+ builderPubkey: string;
107
+ /** Receipt-signing pubkey to attest (internal-review). Omitted when the deploy path
108
+ * can't provision the matching `DVMKIT_RECEIPT_KEY`. */
109
+ receiptPubkey?: string;
110
+ deployedAt?: number;
111
+ }): AttestationPayload;
112
+ /**
113
+ * Sign an attestation payload with the builder identity secret. Returns the
114
+ * 64-byte Schnorr signature as hex. The canonical bytes are produced via the
115
+ * same `canonicaliseForSigning` the verifier uses — both sides hash identical
116
+ * input regardless of object key order.
117
+ */
118
+ declare function signAttestation(payload: AttestationPayload, secretHex: string): string;
119
+ /**
120
+ * Verify a deploy-time attestation. Returns `true` iff the signature is a
121
+ * valid BIP-340 Schnorr signature of `canonicaliseForSigning(payload)` under
122
+ * `pubkeyHex`. Independent of the platform binding — callers (the deploy
123
+ * route, `/v1/info` clients) cross-check the pubkey against their trust root.
124
+ */
125
+ declare function verifyAttestation(payload: AttestationPayload, signatureHex: string, pubkeyHex: string): boolean;
126
+
127
+ /**
128
+ * Per-method amount limits a mint advertises on its NUT-4 / NUT-5 bolt11/sat
129
+ * entry (internal-review). Both values are in the method's own unit — `sat` here,
130
+ * never msats.
131
+ *
132
+ * `null` means the mint advertised nothing in that direction, which reads as
133
+ * unbounded. A mint saying nothing is not a mint saying zero, so silence never
134
+ * narrows what we'll attempt — same defensive posture as the absent-`disabled`
135
+ * rule in {@link canMintBolt11Sat}.
136
+ */
137
+ interface MintAmountBounds {
138
+ /** Smallest amount the mint will quote, or `null` when unadvertised. */
139
+ minSats: number | null;
140
+ /** Largest amount the mint will quote, or `null` when unadvertised. */
141
+ maxSats: number | null;
142
+ }
143
+ /** Error categories returned when a mint health probe fails. */
144
+ type HealthErrorCode = "timeout" | "http_error" | "network" | "parse_error" | "missing_fields";
145
+ /** Outcome of a single health probe against one mint. */
146
+ interface MintHealthCheckResult {
147
+ /** Mint URL exactly as passed in (not normalised). */
148
+ mintUrl: string;
149
+ /** True iff `/v1/info` returned 200, parsed as JSON, and had `pubkey` + `version`. */
150
+ ok: boolean;
151
+ /** Wall-clock duration of the successful (or final failed) attempt in ms. */
152
+ latencyMs: number;
153
+ /** NUT-06 mint pubkey when present. */
154
+ pubkey?: string;
155
+ /** NUT-06 mint version string (e.g. "Nutshell/0.20.0") when present. */
156
+ version?: string;
157
+ /** Sorted list of NUT keys the mint declares support for. */
158
+ supportedNuts?: string[];
159
+ /** Subset of `DEFAULT_REQUIRED_NUTS` the mint does not declare. Empty array when fully supported. */
160
+ missingRequiredNuts?: string[];
161
+ /** True when the mint advertises NUT-04 with method `bolt11` and unit `sat`. */
162
+ bolt11SatMintSupported?: boolean;
163
+ /** True when the mint advertises NUT-05 with method `bolt11` and unit `sat`. */
164
+ bolt11SatMeltSupported?: boolean;
165
+ /**
166
+ * True when the mint can currently *issue* — NUT-04 advertises bolt11/sat and
167
+ * is not switched off (`disabled: true`). Distinct from
168
+ * {@link bolt11SatMintSupported}, which only asks whether the method exists:
169
+ * a mint in melt-only recovery keeps advertising the method and turns the
170
+ * flag on. Consulted when picking a funding default (internal-review).
171
+ */
172
+ mintingEnabled?: boolean;
173
+ /** Same question for NUT-05 (melt) — whether the mint can currently pay out. */
174
+ meltingEnabled?: boolean;
175
+ /**
176
+ * True when the mint can currently serve `/v1/swap` — see {@link canSwap} for
177
+ * why an unadvertised NUT-3 reads as `true`. This is what a per-call spend
178
+ * needs, so a `false` here is the reason a spend routes around this mint
179
+ * (internal-review).
180
+ */
181
+ swapEnabled?: boolean;
182
+ /**
183
+ * Amount limits the mint advertises for issuing (NUT-04 bolt11/sat), in sats
184
+ * (internal-review). Consulted when picking a funding default and when refusing an
185
+ * amount locally, so a fund outside the range never opens a Lightning quote.
186
+ */
187
+ mintAmountBounds?: MintAmountBounds;
188
+ /** The NUT-05 twin — limits on a single payout, which `dvm wallet cash-out` sizes against. */
189
+ meltAmountBounds?: MintAmountBounds;
190
+ /**
191
+ * True when the mint passes the full {@link assertNutSupport} gate — every
192
+ * required NUT present (not `supported: false`) and bolt11/sat on NUT-4 +
193
+ * NUT-5. The runtime `MintHealthTracker` treats a mint as healthy only when
194
+ * this is true, reproducing the boot-time NUT gate post-`listen` (internal-review).
195
+ */
196
+ nutCompliant?: boolean;
197
+ /** Raw `nuts` object from the `/v1/info` response. Used by `assertNutSupport`. */
198
+ nutsRaw?: Record<string, unknown>;
199
+ /** Populated when `ok` is false. */
200
+ error?: {
201
+ code: HealthErrorCode;
202
+ message: string;
203
+ };
204
+ }
205
+ /** Tunables for `checkMintHealth`. */
206
+ interface CheckMintHealthOptions {
207
+ /** Per-attempt timeout in ms. Default: 5000. */
208
+ timeoutMs?: number;
209
+ /** Total attempts including the first. Default: 3. */
210
+ retries?: number;
211
+ /** Inter-attempt backoff schedule in ms. Default: [200, 500, 1000]. */
212
+ backoffMs?: number[];
213
+ /** Injected `fetch` for tests. Default: global fetch. */
214
+ fetchImpl?: typeof fetch;
215
+ }
216
+ /**
217
+ * Probe a Cashu mint's `/v1/info` endpoint with timeout + retries, and
218
+ * report whether it serves the NUT-04 + NUT-05 capabilities first-party DVMs
219
+ * depend on. Never throws — failures are returned as `{ ok: false, error }`.
220
+ */
221
+ declare function checkMintHealth(mintUrl: string, opts?: CheckMintHealthOptions): Promise<MintHealthCheckResult>;
222
+ /**
223
+ * Whether the mint can currently serve `/v1/swap` — the operation every
224
+ * per-call Cashu payment depends on (internal-review).
225
+ *
226
+ * **An absent NUT-3 means yes.** Swap is a baseline mint operation and healthy
227
+ * mints do not enumerate it — neither coinos nor lnvoltz advertises a `"3"` key
228
+ * (see `public design rationale`).
229
+ * Reading silence as "incapable" would rule out every working mint.
230
+ *
231
+ * A mint that has *switched swaps off* does say so: a mint in melt-only
232
+ * recovery publishes a `"3"` entry flagged `disabled` / `supported: false`
233
+ * alongside its live NUT-5. Both spellings are honoured because this is the
234
+ * only signal distinguishing "can't swap" from "swap failed for some other
235
+ * reason", and it costs nothing to accept either.
236
+ *
237
+ * Never a boot-time gate — like {@link canMintBolt11Sat}, this informs mint
238
+ * *selection* only, so a mint that can still melt stays loadable for cash-out.
239
+ */
240
+ declare function canSwap(nuts: Record<string, unknown>): boolean;
241
+ /** Whether `sats` falls inside a mint's advertised limits, and which end it broke. */
242
+ type AmountBoundsVerdict = "ok" | "below_min" | "above_max";
243
+ /**
244
+ * Judge one amount against one direction's limits. The single predicate both
245
+ * `dvm wallet fund` (mint selection, pre-quote refusal) and
246
+ * `dvm wallet cash-out` (per-leg sizing) ask, so the two commands can't drift
247
+ * on what "out of range" means.
248
+ */
249
+ declare function amountBoundsVerdict(sats: number, bounds?: MintAmountBounds): AmountBoundsVerdict;
250
+ /**
251
+ * Assert that a mint's NUT-06 `nuts` object advertises all required capabilities.
252
+ * Two-phase check:
253
+ * 1. Dict-level — each NUT in `requiredNuts` must be present and not have
254
+ * `supported: false`. Throws naming the missing NUT numbers and mint URL.
255
+ * 2. Method-level — NUT-4 and NUT-5 must each advertise a `bolt11`/`sat`
256
+ * entry in their `methods` array (covers NUT-23). Throws naming the
257
+ * missing method.
258
+ */
259
+ declare function assertNutSupport(mintUrl: string, nuts: Record<string, unknown>, requiredNuts?: readonly number[]): void;
260
+
261
+ /** A Lightning invoice created by the backend. */
262
+ interface CreatedInvoice {
263
+ /** BOLT11 payment request string. */
264
+ bolt11: string;
265
+ /** Payment hash (hex) — primary key for looking up settlement. */
266
+ paymentHash: string;
267
+ /** Amount in millisatoshis. */
268
+ amountMsats: number;
269
+ /** Unix milliseconds when the invoice expires. */
270
+ expiresAt: number;
271
+ }
272
+ /** Result of looking up an invoice's settlement status. */
273
+ interface InvoiceStatus {
274
+ /** True once the invoice has been paid and preimage is known. */
275
+ settled: boolean;
276
+ /** Preimage (hex) — present only after settlement. */
277
+ preimage?: string;
278
+ /** Unix milliseconds when the invoice settled (if settled). */
279
+ settledAt?: number;
280
+ /** Unix milliseconds when the invoice expires. */
281
+ expiresAt?: number;
282
+ }
283
+ /** How a payment reached a settled state — see `payInvoiceReconciling`. */
284
+ type LightningPayOutcome = "paid" | "reconciled" | "republished";
285
+ /** Settled payment plus the audit trail of how it got there. */
286
+ interface LightningPayment {
287
+ /** Payment preimage (hex) — proof the invoice was paid. */
288
+ preimage: string;
289
+ /** Routing fee reported by the wallet, in millisatoshis. Absent means unknown. */
290
+ feesPaidMsats?: number;
291
+ /** Whether the wallet answered directly, or the outcome had to be reconciled. */
292
+ outcome: LightningPayOutcome;
293
+ }
294
+ /** Bounds for a read-only wallet transaction snapshot. */
295
+ interface LightningTransactionListOptions {
296
+ /** Include transactions created at or after this Unix timestamp (seconds). */
297
+ from?: number;
298
+ /** Maximum number of transactions the wallet may return. */
299
+ limit?: number;
300
+ }
301
+ /**
302
+ * Credential-safe transaction evidence used to account for a wallet debit.
303
+ *
304
+ * Invoice, payment hash and preimage are deliberately replaced by digests or
305
+ * omitted. `fingerprint` identifies the complete reduced row; `invoiceHash`
306
+ * lets a caller bind an outgoing row to the invoice it just paid.
307
+ */
308
+ interface LightningTransactionSnapshot {
309
+ fingerprint: string;
310
+ invoiceHash?: string;
311
+ type: "incoming" | "outgoing";
312
+ amountMsats: number;
313
+ /** Wallet-reported routing fee. Absent when the wallet omitted it. */
314
+ feesPaidMsats?: number;
315
+ createdAt: number;
316
+ settledAt?: number;
317
+ }
318
+ /** What a backend can tell us about the wallet behind it. */
319
+ interface LightningWalletInfo {
320
+ /** Human-readable wallet name (e.g. "Alby Hub"). */
321
+ alias?: string;
322
+ /** Operations the wallet supports (e.g. `pay_invoice`, `lookup_invoice`). */
323
+ methods: string[];
324
+ /**
325
+ * Budget fields the wallet volunteered, if any.
326
+ *
327
+ * No rail behind this interface is required to expose a connection's
328
+ * spending cap, and NWC — today's only implementation — has no method that
329
+ * returns one. Present it when a wallet offers it, never infer it.
330
+ */
331
+ walletReportedBudget?: Record<string, unknown>;
332
+ }
333
+ /** Abstraction over Lightning wallet backends (NWC, future). */
334
+ interface LightningBackend {
335
+ /**
336
+ * Pay a bolt11 invoice exactly once. Returns the preimage on success.
337
+ *
338
+ * Implementations must never re-send a payment on an unknown outcome without
339
+ * first reconciling against the wallet — the rails behind this interface have
340
+ * no idempotency key, so a blind retry is a second payment.
341
+ *
342
+ * `amountMsats` is passed when known (callers always have it from the
343
+ * provider's payment-request). Backends that don't need it may ignore the
344
+ * param.
345
+ */
346
+ payInvoice(bolt11: string, amountMsats?: number): Promise<LightningPayment>;
347
+ /** Get wallet balance in millisatoshis. */
348
+ getBalance(): Promise<number>;
349
+ /** Get wallet info (name, supported methods, any volunteered budget fields). */
350
+ getInfo(): Promise<LightningWalletInfo>;
351
+ /** Create a new incoming invoice for the given amount and description. */
352
+ createInvoice(params: {
353
+ amountMsats: number;
354
+ description?: string;
355
+ expirySeconds?: number;
356
+ }): Promise<CreatedInvoice>;
357
+ /** Look up an invoice's settlement status by payment hash. */
358
+ lookupInvoice(paymentHash: string): Promise<InvoiceStatus>;
359
+ /**
360
+ * Return a bounded, credential-safe transaction snapshot when supported.
361
+ * Optional so existing backends remain source-compatible; without it an
362
+ * exact total wallet debit cannot be attributed.
363
+ */
364
+ listTransactions?(options: LightningTransactionListOptions): Promise<LightningTransactionSnapshot[]>;
365
+ }
366
+
367
+ export { type AttestationPayload as A, type BuilderIdentityKeypair as B, type CreatedInvoice as C, type InvoiceStatus as I, type LightningTransactionListOptions as L, type MintAmountBounds as M, type LightningTransactionSnapshot as a, type LightningBackend as b, type LightningPayment as c, type LightningWalletInfo as d, type MintHealthCheckResult as e, type CheckMintHealthOptions as f, type LockPubkey as g, amountBoundsVerdict as h, assertNutSupport as i, buildAttestation as j, canSwap as k, checkMintHealth as l, generateIdentity as m, hashCapabilities as n, loadIdentitySecret as o, signAttestation as s, toLockPubkey as t, verifyAttestation as v, writeIdentity as w };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MemoryCreditLedger
3
- } from "./chunk-EXHBXA4U.js";
4
- import "./chunk-LWUR4CGG.js";
5
- import "./chunk-C3MTFLC6.js";
3
+ } from "./chunk-DBCLBYHP.js";
4
+ import "./chunk-MLRCSJYX.js";
6
5
  import "./chunk-S3XAHZQY.js";
6
+ import "./chunk-C3MTFLC6.js";
7
7
  export {
8
8
  MemoryCreditLedger
9
9
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PostgresJobStore
3
- } from "./chunk-6JZIX5WW.js";
3
+ } from "./chunk-LLXV32HA.js";
4
4
  import "./chunk-S3XAHZQY.js";
5
5
  export {
6
6
  PostgresJobStore
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RevenueReporter
3
- } from "./chunk-2ABMGUDS.js";
3
+ } from "./chunk-NFRM5QYP.js";
4
4
  import "./chunk-S3XAHZQY.js";
5
5
  export {
6
6
  RevenueReporter
@@ -1,23 +1,26 @@
1
- import { ah as CashuMode, bP as CreditDrainEnqueue, R as ResolvedCreditConfig, bQ as DVMAuthScheme, B as SignedRequestDomain, bR as CreditLedgerLike, bS as X402RefundSettlementGate, bT as CreditSnapshot, bU as DrawResult, bV as X402SettlementStatus, bW as X402UnresolvedRefund, bX as GrownDrawResult, bY as DrawResolution, bZ as FundingRecord, Y as FundingReceipt, b_ as CreditInvoiceRecord, b$ as InvoiceSettlement, c0 as BlockedInvoiceCursor, c1 as InvoiceReconciliation, c2 as InvoiceWriteOff, c3 as DrawRecord, c4 as StalePendingDrawCursor, c5 as TempoCreditLossEvidence, c6 as CreditLedgerQuerier, c7 as TempoCreditLoss, c8 as X402CreditLossEvidence, c9 as X402CreditLoss, ca as DrainMethod, cb as DrainRequestResult, cc as BitcoinDepositLiability, ao as FundingLot, cd as CreditDrainRecord, ce as ChannelDrainCursor, cf as DrainWriteOff, cg as DrainReleaseResult, ch as DrainFulfilment, ci as DrainTransitionResult, cj as StreamableJobStore, ck as ReceiptIssuingStore, J as JobRecord, cl as RequestIdClaim, cm as RequestIdClaimResult, _ as JobReceipt, aw as OutgoingMessage, cn as AppendOutgoingOptions, co as PaymentCreditDelta, cp as VerifyAndCreditResult, cq as JobCounters, a2 as Message, K as KVStore, G as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../job-store-C53VQ5uu.js';
2
- export { cr as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, cs as ClientCompatibility, ct as ClientCompatibilityEnv, cu as ClientCompatibilityGate, cv as ClientCompatibilityRequirement, cw as ClientSemVer, e as CreateSignedRequestVerifierOpts, cx as CreditFundingBasis, cy as CreditInvoiceStatus, cz as CreditLedger, cA as CreditLedgerError, cB as CreditLedgerErrorCode, cC as CreditLedgerErrorDetails, cD as CreditLedgerPool, cE as CreditStatus, cF as DRAIN_DELIVERY_RESERVE_SATS, cG as DVM_PROTOCOL_VERSION, cH as DrainConflictReason, cI as DrawRailValue, cJ as DrawStatus, n as JobStatus, o as JobStore, cK as PostgresX402ChannelStorage, cL as ReplayStoreBackend, cM as RevenueSkippedNoRailPayload, cN as RevenueSkippedNoRailReason, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, cO as Secp256k1AuthOpts, z as SignedRequestAudience, E as SignedRequestError, F as SignedRequestFailure, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, cP as X402ChannelStorageOpts, cQ as X402RelayLockHolder, cR as X402RelaySubmissionLock, cS as X402RelaySubmissionLockError, cT as allocateDrawValue, cU as clientCompatibilityAttributes, cV as clientCompatibilityMiddleware, cW as clientUpgradeRequired, O as createSignedRequestVerifier, cX as isStreamableJobStore, cY as parseClientCapabilities, cZ as parseClientCompatibility, c_ as parseDvmClient, c$ as parseProtocolVersion, d0 as requireClientCompatibility, d1 as secp256k1Auth, d2 as signedRequestInput, V as signedRequestStatementHeader } from '../job-store-C53VQ5uu.js';
1
+ import { aa as CashuMode, bJ as CreditDrainEnqueue, R as ResolvedCreditConfig, bK as DVMAuthScheme, z as SignedRequestDomain, bL as CreditLedgerLike, bM as X402RefundSettlementGate, bN as CreditSnapshot, bO as DrawResult, bP as X402SettlementStatus, bQ as X402UnresolvedRefund, bR as GrownDrawResult, bS as DrawResolution, bT as FundingRecord, W as FundingReceipt, bU as CreditInvoiceRecord, bV as InvoiceSettlement, bW as BlockedInvoiceCursor, bX as InvoiceReconciliation, bY as InvoiceWriteOff, bZ as DrawRecord, b_ as StalePendingDrawCursor, b$ as TempoCreditLossEvidence, c0 as CreditLedgerQuerier, c1 as TempoCreditLoss, c2 as X402CreditLossEvidence, c3 as X402CreditLoss, c4 as DrainMethod, c5 as DrainRequestResult, c6 as BitcoinDepositLiability, bn as FundingLot, c7 as CreditDrainRecord, c8 as ChannelDrainCursor, c9 as DrainWriteOff, ca as DrainReleaseResult, cb as DrainFulfilment, cc as DrainTransitionResult, X as JobReceipt, a0 as Message, K as KVStore, F as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-3cT4Shk0.js';
2
+ export { cd as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, ce as ClientCompatibility, cf as ClientCompatibilityEnv, cg as ClientCompatibilityGate, ch as ClientCompatibilityRequirement, ci as ClientSemVer, e as CreateSignedRequestVerifierOpts, cj as CreditFundingBasis, ck as CreditInvoiceStatus, cl as CreditLedger, cm as CreditLedgerError, cn as CreditLedgerErrorCode, co as CreditLedgerErrorDetails, cp as CreditLedgerPool, cq as CreditStatus, cr as DRAIN_DELIVERY_RESERVE_SATS, cs as DVM_PROTOCOL_VERSION, ct as DrainConflictReason, cu as DrawRailValue, cv as DrawStatus, cw as PostgresX402ChannelStorage, cx as ReplayStoreBackend, cy as RevenueSkippedNoRailPayload, cz as RevenueSkippedNoRailReason, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, cA as Secp256k1AuthOpts, y as SignedRequestAudience, B as SignedRequestError, E as SignedRequestFailure, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, J as SignedRequestVerifier, cB as X402ChannelStorageOpts, cC as X402RelayLockHolder, cD as X402RelaySubmissionLock, cE as X402RelaySubmissionLockError, cF as allocateDrawValue, cG as clientCompatibilityAttributes, cH as clientCompatibilityMiddleware, cI as clientUpgradeRequired, M as createSignedRequestVerifier, cJ as parseClientCapabilities, cK as parseClientCompatibility, cL as parseDvmClient, cM as parseProtocolVersion, cN as requireClientCompatibility, cO as secp256k1Auth, cP as signedRequestInput, O as signedRequestStatementHeader } from '../step-cache-3cT4Shk0.js';
3
3
  import { Pool } from 'pg';
4
- import { aJ as CreditMenu, i as AppEnv, U as UpfrontPaymentOpts, s as PaymentInfo, aK as ReceiptIssuer, aL as LightningReceive, aM as TempoSettlementReadiness, aN as DVMHostOpts } from '../credit-menu-BM4qCD5U.js';
5
- export { aO as BuildCreditMenuArgs, aP as BuilderIdentity, aQ as CREDIT_ENVELOPE_KEYS, g as ConsumedCredentialStore, aR as CreateX402BatchSettlementServerOpts, aS as CreditEnvelope, aT as CreditEnvelopeError, aU as CreditFundCommitment, aV as CreditTerms, aW as DEFAULT_INVOICE_TTL_SECONDS, aX as DVMHost, aY as JobManager, aZ as JobManagerOpts, a_ as LightningReceiveConfig, a$ as MIN_INVOICE_TTL_SECONDS, b0 as MemoryConsumedCredentialStore, b1 as MemoryConsumedCredentialStoreOpts, b2 as MemoryProcessedPaymentStore, b3 as MemoryX402ExactSettlementStore, b4 as MountOpts, b5 as OwnerDisplay, b6 as PlatformReporterOpts, b7 as PostgresProcessedPaymentStore, b8 as PostgresX402ExactSettlementStore, b9 as PriceFiat, ba as ProcessedPaymentQuerier, bb as ProcessedPaymentRail, bc as ProcessedPaymentRecord, bd as ProcessedPaymentReplayError, be as ProcessedPaymentStore, bf as X402BatchAcceptance, bg as X402BatchFunding, bh as X402BatchRefusal, bi as X402BatchSettlementServer, bj as X402ExactAcceptance, bk as X402ExactIntentConflictError, bl as X402ExactSettlementAttempt, bm as X402ExactSettlementChainEvidence, bn as X402ExactSettlementEffect, bo as X402ExactSettlementEvidenceMissingError, bp as X402ExactSettlementEvidenceReader, bq as X402ExactSettlementIntent, br as X402ExactSettlementNotReadyError, bs as X402ExactSettlementServer, bt as X402ExactSettlementServerOpts, bu as X402ExactSettlementStatus, bv as X402ExactSettlementStore, bw as X402SettlementChainEvidence, bx as X402SettlementEvidenceReader, by as X402SettlementSubmissionError, bz as X402_BATCH_AUTO_SETTLEMENT, bA as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bB as X402_BATCH_SETTLEMENT_NETWORK, bC as attachCreditMenu, bD as buildCreditMenu, bE as createDVMHost, bF as createX402BatchSettlementServer, bG as creditEnvelopeIgnoreFields, bH as drawSettlementRef, bI as extractCreditEnvelope, bJ as fundingCommitment, bK as selectPrimaryCredit, bL as stripCreditEnvelope, bM as toCreditView } from '../credit-menu-BM4qCD5U.js';
4
+ import { ak as CreditMenu, b as AppEnv, U as UpfrontPaymentOpts, h as PaymentInfo, al as ReceiptIssuer, am as LightningReceive, an as TempoSettlementReadiness, ao as DVMHostOpts } from '../credit-menu-C7zAJElJ.js';
5
+ export { ap as BuildCreditMenuArgs, aq as BuilderIdentity, ar as CREDIT_ENVELOPE_KEYS, C as ConsumedCredentialStore, as as CreateX402BatchSettlementServerOpts, at as CreditEnvelope, au as CreditEnvelopeError, av as CreditFundCommitment, aw as CreditTerms, ax as DEFAULT_INVOICE_TTL_SECONDS, ay as DVMHost, az as JobManager, aA as JobManagerOpts, aB as LightningReceiveConfig, aC as MIN_INVOICE_TTL_SECONDS, aD as MemoryConsumedCredentialStore, aE as MemoryConsumedCredentialStoreOpts, aF as MemoryProcessedPaymentStore, aG as MemoryX402ExactSettlementStore, aH as MountOpts, aI as OwnerDisplay, aJ as PlatformReporterOpts, aK as PostgresProcessedPaymentStore, aL as PostgresX402ExactSettlementStore, aM as PriceFiat, aN as ProcessedPaymentQuerier, aO as ProcessedPaymentRail, aP as ProcessedPaymentRecord, aQ as ProcessedPaymentReplayError, aR as ProcessedPaymentStore, aS as X402BatchAcceptance, aT as X402BatchFunding, aU as X402BatchRefusal, aV as X402BatchSettlementServer, aW as X402ExactAcceptance, aX as X402ExactIntentConflictError, aY as X402ExactSettlementAttempt, aZ as X402ExactSettlementChainEvidence, a_ as X402ExactSettlementEffect, a$ as X402ExactSettlementEvidenceMissingError, b0 as X402ExactSettlementEvidenceReader, b1 as X402ExactSettlementIntent, b2 as X402ExactSettlementNotReadyError, b3 as X402ExactSettlementServer, b4 as X402ExactSettlementServerOpts, b5 as X402ExactSettlementStatus, b6 as X402ExactSettlementStore, b7 as X402SettlementChainEvidence, b8 as X402SettlementEvidenceReader, b9 as X402SettlementSubmissionError, ba as X402_BATCH_AUTO_SETTLEMENT, bb as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bc as X402_BATCH_SETTLEMENT_NETWORK, bd as attachCreditMenu, be as buildCreditMenu, bf as createDVMHost, bg as createX402BatchSettlementServer, bh as creditEnvelopeIgnoreFields, bi as drawSettlementRef, bj as extractCreditEnvelope, bk as fundingCommitment, bl as selectPrimaryCredit, bm as stripCreditEnvelope, bn as toCreditView } from '../credit-menu-C7zAJElJ.js';
6
6
  import { Context } from 'hono';
7
7
  import { z } from 'zod';
8
- import { F as FxFetcher } from '../fx-C-liI3oY.js';
8
+ import { F as FxFetcher } from '../fx-BF_SG2i0.js';
9
+ import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-Bn23V3QU.js';
10
+ export { a as JobStatus, b as JobStore, h as isStreamableJobStore } from '../job-store-Bn23V3QU.js';
9
11
  export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from '../ssrf-DbFkpDv0.js';
10
- import '@cashu/cashu-ts';
11
12
  import 'mppx';
12
13
  import '@x402/core/server';
13
14
  import '@x402/evm/batch-settlement/server';
14
15
  import 'viem';
15
16
  import '@x402/core/types';
17
+ import '../lightning-backend-C04nH94l.js';
18
+ import '@cashu/cashu-ts';
16
19
 
17
20
  /** Lifetime of a per-call implicit credit before the ledger refuses new draws. */
18
21
  declare const IMPLICIT_CREDIT_TTL_MS: number;
19
22
 
20
- /** Cashu accumulator opts resolved from environment variables. */
23
+ /** Builder-lock and Cashu accumulator opts resolved from environment variables. */
21
24
  interface ResolvedCashuOpts {
22
25
  cashuMode: CashuMode | undefined;
23
26
  lockPubkey: string | undefined;
@@ -27,10 +30,11 @@ interface ResolvedCashuOpts {
27
30
  canonicalDvmId: string | undefined;
28
31
  }
29
32
  /**
30
- * Resolves cashu accumulator opts from environment variables, initializing DB
31
- * tables when all prerequisites are met. Extracted from serve() so DVMs that
32
- * call createDVMServer directly (cast, scrape) can wire cashu without using
33
- * the serve() wrapper (internal-review).
33
+ * Resolves the builder-lock and Cashu accumulator opts from environment
34
+ * variables, initializing DB tables when their prerequisites are met.
35
+ * Extracted from serve() so DVMs that call createDVMServer directly (cast,
36
+ * scrape) can wire Cashu and the builder admin surface without using the
37
+ * serve() wrapper (internal-review).
34
38
  *
35
39
  * @param pool - existing Postgres pool to reuse; pass undefined when no DB is available
36
40
  * @param cashuModeHint - programmatic override for cashu mode (serve()'s opts.cashuMode)
@@ -327,6 +331,7 @@ declare class MemoryCreditLedger implements CreditLedgerLike {
327
331
  drawId: string;
328
332
  }): Promise<DrawRecord | undefined>;
329
333
  getDrawByJobId(jobId: string): Promise<DrawRecord | undefined>;
334
+ listDrawsByJobId(jobId: string): Promise<DrawRecord[]>;
330
335
  listPendingDraws(creditId: string): Promise<DrawRecord[]>;
331
336
  listStalePendingDraws(args: {
332
337
  createdBeforeMs: number;
@@ -446,6 +451,17 @@ declare class PostgresJobStore implements StreamableJobStore, ReceiptIssuingStor
446
451
  releaseRequestIdClaim(claim: RequestIdClaim): Promise<void>;
447
452
  save(record: JobRecord): Promise<void>;
448
453
  delete(id: string): Promise<void>;
454
+ listJobsForRetention(args: {
455
+ lastActivityBeforeMs: number;
456
+ limit: number;
457
+ capabilities: string[] | null;
458
+ after?: JobRetentionCursor;
459
+ }): Promise<JobRecord[]>;
460
+ redactJob(args: {
461
+ jobId: string;
462
+ expectedLastActivityAt: number;
463
+ redactedAt: number;
464
+ }): Promise<boolean>;
449
465
  claimReceiptSeq(jobId: string): Promise<number>;
450
466
  saveReceipt(jobId: string, receipt: JobReceipt): Promise<JobReceipt | undefined>;
451
467
  appendOutgoing(jobId: string, message: OutgoingMessage, opts?: AppendOutgoingOptions): Promise<number>;