tenjin-cli 0.1.0-alpha.22 → 0.1.0-alpha.24

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 (94) hide show
  1. package/NOTICE.md +1 -1
  2. package/README.md +17 -19
  3. package/dist/{chunk-U5FFVIIF.js → chunk-EP5P2STS.js} +12 -12
  4. package/dist/chunk-EP5P2STS.js.map +1 -0
  5. package/dist/{chunk-F4IJQBGP.js → chunk-FFL5M5BC.js} +2 -2
  6. package/dist/{chunk-DHCOGDJB.js → chunk-GPLSNGKX.js} +4 -4
  7. package/dist/{chunk-CYEUVU3F.js → chunk-H5UR3GFJ.js} +98 -14
  8. package/dist/chunk-H5UR3GFJ.js.map +1 -0
  9. package/dist/{chunk-DA53QKTD.js → chunk-IIE65SJC.js} +4 -4
  10. package/dist/{chunk-2RMXTNLT.js → chunk-KC24CYGV.js} +4 -4
  11. package/dist/{chunk-XBYTP4SP.js → chunk-NSDZESRS.js} +3 -3
  12. package/dist/{chunk-UGLTSPXQ.js → chunk-O2WN732M.js} +2 -2
  13. package/dist/{chunk-SAN5PFTL.js → chunk-P22ZWXFX.js} +1 -1
  14. package/dist/{chunk-SAN5PFTL.js.map → chunk-P22ZWXFX.js.map} +1 -1
  15. package/dist/{chunk-2QYORQBF.js → chunk-P7LABKCW.js} +36 -1
  16. package/dist/{chunk-2QYORQBF.js.map → chunk-P7LABKCW.js.map} +1 -1
  17. package/dist/{chunk-AG4DWNHO.js → chunk-RCJ64OXH.js} +3 -3
  18. package/dist/{chunk-3Q3UBMVB.js → chunk-SQSKVKX6.js} +2 -2
  19. package/dist/{chunk-UHEMZEGW.js → chunk-TMLCEPCD.js} +2 -2
  20. package/dist/{chunk-UAT3Q7VF.js → chunk-UBOFYC6J.js} +35 -22
  21. package/dist/{chunk-UAT3Q7VF.js.map → chunk-UBOFYC6J.js.map} +1 -1
  22. package/dist/{chunk-GONDQ27X.js → chunk-UXSF7IFD.js} +3 -3
  23. package/dist/{chunk-UIOZRILX.js → chunk-W2ARIOAZ.js} +43 -27
  24. package/dist/chunk-W2ARIOAZ.js.map +1 -0
  25. package/dist/{chunk-NZYVSZNF.js → chunk-XRW4N23F.js} +4 -4
  26. package/dist/{chunk-NYJCBQL5.js → chunk-XZUGRTSV.js} +2 -2
  27. package/dist/{chunk-UFCN7NCE.js → chunk-YXLG7Q6Q.js} +22 -12
  28. package/dist/chunk-YXLG7Q6Q.js.map +1 -0
  29. package/dist/{chunk-TU3IK7KK.js → chunk-YZTIYDWU.js} +2 -2
  30. package/dist/{chunk-WXFVJPZD.js → chunk-ZMFDMALH.js} +2 -2
  31. package/dist/{chunk-B4GA3HAK.js → chunk-ZNZGBUV6.js} +11 -9
  32. package/dist/chunk-ZNZGBUV6.js.map +1 -0
  33. package/dist/{cli-5WM56Y7K.js → cli-GGNOQQEB.js} +28 -28
  34. package/dist/{cli-5WM56Y7K.js.map → cli-GGNOQQEB.js.map} +1 -1
  35. package/dist/{config-JBF5BZNO.js → config-XUUFICXK.js} +8 -8
  36. package/dist/{doctor-6KHBE77P.js → doctor-3LGF6CWI.js} +16 -16
  37. package/dist/{fund-GSFCXEF7.js → fund-3URFMBMN.js} +9 -9
  38. package/dist/{hook-command-UQZ4DVDL.js → hook-command-GMIDXVFK.js} +28 -10
  39. package/dist/{hook-command-UQZ4DVDL.js.map → hook-command-GMIDXVFK.js.map} +1 -1
  40. package/dist/index.js +3 -3
  41. package/dist/{install-TDYC22KI.js → install-FRTG4KHF.js} +11 -11
  42. package/dist/{install-identity-QS4UFF27.js → install-identity-WNXSYP6N.js} +6 -6
  43. package/dist/{install-wallet-T737X74E.js → install-wallet-MXLJJP3N.js} +9 -9
  44. package/dist/{mcp-JWOOSKLX.js → mcp-O2WJ3QBW.js} +37 -35
  45. package/dist/{mcp-JWOOSKLX.js.map → mcp-O2WJ3QBW.js.map} +1 -1
  46. package/dist/{pay-TDYQFSKY.js → pay-43WUYTW5.js} +11 -11
  47. package/dist/{payments-26NVMFR2.js → payments-7UTMMTIO.js} +6 -6
  48. package/dist/{send-4RUBQQKP.js → send-ALHG2RXT.js} +8 -8
  49. package/dist/{status-CEHZKHBU.js → status-CFPNHB6R.js} +5 -5
  50. package/dist/{status-line-QRAO3Y2E.js → status-line-FJ6N7MKJ.js} +4 -4
  51. package/dist/{status-line-wiring-XKUVI5UW.js → status-line-wiring-GXFNXHPE.js} +4 -4
  52. package/dist/{uninstall-SJ6R2W2M.js → uninstall-5P2GFYBY.js} +11 -11
  53. package/dist/{update-N2NZS3AA.js → update-QJ5YHJ7I.js} +5 -5
  54. package/dist/{wallet-IB2EFAUP.js → wallet-6OJPGNEV.js} +8 -8
  55. package/docs/agent-permissions.md +6 -6
  56. package/docs/safety-model.md +10 -23
  57. package/package.json +10 -8
  58. package/dist/chunk-B4GA3HAK.js.map +0 -1
  59. package/dist/chunk-CYEUVU3F.js.map +0 -1
  60. package/dist/chunk-U5FFVIIF.js.map +0 -1
  61. package/dist/chunk-UFCN7NCE.js.map +0 -1
  62. package/dist/chunk-UIOZRILX.js.map +0 -1
  63. package/dist/tenjin-daemon.mjs +0 -20601
  64. package/dist/tenjin-shim.mjs +0 -251
  65. package/dist/tenjin-vitest-reporter.mjs +0 -49
  66. /package/dist/{chunk-F4IJQBGP.js.map → chunk-FFL5M5BC.js.map} +0 -0
  67. /package/dist/{chunk-DHCOGDJB.js.map → chunk-GPLSNGKX.js.map} +0 -0
  68. /package/dist/{chunk-DA53QKTD.js.map → chunk-IIE65SJC.js.map} +0 -0
  69. /package/dist/{chunk-2RMXTNLT.js.map → chunk-KC24CYGV.js.map} +0 -0
  70. /package/dist/{chunk-XBYTP4SP.js.map → chunk-NSDZESRS.js.map} +0 -0
  71. /package/dist/{chunk-UGLTSPXQ.js.map → chunk-O2WN732M.js.map} +0 -0
  72. /package/dist/{chunk-AG4DWNHO.js.map → chunk-RCJ64OXH.js.map} +0 -0
  73. /package/dist/{chunk-3Q3UBMVB.js.map → chunk-SQSKVKX6.js.map} +0 -0
  74. /package/dist/{chunk-UHEMZEGW.js.map → chunk-TMLCEPCD.js.map} +0 -0
  75. /package/dist/{chunk-GONDQ27X.js.map → chunk-UXSF7IFD.js.map} +0 -0
  76. /package/dist/{chunk-NZYVSZNF.js.map → chunk-XRW4N23F.js.map} +0 -0
  77. /package/dist/{chunk-NYJCBQL5.js.map → chunk-XZUGRTSV.js.map} +0 -0
  78. /package/dist/{chunk-TU3IK7KK.js.map → chunk-YZTIYDWU.js.map} +0 -0
  79. /package/dist/{chunk-WXFVJPZD.js.map → chunk-ZMFDMALH.js.map} +0 -0
  80. /package/dist/{config-JBF5BZNO.js.map → config-XUUFICXK.js.map} +0 -0
  81. /package/dist/{doctor-6KHBE77P.js.map → doctor-3LGF6CWI.js.map} +0 -0
  82. /package/dist/{fund-GSFCXEF7.js.map → fund-3URFMBMN.js.map} +0 -0
  83. /package/dist/{install-TDYC22KI.js.map → install-FRTG4KHF.js.map} +0 -0
  84. /package/dist/{install-identity-QS4UFF27.js.map → install-identity-WNXSYP6N.js.map} +0 -0
  85. /package/dist/{install-wallet-T737X74E.js.map → install-wallet-MXLJJP3N.js.map} +0 -0
  86. /package/dist/{pay-TDYQFSKY.js.map → pay-43WUYTW5.js.map} +0 -0
  87. /package/dist/{payments-26NVMFR2.js.map → payments-7UTMMTIO.js.map} +0 -0
  88. /package/dist/{send-4RUBQQKP.js.map → send-ALHG2RXT.js.map} +0 -0
  89. /package/dist/{status-CEHZKHBU.js.map → status-CFPNHB6R.js.map} +0 -0
  90. /package/dist/{status-line-QRAO3Y2E.js.map → status-line-FJ6N7MKJ.js.map} +0 -0
  91. /package/dist/{status-line-wiring-XKUVI5UW.js.map → status-line-wiring-GXFNXHPE.js.map} +0 -0
  92. /package/dist/{uninstall-SJ6R2W2M.js.map → uninstall-5P2GFYBY.js.map} +0 -0
  93. /package/dist/{update-N2NZS3AA.js.map → update-QJ5YHJ7I.js.map} +0 -0
  94. /package/dist/{wallet-IB2EFAUP.js.map → wallet-6OJPGNEV.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  paidLegTimeoutMs,
5
5
  runPay,
6
6
  settlementTx
7
- } from "./chunk-UAT3Q7VF.js";
7
+ } from "./chunk-UBOFYC6J.js";
8
8
  import "./chunk-LAIZ2AQA.js";
9
9
  import "./chunk-RGVOODF4.js";
10
10
  import "./chunk-TTNESUPQ.js";
@@ -12,10 +12,10 @@ import "./chunk-HPWO4O6S.js";
12
12
  import "./chunk-POUWHWID.js";
13
13
  import "./chunk-XZKD7DIF.js";
14
14
  import "./chunk-LHHMV4GU.js";
15
- import "./chunk-F4IJQBGP.js";
16
- import "./chunk-DHCOGDJB.js";
17
- import "./chunk-NYJCBQL5.js";
18
- import "./chunk-WXFVJPZD.js";
15
+ import "./chunk-FFL5M5BC.js";
16
+ import "./chunk-GPLSNGKX.js";
17
+ import "./chunk-XZUGRTSV.js";
18
+ import "./chunk-ZMFDMALH.js";
19
19
  import "./chunk-AWQPGIR6.js";
20
20
  import "./chunk-N35E6CM2.js";
21
21
  import "./chunk-JRGFKVAZ.js";
@@ -24,15 +24,15 @@ import "./chunk-EGELTSPU.js";
24
24
  import "./chunk-KG3D7FIF.js";
25
25
  import "./chunk-RBJPAZFI.js";
26
26
  import "./chunk-BPMWXTFX.js";
27
- import "./chunk-UGLTSPXQ.js";
27
+ import "./chunk-O2WN732M.js";
28
28
  import "./chunk-7QKHZQKW.js";
29
- import "./chunk-AG4DWNHO.js";
29
+ import "./chunk-RCJ64OXH.js";
30
30
  import "./chunk-MEFB5KHA.js";
31
31
  import "./chunk-2I4QTOLB.js";
32
- import "./chunk-UHEMZEGW.js";
32
+ import "./chunk-TMLCEPCD.js";
33
33
  import "./chunk-O2JYBOUO.js";
34
- import "./chunk-SAN5PFTL.js";
35
- import "./chunk-B4GA3HAK.js";
34
+ import "./chunk-P22ZWXFX.js";
35
+ import "./chunk-ZNZGBUV6.js";
36
36
  import "./chunk-JLEF5WHM.js";
37
37
  import "./chunk-K6AXXYCG.js";
38
38
  import "./chunk-ZXTAQYNA.js";
@@ -42,4 +42,4 @@ export {
42
42
  runPay,
43
43
  settlementTx
44
44
  };
45
- //# sourceMappingURL=pay-TDYQFSKY.js.map
45
+ //# sourceMappingURL=pay-43WUYTW5.js.map
@@ -1,20 +1,20 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  reconcilePayments
4
- } from "./chunk-GONDQ27X.js";
4
+ } from "./chunk-UXSF7IFD.js";
5
5
  import "./chunk-LAIZ2AQA.js";
6
- import "./chunk-NYJCBQL5.js";
7
- import "./chunk-WXFVJPZD.js";
6
+ import "./chunk-XZUGRTSV.js";
7
+ import "./chunk-ZMFDMALH.js";
8
8
  import "./chunk-7QKHZQKW.js";
9
9
  import "./chunk-MEFB5KHA.js";
10
10
  import "./chunk-2I4QTOLB.js";
11
11
  import {
12
12
  resolveContextSettings
13
- } from "./chunk-UHEMZEGW.js";
13
+ } from "./chunk-TMLCEPCD.js";
14
14
  import {
15
15
  toMoney
16
16
  } from "./chunk-O2JYBOUO.js";
17
- import "./chunk-SAN5PFTL.js";
17
+ import "./chunk-P22ZWXFX.js";
18
18
  import "./chunk-JLEF5WHM.js";
19
19
  import {
20
20
  paidLedgerPath
@@ -44,4 +44,4 @@ async function runPaymentsReconcile(ctx, deps = {}) {
44
44
  export {
45
45
  runPaymentsReconcile
46
46
  };
47
- //# sourceMappingURL=payments-26NVMFR2.js.map
47
+ //# sourceMappingURL=payments-7UTMMTIO.js.map
@@ -10,13 +10,13 @@ import {
10
10
  broadcastUsdcSend,
11
11
  getUsdcBalance,
12
12
  prepareUsdcSend
13
- } from "./chunk-F4IJQBGP.js";
13
+ } from "./chunk-FFL5M5BC.js";
14
14
  import {
15
15
  describeWallet,
16
16
  resolveWalletProvider
17
- } from "./chunk-DHCOGDJB.js";
18
- import "./chunk-NYJCBQL5.js";
19
- import "./chunk-WXFVJPZD.js";
17
+ } from "./chunk-GPLSNGKX.js";
18
+ import "./chunk-XZUGRTSV.js";
19
+ import "./chunk-ZMFDMALH.js";
20
20
  import "./chunk-AWQPGIR6.js";
21
21
  import "./chunk-N35E6CM2.js";
22
22
  import "./chunk-JRGFKVAZ.js";
@@ -29,19 +29,19 @@ import {
29
29
  import "./chunk-KG3D7FIF.js";
30
30
  import "./chunk-RBJPAZFI.js";
31
31
  import "./chunk-BPMWXTFX.js";
32
- import "./chunk-UGLTSPXQ.js";
32
+ import "./chunk-O2WN732M.js";
33
33
  import "./chunk-MEFB5KHA.js";
34
34
  import "./chunk-2I4QTOLB.js";
35
35
  import {
36
36
  resolveContextSettings
37
- } from "./chunk-UHEMZEGW.js";
37
+ } from "./chunk-TMLCEPCD.js";
38
38
  import {
39
39
  parseUsdToAtomic,
40
40
  toMoney
41
41
  } from "./chunk-O2JYBOUO.js";
42
42
  import {
43
43
  SEND_MAX_UNSET
44
- } from "./chunk-SAN5PFTL.js";
44
+ } from "./chunk-P22ZWXFX.js";
45
45
  import {
46
46
  CliError
47
47
  } from "./chunk-JLEF5WHM.js";
@@ -221,4 +221,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
221
221
  export {
222
222
  runSend
223
223
  };
224
- //# sourceMappingURL=send-4RUBQQKP.js.map
224
+ //# sourceMappingURL=send-ALHG2RXT.js.map
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import "./chunk-NYJCBQL5.js";
2
+ import "./chunk-XZUGRTSV.js";
3
3
  import {
4
4
  readSpendSummary,
5
5
  spentOf
6
- } from "./chunk-WXFVJPZD.js";
6
+ } from "./chunk-ZMFDMALH.js";
7
7
  import "./chunk-MEFB5KHA.js";
8
8
  import "./chunk-2I4QTOLB.js";
9
9
  import {
10
10
  resolveContextSettings
11
- } from "./chunk-UHEMZEGW.js";
11
+ } from "./chunk-TMLCEPCD.js";
12
12
  import {
13
13
  toMoney
14
14
  } from "./chunk-O2JYBOUO.js";
@@ -16,7 +16,7 @@ import {
16
16
  RETIRED_PAYMENT_GUIDANCE,
17
17
  loadRawConfig,
18
18
  retiredPaymentKeys
19
- } from "./chunk-SAN5PFTL.js";
19
+ } from "./chunk-P22ZWXFX.js";
20
20
  import "./chunk-JLEF5WHM.js";
21
21
  import "./chunk-K6AXXYCG.js";
22
22
  import "./chunk-ZXTAQYNA.js";
@@ -68,4 +68,4 @@ async function runRouterStatus(ctx, deps = {}) {
68
68
  export {
69
69
  runRouterStatus
70
70
  };
71
- //# sourceMappingURL=status-CEHZKHBU.js.map
71
+ //# sourceMappingURL=status-CFPNHB6R.js.map
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-QF4SSCQV.js";
5
5
  import {
6
6
  routerSettings
7
- } from "./chunk-XBYTP4SP.js";
8
- import "./chunk-UHEMZEGW.js";
7
+ } from "./chunk-NSDZESRS.js";
8
+ import "./chunk-TMLCEPCD.js";
9
9
  import "./chunk-O2JYBOUO.js";
10
- import "./chunk-SAN5PFTL.js";
10
+ import "./chunk-P22ZWXFX.js";
11
11
  import "./chunk-JLEF5WHM.js";
12
12
  import "./chunk-K6AXXYCG.js";
13
13
  import "./chunk-ZXTAQYNA.js";
@@ -84,4 +84,4 @@ export {
84
84
  runStatusLine,
85
85
  statusLineMain
86
86
  };
87
- //# sourceMappingURL=status-line-QRAO3Y2E.js.map
87
+ //# sourceMappingURL=status-line-FJ6N7MKJ.js.map
@@ -9,9 +9,9 @@ import {
9
9
  inspectStatusLine,
10
10
  removeStatusLine,
11
11
  statusLineMode
12
- } from "./chunk-TU3IK7KK.js";
13
- import "./chunk-3Q3UBMVB.js";
14
- import "./chunk-B4GA3HAK.js";
12
+ } from "./chunk-YZTIYDWU.js";
13
+ import "./chunk-SQSKVKX6.js";
14
+ import "./chunk-ZNZGBUV6.js";
15
15
  import "./chunk-JLEF5WHM.js";
16
16
  import "./chunk-K6AXXYCG.js";
17
17
  import "./chunk-ZXTAQYNA.js";
@@ -26,4 +26,4 @@ export {
26
26
  removeStatusLine,
27
27
  statusLineMode
28
28
  };
29
- //# sourceMappingURL=status-line-wiring-XKUVI5UW.js.map
29
+ //# sourceMappingURL=status-line-wiring-GXFNXHPE.js.map
@@ -5,31 +5,31 @@ import {
5
5
  mcpScope,
6
6
  readMcpEntry,
7
7
  routerSettingsPath
8
- } from "./chunk-CYEUVU3F.js";
8
+ } from "./chunk-H5UR3GFJ.js";
9
9
  import {
10
10
  MCP_SERVER_NAME
11
11
  } from "./chunk-TGLKKLQG.js";
12
- import "./chunk-UGLTSPXQ.js";
12
+ import "./chunk-O2WN732M.js";
13
13
  import {
14
14
  onPath,
15
15
  persistRouterProject
16
- } from "./chunk-UIOZRILX.js";
16
+ } from "./chunk-W2ARIOAZ.js";
17
17
  import "./chunk-A36LQPHV.js";
18
- import "./chunk-2QYORQBF.js";
18
+ import "./chunk-P7LABKCW.js";
19
19
  import "./chunk-MEFB5KHA.js";
20
- import "./chunk-XBYTP4SP.js";
20
+ import "./chunk-NSDZESRS.js";
21
21
  import "./chunk-2I4QTOLB.js";
22
- import "./chunk-UHEMZEGW.js";
22
+ import "./chunk-TMLCEPCD.js";
23
23
  import "./chunk-O2JYBOUO.js";
24
- import "./chunk-SAN5PFTL.js";
24
+ import "./chunk-P22ZWXFX.js";
25
25
  import {
26
26
  removeStatusLine
27
- } from "./chunk-TU3IK7KK.js";
27
+ } from "./chunk-YZTIYDWU.js";
28
28
  import {
29
29
  inspectHooksFile,
30
30
  pruneHooks
31
- } from "./chunk-3Q3UBMVB.js";
32
- import "./chunk-B4GA3HAK.js";
31
+ } from "./chunk-SQSKVKX6.js";
32
+ import "./chunk-ZNZGBUV6.js";
33
33
  import {
34
34
  writeFileAtomic
35
35
  } from "./chunk-JLEF5WHM.js";
@@ -162,4 +162,4 @@ export {
162
162
  MCP_REMOVE_COMMAND,
163
163
  runRouterUninstall
164
164
  };
165
- //# sourceMappingURL=uninstall-SJ6R2W2M.js.map
165
+ //# sourceMappingURL=uninstall-5P2GFYBY.js.map
@@ -5,15 +5,15 @@ import {
5
5
  fetchDistTags,
6
6
  isNewer,
7
7
  resolveTarget
8
- } from "./chunk-NZYVSZNF.js";
8
+ } from "./chunk-XRW4N23F.js";
9
9
  import {
10
10
  emitWriteNotice,
11
11
  sanitizeForTerminal
12
- } from "./chunk-UGLTSPXQ.js";
13
- import "./chunk-SAN5PFTL.js";
12
+ } from "./chunk-O2WN732M.js";
13
+ import "./chunk-P22ZWXFX.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-B4GA3HAK.js";
16
+ } from "./chunk-ZNZGBUV6.js";
17
17
  import {
18
18
  CliError
19
19
  } from "./chunk-JLEF5WHM.js";
@@ -430,4 +430,4 @@ export {
430
430
  spawnCapture,
431
431
  versionFreeEntry
432
432
  };
433
- //# sourceMappingURL=update-N2NZS3AA.js.map
433
+ //# sourceMappingURL=update-QJ5YHJ7I.js.map
@@ -3,11 +3,11 @@ import {
3
3
  runWalletBalance,
4
4
  runWalletCreate,
5
5
  runWalletShow
6
- } from "./chunk-2RMXTNLT.js";
7
- import "./chunk-F4IJQBGP.js";
8
- import "./chunk-DHCOGDJB.js";
9
- import "./chunk-NYJCBQL5.js";
10
- import "./chunk-WXFVJPZD.js";
6
+ } from "./chunk-KC24CYGV.js";
7
+ import "./chunk-FFL5M5BC.js";
8
+ import "./chunk-GPLSNGKX.js";
9
+ import "./chunk-XZUGRTSV.js";
10
+ import "./chunk-ZMFDMALH.js";
11
11
  import "./chunk-AWQPGIR6.js";
12
12
  import "./chunk-N35E6CM2.js";
13
13
  import "./chunk-JRGFKVAZ.js";
@@ -16,11 +16,11 @@ import "./chunk-EGELTSPU.js";
16
16
  import "./chunk-KG3D7FIF.js";
17
17
  import "./chunk-RBJPAZFI.js";
18
18
  import "./chunk-BPMWXTFX.js";
19
- import "./chunk-UGLTSPXQ.js";
19
+ import "./chunk-O2WN732M.js";
20
20
  import "./chunk-MEFB5KHA.js";
21
21
  import "./chunk-2I4QTOLB.js";
22
22
  import "./chunk-O2JYBOUO.js";
23
- import "./chunk-SAN5PFTL.js";
23
+ import "./chunk-P22ZWXFX.js";
24
24
  import "./chunk-JLEF5WHM.js";
25
25
  import "./chunk-K6AXXYCG.js";
26
26
  import "./chunk-ZXTAQYNA.js";
@@ -29,4 +29,4 @@ export {
29
29
  runWalletCreate,
30
30
  runWalletShow
31
31
  };
32
- //# sourceMappingURL=wallet-IB2EFAUP.js.map
32
+ //# sourceMappingURL=wallet-6OJPGNEV.js.map
@@ -18,7 +18,7 @@ It is a tool grant, not a spending grant. Every payment the tool makes still pas
18
18
 
19
19
  Router on/off controls automatic routing. The spending controls and ledger are local; the router cannot read or raise them:
20
20
 
21
- - **`maxAutoSpend`** caps automatic router purchases per call. `tenjin install` sets it to 0.25 USD only when absent; the bare CLI defaults to zero. Above the cap, automatic payment is refused without prompting.
21
+ - **`maxAutoSpend`** caps automatic router purchases per call. `tenjin install` asks you to approve or change these limits in an interactive terminal, and writes 0.25 USD only when absent otherwise; the bare CLI defaults to zero. Above the cap, automatic payment is refused without prompting.
22
22
  - **`sessionBudget`** caps automatic exposure in the existing 24 hour ledger window. It defaults to 5.00 USD before and after install. Explicit zero blocks positive automatic spending; `none` removes the automatic daily ceiling.
23
23
  - **`spend.json`** records all payments, with separate automatic exposure and reservation modes. Only automatic exposure and pending automatic reservations consume the daily budget. Manual payments remain in total reporting. Older records without a mode/counter conservatively count as automatic until their window expires. Both modes retain the keyed duplicate guard, including under `none`.
24
24
 
@@ -37,7 +37,7 @@ tenjin config set sessionBudget 2.00
37
37
  The routing decision comes from a server, and it is free: it proposes, it never authorizes. These checks are what keep a wrong or hostile one from being worth anything:
38
38
 
39
39
  - The amount actually signed has to fit `maxAutoSpend` and the day's `sessionBudget`. A live price above the one the decision quoted is refused before anything is signed, so a provider or a stale catalog cannot charge more than it advertised; a hostile server sets that quote itself, so against one the bound stays `maxAutoSpend`.
40
- - An offer carries the service's spec: its input schema, the fields Tenjin pins, and the HTTP request those fields become. Your assistant fills the fields; this CLI puts the pins over them, validates the result against the schema, builds the request and pays the spec's own payee, never above the spec's price ceiling. A lookup that comes without a spec (a free one, or an older offer) is bound by the backend, which sends the finished request for this CLI to send as given.
40
+ - An offer carries the service's spec: its input schema, the fields Tenjin pins, and the HTTP request those fields become. Your assistant fills the fields; this CLI puts the pins over them, validates the result against the schema, builds the request and pays the spec's own payee, never above the spec's price ceiling. The one lookup without a spec, the free docs lookup, is bound by the backend from your assistant's query, and nothing is paid for it.
41
41
  - The destination has to be a public HTTPS endpoint whose name resolves to a public address. This is a check, not a pin: the request resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. See [safety-model.md](./safety-model.md).
42
42
  - A 2xx whose body fails the decision's own success rule is delivered as `unverified`, never `fulfilled`, with a caveat naming the rule it missed. The money has already moved, so the body is not withheld.
43
43
 
@@ -45,7 +45,7 @@ A compromised backend can therefore name any origin it likes, and spend at most
45
45
 
46
46
  ## A prefix rule pins the verb, not the flags
47
47
 
48
- This matters for the shell rules below rather than the tool rule above. Claude Code's `Bash(tenjin pay:*)` matches the verb and lets every flag through, including `--base-url`, which points the command at another host. So a rule you add is a rule for the verb at whatever host the caller names, and a task that arrived from a web page or a purchased document is exactly where such a flag comes from.
48
+ This matters for the shell rules below rather than the tool rule above. Claude Code's `Bash(tenjin pay:*)` matches the verb and lets every flag through, including `--base-url`, which points the command at another host. So a rule you add is a rule for the verb at whatever host the caller names, and a task that arrived from a web page or a provider result is exactly where such a flag comes from.
49
49
 
50
50
  ## Opt in by hand: paying an endpoint you name
51
51
 
@@ -65,7 +65,7 @@ tenjin pay https://api.example.com/quote --json --max-price 0.05
65
65
  tenjin pay https://api.example.com/quote --json --max-price 0.05 --ignore-warnings --yes
66
66
  ```
67
67
 
68
- Both flags still obey the optional explicit `--max-price` cap, destination and supported-challenge checks, and the authoritative wallet balance check. Warnings and acknowledgement status remain in JSON output. Each paid invocation can spend again; there is no purchase-library dedupe. Free or SIWX-entitled delivery needs neither warning acknowledgement nor a payment balance read.
68
+ Both flags still obey the optional explicit `--max-price` cap, destination and supported-challenge checks, and the authoritative wallet balance check. Warnings and acknowledgement status remain in JSON output. Each paid invocation can spend again; nothing deduplicates repeat payments. Free or SIWX-entitled delivery needs neither warning acknowledgement nor a payment balance read.
69
69
 
70
70
  Router calls cannot use `--ignore-warnings`. They require their offered price and retain hard checks for any supplied network, asset or recipient. An offer's spec supplies all four, so the live 402 has to match its recipient, network and asset and stay within its price; a lookup without a spec gets its price alone from the server, and for it this release does not claim complete endpoint/payee quote binding.
71
71
 
@@ -104,12 +104,12 @@ To stop the router without removing anything, `tenjin config set router.enabled
104
104
 
105
105
  1. You type a turn. The hook sends the bounded packet to Tenjin, which answers whether a paid capability fits and, if it does, keeps that packet under a short-lived id.
106
106
  2. When one fits, your assistant sees one line, opening with `Tenjin router (installed by the user):`, that names the service, its price and the call to make: `mcp__x402__request({id, input})` with the required fields as placeholders, or already filled in when the hook holds them (the search a native call was about to run, or the page it was about to fetch). The hook keeps the service's spec on this machine under the id.
107
- 3. Your assistant fills the fields and calls `request({id, input})` once. This CLI validates the input against the spec, builds the request, pays that provider once under your limits, hands back the result, and tells Tenjin only how the call ended. Deciding costs nothing.
107
+ 3. Your assistant fills the fields and calls `request({id, input})` once. This CLI validates the input against the spec, builds the request, pays that provider once under your limits, hands back the result, and tells Tenjin only how the call ended. Deciding costs nothing. Where the spec names the fields its result promises, the result holds only those, and the provider's whole response is saved under `~/.tenjin/results/` (readable by you alone, kept a day) at the path the result names in `fullResultPath`.
108
108
  4. An input that does not fit the spec is refused before anything is sent: your assistant gets every problem and the whole spec (each input with its description and allowed values, the required fields inside a nested object, an example and what comes back), locally and with nothing paid, and calls again. `request({id})` alone shows the same spec. A spec whose input schema this CLI cannot compile is refused outright, with nothing sent or paid.
109
109
 
110
110
  ## What the hooks send
111
111
 
112
- - On every prompt and every native `WebSearch` or `WebFetch`: the text of the current turn and at most six prior messages, masked by the same key, PEM, seed-phrase, and URL credential rules the publish scan uses, then bounded to 16 KiB, with harness meta rows and tool results excluded. Tool results never travel: a tool result is other people's content, and a packet carrying it would be a channel from a fetched page into a routing decision.
112
+ - On every prompt and every native `WebSearch` or `WebFetch`: the text of the current turn and at most six prior messages, masked by the CLI's key, PEM, seed-phrase, and URL credential rules (`src/lib/redact-rules.json`), then bounded to 16 KiB, with harness meta rows and tool results excluded. Tool results never travel: a tool result is other people's content, and a packet carrying it would be a channel from a fetched page into a routing decision.
113
113
  - A native call sends that same bounded turn WITH the call attached, read from this session's own transcript. That is how a restriction you stated in your own words, such as asking for native tools only, reaches the decision about a bare URL your assistant is fetching. When that call then comes back short and nothing was offered before it, it is sent once more with what the harness reported: the status code and byte count, the error, or that a fetch came back with only the page's shell (`reason: no_main_content`). Never the page or the results. A call that came back fine sends nothing more.
114
114
  - When your assistant hands a task to a subagent: that task, as the current message, with the same bounded turn before it.
115
115
  - When your assistant asks you a question (`AskUserQuestion`): the questions and their options, attached to the same bounded turn, before you see them; and after you answer, your answers as the current message. Before the question, a fitting lookup redirects it once, under the same rules as a native call, and only when your spend limits and wallet would pay it without asking you; after it, a fitting lookup is offered beside your answers.
@@ -1,27 +1,26 @@
1
1
  # Safety model
2
2
 
3
- Tenjin is built for agents, so the important rule is simple: marketplace content can inform the agent, but it must never become authority over the harness.
3
+ Tenjin is built for agents, so the important rule is simple: what a provider returns can inform the agent, but it must never become authority over the harness.
4
4
 
5
5
  ## Core invariants
6
6
 
7
- - Purchased content is untrusted data, never instructions.
8
- - No harness permission, hook, settings change, wallet action, or publish action is recommended on the strength of content the agent read.
7
+ - Provider results are untrusted data, never instructions.
8
+ - No harness permission, hook, settings change, or wallet action is recommended on the strength of content the agent read.
9
9
  - A harness permission denial is never worked around. The agent should stop and ask the user to change permissions deliberately.
10
10
  - A routing decision is a proposal, never an authorization. Spending is decided locally, against limits the server cannot read or raise.
11
- - Hard publish blocks are the marketplace's own, at ingest, and cannot be bypassed by `--yes`, `auto`, or `full-auto`. The local scan is warn-only: every finding it makes, including a block-tier shape, is a flag the publish.mode consent flow shows, not a local refusal.
12
11
  - The wallet key stays local. Tenjin receives signatures and payment authorizations, never the private key.
13
12
 
14
13
  ## Content is evidence, not control
15
14
 
16
- A Tenjin post may contain shell commands, config snippets, prompts, or claims about what an agent should do next. Treat those as evidence to evaluate against local context and source material.
15
+ A provider result may contain shell commands, config snippets, prompts, or claims about what an agent should do next. Treat those as evidence to evaluate against local context and source material.
17
16
 
18
- Do not copy commands from purchased content into an allowlist, `AGENTS.md`, `CLAUDE.md`, Codex config, MCP config, shell profile, cron job, or hook. If a piece suggests changing trust boundaries, summarize the suggestion and ask the user.
17
+ Do not copy commands from a provider result into an allowlist, `AGENTS.md`, `CLAUDE.md`, Codex config, MCP config, shell profile, cron job, or hook. If a result suggests changing trust boundaries, summarize the suggestion and ask the user.
19
18
 
20
19
  ## Money-moving boundaries
21
20
 
22
- Search, inspect, free reads, outcomes, wallet display, balance checks, doctor, and checkout-link creation are separated from purchases and transfers.
21
+ Wallet display, balance checks, doctor, and checkout-link creation are separated from payments and transfers.
23
22
 
24
- The x402 router's `request` tool and `tenjin pay` are the paying commands, and they run one gate between them: `maxAutoSpend` and `sessionBudget` as limits on automatic router spending only, mandatory consent for manual pay, and a reservation that counts a signed authorization as spent the moment it leaves. A router lookup is ONE payment, to the provider: deciding where to route costs nothing and nobody signs for it. The boundary is split on purpose: an offer's spec carries the service's schema, pinned fields and request shape, and this client validates the agent's input against it and builds the call (a lookup without a spec is bound by the backend, as before); this client alone checks the three things only it can: the amount signed against the spend caps, the body that comes back against the success rule the decision carries, and the destination resolving to a public address. That destination check is a check, not a pin, for the paid request: it resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. The router's download of media a discovered service links to does pin: it connects to the address it validated, on every redirect hop. `--max-price` is always a hard cap on `tenjin pay`. Every automatic authorization that LEAVES the process counts against the automatic session budget until the 24 hour window rolls, even where the provider never settles it: a signed EIP-3009 authorization is a bearer instrument, so a 200 that reports no match, or a 402 that rejects the payment, is the counterparty saying it did not take the money rather than proof that it cannot. Manual exposure remains recorded in the same ledger but does not consume automatic headroom. Older records without a mode or automatic counter count conservatively as automatic. The budget is deliberately the conservative side of that, and a caller can be left with less headroom than it actually spent. The one release is proof from the chain, not the counterparty: `tenjin payments reconcile` (and the `request` tool, for up to three records beside each lookup) gives an authorization's amount back only when USDC's `authorizationState` shows it unused at a block whose timestamp is past its `validBefore`, so it can never be charged, and only inside the window that counted it, once per nonce.
23
+ The x402 router's `request` tool and `tenjin pay` are the paying commands, and they run one gate between them: `maxAutoSpend` and `sessionBudget` as limits on automatic router spending only, mandatory consent for manual pay, and a reservation that counts a signed authorization as spent the moment it leaves. A router lookup is ONE payment, to the provider: deciding where to route costs nothing and nobody signs for it. The boundary is split on purpose: an offer's spec carries the service's schema, pinned fields and request shape, and this client validates the agent's input against it and builds the call (the free docs lookup, which has no spec and costs nothing, is bound by the backend); this client alone checks the three things only it can: the amount signed against the spend caps, the body that comes back against the success rule the decision carries, and the destination resolving to a public address. That destination check is a check, not a pin, for the paid request: it resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. The router's download of media a discovered service links to does pin: it connects to the address it validated, on every redirect hop. `--max-price` is always a hard cap on `tenjin pay`. Every automatic authorization that LEAVES the process counts against the automatic session budget until the 24 hour window rolls, even where the provider never settles it: a signed EIP-3009 authorization is a bearer instrument, so a 200 that reports no match, or a 402 that rejects the payment, is the counterparty saying it did not take the money rather than proof that it cannot. Manual exposure remains recorded in the same ledger but does not consume automatic headroom. Older records without a mode or automatic counter count conservatively as automatic. The budget is deliberately the conservative side of that, and a caller can be left with less headroom than it actually spent. The one release is proof from the chain, not the counterparty: `tenjin payments reconcile` (and the `request` tool, for up to three records beside each lookup) gives an authorization's amount back only when USDC's `authorizationState` shows it unused at a block whose timestamp is past its `validBefore`, so it can never be charged, and only inside the window that counted it, once per nonce.
25
24
 
26
25
  The automatic daily limit is zero, a finite amount or `none`: zero blocks positive automatic payments and `none` removes that ceiling while retaining reservations and duplicate protection. Manual pay requires explicit user consent and is subject to neither automatic limit. Retired `bazaarPay` and `confirm` values are ignored after upgrade; doctor/status warn, and install/refresh remove and report them while preserving current controls and unrelated fields.
27
26
 
@@ -40,25 +39,13 @@ After policy confirmation and immediately before signing, the actual signer's US
40
39
  1. Delete the line from `KNOWN_DEPLOYMENT_ORIGINS` and update the exact-membership pin in `production-origin.test.ts`, which is written out independently so this cannot be a one-line change.
41
40
  2. Release, then tell operators to update. Until each CLI updates it keeps the old set: a released binary cannot be recalled, so treat the removal as effective only after operators have upgraded, and stop pointing DNS at anyone else's infrastructure in the meantime.
42
41
 
43
- ## Publishing boundaries
42
+ ## Secret redaction
44
43
 
45
- Publishing and editing put content on a public marketplace under your identity. A local scan flags likely secrets and private-key material before every write and inside every router packet: provider token shapes, private keys in and out of PEM framing, connection URIs with an embedded password, BIP-39 recovery phrases, and TOTP provisioning URIs, plus a broader warn tier for other sensitive context the agent still has to use judgment about. Its rules live as data in `src/lib/redact-rules.json`, the one table every redaction surface in the CLI reads.
46
-
47
- The local scan does not refuse on its own: every finding it makes, block-tier shapes included, is a flag that goes through the same publish.mode consent flow as any other change — `review` asks, `auto` holds with `NEEDS_CONFIRMATION`, `full-auto` clears it and proceeds. The marketplace runs its own scan at ingest, on the write itself, and it is the one place that still refuses: its block tier has no acknowledgement path, so no mode and no `--yes` clears it. Today that covers the body, the frontmatter and `--excerpt`. The answer card is frontmatter now, with no flag form on `publish`, so it reaches the marketplace gate inside the document like the body does; `tenjin edit` still authors card fields by flag, and a secret typed into one of those is scanned locally as a flag only until the marketplace gate is extended to the card (loop-redesign PR F).
48
-
49
- Server-side, the block tier has no acknowledgement path. The warn tier is held with a token, and a `--yes` clears that hold only when the marketplace found nothing the local scan had not already rendered. **A confirmation covers the findings it post-dates.** A `--yes` is an answer to a payload, and the payload it answered was rendered before any server call, so it cannot have contained the marketplace's own findings; the semantic checks in particular have no local counterpart at all. `full-auto` acknowledges unasked, because clearing soft findings unasked is that mode's contract. `publish.ackServerWarnings` overrides both readings: `off` never acknowledges whatever the mode says, and `on` is a standing yes that lets a `--yes` cover the marketplace's findings too. Findings the server contributed are marked as such where they are rendered, with their tier, including detectors this release has never heard of.
50
-
51
- Findings never carry the matched secret. Each one is a detector id, a tier, offsets, and a masked excerpt, so a finding can be shown, logged, or forwarded without republishing what it found.
52
-
53
- On a team shelf the destination is the team's own deployment rather than the marketplace, so the warn tier — which asks "is this safe to make public" — is skipped, except for `secret-assignment` (and `hex32-value`, the warn form a block-tier check demotes to). `high-entropy-string`, `env-dump-block` and the injection check `embedded-instruction` are public-only now. Which warn checks survive is data rather than a list in code: the `scopes` list on the rule in `src/lib/redact-rules.json` (a warn scoped to `team` as well as `publish`), applied inside the scan itself, so a new credential detector joins the survivors by marking itself and no command filters. The block on secrets and private-key material is not skipped either: that deployment is still a hosted database with logs and a door key the whole team holds, and a team note is fed to teammates' agents by the loop's hook arms, so neither "is this a live credential" nor "would this text steer the reader" gets easier to answer for being private.
54
-
55
- The ingest gate runs on a team shelf too, since it sits in the shared write path rather than in the marketplace's publish route, and the shelf keeps its block tier on purpose for the reasons above. **Its warn tier stays advisory on a team shelf**: the shelf sets no `SCAN_WARN_MODE`, so warn findings ride the success response onto the team receipt and nothing is held. That is deliberate, not an oversight. Under `enforce` the shelf's warn tier would re-impose exactly the findings the team drop removes, and it is not the shelf's job to re-ask a question the drop already answered. A team shelf that does flip its own `SCAN_WARN_MODE` to `enforce` gets marketplace semantics on this path, warn holds included, and should expect the drop and the gate to disagree.
56
-
57
- When in doubt, publish less context and more reproducible evidence.
44
+ Every router packet is masked before it leaves the machine: provider token shapes, private keys in and out of PEM framing, connection URIs with an embedded password, BIP-39 recovery phrases, and TOTP provisioning URIs. The rules live as data in `src/lib/redact-rules.json`, the one table every redaction surface in the CLI reads. A finding never carries the matched secret: it is a detector id, a tier, offsets, and a masked excerpt.
58
45
 
59
46
  ## Permission boundaries
60
47
 
61
- The recommended free harness permissions are documented in [agent-permissions.md](./agent-permissions.md). They are intentionally narrow and do not include `buy`, `publish`, `edit`, `wallet send`, `wallet create`, `config set`, `install`, or `mcp`.
48
+ The recommended free harness permissions are documented in [agent-permissions.md](./agent-permissions.md). They are intentionally narrow and do not include `pay`, `wallet send`, `wallet create`, `config set`, `install`, or `mcp`.
62
49
 
63
50
  Codex's default `workspace-write` sandbox also needs network access for paid x402 calls:
64
51
 
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "tenjin-cli",
3
- "version": "0.1.0-alpha.22",
4
- "mcpName": "blog.tenjin/tenjin",
3
+ "version": "0.1.0-alpha.24",
5
4
  "type": "module",
6
- "description": "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.",
5
+ "description": "The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.",
7
6
  "repository": {
8
7
  "type": "git",
9
8
  "url": "git+https://github.com/BackTrackCo/tenjin-agent.git"
@@ -11,14 +10,17 @@
11
10
  "homepage": "https://tenjin.blog/agents",
12
11
  "bugs": "https://github.com/BackTrackCo/tenjin-agent/issues",
13
12
  "keywords": [
13
+ "claude-code",
14
+ "coding-agents",
15
+ "tool-router",
16
+ "ai-agents",
17
+ "agent-tools",
18
+ "mcp",
14
19
  "x402",
15
20
  "usdc",
16
21
  "base",
17
- "ai-agents",
18
- "agent-payments",
19
- "mcp",
20
- "knowledge-marketplace",
21
22
  "micropayments",
23
+ "agent-payments",
22
24
  "claude",
23
25
  "codex",
24
26
  "cli"
@@ -35,7 +37,7 @@
35
37
  "NOTICE.md"
36
38
  ],
37
39
  "devDependencies": {
38
- "@changesets/cli": "^2.31.1",
40
+ "@changesets/cli": "^3.0.3",
39
41
  "@clack/prompts": "^1.7.0",
40
42
  "@eslint/js": "^10",
41
43
  "@modelcontextprotocol/sdk": "1.29.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.22\",\n \"mcpName\": \"blog.tenjin/tenjin\",\n \"type\": \"module\",\n \"description\": \"x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.blog/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"x402\",\n \"usdc\",\n \"base\",\n \"ai-agents\",\n \"agent-payments\",\n \"mcp\",\n \"knowledge-marketplace\",\n \"micropayments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=24\"\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"rm -rf dist && tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"githooks\": \"git config core.hooksPath .githooks\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.31.1\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.29.0\",\n \"@types/node\": \"^25\",\n \"@x402/core\": \"2.17.0\",\n \"@x402/evm\": \"2.17.0\",\n \"@x402/extensions\": \"2.17.0\",\n \"ajv\": \"^8.20.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,EAClB,SAAW;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,cAAc;AAAA,IACd,WAAa;AAAA,IACb,gBAAkB;AAAA,IAClB,UAAY;AAAA,EACd;AAAA,EACA,iBAAmB;AAAA,IACjB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,6BAA6B;AAAA,IAC7B,eAAe;AAAA,IACf,cAAc;AAAA,IACd,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,KAAO;AAAA,IACP,eAAe;AAAA,IACf,WAAa;AAAA,IACb,QAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,IAAM;AAAA,IACN,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,KAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/router/install.ts","../src/lib/skill-placement.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readFile, realpath } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { claudeAdapter } from '../adapters/claude';\nimport { persistRouterDefaults } from '../commands/config';\nimport { CliError } from '../lib/errors';\nimport { appendAllowlistRules, claudeSettingsPath } from '../lib/harness-permissions';\nimport {\n inspectHooksFile,\n ownsHookEntry,\n pruneHooks,\n writeHooks,\n type HooksResult,\n} from '../lib/harness-hooks';\nimport { toMoney } from '../lib/money';\nimport { paint } from '../lib/output';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { SpendPolicy } from '../lib/policy';\nimport { removeRetiredSkills } from '../lib/skill-placement';\nimport { loadRawConfig } from '../lib/config';\nimport { onPath } from '../lib/skill-wiring';\nimport type { WalletDeps, WalletOutcome } from '../commands/install-wallet';\nimport type { CommandContext, CommandResult } from '../context';\nimport { MCP_SERVER_NAME, REQUEST_TOOL } from './names';\nimport { ensureStatusLine, type StatusLineMode, type StatusLineResult } from './status-line-wiring';\n\n/**\n * `tenjin install` for the router product: seven hook entries, one MCP server,\n * one permission rule, the spend defaults, and a wallet when there is none.\n *\n * WHAT IT WRITES IS WHAT IT SAYS. There is no skill to materialize and no\n * daemon to start: the hooks are plain command lines, the tool lives in an MCP\n * server the harness starts per session, and every other key in the settings\n * file is preserved byte for byte. The one process a hook starts is the free\n * docs fetch beside a search, which exits within `PREFETCH_TIMEOUT_MS`.\n */\n\nconst exec = promisify(execFile);\n\n/**\n * The harness's kill budget for each hook entry, and the number every other\n * wait inside the hook is cut from: 1 s of stdin plus 3.5 s of gate, with\n * 500 ms left for node's boot and the transcript read (`wire.test.ts` pins it).\n * Raised from 3 s because a gate abort costs the turn its hint silently.\n *\n * A machine carrying the old number is converged by the writer, not by the\n * user: the entries are ours by marker, so `install`, `install --refresh` and\n * the refresh `tenjin update` spawns all rewrite them in place.\n */\nexport const HOOK_TIMEOUT_SECONDS = 5;\n/**\n * The after-call entries' kill budget, longer than the rest for the one wait\n * any hook makes: a search the pre-call arm is fetching free docs for waits up\n * to `AUGMENT_WAIT_MS` for them, and when none came back and the search was\n * short, the gate is asked after that (`wire.test.ts` pins the sum). Every\n * other after-call event returns as fast as before, so the number is a\n * ceiling, not a cost. The pre-call entry stays at\n * {@link HOOK_TIMEOUT_SECONDS}: it starts that fetch and never waits for it.\n */\nexport const AFTER_CALL_TIMEOUT_SECONDS = 15;\nexport { MCP_SERVER_NAME };\nexport const ALLOW_RULE = REQUEST_TOOL;\n/**\n * The MCP registration follows the SAME SCOPE the hook entries do. A\n * `--project` install that wrote its hooks into the project and then registered\n * the server at user scope would reach into `~/.claude.json` on a run whose\n * whole point is to touch this project and nothing else, and `tenjin uninstall\n * --project` would leave that behind.\n *\n * Project scope writes `<project>/.mcp.json`, so the registration lives beside\n * the settings file that names the hooks and travels with the repository.\n */\nexport function mcpScope(project: boolean | undefined): 'user' | 'project' {\n return project === true ? 'project' : 'user';\n}\n\nexport function mcpAddCommand(project?: boolean): string {\n return `claude mcp add ${MCP_SERVER_NAME} -s ${mcpScope(project)} -- tenjin mcp`;\n}\n\nexport function mcpRemoveCommand(project?: boolean): string {\n return `claude mcp remove ${MCP_SERVER_NAME} -s ${mcpScope(project)}`;\n}\n\n/** The user-scope form, kept as the name the docs and the tests already use. */\nexport const MCP_ADD_COMMAND = mcpAddCommand();\n\n/**\n * Which settings file this machine's router wiring lives in, spelled once so\n * `install`, `uninstall` and `doctor` can never disagree about where to look.\n * A doctor reading the home file on a `--project` install reported a correctly\n * wired machine as unwired and exited 3.\n */\nexport function routerSettingsPath(\n opts: { project?: boolean; homeDir?: string; cwd?: string } = {},\n): string {\n if (opts.project === true) return join(opts.cwd ?? process.cwd(), '.claude', 'settings.json');\n return claudeSettingsPath(opts.homeDir ?? homedir());\n}\n\n/** The subagent tool, under its current name and its older one. */\nexport const DELEGATION_MATCHER = 'Agent|Task';\n\n/** The native tools both native arms watch. */\nexport const NATIVE_MATCHER = 'WebSearch|WebFetch';\n\n/** The host's question to the user, watched before it is asked and after. */\nexport const ASK_MATCHER = 'AskUserQuestion';\n\n/**\n * The seven entries, spelled once so `uninstall`, `doctor` and the tests read\n * the same list. The native tools are routed twice over one lookup: BEFORE the\n * call, as every release has, with a line pointing to a paid lookup when one\n * fits; and AFTER it, only when it came back short and nothing was said before,\n * or to add the free docs the pre-call arm fetched to a search's results. A\n * failed call fires PostToolUseFailure rather than PostToolUse, so the second\n * takes both. The host's question to the user is routed the same two ways:\n * before it is asked, when a service could stand in for what it asks for, and\n * after, with the user's answers read as their own words.\n */\nexport function routerHookPlan(): unknown[] {\n const handler = (command: string, timeout = HOOK_TIMEOUT_SECONDS) => [\n { type: 'command', command, timeout },\n ];\n const afterCall = () => handler('tenjin hook shortfall', AFTER_CALL_TIMEOUT_SECONDS);\n return [\n { event: 'UserPromptSubmit', hooks: handler('tenjin hook prompt') },\n { event: 'PreToolUse', matcher: NATIVE_MATCHER, hooks: handler('tenjin hook native') },\n { event: 'PreToolUse', matcher: DELEGATION_MATCHER, hooks: handler('tenjin hook agent') },\n { event: 'PostToolUse', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PostToolUseFailure', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PreToolUse', matcher: ASK_MATCHER, hooks: handler('tenjin hook ask') },\n { event: 'PostToolUse', matcher: ASK_MATCHER, hooks: handler('tenjin hook answer') },\n ];\n}\n\nexport const DISCLOSURE: readonly string[] = [\n \"What leaves this machine: the bounded text of each prompt, each native search query or URL (and, when one came back short, its status, size or error), each task handed to a subagent, and each question your assistant asks you with your answers, sent to Tenjin for the free routing gate, beside this session's id. When the gate offers free library docs for a search, that search query also goes to Tenjin's docs lookup, which asks Context7.\",\n 'What is kept when a lookup is paid: the capability chosen, a hash of the contract, a hash of the arguments, and your wallet address. No prompt text, no arguments, no hint text.',\n 'What never leaves: your private key. It is decrypted in this CLI to sign, and never sent anywhere.',\n];\n\nexport interface RouterInstallArgs {\n /** Write into this project's `.claude/settings.json` instead of your home one. */\n project?: boolean;\n /**\n * Bring the entries this machine ALREADY has up to the running build, and\n * add nothing: no config write, no MCP registration, and a refusal when\n * nothing of ours is here. `tenjin update` spawns exactly this after it swaps\n * the binary, so the flag's name and meaning are a compatibility contract.\n */\n refresh?: boolean;\n /**\n * What to do about Claude Code's `statusLine`. Absent is the default path:\n * write ours when the key is free, and print the composition line when it is\n * not. `compose` wraps the status line already there and appends ours;\n * `skip` leaves the key alone entirely.\n */\n statusLine?: StatusLineMode;\n /** Create no wallet, for CI and scripted machines. */\n noWallet?: boolean;\n}\n\nexport interface RouterInstallDeps extends WalletDeps {\n homeDir?: string;\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n /** PATH probe for the `claude` binary. */\n which?: (bin: string) => boolean;\n /** Runs `claude mcp add`; tests inject it so no binary is spawned. The scope\n * and the working directory are passed, because project scope is decided by\n * where the command runs as much as by the flag. */\n registerMcp?: (\n command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n ) => Promise<void>;\n /** Reads the registration the scope's own file holds; tests inject it. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n}\n\nexport interface McpRegistration {\n name: string;\n registered: boolean;\n /** Which scope it went to, following the hook entries rather than the flag\n * being read twice. `project` writes `<project>/.mcp.json`. */\n scope: 'user' | 'project';\n /** The command to run by hand, when this run could not. */\n command: string;\n /**\n * WHAT THIS RUN ACTUALLY DID, which `registered` alone cannot say:\n * `already-registered` (the scope's file already launches `tenjin mcp`, and\n * nothing was spawned), `added`, `repaired` (a same-name entry launching\n * something else was removed and re-added, which only `uninstall` does now),\n * `unrepaired` (a registration this run KNOWS is wrong or unreadable and will\n * not touch) or `unavailable` (it is simply not there and this machine could\n * not add it, e.g. no `claude` on PATH). A refresh fails on `unrepaired`,\n * because reporting convergence over a registration that launches something\n * else is the thing to avoid; it still only prints the manual command for\n * `unavailable`.\n */\n reconciled: 'already-registered' | 'added' | 'repaired' | 'unrepaired' | 'unavailable';\n reason?: string;\n}\n\nasync function inferRefreshProject(\n cwd: string,\n home: string,\n dataDir: string,\n readRegistration: typeof readMcpEntry,\n): Promise<boolean> {\n const hooks = await probeOurEntries(routerSettingsPath({ project: true, cwd }), dataDir);\n if (hooks.state !== 'present') return false;\n const [cwdPath, homePath] = await Promise.all([\n realpath(cwd),\n realpath(home).catch((err: NodeJS.ErrnoException) => {\n // A missing home cannot alias this existing project. Do not require it\n // to exist (or create it) just to refresh the project's own settings.\n if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return null;\n throw err;\n }),\n ]);\n if (cwdPath !== homePath) return true;\n\n // Home shares one hooks file between scopes. Preserve a project-only install,\n // but prefer user scope when both registrations exist (including alpha.18's\n // accidental duplicate). With neither registration, the default is user.\n // Unreadable/conflicting entries stay in their scope so reconciliation refuses\n // them instead of silently creating a registration in the other scope.\n const user = await readRegistration('user', cwd, home);\n if (user.state !== 'absent') return false;\n const project = await readRegistration('project', cwd, home);\n return project.state !== 'absent';\n}\n\nexport async function runRouterInstall(\n args: RouterInstallArgs,\n ctx: CommandContext,\n deps: RouterInstallDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) {\n throw new CliError('INTERNAL', 'The home directory is not an absolute path.', {\n fix: 'Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`.',\n });\n }\n await loadRawConfig(ctx.dataDir); // Validate before any install writes; retired keys remain readable.\n const cwd = deps.cwd ?? process.cwd();\n // `tenjin update` runs from home, where the hooks file cannot prove scope.\n // An explicit --project still wins, including for a project rooted at home.\n const project =\n args.project ??\n (args.refresh === true &&\n (await inferRefreshProject(cwd, home, ctx.dataDir, deps.readMcpEntry ?? readMcpEntry)));\n const settingsPath = routerSettingsPath({\n ...(project ? { project: true } : {}),\n homeDir: home,\n cwd,\n });\n\n if (args.refresh === true) {\n const probe = await probeOurEntries(settingsPath, ctx.dataDir);\n // An unreadable file is not an absence, and telling someone to install over\n // it is the wrong instruction: the writer would refuse it too.\n if (probe.state === 'unreadable') {\n throw new CliError('CONFIG_INVALID', `Could not inspect ${settingsPath}: ${probe.reason}`, {\n fix: `Fix ${settingsPath}, then re-run: tenjin update`,\n });\n }\n if (probe.state === 'absent') {\n throw new CliError(\n 'REFUSED',\n `Nothing to refresh in ${settingsPath}: no Tenjin hook entries are registered here.`,\n { fix: 'Run `tenjin install` to set this machine up.' },\n );\n }\n }\n const spend = await persistRouterDefaults(ctx.dataDir, args.refresh === true);\n const removedKeysLines =\n spend.removed.length > 0\n ? [\n `Removed retired settings: ${spend.removed.join(', ')}. Automatic router limits remain in effect; manual pay always requires consent.`,\n ]\n : [];\n const removedSkills = await removeRetiredSkills(home, project ? cwd : undefined);\n const hooks = await writeHooks({\n adapter: claudeAdapter,\n homeDir: home,\n dataDir: ctx.dataDir,\n env,\n plan: routerHookPlan(),\n settingsPath,\n });\n const permissions = await ensureAllowRule(settingsPath);\n const statusLine = await ensureStatusLine(settingsPath, {\n ...(args.statusLine !== undefined ? { mode: args.statusLine } : {}),\n ...(args.refresh === true ? { refreshOnly: true } : {}),\n });\n const mcp = await registerMcpServer(deps, env, project, cwd, home);\n if (args.refresh === true) {\n // The SAME writers, minus the one that decides anything: the entries are\n // rewritten in place by their ownership marker so an upgrade never\n // duplicates them, the rule and the registration are re-checked because a\n // new version can change either. Config cleanup only removes retired keys;\n // the wallet, current limits and `spend.json` are unchanged. Widening an agent's spend policy\n // during an unattended upgrade is not a convergence.\n // RECONCILED, not re-added: `claude mcp add` exits 1 on an existing entry,\n // so the registration is read first and only written when it is missing or\n // wrong (see {@link registerMcpServer}).\n // A registration this run KNOWS is wrong and could not repair is not a\n // converged install, and `tenjin update` reporting success over it is how\n // a machine keeps a stale `x402` server across upgrade after upgrade.\n if (mcp.reconciled === 'unrepaired') {\n throw new CliError(\n 'REFUSED',\n `The ${MCP_SERVER_NAME} MCP registration (${mcpScope(project)} scope) is not the router's and this run could not repair it: ${mcp.reason ?? 'unknown reason'}.`,\n { fix: `Run: ${mcp.command}`, details: { settingsPath, hooks, permissions, mcp } },\n );\n }\n return {\n data: {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n mcp,\n refresh: true,\n spend,\n removedSkills,\n scope: mcpScope(project),\n },\n humanLines: [\n ...refreshLines(ctx, problems(ctx, hooks, permissions, statusLine, mcp)),\n ...removedKeysLines,\n ],\n };\n }\n // The shelf install's wallet step, unchanged except that it never asks: a\n // lookup cannot be paid without a wallet, so install makes one. A failure is\n // reported, never fatal; everything above is useful without it.\n const { resolveWallet } = await import('../commands/install-wallet');\n const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? 'flag' : undefined, false);\n // Read back AFTER the write: a machine that already carried its own caps\n // keeps them, and a readout quoting the defaults would describe limits this\n // run did not set.\n const effective = await resolveContextSettings(ctx);\n\n const data = {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n spend: { ...spend, effective: effectiveLimits(effective.policy) },\n mcp,\n wallet,\n disclosure: DISCLOSURE,\n removedSkills,\n };\n return {\n data,\n humanLines: [\n ...lines(ctx, {\n project,\n hooks,\n permissions,\n statusLine,\n mcp,\n wallet,\n policy: effective.policy,\n }),\n ...removedKeysLines,\n ],\n };\n}\n\nexport interface AllowRuleResult {\n path: string;\n rule: string;\n added: boolean;\n /** Set when the file could not be written; the rule is then not in force. */\n warning?: string;\n}\n\n/**\n * The one permission rule, through the shared allowlist writer rather than a\n * third hand-rolled one: it resolves a symlinked settings.json before the\n * rename, refuses a file it cannot parse, and compares the bytes it read before\n * committing, none of which a local copy of the merge would have.\n */\nasync function ensureAllowRule(path: string): Promise<AllowRuleResult> {\n const result = await appendAllowlistRules(path, [ALLOW_RULE]);\n return {\n path: result.path,\n rule: ALLOW_RULE,\n added: result.added.length > 0,\n ...(result.warning !== undefined\n ? { warning: result.warning }\n : result.skipped !== undefined\n ? { warning: `${result.path} was left untouched (${result.skipped}).` }\n : {}),\n };\n}\n\n/**\n * RECONCILE, do not re-add blindly. `claude mcp add` is not idempotent: Claude\n * Code 2.1.280 exits 1 on a second identical add with \"MCP server x402 already\n * exists in .mcp.json\". Running it unconditionally therefore reported a\n * perfectly healthy machine as an unregistered one and printed a repair command\n * that would fail the same way, while a same-name entry launching something\n * else never converged, because `add` refuses to overwrite it.\n *\n * So the scope's own file is read first: an entry that already launches\n * `tenjin mcp` is the goal state and nothing is spawned, and a file that cannot\n * be read is refused out loud rather than written over.\n *\n * AN `x402` ENTRY THAT LAUNCHES SOMETHING ELSE IS SOMEBODY ELSE'S. This command\n * will not delete it. It may be another tool of the user's that happens to\n * share the name, and an installer that removes a registration nobody asked it\n * to touch has destroyed configuration to make its own output look tidy. The\n * conflict is reported with the exact two commands to run, and the user decides.\n */\nasync function registerMcpServer(\n deps: RouterInstallDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<McpRegistration> {\n const scope = mcpScope(project);\n const command = mcpAddCommand(project);\n const base = { name: MCP_SERVER_NAME, scope, command };\n const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n if (existing.state === 'ok') {\n return { ...base, registered: true, reconciled: 'already-registered' };\n }\n if (existing.state === 'unreadable') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n reason: `the ${scope}-scope registration file could not be read, so nothing was written over it`,\n };\n }\n // REFUSED, NOT REPLACED. Nothing of the user's is removed to make room.\n if (existing.state === 'wrong-command') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n command: `${mcpRemoveCommand(project)} && ${command}`,\n reason: `an MCP server named ${MCP_SERVER_NAME} is already registered at ${scope} scope and launches something else. This command will not remove a registration it did not write; run the two commands above if that entry is stale`,\n };\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (!which('claude')) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: 'the `claude` binary is not on PATH',\n };\n }\n try {\n await (deps.registerMcp ?? runClaudeMcpAdd)(command, { scope, cwd });\n return { ...base, registered: true, reconciled: 'added' };\n } catch (err) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport type McpEntryState = 'ok' | 'absent' | 'wrong-command' | 'unreadable';\n\n/**\n * What an entry named `x402` actually launches. The name proves nothing: a\n * stale entry pointing at another binary would read as a working request tool.\n */\nexport function classifyMcpEntry(entry: unknown): McpEntryState {\n if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) return 'absent';\n const { command, args } = entry as { command?: unknown; args?: unknown };\n if (typeof command !== 'string' || command.length === 0) return 'wrong-command';\n // The basename, so `/opt/homebrew/bin/tenjin` and a bare `tenjin` both pass.\n const binary = command.split(/[\\\\/]/).pop();\n const runsRouter =\n binary === 'tenjin' && Array.isArray(args) && args.length === 1 && args[0] === 'mcp';\n return runsRouter ? 'ok' : 'wrong-command';\n}\n\n/**\n * The file each scope writes: the project's own `.mcp.json`, or the user's\n * `~/.claude.json`. Neither can inherit from the other. Shared by `install`,\n * which reconciles against it, and `doctor`, which reports it.\n */\nexport async function readMcpEntry(\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n): Promise<{ found: boolean; state: McpEntryState }> {\n const path = scope === 'project' ? join(cwd, '.mcp.json') : join(home, '.claude.json');\n // ONLY \"it is not there\" is an absence. A permission or filesystem error on a\n // file that DOES exist says nothing about what is registered in it, and\n // treating it as missing sent the refresh on to `claude mcp add` over a\n // registration it had never read: a failed add then looked like a machine\n // that simply lacks the tooling, and `tenjin update` exited 0 over whatever\n // was actually in there.\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === 'ENOENT' || code === 'ENOTDIR') return { found: false, state: 'absent' };\n return { found: true, state: 'unreadable' };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // NOT an absence: the harness's own file is there and unreadable to this\n // build, so neither \"register it\" nor \"it is missing\" is a true statement.\n return { found: true, state: 'unreadable' };\n }\n const servers = (parsed as { mcpServers?: unknown } | null)?.mcpServers;\n if (servers === undefined) return { found: true, state: 'absent' };\n if (servers === null || typeof servers !== 'object' || Array.isArray(servers)) {\n return { found: true, state: 'unreadable' };\n }\n const entry = (servers as Record<string, unknown>)[MCP_SERVER_NAME];\n if (entry === undefined) return { found: true, state: 'absent' };\n return { found: true, state: classifyMcpEntry(entry) };\n}\n\n/** Project scope is decided by the working directory as well as the flag:\n * `claude` writes `.mcp.json` beside the project it was run in. */\nasync function runClaudeMcpAdd(\n _command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n): Promise<void> {\n await exec('claude', ['mcp', 'add', MCP_SERVER_NAME, '-s', opts.scope, '--', 'tenjin', 'mcp'], {\n timeout: 20_000,\n cwd: opts.cwd,\n });\n}\n\ninterface EffectiveLimits {\n maxAutoSpend: string;\n sessionBudget: string;\n}\n\nfunction effectiveLimits(policy: SpendPolicy): EffectiveLimits {\n return {\n maxAutoSpend: toMoney(policy.maxAutoSpendAtomic.toString()).usd,\n sessionBudget:\n policy.sessionBudgetAtomic === null\n ? 'no daily ceiling'\n : toMoney(policy.sessionBudgetAtomic.toString()).usd,\n };\n}\n\n/** Only the status-line state that needs the user: one this install would not\n * touch, with the command that adds the footer beside it. */\nexport function statusLineProblems(ctx: CommandContext, result: StatusLineResult): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n if (result.warning !== undefined) {\n return [warn(`The live status line was not registered (${result.warning})`)];\n }\n if (result.state !== 'foreign') return [];\n return [\n warn('You already have a status line, so it was left exactly as it is.'),\n ' To show the live x402 footer beside it, run:',\n ' tenjin install --status-line compose',\n ...(result.compose === undefined\n ? []\n : [' or set this command yourself:', ` ${result.compose}`]),\n ];\n}\n\n/**\n * A few lines a first-time user can read at a glance: it worked, here is your\n * wallet, here is the one thing to do next. The file paths, entry counts and\n * data-handling detail stay in `--json` and the docs; the terminal only grows\n * a line when something needs the user.\n */\nfunction lines(\n ctx: CommandContext,\n s: {\n project: boolean;\n hooks: HooksResult;\n permissions: AllowRuleResult;\n statusLine: StatusLineResult;\n mcp: McpRegistration;\n wallet: WalletOutcome;\n policy: SpendPolicy;\n },\n): string[] {\n const ok = paint(ctx.io, 'green', '✓');\n const limits = effectiveLimits(s.policy);\n const daily =\n s.policy.sessionBudgetAtomic === null ? 'no daily limit' : `$${limits.sessionBudget} a day`;\n // The first line only says \"set up\" when it is: a settings file this run\n // would not write to means nothing was set up, and hooks without the MCP\n // server point at a `request` tool that is not there.\n const blocked = s.hooks.skipped !== undefined;\n const needsMcp = !blocked && !s.mcp.registered;\n const where = s.project ? ' in this project' : '';\n const fund = paint(ctx.io, 'bold', 'tenjin wallet fund');\n return [\n blocked\n ? paint(ctx.io, 'yellow', `! Tenjin could not finish setting up Claude Code${where}`)\n : needsMcp\n ? paint(ctx.io, 'yellow', '! Almost done: Claude Code needs one command')\n : `${ok} Tenjin is set up for Claude Code${where}`,\n ...walletLines(ctx, ok, s.wallet),\n ` Automatic router: up to $${limits.maxAutoSpend} per call; daily limit ${daily}`,\n ...(s.statusLine.state === 'ours' || s.statusLine.state === 'composed'\n ? [' Live status line on: each lookup names its provider while it runs']\n : []),\n ...problems(ctx, s.hooks, s.permissions, s.statusLine, s.mcp),\n '',\n blocked\n ? 'Next: fix the file above, then run tenjin install again'\n : needsMcp\n ? s.wallet.status === 'created'\n ? `Next: run the command above and ${fund}, then restart Claude Code`\n : 'Next: run the command above, then restart Claude Code'\n : s.wallet.status === 'created'\n ? `Next: ${fund}, then restart Claude Code`\n : 'Next: restart Claude Code',\n ];\n}\n\n/** \"Up to date\" only when nothing below it needs the user. */\nfunction refreshLines(ctx: CommandContext, issues: string[]): string[] {\n if (issues.length === 0) return [`${paint(ctx.io, 'green', '✓')} Tenjin is up to date`];\n return [paint(ctx.io, 'yellow', '! Tenjin is updated, but needs one fix'), ...issues];\n}\n\nfunction walletLines(ctx: CommandContext, ok: string, w: WalletOutcome): string[] {\n if (w.status === 'created') return [`${ok} Wallet created: ${w.address}`];\n if (w.status === 'existing') return [`${ok} Wallet: ${w.address}`];\n if (w.reason === 'flag') return [' No wallet yet. Create one with: tenjin wallet create'];\n return [\n paint(ctx.io, 'yellow', `! No wallet was created. ${w.warning ?? ''}`.trimEnd()),\n ` ${w.fix ?? 'Create one with: tenjin wallet create'}`,\n ];\n}\n\n/** Only what needs the user, each with the command that fixes it. */\nfunction problems(\n ctx: CommandContext,\n hooks: HooksResult,\n permissions: AllowRuleResult,\n statusLine: StatusLineResult,\n mcp: McpRegistration,\n): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n const out: string[] = [];\n // The hooks and the permission rule share one settings file, so a file this\n // run would not touch is reported once, not once per writer.\n if (hooks.skipped !== undefined) {\n out.push(\n warn(\n hooks.warning ??\n `${hooks.path ?? 'Your Claude Code settings file'} was left untouched (${hooks.skipped}).`,\n ),\n );\n } else {\n if (hooks.warning !== undefined) out.push(warn(hooks.warning));\n if (permissions.warning !== undefined) out.push(warn(permissions.warning));\n }\n if (!mcp.registered) {\n // The reason stays in --json: raw exec output is noise here, the fix is not.\n out.push(warn('Could not add the request tool to Claude Code. Run:'));\n out.push(` ${mcp.command}`);\n }\n out.push(...statusLineProblems(ctx, statusLine));\n return out;\n}\n\n/**\n * THREE ANSWERS, NOT TWO. A settings file that cannot be read or parsed is not\n * a file without our entries, and collapsing the two let `refreshEveryInstall`\n * read a momentarily broken project settings file as confirmed absence and\n * strike the project off `install.routerProjects` for good: repairing the file\n * afterwards did not bring it back, so every later `tenjin update` from HOME\n * silently skipped it.\n */\ntype EntriesProbe =\n { state: 'present' } | { state: 'absent' } | { state: 'unreadable'; reason: string };\n\nasync function probeOurEntries(path: string, dataDir: string): Promise<EntriesProbe> {\n const found = await inspectHooksFile(path);\n if ('refusal' in found) {\n // `unreadable` here is the inspection's own vocabulary for \"the file exists\n // and this build could not use it\"; a file that is simply not there comes\n // back as an empty, readable inspection rather than a refusal.\n return { state: 'unreadable', reason: found.refusal.reason };\n }\n const present = Object.values(found.hooks).some((list) =>\n list.some((entry) => ownsHookEntry(entry, dataDir)),\n );\n return present ? { state: 'present' } : { state: 'absent' };\n}\n\n/** Shared with `uninstall`: the prune this module's writer already performs. */\nexport { pruneHooks };\n","import { lstatSync } from 'node:fs';\nimport { readdir, rm, rmdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { readSkillFile, skillFrontmatterName, skillsDirsFor } from './skill-wiring';\nimport { RETIRED_SKILL_NAMES } from './skills-source';\nimport { hasCode } from './errno';\n\nfunction isRealDirectory(path: string): boolean {\n try {\n return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n } catch (err) {\n // Linux reports ENOTDIR when an ancestor is a regular file. Nothing can\n // be installed below it, just as with an absent path. Do not follow symlinks.\n if (hasCode(err, 'ENOENT') || hasCode(err, 'ENOTDIR')) return false;\n throw err;\n }\n}\n\n/** Remove only our named skill file; preserve foreign skills and adjacent user files. */\nexport async function removeOwnedSkill(\n name: string,\n skillsDir: string,\n): Promise<{ changed: boolean }> {\n if (!isRealDirectory(skillsDir)) {\n return { changed: false };\n }\n const skillDir = join(skillsDir, name);\n if (!isRealDirectory(skillDir)) {\n return { changed: false };\n }\n const path = join(skillDir, 'SKILL.md');\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return { changed: false };\n if (read.kind !== 'ok' || skillFrontmatterName(read.bytes.toString('utf8')) !== name) {\n return { changed: false }; // not ours to delete for sitting at our path\n }\n await rm(path, { force: true });\n const rest = await readdir(skillDir).catch(() => null);\n if (rest !== null && rest.length === 0) await rmdir(skillDir).catch(() => undefined);\n return { changed: true };\n}\n\n/** Refresh retires obsolete skills without needing their old packaged source. */\nexport async function removeRetiredSkills(home: string, project?: string): Promise<string[]> {\n const removed: string[] = [];\n const dirs = [...skillsDirsFor(home), ...(project ? skillsDirsFor(project) : [])];\n for (const dir of new Set(dirs)) {\n for (const name of RETIRED_SKILL_NAMES) {\n if ((await removeOwnedSkill(name, dir)).changed) removed.push(join(dir, name));\n }\n }\n return removed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,UAAU,gBAAgB;AACnC,SAAS,eAAe;AACxB,SAAS,YAAY,QAAAA,aAAY;AACjC,SAAS,iBAAiB;;;ACJ1B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,IAAI,aAAa;AACnC,SAAS,YAAY;AAKrB,SAAS,gBAAgB,MAAuB;AAC9C,MAAI;AACF,WAAO,UAAU,MAAM,EAAE,gBAAgB,MAAM,CAAC,GAAG,YAAY,MAAM;AAAA,EACvE,SAAS,KAAK;AAGZ,QAAI,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,SAAS,EAAG,QAAO;AAC9D,UAAM;AAAA,EACR;AACF;AAGA,eAAsB,iBACpB,MACA,WAC+B;AAC/B,MAAI,CAAC,gBAAgB,SAAS,GAAG;AAC/B,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM,WAAW,KAAK,WAAW,IAAI;AACrC,MAAI,CAAC,gBAAgB,QAAQ,GAAG;AAC9B,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM,OAAO,KAAK,UAAU,UAAU;AACtC,QAAM,OAAO,MAAM,cAAc,IAAI;AACrC,MAAI,KAAK,SAAS,SAAU,QAAO,EAAE,SAAS,MAAM;AACpD,MAAI,KAAK,SAAS,QAAQ,qBAAqB,KAAK,MAAM,SAAS,MAAM,CAAC,MAAM,MAAM;AACpF,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM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