vapi-network 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
@@ -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.0";
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.");
@@ -49629,96 +49629,124 @@ function asRecord2(value) {
49629
49629
 
49630
49630
  // ../cli/src/brand.ts
49631
49631
  var MARK_SOURCE_WIDTH = 743;
49632
- var MARK_COLUMNS = 34;
49633
- var MARK_ROWS = 3;
49632
+ var MARK_SOURCE_HEIGHT = 659;
49633
+ var MARK_SOURCE_ROW_HEIGHT = 217;
49634
+ var MARK_COLUMNS = 21;
49635
+ var MARK_ROWS = 9;
49634
49636
  var BLOCK = "\u2588";
49635
- var MARK_STEP_MS = 70;
49636
49637
  var WORDMARK = "vAPI Network";
49637
- var RESET = "\x1B[0m";
49638
- var DEFAULT_FOREGROUND = "\x1B[39m";
49639
- var HIDE_CURSOR = "\x1B[?25l";
49640
- var SHOW_CURSOR = "\x1B[?25h";
49638
+ var WELCOME = "Welcome to the vAPI Network";
49639
+ var TAGLINE = [
49640
+ "The trusted network where agents",
49641
+ "and humans do business.",
49642
+ "",
49643
+ "Search APIs, pay per call, keep",
49644
+ "receipts. More coming soon."
49645
+ ];
49646
+ var ESC = String.fromCharCode(27);
49647
+ var RESET = `${ESC}[0m`;
49648
+ var BOLD = `${ESC}[1m`;
49649
+ var DIM = `${ESC}[2m`;
49650
+ var DEFAULT_FOREGROUND = `${ESC}[39m`;
49641
49651
  var MARK_PALETTE = {
49642
- orange: "#FF6A1A",
49643
- pink: "#FF3D8B",
49644
- lime: "#B8F32D",
49645
- cyan: "#22D3EE",
49646
- blue: "#0052FF",
49647
- purple: "#8B5CF6",
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 },
49648
49658
  ink: null
49649
49659
  };
49650
49660
  var MARK_BLOCKS = [
49651
- { row: 0, x: 2, width: 90, color: "orange", delay: 0 },
49652
- { row: 0, x: 94, width: 35, color: "pink", delay: 1 },
49653
- { row: 0, x: 131, width: 16, color: "lime", delay: 2 },
49654
- { row: 0, x: 522, width: 219, color: "ink", delay: 1 },
49655
- { row: 1, x: 124, width: 50, color: "cyan", delay: 3 },
49656
- { row: 1, x: 176, width: 24, color: "blue", delay: 4 },
49657
- { row: 1, x: 202, width: 17, color: "purple", delay: 5 },
49658
- { row: 1, x: 402, width: 219, color: "blue", delay: 4 },
49659
- { 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" }
49660
49670
  ];
49661
- function markColorEnabled(environment = {}) {
49671
+ function detectColorLevel(environment = {}) {
49662
49672
  const env = environment.env ?? process.env;
49663
49673
  const isTty = environment.isTty ?? Boolean(process.stdout.isTTY);
49664
- return isTty && !env.NO_COLOR;
49665
- }
49666
- function shouldAnimateMark(environment = {}) {
49667
- const env = environment.env ?? process.env;
49668
- if (environment.json) return false;
49669
- if (env.NO_COLOR || env.CI) return false;
49670
- return markColorEnabled(environment);
49671
- }
49672
- function renderMarkFrames(options = {}) {
49673
- const steps = [...new Set(MARK_BLOCKS.map((block) => block.delay))].sort(
49674
- (left, right) => left - right
49675
- );
49676
- return steps.map(
49677
- (step) => renderFrame(
49678
- MARK_BLOCKS.filter((block) => block.delay <= step),
49679
- options.color === true
49680
- )
49681
- );
49682
- }
49683
- function renderBanner(options) {
49684
- const frames = renderMarkFrames(options);
49685
- return [frames[frames.length - 1], WORDMARK, `v${options.version}`].join("\n");
49686
- }
49687
- async function animateBanner(options) {
49688
- const frames = renderMarkFrames({ color: options.color !== false });
49689
- const sleep = options.sleep ?? defaultSleep;
49690
- const stepMs = options.stepMs ?? MARK_STEP_MS;
49691
- options.write(HIDE_CURSOR);
49692
- try {
49693
- for (const [index2, frame] of frames.entries()) {
49694
- if (index2 > 0) options.write(`\x1B[${MARK_ROWS}A`);
49695
- options.write(
49696
- frame.split("\n").map((line) => `\r\x1B[2K${line}
49697
- `).join("")
49698
- );
49699
- if (index2 < frames.length - 1) await sleep(stepMs);
49700
- }
49701
- } finally {
49702
- options.write(SHOW_CURSOR);
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;
49703
49681
  }
49704
- options.write(`${WORDMARK}
49705
- `);
49706
- options.write(`v${options.version}
49707
- `);
49708
- }
49709
- 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) {
49710
49693
  const rows = [];
49711
49694
  for (let row = 0; row < MARK_ROWS; row += 1) {
49695
+ const sourceY = row * MARK_SOURCE_HEIGHT / MARK_ROWS;
49696
+ const band = Math.min(2, Math.floor(sourceY / MARK_SOURCE_ROW_HEIGHT));
49712
49697
  rows.push(
49713
49698
  renderRow(
49714
- blocks.filter((block) => block.row === row),
49715
- color
49699
+ MARK_BLOCKS.filter((block) => block.row === band),
49700
+ colorLevel
49716
49701
  )
49717
49702
  );
49718
49703
  }
49719
49704
  return rows.join("\n");
49720
49705
  }
49721
- 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) {
49722
49750
  const ordered = [...blocks].sort((left, right) => left.x - right.x);
49723
49751
  let column = 0;
49724
49752
  let line = "";
@@ -49729,11 +49757,11 @@ function renderRow(blocks, color) {
49729
49757
  column = start;
49730
49758
  }
49731
49759
  const width = scaleWidth(block.width);
49732
- const glyphs = BLOCK.repeat(width);
49733
- line += color ? `${ansiPrefix(block.color)}${glyphs}${RESET}` : glyphs;
49760
+ const cells = BLOCK.repeat(width);
49761
+ line += colorLevel > 0 ? `${foreground(block.color, colorLevel)}${cells}${RESET}` : cells;
49734
49762
  column += width;
49735
49763
  }
49736
- return line;
49764
+ return line + " ".repeat(Math.max(0, MARK_COLUMNS - column));
49737
49765
  }
49738
49766
  function scaleColumn(x) {
49739
49767
  return Math.round(x * MARK_COLUMNS / MARK_SOURCE_WIDTH);
@@ -49741,20 +49769,28 @@ function scaleColumn(x) {
49741
49769
  function scaleWidth(width) {
49742
49770
  return Math.max(1, Math.round(width * MARK_COLUMNS / MARK_SOURCE_WIDTH));
49743
49771
  }
49744
- function ansiPrefix(color) {
49745
- const hex3 = MARK_PALETTE[color];
49746
- if (hex3 === null) return DEFAULT_FOREGROUND;
49747
- const value = Number.parseInt(hex3.slice(1), 16);
49748
- return `\x1B[38;2;${value >> 16 & 255};${value >> 8 & 255};${value & 255}m`;
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`;
49749
49782
  }
49750
- function defaultSleep(milliseconds) {
49751
- return new Promise((resolve2) => {
49752
- setTimeout(resolve2, milliseconds);
49753
- });
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);
49754
49790
  }
49755
49791
 
49756
49792
  // ../cli/src/version.ts
49757
- var CLI_VERSION = "0.2.0";
49793
+ var CLI_VERSION = "0.2.2";
49758
49794
 
49759
49795
  // ../cli/src/cli.ts
49760
49796
  var HELP_HEADING = "vAPI Network";
@@ -49783,8 +49819,7 @@ var processIo = {
49783
49819
  stdout: (message) => process.stdout.write(`${message}
49784
49820
  `),
49785
49821
  stderr: (message) => process.stderr.write(`${message}
49786
- `),
49787
- write: (chunk) => process.stdout.write(chunk)
49822
+ `)
49788
49823
  };
49789
49824
  var UsageError = class extends Error {
49790
49825
  };
@@ -49803,7 +49838,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
49803
49838
  if (command === void 0 || command === "help" || command === "--help" || command === "-h") {
49804
49839
  requireNoArguments(args.slice(command === void 0 ? 0 : 1), command ?? "help");
49805
49840
  if (command === void 0 && !json2) {
49806
- io.stdout(staticBanner());
49841
+ showBanner(io);
49807
49842
  io.stdout(HELP.slice(HELP_HEADING.length + 2));
49808
49843
  return 0;
49809
49844
  }
@@ -49874,7 +49909,7 @@ async function initCommand(argv, json2, io, dependencies) {
49874
49909
  });
49875
49910
  const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
49876
49911
  const enableSolana = networks.includes("solana");
49877
- if (!json2) await showBanner(io);
49912
+ if (!json2) showBanner(io);
49878
49913
  const paths = getVapiPaths();
49879
49914
  let migrated = [];
49880
49915
  if (!process.env.VAPI_HOME?.trim()) {
@@ -50236,16 +50271,14 @@ function formatNextStep(label, value, note) {
50236
50271
  const step = `${label.padEnd(10)}${value}`;
50237
50272
  return note === void 0 ? step : `${step.padEnd(52)} ${note}`;
50238
50273
  }
50239
- async function showBanner(io) {
50240
- const write = io.write;
50241
- if (write === void 0 || !shouldAnimateMark()) {
50242
- io.stdout(staticBanner());
50243
- return;
50244
- }
50245
- await animateBanner({ version: CLI_VERSION, write });
50246
- }
50247
- function staticBanner() {
50248
- 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
+ );
50249
50282
  }
50250
50283
  function formatAccounts(accounts) {
50251
50284
  if (accounts.length === 0) return "No configured network accounts.";