@dvmkit/sdk 0.8.0 → 0.8.1

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 (52) hide show
  1. package/dist/{chunk-5CQKSLAU.js → chunk-2U6LAASN.js} +1 -1
  2. package/dist/{chunk-6FEHRZO7.js → chunk-7PM4R4GD.js} +1 -1
  3. package/dist/{chunk-EBCLWOKF.js → chunk-AGE5XZKE.js} +1 -1
  4. package/dist/{chunk-2I3OHMTY.js → chunk-ALWVJ2RB.js} +1 -1
  5. package/dist/{chunk-ATXDKX6F.js → chunk-AVV5SYGO.js} +1 -1
  6. package/dist/{chunk-DZQYQN2X.js → chunk-BFGQG4WY.js} +7 -0
  7. package/dist/{chunk-VYP6ADCS.js → chunk-FM6QAGJC.js} +2 -2
  8. package/dist/{chunk-QPXI7YPH.js → chunk-G3MPHW5I.js} +1 -1
  9. package/dist/{chunk-I6PHA54S.js → chunk-IHQUBATH.js} +1 -1
  10. package/dist/{chunk-5K5E6ME6.js → chunk-ILBSZMJL.js} +1 -1
  11. package/dist/{chunk-BL6LRWXD.js → chunk-IOQIXRGM.js} +1 -1
  12. package/dist/{chunk-X3JEME6P.js → chunk-J5J63WDC.js} +1 -1
  13. package/dist/{chunk-GSPV3UIM.js → chunk-JIZ4ZIXX.js} +254 -72
  14. package/dist/{chunk-TFYY5APM.js → chunk-NA2KOR6G.js} +1 -1
  15. package/dist/{chunk-PRSKC7AD.js → chunk-NU5RWJ5B.js} +1 -1
  16. package/dist/{chunk-IFWUWHTW.js → chunk-OP7VCGQR.js} +1 -1
  17. package/dist/{chunk-GB5XPAA5.js → chunk-QKE5NDPF.js} +213 -38
  18. package/dist/{chunk-55NKZQOC.js → chunk-RSNC5T6C.js} +1 -1
  19. package/dist/{chunk-XXLUIXPO.js → chunk-UDJNZ3UG.js} +1 -1
  20. package/dist/{chunk-YPSJU3OH.js → chunk-UVS7MRJX.js} +2 -2
  21. package/dist/{chunk-P5WEZXJ2.js → chunk-UWGBI5WK.js} +58 -1
  22. package/dist/{chunk-RTFBVXCN.js → chunk-ZEPJF4JC.js} +1 -1
  23. package/dist/{content-retention-D2K4MKNO.d.ts → content-retention-B7ddtJ2y.d.ts} +1 -1
  24. package/dist/{credit-ledger-AOU6S34N.js → credit-ledger-KIQIE6I6.js} +3 -3
  25. package/dist/{credit-menu-C-8g2cHT.d.ts → credit-menu-BH3g9GQa.d.ts} +4 -4
  26. package/dist/{fx-Ql4nvdbh.d.ts → fx-DN26_J7o.d.ts} +1 -1
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +4 -4
  29. package/dist/internal/caller.d.ts +6 -6
  30. package/dist/internal/caller.js +7 -7
  31. package/dist/internal/server.d.ts +7 -7
  32. package/dist/internal/server.js +20 -20
  33. package/dist/{job-store-DCvJQUX0.d.ts → job-store-Cq21JT37.d.ts} +1 -1
  34. package/dist/{lightning-backend-CY5ML3km.d.ts → lightning-backend-S8F8nf8q.d.ts} +1 -1
  35. package/dist/{memory-credit-ledger-4HWYINKJ.js → memory-credit-ledger-ATYFAYBG.js} +4 -4
  36. package/dist/{mpp-setup-2BKTPEK6.js → mpp-setup-ZTORW3VF.js} +3 -3
  37. package/dist/{payout-reporter-HQSIIBFL.js → payout-reporter-NN6K2IVQ.js} +2 -2
  38. package/dist/{postgres-consumed-credential-store-R7DNU6CM.js → postgres-consumed-credential-store-XJTE5PCA.js} +1 -1
  39. package/dist/{postgres-job-store-6VGFL6XE.js → postgres-job-store-AR6ZJUQV.js} +2 -2
  40. package/dist/{postgres-replay-store-SY26NUCI.js → postgres-replay-store-33K33QV7.js} +2 -2
  41. package/dist/{pricing-H2RA4X2R.js → pricing-G5IN5YJE.js} +3 -3
  42. package/dist/{revenue-reporter-X52GPZ5U.js → revenue-reporter-KDUZLD5F.js} +2 -2
  43. package/dist/server/index.d.ts +10 -10
  44. package/dist/server/index.js +27 -27
  45. package/dist/{step-cache-BOWAn_BH.d.ts → step-cache-CR12EZ1Q.d.ts} +108 -4
  46. package/dist/{tempo-charge-store-NKXJ2AXE.js → tempo-charge-store-XEGJYM3G.js} +2 -2
  47. package/dist/{tempo-session-store-ZSDQIWSU.js → tempo-session-store-3WTDOO7H.js} +3 -3
  48. package/dist/testing/index.d.ts +3 -3
  49. package/dist/testing/index.js +6 -6
  50. package/dist/{usd-MAtMp3DB.d.ts → usd-s_VZ_eS7.d.ts} +1 -1
  51. package/dist/{x402-Q4S36NHQ.js → x402-HQ5GRQZU.js} +3 -3
  52. package/package.json +1 -1
@@ -1227,13 +1227,51 @@ declare class HostedSettlementReportObligations {
1227
1227
  };
1228
1228
  }): Promise<HostedEffectReservation | null>;
1229
1229
  reserveTempo(channelId: string, operation: "settle" | "close", drainId?: string): Promise<HostedEffectReservation>;
1230
+ /**
1231
+ * Retire a close reservation that never recorded a transaction and reserve
1232
+ * the drain's next attempt, in one transaction, so the drain always keeps one
1233
+ * outstanding close obligation. A close from the retired attempt that lands
1234
+ * late is a close of the same channel: `recordSubmitted` on the retired row
1235
+ * writes it onto the successor, and recovery attaches it there if that
1236
+ * attempt never got to write, so it is reported once.
1237
+ *
1238
+ * The caller has just read the channel open on chain. The age bound only
1239
+ * spares a reservation young enough to be inside its first receipt wait; an
1240
+ * attempt slowed past it by a degraded RPC can still be running.
1241
+ */
1242
+ releaseStaleTempoClose(id: string, channelId: string, drainId: string, limits: {
1243
+ staleAfterMs: number;
1244
+ maxReleases: number;
1245
+ }): Promise<{
1246
+ outcome: "reserved";
1247
+ id: string;
1248
+ releases: number;
1249
+ } | {
1250
+ outcome: "in_flight";
1251
+ } | {
1252
+ outcome: "exhausted";
1253
+ releases: number;
1254
+ }>;
1255
+ /**
1256
+ * Resolve an unsubmitted close reservation whose channel the payer exited
1257
+ * on its own: no cooperative close of ours can land on a finalized channel.
1258
+ */
1259
+ resolveTempoCloseExit(id: string): Promise<boolean>;
1260
+ private reserveTempoIn;
1230
1261
  findPendingTempo(channelId: string, operation: "settle" | "close"): Promise<ObligationRow | undefined>;
1231
1262
  /** The original close obligation reserved for this drain, while its report is outstanding. */
1232
1263
  pendingTempoClose(channelId: string, drainId: string): Promise<{
1233
1264
  id: string;
1234
1265
  txHash: string | null;
1235
1266
  reservedAtMs: number;
1267
+ searchBefore: bigint | null;
1236
1268
  } | undefined>;
1269
+ /**
1270
+ * Where the next search for this close obligation's transaction resumes. It
1271
+ * lives on the obligation, not the drain's close intent, because releasing
1272
+ * the drain deletes the intent while the obligation still needs the search.
1273
+ */
1274
+ recordTempoCloseSearch(id: string, resumeAt: bigint): Promise<void>;
1237
1275
  submittedIds(rail: Rail, operation: Operation, txHash: string, batchId?: string): Promise<string[]>;
1238
1276
  refundClaimDelta(txHash: string, channelId: string): Promise<bigint>;
1239
1277
  assertReservedTempoClose(id: string, channelId: string): Promise<void>;
@@ -1242,6 +1280,26 @@ declare class HostedSettlementReportObligations {
1242
1280
  reserveOpenX402Settlement(): Promise<HostedEffectReservation>;
1243
1281
  private ensureOpenX402Batch;
1244
1282
  recordSubmitted(id: string, txHash: string): Promise<void>;
1283
+ /**
1284
+ * Close reservations that never recorded a transaction, oldest first. Each
1285
+ * one owes a payout report only if its close lands, so it stays unresolved
1286
+ * until a reconcile reads how its channel finalized.
1287
+ */
1288
+ unsubmittedTempoCloses(limit?: number): Promise<Array<{
1289
+ id: string;
1290
+ channelId: string;
1291
+ drainId: string;
1292
+ reservedAtMs: number;
1293
+ searchBefore: bigint | null;
1294
+ }>>;
1295
+ /**
1296
+ * A retired close reservation's attempt can still be running when its
1297
+ * successor is reserved, and its close can land. The close is the same
1298
+ * channel's, so it belongs to the drain's outstanding obligation; writing it
1299
+ * onto the retired row would leave that obligation without a transaction and
1300
+ * the payout unreported.
1301
+ */
1302
+ private successorOfRetiredClose;
1245
1303
  recoveryCandidates(): Promise<HostedRecoverableEffect[]>;
1246
1304
  recoverOriginalX402Refunds(): Promise<Array<{
1247
1305
  id: string;
@@ -4424,6 +4482,18 @@ declare class PostgresTempoSessionStore implements Store.AtomicStore {
4424
4482
  getClose(channelId: string): Promise<TempoSessionCloseRecord | null>;
4425
4483
  /** Persist proof that a cooperative close reached terminal chain state. */
4426
4484
  confirmClose(channelId: string, drainId: string, reference: string): Promise<TempoSessionCloseRecord>;
4485
+ /** Set a close's reference only if none is set, reporting whether this call set it. */
4486
+ claimCloseReference(channelId: string, drainId: string, reference: string): Promise<{
4487
+ reference: string | null;
4488
+ claimed: boolean;
4489
+ }>;
4490
+ getCloseRecovery(channelId: string): Promise<{
4491
+ updatedAtMs: number;
4492
+ searchBefore: bigint | null;
4493
+ settledBeforeClose: bigint | null;
4494
+ } | null>;
4495
+ /** Record where a paused close search resumes; the cursor only moves back. */
4496
+ recordCloseSearch(channelId: string, drainId: string, resumeAt: bigint): Promise<void>;
4427
4497
  private runCloseIntentTransaction;
4428
4498
  private transaction;
4429
4499
  private writeCloseIntent;
@@ -4566,6 +4636,13 @@ interface MppxServer {
4566
4636
  settled: number;
4567
4637
  inFlight: number;
4568
4638
  }>;
4639
+ /**
4640
+ * Bring hosted close obligations whose channel has finalized to what the
4641
+ * chain shows, without settling anything. The sweep runs it too; the hosting
4642
+ * closure runs it alone before it decides, since those obligations block
4643
+ * the closure certificate.
4644
+ */
4645
+ reconcileTempoSessionCloses?: () => Promise<void>;
4569
4646
  /**
4570
4647
  * Reconcile and, if the channel is at risk, settle exactly one TIP-1034
4571
4648
  * channel. The forced-close protection path: a verified on-chain
@@ -4760,12 +4837,39 @@ interface TempoSessionChainOps {
4760
4837
  }): Promise<Hex>;
4761
4838
  readChannelClose(client: Client, channelId: Hex, txHash: Hex): Promise<TempoChannelCloseAmounts>;
4762
4839
  /**
4763
- * The transaction that emitted this channel's `ChannelClosed`, searched back
4764
- * from the chain head no further than blocks older than `notBeforeMs`. Null
4765
- * only when that whole range was searched and holds no close.
4840
+ * Search back for how this channel finalized: the newest `ChannelClosed`,
4841
+ * `CloseRequested` or `CloseRequestCancelled` log, from `startBlock` (the
4842
+ * chain head when omitted) down to blocks older than `notBeforeMs`. One call searches a bounded number of
4843
+ * windows; `paused` names the block the next call resumes from.
4766
4844
  */
4767
- findChannelClose(client: Client, channelId: Hex, escrowContract: `0x${string}`, notBeforeMs: number): Promise<Hex | null>;
4845
+ findChannelClose(client: Client, channelId: Hex, escrowContract: `0x${string}`, notBeforeMs: number, startBlock?: bigint): Promise<TempoChannelCloseSearch>;
4768
4846
  }
4847
+ type TempoChannelCloseSearch =
4848
+ /** A `ChannelClosed` log, with the address that sent its transaction. */
4849
+ {
4850
+ outcome: "closed";
4851
+ txHash: Hex;
4852
+ sender: `0x${string}`;
4853
+ }
4854
+ /**
4855
+ * The payer's `requestClose` is newer than any `ChannelClosed` and was not
4856
+ * cancelled: a timed exit.
4857
+ */
4858
+ | {
4859
+ outcome: "exit_requested";
4860
+ }
4861
+ /**
4862
+ * Nothing read shows what finalized the channel; a later search resumes at
4863
+ * `stoppedAt`, which never leads below the reservation's time bound. Without
4864
+ * it the range may still hold the answer, and a later search starts over.
4865
+ */
4866
+ | {
4867
+ outcome: "none";
4868
+ stoppedAt?: bigint;
4869
+ } | {
4870
+ outcome: "paused";
4871
+ resumeAt: bigint;
4872
+ };
4769
4873
  declare function attachTempoSessionRuntime(mppx: MppxServer, config: MppOpts["tempoSession"], chainOpOverrides?: Partial<TempoSessionChainOps>): MppxServer;
4770
4874
  /** Test-only seams for deterministic watcher coverage without a live Tempo RPC. */
4771
4875
  declare const _testing: {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  PostgresTempoChargeStore
3
- } from "./chunk-TFYY5APM.js";
3
+ } from "./chunk-NA2KOR6G.js";
4
4
  import "./chunk-YG7G4DPZ.js";
5
- import "./chunk-DZQYQN2X.js";
5
+ import "./chunk-BFGQG4WY.js";
6
6
  import "./chunk-COYKJRMM.js";
7
7
  export {
8
8
  PostgresTempoChargeStore
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  PostgresTempoSessionStore,
3
3
  assertMonotonicTransition
4
- } from "./chunk-P5WEZXJ2.js";
4
+ } from "./chunk-UWGBI5WK.js";
5
5
  import "./chunk-YG7G4DPZ.js";
6
- import "./chunk-6FEHRZO7.js";
7
- import "./chunk-DZQYQN2X.js";
6
+ import "./chunk-7PM4R4GD.js";
7
+ import "./chunk-BFGQG4WY.js";
8
8
  import "./chunk-COYKJRMM.js";
9
9
  export {
10
10
  PostgresTempoSessionStore,
@@ -1,6 +1,6 @@
1
- import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-D2K4MKNO.js';
2
- import { a0 as JobReceipt, a5 as Message, a1 as MessageType, K as KVStore, L as Logger, v as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-BOWAn_BH.js';
3
- 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-DCvJQUX0.js';
1
+ import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-B7ddtJ2y.js';
2
+ import { a0 as JobReceipt, a5 as Message, a1 as MessageType, K as KVStore, L as Logger, v as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-CR12EZ1Q.js';
3
+ 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-Cq21JT37.js';
4
4
  import 'hono';
5
5
  import 'mppx';
6
6
  import '@x402/core/server';
@@ -4,22 +4,22 @@ import {
4
4
  import {
5
5
  MemoryJobStore,
6
6
  createInstrumentedFetch
7
- } from "../chunk-I6PHA54S.js";
7
+ } from "../chunk-IHQUBATH.js";
8
8
  import {
9
9
  JobCancelledError
10
10
  } from "../chunk-AFV77S4C.js";
11
11
  import {
12
12
  createNoopLogger
13
- } from "../chunk-IFWUWHTW.js";
14
- import "../chunk-BL6LRWXD.js";
13
+ } from "../chunk-OP7VCGQR.js";
14
+ import "../chunk-IOQIXRGM.js";
15
15
  import "../chunk-FUJ36YDV.js";
16
16
  import "../chunk-66HGCPBU.js";
17
17
  import "../chunk-BQJIFRAZ.js";
18
- import "../chunk-XXLUIXPO.js";
18
+ import "../chunk-UDJNZ3UG.js";
19
19
  import {
20
20
  validateCurrency
21
- } from "../chunk-5CQKSLAU.js";
22
- import "../chunk-DZQYQN2X.js";
21
+ } from "../chunk-2U6LAASN.js";
22
+ import "../chunk-BFGQG4WY.js";
23
23
 
24
24
  // src/sdk/testing/test-context.ts
25
25
  function createTestContext(opts) {
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-BOWAn_BH.js';
1
+ import { C as Currency } from './step-cache-CR12EZ1Q.js';
2
2
 
3
3
  /**
4
4
  * Thrown by `fiatToSatsCeil` / `satsToFiat` when the supplied `ratePerBtc` is
@@ -6,8 +6,8 @@ import {
6
6
  } from "./chunk-WMGXJQI3.js";
7
7
  import {
8
8
  verifyX402Payment
9
- } from "./chunk-YPSJU3OH.js";
10
- import "./chunk-ATXDKX6F.js";
9
+ } from "./chunk-UVS7MRJX.js";
10
+ import "./chunk-AVV5SYGO.js";
11
11
  import {
12
12
  X402_DEFAULT_FACILITATOR,
13
13
  X402_DEFAULT_NETWORK,
@@ -37,7 +37,7 @@ import {
37
37
  x402NetworkListForCopy,
38
38
  x402SupportedNetworksHint
39
39
  } from "./chunk-BPYMEMQX.js";
40
- import "./chunk-DZQYQN2X.js";
40
+ import "./chunk-BFGQG4WY.js";
41
41
  export {
42
42
  X402_DEFAULT_FACILITATOR,
43
43
  X402_DEFAULT_NETWORK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvmkit/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "SDK for building Digital Vending Machines: pay-per-use HTTPS services AI agents can find, pay, and call with no account or API key",
5
5
  "author": "DVM Technologies Ltd",
6
6
  "keywords": [