@aifinpay/mcp 2.4.1 → 2.7.0

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 (49) hide show
  1. package/README.md +161 -31
  2. package/dist/config.d.ts +15 -3
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +65 -7
  5. package/dist/config.js.map +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/native-price.d.ts +18 -9
  11. package/dist/native-price.d.ts.map +1 -1
  12. package/dist/native-price.js +37 -32
  13. package/dist/native-price.js.map +1 -1
  14. package/dist/pay-chains.d.ts +32 -0
  15. package/dist/pay-chains.d.ts.map +1 -0
  16. package/dist/pay-chains.js +38 -0
  17. package/dist/pay-chains.js.map +1 -0
  18. package/dist/payment-identity.d.ts +17 -0
  19. package/dist/payment-identity.d.ts.map +1 -0
  20. package/dist/payment-identity.js +75 -0
  21. package/dist/payment-identity.js.map +1 -0
  22. package/dist/payment-state.d.ts +2 -1
  23. package/dist/payment-state.d.ts.map +1 -1
  24. package/dist/payment-state.js +52 -17
  25. package/dist/payment-state.js.map +1 -1
  26. package/dist/server.d.ts +1 -1
  27. package/dist/server.d.ts.map +1 -1
  28. package/dist/server.js +11 -2
  29. package/dist/server.js.map +1 -1
  30. package/dist/tools/agent-address.d.ts.map +1 -1
  31. package/dist/tools/agent-address.js +1 -1
  32. package/dist/tools/agent-address.js.map +1 -1
  33. package/dist/tools/agent-claim-self.d.ts +3 -3
  34. package/dist/tools/agent-claim-self.d.ts.map +1 -1
  35. package/dist/tools/agent-claim-self.js +65 -88
  36. package/dist/tools/agent-claim-self.js.map +1 -1
  37. package/dist/tools/agent-history.d.ts +0 -1
  38. package/dist/tools/agent-history.d.ts.map +1 -1
  39. package/dist/tools/agent-history.js +51 -52
  40. package/dist/tools/agent-history.js.map +1 -1
  41. package/dist/tools/agent-quota.d.ts.map +1 -1
  42. package/dist/tools/agent-quota.js +42 -11
  43. package/dist/tools/agent-quota.js.map +1 -1
  44. package/dist/tools/payable-fetch.d.ts.map +1 -1
  45. package/dist/tools/payable-fetch.js +178 -66
  46. package/dist/tools/payable-fetch.js.map +1 -1
  47. package/package.json +6 -6
  48. package/skills/SKILL.md +168 -34
  49. package/smithery.yaml +72 -40
package/README.md CHANGED
@@ -4,9 +4,12 @@ AiFinPay MCP server for persistent agent identity, Agent Passport resolution,
4
4
  route discovery and non-signing settlement invoices. Canonical domain:
5
5
  **aifinpay.io**.
6
6
 
7
- Version **2.4.1**. Owner-enabled native Polygon v1.4 purchases with
8
- `payable_fetch` are released (since 2.2.0); site-wide batches with
9
- `scope: "merchant"` since 2.4.1. Without payment configuration the server keeps
7
+ Version **2.7.0** is prepared in this checkout, requiring agent2.5.0 and canonical skill2.8.0.
8
+ The published baseline checked2026-10-04 was MCP2.5.0. Package publication and
9
+ real registry dependency/lock refresh remain release gates; a source-cohort
10
+ build does not prove those steps. Owner-enabled v1.4 purchases with `payable_fetch` are
11
+ released: on Polygon since 2.2.0, on Base (ETH or USDC) since 2.5.0; site-wide
12
+ batches with `scope: "merchant"` since 2.4.1. Without payment configuration the server keeps
10
13
  its inspection-only tool inventory.
11
14
 
12
15
  ## Enable native paid GET requests
@@ -47,13 +50,41 @@ To pay in USDC instead of native POL, the owner also sets
47
50
  POL for gas: an exact-amount token approval plus the settlement, both within
48
51
  `AIFINPAY_MAX_GAS_POL` together. Unset or `"POL"` keeps native POL.
49
52
 
53
+ ### Paying on another chain
54
+
55
+ `AIFINPAY_PAY_CHAIN` explicitly picks the chain `payable_fetch` settles on:
56
+ `polygon` by default, or an exact supported name in the capability list below.
57
+ Only the owner sets it, and a merchant is paid on a chain
58
+ only if its quote is for that chain; a quote for any other chain is refused,
59
+ never followed. On Base the batch is paid in ETH (or `AIFINPAY_PAY_ASSET:
60
+ "USDC"`) and gas is ETH, so the cap is `AIFINPAY_MAX_GAS`, in ETH:
61
+
62
+ ```json
63
+ {
64
+ "AIFINPAY_PAY_CHAIN": "base",
65
+ "AIFINPAY_MAX_GAS": "0.0002"
66
+ }
67
+ ```
68
+
69
+ `AIFINPAY_MAX_GAS` is the gas cap in the pay chain's native currency;
70
+ `AIFINPAY_MAX_GAS_POL` remains accepted on Polygon and is refused on Base rather
71
+ than read as ETH (0.3 POL is about $0.04; 0.3 ETH is several hundred dollars).
72
+ On Base the worst case includes L1 data and operator fees; the owner must set
73
+ the cap from the current estimate. The wallet's EVM address is the same on every chain, so
74
+ fund it with ETH on Base, not on Ethereum mainnet. `AIFINPAY_RPC_URL` optionally
75
+ replaces the chain's public RPC (`https://mainnet.base.org`,
76
+ `https://polygon.drpc.org`).
77
+
78
+ A payment still pending on one chain is recovered only with that chain
79
+ configured; switching chains never re-sends or forgets it.
80
+
50
81
  Call `payable_fetch({"url":"https://merchant.example/api/data"})`. The tool
51
- uses the original signed v1.4 quote, independent fresh POL/USD pricing, SDK
82
+ uses the original signed v1.4 quote, independent fresh native/USD pricing, SDK
52
83
  runtime/signer verification and owner limits. It persists the prepared transaction
53
84
  before sending, verifies the receipt, and reuses the purchased batch. No special
54
- merchant script, alternate contract or facilitator fallback is used. GET,
55
- Polygon live mode only, in POL or the configured stablecoin; Amoy payment
56
- receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
85
+ merchant script, alternate contract or facilitator fallback is used. GET on the configured chain; EVM receipt payments use live
86
+ mode only, in its native currency or the configured
87
+ stablecoin; Amoy payment receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
57
88
  a little above the batch you expect to buy.
58
89
 
59
90
  To buy access to a whole site rather than one endpoint, call
@@ -67,9 +98,10 @@ owner can add it.
67
98
  ### Network access
68
99
 
69
100
  A sandbox that allowlists outbound hosts must allow `api.aifinpay.io` (quotes and
70
- receipts) and a Polygon RPC. The independent POL/USD rate comes from Chainlink
71
- on Polygon over that same RPC, then `api.coinbase.com`, then `api.coingecko.com`;
72
- one of them is enough. If none answers, `payable_fetch` stops before paying and
101
+ receipts) and an RPC for the pay chain. The independent native/USD rate
102
+ uses the pinned Chainlink feed on Polygon/Base, then `api.coinbase.com`,
103
+ then `api.coingecko.com`; other chains use those HTTP price sources.
104
+ If none provides a valid fresh rate, `payable_fetch` stops before paying and
73
105
  the error names each host it tried.
74
106
 
75
107
  ## Link the agent to its owner's dashboard
@@ -78,15 +110,18 @@ The owner sees the agent's balance, payments and receipts at
78
110
  https://dash.aifinpay.io → My Agents. There, **Claim via MCP** generates a
79
111
  one-time URL; pass it to `agent_claim_self`. The tool contacts only AiFinPay
80
112
  origins, signs only the claim challenge for this agent's own address, and moves
81
- no funds. Offer this to the owner after `init`.
113
+ no funds. The owner-selected payment family must be confirmed successfully;
114
+ the second wallet is best-effort. Use the selected wallet's Fund panel for
115
+ available networks and assets; binding does not activate a disabled network.
116
+ Offer this to the owner after `init`.
82
117
 
83
- Private recovery state lives at `AIFINPAY_HOME/payments/<evm-address>/state.json`
118
+ Private recovery state for all payment families lives at `AIFINPAY_HOME/payments/<evm-address>/state.json`
84
119
  (default home `~/.aifinpay`). State is mode600 in mode700 directories, atomically
85
120
  written and fsynced. One operation lock serializes the wallet across processes.
86
121
  A retry recovers a pending receipt before allowing another purchase. A process
87
122
  crash leaves the lock for owner reconciliation; it is never stolen automatically.
88
- If a prepared transaction was never broadcast or reverted, reconcile its exact
89
- hash before clearing anything. Never put raw transactions, receipt JWTs or the
123
+ If a prepared transaction was never broadcast or its outcome remains unknown,
124
+ reconcile its exact hash before clearing anything. Never put raw transactions, receipt JWTs or the
90
125
  state file in chat. Unconfirmed payments consume the budget conservatively.
91
126
 
92
127
  ## Tools
@@ -100,10 +135,18 @@ state file in chat. Unconfirmed payments consume the budget conservatively.
100
135
  | `agent_passport_resolve` | Resolve the global Agent Passport identity. |
101
136
  | `settlement_routes` | Read the available verified settlement routes. |
102
137
  | `settlement_invoice` | Prepare a non-signing settlement invoice. |
103
-
104
- `payable_fetch` appears only with valid owner payment configuration and a persistent wallet.
105
- Legacy `agent_call`, `agent_quote`, `pay_with_split` and `quote_split` remain
106
- unregistered.
138
+ | `agent_history` | Read indexed settlements or retained receipt batches. |
139
+ | `settlement_solana` | Build a non-signing Solana settlement invoice. |
140
+ | `settlement_casper` | Build a non-signing Casper settlement invoice. |
141
+ | `deployment_info` | Read deployments: addresses, assets, settlement status. |
142
+
143
+ `payable_fetch` is registered when the owner sets `AIFINPAY_PAYMENTS_ENABLED=1`
144
+ with a persistent wallet. With payments enabled and any owner limit missing or
145
+ invalid, the server refuses to start rather than hiding the tool. It accepts
146
+ only `url`, `max_amount_usd` and `scope`; `max_amount_usd` can lower the owner's
147
+ per-payment cap for one call, never raise it. `dev_payment_quote` is registered
148
+ only with `AIFINPAY_MODE=dev`. Legacy `agent_call`, `agent_quote`,
149
+ `pay_with_split` and `quote_split` remain unregistered.
107
150
 
108
151
  ## Persistent wallet selection
109
152
 
@@ -162,7 +205,7 @@ A client configuration can use the keystore without embedding its secret:
162
205
  "mcpServers": {
163
206
  "aifinpay": {
164
207
  "command": "npx",
165
- "args": ["-y", "@aifinpay/mcp@2.4.1"],
208
+ "args": ["-y", "@aifinpay/mcp"],
166
209
  "env": {
167
210
  "AIFINPAY_AGENTS_FILE": "/absolute/project/aifinpay/agents.json",
168
211
  "AIFINPAY_AGENT_ID": "research-agent"
@@ -197,23 +240,30 @@ snapshot. Verify `agent_address` against the wallet you intend to use.
197
240
 
198
241
  ## Other environment variables
199
242
 
200
- | Variable | Default | Purpose |
201
- | ---------------------------- | --------------------- | ------------------------------------------------------------------------------------ |
202
- | `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL. |
203
- | `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
204
- | `AIFINPAY_MAX_USD` | — | Configures the underlying agent's per-call cap; it does not enable signing. |
205
- | `AIFINPAY_GATEWAY_ORIGINS` | SDK default | Comma-separated exact HTTPS origins trusted for AIFP-1 settlement. |
206
- | `AIFINPAY_GATEWAY_PATH_MODE` | `gateway` | Use `gateway` for merchant-slug identity or `direct` for full request-path identity. |
207
-
208
- `agent_history({address, source:"transactions"})` reads indexed Polygon
209
- settlements; `source:"receipts"` reads retained batches, including test-mode
243
+ | Variable | Default | Purpose |
244
+ | ---------------------------- | --------------------- | ------------------------------------------------------------------------------------- |
245
+ | `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL. Unset, `payable_fetch` quotes and verifies at `https://api.aifinpay.io`. |
246
+ | `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
247
+ | `AIFINPAY_MAX_USD` | — | Per-payment USD cap for `payable_fetch`; required when payments are enabled. |
248
+ | `AIFINPAY_GATEWAY_ORIGINS` | — | Comma-separated exact HTTPS origins the agent may pay; required with payments. |
249
+ | `AIFINPAY_GATEWAY_PATH_MODE` | `gateway` | Use `gateway` for merchant-slug identity or `direct` for full request-path identity. |
250
+ | `AIFINPAY_PAY_CHAIN` | `polygon` | Owner-selected payment chain; see the2.7.0 source capability list. |
251
+ | `AIFINPAY_MAX_GAS` | — | Gas cap per payment in the pay chain's native currency (POL, ETH, AVAX, BNB, XRP). |
252
+ | `AIFINPAY_RPC_URL` | chain's public RPC | HTTPS RPC for the pay chain. |
253
+ | `AIFINPAY_CLAIM_ORIGINS` | AiFinPay dashboards | Exact origins `agent_claim_self` may link the agent to. |
254
+
255
+ `agent_history({address, source:"transactions", network:"polygon"})` reads
256
+ indexed settlements for that network when the backend's durable indexer serves
257
+ it. The dated production baseline has Polygon indexing; another client chain
258
+ descriptor alone does not prove history coverage. `source:"receipts"` reads retained batches, including test-mode
210
259
  payments. Pass `passport` instead of, or alongside, `address` to resolve a
211
260
  public passport first. A backend without the passport resolver cannot satisfy
212
261
  passport-only queries. No secret API key is needed for public metadata.
213
262
 
214
263
  Responses do not include bearer receipts. Limits are 1..100; follow
215
264
  `next_offset`. History source/coverage is explicit: it is not a full wallet
216
- explorer. Dev networks currently use receipt history, not the Polygon ledger.
265
+ explorer. Test-mode indexing depends on backend capabilities; retained receipt
266
+ history is a separate source and does not establish mainnet activation.
217
267
 
218
268
  ```
219
269
  const { server } = await createServer(loadConfigFromEnv());
@@ -228,7 +278,7 @@ The programmatic equivalents of identity environment options are `seedHash`,
228
278
  - AIFINPAY_MODE=dev: expose dev_payment_quote; requires a separate dev base URL.
229
279
 
230
280
  - AIFINPAY_TIMEOUT_MS: SDK request timeout.
231
- - AIFINPAY_MAX_USD: legacy per-call budget; does not enable signing.
281
+ - AIFINPAY_MAX_USD: per-payment USD cap for payable_fetch; required with payments.
232
282
  - AIFINPAY_TRUSTED_HOSTS: exact hosts allowed to bypass the DNS pre-check.
233
283
  - AIFINPAY_ALLOW_PRIVATE_FETCH=1: explicit local-development network access.
234
284
  Never enable this on the public hosted MCP.
@@ -246,3 +296,83 @@ executor; this MCP does not expose Amoy paid receipt purchases.
246
296
  ## License
247
297
 
248
298
  MIT.
299
+
300
+ ## Additional EVM networks in the 2.7.0 source candidate
301
+
302
+ Owner `AIFINPAY_PAY_CHAIN` accepts polygon, base, optimism, arbitrum, avalanche,
303
+ bnb, unichain, xrplevm and robinhood. `AIFINPAY_MAX_GAS` is in the selected native
304
+ POL/ETH/AVAX/BNB/XRP currency; the legacy POL cap applies only on Polygon. Assets
305
+ must be pinned for that chain, including BNB 18-decimal USDC/USDT and Robinhood
306
+ 18-decimal USDe/6-decimal USDG. XRPL EVM has native XRP only. Metadata comes from
307
+ agent 2.5.0; the backend must still authorize and serve that merchant/network.
308
+ Source support does not activate networks in production. Pending journals retain
309
+ the original chain and are recovered without another settlement. A legacy
310
+ missing-chain journal is adopted only when the owner-configured chain and the
311
+ actual signed transaction's chain ID, payer, pinned target and exact call agree.
312
+ Insufficient evidence requires manual receipt reconciliation. A later quote
313
+ expiry does not invalidate receipt recovery for an existing payment.
314
+
315
+ Release order: publish reviewed canonical skill2.8.0 and agent2.5.0, refresh MCP
316
+ dependencies and lock from those real registry releases, pass standalone MCP
317
+ CI, then publish MCP2.7.0. This candidate is tested against fresh source-packed
318
+ agent2.5.0 and skill2.8.0. The existing registry entries remain until publication;
319
+ no npm integrity/resolution is fabricated. An old2.3.x agent cannot build the
320
+ new descriptor/helper imports, and old skill2.6.0 cannot satisfy the exact
321
+ release-target guard. Hosted source CI uses `scripts/check-mcp-source-cohort.mjs`: a byte-preserving fixed registry bootstrap and genuine same-commit Node plus fully pinned canonical skill packages in disposable directories. Exact package bytes, versions, bundled skill and full tests must pass; the registry publication guard must still refuse this source cohort. Standalone release CI requires the refreshed real registry lock. Never publish the candidate with the old registry dependency lock.
322
+
323
+ Use one shared local filesystem for a wallet's ledger/journal and reconcile
324
+ pending transactions before downgrading. Node 2.4 reservations never expire for
325
+ an unknown outcome; receipt failures never refund confirmed spend. Older SDK
326
+ versions can expire or reset this state. Custom capped v1.4 ledger adapters need
327
+ the new bound preparation/recovery/completion hooks; absence refuses payment.
328
+
329
+ ## Solana source candidate
330
+
331
+ Version2.7 targets NodeSDK2.5 and canonical skill2.8. These are coordinated
332
+ release targets; source integration does not establish npm publication or
333
+ activate a network. The published deployments1.1.3 Solana entries remain
334
+ disabled. `payable_fetch` retains the SDK availability check and cannot
335
+ override it.
336
+
337
+ For a separately accepted and served Solana route, the owner sets
338
+ `AIFINPAY_PAY_CHAIN=solana`, explicit `AIFINPAY_SOLANA_NETWORK=mainnet` with
339
+ live mode (or devnet with dev mode), and a trusted HTTPS `AIFINPAY_RPC_URL`.
340
+ `AIFINPAY_MAX_FEE_LAMPORTS` is a positive integer cap on transaction fees plus
341
+ required account rent; EVM gas caps cannot be used on Solana. Native SOL and
342
+ network-pinned classic SPL assets are selected with `AIFINPAY_PAY_ASSET`.
343
+ Existing payments opt-in, approved origins and per-payment/daily USD caps
344
+ remain required.
345
+
346
+ Before a Solana quote request, SDK2.5 saves the exact signed authorization,
347
+ nonce and owner context in its shared private ledger. After a timeout or
348
+ restart it replays that admission instead of generating a new nonce. The
349
+ per-payment limit stays fixed for that admission across daily rollover;
350
+ MCP still checks the current daily allowance before submission. An exact
351
+ authenticated non-admission response can close only an unreserved local
352
+ intent. It never refunds an issued backend quote reservation. Keep pending
353
+ 2.5 ledger state when upgrading; reconcile it before downgrade and never
354
+ delete state to retry a payment.
355
+
356
+ The private durable journal keeps the full signed Solana transaction and
357
+ base58 signature before submission, including fee/rent in the admission
358
+ amount. Payer identities retain case. Restart/retry recovers the original
359
+ receipt; timeout or blockhash expiry never triggers a replacement payment.
360
+ The same local wallet budget remains shared across payment families.
361
+
362
+ A proven finalized Solana transaction failure is returned as an error, without
363
+ a receipt or replacement payment. After the SDK verifies the exact signed
364
+ transaction and canonical finalized block and durably reconciles its bound
365
+ ledger, MCP atomically retains the actual fee debit and clears its pending
366
+ purchase guard. Its private journal keeps the original signature and failed
367
+ status. Missing or mismatched evidence retains the full reservation; expiry
368
+ alone cannot release it. A persistence failure can be retried without resending.
369
+
370
+ Before publication, install the actual published coordinated Node/skill
371
+ versions and refresh the real registry lock; a locally packed source cohort
372
+ is test evidence only. Do not publish with the previous dependency lock.
373
+
374
+ Solana `agent_history` and `agent_quota` use the exact case-sensitive local
375
+ Solana address and owner-configured cluster plus independently pinned program.
376
+ They request the new program's indexed settlements and retained receipts; the
377
+ legacy program and another cluster are separate histories. Explicit EVM
378
+ history selection continues to use the wallet's EVM address.
package/dist/config.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface McpConfig {
8
8
  agentId?: string;
9
9
  walletHome?: string;
10
10
  walletPassphrase?: string;
11
- /** Enables dev discovery/quoting only; never enables settlement signing. */
11
+ /** Dev environment. EVM payments stay live-only; Solana requires explicit devnet. */
12
12
  devMode?: boolean;
13
13
  /** Custom AiFinPay backend URL. Defaults to production. */
14
14
  baseUrl?: string;
@@ -17,9 +17,21 @@ export interface McpConfig {
17
17
  /** Owner opt-in; never accepted from tool arguments. */
18
18
  paymentsEnabled?: boolean;
19
19
  dailyAmountUsd?: number;
20
+ /** Chain payable_fetch settles on: "polygon" (default), another supported EVM chain, or "solana". Set by
21
+ * the owner only; never inferred from a quote or a tool argument. */
22
+ payChain?: string;
23
+ /** RPC for the pay chain; defaults to the chain's public RPC. */
24
+ rpcUrl?: string;
25
+ /** Gas cap per payment, in the pay chain's native currency (POL, ETH). */
26
+ maxGas?: string;
27
+ /** Owner-selected cluster, independently bound to live/prod or dev mode. */
28
+ solanaNetwork?: "mainnet" | "devnet";
29
+ /** Integer lamports for transaction fees and required account rent. */
30
+ maxFeeLamports?: string;
31
+ /** Same cap under its original name; accepted on Polygon only. */
20
32
  maxGasPol?: string;
21
- /** What payable_fetch pays with: "POL" (default) or a stablecoin the SDK
22
- * pins for Polygon v1.4, e.g. "USDC". Gas is paid in POL either way. */
33
+ /** What payable_fetch pays with: the chain's native currency (default) or a
34
+ * stablecoin the SDK pins for that chain, e.g. "USDC". Gas is native either way. */
23
35
  payAsset?: string;
24
36
  /** Hard cap on a single payment to prevent runaway agents. */
25
37
  maxAmountUsd?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MA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ClB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACrC,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;yFACqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;+CAW2C;IAC3C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAEvC;;;;;;;;;8CAS0C;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,qDAAqD;IACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,CA+B7C;AAgED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAkF/D"}
package/dist/config.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { paymentStableAsset, solanaStableMint } from "@aifinpay/agent";
2
+ import { payChain } from "./pay-chains.js";
1
3
  export function loadConfigFromEnv() {
2
4
  if (process.env.AIFINPAY_MODE && !["live", "dev"].includes(process.env.AIFINPAY_MODE)) {
3
5
  throw new Error("AIFINPAY_MODE must be live or dev");
@@ -8,6 +10,11 @@ export function loadConfigFromEnv() {
8
10
  return {
9
11
  paymentsEnabled: process.env.AIFINPAY_PAYMENTS_ENABLED === "1",
10
12
  dailyAmountUsd: process.env.AIFINPAY_DAILY_USD ? Number(process.env.AIFINPAY_DAILY_USD) : undefined,
13
+ payChain: process.env.AIFINPAY_PAY_CHAIN || undefined,
14
+ rpcUrl: process.env.AIFINPAY_RPC_URL || undefined,
15
+ maxGas: process.env.AIFINPAY_MAX_GAS || undefined,
16
+ solanaNetwork: parseSolanaNetwork(process.env.AIFINPAY_SOLANA_NETWORK),
17
+ maxFeeLamports: process.env.AIFINPAY_MAX_FEE_LAMPORTS || undefined,
11
18
  maxGasPol: process.env.AIFINPAY_MAX_GAS_POL || undefined,
12
19
  payAsset: process.env.AIFINPAY_PAY_ASSET || undefined,
13
20
  devMode: process.env.AIFINPAY_MODE === "dev",
@@ -25,6 +32,13 @@ export function loadConfigFromEnv() {
25
32
  trustedHosts: splitList(process.env.AIFINPAY_TRUSTED_HOSTS),
26
33
  };
27
34
  }
35
+ function parseSolanaNetwork(raw) {
36
+ if (raw === undefined)
37
+ return undefined;
38
+ if (raw === "mainnet" || raw === "devnet")
39
+ return raw;
40
+ throw new Error("AIFINPAY_SOLANA_NETWORK must be mainnet or devnet");
41
+ }
28
42
  function parseGatewayPathMode(raw) {
29
43
  if (raw === undefined || raw.trim() === "")
30
44
  return "gateway";
@@ -83,8 +97,20 @@ function splitOrigins(raw) {
83
97
  export function validatePaymentConfig(config) {
84
98
  if (!config.paymentsEnabled)
85
99
  throw new Error("Payments disabled; owner must set AIFINPAY_PAYMENTS_ENABLED=1");
86
- if (config.devMode)
87
- throw new Error("MCP receipt payments currently support Polygon live mode only");
100
+ const chain = payChain(config.payChain);
101
+ if (config.devMode && chain.name !== "solana")
102
+ throw new Error("MCP receipt payments support live mode only");
103
+ if (config.rpcUrl !== undefined) {
104
+ let rpc;
105
+ try {
106
+ rpc = new URL(config.rpcUrl);
107
+ }
108
+ catch {
109
+ rpc = undefined;
110
+ }
111
+ if (!rpc || rpc.protocol !== "https:" || rpc.username || rpc.password)
112
+ throw new Error("AIFINPAY_RPC_URL must be an https URL without credentials");
113
+ }
88
114
  for (const [name, value] of [
89
115
  ["AIFINPAY_MAX_USD", config.maxAmountUsd],
90
116
  ["AIFINPAY_DAILY_USD", config.dailyAmountUsd],
@@ -103,15 +129,47 @@ export function validatePaymentConfig(config) {
103
129
  }
104
130
  }))
105
131
  throw new Error("Payments require explicit exact HTTPS AIFINPAY_GATEWAY_ORIGINS");
106
- if (config.payAsset !== undefined && !/^[A-Z][A-Z0-9.]{1,11}$/.test(config.payAsset))
107
- throw new Error('AIFINPAY_PAY_ASSET must be "POL" or a stablecoin symbol such as "USDC"');
108
- const gas = config.maxGasPol;
132
+ if (chain.name === "solana") {
133
+ const expectedNetwork = config.devMode ? "devnet" : "mainnet";
134
+ if (config.solanaNetwork !== expectedNetwork)
135
+ throw new Error(`AIFINPAY_SOLANA_NETWORK must be ${expectedNetwork} for the configured AIFINPAY_MODE`);
136
+ if (!config.rpcUrl)
137
+ throw new Error("Solana payments require an explicit owner-trusted AIFINPAY_RPC_URL");
138
+ if (config.maxGas !== undefined || config.maxGasPol !== undefined)
139
+ throw new Error("Solana uses AIFINPAY_MAX_FEE_LAMPORTS for fees and rent; EVM gas caps do not apply");
140
+ if (config.payAsset !== undefined && config.payAsset !== "SOL") {
141
+ try {
142
+ solanaStableMint(config.solanaNetwork, config.payAsset);
143
+ }
144
+ catch {
145
+ throw new Error("AIFINPAY_PAY_ASSET is not pinned for the selected Solana network");
146
+ }
147
+ }
148
+ const fee = config.maxFeeLamports;
149
+ if (typeof fee !== "string" || !/^[1-9][0-9]*$/.test(fee) || BigInt(fee) > 2n ** 64n - 1n)
150
+ throw new Error("AIFINPAY_MAX_FEE_LAMPORTS must be a positive uint64 integer covering transaction fees and account rent");
151
+ return BigInt(fee);
152
+ }
153
+ if (config.solanaNetwork !== undefined || config.maxFeeLamports !== undefined)
154
+ throw new Error("Solana network and lamport fee settings require AIFINPAY_PAY_CHAIN=solana");
155
+ if (config.payAsset !== undefined &&
156
+ config.payAsset !== chain.native &&
157
+ !paymentStableAsset(chain.name, config.payAsset))
158
+ throw new Error(`AIFINPAY_PAY_ASSET must be "${chain.native}" or a stablecoin symbol pinned for ${chain.name}`);
159
+ // The POL-named cap means POL. Read on another chain it would silently cap
160
+ // ETH gas at a number chosen for POL — 0.3 POL is ~$0.04, 0.3 ETH is ~$800.
161
+ if (config.maxGasPol !== undefined && chain.name !== "polygon")
162
+ throw new Error(`AIFINPAY_MAX_GAS_POL caps POL gas and does not apply on ${chain.name}; set AIFINPAY_MAX_GAS in ${chain.native}`);
163
+ if (config.maxGas !== undefined && config.maxGasPol !== undefined && config.maxGas !== config.maxGasPol)
164
+ throw new Error("AIFINPAY_MAX_GAS and AIFINPAY_MAX_GAS_POL disagree; set one");
165
+ const name = config.maxGas !== undefined ? "AIFINPAY_MAX_GAS" : "AIFINPAY_MAX_GAS_POL";
166
+ const gas = config.maxGas ?? config.maxGasPol;
109
167
  if (typeof gas !== "string" || !/^(?:0|[1-9][0-9]*)(?:\.[0-9]{1,18})?$/.test(gas))
110
- throw new Error("AIFINPAY_MAX_GAS_POL must be a positive decimal with at most 18 places");
168
+ throw new Error(`${name} must be a positive decimal with at most 18 places: the gas cap per payment in ${chain.native}`);
111
169
  const [whole, fraction = ""] = gas.split(".");
112
170
  const wei = BigInt(whole) * 10n ** 18n + BigInt(fraction.padEnd(18, "0"));
113
171
  if (wei <= 0n || wei >= 2n ** 256n)
114
- throw new Error("AIFINPAY_MAX_GAS_POL is outside the supported range");
172
+ throw new Error(`${name} is outside the supported range`);
115
173
  return wei;
116
174
  }
117
175
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA+DA,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAA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AuC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/E,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,kFAAkF,KAAK,CAAC,MAAM,EAAE,CACxG,CAAC;IACJ,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iCAAiC,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Tools: public addresses, history, quotas, passport resolution, non-signing
6
6
  * settlement invoices, local wallet reload, and opt-in dev batch quoting.
7
- * Signing tools are not registered in this RC.
7
+ * The one signing tool, payable_fetch, is registered only when the owner
8
+ * enables payments with every limit set.
8
9
  *
9
10
  * Quick start (stdio transport for Claude Desktop / MCP-aware runtimes):
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Tools: public addresses, history, quotas, passport resolution, non-signing
6
6
  * settlement invoices, local wallet reload, and opt-in dev batch quoting.
7
- * Signing tools are not registered in this RC.
7
+ * The one signing tool, payable_fetch, is registered only when the owner
8
+ * enables payments with every limit set.
8
9
  *
9
10
  * Quick start (stdio transport for Claude Desktop / MCP-aware runtimes):
10
11
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { type PayChain } from "./pay-chains.js";
1
2
  /**
2
- * Independent POL/USD rate for payable_fetch.
3
+ * Independent native/USD rate for payable_fetch: POL on Polygon, ETH on Base.
3
4
  *
4
5
  * payable_fetch values a v1.4 quote in USD with a rate it fetches itself —
5
6
  * never the quote API's own — so the owner's per-payment and daily USD limits
@@ -9,23 +10,31 @@
9
10
  * it began, with nothing to try instead.
10
11
  *
11
12
  * Sources, in order; the first fresh, sane answer wins:
12
- * 1. Chainlink POL/USD on Polygon, read over the agent's own Polygon RPC —
13
- * the host the payment already needs, so no extra allowlist entry.
13
+ * 1. Chainlink <native>/USD on the payment chain, read over the agent's own
14
+ * RPC for that chain — the host the payment already needs, so no extra
15
+ * allowlist entry.
14
16
  * 2. api.coinbase.com spot price.
15
- * 3. api.coingecko.com, id polygon-ecosystem-token. NOT matic-network: that
16
- * id stopped updating in February 2026 and answers a stale, higher price.
17
+ * 3. api.coingecko.com.
18
+ * Feed addresses and ids live in pay-chains.ts.
17
19
  */
18
- export declare const CHAINLINK_POL_USD_POLYGON = "0xAB594600376Ec9fD91F8e885dADF0CE036862dE0";
20
+ export declare const CHAINLINK_POL_USD_POLYGON: `0x${string}` | undefined;
19
21
  export interface NativePrice {
20
22
  usd: number;
21
23
  observedAtMs: number;
22
- source: "chainlink-polygon" | "coinbase" | "coingecko";
24
+ source: `chainlink-${string}` | "coinbase" | "coingecko";
23
25
  }
24
26
  type FetchImpl = (input: string, init?: RequestInit) => Promise<Response>;
25
27
  /**
26
- * The first independent POL/USD rate any source gives. Throws one error naming
27
- * every source tried, so an agent in a restricted sandbox knows what to allow.
28
+ * The first independent native/USD rate any source gives for the payment
29
+ * chain. Throws one error naming every source tried, so an agent in a
30
+ * restricted sandbox knows what to allow.
28
31
  */
32
+ export declare function independentNativeUsd(opts: {
33
+ fetchImpl: FetchImpl;
34
+ chain: PayChain;
35
+ rpc?: string;
36
+ }): Promise<NativePrice>;
37
+ /** The Polygon rate, as before chains were configurable. */
29
38
  export declare function independentPolUsd(opts: {
30
39
  fetchImpl: FetchImpl;
31
40
  polygonRpc?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"native-price.d.ts","sourceRoot":"","sources":["../src/native-price.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AAOtF,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,mBAAmB,GAAG,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