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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +149 -264
  3. package/dist/{_esm-FEASBWRP.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/alive-3J3CHOQP.js +21 -0
  5. package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
  6. package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
  7. package/dist/chunk-2SNUOHAT.js +75 -0
  8. package/dist/chunk-2SNUOHAT.js.map +1 -0
  9. package/dist/chunk-3O2BQIF6.js +2227 -0
  10. package/dist/chunk-3O2BQIF6.js.map +1 -0
  11. package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
  12. package/dist/chunk-5LJCEMFD.js +12700 -0
  13. package/dist/chunk-5LJCEMFD.js.map +1 -0
  14. package/dist/chunk-6W5GYG3W.js +128 -0
  15. package/dist/chunk-6W5GYG3W.js.map +1 -0
  16. package/dist/chunk-7EKYXMUO.js +7536 -0
  17. package/dist/chunk-7EKYXMUO.js.map +1 -0
  18. package/dist/chunk-7QKHZQKW.js +1680 -0
  19. package/dist/chunk-7QKHZQKW.js.map +1 -0
  20. package/dist/chunk-A36LQPHV.js +29 -0
  21. package/dist/chunk-A36LQPHV.js.map +1 -0
  22. package/dist/chunk-AEG2PXBP.js +192 -0
  23. package/dist/chunk-AEG2PXBP.js.map +1 -0
  24. package/dist/chunk-AKWGE6JQ.js +49 -0
  25. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  26. package/dist/chunk-AWFUPKTM.js +238 -0
  27. package/dist/chunk-AWFUPKTM.js.map +1 -0
  28. package/dist/{chunk-UGX7YPX2.js → chunk-AWQPGIR6.js} +7 -9
  29. package/dist/{chunk-UGX7YPX2.js.map → chunk-AWQPGIR6.js.map} +1 -1
  30. package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
  31. package/dist/chunk-EBVIKMCH.js +108 -0
  32. package/dist/chunk-EBVIKMCH.js.map +1 -0
  33. package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
  34. package/dist/{chunk-S3IGX57D.js → chunk-EL56RW2J.js} +166 -7237
  35. package/dist/chunk-EL56RW2J.js.map +1 -0
  36. package/dist/chunk-HE2MS4QO.js +256 -0
  37. package/dist/chunk-HE2MS4QO.js.map +1 -0
  38. package/dist/{chunk-CYOF7ROH.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-IOODYAXL.js +324 -0
  40. package/dist/chunk-IOODYAXL.js.map +1 -0
  41. package/dist/chunk-JMM6YE7J.js +2174 -0
  42. package/dist/chunk-JMM6YE7J.js.map +1 -0
  43. package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
  44. package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
  45. package/dist/chunk-KHE6L6TD.js +416 -0
  46. package/dist/chunk-KHE6L6TD.js.map +1 -0
  47. package/dist/chunk-KOGZDMHO.js +21 -0
  48. package/dist/chunk-KOGZDMHO.js.map +1 -0
  49. package/dist/chunk-KYFZTGMC.js +237 -0
  50. package/dist/chunk-KYFZTGMC.js.map +1 -0
  51. package/dist/chunk-LFZJM56J.js +159 -0
  52. package/dist/chunk-LFZJM56J.js.map +1 -0
  53. package/dist/chunk-LHHMV4GU.js +27 -0
  54. package/dist/chunk-LHHMV4GU.js.map +1 -0
  55. package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
  56. package/dist/chunk-MEFB5KHA.js.map +1 -0
  57. package/dist/{chunk-NCE5NSN6.js → chunk-N35E6CM2.js} +140 -10
  58. package/dist/chunk-N35E6CM2.js.map +1 -0
  59. package/dist/chunk-NZIP4PA2.js +114 -0
  60. package/dist/chunk-NZIP4PA2.js.map +1 -0
  61. package/dist/chunk-O2FRQ2L2.js +168 -0
  62. package/dist/chunk-O2FRQ2L2.js.map +1 -0
  63. package/dist/chunk-OK2TDZQU.js +404 -0
  64. package/dist/chunk-OK2TDZQU.js.map +1 -0
  65. package/dist/chunk-ORWL5BSN.js +269 -0
  66. package/dist/chunk-ORWL5BSN.js.map +1 -0
  67. package/dist/{chunk-Z6MFJV5Z.js → chunk-OSYTBCUC.js} +850 -499
  68. package/dist/chunk-OSYTBCUC.js.map +1 -0
  69. package/dist/chunk-P7LABKCW.js +90 -0
  70. package/dist/chunk-P7LABKCW.js.map +1 -0
  71. package/dist/chunk-PAYV4XUA.js +151 -0
  72. package/dist/chunk-PAYV4XUA.js.map +1 -0
  73. package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
  74. package/dist/chunk-QUVVWYJW.js +112 -0
  75. package/dist/chunk-QUVVWYJW.js.map +1 -0
  76. package/dist/chunk-RAULEAZ6.js +228 -0
  77. package/dist/chunk-RAULEAZ6.js.map +1 -0
  78. package/dist/chunk-S4SAZ7OD.js +30 -0
  79. package/dist/chunk-S4SAZ7OD.js.map +1 -0
  80. package/dist/chunk-SJLTEINJ.js +117 -0
  81. package/dist/chunk-SJLTEINJ.js.map +1 -0
  82. package/dist/chunk-SPAVAYSW.js +125 -0
  83. package/dist/chunk-SPAVAYSW.js.map +1 -0
  84. package/dist/chunk-TTBKWWTV.js +1605 -0
  85. package/dist/chunk-TTBKWWTV.js.map +1 -0
  86. package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
  87. package/dist/chunk-U6YQ6FRI.js +378 -0
  88. package/dist/chunk-U6YQ6FRI.js.map +1 -0
  89. package/dist/chunk-VFMQTSXG.js +29 -0
  90. package/dist/chunk-VFMQTSXG.js.map +1 -0
  91. package/dist/chunk-VUFAK2LW.js +115 -0
  92. package/dist/chunk-VUFAK2LW.js.map +1 -0
  93. package/dist/chunk-VZGAONSJ.js +194 -0
  94. package/dist/chunk-VZGAONSJ.js.map +1 -0
  95. package/dist/{chunk-OYMYCW7J.js → chunk-WO5BJNIB.js} +682 -53
  96. package/dist/chunk-WO5BJNIB.js.map +1 -0
  97. package/dist/chunk-WVUSXNIE.js +39 -0
  98. package/dist/chunk-WVUSXNIE.js.map +1 -0
  99. package/dist/chunk-XKESD27X.js +10 -0
  100. package/dist/chunk-XKESD27X.js.map +1 -0
  101. package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
  102. package/dist/{chunk-XJIW7USF.js → chunk-YFQOA5AU.js} +118 -9
  103. package/dist/chunk-YFQOA5AU.js.map +1 -0
  104. package/dist/chunk-YHKXNYTB.js +105 -0
  105. package/dist/chunk-YHKXNYTB.js.map +1 -0
  106. package/dist/{cli-SBXI5AMS.js → cli-O5SN7ZJ4.js} +382 -214
  107. package/dist/cli-O5SN7ZJ4.js.map +1 -0
  108. package/dist/config-OJQI27LT.js +45 -0
  109. package/dist/dist-3LOO6M4U.js +2842 -0
  110. package/dist/dist-3LOO6M4U.js.map +1 -0
  111. package/dist/doctor-IQQJHGGM.js +590 -0
  112. package/dist/doctor-IQQJHGGM.js.map +1 -0
  113. package/dist/env-proxy-XL4P73MZ.js +15 -0
  114. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  115. package/dist/fund-WEV6DMTD.js +365 -0
  116. package/dist/fund-WEV6DMTD.js.map +1 -0
  117. package/dist/hook-command-D2P3ILRV.js +32 -0
  118. package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
  119. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
  120. package/dist/hosts/claude/tenjin/.mcp.json +12 -0
  121. package/dist/hosts/claude/tenjin/hooks/hooks.json +221 -0
  122. package/dist/index.js +21 -2
  123. package/dist/index.js.map +1 -1
  124. package/dist/install-TUCRF32I.js +60 -0
  125. package/dist/install-identity-WHPNMNMQ.js +26 -0
  126. package/dist/install-wallet-MA27FTQ5.js +113 -0
  127. package/dist/install-wallet-MA27FTQ5.js.map +1 -0
  128. package/dist/mcp-QML7ZMPH.js +13427 -0
  129. package/dist/mcp-QML7ZMPH.js.map +1 -0
  130. package/dist/package-LGKYOEPV.js +37 -0
  131. package/dist/package-LGKYOEPV.js.map +1 -0
  132. package/dist/paths-POPTXJO6.js +61 -0
  133. package/dist/paths-POPTXJO6.js.map +1 -0
  134. package/dist/pay-2C2UBBXJ.js +51 -0
  135. package/dist/pay-2C2UBBXJ.js.map +1 -0
  136. package/dist/payments-C44QUFXU.js +106 -0
  137. package/dist/payments-C44QUFXU.js.map +1 -0
  138. package/dist/redact-6W23GGJC.js +15 -0
  139. package/dist/redact-6W23GGJC.js.map +1 -0
  140. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
  141. package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
  142. package/dist/send-KVJX4XIR.js +222 -0
  143. package/dist/send-KVJX4XIR.js.map +1 -0
  144. package/dist/status-S7C3WMSH.js +115 -0
  145. package/dist/status-S7C3WMSH.js.map +1 -0
  146. package/dist/status-line-YR2T5HC4.js +86 -0
  147. package/dist/status-line-YR2T5HC4.js.map +1 -0
  148. package/dist/uninstall-HY6LKIIT.js +149 -0
  149. package/dist/uninstall-HY6LKIIT.js.map +1 -0
  150. package/dist/update-OJV22LR3.js +36 -0
  151. package/dist/update-OJV22LR3.js.map +1 -0
  152. package/dist/usdc-JK4RRFFQ.js +39 -0
  153. package/dist/usdc-JK4RRFFQ.js.map +1 -0
  154. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  155. package/dist/viemAdapter-By13KInL-X2VY6CY3.js.map +1 -0
  156. package/dist/wallet-PD2IMZDU.js +39 -0
  157. package/dist/wallet-PD2IMZDU.js.map +1 -0
  158. package/dist/wallet-kdf-worker.mjs +980 -0
  159. package/docs/agent-permissions.md +180 -0
  160. package/docs/safety-model.md +59 -0
  161. package/docs/troubleshooting.md +13 -0
  162. package/package.json +28 -19
  163. package/LICENSE +0 -21
  164. package/dist/buy-EE6SEXP6.js +0 -1598
  165. package/dist/buy-EE6SEXP6.js.map +0 -1
  166. package/dist/candidate-ERMSYYQZ.js +0 -127
  167. package/dist/candidate-ERMSYYQZ.js.map +0 -1
  168. package/dist/chunk-3OV7E5G5.js +0 -18
  169. package/dist/chunk-3OV7E5G5.js.map +0 -1
  170. package/dist/chunk-4ONXEEQL.js +0 -152
  171. package/dist/chunk-4ONXEEQL.js.map +0 -1
  172. package/dist/chunk-662MSGZB.js +0 -286
  173. package/dist/chunk-662MSGZB.js.map +0 -1
  174. package/dist/chunk-7KUW4MJD.js +0 -59
  175. package/dist/chunk-7KUW4MJD.js.map +0 -1
  176. package/dist/chunk-AWPAWHNX.js +0 -333
  177. package/dist/chunk-AWPAWHNX.js.map +0 -1
  178. package/dist/chunk-DXTQ3CSI.js +0 -171
  179. package/dist/chunk-DXTQ3CSI.js.map +0 -1
  180. package/dist/chunk-ESPNTPQ2.js +0 -207
  181. package/dist/chunk-ESPNTPQ2.js.map +0 -1
  182. package/dist/chunk-FJPLRISB.js +0 -79
  183. package/dist/chunk-FJPLRISB.js.map +0 -1
  184. package/dist/chunk-GO75V3NZ.js +0 -160
  185. package/dist/chunk-GO75V3NZ.js.map +0 -1
  186. package/dist/chunk-JPHG2JW3.js +0 -96
  187. package/dist/chunk-JPHG2JW3.js.map +0 -1
  188. package/dist/chunk-MUBUQVC3.js +0 -67
  189. package/dist/chunk-MUBUQVC3.js.map +0 -1
  190. package/dist/chunk-NCE5NSN6.js.map +0 -1
  191. package/dist/chunk-OYMYCW7J.js.map +0 -1
  192. package/dist/chunk-RY4XKNV3.js +0 -140
  193. package/dist/chunk-RY4XKNV3.js.map +0 -1
  194. package/dist/chunk-S3IGX57D.js.map +0 -1
  195. package/dist/chunk-TLCMMYLY.js +0 -126
  196. package/dist/chunk-TLCMMYLY.js.map +0 -1
  197. package/dist/chunk-UO22YNY4.js +0 -69
  198. package/dist/chunk-UO22YNY4.js.map +0 -1
  199. package/dist/chunk-XHC6FCGZ.js +0 -261
  200. package/dist/chunk-XHC6FCGZ.js.map +0 -1
  201. package/dist/chunk-XJIW7USF.js.map +0 -1
  202. package/dist/chunk-YBMMV4Y4.js.map +0 -1
  203. package/dist/chunk-YN5SHIXQ.js +0 -126
  204. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  205. package/dist/chunk-Z52RA3NC.js +0 -137
  206. package/dist/chunk-Z52RA3NC.js.map +0 -1
  207. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  208. package/dist/cli-SBXI5AMS.js.map +0 -1
  209. package/dist/config-VELDKLHY.js +0 -21
  210. package/dist/doctor-T3KWNNP2.js +0 -20
  211. package/dist/inspect-LMKOXE4Y.js +0 -96
  212. package/dist/inspect-LMKOXE4Y.js.map +0 -1
  213. package/dist/install-LEX3ENQ6.js +0 -387
  214. package/dist/install-LEX3ENQ6.js.map +0 -1
  215. package/dist/lookup-ZPN2Q67N.js +0 -129
  216. package/dist/lookup-ZPN2Q67N.js.map +0 -1
  217. package/dist/outcome-N7TAK6WR.js +0 -66
  218. package/dist/outcome-N7TAK6WR.js.map +0 -1
  219. package/dist/publish-BKBQQAW4.js +0 -1478
  220. package/dist/publish-BKBQQAW4.js.map +0 -1
  221. package/dist/usdc-JIAJW4SV.js +0 -22
  222. package/dist/wallet-CWEMYVIH.js +0 -179
  223. package/dist/wallet-CWEMYVIH.js.map +0 -1
  224. package/dist/wallet-PA54CRBL.js +0 -30
  225. package/skills/tenjin/SKILL.md +0 -199
  226. package/skills/tenjin-publish/SKILL.md +0 -111
  227. package/skills/tenjin-search/SKILL.md +0 -133
  228. /package/dist/{_esm-FEASBWRP.js.map → _esm-CE7KNONL.js.map} +0 -0
  229. /package/dist/{ccip-NQXCEK2U.js.map → alive-3J3CHOQP.js.map} +0 -0
  230. /package/dist/{ccip-XR5NE5QK.js.map → ccip-7RMRLAGV.js.map} +0 -0
  231. /package/dist/{config-VELDKLHY.js.map → ccip-NLCSCHKI.js.map} +0 -0
  232. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
  233. /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
  234. /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
  235. /package/dist/{chunk-CYOF7ROH.js.map → chunk-HPWO4O6S.js.map} +0 -0
  236. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  237. /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
  238. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
  239. /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
  240. /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
  241. /package/dist/{doctor-T3KWNNP2.js.map → config-OJQI27LT.js.map} +0 -0
  242. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
  243. /package/dist/{secp256k1-N3ZHU7LB.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  244. /package/dist/{usdc-JIAJW4SV.js.map → hook-command-D2P3ILRV.js.map} +0 -0
  245. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → install-TUCRF32I.js.map} +0 -0
  246. /package/dist/{wallet-PA54CRBL.js.map → install-identity-WHPNMNMQ.js.map} +0 -0
@@ -1,17 +1,33 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ maybeUpdate,
4
+ readUpdateSignal
5
+ } from "./chunk-VZGAONSJ.js";
6
+ import {
7
+ PERMISSIONS_DOC_URL
8
+ } from "./chunk-A36LQPHV.js";
2
9
  import {
3
10
  defaultIo,
4
11
  emitFailure,
5
12
  emitSuccess
6
- } from "./chunk-Z52RA3NC.js";
13
+ } from "./chunk-KYFZTGMC.js";
7
14
  import {
8
- package_default
9
- } from "./chunk-FJPLRISB.js";
15
+ noteBaseUrlFlag
16
+ } from "./chunk-QUVVWYJW.js";
17
+ import "./chunk-IOODYAXL.js";
18
+ import "./chunk-2I4QTOLB.js";
19
+ import "./chunk-AWFUPKTM.js";
10
20
  import {
11
21
  CliError,
12
- dataDir,
13
22
  external_exports
14
- } from "./chunk-OYMYCW7J.js";
23
+ } from "./chunk-WO5BJNIB.js";
24
+ import "./chunk-O2FRQ2L2.js";
25
+ import {
26
+ dataDir
27
+ } from "./chunk-SJLTEINJ.js";
28
+ import {
29
+ package_default
30
+ } from "./chunk-VUFAK2LW.js";
15
31
  import {
16
32
  __commonJS,
17
33
  __require,
@@ -1185,11 +1201,11 @@ var require_suggestSimilar = __commonJS({
1185
1201
  var require_command = __commonJS({
1186
1202
  "node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js"(exports) {
1187
1203
  "use strict";
1188
- var EventEmitter = __require("events").EventEmitter;
1189
- var childProcess = __require("child_process");
1190
- var path = __require("path");
1191
- var fs = __require("fs");
1192
- var process2 = __require("process");
1204
+ var EventEmitter = __require("node:events").EventEmitter;
1205
+ var childProcess = __require("node:child_process");
1206
+ var path = __require("node:path");
1207
+ var fs = __require("node:fs");
1208
+ var process2 = __require("node:process");
1193
1209
  var { Argument: Argument2, humanReadableArgName } = require_argument();
1194
1210
  var { CommanderError: CommanderError2 } = require_error();
1195
1211
  var { Help: Help2, stripColor } = require_help();
@@ -3468,268 +3484,415 @@ var {
3468
3484
  Help
3469
3485
  } = import_index.default;
3470
3486
 
3471
- // src/cli.ts
3472
- var GlobalOptsSchema = external_exports.object({
3473
- json: external_exports.boolean().default(false),
3474
- baseUrl: external_exports.url().optional(),
3475
- timeout: external_exports.coerce.number().int().positive().default(1e4)
3476
- });
3477
- function addGlobalFlags(cmd) {
3478
- return cmd.option("--json", "emit machine JSON only (suppress human stderr rendering)").option("--base-url <url>", "Tenjin API base URL").option("--timeout <ms>", "request timeout in milliseconds");
3479
- }
3480
- function buildContext(cmd, io) {
3481
- const parsed = GlobalOptsSchema.safeParse(cmd.optsWithGlobals());
3482
- if (!parsed.success) {
3483
- throw new CliError("USAGE", "Invalid global option", {
3484
- fix: "Run `tenjin --help` for usage.",
3485
- details: parsed.error.issues
3486
- });
3487
- }
3488
- const flags = {
3489
- json: parsed.data.json,
3490
- timeout: parsed.data.timeout,
3491
- baseUrl: parsed.data.baseUrl
3492
- };
3493
- return { flags, dataDir: dataDir(process.env), io };
3494
- }
3495
- function buildProgram(io, setExit) {
3496
- const program2 = new Command();
3497
- const runCommand = async (command, cmd, run) => {
3498
- const json = cmd.optsWithGlobals().json === true;
3499
- try {
3500
- const ctx = buildContext(cmd, io);
3501
- const result = await run(ctx);
3502
- emitSuccess(ctx.io, command, result.data, result.humanLines, { json: ctx.flags.json });
3503
- } catch (err) {
3504
- setExit(emitFailure(io, command, err, { json }).exitCode);
3505
- }
3506
- };
3507
- program2.name("tenjin").description("Tenjin agent CLI for the x402 knowledge marketplace.").version(package_default.version, "-V, --version", "output the version number").option("--json", "emit machine JSON only (suppress human stderr rendering)").option("--base-url <url>", "Tenjin API base URL").option("--timeout <ms>", "request timeout in milliseconds", "10000").configureOutput({
3508
- // --help / --version print here (stdout). Nothing else uses writeOut, so
3509
- // stdout stays a single JSON object for every real command.
3510
- writeOut: (str) => io.stdout.write(str),
3511
- // Commander's usage/help text is human decoration: TTY only, never under
3512
- // --json. This gates on the root's --json (the scope available when a parse
3513
- // error fires before any subcommand runs); the machine contract for the same
3514
- // failure goes to stdout via handleParseError, so the two never collide.
3515
- writeErr: (str) => {
3516
- if (io.isTTY && program2.opts().json !== true) io.stderr.write(str);
3517
- }
3518
- }).exitOverride();
3519
- addGlobalFlags(program2.command("install")).description(
3520
- "Detect installed harnesses (Claude Code, Codex), wire the Tenjin skills, then run the doctor checks last"
3521
- ).option(
3522
- "--harness <name>",
3523
- "target a specific harness: claude | codex | shared (repeatable; overrides detection)",
3524
- collect,
3525
- []
3526
- ).option("--dry-run", "print what would change without writing anything").option(
3527
- "--publish-mode <mode>",
3528
- "set the publish consent mode non-interactively: review | auto | full-auto"
3487
+ // src/cli/registration.ts
3488
+ var SETUP = "Setup:";
3489
+ var WALLET = "Wallet:";
3490
+ var INTEGRATION = "Integration:";
3491
+
3492
+ // src/cli/core.ts
3493
+ function registerCore(reg) {
3494
+ const { runCommand, leaf: leaf2, addGlobalFlags: addGlobalFlags2 } = reg;
3495
+ leaf2(SETUP, "install", "set up Tenjin for Claude Code and create a wallet").description(
3496
+ "Set up Claude Code to use Tenjin: a wallet if this machine has none, spend limits for each lookup, and the Claude Code plugin `tenjin` (its routing hooks and its `router` MCP server), registered through Claude Code's own `claude plugin` commands. A settings-based install from an earlier release is removed once the plugin has loaded."
3497
+ ).option("--project", "register the plugin for this project only").option("--no-wallet", "create no wallet").option("--refresh", "bring the plugin this machine already has up to this version").option("--yes", "accept the defaults ($5 a day, $0.25 a call) instead of asking").option("--session-budget <usd|none>", "your own daily limit, or none, instead of asking").option("--max-auto-spend <usd>", "your own per-call limit, at least 0.25 (the default)").addHelpText(
3498
+ "after",
3499
+ `
3500
+ Examples:
3501
+ $ tenjin install
3502
+ $ tenjin install --project
3503
+ $ tenjin install --max-auto-spend 0.50 --session-budget 10
3504
+
3505
+ The daily limit is the control, the per-call limit the runaway guard, and the
3506
+ wallet balance the hard stop. To turn the router off instead:
3507
+ $ tenjin config set router.enabled false
3508
+
3509
+ Learn more:
3510
+ What the router may spend, and what leaves this machine:
3511
+ ${PERMISSIONS_DOC_URL}
3512
+ `
3529
3513
  ).action(async function() {
3530
3514
  await runCommand("install", this, async (ctx) => {
3531
3515
  const o = this.opts();
3532
- const { runInstall } = await import("./install-LEX3ENQ6.js");
3533
- return runInstall(
3516
+ const { runRouterInstall } = await import("./install-TUCRF32I.js");
3517
+ return runRouterInstall(
3534
3518
  {
3535
- ...Array.isArray(o.harness) && o.harness.length > 0 ? { harness: o.harness } : {},
3536
- ...o.dryRun === true ? { dryRun: true } : {},
3537
- ...typeof o.publishMode === "string" ? { publishMode: o.publishMode } : {}
3519
+ ...o.project === true ? { project: true } : {},
3520
+ ...o.refresh === true ? { refresh: true } : {},
3521
+ ...o.yes === true ? { yes: true } : {},
3522
+ ...o.wallet === false ? { noWallet: true } : {},
3523
+ ...typeof o.maxAutoSpend === "string" ? { maxAutoSpend: o.maxAutoSpend } : {},
3524
+ ...typeof o.sessionBudget === "string" ? { sessionBudget: o.sessionBudget } : {}
3538
3525
  },
3539
3526
  ctx
3540
3527
  );
3541
3528
  });
3542
3529
  });
3543
- addGlobalFlags(program2.command("doctor")).description("Check the local environment and Tenjin API reachability").action(async function() {
3530
+ leaf2(SETUP, "uninstall", "remove what install wrote; the wallet is kept").description(
3531
+ "Remove the Tenjin plugin `tenjin install` registered, and any settings-based install an earlier release wrote. Your wallet, spend ledger and config are kept."
3532
+ ).option("--project", "remove the project-only install").action(async function() {
3533
+ await runCommand("uninstall", this, async (ctx) => {
3534
+ const o = this.opts();
3535
+ const { runRouterUninstall } = await import("./uninstall-HY6LKIIT.js");
3536
+ return runRouterUninstall({ ...o.project === true ? { project: true } : {} }, ctx);
3537
+ });
3538
+ });
3539
+ leaf2(SETUP, "doctor", "check this machine can run a lookup").description(
3540
+ "Check everything a lookup needs: the Node floor, Claude Code's version, the Tenjin plugin and its router server, any settings install an earlier release left, the spend limits, the wallet, and the router endpoint answering its 402. It prints one line per check with a fix for each failure, writes nothing, and exits nonzero if a required one fails."
3541
+ ).option("--project", "check the project-only install, as --project registered it").addHelpText(
3542
+ "after",
3543
+ `
3544
+ Examples:
3545
+ $ tenjin doctor
3546
+ $ tenjin doctor --project
3547
+ $ tenjin doctor --json
3548
+ `
3549
+ ).action(async function() {
3544
3550
  await runCommand("doctor", this, async (ctx) => {
3545
- const { runDoctor } = await import("./doctor-T3KWNNP2.js");
3546
- return runDoctor(ctx);
3551
+ const { runRouterDoctor } = await import("./doctor-IQQJHGGM.js");
3552
+ return runRouterDoctor(ctx, this.opts().project === true ? { project: true } : {});
3553
+ });
3554
+ });
3555
+ leaf2(SETUP, "update", "update tenjin-cli to the newest published version").description(
3556
+ "Update tenjin-cli to the newest version npm publishes on the latest tag. It then runs `install --refresh` on the new binary, so the Claude Code plugin is registered at the build that just landed."
3557
+ ).option("--check", "report whether a newer version exists without installing it").action(async function() {
3558
+ await runCommand("update", this, async (ctx) => {
3559
+ const { runUpdate } = await import("./update-OJV22LR3.js");
3560
+ return runUpdate({ check: this.opts().check === true }, ctx);
3547
3561
  });
3548
3562
  });
3549
- const config = addGlobalFlags(program2.command("config")).description(
3550
- "Show or change CLI configuration"
3563
+ const config = leaf2(SETUP, "config", "read and set config values").description(
3564
+ "Print every effective config value, or read and write one. Values are stored in config.json under your Tenjin data dir (~/.tenjin by default)."
3565
+ );
3566
+ config.addHelpText(
3567
+ "after",
3568
+ `
3569
+ Examples:
3570
+ $ tenjin config
3571
+ $ tenjin config set router.context turn
3572
+ $ tenjin config set maxAutoSpend 0.25
3573
+ $ tenjin config set --project router.enabled false
3574
+ `
3551
3575
  );
3552
3576
  config.action(async function() {
3553
3577
  await runCommand("config", this, async (ctx) => {
3554
- const { runConfigList } = await import("./config-VELDKLHY.js");
3578
+ const { runConfigList } = await import("./config-OJQI27LT.js");
3555
3579
  return runConfigList(ctx);
3556
3580
  });
3557
3581
  });
3558
- addGlobalFlags(config.command("get <key>")).description("Print one effective config value").action(async function(key) {
3582
+ addGlobalFlags2(config.command("get <key>")).summary("print one effective config value").description(
3583
+ "Print one effective config value by key. The effective value is what the command would use, defaults and environment overrides included."
3584
+ ).action(async function(key) {
3559
3585
  await runCommand("config.get", this, async (ctx) => {
3560
- const { runConfigGet } = await import("./config-VELDKLHY.js");
3586
+ const { runConfigGet } = await import("./config-OJQI27LT.js");
3561
3587
  return runConfigGet({ key }, ctx);
3562
3588
  });
3563
3589
  });
3564
- addGlobalFlags(config.command("set <key> <value>")).description("Set a config value (decimal USD accepted for spend keys)").action(async function(key, value) {
3590
+ addGlobalFlags2(config.command("set <key> <value>")).summary("set a config value").description(
3591
+ "Write one config value, validated against the key it is for. Spend keys take decimal USD."
3592
+ ).option(
3593
+ "--project",
3594
+ "write a router key into this project's .tenjin/config.json, which is committed"
3595
+ ).option("--local", "with --project, write .tenjin/config.local.json instead, which is yours").action(async function(key, value) {
3596
+ const o = this.opts();
3565
3597
  await runCommand("config.set", this, async (ctx) => {
3566
- const { runConfigSet } = await import("./config-VELDKLHY.js");
3567
- return runConfigSet({ key, value }, ctx);
3598
+ const { runConfigSet } = await import("./config-OJQI27LT.js");
3599
+ return runConfigSet(
3600
+ { key, value, project: o.project === true, local: o.local === true },
3601
+ ctx
3602
+ );
3568
3603
  });
3569
3604
  });
3570
- const wallet = addGlobalFlags(
3571
- program2.command("wallet").description("Manage the local x402 payment wallet")
3605
+ const wallet = leaf2(
3606
+ WALLET,
3607
+ "wallet",
3608
+ "create, show, fund and send from the local wallet"
3609
+ ).description(
3610
+ "Manage the local x402 payment wallet used for paid reads and publishing. The private key is generated on this machine, stored encrypted, and never printed."
3572
3611
  );
3573
- addGlobalFlags(wallet.command("create")).description("Create a new local wallet").action(async function() {
3612
+ addGlobalFlags2(wallet.command("create")).summary("create a new local wallet").description(
3613
+ "Create a new local wallet and store its keystore encrypted under your Tenjin data dir. It refuses when one already exists, so replacing an active wallet is the deliberate --replace."
3614
+ ).option(
3615
+ "--replace",
3616
+ "archive the existing wallet beside the new one, passphrase preserved, then create a new active wallet"
3617
+ ).action(async function() {
3574
3618
  await runCommand("wallet.create", this, async (ctx) => {
3575
- const { runWalletCreate } = await import("./wallet-CWEMYVIH.js");
3576
- return runWalletCreate(ctx);
3619
+ const o = this.opts();
3620
+ const { runWalletCreate } = await import("./wallet-PD2IMZDU.js");
3621
+ return runWalletCreate(ctx, o.replace === true ? { replace: true } : {});
3577
3622
  });
3578
3623
  });
3579
- addGlobalFlags(wallet.command("show")).description("Show the wallet address and key source (never the key)").action(async function() {
3624
+ addGlobalFlags2(wallet.command("show")).alias("address").summary("show the wallet address and key source").description(
3625
+ "Print the active wallet address and where its key comes from. The private key is never printed, by any flag. At a terminal it also draws the address as a QR code for a phone wallet to scan."
3626
+ ).option("--no-qr", "print the address without the QR code").action(async function() {
3580
3627
  await runCommand("wallet.show", this, async (ctx) => {
3581
- const { runWalletShow } = await import("./wallet-CWEMYVIH.js");
3582
- return runWalletShow(ctx);
3628
+ const o = this.opts();
3629
+ const { runWalletShow } = await import("./wallet-PD2IMZDU.js");
3630
+ return runWalletShow(ctx, o.qr === false ? { qr: false } : {});
3583
3631
  });
3584
3632
  });
3585
- addGlobalFlags(wallet.command("balance")).description("Show the wallet USDC balance on Base").action(async function() {
3633
+ addGlobalFlags2(wallet.command("balance")).summary("show the wallet USDC balance on Base").description(
3634
+ "Read the wallet USDC balance on Base. It is a chain read: no key is unlocked and nothing is spent."
3635
+ ).action(async function() {
3586
3636
  await runCommand("wallet.balance", this, async (ctx) => {
3587
- const { runWalletBalance } = await import("./wallet-CWEMYVIH.js");
3637
+ const { runWalletBalance } = await import("./wallet-PD2IMZDU.js");
3588
3638
  return runWalletBalance(ctx);
3589
3639
  });
3590
3640
  });
3591
- addGlobalFlags(program2.command("lookup <question>")).description(
3592
- "Ask for payable candidates or an honest MISS. Use when a task needs public knowledge someone may already have published; send only a generalized public question, never secrets or private context"
3593
- ).option("--max-price <usd>", "only candidates at or below this decimal-USD price").option("--fresh-within <window>", "freshness window, e.g. P30D, P2W, P1Y").option("--limit <n>", "maximum candidates (1-10, default 5)").option("--applies-to <pair>", "applicability filter key=value (repeatable)", collect, []).action(async function(question) {
3594
- await runCommand("lookup", this, async (ctx) => {
3641
+ addGlobalFlags2(wallet.command("fund [amountUsd]")).summary("fund this wallet through a checkout link for your region").description(
3642
+ "Get a checkout link for THIS wallet, open it in the browser, and wait for the USDC to land on Base. In the US: Apple Pay or Google Pay with no Coinbase account. Elsewhere: your Coinbase account. The link moves no money: a human completes the payment."
3643
+ ).option("--no-open", "print the checkout link without opening a browser").option("--no-qr", "skip the QR code of the address for sending USDC from a phone").option(
3644
+ "--no-wait",
3645
+ "return once the link is issued instead of polling the balance (already the default when not at a TTY)"
3646
+ ).action(async function(amountUsd) {
3647
+ await runCommand("wallet.fund", this, async (ctx) => {
3595
3648
  const o = this.opts();
3596
- const { runLookup } = await import("./lookup-ZPN2Q67N.js");
3597
- return runLookup(
3598
- {
3599
- question,
3600
- ...typeof o.maxPrice === "string" ? { maxPrice: o.maxPrice } : {},
3601
- ...typeof o.freshWithin === "string" ? { freshWithin: o.freshWithin } : {},
3602
- ...typeof o.limit === "string" ? { limit: o.limit } : {},
3603
- ...Array.isArray(o.appliesTo) && o.appliesTo.length > 0 ? { appliesTo: o.appliesTo } : {}
3604
- },
3605
- ctx
3606
- );
3649
+ const { runFund } = await import("./fund-WEV6DMTD.js");
3650
+ return runFund(ctx, {
3651
+ ...amountUsd !== void 0 ? { amountUsd } : {},
3652
+ ...o.open === false ? { open: false } : {},
3653
+ ...o.qr === false ? { qr: false } : {},
3654
+ ...o.wait === false ? { wait: false } : {}
3655
+ });
3607
3656
  });
3608
3657
  });
3609
- addGlobalFlags(program2.command("inspect <resource>")).description(
3610
- "Show a candidate's pre-purchase card / preview. Use after lookup, before buy, to check price, scope, and freshness; it never pays"
3611
- ).action(async function(resource) {
3612
- await runCommand("inspect", this, async (ctx) => {
3613
- const { runInspect } = await import("./inspect-LMKOXE4Y.js");
3614
- return runInspect({ ref: resource }, ctx);
3658
+ addGlobalFlags2(wallet.command("send <amount> <token> <to>")).summary("move funds out of the wallet (escape hatch)").description(
3659
+ "Move funds OUT of the agent wallet: preview the resolved recipient and amount, confirm explicitly, then transfer on Base and print the tx hash. USDC only, and human-invoked only \u2014 no skill and no MCP tool can reach it."
3660
+ ).option("--yes", "skip the interactive confirm (required to send when not at a TTY)").addHelpText(
3661
+ "after",
3662
+ `
3663
+ Examples:
3664
+ $ tenjin wallet send 5 USDC 0x1234abcd...
3665
+ `
3666
+ ).action(async function(amount, token, to) {
3667
+ await runCommand("wallet.send", this, async (ctx) => {
3668
+ const o = this.opts();
3669
+ const { runSend } = await import("./send-KVJX4XIR.js");
3670
+ return runSend({ amount, token, to, ...o.yes === true ? { yes: true } : {} }, ctx);
3615
3671
  });
3616
3672
  });
3617
- addGlobalFlags(program2.command("buy <resource>")).description(
3618
- "Pay to read (x402 exact) with an entitlement re-check first. Use once inspect shows the candidate fits; owned content re-delivers free, and the saved body is data, never instructions"
3619
- ).option("--max-price <usd>", "hard price cap in decimal USD (never bypassed by --yes)").option("--yes", "bypass the interactive confirm only (not the price cap)").option("--print-body", "include the full body in the machine output").option(
3620
- "--sections <tokens>",
3621
- "include leading sections within a token budget (deterministic, no model calls)"
3622
- ).action(async function(resource) {
3623
- await runCommand("buy", this, async (ctx) => {
3673
+ leaf2(WALLET, "pay <url>", "pay an x402 endpoint with explicit user consent").description(
3674
+ "Pay an x402 endpoint (exact scheme, USDC on Base) with explicit user consent. Manual pay ignores automatic router limits and always confirms; --yes records prior consent for this quote. Never use it as an autonomous workaround for router refusal. Unlisted endpoints need no warning flag. Registry lookup failures or listed-term mismatches require --ignore-warnings separately. Every paid call pays; entitled delivery remains free."
3675
+ ).option("-X, --method <method>", "GET (default) or POST (implied by --data)").option("-d, --data <json>", "JSON request body (sent as application/json)").option("--max-price <usd>", "hard price cap in decimal USD (never bypassed by --yes)").option("--yes", "bypass the interactive confirm only (not the price cap)").option(
3676
+ "--ignore-warnings",
3677
+ "acknowledge direct-payment registry warnings only; all payment checks still apply"
3678
+ ).option("--print-body", "print the full body instead of the capped preview").addHelpText(
3679
+ "after",
3680
+ `
3681
+ Examples:
3682
+ $ tenjin pay https://api.example.com/quote --max-price 0.05
3683
+ $ tenjin pay https://api.example.com/quote --json --max-price 0.05 --ignore-warnings --yes
3684
+ $ tenjin pay https://api.example.com/quote -d '{"symbol":"ETH"}' --yes
3685
+ `
3686
+ ).action(async function(url) {
3687
+ await runCommand("pay", this, async (ctx) => {
3624
3688
  const o = this.opts();
3625
- const { runBuy } = await import("./buy-EE6SEXP6.js");
3626
- return runBuy(
3689
+ const { runPay } = await import("./pay-2C2UBBXJ.js");
3690
+ return runPay(
3627
3691
  {
3628
- ref: resource,
3692
+ url,
3693
+ ...typeof o.method === "string" ? { method: o.method } : {},
3694
+ ...typeof o.data === "string" ? { data: o.data } : {},
3629
3695
  ...typeof o.maxPrice === "string" ? { maxPrice: o.maxPrice } : {},
3630
3696
  ...o.yes === true ? { yes: true } : {},
3631
3697
  ...o.printBody === true ? { printBody: true } : {},
3632
- ...typeof o.sections === "string" ? { sections: o.sections } : {}
3698
+ ...o.ignoreWarnings === true ? { ignoreWarnings: true } : {}
3633
3699
  },
3634
3700
  ctx
3635
3701
  );
3636
3702
  });
3637
3703
  });
3638
- addGlobalFlags(program2.command("publish [file]")).description(
3639
- "Publish a Markdown file (or a parked --candidate) as a paid or free piece with an optional answer card, gated by the local scan and your publish.mode consent. Use to ship knowledge others can buy; a secret in the file hard-blocks, and soft findings need --yes"
3640
- ).option(
3641
- "--candidate <id>",
3642
- "publish a parked candidate by id instead of a file (clears it on success)"
3643
- ).option("--draft", "save as a private draft instead of publishing").option("--yes", "clear soft findings and the review confirm (never a hard block)").option("--mode <mode>", "consent mode for this run: review | auto | full-auto").option("--price <usd>", "post price in decimal USD (defaults to publish.defaultPrice)").option("--question <text>", "a question this piece answers (repeatable)", collect, []).option("--task <text>", "a task this piece supports (repeatable)", collect, []).option("--scope <text>", "what the piece covers (card scope)").option("--exclusions <text>", "what the piece does not cover (card exclusions)").option("--applies-to <pair>", "applicability key=value (repeatable)", collect, []).option("--as-of <iso>", "as-of timestamp, ISO-8601 with offset").option("--valid-until <iso>", "valid-until timestamp, ISO-8601 with offset").option("--artifact-type <type>", "document | skill | dataset").option("--temporal-mode <mode>", "snapshot | maintained | evergreen").option("--provenance <text>", "provenance summary (card)").option("--methodology <text>", "methodology summary (card)").action(async function(file) {
3644
- await runCommand("publish", this, async (ctx) => {
3645
- const o = this.opts();
3646
- const { runPublish } = await import("./publish-BKBQQAW4.js");
3647
- return runPublish(
3648
- {
3649
- ...typeof file === "string" ? { file } : {},
3650
- ...typeof o.candidate === "string" ? { candidate: o.candidate } : {},
3651
- ...o.draft === true ? { draft: true } : {},
3652
- ...o.yes === true ? { yes: true } : {},
3653
- ...typeof o.mode === "string" ? { mode: o.mode } : {},
3654
- ...typeof o.price === "string" ? { price: o.price } : {},
3655
- ...Array.isArray(o.question) && o.question.length > 0 ? { question: o.question } : {},
3656
- ...Array.isArray(o.task) && o.task.length > 0 ? { task: o.task } : {},
3657
- ...typeof o.scope === "string" ? { scope: o.scope } : {},
3658
- ...typeof o.exclusions === "string" ? { exclusions: o.exclusions } : {},
3659
- ...Array.isArray(o.appliesTo) && o.appliesTo.length > 0 ? { appliesTo: o.appliesTo } : {},
3660
- ...typeof o.asOf === "string" ? { asOf: o.asOf } : {},
3661
- ...typeof o.validUntil === "string" ? { validUntil: o.validUntil } : {},
3662
- ...typeof o.artifactType === "string" ? { artifactType: o.artifactType } : {},
3663
- ...typeof o.temporalMode === "string" ? { temporalMode: o.temporalMode } : {},
3664
- ...typeof o.provenance === "string" ? { provenance: o.provenance } : {},
3665
- ...typeof o.methodology === "string" ? { methodology: o.methodology } : {}
3666
- },
3667
- ctx
3668
- );
3704
+ }
3705
+
3706
+ // src/cli/router.ts
3707
+ function registerRouter(reg) {
3708
+ const { io, runCommand, leaf: leaf2, addGlobalFlags: addGlobalFlags2, buildContext: buildContext2 } = reg;
3709
+ const hook = leaf2(INTEGRATION, "hook", "run one harness hook handler (called by Claude Code)").description(
3710
+ "The handlers Tenjin's Claude Code plugin runs. Each reads one hook event on stdin and writes the harness response, or nothing, on stdout. You never run these by hand."
3711
+ ).helpCommand(false);
3712
+ addGlobalFlags2(hook.command("alive")).summary("SessionStart: mark this session and machine as ones the plugin serves").action(async function() {
3713
+ const ctx = buildContext2(this);
3714
+ const [{ aliveMain }, { default: pkg }] = await Promise.all([
3715
+ import("./alive-3J3CHOQP.js"),
3716
+ import("./package-LGKYOEPV.js")
3717
+ ]);
3718
+ await aliveMain({ dataDir: ctx.dataDir, version: pkg.version });
3719
+ });
3720
+ for (const [name, summary] of [
3721
+ ["prompt", "UserPromptSubmit: build the session packet and ask the free gate"],
3722
+ ["native", "PreToolUse on WebSearch|WebFetch: allow the call, or redirect it"],
3723
+ [
3724
+ "shortfall",
3725
+ "PostToolUse(Failure) on WebSearch|WebFetch: offer a paid lookup when the result came back short"
3726
+ ],
3727
+ ["agent", "PreToolUse on Agent|Task: append any paid offer to the subagent's task"],
3728
+ ["ask", "PreToolUse on AskUserQuestion: allow the question, or redirect it once"],
3729
+ ["answer", "PostToolUse on AskUserQuestion: offer a paid lookup beside the user's answers"]
3730
+ ]) {
3731
+ addGlobalFlags2(hook.command(name)).summary(summary).action(async function() {
3732
+ const ctx = buildContext2(this);
3733
+ const { runHookCommand } = await import("./hook-command-D2P3ILRV.js");
3734
+ await runHookCommand(name, io, {
3735
+ dataDir: ctx.dataDir,
3736
+ ...ctx.flags.baseUrl !== void 0 ? { baseUrl: ctx.flags.baseUrl } : {}
3737
+ });
3669
3738
  });
3739
+ }
3740
+ hook.command("unknown", { hidden: true, isDefault: true }).argument("[args...]").allowUnknownOption().allowExcessArguments().action(() => {
3670
3741
  });
3671
- addGlobalFlags(program2.command("outcome")).description(
3672
- "Report how a lookup ended, honestly (used, partially_used, rejected, regenerated, purchase_declined). Use after acting on a lookup; this closes the loop the marketplace learns from"
3673
- ).option("--lookup-id <id>", "the lookup to report against").option("--last", "target the most recent local lookup").requiredOption(
3674
- "--status <status>",
3675
- "used | partially_used | rejected | regenerated | purchase_declined"
3676
- ).option("--resource <id>", "the resourceId the outcome concerns").option("--content-hash <hash>", "sha256:<64hex> of the exact body read").action(async function() {
3677
- await runCommand("outcome", this, async (ctx) => {
3678
- const o = this.opts();
3679
- const { runOutcome } = await import("./outcome-N7TAK6WR.js");
3680
- return runOutcome(
3681
- {
3682
- status: String(o.status),
3683
- ...typeof o.lookupId === "string" ? { lookupId: o.lookupId } : {},
3684
- ...o.last === true ? { last: true } : {},
3685
- ...typeof o.resource === "string" ? { resource: o.resource } : {},
3686
- ...typeof o.contentHash === "string" ? { contentHash: o.contentHash } : {}
3687
- },
3688
- ctx
3689
- );
3742
+ leaf2(INTEGRATION, "mcp", "run the local stdio MCP server").addOption(new Option("--plugin", "started by the Tenjin Claude Code plugin").hideHelp()).description(
3743
+ "Run the local stdio MCP server that carries the `request` tool: one free routing decision per lookup, then the provider call, built here from the offer's spec and your assistant's input where it has one, under your local spend policy. It speaks on stdin and stdout and runs until the client disconnects, so it prints no envelope of its own."
3744
+ ).action(async function() {
3745
+ const ctx = buildContext2(this);
3746
+ const { runRouterMcpServer } = await import("./mcp-QML7ZMPH.js");
3747
+ await runRouterMcpServer({ dataDir: ctx.dataDir, flags: ctx.flags });
3748
+ });
3749
+ leaf2(INTEGRATION, "status-line", "the live footer, for Claude Code's status line").description(
3750
+ "Print one line naming what this session is looking up right now: the provider actually being called, its bounded parameters, and what it cost. It reads Claude Code's status event on stdin for the session identity, reads that session's own progress records, writes nothing, and prints `x402 \xB7 ready` when this session has no activity. Opt-in: set it as your Claude Code status line command yourself."
3751
+ ).action(async function() {
3752
+ const ctx = buildContext2(this);
3753
+ const { runStatusLine } = await import("./status-line-YR2T5HC4.js");
3754
+ await runStatusLine(io, { dataDir: ctx.dataDir });
3755
+ });
3756
+ leaf2(SETUP, "status", "what this machine has spent, and what is still open").description(
3757
+ "Report the rolling 24h spend window from spend.json: what has settled, what is reserved by a request still in flight, and the per-call and per-day caps in force."
3758
+ ).action(async function() {
3759
+ await runCommand("status", this, async (ctx) => {
3760
+ const { runRouterStatus } = await import("./status-S7C3WMSH.js");
3761
+ return runRouterStatus(ctx);
3690
3762
  });
3691
3763
  });
3692
- const candidate = addGlobalFlags(
3693
- program2.command("candidate").description(
3694
- "Manage local publish candidates (parked drafts; nothing uploads until publish)"
3695
- )
3764
+ const payments = leaf2(SETUP, "payments", "the paid lookups this machine made").description(
3765
+ "The local record of paid router lookups, in `~/.tenjin/paid/ledger.jsonl`. A bare `tenjin payments` lists the newest: when, who was paid, how much, whether it settled, and the transaction."
3696
3766
  );
3697
- addGlobalFlags(candidate.command("add <file>")).description("Park a Markdown draft as a publish candidate, tied to a lookup").requiredOption("--lookup-id <id>", "the lookup whose unmet demand this draft answers").option("--question <q>", "the question this draft answers").action(async function(file) {
3698
- await runCommand("candidate.add", this, async (ctx) => {
3699
- const o = this.opts();
3700
- const { runCandidateAdd } = await import("./candidate-ERMSYYQZ.js");
3701
- return runCandidateAdd(
3702
- {
3703
- file,
3704
- lookupId: String(o.lookupId),
3705
- ...typeof o.question === "string" ? { question: o.question } : {}
3706
- },
3707
- ctx
3708
- );
3767
+ payments.action(async function() {
3768
+ await runCommand("payments", this, async (ctx) => {
3769
+ const { runPaymentsList } = await import("./payments-C44QUFXU.js");
3770
+ return runPaymentsList(ctx);
3709
3771
  });
3710
3772
  });
3711
- addGlobalFlags(candidate.command("list")).description("List pending candidates, newest first").action(async function() {
3712
- await runCommand("candidate.list", this, async (ctx) => {
3713
- const { runCandidateList } = await import("./candidate-ERMSYYQZ.js");
3714
- return runCandidateList(ctx);
3773
+ addGlobalFlags2(payments.command("reconcile")).summary("resolve paid lookups whose settlement is unknown").description(
3774
+ "For each paid lookup whose seller never confirmed settlement and whose authorization has expired, ask USDC on Base (through the configured rpcUrl) whether it was used: used means it was charged, unused means it never can be. Nothing is signed or sent but that one read."
3775
+ ).action(async function() {
3776
+ await runCommand("payments.reconcile", this, async (ctx) => {
3777
+ const { runPaymentsReconcile } = await import("./payments-C44QUFXU.js");
3778
+ return runPaymentsReconcile(ctx);
3715
3779
  });
3716
3780
  });
3717
- addGlobalFlags(candidate.command("drop <id>")).description("Discard a pending candidate (never auto-deleted)").action(async function(id) {
3718
- await runCommand("candidate.drop", this, async (ctx) => {
3719
- const { runCandidateDrop } = await import("./candidate-ERMSYYQZ.js");
3720
- return runCandidateDrop({ id }, ctx);
3781
+ }
3782
+
3783
+ // src/cli.ts
3784
+ var GlobalOptsSchema = external_exports.object({
3785
+ json: external_exports.boolean().default(false),
3786
+ baseUrl: external_exports.url().optional(),
3787
+ timeout: external_exports.coerce.number().int().positive().default(1e4)
3788
+ });
3789
+ var GLOBAL_FLAGS = [
3790
+ ["--json", "emit one machine JSON envelope on stdout instead of the human rendering"],
3791
+ ["--base-url <url>", "Tenjin API base URL"],
3792
+ ["--timeout <ms>", "request timeout in milliseconds", "10000"]
3793
+ ];
3794
+ function addGlobalFlags(cmd) {
3795
+ for (const [flags, help] of GLOBAL_FLAGS) cmd.addOption(new Option(flags, help).hideHelp());
3796
+ return cmd;
3797
+ }
3798
+ function leaf(program2, group, nameAndArgs, summary) {
3799
+ return addGlobalFlags(
3800
+ program2.command(nameAndArgs).helpGroup(group).summary(summary).helpCommand(false).helpOption("-h, --help", "show this help")
3801
+ );
3802
+ }
3803
+ function rootHelpCommand() {
3804
+ return new Command("help").argument("[command]", "the command to show help for").helpGroup(SETUP).summary("show help for a command").description("Show help for a command. `tenjin <command> --help` says the same thing.").helpOption(false);
3805
+ }
3806
+ function buildContext(cmd, io) {
3807
+ const parsed = GlobalOptsSchema.safeParse(cmd.optsWithGlobals());
3808
+ if (!parsed.success) {
3809
+ throw new CliError("USAGE", "Invalid global option", {
3810
+ fix: "Run `tenjin --help` for usage.",
3811
+ details: parsed.error.issues
3721
3812
  });
3722
- });
3723
- return program2;
3813
+ }
3814
+ const flags = {
3815
+ json: parsed.data.json,
3816
+ timeout: parsed.data.timeout,
3817
+ baseUrl: parsed.data.baseUrl
3818
+ };
3819
+ noteBaseUrlFlag(flags.baseUrl);
3820
+ return { flags, dataDir: dataDir(process.env), io };
3724
3821
  }
3725
- function collect(value, previous) {
3726
- return [...previous, value];
3822
+ var PRODUCTS = [registerCore, registerRouter];
3823
+ function buildProgram(io, setExit, products = PRODUCTS) {
3824
+ const program2 = new Command();
3825
+ const runCommand = async (command, cmd, run) => {
3826
+ const json = cmd.optsWithGlobals().json === true;
3827
+ const refreshRun = command === "install" && cmd.optsWithGlobals().refresh === true;
3828
+ const updateAvailable = command === "update" ? null : await readUpdateSignal(dataDir(process.env));
3829
+ try {
3830
+ const ctx = buildContext(cmd, io);
3831
+ const result = await run(ctx);
3832
+ emitSuccess(ctx.io, command, result.data, result.humanLines, {
3833
+ json: ctx.flags.json,
3834
+ updateAvailable
3835
+ });
3836
+ } catch (err) {
3837
+ setExit(emitFailure(io, command, err, { json, updateAvailable }).exitCode);
3838
+ }
3839
+ if (command !== "update" && !refreshRun) {
3840
+ await maybeUpdate({ dir: dataDir(process.env), io, json });
3841
+ }
3842
+ };
3843
+ program2.name("tenjin").description(
3844
+ "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base."
3845
+ ).optionsGroup("Global options:").addHelpCommand(rootHelpCommand()).configureOutput({
3846
+ // --help / --version print here (stdout). Nothing else uses writeOut, so
3847
+ // stdout stays a single JSON object for every real command.
3848
+ writeOut: (str) => io.stdout.write(str),
3849
+ // Commander's usage/help text is human decoration: TTY only, never under
3850
+ // --json. This gates on the root's --json (the scope available when a parse
3851
+ // error fires before any subcommand runs); the machine contract for the same
3852
+ // failure goes to stdout via handleParseError, so the two never collide.
3853
+ writeErr: (str) => {
3854
+ if (io.isTTY && program2.opts().json !== true) io.stderr.write(str);
3855
+ }
3856
+ }).exitOverride();
3857
+ for (const [flags, help, fallback] of GLOBAL_FLAGS) {
3858
+ const option = new Option(flags, help);
3859
+ program2.addOption(fallback === void 0 ? option : option.default(fallback));
3860
+ }
3861
+ program2.version(package_default.version, "-V, --version", "output the version number").helpOption("-h, --help", "show this help");
3862
+ const registration = {
3863
+ program: program2,
3864
+ io,
3865
+ runCommand,
3866
+ leaf: (group, nameAndArgs, summary) => leaf(program2, group, nameAndArgs, summary),
3867
+ addGlobalFlags,
3868
+ buildContext: (cmd) => buildContext(cmd, io)
3869
+ };
3870
+ for (const register of products) register(registration);
3871
+ program2.addHelpText(
3872
+ "after",
3873
+ `
3874
+ Examples:
3875
+ $ tenjin install
3876
+ $ tenjin wallet fund
3877
+ $ tenjin status
3878
+
3879
+ Learn more:
3880
+ Run \`tenjin <command> --help\` for one command.
3881
+ Permissions: ${PERMISSIONS_DOC_URL}
3882
+ Issues: ${package_default.bugs}
3883
+ `
3884
+ );
3885
+ return program2;
3727
3886
  }
3728
- async function main(argv, io = defaultIo()) {
3887
+ async function main(argv, io = defaultIo(), products = PRODUCTS) {
3729
3888
  let exitCode = 0;
3730
- const program2 = buildProgram(io, (code) => {
3731
- exitCode = code;
3732
- });
3889
+ const program2 = buildProgram(
3890
+ io,
3891
+ (code) => {
3892
+ exitCode = code;
3893
+ },
3894
+ products
3895
+ );
3733
3896
  try {
3734
3897
  await program2.parseAsync(argv, { from: "user" });
3735
3898
  } catch (err) {
@@ -3739,21 +3902,26 @@ async function main(argv, io = defaultIo()) {
3739
3902
  }
3740
3903
  function handleParseError(err, io, program2) {
3741
3904
  const json = program2.opts().json === true;
3905
+ const humanFirst = io.isTTY && !json;
3742
3906
  if (err instanceof CommanderError) {
3743
3907
  if (err.code === "commander.version" || err.code === "commander.helpDisplayed") {
3744
3908
  return 0;
3745
3909
  }
3746
- const message = err.code === "commander.help" ? "No command specified" : err.message.replace(/^error:\s*/i, "");
3747
- const usageErr = new CliError("USAGE", message, {
3748
- fix: "Run `tenjin --help` for available commands."
3749
- });
3750
- emitFailure(io, "tenjin", usageErr, { json: true });
3910
+ if (err.code === "commander.help" && err.exitCode === 0) return 0;
3911
+ if (!humanFirst) {
3912
+ const message = err.code === "commander.help" ? "No command specified" : err.message.replace(/^error:\s*/i, "");
3913
+ const usageErr = new CliError("USAGE", message, {
3914
+ fix: "Run `tenjin --help` for available commands."
3915
+ });
3916
+ emitFailure(io, "tenjin", usageErr, { json: true });
3917
+ }
3751
3918
  return 2;
3752
3919
  }
3753
3920
  return emitFailure(io, "tenjin", err, { json }).exitCode;
3754
3921
  }
3755
3922
  export {
3923
+ PRODUCTS,
3756
3924
  buildProgram,
3757
3925
  main
3758
3926
  };
3759
- //# sourceMappingURL=cli-SBXI5AMS.js.map
3927
+ //# sourceMappingURL=cli-O5SN7ZJ4.js.map