tenjin-cli 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (219) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +175 -256
  3. package/dist/{_esm-FEASBWRP.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-2AQO4YDI.js +291 -0
  7. package/dist/chunk-2AQO4YDI.js.map +1 -0
  8. package/dist/chunk-2QYORQBF.js +55 -0
  9. package/dist/chunk-2QYORQBF.js.map +1 -0
  10. package/dist/chunk-3EUTWC2B.js +194 -0
  11. package/dist/chunk-3EUTWC2B.js.map +1 -0
  12. package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
  13. package/dist/chunk-7QKHZQKW.js +1680 -0
  14. package/dist/chunk-7QKHZQKW.js.map +1 -0
  15. package/dist/chunk-A36LQPHV.js +29 -0
  16. package/dist/chunk-A36LQPHV.js.map +1 -0
  17. package/dist/{chunk-XJIW7USF.js → chunk-AQRUD5GQ.js} +115 -11
  18. package/dist/chunk-AQRUD5GQ.js.map +1 -0
  19. package/dist/{chunk-UGX7YPX2.js → chunk-AWQPGIR6.js} +7 -9
  20. package/dist/{chunk-UGX7YPX2.js.map → chunk-AWQPGIR6.js.map} +1 -1
  21. package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
  22. package/dist/chunk-C363JZN2.js +127 -0
  23. package/dist/chunk-C363JZN2.js.map +1 -0
  24. package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
  25. package/dist/chunk-ETW2ASBP.js +10562 -0
  26. package/dist/chunk-ETW2ASBP.js.map +1 -0
  27. package/dist/chunk-GHTPYKDT.js +112 -0
  28. package/dist/chunk-GHTPYKDT.js.map +1 -0
  29. package/dist/{chunk-CYOF7ROH.js → chunk-HPWO4O6S.js} +3 -3
  30. package/dist/chunk-IOB7URFH.js +242 -0
  31. package/dist/chunk-IOB7URFH.js.map +1 -0
  32. package/dist/chunk-IOIHYOU4.js +1784 -0
  33. package/dist/chunk-IOIHYOU4.js.map +1 -0
  34. package/dist/chunk-JLEF5WHM.js +132 -0
  35. package/dist/chunk-JLEF5WHM.js.map +1 -0
  36. package/dist/chunk-JN7TMXVF.js +172 -0
  37. package/dist/chunk-JN7TMXVF.js.map +1 -0
  38. package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
  39. package/dist/chunk-K6AXXYCG.js +109 -0
  40. package/dist/chunk-K6AXXYCG.js.map +1 -0
  41. package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
  42. package/dist/chunk-LAIZ2AQA.js +107 -0
  43. package/dist/chunk-LAIZ2AQA.js.map +1 -0
  44. package/dist/chunk-LHHMV4GU.js +27 -0
  45. package/dist/chunk-LHHMV4GU.js.map +1 -0
  46. package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
  47. package/dist/chunk-MEFB5KHA.js.map +1 -0
  48. package/dist/{chunk-NCE5NSN6.js → chunk-N35E6CM2.js} +140 -10
  49. package/dist/chunk-N35E6CM2.js.map +1 -0
  50. package/dist/chunk-N4DJEQAF.js +190 -0
  51. package/dist/chunk-N4DJEQAF.js.map +1 -0
  52. package/dist/chunk-O2JYBOUO.js +47 -0
  53. package/dist/chunk-O2JYBOUO.js.map +1 -0
  54. package/dist/chunk-OSUD6YZZ.js +451 -0
  55. package/dist/chunk-OSUD6YZZ.js.map +1 -0
  56. package/dist/chunk-OTPEH3AH.js +926 -0
  57. package/dist/chunk-OTPEH3AH.js.map +1 -0
  58. package/dist/chunk-PJEG2JIJ.js +242 -0
  59. package/dist/chunk-PJEG2JIJ.js.map +1 -0
  60. package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
  61. package/dist/chunk-QF4SSCQV.js +377 -0
  62. package/dist/chunk-QF4SSCQV.js.map +1 -0
  63. package/dist/chunk-QHILSA6G.js +82 -0
  64. package/dist/chunk-QHILSA6G.js.map +1 -0
  65. package/dist/chunk-QRFONFRW.js +231 -0
  66. package/dist/chunk-QRFONFRW.js.map +1 -0
  67. package/dist/{chunk-N62ROTMC.js → chunk-RCJQARZF.js} +14 -10
  68. package/dist/chunk-RCJQARZF.js.map +1 -0
  69. package/dist/{chunk-S3IGX57D.js → chunk-RGVOODF4.js} +7703 -7475
  70. package/dist/chunk-RGVOODF4.js.map +1 -0
  71. package/dist/chunk-S2NRVRPF.js +171 -0
  72. package/dist/chunk-S2NRVRPF.js.map +1 -0
  73. package/dist/chunk-SRVDXR6B.js +337 -0
  74. package/dist/chunk-SRVDXR6B.js.map +1 -0
  75. package/dist/chunk-TGLKKLQG.js +11 -0
  76. package/dist/chunk-TGLKKLQG.js.map +1 -0
  77. package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
  78. package/dist/chunk-U2ATFMKZ.js +164 -0
  79. package/dist/chunk-U2ATFMKZ.js.map +1 -0
  80. package/dist/chunk-UY2TOI3B.js +208 -0
  81. package/dist/chunk-UY2TOI3B.js.map +1 -0
  82. package/dist/{chunk-OYMYCW7J.js → chunk-W3LVZ2EN.js} +605 -97
  83. package/dist/chunk-W3LVZ2EN.js.map +1 -0
  84. package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
  85. package/dist/{chunk-Z6MFJV5Z.js → chunk-YVODPFTL.js} +851 -500
  86. package/dist/chunk-YVODPFTL.js.map +1 -0
  87. package/dist/{cli-4NNBEQYH.js → cli-7KJ4QLUU.js} +367 -216
  88. package/dist/cli-7KJ4QLUU.js.map +1 -0
  89. package/dist/config-MSN6H4MD.js +41 -0
  90. package/dist/dist-3LOO6M4U.js +2842 -0
  91. package/dist/dist-3LOO6M4U.js.map +1 -0
  92. package/dist/doctor-ITUCKN6C.js +453 -0
  93. package/dist/doctor-ITUCKN6C.js.map +1 -0
  94. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  95. package/dist/fund-XPB4IIG5.js +298 -0
  96. package/dist/fund-XPB4IIG5.js.map +1 -0
  97. package/dist/hook-command-VVV2Q23L.js +1265 -0
  98. package/dist/hook-command-VVV2Q23L.js.map +1 -0
  99. package/dist/index.js +11 -3
  100. package/dist/index.js.map +1 -1
  101. package/dist/install-OSJRM2ME.js +63 -0
  102. package/dist/install-identity-YIWKQOUD.js +27 -0
  103. package/dist/install-wallet-BWJO2SUC.js +107 -0
  104. package/dist/install-wallet-BWJO2SUC.js.map +1 -0
  105. package/dist/mcp-KE5YKPS2.js +10174 -0
  106. package/dist/mcp-KE5YKPS2.js.map +1 -0
  107. package/dist/paths-MUXHUOCM.js +57 -0
  108. package/dist/pay-MUV2U232.js +46 -0
  109. package/dist/payments-4D27K4L2.js +48 -0
  110. package/dist/payments-4D27K4L2.js.map +1 -0
  111. package/dist/redact-6W23GGJC.js +15 -0
  112. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
  113. package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
  114. package/dist/send-BXHFKDBF.js +225 -0
  115. package/dist/send-BXHFKDBF.js.map +1 -0
  116. package/dist/status-3Z3YPRSE.js +71 -0
  117. package/dist/status-3Z3YPRSE.js.map +1 -0
  118. package/dist/status-line-CKRMGZ3Q.js +87 -0
  119. package/dist/status-line-CKRMGZ3Q.js.map +1 -0
  120. package/dist/status-line-wiring-GECLIIBT.js +29 -0
  121. package/dist/status-line-wiring-GECLIIBT.js.map +1 -0
  122. package/dist/tenjin-daemon.mjs +20598 -0
  123. package/dist/tenjin-shim.mjs +251 -0
  124. package/dist/tenjin-vitest-reporter.mjs +49 -0
  125. package/dist/uninstall-BZTVWJ7W.js +165 -0
  126. package/dist/uninstall-BZTVWJ7W.js.map +1 -0
  127. package/dist/update-IQQTEOI5.js +433 -0
  128. package/dist/update-IQQTEOI5.js.map +1 -0
  129. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  130. package/dist/viemAdapter-By13KInL-X2VY6CY3.js.map +1 -0
  131. package/dist/wallet-UFXQ57TZ.js +33 -0
  132. package/dist/wallet-UFXQ57TZ.js.map +1 -0
  133. package/dist/wallet-kdf-worker.mjs +980 -0
  134. package/docs/agent-permissions.md +141 -0
  135. package/docs/safety-model.md +70 -0
  136. package/package.json +14 -9
  137. package/LICENSE +0 -21
  138. package/dist/buy-U35DQ6XM.js +0 -1598
  139. package/dist/buy-U35DQ6XM.js.map +0 -1
  140. package/dist/candidate-RLYCQMF5.js +0 -127
  141. package/dist/candidate-RLYCQMF5.js.map +0 -1
  142. package/dist/chunk-27ONARHV.js +0 -171
  143. package/dist/chunk-27ONARHV.js.map +0 -1
  144. package/dist/chunk-3OV7E5G5.js +0 -18
  145. package/dist/chunk-3OV7E5G5.js.map +0 -1
  146. package/dist/chunk-7KUW4MJD.js +0 -59
  147. package/dist/chunk-7KUW4MJD.js.map +0 -1
  148. package/dist/chunk-7PHSZKQS.js +0 -333
  149. package/dist/chunk-7PHSZKQS.js.map +0 -1
  150. package/dist/chunk-IYLHQMT5.js +0 -211
  151. package/dist/chunk-IYLHQMT5.js.map +0 -1
  152. package/dist/chunk-JPHG2JW3.js +0 -96
  153. package/dist/chunk-JPHG2JW3.js.map +0 -1
  154. package/dist/chunk-MUBUQVC3.js +0 -67
  155. package/dist/chunk-MUBUQVC3.js.map +0 -1
  156. package/dist/chunk-N62ROTMC.js.map +0 -1
  157. package/dist/chunk-NCE5NSN6.js.map +0 -1
  158. package/dist/chunk-OYMYCW7J.js.map +0 -1
  159. package/dist/chunk-QNP7H47L.js +0 -152
  160. package/dist/chunk-QNP7H47L.js.map +0 -1
  161. package/dist/chunk-RY4XKNV3.js +0 -140
  162. package/dist/chunk-RY4XKNV3.js.map +0 -1
  163. package/dist/chunk-S3IGX57D.js.map +0 -1
  164. package/dist/chunk-TFGSOPWR.js +0 -261
  165. package/dist/chunk-TFGSOPWR.js.map +0 -1
  166. package/dist/chunk-TLCMMYLY.js +0 -126
  167. package/dist/chunk-TLCMMYLY.js.map +0 -1
  168. package/dist/chunk-UO22YNY4.js +0 -69
  169. package/dist/chunk-UO22YNY4.js.map +0 -1
  170. package/dist/chunk-UPIEAMGH.js +0 -160
  171. package/dist/chunk-UPIEAMGH.js.map +0 -1
  172. package/dist/chunk-XJIW7USF.js.map +0 -1
  173. package/dist/chunk-YBMMV4Y4.js.map +0 -1
  174. package/dist/chunk-YIYQ2ZNT.js +0 -286
  175. package/dist/chunk-YIYQ2ZNT.js.map +0 -1
  176. package/dist/chunk-YN5SHIXQ.js +0 -126
  177. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  178. package/dist/chunk-Z52RA3NC.js +0 -137
  179. package/dist/chunk-Z52RA3NC.js.map +0 -1
  180. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  181. package/dist/cli-4NNBEQYH.js.map +0 -1
  182. package/dist/config-2VSXWWHK.js +0 -21
  183. package/dist/doctor-JJPNIBYH.js +0 -20
  184. package/dist/inspect-JGYJWFDP.js +0 -96
  185. package/dist/inspect-JGYJWFDP.js.map +0 -1
  186. package/dist/install-ZQRMSRGW.js +0 -378
  187. package/dist/install-ZQRMSRGW.js.map +0 -1
  188. package/dist/lookup-WYVTOMVY.js +0 -113
  189. package/dist/lookup-WYVTOMVY.js.map +0 -1
  190. package/dist/outcome-HKKT6QIA.js +0 -66
  191. package/dist/outcome-HKKT6QIA.js.map +0 -1
  192. package/dist/publish-D76B3MBK.js +0 -1480
  193. package/dist/publish-D76B3MBK.js.map +0 -1
  194. package/dist/usdc-JIAJW4SV.js +0 -22
  195. package/dist/wallet-6QKS6UHW.js +0 -179
  196. package/dist/wallet-6QKS6UHW.js.map +0 -1
  197. package/dist/wallet-PA54CRBL.js +0 -30
  198. package/skills/tenjin/SKILL.md +0 -199
  199. package/skills/tenjin-publish/SKILL.md +0 -96
  200. package/skills/tenjin-search/SKILL.md +0 -122
  201. /package/dist/{_esm-FEASBWRP.js.map → _esm-CE7KNONL.js.map} +0 -0
  202. /package/dist/{ccip-NQXCEK2U.js.map → ccip-7RMRLAGV.js.map} +0 -0
  203. /package/dist/{ccip-XR5NE5QK.js.map → ccip-NLCSCHKI.js.map} +0 -0
  204. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
  205. /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
  206. /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
  207. /package/dist/{chunk-CYOF7ROH.js.map → chunk-HPWO4O6S.js.map} +0 -0
  208. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  209. /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
  210. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
  211. /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
  212. /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
  213. /package/dist/{config-2VSXWWHK.js.map → config-MSN6H4MD.js.map} +0 -0
  214. /package/dist/{doctor-JJPNIBYH.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  215. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → install-OSJRM2ME.js.map} +0 -0
  216. /package/dist/{secp256k1-N3ZHU7LB.js.map → install-identity-YIWKQOUD.js.map} +0 -0
  217. /package/dist/{usdc-JIAJW4SV.js.map → paths-MUXHUOCM.js.map} +0 -0
  218. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → pay-MUV2U232.js.map} +0 -0
  219. /package/dist/{wallet-PA54CRBL.js.map → redact-6W23GGJC.js.map} +0 -0
@@ -4,10 +4,10 @@ import {
4
4
  offchainLookup,
5
5
  offchainLookupAbiItem,
6
6
  offchainLookupSignature
7
- } from "./chunk-RRN3YTK7.js";
8
- import "./chunk-HIVZG55D.js";
7
+ } from "./chunk-TTNESUPQ.js";
8
+ import "./chunk-KG3D7FIF.js";
9
9
  import "./chunk-RBJPAZFI.js";
10
- import "./chunk-5CLSD5YN.js";
10
+ import "./chunk-BPMWXTFX.js";
11
11
  import "./chunk-ZXTAQYNA.js";
12
12
  export {
13
13
  ccipRequest,
@@ -15,4 +15,4 @@ export {
15
15
  offchainLookupAbiItem,
16
16
  offchainLookupSignature
17
17
  };
18
- //# sourceMappingURL=ccip-NQXCEK2U.js.map
18
+ //# sourceMappingURL=ccip-7RMRLAGV.js.map
@@ -4,11 +4,11 @@ import {
4
4
  offchainLookup,
5
5
  offchainLookupAbiItem,
6
6
  offchainLookupSignature
7
- } from "./chunk-ZMHYXMO6.js";
8
- import "./chunk-YALGASEU.js";
9
- import "./chunk-HIVZG55D.js";
7
+ } from "./chunk-5IEP5EGE.js";
8
+ import "./chunk-EGELTSPU.js";
9
+ import "./chunk-KG3D7FIF.js";
10
10
  import "./chunk-RBJPAZFI.js";
11
- import "./chunk-5CLSD5YN.js";
11
+ import "./chunk-BPMWXTFX.js";
12
12
  import "./chunk-ZXTAQYNA.js";
13
13
  export {
14
14
  ccipRequest,
@@ -16,4 +16,4 @@ export {
16
16
  offchainLookupAbiItem,
17
17
  offchainLookupSignature
18
18
  };
19
- //# sourceMappingURL=ccip-XR5NE5QK.js.map
19
+ //# sourceMappingURL=ccip-NLCSCHKI.js.map
@@ -0,0 +1,291 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ PRODUCTION_ORIGIN
4
+ } from "./chunk-W3LVZ2EN.js";
5
+ import {
6
+ package_default
7
+ } from "./chunk-RCJQARZF.js";
8
+ import {
9
+ CliError
10
+ } from "./chunk-JLEF5WHM.js";
11
+
12
+ // src/lib/client-meta.ts
13
+ var TENJIN_PRODUCT = `tenjin-cli/${package_default.version}`;
14
+ var TENJIN_PRODUCT_NAME = "tenjin-cli";
15
+ var WEBSEARCH_HOOK_PRODUCT_NAME = "tenjin-websearch-hook";
16
+ var WEBSEARCH_HOOK_PRODUCT = `${WEBSEARCH_HOOK_PRODUCT_NAME}/${package_default.version}`;
17
+ var OWN_PRODUCT_NAMES = [TENJIN_PRODUCT_NAME, WEBSEARCH_HOOK_PRODUCT_NAME];
18
+ var TENJIN_COMMENT = `(+${PRODUCTION_ORIGIN})`;
19
+ var TENJIN_USER_AGENT = `${TENJIN_PRODUCT} ${TENJIN_COMMENT}`;
20
+ var WEBSEARCH_HOOK_USER_AGENT = `${WEBSEARCH_HOOK_PRODUCT} ${TENJIN_COMMENT}`;
21
+ var CALLER_USER_AGENT_ENV = "TENJIN_CALLER_USER_AGENT";
22
+ var USER_AGENT_MAX_LENGTH = 512;
23
+ var PRODUCT_RE = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:\/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?$/;
24
+ var PRINTABLE_ASCII_RE = /^[\x20-\x7e]*$/;
25
+ function composeUserAgent(input = {}) {
26
+ const product = input.product ?? TENJIN_PRODUCT;
27
+ const alone = `${product} ${TENJIN_COMMENT}`;
28
+ const raw = input.caller ?? (input.env ?? process.env)[CALLER_USER_AGENT_ENV];
29
+ const products = callerProducts(raw);
30
+ if (products.length === 0) return alone;
31
+ const composed = `${product} ${products.join(" ")} ${TENJIN_COMMENT}`;
32
+ return composed.length <= USER_AGENT_MAX_LENGTH ? composed : alone;
33
+ }
34
+ function callerProducts(raw) {
35
+ if (raw === void 0 || !PRINTABLE_ASCII_RE.test(raw)) return [];
36
+ const tokens = raw.split(" ").filter((token) => token.length > 0 && !isOwnIdentity(token));
37
+ return tokens.every((token) => PRODUCT_RE.test(token)) ? tokens : [];
38
+ }
39
+ function isOwnIdentity(token) {
40
+ const lower = token.toLowerCase();
41
+ if (lower === TENJIN_COMMENT.toLowerCase()) return true;
42
+ return OWN_PRODUCT_NAMES.some((name) => {
43
+ const own = name.toLowerCase();
44
+ return lower === own || lower.startsWith(`${own}/`);
45
+ });
46
+ }
47
+
48
+ // src/lib/http.ts
49
+ var SHELF_BYPASS_HEADER = "x-vercel-protection-bypass";
50
+ function shelfBypassHeaders(url, bypass) {
51
+ if (bypass === void 0 || bypass.secret.length === 0) return {};
52
+ let origin;
53
+ try {
54
+ origin = new URL(url).origin;
55
+ } catch {
56
+ return {};
57
+ }
58
+ if (origin !== bypass.origin) return {};
59
+ return { [SHELF_BYPASS_HEADER]: bypass.secret };
60
+ }
61
+ function carriesBypassKey(headers) {
62
+ return Object.keys(headers).some((name) => name.toLowerCase() === SHELF_BYPASS_HEADER);
63
+ }
64
+ var INSTALL_ID_HEADER = "tenjin-install-id";
65
+ var tenjinIdentity;
66
+ function setTenjinIdentity(identity) {
67
+ tenjinIdentity = identity;
68
+ }
69
+ async function tenjinIdentityHeaders(url) {
70
+ const identity = tenjinIdentity;
71
+ if (identity === void 0) return {};
72
+ try {
73
+ if (!(await identity.origins()).includes(new URL(url).origin)) return {};
74
+ const id = await identity.installId();
75
+ return id !== void 0 ? { [INSTALL_ID_HEADER]: id } : {};
76
+ } catch {
77
+ return {};
78
+ }
79
+ }
80
+ function applyUserAgent(headers, callerUserAgent) {
81
+ headers.set("user-agent", composeUserAgent({ caller: callerUserAgent }));
82
+ return headers;
83
+ }
84
+ var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set([
85
+ "sign-in-with-x",
86
+ "payment-signature",
87
+ "x-payment",
88
+ "tenjin-session-delegation"
89
+ ]);
90
+ function carriesSignedMaterial(headers) {
91
+ return Object.keys(headers).some((name) => CREDENTIAL_HEADERS.has(name.toLowerCase()));
92
+ }
93
+ function timeoutFailure(url, timeoutMs) {
94
+ return {
95
+ ok: false,
96
+ kind: "timeout",
97
+ message: `Request to ${url} timed out after ${timeoutMs}ms`
98
+ };
99
+ }
100
+ var MAX_BINARY_BODY_BYTES = 200 * 1024 * 1024;
101
+ async function readCapped(res, max) {
102
+ const declared = Number(res.headers.get("content-length") ?? "0");
103
+ if (Number.isFinite(declared) && declared > max) {
104
+ await res.body?.cancel().catch(() => void 0);
105
+ return null;
106
+ }
107
+ if (res.body === null) return new Uint8Array();
108
+ const reader = res.body.getReader();
109
+ const chunks = [];
110
+ let size = 0;
111
+ for (; ; ) {
112
+ const { done, value } = await reader.read();
113
+ if (done) break;
114
+ size += value.byteLength;
115
+ if (size > max) {
116
+ await reader.cancel().catch(() => void 0);
117
+ return null;
118
+ }
119
+ chunks.push(value);
120
+ }
121
+ return new Uint8Array(Buffer.concat(chunks));
122
+ }
123
+ function isBinaryContentType(contentType) {
124
+ const type = (contentType ?? "").split(";")[0].trim().toLowerCase();
125
+ if (type.length === 0) return false;
126
+ if (type.startsWith("text/")) return false;
127
+ return !/(?:json|xml|javascript|ecmascript|yaml|x-www-form-urlencoded)/.test(type);
128
+ }
129
+ function prepareRequest(url, opts) {
130
+ try {
131
+ let body;
132
+ const merged = new Headers({ ...opts.headers, ...shelfBypassHeaders(url, opts.bypass) });
133
+ if (opts.jsonBody !== void 0) {
134
+ body = JSON.stringify(opts.jsonBody);
135
+ merged.set("content-type", "application/json");
136
+ } else if (opts.rawBody !== void 0) {
137
+ body = opts.rawBody;
138
+ }
139
+ const wantsAccept = opts.method === "POST" || opts.method === "PUT" || body !== void 0;
140
+ if (wantsAccept && !merged.has("accept")) merged.set("accept", "application/json");
141
+ const headers = Object.fromEntries(applyUserAgent(merged, opts.callerUserAgent).entries());
142
+ const signed = carriesSignedMaterial(headers);
143
+ const bypassed = carriesBypassKey(headers);
144
+ return {
145
+ ok: true,
146
+ headers,
147
+ body,
148
+ signed,
149
+ bypassed,
150
+ pinned: signed || bypassed || opts.blockRedirects === true
151
+ };
152
+ } catch (err) {
153
+ return {
154
+ ok: false,
155
+ kind: "network",
156
+ message: `Request to ${url} failed: ${errorMessage(err)}`
157
+ };
158
+ }
159
+ }
160
+ async function httpRequest(url, opts) {
161
+ const doFetch = opts.fetchImpl ?? fetch;
162
+ const controller = new AbortController();
163
+ let timedOut = false;
164
+ const timer = setTimeout(() => {
165
+ timedOut = true;
166
+ controller.abort();
167
+ }, opts.timeoutMs);
168
+ const signal = opts.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, opts.signal]);
169
+ try {
170
+ const prepared = prepareRequest(url, opts);
171
+ if (!prepared.ok) return prepared;
172
+ const { headers, body, signed, bypassed, pinned } = prepared;
173
+ let res;
174
+ try {
175
+ res = await doFetch(url, {
176
+ method: opts.method ?? "GET",
177
+ headers: { ...headers, ...await tenjinIdentityHeaders(url) },
178
+ body,
179
+ signal,
180
+ ...pinned ? { redirect: "manual" } : {}
181
+ });
182
+ } catch (err) {
183
+ if (timedOut) return timeoutFailure(url, opts.timeoutMs);
184
+ if (isHeaderOverflow(err)) return oversizedHeaderFailure(url);
185
+ return {
186
+ ok: false,
187
+ kind: "network",
188
+ message: `Request to ${url} failed: ${errorMessage(err)}`
189
+ };
190
+ }
191
+ const requestId = res.headers.get("x-request-id") ?? void 0;
192
+ if (pinned && res.status >= 300 && res.status < 400) {
193
+ return {
194
+ ok: false,
195
+ kind: "blocked-redirect",
196
+ status: res.status,
197
+ ...requestId !== void 0 ? { requestId } : {},
198
+ message: signed ? `Request to ${url} was redirected (${res.status}) while carrying a signed header; refusing to follow it, because the signature is bound to the configured origin.` : bypassed ? `Request to ${url} was redirected (${res.status}) while carrying the team shelf's bypass key; refusing to follow it, because the key opens only the configured origin.` : `Request to ${url} was redirected (${res.status}); refusing to follow it, because the response must come from the configured origin.`
199
+ };
200
+ }
201
+ let text;
202
+ let bytes;
203
+ try {
204
+ if (opts.binaryBody === true && isBinaryContentType(res.headers.get("content-type") ?? "")) {
205
+ const read = await readCapped(res, opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES);
206
+ if (read === null) {
207
+ return {
208
+ ok: false,
209
+ kind: "network",
210
+ status: res.status,
211
+ ...requestId !== void 0 ? { requestId } : {},
212
+ message: `Request to ${url} returned a file over the ${Math.round((opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES) / 1048576)} MB cap; it was not kept.`
213
+ };
214
+ }
215
+ bytes = read;
216
+ text = "";
217
+ } else {
218
+ text = await res.text();
219
+ }
220
+ } catch (err) {
221
+ if (timedOut) return timeoutFailure(url, opts.timeoutMs);
222
+ return {
223
+ ok: false,
224
+ kind: "network",
225
+ status: res.status,
226
+ ...requestId !== void 0 ? { requestId } : {},
227
+ message: `Request to ${url} failed while reading the response body: ${errorMessage(err)}`
228
+ };
229
+ }
230
+ let json;
231
+ if (text.length > 0) {
232
+ try {
233
+ json = JSON.parse(text);
234
+ } catch {
235
+ json = void 0;
236
+ }
237
+ }
238
+ return {
239
+ ok: true,
240
+ status: res.status,
241
+ header: (name) => res.headers.get(name) ?? void 0,
242
+ json,
243
+ text,
244
+ ...bytes !== void 0 ? { bytes } : {},
245
+ ...requestId !== void 0 ? { requestId } : {}
246
+ };
247
+ } finally {
248
+ clearTimeout(timer);
249
+ }
250
+ }
251
+ function fetchFailureToCliError(failure, opts = {}) {
252
+ const code = failure.kind === "network" || failure.kind === "timeout" ? "NETWORK_ERROR" : failure.kind === "invalid-json" ? "CONTRACT_MISMATCH" : failure.kind === "oversized-header" ? "CHALLENGE_TOO_LARGE" : "API_UNREACHABLE";
253
+ const fix = opts.fix ?? (failure.kind === "oversized-header" ? "Raising `--max-http-header-size` on the node process that runs this CLI would let the header be read; that is an operator decision, not a default this build changes." : void 0);
254
+ return new CliError(code, failure.message, {
255
+ ...fix !== void 0 ? { fix } : {},
256
+ ...opts.details !== void 0 ? { details: opts.details } : {}
257
+ });
258
+ }
259
+ function errorMessage(err) {
260
+ return err instanceof Error ? err.message : String(err);
261
+ }
262
+ function isHeaderOverflow(err) {
263
+ const seen = [err, err?.cause];
264
+ return seen.some((candidate) => {
265
+ if (candidate === null || typeof candidate !== "object") return false;
266
+ const code = candidate.code;
267
+ if (code === "UND_ERR_HEADERS_OVERFLOW" || code === "HPE_HEADER_OVERFLOW") return true;
268
+ const message = candidate.message;
269
+ return typeof message === "string" && /headers overflow|header overflow/i.test(message);
270
+ });
271
+ }
272
+ function oversizedHeaderFailure(url) {
273
+ let origin = url;
274
+ try {
275
+ origin = new URL(url).origin;
276
+ } catch {
277
+ }
278
+ return {
279
+ ok: false,
280
+ kind: "oversized-header",
281
+ message: `${origin} answered with a response header block larger than this process will read. An x402 challenge travels in a header, and a seller that embeds its whole output schema in one can exceed the limit, so the response could not be read.`
282
+ };
283
+ }
284
+
285
+ export {
286
+ composeUserAgent,
287
+ setTenjinIdentity,
288
+ httpRequest,
289
+ fetchFailureToCliError
290
+ };
291
+ //# sourceMappingURL=chunk-2AQO4YDI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/client-meta.ts","../src/lib/http.ts"],"sourcesContent":["import pkg from '../../package.json';\nimport { PRODUCTION_ORIGIN } from './production-origin';\n\n/**\n * The RFC 9110 product token naming this CLI. It leads every User-Agent the\n * shared transport sends, because the server's `parseUserAgentProduct()` (tenjin\n * PR #544) attributes on the FIRST product only and the CLI is the user agent\n * that constructed and sent the request.\n */\nexport const TENJIN_PRODUCT = `tenjin-cli/${pkg.version}`;\n\n/** The product NAME alone, which is what identifies a copy of us in a handoff. */\nexport const TENJIN_PRODUCT_NAME = 'tenjin-cli';\n\n/**\n * The product the WebSearch hook leads with, so a ridealong query is separable\n * from a deliberate `tenjin search`. Leading is the mechanism: the server\n * attributes on the FIRST User-Agent product, landing here in `client_name`.\n *\n * The separation is the deliverable, not any one consumer: whatever judges hook\n * demand needs these populations distinguishable at ingest (tenjin#704,\n * tenjin-agent#179). A rename breaks no filter today, it merges them again. */\nexport const WEBSEARCH_HOOK_PRODUCT_NAME = 'tenjin-websearch-hook';\nexport const WEBSEARCH_HOOK_PRODUCT = `${WEBSEARCH_HOOK_PRODUCT_NAME}/${pkg.version}`;\n\n/** Every identity of ours a handoff may carry, which composition drops rather\n * than duplicate, whichever product is leading. */\nexport const OWN_PRODUCT_NAMES = [TENJIN_PRODUCT_NAME, WEBSEARCH_HOOK_PRODUCT_NAME];\n\n/**\n * The identifying comment. It rides LAST so a caller's products keep the order\n * they were handed off in, and so stripping it is enough to recover the caller's\n * sequence from an already-composed field (see `composeUserAgent`).\n */\nexport const TENJIN_COMMENT = `(+${PRODUCTION_ORIGIN})`;\n\n/**\n * The CLI's identity on every HTTP request, sent as the standard `User-Agent`\n * header from the shared transport (`http.ts`). `X-Tenjin-Client` is retired and\n * this CLI sends it nowhere.\n */\nexport const TENJIN_USER_AGENT = `${TENJIN_PRODUCT} ${TENJIN_COMMENT}`;\n\n/** The same field for the WebSearch hook, which identifies as its own product. */\nexport const WEBSEARCH_HOOK_USER_AGENT = `${WEBSEARCH_HOOK_PRODUCT} ${TENJIN_COMMENT}`;\n\n/** The handoff seam for an agent that launches the CLI as a subprocess. */\nexport const CALLER_USER_AGENT_ENV = 'TENJIN_CALLER_USER_AGENT';\n\n/** The server's bound: a longer field is discarded whole, never truncated. */\nexport const USER_AGENT_MAX_LENGTH = 512;\n\n/**\n * One RFC 9110 product: a token, optionally `/token`. The handoff accepts a\n * sequence of these and nothing else (no comments, no free text), which is what\n * structurally keeps a user, wallet, session, hostname, or machine identifier\n * out of the field rather than a blocklist that has to guess at one.\n */\nexport const PRODUCT_RE = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?$/;\n\n/** Printable ASCII, the only range the server parses; also excludes CR/LF/tab. */\nexport const PRINTABLE_ASCII_RE = /^[\\x20-\\x7e]*$/;\n\nexport interface ComposeUserAgentInput {\n /** A caller's product sequence, passed programmatically; wins over the env. */\n caller?: string | undefined;\n /** Environment seam; defaults to `process.env`. */\n env?: NodeJS.ProcessEnv;\n /** The product to lead with; the WebSearch hook passes its own. */\n product?: string;\n}\n\n/**\n * Compose the field the transport sends: the Tenjin product, then the caller's\n * products in their original order, then the Tenjin comment. The handoff is\n * SELF-REPORTED TELEMETRY and never trusted policy input; nothing here or on the\n * server may read it to decide entitlement, spend, or trust.\n *\n * Idempotent by construction: the caller value is decomposed into tokens, our own\n * product and comment are dropped from it, and the field is rebuilt from\n * `TENJIN_PRODUCT`, so re-composing an already-composed field (a retry, a nested\n * helper, an agent re-exporting the env it received) yields the same string\n * rather than a second `tenjin-cli` token. Caller products survive byte for byte.\n *\n * Rejection is total, never partial: a non-printable, non-product, or overlong\n * handoff is OMITTED and the Tenjin identity travels alone, because truncating a\n * product token would mint a different, false identity.\n */\nexport function composeUserAgent(input: ComposeUserAgentInput = {}): string {\n const product = input.product ?? TENJIN_PRODUCT;\n const alone = `${product} ${TENJIN_COMMENT}`;\n const raw = input.caller ?? (input.env ?? process.env)[CALLER_USER_AGENT_ENV];\n const products = callerProducts(raw);\n if (products.length === 0) return alone;\n const composed = `${product} ${products.join(' ')} ${TENJIN_COMMENT}`;\n return composed.length <= USER_AGENT_MAX_LENGTH ? composed : alone;\n}\n\n/** The caller's products, or none at all when any part of the handoff is unusable. */\nfunction callerProducts(raw: string | undefined): string[] {\n if (raw === undefined || !PRINTABLE_ASCII_RE.test(raw)) return [];\n // Printable ASCII leaves the space as the only whitespace, so it is the only\n // separator a product sequence can have.\n const tokens = raw.split(' ').filter((token) => token.length > 0 && !isOwnIdentity(token));\n return tokens.every((token) => PRODUCT_RE.test(token)) ? tokens : [];\n}\n\n/**\n * Our own identity inside a caller value, matched case-insensitively: a product\n * token is case-sensitive to the server, but a copy of ours in any casing is\n * still a duplicate identity, and dropping it is what makes composition total.\n */\nfunction isOwnIdentity(token: string): boolean {\n const lower = token.toLowerCase();\n // Both sides are lowered: comparing a lowered token against a constant that is\n // merely all-lowercase TODAY would break silently the day either gains a\n // capital, and it fails safe (the stale copy stops matching, then fails\n // PRODUCT_RE, and the whole handoff drops), so nothing would notice.\n if (lower === TENJIN_COMMENT.toLowerCase()) return true;\n return OWN_PRODUCT_NAMES.some((name) => {\n const own = name.toLowerCase();\n return lower === own || lower.startsWith(`${own}/`);\n });\n}\n","import { CliError } from './errors';\nimport { composeUserAgent } from './client-meta';\n\n/**\n * The single JSON client the whole CLI grows on: `doctor` uses it in B1, `search`\n * reuses it in B2. It never throws on a transport/protocol failure — it returns a\n * discriminated result so callers decide how each failure class maps to a check\n * or an error. `fetchImpl` is injectable so tests never touch the network.\n */\nexport interface FetchJsonOptions {\n /** Abort the request after this many milliseconds. */\n timeoutMs: number;\n /** Override global fetch (tests inject a stub returning canned Responses). */\n fetchImpl?: typeof fetch;\n /** Optional request headers, merged onto the User-Agent this module always sends. */\n headers?: Record<string, string>;\n /** The team shelf's bypass secret and its origin; see {@link ShelfBypass}. */\n bypass?: ShelfBypass;\n /**\n * INTERNAL. A caller's own product sequence, composed BEHIND the CLI's\n * identity (see `composeUserAgent`). The package ships a `bin` and no\n * `exports` map, so this is not a supported seam for code outside this repo:\n * the documented handoff is the `TENJIN_CALLER_USER_AGENT` environment\n * variable, which is what a subprocess launcher sets and what this falls back\n * to. Kept as an option so an in-repo caller can pass a value the environment\n * does not carry.\n */\n callerUserAgent?: string;\n}\n\n/**\n * The team shelf's Vercel \"Protection Bypass for Automation\" header.\n *\n * A door key for a protected preview deployment, not a credential of anyone's:\n * it gets a request past Deployment Protection and authenticates nobody. It is\n * NOT in {@link CREDENTIAL_HEADERS}, whose members are wallet-signed material a\n * redirect target could REPLAY — this one cannot be replayed into a signature.\n * It is still a secret, and DISCLOSING it is the whole harm: whoever holds it\n * walks into the team shelf. So it pins redirects exactly as a signed header\n * does (see {@link carriesBypassKey}), and where it may go is decided here and\n * nowhere else.\n */\nexport const SHELF_BYPASS_HEADER = 'x-vercel-protection-bypass';\n\n/**\n * A bypass secret and the origin it belongs to.\n *\n * THE ORIGIN IS PART OF THE VALUE, and that is the whole design. The CLI talks\n * to two shelves in team mode — the team's own deployment and the public\n * marketplace — and a caller that decides \"this request is to the team shelf, so\n * attach the key\" is a caller that eventually gets it wrong once. So callers\n * pass the pair and this transport does the compare: the header is attached from\n * the REQUEST URL, so a request to any other host cannot carry it, whatever the\n * call site believed.\n */\nexport interface ShelfBypass {\n /** `URL.origin` of the shelf the secret opens (the configured `baseUrl`). */\n origin: string;\n secret: string;\n}\n\n/** The bypass header for `url`, or nothing. Exported for the hook-script mirror\n * test, which runs the generated copy of this rule against this one. */\nexport function shelfBypassHeaders(\n url: string,\n bypass: ShelfBypass | undefined,\n): Record<string, string> {\n if (bypass === undefined || bypass.secret.length === 0) return {};\n let origin: string;\n try {\n origin = new URL(url).origin;\n } catch {\n return {};\n }\n if (origin !== bypass.origin) return {};\n return { [SHELF_BYPASS_HEADER]: bypass.secret };\n}\n\n/**\n * Whether the request being assembled actually carries the door key.\n *\n * A request that carries it MUST NOT follow a redirect. `fetch`'s default\n * `redirect: 'follow'` re-sends request headers verbatim to the new host (Node\n * strips only `Authorization`), so a single 3xx anywhere on the shelf origin —\n * the Vercel Authentication interstitial a rotated bypass secret gets, a domain\n * alias, a CDN rule — would hand the team shelf's key to whatever `Location`\n * names. Nothing else is needed to walk in afterwards, so the key never leaves\n * the origin it was paired with, not even one hop.\n *\n * Read off the BUILT headers rather than off `opts.bypass`, for the same reason\n * {@link CREDENTIAL_HEADERS} is matched by name: attaching the secret is what\n * arms the protection, so an off-origin request (which gets no header) keeps\n * ordinary transport and a call site cannot forget to ask for the pin.\n */\nfunction carriesBypassKey(headers: Record<string, string>): boolean {\n return Object.keys(headers).some((name) => name.toLowerCase() === SHELF_BYPASS_HEADER);\n}\n\n/** The anonymous install id: a random UUID minted once per data dir. */\nexport const INSTALL_ID_HEADER = 'tenjin-install-id';\n\n/**\n * Who is using the router, for Tenjin's own request telemetry: an anonymous\n * install id, random and tied to nothing but the data dir.\n *\n * Same shape as {@link ShelfBypass}, for the same reason: the transport decides\n * where it goes, from the REQUEST URL, so a call site cannot send it to a\n * provider by believing it is talking to Tenjin. `pay` runs over this transport\n * to third-party sellers, and none of them gets the header.\n *\n * Process-wide rather than a per-call option because it is not a per-call\n * decision: every request to Tenjin carries it, and threading it through forty\n * call sites is forty chances to forget one. Set only by the two process entries\n * (the CLI's `index.ts` and the daemon), so an in-process test that never sets\n * it sends exactly what it always did.\n *\n * Redirects are left to the request's usual transport: an unpinned request\n * follows them as `fetch` does, headers and all. Tenjin's origins redirect only\n * to Tenjin's own hosts, and the id is not a credential, so it is not worth the\n * redirect pin the bypass key and signed headers get.\n */\nexport interface TenjinIdentity {\n /** The origins that are Tenjin's own for this process. */\n origins: () => Promise<readonly string[]>;\n /** The install id; absent when it could not be read or created. */\n installId: () => Promise<string | undefined>;\n}\n\nlet tenjinIdentity: TenjinIdentity | undefined;\n\nexport function setTenjinIdentity(identity: TenjinIdentity | undefined): void {\n tenjinIdentity = identity;\n}\n\n/**\n * The telemetry headers for `url`, or nothing. NEVER THROWS: a data dir that\n * cannot be read costs the request its telemetry and nothing else.\n */\nexport async function tenjinIdentityHeaders(url: string): Promise<Record<string, string>> {\n const identity = tenjinIdentity;\n if (identity === undefined) return {};\n try {\n if (!(await identity.origins()).includes(new URL(url).origin)) return {};\n const id = await identity.installId();\n return id !== undefined ? { [INSTALL_ID_HEADER]: id } : {};\n } catch {\n return {};\n }\n}\n\n/**\n * The one place the identity is written for anything that can import it; both\n * transports funnel their Headers through it, so a third entry point on this\n * side cannot ship without it. `.set` on a Headers\n * object is what makes this total: a caller header spelled `User-Agent` in any\n * case lands in the same slot and is overwritten, never duplicated, so a\n * call-specific header cannot erase the composed field or add a second one.\n */\nfunction applyUserAgent(headers: Headers, callerUserAgent?: string): Headers {\n headers.set('user-agent', composeUserAgent({ caller: callerUserAgent }));\n return headers;\n}\n\n/** The same write for `fetchJson`'s plain-object headers; Headers.entries() is lowercase-keyed. */\nfunction withUserAgent(\n callerHeaders?: Record<string, string>,\n callerUserAgent?: string,\n): Record<string, string> {\n return Object.fromEntries(\n applyUserAgent(new Headers(callerHeaders ?? {}), callerUserAgent).entries(),\n );\n}\n\n/** A successful 2xx whose body parsed as JSON. */\nexport interface FetchJsonSuccess {\n ok: true;\n status: number;\n json: unknown;\n /** The server's `x-request-id`, when it sent one — useful in error reports. */\n requestId?: string;\n}\n\n/**\n * A failed request, tagged by class so the caller maps it deliberately:\n * `network`/`timeout` (never reached the server or no answer), `http` (a non-2xx\n * status), `invalid-json` (2xx but the body was not JSON).\n */\nexport interface FetchJsonFailure {\n ok: false;\n kind: 'network' | 'timeout' | 'http' | 'invalid-json' | 'blocked-redirect' | 'oversized-header';\n status?: number;\n requestId?: string;\n message: string;\n /**\n * On `invalid-json`, and on `http` when the status is 401/403: the response\n * looks like an access-protection or sign-in page rather than an API answer.\n * See {@link accessGateSignals} for what \"looks like\" means. Callers use it to\n * point at the missing credential instead of at the base URL, which is the one\n * setting that was already correct (#218).\n */\n gateSuspected?: boolean;\n /**\n * Present (true) only where the response left the host that was asked for:\n * `gateSuspected`'s STRONGER signal (the final URL's host differs), or, on\n * `blocked-redirect`, a `Location` that resolves to another host. An HTML\n * content-type alone proves a page came back, not who sent it, and a 3xx\n * alone proves only that the URL moved; leaving the host is what lets a\n * caller name access protection outright.\n */\n gateOffOrigin?: boolean;\n}\n\n/**\n * Does this response read as a protection page rather than as an API answer?\n *\n * Two independent signals, reported separately because they prove different\n * amounts (the caller's wording must not outrun the evidence):\n *\n * - an HTML content-type, because a Vercel Deployment Protection interstitial\n * and every sign-in wall answer with a page;\n * - a final URL whose host is not the one asked for, because a gate that\n * redirects to sign in lands the probe on another host and `fetch` follows it\n * silently on the unpinned requests this function serves.\n *\n * Decided HERE because this transport is the only place holding the `Response`;\n * a caller re-deriving it from the failure message would be guessing. An\n * unreadable final URL is NOT suspicion: `res.url` is empty on a synthesized\n * Response, so only a host that reads AND differs counts.\n */\nfunction accessGateSignals(\n requestedUrl: string,\n res: Response,\n): { gateSuspected: boolean; gateOffOrigin?: true } {\n const html = /^\\s*text\\/html\\b/i.test(res.headers.get('content-type') ?? '');\n let offOrigin = false;\n if (res.url.length > 0) {\n try {\n offOrigin = new URL(requestedUrl).host !== new URL(res.url).host;\n } catch {\n offOrigin = false;\n }\n }\n return {\n gateSuspected: html || offOrigin,\n ...(offOrigin ? { gateOffOrigin: true as const } : {}),\n };\n}\n\n/**\n * Does an unfollowed 3xx point off the host that was asked for?\n *\n * The pinned branch never follows, so `res.url` is still the requested URL and\n * `Location` is the only evidence about where the hop went. That distinction\n * carries the whole verdict downstream: a gate's sign-in interstitial lands on\n * another host, while an `http://` base URL that 301s to https, or a host\n * normalising to its canonical name, does not, and reading either as a refused\n * credential blames the wrong setting. A relative target resolves against the\n * request, so it is same-host by construction; a missing or unparseable one is\n * NOT an off-host claim.\n */\nfunction redirectLeavesHost(requestedUrl: string, location: string | null): boolean {\n if (location === null || location.length === 0) return false;\n try {\n return new URL(requestedUrl).host !== new URL(location, requestedUrl).host;\n } catch {\n return false;\n }\n}\n\n/**\n * Header names that carry wallet-signed material.\n *\n * A request bearing any of these must NEVER follow a redirect. `resource-ref`\n * pins the invariant — \"nothing signed may leave for a host the user did not\n * configure\" — but `assertOnBaseOrigin` only checks the URL the caller asked\n * for, and `fetch`'s default `redirect: 'follow'` re-sends request headers\n * verbatim to the new host (Node strips only `Authorization`). A 3xx anywhere on\n * the configured origin would therefore hand a signature BOUND TO THE REAL\n * DOMAIN to whoever `Location` points at, replayable against it for the\n * signature's lifetime.\n *\n * Detected by header NAME rather than by a caller-supplied \"this is signed\" flag\n * so the protection cannot be forgotten at a call site: attaching the credential\n * is what arms it. Matched case-insensitively. Kept as literals so the base\n * transport keeps its single dependency; `http.test.ts` pins them against the\n * real constants in `lib/siwx` and the x402 payment headers.\n *\n * All three wallet-signed families this CLI sends are here: the SIWX auth\n * header, the x402 payment header (`payment-signature` for x402 v2, plus\n * `x-payment`, the v1 spelling `@x402/core` can emit, as drift insurance even\n * though `read-client` pins v2), and `tenjin-session-delegation` — a REUSABLE\n * session-lifetime SIWX signature `session-key` attaches to every session-signed\n * write, which makes it the most replayable credential of the set. The RFC 9421\n * `Signature`/`Signature-Input` pair riding alongside it is deliberately absent:\n * it covers method, URL, and body digest, so it is not usefully replayable at\n * another host.\n */\nconst CREDENTIAL_HEADERS = new Set([\n 'sign-in-with-x',\n 'payment-signature',\n 'x-payment',\n 'tenjin-session-delegation',\n]);\n\nfunction carriesSignedMaterial(headers: Record<string, string>): boolean {\n return Object.keys(headers).some((name) => CREDENTIAL_HEADERS.has(name.toLowerCase()));\n}\n\nexport type FetchJsonResult = FetchJsonSuccess | FetchJsonFailure;\n\nexport async function fetchJson(url: string, opts: FetchJsonOptions): Promise<FetchJsonResult> {\n const doFetch = opts.fetchImpl ?? fetch;\n const controller = new AbortController();\n let timedOut = false;\n // The timer stays armed until the body is fully consumed (cleared in the outer\n // finally), so a server that sends headers then stalls the body still trips the\n // deadline instead of hanging forever on res.json().\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, opts.timeoutMs);\n\n try {\n let res: Response;\n // `new Headers` throws on a malformed caller header, so building them stays\n // inside the catch that turns any pre-flight refusal into the same\n // discriminated network failure a dead socket gets.\n let pinned = false;\n try {\n const headers = withUserAgent(\n { ...opts.headers, ...shelfBypassHeaders(url, opts.bypass) },\n opts.callerUserAgent,\n );\n // fetchJson sends no signed material — doctor's probes and the contract\n // checks are anonymous — so the door key is the one thing here worth\n // pinning, and it pins the same way it does in httpRequest.\n pinned = carriesBypassKey(headers);\n res = await doFetch(url, {\n signal: controller.signal,\n headers: { ...headers, ...(await tenjinIdentityHeaders(url)) },\n ...(pinned ? { redirect: 'manual' as const } : {}),\n });\n } catch (err) {\n // A timeout is a network failure the AbortController induced; distinguish it\n // from an organic one so the caller can say \"timed out\" rather than a raw\n // AbortError message.\n return timedOut\n ? timeoutFailure(url, opts.timeoutMs)\n : { ok: false, kind: 'network', message: `Request to ${url} failed: ${errorMessage(err)}` };\n }\n\n const requestId = res.headers.get('x-request-id') ?? undefined;\n\n // Fail CLOSED, ahead of the ordinary non-2xx branch, so an unfollowed 3xx is\n // never reported as a plain HTTP status a caller might retry by hand.\n if (pinned && res.status >= 300 && res.status < 400) {\n return {\n ok: false,\n kind: 'blocked-redirect',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n // Where it pointed, not that it pointed: only a hop that leaves the host\n // asked for is evidence about the key. Same-host 3xx happens to a base\n // URL that needs fixing, with a perfectly good key.\n ...(redirectLeavesHost(url, res.headers.get('location'))\n ? { gateOffOrigin: true as const }\n : {}),\n message:\n `Request to ${url} was redirected (${res.status}) while carrying the team shelf's ` +\n 'bypass key; refusing to follow it, because the key opens only the configured origin.',\n };\n }\n\n if (!res.ok) {\n return {\n ok: false,\n kind: 'http',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n // 401/403 is one of the three shapes deployment protection answers with\n // (200 HTML and a 30x interstitial are the others), so the gate signals\n // ride here too. Other statuses stay unmarked: a 404 or 500 HTML page is\n // an ordinary broken deployment, not a credential problem.\n ...(res.status === 401 || res.status === 403 ? accessGateSignals(url, res) : {}),\n message: `Request to ${url} failed with status ${res.status}`,\n };\n }\n\n let json: unknown;\n try {\n json = await res.json();\n } catch (err) {\n // The body read can fail three ways. A timeout wins first: the abort fires\n // synchronously with `timedOut`, so any abort-induced rejection here is our\n // deadline. Otherwise a SyntaxError is a genuine parse failure (invalid\n // JSON); anything else is a transport failure mid-body (network).\n if (timedOut) return timeoutFailure(url, opts.timeoutMs);\n if (err instanceof SyntaxError) {\n return {\n ok: false,\n kind: 'invalid-json',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n ...accessGateSignals(url, res),\n message: `Response from ${url} was not valid JSON`,\n };\n }\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} failed while reading the response body: ${errorMessage(err)}`,\n };\n }\n\n return {\n ok: true,\n status: res.status,\n json,\n ...(requestId !== undefined ? { requestId } : {}),\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction timeoutFailure(url: string, timeoutMs: number): FetchJsonFailure {\n return {\n ok: false,\n kind: 'timeout',\n message: `Request to ${url} timed out after ${timeoutMs}ms`,\n };\n}\n\n/**\n * A full HTTP round trip that surfaces the STATUS, headers, and best-effort JSON\n * body for ANY status. Unlike fetchJson (2xx-only), the B2 read/pay flow needs\n * the body on a 402 (the leak-safe preview) and a 409 (the owned-re-pay gate),\n * and search/outcome need a 4xx validation envelope. A transport/timeout failure\n * still returns the discriminated FetchJsonFailure so callers map it uniformly.\n */\nexport interface HttpRequestOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'DELETE';\n timeoutMs: number;\n headers?: Record<string, string>;\n /** The team shelf's bypass secret and its origin; see {@link ShelfBypass}. */\n bypass?: ShelfBypass;\n /** INTERNAL; see `FetchJsonOptions.callerUserAgent`. */\n callerUserAgent?: string;\n /** A JSON body (POST); serialized with a content-type header set automatically. */\n jsonBody?: unknown;\n /**\n * A body the CALLER already encoded, sent byte for byte with no content-type\n * of this transport's choosing: the router's provider leg is handed a request\n * the server built, and re-encoding it would make the bytes signed for and\n * the bytes sent two different things. The caller's own `headers` carry the\n * content type. Ignored when `jsonBody` is set.\n */\n rawBody?: string;\n fetchImpl?: typeof fetch;\n /**\n * A caller's own abort, combined with (never replacing) `timeoutMs`. The loop's\n * legs pass the fire's signal here so a harness that closed its socket stops the\n * request in flight; a caller with no such signal is unchanged.\n */\n signal?: AbortSignal;\n /**\n * Refuse redirects even when the request carries no signed header. For a\n * caller whose response becomes a durable local artifact (`fetchRead`: the\n * 200 is written to the library as an entitlement record under the\n * server-chosen id/slug), following a cross-origin redirect would let\n * another host's bytes be recorded as if the configured origin served them.\n * Off by default so search/outcome/publish/doctor keep normal transport.\n */\n blockRedirects?: boolean;\n /**\n * Keep a binary body as bytes. A sound, an image or any other non-text\n * payload decoded as text is corrupted, so with this set a response whose\n * content type is not text ({@link isBinaryContentType}) comes back with\n * `bytes` and an empty `text`. The router's provider leg sets it; every other\n * caller reads text as before.\n */\n binaryBody?: boolean;\n /** The cap on such a body; over it the response is a failure, never a\n * buffer that grows without bound. Defaults to {@link MAX_BINARY_BODY_BYTES}. */\n maxBinaryBytes?: number;\n}\n\n/** The same cap the router's linked-media download uses. */\nexport const MAX_BINARY_BODY_BYTES = 200 * 1024 * 1024;\n\n/**\n * The body's bytes, read chunk by chunk and abandoned the moment they pass\n * `max`; null over the cap. A declared length over it is refused unread.\n */\nasync function readCapped(res: Response, max: number): Promise<Uint8Array | null> {\n const declared = Number(res.headers.get('content-length') ?? '0');\n if (Number.isFinite(declared) && declared > max) {\n await res.body?.cancel().catch(() => undefined);\n return null;\n }\n if (res.body === null) return new Uint8Array();\n const reader = res.body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n size += value.byteLength;\n if (size > max) {\n await reader.cancel().catch(() => undefined);\n return null;\n }\n chunks.push(value);\n }\n return new Uint8Array(Buffer.concat(chunks));\n}\n\n/**\n * A content type whose body is not text: anything that is not `text/*` and\n * not a JSON, XML, JavaScript, YAML or form type. An absent header is text, as\n * it always was here.\n */\nexport function isBinaryContentType(contentType: string | undefined): boolean {\n const type = (contentType ?? '').split(';')[0]!.trim().toLowerCase();\n if (type.length === 0) return false;\n if (type.startsWith('text/')) return false;\n return !/(?:json|xml|javascript|ecmascript|yaml|x-www-form-urlencoded)/.test(type);\n}\n\nexport interface HttpResponse {\n ok: true;\n status: number;\n /** Case-insensitive header lookup over the response. */\n header(name: string): string | undefined;\n /** Parsed JSON body, or undefined when the body was empty or not JSON. */\n json: unknown;\n /** The raw body text; what a non-JSON endpoint actually said (`pay` delivers it). */\n text: string;\n /** The body's bytes, only for a binary body read with `binaryBody`; `text`\n * is then empty. */\n bytes?: Uint8Array;\n requestId?: string;\n}\n\nexport type HttpResult = HttpResponse | FetchJsonFailure;\n\n/** The wire form of one request: what to send, and whether it may follow a redirect. */\ninterface PreparedRequest {\n ok: true;\n headers: Record<string, string>;\n body: string | undefined;\n signed: boolean;\n bypassed: boolean;\n pinned: boolean;\n}\n\n/**\n * Assemble the request and DERIVE its redirect decision from the headers that\n * were actually built, in one place and one pass. The redirect flags are\n * returned rather than assigned, so they have no value until the headers do:\n * there is no state in which `pinned` is readable but not yet computed, which\n * is what would let a signed request follow a 3xx to another host. Anything\n * that refuses here (`new Headers` throws on a malformed caller header) becomes\n * the same discriminated failure a dead socket does, because this transport\n * documents a returned failure for every refusal, not an exception.\n */\nfunction prepareRequest(url: string, opts: HttpRequestOptions): PreparedRequest | FetchJsonFailure {\n try {\n let body: string | undefined;\n // The bypass rides in with the caller's headers rather than being set after\n // them, so a caller cannot spell it a second way and win the slot.\n const merged = new Headers({ ...opts.headers, ...shelfBypassHeaders(url, opts.bypass) });\n if (opts.jsonBody !== undefined) {\n body = JSON.stringify(opts.jsonBody);\n merged.set('content-type', 'application/json');\n } else if (opts.rawBody !== undefined) {\n body = opts.rawBody;\n }\n const wantsAccept = opts.method === 'POST' || opts.method === 'PUT' || body !== undefined;\n if (wantsAccept && !merged.has('accept')) merged.set('accept', 'application/json');\n // An `accept`/`content-type` set here wins the slot regardless of how a\n // caller cased its own copy.\n const headers = Object.fromEntries(applyUserAgent(merged, opts.callerUserAgent).entries());\n\n // Signed requests opt out of redirect following entirely; see CREDENTIAL_HEADERS.\n // So does a request carrying the team shelf's bypass key: it cannot be\n // replayed, but a 3xx would DISCLOSE it, and that is the whole harm (see\n // carriesBypassKey). A caller can also pin an unsigned, keyless request\n // (blockRedirects) when the response it gets back becomes a durable local record.\n const signed = carriesSignedMaterial(headers);\n const bypassed = carriesBypassKey(headers);\n return {\n ok: true,\n headers,\n body,\n signed,\n bypassed,\n pinned: signed || bypassed || opts.blockRedirects === true,\n };\n } catch (err) {\n return {\n ok: false,\n kind: 'network',\n message: `Request to ${url} failed: ${errorMessage(err)}`,\n };\n }\n}\n\nexport async function httpRequest(url: string, opts: HttpRequestOptions): Promise<HttpResult> {\n const doFetch = opts.fetchImpl ?? fetch;\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, opts.timeoutMs);\n // The caller's abort is combined with the timeout rather than chosen between:\n // whichever fires first ends the request, and `timedOut` still says which.\n const signal =\n opts.signal === undefined\n ? controller.signal\n : AbortSignal.any([controller.signal, opts.signal]);\n\n try {\n const prepared = prepareRequest(url, opts);\n if (!prepared.ok) return prepared;\n const { headers, body, signed, bypassed, pinned } = prepared;\n\n let res: Response;\n try {\n res = await doFetch(url, {\n method: opts.method ?? 'GET',\n headers: { ...headers, ...(await tenjinIdentityHeaders(url)) },\n body,\n signal,\n ...(pinned ? { redirect: 'manual' as const } : {}),\n });\n } catch (err) {\n if (timedOut) return timeoutFailure(url, opts.timeoutMs);\n if (isHeaderOverflow(err)) return oversizedHeaderFailure(url);\n return {\n ok: false,\n kind: 'network',\n message: `Request to ${url} failed: ${errorMessage(err)}`,\n };\n }\n\n const requestId = res.headers.get('x-request-id') ?? undefined;\n\n // Fail CLOSED on a redirect the request was not allowed to follow. This\n // returns a failure rather than the 3xx response so no caller can mistake an\n // unfollowed redirect for a normal status and retry it by hand.\n if (pinned && res.status >= 300 && res.status < 400) {\n return {\n ok: false,\n kind: 'blocked-redirect',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: signed\n ? `Request to ${url} was redirected (${res.status}) while carrying a signed header; ` +\n 'refusing to follow it, because the signature is bound to the configured origin.'\n : bypassed\n ? `Request to ${url} was redirected (${res.status}) while carrying the team shelf's ` +\n 'bypass key; refusing to follow it, because the key opens only the configured origin.'\n : `Request to ${url} was redirected (${res.status}); ` +\n 'refusing to follow it, because the response must come from the configured origin.',\n };\n }\n // Read the raw text once; parse best-effort. A non-JSON body (empty 202, an\n // HTML error page) yields `undefined` rather than a thrown parse, because a\n // 402/409 caller keys off the STATUS and only some statuses carry JSON.\n let text: string;\n let bytes: Uint8Array | undefined;\n try {\n if (opts.binaryBody === true && isBinaryContentType(res.headers.get('content-type') ?? '')) {\n const read = await readCapped(res, opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES);\n if (read === null) {\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} returned a file over the ${Math.round((opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES) / 1_048_576)} MB cap; it was not kept.`,\n };\n }\n bytes = read;\n text = '';\n } else {\n text = await res.text();\n }\n } catch (err) {\n if (timedOut) return timeoutFailure(url, opts.timeoutMs);\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} failed while reading the response body: ${errorMessage(err)}`,\n };\n }\n let json: unknown;\n if (text.length > 0) {\n try {\n json = JSON.parse(text);\n } catch {\n json = undefined;\n }\n }\n return {\n ok: true,\n status: res.status,\n header: (name) => res.headers.get(name) ?? undefined,\n json,\n text,\n ...(bytes !== undefined ? { bytes } : {}),\n ...(requestId !== undefined ? { requestId } : {}),\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\nexport interface FailureToCliErrorOptions {\n fix?: string;\n details?: unknown;\n}\n\n/**\n * Normalize a fetch failure into the CLI error contract: network/timeout are a\n * NETWORK_ERROR, an `http` status (server reachable but errored — commonly 5xx)\n * is API_UNREACHABLE, and a 2xx that failed to parse when JSON was required is a\n * CONTRACT_MISMATCH. Callers that need a check-specific code (doctor) build their\n * own CliError; this is the default B2's passthrough leans on.\n */\nexport function fetchFailureToCliError(\n failure: FetchJsonFailure,\n opts: FailureToCliErrorOptions = {},\n): CliError {\n const code =\n failure.kind === 'network' || failure.kind === 'timeout'\n ? 'NETWORK_ERROR'\n : failure.kind === 'invalid-json'\n ? 'CONTRACT_MISMATCH'\n : failure.kind === 'oversized-header'\n ? 'CHALLENGE_TOO_LARGE'\n : 'API_UNREACHABLE';\n // The one failure with a remedy nobody can apply from inside the process, so\n // it names the operator's knob rather than suggesting a retry.\n // The knob, with no claim about payment: a caller that knows its leg passes\n // its own `fix` and says what happened to the money there.\n const fix =\n opts.fix ??\n (failure.kind === 'oversized-header'\n ? 'Raising `--max-http-header-size` on the node process that runs this CLI would let the header be read; that is an operator decision, not a default this build changes.'\n : undefined);\n return new CliError(code, failure.message, {\n ...(fix !== undefined ? { fix } : {}),\n ...(opts.details !== undefined ? { details: opts.details } : {}),\n });\n}\n\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * Does this transport failure mean the response HEADERS were too big for this\n * process to read?\n *\n * Node caps them at 16 KiB unless `--max-http-header-size` says otherwise, and\n * an x402 challenge is a header: a seller that embeds its whole output schema\n * in one can exceed the cap on its own (AnyAPI's is 52 KB, measured\n * 2026-09-22). undici then aborts the request and the generic path reported\n * `fetch failed` with no status and nothing naming the cause, which reads as\n * \"the endpoint is down\" for a seller that is answering perfectly.\n *\n * The message is undici's, matched on its stable text and on the code it\n * attaches; the CAUSE is the one that carries either, so both are checked.\n */\nfunction isHeaderOverflow(err: unknown): boolean {\n const seen = [err, (err as { cause?: unknown } | null)?.cause];\n return seen.some((candidate) => {\n if (candidate === null || typeof candidate !== 'object') return false;\n const code = (candidate as { code?: unknown }).code;\n if (code === 'UND_ERR_HEADERS_OVERFLOW' || code === 'HPE_HEADER_OVERFLOW') return true;\n const message = (candidate as { message?: unknown }).message;\n return typeof message === 'string' && /headers overflow|header overflow/i.test(message);\n });\n}\n\n/**\n * The named refusal for that case. NOT a `network` failure: nothing is wrong\n * with the connection, and a caller that retries gets the same 52 KB again.\n *\n * SAYS NOTHING ABOUT PAYMENT. This transport serves the unpaid probe and the\n * paid retry alike and cannot tell them apart, so a message asserting either\n * way is wrong on one of them: it read as \"nothing was sent\" on a leg where a\n * signed authorization had already left. The leg adds that sentence, because\n * the leg is what knows; see `runPay`.\n */\nfunction oversizedHeaderFailure(url: string): FetchJsonFailure {\n let origin = url;\n try {\n origin = new URL(url).origin;\n } catch {\n // Keep the raw string; this is a diagnostic, not a destination.\n }\n return {\n ok: false,\n kind: 'oversized-header',\n message:\n `${origin} answered with a response header block larger than this process will read. ` +\n 'An x402 challenge travels in a header, and a seller that embeds its whole output ' +\n 'schema in one can exceed the limit, so the response could not be read.',\n };\n}\n"],"mappings":";;;;;;;;;;;;AASO,IAAM,iBAAiB,cAAc,gBAAI,OAAO;AAGhD,IAAM,sBAAsB;AAU5B,IAAM,8BAA8B;AACpC,IAAM,yBAAyB,GAAG,2BAA2B,IAAI,gBAAI,OAAO;AAI5E,IAAM,oBAAoB,CAAC,qBAAqB,2BAA2B;AAO3E,IAAM,iBAAiB,KAAK,iBAAiB;AAO7C,IAAM,oBAAoB,GAAG,cAAc,IAAI,cAAc;AAG7D,IAAM,4BAA4B,GAAG,sBAAsB,IAAI,cAAc;AAG7E,IAAM,wBAAwB;AAG9B,IAAM,wBAAwB;AAQ9B,IAAM,aAAa;AAGnB,IAAM,qBAAqB;AA2B3B,SAAS,iBAAiB,QAA+B,CAAC,GAAW;AAC1E,QAAM,UAAU,MAAM,WAAW;AACjC,QAAM,QAAQ,GAAG,OAAO,IAAI,cAAc;AAC1C,QAAM,MAAM,MAAM,WAAW,MAAM,OAAO,QAAQ,KAAK,qBAAqB;AAC5E,QAAM,WAAW,eAAe,GAAG;AACnC,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,QAAM,WAAW,GAAG,OAAO,IAAI,SAAS,KAAK,GAAG,CAAC,IAAI,cAAc;AACnE,SAAO,SAAS,UAAU,wBAAwB,WAAW;AAC/D;AAGA,SAAS,eAAe,KAAmC;AACzD,MAAI,QAAQ,UAAa,CAAC,mBAAmB,KAAK,GAAG,EAAG,QAAO,CAAC;AAGhE,QAAM,SAAS,IAAI,MAAM,GAAG,EAAE,OAAO,CAAC,UAAU,MAAM,SAAS,KAAK,CAAC,cAAc,KAAK,CAAC;AACzF,SAAO,OAAO,MAAM,CAAC,UAAU,WAAW,KAAK,KAAK,CAAC,IAAI,SAAS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AQ,SAAS,qBACd,0KACA;AACN,SAAO,IAAI,SAAS,MAAM,QAAQ,SAAS;AAAA,IACzC,GAAI,QAAQ,SAAY,EAAE,IAAI,IAAI,CAAC;AAAA,IACnC,GAAI,KAAK,YAAY,SAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EAChE,CAAC;AACH;AAEA,SAAS,aAAa,KAAsB;AAC1C,SAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACxD;AAgBA,SAAS,iBAAiB,KAAuB;AAC/C,QAAM,OAAO,CAAC,KAAM,KAAoC,KAAK;AAC7D,SAAO,KAAK,KAAK,CAAC,cAAc;AAC9B,QAAI,cAAc,QAAQ,OAAO,cAAc,SAAU,QAAO;AAChE,UAAM,OAAQ,UAAiC;AAC/C,QAAI,SAAS,8BAA8B,SAAS,sBAAuB,QAAO;AAClF,UAAM,UAAW,UAAoC;AACrD,WAAO,OAAO,YAAY,YAAY,oCAAoC,KAAK,OAAO;AAAA,EACxF,CAAC;AACH;AAYA,SAAS,uBAAuB,KAA+B;AAC7D,MAAI,SAAS;AACb,MAAI;AACF,aAAS,IAAI,IAAI,GAAG,EAAE;AAAA,EACxB,QAAQ;AAAA,EAER;AACA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SACE,GAAG,MAAM;AAAA,EAGb;AACF;","names":[]}
@@ -0,0 +1,55 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+
3
+ // src/lib/clack.ts
4
+ var SHOW_CURSOR = "\x1B[?25h";
5
+ function withInputEnd(streams, onEnd, run) {
6
+ const controller = new AbortController();
7
+ let settleEnd;
8
+ const ended = new Promise((resolve) => {
9
+ settleEnd = () => {
10
+ streams.output.write(SHOW_CURSOR);
11
+ resolve(onEnd);
12
+ };
13
+ });
14
+ const end = () => {
15
+ controller.abort();
16
+ settleEnd?.();
17
+ };
18
+ const onKeypress = (_text, key) => {
19
+ if (key?.ctrl === true && key.name === "d") end();
20
+ };
21
+ streams.input.on("keypress", onKeypress);
22
+ if (streams.input.readableEnded) {
23
+ queueMicrotask(end);
24
+ } else {
25
+ streams.input.once("end", end);
26
+ streams.input.once("close", end);
27
+ }
28
+ return Promise.race([run(controller.signal), ended]).finally(() => {
29
+ streams.input.off("keypress", onKeypress);
30
+ streams.input.off("end", end);
31
+ streams.input.off("close", end);
32
+ });
33
+ }
34
+ function resolveStreams(streams) {
35
+ return { input: streams.input ?? process.stdin, output: streams.output ?? process.stderr };
36
+ }
37
+ async function confirmChoice(message, initialValue = true, streams = {}) {
38
+ const { confirm, isCancel } = await import("./dist-3LOO6M4U.js");
39
+ const resolved = resolveStreams(streams);
40
+ return withInputEnd(resolved, false, async (signal) => {
41
+ const answer = await confirm({
42
+ message,
43
+ initialValue,
44
+ input: resolved.input,
45
+ output: resolved.output,
46
+ signal
47
+ });
48
+ return isCancel(answer) ? false : answer;
49
+ });
50
+ }
51
+
52
+ export {
53
+ confirmChoice
54
+ };
55
+ //# sourceMappingURL=chunk-2QYORQBF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/clack.ts"],"sourcesContent":["import type { Readable, Writable } from 'node:stream';\n\n/**\n * The pretty-prompt renderer behind the install walkthrough's seams.\n *\n * @clack/prompts is a devDependency BUNDLED by tsup (published `dependencies`\n * stays `{}`), and every entry point here is behind a dynamic `import()` so it\n * lands in its own split chunk: a `search` or `doctor` run never parses it.\n *\n * Nothing in this module is reachable from a machine run. Commands call it only\n * on the real interactive path (a TTY on both stdout and stdin, no `--json`),\n * and always through an injectable seam, so unit tests supply answers directly\n * and never touch clack or a terminal.\n *\n * Prompts render on STDERR, like every other prompt in this CLI: stdout carries\n * the human walkthrough (or a single JSON envelope) and must not be interleaved\n * with prompt chrome.\n */\n\n/** Cancel (ctrl-C, escape) is not an answer. Callers map `null` to their own default. */\nexport type Cancelled = null;\n\nexport interface SelectChoice<T extends string> {\n value: T;\n label: string;\n /** The one line of consequence shown beside the label. */\n hint?: string;\n}\n\n/** Streams a prompt reads and draws on. Injected by tests; defaults to the real ones. */\ninterface PromptStreams {\n input?: Readable;\n output?: Writable;\n}\n\n/** DECTCUM show-cursor. Written on the EOF path in case the prompt did not get to. */\nconst SHOW_CURSOR = '\\x1b[?25h';\n\n/**\n * Settle a prompt when its input goes away instead of hanging forever.\n *\n * Ctrl-D at a clack prompt leaves its promise unsettled: no resolve, no reject,\n * no cancel symbol. The process then dies on an unsettled top-level await with\n * exit 13, nothing printed, and the cursor still hidden. The readline seam this\n * replaced handled it on purpose (\"ctrl-D mid-prompt reads as the default\"), and\n * that behavior has to survive the renderer swap.\n *\n * \"Input goes away\" is two different events, and only covering one of them was\n * the original bug:\n *\n * - The STREAM ends. A pipe closes, a harness detaches, stdin was already at\n * EOF. Caught via `end` / `close`.\n * - The ctrl-D BYTE (0x04) arrives with the stream still open. This is what a\n * real terminal sends, and it is the common case. A prompt puts stdin in raw\n * mode, where 0x04 is ordinary data rather than EOF, so no stream event ever\n * fires; clack has no binding for it and simply keeps waiting. Caught via the\n * `keypress` decoder readline installs, which is a read-only view of the same\n * bytes: listening there takes nothing away from the prompt, where a `data`\n * listener would risk flipping the stream to flowing before clack reads it.\n *\n * Two mechanisms settle it, because one of them is advisory. The AbortSignal is\n * clack's own teardown: it flips the prompt to `cancel`, which restores the\n * cursor and raw mode and resolves with the cancel symbol. The race is the\n * guarantee, for a prompt that is not yet listening or never settles anyway; on\n * that path we restore the cursor ourselves, since no prompt did.\n */\nfunction withInputEnd<T>(\n streams: Required<PromptStreams>,\n onEnd: T,\n run: (signal: AbortSignal) => Promise<T>,\n): Promise<T> {\n const controller = new AbortController();\n let settleEnd: (() => void) | undefined;\n const ended = new Promise<T>((resolve) => {\n settleEnd = () => {\n streams.output.write(SHOW_CURSOR);\n resolve(onEnd);\n };\n });\n\n const end = (): void => {\n controller.abort();\n settleEnd?.();\n };\n const onKeypress = (_text: string | undefined, key?: { name?: string; ctrl?: boolean }): void => {\n if (key?.ctrl === true && key.name === 'd') end();\n };\n\n streams.input.on('keypress', onKeypress);\n // A stream that finished before we got here never emits `end` again, so ask.\n if (streams.input.readableEnded) {\n queueMicrotask(end);\n } else {\n streams.input.once('end', end);\n streams.input.once('close', end);\n }\n\n return Promise.race([run(controller.signal), ended]).finally(() => {\n streams.input.off('keypress', onKeypress);\n streams.input.off('end', end);\n streams.input.off('close', end);\n });\n}\n\nfunction resolveStreams(streams: PromptStreams): Required<PromptStreams> {\n return { input: streams.input ?? process.stdin, output: streams.output ?? process.stderr };\n}\n\n/**\n * A single-choice list. Returns the chosen value, or `null` when the operator\n * cancelled or the input ended, both of which callers treat as \"leave everything\n * as it was\".\n */\nexport async function selectOne<T extends string>(opts: {\n message: string;\n choices: readonly SelectChoice<T>[];\n initialValue: T;\n streams?: PromptStreams;\n}): Promise<T | Cancelled> {\n const { select, isCancel } = await import('@clack/prompts');\n const streams = resolveStreams(opts.streams ?? {});\n return withInputEnd<T | Cancelled>(streams, null, async (signal) => {\n // Instantiated at `string`, not at `T`: clack's `Option<Value>` is a conditional\n // type that a generic `T extends string` cannot resolve. The values come from\n // this call's own choices, so narrowing the answer back is sound.\n const answer = await select<string>({\n message: opts.message,\n options: opts.choices.map((c) => ({\n value: c.value as string,\n label: c.label,\n ...(c.hint !== undefined ? { hint: c.hint } : {}),\n })),\n initialValue: opts.initialValue,\n input: streams.input,\n output: streams.output,\n signal,\n });\n return isCancel(answer) ? null : (answer as T);\n });\n}\n\n/** A multi-choice list. Returns the selected values, or `null` when cancelled. */\nexport async function selectMany<T extends string>(opts: {\n message: string;\n choices: readonly SelectChoice<T>[];\n initialValues: readonly T[];\n required?: boolean;\n streams?: PromptStreams;\n}): Promise<T[] | Cancelled> {\n const { multiselect, isCancel } = await import('@clack/prompts');\n const streams = resolveStreams(opts.streams ?? {});\n return withInputEnd<T[] | Cancelled>(streams, null, async (signal) => {\n const answer = await multiselect<string>({\n message: opts.message,\n options: opts.choices.map((c) => ({\n value: c.value as string,\n label: c.label,\n ...(c.hint !== undefined ? { hint: c.hint } : {}),\n })),\n initialValues: [...opts.initialValues] as string[],\n required: opts.required ?? true,\n input: streams.input,\n output: streams.output,\n signal,\n });\n return isCancel(answer) ? null : (answer as T[]);\n });\n}\n\n/** A yes/no confirm. Cancelling, or an input that ends, reads as no. */\nexport async function confirmChoice(\n message: string,\n initialValue = true,\n streams: PromptStreams = {},\n): Promise<boolean> {\n const { confirm, isCancel } = await import('@clack/prompts');\n const resolved = resolveStreams(streams);\n return withInputEnd<boolean>(resolved, false, async (signal) => {\n const answer = await confirm({\n message,\n initialValue,\n input: resolved.input,\n output: resolved.output,\n signal,\n });\n return isCancel(answer) ? false : answer;\n });\n}\n\n/** Open the walkthrough's prompt sequence with a title bar. */\nexport async function intro(message: string): Promise<void> {\n const clack = await import('@clack/prompts');\n clack.intro(message, { output: process.stderr });\n}\n\n/** Close it, so the last prompt is not left dangling above plain stdout lines. */\nexport async function outro(message: string): Promise<void> {\n const clack = await import('@clack/prompts');\n clack.outro(message, { output: process.stderr });\n}\n"],"mappings":";;;AAoCA,IAAM,cAAc;AA8BpB,SAAS,aACP,SACA,OACA,KACY;AACZ,QAAM,aAAa,IAAI,gBAAgB;AACvC,MAAI;AACJ,QAAM,QAAQ,IAAI,QAAW,CAAC,YAAY;AACxC,gBAAY,MAAM;AAChB,cAAQ,OAAO,MAAM,WAAW;AAChC,cAAQ,KAAK;AAAA,IACf;AAAA,EACF,CAAC;AAED,QAAM,MAAM,MAAY;AACtB,eAAW,MAAM;AACjB,gBAAY;AAAA,EACd;AACA,QAAM,aAAa,CAAC,OAA2B,QAAkD;AAC/F,QAAI,KAAK,SAAS,QAAQ,IAAI,SAAS,IAAK,KAAI;AAAA,EAClD;AAEA,UAAQ,MAAM,GAAG,YAAY,UAAU;AAEvC,MAAI,QAAQ,MAAM,eAAe;AAC/B,mBAAe,GAAG;AAAA,EACpB,OAAO;AACL,YAAQ,MAAM,KAAK,OAAO,GAAG;AAC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