@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
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bnbagent-studio-scaffolding-agent
|
|
3
|
-
description: When the user wants to create a brand-new blockchain SELLER from zero
|
|
3
|
+
description: When the user wants to create a brand-new blockchain SELLER from zero - a single valuable Agent on AWS Bedrock AgentCore that serves A2A by default or MCP optionally, holds the key, and signs in-process - earning $U on BNB Chain via ERC-8004 + ERC-8183 + x402. Drives the full intake → todo-list → execute flow.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
> **Reference file** of the `bnbagent-studio` router skill
|
|
6
|
+
> **Reference file** of the `bnbagent-studio` router skill - installed at `bnbagent-studio/references/` and loaded on demand (not a standalone skill). Route here via the router's decision tree.
|
|
7
7
|
|
|
8
8
|
# bnbagent-studio-scaffolding-agent
|
|
9
9
|
|
|
10
|
-
Procedure for **greenfield** seller creation. Audience: Claude Code (or another
|
|
11
|
-
agent) running in an empty directory with shell + edit access.
|
|
10
|
+
Procedure for **greenfield** seller creation. Audience: Claude Code (or another agent) running in an empty directory with shell + edit access.
|
|
12
11
|
|
|
13
|
-
**Different from** the `bnbagent-studio-adding-to-project.md` reference (in this same references/ directory): that one adds to an existing
|
|
14
|
-
repo; this one creates from zero.
|
|
12
|
+
**Different from** the `bnbagent-studio-adding-to-project.md` reference (in this same references/ directory): that one adds to an existing repo; this one creates from zero.
|
|
15
13
|
|
|
16
|
-
## The single seller runtime (
|
|
14
|
+
## The single seller runtime (current workspace layout)
|
|
17
15
|
|
|
18
|
-
`bag init` scaffolds a **blockchain seller** as a thin workspace root containing
|
|
19
|
-
**one sub-project** under `app/agent/`:
|
|
16
|
+
`bag init` scaffolds a **blockchain seller** as a thin workspace root containing **one sub-project** under `app/agent/`:
|
|
20
17
|
|
|
21
18
|
```
|
|
22
19
|
<name>/ workspace root (thin wrapper / deploy anchor)
|
|
@@ -28,272 +25,133 @@ repo; this one creates from zero.
|
|
|
28
25
|
│ │ names the deploy + drives `bag dev --container`)
|
|
29
26
|
│ ├── agentcore.json deploy descriptor (one native protocol + authorizerConfiguration)
|
|
30
27
|
│ └── aws-targets.json AWS account + region
|
|
31
|
-
├── .studio/
|
|
32
|
-
│
|
|
33
|
-
│
|
|
34
|
-
│ .studio/twak/ when project-dedicated)
|
|
28
|
+
├── .studio/ workspace-local state, outside the codeLocation
|
|
29
|
+
│ ├── .env.local wallet and provider secrets
|
|
30
|
+
│ └── wallets/ evm-local keystore; Agent sole reader
|
|
35
31
|
└── app/
|
|
36
|
-
└── agent/ the single sub-project
|
|
32
|
+
└── agent/ the single sub-project - the seller agent
|
|
37
33
|
├── package.json @bnbagent/studio-runtime + @bnbagent/sdk + ai (AI SDK)
|
|
38
34
|
│ + protocol deps (A2A: @a2a-js/sdk + express;
|
|
39
35
|
│ MCP: @modelcontextprotocol/sdk)
|
|
40
36
|
├── tsconfig.json builds src/ → dist/ (the deployed entrypoint is dist/*.js)
|
|
41
37
|
├── studio.toml wallet / llm / budget / payments.erc8183 bounds / payments.x402 / storage
|
|
42
|
-
├──
|
|
43
|
-
├── Dockerfile container deploy path (twak wallet kind)
|
|
38
|
+
├── Dockerfile container deploy path only (for example, twak)
|
|
44
39
|
└── src/ main.ts / mcpMain.ts / dualMain.ts / sellerCore.ts / executor.ts / agentCard.ts / signing.ts / tools.ts / model.ts
|
|
45
40
|
```
|
|
46
41
|
|
|
47
|
-
- **The Agent (`<name>/app/agent/`, → AWS Bedrock AgentCore).** ONE valuable agent
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- **`notify_funded`** → `signing.ts` `verifySignedJob` (synchronous) → delivery:
|
|
57
|
-
A2A ACKs then runs LLM work + `signing.ts` `submitResult` in the background
|
|
58
|
-
(plus a best-effort in-process sweep of other FUNDED jobs); MCP runs the work
|
|
59
|
-
and submit synchronously inside the tool call.
|
|
60
|
-
|
|
61
|
-
ALL signing is fixed `app/agent/src/signing.ts` code, **never** an LLM tool — the LLM
|
|
62
|
-
gets read-only chain tools only. The keystore lives at the **workspace root**
|
|
63
|
-
`.studio/wallets/` (outside the `app/agent/` codeLocation) and is injected at
|
|
64
|
-
deploy via AWS Secrets Manager — see Step 3 and Stage 4.
|
|
65
|
-
|
|
66
|
-
There is **no** second service, **no** keyless EC2 host, **no** `InvokeAgentRuntime`
|
|
67
|
-
relay, and **no** background poller. The agent is its own public surface.
|
|
68
|
-
|
|
69
|
-
v1 is **seller-only**; chat / buyer roles are deferred to v2. (A studio agent can
|
|
70
|
-
still *buy* other agents' 8183 services via `bag erc8183 buy/fetch/...`, but the
|
|
71
|
-
buyer flow is not yet productized.)
|
|
42
|
+
- **The Agent (`<name>/app/agent/`, → AWS Bedrock AgentCore).** ONE valuable agent (memory / tools / skills / KB / LLM) that **serves the selected faces** (A2A: `0.0.0.0:9000`; MCP: `0.0.0.0:8000/mcp`; A2A+MCP: A2A-native `dualMain.ts` on `:9000` with `/mcp` tunneled), holds the key, and signs **in-process**. Its outward surface is two fixed-code commerce operations (A2A skills on `SellerAgentExecutor`, or MCP tools on the MCP server):
|
|
43
|
+
- **`negotiate`** → rule-based list price CLAMPED to `[min,max]` → `signing.ts` `signQuote` EIP-191 sign. **No LLM.**
|
|
44
|
+
- **`notify_funded`** → `signing.ts` `verifySignedJob` (synchronous) → delivery: A2A ACKs then runs LLM work + `signing.ts` `submitResult` in the background (plus a best-effort in-process sweep of other FUNDED jobs); MCP runs the work and submit synchronously inside the tool call.
|
|
45
|
+
|
|
46
|
+
ALL signing is fixed `app/agent/src/signing.ts` code, **never** an LLM tool - the LLM gets read-only chain tools only. The keystore lives at the **workspace root** `.studio/wallets/` (outside the `app/agent/` codeLocation) and is injected at deploy via AWS Secrets Manager - see Step 3 and Stage 4.
|
|
47
|
+
|
|
48
|
+
There is **no** second service, **no** keyless EC2 host, **no** `InvokeAgentRuntime` relay, and **no** background poller. The agent is its own public surface.
|
|
49
|
+
|
|
50
|
+
v1 is **seller-only**; chat / buyer roles are deferred to v2. (A studio agent can still _buy_ other agents' 8183 services via `bag erc8183 buy/fetch/...`, but the buyer flow is not yet productized.)
|
|
72
51
|
|
|
73
52
|
## Preconditions
|
|
74
53
|
|
|
75
54
|
- Node.js ≥22 available.
|
|
76
|
-
- `bnbagent-studio` (the CLI) installed
|
|
77
|
-
(auto-pulls the `@bnbagent/studio-runtime` lib); for local dev use a monorepo
|
|
78
|
-
clone (`pnpm install` at the workspace root). `bag --version` works.
|
|
55
|
+
- `bnbagent-studio` (the CLI) installed - `npm install -g @bnbagent/studio-cli` (auto-pulls the `@bnbagent/studio-runtime` lib); for local dev use a monorepo clone (`pnpm install` at the workspace root). `bag --version` works.
|
|
79
56
|
- `bag skills install` was run so this skill is loaded.
|
|
80
|
-
- **Bun 1.3+ (`bunx`)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`bedrock-agentcore-starter-toolkit` shim some environments carry.
|
|
88
|
-
(Node ≥22 and `bag` itself are NOT re-checked in the flow: running the CLI
|
|
89
|
-
already required Node, and this skill only runs because `bag` is installed.)
|
|
90
|
-
- **Permission prompts on `bag` calls are normal — do not try to remove them.**
|
|
91
|
-
The IDE asking the user to confirm each `bag` command is the expected flow;
|
|
92
|
-
whether to allowlist anything is the user's own decision, made in their own
|
|
93
|
-
settings UI/file. NEVER edit permission settings yourself, NEVER run
|
|
94
|
-
`claude config` (or any equivalent) to grant yourself permissions, and do
|
|
95
|
-
not ask the user to pre-authorize `bag` — `bag:*` includes money-spending
|
|
96
|
-
commands (deploy, erc8183 buy/settle), so a blanket grant is unsafe.
|
|
97
|
-
- Current working directory is where the project should live. The project is
|
|
98
|
-
created at `<cwd>/<name>/` — pick the parent before triggering this skill.
|
|
99
|
-
|
|
100
|
-
## Stage 1 — Intake (collect ALL answers in one round, then echo back)
|
|
101
|
-
|
|
102
|
-
**Do not ask one question at a time.** Present the full form in a single
|
|
103
|
-
message, with defaults pre-filled. Accept the user's reply (which may be just
|
|
104
|
-
"go with defaults" or selective overrides), then echo a confirmation block and
|
|
105
|
-
proceed. This matches a shell-style prompt — one round-trip, then execute.
|
|
57
|
+
- **Bun 1.3+ (`bunx`) - needed for `bag deploy`, NOT for `bag init`.** Deploys delegate all cloud lifecycle mutations to the pinned `@bnbagent/deploy-cli`, run via `bunx --bun` (override with `BNBAGENT_DEPLOY_COMMAND`); `bag deploy prepare` fails a CRITICAL check when `bunx` is missing. The npm `@aws/agentcore` CLI is needed ONLY for `bag dev --container` (image-parity local runs). The optional AWS CLI is used only for a fail-open, read-only AgentCore quota check during `bag deploy prepare`. If the AgentCore CLI is installed, ensure the `agentcore` that resolves first on PATH is that npm CLI, not the incompatible `bedrock-agentcore-starter-toolkit` shim some environments carry. (Node ≥22 and `bag` itself are NOT re-checked in the flow: running the CLI already required Node, and this skill only runs because `bag` is installed.)
|
|
58
|
+
- **Permission prompts on `bag` calls are normal - do not try to remove them.** The IDE asking the user to confirm each `bag` command is the expected flow; whether to allowlist anything is the user's own decision, made in their own settings UI/file. NEVER edit permission settings yourself, NEVER run `claude config` (or any equivalent) to grant yourself permissions, and do not ask the user to pre-authorize `bag` - `bag:*` includes money-spending commands (deploy, erc8183 buy/settle), so a blanket grant is unsafe.
|
|
59
|
+
- Current working directory is where the project should live. The project is created at `<cwd>/<name>/` - pick the parent before triggering this skill.
|
|
60
|
+
|
|
61
|
+
## Stage 1 - Intake (collect ALL answers in one round, then echo back)
|
|
62
|
+
|
|
63
|
+
**Do not ask one question at a time.** Present the full form in a single message, with defaults pre-filled. Accept the user's reply (which may be just "go with defaults" or selective overrides), then echo a confirmation block and proceed. This matches a shell-style prompt - one round-trip, then execute.
|
|
106
64
|
|
|
107
65
|
The fields (give the user all of them at once):
|
|
108
66
|
|
|
109
67
|
| # | Field | Options | Default |
|
|
110
|
-
|
|
111
|
-
| 1 | **Project name** |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| 1 | **Project name** | Must start with a letter, contain ASCII letters and digits only, and be at most 23 characters. `bag init` rejects `-`, `_`, `.`, and overlong names instead of renaming them. For example: `newsagent`, `twcopywriter`. | (required) |
|
|
112
70
|
| 2 | **Network** | `bsc-testnet` / `bsc-mainnet` | `bsc-testnet` |
|
|
113
71
|
| 3 | **LLM provider** | `pieverse-llm` / `openrouter` / `openai` / `anthropic` / `bedrock` | `pieverse-llm` |
|
|
114
|
-
| 4 | **Wallet kind** (`--wallet-kind`) | `evm-local` (encrypted local keystore at the workspace root; `bag wallet new` creates it, `--private-key` imports an existing key; CodeZip deploy) / `twak` (**fully supported, opt in with `--wallet-kind twak`**
|
|
115
|
-
| 5 | **Storage** | `local` (file:// on disk, offline dev only, does **NOT** survive deploy) / `ipfs` (durable, public, deploy-ready; needs your pinning service's upload endpoint + write key as `STORAGE_API_URL` / `STORAGE_API_KEY` in `.studio/.env.local` **before the first real delivery**
|
|
72
|
+
| 4 | **Wallet kind** (`--wallet-kind`) | `evm-local` (encrypted local keystore at the workspace root; `bag wallet new` creates it, `--private-key` imports an existing key; CodeZip deploy) / `twak` (**fully supported, opt in with `--wallet-kind twak`** - Trust Wallet Agent Kit CLI ≥0.20.0, self-custody encrypted mnemonic in a **project-dedicated** home `.studio/twak`, isolated from your main `~/.twak`; created manually with `HOME=<ws>/.studio/twak twak wallet create`, then `bag wallet new` adopts; container deploy. Reuse an existing wallet across agents with `--twak-home <path>`) | `evm-local` |
|
|
73
|
+
| 5 | **Storage** | `local` (file:// on disk, offline dev only, does **NOT** survive deploy) / `ipfs` (durable, public, deploy-ready; needs your pinning service's upload endpoint + write key as `STORAGE_API_URL` / `STORAGE_API_KEY` in `.studio/.env.local` **before the first real delivery** - see Step 6b) | `local` |
|
|
116
74
|
| 6 | **Protocol faces** (`--protocols`) | any non-empty subset of `A2A`, `MCP`, `X402` | `A2A` |
|
|
117
75
|
| 7 | **LLM model** | provider catalogue; for `pieverse-llm` the default `auto/free` runs at $0/token | `auto/free` |
|
|
118
|
-
| 8 | **Auto-topup** | `enable` / `disable`
|
|
119
|
-
| 9 | **Scaffold destination** (`--destination`) | `self` (prepare the AgentCore scaffold for **your own** AWS account; runtime material stays under your cloud-account control) / `platform` (prepare for a 48h **testnet-only** trial on the BNB Chain managed platform
|
|
76
|
+
| 8 | **Auto-topup** | `enable` / `disable` - lets the Agent auto-pay $U from the wallet when LLM credits run low | deferred (non-interactive `bag init` records no `[budget]`; enable later with `bag budget enable`) |
|
|
77
|
+
| 9 | **Scaffold destination** (`--destination`) | `self` (prepare the AgentCore scaffold for **your own** AWS account; runtime material stays under your cloud-account control) / `platform` (prepare for a 48h **testnet-only** trial on the BNB Chain managed platform - runs the _same_ agent in the **operator's** AWS, so a wallet key **leaves your control**; it hard-forces `[network].default = bsc-testnet`, pins runtime=`agentcore`, packages an artifact, and auth is GitHub device flow. Use a **throwaway** `bag wallet new`, never your main wallet). This is scaffold intent only; deploy still explicitly selects `--provider`. | `platform` while the trial campaign runs (bare init falls back to `self` once it ends, or when `--network bsc-mainnet` / a non-agentcore `--runtime` is passed) |
|
|
120
78
|
| 10 | **ERC-8183 price** (`--erc8183-price`) | non-negative integer string in token base units; `0` explicitly selects FREE | `100000000000000000` (0.1 U) |
|
|
121
79
|
| 11 | **B402/x402 price** (`--b402-price`, when the b402 rail is selected) | non-negative decimal USD string; `0` explicitly selects anonymous FREE passthrough and bypasses B402 | `0.01` |
|
|
122
80
|
|
|
123
|
-
v1 is **seller-only**
|
|
124
|
-
single seller agent under `app/agent/` (serves the selected public faces,
|
|
125
|
-
sole signer).
|
|
126
|
-
Chat / buyer roles are deferred to v2.
|
|
81
|
+
v1 is **seller-only** - there is no role to choose. `bag init` scaffolds the single seller agent under `app/agent/` (serves the selected public faces, sole signer). Chat / buyer roles are deferred to v2.
|
|
127
82
|
|
|
128
|
-
**Architecture selections** (
|
|
129
|
-
**Render these as their own visible table in the intake form**, right after the
|
|
130
|
-
fields above — do NOT compress them to a one-line footnote: they are part of
|
|
131
|
-
the config the user is confirming, and "where's A2A / the runtime?" is a real
|
|
132
|
-
question. Each row: Field | Value | What it is.
|
|
83
|
+
**Architecture selections** (this playbook uses the advertised `agentcore` runtime; protocol faces are selected above). **Render these as their own visible table in the intake form**, right after the fields above - do NOT compress them to a one-line footnote: they are part of the config the user is confirming, and "where's A2A / the runtime?" is a real question. Each row: Field | Value | What it is.
|
|
133
84
|
|
|
134
85
|
| Field | Value | What it is |
|
|
135
|
-
|
|
136
|
-
| **Agent stack** | AI SDK (`ai`) | The library the agent's brain is built with
|
|
137
|
-
| **Runtime** | `agentcore` | AWS Bedrock AgentCore
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| **Agent stack** | AI SDK (`ai`) | The library the agent's brain is built with - the emitted `src/model.ts` factory returns an AI SDK `LanguageModel`, and `src/tools.ts` wraps the chain reads as AI SDK `tool()`s. (There is no `--framework` flag: the old framework axis folded into the runtime templates.) |
|
|
88
|
+
| **Runtime** | `agentcore` | AWS Bedrock AgentCore - where the agent is hosted and served (`--runtime agentcore`). |
|
|
138
89
|
| **Protocol faces** | selected above (`A2A` default; MCP/X402 composable) | A2A hosts agent card + JSON-RPC on `:9000`; MCP-only hosts `/mcp` on `:8000`; A2A+MCP uses A2A-native `dualMain.ts` on `:9000` and tunnels buffered MCP through the platform; X402 adds `/x402`, and X402-only suppresses protocol discovery. |
|
|
139
90
|
|
|
140
91
|
**Not surfaced** (handled automatically, no need to show or ask):
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- **IDE skill target**
|
|
92
|
+
|
|
93
|
+
- **Dependency install** - on by default (`bag init` runs the package install for the workspace unless `--no-install`).
|
|
94
|
+
- **IDE skill target** - auto-detected (`--ide`), falls back to `claude-code`.
|
|
144
95
|
|
|
145
96
|
The following are auto-included by default (don't ask, just mention in the confirmation block):
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- **LLM-credit auto-renew** via the emitted `app/agent/src/model.ts`
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
**automatic, budget-gated auto-renew hook** that tops up the active Pieverse
|
|
152
|
-
key before an LLM call when the cached balance is below the floor. The
|
|
153
|
-
stack-neutral credit-ensurer logic lives in
|
|
154
|
-
`@bnbagent/studio-runtime/pieverse` (`PieverseCreditEnsurer`); the AI-SDK
|
|
155
|
-
shell is in the emitted `app/agent/src/model.ts`. This is the ONLY automatic
|
|
156
|
-
signing path outside `signing.ts`; it rides on the hardened x402 buyer
|
|
157
|
-
kernel (`@bnbagent/studio-runtime/x402`) but is **not an LLM tool** — the
|
|
158
|
-
Agent (the sole key-holder) does it transparently inside the model wrapper.
|
|
159
|
-
If the budget gate is off / exhausted, the hook raises
|
|
160
|
-
`PieverseAccountBalanceExhaustedError` pointing at `bag llm topup --amount N`.
|
|
161
|
-
Opt out via `[llm.auto_renew].enabled = false`.
|
|
162
|
-
|
|
163
|
-
Also collect, if natural to gather: a one-sentence description of what the
|
|
164
|
-
agent does (used in the agent's instruction prompt and, later, in
|
|
165
|
-
ERC-8004 metadata when the user runs `bag deploy verify`).
|
|
97
|
+
|
|
98
|
+
- **Read-only chain tools** wired into the Agent's LLM (`app/agent/src/tools.ts`) - the LLM can query wallet / balances / ERC-8004 / ERC-8183 state but **never signs**.
|
|
99
|
+
- **LLM-credit auto-renew** via the emitted `app/agent/src/model.ts` - the Agent's `buildModel()` factory (in user-owned code) returns an AI SDK `LanguageModel` wrapped (via `wrapLanguageModel` middleware) with an **automatic, budget-gated auto-renew hook** that tops up the active Pieverse key before an LLM call when the cached balance is below the floor. The stack-neutral credit-ensurer logic lives in `@bnbagent/studio-runtime/pieverse` (`PieverseCreditEnsurer`); the AI-SDK shell is in the emitted `app/agent/src/model.ts`. This is the ONLY automatic signing path outside `signing.ts`; it rides on the hardened x402 buyer kernel (`@bnbagent/studio-runtime/x402`) but is **not an LLM tool** - the Agent (the sole key-holder) does it transparently inside the model wrapper. If the budget gate is off / exhausted, the hook raises `PieverseAccountBalanceExhaustedError` pointing at `bag llm topup --amount N`. Opt out via `[llm.auto_renew].enabled = false`.
|
|
100
|
+
|
|
101
|
+
Also collect, if natural to gather: a one-sentence description of what the agent does (used in the agent's instruction prompt and, later, in ERC-8004 metadata when the user runs `bag deploy verify`).
|
|
166
102
|
|
|
167
103
|
After collecting, **echo back** a confirmation block like:
|
|
168
104
|
|
|
169
105
|
```
|
|
170
106
|
Will create (single seller agent):
|
|
171
|
-
name: newsagent (≤23 chars, alphanumeric, letter-start
|
|
107
|
+
name: newsagent (≤23 chars, alphanumeric, letter-start - AgentCore rule)
|
|
172
108
|
agent: app/agent/ (AgentCore, --protocols <faces>, sole signer, signs in-process)
|
|
173
109
|
network: bsc-testnet
|
|
174
110
|
llm: pieverse-llm (model: auto/free, auto-renew enabled)
|
|
175
|
-
wallet: evm-local
|
|
176
|
-
(twak is fully supported too
|
|
177
|
-
storage: local (offline dev; switch to ipfs
|
|
111
|
+
wallet: evm-local - encrypted keystore at the workspace root (.studio/wallets/)
|
|
112
|
+
(twak is fully supported too - opt in with --wallet-kind twak)
|
|
113
|
+
storage: local (offline dev; switch to ipfs - needs a pinning endpoint + key - before deploy)
|
|
178
114
|
fixed: stack=AI SDK (model factory + tools), runtime=agentcore (AWS Bedrock AgentCore)
|
|
179
115
|
protocol: A2A (src/main.ts on 0.0.0.0:9000; local 127.0.0.1:9000)
|
|
180
116
|
or MCP (src/mcpMain.ts on 0.0.0.0:8000/mcp; local localhost:8000/mcp)
|
|
181
|
-
destination: platform (campaign default while the trial runs
|
|
182
|
-
or self (prepare for your own AWS Bedrock AgentCore; runtime material stays in your account
|
|
117
|
+
destination: platform (campaign default while the trial runs - 48h testnet on the operator's AWS; key leaves your machine, use a throwaway wallet)
|
|
118
|
+
or self (prepare for your own AWS Bedrock AgentCore; runtime material stays in your account - pass --destination self)
|
|
183
119
|
extras: read-only chain tools wired into the Agent LLM
|
|
184
120
|
location: /Users/.../newsagent/
|
|
185
121
|
|
|
186
122
|
Proceeding in 3 commands… (interrupt now if anything's off)
|
|
187
123
|
```
|
|
188
124
|
|
|
189
|
-
Then execute Stage 2 **without further prompts** until you hit a step that
|
|
190
|
-
genuinely requires user action (funding the wallet).
|
|
125
|
+
Then execute Stage 2 **without further prompts** until you hit a step that genuinely requires user action (funding the wallet).
|
|
191
126
|
|
|
192
|
-
## Stage 2
|
|
127
|
+
## Stage 2 - Generate a todo list (visible to the user)
|
|
193
128
|
|
|
194
|
-
Build a TodoWrite list. The shape depends on the `wallet kind`. The
|
|
195
|
-
canonical 8-step layout (evm-local default, Pieverse default LLM; plus a conditional
|
|
196
|
-
Step 6b when `storage=ipfs`):
|
|
129
|
+
Build a TodoWrite list. The shape depends on the `wallet kind`. The canonical 8-step layout (evm-local default, Pieverse default LLM; plus a conditional Step 6b when `storage=ipfs`):
|
|
197
130
|
|
|
198
|
-
> **Step 0
|
|
199
|
-
>
|
|
200
|
-
> delegate to the pinned `@bnbagent/deploy-cli` run via `bunx`, so Bun is only
|
|
201
|
-
> needed later, at `bag deploy` time. Do **not** re-check Node or `bag` (both
|
|
202
|
-
> are necessarily present — running the CLI required Node, and this skill only
|
|
203
|
-
> loads because `bag` is installed).
|
|
131
|
+
> **Step 0 - Pre-flight (informational; do NOT block `bag init` on it).** `bag init` self-renders the `agentcore/` deploy descriptor, and deploys delegate to the pinned `@bnbagent/deploy-cli` run via `bunx`, so Bun is only needed later, at `bag deploy` time. Do **not** re-check Node or `bag` (both are necessarily present - running the CLI required Node, and this skill only loads because `bag` is installed).
|
|
132
|
+
>
|
|
204
133
|
> ```bash
|
|
205
|
-
> command -v bunx >/dev/null || echo "bunx not found
|
|
134
|
+
> command -v bunx >/dev/null || echo "bunx not found - OK for init; install Bun 1.3+ before deploy: https://bun.sh"
|
|
206
135
|
> ```
|
|
207
|
-
>
|
|
208
|
-
> (Bun 1.3+, or set `BNBAGENT_DEPLOY_COMMAND`). Likewise for `bag dev
|
|
209
|
-
|
|
210
|
-
>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
> automatically (it prompts once for the wallet password, runs `bag wallet
|
|
215
|
-
> new`, zero-deposit-activates Pieverse, and prints faucet URLs). **You (Claude
|
|
216
|
-
> Code) drive `bag init` non-interactively**, so that auto-flow does NOT fire —
|
|
217
|
-
> keep steps 3/4/6 below. Pass `--no-onboard` to `bag init` to make this
|
|
218
|
-
> explicit and deterministic regardless of how the shell wires stdin.
|
|
219
|
-
|
|
220
|
-
1. `bag init <name> --llm-provider <p> --network <n> --storage-provider <s> --wallet-kind <k> --rails <8183|b402|both> [--erc8183-price <base-units>] [--b402-price <usd>] --no-onboard`
|
|
221
|
-
— scaffold the v0.0.1 workspace. **`<name>` must start with a letter and be
|
|
222
|
-
≤23 chars after sanitizing** — `bag init` auto-drops `-`/`_` for the
|
|
223
|
-
AgentCore name (printing what it used) but errors if the alphanumeric form
|
|
224
|
-
is >23 chars; prefer a clean alphanumeric name from Stage 1. Pass
|
|
225
|
-
`--wallet-kind evm-local` (default) or `--wallet-kind twak` (twak is fully
|
|
226
|
-
supported — pass the flag to opt in), and `--storage-provider local`
|
|
227
|
-
(default) or `ipfs`, per the Stage-1 choices; for twak, add
|
|
228
|
-
`--twak-home <path>` ONLY if the user wants to reuse an existing wallet
|
|
229
|
-
(otherwise omit — a project-dedicated `.studio/twak` is the safe default).
|
|
230
|
-
add `--protocols <comma-list>` when the user chose non-default or multiple
|
|
231
|
-
faces (omit for A2A default; `--protocol <one>` is only a legacy alias), add
|
|
232
|
-
`--model <m>` only if the user overrode the provider default, and
|
|
233
|
-
`--enable-auto-topup` / `--no-auto-topup` only if they made an explicit
|
|
234
|
-
choice (otherwise omit — consent stays deferred). Pass
|
|
235
|
-
`--erc8183-price 0` only when the user explicitly chose FREE; omitting the
|
|
236
|
-
flag preserves the paid 0.1 U default. FREE additionally requires all three
|
|
237
|
-
`ERC8183_COMMERCE_ADDRESS`, `ERC8183_ROUTER_ADDRESS`, and
|
|
238
|
-
`ERC8183_POLICY_ADDRESS` values from one zero-price-compatible custom
|
|
239
|
-
stack; set them with `bag env set` after scaffolding. For B402, pass
|
|
240
|
-
`--b402-price 0` only after the user explicitly accepts an unrestricted
|
|
241
|
-
anonymous FREE `/x402` endpoint. FREE bypasses B402 verify/settle and needs
|
|
242
|
-
no merchant credentials; a positive price keeps the `$0.01` default and
|
|
243
|
-
requires the paid onboarding playbook. **Destination:** while the
|
|
244
|
-
trial campaign runs, bare `bag init` (no `--destination`) defaults to
|
|
245
|
-
`platform` — so pass `--destination self` **explicitly** whenever the user
|
|
246
|
-
chose their own AWS, otherwise studio.toml silently records `platform` and the
|
|
247
|
-
confirmation block you echoed no longer matches what was written. Omit
|
|
248
|
-
`--destination` only when the user actually wants the `platform` 48h testnet
|
|
249
|
-
trial (the campaign default) — do NOT treat that default as a mistake or
|
|
250
|
-
re-confirm it; it is the intended behavior while the campaign is open. (Bare
|
|
251
|
-
init also resolves to `self` once the campaign ends, or when `--network
|
|
252
|
-
bsc-mainnet` / a non-agentcore `--runtime` is passed.) On the `platform` path
|
|
253
|
-
`bag init` hard-forces `bsc-testnet`, pins `--runtime agentcore` + packages an
|
|
254
|
-
artifact (a zip for the default evm-local wallet, a container for twak), and a
|
|
255
|
-
wallet key will later leave your machine, so pair it with a throwaway
|
|
256
|
-
`bag wallet new` (full flow: `docs/guides/platform-deploy.md`). Defaults
|
|
257
|
-
`--runtime agentcore` (the only self-deploy runtime in v0.0.1; there is no
|
|
258
|
-
`--framework` flag — the AI SDK model/tools story is part of the runtime
|
|
259
|
-
templates). Creates `<name>/` workspace root + `<name>/app/agent/` (the
|
|
260
|
-
single sub-project: A2A emits `src/main.ts` (the express + A2A entrypoint) +
|
|
261
|
-
`src/sellerCore.ts` (the protocol-neutral core; executor inherits it) +
|
|
262
|
-
`src/executor.ts` + `src/agentCard.ts`; MCP emits `src/mcpMain.ts`;
|
|
263
|
-
both include `src/signing.ts` + `src/tools.ts` + `src/model.ts` +
|
|
264
|
-
`Dockerfile` + own `studio.toml` + `.env.local` + `package.json` +
|
|
265
|
-
`tsconfig.json`) + `<name>/agentcore/` (`agentcore.json` +
|
|
266
|
-
`aws-targets.json`, self-rendered — no agentcore CLI needed at init). The
|
|
267
|
-
workspace root holds the `agentcore/` deploy descriptor, the
|
|
268
|
-
`.studio/wallets/` keystore, a thin `package.json` + `pnpm-workspace.yaml`,
|
|
269
|
-
README, and `.gitignore`. (v1 is seller-only — no `--role`.)
|
|
270
|
-
2. `cd <name>`, then make sure the dependencies are installed. `bag init`
|
|
271
|
-
already runs the install by default (skip only if it was scaffolded with
|
|
272
|
-
`--no-install`); the manual equivalent from the workspace root is:
|
|
136
|
+
>
|
|
137
|
+
> If Bun is missing at deploy time, **PAUSE** and have the USER install it (Bun 1.3+, or set `BNBAGENT_DEPLOY_COMMAND`). Likewise for `bag dev --container` only: the npm `@aws/agentcore` CLI must be present and must win on PATH over the incompatible `bedrock-agentcore-starter-toolkit` shim - global tools on the user's machine, so the user installs them, not you.
|
|
138
|
+
|
|
139
|
+
> **Onboarding note.** On a human TTY, `bag init` runs steps 3, 4 and 6 automatically (it prompts once for the wallet password, runs `bag wallet new`, zero-deposit-activates Pieverse, and prints faucet URLs). **You (Claude Code) drive `bag init` non-interactively**, so that auto-flow does NOT fire - keep steps 3/4/6 below. Pass `--no-onboard` to `bag init` to make this explicit and deterministic regardless of how the shell wires stdin.
|
|
140
|
+
|
|
141
|
+
1. `bag init <name> --llm-provider <p> --network <n> --storage-provider <s> --wallet-kind <k> --rails <8183|b402|both> [--erc8183-price <base-units>] [--b402-price <usd>] --no-onboard` - scaffold the current workspace. **`<name>` must start with a letter, use ASCII letters and digits only, and be at most 23 characters.** `bag init` rejects `-`, `_`, `.`, and overlong names instead of renaming them. Pass `--wallet-kind evm-local` (default) or `--wallet-kind twak` (twak is fully supported - pass the flag to opt in), and `--storage-provider local` (default) or `ipfs`, per the Stage-1 choices; for twak, add `--twak-home <path>` ONLY if the user wants to reuse an existing wallet (otherwise omit - a project-dedicated `.studio/twak` is the safe default). add `--protocols <comma-list>` when the user chose non-default or multiple faces (omit for A2A default; `--protocol <one>` is only a legacy alias), add `--model <m>` only if the user overrode the provider default, and `--enable-auto-topup` / `--no-auto-topup` only if they made an explicit choice (otherwise omit - consent stays deferred). Pass `--erc8183-price 0` only when the user explicitly chose FREE; omitting the flag preserves the paid 0.1 U default. FREE additionally requires all three `ERC8183_COMMERCE_ADDRESS`, `ERC8183_ROUTER_ADDRESS`, and `ERC8183_POLICY_ADDRESS` values from one zero-price-compatible custom stack; set them with `bag env set` after scaffolding. For B402, pass `--b402-price 0` only after the user explicitly accepts an unrestricted anonymous FREE `/x402` endpoint. FREE bypasses B402 verify/settle and needs no merchant credentials; a positive price keeps the `$0.01` default and requires the paid onboarding playbook. **Destination:** while the trial campaign runs, bare `bag init` (no `--destination`) defaults to `platform` - so pass `--destination self` **explicitly** whenever the user chose their own AWS, otherwise studio.toml silently records `platform` and the confirmation block you echoed no longer matches what was written. Omit `--destination` only when the user actually wants the `platform` 48h testnet trial (the campaign default) - do NOT treat that default as a mistake or re-confirm it; it is the intended behavior while the campaign is open. (Bare init also resolves to `self` once the campaign ends, or when `--network bsc-mainnet` / a non-agentcore `--runtime` is passed.) On the `platform` path `bag init` hard-forces `bsc-testnet`, pins `--runtime agentcore` + packages an artifact (a zip for the default evm-local wallet, a container for twak), and a wallet key will later leave your machine, so pair it with a throwaway `bag wallet new` (full flow: `docs/guides/platform-deploy.md`). Defaults `--runtime agentcore` (the only advertised runtime; the Preview `azure-foundry` runtime remains explicitly selectable but is outside this playbook; there is no `--framework` flag because the AI SDK model/tools story is part of the runtime templates). Creates `<name>/` workspace root + `<name>/app/agent/` (the single sub-project: A2A emits `src/main.ts` (the express + A2A entrypoint) + `src/sellerCore.ts` (the protocol-neutral core; executor inherits it) + `src/executor.ts` + `src/agentCard.ts`; MCP emits `src/mcpMain.ts`; both include `src/signing.ts` + `src/tools.ts` + `src/model.ts` + their own `studio.toml` + `package.json` + `tsconfig.json`) + `<name>/agentcore/` (`agentcore.json` + `aws-targets.json`, self-rendered - no agentcore CLI needed at init). The workspace root holds the `agentcore/` deploy descriptor, the `.studio/wallets/` keystore, a thin `package.json` + `pnpm-workspace.yaml`, README, and `.gitignore`. (v1 is seller-only - no `--role`.)
|
|
142
|
+
2. `cd <name>`, then make sure the dependencies are installed. `bag init` already runs the install by default (skip only if it was scaffolded with `--no-install`); the manual equivalent from the workspace root is:
|
|
273
143
|
```bash
|
|
274
|
-
pnpm install # npm install works too
|
|
144
|
+
pnpm install # npm install works too - tooling is the user's choice
|
|
275
145
|
```
|
|
276
|
-
The sub-project's `package.json` carries its deps:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
For local dev against unreleased libs, `bag init` vendors local `.tgz`
|
|
283
|
-
tarballs and points the manifest at them automatically.
|
|
284
|
-
3. **Set the wallet password** — the USER does this, NOT you.
|
|
285
|
-
|
|
286
|
-
🔒 **SECURITY — never route the wallet password through the chat.** It
|
|
287
|
-
encrypts the key material that is the Agent's sole signing key. Do **NOT**
|
|
288
|
-
ask the user to type it into the chat, and do **NOT** run any command with
|
|
289
|
-
the password on the command line (`bag env set <PW_VAR> <literal>`,
|
|
290
|
-
`twak wallet create --password <literal>`, …) — it would land in the
|
|
291
|
-
session transcript, be sent to the model API, and hit shell history / `ps`.
|
|
292
|
-
|
|
293
|
-
Tell the user to set it **themselves, in their own terminal**, so it never
|
|
294
|
-
reaches you. The env var depends on the wallet kind:
|
|
146
|
+
The sub-project's `package.json` carries its deps: `@bnbagent/studio-runtime` (the runtime lib, pinned to the scaffolding CLI's version range - NOT the CLI itself) + `@bnbagent/sdk` + `ai` (the AI SDK) plus the **protocol-specific** group - A2A adds `@a2a-js/sdk` + `express`, MCP adds `@modelcontextprotocol/sdk` instead (an A2A-only deploy never ships the MCP SDK, and an MCP-only deploy never ships the A2A one). For local dev against unreleased libs, `bag init` vendors local `.tgz` tarballs and points the manifest at them automatically.
|
|
147
|
+
3. **Set the wallet password** - the USER does this, NOT you.
|
|
148
|
+
|
|
149
|
+
🔒 **SECURITY - never route the wallet password through the chat.** It encrypts the key material that is the Agent's sole signing key. Do **NOT** ask the user to type it into the chat, and do **NOT** run any command with the password on the command line (`bag env set <PW_VAR> <literal>`, `twak wallet create --password <literal>`, …) - it would land in the session transcript, be sent to the model API, and hit shell history / `ps`.
|
|
150
|
+
|
|
151
|
+
Tell the user to set it **themselves, in their own terminal**, so it never reaches you. The env var depends on the wallet kind:
|
|
295
152
|
- **twak** → `TWAK_WALLET_PASSWORD` (the twak CLI reads it itself)
|
|
296
153
|
- **evm-local** → `WALLET_PASSWORD`
|
|
154
|
+
|
|
297
155
|
```bash
|
|
298
156
|
# In YOUR OWN terminal (not via the agent): open .studio/.env.local and
|
|
299
157
|
# set the line for your wallet kind:
|
|
@@ -301,149 +159,62 @@ Step 6b when `storage=ipfs`):
|
|
|
301
159
|
# WALLET_PASSWORD=<a strong password you choose> # evm-local
|
|
302
160
|
# Save it. Do not paste the password into this chat.
|
|
303
161
|
```
|
|
304
|
-
|
|
305
|
-
the line is set you do NOT need to `source` it or `cd` anywhere special
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
"../../.studio/twak"` — a **project-dedicated** wallet isolated from your
|
|
311
|
-
main `~/.twak`, so a deploy never pushes the main wallet's key material to
|
|
312
|
-
Secrets Manager. Setting it up is a ONE-TIME job: the user runs the
|
|
313
|
-
interactive 3-step `twak setup` wizard themselves in their own terminal,
|
|
314
|
-
then `bag wallet twak-init` creates the wallet (so the password never goes
|
|
315
|
-
into a command line). Start with the wizard:
|
|
162
|
+
|
|
163
|
+
`bag` auto-loads `.studio/.env.local` (resolved via the project root), so once the line is set you do NOT need to `source` it or `cd` anywhere special - `bag wallet new` / `bag llm activate` will read it. Wait for the user to confirm they've set it before continuing.
|
|
164
|
+
|
|
165
|
+
4. **Create / adopt the wallet** - depends on the wallet kind:
|
|
166
|
+
- **twak** (fully supported - opt in with `--wallet-kind twak`): `bag init` writes `[wallet].twak_home = "../../.studio/twak"` - a **project-dedicated** wallet isolated from your main `~/.twak`, so a deploy never pushes the main wallet's key material to Secrets Manager. Setting it up is a ONE-TIME job: the user runs the interactive 3-step `twak setup` wizard themselves in their own terminal, then `bag wallet twak-init` creates the wallet (so the password never goes into a command line). Start with the wizard:
|
|
167
|
+
|
|
316
168
|
```bash
|
|
317
169
|
HOME=<workspace>/.studio/twak twak setup
|
|
318
170
|
```
|
|
319
|
-
|
|
320
|
-
obvious and a wrong pick is dangerous:
|
|
321
|
-
- **Step 1 (API credentials):** paste Access ID + HMAC secret from
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
- **Step 2 (wire up harnesses): SELECT NONE, press ENTER** (don't press
|
|
325
|
-
SPACE/`a`) — never wire twak's signing MCP into Claude Code / Cursor /
|
|
326
|
-
etc.; studio keeps signing in fixed code, not MCP.
|
|
327
|
-
- **Step 3 (wallet): pick `3) Skip for now`**, then create the wallet with
|
|
328
|
-
the standalone command below. (`1) Create a new agent wallet` persists the
|
|
329
|
-
password via the OS keychain, which fails on keychain-less environments —
|
|
330
|
-
"OS keychain cannot persist passwords here … headless / Docker" — and
|
|
331
|
-
studio unlocks via `TWAK_WALLET_PASSWORD` env anyway. NEVER pick `2) Use
|
|
332
|
-
WalletConnect` = your main wallet.)
|
|
171
|
+
|
|
172
|
+
**Tell the user exactly what to pick at each wizard step** - it is not obvious and a wrong pick is dangerous:
|
|
173
|
+
- **Step 1 (API credentials):** paste Access ID + HMAC secret from https://portal.trustwallet.com/dashboard/apps; WalletConnect Project ID → leave blank, ENTER.
|
|
174
|
+
- **Step 2 (wire up harnesses): SELECT NONE, press ENTER** (don't press SPACE/`a`) - never wire twak's signing MCP into Claude Code / Cursor / etc.; studio keeps signing in fixed code, not MCP.
|
|
175
|
+
- **Step 3 (wallet): pick `3) Skip for now`**, then create the wallet with the standalone command below. (`1) Create a new agent wallet` persists the password via the OS keychain, which fails on keychain-less environments - "OS keychain cannot persist passwords here … headless / Docker" - and studio unlocks via `TWAK_WALLET_PASSWORD` env anyway. NEVER pick `2) Use WalletConnect` = your main wallet.)
|
|
333
176
|
|
|
334
177
|
```bash
|
|
335
178
|
cd app/agent && bag wallet twak-init # hidden prompt
|
|
336
179
|
printf %s "$PW" | bag wallet twak-init --password-stdin # CI / scripts
|
|
337
180
|
```
|
|
338
|
-
|
|
339
|
-
as `TWAK_WALLET_PASSWORD`. `twak-init` passes `--no-keychain`, which keeps
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
keystore, nowhere else on disk).
|
|
357
|
-
5. **Fund the wallet — OPTIONAL; do NOT block on it.** The default `auto/free`
|
|
358
|
-
LLM model runs at $0 and AgentCore deploy consumes no wallet balance, so a
|
|
359
|
-
brand-new seller can scaffold, run `bag dev`, and deploy with an empty
|
|
360
|
-
wallet. `bag doctor` and `bag deploy` only **WARN** (never block) on zero
|
|
361
|
-
balance. Funding is needed later only for: a paid LLM model, on-chain
|
|
362
|
-
settle, paying positive-price ERC-8183 job buys, or buying/smoking a PAID
|
|
363
|
-
B402 request. A FREE ERC-8183 buy needs no U
|
|
364
|
-
escrow or ERC-20 approval, but still needs the ERC-8183 state-changing calls
|
|
365
|
-
and their gas/paymaster path. A FREE B402/x402 request needs neither token
|
|
366
|
-
funding nor a facilitator call. When funding is needed, the wallet uses
|
|
367
|
-
**TWO distinct U balances on TWO chains** (same wallet address, same private
|
|
368
|
-
key, different chains):
|
|
369
|
-
|
|
370
|
-
- **tBNB (gas)** on BSC testnet: https://testnet.bnbchain.org/faucet-smart
|
|
371
|
-
— paste address
|
|
372
|
-
- **BSC mainnet U** (`0xcE24439F2D9C6a2289F741120FE202248B666666`) — for
|
|
373
|
-
Pieverse LLM topup. Minimum **0.2 U** recommended (0.1 for activate +
|
|
374
|
-
slack). Pieverse runs **only on mainnet chainId=56**; testnet U cannot
|
|
375
|
-
pay for LLM credits. Acquire via PancakeSwap. v0.0.1 does NOT
|
|
376
|
-
auto-refill from wallet — keep refilling Account Balance with
|
|
377
|
-
`bag llm topup` as you use credits.
|
|
378
|
-
- **BSC testnet U** (`0xc70B8741B8B07A6d61E54fd4B20f22Fa648E5565`) — for
|
|
379
|
-
ERC-8183 job payments if `[network].default = bsc-testnet`. Faucet:
|
|
380
|
-
https://united-coin-u.github.io/u-faucet/ (paste the agent wallet
|
|
381
|
-
address; see also `docs/guides/U-token-testnet.md`).
|
|
382
|
-
|
|
383
|
-
Both U balances live in the **same agent wallet** — one address, same
|
|
384
|
-
private key — just on different chains. Verify both with
|
|
385
|
-
`bag wallet balance --all`.
|
|
386
|
-
6. **Activate Pieverse LLM** (only if `llm=pieverse-llm`, default): `bag llm
|
|
387
|
-
activate` — **zero-deposit by default** (`--initial-usd` defaults to 0).
|
|
388
|
-
SIWE-logs in with the agent wallet (an off-chain EIP-191 signature — no gas,
|
|
389
|
-
no U), creates an `sk-pv-...` key with a $0 allocation, and writes
|
|
390
|
-
`PIEVERSE_LLM_API_KEY` to `.env.local` + `key_hash` to studio.toml. The
|
|
391
|
-
default model `auto/free` runs at $0/token, so **no funding is required to
|
|
392
|
-
start**. Only when you switch to a paid model do you fund the wallet and run
|
|
393
|
-
`bag llm topup --amount N` (then `[llm.auto_renew]` auto-**allocates** from
|
|
394
|
-
your Pieverse Account Balance to the key below the floor; v0.0.1 never
|
|
395
|
-
auto-spends wallet U). For non-Pieverse providers, manually set the API key
|
|
396
|
-
env var instead.
|
|
397
|
-
|
|
398
|
-
**Step 6b — Set the IPFS pinning credentials** (only when the user chose
|
|
399
|
-
`storage=ipfs`; `bag init` defaults to `local`). With `--storage-provider
|
|
400
|
-
ipfs` the Agent pins each deliverable to IPFS at delivery and publishes
|
|
401
|
-
`ipfs://CID` on-chain (durable, public, deploy-ready). Works with **any** IPFS
|
|
402
|
-
pinning service or a self-hosted node:
|
|
403
|
-
|
|
404
|
-
> Pick a pinning service and create a write key/JWT in its console (or run
|
|
405
|
-
> your own IPFS node — its `/api/v0/add` endpoint usually needs no key),
|
|
406
|
-
> then:
|
|
181
|
+
|
|
182
|
+
Use UPPER + lower + digit; put that same password in `.studio/.env.local` as `TWAK_WALLET_PASSWORD`. `twak-init` passes `--no-keychain`, which keeps the password out of the OS keychain (no macOS prompt); studio unlocks via the env. (If a macOS prompt _loops_ on a manual `twak` run, do NOT "Reset Default Keychain" - `pkill -9 -f twak`, then re-run with `--no-keychain`.) It also adopts the address into `studio.toml` and echoes it - confirm it's the intended wallet before funding/deploy, and there is no separate `bag wallet new` step. The manual equivalent is `HOME=<workspace>/.studio/twak twak wallet create --password <StrongPw> --no-keychain` followed by `bag wallet new`. Full detail: the `bnbagent-studio-using-twak-wallet.md` reference (in the router skill's `references/` directory). To reuse an EXISTING wallet across agents, scaffold with `bag init --twak-home <path-to-its-home>` instead. Reusing your main `~/.twak` is opt-in only (`--twak-home ~`) and discouraged. Full detail: the `bnbagent-studio-using-twak-wallet.md` reference (in the router skill's `references/` directory).
|
|
183
|
+
|
|
184
|
+
- **evm-local** (default): `bag wallet new` creates the encrypted keystore. To import an existing key, the user pastes it and you immediately run `bag wallet new --private-key <pk>` (the key is written only into the keystore, nowhere else on disk).
|
|
185
|
+
|
|
186
|
+
5. **Fund the wallet - OPTIONAL; do NOT block on it.** The default `auto/free` LLM model runs at $0 and AgentCore deploy consumes no wallet balance, so a brand-new seller can scaffold, run `bag dev`, and deploy with an empty wallet. `bag doctor` and `bag deploy` only **WARN** (never block) on zero balance. Funding is needed later only for: a paid LLM model, on-chain settle, paying positive-price ERC-8183 job buys, or buying/smoking a PAID B402 request. A FREE ERC-8183 buy needs no U escrow or ERC-20 approval, but still needs the ERC-8183 state-changing calls and their gas/paymaster path. A FREE B402/x402 request needs neither token funding nor a facilitator call. When funding is needed, the wallet uses **TWO distinct U balances on TWO chains** (same wallet address, same private key, different chains):
|
|
187
|
+
- **tBNB (gas)** on BSC testnet: https://testnet.bnbchain.org/faucet-smart - paste address
|
|
188
|
+
- **BSC mainnet U** (`0xcE24439F2D9C6a2289F741120FE202248B666666`) - for Pieverse LLM topup. Minimum **0.2 U** recommended (0.1 for activate + slack). Pieverse runs **only on mainnet chainId=56**; testnet U cannot pay for LLM credits. Acquire via PancakeSwap. Wallet-funded renewal stays off unless the operator explicitly enables it with `bag budget enable`; otherwise refill Account Balance with `bag llm topup` as needed.
|
|
189
|
+
- **BSC testnet U** (`0xc70B8741B8B07A6d61E54fd4B20f22Fa648E5565`) - for ERC-8183 job payments if `[network].default = bsc-testnet`. Faucet: https://united-coin-u.github.io/u-faucet/ (paste the agent wallet address; see also `docs/guides/U-token-testnet.md`).
|
|
190
|
+
|
|
191
|
+
Both U balances live in the **same agent wallet** - one address, same private key - just on different chains. Verify both with `bag wallet balance --all`.
|
|
192
|
+
|
|
193
|
+
6. **Activate Pieverse LLM** (only if `llm=pieverse-llm`, default): `bag llm activate` - **zero-deposit by default** (`--initial-usd` defaults to 0). SIWE-logs in with the agent wallet (an off-chain EIP-191 signature - no gas, no U), creates an `sk-pv-...` key with a $0 allocation, and writes `PIEVERSE_LLM_API_KEY` to `.env.local` + `key_hash` to studio.toml. The default model `auto/free` runs at $0/token, so **no funding is required to start**. Only when you switch to a paid model do you fund the wallet and run `bag llm topup --amount N` (then `[llm.auto_renew]` auto-**allocates** from your Pieverse Account Balance to the key below the floor; wallet U is spent only when `[budget]` has been explicitly enabled). For non-Pieverse providers, manually set the API key env var instead.
|
|
194
|
+
|
|
195
|
+
**Step 6b - Set the IPFS pinning credentials** (only when the user chose `storage=ipfs`; `bag init` defaults to `local`). With `--storage-provider ipfs` the Agent pins each deliverable to IPFS at delivery and publishes `ipfs://CID` on-chain (durable, public, deploy-ready). Works with **any** IPFS pinning service or a self-hosted node:
|
|
196
|
+
|
|
197
|
+
> Pick a pinning service and create a write key/JWT in its console (or run your own IPFS node - its `/api/v0/add` endpoint usually needs no key), then:
|
|
198
|
+
>
|
|
407
199
|
> ```bash
|
|
408
200
|
> bag env set STORAGE_API_URL <your-service-upload-endpoint>
|
|
409
201
|
> bag env set STORAGE_API_KEY <your-write-key>
|
|
410
202
|
> ```
|
|
411
|
-
>
|
|
412
|
-
> dev`, and deploy all work without them) but **required before the first
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
8. **Verify**: `bag doctor` — confirms the scaffold + Pieverse key activation
|
|
427
|
-
(if applicable) + config. Zero BNB / U are **WARN only** (not failures) —
|
|
428
|
-
funding is optional (see step 5), so do NOT refuse to continue on a balance
|
|
429
|
-
warning. Only refuse on real FAILs (missing keystore, unparseable config,
|
|
430
|
-
etc.).
|
|
431
|
-
|
|
432
|
-
**Do not** register ERC-8004 identity at this stage — it needs the deployed
|
|
433
|
-
agent's public AgentCore endpoint, so it happens **last** at deploy time
|
|
434
|
-
(`bag deploy verify`). Telling the user upfront:
|
|
435
|
-
|
|
436
|
-
> ERC-8004 on-chain identity registers at deploy time with your agent's public
|
|
437
|
-
> AgentCore endpoint (A2A card URL or MCP `/mcp` URL + access metadata). Skipped
|
|
438
|
-
> now so you don't burn gas before you know whether you'll ship this seller.
|
|
439
|
-
|
|
440
|
-
ERC-8183 service publishing is also a deploy-time concern — defer it.
|
|
441
|
-
|
|
442
|
-
Present the todo list to the user; ask "is this OK or do you want me to add/remove steps?"
|
|
443
|
-
**only if** the wallet kind is unusual (e.g. `evm-local` with a key import, or
|
|
444
|
-
`twak`). For the `evm-local` default, skip the confirmation and execute.
|
|
445
|
-
|
|
446
|
-
## Stage 3 — Execute step by step
|
|
203
|
+
>
|
|
204
|
+
> Written to `.studio/.env.local`. **OPTIONAL to start** (scaffold, `bag dev`, and deploy all work without them) but **required before the first real delivery submits on-chain** - without them the Agent can't pin to IPFS and delivery fails. You can also pass `--ipfs-key <key>` to `bag init` upfront. `bag doctor` WARNs (never blocks) while they're unset. For pure offline dev with no IPFS, scaffold with `--storage-provider local` instead (writes `STORAGE_LOCAL_PATH`, no key - but does NOT survive deploy: the deployed agent and your dev box don't share a filesystem).
|
|
205
|
+
|
|
206
|
+
7. **Recipe code is already emitted by `bag init`** - the `app/agent/` sub-project plus its `studio.toml` is written by step 1, so **skip manual recipe emission**. To re-emit or inspect a recipe later, `bag recipe code agent` / `bag recipe code runtimes/agentcore` (emits under `{{PKG}}` = the agent's `src/` dir; pass `--pkg <name>` to override). The real work is editing the Agent's `runWork` hook in `app/agent/src/sellerCore.ts` (A2A) / `app/agent/src/mcpMain.ts` (MCP) (see `bnbagent-studio-selling-via-8183.md` in this same directory).
|
|
207
|
+
8. **Verify**: `bag doctor` - confirms the scaffold + Pieverse key activation (if applicable) + config. Zero BNB / U are **WARN only** (not failures) - funding is optional (see step 5), so do NOT refuse to continue on a balance warning. Only refuse on real FAILs (missing keystore, unparseable config, etc.).
|
|
208
|
+
|
|
209
|
+
**Do not** register ERC-8004 identity at this stage - it needs the deployed agent's public AgentCore endpoint, so it happens **last** at deploy time (`bag deploy verify`). Telling the user upfront:
|
|
210
|
+
|
|
211
|
+
> ERC-8004 on-chain identity registers at deploy time with your agent's public AgentCore endpoint (A2A card URL or MCP `/mcp` URL + access metadata). Skipped now so you don't burn gas before you know whether you'll ship this seller.
|
|
212
|
+
|
|
213
|
+
ERC-8183 service publishing is also a deploy-time concern - defer it.
|
|
214
|
+
|
|
215
|
+
Present the todo list to the user; ask "is this OK or do you want me to add/remove steps?" **only if** the wallet kind is unusual (e.g. `evm-local` with a key import, or `twak`). For the `evm-local` default, skip the confirmation and execute.
|
|
216
|
+
|
|
217
|
+
## Stage 3 - Execute step by step
|
|
447
218
|
|
|
448
219
|
For each todo item:
|
|
449
220
|
|
|
@@ -454,25 +225,17 @@ For each todo item:
|
|
|
454
225
|
|
|
455
226
|
**Stop and ask the user** at:
|
|
456
227
|
|
|
457
|
-
- Step 3 (password): the USER sets it **themselves, in their own terminal**
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
Wait for the user to confirm before continuing.
|
|
463
|
-
- Step 5 (funding): OPTIONAL — only stop here if the user explicitly wants a paid LLM model, on-chain settle, or to pay ERC-8183 buys now. Otherwise skip; the `auto/free` default needs no funds.
|
|
464
|
-
- Step 6 (Pieverse activation): zero-deposit, so it just works — no funding precheck needed. If `bag llm activate` fails on connectivity, retry once.
|
|
465
|
-
- Step 6b (IPFS credentials): only when `storage=ipfs`. OPTIONAL now — do NOT block; the user picks a pinning service and runs `bag env set STORAGE_API_URL <url>` + `bag env set STORAGE_API_KEY <key>` themselves. Remind them they're required before the first real delivery (and `bag doctor` will keep WARNing until set). Skip entirely if they chose `local` storage.
|
|
466
|
-
- Business-logic step: ask the user what the Agent should produce when it delivers a job — the `runWork` hook in `app/agent/src/sellerCore.ts` (A2A) / `app/agent/src/mcpMain.ts` (MCP) is the developer hook. Leave the generic LLM passthrough stub if they don't know yet
|
|
228
|
+
- Step 3 (password): the USER sets it **themselves, in their own terminal** - never through the chat or on a command line (see Step 3's security note). They edit `.studio/.env.local` and set `TWAK_WALLET_PASSWORD` (twak) or `WALLET_PASSWORD` (evm-local). `bag` auto-loads that file, so once it's set `bag wallet new` / `bag llm activate` pick it up - no `source`/`cd` needed. Wait for the user to confirm before continuing.
|
|
229
|
+
- Step 5 (funding): OPTIONAL - only stop here if the user explicitly wants a paid LLM model, on-chain settle, or to pay ERC-8183 buys now. Otherwise skip; the `auto/free` default needs no funds.
|
|
230
|
+
- Step 6 (Pieverse activation): zero-deposit, so it just works - no funding precheck needed. If `bag llm activate` fails on connectivity, retry once.
|
|
231
|
+
- Step 6b (IPFS credentials): only when `storage=ipfs`. OPTIONAL now - do NOT block; the user picks a pinning service and runs `bag env set STORAGE_API_URL <url>` + `bag env set STORAGE_API_KEY <key>` themselves. Remind them they're required before the first real delivery (and `bag doctor` will keep WARNing until set). Skip entirely if they chose `local` storage.
|
|
232
|
+
- Business-logic step: ask the user what the Agent should produce when it delivers a job - the `runWork` hook in `app/agent/src/sellerCore.ts` (A2A) / `app/agent/src/mcpMain.ts` (MCP) is the developer hook. Leave the generic LLM passthrough stub if they don't know yet
|
|
467
233
|
|
|
468
|
-
**Never** ask the user to `echo "KEY=VALUE" >> .env.local`. Always call
|
|
469
|
-
`bag env set KEY VALUE` — it replaces the existing line if present, otherwise
|
|
470
|
-
appends, so it's safe to run repeatedly.
|
|
234
|
+
**Never** ask the user to `echo "KEY=VALUE" >> .env.local`. Always call `bag env set KEY VALUE` - it replaces the existing line if present, otherwise appends, so it's safe to run repeatedly.
|
|
471
235
|
|
|
472
|
-
## Stage 4
|
|
236
|
+
## Stage 4 - Summary
|
|
473
237
|
|
|
474
|
-
After step 8 passes (doctor clean
|
|
475
|
-
0 and that's fine), print:
|
|
238
|
+
After step 8 passes (doctor clean - Pieverse key activated; balances may be 0 and that's fine), print:
|
|
476
239
|
|
|
477
240
|
```
|
|
478
241
|
✅ <name> ready for local development (single seller agent).
|
|
@@ -498,7 +261,7 @@ When ready to deploy:
|
|
|
498
261
|
bag deploy verify --provider aws --endpoint <url> # delegated status + reconcile ERC-8004
|
|
499
262
|
|
|
500
263
|
Edit (from workspace root):
|
|
501
|
-
app/agent/src/sellerCore.ts or mcpMain.ts # the VALUE
|
|
264
|
+
app/agent/src/sellerCore.ts or mcpMain.ts # the VALUE - implement the runWork hook (your work product)
|
|
502
265
|
app/agent/src/signing.ts # fixed signing code (clamp + sign); NOT LLM tools
|
|
503
266
|
app/agent/src/tools.ts # read-only chain tools the LLM may call
|
|
504
267
|
app/agent/src/agentCard.ts # A2A only: advertised card (2 skills + OAuth2 scheme)
|
|
@@ -507,42 +270,13 @@ Edit (from workspace root):
|
|
|
507
270
|
|
|
508
271
|
## Gotchas
|
|
509
272
|
|
|
510
|
-
- **U is 18 decimals** (not 6 like USDC). The `@bnbagent/studio-runtime/networks`
|
|
511
|
-
|
|
512
|
-
- **`
|
|
513
|
-
|
|
514
|
-
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
argv). When **Claude Code** runs `bag init` (non-interactively, via the shell
|
|
518
|
-
tool) that auto-flow does NOT fire, so this skill drives Step 3/4 explicitly —
|
|
519
|
-
use `--no-onboard` to make the behavior deterministic. This skill bridges the
|
|
520
|
-
gap by collecting the wallet kind upfront and calling the right form.
|
|
521
|
-
- **The agent is the sole key-holder; the key material never enters the deploy
|
|
522
|
-
package.** For **evm-local** the encrypted keystore lives at the **workspace
|
|
523
|
-
root** `.studio/wallets/` (outside the `app/agent/` codeLocation, so no
|
|
524
|
-
packaging path can bundle it); for **twak**
|
|
525
|
-
the mnemonic lives at `~/.twak` (or `.studio/twak/`), never in the repo. Either
|
|
526
|
-
way it is injected at deploy via AWS Secrets Manager (default
|
|
527
|
-
`--secrets-mode secretsmanager`) — `WALLET_KEYSTORE_JSON` / `WALLET_PASSWORD`
|
|
528
|
-
for evm-local, `TWAK_WALLET_JSON` / `TWAK_CREDENTIALS_JSON` /
|
|
529
|
-
`TWAK_WALLET_PASSWORD` for twak — reconstructed at cold start, never in the
|
|
530
|
-
package; the testnet-only `--secrets-mode envvars` fallback is refused on
|
|
531
|
-
mainnet.
|
|
532
|
-
- **AgentCore seller endpoints are never anonymous.** `bag deploy --provider aws`
|
|
533
|
-
provisions the Cognito OAuth2 pool + buyer M2M client itself and prints the
|
|
534
|
-
token URL / client id / scope to hand to buyers (`bag deploy provision-cognito`
|
|
535
|
-
is deprecated — a deploy uses its own pool regardless). Locally, `bag dev` runs
|
|
536
|
-
without Cognito env, so the card omits the scheme and is reachable without a
|
|
537
|
-
token.
|
|
538
|
-
- **ERC-8183 does NOT require ERC-8004** at the protocol level (commerce contract
|
|
539
|
-
doesn't check the identity registry). Local two-agent dev can run end-to-end
|
|
540
|
-
without ever touching 8004. Use 8004 only when you actually want discoverable
|
|
541
|
-
identity.
|
|
542
|
-
- **Seller code that needs `ERC8183JobOps` directly** should import the public
|
|
543
|
-
`import { ERC8183JobOps } from "@bnbagent/sdk/erc8183"` — the headless
|
|
544
|
-
funded-job lifecycle ops. `getPendingJobs()` returns FUNDED jobs assigned to
|
|
545
|
-
this provider (the basis for the executor's best-effort sweep).
|
|
273
|
+
- **U is 18 decimals** (not 6 like USDC). The `@bnbagent/studio-runtime/networks` `toRaw`/`fromRaw` helpers handle this.
|
|
274
|
+
- **`buy_workflow`'s `deadline_minutes`** is the seller's _submission_ window. The on-chain job lifetime is automatically `deadline_minutes + 24h dispute_window`.
|
|
275
|
+
- **`bag init` runs wallet onboarding only on a human TTY** (evm-local: prompts for the password and runs `bag wallet new`; twak: adopts the existing twak wallet - never creates one, since `twak wallet create` puts the password on argv). When **Claude Code** runs `bag init` (non-interactively, via the shell tool) that auto-flow does NOT fire, so this skill drives Step 3/4 explicitly - use `--no-onboard` to make the behavior deterministic. This skill bridges the gap by collecting the wallet kind upfront and calling the right form.
|
|
276
|
+
- **The agent is the sole key-holder; the key material never enters the deploy package.** For **evm-local** the encrypted keystore lives at the **workspace root** `.studio/wallets/` (outside the `app/agent/` codeLocation, so no packaging path can bundle it); for **twak** the mnemonic lives at `~/.twak` (or `.studio/twak/`), never in the repo. Either way it is injected at deploy via AWS Secrets Manager (default `--secrets-mode secretsmanager`) - `WALLET_KEYSTORE_JSON` / `WALLET_PASSWORD` for evm-local, `TWAK_WALLET_JSON` / `TWAK_CREDENTIALS_JSON` / `TWAK_WALLET_PASSWORD` for twak - reconstructed at cold start, never in the package; the testnet-only `--secrets-mode envvars` fallback is refused on mainnet.
|
|
277
|
+
- **AgentCore seller endpoints are never anonymous.** `bag deploy --provider aws` provisions the Cognito OAuth2 pool + buyer M2M client itself and prints the token URL / client id / scope to hand to buyers (`bag deploy provision-cognito` is deprecated - a deploy uses its own pool regardless). Locally, `bag dev` runs without Cognito env, so the card omits the scheme and is reachable without a token.
|
|
278
|
+
- **ERC-8183 does NOT require ERC-8004** at the protocol level (commerce contract doesn't check the identity registry). Local two-agent dev can run end-to-end without ever touching 8004. Use 8004 only when you actually want discoverable identity.
|
|
279
|
+
- **Seller code that needs `ERC8183JobOps` directly** should import the public `import { ERC8183JobOps } from "@bnbagent/sdk/erc8183"` - the headless funded-job lifecycle ops. `getPendingJobs()` returns FUNDED jobs assigned to this provider (the basis for the executor's best-effort sweep).
|
|
546
280
|
|
|
547
281
|
## Reference
|
|
548
282
|
|