@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 +48 -8
- package/bin/cli.mjs +23 -34
- package/docs/exit-codes.md +2 -1
- package/docs/release-process.md +9 -7
- package/package.json +1 -1
- package/scripts/postinstall.mjs +6 -6
- package/skills/aigateway/SKILL.md +369 -272
- package/src/balance.mjs +7 -7
- package/src/catalog.mjs +38 -0
- package/src/commands/clean.mjs +5 -5
- package/src/commands/sb-invoke.mjs +407 -0
- package/src/commands/sb-tools.mjs +37 -0
- package/src/commands/wallet-gas.mjs +2 -1
- package/src/commands/wallet-init.mjs +20 -21
- package/src/commands/wallet-topup.mjs +15 -15
- package/src/commands/wallet-withdraw.mjs +7 -7
- package/src/config.mjs +24 -24
- package/src/error-codes.mjs +22 -14
- package/src/funding.mjs +2 -2
- package/src/inputs-validator.mjs +125 -0
- package/src/output.mjs +19 -16
- package/src/tools-download.mjs +264 -0
- package/src/update-check.mjs +50 -47
- package/src/walletconnect.mjs +65 -63
- package/src/x402.mjs +13 -10
- package/skills/aigateway/references/check-status.md +0 -68
- package/skills/aigateway/references/create-card.md +0 -114
- package/skills/aigateway/references/store.md +0 -87
- package/src/commands/create-card-status.mjs +0 -67
- package/src/commands/create-card.mjs +0 -352
- package/src/commands/create-image.mjs +0 -428
- package/src/sanitize.mjs +0 -48
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`
|
|
48
|
-
|
|
49
|
-
**into your session wallet**"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
11
|
-
//
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.
|
|
114
|
-
.
|
|
115
|
-
.
|
|
116
|
-
|
|
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("--
|
|
126
|
-
.option("--
|
|
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 {
|
|
133
|
-
return
|
|
124
|
+
const { sbInvokeCommand } = await import("../src/commands/sb-invoke.mjs");
|
|
125
|
+
return sbInvokeCommand(opts);
|
|
134
126
|
});
|
|
135
127
|
|
|
136
|
-
|
|
137
|
-
.command("
|
|
138
|
-
.description("
|
|
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 {
|
|
144
|
-
return
|
|
132
|
+
const { sbTools } = await import("../src/commands/sb-tools.mjs");
|
|
133
|
+
return sbTools(opts);
|
|
145
134
|
});
|
|
146
135
|
|
|
147
136
|
program
|
package/docs/exit-codes.md
CHANGED
|
@@ -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
|
|
package/docs/release-process.md
CHANGED
|
@@ -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
|
|
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
|
|
65
|
-
2.
|
|
66
|
-
3.
|
|
67
|
-
4. The
|
|
68
|
-
5.
|
|
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
|
-
|
|
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.
|
|
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": {
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* npm install -g
|
|
4
|
+
* After `npm install -g`, automatically install the skill into every detected AI coding tool.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
//
|
|
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
|
|
33
|
+
// skills CLI unavailable or failed — fall back
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// Fallback:
|
|
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 });
|