import{StreamingTextResponse as p}from"ai";async function a(e){if(e.method!=="POST")return new Response("Method not allowed",{status:405,headers:{Allow:"POST"}});if(!e.json)return new Response("Missing JSON",{status:500});let{messages:t,id:s}=await e.json(),n=t.reverse().find(r=>r.role==="user"),o=await fetch(`${process.env.STEAMSHIP_AGENT_URL}/prompt`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${process.env.STEAMSHIP_API_KEY}`},method:"POST",body:JSON.stringify({question:n?.content,chat_session_id:s})});return new p(o.body)}async function i(e){if(e.method!=="GET")return new Response("Method not allowed",{status:405,headers:{Allow:"GET"}});let s=e.nextUrl.pathname.split("/").pop();return fetch(`${process.env.STEAMSHIP_API_URL}/api/v1/block/${s}/raw`,{headers:{Authorization:`Bearer ${process.env.STEAMSHIP_API_KEY}`,"X-Workspace-Handle":process.env.STEAMSHIP_WORKSPACE_KEY||""},method:"GET"})}var c=()=>async(e,t)=>e.nextUrl.pathname==="/api/steamship/chat"?a(e):e.nextUrl.pathname.includes("/api/steamship/blockId/")?i(e):new Response("Not found",{status:404});var d=()=>async(e,t)=>{let s=t.params.id[1];return fetch(`${process.env.STEAMSHIP_API_URL}/api/v1/block/${s}/raw`,{headers:{Authorization:`Bearer ${process.env.STEAMSHIP_API_KEY}`,"X-Workspace-Handle":process.env.STEAMSHIP_WORKSPACE_KEY||""},method:"GET"})};import{StreamingTextResponse as l}from"ai";var m=()=>async e=>{let{messages:t,id:s}=await e.json(),n=t.reverse().find(r=>r.role==="user"),o=await fetch(`${process.env.STEAMSHIP_AGENT_URL}/prompt`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${process.env.STEAMSHIP_API_KEY}`},method:"POST",body:JSON.stringify({question:n?.content,chat_session_id:s})});return new l(o.body)};export{d as createBlockApiHandler,m as createChatApiHandler,c as createNextPagesApiHandler};
//# sourceMappingURL=server.mjs.map