@axlsdk/studio 0.13.8 → 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 +235 -93
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.js +2 -2
- 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
package/dist/server/index.cjs
CHANGED
|
@@ -334,27 +334,30 @@ var CostAggregator = class {
|
|
|
334
334
|
|
|
335
335
|
// src/server/routes/health.ts
|
|
336
336
|
var import_hono = require("hono");
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
337
|
+
function createHealthRoutes(readOnly) {
|
|
338
|
+
const app6 = new import_hono.Hono();
|
|
339
|
+
app6.get("/health", (c) => {
|
|
340
|
+
const runtime = c.get("runtime");
|
|
341
|
+
return c.json({
|
|
342
|
+
ok: true,
|
|
343
|
+
data: {
|
|
344
|
+
status: "healthy",
|
|
345
|
+
readOnly,
|
|
346
|
+
workflows: runtime.getWorkflowNames().length,
|
|
347
|
+
agents: runtime.getAgents().length,
|
|
348
|
+
tools: runtime.getTools().length
|
|
349
|
+
}
|
|
350
|
+
});
|
|
348
351
|
});
|
|
349
|
-
|
|
350
|
-
|
|
352
|
+
return app6;
|
|
353
|
+
}
|
|
351
354
|
|
|
352
355
|
// src/server/routes/workflows.ts
|
|
353
356
|
var import_hono2 = require("hono");
|
|
354
357
|
var import_axl = require("@axlsdk/axl");
|
|
355
358
|
function createWorkflowRoutes(connMgr) {
|
|
356
|
-
const
|
|
357
|
-
|
|
359
|
+
const app6 = new import_hono2.Hono();
|
|
360
|
+
app6.get("/workflows", (c) => {
|
|
358
361
|
const runtime = c.get("runtime");
|
|
359
362
|
const workflows = runtime.getWorkflows().map((w) => ({
|
|
360
363
|
name: w.name,
|
|
@@ -363,7 +366,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
363
366
|
}));
|
|
364
367
|
return c.json({ ok: true, data: workflows });
|
|
365
368
|
});
|
|
366
|
-
|
|
369
|
+
app6.get("/workflows/:name", (c) => {
|
|
367
370
|
const runtime = c.get("runtime");
|
|
368
371
|
const name = c.req.param("name");
|
|
369
372
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -382,7 +385,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
382
385
|
}
|
|
383
386
|
});
|
|
384
387
|
});
|
|
385
|
-
|
|
388
|
+
app6.post("/workflows/:name/execute", async (c) => {
|
|
386
389
|
const runtime = c.get("runtime");
|
|
387
390
|
const name = c.req.param("name");
|
|
388
391
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -406,18 +409,18 @@ function createWorkflowRoutes(connMgr) {
|
|
|
406
409
|
const result = await runtime.execute(name, body.input ?? {}, { metadata: body.metadata });
|
|
407
410
|
return c.json({ ok: true, data: { result } });
|
|
408
411
|
});
|
|
409
|
-
return
|
|
412
|
+
return app6;
|
|
410
413
|
}
|
|
411
414
|
|
|
412
415
|
// src/server/routes/executions.ts
|
|
413
416
|
var import_hono3 = require("hono");
|
|
414
|
-
var
|
|
415
|
-
|
|
417
|
+
var app = new import_hono3.Hono();
|
|
418
|
+
app.get("/executions", async (c) => {
|
|
416
419
|
const runtime = c.get("runtime");
|
|
417
420
|
const executions = await runtime.getExecutions();
|
|
418
421
|
return c.json({ ok: true, data: executions });
|
|
419
422
|
});
|
|
420
|
-
|
|
423
|
+
app.get("/executions/:id", async (c) => {
|
|
421
424
|
const runtime = c.get("runtime");
|
|
422
425
|
const id = c.req.param("id");
|
|
423
426
|
const execution = await runtime.getExecution(id);
|
|
@@ -429,19 +432,19 @@ app2.get("/executions/:id", async (c) => {
|
|
|
429
432
|
}
|
|
430
433
|
return c.json({ ok: true, data: execution });
|
|
431
434
|
});
|
|
432
|
-
|
|
435
|
+
app.post("/executions/:id/abort", (c) => {
|
|
433
436
|
const runtime = c.get("runtime");
|
|
434
437
|
const id = c.req.param("id");
|
|
435
438
|
runtime.abort(id);
|
|
436
439
|
return c.json({ ok: true, data: { aborted: true } });
|
|
437
440
|
});
|
|
438
|
-
var executions_default =
|
|
441
|
+
var executions_default = app;
|
|
439
442
|
|
|
440
443
|
// src/server/routes/sessions.ts
|
|
441
444
|
var import_hono4 = require("hono");
|
|
442
445
|
function createSessionRoutes(connMgr) {
|
|
443
|
-
const
|
|
444
|
-
|
|
446
|
+
const app6 = new import_hono4.Hono();
|
|
447
|
+
app6.get("/sessions", async (c) => {
|
|
445
448
|
const runtime = c.get("runtime");
|
|
446
449
|
const store = runtime.getStateStore();
|
|
447
450
|
if (!store.listSessions) {
|
|
@@ -455,7 +458,7 @@ function createSessionRoutes(connMgr) {
|
|
|
455
458
|
}
|
|
456
459
|
return c.json({ ok: true, data: sessions });
|
|
457
460
|
});
|
|
458
|
-
|
|
461
|
+
app6.get("/sessions/:id", async (c) => {
|
|
459
462
|
const runtime = c.get("runtime");
|
|
460
463
|
const store = runtime.getStateStore();
|
|
461
464
|
const id = c.req.param("id");
|
|
@@ -463,7 +466,7 @@ function createSessionRoutes(connMgr) {
|
|
|
463
466
|
const handoffHistory = await store.getSessionMeta(id, "handoffHistory");
|
|
464
467
|
return c.json({ ok: true, data: { id, history, handoffHistory: handoffHistory ?? [] } });
|
|
465
468
|
});
|
|
466
|
-
|
|
469
|
+
app6.post("/sessions/:id/send", async (c) => {
|
|
467
470
|
const runtime = c.get("runtime");
|
|
468
471
|
const id = c.req.param("id");
|
|
469
472
|
const body = await c.req.json();
|
|
@@ -471,7 +474,7 @@ function createSessionRoutes(connMgr) {
|
|
|
471
474
|
const result = await session.send(body.workflow, body.message);
|
|
472
475
|
return c.json({ ok: true, data: { result } });
|
|
473
476
|
});
|
|
474
|
-
|
|
477
|
+
app6.post("/sessions/:id/stream", async (c) => {
|
|
475
478
|
const runtime = c.get("runtime");
|
|
476
479
|
const id = c.req.param("id");
|
|
477
480
|
const body = await c.req.json();
|
|
@@ -485,21 +488,21 @@ function createSessionRoutes(connMgr) {
|
|
|
485
488
|
})();
|
|
486
489
|
return c.json({ ok: true, data: { executionId, streaming: true } });
|
|
487
490
|
});
|
|
488
|
-
|
|
491
|
+
app6.delete("/sessions/:id", async (c) => {
|
|
489
492
|
const runtime = c.get("runtime");
|
|
490
493
|
const store = runtime.getStateStore();
|
|
491
494
|
const id = c.req.param("id");
|
|
492
495
|
await store.deleteSession(id);
|
|
493
496
|
return c.json({ ok: true, data: { deleted: true } });
|
|
494
497
|
});
|
|
495
|
-
return
|
|
498
|
+
return app6;
|
|
496
499
|
}
|
|
497
500
|
|
|
498
501
|
// src/server/routes/agents.ts
|
|
499
502
|
var import_hono5 = require("hono");
|
|
500
503
|
var import_axl2 = require("@axlsdk/axl");
|
|
501
|
-
var
|
|
502
|
-
|
|
504
|
+
var app2 = new import_hono5.Hono();
|
|
505
|
+
app2.get("/agents", (c) => {
|
|
503
506
|
const runtime = c.get("runtime");
|
|
504
507
|
const agents = runtime.getAgents().map((a) => ({
|
|
505
508
|
name: a._name,
|
|
@@ -518,7 +521,7 @@ app3.get("/agents", (c) => {
|
|
|
518
521
|
}));
|
|
519
522
|
return c.json({ ok: true, data: agents });
|
|
520
523
|
});
|
|
521
|
-
|
|
524
|
+
app2.get("/agents/:name", (c) => {
|
|
522
525
|
const runtime = c.get("runtime");
|
|
523
526
|
const name = c.req.param("name");
|
|
524
527
|
const agent = runtime.getAgent(name);
|
|
@@ -574,13 +577,13 @@ app3.get("/agents/:name", (c) => {
|
|
|
574
577
|
}
|
|
575
578
|
});
|
|
576
579
|
});
|
|
577
|
-
var agents_default =
|
|
580
|
+
var agents_default = app2;
|
|
578
581
|
|
|
579
582
|
// src/server/routes/tools.ts
|
|
580
583
|
var import_hono6 = require("hono");
|
|
581
584
|
var import_axl3 = require("@axlsdk/axl");
|
|
582
|
-
var
|
|
583
|
-
|
|
585
|
+
var app3 = new import_hono6.Hono();
|
|
586
|
+
app3.get("/tools", (c) => {
|
|
584
587
|
const runtime = c.get("runtime");
|
|
585
588
|
const tools = runtime.getTools().map((t) => ({
|
|
586
589
|
name: t.name,
|
|
@@ -591,7 +594,7 @@ app4.get("/tools", (c) => {
|
|
|
591
594
|
}));
|
|
592
595
|
return c.json({ ok: true, data: tools });
|
|
593
596
|
});
|
|
594
|
-
|
|
597
|
+
app3.get("/tools/:name", (c) => {
|
|
595
598
|
const runtime = c.get("runtime");
|
|
596
599
|
const name = c.req.param("name");
|
|
597
600
|
const tool = runtime.getTool(name);
|
|
@@ -618,7 +621,7 @@ app4.get("/tools/:name", (c) => {
|
|
|
618
621
|
}
|
|
619
622
|
});
|
|
620
623
|
});
|
|
621
|
-
|
|
624
|
+
app3.post("/tools/:name/test", async (c) => {
|
|
622
625
|
const runtime = c.get("runtime");
|
|
623
626
|
const name = c.req.param("name");
|
|
624
627
|
const tool = runtime.getTool(name);
|
|
@@ -633,12 +636,12 @@ app4.post("/tools/:name/test", async (c) => {
|
|
|
633
636
|
const result = await tool.run(ctx, body.input);
|
|
634
637
|
return c.json({ ok: true, data: { result } });
|
|
635
638
|
});
|
|
636
|
-
var tools_default =
|
|
639
|
+
var tools_default = app3;
|
|
637
640
|
|
|
638
641
|
// src/server/routes/memory.ts
|
|
639
642
|
var import_hono7 = require("hono");
|
|
640
|
-
var
|
|
641
|
-
|
|
643
|
+
var app4 = new import_hono7.Hono();
|
|
644
|
+
app4.get("/memory/:scope", async (c) => {
|
|
642
645
|
const runtime = c.get("runtime");
|
|
643
646
|
const store = runtime.getStateStore();
|
|
644
647
|
const scope = c.req.param("scope");
|
|
@@ -648,7 +651,7 @@ app5.get("/memory/:scope", async (c) => {
|
|
|
648
651
|
const entries = await store.getAllMemory(scope);
|
|
649
652
|
return c.json({ ok: true, data: entries });
|
|
650
653
|
});
|
|
651
|
-
|
|
654
|
+
app4.get("/memory/:scope/:key", async (c) => {
|
|
652
655
|
const runtime = c.get("runtime");
|
|
653
656
|
const store = runtime.getStateStore();
|
|
654
657
|
const scope = c.req.param("scope");
|
|
@@ -668,7 +671,7 @@ app5.get("/memory/:scope/:key", async (c) => {
|
|
|
668
671
|
}
|
|
669
672
|
return c.json({ ok: true, data: { key, value } });
|
|
670
673
|
});
|
|
671
|
-
|
|
674
|
+
app4.put("/memory/:scope/:key", async (c) => {
|
|
672
675
|
const runtime = c.get("runtime");
|
|
673
676
|
const store = runtime.getStateStore();
|
|
674
677
|
const scope = c.req.param("scope");
|
|
@@ -683,7 +686,7 @@ app5.put("/memory/:scope/:key", async (c) => {
|
|
|
683
686
|
await store.saveMemory(scope, key, body.value);
|
|
684
687
|
return c.json({ ok: true, data: { saved: true } });
|
|
685
688
|
});
|
|
686
|
-
|
|
689
|
+
app4.delete("/memory/:scope/:key", async (c) => {
|
|
687
690
|
const runtime = c.get("runtime");
|
|
688
691
|
const store = runtime.getStateStore();
|
|
689
692
|
const scope = c.req.param("scope");
|
|
@@ -697,61 +700,77 @@ app5.delete("/memory/:scope/:key", async (c) => {
|
|
|
697
700
|
await store.deleteMemory(scope, key);
|
|
698
701
|
return c.json({ ok: true, data: { deleted: true } });
|
|
699
702
|
});
|
|
700
|
-
|
|
703
|
+
app4.post("/memory/search", async (c) => {
|
|
701
704
|
return c.json({
|
|
702
705
|
ok: true,
|
|
703
706
|
data: { results: [], message: "Semantic search requires MemoryManager with vector store" }
|
|
704
707
|
});
|
|
705
708
|
});
|
|
706
|
-
var memory_default =
|
|
709
|
+
var memory_default = app4;
|
|
707
710
|
|
|
708
711
|
// src/server/routes/decisions.ts
|
|
709
712
|
var import_hono8 = require("hono");
|
|
710
|
-
var
|
|
711
|
-
|
|
713
|
+
var app5 = new import_hono8.Hono();
|
|
714
|
+
app5.get("/decisions", async (c) => {
|
|
712
715
|
const runtime = c.get("runtime");
|
|
713
716
|
const decisions = await runtime.getPendingDecisions();
|
|
714
717
|
return c.json({ ok: true, data: decisions });
|
|
715
718
|
});
|
|
716
|
-
|
|
719
|
+
app5.post("/decisions/:executionId/resolve", async (c) => {
|
|
717
720
|
const runtime = c.get("runtime");
|
|
718
721
|
const executionId = c.req.param("executionId");
|
|
719
722
|
const body = await c.req.json();
|
|
720
723
|
await runtime.resolveDecision(executionId, body);
|
|
721
724
|
return c.json({ ok: true, data: { resolved: true } });
|
|
722
725
|
});
|
|
723
|
-
var decisions_default =
|
|
726
|
+
var decisions_default = app5;
|
|
724
727
|
|
|
725
728
|
// src/server/routes/costs.ts
|
|
726
729
|
var import_hono9 = require("hono");
|
|
727
730
|
function createCostRoutes(costAggregator) {
|
|
728
|
-
const
|
|
729
|
-
|
|
731
|
+
const app6 = new import_hono9.Hono();
|
|
732
|
+
app6.get("/costs", (c) => {
|
|
730
733
|
return c.json({ ok: true, data: costAggregator.getData() });
|
|
731
734
|
});
|
|
732
|
-
|
|
735
|
+
app6.post("/costs/reset", (c) => {
|
|
733
736
|
costAggregator.reset();
|
|
734
737
|
return c.json({ ok: true, data: { reset: true } });
|
|
735
738
|
});
|
|
736
|
-
return
|
|
739
|
+
return app6;
|
|
737
740
|
}
|
|
738
741
|
|
|
739
742
|
// src/server/routes/evals.ts
|
|
743
|
+
var import_node_crypto = require("crypto");
|
|
740
744
|
var import_hono10 = require("hono");
|
|
741
745
|
function createEvalRoutes(evalLoader) {
|
|
742
|
-
const
|
|
743
|
-
|
|
746
|
+
const app6 = new import_hono10.Hono();
|
|
747
|
+
app6.get("/evals", async (c) => {
|
|
744
748
|
if (evalLoader) await evalLoader();
|
|
745
749
|
const runtime = c.get("runtime");
|
|
746
750
|
const evals = runtime.getRegisteredEvals();
|
|
747
751
|
return c.json({ ok: true, data: evals });
|
|
748
752
|
});
|
|
749
|
-
|
|
753
|
+
app6.get("/evals/history", async (c) => {
|
|
750
754
|
const runtime = c.get("runtime");
|
|
751
755
|
const history = await runtime.getEvalHistory();
|
|
752
756
|
return c.json({ ok: true, data: history });
|
|
753
757
|
});
|
|
754
|
-
|
|
758
|
+
app6.delete("/evals/history/:id", async (c) => {
|
|
759
|
+
const runtime = c.get("runtime");
|
|
760
|
+
const id = c.req.param("id");
|
|
761
|
+
const deleted = await runtime.deleteEvalResult(id);
|
|
762
|
+
if (!deleted) {
|
|
763
|
+
return c.json(
|
|
764
|
+
{
|
|
765
|
+
ok: false,
|
|
766
|
+
error: { code: "NOT_FOUND", message: `Eval history entry "${id}" not found` }
|
|
767
|
+
},
|
|
768
|
+
404
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
return c.json({ ok: true, data: { id, deleted: true } });
|
|
772
|
+
});
|
|
773
|
+
app6.post("/evals/:name/run", async (c) => {
|
|
755
774
|
if (evalLoader) await evalLoader();
|
|
756
775
|
const runtime = c.get("runtime");
|
|
757
776
|
const name = c.req.param("name");
|
|
@@ -772,9 +791,8 @@ function createEvalRoutes(evalLoader) {
|
|
|
772
791
|
}
|
|
773
792
|
try {
|
|
774
793
|
if (runs > 1) {
|
|
775
|
-
const { randomUUID } = await import("crypto");
|
|
776
794
|
const { aggregateRuns } = await import("@axlsdk/eval");
|
|
777
|
-
const runGroupId = randomUUID();
|
|
795
|
+
const runGroupId = (0, import_node_crypto.randomUUID)();
|
|
778
796
|
const results = [];
|
|
779
797
|
for (let r = 0; r < runs; r++) {
|
|
780
798
|
const result2 = await runtime.runRegisteredEval(name, {
|
|
@@ -796,7 +814,7 @@ function createEvalRoutes(evalLoader) {
|
|
|
796
814
|
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
797
815
|
}
|
|
798
816
|
});
|
|
799
|
-
|
|
817
|
+
app6.post("/evals/:name/rescore", async (c) => {
|
|
800
818
|
if (evalLoader) await evalLoader();
|
|
801
819
|
const runtime = c.get("runtime");
|
|
802
820
|
const name = c.req.param("name");
|
|
@@ -842,25 +860,146 @@ function createEvalRoutes(evalLoader) {
|
|
|
842
860
|
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
843
861
|
}
|
|
844
862
|
});
|
|
845
|
-
|
|
863
|
+
app6.post("/evals/compare", async (c) => {
|
|
846
864
|
const runtime = c.get("runtime");
|
|
847
865
|
const body = await c.req.json();
|
|
866
|
+
const validateIdParam = (v, name) => {
|
|
867
|
+
if (typeof v === "string") return v === "" ? `${name} must be non-empty` : null;
|
|
868
|
+
if (Array.isArray(v)) {
|
|
869
|
+
if (v.length === 0) return `${name} must be a non-empty array`;
|
|
870
|
+
for (const elem of v) {
|
|
871
|
+
if (typeof elem !== "string" || elem === "") {
|
|
872
|
+
return `${name} array must contain only non-empty strings`;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
return `${name} is required (string or string[])`;
|
|
878
|
+
};
|
|
879
|
+
const baselineErr = validateIdParam(body.baselineId, "baselineId");
|
|
880
|
+
const candidateErr = validateIdParam(body.candidateId, "candidateId");
|
|
881
|
+
if (baselineErr || candidateErr) {
|
|
882
|
+
return c.json(
|
|
883
|
+
{
|
|
884
|
+
ok: false,
|
|
885
|
+
error: {
|
|
886
|
+
code: "BAD_REQUEST",
|
|
887
|
+
message: [baselineErr, candidateErr].filter(Boolean).join("; ")
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
400
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
const history = await runtime.getEvalHistory();
|
|
894
|
+
const byId = new Map(history.map((h) => [h.id, h.data]));
|
|
895
|
+
const missing = [];
|
|
896
|
+
const resolveOne = (id) => {
|
|
897
|
+
const data = byId.get(id);
|
|
898
|
+
if (!data) missing.push(id);
|
|
899
|
+
return data;
|
|
900
|
+
};
|
|
901
|
+
const resolveSelection = (idOrIds) => {
|
|
902
|
+
if (Array.isArray(idOrIds)) {
|
|
903
|
+
const unique = Array.from(new Set(idOrIds));
|
|
904
|
+
if (unique.length === 1) return resolveOne(unique[0]);
|
|
905
|
+
const results = [];
|
|
906
|
+
for (const id of unique) {
|
|
907
|
+
const data = resolveOne(id);
|
|
908
|
+
if (data) results.push(data);
|
|
909
|
+
}
|
|
910
|
+
return results;
|
|
911
|
+
}
|
|
912
|
+
return resolveOne(idOrIds);
|
|
913
|
+
};
|
|
914
|
+
const baseline = resolveSelection(body.baselineId);
|
|
915
|
+
const candidate = resolveSelection(body.candidateId);
|
|
916
|
+
if (missing.length > 0) {
|
|
917
|
+
return c.json(
|
|
918
|
+
{
|
|
919
|
+
ok: false,
|
|
920
|
+
error: {
|
|
921
|
+
code: "NOT_FOUND",
|
|
922
|
+
message: `Eval result(s) not found in history: ${missing.join(", ")}`
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
404
|
|
926
|
+
);
|
|
927
|
+
}
|
|
848
928
|
try {
|
|
849
|
-
const result = await runtime.evalCompare(
|
|
929
|
+
const result = await runtime.evalCompare(baseline, candidate, body.options);
|
|
850
930
|
return c.json({ ok: true, data: result });
|
|
851
931
|
} catch (err) {
|
|
852
932
|
const message = err instanceof Error ? err.message : String(err);
|
|
853
|
-
return c.json({ ok: false, error: { code: "
|
|
933
|
+
return c.json({ ok: false, error: { code: "COMPARE_FAILED", message } }, 400);
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
app6.post("/evals/import", async (c) => {
|
|
937
|
+
const runtime = c.get("runtime");
|
|
938
|
+
const body = await c.req.json();
|
|
939
|
+
const bad = (message) => c.json({ ok: false, error: { code: "BAD_REQUEST", message } }, 400);
|
|
940
|
+
if (!body.result || typeof body.result !== "object") {
|
|
941
|
+
return bad("result is required");
|
|
942
|
+
}
|
|
943
|
+
const result = body.result;
|
|
944
|
+
if (!Array.isArray(result.items)) {
|
|
945
|
+
return bad("result.items must be an array");
|
|
946
|
+
}
|
|
947
|
+
if (typeof result.summary !== "object" || result.summary == null) {
|
|
948
|
+
return bad("result.summary must be an object");
|
|
949
|
+
}
|
|
950
|
+
if (typeof result.dataset !== "string" || !result.dataset) {
|
|
951
|
+
return bad("result.dataset must be a non-empty string (required for compare)");
|
|
854
952
|
}
|
|
953
|
+
const summary = result.summary;
|
|
954
|
+
if (typeof summary.scorers !== "object" || summary.scorers == null) {
|
|
955
|
+
return bad("result.summary.scorers must be an object");
|
|
956
|
+
}
|
|
957
|
+
const summaryScorerNames = Object.keys(summary.scorers);
|
|
958
|
+
const items = result.items;
|
|
959
|
+
const summaryScorerSet = new Set(summaryScorerNames);
|
|
960
|
+
const uncoveredAcrossItems = /* @__PURE__ */ new Set();
|
|
961
|
+
for (const item of items) {
|
|
962
|
+
const itemScores = item?.scores;
|
|
963
|
+
if (itemScores && typeof itemScores === "object") {
|
|
964
|
+
for (const name of Object.keys(itemScores)) {
|
|
965
|
+
if (!summaryScorerSet.has(name)) uncoveredAcrossItems.add(name);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
if (uncoveredAcrossItems.size > 0) {
|
|
970
|
+
return bad(
|
|
971
|
+
`item scores reference scorer(s) not in summary.scorers: ${[...uncoveredAcrossItems].join(", ")}`
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
const trim = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
975
|
+
const metadataObj = typeof result.metadata === "object" && result.metadata != null ? result.metadata : {};
|
|
976
|
+
const workflowsFromMeta = Array.isArray(metadataObj.workflows) ? metadataObj.workflows : [];
|
|
977
|
+
const primaryWorkflow = workflowsFromMeta.find((w) => typeof w === "string");
|
|
978
|
+
const evalName = trim(body.eval) ?? trim(primaryWorkflow) ?? // Legacy fallback: pre-0.14 CLI artifacts had workflow at the top level.
|
|
979
|
+
trim(result.workflow) ?? "imported";
|
|
980
|
+
const id = (0, import_node_crypto.randomUUID)();
|
|
981
|
+
const timestamp = Date.now();
|
|
982
|
+
const imported = {
|
|
983
|
+
...result,
|
|
984
|
+
id,
|
|
985
|
+
metadata: typeof result.metadata === "object" && result.metadata != null ? result.metadata : {}
|
|
986
|
+
};
|
|
987
|
+
await runtime.saveEvalResult({
|
|
988
|
+
id,
|
|
989
|
+
eval: evalName,
|
|
990
|
+
timestamp,
|
|
991
|
+
data: imported
|
|
992
|
+
});
|
|
993
|
+
return c.json({ ok: true, data: { id, eval: evalName, timestamp } });
|
|
855
994
|
});
|
|
856
|
-
return
|
|
995
|
+
return app6;
|
|
857
996
|
}
|
|
858
997
|
|
|
859
998
|
// src/server/routes/playground.ts
|
|
860
999
|
var import_hono11 = require("hono");
|
|
861
1000
|
function createPlaygroundRoutes(connMgr) {
|
|
862
|
-
const
|
|
863
|
-
|
|
1001
|
+
const app6 = new import_hono11.Hono();
|
|
1002
|
+
app6.post("/playground/chat", async (c) => {
|
|
864
1003
|
const runtime = c.get("runtime");
|
|
865
1004
|
const body = await c.req.json();
|
|
866
1005
|
if (!body.message || typeof body.message !== "string" || !body.message.trim()) {
|
|
@@ -922,42 +1061,45 @@ function createPlaygroundRoutes(connMgr) {
|
|
|
922
1061
|
data: { sessionId, executionId, streaming: true }
|
|
923
1062
|
});
|
|
924
1063
|
});
|
|
925
|
-
return
|
|
1064
|
+
return app6;
|
|
926
1065
|
}
|
|
927
1066
|
|
|
928
1067
|
// src/server/index.ts
|
|
929
1068
|
function createServer(options) {
|
|
930
1069
|
const { runtime, staticRoot, basePath = "", readOnly = false } = options;
|
|
931
|
-
const
|
|
1070
|
+
const app6 = new import_hono12.Hono();
|
|
932
1071
|
const connMgr = new ConnectionManager();
|
|
933
1072
|
const costAggregator = new CostAggregator(connMgr);
|
|
934
1073
|
if (options.cors !== false) {
|
|
935
|
-
|
|
1074
|
+
app6.use("*", (0, import_cors.cors)());
|
|
936
1075
|
}
|
|
937
|
-
|
|
938
|
-
|
|
1076
|
+
app6.use("*", errorHandler);
|
|
1077
|
+
app6.use("*", async (c, next) => {
|
|
939
1078
|
c.set("runtime", runtime);
|
|
940
1079
|
await next();
|
|
941
1080
|
});
|
|
942
1081
|
if (readOnly) {
|
|
943
1082
|
const blocked = [
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1083
|
+
/^POST \/api\/workflows(\/|$)/,
|
|
1084
|
+
/^POST \/api\/executions(\/|$)/,
|
|
1085
|
+
/^POST \/api\/sessions(\/|$)/,
|
|
1086
|
+
/^DELETE \/api\/sessions(\/|$)/,
|
|
1087
|
+
/^PUT \/api\/memory(\/|$)/,
|
|
1088
|
+
/^DELETE \/api\/memory(\/|$)/,
|
|
1089
|
+
/^POST \/api\/decisions(\/|$)/,
|
|
1090
|
+
/^POST \/api\/costs(\/|$)/,
|
|
1091
|
+
/^POST \/api\/tools(\/|$)/,
|
|
1092
|
+
/^POST \/api\/evals\/import$/,
|
|
1093
|
+
/^POST \/api\/evals\/[^/]+\/run$/,
|
|
1094
|
+
/^POST \/api\/evals\/[^/]+\/rescore$/,
|
|
1095
|
+
/^DELETE \/api\/evals\/history\/[^/]+$/,
|
|
1096
|
+
/^POST \/api\/playground(\/|$)/
|
|
955
1097
|
];
|
|
956
|
-
|
|
1098
|
+
app6.use("/api/*", async (c, next) => {
|
|
957
1099
|
const apiIdx = c.req.path.indexOf("/api/");
|
|
958
1100
|
const apiPath = apiIdx >= 0 ? c.req.path.slice(apiIdx) : c.req.path;
|
|
959
1101
|
const key = `${c.req.method} ${apiPath}`;
|
|
960
|
-
if (blocked.some((
|
|
1102
|
+
if (blocked.some((re) => re.test(key))) {
|
|
961
1103
|
return c.json(
|
|
962
1104
|
{
|
|
963
1105
|
ok: false,
|
|
@@ -970,7 +1112,7 @@ function createServer(options) {
|
|
|
970
1112
|
});
|
|
971
1113
|
}
|
|
972
1114
|
const api = new import_hono12.Hono();
|
|
973
|
-
api.route("/",
|
|
1115
|
+
api.route("/", createHealthRoutes(readOnly));
|
|
974
1116
|
api.route("/", createWorkflowRoutes(connMgr));
|
|
975
1117
|
api.route("/", executions_default);
|
|
976
1118
|
api.route("/", createSessionRoutes(connMgr));
|
|
@@ -981,7 +1123,7 @@ function createServer(options) {
|
|
|
981
1123
|
api.route("/", createCostRoutes(costAggregator));
|
|
982
1124
|
api.route("/", createEvalRoutes(options.evalLoader));
|
|
983
1125
|
api.route("/", createPlaygroundRoutes(connMgr));
|
|
984
|
-
|
|
1126
|
+
app6.route("/api", api);
|
|
985
1127
|
const traceListener = (event) => {
|
|
986
1128
|
const traceEvent = event;
|
|
987
1129
|
if (traceEvent.executionId) {
|
|
@@ -1022,7 +1164,7 @@ function createServer(options) {
|
|
|
1022
1164
|
root: staticRoot,
|
|
1023
1165
|
rewriteRequestPath: basePath ? (path) => path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path : void 0
|
|
1024
1166
|
});
|
|
1025
|
-
|
|
1167
|
+
app6.use("/*", async (c, next) => {
|
|
1026
1168
|
const reqPath = c.req.path;
|
|
1027
1169
|
const resolved = basePath && reqPath.startsWith(basePath) ? reqPath.slice(basePath.length) || "/" : reqPath;
|
|
1028
1170
|
if (resolved === "/" || resolved === "/index.html" || resolved === "/ws") {
|
|
@@ -1031,7 +1173,7 @@ function createServer(options) {
|
|
|
1031
1173
|
return staticHandler(c, next);
|
|
1032
1174
|
});
|
|
1033
1175
|
if (spaHtml) {
|
|
1034
|
-
|
|
1176
|
+
app6.get("*", async (c, next) => {
|
|
1035
1177
|
const resolved = basePath && c.req.path.startsWith(basePath) ? c.req.path.slice(basePath.length) || "/" : c.req.path;
|
|
1036
1178
|
if (resolved === "/ws") return next();
|
|
1037
1179
|
return c.html(spaHtml);
|
|
@@ -1039,7 +1181,7 @@ function createServer(options) {
|
|
|
1039
1181
|
}
|
|
1040
1182
|
}
|
|
1041
1183
|
return {
|
|
1042
|
-
app:
|
|
1184
|
+
app: app6,
|
|
1043
1185
|
connMgr,
|
|
1044
1186
|
costAggregator,
|
|
1045
1187
|
/** Create WS handlers. Call before registering static/SPA routes are reached. */
|