Repository navigation
Commit 90a2d4f
authored
refactor(x402)!: drop flat back-compat fields from _meta.x402 (#1458)
## Why
Closes #892.
`_meta.x402` on paid tools currently carries the same payment data
twice: the spec-shaped `accepts[]` array and a flat copy of the
server-preferred entry (`scheme`, `network`, `amount`, ...). The flat
copy was a shim for clients from before #876 that don't iterate
`accepts[]`. Two shapes invite drift, and the flat one can't express
more than one scheme.
Consumer check before removing it:
- `apify/mcpc` (v0.7.0, main a8c34fc): `selectAcceptFromToolMeta` walks
`accepts[]` first and uses the flat fields only when `accepts[]` is
absent; if that fails too it defers to the 402 response. PR
apify/mcpc#238 merged 2026-05-26.
- `apify/agentic-payments-e2e-tester` x402 canary: reads `accepts[]`
first, flat shape is a legacy fallback.
- Third-party clients: none on file, not verifiable from here.
## What changed
Before: `_meta.x402 = { paymentRequired, ...preferredEntry, accepts }`.
Now: `_meta.x402 = { paymentRequired, accepts }`.
`selectPreferredAcceptEntry` and `X402_PREFERRED_SCHEMES` are deleted
with it. `accepts[]`, the `structuredContent` in 402 results and `upto`
support are untouched.
## Notes for reviewers (human-written)
## Proof it works
Unit: `tests/unit/tools.x402.test.ts` asserts `_meta.x402` equals
exactly `{ paymentRequired: true, accepts: [...] }`. The
`tests/test_kit` payments case no longer expects the flat fields.
Type-check and lint clean. No end-to-end mcpc transcript yet.1 parent 71f9d1a commit 90a2d4f
3 files changed
Lines changed: 7 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 29 | | |
40 | 30 | | |
41 | 31 | | |
| |||
223 | 213 | | |
224 | 214 | | |
225 | 215 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 216 | | |
240 | 217 | | |
241 | 218 | | |
242 | 219 | | |
243 | 220 | | |
244 | | - | |
245 | 221 | | |
246 | 222 | | |
247 | 223 | | |
| |||
250 | 226 | | |
251 | 227 | | |
252 | 228 | | |
253 | | - | |
254 | 229 | | |
255 | 230 | | |
256 | | - | |
257 | 231 | | |
258 | 232 | | |
259 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 88 | | |
94 | 89 | | |
95 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
| 158 | + | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 163 | + | |
168 | 164 | | |
169 | 165 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 166 | + | |
190 | 167 | | |
191 | | - | |
| 168 | + | |
192 | 169 | | |
193 | 170 | | |
194 | 171 | | |
195 | 172 | | |
196 | 173 | | |
197 | | - | |
198 | 174 | | |
199 | 175 | | |
200 | | - | |
| 176 | + | |
201 | 177 | | |
202 | 178 | | |
203 | 179 | | |
204 | 180 | | |
205 | 181 | | |
206 | 182 | | |
207 | | - | |
| 183 | + | |
208 | 184 | | |
209 | 185 | | |
210 | 186 | | |
| |||
0 commit comments