tenjin-cli 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (253) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +41 -295
  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-25TJPVBF.js +353 -0
  7. package/dist/chunk-25TJPVBF.js.map +1 -0
  8. package/dist/chunk-2BKS2FVE.js +93 -0
  9. package/dist/chunk-2BKS2FVE.js.map +1 -0
  10. package/dist/chunk-2QYORQBF.js +55 -0
  11. package/dist/chunk-2QYORQBF.js.map +1 -0
  12. package/dist/{chunk-ACBEHJAH.js → chunk-2U5ZVEV3.js} +14 -16
  13. package/dist/chunk-2U5ZVEV3.js.map +1 -0
  14. package/dist/{chunk-MJSXP4LW.js → chunk-3AJS6LLN.js} +11 -8
  15. package/dist/chunk-3AJS6LLN.js.map +1 -0
  16. package/dist/{chunk-OWVVI4VQ.js → chunk-3AUDA53C.js} +7650 -7361
  17. package/dist/chunk-3AUDA53C.js.map +1 -0
  18. package/dist/{chunk-MJZZTKCC.js → chunk-56MOAIP5.js} +5 -10
  19. package/dist/chunk-56MOAIP5.js.map +1 -0
  20. package/dist/{chunk-U5S527PP.js → chunk-5IEP5EGE.js} +3 -3
  21. package/dist/chunk-5X4SZ5BF.js +227 -0
  22. package/dist/chunk-5X4SZ5BF.js.map +1 -0
  23. package/dist/chunk-7WEQQJLG.js +68 -0
  24. package/dist/chunk-7WEQQJLG.js.map +1 -0
  25. package/dist/{chunk-7FK2UN2T.js → chunk-AWQPGIR6.js} +65 -67
  26. package/dist/{chunk-7FK2UN2T.js.map → chunk-AWQPGIR6.js.map} +1 -1
  27. package/dist/{chunk-PAOVPSP6.js → chunk-BBVUVBUO.js} +517 -138
  28. package/dist/chunk-BBVUVBUO.js.map +1 -0
  29. package/dist/{chunk-ETKZWJ4B.js → chunk-BFFM2WFK.js} +8 -8
  30. package/dist/chunk-BFFM2WFK.js.map +1 -0
  31. package/dist/{chunk-KYQVEKP5.js → chunk-BPMWXTFX.js} +8 -8
  32. package/dist/chunk-DMZZLPZN.js +205 -0
  33. package/dist/chunk-DMZZLPZN.js.map +1 -0
  34. package/dist/{chunk-47PP7TAG.js → chunk-EGELTSPU.js} +1356 -1356
  35. package/dist/chunk-EGELTSPU.js.map +1 -0
  36. package/dist/chunk-GULLJQXA.js +698 -0
  37. package/dist/chunk-GULLJQXA.js.map +1 -0
  38. package/dist/{chunk-S5RYMCV6.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-HVRC33OL.js +174 -0
  40. package/dist/chunk-HVRC33OL.js.map +1 -0
  41. package/dist/{chunk-W6R3HAAG.js → chunk-JRGFKVAZ.js} +2 -2
  42. package/dist/{chunk-XJN5WUKL.js → chunk-KG3D7FIF.js} +2 -2
  43. package/dist/chunk-L3PVMIYQ.js +10328 -0
  44. package/dist/chunk-L3PVMIYQ.js.map +1 -0
  45. package/dist/{chunk-QW2Q2KAH.js → chunk-LHHMV4GU.js} +2 -2
  46. package/dist/{chunk-ZOBNS7CX.js → chunk-MEFB5KHA.js} +4 -18
  47. package/dist/chunk-MEFB5KHA.js.map +1 -0
  48. package/dist/{chunk-M2O56UK7.js → chunk-N35E6CM2.js} +293 -163
  49. package/dist/chunk-N35E6CM2.js.map +1 -0
  50. package/dist/chunk-OCBHUHWB.js +69 -0
  51. package/dist/chunk-OCBHUHWB.js.map +1 -0
  52. package/dist/chunk-OIM4HLN6.js +1405 -0
  53. package/dist/chunk-OIM4HLN6.js.map +1 -0
  54. package/dist/{chunk-PKW3H26Z.js → chunk-OJLYNM4Z.js} +56 -33
  55. package/dist/chunk-OJLYNM4Z.js.map +1 -0
  56. package/dist/{chunk-POJRB2AE.js → chunk-POUWHWID.js} +2 -2
  57. package/dist/chunk-PZEN5PHN.js +285 -0
  58. package/dist/chunk-PZEN5PHN.js.map +1 -0
  59. package/dist/chunk-SKAHDQH7.js +1785 -0
  60. package/dist/chunk-SKAHDQH7.js.map +1 -0
  61. package/dist/{chunk-KZAAWQNP.js → chunk-TTNESUPQ.js} +3 -3
  62. package/dist/{chunk-QWBUKIP2.js → chunk-U5DXNFJC.js} +23 -94
  63. package/dist/chunk-U5DXNFJC.js.map +1 -0
  64. package/dist/chunk-USS336NF.js +165 -0
  65. package/dist/chunk-USS336NF.js.map +1 -0
  66. package/dist/{chunk-UO22YNY4.js → chunk-WH7OWT6G.js} +49 -1
  67. package/dist/chunk-WH7OWT6G.js.map +1 -0
  68. package/dist/chunk-WXC57XGG.js +29 -0
  69. package/dist/chunk-WXC57XGG.js.map +1 -0
  70. package/dist/{chunk-YLYINX2H.js → chunk-XZKD7DIF.js} +3 -3
  71. package/dist/{chunk-7GJQ5RGA.js → chunk-YEETV6IW.js} +1077 -1039
  72. package/dist/chunk-YEETV6IW.js.map +1 -0
  73. package/dist/{chunk-B676GPS2.js → chunk-YJHHCWM3.js} +39 -16
  74. package/dist/chunk-YJHHCWM3.js.map +1 -0
  75. package/dist/{cli-U2BEUA55.js → cli-M3XCSOU6.js} +295 -349
  76. package/dist/cli-M3XCSOU6.js.map +1 -0
  77. package/dist/config-MXOX7XDR.js +41 -0
  78. package/dist/{dist-U4M6QCKE.js → dist-3LOO6M4U.js} +10 -10
  79. package/dist/doctor-LU4YIZWM.js +349 -0
  80. package/dist/doctor-LU4YIZWM.js.map +1 -0
  81. package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  82. package/dist/{chunk-3ZW7HPY5.js → fund-A54P2QFK.js} +81 -22
  83. package/dist/fund-A54P2QFK.js.map +1 -0
  84. package/dist/hook-command-U6KWPEDQ.js +377 -0
  85. package/dist/hook-command-U6KWPEDQ.js.map +1 -0
  86. package/dist/index.js +8 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/install-XUM2XSHW.js +53 -0
  89. package/dist/install-wallet-QIOFORTX.js +105 -0
  90. package/dist/install-wallet-QIOFORTX.js.map +1 -0
  91. package/dist/{run-CJWPGMIQ.js → mcp-HJC2PLRV.js} +3725 -10661
  92. package/dist/mcp-HJC2PLRV.js.map +1 -0
  93. package/dist/paths-P2N4JTDZ.js +49 -0
  94. package/dist/pay-SBXZEPEP.js +37 -0
  95. package/dist/redact-46ZHF2NH.js +17 -0
  96. package/dist/{secp256k1-XRPVBC6V.js → secp256k1-ZZZT2CAX.js} +3 -3
  97. package/dist/{send-C5EOKXOU.js → send-ASD2ZXJD.js} +28 -30
  98. package/dist/send-ASD2ZXJD.js.map +1 -0
  99. package/dist/{chunk-NAAMHWSI.js → skill-placement-NFVHY6A3.js} +159 -12
  100. package/dist/skill-placement-NFVHY6A3.js.map +1 -0
  101. package/dist/status-T2SDB57A.js +63 -0
  102. package/dist/status-T2SDB57A.js.map +1 -0
  103. package/dist/status-line-CGPUSDMC.js +71 -0
  104. package/dist/status-line-CGPUSDMC.js.map +1 -0
  105. package/dist/status-line-wiring-BYPHTYZE.js +30 -0
  106. package/dist/tenjin-daemon.mjs +20060 -0
  107. package/dist/tenjin-shim.mjs +251 -0
  108. package/dist/tenjin-vitest-reporter.mjs +49 -0
  109. package/dist/uninstall-FKYZHAM3.js +144 -0
  110. package/dist/uninstall-FKYZHAM3.js.map +1 -0
  111. package/dist/{update-24Y2CQTT.js → update-ANJ2AOTN.js} +133 -17
  112. package/dist/update-ANJ2AOTN.js.map +1 -0
  113. package/dist/{viemAdapter-By13KInL-TUQJBMHM.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  114. package/dist/wallet-PWAHVKWW.js +31 -0
  115. package/dist/wallet-kdf-worker.mjs +980 -0
  116. package/docs/agent-permissions.md +68 -342
  117. package/docs/safety-model.md +25 -6
  118. package/package.json +8 -7
  119. package/LICENSE +0 -21
  120. package/dist/buy-2JBYPHAI.js +0 -46
  121. package/dist/chunk-3P3ES4XU.js +0 -144
  122. package/dist/chunk-3P3ES4XU.js.map +0 -1
  123. package/dist/chunk-3ZW7HPY5.js.map +0 -1
  124. package/dist/chunk-47PP7TAG.js.map +0 -1
  125. package/dist/chunk-4UHNXY6B.js +0 -786
  126. package/dist/chunk-4UHNXY6B.js.map +0 -1
  127. package/dist/chunk-4Y53PDH6.js +0 -213
  128. package/dist/chunk-4Y53PDH6.js.map +0 -1
  129. package/dist/chunk-54AJIO3E.js +0 -198
  130. package/dist/chunk-54AJIO3E.js.map +0 -1
  131. package/dist/chunk-736DW4V3.js +0 -65
  132. package/dist/chunk-736DW4V3.js.map +0 -1
  133. package/dist/chunk-7GJQ5RGA.js.map +0 -1
  134. package/dist/chunk-7NADDA2V.js +0 -161
  135. package/dist/chunk-7NADDA2V.js.map +0 -1
  136. package/dist/chunk-ACBEHJAH.js.map +0 -1
  137. package/dist/chunk-B676GPS2.js.map +0 -1
  138. package/dist/chunk-DAZAXFSF.js +0 -1357
  139. package/dist/chunk-DAZAXFSF.js.map +0 -1
  140. package/dist/chunk-DTCXO7HS.js +0 -791
  141. package/dist/chunk-DTCXO7HS.js.map +0 -1
  142. package/dist/chunk-ETKZWJ4B.js.map +0 -1
  143. package/dist/chunk-FDUD3W5V.js +0 -317
  144. package/dist/chunk-FDUD3W5V.js.map +0 -1
  145. package/dist/chunk-GEHL43VE.js +0 -711
  146. package/dist/chunk-GEHL43VE.js.map +0 -1
  147. package/dist/chunk-IU2HVT3Y.js +0 -313
  148. package/dist/chunk-IU2HVT3Y.js.map +0 -1
  149. package/dist/chunk-IUQZ4Z7M.js +0 -162
  150. package/dist/chunk-IUQZ4Z7M.js.map +0 -1
  151. package/dist/chunk-IXZJ3JOO.js +0 -614
  152. package/dist/chunk-IXZJ3JOO.js.map +0 -1
  153. package/dist/chunk-J6FUAIRR.js +0 -205
  154. package/dist/chunk-J6FUAIRR.js.map +0 -1
  155. package/dist/chunk-L6G35FU5.js +0 -105
  156. package/dist/chunk-L6G35FU5.js.map +0 -1
  157. package/dist/chunk-LSWP7MU2.js +0 -290
  158. package/dist/chunk-LSWP7MU2.js.map +0 -1
  159. package/dist/chunk-M2O56UK7.js.map +0 -1
  160. package/dist/chunk-MJSXP4LW.js.map +0 -1
  161. package/dist/chunk-MJZZTKCC.js.map +0 -1
  162. package/dist/chunk-NAAMHWSI.js.map +0 -1
  163. package/dist/chunk-O75FOHXS.js +0 -372
  164. package/dist/chunk-O75FOHXS.js.map +0 -1
  165. package/dist/chunk-OWVVI4VQ.js.map +0 -1
  166. package/dist/chunk-PAOVPSP6.js.map +0 -1
  167. package/dist/chunk-PCX2JQ2J.js +0 -233
  168. package/dist/chunk-PCX2JQ2J.js.map +0 -1
  169. package/dist/chunk-PKW3H26Z.js.map +0 -1
  170. package/dist/chunk-PQZVDCCA.js +0 -125
  171. package/dist/chunk-PQZVDCCA.js.map +0 -1
  172. package/dist/chunk-QWBUKIP2.js.map +0 -1
  173. package/dist/chunk-SGK2B724.js +0 -67
  174. package/dist/chunk-SGK2B724.js.map +0 -1
  175. package/dist/chunk-UHTVXQ2O.js +0 -140
  176. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  177. package/dist/chunk-UO22YNY4.js.map +0 -1
  178. package/dist/chunk-VEAERJVJ.js +0 -43
  179. package/dist/chunk-VEAERJVJ.js.map +0 -1
  180. package/dist/chunk-VRPLZERE.js +0 -1421
  181. package/dist/chunk-VRPLZERE.js.map +0 -1
  182. package/dist/chunk-W4VW5XYB.js +0 -149
  183. package/dist/chunk-W4VW5XYB.js.map +0 -1
  184. package/dist/chunk-WU5CZPLD.js +0 -145
  185. package/dist/chunk-WU5CZPLD.js.map +0 -1
  186. package/dist/chunk-WYLMJQVH.js +0 -240
  187. package/dist/chunk-WYLMJQVH.js.map +0 -1
  188. package/dist/chunk-XGZ5EVMB.js +0 -35
  189. package/dist/chunk-XGZ5EVMB.js.map +0 -1
  190. package/dist/chunk-XVPQGCH4.js +0 -176
  191. package/dist/chunk-XVPQGCH4.js.map +0 -1
  192. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  193. package/dist/chunk-ZQIQ55KK.js +0 -51
  194. package/dist/chunk-ZQIQ55KK.js.map +0 -1
  195. package/dist/cli-U2BEUA55.js.map +0 -1
  196. package/dist/config-CNUIX23Q.js +0 -32
  197. package/dist/doctor-QJJXRWTO.js +0 -31
  198. package/dist/edit-HJ44P44P.js +0 -40
  199. package/dist/fund-Y5IAHZ5D.js +0 -40
  200. package/dist/inspect-NFQ6SQQQ.js +0 -37
  201. package/dist/install-DXX7PVUP.js +0 -854
  202. package/dist/install-DXX7PVUP.js.map +0 -1
  203. package/dist/outcome-ANV4QIED.js +0 -24
  204. package/dist/publish-PCBTCXCZ.js +0 -42
  205. package/dist/read-W7QVRBVD.js +0 -160
  206. package/dist/read-W7QVRBVD.js.map +0 -1
  207. package/dist/run-CJWPGMIQ.js.map +0 -1
  208. package/dist/search-JGAVKTYJ.js +0 -25
  209. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  210. package/dist/send-C5EOKXOU.js.map +0 -1
  211. package/dist/session-OBCUUIFX.js +0 -89
  212. package/dist/session-OBCUUIFX.js.map +0 -1
  213. package/dist/skill-heal-D6EPLPS6.js +0 -84
  214. package/dist/skill-heal-D6EPLPS6.js.map +0 -1
  215. package/dist/uninstall-OWJNJ5LI.js +0 -73
  216. package/dist/uninstall-OWJNJ5LI.js.map +0 -1
  217. package/dist/update-24Y2CQTT.js.map +0 -1
  218. package/dist/usdc-4VCDHFWX.js +0 -38
  219. package/dist/usdc-4VCDHFWX.js.map +0 -1
  220. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  221. package/dist/wallet-OFXDIIGP.js +0 -33
  222. package/dist/wallet-OFXDIIGP.js.map +0 -1
  223. package/dist/wallet-SLRIYJ2U.js +0 -42
  224. package/dist/wallet-SLRIYJ2U.js.map +0 -1
  225. package/docs/command-reference.md +0 -261
  226. package/skills/tenjin/SKILL.md +0 -364
  227. package/skills/tenjin-publish/SKILL.md +0 -224
  228. package/skills/tenjin-publish/references/maintain.md +0 -39
  229. package/skills/tenjin-search/SKILL.md +0 -149
  230. package/skills/tenjin-search/references/permissions.md +0 -106
  231. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  232. /package/dist/{buy-2JBYPHAI.js.map → ccip-7RMRLAGV.js.map} +0 -0
  233. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  234. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  235. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  236. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  237. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  238. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  239. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  240. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  241. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  242. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  243. /package/dist/{ccip-ZGGWQN4X.js.map → config-MXOX7XDR.js.map} +0 -0
  244. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  245. /package/dist/{config-CNUIX23Q.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  246. /package/dist/{doctor-QJJXRWTO.js.map → install-XUM2XSHW.js.map} +0 -0
  247. /package/dist/{edit-HJ44P44P.js.map → paths-P2N4JTDZ.js.map} +0 -0
  248. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-SBXZEPEP.js.map} +0 -0
  249. /package/dist/{fund-Y5IAHZ5D.js.map → redact-46ZHF2NH.js.map} +0 -0
  250. /package/dist/{inspect-NFQ6SQQQ.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  251. /package/dist/{outcome-ANV4QIED.js.map → status-line-wiring-BYPHTYZE.js.map} +0 -0
  252. /package/dist/{publish-PCBTCXCZ.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  253. /package/dist/{search-JGAVKTYJ.js.map → wallet-PWAHVKWW.js.map} +0 -0
@@ -1,711 +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-J6FUAIRR.js";
7
- import {
8
- fetchJson
9
- } from "./chunk-54AJIO3E.js";
10
- import {
11
- trimSlash,
12
- tryOriginOf
13
- } from "./chunk-XGZ5EVMB.js";
14
- import {
15
- walletFileExists
16
- } from "./chunk-3P3ES4XU.js";
17
- import {
18
- sanitizeForTerminal
19
- } from "./chunk-B676GPS2.js";
20
- import {
21
- modeGatedPointer,
22
- permissionsPointer,
23
- recommendedPermissions
24
- } from "./chunk-IUQZ4Z7M.js";
25
- import {
26
- loadProjectConfig
27
- } from "./chunk-PKW3H26Z.js";
28
- import {
29
- toMoney
30
- } from "./chunk-736DW4V3.js";
31
- import {
32
- MODE_GATED_RULES,
33
- inspectFreeVerbRules
34
- } from "./chunk-IU2HVT3Y.js";
35
- import {
36
- loadRawConfig,
37
- resolveSettings
38
- } from "./chunk-LSWP7MU2.js";
39
- import {
40
- configPath,
41
- sessionPath
42
- } from "./chunk-ZQIQ55KK.js";
43
- import {
44
- CLI_SKILL_NAMES,
45
- HOSTED_SKILL_NAME,
46
- anyTenjinSkill,
47
- cliSkillsWired,
48
- detectHarnesses,
49
- harnessFlagFor,
50
- harnessInPlay,
51
- harnessReads,
52
- harnessRequested,
53
- missingCliSkills,
54
- onPath,
55
- readAllWiring,
56
- readSkillFile,
57
- resolveSkillsSource,
58
- shadowedCliSkills
59
- } from "./chunk-QWBUKIP2.js";
60
- import {
61
- CliError
62
- } from "./chunk-PAOVPSP6.js";
63
-
64
- // src/commands/doctor.ts
65
- import { styleText } from "util";
66
- import { Stream } from "stream";
67
- import { homedir } from "os";
68
- import { join } from "path";
69
- import { fileURLToPath } from "url";
70
- var POCKET_MONEY_CEILING_ATOMIC = 20000000n;
71
- var FIX_POINT_AT_TENJIN_API = "Point the configured base URL at a Tenjin API (expected an OpenAPI document): `tenjin config set baseUrl <url>`.";
72
- var FIX_CHECK_NETWORK_AND_BASE_URL = "Check your network connection and the configured base URL (`tenjin config get baseUrl`).";
73
- async function collectDoctorChecks(ctx, deps = {}) {
74
- const env = deps.env ?? process.env;
75
- const { config, check: configCheck } = await loadConfigForDoctor(ctx.dataDir);
76
- const project = await loadProjectConfig(deps.cwd ?? process.cwd()).catch(() => null);
77
- const settings = resolveSettings({
78
- config,
79
- flags: { baseUrl: ctx.flags.baseUrl },
80
- env,
81
- project: project?.layer
82
- });
83
- const baseUrl = settings.baseUrl.value;
84
- const built = [
85
- checkNode(),
86
- configCheck,
87
- await checkApiContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),
88
- await checkReadPath(baseUrl, ctx.flags.timeout, deps.fetchImpl),
89
- await checkSearchContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),
90
- await checkSkills(
91
- deps.homeDir ?? homedir(),
92
- deps.which ?? ((bin) => onPath(bin, env)),
93
- config.install?.harness ?? [],
94
- deps.skillsSourceDir
95
- ),
96
- await checkSession(ctx.dataDir, deps.now ?? Date.now, tryOriginOf(baseUrl))
97
- ];
98
- for (const result of await checkWallet(ctx, deps, env, settings.rpcUrl.value)) {
99
- built.push({ result });
100
- }
101
- const checks = built.map((b) => b.result);
102
- const publishMode = settings.publishMode.value;
103
- const probe = await inspectFreeVerbRules(deps.homeDir ?? homedir(), publishMode);
104
- const gated = new Set(MODE_GATED_RULES);
105
- const missingModeGated = (probe.pending ?? []).filter((r) => gated.has(r));
106
- const firstFail = built.find((b) => b.result.required && b.result.status === "fail");
107
- if (firstFail === void 0) return { checks, publishMode, missingModeGated };
108
- return {
109
- checks,
110
- publishMode,
111
- missingModeGated,
112
- failure: { code: firstFail.failCode ?? "INTERNAL", result: firstFail.result }
113
- };
114
- }
115
- async function runDoctor(ctx, deps = {}) {
116
- const { checks, failure, publishMode, missingModeGated } = await collectDoctorChecks(ctx, deps);
117
- if (failure !== void 0) {
118
- const r = failure.result;
119
- throw new CliError(failure.code, r.detail, {
120
- ...r.fix !== void 0 ? { fix: r.fix } : {},
121
- details: { checks, permissions: recommendedPermissions(publishMode) }
122
- });
123
- }
124
- const env = deps.env ?? process.env;
125
- const fromEnv = env.TENJIN_PUBLISH_MODE !== void 0 && env.TENJIN_PUBLISH_MODE.length > 0;
126
- 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");
127
- const showModeLine = fromEnv ? missingModeGated.length > 0 : modeLine !== null;
128
- return {
129
- data: { status: "pass", checks, permissions: recommendedPermissions(publishMode) },
130
- humanLines: [
131
- ...renderDoctorHuman(ctx.io, checks),
132
- "",
133
- ...showModeLine && modeLine !== null ? [modeLine] : [],
134
- permissionsPointer()
135
- ]
136
- };
137
- }
138
- function checkNode() {
139
- const version = process.versions.node;
140
- const major = Number.parseInt(version.split(".")[0] ?? "0", 10);
141
- if (major >= 22) {
142
- return { result: { name: "node", status: "ok", required: true, detail: `Node ${version}` } };
143
- }
144
- return {
145
- result: {
146
- name: "node",
147
- status: "fail",
148
- required: true,
149
- detail: `Node ${version} is unsupported (need >= 22)`,
150
- fix: "Install Node 22 or newer"
151
- },
152
- failCode: "NODE_UNSUPPORTED"
153
- };
154
- }
155
- async function loadConfigForDoctor(dataDir) {
156
- try {
157
- const config = await loadRawConfig(dataDir);
158
- const detail = Object.keys(config).length === 0 ? "No config file; using defaults" : `Config at ${configPath(dataDir)} is valid`;
159
- return { config, check: { result: { name: "config", status: "ok", required: true, detail } } };
160
- } catch (err) {
161
- if (err instanceof CliError && err.code === "CONFIG_INVALID") {
162
- return {
163
- config: {},
164
- check: {
165
- result: {
166
- name: "config",
167
- status: "fail",
168
- required: true,
169
- detail: err.message,
170
- ...err.fix !== void 0 ? { fix: err.fix } : {}
171
- },
172
- failCode: "CONFIG_INVALID"
173
- }
174
- };
175
- }
176
- throw err;
177
- }
178
- }
179
- async function checkApiContract(baseUrl, timeoutMs, fetchImpl) {
180
- const url = `${trimSlash(baseUrl)}/openapi.json`;
181
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
182
- if (!res.ok) {
183
- const malformed = res.kind === "invalid-json";
184
- return {
185
- result: {
186
- name: "api-contract",
187
- status: "fail",
188
- required: true,
189
- detail: malformed ? `OpenAPI document at ${url} was not valid JSON` : `Could not reach the Tenjin API at ${url}: ${res.message}`,
190
- fix: malformed ? FIX_POINT_AT_TENJIN_API : FIX_CHECK_NETWORK_AND_BASE_URL
191
- },
192
- failCode: malformed ? "CONTRACT_MISMATCH" : "API_UNREACHABLE"
193
- };
194
- }
195
- const version = infoVersion(res.json);
196
- if (version === void 0) {
197
- return {
198
- result: {
199
- name: "api-contract",
200
- status: "fail",
201
- required: true,
202
- detail: `OpenAPI document at ${url} is missing a string info.version`,
203
- fix: FIX_POINT_AT_TENJIN_API
204
- },
205
- failCode: "CONTRACT_MISMATCH"
206
- };
207
- }
208
- return {
209
- result: {
210
- name: "api-contract",
211
- status: "ok",
212
- required: true,
213
- detail: `Tenjin API ${version} at ${baseUrl}`
214
- }
215
- };
216
- }
217
- async function checkSearchContract(baseUrl, timeoutMs, fetchImpl) {
218
- const url = `${trimSlash(baseUrl)}/openapi.json`;
219
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
220
- if (!res.ok) {
221
- return {
222
- result: {
223
- name: "search-contract",
224
- status: "warn",
225
- required: false,
226
- detail: `Could not confirm the search endpoint at ${url}`,
227
- fix: "Check the configured base URL (`tenjin config get baseUrl`); search/buy need the A2 endpoints deployed."
228
- }
229
- };
230
- }
231
- const present = hasSearchPath(res.json);
232
- return {
233
- result: present ? {
234
- name: "search-contract",
235
- status: "ok",
236
- required: false,
237
- detail: "Search endpoint advertised"
238
- } : {
239
- name: "search-contract",
240
- status: "warn",
241
- required: false,
242
- detail: "This deployment does not advertise POST /api/agent/search (A2 not deployed)",
243
- fix: "search/buy need A2 deployed; point the configured base URL at a deploy that has it (`tenjin config set baseUrl <url>`)."
244
- }
245
- };
246
- }
247
- function hasSearchPath(json) {
248
- if (!isRecord(json)) return false;
249
- const paths = json.paths;
250
- return isRecord(paths) && "/api/agent/search" in paths;
251
- }
252
- async function checkSkills(home, which, requested, skillsSourceDir) {
253
- const present = detectHarnesses(home, which);
254
- const wiring = await readAllWiring(home);
255
- const data = {
256
- directories: wiring.map((w) => ({
257
- ...w,
258
- harnessPresent: harnessReads(home, w.dir, present),
259
- requested: harnessRequested(home, w.dir, requested)
260
- }))
261
- };
262
- const inPlay = wiring.filter((w) => anyTenjinSkill(w));
263
- if (inPlay.length === 0) {
264
- const targeted = requested.length > 0 ? wiring.filter((w) => harnessInPlay(home, w.dir, present, requested)) : [];
265
- return {
266
- result: {
267
- name: "skills",
268
- status: "warn",
269
- required: false,
270
- detail: `No Tenjin skills wired under ${home} (looked in .claude/skills and .agents/skills)`,
271
- fix: targeted.length > 0 ? fixFor(home, targeted) : "tenjin install",
272
- data
273
- }
274
- };
275
- }
276
- const broken = wiring.filter(
277
- (w) => harnessInPlay(home, w.dir, present, requested) && !cliSkillsWired(w)
278
- );
279
- if (broken.length > 0) {
280
- return {
281
- result: {
282
- name: "skills",
283
- status: "warn",
284
- required: false,
285
- detail: `${broken.map(describeProblem).join("; ")}. Full state: ${describeWiring(inPlay)}`,
286
- fix: fixFor(home, broken),
287
- data
288
- }
289
- };
290
- }
291
- const { stale, verifiable } = await compareWiredSkills(
292
- wiring.map((w) => w.dir),
293
- skillsSourceDir
294
- );
295
- if (!verifiable) {
296
- return {
297
- result: {
298
- name: "skills",
299
- status: "warn",
300
- required: false,
301
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired, but this build's packaged copies could not be read, so whether they are current is unknown`,
302
- // NOT `tenjin update`: this warning means the packaged copies are
303
- // unreadable, which a current version answers with "up to date" and no
304
- // work at all. Reinstalling the same version is the actual repair.
305
- fix: "Reinstall the CLI: `npm i -g tenjin-cli`, then `tenjin install`.",
306
- data
307
- }
308
- };
309
- }
310
- if (stale.length > 0) {
311
- return {
312
- result: {
313
- name: "skills",
314
- status: "warn",
315
- required: false,
316
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired but not from this CLI build (${stale.join(", ")}); agents are reading an older version's instructions`,
317
- // fixFor, like every neighbouring branch: a plain `tenjin install` targets
318
- // DETECTED harnesses only, so for a directory that exists because someone
319
- // passed --harness it would be a fix that never clears the warning.
320
- fix: fixFor(
321
- home,
322
- wiring.filter((w) => stale.includes(w.dir))
323
- ),
324
- data
325
- }
326
- };
327
- }
328
- return {
329
- result: {
330
- name: "skills",
331
- status: "ok",
332
- required: false,
333
- detail: `${CLI_SKILL_NAMES.join(" + ")} wired: ${describeWiring(inPlay)}`,
334
- data
335
- }
336
- };
337
- }
338
- async function compareWiredSkills(dirs, sourceDir) {
339
- let source;
340
- try {
341
- source = sourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
342
- } catch {
343
- return { stale: [], verifiable: false };
344
- }
345
- const packaged = /* @__PURE__ */ new Map();
346
- for (const name of CLI_SKILL_NAMES) {
347
- const read = await readSkillFile(join(source, name, "SKILL.md"));
348
- if (read.kind === "ok") packaged.set(name, read.bytes);
349
- }
350
- if (packaged.size !== CLI_SKILL_NAMES.length) return { stale: [], verifiable: false };
351
- const stale = [];
352
- for (const dir of dirs) {
353
- for (const name of CLI_SKILL_NAMES) {
354
- const onDisk = await readSkillFile(join(dir, name, "SKILL.md"));
355
- if (onDisk.kind !== "ok") continue;
356
- if (!packaged.get(name).equals(onDisk.bytes)) {
357
- stale.push(dir);
358
- break;
359
- }
360
- }
361
- }
362
- return { stale, verifiable: true };
363
- }
364
- function describeProblem(w) {
365
- const shadowed = shadowedCliSkills(w);
366
- const missing = missingCliSkills(w);
367
- const parts = [];
368
- const unreadable = shadowed.filter((n) => reasonFor(w, n) === "unreadable");
369
- const disabled = shadowed.filter((n) => reasonFor(w, n) !== "unreadable");
370
- if (disabled.length > 0) {
371
- parts.push(
372
- `${disabled.join(", ")} installed but not model-invocable (disable-model-invocation: true)`
373
- );
374
- }
375
- if (unreadable.length > 0) {
376
- parts.push(
377
- `${unreadable.join(", ")} installed but not model-invocable (unreadable or disable-model-invocation: true)`
378
- );
379
- }
380
- if (missing.length === CLI_SKILL_NAMES.length) {
381
- parts.push(
382
- w.state === "hosted-only" ? `the hosted ${HOSTED_SKILL_NAME} skill is here but neither CLI skill is wired` : "neither CLI skill is wired"
383
- );
384
- } else if (missing.length > 0) parts.push(`${missing.join(", ")} missing`);
385
- return `${w.dir}: ${parts.join(" and ")}`;
386
- }
387
- function reasonFor(w, name) {
388
- return w.skills.find((s) => s.name === name)?.reason;
389
- }
390
- function hostedHere(w) {
391
- return w.skills.find((s) => s.name === HOSTED_SKILL_NAME)?.present === true;
392
- }
393
- function fixFor(home, dirs) {
394
- const flags = [...new Set(dirs.map((w) => harnessFlagFor(home, w.dir)))];
395
- return `tenjin install ${flags.map((f) => `--harness ${f}`).join(" ")}`;
396
- }
397
- function describeWiring(wiring) {
398
- return wiring.map((w) => {
399
- const parts = w.skills.filter((s) => s.present).map(
400
- (s) => s.modelInvocable === false ? `${s.name} [${s.reason ?? "shadowed"}]` : s.name
401
- );
402
- return `${w.dir} -> ${parts.join(", ")} (${posture(w)})`;
403
- }).join("; ");
404
- }
405
- function posture(w) {
406
- if (w.state !== "wired") return POSTURE[w.state];
407
- return hostedHere(w) ? "CLI skills wired, take precedence over the hosted mirror" : "CLI skills wired";
408
- }
409
- var POSTURE = {
410
- empty: "no Tenjin skills",
411
- "hosted-only": "hosted skill only, no CLI skills here",
412
- partial: "only one CLI skill",
413
- // "at least one": a directory with one CLI skill shadowed and the other absent
414
- // classifies as `shadowed` too, and "CLI skills present" would be false there.
415
- shadowed: "at least one CLI skill present but not model-invocable",
416
- wired: "CLI skills wired, take precedence over the hosted mirror"
417
- };
418
- async function checkSession(dataDir, now, origin) {
419
- const warn = (detail, data2) => ({
420
- result: {
421
- name: "session",
422
- status: "warn",
423
- required: false,
424
- detail,
425
- fix: "tenjin session start --scope read",
426
- ...data2 !== void 0 ? { data: data2 } : {}
427
- }
428
- });
429
- const state = await readSessionFile(dataDir);
430
- if (state.kind === "absent") {
431
- return {
432
- result: {
433
- name: "session",
434
- status: "ok",
435
- required: false,
436
- detail: "No session key; `tenjin read` delivers free and locally-cached pieces (`tenjin session start --scope read` adds owned-piece recovery)"
437
- }
438
- };
439
- }
440
- if (state.kind === "loosened") {
441
- return warn(
442
- `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`
443
- );
444
- }
445
- if (state.kind === "outdated") {
446
- return {
447
- result: {
448
- name: "session",
449
- status: "ok",
450
- required: false,
451
- 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`
452
- }
453
- };
454
- }
455
- if (state.kind === "corrupt") {
456
- return warn(`Session key at ${sessionPath(dataDir)} could not be parsed (${state.reason})`);
457
- }
458
- if (state.kind === "unreadable") {
459
- return warn(`Session key at ${sessionPath(dataDir)} could not be read: ${state.message}`);
460
- }
461
- const file = state.file;
462
- if (origin === null) {
463
- return {
464
- result: {
465
- name: "session",
466
- status: "warn",
467
- required: false,
468
- detail: `Session key was minted for ${file.origin}, but the configured base URL is not an http(s) origin, so it cannot be matched`,
469
- fix: "Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`.",
470
- data: { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp }
471
- }
472
- };
473
- }
474
- const data = { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp };
475
- if (file.origin !== origin) {
476
- return warn(
477
- `Session key was minted for ${file.origin}, but the configured base URL is ${origin}; it is not presented off its own origin`,
478
- data
479
- );
480
- }
481
- if (!Number.isFinite(Date.parse(file.exp))) {
482
- return warn(
483
- `Session key for ${file.address} carries an unparseable expiry (exp ${file.exp})`,
484
- data
485
- );
486
- }
487
- if (!scopeSatisfies(file.scope, "read")) {
488
- return {
489
- result: {
490
- name: "session",
491
- status: "ok",
492
- required: false,
493
- detail: `Session key has scope ${file.scope}, which does not cover reading; \`tenjin session start --scope read\` mints one that does`,
494
- data
495
- }
496
- };
497
- }
498
- if (!isSessionPresentable(file, now(), "read", origin)) {
499
- return {
500
- result: {
501
- name: "session",
502
- status: "ok",
503
- required: false,
504
- detail: "Session key expired (normal after 24h); mint one with `tenjin session start --scope read` when you want free re-reads of owned pieces",
505
- data
506
- }
507
- };
508
- }
509
- return {
510
- result: {
511
- name: "session",
512
- status: "ok",
513
- required: false,
514
- detail: `Session key ${file.address}, scope ${file.scope}, for ${file.origin}, expires ${file.exp}`,
515
- data
516
- }
517
- };
518
- }
519
- async function checkReadPath(baseUrl, timeoutMs, fetchImpl) {
520
- const url = `${trimSlash(baseUrl)}/api/articles?limit=1`;
521
- const res = await fetchJson(url, { timeoutMs, fetchImpl });
522
- if (!res.ok) {
523
- return {
524
- result: {
525
- name: "read-path",
526
- status: "fail",
527
- required: true,
528
- detail: `Read path ${url} failed: ${res.message}`,
529
- fix: FIX_CHECK_NETWORK_AND_BASE_URL
530
- },
531
- failCode: "API_UNREACHABLE"
532
- };
533
- }
534
- const items = isRecord(res.json) ? res.json.items : void 0;
535
- if (!Array.isArray(items)) {
536
- return {
537
- result: {
538
- name: "read-path",
539
- status: "fail",
540
- required: true,
541
- detail: `Read path ${url} did not return an items array`,
542
- fix: "Point the configured base URL at a Tenjin API: `tenjin config set baseUrl <url>`."
543
- },
544
- failCode: "API_UNREACHABLE"
545
- };
546
- }
547
- return {
548
- result: { name: "read-path", status: "ok", required: true, detail: `Read path OK at ${url}` }
549
- };
550
- }
551
- async function checkWallet(ctx, deps, env, rpcUrl) {
552
- const provider = deps.provider ?? await resolveLocalProviderOrNull(ctx, env, deps);
553
- if (provider === null) return [noWalletCheck()];
554
- const { describeWallet } = await import("./wallet-SLRIYJ2U.js");
555
- let desc;
556
- try {
557
- desc = await describeWallet(provider);
558
- } catch (err) {
559
- if (err instanceof CliError && err.code === "WALLET_MISSING") return [noWalletCheck()];
560
- return [walletWarn(err)];
561
- }
562
- const checks = [walletCheck(desc, await verifyWallet(provider))];
563
- for (const warning of (await provider.diagnostics()).warnings) {
564
- checks.push({ name: "wallet-custody", status: "warn", required: false, detail: warning });
565
- }
566
- checks.push(await checkBalance(desc.address, rpcUrl));
567
- return checks;
568
- }
569
- async function resolveLocalProviderOrNull(ctx, env, deps) {
570
- const envKey = env.TENJIN_WALLET_KEY;
571
- const envKeySet = typeof envKey === "string" && envKey.length > 0;
572
- if (!envKeySet && !await walletFileExists(ctx.dataDir)) return null;
573
- const { resolveWalletProvider } = await import("./wallet-SLRIYJ2U.js");
574
- return resolveWalletProvider(ctx, {
575
- ...deps.walletPassphrase !== void 0 ? { passphrase: deps.walletPassphrase } : {}
576
- });
577
- }
578
- async function verifyWallet(provider) {
579
- if (provider.verify === void 0) {
580
- return {
581
- status: "unverified",
582
- detail: `provider "${provider.id}" cannot verify without a key`
583
- };
584
- }
585
- try {
586
- return await provider.verify();
587
- } catch (err) {
588
- return {
589
- status: "unverified",
590
- detail: `verification could not run (${err instanceof Error ? err.message : String(err)})`
591
- };
592
- }
593
- }
594
- function walletCheck(desc, v) {
595
- const head = `Wallet ${desc.address} (${desc.credentialSource})`;
596
- if (v.status === "broken") {
597
- return {
598
- name: "wallet",
599
- status: "warn",
600
- required: false,
601
- detail: `${head}: ${v.detail}`,
602
- fix: v.fix
603
- };
604
- }
605
- if (v.status === "unverified") {
606
- return {
607
- name: "wallet",
608
- status: "warn",
609
- required: false,
610
- detail: `${head} present, not verified: ${v.detail}`,
611
- fix: "Set TENJIN_WALLET_PASSPHRASE, or store the passphrase in your OS credential store, so doctor can prove the keystore still opens."
612
- };
613
- }
614
- return { name: "wallet", status: "ok", required: false, detail: `${head}, ${v.detail}` };
615
- }
616
- function noWalletCheck() {
617
- return {
618
- name: "wallet",
619
- status: "warn",
620
- required: false,
621
- detail: "No wallet; needed only for buy/publish",
622
- fix: "tenjin wallet create",
623
- data: { credential: "absent" }
624
- };
625
- }
626
- function isNoWalletCheck(c) {
627
- return c.name === "wallet" && isRecord(c.data) && c.data.credential === "absent";
628
- }
629
- function walletWarn(err) {
630
- return {
631
- name: "wallet",
632
- status: "warn",
633
- required: false,
634
- detail: err instanceof Error ? err.message : String(err),
635
- ...err instanceof CliError && err.fix !== void 0 ? { fix: err.fix } : {}
636
- };
637
- }
638
- async function checkBalance(address, rpcUrl) {
639
- try {
640
- const { getUsdcBalance } = await import("./usdc-4VCDHFWX.js");
641
- const balance = await getUsdcBalance(address, rpcUrl);
642
- if (balance === 0n) {
643
- return {
644
- name: "balance",
645
- status: "warn",
646
- required: false,
647
- detail: "Wallet USDC balance is 0",
648
- fix: "Fund it with `tenjin fund` (card via Coinbase), or send USDC on Base. $5 covers ~50 typical resources."
649
- };
650
- }
651
- const money = toMoney(balance.toString());
652
- if (balance > POCKET_MONEY_CEILING_ATOMIC) {
653
- return {
654
- name: "balance",
655
- status: "warn",
656
- required: false,
657
- detail: `Balance ${money.usd} USDC is above the ~$20 pocket-money ceiling`,
658
- fix: "Keep only small change in the CLI wallet; sweep the excess to cold storage."
659
- };
660
- }
661
- return {
662
- name: "balance",
663
- status: "ok",
664
- required: false,
665
- detail: `Balance ${money.usd} USDC (${money.atomic} atomic)`
666
- };
667
- } catch (err) {
668
- return {
669
- name: "balance",
670
- status: "warn",
671
- required: false,
672
- detail: `Could not read balance: ${err instanceof Error ? err.message : String(err)}`,
673
- fix: "Check rpcUrl or retry; a balance read failure never fails doctor."
674
- };
675
- }
676
- }
677
- function renderDoctorHuman(io, checks) {
678
- const nameWidth = Math.max(...checks.map((c) => c.name.length));
679
- const lines = [];
680
- for (const c of checks) {
681
- const icon = c.status === "ok" ? paint(io, "green", "\u2713") : c.status === "warn" ? paint(io, "yellow", "!") : paint(io, "red", "\u2717");
682
- lines.push(
683
- `${icon} ${c.name.padEnd(nameWidth)} ${paint(io, "dim", sanitizeForTerminal(c.detail))}`
684
- );
685
- if (c.status !== "ok" && c.fix !== void 0) {
686
- lines.push(` ${paint(io, "dim", `fix: ${sanitizeForTerminal(c.fix)}`)}`);
687
- }
688
- }
689
- return lines;
690
- }
691
- function paint(io, format, text) {
692
- if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });
693
- return styleText(format, text);
694
- }
695
- function infoVersion(json) {
696
- if (!isRecord(json)) return void 0;
697
- const info = json.info;
698
- if (!isRecord(info)) return void 0;
699
- return typeof info.version === "string" ? info.version : void 0;
700
- }
701
- function isRecord(value) {
702
- return typeof value === "object" && value !== null;
703
- }
704
-
705
- export {
706
- collectDoctorChecks,
707
- runDoctor,
708
- isNoWalletCheck,
709
- renderDoctorHuman
710
- };
711
- //# sourceMappingURL=chunk-GEHL43VE.js.map