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