@vapi-network/cli 0.2.0 → 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.0";
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.");
@@ -48801,96 +48801,124 @@ function asRecord(value) {
48801
48801
 
48802
48802
  // src/brand.ts
48803
48803
  var MARK_SOURCE_WIDTH = 743;
48804
- var MARK_COLUMNS = 34;
48805
- var MARK_ROWS = 3;
48804
+ var MARK_SOURCE_HEIGHT = 659;
48805
+ var MARK_SOURCE_ROW_HEIGHT = 217;
48806
+ var MARK_COLUMNS = 21;
48807
+ var MARK_ROWS = 9;
48806
48808
  var BLOCK = "\u2588";
48807
- var MARK_STEP_MS = 70;
48808
48809
  var WORDMARK = "vAPI Network";
48809
- var RESET = "\x1B[0m";
48810
- var DEFAULT_FOREGROUND = "\x1B[39m";
48811
- var HIDE_CURSOR = "\x1B[?25l";
48812
- var SHOW_CURSOR = "\x1B[?25h";
48810
+ var WELCOME = "Welcome to the vAPI Network";
48811
+ var TAGLINE = [
48812
+ "The trusted network where agents",
48813
+ "and humans do business.",
48814
+ "",
48815
+ "Search APIs, pay per call, keep",
48816
+ "receipts. More coming soon."
48817
+ ];
48818
+ var ESC = String.fromCharCode(27);
48819
+ var RESET = `${ESC}[0m`;
48820
+ var BOLD = `${ESC}[1m`;
48821
+ var DIM = `${ESC}[2m`;
48822
+ var DEFAULT_FOREGROUND = `${ESC}[39m`;
48813
48823
  var MARK_PALETTE = {
48814
- orange: "#FF6A1A",
48815
- pink: "#FF3D8B",
48816
- lime: "#B8F32D",
48817
- cyan: "#22D3EE",
48818
- blue: "#0052FF",
48819
- purple: "#8B5CF6",
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 },
48820
48830
  ink: null
48821
48831
  };
48822
48832
  var MARK_BLOCKS = [
48823
- { row: 0, x: 2, width: 90, color: "orange", delay: 0 },
48824
- { row: 0, x: 94, width: 35, color: "pink", delay: 1 },
48825
- { row: 0, x: 131, width: 16, color: "lime", delay: 2 },
48826
- { row: 0, x: 522, width: 219, color: "ink", delay: 1 },
48827
- { row: 1, x: 124, width: 50, color: "cyan", delay: 3 },
48828
- { row: 1, x: 176, width: 24, color: "blue", delay: 4 },
48829
- { row: 1, x: 202, width: 17, color: "purple", delay: 5 },
48830
- { row: 1, x: 402, width: 219, color: "blue", delay: 4 },
48831
- { 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" }
48832
48842
  ];
48833
- function markColorEnabled(environment = {}) {
48843
+ function detectColorLevel(environment = {}) {
48834
48844
  const env = environment.env ?? process.env;
48835
48845
  const isTty = environment.isTty ?? Boolean(process.stdout.isTTY);
48836
- return isTty && !env.NO_COLOR;
48837
- }
48838
- function shouldAnimateMark(environment = {}) {
48839
- const env = environment.env ?? process.env;
48840
- if (environment.json) return false;
48841
- if (env.NO_COLOR || env.CI) return false;
48842
- return markColorEnabled(environment);
48843
- }
48844
- function renderMarkFrames(options = {}) {
48845
- const steps = [...new Set(MARK_BLOCKS.map((block) => block.delay))].sort(
48846
- (left, right) => left - right
48847
- );
48848
- return steps.map(
48849
- (step) => renderFrame(
48850
- MARK_BLOCKS.filter((block) => block.delay <= step),
48851
- options.color === true
48852
- )
48853
- );
48854
- }
48855
- function renderBanner(options) {
48856
- const frames = renderMarkFrames(options);
48857
- return [frames[frames.length - 1], WORDMARK, `v${options.version}`].join("\n");
48858
- }
48859
- async function animateBanner(options) {
48860
- const frames = renderMarkFrames({ color: options.color !== false });
48861
- const sleep = options.sleep ?? defaultSleep;
48862
- const stepMs = options.stepMs ?? MARK_STEP_MS;
48863
- options.write(HIDE_CURSOR);
48864
- try {
48865
- for (const [index2, frame] of frames.entries()) {
48866
- if (index2 > 0) options.write(`\x1B[${MARK_ROWS}A`);
48867
- options.write(
48868
- frame.split("\n").map((line) => `\r\x1B[2K${line}
48869
- `).join("")
48870
- );
48871
- if (index2 < frames.length - 1) await sleep(stepMs);
48872
- }
48873
- } finally {
48874
- options.write(SHOW_CURSOR);
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;
48875
48853
  }
48876
- options.write(`${WORDMARK}
48877
- `);
48878
- options.write(`v${options.version}
48879
- `);
48880
- }
48881
- 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) {
48882
48865
  const rows = [];
48883
48866
  for (let row = 0; row < MARK_ROWS; row += 1) {
48867
+ const sourceY = row * MARK_SOURCE_HEIGHT / MARK_ROWS;
48868
+ const band = Math.min(2, Math.floor(sourceY / MARK_SOURCE_ROW_HEIGHT));
48884
48869
  rows.push(
48885
48870
  renderRow(
48886
- blocks.filter((block) => block.row === row),
48887
- color
48871
+ MARK_BLOCKS.filter((block) => block.row === band),
48872
+ colorLevel
48888
48873
  )
48889
48874
  );
48890
48875
  }
48891
48876
  return rows.join("\n");
48892
48877
  }
48893
- 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) {
48894
48922
  const ordered = [...blocks].sort((left, right) => left.x - right.x);
48895
48923
  let column = 0;
48896
48924
  let line = "";
@@ -48901,11 +48929,11 @@ function renderRow(blocks, color) {
48901
48929
  column = start;
48902
48930
  }
48903
48931
  const width = scaleWidth(block.width);
48904
- const glyphs = BLOCK.repeat(width);
48905
- line += color ? `${ansiPrefix(block.color)}${glyphs}${RESET}` : glyphs;
48932
+ const cells = BLOCK.repeat(width);
48933
+ line += colorLevel > 0 ? `${foreground(block.color, colorLevel)}${cells}${RESET}` : cells;
48906
48934
  column += width;
48907
48935
  }
48908
- return line;
48936
+ return line + " ".repeat(Math.max(0, MARK_COLUMNS - column));
48909
48937
  }
48910
48938
  function scaleColumn(x) {
48911
48939
  return Math.round(x * MARK_COLUMNS / MARK_SOURCE_WIDTH);
@@ -48913,20 +48941,28 @@ function scaleColumn(x) {
48913
48941
  function scaleWidth(width) {
48914
48942
  return Math.max(1, Math.round(width * MARK_COLUMNS / MARK_SOURCE_WIDTH));
48915
48943
  }
48916
- function ansiPrefix(color) {
48917
- const hex3 = MARK_PALETTE[color];
48918
- if (hex3 === null) return DEFAULT_FOREGROUND;
48919
- const value = Number.parseInt(hex3.slice(1), 16);
48920
- return `\x1B[38;2;${value >> 16 & 255};${value >> 8 & 255};${value & 255}m`;
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`;
48921
48954
  }
48922
- function defaultSleep(milliseconds) {
48923
- return new Promise((resolve) => {
48924
- setTimeout(resolve, milliseconds);
48925
- });
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);
48926
48962
  }
48927
48963
 
48928
48964
  // src/version.ts
48929
- var CLI_VERSION = "0.2.0";
48965
+ var CLI_VERSION = "0.2.2";
48930
48966
 
48931
48967
  // src/cli.ts
48932
48968
  var HELP_HEADING = "vAPI Network";
@@ -48955,8 +48991,7 @@ var processIo = {
48955
48991
  stdout: (message) => process.stdout.write(`${message}
48956
48992
  `),
48957
48993
  stderr: (message) => process.stderr.write(`${message}
48958
- `),
48959
- write: (chunk) => process.stdout.write(chunk)
48994
+ `)
48960
48995
  };
48961
48996
  var UsageError = class extends Error {
48962
48997
  };
@@ -48975,7 +49010,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
48975
49010
  if (command === void 0 || command === "help" || command === "--help" || command === "-h") {
48976
49011
  requireNoArguments(args.slice(command === void 0 ? 0 : 1), command ?? "help");
48977
49012
  if (command === void 0 && !json2) {
48978
- io.stdout(staticBanner());
49013
+ showBanner(io);
48979
49014
  io.stdout(HELP.slice(HELP_HEADING.length + 2));
48980
49015
  return 0;
48981
49016
  }
@@ -49046,7 +49081,7 @@ async function initCommand(argv, json2, io, dependencies) {
49046
49081
  });
49047
49082
  const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
49048
49083
  const enableSolana = networks.includes("solana");
49049
- if (!json2) await showBanner(io);
49084
+ if (!json2) showBanner(io);
49050
49085
  const paths = getVapiPaths();
49051
49086
  let migrated = [];
49052
49087
  if (!process.env.VAPI_HOME?.trim()) {
@@ -49408,16 +49443,14 @@ function formatNextStep(label, value, note) {
49408
49443
  const step = `${label.padEnd(10)}${value}`;
49409
49444
  return note === void 0 ? step : `${step.padEnd(52)} ${note}`;
49410
49445
  }
49411
- async function showBanner(io) {
49412
- const write = io.write;
49413
- if (write === void 0 || !shouldAnimateMark()) {
49414
- io.stdout(staticBanner());
49415
- return;
49416
- }
49417
- await animateBanner({ version: CLI_VERSION, write });
49418
- }
49419
- function staticBanner() {
49420
- 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
+ );
49421
49454
  }
49422
49455
  function formatAccounts(accounts) {
49423
49456
  if (accounts.length === 0) return "No configured network accounts.";