tenjin-cli 0.1.0-alpha.25 → 0.1.0-alpha.27

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 (119) hide show
  1. package/README.md +16 -43
  2. package/dist/{chunk-EOGJKIOG.js → chunk-2TYQD22Q.js} +16 -7
  3. package/dist/chunk-2TYQD22Q.js.map +1 -0
  4. package/dist/{chunk-SCAE6PW6.js → chunk-4L7KMA7P.js} +6 -6
  5. package/dist/{chunk-UDWGT4FX.js → chunk-5FGO6TYT.js} +13 -5
  6. package/dist/chunk-5FGO6TYT.js.map +1 -0
  7. package/dist/{chunk-IYLECN4D.js → chunk-5NEHH2E5.js} +3 -3
  8. package/dist/{chunk-EACMJEF3.js → chunk-64SE3QC5.js} +75 -176
  9. package/dist/chunk-64SE3QC5.js.map +1 -0
  10. package/dist/chunk-6ZSGER3A.js +52 -0
  11. package/dist/chunk-6ZSGER3A.js.map +1 -0
  12. package/dist/{chunk-QF4SSCQV.js → chunk-AWKQSKUL.js} +4 -3
  13. package/dist/chunk-AWKQSKUL.js.map +1 -0
  14. package/dist/chunk-B2L53TMK.js +70 -0
  15. package/dist/chunk-B2L53TMK.js.map +1 -0
  16. package/dist/chunk-BOAI23CX.js +222 -0
  17. package/dist/chunk-BOAI23CX.js.map +1 -0
  18. package/dist/{chunk-OZ3LWLCI.js → chunk-DATCR7AU.js} +3 -3
  19. package/dist/{chunk-NTYQHAIM.js → chunk-DSNXKUXI.js} +2 -2
  20. package/dist/{chunk-HII5HOQV.js → chunk-G4AM2SOL.js} +5 -3
  21. package/dist/{chunk-HII5HOQV.js.map → chunk-G4AM2SOL.js.map} +1 -1
  22. package/dist/{chunk-VYONGSMQ.js → chunk-GU4GGKYP.js} +85 -6
  23. package/dist/chunk-GU4GGKYP.js.map +1 -0
  24. package/dist/{chunk-YSW57KUT.js → chunk-H2L33M7F.js} +31 -27
  25. package/dist/chunk-H2L33M7F.js.map +1 -0
  26. package/dist/{chunk-ODH7UXIS.js → chunk-HC3QEZKT.js} +5 -4
  27. package/dist/chunk-HC3QEZKT.js.map +1 -0
  28. package/dist/chunk-MAQUL5BD.js +99 -0
  29. package/dist/chunk-MAQUL5BD.js.map +1 -0
  30. package/dist/{chunk-EG7P4SM6.js → chunk-O7CUHHYU.js} +4 -4
  31. package/dist/{chunk-EG7P4SM6.js.map → chunk-O7CUHHYU.js.map} +1 -1
  32. package/dist/{chunk-CEMXMUIU.js → chunk-OHZYNZSD.js} +36 -7
  33. package/dist/chunk-OHZYNZSD.js.map +1 -0
  34. package/dist/{chunk-3ZYPVSIU.js → chunk-PY7MQUKP.js} +238 -43
  35. package/dist/chunk-PY7MQUKP.js.map +1 -0
  36. package/dist/chunk-PZ5N6BAL.js +268 -0
  37. package/dist/chunk-PZ5N6BAL.js.map +1 -0
  38. package/dist/chunk-S4SAZ7OD.js +30 -0
  39. package/dist/chunk-S4SAZ7OD.js.map +1 -0
  40. package/dist/{chunk-NYPFOHSJ.js → chunk-SKQQOEWH.js} +4 -4
  41. package/dist/{chunk-XICKN3CH.js → chunk-VIOUZW7Z.js} +2 -46
  42. package/dist/chunk-VIOUZW7Z.js.map +1 -0
  43. package/dist/{chunk-YTM7OURD.js → chunk-VNNXAYJE.js} +2 -2
  44. package/dist/{chunk-CKDD554V.js → chunk-VXIBZ6W5.js} +5 -3
  45. package/dist/{chunk-CKDD554V.js.map → chunk-VXIBZ6W5.js.map} +1 -1
  46. package/dist/{chunk-GT6W3VJM.js → chunk-X7I343ZY.js} +3 -53
  47. package/dist/chunk-X7I343ZY.js.map +1 -0
  48. package/dist/{chunk-KGTQRJGS.js → chunk-XVYATBKD.js} +5 -10
  49. package/dist/{chunk-KGTQRJGS.js.map → chunk-XVYATBKD.js.map} +1 -1
  50. package/dist/{chunk-DRXDTITB.js → chunk-YKM2ZTA2.js} +59 -25
  51. package/dist/chunk-YKM2ZTA2.js.map +1 -0
  52. package/dist/{chunk-CP7O6M55.js → chunk-YQOQ6XEI.js} +109 -27
  53. package/dist/chunk-YQOQ6XEI.js.map +1 -0
  54. package/dist/{cli-4WMGZPBP.js → cli-6JNIPZQ6.js} +43 -39
  55. package/dist/{cli-4WMGZPBP.js.map → cli-6JNIPZQ6.js.map} +1 -1
  56. package/dist/{config-VU6U7QOU.js → config-G75YT6NC.js} +15 -10
  57. package/dist/{doctor-26JS2SG3.js → doctor-3GMDOW4Y.js} +140 -98
  58. package/dist/doctor-3GMDOW4Y.js.map +1 -0
  59. package/dist/env-proxy-XL4P73MZ.js +15 -0
  60. package/dist/{fund-JJN3FRRF.js → fund-3IPR5YRJ.js} +26 -14
  61. package/dist/{fund-JJN3FRRF.js.map → fund-3IPR5YRJ.js.map} +1 -1
  62. package/dist/hook-command-ZXX4FT4N.js +32 -0
  63. package/dist/index.js +7 -5
  64. package/dist/index.js.map +1 -1
  65. package/dist/{install-GXQ33J4G.js → install-6OROTYHZ.js} +20 -14
  66. package/dist/{install-identity-HFQUXPSI.js → install-identity-PM4AGFFX.js} +7 -6
  67. package/dist/{install-wallet-27LTEHBI.js → install-wallet-6756NOB5.js} +11 -8
  68. package/dist/{install-wallet-27LTEHBI.js.map → install-wallet-6756NOB5.js.map} +1 -1
  69. package/dist/{mcp-AHCZVD2U.js → mcp-33FAAZ7F.js} +723 -123
  70. package/dist/mcp-33FAAZ7F.js.map +1 -0
  71. package/dist/{pay-3TCOPGCX.js → pay-XOYR4PCH.js} +14 -12
  72. package/dist/{payments-H3LSBGSL.js → payments-UTQDBO7H.js} +8 -6
  73. package/dist/{payments-H3LSBGSL.js.map → payments-UTQDBO7H.js.map} +1 -1
  74. package/dist/{send-LKCLN5GA.js → send-CVGNOQW3.js} +12 -9
  75. package/dist/{send-LKCLN5GA.js.map → send-CVGNOQW3.js.map} +1 -1
  76. package/dist/{status-2FDGI4LQ.js → status-NACN4DGX.js} +10 -7
  77. package/dist/{status-2FDGI4LQ.js.map → status-NACN4DGX.js.map} +1 -1
  78. package/dist/{status-line-QKDJYZGV.js → status-line-3IQKGRUH.js} +6 -5
  79. package/dist/{status-line-QKDJYZGV.js.map → status-line-3IQKGRUH.js.map} +1 -1
  80. package/dist/{status-line-wiring-ZDBYHNYR.js → status-line-wiring-QXBOOY2T.js} +4 -4
  81. package/dist/{uninstall-ZXWABDHS.js → uninstall-NYFKSYW4.js} +22 -16
  82. package/dist/{uninstall-ZXWABDHS.js.map → uninstall-NYFKSYW4.js.map} +1 -1
  83. package/dist/{update-HEIWVOP5.js → update-RJDA5ZY3.js} +11 -13
  84. package/dist/update-RJDA5ZY3.js.map +1 -0
  85. package/dist/{wallet-T7JYWI6O.js → wallet-B3FVHNTS.js} +11 -8
  86. package/dist/wallet-B3FVHNTS.js.map +1 -0
  87. package/docs/agent-permissions.md +18 -7
  88. package/docs/troubleshooting.md +13 -0
  89. package/package.json +4 -3
  90. package/dist/chunk-3ZYPVSIU.js.map +0 -1
  91. package/dist/chunk-CEMXMUIU.js.map +0 -1
  92. package/dist/chunk-CP7O6M55.js.map +0 -1
  93. package/dist/chunk-DRXDTITB.js.map +0 -1
  94. package/dist/chunk-EACMJEF3.js.map +0 -1
  95. package/dist/chunk-EOGJKIOG.js.map +0 -1
  96. package/dist/chunk-GT6W3VJM.js.map +0 -1
  97. package/dist/chunk-ODH7UXIS.js.map +0 -1
  98. package/dist/chunk-QF4SSCQV.js.map +0 -1
  99. package/dist/chunk-UDWGT4FX.js.map +0 -1
  100. package/dist/chunk-VYONGSMQ.js.map +0 -1
  101. package/dist/chunk-XICKN3CH.js.map +0 -1
  102. package/dist/chunk-YSW57KUT.js.map +0 -1
  103. package/dist/doctor-26JS2SG3.js.map +0 -1
  104. package/dist/hook-command-S2V4UNB3.js +0 -28
  105. package/dist/mcp-AHCZVD2U.js.map +0 -1
  106. package/dist/update-HEIWVOP5.js.map +0 -1
  107. /package/dist/{chunk-SCAE6PW6.js.map → chunk-4L7KMA7P.js.map} +0 -0
  108. /package/dist/{chunk-IYLECN4D.js.map → chunk-5NEHH2E5.js.map} +0 -0
  109. /package/dist/{chunk-OZ3LWLCI.js.map → chunk-DATCR7AU.js.map} +0 -0
  110. /package/dist/{chunk-NTYQHAIM.js.map → chunk-DSNXKUXI.js.map} +0 -0
  111. /package/dist/{chunk-NYPFOHSJ.js.map → chunk-SKQQOEWH.js.map} +0 -0
  112. /package/dist/{chunk-YTM7OURD.js.map → chunk-VNNXAYJE.js.map} +0 -0
  113. /package/dist/{config-VU6U7QOU.js.map → config-G75YT6NC.js.map} +0 -0
  114. /package/dist/{hook-command-S2V4UNB3.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
  115. /package/dist/{install-GXQ33J4G.js.map → hook-command-ZXX4FT4N.js.map} +0 -0
  116. /package/dist/{install-identity-HFQUXPSI.js.map → install-6OROTYHZ.js.map} +0 -0
  117. /package/dist/{pay-3TCOPGCX.js.map → install-identity-PM4AGFFX.js.map} +0 -0
  118. /package/dist/{status-line-wiring-ZDBYHNYR.js.map → pay-XOYR4PCH.js.map} +0 -0
  119. /package/dist/{wallet-T7JYWI6O.js.map → status-line-wiring-QXBOOY2T.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,18 +10,24 @@ import {
11
10
  runConfigGet,
12
11
  runConfigList,
13
12
  runConfigSet
14
- } from "./chunk-YSW57KUT.js";
13
+ } from "./chunk-H2L33M7F.js";
14
+ import {
15
+ ROUTER_DEFAULTS
16
+ } from "./chunk-GU4GGKYP.js";
15
17
  import "./chunk-A36LQPHV.js";
18
+ import "./chunk-XVYATBKD.js";
19
+ import "./chunk-AKWGE6JQ.js";
20
+ import "./chunk-TGLKKLQG.js";
16
21
  import "./chunk-P7LABKCW.js";
17
22
  import "./chunk-MEFB5KHA.js";
18
- import "./chunk-OZ3LWLCI.js";
23
+ import "./chunk-B2L53TMK.js";
24
+ import "./chunk-5FGO6TYT.js";
25
+ import "./chunk-DATCR7AU.js";
26
+ import "./chunk-HC3QEZKT.js";
19
27
  import "./chunk-2I4QTOLB.js";
20
- import "./chunk-HII5HOQV.js";
21
- import "./chunk-XICKN3CH.js";
22
- import "./chunk-KGTQRJGS.js";
23
- import "./chunk-AKWGE6JQ.js";
24
- import "./chunk-TGLKKLQG.js";
25
- import "./chunk-ODH7UXIS.js";
28
+ import "./chunk-G4AM2SOL.js";
29
+ import "./chunk-6ZSGER3A.js";
30
+ import "./chunk-VIOUZW7Z.js";
26
31
  import "./chunk-JLEF5WHM.js";
27
32
  import "./chunk-K6AXXYCG.js";
28
33
  import "./chunk-ZXTAQYNA.js";
@@ -39,4 +44,4 @@ export {
39
44
  runConfigList,
40
45
  runConfigSet
41
46
  };
42
- //# sourceMappingURL=config-VU6U7QOU.js.map
47
+ //# sourceMappingURL=config-G75YT6NC.js.map
@@ -4,81 +4,95 @@ import {
4
4
  } from "./chunk-YHKXNYTB.js";
5
5
  import "./chunk-LFZJM56J.js";
6
6
  import {
7
- ROUTER_PATH,
8
- agentsWithoutRequestTool
9
- } from "./chunk-EACMJEF3.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-PY7MQUKP.js";
20
+ import "./chunk-64SE3QC5.js";
21
+ import {
22
+ readMcpServers
23
+ } from "./chunk-MAQUL5BD.js";
10
24
  import "./chunk-EL56RW2J.js";
11
25
  import "./chunk-TTNESUPQ.js";
26
+ import {
27
+ STATUS_LINE_COMMAND,
28
+ inspectStatusLine
29
+ } from "./chunk-DSNXKUXI.js";
12
30
  import {
13
31
  describeWallet,
14
32
  resolveWalletProvider,
15
33
  walletFileExists
16
- } from "./chunk-EG7P4SM6.js";
17
- import "./chunk-CKDD554V.js";
34
+ } from "./chunk-O7CUHHYU.js";
35
+ import "./chunk-VXIBZ6W5.js";
18
36
  import {
19
- evaluateSpendPolicy,
20
37
  readSpendSummary,
21
38
  spentOf
22
- } from "./chunk-GT6W3VJM.js";
39
+ } from "./chunk-X7I343ZY.js";
23
40
  import "./chunk-N35E6CM2.js";
24
41
  import "./chunk-JRGFKVAZ.js";
25
42
  import "./chunk-EGELTSPU.js";
26
43
  import "./chunk-KG3D7FIF.js";
27
44
  import "./chunk-RBJPAZFI.js";
28
45
  import "./chunk-BPMWXTFX.js";
46
+ import "./chunk-S4SAZ7OD.js";
47
+ import "./chunk-OHZYNZSD.js";
29
48
  import {
30
- ALLOW_RULE,
31
- mcpAddCommand,
32
- mcpScope,
33
- readMcpEntry,
34
- routerHookPlan,
35
- routerSettingsPath
36
- } from "./chunk-3ZYPVSIU.js";
49
+ onPath
50
+ } from "./chunk-H2L33M7F.js";
37
51
  import {
52
+ ACCEPT_COMMAND,
38
53
  CHANNEL_DEPOSIT_ATOMIC,
39
54
  MIN_DEPOSIT_ATOMIC,
55
+ OWN_LIMITS_COMMANDS,
40
56
  ROUTING_FEE_ATOMIC,
57
+ feeRefusal,
41
58
  payerDir,
59
+ shownLimits,
60
+ spendQuestion,
42
61
  unpaid,
43
62
  usd
44
- } from "./chunk-VYONGSMQ.js";
45
- import "./chunk-UDWGT4FX.js";
63
+ } from "./chunk-GU4GGKYP.js";
64
+ import "./chunk-A36LQPHV.js";
46
65
  import {
47
- httpRequest
48
- } from "./chunk-CEMXMUIU.js";
66
+ inspectHooksFile,
67
+ ownsHookEntry,
68
+ pruneOurHandlers
69
+ } from "./chunk-XVYATBKD.js";
70
+ import "./chunk-AKWGE6JQ.js";
49
71
  import {
50
- onPath
51
- } from "./chunk-YSW57KUT.js";
52
- import "./chunk-A36LQPHV.js";
72
+ MCP_SERVER_NAME,
73
+ REQUEST_TOOL
74
+ } from "./chunk-TGLKKLQG.js";
53
75
  import "./chunk-P7LABKCW.js";
54
76
  import "./chunk-MEFB5KHA.js";
77
+ import {
78
+ evaluateSpendPolicy
79
+ } from "./chunk-B2L53TMK.js";
80
+ import "./chunk-5FGO6TYT.js";
55
81
  import {
56
82
  routerSettings
57
- } from "./chunk-OZ3LWLCI.js";
83
+ } from "./chunk-DATCR7AU.js";
84
+ import "./chunk-HC3QEZKT.js";
58
85
  import "./chunk-2I4QTOLB.js";
59
86
  import {
60
87
  resolveContextSettings
61
- } from "./chunk-HII5HOQV.js";
88
+ } from "./chunk-G4AM2SOL.js";
62
89
  import {
63
- PRODUCTION_ORIGIN,
64
- readUsdcBalance,
65
90
  toMoney
66
- } from "./chunk-XICKN3CH.js";
91
+ } from "./chunk-6ZSGER3A.js";
67
92
  import {
68
- STATUS_LINE_COMMAND,
69
- inspectStatusLine
70
- } from "./chunk-NTYQHAIM.js";
71
- import {
72
- inspectHooksFile,
73
- ownsHookEntry,
74
- pruneOurHandlers
75
- } from "./chunk-KGTQRJGS.js";
76
- import "./chunk-AKWGE6JQ.js";
77
- import {
78
- MCP_SERVER_NAME,
79
- REQUEST_TOOL
80
- } from "./chunk-TGLKKLQG.js";
81
- import "./chunk-ODH7UXIS.js";
93
+ loadRawConfig,
94
+ readUsdcBalance
95
+ } from "./chunk-VIOUZW7Z.js";
82
96
  import {
83
97
  CliError
84
98
  } from "./chunk-JLEF5WHM.js";
@@ -92,7 +106,7 @@ import { homedir } from "node:os";
92
106
  import { join } from "node:path";
93
107
  import { promisify } from "node:util";
94
108
  var exec = promisify(execFile);
95
- var NODE_FLOOR = 24;
109
+ var NODE_FLOOR = 22;
96
110
  async function runRouterDoctor(ctx, deps = {}) {
97
111
  const env = deps.env ?? process.env;
98
112
  const router = await routerSettings(
@@ -117,11 +131,33 @@ async function runRouterDoctor(ctx, deps = {}) {
117
131
  deps.homeDir ?? homedir()
118
132
  )
119
133
  );
120
- 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
+ );
121
140
  checks.push(experimentalCheck(settings.experimentalBazaar));
122
- checks.push(await routingFeeCheck(ctx, settings, deps.fetchImpl));
141
+ checks.push(await routingFeeCheck(ctx, settings, deps.fetchImpl, unanswered));
123
142
  checks.push(...await walletCheck(ctx));
124
- 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
+ }
125
161
  const agents = await subagentsCheck(deps.cwd ?? process.cwd(), deps.homeDir ?? homedir());
126
162
  if (agents !== null) checks.push(agents);
127
163
  const failure = checks.find((c) => c.status === "fail" && c.required);
@@ -132,15 +168,25 @@ async function runRouterDoctor(ctx, deps = {}) {
132
168
  details: data
133
169
  });
134
170
  }
171
+ return { data, humanLines: doctorLines(checks) };
172
+ }
173
+ function doctorLines(checks) {
135
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));
136
186
  return {
137
- data,
138
- humanLines: [
139
- ...checks.map(
140
- (c) => `${c.status === "ok" ? "ok " : c.status === "warn" ? "warn" : "fail"} ${c.name}: ${c.detail}`
141
- ),
142
- bad === 0 ? `${checks.length} checks, all pass.` : `${checks.length} checks, ${bad} to look at.`
143
- ]
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`
144
190
  };
145
191
  }
146
192
  async function subagentsCheck(cwd, homeDir) {
@@ -362,8 +408,18 @@ async function claudeHasServer(opts) {
362
408
  });
363
409
  return stdout.includes(MCP_SERVER_NAME) && !/no mcp server/i.test(stdout);
364
410
  }
365
- async function routingFeeCheck(ctx, settings, fetchImpl) {
366
- const host = new URL(settings.baseUrl).host;
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
+ }
367
423
  const why = await routingFeeBlock({
368
424
  dataDir: ctx.dataDir,
369
425
  policy: settings.policy,
@@ -373,6 +429,9 @@ async function routingFeeCheck(ctx, settings, fetchImpl) {
373
429
  provider: await walletFileExists(ctx.dataDir) ? resolveWalletProvider(ctx) : null,
374
430
  ...fetchImpl !== void 0 ? { fetchImpl } : {}
375
431
  }).catch(() => null);
432
+ return routingFeeRow(why, host, unanswered);
433
+ }
434
+ function routingFeeRow(why, host, unanswered) {
376
435
  const u = why === null ? null : unpaid(why);
377
436
  if (why === null || u === null) {
378
437
  return {
@@ -382,6 +441,15 @@ async function routingFeeCheck(ctx, settings, fetchImpl) {
382
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`
383
442
  };
384
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
+ }
385
453
  const fixes = {
386
454
  no_wallet: "Run `tenjin wallet create`, then `tenjin wallet fund 0.25`.",
387
455
  limit_below_deposit: `Raise it with \`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\`.`,
@@ -398,21 +466,24 @@ async function routingFeeCheck(ctx, settings, fetchImpl) {
398
466
  }
399
467
  async function routingFeeBlock(input) {
400
468
  const { provider, policy } = input;
469
+ const refused = feeRefusal(policy, input.host);
470
+ if (refused !== null) return refused;
401
471
  if (provider === null) return "no_wallet";
402
472
  const verified = await provider.verify?.().catch(() => null);
403
473
  if (verified !== void 0 && verified !== null && verified.status !== "verified") {
404
474
  return "wallet_locked";
405
475
  }
476
+ const ledger = await readSpendSummary(input.dataDir);
477
+ const spent = ledger === null ? 0n : spentOf(ledger);
406
478
  const { address } = await describeWallet(provider);
407
479
  if (await channelCredit(input.dataDir, address) >= ROUTING_FEE_ATOMIC) return null;
408
480
  const deposit = policy.maxAutoSpendAtomic < CHANNEL_DEPOSIT_ATOMIC ? policy.maxAutoSpendAtomic : CHANNEL_DEPOSIT_ATOMIC;
409
481
  if (deposit < MIN_DEPOSIT_ATOMIC) return "limit_below_deposit";
410
- const ledger = await readSpendSummary(input.dataDir);
411
482
  const evaluation = evaluateSpendPolicy(policy, {
412
483
  mode: "automatic",
413
484
  amountAtomic: deposit,
414
485
  creator: input.host,
415
- sessionSpentAtomic: ledger === null ? 0n : spentOf(ledger)
486
+ sessionSpentAtomic: spent
416
487
  });
417
488
  if (evaluation.reason === "not_allowlisted") return "not_allowlisted";
418
489
  if (evaluation.reason === "session_budget_exceeded") return "budget_reached";
@@ -443,7 +514,7 @@ function experimentalCheck(bazaar) {
443
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"
444
515
  };
445
516
  }
446
- function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic) {
517
+ function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic, unanswered) {
447
518
  if (sessionBudgetAtomic === 0n) {
448
519
  return {
449
520
  name: "spend",
@@ -453,13 +524,22 @@ function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic) {
453
524
  fix: "Choose a daily limit with `tenjin config set sessionBudget <usd|none>`."
454
525
  };
455
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
+ }
456
536
  if (maxAutoSpendAtomic === 0n) {
457
537
  return {
458
538
  name: "spend",
459
539
  status: "fail",
460
540
  required: true,
461
541
  detail: "maxAutoSpend is 0, so every lookup needs approval and none can pay",
462
- fix: "Run `tenjin install`, or `tenjin config set maxAutoSpend 0.10`."
542
+ fix: "Set a per-call limit with `tenjin config set maxAutoSpend <usd>`."
463
543
  };
464
544
  }
465
545
  const budget = sessionBudgetAtomic === null ? "no daily ceiling" : `${toMoney(sessionBudgetAtomic.toString()).usd} USD a day`;
@@ -498,48 +578,10 @@ async function walletCheck(ctx) {
498
578
  ];
499
579
  }
500
580
  }
501
- async function routerCheck(baseUrl, timeoutMs, fetchImpl) {
502
- const url = new URL(ROUTER_PATH, baseUrl).toString();
503
- const probe = await httpRequest(url, {
504
- method: "POST",
505
- timeoutMs,
506
- blockRedirects: true,
507
- jsonBody: {},
508
- ...fetchImpl !== void 0 ? { fetchImpl } : {}
509
- });
510
- const fail = (detail, fix) => ({
511
- name: "router",
512
- status: "fail",
513
- required: true,
514
- detail,
515
- fix
516
- });
517
- const checkBase = "Check that the configured base URL names the Tenjin router (`tenjin config get baseUrl`), then try again later.";
518
- if (!probe.ok) {
519
- return fail(`the router at ${url} is unreachable or erroring (${probe.message})`, checkBase);
520
- }
521
- if (probe.status === 200 || probe.status === 400 || probe.status === 429) {
522
- return { name: "router", status: "ok", required: true, detail: `${url} is live` };
523
- }
524
- if (probe.status === 404) {
525
- return fail(`the router is not enabled at ${url}`, checkBase);
526
- }
527
- if (probe.status === 401 || probe.status === 403) {
528
- return fail(
529
- `${url} is not a Tenjin router (it asked for credentials)`,
530
- `Set the router URL with \`tenjin config set baseUrl ${PRODUCTION_ORIGIN}\`.`
531
- );
532
- }
533
- if (probe.status >= 500) {
534
- return fail(`the router at ${url} is unreachable or erroring (${probe.status})`, checkBase);
535
- }
536
- return fail(
537
- `${url} answered ${probe.status}, which a Tenjin router does not`,
538
- "Check that the configured base URL names a Tenjin deployment (`tenjin config get baseUrl`)."
539
- );
540
- }
541
581
  export {
582
+ doctorLines,
542
583
  routingFeeBlock,
584
+ routingFeeRow,
543
585
  runRouterDoctor
544
586
  };
545
- //# sourceMappingURL=doctor-26JS2SG3.js.map
587
+ //# sourceMappingURL=doctor-3GMDOW4Y.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 = 22;\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,IA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BAAiB,IAAI,OAAO,GAAI;AAC1C,WAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,MAAI;AACF,UAAM,YAAY,MAAM,eAAe,sBAAsB,GAAG,CAAC;AACjE,WAAO,CAAC,EAAE,MAAM,UAAU,QAAQ,MAAM,UAAU,MAAM,QAAQ,UAAU,QAAQ,CAAC;AAAA,EACrF,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,QAAQ,eAAe,WAAW,IAAI,UAAU,OAAO,GAAG;AAAA,QAC1D,GAAI,eAAe,YAAY,IAAI,QAAQ,SAAY,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC;AAAA,MAC7E;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ PROXY_VARIABLES,
4
+ envProxySupported,
5
+ proxyVariable,
6
+ useEnvProxy
7
+ } from "./chunk-S4SAZ7OD.js";
8
+ import "./chunk-ZXTAQYNA.js";
9
+ export {
10
+ PROXY_VARIABLES,
11
+ envProxySupported,
12
+ proxyVariable,
13
+ useEnvProxy
14
+ };
15
+ //# sourceMappingURL=env-proxy-XL4P73MZ.js.map
@@ -8,15 +8,18 @@ import "./chunk-TTNESUPQ.js";
8
8
  import "./chunk-HPWO4O6S.js";
9
9
  import "./chunk-POUWHWID.js";
10
10
  import "./chunk-XZKD7DIF.js";
11
+ import {
12
+ addressQrLines
13
+ } from "./chunk-PZ5N6BAL.js";
11
14
  import {
12
15
  getUsdcBalance
13
- } from "./chunk-YTM7OURD.js";
16
+ } from "./chunk-VNNXAYJE.js";
14
17
  import {
15
18
  describeWallet,
16
19
  resolveWalletProvider
17
- } from "./chunk-EG7P4SM6.js";
18
- import "./chunk-CKDD554V.js";
19
- import "./chunk-GT6W3VJM.js";
20
+ } from "./chunk-O7CUHHYU.js";
21
+ import "./chunk-VXIBZ6W5.js";
22
+ import "./chunk-X7I343ZY.js";
20
23
  import "./chunk-AWQPGIR6.js";
21
24
  import "./chunk-N35E6CM2.js";
22
25
  import "./chunk-JRGFKVAZ.js";
@@ -28,24 +31,27 @@ import {
28
31
  import "./chunk-KG3D7FIF.js";
29
32
  import "./chunk-RBJPAZFI.js";
30
33
  import "./chunk-BPMWXTFX.js";
31
- import {
32
- emitNotice,
33
- emitWriteNotice
34
- } from "./chunk-UDWGT4FX.js";
35
34
  import {
36
35
  fetchFailureToCliError,
37
36
  httpRequest
38
- } from "./chunk-CEMXMUIU.js";
37
+ } from "./chunk-OHZYNZSD.js";
39
38
  import "./chunk-MEFB5KHA.js";
39
+ import "./chunk-B2L53TMK.js";
40
+ import {
41
+ emitNotice,
42
+ emitWriteNotice
43
+ } from "./chunk-5FGO6TYT.js";
44
+ import "./chunk-HC3QEZKT.js";
40
45
  import "./chunk-2I4QTOLB.js";
46
+ import {
47
+ toMoney
48
+ } from "./chunk-6ZSGER3A.js";
41
49
  import {
42
50
  PRODUCTION_ORIGIN,
43
51
  external_exports,
44
52
  loadRawConfig,
45
- resolveSettings,
46
- toMoney
47
- } from "./chunk-XICKN3CH.js";
48
- import "./chunk-ODH7UXIS.js";
53
+ resolveSettings
54
+ } from "./chunk-VIOUZW7Z.js";
49
55
  import {
50
56
  CliError
51
57
  } from "./chunk-JLEF5WHM.js";
@@ -169,6 +175,12 @@ async function runFund(ctx, opts = {}) {
169
175
  { json: ctx.flags.json }
170
176
  );
171
177
  }
178
+ const qrLines = opts.qr !== false && ctx.io.isTTY && !ctx.flags.json ? addressQrLines(address, ctx.io.stderr) : [];
179
+ if (qrLines.length > 0) {
180
+ ctx.io.stderr.write(
181
+ [`Or send USDC from a phone wallet to ${address}:`, ...qrLines].join("\n") + "\n"
182
+ );
183
+ }
172
184
  const funded = shouldWait && startBalance !== void 0 ? await pollForFunds(ctx, desc, rpcUrl, startBalance, opts) : void 0;
173
185
  if (funded !== void 0) {
174
186
  emitWriteNotice(ctx.io, "USDC arrived - you can close the checkout tab.");
@@ -293,4 +305,4 @@ async function pollForFunds(ctx, desc, rpcUrl, startBalance, opts) {
293
305
  export {
294
306
  runFund
295
307
  };
296
- //# sourceMappingURL=fund-JJN3FRRF.js.map
308
+ //# sourceMappingURL=fund-3IPR5YRJ.js.map