@vapi-network/cli 0.2.1 → 0.2.2

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/index.js CHANGED
@@ -46669,7 +46669,7 @@ function csvCell(value) {
46669
46669
  import { mkdir as mkdir6, writeFile as writeFile4 } from "node:fs/promises";
46670
46670
  import { arch, platform, release } from "node:os";
46671
46671
  import { join as join2 } from "node:path";
46672
- var VAPI_CLIENT_VERSION = "0.2.1";
46672
+ var VAPI_CLIENT_VERSION = "0.2.2";
46673
46673
  async function createSupportReport(options) {
46674
46674
  const message = options.message.trim();
46675
46675
  if (!message) throw new Error("Support report message must not be empty.");
@@ -48803,132 +48803,122 @@ function asRecord(value) {
48803
48803
  var MARK_SOURCE_WIDTH = 743;
48804
48804
  var MARK_SOURCE_HEIGHT = 659;
48805
48805
  var MARK_SOURCE_ROW_HEIGHT = 217;
48806
- var MARK_COLUMNS = 28;
48807
- var MARK_ROWS = 12;
48808
- var PLAIN_BLOCK = "\u2588";
48809
- var MARK_STEP_MS = 70;
48806
+ var MARK_COLUMNS = 21;
48807
+ var MARK_ROWS = 9;
48808
+ var BLOCK = "\u2588";
48810
48809
  var WORDMARK = "vAPI Network";
48811
48810
  var WELCOME = "Welcome to the vAPI Network";
48812
48811
  var TAGLINE = [
48813
- "The trusted network where agents and humans do business.",
48814
- "Search APIs, pay per call, keep receipts. More coming soon."
48812
+ "The trusted network where agents",
48813
+ "and humans do business.",
48814
+ "",
48815
+ "Search APIs, pay per call, keep",
48816
+ "receipts. More coming soon."
48815
48817
  ];
48816
- var ESC = "\x1B";
48818
+ var ESC = String.fromCharCode(27);
48817
48819
  var RESET = `${ESC}[0m`;
48818
- var REVERSE = `${ESC}[7m`;
48819
48820
  var BOLD = `${ESC}[1m`;
48820
48821
  var DIM = `${ESC}[2m`;
48821
- var HIDE_CURSOR = `${ESC}[?25l`;
48822
- var SHOW_CURSOR = `${ESC}[?25h`;
48822
+ var DEFAULT_FOREGROUND = `${ESC}[39m`;
48823
48823
  var MARK_PALETTE = {
48824
- orange: "#ff7300",
48825
- pink: "#ff337c",
48826
- lime: "#c3ff3d",
48827
- cyan: "#97efff",
48828
- blue: "#0041eb",
48829
- purple: "#8a37fb",
48824
+ orange: { hex: "#ff7300", ansi16: 33 },
48825
+ pink: { hex: "#ff337c", ansi16: 95 },
48826
+ lime: { hex: "#c3ff3d", ansi16: 92 },
48827
+ cyan: { hex: "#97efff", ansi16: 96 },
48828
+ blue: { hex: "#0041eb", ansi16: 34 },
48829
+ purple: { hex: "#8a37fb", ansi16: 35 },
48830
48830
  ink: null
48831
48831
  };
48832
48832
  var MARK_BLOCKS = [
48833
- { row: 0, x: 2, width: 90, color: "orange", delay: 0 },
48834
- { row: 0, x: 94, width: 35, color: "pink", delay: 1 },
48835
- { row: 0, x: 131, width: 16, color: "lime", delay: 2 },
48836
- { row: 0, x: 522, width: 219, color: "ink", delay: 1 },
48837
- { row: 1, x: 124, width: 50, color: "cyan", delay: 3 },
48838
- { row: 1, x: 176, width: 24, color: "blue", delay: 4 },
48839
- { row: 1, x: 202, width: 17, color: "purple", delay: 5 },
48840
- { row: 1, x: 402, width: 219, color: "blue", delay: 4 },
48841
- { row: 2, x: 282, width: 219, color: "ink", delay: 7 }
48833
+ { row: 0, x: 2, width: 90, color: "orange" },
48834
+ { row: 0, x: 94, width: 35, color: "pink" },
48835
+ { row: 0, x: 131, width: 16, color: "lime" },
48836
+ { row: 0, x: 522, width: 219, color: "ink" },
48837
+ { row: 1, x: 124, width: 50, color: "cyan" },
48838
+ { row: 1, x: 176, width: 24, color: "blue" },
48839
+ { row: 1, x: 202, width: 17, color: "purple" },
48840
+ { row: 1, x: 402, width: 219, color: "blue" },
48841
+ { row: 2, x: 282, width: 219, color: "ink" }
48842
48842
  ];
48843
- function markColorEnabled(environment = {}) {
48843
+ function detectColorLevel(environment = {}) {
48844
48844
  const env = environment.env ?? process.env;
48845
48845
  const isTty = environment.isTty ?? Boolean(process.stdout.isTTY);
48846
- return isTty && !env.NO_COLOR;
48847
- }
48848
- function shouldAnimateMark(environment = {}) {
48849
- const env = environment.env ?? process.env;
48850
- if (environment.json) return false;
48851
- if (env.NO_COLOR || env.CI) return false;
48852
- return markColorEnabled(environment);
48853
- }
48854
- function renderMarkFrames(options = {}) {
48855
- const steps = [...new Set(MARK_BLOCKS.map((block) => block.delay))].sort(
48856
- (left, right) => left - right
48857
- );
48858
- return steps.map(
48859
- (step) => renderFrame(
48860
- MARK_BLOCKS.filter((block) => block.delay <= step),
48861
- options.color === true
48862
- )
48863
- );
48864
- }
48865
- function renderBanner(options) {
48866
- const frames = renderMarkFrames(options);
48867
- return renderBox(frames[frames.length - 1], options).join("\n");
48868
- }
48869
- async function animateBanner(options) {
48870
- const frames = renderMarkFrames({ color: options.color !== false });
48871
- const sleep = options.sleep ?? defaultSleep;
48872
- const stepMs = options.stepMs ?? MARK_STEP_MS;
48873
- const boxes = frames.map((frame) => renderBox(frame, options));
48874
- const height = boxes[0].length;
48875
- options.write(HIDE_CURSOR);
48876
- try {
48877
- for (const [index2, box] of boxes.entries()) {
48878
- if (index2 > 0) options.write(`${ESC}[${height}A`);
48879
- options.write(box.map((line) => `\r${ESC}[2K${line}
48880
- `).join(""));
48881
- if (index2 < boxes.length - 1) await sleep(stepMs);
48882
- }
48883
- } finally {
48884
- options.write(SHOW_CURSOR);
48885
- }
48886
- }
48887
- function renderBox(frame, options) {
48888
- const color = options.color === true;
48889
- const text = [
48890
- { value: WELCOME, style: BOLD },
48891
- { value: "", style: "" },
48892
- ...TAGLINE.map((line) => ({ value: line, style: "" })),
48893
- { value: "", style: "" },
48894
- { value: `${WORDMARK} v${options.version}`, style: DIM }
48895
- ];
48896
- const textWidth = Math.max(...text.map((line) => line.value.length));
48897
- const gap = 3;
48898
- const inner = 2 + MARK_COLUMNS + gap + textWidth + 2;
48899
- const markLines = frame.split("\n");
48900
- const textTop = Math.floor((MARK_ROWS - text.length) / 2);
48901
- const lines = [];
48902
- lines.push(`\u256D${"\u2500".repeat(inner)}\u256E`);
48903
- lines.push(`\u2502${" ".repeat(inner)}\u2502`);
48904
- for (let row = 0; row < MARK_ROWS; row += 1) {
48905
- const mark = markLines[row] ?? "";
48906
- const markPad = " ".repeat(Math.max(0, MARK_COLUMNS - visibleLength(mark)));
48907
- const entry = text[row - textTop];
48908
- const raw = entry?.value ?? "";
48909
- const styled = color && entry && entry.style && raw ? `${entry.style}${raw}${RESET}` : raw;
48910
- const textPad = " ".repeat(textWidth - raw.length);
48911
- lines.push(`\u2502 ${mark}${markPad}${" ".repeat(gap)}${styled}${textPad} \u2502`);
48846
+ if (env.NO_COLOR) return 0;
48847
+ const forced = env.FORCE_COLOR;
48848
+ if (forced !== void 0) {
48849
+ if (forced === "0" || forced === "false") return 0;
48850
+ if (forced === "2") return 2;
48851
+ if (forced === "3") return 3;
48852
+ return 1;
48912
48853
  }
48913
- lines.push(`\u2502${" ".repeat(inner)}\u2502`);
48914
- lines.push(`\u2570${"\u2500".repeat(inner)}\u256F`);
48915
- return lines;
48916
- }
48917
- function renderFrame(blocks, color) {
48854
+ if (!isTty) return 0;
48855
+ const term = env.TERM ?? "";
48856
+ const program = env.TERM_PROGRAM ?? "";
48857
+ if (term === "dumb") return 0;
48858
+ if (/^(truecolor|24bit)$/i.test(env.COLORTERM ?? "")) return 3;
48859
+ if (/kitty|wezterm|ghostty|alacritty/i.test(term)) return 3;
48860
+ if (/^(iTerm\.app|vscode|Hyper|WezTerm|ghostty)$/i.test(program)) return 3;
48861
+ if (/-256(?:color)?$/i.test(term) || program === "Apple_Terminal") return 2;
48862
+ return 1;
48863
+ }
48864
+ function renderMark(colorLevel = 0) {
48918
48865
  const rows = [];
48919
48866
  for (let row = 0; row < MARK_ROWS; row += 1) {
48920
48867
  const sourceY = row * MARK_SOURCE_HEIGHT / MARK_ROWS;
48921
48868
  const band = Math.min(2, Math.floor(sourceY / MARK_SOURCE_ROW_HEIGHT));
48922
48869
  rows.push(
48923
48870
  renderRow(
48924
- blocks.filter((block) => block.row === band),
48925
- color
48871
+ MARK_BLOCKS.filter((block) => block.row === band),
48872
+ colorLevel
48926
48873
  )
48927
48874
  );
48928
48875
  }
48929
48876
  return rows.join("\n");
48930
48877
  }
48931
- function renderRow(blocks, color) {
48878
+ function bannerWidth() {
48879
+ return frameInnerWidth() + 2;
48880
+ }
48881
+ function renderBanner(options) {
48882
+ const colorLevel = options.colorLevel ?? 0;
48883
+ const columns = options.columns ?? Number.POSITIVE_INFINITY;
48884
+ const text = bannerText(options.version, colorLevel);
48885
+ if (columns < bannerWidth()) {
48886
+ return text.map((line) => line.styled).join("\n");
48887
+ }
48888
+ const inner = frameInnerWidth();
48889
+ const markLines = renderMark(colorLevel).split("\n");
48890
+ const lines = [];
48891
+ lines.push(`\u256D${"\u2500".repeat(inner)}\u256E`);
48892
+ lines.push(`\u2502${" ".repeat(inner)}\u2502`);
48893
+ for (let row = 0; row < MARK_ROWS; row += 1) {
48894
+ const entry = text[row];
48895
+ const value = entry?.value ?? "";
48896
+ const styled = entry?.styled ?? "";
48897
+ const pad4 = " ".repeat(TEXT_WIDTH - value.length);
48898
+ lines.push(`\u2502 ${markLines[row]}${" ".repeat(GAP)}${styled}${pad4} \u2502`);
48899
+ }
48900
+ lines.push(`\u2502${" ".repeat(inner)}\u2502`);
48901
+ lines.push(`\u2570${"\u2500".repeat(inner)}\u256F`);
48902
+ return lines.join("\n");
48903
+ }
48904
+ var GAP = 3;
48905
+ var TEXT_WIDTH = Math.max(WELCOME.length, ...TAGLINE.map((line) => line.length));
48906
+ function frameInnerWidth() {
48907
+ return 2 + MARK_COLUMNS + GAP + TEXT_WIDTH + 2;
48908
+ }
48909
+ function bannerText(version5, colorLevel) {
48910
+ const style = (value, code) => colorLevel > 0 && value ? `${code}${value}${RESET}` : value;
48911
+ const rows = [
48912
+ { value: WELCOME, styled: style(WELCOME, BOLD) },
48913
+ { value: "", styled: "" },
48914
+ ...TAGLINE.map((line) => ({ value: line, styled: line })),
48915
+ { value: "", styled: "" },
48916
+ { value: `${WORDMARK} v${version5}`, styled: style(`${WORDMARK} v${version5}`, DIM) }
48917
+ ];
48918
+ if (rows.length > MARK_ROWS) throw new Error("banner text is taller than the mark");
48919
+ return rows;
48920
+ }
48921
+ function renderRow(blocks, colorLevel) {
48932
48922
  const ordered = [...blocks].sort((left, right) => left.x - right.x);
48933
48923
  let column = 0;
48934
48924
  let line = "";
@@ -48939,7 +48929,8 @@ function renderRow(blocks, color) {
48939
48929
  column = start;
48940
48930
  }
48941
48931
  const width = scaleWidth(block.width);
48942
- line += color ? `${cellPrefix(block.color)}${" ".repeat(width)}${RESET}` : PLAIN_BLOCK.repeat(width);
48932
+ const cells = BLOCK.repeat(width);
48933
+ line += colorLevel > 0 ? `${foreground(block.color, colorLevel)}${cells}${RESET}` : cells;
48943
48934
  column += width;
48944
48935
  }
48945
48936
  return line + " ".repeat(Math.max(0, MARK_COLUMNS - column));
@@ -48950,23 +48941,28 @@ function scaleColumn(x) {
48950
48941
  function scaleWidth(width) {
48951
48942
  return Math.max(1, Math.round(width * MARK_COLUMNS / MARK_SOURCE_WIDTH));
48952
48943
  }
48953
- function cellPrefix(color) {
48954
- const hex3 = MARK_PALETTE[color];
48955
- if (hex3 === null) return REVERSE;
48956
- const value = Number.parseInt(hex3.slice(1), 16);
48957
- return `${ESC}[48;2;${value >> 16 & 255};${value >> 8 & 255};${value & 255}m`;
48958
- }
48959
- function visibleLength(line) {
48960
- return line.replace(new RegExp(`${ESC}\\[[0-9;?]*[A-Za-z]`, "g"), "").length;
48944
+ function foreground(color, colorLevel) {
48945
+ const entry = MARK_PALETTE[color];
48946
+ if (entry === null) return DEFAULT_FOREGROUND;
48947
+ const value = Number.parseInt(entry.hex.slice(1), 16);
48948
+ const red = value >> 16 & 255;
48949
+ const green = value >> 8 & 255;
48950
+ const blue = value & 255;
48951
+ if (colorLevel === 3) return `${ESC}[38;2;${red};${green};${blue}m`;
48952
+ if (colorLevel === 2) return `${ESC}[38;5;${rgbToAnsi256(red, green, blue)}m`;
48953
+ return `${ESC}[${entry.ansi16}m`;
48961
48954
  }
48962
- function defaultSleep(milliseconds) {
48963
- return new Promise((resolve) => {
48964
- setTimeout(resolve, milliseconds);
48965
- });
48955
+ function rgbToAnsi256(red, green, blue) {
48956
+ if (red === green && green === blue) {
48957
+ if (red < 8) return 16;
48958
+ if (red > 248) return 231;
48959
+ return Math.round((red - 8) / 247 * 24) + 232;
48960
+ }
48961
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
48966
48962
  }
48967
48963
 
48968
48964
  // src/version.ts
48969
- var CLI_VERSION = "0.2.1";
48965
+ var CLI_VERSION = "0.2.2";
48970
48966
 
48971
48967
  // src/cli.ts
48972
48968
  var HELP_HEADING = "vAPI Network";
@@ -48995,8 +48991,7 @@ var processIo = {
48995
48991
  stdout: (message) => process.stdout.write(`${message}
48996
48992
  `),
48997
48993
  stderr: (message) => process.stderr.write(`${message}
48998
- `),
48999
- write: (chunk) => process.stdout.write(chunk)
48994
+ `)
49000
48995
  };
49001
48996
  var UsageError = class extends Error {
49002
48997
  };
@@ -49015,7 +49010,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
49015
49010
  if (command === void 0 || command === "help" || command === "--help" || command === "-h") {
49016
49011
  requireNoArguments(args.slice(command === void 0 ? 0 : 1), command ?? "help");
49017
49012
  if (command === void 0 && !json2) {
49018
- io.stdout(staticBanner());
49013
+ showBanner(io);
49019
49014
  io.stdout(HELP.slice(HELP_HEADING.length + 2));
49020
49015
  return 0;
49021
49016
  }
@@ -49086,7 +49081,7 @@ async function initCommand(argv, json2, io, dependencies) {
49086
49081
  });
49087
49082
  const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
49088
49083
  const enableSolana = networks.includes("solana");
49089
- if (!json2) await showBanner(io);
49084
+ if (!json2) showBanner(io);
49090
49085
  const paths = getVapiPaths();
49091
49086
  let migrated = [];
49092
49087
  if (!process.env.VAPI_HOME?.trim()) {
@@ -49448,16 +49443,14 @@ function formatNextStep(label, value, note) {
49448
49443
  const step = `${label.padEnd(10)}${value}`;
49449
49444
  return note === void 0 ? step : `${step.padEnd(52)} ${note}`;
49450
49445
  }
49451
- async function showBanner(io) {
49452
- const write = io.write;
49453
- if (write === void 0 || !shouldAnimateMark()) {
49454
- io.stdout(staticBanner());
49455
- return;
49456
- }
49457
- await animateBanner({ version: CLI_VERSION, write });
49458
- }
49459
- function staticBanner() {
49460
- return renderBanner({ version: CLI_VERSION, color: markColorEnabled() });
49446
+ function showBanner(io) {
49447
+ io.stdout(
49448
+ renderBanner({
49449
+ version: CLI_VERSION,
49450
+ colorLevel: detectColorLevel(),
49451
+ columns: process.stdout.columns
49452
+ })
49453
+ );
49461
49454
  }
49462
49455
  function formatAccounts(accounts) {
49463
49456
  if (accounts.length === 0) return "No configured network accounts.";