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