@rozoai/checkout 0.1.19 → 0.1.20

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/llms.txt CHANGED
@@ -158,9 +158,12 @@ balance once with the coin you hold, then pay many small x402 calls from it.
158
158
  npx @rozoai/checkout x402 balance
159
159
 
160
160
  Payment leg (what the seller receives): USDC on Base (eip155:8453) only,
161
- scheme "exact". Solana payment leg is coming later. Topup leg: every --with coin above, plus native
162
- ETH (Ethereum, Base, Arbitrum), BNB and SOL in beta. Native coins never pay a
163
- seller directly.
161
+ scheme "exact". Solana payment leg is coming later. Topup leg: USDT on Solana,
162
+ BNB Chain, Ethereum, Polygon, Arbitrum; USDC on Solana, BNB Chain, Ethereum,
163
+ Polygon, Arbitrum, Base, Stellar. x402 balance top ups accept USDC and USDT only; any other coin
164
+ is answered with 400 X402_TOPUP_SOURCE_UNSUPPORTED. USDT only funds the balance;
165
+ sellers are paid in USDC. Holding a native coin or sats? Use them to top up
166
+ OpenRouter with ROZO Checkout (https://checkout.rozo.ai).
164
167
 
165
168
  Raw HTTP (Authorization: Bearer <agent key ak_...>):
166
169
  POST https://apiserver.mpprouter.dev/v1/x402/topup {"amount":"20","token":"USDT","chain":"900"}
@@ -177,10 +180,105 @@ x402 safety rules:
177
180
  - Refuse a payment above what the user approved; refuse a payTo on a
178
181
  compromised-wallet list.
179
182
  - 503 X402_RETRY, X402_PAYER_MODE_CHANGED or X402_LEDGER_UNAVAILABLE: retry
180
- with the same idempotencyKey. Any other 503 from /v1/x402 = "x402 payer not
181
- enabled" for this key. Nothing was charged; stop.
183
+ with the same idempotencyKey. Any other 503 from /v1/x402 means x402 is not
184
+ available for this key right now. Nothing new was charged; stop. Every server
185
+ code is listed below.
182
186
  - The agent key owns the balance. Store it 0600, never print or log it.
183
187
 
188
+ x402 server error codes (returned by https://apiserver.mpprouter.dev/v1/x402/*):
189
+ Every error body looks like
190
+ {"ok":false,"code":"X402_...","error":{"code":"X402_...","message":"..."}},
191
+ sometimes with extra top level fields (limitUsd, balanceUsd, ...).
192
+ These are separate from the codes the CLI raises on its own (X402_UNSUPPORTED,
193
+ X402_OVER_BUDGET, X402_BAD_CHALLENGE, X402_PAYMENT_REJECTED and others). The balance is
194
+ debited only by the ledger commit inside /sign, after signing; every error
195
+ raised before that commit charges nothing. If /sign answers
196
+ X402_LEDGER_UNAVAILABLE or X402_INTERNAL the commit may have landed: retry
197
+ with the same idempotencyKey, and a payment that did land comes back as the
198
+ stored signature (replay:true), never as a second charge.
199
+ The CLI reports every 503 except X402_RETRY, X402_PAYER_MODE_CHANGED and
200
+ X402_LEDGER_UNAVAILABLE as X402_PAYER_DISABLED, with the server code in
201
+ error.details.serverCode. On /sign it retries 429, 500, 502, 504 and those
202
+ three 503 codes itself, with the same idempotencyKey.
203
+
204
+ balance, topup and sign (keys does not read a key):
205
+ - 401 X402_KEY_INVALID: agent key missing, malformed or unknown. Send
206
+ "Authorization: Bearer ak_...". Do not mint a new key to get around it: the
207
+ balance belongs to the old key.
208
+ - 403 X402_KEY_SUSPENDED: the key is not active. Stop; email hi@rozo.ai.
209
+
210
+ Any route:
211
+ - 503 X402_PAYER_DISABLED: the payer is switched off. Stop, tell the user.
212
+ - 503 X402_PAYER_NOT_CONFIGURED: payer not set up on this deployment. Stop.
213
+ - 503 X402_LEDGER_UNAVAILABLE: ledger unreachable. Retry shortly with the same
214
+ idempotencyKey.
215
+ - 500 X402_INTERNAL: unexpected error. Retry with the same idempotencyKey a few
216
+ times, then stop and report it.
217
+ - 405 METHOD_NOT_ALLOWED: wrong HTTP method (keys/topup/sign are POST, balance is GET).
218
+
219
+ POST /v1/x402/keys:
220
+ - 429 X402_KEY_RATE_LIMITED: too many keys created from this IP this hour.
221
+ Reuse the key you have, or retry later.
222
+ - 503 X402_RETRY: key collision. Retry.
223
+
224
+ POST /v1/x402/topup (no deposit address is shown on any error, so nothing can
225
+ be sent to it; only pay an address from a 200 response):
226
+ - 400 X402_INVALID_REQUEST: body is not JSON, or amount is not a USD amount
227
+ with at most 2 decimals.
228
+ - 400 X402_TOPUP_AMOUNT_OUT_OF_RANGE: top up must be between $5 and $500.
229
+ - 400 X402_TOPUP_SOURCE_REQUIRED: say which coin you pay with: chain and
230
+ token. The response lists accepted chains.
231
+ - 400 X402_UNSUPPORTED_CHAIN: unknown chain. Use a CAIP-2 id or a name such as
232
+ solana, base, ethereum, bsc, polygon, arbitrum, stellar.
233
+ - 400 X402_TOPUP_SOURCE_UNSUPPORTED: that coin is not accepted for top ups.
234
+ Use USDC or USDT. May carry a "supported" list.
235
+ - 502 INTENTS_API_FAILED: the top up order could not be created. Retry later.
236
+ - 503 X402_TOPUP_MISCONFIGURED or X402_TOPUP_NOT_REGISTERED: the order was not
237
+ usable, the address was withheld. Retry later; email hi@rozo.ai if it repeats.
238
+ - 503 X402_PAYER_SHADOW, X402_TOPUP_NOT_CONFIGURED or X402_SIGNER_NOT_CONFIGURED:
239
+ top ups are closed right now. Stop.
240
+
241
+ POST /v1/x402/sign:
242
+ - 400 X402_INVALID_REQUEST: body is not JSON, or budget is not a positive USD amount.
243
+ - 400 X402_IDEMPOTENCY_KEY_REQUIRED: send idempotencyKey, 8 to 128 chars of
244
+ [A-Za-z0-9_.:-], one per 402 challenge.
245
+ - 400 X402_UNSUPPORTED_VERSION: only x402Version 2 is accepted.
246
+ - 400 X402_UNSUPPORTED_NETWORK, X402_UNSUPPORTED_SCHEME, X402_UNSUPPORTED_ASSET,
247
+ X402_INVALID_REQUIREMENT or X402_SIGN_UNSUPPORTED: the accepts entry is
248
+ malformed or asks for something not covered (only exact USDC is signed).
249
+ Do not retry the same entry; tell the user.
250
+ - 402 X402_BUDGET_EXCEEDED: the challenge asks more than your budget. Stop and
251
+ ask the user.
252
+ - 402 X402_PER_TX_LIMIT_EXCEEDED: above this key's single-payment limit
253
+ (limitUsd). Stop and ask the user.
254
+ - 402 X402_INSUFFICIENT_BALANCE: balance too low (balanceUsd). Top up, wait
255
+ for the credit, then pay again.
256
+ - 403 X402_PAYTO_NOT_ALLOWED: payTo is not on this key's allowlist. Stop.
257
+ - 403 X402_PAYTO_BLOCKED: this payTo is blocked. Stop, do not retry.
258
+ - 409 X402_IDEMPOTENCY_CONFLICT: this idempotencyKey was already used for a
259
+ different requirement. Nothing new was charged. Use a new key only for a new
260
+ 402 challenge.
261
+ - 410 X402_CREDENTIAL_REFUNDED: the stored signature expired unused and its
262
+ amount went back to the balance. Fetch a new 402 and sign it with a new key.
263
+ - 429 X402_DAILY_LIMIT_EXCEEDED: this key's daily limit would be exceeded
264
+ (limitUsd, spentTodayUsd). Wait for the daily
265
+ window to reset, or ask hi@rozo.ai for a higher limit.
266
+ - 429 X402_GLOBAL_DAILY_CAP_REACHED or X402_SIGNER_DAILY_CAP_REACHED: a
267
+ platform-wide daily cap was reached. Retry after 00:00 UTC.
268
+ - 429 X402_SIGNER_CAP_REACHED: the signing service refused this amount. Try a
269
+ smaller payment or later.
270
+ - 503 X402_RETRY or X402_PAYER_MODE_CHANGED: transient. Retry with the same
271
+ idempotencyKey.
272
+ - 503 X402_PAYER_SHADOW: the payer is not live for this key. A fresh request
273
+ was checked and recorded but not signed, and nothing was charged. With
274
+ "replay":true it refers to an earlier payment under this idempotencyKey,
275
+ which may have been charged: check /balance, never pay again with a new key.
276
+ Stop.
277
+ - 503 X402_SIGNER_NOT_CONFIGURED or X402_SIGNER_DISABLED: signing for this
278
+ network is off right now. Stop.
279
+ A 200 with "replay":true is the stored signature for an idempotencyKey that
280
+ was already paid; it is not a second charge.
281
+
184
282
  ## Safety rules (encode these, they prevent fund loss)
185
283
 
186
284
  - Before paying, require: status == "payment_unpaid" AND source.txHash == null AND
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozoai/checkout",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "type": "module",
5
5
  "description": "Pay OpenRouter, or any Coinbase invoice, with the crypto you already hold: USDT/USDC on Solana, BNB Chain, Ethereum or Polygon, USDC on Base or Stellar, or BTC over Lightning. No Coinbase account.",
6
6
  "license": "MIT",
@@ -58225,8 +58225,9 @@ USAGE
58225
58225
 
58226
58226
  TOPUP COINS (--with)
58227
58227
  usdt-solana usdc-solana usdt-bnb usdc-bnb usdt-ethereum usdc-ethereum
58228
- usdt-polygon usdc-polygon usdc-base usdc-stellar btc-lightning
58229
- native (beta): eth-ethereum eth-base eth-arbitrum bnb-bnb sol-solana
58228
+ usdt-polygon usdc-polygon usdt-arbitrum usdc-arbitrum usdc-base usdc-stellar
58229
+ x402 top ups accept USDC and USDT only. Holding a native coin or sats?
58230
+ Use them to top up OpenRouter with ROZO Checkout (rozo-checkout pay).
58230
58231
 
58231
58232
  PAY OPTIONS
58232
58233
  --method <m> HTTP method (default GET)
@@ -58563,18 +58564,26 @@ var TOPUP_PRESETS = {
58563
58564
  "usdc-ethereum": { chain: "1", token: "USDC" },
58564
58565
  "usdt-polygon": { chain: "137", token: "USDT" },
58565
58566
  "usdc-polygon": { chain: "137", token: "USDC" },
58567
+ "usdt-arbitrum": { chain: "42161", token: "USDT" },
58568
+ "usdc-arbitrum": { chain: "42161", token: "USDC" },
58566
58569
  "usdc-base": { chain: "8453", token: "USDC" },
58567
- "usdc-stellar": { chain: "1500", token: "USDC" },
58568
- "btc-lightning": { chain: "lightning", token: "BTC" },
58569
- "eth-ethereum": { chain: "1", token: "ETH", native: true },
58570
- "eth-base": { chain: "8453", token: "ETH", native: true },
58571
- "eth-arbitrum": { chain: "42161", token: "ETH", native: true },
58572
- "bnb-bnb": { chain: "56", token: "BNB", native: true },
58573
- "sol-solana": { chain: "900", token: "SOL", native: true }
58570
+ "usdc-stellar": { chain: "1500", token: "USDC" }
58574
58571
  };
58572
+ var NON_TOPUP_PRESETS = /* @__PURE__ */ new Set([
58573
+ "btc-lightning",
58574
+ "eth-ethereum",
58575
+ "eth-base",
58576
+ "eth-arbitrum",
58577
+ "bnb-bnb",
58578
+ "sol-solana"
58579
+ ]);
58580
+ var TOPUP_STABLE_ONLY = "x402 top ups accept USDC and USDT only. Holding a native coin or sats? Use them to top up OpenRouter with: rozo-checkout pay <openrouter-payment-link> --with btc-lightning (sats), or https://checkout.rozo.ai (native coins).";
58575
58581
  var TOPUP_MIN_USD = 5;
58576
58582
  function resolveTopupPreset(value) {
58577
58583
  const key = String(value ?? "").trim().toLowerCase();
58584
+ if (NON_TOPUP_PRESETS.has(key) || /^(eth|bnb|sol|pol|matic|xlm|btc|sats)-/.test(key)) {
58585
+ throw new SkillError("X402_TOPUP_SOURCE_UNSUPPORTED", TOPUP_STABLE_ONLY, { preset: key });
58586
+ }
58578
58587
  const hit = TOPUP_PRESETS[key];
58579
58588
  if (!hit) {
58580
58589
  throw new SkillError(
@@ -58753,7 +58762,6 @@ async function runTopup({ amountUsd, coin }, { fetchImpl, blacklist } = {}) {
58753
58762
  ...created ? { keyCreated: created } : {},
58754
58763
  key: { masked: maskKey(found.key), source: found.source },
58755
58764
  coin: preset.preset,
58756
- native: Boolean(preset.native),
58757
58765
  requestedUsd: String(amountUsd).trim(),
58758
58766
  deposit,
58759
58767
  note: "Send exactly once, from your own wallet. Your x402 balance is credited after the deposit confirms."