@superinterface/server 1.0.25 → 1.0.26
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_btwyo7 +1 -1
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/api-keys/[apiKeyId]/route.js +1 -1
- package/.next/server/app/api/api-keys/[apiKeyId]/route.js.nft.json +1 -1
- package/.next/server/app/api/api-keys/route.js +1 -1
- package/.next/server/app/api/api-keys/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/route.js +1 -1
- package/.next/server/app/api/assistants/route.js.nft.json +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
- package/.next/server/app/api/files/route.js +1 -1
- package/.next/server/app/api/files/route.js.nft.json +1 -1
- package/.next/server/app/api/messages/route.js +1 -1
- package/.next/server/app/api/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/models/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/models/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/route.js +1 -1
- package/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/callback/route.js +1 -1
- package/.next/server/app/api/tasks/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/route.js +1 -1
- package/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js +1 -1
- package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js.nft.json +1 -1
- package/.next/server/app/api/workspaces/[workspaceId]/route.js +1 -1
- package/.next/server/app/api/workspaces/[workspaceId]/route.js.nft.json +1 -1
- package/.next/server/app/api/workspaces/route.js +1 -1
- package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__47b17fad._.js +38 -0
- package/.next/server/chunks/[root-of-the-server]__47b17fad._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__676affb1._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__676affb1._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a878c913._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a878c913._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__f6f61507._.js +38 -0
- package/.next/server/chunks/[root-of-the-server]__f6f61507._.js.map +1 -0
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
- package/.next/server/functions-config-manifest.json +1 -8
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts +52 -0
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.js +121 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +10 -21
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/route.js +6 -125
- package/dist/app/api/api-keys/buildRoute.d.ts +32 -0
- package/dist/app/api/api-keys/buildRoute.d.ts.map +1 -0
- package/dist/app/api/api-keys/buildRoute.js +104 -0
- package/dist/app/api/api-keys/builders.d.ts +31 -0
- package/dist/app/api/api-keys/builders.d.ts.map +1 -0
- package/dist/app/api/api-keys/builders.js +109 -0
- package/dist/app/api/api-keys/route.d.ts +5 -13
- package/dist/app/api/api-keys/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/route.js +8 -108
- package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts +120 -0
- package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/buildRoute.js +226 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts +167 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.js +184 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +10 -21
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +6 -191
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts +114 -0
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.js +117 -0
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/route.js +5 -122
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts +40 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.js +85 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +5 -90
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts +89 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.js +167 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +10 -21
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +6 -174
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts +62 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.js +115 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +5 -120
- package/dist/app/api/assistants/[assistantId]/route.d.ts +11 -22
- package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/route.js +6 -233
- package/dist/app/api/assistants/buildRoute.d.ts +121 -0
- package/dist/app/api/assistants/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/buildRoute.js +144 -0
- package/dist/app/api/assistants/route.d.ts +7 -13
- package/dist/app/api/assistants/route.d.ts.map +1 -1
- package/dist/app/api/assistants/route.js +6 -148
- package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts +18 -0
- package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts.map +1 -0
- package/dist/app/api/files/[fileId]/contents/buildRoute.js +81 -0
- package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -13
- package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
- package/dist/app/api/files/[fileId]/contents/route.js +4 -84
- package/dist/app/api/files/buildRoute.d.ts +14 -0
- package/dist/app/api/files/buildRoute.d.ts.map +1 -0
- package/dist/app/api/files/buildRoute.js +88 -0
- package/dist/app/api/files/route.d.ts +4 -10
- package/dist/app/api/files/route.d.ts.map +1 -1
- package/dist/app/api/files/route.js +4 -91
- package/dist/app/api/messages/buildRoute.d.ts +34 -0
- package/dist/app/api/messages/buildRoute.d.ts.map +1 -0
- package/dist/app/api/messages/buildRoute.js +607 -0
- package/dist/app/api/messages/lib/initialMessagesResponse.d.ts.map +1 -1
- package/dist/app/api/messages/lib/initialMessagesResponse.js +1 -1
- package/dist/app/api/messages/route.d.ts +10 -22
- package/dist/app/api/messages/route.d.ts.map +1 -1
- package/dist/app/api/messages/route.js +6 -612
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts +24 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.js +43 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +4 -9
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -46
- package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts +61 -0
- package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/buildRoute.js +134 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts +19 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.js +43 -0
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +4 -9
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -46
- package/dist/app/api/providers/[modelProviderId]/route.d.ts +10 -21
- package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/route.js +6 -141
- package/dist/app/api/providers/buildRoute.d.ts +38 -0
- package/dist/app/api/providers/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/buildRoute.js +75 -0
- package/dist/app/api/providers/route.d.ts +5 -13
- package/dist/app/api/providers/route.d.ts.map +1 -1
- package/dist/app/api/providers/route.js +5 -80
- package/dist/app/api/tasks/[taskId]/buildRoute.d.ts +19 -0
- package/dist/app/api/tasks/[taskId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/[taskId]/buildRoute.js +125 -0
- package/dist/app/api/tasks/[taskId]/route.d.ts +7 -57
- package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
- package/dist/app/api/tasks/[taskId]/route.js +6 -144
- package/dist/app/api/tasks/buildRoute.d.ts +36 -0
- package/dist/app/api/tasks/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/buildRoute.js +85 -0
- package/dist/app/api/tasks/callback/buildRoute.d.ts +6 -0
- package/dist/app/api/tasks/callback/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/callback/buildRoute.js +244 -0
- package/dist/app/api/tasks/callback/route.d.ts +2 -1
- package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
- package/dist/app/api/tasks/callback/route.js +4 -244
- package/dist/app/api/tasks/route.d.ts +5 -13
- package/dist/app/api/tasks/route.d.ts.map +1 -1
- package/dist/app/api/tasks/route.js +5 -90
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts +10 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts.map +1 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.js +36 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +2 -7
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +3 -37
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts +16 -0
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.js +89 -0
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts +5 -31
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/[workspaceId]/route.js +5 -89
- package/dist/app/api/workspaces/buildRoute.d.ts +42 -0
- package/dist/app/api/workspaces/buildRoute.d.ts.map +1 -0
- package/dist/app/api/workspaces/buildRoute.js +78 -0
- package/dist/app/api/workspaces/route.d.ts +7 -27
- package/dist/app/api/workspaces/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/route.js +6 -82
- package/dist/lib/functions/functionSchema.d.ts +56 -56
- package/dist/lib/functions/handleFunction/getFunction.d.ts +4 -4
- package/dist/lib/mcpServers/mcpServerSchema.d.ts +20 -20
- package/dist/lib/prisma/index.d.ts +2 -5
- package/dist/lib/prisma/index.d.ts.map +1 -1
- package/dist/lib/prisma/index.js +6 -78
- package/package.json +4 -12
- package/.next/server/chunks/[root-of-the-server]__228bff78._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__3307123c._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__ff90af03._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__ff90af03._.js.map +0 -1
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → KhKDqyqUf75vkMRrXaWJf}/_buildManifest.js +0 -0
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → KhKDqyqUf75vkMRrXaWJf}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → KhKDqyqUf75vkMRrXaWJf}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { headers } from 'next/headers';
|
|
2
|
+
import { ApiKeyType, TransportType } from '@prisma/client';
|
|
3
|
+
import { NextResponse } from 'next/server';
|
|
4
|
+
import { cacheHeaders } from '../../../../../../lib/cache/cacheHeaders';
|
|
5
|
+
import { getApiKey } from '../../../../../../lib/apiKeys/getApiKey';
|
|
6
|
+
import { validate } from 'uuid';
|
|
7
|
+
import { serializeApiMcpServer } from '../../../../../../lib/mcpServers/serializeApiMcpServer';
|
|
8
|
+
import { mcpServerSchema } from '../../../../../../lib/mcpServers/mcpServerSchema';
|
|
9
|
+
const validateIds = ({ assistantId, mcpServerId, }) => {
|
|
10
|
+
if (!validate(assistantId)) {
|
|
11
|
+
return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
|
|
12
|
+
}
|
|
13
|
+
if (!validate(mcpServerId)) {
|
|
14
|
+
return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
export const buildGET = ({ prisma }) => async (_request, props) => {
|
|
19
|
+
const { assistantId, mcpServerId } = await props.params;
|
|
20
|
+
const headersList = await headers();
|
|
21
|
+
const authorization = headersList.get('authorization');
|
|
22
|
+
if (!authorization) {
|
|
23
|
+
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
24
|
+
}
|
|
25
|
+
const privateApiKey = await getApiKey({
|
|
26
|
+
type: ApiKeyType.PRIVATE,
|
|
27
|
+
authorization,
|
|
28
|
+
prisma,
|
|
29
|
+
});
|
|
30
|
+
if (!privateApiKey) {
|
|
31
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
32
|
+
}
|
|
33
|
+
const validationError = validateIds({ assistantId, mcpServerId });
|
|
34
|
+
if (validationError)
|
|
35
|
+
return validationError;
|
|
36
|
+
const mcpServer = await prisma.mcpServer.findFirst({
|
|
37
|
+
where: {
|
|
38
|
+
id: mcpServerId,
|
|
39
|
+
assistant: {
|
|
40
|
+
id: assistantId,
|
|
41
|
+
workspaceId: privateApiKey.workspaceId,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
include: {
|
|
45
|
+
sseTransport: true,
|
|
46
|
+
httpTransport: true,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!mcpServer) {
|
|
50
|
+
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
51
|
+
}
|
|
52
|
+
return NextResponse.json({
|
|
53
|
+
mcpServer: serializeApiMcpServer({ mcpServer }),
|
|
54
|
+
}, { headers: cacheHeaders });
|
|
55
|
+
};
|
|
56
|
+
export const buildPATCH = ({ prisma }) => async (request, props) => {
|
|
57
|
+
const { assistantId, mcpServerId } = await props.params;
|
|
58
|
+
const headersList = await headers();
|
|
59
|
+
const authorization = headersList.get('authorization');
|
|
60
|
+
if (!authorization) {
|
|
61
|
+
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
62
|
+
}
|
|
63
|
+
const privateApiKey = await getApiKey({
|
|
64
|
+
authorization,
|
|
65
|
+
type: ApiKeyType.PRIVATE,
|
|
66
|
+
prisma,
|
|
67
|
+
});
|
|
68
|
+
if (!privateApiKey) {
|
|
69
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
70
|
+
}
|
|
71
|
+
const validationError = validateIds({ assistantId, mcpServerId });
|
|
72
|
+
if (validationError)
|
|
73
|
+
return validationError;
|
|
74
|
+
const body = await request.json();
|
|
75
|
+
const parsed = mcpServerSchema.safeParse(body);
|
|
76
|
+
if (!parsed.success) {
|
|
77
|
+
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
|
|
78
|
+
}
|
|
79
|
+
const { transportType, sseTransport, httpTransport } = parsed.data;
|
|
80
|
+
const mcpServer = await prisma.mcpServer.findFirst({
|
|
81
|
+
where: {
|
|
82
|
+
id: mcpServerId,
|
|
83
|
+
assistant: {
|
|
84
|
+
id: assistantId,
|
|
85
|
+
workspaceId: privateApiKey.workspaceId,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
if (!mcpServer) {
|
|
90
|
+
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
91
|
+
}
|
|
92
|
+
const updatedMcpServer = await prisma.mcpServer.update({
|
|
93
|
+
where: {
|
|
94
|
+
id: mcpServerId,
|
|
95
|
+
},
|
|
96
|
+
data: Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
|
|
97
|
+
? {
|
|
98
|
+
sseTransport: {
|
|
99
|
+
update: {
|
|
100
|
+
url: sseTransport.url,
|
|
101
|
+
headers: JSON.parse(sseTransport.headers),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
: {})), (transportType === TransportType.HTTP
|
|
106
|
+
? {
|
|
107
|
+
httpTransport: {
|
|
108
|
+
update: {
|
|
109
|
+
url: httpTransport.url,
|
|
110
|
+
headers: JSON.parse(httpTransport.headers),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
: {})),
|
|
115
|
+
include: {
|
|
116
|
+
sseTransport: true,
|
|
117
|
+
httpTransport: true,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return NextResponse.json({
|
|
121
|
+
mcpServer: serializeApiMcpServer({ mcpServer: updatedMcpServer }),
|
|
122
|
+
}, { headers: cacheHeaders });
|
|
123
|
+
};
|
|
124
|
+
export const buildDELETE = ({ prisma }) => async (_request, props) => {
|
|
125
|
+
const { assistantId, mcpServerId } = await props.params;
|
|
126
|
+
const headersList = await headers();
|
|
127
|
+
const authorization = headersList.get('authorization');
|
|
128
|
+
if (!authorization) {
|
|
129
|
+
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
130
|
+
}
|
|
131
|
+
const privateApiKey = await getApiKey({
|
|
132
|
+
authorization,
|
|
133
|
+
type: ApiKeyType.PRIVATE,
|
|
134
|
+
prisma,
|
|
135
|
+
});
|
|
136
|
+
if (!privateApiKey) {
|
|
137
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
138
|
+
}
|
|
139
|
+
const validationError = validateIds({ assistantId, mcpServerId });
|
|
140
|
+
if (validationError)
|
|
141
|
+
return validationError;
|
|
142
|
+
const mcpServer = await prisma.mcpServer.findFirst({
|
|
143
|
+
where: {
|
|
144
|
+
id: mcpServerId,
|
|
145
|
+
assistant: {
|
|
146
|
+
id: assistantId,
|
|
147
|
+
workspaceId: privateApiKey.workspaceId,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
if (!mcpServer) {
|
|
152
|
+
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
153
|
+
}
|
|
154
|
+
const deletedMcpServer = await prisma.mcpServer.delete({
|
|
155
|
+
where: { id: mcpServerId },
|
|
156
|
+
include: {
|
|
157
|
+
sseTransport: true,
|
|
158
|
+
httpTransport: true,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
return NextResponse.json({
|
|
162
|
+
mcpServer: serializeApiMcpServer({ mcpServer: deletedMcpServer }),
|
|
163
|
+
}, { headers: cacheHeaders });
|
|
164
|
+
};
|
|
165
|
+
export const buildOPTIONS = () => () => NextResponse.json({}, {
|
|
166
|
+
headers: cacheHeaders,
|
|
167
|
+
});
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
-
export declare const buildGET: ({ prisma: providedPrisma }?: {
|
|
4
|
-
prisma?: PrismaClient;
|
|
5
|
-
}) => (_request: NextRequest, props: {
|
|
1
|
+
export declare const GET: (_request: import("next/server").NextRequest, props: {
|
|
6
2
|
params: Promise<{
|
|
7
3
|
assistantId: string;
|
|
8
4
|
mcpServerId: string;
|
|
9
5
|
}>;
|
|
10
|
-
}) => Promise<NextResponse<{
|
|
6
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
11
7
|
error: string;
|
|
12
|
-
}> | NextResponse<{
|
|
8
|
+
}> | import("next/server").NextResponse<{
|
|
13
9
|
mcpServer: {
|
|
14
10
|
id: string;
|
|
15
11
|
transportType: import("@prisma/client").$Enums.TransportType;
|
|
@@ -31,17 +27,14 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
|
|
|
31
27
|
updatedAt: string;
|
|
32
28
|
};
|
|
33
29
|
}>>;
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const buildPATCH: ({ prisma: providedPrisma }?: {
|
|
36
|
-
prisma?: PrismaClient;
|
|
37
|
-
}) => (request: NextRequest, props: {
|
|
30
|
+
export declare const PATCH: (request: import("next/server").NextRequest, props: {
|
|
38
31
|
params: Promise<{
|
|
39
32
|
assistantId: string;
|
|
40
33
|
mcpServerId: string;
|
|
41
34
|
}>;
|
|
42
|
-
}) => Promise<NextResponse<{
|
|
35
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
43
36
|
error: string;
|
|
44
|
-
}> | NextResponse<{
|
|
37
|
+
}> | import("next/server").NextResponse<{
|
|
45
38
|
mcpServer: {
|
|
46
39
|
id: string;
|
|
47
40
|
transportType: import("@prisma/client").$Enums.TransportType;
|
|
@@ -63,17 +56,14 @@ export declare const buildPATCH: ({ prisma: providedPrisma }?: {
|
|
|
63
56
|
updatedAt: string;
|
|
64
57
|
};
|
|
65
58
|
}>>;
|
|
66
|
-
export declare const
|
|
67
|
-
export declare const buildDELETE: ({ prisma: providedPrisma }?: {
|
|
68
|
-
prisma?: PrismaClient;
|
|
69
|
-
}) => (_request: NextRequest, props: {
|
|
59
|
+
export declare const DELETE: (_request: import("next/server").NextRequest, props: {
|
|
70
60
|
params: Promise<{
|
|
71
61
|
assistantId: string;
|
|
72
62
|
mcpServerId: string;
|
|
73
63
|
}>;
|
|
74
|
-
}) => Promise<NextResponse<{
|
|
64
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
75
65
|
error: string;
|
|
76
|
-
}> | NextResponse<{
|
|
66
|
+
}> | import("next/server").NextResponse<{
|
|
77
67
|
mcpServer: {
|
|
78
68
|
id: string;
|
|
79
69
|
transportType: import("@prisma/client").$Enums.TransportType;
|
|
@@ -95,6 +85,5 @@ export declare const buildDELETE: ({ prisma: providedPrisma }?: {
|
|
|
95
85
|
updatedAt: string;
|
|
96
86
|
};
|
|
97
87
|
}>>;
|
|
98
|
-
export declare const
|
|
99
|
-
export declare const OPTIONS: () => NextResponse<{}>;
|
|
88
|
+
export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
|
|
100
89
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyB,CAAA;AAE3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0B,CAAA;AAE7C,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
|
|
@@ -1,174 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { validate } from 'uuid';
|
|
8
|
-
import { serializeApiMcpServer } from '../../../../../../lib/mcpServers/serializeApiMcpServer';
|
|
9
|
-
import { mcpServerSchema } from '../../../../../../lib/mcpServers/mcpServerSchema';
|
|
10
|
-
export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
|
|
11
|
-
const prisma = resolvePrisma(providedPrisma);
|
|
12
|
-
const { assistantId, mcpServerId } = await props.params;
|
|
13
|
-
const headersList = await headers();
|
|
14
|
-
const authorization = headersList.get('authorization');
|
|
15
|
-
if (!authorization) {
|
|
16
|
-
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
17
|
-
}
|
|
18
|
-
const privateApiKey = await getApiKey({
|
|
19
|
-
type: ApiKeyType.PRIVATE,
|
|
20
|
-
authorization,
|
|
21
|
-
prisma,
|
|
22
|
-
});
|
|
23
|
-
if (!privateApiKey) {
|
|
24
|
-
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
25
|
-
}
|
|
26
|
-
if (!validate(assistantId)) {
|
|
27
|
-
return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
|
|
28
|
-
}
|
|
29
|
-
if (!validate(mcpServerId)) {
|
|
30
|
-
return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
|
|
31
|
-
}
|
|
32
|
-
const mcpServer = await prisma.mcpServer.findFirst({
|
|
33
|
-
where: {
|
|
34
|
-
id: mcpServerId,
|
|
35
|
-
assistant: {
|
|
36
|
-
id: assistantId,
|
|
37
|
-
workspaceId: privateApiKey.workspaceId,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
include: {
|
|
41
|
-
sseTransport: true,
|
|
42
|
-
httpTransport: true,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
if (!mcpServer) {
|
|
46
|
-
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
47
|
-
}
|
|
48
|
-
return NextResponse.json({
|
|
49
|
-
mcpServer: serializeApiMcpServer({ mcpServer }),
|
|
50
|
-
}, { headers: cacheHeaders });
|
|
51
|
-
};
|
|
52
|
-
export const GET = ((...args) => buildGET()(...args));
|
|
53
|
-
export const buildPATCH = ({ prisma: providedPrisma } = {}) => async (request, props) => {
|
|
54
|
-
const prisma = resolvePrisma(providedPrisma);
|
|
55
|
-
const { assistantId, mcpServerId } = await props.params;
|
|
56
|
-
const headersList = await headers();
|
|
57
|
-
const authorization = headersList.get('authorization');
|
|
58
|
-
if (!authorization) {
|
|
59
|
-
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
60
|
-
}
|
|
61
|
-
const privateApiKey = await getApiKey({
|
|
62
|
-
authorization,
|
|
63
|
-
type: ApiKeyType.PRIVATE,
|
|
64
|
-
prisma,
|
|
65
|
-
});
|
|
66
|
-
if (!privateApiKey) {
|
|
67
|
-
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
68
|
-
}
|
|
69
|
-
if (!validate(assistantId)) {
|
|
70
|
-
return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
|
|
71
|
-
}
|
|
72
|
-
if (!validate(mcpServerId)) {
|
|
73
|
-
return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
|
|
74
|
-
}
|
|
75
|
-
const body = await request.json();
|
|
76
|
-
const parsed = mcpServerSchema.safeParse(body);
|
|
77
|
-
if (!parsed.success) {
|
|
78
|
-
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
|
|
79
|
-
}
|
|
80
|
-
const { transportType, sseTransport, httpTransport } = parsed.data;
|
|
81
|
-
const mcpServer = await prisma.mcpServer.findFirst({
|
|
82
|
-
where: {
|
|
83
|
-
id: mcpServerId,
|
|
84
|
-
assistant: {
|
|
85
|
-
id: assistantId,
|
|
86
|
-
workspaceId: privateApiKey.workspaceId,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
if (!mcpServer) {
|
|
91
|
-
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
92
|
-
}
|
|
93
|
-
const updatedMcpServer = await prisma.mcpServer.update({
|
|
94
|
-
where: {
|
|
95
|
-
id: mcpServerId,
|
|
96
|
-
},
|
|
97
|
-
data: Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
|
|
98
|
-
? {
|
|
99
|
-
sseTransport: {
|
|
100
|
-
update: {
|
|
101
|
-
url: sseTransport.url,
|
|
102
|
-
headers: JSON.parse(sseTransport.headers),
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
: {})), (transportType === TransportType.HTTP
|
|
107
|
-
? {
|
|
108
|
-
httpTransport: {
|
|
109
|
-
update: {
|
|
110
|
-
url: httpTransport.url,
|
|
111
|
-
headers: JSON.parse(httpTransport.headers),
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
: {})),
|
|
116
|
-
include: {
|
|
117
|
-
sseTransport: true,
|
|
118
|
-
httpTransport: true,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
return NextResponse.json({
|
|
122
|
-
mcpServer: serializeApiMcpServer({ mcpServer: updatedMcpServer }),
|
|
123
|
-
}, { headers: cacheHeaders });
|
|
124
|
-
};
|
|
125
|
-
export const PATCH = ((...args) => buildPATCH()(...args));
|
|
126
|
-
export const buildDELETE = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
|
|
127
|
-
const prisma = resolvePrisma(providedPrisma);
|
|
128
|
-
const { assistantId, mcpServerId } = await props.params;
|
|
129
|
-
const headersList = await headers();
|
|
130
|
-
const authorization = headersList.get('authorization');
|
|
131
|
-
if (!authorization) {
|
|
132
|
-
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
133
|
-
}
|
|
134
|
-
const privateApiKey = await getApiKey({
|
|
135
|
-
authorization,
|
|
136
|
-
type: ApiKeyType.PRIVATE,
|
|
137
|
-
prisma,
|
|
138
|
-
});
|
|
139
|
-
if (!privateApiKey) {
|
|
140
|
-
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
141
|
-
}
|
|
142
|
-
if (!validate(assistantId)) {
|
|
143
|
-
return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
|
|
144
|
-
}
|
|
145
|
-
if (!validate(mcpServerId)) {
|
|
146
|
-
return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
|
|
147
|
-
}
|
|
148
|
-
const mcpServer = await prisma.mcpServer.findFirst({
|
|
149
|
-
where: {
|
|
150
|
-
id: mcpServerId,
|
|
151
|
-
assistant: {
|
|
152
|
-
id: assistantId,
|
|
153
|
-
workspaceId: privateApiKey.workspaceId,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
if (!mcpServer) {
|
|
158
|
-
return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
|
|
159
|
-
}
|
|
160
|
-
const deletedMcpServer = await prisma.mcpServer.delete({
|
|
161
|
-
where: { id: mcpServerId },
|
|
162
|
-
include: {
|
|
163
|
-
sseTransport: true,
|
|
164
|
-
httpTransport: true,
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
return NextResponse.json({
|
|
168
|
-
mcpServer: serializeApiMcpServer({ mcpServer: deletedMcpServer }),
|
|
169
|
-
}, { headers: cacheHeaders });
|
|
170
|
-
};
|
|
171
|
-
export const DELETE = ((...args) => buildDELETE()(...args));
|
|
172
|
-
export const OPTIONS = () => NextResponse.json({}, {
|
|
173
|
-
headers: cacheHeaders,
|
|
174
|
-
});
|
|
1
|
+
import { prisma } from '../../../../../../lib/prisma';
|
|
2
|
+
import { buildDELETE, buildGET, buildOPTIONS, buildPATCH, } from './buildRoute';
|
|
3
|
+
export const GET = buildGET({ prisma });
|
|
4
|
+
export const PATCH = buildPATCH({ prisma });
|
|
5
|
+
export const DELETE = buildDELETE({ prisma });
|
|
6
|
+
export const OPTIONS = buildOPTIONS();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { type PrismaClient } from '@prisma/client';
|
|
3
|
+
type RouteProps = {
|
|
4
|
+
params: Promise<{
|
|
5
|
+
assistantId: string;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
export declare const buildGET: ({ prisma }: {
|
|
9
|
+
prisma: PrismaClient;
|
|
10
|
+
}) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
|
|
11
|
+
error: string;
|
|
12
|
+
}> | NextResponse<{
|
|
13
|
+
mcpServers: {
|
|
14
|
+
id: string;
|
|
15
|
+
transportType: import("@prisma/client").$Enums.TransportType;
|
|
16
|
+
sseTransport: {
|
|
17
|
+
id: string;
|
|
18
|
+
url: string;
|
|
19
|
+
headers: PrismaJson.SseTransportHeaders;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
} | null;
|
|
23
|
+
httpTransport: {
|
|
24
|
+
id: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers: PrismaJson.HttpTransportHeaders;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
} | null;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}[];
|
|
33
|
+
}>>;
|
|
34
|
+
export declare const buildPOST: ({ prisma }: {
|
|
35
|
+
prisma: PrismaClient;
|
|
36
|
+
}) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<{
|
|
37
|
+
error: string;
|
|
38
|
+
}> | NextResponse<{
|
|
39
|
+
mcpServer: {
|
|
40
|
+
id: string;
|
|
41
|
+
transportType: import("@prisma/client").$Enums.TransportType;
|
|
42
|
+
sseTransport: {
|
|
43
|
+
id: string;
|
|
44
|
+
url: string;
|
|
45
|
+
headers: PrismaJson.SseTransportHeaders;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
} | null;
|
|
49
|
+
httpTransport: {
|
|
50
|
+
id: string;
|
|
51
|
+
url: string;
|
|
52
|
+
headers: PrismaJson.HttpTransportHeaders;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
} | null;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
};
|
|
59
|
+
}>>;
|
|
60
|
+
export declare const buildOPTIONS: () => () => NextResponse<{}>;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=buildRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAO7E,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAuD9C,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAoF7C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { ApiKeyType, TransportType } from '@prisma/client';
|
|
3
|
+
import { headers } from 'next/headers';
|
|
4
|
+
import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
|
|
5
|
+
import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
|
|
6
|
+
import { serializeApiMcpServer } from '../../../../../lib/mcpServers/serializeApiMcpServer';
|
|
7
|
+
import { mcpServerSchema } from '../../../../../lib/mcpServers/mcpServerSchema';
|
|
8
|
+
export const buildGET = ({ prisma }) => async (_request, props) => {
|
|
9
|
+
const { assistantId } = await props.params;
|
|
10
|
+
const headersList = await headers();
|
|
11
|
+
const authorization = headersList.get('authorization');
|
|
12
|
+
if (!authorization) {
|
|
13
|
+
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
14
|
+
}
|
|
15
|
+
const privateApiKey = await getApiKey({
|
|
16
|
+
type: ApiKeyType.PRIVATE,
|
|
17
|
+
authorization,
|
|
18
|
+
prisma,
|
|
19
|
+
});
|
|
20
|
+
if (!privateApiKey) {
|
|
21
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
22
|
+
}
|
|
23
|
+
const assistant = await prisma.assistant.findFirst({
|
|
24
|
+
where: {
|
|
25
|
+
id: assistantId,
|
|
26
|
+
workspaceId: privateApiKey.workspaceId,
|
|
27
|
+
},
|
|
28
|
+
include: {
|
|
29
|
+
mcpServers: {
|
|
30
|
+
include: {
|
|
31
|
+
stdioTransport: true,
|
|
32
|
+
sseTransport: true,
|
|
33
|
+
httpTransport: true,
|
|
34
|
+
},
|
|
35
|
+
orderBy: {
|
|
36
|
+
createdAt: 'desc',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
if (!assistant) {
|
|
42
|
+
return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
|
|
43
|
+
}
|
|
44
|
+
return NextResponse.json({
|
|
45
|
+
mcpServers: assistant.mcpServers.map((mcpServer) => serializeApiMcpServer({
|
|
46
|
+
mcpServer,
|
|
47
|
+
})),
|
|
48
|
+
}, { headers: cacheHeaders });
|
|
49
|
+
};
|
|
50
|
+
export const buildPOST = ({ prisma }) => async (request, props) => {
|
|
51
|
+
const { assistantId } = await props.params;
|
|
52
|
+
const headersList = await headers();
|
|
53
|
+
const authorization = headersList.get('authorization');
|
|
54
|
+
if (!authorization) {
|
|
55
|
+
return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
|
|
56
|
+
}
|
|
57
|
+
const privateApiKey = await getApiKey({
|
|
58
|
+
authorization,
|
|
59
|
+
type: ApiKeyType.PRIVATE,
|
|
60
|
+
prisma,
|
|
61
|
+
});
|
|
62
|
+
if (!privateApiKey) {
|
|
63
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
64
|
+
}
|
|
65
|
+
const body = await request.json();
|
|
66
|
+
const parsed = mcpServerSchema.safeParse(body);
|
|
67
|
+
if (!parsed.success) {
|
|
68
|
+
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
|
|
69
|
+
}
|
|
70
|
+
const { transportType, sseTransport, httpTransport } = parsed.data;
|
|
71
|
+
const workspaceId = privateApiKey.workspaceId;
|
|
72
|
+
const assistant = await prisma.assistant.findFirst({
|
|
73
|
+
where: { id: assistantId, workspaceId },
|
|
74
|
+
});
|
|
75
|
+
if (!assistant) {
|
|
76
|
+
return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
|
|
77
|
+
}
|
|
78
|
+
const mcpServer = await prisma.mcpServer.create({
|
|
79
|
+
data: Object.assign(Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
|
|
80
|
+
? {
|
|
81
|
+
sseTransport: {
|
|
82
|
+
create: {
|
|
83
|
+
url: sseTransport.url,
|
|
84
|
+
headers: JSON.parse(sseTransport.headers),
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
: {})), (transportType === TransportType.HTTP
|
|
89
|
+
? {
|
|
90
|
+
httpTransport: {
|
|
91
|
+
create: {
|
|
92
|
+
url: httpTransport.url,
|
|
93
|
+
headers: JSON.parse(httpTransport.headers),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
: {})), { assistant: {
|
|
98
|
+
connect: {
|
|
99
|
+
id: assistantId,
|
|
100
|
+
workspaceId,
|
|
101
|
+
},
|
|
102
|
+
} }),
|
|
103
|
+
include: {
|
|
104
|
+
stdioTransport: true,
|
|
105
|
+
sseTransport: true,
|
|
106
|
+
httpTransport: true,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
return NextResponse.json({
|
|
110
|
+
mcpServer: serializeApiMcpServer({ mcpServer }),
|
|
111
|
+
}, { headers: cacheHeaders });
|
|
112
|
+
};
|
|
113
|
+
export const buildOPTIONS = () => () => NextResponse.json({}, {
|
|
114
|
+
headers: cacheHeaders,
|
|
115
|
+
});
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { type PrismaClient } from '@prisma/client';
|
|
3
|
-
export declare const buildGET: ({ prisma: providedPrisma }?: {
|
|
4
|
-
prisma?: PrismaClient;
|
|
5
|
-
}) => (_request: NextRequest, props: {
|
|
1
|
+
export declare const GET: (_request: import("next/server").NextRequest, props: {
|
|
6
2
|
params: Promise<{
|
|
7
3
|
assistantId: string;
|
|
8
4
|
}>;
|
|
9
|
-
}) => Promise<NextResponse<{
|
|
5
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
10
6
|
error: string;
|
|
11
|
-
}> | NextResponse<{
|
|
7
|
+
}> | import("next/server").NextResponse<{
|
|
12
8
|
mcpServers: {
|
|
13
9
|
id: string;
|
|
14
10
|
transportType: import("@prisma/client").$Enums.TransportType;
|
|
@@ -30,16 +26,13 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
|
|
|
30
26
|
updatedAt: string;
|
|
31
27
|
}[];
|
|
32
28
|
}>>;
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const buildPOST: ({ prisma: providedPrisma }?: {
|
|
35
|
-
prisma?: PrismaClient;
|
|
36
|
-
}) => (request: NextRequest, props: {
|
|
29
|
+
export declare const POST: (request: import("next/server").NextRequest, props: {
|
|
37
30
|
params: Promise<{
|
|
38
31
|
assistantId: string;
|
|
39
32
|
}>;
|
|
40
|
-
}) => Promise<NextResponse<{
|
|
33
|
+
}) => Promise<import("next/server").NextResponse<{
|
|
41
34
|
error: string;
|
|
42
|
-
}> | NextResponse<{
|
|
35
|
+
}> | import("next/server").NextResponse<{
|
|
43
36
|
mcpServer: {
|
|
44
37
|
id: string;
|
|
45
38
|
transportType: import("@prisma/client").$Enums.TransportType;
|
|
@@ -61,6 +54,5 @@ export declare const buildPOST: ({ prisma: providedPrisma }?: {
|
|
|
61
54
|
updatedAt: string;
|
|
62
55
|
};
|
|
63
56
|
}>>;
|
|
64
|
-
export declare const
|
|
65
|
-
export declare const OPTIONS: () => NextResponse<{}>;
|
|
57
|
+
export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
|
|
66
58
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/route.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
|