@superinterface/server 1.0.30 → 1.0.31

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.
@@ -15,8 +15,8 @@
15
15
  "ampDevFiles": [],
16
16
  "polyfillFiles": [],
17
17
  "lowPriorityFiles": [
18
- "static/EBsRA1PJbwsSURXOeC5VV/_ssgManifest.js",
19
- "static/EBsRA1PJbwsSURXOeC5VV/_buildManifest.js"
18
+ "static/SAz3Y3qRZpSW_GEkZI_oP/_ssgManifest.js",
19
+ "static/SAz3Y3qRZpSW_GEkZI_oP/_buildManifest.js"
20
20
  ],
21
21
  "rootMainFiles": [],
22
22
  "ampFirstPages": []
@@ -1 +1 @@
1
- <!DOCTYPE html><!--EBsRA1PJbwsSURXOeC5VV--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/76a8a50dbf44f000.js"/><script src="/_next/static/chunks/079ce3572ffa07f6.js" async=""></script><script src="/_next/static/chunks/4649e58e35bcde4b.js" async=""></script><script src="/_next/static/chunks/turbopack-11882cf18a9eb231.js" async=""></script><script src="/_next/static/chunks/03d938d038bc30e3.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/76a8a50dbf44f000.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[96352,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n3:I[17753,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n4:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"OutletBoundary\"]\n6:I[33159,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"AsyncMetadataOutlet\"]\n8:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"ViewportBoundary\"]\na:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[25098,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"EBsRA1PJbwsSURXOeC5VV\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/03d938d038bc30e3.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style\",\"children\":404}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style\",\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",\"$undefined\"],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
1
+ <!DOCTYPE html><!--SAz3Y3qRZpSW_GEkZI_oP--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/76a8a50dbf44f000.js"/><script src="/_next/static/chunks/079ce3572ffa07f6.js" async=""></script><script src="/_next/static/chunks/4649e58e35bcde4b.js" async=""></script><script src="/_next/static/chunks/turbopack-11882cf18a9eb231.js" async=""></script><script src="/_next/static/chunks/03d938d038bc30e3.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/76a8a50dbf44f000.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[96352,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n3:I[17753,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n4:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"OutletBoundary\"]\n6:I[33159,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"AsyncMetadataOutlet\"]\n8:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"ViewportBoundary\"]\na:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[25098,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"SAz3Y3qRZpSW_GEkZI_oP\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/03d938d038bc30e3.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style\",\"children\":404}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style\",\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",\"$undefined\"],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
@@ -7,7 +7,7 @@
7
7
  a:I[51035,["/_next/static/chunks/03d938d038bc30e3.js"],"MetadataBoundary"]
8
8
  b:"$Sreact.suspense"
9
9
  d:I[25098,["/_next/static/chunks/03d938d038bc30e3.js"],"default"]
10
- 0:{"P":null,"b":"EBsRA1PJbwsSURXOeC5VV","p":"","c":["","_not-found"],"i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","script","script-0",{"src":"/_next/static/chunks/03d938d038bc30e3.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["/_not-found",["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L4",null,{"children":["$L5",["$","$L6",null,{"promise":"$@7"}]]}]]}],{},null,false]},null,false]},null,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],[["$","$L8",null,{"children":"$L9"}],null],["$","$La",null,{"children":["$","div",null,{"hidden":true,"children":["$","$b",null,{"fallback":null,"children":"$Lc"}]}]}]]}],false]],"m":"$undefined","G":["$d","$undefined"],"s":false,"S":true}
10
+ 0:{"P":null,"b":"SAz3Y3qRZpSW_GEkZI_oP","p":"","c":["","_not-found"],"i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","script","script-0",{"src":"/_next/static/chunks/03d938d038bc30e3.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["/_not-found",["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L4",null,{"children":["$L5",["$","$L6",null,{"promise":"$@7"}]]}]]}],{},null,false]},null,false]},null,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],[["$","$L8",null,{"children":"$L9"}],null],["$","$La",null,{"children":["$","div",null,{"hidden":true,"children":["$","$b",null,{"fallback":null,"children":"$Lc"}]}]}]]}],false]],"m":"$undefined","G":["$d","$undefined"],"s":false,"S":true}
11
11
  9:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
12
12
  5:null
13
13
  7:{"metadata":[],"error":null,"digest":"$undefined"}
@@ -1 +1 @@
1
- <!DOCTYPE html><!--EBsRA1PJbwsSURXOeC5VV--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/76a8a50dbf44f000.js"/><script src="/_next/static/chunks/079ce3572ffa07f6.js" async=""></script><script src="/_next/static/chunks/4649e58e35bcde4b.js" async=""></script><script src="/_next/static/chunks/turbopack-11882cf18a9eb231.js" async=""></script><script src="/_next/static/chunks/03d938d038bc30e3.js" async=""></script><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div>@superinterface/server is running.</div><!--$--><!--/$--><script src="/_next/static/chunks/76a8a50dbf44f000.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[96352,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n3:I[17753,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n4:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"OutletBoundary\"]\n6:I[33159,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"AsyncMetadataOutlet\"]\n8:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"ViewportBoundary\"]\na:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[25098,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"EBsRA1PJbwsSURXOeC5VV\",\"p\":\"\",\"c\":[\"\",\"\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/03d938d038bc30e3.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"div\",null,{\"children\":\"@superinterface/server is running.\"}],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
1
+ <!DOCTYPE html><!--SAz3Y3qRZpSW_GEkZI_oP--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/76a8a50dbf44f000.js"/><script src="/_next/static/chunks/079ce3572ffa07f6.js" async=""></script><script src="/_next/static/chunks/4649e58e35bcde4b.js" async=""></script><script src="/_next/static/chunks/turbopack-11882cf18a9eb231.js" async=""></script><script src="/_next/static/chunks/03d938d038bc30e3.js" async=""></script><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div>@superinterface/server is running.</div><!--$--><!--/$--><script src="/_next/static/chunks/76a8a50dbf44f000.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[96352,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n3:I[17753,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n4:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"OutletBoundary\"]\n6:I[33159,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"AsyncMetadataOutlet\"]\n8:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"ViewportBoundary\"]\na:I[51035,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[25098,[\"/_next/static/chunks/03d938d038bc30e3.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"SAz3Y3qRZpSW_GEkZI_oP\",\"p\":\"\",\"c\":[\"\",\"\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/03d938d038bc30e3.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"div\",null,{\"children\":\"@superinterface/server is running.\"}],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
@@ -7,7 +7,7 @@
7
7
  a:I[51035,["/_next/static/chunks/03d938d038bc30e3.js"],"MetadataBoundary"]
8
8
  b:"$Sreact.suspense"
9
9
  d:I[25098,["/_next/static/chunks/03d938d038bc30e3.js"],"default"]
10
- 0:{"P":null,"b":"EBsRA1PJbwsSURXOeC5VV","p":"","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","script","script-0",{"src":"/_next/static/chunks/03d938d038bc30e3.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","div",null,{"children":"@superinterface/server is running."}],null,["$","$L4",null,{"children":["$L5",["$","$L6",null,{"promise":"$@7"}]]}]]}],{},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$L8",null,{"children":"$L9"}],null],["$","$La",null,{"children":["$","div",null,{"hidden":true,"children":["$","$b",null,{"fallback":null,"children":"$Lc"}]}]}]]}],false]],"m":"$undefined","G":["$d",[]],"s":false,"S":true}
10
+ 0:{"P":null,"b":"SAz3Y3qRZpSW_GEkZI_oP","p":"","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","script","script-0",{"src":"/_next/static/chunks/03d938d038bc30e3.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","div",null,{"children":"@superinterface/server is running."}],null,["$","$L4",null,{"children":["$L5",["$","$L6",null,{"promise":"$@7"}]]}]]}],{},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$L8",null,{"children":"$L9"}],null],["$","$La",null,{"children":["$","div",null,{"hidden":true,"children":["$","$b",null,{"fallback":null,"children":"$Lc"}]}]}]]}],false]],"m":"$undefined","G":["$d",[]],"s":false,"S":true}
11
11
  9:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
12
12
  5:null
13
13
  7:{"metadata":[],"error":null,"digest":"$undefined"}
@@ -1,3 +1,3 @@
1
- module.exports=[86719,e=>{"use strict";e.s(["handler",()=>ee,"patchFetch",()=>Y,"routeModule",()=>X,"serverHooks",()=>Q,"workAsyncStorage",()=>J,"workUnitAsyncStorage",()=>Z],86719);var t=e.i(5865),a=e.i(43877),s=e.i(77767),r=e.i(92562),o=e.i(66256),n=e.i(5270),i=e.i(90231),d=e.i(82677),l=e.i(51081),u=e.i(89822),c=e.i(9124),p=e.i(39147),g=e.i(40568),R=e.i(87188),h=e.i(93695);e.i(57132);var v=e.i(80739);e.s(["GET",()=>K,"OPTIONS",()=>W,"POST",()=>B,"maxDuration",()=>D],26738),e.s(["GET",()=>K,"OPTIONS",()=>W,"POST",()=>B],58409);var m=e.i(24493),w=e.i(49493),S=e.i(29173),E=e.i(91877),T=e.i(70691),I=e.i(30611),f=e.i(13669),L=e.i(14554),q=e.i(95690);e.i(97691);var y=e.i(67775),P=e.i(7651),A=e.i(75247);let M=async({textContent:e,audioContent:t,assistant:a})=>{if(e)return e;if(t){let e=a.workspace.modelProviders.find(e=>e.type===S.ModelProviderType.OPENAI);if(!e?.apiKey)throw Error("No OpenAI API key found");let s=(0,P.buildOpenaiClient)({modelProvider:e}),r=t.split(",")[1];if((0,A.isEmpty)(r))return"-";let o=Buffer.from(r,"base64"),n=await (0,y.toFile)(o,"message.mp3");return(await s.audio.transcriptions.create({file:n,model:"whisper-1"})).text}throw Error("No content found")};var O=e.i(9949),N=e.i(56512),x=e.i(9394),k=e.i(38372);let C=async({assistant:e})=>{let t=(0,T.optimisticId)(),a=(0,N.default)().unix();return{data:await Promise.all(e.initialMessages.map(async(s,r)=>(0,T.serializeMessage)({message:{id:(0,T.optimisticId)(),role:s.role.toLowerCase(),created_at:a-r-1,object:"thread.message",content:[{type:"text",text:{annotations:[],value:s.content}}],run_id:null,assistant_id:s.role===S.MessageRole.ASSISTANT?(({assistant:e})=>{if((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:e.storageProviderType}))return e.openaiAssistantId;if((0,k.isResponsesStorageProvider)({storageProviderType:e.storageProviderType})||e.storageProviderType===S.StorageProviderType.SUPERINTERFACE_CLOUD)return e.id;throw Error("Invalid storage type")})({assistant:e}):null,thread_id:t,attachments:s.attachments,metadata:s.metadata,completed_at:a-r-1,incomplete_at:null,incomplete_details:null,status:"completed",runSteps:[]}}))),hasNextPage:!1,lastId:null}};var b=e.i(58011),j=e.i(39713),_=e.i(96227),H=e.i(57623),F=e.i(18527);let G=async({workspaceAccessWhere:e,prisma:t})=>(await t.workspace.findFirst({where:e})).id;var U=e.i(55897);let $=({threadId:e})=>e&&(0,U.validate)(e)?e:"00000000-0000-0000-0000-000000000000";var z=e.i(10671);let D=800,K=(({prisma:e})=>async t=>{let a=f.z.object({publicApiKey:f.z.string().optional(),assistantId:f.z.string().optional(),threadId:f.z.string().optional(),pageParam:f.z.string().optional()}).parse(Object.fromEntries(t.nextUrl.searchParams.entries())),s=await (0,O.workspaceAccessWhere)({publicApiKey:a.publicApiKey??null,prisma:e});if(!s)return w.NextResponse.json({error:"Invalid api key"},{status:400});let r=a.assistantId;if(!r)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistantId found.",workspaceId:await G({workspaceAccessWhere:s,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant id found"},{status:400});let{threadId:o,pageParam:n}=a,i=await e.assistant.findFirst({where:{id:r,workspace:s},include:{threads:{where:{id:$({threadId:o??null})},take:1,include:{assistant:{select:{storageProviderType:!0}}}},workspace:{include:{modelProviders:!0}},modelProvider:!0,initialMessages:{orderBy:{orderNumber:"desc"}},mcpServers:{include:{computerUseTool:!0,stdioTransport:!0,sseTransport:!0,httpTransport:!0}},tools:{include:{fileSearchTool:!0,webSearchTool:!0,imageGenerationTool:!0,codeInterpreterTool:!0,computerUseTool:!0}},functions:!0}});if(!i)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistant found.",workspaceId:await G({workspaceAccessWhere:s,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant found"},{status:400});if(!o)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});let d=i.threads[0];if(!d)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});let l=(0,q.assistantClientAdapter)({assistant:i,prisma:e,thread:d}),u=(0,L.storageThreadId)({thread:d});if(!u)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});try{return w.NextResponse.json(await (0,E.messagesResponse)({threadId:u,client:l,...n?{pageParam:n}:{}}),{headers:I.cacheHeaders})}catch(t){return console.dir({error:t},{depth:null}),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.GET,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to load messages: ${t.message}`,workspaceId:i.workspaceId,assistantId:i.id,threadId:d.id},prisma:e}),w.NextResponse.json({error:"Failed to load messages."},{status:500})}})({prisma:m.prisma}),B=(({prisma:e,onSuccessCreateThread:t=()=>void 0})=>async a=>{let s,r,o,n=f.z.object({audioContent:f.z.any().optional(),content:f.z.any().optional(),attachments:f.z.array(f.z.any()).optional(),assistantId:f.z.string().optional(),publicApiKey:f.z.string().optional(),threadId:f.z.string().optional()}).passthrough().parse(await a.json()),{audioContent:i,content:d,attachments:l,assistantId:u,publicApiKey:c,...p}=n,g=await (0,O.workspaceAccessWhere)({publicApiKey:c??null,prisma:e});if(!g)return w.NextResponse.json({error:"Invalid api key"},{status:400});if(!u)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistantId found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistantId found."},{status:400});if(!d&&!i&&!l?.length)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No content found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No content found."},{status:400});let R=await e.assistant.findFirst({where:{id:u,workspace:g},include:{threads:{where:{id:$({threadId:n.threadId??null})},include:{assistant:{select:{storageProviderType:!0}}},take:1},workspace:{include:{modelProviders:!0}},mcpServers:{include:{computerUseTool:!0,stdioTransport:!0,sseTransport:!0,httpTransport:!0}},tools:{include:{fileSearchTool:!0,webSearchTool:!0,imageGenerationTool:!0,codeInterpreterTool:!0,computerUseTool:{include:{mcpServer:{include:{stdioTransport:!0,sseTransport:!0,httpTransport:!0}}}}}},functions:{include:{handler:{include:{requestHandler:!0,firecrawlHandler:!0,replicateHandler:!0,clientToolHandler:!0,assistantHandler:!0,createTaskHandler:!0,listTasksHandler:!0,updateTaskHandler:!0,deleteTaskHandler:!0}}}},modelProvider:!0,initialMessages:{orderBy:{orderNumber:"asc"}}}});if(!R)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistant found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant found."},{status:400});if((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})&&!R.openaiAssistantId)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"Assistant setup is not done.",workspaceId:R.workspaceId,assistantId:R.id},prisma:e}),w.NextResponse.json({error:"Assistant setup is not done."},{status:400});let h=R.threads[0],v=!1;if(!h){let a=(0,q.assistantClientAdapter)({assistant:R,prisma:e});try{h=await (0,_.createThread)({client:a,assistant:R,prisma:e,variables:p}),t({thread:h})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create thread: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id},prisma:e}),w.NextResponse.json({error:"Failed to create thread."},{status:500})}v=!0}try{s=(0,L.storageThreadId)({thread:h})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:"Failed to get storage thread id.",workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get storage thread id."},{status:500})}if(!s&&((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})||(0,k.isResponsesStorageProvider)({storageProviderType:R.storageProviderType})))try{s=await (0,H.managedOpenaiThreadId)({assistant:R,threadId:h.id,prisma:e})}catch(t){return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to get managed openai thread id: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get managed openai thread id."},{status:500})}if(!s)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:"Invalid thread configuration.",workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Invalid thread configuration."},{status:500});try{r=await M({audioContent:i,textContent:d,assistant:R})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to get content: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get content."},{status:500})}let m=(0,q.assistantClientAdapter)({assistant:R,prisma:e,thread:h});try{await m.beta.threads.messages.create(s,{role:"user",content:r,...l?.length?{attachments:l}:{},metadata:(0,z.serializeMetadata)({variables:p,workspaceId:R.workspaceId,prisma:e})})}catch(t){return console.log({error:t}),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create message: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to create message."},{status:500})}try{o=await m.beta.threads.runs.create(s,await (0,b.createRunOpts)({assistant:R,thread:h,prisma:e}))}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create run stream: ${(({error:e})=>e instanceof Error?`${e.message}${(({error:e})=>e.cause instanceof Error?` ${e.cause.message}`:e.cause?` ${e.cause}`:"")({error:e})}`:String(e))({error:t})}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to create run stream."},{status:500})}let I=null,y=null;return new Response((0,E.createMessageResponse)({client:m,createRunStream:o,handleToolCall:(0,j.handleToolCall)({assistant:R,thread:h,prisma:e}),onStart:({controller:e})=>{if(v)return(0,T.enqueueJson)({controller:e,value:{event:"thread.created",data:(({thread:e})=>({id:(0,L.storageThreadId)({thread:e}),object:"thread",created_at:(0,N.default)(e.createdAt).unix(),metadata:e.metadata}))({thread:h})}})},onError:async({error:t})=>{a.signal.aborted||(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Thread Run failed: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e})},onEvent:({event:t,data:a})=>{"thread.run.failed"===t?(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Thread Run failed: ${a.last_error?.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}):"thread.run.in_progress"===t?I=a:"thread.run.completed"===t&&(y=a)},onClose:async()=>{!y&&(0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})&&I&&await m.beta.threads.runs.cancel(I.id,{thread_id:I.thread_id})}}),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})})({prisma:m.prisma}),W=()=>w.NextResponse.json({},{headers:I.cacheHeaders});e.i(58409);var V=e.i(26738);let X=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/messages/route",pathname:"/api/messages",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts",nextConfigOutput:"",userland:V}),{workAsyncStorage:J,workUnitAsyncStorage:Z,serverHooks:Q}=X;function Y(){return(0,s.patchFetch)({workAsyncStorage:J,workUnitAsyncStorage:Z})}async function ee(e,t,s){var m;let w="/api/messages/route";w=w.replace(/\/index$/,"")||"/";let S=await X.prepare(e,t,{srcPage:w,multiZoneDraftMode:!1});if(!S)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:E,params:T,nextConfig:I,isDraftMode:f,prerenderManifest:L,routerServerContext:q,isOnDemandRevalidate:y,revalidateOnlyGenerated:P,resolvedPathname:A}=S,M=(0,n.normalizeAppPath)(w),O=!!(L.dynamicRoutes[M]||L.routes[A]);if(O&&!f){let e=!!L.routes[A],t=L.dynamicRoutes[M];if(t&&!1===t.fallback&&!e)throw new h.NoFallbackError}let N=null;!O||X.isDev||f||(N="/index"===(N=A)?"/":N);let x=!0===X.isDev||!O,k=O&&!x,C=e.method||"GET",b=(0,o.getTracer)(),j=b.getActiveScopeSpan(),_={params:T,prerenderManifest:L,renderOpts:{experimental:{cacheComponents:!!I.experimental.cacheComponents,authInterrupts:!!I.experimental.authInterrupts},supportsDynamicResponse:x,incrementalCache:(0,r.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:null==(m=I.experimental)?void 0:m.cacheLife,isRevalidate:k,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,s)=>X.onRequestError(e,t,s,q)},sharedContext:{buildId:E}},H=new i.NodeNextRequest(e),F=new i.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(H,(0,d.signalFromNodeResponse)(t));try{let n=async a=>X.handle(G,_).finally(()=>{if(!a)return;a.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=b.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==l.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=s.get("next.route");if(r){let e=`${C} ${r}`;a.setAttributes({"next.route":r,"http.route":r,"next.span_name":e}),a.updateName(e)}else a.updateName(`${C} ${e.url}`)}),i=async o=>{var i,d;let l=async({previousCacheEntry:a})=>{try{if(!(0,r.getRequestMeta)(e,"minimalMode")&&y&&P&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await n(o);e.fetchMetrics=_.renderOpts.fetchMetrics;let d=_.renderOpts.pendingWaitUntil;d&&s.waitUntil&&(s.waitUntil(d),d=void 0);let l=_.renderOpts.collectedTags;if(!O)return await (0,c.sendResponse)(H,F,i,_.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,p.toNodeOutgoingHttpHeaders)(i.headers);l&&(t[R.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==_.renderOpts.collectedRevalidate&&!(_.renderOpts.collectedRevalidate>=R.INFINITE_CACHE)&&_.renderOpts.collectedRevalidate,s=void 0===_.renderOpts.collectedExpire||_.renderOpts.collectedExpire>=R.INFINITE_CACHE?void 0:_.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:s}}}}catch(t){throw(null==a?void 0:a.isStale)&&await X.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isRevalidate:k,isOnDemandRevalidate:y})},q),t}},h=await X.handleResponse({req:e,nextConfig:I,cacheKey:N,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:L,isRoutePPREnabled:!1,isOnDemandRevalidate:y,revalidateOnlyGenerated:P,responseGenerator:l,waitUntil:s.waitUntil});if(!O)return null;if((null==h||null==(i=h.value)?void 0:i.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==h||null==(d=h.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,r.getRequestMeta)(e,"minimalMode")||t.setHeader("x-nextjs-cache",y?"REVALIDATED":h.isMiss?"MISS":h.isStale?"STALE":"HIT"),f&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(h.value.headers);return(0,r.getRequestMeta)(e,"minimalMode")&&O||m.delete(R.NEXT_CACHE_TAGS_HEADER),!h.cacheControl||t.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,g.getCacheControlHeader)(h.cacheControl)),await (0,c.sendResponse)(H,F,new Response(h.value.body,{headers:m,status:h.value.status||200})),null};j?await i(j):await b.withPropagatedContext(e.headers,()=>b.trace(l.BaseServerSpan.handleRequest,{spanName:`${C} ${e.url}`,kind:o.SpanKind.SERVER,attributes:{"http.method":C,"http.target":e.url}},i))}catch(t){if(t instanceof h.NoFallbackError||await X.onRequestError(e,t,{routerKind:"App Router",routePath:M,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isRevalidate:k,isOnDemandRevalidate:y})}),O)throw t;return await (0,c.sendResponse)(H,F,new Response(null,{status:500})),null}}}];
1
+ module.exports=[86719,e=>{"use strict";e.s(["handler",()=>et,"patchFetch",()=>ee,"routeModule",()=>J,"serverHooks",()=>Y,"workAsyncStorage",()=>Z,"workUnitAsyncStorage",()=>Q],86719);var t=e.i(5865),a=e.i(43877),s=e.i(77767),r=e.i(92562),o=e.i(66256),n=e.i(5270),i=e.i(90231),d=e.i(82677),l=e.i(51081),u=e.i(89822),c=e.i(9124),p=e.i(39147),g=e.i(40568),R=e.i(87188),h=e.i(93695);e.i(57132);var v=e.i(80739);e.s(["GET",()=>B,"OPTIONS",()=>V,"POST",()=>W,"maxDuration",()=>K],26738),e.s(["GET",()=>B,"OPTIONS",()=>V,"POST",()=>W],58409);var m=e.i(24493),w=e.i(49493),S=e.i(29173),E=e.i(91877),T=e.i(70691),I=e.i(30611),f=e.i(13669),L=e.i(14554),q=e.i(95690);e.i(97691);var y=e.i(67775),P=e.i(7651),A=e.i(75247);let M=async({textContent:e,audioContent:t,assistant:a})=>{if(e)return e;if(t){let e=a.workspace.modelProviders.find(e=>e.type===S.ModelProviderType.OPENAI);if(!e?.apiKey)throw Error("No OpenAI API key found");let s=(0,P.buildOpenaiClient)({modelProvider:e}),r=t.split(",")[1];if((0,A.isEmpty)(r))return"-";let o=Buffer.from(r,"base64"),n=await (0,y.toFile)(o,"message.mp3");return(await s.audio.transcriptions.create({file:n,model:"whisper-1"})).text}throw Error("No content found")};var O=e.i(9949),N=e.i(56512),x=e.i(9394),k=e.i(38372);let C=async({assistant:e})=>{let t=(0,T.optimisticId)(),a=(0,N.default)().unix();return{data:await Promise.all(e.initialMessages.map(async(s,r)=>(0,T.serializeMessage)({message:{id:(0,T.optimisticId)(),role:s.role.toLowerCase(),created_at:a-r-1,object:"thread.message",content:[{type:"text",text:{annotations:[],value:s.content}}],run_id:null,assistant_id:s.role===S.MessageRole.ASSISTANT?(({assistant:e})=>{if((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:e.storageProviderType}))return e.openaiAssistantId;if((0,k.isResponsesStorageProvider)({storageProviderType:e.storageProviderType})||e.storageProviderType===S.StorageProviderType.SUPERINTERFACE_CLOUD)return e.id;throw Error("Invalid storage type")})({assistant:e}):null,thread_id:t,attachments:s.attachments,metadata:s.metadata,completed_at:a-r-1,incomplete_at:null,incomplete_details:null,status:"completed",runSteps:[]}}))),hasNextPage:!1,lastId:null}};var b=e.i(58011),j=e.i(39713),_=e.i(96227),H=e.i(57623),F=e.i(18527);let G=async({workspaceAccessWhere:e,prisma:t})=>(await t.workspace.findFirst({where:e})).id;var U=e.i(55897);let $=({threadId:e})=>e&&(0,U.validate)(e)?e:"00000000-0000-0000-0000-000000000000";var z=e.i(10671);let D=({error:e})=>e instanceof Error?`${e.message}${(({error:e})=>e.cause instanceof Error?` ${e.cause.message}`:e.cause?` ${e.cause}`:"")({error:e})}`:String(e),K=800,B=(({prisma:e})=>async t=>{let a=f.z.object({publicApiKey:f.z.string().optional(),assistantId:f.z.string().optional(),threadId:f.z.string().optional(),pageParam:f.z.string().optional()}).parse(Object.fromEntries(t.nextUrl.searchParams.entries())),s=await (0,O.workspaceAccessWhere)({publicApiKey:a.publicApiKey??null,prisma:e});if(!s)return w.NextResponse.json({error:"Invalid api key"},{status:400});let r=a.assistantId;if(!r)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistantId found.",workspaceId:await G({workspaceAccessWhere:s,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant id found"},{status:400});let{threadId:o,pageParam:n}=a,i=await e.assistant.findFirst({where:{id:r,workspace:s},include:{threads:{where:{id:$({threadId:o??null})},take:1,include:{assistant:{select:{storageProviderType:!0}}}},workspace:{include:{modelProviders:!0}},modelProvider:!0,initialMessages:{orderBy:{orderNumber:"desc"}},mcpServers:{include:{computerUseTool:!0,stdioTransport:!0,sseTransport:!0,httpTransport:!0}},tools:{include:{fileSearchTool:!0,webSearchTool:!0,imageGenerationTool:!0,codeInterpreterTool:!0,computerUseTool:!0}},functions:!0}});if(!i)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistant found.",workspaceId:await G({workspaceAccessWhere:s,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant found"},{status:400});if(!o)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});let d=i.threads[0];if(!d)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});let l=(0,q.assistantClientAdapter)({assistant:i,prisma:e,thread:d}),u=(0,L.storageThreadId)({thread:d});if(!u)return w.NextResponse.json(await C({assistant:i}),{headers:I.cacheHeaders});try{return w.NextResponse.json(await (0,E.messagesResponse)({threadId:u,client:l,...n?{pageParam:n}:{}}),{headers:I.cacheHeaders})}catch(t){return console.dir({error:t},{depth:null}),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.GET,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to load messages: ${t.message}`,workspaceId:i.workspaceId,assistantId:i.id,threadId:d.id},prisma:e}),w.NextResponse.json({error:"Failed to load messages."},{status:500})}})({prisma:m.prisma}),W=(({prisma:e,onSuccessCreateThread:t=()=>void 0})=>async a=>{let s,r,o,n=f.z.object({audioContent:f.z.any().optional(),content:f.z.any().optional(),attachments:f.z.array(f.z.any()).optional(),assistantId:f.z.string().optional(),publicApiKey:f.z.string().optional(),threadId:f.z.string().optional()}).passthrough().parse(await a.json()),{audioContent:i,content:d,attachments:l,assistantId:u,publicApiKey:c,...p}=n,g=await (0,O.workspaceAccessWhere)({publicApiKey:c??null,prisma:e});if(!g)return w.NextResponse.json({error:"Invalid api key"},{status:400});if(!u)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistantId found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistantId found."},{status:400});if(!d&&!i&&!l?.length)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No content found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No content found."},{status:400});let R=await e.assistant.findFirst({where:{id:u,workspace:g},include:{threads:{where:{id:$({threadId:n.threadId??null})},include:{assistant:{select:{storageProviderType:!0}}},take:1},workspace:{include:{modelProviders:!0}},mcpServers:{include:{computerUseTool:!0,stdioTransport:!0,sseTransport:!0,httpTransport:!0}},tools:{include:{fileSearchTool:!0,webSearchTool:!0,imageGenerationTool:!0,codeInterpreterTool:!0,computerUseTool:{include:{mcpServer:{include:{stdioTransport:!0,sseTransport:!0,httpTransport:!0}}}}}},functions:{include:{handler:{include:{requestHandler:!0,firecrawlHandler:!0,replicateHandler:!0,clientToolHandler:!0,assistantHandler:!0,createTaskHandler:!0,listTasksHandler:!0,updateTaskHandler:!0,deleteTaskHandler:!0}}}},modelProvider:!0,initialMessages:{orderBy:{orderNumber:"asc"}}}});if(!R)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"No assistant found.",workspaceId:await G({workspaceAccessWhere:g,prisma:e})},prisma:e}),w.NextResponse.json({error:"No assistant found."},{status:400});if((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})&&!R.openaiAssistantId)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:400,message:"Assistant setup is not done.",workspaceId:R.workspaceId,assistantId:R.id},prisma:e}),w.NextResponse.json({error:"Assistant setup is not done."},{status:400});let h=R.threads[0],v=!1;if(!h){let a=(0,q.assistantClientAdapter)({assistant:R,prisma:e});try{h=await (0,_.createThread)({client:a,assistant:R,prisma:e,variables:p}),t({thread:h})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create thread: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id},prisma:e}),w.NextResponse.json({error:"Failed to create thread."},{status:500})}v=!0}try{s=(0,L.storageThreadId)({thread:h})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:"Failed to get storage thread id.",workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get storage thread id."},{status:500})}if(!s&&((0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})||(0,k.isResponsesStorageProvider)({storageProviderType:R.storageProviderType})))try{s=await (0,H.managedOpenaiThreadId)({assistant:R,threadId:h.id,prisma:e})}catch(t){return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to get managed openai thread id: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get managed openai thread id."},{status:500})}if(!s)return(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:"Invalid thread configuration.",workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Invalid thread configuration."},{status:500});try{r=await M({audioContent:i,textContent:d,assistant:R})}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to get content: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to get content."},{status:500})}let m=(0,q.assistantClientAdapter)({assistant:R,prisma:e,thread:h});try{await m.beta.threads.messages.create(s,{role:"user",content:r,...l?.length?{attachments:l}:{},metadata:(0,z.serializeMetadata)({variables:p,workspaceId:R.workspaceId,prisma:e})})}catch(t){return console.log({error:t}),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create message: ${t.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to create message."},{status:500})}try{o=await m.beta.threads.runs.create(s,await (0,b.createRunOpts)({assistant:R,thread:h,prisma:e}))}catch(t){return console.error(t),(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Failed to create run stream: ${D({error:t})}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}),w.NextResponse.json({error:"Failed to create run stream."},{status:500})}let I=null,y=null;return new Response((0,E.createMessageResponse)({client:m,createRunStream:o,handleToolCall:(0,j.handleToolCall)({assistant:R,thread:h,prisma:e}),onStart:({controller:e})=>{if(v)return(0,T.enqueueJson)({controller:e,value:{event:"thread.created",data:(({thread:e})=>({id:(0,L.storageThreadId)({thread:e}),object:"thread",created_at:(0,N.default)(e.createdAt).unix(),metadata:e.metadata}))({thread:h})}})},onError:async({error:t})=>{a.signal.aborted||(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Thread Run failed: ${D({error:t})}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e})},onEvent:({event:t,data:a})=>{"thread.run.failed"===t?(0,F.createLog)({log:{requestMethod:S.LogRequestMethod.POST,requestRoute:S.LogRequestRoute.MESSAGES,level:S.LogLevel.ERROR,status:500,message:`Thread Run failed: ${a.last_error?.message}`,workspaceId:R.workspaceId,assistantId:R.id,threadId:h.id},prisma:e}):"thread.run.in_progress"===t?I=a:"thread.run.completed"===t&&(y=a)},onClose:async()=>{!y&&(0,x.isOpenaiAssistantsStorageProvider)({storageProviderType:R.storageProviderType})&&I&&await m.beta.threads.runs.cancel(I.id,{thread_id:I.thread_id})}}),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})})({prisma:m.prisma}),V=()=>w.NextResponse.json({},{headers:I.cacheHeaders});e.i(58409);var X=e.i(26738);let J=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/messages/route",pathname:"/api/messages",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts",nextConfigOutput:"",userland:X}),{workAsyncStorage:Z,workUnitAsyncStorage:Q,serverHooks:Y}=J;function ee(){return(0,s.patchFetch)({workAsyncStorage:Z,workUnitAsyncStorage:Q})}async function et(e,t,s){var m;let w="/api/messages/route";w=w.replace(/\/index$/,"")||"/";let S=await J.prepare(e,t,{srcPage:w,multiZoneDraftMode:!1});if(!S)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:E,params:T,nextConfig:I,isDraftMode:f,prerenderManifest:L,routerServerContext:q,isOnDemandRevalidate:y,revalidateOnlyGenerated:P,resolvedPathname:A}=S,M=(0,n.normalizeAppPath)(w),O=!!(L.dynamicRoutes[M]||L.routes[A]);if(O&&!f){let e=!!L.routes[A],t=L.dynamicRoutes[M];if(t&&!1===t.fallback&&!e)throw new h.NoFallbackError}let N=null;!O||J.isDev||f||(N="/index"===(N=A)?"/":N);let x=!0===J.isDev||!O,k=O&&!x,C=e.method||"GET",b=(0,o.getTracer)(),j=b.getActiveScopeSpan(),_={params:T,prerenderManifest:L,renderOpts:{experimental:{cacheComponents:!!I.experimental.cacheComponents,authInterrupts:!!I.experimental.authInterrupts},supportsDynamicResponse:x,incrementalCache:(0,r.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:null==(m=I.experimental)?void 0:m.cacheLife,isRevalidate:k,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,s)=>J.onRequestError(e,t,s,q)},sharedContext:{buildId:E}},H=new i.NodeNextRequest(e),F=new i.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(H,(0,d.signalFromNodeResponse)(t));try{let n=async a=>J.handle(G,_).finally(()=>{if(!a)return;a.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=b.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==l.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=s.get("next.route");if(r){let e=`${C} ${r}`;a.setAttributes({"next.route":r,"http.route":r,"next.span_name":e}),a.updateName(e)}else a.updateName(`${C} ${e.url}`)}),i=async o=>{var i,d;let l=async({previousCacheEntry:a})=>{try{if(!(0,r.getRequestMeta)(e,"minimalMode")&&y&&P&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await n(o);e.fetchMetrics=_.renderOpts.fetchMetrics;let d=_.renderOpts.pendingWaitUntil;d&&s.waitUntil&&(s.waitUntil(d),d=void 0);let l=_.renderOpts.collectedTags;if(!O)return await (0,c.sendResponse)(H,F,i,_.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,p.toNodeOutgoingHttpHeaders)(i.headers);l&&(t[R.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==_.renderOpts.collectedRevalidate&&!(_.renderOpts.collectedRevalidate>=R.INFINITE_CACHE)&&_.renderOpts.collectedRevalidate,s=void 0===_.renderOpts.collectedExpire||_.renderOpts.collectedExpire>=R.INFINITE_CACHE?void 0:_.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:s}}}}catch(t){throw(null==a?void 0:a.isStale)&&await J.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isRevalidate:k,isOnDemandRevalidate:y})},q),t}},h=await J.handleResponse({req:e,nextConfig:I,cacheKey:N,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:L,isRoutePPREnabled:!1,isOnDemandRevalidate:y,revalidateOnlyGenerated:P,responseGenerator:l,waitUntil:s.waitUntil});if(!O)return null;if((null==h||null==(i=h.value)?void 0:i.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==h||null==(d=h.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,r.getRequestMeta)(e,"minimalMode")||t.setHeader("x-nextjs-cache",y?"REVALIDATED":h.isMiss?"MISS":h.isStale?"STALE":"HIT"),f&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(h.value.headers);return(0,r.getRequestMeta)(e,"minimalMode")&&O||m.delete(R.NEXT_CACHE_TAGS_HEADER),!h.cacheControl||t.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,g.getCacheControlHeader)(h.cacheControl)),await (0,c.sendResponse)(H,F,new Response(h.value.body,{headers:m,status:h.value.status||200})),null};j?await i(j):await b.withPropagatedContext(e.headers,()=>b.trace(l.BaseServerSpan.handleRequest,{spanName:`${C} ${e.url}`,kind:o.SpanKind.SERVER,attributes:{"http.method":C,"http.target":e.url}},i))}catch(t){if(t instanceof h.NoFallbackError||await J.onRequestError(e,t,{routerKind:"App Router",routePath:M,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isRevalidate:k,isOnDemandRevalidate:y})}),O)throw t;return await (0,c.sendResponse)(H,F,new Response(null,{status:500})),null}}}];
2
2
 
3
3
  //# sourceMappingURL=c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/buildRoute.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/initialMessagesResponse.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/threads/validThreadId.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/errors/serializeError.ts","turbopack:///[project]/supercorp/superinterface/node_modules/next/dist/esm/build/templates/app-route.js","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/messages/content.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/getWorkspaceId.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/serializeThread.ts"],"sourcesContent":["import { prisma } from '@/lib/prisma'\nimport { buildGET, buildOPTIONS, buildPOST, maxDuration } from './buildRoute'\n\nexport { maxDuration }\n\nexport const GET = buildGET({ prisma })\n\nexport const POST = buildPOST({ prisma })\n\nexport const OPTIONS = buildOPTIONS()\n","import { type NextRequest, NextResponse } from 'next/server'\nimport OpenAI from 'openai'\nimport {\n LogRequestMethod,\n LogRequestRoute,\n LogLevel,\n type PrismaClient,\n} from '@prisma/client'\nimport type { Thread } from '@prisma/client'\nimport {\n messagesResponse,\n createMessageResponse,\n} from '@superinterface/react/server'\nimport { enqueueJson } from '@superinterface/react/utils'\nimport { cacheHeaders } from '@/lib/cache/cacheHeaders'\nimport { z } from 'zod'\nimport { storageThreadId as getStorageThreadId } from '@/lib/threads/storageThreadId'\nimport { assistantClientAdapter } from '@/lib/assistants/assistantClientAdapter'\nimport { content as getContent } from '@/lib/messages/content'\nimport { workspaceAccessWhere as getWorkspaceAccessWhere } from '@/lib/apiKeys/workspaceAccessWhere'\nimport { initialMessagesResponse } from './lib/initialMessagesResponse'\nimport { createRunOpts } from '@/lib/runs/createRunOpts'\nimport { handleToolCall } from '@/lib/toolCalls/handleToolCall'\nimport { createThread } from '@/lib/threads/createThread'\nimport { managedOpenaiThreadId } from '@/lib/threads/managedOpenaiThreadId'\nimport { createLog } from '@/lib/logs/createLog'\nimport { serializeThread } from './lib/serializeThread'\nimport { getWorkspaceId } from './lib/getWorkspaceId'\nimport { validThreadId } from '@/lib/threads/validThreadId'\nimport { isOpenaiAssistantsStorageProvider } from '@/lib/storageProviders/isOpenaiAssistantsStorageProvider'\nimport { serializeMetadata } from '@/lib/metadata/serializeMetadata'\nimport { isResponsesStorageProvider } from '@/lib/storageProviders/isResponsesStorageProvider'\nimport { serializeError } from '@/lib/errors/serializeError'\n\nexport const maxDuration = 800\n\nexport const buildGET =\n ({ prisma }: { prisma: PrismaClient }) =>\n async (request: NextRequest) => {\n const paramsResult = z\n .object({\n publicApiKey: z.string().optional(),\n assistantId: z.string().optional(),\n threadId: z.string().optional(),\n pageParam: z.string().optional(),\n })\n .parse(Object.fromEntries(request.nextUrl.searchParams.entries()))\n\n const workspaceAccessWhere = await getWorkspaceAccessWhere({\n publicApiKey: paramsResult.publicApiKey ?? null,\n prisma,\n })\n\n if (!workspaceAccessWhere) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n const assistantId = paramsResult.assistantId\n\n if (!assistantId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistantId found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistant id found' },\n { status: 400 },\n )\n }\n\n const { threadId, pageParam } = paramsResult\n\n const assistant = await prisma.assistant.findFirst({\n where: {\n id: assistantId,\n workspace: workspaceAccessWhere,\n },\n include: {\n threads: {\n where: {\n id: validThreadId({ threadId: threadId ?? null }),\n },\n take: 1,\n include: {\n assistant: {\n select: {\n storageProviderType: true,\n },\n },\n },\n },\n workspace: {\n include: {\n modelProviders: true,\n },\n },\n modelProvider: true,\n initialMessages: {\n orderBy: {\n orderNumber: 'desc',\n },\n },\n mcpServers: {\n include: {\n computerUseTool: true,\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n tools: {\n include: {\n fileSearchTool: true,\n webSearchTool: true,\n imageGenerationTool: true,\n codeInterpreterTool: true,\n computerUseTool: true,\n },\n },\n functions: true,\n },\n })\n\n if (!assistant) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistant found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json({ error: 'No assistant found' }, { status: 400 })\n }\n\n if (!threadId) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n const thread = assistant.threads[0]\n\n if (!thread) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n const assistantClient = assistantClientAdapter({\n assistant,\n prisma,\n thread,\n })\n\n const storageThreadId = getStorageThreadId({\n thread,\n })\n\n if (!storageThreadId) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n try {\n return NextResponse.json(\n await messagesResponse({\n threadId: storageThreadId,\n client: assistantClient,\n ...(pageParam ? { pageParam } : {}),\n }),\n {\n headers: cacheHeaders,\n },\n )\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.dir({ error }, { depth: null })\n createLog({\n log: {\n requestMethod: LogRequestMethod.GET,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to load messages: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n return NextResponse.json(\n { error: 'Failed to load messages.' },\n { status: 500 },\n )\n }\n }\n\nexport const buildPOST =\n ({\n prisma,\n onSuccessCreateThread = () => void 0,\n }: {\n prisma: PrismaClient\n onSuccessCreateThread?: ({\n thread,\n }: {\n thread: Thread\n }) => void | Promise<void>\n }) =>\n async (request: NextRequest) => {\n const bodyResult = z\n .object({\n audioContent: z.any().optional(),\n content: z.any().optional(),\n attachments: z.array(z.any()).optional(),\n assistantId: z.string().optional(),\n publicApiKey: z.string().optional(),\n threadId: z.string().optional(),\n })\n .passthrough()\n .parse(await request.json())\n\n const {\n audioContent,\n content: textContent,\n attachments,\n assistantId,\n publicApiKey,\n ...variables\n } = bodyResult\n\n const workspaceAccessWhere = await getWorkspaceAccessWhere({\n publicApiKey: publicApiKey ?? null,\n prisma,\n })\n\n if (!workspaceAccessWhere) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!assistantId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistantId found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistantId found.' },\n { status: 400 },\n )\n }\n\n if (!textContent && !audioContent && !attachments?.length) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No content found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json({ error: 'No content found.' }, { status: 400 })\n }\n\n const assistant = await prisma.assistant.findFirst({\n where: {\n id: assistantId,\n workspace: workspaceAccessWhere,\n },\n include: {\n threads: {\n where: {\n id: validThreadId({ threadId: bodyResult.threadId ?? null }),\n },\n include: {\n assistant: {\n select: {\n storageProviderType: true,\n },\n },\n },\n take: 1,\n },\n workspace: {\n include: {\n modelProviders: true,\n },\n },\n mcpServers: {\n include: {\n computerUseTool: true,\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n tools: {\n include: {\n fileSearchTool: true,\n webSearchTool: true,\n imageGenerationTool: true,\n codeInterpreterTool: true,\n computerUseTool: {\n include: {\n mcpServer: {\n include: {\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n },\n },\n },\n },\n functions: {\n include: {\n handler: {\n include: {\n requestHandler: true,\n firecrawlHandler: true,\n replicateHandler: true,\n clientToolHandler: true,\n assistantHandler: true,\n createTaskHandler: true,\n listTasksHandler: true,\n updateTaskHandler: true,\n deleteTaskHandler: true,\n },\n },\n },\n },\n modelProvider: true,\n initialMessages: {\n orderBy: {\n orderNumber: 'asc',\n },\n },\n },\n })\n\n if (!assistant) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistant found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistant found.' },\n { status: 400 },\n )\n }\n\n if (\n isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }) &&\n !assistant.openaiAssistantId\n ) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'Assistant setup is not done.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Assistant setup is not done.' },\n { status: 400 },\n )\n }\n\n let thread = assistant.threads[0]\n let isThreadCreated = false\n\n if (!thread) {\n const createThreadClient = assistantClientAdapter({ assistant, prisma })\n\n try {\n thread = await createThread({\n client: createThreadClient,\n assistant,\n prisma,\n variables: variables as Record<string, string>,\n })\n\n onSuccessCreateThread({ thread })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create thread: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create thread.' },\n { status: 500 },\n )\n }\n\n isThreadCreated = true\n }\n\n let storageThreadId\n\n try {\n storageThreadId = getStorageThreadId({\n thread,\n })\n } catch (error) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: 'Failed to get storage thread id.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get storage thread id.' },\n { status: 500 },\n )\n }\n\n if (\n !storageThreadId &&\n (isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }) ||\n isResponsesStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }))\n ) {\n try {\n storageThreadId = await managedOpenaiThreadId({\n assistant,\n threadId: thread.id,\n prisma,\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to get managed openai thread id: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get managed openai thread id.' },\n { status: 500 },\n )\n }\n }\n\n if (!storageThreadId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: 'Invalid thread configuration.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Invalid thread configuration.' },\n { status: 500 },\n )\n }\n\n let content\n\n try {\n content = await getContent({\n audioContent,\n textContent,\n assistant,\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to get content: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get content.' },\n { status: 500 },\n )\n }\n\n const assistantClient = assistantClientAdapter({\n assistant,\n prisma,\n thread,\n })\n\n try {\n await assistantClient.beta.threads.messages.create(storageThreadId, {\n role: 'user',\n content,\n ...(attachments?.length ? { attachments } : {}),\n metadata: serializeMetadata({\n variables,\n workspaceId: assistant.workspaceId,\n prisma,\n }),\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.log({ error })\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create message: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create message.' },\n { status: 500 },\n )\n }\n\n let createRunStream\n\n try {\n createRunStream = await assistantClient.beta.threads.runs.create(\n storageThreadId,\n await createRunOpts({ assistant, thread, prisma }),\n )\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create run stream: ${serializeError({ error })}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create run stream.' },\n { status: 500 },\n )\n }\n\n let latestInProgressRunData: OpenAI.Beta.Threads.Runs.Run | null = null\n let latestCompletedRunData: OpenAI.Beta.Threads.Runs.Run | null = null\n\n return new Response(\n createMessageResponse({\n client: assistantClient,\n createRunStream,\n handleToolCall: handleToolCall({ assistant, thread, prisma }),\n onStart: ({\n controller,\n }: {\n controller: ReadableStreamDefaultController\n }) => {\n if (!isThreadCreated) return\n\n return enqueueJson({\n controller,\n value: {\n event: 'thread.created',\n data: serializeThread({\n thread,\n }),\n },\n })\n },\n onError: async ({ error }) => {\n if (request.signal.aborted) return\n\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Thread Run failed: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n // if (latestInProgressRunData) {\n // await assistantClient.beta.threads.runs.cancel(\n // latestInProgressRunData.thread_id,\n // latestInProgressRunData.id,\n // )\n // }\n },\n onEvent: ({ event, data }) => {\n if (event === 'thread.run.failed') {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Thread Run failed: ${data.last_error?.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n } else if (event === 'thread.run.in_progress') {\n latestInProgressRunData = data\n } else if (event === 'thread.run.completed') {\n latestCompletedRunData = data\n }\n },\n onClose: async () => {\n if (latestCompletedRunData) return\n if (\n !isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n )\n return\n\n if (latestInProgressRunData) {\n await assistantClient.beta.threads.runs.cancel(\n latestInProgressRunData.id,\n {\n thread_id: latestInProgressRunData.thread_id,\n },\n )\n }\n },\n }),\n {\n status: 200,\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n },\n },\n )\n }\n\nexport const buildOPTIONS = () => () =>\n NextResponse.json(\n {},\n {\n headers: cacheHeaders,\n },\n )\n","import dayjs from 'dayjs'\nimport type OpenAI from 'openai'\nimport {\n Prisma,\n Assistant,\n StorageProviderType,\n MessageRole,\n} from '@prisma/client'\nimport { optimisticId, serializeMessage } from '@superinterface/react/utils'\nimport { isOpenaiAssistantsStorageProvider } from '@/lib/storageProviders/isOpenaiAssistantsStorageProvider'\nimport { isResponsesStorageProvider } from '@/lib/storageProviders/isResponsesStorageProvider'\n\nconst assistantId = ({ assistant }: { assistant: Assistant }) => {\n if (\n isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n ) {\n return assistant.openaiAssistantId\n }\n\n if (\n isResponsesStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n ) {\n return assistant.id\n }\n\n if (\n assistant.storageProviderType === StorageProviderType.SUPERINTERFACE_CLOUD\n ) {\n return assistant.id\n }\n\n throw new Error('Invalid storage type')\n}\n\nexport const initialMessagesResponse = async ({\n assistant,\n}: {\n assistant: Prisma.AssistantGetPayload<{\n include: {\n initialMessages: true\n }\n }>\n}) => {\n const threadId = optimisticId()\n const initialCreatedAt = dayjs().unix()\n\n return {\n data: await Promise.all(\n assistant.initialMessages.map(\n async (\n message: (typeof assistant.initialMessages)[number],\n index: number,\n ) =>\n serializeMessage({\n message: {\n id: optimisticId(),\n role: message.role.toLowerCase() as OpenAI.Beta.Threads.Messages.Message['role'],\n created_at: initialCreatedAt - index - 1,\n object:\n 'thread.message' as OpenAI.Beta.Threads.Messages.Message['object'],\n content: [\n {\n type: 'text',\n text: {\n annotations: [],\n value: message.content,\n },\n } as OpenAI.Beta.Threads.Messages.TextContentBlock,\n ],\n run_id: null,\n assistant_id:\n message.role === MessageRole.ASSISTANT\n ? assistantId({ assistant })\n : null,\n thread_id: threadId,\n attachments:\n message.attachments as OpenAI.Beta.Threads.Messages.Message['attachments'],\n metadata: message.metadata,\n completed_at: initialCreatedAt - index - 1,\n incomplete_at: null,\n incomplete_details: null,\n status: 'completed',\n runSteps: [],\n },\n }),\n ),\n ),\n hasNextPage: false,\n lastId: null,\n }\n}\n","import { validate } from 'uuid'\n\nconst fallbackUuid = '00000000-0000-0000-0000-000000000000'\n\nexport const validThreadId = ({ threadId }: { threadId: string | null }) => {\n if (!threadId) return fallbackUuid\n if (!validate(threadId)) return fallbackUuid\n\n return threadId\n}\n","const causeMessage = ({ error }: { error: Error }) => {\n if (error.cause instanceof Error) return ` ${error.cause.message}`\n if (error.cause) return ` ${error.cause}`\n return ''\n}\n\nexport const serializeError = ({ error }: { error: unknown }): string => {\n if (!(error instanceof Error)) return String(error)\n\n return `${error.message}${causeMessage({ error })}`\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/messages/route\",\n pathname: \"/api/messages\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n var _nextConfig_experimental;\n let srcPage = \"/api/messages/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isRevalidate = isIsr && !supportsDynamicResponse;\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n cacheComponents: Boolean(nextConfig.experimental.cacheComponents),\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: (_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.cacheLife,\n isRevalidate,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext)=>routeModule.onRequestError(req, error, errorContext, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${req.url}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!getRequestMeta(req, 'minimalMode') && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n }, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!getRequestMeta(req, 'minimalMode')) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(getRequestMeta(req, 'minimalMode') && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${req.url}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n });\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { ModelProviderType, Prisma } from '@prisma/client'\nimport { toFile } from 'openai'\nimport { buildOpenaiClient } from '@/lib/modelProviders/buildOpenaiClient'\nimport { isEmpty } from 'radash'\n\ntype Args = {\n textContent?: string\n audioContent?: string\n assistant: Prisma.AssistantGetPayload<{\n include: {\n workspace: {\n include: {\n modelProviders: true\n }\n }\n }\n }>\n}\n\nexport const content = async ({\n textContent,\n audioContent,\n assistant,\n}: Args) => {\n if (textContent) {\n return textContent\n }\n\n if (audioContent) {\n const openaiModelProvider = assistant.workspace.modelProviders.find(\n (mp) => mp.type === ModelProviderType.OPENAI,\n )\n\n if (!openaiModelProvider?.apiKey) {\n throw new Error('No OpenAI API key found')\n }\n\n const client = buildOpenaiClient({\n modelProvider: openaiModelProvider,\n })\n\n const base64Content = audioContent.split(',')[1]\n\n if (isEmpty(base64Content)) {\n return '-'\n }\n\n const audioBuffer = Buffer.from(base64Content, 'base64')\n const file = await toFile(audioBuffer, 'message.mp3')\n\n const transcription = await client.audio.transcriptions.create({\n file,\n model: 'whisper-1',\n })\n\n return transcription.text\n }\n\n throw new Error('No content found')\n}\n","import type { Prisma, PrismaClient } from '@prisma/client'\n\nexport const getWorkspaceId = async ({\n workspaceAccessWhere,\n prisma,\n}: {\n workspaceAccessWhere: Prisma.WorkspaceWhereInput\n prisma: PrismaClient\n}) =>\n (await prisma.workspace.findFirst({\n where: workspaceAccessWhere,\n }))!.id\n","import { Prisma } from '@prisma/client'\nimport dayjs from 'dayjs'\nimport { storageThreadId } from '@/lib/threads/storageThreadId'\n\nexport const serializeThread = ({\n thread,\n}: {\n thread: Prisma.ThreadGetPayload<{\n include: {\n assistant: {\n select: {\n storageProviderType: true\n }\n }\n }\n }>\n}) => ({\n id: storageThreadId({ thread }),\n object: 'thread',\n created_at: dayjs(thread.createdAt).unix(),\n metadata: thread.metadata,\n})\n"],"names":[],"mappings":"sLKAA,IAAA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,CAAA,CAAA,OAAA,IAAA,EAAA,EAAA,CAAA,CAAA,uILfA,IAAA,EAAA,EAAA,CAAA,CAAA,OCAA,EAAA,EAAA,CAAA,CAAA,OAEA,EAAA,EAAA,CAAA,CAAA,OAOA,EAAA,EAAA,CAAA,CAAA,OAIA,EAAA,EAAA,C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ACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GACvB,AAD0B,CAE9B,EAAG,GAEf,CAAE,MAAO,EAAK,CAcV,GAbI,AAAE,CAAD,YAAgB,EAAA,eAAe,EAChC,CADmC,KAC7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,cAClC,uBACA,CACJ,EACJ,GAIA,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[5]}
1
+ {"version":3,"sources":["turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/buildRoute.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/initialMessagesResponse.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/threads/validThreadId.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/errors/serializeError.ts","turbopack:///[project]/supercorp/superinterface/node_modules/next/dist/esm/build/templates/app-route.js","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/messages/content.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/getWorkspaceId.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/messages/lib/serializeThread.ts"],"sourcesContent":["import { prisma } from '@/lib/prisma'\nimport { buildGET, buildOPTIONS, buildPOST, maxDuration } from './buildRoute'\n\nexport { maxDuration }\n\nexport const GET = buildGET({ prisma })\n\nexport const POST = buildPOST({ prisma })\n\nexport const OPTIONS = buildOPTIONS()\n","import { type NextRequest, NextResponse } from 'next/server'\nimport OpenAI from 'openai'\nimport {\n LogRequestMethod,\n LogRequestRoute,\n LogLevel,\n type PrismaClient,\n} from '@prisma/client'\nimport type { Thread } from '@prisma/client'\nimport {\n messagesResponse,\n createMessageResponse,\n} from '@superinterface/react/server'\nimport { enqueueJson } from '@superinterface/react/utils'\nimport { cacheHeaders } from '@/lib/cache/cacheHeaders'\nimport { z } from 'zod'\nimport { storageThreadId as getStorageThreadId } from '@/lib/threads/storageThreadId'\nimport { assistantClientAdapter } from '@/lib/assistants/assistantClientAdapter'\nimport { content as getContent } from '@/lib/messages/content'\nimport { workspaceAccessWhere as getWorkspaceAccessWhere } from '@/lib/apiKeys/workspaceAccessWhere'\nimport { initialMessagesResponse } from './lib/initialMessagesResponse'\nimport { createRunOpts } from '@/lib/runs/createRunOpts'\nimport { handleToolCall } from '@/lib/toolCalls/handleToolCall'\nimport { createThread } from '@/lib/threads/createThread'\nimport { managedOpenaiThreadId } from '@/lib/threads/managedOpenaiThreadId'\nimport { createLog } from '@/lib/logs/createLog'\nimport { serializeThread } from './lib/serializeThread'\nimport { getWorkspaceId } from './lib/getWorkspaceId'\nimport { validThreadId } from '@/lib/threads/validThreadId'\nimport { isOpenaiAssistantsStorageProvider } from '@/lib/storageProviders/isOpenaiAssistantsStorageProvider'\nimport { serializeMetadata } from '@/lib/metadata/serializeMetadata'\nimport { isResponsesStorageProvider } from '@/lib/storageProviders/isResponsesStorageProvider'\nimport { serializeError } from '@/lib/errors/serializeError'\n\nexport const maxDuration = 800\n\nexport const buildGET =\n ({ prisma }: { prisma: PrismaClient }) =>\n async (request: NextRequest) => {\n const paramsResult = z\n .object({\n publicApiKey: z.string().optional(),\n assistantId: z.string().optional(),\n threadId: z.string().optional(),\n pageParam: z.string().optional(),\n })\n .parse(Object.fromEntries(request.nextUrl.searchParams.entries()))\n\n const workspaceAccessWhere = await getWorkspaceAccessWhere({\n publicApiKey: paramsResult.publicApiKey ?? null,\n prisma,\n })\n\n if (!workspaceAccessWhere) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n const assistantId = paramsResult.assistantId\n\n if (!assistantId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistantId found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistant id found' },\n { status: 400 },\n )\n }\n\n const { threadId, pageParam } = paramsResult\n\n const assistant = await prisma.assistant.findFirst({\n where: {\n id: assistantId,\n workspace: workspaceAccessWhere,\n },\n include: {\n threads: {\n where: {\n id: validThreadId({ threadId: threadId ?? null }),\n },\n take: 1,\n include: {\n assistant: {\n select: {\n storageProviderType: true,\n },\n },\n },\n },\n workspace: {\n include: {\n modelProviders: true,\n },\n },\n modelProvider: true,\n initialMessages: {\n orderBy: {\n orderNumber: 'desc',\n },\n },\n mcpServers: {\n include: {\n computerUseTool: true,\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n tools: {\n include: {\n fileSearchTool: true,\n webSearchTool: true,\n imageGenerationTool: true,\n codeInterpreterTool: true,\n computerUseTool: true,\n },\n },\n functions: true,\n },\n })\n\n if (!assistant) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistant found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json({ error: 'No assistant found' }, { status: 400 })\n }\n\n if (!threadId) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n const thread = assistant.threads[0]\n\n if (!thread) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n const assistantClient = assistantClientAdapter({\n assistant,\n prisma,\n thread,\n })\n\n const storageThreadId = getStorageThreadId({\n thread,\n })\n\n if (!storageThreadId) {\n return NextResponse.json(await initialMessagesResponse({ assistant }), {\n headers: cacheHeaders,\n })\n }\n\n try {\n return NextResponse.json(\n await messagesResponse({\n threadId: storageThreadId,\n client: assistantClient,\n ...(pageParam ? { pageParam } : {}),\n }),\n {\n headers: cacheHeaders,\n },\n )\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.dir({ error }, { depth: null })\n createLog({\n log: {\n requestMethod: LogRequestMethod.GET,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to load messages: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n return NextResponse.json(\n { error: 'Failed to load messages.' },\n { status: 500 },\n )\n }\n }\n\nexport const buildPOST =\n ({\n prisma,\n onSuccessCreateThread = () => void 0,\n }: {\n prisma: PrismaClient\n onSuccessCreateThread?: ({\n thread,\n }: {\n thread: Thread\n }) => void | Promise<void>\n }) =>\n async (request: NextRequest) => {\n const bodyResult = z\n .object({\n audioContent: z.any().optional(),\n content: z.any().optional(),\n attachments: z.array(z.any()).optional(),\n assistantId: z.string().optional(),\n publicApiKey: z.string().optional(),\n threadId: z.string().optional(),\n })\n .passthrough()\n .parse(await request.json())\n\n const {\n audioContent,\n content: textContent,\n attachments,\n assistantId,\n publicApiKey,\n ...variables\n } = bodyResult\n\n const workspaceAccessWhere = await getWorkspaceAccessWhere({\n publicApiKey: publicApiKey ?? null,\n prisma,\n })\n\n if (!workspaceAccessWhere) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!assistantId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistantId found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistantId found.' },\n { status: 400 },\n )\n }\n\n if (!textContent && !audioContent && !attachments?.length) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No content found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json({ error: 'No content found.' }, { status: 400 })\n }\n\n const assistant = await prisma.assistant.findFirst({\n where: {\n id: assistantId,\n workspace: workspaceAccessWhere,\n },\n include: {\n threads: {\n where: {\n id: validThreadId({ threadId: bodyResult.threadId ?? null }),\n },\n include: {\n assistant: {\n select: {\n storageProviderType: true,\n },\n },\n },\n take: 1,\n },\n workspace: {\n include: {\n modelProviders: true,\n },\n },\n mcpServers: {\n include: {\n computerUseTool: true,\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n tools: {\n include: {\n fileSearchTool: true,\n webSearchTool: true,\n imageGenerationTool: true,\n codeInterpreterTool: true,\n computerUseTool: {\n include: {\n mcpServer: {\n include: {\n stdioTransport: true,\n sseTransport: true,\n httpTransport: true,\n },\n },\n },\n },\n },\n },\n functions: {\n include: {\n handler: {\n include: {\n requestHandler: true,\n firecrawlHandler: true,\n replicateHandler: true,\n clientToolHandler: true,\n assistantHandler: true,\n createTaskHandler: true,\n listTasksHandler: true,\n updateTaskHandler: true,\n deleteTaskHandler: true,\n },\n },\n },\n },\n modelProvider: true,\n initialMessages: {\n orderBy: {\n orderNumber: 'asc',\n },\n },\n },\n })\n\n if (!assistant) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'No assistant found.',\n workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'No assistant found.' },\n { status: 400 },\n )\n }\n\n if (\n isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }) &&\n !assistant.openaiAssistantId\n ) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 400,\n message: 'Assistant setup is not done.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Assistant setup is not done.' },\n { status: 400 },\n )\n }\n\n let thread = assistant.threads[0]\n let isThreadCreated = false\n\n if (!thread) {\n const createThreadClient = assistantClientAdapter({ assistant, prisma })\n\n try {\n thread = await createThread({\n client: createThreadClient,\n assistant,\n prisma,\n variables: variables as Record<string, string>,\n })\n\n onSuccessCreateThread({ thread })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create thread: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create thread.' },\n { status: 500 },\n )\n }\n\n isThreadCreated = true\n }\n\n let storageThreadId\n\n try {\n storageThreadId = getStorageThreadId({\n thread,\n })\n } catch (error) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: 'Failed to get storage thread id.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get storage thread id.' },\n { status: 500 },\n )\n }\n\n if (\n !storageThreadId &&\n (isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }) ||\n isResponsesStorageProvider({\n storageProviderType: assistant.storageProviderType,\n }))\n ) {\n try {\n storageThreadId = await managedOpenaiThreadId({\n assistant,\n threadId: thread.id,\n prisma,\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to get managed openai thread id: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get managed openai thread id.' },\n { status: 500 },\n )\n }\n }\n\n if (!storageThreadId) {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: 'Invalid thread configuration.',\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Invalid thread configuration.' },\n { status: 500 },\n )\n }\n\n let content\n\n try {\n content = await getContent({\n audioContent,\n textContent,\n assistant,\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to get content: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to get content.' },\n { status: 500 },\n )\n }\n\n const assistantClient = assistantClientAdapter({\n assistant,\n prisma,\n thread,\n })\n\n try {\n await assistantClient.beta.threads.messages.create(storageThreadId, {\n role: 'user',\n content,\n ...(attachments?.length ? { attachments } : {}),\n metadata: serializeMetadata({\n variables,\n workspaceId: assistant.workspaceId,\n prisma,\n }),\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.log({ error })\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create message: ${error.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create message.' },\n { status: 500 },\n )\n }\n\n let createRunStream\n\n try {\n createRunStream = await assistantClient.beta.threads.runs.create(\n storageThreadId,\n await createRunOpts({ assistant, thread, prisma }),\n )\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n console.error(error)\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Failed to create run stream: ${serializeError({ error })}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n return NextResponse.json(\n { error: 'Failed to create run stream.' },\n { status: 500 },\n )\n }\n\n let latestInProgressRunData: OpenAI.Beta.Threads.Runs.Run | null = null\n let latestCompletedRunData: OpenAI.Beta.Threads.Runs.Run | null = null\n\n return new Response(\n createMessageResponse({\n client: assistantClient,\n createRunStream,\n handleToolCall: handleToolCall({ assistant, thread, prisma }),\n onStart: ({\n controller,\n }: {\n controller: ReadableStreamDefaultController\n }) => {\n if (!isThreadCreated) return\n\n return enqueueJson({\n controller,\n value: {\n event: 'thread.created',\n data: serializeThread({\n thread,\n }),\n },\n })\n },\n onError: async ({ error }) => {\n if (request.signal.aborted) return\n\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Thread Run failed: ${serializeError({ error })}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n\n // if (latestInProgressRunData) {\n // await assistantClient.beta.threads.runs.cancel(\n // latestInProgressRunData.thread_id,\n // latestInProgressRunData.id,\n // )\n // }\n },\n onEvent: ({ event, data }) => {\n if (event === 'thread.run.failed') {\n createLog({\n log: {\n requestMethod: LogRequestMethod.POST,\n requestRoute: LogRequestRoute.MESSAGES,\n level: LogLevel.ERROR,\n status: 500,\n message: `Thread Run failed: ${data.last_error?.message}`,\n workspaceId: assistant.workspaceId,\n assistantId: assistant.id,\n threadId: thread.id,\n },\n prisma,\n })\n } else if (event === 'thread.run.in_progress') {\n latestInProgressRunData = data\n } else if (event === 'thread.run.completed') {\n latestCompletedRunData = data\n }\n },\n onClose: async () => {\n if (latestCompletedRunData) return\n if (\n !isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n )\n return\n\n if (latestInProgressRunData) {\n await assistantClient.beta.threads.runs.cancel(\n latestInProgressRunData.id,\n {\n thread_id: latestInProgressRunData.thread_id,\n },\n )\n }\n },\n }),\n {\n status: 200,\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n },\n },\n )\n }\n\nexport const buildOPTIONS = () => () =>\n NextResponse.json(\n {},\n {\n headers: cacheHeaders,\n },\n )\n","import dayjs from 'dayjs'\nimport type OpenAI from 'openai'\nimport {\n Prisma,\n Assistant,\n StorageProviderType,\n MessageRole,\n} from '@prisma/client'\nimport { optimisticId, serializeMessage } from '@superinterface/react/utils'\nimport { isOpenaiAssistantsStorageProvider } from '@/lib/storageProviders/isOpenaiAssistantsStorageProvider'\nimport { isResponsesStorageProvider } from '@/lib/storageProviders/isResponsesStorageProvider'\n\nconst assistantId = ({ assistant }: { assistant: Assistant }) => {\n if (\n isOpenaiAssistantsStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n ) {\n return assistant.openaiAssistantId\n }\n\n if (\n isResponsesStorageProvider({\n storageProviderType: assistant.storageProviderType,\n })\n ) {\n return assistant.id\n }\n\n if (\n assistant.storageProviderType === StorageProviderType.SUPERINTERFACE_CLOUD\n ) {\n return assistant.id\n }\n\n throw new Error('Invalid storage type')\n}\n\nexport const initialMessagesResponse = async ({\n assistant,\n}: {\n assistant: Prisma.AssistantGetPayload<{\n include: {\n initialMessages: true\n }\n }>\n}) => {\n const threadId = optimisticId()\n const initialCreatedAt = dayjs().unix()\n\n return {\n data: await Promise.all(\n assistant.initialMessages.map(\n async (\n message: (typeof assistant.initialMessages)[number],\n index: number,\n ) =>\n serializeMessage({\n message: {\n id: optimisticId(),\n role: message.role.toLowerCase() as OpenAI.Beta.Threads.Messages.Message['role'],\n created_at: initialCreatedAt - index - 1,\n object:\n 'thread.message' as OpenAI.Beta.Threads.Messages.Message['object'],\n content: [\n {\n type: 'text',\n text: {\n annotations: [],\n value: message.content,\n },\n } as OpenAI.Beta.Threads.Messages.TextContentBlock,\n ],\n run_id: null,\n assistant_id:\n message.role === MessageRole.ASSISTANT\n ? assistantId({ assistant })\n : null,\n thread_id: threadId,\n attachments:\n message.attachments as OpenAI.Beta.Threads.Messages.Message['attachments'],\n metadata: message.metadata,\n completed_at: initialCreatedAt - index - 1,\n incomplete_at: null,\n incomplete_details: null,\n status: 'completed',\n runSteps: [],\n },\n }),\n ),\n ),\n hasNextPage: false,\n lastId: null,\n }\n}\n","import { validate } from 'uuid'\n\nconst fallbackUuid = '00000000-0000-0000-0000-000000000000'\n\nexport const validThreadId = ({ threadId }: { threadId: string | null }) => {\n if (!threadId) return fallbackUuid\n if (!validate(threadId)) return fallbackUuid\n\n return threadId\n}\n","const causeMessage = ({ error }: { error: Error }) => {\n if (error.cause instanceof Error) return ` ${error.cause.message}`\n if (error.cause) return ` ${error.cause}`\n return ''\n}\n\nexport const serializeError = ({ error }: { error: unknown }): string => {\n if (!(error instanceof Error)) return String(error)\n\n return `${error.message}${causeMessage({ error })}`\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/messages/route\",\n pathname: \"/api/messages\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/supercorp/superinterface/packages/server/src/app/api/messages/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n var _nextConfig_experimental;\n let srcPage = \"/api/messages/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isRevalidate = isIsr && !supportsDynamicResponse;\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n cacheComponents: Boolean(nextConfig.experimental.cacheComponents),\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: (_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.cacheLife,\n isRevalidate,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext)=>routeModule.onRequestError(req, error, errorContext, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${req.url}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!getRequestMeta(req, 'minimalMode') && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n }, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!getRequestMeta(req, 'minimalMode')) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(getRequestMeta(req, 'minimalMode') && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${req.url}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n });\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { ModelProviderType, Prisma } from '@prisma/client'\nimport { toFile } from 'openai'\nimport { buildOpenaiClient } from '@/lib/modelProviders/buildOpenaiClient'\nimport { isEmpty } from 'radash'\n\ntype Args = {\n textContent?: string\n audioContent?: string\n assistant: Prisma.AssistantGetPayload<{\n include: {\n workspace: {\n include: {\n modelProviders: true\n }\n }\n }\n }>\n}\n\nexport const content = async ({\n textContent,\n audioContent,\n assistant,\n}: Args) => {\n if (textContent) {\n return textContent\n }\n\n if (audioContent) {\n const openaiModelProvider = assistant.workspace.modelProviders.find(\n (mp) => mp.type === ModelProviderType.OPENAI,\n )\n\n if (!openaiModelProvider?.apiKey) {\n throw new Error('No OpenAI API key found')\n }\n\n const client = buildOpenaiClient({\n modelProvider: openaiModelProvider,\n })\n\n const base64Content = audioContent.split(',')[1]\n\n if (isEmpty(base64Content)) {\n return '-'\n }\n\n const audioBuffer = Buffer.from(base64Content, 'base64')\n const file = await toFile(audioBuffer, 'message.mp3')\n\n const transcription = await client.audio.transcriptions.create({\n file,\n model: 'whisper-1',\n })\n\n return transcription.text\n }\n\n throw new Error('No content found')\n}\n","import type { Prisma, PrismaClient } from '@prisma/client'\n\nexport const getWorkspaceId = async ({\n workspaceAccessWhere,\n prisma,\n}: {\n workspaceAccessWhere: Prisma.WorkspaceWhereInput\n prisma: PrismaClient\n}) =>\n (await prisma.workspace.findFirst({\n where: workspaceAccessWhere,\n }))!.id\n","import { Prisma } from '@prisma/client'\nimport dayjs from 'dayjs'\nimport { storageThreadId } from '@/lib/threads/storageThreadId'\n\nexport const serializeThread = ({\n thread,\n}: {\n thread: Prisma.ThreadGetPayload<{\n include: {\n assistant: {\n select: {\n storageProviderType: true\n }\n }\n }\n }>\n}) => ({\n id: storageThreadId({ thread }),\n object: 'thread',\n created_at: dayjs(thread.createdAt).unix(),\n metadata: thread.metadata,\n})\n"],"names":[],"mappings":"uLKAA,IAAA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,CAAA,CAAA,OAAA,IAAA,EAAA,EAAA,CAAA,CAAA,uILfA,IAAA,EAAA,EAAA,CAAA,CAAA,OCAA,EAAA,EAAA,CAAA,CAAA,OAEA,EAAA,EAAA,CAAA,CAAA,OAOA,EAAA,EAAA,CAAA,CAAA,OAIA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OKhBA,EAAA,CAAA,CAAA,OAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OAgBO,IAAM,EAAU,MAAO,aAC5B,CAAW,cACX,CAAY,WACZ,CAAS,CACJ,IACL,GAAI,EACF,OAAO,EAGT,EAJiB,CAIb,EAAc,CAChB,IAAM,EAAsB,EAAU,SAAS,CAAC,cAAc,CAAC,IAAI,CACjE,AAAC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