@ls-stack/agent-eval 0.6.0 → 0.8.0

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.
@@ -25,8 +25,8 @@
25
25
  href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
26
26
  rel="stylesheet"
27
27
  />
28
- <script type="module" crossorigin src="/assets/index-J1yKYGfN.js"></script>
29
- <link rel="stylesheet" crossorigin href="/assets/index-CdxG9-O-.css">
28
+ <script type="module" crossorigin src="/assets/index-CvJmtK1T.js"></script>
29
+ <link rel="stylesheet" crossorigin href="/assets/index-ClE28i5w.css">
30
30
  </head>
31
31
  <body>
32
32
  <div id="root"></div>
package/dist/bin.mjs CHANGED
@@ -1,18 +1,50 @@
1
1
  #!/usr/bin/env node
2
- import { t as runCli } from "./cli-C-n-Fd4o.mjs";
2
+ import { t as runCli } from "./cli-DQK5W0je.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
  //#region src/bin.ts
5
5
  const moduleMocksFlag = "--experimental-test-module-mocks";
6
+ const inspectFlagPrefix = "--inspect";
7
+ const inspectBrkFlagPrefix = "--inspect-brk";
6
8
  function needsModuleMocksFlag() {
7
9
  return !process.execArgv.includes(moduleMocksFlag);
8
10
  }
9
- async function reexecWithModuleMocksFlag(argv) {
11
+ function parseDebugFlags(argv) {
12
+ const nextArgv = [];
13
+ let inspectArg;
14
+ for (const arg of argv) {
15
+ if (arg === inspectFlagPrefix || arg.startsWith(`${inspectFlagPrefix}=`)) {
16
+ inspectArg = arg;
17
+ continue;
18
+ }
19
+ if (arg === inspectBrkFlagPrefix || arg.startsWith(`${inspectBrkFlagPrefix}=`)) {
20
+ inspectArg = arg;
21
+ continue;
22
+ }
23
+ nextArgv.push(arg);
24
+ }
25
+ return {
26
+ argv: nextArgv,
27
+ inspectArg
28
+ };
29
+ }
30
+ function isInspectArg(arg) {
31
+ return arg === inspectFlagPrefix || arg.startsWith(`${inspectFlagPrefix}=`) || arg === inspectBrkFlagPrefix || arg.startsWith(`${inspectBrkFlagPrefix}=`);
32
+ }
33
+ function buildExecArgv(inspectArg) {
34
+ const nextExecArgv = [moduleMocksFlag, ...process.execArgv.filter((arg) => arg !== moduleMocksFlag && !isInspectArg(arg))];
35
+ if (inspectArg !== void 0) nextExecArgv.push(inspectArg);
36
+ else nextExecArgv.push(...process.execArgv.filter(isInspectArg));
37
+ return nextExecArgv;
38
+ }
39
+ function execArgvMatches(nextExecArgv) {
40
+ return process.execArgv.length === nextExecArgv.length && process.execArgv.every((arg, index) => arg === nextExecArgv[index]);
41
+ }
42
+ async function reexecWithNodeArgs(argv, execArgv) {
10
43
  const entrypoint = process.argv[1];
11
44
  if (!entrypoint) throw new Error("Unable to locate the Agent Evals CLI entrypoint.");
12
45
  await new Promise((resolvePromise, rejectPromise) => {
13
46
  const child = spawn(process.execPath, [
14
- moduleMocksFlag,
15
- ...process.execArgv,
47
+ ...execArgv,
16
48
  entrypoint,
17
49
  ...argv
18
50
  ], {
@@ -34,8 +66,9 @@ async function reexecWithModuleMocksFlag(argv) {
34
66
  });
35
67
  });
36
68
  }
37
- const argv = process.argv.slice(2);
38
- if (needsModuleMocksFlag()) await reexecWithModuleMocksFlag(argv);
69
+ const { argv, inspectArg } = parseDebugFlags(process.argv.slice(2));
70
+ const execArgv = buildExecArgv(inspectArg);
71
+ if (needsModuleMocksFlag() || !execArgvMatches(execArgv)) await reexecWithNodeArgs(argv, execArgv);
39
72
  else await runCli(argv);
40
73
  //#endregion
41
74
  export {};