tenjin-cli 0.1.0-alpha.27 → 0.1.0-alpha.29
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 +18 -26
- package/dist/alive-3J3CHOQP.js +21 -0
- package/dist/{chunk-XVYATBKD.js → chunk-25GGN553.js} +897 -522
- package/dist/chunk-25GGN553.js.map +1 -0
- package/dist/{chunk-B2L53TMK.js → chunk-2SNUOHAT.js} +28 -23
- package/dist/chunk-2SNUOHAT.js.map +1 -0
- package/dist/{chunk-5NEHH2E5.js → chunk-3FY5HG7R.js} +86 -19
- package/dist/chunk-3FY5HG7R.js.map +1 -0
- package/dist/{chunk-YQOQ6XEI.js → chunk-4FYMDRD3.js} +51 -41
- package/dist/chunk-4FYMDRD3.js.map +1 -0
- package/dist/chunk-6W5GYG3W.js +128 -0
- package/dist/chunk-6W5GYG3W.js.map +1 -0
- package/dist/{chunk-G4AM2SOL.js → chunk-AMEUXNJT.js} +4 -8
- package/dist/{chunk-G4AM2SOL.js.map → chunk-AMEUXNJT.js.map} +1 -1
- package/dist/chunk-EWLU46J6.js +100 -0
- package/dist/chunk-EWLU46J6.js.map +1 -0
- package/dist/chunk-LRCJ2IZ5.js +115 -0
- package/dist/{chunk-HC3QEZKT.js.map → chunk-LRCJ2IZ5.js.map} +1 -1
- package/dist/{chunk-X7I343ZY.js → chunk-LX5OT4TQ.js} +3 -3
- package/dist/{chunk-X7I343ZY.js.map → chunk-LX5OT4TQ.js.map} +1 -1
- package/dist/{chunk-DATCR7AU.js → chunk-MG3G644T.js} +5 -7
- package/dist/{chunk-DATCR7AU.js.map → chunk-MG3G644T.js.map} +1 -1
- package/dist/{chunk-BOAI23CX.js → chunk-MOG7PB3A.js} +21 -15
- package/dist/chunk-MOG7PB3A.js.map +1 -0
- package/dist/{chunk-GU4GGKYP.js → chunk-MRUPDSUM.js} +14 -59
- package/dist/chunk-MRUPDSUM.js.map +1 -0
- package/dist/{chunk-AWKQSKUL.js → chunk-OOSRB3OF.js} +2 -2
- package/dist/{chunk-PZ5N6BAL.js → chunk-ORWL5BSN.js} +5 -4
- package/dist/chunk-ORWL5BSN.js.map +1 -0
- package/dist/chunk-P4LVLFO4.js +29 -0
- package/dist/chunk-P4LVLFO4.js.map +1 -0
- package/dist/{chunk-VXIBZ6W5.js → chunk-QTGUDCIR.js} +5 -5
- package/dist/{chunk-YKM2ZTA2.js → chunk-R4AO7GC2.js} +462 -105
- package/dist/chunk-R4AO7GC2.js.map +1 -0
- package/dist/{chunk-OHZYNZSD.js → chunk-RJEPZMYY.js} +12 -8
- package/dist/chunk-RJEPZMYY.js.map +1 -0
- package/dist/chunk-SBL4THYT.js +2074 -0
- package/dist/chunk-SBL4THYT.js.map +1 -0
- package/dist/{chunk-VNNXAYJE.js → chunk-SFEQGENI.js} +2 -2
- package/dist/{chunk-K6AXXYCG.js → chunk-SJLTEINJ.js} +10 -2
- package/dist/{chunk-K6AXXYCG.js.map → chunk-SJLTEINJ.js.map} +1 -1
- package/dist/{chunk-5FGO6TYT.js → chunk-TROZ6HL4.js} +3 -5
- package/dist/{chunk-5FGO6TYT.js.map → chunk-TROZ6HL4.js.map} +1 -1
- package/dist/{chunk-SKQQOEWH.js → chunk-USOLCBKC.js} +6 -8
- package/dist/{chunk-SKQQOEWH.js.map → chunk-USOLCBKC.js.map} +1 -1
- package/dist/{chunk-64SE3QC5.js → chunk-VKQXVCZR.js} +54 -5
- package/dist/chunk-VKQXVCZR.js.map +1 -0
- package/dist/{chunk-VIOUZW7Z.js → chunk-VVAHFCX2.js} +209 -37
- package/dist/chunk-VVAHFCX2.js.map +1 -0
- package/dist/{chunk-4L7KMA7P.js → chunk-WM7TJEBP.js} +8 -10
- package/dist/{chunk-4L7KMA7P.js.map → chunk-WM7TJEBP.js.map} +1 -1
- package/dist/{chunk-2TYQD22Q.js → chunk-XDYKZRLN.js} +23 -16
- package/dist/chunk-XDYKZRLN.js.map +1 -0
- package/dist/{chunk-LAIZ2AQA.js → chunk-XJQ6CH7X.js} +3 -2
- package/dist/{chunk-O7CUHHYU.js → chunk-ZQNGTLOC.js} +8 -10
- package/dist/{chunk-O7CUHHYU.js.map → chunk-ZQNGTLOC.js.map} +1 -1
- package/dist/{cli-6JNIPZQ6.js → cli-JPTDHGRX.js} +58 -52
- package/dist/{cli-6JNIPZQ6.js.map → cli-JPTDHGRX.js.map} +1 -1
- package/dist/{config-G75YT6NC.js → config-YYKDH2TH.js} +12 -15
- package/dist/{doctor-3GMDOW4Y.js → doctor-SSTXGCHX.js} +298 -269
- package/dist/doctor-SSTXGCHX.js.map +1 -0
- package/dist/{fund-3IPR5YRJ.js → fund-QWVWRVDK.js} +95 -43
- package/dist/{fund-3IPR5YRJ.js.map → fund-QWVWRVDK.js.map} +1 -1
- package/dist/hook-command-VWJXRT7H.js +31 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
- package/dist/hosts/claude/tenjin/.mcp.json +12 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +221 -0
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/install-2GXXD4DK.js +51 -0
- package/dist/{install-identity-PM4AGFFX.js → install-identity-FK3YF227.js} +7 -9
- package/dist/{install-wallet-6756NOB5.js → install-wallet-TC22U52X.js} +21 -17
- package/dist/{install-wallet-6756NOB5.js.map → install-wallet-TC22U52X.js.map} +1 -1
- package/dist/{mcp-33FAAZ7F.js → mcp-42H2F4NY.js} +2128 -372
- package/dist/mcp-42H2F4NY.js.map +1 -0
- package/dist/package-6DJA3Y2O.js +37 -0
- package/dist/{paths-MUXHUOCM.js → paths-POPTXJO6.js} +6 -2
- package/dist/{pay-XOYR4PCH.js → pay-LSDJBIAZ.js} +20 -18
- package/dist/payments-SPECLBRQ.js +105 -0
- package/dist/payments-SPECLBRQ.js.map +1 -0
- package/dist/{send-CVGNOQW3.js → send-MHAOLPK3.js} +13 -17
- package/dist/{send-CVGNOQW3.js.map → send-MHAOLPK3.js.map} +1 -1
- package/dist/status-O2RWLPS5.js +114 -0
- package/dist/status-O2RWLPS5.js.map +1 -0
- package/dist/{status-line-3IQKGRUH.js → status-line-45TVCRM3.js} +7 -9
- package/dist/{status-line-3IQKGRUH.js.map → status-line-45TVCRM3.js.map} +1 -1
- package/dist/uninstall-VOK2Z5M4.js +146 -0
- package/dist/uninstall-VOK2Z5M4.js.map +1 -0
- package/dist/update-FGP3HNLD.js +33 -0
- package/dist/update-FGP3HNLD.js.map +1 -0
- package/dist/{wallet-B3FVHNTS.js → wallet-DA7OFNEW.js} +18 -14
- package/dist/wallet-DA7OFNEW.js.map +1 -0
- package/docs/agent-permissions.md +35 -22
- package/docs/safety-model.md +3 -1
- package/package.json +2 -2
- package/dist/chunk-2TYQD22Q.js.map +0 -1
- package/dist/chunk-5NEHH2E5.js.map +0 -1
- package/dist/chunk-64SE3QC5.js.map +0 -1
- package/dist/chunk-6ZSGER3A.js +0 -52
- package/dist/chunk-6ZSGER3A.js.map +0 -1
- package/dist/chunk-B2L53TMK.js.map +0 -1
- package/dist/chunk-BOAI23CX.js.map +0 -1
- package/dist/chunk-DSNXKUXI.js +0 -172
- package/dist/chunk-DSNXKUXI.js.map +0 -1
- package/dist/chunk-GU4GGKYP.js.map +0 -1
- package/dist/chunk-H2L33M7F.js +0 -944
- package/dist/chunk-H2L33M7F.js.map +0 -1
- package/dist/chunk-HC3QEZKT.js +0 -87
- package/dist/chunk-JLEF5WHM.js +0 -132
- package/dist/chunk-JLEF5WHM.js.map +0 -1
- package/dist/chunk-MAQUL5BD.js +0 -99
- package/dist/chunk-MAQUL5BD.js.map +0 -1
- package/dist/chunk-OHZYNZSD.js.map +0 -1
- package/dist/chunk-PY7MQUKP.js +0 -755
- package/dist/chunk-PY7MQUKP.js.map +0 -1
- package/dist/chunk-PZ5N6BAL.js.map +0 -1
- package/dist/chunk-TGLKKLQG.js +0 -11
- package/dist/chunk-TGLKKLQG.js.map +0 -1
- package/dist/chunk-VIOUZW7Z.js.map +0 -1
- package/dist/chunk-XVYATBKD.js.map +0 -1
- package/dist/chunk-YKM2ZTA2.js.map +0 -1
- package/dist/chunk-YQOQ6XEI.js.map +0 -1
- package/dist/doctor-3GMDOW4Y.js.map +0 -1
- package/dist/hook-command-ZXX4FT4N.js +0 -32
- package/dist/install-6OROTYHZ.js +0 -72
- package/dist/mcp-33FAAZ7F.js.map +0 -1
- package/dist/payments-UTQDBO7H.js +0 -48
- package/dist/payments-UTQDBO7H.js.map +0 -1
- package/dist/status-NACN4DGX.js +0 -72
- package/dist/status-NACN4DGX.js.map +0 -1
- package/dist/status-line-wiring-QXBOOY2T.js +0 -31
- package/dist/uninstall-NYFKSYW4.js +0 -175
- package/dist/uninstall-NYFKSYW4.js.map +0 -1
- package/dist/update-RJDA5ZY3.js +0 -442
- package/dist/update-RJDA5ZY3.js.map +0 -1
- /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
- /package/dist/{chunk-AWKQSKUL.js.map → chunk-OOSRB3OF.js.map} +0 -0
- /package/dist/{chunk-VXIBZ6W5.js.map → chunk-QTGUDCIR.js.map} +0 -0
- /package/dist/{chunk-VNNXAYJE.js.map → chunk-SFEQGENI.js.map} +0 -0
- /package/dist/{chunk-LAIZ2AQA.js.map → chunk-XJQ6CH7X.js.map} +0 -0
- /package/dist/{hook-command-ZXX4FT4N.js.map → config-YYKDH2TH.js.map} +0 -0
- /package/dist/{install-6OROTYHZ.js.map → hook-command-VWJXRT7H.js.map} +0 -0
- /package/dist/{install-identity-PM4AGFFX.js.map → install-2GXXD4DK.js.map} +0 -0
- /package/dist/{paths-MUXHUOCM.js.map → install-identity-FK3YF227.js.map} +0 -0
- /package/dist/{pay-XOYR4PCH.js.map → package-6DJA3Y2O.js.map} +0 -0
- /package/dist/{status-line-wiring-QXBOOY2T.js.map → paths-POPTXJO6.js.map} +0 -0
- /package/dist/{wallet-B3FVHNTS.js.map → pay-LSDJBIAZ.js.map} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
reconcilePayments
|
|
4
|
-
} from "./chunk-5NEHH2E5.js";
|
|
5
|
-
import "./chunk-LAIZ2AQA.js";
|
|
6
|
-
import "./chunk-VXIBZ6W5.js";
|
|
7
|
-
import "./chunk-X7I343ZY.js";
|
|
8
|
-
import "./chunk-7QKHZQKW.js";
|
|
9
|
-
import "./chunk-MEFB5KHA.js";
|
|
10
|
-
import "./chunk-B2L53TMK.js";
|
|
11
|
-
import "./chunk-2I4QTOLB.js";
|
|
12
|
-
import {
|
|
13
|
-
resolveContextSettings
|
|
14
|
-
} from "./chunk-G4AM2SOL.js";
|
|
15
|
-
import {
|
|
16
|
-
toMoney
|
|
17
|
-
} from "./chunk-6ZSGER3A.js";
|
|
18
|
-
import "./chunk-VIOUZW7Z.js";
|
|
19
|
-
import "./chunk-JLEF5WHM.js";
|
|
20
|
-
import {
|
|
21
|
-
paidLedgerPath
|
|
22
|
-
} from "./chunk-K6AXXYCG.js";
|
|
23
|
-
import "./chunk-ZXTAQYNA.js";
|
|
24
|
-
|
|
25
|
-
// src/router/payments.ts
|
|
26
|
-
var MAX_COMMAND_CHECKS = 50;
|
|
27
|
-
async function runPaymentsReconcile(ctx, deps = {}) {
|
|
28
|
-
const settings = await resolveContextSettings(ctx);
|
|
29
|
-
const outcome = await reconcilePayments(ctx.dataDir, {
|
|
30
|
-
rpcUrl: settings.rpcUrl,
|
|
31
|
-
max: MAX_COMMAND_CHECKS,
|
|
32
|
-
// Asked for by hand: every due record, however recently it was asked about.
|
|
33
|
-
recheckMs: 0,
|
|
34
|
-
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {},
|
|
35
|
-
...deps.now !== void 0 ? { now: deps.now } : {}
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },
|
|
39
|
-
humanLines: [
|
|
40
|
-
outcome.checked === 0 ? "No paid lookup is waiting on its settlement." : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` + (outcome.releasedAtomic !== "0" ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.` : ""),
|
|
41
|
-
...outcome.unknown > 0 ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`] : []
|
|
42
|
-
]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
runPaymentsReconcile
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=payments-UTQDBO7H.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
package/dist/status-NACN4DGX.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import "./chunk-VXIBZ6W5.js";
|
|
3
|
-
import {
|
|
4
|
-
readSpendSummary,
|
|
5
|
-
spentOf
|
|
6
|
-
} from "./chunk-X7I343ZY.js";
|
|
7
|
-
import "./chunk-MEFB5KHA.js";
|
|
8
|
-
import "./chunk-B2L53TMK.js";
|
|
9
|
-
import "./chunk-2I4QTOLB.js";
|
|
10
|
-
import {
|
|
11
|
-
resolveContextSettings
|
|
12
|
-
} from "./chunk-G4AM2SOL.js";
|
|
13
|
-
import {
|
|
14
|
-
toMoney
|
|
15
|
-
} from "./chunk-6ZSGER3A.js";
|
|
16
|
-
import {
|
|
17
|
-
RETIRED_PAYMENT_GUIDANCE,
|
|
18
|
-
loadRawConfig,
|
|
19
|
-
retiredPaymentKeys
|
|
20
|
-
} from "./chunk-VIOUZW7Z.js";
|
|
21
|
-
import "./chunk-JLEF5WHM.js";
|
|
22
|
-
import "./chunk-K6AXXYCG.js";
|
|
23
|
-
import "./chunk-ZXTAQYNA.js";
|
|
24
|
-
|
|
25
|
-
// src/router/status.ts
|
|
26
|
-
async function runRouterStatus(ctx, deps = {}) {
|
|
27
|
-
const now = deps.now ?? Date.now;
|
|
28
|
-
const settings = await resolveContextSettings(ctx);
|
|
29
|
-
const ledger = await readSpendSummary(ctx.dataDir, { now });
|
|
30
|
-
const committedAtomic = BigInt(ledger?.committedAtomic ?? "0");
|
|
31
|
-
const reservedAtomic = (ledger?.reservations ?? []).reduce(
|
|
32
|
-
(sum, r) => sum + BigInt(r.amountAtomic),
|
|
33
|
-
0n
|
|
34
|
-
);
|
|
35
|
-
const retired = retiredPaymentKeys(await loadRawConfig(ctx.dataDir));
|
|
36
|
-
const warnings = retired.length ? [`Ignored retired keys: ${retired.join(", ")}. ${RETIRED_PAYMENT_GUIDANCE}`] : [];
|
|
37
|
-
const automaticAtomic = ledger === null ? 0n : spentOf(ledger);
|
|
38
|
-
const budgetAtomic = settings.policy.sessionBudgetAtomic;
|
|
39
|
-
const data = {
|
|
40
|
-
baseUrl: settings.baseUrl,
|
|
41
|
-
warnings,
|
|
42
|
-
window: {
|
|
43
|
-
startedAtMs: ledger?.windowStartMs ?? null,
|
|
44
|
-
committed: toMoney(committedAtomic.toString()),
|
|
45
|
-
automaticExposure: toMoney(automaticAtomic.toString()),
|
|
46
|
-
reserved: toMoney(reservedAtomic.toString()),
|
|
47
|
-
budget: budgetAtomic === null ? null : toMoney(budgetAtomic.toString())
|
|
48
|
-
},
|
|
49
|
-
caps: {
|
|
50
|
-
maxAutoSpend: toMoney(settings.policy.maxAutoSpendAtomic.toString())
|
|
51
|
-
},
|
|
52
|
-
inFlight: (ledger?.reservations ?? []).map((r) => ({
|
|
53
|
-
amount: toMoney(r.amountAtomic),
|
|
54
|
-
ageSeconds: Math.max(0, Math.round((now() - r.atMs) / 1e3)),
|
|
55
|
-
...r.requestKey !== void 0 ? { request: r.requestKey } : {}
|
|
56
|
-
}))
|
|
57
|
-
};
|
|
58
|
-
const budgetLine = budgetAtomic === null ? "no daily limit" : `of ${toMoney(budgetAtomic.toString()).usd} USD in the rolling 24h window`;
|
|
59
|
-
return {
|
|
60
|
-
data,
|
|
61
|
-
humanLines: [
|
|
62
|
-
`spent ${toMoney(committedAtomic.toString()).usd} USD total; automatic exposure ${toMoney(automaticAtomic.toString()).usd} USD ${budgetLine}`,
|
|
63
|
-
`reserved ${toMoney(reservedAtomic.toString()).usd} USD in ${data.inFlight.length} open request(s)`,
|
|
64
|
-
`automatic router up to ${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd} USD per call; manual pay always requires consent`,
|
|
65
|
-
...warnings
|
|
66
|
-
]
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
runRouterStatus
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=status-NACN4DGX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,31 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
STATUS_LINE_COMMAND,
|
|
4
|
-
STATUS_LINE_REFRESH_SECONDS,
|
|
5
|
-
classifyStatusLine,
|
|
6
|
-
composeCommand,
|
|
7
|
-
decomposeCommand,
|
|
8
|
-
ensureStatusLine,
|
|
9
|
-
inspectStatusLine,
|
|
10
|
-
removeStatusLine,
|
|
11
|
-
statusLineMode
|
|
12
|
-
} from "./chunk-DSNXKUXI.js";
|
|
13
|
-
import "./chunk-XVYATBKD.js";
|
|
14
|
-
import "./chunk-AKWGE6JQ.js";
|
|
15
|
-
import "./chunk-TGLKKLQG.js";
|
|
16
|
-
import "./chunk-HC3QEZKT.js";
|
|
17
|
-
import "./chunk-JLEF5WHM.js";
|
|
18
|
-
import "./chunk-K6AXXYCG.js";
|
|
19
|
-
import "./chunk-ZXTAQYNA.js";
|
|
20
|
-
export {
|
|
21
|
-
STATUS_LINE_COMMAND,
|
|
22
|
-
STATUS_LINE_REFRESH_SECONDS,
|
|
23
|
-
classifyStatusLine,
|
|
24
|
-
composeCommand,
|
|
25
|
-
decomposeCommand,
|
|
26
|
-
ensureStatusLine,
|
|
27
|
-
inspectStatusLine,
|
|
28
|
-
removeStatusLine,
|
|
29
|
-
statusLineMode
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=status-line-wiring-QXBOOY2T.js.map
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ALLOW_RULE,
|
|
4
|
-
DENY_RULE,
|
|
5
|
-
mcpRemoveCommand,
|
|
6
|
-
mcpScope,
|
|
7
|
-
readMcpEntry,
|
|
8
|
-
routerSettingsPath
|
|
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";
|
|
17
|
-
import {
|
|
18
|
-
onPath,
|
|
19
|
-
persistRouterProject
|
|
20
|
-
} from "./chunk-H2L33M7F.js";
|
|
21
|
-
import "./chunk-GU4GGKYP.js";
|
|
22
|
-
import "./chunk-A36LQPHV.js";
|
|
23
|
-
import {
|
|
24
|
-
inspectHooksFile,
|
|
25
|
-
pruneHooks
|
|
26
|
-
} from "./chunk-XVYATBKD.js";
|
|
27
|
-
import "./chunk-AKWGE6JQ.js";
|
|
28
|
-
import {
|
|
29
|
-
MCP_SERVER_NAME
|
|
30
|
-
} from "./chunk-TGLKKLQG.js";
|
|
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";
|
|
41
|
-
import {
|
|
42
|
-
writeFileAtomic
|
|
43
|
-
} from "./chunk-JLEF5WHM.js";
|
|
44
|
-
import "./chunk-K6AXXYCG.js";
|
|
45
|
-
import "./chunk-ZXTAQYNA.js";
|
|
46
|
-
|
|
47
|
-
// src/router/uninstall.ts
|
|
48
|
-
import { execFile } from "node:child_process";
|
|
49
|
-
import { homedir } from "node:os";
|
|
50
|
-
import { readFile, stat } from "node:fs/promises";
|
|
51
|
-
import { isAbsolute } from "node:path";
|
|
52
|
-
import { promisify } from "node:util";
|
|
53
|
-
var exec = promisify(execFile);
|
|
54
|
-
var MCP_REMOVE_COMMAND = mcpRemoveCommand();
|
|
55
|
-
async function runRouterUninstall(args, ctx, deps = {}) {
|
|
56
|
-
const env = deps.env ?? process.env;
|
|
57
|
-
const home = deps.homeDir ?? homedir();
|
|
58
|
-
if (!isAbsolute(home)) throw new Error("The home directory is not an absolute path.");
|
|
59
|
-
const cwd = deps.cwd ?? process.cwd();
|
|
60
|
-
const settingsPath = routerSettingsPath({
|
|
61
|
-
...args.project === true ? { project: true } : {},
|
|
62
|
-
homeDir: home,
|
|
63
|
-
cwd
|
|
64
|
-
});
|
|
65
|
-
const removed = await removeFromSettings(settingsPath, ctx.dataDir);
|
|
66
|
-
const statusLine = await removeStatusLine(settingsPath);
|
|
67
|
-
if (args.project === true) {
|
|
68
|
-
await persistRouterProject(ctx.dataDir, cwd, false).catch(() => void 0);
|
|
69
|
-
}
|
|
70
|
-
const mcp = await removeMcpServer(deps, env, args.project === true, cwd, home);
|
|
71
|
-
const data = {
|
|
72
|
-
settingsPath,
|
|
73
|
-
...removed,
|
|
74
|
-
statusLine,
|
|
75
|
-
mcp,
|
|
76
|
-
kept: ["wallet.json", "spend.json", "config.json"]
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
data,
|
|
80
|
-
humanLines: [
|
|
81
|
-
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})`,
|
|
82
|
-
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",
|
|
83
|
-
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}`,
|
|
84
|
-
"Your wallet, spend ledger and config are kept."
|
|
85
|
-
]
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async function removeFromSettings(path, dataDir) {
|
|
89
|
-
const nothing = { events: [], ruleRemoved: false, denyRuleRemoved: false, wrote: false };
|
|
90
|
-
const found = await inspectHooksFile(path);
|
|
91
|
-
if ("refusal" in found) return { ...nothing, warning: found.refusal.reason };
|
|
92
|
-
const { raw, settings, hooks } = found;
|
|
93
|
-
if (raw === null) return nothing;
|
|
94
|
-
const pruned = pruneHooks(hooks, dataDir);
|
|
95
|
-
const permissions = settings.permissions !== null && typeof settings.permissions === "object" && !Array.isArray(settings.permissions) ? settings.permissions : void 0;
|
|
96
|
-
const allow = Array.isArray(permissions?.allow) ? permissions.allow : void 0;
|
|
97
|
-
const deny = Array.isArray(permissions?.deny) ? permissions.deny : void 0;
|
|
98
|
-
const ruleRemoved = allow?.includes(ALLOW_RULE) === true;
|
|
99
|
-
const denyRuleRemoved = deny?.includes(DENY_RULE) === true;
|
|
100
|
-
const next = {
|
|
101
|
-
...settings,
|
|
102
|
-
hooks: pruned.next,
|
|
103
|
-
...permissions !== void 0 ? {
|
|
104
|
-
permissions: {
|
|
105
|
-
...permissions,
|
|
106
|
-
...allow !== void 0 ? { allow: allow.filter((r) => r !== ALLOW_RULE) } : {},
|
|
107
|
-
...deny !== void 0 ? { deny: deny.filter((r) => r !== DENY_RULE) } : {}
|
|
108
|
-
}
|
|
109
|
-
} : {}
|
|
110
|
-
};
|
|
111
|
-
const body = `${JSON.stringify(next, null, 2)}
|
|
112
|
-
`;
|
|
113
|
-
if (body === raw) {
|
|
114
|
-
return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: false };
|
|
115
|
-
}
|
|
116
|
-
const mode = await stat(found.path).then((s) => ({ mode: s.mode & 511 })).catch(() => ({}));
|
|
117
|
-
if (await readFile(found.path, "utf8").catch(() => null) !== raw) {
|
|
118
|
-
return { ...nothing, warning: "changed-since-read" };
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
await writeFileAtomic(found.path, body, mode);
|
|
122
|
-
} catch (err) {
|
|
123
|
-
return { ...nothing, warning: err instanceof Error ? err.message : String(err) };
|
|
124
|
-
}
|
|
125
|
-
return { events: pruned.removed, ruleRemoved, denyRuleRemoved, wrote: true };
|
|
126
|
-
}
|
|
127
|
-
async function removeMcpServer(deps, env, project, cwd, home) {
|
|
128
|
-
const scope = mcpScope(project);
|
|
129
|
-
const command = mcpRemoveCommand(project);
|
|
130
|
-
const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);
|
|
131
|
-
if (existing.state === "wrong-command") {
|
|
132
|
-
return {
|
|
133
|
-
removed: false,
|
|
134
|
-
scope,
|
|
135
|
-
command,
|
|
136
|
-
kept: "foreign",
|
|
137
|
-
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`
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
if (existing.state === "unreadable") {
|
|
141
|
-
return {
|
|
142
|
-
removed: false,
|
|
143
|
-
scope,
|
|
144
|
-
command,
|
|
145
|
-
kept: "unreadable",
|
|
146
|
-
reason: `the ${scope}-scope registration file could not be read, so nothing was removed from it`
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const which = deps.which ?? ((bin) => onPath(bin, env));
|
|
150
|
-
if (!which("claude")) {
|
|
151
|
-
return { removed: false, scope, command, reason: "the `claude` binary is not on PATH" };
|
|
152
|
-
}
|
|
153
|
-
try {
|
|
154
|
-
await (deps.removeMcp ?? runClaudeMcpRemove)({ scope, cwd });
|
|
155
|
-
return { removed: true, scope, command };
|
|
156
|
-
} catch (err) {
|
|
157
|
-
return {
|
|
158
|
-
removed: false,
|
|
159
|
-
scope,
|
|
160
|
-
command,
|
|
161
|
-
reason: err instanceof Error ? err.message : String(err)
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function runClaudeMcpRemove(opts) {
|
|
166
|
-
await exec("claude", ["mcp", "remove", MCP_SERVER_NAME, "-s", opts.scope], {
|
|
167
|
-
timeout: 2e4,
|
|
168
|
-
cwd: opts.cwd
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
export {
|
|
172
|
-
MCP_REMOVE_COMMAND,
|
|
173
|
-
runRouterUninstall
|
|
174
|
-
};
|
|
175
|
-
//# sourceMappingURL=uninstall-NYFKSYW4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,YAA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