@vibiz/cli 0.3.2 → 0.3.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.
package/dist/vibiz.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  formatUsd,
12
12
  mergeEnvFile,
13
13
  oneKeyMessage
14
- } from "./chunk-LKIFLTGP.js";
14
+ } from "./chunk-GKTMIOI5.js";
15
15
 
16
16
  // packages/cli/src/main.ts
17
17
  import { spawn } from "node:child_process";
@@ -3409,6 +3409,13 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
3409
3409
  instant): look for broken layout. --out saves the PNGs.
3410
3410
  Each new picture is one page screenshot; repeats free
3411
3411
  vibiz projects list your projects
3412
+ vibiz health [--failing] [--json] Mission Control: every business worst first, one line
3413
+ each with its top problem (site down, failed deploy,
3414
+ errors, traffic drop, payments, limits, domain)
3415
+ vibiz health <project> [--json] all of one business's checks: what, since when, how
3416
+ to fix, and the console page
3417
+ vibiz health run [<project>] check again now (every business, or one); checks
3418
+ also run every hour on their own
3412
3419
  Web data (billed per call; every run is kept: vibiz runs, console \u25B8 Web data)
3413
3420
  vibiz scrape <url> [--json] one page as markdown
3414
3421
  vibiz design <url> [--out design.md] [--tailwind] [--shadcn] [--css] [--own] [--pages /a,/b]
@@ -3549,6 +3556,8 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
3549
3556
  (anthropic/claude-sonnet-5.5): app.vibiz.app/docs/ai
3550
3557
  vibiz ai models [search\u2026] [--all] [--json] the Vibiz models and the model each runs, with prices;
3551
3558
  --all (or a search) lists every model you can call
3559
+ vibiz ai budget [<dollars>] [--project id | --all] a project's daily AI budget: show it, or set it
3560
+ (--all: every project with AI). Full-access key to change.
3552
3561
  vibiz ai keys [set|test|remove google] [--project id]
3553
3562
  your own Google key: calls it serves run only on it
3554
3563
  and cost 0 here. set reads GEMINI_API_KEY or a hidden
@@ -3573,6 +3582,8 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
3573
3582
  vibiz billing [--json] the account's credits: balance, card, auto-recharge
3574
3583
  vibiz billing top-up <dollars> [--open] a payment link to add credits (a person pays there)
3575
3584
  vibiz billing history [--kind usage,topup] what came in and what used it
3585
+ vibiz billing limit [<dollars>] the account's daily spend limit (all projects, AI and
3586
+ web data): show it, or raise it. Full-access key to change.
3576
3587
  vibiz billing auto-recharge on|off [--threshold 5] [--amount 25] (full-access key)
3577
3588
  vibiz metrics [--period 7d] [--json] request counts, error rate and latency by capability
3578
3589
  vibiz keys [create <name> [--limited] | access <id> full|limited | revoke <id>]
@@ -3606,6 +3617,88 @@ var TOKEN_ENV = {
3606
3617
  };
3607
3618
  var usd4 = (micro) => `$${(micro / 1e6).toFixed(micro < 1e4 ? 6 : 4)}`;
3608
3619
  var dot = (status) => ({ ready: "\u25CF", failed: "\u2715", succeeded: "\u25CF", building: "\u25D0", provisioning: "\u25D0" })[status] ?? "\u25CB";
3620
+ var HEALTH_MARK = { fail: "\u2715", warn: "!", ok: "\u25CF", unknown: "\u25CB" };
3621
+ var HEALTH_WORD = {
3622
+ fail: "failing",
3623
+ warn: "warnings",
3624
+ ok: "ok",
3625
+ unknown: "not checked"
3626
+ };
3627
+ function sinceWords(c) {
3628
+ const m = Math.max(1, Math.round((Date.now() - Date.parse(c.since)) / 6e4));
3629
+ const span = m < 60 ? `${m} min` : m < 48 * 60 ? `${Math.round(m / 60)} h` : `${Math.round(m / 1440)} days`;
3630
+ return `${{ fail: "failing", warn: "warning", ok: "ok", unknown: "unknown" }[c.status]} for ${span}`;
3631
+ }
3632
+ function agoWords(iso) {
3633
+ if (!iso) return "not checked yet";
3634
+ const m = Math.round((Date.now() - Date.parse(iso)) / 6e4);
3635
+ return m < 1 ? "checked just now" : m < 60 ? `checked ${m} min ago` : `checked ${Math.round(m / 60)} h ago`;
3636
+ }
3637
+ function printProjectHealth(io, h) {
3638
+ io.log(
3639
+ `${HEALTH_MARK[h.status]} ${h.project.name} ${h.project.url ?? "(no address)"} ${HEALTH_WORD[h.status]}, ${agoWords(h.checked_at)}`
3640
+ );
3641
+ for (const c of h.checks) {
3642
+ io.log(`
3643
+ ${HEALTH_MARK[c.status]} ${c.title.padEnd(16)} ${sinceWords(c)}`);
3644
+ io.log(` ${c.detail}`);
3645
+ if ((c.status === "fail" || c.status === "warn") && c.fix) io.log(` fix: ${c.fix}`);
3646
+ if (c.status !== "ok" && c.link) io.log(` ${c.link}`);
3647
+ }
3648
+ io.log(`
3649
+ Mission Control: ${h.console_url}`);
3650
+ }
3651
+ async function healthCommand(io, positionals, values) {
3652
+ const vibiz2 = await io.client();
3653
+ const run2 = positionals[0] === "run";
3654
+ const which = run2 ? positionals[1] : positionals[0];
3655
+ const find = async (ref) => {
3656
+ const list3 = await vibiz2.health.list();
3657
+ const r = ref.toLowerCase();
3658
+ const hit = list3.data.find(
3659
+ (d) => d.project.id === ref || d.project.slug === r || d.project.name.toLowerCase() === r
3660
+ );
3661
+ if (!hit) {
3662
+ throw new Error(
3663
+ `No business "${ref}" on this account: name one by id, slug or name (vibiz health lists them).`
3664
+ );
3665
+ }
3666
+ return hit.project.id;
3667
+ };
3668
+ if (run2 && !which) {
3669
+ const out = await vibiz2.health.runAll();
3670
+ if (values.json) return io.log(JSON.stringify(out, null, 2));
3671
+ io.log(
3672
+ `Checking ${out.queued} ${out.queued === 1 ? "business" : "businesses"} now, a few at a time.`
3673
+ );
3674
+ io.log(`See them as they finish: vibiz health, or ${out.console_url}`);
3675
+ return;
3676
+ }
3677
+ if (which) {
3678
+ const id = await find(which);
3679
+ const h = run2 ? await vibiz2.health.run(id) : await vibiz2.health.get(id);
3680
+ if (values.json) return io.log(JSON.stringify(h, null, 2));
3681
+ printProjectHealth(io, h);
3682
+ return;
3683
+ }
3684
+ const list2 = await vibiz2.health.list(values.failing ? { status: ["fail"] } : {});
3685
+ if (values.json) return io.log(JSON.stringify(list2, null, 2));
3686
+ const t = list2.totals;
3687
+ io.log(
3688
+ `${t.fail} failing \xB7 ${t.warn} ${t.warn === 1 ? "warning" : "warnings"} \xB7 ${t.ok} ok${t.unknown ? ` \xB7 ${t.unknown} not checked` : ""} (${agoWords(list2.checked_at)})`
3689
+ );
3690
+ if (!list2.data.length) io.log(values.failing ? "\n Nothing failing." : "\n No projects yet.");
3691
+ const width = Math.min(28, Math.max(8, ...list2.data.map((d) => d.project.name.length)));
3692
+ for (const d of list2.data) {
3693
+ const top = d.top[0];
3694
+ io.log(
3695
+ ` ${HEALTH_MARK[d.status]} ${d.project.name.padEnd(width)} ${top ? `${top.title}: ${top.detail}` : d.checked_at ? "all good" : "not checked yet"}`
3696
+ );
3697
+ }
3698
+ io.log(`
3699
+ One business's checks and fixes: vibiz health <project>`);
3700
+ io.log(` Mission Control: ${list2.console_url}`);
3701
+ }
3609
3702
  var DOMAIN_STATUS = {
3610
3703
  pending_dns: "\u25CB waiting for DNS",
3611
3704
  verifying: "\u25D0 checking",
@@ -4587,6 +4680,7 @@ async function runCli(argv2, io) {
4587
4680
  "no-wait": { type: "boolean", default: false },
4588
4681
  period: { type: "string" },
4589
4682
  json: { type: "boolean", default: false },
4683
+ failing: { type: "boolean", default: false },
4590
4684
  errors: { type: "boolean", default: false },
4591
4685
  rage: { type: "boolean", default: false },
4592
4686
  dead: { type: "boolean", default: false },
@@ -6237,6 +6331,10 @@ ${await oneKeyLines(vibiz2, id)}`);
6237
6331
  else printAnalytics(io, report);
6238
6332
  return;
6239
6333
  }
6334
+ case "health": {
6335
+ await healthCommand(io, positionals, values);
6336
+ return;
6337
+ }
6240
6338
  case "replays": {
6241
6339
  if (positionals[0] === "frames") {
6242
6340
  await framesCommand(io, positionals[1], values);
@@ -6334,6 +6432,10 @@ ${await oneKeyLines(vibiz2, id)}`);
6334
6432
  return;
6335
6433
  }
6336
6434
  case "ai": {
6435
+ if (positionals[0] === "budget") {
6436
+ await aiBudgetCommand(io, positionals.slice(1), values);
6437
+ return;
6438
+ }
6337
6439
  if (positionals[0] === "keys") {
6338
6440
  await aiKeysCommand(io, positionals.slice(1), values);
6339
6441
  return;
@@ -6601,6 +6703,26 @@ The credits show in \`vibiz billing\` a few seconds after paying.`
6601
6703
  );
6602
6704
  return;
6603
6705
  }
6706
+ if (sub === "limit") {
6707
+ if (arg === void 0) {
6708
+ const b2 = await vibiz2.billing.get();
6709
+ io.log(
6710
+ values.json ? JSON.stringify({ daily_spend_limit_usd: b2.daily_spend_limit_usd }, null, 2) : `Daily spend limit: $${b2.daily_spend_limit_usd} a day (UTC). Raise it: vibiz billing limit <dollars>`
6711
+ );
6712
+ return;
6713
+ }
6714
+ const usdLimit = Number(arg.replace(/^\$/, ""));
6715
+ if (!Number.isFinite(usdLimit) || usdLimit <= 0) {
6716
+ throw new Error(
6717
+ "usage: vibiz billing limit <dollars a day>, e.g. vibiz billing limit 50"
6718
+ );
6719
+ }
6720
+ const b = await vibiz2.billing.update({ daily_spend_limit_usd: usdLimit });
6721
+ io.log(
6722
+ values.json ? JSON.stringify(b, null, 2) : `Daily spend limit: $${b.daily_spend_limit_usd} a day. It applies at once; the day resets at 00:00 UTC.`
6723
+ );
6724
+ return;
6725
+ }
6604
6726
  if (sub === "auto-recharge") {
6605
6727
  if (arg !== "on" && arg !== "off") {
6606
6728
  throw new Error(
@@ -6677,7 +6799,7 @@ Store the key now: it is not shown again.`
6677
6799
  return;
6678
6800
  }
6679
6801
  case "docs": {
6680
- const { DOC_TOPICS, DOCS } = await import("./src-5T426Q6L.js");
6802
+ const { DOC_TOPICS, DOCS } = await import("./src-3JKAOBIL.js");
6681
6803
  const topic = positionals[0];
6682
6804
  if (!topic || !DOC_TOPICS.includes(topic)) {
6683
6805
  for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
@@ -6702,7 +6824,7 @@ ${DOCS[topic].body}`);
6702
6824
  if (positionals[0])
6703
6825
  throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
6704
6826
  io.local();
6705
- const { serveStdio } = await import("./src-5T426Q6L.js");
6827
+ const { serveStdio } = await import("./src-3JKAOBIL.js");
6706
6828
  await serveStdio({ version: cliVersion() });
6707
6829
  return;
6708
6830
  }
@@ -6739,6 +6861,42 @@ function cliErrorLines(err) {
6739
6861
  }
6740
6862
  return [`\u2715 ${err instanceof Error ? err.message : String(err)}`];
6741
6863
  }
6864
+ async function aiBudgetCommand(io, args, values) {
6865
+ const vibiz2 = await io.client();
6866
+ const [raw] = args;
6867
+ const amount = raw === void 0 ? void 0 : Number(raw.replace(/^\$/, ""));
6868
+ if (amount !== void 0 && (!Number.isFinite(amount) || amount < 0)) {
6869
+ throw new Error(
6870
+ "usage: vibiz ai budget [<dollars a day>] [--project id | --all], e.g. vibiz ai budget 5 --all"
6871
+ );
6872
+ }
6873
+ const ids = values.all ? (await vibiz2.projects.list()).map((p) => ({ id: p.id, name: p.name })) : [{ id: values.project ?? await io.project(), name: "" }];
6874
+ const rows = [];
6875
+ for (const p of ids) {
6876
+ try {
6877
+ const r = amount === void 0 ? await vibiz2.projectAi.get(p.id) : await vibiz2.projectAi.update(p.id, { daily_budget_usd: amount });
6878
+ rows.push({
6879
+ project: p.name || p.id,
6880
+ daily_budget_usd: r.settings.daily_budget_usd,
6881
+ spent_today_usd: r.spent_today_usd
6882
+ });
6883
+ } catch (e) {
6884
+ if (values.all) continue;
6885
+ throw e;
6886
+ }
6887
+ }
6888
+ if (values.json) {
6889
+ io.log(JSON.stringify(rows, null, 2));
6890
+ return;
6891
+ }
6892
+ for (const r of rows) {
6893
+ const budget = r.daily_budget_usd === null ? "no budget" : `$${r.daily_budget_usd}/day`;
6894
+ io.log(`${r.project} ${budget} \xB7 spent today $${r.spent_today_usd.toFixed(2)}`);
6895
+ }
6896
+ if (!rows.length) io.log("No project with AI here. Add it with: vibiz add ai");
6897
+ else if (amount !== void 0) io.log("Set. It applies at once; the day resets at 00:00 UTC.");
6898
+ else io.log("Change it: vibiz ai budget <dollars> (--all for every project with AI)");
6899
+ }
6742
6900
  function modelLine(m) {
6743
6901
  const runs = m.model ? `${m.model.name} (${m.model.maker})` : `${m.name} (${m.maker ?? ""})`;
6744
6902
  const p = m.pricing ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibiz/cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "The Vibiz Stack CLI and MCP server: website, database, sign-in, email and AI for a new business, from your terminal or your AI agent.",
5
5
  "keywords": [
6
6
  "vibiz",