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,4 +1,10 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ DEFAULT_RPC_URL
4
+ } from "./chunk-O2FRQ2L2.js";
5
+ import {
6
+ configPath
7
+ } from "./chunk-SJLTEINJ.js";
2
8
  import {
3
9
  __export
4
10
  } from "./chunk-ZXTAQYNA.js";
@@ -509,7 +515,7 @@ __export(core_exports2, {
509
515
  parse: () => parse,
510
516
  parseAsync: () => parseAsync,
511
517
  prettifyError: () => prettifyError,
512
- process: () => process2,
518
+ process: () => process,
513
519
  regexes: () => regexes_exports,
514
520
  registry: () => registry,
515
521
  safeDecode: () => safeDecode,
@@ -11434,7 +11440,7 @@ function initializeContext(params) {
11434
11440
  external: params?.external ?? void 0
11435
11441
  };
11436
11442
  }
11437
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11443
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
11438
11444
  var _a3;
11439
11445
  const def = schema._zod.def;
11440
11446
  const seen = ctx.seen.get(schema);
@@ -11471,7 +11477,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11471
11477
  if (parent) {
11472
11478
  if (!result.ref)
11473
11479
  result.ref = parent;
11474
- process2(parent, ctx, params);
11480
+ process(parent, ctx, params);
11475
11481
  ctx.seen.get(parent).isParent = true;
11476
11482
  }
11477
11483
  }
@@ -11759,14 +11765,14 @@ function isTransforming(_schema, _ctx) {
11759
11765
  }
11760
11766
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11761
11767
  const ctx = initializeContext({ ...params, processors });
11762
- process2(schema, ctx);
11768
+ process(schema, ctx);
11763
11769
  extractDefs(ctx, schema);
11764
11770
  return finalize(ctx, schema);
11765
11771
  };
11766
11772
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11767
11773
  const { libraryOptions, target } = params ?? {};
11768
11774
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11769
- process2(schema, ctx);
11775
+ process(schema, ctx);
11770
11776
  extractDefs(ctx, schema);
11771
11777
  return finalize(ctx, schema);
11772
11778
  };
@@ -12012,7 +12018,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
12012
12018
  if (typeof maximum === "number")
12013
12019
  json2.maxItems = maximum;
12014
12020
  json2.type = "array";
12015
- json2.items = process2(def.element, ctx, {
12021
+ json2.items = process(def.element, ctx, {
12016
12022
  ...params,
12017
12023
  path: [...params.path, "items"]
12018
12024
  });
@@ -12024,7 +12030,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12024
12030
  json2.properties = {};
12025
12031
  const shape = def.shape;
12026
12032
  for (const key in shape) {
12027
- json2.properties[key] = process2(shape[key], ctx, {
12033
+ json2.properties[key] = process(shape[key], ctx, {
12028
12034
  ...params,
12029
12035
  path: [...params.path, "properties", key]
12030
12036
  });
@@ -12047,7 +12053,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12047
12053
  if (ctx.io === "output")
12048
12054
  json2.additionalProperties = false;
12049
12055
  } else if (def.catchall) {
12050
- json2.additionalProperties = process2(def.catchall, ctx, {
12056
+ json2.additionalProperties = process(def.catchall, ctx, {
12051
12057
  ...params,
12052
12058
  path: [...params.path, "additionalProperties"]
12053
12059
  });
@@ -12056,7 +12062,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12056
12062
  var unionProcessor = (schema, ctx, json2, params) => {
12057
12063
  const def = schema._zod.def;
12058
12064
  const isExclusive = def.inclusive === false;
12059
- const options = def.options.map((x, i) => process2(x, ctx, {
12065
+ const options = def.options.map((x, i) => process(x, ctx, {
12060
12066
  ...params,
12061
12067
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
12062
12068
  }));
@@ -12068,11 +12074,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
12068
12074
  };
12069
12075
  var intersectionProcessor = (schema, ctx, json2, params) => {
12070
12076
  const def = schema._zod.def;
12071
- const a = process2(def.left, ctx, {
12077
+ const a = process(def.left, ctx, {
12072
12078
  ...params,
12073
12079
  path: [...params.path, "allOf", 0]
12074
12080
  });
12075
- const b = process2(def.right, ctx, {
12081
+ const b = process(def.right, ctx, {
12076
12082
  ...params,
12077
12083
  path: [...params.path, "allOf", 1]
12078
12084
  });
@@ -12089,11 +12095,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
12089
12095
  json2.type = "array";
12090
12096
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
12091
12097
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
12092
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
12098
+ const prefixItems = def.items.map((x, i) => process(x, ctx, {
12093
12099
  ...params,
12094
12100
  path: [...params.path, prefixPath, i]
12095
12101
  }));
12096
- const rest = def.rest ? process2(def.rest, ctx, {
12102
+ const rest = def.rest ? process(def.rest, ctx, {
12097
12103
  ...params,
12098
12104
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
12099
12105
  }) : null;
@@ -12133,7 +12139,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12133
12139
  const keyBag = keyType._zod.bag;
12134
12140
  const patterns = keyBag?.patterns;
12135
12141
  if (def.mode === "loose" && patterns && patterns.size > 0) {
12136
- const valueSchema = process2(def.valueType, ctx, {
12142
+ const valueSchema = process(def.valueType, ctx, {
12137
12143
  ...params,
12138
12144
  path: [...params.path, "patternProperties", "*"]
12139
12145
  });
@@ -12143,12 +12149,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
12143
12149
  }
12144
12150
  } else {
12145
12151
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
12146
- json2.propertyNames = process2(def.keyType, ctx, {
12152
+ json2.propertyNames = process(def.keyType, ctx, {
12147
12153
  ...params,
12148
12154
  path: [...params.path, "propertyNames"]
12149
12155
  });
12150
12156
  }
12151
- json2.additionalProperties = process2(def.valueType, ctx, {
12157
+ json2.additionalProperties = process(def.valueType, ctx, {
12152
12158
  ...params,
12153
12159
  path: [...params.path, "additionalProperties"]
12154
12160
  });
@@ -12163,7 +12169,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12163
12169
  };
12164
12170
  var nullableProcessor = (schema, ctx, json2, params) => {
12165
12171
  const def = schema._zod.def;
12166
- const inner = process2(def.innerType, ctx, params);
12172
+ const inner = process(def.innerType, ctx, params);
12167
12173
  const seen = ctx.seen.get(schema);
12168
12174
  if (ctx.target === "openapi-3.0") {
12169
12175
  seen.ref = def.innerType;
@@ -12174,20 +12180,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
12174
12180
  };
12175
12181
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
12176
12182
  const def = schema._zod.def;
12177
- process2(def.innerType, ctx, params);
12183
+ process(def.innerType, ctx, params);
12178
12184
  const seen = ctx.seen.get(schema);
12179
12185
  seen.ref = def.innerType;
12180
12186
  };
12181
12187
  var defaultProcessor = (schema, ctx, json2, params) => {
12182
12188
  const def = schema._zod.def;
12183
- process2(def.innerType, ctx, params);
12189
+ process(def.innerType, ctx, params);
12184
12190
  const seen = ctx.seen.get(schema);
12185
12191
  seen.ref = def.innerType;
12186
12192
  json2.default = JSON.parse(JSON.stringify(def.defaultValue));
12187
12193
  };
12188
12194
  var prefaultProcessor = (schema, ctx, json2, params) => {
12189
12195
  const def = schema._zod.def;
12190
- process2(def.innerType, ctx, params);
12196
+ process(def.innerType, ctx, params);
12191
12197
  const seen = ctx.seen.get(schema);
12192
12198
  seen.ref = def.innerType;
12193
12199
  if (ctx.io === "input")
@@ -12195,7 +12201,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
12195
12201
  };
12196
12202
  var catchProcessor = (schema, ctx, json2, params) => {
12197
12203
  const def = schema._zod.def;
12198
- process2(def.innerType, ctx, params);
12204
+ process(def.innerType, ctx, params);
12199
12205
  const seen = ctx.seen.get(schema);
12200
12206
  seen.ref = def.innerType;
12201
12207
  let catchValue;
@@ -12210,32 +12216,32 @@ var pipeProcessor = (schema, ctx, _json, params) => {
12210
12216
  const def = schema._zod.def;
12211
12217
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
12212
12218
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
12213
- process2(innerType, ctx, params);
12219
+ process(innerType, ctx, params);
12214
12220
  const seen = ctx.seen.get(schema);
12215
12221
  seen.ref = innerType;
12216
12222
  };
12217
12223
  var readonlyProcessor = (schema, ctx, json2, params) => {
12218
12224
  const def = schema._zod.def;
12219
- process2(def.innerType, ctx, params);
12225
+ process(def.innerType, ctx, params);
12220
12226
  const seen = ctx.seen.get(schema);
12221
12227
  seen.ref = def.innerType;
12222
12228
  json2.readOnly = true;
12223
12229
  };
12224
12230
  var promiseProcessor = (schema, ctx, _json, params) => {
12225
12231
  const def = schema._zod.def;
12226
- process2(def.innerType, ctx, params);
12232
+ process(def.innerType, ctx, params);
12227
12233
  const seen = ctx.seen.get(schema);
12228
12234
  seen.ref = def.innerType;
12229
12235
  };
12230
12236
  var optionalProcessor = (schema, ctx, _json, params) => {
12231
12237
  const def = schema._zod.def;
12232
- process2(def.innerType, ctx, params);
12238
+ process(def.innerType, ctx, params);
12233
12239
  const seen = ctx.seen.get(schema);
12234
12240
  seen.ref = def.innerType;
12235
12241
  };
12236
12242
  var lazyProcessor = (schema, ctx, _json, params) => {
12237
12243
  const innerType = schema._zod.innerType;
12238
- process2(innerType, ctx, params);
12244
+ process(innerType, ctx, params);
12239
12245
  const seen = ctx.seen.get(schema);
12240
12246
  seen.ref = innerType;
12241
12247
  };
@@ -12287,7 +12293,7 @@ function toJSONSchema(input, params) {
12287
12293
  const defs = {};
12288
12294
  for (const entry of registry2._idmap.entries()) {
12289
12295
  const [_, schema] = entry;
12290
- process2(schema, ctx2);
12296
+ process(schema, ctx2);
12291
12297
  }
12292
12298
  const schemas = {};
12293
12299
  const external = {
@@ -12310,7 +12316,7 @@ function toJSONSchema(input, params) {
12310
12316
  return { schemas };
12311
12317
  }
12312
12318
  const ctx = initializeContext({ ...params, processors: allProcessors });
12313
- process2(input, ctx);
12319
+ process(input, ctx);
12314
12320
  extractDefs(ctx, input);
12315
12321
  return finalize(ctx, input);
12316
12322
  }
@@ -12368,7 +12374,7 @@ var JSONSchemaGenerator = class {
12368
12374
  * This must be called before emit().
12369
12375
  */
12370
12376
  process(schema, _params = { path: [], schemaPath: [] }) {
12371
- return process2(schema, this.ctx, _params);
12377
+ return process(schema, this.ctx, _params);
12372
12378
  }
12373
12379
  /**
12374
12380
  * Emit the final JSON Schema after processing.
@@ -14536,14 +14542,27 @@ var EXIT_BY_CODE = {
14536
14542
  POLICY_REFUSED: 3,
14537
14543
  PAYMENT_FAILED: 4,
14538
14544
  RESOURCE_NOT_FOUND: 1,
14539
- LOOKUP_NOT_FOUND: 1,
14545
+ SEARCH_NOT_FOUND: 1,
14540
14546
  RATE_LIMITED: 1,
14541
14547
  // A publish awaiting confirmation or hard-blocked is understood-but-refused (3),
14542
14548
  // the same posture as POLICY_REFUSED; a write that failed after approval is a
14543
14549
  // settlement-class failure (4), like PAYMENT_FAILED.
14544
14550
  NEEDS_CONFIRMATION: 3,
14545
14551
  PUBLISH_BLOCKED: 3,
14546
- PUBLISH_FAILED: 4
14552
+ PUBLISH_FAILED: 4,
14553
+ // A send that reverted or stalled AFTER the human approved it and it was
14554
+ // broadcast: the post-decision failure class (4), like PAYMENT_FAILED.
14555
+ SEND_FAILED: 4,
14556
+ // A delete the operator confirmed and the server then refused: same class.
14557
+ DELETE_FAILED: 4,
14558
+ UPDATE_FAILED: 1,
14559
+ // Refused BEFORE any signature existed: the Bazaar lane's fail-closed check.
14560
+ REGISTRY_MISMATCH: 3,
14561
+ // The seller's 402 challenge does not fit this process's header limit, so the
14562
+ // terms could not be read and nothing was sent. Understood and refused (3),
14563
+ // not a transport failure: the connection was fine and a retry changes
14564
+ // nothing without an operator raising `--max-http-header-size`.
14565
+ CHALLENGE_TOO_LARGE: 3
14547
14566
  };
14548
14567
  function exitCodeFor(code) {
14549
14568
  return EXIT_BY_CODE[code];
@@ -14563,34 +14582,644 @@ var CliError = class extends Error {
14563
14582
  }
14564
14583
  };
14565
14584
 
14566
- // src/lib/paths.ts
14567
- import { homedir } from "os";
14568
- import { join } from "path";
14569
- function dataDir(env = process.env) {
14570
- const override = env.TENJIN_DATA_DIR;
14571
- if (override !== void 0 && override.length > 0) return override;
14572
- return join(homedir(), ".tenjin");
14585
+ // src/lib/production-origin.ts
14586
+ var PRODUCTION_ORIGIN = "https://tenjin.sh";
14587
+ var PRODUCTION_HOST = new URL(PRODUCTION_ORIGIN).host;
14588
+ var KNOWN_DEPLOYMENT_ORIGINS = /* @__PURE__ */ new Set([
14589
+ PRODUCTION_ORIGIN,
14590
+ "https://tenjin.blog"
14591
+ ]);
14592
+ function isSameDeployment(a, b) {
14593
+ if (a === b) return true;
14594
+ return KNOWN_DEPLOYMENT_ORIGINS.has(a) && KNOWN_DEPLOYMENT_ORIGINS.has(b);
14595
+ }
14596
+ function knownDeploymentOrigins() {
14597
+ return [...KNOWN_DEPLOYMENT_ORIGINS];
14598
+ }
14599
+
14600
+ // src/lib/config.ts
14601
+ import { readFile } from "node:fs/promises";
14602
+
14603
+ // src/adapters/types.ts
14604
+ var HARNESSES = ["claude", "codex"];
14605
+
14606
+ // src/lib/config.ts
14607
+ var atomicString = external_exports.string().regex(/^\d+$/, "expected an atomic USDC integer string");
14608
+ var PublishModeSchema = external_exports.enum(["review", "auto", "full-auto"]);
14609
+ var AckServerWarningsSchema = external_exports.enum(["mode", "on", "off"]);
14610
+ function parseAckServerWarnings(value, keyName) {
14611
+ const parsed = AckServerWarningsSchema.safeParse(value);
14612
+ if (parsed.success) return parsed.data;
14613
+ throw new CliError("USAGE", `Invalid ${keyName} ${JSON.stringify(value)}`, {
14614
+ fix: 'Use "mode", "on", or "off".'
14615
+ });
14616
+ }
14617
+ var PublishConfigSchema = external_exports.object({
14618
+ mode: PublishModeSchema,
14619
+ defaultPrice: atomicString,
14620
+ ackServerWarnings: AckServerWarningsSchema
14621
+ });
14622
+ var HOOK_ARMS = [
14623
+ "prompt",
14624
+ "web-search",
14625
+ "web-fetch",
14626
+ "subagent",
14627
+ "failure",
14628
+ "publish",
14629
+ "primer"
14630
+ ];
14631
+ var HooksConfigSchema = external_exports.object({
14632
+ prompt: external_exports.boolean(),
14633
+ "web-search": external_exports.boolean(),
14634
+ "web-fetch": external_exports.boolean(),
14635
+ subagent: external_exports.boolean(),
14636
+ failure: external_exports.boolean(),
14637
+ publish: external_exports.boolean(),
14638
+ primer: external_exports.boolean()
14639
+ });
14640
+ var ROUTER_CONTEXTS = ["session", "turn"];
14641
+ var RouterLayerSchema = external_exports.object({
14642
+ enabled: external_exports.boolean().optional(),
14643
+ context: external_exports.enum(ROUTER_CONTEXTS).optional()
14644
+ });
14645
+ var RouterConfigSchema = RouterLayerSchema.required();
14646
+ function parseRouterLayer(json2, path) {
14647
+ if (json2 === null || typeof json2 !== "object" || Array.isArray(json2)) {
14648
+ throw new CliError("CONFIG_INVALID", `Config at ${path} is not a JSON object`, {
14649
+ fix: `Fix ${path}, or delete it.`
14650
+ });
14651
+ }
14652
+ const parsed = RouterLayerSchema.safeParse(json2.router ?? {});
14653
+ if (!parsed.success) {
14654
+ throw new CliError("CONFIG_INVALID", `Config at ${path} has an invalid router block`, {
14655
+ fix: `Use router.enabled true|false and router.context "session"|"turn" in ${path}, or delete it.`,
14656
+ details: parsed.error.issues
14657
+ });
14658
+ }
14659
+ const { enabled, context } = parsed.data;
14660
+ return {
14661
+ ...enabled !== void 0 ? { enabled } : {},
14662
+ ...context !== void 0 ? { context } : {}
14663
+ };
14664
+ }
14665
+ var UpdateModeSchema = external_exports.enum(["nudge", "off"]);
14666
+ var positiveInt = external_exports.number().int().positive();
14667
+ var LoopConfigSchema = external_exports.object({
14668
+ human_wait_ms: positiveInt,
14669
+ tool_wait_ms: positiveInt,
14670
+ idle_exit_min: positiveInt,
14671
+ port: external_exports.number().int().min(0).max(65535).nullable()
14672
+ });
14673
+ var PublicFallbackSchema = external_exports.enum(["on", "off"]);
14674
+ var TeamConfigSchema = external_exports.object({ publicFallback: PublicFallbackSchema });
14675
+ var ExperimentalConfigSchema = external_exports.object({ bazaar: PublicFallbackSchema });
14676
+ function parsePublicFallbackFlag(value, keyName) {
14677
+ const parsed = PublicFallbackSchema.safeParse(value);
14678
+ if (parsed.success) return parsed.data;
14679
+ throw new CliError("USAGE", `Invalid ${keyName}: ${JSON.stringify(value)}`, {
14680
+ fix: 'Use "on" or "off".'
14681
+ });
14682
+ }
14683
+ function parseLoopValue(key, value) {
14684
+ const field = key.slice("loop.".length);
14685
+ if (field === "port" && (value === "null" || value === "auto")) return null;
14686
+ const n = /^\d+$/.test(value.trim()) ? Number(value.trim()) : NaN;
14687
+ const parsed = LoopConfigSchema.shape[field].safeParse(n);
14688
+ if (parsed.success) return parsed.data;
14689
+ throw new CliError("USAGE", `Invalid ${key}: ${JSON.stringify(value)}`, {
14690
+ fix: field === "port" ? 'Use an integer from 0 to 65535, or "null" to derive one from the data dir.' : "Use a positive integer."
14691
+ });
14692
+ }
14693
+ var UpdateConfigSchema = external_exports.object({
14694
+ mode: UpdateModeSchema
14695
+ });
14696
+ function parseUpdateModeFlag(value, flagName) {
14697
+ const parsed = UpdateModeSchema.safeParse(value);
14698
+ if (parsed.success) return parsed.data;
14699
+ throw new CliError("USAGE", `Invalid ${flagName} ${JSON.stringify(value)}`, {
14700
+ fix: 'Use "nudge" or "off".'
14701
+ });
14702
+ }
14703
+ var InstallConfigSchema = external_exports.object({
14704
+ harness: external_exports.array(external_exports.enum(HARNESSES)),
14705
+ /**
14706
+ * The EXACT rule strings still pending the last time an install explicitly
14707
+ * declined the free-verb allowlist (`--no-grant`), so `--refresh`
14708
+ * can subtract them from what it would
14709
+ * otherwise report as pending instead of recomputing from the settings file
14710
+ * and nagging about a settled "no" on every refresh (tenjin-agent#234).
14711
+ *
14712
+ * A LIST, NOT A FLAG, on purpose: a boolean has no way to say "these were
14713
+ * declined" without also silencing every rule a LATER version might add, so a
14714
+ * genuinely new suggestion would never be reported again either. Per-rule
14715
+ * suppression means only the rules that were actually offered and refused
14716
+ * stay quiet; a new one still surfaces.
14717
+ *
14718
+ * Cleared back to `[]` the next time an install actually wires the allowlist,
14719
+ * or finds it already fully satisfied, so a later legitimate grant (manual or
14720
+ * otherwise) is never shadowed by a stale decline.
14721
+ */
14722
+ grantDeclined: external_exports.array(external_exports.string()),
14723
+ /**
14724
+ * Absolute directories a `tenjin install --project` wired, so `tenjin update`
14725
+ * can refresh them. It spawns `install --refresh` from the HOME directory,
14726
+ * which is the one place a project install can never be found by looking
14727
+ * around: without this list a project-only machine refreshed nothing and
14728
+ * reported success while its hooks stayed on the old build.
14729
+ *
14730
+ * A LIST, because one machine can wire several projects, and entries are
14731
+ * dropped by `tenjin uninstall --project` and by any refresh that finds the
14732
+ * project's settings file no longer carries our entries.
14733
+ */
14734
+ routerProjects: external_exports.array(external_exports.string())
14735
+ });
14736
+ var STORED_INSTALL_HARNESSES = [...HARNESSES, "shared"];
14737
+ function resolveInstallHarness(value) {
14738
+ const normalized = new Set(value?.map((harness) => harness === "shared" ? "codex" : harness));
14739
+ return HARNESSES.filter((harness) => normalized.has(harness));
14740
+ }
14741
+ var RawInstallHarnessSchema = external_exports.array(external_exports.enum(STORED_INSTALL_HARNESSES)).transform(resolveInstallHarness);
14742
+ var ConfigSchema = external_exports.object({
14743
+ maxAutoSpend: atomicString,
14744
+ sessionBudget: external_exports.union([atomicString, external_exports.literal("none")]),
14745
+ /**
14746
+ * Hard per-send cap for `tenjin wallet send`, NOT satisfiable by --yes or a prompt
14747
+ * (the spend-policy posture): an atomic amount caps each send, "0" disables
14748
+ * the verb entirely, and "none" = explicitly uncapped (send exists to drain
14749
+ * the wallet, but uncapped is an opt-in, never a default). The key has NO
14750
+ * usable default: absent from config.json, `tenjin wallet send` refuses until it is
14751
+ * set (see resolveSendMaxAmount). Client-enforced like every spend key (see
14752
+ * the note above).
14753
+ */
14754
+ sendMaxAmount: external_exports.union([external_exports.literal("none"), atomicString]),
14755
+ allowlistCreators: external_exports.array(external_exports.string()),
14756
+ baseUrl: external_exports.url(),
14757
+ /**
14758
+ * The PUBLIC marketplace, consume-only, and the second shelf a team-mode
14759
+ * lookup falls through to. Distinct from `baseUrl` because in team mode
14760
+ * `baseUrl` is the team's own deployment: `publish`, `read` and the first leg
14761
+ * of every search go there, and this is the shelf that still gets asked when
14762
+ * the team's own has nothing. In public mode the two are the same origin and
14763
+ * nothing falls through.
14764
+ */
14765
+ publicShelfUrl: external_exports.url(),
14766
+ /**
14767
+ * The team shelf's Vercel "Protection Bypass for Automation" secret, and the
14768
+ * ONE key that decides which mode this CLI is in: empty (the default) is
14769
+ * public mode, byte-for-byte what it always did; non-empty is team mode.
14770
+ *
14771
+ * It is a DOOR KEY, not a credential of the operator's: it gets a request past
14772
+ * Deployment Protection on the team's preview deployment and authenticates
14773
+ * nobody. Stored in plain config.json alongside everything else for exactly
14774
+ * that reason — anything that can read this file can already read the wallet's
14775
+ * keystore path and rewrite `baseUrl`. It is redacted from `config get` and
14776
+ * `config list` all the same, because those outputs are pasted into issues.
14777
+ *
14778
+ * Sent ONLY to `baseUrl`'s origin; see lib/http.ts's `bypass` option, which
14779
+ * derives that from the request URL rather than from the caller's intent.
14780
+ */
14781
+ shelfBypassSecret: external_exports.string(),
14782
+ rpcUrl: external_exports.url(),
14783
+ /**
14784
+ * Evaluation-cohort opt-in (spec 09 §3): when true, search sends
14785
+ * X-Tenjin-Eval-Cohort: 1 and the server stores the generalized question for
14786
+ * 90 days. Off by default; no query text is retained server-side without it.
14787
+ */
14788
+ evalCohort: external_exports.boolean(),
14789
+ /** x402 discovery registries (facilitator base URLs) `discover` queries and
14790
+ * the Bazaar pay lane verifies against. */
14791
+ bazaarRegistries: external_exports.array(external_exports.url()),
14792
+ publish: PublishConfigSchema,
14793
+ install: InstallConfigSchema,
14794
+ hooks: HooksConfigSchema,
14795
+ update: UpdateConfigSchema,
14796
+ loop: LoopConfigSchema,
14797
+ team: TeamConfigSchema,
14798
+ router: RouterConfigSchema,
14799
+ experimental: ExperimentalConfigSchema
14800
+ });
14801
+ var RawInstallConfigSchema = InstallConfigSchema.partial().extend({
14802
+ harness: RawInstallHarnessSchema.optional(),
14803
+ grantDeclined: external_exports.array(external_exports.string()).optional()
14804
+ }).passthrough();
14805
+ var RawConfigSchema = ConfigSchema.partial().extend({
14806
+ publish: PublishConfigSchema.partial().passthrough().optional(),
14807
+ install: RawInstallConfigSchema.optional(),
14808
+ hooks: HooksConfigSchema.partial().passthrough().optional(),
14809
+ update: UpdateConfigSchema.partial().passthrough().optional(),
14810
+ loop: LoopConfigSchema.partial().passthrough().optional(),
14811
+ team: TeamConfigSchema.partial().passthrough().optional(),
14812
+ router: RouterLayerSchema.passthrough().optional(),
14813
+ experimental: ExperimentalConfigSchema.partial().passthrough().optional()
14814
+ }).passthrough();
14815
+ function resolveGrantDeclined(value) {
14816
+ return value ?? [];
14817
+ }
14818
+ var SEND_MAX_UNSET = "unset";
14819
+ var DEFAULT_BAZAAR_REGISTRIES = [
14820
+ "https://api.cdp.coinbase.com/platform/v2/x402",
14821
+ "https://facilitator.ultravioletadao.xyz",
14822
+ "https://facilitator.payai.network"
14823
+ ];
14824
+ var DEFAULT_MAX_AUTO_SPEND = "250000";
14825
+ var DEFAULT_SESSION_BUDGET = "5000000";
14826
+ var MAX_AUTO_SPEND_FLOOR_ATOMIC = 250000n;
14827
+ var MAX_AUTO_SPEND_FLOOR_WHY = "The $0.25 minimum is the routing deposit: below it, routing cannot pay at all. To stop automatic payments, turn the router off with `tenjin config set router.enabled false`.";
14828
+ var CONFIG_DEFAULTS = {
14829
+ maxAutoSpend: DEFAULT_MAX_AUTO_SPEND,
14830
+ sessionBudget: DEFAULT_SESSION_BUDGET,
14831
+ // A type placeholder only, never honored: Config requires every key (and
14832
+ // CONFIG_KEYS derives from these). resolveSendMaxAmount never reads it — an
14833
+ // absent key resolves to SEND_MAX_UNSET and `tenjin wallet send` refuses until the
14834
+ // cap is set. '0' (send disabled) rather than 'none' (uncapped) so that if a
14835
+ // future caller ever DOES read the cap through loadConfig/fileOrDefault, the
14836
+ // leak fails closed instead of silently running uncapped.
14837
+ sendMaxAmount: "0",
14838
+ allowlistCreators: [],
14839
+ baseUrl: PRODUCTION_ORIGIN,
14840
+ publicShelfUrl: PRODUCTION_ORIGIN,
14841
+ // Empty = public mode. Setting it is the whole of "turn on team mode".
14842
+ shelfBypassSecret: "",
14843
+ rpcUrl: DEFAULT_RPC_URL,
14844
+ evalCohort: false,
14845
+ bazaarRegistries: DEFAULT_BAZAAR_REGISTRIES,
14846
+ publish: { mode: "review", defaultPrice: "100000", ackServerWarnings: "mode" },
14847
+ install: { harness: [], grantDeclined: [], routerProjects: [] },
14848
+ // Every hook is on out of the box: a vanilla install turns the whole loop on,
14849
+ // and the disclosure and the undo ride the install output. `false` leaves the
14850
+ // registered entries inert without touching settings.json, so any of these is
14851
+ // one `config set` away in either direction.
14852
+ hooks: {
14853
+ prompt: true,
14854
+ "web-search": true,
14855
+ "web-fetch": true,
14856
+ subagent: true,
14857
+ failure: true,
14858
+ publish: true,
14859
+ primer: true
14860
+ },
14861
+ update: { mode: "nudge" },
14862
+ loop: {
14863
+ human_wait_ms: 2500,
14864
+ tool_wait_ms: 4e3,
14865
+ idle_exit_min: 30,
14866
+ port: null
14867
+ },
14868
+ team: { publicFallback: "on" },
14869
+ router: { enabled: true, context: "session" },
14870
+ experimental: { bazaar: "off" }
14871
+ };
14872
+ var NESTED_CONFIG_KEYS = /* @__PURE__ */ new Set([
14873
+ "publish",
14874
+ "install",
14875
+ "hooks",
14876
+ "update",
14877
+ "loop",
14878
+ "team",
14879
+ "router",
14880
+ "experimental"
14881
+ ]);
14882
+ var CONFIG_KEYS = Object.keys(CONFIG_DEFAULTS).filter(
14883
+ (key) => !NESTED_CONFIG_KEYS.has(key)
14884
+ );
14885
+ var PUBLISH_CONFIG_KEYS = [
14886
+ "publish.mode",
14887
+ "publish.defaultPrice",
14888
+ "publish.ackServerWarnings"
14889
+ ];
14890
+ var HOOKS_CONFIG_KEYS = HOOK_ARMS.map(
14891
+ (arm) => `hooks.${arm}`
14892
+ );
14893
+ var UPDATE_CONFIG_KEYS = ["update.mode"];
14894
+ var LOOP_CONFIG_KEYS = [
14895
+ "loop.human_wait_ms",
14896
+ "loop.tool_wait_ms",
14897
+ "loop.idle_exit_min",
14898
+ "loop.port"
14899
+ ];
14900
+ var TEAM_CONFIG_KEYS = ["team.publicFallback"];
14901
+ var EXPERIMENTAL_CONFIG_KEYS = ["experimental.bazaar"];
14902
+ var ROUTER_CONFIG_KEYS = ["router.enabled", "router.context"];
14903
+ var RETIRED_PAYMENT_KEYS = ["bazaarPay", "confirm"];
14904
+ var RETIRED_PAYMENT_GUIDANCE = "Retired payment settings no longer control payments. Use router.enabled, maxAutoSpend and sessionBudget for automatic routing; manual pay always requires consent. Run tenjin install to remove retired keys.";
14905
+ function retiredPaymentKeys(raw) {
14906
+ return RETIRED_PAYMENT_KEYS.filter((key) => Object.hasOwn(raw, key));
14907
+ }
14908
+ async function loadRawConfig(dir) {
14909
+ const path = configPath(dir);
14910
+ let raw;
14911
+ try {
14912
+ raw = await readFile(path, "utf8");
14913
+ } catch (err) {
14914
+ if (isNotFound(err)) return {};
14915
+ throw new CliError("CONFIG_INVALID", `Could not read config at ${path}`, {
14916
+ fix: `Check file permissions on ${path}.`,
14917
+ cause: err
14918
+ });
14919
+ }
14920
+ let json2;
14921
+ try {
14922
+ json2 = JSON.parse(raw);
14923
+ } catch (err) {
14924
+ throw new CliError("CONFIG_INVALID", `Config at ${path} is not valid JSON`, {
14925
+ fix: `Fix the JSON syntax in ${path}, or delete it to restore defaults.`,
14926
+ cause: err
14927
+ });
14928
+ }
14929
+ const parsed = RawConfigSchema.safeParse(json2);
14930
+ if (!parsed.success) {
14931
+ throw new CliError("CONFIG_INVALID", `Config at ${path} is invalid`, {
14932
+ fix: `Correct the reported keys in ${path}, or delete it to restore defaults.`,
14933
+ details: parsed.error.issues
14934
+ });
14935
+ }
14936
+ return parsed.data;
14573
14937
  }
14574
- function configPath(dir = dataDir()) {
14575
- return join(dir, "config.json");
14938
+ async function loadConfig(dir) {
14939
+ const raw = { ...await loadRawConfig(dir) };
14940
+ for (const key of retiredPaymentKeys(raw)) delete raw[key];
14941
+ return {
14942
+ ...CONFIG_DEFAULTS,
14943
+ ...raw,
14944
+ publish: {
14945
+ mode: raw.publish?.mode ?? CONFIG_DEFAULTS.publish.mode,
14946
+ defaultPrice: raw.publish?.defaultPrice ?? CONFIG_DEFAULTS.publish.defaultPrice,
14947
+ ackServerWarnings: raw.publish?.ackServerWarnings ?? CONFIG_DEFAULTS.publish.ackServerWarnings
14948
+ },
14949
+ install: {
14950
+ harness: raw.install?.harness ?? CONFIG_DEFAULTS.install.harness,
14951
+ routerProjects: raw.install?.routerProjects ?? CONFIG_DEFAULTS.install.routerProjects,
14952
+ grantDeclined: resolveGrantDeclined(raw.install?.grantDeclined)
14953
+ },
14954
+ hooks: resolveHooksConfig(raw),
14955
+ update: { mode: raw.update?.mode ?? CONFIG_DEFAULTS.update.mode },
14956
+ loop: resolveLoopConfig(raw),
14957
+ team: { publicFallback: raw.team?.publicFallback ?? CONFIG_DEFAULTS.team.publicFallback },
14958
+ router: {
14959
+ enabled: raw.router?.enabled ?? CONFIG_DEFAULTS.router.enabled,
14960
+ context: raw.router?.context ?? CONFIG_DEFAULTS.router.context
14961
+ },
14962
+ experimental: {
14963
+ bazaar: raw.experimental?.bazaar ?? CONFIG_DEFAULTS.experimental.bazaar
14964
+ }
14965
+ };
14966
+ }
14967
+ function resolveLoopConfig(raw) {
14968
+ const file2 = raw.loop ?? {};
14969
+ return {
14970
+ human_wait_ms: file2.human_wait_ms ?? CONFIG_DEFAULTS.loop.human_wait_ms,
14971
+ tool_wait_ms: file2.tool_wait_ms ?? CONFIG_DEFAULTS.loop.tool_wait_ms,
14972
+ idle_exit_min: file2.idle_exit_min ?? CONFIG_DEFAULTS.loop.idle_exit_min,
14973
+ port: file2.port === void 0 ? CONFIG_DEFAULTS.loop.port : file2.port
14974
+ };
14975
+ }
14976
+ function resolveSettings(input) {
14977
+ const { config: config2, flags, env, project } = input;
14978
+ return {
14979
+ maxAutoSpend: fileOrDefault("maxAutoSpend", config2),
14980
+ sessionBudget: fileOrDefault("sessionBudget", config2),
14981
+ sendMaxAmount: resolveSendMaxAmount(config2),
14982
+ allowlistCreators: fileOrDefault("allowlistCreators", config2),
14983
+ baseUrl: resolveBaseUrl(config2, flags, env),
14984
+ publicShelfUrl: fileOrDefault("publicShelfUrl", config2),
14985
+ shelfBypassSecret: fileOrDefault("shelfBypassSecret", config2),
14986
+ rpcUrl: fileOrDefault("rpcUrl", config2),
14987
+ evalCohort: fileOrDefault("evalCohort", config2),
14988
+ bazaarRegistries: fileOrDefault("bazaarRegistries", config2),
14989
+ publishMode: resolvePublishMode({ config: config2, project, env }),
14990
+ publishDefaultPrice: resolvePublishDefaultPrice({ config: config2, project }),
14991
+ publishAckServerWarnings: resolveAckServerWarnings(config2),
14992
+ hooks: resolveHookSettings(config2),
14993
+ updateMode: resolveUpdateMode(config2),
14994
+ loop: resolveLoopSettings(config2),
14995
+ teamPublicFallback: resolveTeamPublicFallback(config2),
14996
+ experimentalBazaar: resolveExperimentalBazaar(config2)
14997
+ };
14998
+ }
14999
+ function resolveLoopSettings(config2) {
15000
+ const file2 = config2.loop ?? {};
15001
+ const one = (key) => {
15002
+ const fromFile = file2[key];
15003
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15004
+ return { value: CONFIG_DEFAULTS.loop[key], source: "default" };
15005
+ };
15006
+ return {
15007
+ human_wait_ms: one("human_wait_ms"),
15008
+ tool_wait_ms: one("tool_wait_ms"),
15009
+ idle_exit_min: one("idle_exit_min"),
15010
+ port: one("port")
15011
+ };
15012
+ }
15013
+ function resolveExperimentalBazaar(config2) {
15014
+ const fromFile = config2.experimental?.bazaar;
15015
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15016
+ return { value: CONFIG_DEFAULTS.experimental.bazaar, source: "default" };
15017
+ }
15018
+ function resolveTeamPublicFallback(config2) {
15019
+ const fromFile = config2.team?.publicFallback;
15020
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15021
+ return { value: CONFIG_DEFAULTS.team.publicFallback, source: "default" };
15022
+ }
15023
+ function resolveAckServerWarnings(config2) {
15024
+ const fromFile = config2.publish?.ackServerWarnings;
15025
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15026
+ return { value: CONFIG_DEFAULTS.publish.ackServerWarnings, source: "default" };
15027
+ }
15028
+ function resolveUpdateMode(config2) {
15029
+ const fromFile = config2.update?.mode;
15030
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15031
+ return { value: CONFIG_DEFAULTS.update.mode, source: "default" };
15032
+ }
15033
+ function resolveHook(config2, arm) {
15034
+ const fromFile = config2.hooks?.[arm];
15035
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15036
+ return { value: CONFIG_DEFAULTS.hooks[arm], source: "default" };
15037
+ }
15038
+ function resolveHookSettings(config2) {
15039
+ return Object.fromEntries(
15040
+ HOOK_ARMS.map((arm) => [arm, resolveHook(config2, arm)])
15041
+ );
15042
+ }
15043
+ function resolveHooksConfig(raw) {
15044
+ return Object.fromEntries(
15045
+ HOOK_ARMS.map((arm) => [arm, raw.hooks?.[arm] ?? CONFIG_DEFAULTS.hooks[arm]])
15046
+ );
15047
+ }
15048
+ var FULL_AUTO_DOWNGRADE_WARNING = 'Ignoring publish.mode "full-auto" from a committed .tenjin.json (cloning a repo must not enable auto-publish); using "auto". Add .tenjin.json to .gitignore to opt in.';
15049
+ function coercePublishMode(raw) {
15050
+ if (raw === void 0 || raw.length === 0) return void 0;
15051
+ const parsed = PublishModeSchema.safeParse(raw);
15052
+ return parsed.success ? parsed.data : void 0;
15053
+ }
15054
+ function resolvePublishMode(input) {
15055
+ const { config: config2, project, env, flag } = input;
15056
+ let winner = { value: CONFIG_DEFAULTS.publish.mode, source: "default" };
15057
+ const fromFile = config2.publish?.mode;
15058
+ if (fromFile !== void 0) winner = { value: fromFile, source: "file" };
15059
+ if (project !== void 0 && project.publish?.mode !== void 0) {
15060
+ const fromProject = project.publish.mode;
15061
+ if (fromProject === "full-auto" && !project.gitignored) {
15062
+ winner = { value: "auto", source: "project", downgradedWarning: FULL_AUTO_DOWNGRADE_WARNING };
15063
+ } else {
15064
+ winner = { value: fromProject, source: "project" };
15065
+ }
15066
+ }
15067
+ const fromEnv = coercePublishMode(env.TENJIN_PUBLISH_MODE);
15068
+ if (fromEnv !== void 0) winner = { value: fromEnv, source: "env" };
15069
+ const fromFlag = coercePublishMode(flag);
15070
+ if (fromFlag !== void 0) winner = { value: fromFlag, source: "flag" };
15071
+ return winner;
15072
+ }
15073
+ function resolvePublishDefaultPrice(input) {
15074
+ const { config: config2, project } = input;
15075
+ let result = {
15076
+ value: CONFIG_DEFAULTS.publish.defaultPrice,
15077
+ source: "default"
15078
+ };
15079
+ if (config2.publish?.defaultPrice !== void 0) {
15080
+ result = { value: config2.publish.defaultPrice, source: "file" };
15081
+ }
15082
+ if (project?.publish?.defaultPrice !== void 0) {
15083
+ result = { value: project.publish.defaultPrice, source: "project" };
15084
+ }
15085
+ return result;
15086
+ }
15087
+ function resolveSendMaxAmount(config2) {
15088
+ if (config2.sendMaxAmount !== void 0) return { value: config2.sendMaxAmount, source: "file" };
15089
+ return { value: SEND_MAX_UNSET, source: "default" };
15090
+ }
15091
+ function fileOrDefault(key, config2) {
15092
+ const fromFile = config2[key];
15093
+ if (fromFile !== void 0) return { value: fromFile, source: "file" };
15094
+ return { value: CONFIG_DEFAULTS[key], source: "default" };
15095
+ }
15096
+ function resolveBaseUrl(config2, flags, env) {
15097
+ if (flags.baseUrl !== void 0 && flags.baseUrl.length > 0) {
15098
+ return { value: flags.baseUrl, source: "flag" };
15099
+ }
15100
+ const fromEnv = env.TENJIN_BASE_URL;
15101
+ if (fromEnv !== void 0 && fromEnv.length > 0) {
15102
+ return { value: fromEnv, source: "env" };
15103
+ }
15104
+ if (config2.baseUrl !== void 0) return { value: config2.baseUrl, source: "file" };
15105
+ return { value: CONFIG_DEFAULTS.baseUrl, source: "default" };
15106
+ }
15107
+ function isNotFound(err) {
15108
+ return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
14576
15109
  }
14577
- function walletPath(dir = dataDir()) {
14578
- return join(dir, "wallet.json");
15110
+
15111
+ // src/lib/ids.ts
15112
+ var ATOMIC_RE = /^\d{1,39}$/;
15113
+
15114
+ // src/lib/money.ts
15115
+ var USDC_DECIMALS = 6;
15116
+ function parseUsdToAtomic(input) {
15117
+ const trimmed = input.trim();
15118
+ if (!/^\d+(\.\d+)?$/.test(trimmed)) {
15119
+ throw new CliError("USAGE", `Invalid USD amount: ${JSON.stringify(input)}`, {
15120
+ fix: "Pass a non-negative decimal like 0.25 or 5."
15121
+ });
15122
+ }
15123
+ const [whole, frac = ""] = trimmed.split(".");
15124
+ if (frac.length > USDC_DECIMALS) {
15125
+ throw new CliError(
15126
+ "USAGE",
15127
+ `USD amount ${JSON.stringify(input)} has more than 6 decimal places`,
15128
+ {
15129
+ fix: "USDC supports at most 6 decimal places (micro-dollars)."
15130
+ }
15131
+ );
15132
+ }
15133
+ const atomic = BigInt(`${whole}${frac.padEnd(USDC_DECIMALS, "0")}`);
15134
+ return atomic.toString();
15135
+ }
15136
+ function atomicToUsd(atomic) {
15137
+ const trimmed = atomic.trim();
15138
+ if (!/^\d+$/.test(trimmed)) {
15139
+ throw new CliError("INTERNAL", `Malformed atomic amount: ${JSON.stringify(atomic)}`);
15140
+ }
15141
+ const value = BigInt(trimmed);
15142
+ const base = 10n ** BigInt(USDC_DECIMALS);
15143
+ const whole = value / base;
15144
+ const frac = (value % base).toString().padStart(USDC_DECIMALS, "0").replace(/0+$/, "");
15145
+ return frac.length > 0 ? `${whole}.${frac}` : whole.toString();
14579
15146
  }
14580
- function sessionPath(dir = dataDir()) {
14581
- return join(dir, "session.json");
15147
+ function toMoney(atomic) {
15148
+ return { atomic, usd: atomicToUsd(atomic) };
14582
15149
  }
14583
- function passphraseBlobPath(dir = dataDir()) {
14584
- return join(dir, "passphrase.dpapi");
15150
+ function formatUsdDisplay(atomic) {
15151
+ const [whole, frac = ""] = atomicToUsd(atomic).split(".");
15152
+ return `${whole}.${frac.padEnd(2, "0")}`;
14585
15153
  }
14586
15154
 
14587
15155
  export {
15156
+ $constructor,
15157
+ defineLazy,
15158
+ clone,
15159
+ normalizeParams,
15160
+ parse,
15161
+ parseAsync,
15162
+ safeParse,
15163
+ safeParseAsync,
15164
+ $ZodType,
15165
+ $ZodObject,
15166
+ toJSONSchema,
15167
+ iso_exports,
15168
+ string2 as string,
15169
+ number2 as number,
15170
+ boolean2 as boolean,
15171
+ _null3 as _null,
15172
+ unknown,
15173
+ array,
15174
+ object,
15175
+ looseObject,
15176
+ union,
15177
+ discriminatedUnion,
15178
+ intersection,
15179
+ record,
15180
+ _enum2 as _enum,
15181
+ literal,
15182
+ ZodOptional,
15183
+ optional,
15184
+ custom,
15185
+ preprocess,
14588
15186
  external_exports,
14589
15187
  CliError,
14590
- dataDir,
14591
- configPath,
14592
- walletPath,
14593
- sessionPath,
14594
- passphraseBlobPath
14595
- };
14596
- //# sourceMappingURL=chunk-OYMYCW7J.js.map
15188
+ PRODUCTION_ORIGIN,
15189
+ isSameDeployment,
15190
+ knownDeploymentOrigins,
15191
+ HARNESSES,
15192
+ PublishModeSchema,
15193
+ parseAckServerWarnings,
15194
+ ROUTER_CONTEXTS,
15195
+ parseRouterLayer,
15196
+ parsePublicFallbackFlag,
15197
+ parseLoopValue,
15198
+ parseUpdateModeFlag,
15199
+ RawConfigSchema,
15200
+ SEND_MAX_UNSET,
15201
+ DEFAULT_MAX_AUTO_SPEND,
15202
+ DEFAULT_SESSION_BUDGET,
15203
+ MAX_AUTO_SPEND_FLOOR_ATOMIC,
15204
+ MAX_AUTO_SPEND_FLOOR_WHY,
15205
+ CONFIG_DEFAULTS,
15206
+ CONFIG_KEYS,
15207
+ PUBLISH_CONFIG_KEYS,
15208
+ HOOKS_CONFIG_KEYS,
15209
+ UPDATE_CONFIG_KEYS,
15210
+ LOOP_CONFIG_KEYS,
15211
+ TEAM_CONFIG_KEYS,
15212
+ EXPERIMENTAL_CONFIG_KEYS,
15213
+ ROUTER_CONFIG_KEYS,
15214
+ RETIRED_PAYMENT_GUIDANCE,
15215
+ retiredPaymentKeys,
15216
+ loadRawConfig,
15217
+ loadConfig,
15218
+ resolveSettings,
15219
+ resolveExperimentalBazaar,
15220
+ ATOMIC_RE,
15221
+ parseUsdToAtomic,
15222
+ toMoney,
15223
+ formatUsdDisplay
15224
+ };
15225
+ //# sourceMappingURL=chunk-WO5BJNIB.js.map