@axiom-lattice/gateway 3.0.0 → 3.0.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +20 -0
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/controllers/eval.ts +6 -2
- package/src/services/__tests__/eval-runner.test.ts +131 -0
- package/src/services/eval-runner.ts +44 -3
- package/src/services/local-a2a.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,7 @@ function findWorkspaceRoot(startDir) {
|
|
|
50
50
|
if (parent === current) return null;
|
|
51
51
|
current = parent;
|
|
52
52
|
}
|
|
53
|
+
return null;
|
|
53
54
|
}
|
|
54
55
|
function resolveLocalA2AWorkingDirectory(options) {
|
|
55
56
|
if (options.envWorkdir) return options.envWorkdir;
|
|
@@ -6208,11 +6209,12 @@ var EvalRunner = class {
|
|
|
6208
6209
|
constructor() {
|
|
6209
6210
|
this.runs = /* @__PURE__ */ new Map();
|
|
6210
6211
|
this.eventEmitter = new EventEmitter();
|
|
6212
|
+
this.processStartedAt = /* @__PURE__ */ new Date();
|
|
6211
6213
|
}
|
|
6212
6214
|
getEventEmitter() {
|
|
6213
6215
|
return this.eventEmitter;
|
|
6214
6216
|
}
|
|
6215
|
-
async startRun(tenantId, projectId) {
|
|
6217
|
+
async startRun(tenantId, projectId, suiteIds) {
|
|
6216
6218
|
const store = this.getEvalStore();
|
|
6217
6219
|
const project = await store.getProjectById(tenantId, projectId);
|
|
6218
6220
|
if (!project) throw new Error("Project not found");
|
|
@@ -6222,10 +6224,27 @@ var EvalRunner = class {
|
|
|
6222
6224
|
}
|
|
6223
6225
|
}
|
|
6224
6226
|
const existingRuns = await store.getRunsByTenant(tenantId, { projectId, status: "running" });
|
|
6225
|
-
|
|
6227
|
+
for (const run of existingRuns) {
|
|
6228
|
+
const orphaned = !this.runs.has(run.id) && run.createdAt < this.processStartedAt;
|
|
6229
|
+
if (orphaned) {
|
|
6230
|
+
await store.updateRunStatus(tenantId, run.id, {
|
|
6231
|
+
status: "failed",
|
|
6232
|
+
error: "Gateway restarted \u2014 run orphaned",
|
|
6233
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
6234
|
+
});
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
const stillRunning = await store.getRunsByTenant(tenantId, { projectId, status: "running" });
|
|
6238
|
+
if (stillRunning.length > 0) {
|
|
6226
6239
|
throw new Error("A run is already in progress for this project");
|
|
6227
6240
|
}
|
|
6228
|
-
|
|
6241
|
+
let suites = await store.getSuitesByProject(tenantId, projectId);
|
|
6242
|
+
if (suiteIds && suiteIds.length > 0) {
|
|
6243
|
+
suites = suites.filter((s) => suiteIds.includes(s.id));
|
|
6244
|
+
if (suites.length === 0) {
|
|
6245
|
+
throw new Error("No suites match the requested suiteIds filter");
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6229
6248
|
const evalSuites = [];
|
|
6230
6249
|
let totalCases = 0;
|
|
6231
6250
|
for (const suite of suites) {
|
|
@@ -6324,6 +6343,15 @@ var EvalRunner = class {
|
|
|
6324
6343
|
const runPromise = (async () => {
|
|
6325
6344
|
try {
|
|
6326
6345
|
const evalProject = new LatticeEvalProject(projectConfig, onCaseComplete);
|
|
6346
|
+
const calibration = await evalProject.calibrateJudge();
|
|
6347
|
+
if (!calibration.ok) {
|
|
6348
|
+
await store.updateRunStatus(tenantId, runId, {
|
|
6349
|
+
status: "failed",
|
|
6350
|
+
error: `Judge calibration failed: ${calibration.reason}`,
|
|
6351
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
6352
|
+
});
|
|
6353
|
+
throw new Error(`Judge calibration failed: ${calibration.reason}`);
|
|
6354
|
+
}
|
|
6327
6355
|
const { report } = await evalProject.runAllSuitesBatch(concurrency, abortController.signal);
|
|
6328
6356
|
if (!abortController.signal.aborted) {
|
|
6329
6357
|
const completedCount = stats.passed + stats.failed;
|
|
@@ -6711,11 +6739,12 @@ function registerEvalRoutes(app2) {
|
|
|
6711
6739
|
try {
|
|
6712
6740
|
const tenantId = getTenantId13(request);
|
|
6713
6741
|
const { pid } = request.params;
|
|
6714
|
-
const
|
|
6742
|
+
const body = request.body ?? {};
|
|
6743
|
+
const runId = await evalRunner.startRun(tenantId, pid, body?.suiteIds);
|
|
6715
6744
|
reply.status(202).send({ success: true, message: "Run started", data: { run_id: runId } });
|
|
6716
6745
|
} catch (err) {
|
|
6717
6746
|
const msg = err.message;
|
|
6718
|
-
const code = msg === "Project not found" ? 404 : msg.includes("already in progress") ? 409 : 500;
|
|
6747
|
+
const code = msg === "Project not found" ? 404 : msg.includes("already in progress") ? 409 : msg.includes("No suites match") ? 400 : 500;
|
|
6719
6748
|
reply.status(code).send({ success: false, message: msg });
|
|
6720
6749
|
}
|
|
6721
6750
|
});
|