tenjin-cli 0.1.0-alpha.3 → 0.1.0-alpha.31

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 (284) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +100 -266
  3. package/dist/{_esm-FEASBWRP.js → _esm-MEXZI5DL.js} +9 -10
  4. package/dist/alive-J64H46HI.js +31 -0
  5. package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
  6. package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
  7. package/dist/chunk-27EPWVOY.js +108 -0
  8. package/dist/chunk-27EPWVOY.js.map +1 -0
  9. package/dist/chunk-2SNUOHAT.js +75 -0
  10. package/dist/chunk-2SNUOHAT.js.map +1 -0
  11. package/dist/{chunk-Z6MFJV5Z.js → chunk-2XLC3AEX.js} +857 -504
  12. package/dist/chunk-2XLC3AEX.js.map +1 -0
  13. package/dist/chunk-3623BLPV.js +184 -0
  14. package/dist/chunk-3623BLPV.js.map +1 -0
  15. package/dist/chunk-3UCIG4TG.js +65 -0
  16. package/dist/chunk-3UCIG4TG.js.map +1 -0
  17. package/dist/chunk-4ZZO6ULA.js +151 -0
  18. package/dist/chunk-4ZZO6ULA.js.map +1 -0
  19. package/dist/chunk-5C32RLTA.js +115 -0
  20. package/dist/chunk-5C32RLTA.js.map +1 -0
  21. package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
  22. package/dist/chunk-5K5W4S66.js +105 -0
  23. package/dist/chunk-5K5W4S66.js.map +1 -0
  24. package/dist/chunk-5MARFNSB.js +2018 -0
  25. package/dist/chunk-5MARFNSB.js.map +1 -0
  26. package/dist/{chunk-CYOF7ROH.js → chunk-6E5R45ZO.js} +3 -3
  27. package/dist/chunk-77TCKDEC.js +1987 -0
  28. package/dist/chunk-77TCKDEC.js.map +1 -0
  29. package/dist/chunk-7EKYXMUO.js +7536 -0
  30. package/dist/chunk-7EKYXMUO.js.map +1 -0
  31. package/dist/chunk-7Q5FDF65.js +159 -0
  32. package/dist/chunk-7Q5FDF65.js.map +1 -0
  33. package/dist/chunk-7QKHZQKW.js +1680 -0
  34. package/dist/chunk-7QKHZQKW.js.map +1 -0
  35. package/dist/{chunk-MUBUQVC3.js → chunk-7WEQQJLG.js} +6 -5
  36. package/dist/{chunk-MUBUQVC3.js.map → chunk-7WEQQJLG.js.map} +1 -1
  37. package/dist/chunk-7WU4OPLP.js +244 -0
  38. package/dist/chunk-7WU4OPLP.js.map +1 -0
  39. package/dist/chunk-7ZRL2LBQ.js +192 -0
  40. package/dist/chunk-7ZRL2LBQ.js.map +1 -0
  41. package/dist/chunk-A36LQPHV.js +29 -0
  42. package/dist/chunk-A36LQPHV.js.map +1 -0
  43. package/dist/chunk-AGZ7PJKY.js +326 -0
  44. package/dist/chunk-AGZ7PJKY.js.map +1 -0
  45. package/dist/chunk-AKWGE6JQ.js +49 -0
  46. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  47. package/dist/chunk-B7HUUJOK.js +29 -0
  48. package/dist/chunk-B7HUUJOK.js.map +1 -0
  49. package/dist/{chunk-S3IGX57D.js → chunk-BL3332HQ.js} +290 -7361
  50. package/dist/chunk-BL3332HQ.js.map +1 -0
  51. package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
  52. package/dist/chunk-D65GNPS3.js +12708 -0
  53. package/dist/chunk-D65GNPS3.js.map +1 -0
  54. package/dist/chunk-DOQGNFHM.js +121 -0
  55. package/dist/chunk-DOQGNFHM.js.map +1 -0
  56. package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
  57. package/dist/chunk-FW75G2W4.js +406 -0
  58. package/dist/chunk-FW75G2W4.js.map +1 -0
  59. package/dist/chunk-GA7JETVM.js +150 -0
  60. package/dist/chunk-GA7JETVM.js.map +1 -0
  61. package/dist/chunk-I3EQFHCD.js +175 -0
  62. package/dist/chunk-I3EQFHCD.js.map +1 -0
  63. package/dist/chunk-JKKAIPTU.js +108 -0
  64. package/dist/chunk-JKKAIPTU.js.map +1 -0
  65. package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
  66. package/dist/{chunk-NCE5NSN6.js → chunk-K3I7C2MO.js} +142 -12
  67. package/dist/chunk-K3I7C2MO.js.map +1 -0
  68. package/dist/chunk-K72RURN3.js +239 -0
  69. package/dist/chunk-K72RURN3.js.map +1 -0
  70. package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
  71. package/dist/chunk-KOGZDMHO.js +21 -0
  72. package/dist/chunk-KOGZDMHO.js.map +1 -0
  73. package/dist/chunk-KXQ4UIP7.js +228 -0
  74. package/dist/chunk-KXQ4UIP7.js.map +1 -0
  75. package/dist/chunk-KXVP2VKA.js +194 -0
  76. package/dist/chunk-KXVP2VKA.js.map +1 -0
  77. package/dist/chunk-LEFIX6RS.js +100 -0
  78. package/dist/chunk-LEFIX6RS.js.map +1 -0
  79. package/dist/chunk-LHHMV4GU.js +27 -0
  80. package/dist/chunk-LHHMV4GU.js.map +1 -0
  81. package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
  82. package/dist/chunk-MEFB5KHA.js.map +1 -0
  83. package/dist/chunk-MNXS2U45.js +1768 -0
  84. package/dist/chunk-MNXS2U45.js.map +1 -0
  85. package/dist/{chunk-UGX7YPX2.js → chunk-NEFNKLBE.js} +9 -11
  86. package/dist/{chunk-UGX7YPX2.js.map → chunk-NEFNKLBE.js.map} +1 -1
  87. package/dist/chunk-OHRR5OYM.js +63 -0
  88. package/dist/chunk-OHRR5OYM.js.map +1 -0
  89. package/dist/chunk-ORWL5BSN.js +269 -0
  90. package/dist/chunk-ORWL5BSN.js.map +1 -0
  91. package/dist/chunk-P4NH7OUK.js +398 -0
  92. package/dist/chunk-P4NH7OUK.js.map +1 -0
  93. package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
  94. package/dist/chunk-QSCPK4F5.js +145 -0
  95. package/dist/chunk-QSCPK4F5.js.map +1 -0
  96. package/dist/chunk-QXP3Z3JN.js +131 -0
  97. package/dist/chunk-QXP3Z3JN.js.map +1 -0
  98. package/dist/{chunk-XJIW7USF.js → chunk-R5LCN54M.js} +118 -9
  99. package/dist/chunk-R5LCN54M.js.map +1 -0
  100. package/dist/chunk-S4SAZ7OD.js +30 -0
  101. package/dist/chunk-S4SAZ7OD.js.map +1 -0
  102. package/dist/chunk-SJLTEINJ.js +117 -0
  103. package/dist/chunk-SJLTEINJ.js.map +1 -0
  104. package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
  105. package/dist/chunk-UKY4CHNC.js +498 -0
  106. package/dist/chunk-UKY4CHNC.js.map +1 -0
  107. package/dist/chunk-UQUOVWBG.js +114 -0
  108. package/dist/chunk-UQUOVWBG.js.map +1 -0
  109. package/dist/chunk-V6BSF6OC.js +260 -0
  110. package/dist/chunk-V6BSF6OC.js.map +1 -0
  111. package/dist/chunk-WJXLQXJY.js +43 -0
  112. package/dist/chunk-WJXLQXJY.js.map +1 -0
  113. package/dist/chunk-WK7F3B2E.js +114 -0
  114. package/dist/chunk-WK7F3B2E.js.map +1 -0
  115. package/dist/chunk-XKESD27X.js +10 -0
  116. package/dist/chunk-XKESD27X.js.map +1 -0
  117. package/dist/chunk-XQJXNMSB.js +23 -0
  118. package/dist/chunk-XQJXNMSB.js.map +1 -0
  119. package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
  120. package/dist/chunk-Y527D4TV.js +56 -0
  121. package/dist/chunk-Y527D4TV.js.map +1 -0
  122. package/dist/chunk-YFPY4ONH.js +127 -0
  123. package/dist/chunk-YFPY4ONH.js.map +1 -0
  124. package/dist/{chunk-OYMYCW7J.js → chunk-YVFXE7RR.js} +606 -97
  125. package/dist/chunk-YVFXE7RR.js.map +1 -0
  126. package/dist/clack-EZ7TDWQU.js +19 -0
  127. package/dist/claude-cli-2YKABJJZ.js +31 -0
  128. package/dist/{cli-SBXI5AMS.js → cli-D5OE3URZ.js} +458 -218
  129. package/dist/cli-D5OE3URZ.js.map +1 -0
  130. package/dist/codex-event-PPNVRRDH.js +16 -0
  131. package/dist/codex-host-2RJOJW2B.js +28 -0
  132. package/dist/codex-install-UUZ6QMBQ.js +221 -0
  133. package/dist/codex-install-UUZ6QMBQ.js.map +1 -0
  134. package/dist/config-ZD4OB2DO.js +51 -0
  135. package/dist/dist-3LOO6M4U.js +2842 -0
  136. package/dist/dist-3LOO6M4U.js.map +1 -0
  137. package/dist/doctor-KBR34Q4B.js +601 -0
  138. package/dist/doctor-KBR34Q4B.js.map +1 -0
  139. package/dist/env-proxy-XL4P73MZ.js +15 -0
  140. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  141. package/dist/ethersCompat-Df4a6QIZ-THAVUGIJ.js.map +1 -0
  142. package/dist/fund-5ITKQGYF.js +372 -0
  143. package/dist/fund-5ITKQGYF.js.map +1 -0
  144. package/dist/hook-command-4TYCHHRL.js +39 -0
  145. package/dist/hook-command-4TYCHHRL.js.map +1 -0
  146. package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
  147. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +15 -0
  148. package/dist/hosts/claude/tenjin/.mcp.json +12 -0
  149. package/dist/hosts/claude/tenjin/hooks/hooks.json +224 -0
  150. package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
  151. package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
  152. package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
  153. package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
  154. package/dist/hosts/codex/tenjin/.mcp.json +12 -0
  155. package/dist/hosts/codex/tenjin/hooks/hooks.json +52 -0
  156. package/dist/hosts-FWZOV26H.js +216 -0
  157. package/dist/hosts-FWZOV26H.js.map +1 -0
  158. package/dist/index.js +21 -2
  159. package/dist/index.js.map +1 -1
  160. package/dist/install-XWGE4Q7L.js +77 -0
  161. package/dist/install-XWGE4Q7L.js.map +1 -0
  162. package/dist/install-identity-K7EJIQFP.js +30 -0
  163. package/dist/install-identity-K7EJIQFP.js.map +1 -0
  164. package/dist/install-wallet-XQ6XFZV4.js +117 -0
  165. package/dist/install-wallet-XQ6XFZV4.js.map +1 -0
  166. package/dist/mcp-3LIJSSJB.js +13553 -0
  167. package/dist/mcp-3LIJSSJB.js.map +1 -0
  168. package/dist/package-ZKQFDWLE.js +37 -0
  169. package/dist/package-ZKQFDWLE.js.map +1 -0
  170. package/dist/paths-POPTXJO6.js +61 -0
  171. package/dist/paths-POPTXJO6.js.map +1 -0
  172. package/dist/pay-WHBERZ3W.js +55 -0
  173. package/dist/pay-WHBERZ3W.js.map +1 -0
  174. package/dist/payments-KVICEKD2.js +110 -0
  175. package/dist/payments-KVICEKD2.js.map +1 -0
  176. package/dist/plugin-registration-5TIA564H.js +54 -0
  177. package/dist/plugin-registration-5TIA564H.js.map +1 -0
  178. package/dist/redact-6W23GGJC.js +15 -0
  179. package/dist/redact-6W23GGJC.js.map +1 -0
  180. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
  181. package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
  182. package/dist/send-7G7Y7DLN.js +228 -0
  183. package/dist/send-7G7Y7DLN.js.map +1 -0
  184. package/dist/status-OF7RH5HM.js +120 -0
  185. package/dist/status-OF7RH5HM.js.map +1 -0
  186. package/dist/status-line-XOUE6MPL.js +90 -0
  187. package/dist/status-line-XOUE6MPL.js.map +1 -0
  188. package/dist/uninstall-JXUAFNDB.js +158 -0
  189. package/dist/uninstall-JXUAFNDB.js.map +1 -0
  190. package/dist/update-ZKUERSO2.js +44 -0
  191. package/dist/update-ZKUERSO2.js.map +1 -0
  192. package/dist/usdc-OGOGEHV2.js +40 -0
  193. package/dist/usdc-OGOGEHV2.js.map +1 -0
  194. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-S3DA7DFW.js} +5 -5
  195. package/dist/viemAdapter-By13KInL-S3DA7DFW.js.map +1 -0
  196. package/dist/wallet-2HA6W4R4.js +43 -0
  197. package/dist/wallet-2HA6W4R4.js.map +1 -0
  198. package/dist/wallet-kdf-worker.mjs +980 -0
  199. package/docs/agent-permissions.md +196 -0
  200. package/docs/safety-model.md +59 -0
  201. package/docs/troubleshooting.md +13 -0
  202. package/package.json +28 -19
  203. package/LICENSE +0 -21
  204. package/dist/buy-EE6SEXP6.js +0 -1598
  205. package/dist/buy-EE6SEXP6.js.map +0 -1
  206. package/dist/candidate-ERMSYYQZ.js +0 -127
  207. package/dist/candidate-ERMSYYQZ.js.map +0 -1
  208. package/dist/chunk-3OV7E5G5.js +0 -18
  209. package/dist/chunk-3OV7E5G5.js.map +0 -1
  210. package/dist/chunk-4ONXEEQL.js +0 -152
  211. package/dist/chunk-4ONXEEQL.js.map +0 -1
  212. package/dist/chunk-662MSGZB.js +0 -286
  213. package/dist/chunk-662MSGZB.js.map +0 -1
  214. package/dist/chunk-7KUW4MJD.js +0 -59
  215. package/dist/chunk-7KUW4MJD.js.map +0 -1
  216. package/dist/chunk-AWPAWHNX.js +0 -333
  217. package/dist/chunk-AWPAWHNX.js.map +0 -1
  218. package/dist/chunk-DXTQ3CSI.js +0 -171
  219. package/dist/chunk-DXTQ3CSI.js.map +0 -1
  220. package/dist/chunk-ESPNTPQ2.js +0 -207
  221. package/dist/chunk-ESPNTPQ2.js.map +0 -1
  222. package/dist/chunk-FJPLRISB.js +0 -79
  223. package/dist/chunk-FJPLRISB.js.map +0 -1
  224. package/dist/chunk-GO75V3NZ.js +0 -160
  225. package/dist/chunk-GO75V3NZ.js.map +0 -1
  226. package/dist/chunk-JPHG2JW3.js +0 -96
  227. package/dist/chunk-JPHG2JW3.js.map +0 -1
  228. package/dist/chunk-NCE5NSN6.js.map +0 -1
  229. package/dist/chunk-OYMYCW7J.js.map +0 -1
  230. package/dist/chunk-RY4XKNV3.js +0 -140
  231. package/dist/chunk-RY4XKNV3.js.map +0 -1
  232. package/dist/chunk-S3IGX57D.js.map +0 -1
  233. package/dist/chunk-TLCMMYLY.js +0 -126
  234. package/dist/chunk-TLCMMYLY.js.map +0 -1
  235. package/dist/chunk-UO22YNY4.js +0 -69
  236. package/dist/chunk-UO22YNY4.js.map +0 -1
  237. package/dist/chunk-XHC6FCGZ.js +0 -261
  238. package/dist/chunk-XHC6FCGZ.js.map +0 -1
  239. package/dist/chunk-XJIW7USF.js.map +0 -1
  240. package/dist/chunk-YBMMV4Y4.js.map +0 -1
  241. package/dist/chunk-YN5SHIXQ.js +0 -126
  242. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  243. package/dist/chunk-Z52RA3NC.js +0 -137
  244. package/dist/chunk-Z52RA3NC.js.map +0 -1
  245. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  246. package/dist/cli-SBXI5AMS.js.map +0 -1
  247. package/dist/config-VELDKLHY.js +0 -21
  248. package/dist/doctor-T3KWNNP2.js +0 -20
  249. package/dist/inspect-LMKOXE4Y.js +0 -96
  250. package/dist/inspect-LMKOXE4Y.js.map +0 -1
  251. package/dist/install-LEX3ENQ6.js +0 -387
  252. package/dist/install-LEX3ENQ6.js.map +0 -1
  253. package/dist/lookup-ZPN2Q67N.js +0 -129
  254. package/dist/lookup-ZPN2Q67N.js.map +0 -1
  255. package/dist/outcome-N7TAK6WR.js +0 -66
  256. package/dist/outcome-N7TAK6WR.js.map +0 -1
  257. package/dist/publish-BKBQQAW4.js +0 -1478
  258. package/dist/publish-BKBQQAW4.js.map +0 -1
  259. package/dist/usdc-JIAJW4SV.js +0 -22
  260. package/dist/wallet-CWEMYVIH.js +0 -179
  261. package/dist/wallet-CWEMYVIH.js.map +0 -1
  262. package/dist/wallet-PA54CRBL.js +0 -30
  263. package/skills/tenjin/SKILL.md +0 -199
  264. package/skills/tenjin-publish/SKILL.md +0 -111
  265. package/skills/tenjin-search/SKILL.md +0 -133
  266. /package/dist/{_esm-FEASBWRP.js.map → _esm-MEXZI5DL.js.map} +0 -0
  267. /package/dist/{ccip-NQXCEK2U.js.map → alive-J64H46HI.js.map} +0 -0
  268. /package/dist/{ccip-XR5NE5QK.js.map → ccip-7RMRLAGV.js.map} +0 -0
  269. /package/dist/{config-VELDKLHY.js.map → ccip-NLCSCHKI.js.map} +0 -0
  270. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
  271. /package/dist/{chunk-CYOF7ROH.js.map → chunk-6E5R45ZO.js.map} +0 -0
  272. /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
  273. /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
  274. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  275. /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
  276. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
  277. /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
  278. /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
  279. /package/dist/{doctor-T3KWNNP2.js.map → clack-EZ7TDWQU.js.map} +0 -0
  280. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
  281. /package/dist/{secp256k1-N3ZHU7LB.js.map → codex-event-PPNVRRDH.js.map} +0 -0
  282. /package/dist/{usdc-JIAJW4SV.js.map → codex-host-2RJOJW2B.js.map} +0 -0
  283. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → config-ZD4OB2DO.js.map} +0 -0
  284. /package/dist/{wallet-PA54CRBL.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
@@ -0,0 +1,150 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ HOOK_TOOL,
4
+ hookToolInput
5
+ } from "./chunk-AKWGE6JQ.js";
6
+ import {
7
+ MCP_SERVER_NAME,
8
+ PLUGIN_HOOK_TOOL,
9
+ PLUGIN_NAME,
10
+ PLUGIN_SERVER,
11
+ REQUEST_TOOL
12
+ } from "./chunk-WJXLQXJY.js";
13
+ import {
14
+ PRODUCTION_ORIGIN
15
+ } from "./chunk-XQJXNMSB.js";
16
+
17
+ // src/router/plugin-files.ts
18
+ var ROUTE_HOOK_TIMEOUT_SECONDS = 5;
19
+ var AFTER_CALL_TIMEOUT_SECONDS = 15;
20
+ var LOCAL_HOOK_TIMEOUT_SECONDS = 5;
21
+ var DELEGATION_MATCHER = "Agent|Task";
22
+ var NATIVE_MATCHER = "WebSearch|WebFetch";
23
+ var ASK_MATCHER = "AskUserQuestion";
24
+ var PLUGIN_ROOT_ENTRY = "${CLAUDE_PLUGIN_ROOT}/../../../index.js";
25
+ function cliLaunch(args, entry = PLUGIN_ROOT_ENTRY) {
26
+ return { command: "node", args: [entry, ...args] };
27
+ }
28
+ var ALIVE_ARGS = ["hook", "alive"];
29
+ function permissionAnswer(decision, reason) {
30
+ return JSON.stringify({
31
+ hookSpecificOutput: {
32
+ hookEventName: "PreToolUse",
33
+ permissionDecision: decision,
34
+ permissionDecisionReason: reason
35
+ }
36
+ });
37
+ }
38
+ var PRINT_ARGUMENT = "process.stdout.write(process.argv[1])";
39
+ function printed(answer) {
40
+ return { command: "node", args: ["-e", PRINT_ARGUMENT, answer] };
41
+ }
42
+ var DENY_HOOK = printed(
43
+ permissionAnswer(
44
+ "deny",
45
+ `Only the Tenjin hooks call this tool. To make a lookup, call ${REQUEST_TOOL}.`
46
+ )
47
+ );
48
+ var ALLOW_HOOK = printed(permissionAnswer("allow", "Tenjin lookup"));
49
+ function leg(kind, timeout = ROUTE_HOOK_TIMEOUT_SECONDS) {
50
+ return [
51
+ {
52
+ type: "mcp_tool",
53
+ server: PLUGIN_SERVER,
54
+ tool: HOOK_TOOL,
55
+ input: hookToolInput(kind),
56
+ timeout
57
+ }
58
+ ];
59
+ }
60
+ function command(launch) {
61
+ return [{ type: "command", ...launch, timeout: LOCAL_HOOK_TIMEOUT_SECONDS }];
62
+ }
63
+ function routerHookPlan() {
64
+ const afterCall = () => leg("shortfall", AFTER_CALL_TIMEOUT_SECONDS);
65
+ return [
66
+ { event: "UserPromptSubmit", hooks: leg("prompt") },
67
+ { event: "PreToolUse", matcher: NATIVE_MATCHER, hooks: leg("native") },
68
+ { event: "PreToolUse", matcher: DELEGATION_MATCHER, hooks: leg("agent") },
69
+ { event: "PostToolUse", matcher: NATIVE_MATCHER, hooks: afterCall() },
70
+ { event: "PostToolUseFailure", matcher: NATIVE_MATCHER, hooks: afterCall() },
71
+ { event: "PreToolUse", matcher: ASK_MATCHER, hooks: leg("ask") },
72
+ { event: "PostToolUse", matcher: ASK_MATCHER, hooks: leg("answer") }
73
+ ];
74
+ }
75
+ var MOD_MODULE = "./register.tsx";
76
+ function renderPluginHooks(entry = PLUGIN_ROOT_ENTRY, withMod = false) {
77
+ const plan = [
78
+ { event: "SessionStart", hooks: command(cliLaunch(ALIVE_ARGS, entry)) },
79
+ ...routerHookPlan(),
80
+ { event: "PreToolUse", matcher: PLUGIN_HOOK_TOOL, hooks: command(DENY_HOOK) },
81
+ { event: "PreToolUse", matcher: REQUEST_TOOL, hooks: command(ALLOW_HOOK) }
82
+ ];
83
+ const hooks = {};
84
+ for (const { event, hooks: handlers, ...rest } of plan) {
85
+ (hooks[event] ??= []).push({ ...rest, hooks: handlers });
86
+ }
87
+ return { hooks, ...withMod ? { modules: [MOD_MODULE] } : {} };
88
+ }
89
+ var PLUGIN_MCP_ARGS = ["mcp", "--plugin"];
90
+ function renderPluginMcp(entry = PLUGIN_ROOT_ENTRY) {
91
+ return { mcpServers: { [MCP_SERVER_NAME]: cliLaunch(PLUGIN_MCP_ARGS, entry) } };
92
+ }
93
+ var OWNER_MARKER = "tenjin-cli";
94
+ var UNBUILT = "source";
95
+ var DESCRIPTION = "Tenjin picks the right tool when your agent needs one, and one wallet on this machine pays for every call.";
96
+ function renderPluginManifest(version, withMod = false) {
97
+ return {
98
+ name: PLUGIN_NAME,
99
+ ...version !== void 0 ? { version } : {},
100
+ description: DESCRIPTION,
101
+ // The mod's `$.state` contract, which `claude plugin validate` checks.
102
+ ...withMod ? { types: `./${MOD_TYPES}` } : {},
103
+ author: { name: "Tenjin", url: PRODUCTION_ORIGIN },
104
+ homepage: `${PRODUCTION_ORIGIN}/agents`,
105
+ repository: "https://github.com/BackTrackCo/tenjin-agent",
106
+ metadata: { [OWNER_MARKER]: version ?? UNBUILT }
107
+ };
108
+ }
109
+ var PLUGIN_DIR = PLUGIN_NAME;
110
+ var PLUGIN_FILES = [
111
+ ".mcp.json",
112
+ "types/index.d.ts",
113
+ "hooks/register.tsx",
114
+ "hooks/hooks.json",
115
+ ".claude-plugin/plugin.json"
116
+ ];
117
+ var MOD_TYPES = "types/index.d.ts";
118
+ var MOD_FILES = [MOD_TYPES, "hooks/register.tsx"];
119
+ var json = (value) => `${JSON.stringify(value, null, 2)}
120
+ `;
121
+ function renderPluginFiles(version, entry, mod) {
122
+ const withMod = mod !== void 0;
123
+ return {
124
+ ".mcp.json": json(renderPluginMcp(entry)),
125
+ ...mod ?? {},
126
+ "hooks/hooks.json": json(renderPluginHooks(entry, withMod)),
127
+ ".claude-plugin/plugin.json": json(renderPluginManifest(version, withMod))
128
+ };
129
+ }
130
+ var CODEX_LEGS = ["prompt", "native", "shortfall"];
131
+ var CODEX_ALLOW_ANSWER = JSON.stringify({
132
+ hookSpecificOutput: { hookEventName: "PermissionRequest", decision: { behavior: "allow" } }
133
+ });
134
+ var CODEX_ALLOW_HOOK_COMMAND = `echo '${CODEX_ALLOW_ANSWER}'`;
135
+ var CODEX_ALLOW_HOOK_COMMAND_WINDOWS = `echo ${CODEX_ALLOW_ANSWER}`;
136
+ var CODEX_HOOK_COUNT = CODEX_LEGS.length + 1;
137
+
138
+ export {
139
+ ROUTE_HOOK_TIMEOUT_SECONDS,
140
+ AFTER_CALL_TIMEOUT_SECONDS,
141
+ OWNER_MARKER,
142
+ PLUGIN_DIR,
143
+ PLUGIN_FILES,
144
+ MOD_FILES,
145
+ renderPluginFiles,
146
+ CODEX_ALLOW_HOOK_COMMAND,
147
+ CODEX_ALLOW_HOOK_COMMAND_WINDOWS,
148
+ CODEX_HOOK_COUNT
149
+ };
150
+ //# sourceMappingURL=chunk-GA7JETVM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/plugin-files.ts"],"sourcesContent":["import { PRODUCTION_ORIGIN } from '../lib/production-origin';\nimport { HOOK_TOOL, hookToolInput, type HookKind } from './hook-tool';\nimport {\n CODEX_REQUEST_TOOL,\n MARKETPLACE_NAME,\n MCP_SERVER_NAME,\n PLUGIN_HOOK_TOOL,\n PLUGIN_NAME,\n PLUGIN_SERVER,\n REQUEST_TOOL,\n} from './names';\n\n/**\n * THE CLAUDE CODE PLUGIN, AS FILES. `tenjin install` registers it with Claude\n * Code's own `claude plugin` commands from the package's `dist/hosts/claude`\n * folder, which the build renders from this module, and writes the same plugin\n * folder under the config dir's `skills/` when there is no `claude` binary to\n * run. The checked-in `hosts/claude/` templates are pinned to this render by a\n * test, so the two cannot drift.\n *\n * NOTHING HERE IMPORTS MORE THAN THE NAMES AND THE PRODUCTION ORIGIN:\n * `tsup.config.ts` loads this module to render the shipped files, and its\n * import graph is the build's.\n */\n\n/**\n * The harness's kill budget for each routing leg: a stuck server never holds a\n * prompt longer than this. Every wait inside the leg is cut from it: the gate's\n * 3.5 s, which holds the paid path's 402, the reads before a deposit and the\n * paid request, with 500 ms left for the transcript read and the reply\n * (`wire.test.ts` pins the sum). A whole leg whose call carried a deposit took\n * 2.8 to 3.3 s on Base Sepolia, so it fits; a slower one (a wallet unlock, a\n * slow settlement) loses only that prompt's hint, and the SDK recovers the\n * channel on the next call.\n */\nexport const ROUTE_HOOK_TIMEOUT_SECONDS = 5;\n/**\n * The after-call entries' kill budget, longer than the rest for the one wait\n * a leg makes: a search the pre-call leg is fetching free docs for waits up to\n * `AUGMENT_WAIT_MS` (9 s) for them, and when none came back and the search was\n * short, the gate's 3.5 s follow, with startup to spare (`wire.test.ts` pins\n * the sum). Every other after-call event returns as fast as before, so the\n * number is a ceiling, not a cost.\n */\nexport const AFTER_CALL_TIMEOUT_SECONDS = 15;\n/** The `alive` leg and the two permission answers do no network work. */\nexport const LOCAL_HOOK_TIMEOUT_SECONDS = 5;\n\n/** The subagent tool, under its current name and its older one. */\nexport const DELEGATION_MATCHER = 'Agent|Task';\n/** The native tools both native arms watch. */\nexport const NATIVE_MATCHER = 'WebSearch|WebFetch';\n/** The host's question to the user, watched before it is asked and after. */\nexport const ASK_MATCHER = 'AskUserQuestion';\n\n/**\n * EVERY COMMAND RUNS `node` IN EXEC FORM, with no shell (see `hook-form.ts`).\n * The shipped plugin loads in place from the package's `dist/hosts/claude/tenjin`,\n * so the bundle's entry is three folders above `${CLAUDE_PLUGIN_ROOT}`, which\n * Claude Code substitutes into each argument, and the checked-in template\n * stays static. The folder fallback lives under the config dir instead, and\n * `install` renders it with the absolute entry of the CLI that wrote it.\n */\nexport const PLUGIN_ROOT_ENTRY = '${CLAUDE_PLUGIN_ROOT}/../../../index.js';\n\n/** A process Claude Code spawns directly: a hook's `command` and `args`, or a stdio server's. */\nexport interface ExecLaunch {\n command: string;\n args: string[];\n}\n\n/** The CLI run by `node` from its entry script, never through the `tenjin` shim. */\nexport function cliLaunch(args: readonly string[], entry: string = PLUGIN_ROOT_ENTRY): ExecLaunch {\n return { command: 'node', args: [entry, ...args] };\n}\n\n/**\n * The `alive` leg: the plugin's `SessionStart` entry, so it runs before any\n * other event of a session. It marks the session as one the plugin serves, so\n * a settings-install leg in the same session stays silent, and stamps the\n * machine as one the plugin has loaded on, which the migration waits for. A\n * command, not an `mcp_tool` call: a session's MCP servers may still be\n * connecting when `SessionStart` fires, and a command needs nothing running.\n */\nexport const ALIVE_ARGS = ['hook', 'alive'] as const;\n\n/** A PreToolUse answer, as a hook command's stdout carries it. */\nfunction permissionAnswer(decision: 'allow' | 'deny', reason: string): string {\n return JSON.stringify({\n hookSpecificOutput: {\n hookEventName: 'PreToolUse',\n permissionDecision: decision,\n permissionDecisionReason: reason,\n },\n });\n}\n\n/** A fixed answer `node -e` prints from its own argument: no shell, no CLI, no quoting. */\nexport const PRINT_ARGUMENT = 'process.stdout.write(process.argv[1])';\n\nfunction printed(answer: string): ExecLaunch {\n return { command: 'node', args: ['-e', PRINT_ARGUMENT, answer] };\n}\n\n/**\n * THE HOOK LEGS' TOOL IS DENIED TO THE MODEL. Its event fields are plain\n * arguments, so the model calling it could forge a routing leg. This blocking\n * hook replaces the settings install's `permissions.deny` rule: a plugin cannot\n * carry permission rules, and a blocking hook takes precedence over allow rules\n * in every mode, bypass included, while Claude Code's own `mcp_tool` hook calls\n * still run (lab, Claude Code 2.1.296). The tool stays in the model's list. The\n * tool's transcript check (`admitHookEvent`) stays for a machine with hooks off.\n */\nexport const DENY_HOOK = printed(\n permissionAnswer(\n 'deny',\n `Only the Tenjin hooks call this tool. To make a lookup, call ${REQUEST_TOOL}.`,\n ),\n);\n\n/**\n * THE REQUEST TOOL IS ALLOWED BY THE PLUGIN ITSELF, replacing the settings\n * install's `permissions.allow` rule, so an install needs no rule the user\n * adds. A hook's allow never overrides the user's own `deny` or `ask` rule for\n * the tool. The tool still pays only within the local spend policy, and an\n * amount over it returns `needs_approval` with nothing paid.\n */\nexport const ALLOW_HOOK = printed(permissionAnswer('allow', 'Tenjin lookup'));\n\n/** One routing leg: Claude Code calls the plugin server's `hook` tool. */\nfunction leg(kind: HookKind, timeout = ROUTE_HOOK_TIMEOUT_SECONDS): unknown[] {\n return [\n {\n type: 'mcp_tool',\n server: PLUGIN_SERVER,\n tool: HOOK_TOOL,\n input: hookToolInput(kind),\n timeout,\n },\n ];\n}\n\nfunction command(launch: ExecLaunch): unknown[] {\n return [{ type: 'command', ...launch, timeout: LOCAL_HOOK_TIMEOUT_SECONDS }];\n}\n\n/**\n * The seven routing legs. The native tools are routed twice over one lookup:\n * BEFORE the call, with a line pointing to a paid lookup when one fits; and\n * AFTER it, only when it came back short and nothing was said before, or to\n * add the free docs the pre-call arm fetched to a search's results. A failed\n * call fires PostToolUseFailure rather than PostToolUse, so the second takes\n * both. The host's question to the user is routed the same two ways: before it\n * is asked, when a service could stand in for what it asks for, and after,\n * with the user's answers read as their own words.\n */\nexport function routerHookPlan(): { event: string; matcher?: string; hooks: unknown[] }[] {\n const afterCall = () => leg('shortfall', AFTER_CALL_TIMEOUT_SECONDS);\n return [\n { event: 'UserPromptSubmit', hooks: leg('prompt') },\n { event: 'PreToolUse', matcher: NATIVE_MATCHER, hooks: leg('native') },\n { event: 'PreToolUse', matcher: DELEGATION_MATCHER, hooks: leg('agent') },\n { event: 'PostToolUse', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PostToolUseFailure', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PreToolUse', matcher: ASK_MATCHER, hooks: leg('ask') },\n { event: 'PostToolUse', matcher: ASK_MATCHER, hooks: leg('answer') },\n ];\n}\n\n/** The mod's module, as `hooks/hooks.json` names it (relative to that file). */\nexport const MOD_MODULE = './register.tsx';\n\n/**\n * `hooks/hooks.json`: the `alive` leg, the seven routing legs and the two\n * permission answers, and the mod's module when the folder carries it.\n */\nexport function renderPluginHooks(\n entry: string = PLUGIN_ROOT_ENTRY,\n withMod = false,\n): {\n hooks: Record<string, unknown[]>;\n modules?: string[];\n} {\n const plan = [\n { event: 'SessionStart', hooks: command(cliLaunch(ALIVE_ARGS, entry)) },\n ...routerHookPlan(),\n { event: 'PreToolUse', matcher: PLUGIN_HOOK_TOOL, hooks: command(DENY_HOOK) },\n { event: 'PreToolUse', matcher: REQUEST_TOOL, hooks: command(ALLOW_HOOK) },\n ];\n const hooks: Record<string, unknown[]> = {};\n for (const { event, hooks: handlers, ...rest } of plan) {\n (hooks[event] ??= []).push({ ...rest, hooks: handlers });\n }\n return { hooks, ...(withMod ? { modules: [MOD_MODULE] } : {}) };\n}\n\n/**\n * `.mcp.json`: the server Claude Code starts for the plugin, the CLI's entry\n * run by `node`, which Windows can spawn where it cannot spawn the shim.\n *\n * `--plugin` KEEPS IT FROM BEING SUPPRESSED. Claude Code drops a plugin's MCP\n * server whose command and arguments match a server the user configured, and\n * a settings install's `x402` entry runs `tenjin mcp`; with the same command\n * the plugin's `router` server would not start while the two coexist, its legs\n * would fail, and the old ones stay silent (checked on Claude Code 2.1.296).\n */\nexport const PLUGIN_MCP_ARGS = ['mcp', '--plugin'] as const;\n\nexport function renderPluginMcp(entry: string = PLUGIN_ROOT_ENTRY): {\n mcpServers: Record<string, unknown>;\n} {\n return { mcpServers: { [MCP_SERVER_NAME]: cliLaunch(PLUGIN_MCP_ARGS, entry) } };\n}\n\n/** The key whose presence marks a plugin manifest as one this CLI wrote. */\nexport const OWNER_MARKER = 'tenjin-cli';\n/** The marker's value in the checked-in templates, which carry no version. */\nconst UNBUILT = 'source';\n\nconst DESCRIPTION =\n 'Tenjin picks the right tool when your agent needs one, and one wallet on this machine pays for every call.';\n\n/**\n * `.claude-plugin/plugin.json`. The version is the CLI's, stamped at build time,\n * so Claude Code's plugin list names the build that runs; the checked-in\n * template carries none. `metadata[tenjin-cli]` is the ownership marker the\n * folder fallback, `update` and `uninstall` check before they touch a folder.\n */\nexport function renderPluginManifest(version?: string, withMod = false): Record<string, unknown> {\n return {\n name: PLUGIN_NAME,\n ...(version !== undefined ? { version } : {}),\n description: DESCRIPTION,\n // The mod's `$.state` contract, which `claude plugin validate` checks.\n ...(withMod ? { types: `./${MOD_TYPES}` } : {}),\n author: { name: 'Tenjin', url: PRODUCTION_ORIGIN },\n homepage: `${PRODUCTION_ORIGIN}/agents`,\n repository: 'https://github.com/BackTrackCo/tenjin-agent',\n metadata: { [OWNER_MARKER]: version ?? UNBUILT },\n };\n}\n\n/** The plugin's folder inside the marketplace folder. */\nexport const PLUGIN_DIR = PLUGIN_NAME;\n\n/** `.claude-plugin/marketplace.json`: one plugin, read in place from the package. */\nexport function renderMarketplace(version?: string): Record<string, unknown> {\n return {\n name: MARKETPLACE_NAME,\n owner: { name: 'Tenjin', url: PRODUCTION_ORIGIN },\n description: \"Tenjin's tool router for Claude Code, installed by `tenjin install`.\",\n ...(version !== undefined ? { metadata: { version } } : {}),\n plugins: [\n {\n name: PLUGIN_NAME,\n source: `./${PLUGIN_DIR}`,\n description: DESCRIPTION,\n ...(version !== undefined ? { version } : {}),\n },\n ],\n };\n}\n\n/**\n * EVERY FILE THE PLUGIN FOLDER HOLDS, relative to the plugin's root, and the\n * only paths install, update and uninstall ever write or unlink in a folder.\n * The manifest is last: a crash mid-write never leaves a manifest pointing at\n * parts that are not there yet.\n */\nexport const PLUGIN_FILES = [\n '.mcp.json',\n 'types/index.d.ts',\n 'hooks/register.tsx',\n 'hooks/hooks.json',\n '.claude-plugin/plugin.json',\n] as const;\n\n/** The mod's `$.state` contract, shipped as written. */\nexport const MOD_TYPES = 'types/index.d.ts';\n/**\n * THE MOD SHIPS AS WRITTEN, NOT RENDERED: `hosts/claude/tenjin/` holds its\n * source, the build copies it into `dist/hosts/claude/tenjin/`, and the folder\n * fallback copies it from there. Claude Code compiles it at load (2.1.287 or\n * later); nothing here builds or imports it.\n */\nexport const MOD_FILES = [MOD_TYPES, 'hooks/register.tsx'] as const;\nexport type ModSources = Record<(typeof MOD_FILES)[number], string>;\n\nconst json = (value: unknown): string => `${JSON.stringify(value, null, 2)}\\n`;\n\n/**\n * The plugin folder's files, by {@link PLUGIN_FILES} path. `entry` is the CLI\n * entry the commands run, {@link PLUGIN_ROOT_ENTRY} unless the folder lives\n * outside the package. Without the mod's sources the folder carries the legs\n * and the server alone, and its hooks file names no module.\n */\nexport function renderPluginFiles(\n version?: string,\n entry?: string,\n mod?: ModSources,\n): Record<string, string> {\n const withMod = mod !== undefined;\n return {\n '.mcp.json': json(renderPluginMcp(entry)),\n ...(mod ?? {}),\n 'hooks/hooks.json': json(renderPluginHooks(entry, withMod)),\n '.claude-plugin/plugin.json': json(renderPluginManifest(version, withMod)),\n };\n}\n\n/** The marketplace folder's files: its catalog and the plugin under {@link PLUGIN_DIR}. */\nexport function renderHostFiles(version?: string, mod?: ModSources): Record<string, string> {\n const plugin = Object.entries(renderPluginFiles(version, undefined, mod)).map(\n ([path, body]) => [`${PLUGIN_DIR}/${path}`, body] as const,\n );\n return {\n '.claude-plugin/marketplace.json': json(renderMarketplace(version)),\n ...Object.fromEntries(plugin),\n };\n}\n\n/**\n * THE CODEX PLUGIN, AS FILES, shipped in `dist/hosts/codex` and pinned to the\n * checked-in `hosts/codex/` by the same test. Its legs are command hooks: the\n * prompt, and one web call before it runs and after (Codex has no\n * PostToolUseFailure). Nothing in it names a release, so `codex plugin add`\n * copies the same bytes from every build and the hooks' trust holds across a\n * `tenjin update`.\n */\nexport const CODEX_WEB_MATCHER = 'webrun';\nexport const CODEX_LEGS = ['prompt', 'native', 'shortfall'] as const;\n\nexport function codexHookCommand(kind: (typeof CODEX_LEGS)[number]): string {\n return `tenjin hook ${kind} --harness codex`;\n}\n\n/**\n * THE REQUEST TOOL IS ALLOWED BY THE PLUGIN ITSELF, as {@link ALLOW_HOOK_COMMAND}\n * is in Claude Code. Codex runs a `PermissionRequest` hook before its approval\n * policy, `never` included, so the tool runs without a prompt once the user\n * trusts this hook with the others in `/hooks`. It also overrides a user's own\n * `approval_mode = \"prompt\"` for the tool; that user turns this one hook off in\n * `/hooks`. The wallet's spend limits still bound every payment.\n */\nconst CODEX_ALLOW_ANSWER = JSON.stringify({\n hookSpecificOutput: { hookEventName: 'PermissionRequest', decision: { behavior: 'allow' } },\n});\nexport const CODEX_ALLOW_HOOK_COMMAND = `echo '${CODEX_ALLOW_ANSWER}'`;\n/**\n * The same answer under Windows' `cmd.exe /C`, through Codex's `commandWindows`\n * override: cmd's `echo` prints single quotes as written, and Codex then\n * rejects the output as JSON. The answer holds none of cmd's special\n * characters, so a bare `echo` prints it as is.\n */\nexport const CODEX_ALLOW_HOOK_COMMAND_WINDOWS = `echo ${CODEX_ALLOW_ANSWER}`;\n\n/** Every hook the Codex plugin carries: the three legs and the allow answer. */\nexport const CODEX_HOOK_COUNT = CODEX_LEGS.length + 1;\n\nfunction codexLeg(kind: (typeof CODEX_LEGS)[number], timeout = ROUTE_HOOK_TIMEOUT_SECONDS) {\n return [{ type: 'command', command: codexHookCommand(kind), timeout }];\n}\n\nexport function renderCodexHooks(): { hooks: Record<string, unknown[]> } {\n return {\n hooks: {\n UserPromptSubmit: [{ hooks: codexLeg('prompt') }],\n PreToolUse: [{ matcher: CODEX_WEB_MATCHER, hooks: codexLeg('native') }],\n PostToolUse: [\n { matcher: CODEX_WEB_MATCHER, hooks: codexLeg('shortfall', AFTER_CALL_TIMEOUT_SECONDS) },\n ],\n PermissionRequest: [\n {\n matcher: CODEX_REQUEST_TOOL,\n hooks: [\n {\n type: 'command',\n command: CODEX_ALLOW_HOOK_COMMAND,\n commandWindows: CODEX_ALLOW_HOOK_COMMAND_WINDOWS,\n timeout: LOCAL_HOOK_TIMEOUT_SECONDS,\n },\n ],\n },\n ],\n },\n };\n}\n\nexport const CODEX_MCP_ARGS = ['mcp', '--harness', 'codex'] as const;\n\nexport function renderCodexMcp(): { mcpServers: Record<string, unknown> } {\n return { mcpServers: { [MCP_SERVER_NAME]: { command: 'tenjin', args: [...CODEX_MCP_ARGS] } } };\n}\n\n/** `.codex-plugin/plugin.json`. No version: see {@link renderCodexHostFiles}. */\nexport function renderCodexManifest(): Record<string, unknown> {\n return {\n name: PLUGIN_NAME,\n description: DESCRIPTION,\n author: { name: 'Tenjin', url: PRODUCTION_ORIGIN },\n homepage: `${PRODUCTION_ORIGIN}/agents`,\n repository: 'https://github.com/BackTrackCo/tenjin-agent',\n interface: { displayName: 'Tenjin', developerName: 'Tenjin', category: 'Productivity' },\n mcpServers: './.mcp.json',\n };\n}\n\n/** `.agents/plugins/marketplace.json`: one local plugin, copied by `codex plugin add`. */\nexport function renderCodexMarketplace(): Record<string, unknown> {\n return {\n name: MARKETPLACE_NAME,\n interface: { displayName: 'Tenjin' },\n plugins: [\n {\n name: PLUGIN_NAME,\n source: { source: 'local', path: `./${PLUGIN_DIR}` },\n policy: { installation: 'AVAILABLE', authentication: 'ON_INSTALL' },\n category: 'Productivity',\n },\n ],\n };\n}\n\n/** The Codex marketplace folder's files: its catalog and the plugin under {@link PLUGIN_DIR}. */\nexport function renderCodexHostFiles(): Record<string, string> {\n return {\n '.agents/plugins/marketplace.json': json(renderCodexMarketplace()),\n [`${PLUGIN_DIR}/.mcp.json`]: json(renderCodexMcp()),\n [`${PLUGIN_DIR}/hooks/hooks.json`]: json(renderCodexHooks()),\n [`${PLUGIN_DIR}/.codex-plugin/plugin.json`]: json(renderCodexManifest()),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCO,IAAM,6BAA6B;AASnC,IAAM,6BAA6B;AAEnC,IAAM,6BAA6B;AAGnC,IAAM,qBAAqB;AAE3B,IAAM,iBAAiB;AAEvB,IAAM,cAAc;AAUpB,IAAM,oBAAoB;AAS1B,SAAS,UAAU,MAAyB,QAAgB,mBAA+B;AAChG,SAAO,EAAE,SAAS,QAAQ,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE;AACnD;AAUO,IAAM,aAAa,CAAC,QAAQ,OAAO;AAG1C,SAAS,iBAAiB,UAA4B,QAAwB;AAC5E,SAAO,KAAK,UAAU;AAAA,IACpB,oBAAoB;AAAA,MAClB,eAAe;AAAA,MACf,oBAAoB;AAAA,MACpB,0BAA0B;AAAA,IAC5B;AAAA,EACF,CAAC;AACH;AAGO,IAAM,iBAAiB;AAE9B,SAAS,QAAQ,QAA4B;AAC3C,SAAO,EAAE,SAAS,QAAQ,MAAM,CAAC,MAAM,gBAAgB,MAAM,EAAE;AACjE;AAWO,IAAM,YAAY;A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Q;AACxB,SAAO;AAAA,IACL,aAAa,KAAK,gBAAgB,KAAK,CAAC;AAAA,IACxC,GAAI,OAAO,CAAC;AAAA,IACZ,oBAAoB,KAAK,kBAAkB,OAAO,OAAO,CAAC;AAAA,IAC1D,8BAA8B,KAAK,qBAAqB,SAAS,OAAO,CAAC;AAAA,EAC3E;AACF;AAsBO,IAAM,aAAa,CAAC,UAAU,UAAU,WAAW;AAc1D,IAAM,qBAAqB,KAAK,UAAU;AAAA,EACxC,oBAAoB,EAAE,eAAe,qBAAqB,UAAU,EAAE,UAAU,QAAQ,EAAE;AAC5F,CAAC;AACM,IAAM,2BAA2B,SAAS,kBAAkB;AAO5D,IAAM,mCAAmC,QAAQ,kBAAkB;AAGnE,IAAM,mBAAmB,WAAW,SAAS;","names":[]}
@@ -0,0 +1,175 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ DEFAULT_MAX_AUTO_SPEND
4
+ } from "./chunk-YVFXE7RR.js";
5
+ import {
6
+ DEFAULT_RPC_URL,
7
+ rememberingBalanceReader
8
+ } from "./chunk-27EPWVOY.js";
9
+ import {
10
+ configPath,
11
+ walletPath
12
+ } from "./chunk-SJLTEINJ.js";
13
+
14
+ // src/router/alive.ts
15
+ import { createHash } from "node:crypto";
16
+ import { mkdir, readdir, readFile, rm, rmdir, stat, writeFile } from "node:fs/promises";
17
+ import { join } from "node:path";
18
+ var MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
19
+ var STAMP = "plugin-loaded.json";
20
+ var MAX_SESSION_ID = 200;
21
+ function aliveDir(dataDir) {
22
+ return join(dataDir, "alive");
23
+ }
24
+ function markerName(sessionId) {
25
+ return createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
26
+ }
27
+ function sessionIdOf(event) {
28
+ if (event === null || typeof event !== "object") return null;
29
+ const id = event.session_id;
30
+ return typeof id === "string" && id.length > 0 && id.length <= MAX_SESSION_ID ? id : null;
31
+ }
32
+ async function runAliveHook(event, opts) {
33
+ const sessionId = sessionIdOf(event);
34
+ const now = opts.now ?? Date.now();
35
+ const dir = aliveDir(opts.dataDir);
36
+ try {
37
+ await mkdir(dir, { recursive: true, mode: 448 });
38
+ if (sessionId !== null) {
39
+ await writeFile(join(dir, markerName(sessionId)), `${new Date(now).toISOString()}
40
+ `);
41
+ }
42
+ const stamp = { at: new Date(now).toISOString(), version: opts.version };
43
+ await writeFile(join(dir, STAMP), `${JSON.stringify(stamp)}
44
+ `);
45
+ await pruneMarkers(dir, now);
46
+ } catch {
47
+ }
48
+ }
49
+ async function pruneMarkers(dir, now) {
50
+ for (const name of await readdir(dir).catch(() => [])) {
51
+ if (!/^[0-9a-f]{32}$/.test(name)) continue;
52
+ const path = join(dir, name);
53
+ const s = await stat(path).catch(() => null);
54
+ if (s !== null && now - s.mtimeMs > MARKER_TTL_MS) await rm(path, { force: true });
55
+ }
56
+ }
57
+ async function sessionServedByPlugin(dataDir, event) {
58
+ const sessionId = sessionIdOf(event);
59
+ if (sessionId === null) return false;
60
+ return await stat(join(aliveDir(dataDir), markerName(sessionId))).catch(() => null) !== null;
61
+ }
62
+ async function readAliveStamp(dataDir) {
63
+ try {
64
+ const parsed = JSON.parse(await readFile(join(aliveDir(dataDir), STAMP), "utf8"));
65
+ if (parsed === null || typeof parsed !== "object") return null;
66
+ const { at, version } = parsed;
67
+ return typeof at === "string" && typeof version === "string" ? { at, version } : null;
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ async function removeAliveState(dataDir) {
73
+ const dir = aliveDir(dataDir);
74
+ const existed = await stat(dir).catch(() => null) !== null;
75
+ if (!existed) return false;
76
+ for (const name of await readdir(dir).catch(() => [])) {
77
+ if (name === STAMP || /^[0-9a-f]{32}$/.test(name)) await rm(join(dir, name), { force: true });
78
+ }
79
+ await rmdir(dir).catch(() => void 0);
80
+ return true;
81
+ }
82
+ var WALLET_READ_MS = 2e3;
83
+ async function walletNotice(dataDir, opts = {}) {
84
+ const wallet = await readJson(walletPath(dataDir));
85
+ const address = typeof wallet?.address === "string" ? wallet.address : void 0;
86
+ if (address === void 0 || !/^0x[0-9a-fA-F]{40}$/.test(address)) return null;
87
+ const config = await readJson(configPath(dataDir));
88
+ const rpcUrl = typeof config?.rpcUrl === "string" ? config.rpcUrl : DEFAULT_RPC_URL;
89
+ const timeoutMs = opts.timeoutMs ?? WALLET_READ_MS;
90
+ const read = rememberingBalanceReader(dataDir, {
91
+ ...opts.read !== void 0 ? { read: opts.read } : {}
92
+ });
93
+ const balance = await read(address, rpcUrl, { timeoutMs });
94
+ if (balance === null) return null;
95
+ const cap = BigInt(
96
+ typeof config?.maxAutoSpend === "string" && /^\d{1,30}$/.test(config.maxAutoSpend) ? config.maxAutoSpend : DEFAULT_MAX_AUTO_SPEND
97
+ );
98
+ if (balance > 0n && balance >= cap) return null;
99
+ return `Tenjin balance: $${dollars(balance)}. Ask your agent to add funds to Tenjin.`;
100
+ }
101
+ function dollars(atomic) {
102
+ const fraction = (atomic % 1000000n).toString().padStart(6, "0").replace(/0+$/, "");
103
+ return `${atomic / 1000000n}.${fraction.padEnd(2, "0")}`;
104
+ }
105
+ async function readJson(path) {
106
+ try {
107
+ const value = JSON.parse(await readFile(path, "utf8"));
108
+ return value !== null && typeof value === "object" ? value : null;
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+ async function aliveMain(opts) {
114
+ const raw = await readStdin(1e3).catch(() => "");
115
+ await runAliveHook(parseEvent(raw), opts);
116
+ const notice = await walletNotice(opts.dataDir).catch(() => null);
117
+ if (notice !== null) process.stdout.write(`${JSON.stringify({ systemMessage: notice })}
118
+ `);
119
+ }
120
+ function parseEvent(raw) {
121
+ try {
122
+ return JSON.parse(raw);
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function readStdin(timeoutMs) {
128
+ return new Promise((resolve, reject) => {
129
+ const chunks = [];
130
+ let size = 0;
131
+ const timer = setTimeout(() => reject(new Error("no harness event")), timeoutMs);
132
+ process.stdin.on("data", (chunk) => {
133
+ size += chunk.length;
134
+ if (size > 1e6) {
135
+ clearTimeout(timer);
136
+ reject(new Error("harness event too large"));
137
+ return;
138
+ }
139
+ chunks.push(chunk);
140
+ });
141
+ process.stdin.once("end", () => {
142
+ clearTimeout(timer);
143
+ resolve(Buffer.concat(chunks).toString("utf8"));
144
+ });
145
+ process.stdin.once("error", () => {
146
+ clearTimeout(timer);
147
+ reject(new Error("harness event unreadable"));
148
+ });
149
+ });
150
+ }
151
+ async function markSessionServed(dataDir, event) {
152
+ const sessionId = sessionIdOf(event);
153
+ if (sessionId === null) return;
154
+ const path = join(aliveDir(dataDir), markerName(sessionId));
155
+ if (await stat(path).catch(() => null) !== null) return;
156
+ try {
157
+ await mkdir(aliveDir(dataDir), { recursive: true, mode: 448 });
158
+ await writeFile(path, `${(/* @__PURE__ */ new Date()).toISOString()}
159
+ `);
160
+ } catch {
161
+ }
162
+ }
163
+
164
+ export {
165
+ aliveDir,
166
+ runAliveHook,
167
+ sessionServedByPlugin,
168
+ readAliveStamp,
169
+ removeAliveState,
170
+ WALLET_READ_MS,
171
+ walletNotice,
172
+ aliveMain,
173
+ markSessionServed
174
+ };
175
+ //# sourceMappingURL=chunk-I3EQFHCD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/alive.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, readdir, readFile, rm, rmdir, stat, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DEFAULT_MAX_AUTO_SPEND } from '../lib/config';\nimport { configPath, walletPath } from '../lib/paths';\nimport {\n DEFAULT_RPC_URL,\n readUsdcBalanceWithFallback,\n rememberingBalanceReader,\n} from '../lib/usdc-balance';\n\n/**\n * THE PLUGIN SAYS IT IS HERE. While a machine carries both the plugin and the\n * settings install it replaces, every event would run two sets of routing legs\n * and offer the same lookup twice. The plugin's `SessionStart` entry runs\n * `tenjin hook alive` before any other event of the session, and it writes:\n *\n * - a per-session marker, which every leg a settings install launched checks\n * first, staying silent in a session the plugin serves;\n * - a per-machine stamp, the proof the guarded migration waits for: the plugin\n * has loaded in a real session on this machine at least once, so the\n * settings install can be removed without leaving the machine unrouted.\n *\n * Outside `progress/`, whose files are pruned after ten minutes. Markers are\n * pruned here after a week, which outlasts any session that still matters.\n *\n * SHIM: the per-session check goes on or after 2026-12-01, the first release\n * cut 30 or more days after the plugin PR 2 ships; the stamp stays for doctor.\n */\n\nconst MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1000;\nconst STAMP = 'plugin-loaded.json';\n/** A session id names a file only through its hash, so any string is safe. */\nconst MAX_SESSION_ID = 200;\n\nexport function aliveDir(dataDir: string): string {\n return join(dataDir, 'alive');\n}\n\nfunction markerName(sessionId: string): string {\n return createHash('sha256').update(sessionId).digest('hex').slice(0, 32);\n}\n\nfunction sessionIdOf(event: unknown): string | null {\n if (event === null || typeof event !== 'object') return null;\n const id = (event as { session_id?: unknown }).session_id;\n return typeof id === 'string' && id.length > 0 && id.length <= MAX_SESSION_ID ? id : null;\n}\n\nexport interface AliveStamp {\n at: string;\n /** The CLI version whose plugin loaded. */\n version: string;\n}\n\n/**\n * The `alive` leg: marker, stamp, prune. It prints nothing, because a\n * `SessionStart` hook's plain stdout is added to the session's context\n * ({@link aliveMain} adds the wallet notice as JSON), and it never fails the\n * session: every error is swallowed.\n */\nexport async function runAliveHook(\n event: unknown,\n opts: { dataDir: string; version: string; now?: number },\n): Promise<void> {\n const sessionId = sessionIdOf(event);\n const now = opts.now ?? Date.now();\n const dir = aliveDir(opts.dataDir);\n try {\n await mkdir(dir, { recursive: true, mode: 0o700 });\n if (sessionId !== null) {\n await writeFile(join(dir, markerName(sessionId)), `${new Date(now).toISOString()}\\n`);\n }\n const stamp: AliveStamp = { at: new Date(now).toISOString(), version: opts.version };\n await writeFile(join(dir, STAMP), `${JSON.stringify(stamp)}\\n`);\n await pruneMarkers(dir, now);\n } catch {\n // A marker that could not be written costs only a duplicate offer.\n }\n}\n\nasync function pruneMarkers(dir: string, now: number): Promise<void> {\n for (const name of await readdir(dir).catch(() => [] as string[])) {\n if (!/^[0-9a-f]{32}$/.test(name)) continue;\n const path = join(dir, name);\n const s = await stat(path).catch(() => null);\n if (s !== null && now - s.mtimeMs > MARKER_TTL_MS) await rm(path, { force: true });\n }\n}\n\n/** Has the plugin's `alive` leg marked this session? False on any doubt. */\nexport async function sessionServedByPlugin(dataDir: string, event: unknown): Promise<boolean> {\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return false;\n return (await stat(join(aliveDir(dataDir), markerName(sessionId))).catch(() => null)) !== null;\n}\n\n/** The machine's stamp, or null when the plugin has never loaded here. */\nexport async function readAliveStamp(dataDir: string): Promise<AliveStamp | null> {\n try {\n const parsed = JSON.parse(await readFile(join(aliveDir(dataDir), STAMP), 'utf8')) as unknown;\n if (parsed === null || typeof parsed !== 'object') return null;\n const { at, version } = parsed as { at?: unknown; version?: unknown };\n return typeof at === 'string' && typeof version === 'string' ? { at, version } : null;\n } catch {\n return null;\n }\n}\n\n/** `uninstall`: the markers and the stamp, and nothing else under the data dir. */\nexport async function removeAliveState(dataDir: string): Promise<boolean> {\n const dir = aliveDir(dataDir);\n const existed = (await stat(dir).catch(() => null)) !== null;\n if (!existed) return false;\n for (const name of await readdir(dir).catch(() => [] as string[])) {\n if (name === STAMP || /^[0-9a-f]{32}$/.test(name)) await rm(join(dir, name), { force: true });\n }\n // Only when empty: a file somebody else put there keeps the folder.\n await rmdir(dir).catch(() => undefined);\n return true;\n}\n\n/** How long the leg waits on a balance read before it says nothing. */\nexport const WALLET_READ_MS = 2_000;\n\n/**\n * THE WALLET, SAID TO THE PERSON AT THE START OF A SESSION while it cannot\n * pay: the leg's `systemMessage`, which Claude Code shows the user and never\n * the model, on every surface and without the mod. Null when there is no\n * wallet, the balance could not be read in time, or the wallet holds at least\n * the per-call limit.\n */\nexport async function walletNotice(\n dataDir: string,\n opts: { read?: typeof readUsdcBalanceWithFallback; timeoutMs?: number } = {},\n): Promise<string | null> {\n const wallet = await readJson(walletPath(dataDir));\n const address = typeof wallet?.address === 'string' ? wallet.address : undefined;\n if (address === undefined || !/^0x[0-9a-fA-F]{40}$/.test(address)) return null;\n const config = await readJson(configPath(dataDir));\n const rpcUrl = typeof config?.rpcUrl === 'string' ? config.rpcUrl : DEFAULT_RPC_URL;\n const timeoutMs = opts.timeoutMs ?? WALLET_READ_MS;\n const read = rememberingBalanceReader(dataDir, {\n ...(opts.read !== undefined ? { read: opts.read } : {}),\n });\n const balance = await read(address, rpcUrl, { timeoutMs });\n if (balance === null) return null;\n // The per-call limit as the spend policy reads it: the file's, else the default.\n const cap = BigInt(\n typeof config?.maxAutoSpend === 'string' && /^\\d{1,30}$/.test(config.maxAutoSpend)\n ? config.maxAutoSpend\n : DEFAULT_MAX_AUTO_SPEND,\n );\n if (balance > 0n && balance >= cap) return null;\n // Only the person reads it, inside the session: they ask, the agent runs it.\n return `Tenjin balance: $${dollars(balance)}. Ask your agent to add funds to Tenjin.`;\n}\n\n/** `$0.00`, `$0.10`, `$0.007`: whole cents keep two decimals. */\nfunction dollars(atomic: bigint): string {\n const fraction = (atomic % 1_000_000n).toString().padStart(6, '0').replace(/0+$/, '');\n return `${atomic / 1_000_000n}.${fraction.padEnd(2, '0')}`;\n}\n\nasync function readJson(path: string): Promise<Record<string, unknown> | null> {\n try {\n const value: unknown = JSON.parse(await readFile(path, 'utf8'));\n return value !== null && typeof value === 'object' ? (value as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The command form's entry, read off stdin: `tenjin hook alive`. It prints\n * only a JSON `systemMessage`, which Claude Code shows the user; plain text\n * would be added to the session's context.\n */\nexport async function aliveMain(opts: { dataDir: string; version: string }): Promise<void> {\n const raw = await readStdin(1_000).catch(() => '');\n await runAliveHook(parseEvent(raw), opts);\n const notice = await walletNotice(opts.dataDir).catch(() => null);\n if (notice !== null) process.stdout.write(`${JSON.stringify({ systemMessage: notice })}\\n`);\n}\n\nfunction parseEvent(raw: string): unknown {\n try {\n return JSON.parse(raw) as unknown;\n } catch {\n return null;\n }\n}\n\nfunction readStdin(timeoutMs: number): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n const timer = setTimeout(() => reject(new Error('no harness event')), timeoutMs);\n process.stdin.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > 1_000_000) {\n clearTimeout(timer);\n reject(new Error('harness event too large'));\n return;\n }\n chunks.push(chunk);\n });\n process.stdin.once('end', () => {\n clearTimeout(timer);\n resolve(Buffer.concat(chunks).toString('utf8'));\n });\n process.stdin.once('error', () => {\n clearTimeout(timer);\n reject(new Error('harness event unreadable'));\n });\n });\n}\n\n/**\n * A plugin leg marks its own session too, for a session that loaded the plugin\n * without a `SessionStart` (a `/reload-plugins` mid-session): from the next\n * event on, the settings install's legs there stay silent. A stat when the\n * marker is already there.\n */\nexport async function markSessionServed(dataDir: string, event: unknown): Promise<void> {\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return;\n const path = join(aliveDir(dataDir), markerName(sessionId));\n if ((await stat(path).catch(() => null)) !== null) return;\n try {\n await mkdir(aliveDir(dataDir), { recursive: true, mode: 0o700 });\n await writeFile(path, `${new Date().toISOString()}\\n`);\n } catch {\n // Costs only a duplicate offer.\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,SAAS,UAAU,IAAI,OAAO,MAAM,iBAAiB;AACrE,SAAS,YAAY;AA4BrB,IAAM,gBAAgB,IAAI,KAAK,KAAK,KAAK;AACzC,IAAM,QAAQ;AAEd,IAAM,iBAAiB;AAEhB,SAAS,SAAS,SAAyB;AAChD,SAAO,KAAK,SAAS,OAAO;AAC9B;AAEA,SAAS,WAAW,WAA2B;AAC7C,SAAO,WAAW,QAAQ,EAAE,OAAO,SAAS,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AACzE;AAEA,SAAS,YAAY,OAA+B;AAClD,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SAAS,WAAW;AACtC,UAAM,SAAmB,CAAC;AAC1B,QAAI,OAAO;AACX,UAAM,QAAQ,WAAW,MAAM,OAAO,IAAI,MAAM,kBAAkB,CAAC,GAAG,SAAS;AAC/E,YAAQ,MAAM,GAAG,QAAQ,CAAC,UAAkB;AAC1C,cAAQ,MAAM;AACd,UAAI,OAAO,KAAW;AACpB,qBAAa,KAAK;AAClB,eAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB,CAAC;AACD,YAAQ,MAAM,KAAK,OAAO,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAQ,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,KAAK,SAAS,MAAM;AAChC,mBAAa,KAAK;AAClB,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH,CAAC;AACH;AAQA,eAAsB,kBAAkB,SAAiB,OAA+B;AACtF,QAAM,YAAY,YAAY,KAAK;AACnC,MAAI,cAAc,KAAM;AACxB,QAAM,OAAO,KAAK,SAAS,OAAO,GAAG,WAAW,SAAS,CAAC;AAC1D,MAAK,MAAM,KAAK,IAAI,EAAE,MAAM,MAAM,IAAI,MAAO,KAAM;AACnD,MAAI;AACF,UAAM,MAAM,SAAS,OAAO,GAAG,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAC/D,UAAM,UAAU,MAAM,IAAG,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,CAAI;AAAA,EACvD,QAAQ;AAAA,EAER;AACF;","names":[]}
@@ -0,0 +1,108 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ CliError
4
+ } from "./chunk-3UCIG4TG.js";
5
+
6
+ // src/lib/destination.ts
7
+ import { lookup } from "node:dns/promises";
8
+ import { BlockList, isIP } from "node:net";
9
+ var blockedV4 = new BlockList();
10
+ for (const [base, prefix] of [
11
+ ["0.0.0.0", 8],
12
+ ["10.0.0.0", 8],
13
+ ["100.64.0.0", 10],
14
+ ["127.0.0.0", 8],
15
+ ["169.254.0.0", 16],
16
+ ["172.16.0.0", 12],
17
+ ["192.0.0.0", 24],
18
+ ["192.0.2.0", 24],
19
+ ["192.168.0.0", 16],
20
+ ["198.18.0.0", 15],
21
+ ["198.51.100.0", 24],
22
+ ["203.0.113.0", 24],
23
+ ["224.0.0.0", 4],
24
+ ["240.0.0.0", 4]
25
+ ]) {
26
+ blockedV4.addSubnet(base, prefix, "ipv4");
27
+ }
28
+ var blockedV6 = new BlockList();
29
+ for (const [base, prefix] of [
30
+ ["::", 128],
31
+ ["::1", 128],
32
+ ["64:ff9b::", 96],
33
+ ["100::", 64],
34
+ ["2001:db8::", 32],
35
+ ["fc00::", 7],
36
+ ["fe80::", 10],
37
+ ["ff00::", 8]
38
+ ]) {
39
+ blockedV6.addSubnet(base, prefix, "ipv6");
40
+ }
41
+ function isPublicAddress(value) {
42
+ const kind = isIP(value);
43
+ if (kind === 4) return !blockedV4.check(value, "ipv4");
44
+ return kind === 6 && /^[23]/i.test(value) && !blockedV6.check(value, "ipv6");
45
+ }
46
+ var LOCAL_SUFFIX = /(?:^|\.)(?:localhost|local|internal|home|lan)$/i;
47
+ function refuse(message, details) {
48
+ throw new CliError("USAGE", message, {
49
+ fix: "Paid requests go to public HTTPS endpoints only; nothing was signed.",
50
+ ...details !== void 0 ? { details } : {}
51
+ });
52
+ }
53
+ function assertPublicHttpsUrl(raw) {
54
+ let url;
55
+ try {
56
+ url = new URL(raw);
57
+ } catch {
58
+ return refuse(`Invalid URL: ${JSON.stringify(raw.slice(0, 200))}`);
59
+ }
60
+ if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.hash !== "" || url.port !== "" && url.port !== "443" || raw.length > 16384) {
61
+ refuse("Only public HTTPS endpoints without credentials, fragments or custom ports are paid.");
62
+ }
63
+ const host = url.hostname.replace(/^\[|\]$/g, "");
64
+ if (!host.includes(".") && isIP(host) === 0) refuse("The endpoint host is not a public name.");
65
+ if (LOCAL_SUFFIX.test(host)) refuse("Private or local destinations are not paid.");
66
+ if (isIP(host) !== 0 && !isPublicAddress(host)) {
67
+ refuse("Private or reserved IP destinations are not paid.");
68
+ }
69
+ return url;
70
+ }
71
+ async function assertPublicDestination(raw, options = {}) {
72
+ return (await resolvePublicDestination(raw, options)).url;
73
+ }
74
+ async function resolvePublicDestination(raw, options = {}) {
75
+ const url = assertPublicHttpsUrl(raw);
76
+ const host = url.hostname.replace(/^\[|\]$/g, "");
77
+ if (isIP(host) !== 0) return { url, address: host, family: isIP(host) === 6 ? 6 : 4 };
78
+ const resolve = options.resolveHostname ?? ((name) => lookup(name, { all: true }));
79
+ const signal = AbortSignal.timeout(options.timeoutMs ?? 5e3);
80
+ let addresses;
81
+ try {
82
+ addresses = await Promise.race([
83
+ resolve(host),
84
+ new Promise((_, reject) => {
85
+ signal.addEventListener("abort", () => reject(new Error("DNS lookup timed out.")), {
86
+ once: true
87
+ });
88
+ })
89
+ ]);
90
+ } catch (err) {
91
+ return refuse(`The endpoint host ${host} could not be resolved.`, {
92
+ cause: err instanceof Error ? err.message : String(err)
93
+ });
94
+ }
95
+ if (addresses.length === 0 || addresses.some((entry) => !isPublicAddress(entry.address))) {
96
+ refuse(`The endpoint host ${host} resolves to a private or unsupported network address.`);
97
+ }
98
+ const first = addresses[0];
99
+ return { url, address: first.address, family: isIP(first.address) === 6 ? 6 : 4 };
100
+ }
101
+
102
+ export {
103
+ isPublicAddress,
104
+ assertPublicHttpsUrl,
105
+ assertPublicDestination,
106
+ resolvePublicDestination
107
+ };
108
+ //# sourceMappingURL=chunk-JKKAIPTU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/destination.ts"],"sourcesContent":["import { lookup } from 'node:dns/promises';\nimport { BlockList, isIP } from 'node:net';\nimport { CliError } from './errors';\n\n/**\n * Where this CLI is willing to send a paid request. Ported from the draft\n * auto-mode experiment (PR #369 `execution.ts`) into a shared path, so the\n * router's provider call and `tenjin pay` answer the question the same way.\n *\n * TWO CHECKS, BOTH NEEDED. The lexical one refuses a URL shape that cannot be a\n * public endpoint (a scheme, credentials, a fragment, a literal private\n * address). The DNS one refuses a public-looking NAME that resolves onto the\n * local network, which is the shape a hostile registry listing or a hostile\n * routing decision would take.\n *\n * WHAT IT IS NOT. A resolved address is checked, NOT PINNED. `fetch` resolves\n * the name again on its own, so a host that answers publicly here and privately\n * a moment later is not closed by this, and neither is a remote scraper\n * following its own redirects on its own server. Closing the first needs a\n * transport that connects to the address it validated (`node:https` with a\n * `lookup` override, as the draft experiment's `safeHttpsTransport` did), which\n * the plan for this release left unported for the paid leg. The router's media\n * download does connect that way: it pins its socket to the address\n * {@link resolvePublicDestination} validated (`router/paid.ts`). What this does remove\n * is the easy local target: `http://`, credentials, a custom port, a literal\n * private address, a `.localhost`/`.internal` name, and a public name whose\n * only answers are private. Documented in docs/safety-model.md as a bound.\n */\n\nconst blockedV4 = new BlockList();\nfor (const [base, prefix] of [\n ['0.0.0.0', 8],\n ['10.0.0.0', 8],\n ['100.64.0.0', 10],\n ['127.0.0.0', 8],\n ['169.254.0.0', 16],\n ['172.16.0.0', 12],\n ['192.0.0.0', 24],\n ['192.0.2.0', 24],\n ['192.168.0.0', 16],\n ['198.18.0.0', 15],\n ['198.51.100.0', 24],\n ['203.0.113.0', 24],\n ['224.0.0.0', 4],\n ['240.0.0.0', 4],\n] as const) {\n blockedV4.addSubnet(base, prefix, 'ipv4');\n}\n\nconst blockedV6 = new BlockList();\nfor (const [base, prefix] of [\n ['::', 128],\n ['::1', 128],\n ['64:ff9b::', 96],\n ['100::', 64],\n ['2001:db8::', 32],\n ['fc00::', 7],\n ['fe80::', 10],\n ['ff00::', 8],\n] as const) {\n blockedV6.addSubnet(base, prefix, 'ipv6');\n}\n\n/** Is this literal address one a paid request may be sent to? IPv6 additionally\n * has to sit in the globally routable 2000::/3 range. */\nexport function isPublicAddress(value: string): boolean {\n const kind = isIP(value);\n if (kind === 4) return !blockedV4.check(value, 'ipv4');\n return kind === 6 && /^[23]/i.test(value) && !blockedV6.check(value, 'ipv6');\n}\n\nconst LOCAL_SUFFIX = /(?:^|\\.)(?:localhost|local|internal|home|lan)$/i;\n\nfunction refuse(message: string, details?: Record<string, unknown>): never {\n throw new CliError('USAGE', message, {\n fix: 'Paid requests go to public HTTPS endpoints only; nothing was signed.',\n ...(details !== undefined ? { details } : {}),\n });\n}\n\n/** The lexical half: the URL shape alone, no network. Returns the parsed URL. */\nexport function assertPublicHttpsUrl(raw: string): URL {\n let url: URL;\n try {\n url = new URL(raw);\n } catch {\n return refuse(`Invalid URL: ${JSON.stringify(raw.slice(0, 200))}`);\n }\n if (\n url.protocol !== 'https:' ||\n url.username !== '' ||\n url.password !== '' ||\n url.hash !== '' ||\n (url.port !== '' && url.port !== '443') ||\n raw.length > 16_384\n ) {\n refuse('Only public HTTPS endpoints without credentials, fragments or custom ports are paid.');\n }\n const host = url.hostname.replace(/^\\[|\\]$/g, '');\n if (!host.includes('.') && isIP(host) === 0) refuse('The endpoint host is not a public name.');\n if (LOCAL_SUFFIX.test(host)) refuse('Private or local destinations are not paid.');\n if (isIP(host) !== 0 && !isPublicAddress(host)) {\n refuse('Private or reserved IP destinations are not paid.');\n }\n return url;\n}\n\nexport interface DestinationOptions {\n /** Resolver seam; production leaves it unset and uses `dns.lookup`. */\n resolveHostname?: (hostname: string) => Promise<{ address: string; family: number }[]>;\n /** One deadline for the whole resolution, not per address. */\n timeoutMs?: number;\n}\n\n/**\n * The full preflight: the lexical check, then DNS. A literal address answered\n * the DNS question already and skips the lookup.\n */\nexport async function assertPublicDestination(\n raw: string,\n options: DestinationOptions = {},\n): Promise<URL> {\n return (await resolvePublicDestination(raw, options)).url;\n}\n\n/**\n * The same preflight, returning the ONE address it validated, for a transport\n * that connects to exactly that address instead of resolving the name again\n * (see the module comment). Every answer must be public, as above; the first\n * is the one to pin.\n */\nexport async function resolvePublicDestination(\n raw: string,\n options: DestinationOptions = {},\n): Promise<{ url: URL; address: string; family: 4 | 6 }> {\n const url = assertPublicHttpsUrl(raw);\n const host = url.hostname.replace(/^\\[|\\]$/g, '');\n if (isIP(host) !== 0) return { url, address: host, family: isIP(host) === 6 ? 6 : 4 };\n const resolve = options.resolveHostname ?? ((name: string) => lookup(name, { all: true }));\n const signal = AbortSignal.timeout(options.timeoutMs ?? 5_000);\n let addresses: { address: string; family: number }[];\n try {\n addresses = await Promise.race([\n resolve(host),\n new Promise<never>((_, reject) => {\n signal.addEventListener('abort', () => reject(new Error('DNS lookup timed out.')), {\n once: true,\n });\n }),\n ]);\n } catch (err) {\n return refuse(`The endpoint host ${host} could not be resolved.`, {\n cause: err instanceof Error ? err.message : String(err),\n });\n }\n if (addresses.length === 0 || addresses.some((entry) => !isPublicAddress(entry.address))) {\n refuse(`The endpoint host ${host} resolves to a private or unsupported network address.`);\n }\n const first = addresses[0]!;\n return { url, address: first.address, family: isIP(first.address) === 6 ? 6 : 4 };\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,WAAW,YAAY;AA4BhC,IAAM,YAAY,IAAI,UAAU;AAChC,WAAW,CAAC,MAAM,MAAM,KAAK;AAAA,EAC3B,CAAC,WAAW,CAAC;AAAA,EACb,CAAC,YAAY,CAAC;AAAA,EACd,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,aAAa,CAAC;AAAA,EACf,CAAC,eAAe,EAAE;AAAA,EAClB,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,aAAa,EAAE;AAAA,EAChB,CAAC,aAAa,EAAE;AAAA,EAChB,CAAC,eAAe,EAAE;AAAA,EAClB,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,gBAAgB,EAAE;AAAA,EACnB,CAAC,eAAe,EAAE;AAAA,EAClB,CAAC,aAAa,CAAC;AAAA,EACf,CAAC,aAAa,CAAC;AACjB,GAAY;AACV,YAA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,UAAU,CAAC;AACzB,SAAO,EAAE,KAAK,SAAS,MAAM,SAAS,QAAQ,KAAK,MAAM,OAAO,MAAM,IAAI,IAAI,EAAE;AAClF;","names":[]}
@@ -35,7 +35,7 @@ import {
35
35
  randomBytes,
36
36
  rotr,
37
37
  toBytes
38
- } from "./chunk-5CLSD5YN.js";
38
+ } from "./chunk-BPMWXTFX.js";
39
39
 
40
40
  // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
41
41
  function setBigUint64(view, byteOffset, value, isLE) {
@@ -2250,4 +2250,4 @@ export {
2250
2250
  @noble/curves/esm/secp256k1.js:
2251
2251
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2252
2252
  */
2253
- //# sourceMappingURL=chunk-QVX5MWJZ.js.map
2253
+ //# sourceMappingURL=chunk-JRGFKVAZ.js.map