@bnbagent/studio-cli 0.0.12 → 0.0.13-alpha.1

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.
File without changes
@@ -21,8 +21,15 @@ import { stringify as tomlStringify } from "smol-toml";
21
21
  import { createHash } from "crypto";
22
22
  import * as fs from "fs";
23
23
  import * as path from "path";
24
+ import {
25
+ TURNKEY_SDK_SERVER_PACKAGE,
26
+ TURNKEY_VIEM_PACKAGE
27
+ } from "@bnbagent/sdk/wallets";
24
28
  import { loadStudioToml } from "@bnbagent/studio-runtime/config";
25
- import { resolveProjectAltanaSdkEntry } from "@bnbagent/studio-runtime/wallet";
29
+ import {
30
+ resolveProjectAltanaSdkEntry,
31
+ resolveProjectTurnkeySdkEntry
32
+ } from "@bnbagent/studio-runtime/wallet";
26
33
  import { build as esbuildBuild } from "esbuild";
27
34
 
28
35
  // src/cli/utils/protocol.ts
@@ -141,6 +148,7 @@ async function buildZip(agentDir, outZip, opts = {}) {
141
148
  stageManifest(agentDir, buildRoot, entrypoint);
142
149
  stageStudioToml(agentDir, buildRoot);
143
150
  await stageAltanaSdk(agentDir, buildRoot, opts.bundle ?? bundleEntry);
151
+ await stageTurnkeySdk(agentDir, buildRoot, opts.bundle ?? bundleEntry);
144
152
  assertWithinUncompressedCap(
145
153
  buildRoot,
146
154
  opts.maxUncompressedBytes ?? MAX_UNCOMPRESSED_BYTES
@@ -277,7 +285,7 @@ async function stageAltanaSdk(agentDir, buildRoot, bundle) {
277
285
  }
278
286
  if (entry === null) {
279
287
  throw new Error(
280
- "wallet.kind='altana' but @altananetwork/sdk is not resolvable from the agent project \u2014 the zip runtime could never load the Altana session wallet. Run `pnpm add @altananetwork/sdk@0.5.1` in app/agent, or deploy as a container."
288
+ "wallet.kind='altana' but @altananetwork/sdk is not resolvable from the agent project \u2014 the zip runtime could never load the Altana session wallet. Run `pnpm add @altananetwork/sdk@0.7.1` in app/agent, or deploy as a container."
281
289
  );
282
290
  }
283
291
  const pkgDir = path.join(buildRoot, "node_modules", "@altananetwork", "sdk");
@@ -288,7 +296,7 @@ async function stageAltanaSdk(agentDir, buildRoot, bundle) {
288
296
  `${JSON.stringify(
289
297
  {
290
298
  name: "@altananetwork/sdk",
291
- version: altanaSdkVersionOf(entry),
299
+ version: packageVersionOf(entry, "@altananetwork/sdk"),
292
300
  private: true,
293
301
  type: "module",
294
302
  main: "index.js"
@@ -299,14 +307,76 @@ async function stageAltanaSdk(agentDir, buildRoot, bundle) {
299
307
  `
300
308
  );
301
309
  }
302
- function altanaSdkVersionOf(entry) {
310
+ async function stageTurnkeySdk(agentDir, buildRoot, bundle) {
311
+ let kind = "evm-local";
312
+ try {
313
+ const cfg = loadStudioToml(path.join(agentDir, "studio.toml"));
314
+ const wallet = cfg.wallet;
315
+ if (wallet !== null && typeof wallet === "object" && !Array.isArray(wallet)) {
316
+ kind = String(wallet.kind ?? "evm-local");
317
+ }
318
+ } catch {
319
+ }
320
+ if (kind !== "turnkey") {
321
+ return;
322
+ }
323
+ const packageNames = [
324
+ TURNKEY_SDK_SERVER_PACKAGE,
325
+ TURNKEY_VIEM_PACKAGE
326
+ ];
327
+ const entries = /* @__PURE__ */ new Map();
328
+ try {
329
+ for (const packageName of packageNames) {
330
+ const entry = resolveProjectTurnkeySdkEntry(agentDir, packageName);
331
+ if (entry !== null) {
332
+ entries.set(packageName, entry);
333
+ }
334
+ }
335
+ } catch (exc) {
336
+ throw new Error(
337
+ `wallet.kind='turnkey' zip build: ${exc instanceof Error ? exc.message : exc}`
338
+ );
339
+ }
340
+ if (entries.size !== packageNames.length) {
341
+ const missing = packageNames.filter((name) => !entries.has(name));
342
+ throw new Error(
343
+ `wallet.kind='turnkey' zip build: missing ${missing.join(", ")}; install both Turnkey packages in app/agent: pnpm add ${TURNKEY_SDK_SERVER_PACKAGE} ${TURNKEY_VIEM_PACKAGE}, or deploy as a container.`
344
+ );
345
+ }
346
+ for (const packageName of packageNames) {
347
+ const entry = entries.get(packageName);
348
+ const packageDir = path.join(
349
+ buildRoot,
350
+ "node_modules",
351
+ ...packageName.split("/")
352
+ );
353
+ fs.mkdirSync(packageDir, { recursive: true });
354
+ await bundle(entry, path.join(packageDir, "index.js"));
355
+ fs.writeFileSync(
356
+ path.join(packageDir, "package.json"),
357
+ `${JSON.stringify(
358
+ {
359
+ name: packageName,
360
+ version: packageVersionOf(entry, packageName),
361
+ private: true,
362
+ type: "module",
363
+ main: "index.js"
364
+ },
365
+ null,
366
+ 2
367
+ )}
368
+ `
369
+ );
370
+ }
371
+ }
372
+ function packageVersionOf(entry, packageName) {
303
373
  let cursor = path.dirname(entry);
304
374
  for (let i = 0; i < 4; i += 1) {
305
375
  const manifest = path.join(cursor, "package.json");
306
376
  if (isFile(manifest)) {
307
377
  try {
308
378
  const pkg = JSON.parse(fs.readFileSync(manifest, "utf-8"));
309
- if (pkg.name === "@altananetwork/sdk") {
379
+ if (pkg.name === packageName) {
310
380
  return typeof pkg.version === "string" ? pkg.version : "0.0.0";
311
381
  }
312
382
  } catch {
@@ -686,8 +756,8 @@ function packageRoot() {
686
756
  }
687
757
  }
688
758
  function studioCliVersion() {
689
- if ("0.0.12") {
690
- return "0.0.12";
759
+ if ("0.0.13-alpha.1") {
760
+ return "0.0.13-alpha.1";
691
761
  }
692
762
  const file = path3.join(packageRoot(), "package.json");
693
763
  const pkg = JSON.parse(fs3.readFileSync(file, "utf-8"));
File without changes
@@ -18,7 +18,7 @@ import {
18
18
  runPlatformAccountCommand,
19
19
  trialFromDeployCliJson,
20
20
  withDeployFiles
21
- } from "./chunk-RNWAADXU.js";
21
+ } from "./chunk-RSM3RMDD.js";
22
22
  import "./chunk-RO726HJG.js";
23
23
  export {
24
24
  BNB_PLATFORM_API_URL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bnbagent/studio-cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.13-alpha.1",
4
4
  "description": "Skills-first toolkit and bag CLI for BNB Chain seller agents: ERC-8004 identity, ERC-8183 escrowed commerce, and x402 payments.",
5
5
  "keywords": [
6
6
  "bnb-chain",
@@ -25,7 +25,6 @@
25
25
  "directory": "packages/studio-cli"
26
26
  },
27
27
  "type": "module",
28
- "packageManager": "pnpm@10.24.0",
29
28
  "engines": {
30
29
  "node": ">=22"
31
30
  },
@@ -42,16 +41,8 @@
42
41
  "bin": {
43
42
  "bag": "./dist/bag.js"
44
43
  },
45
- "scripts": {
46
- "build": "tsup",
47
- "test": "vitest run",
48
- "lint": "biome check src tests",
49
- "typecheck": "tsc --noEmit",
50
- "check": "pnpm typecheck && pnpm lint && pnpm test && pnpm build"
51
- },
52
44
  "dependencies": {
53
- "@bnbagent/sdk": "0.5.0",
54
- "@bnbagent/studio-runtime": "0.0.12",
45
+ "@bnbagent/sdk": "0.5.2-alpha.1",
55
46
  "ai": "^7.0.29",
56
47
  "archiver": "^8.0.0",
57
48
  "commander": "^15.0.0",
@@ -62,7 +53,8 @@
62
53
  "smol-toml": "^1.3.0",
63
54
  "tar": "^7.4.0",
64
55
  "viem": "^2.54.0",
65
- "yaml": "^2.9.0"
56
+ "yaml": "^2.9.0",
57
+ "@bnbagent/studio-runtime": "0.0.13-alpha.1"
66
58
  },
67
59
  "devDependencies": {
68
60
  "@a2a-js/sdk": "^0.3.14",
@@ -78,5 +70,12 @@
78
70
  "typescript": "^5.5.0",
79
71
  "vitest": "^2.0.0",
80
72
  "zod": "^3.25.76"
73
+ },
74
+ "scripts": {
75
+ "build": "tsup",
76
+ "test": "vitest run",
77
+ "lint": "biome check src tests",
78
+ "typecheck": "tsc --noEmit",
79
+ "check": "pnpm typecheck && pnpm lint && pnpm test && pnpm build"
81
80
  }
82
- }
81
+ }
@@ -11,7 +11,7 @@ node = [
11
11
  # neutral. The agent project's serving deps (@a2a-js/sdk / MCP SDK / ai)
12
12
  # come from the runtimes/<R>/ recipe selected at `bag init` time.
13
13
  "@bnbagent/studio-runtime",
14
- "@bnbagent/sdk@0.5.0",
14
+ "@bnbagent/sdk@0.5.2-alpha.1",
15
15
  ]
16
16
 
17
17
  [env]
@@ -32,7 +32,7 @@ node = [
32
32
  # BNBAGENT_RUNTIME_SECRET_ID is set (default secretsmanager mode + platform).
33
33
  "@aws-sdk/client-secrets-manager@^3.600.0",
34
34
  "@bnbagent/studio-runtime",
35
- "@bnbagent/sdk@0.5.0",
35
+ "@bnbagent/sdk@0.5.2-alpha.1",
36
36
  # The LLM work hook (generateText + tools) and the model factory.
37
37
  "ai@^7.0.29",
38
38
  # Tool input schemas (AI SDK tools + MCP registerTool).
@@ -29,7 +29,7 @@ node = [
29
29
  # on either cloud.
30
30
  "@aws-sdk/client-secrets-manager@^3.600.0",
31
31
  "@bnbagent/studio-runtime",
32
- "@bnbagent/sdk@0.5.0",
32
+ "@bnbagent/sdk@0.5.2-alpha.1",
33
33
  # The LLM work hook (generateText + tools) and the model factory
34
34
  # (model.ts buildModel — studio.toml [llm] + the provider key env).
35
35
  "ai@^7.0.29",
@@ -1,17 +1,22 @@
1
1
  [recipe]
2
2
  name = "wallet"
3
- description = "Configures the agent's wallet: 'evm-local' (default encrypted keystore), 'twak' (Trust Wallet Agent Kit CLI), or 'altana' (encrypted admin keystore plus one bounded runtime session)."
3
+ description = "Configures the agent's wallet: 'evm-local' (default encrypted keystore), 'twak' (Trust Wallet Agent Kit CLI), 'altana' (encrypted admin keystore plus one bounded runtime session), or 'turnkey' (remote signer; the key lives in Turnkey's AWS Nitro enclave)."
4
4
 
5
5
  [dependencies]
6
6
  node = ["@bnbagent/studio-runtime"]
7
7
 
8
8
  [dependencies.altana]
9
- node = ["@altananetwork/sdk@0.5.1"]
9
+ node = ["@altananetwork/sdk@0.7.1"]
10
+
11
+ [dependencies.turnkey]
12
+ node = ["@turnkey/sdk-server@8.1.0", "@turnkey/viem@0.14.34"]
10
13
 
11
14
  [env]
12
15
  # kind='twak': the twak CLI reads the unlock password from the environment —
13
16
  # it never goes on a command line.
14
17
  TWAK_WALLET_PASSWORD = "unlocks ~/.twak/wallet.json (twak kind); set in .studio/.env.local"
18
+ # kind='turnkey': P-256 API credential; the signing key never leaves Turnkey's enclave.
19
+ TURNKEY_API_PRIVATE_KEY = "Turnkey P-256 API private key (turnkey kind); set in .studio/.env.local"
15
20
  # kind='evm-local' (the `bag init` default) or kind='altana' admin operations:
16
21
  WALLET_PASSWORD = "set to a strong password (>= 12 chars); encrypts .studio/wallets/<addr>.json (runtime never receives it for altana)"
17
22
 
@@ -6,7 +6,7 @@ status = "v0.0.x"
6
6
  [dependencies]
7
7
  node = [
8
8
  "@bnbagent/studio-runtime",
9
- "@bnbagent/sdk@0.5.0",
9
+ "@bnbagent/sdk@0.5.2-alpha.1",
10
10
  "ai@^7.0.29", # AI SDK `tool` wrappers around the buyer functions
11
11
  "zod@^3.25.0", # tool input schemas
12
12
  ]
@@ -5,7 +5,7 @@ description: The single entry point for bnbagent-studio - a TypeScript CLI (`bag
5
5
 
6
6
  # bnbagent-studio (the single entry point)
7
7
 
8
- `bnbagent-studio` (CLI: `bag`) wires the `@bnbagent/sdk` protocol layer (wallet / ERC-8004 / ERC-8183 / Pieverse LLM) into a TypeScript agent project, then deploys it as a **single blockchain seller runtime**. A2A, MCP, and X402 are composable public faces selected with `--protocols`; the default evm-local/twak scaffold serves A2A + X402 with both ERC-8183 and B402 rails, while Altana defaults to A2A + ERC-8183 because paid B402 is unsupported. `bag deploy` uses **scheme C**: every new deploy or redeploy explicitly selects BNB, AWS, or Azure; a recorded deployment is used only to offer an explicit update action, never as a silent default. BNB is a 48h testnet trial and is disabled after expiry. AWS and Azure self-deploy into the user's own account. All cloud lifecycle mutations go through the pinned `@bnbagent/deploy-cli`; the optional AWS CLI is used only by the fail-open, read-only AgentCore quota check in `bag deploy prepare`. AgentCore and Azure Foundry share the unified A2A/X402 entrypoint; Azure rejects MCP. Treat an incompatible provider row as unavailable-do not force through it or mutate the scaffold during deploy.
8
+ `bnbagent-studio` (CLI: `bag`) wires the `@bnbagent/sdk` protocol layer (wallet / ERC-8004 / ERC-8183 / Pieverse LLM) into a TypeScript agent project, then deploys it as a **single blockchain seller runtime**. A2A, MCP, and X402 are composable public faces selected with `--protocols`; every wallet kind scaffolds A2A + X402 with both ERC-8183 and B402 rails by default (for altana the paid B402 payout lands at the admin address). `bag deploy` uses **scheme C**: every new deploy or redeploy explicitly selects BNB, AWS, or Azure; a recorded deployment is used only to offer an explicit update action, never as a silent default. BNB is a 48h testnet trial and is disabled after expiry. AWS and Azure self-deploy into the user's own account. All cloud lifecycle mutations go through the pinned `@bnbagent/deploy-cli`; the optional AWS CLI is used only by the fail-open, read-only AgentCore quota check in `bag deploy prepare`. AgentCore and Azure Foundry share the unified A2A/X402 entrypoint; Azure rejects MCP. Treat an incompatible provider row as unavailable-do not force through it or mutate the scaffold during deploy.
9
9
 
10
10
  Invoked as `/bnbagent-studio <ask>`? Treat `<ask>` as the user's intent and route it through the decision tree below, exactly like a natural-language ask.
11
11
 
@@ -51,6 +51,8 @@ verified = true # studio-reviewed shelf
51
51
 
52
52
  Hard-stop cases: a reviewed merchant whose live payTo drifts from the studio pin (address rotation or tampering - upgrade studio or verify out-of-band and pass `--pay-to`), and `--cap` below the live per-call price.
53
53
 
54
+ Wallet kinds and rails: `evm-local` signs EIP-3009 locally; `twak` and `altana` route through a delegated payer that prefers the merchant's permit2 route. Altana smart-account payments are verified by the B402 facilitator on its permit2 rails (live since 2026-08, CMC field-verified) and need the one-time `bag wallet session x402-setup` arming (checker approval + bounded U→Permit2 allowance) - `bag doctor` shows the arming state as `[wallet] Altana x402 buying`.
55
+
54
56
  ## Step 2 - wire the buyer tools into the agent
55
57
 
56
58
  ```bash
@@ -99,7 +101,8 @@ bag dev # then ask the agent something that needs the paid data
99
101
  | `X402RecipientRequiredError` | No pinned recipient for that host → same fix |
100
102
  | `X402RecipientMismatchError` | Live payTo drifted from the pin - do NOT override casually; re-verify the merchant |
101
103
  | `X402BudgetExhaustedError` | Per-call cap or daily budget hit - raise `per_call_cap_usd` / `[budget].max_per_day_usd` deliberately |
102
- | `x402 402 has no EIP-3009-payable option` | Merchant offers only permit2/other methods for $U on this network - not payable by this buyer today |
104
+ | `x402 402 has no EIP-3009-payable option` | Merchant offers only permit2/other methods for $U on this network - a local-signing (`evm-local`) buyer cannot sign those. Delegated wallets pay permit2 routes through their own client: `twak` (mainnet), or `altana` sessions (ERC-1271; B402 verifies them on the permit2 rails - arm once with `bag wallet session x402-setup`) |
105
+ | `U→Permit2 allowance … cannot cover max_usd` | Altana only: the bounded Permit2 allowance is spent/too small - re-run `bag wallet session x402-setup --allowance-u <amount>` (admin key) |
103
106
  | `X402PolicyError` / `PolicyViolation` | Signing allowlist - see `bnbagent-studio-extending-signing.md` |
104
107
 
105
108
  **Different from**:
@@ -61,7 +61,7 @@ The user wants the agent to pay e.g. `api.example.com` via x402.
61
61
  2. The service uses **EIP-3009 `TransferWithAuthorization`** (or `ReceiveWithAuthorization`). If it uses Permit2 or a custom primary type → goes to Section B.
62
62
  3. The token contract address on BSC is known and the user can confirm it. Don't guess from a token symbol - look up the deployed address.
63
63
 
64
- If any of (1)-(3) fail, **stop and tell the user**. The current release cannot integrate cross-chain services or non-EIP-3009 payment rails. Do not work around it; the SigningPolicy will refuse the request.
64
+ If any of (1)-(3) fail, **stop and tell the user**. The current release cannot integrate cross-chain services or non-EIP-3009 payment rails into the LOCAL signer. Do not work around it; the SigningPolicy will refuse the request. (Merchants that only offer permit2 are still payable without touching SigningPolicy - through a delegated wallet kind: `twak`, or `altana` sessions, whose ERC-1271 signatures B402 verifies on its permit2 rails. That is a wallet-kind choice, not a signing extension.)
65
65
 
66
66
  **Steps when (1)-(3) all pass:**
67
67
 
@@ -136,7 +136,7 @@ The `--all` form is the right move when `app/agent/studio.toml`'s `[network].def
136
136
 
137
137
  `bag doctor` prints ERC-8183 pricing as `PAID` or `FREE`. FREE works on the canonical contract stack. If a custom deployment is selected, set `ERC8183_COMMERCE_ADDRESS`, `ERC8183_ROUTER_ADDRESS`, and `ERC8183_POLICY_ADDRESS` together; a partial set fails because it can mix incompatible commerce, router, and policy deployments.
138
138
 
139
- For the inbound x402 seller rail, `bag doctor` also prints `PAID` or `FREE`. PAID requires the complete B402 merchant credential set and an `evm-local` or `twak` payout wallet. Explicit zero is anonymous FREE passthrough: it does not read B402 credentials, call the facilitator, settle a payment, or apply the paid-mode payout-wallet allowlist. Confirm the same state with `bag x402 sell status`.
139
+ For the inbound x402 seller rail, `bag doctor` also prints `PAID` or `FREE`. PAID requires the complete B402 merchant credential set; any supported wallet kind can be the payout wallet (for altana the payout lands at the admin address anchored as `[wallet].address`). Explicit zero is anonymous FREE passthrough: it does not read B402 credentials, call the facilitator, settle a payment, or apply the paid-mode payout-wallet allowlist. Confirm the same state with `bag x402 sell status`.
140
140
 
141
141
  > The current CLI has no `bag wallet transfer`, `bag erc20 approve/allowance` group, or `bag wallet balance --address` / `--token` flag. Running them returns an invalid-command or unknown-option error. Use an external wallet to move funds or set allowances; ERC-8183 funding auto-approves U as part of the buy flow.
142
142
 
@@ -138,14 +138,14 @@ Build a TodoWrite list. The shape depends on the `wallet kind`. The canonical 8-
138
138
 
139
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
140
 
141
- 1. `bag init <name> --llm-provider <p> --network <n> --storage-provider <s> --wallet-kind <k> [--protocols <comma-list>] [--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). Omit `--protocols` and `--rails` for the default A2A + X402 faces with both ERC-8183 and B402 rails; Altana instead defaults to A2A + ERC-8183 because paid B402 is unsupported. Pass either flag when the user chose another face/rail combination (`--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. The canonical stack supports FREE; if a custom deployment is selected, set all three `ERC8183_COMMERCE_ADDRESS`, `ERC8183_ROUTER_ADDRESS`, and `ERC8183_POLICY_ADDRESS` values from that same stack. 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 and altana wallets, a container for twak). For evm-local a wallet key will later leave your machine, so pair it with a throwaway `bag wallet new`; for altana only the bounded session ships - do NOT create a new wallet (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/unifiedMain.ts` (the express + A2A entrypoint, one code set for both deploy clouds) + `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`.)
141
+ 1. `bag init <name> --llm-provider <p> --network <n> --storage-provider <s> --wallet-kind <k> [--protocols <comma-list>] [--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). Omit `--protocols` and `--rails` for the default A2A + X402 faces with both ERC-8183 and B402 rails (all wallet kinds, altana included its paid B402 payout lands at the admin address). Pass either flag when the user chose another face/rail combination (`--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. The canonical stack supports FREE; if a custom deployment is selected, set all three `ERC8183_COMMERCE_ADDRESS`, `ERC8183_ROUTER_ADDRESS`, and `ERC8183_POLICY_ADDRESS` values from that same stack. 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 and altana wallets, a container for twak). For evm-local a wallet key will later leave your machine, so pair it with a throwaway `bag wallet new`; for altana only the bounded session ships - do NOT create a new wallet (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/unifiedMain.ts` (the express + A2A entrypoint, one code set for both deploy clouds) + `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
142
  > **Altana + custom contracts:** Altana sessions remain bound to the canonical ERC-8183 targets. Use `evm-local` for a custom Commerce/Router/Policy stack; doctor and deploy readiness reject this unsupported combination when the ERC-8183 rail is active.
143
143
 
144
144
  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:
145
145
  ```bash
146
146
  pnpm install # npm install works too - tooling is the user's choice
147
147
  ```
148
- 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.
148
+ The sub-project's `package.json` carries its deps: `@bnbagent/studio-runtime` (the runtime lib, pinned to the scaffolding CLI's exact version - 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.
149
149
  3. **Set the wallet password** - the USER does this, NOT you.
150
150
 
151
151
  🔒 **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`.
@@ -144,7 +144,7 @@ When the credentials, IP allowlist, and facilitator environment are ready, run t
144
144
  bag x402 sell status
145
145
  ```
146
146
 
147
- 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.
147
+ For a sandbox/trial agent, it must find an exact U kind on `eip155:97` (the probe lists the offered rails, e.g. `(eip3009, permit2-exact)`). For production it must find the mainnet environment expected by the project. A network mismatch is not safe to ignore.
148
148
 
149
149
  Run the deployment gate, then redeploy to activate the selected mode:
150
150
 
@@ -164,5 +164,6 @@ On the managed platform the deploy summary must say `x402 rail is ACTIVE` (or `A
164
164
  - 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.
165
165
  - Settlement happens before work. A later work failure retains the payment and does not trigger an automatic refund.
166
166
  - The rail activates on AgentCore and Azure Foundry targets (managed platform or self-hosted); self-hosted targets have no anonymous URL and need an operator-run envelope-v1 front.
167
- - 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.
167
+ - Every supported `wallet.kind` can be the PAID B402 payout wallet: `evm-local`, `twak`, `turnkey`, and `altana`. The payout lands at the configured `pay_to` or, by default, `[wallet].address`; for altana that address is the admin EOA (EIP-7702 the smart account address equals the admin address), so the locally-held admin keystore can always move the revenue. Register the B402 merchant credentials for that exact address. FREE x402 bypasses B402 and has no payout.
168
+ - Buyer compatibility: the 402 challenge advertises both `exact` rails - `eip3009` (EOA buyers, no pre-authorization) and `permit2-exact` (B402 verifies ERC-1271 smart-account signatures on this rail, so Altana sessions and ERC-4337 wallets can pay; the buyer needs a bounded U→Permit2 allowance first - see `bnbagent-studio-using-altana-wallet.md`). Rails are filtered against the facilitator's live `/supported`; `bag x402 sell status` prints which rails it actually offers, e.g. `(eip3009, permit2-exact)`. The seller never verifies signatures locally on either rail.
168
169
  - Never describe FREE as a zero-value B402 settlement. It bypasses B402.
@@ -48,6 +48,8 @@ x402 buying remains separate and exact-bounded:
48
48
  bag wallet session x402-setup --allowance-u <U> --yes
49
49
  ```
50
50
 
51
- Altana cannot be the b402 **seller** payout wallet for a positive price (paid mode allows `evm-local` and `twak` only); init, `bag x402 sell init`, and deploy readiness reject that paid combination. Explicit `price_usd = "0"` is allowed because FREE passthrough performs no payout and bypasses B402. The outbound buying authority above remains a separate feature.
51
+ Once armed, `bag x402 buy` pays b402-facilitated merchants (e.g. CoinMarketCap) end to end: B402 verifies the session's ERC-1271 signature on its **permit2 rails** (live since 2026-08). Studio's own b402 sellers advertise `permit2-exact` alongside `eip3009`, so Altana wallets can pay studio-hosted merchants too; eip3009-only merchants still need a 65-byte EOA signature and cannot be paid by a smart account. The buy preflight checks the U→Permit2 allowance against the spend cap, and `bag doctor` reports `[wallet] Altana x402 buying`. Use `@altananetwork/sdk` 0.7.1 in the project.
52
+
53
+ Altana can also be the b402 **seller** payout wallet for a positive price: the payout lands at `[wallet].address`, which for an EIP-7702 altana account is the admin EOA, so the locally-held admin keystore can always move the revenue. Issue the B402 merchant credentials for that exact address. Explicit `price_usd = "0"` stays FREE passthrough (no payout, bypasses B402). The outbound buying authority above remains a separate feature.
52
54
 
53
55
  For troubleshooting, run `bag doctor` and `bag wallet session status`. Do not print, parse, or copy the `signer` portion of the serialized session, and never move `.studio/wallets/` under `app/agent/`.