@aeon-ai-pay/aigateway 0.1.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 (44) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +116 -0
  4. package/bin/cli.mjs +155 -0
  5. package/docs/env-vars.md +73 -0
  6. package/docs/exit-codes.md +65 -0
  7. package/docs/ide-setup.md +60 -0
  8. package/docs/output-schema.md +188 -0
  9. package/docs/recipes/cron-issue-cards.md +69 -0
  10. package/docs/recipes/error-recovery.md +53 -0
  11. package/docs/recipes/integrate-in-agent.md +108 -0
  12. package/docs/recipes/merchant-integration.md +243 -0
  13. package/docs/release-process.md +98 -0
  14. package/docs/troubleshooting.md +200 -0
  15. package/package.json +58 -0
  16. package/scripts/postinstall.mjs +40 -0
  17. package/skills/aigateway/SKILL.md +370 -0
  18. package/skills/aigateway/references/check-status.md +68 -0
  19. package/skills/aigateway/references/create-card.md +114 -0
  20. package/skills/aigateway/references/store.md +87 -0
  21. package/skills/aigateway/references/x402-protocol.md +143 -0
  22. package/src/balance.mjs +92 -0
  23. package/src/commands/clean.mjs +65 -0
  24. package/src/commands/create-card-status.mjs +67 -0
  25. package/src/commands/create-card.mjs +333 -0
  26. package/src/commands/create-image.mjs +428 -0
  27. package/src/commands/wallet-balance.mjs +47 -0
  28. package/src/commands/wallet-gas.mjs +99 -0
  29. package/src/commands/wallet-init.mjs +42 -0
  30. package/src/commands/wallet-topup.mjs +221 -0
  31. package/src/commands/wallet-withdraw.mjs +183 -0
  32. package/src/config.mjs +50 -0
  33. package/src/constants.mjs +22 -0
  34. package/src/error-codes.mjs +50 -0
  35. package/src/funding.mjs +216 -0
  36. package/src/output.mjs +85 -0
  37. package/src/sanitize.mjs +48 -0
  38. package/src/update-check.mjs +69 -0
  39. package/src/walletconnect.mjs +712 -0
  40. package/src/x402.mjs +120 -0
  41. package/templates/cline/.clinerules +53 -0
  42. package/templates/codex/AGENTS.md +56 -0
  43. package/templates/cursor/.cursor/rules/aigateway.mdc +60 -0
  44. package/templates/windsurf/.windsurfrules +48 -0
@@ -0,0 +1,370 @@
1
+ ---
2
+ name: aigateway
3
+ description: >
4
+ Trigger this skill whenever the user wants to *purchase* or *invoke* anything
5
+ that AEON AI Gateway can settle per-call via the x402 protocol โ€” including
6
+ virtual debit cards and Skill Boss AI services (currently AI image generation).
7
+
8
+ This includes intents such as:
9
+ - "create a virtual card" / "get me a card with $5" / "what's my card status"
10
+ - "generate an image of โ€ฆ" / "draw a picture of โ€ฆ" / "render this scene"
11
+ - "what can I buy" / "what can I do?"
12
+ - "top up my wallet" / "check my balance" / "withdraw my funds"
13
+
14
+ Also, any request involving x402-protocol crypto payments for AI services or
15
+ virtual cards funded with USDT on BSC.
16
+ emoji: "๐Ÿ›ฐ๏ธ"
17
+ homepage: https://github.com/AEON-Project/aigateway
18
+ metadata:
19
+ version: "0.1.0"
20
+ author: AEON-Project
21
+ openclaw:
22
+ requires:
23
+ bins:
24
+ - node
25
+ - npx
26
+ primaryEnv: AIGATEWAY_SERVICE_URL
27
+ user-invocable: true
28
+ disable-model-invocation: false
29
+ compatibility: Requires Node.js >= 25 and npm
30
+ ---
31
+
32
+ # AEON AI Gateway Skill
33
+
34
+ **AEON AI Gateway** lets AI Agents discover, invoke, and settle paid LLMs, APIs, and Skills via a single CLI. Currently open capabilities:
35
+
36
+ - **`create-card`** โ€” issue a one-time virtual Visa/Mastercard (x402-paid, USDT on BSC).
37
+ - **`create-image`** โ€” generate an AI image via Skill Boss (x402-paid, USDT on BSC).
38
+
39
+ Both share the same session-key wallet, funded once via WalletConnect and reused indefinitely.
40
+
41
+ > โšก **Two-step wallet readiness, then pay-per-call**:
42
+ > - **`wallet-init`** *(local, free)*: Generates a local session key (if missing) and returns ready/created status. No QR, no on-chain action.
43
+ > - **`wallet-topup`** *(WalletConnect, one-time)*: Loads USDT (โ‰ฅ5 USDT minimum, presets 5/10/20/50) + 0.0003 BNB approve gas, then the session key broadcasts `ERC20.approve(facilitator, MaxUint256)`. Done once; subsequent paid calls reuse the allowance and run gasless. Use again later (with `--amount <usdt>`) to refill.
44
+ > - **`create-card` / `create-image`** *(gasless)*: Pure EIP-712 signatures โ†’ server submits the USDT transfer (server pays gas). If somehow underfunded, both commands fall back into the same funding flow as `wallet-topup`.
45
+ > - **`wallet-withdraw`**: Session key sends ERC20 transfer + BNB directly on-chain โ€” needs a tiny BNB balance for gas.
46
+ > - **`wallet-gas`**: Transfers BNB only (used when `wallet-withdraw` reports `No BNB for gas`).
47
+
48
+ ---
49
+
50
+ ## Opening Line (Required)
51
+
52
+ Whenever entering this skill for the first time, output this opening line:
53
+
54
+ > Let me check the environment first.
55
+
56
+ Then **immediately** proceed to "Step 1: Pre-check".
57
+
58
+ ---
59
+
60
+ ## Output Envelope
61
+
62
+ Every CLI command writes **one JSON line** to **stdout** โ€” the *envelope*. Progress logs go to stderr and are not required for control flow.
63
+
64
+ - Success: `{ "ok": true, "command": "...", "version": "...", "data": { /* payload */ } }`
65
+ - Failure: `{ "ok": false, "command": "...", "version": "...", "error": { "code": "...", "message": "...", /* extra context */ } }`
66
+
67
+ Field references in this document (e.g. `ready`, `orderNo`, `cardStatus`) refer to fields under **`envelope.data`** (success) or under **`envelope.error`** (failure). **Match on `error.code` (stable) โ€” not on `error.message`.**
68
+
69
+ See [docs/output-schema.md](../../docs/output-schema.md) and [docs/exit-codes.md](../../docs/exit-codes.md) for the full schema and error code reference.
70
+
71
+ ---
72
+
73
+ ## Command Overview
74
+
75
+ ```bash
76
+ aigateway wallet-init # Pre-check / auto-create local session wallet (no QR)
77
+ aigateway wallet-topup [--amount <usdt>] # WalletConnect: top-up USDT (โ‰ฅ5; presets 5/10/20/50) + first-time facilitator approve
78
+ aigateway create-card --amount <usd> --poll # Issue a virtual card ($0.6 ~ $800)
79
+ aigateway create-image --prompt "<text>" # Generate AI image
80
+ aigateway create-card-status --order-no <orderNo> [--poll] # Query card status
81
+ aigateway wallet-balance # Check local wallet balance
82
+ aigateway wallet-gas [--amount <bnb>] # Top up BNB for session key (for withdraw)
83
+ aigateway wallet-withdraw [--to <addr>] [--amount <usdt>] # Reclaim funds
84
+ aigateway clean # Uninstall skill, clear cache
85
+ ```
86
+
87
+ Every command accepts `--app-id <id>` (merchant identifier; defaults to `TEST000001` โ€” do not prompt the user unless they explicitly mention a custom merchant ID). Config lives at `~/.aigateway/config.json` (mode 0o600).
88
+
89
+ **Never ask the user for a private key; the local session key is auto-generated.**
90
+
91
+ ---
92
+
93
+ ## Step 1: Pre-check (Auto Wallet Initialization)
94
+
95
+ Regardless of user intent, **always** run first:
96
+
97
+ ```bash
98
+ aigateway wallet-init
99
+ ```
100
+
101
+ Output template:
102
+
103
+ ```
104
+ > Pre-check in progress...
105
+ ```
106
+
107
+ `envelope.data`: `{ ready, created, mode, address, mainWallet, serviceUrl, amountLimits }`.
108
+
109
+ - `created: true` โ†’ "Auto-creating your designated wallet..." + then "0x0...{last4} Ready."
110
+ - `created: false`, `ready: true` โ†’ "0x0...{last4} Ready."
111
+ - Record `amountLimits.{min,max}` for any subsequent card amount validation.
112
+
113
+ ---
114
+
115
+ ## Step 2: Top up (First-Time Funding + Approve)
116
+
117
+ Trigger: any of (first paid call) | (`wallet-balance` shows < 1 USDT) | (user explicitly wants to "top up" / "load wallet" / "add funds").
118
+
119
+ ```bash
120
+ aigateway wallet-topup # Interactive top-up amount prompt (TTY only)
121
+ aigateway wallet-topup --amount 5 # Non-interactive (recommended for agent invocations)
122
+ ```
123
+
124
+ ### When does topup do nothing?
125
+
126
+ If `wallet` shows USDT โ‰ฅ 1 **and** allowance is already non-zero **and** the user did not explicitly ask to add funds, skip Step 2 entirely.
127
+
128
+ ### Amount selection
129
+
130
+ - Presets: **5 / 10 / 20 / 50 USDT**. Custom amounts must be โ‰ฅ 5 USDT.
131
+ - If user said "top up" without an amount, use this exact copy and ask:
132
+ > How much USDT would you like to load? (presets: 5 / 10 / 20 / 50, or any custom amount โ‰ฅ 5)
133
+ - Once the user picks an amount, run with `--amount <n>`.
134
+
135
+ ### Output template
136
+
137
+ ```
138
+ > Topping up wallet...
139
+ ```
140
+
141
+ On success, surface:
142
+
143
+ ```
144
+ โœ… Wallet prepared
145
+ Address: 0x0...{last4}
146
+ Balance: {usdt} USDT, {bnb} BNB
147
+ Approve: {approveTx truncated or "already approved"}
148
+ ```
149
+
150
+ ### Error cases
151
+
152
+ | `error.code` | Action |
153
+ | --- | --- |
154
+ | `TOPUP_REQUIRED` (non-TTY, balance < 1 USDT) | Ask user for amount (presets in `error.presets`), then rerun with `--amount <n>`. |
155
+ | `TOPUP_AMOUNT_TOO_SMALL` | Show `error.minTopup`, ask again. |
156
+ | `PAYMENT_REJECTED` | User cancelled in wallet. **Do not auto-retry**; ask user. |
157
+ | `PAYMENT_TIMEOUT` | 5-minute WalletConnect window expired. **Do not auto-retry**; ask user. |
158
+ | `INSUFFICIENT_BNB` (post-funding) | Run `aigateway wallet-gas` (interactive) to add BNB, then retry. |
159
+ | `APPROVE_FAILED` | On-chain approve failed; surface message, suggest retry. |
160
+
161
+ โš ๏ธ `wallet-topup` opens a WalletConnect QR โ€” **must run in foreground synchronously**. Never `run_in_background: true`.
162
+
163
+ ---
164
+
165
+ ## Step 3a: Create Virtual Card
166
+
167
+ Trigger: user wants to **buy / create / get a virtual card**.
168
+
169
+ ### Amount confirmation
170
+
171
+ Amount must be in `amountLimits.min ~ amountLimits.max` (from Step 1; never hardcode). If user did not specify, ask once:
172
+
173
+ > You can create a card of up to ${min}~${max}. How much would you like to load onto the card?
174
+
175
+ Once specified, **execute immediately**.
176
+
177
+ ### Execute
178
+
179
+ ```bash
180
+ aigateway create-card --amount <usd> --poll
181
+ # Optional: custom merchant
182
+ aigateway create-card --amount <usd> --app-id <merchantId> --poll
183
+ ```
184
+
185
+ Output template first line:
186
+
187
+ ```
188
+ > Creating Agent Card...
189
+ ```
190
+
191
+ โš ๏ธ If the session wallet is underfunded, `create-card` may open a WalletConnect QR โ€” **must run in foreground**.
192
+
193
+ ### Success
194
+
195
+ `envelope.data`: `{ orderNo, data, paymentResponse, pollResult? }`. After fetching details (may take ~30 s), display **verbatim**:
196
+
197
+ ```
198
+ Order No: {orderNo}
199
+ Card: {cardScheme} โ€ขโ€ขโ€ขโ€ข {last4}
200
+ State: Active
201
+ Remaining balance: ${amount} USD
202
+ Usage: 0 / 1 (single-use)
203
+ ```
204
+
205
+ Always record `orderNo` โ€” only identifier for status queries.
206
+
207
+ ### Errors
208
+
209
+ | `error.code` | Action |
210
+ | --- | --- |
211
+ | `AMOUNT_OUT_OF_RANGE` | Show `error.min` / `error.max`, ask again. |
212
+ | `INSUFFICIENT_USDT` (after funding) | Tell user funding fell short; ask whether to re-top-up. |
213
+ | `PAYMENT_TIMEOUT` / `PAYMENT_REJECTED` | Surface, **do not auto-retry**. |
214
+ | `POLL_TIMEOUT` | Card may still be provisioning. Note `error.orderNo`. Use Step 4 (`status`) later. |
215
+ | `PAYMENT_FAILED` | Show raw error (`error.data`), suggest retry. |
216
+
217
+ See [references/create-card.md](references/create-card.md) for full field details.
218
+
219
+ ---
220
+
221
+ ## Step 3b: Create AI Image
222
+
223
+ Trigger: user wants to **generate / draw / render an image**.
224
+
225
+ ### Execute
226
+
227
+ ```bash
228
+ aigateway create-image --prompt "<text>"
229
+ # Optional flags:
230
+ aigateway create-image --prompt "<text>" --aspect-ratio 1:1 --output-format png --model <id>
231
+ ```
232
+
233
+ Output template first line:
234
+
235
+ ```
236
+ > Generating image...
237
+ ```
238
+
239
+ ### Success
240
+
241
+ `envelope.data`: `{ prompt, transaction, images: [{ url, localPath, format, width, height, sizeHuman }], balance: { initial, before, after, charged } }`.
242
+
243
+ Display **verbatim**:
244
+
245
+ ```
246
+ โœ… Generated
247
+ Prompt: {prompt}
248
+ Image: {localPath} ({width}ร—{height}, {sizeHuman})
249
+ Transaction: {transaction}
250
+ Charged: {balance.charged} USDT
251
+ Balance: {balance.after} USDT remaining
252
+ ```
253
+
254
+ ### Errors
255
+
256
+ | `error.code` | Action |
257
+ | --- | --- |
258
+ | `MISSING_PROMPT` | Ask user for a non-empty prompt. |
259
+ | `INSUFFICIENT_USDT` (after funding) | Same as Step 3a. |
260
+ | `IMAGE_DOWNLOAD_FAILED` | Mention image was generated but local save failed (URL in raw response). |
261
+ | Same set as Step 3a for `PAYMENT_*` / `POLL_*` codes. |
262
+
263
+ ---
264
+
265
+ ## Step 4: Query Status / Wallet / Withdraw
266
+
267
+ ### Status (cards only)
268
+
269
+ ```bash
270
+ aigateway create-card-status --order-no <orderNo>
271
+ aigateway create-card-status --order-no <orderNo> --poll # poll until terminal
272
+ ```
273
+
274
+ `envelope.data` shape mirrors the sanitized server response. Use it to display:
275
+
276
+ ```
277
+ > Fetching card status...
278
+
279
+ Card: {cardScheme} โ€ขโ€ขโ€ขโ€ข {last4}
280
+ State: {Active | Used | Expired | Pending | Failed}
281
+ Remaining balance: ${balance} USD
282
+ Usage: {used} / {total} (single-use)
283
+ ```
284
+
285
+ ### Wallet (balance check)
286
+
287
+ ```bash
288
+ aigateway wallet-balance
289
+ ```
290
+
291
+ `envelope.data`: `{ address, usdt, bnb, mainWallet? }`.
292
+
293
+ ### Withdraw
294
+
295
+ ```bash
296
+ aigateway wallet-withdraw # all USDT โ†’ mainWallet
297
+ aigateway wallet-withdraw --amount <usdt> # specific amount
298
+ aigateway wallet-withdraw --to 0x... # specific destination
299
+ ```
300
+
301
+ Display **verbatim**:
302
+
303
+ ```
304
+ > Reclaiming funds...
305
+
306
+ From: 0x0...{session_last4}
307
+ To: main wallet (0x0...{main_last4})
308
+
309
+ Amount: {amount} USDT
310
+ Status: completed
311
+ ```
312
+
313
+ The literal "main wallet" label is a spec requirement โ€” do not omit.
314
+
315
+ ### Edge cases
316
+
317
+ | Scenario | Action |
318
+ | --- | --- |
319
+ | `error.code = NO_MAIN_WALLET` | Ask user for destination, rerun with `--to <address>`. |
320
+ | `error.code = INSUFFICIENT_BNB` (in withdraw) | Run `aigateway wallet-gas` first. |
321
+ | `error.code = NO_FUNDS` | Inform user nothing to withdraw. |
322
+
323
+ ---
324
+
325
+ ## Decision Routing
326
+
327
+ | User Intent | Entry Command |
328
+ | --- | --- |
329
+ | First entry / uncertain state | `wallet-init` (then `wallet-topup` if balance < 1 USDT) |
330
+ | Top up / load wallet / fund | `wallet-topup --amount <n>` |
331
+ | Create virtual card | `create-card --amount <n> --poll` |
332
+ | Generate AI image | `create-image --prompt "<text>"` |
333
+ | Check card status | `create-card-status --order-no <n>` |
334
+ | Check balance | `wallet` |
335
+ | Withdraw funds | `withdraw [--to <addr>] [--amount <n>]` |
336
+ | Top up BNB for withdraw | `gas [--amount <bnb>]` |
337
+
338
+ ---
339
+
340
+ ## Hard Rules (Global)
341
+
342
+ - **Never** ask for a private key โ€” the local session key is auto-generated.
343
+ - **Never** display full card numbers, CVV, or expiry. The CLI already redacts these to `โ€ขโ€ขโ€ขโ€ข 1234`.
344
+ - **Never** run `wallet-topup` / `create-card` (when underfunded) / `create-image` (when underfunded) / `wallet-gas` in the background โ€” they may open a WalletConnect QR that needs user attention.
345
+ - **Never** auto-retry `PAYMENT_REJECTED` / `PAYMENT_TIMEOUT`. Ask the user.
346
+ - **Never** poll `status` more than 42 times. Stop on timeout, prompt user to note `orderNo`.
347
+ - **Never** fabricate `amountLimits`. Always use `min/max` from `wallet-init`.
348
+ - **Match `error.code`, not `error.message`.** Messages may change between versions.
349
+
350
+ ---
351
+
352
+ ## Copy Constraints (Verbatim Lines)
353
+
354
+ The following first-line / key-phrase strings must be **exactly reproduced** โ€” no rewording, no translation, no extra decorations:
355
+
356
+ | Step | Required first line |
357
+ | --- | --- |
358
+ | Pre-check | `> Pre-check in progress...` |
359
+ | Top up | `> Topping up wallet...` |
360
+ | Create card | `> Creating Agent Card...` |
361
+ | Create image | `> Generating image...` |
362
+ | Fetch details | `> Fetching card details, please wait...` |
363
+ | Query status | `> Fetching card status...` |
364
+ | Withdraw | `> Reclaiming funds...` |
365
+ | Withdraw target line | `To: main wallet (0x0...{last4})` |
366
+ | Withdraw status line | `Status: completed` |
367
+ | Image success header | `โœ… Generated` |
368
+ | Wallet prepared header | `โœ… Wallet prepared` |
369
+
370
+ Address rendering: always `0x0...{last4}` (first 3 + ellipsis + last 4 chars).
@@ -0,0 +1,68 @@
1
+ # Check Card Status
2
+
3
+ ## Command
4
+
5
+ ```bash
6
+ # Single query
7
+ npx @aeon-ai-pay/aigateway create-card-status --order-no <orderNo>
8
+
9
+ # Poll until terminal status (SUCCESS or FAIL)
10
+ npx @aeon-ai-pay/aigateway create-card-status --order-no <orderNo> --poll
11
+ ```
12
+
13
+ ## Response Format
14
+
15
+ ```json
16
+ {
17
+ "code": "0",
18
+ "msg": "success",
19
+ "model": {
20
+ "orderNo": "300217748668047431791",
21
+ "orderStatus": "SUCCESS",
22
+ "channelStatus": "COMPLETED",
23
+ "orderAmount": 0.6,
24
+ "txHash": "0xabc...def",
25
+ "cardLastFour": "4321",
26
+ "cardBin": "485932",
27
+ "cardScheme": "VISA",
28
+ "cardBalance": 0.6,
29
+ "cardStatus": "ACTIVE"
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Status Values
35
+
36
+ ### orderStatus (Order Status)
37
+
38
+ | Status | Meaning | Action |
39
+ |------|------|------|
40
+ | `INIT` | Order created, not yet paid | Wait |
41
+ | `PENDING` | Payment submitted, awaiting on-chain confirmation | Continue polling |
42
+ | `SUCCESS` | Card created successfully | Show card details |
43
+ | `FAIL` | Failed | Show error, suggest retry |
44
+
45
+ ### channelStatus (Channel Status)
46
+
47
+ | Status | Meaning |
48
+ |------|------|
49
+ | `INIT` | Not yet sent to card provider |
50
+ | `PROCESSING` | Provider is creating the card |
51
+ | `COMPLETED` | Card is ready |
52
+ | `FAILED` | Card creation failed |
53
+
54
+ ### cardStatus (Card Status)
55
+
56
+ | Status | Meaning |
57
+ |------|------|
58
+ | `PENDING` | Being provisioned |
59
+ | `ACTIVE` | Ready to use |
60
+ | `FROZEN` | Frozen |
61
+ | `CANCELLED` | Cancelled |
62
+
63
+ ## Polling Behavior
64
+
65
+ With `--poll`:
66
+ - Up to **42 attempts** (first 5 at **2-second** intervals, then every **5 seconds**)
67
+ - Stops on `SUCCESS`, `FAIL`, or `cardStatus=ACTIVE`
68
+ - If timed out, notify user and provide manual query command
@@ -0,0 +1,114 @@
1
+ # Create Virtual Card
2
+
3
+ ## Prerequisites
4
+
5
+ Before creating a card, confirm the following:
6
+
7
+ 1. Wallet is configured โ€” run `wallet-init`. If not ready, the CLI will auto-create one.
8
+ 2. Service URL is configured (built-in default is available; no action needed unless user wants to override)
9
+ 3. The `create` command automatically checks allowance and wallet balance before payment. If insufficient, it auto-initiates WalletConnect funding โ€” no need to run `wallet` or `wallet-topup` separately.
10
+
11
+ ## Workflow
12
+
13
+ ### Step 1: Confirm Amount
14
+
15
+ Ask the user how much to load onto the virtual card.
16
+
17
+ - Amount limits are enforced by the CLI (`amountLimits.min` ~ `amountLimits.max`, from `wallet-init`).
18
+ - Currency: USD (server handles crypto conversion)
19
+
20
+ **If user does not specify an amount**, show the valid range and ask for confirmation (**copy must be verbatim**, variable substitution only):
21
+ > "You can create a card of up to ${min}~${max}. How much would you like to load onto the card๏ผŸ"
22
+
23
+ Once the user specifies an amount, **execute immediately** โ€” no second confirmation needed.
24
+
25
+ ### Step 2: Execute
26
+
27
+ ```bash
28
+ # Create card and auto-poll status
29
+ npx @aeon-ai-pay/aigateway create --amount <amount> --poll
30
+
31
+ # Optional: specify merchant app ID (defaults to TEST000001)
32
+ npx @aeon-ai-pay/aigateway create --amount <amount> --app-id <merchantAppId> --poll
33
+ ```
34
+
35
+ > `--app-id` is the merchant identifier sent with the request; defaults to `TEST000001` when omitted.
36
+
37
+ CLI automatically handles the full flow:
38
+ 1. Send `GET /open/ai/x402/card/create?amount=X&appId=Y` โ†’ receive HTTP 402 + payment requirements (exact USDT amount)
39
+ 2. Check allowance โ†’ if insufficient and no BNB, mark BNB needed
40
+ 3. Check USDT balance โ†’ if insufficient, mark top-up needed
41
+ 4. If top-up or BNB needed โ†’ auto-initiate WalletConnect funding (opens QR page, waits for user to confirm in wallet app)
42
+ 5. After funding completes, auto-continue
43
+ 6. Approve authorization (only on first use or when allowance insufficient, costs small amount of BNB)
44
+ 7. Sign with the exact amount from the first 402 response using EIP-712
45
+ 8. Retry request with `PAYMENT-SIGNATURE` header โ†’ receive HTTP 200
46
+ 9. With `--poll`, polls up to 42 times (first 5 at 2-second intervals, then every 5 seconds) until card is ready
47
+
48
+ ### Step 3: Parse Result
49
+
50
+ **stdout** outputs JSON (parseable), **stderr** outputs progress logs.
51
+
52
+ Successful output:
53
+ ```json
54
+ {
55
+ "success": true,
56
+ "data": {
57
+ "code": "0",
58
+ "msg": "success",
59
+ "model": { "orderNo": "300217748668047431791" }
60
+ },
61
+ "paymentResponse": {
62
+ "txHash": "0x...",
63
+ "networkId": "eip155:56"
64
+ }
65
+ }
66
+ ```
67
+
68
+ With `--poll`, additional output after card is ready:
69
+ ```json
70
+ {
71
+ "pollResult": {
72
+ "orderNo": "300217748668047431791",
73
+ "orderStatus": "SUCCESS",
74
+ "channelStatus": "COMPLETED",
75
+ "orderAmount": 0.6,
76
+ "txHash": "0xabc...def",
77
+ "cardLastFour": "4321",
78
+ "cardBin": "485932",
79
+ "cardScheme": "VISA",
80
+ "cardBalance": 0.6,
81
+ "cardStatus": "ACTIVE"
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Step 4: Present to User
87
+
88
+ Fetching card details may take about 30 seconds. Output a waiting prompt first (**copy must be verbatim**):
89
+ ```
90
+ > Fetching card details, please wait...
91
+ ```
92
+
93
+ Once details are returned, on success (**copy must be verbatim**, variable substitution only):
94
+ ```
95
+ Order No: {orderNo}
96
+ Card: {cardScheme} โ€ขโ€ขโ€ขโ€ข {last4}
97
+ State: Active
98
+ Remaining balance: ${amount} USD
99
+ Usage: 0 / 1 (single-use)
100
+ ```
101
+
102
+ Save the `orderNo` for subsequent status queries.
103
+
104
+ ## Error Handling
105
+
106
+ | Scenario | CLI Output | Action |
107
+ |------|---------|---------|
108
+ | Amount out of range | Error JSON with allowed range | Relay to user |
109
+ | Wallet not configured | `Wallet not configured` | Run `wallet-init` |
110
+ | Funding signature timeout (5 min) | `Payment approval timed out. Please try again.` | Relay to user, ask if they want to retry |
111
+ | User rejected signature | `Payment approval was rejected. Please try again if you'd like to proceed.` | Relay to user, do not auto-retry |
112
+ | Insufficient balance after funding | `Still insufficient USDT after funding` | Relay to user |
113
+ | Network error | Server error JSON | Retry once, then report to user |
114
+ | Transaction reverted | txHash | Suggest user check on BSCScan |
@@ -0,0 +1,87 @@
1
+ # AEON AI Card Store
2
+
3
+ ## When to use
4
+
5
+ Trigger this reference when the user says:
6
+ - "what can I buy"
7
+ - "show me what's available"
8
+ - "what can I do?"
9
+ - "what can I use the card for"
10
+
11
+ Present options conversationally. Do not dump the full list โ€” highlight what's most relevant.
12
+
13
+ ---
14
+
15
+ ## Virtual Card Use Cases
16
+
17
+ ### AEON Agent Card โ€“ Supported & Upcoming Use Cases
18
+
19
+ **Coming Soon**
20
+ - Subscriptions (ChatGPT, Claude, Midjourney)
21
+ - Ads (Google, Meta)
22
+ - Travel bookings
23
+ - SaaS tools
24
+
25
+ **Tell us what you want**
26
+
27
+ Submit your request here:
28
+ ๐Ÿ‘‰ [Google Form link]
29
+
30
+ ---
31
+
32
+ ## x402 API Payments
33
+
34
+ Pay these services directly using `x402 fetch`. No card needed โ€” payment goes straight from your wallet.
35
+
36
+ ### AI & Data
37
+
38
+ | Service | What it does | Chain |
39
+ |---|---|---|
40
+ | AskClaude | Per-question Claude AI access ($0.01โ€“$0.10/query) | Base |
41
+ | Arch AI Tools | 53 AI tools: web search, image generation, fact-checking | Base |
42
+ | Firecrawl | Web scraping and LLM-ready content extraction | Base |
43
+ | Gloria AI | Real-time news data for agents | Base |
44
+ | Minifetch | Web metadata and content summaries | Base |
45
+
46
+ ### Blockchain & DeFi
47
+
48
+ | Service | What it does | Chain |
49
+ |---|---|---|
50
+ | Messari | Crypto research and on-chain data | Base |
51
+ | Nansen | Wallet intelligence and blockchain analytics | Base |
52
+ | DiamondClaws | DeFi yield scoring and protocol risk analysis | Base |
53
+ | Stakevia | Solana validator intelligence | Solana |
54
+
55
+ ### Infrastructure
56
+
57
+ | Service | What it does | Chain |
58
+ |---|---|---|
59
+ | Pinata | IPFS file uploads and retrievals, no account required | Base |
60
+ | Run402 | Postgres databases and serverless functions, no signup | Base |
61
+ | Alchemy | Pay-per-request RPC / blockchain API access | Base |
62
+ | Robtex | DNS and network intelligence APIs | Base |
63
+
64
+ ### Payments & Commerce
65
+
66
+ | Service | What it does | Chain |
67
+ |---|---|---|
68
+ | Bitrefill | Buy gift cards and prepaid cards with crypto | Base |
69
+ | ClawCredit | Access x402 services on credit, pay later | Base |
70
+
71
+ Full registry: [x402.org/ecosystem](https://www.x402.org/ecosystem) ยท [x402list.fun](https://x402list.fun)
72
+
73
+ ---
74
+
75
+ ## How to Present to the User
76
+
77
+ Example response when user has no specific intent:
78
+
79
+ > "Here's what you can do with AEON AI Card:
80
+ >
81
+ > - **Virtual card** โ€” coming soon: subscribe to ChatGPT, Claude, Midjourney, run ads, book travel
82
+ > - **Pay AI APIs** โ€” call Claude, Firecrawl, web search per request via x402
83
+ > - **Access DeFi data** โ€” Nansen, Messari on-chain analytics via x402
84
+ >
85
+ > What would you like to do?"
86
+
87
+ Adapt based on context. For virtual card intent โ†’ route to create-card flow. For x402 API intent โ†’ route to x402 flow.