@dvmkit/sdk 0.11.0-rc.1 → 0.12.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.
@@ -151,6 +151,14 @@ var PostgresJobStore = class {
151
151
  await withSdkInitLock(this.pool, () => this.createTables());
152
152
  }
153
153
  async createTables() {
154
+ await this.pool.query(`CREATE TABLE IF NOT EXISTS credit_balance_payments (
155
+ payment_id TEXT PRIMARY KEY,
156
+ fingerprint TEXT NOT NULL,
157
+ job_id TEXT NOT NULL,
158
+ request_seq BIGINT NOT NULL,
159
+ response JSONB NOT NULL,
160
+ UNIQUE(job_id, request_seq)
161
+ )`);
154
162
  await this.pool.query(`
155
163
  CREATE TABLE IF NOT EXISTS jobs (
156
164
  id TEXT PRIMARY KEY,
@@ -719,6 +727,8 @@ var PostgresJobStore = class {
719
727
  * Read terminal zero-revenue jobs whose latest declared-cost revision has
720
728
  * not yet reached the durable reporter outbox. Keep the filter in step with
721
729
  * `idx_jobs_unreported_terminal_cost`, which bounds each pass to the backlog.
730
+ * Completed balance-paid work carries cost through revenue even when its
731
+ * allocated rail value is zero; its durable acceptance excludes a cost-only replay.
722
732
  */
723
733
  async listUnreportedTerminalCosts(args) {
724
734
  const { rows } = await this.pool.query(
@@ -729,7 +739,9 @@ var PostgresJobStore = class {
729
739
  AND (cost_reported_revision IS NULL OR cost_reported_revision < cost_revision)
730
740
  AND (
731
741
  status IN ('failed', 'cancelled')
732
- OR (status = 'completed' AND paid_msats = 0)
742
+ OR (status = 'completed' AND paid_msats = 0 AND NOT EXISTS (
743
+ SELECT 1 FROM credit_balance_payments p WHERE p.job_id=jobs.id
744
+ ))
733
745
  )
734
746
  AND ($2::text IS NULL OR id > $2)
735
747
  ORDER BY id
@@ -1201,7 +1213,12 @@ var PostgresJobStore = class {
1201
1213
  }
1202
1214
  async getCounters(jobId) {
1203
1215
  const { rows } = await this.pool.query(
1204
- "SELECT status, paid_msats, pending_payment_msats, summary FROM jobs WHERE id = $1",
1216
+ `SELECT status, paid_msats, pending_payment_msats, summary,
1217
+ EXISTS (SELECT 1 FROM credit_balance_payments p WHERE p.job_id=jobs.id
1218
+ AND p.request_seq=(SELECT MAX(m.seq) FROM job_messages m WHERE m.job_id=jobs.id
1219
+ AND m.data->>'type'='payment-request' AND m.data->>'from'='provider'
1220
+ AND m.status='verified')) AS balance_payment_satisfied
1221
+ FROM jobs WHERE id = $1`,
1205
1222
  [jobId]
1206
1223
  );
1207
1224
  if (rows.length === 0) return void 0;
@@ -1450,6 +1467,7 @@ function requestIdAdvisoryLockKey(requesterPubkey, requestId) {
1450
1467
  function rowToCounters(row) {
1451
1468
  return {
1452
1469
  status: row.status,
1470
+ ...row.balance_payment_satisfied && { balancePaymentSatisfied: true },
1453
1471
  paidMsats: Number(row.paid_msats),
1454
1472
  pendingPaymentMsats: row.pending_payment_msats == null ? void 0 : Number(row.pending_payment_msats),
1455
1473
  summary: row.summary ?? void 0
@@ -1,4 +1,4 @@
1
- import { b as JobStore, J as JobRecord } from './job-store-DRwXCJDI.js';
1
+ import { b as JobStore, J as JobRecord } from './job-store-B8Ijr5V6.js';
2
2
 
3
3
  /** Authenticated caller metadata; omitted fields on older services mean unknown. */
4
4
  interface JobContentMetadata {
@@ -10,7 +10,7 @@ import {
10
10
  isDrainMethod,
11
11
  isFundingRail,
12
12
  x402SettlementPending
13
- } from "./chunk-K2ZNIQZP.js";
13
+ } from "./chunk-2VGMZ7VF.js";
14
14
  import "./chunk-YG7G4DPZ.js";
15
15
  import "./chunk-COYKJRMM.js";
16
16
  import "./chunk-5H7P3ORL.js";
@@ -1,11 +1,11 @@
1
- import { f as LockPubkey, e as CheckMintHealthOptions, b as LightningBackend, A as AttestationPayload } from './lightning-backend-BX5YvjnM.js';
2
- import { ci as HostingCleanupFence, d3 as HostedIntent, aj as FundingMethod, p as PaymentMethod, bP as CreditLedgerLike, a5 as Message, $ as FundingReceipt, bR as CreditSnapshot, a0 as JobReceipt, S as SDKJobContext, ax as StepCache, v as ResponseContent, P as PaymentContent, a1 as MessageType, bk as X402Receipt, aF as X402Config, bj as X402ExactVersionSupport, d4 as X402SettlementIntent, ab as PaymentRequirementsV2, d5 as HostedFundingReservation, bL as CreditLedgerQuerier, d6 as X402SettlementCursor, bV as X402SettlementStatus, d7 as X402SettlementWriteOff, bQ as X402RefundSettlementGate, d8 as X402FacilitatorAuth, d9 as X402BatchSettlementConfig, cF as PostgresX402ChannelStorage, da as X402PayoutObserver, bN as HostedSettlementReportObligations, bn as CreditDepositPayload, bs as MppxServer, ae as CashuMode, db as CreditDepositEnqueue, dc as X402SettlementReconciliationReason, aq as PaymentRequirements, a3 as MppxCredential, bU as DrawResult, cs as CreditLedgerError, a7 as ReceiptCredit, ag as DrainReceiptEvent, a8 as DrainReceipt, K as KVStore, z as SignedRequestAudience, dd as CreditDrawReleaseEnqueue, cD as JobCostReportPayload, cE as JobTerminalReportPayload, cH as RevenueSkippedNoRailPayload, Z as ZodLike, a as DVMDescriptor, b_ as CreditInvoiceRecord, b$ as InvoiceSettlement, cm as ClientCompatibilityGate, ck as ClientCompatibility, bw as PostgresTempoSessionStore, bv as PayoutReporter, R as ResolvedCreditConfig, h as CreditView } from './step-cache-d-VKen4K.js';
1
+ import { f as LockPubkey, e as CheckMintHealthOptions, b as LightningBackend, A as AttestationPayload } from './lightning-backend-DmwMSgaM.js';
2
+ import { ci as HostingCleanupFence, d3 as HostedIntent, aj as FundingMethod, p as PaymentMethod, bP as CreditLedgerLike, a5 as Message, $ as FundingReceipt, bR as CreditSnapshot, a0 as JobReceipt, S as SDKJobContext, ax as StepCache, v as ResponseContent, P as PaymentContent, a1 as MessageType, bk as X402Receipt, aF as X402Config, bj as X402ExactVersionSupport, d4 as X402SettlementIntent, ab as PaymentRequirementsV2, d5 as HostedFundingReservation, bL as CreditLedgerQuerier, d6 as X402SettlementCursor, bV as X402SettlementStatus, d7 as X402SettlementWriteOff, bQ as X402RefundSettlementGate, d8 as X402FacilitatorAuth, d9 as X402BatchSettlementConfig, cF as PostgresX402ChannelStorage, da as X402PayoutObserver, bN as HostedSettlementReportObligations, bn as CreditDepositPayload, bs as MppxServer, ae as CashuMode, db as CreditDepositEnqueue, dc as X402SettlementReconciliationReason, aq as PaymentRequirements, a3 as MppxCredential, bU as DrawResult, cs as CreditLedgerError, a7 as ReceiptCredit, ag as DrainReceiptEvent, a8 as DrainReceipt, K as KVStore, z as SignedRequestAudience, dd as CreditDrawReleaseEnqueue, cD as JobCostReportPayload, cE as JobTerminalReportPayload, cH as RevenueSkippedNoRailPayload, Z as ZodLike, a as DVMDescriptor, b_ as CreditInvoiceRecord, b$ as InvoiceSettlement, cm as ClientCompatibilityGate, ck as ClientCompatibility, bw as PostgresTempoSessionStore, bv as PayoutReporter, R as ResolvedCreditConfig, h as CreditView } from './step-cache-DQqpwXa8.js';
3
3
  import { ProofLike, SerializedDLEQ, Proof } from '@cashu/cashu-ts';
4
4
  import { Hono, Context } from 'hono';
5
5
  import { Pool } from 'pg';
6
- import { d as FxSourceFailure, b as FxRateSnapshot, F as FxFetcher } from './fx-DVTNs9q1.js';
6
+ import { d as FxSourceFailure, b as FxRateSnapshot, F as FxFetcher } from './fx-DLhscRUh.js';
7
7
  import { Store, Challenge } from 'mppx';
8
- import { T as TopUpCapUnenforcedReason, A as AppendOutgoingOptions, J as JobRecord, b as JobStore } from './job-store-DRwXCJDI.js';
8
+ import { T as TopUpCapUnenforcedReason, A as AppendOutgoingOptions, J as JobRecord, b as JobStore } from './job-store-B8Ijr5V6.js';
9
9
  import { SettleResponse, SupportedResponse } from '@x402/core/types';
10
10
  import { Channel, AutoSettlementConfig } from '@x402/evm/batch-settlement/server';
11
11
  import { FacilitatorClient } from '@x402/core/server';
@@ -2932,6 +2932,8 @@ declare class JobManager<State, InputSchema extends ZodLike | undefined> {
2932
2932
  private readonly statusChecksInFlight;
2933
2933
  /** Job ids that were notified mid-re-read and must be re-checked. */
2934
2934
  private readonly statusChecksQueued;
2935
+ private readonly paymentAskSeqs;
2936
+ private readonly reactivationAskSeqs;
2935
2937
  private readonly inputResumeTails;
2936
2938
  private readonly claimedPaymentResumes;
2937
2939
  private readonly sessionId;
@@ -3084,6 +3086,8 @@ declare class JobManager<State, InputSchema extends ZodLike | undefined> {
3084
3086
  dispatchMessage(job: ServerJob, type: MessageType, content: unknown): Promise<void>;
3085
3087
  private queueInputResume;
3086
3088
  private claimLocalInput;
3089
+ private claimInputForAsk;
3090
+ private adoptPaymentMetadata;
3087
3091
  private resumeClaimedPayment;
3088
3092
  private dispatchMessageNow;
3089
3093
  /**
@@ -3606,6 +3610,7 @@ declare class JobManager<State, InputSchema extends ZodLike | undefined> {
3606
3610
  * fall back on is a slice of the credit's rail value at a ratio pinned
3607
3611
  * whenever that credit was funded, so it cannot safely fund a new ask.
3608
3612
  */
3613
+ private hasAcceptedBalancePayment;
3609
3614
  private resolveDrawPool;
3610
3615
  /** Internal: structured warn for the one path that can't price a drawn job's pool. */
3611
3616
  private warnDrawPool;
@@ -4499,6 +4504,8 @@ declare function unknownRouteNotFound(c: Context): Response;
4499
4504
  * whitelists this shape so later caller-specific menu fields cannot leak into /v1/info.
4500
4505
  */
4501
4506
  interface CreditTerms {
4507
+ /** Signed balance payments on the job messages endpoint are supported. */
4508
+ balance_payment?: true;
4502
4509
  /** Smallest funding accepted, in 1e-6 units of `currency`. */
4503
4510
  min_micro: number;
4504
4511
  /** Largest residual balance a caller may hold, in 1e-6 units of `currency`. */
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-d-VKen4K.js';
1
+ import { C as Currency } from './step-cache-DQqpwXa8.js';
2
2
 
3
3
  /**
4
4
  * Quote-time FX snapshot. `rates` maps configured lowercase currency codes to
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './step-cache-d-VKen4K.js';
2
- export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CapabilityRate, f as CreateSignedRequestVerifierOpts, g as CreditConfig, h as CreditView, i as DEFAULT_CREDIT_MAX, j as DEFAULT_CREDIT_MIN, k as DEFAULT_CREDIT_TTL_SECONDS, l as DEFAULT_JOB_RETENTION_DAYS, m as DVMRouteContext, I as IncomingMessage, n as InputType, o as InvalidCurrencyError, J as JobCost, K as KVStore, L as Logger, P as PaymentContent, p as PaymentMethod, q as PriceValue, r as ProgressContent, s as PromptOpts, Q as QuoteConfig, t as QuoteContext, u as QuoteResult, R as ResolvedCreditConfig, v as ResponseContent, S as SDKJobContext, w as SDKPaymentRequestOpts, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, z as SignedRequestAudience, B as SignedRequestDomain, E as SignedRequestError, F as SignedRequestFailure, G as SignedRequestReplayStore, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, U as UnsupportedCurrencyError, O as createSignedRequestVerifier, T as isZodSchema, V as signedRequestStatementHeader, W as validateCurrency } from './step-cache-d-VKen4K.js';
3
- export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, d as FxSourceFailure, e as FxSourceFailureCategory, P as PlatformFxSource, f as createFxFetcher, g as fxRateFor, r as resolveFxSourceFromEnv } from './fx-DVTNs9q1.js';
4
- export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-DSroMJ--.js';
5
- export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-DRwXCJDI.js';
1
+ import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './step-cache-DQqpwXa8.js';
2
+ export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CapabilityRate, f as CreateSignedRequestVerifierOpts, g as CreditConfig, h as CreditView, i as DEFAULT_CREDIT_MAX, j as DEFAULT_CREDIT_MIN, k as DEFAULT_CREDIT_TTL_SECONDS, l as DEFAULT_JOB_RETENTION_DAYS, m as DVMRouteContext, I as IncomingMessage, n as InputType, o as InvalidCurrencyError, J as JobCost, K as KVStore, L as Logger, P as PaymentContent, p as PaymentMethod, q as PriceValue, r as ProgressContent, s as PromptOpts, Q as QuoteConfig, t as QuoteContext, u as QuoteResult, R as ResolvedCreditConfig, v as ResponseContent, S as SDKJobContext, w as SDKPaymentRequestOpts, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, z as SignedRequestAudience, B as SignedRequestDomain, E as SignedRequestError, F as SignedRequestFailure, G as SignedRequestReplayStore, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, U as UnsupportedCurrencyError, O as createSignedRequestVerifier, T as isZodSchema, V as signedRequestStatementHeader, W as validateCurrency } from './step-cache-DQqpwXa8.js';
3
+ export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, d as FxSourceFailure, e as FxSourceFailureCategory, P as PlatformFxSource, f as createFxFetcher, g as fxRateFor, r as resolveFxSourceFromEnv } from './fx-DLhscRUh.js';
4
+ export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-D5kk2nIT.js';
5
+ export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-B8Ijr5V6.js';
6
6
  export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from './ssrf-dMooihtY.js';
7
7
  export { z } from 'zod';
8
8
  import 'hono';
@@ -1,16 +1,16 @@
1
- import { L as LightningTransactionListOptions, a as LightningTransactionSnapshot, b as LightningBackend, c as LightningPayment, d as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus } from '../lightning-backend-BX5YvjnM.js';
2
- export { A as AttestationPayload, B as BuilderIdentityKeypair, e as CheckMintHealthOptions, f as LockPubkey, M as MintAmountBounds, g as MintHealthCheckResult, h as amountBoundsVerdict, i as assertNutSupport, j as buildAttestation, k as canSwap, l as checkMintHealth, m as generateIdentity, n as hashCapabilities, o as loadIdentitySecret, p as meltAmountBounds, s as signAttestation, t as toLockPubkey, v as verifyAttestation, w as writeIdentity } from '../lightning-backend-BX5YvjnM.js';
1
+ import { L as LightningTransactionListOptions, a as LightningTransactionSnapshot, b as LightningBackend, c as LightningPayment, d as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus } from '../lightning-backend-DmwMSgaM.js';
2
+ export { A as AttestationPayload, B as BuilderIdentityKeypair, e as CheckMintHealthOptions, f as LockPubkey, M as MintAmountBounds, g as MintHealthCheckResult, h as amountBoundsVerdict, i as assertNutSupport, j as buildAttestation, k as canSwap, l as checkMintHealth, m as generateIdentity, n as hashCapabilities, o as loadIdentitySecret, p as meltAmountBounds, s as signAttestation, t as toLockPubkey, v as verifyAttestation, w as writeIdentity } from '../lightning-backend-DmwMSgaM.js';
3
3
  import { ProofLike, MeltQuoteBolt11Response, Proof, Wallet, MintQuoteBolt11Response, MintPreview, CounterSource, CounterRange, SerializedDLEQ, OutputData, OutputDataLike } from '@cashu/cashu-ts';
4
4
  export { g as getWallet } from '../wallet-Dwjs5n_M.js';
5
- import { X as JsonValue, B as SignedRequestDomain, M as SignedRequestStatementHeader, Y as X402_BATCH_SETTLEMENT_SCHEME, _ as X402_EXACT_SCHEME, $ as FundingReceipt, a0 as JobReceipt$1, a1 as MessageType, a2 as X402Version, a3 as MppxCredential, z as SignedRequestAudience, a4 as PaymentRequired, a5 as Message, a6 as MppxChallenge, a7 as ReceiptCredit, a8 as DrainReceipt, C as Currency, a9 as X402Wallet, aa as PaymentRequirementsV1, ab as PaymentRequirementsV2, L as Logger$1, K as KVStore } from '../step-cache-d-VKen4K.js';
6
- export { ac as BuildPaymentRequirementsOpts, ad as CapabilityDescriptor, ae as CashuMode, af as CompleteContent, ag as DrainReceiptEvent, ah as ExactEvmPayload, ai as ExactEvmPayloadAuthorization, aj as FundingMethod, ak as MessageFrom, al as PaymentPayload, am as PaymentPayloadV1, an as PaymentPayloadV2, ao as PaymentRequestContent, ap as PaymentRequiredV2, aq as PaymentRequirements, ar as PromptContent, as as RAIL_REFUNDABLE, at as ReceiptOutcome, au as ReceiptPayment, av as ResourceInfo, aw as SettleResponse, ax as StepCache, ay as StepRecord, az as TextContent, aA as UnsignedDrainReceipt, aB as UnsignedFundingReceipt, aC as UnsignedJobReceipt, aD as VerifyResponse, aE as WorkingContent, aF as X402Config, aG as X402ResponseBody, aH as X402SelfRelayRpcFailureReason, aI as X402_DEFAULT_NETWORK, aJ as X402_V1_VERSION, aK as X402_VERSION, aL as buildPaymentRequiredV2, aM as buildPaymentRequirements, aN as caip2ToX402Network, aO as canonicalRequestPath, aP as canonicaliseForSigning, aQ as canonicalize, aR as chainIdFromCaip2, aS as computeResultHash, aT as decodePayment, aU as decodePaymentRequiredHeader, aV as encodePayment, aW as encodePaymentRequiredHeader, aX as encodeSettleResponseHeader, aY as exactEvmAuthorization, aZ as isArtifactMessage, a_ as isCancelMessage, a$ as isCompleteMessage, b0 as isDrainReceipt, b1 as isFundingReceipt, b2 as isPaymentRequestMessage, b3 as isPromptMessage, b4 as isSignedJobReceipt, b5 as isTextMessage, b6 as isWorkingMessage, b7 as paymentRequiredV2FromV1, b8 as signDrainReceipt, b9 as signFundingReceipt, ba as signReceipt, bb as usdcContractByCaip2, bc as usdcContractFor, bd as usdcDomainNameFor, be as usdcDomainVersionFor, bf as verifyDrainReceipt, bg as verifyFundingReceipt, bh as verifyReceipt, bi as x402NetworkToCaip2 } from '../step-cache-d-VKen4K.js';
5
+ import { X as JsonValue, B as SignedRequestDomain, M as SignedRequestStatementHeader, Y as X402_BATCH_SETTLEMENT_SCHEME, _ as X402_EXACT_SCHEME, $ as FundingReceipt, a0 as JobReceipt$1, a1 as MessageType, a2 as X402Version, a3 as MppxCredential, z as SignedRequestAudience, a4 as PaymentRequired, a5 as Message, a6 as MppxChallenge, a7 as ReceiptCredit, a8 as DrainReceipt, C as Currency, a9 as X402Wallet, aa as PaymentRequirementsV1, ab as PaymentRequirementsV2, L as Logger$1, K as KVStore } from '../step-cache-DQqpwXa8.js';
6
+ export { ac as BuildPaymentRequirementsOpts, ad as CapabilityDescriptor, ae as CashuMode, af as CompleteContent, ag as DrainReceiptEvent, ah as ExactEvmPayload, ai as ExactEvmPayloadAuthorization, aj as FundingMethod, ak as MessageFrom, al as PaymentPayload, am as PaymentPayloadV1, an as PaymentPayloadV2, ao as PaymentRequestContent, ap as PaymentRequiredV2, aq as PaymentRequirements, ar as PromptContent, as as RAIL_REFUNDABLE, at as ReceiptOutcome, au as ReceiptPayment, av as ResourceInfo, aw as SettleResponse, ax as StepCache, ay as StepRecord, az as TextContent, aA as UnsignedDrainReceipt, aB as UnsignedFundingReceipt, aC as UnsignedJobReceipt, aD as VerifyResponse, aE as WorkingContent, aF as X402Config, aG as X402ResponseBody, aH as X402SelfRelayRpcFailureReason, aI as X402_DEFAULT_NETWORK, aJ as X402_V1_VERSION, aK as X402_VERSION, aL as buildPaymentRequiredV2, aM as buildPaymentRequirements, aN as caip2ToX402Network, aO as canonicalRequestPath, aP as canonicaliseForSigning, aQ as canonicalize, aR as chainIdFromCaip2, aS as computeResultHash, aT as decodePayment, aU as decodePaymentRequiredHeader, aV as encodePayment, aW as encodePaymentRequiredHeader, aX as encodeSettleResponseHeader, aY as exactEvmAuthorization, aZ as isArtifactMessage, a_ as isCancelMessage, a$ as isCompleteMessage, b0 as isDrainReceipt, b1 as isFundingReceipt, b2 as isPaymentRequestMessage, b3 as isPromptMessage, b4 as isSignedJobReceipt, b5 as isTextMessage, b6 as isWorkingMessage, b7 as paymentRequiredV2FromV1, b8 as signDrainReceipt, b9 as signFundingReceipt, ba as signReceipt, bb as usdcContractByCaip2, bc as usdcContractFor, bd as usdcDomainNameFor, be as usdcDomainVersionFor, bf as verifyDrainReceipt, bg as verifyFundingReceipt, bh as verifyReceipt, bi as x402NetworkToCaip2 } from '../step-cache-DQqpwXa8.js';
7
7
  import { SimplePool } from 'nostr-tools/pool';
8
8
  import { Session } from 'mppx/tempo';
9
9
  import { Pool } from 'pg';
10
10
  import { PaymentRequired as PaymentRequired$1 } from '@x402/core/types';
11
11
  import { ClientChannelStorage, BatchSettlementClientContext, BatchSettlementEvmScheme } from '@x402/evm/batch-settlement/client';
12
- export { h as FX_CACHE_TTL_MS, i as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-DVTNs9q1.js';
13
- export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-DSroMJ--.js';
12
+ export { h as FX_CACHE_TTL_MS, i as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-DLhscRUh.js';
13
+ export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-D5kk2nIT.js';
14
14
  import 'hono';
15
15
  import 'mppx';
16
16
  import '@x402/core/server';
@@ -1099,6 +1099,8 @@ interface Quote {
1099
1099
  }
1100
1100
  /** Public prepaid-credit terms advertised on `/v1/info`. Snake_case: wire shape. */
1101
1101
  interface CreditTerms {
1102
+ /** Signed balance payments on the job messages endpoint are supported. */
1103
+ balance_payment?: true;
1102
1104
  /** Smallest funding accepted, in 1e-6 units of `currency`. */
1103
1105
  min_micro: number;
1104
1106
  /** Largest residual balance a caller may hold, in 1e-6 units of `currency`. */
@@ -1098,6 +1098,7 @@ function parseCreditTerms(raw) {
1098
1098
  const x402 = credit.x402 === void 0 ? void 0 : parseCreditX402Terms(credit.x402);
1099
1099
  if (credit.x402 !== void 0 && !x402) return void 0;
1100
1100
  return {
1101
+ ...credit.balance_payment === true && { balance_payment: true },
1101
1102
  min_micro: credit.min_micro,
1102
1103
  max_micro: credit.max_micro,
1103
1104
  ttl_ms: credit.ttl_ms,
@@ -1,22 +1,22 @@
1
1
  import { FacilitatorConfig } from '@x402/core/server';
2
- import { al as PaymentPayload, aa as PaymentRequirementsV1, ab as PaymentRequirementsV2, aF as X402Config, aw as SettleResponse, aD as VerifyResponse, bj as X402ExactVersionSupport, bk as X402Receipt, bl as TransactionalPayoutHook, bm as CashuMeltCompleted } from '../step-cache-d-VKen4K.js';
3
- export { bn as CreditDepositPayload, bo as CreditDrainPayload, bp as FundingLot, bq as LotDebit, br as LotDepletion, bs as MppxServer, bt as NON_CHANNEL_BITCOIN_RAILS, bu as NonChannelBitcoinRail, bv as PayoutReporter, bw as PostgresTempoSessionStore, bx as RevenueReporter, by as SIGNED_ENVELOPE_FIELDS, bz as SIGNED_ENVELOPE_TYPES, bA as X402TrackedChannel, bB as _testing, bC as createDefaultReplayStore, bD as depleteLots, bE as fifoOrder, bF as inKindDrawMsats, bG as isInKindDepletion, bH as isNonChannelBitcoinRail, bI as lotOwedSats, bJ as netOwedSats, bK as wrapMppx } from '../step-cache-d-VKen4K.js';
2
+ import { al as PaymentPayload, aa as PaymentRequirementsV1, ab as PaymentRequirementsV2, aF as X402Config, aw as SettleResponse, aD as VerifyResponse, bj as X402ExactVersionSupport, bk as X402Receipt, bl as TransactionalPayoutHook, bm as CashuMeltCompleted } from '../step-cache-DQqpwXa8.js';
3
+ export { bn as CreditDepositPayload, bo as CreditDrainPayload, bp as FundingLot, bq as LotDebit, br as LotDepletion, bs as MppxServer, bt as NON_CHANNEL_BITCOIN_RAILS, bu as NonChannelBitcoinRail, bv as PayoutReporter, bw as PostgresTempoSessionStore, bx as RevenueReporter, by as SIGNED_ENVELOPE_FIELDS, bz as SIGNED_ENVELOPE_TYPES, bA as X402TrackedChannel, bB as _testing, bC as createDefaultReplayStore, bD as depleteLots, bE as fifoOrder, bF as inKindDrawMsats, bG as isInKindDepletion, bH as isNonChannelBitcoinRail, bI as lotOwedSats, bJ as netOwedSats, bK as wrapMppx } from '../step-cache-DQqpwXa8.js';
4
4
  import { Hono } from 'hono';
5
5
  import { Env, BlankSchema } from 'hono/types';
6
6
  import { Pool } from 'pg';
7
7
  export { Pool } from 'pg';
8
8
  import { g as getWallet } from '../wallet-Dwjs5n_M.js';
9
- import { C as ConsumedCredentialStore, L as LockPubkeyStateLoader } from '../credit-menu-BYySnZBk.js';
10
- export { A as AccumulatorPool, a as AppEnv, b as CreditFundingReport, D as DEFAULT_LOCK_PUBKEY_GRACE_SECONDS, F as FiatDenomination, c as FiatDenominationFailure, d as FundOnlyRequest, I as IncomingPaymentOpts, J as JobCancelledError, e as LockPubkeyPool, f as LockPubkeyState, M as MintHealthTracker, P as PAYMENT_PROOF_KEYS, g as PaymentErrorCode, h as PaymentErrorDetail, i as PaymentInfo, j as PostgresTempoChargeStore, R as ReporterBannerOpts, k as ResolvedFx, l as RevenueBootCheckOpts, S as SDKServerOpts, m as ServerJob, n as ShortPayForfeit, T as TempoChannelReport, o as TempoObserverHealth, p as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, q as VerifyIncomingSnapshot, X as X402BatchChannelObservation, r as X402FacilitatorHealth, s as X402SettlementEvidenceOutcome, t as X402SettlementRepair, u as X402SettlementRepairRefusal, v as X402SettlementRepaired, w as X402WedgedSettlement, x as X402WedgedSettlementPage, y as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, z as abortJob, B as activePubkeySet, E as applyPaymentInfoToJob, G as assertRevenueReporterReady, H as buildPaymentErrorResponse, K as clearAccumulatorForDvm, N as createDVMServer, O as creditDepositPayload, Q as derivedFundCreditId, W as devModeSkipsPaymentVerification, Y as fromJobRecord, Z as fundedMicroFor, _ as hasPaymentProof, $ as hashLockKey, a0 as implicitCreditId, a1 as initLockPubkeyTable, a2 as initWalletAccumulatorTable, a3 as insertAccumulatorRows, a4 as isDerivedCreditId, a5 as isTerminal, a6 as isYieldMessage, a7 as issueUpfrontChallenges, a8 as loadLockPubkeyState, a9 as msatsToFiatMicro, aa as paymentErrorBody, ab as pinAskFiat, ac as priceFiatMicro, ad as processIncomingPayment, ae as providerMessage, af as pruneRetired, ag as repairX402ExactSettlementEffect, ah as resolveFxSnapshot, ai as resolvePriceFiat, aj as revenueReporterBannerState, ak as rotateLockPubkey, al as seedLockPubkeyState, am as toCreditTerms, an as toJobRecord, ao as unknownRouteNotFound, ap as verifyIncomingPayment, aq as verifyTempoSessionManagementCredential, ar as verifyUpfrontPayment, as as x402RequiredUsdcMicro, at as x402SettledShare } from '../credit-menu-BYySnZBk.js';
11
- export { O as OutgoingMessage, S as StaleJobReapable, i as isStaleJobReapable } from '../job-store-DRwXCJDI.js';
9
+ import { C as ConsumedCredentialStore, L as LockPubkeyStateLoader } from '../credit-menu-B2T-O9oY.js';
10
+ export { A as AccumulatorPool, a as AppEnv, b as CreditFundingReport, D as DEFAULT_LOCK_PUBKEY_GRACE_SECONDS, F as FiatDenomination, c as FiatDenominationFailure, d as FundOnlyRequest, I as IncomingPaymentOpts, J as JobCancelledError, e as LockPubkeyPool, f as LockPubkeyState, M as MintHealthTracker, P as PAYMENT_PROOF_KEYS, g as PaymentErrorCode, h as PaymentErrorDetail, i as PaymentInfo, j as PostgresTempoChargeStore, R as ReporterBannerOpts, k as ResolvedFx, l as RevenueBootCheckOpts, S as SDKServerOpts, m as ServerJob, n as ShortPayForfeit, T as TempoChannelReport, o as TempoObserverHealth, p as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, q as VerifyIncomingSnapshot, X as X402BatchChannelObservation, r as X402FacilitatorHealth, s as X402SettlementEvidenceOutcome, t as X402SettlementRepair, u as X402SettlementRepairRefusal, v as X402SettlementRepaired, w as X402WedgedSettlement, x as X402WedgedSettlementPage, y as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, z as abortJob, B as activePubkeySet, E as applyPaymentInfoToJob, G as assertRevenueReporterReady, H as buildPaymentErrorResponse, K as clearAccumulatorForDvm, N as createDVMServer, O as creditDepositPayload, Q as derivedFundCreditId, W as devModeSkipsPaymentVerification, Y as fromJobRecord, Z as fundedMicroFor, _ as hasPaymentProof, $ as hashLockKey, a0 as implicitCreditId, a1 as initLockPubkeyTable, a2 as initWalletAccumulatorTable, a3 as insertAccumulatorRows, a4 as isDerivedCreditId, a5 as isTerminal, a6 as isYieldMessage, a7 as issueUpfrontChallenges, a8 as loadLockPubkeyState, a9 as msatsToFiatMicro, aa as paymentErrorBody, ab as pinAskFiat, ac as priceFiatMicro, ad as processIncomingPayment, ae as providerMessage, af as pruneRetired, ag as repairX402ExactSettlementEffect, ah as resolveFxSnapshot, ai as resolvePriceFiat, aj as revenueReporterBannerState, ak as rotateLockPubkey, al as seedLockPubkeyState, am as toCreditTerms, an as toJobRecord, ao as unknownRouteNotFound, ap as verifyIncomingPayment, aq as verifyTempoSessionManagementCredential, ar as verifyUpfrontPayment, as as x402RequiredUsdcMicro, at as x402SettledShare } from '../credit-menu-B2T-O9oY.js';
11
+ export { O as OutgoingMessage, S as StaleJobReapable, i as isStaleJobReapable } from '../job-store-B8Ijr5V6.js';
12
12
  import { z } from 'zod';
13
- export { f as LockPubkeyStoreLockPubkey, t as lockPubkeyStoreToLockPubkey } from '../lightning-backend-BX5YvjnM.js';
13
+ export { f as LockPubkeyStoreLockPubkey, t as lockPubkeyStoreToLockPubkey } from '../lightning-backend-DmwMSgaM.js';
14
14
  import 'mppx';
15
15
  import '@x402/evm/batch-settlement/server';
16
16
  import '@x402/core/types';
17
17
  import 'viem';
18
18
  import '@cashu/cashu-ts';
19
- import '../fx-DVTNs9q1.js';
19
+ import '../fx-DLhscRUh.js';
20
20
 
21
21
  declare function verifyWithFacilitator(payload: PaymentPayload, requirements: PaymentRequirementsV1 | PaymentRequirementsV2, config?: Pick<X402Config, "facilitator" | "facilitatorAuth">, createAuthHeaders?: FacilitatorConfig["createAuthHeaders"] | undefined): Promise<VerifyResponse>;
22
22
  declare function settleWithFacilitator(payload: PaymentPayload, requirements: PaymentRequirementsV1 | PaymentRequirementsV2, config?: Pick<X402Config, "facilitator" | "facilitatorAuth">, createAuthHeaders?: FacilitatorConfig["createAuthHeaders"] | undefined): Promise<SettleResponse>;
@@ -61,7 +61,7 @@ import {
61
61
  verifyUpfrontPayment,
62
62
  x402RequiredUsdcMicro,
63
63
  x402SettledShare
64
- } from "../chunk-AIQGF52I.js";
64
+ } from "../chunk-S7PIFHE4.js";
65
65
  import "../chunk-XRLKGCAW.js";
66
66
  import {
67
67
  PayoutReporter
@@ -70,8 +70,8 @@ import {
70
70
  settleWithFacilitator,
71
71
  verifyWithFacilitator
72
72
  } from "../chunk-E7ZBCT5U.js";
73
- import "../chunk-55DVLBCD.js";
74
- import "../chunk-HQPQ4PFI.js";
73
+ import "../chunk-POYUX2NN.js";
74
+ import "../chunk-TWKQFIOW.js";
75
75
  import {
76
76
  SIGNED_ENVELOPE_FIELDS,
77
77
  SIGNED_ENVELOPE_TYPES,
@@ -110,7 +110,7 @@ import {
110
110
  isNonChannelBitcoinRail,
111
111
  lotOwedSats,
112
112
  netOwedSats
113
- } from "../chunk-K2ZNIQZP.js";
113
+ } from "../chunk-2VGMZ7VF.js";
114
114
  import "../chunk-YG7G4DPZ.js";
115
115
  import "../chunk-COYKJRMM.js";
116
116
  import "../chunk-5H7P3ORL.js";
@@ -1,5 +1,5 @@
1
1
  import { ProofLike } from '@cashu/cashu-ts';
2
- import { a5 as Message, aj as FundingMethod, $ as FundingReceipt, bR as CreditSnapshot, a0 as JobReceipt, ay as StepRecord, a1 as MessageType } from './step-cache-d-VKen4K.js';
2
+ import { a5 as Message, aj as FundingMethod, $ as FundingReceipt, bR as CreditSnapshot, a0 as JobReceipt, ay as StepRecord, a1 as MessageType } from './step-cache-DQqpwXa8.js';
3
3
 
4
4
  type JobStatus = "processing" | "completed" | "failed" | "awaiting-input" | "cancelled" | "working";
5
5
  interface JobRecord {
@@ -210,6 +210,8 @@ interface JobRecord {
210
210
  * the caller's own words to `ctx.signal.reason` and the `onCancel` hook.
211
211
  */
212
212
  interface JobCounters {
213
+ /** The latest durable payment request was satisfied by a balance authorization. */
214
+ balancePaymentSatisfied?: boolean;
213
215
  status: JobStatus;
214
216
  paidMsats: number;
215
217
  pendingPaymentMsats?: number;
@@ -1,4 +1,4 @@
1
- import { X as JsonValue } from './step-cache-d-VKen4K.js';
1
+ import { X as JsonValue } from './step-cache-DQqpwXa8.js';
2
2
 
3
3
  declare const lockPubkeyBrand: unique symbol;
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MemoryCreditLedger
3
- } from "./chunk-55DVLBCD.js";
4
- import "./chunk-K2ZNIQZP.js";
3
+ } from "./chunk-POYUX2NN.js";
4
+ import "./chunk-2VGMZ7VF.js";
5
5
  import "./chunk-YG7G4DPZ.js";
6
6
  import "./chunk-COYKJRMM.js";
7
7
  import "./chunk-5H7P3ORL.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PostgresJobStore
3
- } from "./chunk-HQPQ4PFI.js";
3
+ } from "./chunk-TWKQFIOW.js";
4
4
  import "./chunk-AFV77S4C.js";
5
5
  import "./chunk-BQJIFRAZ.js";
6
6
  import "./chunk-COYKJRMM.js";
@@ -1,15 +1,15 @@
1
- import { ae as CashuMode, bL as CreditLedgerQuerier, bM as CreditDrainEnqueue, bN as HostedSettlementReportObligations, R as ResolvedCreditConfig, bO as DVMAuthScheme, B as SignedRequestDomain, bP as CreditLedgerLike, bQ as X402RefundSettlementGate, bR as CreditSnapshot, bS as CreditDrawRefundArgs, bT as CreditDrawRefundResult, bU as DrawResult, bV as X402SettlementStatus, bW as X402UnresolvedRefund, bX as GrownDrawResult, bY as DrawResolution, bZ as FundingRecord, $ 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 TempoCreditLoss, c7 as X402CreditLossEvidence, c8 as X402CreditLoss, c9 as DrainMethod, ca as DrainRequestResult, cb as BitcoinDepositLiability, bp as FundingLot, cc as CreditDrainRecord, cd as ChannelDrainCursor, ce as DrainWriteOff, cf as DrainTransitionResult, cg as DrainReleaseResult, ch as DrainFulfilment, ci as HostingCleanupFence, a0 as JobReceipt, a5 as Message, K as KVStore, G as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-d-VKen4K.js';
2
- export { cj as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, ck as ClientCompatibility, cl as ClientCompatibilityEnv, cm as ClientCompatibilityGate, cn as ClientCompatibilityRequirement, co as ClientSemVer, f as CreateSignedRequestVerifierOpts, cp as CreditFundingBasis, cq as CreditInvoiceStatus, cr as CreditLedger, cs as CreditLedgerError, ct as CreditLedgerErrorCode, cu as CreditLedgerErrorDetails, cv as CreditLedgerPool, cw as CreditStatus, cx as DRAIN_DELIVERY_RESERVE_SATS, cy as DVM_PROTOCOL_VERSION, cz as DrainConflictReason, cA as DrawRailValue, cB as DrawStatus, cC as HostedTempoCloseReportWriteOff, cD as JobCostReportPayload, cE as JobTerminalReportPayload, cF as PostgresX402ChannelStorage, cG as ReplayStoreBackend, cH as RevenueSkippedNoRailPayload, cI as RevenueSkippedNoRailReason, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, cJ as Secp256k1AuthOpts, z as SignedRequestAudience, E as SignedRequestError, F as SignedRequestFailure, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, cK as TempoDrainDecision, cL as TempoDrainDecisionArgs, cM as TempoDrainDecisionResult, cN as TempoDrainHoldReason, cO as X402ChannelStorageOpts, cP as X402RelayLockHolder, cQ as X402RelaySubmissionLock, cR as X402RelaySubmissionLockError, cS as allocateDrawValue, cT as clientCompatibilityAttributes, cU as clientCompatibilityMiddleware, cV as clientUpgradeRequired, O as createSignedRequestVerifier, cW as parseClientCapabilities, cX as parseClientCompatibility, cY as parseDvmClient, cZ as parseProtocolVersion, c_ as requireClientCompatibility, c$ as retryHostedTempoCloseReport, d0 as secp256k1Auth, d1 as signedRequestInput, V as signedRequestStatementHeader, d2 as writeOffHostedTempoCloseReport } from '../step-cache-d-VKen4K.js';
1
+ import { ae as CashuMode, bL as CreditLedgerQuerier, bM as CreditDrainEnqueue, bN as HostedSettlementReportObligations, R as ResolvedCreditConfig, bO as DVMAuthScheme, B as SignedRequestDomain, bP as CreditLedgerLike, bQ as X402RefundSettlementGate, bR as CreditSnapshot, bS as CreditDrawRefundArgs, bT as CreditDrawRefundResult, bU as DrawResult, bV as X402SettlementStatus, bW as X402UnresolvedRefund, bX as GrownDrawResult, bY as DrawResolution, bZ as FundingRecord, $ 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 TempoCreditLoss, c7 as X402CreditLossEvidence, c8 as X402CreditLoss, c9 as DrainMethod, ca as DrainRequestResult, cb as BitcoinDepositLiability, bp as FundingLot, cc as CreditDrainRecord, cd as ChannelDrainCursor, ce as DrainWriteOff, cf as DrainTransitionResult, cg as DrainReleaseResult, ch as DrainFulfilment, ci as HostingCleanupFence, a0 as JobReceipt, a5 as Message, K as KVStore, G as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-DQqpwXa8.js';
2
+ export { cj as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, ck as ClientCompatibility, cl as ClientCompatibilityEnv, cm as ClientCompatibilityGate, cn as ClientCompatibilityRequirement, co as ClientSemVer, f as CreateSignedRequestVerifierOpts, cp as CreditFundingBasis, cq as CreditInvoiceStatus, cr as CreditLedger, cs as CreditLedgerError, ct as CreditLedgerErrorCode, cu as CreditLedgerErrorDetails, cv as CreditLedgerPool, cw as CreditStatus, cx as DRAIN_DELIVERY_RESERVE_SATS, cy as DVM_PROTOCOL_VERSION, cz as DrainConflictReason, cA as DrawRailValue, cB as DrawStatus, cC as HostedTempoCloseReportWriteOff, cD as JobCostReportPayload, cE as JobTerminalReportPayload, cF as PostgresX402ChannelStorage, cG as ReplayStoreBackend, cH as RevenueSkippedNoRailPayload, cI as RevenueSkippedNoRailReason, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, cJ as Secp256k1AuthOpts, z as SignedRequestAudience, E as SignedRequestError, F as SignedRequestFailure, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, cK as TempoDrainDecision, cL as TempoDrainDecisionArgs, cM as TempoDrainDecisionResult, cN as TempoDrainHoldReason, cO as X402ChannelStorageOpts, cP as X402RelayLockHolder, cQ as X402RelaySubmissionLock, cR as X402RelaySubmissionLockError, cS as allocateDrawValue, cT as clientCompatibilityAttributes, cU as clientCompatibilityMiddleware, cV as clientUpgradeRequired, O as createSignedRequestVerifier, cW as parseClientCapabilities, cX as parseClientCompatibility, cY as parseDvmClient, cZ as parseProtocolVersion, c_ as requireClientCompatibility, c$ as retryHostedTempoCloseReport, d0 as secp256k1Auth, d1 as signedRequestInput, V as signedRequestStatementHeader, d2 as writeOffHostedTempoCloseReport } from '../step-cache-DQqpwXa8.js';
3
3
  import { Pool } from 'pg';
4
- import { au as CreditMenu, a as AppEnv, U as UpfrontPaymentOpts, i as PaymentInfo, av as ReceiptIssuer, aw as LightningReceive, ax as TempoSettlementReadiness, ay as DVMHostOpts, az as DVMServeResult, L as LockPubkeyStateLoader, C as ConsumedCredentialStore } from '../credit-menu-BYySnZBk.js';
5
- export { aA as BuildCreditMenuArgs, aB as BuilderIdentity, aC as CREDIT_ENVELOPE_KEYS, aD as CreateX402BatchSettlementServerOpts, aE as CreditEnvelope, aF as CreditEnvelopeError, aG as CreditFundCommitment, aH as CreditTerms, aI as DEFAULT_INVOICE_TTL_SECONDS, aJ as DVMHost, aK as HostingClosureCommand, aL as HostingClosureEvidence, aM as HostingControlCommand, aN as HostingControlConfig, aO as HostingControlStatus, aP as JobManager, aQ as JobManagerOpts, aR as LightningReceiveConfig, aS as MIN_INVOICE_TTL_SECONDS, aT as MemoryConsumedCredentialStore, aU as MemoryConsumedCredentialStoreOpts, aV as MemoryProcessedPaymentStore, aW as MemoryX402ExactSettlementStore, aX as MountOpts, aY as OwnerDisplay, aZ as PaidJobCompletion, a_ as PaymentMode, a$ as PlatformReporterOpts, b0 as PostgresProcessedPaymentStore, b1 as PostgresX402ExactSettlementStore, b2 as PriceFiat, b3 as ProcessedPaymentQuerier, b4 as ProcessedPaymentRail, b5 as ProcessedPaymentRecord, b6 as ProcessedPaymentReplayError, b7 as ProcessedPaymentStore, b8 as X402BatchAcceptance, b9 as X402BatchFunding, ba as X402BatchRefusal, bb as X402BatchSettlementServer, bc as X402ExactAcceptance, bd as X402ExactIntentConflictError, be as X402ExactSettlementAttempt, bf as X402ExactSettlementChainEvidence, bg as X402ExactSettlementEffect, bh as X402ExactSettlementEvidenceMissingError, bi as X402ExactSettlementEvidenceReader, bj as X402ExactSettlementIntent, bk as X402ExactSettlementNotReadyError, bl as X402ExactSettlementServer, bm as X402ExactSettlementServerOpts, bn as X402ExactSettlementStatus, bo as X402ExactSettlementStore, bp as X402SettlementChainEvidence, bq as X402SettlementEvidenceReader, br as X402SettlementSubmissionError, bs as X402_BATCH_AUTO_SETTLEMENT, bt as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bu as X402_BATCH_SETTLEMENT_NETWORK, bv as attachCreditMenu, bw as buildCreditMenu, bx as createDVMHost, by as createX402BatchSettlementServer, bz as creditEnvelopeIgnoreFields, bA as drawSettlementRef, bB as extractCreditEnvelope, bC as fundingCommitment, bD as selectPrimaryCredit, bE as signHostingClosure, bF as signHostingControl, bG as stripCreditEnvelope, bH as toCreditView } from '../credit-menu-BYySnZBk.js';
4
+ import { au as CreditMenu, a as AppEnv, U as UpfrontPaymentOpts, i as PaymentInfo, av as ReceiptIssuer, aw as LightningReceive, ax as TempoSettlementReadiness, ay as DVMHostOpts, az as DVMServeResult, L as LockPubkeyStateLoader, C as ConsumedCredentialStore } from '../credit-menu-B2T-O9oY.js';
5
+ export { aA as BuildCreditMenuArgs, aB as BuilderIdentity, aC as CREDIT_ENVELOPE_KEYS, aD as CreateX402BatchSettlementServerOpts, aE as CreditEnvelope, aF as CreditEnvelopeError, aG as CreditFundCommitment, aH as CreditTerms, aI as DEFAULT_INVOICE_TTL_SECONDS, aJ as DVMHost, aK as HostingClosureCommand, aL as HostingClosureEvidence, aM as HostingControlCommand, aN as HostingControlConfig, aO as HostingControlStatus, aP as JobManager, aQ as JobManagerOpts, aR as LightningReceiveConfig, aS as MIN_INVOICE_TTL_SECONDS, aT as MemoryConsumedCredentialStore, aU as MemoryConsumedCredentialStoreOpts, aV as MemoryProcessedPaymentStore, aW as MemoryX402ExactSettlementStore, aX as MountOpts, aY as OwnerDisplay, aZ as PaidJobCompletion, a_ as PaymentMode, a$ as PlatformReporterOpts, b0 as PostgresProcessedPaymentStore, b1 as PostgresX402ExactSettlementStore, b2 as PriceFiat, b3 as ProcessedPaymentQuerier, b4 as ProcessedPaymentRail, b5 as ProcessedPaymentRecord, b6 as ProcessedPaymentReplayError, b7 as ProcessedPaymentStore, b8 as X402BatchAcceptance, b9 as X402BatchFunding, ba as X402BatchRefusal, bb as X402BatchSettlementServer, bc as X402ExactAcceptance, bd as X402ExactIntentConflictError, be as X402ExactSettlementAttempt, bf as X402ExactSettlementChainEvidence, bg as X402ExactSettlementEffect, bh as X402ExactSettlementEvidenceMissingError, bi as X402ExactSettlementEvidenceReader, bj as X402ExactSettlementIntent, bk as X402ExactSettlementNotReadyError, bl as X402ExactSettlementServer, bm as X402ExactSettlementServerOpts, bn as X402ExactSettlementStatus, bo as X402ExactSettlementStore, bp as X402SettlementChainEvidence, bq as X402SettlementEvidenceReader, br as X402SettlementSubmissionError, bs as X402_BATCH_AUTO_SETTLEMENT, bt as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bu as X402_BATCH_SETTLEMENT_NETWORK, bv as attachCreditMenu, bw as buildCreditMenu, bx as createDVMHost, by as createX402BatchSettlementServer, bz as creditEnvelopeIgnoreFields, bA as drawSettlementRef, bB as extractCreditEnvelope, bC as fundingCommitment, bD as selectPrimaryCredit, bE as signHostingClosure, bF as signHostingControl, bG as stripCreditEnvelope, bH as toCreditView } from '../credit-menu-B2T-O9oY.js';
6
6
  import { Context, Hono } from 'hono';
7
7
  import { z } from 'zod';
8
- import { F as FxFetcher } from '../fx-DVTNs9q1.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, b as JobStore } from '../job-store-DRwXCJDI.js';
10
- export { a as JobStatus, h as isStreamableJobStore } from '../job-store-DRwXCJDI.js';
11
- import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-ySTD1wwZ.js';
12
- export { b as ContentHold, c as ContentHoldError, d as ContentHoldEvent, e as ContentHoldStore, f as ContentHoldsResponse, J as JobContentMetadata, g as baselineContentExpiry, h as contentMetadata, i as isContentHoldStore } from '../content-retention-ySTD1wwZ.js';
8
+ import { F as FxFetcher } from '../fx-DLhscRUh.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, b as JobStore } from '../job-store-B8Ijr5V6.js';
10
+ export { a as JobStatus, h as isStreamableJobStore } from '../job-store-B8Ijr5V6.js';
11
+ import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-a1yRdmhI.js';
12
+ export { b as ContentHold, c as ContentHoldError, d as ContentHoldEvent, e as ContentHoldStore, f as ContentHoldsResponse, J as JobContentMetadata, g as baselineContentExpiry, h as contentMetadata, i as isContentHoldStore } from '../content-retention-a1yRdmhI.js';
13
13
  export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from '../ssrf-dMooihtY.js';
14
14
  import { Env, BlankSchema } from 'hono/types';
15
15
  import 'mppx';
@@ -17,7 +17,7 @@ import '@x402/core/server';
17
17
  import '@x402/evm/batch-settlement/server';
18
18
  import '@x402/core/types';
19
19
  import 'viem';
20
- import '../lightning-backend-BX5YvjnM.js';
20
+ import '../lightning-backend-DmwMSgaM.js';
21
21
  import '@cashu/cashu-ts';
22
22
 
23
23
  /** Lifetime of a per-call implicit credit before the ledger refuses new draws. */
@@ -429,6 +429,8 @@ declare class PostgresJobStore implements StreamableJobStore, ReceiptIssuingStor
429
429
  * Read terminal zero-revenue jobs whose latest declared-cost revision has
430
430
  * not yet reached the durable reporter outbox. Keep the filter in step with
431
431
  * `idx_jobs_unreported_terminal_cost`, which bounds each pass to the backlog.
432
+ * Completed balance-paid work carries cost through revenue even when its
433
+ * allocated rail value is zero; its durable acceptance excludes a cost-only replay.
432
434
  */
433
435
  listUnreportedTerminalCosts(args: {
434
436
  dvmId: string;
@@ -82,7 +82,7 @@ import {
82
82
  toCreditView,
83
83
  unknownRouteNotFound,
84
84
  writeOffHostedTempoCloseReport
85
- } from "../chunk-AIQGF52I.js";
85
+ } from "../chunk-S7PIFHE4.js";
86
86
  import {
87
87
  MemoryProcessedPaymentStore,
88
88
  PostgresProcessedPaymentStore,
@@ -92,10 +92,10 @@ import "../chunk-ITRSITFP.js";
92
92
  import "../chunk-E7ZBCT5U.js";
93
93
  import {
94
94
  MemoryCreditLedger
95
- } from "../chunk-55DVLBCD.js";
95
+ } from "../chunk-POYUX2NN.js";
96
96
  import {
97
97
  PostgresJobStore
98
- } from "../chunk-HQPQ4PFI.js";
98
+ } from "../chunk-TWKQFIOW.js";
99
99
  import {
100
100
  SignedRequestError,
101
101
  createDefaultReplayStore,
@@ -139,7 +139,7 @@ import {
139
139
  PostgresX402ChannelStorage,
140
140
  X402RelaySubmissionLockError,
141
141
  allocateDrawValue
142
- } from "../chunk-K2ZNIQZP.js";
142
+ } from "../chunk-2VGMZ7VF.js";
143
143
  import "../chunk-YG7G4DPZ.js";
144
144
  import {
145
145
  SDK_INIT_ADVISORY_LOCK,
@@ -1190,7 +1190,7 @@ function createDVMHost(opts = {}) {
1190
1190
  });
1191
1191
  applyRetryToPool(pool, "dvm-host");
1192
1192
  pgPool = pool;
1193
- const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-WIIVRZPD.js");
1193
+ const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-ZVMAN6L2.js");
1194
1194
  const pgJobStore = new PostgresJobStore2(pool);
1195
1195
  pendingInits.push(pgJobStore.init(), pgJobStore.initStreaming());
1196
1196
  jobStore = pgJobStore;
@@ -1504,7 +1504,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1504
1504
  sharedPgConsumedStore = consumedStore;
1505
1505
  }
1506
1506
  if (pgPool) {
1507
- const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-4CBYLSLY.js");
1507
+ const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-MF23UKRJ.js");
1508
1508
  const pgLedger = new CreditLedger2(pgPool, tempoSessionStore);
1509
1509
  pendingInits.push(pgLedger.init());
1510
1510
  creditLedger = pgLedger;
@@ -1513,7 +1513,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1513
1513
  pendingInits.push(pgProcessed.init());
1514
1514
  processedPayments = pgProcessed;
1515
1515
  } else {
1516
- const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-DKCN7FY2.js");
1516
+ const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-ERD764PS.js");
1517
1517
  creditLedger = disposableCashu?.ledger ?? new MemoryCreditLedger2();
1518
1518
  const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-GKMAWOM3.js");
1519
1519
  processedPayments = new MemoryProcessedPaymentStore2();
@@ -1635,7 +1635,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1635
1635
  lockPubkey: cashuOpts.lockPubkey,
1636
1636
  lockPubkeyGraceSeconds: cashuOpts.lockPubkeyGraceSeconds,
1637
1637
  canonicalDvmId: cashuOpts.canonicalDvmId,
1638
- db: hostingControl ? pgPool : cashuOpts.db,
1638
+ db: pgPool ?? cashuOpts.db,
1639
1639
  hostingControl,
1640
1640
  hostingCleanupSingleMount: mounts.length === 1,
1641
1641
  hostingCleanupKnownRailStores: !mpp || tempoChargeBackend === "postgres",
@@ -7,6 +7,38 @@ import { PaymentPayload as PaymentPayload$1, PaymentRequirements as PaymentRequi
7
7
  import { Account, Client, Hex } from 'viem';
8
8
  import { z } from 'zod';
9
9
 
10
+ /** Auth identifier advertised by DVMs using audience-bound caller proofs. */
11
+ declare const SIGNED_REQUEST_AUTH_ID: "secp256k1-schnorr-v2";
12
+ /** Version of the canonical audience-bound caller statement. */
13
+ declare const SIGNED_REQUEST_STATEMENT_VERSION: 2;
14
+ /** Attested service identity a signed caller statement is intended for. */
15
+ interface SignedRequestAudience {
16
+ dvm_id: string;
17
+ builder_pubkey: string;
18
+ }
19
+ /** Operation fields kept outside the signed input to prevent schema substitution. */
20
+ interface SignedRequestDomain {
21
+ audience: SignedRequestAudience;
22
+ method: string;
23
+ path: string;
24
+ capability: string | null;
25
+ }
26
+ /** Domain fields carried with every v2 signed-request envelope. */
27
+ interface SignedRequestStatementHeader {
28
+ v: typeof SIGNED_REQUEST_STATEMENT_VERSION;
29
+ protocol: "dvmkit";
30
+ protocol_version: 1;
31
+ auth: typeof SIGNED_REQUEST_AUTH_ID;
32
+ audience: SignedRequestAudience;
33
+ method: string;
34
+ path: string;
35
+ capability: string | null;
36
+ }
37
+ /** Build the versioned header persisted beside a caller's flat input envelope. */
38
+ declare function signedRequestStatementHeader(domain: SignedRequestDomain): SignedRequestStatementHeader;
39
+ /** Canonicalize a concrete request path: leading slash, no query or fragment. */
40
+ declare function canonicalRequestPath(pathOrUrl: string): string;
41
+
10
42
  /**
11
43
  * Currency-code identifier used throughout the SDK's pricing surface. Validated
12
44
  * to ISO 4217-style three-letter lowercase ("usd", "eur", "jpy", …) at SDK
@@ -435,6 +467,11 @@ interface ArtifactContent {
435
467
  }
436
468
  /** Provider requests payment to continue. */
437
469
  interface PaymentRequestContent {
470
+ /** Exact outstanding balance charge, in integer micro-units. Use this message’s seq as request_seq. */
471
+ credit?: {
472
+ amount_micro: number;
473
+ currency: string;
474
+ };
438
475
  amount_msats: number;
439
476
  reason: string;
440
477
  /**
@@ -486,8 +523,22 @@ interface PaymentRequestContent {
486
523
  challenges: MppxChallenge[];
487
524
  };
488
525
  }
489
- /** Requester sends payment proof, or provider sends change/refund. */
526
+ /** Requester sends a rail proof or signed balance authorization; provider sends change/refund. */
490
527
  interface PaymentContent {
528
+ /** Signed authorization to spend existing credit on one outstanding ask. Cannot accompany rail credentials. */
529
+ credit?: {
530
+ credit_id: string;
531
+ draw_id: string;
532
+ payment_id: string;
533
+ request_seq: number;
534
+ amount_micro: number;
535
+ currency: string;
536
+ pubkey: string;
537
+ signature: string;
538
+ timestamp: number;
539
+ nonce: string;
540
+ auth_statement: SignedRequestStatementHeader;
541
+ };
491
542
  cashu_token?: string;
492
543
  mint?: string;
493
544
  amount_msats?: number;
@@ -614,38 +665,6 @@ declare function isWorkingMessage(msg: Message): msg is MessageBase & {
614
665
  content: WorkingContent;
615
666
  };
616
667
 
617
- /** Auth identifier advertised by DVMs using audience-bound caller proofs. */
618
- declare const SIGNED_REQUEST_AUTH_ID: "secp256k1-schnorr-v2";
619
- /** Version of the canonical audience-bound caller statement. */
620
- declare const SIGNED_REQUEST_STATEMENT_VERSION: 2;
621
- /** Attested service identity a signed caller statement is intended for. */
622
- interface SignedRequestAudience {
623
- dvm_id: string;
624
- builder_pubkey: string;
625
- }
626
- /** Operation fields kept outside the signed input to prevent schema substitution. */
627
- interface SignedRequestDomain {
628
- audience: SignedRequestAudience;
629
- method: string;
630
- path: string;
631
- capability: string | null;
632
- }
633
- /** Domain fields carried with every v2 signed-request envelope. */
634
- interface SignedRequestStatementHeader {
635
- v: typeof SIGNED_REQUEST_STATEMENT_VERSION;
636
- protocol: "dvmkit";
637
- protocol_version: 1;
638
- auth: typeof SIGNED_REQUEST_AUTH_ID;
639
- audience: SignedRequestAudience;
640
- method: string;
641
- path: string;
642
- capability: string | null;
643
- }
644
- /** Build the versioned header persisted beside a caller's flat input envelope. */
645
- declare function signedRequestStatementHeader(domain: SignedRequestDomain): SignedRequestStatementHeader;
646
- /** Canonicalize a concrete request path: leading slash, no query or fragment. */
647
- declare function canonicalRequestPath(pathOrUrl: string): string;
648
-
649
668
  /** Protocol version spoken by this SDK generation. */
650
669
  declare const DVM_PROTOCOL_VERSION = "1";
651
670
  /** HTTP headers used by the additive client-compatibility contract. */
@@ -2986,7 +3005,8 @@ declare class CreditLedger {
2986
3005
  /**
2987
3006
  * Grow an accepted job’s pending hold while preserving its original ledger_seq. The balance
2988
3007
  * tuple is updated at that sequence, so interleaved draws need not form a monotonic balance
2989
- * trajectory. No expiry check applies to an already accepted job.
3008
+ * trajectory. Existing rail top-ups retain accepted-job semantics; spending existing balance
3009
+ * opts into fresh-spend expiry and channel gates.
2990
3010
  *
2991
3011
  * Available balance excludes every pending hold, including this one. An earmark allocates
2992
3012
  * the incoming funding’s rail value; absent one, growth uses the pool.
@@ -2997,6 +3017,9 @@ declare class CreditLedger {
2997
3017
  * than throwing and rolling back accepted proofs.
2998
3018
  */
2999
3019
  growDraw(args: {
3020
+ /** Apply fresh-spend expiry and channel gates when consuming existing balance. */
3021
+ spendExistingBalance?: boolean;
3022
+ hostingPaymentSeq?: number;
3000
3023
  creditId: string;
3001
3024
  drawId: string;
3002
3025
  addAmountMicro: number;
@@ -3625,6 +3648,8 @@ interface CreditLedgerLike {
3625
3648
  nowMs?: number;
3626
3649
  }): Promise<DrawResult>;
3627
3650
  growDraw(args: {
3651
+ spendExistingBalance?: boolean;
3652
+ hostingPaymentSeq?: number;
3628
3653
  creditId: string;
3629
3654
  drawId: string;
3630
3655
  addAmountMicro: number;
@@ -1,6 +1,6 @@
1
- import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-ySTD1wwZ.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-d-VKen4K.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-DRwXCJDI.js';
1
+ import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-a1yRdmhI.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-DQqpwXa8.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-B8Ijr5V6.js';
4
4
  import 'hono';
5
5
  import 'mppx';
6
6
  import '@x402/core/server';
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-d-VKen4K.js';
1
+ import { C as Currency } from './step-cache-DQqpwXa8.js';
2
2
 
3
3
  /**
4
4
  * Thrown by `fiatToSatsCeil` / `satsToFiat` when the supplied `ratePerBtc` is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvmkit/sdk",
3
- "version": "0.11.0-rc.1",
3
+ "version": "0.12.0",
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": [