tenjin-cli 0.1.0-alpha.32 → 0.1.0-alpha.33

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 (165) hide show
  1. package/README.md +42 -23
  2. package/dist/{_esm-RLLC72MS.js → _esm-BIN7VY2L.js} +2 -2
  3. package/dist/{alive-MROUMFH3.js → alive-GSOWKUOY.js} +4 -4
  4. package/dist/{auto-update-OPWMRZLS.js → auto-update-Y24UL56V.js} +5 -3
  5. package/dist/{chunk-2GNOFONN.js → chunk-2M2VPI2E.js} +2 -2
  6. package/dist/chunk-2M2VPI2E.js.map +1 -0
  7. package/dist/{chunk-VUGQTZ2L.js → chunk-2RWB7RKE.js} +89 -33
  8. package/dist/chunk-2RWB7RKE.js.map +1 -0
  9. package/dist/{chunk-OTWLERSW.js → chunk-36RVGZNY.js} +2 -2
  10. package/dist/{chunk-B7EM4GGF.js → chunk-3GNJXKIT.js} +2 -2
  11. package/dist/{chunk-DRDUIZIA.js → chunk-4K7TQHNP.js} +4 -4
  12. package/dist/{chunk-SYOS5CAC.js → chunk-4YOZGGTZ.js} +73 -2
  13. package/dist/chunk-4YOZGGTZ.js.map +1 -0
  14. package/dist/{chunk-AD226HDR.js → chunk-A5GKIG5O.js} +5 -5
  15. package/dist/{chunk-JEVQ5LKO.js → chunk-AGMVASXZ.js} +3 -3
  16. package/dist/{chunk-ADV4LDTB.js → chunk-BF4XHEQK.js} +12 -2
  17. package/dist/chunk-BF4XHEQK.js.map +1 -0
  18. package/dist/{chunk-IDTRSAHE.js → chunk-C2Q76BVM.js} +48 -49
  19. package/dist/chunk-C2Q76BVM.js.map +1 -0
  20. package/dist/{chunk-VJUVFZ2D.js → chunk-FVIGCDSV.js} +1 -1
  21. package/dist/chunk-FVIGCDSV.js.map +1 -0
  22. package/dist/{chunk-QF3LSMGS.js → chunk-GTTUCOPD.js} +2 -2
  23. package/dist/{chunk-3DIL66VX.js → chunk-HGGWCP7W.js} +2 -2
  24. package/dist/{chunk-D5TOQSO4.js → chunk-HMWYAUA6.js} +10 -6
  25. package/dist/{chunk-D5TOQSO4.js.map → chunk-HMWYAUA6.js.map} +1 -1
  26. package/dist/{chunk-445VQTVM.js → chunk-IE7P2BZE.js} +2 -2
  27. package/dist/{chunk-VOZA6O7K.js → chunk-ILNIZ5I2.js} +190 -96
  28. package/dist/chunk-ILNIZ5I2.js.map +1 -0
  29. package/dist/{chunk-TF5HCP33.js → chunk-INTFHMU4.js} +4 -4
  30. package/dist/{chunk-HREHWL32.js → chunk-J57UC3DD.js} +2 -2
  31. package/dist/{chunk-AV5NZMYO.js → chunk-KM7RY2ZS.js} +2 -2
  32. package/dist/{chunk-TAW4UFFF.js → chunk-L6JEXB3E.js} +132 -132
  33. package/dist/chunk-L6JEXB3E.js.map +1 -0
  34. package/dist/{chunk-E7LGOMH6.js → chunk-LRW6S53P.js} +4 -3
  35. package/dist/chunk-LRW6S53P.js.map +1 -0
  36. package/dist/{chunk-PKHI276N.js → chunk-LXAYUOXI.js} +18 -9
  37. package/dist/chunk-LXAYUOXI.js.map +1 -0
  38. package/dist/{chunk-WOM257PW.js → chunk-NDGZDTSJ.js} +3 -3
  39. package/dist/{chunk-SFASB5FL.js → chunk-P3LFTKE7.js} +3 -14
  40. package/dist/chunk-P3LFTKE7.js.map +1 -0
  41. package/dist/{chunk-YUY4SAGM.js → chunk-RVPYTUP4.js} +5 -5
  42. package/dist/chunk-RVPYTUP4.js.map +1 -0
  43. package/dist/{chunk-GAKUQHKA.js → chunk-TC2WZLSC.js} +3 -3
  44. package/dist/{chunk-D3ZURCG7.js → chunk-TKPF35W6.js} +2 -2
  45. package/dist/{chunk-I5TDIUKM.js → chunk-U3IKUGRP.js} +23 -5
  46. package/dist/chunk-U3IKUGRP.js.map +1 -0
  47. package/dist/{chunk-BI673VEJ.js → chunk-UXZONNEQ.js} +3 -3
  48. package/dist/{chunk-PJNENX2A.js → chunk-WFSPCCVW.js} +2 -2
  49. package/dist/{chunk-PJNENX2A.js.map → chunk-WFSPCCVW.js.map} +1 -1
  50. package/dist/{chunk-DW4YTVR3.js → chunk-WXA2BWTE.js} +6 -2
  51. package/dist/chunk-WXA2BWTE.js.map +1 -0
  52. package/dist/{chunk-JRZBBPO6.js → chunk-ZDZERB6L.js} +56 -228
  53. package/dist/chunk-ZDZERB6L.js.map +1 -0
  54. package/dist/{chunk-G75OPGAK.js → chunk-ZNNXRNFD.js} +5 -3
  55. package/dist/chunk-ZNNXRNFD.js.map +1 -0
  56. package/dist/{chunk-CISYM4EO.js → chunk-ZURZHELF.js} +2 -2
  57. package/dist/{cli-FB4LOA5A.js → cli-E36SPKBW.js} +44 -44
  58. package/dist/{cli-FB4LOA5A.js.map → cli-E36SPKBW.js.map} +1 -1
  59. package/dist/{codex-event-TYVES3UX.js → codex-event-ZO2GEFE6.js} +2 -2
  60. package/dist/{codex-host-WW4H2SKT.js → codex-host-KECJVTA2.js} +3 -3
  61. package/dist/{codex-install-2C623HPW.js → codex-install-HQZDGFXW.js} +90 -47
  62. package/dist/codex-install-HQZDGFXW.js.map +1 -0
  63. package/dist/{config-HOVJFEKD.js → config-HY2E4GGW.js} +8 -8
  64. package/dist/{doctor-NKU4V5OV.js → doctor-I6XQEKWD.js} +42 -31
  65. package/dist/doctor-I6XQEKWD.js.map +1 -0
  66. package/dist/{fund-WEBHTZGN.js → fund-2QRO7OJL.js} +16 -11
  67. package/dist/{fund-WEBHTZGN.js.map → fund-2QRO7OJL.js.map} +1 -1
  68. package/dist/{hook-command-ZA2PNKS6.js → hook-command-2UBCSZG6.js} +12 -13
  69. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  70. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  71. package/dist/hosts/claude/tenjin/hooks/register.tsx +51 -11
  72. package/dist/hosts/claude/tenjin/types/index.d.ts +2 -1
  73. package/dist/{hosts-AV5MHBAU.js → hosts-DVQJ32QC.js} +2 -2
  74. package/dist/index.js +16 -15
  75. package/dist/index.js.map +1 -1
  76. package/dist/{install-PT4EZS4R.js → install-ILUX5C4A.js} +24 -17
  77. package/dist/{install-identity-5A4OE6YC.js → install-identity-TZKGY6LQ.js} +7 -7
  78. package/dist/{install-wallet-SAAPKB73.js → install-wallet-5M4OTYLX.js} +13 -13
  79. package/dist/isows-native-Q2UDIVPT.js +9 -0
  80. package/dist/isows-native-Q2UDIVPT.js.map +1 -0
  81. package/dist/{mcp-HAWKCTPQ.js → mcp-LE4DUS22.js} +23 -24
  82. package/dist/{mcp-HAWKCTPQ.js.map → mcp-LE4DUS22.js.map} +1 -1
  83. package/dist/{package-SR2WB6MK.js → package-IJFGMWEV.js} +2 -2
  84. package/dist/{pay-OXC3WKYV.js → pay-WCG3IH4R.js} +13 -13
  85. package/dist/{payments-3KHMP2MG.js → payments-HFPPWHTV.js} +6 -6
  86. package/dist/{plugin-registration-N3GRIZVM.js → plugin-registration-PZFI5GZW.js} +18 -17
  87. package/dist/{runtime-UVNUA3AS.js → runtime-UZOKSUZX.js} +145 -27
  88. package/dist/runtime-UZOKSUZX.js.map +1 -0
  89. package/dist/{runtime-fetch-EKFRNR6Z.js → runtime-fetch-ZSSSK72Y.js} +5 -2
  90. package/dist/{runtime-layout-BDWZG2TQ.js → runtime-layout-WIDILZ6K.js} +2 -2
  91. package/dist/{send-HMKJLT34.js → send-GCVEAQKL.js} +8 -8
  92. package/dist/{status-RWXIIWYS.js → status-HCVAOCN7.js} +10 -10
  93. package/dist/{status-line-77XYZP7E.js → status-line-OPCXDHL2.js} +6 -6
  94. package/dist/{uninstall-D5G67UJH.js → uninstall-BAWRBXXQ.js} +19 -18
  95. package/dist/{uninstall-D5G67UJH.js.map → uninstall-BAWRBXXQ.js.map} +1 -1
  96. package/dist/{update-LRNOEGSB.js → update-CACXLQLR.js} +20 -17
  97. package/dist/{usdc-D6X7EIQ2.js → usdc-VG4CIOUK.js} +4 -4
  98. package/dist/{viemAdapter-By13KInL-RL742ETX.js → viemAdapter-By13KInL-DOFTEIJV.js} +2 -2
  99. package/dist/{wallet-XFYC27BR.js → wallet-QL4UUXEZ.js} +11 -11
  100. package/docs/agent-permissions.md +16 -12
  101. package/docs/troubleshooting.md +5 -5
  102. package/package.json +4 -4
  103. package/scripts/installers/install.ps1 +67 -0
  104. package/scripts/installers/install.sh +68 -0
  105. package/dist/_esm-C5CRWCYU.js +0 -3737
  106. package/dist/_esm-C5CRWCYU.js.map +0 -1
  107. package/dist/chunk-2GNOFONN.js.map +0 -1
  108. package/dist/chunk-ADV4LDTB.js.map +0 -1
  109. package/dist/chunk-DW4YTVR3.js.map +0 -1
  110. package/dist/chunk-E7LGOMH6.js.map +0 -1
  111. package/dist/chunk-G75OPGAK.js.map +0 -1
  112. package/dist/chunk-I5TDIUKM.js.map +0 -1
  113. package/dist/chunk-IDTRSAHE.js.map +0 -1
  114. package/dist/chunk-JRZBBPO6.js.map +0 -1
  115. package/dist/chunk-PKHI276N.js.map +0 -1
  116. package/dist/chunk-SFASB5FL.js.map +0 -1
  117. package/dist/chunk-SYOS5CAC.js.map +0 -1
  118. package/dist/chunk-TAW4UFFF.js.map +0 -1
  119. package/dist/chunk-VJUVFZ2D.js.map +0 -1
  120. package/dist/chunk-VOZA6O7K.js.map +0 -1
  121. package/dist/chunk-VUGQTZ2L.js.map +0 -1
  122. package/dist/chunk-YUY4SAGM.js.map +0 -1
  123. package/dist/codex-install-2C623HPW.js.map +0 -1
  124. package/dist/doctor-NKU4V5OV.js.map +0 -1
  125. package/dist/runtime-UVNUA3AS.js.map +0 -1
  126. /package/dist/{_esm-RLLC72MS.js.map → _esm-BIN7VY2L.js.map} +0 -0
  127. /package/dist/{alive-MROUMFH3.js.map → alive-GSOWKUOY.js.map} +0 -0
  128. /package/dist/{auto-update-OPWMRZLS.js.map → auto-update-Y24UL56V.js.map} +0 -0
  129. /package/dist/{chunk-OTWLERSW.js.map → chunk-36RVGZNY.js.map} +0 -0
  130. /package/dist/{chunk-B7EM4GGF.js.map → chunk-3GNJXKIT.js.map} +0 -0
  131. /package/dist/{chunk-DRDUIZIA.js.map → chunk-4K7TQHNP.js.map} +0 -0
  132. /package/dist/{chunk-AD226HDR.js.map → chunk-A5GKIG5O.js.map} +0 -0
  133. /package/dist/{chunk-JEVQ5LKO.js.map → chunk-AGMVASXZ.js.map} +0 -0
  134. /package/dist/{chunk-QF3LSMGS.js.map → chunk-GTTUCOPD.js.map} +0 -0
  135. /package/dist/{chunk-3DIL66VX.js.map → chunk-HGGWCP7W.js.map} +0 -0
  136. /package/dist/{chunk-445VQTVM.js.map → chunk-IE7P2BZE.js.map} +0 -0
  137. /package/dist/{chunk-TF5HCP33.js.map → chunk-INTFHMU4.js.map} +0 -0
  138. /package/dist/{chunk-HREHWL32.js.map → chunk-J57UC3DD.js.map} +0 -0
  139. /package/dist/{chunk-AV5NZMYO.js.map → chunk-KM7RY2ZS.js.map} +0 -0
  140. /package/dist/{chunk-WOM257PW.js.map → chunk-NDGZDTSJ.js.map} +0 -0
  141. /package/dist/{chunk-GAKUQHKA.js.map → chunk-TC2WZLSC.js.map} +0 -0
  142. /package/dist/{chunk-D3ZURCG7.js.map → chunk-TKPF35W6.js.map} +0 -0
  143. /package/dist/{chunk-BI673VEJ.js.map → chunk-UXZONNEQ.js.map} +0 -0
  144. /package/dist/{chunk-CISYM4EO.js.map → chunk-ZURZHELF.js.map} +0 -0
  145. /package/dist/{codex-event-TYVES3UX.js.map → codex-event-ZO2GEFE6.js.map} +0 -0
  146. /package/dist/{codex-host-WW4H2SKT.js.map → codex-host-KECJVTA2.js.map} +0 -0
  147. /package/dist/{config-HOVJFEKD.js.map → config-HY2E4GGW.js.map} +0 -0
  148. /package/dist/{hook-command-ZA2PNKS6.js.map → hook-command-2UBCSZG6.js.map} +0 -0
  149. /package/dist/{hosts-AV5MHBAU.js.map → hosts-DVQJ32QC.js.map} +0 -0
  150. /package/dist/{install-PT4EZS4R.js.map → install-ILUX5C4A.js.map} +0 -0
  151. /package/dist/{install-identity-5A4OE6YC.js.map → install-identity-TZKGY6LQ.js.map} +0 -0
  152. /package/dist/{install-wallet-SAAPKB73.js.map → install-wallet-5M4OTYLX.js.map} +0 -0
  153. /package/dist/{package-SR2WB6MK.js.map → package-IJFGMWEV.js.map} +0 -0
  154. /package/dist/{pay-OXC3WKYV.js.map → pay-WCG3IH4R.js.map} +0 -0
  155. /package/dist/{payments-3KHMP2MG.js.map → payments-HFPPWHTV.js.map} +0 -0
  156. /package/dist/{plugin-registration-N3GRIZVM.js.map → plugin-registration-PZFI5GZW.js.map} +0 -0
  157. /package/dist/{runtime-fetch-EKFRNR6Z.js.map → runtime-fetch-ZSSSK72Y.js.map} +0 -0
  158. /package/dist/{runtime-layout-BDWZG2TQ.js.map → runtime-layout-WIDILZ6K.js.map} +0 -0
  159. /package/dist/{send-HMKJLT34.js.map → send-GCVEAQKL.js.map} +0 -0
  160. /package/dist/{status-RWXIIWYS.js.map → status-HCVAOCN7.js.map} +0 -0
  161. /package/dist/{status-line-77XYZP7E.js.map → status-line-OPCXDHL2.js.map} +0 -0
  162. /package/dist/{update-LRNOEGSB.js.map → update-CACXLQLR.js.map} +0 -0
  163. /package/dist/{usdc-D6X7EIQ2.js.map → usdc-VG4CIOUK.js.map} +0 -0
  164. /package/dist/{viemAdapter-By13KInL-RL742ETX.js.map → viemAdapter-By13KInL-DOFTEIJV.js.map} +0 -0
  165. /package/dist/{wallet-XFYC27BR.js.map → wallet-QL4UUXEZ.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  codexResponse,
4
4
  codexRouterEvent,
5
5
  codexSession
6
- } from "./chunk-SFASB5FL.js";
6
+ } from "./chunk-P3LFTKE7.js";
7
7
  import "./chunk-3623BLPV.js";
8
8
  import "./chunk-XKESD27X.js";
9
9
  import "./chunk-3UCIG4TG.js";
@@ -13,4 +13,4 @@ export {
13
13
  codexRouterEvent,
14
14
  codexSession
15
15
  };
16
- //# sourceMappingURL=codex-event-TYVES3UX.js.map
16
+ //# sourceMappingURL=codex-event-ZO2GEFE6.js.map
@@ -8,10 +8,10 @@ import {
8
8
  codexVersion,
9
9
  listCodexHooks,
10
10
  readCodexConfig
11
- } from "./chunk-3DIL66VX.js";
11
+ } from "./chunk-HGGWCP7W.js";
12
12
  import "./chunk-E7SW44LM.js";
13
13
  import "./chunk-F3ED5WTR.js";
14
- import "./chunk-E7LGOMH6.js";
14
+ import "./chunk-LRW6S53P.js";
15
15
  import "./chunk-UUGOUOVT.js";
16
16
  import "./chunk-MPZUYCAP.js";
17
17
  import "./chunk-XQJXNMSB.js";
@@ -26,4 +26,4 @@ export {
26
26
  listCodexHooks,
27
27
  readCodexConfig
28
28
  };
29
- //# sourceMappingURL=codex-host-WW4H2SKT.js.map
29
+ //# sourceMappingURL=codex-host-KECJVTA2.js.map
@@ -8,39 +8,42 @@ import {
8
8
  codexVersion,
9
9
  listCodexHooks,
10
10
  readCodexConfig
11
- } from "./chunk-3DIL66VX.js";
11
+ } from "./chunk-HGGWCP7W.js";
12
12
  import {
13
13
  readInstalledHosts,
14
14
  withNote
15
- } from "./chunk-TF5HCP33.js";
15
+ } from "./chunk-INTFHMU4.js";
16
16
  import {
17
17
  NOTHING_TO_REFRESH,
18
18
  approveLimits,
19
+ assertPluginInstallation,
20
+ continuationCommand,
19
21
  defaultRuntime,
20
22
  effectiveLimits,
21
23
  hasRuntime,
22
24
  namedLimits,
25
+ requireRuntime,
23
26
  runtimeData,
24
27
  runtimeLines,
25
28
  spendStepFor,
26
29
  tilde,
27
30
  versionFreeEntry
28
- } from "./chunk-VOZA6O7K.js";
29
- import "./chunk-I5TDIUKM.js";
31
+ } from "./chunk-ILNIZ5I2.js";
32
+ import "./chunk-U3IKUGRP.js";
30
33
  import "./chunk-KOGZDMHO.js";
31
- import "./chunk-PKHI276N.js";
32
- import "./chunk-B7EM4GGF.js";
34
+ import "./chunk-LXAYUOXI.js";
35
+ import "./chunk-3GNJXKIT.js";
33
36
  import {
34
37
  EVENT_LABEL,
35
38
  persistRouterDefaults,
36
39
  rowsOf,
37
40
  shownLimits,
38
41
  trustCodexHooks
39
- } from "./chunk-AD226HDR.js";
42
+ } from "./chunk-A5GKIG5O.js";
40
43
  import "./chunk-4LMUQMBH.js";
41
44
  import "./chunk-3623BLPV.js";
42
45
  import "./chunk-XKESD27X.js";
43
- import "./chunk-VJUVFZ2D.js";
46
+ import "./chunk-FVIGCDSV.js";
44
47
  import "./chunk-HDPUXS3Z.js";
45
48
  import "./chunk-2SNUOHAT.js";
46
49
  import {
@@ -48,34 +51,35 @@ import {
48
51
  } from "./chunk-E7SW44LM.js";
49
52
  import "./chunk-F3ED5WTR.js";
50
53
  import "./chunk-DOQGNFHM.js";
51
- import "./chunk-TAW4UFFF.js";
54
+ import "./chunk-L6JEXB3E.js";
52
55
  import {
53
56
  CODEX_MCP_HOOKS_VERSION,
54
57
  renderCodexHooks
55
- } from "./chunk-E7LGOMH6.js";
58
+ } from "./chunk-LRW6S53P.js";
56
59
  import "./chunk-MEFB5KHA.js";
57
60
  import "./chunk-UUGOUOVT.js";
58
61
  import "./chunk-MPZUYCAP.js";
62
+ import "./chunk-4YOZGGTZ.js";
59
63
  import "./chunk-3FMZGI7I.js";
60
- import "./chunk-OTWLERSW.js";
64
+ import "./chunk-36RVGZNY.js";
61
65
  import "./chunk-QXP3Z3JN.js";
62
66
  import {
63
67
  package_default
64
- } from "./chunk-YUY4SAGM.js";
65
- import "./chunk-JEVQ5LKO.js";
68
+ } from "./chunk-RVPYTUP4.js";
69
+ import "./chunk-AGMVASXZ.js";
66
70
  import {
67
71
  resolveContextSettings
68
- } from "./chunk-AV5NZMYO.js";
72
+ } from "./chunk-KM7RY2ZS.js";
69
73
  import "./chunk-Y527D4TV.js";
70
- import "./chunk-WOM257PW.js";
74
+ import "./chunk-NDGZDTSJ.js";
71
75
  import "./chunk-BFDQ4WNW.js";
72
76
  import "./chunk-3AIHRXKO.js";
73
77
  import "./chunk-X5ZBP3IY.js";
74
78
  import "./chunk-2I4QTOLB.js";
75
79
  import {
76
80
  loadRawConfig
77
- } from "./chunk-2GNOFONN.js";
78
- import "./chunk-DW4YTVR3.js";
81
+ } from "./chunk-2M2VPI2E.js";
82
+ import "./chunk-WXA2BWTE.js";
79
83
  import "./chunk-XQJXNMSB.js";
80
84
  import "./chunk-SNNSAGMT.js";
81
85
  import "./chunk-7WEQQJLG.js";
@@ -84,8 +88,8 @@ import {
84
88
  } from "./chunk-3UCIG4TG.js";
85
89
  import {
86
90
  autoUpdateLine
87
- } from "./chunk-ADV4LDTB.js";
88
- import "./chunk-G75OPGAK.js";
91
+ } from "./chunk-BF4XHEQK.js";
92
+ import "./chunk-ZNNXRNFD.js";
89
93
  import "./chunk-EDJWHDDL.js";
90
94
  import {
91
95
  runtimeDir
@@ -134,23 +138,50 @@ function runtimeHosts(rt) {
134
138
  const hosts = join(rt.root, "codex");
135
139
  return existsSync(join(hosts, ".agents", "plugins", "marketplace.json")) ? hosts : null;
136
140
  }
137
- async function addPlugin(run, hosts, registered) {
138
- if (hosts === null) {
139
- throw new CliError(
140
- "INTERNAL",
141
- "This build carries no Codex plugin folder (dist/hosts/codex).",
142
- {
143
- fix: "Reinstall a published build: npm i -g tenjin-cli"
141
+ async function addPlugin(run, hosts, registered, previousEnabled, restoreRuntime) {
142
+ let removed = false;
143
+ let added = false;
144
+ const moved = typeof registered === "string" && hosts !== null && resolve(registered) !== resolve(hosts);
145
+ try {
146
+ if (hosts === null)
147
+ throw new CliError("UPDATE_FAILED", "The verified runtime carries no Codex plugin folder.");
148
+ if (moved) {
149
+ const old = await run(["plugin", "marketplace", "remove", CODEX_MARKETPLACE]);
150
+ removed = old.code === 0;
151
+ }
152
+ const market = await run(["plugin", "marketplace", "add", hosts, "--json"]);
153
+ if (market.code !== 0) throw failed("plugin marketplace add", market);
154
+ added = true;
155
+ const plugin = await run(["plugin", "add", CODEX_PLUGIN, "--json"]);
156
+ if (plugin.code !== 0) throw failed("plugin add", plugin);
157
+ } catch (error) {
158
+ try {
159
+ await restoreRuntime?.();
160
+ const restore = async (args) => {
161
+ const out = await run(args);
162
+ if (out.code !== 0) throw failed(args.join(" "), out);
163
+ };
164
+ if (added && (moved || typeof registered !== "string")) {
165
+ await restore(["plugin", "marketplace", "remove", CODEX_MARKETPLACE]);
144
166
  }
145
- );
146
- }
147
- if (typeof registered === "string" && resolve(registered) !== resolve(hosts)) {
148
- await run(["plugin", "marketplace", "remove", CODEX_MARKETPLACE]);
167
+ if (moved && (removed || added) && typeof registered === "string") {
168
+ await restore(["plugin", "marketplace", "add", registered, "--json"]);
169
+ }
170
+ if (previousEnabled && (removed || added)) {
171
+ await restore(["plugin", "add", CODEX_PLUGIN, "--json"]);
172
+ }
173
+ } catch {
174
+ throw new CliError(
175
+ "UPDATE_FAILED",
176
+ "Codex plugin registration failed and the previous registration could not be fully restored.",
177
+ {
178
+ fix: "Run tenjin install --harness codex again. Your payment keys and funds were kept.",
179
+ cause: error
180
+ }
181
+ );
182
+ }
183
+ throw error;
149
184
  }
150
- const market = await run(["plugin", "marketplace", "add", hosts, "--json"]);
151
- if (market.code !== 0) throw failed("plugin marketplace add", market);
152
- const plugin = await run(["plugin", "add", CODEX_PLUGIN, "--json"]);
153
- if (plugin.code !== 0) throw failed("plugin add", plugin);
154
185
  }
155
186
  var TRUST_STEP = "Open Codex, run /hooks and trust the five Tenjin hooks, then start a new session.";
156
187
  var CODEX_TOO_OLD = `Routing in Codex needs Codex ${CODEX_MCP_HOOKS_VERSION} or later, so Tenjin left its Codex plugin as it was. Ask your agent to update Codex.`;
@@ -221,7 +252,8 @@ async function refreshCodexPlugin(ctx, deps = {}) {
221
252
  await addPlugin(
222
253
  deps.run ?? runCodex,
223
254
  hosts,
224
- at(config, "marketplaces", CODEX_MARKETPLACE, "source")
255
+ at(config, "marketplaces", CODEX_MARKETPLACE, "source"),
256
+ at(config, "plugins", CODEX_PLUGIN, "enabled") === true
225
257
  );
226
258
  return await trustPlugin(deps) ? CODEX_REFRESH_LINES.done : CODEX_REFRESH_LINES.review;
227
259
  } catch {
@@ -237,6 +269,7 @@ async function runCodexInstall(args, ctx, deps = {}) {
237
269
  userScopeOnly(args);
238
270
  const run = deps.run ?? runCodex;
239
271
  const home = deps.homeDir ?? homedir();
272
+ assertPluginInstallation(ctx.dataDir, home, deps.env ?? process.env);
240
273
  const config = await loadRawConfig(ctx.dataDir);
241
274
  const named = namedLimits(args);
242
275
  const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
@@ -244,14 +277,6 @@ async function runCodexInstall(args, ctx, deps = {}) {
244
277
  const answered = args.yes === true || named.keys.length > 0;
245
278
  const unasked = config.maxAutoSpend === void 0 && config.sessionBudget === void 0;
246
279
  const limits = named.keys.length > 0 ? { ...shownLimits(config), ...named.limits } : args.yes === true ? shownLimits(config) : canPrompt && unasked ? await approveLimits(deps) : {};
247
- const { resolveWallet, walletValue } = await import("./install-wallet-SAAPKB73.js");
248
- const wallet = await resolveWallet(
249
- ctx,
250
- deps,
251
- args.noWallet === true ? "flag" : void 0,
252
- false
253
- );
254
- const spend = await persistRouterDefaults(ctx.dataDir, false, limits, named.keys);
255
280
  const rt = await (deps.runtime ?? defaultRuntime)({
256
281
  dataDir: ctx.dataDir,
257
282
  home,
@@ -260,18 +285,36 @@ async function runCodexInstall(args, ctx, deps = {}) {
260
285
  moduleDir: dirname(fileURLToPath(import.meta.url)),
261
286
  refresh: false
262
287
  });
288
+ requireRuntime(rt);
289
+ const { resolveWallet, walletValue } = await import("./install-wallet-5M4OTYLX.js");
290
+ const wallet = await resolveWallet(
291
+ ctx,
292
+ deps,
293
+ args.noWallet === true ? "flag" : void 0,
294
+ false
295
+ );
296
+ const spend = await persistRouterDefaults(ctx.dataDir, false, limits, named.keys);
263
297
  const fromRuntime = runtimeHosts(rt);
264
- const hosts = fromRuntime ?? (deps.hostsDir === void 0 ? await codexHostsDir() : deps.hostsDir);
298
+ const hosts = rt.state === "skipped" ? deps.hostsDir === void 0 ? await codexHostsDir() : deps.hostsDir : fromRuntime;
265
299
  const version = await (deps.version ?? codexVersion)();
266
300
  const tooOld = version !== null && !codexAtLeast(version, CODEX_MCP_HOOKS_VERSION);
267
301
  let next = CODEX_TOO_OLD;
268
302
  if (!tooOld) {
269
303
  const codexConfig = await (deps.config ?? (() => readCodexConfig(process.cwd(), 3e3)))();
270
- await addPlugin(run, hosts, at(codexConfig, "marketplaces", CODEX_MARKETPLACE, "source"));
304
+ await addPlugin(
305
+ run,
306
+ hosts,
307
+ at(codexConfig, "marketplaces", CODEX_MARKETPLACE, "source"),
308
+ at(codexConfig, "plugins", CODEX_PLUGIN, "enabled") === true,
309
+ rt.restore
310
+ );
271
311
  next = await trustPlugin(deps).catch(() => false) ? NEW_SESSION_STEP : TRUST_STEP;
272
312
  }
273
313
  const effective = effectiveLimits((await resolveContextSettings(ctx)).policy);
274
- const install = ["tenjin install", ...args.noWallet ? ["--no-wallet"] : []].join(" ");
314
+ const install = [
315
+ `${continuationCommand(rt)} install`,
316
+ ...args.noWallet ? ["--no-wallet"] : []
317
+ ].join(" ");
275
318
  const spendAsk = !canPrompt && !answered && unasked ? spendStepFor(install) : void 0;
276
319
  const daily = effective.sessionBudget === "no daily ceiling" ? "no daily limit" : `$${effective.sessionBudget} a day`;
277
320
  return {
@@ -390,4 +433,4 @@ export {
390
433
  runCodexInstall,
391
434
  runCodexUninstall
392
435
  };
393
- //# sourceMappingURL=codex-install-2C623HPW.js.map
436
+ //# sourceMappingURL=codex-install-HQZDGFXW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/codex-install.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport pkg from '../../package.json';\nimport { persistRouterDefaults } from '../commands/config';\nimport { versionFreeEntry } from '../commands/update';\nimport type { WalletDeps, WalletOutcome } from '../commands/install-wallet';\nimport { autoUpdateLine } from '../lib/auto-update';\nimport { resolveCodex } from '../lib/codex-bin';\nimport { loadRawConfig } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { runtimeDir } from '../lib/paths';\nimport type { RuntimeSetup, setupRuntime } from '../lib/runtime';\nimport type { CommandContext, CommandResult } from '../context';\nimport {\n at,\n CODEX_MARKETPLACE,\n CODEX_PLUGIN,\n codexHookRows,\n codexVersion,\n listCodexHooks,\n readCodexConfig,\n type CodexHookRows,\n WEB_VERIFIED_VERSION,\n} from './codex-host';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n approveLimits,\n assertPluginInstallation,\n continuationCommand,\n requireRuntime,\n defaultRuntime,\n effectiveLimits,\n hasRuntime,\n namedLimits,\n NOTHING_TO_REFRESH,\n runtimeData,\n runtimeLines,\n spendStepFor,\n tilde,\n type QuestionStep,\n type RouterInstallDeps,\n} from './install';\nimport { EVENT_LABEL, rowsOf, trustCodexHooks, type ListedHook } from '../lib/codex-trust';\nimport { readInstalledHosts, withNote } from './hosts';\nimport { CODEX_MCP_HOOKS_VERSION, renderCodexHooks } from './plugin-files';\nimport { shownLimits } from './spend-question';\n\n/**\n * `tenjin install|uninstall|doctor` for Codex. Codex's own commands do\n * every plugin write: `codex plugin marketplace add` and `codex plugin add`\n * copy the plugin from Tenjin's runtime, `~/.tenjin/runtime/codex`, which\n * install sets up as the Claude install does, or from this package's\n * `dist/hosts/codex` where there is none. The plugin's own `PermissionRequest`\n * hook allows the request tool, so install writes no Codex config: the\n * wallet, the spend defaults and the plugin. User scope only.\n */\n\nexport interface CodexArgs {\n project?: boolean;\n yes?: boolean;\n noWallet?: boolean;\n /** `--max-auto-spend`: the per-call limit, at least 0.25 USD. */\n maxAutoSpend?: string;\n /** `--session-budget`: the daily limit in USD, or none. */\n sessionBudget?: string;\n}\n\nexport interface CodexRun {\n code: number;\n stdout: string;\n stderr: string;\n}\n\nexport interface CodexSetupDeps\n extends WalletDeps, Pick<RouterInstallDeps, 'promptLimits' | 'promptAmount'> {\n /** One `codex` command, recorded in tests. */\n run?: (args: string[]) => Promise<CodexRun>;\n /** Codex's merged config (`config/read`), or null when it could not be read. */\n config?: () => Promise<unknown>;\n /** Codex's hook list (`hooks/list`). */\n hooks?: () => Promise<unknown>;\n version?: () => Promise<string | null>;\n /** The marketplace folder without a runtime, by default this package's `dist/hosts/codex`. */\n hostsDir?: string | null;\n isInteractive?: boolean;\n homeDir?: string;\n /** Sets up Tenjin's runtime for this build; tests inject it, production runs `setupRuntime`. */\n runtime?: (o: Parameters<typeof setupRuntime>[0]) => Promise<RuntimeSetup>;\n /** Trusts the listed rows through Codex's app server; tests inject it. */\n trust?: typeof trustCodexHooks;\n}\n\nconst RUN_TIMEOUT_MS = 30_000;\n\nfunction runCodex(args: string[]): Promise<CodexRun> {\n const codex = resolveCodex();\n if (codex === null) {\n return Promise.resolve({ code: 127, stdout: '', stderr: 'codex was not found on PATH' });\n }\n return new Promise((resolve) => {\n execFile(\n codex.cmd,\n [...codex.prefix, ...args],\n { timeout: RUN_TIMEOUT_MS, maxBuffer: 4_000_000, windowsHide: true },\n (err, stdout, stderr) => {\n const code = err === null ? 0 : typeof err.code === 'number' ? err.code : 127;\n resolve({ code, stdout: String(stdout), stderr: String(stderr) });\n },\n );\n });\n}\n\n/** This package's `dist/hosts/codex`, by its version-free path under pnpm. */\nexport async function codexHostsDir(\n moduleDir: string = dirname(fileURLToPath(import.meta.url)),\n): Promise<string | null> {\n const catalog = join(moduleDir, 'hosts', 'codex', '.agents', 'plugins', 'marketplace.json');\n const stable = versionFreeEntry(catalog) ?? catalog;\n if ((await stat(stable).catch(() => null))?.isFile() !== true) return null;\n return dirname(dirname(dirname(stable)));\n}\n\nfunction failed(step: string, out: CodexRun): CliError {\n const detail = (out.stderr || out.stdout).trim().split('\\n')[0] ?? '';\n return new CliError('REFUSED', `\\`codex ${step}\\` failed${detail ? `: ${detail}` : ''}.`, {\n fix: 'Check that Codex CLI is installed and on PATH (`codex --version`), then re-run.',\n });\n}\n\n/**\n * The runtime's Codex marketplace, when the runtime has one: a `kept` older\n * runtime may predate it.\n */\nfunction runtimeHosts(rt: RuntimeSetup): string | null {\n if (rt.state !== 'active' && rt.state !== 'current' && rt.state !== 'kept') return null;\n const hosts = join(rt.root, 'codex');\n return existsSync(join(hosts, '.agents', 'plugins', 'marketplace.json')) ? hosts : null;\n}\n\n/**\n * `registered` is the folder Codex's config names for the `tenjin`\n * marketplace. Codex keeps one marketplace by that name, so one added from\n * another folder (the package's, before the runtime) is removed first.\n */\nasync function addPlugin(\n run: (args: string[]) => Promise<CodexRun>,\n hosts: string | null,\n registered: unknown,\n previousEnabled: boolean,\n restoreRuntime?: () => Promise<void>,\n): Promise<void> {\n let removed = false;\n let added = false;\n const moved =\n typeof registered === 'string' && hosts !== null && resolve(registered) !== resolve(hosts);\n try {\n if (hosts === null)\n throw new CliError('UPDATE_FAILED', 'The verified runtime carries no Codex plugin folder.');\n if (moved) {\n const old = await run(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n removed = old.code === 0;\n }\n const market = await run(['plugin', 'marketplace', 'add', hosts, '--json']);\n if (market.code !== 0) throw failed('plugin marketplace add', market);\n added = true;\n const plugin = await run(['plugin', 'add', CODEX_PLUGIN, '--json']);\n if (plugin.code !== 0) throw failed('plugin add', plugin);\n } catch (error) {\n try {\n await restoreRuntime?.();\n const restore = async (args: string[]): Promise<void> => {\n const out = await run(args);\n if (out.code !== 0) throw failed(args.join(' '), out);\n };\n if (added && (moved || typeof registered !== 'string')) {\n await restore(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n }\n if (moved && (removed || added) && typeof registered === 'string') {\n await restore(['plugin', 'marketplace', 'add', registered, '--json']);\n }\n if (previousEnabled && (removed || added)) {\n await restore(['plugin', 'add', CODEX_PLUGIN, '--json']);\n }\n } catch {\n throw new CliError(\n 'UPDATE_FAILED',\n 'Codex plugin registration failed and the previous registration could not be fully restored.',\n {\n fix: 'Run tenjin install --harness codex again. Your payment keys and funds were kept.',\n cause: error,\n },\n );\n }\n throw error;\n }\n}\n\nconst TRUST_STEP =\n 'Open Codex, run /hooks and trust the five Tenjin hooks, then start a new session.';\n/** What a person reads when this Codex cannot run the plugin's routing hooks. */\nconst CODEX_TOO_OLD = `Routing in Codex needs Codex ${CODEX_MCP_HOOKS_VERSION} or later, so Tenjin left its Codex plugin as it was. Ask your agent to update Codex.`;\n/** What a person reads when an install or update turned the hooks on itself. */\nconst NEW_SESSION_STEP = 'Start a new Codex session: Codex reads hooks when a session starts.';\n\n/**\n * ONE OF THE PLUGIN'S OWN HOOKS, as `hooks/list` lists it: our plugin's hooks\n * file, and at that event, group and position exactly the handler this build\n * renders (an `mcp_tool` leg into `router`/`hook`, the deny, or the allow).\n * Anything else in the list, another plugin's row or a row that moved, is not\n * ours to trust.\n */\nexport function ownCodexRow(row: ListedHook): boolean {\n if (row.pluginId !== CODEX_PLUGIN) return false;\n if (typeof row.sourcePath !== 'string' || !/[\\\\/]hooks[\\\\/]hooks\\.json$/.test(row.sourcePath)) {\n return false;\n }\n const at = /:([a-z_]+):(\\d+):(\\d+)$/.exec(typeof row.key === 'string' ? row.key : '');\n if (at === null) return false;\n const event = Object.keys(EVENT_LABEL).find((e) => EVENT_LABEL[e] === at[1]);\n const group = (renderCodexHooks().hooks[event ?? ''] as Record<string, unknown>[] | undefined)?.[\n Number(at[2])\n ] as { matcher?: string; hooks: Record<string, unknown>[] } | undefined;\n const want = group?.hooks[Number(at[3])];\n if (group === undefined || want === undefined) return false;\n if ((row.matcher ?? null) !== (group.matcher ?? null)) return false;\n return want.type === 'mcp_tool'\n ? row.handlerType === 'mcpTool' && row.server === want.server && row.tool === want.tool\n : row.handlerType === 'command' &&\n (row.command === want.command || row.command === want.commandWindows);\n}\n\n/**\n * TURNS THE PLUGIN'S HOOKS ON, as installing a Claude Code plugin does:\n * through `lib/codex-trust.ts`, which echoes back the `currentHash` Codex\n * reports for each of our rows and verifies them trusted. A row the person\n * turned off in `/hooks` (the allow hook's opt-out) stays off. False when\n * Codex lists none of our rows or any step fails: the person then reviews\n * them in `/hooks`.\n */\nasync function trustPlugin(deps: CodexSetupDeps): Promise<boolean> {\n const list = await (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))();\n const ours = rowsOf(list).filter(ownCodexRow);\n if (ours.length === 0) return false;\n const keys = ours\n .filter(\n (r) => r.enabled !== false && r.trustStatus !== 'trusted' && r.trustStatus !== 'managed',\n )\n .map((r) => r.key as string);\n const result = await (deps.trust ?? trustCodexHooks)(\n deps.homeDir ?? homedir(),\n keys,\n ownCodexRow,\n );\n return result.ok;\n}\n\n/** What `tenjin update` says about Codex, in person-facing words with no command. */\nexport const CODEX_REFRESH_LINES = {\n done: \"Tenjin updated its Codex hooks. They run in Codex's next new session.\",\n review:\n \"Tenjin updated its Codex hooks but could not turn them on. Open /hooks in Codex and approve Tenjin's hooks so routing works.\",\n old: CODEX_TOO_OLD,\n failed:\n 'Tenjin could not update its Codex hooks. Ask your agent to run the Tenjin doctor for Codex.',\n} as const;\n\n/**\n * A bare `install --refresh` with the Codex refresh beside it: the Codex one\n * runs whatever Claude Code's did. Only Claude Code's \"nothing to refresh\"\n * (a Codex-only machine) gives way to a Codex line; any other Claude Code\n * failure stands, so `tenjin update` still reports it with its fix.\n */\nexport async function alongsideCodexRefresh(\n claude: () => Promise<CommandResult>,\n codex: () => Promise<string | undefined>,\n): Promise<CommandResult> {\n let out: CommandResult;\n try {\n out = await claude();\n } catch (err) {\n const line = await codex();\n const nothing = err instanceof CliError && err.message.startsWith(NOTHING_TO_REFRESH);\n if (line === undefined || !nothing) throw err;\n return { data: { notices: [line] }, humanLines: [line] };\n }\n return withNote(out, await codex());\n}\n\n/**\n * THE CODEX REFRESH `tenjin update` RUNS, in the new build (`install\n * --refresh`). Only where Codex already has the Tenjin plugin with the\n * command legs of an older build: it re-adds the plugin from the same folder,\n * which replaces Codex's copy, then turns the new hooks on (`trustPlugin`).\n * It never installs the plugin anywhere it was not, never asks, and never\n * throws: what happened is one line, or nothing.\n */\nexport async function refreshCodexPlugin(\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<string | undefined> {\n try {\n const version = await (deps.version ?? codexVersion)();\n if (version === null) {\n const recorded = (await readInstalledHosts(ctx.dataDir))?.includes('codex') === true;\n return recorded ? CODEX_REFRESH_LINES.failed : undefined;\n }\n const rows = codexHookRows(\n await (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))(),\n );\n if (rows.state === 'absent') return undefined;\n if (rows.state === 'unknown') return CODEX_REFRESH_LINES.failed;\n if (rows.routing !== 'free') return undefined;\n if (!codexAtLeast(version, CODEX_MCP_HOOKS_VERSION)) return CODEX_REFRESH_LINES.old;\n const runtimeCodex = join(runtimeDir(ctx.dataDir), 'codex');\n const hosts = existsSync(join(runtimeCodex, '.agents', 'plugins', 'marketplace.json'))\n ? runtimeCodex\n : deps.hostsDir === undefined\n ? await codexHostsDir()\n : deps.hostsDir;\n const config = await (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))();\n await addPlugin(\n deps.run ?? runCodex,\n hosts,\n at(config, 'marketplaces', CODEX_MARKETPLACE, 'source'),\n at(config, 'plugins', CODEX_PLUGIN, 'enabled') === true,\n );\n return (await trustPlugin(deps)) ? CODEX_REFRESH_LINES.done : CODEX_REFRESH_LINES.review;\n } catch {\n return CODEX_REFRESH_LINES.failed;\n }\n}\n\nfunction userScopeOnly(args: CodexArgs): void {\n if (args.project === true) {\n throw new CliError('USAGE', 'The Codex plugin installs for your user only; omit --project.');\n }\n}\n\nexport async function runCodexInstall(\n args: CodexArgs,\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const run = deps.run ?? runCodex;\n const home = deps.homeDir ?? homedir();\n assertPluginInstallation(ctx.dataDir, home, deps.env ?? process.env);\n const config = await loadRawConfig(ctx.dataDir);\n const named = namedLimits(args);\n const humanOutput = ctx.flags.json === true ? false : (deps.isInteractive ?? ctx.io.isTTY);\n const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));\n // The Claude install's spend model: `--yes` takes the defaults, the two\n // amount flags set the person's own, and a terminal asks once, before any\n // write, only when the file names neither limit. With no answer nothing is\n // written, the defaults hold, and the question goes to whoever ran it.\n const answered = args.yes === true || named.keys.length > 0;\n const unasked = config.maxAutoSpend === undefined && config.sessionBudget === undefined;\n const limits =\n named.keys.length > 0\n ? { ...shownLimits(config), ...named.limits }\n : args.yes === true\n ? shownLimits(config)\n : canPrompt && unasked\n ? await approveLimits(deps)\n : {};\n\n const rt = await (deps.runtime ?? defaultRuntime)({\n dataDir: ctx.dataDir,\n home,\n env: deps.env ?? process.env,\n version: pkg.version,\n moduleDir: dirname(fileURLToPath(import.meta.url)),\n refresh: false,\n });\n requireRuntime(rt);\n const { resolveWallet, walletValue } = await import('../commands/install-wallet');\n const wallet: WalletOutcome = await resolveWallet(\n ctx,\n deps,\n args.noWallet === true ? 'flag' : undefined,\n false,\n );\n const spend = await persistRouterDefaults(ctx.dataDir, false, limits, named.keys);\n const fromRuntime = runtimeHosts(rt);\n const hosts =\n rt.state === 'skipped'\n ? deps.hostsDir === undefined\n ? await codexHostsDir()\n : deps.hostsDir\n : fromRuntime;\n // A Codex too old to run `mcp_tool` hooks keeps whatever copy it has: the\n // new hooks would be skipped, or the file refused. An unknown build installs.\n const version = await (deps.version ?? codexVersion)();\n const tooOld = version !== null && !codexAtLeast(version, CODEX_MCP_HOOKS_VERSION);\n let next: string = CODEX_TOO_OLD;\n if (!tooOld) {\n const codexConfig = await (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))();\n await addPlugin(\n run,\n hosts,\n at(codexConfig, 'marketplaces', CODEX_MARKETPLACE, 'source'),\n at(codexConfig, 'plugins', CODEX_PLUGIN, 'enabled') === true,\n rt.restore,\n );\n next = (await trustPlugin(deps).catch(() => false)) ? NEW_SESSION_STEP : TRUST_STEP;\n }\n\n // Read back after the write, as the Claude install does.\n const effective = effectiveLimits((await resolveContextSettings(ctx)).policy);\n // Run again by the agent in Codex, a bare install finds Codex itself.\n const install = [\n `${continuationCommand(rt)} install`,\n ...(args.noWallet ? ['--no-wallet'] : []),\n ].join(' ');\n const spendAsk: QuestionStep | undefined =\n !canPrompt && !answered && unasked ? spendStepFor(install) : undefined;\n const daily =\n effective.sessionBudget === 'no daily ceiling'\n ? 'no daily limit'\n : `$${effective.sessionBudget} a day`;\n return {\n data: {\n plugin: CODEX_PLUGIN,\n wallet,\n spend: { ...spend, effective },\n runtime: runtimeData(rt),\n nextSteps: spendAsk !== undefined ? [spendAsk] : [],\n next,\n },\n humanLines: [\n `Wallet: ${walletValue(wallet)}`,\n tooOld\n ? `Codex plugin: left as it was (Codex ${version})`\n : `Codex plugin: ${CODEX_PLUGIN} added from ${fromRuntime !== null ? tilde(fromRuntime, home) : 'the package'}`,\n ...runtimeLines(ctx, rt, home),\n `Automatic router: up to $${effective.maxAutoSpend} per call; daily limit ${daily}`,\n ...(spendAsk !== undefined\n ? [\n ` Ask the person in this session: ${spendAsk.question}`,\n ...spendAsk.options.map(\n (o) => ` ${o.label}${o.recommended ? ' (recommended)' : ''}: ${o.command}`,\n ),\n ]\n : []),\n 'Request tool: its plugin hook allows it, under your wallet spend limits. Turn that hook off in /hooks to be asked first.',\n next,\n ],\n };\n}\n\nexport async function runCodexUninstall(\n args: CodexArgs,\n _ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const run = deps.run ?? runCodex;\n const removed = await run(['plugin', 'remove', CODEX_PLUGIN, '--json']);\n if (removed.code !== 0) throw failed('plugin remove', removed);\n // Absent already is the state uninstall wants.\n await run(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n return {\n data: { removed: CODEX_PLUGIN, marketplace: CODEX_MARKETPLACE },\n humanLines: [\n `Codex plugin ${CODEX_PLUGIN} and its marketplace removed. The wallet and Claude setup are kept.`,\n ],\n };\n}\n\nconst PLUGIN_LINE: Record<CodexHookRows['state'], string> = {\n trusted: 'installed, its hooks on and trusted',\n review: `installed, its hooks need review. ${TRUST_STEP}`,\n absent: 'not installed or turned off. Run `tenjin install --harness codex`',\n unknown: \"could not read Codex's hook list\",\n};\n\n/**\n * What the plugin's hooks and server run, from the folder Codex's config names\n * for the marketplace: information only. Nothing when Codex names none, or\n * names another folder on a machine with no runtime to move to.\n */\nfunction runsFrom(ctx: CommandContext, deps: CodexSetupDeps, source: unknown): string | null {\n if (typeof source !== 'string') return null;\n const home = deps.homeDir ?? homedir();\n const hosts = join(runtimeDir(ctx.dataDir), 'codex');\n if (resolve(source) === resolve(hosts)) return `Tenjin's runtime (${tilde(hosts, home)})`;\n if (!hasRuntime(ctx.dataDir, home)) return null;\n return \"`tenjin` from your PATH; run `tenjin install --harness codex` to move it to Tenjin's runtime\";\n}\n\n/** Whether `version` (`x.y.z`, any suffix ignored) is `floor` or later. */\nexport function codexAtLeast(version: string, floor: string): boolean {\n const parts = (v: string) =>\n v\n .split(/[-+]/)[0]!\n .split('.')\n .map((n) => Number.parseInt(n, 10));\n const have = parts(version);\n for (const [i, least] of parts(floor).entries()) {\n const part = have[i] ?? 0;\n if (!Number.isFinite(part)) return false;\n if (part !== least) return part > least;\n }\n return true;\n}\n\nconst ROUTING_LINE: Record<CodexHookRows['routing'], string> = {\n paid: 'its routing hooks call the router MCP server, which pays the routing fee under your wallet spend limits',\n free: 'its routing hooks are commands from an older build, which cannot pay the routing fee, so they offer nothing. Run `tenjin update` or `tenjin install --harness codex` to replace them',\n unknown: \"could not read how Codex runs the plugin's routing hooks\",\n};\n\n/**\n * Reads Codex's view of the plugin and writes nothing. Routing compatibility\n * is read the same way, with nothing paid or sent: the legs must be `mcp_tool`\n * hooks into the plugin's server (`codexHookRows`), and the Codex build must\n * run them ({@link CODEX_MCP_HOOKS_VERSION}).\n */\nexport async function runCodexDoctor(\n args: CodexArgs,\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const [list, config, version] = await Promise.all([\n (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))(),\n (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))(),\n (deps.version ?? codexVersion)(),\n ]);\n const hooks = codexHookRows(list);\n // With its allow hook off, `approval_policy = \"never\"` refuses the tool.\n const refused = hooks.allowOff && at(config, 'approval_policy') === 'never';\n // An unknown build is not failed on: only a known older one cannot run the legs.\n const tooOld = version !== null && !codexAtLeast(version, CODEX_MCP_HOOKS_VERSION);\n const routing = hooks.state === 'absent' ? null : hooks.routing;\n // Command legs from an older build warn without failing: `tenjin update`\n // replaces them, and Codex still runs the rest of the plugin.\n const ok = hooks.state === 'trusted' && !refused && routing !== 'unknown' && !tooOld;\n const runs = runsFrom(ctx, deps, at(config, 'marketplaces', CODEX_MARKETPLACE, 'source'));\n const auto = hasRuntime(ctx.dataDir, deps.homeDir ?? homedir())\n ? autoUpdateLine(runtimeDir(ctx.dataDir))\n : null;\n const lines = [\n `Codex plugin: ${PLUGIN_LINE[hooks.state]}`,\n `Request tool: ${refused ? 'refused: its allow hook is off in /hooks and approval_policy is never' : hooks.allowOff ? 'asks before each call (its allow hook is off in /hooks)' : 'allowed by its plugin hook, under your wallet spend limits'}`,\n ...(routing !== null\n ? [`${routing === 'free' ? '! ' : ''}Routing: ${ROUTING_LINE[routing]}`]\n : []),\n tooOld\n ? `Codex build: ${version}, which cannot run the plugin's routing hooks. Update Codex to ${CODEX_MCP_HOOKS_VERSION} or later`\n : `Codex build: ${version ?? 'unknown'} (web hooks last captured on ${WEB_VERIFIED_VERSION}; information only)`,\n ...(runs !== null ? [`Codex plugin runs: ${runs}`] : []),\n ...(auto !== null ? [auto] : []),\n ];\n const data = {\n plugin: CODEX_PLUGIN,\n hooks: hooks.state,\n allowOff: hooks.allowOff,\n routing,\n version,\n ok,\n };\n if (!ok) {\n throw new CliError('REFUSED', 'The Codex plugin is not ready.', {\n details: data,\n fix: lines.join('\\n'),\n });\n }\n return { data, humanLines: lines };\n}\n"],"mappings":";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B,WAAW,SAAS,gCAAgC,oBAAoB;AAAA,IAC5F,GAAI,SAAS,OAAO,CAAC,sBAAsB,IAAI,EAAE,IAAI,CAAC;AAAA,IACtD,GAAI,SAAS,OAAO,CAAC,IAAI,IAAI,CAAC;AAAA,EAChC;AACA,QAAM,OAAO;AAAA,IACX,QAAQ;AAAA,IACR,OAAO,MAAM;AAAA,IACb,UAAU,MAAM;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,IAAI;AACP,UAAM,IAAI,SAAS,WAAW,kCAAkC;AAAA,MAC9D,SAAS;AAAA,MACT,KAAK,MAAM,KAAK,IAAI;AAAA,IACtB,CAAC;AAAA,EACH;AACA,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":["resolve","at"]}
@@ -11,11 +11,11 @@ import {
11
11
  runConfigGet,
12
12
  runConfigList,
13
13
  runConfigSet
14
- } from "./chunk-AD226HDR.js";
14
+ } from "./chunk-A5GKIG5O.js";
15
15
  import "./chunk-4LMUQMBH.js";
16
16
  import "./chunk-3623BLPV.js";
17
17
  import "./chunk-XKESD27X.js";
18
- import "./chunk-VJUVFZ2D.js";
18
+ import "./chunk-FVIGCDSV.js";
19
19
  import "./chunk-HDPUXS3Z.js";
20
20
  import "./chunk-2SNUOHAT.js";
21
21
  import "./chunk-E7SW44LM.js";
@@ -24,15 +24,15 @@ import "./chunk-DOQGNFHM.js";
24
24
  import "./chunk-MEFB5KHA.js";
25
25
  import "./chunk-UUGOUOVT.js";
26
26
  import "./chunk-MPZUYCAP.js";
27
- import "./chunk-YUY4SAGM.js";
28
- import "./chunk-JEVQ5LKO.js";
29
- import "./chunk-AV5NZMYO.js";
27
+ import "./chunk-RVPYTUP4.js";
28
+ import "./chunk-AGMVASXZ.js";
29
+ import "./chunk-KM7RY2ZS.js";
30
30
  import "./chunk-Y527D4TV.js";
31
31
  import "./chunk-BFDQ4WNW.js";
32
32
  import "./chunk-X5ZBP3IY.js";
33
33
  import "./chunk-2I4QTOLB.js";
34
- import "./chunk-2GNOFONN.js";
35
- import "./chunk-DW4YTVR3.js";
34
+ import "./chunk-2M2VPI2E.js";
35
+ import "./chunk-WXA2BWTE.js";
36
36
  import "./chunk-XQJXNMSB.js";
37
37
  import "./chunk-SNNSAGMT.js";
38
38
  import "./chunk-7WEQQJLG.js";
@@ -52,4 +52,4 @@ export {
52
52
  runConfigList,
53
53
  runConfigSet
54
54
  };
55
- //# sourceMappingURL=config-HOVJFEKD.js.map
55
+ //# sourceMappingURL=config-HY2E4GGW.js.map
@@ -17,14 +17,14 @@ import {
17
17
  } from "./chunk-WYXUQGOL.js";
18
18
  import {
19
19
  channelCredit
20
- } from "./chunk-D3ZURCG7.js";
21
- import "./chunk-QF3LSMGS.js";
22
- import "./chunk-445VQTVM.js";
20
+ } from "./chunk-TKPF35W6.js";
21
+ import "./chunk-GTTUCOPD.js";
22
+ import "./chunk-IE7P2BZE.js";
23
23
  import {
24
24
  createLocalProvider,
25
25
  describeWallet,
26
26
  walletFileExists
27
- } from "./chunk-BI673VEJ.js";
27
+ } from "./chunk-UXZONNEQ.js";
28
28
  import "./chunk-V2LQLN5H.js";
29
29
  import {
30
30
  readSpendSummary,
@@ -39,20 +39,20 @@ import {
39
39
  projectInstallHere,
40
40
  readPluginListing,
41
41
  settingsInstallPaths
42
- } from "./chunk-VOZA6O7K.js";
43
- import "./chunk-I5TDIUKM.js";
42
+ } from "./chunk-ILNIZ5I2.js";
43
+ import "./chunk-U3IKUGRP.js";
44
44
  import "./chunk-KOGZDMHO.js";
45
- import "./chunk-PKHI276N.js";
45
+ import "./chunk-LXAYUOXI.js";
46
46
  import {
47
47
  RECONNECT_FIX,
48
48
  mcpServersState,
49
49
  readProcessSnapshot
50
- } from "./chunk-B7EM4GGF.js";
51
- import "./chunk-AD226HDR.js";
50
+ } from "./chunk-3GNJXKIT.js";
51
+ import "./chunk-A5GKIG5O.js";
52
52
  import "./chunk-4LMUQMBH.js";
53
53
  import "./chunk-3623BLPV.js";
54
54
  import "./chunk-XKESD27X.js";
55
- import "./chunk-VJUVFZ2D.js";
55
+ import "./chunk-FVIGCDSV.js";
56
56
  import {
57
57
  CHANNEL_DEPOSIT_ATOMIC,
58
58
  ROUTING_FEE_ATOMIC,
@@ -68,12 +68,12 @@ import {
68
68
  import "./chunk-E7SW44LM.js";
69
69
  import "./chunk-F3ED5WTR.js";
70
70
  import "./chunk-DOQGNFHM.js";
71
- import "./chunk-TAW4UFFF.js";
71
+ import "./chunk-L6JEXB3E.js";
72
72
  import {
73
73
  LAUNCHER_MARKER,
74
74
  PLUGIN_DIR,
75
75
  RUNTIME_MISSING_FIX
76
- } from "./chunk-E7LGOMH6.js";
76
+ } from "./chunk-LRW6S53P.js";
77
77
  import "./chunk-MEFB5KHA.js";
78
78
  import "./chunk-UUGOUOVT.js";
79
79
  import {
@@ -83,8 +83,9 @@ import {
83
83
  PLUGIN_SERVER,
84
84
  REQUEST_TOOL
85
85
  } from "./chunk-MPZUYCAP.js";
86
+ import "./chunk-4YOZGGTZ.js";
86
87
  import "./chunk-3FMZGI7I.js";
87
- import "./chunk-OTWLERSW.js";
88
+ import "./chunk-36RVGZNY.js";
88
89
  import {
89
90
  describeStoreLocation
90
91
  } from "./chunk-CEXSOI5R.js";
@@ -96,7 +97,7 @@ import {
96
97
  readClaudeCode,
97
98
  runClaude
98
99
  } from "./chunk-QXP3Z3JN.js";
99
- import "./chunk-PJNENX2A.js";
100
+ import "./chunk-WFSPCCVW.js";
100
101
  import "./chunk-JRGFKVAZ.js";
101
102
  import "./chunk-2GP3HRYK.js";
102
103
  import "./chunk-KG3D7FIF.js";
@@ -104,20 +105,20 @@ import "./chunk-RBJPAZFI.js";
104
105
  import "./chunk-BPMWXTFX.js";
105
106
  import {
106
107
  package_default
107
- } from "./chunk-YUY4SAGM.js";
108
+ } from "./chunk-RVPYTUP4.js";
108
109
  import {
109
110
  routerSettings
110
- } from "./chunk-JEVQ5LKO.js";
111
+ } from "./chunk-AGMVASXZ.js";
111
112
  import {
112
113
  resolveContextSettings
113
- } from "./chunk-AV5NZMYO.js";
114
+ } from "./chunk-KM7RY2ZS.js";
114
115
  import {
115
116
  toMoney
116
117
  } from "./chunk-Y527D4TV.js";
117
118
  import {
118
119
  readAliveStamp,
119
120
  readWalletFacts
120
- } from "./chunk-WOM257PW.js";
121
+ } from "./chunk-NDGZDTSJ.js";
121
122
  import {
122
123
  NO_SESSION_CHECKED,
123
124
  UNKNOWN_DETAIL,
@@ -131,10 +132,10 @@ import {
131
132
  import {
132
133
  hasCode
133
134
  } from "./chunk-2I4QTOLB.js";
134
- import "./chunk-2GNOFONN.js";
135
+ import "./chunk-2M2VPI2E.js";
135
136
  import {
136
137
  readUsdcBalance
137
- } from "./chunk-DW4YTVR3.js";
138
+ } from "./chunk-WXA2BWTE.js";
138
139
  import "./chunk-XQJXNMSB.js";
139
140
  import "./chunk-SNNSAGMT.js";
140
141
  import "./chunk-7WEQQJLG.js";
@@ -143,11 +144,11 @@ import {
143
144
  } from "./chunk-3UCIG4TG.js";
144
145
  import {
145
146
  autoUpdateLine
146
- } from "./chunk-ADV4LDTB.js";
147
+ } from "./chunk-BF4XHEQK.js";
147
148
  import {
148
149
  readRuntimeState,
149
150
  runtimeBuild
150
- } from "./chunk-G75OPGAK.js";
151
+ } from "./chunk-ZNNXRNFD.js";
151
152
  import {
152
153
  isNewer
153
154
  } from "./chunk-EDJWHDDL.js";
@@ -332,7 +333,17 @@ async function runRouterDoctor(ctx, deps = {}) {
332
333
  if (old !== null) checks.push(old);
333
334
  }
334
335
  if (plugin.registered && claude.binary !== null) {
335
- checks.push(await serverCheck(claude.binary, env, cwd, layout));
336
+ const serving = live.find(
337
+ (o) => o.harness === "claude" && o.launchedByPlugin && o.cliVersion === package_default.version && resolve(o.cwd) === resolve(cwd)
338
+ );
339
+ checks.push(
340
+ serving !== void 0 ? {
341
+ name: "router server",
342
+ status: "ok",
343
+ required: true,
344
+ detail: `${PLUGIN_SERVER} is serving a Claude Code session in this directory (pid ${serving.pid})`
345
+ } : await serverCheck(claude.binary, env, cwd, layout)
346
+ );
336
347
  }
337
348
  if (legacy.present || legacy.unreadable !== void 0) {
338
349
  checks.push(await migrationCheck(legacy, claude, ctx.dataDir, env, cwd));
@@ -536,7 +547,7 @@ function claudeCodeCheck(claude) {
536
547
  };
537
548
  }
538
549
  function didNotStartFix(layout) {
539
- return layout !== "runtime" ? `Claude Code starts the plugin with the \`node\` on its own PATH, which must be 22 or newer: run \`node --version\` in the shell it starts from, then quit Claude Code fully and start a new session.${moveToRuntime(layout)}` : `Start a new Claude Code session; if Tenjin still does not start, run \`${RUNTIME_MISSING_FIX}\`.`;
550
+ return layout !== "runtime" ? `Claude Code starts the plugin with the \`node\` on its own PATH, which must be 22 or newer: run \`node --version\` in the shell it starts from, then quit Claude Code fully and start a new session.${moveToRuntime(layout)}` : `Start a new Claude Code session. If Tenjin still does not start: ${RUNTIME_MISSING_FIX}`;
540
551
  }
541
552
  function pluginStart(i) {
542
553
  const since = (startedAt) => i.installed !== null && startedAt !== null && startedAt >= i.installed;
@@ -816,7 +827,7 @@ function runVersion(command, entry) {
816
827
  });
817
828
  }
818
829
  async function thisPlatformUnpinned() {
819
- const { runningGlibc, unpinnedPlatform } = await import("./runtime-fetch-EKFRNR6Z.js");
830
+ const { runningGlibc, unpinnedPlatform } = await import("./runtime-fetch-ZSSSK72Y.js");
820
831
  const platform = process.platform;
821
832
  return unpinnedPlatform(platform, process.arch, platform === "linux" ? runningGlibc() : null);
822
833
  }
@@ -835,7 +846,7 @@ async function runtimeCheck(i) {
835
846
  const name = "runtime";
836
847
  const flag = i.project ? " --project" : "";
837
848
  const t = (p) => tilde(p, i.home);
838
- const failFix = `Run \`${RUNTIME_MISSING_FIX}${flag}\`, then start a new Claude Code session.`;
849
+ const failFix = RUNTIME_MISSING_FIX + (i.project ? " For a project-only installation, pass `--project` to the installer from that project folder." : "");
839
850
  const { launch } = i;
840
851
  const unread = {
841
852
  name,
@@ -870,8 +881,8 @@ async function runtimeCheck(i) {
870
881
  name,
871
882
  status: "warn",
872
883
  required: false,
873
- detail: `Tenjin pins no Node for this platform (${i.unpinned}), so it keeps running from npm's copy${from2} on the \`node\` on Claude Code's PATH, by design`,
874
- fix: `Nothing to move. Keep Node 22 or newer on the PATH Claude Code starts with; after changing Node versions, reinstall with that Node's \`npm i -g tenjin-cli\`, then run \`tenjin install${flag}\`.`
884
+ detail: `This older installation runs from npm's copy${from2}; this platform (${i.unpinned}) does not support Tenjin's private runtime`,
885
+ fix: "Use macOS, Windows or glibc Linux 2.28+ on x64/arm64. This installation was left unchanged."
875
886
  };
876
887
  }
877
888
  if (launch.command === "node") {
@@ -932,7 +943,7 @@ async function runtimeCheck(i) {
932
943
  };
933
944
  }
934
945
  if (i.onPath === null && !launcherOnPath(launcherDir(i.home), i.env, platform)) {
935
- const { pathLine } = await import("./runtime-UVNUA3AS.js");
946
+ const { pathLine } = await import("./runtime-UZOKSUZX.js");
936
947
  return {
937
948
  name,
938
949
  status: "warn",
@@ -970,7 +981,7 @@ async function findPathTenjin(env, platform = process.platform) {
970
981
  let root;
971
982
  if (platform === "win32") root = join(dir, "node_modules", "tenjin-cli");
972
983
  else {
973
- const { packageRootOf } = await import("./runtime-UVNUA3AS.js");
984
+ const { packageRootOf } = await import("./runtime-UZOKSUZX.js");
974
985
  root = packageRootOf(dirname(await realpath(path).catch(() => path)));
975
986
  }
976
987
  const unknown = { path, marked: false, version: null, handsOff: false, unknown: true };
@@ -1309,4 +1320,4 @@ export {
1309
1320
  sessionRow,
1310
1321
  walletRow
1311
1322
  };
1312
- //# sourceMappingURL=doctor-NKU4V5OV.js.map
1323
+ //# sourceMappingURL=doctor-I6XQEKWD.js.map