feat: expose copilot header
This commit is contained in:
parent
0eb6f807f2
commit
22f983dde1
|
|
@ -21,11 +21,12 @@ async function bootstrap() {
|
|||
rawBody: true,
|
||||
cors: {
|
||||
...(!process.env.NOT_SECURED ? { credentials: true } : {}),
|
||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization', 'x-copilotkit-runtime-client-gql-version'],
|
||||
exposedHeaders: [
|
||||
'reload',
|
||||
'onboarding',
|
||||
'activate',
|
||||
'x-copilotkit-runtime-client-gql-version',
|
||||
...(process.env.NOT_SECURED ? ['auth', 'showorg', 'impersonate'] : []),
|
||||
],
|
||||
origin: [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type Mastra } from '@mastra/core/mastra';
|
||||
import { Mastra } from '@mastra/core/mastra';
|
||||
import { ConsoleLogger } from '@mastra/core/logger';
|
||||
import { pStore } from '@gitroom/nestjs-libraries/chat/mastra.store';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
|
@ -9,22 +9,17 @@ export class MastraService {
|
|||
static mastra: Mastra;
|
||||
constructor(private _loadToolsService: LoadToolsService) {}
|
||||
async mastra() {
|
||||
if (MastraService.mastra) {
|
||||
return MastraService.mastra;
|
||||
}
|
||||
|
||||
const MastraInstance = await import('@mastra/core/mastra').then(
|
||||
(m) => m.Mastra
|
||||
);
|
||||
MastraService.mastra = new MastraInstance({
|
||||
storage: pStore,
|
||||
agents: {
|
||||
postiz: await this._loadToolsService.agent(),
|
||||
},
|
||||
logger: new ConsoleLogger({
|
||||
level: 'info',
|
||||
}),
|
||||
});
|
||||
MastraService.mastra =
|
||||
MastraService.mastra ||
|
||||
new Mastra({
|
||||
storage: pStore,
|
||||
agents: {
|
||||
postiz: await this._loadToolsService.agent(),
|
||||
},
|
||||
logger: new ConsoleLogger({
|
||||
level: 'info',
|
||||
}),
|
||||
});
|
||||
|
||||
return MastraService.mastra;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { PostgresStore } from '@mastra/pg';
|
||||
import { PostgresStore, PgVector } from '@mastra/pg';
|
||||
|
||||
export const pStore = new PostgresStore({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { INestApplication } from '@nestjs/common';
|
||||
import { Request, Response } from 'express';
|
||||
import { MastraService } from '@gitroom/nestjs-libraries/chat/mastra.service';
|
||||
import { MCPServer } from '@mastra/mcp';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { OrganizationService } from '@gitroom/nestjs-libraries/database/prisma/organizations/organization.service';
|
||||
import { runWithContext } from './async.storage';
|
||||
export const startMcp = async (app: INestApplication) => {
|
||||
const MCPServer = await import('@mastra/mcp').then(m => m.MCPServer);
|
||||
const mastraService = app.get(MastraService, { strict: false });
|
||||
const organizationService = app.get(OrganizationService, { strict: false });
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue