agentv 0.7.4 → 0.7.5

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.
@@ -590,7 +590,7 @@ import fg from "fast-glob";
590
590
  import { stat as stat3 } from "node:fs/promises";
591
591
  import path15 from "node:path";
592
592
 
593
- // ../../packages/core/dist/chunk-L6RCDZ4Z.js
593
+ // ../../packages/core/dist/chunk-7XM7HYRS.js
594
594
  import { constants } from "node:fs";
595
595
  import { access, readFile } from "node:fs/promises";
596
596
  import path from "node:path";
@@ -4636,7 +4636,7 @@ var coerce = {
4636
4636
  };
4637
4637
  var NEVER = INVALID;
4638
4638
 
4639
- // ../../packages/core/dist/chunk-L6RCDZ4Z.js
4639
+ // ../../packages/core/dist/chunk-7XM7HYRS.js
4640
4640
  async function fileExists(filePath) {
4641
4641
  try {
4642
4642
  await access(filePath, constants.F_OK);
@@ -4645,9 +4645,12 @@ async function fileExists(filePath) {
4645
4645
  return false;
4646
4646
  }
4647
4647
  }
4648
+ function normalizeLineEndings(content) {
4649
+ return content.replace(/\r\n/g, "\n");
4650
+ }
4648
4651
  async function readTextFile(filePath) {
4649
4652
  const content = await readFile(filePath, "utf8");
4650
- return content.replace(/\r\n/g, "\n");
4653
+ return normalizeLineEndings(content);
4651
4654
  }
4652
4655
  async function findGitRoot(startPath) {
4653
4656
  let currentDir = path.dirname(path.resolve(startPath));
@@ -12433,7 +12436,6 @@ async function defaultCommandRunner(command, options) {
12433
12436
  };
12434
12437
  try {
12435
12438
  const { stdout, stderr } = await execAsync2(command, execOptions);
12436
- console.error(`[CLI DEBUG] SUCCESS - stdout: ${stdout.length} bytes, stderr: ${stderr.length} bytes`);
12437
12439
  return {
12438
12440
  stdout,
12439
12441
  stderr,
@@ -12444,8 +12446,6 @@ async function defaultCommandRunner(command, options) {
12444
12446
  };
12445
12447
  } catch (error) {
12446
12448
  const execError = error;
12447
- console.error(`[CLI DEBUG] ERROR - code: ${execError.code}, message: ${execError.message}`);
12448
- console.error(`[CLI DEBUG] stdout: ${execError.stdout?.length ?? 0} bytes, stderr: ${execError.stderr?.length ?? 0} bytes`);
12449
12449
  return {
12450
12450
  stdout: execError.stdout ?? "",
12451
12451
  stderr: execError.stderr ?? "",
@@ -12513,7 +12513,7 @@ var CliProvider = class {
12513
12513
  }
12514
12514
  async readAndCleanupOutputFile(filePath) {
12515
12515
  try {
12516
- const content = await fs.readFile(filePath, "utf-8");
12516
+ const content = await readTextFile(filePath);
12517
12517
  return content;
12518
12518
  } catch (error) {
12519
12519
  const errorMsg = error instanceof Error ? error.message : String(error);
@@ -15331,9 +15331,10 @@ var YamlWriter = class _YamlWriter {
15331
15331
  // Let YAML library choose appropriate string style based on content
15332
15332
  // (will use block literal for multiline strings with actual newlines)
15333
15333
  });
15334
+ const normalizedYaml = normalizeLineEndings(yamlDoc);
15334
15335
  const separator = this.isFirst ? "---\n" : "\n---\n";
15335
15336
  this.isFirst = false;
15336
- const content = `${separator}${yamlDoc}`;
15337
+ const content = `${separator}${normalizedYaml}`;
15337
15338
  if (!this.stream.write(content)) {
15338
15339
  await new Promise((resolve, reject) => {
15339
15340
  this.stream.once("drain", resolve);
@@ -15379,27 +15380,42 @@ function getDefaultExtension(format) {
15379
15380
  }
15380
15381
 
15381
15382
  // src/commands/eval/progress-display.ts
15382
- import logUpdate from "log-update";
15383
+ import { stripVTControlCharacters } from "node:util";
15384
+ var ESC = "\x1B[";
15385
+ var CLEAR_LINE = `${ESC}K`;
15386
+ var MOVE_CURSOR_UP = `${ESC}1A`;
15387
+ var SYNC_START = `${ESC}?2026h`;
15388
+ var SYNC_END = `${ESC}?2026l`;
15383
15389
  var ProgressDisplay = class {
15384
15390
  workers = /* @__PURE__ */ new Map();
15385
15391
  maxWorkers;
15386
15392
  totalTests = 0;
15387
15393
  completedTests = 0;
15388
15394
  renderTimer;
15395
+ renderScheduled = false;
15389
15396
  isInteractive;
15390
15397
  logPaths = [];
15391
15398
  logPathSet = /* @__PURE__ */ new Set();
15392
15399
  hasPrintedLogHeader = false;
15400
+ windowHeight = 0;
15401
+ started = false;
15402
+ finished = false;
15393
15403
  constructor(maxWorkers) {
15394
15404
  this.maxWorkers = maxWorkers;
15395
- this.isInteractive = process.stderr.isTTY && !process.env.CI;
15405
+ this.isInteractive = process.stdout.isTTY && !process.env.CI;
15396
15406
  }
15397
15407
  isInteractiveMode() {
15398
15408
  return this.isInteractive;
15399
15409
  }
15400
15410
  start() {
15411
+ this.started = true;
15412
+ this.finished = false;
15401
15413
  if (this.isInteractive) {
15402
- console.log("");
15414
+ this.write("\n");
15415
+ this.renderTimer = setInterval(() => {
15416
+ this.scheduleRender();
15417
+ }, 1e3);
15418
+ this.renderTimer.unref?.();
15403
15419
  }
15404
15420
  }
15405
15421
  setTotalTests(count) {
@@ -15449,22 +15465,42 @@ var ProgressDisplay = class {
15449
15465
  });
15450
15466
  }
15451
15467
  scheduleRender() {
15452
- if (this.renderTimer) {
15468
+ if (this.renderScheduled || this.finished) {
15453
15469
  return;
15454
15470
  }
15455
- this.renderTimer = setTimeout(() => {
15456
- this.renderTimer = void 0;
15471
+ this.renderScheduled = true;
15472
+ setTimeout(() => {
15473
+ this.renderScheduled = false;
15457
15474
  this.render();
15458
15475
  }, 100);
15459
15476
  }
15477
+ write(content) {
15478
+ process.stdout.write(content);
15479
+ }
15480
+ clearWindow() {
15481
+ if (this.windowHeight === 0) {
15482
+ return;
15483
+ }
15484
+ this.write(`\r${CLEAR_LINE}`);
15485
+ for (let i6 = 1; i6 < this.windowHeight; i6++) {
15486
+ this.write(`${MOVE_CURSOR_UP}\r${CLEAR_LINE}`);
15487
+ }
15488
+ this.windowHeight = 0;
15489
+ }
15490
+ getRenderedRowCount(rows) {
15491
+ const columns = process.stdout.columns || 80;
15492
+ let count = 0;
15493
+ for (const row of rows) {
15494
+ const text = stripVTControlCharacters(row);
15495
+ count += Math.max(1, Math.ceil(text.length / columns));
15496
+ }
15497
+ return count;
15498
+ }
15460
15499
  render() {
15461
- if (!this.isInteractive) {
15500
+ if (!this.isInteractive || !this.started || this.finished) {
15462
15501
  return;
15463
15502
  }
15464
15503
  const lines = [];
15465
- const progressBar = this.buildProgressBar(this.completedTests, this.totalTests);
15466
- lines.push(`${progressBar} ${this.completedTests}/${this.totalTests} evals`);
15467
- lines.push("");
15468
15504
  const sortedWorkers = Array.from(this.workers.values()).sort((a, b) => a.workerId - b.workerId);
15469
15505
  for (const worker of sortedWorkers) {
15470
15506
  const line2 = this.formatWorkerLine(worker);
@@ -15477,22 +15513,26 @@ var ProgressDisplay = class {
15477
15513
  lines.push(`${index + 1}. ${path19}`);
15478
15514
  });
15479
15515
  }
15480
- logUpdate(lines.join("\n"));
15516
+ const rowCount = this.getRenderedRowCount(lines);
15517
+ this.clearWindow();
15518
+ if (lines.length > 0) {
15519
+ this.write(lines.join("\n"));
15520
+ }
15521
+ this.windowHeight = rowCount;
15481
15522
  }
15482
15523
  formatWorkerLine(worker) {
15483
15524
  const workerLabel = `${worker.workerId}.`.padEnd(4);
15484
15525
  const statusIcon = this.getStatusIcon(worker.status);
15485
- const elapsed = worker.startedAt ? this.formatElapsed(Date.now() - worker.startedAt) : "";
15486
- const timeLabel = elapsed ? ` (${elapsed})` : "";
15487
15526
  const targetLabel = worker.targetLabel ? ` | ${worker.targetLabel}` : "";
15488
- const maxLineLength = 90;
15489
- const reservedLength = workerLabel.length + statusIcon.length + timeLabel.length + targetLabel.length + 4;
15527
+ const columns = process.stdout.columns || 80;
15528
+ const maxLineLength = Math.max(40, columns - 4);
15529
+ const reservedLength = workerLabel.length + statusIcon.length + targetLabel.length + 4;
15490
15530
  const availableLabelLength = Math.max(15, maxLineLength - reservedLength);
15491
15531
  let testLabel = worker.evalId;
15492
15532
  if (testLabel.length > availableLabelLength) {
15493
15533
  testLabel = `${testLabel.substring(0, Math.max(0, availableLabelLength - 3))}...`;
15494
15534
  }
15495
- return `${workerLabel} ${statusIcon} ${testLabel}${timeLabel}${targetLabel}`;
15535
+ return `${workerLabel} ${statusIcon} ${testLabel}${targetLabel}`;
15496
15536
  }
15497
15537
  getStatusIcon(status) {
15498
15538
  switch (status) {
@@ -15508,39 +15548,26 @@ var ProgressDisplay = class {
15508
15548
  return " ";
15509
15549
  }
15510
15550
  }
15511
- formatElapsed(ms) {
15512
- const seconds = Math.floor(ms / 1e3);
15513
- if (seconds < 60) {
15514
- return `${seconds}s`;
15515
- }
15516
- const minutes = Math.floor(seconds / 60);
15517
- const remainingSeconds = seconds % 60;
15518
- return `${minutes}m ${remainingSeconds}s`;
15519
- }
15520
- buildProgressBar(current, total) {
15521
- if (total === 0) {
15522
- return "[ ]";
15523
- }
15524
- const width = 20;
15525
- const filled = Math.floor(current / total * width);
15526
- const empty = width - filled;
15527
- const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
15528
- const percentage = Math.floor(current / total * 100);
15529
- return `[${bar}] ${percentage}%`;
15530
- }
15531
15551
  finish() {
15532
15552
  if (this.renderTimer) {
15533
- clearTimeout(this.renderTimer);
15553
+ clearInterval(this.renderTimer);
15534
15554
  this.renderTimer = void 0;
15535
15555
  }
15536
- if (this.isInteractive) {
15537
- this.render();
15538
- logUpdate.done();
15556
+ this.finished = true;
15557
+ if (this.isInteractive && this.started) {
15558
+ this.clearWindow();
15559
+ const sortedWorkers = Array.from(this.workers.values()).sort(
15560
+ (a, b) => a.workerId - b.workerId
15561
+ );
15562
+ for (const worker of sortedWorkers) {
15563
+ this.write(this.formatWorkerLine(worker) + "\n");
15564
+ }
15565
+ this.write("\n");
15539
15566
  }
15540
15567
  }
15541
15568
  clear() {
15542
15569
  if (this.isInteractive) {
15543
- logUpdate.clear();
15570
+ this.clearWindow();
15544
15571
  }
15545
15572
  }
15546
15573
  };
@@ -17539,4 +17566,4 @@ export {
17539
17566
  createProgram,
17540
17567
  runCli
17541
17568
  };
17542
- //# sourceMappingURL=chunk-R2OCC2OH.js.map
17569
+ //# sourceMappingURL=chunk-J3LVKRRT.js.map