@aifinpay/skill 2.12.2 → 2.12.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +38 -0
- package/README.md +15 -10
- package/agent/skills/aifinpay/SKILL.md +25 -15
- package/agent/skills/aifinpay-merchant/SKILL.md +141 -46
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aifinpay",
|
|
3
3
|
"description": "Payment rail for AI agents: pay for x402 APIs or charge agents for yours.",
|
|
4
|
-
"version": "2.12.
|
|
4
|
+
"version": "2.12.5",
|
|
5
5
|
"author": { "name": "AiFinPay Support" },
|
|
6
6
|
"homepage": "https://aifinpay.io",
|
|
7
7
|
"repository": "https://github.com/AiFinPay/skill",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## 2.12.5 — no fixed fee rate
|
|
2
|
+
|
|
3
|
+
- Both guides: the AIFP-1 fee is described as included in the quoted price,
|
|
4
|
+
with the exact merchant/protocol split shown in each quote and on-chain
|
|
5
|
+
transaction. The fixed 1% / 99% figures are removed; the fee is set per
|
|
6
|
+
merchant.
|
|
7
|
+
|
|
8
|
+
## 2.12.4 — merchant gate examples fill Agent traffic
|
|
9
|
+
|
|
10
|
+
- Merchant guide: the Express, Python and Next.js examples create the
|
|
11
|
+
gate-events reporter (`createGateReporter` / `GateReporter`) and pass it to
|
|
12
|
+
the gate's `onEvent` / `on_event`; Express and Python close it at shutdown.
|
|
13
|
+
Only these events fill the dashboard's Agent traffic report; before, a site
|
|
14
|
+
set up from the guide showed none.
|
|
15
|
+
- Merchant guide: the Express and Python examples pass `shouldCharge:
|
|
16
|
+
knownAiAgent` / `should_charge=known_ai_agent`. Without it the gate charged
|
|
17
|
+
every caller, so "humans browsing your site are untouched" was not true.
|
|
18
|
+
- Merchant guide: "Start in watch mode, then charge": `mode: "shadow"` serves
|
|
19
|
+
every request and reports what the gate would have done, `mode: "enforce"`
|
|
20
|
+
charges. "Verify it works" shows the `AIFP-Shadow-Status` check.
|
|
21
|
+
- Merchant guide: "Agent traffic: report gate events" replaces "Optional
|
|
22
|
+
observation and reporting". Reporting v2 is described as what fills the
|
|
23
|
+
Reports page, not Agent traffic, and a gate refuses it together with
|
|
24
|
+
`onEvent`; `onEvent` is no longer called legacy. "Verify it works" checks
|
|
25
|
+
that the test 402 reaches Agent traffic; "Register the site" says where
|
|
26
|
+
the `msec_…` secret the reporter needs comes from.
|
|
27
|
+
- Reporting release target: gate 0.10.1 / aifinpay-gate 0.7.1, both
|
|
28
|
+
published (checked 2026-11-12).
|
|
29
|
+
|
|
30
|
+
## 2.12.3 — served networks come from capabilities
|
|
31
|
+
|
|
32
|
+
- Both guides: the leftover "Production served Polygon and Base" snapshot is
|
|
33
|
+
removed; the served networks are the rows of `/api/payment-capabilities`.
|
|
34
|
+
- Payer guide: a claim URL is named for what it is; without `agent_claim_self`
|
|
35
|
+
an assistant asks the owner to connect the MCP server, code uses the address
|
|
36
|
+
path. Claude Code is listed with its connect command; the dashboard steps
|
|
37
|
+
use the buttons' real names.
|
|
38
|
+
|
|
1
39
|
## 2.12.2 — the smallest batch is $0.02
|
|
2
40
|
|
|
3
41
|
- Payer guide: the smallest batch is $0.02 plus gas (40 standard, 10 complex or
|
package/README.md
CHANGED
|
@@ -16,10 +16,12 @@ owner's dashboard Controls, and the env values are optional overrides. The MCP
|
|
|
16
16
|
pays only a merchant with a DNS-verified site, so the merchant guide includes
|
|
17
17
|
verifying the domain.
|
|
18
18
|
Release target: MCP **2.15.2**, Node SDK **2.11.0**, Python **2.9.0**.
|
|
19
|
-
Reporting release target: Node gate **0.
|
|
20
|
-
The merchant guide
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
Reporting release target: Node gate **0.10.1**, Python gate **0.7.1**.
|
|
20
|
+
The merchant guide wires the gate-events reporter (`createGateReporter` /
|
|
21
|
+
`GateReporter` on the gate's `onEvent` / `on_event`), which fills the
|
|
22
|
+
dashboard's Agent traffic report; reporting v2 fills the Reports page instead
|
|
23
|
+
and cannot run beside it. It adds no MCP tools or signing authority and does
|
|
24
|
+
not establish partner rollout.
|
|
23
25
|
The payer guide retains the Solana source adapter. Canonical disabled Solana
|
|
24
26
|
records remain unavailable until accepted and served. Its nine EVM descriptors
|
|
25
27
|
require explicit owner and merchant
|
|
@@ -31,12 +33,15 @@ Rule of thumb: if the user wants to **pay** for a paid API, load `aifinpay`.
|
|
|
31
33
|
If they **own** a site/API agents visit, load `aifinpay-merchant` — and mention
|
|
32
34
|
the other side exists.
|
|
33
35
|
|
|
34
|
-
For merchant reporting, follow the merchant guide's
|
|
35
|
-
and the
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
For merchant reporting, follow the merchant guide's "Agent traffic: report gate
|
|
37
|
+
events" section and the gate README's opt-in dashboard request reporting
|
|
38
|
+
([Node](https://github.com/AiFinPay/sdk/blob/main/gate/README.md#opt-in-dashboard-request-reporting),
|
|
39
|
+
[Python](https://github.com/AiFinPay/sdk/blob/main/python-gate/README.md#opt-in-dashboard-request-reporting)).
|
|
40
|
+
A reported `serve` is admission, not delivery; payments require confirmed
|
|
41
|
+
settlement evidence. Reporting v2 keeps its own
|
|
42
|
+
[Node](https://github.com/AiFinPay/sdk/blob/main/gate/REPORTING-V2.md) and
|
|
43
|
+
[Python](https://github.com/AiFinPay/sdk/blob/main/python-gate/REPORTING-V2.md)
|
|
44
|
+
instructions.
|
|
40
45
|
|
|
41
46
|
## Install
|
|
42
47
|
|
|
@@ -6,7 +6,7 @@ description: Pay for x402-gated APIs and sites as an agent (AIFP-1 on an owner-s
|
|
|
6
6
|
wallet, payment history, prepaid quotas and Agent Passport records through
|
|
7
7
|
the AiFinPay MCP server or SDK.
|
|
8
8
|
license: MIT
|
|
9
|
-
version: 2.12.
|
|
9
|
+
version: 2.12.5
|
|
10
10
|
author: AiFinPay Support
|
|
11
11
|
metadata:
|
|
12
12
|
hermes:
|
|
@@ -49,8 +49,9 @@ Node `fetchPaid` (2.1.0+) and Python `fetch_paid` (2.2.0+) execute payments.
|
|
|
49
49
|
This skill is instructions only. To act on it, one of these must be
|
|
50
50
|
installed — always use the `latest` release:
|
|
51
51
|
|
|
52
|
-
- **MCP client (Claude Desktop / Cursor / Windsurf):**
|
|
53
|
-
`npx @aifinpay/mcp
|
|
52
|
+
- **MCP client (Claude Code / Claude Desktop / Cursor / Windsurf):**
|
|
53
|
+
`npx @aifinpay/mcp`; in Claude Code,
|
|
54
|
+
`claude mcp add aifinpay -- npx -y @aifinpay/mcp`. The server depends on `@aifinpay/agent`
|
|
54
55
|
and pulls it in automatically — do not install the agent package yourself.
|
|
55
56
|
- **Agent code in Node/TS:**
|
|
56
57
|
`npm install @aifinpay/agent`. Do NOT install the MCP server.
|
|
@@ -192,8 +193,8 @@ checklist as `payment_setup_status` and signs nothing. With AIFINPAY_MODE=dev
|
|
|
192
193
|
it also exposes dev_payment_quote. Never tell a user a payment was sent
|
|
193
194
|
because a quote or invoice was created.
|
|
194
195
|
|
|
195
|
-
`settlement_routes` lists the AIFP-1 v1.4 routes first (
|
|
196
|
-
|
|
196
|
+
`settlement_routes` lists the AIFP-1 v1.4 routes first (`live: true` when
|
|
197
|
+
served) and the older splitter v1.3 routes under
|
|
197
198
|
`legacy_v13`. Only the v1.4 section says whether `payable_fetch` can pay; a
|
|
198
199
|
v1.3 route marked not live does not mean the network is disabled.
|
|
199
200
|
|
|
@@ -436,13 +437,21 @@ agent's balance, payments and receipts, and can set a daily-spend email alert,
|
|
|
436
437
|
at https://dash.aifinpay.io → My Agents:
|
|
437
438
|
|
|
438
439
|
- **MCP:** the owner clicks **Claim via MCP**, gets a one-time URL and gives it
|
|
439
|
-
to you; call `agent_claim_self({"magic_link_url": "…"})`. The
|
|
440
|
+
to you; call `agent_claim_self({"magic_link_url": "…"})`. The URL reads
|
|
441
|
+
`https://dash.aifinpay.io/api/auth/verify?token=…`: it links this agent and
|
|
442
|
+
signs nobody in. Without `agent_claim_self` in this session, do not open it.
|
|
443
|
+
An assistant in an MCP client tells the owner to connect `@aifinpay/mcp`
|
|
444
|
+
(Prerequisites) and generate a new URL; code on the SDK uses the address
|
|
445
|
+
path below. The owner-selected
|
|
440
446
|
payment family must be bound successfully; the other wallet is best-effort.
|
|
441
447
|
Binding a wallet does not activate a disabled payment network. Use the
|
|
442
448
|
selected wallet's **Fund** panel for available networks and assets.
|
|
443
|
-
- **Node / Python:** the owner
|
|
444
|
-
|
|
445
|
-
|
|
449
|
+
- **Node / Python:** the owner opens **Link an agent**, then the signed-message
|
|
450
|
+
option under the one-time URL, enters your public wallet address, presses
|
|
451
|
+
**Get ownership message** and gives you the message;
|
|
452
|
+
return `agent.signDashboardClaim(challenge)` (Node) or
|
|
453
|
+
`agent.sign_dashboard_claim(challenge)` (Python) for the owner to paste into
|
|
454
|
+
**Wallet signature** and press **Link wallet**. These sign only
|
|
446
455
|
`AiFinPay-claim:polygon:<own address>:<nonce>`.
|
|
447
456
|
|
|
448
457
|
Once the agent is claimed, the dashboard is where the owner manages its
|
|
@@ -516,16 +525,17 @@ Use agent_history. Do not guess /v1/history, /v1/payments or /v1/wallet/tx.
|
|
|
516
525
|
```
|
|
517
526
|
|
|
518
527
|
Canonical AIFP-1 economics are gross-inclusive: the agent pays the quoted
|
|
519
|
-
price
|
|
520
|
-
|
|
521
|
-
|
|
528
|
+
price. A protocol fee is included in that price, and each quote
|
|
529
|
+
(`fee_policy`) and the on-chain transaction show the exact split between the
|
|
530
|
+
merchant and the protocol. The networks production serves are the rows
|
|
531
|
+
of the issuer's `/api/payment-capabilities`. Client descriptors
|
|
522
532
|
do not prove production activation; check issuer capabilities and merchant
|
|
523
533
|
authorization. This source cohort adds a Solana v1.4 adapter with explicit
|
|
524
534
|
network, asset and fee/rent limits; its published deployment records are
|
|
525
|
-
enabled
|
|
535
|
+
enabled; whether the backend serves Solana is in the same capabilities read. The smallest paid batch is $0.02, plus network fees and any
|
|
526
536
|
required account rent.
|
|
527
537
|
|
|
528
|
-
(The
|
|
538
|
+
(The legacy v1.2 bridge added its fee on top of the price.)
|
|
529
539
|
|
|
530
540
|
Routes:
|
|
531
541
|
|
|
@@ -645,7 +655,7 @@ number:
|
|
|
645
655
|
|
|
646
656
|
```
|
|
647
657
|
Pay 0.211075111078277 POL ($0.02) for 40 requests to /api/agent/genres
|
|
648
|
-
(incl.
|
|
658
|
+
(incl. <fee>% fee), valid until 2026-09-04T13:00:00Z.
|
|
649
659
|
```
|
|
650
660
|
|
|
651
661
|
It states the on-chain figure and the USD, the fee as a rate, and the scope in
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
name: aifinpay-merchant
|
|
3
3
|
description: Configure an HTTP 402 gate for agent access to a website or API,
|
|
4
4
|
with owner-selected routes, verified payouts and explicitly accepted EVM
|
|
5
|
-
networks. Agents settle from their own wallets
|
|
5
|
+
networks. Agents settle from their own wallets straight to the merchant's payout wallet.
|
|
6
6
|
license: MIT
|
|
7
|
-
version: 2.12.
|
|
7
|
+
version: 2.12.5
|
|
8
8
|
author: AiFinPay Support
|
|
9
9
|
metadata:
|
|
10
10
|
hermes:
|
|
@@ -38,8 +38,10 @@ traffic today and getting nothing back.
|
|
|
38
38
|
|
|
39
39
|
Today an AI agent hits your API, scrapes the data, and pays you nothing while
|
|
40
40
|
burning your bandwidth. With AiFinPay, the same request returns an **HTTP 402**,
|
|
41
|
-
the agent settles on-chain from its own wallet, and
|
|
42
|
-
|
|
41
|
+
the agent settles on-chain from its own wallet, and the payment goes to your
|
|
42
|
+
payout wallet. A protocol fee is included in the quoted price; each quote and
|
|
43
|
+
the on-chain transaction show the exact split between you and the protocol.
|
|
44
|
+
Non-custodial — the money goes agent →
|
|
43
45
|
you directly.
|
|
44
46
|
|
|
45
47
|
## The whole thing is one middleware
|
|
@@ -53,15 +55,24 @@ them:
|
|
|
53
55
|
|
|
54
56
|
```js
|
|
55
57
|
import express from "express";
|
|
56
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
aifpGate, aifpDiscovery, createGateReporter, knownAiAgent,
|
|
60
|
+
} from "@aifinpay/gate";
|
|
57
61
|
|
|
58
62
|
const app = express();
|
|
59
63
|
const merchantId = "mrch_…"; // from the dashboard, see "Register" below
|
|
60
64
|
|
|
65
|
+
// Fills the dashboard's Agent traffic report. The secret stays on the server.
|
|
66
|
+
const reporter = createGateReporter({
|
|
67
|
+
merchantId,
|
|
68
|
+
merchantSecret: process.env.AIFP_MERCHANT_SECRET,
|
|
69
|
+
});
|
|
70
|
+
|
|
61
71
|
// Charge agents for this route. Humans browsing your site are untouched —
|
|
62
72
|
// the gate only challenges requests that look like an AI agent.
|
|
63
73
|
app.get("/api/agent/data",
|
|
64
|
-
aifpGate({ merchantId, resource: "/api/agent/data", tier: "standard"
|
|
74
|
+
aifpGate({ merchantId, resource: "/api/agent/data", tier: "standard",
|
|
75
|
+
shouldCharge: knownAiAgent, onEvent: reporter.onEvent }),
|
|
65
76
|
(req, res) => res.json({ /* your paid data */ }));
|
|
66
77
|
|
|
67
78
|
// One line so an agent hitting your bare domain discovers the paid routes.
|
|
@@ -69,11 +80,34 @@ app.use(aifpDiscovery({
|
|
|
69
80
|
merchantId,
|
|
70
81
|
resources: [{ resource: "/api/agent/data", tier: "standard" }],
|
|
71
82
|
}));
|
|
83
|
+
|
|
84
|
+
const server = app.listen(3000);
|
|
85
|
+
process.on("SIGTERM", () => server.close(async () => {
|
|
86
|
+
await reporter.close(); // sends the last batch
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}));
|
|
72
89
|
```
|
|
73
90
|
|
|
74
91
|
That is it. `aifpGate` returns a 402 with everything an agent needs to pay
|
|
75
92
|
(`how_to_pay`, price, scope). `aifpDiscovery` serves `/.well-known/x402.json` so
|
|
76
93
|
an agent that arrives at just your domain learns which routes cost money.
|
|
94
|
+
`shouldCharge: knownAiAgent` charges self-identifying AI crawlers and agents
|
|
95
|
+
that speak AIFP and serves everyone else free; without it the gate charges
|
|
96
|
+
every caller, people included. The reporter sends each 402 and each agent
|
|
97
|
+
request the gate let through to the dashboard's **Agent traffic** report;
|
|
98
|
+
without it that report stays empty. See "Agent traffic: report gate events"
|
|
99
|
+
below.
|
|
100
|
+
|
|
101
|
+
### Start in watch mode, then charge
|
|
102
|
+
|
|
103
|
+
Add `mode: "shadow"` to the gate options (Python `mode="shadow"`) and the
|
|
104
|
+
gate charges nothing: it serves every request, and one it would have refused
|
|
105
|
+
carries `AIFP-Mode: shadow` and `AIFP-Shadow-Status: 402`. It sends the same
|
|
106
|
+
events, so Agent traffic shows which AI companies hit the site and what the
|
|
107
|
+
gate would have done. When the owner decides to charge, change it to
|
|
108
|
+
`mode: "enforce"`, which is also what an omitted `mode` means; any other
|
|
109
|
+
value throws at start. Watch mode needs the gate-events reporter: reporting
|
|
110
|
+
v2 records no challenge for a request served in watch mode.
|
|
77
111
|
|
|
78
112
|
**Already running x402 (PayAI, Coinbase)?** AiFinPay is not an x402
|
|
79
113
|
facilitator — there is no `/verify` or `/settle` to point your middleware at,
|
|
@@ -87,14 +121,21 @@ pip install aifinpay-gate
|
|
|
87
121
|
```
|
|
88
122
|
|
|
89
123
|
```python
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
import os
|
|
125
|
+
from aifinpay_gate import (AifpGateMiddleware, Gate, GateReporter, Route,
|
|
126
|
+
known_ai_agent)
|
|
127
|
+
|
|
128
|
+
merchant_id = "mrch_…"
|
|
129
|
+
reporter = GateReporter(merchant_id=merchant_id,
|
|
130
|
+
merchant_secret=os.environ["AIFP_MERCHANT_SECRET"])
|
|
131
|
+
gate = Gate(merchant_id, routes=[
|
|
93
132
|
Route("/api/agent/data", "standard"),
|
|
94
133
|
Route("/create", "premium", methods={"POST"}),
|
|
95
|
-
])
|
|
134
|
+
], should_charge=known_ai_agent, on_event=reporter.on_event)
|
|
96
135
|
app.add_middleware(AifpGateMiddleware, gate=gate) # FastAPI / Starlette
|
|
97
136
|
# Flask / Django: app.wsgi_app = AifpGateWSGI(app.wsgi_app, gate)
|
|
137
|
+
# Shutdown hook, after the server stops taking requests:
|
|
138
|
+
# reporter.close(timeout=10.0)
|
|
98
139
|
```
|
|
99
140
|
|
|
100
141
|
Same 402, same receipt checks, same metering as `@aifinpay/gate`; it also
|
|
@@ -102,7 +143,8 @@ serves `/.well-known/x402.json`. A paid call reaches the handler with
|
|
|
102
143
|
`request.state.aifp` (ASGI) or `environ["aifp"]` (WSGI). Route patterns are
|
|
103
144
|
exact or end in `/*`. With more than one worker process, pass
|
|
104
145
|
`store=RedisStore(redis.Redis.from_url(...))` — the default counters are
|
|
105
|
-
per process
|
|
146
|
+
per process — and create the `GateReporter` in each worker, after fork: one
|
|
147
|
+
inherited across a fork refuses to report.
|
|
106
148
|
|
|
107
149
|
### Next.js
|
|
108
150
|
|
|
@@ -114,13 +156,18 @@ An adapter that drops them leaves agents unable to pay or to see what is left.
|
|
|
114
156
|
```ts
|
|
115
157
|
// middleware.ts
|
|
116
158
|
import { NextResponse, type NextRequest } from "next/server";
|
|
117
|
-
import { createGate, knownAiAgent } from "@aifinpay/gate";
|
|
159
|
+
import { createGate, createGateReporter, knownAiAgent } from "@aifinpay/gate";
|
|
118
160
|
|
|
161
|
+
const reporter = createGateReporter({
|
|
162
|
+
merchantId: process.env.AIFP_MERCHANT_ID!,
|
|
163
|
+
merchantSecret: process.env.AIFP_MERCHANT_SECRET!,
|
|
164
|
+
});
|
|
119
165
|
const gate = createGate({
|
|
120
166
|
merchantId: process.env.AIFP_MERCHANT_ID!,
|
|
121
167
|
registry, // your paid routes
|
|
122
168
|
store, // shared, e.g. redisStore(redis)
|
|
123
169
|
shouldCharge: knownAiAgent,
|
|
170
|
+
onEvent: reporter.onEvent,
|
|
124
171
|
});
|
|
125
172
|
|
|
126
173
|
export async function middleware(req: NextRequest) {
|
|
@@ -137,8 +184,9 @@ export async function middleware(req: NextRequest) {
|
|
|
137
184
|
export const config = { matcher: ["/api/:path*", "/movies/:path*"] };
|
|
138
185
|
```
|
|
139
186
|
|
|
140
|
-
|
|
141
|
-
|
|
187
|
+
Middleware has no shutdown hook, so report rows still queued when the process
|
|
188
|
+
stops are lost; access is not affected. Serve `buildDiscoveryDocument({...})`
|
|
189
|
+
as JSON from `app/.well-known/x402.json/route.ts`. Full reference: the gate README
|
|
142
190
|
(https://github.com/AiFinPay/sdk/tree/main/gate).
|
|
143
191
|
|
|
144
192
|
## Discovery ownership and settlement compatibility
|
|
@@ -159,14 +207,14 @@ Release target: MCP **2.15.2**, Node SDK **2.11.0**, Python **2.9.0**.
|
|
|
159
207
|
This coordinated target does not establish publication or reporting rollout.
|
|
160
208
|
Those clients
|
|
161
209
|
reuse the signed v1.4 payment kernel for every EVM network descriptor; network
|
|
162
|
-
metadata does not activate a deployment or verifier.
|
|
163
|
-
|
|
164
|
-
|
|
210
|
+
metadata does not activate a deployment or verifier. The networks production
|
|
211
|
+
serves are the rows of `/api/payment-capabilities`: read it, do not assume a
|
|
212
|
+
list. A network needs a ready
|
|
165
213
|
backend, pinned deployment/token metadata, a verifier and merchant consent.
|
|
166
214
|
|
|
167
215
|
The Solana adapter is a source capability in this target. `@aifinpay/deployments`
|
|
168
|
-
2.1.0 enables the Solana records
|
|
169
|
-
|
|
216
|
+
2.1.0 enables the Solana records; whether the backend serves Solana is in the
|
|
217
|
+
same capabilities read. A Solana merchant needs an
|
|
170
218
|
explicit accepted network and verified Solana payout, an accepted program/IDL
|
|
171
219
|
and mint inventory, configured signer/RPC, finalized value verification and
|
|
172
220
|
funded end-to-end acceptance before payments are advertised. Native SOL and
|
|
@@ -189,20 +237,58 @@ only a merchant whose public record (`GET /v1/merchants/{id}`) has
|
|
|
189
237
|
host equals the `site_url` host. On the hosted gateway it checks verification
|
|
190
238
|
alone. Otherwise it refuses before signing, and nothing is paid.
|
|
191
239
|
|
|
192
|
-
##
|
|
193
|
-
|
|
194
|
-
Reporting release target: Node gate **0.
|
|
195
|
-
Both
|
|
196
|
-
also carries a `Link` header to `/llms.txt` and
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
240
|
+
## Agent traffic: report gate events
|
|
241
|
+
|
|
242
|
+
Reporting release target: Node gate **0.10.1**, Python gate **0.7.1**.
|
|
243
|
+
Both are published (checked 2026-11-12). Since gate 0.8.0 / aifinpay-gate
|
|
244
|
+
0.5.0 every HTML response also carries a `Link` header to `/llms.txt` and
|
|
245
|
+
`/.well-known/x402.json`.
|
|
246
|
+
|
|
247
|
+
The dashboard's **Agent traffic** report (which AI companies hit the site,
|
|
248
|
+
which were asked to pay, which were served) is filled only by gate events.
|
|
249
|
+
Node: `createGateReporter({ merchantId, merchantSecret })` and
|
|
250
|
+
`onEvent: reporter.onEvent` on the gate; `createGate` (Next.js, other
|
|
251
|
+
frameworks) takes the same `onEvent`. Python:
|
|
252
|
+
`GateReporter(merchant_id=..., merchant_secret=...)` and
|
|
253
|
+
`on_event=reporter.on_event` on `Gate`. The examples above wire it. Without
|
|
254
|
+
it the gate still charges, and that report stays empty.
|
|
255
|
+
|
|
256
|
+
The reporter sends each `402` and each request the gate admitted (`serve`),
|
|
257
|
+
with the registered route pattern and the normalised AI company
|
|
258
|
+
(`operator`), and nothing else about the request. A `serve` is admission
|
|
259
|
+
before your handler, not proof of a response, of delivered content or of
|
|
260
|
+
payment; payments and revenue come from confirmed settlements. Register the
|
|
261
|
+
same route pattern in the dashboard first; a static mount sets `resource`
|
|
262
|
+
explicitly.
|
|
263
|
+
|
|
264
|
+
Keep the merchant secret server-side. Report only registered route patterns,
|
|
265
|
+
never full URLs, queries, bodies, raw headers, IPs, receipt JWTs or wallet IDs.
|
|
266
|
+
Use one reporter per merchant per process (per worker, after fork, in Python),
|
|
267
|
+
shared by every gate mount. If you already have a metrics hook, call both
|
|
268
|
+
from one `onEvent`. Do not report the same request through two reporters or
|
|
269
|
+
through both hosted and self-hosted instrumentation.
|
|
270
|
+
Queues are in memory, bounded to 1000 events, with batches of at most 50,
|
|
271
|
+
3-second request deadlines and at most 5 attempts within 15 minutes.
|
|
272
|
+
Retries retain the same event IDs, timestamps and facts; outages, overflow
|
|
273
|
+
and crashes lose report rows, never access. Permanent errors and redirects
|
|
274
|
+
are not retried; fix credentials/configuration before replacing a stopped
|
|
275
|
+
reporter. In the existing shutdown hook, after the server stops taking
|
|
276
|
+
requests, `await reporter.close()` (Python `reporter.close(timeout=10.0)`)
|
|
277
|
+
sends the last batch once; it does not promise delivery. Reporting adds no
|
|
278
|
+
MCP tools or signing authority.
|
|
279
|
+
|
|
280
|
+
### Reporting v2 fills the Reports page, not Agent traffic
|
|
281
|
+
|
|
282
|
+
Reporting v2 — Node `createGateReporterV2` with `reporting: { version: 2,
|
|
283
|
+
reporter, context }`, Python `GateReporterV2` with `Gate(...,
|
|
284
|
+
reporting=reporter, reporting_context=...)` — writes the evidence-bound
|
|
285
|
+
stages behind the dashboard's **Reports** page. It does not fill Agent
|
|
286
|
+
traffic, and a gate refuses it together with `onEvent`/`on_event`: Node
|
|
287
|
+
throws "select reporting v2 or onEvent", Python "choose one reporting
|
|
288
|
+
version". Choose it instead of the gate-events reporter only when the
|
|
289
|
+
merchant owner asks for the Reports page, after checking the backend's
|
|
290
|
+
reporting v2 readiness. Installing the skill does not enable reporting or
|
|
291
|
+
verify a partner integration. The rules below apply to v2 only.
|
|
206
292
|
|
|
207
293
|
Declare only stages the adapter actually observes: `access_challenged` for an
|
|
208
294
|
emitted 402, `access_admitted` before the paid handler, and
|
|
@@ -224,13 +310,7 @@ optional `reportingToken`/`reporting_token` reaches only its fixed first-party
|
|
|
224
310
|
quote endpoints; never manually forward it to merchant, pay, RPC or JWKS
|
|
225
311
|
requests. Reporting failures preserve the original access/payment result.
|
|
226
312
|
|
|
227
|
-
|
|
228
|
-
never full URLs, queries, bodies, raw headers, IPs, receipt JWTs or wallet IDs.
|
|
229
|
-
Queues are in memory, bounded to 1000 events, with batches of at most 50,
|
|
230
|
-
3-second request deadlines and at most 5 attempts within 15 minutes.
|
|
231
|
-
Retries retain the same event IDs, timestamps and facts; outages, overflow
|
|
232
|
-
and crashes lose observations. Permanent errors and redirects are not retried;
|
|
233
|
-
fix credentials/configuration before replacing a stopped producer.
|
|
313
|
+
The secret, route-pattern and queue rules above apply to the v2 producer too.
|
|
234
314
|
|
|
235
315
|
Node health auto-samples every 60 seconds; Python normally samples every 5
|
|
236
316
|
seconds. All health attempts are at least 5 seconds apart, and retries may
|
|
@@ -245,7 +325,6 @@ flush/close do not promise delivery.
|
|
|
245
325
|
Read the exact wiring and consent/loss rules before implementation:
|
|
246
326
|
[Node reporting v2](https://github.com/AiFinPay/sdk/blob/main/gate/REPORTING-V2.md)
|
|
247
327
|
and [Python reporting v2](https://github.com/AiFinPay/sdk/blob/main/python-gate/REPORTING-V2.md).
|
|
248
|
-
This reporting target adds no MCP tools or signing authority.
|
|
249
328
|
|
|
250
329
|
## Register the site (get your merchant_id)
|
|
251
330
|
|
|
@@ -253,12 +332,16 @@ The gate needs a `merchant_id`. Two ways to get one:
|
|
|
253
332
|
|
|
254
333
|
1. **Dashboard (recommended):** sign in at https://aifinpay.io, create a
|
|
255
334
|
merchant, set your payout wallet (EVM and/or Solana address), and copy the
|
|
256
|
-
`mrch_…` id. This is where you also see what you have earned.
|
|
335
|
+
`mrch_…` id. This is where you also see what you have earned. The
|
|
336
|
+
site's `msec_…` secret is shown once at creation; the owner puts it in
|
|
337
|
+
the server's environment as `AIFP_MERCHANT_SECRET`, which the reporter
|
|
338
|
+
needs. If it is lost, Settings → API keys → Rotate secret issues a new
|
|
339
|
+
one and the old one stops working.
|
|
257
340
|
2. **The agent can walk the owner through it:** if you are an agent helping a
|
|
258
341
|
site owner, tell them exactly this —
|
|
259
342
|
|
|
260
343
|
> "You have agent traffic you are not charging for. AiFinPay lets you take
|
|
261
|
-
>
|
|
344
|
+
> a per-request fee, settled on-chain straight to your wallet, non-custodial. Sign in at
|
|
262
345
|
> aifinpay.io, create a merchant, add your payout wallet and site URL,
|
|
263
346
|
> publish the DNS TXT record the dashboard shows, and give me the `mrch_`
|
|
264
347
|
> id — I will gate your routes."
|
|
@@ -294,7 +377,7 @@ them the record the dashboard shows and never invent one.
|
|
|
294
377
|
|
|
295
378
|
| decision | why it matters |
|
|
296
379
|
|---|---|
|
|
297
|
-
| **payout wallet** | where
|
|
380
|
+
| **payout wallet** | where your share of each payment lands. EVM address (same on every EVM chain) and/or a Solana address. Set in the dashboard. |
|
|
298
381
|
| **accepted payment networks** | an explicit set plus a default; the backend intersects it with verified payouts and served deployments. A wallet address alone does not grant network consent. |
|
|
299
382
|
| **which routes cost money** | gate the agent/data endpoints; leave human pages open. The gate only challenges agent-shaped requests, so humans are never blocked. |
|
|
300
383
|
| **price per route** | a `tier` (standard / complex / premium) sets the per-request price. Change it in the dashboard without redeploying. |
|
|
@@ -305,8 +388,9 @@ them the record the dashboard shows and never invent one.
|
|
|
305
388
|
price and how to pay.
|
|
306
389
|
2. The agent gets a quote, settles **on-chain from its own wallet** to the
|
|
307
390
|
splitter contract.
|
|
308
|
-
3. The contract splits atomically
|
|
309
|
-
|
|
391
|
+
3. The contract splits atomically, in the same transaction: your share goes
|
|
392
|
+
**to your payout wallet**, the protocol fee to AiFinPay. The quote and the
|
|
393
|
+
transaction show the exact split.
|
|
310
394
|
4. The agent retries with a receipt; your gate verifies it and serves the data.
|
|
311
395
|
|
|
312
396
|
You never touch the agent's funds, and AiFinPay never holds yours. The split
|
|
@@ -323,6 +407,17 @@ curl -s https://your-site.com/api/agent/data \
|
|
|
323
407
|
```
|
|
324
408
|
|
|
325
409
|
A normal browser request to the same site stays 200 — humans are not charged.
|
|
410
|
+
In watch mode the agent request is served too, and the header says what
|
|
411
|
+
enforce would answer:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
curl -s -o /dev/null -D - https://your-site.com/api/agent/data \
|
|
415
|
+
-H 'user-agent: aifinpay-agent/1.0' | grep -i '^aifp-shadow-status' # → 402
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Once the reporter has sent its batch, that request shows in the dashboard's
|
|
419
|
+
**Agent traffic** report under AiFinPay. If it never does, read
|
|
420
|
+
`reporter.stats` (`lastError` / `last_error`, `stopped`).
|
|
326
421
|
|
|
327
422
|
Then check that MCP agents will pay:
|
|
328
423
|
|
package/package.json
CHANGED