@bnbagent/studio-cli 0.0.6-alpha.7 → 0.0.6-alpha.8
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/DISCLAIMER.md +6 -27
- package/README.md +6 -13
- package/dist/bag.js +920 -723
- package/dist/{chunk-VEOOFDSF.js → chunk-JZAW6HMV.js} +74 -5
- package/dist/{deployCli-EEK75T67.js → deployCli-AJ25A4VK.js} +1 -1
- package/package.json +2 -2
- package/recipes/providers/pieverse-llm/skills/funding-pieverse-llm.md +32 -64
- package/skills/bnbagent-studio.md +29 -74
- package/skills/references/bnbagent-studio-adding-to-project.md +58 -169
- package/skills/references/bnbagent-studio-buying-from-bazaar.md +43 -104
- package/skills/references/bnbagent-studio-buying-via-8183.md +38 -112
- package/skills/references/bnbagent-studio-extending-signing.md +47 -50
- package/skills/references/bnbagent-studio-operating.md +58 -110
- package/skills/references/bnbagent-studio-scaffolding-agent.md +134 -400
- package/skills/references/bnbagent-studio-selling-via-8183.md +87 -171
- package/skills/references/bnbagent-studio-selling-via-b402.md +39 -131
- package/skills/references/bnbagent-studio-use-aws-agentcore.md +42 -141
- package/skills/references/bnbagent-studio-use-azure-foundry.md +34 -95
- package/skills/references/bnbagent-studio-use-bnb-trial.md +12 -36
- package/skills/references/bnbagent-studio-using-altana-wallet.md +11 -28
- package/skills/references/bnbagent-studio-using-twak-wallet.md +102 -210
- package/skills/references/bnbagent-studio-wiring-llm-tools.md +71 -150
|
@@ -13,7 +13,7 @@ import * as os from "os";
|
|
|
13
13
|
import * as path5 from "path";
|
|
14
14
|
import {
|
|
15
15
|
findSubProjectRoot as findSubProjectRoot2,
|
|
16
|
-
loadStudioToml as
|
|
16
|
+
loadStudioToml as loadStudioToml3
|
|
17
17
|
} from "@bnbagent/studio-runtime/config";
|
|
18
18
|
import { stringify as tomlStringify } from "smol-toml";
|
|
19
19
|
|
|
@@ -21,6 +21,8 @@ import { stringify as tomlStringify } from "smol-toml";
|
|
|
21
21
|
import { createHash } from "crypto";
|
|
22
22
|
import * as fs from "fs";
|
|
23
23
|
import * as path from "path";
|
|
24
|
+
import { loadStudioToml } from "@bnbagent/studio-runtime/config";
|
|
25
|
+
import { resolveProjectAltanaSdkEntry } from "@bnbagent/studio-runtime/wallet";
|
|
24
26
|
import { build as esbuildBuild } from "esbuild";
|
|
25
27
|
|
|
26
28
|
// src/cli/utils/protocol.ts
|
|
@@ -133,6 +135,7 @@ async function buildZip(agentDir, outZip, opts = {}) {
|
|
|
133
135
|
await (opts.bundle ?? bundleEntry)(entry, outfile);
|
|
134
136
|
stageManifest(agentDir, buildRoot, entrypoint);
|
|
135
137
|
stageStudioToml(agentDir, buildRoot);
|
|
138
|
+
await stageAltanaSdk(agentDir, buildRoot, opts.bundle ?? bundleEntry);
|
|
136
139
|
assertWithinUncompressedCap(
|
|
137
140
|
buildRoot,
|
|
138
141
|
opts.maxUncompressedBytes ?? MAX_UNCOMPRESSED_BYTES
|
|
@@ -222,6 +225,72 @@ function stageStudioToml(agentDir, buildRoot) {
|
|
|
222
225
|
fs.copyFileSync(src, path.join(buildRoot, "studio.toml"));
|
|
223
226
|
}
|
|
224
227
|
}
|
|
228
|
+
async function stageAltanaSdk(agentDir, buildRoot, bundle) {
|
|
229
|
+
let kind = "evm-local";
|
|
230
|
+
try {
|
|
231
|
+
const cfg = loadStudioToml(path.join(agentDir, "studio.toml"));
|
|
232
|
+
const wallet = cfg.wallet;
|
|
233
|
+
if (wallet !== null && typeof wallet === "object" && !Array.isArray(wallet)) {
|
|
234
|
+
kind = String(wallet.kind ?? "evm-local");
|
|
235
|
+
}
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
if (kind !== "altana") {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
let entry = null;
|
|
242
|
+
try {
|
|
243
|
+
entry = resolveProjectAltanaSdkEntry(agentDir);
|
|
244
|
+
} catch (exc) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`wallet.kind='altana' zip build: ${exc instanceof Error ? exc.message : exc}`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
if (entry === null) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
"wallet.kind='altana' but @altananetwork/sdk is not resolvable from the agent project \u2014 the zip runtime could never load the Altana session wallet. Run `pnpm add @altananetwork/sdk@0.5.1` in app/agent, or deploy as a container."
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const pkgDir = path.join(buildRoot, "node_modules", "@altananetwork", "sdk");
|
|
255
|
+
fs.mkdirSync(pkgDir, { recursive: true });
|
|
256
|
+
await bundle(entry, path.join(pkgDir, "index.js"));
|
|
257
|
+
fs.writeFileSync(
|
|
258
|
+
path.join(pkgDir, "package.json"),
|
|
259
|
+
`${JSON.stringify(
|
|
260
|
+
{
|
|
261
|
+
name: "@altananetwork/sdk",
|
|
262
|
+
version: altanaSdkVersionOf(entry),
|
|
263
|
+
private: true,
|
|
264
|
+
type: "module",
|
|
265
|
+
main: "index.js"
|
|
266
|
+
},
|
|
267
|
+
null,
|
|
268
|
+
2
|
|
269
|
+
)}
|
|
270
|
+
`
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function altanaSdkVersionOf(entry) {
|
|
274
|
+
let cursor = path.dirname(entry);
|
|
275
|
+
for (let i = 0; i < 4; i += 1) {
|
|
276
|
+
const manifest = path.join(cursor, "package.json");
|
|
277
|
+
if (isFile(manifest)) {
|
|
278
|
+
try {
|
|
279
|
+
const pkg = JSON.parse(fs.readFileSync(manifest, "utf-8"));
|
|
280
|
+
if (pkg.name === "@altananetwork/sdk") {
|
|
281
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
282
|
+
}
|
|
283
|
+
} catch {
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const parent = path.dirname(cursor);
|
|
287
|
+
if (parent === cursor) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
cursor = parent;
|
|
291
|
+
}
|
|
292
|
+
return "0.0.0";
|
|
293
|
+
}
|
|
225
294
|
async function pack(buildRoot, outZip) {
|
|
226
295
|
fs.rmSync(outZip, { force: true });
|
|
227
296
|
const ZipArchive = await loadZipArchive();
|
|
@@ -568,7 +637,7 @@ import * as path4 from "path";
|
|
|
568
637
|
import {
|
|
569
638
|
envLocalPath,
|
|
570
639
|
findSubProjectRoot,
|
|
571
|
-
loadStudioToml
|
|
640
|
+
loadStudioToml as loadStudioToml2
|
|
572
641
|
} from "@bnbagent/studio-runtime/config";
|
|
573
642
|
|
|
574
643
|
// src/cli/utils/envFile.ts
|
|
@@ -677,7 +746,7 @@ function loadDeployConfig(root) {
|
|
|
677
746
|
try {
|
|
678
747
|
return {
|
|
679
748
|
agentRoot,
|
|
680
|
-
cfg:
|
|
749
|
+
cfg: loadStudioToml2(path4.join(agentRoot, "studio.toml"))
|
|
681
750
|
};
|
|
682
751
|
} catch {
|
|
683
752
|
return { agentRoot, cfg: {} };
|
|
@@ -829,7 +898,7 @@ function providerPassthrough(studio, table4) {
|
|
|
829
898
|
}
|
|
830
899
|
function buildDeploySpec(root, opts) {
|
|
831
900
|
const agentRoot = findSubProjectRoot2("agent", root) ?? root;
|
|
832
|
-
const studio =
|
|
901
|
+
const studio = loadStudioToml3(path5.join(agentRoot, "studio.toml"));
|
|
833
902
|
const name = String(
|
|
834
903
|
opts.nameOverride || descriptorName(root) || tableOf(studio, "project").name || path5.basename(root)
|
|
835
904
|
);
|
|
@@ -963,7 +1032,7 @@ async function withDeployFiles(root, opts, fn) {
|
|
|
963
1032
|
let zip;
|
|
964
1033
|
if (opts.packaging === "zip") {
|
|
965
1034
|
const agentRoot = findSubProjectRoot2("agent", root) ?? root;
|
|
966
|
-
const studio =
|
|
1035
|
+
const studio = loadStudioToml3(
|
|
967
1036
|
path5.join(agentRoot, "studio.toml")
|
|
968
1037
|
);
|
|
969
1038
|
const stack = tableOf(studio, "stack");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bnbagent/studio-cli",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.8",
|
|
4
4
|
"description": "The `bag` CLI: scaffold, run, deploy, and monetize a single seller agent on BNB Chain (ERC-8004 identity, ERC-8183 commerce, x402 payments).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tar": "^7.4.0",
|
|
39
39
|
"viem": "^2.54.0",
|
|
40
40
|
"yaml": "^2.9.0",
|
|
41
|
-
"@bnbagent/studio-runtime": "0.0.6-alpha.
|
|
41
|
+
"@bnbagent/studio-runtime": "0.0.6-alpha.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@a2a-js/sdk": "^0.3.14",
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: funding-pieverse-llm
|
|
3
|
-
description: When the user is dealing with Pieverse LLM funding
|
|
3
|
+
description: When the user is dealing with Pieverse LLM funding - switching to a paid model, hitting InsufficientCreditsError / PieverseAccountBalanceExhaustedError, topping up the wallet for paid LLM usage, or asking "how do I pay for the LLM" / "why is my agent stuck on LLM". Covers the zero-deposit default + the paid-upgrade path.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# funding-pieverse-llm
|
|
7
7
|
|
|
8
|
-
Procedure for **Pieverse LLM funding decisions** in a bnbagent-studio project.
|
|
9
|
-
Audience: Claude Code helping a user who has already run `bag init` + `bag llm activate`.
|
|
8
|
+
Procedure for **Pieverse LLM funding decisions** in a bnbagent-studio project. Audience: Claude Code helping a user who has already run `bag init` + `bag llm activate`.
|
|
10
9
|
|
|
11
|
-
**Different from**: `-operating` (general ops)
|
|
12
|
-
Pieverse credit lifecycle, paid-model upgrade, and topup troubleshooting.
|
|
10
|
+
**Different from**: `-operating` (general ops) - this skill is specifically for the Pieverse credit lifecycle, paid-model upgrade, and topup troubleshooting.
|
|
13
11
|
|
|
14
12
|
## Mental model (zero-deposit default)
|
|
15
13
|
|
|
16
|
-
bnbagent-studio
|
|
14
|
+
The current bnbagent-studio release defaults to **zero-deposit Pieverse activation**:
|
|
17
15
|
|
|
18
|
-
- `bag init` + `bag llm activate` together create a Pieverse account + API key
|
|
19
|
-
|
|
20
|
-
- Default model is **`auto/free`** (Pieverse's $0/token tier). The agent runs
|
|
21
|
-
unmetered against it.
|
|
16
|
+
- `bag init` + `bag llm activate` together create a Pieverse account + API key with **$0 initial allocation**. No wallet funding required.
|
|
17
|
+
- Default model is **`auto/free`** (Pieverse's $0/token tier). The agent runs unmetered against it.
|
|
22
18
|
- The user **only needs to fund their wallet** when they want to:
|
|
23
|
-
1. Switch to a **paid model** (e.g. `auto/paid`, `claude-haiku-4.5`,
|
|
24
|
-
`anthropic/claude-sonnet-4.6`, etc.)
|
|
19
|
+
1. Switch to a **paid model** (e.g. `auto/paid`, `claude-haiku-4.5`, `anthropic/claude-sonnet-4.6`, etc.)
|
|
25
20
|
2. Run `bag erc8004 register` (needs **testnet tBNB** for gas)
|
|
26
21
|
3. `bag deploy` to AgentCore
|
|
27
22
|
|
|
28
23
|
**Three independent balances**, on the same EOA address but different chains/assets:
|
|
29
24
|
|
|
30
25
|
| Balance | Chain | Purpose | When needed |
|
|
31
|
-
|
|
26
|
+
| --- | --- | --- | --- |
|
|
32
27
|
| testnet tBNB | BSC testnet (97) | gas for ERC-8004 / ERC-8183 / deploy txs | register / deploy |
|
|
33
28
|
| testnet U | BSC testnet (97) | ERC-8183 job settlement | when this agent buys/sells via 8183 |
|
|
34
29
|
| mainnet U | BSC mainnet (56) | Pieverse paid LLM credits | switching to paid LLM model |
|
|
@@ -38,7 +33,7 @@ Use `bag wallet balance --all` to see all three.
|
|
|
38
33
|
## Quick triage decision tree
|
|
39
34
|
|
|
40
35
|
| User said... | Run first |
|
|
41
|
-
|
|
36
|
+
| --- | --- |
|
|
42
37
|
| "how do I switch to claude/opus/sonnet/paid model" | Section A below |
|
|
43
38
|
| `InsufficientCreditsError` during a negotiate or job delivery | Section B below |
|
|
44
39
|
| `PieverseAccountBalanceExhaustedError` | Section B below |
|
|
@@ -71,8 +66,7 @@ bag llm status # should show non-zero key_credit
|
|
|
71
66
|
bag llm test # one-shot smoke check
|
|
72
67
|
```
|
|
73
68
|
|
|
74
|
-
**Do NOT** silently fallback to `auto/free` when a paid call fails
|
|
75
|
-
zero-deposit hard-fail rule. The user explicitly chose a paid model; surface the failure.
|
|
69
|
+
**Do NOT** silently fallback to `auto/free` when a paid call fails - see the zero-deposit hard-fail rule. The user explicitly chose a paid model; surface the failure.
|
|
76
70
|
|
|
77
71
|
## B. InsufficientCreditsError / PieverseAccountBalanceExhaustedError
|
|
78
72
|
|
|
@@ -92,55 +86,41 @@ bag llm topup --amount 1 # spends mainnet U via x402
|
|
|
92
86
|
bag llm allocate --amount 1 # then allocate
|
|
93
87
|
```
|
|
94
88
|
|
|
95
|
-
Never edit `studio.toml [llm].model = auto/free` to "fix" a paid model's
|
|
96
|
-
funding error — that's silently changing agent behavior. Either fund or
|
|
97
|
-
explicitly downgrade, and tell the user which you did.
|
|
89
|
+
Never edit `studio.toml [llm].model = auto/free` to "fix" a paid model's funding error - that's silently changing agent behavior. Either fund or explicitly downgrade, and tell the user which you did.
|
|
98
90
|
|
|
99
91
|
## C. PieverseColdStartTopupBlockedError
|
|
100
92
|
|
|
101
|
-
The auto-topup hook refuses to fund during the first 60 seconds after process
|
|
102
|
-
start. This is a **safety feature** (闸门 5) — it prevents boot-loop
|
|
103
|
-
scenarios from burning the user's monthly budget.
|
|
93
|
+
The auto-topup hook refuses to fund during the first 60 seconds after process start. This is a **safety feature** (闸门 5) - it prevents boot-loop scenarios from burning the user's monthly budget.
|
|
104
94
|
|
|
105
95
|
Recovery:
|
|
96
|
+
|
|
106
97
|
- Wait 60s, then retry the LLM call (auto-topup will engage).
|
|
107
|
-
- Or topup manually: `bag llm topup --amount N` (CLI is not subject to the
|
|
108
|
-
|
|
109
|
-
- **Never** advise the user to set `PIEVERSE_BUDGET_COLD_START_SECONDS=0` to
|
|
110
|
-
work around this — that env var is for CI/e2e only. If the user is hitting
|
|
111
|
-
this repeatedly, it indicates the agent is restarting too often; investigate
|
|
112
|
-
why.
|
|
98
|
+
- Or topup manually: `bag llm topup --amount N` (CLI is not subject to the cold-start gate; only the in-process auto-topup hook is).
|
|
99
|
+
- **Never** advise the user to set `PIEVERSE_BUDGET_COLD_START_SECONDS=0` to work around this - that env var is for CI/e2e only. If the user is hitting this repeatedly, it indicates the agent is restarting too often; investigate why.
|
|
113
100
|
|
|
114
101
|
## D. Auto-renew: two independent tiers + their switches
|
|
115
102
|
|
|
116
|
-
Auto-renew is a **two-tier ladder**, each with its own on/off switch. Inspect
|
|
117
|
-
both at once:
|
|
103
|
+
Auto-renew is a **two-tier ladder**, each with its own on/off switch. Inspect both at once:
|
|
118
104
|
|
|
119
105
|
```bash
|
|
120
106
|
bag llm auto-renew status # prints the llm tier AND the wallet tier
|
|
121
107
|
```
|
|
122
108
|
|
|
123
|
-
**Tier 1
|
|
124
|
-
Default **on**. Before each LLM call the agent tops the API key up from credit
|
|
125
|
-
already parked in the Account Balance when it dips below `min_balance_usd`.
|
|
109
|
+
**Tier 1 - `llm` (allocate from Pieverse Account Balance; no wallet spend).** Default **on**. Before each LLM call the agent tops the API key up from credit already parked in the Account Balance when it dips below `min_balance_usd`.
|
|
126
110
|
|
|
127
111
|
```bash
|
|
128
112
|
bag llm auto-renew llm off # disable: agent runs as a plain model, no credit hook
|
|
129
113
|
bag llm auto-renew llm on # re-enable (writes [llm.auto_renew].enabled)
|
|
130
114
|
```
|
|
131
115
|
|
|
132
|
-
**Tier 2
|
|
133
|
-
Default **off** (opt-in; the agent will not autonomously spend the wallet until
|
|
134
|
-
this is on). Turning it on records a consent stamp — required before any
|
|
135
|
-
autonomous spend.
|
|
116
|
+
**Tier 2 - `wallet` (spend wallet U via x402 to refill the Account Balance).** Default **off** (opt-in; the agent will not autonomously spend the wallet until this is on). Turning it on records a consent stamp - required before any autonomous spend.
|
|
136
117
|
|
|
137
118
|
```bash
|
|
138
119
|
bag llm auto-renew wallet on # opt in (= bag budget enable; records acknowledged_at)
|
|
139
120
|
bag llm auto-renew wallet off # opt out (= bag budget disable)
|
|
140
121
|
```
|
|
141
122
|
|
|
142
|
-
`bag llm auto-renew wallet on` is exactly `bag budget enable` and accepts the
|
|
143
|
-
same cap overrides via that command:
|
|
123
|
+
`bag llm auto-renew wallet on` is exactly `bag budget enable` and accepts the same cap overrides via that command:
|
|
144
124
|
|
|
145
125
|
```bash
|
|
146
126
|
bag budget show # current state (default: disabled)
|
|
@@ -153,51 +133,39 @@ bag budget enable \
|
|
|
153
133
|
```
|
|
154
134
|
|
|
155
135
|
Once enabled, the agent will:
|
|
136
|
+
|
|
156
137
|
- Wait at least 60s after process start before any topup (cold-start gate)
|
|
157
|
-
- Try to topup_x402 from mainnet U when the API key drops below
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
applies — next LLM call may retry)
|
|
161
|
-
- Log every topup attempt to `~/.bnbagent-studio/<project>/logs/topup.jsonl`
|
|
162
|
-
and print a red-text notice to stdout
|
|
138
|
+
- Try to topup_x402 from mainnet U when the API key drops below `min_balance_usd` (default $0.2)
|
|
139
|
+
- Stop and raise on cap-exceeded; not retry on failure (exponential backoff applies - next LLM call may retry)
|
|
140
|
+
- Log every topup attempt to `~/.bnbagent-studio/<project>/logs/topup.jsonl` and print a red-text notice to stdout
|
|
163
141
|
|
|
164
|
-
`WALLET_PASSWORD` env must be present in the runtime
|
|
165
|
-
falls back to allocate-only mode (no wallet spend, no error).
|
|
142
|
+
`WALLET_PASSWORD` env must be present in the runtime - without it the gate falls back to allocate-only mode (no wallet spend, no error).
|
|
166
143
|
|
|
167
144
|
## E. Protocol-level details (for advanced cases)
|
|
168
145
|
|
|
169
|
-
When the user needs to understand the Pieverse protocol itself (raw SIWE,
|
|
170
|
-
x402 v2 envelope, deposit methods schema, signing typed data), point them
|
|
171
|
-
to Pieverse's official skill markdown — it is the authoritative reference:
|
|
146
|
+
When the user needs to understand the Pieverse protocol itself (raw SIWE, x402 v2 envelope, deposit methods schema, signing typed data), point them to Pieverse's official skill markdown - it is the authoritative reference:
|
|
172
147
|
|
|
173
148
|
- https://llm.pieverse.io/ai-gateway/skill.md (overview)
|
|
174
149
|
- https://llm.pieverse.io/ai-gateway/references/siwe-format.md (SIWE login)
|
|
175
150
|
- https://llm.pieverse.io/ai-gateway/references/x402-payment.md (topup mechanics)
|
|
176
151
|
- https://llm.pieverse.io/ai-gateway/references/api-reference.md (key/usage)
|
|
177
152
|
|
|
178
|
-
Do **not** re-implement what these documents specify. studio's `bag llm` /
|
|
179
|
-
`bag wallet` commands already wrap these flows.
|
|
153
|
+
Do **not** re-implement what these documents specify. studio's `bag llm` / `bag wallet` commands already wrap these flows.
|
|
180
154
|
|
|
181
155
|
## Read-only inspection (no password needed)
|
|
182
156
|
|
|
183
|
-
The CLI commands that only need the `sk-pv-...` API key (no wallet signature)
|
|
184
|
-
work without prompting for `WALLET_PASSWORD`:
|
|
157
|
+
The CLI commands that only need the `sk-pv-...` API key (no wallet signature) work without prompting for `WALLET_PASSWORD`:
|
|
185
158
|
|
|
186
159
|
```bash
|
|
187
160
|
bag llm usage [--days 7] # per-key usage, no session
|
|
188
161
|
bag llm test --message "hi" # one-shot LLM smoke (uses key only)
|
|
189
162
|
```
|
|
190
163
|
|
|
191
|
-
Anything that needs the session_token (balance / deposits / key management)
|
|
192
|
-
will require `WALLET_PASSWORD` to be set in the environment or interactively.
|
|
164
|
+
Anything that needs the session_token (balance / deposits / key management) will require `WALLET_PASSWORD` to be set in the environment or interactively.
|
|
193
165
|
|
|
194
166
|
## Hard rules
|
|
195
167
|
|
|
196
|
-
- Wallet private keys are never sent to Pieverse, never logged, and never put in
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
- `
|
|
200
|
-
- When in doubt about a topup amount, suggest **smaller** values. Starting at
|
|
201
|
-
$0.5 – $1 is far better than $5+ for a user's first paid run.
|
|
202
|
-
- If the user has not opted into `bag budget enable`, never trigger an
|
|
203
|
-
auto-topup on their behalf — surface the error and let them decide.
|
|
168
|
+
- Wallet private keys are never sent to Pieverse, never logged, and never put in error messages. (Deploying to the managed platform is the one case a key leaves your machine - it is sent to the operator to sign; self-deploy keeps it local.)
|
|
169
|
+
- `session_token` is memory-only per Pieverse spec - never persist to disk.
|
|
170
|
+
- When in doubt about a topup amount, suggest **smaller** values. Starting at $0.5 - $1 is far better than $5+ for a user's first paid run.
|
|
171
|
+
- If the user has not opted into `bag budget enable`, never trigger an auto-topup on their behalf - surface the error and let them decide.
|
|
@@ -1,55 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bnbagent-studio
|
|
3
|
-
description: The single entry point for bnbagent-studio
|
|
3
|
+
description: The single entry point for bnbagent-studio - a TypeScript CLI (`bag`) for building a blockchain SELLER agent that earns $U on BNB Chain via ERC-8004 + ERC-8183 + x402 (Pieverse LLM inside). Load this skill whenever the user works in a bnbagent-studio / `bag` project, or wants to create/scaffold, deploy, run, debug, operate, or monetize such a seller agent (composable A2A, MCP, and X402 faces; BNB Chain trial or AWS AgentCore). All detailed playbooks ship as references/ files inside this skill - route via the decision tree in the body. When invoked with arguments, treat them as the user's intent and route the same way.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# bnbagent-studio (the single entry point)
|
|
7
7
|
|
|
8
|
-
`bnbagent-studio` (CLI: `bag`) wires the `@bnbagent/sdk` protocol layer (wallet /
|
|
9
|
-
|
|
10
|
-
as
|
|
11
|
-
public faces selected with `--protocols`; A2A is the default. `bag deploy` uses
|
|
12
|
-
**scheme C**: every new deploy
|
|
13
|
-
or redeploy explicitly selects BNB or AWS; a recorded deployment is
|
|
14
|
-
used only to offer an explicit update action, never as a silent default. BNB is
|
|
15
|
-
a 48h testnet trial and is disabled after expiry. AWS deploys into the
|
|
16
|
-
user's own account. All cloud lifecycle calls go through the pinned
|
|
17
|
-
`@bnbagent/deploy-cli`; never require the `aws` CLI.
|
|
18
|
-
BNB/AWS share the agentcore scaffold. Treat an incompatible provider row as
|
|
19
|
-
unavailable—do not force through it or mutate the scaffold during deploy.
|
|
20
|
-
|
|
21
|
-
Invoked as `/bnbagent-studio <ask>`? Treat `<ask>` as the user's intent and
|
|
22
|
-
route it through the decision tree below, exactly like a natural-language ask.
|
|
8
|
+
`bnbagent-studio` (CLI: `bag`) wires the `@bnbagent/sdk` protocol layer (wallet / ERC-8004 / ERC-8183 / Pieverse LLM) into a TypeScript agent project, then deploys it as a **single blockchain seller runtime**. A2A, MCP, and X402 are composable public faces selected with `--protocols`; A2A is the default. `bag deploy` uses **scheme C**: every new deploy or redeploy explicitly selects BNB or AWS; a recorded deployment is used only to offer an explicit update action, never as a silent default. BNB is a 48h testnet trial and is disabled after expiry. AWS deploys into the user's own account. All cloud lifecycle mutations go through the pinned `@bnbagent/deploy-cli`; the optional AWS CLI is used only by the fail-open, read-only AgentCore quota check in `bag deploy prepare`. BNB/AWS share the agentcore scaffold. Treat an incompatible provider row as unavailable-do not force through it or mutate the scaffold during deploy.
|
|
9
|
+
|
|
10
|
+
Invoked as `/bnbagent-studio <ask>`? Treat `<ask>` as the user's intent and route it through the decision tree below, exactly like a natural-language ask.
|
|
23
11
|
|
|
24
12
|
## The single seller runtime model (the invariants)
|
|
25
13
|
|
|
26
|
-
One deployed runtime, one signer: a single valuable Agent serves the selected
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**no LLM touches money**) and **`notify_funded`** (verify the funded job →
|
|
32
|
-
produce the deliverable → submit on-chain; A2A acks then delivers in the
|
|
33
|
-
background, MCP delivers synchronously in the tool call). The optional x402
|
|
34
|
-
rail adds an anonymous HTTP request at `/x402`; positive prices settle through
|
|
35
|
-
B402 before work, while explicit zero is FREE passthrough and bypasses the
|
|
36
|
-
facilitator. It does not expose a general signing tool. Read-only chain
|
|
37
|
-
tools remain available. ALL signing is fixed entrypoint code in
|
|
38
|
-
`app/agent/src/signing.ts` or the runtime's bounded x402 payment handler, never
|
|
39
|
-
an LLM-callable tool. The encrypted keystore lives at the workspace root
|
|
40
|
-
`.studio/wallets/`, outside the deploy codeLocation, and is injected only via
|
|
41
|
-
the selected provider's delegated secret channel. `settle` is manual
|
|
42
|
-
(`bag erc8183 settle`). Full layout and lifecycle details live in the
|
|
43
|
-
references below — read them before acting.
|
|
44
|
-
|
|
45
|
-
## Decision tree — which reference to read next
|
|
46
|
-
|
|
47
|
-
**References are plain markdown files installed in THIS skill's directory** at
|
|
48
|
-
`references/<name>.md`. When a row matches, READ THAT FILE before acting — do
|
|
49
|
-
not answer from memory.
|
|
14
|
+
One deployed runtime, one signer: a single valuable Agent serves the selected faces (A2A `src/main.ts` on `:9000`, MCP `src/mcpMain.ts` on `:8000/mcp`, or A2A-native `src/dualMain.ts` on `:9000` with tunneled `/mcp`), holds the key, and signs in-process. The ERC-8183 rail exposes exactly two bounded operations - **`negotiate`** (rule-based price clamp + EIP-191 sign; **no LLM touches money**) and **`notify_funded`** (verify the funded job → produce the deliverable → submit on-chain; A2A acks then delivers in the background, MCP delivers synchronously in the tool call). The optional x402 rail adds an anonymous HTTP request at `/x402`; positive prices settle through B402 before work, while explicit zero is FREE passthrough and bypasses the facilitator. It does not expose a general signing tool. Read-only chain tools remain available. ALL signing is fixed entrypoint code in `app/agent/src/signing.ts` or the runtime's bounded x402 payment handler, never an LLM-callable tool. The encrypted keystore lives at the workspace root `.studio/wallets/`, outside the deploy codeLocation, and is injected only via the selected provider's delegated secret channel. `settle` is manual (`bag erc8183 settle`). Full layout and lifecycle details live in the references below - read them before acting.
|
|
15
|
+
|
|
16
|
+
## Decision tree - which reference to read next
|
|
17
|
+
|
|
18
|
+
**References are plain markdown files installed in THIS skill's directory** at `references/<name>.md`. When a row matches, READ THAT FILE before acting - do not answer from memory.
|
|
50
19
|
|
|
51
20
|
| User intent | Read / do |
|
|
52
|
-
|
|
21
|
+
| --- | --- |
|
|
53
22
|
| Create a brand new single seller project from zero | `references/bnbagent-studio-scaffolding-agent.md` |
|
|
54
23
|
| Add wallet / the single seller runtime to an existing TypeScript agent | `references/bnbagent-studio-adding-to-project.md` |
|
|
55
24
|
| Run / debug / dev / doctor / RPC / balance / incident triage | `references/bnbagent-studio-operating.md` |
|
|
@@ -57,58 +26,44 @@ not answer from memory.
|
|
|
57
26
|
| Sell one paid or FREE HTTP request through the B402-backed x402 rail (pricing choice; paid merchant application, RSA key, credentials, IP allowlist, activation) | `references/bnbagent-studio-selling-via-b402.md` |
|
|
58
27
|
| Deploy / redeploy / status / logs / destroy | Run `bag deploy` and explicitly choose a provider. Non-interactive deploy requires `--provider bnb\|aws --yes` (and `--allow-multiple` when keeping another provider active). Read `references/bnbagent-studio-use-bnb-trial.md` or `references/bnbagent-studio-use-aws-agentcore.md` for the selected provider. `bag deploy status` lists every recorded provider; multi-deployment logs/verify/destroy require `--provider`. |
|
|
59
28
|
| Wire chain-read tools into the Agent's LLM (AI SDK `tool()` wrappers, or any TS agent framework) | `references/bnbagent-studio-wiring-llm-tools.md` |
|
|
60
|
-
| Buy a service from another ERC-8183 seller via CLI
|
|
61
|
-
| Give the agent a PAID x402 capability
|
|
29
|
+
| Buy a service from another ERC-8183 seller via CLI - incl. testing your own seller from the buyer side (v2/internal - NOT the v1 seller product flow) | `references/bnbagent-studio-buying-via-8183.md` |
|
|
30
|
+
| Give the agent a PAID x402 capability - CMC market data / Binance Bazaar (B402) merchants / any pay-per-call API (`bag x402 trust`, x402-buyer recipe, 402 buyer errors) | `references/bnbagent-studio-buying-from-bazaar.md` |
|
|
62
31
|
| Extend the EIP-712 signing allowlist (custom contract / new x402 service / diagnose `PolicyViolation` / `X402PolicyError`) | `references/bnbagent-studio-extending-signing.md` |
|
|
63
32
|
| Project uses `[wallet].kind = "twak"` (create / fund / SIWE-bind / container deploy / known limitations) | `references/bnbagent-studio-using-twak-wallet.md` |
|
|
64
33
|
| Project uses `[wallet].kind = "altana"` (admin keystore / bounded session / quote checker / x402 allowance / local dev) | `references/bnbagent-studio-using-altana-wallet.md` |
|
|
65
34
|
| (Pieverse projects only) Fund the LLM, switch to a paid model, hit insufficient credits (`PieverseBudgetExhaustedError` / `PieverseAccountBalanceExhaustedError`) | skill `funding-pieverse-llm` (project-scope; emitted at `bag init --llm-provider pieverse-llm`) |
|
|
66
35
|
|
|
67
|
-
If two or more match, read both
|
|
36
|
+
If two or more match, read both - they're designed to be orthogonal.
|
|
68
37
|
|
|
69
38
|
### Where the references live
|
|
70
39
|
|
|
71
|
-
Next to this file: this skill installs as a directory with a `references/`
|
|
72
|
-
subdirectory (Claude Code: `~/.claude/skills/bnbagent-studio/references/` or the
|
|
73
|
-
project-scope `<project>/.claude/skills/bnbagent-studio/references/`; Cursor:
|
|
74
|
-
`bnbagent-studio/references/` under the rules directory, beside the `.mdc`
|
|
75
|
-
rules). If a reference file is missing, `bag skills install` (re)installs it.
|
|
40
|
+
Next to this file: this skill installs as a directory with a `references/` subdirectory (Claude Code: `~/.claude/skills/bnbagent-studio/references/` or the project-scope `<project>/.claude/skills/bnbagent-studio/references/`; Cursor: `bnbagent-studio/references/` under the rules directory, beside the `.mdc` rules). If a reference file is missing, `bag skills install` (re)installs it.
|
|
76
41
|
|
|
77
|
-
<!-- Maintainers: this skill's DESCRIPTION only carries ENTRY intents (identity
|
|
78
|
-
+ create/deploy/run/debug/operate/monetize). Mid-journey topics (twak, EIP-712,
|
|
79
|
-
disputes, buyer flow, tool wiring, ...) are routed by the decision tree above and
|
|
80
|
-
must NOT be added to the description — see docs/design/decisions.md §14. -->
|
|
42
|
+
<!-- Maintainers: this skill's DESCRIPTION only carries ENTRY intents (identity + create/deploy/run/debug/operate/monetize). Mid-journey topics such as twak, EIP-712, disputes, buyer flow, and tool wiring are routed by the decision tree above and must NOT be added to the description - see docs/design/decisions.md §14. -->
|
|
81
43
|
|
|
82
44
|
## 5 core commitments (always honor)
|
|
83
45
|
|
|
84
|
-
1. **Agent project code is user-owned**
|
|
85
|
-
2. **Private keys live in a user-controlled environment, never transmitted to studio or third parties**
|
|
86
|
-
3. **Signing is fixed handler code, never an LLM-callable tool**
|
|
87
|
-
4. **SDK protocol layer stays pure**
|
|
88
|
-
5. **The user can jump ship at any point**
|
|
46
|
+
1. **Agent project code is user-owned** - recipe-emitted files are theirs to edit; studio doesn't auto-rewrite them.
|
|
47
|
+
2. **Private keys live in a user-controlled environment, never transmitted to studio or third parties** - the encrypted keystore lives at the workspace root, outside the deploy codeLocation (no packaging path can bundle it). Altana keeps its admin keystore there and gives the runtime only a bounded session — local `bag dev` and deploy both receive the session (`ALTANA_SESSION`), never the admin keystore. Other supported deploy paths inject only their required wallet material into the selected runtime secret channel. (Scoped, consented exception: provider `bnb`, the 48h testnet trial - testnet-forced, throwaway wallet recommended.)
|
|
48
|
+
3. **Signing is fixed handler code, never an LLM-callable tool** - the ERC-8183 rail exposes bounded `negotiate` / `notify_funded` flows and the x402 rail exposes a bounded request handler; raw/arbitrary signing is never exposed. Read-only chain queries remain read-only tools.
|
|
49
|
+
4. **SDK protocol layer stays pure** - studio's opinions don't pollute `bnbagent-sdk`.
|
|
50
|
+
5. **The user can jump ship at any point** - emitted code is theirs to edit / fork / migrate; studio depends on no closed SaaS. Emitted code imports from `@bnbagent/studio-runtime` and depends on that runtime lib (not the CLI), so uninstalling the `@bnbagent/studio-cli` package never breaks a deployed agent.
|
|
89
51
|
|
|
90
|
-
Treat ERC-8183 amounts as decimal strings at CLI/config boundaries and
|
|
91
|
-
`bigint` internally. `price = "0"` is an explicit FREE choice, not a missing
|
|
92
|
-
value; it requires all three contract-address overrides from one verified
|
|
93
|
-
zero-price-compatible stack.
|
|
94
|
-
Treat B402 `price_usd` as a decimal string too. `"0"` is explicit anonymous
|
|
95
|
-
FREE passthrough: B402 verify/settle and secret injection are skipped. Positive
|
|
96
|
-
prices retain the paid merchant flow.
|
|
52
|
+
Treat ERC-8183 amounts as decimal strings at CLI/config boundaries and `bigint` internally. `price = "0"` is an explicit FREE choice, not a missing value; it requires all three contract-address overrides from one verified zero-price-compatible stack. Treat B402 `price_usd` as a decimal string too. `"0"` is explicit anonymous FREE passthrough: B402 verify/settle and secret injection are skipped. Positive prices retain the paid merchant flow.
|
|
97
53
|
|
|
98
54
|
## CLI groups at a glance
|
|
99
55
|
|
|
100
|
-
`init`, `scan`, `recipe`, `skills`, `wallet`, `erc8004`, `erc8183`, `x402`, `agents`, `config`, `env`, `dev`, `doctor`, `audit`, `deploy`, `platform`, `llm`, `bundle`, `budget`
|
|
56
|
+
`init`, `scan`, `recipe`, `skills`, `wallet`, `erc8004`, `erc8183`, `x402`, `agents`, `config`, `env`, `dev`, `doctor`, `audit`, `deploy`, `platform`, `llm`, `bundle`, `budget` - see `bag --help` for details. `bag deploy [--provider bnb\|aws]` is the primary deploy command; `prepare`, `verify`, `status`, `info`, `destroy`, `logs`, and `fix-gitignore` remain lifecycle subcommands (`deploy agent` is a deprecated compatibility alias). Provider deploy/status/logs/destroy and deploy-time credential validation are delegated to pinned `@bnbagent/deploy-cli@0.4.14`.
|
|
101
57
|
|
|
102
58
|
## Tool surface
|
|
103
59
|
|
|
104
|
-
- **CLI**
|
|
105
|
-
- **MCP**
|
|
106
|
-
|
|
107
|
-
- **`@bnbagent/studio-runtime/tools`** — 15 pure read-only functions, wrapped into LLM tools by the chain-tools recipe (read `references/bnbagent-studio-wiring-llm-tools.md`)
|
|
60
|
+
- **CLI** - write-side (wallet ops, on-chain register, x402 buy, deploy)
|
|
61
|
+
- **MCP** - an external seller face (`bag init --protocols MCP`), composable with A2A; dual mode is A2A-native so `HEALTHY_BUSY` preserves background work
|
|
62
|
+
- **`@bnbagent/studio-runtime/tools`** - 15 pure read-only functions, wrapped into LLM tools by the chain-tools recipe (read `references/bnbagent-studio-wiring-llm-tools.md`)
|
|
108
63
|
|
|
109
64
|
## Where docs live
|
|
110
65
|
|
|
111
|
-
- `docs/design/architecture.md`
|
|
112
|
-
- `docs/design/decisions.md`
|
|
113
|
-
- `docs/guides/pieverse-integration.md`
|
|
114
|
-
- `docs/guides/user-guide.md`
|
|
66
|
+
- `docs/design/architecture.md` - layered architecture
|
|
67
|
+
- `docs/design/decisions.md` - decision records (Pieverse default, signing policy, chain tools, zero-deposit, skill reorg, **single seller runtime + protocol faces**)
|
|
68
|
+
- `docs/guides/pieverse-integration.md` - Pieverse LLM full lifecycle
|
|
69
|
+
- `docs/guides/user-guide.md` - end-user procedures
|