@mastra/deployer 0.13.2-alpha.1 → 0.13.2-alpha.3

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.
Files changed (43) hide show
  1. package/dist/build/analyze.cjs +3 -3
  2. package/dist/build/analyze.d.ts.map +1 -1
  3. package/dist/build/analyze.js +1 -1
  4. package/dist/build/babel/check-config-export.d.ts +5 -0
  5. package/dist/build/babel/check-config-export.d.ts.map +1 -0
  6. package/dist/build/index.cjs +9 -9
  7. package/dist/build/index.js +3 -3
  8. package/dist/bundler/index.cjs +2 -2
  9. package/dist/bundler/index.js +1 -1
  10. package/dist/{chunk-E742PKW3.js → chunk-3OH2F6RQ.js} +56 -6
  11. package/dist/chunk-3OH2F6RQ.js.map +1 -0
  12. package/dist/{chunk-GA3I2SUH.cjs → chunk-7T2PU7VS.cjs} +56 -6
  13. package/dist/chunk-7T2PU7VS.cjs.map +1 -0
  14. package/dist/{chunk-FQIQKPRH.js → chunk-7U5E2KBV.js} +3 -3
  15. package/dist/{chunk-FQIQKPRH.js.map → chunk-7U5E2KBV.js.map} +1 -1
  16. package/dist/{chunk-OPNQQDWL.cjs → chunk-DO5ZQHCX.cjs} +9 -9
  17. package/dist/{chunk-OPNQQDWL.cjs.map → chunk-DO5ZQHCX.cjs.map} +1 -1
  18. package/dist/{chunk-IAZWZE5D.js → chunk-IA6E2T4X.js} +4 -4
  19. package/dist/{chunk-IAZWZE5D.js.map → chunk-IA6E2T4X.js.map} +1 -1
  20. package/dist/{chunk-MJK4QE4U.cjs → chunk-J4CNHLNI.cjs} +7 -7
  21. package/dist/{chunk-MJK4QE4U.cjs.map → chunk-J4CNHLNI.cjs.map} +1 -1
  22. package/dist/{chunk-PKWWUDUT.cjs → chunk-USWV4OQC.cjs} +5 -5
  23. package/dist/{chunk-PKWWUDUT.cjs.map → chunk-USWV4OQC.cjs.map} +1 -1
  24. package/dist/{chunk-T454CVHE.js → chunk-XJGTXD3R.js} +3 -3
  25. package/dist/{chunk-T454CVHE.js.map → chunk-XJGTXD3R.js.map} +1 -1
  26. package/dist/index.cjs +4 -4
  27. package/dist/index.js +2 -2
  28. package/dist/server/handlers/a2a.d.ts +81 -21
  29. package/dist/server/handlers/a2a.d.ts.map +1 -1
  30. package/dist/server/handlers/routes/agents/handlers.d.ts +4 -0
  31. package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
  32. package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
  33. package/dist/server/handlers/utils.d.ts +7 -0
  34. package/dist/server/handlers/utils.d.ts.map +1 -1
  35. package/dist/server/index.cjs +266 -160
  36. package/dist/server/index.cjs.map +1 -1
  37. package/dist/server/index.d.ts +2 -0
  38. package/dist/server/index.d.ts.map +1 -1
  39. package/dist/server/index.js +266 -160
  40. package/dist/server/index.js.map +1 -1
  41. package/package.json +5 -5
  42. package/dist/chunk-E742PKW3.js.map +0 -1
  43. package/dist/chunk-GA3I2SUH.cjs.map +0 -1
@@ -13,6 +13,7 @@ var html = require('hono/html');
13
13
  var core = require('@mastra/core');
14
14
  var runtimeContext = require('@mastra/core/runtime-context');
15
15
  var tools = require('@mastra/core/tools');
16
+ var store = require('@mastra/server/a2a/store');
16
17
  var hono = require('hono');
17
18
  var cors = require('hono/cors');
18
19
  var logger = require('hono/logger');
@@ -20,11 +21,11 @@ var timeout = require('hono/timeout');
20
21
  var httpException = require('hono/http-exception');
21
22
  var a2a = require('@mastra/server/handlers/a2a');
22
23
  var streaming = require('hono/streaming');
24
+ var agents = require('@mastra/server/handlers/agents');
23
25
  var bodyLimit = require('hono/body-limit');
24
26
  var agent = require('@mastra/core/agent');
25
27
  var zod = require('zod');
26
28
  var tools$1 = require('@mastra/server/handlers/tools');
27
- var agents = require('@mastra/server/handlers/agents');
28
29
  var voice = require('@mastra/server/handlers/voice');
29
30
  var logs = require('@mastra/server/handlers/logs');
30
31
  var util = require('util');
@@ -939,9 +940,10 @@ async function getAgentExecutionHandler(c2) {
939
940
  const mastra = c2.get("mastra");
940
941
  const agentId = c2.req.param("agentId");
941
942
  const runtimeContext = c2.get("runtimeContext");
943
+ const taskStore = c2.get("taskStore");
942
944
  const logger2 = mastra.getLogger();
943
945
  const body = await c2.req.json();
944
- if (!["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"].includes(body.method)) {
946
+ if (!["message/send", "message/stream", "tasks/get", "tasks/cancel"].includes(body.method)) {
945
947
  return c2.json({ error: { message: `Unsupported method: ${body.method}`, code: "invalid_method" } }, 400);
946
948
  }
947
949
  const result = await a2a.getAgentExecutionHandler({
@@ -951,9 +953,10 @@ async function getAgentExecutionHandler(c2) {
951
953
  requestId: crypto.randomUUID(),
952
954
  method: body.method,
953
955
  params: body.params,
956
+ taskStore,
954
957
  logger: logger2
955
958
  });
956
- if (body.method === "tasks/sendSubscribe") {
959
+ if (body.method === "message/stream") {
957
960
  return streaming.stream(
958
961
  c2,
959
962
  async (stream6) => {
@@ -967,11 +970,11 @@ async function getAgentExecutionHandler(c2) {
967
970
  await stream6.write(JSON.stringify(chunk) + "");
968
971
  }
969
972
  } catch (err) {
970
- logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
973
+ logger2.error("Error in message/stream stream: " + err?.message);
971
974
  }
972
975
  },
973
976
  async (err) => {
974
- logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
977
+ logger2.error("Error in message/stream stream: " + err?.message);
975
978
  }
976
979
  );
977
980
  }
@@ -1003,7 +1006,7 @@ var defaultAuthConfig = {
1003
1006
 
1004
1007
  // src/server/handlers/auth/helpers.ts
1005
1008
  var isDevPlaygroundRequest = (req) => {
1006
- return req.header("x-mastra-dev-playground") === "true" && (req.header("referer")?.includes("localhost") ?? false);
1009
+ return req.header("x-mastra-dev-playground") === "true" && process.env.MASTRA_DEV === "true";
1007
1010
  };
1008
1011
  var isProtectedPath = (path, method, authConfig) => {
1009
1012
  const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
@@ -1239,6 +1242,187 @@ function errorHandler(err, c2, isDev) {
1239
1242
  async function rootHandler(c2) {
1240
1243
  return c2.text("Hello to the Mastra API!");
1241
1244
  }
1245
+ var AllowedProviderKeys = {
1246
+ openai: "OPENAI_API_KEY",
1247
+ xai: "XAI_API_KEY",
1248
+ anthropic: "ANTHROPIC_API_KEY",
1249
+ google: "GOOGLE_GENERATIVE_AI_API_KEY",
1250
+ groq: "GROQ_API_KEY"
1251
+ };
1252
+
1253
+ // src/server/handlers/routes/agents/handlers.ts
1254
+ async function getAgentsHandler(c2) {
1255
+ const serializedAgents = await agents.getAgentsHandler({
1256
+ mastra: c2.get("mastra"),
1257
+ runtimeContext: c2.get("runtimeContext")
1258
+ });
1259
+ return c2.json(serializedAgents);
1260
+ }
1261
+ async function getAgentByIdHandler(c2) {
1262
+ const mastra = c2.get("mastra");
1263
+ const agentId = c2.req.param("agentId");
1264
+ const runtimeContext = c2.get("runtimeContext");
1265
+ const isPlayground = c2.req.header("x-mastra-dev-playground") === "true";
1266
+ const result = await agents.getAgentByIdHandler({
1267
+ mastra,
1268
+ agentId,
1269
+ runtimeContext,
1270
+ isPlayground
1271
+ });
1272
+ return c2.json(result);
1273
+ }
1274
+ async function getEvalsByAgentIdHandler(c2) {
1275
+ const mastra = c2.get("mastra");
1276
+ const agentId = c2.req.param("agentId");
1277
+ const runtimeContext = c2.get("runtimeContext");
1278
+ const result = await agents.getEvalsByAgentIdHandler({
1279
+ mastra,
1280
+ agentId,
1281
+ runtimeContext
1282
+ });
1283
+ return c2.json(result);
1284
+ }
1285
+ async function getLiveEvalsByAgentIdHandler(c2) {
1286
+ const mastra = c2.get("mastra");
1287
+ const agentId = c2.req.param("agentId");
1288
+ const runtimeContext = c2.get("runtimeContext");
1289
+ const result = await agents.getLiveEvalsByAgentIdHandler({
1290
+ mastra,
1291
+ agentId,
1292
+ runtimeContext
1293
+ });
1294
+ return c2.json(result);
1295
+ }
1296
+ async function generateHandler(c2) {
1297
+ try {
1298
+ const mastra = c2.get("mastra");
1299
+ const agentId = c2.req.param("agentId");
1300
+ const runtimeContext = c2.get("runtimeContext");
1301
+ const body = await c2.req.json();
1302
+ const result = await agents.generateHandler({
1303
+ mastra,
1304
+ agentId,
1305
+ runtimeContext,
1306
+ body,
1307
+ abortSignal: c2.req.raw.signal
1308
+ });
1309
+ return c2.json(result);
1310
+ } catch (error) {
1311
+ return handleError(error, "Error generating from agent");
1312
+ }
1313
+ }
1314
+ async function streamGenerateHandler(c2) {
1315
+ try {
1316
+ const mastra = c2.get("mastra");
1317
+ const agentId = c2.req.param("agentId");
1318
+ const runtimeContext = c2.get("runtimeContext");
1319
+ const body = await c2.req.json();
1320
+ const streamResponse = await agents.streamGenerateHandler({
1321
+ mastra,
1322
+ agentId,
1323
+ runtimeContext,
1324
+ body,
1325
+ abortSignal: c2.req.raw.signal
1326
+ });
1327
+ return streamResponse;
1328
+ } catch (error) {
1329
+ return handleError(error, "Error streaming from agent");
1330
+ }
1331
+ }
1332
+ async function streamVNextGenerateHandler(c2) {
1333
+ try {
1334
+ const mastra = c2.get("mastra");
1335
+ const agentId = c2.req.param("agentId");
1336
+ const runtimeContext = c2.get("runtimeContext");
1337
+ const body = await c2.req.json();
1338
+ const logger2 = mastra.getLogger();
1339
+ c2.header("Transfer-Encoding", "chunked");
1340
+ return streaming.stream(
1341
+ c2,
1342
+ async (stream6) => {
1343
+ try {
1344
+ const result = agents.streamVNextGenerateHandler({
1345
+ mastra,
1346
+ agentId,
1347
+ runtimeContext,
1348
+ body,
1349
+ abortSignal: c2.req.raw.signal
1350
+ });
1351
+ const reader = result.getReader();
1352
+ stream6.onAbort(() => {
1353
+ void reader.cancel("request aborted");
1354
+ });
1355
+ let chunkResult;
1356
+ while ((chunkResult = await reader.read()) && !chunkResult.done) {
1357
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
1358
+ }
1359
+ } catch (err) {
1360
+ logger2.error("Error in streamVNext generate: " + (err?.message ?? "Unknown error"));
1361
+ }
1362
+ await stream6.close();
1363
+ },
1364
+ async (err) => {
1365
+ logger2.error("Error in watch stream: " + err?.message);
1366
+ }
1367
+ );
1368
+ } catch (error) {
1369
+ return handleError(error, "Error streaming from agent");
1370
+ }
1371
+ }
1372
+ async function setAgentInstructionsHandler(c2) {
1373
+ try {
1374
+ const isPlayground = c2.get("playground") === true;
1375
+ if (!isPlayground) {
1376
+ return c2.json({ error: "This API is only available in the playground environment" }, 403);
1377
+ }
1378
+ const agentId = c2.req.param("agentId");
1379
+ const { instructions } = await c2.req.json();
1380
+ if (!agentId || !instructions) {
1381
+ return c2.json({ error: "Missing required fields" }, 400);
1382
+ }
1383
+ const mastra = c2.get("mastra");
1384
+ const agent = mastra.getAgent(agentId);
1385
+ if (!agent) {
1386
+ return c2.json({ error: "Agent not found" }, 404);
1387
+ }
1388
+ agent.__updateInstructions(instructions);
1389
+ return c2.json(
1390
+ {
1391
+ instructions
1392
+ },
1393
+ 200
1394
+ );
1395
+ } catch (error) {
1396
+ return handleError(error, "Error setting agent instructions");
1397
+ }
1398
+ }
1399
+ async function updateAgentModelHandler(c2) {
1400
+ try {
1401
+ const mastra = c2.get("mastra");
1402
+ const agentId = c2.req.param("agentId");
1403
+ const body = await c2.req.json();
1404
+ const result = agents.updateAgentModelHandler({
1405
+ mastra,
1406
+ agentId,
1407
+ body
1408
+ });
1409
+ return c2.json(result);
1410
+ } catch (error) {
1411
+ return handleError(error, "Error updating agent model");
1412
+ }
1413
+ }
1414
+ async function getModelProvidersHandler(c2) {
1415
+ const isPlayground = c2.get("playground") === true;
1416
+ if (!isPlayground) {
1417
+ return c2.json({ error: "This API is only available in the playground environment" }, 403);
1418
+ }
1419
+ const envVars = process.env;
1420
+ const providers = Object.entries(AllowedProviderKeys);
1421
+ const envKeys = Object.keys(envVars);
1422
+ const availableProviders = providers.filter(([_, value]) => envKeys.includes(value) && !!envVars[value]);
1423
+ const availableProvidersNames = availableProviders.map(([key]) => key);
1424
+ return c2.json(availableProvidersNames);
1425
+ }
1242
1426
  async function generateSystemPromptHandler(c2) {
1243
1427
  try {
1244
1428
  const agentId = c2.req.param("agentId");
@@ -1412,151 +1596,6 @@ async function executeAgentToolHandler(c2) {
1412
1596
  return handleError(error, "Error executing tool");
1413
1597
  }
1414
1598
  }
1415
- async function getAgentsHandler(c2) {
1416
- const serializedAgents = await agents.getAgentsHandler({
1417
- mastra: c2.get("mastra"),
1418
- runtimeContext: c2.get("runtimeContext")
1419
- });
1420
- return c2.json(serializedAgents);
1421
- }
1422
- async function getAgentByIdHandler(c2) {
1423
- const mastra = c2.get("mastra");
1424
- const agentId = c2.req.param("agentId");
1425
- const runtimeContext = c2.get("runtimeContext");
1426
- const isPlayground = c2.req.header("x-mastra-dev-playground") === "true";
1427
- const result = await agents.getAgentByIdHandler({
1428
- mastra,
1429
- agentId,
1430
- runtimeContext,
1431
- isPlayground
1432
- });
1433
- return c2.json(result);
1434
- }
1435
- async function getEvalsByAgentIdHandler(c2) {
1436
- const mastra = c2.get("mastra");
1437
- const agentId = c2.req.param("agentId");
1438
- const runtimeContext = c2.get("runtimeContext");
1439
- const result = await agents.getEvalsByAgentIdHandler({
1440
- mastra,
1441
- agentId,
1442
- runtimeContext
1443
- });
1444
- return c2.json(result);
1445
- }
1446
- async function getLiveEvalsByAgentIdHandler(c2) {
1447
- const mastra = c2.get("mastra");
1448
- const agentId = c2.req.param("agentId");
1449
- const runtimeContext = c2.get("runtimeContext");
1450
- const result = await agents.getLiveEvalsByAgentIdHandler({
1451
- mastra,
1452
- agentId,
1453
- runtimeContext
1454
- });
1455
- return c2.json(result);
1456
- }
1457
- async function generateHandler(c2) {
1458
- try {
1459
- const mastra = c2.get("mastra");
1460
- const agentId = c2.req.param("agentId");
1461
- const runtimeContext = c2.get("runtimeContext");
1462
- const body = await c2.req.json();
1463
- const result = await agents.generateHandler({
1464
- mastra,
1465
- agentId,
1466
- runtimeContext,
1467
- body,
1468
- abortSignal: c2.req.raw.signal
1469
- });
1470
- return c2.json(result);
1471
- } catch (error) {
1472
- return handleError(error, "Error generating from agent");
1473
- }
1474
- }
1475
- async function streamGenerateHandler(c2) {
1476
- try {
1477
- const mastra = c2.get("mastra");
1478
- const agentId = c2.req.param("agentId");
1479
- const runtimeContext = c2.get("runtimeContext");
1480
- const body = await c2.req.json();
1481
- const streamResponse = await agents.streamGenerateHandler({
1482
- mastra,
1483
- agentId,
1484
- runtimeContext,
1485
- body,
1486
- abortSignal: c2.req.raw.signal
1487
- });
1488
- return streamResponse;
1489
- } catch (error) {
1490
- return handleError(error, "Error streaming from agent");
1491
- }
1492
- }
1493
- async function streamVNextGenerateHandler(c2) {
1494
- try {
1495
- const mastra = c2.get("mastra");
1496
- const agentId = c2.req.param("agentId");
1497
- const runtimeContext = c2.get("runtimeContext");
1498
- const body = await c2.req.json();
1499
- const logger2 = mastra.getLogger();
1500
- c2.header("Transfer-Encoding", "chunked");
1501
- return streaming.stream(
1502
- c2,
1503
- async (stream6) => {
1504
- try {
1505
- const result = agents.streamVNextGenerateHandler({
1506
- mastra,
1507
- agentId,
1508
- runtimeContext,
1509
- body,
1510
- abortSignal: c2.req.raw.signal
1511
- });
1512
- const reader = result.getReader();
1513
- stream6.onAbort(() => {
1514
- void reader.cancel("request aborted");
1515
- });
1516
- let chunkResult;
1517
- while ((chunkResult = await reader.read()) && !chunkResult.done) {
1518
- await stream6.write(JSON.stringify(chunkResult.value) + "");
1519
- }
1520
- } catch (err) {
1521
- logger2.error("Error in streamVNext generate: " + (err?.message ?? "Unknown error"));
1522
- }
1523
- await stream6.close();
1524
- },
1525
- async (err) => {
1526
- logger2.error("Error in watch stream: " + err?.message);
1527
- }
1528
- );
1529
- } catch (error) {
1530
- return handleError(error, "Error streaming from agent");
1531
- }
1532
- }
1533
- async function setAgentInstructionsHandler(c2) {
1534
- try {
1535
- const isPlayground = c2.get("playground") === true;
1536
- if (!isPlayground) {
1537
- return c2.json({ error: "This API is only available in the playground environment" }, 403);
1538
- }
1539
- const agentId = c2.req.param("agentId");
1540
- const { instructions } = await c2.req.json();
1541
- if (!agentId || !instructions) {
1542
- return c2.json({ error: "Missing required fields" }, 400);
1543
- }
1544
- const mastra = c2.get("mastra");
1545
- const agent = mastra.getAgent(agentId);
1546
- if (!agent) {
1547
- return c2.json({ error: "Agent not found" }, 404);
1548
- }
1549
- agent.__updateInstructions(instructions);
1550
- return c2.json(
1551
- {
1552
- instructions
1553
- },
1554
- 200
1555
- );
1556
- } catch (error) {
1557
- return handleError(error, "Error setting agent instructions");
1558
- }
1559
- }
1560
1599
  async function getSpeakersHandler(c2) {
1561
1600
  try {
1562
1601
  const mastra = c2.get("mastra");
@@ -1879,6 +1918,48 @@ function agentsRouter(bodyLimitOptions) {
1879
1918
  }),
1880
1919
  streamVNextGenerateHandler
1881
1920
  );
1921
+ router.post(
1922
+ "/:agentId/model",
1923
+ bodyLimit.bodyLimit(bodyLimitOptions),
1924
+ w({
1925
+ description: "Update the model for an agent",
1926
+ tags: ["agents"],
1927
+ parameters: [
1928
+ {
1929
+ name: "agentId",
1930
+ in: "path",
1931
+ required: true,
1932
+ schema: { type: "string" }
1933
+ }
1934
+ ],
1935
+ requestBody: {
1936
+ required: true,
1937
+ content: {
1938
+ "application/json": {
1939
+ schema: {
1940
+ type: "object",
1941
+ properties: {
1942
+ model: {
1943
+ type: "object",
1944
+ description: "The model to update the agent to"
1945
+ }
1946
+ },
1947
+ required: ["model"]
1948
+ }
1949
+ }
1950
+ }
1951
+ },
1952
+ responses: {
1953
+ 200: {
1954
+ description: "Model updated successfully"
1955
+ },
1956
+ 404: {
1957
+ description: "Agent not found"
1958
+ }
1959
+ }
1960
+ }),
1961
+ updateAgentModelHandler
1962
+ );
1882
1963
  router.get(
1883
1964
  "/:agentId/speakers",
1884
1965
  async (c2, next) => {
@@ -9362,6 +9443,7 @@ async function createHonoServer(mastra, options = {
9362
9443
  }) {
9363
9444
  const app = new hono.Hono();
9364
9445
  const server = mastra.getServer();
9446
+ const a2aTaskStore = new store.InMemoryTaskStore();
9365
9447
  app.use("*", async function setTelemetryInfo(c2, next) {
9366
9448
  const requestId = c2.req.header("x-request-id") ?? crypto.randomUUID();
9367
9449
  const span = core.Telemetry.getActiveSpan();
@@ -9400,6 +9482,7 @@ async function createHonoServer(mastra, options = {
9400
9482
  c2.set("runtimeContext", runtimeContext$1);
9401
9483
  c2.set("mastra", mastra);
9402
9484
  c2.set("tools", options.tools);
9485
+ c2.set("taskStore", a2aTaskStore);
9403
9486
  c2.set("playground", options.playground === true);
9404
9487
  c2.set("isDev", options.isDev === true);
9405
9488
  return next();
@@ -9474,7 +9557,7 @@ async function createHonoServer(mastra, options = {
9474
9557
  app.use(logger.logger());
9475
9558
  }
9476
9559
  app.get(
9477
- "/.well-known/:agentId/agent.json",
9560
+ "/.well-known/:agentId/agent-card.json",
9478
9561
  w({
9479
9562
  description: "Get agent configuration",
9480
9563
  tags: ["agents"],
@@ -9516,14 +9599,14 @@ async function createHonoServer(mastra, options = {
9516
9599
  properties: {
9517
9600
  method: {
9518
9601
  type: "string",
9519
- enum: ["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"],
9602
+ enum: ["message/send", "message/stream", "tasks/get", "tasks/cancel"],
9520
9603
  description: "The A2A protocol method to execute"
9521
9604
  },
9522
9605
  params: {
9523
9606
  type: "object",
9524
9607
  oneOf: [
9525
9608
  {
9526
- // TaskSendParams
9609
+ // MessageSendParams
9527
9610
  type: "object",
9528
9611
  properties: {
9529
9612
  id: {
@@ -9622,6 +9705,19 @@ async function createHonoServer(mastra, options = {
9622
9705
  }),
9623
9706
  rootHandler
9624
9707
  );
9708
+ app.get(
9709
+ "/api/model-providers",
9710
+ w({
9711
+ description: "Get all model providers with available keys",
9712
+ tags: ["agents"],
9713
+ responses: {
9714
+ 200: {
9715
+ description: "All model providers with available keys"
9716
+ }
9717
+ }
9718
+ }),
9719
+ getModelProvidersHandler
9720
+ );
9625
9721
  app.route("/api/agents", agentsRouter(bodyLimitOptions));
9626
9722
  app.route("/api/networks", vNextNetworksRouter(bodyLimitOptions));
9627
9723
  app.route("/api/networks", networksRouter(bodyLimitOptions));
@@ -9686,27 +9782,37 @@ async function createHonoServer(mastra, options = {
9686
9782
  root: "./playground/assets"
9687
9783
  })
9688
9784
  );
9689
- app.use(
9690
- "*",
9691
- serveStatic({
9692
- root: "./playground"
9693
- })
9694
- );
9695
9785
  }
9696
9786
  app.get("*", async (c2, next) => {
9697
9787
  if (c2.req.path.startsWith("/api/") || c2.req.path.startsWith("/swagger-ui") || c2.req.path.startsWith("/openapi.json")) {
9698
9788
  return await next();
9699
9789
  }
9790
+ const path = c2.req.path;
9791
+ if (path.includes(".") && !path.endsWith(".html")) {
9792
+ return await next();
9793
+ }
9700
9794
  if (options?.playground) {
9701
9795
  let indexHtml = await promises.readFile(posix.join(process.cwd(), "./playground/index.html"), "utf-8");
9702
9796
  indexHtml = indexHtml.replace(
9703
9797
  `'%%MASTRA_TELEMETRY_DISABLED%%'`,
9704
9798
  `${Boolean(process.env.MASTRA_TELEMETRY_DISABLED)}`
9705
9799
  );
9800
+ const serverOptions = mastra.getServer();
9801
+ const port = serverOptions?.port ?? (Number(process.env.PORT) || 4111);
9802
+ const host = serverOptions?.host ?? "localhost";
9803
+ indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_URL%%'`, `'http://${host}:${port}'`);
9706
9804
  return c2.newResponse(indexHtml, 200, { "Content-Type": "text/html" });
9707
9805
  }
9708
9806
  return c2.newResponse(html2, 200, { "Content-Type": "text/html" });
9709
9807
  });
9808
+ if (options?.playground) {
9809
+ app.use(
9810
+ "*",
9811
+ serveStatic({
9812
+ root: "./playground"
9813
+ })
9814
+ );
9815
+ }
9710
9816
  return app;
9711
9817
  }
9712
9818
  async function createNodeServer(mastra, options = { tools: {} }) {