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

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 (114) hide show
  1. package/README.md +5 -1
  2. package/dist/{chunk-H5UR3GFJ.js → chunk-3ZYPVSIU.js} +56 -31
  3. package/dist/chunk-3ZYPVSIU.js.map +1 -0
  4. package/dist/chunk-7EKYXMUO.js +7536 -0
  5. package/dist/chunk-7EKYXMUO.js.map +1 -0
  6. package/dist/chunk-AKWGE6JQ.js +49 -0
  7. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  8. package/dist/{chunk-RCJ64OXH.js → chunk-CEMXMUIU.js} +3 -3
  9. package/dist/{chunk-XZUGRTSV.js → chunk-CKDD554V.js} +2 -2
  10. package/dist/{hook-command-GMIDXVFK.js → chunk-CP7O6M55.js} +190 -40
  11. package/dist/chunk-CP7O6M55.js.map +1 -0
  12. package/dist/{chunk-UBOFYC6J.js → chunk-DRXDTITB.js} +1821 -141
  13. package/dist/chunk-DRXDTITB.js.map +1 -0
  14. package/dist/{chunk-EP5P2STS.js → chunk-EACMJEF3.js} +201 -8
  15. package/dist/chunk-EACMJEF3.js.map +1 -0
  16. package/dist/{chunk-GPLSNGKX.js → chunk-EG7P4SM6.js} +4 -4
  17. package/dist/{chunk-RGVOODF4.js → chunk-EL56RW2J.js} +164 -7463
  18. package/dist/chunk-EL56RW2J.js.map +1 -0
  19. package/dist/{chunk-KC24CYGV.js → chunk-EOGJKIOG.js} +6 -8
  20. package/dist/{chunk-KC24CYGV.js.map → chunk-EOGJKIOG.js.map} +1 -1
  21. package/dist/{chunk-ZMFDMALH.js → chunk-GT6W3VJM.js} +2 -2
  22. package/dist/{chunk-TMLCEPCD.js → chunk-HII5HOQV.js} +3 -5
  23. package/dist/chunk-HII5HOQV.js.map +1 -0
  24. package/dist/{chunk-UXSF7IFD.js → chunk-IYLECN4D.js} +3 -3
  25. package/dist/{chunk-SQSKVKX6.js → chunk-KGTQRJGS.js} +17 -8
  26. package/dist/chunk-KGTQRJGS.js.map +1 -0
  27. package/dist/chunk-LFZJM56J.js +159 -0
  28. package/dist/chunk-LFZJM56J.js.map +1 -0
  29. package/dist/{chunk-YZTIYDWU.js → chunk-NTYQHAIM.js} +2 -2
  30. package/dist/{chunk-IIE65SJC.js → chunk-NYPFOHSJ.js} +4 -4
  31. package/dist/{chunk-ZNZGBUV6.js → chunk-ODH7UXIS.js} +8 -7
  32. package/dist/chunk-ODH7UXIS.js.map +1 -0
  33. package/dist/{chunk-NSDZESRS.js → chunk-OZ3LWLCI.js} +3 -3
  34. package/dist/{chunk-XRW4N23F.js → chunk-SCAE6PW6.js} +4 -4
  35. package/dist/{chunk-O2WN732M.js → chunk-UDWGT4FX.js} +2 -2
  36. package/dist/chunk-VYONGSMQ.js +119 -0
  37. package/dist/chunk-VYONGSMQ.js.map +1 -0
  38. package/dist/{chunk-P22ZWXFX.js → chunk-XICKN3CH.js} +49 -4
  39. package/dist/chunk-XICKN3CH.js.map +1 -0
  40. package/dist/chunk-YHKXNYTB.js +105 -0
  41. package/dist/chunk-YHKXNYTB.js.map +1 -0
  42. package/dist/{chunk-W2ARIOAZ.js → chunk-YSW57KUT.js} +8 -10
  43. package/dist/{chunk-W2ARIOAZ.js.map → chunk-YSW57KUT.js.map} +1 -1
  44. package/dist/{chunk-FFL5M5BC.js → chunk-YTM7OURD.js} +2 -2
  45. package/dist/{cli-GGNOQQEB.js → cli-4WMGZPBP.js} +27 -28
  46. package/dist/{cli-GGNOQQEB.js.map → cli-4WMGZPBP.js.map} +1 -1
  47. package/dist/{config-XUUFICXK.js → config-VU6U7QOU.js} +9 -8
  48. package/dist/{doctor-3LGF6CWI.js → doctor-26JS2SG3.js} +123 -31
  49. package/dist/doctor-26JS2SG3.js.map +1 -0
  50. package/dist/{fund-3URFMBMN.js → fund-JJN3FRRF.js} +13 -14
  51. package/dist/fund-JJN3FRRF.js.map +1 -0
  52. package/dist/hook-command-S2V4UNB3.js +28 -0
  53. package/dist/index.js +3 -3
  54. package/dist/{install-FRTG4KHF.js → install-GXQ33J4G.js} +19 -16
  55. package/dist/{install-identity-WNXSYP6N.js → install-identity-HFQUXPSI.js} +6 -7
  56. package/dist/{install-wallet-MXLJJP3N.js → install-wallet-27LTEHBI.js} +8 -9
  57. package/dist/{install-wallet-MXLJJP3N.js.map → install-wallet-27LTEHBI.js.map} +1 -1
  58. package/dist/{mcp-O2WJ3QBW.js → mcp-AHCZVD2U.js} +596 -75
  59. package/dist/mcp-AHCZVD2U.js.map +1 -0
  60. package/dist/{pay-43WUYTW5.js → pay-3TCOPGCX.js} +14 -13
  61. package/dist/{payments-7UTMMTIO.js → payments-H3LSBGSL.js} +6 -7
  62. package/dist/{payments-7UTMMTIO.js.map → payments-H3LSBGSL.js.map} +1 -1
  63. package/dist/{send-ALHG2RXT.js → send-LKCLN5GA.js} +9 -11
  64. package/dist/{send-ALHG2RXT.js.map → send-LKCLN5GA.js.map} +1 -1
  65. package/dist/{status-CFPNHB6R.js → status-2FDGI4LQ.js} +7 -9
  66. package/dist/{status-CFPNHB6R.js.map → status-2FDGI4LQ.js.map} +1 -1
  67. package/dist/{status-line-FJ6N7MKJ.js → status-line-QKDJYZGV.js} +4 -5
  68. package/dist/{status-line-FJ6N7MKJ.js.map → status-line-QKDJYZGV.js.map} +1 -1
  69. package/dist/{status-line-wiring-GXFNXHPE.js → status-line-wiring-ZDBYHNYR.js} +6 -4
  70. package/dist/{uninstall-5P2GFYBY.js → uninstall-ZXWABDHS.js} +33 -29
  71. package/dist/uninstall-ZXWABDHS.js.map +1 -0
  72. package/dist/{update-QJ5YHJ7I.js → update-HEIWVOP5.js} +17 -6
  73. package/dist/update-HEIWVOP5.js.map +1 -0
  74. package/dist/{wallet-6OJPGNEV.js → wallet-T7JYWI6O.js} +8 -9
  75. package/dist/wallet-T7JYWI6O.js.map +1 -0
  76. package/docs/agent-permissions.md +6 -3
  77. package/package.json +7 -6
  78. package/dist/chunk-EP5P2STS.js.map +0 -1
  79. package/dist/chunk-H5UR3GFJ.js.map +0 -1
  80. package/dist/chunk-O2JYBOUO.js +0 -47
  81. package/dist/chunk-O2JYBOUO.js.map +0 -1
  82. package/dist/chunk-P22ZWXFX.js.map +0 -1
  83. package/dist/chunk-RGVOODF4.js.map +0 -1
  84. package/dist/chunk-S2NRVRPF.js +0 -171
  85. package/dist/chunk-S2NRVRPF.js.map +0 -1
  86. package/dist/chunk-SQSKVKX6.js.map +0 -1
  87. package/dist/chunk-TMLCEPCD.js.map +0 -1
  88. package/dist/chunk-UBOFYC6J.js.map +0 -1
  89. package/dist/chunk-YXLG7Q6Q.js +0 -140
  90. package/dist/chunk-YXLG7Q6Q.js.map +0 -1
  91. package/dist/chunk-ZNZGBUV6.js.map +0 -1
  92. package/dist/doctor-3LGF6CWI.js.map +0 -1
  93. package/dist/fund-3URFMBMN.js.map +0 -1
  94. package/dist/hook-command-GMIDXVFK.js.map +0 -1
  95. package/dist/mcp-O2WJ3QBW.js.map +0 -1
  96. package/dist/uninstall-5P2GFYBY.js.map +0 -1
  97. package/dist/update-QJ5YHJ7I.js.map +0 -1
  98. /package/dist/{chunk-RCJ64OXH.js.map → chunk-CEMXMUIU.js.map} +0 -0
  99. /package/dist/{chunk-XZUGRTSV.js.map → chunk-CKDD554V.js.map} +0 -0
  100. /package/dist/{chunk-GPLSNGKX.js.map → chunk-EG7P4SM6.js.map} +0 -0
  101. /package/dist/{chunk-ZMFDMALH.js.map → chunk-GT6W3VJM.js.map} +0 -0
  102. /package/dist/{chunk-UXSF7IFD.js.map → chunk-IYLECN4D.js.map} +0 -0
  103. /package/dist/{chunk-YZTIYDWU.js.map → chunk-NTYQHAIM.js.map} +0 -0
  104. /package/dist/{chunk-IIE65SJC.js.map → chunk-NYPFOHSJ.js.map} +0 -0
  105. /package/dist/{chunk-NSDZESRS.js.map → chunk-OZ3LWLCI.js.map} +0 -0
  106. /package/dist/{chunk-XRW4N23F.js.map → chunk-SCAE6PW6.js.map} +0 -0
  107. /package/dist/{chunk-O2WN732M.js.map → chunk-UDWGT4FX.js.map} +0 -0
  108. /package/dist/{chunk-FFL5M5BC.js.map → chunk-YTM7OURD.js.map} +0 -0
  109. /package/dist/{config-XUUFICXK.js.map → config-VU6U7QOU.js.map} +0 -0
  110. /package/dist/{install-FRTG4KHF.js.map → hook-command-S2V4UNB3.js.map} +0 -0
  111. /package/dist/{install-identity-WNXSYP6N.js.map → install-GXQ33J4G.js.map} +0 -0
  112. /package/dist/{pay-43WUYTW5.js.map → install-identity-HFQUXPSI.js.map} +0 -0
  113. /package/dist/{status-line-wiring-GXFNXHPE.js.map → pay-3TCOPGCX.js.map} +0 -0
  114. /package/dist/{wallet-6OJPGNEV.js.map → status-line-wiring-ZDBYHNYR.js.map} +0 -0
@@ -4,18 +4,20 @@ import {
4
4
  paidLegTimeoutMs,
5
5
  runPay,
6
6
  settlementTx
7
- } from "./chunk-UBOFYC6J.js";
7
+ } from "./chunk-DRXDTITB.js";
8
8
  import "./chunk-LAIZ2AQA.js";
9
- import "./chunk-RGVOODF4.js";
9
+ import "./chunk-LFZJM56J.js";
10
+ import "./chunk-7EKYXMUO.js";
11
+ import "./chunk-EL56RW2J.js";
10
12
  import "./chunk-TTNESUPQ.js";
11
13
  import "./chunk-HPWO4O6S.js";
12
14
  import "./chunk-POUWHWID.js";
13
15
  import "./chunk-XZKD7DIF.js";
14
16
  import "./chunk-LHHMV4GU.js";
15
- import "./chunk-FFL5M5BC.js";
16
- import "./chunk-GPLSNGKX.js";
17
- import "./chunk-XZUGRTSV.js";
18
- import "./chunk-ZMFDMALH.js";
17
+ import "./chunk-YTM7OURD.js";
18
+ import "./chunk-EG7P4SM6.js";
19
+ import "./chunk-CKDD554V.js";
20
+ import "./chunk-GT6W3VJM.js";
19
21
  import "./chunk-AWQPGIR6.js";
20
22
  import "./chunk-N35E6CM2.js";
21
23
  import "./chunk-JRGFKVAZ.js";
@@ -24,15 +26,14 @@ import "./chunk-EGELTSPU.js";
24
26
  import "./chunk-KG3D7FIF.js";
25
27
  import "./chunk-RBJPAZFI.js";
26
28
  import "./chunk-BPMWXTFX.js";
27
- import "./chunk-O2WN732M.js";
29
+ import "./chunk-UDWGT4FX.js";
28
30
  import "./chunk-7QKHZQKW.js";
29
- import "./chunk-RCJ64OXH.js";
31
+ import "./chunk-CEMXMUIU.js";
30
32
  import "./chunk-MEFB5KHA.js";
31
33
  import "./chunk-2I4QTOLB.js";
32
- import "./chunk-TMLCEPCD.js";
33
- import "./chunk-O2JYBOUO.js";
34
- import "./chunk-P22ZWXFX.js";
35
- import "./chunk-ZNZGBUV6.js";
34
+ import "./chunk-HII5HOQV.js";
35
+ import "./chunk-XICKN3CH.js";
36
+ import "./chunk-ODH7UXIS.js";
36
37
  import "./chunk-JLEF5WHM.js";
37
38
  import "./chunk-K6AXXYCG.js";
38
39
  import "./chunk-ZXTAQYNA.js";
@@ -42,4 +43,4 @@ export {
42
43
  runPay,
43
44
  settlementTx
44
45
  };
45
- //# sourceMappingURL=pay-43WUYTW5.js.map
46
+ //# sourceMappingURL=pay-3TCOPGCX.js.map
@@ -1,20 +1,19 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  reconcilePayments
4
- } from "./chunk-UXSF7IFD.js";
4
+ } from "./chunk-IYLECN4D.js";
5
5
  import "./chunk-LAIZ2AQA.js";
6
- import "./chunk-XZUGRTSV.js";
7
- import "./chunk-ZMFDMALH.js";
6
+ import "./chunk-CKDD554V.js";
7
+ import "./chunk-GT6W3VJM.js";
8
8
  import "./chunk-7QKHZQKW.js";
9
9
  import "./chunk-MEFB5KHA.js";
10
10
  import "./chunk-2I4QTOLB.js";
11
11
  import {
12
12
  resolveContextSettings
13
- } from "./chunk-TMLCEPCD.js";
13
+ } from "./chunk-HII5HOQV.js";
14
14
  import {
15
15
  toMoney
16
- } from "./chunk-O2JYBOUO.js";
17
- import "./chunk-P22ZWXFX.js";
16
+ } from "./chunk-XICKN3CH.js";
18
17
  import "./chunk-JLEF5WHM.js";
19
18
  import {
20
19
  paidLedgerPath
@@ -44,4 +43,4 @@ async function runPaymentsReconcile(ctx, deps = {}) {
44
43
  export {
45
44
  runPaymentsReconcile
46
45
  };
47
- //# sourceMappingURL=payments-7UTMMTIO.js.map
46
+ //# sourceMappingURL=payments-H3LSBGSL.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/payments.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { paidLedgerPath } from '../lib/paths';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { CommandContext, CommandResult } from '../context';\nimport { reconcilePayments } from './paid';\n\n/**\n * `tenjin payments reconcile`: settle every \"settlement unknown\" record in the\n * paid ledger that the chain can now answer for. The `request` tool runs the\n * same pass, three records at a time, before each lookup; this one asks about\n * up to {@link MAX_COMMAND_CHECKS}.\n *\n * A record found not charged also gives its amount back to the daily budget,\n * when the spend ledger still holds that payment's exposure in this window.\n */\n\nconst MAX_COMMAND_CHECKS = 50;\n\nexport interface PaymentsDeps {\n fetchImpl?: typeof fetch;\n now?: () => number;\n}\n\nexport async function runPaymentsReconcile(\n ctx: CommandContext,\n deps: PaymentsDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const outcome = await reconcilePayments(ctx.dataDir, {\n rpcUrl: settings.rpcUrl,\n max: MAX_COMMAND_CHECKS,\n // Asked for by hand: every due record, however recently it was asked about.\n recheckMs: 0,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n return {\n data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },\n humanLines: [\n outcome.checked === 0\n ? 'No paid lookup is waiting on its settlement.'\n : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` +\n (outcome.releasedAtomic !== '0'\n ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.`\n : ''),\n ...(outcome.unknown > 0\n ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`]\n : []),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAqB;AAO3B,eAAsB,qBACpB,KACA,OAAqB,CAAC,GACE;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,UAAU,MAAM,kBAAkB,IAAI,SAAS;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,KAAK;AAAA;AAAA,IAEL,WAAW;AAAA,IACX,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACpE,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,SAAO;AAAA,IACL,MAAM,EAAE,QAAQ,eAAe,IAAI,OAAO,GAAG,GAAG,QAAQ;AAAA,IACxD,YAAY;AAAA,MACV,QAAQ,YAAY,IAChB,iDACA,WAAW,QAAQ,OAAO,KAAK,QAAQ,OAAO,aAAa,QAAQ,UAAU,mBAC5E,QAAQ,mBAAmB,MACxB,IAAI,QAAQ,QAAQ,cAAc,EAAE,GAAG,qCACvC;AAAA,MACR,GAAI,QAAQ,UAAU,IAClB,CAAC,GAAG,QAAQ,OAAO,8DAA8D,IACjF,CAAC;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/router/payments.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { paidLedgerPath } from '../lib/paths';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { CommandContext, CommandResult } from '../context';\nimport { reconcilePayments } from './paid';\n\n/**\n * `tenjin payments reconcile`: settle every \"settlement unknown\" record in the\n * paid ledger that the chain can now answer for. The `request` tool runs the\n * same pass, three records at a time, before each lookup; this one asks about\n * up to {@link MAX_COMMAND_CHECKS}.\n *\n * A record found not charged also gives its amount back to the daily budget,\n * when the spend ledger still holds that payment's exposure in this window.\n */\n\nconst MAX_COMMAND_CHECKS = 50;\n\nexport interface PaymentsDeps {\n fetchImpl?: typeof fetch;\n now?: () => number;\n}\n\nexport async function runPaymentsReconcile(\n ctx: CommandContext,\n deps: PaymentsDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const outcome = await reconcilePayments(ctx.dataDir, {\n rpcUrl: settings.rpcUrl,\n max: MAX_COMMAND_CHECKS,\n // Asked for by hand: every due record, however recently it was asked about.\n recheckMs: 0,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n return {\n data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },\n humanLines: [\n outcome.checked === 0\n ? 'No paid lookup is waiting on its settlement.'\n : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` +\n (outcome.releasedAtomic !== '0'\n ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.`\n : ''),\n ...(outcome.unknown > 0\n ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`]\n : []),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAqB;AAO3B,eAAsB,qBACpB,KACA,OAAqB,CAAC,GACE;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,UAAU,MAAM,kBAAkB,IAAI,SAAS;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,KAAK;AAAA;AAAA,IAEL,WAAW;AAAA,IACX,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACpE,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,SAAO;AAAA,IACL,MAAM,EAAE,QAAQ,eAAe,IAAI,OAAO,GAAG,GAAG,QAAQ;AAAA,IACxD,YAAY;AAAA,MACV,QAAQ,YAAY,IAChB,iDACA,WAAW,QAAQ,OAAO,KAAK,QAAQ,OAAO,aAAa,QAAQ,UAAU,mBAC5E,QAAQ,mBAAmB,MACxB,IAAI,QAAQ,QAAQ,cAAc,EAAE,GAAG,qCACvC;AAAA,MACR,GAAI,QAAQ,UAAU,IAClB,CAAC,GAAG,QAAQ,OAAO,8DAA8D,IACjF,CAAC;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -10,13 +10,13 @@ import {
10
10
  broadcastUsdcSend,
11
11
  getUsdcBalance,
12
12
  prepareUsdcSend
13
- } from "./chunk-FFL5M5BC.js";
13
+ } from "./chunk-YTM7OURD.js";
14
14
  import {
15
15
  describeWallet,
16
16
  resolveWalletProvider
17
- } from "./chunk-GPLSNGKX.js";
18
- import "./chunk-XZUGRTSV.js";
19
- import "./chunk-ZMFDMALH.js";
17
+ } from "./chunk-EG7P4SM6.js";
18
+ import "./chunk-CKDD554V.js";
19
+ import "./chunk-GT6W3VJM.js";
20
20
  import "./chunk-AWQPGIR6.js";
21
21
  import "./chunk-N35E6CM2.js";
22
22
  import "./chunk-JRGFKVAZ.js";
@@ -29,19 +29,17 @@ import {
29
29
  import "./chunk-KG3D7FIF.js";
30
30
  import "./chunk-RBJPAZFI.js";
31
31
  import "./chunk-BPMWXTFX.js";
32
- import "./chunk-O2WN732M.js";
32
+ import "./chunk-UDWGT4FX.js";
33
33
  import "./chunk-MEFB5KHA.js";
34
34
  import "./chunk-2I4QTOLB.js";
35
35
  import {
36
36
  resolveContextSettings
37
- } from "./chunk-TMLCEPCD.js";
37
+ } from "./chunk-HII5HOQV.js";
38
38
  import {
39
+ SEND_MAX_UNSET,
39
40
  parseUsdToAtomic,
40
41
  toMoney
41
- } from "./chunk-O2JYBOUO.js";
42
- import {
43
- SEND_MAX_UNSET
44
- } from "./chunk-P22ZWXFX.js";
42
+ } from "./chunk-XICKN3CH.js";
45
43
  import {
46
44
  CliError
47
45
  } from "./chunk-JLEF5WHM.js";
@@ -221,4 +219,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
221
219
  export {
222
220
  runSend
223
221
  };
224
- //# sourceMappingURL=send-ALHG2RXT.js.map
222
+ //# sourceMappingURL=send-LKCLN5GA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/send.ts"],"sourcesContent":["import { formatEther, getAddress, isAddress, type Address } from 'viem';\nimport { SEND_MAX_UNSET } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { promptYesNo } from '../lib/prompt';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n broadcastUsdcSend,\n FeeCapExceededError,\n getUsdcBalance,\n prepareUsdcSend,\n SendPendingError,\n SendRevertedError,\n USDC_ADDRESS,\n} from '../lib/usdc';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin wallet send <amount> <token> <to>`: the escape hatch that moves funds OUT of\n * the agent wallet, complementary to delegation (which redirects future revenue\n * off the hot key; this is for a balance already on it). Invariants a reader\n * cannot derive from the code order alone:\n * - the confirm (buy's posture: interactive y/N, `--yes` bypasses the prompt\n * only, headless without it refuses) runs BEFORE the signer is resolved, so\n * no refusal branch ever touches key material;\n * - `sendMaxAmount` is a spend-policy gate, NOT satisfiable by --yes, and it\n * has NO default: unset refuses until `config set sendMaxAmount` is run\n * (require-set-before-first-send; \"none\" is an explicit uncapped opt-in);\n * - the verb is deliberately absent from the MCP toolset (spec 10's narrow\n * toolset) and the skill adapters — human-invoked only, both pinned by tests.\n */\n\nexport interface SendArgs {\n /** Decimal USD at the edge (O1 convention); converted to atomic exactly once. */\n amount: string;\n token: string;\n /** Recipient address, 0x-prefixed; checksummed or all-lowercase. */\n to: string;\n /** Skip the interactive confirm. REQUIRED to send when not at a TTY. */\n yes?: boolean;\n}\n\nexport interface SendDeps {\n /** Test seam: bypass the local wallet provider. */\n provider?: WalletProvider;\n /** Interactive-confirm seam; defaults to a TTY y/n prompt (same shape as buy). */\n confirm?: (prompt: string) => Promise<boolean>;\n}\n\nconst ZERO_ADDRESS: Address = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS: Address = '0x000000000000000000000000000000000000dEaD';\n\nexport async function runSend(\n args: SendArgs,\n ctx: CommandContext,\n deps: SendDeps = {},\n): Promise<CommandResult> {\n requireUsdc(args.token);\n const amountAtomic = BigInt(parseUsdToAtomic(args.amount));\n if (amountAtomic === 0n) {\n throw new CliError('USAGE', 'The send amount must be greater than zero.', {\n fix: 'Pass a positive decimal USDC amount, e.g. `tenjin wallet send 5 usdc <to>`.',\n });\n }\n const to = parseRecipient(args.to);\n\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n // Address + posture only; surfaces WALLET_MISSING. No key material yet.\n const desc = await describeWallet(provider);\n if (to.toLowerCase() === desc.address.toLowerCase()) {\n throw new CliError('USAGE', 'The recipient is this wallet itself.', {\n fix: 'Pass the destination wallet address, not the sending one.',\n });\n }\n\n const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);\n enforceSendCap(amountAtomic, sendMaxAmountAtomic);\n\n let balance: bigint;\n try {\n balance = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (amountAtomic > balance) {\n throw new CliError('REFUSED', 'The amount exceeds the wallet USDC balance.', {\n fix: 'Check `tenjin wallet balance` and send at most that amount.',\n details: {\n requested: toMoney(amountAtomic.toString()),\n balance: toMoney(balance.toString()),\n },\n });\n }\n\n // Read-only chain prep before the confirm, so the prompt can show the fee and\n // a wallet without gas refuses before asking anyone to approve anything.\n let prepared;\n try {\n prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });\n } catch (err) {\n if (err instanceof FeeCapExceededError) {\n throw new CliError('REFUSED', 'The RPC gas/fee estimate is abnormal for Base; refusing.', {\n fix: 'Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking — wait and retry.',\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'Could not prepare the transfer on Base.', {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (prepared.ethBalanceWei < prepared.feeWei) {\n throw new CliError('REFUSED', 'The wallet has no ETH on Base to pay the network fee.', {\n fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,\n details: {\n ethBalanceWei: prepared.ethBalanceWei.toString(),\n feeWei: prepared.feeWei.toString(),\n },\n });\n }\n\n const approved = await confirmSend(ctx, deps, args.yes === true, {\n amountAtomic,\n to,\n from: desc.address,\n feeWei: prepared.feeWei,\n });\n if (!approved) {\n throw new CliError('REFUSED', 'Send not confirmed.', {\n fix: 'Verify the recipient and amount, then re-run with --yes to approve this transfer.',\n details: { to, amount: toMoney(amountAtomic.toString()) },\n });\n }\n\n // The only door to the key; a missing passphrase entry refuses here with the\n // provider's coded error. The signer must be the wallet the human just saw:\n // the local provider guarantees it, a hosted one is only trusted after this.\n const signer = await provider.getSigner();\n if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {\n throw new CliError(\n 'PROVIDER_ERROR',\n `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,\n { fix: 'The wallet changed between preview and signing; re-run `tenjin wallet send`.' },\n );\n }\n\n let txHash: string;\n try {\n txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });\n } catch (err) {\n if (err instanceof SendRevertedError) {\n throw new CliError('SEND_FAILED', 'The transfer was mined but reverted; no USDC moved.', {\n fix: 'Check the transaction on a Base explorer, then retry if the cause is transient.',\n details: { txHash: err.txHash },\n cause: err,\n });\n }\n if (err instanceof SendPendingError) {\n throw new CliError('SEND_FAILED', 'The transfer was broadcast but not confirmed in time.', {\n fix: 'Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.',\n details: { txHash: err.txHash, pending: true },\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'The transfer could not be sent on Base.', {\n fix: 'Check the network and RPC, then retry.',\n cause: err,\n });\n }\n\n const amount = toMoney(amountAtomic.toString());\n return {\n data: { txHash, from: signer.address, to, token: 'USDC', network: 'base', amount },\n humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`],\n };\n}\n\n/**\n * The hard per-send cap (`config set sendMaxAmount`): a policy gate, not a\n * confirm — no branch here is satisfiable by --yes. There is no default cap:\n * an unset key refuses (require-set-before-first-send), exactly as strict as\n * the set-cap refusals below.\n */\nfunction enforceSendCap(\n amountAtomic: bigint,\n capAtomic: bigint | null | typeof SEND_MAX_UNSET,\n): void {\n if (capAtomic === SEND_MAX_UNSET) {\n throw new CliError(\n 'POLICY_REFUSED',\n 'No sendMaxAmount is configured; a per-send cap must be set before the first send.',\n {\n fix: 'Run `tenjin config set sendMaxAmount <usd>` (or `0` to disable send, or `none` to opt in to uncapped), then retry. --yes does not bypass this.',\n },\n );\n }\n if (capAtomic === null) return;\n if (capAtomic === 0n) {\n throw new CliError('POLICY_REFUSED', 'Sending is disabled by sendMaxAmount = 0.', {\n fix: 'Run `tenjin config set sendMaxAmount <usd|none>` to allow sends.',\n });\n }\n if (amountAtomic > capAtomic) {\n throw new CliError('POLICY_REFUSED', 'The amount exceeds the sendMaxAmount cap.', {\n fix: 'Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.',\n details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) },\n });\n }\n}\n\n/** USDC on Base only; anything else is a usage error, not a guess. */\nfunction requireUsdc(token: string): void {\n if (token.trim().toLowerCase() === 'usdc') return;\n throw new CliError('USAGE', `Unsupported token: ${JSON.stringify(token)}`, {\n fix: 'Only USDC on Base is supported: `tenjin wallet send <amount> usdc <to>`.',\n });\n}\n\n/**\n * Validate and resolve the recipient. Strict `isAddress` refuses malformed input\n * and a bad EIP-55 checksum on MIXED-CASE input (all-lowercase input carries no\n * checksum to verify — that limit is inherent to the format); `getAddress` then\n * yields the checksummed form the preview shows and the transfer targets. Known\n * fund-destroying destinations (the USDC contract, the zero address, the burn\n * address) refuse outright.\n */\nfunction parseRecipient(raw: string): Address {\n const trimmed = raw.trim();\n if (!isAddress(trimmed)) {\n throw new CliError('USAGE', `Invalid recipient address: ${JSON.stringify(raw)}`, {\n fix: 'Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check).',\n });\n }\n const to = getAddress(trimmed);\n if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {\n throw new CliError('USAGE', 'The recipient is a known fund-destroying address.', {\n fix: 'Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address.',\n });\n }\n return to;\n}\n\ninterface ConfirmDetails {\n amountAtomic: bigint;\n to: Address;\n from: Address;\n feeWei: bigint;\n}\n\n/** Buy's confirm posture; the preview names the resolved recipient, amount, and fee. */\nasync function confirmSend(\n ctx: CommandContext,\n deps: SendDeps,\n yes: boolean,\n d: ConfirmDetails,\n): Promise<boolean> {\n if (yes) return true;\n const prompt =\n `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base\\n` +\n ` from ${d.from}\\n` +\n ` to ${d.to}\\n` +\n ` network fee up to ~${formatEther(d.feeWei)} ETH\\n` +\n `This moves funds out of the agent wallet and cannot be undone. [y/N] `;\n if (deps.confirm !== undefined) return deps.confirm(prompt);\n // Both streams must be real TTYs; piped stdin/stdout without --yes refuses.\n if (!ctx.io.isTTY || !process.stdin.isTTY) return false;\n return promptYesNo(prompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAM,eAAwB;AAC9B,IAAM,eAAwB;A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,CAAC,IAAI;AAAA,IACzE,KAAK;AAAA,EACP,CAAC;AACH;AAUA,SAAS,eAAe,KAAsB;AAC5C,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,CAAC,UAAU,OAAO,GAAG;AACvB,UAAM,IAAI,SAAS,SAAS,8BAA8B,KAAK,UAAU,GAAG,CAAC,IAAI;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,KAAK,WAAW,OAAO;AAC7B,MAAI,OAAO,gBAAgB,OAAO,gBAAgB,OAAO,cAAc;AACrE,UAAM,IAAI,SAAS,SAAS,qDAAqD;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAUA,eAAe,YACb,KACA,MACA,KACA,GACkB;AAClB,MAAI,IAAK,QAAO;AAChB,QAAM,SACJ,QAAQ,QAAQ,EAAE,aAAa,SAAS,CAAC,EAAE,GAAG;AAAA,SACpC,EAAE,IAAI;AAAA,SACN,EAAE,EAAE;AAAA,uBACU,YAAY,EAAE,MAAM,CAAC;AAAA;AAE/C,MAAI,KAAK,YAAY,OAAW,QAAO,KAAK,QAAQ,MAAM;AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../src/commands/send.ts"],"sourcesContent":["import { formatEther, getAddress, isAddress, type Address } from 'viem';\nimport { SEND_MAX_UNSET } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { promptYesNo } from '../lib/prompt';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n broadcastUsdcSend,\n FeeCapExceededError,\n getUsdcBalance,\n prepareUsdcSend,\n SendPendingError,\n SendRevertedError,\n USDC_ADDRESS,\n} from '../lib/usdc';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin wallet send <amount> <token> <to>`: the escape hatch that moves funds OUT of\n * the agent wallet, complementary to delegation (which redirects future revenue\n * off the hot key; this is for a balance already on it). Invariants a reader\n * cannot derive from the code order alone:\n * - the confirm (buy's posture: interactive y/N, `--yes` bypasses the prompt\n * only, headless without it refuses) runs BEFORE the signer is resolved, so\n * no refusal branch ever touches key material;\n * - `sendMaxAmount` is a spend-policy gate, NOT satisfiable by --yes, and it\n * has NO default: unset refuses until `config set sendMaxAmount` is run\n * (require-set-before-first-send; \"none\" is an explicit uncapped opt-in);\n * - the verb is deliberately absent from the MCP toolset (spec 10's narrow\n * toolset) and the skill adapters — human-invoked only, both pinned by tests.\n */\n\nexport interface SendArgs {\n /** Decimal USD at the edge (O1 convention); converted to atomic exactly once. */\n amount: string;\n token: string;\n /** Recipient address, 0x-prefixed; checksummed or all-lowercase. */\n to: string;\n /** Skip the interactive confirm. REQUIRED to send when not at a TTY. */\n yes?: boolean;\n}\n\nexport interface SendDeps {\n /** Test seam: bypass the local wallet provider. */\n provider?: WalletProvider;\n /** Interactive-confirm seam; defaults to a TTY y/n prompt (same shape as buy). */\n confirm?: (prompt: string) => Promise<boolean>;\n}\n\nconst ZERO_ADDRESS: Address = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS: Address = '0x000000000000000000000000000000000000dEaD';\n\nexport async function runSend(\n args: SendArgs,\n ctx: CommandContext,\n deps: SendDeps = {},\n): Promise<CommandResult> {\n requireUsdc(args.token);\n const amountAtomic = BigInt(parseUsdToAtomic(args.amount));\n if (amountAtomic === 0n) {\n throw new CliError('USAGE', 'The send amount must be greater than zero.', {\n fix: 'Pass a positive decimal USDC amount, e.g. `tenjin wallet send 5 usdc <to>`.',\n });\n }\n const to = parseRecipient(args.to);\n\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n // Address + posture only; surfaces WALLET_MISSING. No key material yet.\n const desc = await describeWallet(provider);\n if (to.toLowerCase() === desc.address.toLowerCase()) {\n throw new CliError('USAGE', 'The recipient is this wallet itself.', {\n fix: 'Pass the destination wallet address, not the sending one.',\n });\n }\n\n const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);\n enforceSendCap(amountAtomic, sendMaxAmountAtomic);\n\n let balance: bigint;\n try {\n balance = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (amountAtomic > balance) {\n throw new CliError('REFUSED', 'The amount exceeds the wallet USDC balance.', {\n fix: 'Check `tenjin wallet balance` and send at most that amount.',\n details: {\n requested: toMoney(amountAtomic.toString()),\n balance: toMoney(balance.toString()),\n },\n });\n }\n\n // Read-only chain prep before the confirm, so the prompt can show the fee and\n // a wallet without gas refuses before asking anyone to approve anything.\n let prepared;\n try {\n prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });\n } catch (err) {\n if (err instanceof FeeCapExceededError) {\n throw new CliError('REFUSED', 'The RPC gas/fee estimate is abnormal for Base; refusing.', {\n fix: 'Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking — wait and retry.',\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'Could not prepare the transfer on Base.', {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (prepared.ethBalanceWei < prepared.feeWei) {\n throw new CliError('REFUSED', 'The wallet has no ETH on Base to pay the network fee.', {\n fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,\n details: {\n ethBalanceWei: prepared.ethBalanceWei.toString(),\n feeWei: prepared.feeWei.toString(),\n },\n });\n }\n\n const approved = await confirmSend(ctx, deps, args.yes === true, {\n amountAtomic,\n to,\n from: desc.address,\n feeWei: prepared.feeWei,\n });\n if (!approved) {\n throw new CliError('REFUSED', 'Send not confirmed.', {\n fix: 'Verify the recipient and amount, then re-run with --yes to approve this transfer.',\n details: { to, amount: toMoney(amountAtomic.toString()) },\n });\n }\n\n // The only door to the key; a missing passphrase entry refuses here with the\n // provider's coded error. The signer must be the wallet the human just saw:\n // the local provider guarantees it, a hosted one is only trusted after this.\n const signer = await provider.getSigner();\n if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {\n throw new CliError(\n 'PROVIDER_ERROR',\n `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,\n { fix: 'The wallet changed between preview and signing; re-run `tenjin wallet send`.' },\n );\n }\n\n let txHash: string;\n try {\n txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });\n } catch (err) {\n if (err instanceof SendRevertedError) {\n throw new CliError('SEND_FAILED', 'The transfer was mined but reverted; no USDC moved.', {\n fix: 'Check the transaction on a Base explorer, then retry if the cause is transient.',\n details: { txHash: err.txHash },\n cause: err,\n });\n }\n if (err instanceof SendPendingError) {\n throw new CliError('SEND_FAILED', 'The transfer was broadcast but not confirmed in time.', {\n fix: 'Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.',\n details: { txHash: err.txHash, pending: true },\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'The transfer could not be sent on Base.', {\n fix: 'Check the network and RPC, then retry.',\n cause: err,\n });\n }\n\n const amount = toMoney(amountAtomic.toString());\n return {\n data: { txHash, from: signer.address, to, token: 'USDC', network: 'base', amount },\n humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`],\n };\n}\n\n/**\n * The hard per-send cap (`config set sendMaxAmount`): a policy gate, not a\n * confirm — no branch here is satisfiable by --yes. There is no default cap:\n * an unset key refuses (require-set-before-first-send), exactly as strict as\n * the set-cap refusals below.\n */\nfunction enforceSendCap(\n amountAtomic: bigint,\n capAtomic: bigint | null | typeof SEND_MAX_UNSET,\n): void {\n if (capAtomic === SEND_MAX_UNSET) {\n throw new CliError(\n 'POLICY_REFUSED',\n 'No sendMaxAmount is configured; a per-send cap must be set before the first send.',\n {\n fix: 'Run `tenjin config set sendMaxAmount <usd>` (or `0` to disable send, or `none` to opt in to uncapped), then retry. --yes does not bypass this.',\n },\n );\n }\n if (capAtomic === null) return;\n if (capAtomic === 0n) {\n throw new CliError('POLICY_REFUSED', 'Sending is disabled by sendMaxAmount = 0.', {\n fix: 'Run `tenjin config set sendMaxAmount <usd|none>` to allow sends.',\n });\n }\n if (amountAtomic > capAtomic) {\n throw new CliError('POLICY_REFUSED', 'The amount exceeds the sendMaxAmount cap.', {\n fix: 'Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.',\n details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) },\n });\n }\n}\n\n/** USDC on Base only; anything else is a usage error, not a guess. */\nfunction requireUsdc(token: string): void {\n if (token.trim().toLowerCase() === 'usdc') return;\n throw new CliError('USAGE', `Unsupported token: ${JSON.stringify(token)}`, {\n fix: 'Only USDC on Base is supported: `tenjin wallet send <amount> usdc <to>`.',\n });\n}\n\n/**\n * Validate and resolve the recipient. Strict `isAddress` refuses malformed input\n * and a bad EIP-55 checksum on MIXED-CASE input (all-lowercase input carries no\n * checksum to verify — that limit is inherent to the format); `getAddress` then\n * yields the checksummed form the preview shows and the transfer targets. Known\n * fund-destroying destinations (the USDC contract, the zero address, the burn\n * address) refuse outright.\n */\nfunction parseRecipient(raw: string): Address {\n const trimmed = raw.trim();\n if (!isAddress(trimmed)) {\n throw new CliError('USAGE', `Invalid recipient address: ${JSON.stringify(raw)}`, {\n fix: 'Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check).',\n });\n }\n const to = getAddress(trimmed);\n if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {\n throw new CliError('USAGE', 'The recipient is a known fund-destroying address.', {\n fix: 'Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address.',\n });\n }\n return to;\n}\n\ninterface ConfirmDetails {\n amountAtomic: bigint;\n to: Address;\n from: Address;\n feeWei: bigint;\n}\n\n/** Buy's confirm posture; the preview names the resolved recipient, amount, and fee. */\nasync function confirmSend(\n ctx: CommandContext,\n deps: SendDeps,\n yes: boolean,\n d: ConfirmDetails,\n): Promise<boolean> {\n if (yes) return true;\n const prompt =\n `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base\\n` +\n ` from ${d.from}\\n` +\n ` to ${d.to}\\n` +\n ` network fee up to ~${formatEther(d.feeWei)} ETH\\n` +\n `This moves funds out of the agent wallet and cannot be undone. [y/N] `;\n if (deps.confirm !== undefined) return deps.confirm(prompt);\n // Both streams must be real TTYs; piped stdin/stdout without --yes refuses.\n if (!ctx.io.isTTY || !process.stdin.isTTY) return false;\n return promptYesNo(prompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAM,eAAwB;AAC9B,IAAM,eAAwB;AAE9B,eAAsB,QACpB,MACA,KACA,OAAiB,CAAC,GACM;AACxB,cAAY,KAAK,KAAK;AACtB,QAAM,eAAe,OAAO,iBAAiB,KAAK,MAAM,CAAC;AACzD,MAAI,iBAAiB,IAAI;AACvB,UAAM,IAAI,SAAS,SAAS,8CAA8C;AAAA,MACxE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,KAAK,eAAe,KAAK,EAAE;AAEjC,QAAM,WAAW;AAAA,IACf;AAAA,IACA,KAAK,aAAa,SAAY,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;AAAA,EAC/D;AAEA,QAAM,OAAO,MAAM,eAAe,QAAQ;AAC1C,MAAI,GAAG,YAAY,MAAM,KAAK,QAAQ,YAAY,GAAG;AACnD,UAAM,IAAI,SAAS,SAAS,wCAAwC;AAAA,MAClE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,QAAQ,oBAAoB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,EAAE,IAAI;AAAA,SACN,EAAE,EAAE;AAAA,uBACU,YAAY,EAAE,MAAM,CAAC;AAAA;AAE/C,MAAI,KAAK,YAAY,OAAW,QAAO,KAAK,QAAQ,MAAM;AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
@@ -1,22 +1,20 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import "./chunk-XZUGRTSV.js";
2
+ import "./chunk-CKDD554V.js";
3
3
  import {
4
4
  readSpendSummary,
5
5
  spentOf
6
- } from "./chunk-ZMFDMALH.js";
6
+ } from "./chunk-GT6W3VJM.js";
7
7
  import "./chunk-MEFB5KHA.js";
8
8
  import "./chunk-2I4QTOLB.js";
9
9
  import {
10
10
  resolveContextSettings
11
- } from "./chunk-TMLCEPCD.js";
12
- import {
13
- toMoney
14
- } from "./chunk-O2JYBOUO.js";
11
+ } from "./chunk-HII5HOQV.js";
15
12
  import {
16
13
  RETIRED_PAYMENT_GUIDANCE,
17
14
  loadRawConfig,
18
- retiredPaymentKeys
19
- } from "./chunk-P22ZWXFX.js";
15
+ retiredPaymentKeys,
16
+ toMoney
17
+ } from "./chunk-XICKN3CH.js";
20
18
  import "./chunk-JLEF5WHM.js";
21
19
  import "./chunk-K6AXXYCG.js";
22
20
  import "./chunk-ZXTAQYNA.js";
@@ -68,4 +66,4 @@ async function runRouterStatus(ctx, deps = {}) {
68
66
  export {
69
67
  runRouterStatus
70
68
  };
71
- //# sourceMappingURL=status-CFPNHB6R.js.map
69
+ //# sourceMappingURL=status-2FDGI4LQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/status.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { loadRawConfig, retiredPaymentKeys, RETIRED_PAYMENT_GUIDANCE } from '../lib/config';\nimport { spentOf } from '../lib/spend-ledger';\nimport { resolveContextSettings } from '../lib/settings';\nimport { readSpendSummary } from '../lib/wallet/spend';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin status`: what this machine has spent and what it is still holding.\n *\n * IT READS `spend.json`, NOT THE BACKEND. The rolling window, the committed\n * total and the reservations still open are the local truth about money, and\n * the reservations are also the record of a request whose outcome is unknown:\n * an authorization that was transmitted is committed, so anything still open\n * here is either in flight or a crash that has not yet aged out.\n */\n\nexport interface StatusDeps {\n now?: () => number;\n}\n\nexport async function runRouterStatus(\n ctx: CommandContext,\n deps: StatusDeps = {},\n): Promise<CommandResult> {\n const now = deps.now ?? Date.now;\n const settings = await resolveContextSettings(ctx);\n // The same projection an authorization would make, so what this prints is\n // what the next lookup would actually be measured against.\n const ledger = await readSpendSummary(ctx.dataDir, { now });\n const committedAtomic = BigInt(ledger?.committedAtomic ?? '0');\n const reservedAtomic = (ledger?.reservations ?? []).reduce(\n (sum, r) => sum + BigInt(r.amountAtomic),\n 0n,\n );\n const retired = retiredPaymentKeys(await loadRawConfig(ctx.dataDir));\n const warnings = retired.length\n ? [`Ignored retired keys: ${retired.join(', ')}. ${RETIRED_PAYMENT_GUIDANCE}`]\n : [];\n const automaticAtomic = ledger === null ? 0n : spentOf(ledger);\n const budgetAtomic = settings.policy.sessionBudgetAtomic;\n const data = {\n baseUrl: settings.baseUrl,\n warnings,\n window: {\n startedAtMs: ledger?.windowStartMs ?? null,\n committed: toMoney(committedAtomic.toString()),\n automaticExposure: toMoney(automaticAtomic.toString()),\n reserved: toMoney(reservedAtomic.toString()),\n budget: budgetAtomic === null ? null : toMoney(budgetAtomic.toString()),\n },\n caps: {\n maxAutoSpend: toMoney(settings.policy.maxAutoSpendAtomic.toString()),\n },\n inFlight: (ledger?.reservations ?? []).map((r) => ({\n amount: toMoney(r.amountAtomic),\n ageSeconds: Math.max(0, Math.round((now() - r.atMs) / 1000)),\n ...(r.requestKey !== undefined ? { request: r.requestKey } : {}),\n })),\n };\n const budgetLine =\n budgetAtomic === null\n ? 'no daily limit'\n : `of ${toMoney(budgetAtomic.toString()).usd} USD in the rolling 24h window`;\n return {\n data,\n humanLines: [\n `spent ${toMoney(committedAtomic.toString()).usd} USD total; automatic exposure ${toMoney(automaticAtomic.toString()).usd} USD ${budgetLine}`,\n `reserved ${toMoney(reservedAtomic.toString()).usd} USD in ${data.inFlight.length} open request(s)`,\n `automatic router up to ${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd} USD per call; manual pay always requires consent`,\n ...warnings,\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,eAAsB,gBACpB,KACA,OAAmB,CAAC,GACI;AACxB,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,WAAW,MAAM,uBAAuB,GAAG;AAGjD,QAAM,SAAS,MAAM,iBAAiB,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1D,QAAM,kBAAkB,OAAO,QAAQ,mBAAmB,GAAG;AAC7D,QAAM,kBAAkB,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IAClD,CAAC,KAAK,MAAM,MAAM,OAAO,EAAE,YAAY;AAAA,IACvC;AAAA,EACF;AACA,QAAM,UAAU,mBAAmB,MAAM,cAAc,IAAI,OAAO,CAAC;AACnE,QAAM,WAAW,QAAQ,SACrB,CAAC,yBAAyB,QAAQ,KAAK,IAAI,CAAC,KAAK,wBAAwB,EAAE,IAC3E,CAAC;AACL,QAAM,kBAAkB,WAAW,OAAO,KAAK,QAAQ,MAAM;AAC7D,QAAM,eAAe,SAAS,OAAO;AACrC,QAAM,OAAO;AAAA,IACX,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,MACN,aAAa,QAAQ,iBAAiB;AAAA,MACtC,WAAW,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MAC7C,mBAAmB,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MACrD,UAAU,QAAQ,eAAe,SAAS,CAAC;AAAA,MAC3C,QAAQ,iBAAiB,OAAO,OAAO,QAAQ,aAAa,SAAS,CAAC;AAAA,IACxE;AAAA,IACA,MAAM;AAAA,MACJ,cAAc,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC;AAAA,IACrE;AAAA,IACA,WAAW,QAAQ,gBAAgB,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,MACjD,QAAQ,QAAQ,EAAE,YAAY;AAAA,MAC9B,YAAY,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,IAAI,EAAE,QAAQ,GAAI,CAAC;AAAA,MAC3D,GAAI,EAAE,eAAe,SAAY,EAAE,SAAS,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE,EAAE;AAAA,EACJ;AACA,QAAM,aACJ,iBAAiB,OACb,mBACA,MAAM,QAAQ,aAAa,SAAS,CAAC,EAAE,GAAG;AAChD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,SAAS,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,kCAAkC,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,QAAQ,UAAU;AAAA,MAC3I,YAAY,QAAQ,eAAe,SAAS,CAAC,EAAE,GAAG,WAAW,KAAK,SAAS,MAAM;AAAA,MACjF,0BAA0B,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC,EAAE,GAAG;AAAA,MACpF,GAAG;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/router/status.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { loadRawConfig, retiredPaymentKeys, RETIRED_PAYMENT_GUIDANCE } from '../lib/config';\nimport { spentOf } from '../lib/spend-ledger';\nimport { resolveContextSettings } from '../lib/settings';\nimport { readSpendSummary } from '../lib/wallet/spend';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin status`: what this machine has spent and what it is still holding.\n *\n * IT READS `spend.json`, NOT THE BACKEND. The rolling window, the committed\n * total and the reservations still open are the local truth about money, and\n * the reservations are also the record of a request whose outcome is unknown:\n * an authorization that was transmitted is committed, so anything still open\n * here is either in flight or a crash that has not yet aged out.\n */\n\nexport interface StatusDeps {\n now?: () => number;\n}\n\nexport async function runRouterStatus(\n ctx: CommandContext,\n deps: StatusDeps = {},\n): Promise<CommandResult> {\n const now = deps.now ?? Date.now;\n const settings = await resolveContextSettings(ctx);\n // The same projection an authorization would make, so what this prints is\n // what the next lookup would actually be measured against.\n const ledger = await readSpendSummary(ctx.dataDir, { now });\n const committedAtomic = BigInt(ledger?.committedAtomic ?? '0');\n const reservedAtomic = (ledger?.reservations ?? []).reduce(\n (sum, r) => sum + BigInt(r.amountAtomic),\n 0n,\n );\n const retired = retiredPaymentKeys(await loadRawConfig(ctx.dataDir));\n const warnings = retired.length\n ? [`Ignored retired keys: ${retired.join(', ')}. ${RETIRED_PAYMENT_GUIDANCE}`]\n : [];\n const automaticAtomic = ledger === null ? 0n : spentOf(ledger);\n const budgetAtomic = settings.policy.sessionBudgetAtomic;\n const data = {\n baseUrl: settings.baseUrl,\n warnings,\n window: {\n startedAtMs: ledger?.windowStartMs ?? null,\n committed: toMoney(committedAtomic.toString()),\n automaticExposure: toMoney(automaticAtomic.toString()),\n reserved: toMoney(reservedAtomic.toString()),\n budget: budgetAtomic === null ? null : toMoney(budgetAtomic.toString()),\n },\n caps: {\n maxAutoSpend: toMoney(settings.policy.maxAutoSpendAtomic.toString()),\n },\n inFlight: (ledger?.reservations ?? []).map((r) => ({\n amount: toMoney(r.amountAtomic),\n ageSeconds: Math.max(0, Math.round((now() - r.atMs) / 1000)),\n ...(r.requestKey !== undefined ? { request: r.requestKey } : {}),\n })),\n };\n const budgetLine =\n budgetAtomic === null\n ? 'no daily limit'\n : `of ${toMoney(budgetAtomic.toString()).usd} USD in the rolling 24h window`;\n return {\n data,\n humanLines: [\n `spent ${toMoney(committedAtomic.toString()).usd} USD total; automatic exposure ${toMoney(automaticAtomic.toString()).usd} USD ${budgetLine}`,\n `reserved ${toMoney(reservedAtomic.toString()).usd} USD in ${data.inFlight.length} open request(s)`,\n `automatic router up to ${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd} USD per call; manual pay always requires consent`,\n ...warnings,\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,eAAsB,gBACpB,KACA,OAAmB,CAAC,GACI;AACxB,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,WAAW,MAAM,uBAAuB,GAAG;AAGjD,QAAM,SAAS,MAAM,iBAAiB,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1D,QAAM,kBAAkB,OAAO,QAAQ,mBAAmB,GAAG;AAC7D,QAAM,kBAAkB,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IAClD,CAAC,KAAK,MAAM,MAAM,OAAO,EAAE,YAAY;AAAA,IACvC;AAAA,EACF;AACA,QAAM,UAAU,mBAAmB,MAAM,cAAc,IAAI,OAAO,CAAC;AACnE,QAAM,WAAW,QAAQ,SACrB,CAAC,yBAAyB,QAAQ,KAAK,IAAI,CAAC,KAAK,wBAAwB,EAAE,IAC3E,CAAC;AACL,QAAM,kBAAkB,WAAW,OAAO,KAAK,QAAQ,MAAM;AAC7D,QAAM,eAAe,SAAS,OAAO;AACrC,QAAM,OAAO;AAAA,IACX,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,MACN,aAAa,QAAQ,iBAAiB;AAAA,MACtC,WAAW,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MAC7C,mBAAmB,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MACrD,UAAU,QAAQ,eAAe,SAAS,CAAC;AAAA,MAC3C,QAAQ,iBAAiB,OAAO,OAAO,QAAQ,aAAa,SAAS,CAAC;AAAA,IACxE;AAAA,IACA,MAAM;AAAA,MACJ,cAAc,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC;AAAA,IACrE;AAAA,IACA,WAAW,QAAQ,gBAAgB,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,MACjD,QAAQ,QAAQ,EAAE,YAAY;AAAA,MAC9B,YAAY,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,IAAI,EAAE,QAAQ,GAAI,CAAC;AAAA,MAC3D,GAAI,EAAE,eAAe,SAAY,EAAE,SAAS,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE,EAAE;AAAA,EACJ;AACA,QAAM,aACJ,iBAAiB,OACb,mBACA,MAAM,QAAQ,aAAa,SAAS,CAAC,EAAE,GAAG;AAChD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,SAAS,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,kCAAkC,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,QAAQ,UAAU;AAAA,MAC3I,YAAY,QAAQ,eAAe,SAAS,CAAC,EAAE,GAAG,WAAW,KAAK,SAAS,MAAM;AAAA,MACjF,0BAA0B,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC,EAAE,GAAG;AAAA,MACpF,GAAG;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -4,10 +4,9 @@ import {
4
4
  } from "./chunk-QF4SSCQV.js";
5
5
  import {
6
6
  routerSettings
7
- } from "./chunk-NSDZESRS.js";
8
- import "./chunk-TMLCEPCD.js";
9
- import "./chunk-O2JYBOUO.js";
10
- import "./chunk-P22ZWXFX.js";
7
+ } from "./chunk-OZ3LWLCI.js";
8
+ import "./chunk-HII5HOQV.js";
9
+ import "./chunk-XICKN3CH.js";
11
10
  import "./chunk-JLEF5WHM.js";
12
11
  import "./chunk-K6AXXYCG.js";
13
12
  import "./chunk-ZXTAQYNA.js";
@@ -84,4 +83,4 @@ export {
84
83
  runStatusLine,
85
84
  statusLineMain
86
85
  };
87
- //# sourceMappingURL=status-line-FJ6N7MKJ.js.map
86
+ //# sourceMappingURL=status-line-QKDJYZGV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/status-line.ts"],"sourcesContent":["import { renderProgress } from './progress';\nimport { routerSettings } from './settings';\nimport type { Io } from '../lib/output';\n\n/**\n * `tenjin status-line`: the live footer Claude Code runs on its own refresh.\n *\n * CHEAP AND READ-ONLY. One JSON event on stdin for the session identity, the\n * router's own switch for its directory, one read of that session's progress\n * directory, one line out. No network call, no wallet, no write: it runs once a\n * second for as long as a session is open, so anything it touched would be\n * touched 3,600 times an hour.\n *\n * IT CANNOT FAIL LOUDLY either. Every error path writes nothing and returns, so\n * the command exits 0 with empty output and the harness shows no footer.\n */\n\n/** Claude Code's status event is small; anything larger is not one. */\nconst MAX_EVENT_BYTES = 64_000;\n/** The harness writes the event immediately, so this is a liveness check. */\nexport const STDIN_TIMEOUT_MS = 1_000;\n\nexport interface StatusLineDeps {\n dataDir: string;\n /** Test seam for the harness event; production reads stdin. */\n readEvent?: () => Promise<string>;\n env?: NodeJS.ProcessEnv;\n now?: () => number;\n}\n\n/**\n * The bin entry's fast path for a bare `tenjin status-line`, which runs on a\n * one-second timer: commander and the command tree cost about 120 ms of parse\n * per tick over this path. It does load zod, for the router's own switch\n * through the one config parser, about 17 ms a tick. `dist-chunks.test.ts`\n * pins what it may load.\n */\nexport async function statusLineMain(): Promise<void> {\n const { dataDir } = await import('../lib/paths');\n await runStatusLine(\n { stdout: process.stdout, stderr: process.stderr, isTTY: false },\n { dataDir: dataDir(process.env) },\n );\n}\n\nexport async function runStatusLine(io: Io, deps: StatusLineDeps): Promise<void> {\n let rendered: string;\n try {\n const raw = await (deps.readEvent ?? readStdin)();\n const event: unknown = JSON.parse(raw);\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return;\n // Off here means no footer: the router is not running in this directory.\n const router = await routerSettings(\n { cwd: cwdOf(event) ?? process.cwd(), dataDir: deps.dataDir },\n { warn: () => undefined },\n );\n if (!router.enabled.value) return;\n const columns = Number((deps.env ?? process.env).COLUMNS);\n rendered = await renderProgress(deps.dataDir, sessionId, {\n ...(Number.isFinite(columns) && columns > 0 ? { columns } : {}),\n ...(deps.now !== undefined ? { now: deps.now() } : {}),\n });\n } catch {\n return;\n }\n if (rendered.length > 0) io.stdout.write(`${rendered}\\n`);\n}\n\n/**\n * The session identity, and nothing else off the event. A footer that showed\n * the wrong session's lookups would be a leak between two terminals, so an\n * event without a plain, bounded `session_id` renders nothing at all.\n */\nfunction sessionIdOf(event: unknown): string | null {\n if (event === null || typeof event !== 'object' || Array.isArray(event)) return null;\n const value = (event as { session_id?: unknown }).session_id;\n if (typeof value !== 'string' || value.length === 0 || value.length > 200) return null;\n return value;\n}\n\n/** The session's working directory, which `router.*` resolves from. */\nfunction cwdOf(event: unknown): string | null {\n const value = (event as { cwd?: unknown }).cwd;\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n\nasync function readStdin(): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n const timer = setTimeout(() => reject(new Error('no harness event')), STDIN_TIMEOUT_MS);\n process.stdin.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_EVENT_BYTES) {\n clearTimeout(timer);\n reject(new Error('harness event too large'));\n return;\n }\n chunks.push(chunk);\n });\n process.stdin.once('end', () => {\n clearTimeout(timer);\n resolve(Buffer.concat(chunks).toString('utf8'));\n });\n process.stdin.once('error', () => {\n clearTimeout(timer);\n reject(new Error('harness event unreadable'));\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,kBAAkB;AAEjB,IAAM,mBAAmB;AAiBhC,eAAsB,iBAAgC;AACpD,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,qBAAc;AAC/C,QAAM;AAAA,IACJ,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,OAAO,MAAM;AAAA,IAC/D,EAAE,SAAS,QAAQ,QAAQ,GAAG,EAAE;AAAA,EAClC;AACF;AAEA,eAAsB,cAAc,IAAQ,MAAqC;AAC/E,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,OAAO,KAAK,aAAa,WAAW;AAChD,UAAM,QAA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MAAM;AACd,UAAI,OAAO,iBAAiB;AAC1B,qBAAa,KAAK;AAClB,eAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB,CAAC;AACD,YAAQ,MAAM,KAAK,OAAO,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAQ,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,KAAK,SAAS,MAAM;AAChC,mBAAa,KAAK;AAClB,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/router/status-line.ts"],"sourcesContent":["import { renderProgress } from './progress';\nimport { routerSettings } from './settings';\nimport type { Io } from '../lib/output';\n\n/**\n * `tenjin status-line`: the live footer Claude Code runs on its own refresh.\n *\n * CHEAP AND READ-ONLY. One JSON event on stdin for the session identity, the\n * router's own switch for its directory, one read of that session's progress\n * directory, one line out. No network call, no wallet, no write: it runs once a\n * second for as long as a session is open, so anything it touched would be\n * touched 3,600 times an hour.\n *\n * IT CANNOT FAIL LOUDLY either. Every error path writes nothing and returns, so\n * the command exits 0 with empty output and the harness shows no footer.\n */\n\n/** Claude Code's status event is small; anything larger is not one. */\nconst MAX_EVENT_BYTES = 64_000;\n/** The harness writes the event immediately, so this is a liveness check. */\nexport const STDIN_TIMEOUT_MS = 1_000;\n\nexport interface StatusLineDeps {\n dataDir: string;\n /** Test seam for the harness event; production reads stdin. */\n readEvent?: () => Promise<string>;\n env?: NodeJS.ProcessEnv;\n now?: () => number;\n}\n\n/**\n * The bin entry's fast path for a bare `tenjin status-line`, which runs on a\n * one-second timer: commander and the command tree cost about 120 ms of parse\n * per tick over this path. It does load zod, for the router's own switch\n * through the one config parser, about 17 ms a tick. `dist-chunks.test.ts`\n * pins what it may load.\n */\nexport async function statusLineMain(): Promise<void> {\n const { dataDir } = await import('../lib/paths');\n await runStatusLine(\n { stdout: process.stdout, stderr: process.stderr, isTTY: false },\n { dataDir: dataDir(process.env) },\n );\n}\n\nexport async function runStatusLine(io: Io, deps: StatusLineDeps): Promise<void> {\n let rendered: string;\n try {\n const raw = await (deps.readEvent ?? readStdin)();\n const event: unknown = JSON.parse(raw);\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return;\n // Off here means no footer: the router is not running in this directory.\n const router = await routerSettings(\n { cwd: cwdOf(event) ?? process.cwd(), dataDir: deps.dataDir },\n { warn: () => undefined },\n );\n if (!router.enabled.value) return;\n const columns = Number((deps.env ?? process.env).COLUMNS);\n rendered = await renderProgress(deps.dataDir, sessionId, {\n ...(Number.isFinite(columns) && columns > 0 ? { columns } : {}),\n ...(deps.now !== undefined ? { now: deps.now() } : {}),\n });\n } catch {\n return;\n }\n if (rendered.length > 0) io.stdout.write(`${rendered}\\n`);\n}\n\n/**\n * The session identity, and nothing else off the event. A footer that showed\n * the wrong session's lookups would be a leak between two terminals, so an\n * event without a plain, bounded `session_id` renders nothing at all.\n */\nfunction sessionIdOf(event: unknown): string | null {\n if (event === null || typeof event !== 'object' || Array.isArray(event)) return null;\n const value = (event as { session_id?: unknown }).session_id;\n if (typeof value !== 'string' || value.length === 0 || value.length > 200) return null;\n return value;\n}\n\n/** The session's working directory, which `router.*` resolves from. */\nfunction cwdOf(event: unknown): string | null {\n const value = (event as { cwd?: unknown }).cwd;\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n\nasync function readStdin(): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n const timer = setTimeout(() => reject(new Error('no harness event')), STDIN_TIMEOUT_MS);\n process.stdin.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_EVENT_BYTES) {\n clearTimeout(timer);\n reject(new Error('harness event too large'));\n return;\n }\n chunks.push(chunk);\n });\n process.stdin.once('end', () => {\n clearTimeout(timer);\n resolve(Buffer.concat(chunks).toString('utf8'));\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AG,QAAO;AAChF,QAAM,QAAS,MAAmC;AAClD,MAAI,OAAO,UAAU,YAAY,MAAM,WAAW,KAAK,MAAM,SAAS,IAAK,QAAO;AAClF,SAAO;AACT;AAGA,SAAS,MAAM,OAA+B;AAC5C,QAAM,QAAS,MAA4B;AAC3C,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAEA,eAAe,YAA6B;AAC1C,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAmB,CAAC;AAC1B,QAAI,OAAO;AACX,UAAM,QAAQ,WAAW,MAAM,OAAO,IAAI,MAAM,kBAAkB,CAAC,GAAG,gBAAgB;AACtF,YAAQ,MAAM,GAAG,QAAQ,CAAC,UAAkB;AAC1C,cAAQ,MAAM;AACd,UAAI,OAAO,iBAAiB;AAC1B,qBAAa,KAAK;AAClB,eAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB,CAAC;AACD,YAAQ,MAAM,KAAK,OAAO,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAQ,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,KAAK,SAAS,MAAM;AAChC,mBAAa,KAAK;AAClB,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -9,9 +9,11 @@ import {
9
9
  inspectStatusLine,
10
10
  removeStatusLine,
11
11
  statusLineMode
12
- } from "./chunk-YZTIYDWU.js";
13
- import "./chunk-SQSKVKX6.js";
14
- import "./chunk-ZNZGBUV6.js";
12
+ } from "./chunk-NTYQHAIM.js";
13
+ import "./chunk-KGTQRJGS.js";
14
+ import "./chunk-AKWGE6JQ.js";
15
+ import "./chunk-TGLKKLQG.js";
16
+ import "./chunk-ODH7UXIS.js";
15
17
  import "./chunk-JLEF5WHM.js";
16
18
  import "./chunk-K6AXXYCG.js";
17
19
  import "./chunk-ZXTAQYNA.js";
@@ -26,4 +28,4 @@ export {
26
28
  removeStatusLine,
27
29
  statusLineMode
28
30
  };
29
- //# sourceMappingURL=status-line-wiring-GXFNXHPE.js.map
31
+ //# sourceMappingURL=status-line-wiring-ZDBYHNYR.js.map
@@ -1,35 +1,37 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  ALLOW_RULE,
4
+ DENY_RULE,
4
5
  mcpRemoveCommand,
5
6
  mcpScope,
6
7
  readMcpEntry,
7
8
  routerSettingsPath
8
- } from "./chunk-H5UR3GFJ.js";
9
- import {
10
- MCP_SERVER_NAME
11
- } from "./chunk-TGLKKLQG.js";
12
- import "./chunk-O2WN732M.js";
9
+ } from "./chunk-3ZYPVSIU.js";
10
+ import "./chunk-VYONGSMQ.js";
11
+ import "./chunk-UDWGT4FX.js";
13
12
  import {
14
13
  onPath,
15
14
  persistRouterProject
16
- } from "./chunk-W2ARIOAZ.js";
15
+ } from "./chunk-YSW57KUT.js";
17
16
  import "./chunk-A36LQPHV.js";
18
17
  import "./chunk-P7LABKCW.js";
19
18
  import "./chunk-MEFB5KHA.js";
20
- import "./chunk-NSDZESRS.js";
19
+ import "./chunk-OZ3LWLCI.js";
21
20
  import "./chunk-2I4QTOLB.js";
22
- import "./chunk-TMLCEPCD.js";
23
- import "./chunk-O2JYBOUO.js";
24
- import "./chunk-P22ZWXFX.js";
21
+ import "./chunk-HII5HOQV.js";
22
+ import "./chunk-XICKN3CH.js";
25
23
  import {
26
24
  removeStatusLine
27
- } from "./chunk-YZTIYDWU.js";
25
+ } from "./chunk-NTYQHAIM.js";
28
26
  import {
29
27
  inspectHooksFile,
30
28
  pruneHooks
31
- } from "./chunk-SQSKVKX6.js";
32
- import "./chunk-ZNZGBUV6.js";
29
+ } from "./chunk-KGTQRJGS.js";
30
+ import "./chunk-AKWGE6JQ.js";
31
+ import {
32
+ MCP_SERVER_NAME
33
+ } from "./chunk-TGLKKLQG.js";
34
+ import "./chunk-ODH7UXIS.js";
33
35
  import {
34
36
  writeFileAtomic
35
37
  } from "./chunk-JLEF5WHM.js";
@@ -70,7 +72,7 @@ async function runRouterUninstall(args, ctx, deps = {}) {
70
72
  return {
71
73
  data,
72
74
  humanLines: [
73
- removed.warning === void 0 ? `removed ${removed.events.length > 0 ? removed.events.join(", ") : "no"} hook entries and ${removed.ruleRemoved ? "the" : "no"} permission rule from ${settingsPath}` : `${settingsPath} was left untouched (${removed.warning})`,
75
+ removed.warning === void 0 ? `removed ${removed.events.length > 0 ? removed.events.join(", ") : "no"} hook entries and ${removed.ruleRemoved || removed.denyRuleRemoved ? "the" : "no"} permission rules from ${settingsPath}` : `${settingsPath} was left untouched (${removed.warning})`,
74
76
  statusLine.wrote ? "removed the x402 status line" : statusLine.state === "composed" ? "status line: yours also runs the x402 footer; edit that command to drop it" : "status line: none of ours was registered",
75
77
  mcp.removed ? `removed the ${MCP_SERVER_NAME} MCP server (${mcp.scope} scope)` : mcp.kept !== void 0 ? `mcp: ${mcp.reason ?? "left in place"}` : `mcp: run ${mcp.command}`,
76
78
  "Your wallet, spend ledger and config are kept."
@@ -78,41 +80,43 @@ async function runRouterUninstall(args, ctx, deps = {}) {
78
80
  };
79
81
  }
80
82
  async function removeFromSettings(path, dataDir) {
83
+ const nothing = { events: [], ruleRemoved: false, denyRuleRemoved: false, wrote: false };
81
84
  const found = await inspectHooksFile(path);
82
- if ("refusal" in found) {
83
- return { events: [], ruleRemoved: false, wrote: false, warning: found.refusal.reason };
84
- }
85
+ if ("refusal" in found) return { ...nothing, warning: found.refusal.reason };
85
86
  const { raw, settings, hooks } = found;
86
- if (raw === null) return { events: [], ruleRemoved: false, wrote: false };
87
+ if (raw === null) return nothing;
87
88
  const pruned = pruneHooks(hooks, dataDir);
88
89
  const permissions = settings.permissions !== null && typeof settings.permissions === "object" && !Array.isArray(settings.permissions) ? settings.permissions : void 0;
89
90
  const allow = Array.isArray(permissions?.allow) ? permissions.allow : void 0;
91
+ const deny = Array.isArray(permissions?.deny) ? permissions.deny : void 0;
90
92
  const ruleRemoved = allow?.includes(ALLOW_RULE) === true;
93
+ const denyRuleRemoved = deny?.includes(DENY_RULE) === true;
91
94
  const next = {
92
95
  ...settings,
93
96
  hooks: pruned.next,
94
- ...permissions !== void 0 && allow !== void 0 ? { permissions: { ...permissions, allow: allow.filter((r) => r !== ALLOW_RULE) } } : {}
97
+ ...permissions !== void 0 ? {
98
+ permissions: {
99
+ ...permissions,
100
+ ...allow !== void 0 ? { allow: allow.filter((r) => r !== ALLOW_RULE) } : {},
101
+ ...deny !== void 0 ? { deny: deny.filter((r) => r !== DENY_RULE) } : {}
102
+ }
103
+ } : {}
95
104
  };
96
105
  const body = `${JSON.stringify(next, null, 2)}
97
106
  `;
98
107
  if (body === raw) {
99
- return { events: pruned.removed, ruleRemoved, wrote: false };
108
+ return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: false };
100
109
  }
101
110
  const mode = await stat(found.path).then((s) => ({ mode: s.mode & 511 })).catch(() => ({}));
102
111
  if (await readFile(found.path, "utf8").catch(() => null) !== raw) {
103
- return { events: [], ruleRemoved: false, wrote: false, warning: "changed-since-read" };
112
+ return { ...nothing, warning: "changed-since-read" };
104
113
  }
105
114
  try {
106
115
  await writeFileAtomic(found.path, body, mode);
107
116
  } catch (err) {
108
- return {
109
- events: [],
110
- ruleRemoved: false,
111
- wrote: false,
112
- warning: err instanceof Error ? err.message : String(err)
113
- };
117
+ return { ...nothing, warning: err instanceof Error ? err.message : String(err) };
114
118
  }
115
- return { events: pruned.removed, ruleRemoved, wrote: true };
119
+ return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: true };
116
120
  }
117
121
  async function removeMcpServer(deps, env, project, cwd, home) {
118
122
  const scope = mcpScope(project);
@@ -162,4 +166,4 @@ export {
162
166
  MCP_REMOVE_COMMAND,
163
167
  runRouterUninstall
164
168
  };
165
- //# sourceMappingURL=uninstall-5P2GFYBY.js.map
169
+ //# sourceMappingURL=uninstall-ZXWABDHS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/uninstall.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { homedir } from 'node:os';\nimport { readFile, stat } from 'node:fs/promises';\nimport { isAbsolute } from 'node:path';\nimport { promisify } from 'node:util';\nimport { persistRouterProject } from '../commands/config';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { inspectHooksFile, pruneHooks } from '../lib/harness-hooks';\nimport { onPath } from '../lib/skill-wiring';\nimport type { CommandContext, CommandResult } from '../context';\nimport {\n ALLOW_RULE,\n DENY_RULE,\n MCP_SERVER_NAME,\n mcpRemoveCommand,\n mcpScope,\n readMcpEntry,\n routerSettingsPath,\n type McpEntryState,\n} from './install';\nimport { removeStatusLine } from './status-line-wiring';\n\n/**\n * `tenjin uninstall`: take out the hook entries, the allow and deny rules and\n * the MCP registration, and nothing else.\n *\n * THE WALLET AND `spend.json` STAY. Removing an integration is not a reason to\n * destroy a key that holds funds or a ledger that records what was spent; both\n * are the user's, and `tenjin wallet` is where they go to move either.\n */\n\nconst exec = promisify(execFile);\n/** The user-scope form; `--project` removes at project scope symmetrically. */\nexport const MCP_REMOVE_COMMAND = mcpRemoveCommand();\n\nexport interface RouterUninstallArgs {\n project?: boolean;\n}\n\nexport interface RouterUninstallDeps {\n homeDir?: string;\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n which?: (bin: string) => boolean;\n removeMcp?: (opts: { scope: 'user' | 'project'; cwd: string }) => Promise<void>;\n /** Reads the registration the scope's own file holds; tests inject it. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n}\n\nexport async function runRouterUninstall(\n args: RouterUninstallArgs,\n ctx: CommandContext,\n deps: RouterUninstallDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) throw new Error('The home directory is not an absolute path.');\n const cwd = deps.cwd ?? process.cwd();\n const settingsPath = routerSettingsPath({\n ...(args.project === true ? { project: true } : {}),\n homeDir: home,\n cwd,\n });\n\n const removed = await removeFromSettings(settingsPath, ctx.dataDir);\n // OURS ALONE, and after the hooks write so the two never touch the file at\n // once. A COMPOSED status line is the user's own text with ours appended:\n // deleting it would take their line with it, so it is reported and kept.\n const statusLine = await removeStatusLine(settingsPath);\n // Forgotten, so a later `tenjin update` does not go looking for a project\n // this machine no longer wires.\n if (args.project === true) {\n await persistRouterProject(ctx.dataDir, cwd, false).catch(() => undefined);\n }\n // The SAME scope the install used, or a `--project` uninstall would leave the\n // project's registration behind and reach into the user's file instead.\n const mcp = await removeMcpServer(deps, env, args.project === true, cwd, home);\n const data = {\n settingsPath,\n ...removed,\n statusLine,\n mcp,\n kept: ['wallet.json', 'spend.json', 'config.json'],\n };\n return {\n data,\n humanLines: [\n removed.warning === undefined\n ? `removed ${removed.events.length > 0 ? removed.events.join(', ') : 'no'} hook entries and ${removed.ruleRemoved || removed.denyRuleRemoved ? 'the' : 'no'} permission rules from ${settingsPath}`\n : `${settingsPath} was left untouched (${removed.warning})`,\n statusLine.wrote\n ? 'removed the x402 status line'\n : statusLine.state === 'composed'\n ? 'status line: yours also runs the x402 footer; edit that command to drop it'\n : 'status line: none of ours was registered',\n mcp.removed\n ? `removed the ${MCP_SERVER_NAME} MCP server (${mcp.scope} scope)`\n : mcp.kept !== undefined\n ? `mcp: ${mcp.reason ?? 'left in place'}`\n : `mcp: run ${mcp.command}`,\n 'Your wallet, spend ledger and config are kept.',\n ],\n };\n}\n\ninterface SettingsRemoval {\n /** The events an entry of ours was taken out of. */\n events: string[];\n ruleRemoved: boolean;\n denyRuleRemoved: boolean;\n wrote: boolean;\n warning?: string;\n}\n\nasync function removeFromSettings(path: string, dataDir: string): Promise<SettingsRemoval> {\n const nothing = { events: [], ruleRemoved: false, denyRuleRemoved: false, wrote: false };\n const found = await inspectHooksFile(path);\n if ('refusal' in found) return { ...nothing, warning: found.refusal.reason };\n const { raw, settings, hooks } = found;\n if (raw === null) return nothing;\n const pruned = pruneHooks(hooks, dataDir);\n const permissions =\n settings.permissions !== null &&\n typeof settings.permissions === 'object' &&\n !Array.isArray(settings.permissions)\n ? (settings.permissions as Record<string, unknown>)\n : undefined;\n // Each list loses our one rule and keeps every other entry; a list that is\n // absent or not an array is left as it is.\n const allow = Array.isArray(permissions?.allow) ? permissions.allow : undefined;\n const deny = Array.isArray(permissions?.deny) ? permissions.deny : undefined;\n const ruleRemoved = allow?.includes(ALLOW_RULE) === true;\n const denyRuleRemoved = deny?.includes(DENY_RULE) === true;\n const next = {\n ...settings,\n hooks: pruned.next,\n ...(permissions !== undefined\n ? {\n permissions: {\n ...permissions,\n ...(allow !== undefined ? { allow: allow.filter((r) => r !== ALLOW_RULE) } : {}),\n ...(deny !== undefined ? { deny: deny.filter((r) => r !== DENY_RULE) } : {}),\n },\n }\n : {}),\n };\n const body = `${JSON.stringify(next, null, 2)}\\n`;\n if (body === raw) {\n return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: false };\n }\n const mode = await stat(found.path)\n .then((s) => ({ mode: s.mode & 0o777 }))\n .catch(() => ({}));\n if ((await readFile(found.path, 'utf8').catch(() => null)) !== raw) {\n return { ...nothing, warning: 'changed-since-read' };\n }\n try {\n await writeFileAtomic(found.path, body, mode);\n } catch (err) {\n return { ...nothing, warning: err instanceof Error ? err.message : String(err) };\n }\n return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: true };\n}\n\nasync function removeMcpServer(\n deps: RouterUninstallDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<{\n removed: boolean;\n scope: 'user' | 'project';\n command: string;\n reason?: string;\n kept?: 'foreign' | 'unreadable';\n}> {\n const scope = mcpScope(project);\n const command = mcpRemoveCommand(project);\n // THE SAME CHECK INSTALL MAKES. The name `x402` proves nothing: another tool\n // can register its own server under it, and install refuses to touch that\n // entry. Uninstall must not remove it either. An absent entry falls through\n // to the remove as before, so nothing changes for a normal install.\n const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n if (existing.state === 'wrong-command') {\n return {\n removed: false,\n scope,\n command,\n kept: 'foreign',\n reason: `an MCP server named ${MCP_SERVER_NAME} at ${scope} scope launches something else; this command will not remove a registration it did not write, so it was left in place`,\n };\n }\n if (existing.state === 'unreadable') {\n return {\n removed: false,\n scope,\n command,\n kept: 'unreadable',\n reason: `the ${scope}-scope registration file could not be read, so nothing was removed from it`,\n };\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (!which('claude')) {\n return { removed: false, scope, command, reason: 'the `claude` binary is not on PATH' };\n }\n try {\n await (deps.removeMcp ?? runClaudeMcpRemove)({ scope, cwd });\n return { removed: true, scope, command };\n } catch (err) {\n return {\n removed: false,\n scope,\n command,\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nasync function runClaudeMcpRemove(opts: { scope: 'user' | 'project'; cwd: string }): Promise<void> {\n await exec('claude', ['mcp', 'remove', MCP_SERVER_NAME, '-s', opts.scope], {\n timeout: 20_000,\n cwd: opts.cwd,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,UAAU,YAAY;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AA2B1B,IAAM,OAAO,UAAU,QAAQ;AAExB,IAAM,qBAAqB,iBAAiB;AAoBnD,eAAsB,mBACpB,MACA,KACA,OAA4B,CAAC,GACL;AACxB,QAAM,MAAM,KAAK,OAAO,QAAQ;AAChC,QAAM,OAAO,KAAK,WAAW,QAAQ;AACrC,MAAI,CAAC,WAAW,IAAI,EAAG,OAAM,IAAI,MAAM,6CAA6C;AACpF,QAAM,MAAM,KAAK,OAAO,QAAQ,IAAI;AACpC,Q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iB,MAAM,KAAK,KAAK,GAAG;AAAA,IACzE,SAAS;AAAA,IACT,KAAK,KAAK;AAAA,EACZ,CAAC;AACH;","names":[]}
@@ -5,15 +5,21 @@ import {
5
5
  fetchDistTags,
6
6
  isNewer,
7
7
  resolveTarget
8
- } from "./chunk-XRW4N23F.js";
8
+ } from "./chunk-SCAE6PW6.js";
9
+ import {
10
+ CHANNEL_DEPOSIT_ATOMIC,
11
+ ROUTING_FEE_ATOMIC,
12
+ usd
13
+ } from "./chunk-VYONGSMQ.js";
9
14
  import {
10
15
  emitWriteNotice,
11
16
  sanitizeForTerminal
12
- } from "./chunk-O2WN732M.js";
13
- import "./chunk-P22ZWXFX.js";
17
+ } from "./chunk-UDWGT4FX.js";
18
+ import "./chunk-2I4QTOLB.js";
19
+ import "./chunk-XICKN3CH.js";
14
20
  import {
15
21
  package_default
16
- } from "./chunk-ZNZGBUV6.js";
22
+ } from "./chunk-ODH7UXIS.js";
17
23
  import {
18
24
  CliError
19
25
  } from "./chunk-JLEF5WHM.js";
@@ -289,9 +295,14 @@ async function runUpdate(opts, ctx, deps = {}) {
289
295
  const refresh = await refreshProfiles(ctx, deps);
290
296
  return {
291
297
  data: { ...data(true), refresh },
292
- humanLines: [`Updated tenjin-cli ${current} -> ${latest}.`, ...refreshLines(refresh)]
298
+ humanLines: [
299
+ `Updated tenjin-cli ${current} -> ${latest}.`,
300
+ ...refreshLines(refresh),
301
+ ROUTING_FEE_LINE
302
+ ]
293
303
  };
294
304
  }
305
+ var ROUTING_FEE_LINE = `Routing costs $${usd(ROUTING_FEE_ATOMIC)} a call once Tenjin's server turns the fee on, paid from deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that count against your spend limits (\`tenjin config get maxAutoSpend\`, \`tenjin config get sessionBudget\`).`;
295
306
  var REFRESH_TIMEOUT_MS = 6e4;
296
307
  async function refreshProfiles(ctx, deps) {
297
308
  const home = deps.homeDir ?? homedir();
@@ -430,4 +441,4 @@ export {
430
441
  spawnCapture,
431
442
  versionFreeEntry
432
443
  };
433
- //# sourceMappingURL=update-QJ5YHJ7I.js.map
444
+ //# sourceMappingURL=update-HEIWVOP5.js.map