export const mastra = new Mastra({
workflows: { fileUploadProcessorWorkflow },
agents: { fileProcessorAgent, investmentChatAgent },
storage: getStorage(),
// Server configuration to bind to all interfaces
server: {
port: 4111,
host: "0.0.0.0",
middleware: [
async (c, next) => {
const runtimeContext = c.get("runtimeContext");
if (c.req.method === "POST" && c.req.url.includes("/chat")) {
try {
const clonedReq = c.req.raw.clone();
const body = await clonedReq.json();
if (body?.data) {
for (const [key, value] of Object.entries(body.data)) {
runtimeContext.set(key, value);
}
}
} catch {}
}
await next();
},
],
apiRoutes: [
chatRoute({
path: "/chat",
agent: "investmentChatAgent",
}),
],
}
})
export const mastra = new Mastra({
workflows: { fileUploadProcessorWorkflow },
agents: { fileProcessorAgent, investmentChatAgent },
storage: getStorage(),
// Server configuration to bind to all interfaces
server: {
port: 4111,
host: "0.0.0.0",
middleware: [
async (c, next) => {
const runtimeContext = c.get("runtimeContext");
if (c.req.method === "POST" && c.req.url.includes("/chat")) {
try {
const clonedReq = c.req.raw.clone();
const body = await clonedReq.json();
if (body?.data) {
for (const [key, value] of Object.entries(body.data)) {
runtimeContext.set(key, value);
}
}
} catch {}
}
await next();
},
],
apiRoutes: [
chatRoute({
path: "/chat",
agent: "investmentChatAgent",
}),
],
}
})