@axlsdk/studio 0.10.0 → 0.10.1
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 +51 -0
- package/dist/{chunk-RBTYI3TW.js → chunk-GKIPF45K.js} +71 -67
- package/dist/chunk-GKIPF45K.js.map +1 -0
- package/dist/cli.cjs +74 -70
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/middleware.cjs +263 -78
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.cts +56 -1
- package/dist/middleware.d.ts +56 -1
- package/dist/middleware.js +181 -8
- package/dist/middleware.js.map +1 -1
- package/dist/server/index.cjs +70 -66
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-RBTYI3TW.js.map +0 -1
package/dist/middleware.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/middleware.ts
|
|
@@ -24,9 +34,9 @@ __export(middleware_exports, {
|
|
|
24
34
|
handleWsMessage: () => handleWsMessage
|
|
25
35
|
});
|
|
26
36
|
module.exports = __toCommonJS(middleware_exports);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
37
|
+
var import_node_path3 = require("path");
|
|
38
|
+
var import_node_fs3 = require("fs");
|
|
39
|
+
var import_node_url2 = require("url");
|
|
30
40
|
var import_node_server = require("@hono/node-server");
|
|
31
41
|
var import_ws = require("ws");
|
|
32
42
|
|
|
@@ -308,8 +318,8 @@ var health_default = app;
|
|
|
308
318
|
var import_hono2 = require("hono");
|
|
309
319
|
var import_axl = require("@axlsdk/axl");
|
|
310
320
|
function createWorkflowRoutes(connMgr) {
|
|
311
|
-
const
|
|
312
|
-
|
|
321
|
+
const app7 = new import_hono2.Hono();
|
|
322
|
+
app7.get("/workflows", (c) => {
|
|
313
323
|
const runtime = c.get("runtime");
|
|
314
324
|
const workflows = runtime.getWorkflows().map((w) => ({
|
|
315
325
|
name: w.name,
|
|
@@ -318,7 +328,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
318
328
|
}));
|
|
319
329
|
return c.json({ ok: true, data: workflows });
|
|
320
330
|
});
|
|
321
|
-
|
|
331
|
+
app7.get("/workflows/:name", (c) => {
|
|
322
332
|
const runtime = c.get("runtime");
|
|
323
333
|
const name = c.req.param("name");
|
|
324
334
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -337,7 +347,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
337
347
|
}
|
|
338
348
|
});
|
|
339
349
|
});
|
|
340
|
-
|
|
350
|
+
app7.post("/workflows/:name/execute", async (c) => {
|
|
341
351
|
const runtime = c.get("runtime");
|
|
342
352
|
const name = c.req.param("name");
|
|
343
353
|
const workflow = runtime.getWorkflow(name);
|
|
@@ -368,7 +378,7 @@ function createWorkflowRoutes(connMgr) {
|
|
|
368
378
|
const result = await runtime.execute(name, body.input ?? {}, { metadata: body.metadata });
|
|
369
379
|
return c.json({ ok: true, data: { result } });
|
|
370
380
|
});
|
|
371
|
-
return
|
|
381
|
+
return app7;
|
|
372
382
|
}
|
|
373
383
|
|
|
374
384
|
// src/server/routes/executions.ts
|
|
@@ -402,8 +412,8 @@ var executions_default = app2;
|
|
|
402
412
|
// src/server/routes/sessions.ts
|
|
403
413
|
var import_hono4 = require("hono");
|
|
404
414
|
function createSessionRoutes(connMgr) {
|
|
405
|
-
const
|
|
406
|
-
|
|
415
|
+
const app7 = new import_hono4.Hono();
|
|
416
|
+
app7.get("/sessions", async (c) => {
|
|
407
417
|
const runtime = c.get("runtime");
|
|
408
418
|
const store = runtime.getStateStore();
|
|
409
419
|
if (!store.listSessions) {
|
|
@@ -417,7 +427,7 @@ function createSessionRoutes(connMgr) {
|
|
|
417
427
|
}
|
|
418
428
|
return c.json({ ok: true, data: sessions });
|
|
419
429
|
});
|
|
420
|
-
|
|
430
|
+
app7.get("/sessions/:id", async (c) => {
|
|
421
431
|
const runtime = c.get("runtime");
|
|
422
432
|
const store = runtime.getStateStore();
|
|
423
433
|
const id = c.req.param("id");
|
|
@@ -425,7 +435,7 @@ function createSessionRoutes(connMgr) {
|
|
|
425
435
|
const handoffHistory = await store.getSessionMeta(id, "handoffHistory");
|
|
426
436
|
return c.json({ ok: true, data: { id, history, handoffHistory: handoffHistory ?? [] } });
|
|
427
437
|
});
|
|
428
|
-
|
|
438
|
+
app7.post("/sessions/:id/send", async (c) => {
|
|
429
439
|
const runtime = c.get("runtime");
|
|
430
440
|
const id = c.req.param("id");
|
|
431
441
|
const body = await c.req.json();
|
|
@@ -433,7 +443,7 @@ function createSessionRoutes(connMgr) {
|
|
|
433
443
|
const result = await session.send(body.workflow, body.message);
|
|
434
444
|
return c.json({ ok: true, data: { result } });
|
|
435
445
|
});
|
|
436
|
-
|
|
446
|
+
app7.post("/sessions/:id/stream", async (c) => {
|
|
437
447
|
const runtime = c.get("runtime");
|
|
438
448
|
const id = c.req.param("id");
|
|
439
449
|
const body = await c.req.json();
|
|
@@ -454,14 +464,14 @@ function createSessionRoutes(connMgr) {
|
|
|
454
464
|
})();
|
|
455
465
|
return c.json({ ok: true, data: { executionId, streaming: true } });
|
|
456
466
|
});
|
|
457
|
-
|
|
467
|
+
app7.delete("/sessions/:id", async (c) => {
|
|
458
468
|
const runtime = c.get("runtime");
|
|
459
469
|
const store = runtime.getStateStore();
|
|
460
470
|
const id = c.req.param("id");
|
|
461
471
|
await store.deleteSession(id);
|
|
462
472
|
return c.json({ ok: true, data: { deleted: true } });
|
|
463
473
|
});
|
|
464
|
-
return
|
|
474
|
+
return app7;
|
|
465
475
|
}
|
|
466
476
|
|
|
467
477
|
// src/server/routes/agents.ts
|
|
@@ -694,61 +704,65 @@ var decisions_default = app6;
|
|
|
694
704
|
// src/server/routes/costs.ts
|
|
695
705
|
var import_hono9 = require("hono");
|
|
696
706
|
function createCostRoutes(costAggregator) {
|
|
697
|
-
const
|
|
698
|
-
|
|
707
|
+
const app7 = new import_hono9.Hono();
|
|
708
|
+
app7.get("/costs", (c) => {
|
|
699
709
|
return c.json({ ok: true, data: costAggregator.getData() });
|
|
700
710
|
});
|
|
701
|
-
|
|
711
|
+
app7.post("/costs/reset", (c) => {
|
|
702
712
|
costAggregator.reset();
|
|
703
713
|
return c.json({ ok: true, data: { reset: true } });
|
|
704
714
|
});
|
|
705
|
-
return
|
|
715
|
+
return app7;
|
|
706
716
|
}
|
|
707
717
|
|
|
708
718
|
// src/server/routes/evals.ts
|
|
709
719
|
var import_hono10 = require("hono");
|
|
710
|
-
|
|
711
|
-
app7
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
720
|
+
function createEvalRoutes(evalLoader) {
|
|
721
|
+
const app7 = new import_hono10.Hono();
|
|
722
|
+
app7.get("/evals", async (c) => {
|
|
723
|
+
if (evalLoader) await evalLoader();
|
|
724
|
+
const runtime = c.get("runtime");
|
|
725
|
+
const evals = runtime.getRegisteredEvals();
|
|
726
|
+
return c.json({ ok: true, data: evals });
|
|
727
|
+
});
|
|
728
|
+
app7.post("/evals/:name/run", async (c) => {
|
|
729
|
+
if (evalLoader) await evalLoader();
|
|
730
|
+
const runtime = c.get("runtime");
|
|
731
|
+
const name = c.req.param("name");
|
|
732
|
+
const entry = runtime.getRegisteredEval(name);
|
|
733
|
+
if (!entry) {
|
|
734
|
+
return c.json(
|
|
735
|
+
{ ok: false, error: { code: "NOT_FOUND", message: `Eval "${name}" not found` } },
|
|
736
|
+
404
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
try {
|
|
740
|
+
const result = await runtime.runRegisteredEval(name);
|
|
741
|
+
return c.json({ ok: true, data: result });
|
|
742
|
+
} catch (err) {
|
|
743
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
744
|
+
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
app7.post("/evals/compare", async (c) => {
|
|
748
|
+
const runtime = c.get("runtime");
|
|
749
|
+
const body = await c.req.json();
|
|
750
|
+
try {
|
|
751
|
+
const result = await runtime.evalCompare(body.baseline, body.candidate);
|
|
752
|
+
return c.json({ ok: true, data: result });
|
|
753
|
+
} catch (err) {
|
|
754
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
755
|
+
return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
return app7;
|
|
759
|
+
}
|
|
746
760
|
|
|
747
761
|
// src/server/routes/playground.ts
|
|
748
762
|
var import_hono11 = require("hono");
|
|
749
763
|
function createPlaygroundRoutes(connMgr) {
|
|
750
|
-
const
|
|
751
|
-
|
|
764
|
+
const app7 = new import_hono11.Hono();
|
|
765
|
+
app7.post("/playground/chat", async (c) => {
|
|
752
766
|
const runtime = c.get("runtime");
|
|
753
767
|
const body = await c.req.json();
|
|
754
768
|
const workflowName = body.workflow ?? runtime.getWorkflowNames()[0];
|
|
@@ -779,20 +793,20 @@ function createPlaygroundRoutes(connMgr) {
|
|
|
779
793
|
data: { sessionId, executionId, streaming: true }
|
|
780
794
|
});
|
|
781
795
|
});
|
|
782
|
-
return
|
|
796
|
+
return app7;
|
|
783
797
|
}
|
|
784
798
|
|
|
785
799
|
// src/server/index.ts
|
|
786
800
|
function createServer(options) {
|
|
787
801
|
const { runtime, staticRoot, basePath = "", readOnly = false } = options;
|
|
788
|
-
const
|
|
802
|
+
const app7 = new import_hono12.Hono();
|
|
789
803
|
const connMgr = new ConnectionManager();
|
|
790
804
|
const costAggregator = new CostAggregator(connMgr);
|
|
791
805
|
if (options.cors !== false) {
|
|
792
|
-
|
|
806
|
+
app7.use("*", (0, import_cors.cors)());
|
|
793
807
|
}
|
|
794
|
-
|
|
795
|
-
|
|
808
|
+
app7.use("*", errorHandler);
|
|
809
|
+
app7.use("*", async (c, next) => {
|
|
796
810
|
c.set("runtime", runtime);
|
|
797
811
|
await next();
|
|
798
812
|
});
|
|
@@ -810,7 +824,7 @@ function createServer(options) {
|
|
|
810
824
|
"POST /api/evals",
|
|
811
825
|
"POST /api/playground"
|
|
812
826
|
];
|
|
813
|
-
|
|
827
|
+
app7.use("/api/*", async (c, next) => {
|
|
814
828
|
const apiIdx = c.req.path.indexOf("/api/");
|
|
815
829
|
const apiPath = apiIdx >= 0 ? c.req.path.slice(apiIdx) : c.req.path;
|
|
816
830
|
const key = `${c.req.method} ${apiPath}`;
|
|
@@ -836,9 +850,9 @@ function createServer(options) {
|
|
|
836
850
|
api.route("/", memory_default);
|
|
837
851
|
api.route("/", decisions_default);
|
|
838
852
|
api.route("/", createCostRoutes(costAggregator));
|
|
839
|
-
api.route("/",
|
|
853
|
+
api.route("/", createEvalRoutes(options.evalLoader));
|
|
840
854
|
api.route("/", createPlaygroundRoutes(connMgr));
|
|
841
|
-
|
|
855
|
+
app7.route("/api", api);
|
|
842
856
|
const traceListener = (event) => {
|
|
843
857
|
const traceEvent = event;
|
|
844
858
|
if (traceEvent.executionId) {
|
|
@@ -851,7 +865,7 @@ function createServer(options) {
|
|
|
851
865
|
};
|
|
852
866
|
runtime.on("trace", traceListener);
|
|
853
867
|
if (staticRoot) {
|
|
854
|
-
|
|
868
|
+
app7.use(
|
|
855
869
|
"/*",
|
|
856
870
|
(0, import_serve_static.serveStatic)({
|
|
857
871
|
root: staticRoot,
|
|
@@ -876,14 +890,14 @@ function createServer(options) {
|
|
|
876
890
|
"[axl-studio] Could not inject basePath into index.html \u2014 </head> tag not found. The SPA may not route correctly."
|
|
877
891
|
);
|
|
878
892
|
}
|
|
879
|
-
|
|
893
|
+
app7.get("*", (c) => c.html(injectedHtml));
|
|
880
894
|
}
|
|
881
895
|
} else {
|
|
882
|
-
|
|
896
|
+
app7.get("*", (0, import_serve_static.serveStatic)({ root: staticRoot, path: "/index.html" }));
|
|
883
897
|
}
|
|
884
898
|
}
|
|
885
899
|
return {
|
|
886
|
-
app:
|
|
900
|
+
app: app7,
|
|
887
901
|
connMgr,
|
|
888
902
|
costAggregator,
|
|
889
903
|
createWsHandlers: () => createWsHandlers(connMgr),
|
|
@@ -891,6 +905,175 @@ function createServer(options) {
|
|
|
891
905
|
};
|
|
892
906
|
}
|
|
893
907
|
|
|
908
|
+
// src/eval-loader.ts
|
|
909
|
+
var import_node_path2 = require("path");
|
|
910
|
+
var import_node_fs2 = require("fs");
|
|
911
|
+
var import_node_url = require("url");
|
|
912
|
+
function createEvalLoader(config, runtime, cwd) {
|
|
913
|
+
let loadPromise;
|
|
914
|
+
const { patterns, conditions } = normalizeConfig(config);
|
|
915
|
+
const baseCwd = cwd ?? process.cwd();
|
|
916
|
+
return () => {
|
|
917
|
+
if (!loadPromise) {
|
|
918
|
+
loadPromise = loadEvalFiles(patterns, conditions, baseCwd, runtime).catch((err) => {
|
|
919
|
+
loadPromise = void 0;
|
|
920
|
+
throw err;
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
return loadPromise;
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
async function loadEvalFiles(patterns, conditions, cwd, runtime) {
|
|
927
|
+
if (conditions.length > 0) {
|
|
928
|
+
await registerConditions(conditions);
|
|
929
|
+
}
|
|
930
|
+
const files = resolvePatterns(patterns, cwd);
|
|
931
|
+
if (files.length === 0) {
|
|
932
|
+
console.warn(`[axl-studio] No eval files found matching: ${patterns.join(", ")}`);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (files.some((f) => /\.[mc]?tsx?$/.test(f))) {
|
|
936
|
+
await ensureTsxLoader();
|
|
937
|
+
}
|
|
938
|
+
for (const file of files) {
|
|
939
|
+
try {
|
|
940
|
+
const mod = await import((0, import_node_url.pathToFileURL)(file).href);
|
|
941
|
+
const evalConfig = mod.default ?? mod.config ?? mod;
|
|
942
|
+
if (!evalConfig.workflow || !evalConfig.dataset || !evalConfig.scorers) {
|
|
943
|
+
console.warn(
|
|
944
|
+
`[axl-studio] Skipping ${file}: not a valid eval config (missing workflow, dataset, or scorers)`
|
|
945
|
+
);
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
const name = deriveEvalName(file, cwd);
|
|
949
|
+
if (runtime.getRegisteredEval(name)) {
|
|
950
|
+
console.warn(
|
|
951
|
+
`[axl-studio] Eval name "${name}" from ${file} collides with an already-registered eval \u2014 overwriting`
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
runtime.registerEval(name, evalConfig, mod.executeWorkflow);
|
|
955
|
+
} catch (err) {
|
|
956
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
957
|
+
console.warn(`[axl-studio] Failed to load eval ${file}: ${msg}`);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function normalizeConfig(config) {
|
|
962
|
+
if (typeof config === "string") {
|
|
963
|
+
return { patterns: [config], conditions: [] };
|
|
964
|
+
}
|
|
965
|
+
if (Array.isArray(config)) {
|
|
966
|
+
return { patterns: config, conditions: [] };
|
|
967
|
+
}
|
|
968
|
+
const files = typeof config.files === "string" ? [config.files] : config.files;
|
|
969
|
+
return { patterns: files, conditions: config.conditions ?? [] };
|
|
970
|
+
}
|
|
971
|
+
function deriveEvalName(filePath, cwd) {
|
|
972
|
+
const rel = (0, import_node_path2.relative)(cwd, filePath);
|
|
973
|
+
const normalized = rel.replace(/\\/g, "/");
|
|
974
|
+
if (normalized.startsWith("../")) {
|
|
975
|
+
const base = (0, import_node_path2.basename)(filePath);
|
|
976
|
+
const stripped = base.replace(/\.eval\.[mc]?[jt]sx?$/, "");
|
|
977
|
+
return stripped !== base ? stripped : base.replace(/\.[mc]?[jt]sx?$/, "") || base;
|
|
978
|
+
}
|
|
979
|
+
const withoutEval = normalized.replace(/\.eval\.[mc]?[jt]sx?$/, "");
|
|
980
|
+
if (withoutEval !== normalized) return withoutEval;
|
|
981
|
+
const withoutExt = normalized.replace(/\.[mc]?[jt]sx?$/, "");
|
|
982
|
+
return withoutExt || normalized;
|
|
983
|
+
}
|
|
984
|
+
function resolvePatterns(patterns, cwd) {
|
|
985
|
+
const files = [];
|
|
986
|
+
const seen = /* @__PURE__ */ new Set();
|
|
987
|
+
for (const pattern of patterns) {
|
|
988
|
+
const resolved = pattern.includes("*") ? expandGlob(pattern, cwd) : [(0, import_node_path2.resolve)(cwd, pattern)];
|
|
989
|
+
for (const file of resolved) {
|
|
990
|
+
if (!seen.has(file)) {
|
|
991
|
+
seen.add(file);
|
|
992
|
+
files.push(file);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return files;
|
|
997
|
+
}
|
|
998
|
+
function expandGlob(pattern, cwd) {
|
|
999
|
+
if (pattern.includes("**/")) {
|
|
1000
|
+
const sepIdx = pattern.indexOf("**/");
|
|
1001
|
+
const baseDir = (0, import_node_path2.resolve)(cwd, pattern.slice(0, sepIdx) || ".");
|
|
1002
|
+
const fileGlob2 = pattern.slice(sepIdx + 3) || "*";
|
|
1003
|
+
return findFiles(baseDir, fileGlob2, true);
|
|
1004
|
+
}
|
|
1005
|
+
const dir = (0, import_node_path2.resolve)(cwd, (0, import_node_path2.dirname)(pattern));
|
|
1006
|
+
const fileGlob = (0, import_node_path2.basename)(pattern);
|
|
1007
|
+
return findFiles(dir, fileGlob, false);
|
|
1008
|
+
}
|
|
1009
|
+
var MAX_DEPTH = 20;
|
|
1010
|
+
function findFiles(dir, fileGlob, recursive, depth = 0) {
|
|
1011
|
+
if (depth > MAX_DEPTH) return [];
|
|
1012
|
+
const matcher = globToRegex(fileGlob);
|
|
1013
|
+
const results = [];
|
|
1014
|
+
try {
|
|
1015
|
+
const entries = (0, import_node_fs2.readdirSync)(dir);
|
|
1016
|
+
for (const entry of entries) {
|
|
1017
|
+
const full = (0, import_node_path2.resolve)(dir, entry);
|
|
1018
|
+
try {
|
|
1019
|
+
const stat = (0, import_node_fs2.statSync)(full);
|
|
1020
|
+
if (stat.isFile() && matcher.test(entry)) {
|
|
1021
|
+
results.push(full);
|
|
1022
|
+
} else if (stat.isDirectory() && recursive) {
|
|
1023
|
+
results.push(...findFiles(full, fileGlob, true, depth + 1));
|
|
1024
|
+
}
|
|
1025
|
+
} catch {
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
} catch {
|
|
1029
|
+
}
|
|
1030
|
+
return results;
|
|
1031
|
+
}
|
|
1032
|
+
function globToRegex(glob) {
|
|
1033
|
+
const escaped = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
1034
|
+
return new RegExp(`^${escaped}$`);
|
|
1035
|
+
}
|
|
1036
|
+
var tsxRegistered = false;
|
|
1037
|
+
async function ensureTsxLoader() {
|
|
1038
|
+
if (tsxRegistered) return;
|
|
1039
|
+
tsxRegistered = true;
|
|
1040
|
+
let loaded = false;
|
|
1041
|
+
try {
|
|
1042
|
+
const tsxEsm = await import("tsx/esm/api");
|
|
1043
|
+
tsxEsm.register();
|
|
1044
|
+
loaded = true;
|
|
1045
|
+
} catch {
|
|
1046
|
+
}
|
|
1047
|
+
try {
|
|
1048
|
+
const tsxCjs = await import("tsx/cjs/api");
|
|
1049
|
+
tsxCjs.register();
|
|
1050
|
+
loaded = true;
|
|
1051
|
+
} catch {
|
|
1052
|
+
}
|
|
1053
|
+
if (!loaded) {
|
|
1054
|
+
console.warn(
|
|
1055
|
+
"[axl-studio] Warning: tsx is not installed. TypeScript eval files require tsx.\n Install it with: npm install -D tsx"
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
async function registerConditions(conditions) {
|
|
1060
|
+
try {
|
|
1061
|
+
const nodeModule = await import("module");
|
|
1062
|
+
const hookCode = [
|
|
1063
|
+
`const extra = ${JSON.stringify(conditions)};`,
|
|
1064
|
+
`export async function resolve(specifier, context, nextResolve) {`,
|
|
1065
|
+
` return nextResolve(specifier, {`,
|
|
1066
|
+
` ...context,`,
|
|
1067
|
+
` conditions: [...new Set([...context.conditions, ...extra])],`,
|
|
1068
|
+
` });`,
|
|
1069
|
+
`}`
|
|
1070
|
+
].join("\n");
|
|
1071
|
+
nodeModule.register(`data:text/javascript,${encodeURIComponent(hookCode)}`);
|
|
1072
|
+
} catch {
|
|
1073
|
+
console.warn("[axl-studio] Warning: import conditions require Node.js 20.6+");
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
894
1077
|
// src/middleware.ts
|
|
895
1078
|
var import_meta = {};
|
|
896
1079
|
function createStudioMiddleware(options) {
|
|
@@ -898,25 +1081,27 @@ function createStudioMiddleware(options) {
|
|
|
898
1081
|
const basePath = normalizeBasePath(options.basePath);
|
|
899
1082
|
const staticRoot = serveClient ? resolveClientDist() : void 0;
|
|
900
1083
|
if (serveClient && !staticRoot) {
|
|
901
|
-
const dir = import_meta.dirname ?? (0,
|
|
1084
|
+
const dir = import_meta.dirname ?? (0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta.url));
|
|
902
1085
|
console.warn(
|
|
903
|
-
`[axl-studio] serveClient is true but no pre-built client found at ${(0,
|
|
1086
|
+
`[axl-studio] serveClient is true but no pre-built client found at ${(0, import_node_path3.resolve)(dir, "client")}. Studio UI will not be available. Set serveClient: false to suppress this warning.`
|
|
904
1087
|
);
|
|
905
1088
|
}
|
|
906
|
-
const
|
|
1089
|
+
const evalLoader = options.evals ? createEvalLoader(options.evals, runtime) : void 0;
|
|
1090
|
+
const { app: app7, connMgr, traceListener } = createServer({
|
|
907
1091
|
runtime,
|
|
908
1092
|
staticRoot,
|
|
909
1093
|
basePath,
|
|
910
1094
|
readOnly,
|
|
911
|
-
cors: false
|
|
1095
|
+
cors: false,
|
|
912
1096
|
// Host framework owns CORS policy
|
|
1097
|
+
evalLoader
|
|
913
1098
|
});
|
|
914
1099
|
if (process.env.NODE_ENV === "production" && !verifyUpgrade) {
|
|
915
1100
|
console.warn(
|
|
916
1101
|
"[axl-studio] WARNING: Studio middleware mounted in production without verifyUpgrade. WebSocket connections are not authenticated. All registered workflows, tools, and agents are accessible. See https://axlsdk.com/docs/studio/security"
|
|
917
1102
|
);
|
|
918
1103
|
}
|
|
919
|
-
const listener = (0, import_node_server.getRequestListener)(
|
|
1104
|
+
const listener = (0, import_node_server.getRequestListener)(app7.fetch, {
|
|
920
1105
|
overrideGlobalObjects: false
|
|
921
1106
|
});
|
|
922
1107
|
let closed = false;
|
|
@@ -1020,7 +1205,7 @@ function createStudioMiddleware(options) {
|
|
|
1020
1205
|
handler,
|
|
1021
1206
|
handleWebSocket,
|
|
1022
1207
|
upgradeWebSocket,
|
|
1023
|
-
app:
|
|
1208
|
+
app: app7,
|
|
1024
1209
|
connectionManager: connMgr,
|
|
1025
1210
|
close
|
|
1026
1211
|
};
|
|
@@ -1046,9 +1231,9 @@ function normalizeBasePath(raw) {
|
|
|
1046
1231
|
return normalized;
|
|
1047
1232
|
}
|
|
1048
1233
|
function resolveClientDist() {
|
|
1049
|
-
const dir = import_meta.dirname ?? (0,
|
|
1050
|
-
const candidate = (0,
|
|
1051
|
-
return (0,
|
|
1234
|
+
const dir = import_meta.dirname ?? (0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta.url));
|
|
1235
|
+
const candidate = (0, import_node_path3.resolve)(dir, "client");
|
|
1236
|
+
return (0, import_node_fs3.existsSync)((0, import_node_path3.resolve)(candidate, "index.html")) ? candidate : void 0;
|
|
1052
1237
|
}
|
|
1053
1238
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1054
1239
|
0 && (module.exports = {
|