@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,88 @@
1
+ import { isString } from 'radash';
2
+ import { StorageProviderType } from '@prisma/client';
3
+ import { NextResponse } from 'next/server';
4
+ import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
5
+ import { assistantClientAdapter } from '../../../lib/assistants/assistantClientAdapter';
6
+ import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../lib/apiKeys/workspaceAccessWhere';
7
+ import { isOpenaiAssistantsStorageProvider } from '../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
8
+ export const buildPOST = ({ prisma }) => async (request) => {
9
+ var _a;
10
+ const formData = await request.formData();
11
+ const assistantId = formData.get('assistantId');
12
+ if (!isString(assistantId)) {
13
+ return NextResponse.json({ error: 'Invalid assistantId' }, { status: 400 });
14
+ }
15
+ const publicApiKey = formData.get('publicApiKey');
16
+ if (!isString(publicApiKey)) {
17
+ return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
18
+ }
19
+ const file = formData.get('file');
20
+ const workspaceAccessWhere = await getWorkspaceAccessWhere({
21
+ publicApiKey,
22
+ prisma,
23
+ });
24
+ if (!workspaceAccessWhere) {
25
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
26
+ }
27
+ if (!assistantId) {
28
+ return NextResponse.json({ error: 'No assistantId found' }, { status: 400 });
29
+ }
30
+ if (!file) {
31
+ return NextResponse.json({ error: 'No file found' }, { status: 400 });
32
+ }
33
+ const assistant = await prisma.assistant.findFirst({
34
+ where: {
35
+ id: assistantId,
36
+ workspace: workspaceAccessWhere,
37
+ },
38
+ include: {
39
+ modelProvider: true,
40
+ tools: {
41
+ include: {
42
+ fileSearchTool: true,
43
+ webSearchTool: true,
44
+ imageGenerationTool: true,
45
+ codeInterpreterTool: true,
46
+ computerUseTool: true,
47
+ },
48
+ },
49
+ mcpServers: {
50
+ include: {
51
+ computerUseTool: true,
52
+ stdioTransport: true,
53
+ sseTransport: true,
54
+ httpTransport: true,
55
+ },
56
+ },
57
+ functions: true,
58
+ },
59
+ });
60
+ if (!assistant) {
61
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
62
+ }
63
+ if (isOpenaiAssistantsStorageProvider({
64
+ storageProviderType: assistant.storageProviderType,
65
+ }) &&
66
+ !assistant.openaiAssistantId) {
67
+ return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
68
+ }
69
+ const assistantClient = assistantClientAdapter({ assistant, prisma });
70
+ const purpose = (_a = formData.get('purpose')) !== null && _a !== void 0 ? _a : 'assistants';
71
+ const createFileResponse = await assistantClient.files.create(Object.assign({
72
+ // @ts-expect-error file is Uploadable
73
+ file,
74
+ purpose }, (assistant.storageProviderType === StorageProviderType.OPENAI
75
+ ? {
76
+ expires_after: {
77
+ anchor: 'created_at',
78
+ seconds: 2592000, // 30 days
79
+ },
80
+ }
81
+ : {})));
82
+ return NextResponse.json({
83
+ file: createFileResponse,
84
+ }, { headers: cacheHeaders });
85
+ };
86
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
87
+ headers: cacheHeaders,
88
+ });
@@ -1,15 +1,9 @@
1
- import type OpenAI from 'openai';
2
- import { type PrismaClient } from '@prisma/client';
3
- import { type NextRequest, NextResponse } from 'next/server';
4
- export declare const buildPOST: ({ prisma: providedPrisma }?: {
5
- prisma?: PrismaClient;
6
- }) => (request: NextRequest) => Promise<NextResponse<{
1
+ export declare const POST: (request: import("next/server").NextRequest) => Promise<import("next/server").NextResponse<{
7
2
  error: string;
8
- }> | NextResponse<{
9
- file: OpenAI.Files.FileObject & {
3
+ }> | import("next/server").NextResponse<{
4
+ file: import("openai/resources/files.mjs").FileObject & {
10
5
  _request_id?: string | null;
11
6
  };
12
7
  }>>;
13
- export declare const POST: ReturnType<typeof buildPOST>;
14
- export declare const OPTIONS: () => NextResponse<{}>;
8
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
15
9
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/files/route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,SAAS,GACnB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;;;GA+G1B,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/files/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,91 +1,4 @@
1
- import { isString } from 'radash';
2
- import { StorageProviderType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
5
- import { assistantClientAdapter } from '../../../lib/assistants/assistantClientAdapter';
6
- import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../lib/apiKeys/workspaceAccessWhere';
7
- import { resolvePrisma } from '../../../lib/prisma';
8
- import { isOpenaiAssistantsStorageProvider } from '../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
9
- export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request) => {
10
- var _a;
11
- const prisma = resolvePrisma(providedPrisma);
12
- const formData = await request.formData();
13
- const assistantId = formData.get('assistantId');
14
- if (!isString(assistantId)) {
15
- return NextResponse.json({ error: 'Invalid assistantId' }, { status: 400 });
16
- }
17
- const publicApiKey = formData.get('publicApiKey');
18
- if (!isString(publicApiKey)) {
19
- return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
20
- }
21
- const file = formData.get('file');
22
- const workspaceAccessWhere = await getWorkspaceAccessWhere({
23
- publicApiKey,
24
- prisma,
25
- });
26
- if (!workspaceAccessWhere) {
27
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
28
- }
29
- if (!assistantId) {
30
- return NextResponse.json({ error: 'No assistantId found' }, { status: 400 });
31
- }
32
- if (!file) {
33
- return NextResponse.json({ error: 'No file found' }, { status: 400 });
34
- }
35
- const assistant = await prisma.assistant.findFirst({
36
- where: {
37
- id: assistantId,
38
- workspace: workspaceAccessWhere,
39
- },
40
- include: {
41
- modelProvider: true,
42
- tools: {
43
- include: {
44
- fileSearchTool: true,
45
- webSearchTool: true,
46
- imageGenerationTool: true,
47
- codeInterpreterTool: true,
48
- computerUseTool: true,
49
- },
50
- },
51
- mcpServers: {
52
- include: {
53
- computerUseTool: true,
54
- stdioTransport: true,
55
- sseTransport: true,
56
- httpTransport: true,
57
- },
58
- },
59
- functions: true,
60
- },
61
- });
62
- if (!assistant) {
63
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
64
- }
65
- if (isOpenaiAssistantsStorageProvider({
66
- storageProviderType: assistant.storageProviderType,
67
- }) &&
68
- !assistant.openaiAssistantId) {
69
- return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
70
- }
71
- const assistantClient = assistantClientAdapter({ assistant, prisma });
72
- const purpose = (_a = formData.get('purpose')) !== null && _a !== void 0 ? _a : 'assistants';
73
- const createFileResponse = await assistantClient.files.create(Object.assign({
74
- // @ts-expect-error file is Uploadable
75
- file,
76
- purpose }, (assistant.storageProviderType === StorageProviderType.OPENAI
77
- ? {
78
- expires_after: {
79
- anchor: 'created_at',
80
- seconds: 2592000, // 30 days
81
- },
82
- }
83
- : {})));
84
- return NextResponse.json({
85
- file: createFileResponse,
86
- }, { headers: cacheHeaders });
87
- };
88
- export const POST = ((...args) => buildPOST()(...args));
89
- export const OPTIONS = () => NextResponse.json({}, {
90
- headers: cacheHeaders,
91
- });
1
+ import { prisma } from '../../../lib/prisma';
2
+ import { buildOPTIONS, buildPOST } from './buildRoute';
3
+ export const POST = buildPOST({ prisma });
4
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,34 @@
1
+ import { type NextRequest, NextResponse } from 'next/server';
2
+ import OpenAI from 'openai';
3
+ import { type PrismaClient } from '@prisma/client';
4
+ import type { Thread } from '@prisma/client';
5
+ export declare const maxDuration = 800;
6
+ export declare const buildGET: ({ prisma }: {
7
+ prisma: PrismaClient;
8
+ }) => (request: NextRequest) => Promise<NextResponse<{
9
+ error: string;
10
+ }> | NextResponse<{
11
+ data: {
12
+ id: string;
13
+ role: "user" | "assistant";
14
+ created_at: number;
15
+ content: OpenAI.Beta.Threads.Messages.MessageContent[];
16
+ run_id: string;
17
+ assistant_id: string;
18
+ thread_id: string;
19
+ attachments: OpenAI.Beta.Threads.Messages.Message.Attachment[];
20
+ metadata: import("openai/resources/shared.mjs").Metadata;
21
+ runSteps: Pick<OpenAI.Beta.Threads.Runs.Steps.RunStep, "id" | "run_id" | "step_details" | "completed_at" | "cancelled_at" | "failed_at" | "status">[];
22
+ status: "in_progress" | "incomplete" | "completed";
23
+ }[];
24
+ hasNextPage: boolean;
25
+ lastId: null;
26
+ }> | NextResponse<import("@superinterface/react/types/index").MessagesPage>>;
27
+ export declare const buildPOST: ({ prisma, onSuccessCreateThread, }: {
28
+ prisma: PrismaClient;
29
+ onSuccessCreateThread?: ({ thread, }: {
30
+ thread: Thread;
31
+ }) => void | Promise<void>;
32
+ }) => (request: NextRequest) => Promise<Response>;
33
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
34
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../src/app/api/messages/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AA0B5C,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;;;;;;;;;;;;;;;4EA2K1B,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,oCAGE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,qBAAqB,CAAC,EAAE,CAAC,EACvB,MAAM,GACP,EAAE;QACD,MAAM,EAAE,MAAM,CAAA;KACf,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B,MACM,SAAS,WAAW,sBA+f1B,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}