tenjin-cli 0.1.0-alpha.21 → 0.1.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +17 -14
  2. package/dist/{chunk-PJEG2JIJ.js → chunk-2RMXTNLT.js} +4 -4
  3. package/dist/{chunk-2AQO4YDI.js → chunk-3IOS6YG6.js} +3 -3
  4. package/dist/{chunk-IOIHYOU4.js → chunk-6O6DFYF3.js} +2 -2
  5. package/dist/chunk-A2XMQSWI.js +140 -0
  6. package/dist/chunk-A2XMQSWI.js.map +1 -0
  7. package/dist/{chunk-YVODPFTL.js → chunk-DHCOGDJB.js} +4 -4
  8. package/dist/{chunk-AQRUD5GQ.js → chunk-F4IJQBGP.js} +4 -4
  9. package/dist/{chunk-SRVDXR6B.js → chunk-GONDQ27X.js} +5 -5
  10. package/dist/{chunk-JN7TMXVF.js → chunk-HJYI52HM.js} +2 -2
  11. package/dist/{chunk-UY2TOI3B.js → chunk-HTC4VJFT.js} +77 -7
  12. package/dist/chunk-HTC4VJFT.js.map +1 -0
  13. package/dist/{chunk-OTPEH3AH.js → chunk-I2GBBIDI.js} +5 -5
  14. package/dist/{chunk-GHTPYKDT.js → chunk-K63HPLYT.js} +4 -4
  15. package/dist/{chunk-3EUTWC2B.js → chunk-N7A5EXJZ.js} +4 -4
  16. package/dist/{chunk-N4DJEQAF.js → chunk-NYJCBQL5.js} +2 -2
  17. package/dist/{chunk-RCJQARZF.js → chunk-RA2J3TWG.js} +2 -2
  18. package/dist/{chunk-RCJQARZF.js.map → chunk-RA2J3TWG.js.map} +1 -1
  19. package/dist/{chunk-W3LVZ2EN.js → chunk-SAN5PFTL.js} +102 -5
  20. package/dist/chunk-SAN5PFTL.js.map +1 -0
  21. package/dist/{chunk-QRFONFRW.js → chunk-UGLTSPXQ.js} +2 -2
  22. package/dist/{chunk-IOB7URFH.js → chunk-UHEMZEGW.js} +2 -2
  23. package/dist/{chunk-U2ATFMKZ.js → chunk-WXFVJPZD.js} +2 -2
  24. package/dist/{chunk-C363JZN2.js → chunk-XBYTP4SP.js} +3 -3
  25. package/dist/{chunk-OSUD6YZZ.js → chunk-Y3LKUXZA.js} +8 -8
  26. package/dist/{chunk-ETW2ASBP.js → chunk-YT7A7DLY.js} +94 -29
  27. package/dist/chunk-YT7A7DLY.js.map +1 -0
  28. package/dist/{cli-7KJ4QLUU.js → cli-MUYFTWWB.js} +28 -28
  29. package/dist/{cli-7KJ4QLUU.js.map → cli-MUYFTWWB.js.map} +1 -1
  30. package/dist/{config-MSN6H4MD.js → config-IIRRO3XC.js} +7 -7
  31. package/dist/{doctor-ITUCKN6C.js → doctor-KGHM2CAC.js} +15 -15
  32. package/dist/{fund-XPB4IIG5.js → fund-DOWIT3JT.js} +9 -10
  33. package/dist/{fund-XPB4IIG5.js.map → fund-DOWIT3JT.js.map} +1 -1
  34. package/dist/{hook-command-VVV2Q23L.js → hook-command-RDT754KQ.js} +90 -12
  35. package/dist/hook-command-RDT754KQ.js.map +1 -0
  36. package/dist/index.js +3 -3
  37. package/dist/{install-OSJRM2ME.js → install-BYQUMYBN.js} +10 -10
  38. package/dist/{install-identity-YIWKQOUD.js → install-identity-KTQPYVAO.js} +6 -6
  39. package/dist/{install-wallet-BWJO2SUC.js → install-wallet-T737X74E.js} +8 -9
  40. package/dist/{install-wallet-BWJO2SUC.js.map → install-wallet-T737X74E.js.map} +1 -1
  41. package/dist/{mcp-KE5YKPS2.js → mcp-ZKOTURQN.js} +462 -69
  42. package/dist/mcp-ZKOTURQN.js.map +1 -0
  43. package/dist/{pay-MUV2U232.js → pay-LZPU2HUT.js} +11 -12
  44. package/dist/{payments-4D27K4L2.js → payments-26NVMFR2.js} +6 -7
  45. package/dist/{payments-4D27K4L2.js.map → payments-26NVMFR2.js.map} +1 -1
  46. package/dist/{send-BXHFKDBF.js → send-4RUBQQKP.js} +8 -9
  47. package/dist/{send-BXHFKDBF.js.map → send-4RUBQQKP.js.map} +1 -1
  48. package/dist/{status-3Z3YPRSE.js → status-CEHZKHBU.js} +5 -5
  49. package/dist/{status-line-CKRMGZ3Q.js → status-line-QRAO3Y2E.js} +4 -4
  50. package/dist/{status-line-wiring-GECLIIBT.js → status-line-wiring-7D2CSV3K.js} +4 -4
  51. package/dist/tenjin-daemon.mjs +5 -2
  52. package/dist/{uninstall-BZTVWJ7W.js → uninstall-VR44B4KD.js} +10 -10
  53. package/dist/{update-IQQTEOI5.js → update-SOYQLDBF.js} +5 -5
  54. package/dist/{wallet-UFXQ57TZ.js → wallet-IB2EFAUP.js} +8 -9
  55. package/docs/agent-permissions.md +8 -8
  56. package/docs/safety-model.md +2 -2
  57. package/package.json +1 -1
  58. package/dist/chunk-ETW2ASBP.js.map +0 -1
  59. package/dist/chunk-QHILSA6G.js +0 -82
  60. package/dist/chunk-QHILSA6G.js.map +0 -1
  61. package/dist/chunk-UY2TOI3B.js.map +0 -1
  62. package/dist/chunk-W3LVZ2EN.js.map +0 -1
  63. package/dist/hook-command-VVV2Q23L.js.map +0 -1
  64. package/dist/mcp-KE5YKPS2.js.map +0 -1
  65. /package/dist/{chunk-PJEG2JIJ.js.map → chunk-2RMXTNLT.js.map} +0 -0
  66. /package/dist/{chunk-2AQO4YDI.js.map → chunk-3IOS6YG6.js.map} +0 -0
  67. /package/dist/{chunk-IOIHYOU4.js.map → chunk-6O6DFYF3.js.map} +0 -0
  68. /package/dist/{chunk-YVODPFTL.js.map → chunk-DHCOGDJB.js.map} +0 -0
  69. /package/dist/{chunk-AQRUD5GQ.js.map → chunk-F4IJQBGP.js.map} +0 -0
  70. /package/dist/{chunk-SRVDXR6B.js.map → chunk-GONDQ27X.js.map} +0 -0
  71. /package/dist/{chunk-JN7TMXVF.js.map → chunk-HJYI52HM.js.map} +0 -0
  72. /package/dist/{chunk-OTPEH3AH.js.map → chunk-I2GBBIDI.js.map} +0 -0
  73. /package/dist/{chunk-GHTPYKDT.js.map → chunk-K63HPLYT.js.map} +0 -0
  74. /package/dist/{chunk-3EUTWC2B.js.map → chunk-N7A5EXJZ.js.map} +0 -0
  75. /package/dist/{chunk-N4DJEQAF.js.map → chunk-NYJCBQL5.js.map} +0 -0
  76. /package/dist/{chunk-QRFONFRW.js.map → chunk-UGLTSPXQ.js.map} +0 -0
  77. /package/dist/{chunk-IOB7URFH.js.map → chunk-UHEMZEGW.js.map} +0 -0
  78. /package/dist/{chunk-U2ATFMKZ.js.map → chunk-WXFVJPZD.js.map} +0 -0
  79. /package/dist/{chunk-C363JZN2.js.map → chunk-XBYTP4SP.js.map} +0 -0
  80. /package/dist/{chunk-OSUD6YZZ.js.map → chunk-Y3LKUXZA.js.map} +0 -0
  81. /package/dist/{config-MSN6H4MD.js.map → config-IIRRO3XC.js.map} +0 -0
  82. /package/dist/{doctor-ITUCKN6C.js.map → doctor-KGHM2CAC.js.map} +0 -0
  83. /package/dist/{install-OSJRM2ME.js.map → install-BYQUMYBN.js.map} +0 -0
  84. /package/dist/{install-identity-YIWKQOUD.js.map → install-identity-KTQPYVAO.js.map} +0 -0
  85. /package/dist/{pay-MUV2U232.js.map → pay-LZPU2HUT.js.map} +0 -0
  86. /package/dist/{status-3Z3YPRSE.js.map → status-CEHZKHBU.js.map} +0 -0
  87. /package/dist/{status-line-CKRMGZ3Q.js.map → status-line-QRAO3Y2E.js.map} +0 -0
  88. /package/dist/{status-line-wiring-GECLIIBT.js.map → status-line-wiring-7D2CSV3K.js.map} +0 -0
  89. /package/dist/{uninstall-BZTVWJ7W.js.map → uninstall-VR44B4KD.js.map} +0 -0
  90. /package/dist/{update-IQQTEOI5.js.map → update-SOYQLDBF.js.map} +0 -0
  91. /package/dist/{wallet-UFXQ57TZ.js.map → wallet-IB2EFAUP.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  paidLegTimeoutMs,
5
5
  runPay,
6
6
  settlementTx
7
- } from "./chunk-ETW2ASBP.js";
7
+ } from "./chunk-YT7A7DLY.js";
8
8
  import "./chunk-LAIZ2AQA.js";
9
9
  import "./chunk-RGVOODF4.js";
10
10
  import "./chunk-TTNESUPQ.js";
@@ -12,11 +12,10 @@ import "./chunk-HPWO4O6S.js";
12
12
  import "./chunk-POUWHWID.js";
13
13
  import "./chunk-XZKD7DIF.js";
14
14
  import "./chunk-LHHMV4GU.js";
15
- import "./chunk-AQRUD5GQ.js";
16
- import "./chunk-QHILSA6G.js";
17
- import "./chunk-YVODPFTL.js";
18
- import "./chunk-N4DJEQAF.js";
19
- import "./chunk-U2ATFMKZ.js";
15
+ import "./chunk-F4IJQBGP.js";
16
+ import "./chunk-DHCOGDJB.js";
17
+ import "./chunk-NYJCBQL5.js";
18
+ import "./chunk-WXFVJPZD.js";
20
19
  import "./chunk-AWQPGIR6.js";
21
20
  import "./chunk-N35E6CM2.js";
22
21
  import "./chunk-JRGFKVAZ.js";
@@ -25,15 +24,15 @@ import "./chunk-EGELTSPU.js";
25
24
  import "./chunk-KG3D7FIF.js";
26
25
  import "./chunk-RBJPAZFI.js";
27
26
  import "./chunk-BPMWXTFX.js";
28
- import "./chunk-QRFONFRW.js";
27
+ import "./chunk-UGLTSPXQ.js";
29
28
  import "./chunk-7QKHZQKW.js";
30
- import "./chunk-2AQO4YDI.js";
29
+ import "./chunk-3IOS6YG6.js";
31
30
  import "./chunk-MEFB5KHA.js";
32
31
  import "./chunk-2I4QTOLB.js";
33
- import "./chunk-IOB7URFH.js";
32
+ import "./chunk-UHEMZEGW.js";
34
33
  import "./chunk-O2JYBOUO.js";
35
- import "./chunk-W3LVZ2EN.js";
36
- import "./chunk-RCJQARZF.js";
34
+ import "./chunk-SAN5PFTL.js";
35
+ import "./chunk-RA2J3TWG.js";
37
36
  import "./chunk-JLEF5WHM.js";
38
37
  import "./chunk-K6AXXYCG.js";
39
38
  import "./chunk-ZXTAQYNA.js";
@@ -43,4 +42,4 @@ export {
43
42
  runPay,
44
43
  settlementTx
45
44
  };
46
- //# sourceMappingURL=pay-MUV2U232.js.map
45
+ //# sourceMappingURL=pay-LZPU2HUT.js.map
@@ -1,21 +1,20 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  reconcilePayments
4
- } from "./chunk-SRVDXR6B.js";
4
+ } from "./chunk-GONDQ27X.js";
5
5
  import "./chunk-LAIZ2AQA.js";
6
- import "./chunk-QHILSA6G.js";
7
- import "./chunk-N4DJEQAF.js";
8
- import "./chunk-U2ATFMKZ.js";
6
+ import "./chunk-NYJCBQL5.js";
7
+ import "./chunk-WXFVJPZD.js";
9
8
  import "./chunk-7QKHZQKW.js";
10
9
  import "./chunk-MEFB5KHA.js";
11
10
  import "./chunk-2I4QTOLB.js";
12
11
  import {
13
12
  resolveContextSettings
14
- } from "./chunk-IOB7URFH.js";
13
+ } from "./chunk-UHEMZEGW.js";
15
14
  import {
16
15
  toMoney
17
16
  } from "./chunk-O2JYBOUO.js";
18
- import "./chunk-W3LVZ2EN.js";
17
+ import "./chunk-SAN5PFTL.js";
19
18
  import "./chunk-JLEF5WHM.js";
20
19
  import {
21
20
  paidLedgerPath
@@ -45,4 +44,4 @@ async function runPaymentsReconcile(ctx, deps = {}) {
45
44
  export {
46
45
  runPaymentsReconcile
47
46
  };
48
- //# sourceMappingURL=payments-4D27K4L2.js.map
47
+ //# sourceMappingURL=payments-26NVMFR2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/payments.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { paidLedgerPath } from '../lib/paths';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { CommandContext, CommandResult } from '../context';\nimport { reconcilePayments } from './paid';\n\n/**\n * `tenjin payments reconcile`: settle every \"settlement unknown\" record in the\n * paid ledger that the chain can now answer for. The `request` tool runs the\n * same pass, three records at a time, before each lookup; this one asks about\n * up to {@link MAX_COMMAND_CHECKS}.\n *\n * A record found not charged also gives its amount back to the daily budget,\n * when the spend ledger still holds that payment's exposure in this window.\n */\n\nconst MAX_COMMAND_CHECKS = 50;\n\nexport interface PaymentsDeps {\n fetchImpl?: typeof fetch;\n now?: () => number;\n}\n\nexport async function runPaymentsReconcile(\n ctx: CommandContext,\n deps: PaymentsDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const outcome = await reconcilePayments(ctx.dataDir, {\n rpcUrl: settings.rpcUrl,\n max: MAX_COMMAND_CHECKS,\n // Asked for by hand: every due record, however recently it was asked about.\n recheckMs: 0,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n return {\n data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },\n humanLines: [\n outcome.checked === 0\n ? 'No paid lookup is waiting on its settlement.'\n : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` +\n (outcome.releasedAtomic !== '0'\n ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.`\n : ''),\n ...(outcome.unknown > 0\n ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`]\n : []),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAqB;AAO3B,eAAsB,qBACpB,KACA,OAAqB,CAAC,GACE;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,UAAU,MAAM,kBAAkB,IAAI,SAAS;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,KAAK;AAAA;AAAA,IAEL,WAAW;AAAA,IACX,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACpE,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,SAAO;AAAA,IACL,MAAM,EAAE,QAAQ,eAAe,IAAI,OAAO,GAAG,GAAG,QAAQ;AAAA,IACxD,YAAY;AAAA,MACV,QAAQ,YAAY,IAChB,iDACA,WAAW,QAAQ,OAAO,KAAK,QAAQ,OAAO,aAAa,QAAQ,UAAU,mBAC5E,QAAQ,mBAAmB,MACxB,IAAI,QAAQ,QAAQ,cAAc,EAAE,GAAG,qCACvC;AAAA,MACR,GAAI,QAAQ,UAAU,IAClB,CAAC,GAAG,QAAQ,OAAO,8DAA8D,IACjF,CAAC;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/router/payments.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport { paidLedgerPath } from '../lib/paths';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { CommandContext, CommandResult } from '../context';\nimport { reconcilePayments } from './paid';\n\n/**\n * `tenjin payments reconcile`: settle every \"settlement unknown\" record in the\n * paid ledger that the chain can now answer for. The `request` tool runs the\n * same pass, three records at a time, before each lookup; this one asks about\n * up to {@link MAX_COMMAND_CHECKS}.\n *\n * A record found not charged also gives its amount back to the daily budget,\n * when the spend ledger still holds that payment's exposure in this window.\n */\n\nconst MAX_COMMAND_CHECKS = 50;\n\nexport interface PaymentsDeps {\n fetchImpl?: typeof fetch;\n now?: () => number;\n}\n\nexport async function runPaymentsReconcile(\n ctx: CommandContext,\n deps: PaymentsDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const outcome = await reconcilePayments(ctx.dataDir, {\n rpcUrl: settings.rpcUrl,\n max: MAX_COMMAND_CHECKS,\n // Asked for by hand: every due record, however recently it was asked about.\n recheckMs: 0,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n return {\n data: { ledger: paidLedgerPath(ctx.dataDir), ...outcome },\n humanLines: [\n outcome.checked === 0\n ? 'No paid lookup is waiting on its settlement.'\n : `Checked ${outcome.checked}: ${outcome.settled} charged, ${outcome.notCharged} not charged.` +\n (outcome.releasedAtomic !== '0'\n ? ` ${toMoney(outcome.releasedAtomic).usd} USD went back to today's limit.`\n : ''),\n ...(outcome.unknown > 0\n ? [`${outcome.unknown} still unknown: not expired yet, or the chain could not say.`]\n : []),\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAqB;AAO3B,eAAsB,qBACpB,KACA,OAAqB,CAAC,GACE;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,UAAU,MAAM,kBAAkB,IAAI,SAAS;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,KAAK;AAAA;AAAA,IAEL,WAAW;AAAA,IACX,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACpE,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,EACpD,CAAC;AACD,SAAO;AAAA,IACL,MAAM,EAAE,QAAQ,eAAe,IAAI,OAAO,GAAG,GAAG,QAAQ;AAAA,IACxD,YAAY;AAAA,MACV,QAAQ,YAAY,IAChB,iDACA,WAAW,QAAQ,OAAO,KAAK,QAAQ,OAAO,aAAa,QAAQ,UAAU,mBAC5E,QAAQ,mBAAmB,MACxB,IAAI,QAAQ,QAAQ,cAAc,EAAE,GAAG,qCACvC;AAAA,MACR,GAAI,QAAQ,UAAU,IAClB,CAAC,GAAG,QAAQ,OAAO,8DAA8D,IACjF,CAAC;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -10,14 +10,13 @@ import {
10
10
  broadcastUsdcSend,
11
11
  getUsdcBalance,
12
12
  prepareUsdcSend
13
- } from "./chunk-AQRUD5GQ.js";
14
- import "./chunk-QHILSA6G.js";
13
+ } from "./chunk-F4IJQBGP.js";
15
14
  import {
16
15
  describeWallet,
17
16
  resolveWalletProvider
18
- } from "./chunk-YVODPFTL.js";
19
- import "./chunk-N4DJEQAF.js";
20
- import "./chunk-U2ATFMKZ.js";
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,19 +29,19 @@ import {
30
29
  import "./chunk-KG3D7FIF.js";
31
30
  import "./chunk-RBJPAZFI.js";
32
31
  import "./chunk-BPMWXTFX.js";
33
- import "./chunk-QRFONFRW.js";
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-IOB7URFH.js";
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-W3LVZ2EN.js";
44
+ } from "./chunk-SAN5PFTL.js";
46
45
  import {
47
46
  CliError
48
47
  } from "./chunk-JLEF5WHM.js";
@@ -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-BXHFKDBF.js.map
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,GAAG;AACxE,iBA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AAA,uBACU,YAAY,EAAE,MAAM,CAAC;AAAA;AAE/C,MAAI,KAAK,YAAY,OAAW,QAAO,KAAK,QAAQ,MAAM;AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../src/commands/send.ts"],"sourcesContent":["import { formatEther, getAddress, isAddress, type Address } from 'viem';\nimport { SEND_MAX_UNSET } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { promptYesNo } from '../lib/prompt';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n broadcastUsdcSend,\n FeeCapExceededError,\n getUsdcBalance,\n prepareUsdcSend,\n SendPendingError,\n SendRevertedError,\n USDC_ADDRESS,\n} from '../lib/usdc';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin wallet send <amount> <token> <to>`: the escape hatch that moves funds OUT of\n * the agent wallet, complementary to delegation (which redirects future revenue\n * off the hot key; this is for a balance already on it). Invariants a reader\n * cannot derive from the code order alone:\n * - the confirm (buy's posture: interactive y/N, `--yes` bypasses the prompt\n * only, headless without it refuses) runs BEFORE the signer is resolved, so\n * no refusal branch ever touches key material;\n * - `sendMaxAmount` is a spend-policy gate, NOT satisfiable by --yes, and it\n * has NO default: unset refuses until `config set sendMaxAmount` is run\n * (require-set-before-first-send; \"none\" is an explicit uncapped opt-in);\n * - the verb is deliberately absent from the MCP toolset (spec 10's narrow\n * toolset) and the skill adapters — human-invoked only, both pinned by tests.\n */\n\nexport interface SendArgs {\n /** Decimal USD at the edge (O1 convention); converted to atomic exactly once. */\n amount: string;\n token: string;\n /** Recipient address, 0x-prefixed; checksummed or all-lowercase. */\n to: string;\n /** Skip the interactive confirm. REQUIRED to send when not at a TTY. */\n yes?: boolean;\n}\n\nexport interface SendDeps {\n /** Test seam: bypass the local wallet provider. */\n provider?: WalletProvider;\n /** Interactive-confirm seam; defaults to a TTY y/n prompt (same shape as buy). */\n confirm?: (prompt: string) => Promise<boolean>;\n}\n\nconst ZERO_ADDRESS: Address = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS: Address = '0x000000000000000000000000000000000000dEaD';\n\nexport async function runSend(\n args: SendArgs,\n ctx: CommandContext,\n deps: SendDeps = {},\n): Promise<CommandResult> {\n requireUsdc(args.token);\n const amountAtomic = BigInt(parseUsdToAtomic(args.amount));\n if (amountAtomic === 0n) {\n throw new CliError('USAGE', 'The send amount must be greater than zero.', {\n fix: 'Pass a positive decimal USDC amount, e.g. `tenjin wallet send 5 usdc <to>`.',\n });\n }\n const to = parseRecipient(args.to);\n\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n // Address + posture only; surfaces WALLET_MISSING. No key material yet.\n const desc = await describeWallet(provider);\n if (to.toLowerCase() === desc.address.toLowerCase()) {\n throw new CliError('USAGE', 'The recipient is this wallet itself.', {\n fix: 'Pass the destination wallet address, not the sending one.',\n });\n }\n\n const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);\n enforceSendCap(amountAtomic, sendMaxAmountAtomic);\n\n let balance: bigint;\n try {\n balance = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (amountAtomic > balance) {\n throw new CliError('REFUSED', 'The amount exceeds the wallet USDC balance.', {\n fix: 'Check `tenjin wallet balance` and send at most that amount.',\n details: {\n requested: toMoney(amountAtomic.toString()),\n balance: toMoney(balance.toString()),\n },\n });\n }\n\n // Read-only chain prep before the confirm, so the prompt can show the fee and\n // a wallet without gas refuses before asking anyone to approve anything.\n let prepared;\n try {\n prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });\n } catch (err) {\n if (err instanceof FeeCapExceededError) {\n throw new CliError('REFUSED', 'The RPC gas/fee estimate is abnormal for Base; refusing.', {\n fix: 'Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking — wait and retry.',\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'Could not prepare the transfer on Base.', {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (prepared.ethBalanceWei < prepared.feeWei) {\n throw new CliError('REFUSED', 'The wallet has no ETH on Base to pay the network fee.', {\n fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,\n details: {\n ethBalanceWei: prepared.ethBalanceWei.toString(),\n feeWei: prepared.feeWei.toString(),\n },\n });\n }\n\n const approved = await confirmSend(ctx, deps, args.yes === true, {\n amountAtomic,\n to,\n from: desc.address,\n feeWei: prepared.feeWei,\n });\n if (!approved) {\n throw new CliError('REFUSED', 'Send not confirmed.', {\n fix: 'Verify the recipient and amount, then re-run with --yes to approve this transfer.',\n details: { to, amount: toMoney(amountAtomic.toString()) },\n });\n }\n\n // The only door to the key; a missing passphrase entry refuses here with the\n // provider's coded error. The signer must be the wallet the human just saw:\n // the local provider guarantees it, a hosted one is only trusted after this.\n const signer = await provider.getSigner();\n if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {\n throw new CliError(\n 'PROVIDER_ERROR',\n `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,\n { fix: 'The wallet changed between preview and signing; re-run `tenjin wallet send`.' },\n );\n }\n\n let txHash: string;\n try {\n txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });\n } catch (err) {\n if (err instanceof SendRevertedError) {\n throw new CliError('SEND_FAILED', 'The transfer was mined but reverted; no USDC moved.', {\n fix: 'Check the transaction on a Base explorer, then retry if the cause is transient.',\n details: { txHash: err.txHash },\n cause: err,\n });\n }\n if (err instanceof SendPendingError) {\n throw new CliError('SEND_FAILED', 'The transfer was broadcast but not confirmed in time.', {\n fix: 'Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.',\n details: { txHash: err.txHash, pending: true },\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'The transfer could not be sent on Base.', {\n fix: 'Check the network and RPC, then retry.',\n cause: err,\n });\n }\n\n const amount = toMoney(amountAtomic.toString());\n return {\n data: { txHash, from: signer.address, to, token: 'USDC', network: 'base', amount },\n humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`],\n };\n}\n\n/**\n * The hard per-send cap (`config set sendMaxAmount`): a policy gate, not a\n * confirm — no branch here is satisfiable by --yes. There is no default cap:\n * an unset key refuses (require-set-before-first-send), exactly as strict as\n * the set-cap refusals below.\n */\nfunction enforceSendCap(\n amountAtomic: bigint,\n capAtomic: bigint | null | typeof SEND_MAX_UNSET,\n): void {\n if (capAtomic === SEND_MAX_UNSET) {\n throw new CliError(\n 'POLICY_REFUSED',\n 'No sendMaxAmount is configured; a per-send cap must be set before the first send.',\n {\n fix: 'Run `tenjin config set sendMaxAmount <usd>` (or `0` to disable send, or `none` to opt in to uncapped), then retry. --yes does not bypass this.',\n },\n );\n }\n if (capAtomic === null) return;\n if (capAtomic === 0n) {\n throw new CliError('POLICY_REFUSED', 'Sending is disabled by sendMaxAmount = 0.', {\n fix: 'Run `tenjin config set sendMaxAmount <usd|none>` to allow sends.',\n });\n }\n if (amountAtomic > capAtomic) {\n throw new CliError('POLICY_REFUSED', 'The amount exceeds the sendMaxAmount cap.', {\n fix: 'Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.',\n details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) },\n });\n }\n}\n\n/** USDC on Base only; anything else is a usage error, not a guess. */\nfunction requireUsdc(token: string): void {\n if (token.trim().toLowerCase() === 'usdc') return;\n throw new CliError('USAGE', `Unsupported token: ${JSON.stringify(token)}`, {\n fix: 'Only USDC on Base is supported: `tenjin wallet send <amount> usdc <to>`.',\n });\n}\n\n/**\n * Validate and resolve the recipient. Strict `isAddress` refuses malformed input\n * and a bad EIP-55 checksum on MIXED-CASE input (all-lowercase input carries no\n * checksum to verify — that limit is inherent to the format); `getAddress` then\n * yields the checksummed form the preview shows and the transfer targets. Known\n * fund-destroying destinations (the USDC contract, the zero address, the burn\n * address) refuse outright.\n */\nfunction parseRecipient(raw: string): Address {\n const trimmed = raw.trim();\n if (!isAddress(trimmed)) {\n throw new CliError('USAGE', `Invalid recipient address: ${JSON.stringify(raw)}`, {\n fix: 'Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check).',\n });\n }\n const to = getAddress(trimmed);\n if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {\n throw new CliError('USAGE', 'The recipient is a known fund-destroying address.', {\n fix: 'Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address.',\n });\n }\n return to;\n}\n\ninterface ConfirmDetails {\n amountAtomic: bigint;\n to: Address;\n from: Address;\n feeWei: bigint;\n}\n\n/** Buy's confirm posture; the preview names the resolved recipient, amount, and fee. */\nasync function confirmSend(\n ctx: CommandContext,\n deps: SendDeps,\n yes: boolean,\n d: ConfirmDetails,\n): Promise<boolean> {\n if (yes) return true;\n const prompt =\n `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base\\n` +\n ` from ${d.from}\\n` +\n ` to ${d.to}\\n` +\n ` network fee up to ~${formatEther(d.feeWei)} ETH\\n` +\n `This moves funds out of the agent wallet and cannot be undone. [y/N] `;\n if (deps.confirm !== undefined) return deps.confirm(prompt);\n // Both streams must be real TTYs; piped stdin/stdout without --yes refuses.\n if (!ctx.io.isTTY || !process.stdin.isTTY) return false;\n return promptYesNo(prompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAM,eAA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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-N4DJEQAF.js";
2
+ import "./chunk-NYJCBQL5.js";
3
3
  import {
4
4
  readSpendSummary,
5
5
  spentOf
6
- } from "./chunk-U2ATFMKZ.js";
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-IOB7URFH.js";
11
+ } from "./chunk-UHEMZEGW.js";
12
12
  import {
13
13
  toMoney
14
14
  } from "./chunk-O2JYBOUO.js";
@@ -16,7 +16,7 @@ import {
16
16
  RETIRED_PAYMENT_GUIDANCE,
17
17
  loadRawConfig,
18
18
  retiredPaymentKeys
19
- } from "./chunk-W3LVZ2EN.js";
19
+ } from "./chunk-SAN5PFTL.js";
20
20
  import "./chunk-JLEF5WHM.js";
21
21
  import "./chunk-K6AXXYCG.js";
22
22
  import "./chunk-ZXTAQYNA.js";
@@ -68,4 +68,4 @@ async function runRouterStatus(ctx, deps = {}) {
68
68
  export {
69
69
  runRouterStatus
70
70
  };
71
- //# sourceMappingURL=status-3Z3YPRSE.js.map
71
+ //# sourceMappingURL=status-CEHZKHBU.js.map
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-QF4SSCQV.js";
5
5
  import {
6
6
  routerSettings
7
- } from "./chunk-C363JZN2.js";
8
- import "./chunk-IOB7URFH.js";
7
+ } from "./chunk-XBYTP4SP.js";
8
+ import "./chunk-UHEMZEGW.js";
9
9
  import "./chunk-O2JYBOUO.js";
10
- import "./chunk-W3LVZ2EN.js";
10
+ import "./chunk-SAN5PFTL.js";
11
11
  import "./chunk-JLEF5WHM.js";
12
12
  import "./chunk-K6AXXYCG.js";
13
13
  import "./chunk-ZXTAQYNA.js";
@@ -84,4 +84,4 @@ export {
84
84
  runStatusLine,
85
85
  statusLineMain
86
86
  };
87
- //# sourceMappingURL=status-line-CKRMGZ3Q.js.map
87
+ //# sourceMappingURL=status-line-QRAO3Y2E.js.map
@@ -9,9 +9,9 @@ import {
9
9
  inspectStatusLine,
10
10
  removeStatusLine,
11
11
  statusLineMode
12
- } from "./chunk-JN7TMXVF.js";
13
- import "./chunk-IOIHYOU4.js";
14
- import "./chunk-RCJQARZF.js";
12
+ } from "./chunk-HJYI52HM.js";
13
+ import "./chunk-6O6DFYF3.js";
14
+ import "./chunk-RA2J3TWG.js";
15
15
  import "./chunk-JLEF5WHM.js";
16
16
  import "./chunk-K6AXXYCG.js";
17
17
  import "./chunk-ZXTAQYNA.js";
@@ -26,4 +26,4 @@ export {
26
26
  removeStatusLine,
27
27
  statusLineMode
28
28
  };
29
- //# sourceMappingURL=status-line-wiring-GECLIIBT.js.map
29
+ //# sourceMappingURL=status-line-wiring-7D2CSV3K.js.map
@@ -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.21",
14
+ version: "0.1.0-alpha.23",
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.",
@@ -16586,6 +16586,9 @@ function daemonLogPath(dir = dataDir()) {
16586
16586
  // src/adapters/types.ts
16587
16587
  var HARNESSES = ["claude", "codex"];
16588
16588
 
16589
+ // src/lib/usdc-balance.ts
16590
+ var DEFAULT_RPC_URL = "https://mainnet.base.org";
16591
+
16589
16592
  // src/lib/config.ts
16590
16593
  var atomicString = external_exports.string().regex(/^\d+$/, "expected an atomic USDC integer string");
16591
16594
  var PublishModeSchema = external_exports.enum(["review", "auto", "full-auto"]);
@@ -16765,7 +16768,7 @@ var CONFIG_DEFAULTS = {
16765
16768
  publicShelfUrl: PRODUCTION_ORIGIN,
16766
16769
  // Empty = public mode. Setting it is the whole of "turn on team mode".
16767
16770
  shelfBypassSecret: "",
16768
- rpcUrl: "https://mainnet.base.org",
16771
+ rpcUrl: DEFAULT_RPC_URL,
16769
16772
  evalCohort: false,
16770
16773
  bazaarRegistries: DEFAULT_BAZAAR_REGISTRIES,
16771
16774
  publish: { mode: "review", defaultPrice: "100000", ackServerWarnings: "mode" },
@@ -5,31 +5,31 @@ import {
5
5
  mcpScope,
6
6
  readMcpEntry,
7
7
  routerSettingsPath
8
- } from "./chunk-OSUD6YZZ.js";
8
+ } from "./chunk-Y3LKUXZA.js";
9
9
  import {
10
10
  MCP_SERVER_NAME
11
11
  } from "./chunk-TGLKKLQG.js";
12
- import "./chunk-QRFONFRW.js";
12
+ import "./chunk-UGLTSPXQ.js";
13
13
  import {
14
14
  onPath,
15
15
  persistRouterProject
16
- } from "./chunk-OTPEH3AH.js";
16
+ } from "./chunk-I2GBBIDI.js";
17
17
  import "./chunk-A36LQPHV.js";
18
18
  import "./chunk-2QYORQBF.js";
19
19
  import "./chunk-MEFB5KHA.js";
20
- import "./chunk-C363JZN2.js";
20
+ import "./chunk-XBYTP4SP.js";
21
21
  import "./chunk-2I4QTOLB.js";
22
- import "./chunk-IOB7URFH.js";
22
+ import "./chunk-UHEMZEGW.js";
23
23
  import "./chunk-O2JYBOUO.js";
24
- import "./chunk-W3LVZ2EN.js";
24
+ import "./chunk-SAN5PFTL.js";
25
25
  import {
26
26
  removeStatusLine
27
- } from "./chunk-JN7TMXVF.js";
27
+ } from "./chunk-HJYI52HM.js";
28
28
  import {
29
29
  inspectHooksFile,
30
30
  pruneHooks
31
- } from "./chunk-IOIHYOU4.js";
32
- import "./chunk-RCJQARZF.js";
31
+ } from "./chunk-6O6DFYF3.js";
32
+ import "./chunk-RA2J3TWG.js";
33
33
  import {
34
34
  writeFileAtomic
35
35
  } from "./chunk-JLEF5WHM.js";
@@ -162,4 +162,4 @@ export {
162
162
  MCP_REMOVE_COMMAND,
163
163
  runRouterUninstall
164
164
  };
165
- //# sourceMappingURL=uninstall-BZTVWJ7W.js.map
165
+ //# sourceMappingURL=uninstall-VR44B4KD.js.map
@@ -5,15 +5,15 @@ import {
5
5
  fetchDistTags,
6
6
  isNewer,
7
7
  resolveTarget
8
- } from "./chunk-3EUTWC2B.js";
8
+ } from "./chunk-N7A5EXJZ.js";
9
9
  import {
10
10
  emitWriteNotice,
11
11
  sanitizeForTerminal
12
- } from "./chunk-QRFONFRW.js";
13
- import "./chunk-W3LVZ2EN.js";
12
+ } from "./chunk-UGLTSPXQ.js";
13
+ import "./chunk-SAN5PFTL.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-RCJQARZF.js";
16
+ } from "./chunk-RA2J3TWG.js";
17
17
  import {
18
18
  CliError
19
19
  } from "./chunk-JLEF5WHM.js";
@@ -430,4 +430,4 @@ export {
430
430
  spawnCapture,
431
431
  versionFreeEntry
432
432
  };
433
- //# sourceMappingURL=update-IQQTEOI5.js.map
433
+ //# sourceMappingURL=update-SOYQLDBF.js.map
@@ -3,12 +3,11 @@ import {
3
3
  runWalletBalance,
4
4
  runWalletCreate,
5
5
  runWalletShow
6
- } from "./chunk-PJEG2JIJ.js";
7
- import "./chunk-AQRUD5GQ.js";
8
- import "./chunk-QHILSA6G.js";
9
- import "./chunk-YVODPFTL.js";
10
- import "./chunk-N4DJEQAF.js";
11
- import "./chunk-U2ATFMKZ.js";
6
+ } from "./chunk-2RMXTNLT.js";
7
+ import "./chunk-F4IJQBGP.js";
8
+ import "./chunk-DHCOGDJB.js";
9
+ import "./chunk-NYJCBQL5.js";
10
+ import "./chunk-WXFVJPZD.js";
12
11
  import "./chunk-AWQPGIR6.js";
13
12
  import "./chunk-N35E6CM2.js";
14
13
  import "./chunk-JRGFKVAZ.js";
@@ -17,11 +16,11 @@ import "./chunk-EGELTSPU.js";
17
16
  import "./chunk-KG3D7FIF.js";
18
17
  import "./chunk-RBJPAZFI.js";
19
18
  import "./chunk-BPMWXTFX.js";
20
- import "./chunk-QRFONFRW.js";
19
+ import "./chunk-UGLTSPXQ.js";
21
20
  import "./chunk-MEFB5KHA.js";
22
21
  import "./chunk-2I4QTOLB.js";
23
22
  import "./chunk-O2JYBOUO.js";
24
- import "./chunk-W3LVZ2EN.js";
23
+ import "./chunk-SAN5PFTL.js";
25
24
  import "./chunk-JLEF5WHM.js";
26
25
  import "./chunk-K6AXXYCG.js";
27
26
  import "./chunk-ZXTAQYNA.js";
@@ -30,4 +29,4 @@ export {
30
29
  runWalletCreate,
31
30
  runWalletShow
32
31
  };
33
- //# sourceMappingURL=wallet-UFXQ57TZ.js.map
32
+ //# sourceMappingURL=wallet-IB2EFAUP.js.map
@@ -37,7 +37,7 @@ tenjin config set sessionBudget 2.00
37
37
  The routing decision comes from a server, and it is free: it proposes, it never authorizes. These checks are what keep a wrong or hostile one from being worth anything:
38
38
 
39
39
  - The amount actually signed has to fit `maxAutoSpend` and the day's `sessionBudget`. A live price above the one the decision quoted is refused before anything is signed, so a provider or a stale catalog cannot charge more than it advertised; a hostile server sets that quote itself, so against one the bound stays `maxAutoSpend`.
40
- - The backend binds the call and validates its arguments against the capability's own schema, then sends the finished request; this CLI sends it as given and never rebuilds it, so there is no second copy of that rule here to drift from the first.
40
+ - An offer carries the service's spec: its input schema, the fields Tenjin pins, and the HTTP request those fields become. Your assistant fills the fields; this CLI puts the pins over them, validates the result against the schema, builds the request and pays the spec's own payee, never above the spec's price ceiling. A lookup that comes without a spec (a free one, or an older offer) is bound by the backend, which sends the finished request for this CLI to send as given.
41
41
  - The destination has to be a public HTTPS endpoint whose name resolves to a public address. This is a check, not a pin: the request resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. See [safety-model.md](./safety-model.md).
42
42
  - A 2xx whose body fails the decision's own success rule is delivered as `unverified`, never `fulfilled`, with a caveat naming the rule it missed. The money has already moved, so the body is not withheld.
43
43
 
@@ -67,9 +67,9 @@ tenjin pay https://api.example.com/quote --json --max-price 0.05 --ignore-warnin
67
67
 
68
68
  Both flags still obey the optional explicit `--max-price` cap, destination and supported-challenge checks, and the authoritative wallet balance check. Warnings and acknowledgement status remain in JSON output. Each paid invocation can spend again; there is no purchase-library dedupe. Free or SIWX-entitled delivery needs neither warning acknowledgement nor a payment balance read.
69
69
 
70
- Router calls cannot use `--ignore-warnings`. They require their offered price and retain hard checks for any supplied network, asset or recipient. The current server protocol supplies price only; this release does not claim complete endpoint/payee quote binding.
70
+ Router calls cannot use `--ignore-warnings`. They require their offered price and retain hard checks for any supplied network, asset or recipient. An offer's spec supplies all four, so the live 402 has to match its recipient, network and asset and stay within its price; a lookup without a spec gets its price alone from the server, and for it this release does not claim complete endpoint/payee quote binding.
71
71
 
72
- Immediately before signing a positive payment, the CLI reads the actual signer's Base USDC balance through the configured RPC. An unreadable balance gets one retry within the original deadline. Confirmed insufficient funds or two unreadable results refuse, releases the reservation and counts no spend. Hook balance reads are advisory and bounded: prompt, pre-call, after-call and subagent offers are suppressed for known insufficient funds or policy refusal. A hook reuses a read from the last minute (`balance.json`, the address and amount only); the payment's read never does. A successful balance read cannot reserve funds or guarantee settlement after concurrent transfers.
72
+ Immediately before signing a positive payment, the CLI reads the actual signer's Base USDC balance through the configured RPC; on the shipped default, `https://base-rpc.publicnode.com` and then `https://base.drpc.org` are asked if it fails. An unreadable balance gets one retry within the original deadline. Confirmed insufficient funds or two unreadable results refuse, releases the reservation and counts no spend. Hook balance reads are advisory and bounded: prompt, pre-call, after-call and subagent offers are suppressed for known insufficient funds or policy refusal. A hook reuses a read from the last minute (`balance.json`, the address and amount only); the payment's read never does. A successful balance read cannot reserve funds or guarantee settlement after concurrent transfers.
73
73
 
74
74
  ## Never recommended
75
75
 
@@ -103,15 +103,14 @@ To stop the router without removing anything, `tenjin config set router.enabled
103
103
  ## How one lookup runs
104
104
 
105
105
  1. You type a turn. The hook sends the bounded packet to Tenjin, which answers whether a paid capability fits and, if it does, keeps that packet under a short-lived id.
106
- 2. When one fits, your assistant sees one line, opening with `Tenjin router (installed by the user):`, that names the service and the call to make: `mcp__x402__request` with your exact lookup and that id.
107
- 3. Your assistant calls `request({query, id})` with the lookup it actually means. That is the accurate part: the routing is decided from your assistant's own query plus the stored context, not from a guess made before the lookup was known.
108
- 4. Tenjin answers with the call to make and what the provider charges. Deciding costs nothing.
109
- 5. This CLI pays that provider once, under your limits, and hands back the result.
106
+ 2. When one fits, your assistant sees one line, opening with `Tenjin router (installed by the user):`, that names the service, its price and the call to make: `mcp__x402__request({id, input})` with the required fields as placeholders, or already filled in when the hook holds them (the search a native call was about to run, or the page it was about to fetch). The hook keeps the service's spec on this machine under the id.
107
+ 3. Your assistant fills the fields and calls `request({id, input})` once. This CLI validates the input against the spec, builds the request, pays that provider once under your limits, hands back the result, and tells Tenjin only how the call ended. Deciding costs nothing. Where the spec names the fields its result promises, the result holds only those, and the provider's whole response is saved under `~/.tenjin/results/` (readable by you alone, kept a day) at the path the result names in `fullResultPath`.
108
+ 4. An input that does not fit the spec is refused before anything is sent: your assistant gets every problem and the whole spec (each input with its description and allowed values, the required fields inside a nested object, an example and what comes back), locally and with nothing paid, and calls again. `request({id})` alone shows the same spec. A spec whose input schema this CLI cannot compile is refused outright, with nothing sent or paid.
110
109
 
111
110
  ## What the hooks send
112
111
 
113
112
  - On every prompt and every native `WebSearch` or `WebFetch`: the text of the current turn and at most six prior messages, masked by the same key, PEM, seed-phrase, and URL credential rules the publish scan uses, then bounded to 16 KiB, with harness meta rows and tool results excluded. Tool results never travel: a tool result is other people's content, and a packet carrying it would be a channel from a fetched page into a routing decision.
114
- - A native call sends that same bounded turn WITH the call attached, read from this session's own transcript. That is how a restriction you stated in your own words, such as asking for native tools only, reaches the decision about a bare URL your assistant is fetching. When that call then comes back short and nothing was offered before it, it is sent once more with what the harness reported: the status code and byte count, or the error. Never the page or the results. A call that came back fine sends nothing more.
113
+ - A native call sends that same bounded turn WITH the call attached, read from this session's own transcript. That is how a restriction you stated in your own words, such as asking for native tools only, reaches the decision about a bare URL your assistant is fetching. When that call then comes back short and nothing was offered before it, it is sent once more with what the harness reported: the status code and byte count, the error, or that a fetch came back with only the page's shell (`reason: no_main_content`). Never the page or the results. A call that came back fine sends nothing more.
115
114
  - When your assistant hands a task to a subagent: that task, as the current message, with the same bounded turn before it.
116
115
  - When your assistant asks you a question (`AskUserQuestion`): the questions and their options, attached to the same bounded turn, before you see them; and after you answer, your answers as the current message. Before the question, a fitting lookup redirects it once, under the same rules as a native call, and only when your spend limits and wallet would pay it without asking you; after it, a fitting lookup is offered beside your answers.
117
116
  - Every hook request carries this session's id, so one session is not offered the same pay-per-call service twice.
@@ -119,6 +118,7 @@ To stop the router without removing anything, `tenjin config set router.enabled
119
118
  - Slash commands and one-word acknowledgements are never sent at all.
120
119
  - The packet is stored on the backend against the decision id, so the lookup your assistant sends next is decided with the context you gave. Expired packets are unreadable after 15 minutes (the route refuses an expired id) and are deleted by the next router request or the daily cleanup, whichever comes first.
121
120
  - On a paid lookup: the capability chosen, a hash of the contract, a hash of the arguments, your wallet address, the amount and the transaction hash are kept.
121
+ - On a call run from an offer's spec, once it ran or money left: the offer's id, how the call ended, the provider's HTTP status and how long it took. Never the input or the result.
122
122
 
123
123
  The answer can put one line into your session, or into a task your assistant delegates: the service that fits, what it does, its listed price, and the `mcp__x402__request` call carrying the id that brings your context to it. The line says it comes from the Tenjin router you installed, and it is an option: your assistant's own tools keep working. Which service actually runs, and what it costs, is decided when your assistant makes that call, under your spend policy.
124
124
 
@@ -21,11 +21,11 @@ Do not copy commands from purchased content into an allowlist, `AGENTS.md`, `CLA
21
21
 
22
22
  Search, inspect, free reads, outcomes, wallet display, balance checks, doctor, and checkout-link creation are separated from purchases and transfers.
23
23
 
24
- The x402 router's `request` tool and `tenjin pay` are the paying commands, and they run one gate between them: `maxAutoSpend` and `sessionBudget` as limits on automatic router spending only, mandatory consent for manual pay, and a reservation that counts a signed authorization as spent the moment it leaves. A router lookup is ONE payment, to the provider: deciding where to route costs nothing and nobody signs for it. The boundary is split on purpose: the backend binds the call and validates its arguments against the capability's own schema, and this client checks the three things only it can: the amount signed against the spend caps, the body that comes back against the success rule the decision carries, and the destination resolving to a public address. That destination check is a check, not a pin, for the paid request: it resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. The router's download of media a discovered service links to does pin: it connects to the address it validated, on every redirect hop. `--max-price` is always a hard cap on `tenjin pay`. Every automatic authorization that LEAVES the process counts against the automatic session budget until the 24 hour window rolls, even where the provider never settles it: a signed EIP-3009 authorization is a bearer instrument, so a 200 that reports no match, or a 402 that rejects the payment, is the counterparty saying it did not take the money rather than proof that it cannot. Manual exposure remains recorded in the same ledger but does not consume automatic headroom. Older records without a mode or automatic counter count conservatively as automatic. The budget is deliberately the conservative side of that, and a caller can be left with less headroom than it actually spent. The one release is proof from the chain, not the counterparty: `tenjin payments reconcile` (and the `request` tool, for up to three records beside each lookup) gives an authorization's amount back only when USDC's `authorizationState` shows it unused at a block whose timestamp is past its `validBefore`, so it can never be charged, and only inside the window that counted it, once per nonce.
24
+ The x402 router's `request` tool and `tenjin pay` are the paying commands, and they run one gate between them: `maxAutoSpend` and `sessionBudget` as limits on automatic router spending only, mandatory consent for manual pay, and a reservation that counts a signed authorization as spent the moment it leaves. A router lookup is ONE payment, to the provider: deciding where to route costs nothing and nobody signs for it. The boundary is split on purpose: an offer's spec carries the service's schema, pinned fields and request shape, and this client validates the agent's input against it and builds the call (a lookup without a spec is bound by the backend, as before); this client alone checks the three things only it can: the amount signed against the spend caps, the body that comes back against the success rule the decision carries, and the destination resolving to a public address. That destination check is a check, not a pin, for the paid request: it resolves the name again on its own, so a host that answers publicly at check time and privately a moment later is not closed by it. The router's download of media a discovered service links to does pin: it connects to the address it validated, on every redirect hop. `--max-price` is always a hard cap on `tenjin pay`. Every automatic authorization that LEAVES the process counts against the automatic session budget until the 24 hour window rolls, even where the provider never settles it: a signed EIP-3009 authorization is a bearer instrument, so a 200 that reports no match, or a 402 that rejects the payment, is the counterparty saying it did not take the money rather than proof that it cannot. Manual exposure remains recorded in the same ledger but does not consume automatic headroom. Older records without a mode or automatic counter count conservatively as automatic. The budget is deliberately the conservative side of that, and a caller can be left with less headroom than it actually spent. The one release is proof from the chain, not the counterparty: `tenjin payments reconcile` (and the `request` tool, for up to three records beside each lookup) gives an authorization's amount back only when USDC's `authorizationState` shows it unused at a block whose timestamp is past its `validBefore`, so it can never be charged, and only inside the window that counted it, once per nonce.
25
25
 
26
26
  The automatic daily limit is zero, a finite amount or `none`: zero blocks positive automatic payments and `none` removes that ceiling while retaining reservations and duplicate protection. Manual pay requires explicit user consent and is subject to neither automatic limit. Retired `bazaarPay` and `confirm` values are ignored after upgrade; doctor/status warn, and install/refresh remove and report them while preserving current controls and unrelated fields.
27
27
 
28
- Direct third-party payments use the supported live 402 quote. Unavailable/incomplete verification and differences from an exact listing block payment unless this invocation supplies `--ignore-warnings`. Missing listings or a missing Bazaar extension require no warning or flag. Warnings remain visible and structured in JSON. This flag acknowledges registry evidence only; `--yes` confirms payment only. Manual pay requires explicit user consent regardless of configured automatic limits and must never be an autonomous workaround for router refusal. Neither flag bypasses an explicit price cap, supported challenge, destination checks or balance check. Router payments retain the offered-price ceiling and hard checks on supplied terms, with no direct-payment fallback. The current price-only protocol does not provide complete endpoint/payee quote binding.
28
+ Direct third-party payments use the supported live 402 quote. Unavailable/incomplete verification and differences from an exact listing block payment unless this invocation supplies `--ignore-warnings`. Missing listings or a missing Bazaar extension require no warning or flag. Warnings remain visible and structured in JSON. This flag acknowledges registry evidence only; `--yes` confirms payment only. Manual pay requires explicit user consent regardless of configured automatic limits and must never be an autonomous workaround for router refusal. Neither flag bypasses an explicit price cap, supported challenge, destination checks or balance check. Router payments retain the offered-price ceiling and hard checks on supplied terms, with no direct-payment fallback. An offer's spec supplies the recipient, network and asset beside the price, and the live 402 has to match them; a lookup without a spec is quoted on price alone, which does not provide complete endpoint/payee quote binding.
29
29
 
30
30
  After policy confirmation and immediately before signing, the actual signer's USDC balance must be readable and sufficient. Refusal releases the reservation and does not count spend; free and entitled delivery skips this read. The hook's bounded advisory read suppresses known unusable offers but does not authorize payment. Balances can change after a read, so settlement is not guaranteed. Once a payment authorization is transmitted, the conservative accounting described above applies, with that one chain-proven release.
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenjin-cli",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.23",
4
4
  "mcpName": "blog.tenjin/tenjin",
5
5
  "type": "module",
6
6
  "description": "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.",