@superinterface/server 1.0.18 → 1.0.20

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 (264) 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/files/[fileId]/contents/route.js +1 -1
  9. package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
  10. package/.next/server/app/api/files/route.js +1 -1
  11. package/.next/server/app/api/files/route.js.nft.json +1 -1
  12. package/.next/server/app/api/messages/route.js +3 -3
  13. package/.next/server/app/api/messages/route.js.nft.json +1 -1
  14. package/.next/server/app/index.html +1 -1
  15. package/.next/server/app/index.rsc +1 -1
  16. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
  17. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
  18. package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js +1 -1
  19. package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js.map +1 -1
  20. package/.next/server/chunks/[root-of-the-server]__228bff78._.js +2 -2
  21. package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +1 -1
  22. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
  23. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  24. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js +1 -1
  25. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js.map +1 -1
  26. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  27. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  28. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  29. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  30. package/.next/server/chunks/[root-of-the-server]__29b43490._.js +2 -2
  31. package/.next/server/chunks/[root-of-the-server]__29b43490._.js.map +1 -1
  32. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  33. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  34. package/.next/server/chunks/[root-of-the-server]__3307123c._.js +2 -2
  35. package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +1 -1
  36. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  37. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  38. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  39. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  40. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  41. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  42. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +2 -2
  43. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +1 -1
  44. package/.next/server/chunks/[root-of-the-server]__51977f30._.js +1 -1
  45. package/.next/server/chunks/[root-of-the-server]__51977f30._.js.map +1 -1
  46. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  47. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  48. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  49. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  50. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  51. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  52. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  53. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +2 -2
  55. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__a135e388._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__a135e388._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js +2 -2
  71. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js.map +1 -1
  72. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +2 -2
  73. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  76. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js +1 -1
  77. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js.map +1 -1
  78. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +2 -2
  79. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +1 -1
  80. package/.next/server/chunks/{[root-of-the-server]__30845206._.js → [root-of-the-server]__ff90af03._.js} +3 -3
  81. package/.next/server/chunks/{[root-of-the-server]__30845206._.js.map → [root-of-the-server]__ff90af03._.js.map} +1 -1
  82. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  83. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  84. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  85. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  86. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js +2 -2
  87. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js.map +1 -1
  88. package/.next/server/pages/404.html +1 -1
  89. package/.next/server/pages/500.html +1 -1
  90. package/.next/trace +1 -1
  91. package/bin/index.cjs +2 -0
  92. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +55 -0
  93. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  94. package/dist/app/api/api-keys/[apiKeyId]/route.js +10 -4
  95. package/dist/app/api/api-keys/route.d.ts +29 -0
  96. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  97. package/dist/app/api/api-keys/route.js +8 -3
  98. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +172 -0
  99. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  100. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +11 -4
  101. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +113 -0
  102. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  103. package/dist/app/api/assistants/[assistantId]/functions/route.js +8 -3
  104. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +39 -0
  105. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  106. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +8 -3
  107. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +94 -0
  108. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  109. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +10 -4
  110. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +61 -0
  111. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  112. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +7 -3
  113. package/dist/app/api/assistants/[assistantId]/route.d.ts +123 -0
  114. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  115. package/dist/app/api/assistants/[assistantId]/route.js +15 -6
  116. package/dist/app/api/assistants/route.d.ts +59 -0
  117. package/dist/app/api/assistants/route.d.ts.map +1 -1
  118. package/dist/app/api/assistants/route.js +8 -4
  119. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -2
  120. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  121. package/dist/app/api/files/[fileId]/contents/route.js +9 -6
  122. package/dist/app/api/files/route.d.ts +10 -0
  123. package/dist/app/api/files/route.d.ts.map +1 -1
  124. package/dist/app/api/files/route.js +9 -5
  125. package/dist/app/api/messages/route.d.ts +24 -1
  126. package/dist/app/api/messages/route.d.ts.map +1 -1
  127. package/dist/app/api/messages/route.js +38 -13
  128. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +19 -0
  129. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  130. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -2
  131. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +14 -0
  132. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  133. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -2
  134. package/dist/app/api/providers/[modelProviderId]/route.d.ts +64 -0
  135. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  136. package/dist/app/api/providers/[modelProviderId]/route.js +12 -6
  137. package/dist/app/api/providers/route.d.ts +35 -0
  138. package/dist/app/api/providers/route.d.ts.map +1 -1
  139. package/dist/app/api/providers/route.js +9 -5
  140. package/dist/app/api/tasks/[taskId]/route.d.ts +61 -0
  141. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  142. package/dist/app/api/tasks/[taskId]/route.js +11 -5
  143. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  144. package/dist/app/api/tasks/callback/route.js +17 -9
  145. package/dist/app/api/tasks/route.d.ts +33 -0
  146. package/dist/app/api/tasks/route.d.ts.map +1 -1
  147. package/dist/app/api/tasks/route.js +8 -4
  148. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +9 -1
  149. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  150. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +5 -3
  151. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +33 -0
  152. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  153. package/dist/app/api/workspaces/[workspaceId]/route.js +7 -3
  154. package/dist/app/api/workspaces/route.d.ts +17 -3
  155. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  156. package/dist/app/api/workspaces/route.js +8 -4
  157. package/dist/lib/apiKeys/getApiKey.d.ts +3 -2
  158. package/dist/lib/apiKeys/getApiKey.d.ts.map +1 -1
  159. package/dist/lib/apiKeys/getApiKey.js +1 -2
  160. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts +3 -1
  161. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts.map +1 -1
  162. package/dist/lib/apiKeys/workspaceAccessWhere.js +2 -1
  163. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts +3 -2
  164. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts.map +1 -1
  165. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.js +3 -3
  166. package/dist/lib/assistants/assistantClientAdapter/index.d.ts.map +1 -1
  167. package/dist/lib/assistants/assistantClientAdapter/index.js +7 -2
  168. package/dist/lib/computerCalls/handleComputerCall/index.d.ts +3 -2
  169. package/dist/lib/computerCalls/handleComputerCall/index.d.ts.map +1 -1
  170. package/dist/lib/computerCalls/handleComputerCall/index.js +5 -1
  171. package/dist/lib/functions/createFunction.d.ts +2 -1
  172. package/dist/lib/functions/createFunction.d.ts.map +1 -1
  173. package/dist/lib/functions/createFunction.js +2 -2
  174. package/dist/lib/functions/handleFunction/handleAssistant.d.ts +3 -2
  175. package/dist/lib/functions/handleFunction/handleAssistant.d.ts.map +1 -1
  176. package/dist/lib/functions/handleFunction/handleAssistant.js +12 -2
  177. package/dist/lib/functions/handleFunction/handleClientTool.d.ts +3 -2
  178. package/dist/lib/functions/handleFunction/handleClientTool.d.ts.map +1 -1
  179. package/dist/lib/functions/handleFunction/handleClientTool.js +2 -1
  180. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts +3 -2
  181. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts.map +1 -1
  182. package/dist/lib/functions/handleFunction/handleFirecrawl.js +7 -1
  183. package/dist/lib/functions/handleFunction/handleReplicate.d.ts +3 -2
  184. package/dist/lib/functions/handleFunction/handleReplicate.d.ts.map +1 -1
  185. package/dist/lib/functions/handleFunction/handleReplicate.js +4 -1
  186. package/dist/lib/functions/handleFunction/handleRequest.d.ts +3 -2
  187. package/dist/lib/functions/handleFunction/handleRequest.d.ts.map +1 -1
  188. package/dist/lib/functions/handleFunction/handleRequest.js +6 -1
  189. package/dist/lib/functions/handleFunction/index.d.ts +3 -2
  190. package/dist/lib/functions/handleFunction/index.d.ts.map +1 -1
  191. package/dist/lib/functions/handleFunction/index.js +25 -1
  192. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts +3 -2
  193. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts.map +1 -1
  194. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.js +4 -4
  195. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts +3 -2
  196. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts.map +1 -1
  197. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.js +3 -3
  198. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts +3 -2
  199. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts.map +1 -1
  200. package/dist/lib/functions/handleFunction/tasks/handleListTasks.js +3 -3
  201. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts +3 -2
  202. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts.map +1 -1
  203. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.js +4 -4
  204. package/dist/lib/functions/updateFunction.d.ts +2 -1
  205. package/dist/lib/functions/updateFunction.d.ts.map +1 -1
  206. package/dist/lib/functions/updateFunction.js +2 -2
  207. package/dist/lib/handlers/handlerPrismaInput.d.ts +3 -1
  208. package/dist/lib/handlers/handlerPrismaInput.d.ts.map +1 -1
  209. package/dist/lib/handlers/handlerPrismaInput.jsx +1 -2
  210. package/dist/lib/initialMessages/updateInitialMessages.d.ts +3 -2
  211. package/dist/lib/initialMessages/updateInitialMessages.d.ts.map +1 -1
  212. package/dist/lib/initialMessages/updateInitialMessages.js +1 -2
  213. package/dist/lib/logs/createLog.d.ts +3 -2
  214. package/dist/lib/logs/createLog.d.ts.map +1 -1
  215. package/dist/lib/logs/createLog.js +1 -2
  216. package/dist/lib/mcpServers/connectMcpServer.d.ts +5 -3
  217. package/dist/lib/mcpServers/connectMcpServer.d.ts.map +1 -1
  218. package/dist/lib/mcpServers/connectMcpServer.js +7 -5
  219. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts +3 -2
  220. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts.map +1 -1
  221. package/dist/lib/mcpServers/getToolCallMcpServer.js +2 -1
  222. package/dist/lib/mcpServers/headers.d.ts +3 -2
  223. package/dist/lib/mcpServers/headers.d.ts.map +1 -1
  224. package/dist/lib/mcpServers/headers.js +2 -1
  225. package/dist/lib/mcpServers/url.d.ts +3 -2
  226. package/dist/lib/mcpServers/url.d.ts.map +1 -1
  227. package/dist/lib/mcpServers/url.js +2 -1
  228. package/dist/lib/metadata/serializeMetadata.d.ts +3 -1
  229. package/dist/lib/metadata/serializeMetadata.d.ts.map +1 -1
  230. package/dist/lib/metadata/serializeMetadata.js +3 -2
  231. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts +3 -2
  232. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts.map +1 -1
  233. package/dist/lib/organizationApiKeys/getOrganizationApiKey.js +1 -2
  234. package/dist/lib/prisma/index.d.ts +2 -0
  235. package/dist/lib/prisma/index.d.ts.map +1 -1
  236. package/dist/lib/prisma/index.js +16 -4
  237. package/dist/lib/runs/createRunOpts.d.ts +3 -2
  238. package/dist/lib/runs/createRunOpts.d.ts.map +1 -1
  239. package/dist/lib/runs/createRunOpts.js +2 -2
  240. package/dist/lib/tasks/getTaskToolKey.d.ts +3 -2
  241. package/dist/lib/tasks/getTaskToolKey.d.ts.map +1 -1
  242. package/dist/lib/tasks/getTaskToolKey.js +2 -1
  243. package/dist/lib/tasks/parseTaskToolArgs.d.ts +3 -2
  244. package/dist/lib/tasks/parseTaskToolArgs.d.ts.map +1 -1
  245. package/dist/lib/tasks/parseTaskToolArgs.js +4 -1
  246. package/dist/lib/tasks/scheduleTask.d.ts +3 -2
  247. package/dist/lib/tasks/scheduleTask.d.ts.map +1 -1
  248. package/dist/lib/tasks/scheduleTask.js +1 -2
  249. package/dist/lib/threads/createThread/index.d.ts.map +1 -1
  250. package/dist/lib/threads/createThread/index.js +1 -0
  251. package/dist/lib/threads/managedOpenaiThreadId.d.ts +3 -2
  252. package/dist/lib/threads/managedOpenaiThreadId.d.ts.map +1 -1
  253. package/dist/lib/threads/managedOpenaiThreadId.js +1 -2
  254. package/dist/lib/toolCalls/handleToolCall.d.ts +3 -2
  255. package/dist/lib/toolCalls/handleToolCall.d.ts.map +1 -1
  256. package/dist/lib/toolCalls/handleToolCall.js +5 -1
  257. package/dist/lib/tools/tools/index.d.ts +3 -2
  258. package/dist/lib/tools/tools/index.d.ts.map +1 -1
  259. package/dist/lib/tools/tools/index.js +9 -6
  260. package/package.json +1 -1
  261. package/scripts/utils/loadPrisma.ts +1 -2
  262. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_buildManifest.js +0 -0
  263. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_clientMiddlewareManifest.json +0 -0
  264. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_ssgManifest.js +0 -0
@@ -2,11 +2,11 @@ import { NextResponse } from 'next/server';
2
2
  import { ApiKeyType, TransportType } from '@prisma/client';
3
3
  import { headers } from 'next/headers';
4
4
  import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
- import { prisma } from '../../../../../lib/prisma';
5
+ import { getPrisma } from '../../../../../lib/prisma';
6
6
  import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
7
7
  import { serializeApiMcpServer } from '../../../../../lib/mcpServers/serializeApiMcpServer';
8
8
  import { mcpServerSchema } from '../../../../../lib/mcpServers/mcpServerSchema';
9
- export const GET = async (_request, props) => {
9
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async (_request, props) => {
10
10
  const { assistantId } = await props.params;
11
11
  const headersList = await headers();
12
12
  const authorization = headersList.get('authorization');
@@ -16,6 +16,7 @@ export const GET = async (_request, props) => {
16
16
  const privateApiKey = await getApiKey({
17
17
  type: ApiKeyType.PRIVATE,
18
18
  authorization,
19
+ prisma,
19
20
  });
20
21
  if (!privateApiKey) {
21
22
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -47,7 +48,8 @@ export const GET = async (_request, props) => {
47
48
  })),
48
49
  }, { headers: cacheHeaders });
49
50
  };
50
- export const POST = async (request, props) => {
51
+ export const GET = buildGET();
52
+ export const buildPOST = ({ prisma = getPrisma() } = {}) => async (request, props) => {
51
53
  const { assistantId } = await props.params;
52
54
  const headersList = await headers();
53
55
  const authorization = headersList.get('authorization');
@@ -57,6 +59,7 @@ export const POST = async (request, props) => {
57
59
  const privateApiKey = await getApiKey({
58
60
  authorization,
59
61
  type: ApiKeyType.PRIVATE,
62
+ prisma,
60
63
  });
61
64
  if (!privateApiKey) {
62
65
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -109,6 +112,7 @@ export const POST = async (request, props) => {
109
112
  mcpServer: serializeApiMcpServer({ mcpServer }),
110
113
  }, { headers: cacheHeaders });
111
114
  };
115
+ export const POST = buildPOST();
112
116
  export const OPTIONS = () => NextResponse.json({}, {
113
117
  headers: cacheHeaders,
114
118
  });
@@ -1,4 +1,61 @@
1
1
  import { type NextRequest, NextResponse } from 'next/server';
2
+ import { type PrismaClient } from '@prisma/client';
3
+ export declare const buildGET: ({ prisma }?: {
4
+ prisma?: PrismaClient;
5
+ }) => (request: NextRequest, props: {
6
+ params: Promise<{
7
+ assistantId: string;
8
+ }>;
9
+ }) => Promise<NextResponse<{
10
+ error: string;
11
+ }> | NextResponse<{
12
+ assistant: {
13
+ id: string;
14
+ storageProviderType: import("@prisma/client").$Enums.StorageProviderType;
15
+ storageProviderAssistantId: string | null;
16
+ modelProviderId: string;
17
+ model: string;
18
+ name: string;
19
+ description: string;
20
+ instructions: string;
21
+ codeInterpreterEnabled: boolean;
22
+ fileSearchEnabled: boolean;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ avatar: {
26
+ type: import("@prisma/client").$Enums.AvatarType;
27
+ imageAvatar: {
28
+ url: string;
29
+ } | null;
30
+ iconAvatar: {
31
+ name: import("@prisma/client").$Enums.IconAvatarName;
32
+ } | null;
33
+ };
34
+ };
35
+ }> | NextResponse<{
36
+ assistant: {
37
+ id: string;
38
+ name: string;
39
+ description: string;
40
+ theme: {
41
+ accentColor: "gray" | "gold" | "bronze" | "brown" | "yellow" | "amber" | "orange" | "tomato" | "red" | "ruby" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "lime" | "mint" | "sky";
42
+ grayColor: "auto" | "gray" | "mauve" | "slate" | "sage" | "olive" | "sand";
43
+ appearance: "inherit" | "light" | "dark";
44
+ radius: "small" | "none" | "medium" | "large" | "full";
45
+ scaling: "90%" | "95%" | "100%" | "105%" | "110%";
46
+ panelBackground: "solid";
47
+ };
48
+ avatar: {
49
+ type: import("@prisma/client").$Enums.AvatarType;
50
+ imageAvatar: {
51
+ url: string;
52
+ } | null;
53
+ iconAvatar: {
54
+ name: import("@prisma/client").$Enums.IconAvatarName;
55
+ } | null;
56
+ };
57
+ };
58
+ }>>;
2
59
  export declare const GET: (request: NextRequest, props: {
3
60
  params: Promise<{
4
61
  assistantId: string;
@@ -53,6 +110,39 @@ export declare const GET: (request: NextRequest, props: {
53
110
  };
54
111
  };
55
112
  }>>;
113
+ export declare const buildPATCH: ({ prisma }?: {
114
+ prisma?: PrismaClient;
115
+ }) => (request: NextRequest, props: {
116
+ params: Promise<{
117
+ assistantId: string;
118
+ }>;
119
+ }) => Promise<NextResponse<{
120
+ error: string;
121
+ }> | NextResponse<{
122
+ assistant: {
123
+ id: string;
124
+ storageProviderType: import("@prisma/client").$Enums.StorageProviderType;
125
+ storageProviderAssistantId: string | null;
126
+ modelProviderId: string;
127
+ model: string;
128
+ name: string;
129
+ description: string;
130
+ instructions: string;
131
+ codeInterpreterEnabled: boolean;
132
+ fileSearchEnabled: boolean;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ avatar: {
136
+ type: import("@prisma/client").$Enums.AvatarType;
137
+ imageAvatar: {
138
+ url: string;
139
+ } | null;
140
+ iconAvatar: {
141
+ name: import("@prisma/client").$Enums.IconAvatarName;
142
+ } | null;
143
+ };
144
+ };
145
+ }>>;
56
146
  export declare const PATCH: (request: NextRequest, props: {
57
147
  params: Promise<{
58
148
  assistantId: string;
@@ -84,6 +174,39 @@ export declare const PATCH: (request: NextRequest, props: {
84
174
  };
85
175
  };
86
176
  }>>;
177
+ export declare const buildDELETE: ({ prisma }?: {
178
+ prisma?: PrismaClient;
179
+ }) => (request: NextRequest, props: {
180
+ params: Promise<{
181
+ assistantId: string;
182
+ }>;
183
+ }) => Promise<NextResponse<{
184
+ error: string;
185
+ }> | NextResponse<{
186
+ assistant: {
187
+ id: string;
188
+ storageProviderType: import("@prisma/client").$Enums.StorageProviderType;
189
+ storageProviderAssistantId: string | null;
190
+ modelProviderId: string;
191
+ model: string;
192
+ name: string;
193
+ description: string;
194
+ instructions: string;
195
+ codeInterpreterEnabled: boolean;
196
+ fileSearchEnabled: boolean;
197
+ createdAt: string;
198
+ updatedAt: string;
199
+ avatar: {
200
+ type: import("@prisma/client").$Enums.AvatarType;
201
+ imageAvatar: {
202
+ url: string;
203
+ } | null;
204
+ iconAvatar: {
205
+ name: import("@prisma/client").$Enums.IconAvatarName;
206
+ } | null;
207
+ };
208
+ };
209
+ }>>;
87
210
  export declare const DELETE: (request: NextRequest, props: {
88
211
  params: Promise<{
89
212
  assistantId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/assistants/[assistantId]/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAgB5D,eAAO,MAAM,GAAG,GACd,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFF,CAAA;AAED,eAAO,MAAM,KAAK,GAChB,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GAmJF,CAAA;AAED,eAAO,MAAM,MAAM,GACjB,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDF,CAAA;AAED,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/assistants/[assistantId]/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAUvB,eAAO,MAAM,QAAQ,GAClB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEvD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FF,CAAA;AAEH,eAAO,MAAM,GAAG,YAnGH,WAAW,SACb;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FwB,CAAA;AAE7B,eAAO,MAAM,UAAU,GACpB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEvD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GAsJF,CAAA;AAEH,eAAO,MAAM,KAAK,YA7JL,WAAW,SACb;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GAwJ4B,CAAA;AAEjC,eAAO,MAAM,WAAW,GACrB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEvD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDF,CAAA;AAEH,eAAO,MAAM,MAAM,YA/DN,WAAW,SACb;IACL,MAAM,EAAE,OAAO,CAAC;QACd,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0D8B,CAAA;AAEnC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -2,13 +2,13 @@ import { NextResponse } from 'next/server';
2
2
  import { StorageProviderType, ApiKeyType, ToolType, } from '@prisma/client';
3
3
  import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
4
4
  import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../lib/apiKeys/workspaceAccessWhere';
5
- import { prisma } from '../../../../lib/prisma';
5
+ import { getPrisma } from '../../../../lib/prisma';
6
6
  import { serializeAssistant } from '../../../../lib/assistants/serializeAssistant';
7
7
  import { serializeApiAssistant } from '../../../../lib/assistants/serializeApiAssistant';
8
8
  import { headers } from 'next/headers';
9
9
  import { z } from 'zod';
10
10
  import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
11
- export const GET = async (request, props) => {
11
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async (request, props) => {
12
12
  const params = await props.params;
13
13
  const { assistantId } = params;
14
14
  const headersList = await headers();
@@ -17,6 +17,7 @@ export const GET = async (request, props) => {
17
17
  const privateApiKey = await getApiKey({
18
18
  authorization,
19
19
  type: ApiKeyType.PRIVATE,
20
+ prisma,
20
21
  });
21
22
  if (!privateApiKey) {
22
23
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -45,6 +46,7 @@ export const GET = async (request, props) => {
45
46
  }
46
47
  const workspaceAccessWhere = await getWorkspaceAccessWhere({
47
48
  publicApiKey: request.nextUrl.searchParams.get('publicApiKey'),
49
+ prisma,
48
50
  });
49
51
  if (!workspaceAccessWhere) {
50
52
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -73,7 +75,8 @@ export const GET = async (request, props) => {
73
75
  assistant: serializeAssistant({ assistant }),
74
76
  }, { headers: cacheHeaders });
75
77
  };
76
- export const PATCH = async (request, props) => {
78
+ export const GET = buildGET();
79
+ export const buildPATCH = ({ prisma = getPrisma() } = {}) => async (request, props) => {
77
80
  const params = await props.params;
78
81
  const { assistantId } = params;
79
82
  const headersList = await headers();
@@ -84,6 +87,7 @@ export const PATCH = async (request, props) => {
84
87
  const privateApiKey = await getApiKey({
85
88
  authorization,
86
89
  type: ApiKeyType.PRIVATE,
90
+ prisma,
87
91
  });
88
92
  if (!privateApiKey) {
89
93
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -103,7 +107,8 @@ export const PATCH = async (request, props) => {
103
107
  .superRefine((data, ctx) => {
104
108
  if (!data.storageProviderType)
105
109
  return;
106
- if (data.storageProviderType === StorageProviderType.SUPERINTERFACE_CLOUD &&
110
+ if (data.storageProviderType ===
111
+ StorageProviderType.SUPERINTERFACE_CLOUD &&
107
112
  data.storageProviderAssistantId) {
108
113
  ctx.addIssue({
109
114
  code: z.ZodIssueCode.custom,
@@ -111,7 +116,8 @@ export const PATCH = async (request, props) => {
111
116
  path: ['storageProviderAssistantId'],
112
117
  });
113
118
  }
114
- if (data.storageProviderType !== StorageProviderType.SUPERINTERFACE_CLOUD &&
119
+ if (data.storageProviderType !==
120
+ StorageProviderType.SUPERINTERFACE_CLOUD &&
115
121
  !data.storageProviderAssistantId) {
116
122
  ctx.addIssue({
117
123
  code: z.ZodIssueCode.custom,
@@ -174,7 +180,8 @@ export const PATCH = async (request, props) => {
174
180
  assistant: serializeApiAssistant({ assistant }),
175
181
  }, { headers: cacheHeaders });
176
182
  };
177
- export const DELETE = async (request, props) => {
183
+ export const PATCH = buildPATCH();
184
+ export const buildDELETE = ({ prisma = getPrisma() } = {}) => async (request, props) => {
178
185
  const params = await props.params;
179
186
  const { assistantId } = params;
180
187
  const headersList = await headers();
@@ -185,6 +192,7 @@ export const DELETE = async (request, props) => {
185
192
  const privateApiKey = await getApiKey({
186
193
  authorization,
187
194
  type: ApiKeyType.PRIVATE,
195
+ prisma,
188
196
  });
189
197
  if (!privateApiKey) {
190
198
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -216,6 +224,7 @@ export const DELETE = async (request, props) => {
216
224
  assistant: serializeApiAssistant({ assistant }),
217
225
  }, { headers: cacheHeaders });
218
226
  };
227
+ export const DELETE = buildDELETE();
219
228
  export const OPTIONS = () => NextResponse.json({}, {
220
229
  headers: cacheHeaders,
221
230
  });
@@ -1,4 +1,34 @@
1
+ import { type PrismaClient } from '@prisma/client';
1
2
  import { NextResponse } from 'next/server';
3
+ export declare const buildGET: ({ prisma }?: {
4
+ prisma?: PrismaClient;
5
+ }) => () => Promise<NextResponse<{
6
+ error: string;
7
+ }> | NextResponse<{
8
+ assistants: {
9
+ id: string;
10
+ storageProviderType: import("@prisma/client").$Enums.StorageProviderType;
11
+ storageProviderAssistantId: string | null;
12
+ modelProviderId: string;
13
+ model: string;
14
+ name: string;
15
+ description: string;
16
+ instructions: string;
17
+ codeInterpreterEnabled: boolean;
18
+ fileSearchEnabled: boolean;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ avatar: {
22
+ type: import("@prisma/client").$Enums.AvatarType;
23
+ imageAvatar: {
24
+ url: string;
25
+ } | null;
26
+ iconAvatar: {
27
+ name: import("@prisma/client").$Enums.IconAvatarName;
28
+ } | null;
29
+ };
30
+ }[];
31
+ }>>;
2
32
  export declare const GET: () => Promise<NextResponse<{
3
33
  error: string;
4
34
  }> | NextResponse<{
@@ -26,6 +56,35 @@ export declare const GET: () => Promise<NextResponse<{
26
56
  };
27
57
  }[];
28
58
  }>>;
59
+ export declare const buildPOST: ({ prisma }?: {
60
+ prisma?: PrismaClient;
61
+ }) => (request: Request) => Promise<NextResponse<{
62
+ error: string;
63
+ }> | NextResponse<{
64
+ assistant: {
65
+ id: string;
66
+ storageProviderType: import("@prisma/client").$Enums.StorageProviderType;
67
+ storageProviderAssistantId: string | null;
68
+ modelProviderId: string;
69
+ model: string;
70
+ name: string;
71
+ description: string;
72
+ instructions: string;
73
+ codeInterpreterEnabled: boolean;
74
+ fileSearchEnabled: boolean;
75
+ createdAt: string;
76
+ updatedAt: string;
77
+ avatar: {
78
+ type: import("@prisma/client").$Enums.AvatarType;
79
+ imageAvatar: {
80
+ url: string;
81
+ } | null;
82
+ iconAvatar: {
83
+ name: import("@prisma/client").$Enums.IconAvatarName;
84
+ } | null;
85
+ };
86
+ };
87
+ }>>;
29
88
  export declare const POST: (request: Request) => Promise<NextResponse<{
30
89
  error: string;
31
90
  }> | NextResponse<{
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/assistants/route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO1C,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA0Cf,CAAA;AAwCD,eAAO,MAAM,IAAI,GAAU,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAgG1C,CAAA;AAED,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/assistants/route.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO1C,eAAO,MAAM,QAAQ,GAClB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CxD,CAAA;AAEH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GAAa,CAAA;AAwC7B,eAAO,MAAM,SAAS,GACnB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGtB,CAAA;AAEH,eAAO,MAAM,IAAI,YAnGC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGM,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -1,12 +1,12 @@
1
1
  import { headers } from 'next/headers';
2
- import { ApiKeyType, StorageProviderType, ToolType } from '@prisma/client';
2
+ import { ApiKeyType, StorageProviderType, ToolType, } from '@prisma/client';
3
3
  import { NextResponse } from 'next/server';
4
4
  import { z } from 'zod';
5
5
  import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
6
- import { prisma } from '../../../lib/prisma';
6
+ import { getPrisma } from '../../../lib/prisma';
7
7
  import { serializeApiAssistant } from '../../../lib/assistants/serializeApiAssistant';
8
8
  import { getApiKey } from '../../../lib/apiKeys/getApiKey';
9
- export const GET = async () => {
9
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async () => {
10
10
  const headersList = await headers();
11
11
  const authorization = headersList.get('authorization');
12
12
  if (!authorization) {
@@ -15,6 +15,7 @@ export const GET = async () => {
15
15
  const privateApiKey = await getApiKey({
16
16
  authorization,
17
17
  type: ApiKeyType.PRIVATE,
18
+ prisma,
18
19
  });
19
20
  if (!privateApiKey) {
20
21
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -37,6 +38,7 @@ export const GET = async () => {
37
38
  assistants: assistants.map((a) => serializeApiAssistant({ assistant: a })),
38
39
  }, { headers: cacheHeaders });
39
40
  };
41
+ export const GET = buildGET();
40
42
  const createAssistantSchema = z
41
43
  .object({
42
44
  storageProviderType: z.nativeEnum(StorageProviderType),
@@ -67,7 +69,7 @@ const createAssistantSchema = z
67
69
  });
68
70
  }
69
71
  });
70
- export const POST = async (request) => {
72
+ export const buildPOST = ({ prisma = getPrisma() } = {}) => async (request) => {
71
73
  const headersList = await headers();
72
74
  const authorization = headersList.get('authorization');
73
75
  if (!authorization) {
@@ -76,6 +78,7 @@ export const POST = async (request) => {
76
78
  const privateApiKey = await getApiKey({
77
79
  authorization,
78
80
  type: ApiKeyType.PRIVATE,
81
+ prisma,
79
82
  });
80
83
  if (!privateApiKey) {
81
84
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -137,6 +140,7 @@ export const POST = async (request) => {
137
140
  assistant: serializeApiAssistant({ assistant }),
138
141
  }, { headers: cacheHeaders });
139
142
  };
143
+ export const POST = buildPOST();
140
144
  export const OPTIONS = () => NextResponse.json({}, {
141
145
  headers: cacheHeaders,
142
146
  });
@@ -1,7 +1,8 @@
1
1
  import type { OpenAI } from 'openai';
2
- import type { Prisma } from '@prisma/client';
2
+ import { type Prisma, type PrismaClient } from '@prisma/client';
3
3
  import { type NextRequest, NextResponse } from 'next/server';
4
- export declare const buildGET: ({ purposeAssistantsResponse, }: {
4
+ export declare const buildGET: ({ prisma, purposeAssistantsResponse, }?: {
5
+ prisma?: PrismaClient;
5
6
  purposeAssistantsResponse?: ({ file, }: {
6
7
  file: OpenAI.Files.FileObject;
7
8
  workspaceAccessWhere: Prisma.WorkspaceWhereInput;
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/files/[fileId]/contents/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,gCAGE;IACD,yBAAyB,CAAC,EAAE,CAAC,EAC3B,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;QAC7B,oBAAoB,EAAE,MAAM,CAAC,mBAAmB,CAAA;KACjD,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAA;CAC3C,MAEC,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACf,CAAC,CAAA;CACH,mCA0GF,CAAA;AAEH,eAAO,MAAM,GAAG,YAjHH,WAAW,SACb;IACL,MAAM,EAAE,OAAO,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACf,CAAC,CAAA;CACH,mCA4G0B,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/files/[fileId]/contents/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,yCAIE;IACD,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,yBAAyB,CAAC,EAAE,CAAC,EAC3B,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;QAC7B,oBAAoB,EAAE,MAAM,CAAC,mBAAmB,CAAA;KACjD,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAA;CACtC,MAEJ,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACf,CAAC,CAAA;CACH,mCA6GF,CAAA;AAEH,eAAO,MAAM,GAAG,YApHH,WAAW,SACb;IACL,MAAM,EAAE,OAAO,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACf,CAAC,CAAA;CACH,mCA+G0B,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -3,9 +3,9 @@ import { NextResponse } from 'next/server';
3
3
  import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
4
4
  import { assistantClientAdapter } from '../../../../../lib/assistants/assistantClientAdapter';
5
5
  import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../../lib/apiKeys/workspaceAccessWhere';
6
- import { prisma } from '../../../../../lib/prisma';
6
+ import { getPrisma } from '../../../../../lib/prisma';
7
7
  import { isOpenaiAssistantsStorageProvider } from '../../../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
8
- export const buildGET = ({ purposeAssistantsResponse = () => NextResponse.json({ error: 'No file source found' }, { status: 404 }), }) => async (request, props) => {
8
+ export const buildGET = ({ prisma = getPrisma(), purposeAssistantsResponse = () => NextResponse.json({ error: 'No file source found' }, { status: 404 }), } = {}) => async (request, props) => {
9
9
  var _a, _b;
10
10
  const params = await props.params;
11
11
  const { fileId } = params;
@@ -17,7 +17,10 @@ export const buildGET = ({ purposeAssistantsResponse = () => NextResponse.json({
17
17
  if (!isString(publicApiKey)) {
18
18
  return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
19
19
  }
20
- const workspaceAccessWhere = await getWorkspaceAccessWhere({ publicApiKey });
20
+ const workspaceAccessWhere = await getWorkspaceAccessWhere({
21
+ publicApiKey,
22
+ prisma,
23
+ });
21
24
  if (!workspaceAccessWhere) {
22
25
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
23
26
  }
@@ -60,15 +63,15 @@ export const buildGET = ({ purposeAssistantsResponse = () => NextResponse.json({
60
63
  !assistant.openaiAssistantId) {
61
64
  return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
62
65
  }
63
- const client = assistantClientAdapter({ assistant, prisma });
64
- const file = await client.files.retrieve(fileId);
66
+ const assistantClient = assistantClientAdapter({ assistant, prisma });
67
+ const file = await assistantClient.files.retrieve(fileId);
65
68
  if (!file) {
66
69
  return NextResponse.json({ error: 'No file found' }, { status: 404 });
67
70
  }
68
71
  if (file.purpose === 'assistants') {
69
72
  return purposeAssistantsResponse({ file, workspaceAccessWhere });
70
73
  }
71
- const fileContentResponse = await client.files.content(fileId);
74
+ const fileContentResponse = await assistantClient.files.content(fileId);
72
75
  const fileData = await fileContentResponse.arrayBuffer();
73
76
  return new NextResponse(fileData, {
74
77
  headers: Object.assign(Object.assign({}, cacheHeaders), { 'Content-Type': (_a = fileContentResponse.headers.get('Content-Type')) !== null && _a !== void 0 ? _a : 'application/octet-stream', 'Content-Disposition': (_b = fileContentResponse.headers.get('Content-Disposition')) !== null && _b !== void 0 ? _b : 'inline' }),
@@ -1,5 +1,15 @@
1
1
  import type OpenAI from 'openai';
2
+ import { type PrismaClient } from '@prisma/client';
2
3
  import { type NextRequest, NextResponse } from 'next/server';
4
+ export declare const buildPOST: ({ prisma }?: {
5
+ prisma?: PrismaClient;
6
+ }) => (request: NextRequest) => Promise<NextResponse<{
7
+ error: string;
8
+ }> | NextResponse<{
9
+ file: OpenAI.Files.FileObject & {
10
+ _request_id?: string | null;
11
+ };
12
+ }>>;
3
13
  export declare const POST: (request: NextRequest) => Promise<NextResponse<{
4
14
  error: string;
5
15
  }> | NextResponse<{
@@ -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;AAEhC,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,IAAI,GAAU,SAAS,WAAW;;;;;;GAkG9C,CAAA;AAED,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
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,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,WAAW;;;;;;GA8G1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAhHC,WAAW;;;;;;GAgHE,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -4,9 +4,9 @@ import { NextResponse } from 'next/server';
4
4
  import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
5
5
  import { assistantClientAdapter } from '../../../lib/assistants/assistantClientAdapter';
6
6
  import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../lib/apiKeys/workspaceAccessWhere';
7
- import { prisma } from '../../../lib/prisma';
7
+ import { getPrisma } from '../../../lib/prisma';
8
8
  import { isOpenaiAssistantsStorageProvider } from '../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
9
- export const POST = async (request) => {
9
+ export const buildPOST = ({ prisma = getPrisma() } = {}) => async (request) => {
10
10
  var _a;
11
11
  const formData = await request.formData();
12
12
  const assistantId = formData.get('assistantId');
@@ -18,7 +18,10 @@ export const POST = async (request) => {
18
18
  return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
19
19
  }
20
20
  const file = formData.get('file');
21
- const workspaceAccessWhere = await getWorkspaceAccessWhere({ publicApiKey });
21
+ const workspaceAccessWhere = await getWorkspaceAccessWhere({
22
+ publicApiKey,
23
+ prisma,
24
+ });
22
25
  if (!workspaceAccessWhere) {
23
26
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
24
27
  }
@@ -64,9 +67,9 @@ export const POST = async (request) => {
64
67
  !assistant.openaiAssistantId) {
65
68
  return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
66
69
  }
67
- const client = assistantClientAdapter({ assistant, prisma });
70
+ const assistantClient = assistantClientAdapter({ assistant, prisma });
68
71
  const purpose = (_a = formData.get('purpose')) !== null && _a !== void 0 ? _a : 'assistants';
69
- const createFileResponse = await client.files.create(Object.assign({
72
+ const createFileResponse = await assistantClient.files.create(Object.assign({
70
73
  // @ts-expect-error file is Uploadable
71
74
  file,
72
75
  purpose }, (assistant.storageProviderType === StorageProviderType.OPENAI
@@ -81,6 +84,7 @@ export const POST = async (request) => {
81
84
  file: createFileResponse,
82
85
  }, { headers: cacheHeaders });
83
86
  };
87
+ export const POST = buildPOST();
84
88
  export const OPTIONS = () => NextResponse.json({}, {
85
89
  headers: cacheHeaders,
86
90
  });
@@ -1,7 +1,29 @@
1
1
  import { type NextRequest, NextResponse } from 'next/server';
2
2
  import OpenAI from 'openai';
3
+ import { type PrismaClient } from '@prisma/client';
3
4
  import type { Thread } from '@prisma/client';
4
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>>;
5
27
  export declare const GET: (request: NextRequest) => Promise<NextResponse<{
6
28
  error: string;
7
29
  }> | NextResponse<{
@@ -21,7 +43,8 @@ export declare const GET: (request: NextRequest) => Promise<NextResponse<{
21
43
  hasNextPage: boolean;
22
44
  lastId: null;
23
45
  }> | NextResponse<import("@superinterface/react/types/index").MessagesPage>>;
24
- export declare const buildPOST: ({ onSuccessCreateThread, }: {
46
+ export declare const buildPOST: ({ prisma, onSuccessCreateThread, }?: {
47
+ prisma?: PrismaClient;
25
48
  onSuccessCreateThread?: ({ thread, }: {
26
49
  thread: Thread;
27
50
  }) => void | Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/messages/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AA2B5C,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,eAAO,MAAM,GAAG,GAAU,SAAS,WAAW;;;;;;;;;;;;;;;;;;4EAmK7C,CAAA;AAED,eAAO,MAAM,SAAS,GACnB,4BAEE;IACD,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,sBA4e1B,CAAA;AAEH,eAAO,MAAM,IAAI,YA9eC,WAAW,sBA8eI,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/messages/route.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;AA2B5C,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,eAAO,MAAM,QAAQ,GAClB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,WAAW;;;;;;;;;;;;;;;;;;4EA2K1B,CAAA;AAEH,eAAO,MAAM,GAAG,YA7KE,WAAW;;;;;;;;;;;;;;;;;;4EA6KA,CAAA;AAE7B,eAAO,MAAM,SAAS,GACnB,qCAGE;IACD,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,qBAAqB,CAAC,EAAE,CAAC,EACvB,MAAM,GACP,EAAE;QACD,MAAM,EAAE,MAAM,CAAA;KACf,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB,MACC,SAAS,WAAW,sBA+f1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAjgBC,WAAW,sBAigBI,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}