@dvmkit/sdk 0.6.0-rc.1 → 0.7.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +39 -2
  2. package/dist/{chunk-PLG4XER6.js → chunk-2NUFE2PG.js} +47 -5
  3. package/dist/{chunk-7ZUKL4IV.js → chunk-3E4C6W7W.js} +16 -5
  4. package/dist/{chunk-HHBDBMEO.js → chunk-53SNRGQQ.js} +375 -158
  5. package/dist/{chunk-IWQHUSMO.js → chunk-62FI3NJF.js} +78 -2
  6. package/dist/chunk-6HJEVCVI.js +17 -0
  7. package/dist/chunk-A262WVYX.js +6 -0
  8. package/dist/{chunk-RLTSCKRI.js → chunk-BPYMEMQX.js} +50 -3
  9. package/dist/{chunk-IV6Q7NRW.js → chunk-C5RIQWG4.js} +1 -1
  10. package/dist/{chunk-GAOAYHZA.js → chunk-FBQVOOYF.js} +37 -6
  11. package/dist/{chunk-Z4ZT5LNT.js → chunk-GEI4MAXE.js} +3 -3
  12. package/dist/{chunk-FYRR2UEZ.js → chunk-GLIAR7RN.js} +1 -1
  13. package/dist/{chunk-X7EZ5CLI.js → chunk-HCATFJDD.js} +3 -3
  14. package/dist/{chunk-BYCEKO65.js → chunk-HPCXF3DV.js} +220 -32
  15. package/dist/{chunk-JH3SX3LY.js → chunk-IRXIH775.js} +6 -6
  16. package/dist/{chunk-QR2EF2NI.js → chunk-KCQDXIJU.js} +1 -42
  17. package/dist/chunk-MDW7ZR7V.js +47 -0
  18. package/dist/{chunk-KA6VN5FK.js → chunk-MQYM4T66.js} +3 -3
  19. package/dist/{chunk-P6QON7ER.js → chunk-NV7Z7377.js} +1 -1
  20. package/dist/{chunk-OQA7IHI4.js → chunk-OBBVDKLE.js} +484 -234
  21. package/dist/{chunk-EQLA4FFY.js → chunk-OHUXCAOM.js} +17 -6
  22. package/dist/{chunk-FI4CST2D.js → chunk-PZ5IAWFD.js} +5 -7
  23. package/dist/{chunk-IXR5RFK7.js → chunk-R3TQSXWT.js} +191 -5
  24. package/dist/{chunk-VHNPVGSA.js → chunk-T5DIXOLR.js} +3 -3
  25. package/dist/{chunk-RCM3P2HE.js → chunk-UKD3R2KU.js} +55 -4
  26. package/dist/chunk-WMGXJQI3.js +120 -0
  27. package/dist/{chunk-N5RZ5HVB.js → chunk-X6S2CHFM.js} +2 -2
  28. package/dist/{chunk-ETXDTUJO.js → chunk-ZCNPIILZ.js} +112 -1
  29. package/dist/{content-retention-BTGSQRfP.d.ts → content-retention-D2K4MKNO.d.ts} +1 -1
  30. package/dist/{credit-ledger-MI2H7NEC.js → credit-ledger-MFIIOSZH.js} +4 -5
  31. package/dist/{credit-menu-BAsrRu3z.d.ts → credit-menu-D2t1-Tf6.d.ts} +13 -6
  32. package/dist/{fx-BgDmyTdd.d.ts → fx-Ql4nvdbh.d.ts} +10 -3
  33. package/dist/index.d.ts +5 -5
  34. package/dist/index.js +248 -16
  35. package/dist/internal/caller.d.ts +4586 -7318
  36. package/dist/internal/caller.js +4431 -8127
  37. package/dist/internal/index.js +1 -1
  38. package/dist/internal/server.d.ts +7 -7
  39. package/dist/internal/server.js +30 -33
  40. package/dist/{job-store-BVeF5_Jq.d.ts → job-store-DCvJQUX0.d.ts} +1 -1
  41. package/dist/{lightning-backend-40fIzz1W.d.ts → lightning-backend-CY5ML3km.d.ts} +4 -2
  42. package/dist/memory-credit-ledger-44NE4PZC.js +11 -0
  43. package/dist/{mpp-setup-RF5FXGGV.js → mpp-setup-HRWUBULX.js} +4 -2
  44. package/dist/{payout-reporter-3Y2U55ZX.js → payout-reporter-7P66T77I.js} +6 -4
  45. package/dist/{postgres-consumed-credential-store-BUVCAPLS.js → postgres-consumed-credential-store-IDGPFKIL.js} +3 -3
  46. package/dist/{postgres-job-store-VHLQBJZC.js → postgres-job-store-UKNJ2F6Z.js} +2 -2
  47. package/dist/{postgres-replay-store-ARZSQ45X.js → postgres-replay-store-PMA4ADXN.js} +2 -2
  48. package/dist/{pricing-XT2IAPNE.js → pricing-52XJHJ6K.js} +12 -12
  49. package/dist/{revenue-reporter-MAERPYGK.js → revenue-reporter-HV7RMS54.js} +2 -2
  50. package/dist/server/index.d.ts +12 -11
  51. package/dist/server/index.js +49 -53
  52. package/dist/{step-cache-CPdH1hei.d.ts → step-cache-BOWAn_BH.d.ts} +84 -7
  53. package/dist/{tempo-charge-store-Q3D7KYMH.js → tempo-charge-store-P2Z4RMU7.js} +2 -2
  54. package/dist/{tempo-session-store-ZRNCOX7P.js → tempo-session-store-VSP7KLBS.js} +3 -3
  55. package/dist/testing/index.d.ts +3 -3
  56. package/dist/testing/index.js +7 -6
  57. package/dist/{usd-AWlrwlM5.d.ts → usd-MAtMp3DB.d.ts} +1 -1
  58. package/dist/{x402-R6HPBY5D.js → x402-3IQ3HXSG.js} +9 -29
  59. package/package.json +3 -2
  60. package/dist/chunk-AT6V3SY7.js +0 -102
  61. package/dist/chunk-B2IROPQF.js +0 -1844
  62. package/dist/chunk-CZULM42S.js +0 -143
  63. package/dist/chunk-GFY5FRX3.js +0 -218
  64. package/dist/chunk-HCLVYZUZ.js +0 -244
  65. package/dist/chunk-LE74UEV7.js +0 -1071
  66. package/dist/chunk-LIRAHP7B.js +0 -53
  67. package/dist/chunk-MZRJR2CW.js +0 -776
  68. package/dist/chunk-OFVV37XC.js +0 -57
  69. package/dist/chunk-PAIM66YA.js +0 -347
  70. package/dist/chunk-UOCZXO2Z.js +0 -1663
  71. package/dist/memory-credit-ledger-W2BAUYJP.js +0 -12
  72. package/dist/tempo-lifecycle-ZBBLFBMH.js +0 -15
  73. package/dist/tempo-wallet-B5XXV3YH.js +0 -40
@@ -337,6 +337,9 @@ var diagnostic_catalogue_v1_default = {
337
337
  "revenue_skipped_unsettled_draw",
338
338
  "rollback",
339
339
  "router.proxy",
340
+ "sanctions_ip_data_incomplete",
341
+ "sanctions_ip_data_load_failed",
342
+ "sanctions_ip_data_stale",
340
343
  "scrape_cache_touch_failed",
341
344
  "scrape_cache_write_failed",
342
345
  "scrape_card_segmentation_failed",
@@ -409,6 +412,7 @@ var diagnostic_catalogue_v1_default = {
409
412
  "tempo_observer_health_unavailable",
410
413
  "tempo_observer_scan_failed",
411
414
  "tempo_refund_amount_unreported",
415
+ "tempo_replay_mark_failed",
412
416
  "tempo_routine_sweep",
413
417
  "tempo_routine_sweep_failed",
414
418
  "tempo_session_advertised_refresh_failed",
@@ -416,6 +420,7 @@ var diagnostic_catalogue_v1_default = {
416
420
  "tempo_session_close_failed",
417
421
  "tempo_session_close_failure_reconcile_failed",
418
422
  "tempo_session_close_recovery_failed",
423
+ "tempo_session_close_recovery_unmatched",
419
424
  "tempo_session_open_refused",
420
425
  "tempo_session_settled",
421
426
  "tempo_session_withheld",
@@ -776,6 +781,7 @@ var diagnostic_catalogue_v1_default = {
776
781
  "hardened",
777
782
  "head_status",
778
783
  "hint",
784
+ "hosting_identity_revoke_failed",
779
785
  "ingest_concurrency",
780
786
  "ingest_global_concurrency",
781
787
  "ingest_ip_concurrency",
@@ -825,6 +831,7 @@ var diagnostic_catalogue_v1_default = {
825
831
  "quota_exceeded",
826
832
  "rate_limited",
827
833
  "rate_limited_by_target",
834
+ "region_unavailable",
828
835
  "replay_detected",
829
836
  "request_integrity_failed",
830
837
  "retry_hardened",
@@ -977,6 +984,7 @@ var diagnostic_catalogue_v1_default = {
977
984
  ],
978
985
  tokenFields: [],
979
986
  hashFields: [
987
+ "job_id_hash",
980
988
  "key_hash",
981
989
  "prefix_hash"
982
990
  ],
@@ -998,11 +1006,108 @@ var diagnostic_catalogue_v1_default = {
998
1006
  ],
999
1007
  clientVersionFields: [
1000
1008
  "client.version"
1009
+ ],
1010
+ paymentSkipReasons: [
1011
+ "credit_or_draw_missing",
1012
+ "draw_not_pending",
1013
+ "draw_job_mismatch",
1014
+ "rail_mismatch",
1015
+ "channel_binding_mismatch",
1016
+ "denomination_unavailable",
1017
+ "topup_cap_unavailable",
1018
+ "topup_cap_currency_mismatch",
1019
+ "unknown"
1020
+ ],
1021
+ denominationCauses: [
1022
+ "no_msats",
1023
+ "sub_micro",
1024
+ "unsupported_currency",
1025
+ "rate_unavailable",
1026
+ "rate_stale_refused",
1027
+ "unknown"
1028
+ ],
1029
+ fxSourceFailures: [
1030
+ "network_error",
1031
+ "http_error",
1032
+ "invalid_body",
1033
+ "no_usable_rate",
1034
+ "missing_currency",
1035
+ "unknown"
1036
+ ],
1037
+ paymentFailureCategories: [
1038
+ "invalid_challenge",
1039
+ "malformed_credential",
1040
+ "payment_expired",
1041
+ "verification_failed",
1042
+ "insufficient_funds",
1043
+ "invalid_signature",
1044
+ "unsupported_method",
1045
+ "replay_detected",
1046
+ "ledger_refused",
1047
+ "settlement_failed",
1048
+ "unsupported_version",
1049
+ "unknown"
1050
+ ],
1051
+ paymentFailureStages: [
1052
+ "verifier",
1053
+ "broadcast",
1054
+ "verifier_broadcast",
1055
+ "replay_store",
1056
+ "funding_ledger",
1057
+ "unknown"
1058
+ ],
1059
+ paymentPhases: [
1060
+ "upfront",
1061
+ "mid-job"
1062
+ ],
1063
+ sanctionsRegions: [
1064
+ "BY",
1065
+ "CU",
1066
+ "IR",
1067
+ "KP",
1068
+ "RU",
1069
+ "UA-09",
1070
+ "UA-14",
1071
+ "UA-40",
1072
+ "UA-43"
1073
+ ],
1074
+ submitIdentitySources: [
1075
+ "header",
1076
+ "header_absent",
1077
+ "header_invalid",
1078
+ "not_extracted"
1079
+ ],
1080
+ fundedRuntimeReclaims: [
1081
+ "closed"
1082
+ ],
1083
+ suspensionReasons: [
1084
+ "request_limit",
1085
+ "dvm_limit",
1086
+ "behaviour",
1087
+ "free_tier_idle",
1088
+ "admin_org_suspend",
1089
+ "builder_pause",
1090
+ "withdrawn",
1091
+ "operator"
1001
1092
  ]
1002
1093
  };
1003
1094
 
1004
1095
  // src/observability/projection.ts
1005
1096
  var DIAGNOSTIC_CATALOGUE_VERSION = diagnostic_catalogue_v1_default.version;
1097
+ var PAYMENT_ENUMS = {
1098
+ reason: new Set(diagnostic_catalogue_v1_default.paymentSkipReasons),
1099
+ cause: new Set(diagnostic_catalogue_v1_default.denominationCauses),
1100
+ source_failure: new Set(diagnostic_catalogue_v1_default.fxSourceFailures),
1101
+ failure_category: new Set(diagnostic_catalogue_v1_default.paymentFailureCategories),
1102
+ failure_stage: new Set(diagnostic_catalogue_v1_default.paymentFailureStages),
1103
+ phase: new Set(diagnostic_catalogue_v1_default.paymentPhases)
1104
+ };
1105
+ var ROUTER_ENUMS = {
1106
+ submit_identity_source: new Set(diagnostic_catalogue_v1_default.submitIdentitySources),
1107
+ funded_runtime_reclaim: new Set(diagnostic_catalogue_v1_default.fundedRuntimeReclaims),
1108
+ suspended_reclaim: new Set(diagnostic_catalogue_v1_default.suspensionReasons),
1109
+ suspended_admin: new Set(diagnostic_catalogue_v1_default.suspensionReasons)
1110
+ };
1006
1111
  var EVENTS = new Set(diagnostic_catalogue_v1_default.events);
1007
1112
  var ROUTE_TEMPLATES = [...diagnostic_catalogue_v1_default.routeTemplates].sort(
1008
1113
  compareRouteTemplates
@@ -1027,6 +1132,7 @@ var CLIENT_PROTOCOL_VERSIONS = new Set(
1027
1132
  diagnostic_catalogue_v1_default.clientProtocolVersions
1028
1133
  );
1029
1134
  var CLIENT_VERSION_FIELDS = new Set(diagnostic_catalogue_v1_default.clientVersionFields);
1135
+ var SANCTIONS_REGIONS = new Set(diagnostic_catalogue_v1_default.sanctionsRegions);
1030
1136
  var SPAN_ID_RE = /^(?!0{16}$)[0-9a-f]{16}$/;
1031
1137
  var TRACE_ID_RE = /^(?!0{32}$)[0-9a-f]{32}$/;
1032
1138
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -1202,6 +1308,9 @@ function projectFields(input, dataset, authority, identityAuthority) {
1202
1308
  return output;
1203
1309
  }
1204
1310
  function projectField(key, value, dataset, authority, identityAuthority) {
1311
+ const closedEnum = Object.hasOwn(PAYMENT_ENUMS, key) ? PAYMENT_ENUMS[key] : Object.hasOwn(ROUTER_ENUMS, key) ? ROUTER_ENUMS[key] : void 0;
1312
+ if (closedEnum)
1313
+ return typeof value === "string" && closedEnum.has(value) ? value : void 0;
1205
1314
  if (BOOLEAN_FIELDS.has(key))
1206
1315
  return typeof value === "boolean" ? value : void 0;
1207
1316
  if (INTEGER_FIELDS.has(key))
@@ -1218,7 +1327,7 @@ function projectField(key, value, dataset, authority, identityAuthority) {
1218
1327
  if (key === "route") return projectQualifiedRoute(value);
1219
1328
  if (key === "http.route" || key === "resource_path")
1220
1329
  return projectRouteTemplate(value);
1221
- if (key === "status_code" || key === "http.status_code") {
1330
+ if (key === "status_code" || key === "http.status_code" || key === "source_status") {
1222
1331
  return Number.isInteger(value) && value >= 100 && value <= 599 ? value : void 0;
1223
1332
  }
1224
1333
  if (key === "method" || key === "http.method") {
@@ -1252,6 +1361,8 @@ function projectField(key, value, dataset, authority, identityAuthority) {
1252
1361
  return typeof value === "string" && STRIPE_EVENT_RE.test(value) ? value : void 0;
1253
1362
  if (key === "reject_reason")
1254
1363
  return value === "scanner_probe" ? value : void 0;
1364
+ if (key === "sanctions_region")
1365
+ return typeof value === "string" && SANCTIONS_REGIONS.has(value) ? value : void 0;
1255
1366
  return void 0;
1256
1367
  }
1257
1368
  function projectService(value) {
@@ -1,4 +1,4 @@
1
- import { b as JobStore, J as JobRecord } from './job-store-BVeF5_Jq.js';
1
+ import { b as JobStore, J as JobRecord } from './job-store-DCvJQUX0.js';
2
2
 
3
3
  /** Authenticated caller metadata; omitted fields on older services mean unknown. */
4
4
  interface JobContentMetadata {
@@ -10,12 +10,11 @@ import {
10
10
  isDrainMethod,
11
11
  isFundingRail,
12
12
  x402SettlementPending
13
- } from "./chunk-JH3SX3LY.js";
13
+ } from "./chunk-IRXIH775.js";
14
+ import "./chunk-NV7Z7377.js";
15
+ import "./chunk-BPYMEMQX.js";
16
+ import "./chunk-ZCNPIILZ.js";
14
17
  import "./chunk-COYKJRMM.js";
15
- import "./chunk-P6QON7ER.js";
16
- import "./chunk-RLTSCKRI.js";
17
- import "./chunk-LIRAHP7B.js";
18
- import "./chunk-ETXDTUJO.js";
19
18
  export {
20
19
  CreditLedger,
21
20
  CreditLedgerError,
@@ -1,11 +1,11 @@
1
- import { g as LockPubkey, f as CheckMintHealthOptions, b as LightningBackend, A as AttestationPayload } from './lightning-backend-40fIzz1W.js';
2
- import { cf as HostingCleanupFence, cV as HostedIntent, ah as FundingMethod, o as PaymentMethod, bN as CreditLedgerLike, a1 as Message, X as FundingReceipt, bP as CreditSnapshot, Y as JobReceipt, S as SDKJobContext, aw as StepCache, u as ResponseContent, P as PaymentContent, a2 as MessageType, bj as X402Receipt, aE as X402Config, bi as X402ExactVersionSupport, cW as X402SettlementIntent, aq as PaymentRequirementsV2, cX as HostedFundingReservation, c2 as CreditLedgerQuerier, cY as X402SettlementCursor, bR as X402SettlementStatus, cZ as X402SettlementWriteOff, bO as X402RefundSettlementGate, c_ as X402FacilitatorAuth, c$ as X402BatchSettlementConfig, cB as PostgresX402ChannelStorage, d0 as X402PayoutObserver, bL as HostedSettlementReportObligations, br as MppxServer, ac as CashuMode, d1 as CreditDepositEnqueue, d2 as X402SettlementReconciliationReason, ao as PaymentRequirements, a0 as MppxCredential, bm as CreditDepositPayload, bQ as DrawResult, cp as CreditLedgerError, a7 as ReceiptCredit, ae as DrainReceiptEvent, a6 as DrainReceipt, K as KVStore, y as SignedRequestAudience, d3 as CreditDrawReleaseEnqueue, cz as JobCostReportPayload, cA as JobTerminalReportPayload, cD as RevenueSkippedNoRailPayload, Z as ZodLike, a as DVMDescriptor, bW as CreditInvoiceRecord, bX as InvoiceSettlement, cj as ClientCompatibilityGate, ch as ClientCompatibility, bv as PostgresTempoSessionStore, bu as PayoutReporter, R as ResolvedCreditConfig, g as CreditView } from './step-cache-CPdH1hei.js';
1
+ import { f as LockPubkey, e as CheckMintHealthOptions, b as LightningBackend, A as AttestationPayload } from './lightning-backend-CY5ML3km.js';
2
+ import { cg as HostingCleanupFence, cW as HostedIntent, aj as FundingMethod, p as PaymentMethod, bO as CreditLedgerLike, a5 as Message, $ as FundingReceipt, bQ 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, cX as X402SettlementIntent, ab as PaymentRequirementsV2, cY as HostedFundingReservation, c3 as CreditLedgerQuerier, cZ as X402SettlementCursor, bS as X402SettlementStatus, c_ as X402SettlementWriteOff, bP as X402RefundSettlementGate, c$ as X402FacilitatorAuth, d0 as X402BatchSettlementConfig, cC as PostgresX402ChannelStorage, d1 as X402PayoutObserver, bM as HostedSettlementReportObligations, bn as CreditDepositPayload, bs as MppxServer, ae as CashuMode, d2 as CreditDepositEnqueue, d3 as X402SettlementReconciliationReason, aq as PaymentRequirements, a3 as MppxCredential, bR as DrawResult, cq as CreditLedgerError, a7 as ReceiptCredit, ag as DrainReceiptEvent, a8 as DrainReceipt, K as KVStore, z as SignedRequestAudience, d4 as CreditDrawReleaseEnqueue, cA as JobCostReportPayload, cB as JobTerminalReportPayload, cE as RevenueSkippedNoRailPayload, Z as ZodLike, a as DVMDescriptor, bX as CreditInvoiceRecord, bY as InvoiceSettlement, ck as ClientCompatibilityGate, ci as ClientCompatibility, bw as PostgresTempoSessionStore, bv as PayoutReporter, R as ResolvedCreditConfig, h as CreditView } from './step-cache-BOWAn_BH.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 { b as FxRateSnapshot, F as FxFetcher } from './fx-BgDmyTdd.js';
6
+ import { d as FxSourceFailure, b as FxRateSnapshot, F as FxFetcher } from './fx-Ql4nvdbh.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-BVeF5_Jq.js';
8
+ import { T as TopUpCapUnenforcedReason, A as AppendOutgoingOptions, J as JobRecord, b as JobStore } from './job-store-DCvJQUX0.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';
@@ -417,6 +417,8 @@ interface HostingControlStatus {
417
417
  admissionId: string;
418
418
  jobId: string;
419
419
  }[];
420
+ /** Version of the job-identity response-head field this deployment emits. */
421
+ jobIdentityHeader: "v1";
420
422
  }
421
423
 
422
424
  interface PromptResolver {
@@ -882,6 +884,7 @@ type ResolvedFx = {
882
884
  ok: false;
883
885
  reason: FiatDenominationFailure;
884
886
  detail?: string;
887
+ sourceFailure?: FxSourceFailure;
885
888
  };
886
889
  /**
887
890
  * The result of denominating an msat amount. See {@link msatsToFiatMicro}.
@@ -903,6 +906,7 @@ type FiatDenomination = {
903
906
  ok: false;
904
907
  reason: FiatDenominationFailure;
905
908
  detail?: string;
909
+ sourceFailure?: FxSourceFailure;
906
910
  };
907
911
  /**
908
912
  * A live fetch failure may use lastKnown(), but a known-stale refusal never
@@ -1430,9 +1434,9 @@ interface X402SettlementEvidenceReader extends X402ExactSettlementEvidenceReader
1430
1434
  declare const X402_BATCH_SETTLEMENT_NETWORK = "eip155:84532";
1431
1435
  /** Base mainnet channel network, enabled only with an in-process relay. */
1432
1436
  declare const X402_BATCH_SETTLEMENT_MAINNET_NETWORK = "eip155:8453";
1433
- /** Policy floor advertised to callers and enforced at boot. */
1437
+ /** Default withdrawal grace and minimum outside Base Sepolia; seconds. */
1434
1438
  declare const X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS = 86400;
1435
- /** Default claim and transfer cadence; comfortably inside the 24-hour exit window. */
1439
+ /** Default claim and transfer cadence; comfortably inside the default 24-hour exit window. */
1436
1440
  declare const X402_BATCH_AUTO_SETTLEMENT: AutoSettlementConfig;
1437
1441
  /** Natural identity and incremental value carried by an accepted channel voucher. */
1438
1442
  interface X402BatchFunding {
@@ -1857,6 +1861,8 @@ interface CreditFundingReport {
1857
1861
  fundedAt: number;
1858
1862
  /** Current credit expiry after this funding committed (epoch ms). */
1859
1863
  expiryMs: number;
1864
+ /** The funded credit's stored instrument; absent for Cashu. */
1865
+ instrument?: CreditInstrument;
1860
1866
  /** TIP-1034 voucher identity, present only for session-funded credit. */
1861
1867
  tempoSession?: {
1862
1868
  channelId: string;
@@ -2502,6 +2508,7 @@ declare function repairX402ExactSettlementEffect(args: {
2502
2508
  enqueueCreditDeposit?: CreditDepositEnqueue;
2503
2509
  tx?: CreditLedgerQuerier;
2504
2510
  }): Promise<CommittedFunding | undefined>;
2511
+ type CreditInstrument = NonNullable<CreditDepositPayload["instrument"]>;
2505
2512
 
2506
2513
  interface ReceiptIssuerOpts {
2507
2514
  /** 32-byte hex receipt secret — `DVMKIT_RECEIPT_KEY`, or an ephemeral dev key. */
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-CPdH1hei.js';
1
+ import { C as Currency } from './step-cache-BOWAn_BH.js';
2
2
 
3
3
  /**
4
4
  * Quote-time FX snapshot. `rates` maps configured lowercase currency codes to
@@ -61,6 +61,12 @@ interface PlatformFxSource {
61
61
  declare const FX_CACHE_TTL_MS = 300000;
62
62
  /** Default retry budget per `fetch()` call before raising `fx_rate_unavailable`. */
63
63
  declare const FX_RETRY_COUNT = 2;
64
+ type FxSourceFailureCategory = "network_error" | "http_error" | "invalid_body" | "no_usable_rate" | "missing_currency" | "unknown";
65
+ /** Observed source failure only; never provider text or an inferred root cause. */
66
+ interface FxSourceFailure {
67
+ category: FxSourceFailureCategory;
68
+ httpStatus?: number;
69
+ }
64
70
  interface FxRateUnavailableCopy {
65
71
  display?: string;
66
72
  hint?: string;
@@ -109,7 +115,8 @@ declare class FxRateUnavailableError extends Error {
109
115
  * the last-known rate without it. See {@link FxKnownStale}.
110
116
  */
111
117
  readonly knownStale?: FxKnownStale;
112
- constructor(message?: string, copy?: FxRateUnavailableCopy, knownStale?: FxKnownStale);
118
+ readonly sourceFailure?: FxSourceFailure;
119
+ constructor(message?: string, copy?: FxRateUnavailableCopy, knownStale?: FxKnownStale, sourceFailure?: FxSourceFailure);
113
120
  }
114
121
  /**
115
122
  * Snapshot fetcher for BTC against one or more fiat currencies. Caches
@@ -196,4 +203,4 @@ declare function fxRateFor(snapshot: FxRateSnapshot, currency: Currency): number
196
203
  */
197
204
  declare function resolveFxSourceFromEnv(env: Record<string, string | undefined>): string | PlatformFxSource | undefined;
198
205
 
199
- export { type CreateFxFetcherOpts as C, DEFAULT_FX_CURRENCIES as D, type FxFetcher as F, type PlatformFxSource as P, DEFAULT_FX_RATE_SOURCE as a, type FxRateSnapshot as b, FxRateUnavailableError as c, createFxFetcher as d, FX_CACHE_TTL_MS as e, fxRateFor as f, FX_RETRY_COUNT as g, resolveFxSourceFromEnv as r, warmFxSnapshot as w };
206
+ export { type CreateFxFetcherOpts as C, DEFAULT_FX_CURRENCIES as D, type FxFetcher as F, type PlatformFxSource as P, DEFAULT_FX_RATE_SOURCE as a, type FxRateSnapshot as b, FxRateUnavailableError as c, type FxSourceFailure as d, type FxSourceFailureCategory as e, createFxFetcher as f, fxRateFor as g, FX_CACHE_TTL_MS as h, FX_RETRY_COUNT as i, resolveFxSourceFromEnv as r, warmFxSnapshot as w };
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-CPdH1hei.js';
2
- export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CreateSignedRequestVerifierOpts, f as CreditConfig, g as CreditView, h as DEFAULT_CREDIT_MAX, i as DEFAULT_CREDIT_MIN, j as DEFAULT_CREDIT_TTL_SECONDS, k as DEFAULT_JOB_RETENTION_DAYS, l as DVMRouteContext, I as IncomingMessage, m as InputType, n as InvalidCurrencyError, J as JobCost, K as KVStore, L as Logger, P as PaymentContent, o as PaymentMethod, p as PriceValue, q as ProgressContent, r as PromptOpts, Q as QuoteConfig, s as QuoteContext, t as QuoteResult, R as ResolvedCreditConfig, u as ResponseContent, S as SDKJobContext, v as SDKPaymentRequestOpts, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, y as SignedRequestAudience, z as SignedRequestDomain, B as SignedRequestError, E as SignedRequestFailure, F as SignedRequestReplayStore, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, U as UnsupportedCurrencyError, N as createSignedRequestVerifier, O as isZodSchema, T as signedRequestStatementHeader, V as validateCurrency } from './step-cache-CPdH1hei.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, P as PlatformFxSource, d as createFxFetcher, f as fxRateFor, r as resolveFxSourceFromEnv } from './fx-BgDmyTdd.js';
4
- export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-AWlrwlM5.js';
5
- export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-BVeF5_Jq.js';
1
+ import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './step-cache-BOWAn_BH.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-BOWAn_BH.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-Ql4nvdbh.js';
4
+ export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-MAtMp3DB.js';
5
+ export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-DCvJQUX0.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';
package/dist/index.js CHANGED
@@ -5,13 +5,12 @@ import {
5
5
  envFlag
6
6
  } from "./chunk-TVI4V7GF.js";
7
7
  import {
8
- configureDVM,
9
- isConfiguredDVMDescriptor
10
- } from "./chunk-HCLVYZUZ.js";
8
+ CAPABILITY_NAME_RE
9
+ } from "./chunk-A262WVYX.js";
11
10
  import {
12
11
  SignedRequestError,
13
12
  createSignedRequestVerifier
14
- } from "./chunk-N5RZ5HVB.js";
13
+ } from "./chunk-X6S2CHFM.js";
15
14
  import {
16
15
  DEFAULT_CREDIT_MAX,
17
16
  DEFAULT_CREDIT_MIN,
@@ -21,29 +20,262 @@ import {
21
20
  SIGNED_REQUEST_STATEMENT_VERSION,
22
21
  isZodSchema,
23
22
  signedRequestStatementHeader
24
- } from "./chunk-RCM3P2HE.js";
25
- import "./chunk-OFVV37XC.js";
23
+ } from "./chunk-UKD3R2KU.js";
24
+ import {
25
+ buildUpfront
26
+ } from "./chunk-6HJEVCVI.js";
26
27
  import {
27
28
  DEFAULT_FX_CURRENCIES,
28
29
  DEFAULT_FX_RATE_SOURCE,
29
30
  FxRateUnavailableError,
30
31
  InvalidCurrencyError,
32
+ InvalidFxRateError,
31
33
  UnsupportedCurrencyError,
32
- buildUpfront,
33
34
  createFxFetcher,
34
- fxRateFor,
35
- resolveFxSourceFromEnv,
36
- validateCurrency
37
- } from "./chunk-BYCEKO65.js";
38
- import {
39
- InvalidFxRateError,
40
35
  fiatToSatsCeil,
41
36
  formatFiat,
42
37
  formatUsd,
38
+ fxRateFor,
39
+ parseUsdPrice,
40
+ resolveFxSourceFromEnv,
43
41
  roundUsd,
44
- satsToFiat
45
- } from "./chunk-AT6V3SY7.js";
46
- import "./chunk-ETXDTUJO.js";
42
+ satsToFiat,
43
+ validateCurrency
44
+ } from "./chunk-HPCXF3DV.js";
45
+ import "./chunk-ZCNPIILZ.js";
46
+
47
+ // src/sdk/configure.ts
48
+ function configureDVM(config) {
49
+ const tags = collectTags(config);
50
+ const currency = resolvePricingCurrency(config.currency);
51
+ const capabilities = buildCapabilityMap(config, currency);
52
+ const jobRetentionDays = resolveJobRetentionDays(config.jobRetentionDays);
53
+ const onlyCapability = singleCapabilityEntry(capabilities);
54
+ const descriptor = {
55
+ name: config.name,
56
+ description: config.description ?? "",
57
+ tags,
58
+ currency,
59
+ price: onlyCapability?.price,
60
+ inputSchema: onlyCapability?.input,
61
+ state: onlyCapability?.state ?? {},
62
+ idleTimeout: config.idleTimeout ?? 3600,
63
+ processingWatchdog: config.processingWatchdog,
64
+ jobRetentionDays,
65
+ config,
66
+ capabilities,
67
+ paymentMethods: config.paymentMethods,
68
+ x402: config.x402,
69
+ mpp: config.mpp,
70
+ credit: resolveCreditConfig(config.credit),
71
+ auth: config.auth
72
+ };
73
+ CONFIGURED_DVM_DESCRIPTORS.add(descriptor);
74
+ return Object.freeze(descriptor);
75
+ }
76
+ function resolveJobRetentionDays(raw) {
77
+ const days = raw ?? DEFAULT_JOB_RETENTION_DAYS;
78
+ if (!Number.isSafeInteger(days) || days < 0 || days > Math.floor((Number.MAX_SAFE_INTEGER - Date.now()) / 864e5)) {
79
+ throw new Error(
80
+ `configureDVM: jobRetentionDays must be a non-negative whole number of days; received ${JSON.stringify(raw)}`
81
+ );
82
+ }
83
+ return days;
84
+ }
85
+ function isConfiguredDVMDescriptor(value) {
86
+ return typeof value === "object" && value !== null && CONFIGURED_DVM_DESCRIPTORS.has(value);
87
+ }
88
+ var CONFIGURED_DVM_DESCRIPTORS = /* @__PURE__ */ new WeakSet();
89
+ function resolvePricingCurrency(raw) {
90
+ if (raw === void 0) return "usd";
91
+ try {
92
+ return validateCurrency(raw);
93
+ } catch (err) {
94
+ if (err instanceof InvalidCurrencyError) {
95
+ throw new Error(
96
+ `configureDVM: currency ${JSON.stringify(raw)} is not an ISO 4217 lowercase code like "usd" or "eur". Omit the field to price in USD.`,
97
+ { cause: err }
98
+ );
99
+ }
100
+ throw err;
101
+ }
102
+ }
103
+ function resolveCreditConfig(credit) {
104
+ if (!credit) return void 0;
105
+ const min = credit.min ?? DEFAULT_CREDIT_MIN;
106
+ const max = credit.max ?? DEFAULT_CREDIT_MAX;
107
+ const ttlSeconds = credit.ttl ?? DEFAULT_CREDIT_TTL_SECONDS;
108
+ const minAmount = validatePriceLiteral(min, "credit.min");
109
+ const maxAmount = validatePriceLiteral(max, "credit.max");
110
+ if (minAmount > maxAmount) {
111
+ throw new Error(
112
+ `credit.min (${JSON.stringify(min)}) exceeds credit.max (${JSON.stringify(max)}) \u2014 no funding amount could satisfy both.`
113
+ );
114
+ }
115
+ if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
116
+ throw new Error(`credit.ttl must be a positive number of seconds (got ${ttlSeconds}).`);
117
+ }
118
+ const allowOneShotStablecoin = credit.allowOneShotStablecoin === true;
119
+ return { min, max, ttlSeconds, allowOneShotStablecoin };
120
+ }
121
+ function validatePriceLiteral(value, field, key = field) {
122
+ if (typeof value === "number") {
123
+ throw new Error(
124
+ `${field} is a number (${value}). Prices are USD literals \u2014 write ${key}: "$0.01" for one cent. Callers still pay in sats; the SDK converts at request time. Omit the field for a free capability, or use \`onQuote\` for dynamic pricing.`
125
+ );
126
+ }
127
+ if (typeof value !== "string") {
128
+ throw new Error(`${field} must be a USD literal like "$0.05" (got ${JSON.stringify(value)}).`);
129
+ }
130
+ return parseUsdPrice(value, field);
131
+ }
132
+ function validateCapabilityPrice(price, capabilityName, currency) {
133
+ if (price === void 0) return;
134
+ if (currency !== "usd") {
135
+ throw new Error(
136
+ `configureDVM: capability "${capabilityName}" declares a static price (${JSON.stringify(price)}) but this DVM prices in ${currency}. Static prices are USD literals, so they cannot express ${currency} \u2014 price this capability with \`onQuote\` returning { amount, currency: ${JSON.stringify(currency)} }, or drop the DVM-level \`currency\` to price in USD.`
137
+ );
138
+ }
139
+ validatePriceLiteral(price, `configureDVM: capability "${capabilityName}" price`, "price");
140
+ }
141
+ function collectTags(config) {
142
+ const tagSet = /* @__PURE__ */ new Set();
143
+ if (config.tag) tagSet.add(config.tag);
144
+ if (config.tags) {
145
+ for (const t of config.tags) tagSet.add(t);
146
+ }
147
+ return [...tagSet];
148
+ }
149
+ function buildCapabilityMap(config, currency) {
150
+ const hasExplicitBlock = config.capabilities !== void 0;
151
+ const hasFlatCapabilityName = typeof config.capability === "string";
152
+ const hasFlatHandler = typeof config.onJob === "function";
153
+ if (hasExplicitBlock && (hasFlatCapabilityName || hasFlatHandler || flatPerCapFieldsSet(config))) {
154
+ throw new Error(
155
+ "configureDVM: pass either the flat single-capability shape (capability + onJob + ...) or the explicit `capabilities` block, not both."
156
+ );
157
+ }
158
+ if (hasExplicitBlock) {
159
+ return buildExplicitCapabilities(config.capabilities ?? {}, currency);
160
+ }
161
+ if (!hasFlatHandler) {
162
+ throw new Error("configureDVM: onJob handler is required");
163
+ }
164
+ const name = typeof config.capability === "string" ? config.capability : slugifyCapabilityName(config.name);
165
+ validateCapabilityName(name);
166
+ validateCapabilityPrice(config.price, name, currency);
167
+ validateExampleAgainstInput(name, config.input, config.example);
168
+ const entry = {
169
+ name,
170
+ description: config.description ?? "",
171
+ input: config.input,
172
+ example: config.example,
173
+ state: config.state ?? {},
174
+ price: config.price,
175
+ onQuote: config.onQuote,
176
+ rates: snapshotRates(config.rates),
177
+ onJob: config.onJob,
178
+ onResponse: config.onResponse,
179
+ onPayment: config.onPayment,
180
+ onApproval: config.onApproval,
181
+ onCancel: config.onCancel,
182
+ onMessage: config.onMessage
183
+ };
184
+ return { [name]: entry };
185
+ }
186
+ function buildExplicitCapabilities(capabilities, currency) {
187
+ const keys = Object.keys(capabilities);
188
+ if (keys.length === 0) {
189
+ throw new Error("configureDVM: `capabilities` block must declare at least one capability");
190
+ }
191
+ const out = {};
192
+ for (const name of keys) {
193
+ validateCapabilityName(name);
194
+ const cap = capabilities[name];
195
+ if (typeof cap.onJob !== "function") {
196
+ throw new Error(`configureDVM: capability "${name}" is missing required onJob handler`);
197
+ }
198
+ validateCapabilityPrice(cap.price, name, currency);
199
+ validateExampleAgainstInput(name, cap.input, cap.example);
200
+ const entry = {
201
+ name,
202
+ description: cap.description ?? "",
203
+ // Per-capability `input` is the builder's Zod schema; the `any` widening
204
+ // through `Record<string, CapabilityConfig<any, any>>` is unavoidable
205
+ // here.
206
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
207
+ input: cap.input,
208
+ example: cap.example,
209
+ state: cap.state !== void 0 ? structuredClone(cap.state) : {},
210
+ price: cap.price,
211
+ onQuote: cap.onQuote,
212
+ rates: snapshotRates(cap.rates),
213
+ onJob: cap.onJob,
214
+ onResponse: cap.onResponse,
215
+ onPayment: cap.onPayment,
216
+ onApproval: cap.onApproval,
217
+ onCancel: cap.onCancel,
218
+ onMessage: cap.onMessage
219
+ };
220
+ out[name] = entry;
221
+ }
222
+ return out;
223
+ }
224
+ function flatPerCapFieldsSet(config) {
225
+ return config.input !== void 0 || config.example !== void 0 || config.state !== void 0 || config.price !== void 0 || config.onQuote !== void 0 || config.rates !== void 0 || typeof config.onResponse === "function" || typeof config.onPayment === "function" || typeof config.onApproval === "function" || typeof config.onCancel === "function" || typeof config.onMessage === "function";
226
+ }
227
+ function validateExampleAgainstInput(capName, input, example) {
228
+ if (example === void 0) return;
229
+ if (!isZodSchema(input)) return;
230
+ const result = input.safeParse(example);
231
+ if (result.success) return;
232
+ throw new Error(
233
+ `configureDVM: capability "${capName}" example does not satisfy its input schema. Update the example to match the schema (including any \`.refine()\` checks). Issues: ${formatZodIssues(result.error)}`
234
+ );
235
+ }
236
+ function formatZodIssues(err) {
237
+ if (err && typeof err === "object" && "issues" in err && Array.isArray(err.issues)) {
238
+ const issues = err.issues;
239
+ if (issues.length === 0) return "(no issues reported)";
240
+ return issues.map((issue) => {
241
+ const path = issue.path.length > 0 ? issue.path.join(".") : "(root)";
242
+ return `${path}: ${issue.message}`;
243
+ }).join("; ");
244
+ }
245
+ if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
246
+ return err.message.replace(/\s+/g, " ").trim();
247
+ }
248
+ try {
249
+ return JSON.stringify(err);
250
+ } catch {
251
+ return String(err);
252
+ }
253
+ }
254
+ function validateCapabilityName(name) {
255
+ if (!CAPABILITY_NAME_RE.test(name)) {
256
+ throw new Error(
257
+ `configureDVM: invalid capability name "${name}" \u2014 must be lowercase letters/digits/hyphens, must start with a letter or digit, must not contain slashes.`
258
+ );
259
+ }
260
+ }
261
+ function slugifyCapabilityName(name) {
262
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
263
+ }
264
+ function singleCapabilityEntry(capabilities) {
265
+ const keys = Object.keys(capabilities);
266
+ if (keys.length !== 1) return void 0;
267
+ return capabilities[keys[0]];
268
+ }
269
+ function snapshotRates(rates) {
270
+ if (rates === void 0) return void 0;
271
+ const copy = structuredClone(rates);
272
+ if (Array.isArray(copy)) {
273
+ for (const entry of copy) {
274
+ if (typeof entry === "object" && entry !== null) Object.freeze(entry);
275
+ }
276
+ }
277
+ return Object.freeze(copy);
278
+ }
47
279
 
48
280
  // src/sdk/heartbeat.ts
49
281
  async function withProgressHeartbeat(opts, fn) {