tenjin-cli 0.1.0-alpha.15 → 0.1.0-alpha.17

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 (278) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +43 -310
  3. package/dist/{_esm-N4KAVXQR.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-ZGGWQN4X.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-RPPPKTJR.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-2BKS2FVE.js +93 -0
  7. package/dist/chunk-2BKS2FVE.js.map +1 -0
  8. package/dist/chunk-2G2WLVHB.js +102 -0
  9. package/dist/chunk-2G2WLVHB.js.map +1 -0
  10. package/dist/chunk-2I4QTOLB.js +11 -0
  11. package/dist/chunk-2I4QTOLB.js.map +1 -0
  12. package/dist/chunk-2JGT3KDW.js +172 -0
  13. package/dist/chunk-2JGT3KDW.js.map +1 -0
  14. package/dist/chunk-2QYORQBF.js +55 -0
  15. package/dist/chunk-2QYORQBF.js.map +1 -0
  16. package/dist/chunk-35M3VITA.js +102 -0
  17. package/dist/chunk-35M3VITA.js.map +1 -0
  18. package/dist/{chunk-KINZ23CV.js → chunk-3AUDA53C.js} +4740 -23
  19. package/dist/chunk-3AUDA53C.js.map +1 -0
  20. package/dist/{chunk-MJZZTKCC.js → chunk-56MOAIP5.js} +5 -10
  21. package/dist/chunk-56MOAIP5.js.map +1 -0
  22. package/dist/{chunk-U5S527PP.js → chunk-5IEP5EGE.js} +3 -3
  23. package/dist/chunk-5QHHRMRA.js +227 -0
  24. package/dist/chunk-5QHHRMRA.js.map +1 -0
  25. package/dist/{chunk-JBIKAAT3.js → chunk-5UDD5VSY.js} +8 -8
  26. package/dist/chunk-5UDD5VSY.js.map +1 -0
  27. package/dist/chunk-7QKHZQKW.js +1680 -0
  28. package/dist/chunk-7QKHZQKW.js.map +1 -0
  29. package/dist/{chunk-ZFJJ3EXC.js → chunk-AR7U7BRG.js} +550 -182
  30. package/dist/chunk-AR7U7BRG.js.map +1 -0
  31. package/dist/chunk-AUKDYPPX.js +130 -0
  32. package/dist/chunk-AUKDYPPX.js.map +1 -0
  33. package/dist/{chunk-7FK2UN2T.js → chunk-AWQPGIR6.js} +65 -67
  34. package/dist/{chunk-7FK2UN2T.js.map → chunk-AWQPGIR6.js.map} +1 -1
  35. package/dist/{chunk-KYQVEKP5.js → chunk-BPMWXTFX.js} +8 -8
  36. package/dist/{chunk-47PP7TAG.js → chunk-EGELTSPU.js} +1356 -1356
  37. package/dist/chunk-EGELTSPU.js.map +1 -0
  38. package/dist/{chunk-S5RYMCV6.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-J5INH7WB.js +299 -0
  40. package/dist/chunk-J5INH7WB.js.map +1 -0
  41. package/dist/chunk-JLEF5WHM.js +132 -0
  42. package/dist/chunk-JLEF5WHM.js.map +1 -0
  43. package/dist/{chunk-W6R3HAAG.js → chunk-JRGFKVAZ.js} +2 -2
  44. package/dist/{chunk-XJN5WUKL.js → chunk-KG3D7FIF.js} +2 -2
  45. package/dist/chunk-KK4YGYTV.js +808 -0
  46. package/dist/chunk-KK4YGYTV.js.map +1 -0
  47. package/dist/{chunk-CPCX67TI.js → chunk-KUBEYXSO.js} +1076 -1038
  48. package/dist/chunk-KUBEYXSO.js.map +1 -0
  49. package/dist/{chunk-QW2Q2KAH.js → chunk-LHHMV4GU.js} +2 -2
  50. package/dist/{chunk-NIKXHWOL.js → chunk-LJ4DMVFI.js} +16 -16
  51. package/dist/chunk-LJ4DMVFI.js.map +1 -0
  52. package/dist/{chunk-ZOBNS7CX.js → chunk-MEFB5KHA.js} +4 -18
  53. package/dist/chunk-MEFB5KHA.js.map +1 -0
  54. package/dist/{chunk-HPJGOLTN.js → chunk-MRGADYDD.js} +13 -8
  55. package/dist/chunk-MRGADYDD.js.map +1 -0
  56. package/dist/{chunk-M2O56UK7.js → chunk-N35E6CM2.js} +293 -163
  57. package/dist/chunk-N35E6CM2.js.map +1 -0
  58. package/dist/chunk-O4ZNKFRU.js +366 -0
  59. package/dist/chunk-O4ZNKFRU.js.map +1 -0
  60. package/dist/chunk-PDA2BVFY.js +244 -0
  61. package/dist/chunk-PDA2BVFY.js.map +1 -0
  62. package/dist/{chunk-POJRB2AE.js → chunk-POUWHWID.js} +2 -2
  63. package/dist/chunk-QDD2RN7G.js +10238 -0
  64. package/dist/chunk-QDD2RN7G.js.map +1 -0
  65. package/dist/chunk-S2NRVRPF.js +171 -0
  66. package/dist/chunk-S2NRVRPF.js.map +1 -0
  67. package/dist/chunk-TGLKKLQG.js +11 -0
  68. package/dist/chunk-TGLKKLQG.js.map +1 -0
  69. package/dist/chunk-TP4D47BY.js +127 -0
  70. package/dist/chunk-TP4D47BY.js.map +1 -0
  71. package/dist/{chunk-KZAAWQNP.js → chunk-TTNESUPQ.js} +3 -3
  72. package/dist/{chunk-UO22YNY4.js → chunk-U2DZISAH.js} +43 -1
  73. package/dist/chunk-U2DZISAH.js.map +1 -0
  74. package/dist/chunk-WGQVJM56.js +165 -0
  75. package/dist/chunk-WGQVJM56.js.map +1 -0
  76. package/dist/{chunk-OLWTRUTS.js → chunk-WLMJE3GJ.js} +35 -16
  77. package/dist/chunk-WLMJE3GJ.js.map +1 -0
  78. package/dist/chunk-WS4JA6TC.js +137 -0
  79. package/dist/chunk-WS4JA6TC.js.map +1 -0
  80. package/dist/chunk-WXC57XGG.js +29 -0
  81. package/dist/chunk-WXC57XGG.js.map +1 -0
  82. package/dist/{chunk-YLYINX2H.js → chunk-XZKD7DIF.js} +3 -3
  83. package/dist/chunk-XZOEUYMX.js +1784 -0
  84. package/dist/chunk-XZOEUYMX.js.map +1 -0
  85. package/dist/{cli-KKRKBU5T.js → cli-VHYYYYXM.js} +303 -374
  86. package/dist/cli-VHYYYYXM.js.map +1 -0
  87. package/dist/config-5ADBAAXU.js +42 -0
  88. package/dist/{dist-U4M6QCKE.js → dist-3LOO6M4U.js} +10 -10
  89. package/dist/doctor-Q35VQW3S.js +436 -0
  90. package/dist/doctor-Q35VQW3S.js.map +1 -0
  91. package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  92. package/dist/{chunk-KAJZHIQ4.js → fund-GDDPL2BB.js} +81 -24
  93. package/dist/fund-GDDPL2BB.js.map +1 -0
  94. package/dist/hook-command-PBERPRE3.js +763 -0
  95. package/dist/hook-command-PBERPRE3.js.map +1 -0
  96. package/dist/index.js +8 -3
  97. package/dist/index.js.map +1 -1
  98. package/dist/install-OKDKGUXM.js +60 -0
  99. package/dist/install-wallet-SI4LZ73K.js +106 -0
  100. package/dist/install-wallet-SI4LZ73K.js.map +1 -0
  101. package/dist/{run-XYTQ5TWQ.js → mcp-XX3WRQEZ.js} +3766 -10677
  102. package/dist/mcp-XX3WRQEZ.js.map +1 -0
  103. package/dist/paths-P2N4JTDZ.js +49 -0
  104. package/dist/pay-3SYKHKWJ.js +39 -0
  105. package/dist/redact-6W23GGJC.js +15 -0
  106. package/dist/{secp256k1-XRPVBC6V.js → secp256k1-ZZZT2CAX.js} +3 -3
  107. package/dist/{send-G746D7PQ.js → send-LQRKTEJT.js} +29 -29
  108. package/dist/send-LQRKTEJT.js.map +1 -0
  109. package/dist/{chunk-QZ6ROAJU.js → skill-placement-JMDPSKE6.js} +155 -10
  110. package/dist/skill-placement-JMDPSKE6.js.map +1 -0
  111. package/dist/status-FFC6FO72.js +64 -0
  112. package/dist/status-FFC6FO72.js.map +1 -0
  113. package/dist/status-line-SAXSU6CR.js +87 -0
  114. package/dist/status-line-SAXSU6CR.js.map +1 -0
  115. package/dist/status-line-wiring-L2WYIYBM.js +29 -0
  116. package/dist/tenjin-daemon.mjs +20421 -0
  117. package/dist/tenjin-shim.mjs +251 -0
  118. package/dist/tenjin-vitest-reporter.mjs +49 -0
  119. package/dist/uninstall-OACH27UV.js +147 -0
  120. package/dist/uninstall-OACH27UV.js.map +1 -0
  121. package/dist/{update-R76LHOZW.js → update-4W6EKLGZ.js} +132 -16
  122. package/dist/update-4W6EKLGZ.js.map +1 -0
  123. package/dist/{viemAdapter-By13KInL-TUQJBMHM.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  124. package/dist/wallet-BMEXRR3P.js +32 -0
  125. package/dist/wallet-kdf-worker.mjs +980 -0
  126. package/docs/agent-permissions.md +71 -352
  127. package/docs/safety-model.md +16 -6
  128. package/package.json +8 -7
  129. package/LICENSE +0 -21
  130. package/dist/buy-VIRNSYGN.js +0 -47
  131. package/dist/chunk-2MYQN7HM.js +0 -247
  132. package/dist/chunk-2MYQN7HM.js.map +0 -1
  133. package/dist/chunk-2RF2GIJQ.js +0 -1188
  134. package/dist/chunk-2RF2GIJQ.js.map +0 -1
  135. package/dist/chunk-3GL2Z5QK.js +0 -57
  136. package/dist/chunk-3GL2Z5QK.js.map +0 -1
  137. package/dist/chunk-47PP7TAG.js.map +0 -1
  138. package/dist/chunk-4CQIDQOT.js +0 -167
  139. package/dist/chunk-4CQIDQOT.js.map +0 -1
  140. package/dist/chunk-4KG27W2S.js +0 -614
  141. package/dist/chunk-4KG27W2S.js.map +0 -1
  142. package/dist/chunk-5QQTYWEU.js +0 -199
  143. package/dist/chunk-5QQTYWEU.js.map +0 -1
  144. package/dist/chunk-65DTCCJ7.js +0 -21
  145. package/dist/chunk-65DTCCJ7.js.map +0 -1
  146. package/dist/chunk-A5DKHMUN.js +0 -173
  147. package/dist/chunk-A5DKHMUN.js.map +0 -1
  148. package/dist/chunk-B63XPWQ4.js +0 -246
  149. package/dist/chunk-B63XPWQ4.js.map +0 -1
  150. package/dist/chunk-CAR6FHK6.js +0 -105
  151. package/dist/chunk-CAR6FHK6.js.map +0 -1
  152. package/dist/chunk-CPCX67TI.js.map +0 -1
  153. package/dist/chunk-CQBVCYI2.js +0 -162
  154. package/dist/chunk-CQBVCYI2.js.map +0 -1
  155. package/dist/chunk-DBU5CXBV.js +0 -4731
  156. package/dist/chunk-DBU5CXBV.js.map +0 -1
  157. package/dist/chunk-DHJD77OW.js +0 -81
  158. package/dist/chunk-DHJD77OW.js.map +0 -1
  159. package/dist/chunk-EDZSNPE5.js +0 -35
  160. package/dist/chunk-EDZSNPE5.js.map +0 -1
  161. package/dist/chunk-EFWZPUTC.js +0 -65
  162. package/dist/chunk-EFWZPUTC.js.map +0 -1
  163. package/dist/chunk-EPFL6CTE.js +0 -448
  164. package/dist/chunk-EPFL6CTE.js.map +0 -1
  165. package/dist/chunk-GHLVXVZD.js +0 -142
  166. package/dist/chunk-GHLVXVZD.js.map +0 -1
  167. package/dist/chunk-H3SOOJ2I.js +0 -580
  168. package/dist/chunk-H3SOOJ2I.js.map +0 -1
  169. package/dist/chunk-HPJGOLTN.js.map +0 -1
  170. package/dist/chunk-HRGBS2PA.js +0 -203
  171. package/dist/chunk-HRGBS2PA.js.map +0 -1
  172. package/dist/chunk-ITUXPJIS.js +0 -314
  173. package/dist/chunk-ITUXPJIS.js.map +0 -1
  174. package/dist/chunk-JBIKAAT3.js.map +0 -1
  175. package/dist/chunk-KAJZHIQ4.js.map +0 -1
  176. package/dist/chunk-KINZ23CV.js.map +0 -1
  177. package/dist/chunk-LRYV3SK7.js +0 -235
  178. package/dist/chunk-LRYV3SK7.js.map +0 -1
  179. package/dist/chunk-M2O56UK7.js.map +0 -1
  180. package/dist/chunk-MJZZTKCC.js.map +0 -1
  181. package/dist/chunk-NIKXHWOL.js.map +0 -1
  182. package/dist/chunk-OKDRDT74.js +0 -209
  183. package/dist/chunk-OKDRDT74.js.map +0 -1
  184. package/dist/chunk-OKYSNAS3.js +0 -2144
  185. package/dist/chunk-OKYSNAS3.js.map +0 -1
  186. package/dist/chunk-OLWTRUTS.js.map +0 -1
  187. package/dist/chunk-QQ6ELLSA.js +0 -143
  188. package/dist/chunk-QQ6ELLSA.js.map +0 -1
  189. package/dist/chunk-QZ6ROAJU.js.map +0 -1
  190. package/dist/chunk-R7RSCBI7.js +0 -794
  191. package/dist/chunk-R7RSCBI7.js.map +0 -1
  192. package/dist/chunk-SGK2B724.js +0 -67
  193. package/dist/chunk-SGK2B724.js.map +0 -1
  194. package/dist/chunk-U6VPKMGC.js +0 -390
  195. package/dist/chunk-U6VPKMGC.js.map +0 -1
  196. package/dist/chunk-UHTVXQ2O.js +0 -140
  197. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  198. package/dist/chunk-UO22YNY4.js.map +0 -1
  199. package/dist/chunk-US456VUI.js +0 -149
  200. package/dist/chunk-US456VUI.js.map +0 -1
  201. package/dist/chunk-V44J2MXV.js +0 -400
  202. package/dist/chunk-V44J2MXV.js.map +0 -1
  203. package/dist/chunk-VJQKL3YH.js +0 -216
  204. package/dist/chunk-VJQKL3YH.js.map +0 -1
  205. package/dist/chunk-VJSQSLBM.js +0 -1442
  206. package/dist/chunk-VJSQSLBM.js.map +0 -1
  207. package/dist/chunk-VYOJOX4Z.js +0 -165
  208. package/dist/chunk-VYOJOX4Z.js.map +0 -1
  209. package/dist/chunk-WY2K35OL.js +0 -269
  210. package/dist/chunk-WY2K35OL.js.map +0 -1
  211. package/dist/chunk-ZFJJ3EXC.js.map +0 -1
  212. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  213. package/dist/cli-KKRKBU5T.js.map +0 -1
  214. package/dist/config-JMRUNYE6.js +0 -37
  215. package/dist/discover-B5HF6SHM.js +0 -102
  216. package/dist/discover-B5HF6SHM.js.map +0 -1
  217. package/dist/doctor-ZBG7X66D.js +0 -32
  218. package/dist/edit-PZJIILQE.js +0 -40
  219. package/dist/fund-EUDH5KPA.js +0 -40
  220. package/dist/inspect-QC6WEQPN.js +0 -37
  221. package/dist/install-GNK2W3PI.js +0 -972
  222. package/dist/install-GNK2W3PI.js.map +0 -1
  223. package/dist/outcome-KSGWZHUS.js +0 -24
  224. package/dist/pay-BC4UICPA.js +0 -361
  225. package/dist/pay-BC4UICPA.js.map +0 -1
  226. package/dist/publish-LXWFDIKF.js +0 -42
  227. package/dist/read-JMNUQ56P.js +0 -160
  228. package/dist/read-JMNUQ56P.js.map +0 -1
  229. package/dist/run-XYTQ5TWQ.js.map +0 -1
  230. package/dist/search-TSQAB45E.js +0 -25
  231. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  232. package/dist/send-G746D7PQ.js.map +0 -1
  233. package/dist/session-JBKWMJ24.js +0 -89
  234. package/dist/session-JBKWMJ24.js.map +0 -1
  235. package/dist/skill-heal-WKD67SLJ.js +0 -92
  236. package/dist/skill-heal-WKD67SLJ.js.map +0 -1
  237. package/dist/skill-placement-RIU4AMC2.js +0 -20
  238. package/dist/skill-placement-RIU4AMC2.js.map +0 -1
  239. package/dist/uninstall-5E263VTS.js +0 -73
  240. package/dist/uninstall-5E263VTS.js.map +0 -1
  241. package/dist/update-R76LHOZW.js.map +0 -1
  242. package/dist/usdc-4VCDHFWX.js +0 -38
  243. package/dist/usdc-4VCDHFWX.js.map +0 -1
  244. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  245. package/dist/wallet-TQ7D5EQ7.js +0 -41
  246. package/dist/wallet-TQ7D5EQ7.js.map +0 -1
  247. package/dist/wallet-ZAVXWLWP.js +0 -32
  248. package/dist/wallet-ZAVXWLWP.js.map +0 -1
  249. package/docs/command-reference.md +0 -303
  250. package/skills/tenjin/SKILL.md +0 -373
  251. package/skills/tenjin-pay/SKILL.md +0 -76
  252. package/skills/tenjin-publish/SKILL.md +0 -227
  253. package/skills/tenjin-publish/references/maintain.md +0 -39
  254. package/skills/tenjin-search/SKILL.md +0 -154
  255. package/skills/tenjin-search/references/permissions.md +0 -112
  256. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  257. /package/dist/{buy-VIRNSYGN.js.map → ccip-7RMRLAGV.js.map} +0 -0
  258. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  259. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  260. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  261. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  262. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  263. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  264. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  265. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  266. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  267. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  268. /package/dist/{ccip-ZGGWQN4X.js.map → config-5ADBAAXU.js.map} +0 -0
  269. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  270. /package/dist/{config-JMRUNYE6.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  271. /package/dist/{doctor-ZBG7X66D.js.map → install-OKDKGUXM.js.map} +0 -0
  272. /package/dist/{edit-PZJIILQE.js.map → paths-P2N4JTDZ.js.map} +0 -0
  273. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-3SYKHKWJ.js.map} +0 -0
  274. /package/dist/{fund-EUDH5KPA.js.map → redact-6W23GGJC.js.map} +0 -0
  275. /package/dist/{inspect-QC6WEQPN.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  276. /package/dist/{outcome-KSGWZHUS.js.map → status-line-wiring-L2WYIYBM.js.map} +0 -0
  277. /package/dist/{publish-LXWFDIKF.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  278. /package/dist/{search-TSQAB45E.js.map → wallet-BMEXRR3P.js.map} +0 -0
@@ -1,794 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- isSessionPresentable,
4
- readSessionFile,
5
- scopeSatisfies
6
- } from "./chunk-HRGBS2PA.js";
7
- import {
8
- trimSlash,
9
- tryOriginOf
10
- } from "./chunk-EDZSNPE5.js";
11
- import {
12
- fetchJson
13
- } from "./chunk-5QQTYWEU.js";
14
- import {
15
- walletFileExists
16
- } from "./chunk-GHLVXVZD.js";
17
- import {
18
- sanitizeForTerminal
19
- } from "./chunk-OLWTRUTS.js";
20
- import {
21
- modeGatedPointer,
22
- permissionsPointer,
23
- recommendedPermissions
24
- } from "./chunk-4CQIDQOT.js";
25
- import {
26
- loadProjectConfig
27
- } from "./chunk-VYOJOX4Z.js";
28
- import {
29
- toMoney
30
- } from "./chunk-EFWZPUTC.js";
31
- import {
32
- loadRawConfig,
33
- resolveSettings
34
- } from "./chunk-U6VPKMGC.js";
35
- import {
36
- MODE_GATED_RULES,
37
- inspectFreeVerbRules,
38
- readHermesIntegrationStatus,
39
- resolveHermesHomeLenient
40
- } from "./chunk-OKYSNAS3.js";
41
- import {
42
- CLI_SKILL_NAMES,
43
- HOSTED_SKILL_NAME,
44
- OPTIONAL_PAY_SKILL,
45
- OPTIONAL_SKILL_NAMES,
46
- anyTenjinSkill,
47
- cliSkillsWired,
48
- detectHarnesses,
49
- harnessDetectedBy,
50
- harnessFlagFor,
51
- harnessInPlay,
52
- harnessReads,
53
- harnessRequested,
54
- missingCliSkills,
55
- onPath,
56
- readAllWiring,
57
- readSkillFile,
58
- resolveSkillsSource,
59
- shadowedCliSkills
60
- } from "./chunk-2MYQN7HM.js";
61
- import {
62
- CliError,
63
- configPath,
64
- sessionPath
65
- } from "./chunk-ZFJJ3EXC.js";
66
-
67
- // src/commands/doctor.ts
68
- import { styleText } from "util";
69
- import { Stream } from "stream";
70
- import { homedir } from "os";
71
- import { join } from "path";
72
- import { fileURLToPath } from "url";
73
- var POCKET_MONEY_CEILING_ATOMIC = 20000000n;
74
- var FIX_POINT_AT_TENJIN_API = "Point the configured base URL at a Tenjin API (expected an OpenAPI document): `tenjin config set baseUrl <url>`.";
75
- var FIX_CHECK_NETWORK_AND_BASE_URL = "Check your network connection and the configured base URL (`tenjin config get baseUrl`).";
76
- async function collectDoctorChecks(ctx, deps = {}) {
77
- const env = deps.env ?? process.env;
78
- const { config, check: configCheck } = await loadConfigForDoctor(ctx.dataDir);
79
- const project = await loadProjectConfig(deps.cwd ?? process.cwd()).catch(() => null);
80
- const settings = resolveSettings({
81
- config,
82
- flags: { baseUrl: ctx.flags.baseUrl },
83
- env,
84
- project: project?.layer
85
- });
86
- const baseUrl = settings.baseUrl.value;
87
- const home = deps.homeDir ?? homedir();
88
- const which = deps.which ?? ((bin) => onPath(bin, env));
89
- const requested = config.install?.harness ?? [];
90
- const hermesTarget = deps.hermesHome === void 0 ? resolveHermesHomeLenient(home, env) : { home: deps.hermesHome, warning: void 0 };
91
- const hermesHome = hermesTarget.home;
92
- const built = [
93
- checkNode(),
94
- configCheck,
95
- await checkApiContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),
96
- await checkReadPath(baseUrl, ctx.flags.timeout, deps.fetchImpl),
97
- await checkSearchContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),
98
- await checkSkills(
99
- home,
100
- which,
101
- requested,
102
- settings.bazaarPay.value,
103
- deps.skillsSourceDir,
104
- hermesHome
105
- ),
106
- await checkSession(ctx.dataDir, deps.now ?? Date.now, tryOriginOf(baseUrl))
107
- ];
108
- const hermes = await checkHermes({
109
- home,
110
- hermesHome,
111
- which,
112
- requested,
113
- webSearch: config.hooks?.webSearch ?? config.hooks?.searchMode,
114
- homeWarning: hermesTarget.warning
115
- });
116
- if (hermes !== null) built.push(hermes);
117
- for (const result of await checkWallet(ctx, deps, env, settings.rpcUrl.value)) {
118
- built.push({ result });
119
- }
120
- const checks = built.map((b) => b.result);
121
- const publishMode = settings.publishMode.value;
122
- const probe = await inspectFreeVerbRules(deps.homeDir ?? homedir(), publishMode);
123
- const gated = new Set(MODE_GATED_RULES);
124
- const missingModeGated = (probe.pending ?? []).filter((r) => gated.has(r));
125
- const firstFail = built.find((b) => b.result.required && b.result.status === "fail");
126
- if (firstFail === void 0) return { checks, publishMode, missingModeGated };
127
- return {
128
- checks,
129
- publishMode,
130
- missingModeGated,
131
- failure: { code: firstFail.failCode ?? "INTERNAL", result: firstFail.result }
132
- };
133
- }
134
- async function runDoctor(ctx, deps = {}) {
135
- const { checks, failure, publishMode, missingModeGated } = await collectDoctorChecks(ctx, deps);
136
- if (failure !== void 0) {
137
- const r = failure.result;
138
- throw new CliError(failure.code, r.detail, {
139
- ...r.fix !== void 0 ? { fix: r.fix } : {},
140
- details: { checks, permissions: recommendedPermissions(publishMode) }
141
- });
142
- }
143
- const env = deps.env ?? process.env;
144
- const fromEnv = env.TENJIN_PUBLISH_MODE !== void 0 && env.TENJIN_PUBLISH_MODE.length > 0;
145
- const modeLine = fromEnv ? `TENJIN_PUBLISH_MODE=${publishMode} is overriding your configured publish mode for this run only; the harness rules it needs are ${missingModeGated.join(" and ")}.` : modeGatedPointer(publishMode, missingModeGated, "tenjin install");
146
- const showModeLine = fromEnv ? missingModeGated.length > 0 : modeLine !== null;
147
- return {
148
- data: { status: "pass", checks, permissions: recommendedPermissions(publishMode) },
149
- humanLines: [
150
- ...renderDoctorHuman(ctx.io, checks),
151
- "",
152
- ...showModeLine && modeLine !== null ? [modeLine] : [],
153
- permissionsPointer()
154
- ]
155
- };
156
- }
157
- function checkNode() {
158
- const version = process.versions.node;
159
- const major = Number.parseInt(version.split(".")[0] ?? "0", 10);
160
- if (major >= 22) {
161
- return { result: { name: "node", status: "ok", required: true, detail: `Node ${version}` } };
162
- }
163
- return {
164
- result: {
165
- name: "node",
166
- status: "fail",
167
- required: true,
168
- detail: `Node ${version} is unsupported (need >= 22)`,
169
- fix: "Install Node 22 or newer"
170
- },
171
- failCode: "NODE_UNSUPPORTED"
172
- };
173
- }
174
- async function loadConfigForDoctor(dataDir) {
175
- try {
176
- const config = await loadRawConfig(dataDir);
177
- const detail = Object.keys(config).length === 0 ? "No config file; using defaults" : `Config at ${configPath(dataDir)} is valid`;
178
- return { config, check: { result: { name: "config", status: "ok", required: true, detail } } };
179
- } catch (err) {
180
- if (err instanceof CliError && err.code === "CONFIG_INVALID") {
181
- return {
182
- config: {},
183
- check: {
184
- result: {
185
- name: "config",
186
- status: "fail",
187
- required: true,
188
- detail: err.message,
189
- ...err.fix !== void 0 ? { fix: err.fix } : {}
190
- },
191
- failCode: "CONFIG_INVALID"
192
- }
193
- };
194
- }
195
- throw err;
196
- }
197
- }
198
- async function checkApiContract(baseUrl, timeoutMs, fetchImpl) {
199
- const url = `${trimSlash(baseUrl)}/openapi.json`;
200
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
201
- if (!res.ok) {
202
- const malformed = res.kind === "invalid-json";
203
- return {
204
- result: {
205
- name: "api-contract",
206
- status: "fail",
207
- required: true,
208
- detail: malformed ? `OpenAPI document at ${url} was not valid JSON` : `Could not reach the Tenjin API at ${url}: ${res.message}`,
209
- fix: malformed ? FIX_POINT_AT_TENJIN_API : FIX_CHECK_NETWORK_AND_BASE_URL
210
- },
211
- failCode: malformed ? "CONTRACT_MISMATCH" : "API_UNREACHABLE"
212
- };
213
- }
214
- const version = infoVersion(res.json);
215
- if (version === void 0) {
216
- return {
217
- result: {
218
- name: "api-contract",
219
- status: "fail",
220
- required: true,
221
- detail: `OpenAPI document at ${url} is missing a string info.version`,
222
- fix: FIX_POINT_AT_TENJIN_API
223
- },
224
- failCode: "CONTRACT_MISMATCH"
225
- };
226
- }
227
- return {
228
- result: {
229
- name: "api-contract",
230
- status: "ok",
231
- required: true,
232
- detail: `Tenjin API ${version} at ${baseUrl}`
233
- }
234
- };
235
- }
236
- async function checkSearchContract(baseUrl, timeoutMs, fetchImpl) {
237
- const url = `${trimSlash(baseUrl)}/openapi.json`;
238
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
239
- if (!res.ok) {
240
- return {
241
- result: {
242
- name: "search-contract",
243
- status: "warn",
244
- required: false,
245
- detail: `Could not confirm the search endpoint at ${url}`,
246
- fix: "Check the configured base URL (`tenjin config get baseUrl`); search/buy need the A2 endpoints deployed."
247
- }
248
- };
249
- }
250
- const present = hasSearchPath(res.json);
251
- return {
252
- result: present ? {
253
- name: "search-contract",
254
- status: "ok",
255
- required: false,
256
- detail: "Search endpoint advertised"
257
- } : {
258
- name: "search-contract",
259
- status: "warn",
260
- required: false,
261
- detail: "This deployment does not advertise POST /api/search (it predates search v3)",
262
- fix: "search/buy need search v3 deployed; point the configured base URL at a deploy that has it (`tenjin config set baseUrl <url>`)."
263
- }
264
- };
265
- }
266
- function hasSearchPath(json) {
267
- if (!isRecord(json)) return false;
268
- const paths = json.paths;
269
- return isRecord(paths) && "/api/search" in paths;
270
- }
271
- async function checkSkills(home, which, requested, bazaarPay, skillsSourceDir, hermesHome) {
272
- const resolvedHermesHome = hermesHome;
273
- const present = detectHarnesses(home, which, resolvedHermesHome);
274
- const wiring = await readAllWiring(home, resolvedHermesHome);
275
- const data = {
276
- directories: wiring.map((w) => ({
277
- ...w,
278
- harnessPresent: harnessReads(home, w.dir, present, resolvedHermesHome),
279
- requested: harnessRequested(home, w.dir, requested, resolvedHermesHome)
280
- }))
281
- };
282
- const inPlay = wiring.filter((w) => anyTenjinSkill(w));
283
- if (inPlay.length === 0) {
284
- const targeted = requested.length > 0 ? wiring.filter((w) => harnessInPlay(home, w.dir, present, requested, resolvedHermesHome)) : [];
285
- return {
286
- result: {
287
- name: "skills",
288
- status: "warn",
289
- required: false,
290
- detail: `No Tenjin skills wired under ${home} (looked in .claude/skills, .agents/skills, and Hermes skills)`,
291
- fix: targeted.length > 0 ? fixFor(home, targeted, resolvedHermesHome) : "tenjin install",
292
- data
293
- }
294
- };
295
- }
296
- const broken = wiring.filter(
297
- (w) => harnessInPlay(home, w.dir, present, requested, resolvedHermesHome) && !cliSkillsWired(w)
298
- );
299
- if (broken.length > 0) {
300
- return {
301
- result: {
302
- name: "skills",
303
- status: "warn",
304
- required: false,
305
- detail: `${broken.map(describeProblem).join("; ")}. Full state: ${describeWiring(inPlay)}`,
306
- fix: fixFor(home, broken, resolvedHermesHome),
307
- data
308
- }
309
- };
310
- }
311
- const payDrift = [];
312
- for (const w of inPlay) {
313
- if (!harnessInPlay(home, w.dir, present, requested, resolvedHermesHome)) continue;
314
- const onDisk = await readSkillFile(join(w.dir, OPTIONAL_PAY_SKILL, "SKILL.md"));
315
- if (onDisk.kind === "ok" !== bazaarPay) payDrift.push(w.dir);
316
- }
317
- if (payDrift.length > 0) {
318
- return {
319
- result: {
320
- name: "skills",
321
- status: "warn",
322
- required: false,
323
- detail: bazaarPay ? `bazaarPay is on but the ${OPTIONAL_PAY_SKILL} skill is missing under ${payDrift.join(", ")}; agents are not being taught the lane` : `bazaarPay is off but the ${OPTIONAL_PAY_SKILL} skill is still present under ${payDrift.join(", ")}; agents are being taught a lane the runtime gate will refuse`,
324
- fix: `Re-run \`tenjin config set bazaarPay ${bazaarPay ? "on" : "off"}\` to re-sync the skill's presence.`,
325
- data
326
- }
327
- };
328
- }
329
- const { stale, verifiable } = await compareWiredSkills(
330
- wiring.map((w) => w.dir),
331
- skillsSourceDir
332
- );
333
- if (!verifiable) {
334
- return {
335
- result: {
336
- name: "skills",
337
- status: "warn",
338
- required: false,
339
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired, but this build's packaged copies could not be read, so whether they are current is unknown`,
340
- // NOT `tenjin update`: this warning means the packaged copies are
341
- // unreadable, which a current version answers with "up to date" and no
342
- // work at all. Reinstalling the same version is the actual repair.
343
- fix: "Reinstall the CLI: `npm i -g tenjin-cli`, then `tenjin install`.",
344
- data
345
- }
346
- };
347
- }
348
- if (stale.length > 0) {
349
- return {
350
- result: {
351
- name: "skills",
352
- status: "warn",
353
- required: false,
354
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired but not from this CLI build (${stale.join(", ")}); agents are reading an older version's instructions`,
355
- // fixFor, like every neighbouring branch: a plain `tenjin install` targets
356
- // DETECTED harnesses only, so for a directory that exists because someone
357
- // passed --harness it would be a fix that never clears the warning.
358
- fix: fixFor(
359
- home,
360
- wiring.filter((w) => stale.includes(w.dir)),
361
- resolvedHermesHome
362
- ),
363
- data
364
- }
365
- };
366
- }
367
- return {
368
- result: {
369
- name: "skills",
370
- status: "ok",
371
- required: false,
372
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired: ${describeWiring(inPlay)}`,
373
- data
374
- }
375
- };
376
- }
377
- async function checkHermes(args) {
378
- const { home, hermesHome, which, requested, webSearch: searchMode, homeWarning } = args;
379
- const inPlay = requested.includes("hermes") || harnessDetectedBy(home, "hermes", which, hermesHome).length > 0;
380
- if (!inPlay) return null;
381
- const status = {
382
- ...await readHermesIntegrationStatus(hermesHome),
383
- ...homeWarning !== void 0 ? { homeWarning } : {}
384
- };
385
- const ok = status.mcp === "configured" && status.plugin === "installed" && status.activation === "enabled";
386
- if (ok && homeWarning === void 0) {
387
- return {
388
- result: {
389
- name: "hermes",
390
- status: "ok",
391
- required: false,
392
- detail: `Native Tenjin retrieval and publish-back plugin enabled in ${hermesHome}`,
393
- data: status
394
- }
395
- };
396
- }
397
- const problems = [];
398
- if (status.mcp === "stale") {
399
- problems.push(`MCP command missing (${status.mcpCommand ?? "unknown"})`);
400
- } else if (status.mcp !== "configured") problems.push(`MCP ${status.mcp}`);
401
- if (status.plugin !== "installed") problems.push(`plugin ${status.plugin}`);
402
- if (status.activation !== "enabled") problems.push(`activation ${status.activation}`);
403
- if (homeWarning !== void 0) problems.push("HERMES_HOME ignored");
404
- return {
405
- result: {
406
- name: "hermes",
407
- status: "warn",
408
- required: false,
409
- detail: `Hermes Tenjin integration incomplete in ${hermesHome}: ${problems.join(", ")}${homeWarning === void 0 ? "" : `. ${homeWarning}`}`,
410
- // `tenjin install --harness hermes` alone is a dead end when the stored mode
411
- // is `off`: it re-runs, withholds the hook code by design, and prints the same
412
- // warning forever. Name the blocker that actually has to move first.
413
- fix: searchMode === "off" ? "tenjin config set hooks.webSearch auto && tenjin install --harness hermes" : "tenjin install --harness hermes",
414
- data: status
415
- }
416
- };
417
- }
418
- async function compareWiredSkills(dirs, sourceDir) {
419
- let source;
420
- try {
421
- source = sourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
422
- } catch {
423
- return { stale: [], verifiable: false };
424
- }
425
- const packaged = /* @__PURE__ */ new Map();
426
- for (const name of [...CLI_SKILL_NAMES, ...OPTIONAL_SKILL_NAMES]) {
427
- const read = await readSkillFile(join(source, name, "SKILL.md"));
428
- if (read.kind === "ok") packaged.set(name, read.bytes);
429
- }
430
- if (CLI_SKILL_NAMES.some((name) => !packaged.has(name))) {
431
- return { stale: [], verifiable: false };
432
- }
433
- const stale = [];
434
- for (const dir of dirs) {
435
- for (const name of [...CLI_SKILL_NAMES, ...OPTIONAL_SKILL_NAMES]) {
436
- if (!packaged.has(name)) continue;
437
- const onDisk = await readSkillFile(join(dir, name, "SKILL.md"));
438
- if (onDisk.kind !== "ok") continue;
439
- if (!packaged.get(name).equals(onDisk.bytes)) {
440
- stale.push(dir);
441
- break;
442
- }
443
- }
444
- }
445
- return { stale, verifiable: true };
446
- }
447
- function describeProblem(w) {
448
- const shadowed = shadowedCliSkills(w);
449
- const missing = missingCliSkills(w);
450
- const parts = [];
451
- const unreadable = shadowed.filter((n) => reasonFor(w, n) === "unreadable");
452
- const disabled = shadowed.filter((n) => reasonFor(w, n) !== "unreadable");
453
- if (disabled.length > 0) {
454
- parts.push(
455
- `${disabled.join(", ")} installed but not model-invocable (disable-model-invocation: true)`
456
- );
457
- }
458
- if (unreadable.length > 0) {
459
- parts.push(
460
- `${unreadable.join(", ")} installed but not model-invocable (unreadable or disable-model-invocation: true)`
461
- );
462
- }
463
- if (missing.length === CLI_SKILL_NAMES.length) {
464
- parts.push(
465
- w.state === "hosted-only" ? `the hosted ${HOSTED_SKILL_NAME} skill is here but neither CLI skill is wired` : "neither CLI skill is wired"
466
- );
467
- } else if (missing.length > 0) parts.push(`${missing.join(", ")} missing`);
468
- return `${w.dir}: ${parts.join(" and ")}`;
469
- }
470
- function reasonFor(w, name) {
471
- return w.skills.find((s) => s.name === name)?.reason;
472
- }
473
- function hostedHere(w) {
474
- return w.skills.find((s) => s.name === HOSTED_SKILL_NAME)?.present === true;
475
- }
476
- function fixFor(home, dirs, hermesHome) {
477
- const flags = [...new Set(dirs.map((w) => harnessFlagFor(home, w.dir, hermesHome)))];
478
- return `tenjin install ${flags.map((f) => `--harness ${f}`).join(" ")}`;
479
- }
480
- function describeWiring(wiring) {
481
- return wiring.map((w) => {
482
- const parts = w.skills.filter((s) => s.present).map(
483
- (s) => s.modelInvocable === false ? `${s.name} [${s.reason ?? "shadowed"}]` : s.name
484
- );
485
- return `${w.dir} -> ${parts.join(", ")} (${posture(w)})`;
486
- }).join("; ");
487
- }
488
- function posture(w) {
489
- if (w.state !== "wired") return POSTURE[w.state];
490
- return hostedHere(w) ? "CLI skills wired, take precedence over the hosted mirror" : "CLI skills wired";
491
- }
492
- var POSTURE = {
493
- empty: "no Tenjin skills",
494
- "hosted-only": "hosted skill only, no CLI skills here",
495
- partial: "only one CLI skill",
496
- // "at least one": a directory with one CLI skill shadowed and the other absent
497
- // classifies as `shadowed` too, and "CLI skills present" would be false there.
498
- shadowed: "at least one CLI skill present but not model-invocable",
499
- wired: "CLI skills wired, take precedence over the hosted mirror"
500
- };
501
- async function checkSession(dataDir, now, origin) {
502
- const warn = (detail, data2) => ({
503
- result: {
504
- name: "session",
505
- status: "warn",
506
- required: false,
507
- detail,
508
- fix: "tenjin session start --scope read",
509
- ...data2 !== void 0 ? { data: data2 } : {}
510
- }
511
- });
512
- const state = await readSessionFile(dataDir);
513
- if (state.kind === "absent") {
514
- return {
515
- result: {
516
- name: "session",
517
- status: "ok",
518
- required: false,
519
- detail: "No session key; `tenjin read` delivers free and locally-cached pieces (`tenjin session start --scope read` adds owned-piece recovery)"
520
- }
521
- };
522
- }
523
- if (state.kind === "loosened") {
524
- return warn(
525
- `Session key at ${sessionPath(dataDir)} is mode 0${state.mode.toString(8)}, not 0600, so it is refused; it holds a wallet-derived credential and was changed out of band. Delete it and re-mint`
526
- );
527
- }
528
- if (state.kind === "outdated") {
529
- return {
530
- result: {
531
- name: "session",
532
- status: "ok",
533
- required: false,
534
- detail: `Cached session key at ${sessionPath(dataDir)} predates this CLI version (no \`${state.field}\`) and is not used; \`tenjin session start --scope read\` mints a current one`
535
- }
536
- };
537
- }
538
- if (state.kind === "corrupt") {
539
- return warn(`Session key at ${sessionPath(dataDir)} could not be parsed (${state.reason})`);
540
- }
541
- if (state.kind === "unreadable") {
542
- return warn(`Session key at ${sessionPath(dataDir)} could not be read: ${state.message}`);
543
- }
544
- const file = state.file;
545
- if (origin === null) {
546
- return {
547
- result: {
548
- name: "session",
549
- status: "warn",
550
- required: false,
551
- detail: `Session key was minted for ${file.origin}, but the configured base URL is not an http(s) origin, so it cannot be matched`,
552
- fix: "Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`.",
553
- data: { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp }
554
- }
555
- };
556
- }
557
- const data = { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp };
558
- if (file.origin !== origin) {
559
- return warn(
560
- `Session key was minted for ${file.origin}, but the configured base URL is ${origin}; it is not presented off its own origin`,
561
- data
562
- );
563
- }
564
- if (!Number.isFinite(Date.parse(file.exp))) {
565
- return warn(
566
- `Session key for ${file.address} carries an unparseable expiry (exp ${file.exp})`,
567
- data
568
- );
569
- }
570
- if (!scopeSatisfies(file.scope, "read")) {
571
- return {
572
- result: {
573
- name: "session",
574
- status: "ok",
575
- required: false,
576
- detail: `Session key has scope ${file.scope}, which does not cover reading; \`tenjin session start --scope read\` mints one that does`,
577
- data
578
- }
579
- };
580
- }
581
- if (!isSessionPresentable(file, now(), "read", origin)) {
582
- return {
583
- result: {
584
- name: "session",
585
- status: "ok",
586
- required: false,
587
- detail: "Session key expired (normal after 24h); mint one with `tenjin session start --scope read` when you want free re-reads of owned pieces",
588
- data
589
- }
590
- };
591
- }
592
- return {
593
- result: {
594
- name: "session",
595
- status: "ok",
596
- required: false,
597
- detail: `Session key ${file.address}, scope ${file.scope}, for ${file.origin}, expires ${file.exp}`,
598
- data
599
- }
600
- };
601
- }
602
- async function checkReadPath(baseUrl, timeoutMs, fetchImpl) {
603
- const url = `${trimSlash(baseUrl)}/api/articles?limit=1`;
604
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
605
- if (!res.ok) {
606
- return {
607
- result: {
608
- name: "read-path",
609
- status: "fail",
610
- required: true,
611
- detail: `Read path ${url} failed: ${res.message}`,
612
- fix: FIX_CHECK_NETWORK_AND_BASE_URL
613
- },
614
- failCode: "API_UNREACHABLE"
615
- };
616
- }
617
- const items = isRecord(res.json) ? res.json.items : void 0;
618
- if (!Array.isArray(items)) {
619
- return {
620
- result: {
621
- name: "read-path",
622
- status: "fail",
623
- required: true,
624
- detail: `Read path ${url} did not return an items array`,
625
- fix: "Point the configured base URL at a Tenjin API: `tenjin config set baseUrl <url>`."
626
- },
627
- failCode: "API_UNREACHABLE"
628
- };
629
- }
630
- return {
631
- result: { name: "read-path", status: "ok", required: true, detail: `Read path OK at ${url}` }
632
- };
633
- }
634
- async function checkWallet(ctx, deps, env, rpcUrl) {
635
- const provider = deps.provider ?? await resolveLocalProviderOrNull(ctx, env, deps);
636
- if (provider === null) return [noWalletCheck()];
637
- const { describeWallet } = await import("./wallet-TQ7D5EQ7.js");
638
- let desc;
639
- try {
640
- desc = await describeWallet(provider);
641
- } catch (err) {
642
- if (err instanceof CliError && err.code === "WALLET_MISSING") return [noWalletCheck()];
643
- return [walletWarn(err)];
644
- }
645
- const checks = [walletCheck(desc, await verifyWallet(provider))];
646
- for (const warning of (await provider.diagnostics()).warnings) {
647
- checks.push({ name: "wallet-custody", status: "warn", required: false, detail: warning });
648
- }
649
- checks.push(await checkBalance(desc.address, rpcUrl));
650
- return checks;
651
- }
652
- async function resolveLocalProviderOrNull(ctx, env, deps) {
653
- const envKey = env.TENJIN_WALLET_KEY;
654
- const envKeySet = typeof envKey === "string" && envKey.length > 0;
655
- if (!envKeySet && !await walletFileExists(ctx.dataDir)) return null;
656
- const { resolveWalletProvider } = await import("./wallet-TQ7D5EQ7.js");
657
- return resolveWalletProvider(ctx, {
658
- ...deps.walletPassphrase !== void 0 ? { passphrase: deps.walletPassphrase } : {}
659
- });
660
- }
661
- async function verifyWallet(provider) {
662
- if (provider.verify === void 0) {
663
- return {
664
- status: "unverified",
665
- detail: `provider "${provider.id}" cannot verify without a key`
666
- };
667
- }
668
- try {
669
- return await provider.verify();
670
- } catch (err) {
671
- return {
672
- status: "unverified",
673
- detail: `verification could not run (${err instanceof Error ? err.message : String(err)})`
674
- };
675
- }
676
- }
677
- function walletCheck(desc, v) {
678
- const head = `Wallet ${desc.address} (${desc.credentialSource})`;
679
- if (v.status === "broken") {
680
- return {
681
- name: "wallet",
682
- status: "warn",
683
- required: false,
684
- detail: `${head}: ${v.detail}`,
685
- fix: v.fix
686
- };
687
- }
688
- if (v.status === "unverified") {
689
- return {
690
- name: "wallet",
691
- status: "warn",
692
- required: false,
693
- detail: `${head} present, not verified: ${v.detail}`,
694
- fix: "Set TENJIN_WALLET_PASSPHRASE, or store the passphrase in your OS credential store, so doctor can prove the keystore still opens."
695
- };
696
- }
697
- return { name: "wallet", status: "ok", required: false, detail: `${head}, ${v.detail}` };
698
- }
699
- function noWalletCheck() {
700
- return {
701
- name: "wallet",
702
- status: "warn",
703
- required: false,
704
- detail: "No wallet; needed only for buy/publish",
705
- fix: "tenjin wallet create",
706
- data: { credential: "absent" }
707
- };
708
- }
709
- function isNoWalletCheck(c) {
710
- return c.name === "wallet" && isRecord(c.data) && c.data.credential === "absent";
711
- }
712
- function walletWarn(err) {
713
- return {
714
- name: "wallet",
715
- status: "warn",
716
- required: false,
717
- detail: err instanceof Error ? err.message : String(err),
718
- ...err instanceof CliError && err.fix !== void 0 ? { fix: err.fix } : {}
719
- };
720
- }
721
- async function checkBalance(address, rpcUrl) {
722
- try {
723
- const { getUsdcBalance } = await import("./usdc-4VCDHFWX.js");
724
- const balance = await getUsdcBalance(address, rpcUrl);
725
- if (balance === 0n) {
726
- return {
727
- name: "balance",
728
- status: "warn",
729
- required: false,
730
- detail: "Wallet USDC balance is 0",
731
- fix: "Fund it with `tenjin fund` (card via Coinbase), or send USDC on Base. $5 covers ~50 typical resources."
732
- };
733
- }
734
- const money = toMoney(balance.toString());
735
- if (balance > POCKET_MONEY_CEILING_ATOMIC) {
736
- return {
737
- name: "balance",
738
- status: "warn",
739
- required: false,
740
- detail: `Balance ${money.usd} USDC is above the ~$20 pocket-money ceiling`,
741
- fix: "Keep only small change in the CLI wallet; sweep the excess to cold storage."
742
- };
743
- }
744
- return {
745
- name: "balance",
746
- status: "ok",
747
- required: false,
748
- detail: `Balance ${money.usd} USDC (${money.atomic} atomic)`
749
- };
750
- } catch (err) {
751
- return {
752
- name: "balance",
753
- status: "warn",
754
- required: false,
755
- detail: `Could not read balance: ${err instanceof Error ? err.message : String(err)}`,
756
- fix: "Check rpcUrl or retry; a balance read failure never fails doctor."
757
- };
758
- }
759
- }
760
- function renderDoctorHuman(io, checks) {
761
- const nameWidth = Math.max(...checks.map((c) => c.name.length));
762
- const lines = [];
763
- for (const c of checks) {
764
- const icon = c.status === "ok" ? paint(io, "green", "\u2713") : c.status === "warn" ? paint(io, "yellow", "!") : paint(io, "red", "\u2717");
765
- lines.push(
766
- `${icon} ${c.name.padEnd(nameWidth)} ${paint(io, "dim", sanitizeForTerminal(c.detail))}`
767
- );
768
- if (c.status !== "ok" && c.fix !== void 0) {
769
- lines.push(` ${paint(io, "dim", `fix: ${sanitizeForTerminal(c.fix)}`)}`);
770
- }
771
- }
772
- return lines;
773
- }
774
- function paint(io, format, text) {
775
- if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });
776
- return styleText(format, text);
777
- }
778
- function infoVersion(json) {
779
- if (!isRecord(json)) return void 0;
780
- const info = json.info;
781
- if (!isRecord(info)) return void 0;
782
- return typeof info.version === "string" ? info.version : void 0;
783
- }
784
- function isRecord(value) {
785
- return typeof value === "object" && value !== null;
786
- }
787
-
788
- export {
789
- collectDoctorChecks,
790
- runDoctor,
791
- isNoWalletCheck,
792
- renderDoctorHuman
793
- };
794
- //# sourceMappingURL=chunk-R7RSCBI7.js.map