@t2000/sdk 10.25.1 → 10.26.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.
@@ -938,6 +938,50 @@ declare function preflightPay(input: {
938
938
  url: string;
939
939
  maxPrice?: number;
940
940
  }): PreflightResult;
941
+ /**
942
+ * What a paid call WOULD cost, without paying (S.919). Every branch mirrors
943
+ * a `payWithX402` outcome so the probe can never promise something the pay
944
+ * path then refuses — one dialect story, not two.
945
+ */
946
+ type X402Probe = {
947
+ kind: 'free';
948
+ status: number;
949
+ note: string;
950
+ } | {
951
+ kind: 'payable';
952
+ priceUsdc: number;
953
+ asset: string;
954
+ payTo: string;
955
+ network: string;
956
+ } | {
957
+ kind: 'escrow';
958
+ priceUsdc: number;
959
+ payTo: string;
960
+ note: string;
961
+ } | {
962
+ kind: 'unsupported';
963
+ reason: string;
964
+ note: string;
965
+ } | {
966
+ kind: 'incomplete';
967
+ reason: string;
968
+ note: string;
969
+ } | {
970
+ kind: 'not-x402';
971
+ status: number;
972
+ note: string;
973
+ };
974
+ /**
975
+ * READ-ONLY x402 probe: issue the same request `pay()` would, read the 402,
976
+ * and report the terms. Never signs, never spends, never throws on a
977
+ * non-payable answer — an unpayable endpoint is information, not a failure.
978
+ * (Invalid input still throws, exactly as `pay()` would, so a caller can't
979
+ * probe a URL that could never be paid.)
980
+ */
981
+ declare function probeX402(args: {
982
+ network: string;
983
+ options: PayOptions;
984
+ }): Promise<X402Probe>;
941
985
  declare function payWithX402(args: {
942
986
  signer: TransactionSigner;
943
987
  client: SuiGrpcClient;
@@ -1556,4 +1600,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1556
1600
  * the store is untrusted; the chain hash is the authority). */
1557
1601
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1558
1602
 
1559
- export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type SerializedCetusRoute as b5, type SwapResult as b6, type SwapQuoteResult as b7, type PaymentRequest as b8, type SuiCoreClient as b9, normalizeAsset as bA, normalizeCoinType as bB, queryHistory as bC, queryTransaction as bD, selectAndSplitCoin as bE, selectSuiCoin as bF, serializeCetusRoute as bG, simulateTransaction as bH, throwIfSimulationFailed as bI, verifyCetusRouteCoinMatch as bJ, type SponsoredCoinMergeCache as ba, type SendableAsset as bb, CETUS_USDC_SUI_POOL as bc, type CoinPage as bd, DEFAULT_GRPC_URL as be, GASLESS_MIN_STABLE_AMOUNT as bf, GASLESS_STABLE_TYPES as bg, OPERATION_ASSETS as bh, type Operation as bi, SENDABLE_ASSETS as bj, type SelectAndSplitResult as bk, type SerializedCetusRoutePath as bl, type SerializedRouterDataV3 as bm, addSendToTx as bn, addSwapToTx as bo, assertAllowedAsset as bp, assertBuyerRequirements as bq, buildDeclineJobTx as br, deserializeCetusRoute as bs, fetchAllCoins as bt, getCoinMeta as bu, getSuiClient as bv, getSuiGrpcClient as bw, isAllowedAsset as bx, isCetusRouteFresh as by, isInRegistry as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
1603
+ export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type X402Probe as b5, type SerializedCetusRoute as b6, type SwapResult as b7, type SwapQuoteResult as b8, type PaymentRequest as b9, isInRegistry as bA, normalizeAsset as bB, normalizeCoinType as bC, probeX402 as bD, queryHistory as bE, queryTransaction as bF, selectAndSplitCoin as bG, selectSuiCoin as bH, serializeCetusRoute as bI, simulateTransaction as bJ, throwIfSimulationFailed as bK, verifyCetusRouteCoinMatch as bL, type SuiCoreClient as ba, type SponsoredCoinMergeCache as bb, type SendableAsset as bc, CETUS_USDC_SUI_POOL as bd, type CoinPage as be, DEFAULT_GRPC_URL as bf, GASLESS_MIN_STABLE_AMOUNT as bg, GASLESS_STABLE_TYPES as bh, OPERATION_ASSETS as bi, type Operation as bj, SENDABLE_ASSETS as bk, type SelectAndSplitResult as bl, type SerializedCetusRoutePath as bm, type SerializedRouterDataV3 as bn, addSendToTx as bo, addSwapToTx as bp, assertAllowedAsset as bq, assertBuyerRequirements as br, buildDeclineJobTx as bs, deserializeCetusRoute as bt, fetchAllCoins as bu, getCoinMeta as bv, getSuiClient as bw, getSuiGrpcClient as bx, isAllowedAsset as by, isCetusRouteFresh as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
@@ -938,6 +938,50 @@ declare function preflightPay(input: {
938
938
  url: string;
939
939
  maxPrice?: number;
940
940
  }): PreflightResult;
941
+ /**
942
+ * What a paid call WOULD cost, without paying (S.919). Every branch mirrors
943
+ * a `payWithX402` outcome so the probe can never promise something the pay
944
+ * path then refuses — one dialect story, not two.
945
+ */
946
+ type X402Probe = {
947
+ kind: 'free';
948
+ status: number;
949
+ note: string;
950
+ } | {
951
+ kind: 'payable';
952
+ priceUsdc: number;
953
+ asset: string;
954
+ payTo: string;
955
+ network: string;
956
+ } | {
957
+ kind: 'escrow';
958
+ priceUsdc: number;
959
+ payTo: string;
960
+ note: string;
961
+ } | {
962
+ kind: 'unsupported';
963
+ reason: string;
964
+ note: string;
965
+ } | {
966
+ kind: 'incomplete';
967
+ reason: string;
968
+ note: string;
969
+ } | {
970
+ kind: 'not-x402';
971
+ status: number;
972
+ note: string;
973
+ };
974
+ /**
975
+ * READ-ONLY x402 probe: issue the same request `pay()` would, read the 402,
976
+ * and report the terms. Never signs, never spends, never throws on a
977
+ * non-payable answer — an unpayable endpoint is information, not a failure.
978
+ * (Invalid input still throws, exactly as `pay()` would, so a caller can't
979
+ * probe a URL that could never be paid.)
980
+ */
981
+ declare function probeX402(args: {
982
+ network: string;
983
+ options: PayOptions;
984
+ }): Promise<X402Probe>;
941
985
  declare function payWithX402(args: {
942
986
  signer: TransactionSigner;
943
987
  client: SuiGrpcClient;
@@ -1556,4 +1600,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1556
1600
  * the store is untrusted; the chain hash is the authority). */
1557
1601
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1558
1602
 
1559
- export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type SerializedCetusRoute as b5, type SwapResult as b6, type SwapQuoteResult as b7, type PaymentRequest as b8, type SuiCoreClient as b9, normalizeAsset as bA, normalizeCoinType as bB, queryHistory as bC, queryTransaction as bD, selectAndSplitCoin as bE, selectSuiCoin as bF, serializeCetusRoute as bG, simulateTransaction as bH, throwIfSimulationFailed as bI, verifyCetusRouteCoinMatch as bJ, type SponsoredCoinMergeCache as ba, type SendableAsset as bb, CETUS_USDC_SUI_POOL as bc, type CoinPage as bd, DEFAULT_GRPC_URL as be, GASLESS_MIN_STABLE_AMOUNT as bf, GASLESS_STABLE_TYPES as bg, OPERATION_ASSETS as bh, type Operation as bi, SENDABLE_ASSETS as bj, type SelectAndSplitResult as bk, type SerializedCetusRoutePath as bl, type SerializedRouterDataV3 as bm, addSendToTx as bn, addSwapToTx as bo, assertAllowedAsset as bp, assertBuyerRequirements as bq, buildDeclineJobTx as br, deserializeCetusRoute as bs, fetchAllCoins as bt, getCoinMeta as bu, getSuiClient as bv, getSuiGrpcClient as bw, isAllowedAsset as bx, isCetusRouteFresh as by, isInRegistry as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
1603
+ export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type X402Probe as b5, type SerializedCetusRoute as b6, type SwapResult as b7, type SwapQuoteResult as b8, type PaymentRequest as b9, isInRegistry as bA, normalizeAsset as bB, normalizeCoinType as bC, probeX402 as bD, queryHistory as bE, queryTransaction as bF, selectAndSplitCoin as bG, selectSuiCoin as bH, serializeCetusRoute as bI, simulateTransaction as bJ, throwIfSimulationFailed as bK, verifyCetusRouteCoinMatch as bL, type SuiCoreClient as ba, type SponsoredCoinMergeCache as bb, type SendableAsset as bc, CETUS_USDC_SUI_POOL as bd, type CoinPage as be, DEFAULT_GRPC_URL as bf, GASLESS_MIN_STABLE_AMOUNT as bg, GASLESS_STABLE_TYPES as bh, OPERATION_ASSETS as bi, type Operation as bj, SENDABLE_ASSETS as bk, type SelectAndSplitResult as bl, type SerializedCetusRoutePath as bm, type SerializedRouterDataV3 as bn, addSendToTx as bo, addSwapToTx as bp, assertAllowedAsset as bq, assertBuyerRequirements as br, buildDeclineJobTx as bs, deserializeCetusRoute as bt, fetchAllCoins as bu, getCoinMeta as bv, getSuiClient as bw, getSuiGrpcClient as bx, isAllowedAsset as by, isCetusRouteFresh as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
package/dist/index.cjs CHANGED
@@ -1140,11 +1140,65 @@ function preflightPay(input) {
1140
1140
  }
1141
1141
  return exports.PREFLIGHT_OK;
1142
1142
  }
1143
- async function payWithX402(args) {
1144
- const { signer, client } = args;
1145
- let options = args.options;
1146
- const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
1143
+ async function probeX402(args) {
1144
+ const { network } = args;
1145
+ const pf = preflightPay({ url: args.options.url, maxPrice: args.options.maxPrice });
1147
1146
  if (!pf.valid) throw new exports.T2000Error(pf.code, pf.error);
1147
+ const { reqInit } = normalizePayRequest(args.options);
1148
+ const probe = await fetch(args.options.url, reqInit);
1149
+ if (probe.status !== 402) {
1150
+ return {
1151
+ kind: "free",
1152
+ status: probe.status,
1153
+ note: "No payment required \u2014 this endpoint served without a 402."
1154
+ };
1155
+ }
1156
+ const pick = await pickSuiExactRequirements(probe, network);
1157
+ if (pick.kind === "payable") {
1158
+ const requirements = pick.requirements;
1159
+ const priceUsdc = atomicToHuman(
1160
+ BigInt(requirements.maxAmountRequired),
1161
+ await assetDecimals(requirements.asset)
1162
+ );
1163
+ const { isX402EscrowRequirements } = await import('@t2000/sui-x402');
1164
+ if (isX402EscrowRequirements(requirements)) {
1165
+ return {
1166
+ kind: "escrow",
1167
+ priceUsdc,
1168
+ payTo: requirements.payTo,
1169
+ note: "This endpoint sells deliverable work through on-chain escrow, not an instant call. Hire it as a job instead \u2014 funds lock in a Job object and release on delivery."
1170
+ };
1171
+ }
1172
+ return {
1173
+ kind: "payable",
1174
+ priceUsdc,
1175
+ asset: requirements.asset,
1176
+ payTo: requirements.payTo,
1177
+ network
1178
+ };
1179
+ }
1180
+ if (hasPaymentAuthenticateHeader(probe)) {
1181
+ return {
1182
+ kind: "unsupported",
1183
+ reason: "header-only-402-unsupported",
1184
+ note: "This seller answered a header-only 402 (WWW-Authenticate: Payment) with no payable x402 accepts[] envelope. That dialect is no longer supported \u2014 the seller must offer x402 (e.g. @t2000/serve emits it)."
1185
+ };
1186
+ }
1187
+ if (pick.kind === "incomplete") {
1188
+ return {
1189
+ kind: "incomplete",
1190
+ reason: "incomplete-x402-accepts",
1191
+ note: "Seller's x402 challenge is incomplete (missing extra.suimpp) \u2014 the 402 advertises an exact/sui entry but carries no settlement challenge to bind a payment to."
1192
+ };
1193
+ }
1194
+ return {
1195
+ kind: "not-x402",
1196
+ status: probe.status,
1197
+ note: `Endpoint returned 402 without an x402 'exact' / sui:${network} requirement in the body. Nothing this SDK can pay.`
1198
+ };
1199
+ }
1200
+ function normalizePayRequest(input) {
1201
+ let options = input;
1148
1202
  const method = (options.method ?? "GET").toUpperCase();
1149
1203
  const canHaveBody = method !== "GET" && method !== "HEAD";
1150
1204
  if (canHaveBody && typeof options.body === "string" && isJsonText(options.body) && !hasContentType(options.headers)) {
@@ -1153,11 +1207,23 @@ async function payWithX402(args) {
1153
1207
  headers: { ...options.headers ?? {}, "content-type": "application/json" }
1154
1208
  };
1155
1209
  }
1156
- const reqInit = {
1157
- method,
1158
- headers: options.headers,
1159
- body: canHaveBody ? options.body : void 0
1210
+ return {
1211
+ options,
1212
+ reqInit: {
1213
+ method,
1214
+ headers: options.headers,
1215
+ body: canHaveBody ? options.body : void 0
1216
+ }
1160
1217
  };
1218
+ }
1219
+ async function payWithX402(args) {
1220
+ const { signer, client } = args;
1221
+ let options = args.options;
1222
+ const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
1223
+ if (!pf.valid) throw new exports.T2000Error(pf.code, pf.error);
1224
+ const normalized = normalizePayRequest(options);
1225
+ options = normalized.options;
1226
+ const reqInit = normalized.reqInit;
1161
1227
  const probe = await fetch(options.url, reqInit);
1162
1228
  if (probe.status !== 402) {
1163
1229
  return finalize(probe, { paid: false });
@@ -2799,6 +2865,15 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2799
2865
  return this._signer;
2800
2866
  }
2801
2867
  // -- MPP Payments --
2868
+ /**
2869
+ * READ-ONLY price probe for an x402 endpoint (S.919). Reports what `pay()`
2870
+ * would cost without signing or spending, so a caller (Connect's
2871
+ * `t2000_pay_probe`, the CLI, a UI) can show terms before committing.
2872
+ * No limit gate: nothing moves.
2873
+ */
2874
+ async payProbe(options) {
2875
+ return await probeX402({ network: this.client.network, options });
2876
+ }
2802
2877
  async pay(options) {
2803
2878
  this.limits.assert({ operation: "pay", amountUsd: options.maxPrice ?? 0, force: options.force });
2804
2879
  const result = await payWithX402({ signer: this._signer, client: this.client, options });
@@ -4355,6 +4430,7 @@ exports.preflightFail = preflightFail;
4355
4430
  exports.preflightPay = preflightPay;
4356
4431
  exports.preflightSend = preflightSend;
4357
4432
  exports.preflightSwap = preflightSwap;
4433
+ exports.probeX402 = probeX402;
4358
4434
  exports.putJobSpec = putJobSpec;
4359
4435
  exports.queryBalance = queryBalance;
4360
4436
  exports.queryHistory = queryHistory;