tenjin-cli 0.1.0-alpha.24 → 0.1.0-alpha.25

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 (114) hide show
  1. package/README.md +5 -1
  2. package/dist/{chunk-H5UR3GFJ.js → chunk-3ZYPVSIU.js} +56 -31
  3. package/dist/chunk-3ZYPVSIU.js.map +1 -0
  4. package/dist/chunk-7EKYXMUO.js +7536 -0
  5. package/dist/chunk-7EKYXMUO.js.map +1 -0
  6. package/dist/chunk-AKWGE6JQ.js +49 -0
  7. package/dist/chunk-AKWGE6JQ.js.map +1 -0
  8. package/dist/{chunk-RCJ64OXH.js → chunk-CEMXMUIU.js} +3 -3
  9. package/dist/{chunk-XZUGRTSV.js → chunk-CKDD554V.js} +2 -2
  10. package/dist/{hook-command-GMIDXVFK.js → chunk-CP7O6M55.js} +190 -40
  11. package/dist/chunk-CP7O6M55.js.map +1 -0
  12. package/dist/{chunk-UBOFYC6J.js → chunk-DRXDTITB.js} +1821 -141
  13. package/dist/chunk-DRXDTITB.js.map +1 -0
  14. package/dist/{chunk-EP5P2STS.js → chunk-EACMJEF3.js} +201 -8
  15. package/dist/chunk-EACMJEF3.js.map +1 -0
  16. package/dist/{chunk-GPLSNGKX.js → chunk-EG7P4SM6.js} +4 -4
  17. package/dist/{chunk-RGVOODF4.js → chunk-EL56RW2J.js} +164 -7463
  18. package/dist/chunk-EL56RW2J.js.map +1 -0
  19. package/dist/{chunk-KC24CYGV.js → chunk-EOGJKIOG.js} +6 -8
  20. package/dist/{chunk-KC24CYGV.js.map → chunk-EOGJKIOG.js.map} +1 -1
  21. package/dist/{chunk-ZMFDMALH.js → chunk-GT6W3VJM.js} +2 -2
  22. package/dist/{chunk-TMLCEPCD.js → chunk-HII5HOQV.js} +3 -5
  23. package/dist/chunk-HII5HOQV.js.map +1 -0
  24. package/dist/{chunk-UXSF7IFD.js → chunk-IYLECN4D.js} +3 -3
  25. package/dist/{chunk-SQSKVKX6.js → chunk-KGTQRJGS.js} +17 -8
  26. package/dist/chunk-KGTQRJGS.js.map +1 -0
  27. package/dist/chunk-LFZJM56J.js +159 -0
  28. package/dist/chunk-LFZJM56J.js.map +1 -0
  29. package/dist/{chunk-YZTIYDWU.js → chunk-NTYQHAIM.js} +2 -2
  30. package/dist/{chunk-IIE65SJC.js → chunk-NYPFOHSJ.js} +4 -4
  31. package/dist/{chunk-ZNZGBUV6.js → chunk-ODH7UXIS.js} +8 -7
  32. package/dist/chunk-ODH7UXIS.js.map +1 -0
  33. package/dist/{chunk-NSDZESRS.js → chunk-OZ3LWLCI.js} +3 -3
  34. package/dist/{chunk-XRW4N23F.js → chunk-SCAE6PW6.js} +4 -4
  35. package/dist/{chunk-O2WN732M.js → chunk-UDWGT4FX.js} +2 -2
  36. package/dist/chunk-VYONGSMQ.js +119 -0
  37. package/dist/chunk-VYONGSMQ.js.map +1 -0
  38. package/dist/{chunk-P22ZWXFX.js → chunk-XICKN3CH.js} +49 -4
  39. package/dist/chunk-XICKN3CH.js.map +1 -0
  40. package/dist/chunk-YHKXNYTB.js +105 -0
  41. package/dist/chunk-YHKXNYTB.js.map +1 -0
  42. package/dist/{chunk-W2ARIOAZ.js → chunk-YSW57KUT.js} +8 -10
  43. package/dist/{chunk-W2ARIOAZ.js.map → chunk-YSW57KUT.js.map} +1 -1
  44. package/dist/{chunk-FFL5M5BC.js → chunk-YTM7OURD.js} +2 -2
  45. package/dist/{cli-GGNOQQEB.js → cli-4WMGZPBP.js} +27 -28
  46. package/dist/{cli-GGNOQQEB.js.map → cli-4WMGZPBP.js.map} +1 -1
  47. package/dist/{config-XUUFICXK.js → config-VU6U7QOU.js} +9 -8
  48. package/dist/{doctor-3LGF6CWI.js → doctor-26JS2SG3.js} +123 -31
  49. package/dist/doctor-26JS2SG3.js.map +1 -0
  50. package/dist/{fund-3URFMBMN.js → fund-JJN3FRRF.js} +13 -14
  51. package/dist/fund-JJN3FRRF.js.map +1 -0
  52. package/dist/hook-command-S2V4UNB3.js +28 -0
  53. package/dist/index.js +3 -3
  54. package/dist/{install-FRTG4KHF.js → install-GXQ33J4G.js} +19 -16
  55. package/dist/{install-identity-WNXSYP6N.js → install-identity-HFQUXPSI.js} +6 -7
  56. package/dist/{install-wallet-MXLJJP3N.js → install-wallet-27LTEHBI.js} +8 -9
  57. package/dist/{install-wallet-MXLJJP3N.js.map → install-wallet-27LTEHBI.js.map} +1 -1
  58. package/dist/{mcp-O2WJ3QBW.js → mcp-AHCZVD2U.js} +596 -75
  59. package/dist/mcp-AHCZVD2U.js.map +1 -0
  60. package/dist/{pay-43WUYTW5.js → pay-3TCOPGCX.js} +14 -13
  61. package/dist/{payments-7UTMMTIO.js → payments-H3LSBGSL.js} +6 -7
  62. package/dist/{payments-7UTMMTIO.js.map → payments-H3LSBGSL.js.map} +1 -1
  63. package/dist/{send-ALHG2RXT.js → send-LKCLN5GA.js} +9 -11
  64. package/dist/{send-ALHG2RXT.js.map → send-LKCLN5GA.js.map} +1 -1
  65. package/dist/{status-CFPNHB6R.js → status-2FDGI4LQ.js} +7 -9
  66. package/dist/{status-CFPNHB6R.js.map → status-2FDGI4LQ.js.map} +1 -1
  67. package/dist/{status-line-FJ6N7MKJ.js → status-line-QKDJYZGV.js} +4 -5
  68. package/dist/{status-line-FJ6N7MKJ.js.map → status-line-QKDJYZGV.js.map} +1 -1
  69. package/dist/{status-line-wiring-GXFNXHPE.js → status-line-wiring-ZDBYHNYR.js} +6 -4
  70. package/dist/{uninstall-5P2GFYBY.js → uninstall-ZXWABDHS.js} +33 -29
  71. package/dist/uninstall-ZXWABDHS.js.map +1 -0
  72. package/dist/{update-QJ5YHJ7I.js → update-HEIWVOP5.js} +17 -6
  73. package/dist/update-HEIWVOP5.js.map +1 -0
  74. package/dist/{wallet-6OJPGNEV.js → wallet-T7JYWI6O.js} +8 -9
  75. package/dist/wallet-T7JYWI6O.js.map +1 -0
  76. package/docs/agent-permissions.md +6 -3
  77. package/package.json +7 -6
  78. package/dist/chunk-EP5P2STS.js.map +0 -1
  79. package/dist/chunk-H5UR3GFJ.js.map +0 -1
  80. package/dist/chunk-O2JYBOUO.js +0 -47
  81. package/dist/chunk-O2JYBOUO.js.map +0 -1
  82. package/dist/chunk-P22ZWXFX.js.map +0 -1
  83. package/dist/chunk-RGVOODF4.js.map +0 -1
  84. package/dist/chunk-S2NRVRPF.js +0 -171
  85. package/dist/chunk-S2NRVRPF.js.map +0 -1
  86. package/dist/chunk-SQSKVKX6.js.map +0 -1
  87. package/dist/chunk-TMLCEPCD.js.map +0 -1
  88. package/dist/chunk-UBOFYC6J.js.map +0 -1
  89. package/dist/chunk-YXLG7Q6Q.js +0 -140
  90. package/dist/chunk-YXLG7Q6Q.js.map +0 -1
  91. package/dist/chunk-ZNZGBUV6.js.map +0 -1
  92. package/dist/doctor-3LGF6CWI.js.map +0 -1
  93. package/dist/fund-3URFMBMN.js.map +0 -1
  94. package/dist/hook-command-GMIDXVFK.js.map +0 -1
  95. package/dist/mcp-O2WJ3QBW.js.map +0 -1
  96. package/dist/uninstall-5P2GFYBY.js.map +0 -1
  97. package/dist/update-QJ5YHJ7I.js.map +0 -1
  98. /package/dist/{chunk-RCJ64OXH.js.map → chunk-CEMXMUIU.js.map} +0 -0
  99. /package/dist/{chunk-XZUGRTSV.js.map → chunk-CKDD554V.js.map} +0 -0
  100. /package/dist/{chunk-GPLSNGKX.js.map → chunk-EG7P4SM6.js.map} +0 -0
  101. /package/dist/{chunk-ZMFDMALH.js.map → chunk-GT6W3VJM.js.map} +0 -0
  102. /package/dist/{chunk-UXSF7IFD.js.map → chunk-IYLECN4D.js.map} +0 -0
  103. /package/dist/{chunk-YZTIYDWU.js.map → chunk-NTYQHAIM.js.map} +0 -0
  104. /package/dist/{chunk-IIE65SJC.js.map → chunk-NYPFOHSJ.js.map} +0 -0
  105. /package/dist/{chunk-NSDZESRS.js.map → chunk-OZ3LWLCI.js.map} +0 -0
  106. /package/dist/{chunk-XRW4N23F.js.map → chunk-SCAE6PW6.js.map} +0 -0
  107. /package/dist/{chunk-O2WN732M.js.map → chunk-UDWGT4FX.js.map} +0 -0
  108. /package/dist/{chunk-FFL5M5BC.js.map → chunk-YTM7OURD.js.map} +0 -0
  109. /package/dist/{config-XUUFICXK.js.map → config-VU6U7QOU.js.map} +0 -0
  110. /package/dist/{install-FRTG4KHF.js.map → hook-command-S2V4UNB3.js.map} +0 -0
  111. /package/dist/{install-identity-WNXSYP6N.js.map → install-GXQ33J4G.js.map} +0 -0
  112. /package/dist/{pay-43WUYTW5.js.map → install-identity-HFQUXPSI.js.map} +0 -0
  113. /package/dist/{status-line-wiring-GXFNXHPE.js.map → pay-3TCOPGCX.js.map} +0 -0
  114. /package/dist/{wallet-6OJPGNEV.js.map → status-line-wiring-ZDBYHNYR.js.map} +0 -0
@@ -0,0 +1,159 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ hashTypedData
4
+ } from "./chunk-EL56RW2J.js";
5
+ import {
6
+ getAddress,
7
+ keccak256,
8
+ toBytes,
9
+ toHex
10
+ } from "./chunk-TTNESUPQ.js";
11
+
12
+ // node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/dist/esm/chunk-EKCH75YB.mjs
13
+ var EIP155_NETWORK_REGEX = /^eip155:(\d+)$/;
14
+ function getEvmChainId(network) {
15
+ if (!network.startsWith("eip155:")) {
16
+ throw new Error(`Unsupported network format: ${network} (expected eip155:CHAIN_ID)`);
17
+ }
18
+ const match = EIP155_NETWORK_REGEX.exec(network);
19
+ if (!match) {
20
+ throw new Error(`Invalid CAIP-2 chain ID: ${network}`);
21
+ }
22
+ const chainId = Number(match[1]);
23
+ if (!Number.isSafeInteger(chainId)) {
24
+ throw new Error(`Invalid CAIP-2 chain ID: ${network}`);
25
+ }
26
+ return chainId;
27
+ }
28
+ function getCrypto() {
29
+ const cryptoObj = globalThis.crypto;
30
+ if (!cryptoObj) {
31
+ throw new Error("Crypto API not available");
32
+ }
33
+ return cryptoObj;
34
+ }
35
+ function createNonce() {
36
+ return toHex(getCrypto().getRandomValues(new Uint8Array(32)));
37
+ }
38
+ function createPermit2Nonce() {
39
+ const randomBytes = getCrypto().getRandomValues(new Uint8Array(32));
40
+ return BigInt(toHex(randomBytes)).toString();
41
+ }
42
+
43
+ // node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/dist/esm/chunk-5XX3PMSD.mjs
44
+ var BATCH_SETTLEMENT_SCHEME = "batch-settlement";
45
+ var BATCH_SETTLEMENT_ADDRESS = "0x4020074e9dF2ce1deE5A9C1b5c3f541D02a10003";
46
+ var ERC3009_DEPOSIT_COLLECTOR_ADDRESS = "0x4020806089470a89826cB9fB1f4059150b550004";
47
+ var PERMIT2_DEPOSIT_COLLECTOR_ADDRESS = "0x4020425FAf3B746C082C2f942b4E5159887B0005";
48
+ var MIN_WITHDRAW_DELAY = 900;
49
+ var BATCH_SETTLEMENT_DOMAIN = {
50
+ name: "x402 Batch Settlement",
51
+ version: "1"
52
+ };
53
+ var CHANNEL_CONFIG_TYPEHASH = keccak256(
54
+ toBytes(
55
+ "ChannelConfig(address payer,address payerAuthorizer,address receiver,address receiverAuthorizer,address token,uint40 withdrawDelay,bytes32 salt)"
56
+ )
57
+ );
58
+ var channelConfigTypes = {
59
+ ChannelConfig: [
60
+ { name: "payer", type: "address" },
61
+ { name: "payerAuthorizer", type: "address" },
62
+ { name: "receiver", type: "address" },
63
+ { name: "receiverAuthorizer", type: "address" },
64
+ { name: "token", type: "address" },
65
+ { name: "withdrawDelay", type: "uint40" },
66
+ { name: "salt", type: "bytes32" }
67
+ ]
68
+ };
69
+ var voucherTypes = {
70
+ Voucher: [
71
+ { name: "channelId", type: "bytes32" },
72
+ { name: "maxClaimableAmount", type: "uint128" }
73
+ ]
74
+ };
75
+ var receiveAuthorizationTypes = {
76
+ ReceiveWithAuthorization: [
77
+ { name: "from", type: "address" },
78
+ { name: "to", type: "address" },
79
+ { name: "value", type: "uint256" },
80
+ { name: "validAfter", type: "uint256" },
81
+ { name: "validBefore", type: "uint256" },
82
+ { name: "nonce", type: "bytes32" }
83
+ ]
84
+ };
85
+ var batchPermit2WitnessTypes = {
86
+ PermitWitnessTransferFrom: [
87
+ { name: "permitted", type: "TokenPermissions" },
88
+ { name: "spender", type: "address" },
89
+ { name: "nonce", type: "uint256" },
90
+ { name: "deadline", type: "uint256" },
91
+ { name: "witness", type: "DepositWitness" }
92
+ ],
93
+ TokenPermissions: [
94
+ { name: "token", type: "address" },
95
+ { name: "amount", type: "uint256" }
96
+ ],
97
+ DepositWitness: [{ name: "channelId", type: "bytes32" }]
98
+ };
99
+ var ErrCumulativeAmountBelowClaimed = "invalid_batch_settlement_evm_cumulative_below_claimed";
100
+ var ErrInvalidChannelId = "invalid_batch_settlement_evm_channel_id_invalid";
101
+ var ErrCumulativeAmountMismatch = "invalid_batch_settlement_evm_cumulative_amount_mismatch";
102
+ var ErrRefundNoBalance = "invalid_batch_settlement_evm_refund_no_balance";
103
+ var ErrRefundAmountInvalid = "invalid_batch_settlement_evm_refund_amount_invalid";
104
+ var CHANNEL_ID_RE = /^0x[0-9a-fA-F]{64}$/;
105
+ function isCanonicalChannelId(value) {
106
+ return typeof value === "string" && CHANNEL_ID_RE.test(value);
107
+ }
108
+ function normalizeChannelId(channelId) {
109
+ if (!isCanonicalChannelId(channelId)) {
110
+ throw new Error(ErrInvalidChannelId);
111
+ }
112
+ return channelId.toLowerCase();
113
+ }
114
+ function computeChannelId(config, networkOrChainId) {
115
+ const chainId = typeof networkOrChainId === "number" ? networkOrChainId : getEvmChainId(networkOrChainId);
116
+ return hashTypedData({
117
+ domain: getBatchSettlementEip712Domain(chainId),
118
+ types: channelConfigTypes,
119
+ primaryType: "ChannelConfig",
120
+ message: {
121
+ payer: config.payer,
122
+ payerAuthorizer: config.payerAuthorizer,
123
+ receiver: config.receiver,
124
+ receiverAuthorizer: config.receiverAuthorizer,
125
+ token: config.token,
126
+ withdrawDelay: config.withdrawDelay,
127
+ salt: config.salt
128
+ }
129
+ });
130
+ }
131
+ function getBatchSettlementEip712Domain(chainId) {
132
+ return {
133
+ ...BATCH_SETTLEMENT_DOMAIN,
134
+ chainId,
135
+ verifyingContract: getAddress(BATCH_SETTLEMENT_ADDRESS)
136
+ };
137
+ }
138
+
139
+ export {
140
+ getEvmChainId,
141
+ createNonce,
142
+ createPermit2Nonce,
143
+ BATCH_SETTLEMENT_SCHEME,
144
+ BATCH_SETTLEMENT_ADDRESS,
145
+ ERC3009_DEPOSIT_COLLECTOR_ADDRESS,
146
+ PERMIT2_DEPOSIT_COLLECTOR_ADDRESS,
147
+ MIN_WITHDRAW_DELAY,
148
+ voucherTypes,
149
+ receiveAuthorizationTypes,
150
+ batchPermit2WitnessTypes,
151
+ ErrCumulativeAmountBelowClaimed,
152
+ ErrCumulativeAmountMismatch,
153
+ ErrRefundNoBalance,
154
+ ErrRefundAmountInvalid,
155
+ normalizeChannelId,
156
+ computeChannelId,
157
+ getBatchSettlementEip712Domain
158
+ };
159
+ //# sourceMappingURL=chunk-LFZJM56J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/utils.ts","../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/batch-settlement/constants.ts","../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/batch-settlement/errors.ts","../node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/src/batch-settlement/utils.ts"],"sourcesContent":["import type { Network, SettleResponse } from \"@x402/core/types\";\nimport { isHash, toHex } from \"viem\";\n\n/** CAIP-2 `eip155` reference: a bare decimal chain ID, matching the Go and Python SDKs. */\nconst EIP155_NETWORK_REGEX = /^eip155:(\\d+)$/;\n\n/**\n * Extract chain ID from a CAIP-2 network identifier (eip155:CHAIN_ID).\n *\n * @param network - The network identifier in CAIP-2 format (e.g., \"eip155:8453\")\n * @returns The numeric chain ID\n * @throws Error if the network format is invalid\n */\nexport function getEvmChainId(network: string): number {\n if (!network.startsWith(\"eip155:\")) {\n throw new Error(`Unsupported network format: ${network} (expected eip155:CHAIN_ID)`);\n }\n\n const match = EIP155_NETWORK_REGEX.exec(network);\n if (!match) {\n throw new Error(`Invalid CAIP-2 chain ID: ${network}`);\n }\n\n const chainId = Number(match[1]);\n if (!Number.isSafeInteger(chainId)) {\n throw new Error(`Invalid CAIP-2 chain ID: ${network}`);\n }\n\n return chainId;\n}\n\n/**\n * Get the crypto object from the global scope.\n *\n * @returns The crypto object\n * @throws Error if crypto API is not available\n */\nfunction getCrypto(): Crypto {\n const cryptoObj = globalThis.crypto as Crypto | undefined;\n if (!cryptoObj) {\n throw new Error(\"Crypto API not available\");\n }\n return cryptoObj;\n}\n\n/**\n * Create a random 32-byte nonce for EIP-3009 authorization.\n *\n * @returns A hex-encoded 32-byte nonce\n */\nexport function createNonce(): `0x${string}` {\n return toHex(getCrypto().getRandomValues(new Uint8Array(32)));\n}\n\n/**\n * Creates a random 256-bit nonce for Permit2.\n * Permit2 uses uint256 nonces (not bytes32 like EIP-3009).\n *\n * @returns A string representation of the random nonce\n */\nexport function createPermit2Nonce(): string {\n const randomBytes = getCrypto().getRandomValues(new Uint8Array(32));\n return BigInt(toHex(randomBytes)).toString();\n}\n\n/** Matches the truncation length used by the Go and Python SDKs. */\nexport const MAX_ERROR_MESSAGE_LENGTH = 500;\n\n/**\n * Bounds raw error text (e.g. from an RPC client) before it is placed in a settle/verify\n * errorMessage. RPC/transport errors can carry node URLs, request bodies, or other verbose\n * data that should not be echoed to callers unbounded.\n *\n * @param message - Raw error text to bound.\n * @returns `message`, truncated to {@link MAX_ERROR_MESSAGE_LENGTH} characters.\n */\nexport function truncateErrorMessage(message: string): string {\n return message.slice(0, MAX_ERROR_MESSAGE_LENGTH);\n}\n\n/**\n * Last hash from a two-request extension-signer broadcast (e.g. approve + settle/deposit).\n * Conforming signers return one hash (atomic bundle) or two (sequential); any other\n * count means a partial execution.\n *\n * @param txHashes - Hashes returned by the signer for the two-request broadcast\n * @returns The final transaction hash, or undefined if the hash count is invalid\n */\nexport function finalHashFromTwoRequestSend<T extends string>(\n txHashes: readonly T[],\n): T | undefined {\n if (txHashes.length !== 1 && txHashes.length !== 2) {\n return undefined;\n }\n return txHashes[txHashes.length - 1];\n}\n\n/**\n * Checks that a signer-supplied transaction hash is usable for a receipt wait. The all-zero\n * hash is rejected because it reconciles to nothing, so a signer reporting success with a\n * placeholder fails terminally instead of as settlement_pending.\n *\n * @param hash - Transaction hash returned by the signer\n * @returns True if the hash is a well-formed, non-zero 32-byte hash\n */\nexport function isValidTxHash(hash: string): boolean {\n return isHash(hash) && !/^0x0+$/.test(hash);\n}\n\n/**\n * Terminal failure when a signer reports success without a usable transaction hash.\n *\n * @param tx - Value returned in place of a valid transaction hash\n * @param errorReason - Scheme/action-specific terminal error reason\n * @param network - Network the transaction was broadcast to\n * @param payer - Payer address, when known\n * @returns Failed {@link SettleResponse} with no transaction hash\n */\nexport function invalidBroadcastHashResponse(\n tx: unknown,\n errorReason: string,\n network: Network,\n payer?: string,\n): SettleResponse {\n return {\n success: false,\n errorReason,\n errorMessage: `signer returned an invalid transaction hash: ${typeof tx === \"string\" ? tx : JSON.stringify(tx)}`,\n transaction: \"\",\n network,\n payer,\n };\n}\n","import { keccak256, toBytes } from \"viem\";\n\n/** Scheme identifier for the batch-settlement payment scheme. */\nexport const BATCH_SETTLEMENT_SCHEME = \"batch-settlement\" as const;\n\n/** Deployed address of the x402BatchSettlement contract. */\nexport const BATCH_SETTLEMENT_ADDRESS = \"0x4020074e9dF2ce1deE5A9C1b5c3f541D02a10003\" as const;\n\n/** Deployed address of the ERC3009DepositCollector contract. */\nexport const ERC3009_DEPOSIT_COLLECTOR_ADDRESS =\n \"0x4020806089470a89826cB9fB1f4059150b550004\" as const;\n\n/** Deployed address of the Permit2DepositCollector contract. */\nexport const PERMIT2_DEPOSIT_COLLECTOR_ADDRESS =\n \"0x4020425FAf3B746C082C2f942b4E5159887B0005\" as const;\n\n/**\n * Bounds for the post-transaction channel-state polling loops in refund.ts and\n * deposit.ts, which re-read onchain state until it reflects a just-confirmed\n * change (a pending-withdrawal cancellation or a deposit balance increase).\n * Shared so both call sites stay in lockstep.\n */\nexport const CHANNEL_STATE_POLL_MS = 2_000;\nexport const CHANNEL_STATE_POLL_INTERVAL_MS = 150;\n\n/** Default server SDK multiplier for `extra.minDeposit` when no floor is configured. */\nexport const DEFAULT_SERVER_MIN_DEPOSIT_MULTIPLIER = 10;\n\n/** Minimum withdraw delay in seconds (15 minutes), matching the onchain constant. */\nexport const MIN_WITHDRAW_DELAY = 900;\n\n/** Maximum withdraw delay in seconds (30 days), matching the onchain constant. */\nexport const MAX_WITHDRAW_DELAY = 2_592_000;\n\n/** EIP-712 domain fields shared across all batch-settlement typed-data signatures. */\nexport const BATCH_SETTLEMENT_DOMAIN = {\n name: \"x402 Batch Settlement\",\n version: \"1\",\n} as const;\n\n/** EIP-712 type hash for channel identity. */\nexport const CHANNEL_CONFIG_TYPEHASH = keccak256(\n toBytes(\n \"ChannelConfig(address payer,address payerAuthorizer,address receiver,address receiverAuthorizer,address token,uint40 withdrawDelay,bytes32 salt)\",\n ),\n);\n\n/** EIP-712 type definition for a channel configuration. */\nexport const channelConfigTypes = {\n ChannelConfig: [\n { name: \"payer\", type: \"address\" },\n { name: \"payerAuthorizer\", type: \"address\" },\n { name: \"receiver\", type: \"address\" },\n { name: \"receiverAuthorizer\", type: \"address\" },\n { name: \"token\", type: \"address\" },\n { name: \"withdrawDelay\", type: \"uint40\" },\n { name: \"salt\", type: \"bytes32\" },\n ],\n} as const;\n\n/** EIP-712 type definition for a cumulative voucher: `Voucher(bytes32 channelId, uint128 maxClaimableAmount)`. */\nexport const voucherTypes = {\n Voucher: [\n { name: \"channelId\", type: \"bytes32\" },\n { name: \"maxClaimableAmount\", type: \"uint128\" },\n ],\n} as const;\n\n/** EIP-712 type definition for cooperative refund: `Refund(bytes32 channelId, uint256 nonce, uint128 amount)`. */\nexport const refundTypes = {\n Refund: [\n { name: \"channelId\", type: \"bytes32\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"amount\", type: \"uint128\" },\n ],\n} as const;\n\n/** EIP-712 type definitions for a receiver-authorizer claim batch (nested ClaimEntry). */\nexport const claimBatchTypes = {\n ClaimBatch: [{ name: \"claims\", type: \"ClaimEntry[]\" }],\n ClaimEntry: [\n { name: \"channelId\", type: \"bytes32\" },\n { name: \"maxClaimableAmount\", type: \"uint128\" },\n { name: \"totalClaimed\", type: \"uint128\" },\n ],\n} as const;\n\n/** EIP-712 type definition for ERC-3009 `ReceiveWithAuthorization` (used for gasless deposits). */\nexport const receiveAuthorizationTypes = {\n ReceiveWithAuthorization: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n ],\n} as const;\n\n/** Permit2 typed data for channel-bound batch deposits. */\nexport const batchPermit2WitnessTypes = {\n PermitWitnessTransferFrom: [\n { name: \"permitted\", type: \"TokenPermissions\" },\n { name: \"spender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"witness\", type: \"DepositWitness\" },\n ],\n TokenPermissions: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n DepositWitness: [{ name: \"channelId\", type: \"bytes32\" }],\n} as const;\n","/** Error codes for the batch-settlement EVM scheme (see scheme_batch_settlement_evm2.md). */\n\nexport const ErrChannelNotFound = \"invalid_batch_settlement_evm_channel_not_found\";\nexport const ErrTokenMismatch = \"invalid_batch_settlement_evm_token_mismatch\";\nexport const ErrInvalidVoucherSignature = \"invalid_batch_settlement_evm_voucher_signature\";\nexport const ErrCumulativeExceedsBalance =\n \"invalid_batch_settlement_evm_cumulative_exceeds_balance\";\nexport const ErrCumulativeAmountBelowClaimed =\n \"invalid_batch_settlement_evm_cumulative_below_claimed\";\nexport const ErrInsufficientBalance = \"invalid_batch_settlement_evm_insufficient_balance\";\nexport const ErrDepositTransactionFailed =\n \"invalid_batch_settlement_evm_deposit_transaction_failed\";\nexport const ErrClaimTransactionFailed = \"invalid_batch_settlement_evm_claim_transaction_failed\";\nexport const ErrSettleTransactionFailed = \"invalid_batch_settlement_evm_settle_transaction_failed\";\nexport const ErrInvalidScheme = \"invalid_batch_settlement_evm_scheme\";\nexport const ErrNetworkMismatch = \"invalid_batch_settlement_evm_network_mismatch\";\nexport const ErrMissingEip712Domain = \"invalid_batch_settlement_evm_missing_eip712_domain\";\nexport const ErrValidBeforeExpired =\n \"invalid_batch_settlement_evm_payload_authorization_valid_before\";\nexport const ErrValidAfterInFuture =\n \"invalid_batch_settlement_evm_payload_authorization_valid_after\";\nexport const ErrInvalidReceiveAuthorizationSignature =\n \"invalid_batch_settlement_evm_receive_authorization_signature\";\nexport const ErrErc3009AuthorizationRequired =\n \"invalid_batch_settlement_evm_erc3009_authorization_required\";\nexport const ErrRefundTransactionFailed = \"invalid_batch_settlement_evm_refund_transaction_failed\";\nexport const ErrInvalidPayloadType = \"invalid_batch_settlement_evm_payload_type\";\nexport const ErrWithdrawDelayOutOfRange =\n \"invalid_batch_settlement_evm_withdraw_delay_out_of_range\";\nexport const ErrChannelIdMismatch = \"invalid_batch_settlement_evm_channel_id_mismatch\";\nexport const ErrInvalidChannelId = \"invalid_batch_settlement_evm_channel_id_invalid\";\nexport const ErrReceiverMismatch = \"invalid_batch_settlement_evm_receiver_mismatch\";\nexport const ErrReceiverAuthorizerMismatch =\n \"invalid_batch_settlement_evm_receiver_authorizer_mismatch\";\nexport const ErrWithdrawDelayMismatch = \"invalid_batch_settlement_evm_withdraw_delay_mismatch\";\nexport const ErrAuthorizerAddressMismatch =\n \"invalid_batch_settlement_evm_authorizer_address_mismatch\";\nexport const ErrAuthorizerNotConfigured = \"invalid_batch_settlement_evm_authorizer_not_configured\";\nexport const ErrDepositSimulationFailed = \"invalid_batch_settlement_evm_deposit_simulation_failed\";\nexport const ErrDepositBelowMinDeposit = \"invalid_batch_settlement_evm_deposit_below_min_deposit\";\n\n// ERC-6492 counterfactual deployment errors (ERC-3009 deposit path). Wire values keep the\n// scheme prefix to match the rest of this module's contract.\nexport const ErrFactoryNotAllowed = \"invalid_batch_settlement_evm_eip6492_factory_not_allowed\";\nexport const ErrSmartWalletDeploymentFailed =\n \"invalid_batch_settlement_evm_smart_wallet_deployment_failed\";\nexport const ErrClaimSimulationFailed = \"invalid_batch_settlement_evm_claim_simulation_failed\";\nexport const ErrSettleSimulationFailed = \"invalid_batch_settlement_evm_settle_simulation_failed\";\nexport const ErrNothingToSettle = \"invalid_batch_settlement_evm_nothing_to_settle\";\nexport const ErrRefundPayload = \"invalid_batch_settlement_evm_refund_payload\";\nexport const ErrRefundSimulationFailed = \"invalid_batch_settlement_evm_refund_simulation_failed\";\nexport const ErrRpcReadFailed = \"invalid_batch_settlement_evm_rpc_read_failed\";\nexport const ErrPermit2AuthorizationRequired =\n \"invalid_batch_settlement_evm_permit2_authorization_required\";\nexport const ErrPermit2InvalidSpender = \"invalid_batch_settlement_evm_permit2_invalid_spender\";\nexport const ErrPermit2AmountMismatch = \"invalid_batch_settlement_evm_permit2_amount_mismatch\";\nexport const ErrPermit2DeadlineExpired = \"invalid_batch_settlement_evm_permit2_deadline_expired\";\nexport const ErrPermit2InvalidSignature = \"invalid_batch_settlement_evm_permit2_invalid_signature\";\nexport const ErrPermit2AllowanceRequired =\n \"invalid_batch_settlement_evm_permit2_allowance_required\";\nexport const ErrEip2612AmountMismatch = \"invalid_batch_settlement_evm_eip2612_amount_mismatch\";\nexport const ErrEip2612OwnerMismatch = \"invalid_batch_settlement_evm_eip2612_owner_mismatch\";\nexport const ErrEip2612AssetMismatch = \"invalid_batch_settlement_evm_eip2612_asset_mismatch\";\nexport const ErrEip2612SpenderMismatch = \"invalid_batch_settlement_evm_eip2612_spender_mismatch\";\nexport const ErrEip2612DeadlineExpired = \"invalid_batch_settlement_evm_eip2612_deadline_expired\";\nexport const ErrErc20ApprovalUnavailable =\n \"invalid_batch_settlement_evm_erc20_approval_unavailable\";\n\n/** Resource server: 402 `error` and lifecycle `reason` (same strings as the spec). */\nexport const ErrCumulativeAmountMismatch =\n \"invalid_batch_settlement_evm_cumulative_amount_mismatch\";\nexport const ErrChannelBusy = \"invalid_batch_settlement_evm_channel_busy\";\nexport const ErrVerificationStateUnavailable =\n \"invalid_batch_settlement_evm_verification_state_unavailable\";\nexport const ErrChargeExceedsSignedCumulative =\n \"invalid_batch_settlement_evm_charge_exceeds_signed_cumulative\";\nexport const ErrMissingChannel = \"invalid_batch_settlement_evm_missing_channel\";\nexport const ErrRefundNoBalance = \"invalid_batch_settlement_evm_refund_no_balance\";\nexport const ErrRefundAmountInvalid = \"invalid_batch_settlement_evm_refund_amount_invalid\";\n","import { getAddress, hashTypedData } from \"viem\";\nimport { BATCH_SETTLEMENT_ADDRESS, BATCH_SETTLEMENT_DOMAIN, channelConfigTypes } from \"./constants\";\nimport { ErrChannelIdMismatch, ErrInvalidChannelId } from \"./errors\";\nimport type { ChannelConfig } from \"./types\";\nimport { getEvmChainId } from \"../utils\";\n\n/** Canonical `bytes32` channel id: `0x` followed by exactly 64 hex digits. */\nconst CHANNEL_ID_RE = /^0x[0-9a-fA-F]{64}$/;\n\n/**\n * Narrows an untrusted value to a canonical `bytes32` channel id string.\n *\n * @param value - The value to test.\n * @returns `true` when `value` is a `0x`-prefixed 64-hex-digit string.\n */\nexport function isCanonicalChannelId(value: unknown): value is `0x${string}` {\n return typeof value === \"string\" && CHANNEL_ID_RE.test(value);\n}\n\n/**\n * Validates canonical `bytes32` form and normalizes to lowercase.\n *\n * @param channelId - Untrusted channel identifier from a request payload.\n * @returns The lowercased channel id.\n * @throws When `channelId` is not a canonical `bytes32` string. The message is generic\n * so untrusted input is never echoed into logs.\n */\nexport function normalizeChannelId(channelId: string): `0x${string}` {\n if (!isCanonicalChannelId(channelId)) {\n throw new Error(ErrInvalidChannelId);\n }\n return channelId.toLowerCase() as `0x${string}`;\n}\n\n/**\n * Binds a claimed channel id to a channel config and network.\n *\n * @param config - The immutable channel configuration from the payload.\n * @param claimedChannelId - The channel id the client claims the config resolves to.\n * @param networkOrChainId - CAIP-2 network identifier or numeric EVM chain id.\n * @returns An error code when the id is malformed or does not match the config, else `undefined`.\n */\nexport function channelIdBindingError(\n config: ChannelConfig,\n claimedChannelId: string,\n networkOrChainId: string | number,\n): string | undefined {\n if (!isCanonicalChannelId(claimedChannelId)) return ErrInvalidChannelId;\n if (computeChannelId(config, networkOrChainId).toLowerCase() !== claimedChannelId.toLowerCase()) {\n return ErrChannelIdMismatch;\n }\n return undefined;\n}\n\n/**\n * Computes the chain-bound channel id from a {@link ChannelConfig} struct.\n *\n * @param config - The immutable channel configuration.\n * @param networkOrChainId - CAIP-2 network identifier or numeric EVM chain id.\n * @returns The `bytes32` channel id as a hex string.\n */\nexport function computeChannelId(\n config: ChannelConfig,\n networkOrChainId: string | number,\n): `0x${string}` {\n const chainId =\n typeof networkOrChainId === \"number\" ? networkOrChainId : getEvmChainId(networkOrChainId);\n return hashTypedData({\n domain: getBatchSettlementEip712Domain(chainId),\n types: channelConfigTypes,\n primaryType: \"ChannelConfig\",\n message: {\n payer: config.payer,\n payerAuthorizer: config.payerAuthorizer,\n receiver: config.receiver,\n receiverAuthorizer: config.receiverAuthorizer,\n token: config.token,\n withdrawDelay: config.withdrawDelay,\n salt: config.salt,\n },\n });\n}\n\n/**\n * Returns the full EIP-712 domain for the batch-settlement contract on the given chain.\n *\n * @param chainId - Numeric EVM chain id.\n * @returns EIP-712 domain with `name`, `version`, `chainId`, and checksummed `verifyingContract`.\n */\nexport function getBatchSettlementEip712Domain(chainId: number) {\n return {\n ...BATCH_SETTLEMENT_DOMAIN,\n chainId,\n verifyingContract: getAddress(BATCH_SETTLEMENT_ADDRESS),\n } as const;\n}\n"],"mappings":"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","names":[]}
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  inspectHooksFile
4
- } from "./chunk-SQSKVKX6.js";
4
+ } from "./chunk-KGTQRJGS.js";
5
5
  import {
6
6
  CliError,
7
7
  writeFileAtomic
@@ -169,4 +169,4 @@ export {
169
169
  removeStatusLine,
170
170
  inspectStatusLine
171
171
  };
172
- //# sourceMappingURL=chunk-YZTIYDWU.js.map
172
+ //# sourceMappingURL=chunk-NTYQHAIM.js.map
@@ -1,18 +1,18 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  setTenjinIdentity
4
- } from "./chunk-RCJ64OXH.js";
4
+ } from "./chunk-CEMXMUIU.js";
5
5
  import {
6
6
  hasCode
7
7
  } from "./chunk-2I4QTOLB.js";
8
8
  import {
9
9
  isTeamModeConfig
10
- } from "./chunk-TMLCEPCD.js";
10
+ } from "./chunk-HII5HOQV.js";
11
11
  import {
12
12
  knownDeploymentOrigins,
13
13
  loadRawConfig,
14
14
  resolveSettings
15
- } from "./chunk-P22ZWXFX.js";
15
+ } from "./chunk-XICKN3CH.js";
16
16
  import {
17
17
  writeFileAtomicExclusive
18
18
  } from "./chunk-JLEF5WHM.js";
@@ -109,4 +109,4 @@ export {
109
109
  enableCliIdentity,
110
110
  enableDaemonIdentity
111
111
  };
112
- //# sourceMappingURL=chunk-IIE65SJC.js.map
112
+ //# sourceMappingURL=chunk-NYPFOHSJ.js.map
@@ -3,14 +3,14 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "tenjin-cli",
6
- version: "0.1.0-alpha.24",
6
+ version: "0.1.0-alpha.25",
7
7
  type: "module",
8
8
  description: "The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.",
9
9
  repository: {
10
10
  type: "git",
11
11
  url: "git+https://github.com/BackTrackCo/tenjin-agent.git"
12
12
  },
13
- homepage: "https://tenjin.blog/agents",
13
+ homepage: "https://tenjin.sh/agents",
14
14
  bugs: "https://github.com/BackTrackCo/tenjin-agent/issues",
15
15
  keywords: [
16
16
  "claude-code",
@@ -58,11 +58,12 @@ var package_default = {
58
58
  "@changesets/cli": "^3.0.3",
59
59
  "@clack/prompts": "^1.7.0",
60
60
  "@eslint/js": "^10",
61
- "@modelcontextprotocol/sdk": "1.29.0",
61
+ "@modelcontextprotocol/sdk": "1.31.0",
62
62
  "@types/node": "^25",
63
- "@x402/core": "2.17.0",
64
- "@x402/evm": "2.17.0",
65
- "@x402/extensions": "2.17.0",
63
+ "@x402/core": "2.28.0",
64
+ "@x402/evm": "2.28.0",
65
+ "@x402/extensions": "2.28.0",
66
+ "@x402/fetch": "2.28.0",
66
67
  ajv: "^8.20.0",
67
68
  "ajv-formats": "^3.0.1",
68
69
  commander: "^14.0.1",
@@ -82,4 +83,4 @@ var package_default = {
82
83
  export {
83
84
  package_default
84
85
  };
85
- //# sourceMappingURL=chunk-ZNZGBUV6.js.map
86
+ //# sourceMappingURL=chunk-ODH7UXIS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.25\",\n \"type\": \"module\",\n \"description\": \"The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.sh/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"claude-code\",\n \"coding-agents\",\n \"tool-router\",\n \"ai-agents\",\n \"agent-tools\",\n \"mcp\",\n \"x402\",\n \"usdc\",\n \"base\",\n \"micropayments\",\n \"agent-payments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=24\"\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"rm -rf dist && tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"githooks\": \"git config core.hooksPath .githooks\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^3.0.3\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.31.0\",\n \"@types/node\": \"^25\",\n \"@x402/core\": \"2.28.0\",\n \"@x402/evm\": \"2.28.0\",\n \"@x402/extensions\": \"2.28.0\",\n \"@x402/fetch\": \"2.28.0\",\n \"ajv\": \"^8.20.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,EAClB,SAAW;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,cAAc;AAAA,IACd,WAAa;AAAA,IACb,gBAAkB;AAAA,IAClB,UAAY;AAAA,EACd;AAAA,EACA,iBAAmB;AAAA,IACjB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,6BAA6B;AAAA,IAC7B,eAAe;AAAA,IACf,cAAc;AAAA,IACd,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,KAAO;AAAA,IACP,eAAe;AAAA,IACf,WAAa;AAAA,IACb,QAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,IAAM;AAAA,IACN,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,KAAO;AAAA,EACT;AACF;","names":[]}
@@ -5,12 +5,12 @@ import {
5
5
  mainWorktreeOf,
6
6
  ownedCandidates,
7
7
  projectRoot
8
- } from "./chunk-TMLCEPCD.js";
8
+ } from "./chunk-HII5HOQV.js";
9
9
  import {
10
10
  CONFIG_DEFAULTS,
11
11
  loadRawConfig,
12
12
  parseRouterLayer
13
- } from "./chunk-P22ZWXFX.js";
13
+ } from "./chunk-XICKN3CH.js";
14
14
  import {
15
15
  CliError
16
16
  } from "./chunk-JLEF5WHM.js";
@@ -124,4 +124,4 @@ export {
124
124
  readProjectRouterFile,
125
125
  projectRouterPath
126
126
  };
127
- //# sourceMappingURL=chunk-NSDZESRS.js.map
127
+ //# sourceMappingURL=chunk-OZ3LWLCI.js.map
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  emitNotice
4
- } from "./chunk-O2WN732M.js";
4
+ } from "./chunk-UDWGT4FX.js";
5
5
  import {
6
6
  external_exports,
7
7
  loadConfig
8
- } from "./chunk-P22ZWXFX.js";
8
+ } from "./chunk-XICKN3CH.js";
9
9
  import {
10
10
  package_default
11
- } from "./chunk-ZNZGBUV6.js";
11
+ } from "./chunk-ODH7UXIS.js";
12
12
  import {
13
13
  writeFileAtomic
14
14
  } from "./chunk-JLEF5WHM.js";
@@ -191,4 +191,4 @@ export {
191
191
  fetchDistTags,
192
192
  isNewer
193
193
  };
194
- //# sourceMappingURL=chunk-XRW4N23F.js.map
194
+ //# sourceMappingURL=chunk-SCAE6PW6.js.map
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  external_exports
4
- } from "./chunk-P22ZWXFX.js";
4
+ } from "./chunk-XICKN3CH.js";
5
5
  import {
6
6
  CliError
7
7
  } from "./chunk-JLEF5WHM.js";
@@ -228,4 +228,4 @@ export {
228
228
  sanitizeForTerminal,
229
229
  paint
230
230
  };
231
- //# sourceMappingURL=chunk-O2WN732M.js.map
231
+ //# sourceMappingURL=chunk-UDWGT4FX.js.map
@@ -0,0 +1,119 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ hasCode
4
+ } from "./chunk-2I4QTOLB.js";
5
+ import {
6
+ formatUsdDisplay
7
+ } from "./chunk-XICKN3CH.js";
8
+
9
+ // src/router/fee.ts
10
+ import { createHash } from "node:crypto";
11
+ import { mkdir, open, readFile, readdir, rm } from "node:fs/promises";
12
+ import { join } from "node:path";
13
+ var ROUTE_PAID_PATH = "/api/x402-router/route";
14
+ var ROUTING_FEE_ATOMIC = 3000n;
15
+ var CHANNEL_DEPOSIT_ATOMIC = 250000n;
16
+ var MIN_DEPOSIT_ATOMIC = 10n * ROUTING_FEE_ATOMIC;
17
+ var FEE_REQUIRED = "fee_required";
18
+ function isFeeRequired(response) {
19
+ const decision = response?.decision;
20
+ const diagnostics = decision?.diagnostics;
21
+ return decision?.action === "native" && diagnostics?.reasonCode === FEE_REQUIRED;
22
+ }
23
+ var UNPAID = {
24
+ wallet_low: {
25
+ reason: `the wallet holds less than the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,
26
+ fix: `Fund it with \`tenjin wallet fund ${usd(CHANNEL_DEPOSIT_ATOMIC)}\`.`
27
+ },
28
+ wallet_locked: {
29
+ reason: "`tenjin mcp` cannot unlock the wallet without a prompt",
30
+ fix: "Set TENJIN_WALLET_PASSPHRASE in the environment Claude Code starts from, then restart Claude Code."
31
+ },
32
+ no_wallet: {
33
+ reason: "this machine has no wallet",
34
+ fix: "Run `tenjin doctor`."
35
+ },
36
+ limit_below_deposit: {
37
+ reason: `the per-call spend limit is below the smallest routing deposit ($${usd(MIN_DEPOSIT_ATOMIC)})`,
38
+ fix: "Run `tenjin doctor`."
39
+ },
40
+ budget_reached: {
41
+ reason: "the daily spend limit has no room left for a routing deposit",
42
+ fix: "Run `tenjin doctor`."
43
+ },
44
+ not_allowlisted: {
45
+ reason: "allowlistCreators does not include the router",
46
+ fix: "Run `tenjin doctor`."
47
+ },
48
+ payment_failed: {
49
+ reason: "the routing payment failed",
50
+ fix: "Run `tenjin doctor`."
51
+ },
52
+ [FEE_REQUIRED]: {
53
+ reason: "the router now charges it, and this session cannot pay it",
54
+ fix: "Run `tenjin doctor`."
55
+ }
56
+ };
57
+ var NO_FAULT = /* @__PURE__ */ new Set(["channel_busy", "paid_path_absent", "busy", "no_call"]);
58
+ function unpaid(why) {
59
+ if (NO_FAULT.has(why)) return null;
60
+ return UNPAID[why] ?? UNPAID["payment_failed"];
61
+ }
62
+ function unpaidSentence(why) {
63
+ const u = unpaid(why);
64
+ if (u === null) return null;
65
+ return `Tenjin routing could not pay its $${usd(ROUTING_FEE_ATOMIC)} fee (${u.reason}), so calls take the free path until that is fixed. ${u.fix}`;
66
+ }
67
+ var ADDRESS_RE = /^0x[0-9a-f]{40}$/;
68
+ function payerDir(dataDir, payer) {
69
+ const name = payer.toLowerCase();
70
+ if (!ADDRESS_RE.test(name)) throw new Error(`not a wallet address: ${payer}`);
71
+ return join(dataDir, "router", "fee", name);
72
+ }
73
+ function usd(atomic) {
74
+ return formatUsdDisplay(atomic.toString());
75
+ }
76
+ var NOTICE_KEEP_MS = 7 * 864e5;
77
+ async function firstNoticeFor(dataDir, sessionId, now) {
78
+ const dir = join(dataDir, "router", "notices");
79
+ const name = createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
80
+ const created = await createExclusive(join(dir, name), String(now));
81
+ if (created) {
82
+ for (const entry of await readdir(dir).catch(() => [])) {
83
+ const path = join(dir, entry);
84
+ const at = Number(await readFile(path, "utf8").catch(() => "NaN"));
85
+ if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });
86
+ }
87
+ }
88
+ return created;
89
+ }
90
+ async function createExclusive(path, body) {
91
+ try {
92
+ await mkdir(join(path, ".."), { recursive: true, mode: 448 });
93
+ const handle = await open(path, "wx", 384);
94
+ try {
95
+ await handle.writeFile(body);
96
+ } finally {
97
+ await handle.close();
98
+ }
99
+ return true;
100
+ } catch (err) {
101
+ if (hasCode(err, "EEXIST")) return false;
102
+ throw err;
103
+ }
104
+ }
105
+
106
+ export {
107
+ ROUTE_PAID_PATH,
108
+ ROUTING_FEE_ATOMIC,
109
+ CHANNEL_DEPOSIT_ATOMIC,
110
+ MIN_DEPOSIT_ATOMIC,
111
+ FEE_REQUIRED,
112
+ isFeeRequired,
113
+ unpaid,
114
+ unpaidSentence,
115
+ payerDir,
116
+ usd,
117
+ firstNoticeFor
118
+ };
119
+ //# sourceMappingURL=chunk-VYONGSMQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/fee.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, open, readFile, readdir, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { hasCode } from '../lib/errno';\nimport { formatUsdDisplay } from '../lib/money';\nimport type { DecisionRoute } from './decision';\n\n/**\n * THE ROUTING FEE, WITHOUT ANYTHING THAT PAYS. Every routing call on the paid\n * path pays $0.003 over x402 `batch-settlement`, and the stock SDK client in\n * `tenjin mcp` does all of it (`routing-payer.ts`). Everything else, `tenjin\n * hook` included, is the free path exactly as before this fee existed.\n *\n * Hook-safe: `tenjin hook` loads this module, and its chunk graph stays free\n * of the wallet and the x402 SDK (`dist-chunks.test.ts`).\n */\n\nexport const ROUTE_PAID_PATH = '/api/x402-router/route';\n\n/** The flat fee per routing call, atomic USDC ($0.003). */\nexport const ROUTING_FEE_ATOMIC = 3_000n;\n/** The largest channel deposit, atomic USDC ($0.25), made inline by the SDK\n * on the first paid call of a channel that cannot cover the next fee. */\nexport const CHANNEL_DEPOSIT_ATOMIC = 250_000n;\n/**\n * The smallest deposit worth signing: ten fees ($0.03). A per-call limit under\n * $0.25 sizes the deposit down to the limit while it still covers this many.\n */\nexport const MIN_DEPOSIT_ATOMIC = 10n * ROUTING_FEE_ATOMIC;\n\n/** The paid path for this call, or null for the free path. `tenjin mcp` passes\n * its payer's; absent, every call is free. */\nexport type RouteFor = (baseUrl: string) => Promise<DecisionRoute | null>;\n\n/** The free path's reason code once the server routes only paid calls. */\nexport const FEE_REQUIRED = 'fee_required';\n\n/** Whether a decision is the free path's `fee_required` answer. */\nexport function isFeeRequired(response: unknown): boolean {\n const decision = (response as { decision?: { action?: unknown; diagnostics?: unknown } })\n ?.decision;\n const diagnostics = decision?.diagnostics as { reasonCode?: unknown } | undefined;\n return decision?.action === 'native' && diagnostics?.reasonCode === FEE_REQUIRED;\n}\n\n/**\n * WHY A CALL WAS NOT PAID, for the user: the reason and the fix, keyed by the\n * payer's skip reason (or `fee_required`, when the free path answered it and\n * nothing else explains why). Null for a reason that is no fault and needs no\n * fix: another session's call on the channel, a server with no paid path, or\n * a call queued past its own budget.\n */\nconst UNPAID: Record<string, { reason: string; fix: string }> = {\n wallet_low: {\n reason: `the wallet holds less than the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,\n fix: `Fund it with \\`tenjin wallet fund ${usd(CHANNEL_DEPOSIT_ATOMIC)}\\`.`,\n },\n wallet_locked: {\n reason: '`tenjin mcp` cannot unlock the wallet without a prompt',\n fix: 'Set TENJIN_WALLET_PASSPHRASE in the environment Claude Code starts from, then restart Claude Code.',\n },\n no_wallet: {\n reason: 'this machine has no wallet',\n fix: 'Run `tenjin doctor`.',\n },\n limit_below_deposit: {\n reason: `the per-call spend limit is below the smallest routing deposit ($${usd(MIN_DEPOSIT_ATOMIC)})`,\n fix: 'Run `tenjin doctor`.',\n },\n budget_reached: {\n reason: 'the daily spend limit has no room left for a routing deposit',\n fix: 'Run `tenjin doctor`.',\n },\n not_allowlisted: {\n reason: 'allowlistCreators does not include the router',\n fix: 'Run `tenjin doctor`.',\n },\n payment_failed: {\n reason: 'the routing payment failed',\n fix: 'Run `tenjin doctor`.',\n },\n [FEE_REQUIRED]: {\n reason: 'the router now charges it, and this session cannot pay it',\n fix: 'Run `tenjin doctor`.',\n },\n};\nconst NO_FAULT = new Set(['channel_busy', 'paid_path_absent', 'busy', 'no_call']);\n\n/** The reason and fix for an unpaid call, or null when it needs no word. */\nexport function unpaid(why: string): { reason: string; fix: string } | null {\n if (NO_FAULT.has(why)) return null;\n return UNPAID[why] ?? UNPAID['payment_failed']!;\n}\n\n/** The one line the user sees, once per session, when a call was not paid. */\nexport function unpaidSentence(why: string): string | null {\n const u = unpaid(why);\n if (u === null) return null;\n return `Tenjin routing could not pay its $${usd(ROUTING_FEE_ATOMIC)} fee (${u.reason}), so calls take the free path until that is fixed. ${u.fix}`;\n}\n\nconst ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/** One wallet's folder: the SDK's file storage for its routing channel\n * (`client/<channelId>.json`). */\nexport function payerDir(dataDir: string, payer: string): string {\n const name = payer.toLowerCase();\n if (!ADDRESS_RE.test(name)) throw new Error(`not a wallet address: ${payer}`);\n return join(dataDir, 'router', 'fee', name);\n}\n\n/** Atomic USDC as dollars with at least two decimals, never a float. */\nexport function usd(atomic: bigint): string {\n return formatUsdDisplay(atomic.toString());\n}\n\n/** How long a session's notice marker is kept. */\nconst NOTICE_KEEP_MS = 7 * 86_400_000;\n\n/**\n * TRUE ONCE PER SESSION: the first caller for a session id creates its marker\n * and gets true; every later one gets false. Each marker holds the time it was\n * made, and those older than a week go on the way past, so the directory does\n * not grow with every session ever run.\n */\nexport async function firstNoticeFor(\n dataDir: string,\n sessionId: string,\n now: number,\n): Promise<boolean> {\n const dir = join(dataDir, 'router', 'notices');\n const name = createHash('sha256').update(sessionId).digest('hex').slice(0, 32);\n const created = await createExclusive(join(dir, name), String(now));\n if (created) {\n for (const entry of await readdir(dir).catch(() => [] as string[])) {\n const path = join(dir, entry);\n const at = Number(await readFile(path, 'utf8').catch(() => 'NaN'));\n if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });\n }\n }\n return created;\n}\n\nasync function createExclusive(path: string, body: string): Promise<boolean> {\n try {\n await mkdir(join(path, '..'), { recursive: true, mode: 0o700 });\n const handle = await open(path, 'wx', 0o600);\n try {\n await handle.writeFile(body);\n } finally {\n await handle.close();\n }\n return true;\n } catch (err) {\n if (hasCode(err, 'EEXIST')) return false;\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,MAAM,UAAU,SAAS,UAAU;AACnD,SAAS,YAAY;AAed,IAAM,kBAAkB;AAGxB,IAAM,qBAAqB;AAG3B,IAAM,yBAAyB;AAK/B,IAAM,qBAAqB,MAAM;AAOjC,IAAM,eAAe;AAGrB,SAAS,cAAc,UAA4B;AACxD,QAAM,WAAY,UACd;AACJ,QAAM,cAAc,UAAU;AAC9B,SAAO,UAAU,WAAW,YAAY,aAAa,eAAe;AACtE;AASA,IAAM,SAA0D;AAAA,EAC9D,YAAY;AAAA,IACV,QAAQ,mCAAmC,IAAI,sBAAsB,CAAC;AAAA,IACtE,KAAK,qCAAqC,IAAI,sBAAsB,CAAC;AAAA,EACvE;AAAA,EACA,eAAe;AAAA,IACb,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,qBAAqB;AAAA,IACnB,QAAQ,oEAAoE,IAAI,kBAAkB,CAAC;AAAA,IACnG,KAAK;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,IACd,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,IACd,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,CAAC,YAAY,GAAG;AAAA,IACd,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AACF;AACA,IAAM,WAAW,oBAAI,IAAI,CAAC,gBAAgB,oBAAoB,QAAQ,SAAS,CAAC;AAGzE,SAAS,OAAO,KAAqD;AAC1E,MAAI,SAAS,IAAI,GAAG,EAAG,QAAO;AAC9B,SAAO,OAAO,GAAG,KAAK,OAAO,gBAAgB;AAC/C;AAGO,SAAS,eAAe,KAA4B;AACzD,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,MAAM,KAAM,QAAO;AACvB,SAAO,qCAAqC,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,uDAAuD,EAAE,GAAG;AAClJ;AAEA,IAAM,aAAa;AAIZ,SAAS,SAAS,SAAiB,OAAuB;AAC/D,QAAM,OAAO,MAAM,YAAY;AAC/B,MAAI,CAAC,WAAW,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAC5E,SAAO,KAAK,SAAS,UAAU,OAAO,IAAI;AAC5C;AAGO,SAAS,IAAI,QAAwB;AAC1C,SAAO,iBAAiB,OAAO,SAAS,CAAC;AAC3C;AAGA,IAAM,iBAAiB,IAAI;AAQ3B,eAAsB,eACpB,SACA,WACA,KACkB;AAClB,QAAM,MAAM,KAAK,SAAS,UAAU,SAAS;AAC7C,QAAM,OAAO,WAAW,QAAQ,EAAE,OAAO,SAAS,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC7E,QAAM,UAAU,MAAM,gBAAgB,KAAK,KAAK,IAAI,GAAG,OAAO,GAAG,CAAC;AAClE,MAAI,SAAS;AACX,eAAW,SAAS,MAAM,QAAQ,GAAG,EAAE,MAAM,MAAM,CAAC,CAAa,GAAG;AAClE,YAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,YAAM,KAAK,OAAO,MAAM,SAAS,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,CAAC;AACjE,UAAI,CAAC,OAAO,SAAS,EAAE,KAAK,MAAM,KAAK,eAAgB,OAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;AAAA,IACvF;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAe,gBAAgB,MAAc,MAAgC;AAC3E,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,IAAI,GAAG,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAC9D,UAAM,SAAS,MAAM,KAAK,MAAM,MAAM,GAAK;AAC3C,QAAI;AACF,YAAM,OAAO,UAAU,IAAI;AAAA,IAC7B,UAAE;AACA,YAAM,OAAO,MAAM;AAAA,IACrB;AACA,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,QAAI,QAAQ,KAAK,QAAQ,EAAG,QAAO;AACnC,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -14527,11 +14527,11 @@ function date4(params) {
14527
14527
  config(en_default());
14528
14528
 
14529
14529
  // src/lib/production-origin.ts
14530
- var PRODUCTION_ORIGIN = "https://tenjin.blog";
14530
+ var PRODUCTION_ORIGIN = "https://tenjin.sh";
14531
14531
  var PRODUCTION_HOST = new URL(PRODUCTION_ORIGIN).host;
14532
14532
  var KNOWN_DEPLOYMENT_ORIGINS = /* @__PURE__ */ new Set([
14533
14533
  PRODUCTION_ORIGIN,
14534
- "https://tenjin.sh"
14534
+ "https://tenjin.blog"
14535
14535
  ]);
14536
14536
  function isSameDeployment(a, b) {
14537
14537
  if (a === b) return true;
@@ -15135,6 +15135,47 @@ function isNotFound(err) {
15135
15135
  return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
15136
15136
  }
15137
15137
 
15138
+ // src/lib/money.ts
15139
+ var USDC_DECIMALS = 6;
15140
+ function parseUsdToAtomic(input) {
15141
+ const trimmed = input.trim();
15142
+ if (!/^\d+(\.\d+)?$/.test(trimmed)) {
15143
+ throw new CliError("USAGE", `Invalid USD amount: ${JSON.stringify(input)}`, {
15144
+ fix: "Pass a non-negative decimal like 0.25 or 5."
15145
+ });
15146
+ }
15147
+ const [whole, frac = ""] = trimmed.split(".");
15148
+ if (frac.length > USDC_DECIMALS) {
15149
+ throw new CliError(
15150
+ "USAGE",
15151
+ `USD amount ${JSON.stringify(input)} has more than 6 decimal places`,
15152
+ {
15153
+ fix: "USDC supports at most 6 decimal places (micro-dollars)."
15154
+ }
15155
+ );
15156
+ }
15157
+ const atomic = BigInt(`${whole}${frac.padEnd(USDC_DECIMALS, "0")}`);
15158
+ return atomic.toString();
15159
+ }
15160
+ function atomicToUsd(atomic) {
15161
+ const trimmed = atomic.trim();
15162
+ if (!/^\d+$/.test(trimmed)) {
15163
+ throw new CliError("INTERNAL", `Malformed atomic amount: ${JSON.stringify(atomic)}`);
15164
+ }
15165
+ const value = BigInt(trimmed);
15166
+ const base = 10n ** BigInt(USDC_DECIMALS);
15167
+ const whole = value / base;
15168
+ const frac = (value % base).toString().padStart(USDC_DECIMALS, "0").replace(/0+$/, "");
15169
+ return frac.length > 0 ? `${whole}.${frac}` : whole.toString();
15170
+ }
15171
+ function toMoney(atomic) {
15172
+ return { atomic, usd: atomicToUsd(atomic) };
15173
+ }
15174
+ function formatUsdDisplay(atomic) {
15175
+ const [whole, frac = ""] = atomicToUsd(atomic).split(".");
15176
+ return `${whole}.${frac.padEnd(2, "0")}`;
15177
+ }
15178
+
15138
15179
  export {
15139
15180
  $constructor,
15140
15181
  defineLazy,
@@ -15171,6 +15212,7 @@ export {
15171
15212
  isSameDeployment,
15172
15213
  knownDeploymentOrigins,
15173
15214
  USDC_ADDRESS,
15215
+ readUsdcBalance,
15174
15216
  readUsdcBalanceWithFallback,
15175
15217
  rememberingBalanceReader,
15176
15218
  PublishModeSchema,
@@ -15196,6 +15238,9 @@ export {
15196
15238
  loadRawConfig,
15197
15239
  loadConfig,
15198
15240
  resolveSettings,
15199
- resolveExperimentalBazaar
15241
+ resolveExperimentalBazaar,
15242
+ parseUsdToAtomic,
15243
+ toMoney,
15244
+ formatUsdDisplay
15200
15245
  };
15201
- //# sourceMappingURL=chunk-P22ZWXFX.js.map
15246
+ //# sourceMappingURL=chunk-XICKN3CH.js.map