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

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 (246) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +149 -264
  3. package/dist/{_esm-FEASBWRP.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/alive-3J3CHOQP.js +21 -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-2SNUOHAT.js +75 -0
  8. package/dist/chunk-2SNUOHAT.js.map +1 -0
  9. package/dist/chunk-3O2BQIF6.js +2227 -0
  10. package/dist/chunk-3O2BQIF6.js.map +1 -0
  11. package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
  12. package/dist/chunk-5LJCEMFD.js +12700 -0
  13. package/dist/chunk-5LJCEMFD.js.map +1 -0
  14. package/dist/chunk-6W5GYG3W.js +128 -0
  15. package/dist/chunk-6W5GYG3W.js.map +1 -0
  16. package/dist/chunk-7EKYXMUO.js +7536 -0
  17. package/dist/chunk-7EKYXMUO.js.map +1 -0
  18. package/dist/chunk-7QKHZQKW.js +1680 -0
  19. package/dist/chunk-7QKHZQKW.js.map +1 -0
  20. package/dist/chunk-A36LQPHV.js +29 -0
  21. package/dist/chunk-A36LQPHV.js.map +1 -0
  22. package/dist/chunk-AEG2PXBP.js +192 -0
  23. package/dist/chunk-AEG2PXBP.js.map +1 -0
  24. package/dist/chunk-AKWGE6JQ.js +49 -0
  25. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  26. package/dist/chunk-AWFUPKTM.js +238 -0
  27. package/dist/chunk-AWFUPKTM.js.map +1 -0
  28. package/dist/{chunk-UGX7YPX2.js → chunk-AWQPGIR6.js} +7 -9
  29. package/dist/{chunk-UGX7YPX2.js.map → chunk-AWQPGIR6.js.map} +1 -1
  30. package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
  31. package/dist/chunk-EBVIKMCH.js +108 -0
  32. package/dist/chunk-EBVIKMCH.js.map +1 -0
  33. package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
  34. package/dist/{chunk-S3IGX57D.js → chunk-EL56RW2J.js} +166 -7237
  35. package/dist/chunk-EL56RW2J.js.map +1 -0
  36. package/dist/chunk-HE2MS4QO.js +256 -0
  37. package/dist/chunk-HE2MS4QO.js.map +1 -0
  38. package/dist/{chunk-CYOF7ROH.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-IOODYAXL.js +324 -0
  40. package/dist/chunk-IOODYAXL.js.map +1 -0
  41. package/dist/chunk-JMM6YE7J.js +2174 -0
  42. package/dist/chunk-JMM6YE7J.js.map +1 -0
  43. package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
  44. package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
  45. package/dist/chunk-KHE6L6TD.js +416 -0
  46. package/dist/chunk-KHE6L6TD.js.map +1 -0
  47. package/dist/chunk-KOGZDMHO.js +21 -0
  48. package/dist/chunk-KOGZDMHO.js.map +1 -0
  49. package/dist/chunk-KYFZTGMC.js +237 -0
  50. package/dist/chunk-KYFZTGMC.js.map +1 -0
  51. package/dist/chunk-LFZJM56J.js +159 -0
  52. package/dist/chunk-LFZJM56J.js.map +1 -0
  53. package/dist/chunk-LHHMV4GU.js +27 -0
  54. package/dist/chunk-LHHMV4GU.js.map +1 -0
  55. package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
  56. package/dist/chunk-MEFB5KHA.js.map +1 -0
  57. package/dist/{chunk-NCE5NSN6.js → chunk-N35E6CM2.js} +140 -10
  58. package/dist/chunk-N35E6CM2.js.map +1 -0
  59. package/dist/chunk-NZIP4PA2.js +114 -0
  60. package/dist/chunk-NZIP4PA2.js.map +1 -0
  61. package/dist/chunk-O2FRQ2L2.js +168 -0
  62. package/dist/chunk-O2FRQ2L2.js.map +1 -0
  63. package/dist/chunk-OK2TDZQU.js +404 -0
  64. package/dist/chunk-OK2TDZQU.js.map +1 -0
  65. package/dist/chunk-ORWL5BSN.js +269 -0
  66. package/dist/chunk-ORWL5BSN.js.map +1 -0
  67. package/dist/{chunk-Z6MFJV5Z.js → chunk-OSYTBCUC.js} +850 -499
  68. package/dist/chunk-OSYTBCUC.js.map +1 -0
  69. package/dist/chunk-P7LABKCW.js +90 -0
  70. package/dist/chunk-P7LABKCW.js.map +1 -0
  71. package/dist/chunk-PAYV4XUA.js +151 -0
  72. package/dist/chunk-PAYV4XUA.js.map +1 -0
  73. package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
  74. package/dist/chunk-QUVVWYJW.js +112 -0
  75. package/dist/chunk-QUVVWYJW.js.map +1 -0
  76. package/dist/chunk-RAULEAZ6.js +228 -0
  77. package/dist/chunk-RAULEAZ6.js.map +1 -0
  78. package/dist/chunk-S4SAZ7OD.js +30 -0
  79. package/dist/chunk-S4SAZ7OD.js.map +1 -0
  80. package/dist/chunk-SJLTEINJ.js +117 -0
  81. package/dist/chunk-SJLTEINJ.js.map +1 -0
  82. package/dist/chunk-SPAVAYSW.js +125 -0
  83. package/dist/chunk-SPAVAYSW.js.map +1 -0
  84. package/dist/chunk-TTBKWWTV.js +1605 -0
  85. package/dist/chunk-TTBKWWTV.js.map +1 -0
  86. package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
  87. package/dist/chunk-U6YQ6FRI.js +378 -0
  88. package/dist/chunk-U6YQ6FRI.js.map +1 -0
  89. package/dist/chunk-VFMQTSXG.js +29 -0
  90. package/dist/chunk-VFMQTSXG.js.map +1 -0
  91. package/dist/chunk-VUFAK2LW.js +115 -0
  92. package/dist/chunk-VUFAK2LW.js.map +1 -0
  93. package/dist/chunk-VZGAONSJ.js +194 -0
  94. package/dist/chunk-VZGAONSJ.js.map +1 -0
  95. package/dist/{chunk-OYMYCW7J.js → chunk-WO5BJNIB.js} +682 -53
  96. package/dist/chunk-WO5BJNIB.js.map +1 -0
  97. package/dist/chunk-WVUSXNIE.js +39 -0
  98. package/dist/chunk-WVUSXNIE.js.map +1 -0
  99. package/dist/chunk-XKESD27X.js +10 -0
  100. package/dist/chunk-XKESD27X.js.map +1 -0
  101. package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
  102. package/dist/{chunk-XJIW7USF.js → chunk-YFQOA5AU.js} +118 -9
  103. package/dist/chunk-YFQOA5AU.js.map +1 -0
  104. package/dist/chunk-YHKXNYTB.js +105 -0
  105. package/dist/chunk-YHKXNYTB.js.map +1 -0
  106. package/dist/{cli-SBXI5AMS.js → cli-O5SN7ZJ4.js} +382 -214
  107. package/dist/cli-O5SN7ZJ4.js.map +1 -0
  108. package/dist/config-OJQI27LT.js +45 -0
  109. package/dist/dist-3LOO6M4U.js +2842 -0
  110. package/dist/dist-3LOO6M4U.js.map +1 -0
  111. package/dist/doctor-IQQJHGGM.js +590 -0
  112. package/dist/doctor-IQQJHGGM.js.map +1 -0
  113. package/dist/env-proxy-XL4P73MZ.js +15 -0
  114. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  115. package/dist/fund-WEV6DMTD.js +365 -0
  116. package/dist/fund-WEV6DMTD.js.map +1 -0
  117. package/dist/hook-command-D2P3ILRV.js +32 -0
  118. package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
  119. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
  120. package/dist/hosts/claude/tenjin/.mcp.json +12 -0
  121. package/dist/hosts/claude/tenjin/hooks/hooks.json +221 -0
  122. package/dist/index.js +21 -2
  123. package/dist/index.js.map +1 -1
  124. package/dist/install-TUCRF32I.js +60 -0
  125. package/dist/install-identity-WHPNMNMQ.js +26 -0
  126. package/dist/install-wallet-MA27FTQ5.js +113 -0
  127. package/dist/install-wallet-MA27FTQ5.js.map +1 -0
  128. package/dist/mcp-QML7ZMPH.js +13427 -0
  129. package/dist/mcp-QML7ZMPH.js.map +1 -0
  130. package/dist/package-LGKYOEPV.js +37 -0
  131. package/dist/package-LGKYOEPV.js.map +1 -0
  132. package/dist/paths-POPTXJO6.js +61 -0
  133. package/dist/paths-POPTXJO6.js.map +1 -0
  134. package/dist/pay-2C2UBBXJ.js +51 -0
  135. package/dist/pay-2C2UBBXJ.js.map +1 -0
  136. package/dist/payments-C44QUFXU.js +106 -0
  137. package/dist/payments-C44QUFXU.js.map +1 -0
  138. package/dist/redact-6W23GGJC.js +15 -0
  139. package/dist/redact-6W23GGJC.js.map +1 -0
  140. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
  141. package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
  142. package/dist/send-KVJX4XIR.js +222 -0
  143. package/dist/send-KVJX4XIR.js.map +1 -0
  144. package/dist/status-S7C3WMSH.js +115 -0
  145. package/dist/status-S7C3WMSH.js.map +1 -0
  146. package/dist/status-line-YR2T5HC4.js +86 -0
  147. package/dist/status-line-YR2T5HC4.js.map +1 -0
  148. package/dist/uninstall-HY6LKIIT.js +149 -0
  149. package/dist/uninstall-HY6LKIIT.js.map +1 -0
  150. package/dist/update-OJV22LR3.js +36 -0
  151. package/dist/update-OJV22LR3.js.map +1 -0
  152. package/dist/usdc-JK4RRFFQ.js +39 -0
  153. package/dist/usdc-JK4RRFFQ.js.map +1 -0
  154. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  155. package/dist/viemAdapter-By13KInL-X2VY6CY3.js.map +1 -0
  156. package/dist/wallet-PD2IMZDU.js +39 -0
  157. package/dist/wallet-PD2IMZDU.js.map +1 -0
  158. package/dist/wallet-kdf-worker.mjs +980 -0
  159. package/docs/agent-permissions.md +180 -0
  160. package/docs/safety-model.md +59 -0
  161. package/docs/troubleshooting.md +13 -0
  162. package/package.json +28 -19
  163. package/LICENSE +0 -21
  164. package/dist/buy-EE6SEXP6.js +0 -1598
  165. package/dist/buy-EE6SEXP6.js.map +0 -1
  166. package/dist/candidate-ERMSYYQZ.js +0 -127
  167. package/dist/candidate-ERMSYYQZ.js.map +0 -1
  168. package/dist/chunk-3OV7E5G5.js +0 -18
  169. package/dist/chunk-3OV7E5G5.js.map +0 -1
  170. package/dist/chunk-4ONXEEQL.js +0 -152
  171. package/dist/chunk-4ONXEEQL.js.map +0 -1
  172. package/dist/chunk-662MSGZB.js +0 -286
  173. package/dist/chunk-662MSGZB.js.map +0 -1
  174. package/dist/chunk-7KUW4MJD.js +0 -59
  175. package/dist/chunk-7KUW4MJD.js.map +0 -1
  176. package/dist/chunk-AWPAWHNX.js +0 -333
  177. package/dist/chunk-AWPAWHNX.js.map +0 -1
  178. package/dist/chunk-DXTQ3CSI.js +0 -171
  179. package/dist/chunk-DXTQ3CSI.js.map +0 -1
  180. package/dist/chunk-ESPNTPQ2.js +0 -207
  181. package/dist/chunk-ESPNTPQ2.js.map +0 -1
  182. package/dist/chunk-FJPLRISB.js +0 -79
  183. package/dist/chunk-FJPLRISB.js.map +0 -1
  184. package/dist/chunk-GO75V3NZ.js +0 -160
  185. package/dist/chunk-GO75V3NZ.js.map +0 -1
  186. package/dist/chunk-JPHG2JW3.js +0 -96
  187. package/dist/chunk-JPHG2JW3.js.map +0 -1
  188. package/dist/chunk-MUBUQVC3.js +0 -67
  189. package/dist/chunk-MUBUQVC3.js.map +0 -1
  190. package/dist/chunk-NCE5NSN6.js.map +0 -1
  191. package/dist/chunk-OYMYCW7J.js.map +0 -1
  192. package/dist/chunk-RY4XKNV3.js +0 -140
  193. package/dist/chunk-RY4XKNV3.js.map +0 -1
  194. package/dist/chunk-S3IGX57D.js.map +0 -1
  195. package/dist/chunk-TLCMMYLY.js +0 -126
  196. package/dist/chunk-TLCMMYLY.js.map +0 -1
  197. package/dist/chunk-UO22YNY4.js +0 -69
  198. package/dist/chunk-UO22YNY4.js.map +0 -1
  199. package/dist/chunk-XHC6FCGZ.js +0 -261
  200. package/dist/chunk-XHC6FCGZ.js.map +0 -1
  201. package/dist/chunk-XJIW7USF.js.map +0 -1
  202. package/dist/chunk-YBMMV4Y4.js.map +0 -1
  203. package/dist/chunk-YN5SHIXQ.js +0 -126
  204. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  205. package/dist/chunk-Z52RA3NC.js +0 -137
  206. package/dist/chunk-Z52RA3NC.js.map +0 -1
  207. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  208. package/dist/cli-SBXI5AMS.js.map +0 -1
  209. package/dist/config-VELDKLHY.js +0 -21
  210. package/dist/doctor-T3KWNNP2.js +0 -20
  211. package/dist/inspect-LMKOXE4Y.js +0 -96
  212. package/dist/inspect-LMKOXE4Y.js.map +0 -1
  213. package/dist/install-LEX3ENQ6.js +0 -387
  214. package/dist/install-LEX3ENQ6.js.map +0 -1
  215. package/dist/lookup-ZPN2Q67N.js +0 -129
  216. package/dist/lookup-ZPN2Q67N.js.map +0 -1
  217. package/dist/outcome-N7TAK6WR.js +0 -66
  218. package/dist/outcome-N7TAK6WR.js.map +0 -1
  219. package/dist/publish-BKBQQAW4.js +0 -1478
  220. package/dist/publish-BKBQQAW4.js.map +0 -1
  221. package/dist/usdc-JIAJW4SV.js +0 -22
  222. package/dist/wallet-CWEMYVIH.js +0 -179
  223. package/dist/wallet-CWEMYVIH.js.map +0 -1
  224. package/dist/wallet-PA54CRBL.js +0 -30
  225. package/skills/tenjin/SKILL.md +0 -199
  226. package/skills/tenjin-publish/SKILL.md +0 -111
  227. package/skills/tenjin-search/SKILL.md +0 -133
  228. /package/dist/{_esm-FEASBWRP.js.map → _esm-CE7KNONL.js.map} +0 -0
  229. /package/dist/{ccip-NQXCEK2U.js.map → alive-3J3CHOQP.js.map} +0 -0
  230. /package/dist/{ccip-XR5NE5QK.js.map → ccip-7RMRLAGV.js.map} +0 -0
  231. /package/dist/{config-VELDKLHY.js.map → ccip-NLCSCHKI.js.map} +0 -0
  232. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
  233. /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
  234. /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
  235. /package/dist/{chunk-CYOF7ROH.js.map → chunk-HPWO4O6S.js.map} +0 -0
  236. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  237. /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
  238. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
  239. /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
  240. /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
  241. /package/dist/{doctor-T3KWNNP2.js.map → config-OJQI27LT.js.map} +0 -0
  242. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
  243. /package/dist/{secp256k1-N3ZHU7LB.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  244. /package/dist/{usdc-JIAJW4SV.js.map → hook-command-D2P3ILRV.js.map} +0 -0
  245. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → install-TUCRF32I.js.map} +0 -0
  246. /package/dist/{wallet-PA54CRBL.js.map → install-identity-WHPNMNMQ.js.map} +0 -0
@@ -0,0 +1,39 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+
3
+ // src/router/names.ts
4
+ var PLUGIN_NAME = "tenjin";
5
+ var MCP_SERVER_NAME = "router";
6
+ var MARKETPLACE_NAME = "tenjin";
7
+ var PLUGIN_ID = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
8
+ var SKILLS_DIR_PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;
9
+ var PLUGIN_SERVER = `plugin:${PLUGIN_NAME}:${MCP_SERVER_NAME}`;
10
+ var TOOL_PREFIX = `mcp__plugin_${PLUGIN_NAME}_${MCP_SERVER_NAME}`;
11
+ var REQUEST_TOOL = `${TOOL_PREFIX}__request`;
12
+ var PLUGIN_HOOK_TOOL = `${TOOL_PREFIX}__hook`;
13
+ var LEGACY_MCP_SERVER_NAME = "x402";
14
+ var LEGACY_REQUEST_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__request`;
15
+ var LEGACY_HOOK_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__hook`;
16
+ function launchedByPlugin(env = process.env) {
17
+ const root = env.CLAUDE_PLUGIN_ROOT;
18
+ return typeof root === "string" && root.length > 0;
19
+ }
20
+ function requestToolName(env = process.env) {
21
+ return launchedByPlugin(env) ? REQUEST_TOOL : LEGACY_REQUEST_TOOL;
22
+ }
23
+
24
+ export {
25
+ PLUGIN_NAME,
26
+ MCP_SERVER_NAME,
27
+ MARKETPLACE_NAME,
28
+ PLUGIN_ID,
29
+ SKILLS_DIR_PLUGIN_ID,
30
+ PLUGIN_SERVER,
31
+ REQUEST_TOOL,
32
+ PLUGIN_HOOK_TOOL,
33
+ LEGACY_MCP_SERVER_NAME,
34
+ LEGACY_REQUEST_TOOL,
35
+ LEGACY_HOOK_TOOL,
36
+ launchedByPlugin,
37
+ requestToolName
38
+ };
39
+ //# sourceMappingURL=chunk-WVUSXNIE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/names.ts"],"sourcesContent":["/**\n * THE NAMES THE HARNESS KNOWS THE ROUTER BY, spelled once. `install` registers\n * the Claude Code plugin {@link PLUGIN_NAME}, whose MCP server is\n * {@link MCP_SERVER_NAME}, and Claude Code names a plugin's tools\n * `mcp__plugin_<plugin>_<server>__<tool>`. The plugin's hooks, the server's own\n * name and every hint line the hooks inject read these, so a rename moves them\n * together.\n *\n * A module of its own because the hooks need the tool name and must not load\n * `install` to get it: their chunk graph is the product's floor.\n */\nexport const PLUGIN_NAME = 'tenjin';\nexport const MCP_SERVER_NAME = 'router';\n/** The marketplace `install` adds from the package, so the plugin id is `tenjin@tenjin`. */\nexport const MARKETPLACE_NAME = 'tenjin';\nexport const PLUGIN_ID = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;\n/** The id Claude Code gives the same plugin loaded from a skills-directory folder. */\nexport const SKILLS_DIR_PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;\n/** How a plugin's `hooks.json` and `claude mcp` name the plugin's own server. */\nexport const PLUGIN_SERVER = `plugin:${PLUGIN_NAME}:${MCP_SERVER_NAME}`;\nconst TOOL_PREFIX = `mcp__plugin_${PLUGIN_NAME}_${MCP_SERVER_NAME}`;\nexport const REQUEST_TOOL = `${TOOL_PREFIX}__request`;\n/** The tool the plugin's hook legs call, which its own deny hook keeps from the model. */\nexport const PLUGIN_HOOK_TOOL = `${TOOL_PREFIX}__hook`;\n\n/**\n * THE SETTINGS-BASED INSTALL'S NAMES, for its migration and nothing else.\n * Releases up to alpha.26 registered the server as `x402` through `claude mcp\n * add` and wrote seven hook entries and two permission rules into settings.json.\n *\n * SHIM: remove on or after 2026-12-01, the first release cut 30 or more days\n * after the plugin PR 2 ships. Doctor keeps naming an unmigrated machine after.\n */\nexport const LEGACY_MCP_SERVER_NAME = 'x402';\nexport const LEGACY_REQUEST_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__request`;\nexport const LEGACY_HOOK_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__hook`;\n\n/**\n * Is this process one Claude Code launched from the plugin? Claude Code sets\n * `CLAUDE_PLUGIN_ROOT` for a plugin's MCP server and its command hooks\n * (checked on 2.1.296), and not for a server registered in `~/.claude.json`.\n */\nexport function launchedByPlugin(env: NodeJS.ProcessEnv = process.env): boolean {\n const root = env.CLAUDE_PLUGIN_ROOT;\n return typeof root === 'string' && root.length > 0;\n}\n\n/**\n * The request tool's name as THIS process's harness exposes it: the plugin's\n * tool for a server the plugin launched, and the `x402` server's tool for one a\n * settings install launched, so an offer line never names a tool the model\n * does not have.\n *\n * SHIM: the second branch goes on or after 2026-12-01 (see\n * {@link LEGACY_MCP_SERVER_NAME}); the name is then always {@link REQUEST_TOOL}.\n */\nexport function requestToolName(env: NodeJS.ProcessEnv = process.env): string {\n return launchedByPlugin(env) ? REQUEST_TOOL : LEGACY_REQUEST_TOOL;\n}\n"],"mappings":";;;AAWO,IAAM,cAAc;AACpB,IAAM,kBAAkB;AAExB,IAAM,mBAAmB;AACzB,IAAM,YAAY,GAAG,WAAW,IAAI,gBAAgB;AAEpD,IAAM,uBAAuB,GAAG,WAAW;AAE3C,IAAM,gBAAgB,UAAU,WAAW,IAAI,eAAe;AACrE,IAAM,cAAc,eAAe,WAAW,IAAI,eAAe;AAC1D,IAAM,eAAe,GAAG,WAAW;AAEnC,IAAM,mBAAmB,GAAG,WAAW;AAUvC,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB,QAAQ,sBAAsB;AAC1D,IAAM,mBAAmB,QAAQ,sBAAsB;AAOvD,SAAS,iBAAiB,MAAyB,QAAQ,KAAc;AAC9E,QAAM,OAAO,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,SAAS;AACnD;AAWO,SAAS,gBAAgB,MAAyB,QAAQ,KAAa;AAC5E,SAAO,iBAAiB,GAAG,IAAI,eAAe;AAChD;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+
3
+ // src/lib/grade.ts
4
+ var ENDED_AFTER_MS = 30 * 6e4;
5
+ var AGENT_ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
6
+
7
+ export {
8
+ AGENT_ID_RE
9
+ };
10
+ //# sourceMappingURL=chunk-XKESD27X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/grade.ts"],"sourcesContent":["import { CliError } from './errors';\n\n/**\n * Did the agent USE what a hook arm showed it? The transcript is the only place\n * that answer exists.\n *\n * The arms record what they delivered (`fires`/`legs`), and the shelf records\n * what it served, but neither can see what happened next: the finding lands as\n * additional context in the agent's turn, and from there it is either acted on\n * or it is not. Nobody reports that, so without this the loop has no measure of\n * its own precision.\n *\n * WHAT COUNTS AS EVIDENCE, and why it is only ever a TOOL INPUT. An agent that\n * says \"as the Tenjin note suggests\" in prose has said nothing checkable — the\n * words are cheap, the sentence is generated beside a hundred others, and prose\n * agreeing with an injection is exactly what an injection makes likely whether\n * or not it helped. A tool call is a decision the agent spent something on. So\n * this reads two kinds of row and no others: the `hook_additional_context`\n * attachment that carries the injection (the anchor), and every later\n * `tool_use` block's input, serialized whole so a command, an edit's new text\n * and a written file all read the same way.\n *\n * THREE VERDICTS FOR \"USED\", TWO WEAK. Explicit `tenjin read|inspect <id>`, or\n * the injected url appearing in a tool input, is the agent following the\n * pointer: that is `read`, and it counts anywhere later in the session,\n * because a piece bought twenty tool calls after it was shown is still a piece\n * the injection sold. A backtick span copied out of the injected text is much\n * weaker — it may be a command the agent would have run anyway — so it counts\n * only inside {@link SPAN_WINDOW} tool calls of the anchor, needs at least two\n * words, and is reported to the shelf as `partially_used` rather than `used`.\n * `likely` is weaker again: a command head or file basename named anywhere in\n * the note's prose, with no backticks at all, matched the same way and ranked\n * below `span` — see {@link likelyTokens}.\n *\n * A SPAN OR A LIKELY TOKEN IS EXCLUDED WHEN THE SESSION ALREADY USED IT BEFORE\n * THE INJECTION (tenjin-agent#254a). Boilerplate a machine writes into every\n * subagent work order — `CI=true pnpm format:check` and the like — will always\n * reappear in the next tool call whether or not the injection ran, so a match\n * that cannot see behind the anchor cannot tell \"copied because shown\" from\n * \"was going to type this anyway\". `judge()` is handed the {@link SPAN_WINDOW}\n * tool calls BEFORE the anchor as well as after, and a candidate already\n * present there earns no credit — matched at a token boundary, not by plain\n * substring, so a longer pre-injection token cannot erase credit for a\n * shorter genuine one. This applies to `span` and `likely` only: `read` is a\n * command naming this specific piece, which nothing pre-injection could have\n * done by coincidence.\n *\n * NOTHING IS NOT REJECTION UNTIL THE SESSION IS OVER. A row whose session is\n * still running has simply not been answered yet, and grading it `rejected`\n * would post a verdict the next tool call could contradict. So \"nothing matched\"\n * becomes `rejected` only once the session has ended — `sessions.ended_at`, or a\n * transcript nothing has written to for {@link ENDED_AFTER_MS}.\n *\n * RELAYED ROWS ANCHOR ON THE FIRST TOOL CALL. The subagent arm hands its finding\n * to a child at SubagentStart, and that text reaches no transcript at all: the\n * child is given it as its opening context, and neither the parent's file nor\n * the child's records a `hook_additional_context` row for it. So there is no\n * anchor to find, and there does not need to be — the pointer preceded every\n * call the child ever made, which makes the child's FIRST tool call evidence\n * rather than the row after the anchor. {@link gradeRelayed} judges from there,\n * inclusively, while {@link gradeInjection} keeps its exclusive `anchor + 1`.\n *\n * A relayed row also has no injected text on disk to take spans from — the arm\n * renders a title, a price and possibly a fetched body, and stores none of it —\n * so its span evidence comes from the piece's TITLE alone, which is usually no\n * spans at all. Relayed findings are therefore judged almost entirely on the\n * strong evidence (an explicit read, or the url), which is the right way round.\n * Storing the injected text is a second schema change and is not this one.\n *\n * The functions here are pure over parsed rows, except the two that touch the\n * filesystem at the bottom; the command in commands/grade.ts owns the store.\n */\n\n/** How many tool calls after the anchor a copied span may still be evidence. */\nexport const SPAN_WINDOW = 10;\n\n/** A transcript nothing has appended to for this long belongs to a session that\n * is over, whether or not a Stop hook ever stamped `ended_at` (a crashed or\n * killed harness never does). */\nexport const ENDED_AFTER_MS = 30 * 60_000;\n\n/** How many tool inputs `--explain` shows for a rejected row, and how much of\n * each: enough to see what the agent did instead, not a transcript dump. */\nconst EVIDENCE_ROWS = 3;\nconst EVIDENCE_CHARS = 200;\n\n/** A session id is used as a filename, so it is checked like one. */\nconst SESSION_ID_RE = /^[A-Za-z0-9-]{1,80}$/;\n\n/**\n * An agent id becomes a filename too (`agent-<id>.jsonl`), so it gets the same\n * treatment as a session id.\n *\n * THE ONLY DEFINITION, and every other reader takes it from here rather than\n * restating it: `prelude` interpolates it into the rendered scripts, where\n * `identityOf` and the capture ask's flag splice both read that one declaration,\n * and `publish --agent` tests against this constant directly. The splice and\n * `--agent` used to share a wider `shell-safe` copy admitting `.` and `:` on the\n * reasoning that only shell metacharacters matter in a command line: `:` is the\n * separator `agentKey` joins on, so an id carrying one keys a child's rows into\n * another child's range, and an id one reader accepts and another refuses is a\n * row that can never be graded or reported.\n */\nexport const AGENT_ID_RE = /^[A-Za-z0-9_-]{1,128}$/;\n\n/** The only two row kinds that decide anything; see the module note. */\nexport interface TranscriptRow {\n /** 1-based line number in the JSONL, for `--explain`. */\n line: number;\n kind: 'context' | 'tool_use';\n text: string;\n}\n\nexport interface GradeTarget {\n resourceId: string | null;\n url: string | null;\n title: string | null;\n}\n\nexport type Verdict =\n | { outcome: 'used'; by: 'read' | 'span' | 'likely'; evidence: string }\n | { outcome: 'rejected'; by: 'none'; evidence: string[] }\n | { outcome: 'unobserved'; by: 'none' }\n /** Still open: the session may yet answer, so nothing is written. */\n | { outcome: null; evidence: string[] };\n\n/**\n * The transcript, reduced to the rows that can decide a verdict.\n *\n * A malformed line is skipped rather than failing the parse: a transcript being\n * appended to while this runs can end mid-line, and one truncated row is not a\n * reason to refuse to grade a session.\n *\n * `isCompactSummary` rows are dropped. A compaction REPLAYS earlier tool calls\n * into a summary the assistant then carries, so counting them would let one\n * injection be \"used\" by the echo of a call that happened before it was shown.\n */\nexport function parseTranscript(jsonl: string): TranscriptRow[] {\n const rows: TranscriptRow[] = [];\n const lines = jsonl.split('\\n');\n for (let i = 0; i < lines.length; i += 1) {\n const raw = lines[i];\n if (raw === undefined || raw.length === 0) continue;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n continue;\n }\n if (!isRecord(parsed)) continue;\n const line = i + 1;\n const attachment = parsed.attachment;\n if (isRecord(attachment) && attachment.type === 'hook_additional_context') {\n rows.push({ line, kind: 'context', text: contextText(attachment.content) });\n continue;\n }\n if (parsed.type !== 'assistant' || parsed.isCompactSummary === true) continue;\n const message = parsed.message;\n if (!isRecord(message) || !Array.isArray(message.content)) continue;\n for (const block of message.content) {\n if (!isRecord(block) || block.type !== 'tool_use') continue;\n rows.push({ line, kind: 'tool_use', text: JSON.stringify(block.input ?? null) });\n }\n }\n return rows;\n}\n\n/**\n * Where the injection landed, as an index into `rows`, or -1.\n *\n * THE FIRST MATCH, not the nearest one after the row's timestamp. The\n * `injections_shown_once` index makes one injected row per (session,\n * resourceId), so there is only ever one context row naming a given piece, and\n * matching it by content beats matching it by clock: the hook's `at` and the\n * transcript's line order are written by different processes.\n *\n * Id, then url, then title, weakest last: a title is display text that could\n * appear in an unrelated context row, so it is what is tried when the piece has\n * nothing more specific to be found by.\n */\nexport function findAnchor(rows: TranscriptRow[], target: GradeTarget): number {\n for (const needle of [target.resourceId, target.url, target.title]) {\n if (needle === null || needle.length === 0) continue;\n const at = rows.findIndex((row) => row.kind === 'context' && row.text.includes(needle));\n if (at !== -1) return at;\n }\n return -1;\n}\n\n/**\n * The backtick spans in the injected text worth looking for later: at least two\n * whitespace-separated words, deduped.\n *\n * TWO WORDS IS THE FLOOR because one is noise. A note names `pnpm`, `useEffect`\n * or a filename, the agent types the same token in the next command, and a\n * one-word rule calls that reuse — on a machine where the agent was going to\n * type it anyway. Two words is a phrase somebody copied.\n */\nexport function backtickSpans(text: string): string[] {\n const spans = new Set<string>();\n for (const match of text.matchAll(/`([^`\\n]+)`/g)) {\n const span = (match[1] ?? '').trim();\n if (span.split(/\\s+/).filter((w) => w.length > 0).length >= 2) spans.add(span);\n }\n return [...spans];\n}\n\n/** A candidate token has to carry its own punctuation to qualify — see\n * {@link likelyTokens}. */\nconst LIKELY_TOKEN_RE = /\\b[A-Za-z][A-Za-z0-9]*(?:[:_./-][A-Za-z0-9]+)+\\b/g;\nconst LIKELY_MIN_CHARS = 4;\n/** Compounds common enough in ordinary prose to look like a command or a path\n * but never are one. Not a promise of completeness — the punctuation\n * requirement in {@link LIKELY_TOKEN_RE} is what does most of the work; this\n * catches the handful of hyphenated English words that would otherwise slip\n * through it. */\nconst LIKELY_GENERIC = new Set([\n 're-run',\n 're-runs',\n 're-ran',\n 're-executes',\n 're-executed',\n 'up-to-date',\n 'well-known',\n 'self-contained',\n 'read-only',\n 'long-lived',\n 'built-in',\n 'one-word',\n 'two-word',\n 'so-called',\n 'case-by-case',\n 'pre-commit',\n 'post-commit',\n 'e.g',\n 'i.e',\n // The injection's OWN scaffolding, not anything a seller wrote: PUBLIC_OPENER,\n // CLOSING_LINE and the body fence itself (`--- tenjin-body <nonce> ---`) from\n // hooks/prose.ts land in every full-form injection, so without these three\n // `likelyTokens(fullForm(...))` always nets its own boilerplate as a\n // candidate.\n 'third-party',\n 're-verifying',\n 'tenjin-body',\n]);\n\n/**\n * Command heads and file basenames named anywhere in `text`, with no backticks\n * at all — the weaker, single-token net {@link judge} tries below `span` for a\n * note that describes a command in prose instead of quoting it\n * (tenjin-agent#254b: \"gh run rerun\" named only in a title, \"pnpm check\" named\n * only as English words, each with a tool call that actually followed it).\n *\n * CONSERVATIVE ON PURPOSE. A bare English word (\"run\", \"check\", or \"pnpm\" on\n * its own) is exactly what the two-word floor on {@link backtickSpans} already\n * excludes as noise the agent was going to type anyway; a single-token net\n * that took bare words would reopen that hole wider than the floor closes it.\n * So a candidate must carry its own internal structure — a colon, dot, slash,\n * underscore or hyphen joining two word-shaped halves, the way a subcommand\n * (`db:generate`), a filename (`ci.yml`), or a path segment does — which a\n * plain English word essentially never does, and it must be at least\n * {@link LIKELY_MIN_CHARS} long.\n *\n * BACKTICK CONTENT IS STRIPPED FIRST, so a span already tried (and ranked\n * above this) is never re-offered as weaker evidence for the same text.\n *\n * THE PIECE'S OWN ID AND URL ARE EXCLUDED. Those already have a dedicated,\n * stronger `read` verdict; re-crediting them here would rank a followed\n * pointer BELOW a copied identifier instead of above it.\n */\nexport function likelyTokens(text: string, target: GradeTarget): string[] {\n const stripped = text.replace(/`[^`\\n]+`/g, ' ');\n const tokens = new Set<string>();\n for (const match of stripped.matchAll(LIKELY_TOKEN_RE)) {\n const token = match[0];\n if (token.length < LIKELY_MIN_CHARS) continue;\n if (LIKELY_GENERIC.has(token.toLowerCase())) continue;\n // A FRAGMENT counts as the id or the url, not just an exact match: a uuid\n // is all hyphens and hex, so the token regex can walk in from the middle\n // of one (`bbbb-cccc-dddd-...`) and still name nothing but the piece the\n // `read` tier already owns.\n if (target.resourceId !== null && target.resourceId.includes(token)) continue;\n if (target.url !== null && target.url.length > 0 && target.url.includes(token)) continue;\n tokens.add(token);\n }\n return [...tokens];\n}\n\n/**\n * The verdict for one injection, given its transcript and its anchor.\n *\n * Read beats span: both may be present, and \"the agent went and read the piece\"\n * is the stronger claim, so it is the one reported.\n */\nexport function gradeInjection(\n rows: TranscriptRow[],\n anchor: number,\n target: GradeTarget,\n opts: { ended: boolean },\n): Verdict {\n if (anchor < 0 || anchor >= rows.length) return { outcome: 'unobserved', by: 'none' };\n // EXCLUSIVE: the anchor row IS the injection, so the calls that can answer for\n // it are the ones after it. The ones BEFORE it are what a span or a likely\n // token has to clear to earn credit — see the module note on #254a. Bounded\n // to the same SPAN_WINDOW as `after`: a session's first call from an hour\n // before the injection is not \"standing boilerplate\" any more than a session's\n // fiftieth call after it is still \"the injection in view\" — both are the same\n // claim, made symmetrically.\n const before = rows\n .slice(0, anchor)\n .filter((row) => row.kind === 'tool_use')\n .slice(-SPAN_WINDOW);\n const after = rows.slice(anchor + 1).filter((row) => row.kind === 'tool_use');\n const text = rows[anchor]?.text ?? '';\n return judge(after, before, backtickSpans(text), likelyTokens(text, target), target, opts.ended);\n}\n\n/**\n * Where a relayed finding's evidence starts: the first `tool_use` row, or -1.\n *\n * The caller reports it as the anchor line under `--explain`, so a verdict on a\n * child still names the row it was read from.\n */\nexport function firstToolCall(rows: TranscriptRow[]): number {\n return rows.findIndex((row) => row.kind === 'tool_use');\n}\n\n/**\n * The verdict for a finding RELAYED to a subagent, given that child's own\n * transcript.\n *\n * INCLUSIVE OF THE FIRST CALL, and with no anchor at all — see the module note.\n * A child that made no tool calls has done nothing that could be evidence, so it\n * is `rejected` once it is over and open while it runs, exactly as an\n * unanswered main-session row is.\n */\nexport function gradeRelayed(\n rows: TranscriptRow[],\n target: GradeTarget,\n opts: { ended: boolean },\n): Verdict {\n const calls = rows.filter((row) => row.kind === 'tool_use');\n // The title is the only injected text this row left on disk; usually it holds\n // no two-word backtick span at all, and that is the documented limit of what\n // a relayed row can be judged `span` or `likely` on. No pre-injection\n // exclusion here: the pointer preceded the child's first call, so there is no\n // \"before\" inside this transcript for anything to have leaked from.\n const title = target.title ?? '';\n return judge(calls, [], backtickSpans(title), likelyTokens(title, target), target, opts.ended);\n}\n\n/**\n * The evidence rules themselves, over whichever tool calls the caller decided\n * are eligible. Shared byte-for-byte by both verdict functions, so a relayed row\n * and a main-session row can never drift into being judged by different rules.\n *\n * Read beats span beats likely: each may be present alongside a weaker one, and\n * the strongest claim actually supported is the one reported.\n *\n * `before` is up to {@link SPAN_WINDOW} tool calls that happened in this same\n * session BEFORE the injection (empty for a relayed row, which has none). A\n * span or a likely token already present there is boilerplate the session was\n * going to write anyway, so it earns no credit here — tenjin-agent#254a.\n */\nfunction judge(\n after: TranscriptRow[],\n before: TranscriptRow[],\n spans: string[],\n likely: string[],\n target: GradeTarget,\n ended: boolean,\n): Verdict {\n const readRe = target.resourceId === null ? null : readCommandRe(target.resourceId);\n for (const row of after) {\n if (readRe !== null && readRe.test(row.text)) {\n return { outcome: 'used', by: 'read', evidence: cap(row.text) };\n }\n if (target.url !== null && target.url.length > 0 && row.text.includes(target.url)) {\n return { outcome: 'used', by: 'read', evidence: cap(row.text) };\n }\n }\n // A TOKEN BOUNDARY MATCH, not a substring, ON BOTH SIDES: `db:generate` is a\n // plain substring of `db:generate-types`, so a pre-injection call to the\n // latter must not erase credit for a genuine post-injection call to the\n // former (the `before` side) — but by the same logic, a post-injection call\n // to `db:generate-types` must not be credited as a hit for a note that only\n // ever named `db:generate` (the `after` side): that is the identical\n // boilerplate #254a exists to exclude, just spelled with the shorter token\n // as the candidate instead of the longer one. Plain `includes` on one side\n // and a boundary match on the other opens exactly that gap — fixed by\n // sharing one boundary test both directions (tenjin-agent#276 review round\n // 2, major). The class in the lookaround is exactly {@link\n // LIKELY_TOKEN_RE}'s own — a colon, dot, slash, underscore or hyphen still\n // extends a token, so this only rules out landing inside a longer one, not\n // a real reappearance next to punctuation.\n const atBoundary = (haystack: string, candidate: string): boolean =>\n new RegExp(`(?<![A-Za-z0-9:_./-])${escapeRe(candidate)}(?![A-Za-z0-9:_./-])`).test(haystack);\n const seenBefore = (candidate: string): boolean =>\n before.some((row) => atBoundary(row.text, candidate));\n for (const row of after.slice(0, SPAN_WINDOW)) {\n const hit = spans.find((span) => !seenBefore(span) && atBoundary(row.text, span));\n // Capped like every other evidence string here: the span is copied out of\n // injected text, which came off a shelf, and `--explain` prints it.\n if (hit !== undefined) return { outcome: 'used', by: 'span', evidence: cap(hit) };\n }\n for (const row of after.slice(0, SPAN_WINDOW)) {\n const hit = likely.find((token) => !seenBefore(token) && atBoundary(row.text, token));\n if (hit !== undefined) return { outcome: 'used', by: 'likely', evidence: cap(hit) };\n }\n const evidence = after.slice(0, EVIDENCE_ROWS).map(cap);\n return ended ? { outcome: 'rejected', by: 'none', evidence } : { outcome: null, evidence };\n}\n\n/** `7d`, `24h`, `30m` as milliseconds. Anything else is a usage error rather\n * than a silent default, so a typo cannot quietly widen or narrow a sweep. */\nexport function parseSince(text: string): number {\n const match = /^(\\d+)([dhm])$/.exec(text.trim());\n const value = match === null ? 0 : Number(match[1]);\n if (match === null || value <= 0) {\n throw new CliError('USAGE', `Invalid --since window: ${JSON.stringify(text)}`, {\n fix: 'Pass a window like 7d, 24h or 30m.',\n });\n }\n const unit = { d: 24 * 60 * 60_000, h: 60 * 60_000, m: 60_000 }[match[2] as 'd' | 'h' | 'm'];\n return value * unit;\n}\n\n/**\n * Where a session's transcript is, or WHY there is none.\n *\n * `absent` is a FACT ABOUT THE SESSION: the projects directory was listed and\n * holds no file for it. `unreadable` is a fact about this machine right now —\n * no projects directory, a home that is not mounted, a permissions change\n * mid-run — and says nothing about the session at all.\n */\nexport type TranscriptLookup =\n { kind: 'found'; path: string } | { kind: 'absent' } | { kind: 'unreadable'; reason: string };\n\n/**\n * The transcript for a session, or for one subagent of it, or why it was not\n * found.\n *\n * BY READDIR, not by mangling the cwd into a directory name. Claude Code names\n * the project directory from the working directory with a substitution this CLI\n * would have to reimplement and keep in step (and which a worktree, a symlinked\n * home or a renamed checkout each break differently); the session id is a uuid\n * and is unique across them, so one listing finds it wherever it landed.\n *\n * WITH AN AGENT ID IT IS A DIFFERENT FILE, not a different search: a subagent\n * writes to `<session>/subagents/agent-<id>.jsonl` beside the parent's\n * `<session>.jsonl`, under the same project directory. The child's tool calls\n * appear in NO parent file, so a row stamped with an agent id is answered only\n * here.\n *\n * THE TWO NEGATIVE ANSWERS ARE NOT THE SAME ANSWER, and collapsing them to\n * `null` is how a transient fault becomes permanent: the caller turns \"no\n * transcript\" into `unobserved`, `unobserved` is a verdict, and a verdict is\n * never re-graded. One run under a home directory that could not be read would\n * have closed every open row on the machine as never-seen, with no way back.\n */\nexport async function findTranscript(\n homeDir: string,\n sessionId: string,\n agentId: string | null = null,\n): Promise<TranscriptLookup> {\n // An id that cannot be a filename names no transcript in any project\n // directory, now or ever: that is absence, and it is permanent.\n if (!SESSION_ID_RE.test(sessionId)) return { kind: 'absent' };\n if (agentId !== null && !AGENT_ID_RE.test(agentId)) return { kind: 'absent' };\n const { readdir, stat } = await import('node:fs/promises');\n const { join } = await import('node:path');\n const projects = join(homeDir, '.claude', 'projects');\n let dirs: string[];\n try {\n dirs = (await readdir(projects, { withFileTypes: true }))\n .filter((e) => e.isDirectory())\n .map((e) => e.name);\n } catch (err) {\n // A missing projects directory included: a machine where the harness has\n // never run, or has not run yet, has not told us anything about this row.\n return { kind: 'unreadable', reason: errorReason(err) };\n }\n let blocked: string | null = null;\n for (const dir of dirs) {\n const path =\n agentId === null\n ? join(projects, dir, `${sessionId}.jsonl`)\n : join(projects, dir, sessionId, 'subagents', `agent-${agentId}.jsonl`);\n try {\n if ((await stat(path)).isFile()) return { kind: 'found', path };\n } catch (err) {\n // ENOENT is the ordinary answer — the session is simply not in THIS\n // project directory, and on the child path its `<session>/` directory may\n // not exist at all (ENOENT, or ENOTDIR where a plain file sits where the\n // directory would be). Anything else is a directory that could be hiding\n // it, so the sweep can no longer claim the file is absent.\n const code = errorCode(err);\n if (code !== 'ENOENT' && code !== 'ENOTDIR') blocked ??= errorReason(err);\n }\n }\n return blocked === null ? { kind: 'absent' } : { kind: 'unreadable', reason: blocked };\n}\n\n/** Has nothing been appended to this transcript for {@link ENDED_AFTER_MS}? The\n * half of \"the session is over\" that survives a harness which never stopped\n * cleanly and so never stamped `ended_at`. Unreadable reads as NOT idle: an\n * unknown must never manufacture a `rejected`. */\nexport async function transcriptIdle(path: string, nowMs: number): Promise<boolean> {\n try {\n const { stat } = await import('node:fs/promises');\n return nowMs - (await stat(path)).mtimeMs > ENDED_AFTER_MS;\n } catch {\n return false;\n }\n}\n\n/** An errno if the platform gave one, else the message: short enough to print\n * on the one `--explain` line that says why a row was left alone. Exported so\n * the caller's own read of the file it was handed reports failures in the same\n * words this one does. */\nexport function errorReason(err: unknown): string {\n const code = errorCode(err);\n if (code !== null) return code;\n return cap(err instanceof Error ? err.message : 'unknown error');\n}\n\nfunction errorCode(err: unknown): string | null {\n return isRecord(err) && typeof err.code === 'string' ? err.code : null;\n}\n\nfunction readCommandRe(resourceId: string): RegExp {\n return new RegExp(`tenjin\\\\s+(?:read|inspect)\\\\s+${escapeRe(resourceId)}`);\n}\n\nfunction escapeRe(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction cap(row: TranscriptRow | string): string {\n const text = typeof row === 'string' ? row : row.text;\n return text.length > EVIDENCE_CHARS ? `${text.slice(0, EVIDENCE_CHARS)}…` : text;\n}\n\n/**\n * The injected text, whatever shape the attachment carried it in: a bare string,\n * an array of strings, or an array of `{ type: 'text', text }` blocks. All three\n * appear, and the anchor match only needs the words.\n */\nfunction contextText(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n const parts: string[] = [];\n for (const item of content) {\n if (typeof item === 'string') parts.push(item);\n else if (isRecord(item) && typeof item.text === 'string') parts.push(item.text);\n }\n return parts.join('\\n');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;AA+EO,IAAM,iBAAiB,KAAK;AAwB5B,IAAM,cAAc;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  keccak_256
4
- } from "./chunk-HIVZG55D.js";
4
+ } from "./chunk-KG3D7FIF.js";
5
5
  import {
6
6
  bytesToHex
7
- } from "./chunk-5CLSD5YN.js";
7
+ } from "./chunk-BPMWXTFX.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __require,
@@ -7803,4 +7803,4 @@ export {
7803
7803
  p2 as p,
7804
7804
  m2 as m
7805
7805
  };
7806
- //# sourceMappingURL=chunk-HSDCI7OV.js.map
7806
+ //# sourceMappingURL=chunk-XZKD7DIF.js.map
@@ -7,14 +7,16 @@ import {
7
7
  defineTransactionReceipt,
8
8
  formatTransaction,
9
9
  http
10
- } from "./chunk-UGX7YPX2.js";
10
+ } from "./chunk-AWQPGIR6.js";
11
11
  import {
12
12
  serializeTransaction,
13
13
  toRlp
14
- } from "./chunk-NCE5NSN6.js";
14
+ } from "./chunk-N35E6CM2.js";
15
15
  import {
16
+ decodeFunctionData,
17
+ encodeFunctionData,
16
18
  erc20Abi
17
- } from "./chunk-ZMHYXMO6.js";
19
+ } from "./chunk-5IEP5EGE.js";
18
20
  import {
19
21
  InvalidAddressError,
20
22
  concatHex,
@@ -22,7 +24,10 @@ import {
22
24
  hexToNumber,
23
25
  isAddress,
24
26
  toHex
25
- } from "./chunk-YALGASEU.js";
27
+ } from "./chunk-EGELTSPU.js";
28
+ import {
29
+ USDC_ADDRESS
30
+ } from "./chunk-O2FRQ2L2.js";
26
31
 
27
32
  // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/op-stack/contracts.js
28
33
  var contracts = {
@@ -197,21 +202,125 @@ var basePreconf = /* @__PURE__ */ defineChain({
197
202
  });
198
203
 
199
204
  // src/lib/usdc.ts
200
- var USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
205
+ var USDC_ADDRESS2 = USDC_ADDRESS;
201
206
  var USDC_DECIMALS = 6;
202
207
  async function getUsdcBalance(address, rpcUrl) {
203
208
  const client = createPublicClient({ chain: base, transport: http(rpcUrl) });
204
209
  return client.readContract({
205
- address: USDC_ADDRESS,
210
+ address: USDC_ADDRESS2,
206
211
  abi: erc20Abi,
207
212
  functionName: "balanceOf",
208
213
  args: [address]
209
214
  });
210
215
  }
216
+ var SEND_GAS_CAP = 150000n;
217
+ var SEND_MAX_FEE_PER_GAS_CAP = 10000000000n;
218
+ var SEND_MAX_PRIORITY_FEE_CAP = 2000000000n;
219
+ var FeeCapExceededError = class extends Error {
220
+ constructor(field, value, cap) {
221
+ super(`${field} estimate ${value} exceeds the send ceiling ${cap}`);
222
+ this.name = "FeeCapExceededError";
223
+ }
224
+ };
225
+ var SendRevertedError = class extends Error {
226
+ constructor(txHash) {
227
+ super(`Transaction ${txHash} reverted`);
228
+ this.txHash = txHash;
229
+ this.name = "SendRevertedError";
230
+ }
231
+ txHash;
232
+ };
233
+ var SendPendingError = class extends Error {
234
+ constructor(txHash) {
235
+ super(`Transaction ${txHash} was broadcast but not confirmed in time`);
236
+ this.txHash = txHash;
237
+ this.name = "SendPendingError";
238
+ }
239
+ txHash;
240
+ };
241
+ async function prepareUsdcSend({
242
+ from,
243
+ to,
244
+ amountAtomic,
245
+ rpcUrl
246
+ }) {
247
+ const client = createPublicClient({ chain: base, transport: http(rpcUrl) });
248
+ const data = encodeFunctionData({
249
+ abi: erc20Abi,
250
+ functionName: "transfer",
251
+ args: [to, amountAtomic]
252
+ });
253
+ const [nonce, gas, fees, ethBalanceWei] = await Promise.all([
254
+ client.getTransactionCount({ address: from, blockTag: "pending" }),
255
+ client.estimateGas({ account: from, to: USDC_ADDRESS2, data }),
256
+ client.estimateFeesPerGas(),
257
+ client.getBalance({ address: from })
258
+ ]);
259
+ assertUnderCap("gas", gas, SEND_GAS_CAP);
260
+ assertUnderCap("maxFeePerGas", fees.maxFeePerGas, SEND_MAX_FEE_PER_GAS_CAP);
261
+ assertUnderCap("maxPriorityFeePerGas", fees.maxPriorityFeePerGas, SEND_MAX_PRIORITY_FEE_CAP);
262
+ return {
263
+ to,
264
+ amountAtomic,
265
+ data,
266
+ nonce,
267
+ gas,
268
+ maxFeePerGas: fees.maxFeePerGas,
269
+ maxPriorityFeePerGas: fees.maxPriorityFeePerGas,
270
+ feeWei: gas * fees.maxFeePerGas,
271
+ ethBalanceWei
272
+ };
273
+ }
274
+ async function broadcastUsdcSend({
275
+ signer,
276
+ prepared,
277
+ rpcUrl,
278
+ receiptTimeoutMs = 12e4
279
+ }) {
280
+ const client = createPublicClient({ chain: base, transport: http(rpcUrl) });
281
+ const decoded = decodeFunctionData({ abi: erc20Abi, data: prepared.data });
282
+ if (decoded.functionName !== "transfer" || decoded.args[0].toLowerCase() !== prepared.to.toLowerCase() || decoded.args[1] !== prepared.amountAtomic) {
283
+ throw new Error(
284
+ "Prepared calldata does not decode to the previewed recipient and amount; nothing was signed."
285
+ );
286
+ }
287
+ const serializedTransaction = await signer.signTransaction({
288
+ type: "eip1559",
289
+ chainId: base.id,
290
+ to: USDC_ADDRESS2,
291
+ // Explicitly zero: an ERC-20 transfer carries no native value (test-pinned).
292
+ value: 0n,
293
+ data: prepared.data,
294
+ nonce: prepared.nonce,
295
+ gas: prepared.gas,
296
+ maxFeePerGas: prepared.maxFeePerGas,
297
+ maxPriorityFeePerGas: prepared.maxPriorityFeePerGas
298
+ });
299
+ const txHash = await client.sendRawTransaction({ serializedTransaction });
300
+ let receipt;
301
+ try {
302
+ receipt = await client.waitForTransactionReceipt({ hash: txHash, timeout: receiptTimeoutMs });
303
+ } catch {
304
+ throw new SendPendingError(txHash);
305
+ }
306
+ if (receipt.status !== "success") throw new SendRevertedError(txHash);
307
+ return txHash;
308
+ }
309
+ function assertUnderCap(field, value, cap) {
310
+ if (value > cap) throw new FeeCapExceededError(field, value, cap);
311
+ }
211
312
 
212
313
  export {
213
- USDC_ADDRESS,
314
+ USDC_ADDRESS2 as USDC_ADDRESS,
214
315
  USDC_DECIMALS,
215
- getUsdcBalance
316
+ getUsdcBalance,
317
+ SEND_GAS_CAP,
318
+ SEND_MAX_FEE_PER_GAS_CAP,
319
+ SEND_MAX_PRIORITY_FEE_CAP,
320
+ FeeCapExceededError,
321
+ SendRevertedError,
322
+ SendPendingError,
323
+ prepareUsdcSend,
324
+ broadcastUsdcSend
216
325
  };
217
- //# sourceMappingURL=chunk-XJIW7USF.js.map
326
+ //# sourceMappingURL=chunk-YFQOA5AU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/op-stack/contracts.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/op-stack/formatters.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/op-stack/serializers.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/op-stack/chainConfig.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/chains/definitions/base.ts","../src/lib/usdc.ts"],"sourcesContent":["import type { Chain } from '../types/chain.js'\n\n/**\n * Predeploy contracts for OP Stack.\n * @see https://github.com/ethereum-optimism/optimism/blob/develop/specs/predeploys.md\n */\nexport const contracts = {\n gasPriceOracle: { address: '0x420000000000000000000000000000000000000F' },\n l1Block: { address: '0x4200000000000000000000000000000000000015' },\n l2CrossDomainMessenger: {\n address: '0x4200000000000000000000000000000000000007',\n },\n l2Erc721Bridge: { address: '0x4200000000000000000000000000000000000014' },\n l2StandardBridge: { address: '0x4200000000000000000000000000000000000010' },\n l2ToL1MessagePasser: {\n address: '0x4200000000000000000000000000000000000016',\n },\n} as const satisfies Chain['contracts']\n","import type { ChainFormatters } from '../types/chain.js'\nimport type { RpcTransaction } from '../types/rpc.js'\nimport { hexToBigInt, hexToNumber } from '../utils/encoding/fromHex.js'\nimport { defineBlock } from '../utils/formatters/block.js'\nimport {\n defineTransaction,\n formatTransaction,\n} from '../utils/formatters/transaction.js'\nimport { defineTransactionReceipt } from '../utils/formatters/transactionReceipt.js'\nimport type { OpStackBlock, OpStackRpcBlock } from './types/block.js'\nimport type {\n OpStackRpcTransaction,\n OpStackRpcTransactionReceipt,\n OpStackTransaction,\n OpStackTransactionReceipt,\n} from './types/transaction.js'\n\nexport const formatters = {\n block: /*#__PURE__*/ defineBlock({\n format(args: OpStackRpcBlock): OpStackBlock {\n const transactions = args.transactions?.map((transaction) => {\n if (typeof transaction === 'string') return transaction\n const formatted = formatTransaction(\n transaction as RpcTransaction,\n ) as OpStackTransaction\n if (formatted.typeHex === '0x7e') {\n formatted.isSystemTx = transaction.isSystemTx\n formatted.mint = transaction.mint\n ? hexToBigInt(transaction.mint)\n : undefined\n formatted.sourceHash = transaction.sourceHash\n formatted.type = 'deposit'\n }\n return formatted\n })\n return {\n transactions,\n stateRoot: args.stateRoot,\n } as OpStackBlock\n },\n }),\n transaction: /*#__PURE__*/ defineTransaction({\n format(args: OpStackRpcTransaction): OpStackTransaction {\n const transaction = {} as OpStackTransaction\n if (args.type === '0x7e') {\n transaction.isSystemTx = args.isSystemTx\n transaction.mint = args.mint ? hexToBigInt(args.mint) : undefined\n transaction.sourceHash = args.sourceHash\n transaction.type = 'deposit'\n }\n return transaction\n },\n }),\n transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({\n format(args: OpStackRpcTransactionReceipt): OpStackTransactionReceipt {\n return {\n ...(args.depositNonce\n ? { depositNonce: hexToBigInt(args.depositNonce) }\n : {}),\n ...(args.depositReceiptVersion\n ? { depositReceiptVersion: hexToNumber(args.depositReceiptVersion) }\n : {}),\n l1GasPrice: args.l1GasPrice ? hexToBigInt(args.l1GasPrice) : null,\n l1GasUsed: args.l1GasUsed ? hexToBigInt(args.l1GasUsed) : null,\n l1Fee: args.l1Fee ? hexToBigInt(args.l1Fee) : null,\n l1FeeScalar: args.l1FeeScalar ? Number(args.l1FeeScalar) : null,\n } as OpStackTransactionReceipt\n },\n }),\n} as const satisfies ChainFormatters\n","import { InvalidAddressError } from '../errors/address.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { ChainSerializers } from '../types/chain.js'\nimport type { Hex, Signature } from '../types/misc.js'\nimport type { TransactionSerializable } from '../types/transaction.js'\nimport type { RequiredBy } from '../types/utils.js'\nimport { isAddress } from '../utils/address/isAddress.js'\nimport { concatHex } from '../utils/data/concat.js'\nimport { toHex } from '../utils/encoding/toHex.js'\nimport { toRlp } from '../utils/encoding/toRlp.js'\nimport {\n type SerializeTransactionErrorType as SerializeTransactionErrorType_,\n serializeTransaction as serializeTransaction_,\n} from '../utils/transaction/serializeTransaction.js'\nimport type {\n OpStackTransactionSerializable,\n TransactionSerializableDeposit,\n TransactionSerializedDeposit,\n} from './types/transaction.js'\n\nexport type SerializeTransactionReturnType = ReturnType<\n typeof serializeTransaction\n>\n\nexport type SerializeTransactionErrorType =\n | SerializeTransactionErrorType_\n | ErrorType\n\nexport function serializeTransaction(\n transaction: OpStackTransactionSerializable,\n signature?: Signature,\n) {\n if (isDeposit(transaction)) return serializeTransactionDeposit(transaction)\n return serializeTransaction_(\n transaction as TransactionSerializable,\n signature,\n )\n}\n\nexport const serializers = {\n transaction: serializeTransaction,\n} as const satisfies ChainSerializers\n\n//////////////////////////////////////////////////////////////////////////////\n// Serializers\n\nexport type SerializeTransactionDepositReturnType = TransactionSerializedDeposit\n\nfunction serializeTransactionDeposit(\n transaction: TransactionSerializableDeposit,\n): SerializeTransactionDepositReturnType {\n assertTransactionDeposit(transaction)\n\n const { sourceHash, data, from, gas, isSystemTx, mint, to, value } =\n transaction\n\n const serializedTransaction: Hex[] = [\n sourceHash,\n from,\n to ?? '0x',\n mint ? toHex(mint) : '0x',\n value ? toHex(value) : '0x',\n gas ? toHex(gas) : '0x',\n isSystemTx ? '0x1' : '0x',\n data ?? '0x',\n ]\n\n return concatHex([\n '0x7e',\n toRlp(serializedTransaction),\n ]) as SerializeTransactionDepositReturnType\n}\n\nfunction isDeposit(\n transaction: OpStackTransactionSerializable,\n): transaction is RequiredBy<TransactionSerializableDeposit, 'type'> {\n if (transaction.type === 'deposit') return true\n if (typeof transaction.sourceHash !== 'undefined') return true\n return false\n}\n\nexport function assertTransactionDeposit(\n transaction: TransactionSerializableDeposit,\n) {\n const { from, to } = transaction\n if (from && !isAddress(from)) throw new InvalidAddressError({ address: from })\n if (to && !isAddress(to)) throw new InvalidAddressError({ address: to })\n}\n","import { contracts } from './contracts.js'\nimport { formatters } from './formatters.js'\nimport { serializers } from './serializers.js'\n\nexport const chainConfig = {\n blockTime: 2_000,\n contracts,\n formatters,\n serializers,\n} as const\n","import { chainConfig } from '../../op-stack/chainConfig.js'\nimport { defineChain } from '../../utils/chain/defineChain.js'\n\nconst sourceId = 1 // mainnet\n\nexport const base = /*#__PURE__*/ defineChain({\n ...chainConfig,\n id: 8453,\n name: 'Base',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: {\n http: ['https://mainnet.base.org'],\n },\n },\n blockExplorers: {\n default: {\n name: 'Basescan',\n url: 'https://basescan.org',\n apiUrl: 'https://api.basescan.org/api',\n },\n },\n contracts: {\n ...chainConfig.contracts,\n disputeGameFactory: {\n [sourceId]: {\n address: '0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e',\n },\n },\n l2OutputOracle: {\n [sourceId]: {\n address: '0x56315b90c40730925ec5485cf004d835058518A0',\n },\n },\n multicall3: {\n address: '0xca11bde05977b3631167028862be2a173976ca11',\n blockCreated: 5022,\n },\n portal: {\n [sourceId]: {\n address: '0x49048044D57e1C92A77f79988d21Fa8fAF74E97e',\n blockCreated: 17482143,\n },\n },\n l1StandardBridge: {\n [sourceId]: {\n address: '0x3154Cf16ccdb4C6d922629664174b904d80F2C35',\n blockCreated: 17482143,\n },\n },\n },\n sourceId,\n})\n\nexport const basePreconf = /*#__PURE__*/ defineChain({\n ...base,\n experimental_preconfirmationTime: 200,\n rpcUrls: {\n default: {\n http: ['https://mainnet-preconf.base.org'],\n },\n },\n})\n","import {\n createPublicClient,\n decodeFunctionData,\n encodeFunctionData,\n erc20Abi,\n http,\n type Address,\n type Hex,\n} from 'viem';\nimport { base } from 'viem/chains';\nimport { USDC_ADDRESS as USDC } from './usdc-balance';\nimport type { TenjinSigner } from './wallet/provider';\n\n/** Lives in `usdc-balance.ts`, which the viem-free hooks can load. */\nexport const USDC_ADDRESS: Address = USDC;\nexport const USDC_DECIMALS = 6;\n\nexport async function getUsdcBalance(address: Address, rpcUrl: string): Promise<bigint> {\n const client = createPublicClient({ chain: base, transport: http(rpcUrl) });\n return client.readContract({\n address: USDC_ADDRESS,\n abi: erc20Abi,\n functionName: 'balanceOf',\n args: [address],\n });\n}\n\n// The chain boundary for `tenjin wallet send`, two-phase around the human confirm:\n// prepareUsdcSend (read-only: encode, nonce, gas, fees, ETH-for-gas balance)\n// runs BEFORE the confirm so the prompt can show the fee, broadcastUsdcSend\n// (sign via the TenjinSigner seam, broadcast, wait for the receipt) runs after.\n// Command tests mock this whole module, so no test can ever reach a real chain.\n\n/**\n * Ceilings on the RPC-supplied gas and fee fields. The RPC endpoint is\n * config-controlled and its estimates go straight into the signed transaction; a\n * hostile or broken endpoint returning huge values would burn the wallet's ETH\n * as fees. An ERC-20 transfer is ~65k gas and Base fees run well under a gwei,\n * so estimates past these bounds mean something is wrong: refuse, never clamp\n * (a clamped maxFeePerGas below the real base fee would just strand the tx).\n * A genuine extreme fee spike on Base trips the same refusal; that is intended\n * — waiting it out beats signing an irreversible transfer at panic prices.\n */\nexport const SEND_GAS_CAP = 150_000n;\nexport const SEND_MAX_FEE_PER_GAS_CAP = 10_000_000_000n; // 10 gwei\nexport const SEND_MAX_PRIORITY_FEE_CAP = 2_000_000_000n; // 2 gwei\n\n/** An RPC gas/fee estimate exceeded the send ceilings; nothing was signed. */\nexport class FeeCapExceededError extends Error {\n constructor(field: string, value: bigint, cap: bigint) {\n super(`${field} estimate ${value} exceeds the send ceiling ${cap}`);\n this.name = 'FeeCapExceededError';\n }\n}\n\n/** The transfer was mined but reverted; the fee was spent, the USDC did not move. */\nexport class SendRevertedError extends Error {\n constructor(readonly txHash: Hex) {\n super(`Transaction ${txHash} reverted`);\n this.name = 'SendRevertedError';\n }\n}\n\n/** Broadcast succeeded but no receipt arrived in time; the tx may still mine. */\nexport class SendPendingError extends Error {\n constructor(readonly txHash: Hex) {\n super(`Transaction ${txHash} was broadcast but not confirmed in time`);\n this.name = 'SendPendingError';\n }\n}\n\nexport interface PrepareUsdcSendArgs {\n from: Address;\n to: Address;\n amountAtomic: bigint;\n rpcUrl: string;\n}\n\n/**\n * Everything signed later, fixed at prepare time, plus the gas-cost preview.\n * The nonce is pinned here, BEFORE the human confirm, so anything else spending\n * from this key during that window makes the later broadcast fail nonce-stale\n * (an RPC_ERROR from the node; nothing double-spends — re-run to re-prepare).\n * `to` and `amountAtomic` are the previewed intent; broadcastUsdcSend re-decodes\n * `data` against them before signing.\n */\nexport interface PreparedUsdcSend {\n to: Address;\n amountAtomic: bigint;\n data: Hex;\n nonce: number;\n gas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n /** Worst-case fee (gas * maxFeePerGas), for the confirm prompt and gas check. */\n feeWei: bigint;\n /** The sender's native ETH balance, for the has-gas pre-check. */\n ethBalanceWei: bigint;\n}\n\nexport async function prepareUsdcSend({\n from,\n to,\n amountAtomic,\n rpcUrl,\n}: PrepareUsdcSendArgs): Promise<PreparedUsdcSend> {\n const client = createPublicClient({ chain: base, transport: http(rpcUrl) });\n const data = encodeFunctionData({\n abi: erc20Abi,\n functionName: 'transfer',\n args: [to, amountAtomic],\n });\n const [nonce, gas, fees, ethBalanceWei] = await Promise.all([\n client.getTransactionCount({ address: from, blockTag: 'pending' }),\n client.estimateGas({ account: from, to: USDC_ADDRESS, data }),\n client.estimateFeesPerGas(),\n client.getBalance({ address: from }),\n ]);\n assertUnderCap('gas', gas, SEND_GAS_CAP);\n assertUnderCap('maxFeePerGas', fees.maxFeePerGas, SEND_MAX_FEE_PER_GAS_CAP);\n assertUnderCap('maxPriorityFeePerGas', fees.maxPriorityFeePerGas, SEND_MAX_PRIORITY_FEE_CAP);\n return {\n to,\n amountAtomic,\n data,\n nonce,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n feeWei: gas * fees.maxFeePerGas,\n ethBalanceWei,\n };\n}\n\nexport interface BroadcastUsdcSendArgs {\n signer: TenjinSigner;\n prepared: PreparedUsdcSend;\n rpcUrl: string;\n /** Receipt wait bound in ms; Base blocks are ~2s, so the default is generous. */\n receiptTimeoutMs?: number;\n}\n\n/**\n * Sign the prepared transfer through the TenjinSigner seam (never a raw key),\n * broadcast it, and wait for the receipt so \"sent\" means mined. Throws\n * SendRevertedError (mined but failed) or SendPendingError (no receipt in time);\n * both carry the hash so the caller can report it either way.\n */\nexport async function broadcastUsdcSend({\n signer,\n prepared,\n rpcUrl,\n receiptTimeoutMs = 120_000,\n}: BroadcastUsdcSendArgs): Promise<Hex> {\n const client = createPublicClient({ chain: base, transport: http(rpcUrl) });\n // Pre-sign cross-check, the calldata twin of send.ts's signer/preview match:\n // the bytes about to be signed must still decode to the previewed recipient\n // and amount. Unreachable unless prepare-time state was corrupted; refusing\n // here means nothing is signed against a preview it does not match.\n const decoded = decodeFunctionData({ abi: erc20Abi, data: prepared.data });\n if (\n decoded.functionName !== 'transfer' ||\n decoded.args[0].toLowerCase() !== prepared.to.toLowerCase() ||\n decoded.args[1] !== prepared.amountAtomic\n ) {\n throw new Error(\n 'Prepared calldata does not decode to the previewed recipient and amount; nothing was signed.',\n );\n }\n const serializedTransaction = await signer.signTransaction({\n type: 'eip1559',\n chainId: base.id,\n to: USDC_ADDRESS,\n // Explicitly zero: an ERC-20 transfer carries no native value (test-pinned).\n value: 0n,\n data: prepared.data,\n nonce: prepared.nonce,\n gas: prepared.gas,\n maxFeePerGas: prepared.maxFeePerGas,\n maxPriorityFeePerGas: prepared.maxPriorityFeePerGas,\n });\n const txHash = await client.sendRawTransaction({ serializedTransaction });\n let receipt;\n try {\n receipt = await client.waitForTransactionReceipt({ hash: txHash, timeout: receiptTimeoutMs });\n } catch {\n throw new SendPendingError(txHash);\n }\n if (receipt.status !== 'success') throw new SendRevertedError(txHash);\n return txHash;\n}\n\nfunction assertUnderCap(field: string, value: bigint, cap: bigint): void {\n if (value > cap) throw new FeeCapExceededError(field, value, cap);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAM,YAAY;EACvB,gBAAgB,EAAE,SAAS,6CAA4C;EACvE,SAAS,EAAE,SAAS,6CAA4C;EAChE,wBAAwB;IACtB,SAAS;;EAEX,gBAAgB,EAAE,SAAS,6CAA4C;EACvE,kBAAkB,EAAE,SAAS,6CAA4C;EACzE,qBAAqB;IACnB,SAAS;;;;;ACEN,IAAM,aAAa;EACxB,OAAqB,4BAAY;IAC/B,OAAO,MAAqB;AAC1B,YAAM,eAAe,KAAK,cAAc,IAAI,CAAC,gBAAe;AAC1D,YAAI,OAAO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AACxE,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,OAAO,0BAA0B,EAAE,MAAM,QAAQ,SAAS,iBAAiB,CAAC;AAAA,EAC9F,QAAQ;AACN,UAAM,IAAI,iBAAiB,MAAM;AAAA,EACnC;AACA,MAAI,QAAQ,WAAW,UAAW,OAAM,IAAI,kBAAkB,MAAM;AACpE,SAAO;AACT;AAEA,SAAS,eAAe,OAAe,OAAe,KAAmB;AACvE,MAAI,QAAQ,IAAK,OAAM,IAAI,oBAAoB,OAAO,OAAO,GAAG;AAClE;","names":["serializeTransaction","USDC_ADDRESS"]}
@@ -0,0 +1,105 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ normalizeChannelId
4
+ } from "./chunk-LFZJM56J.js";
5
+
6
+ // node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/dist/esm/chunk-3632HGL3.mjs
7
+ import { mkdir, readFile, rename, unlink, writeFile } from "fs/promises";
8
+ import { dirname, join, resolve, sep } from "path";
9
+ function resolveWithinDir(baseDir, filename) {
10
+ const base = resolve(baseDir);
11
+ const target = resolve(base, filename);
12
+ if (target !== base && !target.startsWith(base + sep)) {
13
+ throw new Error("resolved channel path escapes storage root");
14
+ }
15
+ return target;
16
+ }
17
+ function isNodeEnoent(err) {
18
+ if (!err || typeof err !== "object" || !("code" in err)) return false;
19
+ return err.code === "ENOENT";
20
+ }
21
+ async function readJsonFile(filePath) {
22
+ try {
23
+ const raw = await readFile(filePath, "utf8");
24
+ return JSON.parse(raw);
25
+ } catch (err) {
26
+ if (isNodeEnoent(err)) return void 0;
27
+ throw err;
28
+ }
29
+ }
30
+ async function writeJsonAtomic(filePath, value) {
31
+ const dir = dirname(filePath);
32
+ await mkdir(dir, { recursive: true });
33
+ const tmp = join(dir, `.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);
34
+ const body = `${JSON.stringify(value, null, 2)}
35
+ `;
36
+ await writeFile(tmp, body, "utf8");
37
+ try {
38
+ await rename(tmp, filePath);
39
+ } catch {
40
+ await unlink(filePath).catch(() => {
41
+ });
42
+ await rename(tmp, filePath);
43
+ }
44
+ }
45
+
46
+ // node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/dist/esm/batch-settlement/client/file-storage.mjs
47
+ import { unlink as unlink2 } from "fs/promises";
48
+ import { join as join2 } from "path";
49
+ var FileClientChannelStorage = class {
50
+ /**
51
+ * Creates file-backed client channel storage under the given root directory.
52
+ *
53
+ * @param options - Configuration including the storage root directory.
54
+ */
55
+ constructor(options) {
56
+ this.root = options.directory;
57
+ }
58
+ /**
59
+ * Loads the stored client context for a channel, if present.
60
+ *
61
+ * @param key - Channel storage key (typically a lowercased channelId).
62
+ * @returns Parsed context or `undefined` when the file is missing.
63
+ */
64
+ async get(key) {
65
+ return readJsonFile(this.filePath(key));
66
+ }
67
+ /**
68
+ * Persists the client context for a channel.
69
+ *
70
+ * @param key - Channel storage key.
71
+ * @param context - Context record to write.
72
+ */
73
+ async set(key, context) {
74
+ await writeJsonAtomic(this.filePath(key), context);
75
+ }
76
+ /**
77
+ * Removes the persisted context file for a channel, if it exists.
78
+ *
79
+ * @param key - Channel storage key.
80
+ */
81
+ async delete(key) {
82
+ try {
83
+ await unlink2(this.filePath(key));
84
+ } catch (err) {
85
+ if (isNodeEnoent(err)) return;
86
+ throw err;
87
+ }
88
+ }
89
+ /**
90
+ * Absolute path to the JSON file for a channel.
91
+ *
92
+ * @param key - Channel storage key (a canonical `bytes32` channel id).
93
+ * @returns Filesystem path under `{root}/client/...`.
94
+ * @throws When `key` is not a canonical `bytes32` string or escapes the storage root.
95
+ */
96
+ filePath(key) {
97
+ const id = normalizeChannelId(key);
98
+ return resolveWithinDir(join2(this.root, "client"), `${id}.json`);
99
+ }
100
+ };
101
+
102
+ export {
103
+ FileClientChannelStorage
104
+ };
105
+ //# sourceMappingURL=chunk-YHKXNYTB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/batch-settlement/storage-utils.ts","../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/batch-settlement/client/fileStorage.ts"],"sourcesContent":["import { mkdir, readFile, rename, unlink, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve, sep } from \"node:path\";\n\n/**\n * Resolves `filename` under `baseDir` and asserts the result stays within `baseDir`.\n *\n * @param baseDir - Directory that must contain the resolved path.\n * @param filename - Filename to resolve against `baseDir`.\n * @returns The absolute resolved path.\n * @throws When the resolved path escapes `baseDir` (e.g. via `..` or separators).\n */\nexport function resolveWithinDir(baseDir: string, filename: string): string {\n const base = resolve(baseDir);\n const target = resolve(base, filename);\n if (target !== base && !target.startsWith(base + sep)) {\n throw new Error(\"resolved channel path escapes storage root\");\n }\n return target;\n}\n\n/**\n * Returns true when `err` is a Node.js `ENOENT` filesystem error (file does not exist).\n *\n * @param err - The thrown value to inspect.\n * @returns `true` for `ENOENT`, `false` for any other value or error code.\n */\nexport function isNodeEnoent(err: unknown): boolean {\n if (!err || typeof err !== \"object\" || !(\"code\" in err)) return false;\n return (err as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n\n/**\n * Reads a JSON file and parses it. Returns `undefined` if the file does not exist.\n * Other errors (permission, malformed JSON) are rethrown.\n *\n * @param filePath - Path to the JSON file.\n * @returns Parsed value, or `undefined` for `ENOENT`.\n */\nexport async function readJsonFile<T>(filePath: string): Promise<T | undefined> {\n try {\n const raw = await readFile(filePath, \"utf8\");\n return JSON.parse(raw) as T;\n } catch (err: unknown) {\n if (isNodeEnoent(err)) return undefined;\n throw err;\n }\n}\n\n/**\n * Writes JSON to `filePath` atomically (temp file in the same directory, then rename).\n * Creates parent directories as needed.\n *\n * @param filePath - Destination file path; parent dirs are created if missing.\n * @param value - JSON-serializable value to persist.\n */\nexport async function writeJsonAtomic(filePath: string, value: unknown): Promise<void> {\n const dir = dirname(filePath);\n await mkdir(dir, { recursive: true });\n const tmp = join(dir, `.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);\n const body = `${JSON.stringify(value, null, 2)}\\n`;\n await writeFile(tmp, body, \"utf8\");\n try {\n await rename(tmp, filePath);\n } catch {\n // On Windows, rename() onto an existing file throws EEXIST; unlink + rename is intentional.\n await unlink(filePath).catch(() => {});\n await rename(tmp, filePath);\n }\n}\n","import { unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { isNodeEnoent, readJsonFile, resolveWithinDir, writeJsonAtomic } from \"../storage-utils\";\nimport { normalizeChannelId } from \"../utils\";\nimport type { FileChannelStorageOptions } from \"../types\";\nimport type { ClientChannelStorage, BatchSettlementClientContext } from \"./storage\";\n\nexport type { FileChannelStorageOptions };\n\n/**\n * Node.js file-backed {@link ClientChannelStorage} for the batched client scheme.\n * Each channel's context is persisted as `{root}/client/{channelId}.json` so that channel\n * records survive process restarts.\n */\nexport class FileClientChannelStorage implements ClientChannelStorage {\n private readonly root: string;\n\n /**\n * Creates file-backed client channel storage under the given root directory.\n *\n * @param options - Configuration including the storage root directory.\n */\n constructor(options: FileChannelStorageOptions) {\n this.root = options.directory;\n }\n\n /**\n * Loads the stored client context for a channel, if present.\n *\n * @param key - Channel storage key (typically a lowercased channelId).\n * @returns Parsed context or `undefined` when the file is missing.\n */\n async get(key: string): Promise<BatchSettlementClientContext | undefined> {\n return readJsonFile<BatchSettlementClientContext>(this.filePath(key));\n }\n\n /**\n * Persists the client context for a channel.\n *\n * @param key - Channel storage key.\n * @param context - Context record to write.\n */\n async set(key: string, context: BatchSettlementClientContext): Promise<void> {\n await writeJsonAtomic(this.filePath(key), context);\n }\n\n /**\n * Removes the persisted context file for a channel, if it exists.\n *\n * @param key - Channel storage key.\n */\n async delete(key: string): Promise<void> {\n try {\n await unlink(this.filePath(key));\n } catch (err: unknown) {\n if (isNodeEnoent(err)) return;\n throw err;\n }\n }\n\n /**\n * Absolute path to the JSON file for a channel.\n *\n * @param key - Channel storage key (a canonical `bytes32` channel id).\n * @returns Filesystem path under `{root}/client/...`.\n * @throws When `key` is not a canonical `bytes32` string or escapes the storage root.\n */\n private filePath(key: string): string {\n const id = normalizeChannelId(key);\n return resolveWithinDir(join(this.root, \"client\"), `${id}.json`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,OAAO,UAAU,QAAQ,QAAQ,iBAAiB;AAC3D,SAAS,SAAS,MAAM,SAAS,WAAW;AAUrC,SAAS,iBAAiB,SAAiB,UAA0B;AAC1E,QAAM,OAAO,QAAQ,OAAO;AAC5B,QAAM,SAAS,QAAQ,MAAM,QAAQ;AACrC,MAAI,WAAW,QAAQ,CAAC,OAAO,WAAW,OAAO,GAAG,GAAG;AACrD,UAAM,IAAI,MAAM,4CAA4C;EAC9D;AACA,SAAO;AACT;AAQO,SAAS,aAAa,KAAuB;AAClD,MAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,EAAE,UAAU,KAAM,QAAO;AAChE,SAAQ,IAA8B,SAAS;AACjD;AASA,eAAsB,aAAgB,UAA0C;AAC9E,MAAI;AACF,UAAM,MAAM,MAAM,SAAS,UAAU,MAAM;AAC3C,WAAO,KAAK,MAAM,GAAG;EACvB,SAAS,KAAc;AACrB,QAAI,aAAa,GAAG,EAAG,QAAO;AAC9B,UAAM;EACR;AACF;AASA,eAAsB,gBAAgB,UAAkB,OAA+B;AACrF,QAAM,MAAM,QAAQ,QAAQ;AAC5B,QAAM,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AACpC,QAAM,MAAM,KAAK,KAAK,IAAI,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM;AAChG,QAAM,OAAO,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;;AAC9C,QAAM,UAAU,KAAK,MAAM,MAAM;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