@axiom-lattice/gateway 3.0.4 → 3.0.6

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/index.mjs CHANGED
@@ -6261,6 +6261,7 @@ var EvalRunner = class {
6261
6261
  input: { message: c.inputMessage, files: c.inputFiles },
6262
6262
  steps: c.steps,
6263
6263
  output: { type: "message_content" },
6264
+ interruptPolicy: c.interruptPolicy,
6264
6265
  eval: {
6265
6266
  content_assertion: c.contentAssertion,
6266
6267
  eval_rubrics: c.rubrics?.map((r) => ({
@@ -6317,13 +6318,14 @@ var EvalRunner = class {
6317
6318
  concurrency
6318
6319
  };
6319
6320
  const abortController = new AbortController();
6320
- const stats = { passed: 0, failed: 0, totalScore: 0 };
6321
+ const stats = { passed: 0, failed: 0, interrupted: 0, totalScore: 0 };
6321
6322
  const onCaseComplete = async (result, suiteName) => {
6322
6323
  const passed = result.result?.pass ?? false;
6323
6324
  const score = result.result?.final_score ?? 0;
6324
6325
  if (passed) stats.passed++;
6325
6326
  else stats.failed++;
6326
6327
  stats.totalScore += score;
6328
+ if (result.interrupted) stats.interrupted++;
6327
6329
  const completedCount = stats.passed + stats.failed;
6328
6330
  await store.createRunResult(tenantId, runId, uuidv43(), {
6329
6331
  suiteName,
@@ -6339,18 +6341,20 @@ var EvalRunner = class {
6339
6341
  durationMs: result.duration_ms,
6340
6342
  messages: result.messages,
6341
6343
  logs: mapLogs(result.logs),
6342
- error: result.error
6344
+ error: result.error,
6345
+ interrupted: result.interrupted
6343
6346
  });
6344
6347
  const avgScore = completedCount > 0 ? stats.totalScore / completedCount : 0;
6345
6348
  await store.updateRunStatus(tenantId, runId, {
6346
6349
  passedCases: stats.passed,
6347
6350
  failedCases: stats.failed,
6351
+ interruptedCases: stats.interrupted,
6348
6352
  avgScore
6349
6353
  });
6350
6354
  this.eventEmitter.emit(`run:${runId}`, {
6351
6355
  type: "progress",
6352
6356
  runId,
6353
- data: { suiteName, caseId: result.caseId, pass: passed, score, completed: completedCount, total: totalCases }
6357
+ data: { suiteName, caseId: result.caseId, pass: passed, score, interrupted: result.interrupted ?? false, completed: completedCount, total: totalCases }
6354
6358
  });
6355
6359
  };
6356
6360
  const runPromise = (async () => {
@@ -6376,6 +6380,7 @@ var EvalRunner = class {
6376
6380
  completedAt: /* @__PURE__ */ new Date(),
6377
6381
  passedCases: stats.passed,
6378
6382
  failedCases: stats.failed,
6383
+ interruptedCases: stats.interrupted,
6379
6384
  avgScore: completedCount > 0 ? stats.totalScore / completedCount : 0
6380
6385
  });
6381
6386
  this.eventEmitter.emit(`run:${runId}`, {
@@ -6449,6 +6454,13 @@ async function createProject(request, reply) {
6449
6454
  const store = getEvalStore();
6450
6455
  const id = uuidv44();
6451
6456
  const data = request.body;
6457
+ const existing = await store.getProjectsByTenant(tenantId);
6458
+ if (existing.some((p) => p.name === data.name)) {
6459
+ return reply.status(409).send({
6460
+ success: false,
6461
+ message: `Eval project with name "${data.name}" already exists`
6462
+ });
6463
+ }
6452
6464
  const serverCfg = data.targetServerConfig || {};
6453
6465
  const judgeCfg = data.judgeModelConfig || {};
6454
6466
  const modelKey = judgeCfg.modelKey || "";
@@ -6480,6 +6492,14 @@ async function createProject(request, reply) {
6480
6492
  });
6481
6493
  } catch (err) {
6482
6494
  const message = err instanceof Error ? err.message : "Failed to create project";
6495
+ const code = err.code;
6496
+ const isUniqueViolation = code === "23505" || typeof message === "string" && message.includes("UNIQUE constraint failed");
6497
+ if (isUniqueViolation) {
6498
+ return reply.status(409).send({
6499
+ success: false,
6500
+ message: `Eval project with name "${request.body.name}" already exists`
6501
+ });
6502
+ }
6483
6503
  return reply.status(500).send({ success: false, message });
6484
6504
  }
6485
6505
  }
@@ -6677,7 +6697,8 @@ async function createCase(request, reply) {
6677
6697
  steps: data.steps ?? [],
6678
6698
  outputType: data.outputType ?? "message_content",
6679
6699
  contentAssertion: data.contentAssertion ?? "",
6680
- rubrics: data.rubrics
6700
+ rubrics: data.rubrics,
6701
+ interruptPolicy: data.interruptPolicy
6681
6702
  });
6682
6703
  return reply.status(201).send({
6683
6704
  success: true,