@aeon-ai-pay/aigateway 0.1.4 → 0.1.6

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.4"
29
+ version: "0.2.0"
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,337 +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`)
158
-
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.
162
+ ## Phase 2: 钱包充值(条件触发)
160
163
 
161
- ### Amount selection
164
+ 触发:Phase 1 报 `needsTopup: true`(原因可能是 `first_time` / `low_balance` / `no_approve`),**或**用户明确要求充值。
162
165
 
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.
166
+ ### 金额选择
164
167
 
165
- - Presets: **5 / 10 / 20 / 50 USDT**. Custom amounts must be ≥ 5 USDT.
166
- - Ask the user **before** running the command. **Make "wallet" / "钱包" explicit in the question:**
168
+ 这是**给 session 钱包**充值。措辞必须明确指向钱包(与"调用费用"区分):
167
169
 
168
- > How much USDT would you like to load **into your session wallet**? (presets: 5 / 10 / 20 / 50, or any custom amount ≥ 5)
170
+ - 预设:**5 / 10 / 20 / 50 USDT**。自定义金额 ≥ 5 USDT
171
+ - 命令执行**前**询问用户,问句里"钱包"必须显式出现:
169
172
 
170
- (Suggested Chinese phrasing: "请问要往**本地钱包**充值多少 USDT?预设 5 / 10 / 20 / 50,或自定义 ≥ 5。")
173
+ > 你想给 **session 钱包** 充值多少 USDT?(预设:5 / 10 / 20 / 50,或任意自定义 ≥ 5
171
174
 
172
- - Once the user picks an amount, run:
175
+ - 选定后执行:
173
176
 
174
177
  ```bash
175
- aigateway wallet-topup --amount <n> # always pass --amount in agent context
178
+ aigateway wallet-topup --amount <n> # agent 上下文里必须总是带 --amount
176
179
  ```
177
180
 
178
- ### Output template
181
+ 输出第一行(**按字面**):
179
182
 
180
183
  ```
181
184
  > Topping up wallet...
182
185
  ```
183
186
 
184
- On success, surface:
187
+ 成功展示:
185
188
 
186
189
  ```
187
190
  ✅ Wallet prepared
188
- Address: 0x0...{last4}
191
+ Address: {addr前3}...{last4}
189
192
  Balance: {usdt} USDT, {bnb} BNB
190
193
  Approve: {approveTx truncated or "already approved"}
191
194
  ```
192
195
 
193
- ### Error cases
196
+ ⚠️ `wallet-topup` 会弹 WalletConnect 二维码 —— **必须前台同步运行**,永远不要 `run_in_background: true`。
194
197
 
195
- | `error.code` | Action |
196
- | --- | --- |
197
- | `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>`. |
198
- | `TOPUP_AMOUNT_TOO_SMALL` | Show `error.minTopup`, ask the user for a larger amount. |
199
- | `PAYMENT_REJECTED` | User cancelled in wallet. **Do not auto-retry**; ask user. |
200
- | `PAYMENT_TIMEOUT` | 5-minute WalletConnect window expired. **Do not auto-retry**; ask user. |
201
- | `INSUFFICIENT_BNB` (post-funding) | Run `aigateway wallet-gas` (interactive) to add BNB, then retry. |
202
- | `APPROVE_FAILED` | On-chain approve failed; surface message, suggest retry. |
198
+ ### 错误情况
203
199
 
204
- ⚠️ `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 失败;透传错误,建议重试 |
205
207
 
206
208
  ---
207
209
 
208
- ## Step 3a: Create Virtual Card
210
+ ## Phase 3: 识别任务类别 + 选择模型 ⭐
209
211
 
210
- 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` 字段。
211
213
 
212
- ### Amount confirmation
214
+ > Inputs 的**最终校验**由 `sb invoke` 在 Phase 4 内置兜底(必填 / 枚举 / 类型 / 范围),所以本阶段重点是**翻译**而非"校验"。
213
215
 
214
- 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 user did not specify, ask once — **use the word "card face value" / "面额", never "充值" / "top up"** to avoid confusing it with the `wallet-topup` step:
216
+ ### 3.1 识别任务类别
215
217
 
216
- > What card face value would you like to issue? Allowed range: ${min}~${max} USD.
218
+ 把用户意图归到下表中的一行:
217
219
 
218
- (Suggested Chinese phrasing: "请问要开多少美元的卡?允许范围 $${min} ~ $${max}。"
219
- **Do not** translate this as "充值多少美元" that wording belongs to `wallet-topup` and confuses users.)
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
+ | 不确定能做什么 | (引导) | — | 引用上表,告诉用户能做什么 |
220
236
 
221
- Once specified, **execute immediately**.
237
+ > 同一意图可能落到多个类别(如"做个含图的演示" = `image` + `ui_generation`),按用户**主诉求**选最匹配的一类先做。
222
238
 
223
- ### Execute
239
+ ### 3.2 选择模型挑选策略
224
240
 
225
- ```bash
226
- aigateway create-card --amount <usd> --poll
227
- # Optional: custom merchant
228
- aigateway create-card --amount <usd> --app-id <merchantId> --poll
229
- ```
241
+ 按用户偏好挑 `model_id`(`price` / `quality` / `balanced` 三档策略):
230
242
 
231
- Output template first line:
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 | **直接用**,跳过挑选 |
232
249
 
233
- ```
234
- > Creating Agent Card...
235
- ```
250
+ **查询 model 清单**:跑 `aigateway sb tools` 拿到完整 catalog,从 stdout envelope 的 `data.categories[].models[]` 中按 `tier` 挑 `model_id`。
236
251
 
237
- ⚠️ If the session wallet is underfunded, `create-card` may open a WalletConnect QR — **must run in foreground**.
252
+ **重要**:
253
+ - **不要凭记忆猜 model_id** —— 不同 vendor 命名风格不一(`firecrawl/scrape`、`linkedin-profile`、`replicate/openai/sora-2-pro`)
254
+ - **不要把任务类别字面当 model_id** —— `tts` 不是 model_id,`minimax/speech-01-turbo` 才是
238
255
 
239
- ### Success
256
+ ### 3.3 用 inputsSchema 组装 `inputs` 字段
240
257
 
241
- `envelope.data`: `{ orderNo, amount, data, paymentResponse, balance: { initial, before, after, charged, topup }, pollResult? }`.
258
+ catalog 中拿所选 model schema(`model.inputsOverride ?? category.defaultInputsSchema`),**把用户原话映射成具体字段值**:
242
259
 
243
- After fetching details (may take ~30 s), display **verbatim** (emoji, spacing, glyphs `→` / `−` / `+` must match exactly):
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 字段)
244
264
 
245
- ```
246
- ✅ Card Issued
247
- 🆔 Order {orderNo}
248
- 💳 Card {cardScheme} •••• {last4}
249
- 🎯 State Active
250
- 💵 Face value ${amount} USD
251
- 🔢 Usage 0 / 1 (single-use)
252
- 🔗 Tx {transaction}
253
- 💸 Top-up {initial} → {before} USDT (+{topup})
254
- 💰 Charged {before} → {after} USDT (−{charged})
255
- ```
265
+ **绝不**用占位符(`"https://example.com"` / `"..."`)替代用户真实输入。
256
266
 
257
- **Field rules:**
267
+ > 📌 **校验由 `sb invoke` 兜底**:组装完直接调用即可。CLI 在 Phase 4 发出网络请求前会用 catalog 强校验 inputs,错误码 `MISSING_INPUTS` / `INVALID_INPUTS` / `INVALID_MODEL_ID` 会**本地秒级反馈**,不消耗 x402 探测。
258
268
 
259
- - `{cardScheme}` and `••••{last4}` come from `data.data.model` (already sanitized — never show full card number).
260
- - `{transaction}` is `data.paymentResponse.txHash` or `data.data.transaction`. If absent, render the line as `🔗 Tx —`.
261
- - 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**.
262
- - The **`💰 Charged`** row is always rendered.
263
- - Use the minus sign character `−` (U+2212) before `{charged}`, not the hyphen `-`. Use `→` (U+2192) for the balance transition arrow.
269
+ ---
264
270
 
265
- Always record `orderNo` only identifier for status queries.
271
+ ## Phase 4: x402 支付调用
266
272
 
267
- ### Errors
273
+ ### 4.1 通用形式
268
274
 
269
- | `error.code` | Action |
270
- | --- | --- |
271
- | `AMOUNT_OUT_OF_RANGE` | Show `error.min` / `error.max`, ask again. |
272
- | `INSUFFICIENT_USDT` (after funding) | Tell user funding fell short; ask whether to re-top-up. |
273
- | `PAYMENT_TIMEOUT` / `PAYMENT_REJECTED` | Surface, **do not auto-retry**. |
274
- | `POLL_TIMEOUT` | Card may still be provisioning. Note `error.orderNo`. Use Step 4 (`status`) later. |
275
- | `PAYMENT_FAILED` | Show raw error (`error.data`), suggest retry. |
275
+ ```bash
276
+ aigateway sb invoke \
277
+ --model <model_id> \
278
+ --inputs '<json>' \
279
+ [--output <dir>] \
280
+ [--raw]
281
+ ```
276
282
 
277
- See [references/create-card.md](references/create-card.md) for full field details.
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
278
287
 
279
- ---
288
+ 输出第一行(**按字面**):
289
+
290
+ ```
291
+ > Invoking {model_id}...
292
+ ```
280
293
 
281
- ## Step 3b: Create AI Image
294
+ ⚠️ 钱包余额不足时,`sb invoke` 可能弹 WalletConnect 二维码 —— **必须前台运行**。
282
295
 
283
- Trigger: user wants to **generate / draw / render an image**.
296
+ ### 4.2 x402 流程(CLI 自动完成,Agent 无需介入)
284
297
 
285
- ### Execute
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`
286
304
 
287
- ```bash
288
- aigateway create-image --prompt "<text>"
289
- # Optional flags:
290
- aigateway create-image --prompt "<text>" --aspect-ratio 1:1 --output-format png --model <id>
291
- ```
305
+ ---
292
306
 
293
- Output template first line:
307
+ ## Phase 5: 渲染响应
294
308
 
295
- ```
296
- > Generating image...
309
+ ### 5.1 `sb invoke` 成功 —— `envelope.data` 形状
310
+
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
+ }
297
322
  ```
298
323
 
299
- ### Success
324
+ - **二进制输出**(image / video / audio)—— `downloaded[]` 非空,Agent 应该把 `localPath` 展示给用户
325
+ - **JSON 输出**(搜索 / 抓取 / 数据 / 转录 / 邮件确认 等)—— 真实结果在 `raw` 下,按 `sb tools` catalog 中该 model 的 `responseFields.jsonPath` 提取
300
326
 
301
- `envelope.data`: `{ prompt, transaction, images: [{ url, localPath, format, width, height, sizeHuman }], balance: { initial, before, after, charged, topup } }`.
327
+ ### 5.2 渲染模板(二进制输出)
302
328
 
303
- Display **verbatim** (emoji, spacing, dash glyphs `→` / `−` / `+` must match exactly):
329
+ **按字面**渲染(emoji、空格、字形 `→` / `−` / `+` 严格一致):
304
330
 
305
331
  ```
306
- Generated
307
- 🧩 Powered by Skillboss
332
+ Done
333
+ 🧩 Powered by Skillboss · {model_id}
308
334
  📁 Path {localPath}
335
+ 🔗 Tx {transaction}
336
+ 💸 Top-up {initial} → {before} USDT (+{topup}) ← topup 为 null 或 "0" 时整行省略
337
+ 💰 Charged {before} → {after} USDT (−{charged})
338
+ ```
339
+
340
+ 图像额外行:
341
+
342
+ ```
309
343
  🎨 Format {FORMAT}
310
344
  📐 Dimensions {width} × {height}
311
345
  💾 Size {sizeHuman}
312
- 🔗 Tx {transaction}
313
- 💸 Top-up {initial} → {before} USDT (+{topup})
314
- 💰 Charged {before} → {after} USDT (−{charged})
315
346
  ```
316
347
 
317
- **Field rules:**
348
+ 视频额外行:
318
349
 
319
- - `{FORMAT}` is `data.outputFormat` uppercased (e.g. `PNG`, `JPEG`, `WEBP`).
320
- - `{width}` / `{height}` / `{sizeHuman}` come from `data.images[0]` (first image only — agent does not list extras unless asked).
321
- - `{transaction}` is `data.transaction` (may be `null` if the server didn't return one; in that case render the line as `🔗 Tx —`).
322
- - 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**.
323
- - The **`💰 Charged`** line is always rendered.
324
- - 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
+ ```
325
354
 
326
- ### Errors
355
+ 音频额外行:
327
356
 
328
- | `error.code` | Action |
329
- | --- | --- |
330
- | `MISSING_PROMPT` | Ask user for a non-empty prompt. |
331
- | `INSUFFICIENT_USDT` (after funding) | Same as Step 3a. |
332
- | `IMAGE_DOWNLOAD_FAILED` | Mention image was generated but local save failed (URL in raw response). |
333
- | Same set as Step 3a for `PAYMENT_*` / `POLL_*` codes. |
357
+ ```
358
+ 🎵 Duration {duration_seconds}s
359
+ 💾 Size {sizeHuman}
360
+ ```
334
361
 
335
- ---
362
+ 字段规则:
363
+ - `{transaction}` = `data.transaction`;为 `null` 时该行渲染 `🔗 Tx —`
364
+ - `💸 Top-up` 行**条件渲染**:仅当 `data.balance.topup` 非 null 且非 "0" 时;否则**整行省略**
365
+ - `💰 Charged` 行**永远**渲染
366
+ - 减号 `−` (U+2212),箭头 `→` (U+2192)
336
367
 
337
- ## Step 4: Query Status / Wallet / Withdraw
368
+ ### 5.3 渲染模板(仅 JSON 输出)
338
369
 
339
- ### Status (cards only)
370
+ **按字面**渲染:
340
371
 
341
- ```bash
342
- aigateway create-card-status --order-no <orderNo>
343
- 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})
344
378
  ```
345
379
 
346
- `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`),**完全照原样重跑**同条命令;**不要**让用户手动升级 |
347
407
 
348
- ```
349
- > Fetching card status...
408
+ ---
350
409
 
351
- Card: {cardScheme} •••• {last4}
352
- State: {Active | Used | Expired | Pending | Failed}
353
- Remaining balance: ${balance} USD
354
- Usage: {used} / {total} (single-use)
355
- ```
410
+ ## Phase 6: 钱包管理(按需)
356
411
 
357
- ### Wallet (balance check)
412
+ ### 余额查询
358
413
 
359
414
  ```bash
360
415
  aigateway wallet-balance
361
416
  ```
362
417
 
363
- `envelope.data`: `{ address, usdt, bnb, mainWallet? }`.
418
+ `envelope.data`:`{ address, usdt, bnb, mainWallet? }`
364
419
 
365
- ### Withdraw
420
+ ### 提现
366
421
 
367
422
  ```bash
368
- aigateway wallet-withdraw # all USDT → mainWallet
369
- aigateway wallet-withdraw --amount <usdt> # specific amount
370
- 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... # 指定目标
371
426
  ```
372
427
 
373
- Display **verbatim**:
428
+ **按字面**展示:
374
429
 
375
430
  ```
376
431
  > Reclaiming funds...
377
432
 
378
- From: 0x0...{session_last4}
379
- To: main wallet (0x0...{main_last4})
433
+ From: {session前3}...{session_last4}
434
+ To: main wallet ({main前3}...{main_last4})
380
435
 
381
436
  Amount: {amount} USDT
382
437
  Status: completed
383
438
  ```
384
439
 
385
- The literal "main wallet" label is a spec requirement — do not omit.
440
+ "main wallet" 字面标签必须保留。
386
441
 
387
- ### Edge cases
388
-
389
- | Scenario | Action |
442
+ | 边界 `error.code` | 动作 |
390
443
  | --- | --- |
391
- | `error.code = NO_MAIN_WALLET` | Ask user for destination, rerun with `--to <address>`. |
392
- | `error.code = INSUFFICIENT_BNB` (in withdraw) | Run `aigateway wallet-gas` first. |
393
- | `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 时。
394
455
 
395
456
  ---
396
457
 
397
- ## Decision Routing
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
398
470
 
399
- | User Intent | Entry Command |
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 自动生成。
481
+
482
+ ---
483
+
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)。
494
+
495
+ ---
496
+
497
+ ## 决策路由(Decision Routing 总表)
498
+
499
+ | 用户意图 | 入口命令 |
400
500
  | --- | --- |
401
- | First entry / uncertain state | `wallet-init` (then `wallet-topup` if balance < 1 USDT) |
402
- | Top up / load wallet / fund | `wallet-topup --amount <n>` |
403
- | Create virtual card | `create-card --amount <n> --poll` |
404
- | Generate AI image | `create-image --prompt "<text>"` |
405
- | Check card status | `create-card-status --order-no <n>` |
406
- | Check balance | `wallet` |
407
- | Withdraw funds | `withdraw [--to <addr>] [--amount <n>]` |
408
- | 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>]` |
409
507
 
410
508
  ---
411
509
 
412
- ## Hard Rules (Global)
510
+ ## 硬性规则(全局)
413
511
 
414
- - **Never** ask for a private key — the local session key is auto-generated.
415
- - **Never** display full card numbers, CVV, or expiry. The CLI already redacts these to `•••• 1234`.
416
- - **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.
417
- - **Never** auto-retry `PAYMENT_REJECTED` / `PAYMENT_TIMEOUT`. Ask the user.
418
- - **Never** poll `status` more than 42 times. Stop on timeout, prompt user to note `orderNo`.
419
- - **Never** fabricate `amountLimits`. Always use `min/max` from `wallet-init`.
420
- - **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`),**完全照原样重跑**同条命令;**不要**让用户手动升级
421
519
 
422
520
  ---
423
521
 
424
- ## Copy Constraints (Verbatim Lines)
522
+ ## 必须按字面输出的字符串(Copy Constraints
425
523
 
426
- The following first-line / key-phrase strings must be **exactly reproduced** — no rewording, no translation, no extra decorations:
524
+ 以下首行 / 关键短语必须 **逐字符复现** —— 不改写、不翻译、不加装饰:
427
525
 
428
- | Step | Required first line |
526
+ | 阶段 | 必须按字面的行 |
429
527
  | --- | --- |
430
- | Pre-check | `> Pre-check in progress...` |
431
- | Top up | `> Topping up wallet...` |
432
- | Create card | `> Creating Agent Card...` |
433
- | Card success header | `✅ Card Issued` |
434
- | Card Order row | `🆔 Order {orderNo}` |
435
- | Card scheme row | `💳 Card {cardScheme} •••• {last4}` |
436
- | Card State row | `🎯 State Active` |
437
- | Card Face value row | `💵 Face value ${amount} USD` |
438
- | Card Usage row | `🔢 Usage 0 / 1 (single-use)` |
439
- | Card Tx row | `🔗 Tx {transaction}` |
440
- | Card Top-up row (conditional) | `💸 Top-up {initial} {before} USDT (+{topup})` |
441
- | Card Charged row | `💰 Charged {before} → {after} USDT (−{charged})` |
442
- | Create image | `> Generating image...` |
443
- | Fetch details | `> Fetching card details, please wait...` |
444
- | Query status | `> Fetching card status...` |
445
- | Withdraw | `> Reclaiming funds...` |
446
- | Withdraw target line | `To: main wallet (0x0...{last4})` |
447
- | Withdraw status line | `Status: completed` |
448
- | Image success header | `✅ Generated` |
449
- | Image success row 2 | `🧩 Powered by Skillboss` |
450
- | Image Path row | `📁 Path {localPath}` |
451
- | Image Format row | `🎨 Format {FORMAT}` |
452
- | Image Dimensions row | `📐 Dimensions {width} × {height}` |
453
- | Image Size row | `💾 Size {sizeHuman}` |
454
- | Image Tx row | `🔗 Tx {transaction}` |
455
- | Image Top-up row (conditional) | `💸 Top-up {initial} → {before} USDT (+{topup})` |
456
- | Image Charged row | `💰 Charged {before} → {after} USDT (−{charged})` |
457
- | Wallet prepared header | `✅ Wallet prepared` |
458
-
459
- Address rendering: always `0x0...{last4}` (first 3 + ellipsis + last 4 chars).
460
-
461
- ### Wording Discipline: "wallet top-up" vs "card face value"
462
-
463
- These two amounts are **different concepts** asked at **different steps**. Translators must keep them lexically distinct so users don't conflate them:
464
-
465
- | Step | Concept | Required wording (English) | Suggested Chinese | Forbidden mix-ups |
466
- | --- | --- | --- | --- | --- |
467
- | Step 2 (`wallet-topup`) | USDT into the **session wallet** | "load USDT **into your session wallet**" | "往**本地钱包**充值 USDT" | Don't say "充值到卡里" / "load onto the card" — that's Step 3a |
468
- | Step 3a (`create-card`) | USD **face value** loaded onto a new card | "card **face value**" / "issue a card with how much" | "**开多少美元的卡** / 卡的面额" | Don't say "充值多少" / "充值到卡" without strong "card" qualifier — confuses with Step 2 |
469
-
470
- **Rule of thumb**: if the agent's question contains the word "充值" (top up), the noun *must* be "钱包" (wallet); if the question is about a card's amount, prefer "**面额**" or "**开多少美元的卡**", never "充值".
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
+ ---
566
+
567
+ **一个 session 钱包。一份 x402 协议。200+ 个工具。零摩擦付费。**