tenjin-cli 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (157) hide show
  1. package/README.md +322 -197
  2. package/dist/{_esm-FEASBWRP.js → _esm-N4KAVXQR.js} +9 -9
  3. package/dist/buy-YMXXVNFH.js +42 -0
  4. package/dist/candidate-H7FR4AU5.js +22 -0
  5. package/dist/{ccip-XR5NE5QK.js → ccip-RPPPKTJR.js} +5 -5
  6. package/dist/{ccip-NQXCEK2U.js → ccip-ZGGWQN4X.js} +4 -4
  7. package/dist/{chunk-MUBUQVC3.js → chunk-2JQ5JSG6.js} +3 -2
  8. package/dist/{chunk-MUBUQVC3.js.map → chunk-2JQ5JSG6.js.map} +1 -1
  9. package/dist/{chunk-662MSGZB.js → chunk-3IRDP7TN.js} +100 -66
  10. package/dist/chunk-3IRDP7TN.js.map +1 -0
  11. package/dist/{chunk-YALGASEU.js → chunk-47PP7TAG.js} +1610 -1610
  12. package/dist/chunk-47PP7TAG.js.map +1 -0
  13. package/dist/{buy-EE6SEXP6.js → chunk-4WVKXKDK.js} +27 -59
  14. package/dist/chunk-4WVKXKDK.js.map +1 -0
  15. package/dist/chunk-5SCU253N.js +412 -0
  16. package/dist/chunk-5SCU253N.js.map +1 -0
  17. package/dist/{chunk-UGX7YPX2.js → chunk-7FK2UN2T.js} +65 -65
  18. package/dist/{chunk-UGX7YPX2.js.map → chunk-7FK2UN2T.js.map} +1 -1
  19. package/dist/chunk-ADJYSM45.js +135 -0
  20. package/dist/chunk-ADJYSM45.js.map +1 -0
  21. package/dist/{chunk-DXTQ3CSI.js → chunk-BIKAUVC2.js} +43 -11
  22. package/dist/chunk-BIKAUVC2.js.map +1 -0
  23. package/dist/{chunk-Z6MFJV5Z.js → chunk-C444K6MI.js} +266 -55
  24. package/dist/chunk-C444K6MI.js.map +1 -0
  25. package/dist/{chunk-JPHG2JW3.js → chunk-CVX6JNGD.js} +26 -26
  26. package/dist/chunk-CVX6JNGD.js.map +1 -0
  27. package/dist/{chunk-S3IGX57D.js → chunk-FU6MCSLG.js} +9 -9
  28. package/dist/{lookup-ZPN2Q67N.js → chunk-HTDALK7M.js} +46 -32
  29. package/dist/chunk-HTDALK7M.js.map +1 -0
  30. package/dist/chunk-IOPWPMT2.js +239 -0
  31. package/dist/chunk-IOPWPMT2.js.map +1 -0
  32. package/dist/{chunk-5CLSD5YN.js → chunk-KYQVEKP5.js} +7 -7
  33. package/dist/{chunk-RRN3YTK7.js → chunk-KZAAWQNP.js} +3 -3
  34. package/dist/{chunk-7KUW4MJD.js → chunk-L4IHCN6B.js} +11 -7
  35. package/dist/chunk-L4IHCN6B.js.map +1 -0
  36. package/dist/{chunk-XHC6FCGZ.js → chunk-LAM66WFJ.js} +25 -11
  37. package/dist/chunk-LAM66WFJ.js.map +1 -0
  38. package/dist/{chunk-NCE5NSN6.js → chunk-M2O56UK7.js} +158 -158
  39. package/dist/chunk-M2O56UK7.js.map +1 -0
  40. package/dist/{chunk-GO75V3NZ.js → chunk-MDDGEGSW.js} +8 -6
  41. package/dist/chunk-MDDGEGSW.js.map +1 -0
  42. package/dist/{chunk-XJIW7USF.js → chunk-MJZZTKCC.js} +112 -6
  43. package/dist/chunk-MJZZTKCC.js.map +1 -0
  44. package/dist/{chunk-Z52RA3NC.js → chunk-NFSOVL3C.js} +51 -21
  45. package/dist/chunk-NFSOVL3C.js.map +1 -0
  46. package/dist/{chunk-FJPLRISB.js → chunk-NJF2WENW.js} +5 -4
  47. package/dist/chunk-NJF2WENW.js.map +1 -0
  48. package/dist/{chunk-OYMYCW7J.js → chunk-PAUXMRSF.js} +45 -4
  49. package/dist/{chunk-OYMYCW7J.js.map → chunk-PAUXMRSF.js.map} +1 -1
  50. package/dist/{chunk-ZABPQJ3M.js → chunk-POJRB2AE.js} +2 -2
  51. package/dist/{publish-BKBQQAW4.js → chunk-PYNSGYBE.js} +254 -57
  52. package/dist/chunk-PYNSGYBE.js.map +1 -0
  53. package/dist/{chunk-YN5SHIXQ.js → chunk-QONTBYQW.js} +12 -9
  54. package/dist/chunk-QONTBYQW.js.map +1 -0
  55. package/dist/chunk-QW2Q2KAH.js +27 -0
  56. package/dist/chunk-QW2Q2KAH.js.map +1 -0
  57. package/dist/chunk-RTJLLPFA.js +599 -0
  58. package/dist/chunk-RTJLLPFA.js.map +1 -0
  59. package/dist/{chunk-CYOF7ROH.js → chunk-S5RYMCV6.js} +3 -3
  60. package/dist/chunk-TXPPMK4L.js +59 -0
  61. package/dist/chunk-TXPPMK4L.js.map +1 -0
  62. package/dist/{chunk-ZMHYXMO6.js → chunk-U5S527PP.js} +3 -3
  63. package/dist/{chunk-RY4XKNV3.js → chunk-UHTVXQ2O.js} +3 -3
  64. package/dist/{chunk-QVX5MWJZ.js → chunk-W6R3HAAG.js} +2 -2
  65. package/dist/{chunk-3OV7E5G5.js → chunk-WWX32ML4.js} +1 -1
  66. package/dist/{chunk-3OV7E5G5.js.map → chunk-WWX32ML4.js.map} +1 -1
  67. package/dist/{chunk-HIVZG55D.js → chunk-XJN5WUKL.js} +2 -2
  68. package/dist/{chunk-HSDCI7OV.js → chunk-YLYINX2H.js} +3 -3
  69. package/dist/{chunk-4ONXEEQL.js → chunk-ZDY2KY5X.js} +2 -2
  70. package/dist/{chunk-4ONXEEQL.js.map → chunk-ZDY2KY5X.js.map} +1 -1
  71. package/dist/{chunk-TLCMMYLY.js → chunk-ZIYVN4CD.js} +6 -6
  72. package/dist/chunk-ZIYVN4CD.js.map +1 -0
  73. package/dist/{candidate-ERMSYYQZ.js → chunk-ZW3B5LWX.js} +15 -19
  74. package/dist/{candidate-ERMSYYQZ.js.map → chunk-ZW3B5LWX.js.map} +1 -1
  75. package/dist/{cli-SBXI5AMS.js → cli-IW76QTN3.js} +64 -40
  76. package/dist/{cli-SBXI5AMS.js.map → cli-IW76QTN3.js.map} +1 -1
  77. package/dist/{config-VELDKLHY.js → config-VCOS7P5K.js} +8 -6
  78. package/dist/{doctor-T3KWNNP2.js → doctor-WS65JG3V.js} +9 -8
  79. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-WHYKB6HA.js} +5 -5
  80. package/dist/index.js +1 -1
  81. package/dist/inspect-SFJWUQHO.js +33 -0
  82. package/dist/install-RVPQPCKH.js +589 -0
  83. package/dist/install-RVPQPCKH.js.map +1 -0
  84. package/dist/outcome-GNYCSZ7J.js +20 -0
  85. package/dist/publish-DSFWQRUN.js +36 -0
  86. package/dist/publish-DSFWQRUN.js.map +1 -0
  87. package/dist/run-OMPKA43G.js +16807 -0
  88. package/dist/run-OMPKA43G.js.map +1 -0
  89. package/dist/search-KOI6Y7P6.js +24 -0
  90. package/dist/search-KOI6Y7P6.js.map +1 -0
  91. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-XRPVBC6V.js} +3 -3
  92. package/dist/secp256k1-XRPVBC6V.js.map +1 -0
  93. package/dist/send-3G4C64HJ.js +222 -0
  94. package/dist/send-3G4C64HJ.js.map +1 -0
  95. package/dist/usdc-4VCDHFWX.js +38 -0
  96. package/dist/usdc-4VCDHFWX.js.map +1 -0
  97. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-TUQJBMHM.js} +5 -5
  98. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +1 -0
  99. package/dist/wallet-B7KJS2R5.js +40 -0
  100. package/dist/wallet-B7KJS2R5.js.map +1 -0
  101. package/dist/wallet-PP22LAX7.js +31 -0
  102. package/dist/wallet-PP22LAX7.js.map +1 -0
  103. package/package.json +4 -3
  104. package/skills/tenjin/SKILL.md +83 -15
  105. package/skills/tenjin-publish/SKILL.md +118 -18
  106. package/skills/tenjin-search/SKILL.md +149 -31
  107. package/dist/buy-EE6SEXP6.js.map +0 -1
  108. package/dist/chunk-662MSGZB.js.map +0 -1
  109. package/dist/chunk-7KUW4MJD.js.map +0 -1
  110. package/dist/chunk-AWPAWHNX.js +0 -333
  111. package/dist/chunk-AWPAWHNX.js.map +0 -1
  112. package/dist/chunk-DXTQ3CSI.js.map +0 -1
  113. package/dist/chunk-ESPNTPQ2.js +0 -207
  114. package/dist/chunk-ESPNTPQ2.js.map +0 -1
  115. package/dist/chunk-FJPLRISB.js.map +0 -1
  116. package/dist/chunk-GO75V3NZ.js.map +0 -1
  117. package/dist/chunk-JPHG2JW3.js.map +0 -1
  118. package/dist/chunk-NCE5NSN6.js.map +0 -1
  119. package/dist/chunk-TLCMMYLY.js.map +0 -1
  120. package/dist/chunk-XHC6FCGZ.js.map +0 -1
  121. package/dist/chunk-XJIW7USF.js.map +0 -1
  122. package/dist/chunk-YALGASEU.js.map +0 -1
  123. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  124. package/dist/chunk-Z52RA3NC.js.map +0 -1
  125. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  126. package/dist/inspect-LMKOXE4Y.js +0 -96
  127. package/dist/inspect-LMKOXE4Y.js.map +0 -1
  128. package/dist/install-LEX3ENQ6.js +0 -387
  129. package/dist/install-LEX3ENQ6.js.map +0 -1
  130. package/dist/lookup-ZPN2Q67N.js.map +0 -1
  131. package/dist/outcome-N7TAK6WR.js +0 -66
  132. package/dist/outcome-N7TAK6WR.js.map +0 -1
  133. package/dist/publish-BKBQQAW4.js.map +0 -1
  134. package/dist/usdc-JIAJW4SV.js +0 -22
  135. package/dist/wallet-CWEMYVIH.js +0 -179
  136. package/dist/wallet-CWEMYVIH.js.map +0 -1
  137. package/dist/wallet-PA54CRBL.js +0 -30
  138. /package/dist/{_esm-FEASBWRP.js.map → _esm-N4KAVXQR.js.map} +0 -0
  139. /package/dist/{ccip-NQXCEK2U.js.map → buy-YMXXVNFH.js.map} +0 -0
  140. /package/dist/{ccip-XR5NE5QK.js.map → candidate-H7FR4AU5.js.map} +0 -0
  141. /package/dist/{config-VELDKLHY.js.map → ccip-RPPPKTJR.js.map} +0 -0
  142. /package/dist/{doctor-T3KWNNP2.js.map → ccip-ZGGWQN4X.js.map} +0 -0
  143. /package/dist/{chunk-S3IGX57D.js.map → chunk-FU6MCSLG.js.map} +0 -0
  144. /package/dist/{chunk-5CLSD5YN.js.map → chunk-KYQVEKP5.js.map} +0 -0
  145. /package/dist/{chunk-RRN3YTK7.js.map → chunk-KZAAWQNP.js.map} +0 -0
  146. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POJRB2AE.js.map} +0 -0
  147. /package/dist/{chunk-CYOF7ROH.js.map → chunk-S5RYMCV6.js.map} +0 -0
  148. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-U5S527PP.js.map} +0 -0
  149. /package/dist/{chunk-RY4XKNV3.js.map → chunk-UHTVXQ2O.js.map} +0 -0
  150. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-W6R3HAAG.js.map} +0 -0
  151. /package/dist/{chunk-HIVZG55D.js.map → chunk-XJN5WUKL.js.map} +0 -0
  152. /package/dist/{chunk-HSDCI7OV.js.map → chunk-YLYINX2H.js.map} +0 -0
  153. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → config-VCOS7P5K.js.map} +0 -0
  154. /package/dist/{secp256k1-N3ZHU7LB.js.map → doctor-WS65JG3V.js.map} +0 -0
  155. /package/dist/{usdc-JIAJW4SV.js.map → ethersCompat-Df4a6QIZ-WHYKB6HA.js.map} +0 -0
  156. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → inspect-SFJWUQHO.js.map} +0 -0
  157. /package/dist/{wallet-PA54CRBL.js.map → outcome-GNYCSZ7J.js.map} +0 -0
@@ -0,0 +1,24 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ runSearch
4
+ } from "./chunk-HTDALK7M.js";
5
+ import "./chunk-L4IHCN6B.js";
6
+ import "./chunk-CVX6JNGD.js";
7
+ import "./chunk-3IRDP7TN.js";
8
+ import "./chunk-ZIYVN4CD.js";
9
+ import "./chunk-WWX32ML4.js";
10
+ import "./chunk-ZDY2KY5X.js";
11
+ import "./chunk-NJF2WENW.js";
12
+ import "./chunk-NFSOVL3C.js";
13
+ import "./chunk-2I4QTOLB.js";
14
+ import "./chunk-MDDGEGSW.js";
15
+ import "./chunk-YBMMV4Y4.js";
16
+ import "./chunk-UO22YNY4.js";
17
+ import "./chunk-5SCU253N.js";
18
+ import "./chunk-2JQ5JSG6.js";
19
+ import "./chunk-PAUXMRSF.js";
20
+ import "./chunk-ZXTAQYNA.js";
21
+ export {
22
+ runSearch
23
+ };
24
+ //# sourceMappingURL=search-KOI6Y7P6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -5,9 +5,9 @@ import {
5
5
  schnorr,
6
6
  secp256k1,
7
7
  secp256k1_hasher
8
- } from "./chunk-QVX5MWJZ.js";
8
+ } from "./chunk-W6R3HAAG.js";
9
9
  import "./chunk-RBJPAZFI.js";
10
- import "./chunk-5CLSD5YN.js";
10
+ import "./chunk-KYQVEKP5.js";
11
11
  import "./chunk-ZXTAQYNA.js";
12
12
  export {
13
13
  encodeToCurve,
@@ -16,4 +16,4 @@ export {
16
16
  secp256k1,
17
17
  secp256k1_hasher
18
18
  };
19
- //# sourceMappingURL=secp256k1-N3ZHU7LB.js.map
19
+ //# sourceMappingURL=secp256k1-XRPVBC6V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,222 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ promptYesNo
4
+ } from "./chunk-QW2Q2KAH.js";
5
+ import {
6
+ describeWallet,
7
+ resolveWalletProvider
8
+ } from "./chunk-C444K6MI.js";
9
+ import "./chunk-QONTBYQW.js";
10
+ import "./chunk-2I4QTOLB.js";
11
+ import {
12
+ resolveContextSettings
13
+ } from "./chunk-MDDGEGSW.js";
14
+ import "./chunk-YBMMV4Y4.js";
15
+ import "./chunk-UO22YNY4.js";
16
+ import {
17
+ SEND_MAX_UNSET,
18
+ parseUsdToAtomic,
19
+ toMoney
20
+ } from "./chunk-5SCU253N.js";
21
+ import "./chunk-2JQ5JSG6.js";
22
+ import {
23
+ CliError
24
+ } from "./chunk-PAUXMRSF.js";
25
+ import {
26
+ FeeCapExceededError,
27
+ SendPendingError,
28
+ SendRevertedError,
29
+ USDC_ADDRESS,
30
+ broadcastUsdcSend,
31
+ getUsdcBalance,
32
+ prepareUsdcSend
33
+ } from "./chunk-MJZZTKCC.js";
34
+ import "./chunk-7FK2UN2T.js";
35
+ import "./chunk-M2O56UK7.js";
36
+ import "./chunk-UHTVXQ2O.js";
37
+ import "./chunk-W6R3HAAG.js";
38
+ import "./chunk-U5S527PP.js";
39
+ import {
40
+ formatEther,
41
+ getAddress,
42
+ isAddress
43
+ } from "./chunk-47PP7TAG.js";
44
+ import "./chunk-XJN5WUKL.js";
45
+ import "./chunk-RBJPAZFI.js";
46
+ import "./chunk-KYQVEKP5.js";
47
+ import "./chunk-ZXTAQYNA.js";
48
+
49
+ // src/commands/send.ts
50
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
51
+ var DEAD_ADDRESS = "0x000000000000000000000000000000000000dEaD";
52
+ async function runSend(args, ctx, deps = {}) {
53
+ requireUsdc(args.token);
54
+ const amountAtomic = BigInt(parseUsdToAtomic(args.amount));
55
+ if (amountAtomic === 0n) {
56
+ throw new CliError("USAGE", "The send amount must be greater than zero.", {
57
+ fix: "Pass a positive decimal USDC amount, e.g. `tenjin send 5 usdc <to>`."
58
+ });
59
+ }
60
+ const to = parseRecipient(args.to);
61
+ const provider = resolveWalletProvider(
62
+ ctx,
63
+ deps.provider !== void 0 ? { provider: deps.provider } : {}
64
+ );
65
+ const desc = await describeWallet(provider);
66
+ if (to.toLowerCase() === desc.address.toLowerCase()) {
67
+ throw new CliError("USAGE", "The recipient is this wallet itself.", {
68
+ fix: "Pass the destination wallet address, not the sending one."
69
+ });
70
+ }
71
+ const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);
72
+ enforceSendCap(amountAtomic, sendMaxAmountAtomic);
73
+ let balance;
74
+ try {
75
+ balance = await getUsdcBalance(desc.address, rpcUrl);
76
+ } catch (err) {
77
+ throw new CliError("RPC_ERROR", `Could not read the USDC balance from ${rpcUrl}.`, {
78
+ fix: "Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.",
79
+ cause: err
80
+ });
81
+ }
82
+ if (amountAtomic > balance) {
83
+ throw new CliError("REFUSED", "The amount exceeds the wallet USDC balance.", {
84
+ fix: "Check `tenjin wallet balance` and send at most that amount.",
85
+ details: {
86
+ requested: toMoney(amountAtomic.toString()),
87
+ balance: toMoney(balance.toString())
88
+ }
89
+ });
90
+ }
91
+ let prepared;
92
+ try {
93
+ prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });
94
+ } catch (err) {
95
+ if (err instanceof FeeCapExceededError) {
96
+ throw new CliError("REFUSED", "The RPC gas/fee estimate is abnormal for Base; refusing.", {
97
+ fix: "Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking \u2014 wait and retry.",
98
+ cause: err
99
+ });
100
+ }
101
+ throw new CliError("RPC_ERROR", "Could not prepare the transfer on Base.", {
102
+ fix: "Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.",
103
+ cause: err
104
+ });
105
+ }
106
+ if (prepared.ethBalanceWei < prepared.feeWei) {
107
+ throw new CliError("REFUSED", "The wallet has no ETH on Base to pay the network fee.", {
108
+ fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,
109
+ details: {
110
+ ethBalanceWei: prepared.ethBalanceWei.toString(),
111
+ feeWei: prepared.feeWei.toString()
112
+ }
113
+ });
114
+ }
115
+ const approved = await confirmSend(ctx, deps, args.yes === true, {
116
+ amountAtomic,
117
+ to,
118
+ from: desc.address,
119
+ feeWei: prepared.feeWei
120
+ });
121
+ if (!approved) {
122
+ throw new CliError("REFUSED", "Send not confirmed.", {
123
+ fix: "Verify the recipient and amount, then re-run with --yes to approve this transfer.",
124
+ details: { to, amount: toMoney(amountAtomic.toString()) }
125
+ });
126
+ }
127
+ const signer = await provider.getSigner();
128
+ if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {
129
+ throw new CliError(
130
+ "PROVIDER_ERROR",
131
+ `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,
132
+ { fix: "The wallet changed between preview and signing; re-run `tenjin send`." }
133
+ );
134
+ }
135
+ let txHash;
136
+ try {
137
+ txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });
138
+ } catch (err) {
139
+ if (err instanceof SendRevertedError) {
140
+ throw new CliError("SEND_FAILED", "The transfer was mined but reverted; no USDC moved.", {
141
+ fix: "Check the transaction on a Base explorer, then retry if the cause is transient.",
142
+ details: { txHash: err.txHash },
143
+ cause: err
144
+ });
145
+ }
146
+ if (err instanceof SendPendingError) {
147
+ throw new CliError("SEND_FAILED", "The transfer was broadcast but not confirmed in time.", {
148
+ fix: "Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.",
149
+ details: { txHash: err.txHash, pending: true },
150
+ cause: err
151
+ });
152
+ }
153
+ throw new CliError("RPC_ERROR", "The transfer could not be sent on Base.", {
154
+ fix: "Check the network and RPC, then retry.",
155
+ cause: err
156
+ });
157
+ }
158
+ const amount = toMoney(amountAtomic.toString());
159
+ return {
160
+ data: { txHash, from: signer.address, to, token: "USDC", network: "base", amount },
161
+ humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`]
162
+ };
163
+ }
164
+ function enforceSendCap(amountAtomic, capAtomic) {
165
+ if (capAtomic === SEND_MAX_UNSET) {
166
+ throw new CliError(
167
+ "POLICY_REFUSED",
168
+ "No sendMaxAmount is configured; a per-send cap must be set before the first send.",
169
+ {
170
+ 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."
171
+ }
172
+ );
173
+ }
174
+ if (capAtomic === null) return;
175
+ if (capAtomic === 0n) {
176
+ throw new CliError("POLICY_REFUSED", "Sending is disabled by sendMaxAmount = 0.", {
177
+ fix: "Run `tenjin config set sendMaxAmount <usd|none>` to allow sends."
178
+ });
179
+ }
180
+ if (amountAtomic > capAtomic) {
181
+ throw new CliError("POLICY_REFUSED", "The amount exceeds the sendMaxAmount cap.", {
182
+ fix: "Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.",
183
+ details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) }
184
+ });
185
+ }
186
+ }
187
+ function requireUsdc(token) {
188
+ if (token.trim().toLowerCase() === "usdc") return;
189
+ throw new CliError("USAGE", `Unsupported token: ${JSON.stringify(token)}`, {
190
+ fix: "Only USDC on Base is supported: `tenjin send <amount> usdc <to>`."
191
+ });
192
+ }
193
+ function parseRecipient(raw) {
194
+ const trimmed = raw.trim();
195
+ if (!isAddress(trimmed)) {
196
+ throw new CliError("USAGE", `Invalid recipient address: ${JSON.stringify(raw)}`, {
197
+ fix: "Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check)."
198
+ });
199
+ }
200
+ const to = getAddress(trimmed);
201
+ if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {
202
+ throw new CliError("USAGE", "The recipient is a known fund-destroying address.", {
203
+ fix: "Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address."
204
+ });
205
+ }
206
+ return to;
207
+ }
208
+ async function confirmSend(ctx, deps, yes, d) {
209
+ if (yes) return true;
210
+ const prompt = `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base
211
+ from ${d.from}
212
+ to ${d.to}
213
+ network fee up to ~${formatEther(d.feeWei)} ETH
214
+ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
215
+ if (deps.confirm !== void 0) return deps.confirm(prompt);
216
+ if (!ctx.io.isTTY || !process.stdin.isTTY) return false;
217
+ return promptYesNo(prompt);
218
+ }
219
+ export {
220
+ runSend
221
+ };
222
+ //# sourceMappingURL=send-3G4C64HJ.js.map
@@ -0,0 +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 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 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 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 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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E,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":[]}
@@ -0,0 +1,38 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ FeeCapExceededError,
4
+ SEND_GAS_CAP,
5
+ SEND_MAX_FEE_PER_GAS_CAP,
6
+ SEND_MAX_PRIORITY_FEE_CAP,
7
+ SendPendingError,
8
+ SendRevertedError,
9
+ USDC_ADDRESS,
10
+ USDC_DECIMALS,
11
+ broadcastUsdcSend,
12
+ getUsdcBalance,
13
+ prepareUsdcSend
14
+ } from "./chunk-MJZZTKCC.js";
15
+ import "./chunk-7FK2UN2T.js";
16
+ import "./chunk-M2O56UK7.js";
17
+ import "./chunk-UHTVXQ2O.js";
18
+ import "./chunk-W6R3HAAG.js";
19
+ import "./chunk-U5S527PP.js";
20
+ import "./chunk-47PP7TAG.js";
21
+ import "./chunk-XJN5WUKL.js";
22
+ import "./chunk-RBJPAZFI.js";
23
+ import "./chunk-KYQVEKP5.js";
24
+ import "./chunk-ZXTAQYNA.js";
25
+ export {
26
+ FeeCapExceededError,
27
+ SEND_GAS_CAP,
28
+ SEND_MAX_FEE_PER_GAS_CAP,
29
+ SEND_MAX_PRIORITY_FEE_CAP,
30
+ SendPendingError,
31
+ SendRevertedError,
32
+ USDC_ADDRESS,
33
+ USDC_DECIMALS,
34
+ broadcastUsdcSend,
35
+ getUsdcBalance,
36
+ prepareUsdcSend
37
+ };
38
+ //# sourceMappingURL=usdc-4VCDHFWX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -2,13 +2,13 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
2
2
  import {
3
3
  a,
4
4
  s
5
- } from "./chunk-CYOF7ROH.js";
6
- import "./chunk-HSDCI7OV.js";
7
- import "./chunk-HIVZG55D.js";
8
- import "./chunk-5CLSD5YN.js";
5
+ } from "./chunk-S5RYMCV6.js";
6
+ import "./chunk-YLYINX2H.js";
7
+ import "./chunk-XJN5WUKL.js";
8
+ import "./chunk-KYQVEKP5.js";
9
9
  import "./chunk-ZXTAQYNA.js";
10
10
  export {
11
11
  a as n,
12
12
  s as t
13
13
  };
14
- //# sourceMappingURL=viemAdapter-By13KInL-ZZE6UV4Y.js.map
14
+ //# sourceMappingURL=viemAdapter-By13KInL-TUQJBMHM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,40 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ commitLocalWallet,
4
+ createLocalSpendAuthorizer,
5
+ createLocalWallet,
6
+ describeWallet,
7
+ parkOutgoingWallet,
8
+ prepareLocalWallet,
9
+ resolveSpendAuthorizer,
10
+ resolveWalletProvider,
11
+ restoreParkedWallet,
12
+ verifyAndPreserveOutgoingWallet
13
+ } from "./chunk-C444K6MI.js";
14
+ import "./chunk-QONTBYQW.js";
15
+ import "./chunk-2I4QTOLB.js";
16
+ import "./chunk-YBMMV4Y4.js";
17
+ import "./chunk-UO22YNY4.js";
18
+ import "./chunk-2JQ5JSG6.js";
19
+ import "./chunk-PAUXMRSF.js";
20
+ import "./chunk-M2O56UK7.js";
21
+ import "./chunk-UHTVXQ2O.js";
22
+ import "./chunk-W6R3HAAG.js";
23
+ import "./chunk-47PP7TAG.js";
24
+ import "./chunk-XJN5WUKL.js";
25
+ import "./chunk-RBJPAZFI.js";
26
+ import "./chunk-KYQVEKP5.js";
27
+ import "./chunk-ZXTAQYNA.js";
28
+ export {
29
+ commitLocalWallet,
30
+ createLocalSpendAuthorizer,
31
+ createLocalWallet,
32
+ describeWallet,
33
+ parkOutgoingWallet,
34
+ prepareLocalWallet,
35
+ resolveSpendAuthorizer,
36
+ resolveWalletProvider,
37
+ restoreParkedWallet,
38
+ verifyAndPreserveOutgoingWallet
39
+ };
40
+ //# sourceMappingURL=wallet-B7KJS2R5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,31 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ runWalletBalance,
4
+ runWalletCreate,
5
+ runWalletShow
6
+ } from "./chunk-IOPWPMT2.js";
7
+ import "./chunk-C444K6MI.js";
8
+ import "./chunk-QONTBYQW.js";
9
+ import "./chunk-2I4QTOLB.js";
10
+ import "./chunk-YBMMV4Y4.js";
11
+ import "./chunk-UO22YNY4.js";
12
+ import "./chunk-5SCU253N.js";
13
+ import "./chunk-2JQ5JSG6.js";
14
+ import "./chunk-PAUXMRSF.js";
15
+ import "./chunk-MJZZTKCC.js";
16
+ import "./chunk-7FK2UN2T.js";
17
+ import "./chunk-M2O56UK7.js";
18
+ import "./chunk-UHTVXQ2O.js";
19
+ import "./chunk-W6R3HAAG.js";
20
+ import "./chunk-U5S527PP.js";
21
+ import "./chunk-47PP7TAG.js";
22
+ import "./chunk-XJN5WUKL.js";
23
+ import "./chunk-RBJPAZFI.js";
24
+ import "./chunk-KYQVEKP5.js";
25
+ import "./chunk-ZXTAQYNA.js";
26
+ export {
27
+ runWalletBalance,
28
+ runWalletCreate,
29
+ runWalletShow
30
+ };
31
+ //# sourceMappingURL=wallet-PP22LAX7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenjin-cli",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.5",
4
4
  "type": "module",
5
5
  "description": "Tenjin agent CLI for the x402 knowledge marketplace.",
6
6
  "license": "MIT",
@@ -36,13 +36,14 @@
36
36
  ],
37
37
  "devDependencies": {
38
38
  "@changesets/cli": "^2.31.1",
39
- "@eslint/js": "^9",
39
+ "@eslint/js": "^10",
40
+ "@modelcontextprotocol/sdk": "1.29.0",
40
41
  "@types/node": "^25",
41
42
  "@x402/core": "2.17.0",
42
43
  "@x402/evm": "2.17.0",
43
44
  "@x402/extensions": "2.17.0",
44
45
  "commander": "^14.0.1",
45
- "eslint": "^9",
46
+ "eslint": "^10",
46
47
  "eslint-config-prettier": "^10",
47
48
  "ox": "0.14.30",
48
49
  "prettier": "^3",
@@ -46,7 +46,10 @@ word-handle OR their 0x address). Request it as an agent to get the x402 flow:
46
46
  client do it), whose `accepts[0]` is `{ scheme:"exact", network:"eip155:8453",
47
47
  asset:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount:"<atomic>", payTo:"<0x>", maxTimeoutSeconds:300 }`.
48
48
  The 402 response *body* is a leak-safe preview in raw Markdown
49
- (title/excerpt/bodyMdPreview/price/tags/creator) — never the paid body.
49
+ (title/excerpt/bodyMdPreview/price/tags/creator) — never the paid body. It also
50
+ carries the piece's answer card in `card` (what it answers, what it applies to,
51
+ what it excludes, and its `asOf`/`validUntil` dates) when the piece has one, so
52
+ you can judge fit before paying.
50
53
  3. Sign an x402 `exact` payment over `accepts[0]` and re-request the same URL with
51
54
  the payment in the `PAYMENT-SIGNATURE` header → `200` + the full piece JSON,
52
55
  including raw source Markdown in `bodyMd`; the
@@ -80,7 +83,9 @@ in `bodyMd`; to download it as a file, use `GET https://tenjin.blog/api/read/<ha
80
83
  Every discovery surface is public, unauthenticated, CORS-open, and PREVIEW-ONLY:
81
84
 
82
85
  - `GET https://tenjin.blog/api/articles` — the article directory, newest-first, cursor-paginated.
83
- Compose `?q=<text>` (leak-safe full-text search over title/excerpt/tags),
86
+ Compose `?q=<text>` (leak-safe full-text search over title/excerpt/tags plus the body
87
+ text that is already public — a free piece's whole body, a paid piece's pre-paywall
88
+ preview only, never text below a paywall),
84
89
  `?tag=<slug>` (a shared tag is how authors form a "series"),
85
90
  `?creator=<handle|0x>`, `?maxPrice=`/`?minPrice=<atomic USDC>` (a price band;
86
91
  `maxPrice=0` = free only), `?updatedSince=<ISO-8601 UTC>` (incremental sync —
@@ -97,20 +102,36 @@ Every discovery surface is public, unauthenticated, CORS-open, and PREVIEW-ONLY:
97
102
  From outside Tenjin: a paid article is auto-indexed by the CDP x402 Bazaar after its
98
103
  FIRST settled sale (no register call), and by x402scan once CDP-settled payments flow.
99
104
 
100
- ## Find a paid answer for a task (agent lookup)
105
+ ## Find a paid answer for a task (agent search)
101
106
 
102
107
  Mid-task, ask a QUESTION instead of browsing: it matches author-attested answer cards with
103
- freshness/price/applicability as HARD gates (honest lexical, not a semantic score). Anonymous,
104
- no wallet.
105
-
106
- - `POST https://tenjin.blog/api/agent/lookup` with `{ "schemaVersion": 1, "question": "<task question>",
107
- "maxPrice"?: "<atomic USDC>", "freshWithin"?: "P30D", "limit"?: 5 }` → `{ lookupId,
108
- decision: "CANDIDATES" | "MISS", candidates? }`. A small early catalog means MISS is often
109
- the honest answer; the question is never stored unless you send `X-Tenjin-Eval-Cohort: 1`.
108
+ freshness/price/applicability as HARD gates. A MISS does not prove absence — rephrase, or
109
+ browse `?q=` (a MISS may carry a small `browse` tail). Anonymous, no wallet. Matching
110
+ runs on wording and meaning, so send the whole question as one natural-language sentence
111
+ rather than keywords, generalized first (no private identifiers, internal names, or
112
+ secrets; generalize the NAMES, keep the technical specifics).
113
+
114
+ - `POST https://tenjin.blog/api/agent/search` with `{ "schemaVersion": 2, "question": "<task question>",
115
+ "maxPrice"?: "<atomic USDC>", "freshWithin"?: "P30D", "limit"?: 5 }` → `{ schemaVersion: 2,
116
+ searchId, decision: "CANDIDATES" | "MISS", candidates?, truncated?, browse? }`. You get up to
117
+ `limit` (1-10, default 5) lean candidates: id, payable `url`, slug, title, artifactType,
118
+ price, asOf, validUntil, matchReasons, estimatedTokens, creator handle (slug + creator handle
119
+ feed any handle/slug call directly, so you never parse the url). A small early catalog means
120
+ MISS is often the honest answer; the question is never stored unless you send
121
+ `X-Tenjin-Eval-Cohort: 1`.
122
+ - Inspect a candidate for FREE before buying: fetch its `url` without paying. A PAID piece
123
+ answers `402` whose body carries a `card` object (`questionsAnswered`, `tasksSupported`,
124
+ `appliesTo`, `scope`, `exclusions`, `temporalMode`) plus the preview, present only when
125
+ the card has public content; a FREE piece (`price` `"0"`) answers `200` with the whole
126
+ piece in `bodyMd` and no `card`. Shortlist wide, then inspect the 2 or 3 best rather than
127
+ all of them: a maximal card is roughly 25kB.
128
+ - `truncated: true` means the size backstop dropped trailing candidates. The ceiling grows
129
+ with the number returned, so retry with a LARGER `limit` (up to 10) to get more; at
130
+ `limit` 10 the tail is unrecoverable and narrowing the question is the remedy.
110
131
  - Buy a candidate by paying its `url` (the payable `/api/read/...` link) exactly like a paid
111
- piece above — no extra headers required. OPTIONALLY add `X-Tenjin-Lookup-Id: <lookupId>` on
112
- that read to link it to this lookup (helps measure discovery quality; expires at 90 days).
113
- - `POST https://tenjin.blog/api/agent/lookups/<lookupId>/outcomes` with `{ "status": "used" | "rejected"
132
+ piece above — no extra headers required. OPTIONALLY add `X-Tenjin-Search-Id: <searchId>` on
133
+ that read to link it to this search (helps measure discovery quality; expires at 90 days).
134
+ - `POST https://tenjin.blog/api/agent/searches/<searchId>/outcomes` with `{ "status": "used" | "rejected"
114
135
  | "regenerated" | "partially_used" | "purchase_declined", "resourceId"?, "contentHash"? }`
115
136
  to report what you did → `202` (no existence oracle).
116
137
 
@@ -121,7 +142,8 @@ Publishing is free; it is gated by a wallet SIGNATURE (SIWX), not a payment.
121
142
  ```
122
143
  POST https://tenjin.blog/api/posts
123
144
  header: SIGN-IN-WITH-X: <base64 CAIP-122 message you signed> (see below)
124
- body: { "title", "bodyMd", "excerpt"?, "price"?, "tags"?, "handle"?, "status"? }
145
+ body: { "title", "bodyMd", "excerpt"?, "price"?, "tags"?, "handle"?, "status"?,
146
+ "resource"?, "searchId"? }
125
147
  ```
126
148
 
127
149
  - `title` (1–200) and `bodyMd` (markdown, 1–200000) are required. For a paid post,
@@ -131,6 +153,12 @@ POST https://tenjin.blog/api/posts
131
153
  `tags` ≤ 5; `handle` (first post only) claims your word-handle; `status` is
132
154
  `"published"` (default), `"draft"` (private WIP), or `"unlisted"` (link-only).
133
155
  - `excerpt` is a separate listing teaser, NOT the in-page preview.
156
+ - `resource` is the optional answer card that makes the piece findable by agent
157
+ search — see the next section.
158
+ - `searchId` (uuid) is optional supply-loop attribution: pass the `searchId` of an
159
+ agent search that MISSED (above) when you publish the piece that answers it. Stored
160
+ server-side only and NEVER returned in any response; set-once, so a later `PUT` may
161
+ set it while it is still unset (draft or already published) but never change it.
134
162
 
135
163
  Returns `201` with the post + public `url`. Your first post auto-creates a publisher
136
164
  profile for your wallet. To embed an image, upload the bytes FIRST:
@@ -138,6 +166,45 @@ profile for your wallet. To embed an image, upload the bytes FIRST:
138
166
  same SIWX header) → `{ imageId, url }`, then put `![alt](/api/images/<id>)` in `bodyMd`.
139
167
  Your first free-preview image becomes the cover automatically.
140
168
 
169
+ ### Resource card (what makes a piece findable via search)
170
+
171
+ Agent search (below) matches a QUESTION against a machine-readable answer card, so a
172
+ piece WITHOUT one is invisible to search — a plain document, browseable but never a
173
+ search candidate. Attach a `resource` object to the same POST (or merge-update it
174
+ later with `PUT https://tenjin.blog/api/posts/<id>`) to make the piece findable, gateable, and
175
+ priceable before a buyer pays:
176
+
177
+ ```
178
+ "resource": {
179
+ "artifactType": "document", // document | skill | dataset
180
+ "temporalMode": "snapshot", // snapshot | maintained | evergreen
181
+ "asOf": "2026-07-01T00:00:00Z", // required for a snapshot to be eligible
182
+ "questionsAnswered": ["Does Vercel respect .nvmrc for serverless builds?"],
183
+ "scope": "Vercel serverless builds, Next 15/16",
184
+ "exclusions": "Not edge runtime",
185
+ "appliesTo": { "products": ["Vercel"] },
186
+ "provenanceSummary": "Reproduced on a live deploy 2026-07-01"
187
+ }
188
+ ```
189
+
190
+ `questionsAnswered` is the field that most decides findability. Write 5 to 10 entries, 200 chars max each,
191
+ in DIFFERENT registers: a natural symptom sentence a stuck agent would ask, a terse keyword
192
+ or verbatim error-string form, and a why/how form. Each entry is its own search target. The
193
+ registers are an axis, not a quota: list every distinct question the piece answers, then
194
+ write each in whichever registers fit it. Near-duplicate rephrasings of one question in one
195
+ register add nothing.
196
+ `scope` is searched too: make it a dense factual sentence. Only `questionsAnswered` and
197
+ `scope` are matched by meaning; `tasksSupported` and `appliesTo` match exact wording only,
198
+ so anything a searcher might paraphrase belongs in `questionsAnswered` or `scope`.
199
+ Questions the piece ANSWERS go in `questionsAnswered`; tasks it helps COMPLETE go in
200
+ `tasksSupported`.
201
+
202
+ Every card field is PUBLIC, pre-paywall: never put paid content in it. The response
203
+ echoes a server-computed `cacheEligible` plus `cacheEligibleMissing` listing what the
204
+ card still needs (at least one question/task, `scope`, `exclusions`, `asOf` for a
205
+ snapshot, a provenance summary); fix the gaps with a `PUT`. See /llms.txt for the full
206
+ field contract.
207
+
141
208
  ### Build the SIGN-IN-WITH-X header
142
209
 
143
210
  CLIENT-driven: you construct, sign, and send the full CAIP-122 message on the FIRST
@@ -186,7 +253,8 @@ All of these take the same `SIGN-IN-WITH-X` header (single-use nonce per write):
186
253
  ## MCP server
187
254
 
188
255
  https://tenjin.blog/api/mcp is a remote MCP server (Streamable HTTP) exposing these flows as
189
- callable tools — `search_articles`, `get_article`, `get_creator`, `list_tags`
256
+ callable tools — `search_articles`, `search` (mid-task question → buyable
257
+ candidates), `get_article`, `get_creator`, `list_tags`, `submit_feedback`
190
258
  (keyless), plus `pay_and_read`, `publish_essay`, `get_profile`, and `get_library`.
191
259
  The server NEVER holds your keys: the keyless tools hit the public discovery + read
192
260
  surface, and the wallet tools take a header YOU signed locally (the