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

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 (133) hide show
  1. package/README.md +19 -42
  2. package/dist/{chunk-GPLSNGKX.js → chunk-4HAV6IFE.js} +6 -6
  3. package/dist/{chunk-UXSF7IFD.js → chunk-5HS54CLI.js} +3 -3
  4. package/dist/{chunk-RCJ64OXH.js → chunk-5INS5ZZF.js} +36 -7
  5. package/dist/chunk-5INS5ZZF.js.map +1 -0
  6. package/dist/{chunk-XZUGRTSV.js → chunk-5NUF4BHR.js} +5 -3
  7. package/dist/{chunk-XZUGRTSV.js.map → chunk-5NUF4BHR.js.map} +1 -1
  8. package/dist/{chunk-YZTIYDWU.js → chunk-65EJJVT3.js} +2 -2
  9. package/dist/{chunk-ZMFDMALH.js → chunk-6JIYGYRB.js} +3 -53
  10. package/dist/chunk-6JIYGYRB.js.map +1 -0
  11. package/dist/chunk-7EKYXMUO.js +7536 -0
  12. package/dist/chunk-7EKYXMUO.js.map +1 -0
  13. package/dist/chunk-AKWGE6JQ.js +49 -0
  14. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  15. package/dist/{chunk-KC24CYGV.js → chunk-ALJRB7NG.js} +14 -9
  16. package/dist/chunk-ALJRB7NG.js.map +1 -0
  17. package/dist/{chunk-S2NRVRPF.js → chunk-BOAI23CX.js} +53 -2
  18. package/dist/chunk-BOAI23CX.js.map +1 -0
  19. package/dist/{chunk-SQSKVKX6.js → chunk-DI7WHXOZ.js} +20 -16
  20. package/dist/chunk-DI7WHXOZ.js.map +1 -0
  21. package/dist/{chunk-UBOFYC6J.js → chunk-EJXIK6WY.js} +1817 -137
  22. package/dist/chunk-EJXIK6WY.js.map +1 -0
  23. package/dist/{chunk-RGVOODF4.js → chunk-EL56RW2J.js} +164 -7463
  24. package/dist/chunk-EL56RW2J.js.map +1 -0
  25. package/dist/{chunk-ZNZGBUV6.js → chunk-GHR4BTNJ.js} +9 -7
  26. package/dist/chunk-GHR4BTNJ.js.map +1 -0
  27. package/dist/chunk-H4BOQLWW.js +99 -0
  28. package/dist/chunk-H4BOQLWW.js.map +1 -0
  29. package/dist/{chunk-TMLCEPCD.js → chunk-HII5HOQV.js} +3 -5
  30. package/dist/chunk-HII5HOQV.js.map +1 -0
  31. package/dist/chunk-LFZJM56J.js +159 -0
  32. package/dist/chunk-LFZJM56J.js.map +1 -0
  33. package/dist/chunk-OBPZ36HG.js +145 -0
  34. package/dist/chunk-OBPZ36HG.js.map +1 -0
  35. package/dist/{chunk-NSDZESRS.js → chunk-OZ3LWLCI.js} +3 -3
  36. package/dist/chunk-PM2MOXJ3.js +66 -0
  37. package/dist/chunk-PM2MOXJ3.js.map +1 -0
  38. package/dist/chunk-PZ5N6BAL.js +268 -0
  39. package/dist/chunk-PZ5N6BAL.js.map +1 -0
  40. package/dist/{chunk-O2WN732M.js → chunk-UDWGT4FX.js} +2 -2
  41. package/dist/{chunk-W2ARIOAZ.js → chunk-VNT3CQFV.js} +23 -25
  42. package/dist/chunk-VNT3CQFV.js.map +1 -0
  43. package/dist/{chunk-XRW4N23F.js → chunk-W36HL4TB.js} +6 -6
  44. package/dist/{chunk-IIE65SJC.js → chunk-WT7DHJNJ.js} +4 -4
  45. package/dist/{chunk-P22ZWXFX.js → chunk-XICKN3CH.js} +49 -4
  46. package/dist/chunk-XICKN3CH.js.map +1 -0
  47. package/dist/chunk-XMIVHQ35.js +55 -0
  48. package/dist/chunk-XMIVHQ35.js.map +1 -0
  49. package/dist/chunk-YHKXNYTB.js +105 -0
  50. package/dist/chunk-YHKXNYTB.js.map +1 -0
  51. package/dist/{chunk-H5UR3GFJ.js → chunk-YHWBDCGS.js} +272 -54
  52. package/dist/chunk-YHWBDCGS.js.map +1 -0
  53. package/dist/{hook-command-GMIDXVFK.js → chunk-YLCWI6ZR.js} +231 -40
  54. package/dist/chunk-YLCWI6ZR.js.map +1 -0
  55. package/dist/{chunk-FFL5M5BC.js → chunk-YTM7OURD.js} +2 -2
  56. package/dist/{chunk-EP5P2STS.js → chunk-Z7R2QDX2.js} +67 -10
  57. package/dist/chunk-Z7R2QDX2.js.map +1 -0
  58. package/dist/chunk-ZLD6MJVJ.js +30 -0
  59. package/dist/chunk-ZLD6MJVJ.js.map +1 -0
  60. package/dist/{cli-GGNOQQEB.js → cli-2U5JB7OQ.js} +38 -36
  61. package/dist/{cli-GGNOQQEB.js.map → cli-2U5JB7OQ.js.map} +1 -1
  62. package/dist/{config-XUUFICXK.js → config-44EGO636.js} +14 -9
  63. package/dist/{doctor-3LGF6CWI.js → doctor-BD42BBEG.js} +231 -97
  64. package/dist/doctor-BD42BBEG.js.map +1 -0
  65. package/dist/env-proxy-KEGEMWKX.js +15 -0
  66. package/dist/{fund-3URFMBMN.js → fund-WQOOUESE.js} +26 -17
  67. package/dist/fund-WQOOUESE.js.map +1 -0
  68. package/dist/hook-command-23LC5NRN.js +32 -0
  69. package/dist/index.js +5 -3
  70. package/dist/index.js.map +1 -1
  71. package/dist/{install-FRTG4KHF.js → install-REPLHNU7.js} +25 -16
  72. package/dist/{install-identity-WNXSYP6N.js → install-identity-4RDWTLJ2.js} +6 -7
  73. package/dist/{install-wallet-MXLJJP3N.js → install-wallet-USHWL7AX.js} +10 -9
  74. package/dist/{install-wallet-MXLJJP3N.js.map → install-wallet-USHWL7AX.js.map} +1 -1
  75. package/dist/{mcp-O2WJ3QBW.js → mcp-T5SYCLP7.js} +778 -83
  76. package/dist/mcp-T5SYCLP7.js.map +1 -0
  77. package/dist/{pay-43WUYTW5.js → pay-276DSSYG.js} +16 -14
  78. package/dist/{payments-7UTMMTIO.js → payments-TZYLJXK3.js} +7 -7
  79. package/dist/{send-ALHG2RXT.js → send-YHDKZPED.js} +10 -11
  80. package/dist/{send-ALHG2RXT.js.map → send-YHDKZPED.js.map} +1 -1
  81. package/dist/{status-CFPNHB6R.js → status-X2INT6VD.js} +8 -9
  82. package/dist/{status-CFPNHB6R.js.map → status-X2INT6VD.js.map} +1 -1
  83. package/dist/{status-line-FJ6N7MKJ.js → status-line-QKDJYZGV.js} +4 -5
  84. package/dist/{status-line-FJ6N7MKJ.js.map → status-line-QKDJYZGV.js.map} +1 -1
  85. package/dist/{status-line-wiring-GXFNXHPE.js → status-line-wiring-LW4HFRHB.js} +6 -4
  86. package/dist/status-line-wiring-LW4HFRHB.js.map +1 -0
  87. package/dist/{uninstall-5P2GFYBY.js → uninstall-NVTGU7JD.js} +43 -33
  88. package/dist/uninstall-NVTGU7JD.js.map +1 -0
  89. package/dist/{update-QJ5YHJ7I.js → update-QXVH2DE7.js} +25 -7
  90. package/dist/update-QXVH2DE7.js.map +1 -0
  91. package/dist/{wallet-6OJPGNEV.js → wallet-CKKB23D5.js} +10 -9
  92. package/dist/wallet-CKKB23D5.js.map +1 -0
  93. package/docs/agent-permissions.md +18 -5
  94. package/docs/troubleshooting.md +13 -0
  95. package/package.json +8 -6
  96. package/dist/chunk-EP5P2STS.js.map +0 -1
  97. package/dist/chunk-H5UR3GFJ.js.map +0 -1
  98. package/dist/chunk-KC24CYGV.js.map +0 -1
  99. package/dist/chunk-O2JYBOUO.js +0 -47
  100. package/dist/chunk-O2JYBOUO.js.map +0 -1
  101. package/dist/chunk-P22ZWXFX.js.map +0 -1
  102. package/dist/chunk-RCJ64OXH.js.map +0 -1
  103. package/dist/chunk-RGVOODF4.js.map +0 -1
  104. package/dist/chunk-S2NRVRPF.js.map +0 -1
  105. package/dist/chunk-SQSKVKX6.js.map +0 -1
  106. package/dist/chunk-TMLCEPCD.js.map +0 -1
  107. package/dist/chunk-UBOFYC6J.js.map +0 -1
  108. package/dist/chunk-W2ARIOAZ.js.map +0 -1
  109. package/dist/chunk-YXLG7Q6Q.js +0 -140
  110. package/dist/chunk-YXLG7Q6Q.js.map +0 -1
  111. package/dist/chunk-ZMFDMALH.js.map +0 -1
  112. package/dist/chunk-ZNZGBUV6.js.map +0 -1
  113. package/dist/doctor-3LGF6CWI.js.map +0 -1
  114. package/dist/fund-3URFMBMN.js.map +0 -1
  115. package/dist/hook-command-GMIDXVFK.js.map +0 -1
  116. package/dist/mcp-O2WJ3QBW.js.map +0 -1
  117. package/dist/uninstall-5P2GFYBY.js.map +0 -1
  118. package/dist/update-QJ5YHJ7I.js.map +0 -1
  119. /package/dist/{chunk-GPLSNGKX.js.map → chunk-4HAV6IFE.js.map} +0 -0
  120. /package/dist/{chunk-UXSF7IFD.js.map → chunk-5HS54CLI.js.map} +0 -0
  121. /package/dist/{chunk-YZTIYDWU.js.map → chunk-65EJJVT3.js.map} +0 -0
  122. /package/dist/{chunk-NSDZESRS.js.map → chunk-OZ3LWLCI.js.map} +0 -0
  123. /package/dist/{chunk-O2WN732M.js.map → chunk-UDWGT4FX.js.map} +0 -0
  124. /package/dist/{chunk-XRW4N23F.js.map → chunk-W36HL4TB.js.map} +0 -0
  125. /package/dist/{chunk-IIE65SJC.js.map → chunk-WT7DHJNJ.js.map} +0 -0
  126. /package/dist/{chunk-FFL5M5BC.js.map → chunk-YTM7OURD.js.map} +0 -0
  127. /package/dist/{config-XUUFICXK.js.map → config-44EGO636.js.map} +0 -0
  128. /package/dist/{install-FRTG4KHF.js.map → env-proxy-KEGEMWKX.js.map} +0 -0
  129. /package/dist/{install-identity-WNXSYP6N.js.map → hook-command-23LC5NRN.js.map} +0 -0
  130. /package/dist/{pay-43WUYTW5.js.map → install-REPLHNU7.js.map} +0 -0
  131. /package/dist/{status-line-wiring-GXFNXHPE.js.map → install-identity-4RDWTLJ2.js.map} +0 -0
  132. /package/dist/{wallet-6OJPGNEV.js.map → pay-276DSSYG.js.map} +0 -0
  133. /package/dist/{payments-7UTMMTIO.js.map → payments-TZYLJXK3.js.map} +0 -0
@@ -1,7 +1,6 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  EXPERIMENTAL_BAZAAR_WARNING,
4
- ROUTER_DEFAULTS,
5
4
  persistGrantDeclined,
6
5
  persistHookArm,
7
6
  persistInstallHarness,
@@ -11,17 +10,23 @@ import {
11
10
  runConfigGet,
12
11
  runConfigList,
13
12
  runConfigSet
14
- } from "./chunk-W2ARIOAZ.js";
13
+ } from "./chunk-VNT3CQFV.js";
14
+ import {
15
+ ROUTER_DEFAULTS
16
+ } from "./chunk-PM2MOXJ3.js";
15
17
  import "./chunk-A36LQPHV.js";
18
+ import "./chunk-OBPZ36HG.js";
19
+ import "./chunk-DI7WHXOZ.js";
20
+ import "./chunk-AKWGE6JQ.js";
21
+ import "./chunk-TGLKKLQG.js";
16
22
  import "./chunk-P7LABKCW.js";
17
23
  import "./chunk-MEFB5KHA.js";
18
- import "./chunk-NSDZESRS.js";
24
+ import "./chunk-XMIVHQ35.js";
25
+ import "./chunk-OZ3LWLCI.js";
26
+ import "./chunk-GHR4BTNJ.js";
19
27
  import "./chunk-2I4QTOLB.js";
20
- import "./chunk-TMLCEPCD.js";
21
- import "./chunk-O2JYBOUO.js";
22
- import "./chunk-P22ZWXFX.js";
23
- import "./chunk-SQSKVKX6.js";
24
- import "./chunk-ZNZGBUV6.js";
28
+ import "./chunk-HII5HOQV.js";
29
+ import "./chunk-XICKN3CH.js";
25
30
  import "./chunk-JLEF5WHM.js";
26
31
  import "./chunk-K6AXXYCG.js";
27
32
  import "./chunk-ZXTAQYNA.js";
@@ -38,4 +43,4 @@ export {
38
43
  runConfigList,
39
44
  runConfigSet
40
45
  };
41
- //# sourceMappingURL=config-XUUFICXK.js.map
46
+ //# sourceMappingURL=config-44EGO636.js.map
@@ -1,68 +1,98 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
- agentsWithoutRequestTool
4
- } from "./chunk-S2NRVRPF.js";
3
+ FileClientChannelStorage
4
+ } from "./chunk-YHKXNYTB.js";
5
+ import "./chunk-LFZJM56J.js";
5
6
  import {
6
- ROUTER_PATH
7
- } from "./chunk-EP5P2STS.js";
7
+ agentsWithoutRequestTool,
8
+ clearRouterMemo,
9
+ readRouterMemo
10
+ } from "./chunk-BOAI23CX.js";
11
+ import {
12
+ ALLOW_RULE,
13
+ mcpAddCommand,
14
+ mcpScope,
15
+ probeRouter,
16
+ readMcpEntry,
17
+ routerHookPlan,
18
+ routerSettingsPath
19
+ } from "./chunk-YHWBDCGS.js";
20
+ import "./chunk-Z7R2QDX2.js";
21
+ import {
22
+ readMcpServers
23
+ } from "./chunk-H4BOQLWW.js";
24
+ import "./chunk-EL56RW2J.js";
25
+ import "./chunk-TTNESUPQ.js";
26
+ import {
27
+ STATUS_LINE_COMMAND,
28
+ inspectStatusLine
29
+ } from "./chunk-65EJJVT3.js";
8
30
  import {
9
31
  describeWallet,
10
32
  resolveWalletProvider,
11
33
  walletFileExists
12
- } from "./chunk-GPLSNGKX.js";
13
- import "./chunk-XZUGRTSV.js";
14
- import "./chunk-ZMFDMALH.js";
34
+ } from "./chunk-4HAV6IFE.js";
35
+ import "./chunk-5NUF4BHR.js";
36
+ import {
37
+ readSpendSummary,
38
+ spentOf
39
+ } from "./chunk-6JIYGYRB.js";
40
+ import "./chunk-UDWGT4FX.js";
15
41
  import "./chunk-N35E6CM2.js";
16
42
  import "./chunk-JRGFKVAZ.js";
17
43
  import "./chunk-EGELTSPU.js";
18
44
  import "./chunk-KG3D7FIF.js";
19
45
  import "./chunk-RBJPAZFI.js";
20
46
  import "./chunk-BPMWXTFX.js";
47
+ import "./chunk-ZLD6MJVJ.js";
48
+ import "./chunk-5INS5ZZF.js";
21
49
  import {
22
- ALLOW_RULE,
23
- mcpAddCommand,
24
- mcpScope,
25
- readMcpEntry,
26
- routerHookPlan,
27
- routerSettingsPath
28
- } from "./chunk-H5UR3GFJ.js";
50
+ onPath
51
+ } from "./chunk-VNT3CQFV.js";
52
+ import {
53
+ ACCEPT_COMMAND,
54
+ OWN_LIMITS_COMMANDS,
55
+ shownLimits,
56
+ spendQuestion
57
+ } from "./chunk-PM2MOXJ3.js";
58
+ import "./chunk-A36LQPHV.js";
59
+ import {
60
+ CHANNEL_DEPOSIT_ATOMIC,
61
+ MIN_DEPOSIT_ATOMIC,
62
+ ROUTING_FEE_ATOMIC,
63
+ feeRefusal,
64
+ payerDir,
65
+ unpaid,
66
+ usd
67
+ } from "./chunk-OBPZ36HG.js";
68
+ import {
69
+ inspectHooksFile,
70
+ ownsHookEntry,
71
+ pruneOurHandlers
72
+ } from "./chunk-DI7WHXOZ.js";
73
+ import "./chunk-AKWGE6JQ.js";
29
74
  import {
30
75
  MCP_SERVER_NAME,
31
76
  REQUEST_TOOL
32
77
  } from "./chunk-TGLKKLQG.js";
33
- import "./chunk-O2WN732M.js";
34
- import {
35
- httpRequest
36
- } from "./chunk-RCJ64OXH.js";
37
- import {
38
- onPath
39
- } from "./chunk-W2ARIOAZ.js";
40
- import "./chunk-A36LQPHV.js";
41
78
  import "./chunk-P7LABKCW.js";
42
79
  import "./chunk-MEFB5KHA.js";
80
+ import {
81
+ evaluateSpendPolicy
82
+ } from "./chunk-XMIVHQ35.js";
43
83
  import {
44
84
  routerSettings
45
- } from "./chunk-NSDZESRS.js";
85
+ } from "./chunk-OZ3LWLCI.js";
86
+ import "./chunk-GHR4BTNJ.js";
46
87
  import "./chunk-2I4QTOLB.js";
47
88
  import {
48
89
  resolveContextSettings
49
- } from "./chunk-TMLCEPCD.js";
90
+ } from "./chunk-HII5HOQV.js";
50
91
  import {
92
+ loadRawConfig,
93
+ readUsdcBalance,
51
94
  toMoney
52
- } from "./chunk-O2JYBOUO.js";
53
- import {
54
- PRODUCTION_ORIGIN
55
- } from "./chunk-P22ZWXFX.js";
56
- import {
57
- STATUS_LINE_COMMAND,
58
- inspectStatusLine
59
- } from "./chunk-YZTIYDWU.js";
60
- import {
61
- inspectHooksFile,
62
- ownsHookEntry,
63
- pruneOurHandlers
64
- } from "./chunk-SQSKVKX6.js";
65
- import "./chunk-ZNZGBUV6.js";
95
+ } from "./chunk-XICKN3CH.js";
66
96
  import {
67
97
  CliError
68
98
  } from "./chunk-JLEF5WHM.js";
@@ -71,7 +101,9 @@ import "./chunk-ZXTAQYNA.js";
71
101
 
72
102
  // src/router/doctor.ts
73
103
  import { execFile } from "node:child_process";
104
+ import { readdir } from "node:fs/promises";
74
105
  import { homedir } from "node:os";
106
+ import { join } from "node:path";
75
107
  import { promisify } from "node:util";
76
108
  var exec = promisify(execFile);
77
109
  var NODE_FLOOR = 24;
@@ -99,10 +131,33 @@ async function runRouterDoctor(ctx, deps = {}) {
99
131
  deps.homeDir ?? homedir()
100
132
  )
101
133
  );
102
- checks.push(spendCheck(settings.policy.maxAutoSpendAtomic, settings.policy.sessionBudgetAtomic));
134
+ checks.push((await readMcpServers(deps)).check);
135
+ const rawConfig = await loadRawConfig(ctx.dataDir);
136
+ const unanswered = rawConfig.maxAutoSpend === void 0 ? { limits: shownLimits(rawConfig) } : null;
137
+ checks.push(
138
+ spendCheck(settings.policy.maxAutoSpendAtomic, settings.policy.sessionBudgetAtomic, unanswered)
139
+ );
103
140
  checks.push(experimentalCheck(settings.experimentalBazaar));
141
+ checks.push(await routingFeeCheck(ctx, settings, deps.fetchImpl, unanswered));
104
142
  checks.push(...await walletCheck(ctx));
105
- checks.push(await routerCheck(settings.baseUrl, ctx.flags.timeout, deps.fetchImpl));
143
+ const now = deps.now?.() ?? Date.now();
144
+ const probe = await probeRouter(settings.baseUrl, {
145
+ timeoutMs: ctx.flags.timeout,
146
+ env,
147
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
148
+ });
149
+ if (probe.status === "ok") {
150
+ await clearRouterMemo(ctx.dataDir, "unreachable", settings.baseUrl);
151
+ checks.push(probe);
152
+ } else {
153
+ checks.push(
154
+ withBackoff(
155
+ probe,
156
+ await readRouterMemo(ctx.dataDir, "unreachable", settings.baseUrl, now),
157
+ now
158
+ )
159
+ );
160
+ }
106
161
  const agents = await subagentsCheck(deps.cwd ?? process.cwd(), deps.homeDir ?? homedir());
107
162
  if (agents !== null) checks.push(agents);
108
163
  const failure = checks.find((c) => c.status === "fail" && c.required);
@@ -113,15 +168,25 @@ async function runRouterDoctor(ctx, deps = {}) {
113
168
  details: data
114
169
  });
115
170
  }
171
+ return { data, humanLines: doctorLines(checks) };
172
+ }
173
+ function doctorLines(checks) {
116
174
  const bad = checks.filter((c) => c.status !== "ok").length;
175
+ return [
176
+ ...checks.flatMap((c) => [
177
+ `${c.status === "ok" ? "ok " : c.status === "warn" ? "warn" : "fail"} ${c.name}: ${c.detail}`,
178
+ ...c.status !== "ok" && c.fix !== void 0 ? [` fix: ${c.fix}`] : []
179
+ ]),
180
+ bad === 0 ? `${checks.length} checks, all pass.` : `${checks.length} checks, ${bad} to look at.`
181
+ ];
182
+ }
183
+ function withBackoff(check, memo, now) {
184
+ if (memo === null) return check;
185
+ const left = Math.max(1, Math.ceil((memo.until - now) / 1e3));
117
186
  return {
118
- data,
119
- humanLines: [
120
- ...checks.map(
121
- (c) => `${c.status === "ok" ? "ok " : c.status === "warn" ? "warn" : "fail"} ${c.name}: ${c.detail}`
122
- ),
123
- bad === 0 ? `${checks.length} checks, all pass.` : `${checks.length} checks, ${bad} to look at.`
124
- ]
187
+ ...check,
188
+ status: check.status === "ok" ? "warn" : check.status,
189
+ detail: `${check.detail}; routing calls skip the router for ${left}s more, after one did not reach it`
125
190
  };
126
191
  }
127
192
  async function subagentsCheck(cwd, homeDir) {
@@ -249,12 +314,14 @@ async function hooksCheck(path, dataDir, router) {
249
314
  detail: `${events.join(" and ")} registered, ${ALLOW_RULE} allowed`
250
315
  };
251
316
  }
252
- function entryLabel(event, matcher, command) {
253
- return `${event}${typeof matcher === "string" ? ` ${matcher}` : ""} \u2192 ${command}`;
317
+ function entryLabel(event, matcher, handler) {
318
+ const h = handler ?? {};
319
+ const runs = h.type === "mcp_tool" ? `${String(h.server)} ${String(h.tool)} ${String(h.input?.kind)}` : typeof h.command === "string" ? h.command : typeof h.url === "string" ? h.url : "?";
320
+ return `${event}${typeof matcher === "string" ? ` ${matcher}` : ""} \u2192 ${runs}`;
254
321
  }
255
322
  function planDrift(hooks, dataDir) {
256
323
  const planned = routerHookPlan().map(
257
- (entry) => entryLabel(entry.event, entry.matcher, entry.hooks[0].command)
324
+ (entry) => entryLabel(entry.event, entry.matcher, entry.hooks[0])
258
325
  );
259
326
  const present = [];
260
327
  for (const [event, list] of Object.entries(hooks)) {
@@ -263,10 +330,7 @@ function planDrift(hooks, dataDir) {
263
330
  const { matcher, hooks: handlers } = entry;
264
331
  const kept = pruneOurHandlers(entry, dataDir);
265
332
  for (const handler of handlers.filter((h) => kept === null || !kept.hooks.includes(h))) {
266
- const command = handler.command;
267
- const url = handler.url;
268
- const label = typeof command === "string" ? command : typeof url === "string" ? url : "?";
269
- present.push(entryLabel(event, matcher, label));
333
+ present.push(entryLabel(event, matcher, handler));
270
334
  }
271
335
  }
272
336
  }
@@ -344,6 +408,104 @@ async function claudeHasServer(opts) {
344
408
  });
345
409
  return stdout.includes(MCP_SERVER_NAME) && !/no mcp server/i.test(stdout);
346
410
  }
411
+ async function routingFeeCheck(ctx, settings, fetchImpl, unanswered) {
412
+ let host;
413
+ try {
414
+ host = new URL(settings.baseUrl).host;
415
+ } catch {
416
+ return {
417
+ name: "routing fee",
418
+ status: "warn",
419
+ required: false,
420
+ detail: "not checked, because the base URL is not a URL"
421
+ };
422
+ }
423
+ const why = await routingFeeBlock({
424
+ dataDir: ctx.dataDir,
425
+ policy: settings.policy,
426
+ rpcUrl: settings.rpcUrl,
427
+ host,
428
+ timeoutMs: ctx.flags.timeout,
429
+ provider: await walletFileExists(ctx.dataDir) ? resolveWalletProvider(ctx) : null,
430
+ ...fetchImpl !== void 0 ? { fetchImpl } : {}
431
+ }).catch(() => null);
432
+ return routingFeeRow(why, host, unanswered);
433
+ }
434
+ function routingFeeRow(why, host, unanswered) {
435
+ const u = why === null ? null : unpaid(why);
436
+ if (why === null || u === null) {
437
+ return {
438
+ name: "routing fee",
439
+ status: "ok",
440
+ required: false,
441
+ detail: `$${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that count against the spend limits`
442
+ };
443
+ }
444
+ if (why === "limit_below_deposit" && unanswered !== null) {
445
+ return {
446
+ name: "routing fee",
447
+ status: "warn",
448
+ required: false,
449
+ detail: "the spend limits are not answered yet, so routing calls take the free path",
450
+ fix: `Answer the spend question: ${spendQuestion(unanswered.limits)} For a yes, run \`${ACCEPT_COMMAND}\`; for other amounts, ${OWN_LIMITS_COMMANDS}.`
451
+ };
452
+ }
453
+ const fixes = {
454
+ no_wallet: "Run `tenjin wallet create`, then `tenjin wallet fund 0.25`.",
455
+ limit_below_deposit: `Raise it with \`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\`.`,
456
+ budget_reached: "Room comes back as the rolling day passes, or raise it with `tenjin config set sessionBudget <usd>`.",
457
+ not_allowlisted: `Add ${host} to allowlistCreators, or clear the allowlist.`
458
+ };
459
+ return {
460
+ name: "routing fee",
461
+ status: "warn",
462
+ required: false,
463
+ detail: `${u.reason}, so routing calls take the free path`,
464
+ fix: fixes[why] ?? u.fix
465
+ };
466
+ }
467
+ async function routingFeeBlock(input) {
468
+ const { provider, policy } = input;
469
+ const refused = feeRefusal(policy, input.host);
470
+ if (refused !== null) return refused;
471
+ if (provider === null) return "no_wallet";
472
+ const verified = await provider.verify?.().catch(() => null);
473
+ if (verified !== void 0 && verified !== null && verified.status !== "verified") {
474
+ return "wallet_locked";
475
+ }
476
+ const ledger = await readSpendSummary(input.dataDir);
477
+ const spent = ledger === null ? 0n : spentOf(ledger);
478
+ const { address } = await describeWallet(provider);
479
+ if (await channelCredit(input.dataDir, address) >= ROUTING_FEE_ATOMIC) return null;
480
+ const deposit = policy.maxAutoSpendAtomic < CHANNEL_DEPOSIT_ATOMIC ? policy.maxAutoSpendAtomic : CHANNEL_DEPOSIT_ATOMIC;
481
+ if (deposit < MIN_DEPOSIT_ATOMIC) return "limit_below_deposit";
482
+ const evaluation = evaluateSpendPolicy(policy, {
483
+ mode: "automatic",
484
+ amountAtomic: deposit,
485
+ creator: input.host,
486
+ sessionSpentAtomic: spent
487
+ });
488
+ if (evaluation.reason === "not_allowlisted") return "not_allowlisted";
489
+ if (evaluation.reason === "session_budget_exceeded") return "budget_reached";
490
+ const balance = await readUsdcBalance(address, input.rpcUrl, {
491
+ timeoutMs: input.timeoutMs,
492
+ ...input.fetchImpl !== void 0 ? { fetchImpl: input.fetchImpl } : {}
493
+ });
494
+ return balance !== null && balance < deposit ? "wallet_low" : null;
495
+ }
496
+ async function channelCredit(dataDir, address) {
497
+ const dir = payerDir(dataDir, address);
498
+ const storage = new FileClientChannelStorage({ directory: dir });
499
+ let best = 0n;
500
+ for (const name of await readdir(join(dir, "client")).catch(() => [])) {
501
+ const id = /^(0x[0-9a-f]{64})\.json$/.exec(name)?.[1];
502
+ const channel = id === void 0 ? void 0 : await storage.get(id).catch(() => void 0);
503
+ if (channel === void 0) continue;
504
+ const credit = BigInt(channel.balance ?? "0") - BigInt(channel.chargedCumulativeAmount ?? "0");
505
+ if (credit > best) best = credit;
506
+ }
507
+ return best;
508
+ }
347
509
  function experimentalCheck(bazaar) {
348
510
  return {
349
511
  name: "experimental",
@@ -352,7 +514,7 @@ function experimentalCheck(bazaar) {
352
514
  detail: bazaar ? "list: on; bazaar: on (experimental): the router may also suggest unreviewed sellers from the open x402 Bazaar" : "list: on; bazaar: off (experimental): `tenjin config set experimental.bazaar on` to add the open x402 Bazaar"
353
515
  };
354
516
  }
355
- function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic) {
517
+ function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic, unanswered) {
356
518
  if (sessionBudgetAtomic === 0n) {
357
519
  return {
358
520
  name: "spend",
@@ -362,13 +524,22 @@ function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic) {
362
524
  fix: "Choose a daily limit with `tenjin config set sessionBudget <usd|none>`."
363
525
  };
364
526
  }
527
+ if (maxAutoSpendAtomic === 0n && unanswered !== null) {
528
+ return {
529
+ name: "spend",
530
+ status: "warn",
531
+ required: false,
532
+ detail: `the spend limits are not answered yet, so automatic payments are off and every lookup needs approval. Ask the user: ${spendQuestion(unanswered.limits)}`,
533
+ fix: `Answer the spend question: for a yes, run \`${ACCEPT_COMMAND}\`; for other amounts, ${OWN_LIMITS_COMMANDS}; or run \`tenjin install\` in a terminal to choose.`
534
+ };
535
+ }
365
536
  if (maxAutoSpendAtomic === 0n) {
366
537
  return {
367
538
  name: "spend",
368
539
  status: "fail",
369
540
  required: true,
370
541
  detail: "maxAutoSpend is 0, so every lookup needs approval and none can pay",
371
- fix: "Run `tenjin install`, or `tenjin config set maxAutoSpend 0.10`."
542
+ fix: "Set a per-call limit with `tenjin config set maxAutoSpend <usd>`."
372
543
  };
373
544
  }
374
545
  const budget = sessionBudgetAtomic === null ? "no daily ceiling" : `${toMoney(sessionBudgetAtomic.toString()).usd} USD a day`;
@@ -407,47 +578,10 @@ async function walletCheck(ctx) {
407
578
  ];
408
579
  }
409
580
  }
410
- async function routerCheck(baseUrl, timeoutMs, fetchImpl) {
411
- const url = new URL(ROUTER_PATH, baseUrl).toString();
412
- const probe = await httpRequest(url, {
413
- method: "POST",
414
- timeoutMs,
415
- blockRedirects: true,
416
- jsonBody: {},
417
- ...fetchImpl !== void 0 ? { fetchImpl } : {}
418
- });
419
- const fail = (detail, fix) => ({
420
- name: "router",
421
- status: "fail",
422
- required: true,
423
- detail,
424
- fix
425
- });
426
- const checkBase = "Check that the configured base URL names the Tenjin router (`tenjin config get baseUrl`), then try again later.";
427
- if (!probe.ok) {
428
- return fail(`the router at ${url} is unreachable or erroring (${probe.message})`, checkBase);
429
- }
430
- if (probe.status === 200 || probe.status === 400 || probe.status === 429) {
431
- return { name: "router", status: "ok", required: true, detail: `${url} is live` };
432
- }
433
- if (probe.status === 404) {
434
- return fail(`the router is not enabled at ${url}`, checkBase);
435
- }
436
- if (probe.status === 401 || probe.status === 403) {
437
- return fail(
438
- `${url} is not a Tenjin router (it asked for credentials)`,
439
- `Set the router URL with \`tenjin config set baseUrl ${PRODUCTION_ORIGIN}\`.`
440
- );
441
- }
442
- if (probe.status >= 500) {
443
- return fail(`the router at ${url} is unreachable or erroring (${probe.status})`, checkBase);
444
- }
445
- return fail(
446
- `${url} answered ${probe.status}, which a Tenjin router does not`,
447
- "Check that the configured base URL names a Tenjin deployment (`tenjin config get baseUrl`)."
448
- );
449
- }
450
581
  export {
582
+ doctorLines,
583
+ routingFeeBlock,
584
+ routingFeeRow,
451
585
  runRouterDoctor
452
586
  };
453
- //# sourceMappingURL=doctor-3LGF6CWI.js.map
587
+ //# sourceMappingURL=doctor-BD42BBEG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/doctor.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readdir } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { FileClientChannelStorage } from '@x402/evm/batch-settlement/client/file-storage';\nimport { loadRawConfig } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { inspectHooksFile, ownsHookEntry, pruneOurHandlers } from '../lib/harness-hooks';\nimport { toMoney } from '../lib/money';\nimport { evaluateSpendPolicy, type SpendPolicy } from '../lib/policy';\nimport { resolveContextSettings, type ResolvedSettings } from '../lib/settings';\nimport { spentOf } from '../lib/spend-ledger';\nimport { readUsdcBalance } from '../lib/usdc-balance';\nimport { onPath } from '../lib/skill-wiring';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport { readSpendSummary } from '../lib/wallet/spend';\nimport { walletFileExists } from '../lib/wallet/store';\nimport type { CommandContext, CommandResult } from '../context';\nimport { agentsWithoutRequestTool } from './agent-tools';\nimport {\n CHANNEL_DEPOSIT_ATOMIC,\n feeRefusal,\n MIN_DEPOSIT_ATOMIC,\n payerDir,\n ROUTING_FEE_ATOMIC,\n unpaid,\n usd,\n} from './fee';\nimport {\n ALLOW_RULE,\n MCP_SERVER_NAME,\n mcpAddCommand,\n mcpScope,\n readMcpEntry,\n routerHookPlan,\n routerSettingsPath,\n type McpEntryState,\n} from './install';\nimport { routerSettings, type RouterSettings } from './settings';\nimport { REQUEST_TOOL } from './names';\nimport { probeRouter, type RouterCheck } from './reachability';\nimport { readMcpServers, type InstalledAt, type ListMcpProcesses } from './mcp-processes';\nimport { clearRouterMemo, readRouterMemo, type RouterMemo } from './router-memo';\nimport {\n ACCEPT_COMMAND,\n OWN_LIMITS_COMMANDS,\n shownLimits,\n spendQuestion,\n type RouterLimits,\n} from './spend-question';\nimport { inspectStatusLine, STATUS_LINE_COMMAND } from './status-line-wiring';\n\n/**\n * `tenjin doctor` for the router product: the six things that decide whether a\n * lookup can happen at all.\n *\n * THE SHELF'S DOCTOR IS NOT THIS ONE. It checks a loop daemon, a skills tree\n * and a marketplace contract, and prescribes `tenjin daemon start`, a command\n * this release does not register: on a router install every one of those lines\n * was a failure about a product that is not installed. That doctor stays with\n * the product it belongs to (`src/commands/doctor.ts`, unregistered), and this\n * one reports the router's own wiring.\n */\n\nconst exec = promisify(execFile);\n\nexport type { RouterCheck };\n\nexport interface RouterDoctorDeps {\n homeDir?: string;\n cwd?: string;\n /** Look at this project's `.claude/settings.json`, as `--project` installed it. */\n project?: boolean;\n env?: NodeJS.ProcessEnv;\n which?: (bin: string) => boolean;\n fetchImpl?: typeof fetch;\n /** The harness's own read-back, for a user-scope registration this build\n * cannot find on disk; tests inject it so nothing is spawned. */\n readMcp?: (opts: { scope: 'user' | 'project'; cwd: string }) => Promise<boolean>;\n /** Reads the registration entry from the file the scope writes. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n /** Node's own version, for the floor check. */\n nodeVersion?: string;\n /** This user's running `tenjin mcp` processes; tests inject them. */\n listMcpProcesses?: ListMcpProcesses;\n /** When this build was installed; tests inject it. */\n installedAt?: InstalledAt;\n now?: () => number;\n}\n\nconst NODE_FLOOR = 24;\n\nexport async function runRouterDoctor(\n ctx: CommandContext,\n deps: RouterDoctorDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n // From the directory doctor runs in, which is the one a session there would use.\n const router = await routerSettings(\n { cwd: deps.cwd ?? process.cwd(), dataDir: ctx.dataDir },\n deps.homeDir !== undefined ? { homeDir: deps.homeDir } : {},\n ).catch((err: unknown) => (err instanceof Error ? err : new Error(String(err))));\n const settings = await resolveContextSettings(ctx);\n // The SAME resolution `install` and `uninstall` use. Reading the home file\n // only made a correctly wired `--project` install, which the README tells\n // people to do, fail a required check and exit 3.\n const settingsPath = routerSettingsPath({\n ...(deps.project === true ? { project: true } : {}),\n ...(deps.homeDir !== undefined ? { homeDir: deps.homeDir } : {}),\n ...(deps.cwd !== undefined ? { cwd: deps.cwd } : {}),\n });\n const checks: RouterCheck[] = [nodeCheck(deps.nodeVersion ?? process.version)];\n checks.push(await hooksCheck(settingsPath, ctx.dataDir, router));\n checks.push(await statusLineCheck(settingsPath));\n checks.push(\n await mcpCheck(\n deps,\n env,\n deps.project === true,\n deps.cwd ?? process.cwd(),\n deps.homeDir ?? homedir(),\n ),\n );\n checks.push((await readMcpServers(deps)).check);\n const rawConfig = await loadRawConfig(ctx.dataDir);\n const unanswered =\n rawConfig.maxAutoSpend === undefined ? { limits: shownLimits(rawConfig) } : null;\n checks.push(\n spendCheck(settings.policy.maxAutoSpendAtomic, settings.policy.sessionBudgetAtomic, unanswered),\n );\n checks.push(experimentalCheck(settings.experimentalBazaar));\n checks.push(await routingFeeCheck(ctx, settings, deps.fetchImpl, unanswered));\n checks.push(...(await walletCheck(ctx)));\n const now = deps.now?.() ?? Date.now();\n const probe = await probeRouter(settings.baseUrl, {\n timeoutMs: ctx.flags.timeout,\n env,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n // A probe the router answered ends the routing legs' backoff at once.\n if (probe.status === 'ok') {\n await clearRouterMemo(ctx.dataDir, 'unreachable', settings.baseUrl);\n checks.push(probe);\n } else {\n checks.push(\n withBackoff(\n probe,\n await readRouterMemo(ctx.dataDir, 'unreachable', settings.baseUrl, now),\n now,\n ),\n );\n }\n const agents = await subagentsCheck(deps.cwd ?? process.cwd(), deps.homeDir ?? homedir());\n if (agents !== null) checks.push(agents);\n\n const failure = checks.find((c) => c.status === 'fail' && c.required);\n const data = { checks, dataDir: ctx.dataDir, baseUrl: settings.baseUrl, settingsPath };\n if (failure !== undefined) {\n // REFUSED, the exit-3 class: a machine this command found unready is\n // understood and refused, not a runtime failure of the command itself.\n throw new CliError('REFUSED', failure.detail, {\n ...(failure.fix !== undefined ? { fix: failure.fix } : {}),\n details: data,\n });\n }\n return { data, humanLines: doctorLines(checks) };\n}\n\n/** The human report: one line a check, and under each row to look at, its\n * fix, as `--json` carries it. */\nexport function doctorLines(checks: RouterCheck[]): string[] {\n const bad = checks.filter((c) => c.status !== 'ok').length;\n return [\n ...checks.flatMap((c) => [\n `${c.status === 'ok' ? 'ok ' : c.status === 'warn' ? 'warn' : 'fail'} ${c.name}: ${c.detail}`,\n ...(c.status !== 'ok' && c.fix !== undefined ? [` fix: ${c.fix}`] : []),\n ]),\n bad === 0\n ? `${checks.length} checks, all pass.`\n : `${checks.length} checks, ${bad} to look at.`,\n ];\n}\n\n/**\n * The routing legs' backoff, named on a router line whose probe failed too.\n * It ends by itself after its minute, or when a probe here reaches the router.\n */\nfunction withBackoff(check: RouterCheck, memo: RouterMemo | null, now: number): RouterCheck {\n if (memo === null) return check;\n const left = Math.max(1, Math.ceil((memo.until - now) / 1000));\n return {\n ...check,\n status: check.status === 'ok' ? 'warn' : check.status,\n detail: `${check.detail}; routing calls skip the router for ${left}s more, after one did not reach it`,\n };\n}\n\n/**\n * INFORMATIONAL, NEVER A FAILURE. A custom agent whose `tools:` leave the\n * request tool out is a choice its author may have meant, so this names those\n * agents and the one line that would change it, and counts as passing. It is\n * absent when there is nothing to name. The files are only read.\n */\nasync function subagentsCheck(cwd: string, homeDir: string): Promise<RouterCheck | null> {\n const excluded = await agentsWithoutRequestTool({ cwd, homeDir });\n if (excluded.length === 0) return null;\n return {\n name: 'subagents',\n status: 'ok',\n required: false,\n detail: `${excluded.join(', ')} ${excluded.length === 1 ? 'is' : 'are'} offered no paid lookups: add ${REQUEST_TOOL} to tools: to allow paid lookups there`,\n };\n}\n\nfunction nodeCheck(version: string): RouterCheck {\n const major = Number(/^v(\\d+)/.exec(version)?.[1] ?? '0');\n return major >= NODE_FLOOR\n ? { name: 'node', status: 'ok', required: true, detail: version }\n : {\n name: 'node',\n status: 'fail',\n required: true,\n detail: `${version} is below the Node ${NODE_FLOOR} floor.`,\n fix: `Install Node ${NODE_FLOOR} or newer, then re-run \\`tenjin doctor\\`.`,\n };\n}\n\n/**\n * The live footer, which is the one check here that is never required: a lookup\n * runs exactly the same without it. It reports what is in the file, including a\n * status line of the user's that this CLI deliberately did not touch.\n */\nasync function statusLineCheck(path: string): Promise<RouterCheck> {\n const found = await inspectStatusLine(path);\n const name = 'status line';\n if (found.warning !== undefined) {\n return { name, status: 'warn', required: false, detail: found.warning };\n }\n switch (found.state) {\n case 'ours':\n return { name, status: 'ok', required: false, detail: `\\`${STATUS_LINE_COMMAND}\\`` };\n case 'composed':\n return {\n name,\n status: 'ok',\n required: false,\n detail: 'yours, with the x402 footer appended',\n };\n case 'foreign':\n return {\n name,\n status: 'warn',\n required: false,\n detail: 'yours is registered and was left alone, so there is no live x402 footer',\n fix: 'Run `tenjin install --status-line compose` to show both.',\n };\n default:\n return {\n name,\n status: 'warn',\n required: false,\n detail: 'not registered, so lookups run without the live footer',\n fix: 'Run `tenjin install` to register it.',\n };\n }\n}\n\nasync function hooksCheck(\n path: string,\n dataDir: string,\n router: RouterSettings | Error,\n): Promise<RouterCheck> {\n const found = await inspectHooksFile(path);\n if ('refusal' in found) {\n return {\n name: 'hooks',\n status: 'fail',\n required: true,\n detail: found.refusal.message,\n fix: 'Fix the reported file, then run `tenjin install`.',\n };\n }\n const events = Object.entries(found.hooks)\n .filter(([, list]) => list.some((entry) => ownsHookEntry(entry, dataDir)))\n .map(([event]) => event);\n const allow = allowRules(found.settings);\n if (events.length === 0) {\n return {\n name: 'hooks',\n status: 'fail',\n required: true,\n detail: `no Tenjin hook entries in ${path}`,\n fix: 'Run `tenjin install`, then restart Claude Code.',\n };\n }\n // WIRED BUT SWITCHED OFF is a choice, not a fault, so it warns and names the\n // file that made it: the entries are there and every one of them is silent.\n if (router instanceof Error) {\n return {\n name: 'hooks',\n status: 'warn',\n required: false,\n detail: `${events.join(' and ')} registered, but the router is off here: ${router.message}`,\n fix: 'Fix or delete that file.',\n };\n }\n if (!router.enabled.value) {\n const file = router.enabled.path ?? 'the config';\n return {\n name: 'hooks',\n status: 'warn',\n required: false,\n detail: `${events.join(' and ')} registered, but router.enabled is false in ${file}, so nothing is routed from this directory`,\n fix:\n router.enabled.source === 'file'\n ? 'Run `tenjin config set router.enabled true` to route again.'\n : `Remove router.enabled from ${file} to route here again.`,\n };\n }\n if (!allow.includes(ALLOW_RULE)) {\n return {\n name: 'hooks',\n status: 'warn',\n required: false,\n detail: `${events.join(' and ')} registered, but ${ALLOW_RULE} is not allowed, so every lookup asks`,\n fix: 'Run `tenjin install` to write the permission rule.',\n };\n }\n // AN INSTALL FROM AN OLDER BUILD STILL WORKS, so this is a warning with its\n // one-command remedy, not a failure: its `tenjin hook` command entries take\n // the free path only, and the entries it lacks are offers it does not make.\n const drift = planDrift(found.hooks, dataDir);\n if (drift.missing.length > 0 || drift.stale.length > 0) {\n const parts = [\n ...(drift.missing.length > 0 ? [`missing ${drift.missing.join(', ')}`] : []),\n ...(drift.stale.length > 0 ? [`stale ${drift.stale.join(', ')}`] : []),\n ];\n return {\n name: 'hooks',\n status: 'warn',\n required: false,\n detail: `${events.join(' and ')} registered, but not as this build writes them: ${parts.join('; ')}`,\n fix: 'Run `tenjin install --refresh`.',\n };\n }\n return {\n name: 'hooks',\n status: 'ok',\n required: true,\n detail: `${events.join(' and ')} registered, ${ALLOW_RULE} allowed`,\n };\n}\n\n/** One entry as `event matcher → what it runs`, the way doctor names it. */\nfunction entryLabel(event: string, matcher: unknown, handler: unknown): string {\n const h = (handler ?? {}) as Record<string, unknown>;\n const runs =\n h.type === 'mcp_tool'\n ? `${String(h.server)} ${String(h.tool)} ${String((h.input as { kind?: unknown } | undefined)?.kind)}`\n : typeof h.command === 'string'\n ? h.command\n : typeof h.url === 'string'\n ? h.url\n : '?';\n return `${event}${typeof matcher === 'string' ? ` ${matcher}` : ''} → ${runs}`;\n}\n\n/**\n * Which of `routerHookPlan()`'s entries this file lacks, and which handlers of\n * ours it carries that the plan no longer writes (an older install's\n * `tenjin hook prompt` command, or a shelf-era entry). Compared by event,\n * matcher and what the handler runs, so a timeout the writer would raise is not\n * called drift here.\n */\nfunction planDrift(\n hooks: Record<string, unknown[]>,\n dataDir: string,\n): { missing: string[]; stale: string[] } {\n const planned = (routerHookPlan() as PlannedEntry[]).map((entry) =>\n entryLabel(entry.event, entry.matcher, entry.hooks[0]),\n );\n const present: string[] = [];\n for (const [event, list] of Object.entries(hooks)) {\n for (const entry of list) {\n if (!ownsHookEntry(entry, dataDir)) continue;\n const { matcher, hooks: handlers } = entry as { matcher?: unknown; hooks: unknown[] };\n // Ours only: a handler someone hand-merged beside ours is not drift.\n const kept = pruneOurHandlers(entry, dataDir) as { hooks: unknown[] } | null;\n for (const handler of handlers.filter((h) => kept === null || !kept.hooks.includes(h))) {\n present.push(entryLabel(event, matcher, handler));\n }\n }\n }\n return {\n missing: planned.filter((label) => !present.includes(label)),\n stale: present.filter((label) => !planned.includes(label)),\n };\n}\n\ninterface PlannedEntry {\n event: string;\n matcher?: string;\n hooks: unknown[];\n}\n\nfunction allowRules(settings: Record<string, unknown>): string[] {\n const permissions = settings.permissions;\n if (permissions === null || typeof permissions !== 'object' || Array.isArray(permissions)) {\n return [];\n }\n const allow = (permissions as { allow?: unknown }).allow;\n return Array.isArray(allow) ? allow.filter((r): r is string => typeof r === 'string') : [];\n}\n\nasync function mcpCheck(\n deps: RouterDoctorDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<RouterCheck> {\n const scope = mcpScope(project);\n const add = mcpAddCommand(project);\n const where = scope === 'project' ? \"this project's .mcp.json\" : '~/.claude.json';\n const { found, state } = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n\n if (state === 'ok') {\n return {\n name: 'mcp',\n status: 'ok',\n required: true,\n detail: `${MCP_SERVER_NAME} registered (${scope} scope), running \\`tenjin mcp\\``,\n };\n }\n if (state === 'wrong-command') {\n return {\n name: 'mcp',\n status: 'fail',\n required: true,\n detail: `${MCP_SERVER_NAME} registered but not \\`tenjin mcp\\`: the entry in ${where} launches something else, so the request tool is not there`,\n fix: `Remove it and re-run \\`tenjin install\\`${project ? ' --project' : ''}, or: ${add}`,\n };\n }\n // A file that is there and unreadable is not an absence: \"run install\" would\n // be the wrong instruction, since `install` refuses to write over it too.\n if (state === 'unreadable') {\n return {\n name: 'mcp',\n status: 'fail',\n required: true,\n detail: `${where} could not be read, so whether ${MCP_SERVER_NAME} is registered is unknown`,\n fix: `Fix the JSON in ${where}, then re-run \\`tenjin install\\`${project ? ' --project' : ''}.`,\n };\n }\n // Absent. On USER scope the file may simply not be where this build looks,\n // so the harness's own answer is worth asking before calling it missing.\n if (scope === 'user') {\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (which('claude')) {\n const seen = await (deps.readMcp ?? claudeHasServer)({ scope, cwd }).catch(() => false);\n if (seen) {\n return {\n name: 'mcp',\n status: 'warn',\n required: false,\n detail: `${MCP_SERVER_NAME} is registered somewhere this check cannot read, so what it launches was not verified`,\n fix: `Re-run \\`tenjin install\\` to write a registration this build can check, or: ${add}`,\n };\n }\n }\n }\n return {\n name: 'mcp',\n status: 'fail',\n required: true,\n detail: found\n ? `${MCP_SERVER_NAME} is not in ${where}, so there is no request tool`\n : `${where} does not exist, so ${MCP_SERVER_NAME} is not registered`,\n fix: `Run \\`tenjin install\\`${project ? ' --project' : ''}, or: ${add}`,\n };\n}\n\n/** The harness's own answer, for a user-scope registration this build cannot\n * find on disk. It resolves across scopes, which is why it is a last resort\n * and only ever downgrades the verdict to a warn. */\nasync function claudeHasServer(opts: { scope: 'user' | 'project'; cwd: string }): Promise<boolean> {\n const { stdout } = await exec('claude', ['mcp', 'get', MCP_SERVER_NAME], {\n timeout: 15_000,\n cwd: opts.cwd,\n });\n return stdout.includes(MCP_SERVER_NAME) && !/no mcp server/i.test(stdout);\n}\n\n/**\n * THE ROUTING FEE, AS THE NEXT PAID CALL WOULD MEET IT: the reasons the session\n * notice gives (`unpaid`), worked out here from the wallet, the spend limits,\n * the ledger and the channel the SDK keeps. Never a failure: a call the fee\n * cannot pay takes the free path. A payment that failed in a session leaves\n * nothing to read here; these are the causes this can check.\n */\nasync function routingFeeCheck(\n ctx: CommandContext,\n settings: ResolvedSettings,\n fetchImpl: typeof fetch | undefined,\n unanswered: { limits: RouterLimits } | null,\n): Promise<RouterCheck> {\n let host: string;\n try {\n host = new URL(settings.baseUrl).host;\n } catch {\n // The router check below names the bad base URL and its fix.\n return {\n name: 'routing fee',\n status: 'warn',\n required: false,\n detail: 'not checked, because the base URL is not a URL',\n };\n }\n const why = await routingFeeBlock({\n dataDir: ctx.dataDir,\n policy: settings.policy,\n rpcUrl: settings.rpcUrl,\n host,\n timeoutMs: ctx.flags.timeout,\n provider: (await walletFileExists(ctx.dataDir)) ? resolveWalletProvider(ctx) : null,\n ...(fetchImpl !== undefined ? { fetchImpl } : {}),\n }).catch(() => null);\n return routingFeeRow(why, host, unanswered);\n}\n\n/** The routing-fee row for what {@link routingFeeBlock} found. */\nexport function routingFeeRow(\n why: string | null,\n host: string,\n unanswered: { limits: RouterLimits } | null,\n): RouterCheck {\n const u = why === null ? null : unpaid(why);\n if (why === null || u === null) {\n return {\n name: 'routing fee',\n status: 'ok',\n required: false,\n detail: `$${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that count against the spend limits`,\n };\n }\n if (why === 'limit_below_deposit' && unanswered !== null) {\n // The zero is the open spend question, not a limit anyone chose: the fix\n // is the question itself, with the fee terms it approves.\n return {\n name: 'routing fee',\n status: 'warn',\n required: false,\n detail: 'the spend limits are not answered yet, so routing calls take the free path',\n fix: `Answer the spend question: ${spendQuestion(unanswered.limits)} For a yes, run \\`${ACCEPT_COMMAND}\\`; for other amounts, ${OWN_LIMITS_COMMANDS}.`,\n };\n }\n const fixes: Record<string, string> = {\n no_wallet: 'Run `tenjin wallet create`, then `tenjin wallet fund 0.25`.',\n limit_below_deposit: `Raise it with \\`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\\`.`,\n budget_reached:\n 'Room comes back as the rolling day passes, or raise it with `tenjin config set sessionBudget <usd>`.',\n not_allowlisted: `Add ${host} to allowlistCreators, or clear the allowlist.`,\n };\n return {\n name: 'routing fee',\n status: 'warn',\n required: false,\n detail: `${u.reason}, so routing calls take the free path`,\n fix: fixes[why] ?? u.fix,\n };\n}\n\n/** What {@link routingFeeBlock} reads; `provider` is null with no wallet. */\nexport interface RoutingFeeInput {\n dataDir: string;\n policy: SpendPolicy;\n rpcUrl: string;\n /** The router's host, the creator a deposit pays. */\n host: string;\n timeoutMs: number;\n provider: WalletProvider | null;\n fetchImpl?: typeof fetch;\n}\n\n/** Why the next deposit would be refused, or null when the fee can be paid. */\nexport async function routingFeeBlock(input: RoutingFeeInput): Promise<string | null> {\n const { provider, policy } = input;\n // The fee's per-payment checks first, before the wallet, as the payer runs\n // them on every call: a channel with credit pays nothing they refuse, and\n // unanswered limits are the question to name, not the passphrase.\n const refused = feeRefusal(policy, input.host);\n if (refused !== null) return refused;\n if (provider === null) return 'no_wallet';\n const verified = await provider.verify?.().catch(() => null);\n if (verified !== undefined && verified !== null && verified.status !== 'verified') {\n return 'wallet_locked';\n }\n const ledger = await readSpendSummary(input.dataDir);\n const spent = ledger === null ? 0n : spentOf(ledger);\n const { address } = await describeWallet(provider);\n if ((await channelCredit(input.dataDir, address)) >= ROUTING_FEE_ATOMIC) return null;\n const deposit =\n policy.maxAutoSpendAtomic < CHANNEL_DEPOSIT_ATOMIC\n ? policy.maxAutoSpendAtomic\n : CHANNEL_DEPOSIT_ATOMIC;\n if (deposit < MIN_DEPOSIT_ATOMIC) return 'limit_below_deposit';\n const evaluation = evaluateSpendPolicy(policy, {\n mode: 'automatic',\n amountAtomic: deposit,\n creator: input.host,\n sessionSpentAtomic: spent,\n });\n if (evaluation.reason === 'not_allowlisted') return 'not_allowlisted';\n if (evaluation.reason === 'session_budget_exceeded') return 'budget_reached';\n const balance = await readUsdcBalance(address, input.rpcUrl, {\n timeoutMs: input.timeoutMs,\n ...(input.fetchImpl !== undefined ? { fetchImpl: input.fetchImpl } : {}),\n });\n return balance !== null && balance < deposit ? 'wallet_low' : null;\n}\n\n/** What the wallet's routing channel still holds for fees, from the SDK's own files. */\nasync function channelCredit(dataDir: string, address: string): Promise<bigint> {\n const dir = payerDir(dataDir, address);\n const storage = new FileClientChannelStorage({ directory: dir });\n let best = 0n;\n for (const name of await readdir(join(dir, 'client')).catch(() => [] as string[])) {\n const id = /^(0x[0-9a-f]{64})\\.json$/.exec(name)?.[1];\n const channel = id === undefined ? undefined : await storage.get(id).catch(() => undefined);\n if (channel === undefined) continue;\n const credit = BigInt(channel.balance ?? '0') - BigInt(channel.chargedCumulativeAmount ?? '0');\n if (credit > best) best = credit;\n }\n return best;\n}\n\n/** INFORMATIONAL: which experiment is on, in one line. Either state passes. */\nfunction experimentalCheck(bazaar: boolean): RouterCheck {\n return {\n name: 'experimental',\n status: 'ok',\n required: false,\n detail: bazaar\n ? 'list: on; bazaar: on (experimental): the router may also suggest unreviewed sellers from the open x402 Bazaar'\n : 'list: on; bazaar: off (experimental): `tenjin config set experimental.bazaar on` to add the open x402 Bazaar',\n };\n}\n\n/**\n * `unanswered` is set when the config file names no `maxAutoSpend`: the state\n * an install that could not ask leaves, the same as a cancel at its selector.\n * The code default's zero holds, and that is a question still open, not a\n * broken machine, so it warns with the question and its one-step yes, and the\n * checks after it (the router probe above all) still print. A 0 the user\n * wrote is their answer and stays a failure.\n */\nfunction spendCheck(\n maxAutoSpendAtomic: bigint,\n sessionBudgetAtomic: bigint | null,\n unanswered: { limits: RouterLimits } | null,\n): RouterCheck {\n if (sessionBudgetAtomic === 0n) {\n return {\n name: 'spend',\n status: 'fail',\n required: true,\n detail: 'The daily limit is 0, so positive payments are refused even with --yes.',\n fix: 'Choose a daily limit with `tenjin config set sessionBudget <usd|none>`.',\n };\n }\n if (maxAutoSpendAtomic === 0n && unanswered !== null) {\n return {\n name: 'spend',\n status: 'warn',\n required: false,\n detail: `the spend limits are not answered yet, so automatic payments are off and every lookup needs approval. Ask the user: ${spendQuestion(unanswered.limits)}`,\n fix: `Answer the spend question: for a yes, run \\`${ACCEPT_COMMAND}\\`; for other amounts, ${OWN_LIMITS_COMMANDS}; or run \\`tenjin install\\` in a terminal to choose.`,\n };\n }\n if (maxAutoSpendAtomic === 0n) {\n return {\n name: 'spend',\n status: 'fail',\n required: true,\n detail: 'maxAutoSpend is 0, so every lookup needs approval and none can pay',\n fix: 'Set a per-call limit with `tenjin config set maxAutoSpend <usd>`.',\n };\n }\n const budget =\n sessionBudgetAtomic === null\n ? 'no daily ceiling'\n : `${toMoney(sessionBudgetAtomic.toString()).usd} USD a day`;\n return {\n name: 'spend',\n status: sessionBudgetAtomic === null ? 'warn' : 'ok',\n required: false,\n detail: `automatic approval up to ${toMoney(maxAutoSpendAtomic.toString()).usd} USD a call, ${budget}`,\n ...(sessionBudgetAtomic === null\n ? { fix: 'Set one with `tenjin config set sessionBudget 1.00`.' }\n : {}),\n };\n}\n\nasync function walletCheck(ctx: CommandContext): Promise<RouterCheck[]> {\n if (!(await walletFileExists(ctx.dataDir))) {\n return [\n {\n name: 'wallet',\n status: 'fail',\n required: true,\n detail: 'no wallet on this machine, so nothing can pay',\n fix: 'Run `tenjin wallet create`, then `tenjin wallet fund`.',\n },\n ];\n }\n try {\n const described = await describeWallet(resolveWalletProvider(ctx));\n return [{ name: 'wallet', status: 'ok', required: true, detail: described.address }];\n } catch (err) {\n return [\n {\n name: 'wallet',\n status: 'fail',\n required: true,\n detail: err instanceof CliError ? err.message : String(err),\n ...(err instanceof CliError && err.fix !== undefined ? { fix: err.fix } : {}),\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AA6D1B,IAAM,OAAO,UAAU,QAAQ;AA8B/B,IAAM,aAAa;AAEnB,eAAsB,gBACpB,KACA,OAAyB,CAAC,GACF;AACxB,QAAM,MAAM,KAAK,OAAO,QAAQ;AAEhC,QAAM,SAAS,MAAM;AAAA,IACnB,EAAE,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG,SAAS,IAAI,QAAQ;AAAA,IACvD,KAAK,YAAY,SAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EAC5D,EAAE,MAAM,CAAC,QAAkB,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC,CAAE;AAC/E,QAAM,WAAW,MAAM,uBAAuB,GAAG;AAIjD,QAAM,eAAe,mBAAmB;AAAA,IACtC,GAAI,KAAK,YAAY,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,IACjD,GAAI,KAAK,YAAY,SAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,IAC9D,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,QAAM,S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__tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ PROXY_VARIABLES,
4
+ envProxySupported,
5
+ proxyVariable,
6
+ useEnvProxy
7
+ } from "./chunk-ZLD6MJVJ.js";
8
+ import "./chunk-ZXTAQYNA.js";
9
+ export {
10
+ PROXY_VARIABLES,
11
+ envProxySupported,
12
+ proxyVariable,
13
+ useEnvProxy
14
+ };
15
+ //# sourceMappingURL=env-proxy-KEGEMWKX.js.map