@bnbagent/studio-cli 0.0.11-alpha.5 → 0.0.11-alpha.7

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/dist/bag.js CHANGED
@@ -52,7 +52,7 @@ import {
52
52
  x402SellerIsFree,
53
53
  x402SellerPricingState,
54
54
  x402SellerUsesB402
55
- } from "./chunk-XY6EZGQF.js";
55
+ } from "./chunk-3QSCJAXQ.js";
56
56
  import {
57
57
  TWAK_CLI_MIN_VERSION,
58
58
  TWAK_CLI_VERSION,
@@ -230,7 +230,7 @@ import {
230
230
  var CAMPAIGN_DOC_URL = "https://www.bnbchain.org/en/blog/bnb-agent-studio-is-live-on-bnb-chain-ai-agents-from-one-prompt";
231
231
  var CAMPAIGN_CHECK_TIMEOUT_MS = 6e3;
232
232
  async function fetchCampaignActive() {
233
- const { bnbPlatformApiUrl: bnbPlatformApiUrl2 } = await import("./deployCli-OQICQCKT.js");
233
+ const { bnbPlatformApiUrl: bnbPlatformApiUrl2 } = await import("./deployCli-374HYGDA.js");
234
234
  const controller = new AbortController();
235
235
  const timer = setTimeout(() => controller.abort(), CAMPAIGN_CHECK_TIMEOUT_MS);
236
236
  try {
@@ -3380,6 +3380,10 @@ function recordedX402Snapshot(azure) {
3380
3380
  credentialsComplete
3381
3381
  };
3382
3382
  }
3383
+ function recordedX402Carrier(azure) {
3384
+ const carrier = text(azure.deployed_x402_carrier);
3385
+ return carrier === "http-envelope-v1" || carrier === "incompatible-scaffold" ? carrier : void 0;
3386
+ }
3383
3387
  function descriptorName(workspaceRoot) {
3384
3388
  try {
3385
3389
  const data = JSON.parse(
@@ -3438,6 +3442,7 @@ function discoverRecordedDeployments(root) {
3438
3442
  const azureDeploymentId = text(azure.deployment_id);
3439
3443
  const azureFaces = protocolFaces(azure.deployed_faces);
3440
3444
  const azureX402 = recordedX402Snapshot(azure);
3445
+ const azureX402Carrier = recordedX402Carrier(azure);
3441
3446
  if (azureEndpoint || azureDeploymentId || text(azure.last_deploy_at)) {
3442
3447
  found.push({
3443
3448
  provider: "azure",
@@ -3447,6 +3452,7 @@ function discoverRecordedDeployments(root) {
3447
3452
  endpoint: azureEndpoint,
3448
3453
  ...azureFaces ? { faces: azureFaces } : {},
3449
3454
  ...azureX402 ? { x402: azureX402 } : {},
3455
+ ...azureX402Carrier ? { x402Carrier: azureX402Carrier } : {},
3450
3456
  status: "active"
3451
3457
  });
3452
3458
  }
@@ -4167,6 +4173,52 @@ function isFile6(p) {
4167
4173
  return false;
4168
4174
  }
4169
4175
  }
4176
+ function inspectAzureX402Carrier(agentRoot2) {
4177
+ const dockerfile = path16.join(agentRoot2, "Dockerfile");
4178
+ let entryStem = null;
4179
+ if (isFile6(dockerfile)) {
4180
+ const docker = fs17.readFileSync(dockerfile, "utf8");
4181
+ const match = docker.match(
4182
+ /(?:CMD|ENTRYPOINT)\s*\[\s*["']node["']\s*,\s*["'](?:\.\/)?dist\/([^"'/]+)\.js["']\s*\]/m
4183
+ );
4184
+ entryStem = match?.[1] ?? null;
4185
+ }
4186
+ if (entryStem === null) {
4187
+ return {
4188
+ status: "incompatible-scaffold",
4189
+ entrypoint: null,
4190
+ detail: "Dockerfile does not identify the built Azure entrypoint as CMD/ENTRYPOINT node dist/<name>.js"
4191
+ };
4192
+ }
4193
+ const entrypoint = `src/${entryStem}.ts`;
4194
+ const entryFile = path16.join(agentRoot2, entrypoint);
4195
+ if (!isFile6(entryFile)) {
4196
+ return {
4197
+ status: "incompatible-scaffold",
4198
+ entrypoint,
4199
+ detail: `${entrypoint} is selected by Dockerfile but its source is missing`
4200
+ };
4201
+ }
4202
+ const source = fs17.readFileSync(entryFile, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
4203
+ const hasSeller = /\bX402Seller\s*\.\s*create\s*\(/m.test(source);
4204
+ const hasCarrier = /\bcreateEnvelopeMiddleware\s*\(/m.test(source);
4205
+ if (!hasSeller || !hasCarrier) {
4206
+ const missing = [
4207
+ ...hasCarrier ? [] : ["createEnvelopeMiddleware"],
4208
+ ...hasSeller ? [] : ["X402Seller.create"]
4209
+ ];
4210
+ return {
4211
+ status: "incompatible-scaffold",
4212
+ entrypoint,
4213
+ detail: `${entrypoint} does not mount ${missing.join(" and ")}`
4214
+ };
4215
+ }
4216
+ return {
4217
+ status: "http-envelope-v1",
4218
+ entrypoint,
4219
+ detail: `${entrypoint} mounts the X402 seller and envelope carrier`
4220
+ };
4221
+ }
4170
4222
  function tableOf4(cfg, key) {
4171
4223
  const v = cfg[key];
4172
4224
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
@@ -4195,11 +4247,13 @@ function recordAzureDeployment(root, data, endpoint) {
4195
4247
  const tomlPath = path16.join(agentRoot2, "studio.toml");
4196
4248
  let deployedFaces = null;
4197
4249
  let deployedX402 = null;
4250
+ let deployedX402Carrier = null;
4198
4251
  try {
4199
4252
  const cfg = loadStudioCfg(deployWorkspaceRoot(root));
4200
4253
  deployedFaces = stackFaces(tableOf4(cfg, "stack"), tableOf4(cfg, "payments"));
4201
4254
  if (hasX402Face(deployedFaces)) {
4202
4255
  deployedX402 = x402DeploymentSnapshot(agentRoot2, "self");
4256
+ deployedX402Carrier = inspectAzureX402Carrier(agentRoot2).status;
4203
4257
  }
4204
4258
  } catch {
4205
4259
  }
@@ -4233,6 +4287,12 @@ function recordAzureDeployment(root, data, endpoint) {
4233
4287
  "deployed_x402_credentials_complete",
4234
4288
  deployedX402?.credentialsComplete ?? false
4235
4289
  );
4290
+ patchTomlKv(
4291
+ tomlPath,
4292
+ "azure",
4293
+ "deployed_x402_carrier",
4294
+ deployedX402Carrier ?? ""
4295
+ );
4236
4296
  }
4237
4297
  patchTomlKv(tomlPath, "azure", "last_deploy_at", (/* @__PURE__ */ new Date()).toISOString());
4238
4298
  } catch {
@@ -4255,6 +4315,7 @@ function clearAzureEndpoint(root) {
4255
4315
  patchTomlKv(tomlPath, "azure", "deployed_x402_status", "");
4256
4316
  patchTomlKv(tomlPath, "azure", "deployed_x402_price_mode", "");
4257
4317
  patchTomlKv(tomlPath, "azure", "deployed_x402_credentials_complete", false);
4318
+ patchTomlKv(tomlPath, "azure", "deployed_x402_carrier", "");
4258
4319
  } catch {
4259
4320
  }
4260
4321
  }
@@ -4362,7 +4423,24 @@ async function deployAzureFoundry(opts) {
4362
4423
  async function destroyAzureFoundry(opts) {
4363
4424
  const workspaceRoot = deployWorkspaceRoot(opts.projectRoot);
4364
4425
  if (!opts.execute) {
4365
- const extra = opts.purge ? " --purge" : "";
4426
+ if (opts.purge || opts.purgeImages) {
4427
+ return withDeployFiles(
4428
+ opts.projectRoot,
4429
+ { target: "azure/foundry", packaging: "container" },
4430
+ async (files, spec) => runDeployCliStream(
4431
+ [
4432
+ "destroy",
4433
+ "-f",
4434
+ files.configPath,
4435
+ "--yes",
4436
+ "--dry-run",
4437
+ ...opts.purgeImages ? ["--purge-images"] : [],
4438
+ ...opts.purge ? ["--purge"] : []
4439
+ ],
4440
+ { cwd: spec.agentRoot }
4441
+ )
4442
+ );
4443
+ }
4366
4444
  printOut("=== bag deploy destroy \u2014 teardown plan (dry-run) ===\n");
4367
4445
  printOut(
4368
4446
  `project: ${path16.basename(workspaceRoot)} (runtime: azure-foundry)
@@ -4370,9 +4448,7 @@ async function destroyAzureFoundry(opts) {
4370
4448
  );
4371
4449
  printOut("--- Agent (Foundry Hosted Agent) ---");
4372
4450
  printOut(
4373
- ` Teardown (delegated to bnbagent-deploy \u2014 removes the hosted agent + the Foundry resources its deploy record tracks):
4374
- bnbagent-deploy destroy --yes${extra}
4375
- Run \`bag deploy destroy --provider azure --execute\` to do this. Add \`--purge\` to also delete retained resources (e.g. the soft-deleted account, freeing the custom subdomain now instead of ~48h).`
4451
+ " Teardown (delegated to bnbagent-deploy \u2014 removes the hosted agent + the Foundry resources its deploy record tracks):\n bnbagent-deploy destroy --yes\n Run `bag deploy destroy --provider azure --execute` to do this. Add `--purge-images` to preview/remove this agent's owned ACR repository, or `--purge` to also delete retained infrastructure (e.g. the soft-deleted account, freeing the custom subdomain now instead of ~48h)."
4376
4452
  );
4377
4453
  printOut(
4378
4454
  "\n--- always note ---\n - the encrypted keystore (.studio/wallets/) is left UNTOUCHED."
@@ -4391,6 +4467,7 @@ async function destroyAzureFoundry(opts) {
4391
4467
  "-f",
4392
4468
  files.configPath,
4393
4469
  "--yes",
4470
+ ...opts.purgeImages ? ["--purge-images"] : [],
4394
4471
  ...opts.purge ? ["--purge"] : []
4395
4472
  ],
4396
4473
  { cwd: spec.agentRoot }
@@ -4551,6 +4628,20 @@ var checkEntrypointAndDockerfile = async (root, _target) => {
4551
4628
  details: { entrypoint: entry }
4552
4629
  });
4553
4630
  }
4631
+ if (hasX402Face(faces)) {
4632
+ const carrier = inspectAzureX402Carrier(agentRoot2);
4633
+ if (carrier.status !== "http-envelope-v1") {
4634
+ findings.push({
4635
+ level: "CRITICAL",
4636
+ name: "azure_x402_entrypoint_compatible",
4637
+ message: `${carrier.detail}. This scaffold cannot serve X402 even though studio.toml enables it. In a clean parent directory, run \`bag init azurex402migration --runtime azure-foundry --protocols ${faces.join(",")} --no-install --no-onboard\`, then review and merge its src/unifiedMain.ts, Dockerfile, and package scripts before redeploying. Studio will not overwrite user-owned agent code.`,
4638
+ details: {
4639
+ entrypoint: carrier.entrypoint,
4640
+ carrier: carrier.status
4641
+ }
4642
+ });
4643
+ }
4644
+ }
4554
4645
  if (!isFile6(path16.join(agentRoot2, "Dockerfile"))) {
4555
4646
  findings.push({
4556
4647
  level: "CRITICAL",
@@ -6065,9 +6156,7 @@ var LEGACY_SKILL_NAMES = [
6065
6156
  ];
6066
6157
  var ROUTER_SKILL_NAME = "bnbagent-studio";
6067
6158
  var META_FILENAME = ".bag-meta.json";
6068
- var HIDDEN_SKILL_NAMES = /* @__PURE__ */ new Set([
6069
- "bnbagent-studio-use-azure-foundry"
6070
- ]);
6159
+ var HIDDEN_SKILL_NAMES = /* @__PURE__ */ new Set();
6071
6160
  function isDir3(p) {
6072
6161
  try {
6073
6162
  return fs20.statSync(p).isDirectory();
@@ -13823,6 +13912,7 @@ async function runPrepare(opts = {}) {
13823
13912
  checkLocalKeystoreExists,
13824
13913
  checkWalletPasswordEnvSet,
13825
13914
  checkLlmProviderKeySet,
13915
+ checkPieverseKeyHash,
13826
13916
  checkCommerceReady,
13827
13917
  ...azureFoundryChecks
13828
13918
  ],
@@ -15358,9 +15448,12 @@ function registerDeploy(program) {
15358
15448
  ).option(
15359
15449
  "--yes",
15360
15450
  "Skip the typed project-name confirmation (required for --execute on a non-interactive terminal)."
15451
+ ).option(
15452
+ "--purge-images",
15453
+ "Azure: inspect and delete only this agent's owned ACR repository; dry-run unless --execute is also supplied."
15361
15454
  ).option(
15362
15455
  "--purge",
15363
- "Also delete retained resources (ECR repository + CloudWatch log groups) via bnbagent-deploy's --purge."
15456
+ "Also delete retained provider-owned infrastructure via bnbagent-deploy's --purge."
15364
15457
  ).action(
15365
15458
  act(
15366
15459
  (opts) => cmdDestroy(opts)
@@ -16095,6 +16188,7 @@ async function cmdAgent(opts, agentcoreArgs) {
16095
16188
  return rc;
16096
16189
  }
16097
16190
  await printAccessNextSteps2(root, "azure-foundry");
16191
+ await printAzureAgentClientPrompt(root);
16098
16192
  return 0;
16099
16193
  }
16100
16194
  migrateEnvLocal(root);
@@ -16468,6 +16562,60 @@ async function printAgentClientPrompt2(root, destination, opts = {}) {
16468
16562
  printOut(` Scrolled past it? Run: cat ${saved}`);
16469
16563
  }
16470
16564
  }
16565
+ async function printAzureAgentClientPrompt(root) {
16566
+ const agentRoot2 = findSubProjectRoot16("agent", root) ?? root;
16567
+ const deployment = discoverRecordedDeployments(
16568
+ deployWorkspaceRoot2(root)
16569
+ ).find((candidate) => candidate.provider === "azure");
16570
+ const endpoint = deployment?.endpoint ?? recordedEndpoint(root) ?? "<run `bag deploy info --provider azure` to recover the endpoint>";
16571
+ const faces = deployment?.faces ?? agentFacesOf(agentRoot2);
16572
+ const hasX402 = hasX402Face(faces);
16573
+ const hasA2a = hasA2aFace(faces);
16574
+ const request = hasA2a ? JSON.stringify(azureNegotiateQuickVerifyBody()) : hasX402 ? JSON.stringify(azureX402CarrierBody()) : JSON.stringify(azureNegotiateQuickVerifyBody());
16575
+ const lines = [
16576
+ "",
16577
+ CLIENT_PROMPT_RULE2,
16578
+ "\u{1F4CB} COPY EVERYTHING BELOW THIS LINE INTO CLAUDE CODE OR CURSOR",
16579
+ " \u2014 it will build and run an Azure Foundry operator/gateway client",
16580
+ CLIENT_PROMPT_RULE2,
16581
+ "I deployed a BNB Chain seller to Azure Foundry. Build a small TypeScript (fetch) Azure Foundry operator/gateway client and run one non-destructive smoke request.",
16582
+ "",
16583
+ "WHAT WAS DEPLOYED",
16584
+ `- Faces: ${faces.join(", ") || "unknown"}`,
16585
+ `- Entra-authenticated Invocations endpoint: ${endpoint}`,
16586
+ `- Token scope: ${AZURE_FOUNDRY_TOKEN_SCOPE}`,
16587
+ "- This is not an anonymous buyer URL. A public x402 buyer requires an external HTTPS gateway in front of Foundry.",
16588
+ "",
16589
+ "REQUEST",
16590
+ `- POST application/json: ${request}`,
16591
+ ...hasA2a ? ["- The input field contains the JSON-stringified negotiate payload."] : [],
16592
+ ...hasX402 ? [
16593
+ ...hasA2a ? [
16594
+ `- X402 carrier alternative: ${JSON.stringify(azureX402CarrierBody())}`
16595
+ ] : [],
16596
+ "- The outer object is http-envelope-v1. Build it with:",
16597
+ ' const inner = { prompt: "Say hi in one short sentence." };',
16598
+ ' const body = Buffer.from(JSON.stringify(inner)).toString("base64");',
16599
+ "- The outer response is another HTTP envelope. Decode response.body from base64 before parsing the inner x402 JSON."
16600
+ ] : [],
16601
+ "",
16602
+ "AUTHENTICATION AND LOGS",
16603
+ "- Obtain an Entra token for https://ai.azure.com with DefaultAzureCredential, ClientSecretCredential, or an operator-only `az account get-access-token` smoke command.",
16604
+ "- Capture the response header `x-agent-session-id`; then stream that exact invocation with `bag deploy logs --provider azure --session <id>`.",
16605
+ "",
16606
+ "YOUR TASK",
16607
+ "Create and run the client, print the outer status and body, decode the inner envelope when present, print x-agent-session-id, and show the exact logs command for that session. Do not claim that the Foundry endpoint is anonymously reachable.",
16608
+ CLIENT_PROMPT_RULE2
16609
+ ];
16610
+ const text2 = lines.join("\n");
16611
+ printOut(text2);
16612
+ const saved = persistDeploySummary2(root, text2);
16613
+ if (saved !== null) {
16614
+ printOut(`
16615
+ \u{1F4BE} Saved the copy-paste prompt above to ${saved}`);
16616
+ printOut(` Scrolled past it? Run: cat ${saved}`);
16617
+ }
16618
+ }
16471
16619
  function persistDeploySummary2(root, text2) {
16472
16620
  try {
16473
16621
  if (!fs37.statSync(path37.resolve(root)).isDirectory()) {
@@ -16810,9 +16958,10 @@ function azureX402CarrierBody() {
16810
16958
  path: "/x402",
16811
16959
  query: {},
16812
16960
  headers: { "content-type": "application/json" },
16813
- body: Buffer.from(JSON.stringify({ prompt: "" }), "utf8").toString(
16814
- "base64"
16815
- )
16961
+ body: Buffer.from(
16962
+ JSON.stringify({ prompt: "Say hi in one short sentence." }),
16963
+ "utf8"
16964
+ ).toString("base64")
16816
16965
  };
16817
16966
  }
16818
16967
  function sameFaces(a, b) {
@@ -16859,17 +17008,20 @@ function printAzureInfo(root, deployment, opts) {
16859
17008
  const x402State = deployment.x402 ?? currentX402;
16860
17009
  const x402StateSource = deployment.x402 ? "deployment-record" : "current-scaffold";
16861
17010
  const x402Drift = deployment.x402 !== void 0 && !sameX402Snapshot(deployment.x402, currentX402);
16862
- const configurationDrift = facesDrift || x402Drift;
16863
- const x402Summary = hasX402 ? deployment.x402 ? x402DeploySummaryFromSnapshot(
17011
+ const currentCarrier = hasX402Face(currentFaces) ? inspectAzureX402Carrier(agentRoot2).status : null;
17012
+ const carrierDrift = deployment.x402Carrier !== void 0 && deployment.x402Carrier !== currentCarrier;
17013
+ const configurationDrift = facesDrift || x402Drift || carrierDrift;
17014
+ const carrierVerified = deployment.x402Carrier === "http-envelope-v1";
17015
+ const x402Summary = hasX402 ? carrierVerified ? deployment.x402 ? x402DeploySummaryFromSnapshot(
16864
17016
  deployment.x402,
16865
17017
  "azure-foundry",
16866
17018
  "self",
16867
17019
  null
16868
- ) : x402DeploySummary(agentRoot2, "self", null) : "";
16869
- const x402Status = x402State?.status ?? (x402Summary.includes("ACTIVE in FREE mode") ? "free" : x402Summary.startsWith("x402 rail is ACTIVE") ? "active" : "dormant");
16870
- const x402Body = hasX402 ? azureX402CarrierBody() : void 0;
16871
- const body = hasA2a || x402Body === void 0 ? azureNegotiateQuickVerifyBody() : x402Body;
16872
- const x402Info = hasX402 ? {
17020
+ ) : x402DeploySummary(agentRoot2, "self", null) : deployment.x402Carrier === "incompatible-scaffold" ? "The deployed Azure entrypoint did not mount createEnvelopeMiddleware and X402Seller. Re-scaffold the unified entrypoint, review the diff, and redeploy." : "This deployment record predates X402 carrier verification, so the deployed artifact cannot be treated as X402-capable. Verify or migrate the unified entrypoint and redeploy." : "";
17021
+ const x402Status = carrierVerified ? x402State?.status ?? (x402Summary.includes("ACTIVE in FREE mode") ? "free" : x402Summary.startsWith("x402 rail is ACTIVE") ? "active" : "dormant") : "incompatible-scaffold";
17022
+ const x402Body = hasX402 && carrierVerified ? azureX402CarrierBody() : void 0;
17023
+ const body = hasA2a ? azureNegotiateQuickVerifyBody() : x402Body;
17024
+ const x402Info = hasX402 ? carrierVerified ? {
16873
17025
  status: x402Status,
16874
17026
  access: x402Status === "dormant" ? "dormant" : "requires-external-gateway",
16875
17027
  public_url: null,
@@ -16882,9 +17034,15 @@ function printAzureInfo(root, deployment, opts) {
16882
17034
  method: "POST",
16883
17035
  content_type: "application/json",
16884
17036
  body: x402Body,
16885
- executes_seller_work: false
17037
+ executes_seller_work: x402Status === "free"
16886
17038
  }
16887
17039
  }
17040
+ } : {
17041
+ status: "incompatible-scaffold",
17042
+ access: "incompatible-scaffold",
17043
+ public_url: null,
17044
+ summary: x402Summary,
17045
+ state_source: deployment.x402Carrier ? "deployment-record" : "unverified-deployment"
16888
17046
  } : void 0;
16889
17047
  if (opts.json) {
16890
17048
  printOut(
@@ -16903,11 +17061,11 @@ function printAzureInfo(root, deployment, opts) {
16903
17061
  resource: AZURE_FOUNDRY_TOKEN_RESOURCE,
16904
17062
  scope: AZURE_FOUNDRY_TOKEN_SCOPE
16905
17063
  },
16906
- request: {
17064
+ request: body ? {
16907
17065
  method: "POST",
16908
17066
  content_type: "application/json",
16909
17067
  body
16910
- },
17068
+ } : null,
16911
17069
  ...x402Info ? { x402: x402Info } : {}
16912
17070
  },
16913
17071
  null,
@@ -16927,10 +17085,18 @@ function printAzureInfo(root, deployment, opts) {
16927
17085
  printOut(
16928
17086
  ` authentication: Microsoft Entra bearer token (resource ${AZURE_FOUNDRY_TOKEN_RESOURCE}; SDK scope ${AZURE_FOUNDRY_TOKEN_SCOPE})`
16929
17087
  );
16930
- printOut(" request: POST application/json");
16931
- printOut(` body: ${JSON.stringify(body)}`);
17088
+ if (body) {
17089
+ printOut(" request: POST application/json");
17090
+ printOut(` body: ${JSON.stringify(body)}`);
17091
+ } else {
17092
+ printOut(
17093
+ " request: unavailable until the X402 scaffold is migrated and redeployed"
17094
+ );
17095
+ }
16932
17096
  if (x402Info) {
16933
- if (x402Info.access === "dormant") {
17097
+ if (x402Info.access === "incompatible-scaffold") {
17098
+ printOut(` x402 access: incompatible-scaffold \u2014 ${x402Info.summary}`);
17099
+ } else if (x402Info.access === "dormant") {
16934
17100
  printOut(` x402 access: dormant \u2014 ${x402Info.summary}`);
16935
17101
  } else {
16936
17102
  printOut(
@@ -16941,29 +17107,46 @@ function printAzureInfo(root, deployment, opts) {
16941
17107
  );
16942
17108
  if (hasA2a && x402Body) {
16943
17109
  printOut(
16944
- ` x402 no-work route probe: ${JSON.stringify(x402Body)} (expect an inner 400 in FREE mode or 402 before payment in PAID mode)`
17110
+ ` x402 request example: ${JSON.stringify(x402Body)} (expect work in FREE mode or 402 before payment in PAID mode)`
16945
17111
  );
16946
17112
  }
16947
17113
  printOut(` x402 gateway guide: ${foundryX402GatewayGuideUrl()}`);
16948
17114
  }
16949
17115
  }
16950
- if (opts.withCurl) {
16951
- printOut(
16952
- hasA2a ? "\nQuick-verify curl:" : "\nX402 no-work route-probe curl:"
16953
- );
17116
+ if (opts.withCurl && body) {
17117
+ printOut(hasA2a ? "\nQuick-verify curl:" : "\nX402 request curl:");
16954
17118
  printOut(
16955
17119
  ` AZURE_TOKEN=$(az account get-access-token --resource ${AZURE_FOUNDRY_TOKEN_RESOURCE} --query accessToken -o tsv)`
16956
17120
  );
16957
17121
  printOut(` AZURE_ENDPOINT=${JSON.stringify(endpoint)}`);
17122
+ printOut(" AZURE_HEADERS=$(mktemp)");
16958
17123
  printOut(
16959
- ` curl -sS -X POST "$AZURE_ENDPOINT" \\
17124
+ ` AZURE_RESPONSE=$(curl -sS -D "$AZURE_HEADERS" -X POST "$AZURE_ENDPOINT" \\
16960
17125
  -H "Authorization: Bearer $AZURE_TOKEN" \\
16961
17126
  -H "Content-Type: application/json" \\
16962
- -d '${JSON.stringify(body)}'`
17127
+ -d '${JSON.stringify(body)}')`
17128
+ );
17129
+ printOut(' printf "%s\\n" "$AZURE_RESPONSE"');
17130
+ printOut(
17131
+ ` AZURE_SESSION=$(awk 'tolower($1) == "x-agent-session-id:" {gsub(/\\r/, "", $2); print $2}' "$AZURE_HEADERS" | tail -1)`
16963
17132
  );
17133
+ printOut(' printf "session: %s\\n" "$AZURE_SESSION"');
17134
+ printOut(' bag deploy logs --provider azure --session "$AZURE_SESSION"');
17135
+ if (!hasA2a && x402Body) {
17136
+ printOut(
17137
+ "\n Decode response.body from base64 to read the inner x402 JSON."
17138
+ );
17139
+ printOut(
17140
+ ` node -e 'const outer=JSON.parse(process.argv[1]); console.log(Buffer.from(outer.body,"base64").toString("utf8"))' "$AZURE_RESPONSE"`
17141
+ );
17142
+ }
16964
17143
  printOut(
16965
17144
  "\n The Azure CLI command is only a convenient way to mint a token for this curl. Deployment itself does not require az/azd; DefaultAzureCredential or ClientSecretCredential can mint the same scope in an application."
16966
17145
  );
17146
+ } else if (opts.withCurl) {
17147
+ printErr(
17148
+ "warning: no X402 curl was emitted because the recorded Azure deployment does not prove http-envelope-v1 support; migrate and redeploy first."
17149
+ );
16967
17150
  }
16968
17151
  return 0;
16969
17152
  }
@@ -17074,6 +17257,10 @@ async function cmdDestroy(opts) {
17074
17257
  "destroy"
17075
17258
  );
17076
17259
  if (typeof deployment === "number") return deployment;
17260
+ if (opts.purgeImages && deployment.provider !== "azure") {
17261
+ printErr("error: --purge-images is only valid for Azure self-deployments");
17262
+ return 2;
17263
+ }
17077
17264
  if (deployment.provider === "bnb") {
17078
17265
  return platformDestroy({
17079
17266
  root,
@@ -17102,7 +17289,8 @@ async function cmdDestroy(opts) {
17102
17289
  return destroyAzureFoundry({
17103
17290
  projectRoot: workspaceRoot,
17104
17291
  execute: Boolean(opts.execute),
17105
- purge: Boolean(opts.purge)
17292
+ purge: Boolean(opts.purge),
17293
+ purgeImages: Boolean(opts.purgeImages)
17106
17294
  });
17107
17295
  }
17108
17296
  return runDestroy({
@@ -686,8 +686,8 @@ function packageRoot() {
686
686
  }
687
687
  }
688
688
  function studioCliVersion() {
689
- if ("0.0.11-alpha.5") {
690
- return "0.0.11-alpha.5";
689
+ if ("0.0.11-alpha.7") {
690
+ return "0.0.11-alpha.7";
691
691
  }
692
692
  const file = path3.join(packageRoot(), "package.json");
693
693
  const pkg = JSON.parse(fs3.readFileSync(file, "utf-8"));
@@ -937,7 +937,7 @@ function isTable(value) {
937
937
  }
938
938
 
939
939
  // src/cli/_deploy/deployCli.ts
940
- var DEPLOY_CLI_VERSION = "0.5.12";
940
+ var DEPLOY_CLI_VERSION = "0.5.13";
941
941
  var DEPLOY_CLI_PACKAGE = `@bnbagent/deploy-cli@${DEPLOY_CLI_VERSION}`;
942
942
  var BNB_PLATFORM_API_URL = "https://bnbagent-api.bnbchain.world";
943
943
  var BNB_PLATFORM_API_URL_ENV = "BNBAGENT_API_URL";
@@ -18,7 +18,7 @@ import {
18
18
  runPlatformAccountCommand,
19
19
  trialFromDeployCliJson,
20
20
  withDeployFiles
21
- } from "./chunk-XY6EZGQF.js";
21
+ } from "./chunk-3QSCJAXQ.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.11-alpha.5",
3
+ "version": "0.0.11-alpha.7",
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",
@@ -54,7 +54,7 @@
54
54
  "tar": "^7.4.0",
55
55
  "viem": "^2.54.0",
56
56
  "yaml": "^2.9.0",
57
- "@bnbagent/studio-runtime": "0.0.11-alpha.5"
57
+ "@bnbagent/studio-runtime": "0.0.11-alpha.7"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@a2a-js/sdk": "^0.3.14",
@@ -53,7 +53,7 @@ Treat ERC-8183 amounts as decimal strings at CLI/config boundaries and `bigint`
53
53
 
54
54
  ## CLI groups at a glance
55
55
 
56
- `init`, `scan`, `recipe`, `skills`, `wallet`, `erc8004`, `erc8183`, `x402`, `agents`, `config`, `env`, `dev`, `doctor`, `audit`, `deploy`, `platform`, `llm`, `bundle`, `budget` - see `bag --help` for details. `bag deploy [--provider bnb\|aws\|azure] [--backend aws\|azure]` is the primary deploy command; `--backend` is valid only for provider `bnb` and confirms the recipe-derived managed backend. `prepare`, `verify`, `status`, `info`, `destroy`, `logs`, and `fix-gitignore` remain lifecycle subcommands (`deploy agent` is a deprecated compatibility alias). Provider deploy/status/logs/destroy and deploy-time credential validation are delegated to pinned `@bnbagent/deploy-cli@0.5.12`.
56
+ `init`, `scan`, `recipe`, `skills`, `wallet`, `erc8004`, `erc8183`, `x402`, `agents`, `config`, `env`, `dev`, `doctor`, `audit`, `deploy`, `platform`, `llm`, `bundle`, `budget` - see `bag --help` for details. `bag deploy [--provider bnb\|aws\|azure] [--backend aws\|azure]` is the primary deploy command; `--backend` is valid only for provider `bnb` and confirms the recipe-derived managed backend. `prepare`, `verify`, `status`, `info`, `destroy`, `logs`, and `fix-gitignore` remain lifecycle subcommands (`deploy agent` is a deprecated compatibility alias). Provider deploy/status/logs/destroy and deploy-time credential validation are delegated to pinned `@bnbagent/deploy-cli@0.5.13`.
57
57
 
58
58
  ## Tool surface
59
59
 
@@ -1,6 +1,6 @@
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 lifecycle mutations are delegated to pinned `@bnbagent/deploy-cli@0.5.12`), 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.
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.5.13`), 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
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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bnbagent-studio-use-azure-foundry
3
- description: When the user wants to deploy or operate a bnbagent-studio project on Azure AI Foundry Hosted Agents - scaffold with `bag init --runtime azure-foundry`, deploy either to the managed platform with `bag deploy --provider bnb --backend azure` or directly with `bag deploy --provider azure`; all cloud lifecycle execution is delegated to pinned `@bnbagent/deploy-cli@0.5.12`. Native MCP is not supported on Azure; use AgentCore for MCP.
3
+ description: When the user wants to deploy or operate a bnbagent-studio project on Azure AI Foundry Hosted Agents - scaffold with `bag init --runtime azure-foundry`, deploy either to the managed platform with `bag deploy --provider bnb --backend azure` or directly with `bag deploy --provider azure`; all cloud lifecycle execution is delegated to pinned `@bnbagent/deploy-cli@0.5.13`. Native MCP is not supported on Azure; use AgentCore for MCP.
4
4
  ---
5
5
 
6
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.
@@ -31,7 +31,7 @@ Procedure for deploying and operating the seller Agent on **Azure AI Foundry Hos
31
31
 
32
32
  1. **Bun 1.3+ (`bunx`) on PATH** - the pinned `@bnbagent/deploy-cli` runs through it.
33
33
  2. **Docker running** - the image is built locally (linux/amd64) before push.
34
- 3. **An Azure subscription** the operator may provision in (Foundry account/project, container registry, hosted agent). Before a local self-deploy, run `bunx --bun @bnbagent/deploy-cli@0.5.12 login --provider azure`; use OIDC/service-principal credentials in CI.
34
+ 3. **An Azure subscription** the operator may provision in (Foundry account/project, container registry, hosted agent). Before a local self-deploy, run `bunx --bun @bnbagent/deploy-cli@0.5.13 login --provider azure`; use OIDC/service-principal credentials in CI.
35
35
 
36
36
  ## ⚠️ Foundry gotchas (read before deploying)
37
37
 
@@ -49,7 +49,7 @@ Procedure for deploying and operating the seller Agent on **Azure AI Foundry Hos
49
49
 
50
50
  > The encrypted keystore (`.studio/wallets/`) stays at the workspace root and rides only that secret channel - never baked into the image.
51
51
 
52
- Provider-native overrides go in the optional `studio.toml [deploy.foundry]` table (verbatim deploy-spec keys; deploy-cli 0.5.12 consumes `account`, `cpu`, `location`, `memory`, `project`, `projectEndpoint`, `protocol`, `registry`, `subscriptionId` and warns about anything else). The `[azure]` block's `subscription_id` / `account_name` / `project_name` / `project_endpoint` / `location` win over conflicting `[deploy.foundry]` keys.
52
+ Provider-native overrides go in the optional `studio.toml [deploy.foundry]` table (verbatim deploy-spec keys; deploy-cli 0.5.13 consumes `account`, `cpu`, `location`, `memory`, `project`, `projectEndpoint`, `protocol`, `registry`, `subscriptionId` and warns about anything else). The `[azure]` block's `subscription_id` / `account_name` / `project_name` / `project_endpoint` / `location` win over conflicting `[deploy.foundry]` keys.
53
53
 
54
54
  ## Typical workflow
55
55
 
@@ -95,6 +95,13 @@ Invocations request. This does not make the Azure CLI a deploy prerequisite;
95
95
  application clients may mint the same `https://ai.azure.com/.default` scope
96
96
  with `DefaultAzureCredential` or `ClientSecretCredential`.
97
97
 
98
+ The generated curl stores the response headers, extracts
99
+ `x-agent-session-id`, and prints the exact
100
+ `bag deploy logs --provider azure --session <id>` command. Without an explicit
101
+ session, logs lists the recent sessions visible to the current Azure identity.
102
+ Foundry scopes that list by identity/isolation key, so an external buyer or
103
+ gateway must still preserve the session header from its own response.
104
+
98
105
  The built-in smoke proves the container contract, not the seller signature. For a release E2E, invoke with a complete `negotiate` envelope and require `response.accepted=true`, a non-empty `negotiation_hash`, and `provider_sig`. The Invocations body is `{"input":"<serialized skill JSON>"}`.
99
106
 
100
107
  ### X402 external gateway
@@ -117,7 +124,9 @@ body:
117
124
  ```
118
125
 
119
126
  `bag deploy info --provider azure --json` reports the deployed face snapshot,
120
- seller state, carrier contract, and a no-work route probe. A PAID seller also
127
+ seller state, carrier contract, and a request example. In FREE mode that
128
+ example executes seller work without a payment; in PAID mode it returns the
129
+ inner 402 before work until a valid payment is supplied. A PAID seller also
121
130
  needs fixed facilitator egress; use an Azure Container Apps workload-profiles
122
131
  environment with VNet integration and a NAT Gateway static IP, then allowlist
123
132
  that IP with B402. Studio does not deploy or manage the gateway or network.
@@ -126,11 +135,21 @@ that IP with B402. Studio does not deploy or manage the gateway or network.
126
135
 
127
136
  ```bash
128
137
  bag deploy destroy --provider azure # dry-run plan
138
+ bag deploy destroy --provider azure --purge-images # read-only ACR repository inventory
129
139
  bag deploy destroy --provider azure --execute # delegates `destroy --yes`
140
+ bag deploy destroy --provider azure --execute --purge-images # delete this agent's owned ACR repository
130
141
  bag deploy destroy --provider azure --execute --purge # retained resources too
131
142
  ```
132
143
 
133
- `--purge` also removes the retained resources the deploy record tracks - including the soft-deleted Cognitive Services account, freeing the custom subdomain immediately (otherwise held ~48h). A successful teardown clears the recorded `[azure].agent_endpoint`.
144
+ Default destroy keeps pushed images and reports that they continue to bill for
145
+ storage. `--purge-images` inventories manifest/tag count and estimated image
146
+ size, then deletes only the deterministic `bnbagent/<agent-name>` repository in
147
+ a registry proven to be owned by bnbagent-deploy. External registry overrides,
148
+ untagged registries, and registries shared by another Foundry project are kept.
149
+ `--purge` also removes the retained resources the deploy record tracks -
150
+ including the soft-deleted Cognitive Services account, freeing the custom
151
+ subdomain immediately (otherwise held ~48h). A successful teardown clears the
152
+ recorded `[azure].agent_endpoint`.
134
153
 
135
154
  ## Scope note
136
155
 
@@ -9,7 +9,7 @@ description: Use when deploying or operating a bnbagent-studio seller on the BNB
9
9
 
10
10
  Treat this provider as a temporary testnet sandbox. Require a throwaway wallet, keep `bsc-testnet`, and explain that the runtime signing material is transmitted to the operator's managed secret store for the trial. Never use a mainnet key. Exception: `wallet.kind='altana'` ships only the bounded, budget-limited, revocable session - the throwaway-wallet advice does not apply; tighten the session instead (`bag wallet session grant --force --budget-u <small> --expiry-days <short>`) and never run `bag wallet new` on an altana project (it breaks the session's `[wallet].address` anchor).
11
11
 
12
- All auth and cloud lifecycle work must cross the pinned `@bnbagent/deploy-cli@0.5.12` boundary. Do not call a cloud CLI or platform REST routes directly. The managed backend is recipe-derived: `agentcore` uses AWS; `azure-foundry` uses Azure. For headless managed Azure, confirm with `bag deploy --provider bnb --backend azure --yes`; never treat `--backend` as a cross-cloud recipe converter.
12
+ All auth and cloud lifecycle work must cross the pinned `@bnbagent/deploy-cli@0.5.13` boundary. Do not call a cloud CLI or platform REST routes directly. The managed backend is recipe-derived: `agentcore` uses AWS; `azure-foundry` uses Azure. For headless managed Azure, confirm with `bag deploy --provider bnb --backend azure --yes`; never treat `--backend` as a cross-cloud recipe converter.
13
13
 
14
14
  ## Select and authenticate
15
15