@superinterface/server 1.0.24 → 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.
Files changed (266) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_btwyo7 +1 -1
  5. package/.next/fallback-build-manifest.json +2 -2
  6. package/.next/server/app/_not-found.html +1 -1
  7. package/.next/server/app/_not-found.rsc +1 -1
  8. package/.next/server/app/api/api-keys/[apiKeyId]/route.js +1 -1
  9. package/.next/server/app/api/api-keys/[apiKeyId]/route.js.nft.json +1 -1
  10. package/.next/server/app/api/api-keys/route.js +1 -1
  11. package/.next/server/app/api/api-keys/route.js.nft.json +1 -1
  12. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js +1 -1
  13. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js.nft.json +1 -1
  14. package/.next/server/app/api/assistants/[assistantId]/functions/route.js +1 -1
  15. package/.next/server/app/api/assistants/[assistantId]/functions/route.js.nft.json +1 -1
  16. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js +1 -1
  17. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js.nft.json +1 -1
  18. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +1 -1
  19. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js.nft.json +1 -1
  20. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js +1 -1
  21. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js.nft.json +1 -1
  22. package/.next/server/app/api/assistants/[assistantId]/route.js +1 -1
  23. package/.next/server/app/api/assistants/[assistantId]/route.js.nft.json +1 -1
  24. package/.next/server/app/api/assistants/route.js +1 -1
  25. package/.next/server/app/api/assistants/route.js.nft.json +1 -1
  26. package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
  27. package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
  28. package/.next/server/app/api/files/route.js +1 -1
  29. package/.next/server/app/api/files/route.js.nft.json +1 -1
  30. package/.next/server/app/api/messages/route.js +1 -1
  31. package/.next/server/app/api/messages/route.js.nft.json +1 -1
  32. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js +1 -1
  33. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js.nft.json +1 -1
  34. package/.next/server/app/api/providers/[modelProviderId]/models/route.js +1 -1
  35. package/.next/server/app/api/providers/[modelProviderId]/models/route.js.nft.json +1 -1
  36. package/.next/server/app/api/providers/[modelProviderId]/route.js +1 -1
  37. package/.next/server/app/api/providers/[modelProviderId]/route.js.nft.json +1 -1
  38. package/.next/server/app/api/providers/route.js +1 -1
  39. package/.next/server/app/api/providers/route.js.nft.json +1 -1
  40. package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
  41. package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
  42. package/.next/server/app/api/tasks/callback/route.js +1 -1
  43. package/.next/server/app/api/tasks/callback/route.js.nft.json +1 -1
  44. package/.next/server/app/api/tasks/route.js +1 -1
  45. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  46. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js +1 -1
  47. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js.nft.json +1 -1
  48. package/.next/server/app/api/workspaces/[workspaceId]/route.js +1 -1
  49. package/.next/server/app/api/workspaces/[workspaceId]/route.js.nft.json +1 -1
  50. package/.next/server/app/api/workspaces/route.js +1 -1
  51. package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  52. package/.next/server/app/index.html +1 -1
  53. package/.next/server/app/index.rsc +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
  55. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js +38 -0
  71. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js.map +1 -0
  72. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  73. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  76. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  77. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  78. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  79. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  80. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  81. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  82. package/.next/server/chunks/[root-of-the-server]__676affb1._.js +1 -1
  83. package/.next/server/chunks/[root-of-the-server]__676affb1._.js.map +1 -1
  84. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  85. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  86. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  87. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  88. package/.next/server/chunks/[root-of-the-server]__a878c913._.js +1 -1
  89. package/.next/server/chunks/[root-of-the-server]__a878c913._.js.map +1 -1
  90. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  91. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  92. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  93. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  94. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  95. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  96. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js +38 -0
  97. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js.map +1 -0
  98. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  99. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  100. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  101. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  102. package/.next/server/functions-config-manifest.json +1 -8
  103. package/.next/server/pages/404.html +1 -1
  104. package/.next/server/pages/500.html +1 -1
  105. package/.next/trace +1 -1
  106. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts +52 -0
  107. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts.map +1 -0
  108. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.js +121 -0
  109. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +10 -21
  110. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  111. package/dist/app/api/api-keys/[apiKeyId]/route.js +6 -125
  112. package/dist/app/api/api-keys/buildRoute.d.ts +32 -0
  113. package/dist/app/api/api-keys/buildRoute.d.ts.map +1 -0
  114. package/dist/app/api/api-keys/buildRoute.js +104 -0
  115. package/dist/app/api/api-keys/builders.d.ts +31 -0
  116. package/dist/app/api/api-keys/builders.d.ts.map +1 -0
  117. package/dist/app/api/api-keys/builders.js +109 -0
  118. package/dist/app/api/api-keys/route.d.ts +5 -13
  119. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  120. package/dist/app/api/api-keys/route.js +8 -108
  121. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts +120 -0
  122. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts.map +1 -0
  123. package/dist/app/api/assistants/[assistantId]/buildRoute.js +226 -0
  124. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts +167 -0
  125. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts.map +1 -0
  126. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.js +184 -0
  127. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +10 -21
  128. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  129. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +6 -191
  130. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts +114 -0
  131. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts.map +1 -0
  132. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.js +117 -0
  133. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +7 -15
  134. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  135. package/dist/app/api/assistants/[assistantId]/functions/route.js +5 -122
  136. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts +40 -0
  137. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts.map +1 -0
  138. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.js +85 -0
  139. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +7 -15
  140. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  141. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +5 -90
  142. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts +89 -0
  143. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts.map +1 -0
  144. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.js +167 -0
  145. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +10 -21
  146. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  147. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +6 -174
  148. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts +62 -0
  149. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts.map +1 -0
  150. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.js +115 -0
  151. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +7 -15
  152. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  153. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +5 -120
  154. package/dist/app/api/assistants/[assistantId]/route.d.ts +11 -22
  155. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  156. package/dist/app/api/assistants/[assistantId]/route.js +6 -233
  157. package/dist/app/api/assistants/buildRoute.d.ts +121 -0
  158. package/dist/app/api/assistants/buildRoute.d.ts.map +1 -0
  159. package/dist/app/api/assistants/buildRoute.js +144 -0
  160. package/dist/app/api/assistants/route.d.ts +7 -13
  161. package/dist/app/api/assistants/route.d.ts.map +1 -1
  162. package/dist/app/api/assistants/route.js +6 -148
  163. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts +18 -0
  164. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts.map +1 -0
  165. package/dist/app/api/files/[fileId]/contents/buildRoute.js +81 -0
  166. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -13
  167. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  168. package/dist/app/api/files/[fileId]/contents/route.js +4 -84
  169. package/dist/app/api/files/buildRoute.d.ts +14 -0
  170. package/dist/app/api/files/buildRoute.d.ts.map +1 -0
  171. package/dist/app/api/files/buildRoute.js +88 -0
  172. package/dist/app/api/files/route.d.ts +4 -10
  173. package/dist/app/api/files/route.d.ts.map +1 -1
  174. package/dist/app/api/files/route.js +4 -91
  175. package/dist/app/api/messages/buildRoute.d.ts +34 -0
  176. package/dist/app/api/messages/buildRoute.d.ts.map +1 -0
  177. package/dist/app/api/messages/buildRoute.js +607 -0
  178. package/dist/app/api/messages/lib/initialMessagesResponse.d.ts.map +1 -1
  179. package/dist/app/api/messages/lib/initialMessagesResponse.js +1 -1
  180. package/dist/app/api/messages/route.d.ts +10 -22
  181. package/dist/app/api/messages/route.d.ts.map +1 -1
  182. package/dist/app/api/messages/route.js +6 -612
  183. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts +24 -0
  184. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts.map +1 -0
  185. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.js +43 -0
  186. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +4 -9
  187. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  188. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -46
  189. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts +61 -0
  190. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts.map +1 -0
  191. package/dist/app/api/providers/[modelProviderId]/buildRoute.js +134 -0
  192. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts +19 -0
  193. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts.map +1 -0
  194. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.js +43 -0
  195. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +4 -9
  196. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  197. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -46
  198. package/dist/app/api/providers/[modelProviderId]/route.d.ts +10 -21
  199. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  200. package/dist/app/api/providers/[modelProviderId]/route.js +6 -141
  201. package/dist/app/api/providers/buildRoute.d.ts +38 -0
  202. package/dist/app/api/providers/buildRoute.d.ts.map +1 -0
  203. package/dist/app/api/providers/buildRoute.js +75 -0
  204. package/dist/app/api/providers/route.d.ts +5 -13
  205. package/dist/app/api/providers/route.d.ts.map +1 -1
  206. package/dist/app/api/providers/route.js +5 -80
  207. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts +19 -0
  208. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts.map +1 -0
  209. package/dist/app/api/tasks/[taskId]/buildRoute.js +125 -0
  210. package/dist/app/api/tasks/[taskId]/route.d.ts +7 -57
  211. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  212. package/dist/app/api/tasks/[taskId]/route.js +6 -144
  213. package/dist/app/api/tasks/buildRoute.d.ts +36 -0
  214. package/dist/app/api/tasks/buildRoute.d.ts.map +1 -0
  215. package/dist/app/api/tasks/buildRoute.js +85 -0
  216. package/dist/app/api/tasks/callback/buildRoute.d.ts +6 -0
  217. package/dist/app/api/tasks/callback/buildRoute.d.ts.map +1 -0
  218. package/dist/app/api/tasks/callback/buildRoute.js +244 -0
  219. package/dist/app/api/tasks/callback/route.d.ts +2 -1
  220. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  221. package/dist/app/api/tasks/callback/route.js +4 -244
  222. package/dist/app/api/tasks/route.d.ts +5 -13
  223. package/dist/app/api/tasks/route.d.ts.map +1 -1
  224. package/dist/app/api/tasks/route.js +5 -90
  225. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts +10 -0
  226. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts.map +1 -0
  227. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.js +36 -0
  228. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +2 -7
  229. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  230. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +3 -37
  231. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts +16 -0
  232. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts.map +1 -0
  233. package/dist/app/api/workspaces/[workspaceId]/buildRoute.js +89 -0
  234. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +5 -31
  235. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  236. package/dist/app/api/workspaces/[workspaceId]/route.js +5 -89
  237. package/dist/app/api/workspaces/buildRoute.d.ts +42 -0
  238. package/dist/app/api/workspaces/buildRoute.d.ts.map +1 -0
  239. package/dist/app/api/workspaces/buildRoute.js +78 -0
  240. package/dist/app/api/workspaces/route.d.ts +7 -27
  241. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  242. package/dist/app/api/workspaces/route.js +6 -82
  243. package/dist/lib/functions/functionSchema.d.ts +56 -56
  244. package/dist/lib/functions/handleFunction/getFunction.d.ts +4 -4
  245. package/dist/lib/mcpServers/mcpServerSchema.d.ts +20 -20
  246. package/dist/lib/prisma/index.d.ts +2 -5
  247. package/dist/lib/prisma/index.d.ts.map +1 -1
  248. package/dist/lib/prisma/index.js +5 -70
  249. package/package.json +2 -2
  250. package/.next/server/chunks/[root-of-the-server]__228bff78._.js +0 -38
  251. package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +0 -1
  252. package/.next/server/chunks/[root-of-the-server]__3307123c._.js +0 -38
  253. package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +0 -1
  254. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +0 -38
  255. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +0 -1
  256. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +0 -38
  257. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +0 -1
  258. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +0 -38
  259. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +0 -1
  260. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +0 -38
  261. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +0 -1
  262. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js +0 -38
  263. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js.map +0 -1
  264. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_buildManifest.js +0 -0
  265. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_clientMiddlewareManifest.json +0 -0
  266. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_ssgManifest.js +0 -0
@@ -0,0 +1,117 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { ApiKeyType } 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 { serializeApiFunction } from '../../../../../lib/functions/serializeApiFunction';
7
+ import { functionSchema } from '../../../../../lib/functions/functionSchema';
8
+ import { createFunction } from '../../../../../lib/functions/createFunction';
9
+ export const buildGET = ({ prisma }) => async (_request, props) => {
10
+ const { assistantId } = await props.params;
11
+ const headersList = await headers();
12
+ const authorization = headersList.get('authorization');
13
+ if (!authorization) {
14
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
15
+ }
16
+ const privateApiKey = await getApiKey({
17
+ type: ApiKeyType.PRIVATE,
18
+ authorization,
19
+ prisma,
20
+ });
21
+ if (!privateApiKey) {
22
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
23
+ }
24
+ const assistant = await prisma.assistant.findFirst({
25
+ where: {
26
+ id: assistantId,
27
+ workspaceId: privateApiKey.workspaceId,
28
+ },
29
+ include: {
30
+ functions: {
31
+ include: {
32
+ handler: {
33
+ include: {
34
+ requestHandler: true,
35
+ firecrawlHandler: true,
36
+ replicateHandler: true,
37
+ clientToolHandler: true,
38
+ assistantHandler: true,
39
+ createTaskHandler: true,
40
+ listTasksHandler: true,
41
+ updateTaskHandler: true,
42
+ deleteTaskHandler: true,
43
+ },
44
+ },
45
+ },
46
+ orderBy: {
47
+ createdAt: 'desc',
48
+ },
49
+ },
50
+ },
51
+ });
52
+ if (!assistant) {
53
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
54
+ }
55
+ return NextResponse.json({
56
+ functions: assistant.functions.map((fn) => serializeApiFunction({
57
+ fn,
58
+ })),
59
+ }, { headers: cacheHeaders });
60
+ };
61
+ export const buildPOST = ({ prisma }) => async (request, props) => {
62
+ const { assistantId } = await props.params;
63
+ const headersList = await headers();
64
+ const authorization = headersList.get('authorization');
65
+ if (!authorization) {
66
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
67
+ }
68
+ const privateApiKey = await getApiKey({
69
+ authorization,
70
+ type: ApiKeyType.PRIVATE,
71
+ prisma,
72
+ });
73
+ if (!privateApiKey) {
74
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
75
+ }
76
+ const assistant = await prisma.assistant.findFirst({
77
+ where: {
78
+ id: assistantId,
79
+ workspaceId: privateApiKey.workspaceId,
80
+ },
81
+ });
82
+ if (!assistant) {
83
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
84
+ }
85
+ const body = await request.json();
86
+ const parsed = functionSchema.safeParse(body);
87
+ if (!parsed.success) {
88
+ console.error('Function creation error:', parsed.error);
89
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
90
+ }
91
+ const fn = await createFunction({
92
+ parsedInput: parsed.data,
93
+ assistant,
94
+ include: {
95
+ handler: {
96
+ include: {
97
+ requestHandler: true,
98
+ firecrawlHandler: true,
99
+ replicateHandler: true,
100
+ clientToolHandler: true,
101
+ assistantHandler: true,
102
+ createTaskHandler: true,
103
+ listTasksHandler: true,
104
+ updateTaskHandler: true,
105
+ deleteTaskHandler: true,
106
+ },
107
+ },
108
+ },
109
+ prisma,
110
+ });
111
+ return NextResponse.json({
112
+ function: serializeApiFunction({ fn }),
113
+ }, { headers: cacheHeaders });
114
+ };
115
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
116
+ headers: cacheHeaders,
117
+ });
@@ -1,14 +1,10 @@
1
- import { type NextRequest, NextResponse } from 'next/server';
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
  functions: {
13
9
  id: string;
14
10
  openapiSpec: PrismaJson.OpenapiSpec;
@@ -56,16 +52,13 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
56
52
  updatedAt: string;
57
53
  }[];
58
54
  }>>;
59
- export declare const GET: ReturnType<typeof buildGET>;
60
- export declare const buildPOST: ({ prisma: providedPrisma }?: {
61
- prisma?: PrismaClient;
62
- }) => (request: NextRequest, props: {
55
+ export declare const POST: (request: import("next/server").NextRequest, props: {
63
56
  params: Promise<{
64
57
  assistantId: string;
65
58
  }>;
66
- }) => Promise<NextResponse<{
59
+ }) => Promise<import("next/server").NextResponse<{
67
60
  error: string;
68
- }> | NextResponse<{
61
+ }> | import("next/server").NextResponse<{
69
62
  function: {
70
63
  id: string;
71
64
  openapiSpec: PrismaJson.OpenapiSpec;
@@ -113,6 +106,5 @@ export declare const buildPOST: ({ prisma: providedPrisma }?: {
113
106
  updatedAt: string;
114
107
  };
115
108
  }>>;
116
- export declare const POST: ReturnType<typeof buildPOST>;
117
- export declare const OPTIONS: () => NextResponse<{}>;
109
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
118
110
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/functions/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAS9D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,SAAS,GACnB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEF,CAAA;AAEH,eAAO,MAAM,IAAI,EACU,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEvD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/functions/route.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,122 +1,5 @@
1
- import { NextResponse } from 'next/server';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { headers } from 'next/headers';
4
- import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../../lib/prisma';
6
- import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
7
- import { serializeApiFunction } from '../../../../../lib/functions/serializeApiFunction';
8
- import { functionSchema } from '../../../../../lib/functions/functionSchema';
9
- import { createFunction } from '../../../../../lib/functions/createFunction';
10
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
11
- const prisma = resolvePrisma(providedPrisma);
12
- const { assistantId } = 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
- const assistant = await prisma.assistant.findFirst({
27
- where: {
28
- id: assistantId,
29
- workspaceId: privateApiKey.workspaceId,
30
- },
31
- include: {
32
- functions: {
33
- include: {
34
- handler: {
35
- include: {
36
- requestHandler: true,
37
- firecrawlHandler: true,
38
- replicateHandler: true,
39
- clientToolHandler: true,
40
- assistantHandler: true,
41
- createTaskHandler: true,
42
- listTasksHandler: true,
43
- updateTaskHandler: true,
44
- deleteTaskHandler: true,
45
- },
46
- },
47
- },
48
- orderBy: {
49
- createdAt: 'desc',
50
- },
51
- },
52
- },
53
- });
54
- if (!assistant) {
55
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
56
- }
57
- return NextResponse.json({
58
- functions: assistant.functions.map((fn) => serializeApiFunction({
59
- fn,
60
- })),
61
- }, { headers: cacheHeaders });
62
- };
63
- export const GET = ((...args) => buildGET()(...args));
64
- export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request, props) => {
65
- const prisma = resolvePrisma(providedPrisma);
66
- const { assistantId } = await props.params;
67
- const headersList = await headers();
68
- const authorization = headersList.get('authorization');
69
- if (!authorization) {
70
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
71
- }
72
- const privateApiKey = await getApiKey({
73
- authorization,
74
- type: ApiKeyType.PRIVATE,
75
- prisma,
76
- });
77
- if (!privateApiKey) {
78
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
79
- }
80
- const assistant = await prisma.assistant.findFirst({
81
- where: {
82
- id: assistantId,
83
- workspaceId: privateApiKey.workspaceId,
84
- },
85
- });
86
- if (!assistant) {
87
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
88
- }
89
- const body = await request.json();
90
- const parsed = functionSchema.safeParse(body);
91
- if (!parsed.success) {
92
- console.error('Function creation error:', parsed.error);
93
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
94
- }
95
- const fn = await createFunction({
96
- parsedInput: parsed.data,
97
- assistant,
98
- include: {
99
- handler: {
100
- include: {
101
- requestHandler: true,
102
- firecrawlHandler: true,
103
- replicateHandler: true,
104
- clientToolHandler: true,
105
- assistantHandler: true,
106
- createTaskHandler: true,
107
- listTasksHandler: true,
108
- updateTaskHandler: true,
109
- deleteTaskHandler: true,
110
- },
111
- },
112
- },
113
- prisma,
114
- });
115
- return NextResponse.json({
116
- function: serializeApiFunction({ fn }),
117
- }, { headers: cacheHeaders });
118
- };
119
- export const POST = ((...args) => buildPOST()(...args));
120
- export const OPTIONS = () => NextResponse.json({}, {
121
- headers: cacheHeaders,
122
- });
1
+ import { prisma } from '../../../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS, buildPOST, } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const POST = buildPOST({ prisma });
5
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,40 @@
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
+ initialMessages: {
14
+ id: string;
15
+ role: import("@prisma/client").$Enums.MessageRole;
16
+ content: string;
17
+ orderNumber: number;
18
+ assistantId: string | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }[];
22
+ }>>;
23
+ export declare const buildPUT: ({ prisma }: {
24
+ prisma: PrismaClient;
25
+ }) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<{
26
+ error: string;
27
+ }> | NextResponse<{
28
+ initialMessages: {
29
+ id: string;
30
+ role: import("@prisma/client").$Enums.MessageRole;
31
+ content: string;
32
+ orderNumber: number;
33
+ assistantId: string | null;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ }[];
37
+ }>>;
38
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
39
+ export {};
40
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/initial-messages/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQ9E,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;;;;;;;;;;;;GAgD9C,CAAA;AAEH,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;GAuD7C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,85 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { ApiKeyType } from '@prisma/client';
3
+ import { headers } from 'next/headers';
4
+ import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
+ import { serializeApiInitialMessage } from '../../../../../lib/initialMessages/serializeApiInitialMessage';
6
+ import { initialMessagesSchema } from '../../../../../lib/initialMessages/schema';
7
+ import { updateInitialMessages } from '../../../../../lib/initialMessages/updateInitialMessages';
8
+ import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
9
+ export const buildGET = ({ prisma }) => async (_request, props) => {
10
+ const { assistantId } = await props.params;
11
+ const headersList = await headers();
12
+ const authorization = headersList.get('authorization');
13
+ if (!authorization) {
14
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
15
+ }
16
+ const privateApiKey = await getApiKey({
17
+ type: ApiKeyType.PRIVATE,
18
+ authorization,
19
+ prisma,
20
+ });
21
+ if (!privateApiKey) {
22
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
23
+ }
24
+ const assistant = await prisma.assistant.findFirst({
25
+ where: {
26
+ id: assistantId,
27
+ workspaceId: privateApiKey.workspaceId,
28
+ },
29
+ include: {
30
+ initialMessages: {
31
+ orderBy: {
32
+ orderNumber: 'asc',
33
+ },
34
+ },
35
+ },
36
+ });
37
+ if (!assistant) {
38
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
39
+ }
40
+ return NextResponse.json({
41
+ initialMessages: assistant.initialMessages.map((m) => serializeApiInitialMessage({ initialMessage: m })),
42
+ }, { headers: cacheHeaders });
43
+ };
44
+ export const buildPUT = ({ prisma }) => async (request, props) => {
45
+ const { assistantId } = await props.params;
46
+ const headersList = await headers();
47
+ const authorization = headersList.get('authorization');
48
+ if (!authorization) {
49
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
50
+ }
51
+ const privateApiKey = await getApiKey({
52
+ authorization,
53
+ type: ApiKeyType.PRIVATE,
54
+ prisma,
55
+ });
56
+ if (!privateApiKey) {
57
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
58
+ }
59
+ const body = await request.json();
60
+ const bodyParse = initialMessagesSchema.safeParse(body);
61
+ if (!bodyParse.success) {
62
+ return NextResponse.json({ error: 'Invalid body' }, { status: 400 });
63
+ }
64
+ const { initialMessages } = bodyParse.data;
65
+ const assistant = await prisma.assistant.findFirst({
66
+ where: {
67
+ id: assistantId,
68
+ workspaceId: privateApiKey.workspaceId,
69
+ },
70
+ });
71
+ if (!assistant) {
72
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
73
+ }
74
+ const messages = await updateInitialMessages({
75
+ assistantId: assistant.id,
76
+ initialMessages,
77
+ prisma,
78
+ });
79
+ return NextResponse.json({
80
+ initialMessages: messages.map((m) => serializeApiInitialMessage({ initialMessage: m })),
81
+ }, { headers: cacheHeaders });
82
+ };
83
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
84
+ headers: cacheHeaders,
85
+ });
@@ -1,14 +1,10 @@
1
- import { type NextRequest, NextResponse } from 'next/server';
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
  initialMessages: {
13
9
  id: string;
14
10
  role: import("@prisma/client").$Enums.MessageRole;
@@ -19,16 +15,13 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
19
15
  updatedAt: string;
20
16
  }[];
21
17
  }>>;
22
- export declare const GET: ReturnType<typeof buildGET>;
23
- export declare const buildPUT: ({ prisma: providedPrisma }?: {
24
- prisma?: PrismaClient;
25
- }) => (request: NextRequest, props: {
18
+ export declare const PUT: (request: import("next/server").NextRequest, props: {
26
19
  params: Promise<{
27
20
  assistantId: string;
28
21
  }>;
29
- }) => Promise<NextResponse<{
22
+ }) => Promise<import("next/server").NextResponse<{
30
23
  error: string;
31
- }> | NextResponse<{
24
+ }> | import("next/server").NextResponse<{
32
25
  initialMessages: {
33
26
  id: string;
34
27
  role: import("@prisma/client").$Enums.MessageRole;
@@ -39,6 +32,5 @@ export declare const buildPUT: ({ prisma: providedPrisma }?: {
39
32
  updatedAt: string;
40
33
  }[];
41
34
  }>>;
42
- export declare const PUT: ReturnType<typeof buildPUT>;
43
- export declare const OPTIONS: () => NextResponse<{}>;
35
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
44
36
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/initial-messages/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAS9E,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;GAkDF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;GAyDF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/initial-messages/route.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,90 +1,5 @@
1
- import { NextResponse } from 'next/server';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { headers } from 'next/headers';
4
- import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../../lib/prisma';
6
- import { serializeApiInitialMessage } from '../../../../../lib/initialMessages/serializeApiInitialMessage';
7
- import { initialMessagesSchema } from '../../../../../lib/initialMessages/schema';
8
- import { updateInitialMessages } from '../../../../../lib/initialMessages/updateInitialMessages';
9
- import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
10
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
11
- const prisma = resolvePrisma(providedPrisma);
12
- const { assistantId } = 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
- const assistant = await prisma.assistant.findFirst({
27
- where: {
28
- id: assistantId,
29
- workspaceId: privateApiKey.workspaceId,
30
- },
31
- include: {
32
- initialMessages: {
33
- orderBy: {
34
- orderNumber: 'asc',
35
- },
36
- },
37
- },
38
- });
39
- if (!assistant) {
40
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
41
- }
42
- return NextResponse.json({
43
- initialMessages: assistant.initialMessages.map((m) => serializeApiInitialMessage({ initialMessage: m })),
44
- }, { headers: cacheHeaders });
45
- };
46
- export const GET = ((...args) => buildGET()(...args));
47
- export const buildPUT = ({ prisma: providedPrisma } = {}) => async (request, props) => {
48
- const prisma = resolvePrisma(providedPrisma);
49
- const { assistantId } = await props.params;
50
- const headersList = await headers();
51
- const authorization = headersList.get('authorization');
52
- if (!authorization) {
53
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
54
- }
55
- const privateApiKey = await getApiKey({
56
- authorization,
57
- type: ApiKeyType.PRIVATE,
58
- prisma,
59
- });
60
- if (!privateApiKey) {
61
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
62
- }
63
- const body = await request.json();
64
- const bodyParse = initialMessagesSchema.safeParse(body);
65
- if (!bodyParse.success) {
66
- return NextResponse.json({ error: 'Invalid body' }, { status: 400 });
67
- }
68
- const { initialMessages } = bodyParse.data;
69
- const assistant = await prisma.assistant.findFirst({
70
- where: {
71
- id: assistantId,
72
- workspaceId: privateApiKey.workspaceId,
73
- },
74
- });
75
- if (!assistant) {
76
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
77
- }
78
- const messages = await updateInitialMessages({
79
- assistantId: assistant.id,
80
- initialMessages,
81
- prisma,
82
- });
83
- return NextResponse.json({
84
- initialMessages: messages.map((m) => serializeApiInitialMessage({ initialMessage: m })),
85
- }, { headers: cacheHeaders });
86
- };
87
- export const PUT = ((...args) => buildPUT()(...args));
88
- export const OPTIONS = () => NextResponse.json({}, {
89
- headers: cacheHeaders,
90
- });
1
+ import { prisma } from '../../../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS, buildPUT, } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const PUT = buildPUT({ prisma });
5
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,89 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ type RouteProps = {
4
+ params: Promise<{
5
+ assistantId: string;
6
+ mcpServerId: string;
7
+ }>;
8
+ };
9
+ export declare const buildGET: ({ prisma }: {
10
+ prisma: PrismaClient;
11
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
12
+ error: string;
13
+ }> | NextResponse<{
14
+ mcpServer: {
15
+ id: string;
16
+ transportType: import("@prisma/client").$Enums.TransportType;
17
+ sseTransport: {
18
+ id: string;
19
+ url: string;
20
+ headers: PrismaJson.SseTransportHeaders;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ } | null;
24
+ httpTransport: {
25
+ id: string;
26
+ url: string;
27
+ headers: PrismaJson.HttpTransportHeaders;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ } | null;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ };
34
+ }>>;
35
+ export declare const buildPATCH: ({ prisma }: {
36
+ prisma: PrismaClient;
37
+ }) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<{
38
+ error: string;
39
+ }> | NextResponse<{
40
+ mcpServer: {
41
+ id: string;
42
+ transportType: import("@prisma/client").$Enums.TransportType;
43
+ sseTransport: {
44
+ id: string;
45
+ url: string;
46
+ headers: PrismaJson.SseTransportHeaders;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ } | null;
50
+ httpTransport: {
51
+ id: string;
52
+ url: string;
53
+ headers: PrismaJson.HttpTransportHeaders;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ } | null;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ };
60
+ }>>;
61
+ export declare const buildDELETE: ({ prisma }: {
62
+ prisma: PrismaClient;
63
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
64
+ error: string;
65
+ }> | NextResponse<{
66
+ mcpServer: {
67
+ id: string;
68
+ transportType: import("@prisma/client").$Enums.TransportType;
69
+ sseTransport: {
70
+ id: string;
71
+ url: string;
72
+ headers: PrismaJson.SseTransportHeaders;
73
+ createdAt: string;
74
+ updatedAt: string;
75
+ } | null;
76
+ httpTransport: {
77
+ id: string;
78
+ url: string;
79
+ headers: PrismaJson.HttpTransportHeaders;
80
+ createdAt: string;
81
+ updatedAt: string;
82
+ } | null;
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ };
86
+ }>>;
87
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
88
+ export {};
89
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D,CAAA;AA0BD,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAoD9C,CAAA;AAEH,eAAO,MAAM,UAAU,GACpB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GA2F7C,CAAA;AAEH,eAAO,MAAM,WAAW,GACrB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAwD9C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}