@aeon-ai-pay/aigateway 0.1.5 → 0.2.1

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.
@@ -1,22 +1,32 @@
1
1
  ---
2
2
  name: aigateway
3
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.
4
+ 当用户希望通过 x402 协议、用 BSC 上的 USDT 按次结算调用 AI 工具时
5
+ 触发此 skill —— 200+ 个工具端点:图像 / 视频 / 音频 (TTS) / 转录 (STT) / 网络搜索 /
6
+ 网页抓取 / 社交与商业数据 / 邮件 / 短信 / 文档解析 / UI 与演示生成 / 嵌入向量 /
7
+ 金融 / 新闻 / 地理位置 / 实用 API。
8
+
9
+ skill **不暴露 chat / LLM** —— Agent 自身已是 LLM,无需通过 x402 付费调另一个 LLM。
10
+
11
+ 触发意图示例:
12
+ - "生成一张图 / 画个 / 渲染场景"
13
+ - "生成视频 / 动画 / 短片"
14
+ - "把这段文字转语音 / 合成声音"
15
+ - "转录这段录音 / 语音转文字"
16
+ - "搜一下 … / 查询信息"
17
+ - "抓这个 URL / 从这个页面提取数据"
18
+ - "发邮件给 … / 发短信 / OTP 验证码"
19
+ - "解析这个 PDF / DOCX / 把文档转 markdown"
20
+ - "生成落地页 / 移动 UI / 幻灯片"
21
+ - "给这些文本做嵌入向量"
22
+ - "查加密货币 / 股票 / 外汇 / 天气数据"
23
+ - "拉 <平台> 资料"(Twitter / Instagram / LinkedIn / Amazon / Yelp …)
24
+ - "我能做什么?"
25
+ - "充值钱包 / 查余额 / 提现"
16
26
  emoji: "🛰️"
17
27
  homepage: https://github.com/AEON-Project/aigateway
18
28
  metadata:
19
- version: "0.1.5"
29
+ version: "0.2.1"
20
30
  author: AEON-Project
21
31
  openclaw:
22
32
  requires:
@@ -26,103 +36,101 @@ metadata:
26
36
  primaryEnv: AIGATEWAY_SERVICE_URL
27
37
  user-invocable: true
28
38
  disable-model-invocation: false
29
- compatibility: Requires Node.js >= 25 and npm
39
+ compatibility: 需要 Node.js >= 25 npm
30
40
  ---
31
41
 
32
- # AEON AI Gateway Skill
42
+ # AEON AI Gateway for AI Agents
33
43
 
34
- **AEON AI Gateway** lets AI Agents discover, invoke, and settle paid LLMs, APIs, and Skills via a single CLI. Currently open capabilities:
44
+ **AEON AI Gateway** = "**x402 协议钱包工具统一付费入口**" CLI。让 AI Agent BSC 上的 USDT,按次结算地调用 ≈200+ AI 工具与服务(**不含 chat**)。
35
45
 
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).
46
+ ## 核心入口
38
47
 
39
- Both share the same session-key wallet, funded once via WalletConnect and reused indefinitely.
48
+ **`aigateway sb invoke --model <id> --inputs <json>`** —— **唯一的 x402 付费调用入口**。覆盖全部 AI 工具能力(图像 / 视频 / 音频 / TTS / STT / 网络搜索 / 网页抓取 / 社交数据 / 邮件 / 短信 / 文档 / UI / 嵌入 / 金融 / 新闻 / 地理位置 / 实用 API)。
40
49
 
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`).
50
+ 完整工具索引(每个 `category` `agentTrigger` / `defaultInputsSchema`;每个 `model` 含 `id` / `useCase` / `tier` / 可选 `inputsOverride`)由服务端集中维护,每次实时拉取。**无本地缓存** —— 服务端是 single source of truth,model 新增 / schema 改动立即生效。
47
51
 
48
- ---
49
-
50
- ## Opening Line (Required)
52
+ **Agent 在 Phase 3.2 选 model 时**:
51
53
 
52
- Whenever entering this skill for the first time, output this opening line:
54
+ ```bash
55
+ aigateway sb tools # 调服务端 → stdout 输出 envelope,data 字段即完整 catalog JSON
56
+ ```
53
57
 
54
- > Let me check the environment first.
58
+ stdout JSON parse 出来,按 `data.categories[].models[]` 挑 model。每次都从服务端实时获取,无本地缓存。
55
59
 
56
- Then **immediately** proceed to "Step 1: Pre-check".
60
+ 价格不在 catalog 里:x402 第一阶段(402 响应)会实时返回本次调用的 USDT 金额,CLI 自动展示给用户。
57
61
 
58
- ---
62
+ ## 钱包模型(与 x402 的关系)
59
63
 
60
- ## Output Envelope
64
+ 所有付费调用共用同一个 **session-key 钱包**,通过 WalletConnect 充值一次即可长期复用:
61
65
 
62
- Every CLI command writes **one JSON line** to **stdout** — the *envelope*. Progress logs go to stderr and are not required for control flow.
66
+ > **两步钱包就绪,然后按次付费**:
67
+ > - **`wallet-init`** *(本地、免费)*:检查 / 创建本地 session-key,返回 ready / created / needsTopup 状态
68
+ > - **`wallet-topup`** *(WalletConnect、一次性)*:充值 USDT(最低 5 USDT,预设 5/10/20/50)+ 0.0003 BNB approve gas,session-key 广播 `ERC20.approve(facilitator, MaxUint256)`。后续付费调用全部复用授权额度并 gasless
69
+ > - **付费调用**(`sb invoke`):纯 EIP-712 签名 → 服务端代发 USDT 转账(服务端付 gas)。余额不足时自动回落 `wallet-topup` 流程
70
+ > - **`wallet-withdraw`**:session-key 直接链上发起 ERC20 + BNB 转账 —— 需少量 BNB 用作 gas
71
+ > - **`wallet-gas`**:仅转 BNB(`wallet-withdraw` 报 "No BNB for gas" 时使用)
63
72
 
64
- - Success: `{ "ok": true, "command": "...", "version": "...", "data": { /* payload */ } }`
65
- - Failure: `{ "ok": false, "command": "...", "version": "...", "error": { "code": "...", "message": "...", /* extra context */ } }`
73
+ ---
66
74
 
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`.**
75
+ # 🎯 Agent 决策流程(5 阶段)
68
76
 
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.
77
+ "**识别类别 选模型 → x402 调用**" 的决策思维链(**验参数已内置到 `sb invoke`**,Agent 不需要单独做),前置 aigateway 的"钱包预检 / 充值",后置"渲染 / 余额 / 提现",共 5 个阶段:
70
78
 
71
- ---
79
+ ```
80
+ Phase 1: 钱包预检 ← aigateway 独有,所有调用前必跑
81
+
82
+ Phase 2: 钱包充值(条件) ← needsTopup=true 或用户主动充值
83
+
84
+ Phase 3: 识别类别 + 选模型 ← Agent 决策
85
+
86
+ Phase 4: x402 支付调用 ← aigateway 的 USDT/EIP-712 结算入口(CLI 内置 inputs 校验兜底)
87
+
88
+ Phase 5: 渲染响应 / 余额 / 提现 ← aigateway 收尾
89
+ ```
72
90
 
73
- ## Command Overview
91
+ ## Opening Line(必须按字面输出)
74
92
 
75
- ```bash
76
- aigateway wallet-init # Pre-check / create wallet AND report needsTopup status (one-stop pre-flight)
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 # (optional) Re-query balance — agent rarely needs this; wallet-init already reports it
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
- ```
93
+ 每次首次进入此 skill,输出这一行(**英文原文,不要翻译**):
86
94
 
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).
95
+ > Let me check the environment first.
88
96
 
89
- **Never ask the user for a private key; the local session key is auto-generated.**
97
+ 然后**立即**进入 Phase 1。
90
98
 
91
99
  ---
92
100
 
93
- ## Step 1: Pre-check (Auto Wallet Initialization)
101
+ ## Phase 1: 钱包预检(无条件运行)
94
102
 
95
- Regardless of user intent, **always** run first:
103
+ 无论用户意图为何,**永远**先执行:
96
104
 
97
105
  ```bash
98
106
  aigateway wallet-init
99
107
  ```
100
108
 
101
- Output template:
109
+ 输出第一行(**按字面**):
102
110
 
103
111
  ```
104
112
  > Pre-check in progress...
105
113
  ```
106
114
 
107
- ### If `aigateway` is not found (exit 127 / "command not found")
115
+ ### 如果 `aigateway` 没找到(exit 127 / "command not found"
108
116
 
109
- The CLI hasn't been installed on this host yet. Output to the user **verbatim**:
117
+ CLI 在本机还没装。按字面输出:
110
118
 
111
119
  ```
112
120
  > Installing aigateway...
113
121
  ```
114
122
 
115
- Then run **in the foreground** (this can take 30–60 seconds; do **not** background it):
123
+ 然后**前台**运行(30–60 秒,**不要**后台):
116
124
 
117
125
  ```bash
118
126
  npm install -g @aeon-ai-pay/aigateway
119
127
  ```
120
128
 
121
- After install completes, re-run `aigateway wallet-init`. If `npm install` itself fails (network / permissions), surface the raw error and ask the user to fix their npm environment.
129
+ 完成后重新跑 `aigateway wallet-init`。
122
130
 
123
- ### Envelope on success
131
+ ### 成功响应(envelope)
124
132
 
125
- `envelope.data` (full shape):
133
+ `envelope.data` 形状:
126
134
 
127
135
  ```json
128
136
  {
@@ -134,332 +142,426 @@ After install completes, re-run `aigateway wallet-init`. If `npm install` itself
134
142
  "bnb": "0.0003",
135
143
  "allowance": "115792...max" | "0",
136
144
  "needsTopup": false,
137
- "topupReason": null | "no_prior_funding" | "low_balance" | "no_approve",
145
+ "topupReason": null | "first_time" | "low_balance" | "no_approve" | "chain_check_failed",
138
146
  "minTopup": 5,
139
- "presets": [5, 10, 20, 50],
140
- "amountLimits": { "min": 0.6, "max": 800 }
147
+ "presets": [5, 10, 20, 50]
141
148
  }
142
149
  ```
143
150
 
144
- ### Decision tree (this is the whole pre-flight)
151
+ ### 决策树
145
152
 
146
- | Field | Action |
153
+ | 字段 | 动作 |
147
154
  | --- | --- |
148
- | `created: true` | "Auto-creating your designated wallet..." + "0x0...{last4} Ready." |
149
- | `created: false`, `ready: true` | "0x0...{last4} Ready." |
150
- | **`needsTopup: true`** | **Go to Step 2 immediately.** Use `presets` / `minTopup` from this envelope (don't hardcode). |
151
- | `needsTopup: false` | Wallet has enough USDT and is approved. **Skip Step 2** and jump straight to the user's intent (`create-card` / `create-image` / other). |
152
-
153
- Record `amountLimits.{min,max}` for any subsequent card amount validation.
155
+ | `created: true` | 输出 "正在自动创建你的专属钱包..." + "{addr前3}...{last4} Ready." |
156
+ | `created: false`, `ready: true` | 输出 "{addr前3}...{last4} Ready." |
157
+ | **`needsTopup: true`** | **立即跳到 Phase 2。** envelope 里的 `presets` / `minTopup`(不要硬编码) |
158
+ | `needsTopup: false` | 钱包就绪。**跳过 Phase 2,直接进入 Phase 3。** |
154
159
 
155
160
  ---
156
161
 
157
- ## Step 2: Top up (only if Step 1's envelope says `needsTopup: true`)
162
+ ## Phase 2: 钱包充值(条件触发)
158
163
 
159
- Trigger: `wallet-init` envelope reports `needsTopup: true` (any of `no_prior_funding` / `low_balance` / `no_approve`), **or** the user explicitly asks to top up / load funds.
164
+ 触发:Phase 1 `needsTopup: true`(原因可能是 `first_time` / `low_balance` / `no_approve`),**或**用户明确要求充值。
160
165
 
161
- ### Amount selection
166
+ ### 金额选择
162
167
 
163
- This is a **session-wallet top-up** in USDT (NOT card face value). Make the wording unambiguously about the wallet to avoid the user confusing it with the card face value asked in Step 3a.
168
+ 这是**给 session 钱包**充值。措辞必须明确指向钱包(与"调用费用"区分):
164
169
 
165
- - Presets: **5 / 10 / 20 / 50 USDT**. Custom amounts must be ≥ 5 USDT.
166
- - Ask the user **before** running the command. **Make the noun "wallet" explicit in the question** (when translating to other languages, the translated noun must also unambiguously mean *session wallet*, never *card*):
170
+ - 预设:**5 / 10 / 20 / 50 USDT**。自定义金额 ≥ 5 USDT
171
+ - 命令执行**前**询问用户,问句里"钱包"必须显式出现:
167
172
 
168
- > How much USDT would you like to load **into your session wallet**? (presets: 5 / 10 / 20 / 50, or any custom amount ≥ 5)
173
+ > 你想给 **session 钱包** 充值多少 USDT?(预设:5 / 10 / 20 / 50,或任意自定义 ≥ 5
169
174
 
170
- - Once the user picks an amount, run:
175
+ - 选定后执行:
171
176
 
172
177
  ```bash
173
- aigateway wallet-topup --amount <n> # always pass --amount in agent context
178
+ aigateway wallet-topup --amount <n> # agent 上下文里必须总是带 --amount
174
179
  ```
175
180
 
176
- ### Output template
181
+ 输出第一行(**按字面**):
177
182
 
178
183
  ```
179
184
  > Topping up wallet...
180
185
  ```
181
186
 
182
- On success, surface:
187
+ 成功展示:
183
188
 
184
189
  ```
185
190
  ✅ Wallet prepared
186
- Address: 0x0...{last4}
191
+ Address: {addr前3}...{last4}
187
192
  Balance: {usdt} USDT, {bnb} BNB
188
193
  Approve: {approveTx truncated or "already approved"}
189
194
  ```
190
195
 
191
- ### Error cases
196
+ ⚠️ `wallet-topup` 会弹 WalletConnect 二维码 —— **必须前台同步运行**,永远不要 `run_in_background: true`。
192
197
 
193
- | `error.code` | Action |
194
- | --- | --- |
195
- | `TOPUP_REQUIRED` (would only happen if you skipped Step 2) | Bug in agent — should have asked for amount in Step 3. Ask now, then rerun with `--amount <n>`. |
196
- | `TOPUP_AMOUNT_TOO_SMALL` | Show `error.minTopup`, ask the user for a larger amount. |
197
- | `PAYMENT_REJECTED` | User cancelled in wallet. **Do not auto-retry**; ask user. |
198
- | `PAYMENT_TIMEOUT` | 5-minute WalletConnect window expired. **Do not auto-retry**; ask user. |
199
- | `INSUFFICIENT_BNB` (post-funding) | Run `aigateway wallet-gas` (interactive) to add BNB, then retry. |
200
- | `APPROVE_FAILED` | On-chain approve failed; surface message, suggest retry. |
198
+ ### 错误情况
201
199
 
202
- ⚠️ `wallet-topup` opens a WalletConnect QR — **must run in foreground synchronously**. Never `run_in_background: true`.
200
+ | `error.code` | 动作 |
201
+ | --- | --- |
202
+ | `TOPUP_AMOUNT_TOO_SMALL` | 展示 `error.minTopup`,问更大金额 |
203
+ | `PAYMENT_REJECTED` | 用户取消。**不要自动重试** |
204
+ | `PAYMENT_TIMEOUT` | 5 分钟窗口过期。**不要自动重试** |
205
+ | `INSUFFICIENT_BNB`(充值后) | 运行 `aigateway wallet-gas`,再重试 |
206
+ | `APPROVE_FAILED` | 链上 approve 失败;透传错误,建议重试 |
203
207
 
204
208
  ---
205
209
 
206
- ## Step 3a: Create Virtual Card
210
+ ## Phase 3: 识别任务类别 + 选择模型 ⭐
207
211
 
208
- Trigger: user wants to **buy / create / get a virtual card** *and* Step 1 envelope showed `needsTopup: false` (or Step 2 just completed successfully).
212
+ 这是 Agent 决策的核心:从用户原话识别类别 catalog 挑选 model 把用户原话翻译成 `inputs` 字段。
209
213
 
210
- ### Amount confirmation
214
+ > Inputs 的**最终校验**由 `sb invoke` 在 Phase 4 内置兜底(必填 / 枚举 / 类型 / 范围),所以本阶段重点是**翻译**而非"校验"。
211
215
 
212
- This is the **card face value** the user wants to issue (NOT a wallet top-up). Amount must be in `amountLimits.min ~ amountLimits.max` (from Step 1; never hardcode). If the user did not specify a value, ask once — use the phrase **"card face value"** (or in any non-English language, the equivalent for *the amount loaded onto a new card*), never the verb used for *wallet top-up*:
216
+ ### 3.1 识别任务类别
213
217
 
214
- > What card face value would you like to issue? Allowed range: ${min}~${max} USD.
218
+ 把用户意图归到下表中的一行:
215
219
 
216
- Once specified, **execute immediately**.
220
+ | 用户想做的事 | 类别 | 模板 model_id | 推荐入口 |
221
+ | --- | --- | --- | --- |
222
+ | 生成图像 | `image` | 见 ref(flux-schnell / flux-2-max / dall-e-3 / fal/upscale 等) | `sb invoke --model <id>` |
223
+ | 生成视频 / 动画 | `video` | `seedance/seedance-2.0`、`replicate/google/veo-3.1` 等 | `sb invoke --model <id>` |
224
+ | 文本转语音 / 合成声音 | `tts` | `elevenlabs/eleven_multilingual_v2`、`minimax/speech-01-turbo` 等 | `sb invoke --model <id>` |
225
+ | 转录 / 语音转文字 | `stt` | `openai/whisper-1` | `sb invoke --model <id>` |
226
+ | 网络搜索 / 查信息 | `search` | `perplexity/search`、`tavily/search` 等 | `sb invoke --model <id>` |
227
+ | 抓取网页 / 提取数据 | `scraper` | `firecrawl/scrape`、`firecrawl/extract` 等 | `sb invoke --model <id>` |
228
+ | 社交 / 商业数据(Twitter / IG / LinkedIn / Amazon / Yelp …) | `social_data` | `linkedin-profile`、`twitter-profile` 等 | `sb invoke --model <id>` |
229
+ | 发邮件 | `email` | `aws/send-emails`、`ses/send-batch` | `sb invoke --model <id>` |
230
+ | 发短信 / OTP | `sms` | `prelude/notify-send`、`prelude/verify-send` | `sb invoke --model <id>` |
231
+ | 解析 PDF / DOCX | `document` | `reducto/parse`、`marker` | `sb invoke --model <id>` |
232
+ | 生成落地页 / 移动 UI / 演示文稿 | `ui_generation` | `stitch/generate-desktop`、`gamma/generation` | `sb invoke --model <id>` |
233
+ | 向量嵌入 | `embeddings` | `openai/text-embedding-3-large` | `sb invoke --model <id>` |
234
+ | 加密货币 / 股票 / 外汇 / 天气 / 实用数据 | `utility` | `alphavantage/quote`、`openmeteo/*` 等 | `sb invoke --model <id>` |
235
+ | 不确定能做什么 | (引导) | — | 引用上表,告诉用户能做什么 |
236
+
237
+ > 同一意图可能落到多个类别(如"做个含图的演示" = `image` + `ui_generation`),按用户**主诉求**选最匹配的一类先做。
238
+
239
+ ### 3.2 选择模型挑选策略
240
+
241
+ 按用户偏好挑 `model_id`(`price` / `quality` / `balanced` 三档策略):
242
+
243
+ | 用户表达偏好 | 策略 |
244
+ | --- | --- |
245
+ | "用便宜的 / 快速试一下" | 选**最便宜**的 model(如 image 选 `flux-schnell`、search 选 `tavily/search`) |
246
+ | "用最好的 / 高质量" | 选该类**旗舰** model(如 image 选 `flux-2-max`、video 选 `seedance/seedance-2.0`) |
247
+ | 没说偏好(默认) | 选**平衡**款(如 image 默认 `flux-schnell`、search 默认 `perplexity/search`) |
248
+ | 用户直接指定 model | **直接用**,跳过挑选 |
217
249
 
218
- ### Execute
250
+ **查询 model 清单**:跑 `aigateway sb tools` 拿到完整 catalog,从 stdout envelope 的 `data.categories[].models[]` 中按 `tier` 挑 `model_id`。
219
251
 
220
- ```bash
221
- aigateway create-card --amount <usd> --poll
222
- # Optional: custom merchant
223
- aigateway create-card --amount <usd> --app-id <merchantId> --poll
224
- ```
252
+ **重要**:
253
+ - **不要凭记忆猜 model_id** —— 不同 vendor 命名风格不一(`firecrawl/scrape`、`linkedin-profile`、`replicate/openai/sora-2-pro`)
254
+ - **不要把任务类别字面当 model_id** —— `tts` 不是 model_id,`minimax/speech-01-turbo` 才是
225
255
 
226
- Output template first line:
256
+ ### 3.3 inputsSchema 组装 `inputs` 字段
227
257
 
228
- ```
229
- > Creating Agent Card...
230
- ```
258
+ 从 catalog 中拿所选 model 的 schema(`model.inputsOverride ?? category.defaultInputsSchema`),**把用户原话映射成具体字段值**:
259
+
260
+ - 取 `required` 数组,必填字段从用户表达里拿;拿不到 → 问一次:"调用 `{model_id}` 需要 `{field}`,你的 `{field}` 是?"
261
+ - 取 `properties.{field}.enum` / `default` / `description`,把模糊表达落到精确取值
262
+ - 例:"正方形" → `aspect_ratio: "1:1"`(从 enum 选)
263
+ - 例:"要快" → 选 `tier: "price"` 的 model(这是 3.2 的工作,不是 inputs 字段)
231
264
 
232
- ⚠️ If the session wallet is underfunded, `create-card` may open a WalletConnect QR — **must run in foreground**.
265
+ **绝不**用占位符(`"https://example.com"` / `"..."`)替代用户真实输入。
233
266
 
234
- ### Success
267
+ > 📌 **校验由 `sb invoke` 兜底**:组装完直接调用即可。CLI 在 Phase 4 发出网络请求前会用 catalog 强校验 inputs,错误码 `MISSING_INPUTS` / `INVALID_INPUTS` / `INVALID_MODEL_ID` 会**本地秒级反馈**,不消耗 x402 探测。
235
268
 
236
- `envelope.data`: `{ orderNo, amount, data, paymentResponse, balance: { initial, before, after, charged, topup }, pollResult? }`.
269
+ ---
237
270
 
238
- After fetching details (may take ~30 s), display **verbatim** (emoji, spacing, glyphs `→` / `−` / `+` must match exactly):
271
+ ## Phase 4: x402 支付调用
239
272
 
240
- ```
241
- ✅ Card Issued
242
- 🆔 Order {orderNo}
243
- 💳 Card {cardScheme} •••• {last4}
244
- 🎯 State Active
245
- 💵 Face value ${amount} USD
246
- 🔢 Usage 0 / 1 (single-use)
247
- 🔗 Tx {transaction}
248
- 💸 Top-up {initial} → {before} USDT (+{topup})
249
- 💰 Charged {before} → {after} USDT (−{charged})
273
+ ### 4.1 通用形式
274
+
275
+ ```bash
276
+ aigateway sb invoke \
277
+ --model <model_id> \
278
+ --inputs '<json>' \
279
+ [--output <dir>] \
280
+ [--raw]
250
281
  ```
251
282
 
252
- **Field rules:**
283
+ - `--model` = Phase 3.2 选定的 `model_id`
284
+ - `--inputs` = Phase 3.3 组装好的 JSON(字面量或 `@path/to/file.json`);CLI 在发请求前会用 catalog 内置校验
285
+ - `--output` = 默认按类型放到 `~/aigateway-images/` / `~/aigateway-videos/` / `~/aigateway-audio/`,用户指定时才覆盖
286
+ - `--raw` = 跳过自动下载,直接输出服务端 raw response
253
287
 
254
- - `{cardScheme}` and `••••{last4}` come from `data.data.model` (already sanitized — never show full card number).
255
- - `{transaction}` is `data.paymentResponse.txHash` or `data.data.transaction`. If absent, render the line as `🔗 Tx —`.
256
- - The **`💸 Top-up`** row is **conditional**: render only when `data.balance.topup` is non-null and non-zero (i.e. a lazy top-up actually happened during this call). Otherwise **omit the entire `💸 Top-up` line**.
257
- - The **`💰 Charged`** row is always rendered.
258
- - Use the minus sign character `−` (U+2212) before `{charged}`, not the hyphen `-`. Use `→` (U+2192) for the balance transition arrow.
288
+ 输出第一行(**按字面**):
259
289
 
260
- Always record `orderNo` — only identifier for status queries.
290
+ ```
291
+ > Invoking {model_id}...
292
+ ```
261
293
 
262
- ### Errors
294
+ ⚠️ 钱包余额不足时,`sb invoke` 可能弹 WalletConnect 二维码 —— **必须前台运行**。
263
295
 
264
- | `error.code` | Action |
265
- | --- | --- |
266
- | `AMOUNT_OUT_OF_RANGE` | Show `error.min` / `error.max`, ask again. |
267
- | `INSUFFICIENT_USDT` (after funding) | Tell user funding fell short; ask whether to re-top-up. |
268
- | `PAYMENT_TIMEOUT` / `PAYMENT_REJECTED` | Surface, **do not auto-retry**. |
269
- | `POLL_TIMEOUT` | Card may still be provisioning. Note `error.orderNo`. Use Step 4 (`status`) later. |
270
- | `PAYMENT_FAILED` | Show raw error (`error.data`), suggest retry. |
296
+ ### 4.2 x402 流程(CLI 自动完成,Agent 无需介入)
271
297
 
272
- See [references/create-card.md](references/create-card.md) for full field details.
298
+ 1. 第一次请求 `GET /open/ai/x402/skillBoss/create?body=<urlencoded JSON>&appId=<merchant>` 服务端返回 HTTP 402 + 支付要求(USDT 金额 + payTo + orderNo)
299
+ 2. CLI 检查 USDT 余额 / allowance,不足时自动回落到 Phase 2 充值流程
300
+ 3. EIP-712 签署 USDT 支付 → 携带 `PAYMENT-SIGNATURE` header 重发请求
301
+ 4. 服务端拿到支付凭证 → 代理调用上游 AI 工具 API
302
+ 5. 返回 HTTP 200 + 响应数据(含 `transaction` hash 与下载链接)
303
+ 6. CLI 把二进制(image / video / audio)自动下载到 `--output`
273
304
 
274
305
  ---
275
306
 
276
- ## Step 3b: Create AI Image
277
-
278
- Trigger: user wants to **generate / draw / render an image**.
307
+ ## Phase 5: 渲染响应
279
308
 
280
- ### Execute
309
+ ### 5.1 `sb invoke` 成功 —— `envelope.data` 形状
281
310
 
282
- ```bash
283
- aigateway create-image --prompt "<text>"
284
- # Optional flags:
285
- aigateway create-image --prompt "<text>" --aspect-ratio 1:1 --output-format png --model <id>
311
+ ```json
312
+ {
313
+ "model": "<model_id>",
314
+ "inputs": { /* 回显 */ },
315
+ "transaction": "0x..." | null,
316
+ "downloaded": [
317
+ { "url": "...", "localPath": "...", "format": "png", "width": 1024, "height": 576, "sizeBytes": 412345, "sizeHuman": "402.7 KB" }
318
+ ],
319
+ "raw": { /* 上游完整响应 */ },
320
+ "balance": { "initial": "...", "before": "...", "after": "...", "charged": 0.01, "topup": null }
321
+ }
286
322
  ```
287
323
 
288
- Output template first line:
324
+ - **二进制输出**(image / video / audio)—— `downloaded[]` 非空,Agent 应该把 `localPath` 展示给用户
325
+ - **JSON 输出**(搜索 / 抓取 / 数据 / 转录 / 邮件确认 等)—— 真实结果在 `raw` 下,按 `sb tools` catalog 中该 model 的 `responseFields.jsonPath` 提取
289
326
 
290
- ```
291
- > Generating image...
292
- ```
327
+ ### 5.2 渲染模板(二进制输出)
293
328
 
294
- ### Success
329
+ **按字面**渲染(emoji、空格、字形 `→` / `−` / `+` 严格一致):
295
330
 
296
- `envelope.data`: `{ prompt, transaction, images: [{ url, localPath, format, width, height, sizeHuman }], balance: { initial, before, after, charged, topup } }`.
331
+ ```
332
+ ✅ Done
333
+ 🧩 Powered by Skillboss · {model_id}
334
+ 📁 Path {localPath}
335
+ 🔗 Tx {transaction}
336
+ 💸 Top-up {initial} → {before} USDT (+{topup}) ← topup 为 null 或 "0" 时整行省略
337
+ 💰 Charged {before} → {after} USDT (−{charged})
338
+ ```
297
339
 
298
- Display **verbatim** (emoji, spacing, dash glyphs `→` / `−` / `+` must match exactly):
340
+ 图像额外行:
299
341
 
300
342
  ```
301
- ✅ Generated
302
- 🧩 Powered by Skillboss
303
- 📁 Path {localPath}
304
343
  🎨 Format {FORMAT}
305
344
  📐 Dimensions {width} × {height}
306
345
  💾 Size {sizeHuman}
307
- 🔗 Tx {transaction}
308
- 💸 Top-up {initial} → {before} USDT (+{topup})
309
- 💰 Charged {before} → {after} USDT (−{charged})
310
346
  ```
311
347
 
312
- **Field rules:**
348
+ 视频额外行:
313
349
 
314
- - `{FORMAT}` is `data.outputFormat` uppercased (e.g. `PNG`, `JPEG`, `WEBP`).
315
- - `{width}` / `{height}` / `{sizeHuman}` come from `data.images[0]` (first image only — agent does not list extras unless asked).
316
- - `{transaction}` is `data.transaction` (may be `null` if the server didn't return one; in that case render the line as `🔗 Tx —`).
317
- - The **`💸 Top-up`** line is **conditional**: only render it if `data.balance.topup` is not null and not "0" (i.e. a lazy top-up actually happened during this call). Otherwise **omit the entire `💸 Top-up` line**.
318
- - The **`💰 Charged`** line is always rendered.
319
- - Use the minus sign character `−` (U+2212) before `{charged}`, not the hyphen `-`. Use `→` (U+2192) for the balance transition arrow.
350
+ ```
351
+ ⏱ Duration {duration_seconds}s
352
+ 💾 Size {sizeHuman}
353
+ ```
320
354
 
321
- ### Errors
355
+ 音频额外行:
322
356
 
323
- | `error.code` | Action |
324
- | --- | --- |
325
- | `MISSING_PROMPT` | Ask user for a non-empty prompt. |
326
- | `INSUFFICIENT_USDT` (after funding) | Same as Step 3a. |
327
- | `IMAGE_DOWNLOAD_FAILED` | Mention image was generated but local save failed (URL in raw response). |
328
- | Same set as Step 3a for `PAYMENT_*` / `POLL_*` codes. |
357
+ ```
358
+ 🎵 Duration {duration_seconds}s
359
+ 💾 Size {sizeHuman}
360
+ ```
329
361
 
330
- ---
362
+ 字段规则:
363
+ - `{transaction}` = `data.transaction`;为 `null` 时该行渲染 `🔗 Tx —`
364
+ - `💸 Top-up` 行**条件渲染**:仅当 `data.balance.topup` 非 null 且非 "0" 时;否则**整行省略**
365
+ - `💰 Charged` 行**永远**渲染
366
+ - 减号 `−` (U+2212),箭头 `→` (U+2192)
331
367
 
332
- ## Step 4: Query Status / Wallet / Withdraw
368
+ ### 5.3 渲染模板(仅 JSON 输出)
333
369
 
334
- ### Status (cards only)
370
+ **按字面**渲染:
335
371
 
336
- ```bash
337
- aigateway create-card-status --order-no <orderNo>
338
- aigateway create-card-status --order-no <orderNo> --poll # poll until terminal
372
+ ```
373
+ Done
374
+ 🧩 Powered by Skillboss · {model_id}
375
+ 🔗 Tx {transaction}
376
+ 💸 Top-up {initial} → {before} USDT (+{topup}) ← topup 为 null 或 "0" 时整行省略
377
+ 💰 Charged {before} → {after} USDT (−{charged})
339
378
  ```
340
379
 
341
- `envelope.data` shape mirrors the sanitized server response. Use it to display:
380
+ 然后用 **一两句话**总结实际结果(前 3 条搜索命中、抓取的 markdown 节选、邮件 message-id、社交资料概要等)。**不要倾倒整个 `raw` JSON**,除非用户明确要看。
381
+
382
+ ### 5.4 错误码(统一)
383
+
384
+ | `error.code` | exit | 含义 / Agent 应对 |
385
+ | --- | --- | --- |
386
+ | `WALLET_NOT_CONFIGURED` | 1 | 钱包未初始化;运行 `wallet-init` |
387
+ | `MISSING_MODEL` | 1 | `--model` 必填;提示用户/agent 选 model |
388
+ | `MISSING_INPUTS` | 1 | CLI 兜底校验:必填字段缺失(含 `errors[].field` 列出缺哪些);按 Phase 3.3 schema 补齐 |
389
+ | `INVALID_INPUTS` | 1 | CLI 兜底校验:inputs schema 不通过(含 `errors[].field` + `kind` ∈ enum / type / range);按 schema 修正 |
390
+ | `INVALID_INPUTS_JSON` | 1 | `--inputs` JSON 解析失败;检查引号转义 |
391
+ | `INPUTS_FILE_NOT_FOUND` | 1 | `--inputs @path` 文件不存在;与用户确认路径 |
392
+ | `INVALID_MODEL_ID` | 1 | 服务端拒绝该 model_id;重 Read ref 挑有效的 |
393
+ | `INSUFFICIENT_USDT`(充值后) | 1 | 充值不够;建议增大 `--topup-amount` |
394
+ | `INSUFFICIENT_BNB`(充值后) | 1 | 无 BNB 付 approve gas;运行 `wallet-gas` |
395
+ | `PAYMENT_REJECTED` | 1 | 用户取消签名;**不要自动重试** |
396
+ | `PAYMENT_TIMEOUT` | 2 | 5 分钟窗口过期;**不要自动重试** |
397
+ | `DOWNLOAD_FAILED` | 3 | 服务端返回 URL 但本地下载失败;URL 仍在 `data.downloaded[].url` |
398
+ | `PAYMENT_FAILED` | 3 | 上游 vendor 错误;透传 `error.data`;5xx 重试一次 |
399
+ | `PAYMENT_FETCH_FAILED` | 3 | 拉取支付要求失败;网络问题 |
400
+ | `MODEL_PRICING_NOT_CONFIGURED` | 1 | 服务端未给该 model 配价;告知用户该 model 暂不可用,建议换 model(或联系运维补 catalog) |
401
+ | `INVALID_BODY` | 1 | 服务端拒绝 body 格式;通常是 CLI bug,提交反馈 |
402
+ | `CATALOG_FETCH_FAILED` | 3 | `sb tools` 拉取 catalog 失败;网络问题,stale cache 仍可用 |
403
+ | `TOPUP_REQUIRED` | 1 | 余额不足且非交互模式;按 `error.minTopup` / `error.presets` 引导用户带 `--topup-amount` 重跑 |
404
+ | `NO_MAIN_WALLET` | 1 | `wallet-withdraw` 没指定目标;询问地址,带 `--to <address>` 重试 |
405
+ | `NO_FUNDS` | 1 | `wallet-withdraw` 时无可提现资金 |
406
+ | `UPDATE_APPLIED` | 2 | CLI 已同步升级到新版本,**之前命令未执行**;告知版本切换(`error.from` → `error.to`),**完全照原样重跑**同条命令;**不要**让用户手动升级 |
342
407
 
343
- ```
344
- > Fetching card status...
408
+ ---
345
409
 
346
- Card: {cardScheme} •••• {last4}
347
- State: {Active | Used | Expired | Pending | Failed}
348
- Remaining balance: ${balance} USD
349
- Usage: {used} / {total} (single-use)
350
- ```
410
+ ## Phase 6: 钱包管理(按需)
351
411
 
352
- ### Wallet (balance check)
412
+ ### 余额查询
353
413
 
354
414
  ```bash
355
415
  aigateway wallet-balance
356
416
  ```
357
417
 
358
- `envelope.data`: `{ address, usdt, bnb, mainWallet? }`.
418
+ `envelope.data`:`{ address, usdt, bnb, mainWallet? }`
359
419
 
360
- ### Withdraw
420
+ ### 提现
361
421
 
362
422
  ```bash
363
- aigateway wallet-withdraw # all USDT → mainWallet
364
- aigateway wallet-withdraw --amount <usdt> # specific amount
365
- aigateway wallet-withdraw --to 0x... # specific destination
423
+ aigateway wallet-withdraw # 全部 USDT → mainWallet
424
+ aigateway wallet-withdraw --amount <usdt> # 指定金额
425
+ aigateway wallet-withdraw --to 0x... # 指定目标
366
426
  ```
367
427
 
368
- Display **verbatim**:
428
+ **按字面**展示:
369
429
 
370
430
  ```
371
431
  > Reclaiming funds...
372
432
 
373
- From: 0x0...{session_last4}
374
- To: main wallet (0x0...{main_last4})
433
+ From: {session前3}...{session_last4}
434
+ To: main wallet ({main前3}...{main_last4})
375
435
 
376
436
  Amount: {amount} USDT
377
437
  Status: completed
378
438
  ```
379
439
 
380
- The literal "main wallet" label is a spec requirement — do not omit.
381
-
382
- ### Edge cases
440
+ "main wallet" 字面标签必须保留。
383
441
 
384
- | Scenario | Action |
442
+ | 边界 `error.code` | 动作 |
385
443
  | --- | --- |
386
- | `error.code = NO_MAIN_WALLET` | Ask user for destination, rerun with `--to <address>`. |
387
- | `error.code = INSUFFICIENT_BNB` (in withdraw) | Run `aigateway wallet-gas` first. |
388
- | `error.code = NO_FUNDS` | Inform user nothing to withdraw. |
444
+ | `NO_MAIN_WALLET` | 询问目标地址,带 `--to <address>` 重试 |
445
+ | `INSUFFICIENT_BNB`(提现时) | 先运行 `aigateway wallet-gas` |
446
+ | `NO_FUNDS` | 告诉用户没有可提现资金 |
447
+
448
+ ### 补 BNB
449
+
450
+ ```bash
451
+ aigateway wallet-gas [--amount <bnb>]
452
+ ```
453
+
454
+ 用于 `wallet-withdraw` 需要 gas 时。
455
+
456
+ ---
457
+
458
+ ## 命令总览
459
+
460
+ ```bash
461
+ # 钱包管理(aigateway 独有)
462
+ aigateway wallet-init # 预检 / 创建钱包并报告 needsTopup
463
+ aigateway wallet-topup [--amount <usdt>] # WalletConnect 充值 + 首次 approve
464
+ aigateway wallet-balance # 重新查余额
465
+ aigateway wallet-gas [--amount <bnb>] # 给 session-key 补 BNB
466
+ aigateway wallet-withdraw [--to <addr>] [--amount <usdt>] # 提现
467
+
468
+ # 工具 catalog(从服务端实时获取)
469
+ aigateway sb tools # 实时拉取 catalog
470
+
471
+ # x402 付费调用统一入口
472
+ aigateway sb invoke --model <id> --inputs '<json>' [--output <dir>] [--raw]
473
+
474
+ # 其它
475
+ aigateway clean # 卸载 skill、清缓存
476
+ ```
477
+
478
+ 所有命令都接受 `--app-id <id>`(商户 ID;默认 `TEST000001`,用户没明确指定时**不要主动询问**)。配置位于 `~/.aigateway/config.json`(权限 0o600)。
479
+
480
+ **永远不要向用户索取私钥** —— 本地 session-key 自动生成。
389
481
 
390
482
  ---
391
483
 
392
- ## Decision Routing
484
+ ## 输出信封(Output Envelope)
485
+
486
+ 每个 CLI 命令向 **stdout** 输出**一行 JSON** —— 即 *envelope*。进度日志走 stderr,不参与控制流。
487
+
488
+ - 成功:`{ "ok": true, "command": "...", "version": "...", "data": { /* payload */ } }`
489
+ - 失败:`{ "ok": false, "command": "...", "version": "...", "error": { "code": "...", "message": "...", ... } }`
490
+
491
+ 字段名(`ready`、`model`、`downloaded` 等)位于成功的 `envelope.data` 下或失败的 `envelope.error` 下。**匹配 `error.code` 而非 `error.message`。**
492
+
493
+ 完整 schema:[docs/output-schema.md](../../docs/output-schema.md)、[docs/exit-codes.md](../../docs/exit-codes.md)。
393
494
 
394
- | User Intent | Entry Command |
495
+ ---
496
+
497
+ ## 决策路由(Decision Routing 总表)
498
+
499
+ | 用户意图 | 入口命令 |
395
500
  | --- | --- |
396
- | First entry / uncertain state | `wallet-init` (then `wallet-topup` if balance < 1 USDT) |
397
- | Top up / load wallet / fund | `wallet-topup --amount <n>` |
398
- | Create virtual card | `create-card --amount <n> --poll` |
399
- | Generate AI image | `create-image --prompt "<text>"` |
400
- | Check card status | `create-card-status --order-no <n>` |
401
- | Check balance | `wallet` |
402
- | Withdraw funds | `withdraw [--to <addr>] [--amount <n>]` |
403
- | Top up BNB for withdraw | `gas [--amount <bnb>]` |
501
+ | 首次进入 / 状态不明 | `wallet-init`(如 needsTopup `wallet-topup`) |
502
+ | 充值 / 加载钱包 | `wallet-topup --amount <n>` |
503
+ | 任意 x402 付费工具(图像 / 视频 / 音频 / 搜索 / 抓取 / 邮件 / 短信 / 文档 / UI / 嵌入 / 金融 / 实用 …) | **先 `aigateway sb tools` 拿 catalog**,再 `sb invoke --model <id> --inputs '<json>'` |
504
+ | 查余额 | `wallet-balance` |
505
+ | 提现 | `wallet-withdraw [--to <addr>] [--amount <n>]` |
506
+ | BNB(用于提现) | `wallet-gas [--amount <bnb>]` |
404
507
 
405
508
  ---
406
509
 
407
- ## Hard Rules (Global)
510
+ ## 硬性规则(全局)
408
511
 
409
- - **Never** ask for a private key — the local session key is auto-generated.
410
- - **Never** display full card numbers, CVV, or expiry. The CLI already redacts these to `•••• 1234`.
411
- - **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.
412
- - **Never** auto-retry `PAYMENT_REJECTED` / `PAYMENT_TIMEOUT`. Ask the user.
413
- - **Never** poll `status` more than 42 times. Stop on timeout, prompt user to note `orderNo`.
414
- - **Never** fabricate `amountLimits`. Always use `min/max` from `wallet-init`.
415
- - **Match `error.code`, not `error.message`.** Messages may change between versions.
512
+ - **永远不要**向用户索取私钥 —— session-key 自动生成
513
+ - **永远不要**后台运行任何会弹 WalletConnect 二维码的命令(`wallet-topup` / `wallet-gas` / `sb invoke` 当钱包不足时)
514
+ - **永远不要**自动重试 `PAYMENT_REJECTED` / `PAYMENT_TIMEOUT` —— 问用户
515
+ - **永远不要**伪造 `presets` / `minTopup` —— `wallet-init` 返回的
516
+ - **永远不要**塞占位符(`"https://example.com"` / `"..."`)替代用户真实输入
517
+ - **匹配 `error.code`,不匹配 `error.message`** —— 文本随版本变
518
+ - **`error.code === "UPDATE_APPLIED"` 时**:CLI 已同步升级,之前命令未执行;告知版本切换(`error.from` `error.to`),**完全照原样重跑**同条命令;**不要**让用户手动升级
416
519
 
417
520
  ---
418
521
 
419
- ## Copy Constraints (Verbatim Lines)
522
+ ## 必须按字面输出的字符串(Copy Constraints
420
523
 
421
- The following first-line / key-phrase strings must be **exactly reproduced** — no rewording, no translation, no extra decorations:
524
+ 以下首行 / 关键短语必须 **逐字符复现** —— 不改写、不翻译、不加装饰:
422
525
 
423
- | Step | Required first line |
526
+ | 阶段 | 必须按字面的行 |
424
527
  | --- | --- |
425
- | Pre-check | `> Pre-check in progress...` |
426
- | Top up | `> Topping up wallet...` |
427
- | Create card | `> Creating Agent Card...` |
428
- | Card success header | `✅ Card Issued` |
429
- | Card Order row | `🆔 Order {orderNo}` |
430
- | Card scheme row | `💳 Card {cardScheme} •••• {last4}` |
431
- | Card State row | `🎯 State Active` |
432
- | Card Face value row | `💵 Face value ${amount} USD` |
433
- | Card Usage row | `🔢 Usage 0 / 1 (single-use)` |
434
- | Card Tx row | `🔗 Tx {transaction}` |
435
- | Card Top-up row (conditional) | `💸 Top-up {initial} {before} USDT (+{topup})` |
436
- | Card Charged row | `💰 Charged {before} → {after} USDT (−{charged})` |
437
- | Create image | `> Generating image...` |
438
- | Fetch details | `> Fetching card details, please wait...` |
439
- | Query status | `> Fetching card status...` |
440
- | Withdraw | `> Reclaiming funds...` |
441
- | Withdraw target line | `To: main wallet (0x0...{last4})` |
442
- | Withdraw status line | `Status: completed` |
443
- | Image success header | `✅ Generated` |
444
- | Image success row 2 | `🧩 Powered by Skillboss` |
445
- | Image Path row | `📁 Path {localPath}` |
446
- | Image Format row | `🎨 Format {FORMAT}` |
447
- | Image Dimensions row | `📐 Dimensions {width} × {height}` |
448
- | Image Size row | `💾 Size {sizeHuman}` |
449
- | Image Tx row | `🔗 Tx {transaction}` |
450
- | Image Top-up row (conditional) | `💸 Top-up {initial} → {before} USDT (+{topup})` |
451
- | Image Charged row | `💰 Charged {before} → {after} USDT (−{charged})` |
452
- | Wallet prepared header | `✅ Wallet prepared` |
453
-
454
- Address rendering: always `0x0...{last4}` (first 3 + ellipsis + last 4 chars).
455
-
456
- ### Wording Discipline: "wallet top-up" vs "card face value"
457
-
458
- These two amounts are **different concepts** asked at **different steps**. Translators (to any non-English language) must keep them **lexically distinct** so users do not conflate them:
459
-
460
- | Step | Concept | Required English wording | Forbidden mix-ups |
461
- | --- | --- | --- | --- |
462
- | Step 2 (`wallet-topup`) | USDT into the **session wallet** | "load USDT **into your session wallet**" | Never say "load onto the card" — that's Step 3a |
463
- | Step 3a (`create-card`) | USD **face value** loaded onto a new card | "card **face value**" / "issue a card with how much" | Never use the same verb you used for *wallet top-up* without a strong "card" qualifier |
528
+ | Opening Line | `> Let me check the environment first.` |
529
+ | Phase 1 第一行 | `> Pre-check in progress...` |
530
+ | Phase 1 安装提示 | `> Installing aigateway...` |
531
+ | Phase 2 第一行 | `> Topping up wallet...` |
532
+ | Phase 2 成功 header | `✅ Wallet prepared` |
533
+ | Phase 4.1 sb invoke 第一行 | `> Invoking {model_id}...` |
534
+ | Phase 5.2 通用成功 header | `✅ Done` |
535
+ | Phase 5.2 Powered | `🧩 Powered by Skillboss · {model_id}` |
536
+ | Phase 5.2 Path | `📁 Path {localPath}` |
537
+ | Phase 5.2 Format | `🎨 Format {FORMAT}` |
538
+ | Phase 5.2 Dimensions | `📐 Dimensions {width} × {height}` |
539
+ | Phase 5.2 Size | `💾 Size {sizeHuman}` |
540
+ | Phase 5.2 Tx 行 | `🔗 Tx {transaction}` |
541
+ | Phase 5.2 视频 Duration | `⏱ Duration {duration_seconds}s` |
542
+ | Phase 5.2 音频 Duration | `🎵 Duration {duration_seconds}s` |
543
+ | Phase 5.2 Top-up 行(条件) | `💸 Top-up {initial} {before} USDT (+{topup})` |
544
+ | Phase 5.2 Charged | `💰 Charged {before} {after} USDT ({charged})` |
545
+ | Phase 6 提现第一行 | `> Reclaiming funds...` |
546
+ | Phase 6 提现目标行 | `To: main wallet ({main前3}...{main_last4})` |
547
+ | Phase 6 提现状态行 | `Status: completed` |
548
+
549
+ **地址渲染规则**:占位符 `{addr前3}` / `{session前3}` / `{main前3}` 必须替换为**地址真实的前 3 字符**(不要写死 `0x0`);`{last4}` 等是后 4 字符。例如:
550
+ - 地址 `0xAbC123…DEF7` `0xA...DEF7`
551
+ - 地址 `0x000000…4567` `0x0...4567`
552
+ - 地址 `0xc0FFee…BEEF` `0xc...BEEF`
553
+
554
+ ---
555
+
556
+ ## 常见 Agent 错误(Anti-patterns)
557
+
558
+ > 完整 `error.code` 列表与处置见 Phase 5.4。下面只是 Agent 容易踩的坑:
559
+
560
+ - 凭记忆猜 `model_id` —— 一定要先跑 `aigateway sb tools` 拿当前 catalog
561
+ - 把任务类别名当 model_id(如 `--model tts`)—— 必须用具体 vendor/model(如 `--model minimax/speech-01-turbo`)
562
+ - 给依赖 `image_url` / `file_url` 的 model 传本地路径 —— 必须是公开可访问的 URL
563
+ - 用占位符替代用户真实输入 —— 缺字段必须问用户
564
+
565
+ ---
464
566
 
465
- **Rule of thumb**: if a question is about the *wallet* (Step 2), the target noun must mean *session wallet*. If a question is about a *card amount* (Step 3a), prefer wording that means *face value* / *the amount loaded onto a new card*. The verb for one concept must never be reused for the other concept in the same language.
567
+ **一个 session 钱包。一份 x402 协议。200+ 个工具。零摩擦付费。**