@bnbagent/studio-cli 0.0.6-alpha.6 → 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.
@@ -3,30 +3,20 @@ name: bnbagent-studio-selling-via-b402
3
3
  description: When the user wants a bnbagent-studio agent to sell paid or FREE HTTP requests through the B402-backed x402 rail. Owns the explicit pricing choice and, for PAID mode, per-agent merchant onboarding, RSA key preparation, egress-IP allowlisting, sandbox/production separation, B402 environment setup, seller status checks, and activation by redeploy (managed platform or self-hosted AgentCore).
4
4
  ---
5
5
 
6
- > **Reference file** of the `bnbagent-studio` router skill, installed at
7
- > `bnbagent-studio/references/` and loaded on demand (not a standalone skill).
8
- > Route here via the router's decision tree.
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.
9
7
 
10
8
  # Sell via B402
11
9
 
12
- Use this playbook to activate the x402 seller rail for one agent. First choose
13
- PAID or FREE explicitly. B402 merchant credentials are per agent and per
14
- environment and are needed only for PAID. Never reuse a merchant record across
15
- agent wallets, or mix sandbox and production values.
10
+ Use this playbook to activate the x402 seller rail for one agent. First choose PAID or FREE explicitly. B402 merchant credentials are per agent and per environment and are needed only for PAID. Never reuse a merchant record across agent wallets, or mix sandbox and production values.
16
11
 
17
12
  ## Preconditions
18
13
 
19
14
  - The agent wallet already exists. In PAID mode its address receives U.
20
- - The project targets the managed platform or self-hosted AgentCore
21
- (azure-foundry cannot activate the rail).
22
- - PAID managed platform only: an interactive GitHub-login session from
23
- `bag platform login` is available for reading the platform Relay egress
24
- IPs. A `bnbk_…` CI token does not satisfy this endpoint's GitHub-user check.
25
- - `[payments.x402_seller]` exists. If not, run
26
- `bag x402 sell init`.
15
+ - The project targets the managed platform or self-hosted AgentCore (azure-foundry cannot activate the rail).
16
+ - PAID managed platform only: an interactive GitHub-login session from `bag platform login` is available for reading the platform Relay egress IPs. A `bnbk_…` CI token does not satisfy this endpoint's GitHub-user check.
17
+ - `[payments.x402_seller]` exists. If not, run `bag x402 sell init`.
27
18
 
28
- The PAID application uses the **agent wallet address**, not a developer
29
- treasury, buyer wallet, or platform wallet.
19
+ The PAID application uses the **agent wallet address**, not a developer treasury, buyer wallet, or platform wallet.
30
20
 
31
21
  ## Choose PAID or FREE
32
22
 
@@ -38,28 +28,15 @@ bag x402 sell init --price-usd 0
38
28
  bag config set payments.x402_seller.price_usd 0
39
29
  ```
40
30
 
41
- `"0"` means anonymous FREE passthrough. The runtime returns work directly and
42
- does not issue a 402 challenge, call B402 `/supported`/verify/settle, transfer
43
- U, or write an `x402_sell` settlement audit. B402 credentials are ignored and
44
- not synchronized. Run `bag x402 sell status`, `bag doctor`, and
45
- `bag deploy prepare`; all must label the route FREE.
31
+ `"0"` means anonymous FREE passthrough. The runtime returns work directly and does not issue a 402 challenge, call B402 `/supported`/verify/settle, transfer U, or write an `x402_sell` settlement audit. B402 credentials are ignored and not synchronized. Run `bag x402 sell status`, `bag doctor`, and `bag deploy prepare`; all must label the route FREE.
46
32
 
47
- This is unrestricted public access. Confirm that intent before continuing.
48
- Managed platform still publishes the route through its gateway; self-hosted
49
- AgentCore still needs an envelope-v1 front; Azure Foundry remains unsupported.
50
- If FREE is the selected product, skip the merchant/RSA/IP sections below.
33
+ This is unrestricted public access. Confirm that intent before continuing. Managed platform still publishes the route through its gateway; self-hosted AgentCore still needs an envelope-v1 front; Azure Foundry remains unsupported. If FREE is the selected product, skip the merchant/RSA/IP sections below.
51
34
 
52
35
  ## Generate the agent's RSA material
53
36
 
54
- This playbook is the canonical key-generation procedure; neither the CLI nor
55
- the B402 SDK generates keys. The pair authenticates every facilitator API
56
- call under the
57
- [B402 request-signing scheme](https://developers.binance.com/en/docs/products/onchainpay-x402/basics/3.request-signing);
58
- the runtime signs each request automatically once the credentials are stored.
37
+ This playbook is the canonical key-generation procedure; neither the CLI nor the B402 SDK generates keys. The pair authenticates every facilitator API call under the [B402 request-signing scheme](https://developers.binance.com/en/docs/products/onchainpay-x402/basics/3.request-signing); the runtime signs each request automatically once the credentials are stored.
59
38
 
60
- Work from the workspace root. Keep private material under `.studio/`, which is
61
- excluded from source and deploy artifacts. Generate a separate key pair for
62
- each environment:
39
+ Work from the workspace root. Keep private material under `.studio/`, which is excluded from source and deploy artifacts. Generate a separate key pair for each environment:
63
40
 
64
41
  ```bash
65
42
  umask 077
@@ -79,25 +56,15 @@ chmod 600 ".studio/b402/$b402_env/private.pem" \
79
56
  ".studio/b402/$b402_env/private.der.b64"
80
57
  ```
81
58
 
82
- Do not print the private key or its base64 form. Submit only the public key
83
- material to B402.
59
+ Do not print the private key or its base64 form. Submit only the public key material to B402.
84
60
 
85
- The current B402 request-signing contract explicitly requires a 1024-bit RSA
86
- key and RSA-SHA256. Follow that protocol requirement even if a larger RSA key
87
- would normally be preferred elsewhere. Repeat with `b402_env=production`
88
- instead of reusing the sandbox pair.
61
+ The current B402 request-signing contract explicitly requires a 1024-bit RSA key and RSA-SHA256. Follow that protocol requirement even if a larger RSA key would normally be preferred elsewhere. Repeat with `b402_env=production` instead of reusing the sandbox pair.
89
62
 
90
63
  ## Collect the IP allowlist
91
64
 
92
- B402 allowlists the merchant's **outbound** (egress) IPs, the addresses the
93
- agent's facilitator calls come FROM. Submit every part that applies to your
94
- deployment target:
65
+ B402 allowlists the merchant's **outbound** (egress) IPs, the addresses the agent's facilitator calls come FROM. Submit every part that applies to your deployment target:
95
66
 
96
- 1. **Platform Relay egress IPs (managed-platform deploys)**: the addresses
97
- that the platform B402 Relay uses to reach the facilitator. The managed
98
- deployment worker points only the AgentCore runtime copy of
99
- `B402_BASE_URL` at this Relay. Refresh and read the interactive session
100
- without printing its bearer:
67
+ 1. **Platform Relay egress IPs (managed-platform deploys)**: the addresses that the platform B402 Relay uses to reach the facilitator. The managed deployment worker points only the AgentCore runtime copy of `B402_BASE_URL` at this Relay. Refresh and read the interactive session without printing its bearer:
101
68
 
102
69
  ```bash
103
70
  bag platform whoami >/dev/null
@@ -110,48 +77,26 @@ deployment target:
110
77
  # → {"whitelist_ips": ["13.115.15.190", …], "cache_ttl_seconds": 300}
111
78
  ```
112
79
 
113
- Submit every address in `whitelist_ips`. The list is served with a short
114
- cache TTL and can rotate, so re-read it right before submitting the form.
115
- The login session is stored mode `0600`. Do not echo, log, or paste its
116
- access or refresh token. `bnbk_` tokens from `bag platform token` are
117
- deliberately rejected by this GitHub-login-only endpoint.
80
+ Submit every address in `whitelist_ips`. The list is served with a short cache TTL and can rotate, so re-read it right before submitting the form. The login session is stored mode `0600`. Do not echo, log, or paste its access or refresh token. `bnbk_` tokens from `bag platform token` are deliberately rejected by this GitHub-login-only endpoint.
118
81
 
119
- 2. **Your local public IP**: required so a local `bag dev` run can reach
120
- B402:
82
+ 2. **Your local public IP**: required so a local `bag dev` run can reach B402:
121
83
 
122
84
  ```bash
123
85
  curl ipinfo.io/ip
124
86
  ```
125
87
 
126
- 3. **Self-hosted AgentCore egress (self-deploys)**: operate a restricted B402
127
- Relay on a host with a fixed public egress IP, such as a user-managed VPS,
128
- and submit that IP. Set the runtime `B402_BASE_URL` to the Relay base URL.
129
- The Relay exposes only
130
- `supported`, `verify`, and `settle`, fixes the upstream facilitator, and
131
- forwards the signed body and Tesla header allowlist without holding the
132
- merchant private key or automatically retrying a settlement transport
133
- failure. See the
134
- [self-hosted x402 gateway guide](https://github.com/bnb-chain/bnbagent-studio/blob/main/docs/guides/self-hosted-x402-gateway.md)
135
- for a TypeScript example.
136
-
137
- As an alternative, use AWS-supported AgentCore VPC mode with a private subnet, NAT
138
- Gateway, and Elastic IP. Submit the Elastic IP and keep
139
- `B402_BASE_URL` pointed at the facilitator. Studio does not deploy or
140
- manage that AWS network.
141
-
142
- Do not add the public inbound gateway IP, a transient build-runner IP, or
143
- guessed addresses. If the whitelist endpoint is unreachable, stop onboarding
144
- and confirm the platform environment with the operator.
88
+ 3. **Self-hosted AgentCore egress (self-deploys)**: operate a restricted B402 Relay on a host with a fixed public egress IP, such as a user-managed VPS, and submit that IP. Set the runtime `B402_BASE_URL` to the Relay base URL. The Relay exposes only `supported`, `verify`, and `settle`, fixes the upstream facilitator, and forwards the signed body and Tesla header allowlist without holding the merchant private key or automatically retrying a settlement transport failure. See the [self-hosted x402 gateway guide](https://github.com/bnb-chain/bnbagent-studio/blob/main/docs/guides/self-hosted-x402-gateway.md) for a TypeScript example.
89
+
90
+ As an alternative, use AWS-supported AgentCore VPC mode with a private subnet, NAT Gateway, and Elastic IP. Submit the Elastic IP and keep `B402_BASE_URL` pointed at the facilitator. Studio does not deploy or manage that AWS network.
91
+
92
+ Do not add the public inbound gateway IP, a transient build-runner IP, or guessed addresses. If the whitelist endpoint is unreachable, stop onboarding and confirm the platform environment with the operator.
145
93
 
146
94
  ## Submit the B402 merchant application
147
95
 
148
- Apply through the
149
- [B402 developer account application](https://developers.binance.com/en/docs/products/onchainpay-x402/basics/6.apply-developer-account).
150
- Complete one application for sandbox and a separate application for
151
- production. Fill the form as follows:
96
+ Apply through the [B402 developer account application](https://developers.binance.com/en/docs/products/onchainpay-x402/basics/6.apply-developer-account). Complete one application for sandbox and a separate application for production. Fill the form as follows:
152
97
 
153
98
  | Field | Value |
154
- |---|---|
99
+ | --- | --- |
155
100
  | Business Name | Your agent or business display name |
156
101
  | Email | Primary contact email address |
157
102
  | Wallet address | The agent wallet for that environment |
@@ -161,15 +106,14 @@ production. Fill the form as follows:
161
106
 
162
107
  Keep the two environments isolated:
163
108
 
164
- | Environment | Chain | Credentials | Wallet/IP registration |
165
- |---|---|---|---|
166
- | Sandbox | BSC testnet | sandbox-only | apply separately |
167
- | Production | BSC mainnet | production-only | apply separately |
109
+ | Environment | Chain | Credentials | Wallet/IP registration |
110
+ | ----------- | ----------- | --------------- | ---------------------- |
111
+ | Sandbox | BSC testnet | sandbox-only | apply separately |
112
+ | Production | BSC mainnet | production-only | apply separately |
168
113
 
169
114
  ## Store the issued credentials
170
115
 
171
- Open the workspace `.studio/.env.local` in an editor and fill exactly four
172
- values:
116
+ Open the workspace `.studio/.env.local` in an editor and fill exactly four values:
173
117
 
174
118
  ```dotenv
175
119
  B402_BASE_URL=
@@ -178,21 +122,11 @@ B402_ACCESS_TOKEN=
178
122
  B402_PRIVATE_KEY_B64=
179
123
  ```
180
124
 
181
- Copy the single-line DER value from
182
- `.studio/b402/<environment>/private.der.b64` into `B402_PRIVATE_KEY_B64`.
183
- `B402_BASE_URL`, `B402_CLIENT_ID`, and `B402_ACCESS_TOKEN` are the values
184
- issued together for that environment. Do not include any value in shell
185
- history, terminal output, source files, TOML, screenshots, or support tickets.
125
+ Copy the single-line DER value from `.studio/b402/<environment>/private.der.b64` into `B402_PRIVATE_KEY_B64`. `B402_BASE_URL`, `B402_CLIENT_ID`, and `B402_ACCESS_TOKEN` are the values issued together for that environment. Do not include any value in shell history, terminal output, source files, TOML, screenshots, or support tickets.
186
126
 
187
- `B402_PRIVATE_KEY` accepts the PEM representation as an alternative. Keep
188
- exactly one private-key form; do not set both.
127
+ `B402_PRIVATE_KEY` accepts the PEM representation as an alternative. Keep exactly one private-key form; do not set both.
189
128
 
190
- For the current managed BSC Testnet path, the platform-supported upstream is
191
- `https://qacb.sdtaop.com`; the worker projects only the AgentCore runtime copy
192
- to its Relay. For a generic self-hosted environment, use the authenticated
193
- base URL issued during onboarding. With your own Relay, set the runtime
194
- `B402_BASE_URL` to that Relay base URL and configure the Relay's fixed upstream
195
- to the issued URL.
129
+ For the current managed BSC Testnet path, the platform-supported upstream is `https://qacb.sdtaop.com`; the worker projects only the AgentCore runtime copy to its Relay. For a generic self-hosted environment, use the authenticated base URL issued during onboarding. With your own Relay, set the runtime `B402_BASE_URL` to that Relay base URL and configure the Relay's fixed upstream to the issued URL.
196
130
 
197
131
  ## Verify and activate
198
132
 
@@ -202,16 +136,13 @@ For PAID mode, check names and presence without exposing values:
202
136
  bag x402 sell status --no-probe
203
137
  ```
204
138
 
205
- When the credentials, IP allowlist, and facilitator environment are ready, run
206
- the authenticated read-only capability check:
139
+ When the credentials, IP allowlist, and facilitator environment are ready, run the authenticated read-only capability check:
207
140
 
208
141
  ```bash
209
142
  bag x402 sell status
210
143
  ```
211
144
 
212
- For a sandbox/trial agent, it must find exact/eip3009 U on `eip155:97`. For
213
- production it must find the mainnet environment expected by the project. A
214
- network mismatch is not safe to ignore.
145
+ For a sandbox/trial agent, it must find exact/eip3009 U on `eip155:97`. For production it must find the mainnet environment expected by the project. A network mismatch is not safe to ignore.
215
146
 
216
147
  Run the deployment gate, then redeploy to activate the selected mode:
217
148
 
@@ -221,38 +152,15 @@ bag deploy --provider bnb # managed platform
221
152
  bag deploy --provider aws # self-hosted AgentCore
222
153
  ```
223
154
 
224
- On the managed platform the deploy summary must say `x402 rail is ACTIVE` (or
225
- `ACTIVE in FREE mode`) and print the anonymous `/x402` URL. On a self-hosted
226
- AgentCore deploy it says `x402 rail is ACTIVE (self-hosted AgentCore)` or
227
- `ACTIVE in FREE mode (self-hosted AgentCore)`: the rail runs in-process, but
228
- there is no anonymous URL. Operate your own HTTP front that relays envelope-v1
229
- JSON through an authenticated AgentCore invocation. The default Bag
230
- self-deploy uses Cognito OAuth over raw HTTPS; AWS SDK/SigV4 is only for a
231
- runtime deliberately configured with IAM authorization. PAID also needs your
232
- own fixed-egress B402 Relay or equivalent network path. The complete gateway
233
- wrapper, response parser, Relay example, and direct-invocation fallback are in
234
- the
235
- [self-hosted x402 gateway guide](https://github.com/bnb-chain/bnbagent-studio/blob/main/docs/guides/self-hosted-x402-gateway.md).
236
- A dormant or forced-dormant summary means the rail was not activated; fix the
237
- named credential, runtime, network, or tunnel condition and redeploy.
155
+ On the managed platform the deploy summary must say `x402 rail is ACTIVE` (or `ACTIVE in FREE mode`) and print the anonymous `/x402` URL. On a self-hosted AgentCore deploy it says `x402 rail is ACTIVE (self-hosted AgentCore)` or `ACTIVE in FREE mode (self-hosted AgentCore)`: the rail runs in-process, but there is no anonymous URL. Operate your own HTTP front that relays envelope-v1 JSON through an authenticated AgentCore invocation. The default Bag self-deploy uses Cognito OAuth over raw HTTPS; AWS SDK/SigV4 is only for a runtime deliberately configured with IAM authorization. PAID also needs your own fixed-egress B402 Relay or equivalent network path. The complete gateway wrapper, response parser, Relay example, and direct-invocation fallback are in the [self-hosted x402 gateway guide](https://github.com/bnb-chain/bnbagent-studio/blob/main/docs/guides/self-hosted-x402-gateway.md). A dormant or forced-dormant summary means the rail was not activated; fix the named credential, runtime, network, or tunnel condition and redeploy.
238
156
 
239
157
  ## Hard rules
240
158
 
241
159
  - Never log or print any B402 value or private key.
242
160
  - Never put a B402 value in `studio.toml` or a deploy descriptor.
243
- - Never replay a paid HTTP request whose outcome is unknown. Follow
244
- `docs/guides/x402-selling.md` and reconcile `(nonce, network, payer)` first.
245
- - Binance `/settle` is asynchronous. A parseable `success: false` response
246
- with a transaction is pending and requires an idempotent poll with the same
247
- settlement payload. Studio v0.0.6 and the latest
248
- `@bnb-chain/b402@0.1.0` do not yet perform that poll; they classify pending
249
- as unknown. Do not claim current mainnet readiness until this is updated.
250
- - Settlement happens before work. A later work failure retains the payment and
251
- does not trigger an automatic refund.
252
- - The rail activates on AgentCore targets only (managed platform or
253
- self-hosted); azure-foundry stays forced dormant.
254
- - PAID B402 payout wallets must use `wallet.kind` `evm-local` (private-key
255
- wallet stored as an encrypted keystore) or `twak`. Altana is unsupported.
256
- FREE x402 bypasses B402, has no payout, and must not be described as Altana
257
- B402 support.
161
+ - Never replay a paid HTTP request whose outcome is unknown. Follow `docs/guides/x402-selling.md` and reconcile `(nonce, network, payer)` first.
162
+ - Binance `/settle` is asynchronous. A parseable `success: false` response with a transaction is pending and requires an idempotent poll with the same settlement payload. Studio v0.0.6 and the latest `@bnb-chain/b402@0.1.0` do not yet perform that poll; they classify pending as unknown. Do not claim current mainnet readiness until this is updated.
163
+ - Settlement happens before work. A later work failure retains the payment and does not trigger an automatic refund.
164
+ - The rail activates on AgentCore targets only (managed platform or self-hosted); azure-foundry stays forced dormant.
165
+ - PAID B402 payout wallets must use `wallet.kind` `evm-local` (private-key wallet stored as an encrypted keystore) or `twak`. Altana is unsupported. FREE x402 bypasses B402, has no payout, and must not be described as Altana B402 support.
258
166
  - Never describe FREE as a zero-value B402 settlement. It bypasses B402.
@@ -1,28 +1,15 @@
1
1
  ---
2
2
  name: bnbagent-studio-use-aws-agentcore
3
- description: When the user wants to deploy or operate a bnbagent-studio project on AWS Bedrock AgentCore deploy with `bag deploy --provider aws` (ALL cloud execution is delegated to pinned `@bnbagent/deploy-cli@0.4.14`), inspect with `bag deploy status` / `logs --provider aws` / `verify --provider aws`, and tear down with `bag deploy destroy --provider aws --execute [--purge]`. Also covers AWS credential prerequisites and the runtime-secret channel.
3
+ description: When the user wants to deploy or operate a bnbagent-studio project on AWS Bedrock AgentCore - deploy with `bag deploy --provider aws` (all cloud lifecycle mutations are delegated to pinned `@bnbagent/deploy-cli@0.4.14`), inspect with `bag deploy status` / `logs --provider aws` / `verify --provider aws`, and tear down with `bag deploy destroy --provider aws --execute [--purge]`. Also covers AWS credential prerequisites, the optional read-only quota probe, and the runtime-secret channel.
4
4
  ---
5
5
 
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.
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-use-aws-agentcore
9
9
 
10
- Procedure for deploying and operating the seller Agent on **AWS Bedrock
11
- AgentCore** via the **delegated deploy**: `bag deploy --provider aws` hands a generated
12
- deploy spec to the pinned **`@bnbagent/deploy-cli`** (run via `bunx --bun`;
13
- override the command with `BNBAGENT_DEPLOY_COMMAND`), which executes every
14
- cloud step through the AWS SDK under the user's credentials. There is **no
15
- `aws` CLI, no CDK deploy, and no `agentcore deploy`** in this path — the npm
16
- `@aws/agentcore` CLI is used ONLY by `bag dev --container` (image-parity local
17
- runs).
18
-
19
- The deployed product is **one** valuable Agent that serves its selected public
20
- faces (A2A → `0.0.0.0:9000`, MCP-only → `0.0.0.0:8000/mcp`, or A2A+MCP →
21
- A2A-native `dualMain.ts` on `:9000` with `/mcp` tunneled by the platform, per
22
- `app/agent/studio.toml [stack].protocols`): it holds the key, signs in-process,
23
- and is its own public endpoint behind an OAuth2 authorizer. There is no
24
- separate service to deploy — the agent IS the public surface, so this one
25
- procedure is the whole runtime deploy.
10
+ Procedure for deploying and operating the seller Agent on **AWS Bedrock AgentCore** via the **delegated deploy**: `bag deploy --provider aws` hands a generated deploy spec to the pinned **`@bnbagent/deploy-cli`** (run via `bunx --bun`; override the command with `BNBAGENT_DEPLOY_COMMAND`), which executes every cloud lifecycle mutation through the AWS SDK under the user's credentials. There is **no `aws` CLI, no CDK deploy, and no `agentcore deploy`** in the mutation path - the npm `@aws/agentcore` CLI is used ONLY by `bag dev --container` (image-parity local runs). If the AWS CLI is installed, `bag deploy prepare` may use it only for a fail-open, read-only AgentCore quota-headroom probe.
11
+
12
+ The deployed product is **one** valuable Agent that serves its selected public faces (A2A → `0.0.0.0:9000`, MCP-only → `0.0.0.0:8000/mcp`, or A2A+MCP → A2A-native `dualMain.ts` on `:9000` with `/mcp` tunneled by the platform, per `app/agent/studio.toml [stack].protocols`): it holds the key, signs in-process, and is its own public endpoint behind an OAuth2 authorizer. There is no separate service to deploy - the agent IS the public surface, so this one procedure is the whole runtime deploy.
26
13
 
27
14
  ```
28
15
  <workspace>/
@@ -32,157 +19,74 @@ procedure is the whole runtime deploy.
32
19
  └── app/agent/ # the deployed code (entrypoint lives here)
33
20
  ```
34
21
 
35
- > **`bag deploy --provider aws` runs the whole deploy.** It gates on readiness, builds
36
- > the agent (`pnpm build`), collects the runtime secrets, and delegates to
37
- > bnbagent-deploy. The old `bag deploy agent` spelling is a deprecated
38
- > compatibility alias.
22
+ > **`bag deploy --provider aws` runs the whole deploy.** It gates on readiness, builds the agent (`pnpm build`), collects the runtime secrets, and delegates to bnbagent-deploy. The old `bag deploy agent` spelling is a deprecated compatibility alias.
39
23
 
40
24
  ## Prerequisites
41
25
 
42
- 1. **Bun 1.3+ (`bunx`) on PATH** the pinned `@bnbagent/deploy-cli` runs
43
- through it (`bag deploy prepare` fails a CRITICAL check when `bunx` is
44
- missing). Install from https://bun.sh, or point `BNBAGENT_DEPLOY_COMMAND`
45
- at another launcher.
46
- 2. **AWS credentials** for the deploy identity use `bnbagent-deploy login
47
- --provider aws` or the standard env/profile files. Studio does not inspect
48
- credentials itself; the delegated deploy-cli validates identity and
49
- permissions before mutation. Credentials may come from
50
- `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_REGION` or the
51
- standard `~/.aws/credentials` file. Verify you're in the RIGHT account: it must
52
- match `agentcore/aws-targets.json` (the AWS Console's account menu shows
53
- the active account id). Least-privilege policy JSON:
54
- `docs/guides/agentcore-deploy-iam.md`.
55
- 3. **Docker running — container packaging only** (`wallet.kind = "twak"` or a
56
- scaffold with `[deploy].platform_artifact = "container"`): bnbagent-deploy
57
- builds the scaffolded Dockerfile locally for linux/arm64 and pushes it to
58
- ECR. A default evm-local AWS scaffold deploys as a Node zip and needs no
59
- Docker; an evm-local platform-container scaffold remains a container when
60
- AWS is selected later.
61
- 4. **`@aws/agentcore` CLI — ONLY for `bag dev --container`** (needs Node ≥ 20:
62
- `npm install -g @aws/agentcore`). Not needed to deploy.
63
- ⚠️ Some environments carry `bedrock-agentcore-starter-toolkit`, a
64
- **same-named but incompatible** `agentcore` shim that can shadow the npm
65
- CLI on PATH. Check with `which -a agentcore` and remove the shim (or put
66
- the npm `@aws/agentcore` first on PATH) if `bag dev --container`
67
- misbehaves.
26
+ 1. **Bun 1.3+ (`bunx`) on PATH** - the pinned `@bnbagent/deploy-cli` runs through it (`bag deploy prepare` fails a CRITICAL check when `bunx` is missing). Install from https://bun.sh, or point `BNBAGENT_DEPLOY_COMMAND` at another launcher.
27
+ 2. **AWS credentials** for the deploy identity - use `bnbagent-deploy login --provider aws` or the standard env/profile files. Studio does not inspect credentials itself; the delegated deploy-cli validates identity and permissions before mutation. Credentials may come from `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_REGION` or the standard `~/.aws/credentials` file. Verify you're in the RIGHT account: it must match `agentcore/aws-targets.json` (the AWS Console's account menu shows the active account id). Least-privilege policy JSON: `docs/guides/agentcore-deploy-iam.md`.
28
+ 3. **Docker running - container packaging only** (`wallet.kind = "twak"` or a scaffold with `[deploy].platform_artifact = "container"`): bnbagent-deploy builds the scaffolded Dockerfile locally for linux/arm64 and pushes it to ECR. A default evm-local AWS scaffold deploys as a Node zip and needs no Docker; an evm-local platform-container scaffold remains a container when AWS is selected later.
29
+ 4. **`@aws/agentcore` CLI - ONLY for `bag dev --container`** (use the repository baseline, Node >=22: `npm install -g @aws/agentcore`). Not needed to deploy. ⚠️ Some environments carry `bedrock-agentcore-starter-toolkit`, a **same-named but incompatible** `agentcore` shim that can shadow the npm CLI on PATH. Check with `which -a agentcore` and remove the shim (or put the npm `@aws/agentcore` first on PATH) if `bag dev --container` misbehaves.
30
+ 5. **AWS CLI - optional for readiness only.** When available, `bag deploy prepare` reads quota `L-F4575653` and lists existing AgentCore runtimes so it can stop before a full-quota deploy creates orphaned intermediate resources. The probe stays silent if the CLI, credentials, `servicequotas:GetServiceQuota`, `bedrock-agentcore:ListAgentRuntimes`, or usable JSON output is unavailable. The delegated deployment itself does not require the AWS CLI.
68
31
 
69
32
  ## The runtime-secret channel (read this first)
70
33
 
71
- The deployed runtime does NOT read `.env.local` nothing ships it. Instead,
72
- `bag deploy --provider aws` collects the runtime secrets (provider/storage keys,
73
- `WALLET_PASSWORD`, the encrypted keystore as `WALLET_KEYSTORE_JSON` or the
74
- twak bundle) and hands them to bnbagent-deploy as a private (mode 0600)
75
- tempdir envFile. The deploy CLI provisions them as ONE Secrets Manager secret
76
- (`bnbagent/<project>/runtime`), injects the `BNBAGENT_RUNTIME_SECRET_ID`
77
- pointer into the runtime env, and grants the runtime execution role read
78
- access. The entrypoint loads the bundle at cold start.
79
-
80
- > **The KEYSTORE is never bundled.** The encrypted wallet keystore lives at
81
- > the WORKSPACE root (`.studio/wallets/`, outside `app/agent/`, so no
82
- > packaging path can include it) and reaches the runtime ONLY via that
83
- > Secrets Manager channel. Only put non-secret runtime config in
84
- > `agentcore.json` `envVars[]`.
85
-
86
- > **`--secrets-mode envvars` is testnet-only.** It inlines the secrets as
87
- > PLAINTEXT runtime env vars in the deploy spec — use it only when you cannot
88
- > grant `secretsmanager:CreateSecret`; it is refused on mainnet.
89
-
90
- Provider-native overrides: the optional `studio.toml [deploy.agentcore]` table
91
- passes verbatim deploy-spec keys through to CreateAgentRuntime /
92
- UpdateAgentRuntime. Two keys are reserved and refused: `secretName`
93
- (studio-managed) and `environmentVariables` (would replace the merged runtime
94
- env, secret pointer included).
34
+ The deployed runtime does NOT read `.env.local` - nothing ships it. Instead, `bag deploy --provider aws` collects the runtime secrets (provider/storage keys, `WALLET_PASSWORD`, the encrypted keystore as `WALLET_KEYSTORE_JSON` - or the twak bundle) and hands them to bnbagent-deploy as a private (mode 0600) tempdir envFile. The deploy CLI provisions them as ONE Secrets Manager secret (`bnbagent/<project>/runtime`), injects the `BNBAGENT_RUNTIME_SECRET_ID` pointer into the runtime env, and grants the runtime execution role read access. The entrypoint loads the bundle at cold start.
35
+
36
+ > **The KEYSTORE is never bundled.** The encrypted wallet keystore lives at the WORKSPACE root (`.studio/wallets/`, outside `app/agent/`, so no packaging path can include it) and reaches the runtime ONLY via that Secrets Manager channel. Only put non-secret runtime config in `agentcore.json` `envVars[]`.
37
+
38
+ > **`--secrets-mode envvars` is testnet-only.** It inlines the secrets as PLAINTEXT runtime env vars in the deploy spec - use it only when you cannot grant `secretsmanager:CreateSecret`; it is refused on mainnet.
39
+
40
+ Provider-native overrides: the optional `studio.toml [deploy.agentcore]` table passes verbatim deploy-spec keys through to CreateAgentRuntime / UpdateAgentRuntime. Two keys are reserved and refused: `secretName` (studio-managed) and `environmentVariables` (would replace the merged runtime env, secret pointer included).
95
41
 
96
42
  ## Command reference
97
43
 
98
- Everything runs through `bag deploy` (run `bag deploy <cmd> --help` for
99
- flags); cloud execution is the pinned bnbagent-deploy's job.
44
+ Everything runs through `bag deploy` (run `bag deploy <cmd> --help` for flags); cloud execution is the pinned bnbagent-deploy's job.
100
45
 
101
46
  | Command | What it does |
102
- |---|---|
103
- | `bag deploy prepare` | The deploy-readiness sweep (incl. the `bunx` check). Run before deploying. |
47
+ | --- | --- |
48
+ | `bag deploy prepare` | The deploy-readiness sweep, including `bunx` and the optional fail-open AgentCore quota probe. Run before deploying. |
104
49
  | `bag deploy --provider aws [--yes]` | The whole deploy: prepare gate → AWS-permissions notice → secret hand-off → `pnpm build` → delegated deploy (artifact, runtime create/update, secret provision + role grant, Cognito inbound OAuth) → ARN capture + state stamp. Automation requires `--yes`; add `--allow-multiple` when another provider stays active. |
105
50
  | `bag deploy verify [--provider aws]` | Ask bnbagent-deploy for live provider status, then reconcile ERC-8004. Provider is required only when multiple deployments are recorded. |
106
51
  | `bag deploy status [--provider aws]` | List every recorded deployment and delegated live state (read-only); `--no-probe` is local-only. |
107
52
  | `bag deploy logs [--provider aws] [--follow] [--since 10m]` | Delegate runtime logs to bnbagent-deploy. |
108
53
  | `bag deploy destroy [--provider aws]` | Dry-run teardown plan; `--execute` delegates `destroy --yes`; `--purge` also deletes retained ECR/log resources. |
109
- | `bag deploy provision-cognito [--wire]` | Emit (then wire) the optional Cognito CDK app for operator-managed buyer credentials. |
54
+ | `bag deploy provision-cognito [--wire]` | **Deprecated** (hidden from `--help`). Emits a Cognito CDK app whose pool a deploy never uses. |
110
55
 
111
56
  ## Typical workflows
112
57
 
113
58
  ### A. Run locally
114
59
 
115
- Prefer `bag dev` (auto-loads `.env.local`, runs the agent in-process, no
116
- Docker). `bag dev --container` opts into the native `agentcore dev` container
117
- for full image parity — the ONE flow that needs the npm `@aws/agentcore` CLI
118
- plus a container engine.
60
+ Prefer `bag dev` (auto-loads `.env.local`, runs the agent in-process, no Docker). `bag dev --container` opts into the native `agentcore dev` container for full image parity - the ONE flow that needs the npm `@aws/agentcore` CLI plus a container engine.
119
61
 
120
62
  ### B. Deploy to AWS (delegated)
121
63
 
122
- > ⚠️ **First deploy: relay the AWS-permissions notice to the user.** Deploying
123
- > provisions resources in the user's AWS account. `bag deploy --provider aws` prints a
124
- > pre-deploy notice (required-permission guides, AWS best-practice links, and a
125
- > disclaimer) and gates the project's FIRST deploy on an explicit acceptance —
126
- > in a non-interactive run it exits with an error instead of prompting. When
127
- > that happens: show the printed notice to the user **verbatim**, get their
128
- > explicit consent, then re-run with `--accept-risk`. NEVER add `--accept-risk`
129
- > without asking the user first.
130
-
131
- > 🔒 **Inbound auth is auto-provisioned.** An AgentCore seller endpoint is
132
- > **never anonymous**. When `agentcore.json` carries no authorizer of its own,
133
- > the delegated deploy auto-provisions a Cognito inbound OAuth (account pool +
134
- > per-agent M2M client) so the runtime is token-gated. To mint buyer
135
- > credentials the operator manages directly, use the optional CDK path:
64
+ > ⚠️ **First deploy: relay the AWS-permissions notice to the user.** Deploying provisions resources in the user's AWS account. `bag deploy --provider aws` prints a pre-deploy notice (required-permission guides, AWS best-practice links, and a disclaimer) and gates the project's FIRST deploy on an explicit acceptance - in a non-interactive run it exits with an error instead of prompting. When that happens: show the printed notice to the user **verbatim**, get their explicit consent, then re-run with `--accept-risk`. NEVER add `--accept-risk` without asking the user first.
65
+
66
+ > 🔒 **Inbound auth is auto-provisioned.** An AgentCore seller endpoint is **never anonymous**. The delegated deploy provisions a Cognito inbound OAuth (account pool + per-agent M2M client) so the runtime is token-gated, then writes the live token URL, scope, client id, and discovery URL back into `studio.toml`, `agentcore.json`, and the printed buyer block. Hand those to each buyer; the client secret is retrieved read-only in the AWS Console (Cognito → User pools → App clients → "Show client secret") - never persisted by studio.
136
67
  >
137
- > 1. `bag deploy provision-cognito` emits a self-contained Cognito CDK app
138
- > (UserPool + M2M app client) — the user runs `cdk deploy --outputs-file
139
- > cdk-outputs.json` themselves.
140
- > 2. `bag deploy provision-cognito --wire` reads that local outputs file and
141
- > patches `agentcore.json`'s `authorizerConfiguration.customJwtAuthorizer` +
142
- > the card's `OAUTH_TOKEN_URL` / `OAUTH_SCOPE` (no AWS call). The client
143
- > secret is retrieved read-only in the AWS Console (Cognito → User pools →
144
- > App clients → "Show client secret") — never persisted by studio.
68
+ > `bag deploy provision-cognito` (the CDK path) is **deprecated**: a deploy provisions and uses its own pool regardless, so the CDK stack is a billable orphan and anything wired from it gets overwritten.
145
69
  >
146
- > Buyers then reach the agent over plain HTTPS + an OAuth2 Bearer (the
147
- > client-credentials grant) — **no AWS SigV4 / IAM credentials**. Locally,
148
- > `bag dev` runs without Cognito env, so the card omits the scheme.
70
+ > Buyers reach the agent over plain HTTPS + an OAuth2 Bearer (the client-credentials grant) - **no AWS SigV4 / IAM credentials**. Locally, `bag dev` runs without Cognito env, so the card omits the scheme.
149
71
 
150
- The 2026-07-20 live baseline passed both ZIP and linux/arm64 container through
151
- deploy, status, OAuth-authenticated signed A2A negotiation, logs, destroy, and
152
- purge. A SigV4 invoke against this custom-JWT endpoint is expected to fail; use
153
- the buyer OAuth bearer when verifying the data plane. That baseline bypassed
154
- local storage readiness and therefore does not prove funded delivery or durable
155
- storage.
72
+ The 2026-07-20 live baseline passed both ZIP and linux/arm64 container through deploy, status, OAuth-authenticated signed A2A negotiation, logs, destroy, and purge. A SigV4 invoke against this custom-JWT endpoint is expected to fail; use the buyer OAuth bearer when verifying the data plane. That baseline bypassed local storage readiness and therefore does not prove funded delivery or durable storage.
156
73
 
157
74
  ```bash
158
75
  # 1. Set the real AWS account + region in agentcore/aws-targets.json and
159
76
  # export the deploy credentials (env vars or ~/.aws/credentials).
160
- # 2. Check readiness, then deploy the pinned bnbagent-deploy does the cloud work:
77
+ # 2. Check readiness, then deploy - the pinned bnbagent-deploy does the cloud work:
161
78
  bag deploy prepare
162
79
  bag deploy --provider aws
163
80
  ```
164
81
 
165
- > After deploy, ERC-8004 registration records the **AgentCore endpoint**:
166
- > A2A uses the normalized agent-card URL (`AgentEndpoint.a2a`), while MCP records
167
- > the `/mcp` endpoint plus access metadata. `bag deploy verify` handles this. The
168
- > on-chain identity points buyers straight at the agent; there is no proxy or
169
- > relay in front of it.
82
+ > After deploy, ERC-8004 registration records the **AgentCore endpoint**: A2A uses the normalized agent-card URL (`AgentEndpoint.a2a`), while MCP records the `/mcp` endpoint plus access metadata. `bag deploy verify` handles this. The on-chain identity points buyers straight at the agent; there is no proxy or relay in front of it.
170
83
 
171
84
  ### B1. Troubleshooting the delegated deploy
172
85
 
173
- - **`could not start bnbagent-deploy (bunx not found)`** install Bun 1.3+
174
- (https://bun.sh) or set `BNBAGENT_DEPLOY_COMMAND` to a command that can run
175
- the pinned `@bnbagent/deploy-cli`.
176
- - **Permission denials (AccessDenied)** the deploy identity is missing one
177
- of the least-privilege statements; apply the policy JSON from
178
- `docs/guides/agentcore-deploy-iam.md`. The deploy CLI preflight-simulates
179
- its permissions when it can and names the denied actions.
180
- - **Wrong account** — the credentials in the environment resolve to an account
181
- that does not match `agentcore/aws-targets.json`; fix the env vars /
182
- `~/.aws/credentials` profile, not the descriptor.
183
- - **Container build fails / hangs** (twak) — the image is built LOCALLY for
184
- linux/arm64 and pushed to ECR; Docker must be running (x86 machines need
185
- buildx/containerd cross-build support).
86
+ - **`could not start bnbagent-deploy (bunx not found)`** - install Bun 1.3+ (https://bun.sh) or set `BNBAGENT_DEPLOY_COMMAND` to a command that can run the pinned `@bnbagent/deploy-cli`.
87
+ - **Permission denials (AccessDenied)** - the deploy identity is missing one of the least-privilege statements; apply the policy JSON from `docs/guides/agentcore-deploy-iam.md`. The deploy CLI preflight-simulates its permissions when it can and names the denied actions.
88
+ - **Wrong account** - the credentials in the environment resolve to an account that does not match `agentcore/aws-targets.json`; fix the env vars / `~/.aws/credentials` profile, not the descriptor.
89
+ - **Container build fails / hangs** (twak) - the image is built LOCALLY for linux/arm64 and pushed to ECR; Docker must be running (x86 machines need buildx/containerd cross-build support).
186
90
 
187
91
  ### C. Inspect / operate
188
92
 
@@ -194,19 +98,14 @@ bag deploy destroy --provider aws # dry-run teardown plan
194
98
  bag deploy destroy --provider aws --execute # delegated teardown (add --purge)
195
99
  ```
196
100
 
101
+ If verification reports a partial ERC-8004 registration because `setAgentURI` did not complete, the deployment check remains a warning and records pending identity state. Retry with `bag erc8004 update-endpoint --endpoint <url>`, or run `bag erc8004 clear-pending` first when the relay transaction was never observed on-chain.
102
+
197
103
  ## Reference
198
104
 
199
- - b402/x402 selling on self-hosted AgentCore: the rail activates in-process
200
- with complete B402 credentials for PAID, or without them when explicit zero
201
- selects FREE. There is no anonymous URL — operate your own HTTP front that
202
- relays envelope-v1 through the runtime's configured authorizer. The default
203
- Bag deploy uses Cognito OAuth over HTTPS, not SDK/SigV4. PAID also needs a
204
- fixed-egress B402 Relay or VPC/NAT/Elastic-IP path. See
205
- `bnbagent-studio-selling-via-b402` and
206
- `docs/guides/self-hosted-x402-gateway.md`.
105
+ - b402/x402 selling on self-hosted AgentCore: the rail activates in-process with complete B402 credentials for PAID, or without them when explicit zero selects FREE. There is no anonymous URL - operate your own HTTP front that relays envelope-v1 through the runtime's configured authorizer. The default Bag deploy uses Cognito OAuth over HTTPS, not SDK/SigV4. PAID also needs a fixed-egress B402 Relay or VPC/NAT/Elastic-IP path. See `bnbagent-studio-selling-via-b402` and `docs/guides/self-hosted-x402-gateway.md`.
207
106
  - `bag deploy --help` / `bag deploy <command> --help` (authoritative for commands + flags)
208
- - `agentcore/agentcore.json` name (resource naming continuity), protocol, authorizer, envVars
209
- - `agentcore/aws-targets.json` AWS account + region
210
- - `app/agent/studio.toml [deploy.agentcore]` provider-native deploy-spec passthrough
211
- - `docs/guides/agentcore-deploy-iam.md` least-privilege IAM for the delegated deploy
212
- - `BNBAGENT_DEPLOY_COMMAND` override the pinned `bunx --bun @bnbagent/deploy-cli@<pin>` invocation (E2E/dev)
107
+ - `agentcore/agentcore.json` - name (resource naming continuity), protocol, authorizer, envVars
108
+ - `agentcore/aws-targets.json` - AWS account + region
109
+ - `app/agent/studio.toml [deploy.agentcore]` - provider-native deploy-spec passthrough
110
+ - `docs/guides/agentcore-deploy-iam.md` - least-privilege IAM for the delegated deploy
111
+ - `BNBAGENT_DEPLOY_COMMAND` - override the pinned `bunx --bun @bnbagent/deploy-cli@<pin>` invocation (E2E/dev)