tenjin-cli 0.1.0-alpha.15 → 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 (267) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +41 -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-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-NIKXHWOL.js → chunk-2U5ZVEV3.js} +16 -16
  13. package/dist/chunk-2U5ZVEV3.js.map +1 -0
  14. package/dist/{chunk-HPJGOLTN.js → chunk-3AJS6LLN.js} +13 -8
  15. package/dist/chunk-3AJS6LLN.js.map +1 -0
  16. package/dist/{chunk-KINZ23CV.js → chunk-3AUDA53C.js} +4740 -23
  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-ZFJJ3EXC.js → chunk-BBVUVBUO.js} +516 -185
  28. package/dist/chunk-BBVUVBUO.js.map +1 -0
  29. package/dist/{chunk-JBIKAAT3.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-VYOJOX4Z.js → chunk-OJLYNM4Z.js} +54 -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-U5DXNFJC.js +137 -0
  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-CPCX67TI.js → chunk-YEETV6IW.js} +1079 -1039
  72. package/dist/chunk-YEETV6IW.js.map +1 -0
  73. package/dist/{chunk-OLWTRUTS.js → chunk-YJHHCWM3.js} +35 -16
  74. package/dist/chunk-YJHHCWM3.js.map +1 -0
  75. package/dist/{cli-KKRKBU5T.js → cli-M3XCSOU6.js} +289 -374
  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-KAJZHIQ4.js → fund-A54P2QFK.js} +80 -24
  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-XYTQ5TWQ.js → mcp-HJC2PLRV.js} +3727 -10670
  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-G746D7PQ.js → send-ASD2ZXJD.js} +28 -29
  98. package/dist/send-ASD2ZXJD.js.map +1 -0
  99. package/dist/{chunk-QZ6ROAJU.js → skill-placement-NFVHY6A3.js} +157 -11
  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-R76LHOZW.js → update-ANJ2AOTN.js} +133 -16
  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 +65 -354
  117. package/docs/safety-model.md +16 -6
  118. package/package.json +8 -7
  119. package/LICENSE +0 -21
  120. package/dist/buy-VIRNSYGN.js +0 -47
  121. package/dist/chunk-2MYQN7HM.js +0 -247
  122. package/dist/chunk-2MYQN7HM.js.map +0 -1
  123. package/dist/chunk-2RF2GIJQ.js +0 -1188
  124. package/dist/chunk-2RF2GIJQ.js.map +0 -1
  125. package/dist/chunk-3GL2Z5QK.js +0 -57
  126. package/dist/chunk-3GL2Z5QK.js.map +0 -1
  127. package/dist/chunk-47PP7TAG.js.map +0 -1
  128. package/dist/chunk-4CQIDQOT.js +0 -167
  129. package/dist/chunk-4CQIDQOT.js.map +0 -1
  130. package/dist/chunk-4KG27W2S.js +0 -614
  131. package/dist/chunk-4KG27W2S.js.map +0 -1
  132. package/dist/chunk-5QQTYWEU.js +0 -199
  133. package/dist/chunk-5QQTYWEU.js.map +0 -1
  134. package/dist/chunk-65DTCCJ7.js +0 -21
  135. package/dist/chunk-65DTCCJ7.js.map +0 -1
  136. package/dist/chunk-A5DKHMUN.js +0 -173
  137. package/dist/chunk-A5DKHMUN.js.map +0 -1
  138. package/dist/chunk-B63XPWQ4.js +0 -246
  139. package/dist/chunk-B63XPWQ4.js.map +0 -1
  140. package/dist/chunk-CAR6FHK6.js +0 -105
  141. package/dist/chunk-CAR6FHK6.js.map +0 -1
  142. package/dist/chunk-CPCX67TI.js.map +0 -1
  143. package/dist/chunk-CQBVCYI2.js +0 -162
  144. package/dist/chunk-CQBVCYI2.js.map +0 -1
  145. package/dist/chunk-DBU5CXBV.js +0 -4731
  146. package/dist/chunk-DBU5CXBV.js.map +0 -1
  147. package/dist/chunk-DHJD77OW.js +0 -81
  148. package/dist/chunk-DHJD77OW.js.map +0 -1
  149. package/dist/chunk-EDZSNPE5.js +0 -35
  150. package/dist/chunk-EDZSNPE5.js.map +0 -1
  151. package/dist/chunk-EFWZPUTC.js +0 -65
  152. package/dist/chunk-EFWZPUTC.js.map +0 -1
  153. package/dist/chunk-EPFL6CTE.js +0 -448
  154. package/dist/chunk-EPFL6CTE.js.map +0 -1
  155. package/dist/chunk-GHLVXVZD.js +0 -142
  156. package/dist/chunk-GHLVXVZD.js.map +0 -1
  157. package/dist/chunk-H3SOOJ2I.js +0 -580
  158. package/dist/chunk-H3SOOJ2I.js.map +0 -1
  159. package/dist/chunk-HPJGOLTN.js.map +0 -1
  160. package/dist/chunk-HRGBS2PA.js +0 -203
  161. package/dist/chunk-HRGBS2PA.js.map +0 -1
  162. package/dist/chunk-ITUXPJIS.js +0 -314
  163. package/dist/chunk-ITUXPJIS.js.map +0 -1
  164. package/dist/chunk-JBIKAAT3.js.map +0 -1
  165. package/dist/chunk-KAJZHIQ4.js.map +0 -1
  166. package/dist/chunk-KINZ23CV.js.map +0 -1
  167. package/dist/chunk-LRYV3SK7.js +0 -235
  168. package/dist/chunk-LRYV3SK7.js.map +0 -1
  169. package/dist/chunk-M2O56UK7.js.map +0 -1
  170. package/dist/chunk-MJZZTKCC.js.map +0 -1
  171. package/dist/chunk-NIKXHWOL.js.map +0 -1
  172. package/dist/chunk-OKDRDT74.js +0 -209
  173. package/dist/chunk-OKDRDT74.js.map +0 -1
  174. package/dist/chunk-OKYSNAS3.js +0 -2144
  175. package/dist/chunk-OKYSNAS3.js.map +0 -1
  176. package/dist/chunk-OLWTRUTS.js.map +0 -1
  177. package/dist/chunk-QQ6ELLSA.js +0 -143
  178. package/dist/chunk-QQ6ELLSA.js.map +0 -1
  179. package/dist/chunk-QZ6ROAJU.js.map +0 -1
  180. package/dist/chunk-R7RSCBI7.js +0 -794
  181. package/dist/chunk-R7RSCBI7.js.map +0 -1
  182. package/dist/chunk-SGK2B724.js +0 -67
  183. package/dist/chunk-SGK2B724.js.map +0 -1
  184. package/dist/chunk-U6VPKMGC.js +0 -390
  185. package/dist/chunk-U6VPKMGC.js.map +0 -1
  186. package/dist/chunk-UHTVXQ2O.js +0 -140
  187. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  188. package/dist/chunk-UO22YNY4.js.map +0 -1
  189. package/dist/chunk-US456VUI.js +0 -149
  190. package/dist/chunk-US456VUI.js.map +0 -1
  191. package/dist/chunk-V44J2MXV.js +0 -400
  192. package/dist/chunk-V44J2MXV.js.map +0 -1
  193. package/dist/chunk-VJQKL3YH.js +0 -216
  194. package/dist/chunk-VJQKL3YH.js.map +0 -1
  195. package/dist/chunk-VJSQSLBM.js +0 -1442
  196. package/dist/chunk-VJSQSLBM.js.map +0 -1
  197. package/dist/chunk-VYOJOX4Z.js.map +0 -1
  198. package/dist/chunk-WY2K35OL.js +0 -269
  199. package/dist/chunk-WY2K35OL.js.map +0 -1
  200. package/dist/chunk-ZFJJ3EXC.js.map +0 -1
  201. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  202. package/dist/cli-KKRKBU5T.js.map +0 -1
  203. package/dist/config-JMRUNYE6.js +0 -37
  204. package/dist/discover-B5HF6SHM.js +0 -102
  205. package/dist/discover-B5HF6SHM.js.map +0 -1
  206. package/dist/doctor-ZBG7X66D.js +0 -32
  207. package/dist/edit-PZJIILQE.js +0 -40
  208. package/dist/fund-EUDH5KPA.js +0 -40
  209. package/dist/inspect-QC6WEQPN.js +0 -37
  210. package/dist/install-GNK2W3PI.js +0 -972
  211. package/dist/install-GNK2W3PI.js.map +0 -1
  212. package/dist/outcome-KSGWZHUS.js +0 -24
  213. package/dist/pay-BC4UICPA.js +0 -361
  214. package/dist/pay-BC4UICPA.js.map +0 -1
  215. package/dist/publish-LXWFDIKF.js +0 -42
  216. package/dist/read-JMNUQ56P.js +0 -160
  217. package/dist/read-JMNUQ56P.js.map +0 -1
  218. package/dist/run-XYTQ5TWQ.js.map +0 -1
  219. package/dist/search-TSQAB45E.js +0 -25
  220. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  221. package/dist/send-G746D7PQ.js.map +0 -1
  222. package/dist/session-JBKWMJ24.js +0 -89
  223. package/dist/session-JBKWMJ24.js.map +0 -1
  224. package/dist/skill-heal-WKD67SLJ.js +0 -92
  225. package/dist/skill-heal-WKD67SLJ.js.map +0 -1
  226. package/dist/skill-placement-RIU4AMC2.js +0 -20
  227. package/dist/skill-placement-RIU4AMC2.js.map +0 -1
  228. package/dist/uninstall-5E263VTS.js +0 -73
  229. package/dist/uninstall-5E263VTS.js.map +0 -1
  230. package/dist/update-R76LHOZW.js.map +0 -1
  231. package/dist/usdc-4VCDHFWX.js +0 -38
  232. package/dist/usdc-4VCDHFWX.js.map +0 -1
  233. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  234. package/dist/wallet-TQ7D5EQ7.js +0 -41
  235. package/dist/wallet-TQ7D5EQ7.js.map +0 -1
  236. package/dist/wallet-ZAVXWLWP.js +0 -32
  237. package/dist/wallet-ZAVXWLWP.js.map +0 -1
  238. package/docs/command-reference.md +0 -303
  239. package/skills/tenjin/SKILL.md +0 -373
  240. package/skills/tenjin-pay/SKILL.md +0 -76
  241. package/skills/tenjin-publish/SKILL.md +0 -227
  242. package/skills/tenjin-publish/references/maintain.md +0 -39
  243. package/skills/tenjin-search/SKILL.md +0 -154
  244. package/skills/tenjin-search/references/permissions.md +0 -112
  245. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  246. /package/dist/{buy-VIRNSYGN.js.map → ccip-7RMRLAGV.js.map} +0 -0
  247. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  248. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  249. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  250. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  251. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  252. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  253. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  254. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  255. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  256. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  257. /package/dist/{ccip-ZGGWQN4X.js.map → config-MXOX7XDR.js.map} +0 -0
  258. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  259. /package/dist/{config-JMRUNYE6.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  260. /package/dist/{doctor-ZBG7X66D.js.map → install-XUM2XSHW.js.map} +0 -0
  261. /package/dist/{edit-PZJIILQE.js.map → paths-P2N4JTDZ.js.map} +0 -0
  262. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-SBXZEPEP.js.map} +0 -0
  263. /package/dist/{fund-EUDH5KPA.js.map → redact-46ZHF2NH.js.map} +0 -0
  264. /package/dist/{inspect-QC6WEQPN.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  265. /package/dist/{outcome-KSGWZHUS.js.map → status-line-wiring-BYPHTYZE.js.map} +0 -0
  266. /package/dist/{publish-LXWFDIKF.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  267. /package/dist/{search-TSQAB45E.js.map → wallet-PWAHVKWW.js.map} +0 -0
@@ -0,0 +1,698 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ modeGatedPointer
4
+ } from "./chunk-WXC57XGG.js";
5
+ import {
6
+ confirmChoice
7
+ } from "./chunk-2QYORQBF.js";
8
+ import {
9
+ LockTimeoutError,
10
+ withFileLock
11
+ } from "./chunk-MEFB5KHA.js";
12
+ import {
13
+ detectHarnesses,
14
+ harnessInPlay,
15
+ harnessTargetDir,
16
+ onPath
17
+ } from "./chunk-U5DXNFJC.js";
18
+ import {
19
+ isTeamShelfOrigin,
20
+ loadProjectConfig
21
+ } from "./chunk-OJLYNM4Z.js";
22
+ import {
23
+ parseUsdToAtomic,
24
+ toMoney
25
+ } from "./chunk-WH7OWT6G.js";
26
+ import {
27
+ CONFIG_KEYS,
28
+ HOOKS_CONFIG_KEYS,
29
+ LOOP_CONFIG_KEYS,
30
+ PRODUCTION_ORIGIN,
31
+ PUBLISH_CONFIG_KEYS,
32
+ PublishModeSchema,
33
+ RawConfigSchema,
34
+ SEND_MAX_UNSET,
35
+ TEAM_CONFIG_KEYS,
36
+ UPDATE_CONFIG_KEYS,
37
+ isSameDeployment,
38
+ loadRawConfig,
39
+ parseAckServerWarnings,
40
+ parseLoopValue,
41
+ parsePublicFallbackFlag,
42
+ parseUpdateModeFlag,
43
+ resolveSettings
44
+ } from "./chunk-BBVUVBUO.js";
45
+ import {
46
+ ADAPTERS,
47
+ MODE_GATED_RULES,
48
+ inspectFreeVerbRules,
49
+ registeredHooks,
50
+ retractModeGatedRules,
51
+ wireFreeVerbAllowlist
52
+ } from "./chunk-SKAHDQH7.js";
53
+ import {
54
+ CliError
55
+ } from "./chunk-OCBHUHWB.js";
56
+ import {
57
+ configPath
58
+ } from "./chunk-2BKS2FVE.js";
59
+ import {
60
+ writeFileAtomic
61
+ } from "./chunk-7WEQQJLG.js";
62
+
63
+ // src/commands/config.ts
64
+ import { mkdir } from "node:fs/promises";
65
+ import { homedir } from "node:os";
66
+ import { styleText } from "node:util";
67
+
68
+ // src/lib/harness-presence.ts
69
+ async function installedHarnessInPlay(adapter, home, dataDir, options = {}) {
70
+ const env = options.env ?? process.env;
71
+ const which = options.which ?? ((bin) => onPath(bin, env));
72
+ if (harnessInPlay(
73
+ home,
74
+ harnessTargetDir(home, adapter.id),
75
+ detectHarnesses(home, which),
76
+ options.requested ?? []
77
+ )) {
78
+ return true;
79
+ }
80
+ return (await registeredHooks(adapter, home, dataDir, env)).entries > 0;
81
+ }
82
+
83
+ // src/commands/config.ts
84
+ var CONFIRM_ABOVE = "above:";
85
+ var KEY_WIDTH = Math.max(
86
+ ...[
87
+ ...CONFIG_KEYS,
88
+ ...PUBLISH_CONFIG_KEYS,
89
+ ...HOOKS_CONFIG_KEYS,
90
+ ...UPDATE_CONFIG_KEYS,
91
+ ...LOOP_CONFIG_KEYS,
92
+ ...TEAM_CONFIG_KEYS
93
+ ].map((key) => key.length)
94
+ );
95
+ var KEY_DESCRIPTIONS = {
96
+ maxAutoSpend: "auto-approve a read up to this amount",
97
+ sessionBudget: "cap on total auto-spend per session",
98
+ confirm: "when to ask before paying",
99
+ sendMaxAmount: "hard cap per tenjin wallet send; unset = send refuses until set, 0 disables send, none = uncapped; never bypassed by --yes",
100
+ allowlistCreators: "only auto-pay these creators (empty = any)",
101
+ baseUrl: "Tenjin API base URL: what publish/read/search go to (the team shelf, in team mode)",
102
+ publicShelfUrl: "the public marketplace, consume-only: the second shelf a team-mode search falls through to",
103
+ shelfBypassSecret: "the team shelf's Vercel protection-bypass secret; setting it is what turns team mode on (printed as set/unset)",
104
+ rpcUrl: "Base RPC endpoint for balance reads",
105
+ evalCohort: "opt in to the search evaluation cohort",
106
+ bazaarPay: "let `tenjin pay` spend at registry-listed non-Tenjin endpoints",
107
+ bazaarRegistries: "x402 discovery registries for `discover` and the pay lane",
108
+ "publish.mode": "review=always ask, auto=ask on findings, full-auto=only hard blocks stop it",
109
+ "publish.defaultPrice": "price used when none is given",
110
+ "publish.ackServerWarnings": "whether a yes covers the MARKETPLACE scan's warn findings: mode=only the ones an earlier render already showed you (full-auto still acks), on=any of them, off=never",
111
+ "hooks.prompt": "answer the prompt you just typed with what the shelves already know",
112
+ "hooks.web-search": "ask Tenjin before the agent runs a WebSearch",
113
+ "hooks.web-fetch": "ask Tenjin before the agent fetches a page",
114
+ "hooks.subagent": "ask Tenjin with a subagent work order (the most sensitive payload any hook sees) and hand the answer to the child at its start",
115
+ "hooks.failure": "answer a failing command with the fix this machine or a shelf already has",
116
+ "hooks.publish": "the turn-end ask to publish what this turn settled, spoken to you and to each subagent at its own end",
117
+ "hooks.primer": "one-paragraph search-first primer at session start",
118
+ "update.mode": "nudge=report a newer version (stderr line, JSON envelope, hook output), off=neither report nor ask npm",
119
+ "loop.human_wait_ms": "ms a hook fire may take when a human is waiting on it (prompt, Stop, SessionStart)",
120
+ "loop.tool_wait_ms": "ms a hook fire may take when a tool call is waiting on it",
121
+ "loop.idle_exit_min": "minutes without a hook fire before the loop daemon exits",
122
+ "loop.port": "the loop daemon's loopback port; null derives one from the data dir (set only when doctor reports a foreign listener)",
123
+ "team.publicFallback": "on=a team-shelf miss falls through to the public marketplace, off=team-only (public-only lookup stages are dropped)"
124
+ };
125
+ function isLoopKey(key) {
126
+ return LOOP_CONFIG_KEYS.includes(key);
127
+ }
128
+ function isTeamKey(key) {
129
+ return TEAM_CONFIG_KEYS.includes(key);
130
+ }
131
+ function renderLoopSetting(key, settings) {
132
+ const field = key.slice("loop.".length);
133
+ const { value, source } = settings.loop[field];
134
+ return { value: value === null ? "null" : String(value), source };
135
+ }
136
+ function isPublishKey(key) {
137
+ return PUBLISH_CONFIG_KEYS.includes(key);
138
+ }
139
+ function isHooksKey(key) {
140
+ return HOOKS_CONFIG_KEYS.includes(key);
141
+ }
142
+ function isUpdateKey(key) {
143
+ return UPDATE_CONFIG_KEYS.includes(key);
144
+ }
145
+ async function runConfigList(ctx) {
146
+ const settings = await resolveFromContext(ctx);
147
+ const data = {};
148
+ const humanLines = [];
149
+ for (const key of CONFIG_KEYS) {
150
+ const entry = renderSetting(key, settings[key].value, settings[key].source);
151
+ data[key] = entry;
152
+ humanLines.push(describedLine(key, entry));
153
+ }
154
+ for (const key of PUBLISH_CONFIG_KEYS) {
155
+ const entry = renderPublishSetting(key, settings);
156
+ data[key] = entry;
157
+ humanLines.push(describedLine(key, entry, downgradeNote(key, settings)));
158
+ }
159
+ for (const key of HOOKS_CONFIG_KEYS) {
160
+ const entry = renderHooksSetting(key, settings);
161
+ data[key] = entry;
162
+ humanLines.push(describedLine(key, entry));
163
+ }
164
+ for (const key of UPDATE_CONFIG_KEYS) {
165
+ const entry = {
166
+ value: settings.updateMode.value,
167
+ source: settings.updateMode.source
168
+ };
169
+ data[key] = entry;
170
+ humanLines.push(describedLine(key, entry));
171
+ }
172
+ for (const key of LOOP_CONFIG_KEYS) {
173
+ const entry = renderLoopSetting(key, settings);
174
+ data[key] = entry;
175
+ humanLines.push(describedLine(key, entry));
176
+ }
177
+ for (const key of TEAM_CONFIG_KEYS) {
178
+ const entry = {
179
+ value: settings.teamPublicFallback.value,
180
+ source: settings.teamPublicFallback.source
181
+ };
182
+ data[key] = entry;
183
+ humanLines.push(describedLine(key, entry));
184
+ }
185
+ return { data, humanLines };
186
+ }
187
+ async function runConfigGet({ key }, ctx) {
188
+ if (isPublishKey(key)) {
189
+ const settings2 = await resolveFromContext(ctx);
190
+ const entry2 = renderPublishSetting(key, settings2);
191
+ return {
192
+ data: { key, ...entry2 },
193
+ humanLines: [withNote(formatLine(key, entry2), downgradeNote(key, settings2))]
194
+ };
195
+ }
196
+ if (isHooksKey(key)) {
197
+ const entry2 = renderHooksSetting(key, await resolveFromContext(ctx));
198
+ return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
199
+ }
200
+ if (isUpdateKey(key)) {
201
+ const { updateMode } = await resolveFromContext(ctx);
202
+ const entry2 = { value: updateMode.value, source: updateMode.source };
203
+ return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
204
+ }
205
+ if (isLoopKey(key)) {
206
+ const entry2 = renderLoopSetting(key, await resolveFromContext(ctx));
207
+ return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
208
+ }
209
+ if (isTeamKey(key)) {
210
+ const { teamPublicFallback } = await resolveFromContext(ctx);
211
+ const entry2 = {
212
+ value: teamPublicFallback.value,
213
+ source: teamPublicFallback.source
214
+ };
215
+ return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
216
+ }
217
+ const configKey = assertKey(key);
218
+ const settings = await resolveFromContext(ctx);
219
+ const entry = renderSetting(configKey, settings[configKey].value, settings[configKey].source);
220
+ return { data: { key: configKey, ...entry }, humanLines: [formatLine(configKey, entry)] };
221
+ }
222
+ async function runConfigSet({ key, value }, ctx, deps = {}) {
223
+ if (isPublishKey(key)) return setPublishKey(key, value, ctx, deps);
224
+ if (isHooksKey(key)) return setHooksKey(key, value, ctx);
225
+ if (isUpdateKey(key)) return setUpdateKey(key, value, ctx);
226
+ if (isLoopKey(key)) return setLoopKey(key, value, ctx);
227
+ if (isTeamKey(key)) return setTeamKey(key, value, ctx);
228
+ const configKey = assertKey(key);
229
+ const stored = parseValue(configKey, value);
230
+ await persist(ctx.dataDir, (existing) => ({ ...existing, [configKey]: stored }));
231
+ if (configKey === "bazaarPay") {
232
+ try {
233
+ const { syncBazaarSkill } = await import("./skill-placement-NFVHY6A3.js");
234
+ await syncBazaarSkill(
235
+ stored === true,
236
+ deps.placeSkill ?? { io: ctx.io, dataDir: ctx.dataDir }
237
+ );
238
+ } catch {
239
+ }
240
+ }
241
+ const entry = renderSetting(configKey, stored, "file");
242
+ const warning = await halfWiredTeamShelf(configKey, ctx.dataDir);
243
+ return {
244
+ data: { key: configKey, ...entry, ...warning !== void 0 ? { warning } : {} },
245
+ humanLines: [formatLine(configKey, entry), ...warning !== void 0 ? [warning] : []]
246
+ };
247
+ }
248
+ async function halfWiredTeamShelf(configKey, dataDir) {
249
+ if (configKey !== "shelfBypassSecret" && configKey !== "baseUrl" && configKey !== "publicShelfUrl") {
250
+ return void 0;
251
+ }
252
+ const config = await loadRawConfig(dataDir).catch(() => void 0);
253
+ if (config === void 0) return void 0;
254
+ const s = resolveSettings({ config, flags: {}, env: {} });
255
+ if (s.shelfBypassSecret.value.length === 0) return void 0;
256
+ const baseUrl = s.baseUrl.value;
257
+ if (isTeamShelfOrigin(new URL(baseUrl).origin, s.publicShelfUrl.value)) return void 0;
258
+ const isProduction = isSameDeployment(new URL(baseUrl).origin, PRODUCTION_ORIGIN);
259
+ const cause = isProduction ? `baseUrl is the public marketplace (${baseUrl})` : `baseUrl and publicShelfUrl are the same shelf (${baseUrl})`;
260
+ const fix = isProduction ? "Point baseUrl at the team deployment to finish team mode: `tenjin config set baseUrl <team shelf url>`." : `A team shelf must differ from the shelf it falls through to: \`tenjin config set publicShelfUrl ${PRODUCTION_ORIGIN}\`.`;
261
+ return `Warning: shelfBypassSecret is set, but ${cause}, so this machine stays in PUBLIC mode \u2014 publishes go to the marketplace with the scan\u2019s warn tier and the confirm cascade on. ` + fix;
262
+ }
263
+ async function setPublishKey(key, value, ctx, deps) {
264
+ const entry = key === "publish.mode" ? { value: parsePublishMode(value), source: "file" } : key === "publish.ackServerWarnings" ? { value: parseAckServerWarnings(value, key), source: "file" } : { value: toMoney(parseUsdToAtomic(value)), source: "file" };
265
+ const subkey = key === "publish.mode" ? "mode" : key === "publish.ackServerWarnings" ? "ackServerWarnings" : "defaultPrice";
266
+ const stored = key === "publish.defaultPrice" ? entry.value.atomic : entry.value;
267
+ const persistEntry = async () => persist(ctx.dataDir, (existing) => ({
268
+ ...existing,
269
+ publish: { ...existing.publish, [subkey]: stored }
270
+ }));
271
+ const humanLines = [formatLine(key, entry)];
272
+ if (key !== "publish.mode") {
273
+ await persistEntry();
274
+ return { data: { key, ...entry }, humanLines };
275
+ }
276
+ const allowlist = await syncPublishRule(entry.value, ctx, deps);
277
+ const failure = grantSyncFailure(allowlist);
278
+ if (failure !== void 0) {
279
+ throw new CliError(
280
+ "REFUSED",
281
+ `publish.mode was not changed because the ${failure.harness} grant could not be updated: ${failure.reason}`,
282
+ {
283
+ fix: failure.fix ?? `Fix the permissions for ${failure.path}, then re-run \`tenjin config set publish.mode ${entry.value}\`.`,
284
+ details: { key, value: entry.value, allowlist }
285
+ }
286
+ );
287
+ }
288
+ await persistEntry();
289
+ return {
290
+ data: { key, ...entry, allowlist },
291
+ humanLines: [...humanLines, ...allowlistLines(allowlist)]
292
+ };
293
+ }
294
+ function grantSyncFailure(sync) {
295
+ for (const [harness, result] of Object.entries(sync.byHarness)) {
296
+ if ("error" in result && result.error !== void 0) {
297
+ return { harness, path: result.path, reason: result.error };
298
+ }
299
+ if ("warning" in result && result.warning !== void 0) {
300
+ return {
301
+ harness,
302
+ path: result.path ?? "(unknown path)",
303
+ reason: result.warning,
304
+ ...result.fix !== void 0 ? { fix: result.fix } : {}
305
+ };
306
+ }
307
+ }
308
+ return void 0;
309
+ }
310
+ function publishRuleQuestion(mode, pending, harnesses) {
311
+ const gated = new Set(MODE_GATED_RULES);
312
+ const others = pending.filter((rule) => !gated.has(rule)).length;
313
+ const also = others > 0 ? ` Also adds the ${others} command-grant rule(s) \`tenjin install\` writes.` : "";
314
+ const targets = harnesses.map(
315
+ (harness) => harness === "claude" ? "Claude Code" : harness === "codex" ? "Codex" : harness
316
+ ).join(" and ");
317
+ return `publish.mode ${mode} is unattended only if ${targets} carries the matching grant for ${MODE_GATED_RULES.join(" and ")}. Update the ${targets} grant now?${also}`;
318
+ }
319
+ async function syncPublishRule(mode, ctx, deps) {
320
+ const home = deps.homeDir ?? homedir();
321
+ const nothing = { byHarness: {} };
322
+ const write = async () => {
323
+ const result = await (deps.wireAllowlist ?? wireFreeVerbAllowlist)(home, mode);
324
+ if (result.skipped !== void 0) {
325
+ return {
326
+ byHarness: { claude: result },
327
+ skipped: "unwritable",
328
+ ...result.fix !== void 0 ? { pointer: result.fix } : {}
329
+ };
330
+ }
331
+ return { byHarness: { claude: result } };
332
+ };
333
+ const adapters = deps.adapters ?? ADAPTERS;
334
+ const env = deps.env ?? process.env;
335
+ const which = deps.which ?? ((bin) => onPath(bin, env));
336
+ const requested = await loadRawConfig(ctx.dataDir).then((config) => config.install?.harness ?? []).catch(() => []);
337
+ const inPlay = deps.harnessesInPlay ?? (await Promise.all(
338
+ Object.values(adapters).map(async (adapter) => ({
339
+ adapter,
340
+ selected: await installedHarnessInPlay(adapter, home, ctx.dataDir, {
341
+ env,
342
+ which,
343
+ requested
344
+ })
345
+ }))
346
+ )).filter((entry) => entry.selected).map((entry) => entry.adapter.id);
347
+ const selectedAdapters = inPlay.map((harness) => adapters[harness]);
348
+ const isClaude = inPlay.includes("claude");
349
+ const withOtherGrants = async (sync) => {
350
+ const byHarness = { ...sync.byHarness };
351
+ for (const adapter of selectedAdapters) {
352
+ if (adapter.id === "claude" || adapter.registrar.grant === void 0) continue;
353
+ const result = await adapter.registrar.grant.write(home, mode, env);
354
+ byHarness[adapter.id] = result;
355
+ }
356
+ return { ...sync, byHarness };
357
+ };
358
+ if (selectedAdapters.every((adapter) => adapter.registrar.grant === void 0)) {
359
+ return { ...nothing, skipped: "not-claude" };
360
+ }
361
+ const probe = isClaude ? await (deps.inspectAllowlist ?? inspectFreeVerbRules)(home, mode) : { pending: [] };
362
+ const gated = new Set(MODE_GATED_RULES);
363
+ const missing = (probe.pending ?? []).filter((r) => gated.has(r));
364
+ const pointer = modeGatedPointer(mode, missing) ?? void 0;
365
+ if (mode === "review") {
366
+ const retracted = isClaude ? await (deps.retractModeGated ?? retractModeGatedRules)(home) : void 0;
367
+ if (retracted?.skipped !== void 0) {
368
+ return {
369
+ ...nothing,
370
+ skipped: "unwritable",
371
+ ...retracted.fix !== void 0 ? { pointer: retracted.fix } : {}
372
+ };
373
+ }
374
+ return await withOtherGrants({
375
+ byHarness: retracted === void 0 ? {} : { claude: retracted }
376
+ });
377
+ }
378
+ if (probe.satisfied !== void 0 && selectedAdapters.length === 1 && isClaude) return nothing;
379
+ const canPrompt = ctx.flags.json === true ? false : deps.isInteractive ?? Boolean(process.stdin.isTTY);
380
+ if (!canPrompt) {
381
+ return { ...nothing, skipped: "no-tty", ...pointer ? { pointer } : {} };
382
+ }
383
+ const confirm = deps.confirmRule ?? ((label) => confirmChoice(label, true));
384
+ const grantable = selectedAdapters.filter((adapter) => adapter.registrar.grant !== void 0).map((adapter) => adapter.id);
385
+ if (!await confirm(publishRuleQuestion(mode, probe.pending ?? [], grantable))) {
386
+ return { ...nothing, skipped: "declined", ...pointer ? { pointer } : {} };
387
+ }
388
+ return await withOtherGrants(isClaude ? await write() : nothing);
389
+ }
390
+ function allowlistLines(sync) {
391
+ const lines = [];
392
+ const claude = sync.byHarness.claude;
393
+ if ((claude?.added.length ?? 0) > 0) {
394
+ lines.push(`Added ${claude?.added.length ?? 0} harness rule(s) to your allowlist.`);
395
+ }
396
+ if ((claude?.removed.length ?? 0) > 0) {
397
+ lines.push(`Removed ${claude?.removed.join(", ")} from your allowlist.`);
398
+ }
399
+ const grant = sync.byHarness.codex;
400
+ if (grant !== void 0 && grant.error === void 0 && grant.wrote) {
401
+ lines.push(
402
+ `Codex now allows ${grant.granted.length} tenjin command prefix(es) in ${grant.path}.`
403
+ );
404
+ }
405
+ if (grant?.error !== void 0) {
406
+ lines.push(`Codex's grant at ${grant.path} could not be updated (${grant.error}).`);
407
+ }
408
+ if (sync.pointer !== void 0) lines.push(sync.pointer);
409
+ return lines;
410
+ }
411
+ async function setHooksKey(key, value, ctx) {
412
+ const arm = key.slice("hooks.".length);
413
+ const parsed = parseBoolean(value);
414
+ await persistHookArm(ctx.dataDir, arm, parsed);
415
+ const entry = { value: parsed, source: "file" };
416
+ return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
417
+ }
418
+ async function setUpdateKey(key, value, ctx) {
419
+ const parsed = parseUpdateModeFlag(value, key);
420
+ await persist(ctx.dataDir, (existing) => ({
421
+ ...existing,
422
+ update: { ...existing.update, mode: parsed }
423
+ }));
424
+ const entry = { value: parsed, source: "file" };
425
+ return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
426
+ }
427
+ async function setLoopKey(key, value, ctx) {
428
+ const parsed = parseLoopValue(key, value);
429
+ const field = key.slice("loop.".length);
430
+ await persist(ctx.dataDir, (existing) => ({
431
+ ...existing,
432
+ loop: { ...existing.loop, [field]: parsed }
433
+ }));
434
+ const entry = {
435
+ value: parsed === null ? "null" : String(parsed),
436
+ source: "file"
437
+ };
438
+ return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
439
+ }
440
+ async function setTeamKey(key, value, ctx) {
441
+ const parsed = parsePublicFallbackFlag(value, key);
442
+ await persist(ctx.dataDir, (existing) => ({
443
+ ...existing,
444
+ team: { ...existing.team, publicFallback: parsed }
445
+ }));
446
+ const entry = { value: parsed, source: "file" };
447
+ return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
448
+ }
449
+ function parsePublishMode(value) {
450
+ const parsed = PublishModeSchema.safeParse(value);
451
+ if (parsed.success) return parsed.data;
452
+ throw new CliError("USAGE", `Invalid publish mode: ${JSON.stringify(value)}`, {
453
+ fix: 'Use "review", "auto", or "full-auto".'
454
+ });
455
+ }
456
+ async function persistHookArm(dir, arm, value) {
457
+ await persist(dir, (existing) => ({
458
+ ...existing,
459
+ hooks: { ...existing.hooks, [arm]: value }
460
+ }));
461
+ }
462
+ async function persistPublishMode(dir, mode) {
463
+ await persist(dir, (existing) => ({
464
+ ...existing,
465
+ publish: { ...existing.publish, mode }
466
+ }));
467
+ }
468
+ async function persistBazaarPay(dir, enabled) {
469
+ await persist(dir, (existing) => ({ ...existing, bazaarPay: enabled }));
470
+ }
471
+ async function persistRouterProject(dir, projectDir, present = true) {
472
+ await persist(dir, (existing) => {
473
+ const known = new Set(existing.install?.routerProjects ?? []);
474
+ if (present) known.add(projectDir);
475
+ else known.delete(projectDir);
476
+ return { ...existing, install: { ...existing.install, routerProjects: [...known].sort() } };
477
+ });
478
+ }
479
+ var ROUTER_DEFAULTS = {
480
+ maxAutoSpend: "250000",
481
+ sessionBudget: "5000000",
482
+ confirm: "above:250000"
483
+ };
484
+ async function persistRouterDefaults(dir) {
485
+ const result = { set: [], kept: [] };
486
+ await persist(dir, (existing) => {
487
+ const next = { ...existing, bazaarPay: true };
488
+ for (const [key, value] of Object.entries(ROUTER_DEFAULTS)) {
489
+ if (existing[key] === void 0) {
490
+ next[key] = value;
491
+ result.set.push(key);
492
+ } else result.kept.push(key);
493
+ }
494
+ return next;
495
+ });
496
+ return result;
497
+ }
498
+ async function persistInstallHarness(dir, harness) {
499
+ await persist(dir, (existing) => ({
500
+ ...existing,
501
+ install: { ...existing.install, harness: [...harness] }
502
+ }));
503
+ }
504
+ async function persistGrantDeclined(dir, declined) {
505
+ await persist(dir, (existing) => ({
506
+ ...existing,
507
+ install: { ...existing.install, grantDeclined: declined }
508
+ }));
509
+ }
510
+ async function resolveFromContext(ctx) {
511
+ const config = await loadRawConfig(ctx.dataDir);
512
+ const project = await loadProjectConfig(process.cwd());
513
+ return resolveSettings({
514
+ config,
515
+ flags: { baseUrl: ctx.flags.baseUrl },
516
+ env: process.env,
517
+ project: project?.layer
518
+ });
519
+ }
520
+ function assertKey(key) {
521
+ if (CONFIG_KEYS.includes(key)) return key;
522
+ throw new CliError("USAGE", `Unknown config key: ${JSON.stringify(key)}`, {
523
+ fix: `Valid keys: ${[...CONFIG_KEYS, ...PUBLISH_CONFIG_KEYS, ...HOOKS_CONFIG_KEYS].join(", ")}.`
524
+ });
525
+ }
526
+ function renderSetting(key, stored, source) {
527
+ return { ...renderValue(key, stored), source };
528
+ }
529
+ function renderPublishSetting(key, settings) {
530
+ if (key === "publish.mode") {
531
+ return { value: settings.publishMode.value, source: settings.publishMode.source };
532
+ }
533
+ if (key === "publish.ackServerWarnings") {
534
+ return {
535
+ value: settings.publishAckServerWarnings.value,
536
+ source: settings.publishAckServerWarnings.source
537
+ };
538
+ }
539
+ return {
540
+ value: toMoney(settings.publishDefaultPrice.value),
541
+ source: settings.publishDefaultPrice.source
542
+ };
543
+ }
544
+ function renderHooksSetting(key, settings) {
545
+ const { value, source } = settings.hooks[key.slice("hooks.".length)];
546
+ return { value, source };
547
+ }
548
+ function renderValue(key, stored) {
549
+ if (key === "shelfBypassSecret") {
550
+ return { value: typeof stored === "string" && stored.length > 0 ? "set" : "unset" };
551
+ }
552
+ if (Array.isArray(stored) || typeof stored === "boolean") return { value: stored };
553
+ if (key === "maxAutoSpend" || key === "sessionBudget") return { value: toMoney(stored) };
554
+ if (key === "sendMaxAmount") {
555
+ return { value: stored === "none" || stored === SEND_MAX_UNSET ? stored : toMoney(stored) };
556
+ }
557
+ if (key === "confirm" && stored.startsWith(CONFIRM_ABOVE)) {
558
+ return { value: stored, threshold: toMoney(stored.slice(CONFIRM_ABOVE.length)) };
559
+ }
560
+ return { value: stored };
561
+ }
562
+ function parseValue(key, value) {
563
+ switch (key) {
564
+ case "maxAutoSpend":
565
+ case "sessionBudget":
566
+ return parseUsdToAtomic(value);
567
+ // throws USAGE on a bad amount
568
+ case "sendMaxAmount":
569
+ return value === "none" ? "none" : parseUsdToAtomic(value);
570
+ case "confirm":
571
+ return parseConfirm(value);
572
+ case "allowlistCreators":
573
+ return parseAllowlist(value);
574
+ case "baseUrl":
575
+ case "publicShelfUrl":
576
+ case "rpcUrl":
577
+ return parseHttpUrl(value);
578
+ case "shelfBypassSecret":
579
+ return value.trim();
580
+ case "evalCohort":
581
+ case "bazaarPay":
582
+ return parseBoolean(value);
583
+ case "bazaarRegistries":
584
+ return parseRegistryList(value);
585
+ }
586
+ }
587
+ function parseRegistryList(value) {
588
+ return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0).map((entry) => parseHttpUrl(entry));
589
+ }
590
+ function parseBoolean(value) {
591
+ if (value === "true" || value === "on") return true;
592
+ if (value === "false" || value === "off") return false;
593
+ throw new CliError("USAGE", `Invalid boolean value: ${JSON.stringify(value)}`, {
594
+ fix: 'Use "on" or "off" (or "true"/"false").'
595
+ });
596
+ }
597
+ function parseConfirm(value) {
598
+ if (value === "always") return "always";
599
+ if (value.startsWith(CONFIRM_ABOVE)) {
600
+ return `${CONFIRM_ABOVE}${parseUsdToAtomic(value.slice(CONFIRM_ABOVE.length))}`;
601
+ }
602
+ throw new CliError("USAGE", `Invalid confirm value: ${JSON.stringify(value)}`, {
603
+ fix: 'Use "always" or "above:<usd>", e.g. above:0.25.'
604
+ });
605
+ }
606
+ function parseAllowlist(value) {
607
+ const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
608
+ for (const entry of entries) {
609
+ if (/\s/.test(entry)) {
610
+ throw new CliError("USAGE", `Invalid creator entry: ${JSON.stringify(entry)}`, {
611
+ fix: "Creator entries cannot contain spaces; separate multiple with commas."
612
+ });
613
+ }
614
+ }
615
+ return entries;
616
+ }
617
+ function parseHttpUrl(value) {
618
+ let url;
619
+ try {
620
+ url = new URL(value);
621
+ } catch {
622
+ throw new CliError("USAGE", `Invalid URL: ${JSON.stringify(value)}`, {
623
+ fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
624
+ });
625
+ }
626
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
627
+ throw new CliError("USAGE", `URL must be http or https: ${JSON.stringify(value)}`, {
628
+ fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
629
+ });
630
+ }
631
+ return value;
632
+ }
633
+ async function persist(dir, merge) {
634
+ await mkdir(dir, { recursive: true, mode: 448 });
635
+ const lockPath = `${configPath(dir)}.lock`;
636
+ try {
637
+ await withFileLock(lockPath, async () => {
638
+ const existing = await loadRawConfig(dir);
639
+ const merged = merge(existing);
640
+ const validated = RawConfigSchema.parse(merged);
641
+ await writeFileAtomic(configPath(dir), `${JSON.stringify(validated, null, 2)}
642
+ `, {
643
+ mode: 384,
644
+ dirMode: 448
645
+ });
646
+ });
647
+ } catch (err) {
648
+ if (err instanceof LockTimeoutError) {
649
+ throw new CliError("INTERNAL", err.message, {
650
+ fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
651
+ cause: err
652
+ });
653
+ }
654
+ throw err;
655
+ }
656
+ }
657
+ function formatLine(key, entry) {
658
+ const label = key.padEnd(KEY_WIDTH);
659
+ return ` ${label} ${displayValue(entry)} ${styleText("dim", `(${entry.source})`)}`;
660
+ }
661
+ function describedLine(key, entry, note) {
662
+ const description = KEY_DESCRIPTIONS[key];
663
+ let line = formatLine(key, entry);
664
+ if (description !== void 0) line += ` ${styleText("dim", `- ${description}`)}`;
665
+ return withNote(line, note);
666
+ }
667
+ function withNote(line, note) {
668
+ return note !== void 0 ? `${line} ${styleText("dim", `(${note})`)}` : line;
669
+ }
670
+ function downgradeNote(key, settings) {
671
+ if (key !== "publish.mode" || settings.publishMode.downgradedWarning === void 0) {
672
+ return void 0;
673
+ }
674
+ return "downgraded from full-auto: committed .tenjin.json (gitignore it to opt in)";
675
+ }
676
+ function displayValue(entry) {
677
+ const { value } = entry;
678
+ if (Array.isArray(value)) return value.length > 0 ? value.join(", ") : "(empty)";
679
+ if (typeof value === "boolean") return value ? "true" : "false";
680
+ if (typeof value === "object") return `${value.usd} USD`;
681
+ if (entry.threshold !== void 0) return `above ${entry.threshold.usd} USD`;
682
+ return value;
683
+ }
684
+
685
+ export {
686
+ runConfigList,
687
+ runConfigGet,
688
+ runConfigSet,
689
+ persistHookArm,
690
+ persistPublishMode,
691
+ persistBazaarPay,
692
+ persistRouterProject,
693
+ ROUTER_DEFAULTS,
694
+ persistRouterDefaults,
695
+ persistInstallHarness,
696
+ persistGrantDeclined
697
+ };
698
+ //# sourceMappingURL=chunk-GULLJQXA.js.map