apiblaze 0.17.2 → 0.17.4

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.
Files changed (2) hide show
  1. package/dist/index.js +75 -70
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -204,10 +204,10 @@ async function createProxy(payload) {
204
204
  body: JSON.stringify(payload)
205
205
  });
206
206
  }
207
- async function claimTeam(code, teamId) {
207
+ async function claimTeam(code, teamId, name) {
208
208
  return apiFetch("/api/cli/claim-team", {
209
209
  method: "POST",
210
- body: JSON.stringify({ code, ...teamId ? { team_id: teamId } : {} })
210
+ body: JSON.stringify({ code, ...teamId ? { team_id: teamId } : {}, ...name ? { name } : {} })
211
211
  });
212
212
  }
213
213
  async function sidecarInitAnonymous() {
@@ -386,32 +386,32 @@ function maskBody(body) {
386
386
  }
387
387
  function renderTrace() {
388
388
  if (!verbose || entries.length === 0) return;
389
- console.log(import_chalk15.default.dim("\n" + "\u2500".repeat(64)));
390
- console.log(import_chalk15.default.bold(`--verbose: ${entries.length} API call${entries.length === 1 ? "" : "s"} this command made`));
389
+ console.log(import_chalk11.default.dim("\n" + "\u2500".repeat(64)));
390
+ console.log(import_chalk11.default.bold(`--verbose: ${entries.length} API call${entries.length === 1 ? "" : "s"} this command made`));
391
391
  console.log(
392
- import_chalk15.default.dim("The same thing on the official API \u2014 copy/paste with your control-plane key\n(get one from the Developers section of dashboard.apiblaze.com, then\n`export APIBLAZE_CONTROLPLANE_APIKEY=sk_...`).\nFull API reference: https://api.apiblaze.com/openapi.json\n")
392
+ import_chalk11.default.dim("The same thing on the official API \u2014 copy/paste with your control-plane key\n(get one from the Developers section of dashboard.apiblaze.com, then\n`export APIBLAZE_CONTROLPLANE_APIKEY=sk_...`).\nFull API reference: https://api.apiblaze.com/openapi.json\n")
393
393
  );
394
394
  entries.forEach((e, i) => {
395
- const n = entries.length > 1 ? import_chalk15.default.bold(`${i + 1}. `) : "";
396
- if (e.summary) console.log(`${n}${import_chalk15.default.cyan(e.summary)}${e.status ? import_chalk15.default.dim(` (HTTP ${e.status})`) : ""}`);
395
+ const n = entries.length > 1 ? import_chalk11.default.bold(`${i + 1}. `) : "";
396
+ if (e.summary) console.log(`${n}${import_chalk11.default.cyan(e.summary)}${e.status ? import_chalk11.default.dim(` (HTTP ${e.status})`) : ""}`);
397
397
  const url = `https://api.apiblaze.com/${CONTROL_API_VERSION}/prod${e.path}`;
398
398
  const masked = maskBody(e.body);
399
399
  const hasBody = e.method !== "GET" && masked !== void 0;
400
- console.log(import_chalk15.default.green(` curl -sS -X ${e.method} ${url}` + (hasBody ? " \\" : "")));
401
- console.log(import_chalk15.default.green(' -H "X-API-Key: $APIBLAZE_CONTROLPLANE_APIKEY"' + (hasBody ? " \\" : "")));
400
+ console.log(import_chalk11.default.green(` curl -sS -X ${e.method} ${url}` + (hasBody ? " \\" : "")));
401
+ console.log(import_chalk11.default.green(' -H "X-API-Key: $APIBLAZE_CONTROLPLANE_APIKEY"' + (hasBody ? " \\" : "")));
402
402
  if (hasBody) {
403
- console.log(import_chalk15.default.green(" -H 'Content-Type: application/json' \\"));
404
- console.log(import_chalk15.default.green(` -d '${masked}'`));
403
+ console.log(import_chalk11.default.green(" -H 'Content-Type: application/json' \\"));
404
+ console.log(import_chalk11.default.green(` -d '${masked}'`));
405
405
  }
406
406
  if (i < entries.length - 1) console.log();
407
407
  });
408
408
  entries.length = 0;
409
409
  }
410
- var import_chalk15, CONTROL_API_VERSION, verbose, entries, SECRET_KEY;
410
+ var import_chalk11, CONTROL_API_VERSION, verbose, entries, SECRET_KEY;
411
411
  var init_trace = __esm({
412
412
  "src/lib/trace.ts"() {
413
413
  "use strict";
414
- import_chalk15 = __toESM(require("chalk"));
414
+ import_chalk11 = __toESM(require("chalk"));
415
415
  CONTROL_API_VERSION = "1.0.0";
416
416
  verbose = false;
417
417
  entries = [];
@@ -440,19 +440,22 @@ async function admin(call) {
440
440
  }
441
441
  return data;
442
442
  }
443
+ function formatBilling(billing) {
444
+ const b = billing;
445
+ if (!b || typeof b.charged_cents !== "number") return null;
446
+ const usd = (b.charged_cents / 100).toFixed(2);
447
+ const rem = typeof b.credits_remaining === "number" ? ` \xB7 $${(b.credits_remaining / 100).toFixed(2)} credit left` : "";
448
+ return `\u{1F4B3} Charged $${usd}${rem}`;
449
+ }
443
450
  function maybePrintBilling(data) {
444
- const b = data?.billing;
445
- if (b && typeof b.charged_cents === "number") {
446
- const usd = (b.charged_cents / 100).toFixed(2);
447
- const rem = typeof b.credits_remaining === "number" ? ` \xB7 $${(b.credits_remaining / 100).toFixed(2)} credit left` : "";
448
- console.log(import_chalk16.default.magenta(` \u{1F4B3} Charged $${usd}${rem}`));
449
- }
451
+ const line = formatBilling(data?.billing);
452
+ if (line) console.log(import_chalk12.default.magenta(` ${line}`));
450
453
  }
451
- var import_chalk16, DASHBOARD_BASE3;
454
+ var import_chalk12, DASHBOARD_BASE3;
452
455
  var init_admin = __esm({
453
456
  "src/lib/admin.ts"() {
454
457
  "use strict";
455
- import_chalk16 = __toESM(require("chalk"));
458
+ import_chalk12 = __toESM(require("chalk"));
456
459
  init_auth();
457
460
  init_trace();
458
461
  init_types();
@@ -690,7 +693,7 @@ var import_commander = require("commander");
690
693
  var import_chalk35 = __toESM(require("chalk"));
691
694
 
692
695
  // package.json
693
- var version = "0.17.2";
696
+ var version = "0.17.4";
694
697
 
695
698
  // src/index.ts
696
699
  init_types();
@@ -1970,7 +1973,7 @@ async function runClaim(claimCodeArg, opts) {
1970
1973
  }
1971
1974
  let res;
1972
1975
  try {
1973
- res = await claimTeam(claimCode, targetTeamId);
1976
+ res = await claimTeam(claimCode, targetTeamId, opts.name);
1974
1977
  } catch (err) {
1975
1978
  if (err instanceof ApiError) {
1976
1979
  const c = typeof err.body === "object" && err.body ? err.body.error : void 0;
@@ -2000,8 +2003,9 @@ async function runClaim(claimCodeArg, opts) {
2000
2003
  if (res.merged) {
2001
2004
  console.log(` Merged ${import_chalk7.default.bold(String(res.proxy_count ?? ""))} prox${res.proxy_count === 1 ? "y" : "ies"} into team ${import_chalk7.default.bold(res.team_id)}.`);
2002
2005
  } else {
2003
- console.log(` It's now your team ${import_chalk7.default.bold(res.team_id)}. Switch to it with ${import_chalk7.default.cyan(`apiblaze team ${res.team_id}`)}.`);
2004
- console.log(import_chalk7.default.dim(` (Tip: re-run with --team <name> to merge into an existing team instead.)`));
2006
+ const label2 = res.team_name ? `\u201C${res.team_name}\u201D` : res.team_id;
2007
+ console.log(` It's now your team ${import_chalk7.default.bold(label2)}. Switch to it with ${import_chalk7.default.cyan(`apiblaze team ${res.team_id}`)}.`);
2008
+ console.log(import_chalk7.default.dim(` (Tip: name it with --name, or --team <name> to merge into an existing team instead.)`));
2005
2009
  }
2006
2010
  console.log(`
2007
2011
  Manage it at ${import_chalk7.default.cyan("https://dashboard.apiblaze.com/dashboard")}`);
@@ -2277,41 +2281,42 @@ async function runTeam(arg) {
2277
2281
  }
2278
2282
 
2279
2283
  // src/commands/authz.ts
2280
- var import_chalk12 = __toESM(require("chalk"));
2284
+ var import_chalk14 = __toESM(require("chalk"));
2281
2285
  init_auth();
2282
2286
  init_api();
2283
2287
 
2284
2288
  // src/lib/agent-chat.ts
2285
2289
  var import_readline = __toESM(require("readline"));
2286
- var import_chalk11 = __toESM(require("chalk"));
2290
+ var import_chalk13 = __toESM(require("chalk"));
2287
2291
  init_api();
2292
+ init_admin();
2288
2293
  async function runAgentChatRepl(opts) {
2289
2294
  const { title, subtitle, endpoint, buildBody, seedPrompt, summarizeProposal, commands } = opts;
2290
- console.log("\n" + import_chalk11.default.cyan.bold(title));
2291
- if (subtitle) console.log(import_chalk11.default.dim(subtitle));
2295
+ console.log("\n" + import_chalk13.default.cyan.bold(title));
2296
+ if (subtitle) console.log(import_chalk13.default.dim(subtitle));
2292
2297
  const messages = [];
2293
2298
  const ctx = { proposal: null, lastData: null, log: (s) => console.log(s) };
2294
2299
  const cmdByName = new Map(commands.map((c) => [c.name, c]));
2295
2300
  const footer = () => {
2296
2301
  const parts = [
2297
- import_chalk11.default.dim("type to chat/refine"),
2298
- ...commands.map((c) => import_chalk11.default.dim(`/${c.name} ${c.describe}`)),
2299
- import_chalk11.default.dim("/show"),
2300
- import_chalk11.default.dim("/drop discard & exit")
2302
+ import_chalk13.default.dim("type to chat/refine"),
2303
+ ...commands.map((c) => import_chalk13.default.dim(`/${c.name} ${c.describe}`)),
2304
+ import_chalk13.default.dim("/show"),
2305
+ import_chalk13.default.dim("/drop discard & exit")
2301
2306
  ];
2302
- return " " + import_chalk11.default.dim("[ ") + parts.join(import_chalk11.default.dim(" \xB7 ")) + import_chalk11.default.dim(" ]");
2307
+ return " " + import_chalk13.default.dim("[ ") + parts.join(import_chalk13.default.dim(" \xB7 ")) + import_chalk13.default.dim(" ]");
2303
2308
  };
2304
2309
  async function turn(content) {
2305
2310
  messages.push({ role: "user", content });
2306
- process.stdout.write(import_chalk11.default.dim(" \u2026thinking\n"));
2311
+ process.stdout.write(import_chalk13.default.dim(" \u2026thinking\n"));
2307
2312
  const { status, data } = await agentCall(endpoint, "POST", { messages, ...buildBody(messages) });
2308
2313
  if (status === 402) {
2309
- console.log(import_chalk11.default.red(" Insufficient credits \u2014 top up to keep using the agents.\n"));
2314
+ console.log(import_chalk13.default.red(" Insufficient credits \u2014 top up to keep using the agents.\n"));
2310
2315
  messages.pop();
2311
2316
  return;
2312
2317
  }
2313
2318
  if (status >= 400 || !data) {
2314
- console.log(import_chalk11.default.red(` Error (${status}): ${(data && data.error) ?? "request failed"}
2319
+ console.log(import_chalk13.default.red(` Error (${status}): ${(data && data.error) ?? "request failed"}
2315
2320
  `));
2316
2321
  messages.pop();
2317
2322
  return;
@@ -2319,20 +2324,19 @@ async function runAgentChatRepl(opts) {
2319
2324
  ctx.lastData = data;
2320
2325
  const reply = data.reply ?? data.message ?? "(no reply)";
2321
2326
  messages.push({ role: "assistant", content: reply });
2322
- console.log("\n" + import_chalk11.default.cyan("agent \u203A ") + reply + "\n");
2327
+ console.log("\n" + import_chalk13.default.cyan("agent \u203A ") + reply + "\n");
2323
2328
  if (data.proposal) {
2324
2329
  ctx.proposal = data.proposal;
2325
2330
  const summary = summarizeProposal?.(data);
2326
- if (summary) console.log(import_chalk11.default.yellow(" " + summary));
2331
+ if (summary) console.log(import_chalk13.default.yellow(" " + summary));
2327
2332
  const ready = commands.filter((c) => c.needsProposal).map((c) => `/${c.name}`).join(" or ");
2328
- if (ready) console.log(import_chalk11.default.dim(` Ready \u2014 ${ready} to make it official, or keep refining.`));
2333
+ if (ready) console.log(import_chalk13.default.dim(` Ready \u2014 ${ready} to make it official, or keep refining.`));
2329
2334
  console.log();
2330
2335
  }
2331
- const llm = data.llm;
2332
- if (llm) {
2333
- const credits = data.credits_remaining;
2334
- const left = typeof credits === "number" ? ` \xB7 $${(credits / 100).toFixed(2)} credit left` : "";
2335
- console.log(import_chalk11.default.dim(` ~$${(llm.cost_estimate ?? 0).toFixed(4)} \xB7 ${llm.model ?? "?"}${left}`));
2336
+ const line = formatBilling(data.billing);
2337
+ if (line) {
2338
+ const llm = data.llm;
2339
+ console.log(import_chalk13.default.dim(` ${line}${llm?.model ? ` \xB7 ${llm.model}` : ""}`));
2336
2340
  }
2337
2341
  }
2338
2342
  const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
@@ -2340,26 +2344,26 @@ async function runAgentChatRepl(opts) {
2340
2344
  await turn(seedPrompt);
2341
2345
  for (; ; ) {
2342
2346
  console.log(footer());
2343
- const line = (await ask(import_chalk11.default.green("you \u203A "))).trim();
2347
+ const line = (await ask(import_chalk13.default.green("you \u203A "))).trim();
2344
2348
  if (!line) continue;
2345
2349
  if (line === "/drop" || line === "/exit" || line === "/quit") {
2346
- console.log(import_chalk11.default.dim(" Dropped \u2014 nothing applied.\n"));
2350
+ console.log(import_chalk13.default.dim(" Dropped \u2014 nothing applied.\n"));
2347
2351
  break;
2348
2352
  }
2349
2353
  if (line === "/show") {
2350
- if (!ctx.proposal) console.log(import_chalk11.default.dim(" No proposal yet \u2014 keep chatting until the agent proposes one.\n"));
2354
+ if (!ctx.proposal) console.log(import_chalk13.default.dim(" No proposal yet \u2014 keep chatting until the agent proposes one.\n"));
2351
2355
  else console.log("\n" + JSON.stringify(ctx.proposal, null, 2) + "\n");
2352
2356
  continue;
2353
2357
  }
2354
2358
  if (line.startsWith("/")) {
2355
2359
  const cmd = cmdByName.get(line.slice(1));
2356
2360
  if (!cmd) {
2357
- console.log(import_chalk11.default.red(` Unknown command "${line}". Try one of: ${commands.map((c) => "/" + c.name).join(", ")}, /show, /drop
2361
+ console.log(import_chalk13.default.red(` Unknown command "${line}". Try one of: ${commands.map((c) => "/" + c.name).join(", ")}, /show, /drop
2358
2362
  `));
2359
2363
  continue;
2360
2364
  }
2361
2365
  if (cmd.needsProposal && !ctx.proposal) {
2362
- console.log(import_chalk11.default.yellow(" No proposal yet \u2014 keep chatting until the agent generates one, then try again.\n"));
2366
+ console.log(import_chalk13.default.yellow(" No proposal yet \u2014 keep chatting until the agent generates one, then try again.\n"));
2363
2367
  continue;
2364
2368
  }
2365
2369
  await cmd.run(ctx);
@@ -2388,11 +2392,11 @@ async function runAuthz(projectArg, apiVersionArg) {
2388
2392
  if (!enable) {
2389
2393
  const m = await agentCall(`/projects/${projectId}/${apiVersion}/policies/model?tenantId=${encodeURIComponent(tenant2)}`, "POST", proposal.model);
2390
2394
  if (m.status === 404) {
2391
- ctx.log(import_chalk12.default.red(" Authorization store not provisioned yet. Open the dashboard Authorization tab for this project once (it auto-provisions the store), then re-run.\n"));
2395
+ ctx.log(import_chalk14.default.red(" Authorization store not provisioned yet. Open the dashboard Authorization tab for this project once (it auto-provisions the store), then re-run.\n"));
2392
2396
  return;
2393
2397
  }
2394
2398
  if (m.status >= 400) {
2395
- ctx.log(import_chalk12.default.red(` Model save failed (${m.status}): ${m.data?.error ?? ""}
2399
+ ctx.log(import_chalk14.default.red(` Model save failed (${m.status}): ${m.data?.error ?? ""}
2396
2400
  `));
2397
2401
  return;
2398
2402
  }
@@ -2421,14 +2425,14 @@ async function runAuthz(projectArg, apiVersionArg) {
2421
2425
  if (enable) {
2422
2426
  const e = await agentCall(`/${projectId}/${apiVersion}/config`, "PATCH", { authorization: { enforce_authorization: true }, tenant: tenant2 });
2423
2427
  if (e.status >= 400) {
2424
- ctx.log(import_chalk12.default.red(` Enforced ${ok} route(s) but turning on the project-level switch failed (${e.status}). Toggle "Enforce Authorization" on in the dashboard.
2428
+ ctx.log(import_chalk14.default.red(` Enforced ${ok} route(s) but turning on the project-level switch failed (${e.status}). Toggle "Enforce Authorization" on in the dashboard.
2425
2429
  `));
2426
2430
  return;
2427
2431
  }
2428
- ctx.log(import_chalk12.default.green(` \u2713 Enforcement ON \u2014 ${ok} route(s) + project switch on${fail4 ? `, ${fail4} failed` : ""}.
2432
+ ctx.log(import_chalk14.default.green(` \u2713 Enforcement ON \u2014 ${ok} route(s) + project switch on${fail4 ? `, ${fail4} failed` : ""}.
2429
2433
  `));
2430
2434
  } else {
2431
- ctx.log(import_chalk12.default.green(` \u2713 Published (shadow): model + ${ok} route(s)${fail4 ? `, ${fail4} failed` : ""}. Review, then /enable.
2435
+ ctx.log(import_chalk14.default.green(` \u2713 Published (shadow): model + ${ok} route(s)${fail4 ? `, ${fail4} failed` : ""}. Review, then /enable.
2432
2436
  `));
2433
2437
  }
2434
2438
  }
@@ -2453,7 +2457,7 @@ async function runAuthz(projectArg, apiVersionArg) {
2453
2457
  }
2454
2458
 
2455
2459
  // src/commands/openapi.ts
2456
- var import_chalk13 = __toESM(require("chalk"));
2460
+ var import_chalk15 = __toESM(require("chalk"));
2457
2461
  init_auth();
2458
2462
  init_api();
2459
2463
  async function runOpenapi(projectArg, apiVersionArg) {
@@ -2464,10 +2468,10 @@ async function runOpenapi(projectArg, apiVersionArg) {
2464
2468
  if (!match) throw new Error(`Project "${projectArg}" not found in your active team. Run \`apiblaze projects\`.`);
2465
2469
  const projectId = match.projectId;
2466
2470
  const apiVersion = apiVersionArg || match.apiVersion;
2467
- console.log(import_chalk13.default.dim("Gathering captured traffic samples\u2026"));
2471
+ console.log(import_chalk15.default.dim("Gathering captured traffic samples\u2026"));
2468
2472
  const routesRes = await agentCall(`/projects/${projectId}/${apiVersion}/samples/routes`, "GET");
2469
2473
  if (routesRes.status >= 400) {
2470
- console.log(import_chalk13.default.red(`Could not list traffic (${routesRes.status}): ${routesRes.data?.error ?? ""}`));
2474
+ console.log(import_chalk15.default.red(`Could not list traffic (${routesRes.status}): ${routesRes.data?.error ?? ""}`));
2471
2475
  return;
2472
2476
  }
2473
2477
  const routes = routesRes.data?.routes ?? (Array.isArray(routesRes.data) ? routesRes.data : []);
@@ -2480,25 +2484,25 @@ async function runOpenapi(projectArg, apiVersionArg) {
2480
2484
  }
2481
2485
  const sampleIds = [...ids];
2482
2486
  if (sampleIds.length === 0) {
2483
- console.log(import_chalk13.default.yellow("No captured traffic samples found. Hit the dev environment of this proxy to capture some traces, then retry."));
2487
+ console.log(import_chalk15.default.yellow("No captured traffic samples found. Hit the dev environment of this proxy to capture some traces, then retry."));
2484
2488
  return;
2485
2489
  }
2486
2490
  async function publish(ctx) {
2487
2491
  const patch = ctx.proposal.patch;
2488
2492
  if (!Array.isArray(patch) || patch.length === 0) {
2489
- ctx.log(import_chalk13.default.green(" Nothing to publish \u2014 the spec already covers the observed traffic.\n"));
2493
+ ctx.log(import_chalk15.default.green(" Nothing to publish \u2014 the spec already covers the observed traffic.\n"));
2490
2494
  return;
2491
2495
  }
2492
2496
  const specSource = ctx.lastData?.spec_source ?? "unknown";
2493
2497
  const endpoint = specSource === "github" ? "open-pr" : "publish-openapi";
2494
2498
  const pub = await agentCall(`/projects/${projectId}/${apiVersion}/samples/${endpoint}`, "POST", { patch, sample_ids_used: sampleIds });
2495
2499
  if (pub.status >= 400) {
2496
- ctx.log(import_chalk13.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
2500
+ ctx.log(import_chalk15.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
2497
2501
  `));
2498
2502
  return;
2499
2503
  }
2500
2504
  const prUrl = pub.data?.pr_url;
2501
- ctx.log(import_chalk13.default.green(prUrl ? ` \u2713 Pull request opened: ${prUrl}
2505
+ ctx.log(import_chalk15.default.green(prUrl ? ` \u2713 Pull request opened: ${prUrl}
2502
2506
  ` : " \u2713 Published updated OpenAPI spec.\n"));
2503
2507
  }
2504
2508
  await runAgentChatRepl({
@@ -2519,7 +2523,7 @@ async function runOpenapi(projectArg, apiVersionArg) {
2519
2523
  }
2520
2524
 
2521
2525
  // src/commands/mcp.ts
2522
- var import_chalk14 = __toESM(require("chalk"));
2526
+ var import_chalk16 = __toESM(require("chalk"));
2523
2527
  init_auth();
2524
2528
  init_api();
2525
2529
  async function runMcp(projectArg, apiVersionArg, opts) {
@@ -2536,11 +2540,11 @@ async function runMcp(projectArg, apiVersionArg, opts) {
2536
2540
  const spec2 = ctx.proposal;
2537
2541
  const pub = await agentCall(`/projects/${projectId}/${apiVersion}/mcp/spec`, "PUT", { environment, spec: spec2 });
2538
2542
  if (pub.status >= 400) {
2539
- ctx.log(import_chalk14.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
2543
+ ctx.log(import_chalk16.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
2540
2544
  `));
2541
2545
  return;
2542
2546
  }
2543
- ctx.log(import_chalk14.default.green(` \u2713 Published MCP server \u2014 ${mcpHost}.mcp.apiblaze.com/${apiVersion}/${environment}.
2547
+ ctx.log(import_chalk16.default.green(` \u2713 Published MCP server \u2014 ${mcpHost}.mcp.apiblaze.com/${apiVersion}/${environment}.
2544
2548
  `));
2545
2549
  }
2546
2550
  await runAgentChatRepl({
@@ -3580,6 +3584,7 @@ async function runSpecSet(project, opts) {
3580
3584
  var import_chalk28 = __toESM(require("chalk"));
3581
3585
  var import_ora13 = __toESM(require("ora"));
3582
3586
  init_auth();
3587
+ init_admin();
3583
3588
 
3584
3589
  // src/lib/tools.ts
3585
3590
  var import_chalk27 = __toESM(require("chalk"));
@@ -3763,9 +3768,9 @@ function truncate(value, max = 1500) {
3763
3768
  if (s.length <= max) return s;
3764
3769
  return s.slice(0, max) + `\u2026 [truncated ${s.length - max} chars]`;
3765
3770
  }
3766
- function printCost(llm) {
3767
- const usd = llm.cost > 0 ? `$${llm.cost.toFixed(4)}` : "<$0.0001";
3768
- console.log(import_chalk28.default.magenta(` \u{1F4B3} ${usd}`) + import_chalk28.default.dim(` (${llm.model}, ${llm.total_tokens} tok)`));
3771
+ function printCost(resp) {
3772
+ const line = formatBilling(resp.billing);
3773
+ if (line) console.log(import_chalk28.default.magenta(` ${line}`) + import_chalk28.default.dim(` (${resp.llm.model}, ${resp.llm.total_tokens} tok)`));
3769
3774
  }
3770
3775
  async function runAgent(opts) {
3771
3776
  requireAuth();
@@ -3795,7 +3800,7 @@ async function runAgent(opts) {
3795
3800
  throw err;
3796
3801
  }
3797
3802
  history.push({ role: "assistant", content: resp.raw });
3798
- printCost(resp.llm);
3803
+ printCost(resp);
3799
3804
  if (resp.reply) console.log(import_chalk28.default.green("agent") + " \u203A " + resp.reply);
3800
3805
  if (!resp.action) break;
3801
3806
  const tool = findTool(resp.action.tool);
@@ -5489,7 +5494,7 @@ program.command("whoami").description("Show who you are \u2014 both API Producer
5489
5494
  process.exit(1);
5490
5495
  }
5491
5496
  });
5492
- program.command("claim").description("Claim your anonymous workspace into your account (requires login)").argument("[code]", "Claim code from `create`/`init` output (omit to claim this machine's workspace)").option("--team <id|name>", "Merge into this existing team (default: promote to a new team)").option("--json", "Output machine-readable JSON (non-interactive)").action(async (code, opts) => {
5497
+ program.command("claim").description("Claim your anonymous workspace into your account (requires login)").argument("[code]", "Claim code from `create`/`init` output (omit to claim this machine's workspace)").option("--team <id|name>", "Merge into this existing team (default: promote to a new team)").option("--name <name>", "Name for the new team (promote only; defaults to your proxy's target host)").option("--json", "Output machine-readable JSON (non-interactive)").action(async (code, opts) => {
5493
5498
  try {
5494
5499
  await runClaim(code, opts);
5495
5500
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "APIblaze CLI + sidecar — manage API proxies, run dev tunnels, and route a Next.js app's egress through APIblaze with one command",
5
5
  "keywords": [
6
6
  "apiblaze",