@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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.6] — 2026-05-19
11
+
12
+ ### Changed
13
+ - **`update-check.mjs` is now synchronous / foreground.** A newer published
14
+ version triggers `npm install -g` + `scripts/postinstall.mjs` *inline*,
15
+ with `npm`'s own progress streamed to stderr. After the upgrade the CLI
16
+ emits an envelope with `error.code === "UPDATE_APPLIED"` (and `error.from`
17
+ / `error.to`) and exits with code 2 **without running the original
18
+ command**. The caller / agent reruns the command on the new CLI + new
19
+ SKILL.md.
20
+ - Replaces the previous detached-background upgrade, which could leave the
21
+ global package half-replaced (`bin/cli.mjs` already updated while
22
+ `src/commands/*` still old → `ERR_MODULE_NOT_FOUND` on the very next
23
+ invocation) and could fail silently (e.g. `ENOTEMPTY` on Windows / nvm).
24
+
25
+ ### Added
26
+ - New error code `UPDATE_APPLIED` (exit 2) emitted by `update-check.mjs`
27
+ after a successful synchronous upgrade.
28
+ - SKILL.md Hard Rules: new clause telling the agent how to react when it
29
+ sees `error.code === "UPDATE_APPLIED"` (briefly inform the user of the
30
+ version transition, then rerun the same command).
31
+
32
+ ## [0.1.5] — 2026-05-19
33
+
34
+ ### Changed
35
+ - **Removed all Chinese-language content from source files**. All comments,
36
+ docstrings, log messages, and SKILL.md guidance are now English-only.
37
+ `normalizeWalletError` no longer matches CJK error strings from localised
38
+ wallet apps; those fall through to the generic `WALLET_ERROR` code.
39
+ - SKILL.md's "Wording Discipline" section is now language-neutral: instead
40
+ of listing Chinese phrasings, it instructs translators to keep the "wallet
41
+ top-up" verb / noun lexically distinct from the "card face value" verb /
42
+ noun in every target language.
43
+
44
+ ### Removed
45
+ - `test/create-logic.test.mjs` — stale unit tests inherited from `aicard`
46
+ that referenced internal functions removed during the merge (e.g.
47
+ `inlineWalletConnectTopup`, now replaced by `funding.mjs::fundSessionKey`).
48
+ The file was never published to npm (`test/` is not in `files`).
49
+
10
50
  ## [0.1.4] — 2026-05-19
11
51
 
12
52
  ### Added
@@ -44,14 +84,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
44
84
  ## [0.1.2] — 2026-05-19
45
85
 
46
86
  ### Changed
47
- - **SKILL.md wording discipline**: `wallet-topup` ask and `create-card` ask now have
48
- enforced lexical separation. Step 2 (`wallet-topup`) explicitly says "load USDT
49
- **into your session wallet**" / "往**本地钱包**充值 USDT". Step 3a (`create-card`)
50
- says "card **face value**" / "**开多少美元的卡** / 卡的面额", and explicitly
51
- forbids translating it as "充值". Fixes a UX confusion where a user with a
52
- funded wallet would be asked "请问您想充值多少美元到虚拟卡上?" and reasonably
53
- wonder if it was another wallet top-up prompt.
54
- - New "Wording Discipline" section in SKILL.md `## Copy Constraints` to lock this in.
87
+ - **SKILL.md wording discipline**: the `wallet-topup` and `create-card` prompts
88
+ now enforce strict lexical separation. Step 2 (`wallet-topup`) says "load USDT
89
+ **into your session wallet**"; Step 3a (`create-card`) says "card
90
+ **face value**" / "issue a card with how much". When translating to any
91
+ non-English language, the verb / noun for each concept must remain distinct
92
+ so users cannot conflate them.
93
+ - New "Wording Discipline" section in SKILL.md `## Copy Constraints` to lock
94
+ this in.
55
95
 
56
96
  ## [0.1.1] — 2026-05-19
57
97
 
package/bin/cli.mjs CHANGED
@@ -7,8 +7,9 @@ if (major < 25) {
7
7
  process.exit(1);
8
8
  }
9
9
 
10
- // WalletConnect v2 SDK 已知缺陷:relay 偶发 null WebSocket 帧导致
11
- // isJsonRpcPayload 内部 'id' in null TypeError,不影响业务流程,静默忽略
10
+ // Known WalletConnect v2 SDK quirk: the relay occasionally emits null WebSocket frames,
11
+ // causing `'id' in null` inside isJsonRpcPayload to throw a TypeError. It does not
12
+ // affect business logic, so silently ignore it.
12
13
  process.on("uncaughtException", (err) => {
13
14
  if (
14
15
  err instanceof TypeError &&
@@ -103,45 +104,33 @@ program
103
104
  return withdraw(opts);
104
105
  });
105
106
 
106
- program
107
- .command("create-card")
108
- .description("Create a one-time virtual card by paying with USDT on BSC via x402")
109
- .requiredOption("--amount <usd>", "Card amount in USD ($0.6 ~ $800)")
110
- .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
111
- .option("--topup-amount <usdt>", "USDT top-up amount when balance is insufficient (≥5)")
112
- .option("--private-key <key>", "Override EVM private key")
113
- .option("--poll", "Auto-poll status after creation", false)
114
- .option("--dry-run", "Run all preflight checks but do not sign/transact", false)
115
- .action(async (opts) => {
116
- const { createCard } = await import("../src/commands/create-card.mjs");
117
- return createCard(opts);
118
- });
119
-
120
- program
121
- .command("create-image")
122
- .description("Generate an AI image via Skill Boss, paying with USDT on BSC via x402")
123
- .requiredOption("--prompt <text>", "Image prompt text")
107
+ // ─── x402 unified paid-call entry ──────────────────────────────────────────
108
+ // The only paid-call surface: `sb invoke --model <id> --inputs <json|@file>`.
109
+ const sb = program
110
+ .command("sb")
111
+ .description("AI tools invoke any of ~200+ endpoints via x402 (USDT on BSC)");
112
+
113
+ sb
114
+ .command("invoke")
115
+ .description("Invoke any AI tool model (run `aigateway sb tools` first to populate the local catalog)")
116
+ .requiredOption("--model <id>", "Model id, e.g. replicate/black-forest-labs/flux-schnell")
117
+ .requiredOption("--inputs <json>", "Inputs as JSON literal or @path/to/file.json")
124
118
  .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
125
- .option("--aspect-ratio <ratio>", "Image aspect ratio", "16:9")
126
- .option("--output-format <fmt>", "Image format (png/jpeg/webp)", "png")
127
- .option("--model <id>", "Model identifier")
128
- .option("--output <dir>", "Output directory (default ~/aigateway-images)")
119
+ .option("--output <dir>", "Output directory for binary downloads (image/video/audio)")
120
+ .option("--raw", "Skip auto-download and emit the upstream response as-is", false)
129
121
  .option("--topup-amount <usdt>", "USDT top-up amount when balance is insufficient (≥5)")
130
122
  .option("--private-key <key>", "Override EVM private key")
131
123
  .action(async (opts) => {
132
- const { createImage } = await import("../src/commands/create-image.mjs");
133
- return createImage(opts);
124
+ const { sbInvokeCommand } = await import("../src/commands/sb-invoke.mjs");
125
+ return sbInvokeCommand(opts);
134
126
  });
135
127
 
136
- program
137
- .command("create-card-status")
138
- .description("Query the status of a virtual card created via create-card")
139
- .requiredOption("--order-no <orderNo>", "Order number returned by create-card")
140
- .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
141
- .option("--poll", "Poll until terminal status", false)
128
+ sb
129
+ .command("tools")
130
+ .description("Fetch and display the AI tool catalog from the server (no caching, always live)")
142
131
  .action(async (opts) => {
143
- const { status } = await import("../src/commands/create-card-status.mjs");
144
- return status(opts);
132
+ const { sbTools } = await import("../src/commands/sb-tools.mjs");
133
+ return sbTools(opts);
145
134
  });
146
135
 
147
136
  program
@@ -38,8 +38,9 @@ The full set of `error.code` values, grouped by exit code, is defined in [`src/e
38
38
  | ---- | ---- |
39
39
  | `PAYMENT_TIMEOUT` | WalletConnect / signature request timed out (5 minutes). |
40
40
  | `WC_SESSION_EXPIRED` | WalletConnect session dropped mid-flow. |
41
- | `POLL_TIMEOUT` | `status --poll` exhausted attempts. Card may still be provisioning. |
41
+ | `POLL_TIMEOUT` | `create-card-status --poll` exhausted attempts. Card may still be provisioning. |
42
42
  | `TX_TIMEOUT` | On-chain receipt wait exceeded 60 s. |
43
+ | `UPDATE_APPLIED` | The CLI just upgraded itself synchronously to a newer version. The previous command was not executed — the caller (or the agent) must rerun it on the new version. Envelope carries `error.from` / `error.to` showing the version transition. |
43
44
 
44
45
  ### Exit 3 — Service / Network
45
46
 
@@ -59,15 +59,17 @@ We follow [SemVer](https://semver.org/):
59
59
 
60
60
  ## What happens for users after publish
61
61
 
62
- `src/update-check.mjs` runs on every CLI invocation. Within a few seconds of the next `aigateway <cmd>` call by any user, they will:
62
+ `src/update-check.mjs` runs at the start of every CLI invocation. On the **next** `aigateway <cmd>` call by any user with a stale version, they will:
63
63
 
64
- 1. See `[update] @aeon-ai-pay/aigateway 0.1.0 → 0.1.1, upgrading in background...` on stderr.
65
- 2. The current command still completes normally.
66
- 3. A detached child process runs `npm install -g @aeon-ai-pay/aigateway@0.1.1` + `node scripts/postinstall.mjs`, which calls `npx skills add ... -g -y --copy`.
67
- 4. The new `SKILL.md` is re-installed into every detected IDE skill folder (Cursor / Claude Code / Codex / Windsurf / Cline / …).
68
- 5. Next invocation uses the new CLI and the new agent reads the new skill.
64
+ 1. See `[update] @aeon-ai-pay/aigateway 0.1.0 → 0.1.1, upgrading (foreground)...` on stderr.
65
+ 2. **`npm install -g @aeon-ai-pay/aigateway@<latest>` runs synchronously**, with `npm`'s own progress streamed to stderr.
66
+ 3. **`scripts/postinstall.mjs` runs synchronously**, calling `npx skills add ... -g -y --copy` to refresh every detected IDE skill folder (Cursor / Claude Code / Codex / Windsurf / Cline / …).
67
+ 4. The CLI emits an envelope with `error.code === "UPDATE_APPLIED"` and **exits with code 2** without executing the original command.
68
+ 5. The caller (or the agent `error.code` is stable, agents should match on it) **reruns the original command**, which now executes on the new CLI + new SKILL.md.
69
69
 
70
- Upgrade results land in `~/.aigateway/update.log`.
70
+ Why foreground instead of detached background: a backgrounded `npm install -g` mid-command can leave the global package in a half-replaced state (`bin/cli.mjs` already updated while `src/commands/*` still old, or vice versa), causing `ERR_MODULE_NOT_FOUND` on the very next invocation. Synchronous upgrade keeps the package consistent.
71
+
72
+ If the upgrade itself fails (network, permissions, `ENOTEMPTY` on Windows / nvm), the failure is logged to stderr and the command continues on the current version — the user is never silently left on a half-installed package.
71
73
 
72
74
  ## Rolling back
73
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeon-ai-pay/aigateway",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "AI Agents discover, invoke, and settle paid LLMs, APIs, and Skills — starting with Skill Boss. No manual key setup. No prepayment. Pay-per-call via x402 or Agent Card.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * npm install -g 后自动安装 skill 到所有已检测的 AI 编码工具
4
+ * After `npm install -g`, automatically install the skill into every detected AI coding tool.
5
5
  *
6
- * 优先使用 `npx skills add` (Vercel Labs) 统一安装到所有工具
7
- * 失败时 fallback 到手动复制 Claude Code skills 目录
6
+ * Prefer `npx skills add` (Vercel Labs) so the skill is registered across all tools at once.
7
+ * If that fails, fall back to manually copying the skill into the Claude Code skills directory.
8
8
  */
9
9
 
10
10
  import { cpSync, existsSync, mkdirSync } from 'node:fs';
@@ -20,7 +20,7 @@ if (!existsSync(skillSrc)) {
20
20
  process.exit(0);
21
21
  }
22
22
 
23
- // 尝试用 skills CLI 安装到所有工具
23
+ // Try installing into every tool via the skills CLI
24
24
  try {
25
25
  execFileSync('npx', ['skills', 'add', skillSrc, '-g', '-y', '--copy'], {
26
26
  stdio: 'inherit',
@@ -30,10 +30,10 @@ try {
30
30
  console.log('✔ aigateway skill installed via skills CLI (all detected tools)');
31
31
  process.exit(0);
32
32
  } catch {
33
- // skills CLI 不可用或失败,fallback
33
+ // skills CLI unavailable or failed — fall back
34
34
  }
35
35
 
36
- // Fallback: 手动复制到 Claude Code
36
+ // Fallback: copy manually into Claude Code
37
37
  const dest = join(homedir(), '.claude', 'skills', 'aigateway');
38
38
  mkdirSync(dirname(dest), { recursive: true });
39
39
  cpSync(skillSrc, dest, { recursive: true, force: true });