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.
- package/README.md +16 -43
- package/dist/{chunk-EOGJKIOG.js → chunk-2TYQD22Q.js} +16 -7
- package/dist/chunk-2TYQD22Q.js.map +1 -0
- package/dist/{chunk-SCAE6PW6.js → chunk-4L7KMA7P.js} +6 -6
- package/dist/{chunk-UDWGT4FX.js → chunk-5FGO6TYT.js} +13 -5
- package/dist/chunk-5FGO6TYT.js.map +1 -0
- package/dist/{chunk-IYLECN4D.js → chunk-5NEHH2E5.js} +3 -3
- package/dist/{chunk-EACMJEF3.js → chunk-64SE3QC5.js} +75 -176
- package/dist/chunk-64SE3QC5.js.map +1 -0
- package/dist/chunk-6ZSGER3A.js +52 -0
- package/dist/chunk-6ZSGER3A.js.map +1 -0
- package/dist/{chunk-QF4SSCQV.js → chunk-AWKQSKUL.js} +4 -3
- package/dist/chunk-AWKQSKUL.js.map +1 -0
- package/dist/chunk-B2L53TMK.js +70 -0
- package/dist/chunk-B2L53TMK.js.map +1 -0
- package/dist/chunk-BOAI23CX.js +222 -0
- package/dist/chunk-BOAI23CX.js.map +1 -0
- package/dist/{chunk-OZ3LWLCI.js → chunk-DATCR7AU.js} +3 -3
- package/dist/{chunk-NTYQHAIM.js → chunk-DSNXKUXI.js} +2 -2
- package/dist/{chunk-HII5HOQV.js → chunk-G4AM2SOL.js} +5 -3
- package/dist/{chunk-HII5HOQV.js.map → chunk-G4AM2SOL.js.map} +1 -1
- package/dist/{chunk-VYONGSMQ.js → chunk-GU4GGKYP.js} +85 -6
- package/dist/chunk-GU4GGKYP.js.map +1 -0
- package/dist/{chunk-YSW57KUT.js → chunk-H2L33M7F.js} +31 -27
- package/dist/chunk-H2L33M7F.js.map +1 -0
- package/dist/{chunk-ODH7UXIS.js → chunk-HC3QEZKT.js} +5 -4
- package/dist/chunk-HC3QEZKT.js.map +1 -0
- package/dist/chunk-MAQUL5BD.js +99 -0
- package/dist/chunk-MAQUL5BD.js.map +1 -0
- package/dist/{chunk-EG7P4SM6.js → chunk-O7CUHHYU.js} +4 -4
- package/dist/{chunk-EG7P4SM6.js.map → chunk-O7CUHHYU.js.map} +1 -1
- package/dist/{chunk-CEMXMUIU.js → chunk-OHZYNZSD.js} +36 -7
- package/dist/chunk-OHZYNZSD.js.map +1 -0
- package/dist/{chunk-3ZYPVSIU.js → chunk-PY7MQUKP.js} +238 -43
- package/dist/chunk-PY7MQUKP.js.map +1 -0
- package/dist/chunk-PZ5N6BAL.js +268 -0
- package/dist/chunk-PZ5N6BAL.js.map +1 -0
- package/dist/chunk-S4SAZ7OD.js +30 -0
- package/dist/chunk-S4SAZ7OD.js.map +1 -0
- package/dist/{chunk-NYPFOHSJ.js → chunk-SKQQOEWH.js} +4 -4
- package/dist/{chunk-XICKN3CH.js → chunk-VIOUZW7Z.js} +2 -46
- package/dist/chunk-VIOUZW7Z.js.map +1 -0
- package/dist/{chunk-YTM7OURD.js → chunk-VNNXAYJE.js} +2 -2
- package/dist/{chunk-CKDD554V.js → chunk-VXIBZ6W5.js} +5 -3
- package/dist/{chunk-CKDD554V.js.map → chunk-VXIBZ6W5.js.map} +1 -1
- package/dist/{chunk-GT6W3VJM.js → chunk-X7I343ZY.js} +3 -53
- package/dist/chunk-X7I343ZY.js.map +1 -0
- package/dist/{chunk-KGTQRJGS.js → chunk-XVYATBKD.js} +5 -10
- package/dist/{chunk-KGTQRJGS.js.map → chunk-XVYATBKD.js.map} +1 -1
- package/dist/{chunk-DRXDTITB.js → chunk-YKM2ZTA2.js} +59 -25
- package/dist/chunk-YKM2ZTA2.js.map +1 -0
- package/dist/{chunk-CP7O6M55.js → chunk-YQOQ6XEI.js} +109 -27
- package/dist/chunk-YQOQ6XEI.js.map +1 -0
- package/dist/{cli-4WMGZPBP.js → cli-6JNIPZQ6.js} +43 -39
- package/dist/{cli-4WMGZPBP.js.map → cli-6JNIPZQ6.js.map} +1 -1
- package/dist/{config-VU6U7QOU.js → config-G75YT6NC.js} +15 -10
- package/dist/{doctor-26JS2SG3.js → doctor-3GMDOW4Y.js} +140 -98
- package/dist/doctor-3GMDOW4Y.js.map +1 -0
- package/dist/env-proxy-XL4P73MZ.js +15 -0
- package/dist/{fund-JJN3FRRF.js → fund-3IPR5YRJ.js} +26 -14
- package/dist/{fund-JJN3FRRF.js.map → fund-3IPR5YRJ.js.map} +1 -1
- package/dist/hook-command-ZXX4FT4N.js +32 -0
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/{install-GXQ33J4G.js → install-6OROTYHZ.js} +20 -14
- package/dist/{install-identity-HFQUXPSI.js → install-identity-PM4AGFFX.js} +7 -6
- package/dist/{install-wallet-27LTEHBI.js → install-wallet-6756NOB5.js} +11 -8
- package/dist/{install-wallet-27LTEHBI.js.map → install-wallet-6756NOB5.js.map} +1 -1
- package/dist/{mcp-AHCZVD2U.js → mcp-33FAAZ7F.js} +723 -123
- package/dist/mcp-33FAAZ7F.js.map +1 -0
- package/dist/{pay-3TCOPGCX.js → pay-XOYR4PCH.js} +14 -12
- package/dist/{payments-H3LSBGSL.js → payments-UTQDBO7H.js} +8 -6
- package/dist/{payments-H3LSBGSL.js.map → payments-UTQDBO7H.js.map} +1 -1
- package/dist/{send-LKCLN5GA.js → send-CVGNOQW3.js} +12 -9
- package/dist/{send-LKCLN5GA.js.map → send-CVGNOQW3.js.map} +1 -1
- package/dist/{status-2FDGI4LQ.js → status-NACN4DGX.js} +10 -7
- package/dist/{status-2FDGI4LQ.js.map → status-NACN4DGX.js.map} +1 -1
- package/dist/{status-line-QKDJYZGV.js → status-line-3IQKGRUH.js} +6 -5
- package/dist/{status-line-QKDJYZGV.js.map → status-line-3IQKGRUH.js.map} +1 -1
- package/dist/{status-line-wiring-ZDBYHNYR.js → status-line-wiring-QXBOOY2T.js} +4 -4
- package/dist/{uninstall-ZXWABDHS.js → uninstall-NYFKSYW4.js} +22 -16
- package/dist/{uninstall-ZXWABDHS.js.map → uninstall-NYFKSYW4.js.map} +1 -1
- package/dist/{update-HEIWVOP5.js → update-RJDA5ZY3.js} +11 -13
- package/dist/update-RJDA5ZY3.js.map +1 -0
- package/dist/{wallet-T7JYWI6O.js → wallet-B3FVHNTS.js} +11 -8
- package/dist/wallet-B3FVHNTS.js.map +1 -0
- package/docs/agent-permissions.md +18 -7
- package/docs/troubleshooting.md +13 -0
- package/package.json +4 -3
- package/dist/chunk-3ZYPVSIU.js.map +0 -1
- package/dist/chunk-CEMXMUIU.js.map +0 -1
- package/dist/chunk-CP7O6M55.js.map +0 -1
- package/dist/chunk-DRXDTITB.js.map +0 -1
- package/dist/chunk-EACMJEF3.js.map +0 -1
- package/dist/chunk-EOGJKIOG.js.map +0 -1
- package/dist/chunk-GT6W3VJM.js.map +0 -1
- package/dist/chunk-ODH7UXIS.js.map +0 -1
- package/dist/chunk-QF4SSCQV.js.map +0 -1
- package/dist/chunk-UDWGT4FX.js.map +0 -1
- package/dist/chunk-VYONGSMQ.js.map +0 -1
- package/dist/chunk-XICKN3CH.js.map +0 -1
- package/dist/chunk-YSW57KUT.js.map +0 -1
- package/dist/doctor-26JS2SG3.js.map +0 -1
- package/dist/hook-command-S2V4UNB3.js +0 -28
- package/dist/mcp-AHCZVD2U.js.map +0 -1
- package/dist/update-HEIWVOP5.js.map +0 -1
- /package/dist/{chunk-SCAE6PW6.js.map → chunk-4L7KMA7P.js.map} +0 -0
- /package/dist/{chunk-IYLECN4D.js.map → chunk-5NEHH2E5.js.map} +0 -0
- /package/dist/{chunk-OZ3LWLCI.js.map → chunk-DATCR7AU.js.map} +0 -0
- /package/dist/{chunk-NTYQHAIM.js.map → chunk-DSNXKUXI.js.map} +0 -0
- /package/dist/{chunk-NYPFOHSJ.js.map → chunk-SKQQOEWH.js.map} +0 -0
- /package/dist/{chunk-YTM7OURD.js.map → chunk-VNNXAYJE.js.map} +0 -0
- /package/dist/{config-VU6U7QOU.js.map → config-G75YT6NC.js.map} +0 -0
- /package/dist/{hook-command-S2V4UNB3.js.map → env-proxy-XL4P73MZ.js.map} +0 -0
- /package/dist/{install-GXQ33J4G.js.map → hook-command-ZXX4FT4N.js.map} +0 -0
- /package/dist/{install-identity-HFQUXPSI.js.map → install-6OROTYHZ.js.map} +0 -0
- /package/dist/{pay-3TCOPGCX.js.map → install-identity-PM4AGFFX.js.map} +0 -0
- /package/dist/{status-line-wiring-ZDBYHNYR.js.map → pay-XOYR4PCH.js.map} +0 -0
- /package/dist/{wallet-T7JYWI6O.js.map → status-line-wiring-QXBOOY2T.js.map} +0 -0
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
paidLegTimeoutMs,
|
|
5
5
|
runPay,
|
|
6
6
|
settlementTx
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YKM2ZTA2.js";
|
|
8
|
+
import "./chunk-LHHMV4GU.js";
|
|
8
9
|
import "./chunk-LAIZ2AQA.js";
|
|
9
10
|
import "./chunk-LFZJM56J.js";
|
|
10
11
|
import "./chunk-7EKYXMUO.js";
|
|
@@ -13,11 +14,10 @@ import "./chunk-TTNESUPQ.js";
|
|
|
13
14
|
import "./chunk-HPWO4O6S.js";
|
|
14
15
|
import "./chunk-POUWHWID.js";
|
|
15
16
|
import "./chunk-XZKD7DIF.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-GT6W3VJM.js";
|
|
17
|
+
import "./chunk-VNNXAYJE.js";
|
|
18
|
+
import "./chunk-O7CUHHYU.js";
|
|
19
|
+
import "./chunk-VXIBZ6W5.js";
|
|
20
|
+
import "./chunk-X7I343ZY.js";
|
|
21
21
|
import "./chunk-AWQPGIR6.js";
|
|
22
22
|
import "./chunk-N35E6CM2.js";
|
|
23
23
|
import "./chunk-JRGFKVAZ.js";
|
|
@@ -26,14 +26,16 @@ import "./chunk-EGELTSPU.js";
|
|
|
26
26
|
import "./chunk-KG3D7FIF.js";
|
|
27
27
|
import "./chunk-RBJPAZFI.js";
|
|
28
28
|
import "./chunk-BPMWXTFX.js";
|
|
29
|
-
import "./chunk-UDWGT4FX.js";
|
|
30
29
|
import "./chunk-7QKHZQKW.js";
|
|
31
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-OHZYNZSD.js";
|
|
32
31
|
import "./chunk-MEFB5KHA.js";
|
|
32
|
+
import "./chunk-B2L53TMK.js";
|
|
33
|
+
import "./chunk-5FGO6TYT.js";
|
|
34
|
+
import "./chunk-HC3QEZKT.js";
|
|
33
35
|
import "./chunk-2I4QTOLB.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
36
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-G4AM2SOL.js";
|
|
37
|
+
import "./chunk-6ZSGER3A.js";
|
|
38
|
+
import "./chunk-VIOUZW7Z.js";
|
|
37
39
|
import "./chunk-JLEF5WHM.js";
|
|
38
40
|
import "./chunk-K6AXXYCG.js";
|
|
39
41
|
import "./chunk-ZXTAQYNA.js";
|
|
@@ -43,4 +45,4 @@ export {
|
|
|
43
45
|
runPay,
|
|
44
46
|
settlementTx
|
|
45
47
|
};
|
|
46
|
-
//# sourceMappingURL=pay-
|
|
48
|
+
//# sourceMappingURL=pay-XOYR4PCH.js.map
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
reconcilePayments
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5NEHH2E5.js";
|
|
5
5
|
import "./chunk-LAIZ2AQA.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-VXIBZ6W5.js";
|
|
7
|
+
import "./chunk-X7I343ZY.js";
|
|
8
8
|
import "./chunk-7QKHZQKW.js";
|
|
9
9
|
import "./chunk-MEFB5KHA.js";
|
|
10
|
+
import "./chunk-B2L53TMK.js";
|
|
10
11
|
import "./chunk-2I4QTOLB.js";
|
|
11
12
|
import {
|
|
12
13
|
resolveContextSettings
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-G4AM2SOL.js";
|
|
14
15
|
import {
|
|
15
16
|
toMoney
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6ZSGER3A.js";
|
|
18
|
+
import "./chunk-VIOUZW7Z.js";
|
|
17
19
|
import "./chunk-JLEF5WHM.js";
|
|
18
20
|
import {
|
|
19
21
|
paidLedgerPath
|
|
@@ -43,4 +45,4 @@ async function runPaymentsReconcile(ctx, deps = {}) {
|
|
|
43
45
|
export {
|
|
44
46
|
runPaymentsReconcile
|
|
45
47
|
};
|
|
46
|
-
//# sourceMappingURL=payments-
|
|
48
|
+
//# sourceMappingURL=payments-UTQDBO7H.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":"
|
|
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-
|
|
13
|
+
} from "./chunk-VNNXAYJE.js";
|
|
14
14
|
import {
|
|
15
15
|
describeWallet,
|
|
16
16
|
resolveWalletProvider
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-O7CUHHYU.js";
|
|
18
|
+
import "./chunk-VXIBZ6W5.js";
|
|
19
|
+
import "./chunk-X7I343ZY.js";
|
|
20
20
|
import "./chunk-AWQPGIR6.js";
|
|
21
21
|
import "./chunk-N35E6CM2.js";
|
|
22
22
|
import "./chunk-JRGFKVAZ.js";
|
|
@@ -29,17 +29,20 @@ import {
|
|
|
29
29
|
import "./chunk-KG3D7FIF.js";
|
|
30
30
|
import "./chunk-RBJPAZFI.js";
|
|
31
31
|
import "./chunk-BPMWXTFX.js";
|
|
32
|
-
import "./chunk-UDWGT4FX.js";
|
|
33
32
|
import "./chunk-MEFB5KHA.js";
|
|
33
|
+
import "./chunk-B2L53TMK.js";
|
|
34
|
+
import "./chunk-5FGO6TYT.js";
|
|
34
35
|
import "./chunk-2I4QTOLB.js";
|
|
35
36
|
import {
|
|
36
37
|
resolveContextSettings
|
|
37
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-G4AM2SOL.js";
|
|
38
39
|
import {
|
|
39
|
-
SEND_MAX_UNSET,
|
|
40
40
|
parseUsdToAtomic,
|
|
41
41
|
toMoney
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-6ZSGER3A.js";
|
|
43
|
+
import {
|
|
44
|
+
SEND_MAX_UNSET
|
|
45
|
+
} from "./chunk-VIOUZW7Z.js";
|
|
43
46
|
import {
|
|
44
47
|
CliError
|
|
45
48
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -219,4 +222,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
|
|
|
219
222
|
export {
|
|
220
223
|
runSend
|
|
221
224
|
};
|
|
222
|
-
//# sourceMappingURL=send-
|
|
225
|
+
//# sourceMappingURL=send-CVGNOQW3.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;AAE9B,eAAsB,QACpB,MACA,KACA,OAAiB,CAAC,GACM;AACxB,cAAY,KAAK,KAAK;AACtB,QAAM,eAAe,OAAO,iBAAiB,KAAK,MAAM,CAAC;AACzD,MAAI,iBAAiB,IAA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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,IAAI,MAAM,uBAAuB,GAAG;AACxE,iBAAe,cAAc,mBAAmB;AAEhD,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,eAAe,KAAK,SAAS,MAAM;AAAA,EACrD,S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AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-VXIBZ6W5.js";
|
|
3
3
|
import {
|
|
4
4
|
readSpendSummary,
|
|
5
5
|
spentOf
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X7I343ZY.js";
|
|
7
7
|
import "./chunk-MEFB5KHA.js";
|
|
8
|
+
import "./chunk-B2L53TMK.js";
|
|
8
9
|
import "./chunk-2I4QTOLB.js";
|
|
9
10
|
import {
|
|
10
11
|
resolveContextSettings
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-G4AM2SOL.js";
|
|
13
|
+
import {
|
|
14
|
+
toMoney
|
|
15
|
+
} from "./chunk-6ZSGER3A.js";
|
|
12
16
|
import {
|
|
13
17
|
RETIRED_PAYMENT_GUIDANCE,
|
|
14
18
|
loadRawConfig,
|
|
15
|
-
retiredPaymentKeys
|
|
16
|
-
|
|
17
|
-
} from "./chunk-XICKN3CH.js";
|
|
19
|
+
retiredPaymentKeys
|
|
20
|
+
} from "./chunk-VIOUZW7Z.js";
|
|
18
21
|
import "./chunk-JLEF5WHM.js";
|
|
19
22
|
import "./chunk-K6AXXYCG.js";
|
|
20
23
|
import "./chunk-ZXTAQYNA.js";
|
|
@@ -66,4 +69,4 @@ async function runRouterStatus(ctx, deps = {}) {
|
|
|
66
69
|
export {
|
|
67
70
|
runRouterStatus
|
|
68
71
|
};
|
|
69
|
-
//# sourceMappingURL=status-
|
|
72
|
+
//# sourceMappingURL=status-NACN4DGX.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":"
|
|
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,CA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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,12 +1,13 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
renderProgress
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AWKQSKUL.js";
|
|
5
5
|
import {
|
|
6
6
|
routerSettings
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-DATCR7AU.js";
|
|
8
|
+
import "./chunk-G4AM2SOL.js";
|
|
9
|
+
import "./chunk-6ZSGER3A.js";
|
|
10
|
+
import "./chunk-VIOUZW7Z.js";
|
|
10
11
|
import "./chunk-JLEF5WHM.js";
|
|
11
12
|
import "./chunk-K6AXXYCG.js";
|
|
12
13
|
import "./chunk-ZXTAQYNA.js";
|
|
@@ -83,4 +84,4 @@ export {
|
|
|
83
84
|
runStatusLine,
|
|
84
85
|
statusLineMain
|
|
85
86
|
};
|
|
86
|
-
//# sourceMappingURL=status-line-
|
|
87
|
+
//# sourceMappingURL=status-line-3IQKGRUH.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":"
|
|
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,QAAiB,KAAK,MAAM,GAAG;AACrC,UAAM,YAAY,YAAY,KAAK;AACnC,QAAI,cAAc,KAAM;AAExB,UAAM,SAAS,MAAM;AAAA,MACnB,EAAE,KAAK,MAAM,KAAK,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,QAAQ;AAAA,MAC5D,EAAE,MAAM,MAAM,OAAU;AAAA,IAC1B;AACA,QAAI,CAAC,OAAO,QAAQ,MAAO;AAC3B,UAAM,UAAU,QAAQ,KAAK,OAAO,QAAQ,KAAK,OAAO;AACxD,eAAW,MAAM,eAAe,KAAK,SAAS,WAAW;AAAA,MACvD,GAAI,OAAO,SAAS,OAAO,KAAK,UAAU,IAAI,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC7D,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,EAAE,IAAI,CAAC;AAAA,I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"./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-DSNXKUXI.js";
|
|
13
|
+
import "./chunk-XVYATBKD.js";
|
|
14
14
|
import "./chunk-AKWGE6JQ.js";
|
|
15
15
|
import "./chunk-TGLKKLQG.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-HC3QEZKT.js";
|
|
17
17
|
import "./chunk-JLEF5WHM.js";
|
|
18
18
|
import "./chunk-K6AXXYCG.js";
|
|
19
19
|
import "./chunk-ZXTAQYNA.js";
|
|
@@ -28,4 +28,4 @@ export {
|
|
|
28
28
|
removeStatusLine,
|
|
29
29
|
statusLineMode
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=status-line-wiring-
|
|
31
|
+
//# sourceMappingURL=status-line-wiring-QXBOOY2T.js.map
|
|
@@ -6,32 +6,38 @@ import {
|
|
|
6
6
|
mcpScope,
|
|
7
7
|
readMcpEntry,
|
|
8
8
|
routerSettingsPath
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-PY7MQUKP.js";
|
|
10
|
+
import "./chunk-64SE3QC5.js";
|
|
11
|
+
import "./chunk-MAQUL5BD.js";
|
|
12
|
+
import {
|
|
13
|
+
removeStatusLine
|
|
14
|
+
} from "./chunk-DSNXKUXI.js";
|
|
15
|
+
import "./chunk-S4SAZ7OD.js";
|
|
16
|
+
import "./chunk-OHZYNZSD.js";
|
|
12
17
|
import {
|
|
13
18
|
onPath,
|
|
14
19
|
persistRouterProject
|
|
15
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-H2L33M7F.js";
|
|
21
|
+
import "./chunk-GU4GGKYP.js";
|
|
16
22
|
import "./chunk-A36LQPHV.js";
|
|
17
|
-
import "./chunk-P7LABKCW.js";
|
|
18
|
-
import "./chunk-MEFB5KHA.js";
|
|
19
|
-
import "./chunk-OZ3LWLCI.js";
|
|
20
|
-
import "./chunk-2I4QTOLB.js";
|
|
21
|
-
import "./chunk-HII5HOQV.js";
|
|
22
|
-
import "./chunk-XICKN3CH.js";
|
|
23
|
-
import {
|
|
24
|
-
removeStatusLine
|
|
25
|
-
} from "./chunk-NTYQHAIM.js";
|
|
26
23
|
import {
|
|
27
24
|
inspectHooksFile,
|
|
28
25
|
pruneHooks
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-XVYATBKD.js";
|
|
30
27
|
import "./chunk-AKWGE6JQ.js";
|
|
31
28
|
import {
|
|
32
29
|
MCP_SERVER_NAME
|
|
33
30
|
} from "./chunk-TGLKKLQG.js";
|
|
34
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-P7LABKCW.js";
|
|
32
|
+
import "./chunk-MEFB5KHA.js";
|
|
33
|
+
import "./chunk-B2L53TMK.js";
|
|
34
|
+
import "./chunk-5FGO6TYT.js";
|
|
35
|
+
import "./chunk-DATCR7AU.js";
|
|
36
|
+
import "./chunk-HC3QEZKT.js";
|
|
37
|
+
import "./chunk-2I4QTOLB.js";
|
|
38
|
+
import "./chunk-G4AM2SOL.js";
|
|
39
|
+
import "./chunk-6ZSGER3A.js";
|
|
40
|
+
import "./chunk-VIOUZW7Z.js";
|
|
35
41
|
import {
|
|
36
42
|
writeFileAtomic
|
|
37
43
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -166,4 +172,4 @@ export {
|
|
|
166
172
|
MCP_REMOVE_COMMAND,
|
|
167
173
|
runRouterUninstall
|
|
168
174
|
};
|
|
169
|
-
//# sourceMappingURL=uninstall-
|
|
175
|
+
//# sourceMappingURL=uninstall-NYFKSYW4.js.map
|
|
@@ -1 +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,QAAM,eAAe,mBAAmB;AAAA,IACtC,GAAI,KAAK,YAAY,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,IACjD,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAED,QAAM,UAAU,MAAM,mBAAmB,cAAc,IAAI,OAAO;AAIlE,QAAM,aAAa,MAAM,iBAAiB,YAAY;AAGtD,MAAI,KAAK,YAAY,MAAM;AACzB,UAAM,qBAAqB,IAAI,SAAS,KAAK,KAA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AS,OAAO;AAC9B,QAAM,UAAU,iBAAiB,OAAO;AAKxC,QAAM,WAAW,OAAO,KAAK,gBAAgB,cAAc,OAAO,KAAK,IAAI;AAC3E,MAAI,SAAS,UAAU,iBAAiB;AACtC,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,QAAQ,uBAAuB,eAAe,OAAO,KAAK;AAAA,IAC5D;AAAA,EACF;AACA,MAAI,SAAS,UAAU,cAAc;AACnC,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,QAAQ,OAAO,KAAK;AAAA,IACtB;AAAA,EACF;AACA,QAAM,QAAQ,KAAK,UAAU,CAAC,QAAgB,OAAO,KAAK,GAAG;AAC7D,MAAI,CAAC,MAAM,QAAQ,GAAG;AACpB,WAAO,EAAE,SAAS,OAAO,OAAO,SAAS,QAAQ,qCAAqC;AAAA,EACxF;AACA,MAAI;AACF,WAAO,KAAK,aAAa,oBAAoB,EAAE,OAAO,IAAI,CAAC;AAC3D,WAAO,EAAE,SAAS,MAAM,OAAO,QAAQ;AAAA,EACzC,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,QAAQ,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,IACzD;AAAA,EACF;AACF;AAEA,eAAe,mBAAmB,MAAiE;AACjG,QAAM,KAAK,UAAU,CAAC,OAAO,UAAU,iBAAiB,MAAM,KAAK,KAAK,GAAG;AAAA,IACzE,SAAS;AAAA,IACT,KAAK,KAAK;AAAA,EACZ,CAAC;AACH;","names":[]}
|
|
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,QAAM,eAAe,mBAAmB;AAAA,IACtC,GAAI,KAAK,YAAY,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,IACjD,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAED,QAAM,UAAU,MAAM,mBAAmB,cAAc,IAAI,OAAO;AAIlE,QAAM,aAAa,MAAM,iBAAiB,YAAY;AAGtD,MAAI,KAAK,YAAY,MAAM;AACzB,UAAM,qBAAqB,IA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|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-VYONGSMQ.js";
|
|
10
|
+
RECONNECT_FIX,
|
|
11
|
+
readMcpServers
|
|
12
|
+
} from "./chunk-MAQUL5BD.js";
|
|
14
13
|
import {
|
|
15
14
|
emitWriteNotice,
|
|
16
15
|
sanitizeForTerminal
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-2I4QTOLB.js";
|
|
19
|
-
import "./chunk-XICKN3CH.js";
|
|
16
|
+
} from "./chunk-5FGO6TYT.js";
|
|
20
17
|
import {
|
|
21
18
|
package_default
|
|
22
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HC3QEZKT.js";
|
|
20
|
+
import "./chunk-VIOUZW7Z.js";
|
|
23
21
|
import {
|
|
24
22
|
CliError
|
|
25
23
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -293,16 +291,16 @@ async function runUpdate(opts, ctx, deps = {}) {
|
|
|
293
291
|
`tenjin update: replaced the global tenjin-cli with ${latest} via ${manager}`
|
|
294
292
|
);
|
|
295
293
|
const refresh = await refreshProfiles(ctx, deps);
|
|
294
|
+
const servers = await readMcpServers(deps);
|
|
296
295
|
return {
|
|
297
|
-
data: { ...data(true), refresh },
|
|
296
|
+
data: { ...data(true), refresh, mcpServer: servers.check },
|
|
298
297
|
humanLines: [
|
|
299
298
|
`Updated tenjin-cli ${current} -> ${latest}.`,
|
|
300
299
|
...refreshLines(refresh),
|
|
301
|
-
|
|
300
|
+
...servers.stale > 0 ? [`! ${servers.check.detail}. ${RECONNECT_FIX}`] : []
|
|
302
301
|
]
|
|
303
302
|
};
|
|
304
303
|
}
|
|
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\`).`;
|
|
306
304
|
var REFRESH_TIMEOUT_MS = 6e4;
|
|
307
305
|
async function refreshProfiles(ctx, deps) {
|
|
308
306
|
const home = deps.homeDir ?? homedir();
|
|
@@ -441,4 +439,4 @@ export {
|
|
|
441
439
|
spawnCapture,
|
|
442
440
|
versionFreeEntry
|
|
443
441
|
};
|
|
444
|
-
//# sourceMappingURL=update-
|
|
442
|
+
//# sourceMappingURL=update-RJDA5ZY3.js.map
|