agentv 4.38.0 → 4.38.1-next.1

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.
@@ -6,12 +6,9 @@ import {
6
6
  clearRemoteRunTags,
7
7
  deleteRunTags,
8
8
  detectFileType,
9
- detectInstallScope,
10
- detectPackageManager,
11
9
  discoverEvalFiles,
12
10
  enforceRequiredVersion,
13
11
  ensureRemoteRunAvailable,
14
- fetchLatestVersion,
15
12
  findRepoRoot,
16
13
  findRunById,
17
14
  formatCost,
@@ -19,7 +16,6 @@ import {
19
16
  formatNumber,
20
17
  formatScore,
21
18
  formatSize,
22
- getDistTagForVersion,
23
19
  getRemoteResultsStatus,
24
20
  getTraceSpans,
25
21
  getTraceSummary,
@@ -35,7 +31,6 @@ import {
35
31
  padLeft,
36
32
  padRight,
37
33
  parseResultManifest,
38
- performSelfUpdate,
39
34
  readRemoteRunTagState,
40
35
  readRunTags,
41
36
  resolveEvalPaths,
@@ -53,7 +48,7 @@ import {
53
48
  validateTargetsFile,
54
49
  validateWorkspacePaths,
55
50
  writeRunTags
56
- } from "./chunk-EKMMIULD.js";
51
+ } from "./chunk-Z4BVJJXA.js";
57
52
  import {
58
53
  RESULT_INDEX_FILENAME,
59
54
  aggregateRunDir,
@@ -4605,7 +4600,7 @@ var evalRunCommand = command({
4605
4600
  },
4606
4601
  handler: async (args) => {
4607
4602
  if (args.evalPaths.length === 0 && process.stdin.isTTY) {
4608
- const { launchInteractiveWizard } = await import("./interactive-QFAAM4SI.js");
4603
+ const { launchInteractiveWizard } = await import("./interactive-A7JNS2MT.js");
4609
4604
  await launchInteractiveWizard();
4610
4605
  return;
4611
4606
  }
@@ -14021,6 +14016,150 @@ var runsCommand = subcommands({
14021
14016
  }
14022
14017
  });
14023
14018
 
14019
+ // src/self-update.ts
14020
+ import { spawn as spawn2 } from "node:child_process";
14021
+ import { existsSync as existsSync17 } from "node:fs";
14022
+ import { get } from "node:https";
14023
+ import { basename, dirname as dirname3, join as join5, win32 } from "node:path";
14024
+ var NPM_REGISTRY_BASE = "https://registry.npmjs.org/agentv/";
14025
+ function getDistTagForVersion(version) {
14026
+ return version.includes("-") ? "next" : "latest";
14027
+ }
14028
+ function detectPackageManagerFromPath(scriptPath) {
14029
+ if (scriptPath.includes(".bun")) {
14030
+ return "bun";
14031
+ }
14032
+ return "npm";
14033
+ }
14034
+ function detectPackageManager() {
14035
+ return detectPackageManagerFromPath(process.argv[1] ?? "");
14036
+ }
14037
+ function detectInstallScopeFromPath(scriptPath, cwd = process.cwd()) {
14038
+ const normalizedScriptPath = scriptPath.replace(/\\/g, "/");
14039
+ const normalizedCwd = cwd.replace(/\\/g, "/");
14040
+ if (!normalizedScriptPath.includes("/node_modules/")) {
14041
+ return "global";
14042
+ }
14043
+ if (normalizedScriptPath.includes("/.npm/_npx/") || normalizedScriptPath.includes("/npm-cache/_npx/")) {
14044
+ return "local";
14045
+ }
14046
+ const packageRoot = normalizedScriptPath.split("/node_modules/")[0];
14047
+ if (!packageRoot) {
14048
+ return "global";
14049
+ }
14050
+ const scriptPathComparable = process.platform === "win32" ? normalizedScriptPath.toLowerCase() : normalizedScriptPath;
14051
+ const cwdComparable = process.platform === "win32" ? normalizedCwd.toLowerCase() : normalizedCwd;
14052
+ const packageRootComparable = process.platform === "win32" ? packageRoot.toLowerCase() : packageRoot;
14053
+ const projectOwnsPackage = cwdComparable === packageRootComparable || cwdComparable.startsWith(`${packageRootComparable}/`);
14054
+ return projectOwnsPackage ? "local" : "global";
14055
+ }
14056
+ function detectInstallScope() {
14057
+ return detectInstallScopeFromPath(process.argv[1] ?? "");
14058
+ }
14059
+ function runCommand(cmd, args) {
14060
+ return new Promise((resolve3, reject) => {
14061
+ const child = spawn2(cmd, args, { stdio: ["inherit", "pipe", "inherit"] });
14062
+ let stdout = "";
14063
+ child.stdout?.on("data", (data) => {
14064
+ process.stdout.write(data);
14065
+ stdout += data.toString();
14066
+ });
14067
+ child.on("error", reject);
14068
+ child.on("close", (code) => resolve3({ exitCode: code ?? 1, stdout }));
14069
+ });
14070
+ }
14071
+ function fetchLatestVersion(distTag = "latest") {
14072
+ return new Promise((resolve3) => {
14073
+ const req = get(`${NPM_REGISTRY_BASE}${distTag}`, { timeout: 5e3 }, (res) => {
14074
+ if (res.statusCode !== 200) {
14075
+ res.resume();
14076
+ resolve3(null);
14077
+ return;
14078
+ }
14079
+ let body = "";
14080
+ res.on("data", (chunk) => {
14081
+ body += chunk.toString();
14082
+ });
14083
+ res.on("end", () => {
14084
+ try {
14085
+ const version = JSON.parse(body).version;
14086
+ resolve3(typeof version === "string" ? version : null);
14087
+ } catch {
14088
+ resolve3(null);
14089
+ }
14090
+ });
14091
+ });
14092
+ req.on("error", () => resolve3(null));
14093
+ req.on("timeout", () => {
14094
+ req.destroy();
14095
+ resolve3(null);
14096
+ });
14097
+ });
14098
+ }
14099
+ function getInstallArgs(pm, versionSpec, scope) {
14100
+ const pkg = `agentv@${versionSpec}`;
14101
+ const baseCmd = pm === "npm" ? "install" : "add";
14102
+ return scope === "global" ? [baseCmd, "-g", pkg] : [baseCmd, pkg];
14103
+ }
14104
+ function findBundledNpmCli(execPath, platform, exists) {
14105
+ const pathApi = platform === "win32" ? win32 : { dirname: dirname3, join: join5 };
14106
+ const execDir = pathApi.dirname(execPath);
14107
+ const candidates = platform === "win32" ? [pathApi.join(execDir, "node_modules", "npm", "bin", "npm-cli.js")] : [
14108
+ pathApi.join(execDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
14109
+ pathApi.join(execDir, "node_modules", "npm", "bin", "npm-cli.js")
14110
+ ];
14111
+ return candidates.find((candidate) => exists(candidate));
14112
+ }
14113
+ function resolvePackageManagerCommand(pm, args, options) {
14114
+ const execPath = options?.execPath ?? process.execPath;
14115
+ const platform = options?.platform ?? process.platform;
14116
+ const exists = options?.exists ?? existsSync17;
14117
+ const pathApi = platform === "win32" ? win32 : { basename };
14118
+ if (pm === "bun") {
14119
+ const runtimeName = pathApi.basename(execPath).toLowerCase();
14120
+ if ((runtimeName === "bun" || runtimeName === "bun.exe") && exists(execPath)) {
14121
+ return { cmd: execPath, args };
14122
+ }
14123
+ return { cmd: "bun", args };
14124
+ }
14125
+ const npmCliPath = findBundledNpmCli(execPath, platform, exists);
14126
+ if (npmCliPath) {
14127
+ return { cmd: execPath, args: [npmCliPath, ...args] };
14128
+ }
14129
+ return { cmd: "npm", args };
14130
+ }
14131
+ async function performSelfUpdate(options) {
14132
+ const pm = options?.pm ?? detectPackageManager();
14133
+ const currentVersion = options?.currentVersion ?? "unknown";
14134
+ const versionSpec = options?.versionRange ?? getDistTagForVersion(currentVersion === "unknown" ? "" : currentVersion);
14135
+ const scope = options?.scope ?? detectInstallScope();
14136
+ const args = getInstallArgs(pm, versionSpec, scope);
14137
+ const command2 = resolvePackageManagerCommand(pm, args);
14138
+ try {
14139
+ const result = await runCommand(command2.cmd, command2.args);
14140
+ if (result.exitCode !== 0) {
14141
+ return { success: false, currentVersion, scope };
14142
+ }
14143
+ let newVersion;
14144
+ try {
14145
+ const versionResult = await runCommand("agentv", ["--version"]);
14146
+ newVersion = versionResult.stdout.trim();
14147
+ } catch {
14148
+ }
14149
+ return { success: true, currentVersion, newVersion, scope };
14150
+ } catch (error) {
14151
+ if (error instanceof Error) {
14152
+ if (error.message.includes("ENOENT") || error.message.includes("not found")) {
14153
+ const alternative = pm === "npm" ? "bun" : "npm";
14154
+ console.error(`Error: ${pm} not found. Try using --${alternative} flag.`);
14155
+ } else {
14156
+ console.error(`Error: ${error.message}`);
14157
+ }
14158
+ }
14159
+ return { success: false, currentVersion, scope };
14160
+ }
14161
+ }
14162
+
14024
14163
  // src/commands/self/index.ts
14025
14164
  var updateCommand = command({
14026
14165
  name: "update",
@@ -14080,14 +14219,14 @@ var selfCommand = subcommands({
14080
14219
  });
14081
14220
 
14082
14221
  // src/commands/skills/index.ts
14083
- import { existsSync as existsSync17, readFileSync as readFileSync13, readdirSync as readdirSync5 } from "node:fs";
14222
+ import { existsSync as existsSync18, readFileSync as readFileSync13, readdirSync as readdirSync5 } from "node:fs";
14084
14223
  import path25 from "node:path";
14085
14224
  import { fileURLToPath as fileURLToPath4 } from "node:url";
14086
14225
  function isValidSkillsDir(dir) {
14087
- if (!existsSync17(dir)) return false;
14226
+ if (!existsSync18(dir)) return false;
14088
14227
  try {
14089
14228
  return readdirSync5(dir, { withFileTypes: true }).some(
14090
- (e) => e.isDirectory() && existsSync17(path25.join(dir, e.name, "SKILL.md"))
14229
+ (e) => e.isDirectory() && existsSync18(path25.join(dir, e.name, "SKILL.md"))
14091
14230
  );
14092
14231
  } catch {
14093
14232
  return false;
@@ -14118,17 +14257,17 @@ function requireSkillsDir() {
14118
14257
  return dir;
14119
14258
  }
14120
14259
  function listSkillNames(skillsDir) {
14121
- if (!existsSync17(skillsDir)) return [];
14260
+ if (!existsSync18(skillsDir)) return [];
14122
14261
  return readdirSync5(skillsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
14123
14262
  }
14124
14263
  function readSkillFile(skillDir, relPath) {
14125
14264
  const full = path25.join(skillDir, relPath);
14126
- if (!existsSync17(full)) return null;
14265
+ if (!existsSync18(full)) return null;
14127
14266
  return readFileSync13(full, "utf-8");
14128
14267
  }
14129
14268
  function collectDir(dir, prefix = "") {
14130
14269
  const result = {};
14131
- if (!existsSync17(dir)) return result;
14270
+ if (!existsSync18(dir)) return result;
14132
14271
  for (const entry of readdirSync5(dir, { withFileTypes: true })) {
14133
14272
  const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
14134
14273
  if (entry.isDirectory()) {
@@ -14140,12 +14279,12 @@ function collectDir(dir, prefix = "") {
14140
14279
  return result;
14141
14280
  }
14142
14281
  function listSkillSubdirs(skillDir) {
14143
- if (!existsSync17(skillDir)) return [];
14282
+ if (!existsSync18(skillDir)) return [];
14144
14283
  return readdirSync5(skillDir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
14145
14284
  }
14146
14285
  function readSkill(skillsDir, name, full) {
14147
14286
  const skillDir = path25.join(skillsDir, name);
14148
- if (!existsSync17(skillDir)) return null;
14287
+ if (!existsSync18(skillDir)) return null;
14149
14288
  const content = readSkillFile(skillDir, "SKILL.md");
14150
14289
  if (content === null) return null;
14151
14290
  if (!full) return { name, content };
@@ -14162,14 +14301,14 @@ function findRefFile(skillDir, refName) {
14162
14301
  for (const sub of listSkillSubdirs(skillDir)) {
14163
14302
  for (const candidate of candidates) {
14164
14303
  const filePath = path25.join(skillDir, sub, candidate);
14165
- if (existsSync17(filePath)) {
14304
+ if (existsSync18(filePath)) {
14166
14305
  return { relPath: `${sub}/${candidate}`, content: readFileSync13(filePath, "utf-8") };
14167
14306
  }
14168
14307
  }
14169
14308
  }
14170
14309
  for (const candidate of candidates) {
14171
14310
  const filePath = path25.join(skillDir, candidate);
14172
- if (existsSync17(filePath)) {
14311
+ if (existsSync18(filePath)) {
14173
14312
  return { relPath: candidate, content: readFileSync13(filePath, "utf-8") };
14174
14313
  }
14175
14314
  }
@@ -14263,7 +14402,7 @@ var skillsGetCommand = command({
14263
14402
  process.exit(1);
14264
14403
  }
14265
14404
  const skillDir = path25.join(skillsDir, name);
14266
- if (!existsSync17(skillDir)) {
14405
+ if (!existsSync18(skillDir)) {
14267
14406
  const msg = `skill '${name}' not found`;
14268
14407
  if (json) {
14269
14408
  process.stdout.write(`${JSON.stringify({ success: false, error: msg })}
@@ -14352,7 +14491,7 @@ var skillsPathCommand = command({
14352
14491
  const skillsDir = requireSkillsDir();
14353
14492
  if (name) {
14354
14493
  const skillDir = path25.join(skillsDir, name);
14355
- if (!existsSync17(skillDir)) {
14494
+ if (!existsSync18(skillDir)) {
14356
14495
  console.error(`Error: skill '${name}' not found`);
14357
14496
  process.exit(1);
14358
14497
  }
@@ -15078,7 +15217,7 @@ var validateCommand = command({
15078
15217
  });
15079
15218
 
15080
15219
  // src/commands/workspace/clean.ts
15081
- import { existsSync as existsSync18 } from "node:fs";
15220
+ import { existsSync as existsSync19 } from "node:fs";
15082
15221
  import { readFile as readFile8, readdir as readdir5, rm } from "node:fs/promises";
15083
15222
  import path29 from "node:path";
15084
15223
  async function confirm2(message) {
@@ -15107,7 +15246,7 @@ var cleanCommand = command({
15107
15246
  },
15108
15247
  handler: async ({ repo, force }) => {
15109
15248
  const poolRoot = getWorkspacePoolRoot();
15110
- if (!existsSync18(poolRoot)) {
15249
+ if (!existsSync19(poolRoot)) {
15111
15250
  console.log("No workspace pool entries found.");
15112
15251
  return;
15113
15252
  }
@@ -15207,7 +15346,7 @@ var depsCommand = command({
15207
15346
  });
15208
15347
 
15209
15348
  // src/commands/workspace/list.ts
15210
- import { existsSync as existsSync19 } from "node:fs";
15349
+ import { existsSync as existsSync20 } from "node:fs";
15211
15350
  import { readFile as readFile9, readdir as readdir6, stat as stat2 } from "node:fs/promises";
15212
15351
  import path31 from "node:path";
15213
15352
  async function getDirectorySize(dirPath) {
@@ -15239,7 +15378,7 @@ var listCommand = command({
15239
15378
  args: {},
15240
15379
  handler: async () => {
15241
15380
  const poolRoot = getWorkspacePoolRoot();
15242
- if (!existsSync19(poolRoot)) {
15381
+ if (!existsSync20(poolRoot)) {
15243
15382
  console.log("No workspace pool entries found.");
15244
15383
  return;
15245
15384
  }
@@ -15294,15 +15433,15 @@ var workspaceCommand = subcommands({
15294
15433
  });
15295
15434
 
15296
15435
  // src/update-check.ts
15297
- import { spawn as spawn2 } from "node:child_process";
15436
+ import { spawn as spawn3 } from "node:child_process";
15298
15437
  import { readFile as readFile10 } from "node:fs/promises";
15299
- import { join as join5 } from "node:path";
15438
+ import { join as join6 } from "node:path";
15300
15439
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
15301
15440
  var CONFIG_DIR = getAgentvConfigDir();
15302
15441
  var CACHE_FILE = "version-check.json";
15303
- var NPM_REGISTRY_BASE = "https://registry.npmjs.org/agentv/";
15442
+ var NPM_REGISTRY_BASE2 = "https://registry.npmjs.org/agentv/";
15304
15443
  async function getCachedUpdateInfo(path33) {
15305
- const filePath = path33 ?? join5(CONFIG_DIR, CACHE_FILE);
15444
+ const filePath = path33 ?? join6(CONFIG_DIR, CACHE_FILE);
15306
15445
  try {
15307
15446
  const raw = await readFile10(filePath, "utf-8");
15308
15447
  const data = JSON.parse(raw);
@@ -15336,8 +15475,8 @@ function buildNotice(currentVersion, latestVersion) {
15336
15475
  }
15337
15476
  function backgroundUpdateCheck(distTag = "latest") {
15338
15477
  const dir = CONFIG_DIR;
15339
- const filePath = join5(dir, CACHE_FILE);
15340
- const registryUrl = `${NPM_REGISTRY_BASE}${distTag}`;
15478
+ const filePath = join6(dir, CACHE_FILE);
15479
+ const registryUrl = `${NPM_REGISTRY_BASE2}${distTag}`;
15341
15480
  const script = `
15342
15481
  const https = require('https');
15343
15482
  const fs = require('fs');
@@ -15360,7 +15499,7 @@ function backgroundUpdateCheck(distTag = "latest") {
15360
15499
  }).on('error', () => process.exit()).on('timeout', function() { this.destroy(); process.exit(); });
15361
15500
  `;
15362
15501
  try {
15363
- const child = spawn2(process.execPath, ["-e", script], {
15502
+ const child = spawn3(process.execPath, ["-e", script], {
15364
15503
  detached: true,
15365
15504
  stdio: "ignore",
15366
15505
  windowsHide: true
@@ -15493,4 +15632,4 @@ export {
15493
15632
  preprocessArgv,
15494
15633
  runCli
15495
15634
  };
15496
- //# sourceMappingURL=chunk-3G4BK6Z5.js.map
15635
+ //# sourceMappingURL=chunk-SMZQ7RPW.js.map