@mastra/deployer 1.36.0-alpha.1 → 1.36.0-alpha.10

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AAgCF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CA0XhE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAyElG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AAgCF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CAmZhE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAyElG"}
@@ -3157,6 +3157,9 @@ async function setupBrowserStream(app, config2) {
3157
3157
  }
3158
3158
  const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
3159
3159
  const registry2 = new ViewerRegistry();
3160
+ const rawPrefix = config2.apiPrefix ?? "/api";
3161
+ const trimmed = rawPrefix.endsWith("/") ? rawPrefix.slice(0, -1) : rawPrefix;
3162
+ const apiPrefix = trimmed || "/api";
3160
3163
  app.get(
3161
3164
  "/browser/:agentId/stream",
3162
3165
  upgradeWebSocket((c) => {
@@ -3171,7 +3174,7 @@ async function setupBrowserStream(app, config2) {
3171
3174
  onMessage(event, _ws) {
3172
3175
  const data = typeof event.data === "string" ? event.data : null;
3173
3176
  if (data) {
3174
- handleInputMessage(data, config2.getToolset, agentId, threadId);
3177
+ void handleInputMessage(data, config2.getToolset, agentId, threadId);
3175
3178
  }
3176
3179
  },
3177
3180
  onClose(_event, ws) {
@@ -3184,12 +3187,25 @@ async function setupBrowserStream(app, config2) {
3184
3187
  };
3185
3188
  })
3186
3189
  );
3187
- app.post("/api/agents/:agentId/browser/close", async (c) => {
3190
+ app.get(`${apiPrefix}/agents/:agentId/browser/session`, async (c) => {
3188
3191
  const agentId = c.req.param("agentId");
3189
3192
  if (!agentId) {
3190
3193
  return c.json({ error: "Agent ID is required" }, 400);
3191
3194
  }
3192
- const toolset = config2.getToolset(agentId);
3195
+ const threadId = c.req.query("threadId");
3196
+ const toolset = await config2.getToolset(agentId);
3197
+ if (!toolset) {
3198
+ return c.json({ hasSession: false, screencastAvailable: true });
3199
+ }
3200
+ const hasSession = threadId ? toolset.hasThreadSession(threadId) : false;
3201
+ return c.json({ hasSession, screencastAvailable: true });
3202
+ });
3203
+ app.post(`${apiPrefix}/agents/:agentId/browser/close`, async (c) => {
3204
+ const agentId = c.req.param("agentId");
3205
+ if (!agentId) {
3206
+ return c.json({ error: "Agent ID is required" }, 400);
3207
+ }
3208
+ const toolset = await config2.getToolset(agentId);
3193
3209
  if (!toolset) {
3194
3210
  return c.json({ error: "No browser session for this agent" }, 404);
3195
3211
  }
@@ -3590,7 +3606,7 @@ var MastraServer = class extends MastraServer$1 {
3590
3606
  if (authConfig) {
3591
3607
  const hasPermission = await loadHasPermission();
3592
3608
  if (hasPermission) {
3593
- const userPermissions = c.get("requestContext").get("userPermissions");
3609
+ const userPermissions = c.get("requestContext").get("mastra__userPermissions");
3594
3610
  const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission);
3595
3611
  if (permissionError) {
3596
3612
  return c.json(
@@ -3687,7 +3703,7 @@ var MastraServer = class extends MastraServer$1 {
3687
3703
  if (authConfig) {
3688
3704
  const hasPermission = await loadHasPermission();
3689
3705
  if (hasPermission) {
3690
- const userPermissions = c.get("requestContext").get("userPermissions");
3706
+ const userPermissions = c.get("requestContext").get("mastra__userPermissions");
3691
3707
  const permissionError = this.checkRoutePermission(serverRoute, userPermissions, hasPermission);
3692
3708
  if (permissionError) {
3693
3709
  return c.json(
@@ -4525,11 +4541,29 @@ async function createHonoServer(mastra, options = {
4525
4541
  }
4526
4542
  }
4527
4543
  const browserStreamSetup = await setupBrowserStream(app, {
4528
- getToolset: (agentId) => {
4529
- const agent = mastra.getAgentById(agentId);
4530
- return agent?.browser;
4531
- }
4544
+ getToolset: async (agentId) => {
4545
+ try {
4546
+ const runtimeAgent = mastra.getAgentById(agentId);
4547
+ if (runtimeAgent) {
4548
+ return runtimeAgent.browser;
4549
+ }
4550
+ } catch {
4551
+ }
4552
+ try {
4553
+ const storedAgent = await mastra.getEditor?.()?.agent.getById(agentId);
4554
+ return storedAgent?.browser;
4555
+ } catch {
4556
+ return void 0;
4557
+ }
4558
+ },
4559
+ apiPrefix
4532
4560
  });
4561
+ if (!browserStreamSetup) {
4562
+ app.get(
4563
+ `${apiPrefix}/agents/:agentId/browser/session`,
4564
+ (c) => c.json({ hasSession: false, screencastAvailable: false })
4565
+ );
4566
+ }
4533
4567
  if (server?.cors === false) {
4534
4568
  app.use("*", timeout(server?.timeout ?? 3 * 60 * 1e3));
4535
4569
  } else {