vapi-network 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
@@ -47022,7 +47022,7 @@ function csvCell(value) {
47022
47022
  import { mkdir as mkdir6, writeFile as writeFile4 } from "node:fs/promises";
47023
47023
  import { arch, platform, release } from "node:os";
47024
47024
  import { join as join2 } from "node:path";
47025
- var VAPI_CLIENT_VERSION = "0.2.1";
47025
+ var VAPI_CLIENT_VERSION = "0.2.2";
47026
47026
  async function createSupportReport(options) {
47027
47027
  const message = options.message.trim();
47028
47028
  if (!message) throw new Error("Support report message must not be empty.");
@@ -49631,132 +49631,122 @@ function asRecord2(value) {
49631
49631
  var MARK_SOURCE_WIDTH = 743;
49632
49632
  var MARK_SOURCE_HEIGHT = 659;
49633
49633
  var MARK_SOURCE_ROW_HEIGHT = 217;
49634
- var MARK_COLUMNS = 28;
49635
- var MARK_ROWS = 12;
49636
- var PLAIN_BLOCK = "\u2588";
49637
- var MARK_STEP_MS = 70;
49634
+ var MARK_COLUMNS = 21;
49635
+ var MARK_ROWS = 9;
49636
+ var BLOCK = "\u2588";
49638
49637
  var WORDMARK = "vAPI Network";
49639
49638
  var WELCOME = "Welcome to the vAPI Network";
49640
49639
  var TAGLINE = [
49641
- "The trusted network where agents and humans do business.",
49642
- "Search APIs, pay per call, keep receipts. More coming soon."
49640
+ "The trusted network where agents",
49641
+ "and humans do business.",
49642
+ "",
49643
+ "Search APIs, pay per call, keep",
49644
+ "receipts. More coming soon."
49643
49645
  ];
49644
- var ESC = "\x1B";
49646
+ var ESC = String.fromCharCode(27);
49645
49647
  var RESET = `${ESC}[0m`;
49646
- var REVERSE = `${ESC}[7m`;
49647
49648
  var BOLD = `${ESC}[1m`;
49648
49649
  var DIM = `${ESC}[2m`;
49649
- var HIDE_CURSOR = `${ESC}[?25l`;
49650
- var SHOW_CURSOR = `${ESC}[?25h`;
49650
+ var DEFAULT_FOREGROUND = `${ESC}[39m`;
49651
49651
  var MARK_PALETTE = {
49652
- orange: "#ff7300",
49653
- pink: "#ff337c",
49654
- lime: "#c3ff3d",
49655
- cyan: "#97efff",
49656
- blue: "#0041eb",
49657
- purple: "#8a37fb",
49652
+ orange: { hex: "#ff7300", ansi16: 33 },
49653
+ pink: { hex: "#ff337c", ansi16: 95 },
49654
+ lime: { hex: "#c3ff3d", ansi16: 92 },
49655
+ cyan: { hex: "#97efff", ansi16: 96 },
49656
+ blue: { hex: "#0041eb", ansi16: 34 },
49657
+ purple: { hex: "#8a37fb", ansi16: 35 },
49658
49658
  ink: null
49659
49659
  };
49660
49660
  var MARK_BLOCKS = [
49661
- { row: 0, x: 2, width: 90, color: "orange", delay: 0 },
49662
- { row: 0, x: 94, width: 35, color: "pink", delay: 1 },
49663
- { row: 0, x: 131, width: 16, color: "lime", delay: 2 },
49664
- { row: 0, x: 522, width: 219, color: "ink", delay: 1 },
49665
- { row: 1, x: 124, width: 50, color: "cyan", delay: 3 },
49666
- { row: 1, x: 176, width: 24, color: "blue", delay: 4 },
49667
- { row: 1, x: 202, width: 17, color: "purple", delay: 5 },
49668
- { row: 1, x: 402, width: 219, color: "blue", delay: 4 },
49669
- { row: 2, x: 282, width: 219, color: "ink", delay: 7 }
49661
+ { row: 0, x: 2, width: 90, color: "orange" },
49662
+ { row: 0, x: 94, width: 35, color: "pink" },
49663
+ { row: 0, x: 131, width: 16, color: "lime" },
49664
+ { row: 0, x: 522, width: 219, color: "ink" },
49665
+ { row: 1, x: 124, width: 50, color: "cyan" },
49666
+ { row: 1, x: 176, width: 24, color: "blue" },
49667
+ { row: 1, x: 202, width: 17, color: "purple" },
49668
+ { row: 1, x: 402, width: 219, color: "blue" },
49669
+ { row: 2, x: 282, width: 219, color: "ink" }
49670
49670
  ];
49671
- function markColorEnabled(environment = {}) {
49671
+ function detectColorLevel(environment = {}) {
49672
49672
  const env = environment.env ?? process.env;
49673
49673
  const isTty = environment.isTty ?? Boolean(process.stdout.isTTY);
49674
- return isTty && !env.NO_COLOR;
49675
- }
49676
- function shouldAnimateMark(environment = {}) {
49677
- const env = environment.env ?? process.env;
49678
- if (environment.json) return false;
49679
- if (env.NO_COLOR || env.CI) return false;
49680
- return markColorEnabled(environment);
49681
- }
49682
- function renderMarkFrames(options = {}) {
49683
- const steps = [...new Set(MARK_BLOCKS.map((block) => block.delay))].sort(
49684
- (left, right) => left - right
49685
- );
49686
- return steps.map(
49687
- (step) => renderFrame(
49688
- MARK_BLOCKS.filter((block) => block.delay <= step),
49689
- options.color === true
49690
- )
49691
- );
49692
- }
49693
- function renderBanner(options) {
49694
- const frames = renderMarkFrames(options);
49695
- return renderBox(frames[frames.length - 1], options).join("\n");
49696
- }
49697
- async function animateBanner(options) {
49698
- const frames = renderMarkFrames({ color: options.color !== false });
49699
- const sleep = options.sleep ?? defaultSleep;
49700
- const stepMs = options.stepMs ?? MARK_STEP_MS;
49701
- const boxes = frames.map((frame) => renderBox(frame, options));
49702
- const height = boxes[0].length;
49703
- options.write(HIDE_CURSOR);
49704
- try {
49705
- for (const [index2, box] of boxes.entries()) {
49706
- if (index2 > 0) options.write(`${ESC}[${height}A`);
49707
- options.write(box.map((line) => `\r${ESC}[2K${line}
49708
- `).join(""));
49709
- if (index2 < boxes.length - 1) await sleep(stepMs);
49710
- }
49711
- } finally {
49712
- options.write(SHOW_CURSOR);
49713
- }
49714
- }
49715
- function renderBox(frame, options) {
49716
- const color = options.color === true;
49717
- const text = [
49718
- { value: WELCOME, style: BOLD },
49719
- { value: "", style: "" },
49720
- ...TAGLINE.map((line) => ({ value: line, style: "" })),
49721
- { value: "", style: "" },
49722
- { value: `${WORDMARK} v${options.version}`, style: DIM }
49723
- ];
49724
- const textWidth = Math.max(...text.map((line) => line.value.length));
49725
- const gap = 3;
49726
- const inner = 2 + MARK_COLUMNS + gap + textWidth + 2;
49727
- const markLines = frame.split("\n");
49728
- const textTop = Math.floor((MARK_ROWS - text.length) / 2);
49729
- const lines = [];
49730
- lines.push(`\u256D${"\u2500".repeat(inner)}\u256E`);
49731
- lines.push(`\u2502${" ".repeat(inner)}\u2502`);
49732
- for (let row = 0; row < MARK_ROWS; row += 1) {
49733
- const mark = markLines[row] ?? "";
49734
- const markPad = " ".repeat(Math.max(0, MARK_COLUMNS - visibleLength(mark)));
49735
- const entry = text[row - textTop];
49736
- const raw = entry?.value ?? "";
49737
- const styled = color && entry && entry.style && raw ? `${entry.style}${raw}${RESET}` : raw;
49738
- const textPad = " ".repeat(textWidth - raw.length);
49739
- lines.push(`\u2502 ${mark}${markPad}${" ".repeat(gap)}${styled}${textPad} \u2502`);
49674
+ if (env.NO_COLOR) return 0;
49675
+ const forced = env.FORCE_COLOR;
49676
+ if (forced !== void 0) {
49677
+ if (forced === "0" || forced === "false") return 0;
49678
+ if (forced === "2") return 2;
49679
+ if (forced === "3") return 3;
49680
+ return 1;
49740
49681
  }
49741
- lines.push(`\u2502${" ".repeat(inner)}\u2502`);
49742
- lines.push(`\u2570${"\u2500".repeat(inner)}\u256F`);
49743
- return lines;
49744
- }
49745
- function renderFrame(blocks, color) {
49682
+ if (!isTty) return 0;
49683
+ const term = env.TERM ?? "";
49684
+ const program = env.TERM_PROGRAM ?? "";
49685
+ if (term === "dumb") return 0;
49686
+ if (/^(truecolor|24bit)$/i.test(env.COLORTERM ?? "")) return 3;
49687
+ if (/kitty|wezterm|ghostty|alacritty/i.test(term)) return 3;
49688
+ if (/^(iTerm\.app|vscode|Hyper|WezTerm|ghostty)$/i.test(program)) return 3;
49689
+ if (/-256(?:color)?$/i.test(term) || program === "Apple_Terminal") return 2;
49690
+ return 1;
49691
+ }
49692
+ function renderMark(colorLevel = 0) {
49746
49693
  const rows = [];
49747
49694
  for (let row = 0; row < MARK_ROWS; row += 1) {
49748
49695
  const sourceY = row * MARK_SOURCE_HEIGHT / MARK_ROWS;
49749
49696
  const band = Math.min(2, Math.floor(sourceY / MARK_SOURCE_ROW_HEIGHT));
49750
49697
  rows.push(
49751
49698
  renderRow(
49752
- blocks.filter((block) => block.row === band),
49753
- color
49699
+ MARK_BLOCKS.filter((block) => block.row === band),
49700
+ colorLevel
49754
49701
  )
49755
49702
  );
49756
49703
  }
49757
49704
  return rows.join("\n");
49758
49705
  }
49759
- function renderRow(blocks, color) {
49706
+ function bannerWidth() {
49707
+ return frameInnerWidth() + 2;
49708
+ }
49709
+ function renderBanner(options) {
49710
+ const colorLevel = options.colorLevel ?? 0;
49711
+ const columns = options.columns ?? Number.POSITIVE_INFINITY;
49712
+ const text = bannerText(options.version, colorLevel);
49713
+ if (columns < bannerWidth()) {
49714
+ return text.map((line) => line.styled).join("\n");
49715
+ }
49716
+ const inner = frameInnerWidth();
49717
+ const markLines = renderMark(colorLevel).split("\n");
49718
+ const lines = [];
49719
+ lines.push(`\u256D${"\u2500".repeat(inner)}\u256E`);
49720
+ lines.push(`\u2502${" ".repeat(inner)}\u2502`);
49721
+ for (let row = 0; row < MARK_ROWS; row += 1) {
49722
+ const entry = text[row];
49723
+ const value = entry?.value ?? "";
49724
+ const styled = entry?.styled ?? "";
49725
+ const pad4 = " ".repeat(TEXT_WIDTH - value.length);
49726
+ lines.push(`\u2502 ${markLines[row]}${" ".repeat(GAP)}${styled}${pad4} \u2502`);
49727
+ }
49728
+ lines.push(`\u2502${" ".repeat(inner)}\u2502`);
49729
+ lines.push(`\u2570${"\u2500".repeat(inner)}\u256F`);
49730
+ return lines.join("\n");
49731
+ }
49732
+ var GAP = 3;
49733
+ var TEXT_WIDTH = Math.max(WELCOME.length, ...TAGLINE.map((line) => line.length));
49734
+ function frameInnerWidth() {
49735
+ return 2 + MARK_COLUMNS + GAP + TEXT_WIDTH + 2;
49736
+ }
49737
+ function bannerText(version5, colorLevel) {
49738
+ const style = (value, code) => colorLevel > 0 && value ? `${code}${value}${RESET}` : value;
49739
+ const rows = [
49740
+ { value: WELCOME, styled: style(WELCOME, BOLD) },
49741
+ { value: "", styled: "" },
49742
+ ...TAGLINE.map((line) => ({ value: line, styled: line })),
49743
+ { value: "", styled: "" },
49744
+ { value: `${WORDMARK} v${version5}`, styled: style(`${WORDMARK} v${version5}`, DIM) }
49745
+ ];
49746
+ if (rows.length > MARK_ROWS) throw new Error("banner text is taller than the mark");
49747
+ return rows;
49748
+ }
49749
+ function renderRow(blocks, colorLevel) {
49760
49750
  const ordered = [...blocks].sort((left, right) => left.x - right.x);
49761
49751
  let column = 0;
49762
49752
  let line = "";
@@ -49767,7 +49757,8 @@ function renderRow(blocks, color) {
49767
49757
  column = start;
49768
49758
  }
49769
49759
  const width = scaleWidth(block.width);
49770
- line += color ? `${cellPrefix(block.color)}${" ".repeat(width)}${RESET}` : PLAIN_BLOCK.repeat(width);
49760
+ const cells = BLOCK.repeat(width);
49761
+ line += colorLevel > 0 ? `${foreground(block.color, colorLevel)}${cells}${RESET}` : cells;
49771
49762
  column += width;
49772
49763
  }
49773
49764
  return line + " ".repeat(Math.max(0, MARK_COLUMNS - column));
@@ -49778,23 +49769,28 @@ function scaleColumn(x) {
49778
49769
  function scaleWidth(width) {
49779
49770
  return Math.max(1, Math.round(width * MARK_COLUMNS / MARK_SOURCE_WIDTH));
49780
49771
  }
49781
- function cellPrefix(color) {
49782
- const hex3 = MARK_PALETTE[color];
49783
- if (hex3 === null) return REVERSE;
49784
- const value = Number.parseInt(hex3.slice(1), 16);
49785
- return `${ESC}[48;2;${value >> 16 & 255};${value >> 8 & 255};${value & 255}m`;
49786
- }
49787
- function visibleLength(line) {
49788
- return line.replace(new RegExp(`${ESC}\\[[0-9;?]*[A-Za-z]`, "g"), "").length;
49772
+ function foreground(color, colorLevel) {
49773
+ const entry = MARK_PALETTE[color];
49774
+ if (entry === null) return DEFAULT_FOREGROUND;
49775
+ const value = Number.parseInt(entry.hex.slice(1), 16);
49776
+ const red = value >> 16 & 255;
49777
+ const green = value >> 8 & 255;
49778
+ const blue = value & 255;
49779
+ if (colorLevel === 3) return `${ESC}[38;2;${red};${green};${blue}m`;
49780
+ if (colorLevel === 2) return `${ESC}[38;5;${rgbToAnsi256(red, green, blue)}m`;
49781
+ return `${ESC}[${entry.ansi16}m`;
49789
49782
  }
49790
- function defaultSleep(milliseconds) {
49791
- return new Promise((resolve2) => {
49792
- setTimeout(resolve2, milliseconds);
49793
- });
49783
+ function rgbToAnsi256(red, green, blue) {
49784
+ if (red === green && green === blue) {
49785
+ if (red < 8) return 16;
49786
+ if (red > 248) return 231;
49787
+ return Math.round((red - 8) / 247 * 24) + 232;
49788
+ }
49789
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
49794
49790
  }
49795
49791
 
49796
49792
  // ../cli/src/version.ts
49797
- var CLI_VERSION = "0.2.1";
49793
+ var CLI_VERSION = "0.2.2";
49798
49794
 
49799
49795
  // ../cli/src/cli.ts
49800
49796
  var HELP_HEADING = "vAPI Network";
@@ -49823,8 +49819,7 @@ var processIo = {
49823
49819
  stdout: (message) => process.stdout.write(`${message}
49824
49820
  `),
49825
49821
  stderr: (message) => process.stderr.write(`${message}
49826
- `),
49827
- write: (chunk) => process.stdout.write(chunk)
49822
+ `)
49828
49823
  };
49829
49824
  var UsageError = class extends Error {
49830
49825
  };
@@ -49843,7 +49838,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
49843
49838
  if (command === void 0 || command === "help" || command === "--help" || command === "-h") {
49844
49839
  requireNoArguments(args.slice(command === void 0 ? 0 : 1), command ?? "help");
49845
49840
  if (command === void 0 && !json2) {
49846
- io.stdout(staticBanner());
49841
+ showBanner(io);
49847
49842
  io.stdout(HELP.slice(HELP_HEADING.length + 2));
49848
49843
  return 0;
49849
49844
  }
@@ -49914,7 +49909,7 @@ async function initCommand(argv, json2, io, dependencies) {
49914
49909
  });
49915
49910
  const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
49916
49911
  const enableSolana = networks.includes("solana");
49917
- if (!json2) await showBanner(io);
49912
+ if (!json2) showBanner(io);
49918
49913
  const paths = getVapiPaths();
49919
49914
  let migrated = [];
49920
49915
  if (!process.env.VAPI_HOME?.trim()) {
@@ -50276,16 +50271,14 @@ function formatNextStep(label, value, note) {
50276
50271
  const step = `${label.padEnd(10)}${value}`;
50277
50272
  return note === void 0 ? step : `${step.padEnd(52)} ${note}`;
50278
50273
  }
50279
- async function showBanner(io) {
50280
- const write = io.write;
50281
- if (write === void 0 || !shouldAnimateMark()) {
50282
- io.stdout(staticBanner());
50283
- return;
50284
- }
50285
- await animateBanner({ version: CLI_VERSION, write });
50286
- }
50287
- function staticBanner() {
50288
- return renderBanner({ version: CLI_VERSION, color: markColorEnabled() });
50274
+ function showBanner(io) {
50275
+ io.stdout(
50276
+ renderBanner({
50277
+ version: CLI_VERSION,
50278
+ colorLevel: detectColorLevel(),
50279
+ columns: process.stdout.columns
50280
+ })
50281
+ );
50289
50282
  }
50290
50283
  function formatAccounts(accounts) {
50291
50284
  if (accounts.length === 0) return "No configured network accounts.";