@axlsdk/studio 0.13.7 → 0.14.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/README.md +54 -1
- package/dist/{chunk-YWRYXT7U.js → chunk-HUKUQDYL.js} +232 -90
- package/dist/chunk-HUKUQDYL.js.map +1 -0
- package/dist/{chunk-6VDX5CRP.js → chunk-JGQ3MSIG.js} +5 -2
- package/dist/chunk-JGQ3MSIG.js.map +1 -0
- package/dist/cli.cjs +246 -96
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/index-7aDhMztu.css +1 -0
- package/dist/client/assets/index-Bzr3vDPz.js +255 -0
- package/dist/client/index.html +2 -2
- package/dist/middleware.cjs +242 -93
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.js +9 -2
- package/dist/middleware.js.map +1 -1
- package/dist/server/index.cjs +232 -90
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +1 -1
- package/package.json +5 -4
- package/dist/chunk-6VDX5CRP.js.map +0 -1
- package/dist/chunk-YWRYXT7U.js.map +0 -1
- package/dist/client/assets/index-C_uwupnn.js +0 -221
- package/dist/client/assets/index-DVcH6P9w.css +0 -1
|
@@ -298,27 +298,30 @@ var CostAggregator = class {
|
|
|
298
298
|
|
|
299
299
|
// src/server/routes/health.ts
|
|
300
300
|
import { Hono } from "hono";
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
301
|
+
function createHealthRoutes(readOnly) {
|
|
302
|
+
const app6 = new Hono();
|
|
303
|
+
app6.get("/health", (c) => {
|
|
304
|
+
const runtime = c.get("runtime");
|
|
305
|
+
return c.json({
|
|
306
|
+
ok: true,
|
|
307
|
+
data: {
|
|
308
|
+
status: "healthy",
|
|
309
|
+
readOnly,
|
|
310
|
+
workflows: runtime.getWorkflowNames().length,
|
|
311
|
+
agents: runtime.getAgents().length,
|
|
312
|
+
tools: runtime.getTools().length
|
|
313
|
+
}
|
|
314
|
+
});
|
|
312
315
|
});
|
|
313
|
-
|
|
314
|
-
|
|
316
|
+
return app6;
|
|
317
|
+
}
|
|
315
318
|
|
|
316
319
|
// src/server/routes/workflows.ts
|
|
317
320
|
import { Hono as Hono2 } from "hono";
|
|
318
321
|
import { zodToJsonSchema } from "@axlsdk/axl";
|
|
319
322
|
function createWorkflowRoutes(connMgr) {
|
|
320
|
-
const
|
|
321
|
-
|
|
323
|
+
const app6 = new Hono2();
|
|
324
|
+
app6.get("/workflows", (c) => {
|
|
322
325
|
const runtime = c.get("runtime");
|
|
323
326
|
const workflows = runtime.getWorkflows().map((w) => ({
|
|
324
327
|
name: w.name,
|
|
@@ -327,7 +330,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
327
330
|
}));
|
|
328
331
|
return c.json({ ok: true, data: workflows });
|
|
329
332
|
});
|
|
330
|
-
|
|
333
|
+
app6.get("/workflows/:name", (c) => {
|
|
331
334
|
const runtime = c.get("runtime");
|
|
332
335
|
const name = c.req.param("name");
|
|
333
336
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -346,7 +349,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
346
349
|
}
|
|
347
350
|
});
|
|
348
351
|
});
|
|
349
|
-
|
|
352
|
+
app6.post("/workflows/:name/execute", async (c) => {
|
|
350
353
|
const runtime = c.get("runtime");
|
|
351
354
|
const name = c.req.param("name");
|
|
352
355
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -370,18 +373,18 @@ function createWorkflowRoutes(connMgr) {
|
|
|
370
373
|
const result = await runtime.execute(name, body.input ?? {}, { metadata: body.metadata });
|
|
371
374
|
return c.json({ ok: true, data: { result } });
|
|
372
375
|
});
|
|
373
|
-
return
|
|
376
|
+
return app6;
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
// src/server/routes/executions.ts
|
|
377
380
|
import { Hono as Hono3 } from "hono";
|
|
378
|
-
var
|
|
379
|
-
|
|
381
|
+
var app = new Hono3();
|
|
382
|
+
app.get("/executions", async (c) => {
|
|
380
383
|
const runtime = c.get("runtime");
|
|
381
384
|
const executions = await runtime.getExecutions();
|
|
382
385
|
return c.json({ ok: true, data: executions });
|
|
383
386
|
});
|
|
384
|
-
|
|
387
|
+
app.get("/executions/:id", async (c) => {
|
|
385
388
|
const runtime = c.get("runtime");
|
|
386
389
|
const id = c.req.param("id");
|
|
387
390
|
const execution = await runtime.getExecution(id);
|
|
@@ -393,19 +396,19 @@ app2.get("/executions/:id", async (c) => {
|
|
|
393
396
|
}
|
|
394
397
|
return c.json({ ok: true, data: execution });
|
|
395
398
|
});
|
|
396
|
-
|
|
399
|
+
app.post("/executions/:id/abort", (c) => {
|
|
397
400
|
const runtime = c.get("runtime");
|
|
398
401
|
const id = c.req.param("id");
|
|
399
402
|
runtime.abort(id);
|
|
400
403
|
return c.json({ ok: true, data: { aborted: true } });
|
|
401
404
|
});
|
|
402
|
-
var executions_default =
|
|
405
|
+
var executions_default = app;
|
|
403
406
|
|
|
404
407
|
// src/server/routes/sessions.ts
|
|
405
408
|
import { Hono as Hono4 } from "hono";
|
|
406
409
|
function createSessionRoutes(connMgr) {
|
|
407
|
-
const
|
|
408
|
-
|
|
410
|
+
const app6 = new Hono4();
|
|
411
|
+
app6.get("/sessions", async (c) => {
|
|
409
412
|
const runtime = c.get("runtime");
|
|
410
413
|
const store = runtime.getStateStore();
|
|
411
414
|
if (!store.listSessions) {
|
|
@@ -419,7 +422,7 @@ function createSessionRoutes(connMgr) {
|
|
|
419
422
|
}
|
|
420
423
|
return c.json({ ok: true, data: sessions });
|
|
421
424
|
});
|
|
422
|
-
|
|
425
|
+
app6.get("/sessions/:id", async (c) => {
|
|
423
426
|
const runtime = c.get("runtime");
|
|
424
427
|
const store = runtime.getStateStore();
|
|
425
428
|
const id = c.req.param("id");
|
|
@@ -427,7 +430,7 @@ function createSessionRoutes(connMgr) {
|
|
|
427
430
|
const handoffHistory = await store.getSessionMeta(id, "handoffHistory");
|
|
428
431
|
return c.json({ ok: true, data: { id, history, handoffHistory: handoffHistory ?? [] } });
|
|
429
432
|
});
|
|
430
|
-
|
|
433
|
+
app6.post("/sessions/:id/send", async (c) => {
|
|
431
434
|
const runtime = c.get("runtime");
|
|
432
435
|
const id = c.req.param("id");
|
|
433
436
|
const body = await c.req.json();
|
|
@@ -435,7 +438,7 @@ function createSessionRoutes(connMgr) {
|
|
|
435
438
|
const result = await session.send(body.workflow, body.message);
|
|
436
439
|
return c.json({ ok: true, data: { result } });
|
|
437
440
|
});
|
|
438
|
-
|
|
441
|
+
app6.post("/sessions/:id/stream", async (c) => {
|
|
439
442
|
const runtime = c.get("runtime");
|
|
440
443
|
const id = c.req.param("id");
|
|
441
444
|
const body = await c.req.json();
|
|
@@ -449,21 +452,21 @@ function createSessionRoutes(connMgr) {
|
|
|
449
452
|
})();
|
|
450
453
|
return c.json({ ok: true, data: { executionId, streaming: true } });
|
|
451
454
|
});
|
|
452
|
-
|
|
455
|
+
app6.delete("/sessions/:id", async (c) => {
|
|
453
456
|
const runtime = c.get("runtime");
|
|
454
457
|
const store = runtime.getStateStore();
|
|
455
458
|
const id = c.req.param("id");
|
|
456
459
|
await store.deleteSession(id);
|
|
457
460
|
return c.json({ ok: true, data: { deleted: true } });
|
|
458
461
|
});
|
|
459
|
-
return
|
|
462
|
+
return app6;
|
|
460
463
|
}
|
|
461
464
|
|
|
462
465
|
// src/server/routes/agents.ts
|
|
463
466
|
import { Hono as Hono5 } from "hono";
|
|
464
467
|
import { zodToJsonSchema as zodToJsonSchema2 } from "@axlsdk/axl";
|
|
465
|
-
var
|
|
466
|
-
|
|
468
|
+
var app2 = new Hono5();
|
|
469
|
+
app2.get("/agents", (c) => {
|
|
467
470
|
const runtime = c.get("runtime");
|
|
468
471
|
const agents = runtime.getAgents().map((a) => ({
|
|
469
472
|
name: a._name,
|
|
@@ -482,7 +485,7 @@ app3.get("/agents", (c) => {
|
|
|
482
485
|
}));
|
|
483
486
|
return c.json({ ok: true, data: agents });
|
|
484
487
|
});
|
|
485
|
-
|
|
488
|
+
app2.get("/agents/:name", (c) => {
|
|
486
489
|
const runtime = c.get("runtime");
|
|
487
490
|
const name = c.req.param("name");
|
|
488
491
|
const agent = runtime.getAgent(name);
|
|
@@ -538,13 +541,13 @@ app3.get("/agents/:name", (c) => {
|
|
|
538
541
|
}
|
|
539
542
|
});
|
|
540
543
|
});
|
|
541
|
-
var agents_default =
|
|
544
|
+
var agents_default = app2;
|
|
542
545
|
|
|
543
546
|
// src/server/routes/tools.ts
|
|
544
547
|
import { Hono as Hono6 } from "hono";
|
|
545
548
|
import { zodToJsonSchema as zodToJsonSchema3 } from "@axlsdk/axl";
|
|
546
|
-
var
|
|
547
|
-
|
|
549
|
+
var app3 = new Hono6();
|
|
550
|
+
app3.get("/tools", (c) => {
|
|
548
551
|
const runtime = c.get("runtime");
|
|
549
552
|
const tools = runtime.getTools().map((t) => ({
|
|
550
553
|
name: t.name,
|
|
@@ -555,7 +558,7 @@ app4.get("/tools", (c) => {
|
|
|
555
558
|
}));
|
|
556
559
|
return c.json({ ok: true, data: tools });
|
|
557
560
|
});
|
|
558
|
-
|
|
561
|
+
app3.get("/tools/:name", (c) => {
|
|
559
562
|
const runtime = c.get("runtime");
|
|
560
563
|
const name = c.req.param("name");
|
|
561
564
|
const tool = runtime.getTool(name);
|
|
@@ -582,7 +585,7 @@ app4.get("/tools/:name", (c) => {
|
|
|
582
585
|
}
|
|
583
586
|
});
|
|
584
587
|
});
|
|
585
|
-
|
|
588
|
+
app3.post("/tools/:name/test", async (c) => {
|
|
586
589
|
const runtime = c.get("runtime");
|
|
587
590
|
const name = c.req.param("name");
|
|
588
591
|
const tool = runtime.getTool(name);
|
|
@@ -597,12 +600,12 @@ app4.post("/tools/:name/test", async (c) => {
|
|
|
597
600
|
const result = await tool.run(ctx, body.input);
|
|
598
601
|
return c.json({ ok: true, data: { result } });
|
|
599
602
|
});
|
|
600
|
-
var tools_default =
|
|
603
|
+
var tools_default = app3;
|
|
601
604
|
|
|
602
605
|
// src/server/routes/memory.ts
|
|
603
606
|
import { Hono as Hono7 } from "hono";
|
|
604
|
-
var
|
|
605
|
-
|
|
607
|
+
var app4 = new Hono7();
|
|
608
|
+
app4.get("/memory/:scope", async (c) => {
|
|
606
609
|
const runtime = c.get("runtime");
|
|
607
610
|
const store = runtime.getStateStore();
|
|
608
611
|
const scope = c.req.param("scope");
|
|
@@ -612,7 +615,7 @@ app5.get("/memory/:scope", async (c) => {
|
|
|
612
615
|
const entries = await store.getAllMemory(scope);
|
|
613
616
|
return c.json({ ok: true, data: entries });
|
|
614
617
|
});
|
|
615
|
-
|
|
618
|
+
app4.get("/memory/:scope/:key", async (c) => {
|
|
616
619
|
const runtime = c.get("runtime");
|
|
617
620
|
const store = runtime.getStateStore();
|
|
618
621
|
const scope = c.req.param("scope");
|
|
@@ -632,7 +635,7 @@ app5.get("/memory/:scope/:key", async (c) => {
|
|
|
632
635
|
}
|
|
633
636
|
return c.json({ ok: true, data: { key, value } });
|
|
634
637
|
});
|
|
635
|
-
|
|
638
|
+
app4.put("/memory/:scope/:key", async (c) => {
|
|
636
639
|
const runtime = c.get("runtime");
|
|
637
640
|
const store = runtime.getStateStore();
|
|
638
641
|
const scope = c.req.param("scope");
|
|
@@ -647,7 +650,7 @@ app5.put("/memory/:scope/:key", async (c) => {
|
|
|
647
650
|
await store.saveMemory(scope, key, body.value);
|
|
648
651
|
return c.json({ ok: true, data: { saved: true } });
|
|
649
652
|
});
|
|
650
|
-
|
|
653
|
+
app4.delete("/memory/:scope/:key", async (c) => {
|
|
651
654
|
const runtime = c.get("runtime");
|
|
652
655
|
const store = runtime.getStateStore();
|
|
653
656
|
const scope = c.req.param("scope");
|
|
@@ -661,61 +664,77 @@ app5.delete("/memory/:scope/:key", async (c) => {
|
|
|
661
664
|
await store.deleteMemory(scope, key);
|
|
662
665
|
return c.json({ ok: true, data: { deleted: true } });
|
|
663
666
|
});
|
|
664
|
-
|
|
667
|
+
app4.post("/memory/search", async (c) => {
|
|
665
668
|
return c.json({
|
|
666
669
|
ok: true,
|
|
667
670
|
data: { results: [], message: "Semantic search requires MemoryManager with vector store" }
|
|
668
671
|
});
|
|
669
672
|
});
|
|
670
|
-
var memory_default =
|
|
673
|
+
var memory_default = app4;
|
|
671
674
|
|
|
672
675
|
// src/server/routes/decisions.ts
|
|
673
676
|
import { Hono as Hono8 } from "hono";
|
|
674
|
-
var
|
|
675
|
-
|
|
677
|
+
var app5 = new Hono8();
|
|
678
|
+
app5.get("/decisions", async (c) => {
|
|
676
679
|
const runtime = c.get("runtime");
|
|
677
680
|
const decisions = await runtime.getPendingDecisions();
|
|
678
681
|
return c.json({ ok: true, data: decisions });
|
|
679
682
|
});
|
|
680
|
-
|
|
683
|
+
app5.post("/decisions/:executionId/resolve", async (c) => {
|
|
681
684
|
const runtime = c.get("runtime");
|
|
682
685
|
const executionId = c.req.param("executionId");
|
|
683
686
|
const body = await c.req.json();
|
|
684
687
|
await runtime.resolveDecision(executionId, body);
|
|
685
688
|
return c.json({ ok: true, data: { resolved: true } });
|
|
686
689
|
});
|
|
687
|
-
var decisions_default =
|
|
690
|
+
var decisions_default = app5;
|
|
688
691
|
|
|
689
692
|
// src/server/routes/costs.ts
|
|
690
693
|
import { Hono as Hono9 } from "hono";
|
|
691
694
|
function createCostRoutes(costAggregator) {
|
|
692
|
-
const
|
|
693
|
-
|
|
695
|
+
const app6 = new Hono9();
|
|
696
|
+
app6.get("/costs", (c) => {
|
|
694
697
|
return c.json({ ok: true, data: costAggregator.getData() });
|
|
695
698
|
});
|
|
696
|
-
|
|
699
|
+
app6.post("/costs/reset", (c) => {
|
|
697
700
|
costAggregator.reset();
|
|
698
701
|
return c.json({ ok: true, data: { reset: true } });
|
|
699
702
|
});
|
|
700
|
-
return
|
|
703
|
+
return app6;
|
|
701
704
|
}
|
|
702
705
|
|
|
703
706
|
// src/server/routes/evals.ts
|
|
707
|
+
import { randomUUID } from "crypto";
|
|
704
708
|
import { Hono as Hono10 } from "hono";
|
|
705
709
|
function createEvalRoutes(evalLoader) {
|
|
706
|
-
const
|
|
707
|
-
|
|
710
|
+
const app6 = new Hono10();
|
|
711
|
+
app6.get("/evals", async (c) => {
|
|
708
712
|
if (evalLoader) await evalLoader();
|
|
709
713
|
const runtime = c.get("runtime");
|
|
710
714
|
const evals = runtime.getRegisteredEvals();
|
|
711
715
|
return c.json({ ok: true, data: evals });
|
|
712
716
|
});
|
|
713
|
-
|
|
717
|
+
app6.get("/evals/history", async (c) => {
|
|
714
718
|
const runtime = c.get("runtime");
|
|
715
719
|
const history = await runtime.getEvalHistory();
|
|
716
720
|
return c.json({ ok: true, data: history });
|
|
717
721
|
});
|
|
718
|
-
|
|
722
|
+
app6.delete("/evals/history/:id", async (c) => {
|
|
723
|
+
const runtime = c.get("runtime");
|
|
724
|
+
const id = c.req.param("id");
|
|
725
|
+
const deleted = await runtime.deleteEvalResult(id);
|
|
726
|
+
if (!deleted) {
|
|
727
|
+
return c.json(
|
|
728
|
+
{
|
|
729
|
+
ok: false,
|
|
730
|
+
error: { code: "NOT_FOUND", message: `Eval history entry "${id}" not found` }
|
|
731
|
+
},
|
|
732
|
+
404
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
return c.json({ ok: true, data: { id, deleted: true } });
|
|
736
|
+
});
|
|
737
|
+
app6.post("/evals/:name/run", async (c) => {
|
|
719
738
|
if (evalLoader) await evalLoader();
|
|
720
739
|
const runtime = c.get("runtime");
|
|
721
740
|
const name = c.req.param("name");
|
|
@@ -736,7 +755,6 @@ function createEvalRoutes(evalLoader) {
|
|
|
736
755
|
}
|
|
737
756
|
try {
|
|
738
757
|
if (runs > 1) {
|
|
739
|
-
const { randomUUID } = await import("crypto");
|
|
740
758
|
const { aggregateRuns } = await import("@axlsdk/eval");
|
|
741
759
|
const runGroupId = randomUUID();
|
|
742
760
|
const results = [];
|
|
@@ -760,7 +778,7 @@ function createEvalRoutes(evalLoader) {
|
|
|
760
778
|
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
761
779
|
}
|
|
762
780
|
});
|
|
763
|
-
|
|
781
|
+
app6.post("/evals/:name/rescore", async (c) => {
|
|
764
782
|
if (evalLoader) await evalLoader();
|
|
765
783
|
const runtime = c.get("runtime");
|
|
766
784
|
const name = c.req.param("name");
|
|
@@ -806,25 +824,146 @@ function createEvalRoutes(evalLoader) {
|
|
|
806
824
|
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
807
825
|
}
|
|
808
826
|
});
|
|
809
|
-
|
|
827
|
+
app6.post("/evals/compare", async (c) => {
|
|
810
828
|
const runtime = c.get("runtime");
|
|
811
829
|
const body = await c.req.json();
|
|
830
|
+
const validateIdParam = (v, name) => {
|
|
831
|
+
if (typeof v === "string") return v === "" ? `${name} must be non-empty` : null;
|
|
832
|
+
if (Array.isArray(v)) {
|
|
833
|
+
if (v.length === 0) return `${name} must be a non-empty array`;
|
|
834
|
+
for (const elem of v) {
|
|
835
|
+
if (typeof elem !== "string" || elem === "") {
|
|
836
|
+
return `${name} array must contain only non-empty strings`;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
return `${name} is required (string or string[])`;
|
|
842
|
+
};
|
|
843
|
+
const baselineErr = validateIdParam(body.baselineId, "baselineId");
|
|
844
|
+
const candidateErr = validateIdParam(body.candidateId, "candidateId");
|
|
845
|
+
if (baselineErr || candidateErr) {
|
|
846
|
+
return c.json(
|
|
847
|
+
{
|
|
848
|
+
ok: false,
|
|
849
|
+
error: {
|
|
850
|
+
code: "BAD_REQUEST",
|
|
851
|
+
message: [baselineErr, candidateErr].filter(Boolean).join("; ")
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
400
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
const history = await runtime.getEvalHistory();
|
|
858
|
+
const byId = new Map(history.map((h) => [h.id, h.data]));
|
|
859
|
+
const missing = [];
|
|
860
|
+
const resolveOne = (id) => {
|
|
861
|
+
const data = byId.get(id);
|
|
862
|
+
if (!data) missing.push(id);
|
|
863
|
+
return data;
|
|
864
|
+
};
|
|
865
|
+
const resolveSelection = (idOrIds) => {
|
|
866
|
+
if (Array.isArray(idOrIds)) {
|
|
867
|
+
const unique = Array.from(new Set(idOrIds));
|
|
868
|
+
if (unique.length === 1) return resolveOne(unique[0]);
|
|
869
|
+
const results = [];
|
|
870
|
+
for (const id of unique) {
|
|
871
|
+
const data = resolveOne(id);
|
|
872
|
+
if (data) results.push(data);
|
|
873
|
+
}
|
|
874
|
+
return results;
|
|
875
|
+
}
|
|
876
|
+
return resolveOne(idOrIds);
|
|
877
|
+
};
|
|
878
|
+
const baseline = resolveSelection(body.baselineId);
|
|
879
|
+
const candidate = resolveSelection(body.candidateId);
|
|
880
|
+
if (missing.length > 0) {
|
|
881
|
+
return c.json(
|
|
882
|
+
{
|
|
883
|
+
ok: false,
|
|
884
|
+
error: {
|
|
885
|
+
code: "NOT_FOUND",
|
|
886
|
+
message: `Eval result(s) not found in history: ${missing.join(", ")}`
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
404
|
|
890
|
+
);
|
|
891
|
+
}
|
|
812
892
|
try {
|
|
813
|
-
const result = await runtime.evalCompare(
|
|
893
|
+
const result = await runtime.evalCompare(baseline, candidate, body.options);
|
|
814
894
|
return c.json({ ok: true, data: result });
|
|
815
895
|
} catch (err) {
|
|
816
896
|
const message = err instanceof Error ? err.message : String(err);
|
|
817
|
-
return c.json({ ok: false, error: { code: "
|
|
897
|
+
return c.json({ ok: false, error: { code: "COMPARE_FAILED", message } }, 400);
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
app6.post("/evals/import", async (c) => {
|
|
901
|
+
const runtime = c.get("runtime");
|
|
902
|
+
const body = await c.req.json();
|
|
903
|
+
const bad = (message) => c.json({ ok: false, error: { code: "BAD_REQUEST", message } }, 400);
|
|
904
|
+
if (!body.result || typeof body.result !== "object") {
|
|
905
|
+
return bad("result is required");
|
|
906
|
+
}
|
|
907
|
+
const result = body.result;
|
|
908
|
+
if (!Array.isArray(result.items)) {
|
|
909
|
+
return bad("result.items must be an array");
|
|
910
|
+
}
|
|
911
|
+
if (typeof result.summary !== "object" || result.summary == null) {
|
|
912
|
+
return bad("result.summary must be an object");
|
|
913
|
+
}
|
|
914
|
+
if (typeof result.dataset !== "string" || !result.dataset) {
|
|
915
|
+
return bad("result.dataset must be a non-empty string (required for compare)");
|
|
818
916
|
}
|
|
917
|
+
const summary = result.summary;
|
|
918
|
+
if (typeof summary.scorers !== "object" || summary.scorers == null) {
|
|
919
|
+
return bad("result.summary.scorers must be an object");
|
|
920
|
+
}
|
|
921
|
+
const summaryScorerNames = Object.keys(summary.scorers);
|
|
922
|
+
const items = result.items;
|
|
923
|
+
const summaryScorerSet = new Set(summaryScorerNames);
|
|
924
|
+
const uncoveredAcrossItems = /* @__PURE__ */ new Set();
|
|
925
|
+
for (const item of items) {
|
|
926
|
+
const itemScores = item?.scores;
|
|
927
|
+
if (itemScores && typeof itemScores === "object") {
|
|
928
|
+
for (const name of Object.keys(itemScores)) {
|
|
929
|
+
if (!summaryScorerSet.has(name)) uncoveredAcrossItems.add(name);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (uncoveredAcrossItems.size > 0) {
|
|
934
|
+
return bad(
|
|
935
|
+
`item scores reference scorer(s) not in summary.scorers: ${[...uncoveredAcrossItems].join(", ")}`
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
const trim = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
939
|
+
const metadataObj = typeof result.metadata === "object" && result.metadata != null ? result.metadata : {};
|
|
940
|
+
const workflowsFromMeta = Array.isArray(metadataObj.workflows) ? metadataObj.workflows : [];
|
|
941
|
+
const primaryWorkflow = workflowsFromMeta.find((w) => typeof w === "string");
|
|
942
|
+
const evalName = trim(body.eval) ?? trim(primaryWorkflow) ?? // Legacy fallback: pre-0.14 CLI artifacts had workflow at the top level.
|
|
943
|
+
trim(result.workflow) ?? "imported";
|
|
944
|
+
const id = randomUUID();
|
|
945
|
+
const timestamp = Date.now();
|
|
946
|
+
const imported = {
|
|
947
|
+
...result,
|
|
948
|
+
id,
|
|
949
|
+
metadata: typeof result.metadata === "object" && result.metadata != null ? result.metadata : {}
|
|
950
|
+
};
|
|
951
|
+
await runtime.saveEvalResult({
|
|
952
|
+
id,
|
|
953
|
+
eval: evalName,
|
|
954
|
+
timestamp,
|
|
955
|
+
data: imported
|
|
956
|
+
});
|
|
957
|
+
return c.json({ ok: true, data: { id, eval: evalName, timestamp } });
|
|
819
958
|
});
|
|
820
|
-
return
|
|
959
|
+
return app6;
|
|
821
960
|
}
|
|
822
961
|
|
|
823
962
|
// src/server/routes/playground.ts
|
|
824
963
|
import { Hono as Hono11 } from "hono";
|
|
825
964
|
function createPlaygroundRoutes(connMgr) {
|
|
826
|
-
const
|
|
827
|
-
|
|
965
|
+
const app6 = new Hono11();
|
|
966
|
+
app6.post("/playground/chat", async (c) => {
|
|
828
967
|
const runtime = c.get("runtime");
|
|
829
968
|
const body = await c.req.json();
|
|
830
969
|
if (!body.message || typeof body.message !== "string" || !body.message.trim()) {
|
|
@@ -886,42 +1025,45 @@ function createPlaygroundRoutes(connMgr) {
|
|
|
886
1025
|
data: { sessionId, executionId, streaming: true }
|
|
887
1026
|
});
|
|
888
1027
|
});
|
|
889
|
-
return
|
|
1028
|
+
return app6;
|
|
890
1029
|
}
|
|
891
1030
|
|
|
892
1031
|
// src/server/index.ts
|
|
893
1032
|
function createServer(options) {
|
|
894
1033
|
const { runtime, staticRoot, basePath = "", readOnly = false } = options;
|
|
895
|
-
const
|
|
1034
|
+
const app6 = new Hono12();
|
|
896
1035
|
const connMgr = new ConnectionManager();
|
|
897
1036
|
const costAggregator = new CostAggregator(connMgr);
|
|
898
1037
|
if (options.cors !== false) {
|
|
899
|
-
|
|
1038
|
+
app6.use("*", cors());
|
|
900
1039
|
}
|
|
901
|
-
|
|
902
|
-
|
|
1040
|
+
app6.use("*", errorHandler);
|
|
1041
|
+
app6.use("*", async (c, next) => {
|
|
903
1042
|
c.set("runtime", runtime);
|
|
904
1043
|
await next();
|
|
905
1044
|
});
|
|
906
1045
|
if (readOnly) {
|
|
907
1046
|
const blocked = [
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1047
|
+
/^POST \/api\/workflows(\/|$)/,
|
|
1048
|
+
/^POST \/api\/executions(\/|$)/,
|
|
1049
|
+
/^POST \/api\/sessions(\/|$)/,
|
|
1050
|
+
/^DELETE \/api\/sessions(\/|$)/,
|
|
1051
|
+
/^PUT \/api\/memory(\/|$)/,
|
|
1052
|
+
/^DELETE \/api\/memory(\/|$)/,
|
|
1053
|
+
/^POST \/api\/decisions(\/|$)/,
|
|
1054
|
+
/^POST \/api\/costs(\/|$)/,
|
|
1055
|
+
/^POST \/api\/tools(\/|$)/,
|
|
1056
|
+
/^POST \/api\/evals\/import$/,
|
|
1057
|
+
/^POST \/api\/evals\/[^/]+\/run$/,
|
|
1058
|
+
/^POST \/api\/evals\/[^/]+\/rescore$/,
|
|
1059
|
+
/^DELETE \/api\/evals\/history\/[^/]+$/,
|
|
1060
|
+
/^POST \/api\/playground(\/|$)/
|
|
919
1061
|
];
|
|
920
|
-
|
|
1062
|
+
app6.use("/api/*", async (c, next) => {
|
|
921
1063
|
const apiIdx = c.req.path.indexOf("/api/");
|
|
922
1064
|
const apiPath = apiIdx >= 0 ? c.req.path.slice(apiIdx) : c.req.path;
|
|
923
1065
|
const key = `${c.req.method} ${apiPath}`;
|
|
924
|
-
if (blocked.some((
|
|
1066
|
+
if (blocked.some((re) => re.test(key))) {
|
|
925
1067
|
return c.json(
|
|
926
1068
|
{
|
|
927
1069
|
ok: false,
|
|
@@ -934,7 +1076,7 @@ function createServer(options) {
|
|
|
934
1076
|
});
|
|
935
1077
|
}
|
|
936
1078
|
const api = new Hono12();
|
|
937
|
-
api.route("/",
|
|
1079
|
+
api.route("/", createHealthRoutes(readOnly));
|
|
938
1080
|
api.route("/", createWorkflowRoutes(connMgr));
|
|
939
1081
|
api.route("/", executions_default);
|
|
940
1082
|
api.route("/", createSessionRoutes(connMgr));
|
|
@@ -945,7 +1087,7 @@ function createServer(options) {
|
|
|
945
1087
|
api.route("/", createCostRoutes(costAggregator));
|
|
946
1088
|
api.route("/", createEvalRoutes(options.evalLoader));
|
|
947
1089
|
api.route("/", createPlaygroundRoutes(connMgr));
|
|
948
|
-
|
|
1090
|
+
app6.route("/api", api);
|
|
949
1091
|
const traceListener = (event) => {
|
|
950
1092
|
const traceEvent = event;
|
|
951
1093
|
if (traceEvent.executionId) {
|
|
@@ -986,7 +1128,7 @@ function createServer(options) {
|
|
|
986
1128
|
root: staticRoot,
|
|
987
1129
|
rewriteRequestPath: basePath ? (path) => path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path : void 0
|
|
988
1130
|
});
|
|
989
|
-
|
|
1131
|
+
app6.use("/*", async (c, next) => {
|
|
990
1132
|
const reqPath = c.req.path;
|
|
991
1133
|
const resolved = basePath && reqPath.startsWith(basePath) ? reqPath.slice(basePath.length) || "/" : reqPath;
|
|
992
1134
|
if (resolved === "/" || resolved === "/index.html" || resolved === "/ws") {
|
|
@@ -995,7 +1137,7 @@ function createServer(options) {
|
|
|
995
1137
|
return staticHandler(c, next);
|
|
996
1138
|
});
|
|
997
1139
|
if (spaHtml) {
|
|
998
|
-
|
|
1140
|
+
app6.get("*", async (c, next) => {
|
|
999
1141
|
const resolved = basePath && c.req.path.startsWith(basePath) ? c.req.path.slice(basePath.length) || "/" : c.req.path;
|
|
1000
1142
|
if (resolved === "/ws") return next();
|
|
1001
1143
|
return c.html(spaHtml);
|
|
@@ -1003,7 +1145,7 @@ function createServer(options) {
|
|
|
1003
1145
|
}
|
|
1004
1146
|
}
|
|
1005
1147
|
return {
|
|
1006
|
-
app:
|
|
1148
|
+
app: app6,
|
|
1007
1149
|
connMgr,
|
|
1008
1150
|
costAggregator,
|
|
1009
1151
|
/** Create WS handlers. Call before registering static/SPA routes are reached. */
|
|
@@ -1018,4 +1160,4 @@ export {
|
|
|
1018
1160
|
CostAggregator,
|
|
1019
1161
|
createServer
|
|
1020
1162
|
};
|
|
1021
|
-
//# sourceMappingURL=chunk-
|
|
1163
|
+
//# sourceMappingURL=chunk-HUKUQDYL.js.map
|