tenjin-cli 0.1.0-alpha.26 → 0.1.0-alpha.27

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 (110) hide show
  1. package/README.md +3 -3
  2. package/dist/{chunk-ALJRB7NG.js → chunk-2TYQD22Q.js} +8 -6
  3. package/dist/{chunk-ALJRB7NG.js.map → chunk-2TYQD22Q.js.map} +1 -1
  4. package/dist/{chunk-W36HL4TB.js → chunk-4L7KMA7P.js} +4 -4
  5. package/dist/{chunk-UDWGT4FX.js → chunk-5FGO6TYT.js} +13 -5
  6. package/dist/chunk-5FGO6TYT.js.map +1 -0
  7. package/dist/{chunk-5HS54CLI.js → chunk-5NEHH2E5.js} +3 -3
  8. package/dist/{chunk-Z7R2QDX2.js → chunk-64SE3QC5.js} +42 -7
  9. package/dist/chunk-64SE3QC5.js.map +1 -0
  10. package/dist/chunk-6ZSGER3A.js +52 -0
  11. package/dist/chunk-6ZSGER3A.js.map +1 -0
  12. package/dist/{chunk-QF4SSCQV.js → chunk-AWKQSKUL.js} +4 -3
  13. package/dist/chunk-AWKQSKUL.js.map +1 -0
  14. package/dist/{chunk-XMIVHQ35.js → chunk-B2L53TMK.js} +17 -2
  15. package/dist/{chunk-XMIVHQ35.js.map → chunk-B2L53TMK.js.map} +1 -1
  16. package/dist/{chunk-OZ3LWLCI.js → chunk-DATCR7AU.js} +3 -3
  17. package/dist/{chunk-65EJJVT3.js → chunk-DSNXKUXI.js} +2 -2
  18. package/dist/{chunk-HII5HOQV.js → chunk-G4AM2SOL.js} +5 -3
  19. package/dist/{chunk-HII5HOQV.js.map → chunk-G4AM2SOL.js.map} +1 -1
  20. package/dist/{chunk-OBPZ36HG.js → chunk-GU4GGKYP.js} +58 -5
  21. package/dist/chunk-GU4GGKYP.js.map +1 -0
  22. package/dist/{chunk-VNT3CQFV.js → chunk-H2L33M7F.js} +17 -13
  23. package/dist/{chunk-VNT3CQFV.js.map → chunk-H2L33M7F.js.map} +1 -1
  24. package/dist/{chunk-GHR4BTNJ.js → chunk-HC3QEZKT.js} +4 -4
  25. package/dist/chunk-HC3QEZKT.js.map +1 -0
  26. package/dist/{chunk-H4BOQLWW.js → chunk-MAQUL5BD.js} +2 -2
  27. package/dist/{chunk-4HAV6IFE.js → chunk-O7CUHHYU.js} +6 -6
  28. package/dist/{chunk-4HAV6IFE.js.map → chunk-O7CUHHYU.js.map} +1 -1
  29. package/dist/{chunk-5INS5ZZF.js → chunk-OHZYNZSD.js} +3 -3
  30. package/dist/{chunk-YHWBDCGS.js → chunk-PY7MQUKP.js} +20 -18
  31. package/dist/{chunk-YHWBDCGS.js.map → chunk-PY7MQUKP.js.map} +1 -1
  32. package/dist/{chunk-ZLD6MJVJ.js → chunk-S4SAZ7OD.js} +1 -1
  33. package/dist/chunk-S4SAZ7OD.js.map +1 -0
  34. package/dist/{chunk-WT7DHJNJ.js → chunk-SKQQOEWH.js} +4 -4
  35. package/dist/{chunk-XICKN3CH.js → chunk-VIOUZW7Z.js} +2 -46
  36. package/dist/chunk-VIOUZW7Z.js.map +1 -0
  37. package/dist/{chunk-YTM7OURD.js → chunk-VNNXAYJE.js} +2 -2
  38. package/dist/{chunk-5NUF4BHR.js → chunk-VXIBZ6W5.js} +3 -3
  39. package/dist/{chunk-6JIYGYRB.js → chunk-X7I343ZY.js} +2 -2
  40. package/dist/{chunk-DI7WHXOZ.js → chunk-XVYATBKD.js} +2 -2
  41. package/dist/{chunk-EJXIK6WY.js → chunk-YKM2ZTA2.js} +56 -22
  42. package/dist/chunk-YKM2ZTA2.js.map +1 -0
  43. package/dist/{chunk-YLCWI6ZR.js → chunk-YQOQ6XEI.js} +59 -18
  44. package/dist/chunk-YQOQ6XEI.js.map +1 -0
  45. package/dist/{cli-2U5JB7OQ.js → cli-6JNIPZQ6.js} +32 -31
  46. package/dist/{cli-2U5JB7OQ.js.map → cli-6JNIPZQ6.js.map} +1 -1
  47. package/dist/{config-44EGO636.js → config-G75YT6NC.js} +11 -10
  48. package/dist/{doctor-BD42BBEG.js → doctor-3GMDOW4Y.js} +28 -28
  49. package/dist/{doctor-BD42BBEG.js.map → doctor-3GMDOW4Y.js.map} +1 -1
  50. package/dist/{env-proxy-KEGEMWKX.js → env-proxy-XL4P73MZ.js} +2 -2
  51. package/dist/{fund-WQOOUESE.js → fund-3IPR5YRJ.js} +17 -15
  52. package/dist/{fund-WQOOUESE.js.map → fund-3IPR5YRJ.js.map} +1 -1
  53. package/dist/{hook-command-23LC5NRN.js → hook-command-ZXX4FT4N.js} +14 -14
  54. package/dist/index.js +6 -6
  55. package/dist/index.js.map +1 -1
  56. package/dist/{install-REPLHNU7.js → install-6OROTYHZ.js} +17 -17
  57. package/dist/{install-identity-4RDWTLJ2.js → install-identity-PM4AGFFX.js} +7 -6
  58. package/dist/{install-wallet-USHWL7AX.js → install-wallet-6756NOB5.js} +10 -9
  59. package/dist/{install-wallet-USHWL7AX.js.map → install-wallet-6756NOB5.js.map} +1 -1
  60. package/dist/{mcp-T5SYCLP7.js → mcp-33FAAZ7F.js} +503 -77
  61. package/dist/mcp-33FAAZ7F.js.map +1 -0
  62. package/dist/{pay-276DSSYG.js → pay-XOYR4PCH.js} +13 -12
  63. package/dist/{payments-TZYLJXK3.js → payments-UTQDBO7H.js} +8 -7
  64. package/dist/{payments-TZYLJXK3.js.map → payments-UTQDBO7H.js.map} +1 -1
  65. package/dist/{send-YHDKZPED.js → send-CVGNOQW3.js} +12 -10
  66. package/dist/{send-YHDKZPED.js.map → send-CVGNOQW3.js.map} +1 -1
  67. package/dist/{status-X2INT6VD.js → status-NACN4DGX.js} +10 -8
  68. package/dist/{status-X2INT6VD.js.map → status-NACN4DGX.js.map} +1 -1
  69. package/dist/{status-line-QKDJYZGV.js → status-line-3IQKGRUH.js} +6 -5
  70. package/dist/{status-line-QKDJYZGV.js.map → status-line-3IQKGRUH.js.map} +1 -1
  71. package/dist/{status-line-wiring-LW4HFRHB.js → status-line-wiring-QXBOOY2T.js} +4 -4
  72. package/dist/{uninstall-NVTGU7JD.js → uninstall-NYFKSYW4.js} +17 -17
  73. package/dist/{update-QXVH2DE7.js → update-RJDA5ZY3.js} +7 -16
  74. package/dist/update-RJDA5ZY3.js.map +1 -0
  75. package/dist/{wallet-CKKB23D5.js → wallet-B3FVHNTS.js} +10 -9
  76. package/docs/agent-permissions.md +5 -4
  77. package/package.json +3 -3
  78. package/dist/chunk-EJXIK6WY.js.map +0 -1
  79. package/dist/chunk-GHR4BTNJ.js.map +0 -1
  80. package/dist/chunk-OBPZ36HG.js.map +0 -1
  81. package/dist/chunk-PM2MOXJ3.js +0 -66
  82. package/dist/chunk-PM2MOXJ3.js.map +0 -1
  83. package/dist/chunk-QF4SSCQV.js.map +0 -1
  84. package/dist/chunk-UDWGT4FX.js.map +0 -1
  85. package/dist/chunk-XICKN3CH.js.map +0 -1
  86. package/dist/chunk-YLCWI6ZR.js.map +0 -1
  87. package/dist/chunk-Z7R2QDX2.js.map +0 -1
  88. package/dist/chunk-ZLD6MJVJ.js.map +0 -1
  89. package/dist/mcp-T5SYCLP7.js.map +0 -1
  90. package/dist/update-QXVH2DE7.js.map +0 -1
  91. /package/dist/{chunk-W36HL4TB.js.map → chunk-4L7KMA7P.js.map} +0 -0
  92. /package/dist/{chunk-5HS54CLI.js.map → chunk-5NEHH2E5.js.map} +0 -0
  93. /package/dist/{chunk-OZ3LWLCI.js.map → chunk-DATCR7AU.js.map} +0 -0
  94. /package/dist/{chunk-65EJJVT3.js.map → chunk-DSNXKUXI.js.map} +0 -0
  95. /package/dist/{chunk-H4BOQLWW.js.map → chunk-MAQUL5BD.js.map} +0 -0
  96. /package/dist/{chunk-5INS5ZZF.js.map → chunk-OHZYNZSD.js.map} +0 -0
  97. /package/dist/{chunk-WT7DHJNJ.js.map → chunk-SKQQOEWH.js.map} +0 -0
  98. /package/dist/{chunk-YTM7OURD.js.map → chunk-VNNXAYJE.js.map} +0 -0
  99. /package/dist/{chunk-5NUF4BHR.js.map → chunk-VXIBZ6W5.js.map} +0 -0
  100. /package/dist/{chunk-6JIYGYRB.js.map → chunk-X7I343ZY.js.map} +0 -0
  101. /package/dist/{chunk-DI7WHXOZ.js.map → chunk-XVYATBKD.js.map} +0 -0
  102. /package/dist/{config-44EGO636.js.map → config-G75YT6NC.js.map} +0 -0
  103. /package/dist/{env-proxy-KEGEMWKX.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
  104. /package/dist/{hook-command-23LC5NRN.js.map → hook-command-ZXX4FT4N.js.map} +0 -0
  105. /package/dist/{install-REPLHNU7.js.map → install-6OROTYHZ.js.map} +0 -0
  106. /package/dist/{install-identity-4RDWTLJ2.js.map → install-identity-PM4AGFFX.js.map} +0 -0
  107. /package/dist/{pay-276DSSYG.js.map → pay-XOYR4PCH.js.map} +0 -0
  108. /package/dist/{status-line-wiring-LW4HFRHB.js.map → status-line-wiring-QXBOOY2T.js.map} +0 -0
  109. /package/dist/{uninstall-NVTGU7JD.js.map → uninstall-NYFKSYW4.js.map} +0 -0
  110. /package/dist/{wallet-CKKB23D5.js.map → wallet-B3FVHNTS.js.map} +0 -0
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-EGELTSPU.js";
28
28
  import {
29
29
  USDC_ADDRESS
30
- } from "./chunk-XICKN3CH.js";
30
+ } from "./chunk-VIOUZW7Z.js";
31
31
 
32
32
  // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/op-stack/contracts.js
33
33
  var contracts = {
@@ -318,4 +318,4 @@ export {
318
318
  prepareUsdcSend,
319
319
  broadcastUsdcSend
320
320
  };
321
- //# sourceMappingURL=chunk-YTM7OURD.js.map
321
+ //# sourceMappingURL=chunk-VNNXAYJE.js.map
@@ -5,13 +5,13 @@ import {
5
5
  emptyLedger,
6
6
  readLedger,
7
7
  spentOf
8
- } from "./chunk-6JIYGYRB.js";
8
+ } from "./chunk-X7I343ZY.js";
9
9
  import {
10
10
  withFileLock
11
11
  } from "./chunk-MEFB5KHA.js";
12
12
  import {
13
13
  evaluateSpendPolicy
14
- } from "./chunk-XMIVHQ35.js";
14
+ } from "./chunk-B2L53TMK.js";
15
15
  import {
16
16
  writeFileAtomic
17
17
  } from "./chunk-JLEF5WHM.js";
@@ -189,4 +189,4 @@ export {
189
189
  createLocalSpendAuthorizer,
190
190
  releaseUnchargedExposure
191
191
  };
192
- //# sourceMappingURL=chunk-5NUF4BHR.js.map
192
+ //# sourceMappingURL=chunk-VXIBZ6W5.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-2I4QTOLB.js";
5
5
  import {
6
6
  external_exports
7
- } from "./chunk-XICKN3CH.js";
7
+ } from "./chunk-VIOUZW7Z.js";
8
8
  import {
9
9
  spendLedgerPath
10
10
  } from "./chunk-K6AXXYCG.js";
@@ -111,4 +111,4 @@ export {
111
111
  readLedger,
112
112
  readSpendSummary
113
113
  };
114
- //# sourceMappingURL=chunk-6JIYGYRB.js.map
114
+ //# sourceMappingURL=chunk-X7I343ZY.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-TGLKKLQG.js";
8
8
  import {
9
9
  package_default
10
- } from "./chunk-GHR4BTNJ.js";
10
+ } from "./chunk-HC3QEZKT.js";
11
11
  import {
12
12
  CliError,
13
13
  HARNESSES,
@@ -1785,4 +1785,4 @@ export {
1785
1785
  registeredHooks,
1786
1786
  writeHooks
1787
1787
  };
1788
- //# sourceMappingURL=chunk-DI7WHXOZ.js.map
1788
+ //# sourceMappingURL=chunk-XVYATBKD.js.map
@@ -59,15 +59,12 @@ import {
59
59
  } from "./chunk-TTNESUPQ.js";
60
60
  import {
61
61
  USDC_ADDRESS
62
- } from "./chunk-YTM7OURD.js";
62
+ } from "./chunk-VNNXAYJE.js";
63
63
  import {
64
64
  describeWallet,
65
65
  resolveSpendAuthorizer,
66
66
  resolveWalletProvider
67
- } from "./chunk-4HAV6IFE.js";
68
- import {
69
- sanitizeForTerminal
70
- } from "./chunk-UDWGT4FX.js";
67
+ } from "./chunk-O7CUHHYU.js";
71
68
  import {
72
69
  getAddress
73
70
  } from "./chunk-EGELTSPU.js";
@@ -77,17 +74,22 @@ import {
77
74
  import {
78
75
  fetchFailureToCliError,
79
76
  httpRequest
80
- } from "./chunk-5INS5ZZF.js";
77
+ } from "./chunk-OHZYNZSD.js";
78
+ import {
79
+ sanitizeForTerminal
80
+ } from "./chunk-5FGO6TYT.js";
81
81
  import {
82
82
  resolveContextSettings
83
- } from "./chunk-HII5HOQV.js";
83
+ } from "./chunk-G4AM2SOL.js";
84
84
  import {
85
- external_exports,
86
- isSameDeployment,
87
85
  parseUsdToAtomic,
88
- readUsdcBalanceWithFallback,
89
86
  toMoney
90
- } from "./chunk-XICKN3CH.js";
87
+ } from "./chunk-6ZSGER3A.js";
88
+ import {
89
+ external_exports,
90
+ isSameDeployment,
91
+ readUsdcBalanceWithFallback
92
+ } from "./chunk-VIOUZW7Z.js";
91
93
  import {
92
94
  CliError
93
95
  } from "./chunk-JLEF5WHM.js";
@@ -11821,8 +11823,7 @@ async function executePay(args, ctx, deps, warnings) {
11821
11823
  ctx,
11822
11824
  deps.provider !== void 0 ? { provider: deps.provider } : {}
11823
11825
  );
11824
- await describeWallet(provider);
11825
- const signer = await provider.getSigner();
11826
+ const signer = await openWallet(provider);
11826
11827
  openedSigner.current = signer;
11827
11828
  let effectiveChallenge = paymentRequired;
11828
11829
  let effectiveRequirement = requirement;
@@ -11995,17 +11996,19 @@ async function executePay(args, ctx, deps, warnings) {
11995
11996
  printBody: args.printBody === true
11996
11997
  });
11997
11998
  }
11999
+ const refusal = settlementRefusal(paid);
11998
12000
  throw new CliError(
11999
12001
  "PAYMENT_FAILED",
12000
- paid.status === 402 ? "Payment was not accepted by the endpoint." : `The endpoint answered ${paid.status} on the paid request; whether it settled is unknown.`,
12002
+ refusal !== void 0 ? `The endpoint did not settle the payment${refusal.reason !== void 0 ? `: ${refusal.reason.replace(/\.+$/, "")}` : ""}.` : paid.status === 402 ? "Payment was not accepted by the endpoint." : `The endpoint answered ${paid.status} on the paid request; whether it settled is unknown.`,
12001
12003
  {
12002
- fix: "The signed payment already left and is recorded as transmitted exposure; the endpoint may still settle it. Do not simply retry: each attempt signs a fresh authorization. Verify the endpoint (and this listing, if Bazaar) before paying again.",
12004
+ fix: refusal !== void 0 ? "The seller reported that nothing settled, but the signed authorization stays valid until it expires, so it is recorded as transmitted exposure. Do not simply retry: each attempt signs a fresh authorization. Use a different service for this." : "The signed payment already left and is recorded as transmitted exposure; the endpoint may still settle it. Do not simply retry: each attempt signs a fresh authorization. Verify the endpoint (and this listing, if Bazaar) before paying again.",
12003
12005
  // The amount rides on the failure so a caller can report what is at risk
12004
12006
  // rather than a zero. Settlement is unknown by construction here.
12005
12007
  details: {
12006
12008
  status: paid.status,
12007
12009
  body: paid.json,
12008
12010
  ...providerError(paid.text),
12011
+ ...refusal?.reason !== void 0 ? { settlementError: refusal.reason } : {},
12009
12012
  amountAtomic: payment.amountAtomic.toString(),
12010
12013
  settlement: "unknown",
12011
12014
  ...payment.authorization !== void 0 ? { authorization: payment.authorization } : {}
@@ -12138,14 +12141,15 @@ function providerMessage(body) {
12138
12141
  }
12139
12142
  var PROVIDER_ERROR_CHARS = 500;
12140
12143
  function providerError(text) {
12144
+ const line = sellerLine(text);
12145
+ return line.length > 0 ? { providerError: line } : {};
12146
+ }
12147
+ function sellerLine(text) {
12141
12148
  const flat = sanitizeForTerminal(
12142
12149
  mask(text.slice(0, PROVIDER_ERROR_CHARS * 8)).replace(/\s+/g, " ")
12143
12150
  ).trim();
12144
- if (flat.length === 0) return {};
12145
12151
  const chars = Array.from(flat);
12146
- return {
12147
- providerError: chars.length <= PROVIDER_ERROR_CHARS ? flat : `${chars.slice(0, PROVIDER_ERROR_CHARS).join("")}\u2026`
12148
- };
12152
+ return chars.length <= PROVIDER_ERROR_CHARS ? flat : `${chars.slice(0, PROVIDER_ERROR_CHARS).join("")}\u2026`;
12149
12153
  }
12150
12154
  function noMatchingEntry(challenge, terms) {
12151
12155
  if (terms === void 0 || terms.network === void 0 && terms.asset === void 0) {
@@ -12271,16 +12275,45 @@ function deliver(url, lane, res, opts) {
12271
12275
  };
12272
12276
  }
12273
12277
  function settlementTx(res) {
12278
+ const tx = paymentResponse(res)?.transaction;
12279
+ return typeof tx === "string" && /^0x[0-9a-fA-F]{64}$/.test(tx) ? tx : void 0;
12280
+ }
12281
+ function settlementRefusal(res) {
12282
+ const settle = paymentResponse(res);
12283
+ if (settle?.success !== false) return void 0;
12284
+ const said = [settle.errorReason, settle.errorMessage].find(
12285
+ (value) => typeof value === "string" && value.trim().length > 0
12286
+ );
12287
+ const reason = said !== void 0 ? sellerLine(said) : "";
12288
+ return reason.length > 0 ? { reason } : {};
12289
+ }
12290
+ function paymentResponse(res) {
12274
12291
  const header = res.header(PAYMENT_RESPONSE_HEADER) ?? res.header(PAYMENT_RESPONSE_HEADER_V1);
12275
12292
  if (header === void 0) return void 0;
12276
12293
  try {
12277
12294
  const settle = decodePaymentResponseHeader(header);
12278
- const tx = settle.transaction;
12279
- return typeof tx === "string" && /^0x[0-9a-fA-F]{64}$/.test(tx) ? tx : void 0;
12295
+ return typeof settle === "object" && settle !== null ? settle : void 0;
12280
12296
  } catch {
12281
12297
  return void 0;
12282
12298
  }
12283
12299
  }
12300
+ async function openWallet(provider) {
12301
+ try {
12302
+ await describeWallet(provider);
12303
+ return await provider.getSigner();
12304
+ } catch (err) {
12305
+ if (!(err instanceof CliError)) throw err;
12306
+ throw new CliError(err.code, err.message, {
12307
+ exitCode: err.exitCode,
12308
+ ...err.fix !== void 0 ? { fix: err.fix } : {},
12309
+ details: {
12310
+ ...typeof err.details === "object" && err.details !== null ? err.details : {},
12311
+ walletUnavailable: true
12312
+ },
12313
+ cause: err
12314
+ });
12315
+ }
12316
+ }
12284
12317
  function signerOrThrow(held) {
12285
12318
  if (held.current === void 0) {
12286
12319
  throw new CliError("INTERNAL", "The payment was built before the wallet was opened.");
@@ -12295,6 +12328,7 @@ export {
12295
12328
  inputProblems,
12296
12329
  assertResultSchema,
12297
12330
  projectBody,
12331
+ policyFix,
12298
12332
  x402Client,
12299
12333
  BatchSettlementEvmScheme,
12300
12334
  toClientEvmSigner,
@@ -12304,4 +12338,4 @@ export {
12304
12338
  paidLegTimeoutMs,
12305
12339
  settlementTx
12306
12340
  };
12307
- //# sourceMappingURL=chunk-EJXIK6WY.js.map
12341
+ //# sourceMappingURL=chunk-YKM2ZTA2.js.map