@mastra/hono 1.4.18-alpha.0 → 1.4.18-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -467,6 +467,9 @@ async function setupBrowserStream(app, config2) {
467
467
  }
468
468
  const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
469
469
  const registry2 = new ViewerRegistry();
470
+ const rawPrefix = config2.apiPrefix ?? "/api";
471
+ const trimmed = rawPrefix.endsWith("/") ? rawPrefix.slice(0, -1) : rawPrefix;
472
+ const apiPrefix = trimmed || "/api";
470
473
  app.get(
471
474
  "/browser/:agentId/stream",
472
475
  upgradeWebSocket((c) => {
@@ -494,7 +497,20 @@ async function setupBrowserStream(app, config2) {
494
497
  };
495
498
  })
496
499
  );
497
- app.post("/api/agents/:agentId/browser/close", async (c) => {
500
+ app.get(`${apiPrefix}/agents/:agentId/browser/session`, (c) => {
501
+ const agentId = c.req.param("agentId");
502
+ if (!agentId) {
503
+ return c.json({ error: "Agent ID is required" }, 400);
504
+ }
505
+ const threadId = c.req.query("threadId");
506
+ const toolset = config2.getToolset(agentId);
507
+ if (!toolset) {
508
+ return c.json({ hasSession: false, screencastAvailable: true });
509
+ }
510
+ const hasSession = threadId ? toolset.hasThreadSession(threadId) : false;
511
+ return c.json({ hasSession, screencastAvailable: true });
512
+ });
513
+ app.post(`${apiPrefix}/agents/:agentId/browser/close`, async (c) => {
498
514
  const agentId = c.req.param("agentId");
499
515
  if (!agentId) {
500
516
  return c.json({ error: "Agent ID is required" }, 400);
@@ -902,7 +918,7 @@ var MastraServer = class extends MastraServer$1 {
902
918
  if (authConfig) {
903
919
  const hasPermission = await loadHasPermission();
904
920
  if (hasPermission) {
905
- const userPermissions = c.get("requestContext").get("userPermissions");
921
+ const userPermissions = c.get("requestContext").get("mastra__userPermissions");
906
922
  const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission);
907
923
  if (permissionError) {
908
924
  return c.json(
@@ -999,7 +1015,7 @@ var MastraServer = class extends MastraServer$1 {
999
1015
  if (authConfig) {
1000
1016
  const hasPermission = await loadHasPermission();
1001
1017
  if (hasPermission) {
1002
- const userPermissions = c.get("requestContext").get("userPermissions");
1018
+ const userPermissions = c.get("requestContext").get("mastra__userPermissions");
1003
1019
  const permissionError = this.checkRoutePermission(serverRoute, userPermissions, hasPermission);
1004
1020
  if (permissionError) {
1005
1021
  return c.json(