"use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var s in t)a(e,s,{get:t[s],enumerable:!0})},R=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of S(t))!A.call(e,n)&&n!==s&&a(e,n,{get:()=>t[n],enumerable:!(o=h(t,n))||o.enumerable});return e};var E=e=>R(a({},"__esModule",{value:!0}),e);var P={};f(P,{createBlockApiHandler:()=>l,createChatApiHandler:()=>u,createNextPagesApiHandler:()=>d});module.exports=E(P);var c=require("ai");async function i(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(),o=t.reverse().find(r=>r.role==="user"),n=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:o?.content,chat_session_id:s})});return new c.StreamingTextResponse(n.body)}async function p(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 d=()=>async(e,t)=>e.nextUrl.pathname==="/api/steamship/chat"?i(e):e.nextUrl.pathname.includes("/api/steamship/blockId/")?p(e):new Response("Not found",{status:404});var l=()=>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"})};var m=require("ai"),u=()=>async e=>{let{messages:t,id:s}=await e.json(),o=t.reverse().find(r=>r.role==="user"),n=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:o?.content,chat_session_id:s})});return new m.StreamingTextResponse(n.body)};0&&(module.exports={createBlockApiHandler,createChatApiHandler,createNextPagesApiHandler});
//# sourceMappingURL=server.js.map