@ls-stack/agent-eval 0.37.0 → 0.38.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.
package/dist/runChild.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { At as evalStatsConfigSchema, C as parseEvalDiscovery, En as columnDefSchema, J as runManifestSchema, M as createRunRequestSchema, Qn as configureEvalRunLogs, Rt as manualInputDescriptorSchema, T as loadConfig, Y as runSummarySchema, bt as buildEvalKey, en as evalChartsConfigSchema, k as createFsCacheStore, p as persistRunState, r as getTargetEvals$1, t as executeRun } from "./runOrchestration-C4o5TcIu.mjs";
1
+ import { At as evalStatsConfigSchema, C as parseEvalDiscovery, En as columnDefSchema, J as runManifestSchema, M as createRunRequestSchema, Qn as configureEvalRunLogs, Rt as manualInputDescriptorSchema, T as loadConfig, Y as runSummarySchema, bt as buildEvalKey, en as evalChartsConfigSchema, k as createFsCacheStore, p as persistRunState, r as getTargetEvals$1, t as executeRun } from "./runOrchestration-BhUFWvq9.mjs";
2
2
  import { createHash } from "node:crypto";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { relative } from "node:path";
@@ -29,10 +29,20 @@ const runChildContextSchema = z.object({
29
29
  evals: z.array(evalMetaSchema).optional()
30
30
  });
31
31
  let activeContext;
32
+ let fatalErrorReported = false;
33
+ let disconnectExpected = false;
32
34
  function sendMessage(message) {
33
35
  if (process.send === void 0) return;
34
36
  process.send(message);
35
37
  }
38
+ function installFatalRunChildErrorHandlers() {
39
+ process.once("uncaughtException", (error) => {
40
+ reportFatalRunChildErrorAndExit(error);
41
+ });
42
+ process.once("unhandledRejection", (reason) => {
43
+ reportFatalRunChildErrorAndExit(toUnhandledRejectionError(reason));
44
+ });
45
+ }
36
46
  function getSourceFingerprint(source) {
37
47
  return createHash("sha256").update(source).digest("hex");
38
48
  }
@@ -92,6 +102,7 @@ async function readContext(contextPath) {
92
102
  }
93
103
  async function main() {
94
104
  process.on("disconnect", () => {
105
+ if (disconnectExpected) return;
95
106
  process.exit(1);
96
107
  });
97
108
  const context = await readContext(process.argv[2]);
@@ -157,6 +168,8 @@ async function main() {
157
168
  });
158
169
  }
159
170
  async function handleFatalRunChildError(error) {
171
+ if (fatalErrorReported) return;
172
+ fatalErrorReported = true;
160
173
  const message = formatUnknownErrorDetails(error);
161
174
  process.exitCode = 1;
162
175
  console.error(message);
@@ -193,9 +206,25 @@ function formatUnknownErrorDetails(error) {
193
206
  if (typeof error === "string") return error;
194
207
  return String(error);
195
208
  }
209
+ function toUnhandledRejectionError(reason) {
210
+ if (reason instanceof Error) return reason;
211
+ return /* @__PURE__ */ new Error(`Unhandled rejection: ${formatUnknownErrorDetails(reason)}`);
212
+ }
213
+ async function reportFatalRunChildErrorAndExit(error) {
214
+ try {
215
+ await handleFatalRunChildError(error);
216
+ } catch (reportError) {
217
+ console.error("Failed to report fatal run child error:");
218
+ console.error(formatUnknownErrorDetails(reportError));
219
+ } finally {
220
+ process.exit(1);
221
+ }
222
+ }
223
+ installFatalRunChildErrorHandlers();
196
224
  await main().catch(async (error) => {
197
225
  await handleFatalRunChildError(error);
198
226
  });
227
+ disconnectExpected = true;
199
228
  process.disconnect();
200
229
  //#endregion
201
230
  export {};