@aeon-ai-pay/aigateway 0.1.5 → 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,28 @@ 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
+
10
32
  ## [0.1.5] — 2026-05-19
11
33
 
12
34
  ### Changed
package/bin/cli.mjs CHANGED
@@ -104,45 +104,33 @@ program
104
104
  return withdraw(opts);
105
105
  });
106
106
 
107
- program
108
- .command("create-card")
109
- .description("Create a one-time virtual card by paying with USDT on BSC via x402")
110
- .requiredOption("--amount <usd>", "Card amount in USD ($0.6 ~ $800)")
111
- .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
112
- .option("--topup-amount <usdt>", "USDT top-up amount when balance is insufficient (≥5)")
113
- .option("--private-key <key>", "Override EVM private key")
114
- .option("--poll", "Auto-poll status after creation", false)
115
- .option("--dry-run", "Run all preflight checks but do not sign/transact", false)
116
- .action(async (opts) => {
117
- const { createCard } = await import("../src/commands/create-card.mjs");
118
- return createCard(opts);
119
- });
120
-
121
- program
122
- .command("create-image")
123
- .description("Generate an AI image via Skill Boss, paying with USDT on BSC via x402")
124
- .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")
125
118
  .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
126
- .option("--aspect-ratio <ratio>", "Image aspect ratio", "16:9")
127
- .option("--output-format <fmt>", "Image format (png/jpeg/webp)", "png")
128
- .option("--model <id>", "Model identifier")
129
- .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)
130
121
  .option("--topup-amount <usdt>", "USDT top-up amount when balance is insufficient (≥5)")
131
122
  .option("--private-key <key>", "Override EVM private key")
132
123
  .action(async (opts) => {
133
- const { createImage } = await import("../src/commands/create-image.mjs");
134
- return createImage(opts);
124
+ const { sbInvokeCommand } = await import("../src/commands/sb-invoke.mjs");
125
+ return sbInvokeCommand(opts);
135
126
  });
136
127
 
137
- program
138
- .command("create-card-status")
139
- .description("Query the status of a virtual card created via create-card")
140
- .requiredOption("--order-no <orderNo>", "Order number returned by create-card")
141
- .option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
142
- .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)")
143
131
  .action(async (opts) => {
144
- const { status } = await import("../src/commands/create-card-status.mjs");
145
- return status(opts);
132
+ const { sbTools } = await import("../src/commands/sb-tools.mjs");
133
+ return sbTools(opts);
146
134
  });
147
135
 
148
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.5",
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": {