@axlsdk/studio 0.9.1 → 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.
@@ -1,4 +1,6 @@
1
1
  // src/server/index.ts
2
+ import { existsSync, readFileSync } from "fs";
3
+ import { resolve } from "path";
2
4
  import { Hono as Hono12 } from "hono";
3
5
  import { cors } from "hono/cors";
4
6
  import { serveStatic } from "@hono/node-server/serve-static";
@@ -35,8 +37,13 @@ var ConnectionManager = class {
35
37
  channels = /* @__PURE__ */ new Map();
36
38
  /** ws -> set of subscribed channels (for cleanup) */
37
39
  connections = /* @__PURE__ */ new Map();
40
+ maxConnections = 100;
38
41
  /** Register a new WS connection. */
39
42
  add(ws) {
43
+ if (this.connections.size >= this.maxConnections) {
44
+ ws.close?.();
45
+ return;
46
+ }
40
47
  this.connections.set(ws, /* @__PURE__ */ new Set());
41
48
  }
42
49
  /** Remove a WS connection and all its subscriptions. */
@@ -52,15 +59,16 @@ var ConnectionManager = class {
52
59
  }
53
60
  this.connections.delete(ws);
54
61
  }
55
- /** Subscribe a connection to a channel. */
62
+ /** Subscribe a connection to a channel. No-op if the connection was not added. */
56
63
  subscribe(ws, channel) {
64
+ if (!this.connections.has(ws)) return;
57
65
  let subs = this.channels.get(channel);
58
66
  if (!subs) {
59
67
  subs = /* @__PURE__ */ new Set();
60
68
  this.channels.set(channel, subs);
61
69
  }
62
70
  subs.add(ws);
63
- this.connections.get(ws)?.add(channel);
71
+ this.connections.get(ws).add(channel);
64
72
  }
65
73
  /** Unsubscribe a connection from a channel. */
66
74
  unsubscribe(ws, channel) {
@@ -101,6 +109,14 @@ var ConnectionManager = class {
101
109
  }
102
110
  }
103
111
  }
112
+ /** Close all connections and clear all state. Used during shutdown. */
113
+ closeAll() {
114
+ for (const ws of this.connections.keys()) {
115
+ ws.close?.();
116
+ }
117
+ this.connections.clear();
118
+ this.channels.clear();
119
+ }
104
120
  /** Get the number of active connections. */
105
121
  get connectionCount() {
106
122
  return this.connections.size;
@@ -111,6 +127,52 @@ var ConnectionManager = class {
111
127
  }
112
128
  };
113
129
 
130
+ // src/server/ws/protocol.ts
131
+ var VALID_CHANNEL_PREFIXES = ["execution:", "trace:"];
132
+ var VALID_EXACT_CHANNELS = ["costs", "decisions"];
133
+ var MAX_CHANNEL_LENGTH = 256;
134
+ function handleWsMessage(raw, socket, connMgr) {
135
+ if (raw.length > 65536) {
136
+ return JSON.stringify({ type: "error", message: "Message too large" });
137
+ }
138
+ let msg;
139
+ try {
140
+ msg = JSON.parse(raw);
141
+ } catch {
142
+ return JSON.stringify({ type: "error", message: "Invalid JSON" });
143
+ }
144
+ switch (msg.type) {
145
+ case "subscribe": {
146
+ const error = validateChannel(msg.channel);
147
+ if (error) return JSON.stringify({ type: "error", message: error });
148
+ connMgr.subscribe(socket, msg.channel);
149
+ return JSON.stringify({ type: "subscribed", channel: msg.channel });
150
+ }
151
+ case "unsubscribe": {
152
+ const error = validateChannel(msg.channel);
153
+ if (error) return JSON.stringify({ type: "error", message: error });
154
+ connMgr.unsubscribe(socket, msg.channel);
155
+ return JSON.stringify({ type: "unsubscribed", channel: msg.channel });
156
+ }
157
+ case "ping":
158
+ return JSON.stringify({ type: "pong" });
159
+ default:
160
+ return JSON.stringify({ type: "error", message: "Unknown message type" });
161
+ }
162
+ }
163
+ function validateChannel(channel) {
164
+ if (typeof channel !== "string" || !channel) {
165
+ return "Missing or invalid channel";
166
+ }
167
+ if (channel.length > MAX_CHANNEL_LENGTH) {
168
+ return `Channel name exceeds ${MAX_CHANNEL_LENGTH} characters`;
169
+ }
170
+ if (!VALID_EXACT_CHANNELS.includes(channel) && !VALID_CHANNEL_PREFIXES.some((p) => channel.startsWith(p))) {
171
+ return `Invalid channel: ${channel}`;
172
+ }
173
+ return null;
174
+ }
175
+
114
176
  // src/server/ws/handler.ts
115
177
  function createWsHandlers(connMgr) {
116
178
  return {
@@ -118,37 +180,8 @@ function createWsHandlers(connMgr) {
118
180
  connMgr.add(ws);
119
181
  },
120
182
  onMessage(event, ws) {
121
- let msg;
122
- try {
123
- msg = JSON.parse(String(event.data));
124
- } catch {
125
- const err = { type: "error", message: "Invalid JSON" };
126
- ws.send(JSON.stringify(err));
127
- return;
128
- }
129
- switch (msg.type) {
130
- case "subscribe": {
131
- connMgr.subscribe(ws, msg.channel);
132
- const reply = { type: "subscribed", channel: msg.channel };
133
- ws.send(JSON.stringify(reply));
134
- break;
135
- }
136
- case "unsubscribe": {
137
- connMgr.unsubscribe(ws, msg.channel);
138
- const reply = { type: "unsubscribed", channel: msg.channel };
139
- ws.send(JSON.stringify(reply));
140
- break;
141
- }
142
- case "ping": {
143
- const reply = { type: "pong" };
144
- ws.send(JSON.stringify(reply));
145
- break;
146
- }
147
- default: {
148
- const err = { type: "error", message: `Unknown message type` };
149
- ws.send(JSON.stringify(err));
150
- }
151
- }
183
+ const reply = handleWsMessage(String(event.data), ws, connMgr);
184
+ if (reply) ws.send(reply);
152
185
  },
153
186
  onClose(_event, ws) {
154
187
  connMgr.remove(ws);
@@ -243,8 +276,8 @@ var health_default = app;
243
276
  import { Hono as Hono2 } from "hono";
244
277
  import { zodToJsonSchema } from "@axlsdk/axl";
245
278
  function createWorkflowRoutes(connMgr) {
246
- const app8 = new Hono2();
247
- app8.get("/workflows", (c) => {
279
+ const app7 = new Hono2();
280
+ app7.get("/workflows", (c) => {
248
281
  const runtime = c.get("runtime");
249
282
  const workflows = runtime.getWorkflows().map((w) => ({
250
283
  name: w.name,
@@ -253,7 +286,7 @@ function createWorkflowRoutes(connMgr) {
253
286
  }));
254
287
  return c.json({ ok: true, data: workflows });
255
288
  });
256
- app8.get("/workflows/:name", (c) => {
289
+ app7.get("/workflows/:name", (c) => {
257
290
  const runtime = c.get("runtime");
258
291
  const name = c.req.param("name");
259
292
  const workflow = runtime.getWorkflow(name);
@@ -272,7 +305,7 @@ function createWorkflowRoutes(connMgr) {
272
305
  }
273
306
  });
274
307
  });
275
- app8.post("/workflows/:name/execute", async (c) => {
308
+ app7.post("/workflows/:name/execute", async (c) => {
276
309
  const runtime = c.get("runtime");
277
310
  const name = c.req.param("name");
278
311
  const workflow = runtime.getWorkflow(name);
@@ -303,7 +336,7 @@ function createWorkflowRoutes(connMgr) {
303
336
  const result = await runtime.execute(name, body.input ?? {}, { metadata: body.metadata });
304
337
  return c.json({ ok: true, data: { result } });
305
338
  });
306
- return app8;
339
+ return app7;
307
340
  }
308
341
 
309
342
  // src/server/routes/executions.ts
@@ -337,8 +370,8 @@ var executions_default = app2;
337
370
  // src/server/routes/sessions.ts
338
371
  import { Hono as Hono4 } from "hono";
339
372
  function createSessionRoutes(connMgr) {
340
- const app8 = new Hono4();
341
- app8.get("/sessions", async (c) => {
373
+ const app7 = new Hono4();
374
+ app7.get("/sessions", async (c) => {
342
375
  const runtime = c.get("runtime");
343
376
  const store = runtime.getStateStore();
344
377
  if (!store.listSessions) {
@@ -352,7 +385,7 @@ function createSessionRoutes(connMgr) {
352
385
  }
353
386
  return c.json({ ok: true, data: sessions });
354
387
  });
355
- app8.get("/sessions/:id", async (c) => {
388
+ app7.get("/sessions/:id", async (c) => {
356
389
  const runtime = c.get("runtime");
357
390
  const store = runtime.getStateStore();
358
391
  const id = c.req.param("id");
@@ -360,7 +393,7 @@ function createSessionRoutes(connMgr) {
360
393
  const handoffHistory = await store.getSessionMeta(id, "handoffHistory");
361
394
  return c.json({ ok: true, data: { id, history, handoffHistory: handoffHistory ?? [] } });
362
395
  });
363
- app8.post("/sessions/:id/send", async (c) => {
396
+ app7.post("/sessions/:id/send", async (c) => {
364
397
  const runtime = c.get("runtime");
365
398
  const id = c.req.param("id");
366
399
  const body = await c.req.json();
@@ -368,7 +401,7 @@ function createSessionRoutes(connMgr) {
368
401
  const result = await session.send(body.workflow, body.message);
369
402
  return c.json({ ok: true, data: { result } });
370
403
  });
371
- app8.post("/sessions/:id/stream", async (c) => {
404
+ app7.post("/sessions/:id/stream", async (c) => {
372
405
  const runtime = c.get("runtime");
373
406
  const id = c.req.param("id");
374
407
  const body = await c.req.json();
@@ -389,14 +422,14 @@ function createSessionRoutes(connMgr) {
389
422
  })();
390
423
  return c.json({ ok: true, data: { executionId, streaming: true } });
391
424
  });
392
- app8.delete("/sessions/:id", async (c) => {
425
+ app7.delete("/sessions/:id", async (c) => {
393
426
  const runtime = c.get("runtime");
394
427
  const store = runtime.getStateStore();
395
428
  const id = c.req.param("id");
396
429
  await store.deleteSession(id);
397
430
  return c.json({ ok: true, data: { deleted: true } });
398
431
  });
399
- return app8;
432
+ return app7;
400
433
  }
401
434
 
402
435
  // src/server/routes/agents.ts
@@ -629,61 +662,65 @@ var decisions_default = app6;
629
662
  // src/server/routes/costs.ts
630
663
  import { Hono as Hono9 } from "hono";
631
664
  function createCostRoutes(costAggregator) {
632
- const app8 = new Hono9();
633
- app8.get("/costs", (c) => {
665
+ const app7 = new Hono9();
666
+ app7.get("/costs", (c) => {
634
667
  return c.json({ ok: true, data: costAggregator.getData() });
635
668
  });
636
- app8.post("/costs/reset", (c) => {
669
+ app7.post("/costs/reset", (c) => {
637
670
  costAggregator.reset();
638
671
  return c.json({ ok: true, data: { reset: true } });
639
672
  });
640
- return app8;
673
+ return app7;
641
674
  }
642
675
 
643
676
  // src/server/routes/evals.ts
644
677
  import { Hono as Hono10 } from "hono";
645
- var app7 = new Hono10();
646
- app7.get("/evals", async (c) => {
647
- const runtime = c.get("runtime");
648
- const evals = runtime.getRegisteredEvals();
649
- return c.json({ ok: true, data: evals });
650
- });
651
- app7.post("/evals/:name/run", async (c) => {
652
- const runtime = c.get("runtime");
653
- const name = c.req.param("name");
654
- const entry = runtime.getRegisteredEval(name);
655
- if (!entry) {
656
- return c.json(
657
- { ok: false, error: { code: "NOT_FOUND", message: `Eval "${name}" not found` } },
658
- 404
659
- );
660
- }
661
- try {
662
- const result = await runtime.runRegisteredEval(name);
663
- return c.json({ ok: true, data: result });
664
- } catch (err) {
665
- const message = err instanceof Error ? err.message : String(err);
666
- return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
667
- }
668
- });
669
- app7.post("/evals/compare", async (c) => {
670
- const runtime = c.get("runtime");
671
- const body = await c.req.json();
672
- try {
673
- const result = await runtime.evalCompare(body.baseline, body.candidate);
674
- return c.json({ ok: true, data: result });
675
- } catch (err) {
676
- const message = err instanceof Error ? err.message : String(err);
677
- return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
678
- }
679
- });
680
- var evals_default = app7;
678
+ function createEvalRoutes(evalLoader) {
679
+ const app7 = new Hono10();
680
+ app7.get("/evals", async (c) => {
681
+ if (evalLoader) await evalLoader();
682
+ const runtime = c.get("runtime");
683
+ const evals = runtime.getRegisteredEvals();
684
+ return c.json({ ok: true, data: evals });
685
+ });
686
+ app7.post("/evals/:name/run", async (c) => {
687
+ if (evalLoader) await evalLoader();
688
+ const runtime = c.get("runtime");
689
+ const name = c.req.param("name");
690
+ const entry = runtime.getRegisteredEval(name);
691
+ if (!entry) {
692
+ return c.json(
693
+ { ok: false, error: { code: "NOT_FOUND", message: `Eval "${name}" not found` } },
694
+ 404
695
+ );
696
+ }
697
+ try {
698
+ const result = await runtime.runRegisteredEval(name);
699
+ return c.json({ ok: true, data: result });
700
+ } catch (err) {
701
+ const message = err instanceof Error ? err.message : String(err);
702
+ return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
703
+ }
704
+ });
705
+ app7.post("/evals/compare", async (c) => {
706
+ const runtime = c.get("runtime");
707
+ const body = await c.req.json();
708
+ try {
709
+ const result = await runtime.evalCompare(body.baseline, body.candidate);
710
+ return c.json({ ok: true, data: result });
711
+ } catch (err) {
712
+ const message = err instanceof Error ? err.message : String(err);
713
+ return c.json({ ok: false, error: { code: "EVAL_ERROR", message } }, 400);
714
+ }
715
+ });
716
+ return app7;
717
+ }
681
718
 
682
719
  // src/server/routes/playground.ts
683
720
  import { Hono as Hono11 } from "hono";
684
721
  function createPlaygroundRoutes(connMgr) {
685
- const app8 = new Hono11();
686
- app8.post("/playground/chat", async (c) => {
722
+ const app7 = new Hono11();
723
+ app7.post("/playground/chat", async (c) => {
687
724
  const runtime = c.get("runtime");
688
725
  const body = await c.req.json();
689
726
  const workflowName = body.workflow ?? runtime.getWorkflowNames()[0];
@@ -714,21 +751,53 @@ function createPlaygroundRoutes(connMgr) {
714
751
  data: { sessionId, executionId, streaming: true }
715
752
  });
716
753
  });
717
- return app8;
754
+ return app7;
718
755
  }
719
756
 
720
757
  // src/server/index.ts
721
758
  function createServer(options) {
722
- const { runtime, staticRoot } = options;
723
- const app8 = new Hono12();
759
+ const { runtime, staticRoot, basePath = "", readOnly = false } = options;
760
+ const app7 = new Hono12();
724
761
  const connMgr = new ConnectionManager();
725
762
  const costAggregator = new CostAggregator(connMgr);
726
- app8.use("*", cors());
727
- app8.use("*", errorHandler);
728
- app8.use("*", async (c, next) => {
763
+ if (options.cors !== false) {
764
+ app7.use("*", cors());
765
+ }
766
+ app7.use("*", errorHandler);
767
+ app7.use("*", async (c, next) => {
729
768
  c.set("runtime", runtime);
730
769
  await next();
731
770
  });
771
+ if (readOnly) {
772
+ const blocked = [
773
+ "POST /api/workflows",
774
+ "POST /api/executions",
775
+ "POST /api/sessions",
776
+ "DELETE /api/sessions",
777
+ "PUT /api/memory",
778
+ "DELETE /api/memory",
779
+ "POST /api/decisions",
780
+ "POST /api/costs",
781
+ "POST /api/tools",
782
+ "POST /api/evals",
783
+ "POST /api/playground"
784
+ ];
785
+ app7.use("/api/*", async (c, next) => {
786
+ const apiIdx = c.req.path.indexOf("/api/");
787
+ const apiPath = apiIdx >= 0 ? c.req.path.slice(apiIdx) : c.req.path;
788
+ const key = `${c.req.method} ${apiPath}`;
789
+ if (blocked.some((b) => key.startsWith(b))) {
790
+ return c.json(
791
+ {
792
+ ok: false,
793
+ error: { code: "READ_ONLY", message: "Studio is mounted in read-only mode" }
794
+ },
795
+ 405
796
+ );
797
+ }
798
+ await next();
799
+ });
800
+ }
732
801
  const api = new Hono12();
733
802
  api.route("/", health_default);
734
803
  api.route("/", createWorkflowRoutes(connMgr));
@@ -739,10 +808,10 @@ function createServer(options) {
739
808
  api.route("/", memory_default);
740
809
  api.route("/", decisions_default);
741
810
  api.route("/", createCostRoutes(costAggregator));
742
- api.route("/", evals_default);
811
+ api.route("/", createEvalRoutes(options.evalLoader));
743
812
  api.route("/", createPlaygroundRoutes(connMgr));
744
- app8.route("/api", api);
745
- runtime.on("trace", (event) => {
813
+ app7.route("/api", api);
814
+ const traceListener = (event) => {
746
815
  const traceEvent = event;
747
816
  if (traceEvent.executionId) {
748
817
  connMgr.broadcastWithWildcard(`trace:${traceEvent.executionId}`, traceEvent);
@@ -751,17 +820,53 @@ function createServer(options) {
751
820
  if (traceEvent.type === "await_human") {
752
821
  connMgr.broadcast("decisions", traceEvent);
753
822
  }
754
- });
823
+ };
824
+ runtime.on("trace", traceListener);
755
825
  if (staticRoot) {
756
- app8.use("/*", serveStatic({ root: staticRoot }));
757
- app8.get("*", serveStatic({ root: staticRoot, path: "/index.html" }));
826
+ app7.use(
827
+ "/*",
828
+ serveStatic({
829
+ root: staticRoot,
830
+ rewriteRequestPath: basePath ? (path) => path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path : void 0
831
+ })
832
+ );
833
+ if (basePath) {
834
+ const indexPath = resolve(staticRoot, "index.html");
835
+ if (!existsSync(indexPath)) {
836
+ console.warn(`[axl-studio] index.html not found at ${indexPath}`);
837
+ } else {
838
+ const indexHtml = readFileSync(indexPath, "utf-8");
839
+ const safeBasePath = JSON.stringify(basePath).replace(/</g, "\\u003c");
840
+ const injectedHtml = indexHtml.replace(
841
+ "</head>",
842
+ `<base href="${basePath}/">
843
+ <script>window.__AXL_STUDIO_BASE__=${safeBasePath}</script>
844
+ </head>`
845
+ );
846
+ if (injectedHtml === indexHtml) {
847
+ console.warn(
848
+ "[axl-studio] Could not inject basePath into index.html \u2014 </head> tag not found. The SPA may not route correctly."
849
+ );
850
+ }
851
+ app7.get("*", (c) => c.html(injectedHtml));
852
+ }
853
+ } else {
854
+ app7.get("*", serveStatic({ root: staticRoot, path: "/index.html" }));
855
+ }
758
856
  }
759
- return { app: app8, connMgr, costAggregator, createWsHandlers: () => createWsHandlers(connMgr) };
857
+ return {
858
+ app: app7,
859
+ connMgr,
860
+ costAggregator,
861
+ createWsHandlers: () => createWsHandlers(connMgr),
862
+ traceListener
863
+ };
760
864
  }
761
865
 
762
866
  export {
763
867
  ConnectionManager,
868
+ handleWsMessage,
764
869
  CostAggregator,
765
870
  createServer
766
871
  };
767
- //# sourceMappingURL=chunk-EG74VI3M.js.map
872
+ //# sourceMappingURL=chunk-GKIPF45K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/index.ts","../src/server/middleware/error-handler.ts","../src/server/ws/connection-manager.ts","../src/server/ws/protocol.ts","../src/server/ws/handler.ts","../src/server/cost-aggregator.ts","../src/server/routes/health.ts","../src/server/routes/workflows.ts","../src/server/routes/executions.ts","../src/server/routes/sessions.ts","../src/server/routes/agents.ts","../src/server/routes/tools.ts","../src/server/routes/memory.ts","../src/server/routes/decisions.ts","../src/server/routes/costs.ts","../src/server/routes/evals.ts","../src/server/routes/playground.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { Hono } from 'hono';\nimport { cors } from 'hono/cors';\nimport { serveStatic } from '@hono/node-server/serve-static';\nimport type { AxlRuntime } from '@axlsdk/axl';\nimport type { StudioEnv } from './types.js';\nimport { errorHandler } from './middleware/error-handler.js';\nimport { ConnectionManager } from './ws/connection-manager.js';\nimport { createWsHandlers } from './ws/handler.js';\nimport { CostAggregator } from './cost-aggregator.js';\nimport healthRoutes from './routes/health.js';\nimport { createWorkflowRoutes } from './routes/workflows.js';\nimport executionRoutes from './routes/executions.js';\nimport { createSessionRoutes } from './routes/sessions.js';\nimport agentRoutes from './routes/agents.js';\nimport toolRoutes from './routes/tools.js';\nimport memoryRoutes from './routes/memory.js';\nimport decisionRoutes from './routes/decisions.js';\nimport { createCostRoutes } from './routes/costs.js';\nimport { createEvalRoutes } from './routes/evals.js';\nimport { createPlaygroundRoutes } from './routes/playground.js';\n\nexport type { StudioEnv } from './types.js';\nexport { ConnectionManager } from './ws/connection-manager.js';\nexport type { BroadcastTarget } from './ws/connection-manager.js';\nexport { CostAggregator } from './cost-aggregator.js';\n\nexport type CreateServerOptions = {\n runtime: AxlRuntime;\n /** Root path for serving pre-built SPA static assets. */\n staticRoot?: string;\n /** Base URL path for client-side routing and API calls. Injected into index.html at serve time. */\n basePath?: string;\n /** When true, disable all mutating API endpoints. */\n readOnly?: boolean;\n /** Apply CORS headers. Default: true (standalone CLI). Set false for embedded middleware. */\n cors?: boolean;\n /** Lazy eval file loader. Called before eval routes access the runtime's registered evals. */\n evalLoader?: () => Promise<void>;\n};\n\nexport function createServer(options: CreateServerOptions) {\n const { runtime, staticRoot, basePath = '', readOnly = false } = options;\n const app = new Hono<StudioEnv>();\n const connMgr = new ConnectionManager();\n const costAggregator = new CostAggregator(connMgr);\n\n // ── Middleware ──────────────────────────────────────────────────────\n if (options.cors !== false) {\n app.use('*', cors());\n }\n app.use('*', errorHandler);\n app.use('*', async (c, next) => {\n c.set('runtime', runtime);\n await next();\n });\n\n // ── Read-only mode ──────────────────────────────────────────────────\n if (readOnly) {\n const blocked = [\n 'POST /api/workflows',\n 'POST /api/executions',\n 'POST /api/sessions',\n 'DELETE /api/sessions',\n 'PUT /api/memory',\n 'DELETE /api/memory',\n 'POST /api/decisions',\n 'POST /api/costs',\n 'POST /api/tools',\n 'POST /api/evals',\n 'POST /api/playground',\n ];\n app.use('/api/*', async (c, next) => {\n // c.req.path returns the full path including any parent route prefix\n // (e.g., /studio/api/workflows when mounted via app.route('/studio', ...)).\n // Extract just the /api/... portion for matching.\n const apiIdx = c.req.path.indexOf('/api/');\n const apiPath = apiIdx >= 0 ? c.req.path.slice(apiIdx) : c.req.path;\n const key = `${c.req.method} ${apiPath}`;\n if (blocked.some((b) => key.startsWith(b))) {\n return c.json(\n {\n ok: false,\n error: { code: 'READ_ONLY', message: 'Studio is mounted in read-only mode' },\n },\n 405,\n );\n }\n await next();\n });\n }\n\n // ── API Routes ─────────────────────────────────────────────────────\n const api = new Hono<StudioEnv>();\n api.route('/', healthRoutes);\n api.route('/', createWorkflowRoutes(connMgr));\n api.route('/', executionRoutes);\n api.route('/', createSessionRoutes(connMgr));\n api.route('/', agentRoutes);\n api.route('/', toolRoutes);\n api.route('/', memoryRoutes);\n api.route('/', decisionRoutes);\n api.route('/', createCostRoutes(costAggregator));\n api.route('/', createEvalRoutes(options.evalLoader));\n api.route('/', createPlaygroundRoutes(connMgr));\n\n app.route('/api', api);\n\n // ── Trace event bridging ───────────────────────────────────────────\n const traceListener = (event: unknown) => {\n const traceEvent = event as {\n executionId?: string;\n type?: string;\n agent?: string;\n model?: string;\n workflow?: string;\n cost?: number;\n tokens?: { input?: number; output?: number; reasoning?: number };\n };\n\n // Broadcast to trace channels\n if (traceEvent.executionId) {\n connMgr.broadcastWithWildcard(`trace:${traceEvent.executionId}`, traceEvent);\n }\n\n // Feed cost aggregator\n costAggregator.onTrace(traceEvent);\n\n // Broadcast pending decisions\n if (traceEvent.type === 'await_human') {\n connMgr.broadcast('decisions', traceEvent);\n }\n };\n runtime.on('trace', traceListener);\n\n // ── Static SPA serving (production) ────────────────────────────────\n if (staticRoot) {\n // Serve static assets (JS, CSS, images).\n // When basePath is set and this app is mounted via Hono's app.route(),\n // c.req.path may include the full prefix. rewriteRequestPath strips it\n // so serveStatic resolves files relative to staticRoot correctly.\n app.use(\n '/*',\n serveStatic({\n root: staticRoot,\n rewriteRequestPath: basePath\n ? (path) => (path.startsWith(basePath) ? path.slice(basePath.length) || '/' : path)\n : undefined,\n }),\n );\n\n if (basePath) {\n // Read and inject base path into index.html at startup (not per-request).\n const indexPath = resolve(staticRoot, 'index.html');\n if (!existsSync(indexPath)) {\n console.warn(`[axl-studio] index.html not found at ${indexPath}`);\n } else {\n const indexHtml = readFileSync(indexPath, 'utf-8');\n\n // Escape all '<' as '\\u003c' to prevent </script> in basePath from\n // breaking out of the script tag. JSON.stringify alone is insufficient\n // because the HTML parser processes </script> before JavaScript runs.\n const safeBasePath = JSON.stringify(basePath).replace(/</g, '\\\\u003c');\n\n // Inject both:\n // 1. <base> tag so relative asset paths (./assets/main.js) resolve\n // correctly regardless of trailing slash on the mount URL.\n // 2. Runtime config script for React Router, API client, and WS client.\n const injectedHtml = indexHtml.replace(\n '</head>',\n `<base href=\"${basePath}/\">\\n` +\n `<script>window.__AXL_STUDIO_BASE__=${safeBasePath}</script>\\n</head>`,\n );\n\n if (injectedHtml === indexHtml) {\n console.warn(\n '[axl-studio] Could not inject basePath into index.html — ' +\n '</head> tag not found. The SPA may not route correctly.',\n );\n }\n\n app.get('*', (c) => c.html(injectedHtml));\n }\n } else {\n // SPA fallback: serve index.html for non-API, non-WS routes\n app.get('*', serveStatic({ root: staticRoot, path: '/index.html' }));\n }\n }\n\n return {\n app,\n connMgr,\n costAggregator,\n createWsHandlers: () => createWsHandlers(connMgr),\n traceListener,\n };\n}\n","import type { Context, Next } from 'hono';\nimport type { StudioEnv, ApiError } from '../types.js';\n\nexport async function errorHandler(c: Context<StudioEnv>, next: Next) {\n try {\n await next();\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n const code = (err as { code?: string }).code ?? 'INTERNAL_ERROR';\n\n // Determine HTTP status from error properties\n let status = 500;\n if ('status' in (err as object)) {\n const errStatus = (err as { status: unknown }).status;\n if (typeof errStatus === 'number' && errStatus >= 400 && errStatus < 600) {\n status = errStatus;\n }\n } else if (\n code === 'NOT_FOUND' ||\n message.includes('not found') ||\n message.includes('not registered')\n ) {\n status = 404;\n } else if (\n code === 'VALIDATION_ERROR' ||\n message.includes('Expected') ||\n message.includes('invalid')\n ) {\n status = 400;\n }\n\n const body: ApiError = {\n ok: false,\n error: { code, message },\n };\n\n return c.json(body, status as 400 | 404 | 500);\n }\n}\n","/**\n * Minimal interface for a connection that can receive broadcast messages.\n * Satisfied by WSContext (Hono), ws.WebSocket (Node.js), and the middleware's\n * adapted socket. Internal to ConnectionManager — not part of the public API.\n */\nexport interface BroadcastTarget {\n send(data: string): void;\n close?(): void;\n}\n\n/**\n * Manages WebSocket connections and channel subscriptions.\n * Supports channel multiplexing: clients subscribe/unsubscribe to channels\n * and receive events only for channels they're subscribed to.\n */\nexport class ConnectionManager {\n /** channel -> set of WS connections */\n private channels = new Map<string, Set<BroadcastTarget>>();\n /** ws -> set of subscribed channels (for cleanup) */\n private connections = new Map<BroadcastTarget, Set<string>>();\n private maxConnections = 100;\n\n /** Register a new WS connection. */\n add(ws: BroadcastTarget): void {\n if (this.connections.size >= this.maxConnections) {\n ws.close?.();\n return;\n }\n this.connections.set(ws, new Set());\n }\n\n /** Remove a WS connection and all its subscriptions. */\n remove(ws: BroadcastTarget): void {\n const channels = this.connections.get(ws);\n if (channels) {\n for (const ch of channels) {\n this.channels.get(ch)?.delete(ws);\n if (this.channels.get(ch)?.size === 0) {\n this.channels.delete(ch);\n }\n }\n }\n this.connections.delete(ws);\n }\n\n /** Subscribe a connection to a channel. No-op if the connection was not added. */\n subscribe(ws: BroadcastTarget, channel: string): void {\n if (!this.connections.has(ws)) return;\n let subs = this.channels.get(channel);\n if (!subs) {\n subs = new Set();\n this.channels.set(channel, subs);\n }\n subs.add(ws);\n this.connections.get(ws)!.add(channel);\n }\n\n /** Unsubscribe a connection from a channel. */\n unsubscribe(ws: BroadcastTarget, channel: string): void {\n this.channels.get(channel)?.delete(ws);\n if (this.channels.get(channel)?.size === 0) {\n this.channels.delete(channel);\n }\n this.connections.get(ws)?.delete(channel);\n }\n\n /** Broadcast data to all subscribers of a channel. */\n broadcast(channel: string, data: unknown): void {\n const subs = this.channels.get(channel);\n if (!subs || subs.size === 0) return;\n\n const msg = JSON.stringify({ type: 'event', channel, data });\n for (const ws of [...subs]) {\n try {\n ws.send(msg);\n } catch {\n // Connection closed — clean up\n this.remove(ws);\n }\n }\n }\n\n /** Broadcast to channel and all wildcard subscribers (e.g., trace:* matches trace:abc). */\n broadcastWithWildcard(channel: string, data: unknown): void {\n this.broadcast(channel, data);\n\n // Check for wildcard subscribers: \"prefix:*\" matches \"prefix:anything\"\n // Send with the actual channel name so wildcard subscribers know the source.\n const colonIdx = channel.indexOf(':');\n if (colonIdx > 0) {\n const wildcardChannel = channel.substring(0, colonIdx) + ':*';\n const subs = this.channels.get(wildcardChannel);\n if (!subs || subs.size === 0) return;\n\n const msg = JSON.stringify({ type: 'event', channel, data });\n for (const ws of [...subs]) {\n try {\n ws.send(msg);\n } catch {\n this.remove(ws);\n }\n }\n }\n }\n\n /** Close all connections and clear all state. Used during shutdown. */\n closeAll(): void {\n for (const ws of this.connections.keys()) {\n ws.close?.();\n }\n this.connections.clear();\n this.channels.clear();\n }\n\n /** Get the number of active connections. */\n get connectionCount(): number {\n return this.connections.size;\n }\n\n /** Check if any connections are subscribed to a channel. */\n hasSubscribers(channel: string): boolean {\n return (this.channels.get(channel)?.size ?? 0) > 0;\n }\n}\n","import type { BroadcastTarget } from './connection-manager.js';\nimport type { ConnectionManager } from './connection-manager.js';\n\n/** Channel prefixes that accept suffixes (e.g., execution:abc, trace:*). */\nconst VALID_CHANNEL_PREFIXES = ['execution:', 'trace:'];\n/** Channels that must match exactly (no suffix allowed). */\nconst VALID_EXACT_CHANNELS = ['costs', 'decisions'];\nconst MAX_CHANNEL_LENGTH = 256;\n\n/**\n * Handle a single WebSocket message according to the Studio protocol.\n * Returns a JSON string to send back to the client, or null for no response.\n *\n * Used by both the Hono WS handler (ws/handler.ts) and the Node.js\n * middleware (middleware.ts) to keep the protocol in one place.\n */\nexport function handleWsMessage(\n raw: string,\n socket: BroadcastTarget,\n connMgr: ConnectionManager,\n): string | null {\n // Reject oversized messages (64KB limit)\n if (raw.length > 65536) {\n return JSON.stringify({ type: 'error', message: 'Message too large' });\n }\n\n let msg: { type: string; channel?: string };\n try {\n msg = JSON.parse(raw);\n } catch {\n return JSON.stringify({ type: 'error', message: 'Invalid JSON' });\n }\n\n switch (msg.type) {\n case 'subscribe': {\n const error = validateChannel(msg.channel);\n if (error) return JSON.stringify({ type: 'error', message: error });\n connMgr.subscribe(socket, msg.channel!);\n return JSON.stringify({ type: 'subscribed', channel: msg.channel });\n }\n case 'unsubscribe': {\n const error = validateChannel(msg.channel);\n if (error) return JSON.stringify({ type: 'error', message: error });\n connMgr.unsubscribe(socket, msg.channel!);\n return JSON.stringify({ type: 'unsubscribed', channel: msg.channel });\n }\n case 'ping':\n return JSON.stringify({ type: 'pong' });\n default:\n return JSON.stringify({ type: 'error', message: 'Unknown message type' });\n }\n}\n\nfunction validateChannel(channel: unknown): string | null {\n if (typeof channel !== 'string' || !channel) {\n return 'Missing or invalid channel';\n }\n if (channel.length > MAX_CHANNEL_LENGTH) {\n return `Channel name exceeds ${MAX_CHANNEL_LENGTH} characters`;\n }\n if (\n !VALID_EXACT_CHANNELS.includes(channel as (typeof VALID_EXACT_CHANNELS)[number]) &&\n !VALID_CHANNEL_PREFIXES.some((p) => channel.startsWith(p))\n ) {\n return `Invalid channel: ${channel}`;\n }\n return null;\n}\n","import type { WSContext } from 'hono/ws';\nimport type { ConnectionManager } from './connection-manager.js';\nimport { handleWsMessage } from './protocol.js';\n\n/** Create WS event handlers for a Hono WebSocket connection. */\nexport function createWsHandlers(connMgr: ConnectionManager) {\n return {\n onOpen(_event: Event, ws: WSContext) {\n connMgr.add(ws);\n },\n\n onMessage(event: MessageEvent, ws: WSContext) {\n const reply = handleWsMessage(String(event.data), ws, connMgr);\n if (reply) ws.send(reply);\n },\n\n onClose(_event: CloseEvent, ws: WSContext) {\n connMgr.remove(ws);\n },\n\n onError(_event: Event, ws: WSContext) {\n connMgr.remove(ws);\n },\n };\n}\n","import type { CostData } from './types.js';\nimport type { ConnectionManager } from './ws/connection-manager.js';\n\n/**\n * Accumulates cost data from trace events.\n * Broadcasts updates to the 'costs' WS channel.\n */\nexport class CostAggregator {\n private data: CostData = {\n totalCost: 0,\n totalTokens: { input: 0, output: 0, reasoning: 0 },\n byAgent: {},\n byModel: {},\n byWorkflow: {},\n };\n\n constructor(private connMgr: ConnectionManager) {}\n\n /** Process a trace event and update cost data. */\n onTrace(event: {\n type?: string;\n agent?: string;\n model?: string;\n workflow?: string;\n cost?: number;\n tokens?: { input?: number; output?: number; reasoning?: number };\n }): void {\n if (!event.cost && !event.tokens) return;\n\n const cost = event.cost ?? 0;\n const tokens = event.tokens ?? {};\n\n this.data.totalCost += cost;\n this.data.totalTokens.input += tokens.input ?? 0;\n this.data.totalTokens.output += tokens.output ?? 0;\n this.data.totalTokens.reasoning += tokens.reasoning ?? 0;\n\n if (event.agent) {\n const entry = this.data.byAgent[event.agent] ?? { cost: 0, calls: 0 };\n entry.cost += cost;\n entry.calls += 1;\n this.data.byAgent[event.agent] = entry;\n }\n\n if (event.model) {\n const entry = this.data.byModel[event.model] ?? {\n cost: 0,\n calls: 0,\n tokens: { input: 0, output: 0 },\n };\n entry.cost += cost;\n entry.calls += 1;\n entry.tokens.input += tokens.input ?? 0;\n entry.tokens.output += tokens.output ?? 0;\n this.data.byModel[event.model] = entry;\n }\n\n if (event.workflow) {\n const entry = this.data.byWorkflow[event.workflow] ?? { cost: 0, executions: 0 };\n entry.cost += cost;\n if (event.type === 'workflow_start') entry.executions += 1;\n this.data.byWorkflow[event.workflow] = entry;\n }\n\n // Broadcast to WS subscribers\n this.connMgr.broadcast('costs', this.data);\n }\n\n /** Get current aggregated cost data. */\n getData(): CostData {\n return this.data;\n }\n\n /** Reset all accumulated data. */\n reset(): void {\n this.data = {\n totalCost: 0,\n totalTokens: { input: 0, output: 0, reasoning: 0 },\n byAgent: {},\n byModel: {},\n byWorkflow: {},\n };\n }\n}\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\napp.get('/health', (c) => {\n const runtime = c.get('runtime');\n return c.json({\n ok: true,\n data: {\n status: 'healthy',\n workflows: runtime.getWorkflowNames().length,\n agents: runtime.getAgents().length,\n tools: runtime.getTools().length,\n },\n });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport { zodToJsonSchema } from '@axlsdk/axl';\nimport type { StudioEnv, WorkflowSummary } from '../types.js';\nimport type { ConnectionManager } from '../ws/connection-manager.js';\n\nexport function createWorkflowRoutes(connMgr: ConnectionManager) {\n const app = new Hono<StudioEnv>();\n\n // List all workflows\n app.get('/workflows', (c) => {\n const runtime = c.get('runtime');\n const workflows: WorkflowSummary[] = runtime.getWorkflows().map((w) => ({\n name: w.name,\n hasInputSchema: !!w.inputSchema,\n hasOutputSchema: !!w.outputSchema,\n }));\n return c.json({ ok: true, data: workflows });\n });\n\n // Get workflow detail (including schemas)\n app.get('/workflows/:name', (c) => {\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n const workflow = runtime.getWorkflow(name);\n if (!workflow) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Workflow \"${name}\" not found` } },\n 404,\n );\n }\n\n return c.json({\n ok: true,\n data: {\n name: workflow.name,\n inputSchema: workflow.inputSchema ? zodToJsonSchema(workflow.inputSchema) : null,\n outputSchema: workflow.outputSchema ? zodToJsonSchema(workflow.outputSchema) : null,\n },\n });\n });\n\n // Execute a workflow\n app.post('/workflows/:name/execute', async (c) => {\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n\n const workflow = runtime.getWorkflow(name);\n if (!workflow) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Workflow \"${name}\" not found` } },\n 404,\n );\n }\n\n const body = await c.req.json<{\n input?: unknown;\n stream?: boolean;\n metadata?: Record<string, unknown>;\n }>();\n\n if (body.stream) {\n // Streaming execution — pipe events to WS channel\n const stream = runtime.stream(name, body.input ?? {}, { metadata: body.metadata });\n const executionId = `stream-${Date.now()}`;\n\n // Forward stream events to WS\n (async () => {\n try {\n for await (const event of stream) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, event);\n }\n } catch (err) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, {\n type: 'error',\n message: err instanceof Error ? err.message : 'Stream error',\n });\n }\n })();\n\n return c.json({ ok: true, data: { executionId, streaming: true } });\n }\n\n const result = await runtime.execute(name, body.input ?? {}, { metadata: body.metadata });\n return c.json({ ok: true, data: { result } });\n });\n\n return app;\n}\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\n// List all executions\napp.get('/executions', (c) => {\n const runtime = c.get('runtime');\n const executions = runtime.getExecutions();\n return c.json({ ok: true, data: executions });\n});\n\n// Get execution by ID\napp.get('/executions/:id', async (c) => {\n const runtime = c.get('runtime');\n const id = c.req.param('id');\n const execution = await runtime.getExecution(id);\n if (!execution) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Execution \"${id}\" not found` } },\n 404,\n );\n }\n return c.json({ ok: true, data: execution });\n});\n\n// Abort a running execution\napp.post('/executions/:id/abort', (c) => {\n const runtime = c.get('runtime');\n const id = c.req.param('id');\n runtime.abort(id);\n return c.json({ ok: true, data: { aborted: true } });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport type { StudioEnv, SessionSummary } from '../types.js';\nimport type { ConnectionManager } from '../ws/connection-manager.js';\n\nexport function createSessionRoutes(connMgr: ConnectionManager) {\n const app = new Hono<StudioEnv>();\n\n // List all sessions\n app.get('/sessions', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n if (!store.listSessions) {\n return c.json({ ok: true, data: [] });\n }\n const ids = await store.listSessions();\n const sessions: SessionSummary[] = [];\n for (const id of ids) {\n const history = await store.getSession(id);\n sessions.push({ id, messageCount: history.length });\n }\n return c.json({ ok: true, data: sessions });\n });\n\n // Get session history\n app.get('/sessions/:id', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const id = c.req.param('id');\n const history = await store.getSession(id);\n const handoffHistory = await store.getSessionMeta(id, 'handoffHistory');\n return c.json({ ok: true, data: { id, history, handoffHistory: handoffHistory ?? [] } });\n });\n\n // Send message to session (non-streaming)\n app.post('/sessions/:id/send', async (c) => {\n const runtime = c.get('runtime');\n const id = c.req.param('id');\n const body = await c.req.json<{ message: string; workflow: string }>();\n\n const session = runtime.session(id);\n const result = await session.send(body.workflow, body.message);\n return c.json({ ok: true, data: { result } });\n });\n\n // Stream session message\n app.post('/sessions/:id/stream', async (c) => {\n const runtime = c.get('runtime');\n const id = c.req.param('id');\n const body = await c.req.json<{ message: string; workflow: string }>();\n\n const session = runtime.session(id);\n const stream = await session.stream(body.workflow, body.message);\n const executionId = `session-${id}-${Date.now()}`;\n\n // Forward stream events to WS\n (async () => {\n try {\n for await (const event of stream) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, event);\n }\n } catch (err) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, {\n type: 'error',\n message: err instanceof Error ? err.message : 'Stream error',\n });\n }\n })();\n\n return c.json({ ok: true, data: { executionId, streaming: true } });\n });\n\n // Delete session\n app.delete('/sessions/:id', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const id = c.req.param('id');\n await store.deleteSession(id);\n return c.json({ ok: true, data: { deleted: true } });\n });\n\n return app;\n}\n","import { Hono } from 'hono';\nimport { zodToJsonSchema } from '@axlsdk/axl';\nimport type { StudioEnv, AgentSummary } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\n// List all agents\napp.get('/agents', (c) => {\n const runtime = c.get('runtime');\n const agents: AgentSummary[] = runtime.getAgents().map((a) => ({\n name: a._name,\n model: a.resolveModel(),\n system: a.resolveSystem(),\n tools: a._config.tools?.map((t) => t.name) ?? [],\n handoffs:\n typeof a._config.handoffs === 'function'\n ? ['(dynamic)']\n : (a._config.handoffs?.map((h) => h.agent._name) ?? []),\n maxTurns: a._config.maxTurns,\n temperature: a._config.temperature,\n maxTokens: a._config.maxTokens,\n effort: a._config.effort,\n thinkingBudget: a._config.thinkingBudget,\n includeThoughts: a._config.includeThoughts,\n toolChoice: a._config.toolChoice,\n stop: a._config.stop,\n }));\n return c.json({ ok: true, data: agents });\n});\n\n// Get agent detail\napp.get('/agents/:name', (c) => {\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n const agent = runtime.getAgent(name);\n if (!agent) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Agent \"${name}\" not found` } },\n 404,\n );\n }\n\n const cfg = agent._config;\n return c.json({\n ok: true,\n data: {\n name: agent._name,\n model: agent.resolveModel(),\n system: agent.resolveSystem(),\n tools:\n cfg.tools?.map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: zodToJsonSchema(t.inputSchema),\n })) ?? [],\n handoffs:\n typeof cfg.handoffs === 'function'\n ? [\n {\n agent: '(dynamic)',\n description: 'Resolved at runtime from metadata',\n mode: 'oneway' as const,\n },\n ]\n : (cfg.handoffs?.map((h) => ({\n agent: h.agent._name,\n description: h.description,\n mode: h.mode ?? 'oneway',\n })) ?? []),\n maxTurns: cfg.maxTurns,\n temperature: cfg.temperature,\n maxTokens: cfg.maxTokens,\n effort: cfg.effort,\n thinkingBudget: cfg.thinkingBudget,\n includeThoughts: cfg.includeThoughts,\n toolChoice: cfg.toolChoice,\n stop: cfg.stop,\n timeout: cfg.timeout,\n maxContext: cfg.maxContext,\n version: cfg.version,\n mcp: cfg.mcp,\n mcpTools: cfg.mcpTools,\n hasGuardrails: !!cfg.guardrails,\n guardrails: cfg.guardrails\n ? {\n hasInput: !!cfg.guardrails.input,\n hasOutput: !!cfg.guardrails.output,\n onBlock: cfg.guardrails.onBlock ?? 'throw',\n maxRetries: cfg.guardrails.maxRetries,\n }\n : null,\n },\n });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport { zodToJsonSchema } from '@axlsdk/axl';\nimport type { StudioEnv, ToolSummary } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\n// List all tools\napp.get('/tools', (c) => {\n const runtime = c.get('runtime');\n const tools: ToolSummary[] = runtime.getTools().map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: t.inputSchema ? zodToJsonSchema(t.inputSchema) : {},\n sensitive: t.sensitive ?? false,\n requireApproval: t.requireApproval ?? false,\n }));\n return c.json({ ok: true, data: tools });\n});\n\n// Get tool detail\napp.get('/tools/:name', (c) => {\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n const tool = runtime.getTool(name);\n if (!tool) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Tool \"${name}\" not found` } },\n 404,\n );\n }\n\n return c.json({\n ok: true,\n data: {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema) : {},\n sensitive: tool.sensitive,\n requireApproval: tool.requireApproval,\n retry: tool.retry,\n hasHooks: !!tool.hooks,\n hooks: tool.hooks\n ? {\n hasBefore: !!tool.hooks.before,\n hasAfter: !!tool.hooks.after,\n }\n : null,\n },\n });\n});\n\n// Test a tool directly\napp.post('/tools/:name/test', async (c) => {\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n const tool = runtime.getTool(name);\n if (!tool) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Tool \"${name}\" not found` } },\n 404,\n );\n }\n\n const body = await c.req.json<{ input: unknown }>();\n const ctx = runtime.createContext();\n const result = await tool.run(ctx, body.input);\n return c.json({ ok: true, data: { result } });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\n// Get all memory entries for a scope\napp.get('/memory/:scope', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const scope = c.req.param('scope');\n\n if (!store.getAllMemory) {\n return c.json({ ok: true, data: [] });\n }\n\n const entries = await store.getAllMemory(scope);\n return c.json({ ok: true, data: entries });\n});\n\n// Get a specific memory entry\napp.get('/memory/:scope/:key', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const scope = c.req.param('scope');\n const key = c.req.param('key');\n\n if (!store.getMemory) {\n return c.json(\n { ok: false, error: { code: 'NOT_SUPPORTED', message: 'Memory not supported' } },\n 501,\n );\n }\n\n const value = await store.getMemory(scope, key);\n if (value === null) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Memory \"${scope}/${key}\" not found` } },\n 404,\n );\n }\n\n return c.json({ ok: true, data: { key, value } });\n});\n\n// Save a memory entry\napp.put('/memory/:scope/:key', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const scope = c.req.param('scope');\n const key = c.req.param('key');\n\n if (!store.saveMemory) {\n return c.json(\n { ok: false, error: { code: 'NOT_SUPPORTED', message: 'Memory not supported' } },\n 501,\n );\n }\n\n const body = await c.req.json<{ value: unknown }>();\n await store.saveMemory(scope, key, body.value);\n return c.json({ ok: true, data: { saved: true } });\n});\n\n// Delete a memory entry\napp.delete('/memory/:scope/:key', async (c) => {\n const runtime = c.get('runtime');\n const store = runtime.getStateStore();\n const scope = c.req.param('scope');\n const key = c.req.param('key');\n\n if (!store.deleteMemory) {\n return c.json(\n { ok: false, error: { code: 'NOT_SUPPORTED', message: 'Memory not supported' } },\n 501,\n );\n }\n\n await store.deleteMemory(scope, key);\n return c.json({ ok: true, data: { deleted: true } });\n});\n\n// Semantic search\napp.post('/memory/search', async (c) => {\n // TODO: Connect to MemoryManager's vector search once exposed\n return c.json({\n ok: true,\n data: { results: [], message: 'Semantic search requires MemoryManager with vector store' },\n });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\n\nconst app = new Hono<StudioEnv>();\n\n// List pending decisions\napp.get('/decisions', async (c) => {\n const runtime = c.get('runtime');\n const decisions = await runtime.getPendingDecisions();\n return c.json({ ok: true, data: decisions });\n});\n\n// Resolve a pending decision\napp.post('/decisions/:executionId/resolve', async (c) => {\n const runtime = c.get('runtime');\n const executionId = c.req.param('executionId');\n const body = await c.req.json<{ approved: boolean; reason?: string }>();\n\n await runtime.resolveDecision(executionId, body);\n return c.json({ ok: true, data: { resolved: true } });\n});\n\nexport default app;\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\nimport type { CostAggregator } from '../cost-aggregator.js';\n\nexport function createCostRoutes(costAggregator: CostAggregator) {\n const app = new Hono<StudioEnv>();\n\n app.get('/costs', (c) => {\n return c.json({ ok: true, data: costAggregator.getData() });\n });\n\n app.post('/costs/reset', (c) => {\n costAggregator.reset();\n return c.json({ ok: true, data: { reset: true } });\n });\n\n return app;\n}\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\n\nexport function createEvalRoutes(evalLoader?: () => Promise<void>) {\n const app = new Hono<StudioEnv>();\n\n // List registered eval configs\n app.get('/evals', async (c) => {\n if (evalLoader) await evalLoader();\n const runtime = c.get('runtime');\n const evals = runtime.getRegisteredEvals();\n return c.json({ ok: true, data: evals });\n });\n\n // Run a registered eval by name\n app.post('/evals/:name/run', async (c) => {\n if (evalLoader) await evalLoader();\n const runtime = c.get('runtime');\n const name = c.req.param('name');\n\n const entry = runtime.getRegisteredEval(name);\n if (!entry) {\n return c.json(\n { ok: false, error: { code: 'NOT_FOUND', message: `Eval \"${name}\" not found` } },\n 404,\n );\n }\n\n try {\n const result = await runtime.runRegisteredEval(name);\n return c.json({ ok: true, data: result });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { code: 'EVAL_ERROR', message } }, 400);\n }\n });\n\n // Compare eval results\n app.post('/evals/compare', async (c) => {\n const runtime = c.get('runtime');\n const body = await c.req.json<{ baseline: unknown; candidate: unknown }>();\n\n try {\n const result = await runtime.evalCompare(body.baseline, body.candidate);\n return c.json({ ok: true, data: result });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { code: 'EVAL_ERROR', message } }, 400);\n }\n });\n\n return app;\n}\n","import { Hono } from 'hono';\nimport type { StudioEnv } from '../types.js';\nimport type { ConnectionManager } from '../ws/connection-manager.js';\n\nexport function createPlaygroundRoutes(connMgr: ConnectionManager) {\n const app = new Hono<StudioEnv>();\n\n // Chat with an agent via session\n app.post('/playground/chat', async (c) => {\n const runtime = c.get('runtime');\n const body = await c.req.json<{\n sessionId?: string;\n message: string;\n workflow?: string;\n }>();\n\n const workflowName = body.workflow ?? runtime.getWorkflowNames()[0];\n if (!workflowName) {\n return c.json(\n { ok: false, error: { code: 'NO_WORKFLOW', message: 'No workflows registered' } },\n 400,\n );\n }\n const sessionId = body.sessionId ?? `playground-${Date.now()}`;\n const session = runtime.session(sessionId);\n\n // Stream the response\n const stream = await session.stream(workflowName, body.message);\n const executionId = `playground-${sessionId}-${Date.now()}`;\n\n // Forward stream events to WS\n (async () => {\n try {\n for await (const event of stream) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, event);\n }\n } catch (err) {\n connMgr.broadcastWithWildcard(`execution:${executionId}`, {\n type: 'error',\n message: err instanceof Error ? err.message : 'Stream error',\n });\n }\n })();\n\n return c.json({\n ok: true,\n data: { sessionId, executionId, streaming: true },\n });\n });\n\n return app;\n}\n"],"mappings":";AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,QAAAA,cAAY;AACrB,SAAS,YAAY;AACrB,SAAS,mBAAmB;;;ACD5B,eAAsB,aAAa,GAAuB,MAAY;AACpE,MAAI;AACF,UAAM,KAAK;AAAA,EACb,SAAS,KAAK;AACZ,UAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,UAAM,OAAQ,IAA0B,QAAQ;AAGhD,QAAI,SAAS;AACb,QAAI,YAAa,KAAgB;AAC/B,YAAM,YAAa,IAA4B;AAC/C,UAAI,OAAO,cAAc,YAAY,aAAa,OAAO,YAAY,KAAK;AACxE,iBAAS;AAAA,MACX;AAAA,IACF,WACE,SAAS,eACT,QAAQ,SAAS,WAAW,KAC5B,QAAQ,SAAS,gBAAgB,GACjC;AACA,eAAS;AAAA,IACX,WACE,SAAS,sBACT,QAAQ,SAAS,UAAU,KAC3B,QAAQ,SAAS,SAAS,GAC1B;AACA,eAAS;AAAA,IACX;AAEA,UAAM,OAA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ono","app","Hono","app","Hono","app","Hono","app","Hono","app","app","Hono"]}