tenjin-cli 0.1.0-alpha.20 → 0.1.0-alpha.22
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 -3
- package/dist/{chunk-LI44XLMB.js → chunk-2RMXTNLT.js} +5 -5
- package/dist/{chunk-5FYKPQNX.js → chunk-3Q3UBMVB.js} +3 -3
- package/dist/{chunk-3BS55ANY.js → chunk-AG4DWNHO.js} +50 -4
- package/dist/{chunk-3BS55ANY.js.map → chunk-AG4DWNHO.js.map} +1 -1
- package/dist/{chunk-P42QX3QF.js → chunk-B4GA3HAK.js} +2 -2
- package/dist/{chunk-P42QX3QF.js.map → chunk-B4GA3HAK.js.map} +1 -1
- package/dist/{chunk-NSG5TVZQ.js → chunk-CYEUVU3F.js} +14 -10
- package/dist/chunk-CYEUVU3F.js.map +1 -0
- package/dist/{chunk-RPR2C2JO.js → chunk-DA53QKTD.js} +5 -5
- package/dist/{chunk-YEBNE5NW.js → chunk-DHCOGDJB.js} +5 -5
- package/dist/{chunk-BTX2QE2Y.js → chunk-F4IJQBGP.js} +4 -4
- package/dist/chunk-GONDQ27X.js +337 -0
- package/dist/chunk-GONDQ27X.js.map +1 -0
- package/dist/{chunk-TU7XH3JJ.js → chunk-K6AXXYCG.js} +14 -2
- package/dist/chunk-K6AXXYCG.js.map +1 -0
- package/dist/{chunk-2G2WLVHB.js → chunk-LAIZ2AQA.js} +9 -4
- package/dist/chunk-LAIZ2AQA.js.map +1 -0
- package/dist/{chunk-YREKMJPP.js → chunk-NYJCBQL5.js} +65 -6
- package/dist/chunk-NYJCBQL5.js.map +1 -0
- package/dist/{chunk-HH3PDYIG.js → chunk-NZYVSZNF.js} +5 -5
- package/dist/{chunk-4M5FBWT5.js → chunk-QF4SSCQV.js} +10 -1
- package/dist/chunk-QF4SSCQV.js.map +1 -0
- package/dist/{chunk-CCDOV45D.js → chunk-SAN5PFTL.js} +126 -12
- package/dist/chunk-SAN5PFTL.js.map +1 -0
- package/dist/{chunk-LN2HISWU.js → chunk-TU3IK7KK.js} +2 -2
- package/dist/{chunk-4AS52HUG.js → chunk-U5FFVIIF.js} +138 -28
- package/dist/chunk-U5FFVIIF.js.map +1 -0
- package/dist/{chunk-PO4HAXAW.js → chunk-UAT3Q7VF.js} +112 -26
- package/dist/chunk-UAT3Q7VF.js.map +1 -0
- package/dist/chunk-UFCN7NCE.js +130 -0
- package/dist/chunk-UFCN7NCE.js.map +1 -0
- package/dist/{chunk-72UHZRG6.js → chunk-UGLTSPXQ.js} +2 -2
- package/dist/{chunk-5KD5HRAJ.js → chunk-UHEMZEGW.js} +3 -2
- package/dist/chunk-UHEMZEGW.js.map +1 -0
- package/dist/{chunk-2E6GVIRP.js → chunk-UIOZRILX.js} +47 -9
- package/dist/chunk-UIOZRILX.js.map +1 -0
- package/dist/{chunk-7ACHDNJA.js → chunk-WXFVJPZD.js} +13 -4
- package/dist/chunk-WXFVJPZD.js.map +1 -0
- package/dist/{chunk-CXUYCDPX.js → chunk-XBYTP4SP.js} +4 -4
- package/dist/{cli-XJQYUOHI.js → cli-5WM56Y7K.js} +43 -30
- package/dist/{cli-XJQYUOHI.js.map → cli-5WM56Y7K.js.map} +1 -1
- package/dist/{config-KMJLFPSI.js → config-JBF5BZNO.js} +10 -8
- package/dist/{doctor-KMN55D7U.js → doctor-6KHBE77P.js} +25 -16
- package/dist/{doctor-KMN55D7U.js.map → doctor-6KHBE77P.js.map} +1 -1
- package/dist/{fund-LT6ZPGEQ.js → fund-GSFCXEF7.js} +10 -11
- package/dist/{fund-LT6ZPGEQ.js.map → fund-GSFCXEF7.js.map} +1 -1
- package/dist/{hook-command-U5XPEHAJ.js → hook-command-UQZ4DVDL.js} +373 -82
- package/dist/hook-command-UQZ4DVDL.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/{install-MMNXJ5LM.js → install-TDYC22KI.js} +13 -11
- package/dist/{install-identity-B7FVIWML.js → install-identity-QS4UFF27.js} +7 -7
- package/dist/{install-wallet-XMVUBCHS.js → install-wallet-T737X74E.js} +9 -10
- package/dist/{install-wallet-XMVUBCHS.js.map → install-wallet-T737X74E.js.map} +1 -1
- package/dist/{mcp-TUPRIPSI.js → mcp-JWOOSKLX.js} +624 -69
- package/dist/mcp-JWOOSKLX.js.map +1 -0
- package/dist/{paths-LRMWNTJP.js → paths-MUXHUOCM.js} +8 -2
- package/dist/{pay-XAWW3NV3.js → pay-TDYQFSKY.js} +17 -16
- package/dist/payments-26NVMFR2.js +47 -0
- package/dist/payments-26NVMFR2.js.map +1 -0
- package/dist/{send-HESQYRKM.js → send-4RUBQQKP.js} +9 -10
- package/dist/{send-HESQYRKM.js.map → send-4RUBQQKP.js.map} +1 -1
- package/dist/{status-ANZPRZJJ.js → status-CEHZKHBU.js} +6 -6
- package/dist/{status-line-J3TUWVRQ.js → status-line-QRAO3Y2E.js} +7 -7
- package/dist/{status-line-wiring-HSV7DXO5.js → status-line-wiring-XKUVI5UW.js} +5 -5
- package/dist/tenjin-daemon.mjs +61 -7
- package/dist/{uninstall-GUU34YKP.js → uninstall-SJ6R2W2M.js} +11 -11
- package/dist/{update-KO2NZRJ5.js → update-N2NZS3AA.js} +6 -6
- package/dist/{wallet-3URC5QPK.js → wallet-IB2EFAUP.js} +9 -10
- package/docs/agent-permissions.md +11 -9
- package/docs/safety-model.md +3 -3
- package/package.json +1 -1
- package/dist/chunk-2E6GVIRP.js.map +0 -1
- package/dist/chunk-2G2WLVHB.js.map +0 -1
- package/dist/chunk-3KKKB2AQ.js +0 -40
- package/dist/chunk-3KKKB2AQ.js.map +0 -1
- package/dist/chunk-4AS52HUG.js.map +0 -1
- package/dist/chunk-4M5FBWT5.js.map +0 -1
- package/dist/chunk-5KD5HRAJ.js.map +0 -1
- package/dist/chunk-7ACHDNJA.js.map +0 -1
- package/dist/chunk-CCDOV45D.js.map +0 -1
- package/dist/chunk-NSG5TVZQ.js.map +0 -1
- package/dist/chunk-PO4HAXAW.js.map +0 -1
- package/dist/chunk-TU7XH3JJ.js.map +0 -1
- package/dist/chunk-YREKMJPP.js.map +0 -1
- package/dist/hook-command-U5XPEHAJ.js.map +0 -1
- package/dist/mcp-TUPRIPSI.js.map +0 -1
- /package/dist/{chunk-LI44XLMB.js.map → chunk-2RMXTNLT.js.map} +0 -0
- /package/dist/{chunk-5FYKPQNX.js.map → chunk-3Q3UBMVB.js.map} +0 -0
- /package/dist/{chunk-RPR2C2JO.js.map → chunk-DA53QKTD.js.map} +0 -0
- /package/dist/{chunk-YEBNE5NW.js.map → chunk-DHCOGDJB.js.map} +0 -0
- /package/dist/{chunk-BTX2QE2Y.js.map → chunk-F4IJQBGP.js.map} +0 -0
- /package/dist/{chunk-HH3PDYIG.js.map → chunk-NZYVSZNF.js.map} +0 -0
- /package/dist/{chunk-LN2HISWU.js.map → chunk-TU3IK7KK.js.map} +0 -0
- /package/dist/{chunk-72UHZRG6.js.map → chunk-UGLTSPXQ.js.map} +0 -0
- /package/dist/{chunk-CXUYCDPX.js.map → chunk-XBYTP4SP.js.map} +0 -0
- /package/dist/{config-KMJLFPSI.js.map → config-JBF5BZNO.js.map} +0 -0
- /package/dist/{install-MMNXJ5LM.js.map → install-TDYC22KI.js.map} +0 -0
- /package/dist/{install-identity-B7FVIWML.js.map → install-identity-QS4UFF27.js.map} +0 -0
- /package/dist/{paths-LRMWNTJP.js.map → paths-MUXHUOCM.js.map} +0 -0
- /package/dist/{pay-XAWW3NV3.js.map → pay-TDYQFSKY.js.map} +0 -0
- /package/dist/{status-ANZPRZJJ.js.map → status-CEHZKHBU.js.map} +0 -0
- /package/dist/{status-line-J3TUWVRQ.js.map → status-line-QRAO3Y2E.js.map} +0 -0
- /package/dist/{status-line-wiring-HSV7DXO5.js.map → status-line-wiring-XKUVI5UW.js.map} +0 -0
- /package/dist/{uninstall-GUU34YKP.js.map → uninstall-SJ6R2W2M.js.map} +0 -0
- /package/dist/{update-KO2NZRJ5.js.map → update-N2NZS3AA.js.map} +0 -0
- /package/dist/{wallet-3URC5QPK.js.map → wallet-IB2EFAUP.js.map} +0 -0
|
@@ -2,6 +2,7 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
VITEST_REPORTER_FILE,
|
|
4
4
|
archivedWalletPath,
|
|
5
|
+
balanceCachePath,
|
|
5
6
|
configPath,
|
|
6
7
|
daemonBundlePath,
|
|
7
8
|
daemonLogPath,
|
|
@@ -10,10 +11,12 @@ import {
|
|
|
10
11
|
daemonTokenPath,
|
|
11
12
|
dataDir,
|
|
12
13
|
defaultDataDir,
|
|
14
|
+
downloadsDir,
|
|
13
15
|
hookHealthPath,
|
|
14
16
|
hooksDir,
|
|
15
17
|
installIdPath,
|
|
16
18
|
loopDbPath,
|
|
19
|
+
paidLedgerPath,
|
|
17
20
|
passphraseBlobPath,
|
|
18
21
|
passphraseBlobPathFor,
|
|
19
22
|
sessionPath,
|
|
@@ -22,11 +25,12 @@ import {
|
|
|
22
25
|
updateCheckPath,
|
|
23
26
|
vitestReporterPath,
|
|
24
27
|
walletPath
|
|
25
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-K6AXXYCG.js";
|
|
26
29
|
import "./chunk-ZXTAQYNA.js";
|
|
27
30
|
export {
|
|
28
31
|
VITEST_REPORTER_FILE,
|
|
29
32
|
archivedWalletPath,
|
|
33
|
+
balanceCachePath,
|
|
30
34
|
configPath,
|
|
31
35
|
daemonBundlePath,
|
|
32
36
|
daemonLogPath,
|
|
@@ -35,10 +39,12 @@ export {
|
|
|
35
39
|
daemonTokenPath,
|
|
36
40
|
dataDir,
|
|
37
41
|
defaultDataDir,
|
|
42
|
+
downloadsDir,
|
|
38
43
|
hookHealthPath,
|
|
39
44
|
hooksDir,
|
|
40
45
|
installIdPath,
|
|
41
46
|
loopDbPath,
|
|
47
|
+
paidLedgerPath,
|
|
42
48
|
passphraseBlobPath,
|
|
43
49
|
passphraseBlobPathFor,
|
|
44
50
|
sessionPath,
|
|
@@ -48,4 +54,4 @@ export {
|
|
|
48
54
|
vitestReporterPath,
|
|
49
55
|
walletPath
|
|
50
56
|
};
|
|
51
|
-
//# sourceMappingURL=paths-
|
|
57
|
+
//# sourceMappingURL=paths-MUXHUOCM.js.map
|
|
@@ -2,20 +2,20 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
MAX_PAID_LEG_TIMEOUT_MS,
|
|
4
4
|
paidLegTimeoutMs,
|
|
5
|
-
runPay
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
runPay,
|
|
6
|
+
settlementTx
|
|
7
|
+
} from "./chunk-UAT3Q7VF.js";
|
|
8
|
+
import "./chunk-LAIZ2AQA.js";
|
|
8
9
|
import "./chunk-RGVOODF4.js";
|
|
9
10
|
import "./chunk-TTNESUPQ.js";
|
|
10
11
|
import "./chunk-HPWO4O6S.js";
|
|
11
12
|
import "./chunk-POUWHWID.js";
|
|
12
13
|
import "./chunk-XZKD7DIF.js";
|
|
13
14
|
import "./chunk-LHHMV4GU.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-7ACHDNJA.js";
|
|
15
|
+
import "./chunk-F4IJQBGP.js";
|
|
16
|
+
import "./chunk-DHCOGDJB.js";
|
|
17
|
+
import "./chunk-NYJCBQL5.js";
|
|
18
|
+
import "./chunk-WXFVJPZD.js";
|
|
19
19
|
import "./chunk-AWQPGIR6.js";
|
|
20
20
|
import "./chunk-N35E6CM2.js";
|
|
21
21
|
import "./chunk-JRGFKVAZ.js";
|
|
@@ -24,21 +24,22 @@ import "./chunk-EGELTSPU.js";
|
|
|
24
24
|
import "./chunk-KG3D7FIF.js";
|
|
25
25
|
import "./chunk-RBJPAZFI.js";
|
|
26
26
|
import "./chunk-BPMWXTFX.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-UGLTSPXQ.js";
|
|
28
28
|
import "./chunk-7QKHZQKW.js";
|
|
29
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-AG4DWNHO.js";
|
|
30
30
|
import "./chunk-MEFB5KHA.js";
|
|
31
31
|
import "./chunk-2I4QTOLB.js";
|
|
32
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-UHEMZEGW.js";
|
|
33
33
|
import "./chunk-O2JYBOUO.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
34
|
+
import "./chunk-SAN5PFTL.js";
|
|
35
|
+
import "./chunk-B4GA3HAK.js";
|
|
36
36
|
import "./chunk-JLEF5WHM.js";
|
|
37
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-K6AXXYCG.js";
|
|
38
38
|
import "./chunk-ZXTAQYNA.js";
|
|
39
39
|
export {
|
|
40
40
|
MAX_PAID_LEG_TIMEOUT_MS,
|
|
41
41
|
paidLegTimeoutMs,
|
|
42
|
-
runPay
|
|
42
|
+
runPay,
|
|
43
|
+
settlementTx
|
|
43
44
|
};
|
|
44
|
-
//# sourceMappingURL=pay-
|
|
45
|
+
//# sourceMappingURL=pay-TDYQFSKY.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
reconcilePayments
|
|
4
|
+
} from "./chunk-GONDQ27X.js";
|
|
5
|
+
import "./chunk-LAIZ2AQA.js";
|
|
6
|
+
import "./chunk-NYJCBQL5.js";
|
|
7
|
+
import "./chunk-WXFVJPZD.js";
|
|
8
|
+
import "./chunk-7QKHZQKW.js";
|
|
9
|
+
import "./chunk-MEFB5KHA.js";
|
|
10
|
+
import "./chunk-2I4QTOLB.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveContextSettings
|
|
13
|
+
} from "./chunk-UHEMZEGW.js";
|
|
14
|
+
import {
|
|
15
|
+
toMoney
|
|
16
|
+
} from "./chunk-O2JYBOUO.js";
|
|
17
|
+
import "./chunk-SAN5PFTL.js";
|
|
18
|
+
import "./chunk-JLEF5WHM.js";
|
|
19
|
+
import {
|
|
20
|
+
paidLedgerPath
|
|
21
|
+
} from "./chunk-K6AXXYCG.js";
|
|
22
|
+
import "./chunk-ZXTAQYNA.js";
|
|
23
|
+
|
|
24
|
+
// src/router/payments.ts
|
|
25
|
+
var MAX_COMMAND_CHECKS = 50;
|
|
26
|
+
async function runPaymentsReconcile(ctx, deps = {}) {
|
|
27
|
+
const settings = await resolveContextSettings(ctx);
|
|
28
|
+
const outcome = await reconcilePayments(ctx.dataDir, {
|
|
29
|
+
rpcUrl: settings.rpcUrl,
|
|
30
|
+
max: MAX_COMMAND_CHECKS,
|
|
31
|
+
// Asked for by hand: every due record, however recently it was asked about.
|
|
32
|
+
recheckMs: 0,
|
|
33
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {},
|
|
34
|
+
...deps.now !== void 0 ? { now: deps.now } : {}
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },
|
|
38
|
+
humanLines: [
|
|
39
|
+
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.` : ""),
|
|
40
|
+
...outcome.unknown > 0 ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`] : []
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
runPaymentsReconcile
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=payments-26NVMFR2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/payments.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { paidLedgerPath } from '../lib/paths';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { CommandContext, CommandResult } from '../context';\nimport { reconcilePayments } from './paid';\n\n/**\n * `tenjin payments reconcile`: settle every \"settlement unknown\" record in the\n * paid ledger that the chain can now answer for. The `request` tool runs the\n * same pass, three records at a time, before each lookup; this one asks about\n * up to {@link MAX_COMMAND_CHECKS}.\n *\n * A record found not charged also gives its amount back to the daily budget,\n * when the spend ledger still holds that payment's exposure in this window.\n */\n\nconst MAX_COMMAND_CHECKS = 50;\n\nexport interface PaymentsDeps {\n fetchImpl?: typeof fetch;\n now?: () => number;\n}\n\nexport async function runPaymentsReconcile(\n ctx: CommandContext,\n deps: PaymentsDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const outcome = await reconcilePayments(ctx.dataDir, {\n rpcUrl: settings.rpcUrl,\n max: MAX_COMMAND_CHECKS,\n // Asked for by hand: every due record, however recently it was asked about.\n recheckMs: 0,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n return {\n data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },\n humanLines: [\n outcome.checked === 0\n ? 'No paid lookup is waiting on its settlement.'\n : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` +\n (outcome.releasedAtomic !== '0'\n ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.`\n : ''),\n ...(outcome.unknown > 0\n ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`]\n : []),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAqB;AAO3B,eAAsB,qBACpB,KACA,OAAqB,CAAC,GACE;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,UAAU,MAAM,kBAAkB,IAAI,SAAS;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,KAAK;AAAA;AAAA,IAEL,WAAW;AAAA,IACX,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACpE,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,SAAO;AAAA,IACL,MAAM,EAAE,QAAQ,eAAe,IAAI,OAAO,GAAG,GAAG,QAAQ;AAAA,IACxD,YAAY;AAAA,MACV,QAAQ,YAAY,IAChB,iDACA,WAAW,QAAQ,OAAO,KAAK,QAAQ,OAAO,aAAa,QAAQ,UAAU,mBAC5E,QAAQ,mBAAmB,MACxB,IAAI,QAAQ,QAAQ,cAAc,EAAE,GAAG,qCACvC;AAAA,MACR,GAAI,QAAQ,UAAU,IAClB,CAAC,GAAG,QAAQ,OAAO,8DAA8D,IACjF,CAAC;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -10,14 +10,13 @@ import {
|
|
|
10
10
|
broadcastUsdcSend,
|
|
11
11
|
getUsdcBalance,
|
|
12
12
|
prepareUsdcSend
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-3KKKB2AQ.js";
|
|
13
|
+
} from "./chunk-F4IJQBGP.js";
|
|
15
14
|
import {
|
|
16
15
|
describeWallet,
|
|
17
16
|
resolveWalletProvider
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-DHCOGDJB.js";
|
|
18
|
+
import "./chunk-NYJCBQL5.js";
|
|
19
|
+
import "./chunk-WXFVJPZD.js";
|
|
21
20
|
import "./chunk-AWQPGIR6.js";
|
|
22
21
|
import "./chunk-N35E6CM2.js";
|
|
23
22
|
import "./chunk-JRGFKVAZ.js";
|
|
@@ -30,23 +29,23 @@ import {
|
|
|
30
29
|
import "./chunk-KG3D7FIF.js";
|
|
31
30
|
import "./chunk-RBJPAZFI.js";
|
|
32
31
|
import "./chunk-BPMWXTFX.js";
|
|
33
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-UGLTSPXQ.js";
|
|
34
33
|
import "./chunk-MEFB5KHA.js";
|
|
35
34
|
import "./chunk-2I4QTOLB.js";
|
|
36
35
|
import {
|
|
37
36
|
resolveContextSettings
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-UHEMZEGW.js";
|
|
39
38
|
import {
|
|
40
39
|
parseUsdToAtomic,
|
|
41
40
|
toMoney
|
|
42
41
|
} from "./chunk-O2JYBOUO.js";
|
|
43
42
|
import {
|
|
44
43
|
SEND_MAX_UNSET
|
|
45
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-SAN5PFTL.js";
|
|
46
45
|
import {
|
|
47
46
|
CliError
|
|
48
47
|
} from "./chunk-JLEF5WHM.js";
|
|
49
|
-
import "./chunk-
|
|
48
|
+
import "./chunk-K6AXXYCG.js";
|
|
50
49
|
import "./chunk-ZXTAQYNA.js";
|
|
51
50
|
|
|
52
51
|
// src/commands/send.ts
|
|
@@ -222,4 +221,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
|
|
|
222
221
|
export {
|
|
223
222
|
runSend
|
|
224
223
|
};
|
|
225
|
-
//# sourceMappingURL=send-
|
|
224
|
+
//# sourceMappingURL=send-4RUBQQKP.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,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,GAA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AAE,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,IAAI,SAAS,SAAS,sBAAsB,KAAK,UAAU,KAAK,CAAC,IAAI;AAAA,IACzE,KAAK;AAAA,EACP,CAAC;AACH;AAUA,SAAS,eAAe,KAAsB;AAC5C,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,CAAC,UAAU,OAAO,GAAG;AACvB,UAAM,IAAI,SAAS,SAAS,8BAA8B,KAAK,UAAU,GAAG,CAAC,IAAI;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,KAAK,WAAW,OAAO;AAC7B,MAAI,OAAO,gBAAgB,OAAO,gBAAgB,OAAO,cAAc;AACrE,UAAM,IAAI,SAAS,SAAS,qDAAqD;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAUA,eAAe,YACb,KACA,MACA,KACA,GACkB;AAClB,MAAI,IAAK,QAAO;AAChB,QAAM,SACJ,QAAQ,QAAQ,EAAE,aAAa,SAAS,CAAC,EAAE,GAAG;AAAA,SACpC,EAAE,IAAI;AAAA,SACN,EAAE,EAAE;AAAA,uBACU,YAAY,EAAE,MAAM,CAAC;AAAA;AAE/C,MAAI,KAAK,YAAY,OAAW,QAAO,KAAK,QAAQ,MAAM;AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-NYJCBQL5.js";
|
|
3
3
|
import {
|
|
4
4
|
readSpendSummary,
|
|
5
5
|
spentOf
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WXFVJPZD.js";
|
|
7
7
|
import "./chunk-MEFB5KHA.js";
|
|
8
8
|
import "./chunk-2I4QTOLB.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveContextSettings
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UHEMZEGW.js";
|
|
12
12
|
import {
|
|
13
13
|
toMoney
|
|
14
14
|
} from "./chunk-O2JYBOUO.js";
|
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
RETIRED_PAYMENT_GUIDANCE,
|
|
17
17
|
loadRawConfig,
|
|
18
18
|
retiredPaymentKeys
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SAN5PFTL.js";
|
|
20
20
|
import "./chunk-JLEF5WHM.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-K6AXXYCG.js";
|
|
22
22
|
import "./chunk-ZXTAQYNA.js";
|
|
23
23
|
|
|
24
24
|
// src/router/status.ts
|
|
@@ -68,4 +68,4 @@ async function runRouterStatus(ctx, deps = {}) {
|
|
|
68
68
|
export {
|
|
69
69
|
runRouterStatus
|
|
70
70
|
};
|
|
71
|
-
//# sourceMappingURL=status-
|
|
71
|
+
//# sourceMappingURL=status-CEHZKHBU.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
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-QF4SSCQV.js";
|
|
5
5
|
import {
|
|
6
6
|
routerSettings
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-XBYTP4SP.js";
|
|
8
|
+
import "./chunk-UHEMZEGW.js";
|
|
9
9
|
import "./chunk-O2JYBOUO.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-SAN5PFTL.js";
|
|
11
11
|
import "./chunk-JLEF5WHM.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-K6AXXYCG.js";
|
|
13
13
|
import "./chunk-ZXTAQYNA.js";
|
|
14
14
|
|
|
15
15
|
// src/router/status-line.ts
|
|
16
16
|
var MAX_EVENT_BYTES = 64e3;
|
|
17
17
|
var STDIN_TIMEOUT_MS = 1e3;
|
|
18
18
|
async function statusLineMain() {
|
|
19
|
-
const { dataDir } = await import("./paths-
|
|
19
|
+
const { dataDir } = await import("./paths-MUXHUOCM.js");
|
|
20
20
|
await runStatusLine(
|
|
21
21
|
{ stdout: process.stdout, stderr: process.stderr, isTTY: false },
|
|
22
22
|
{ dataDir: dataDir(process.env) }
|
|
@@ -84,4 +84,4 @@ export {
|
|
|
84
84
|
runStatusLine,
|
|
85
85
|
statusLineMain
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=status-line-
|
|
87
|
+
//# sourceMappingURL=status-line-QRAO3Y2E.js.map
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
inspectStatusLine,
|
|
10
10
|
removeStatusLine,
|
|
11
11
|
statusLineMode
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-TU3IK7KK.js";
|
|
13
|
+
import "./chunk-3Q3UBMVB.js";
|
|
14
|
+
import "./chunk-B4GA3HAK.js";
|
|
15
15
|
import "./chunk-JLEF5WHM.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-K6AXXYCG.js";
|
|
17
17
|
import "./chunk-ZXTAQYNA.js";
|
|
18
18
|
export {
|
|
19
19
|
STATUS_LINE_COMMAND,
|
|
@@ -26,4 +26,4 @@ export {
|
|
|
26
26
|
removeStatusLine,
|
|
27
27
|
statusLineMode
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=status-line-wiring-
|
|
29
|
+
//# sourceMappingURL=status-line-wiring-XKUVI5UW.js.map
|
package/dist/tenjin-daemon.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "tenjin-cli",
|
|
14
|
-
version: "0.1.0-alpha.
|
|
14
|
+
version: "0.1.0-alpha.22",
|
|
15
15
|
mcpName: "blog.tenjin/tenjin",
|
|
16
16
|
type: "module",
|
|
17
17
|
description: "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.",
|
|
@@ -16234,6 +16234,35 @@ function timeoutFailure(url2, timeoutMs) {
|
|
|
16234
16234
|
message: `Request to ${url2} timed out after ${timeoutMs}ms`
|
|
16235
16235
|
};
|
|
16236
16236
|
}
|
|
16237
|
+
var MAX_BINARY_BODY_BYTES = 200 * 1024 * 1024;
|
|
16238
|
+
async function readCapped(res, max) {
|
|
16239
|
+
const declared = Number(res.headers.get("content-length") ?? "0");
|
|
16240
|
+
if (Number.isFinite(declared) && declared > max) {
|
|
16241
|
+
await res.body?.cancel().catch(() => void 0);
|
|
16242
|
+
return null;
|
|
16243
|
+
}
|
|
16244
|
+
if (res.body === null) return new Uint8Array();
|
|
16245
|
+
const reader = res.body.getReader();
|
|
16246
|
+
const chunks = [];
|
|
16247
|
+
let size = 0;
|
|
16248
|
+
for (; ; ) {
|
|
16249
|
+
const { done, value } = await reader.read();
|
|
16250
|
+
if (done) break;
|
|
16251
|
+
size += value.byteLength;
|
|
16252
|
+
if (size > max) {
|
|
16253
|
+
await reader.cancel().catch(() => void 0);
|
|
16254
|
+
return null;
|
|
16255
|
+
}
|
|
16256
|
+
chunks.push(value);
|
|
16257
|
+
}
|
|
16258
|
+
return new Uint8Array(Buffer.concat(chunks));
|
|
16259
|
+
}
|
|
16260
|
+
function isBinaryContentType(contentType) {
|
|
16261
|
+
const type = (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
16262
|
+
if (type.length === 0) return false;
|
|
16263
|
+
if (type.startsWith("text/")) return false;
|
|
16264
|
+
return !/(?:json|xml|javascript|ecmascript|yaml|x-www-form-urlencoded)/.test(type);
|
|
16265
|
+
}
|
|
16237
16266
|
function prepareRequest(url2, opts) {
|
|
16238
16267
|
try {
|
|
16239
16268
|
let body;
|
|
@@ -16307,8 +16336,24 @@ async function httpRequest(url2, opts) {
|
|
|
16307
16336
|
};
|
|
16308
16337
|
}
|
|
16309
16338
|
let text;
|
|
16339
|
+
let bytes;
|
|
16310
16340
|
try {
|
|
16311
|
-
|
|
16341
|
+
if (opts.binaryBody === true && isBinaryContentType(res.headers.get("content-type") ?? "")) {
|
|
16342
|
+
const read = await readCapped(res, opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES);
|
|
16343
|
+
if (read === null) {
|
|
16344
|
+
return {
|
|
16345
|
+
ok: false,
|
|
16346
|
+
kind: "network",
|
|
16347
|
+
status: res.status,
|
|
16348
|
+
...requestId !== void 0 ? { requestId } : {},
|
|
16349
|
+
message: `Request to ${url2} returned a file over the ${Math.round((opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES) / 1048576)} MB cap; it was not kept.`
|
|
16350
|
+
};
|
|
16351
|
+
}
|
|
16352
|
+
bytes = read;
|
|
16353
|
+
text = "";
|
|
16354
|
+
} else {
|
|
16355
|
+
text = await res.text();
|
|
16356
|
+
}
|
|
16312
16357
|
} catch (err) {
|
|
16313
16358
|
if (timedOut) return timeoutFailure(url2, opts.timeoutMs);
|
|
16314
16359
|
return {
|
|
@@ -16333,6 +16378,7 @@ async function httpRequest(url2, opts) {
|
|
|
16333
16378
|
header: (name) => res.headers.get(name) ?? void 0,
|
|
16334
16379
|
json: json2,
|
|
16335
16380
|
text,
|
|
16381
|
+
...bytes !== void 0 ? { bytes } : {},
|
|
16336
16382
|
...requestId !== void 0 ? { requestId } : {}
|
|
16337
16383
|
};
|
|
16338
16384
|
} finally {
|
|
@@ -16540,6 +16586,9 @@ function daemonLogPath(dir = dataDir()) {
|
|
|
16540
16586
|
// src/adapters/types.ts
|
|
16541
16587
|
var HARNESSES = ["claude", "codex"];
|
|
16542
16588
|
|
|
16589
|
+
// src/lib/usdc-balance.ts
|
|
16590
|
+
var DEFAULT_RPC_URL = "https://mainnet.base.org";
|
|
16591
|
+
|
|
16543
16592
|
// src/lib/config.ts
|
|
16544
16593
|
var atomicString = external_exports.string().regex(/^\d+$/, "expected an atomic USDC integer string");
|
|
16545
16594
|
var PublishModeSchema = external_exports.enum(["review", "auto", "full-auto"]);
|
|
@@ -16583,6 +16632,7 @@ var LoopConfigSchema = external_exports.object({
|
|
|
16583
16632
|
});
|
|
16584
16633
|
var PublicFallbackSchema = external_exports.enum(["on", "off"]);
|
|
16585
16634
|
var TeamConfigSchema = external_exports.object({ publicFallback: PublicFallbackSchema });
|
|
16635
|
+
var ExperimentalConfigSchema = external_exports.object({ bazaar: PublicFallbackSchema });
|
|
16586
16636
|
var UpdateConfigSchema = external_exports.object({
|
|
16587
16637
|
mode: UpdateModeSchema
|
|
16588
16638
|
});
|
|
@@ -16681,7 +16731,8 @@ var ConfigSchema = external_exports.object({
|
|
|
16681
16731
|
update: UpdateConfigSchema,
|
|
16682
16732
|
loop: LoopConfigSchema,
|
|
16683
16733
|
team: TeamConfigSchema,
|
|
16684
|
-
router: RouterConfigSchema
|
|
16734
|
+
router: RouterConfigSchema,
|
|
16735
|
+
experimental: ExperimentalConfigSchema
|
|
16685
16736
|
});
|
|
16686
16737
|
var RawInstallConfigSchema = InstallConfigSchema.partial().extend({
|
|
16687
16738
|
harness: RawInstallHarnessSchema.optional(),
|
|
@@ -16694,7 +16745,8 @@ var RawConfigSchema = ConfigSchema.partial().extend({
|
|
|
16694
16745
|
update: UpdateConfigSchema.partial().passthrough().optional(),
|
|
16695
16746
|
loop: LoopConfigSchema.partial().passthrough().optional(),
|
|
16696
16747
|
team: TeamConfigSchema.partial().passthrough().optional(),
|
|
16697
|
-
router: RouterLayerSchema.passthrough().optional()
|
|
16748
|
+
router: RouterLayerSchema.passthrough().optional(),
|
|
16749
|
+
experimental: ExperimentalConfigSchema.partial().passthrough().optional()
|
|
16698
16750
|
}).passthrough();
|
|
16699
16751
|
var DEFAULT_BAZAAR_REGISTRIES = [
|
|
16700
16752
|
"https://api.cdp.coinbase.com/platform/v2/x402",
|
|
@@ -16716,7 +16768,7 @@ var CONFIG_DEFAULTS = {
|
|
|
16716
16768
|
publicShelfUrl: PRODUCTION_ORIGIN,
|
|
16717
16769
|
// Empty = public mode. Setting it is the whole of "turn on team mode".
|
|
16718
16770
|
shelfBypassSecret: "",
|
|
16719
|
-
rpcUrl:
|
|
16771
|
+
rpcUrl: DEFAULT_RPC_URL,
|
|
16720
16772
|
evalCohort: false,
|
|
16721
16773
|
bazaarRegistries: DEFAULT_BAZAAR_REGISTRIES,
|
|
16722
16774
|
publish: { mode: "review", defaultPrice: "100000", ackServerWarnings: "mode" },
|
|
@@ -16742,7 +16794,8 @@ var CONFIG_DEFAULTS = {
|
|
|
16742
16794
|
port: null
|
|
16743
16795
|
},
|
|
16744
16796
|
team: { publicFallback: "on" },
|
|
16745
|
-
router: { enabled: true, context: "session" }
|
|
16797
|
+
router: { enabled: true, context: "session" },
|
|
16798
|
+
experimental: { bazaar: "off" }
|
|
16746
16799
|
};
|
|
16747
16800
|
var NESTED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
16748
16801
|
"publish",
|
|
@@ -16751,7 +16804,8 @@ var NESTED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
16751
16804
|
"update",
|
|
16752
16805
|
"loop",
|
|
16753
16806
|
"team",
|
|
16754
|
-
"router"
|
|
16807
|
+
"router",
|
|
16808
|
+
"experimental"
|
|
16755
16809
|
]);
|
|
16756
16810
|
var CONFIG_KEYS = Object.keys(CONFIG_DEFAULTS).filter(
|
|
16757
16811
|
(key) => !NESTED_CONFIG_KEYS.has(key)
|
|
@@ -5,35 +5,35 @@ import {
|
|
|
5
5
|
mcpScope,
|
|
6
6
|
readMcpEntry,
|
|
7
7
|
routerSettingsPath
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CYEUVU3F.js";
|
|
9
9
|
import {
|
|
10
10
|
MCP_SERVER_NAME
|
|
11
11
|
} from "./chunk-TGLKKLQG.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-UGLTSPXQ.js";
|
|
13
13
|
import {
|
|
14
14
|
onPath,
|
|
15
15
|
persistRouterProject
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UIOZRILX.js";
|
|
17
17
|
import "./chunk-A36LQPHV.js";
|
|
18
18
|
import "./chunk-2QYORQBF.js";
|
|
19
19
|
import "./chunk-MEFB5KHA.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-XBYTP4SP.js";
|
|
21
21
|
import "./chunk-2I4QTOLB.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-UHEMZEGW.js";
|
|
23
23
|
import "./chunk-O2JYBOUO.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-SAN5PFTL.js";
|
|
25
25
|
import {
|
|
26
26
|
removeStatusLine
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-TU3IK7KK.js";
|
|
28
28
|
import {
|
|
29
29
|
inspectHooksFile,
|
|
30
30
|
pruneHooks
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-3Q3UBMVB.js";
|
|
32
|
+
import "./chunk-B4GA3HAK.js";
|
|
33
33
|
import {
|
|
34
34
|
writeFileAtomic
|
|
35
35
|
} from "./chunk-JLEF5WHM.js";
|
|
36
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-K6AXXYCG.js";
|
|
37
37
|
import "./chunk-ZXTAQYNA.js";
|
|
38
38
|
|
|
39
39
|
// src/router/uninstall.ts
|
|
@@ -162,4 +162,4 @@ export {
|
|
|
162
162
|
MCP_REMOVE_COMMAND,
|
|
163
163
|
runRouterUninstall
|
|
164
164
|
};
|
|
165
|
-
//# sourceMappingURL=uninstall-
|
|
165
|
+
//# sourceMappingURL=uninstall-SJ6R2W2M.js.map
|
|
@@ -5,21 +5,21 @@ import {
|
|
|
5
5
|
fetchDistTags,
|
|
6
6
|
isNewer,
|
|
7
7
|
resolveTarget
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NZYVSZNF.js";
|
|
9
9
|
import {
|
|
10
10
|
emitWriteNotice,
|
|
11
11
|
sanitizeForTerminal
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-UGLTSPXQ.js";
|
|
13
|
+
import "./chunk-SAN5PFTL.js";
|
|
14
14
|
import {
|
|
15
15
|
package_default
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-B4GA3HAK.js";
|
|
17
17
|
import {
|
|
18
18
|
CliError
|
|
19
19
|
} from "./chunk-JLEF5WHM.js";
|
|
20
20
|
import {
|
|
21
21
|
defaultDataDir
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-K6AXXYCG.js";
|
|
23
23
|
import "./chunk-ZXTAQYNA.js";
|
|
24
24
|
|
|
25
25
|
// src/commands/update.ts
|
|
@@ -430,4 +430,4 @@ export {
|
|
|
430
430
|
spawnCapture,
|
|
431
431
|
versionFreeEntry
|
|
432
432
|
};
|
|
433
|
-
//# sourceMappingURL=update-
|
|
433
|
+
//# sourceMappingURL=update-N2NZS3AA.js.map
|