@@ -53,13 +53,14 @@ export const honoCtxToAppCtx = (c: Context<AppEnv>): AppContext => {
5353 token : c . req . header ( "Authorization" ) ?. replace ( "Bearer " , "" ) ,
5454 kbFileProcessor : c . env . KB_FILE_PROCESSOR ,
5555 workspaceDO : c . env . WORKSPACE_DB ,
56- workspace : slug && root
57- ? {
58- root,
59- slug,
60- value : workspace ,
61- }
62- : undefined ,
56+ workspace :
57+ slug && root
58+ ? {
59+ root,
60+ slug,
61+ value : workspace ,
62+ }
63+ : undefined ,
6364 } ;
6465} ;
6566
@@ -101,12 +102,14 @@ const createMCPHandlerFor = (
101102 {
102103 annotations : tool . annotations ,
103104 description : tool . description ,
104- inputSchema : "shape" in tool . inputSchema
105- ? ( tool . inputSchema . shape as z . ZodRawShape )
106- : z . object ( { } ) . shape ,
105+ inputSchema :
106+ "shape" in tool . inputSchema
107+ ? ( tool . inputSchema . shape as z . ZodRawShape )
108+ : z . object ( { } ) . shape ,
107109 outputSchema :
108- tool . outputSchema && typeof tool . outputSchema === "object" &&
109- "shape" in tool . outputSchema
110+ tool . outputSchema &&
111+ typeof tool . outputSchema === "object" &&
112+ "shape" in tool . outputSchema
110113 ? ( tool . outputSchema . shape as z . ZodRawShape )
111114 : z . object ( { } ) . shape ,
112115 } ,
@@ -182,28 +185,30 @@ const createToolCallHandlerFor = <
182185app . use ( logger ( ) ) ;
183186
184187// Enable CORS for all routes on api.deco.chat and localhost
185- app . use ( cors ( {
186- origin : ( origin ) => origin ,
187- maxAge : 86400 , // one day
188- allowMethods : [ "HEAD" , "GET" , "POST" , "PUT" , "DELETE" , "PATCH" , "OPTIONS" ] ,
189- allowHeaders : [
190- "Content-Type" ,
191- "Authorization" ,
192- "Cookie" ,
193- "Accept" ,
194- "cache-control" ,
195- "pragma" ,
196- "x-trace-debug-id" ,
197- "x-deno-isolate-instance-id" ,
198- ] ,
199- exposeHeaders : [
200- "Content-Type" ,
201- "Authorization" ,
202- "Set-Cookie" ,
203- "x-trace-debug-id" ,
204- ] ,
205- credentials : true ,
206- } ) ) ;
188+ app . use (
189+ cors ( {
190+ origin : ( origin ) => origin ,
191+ maxAge : 86400 , // one day
192+ allowMethods : [ "HEAD" , "GET" , "POST" , "PUT" , "DELETE" , "PATCH" , "OPTIONS" ] ,
193+ allowHeaders : [
194+ "Content-Type" ,
195+ "Authorization" ,
196+ "Cookie" ,
197+ "Accept" ,
198+ "cache-control" ,
199+ "pragma" ,
200+ "x-trace-debug-id" ,
201+ "x-deno-isolate-instance-id" ,
202+ ] ,
203+ exposeHeaders : [
204+ "Content-Type" ,
205+ "Authorization" ,
206+ "Set-Cookie" ,
207+ "x-trace-debug-id" ,
208+ ] ,
209+ credentials : true ,
210+ } ) ,
211+ ) ;
207212
208213app . use ( withContextMiddleware ) ;
209214app . use ( setUserMiddleware ) ;
@@ -221,24 +226,12 @@ app.use(async (c, next) => {
221226app . use ( withActorsMiddleware ) ;
222227
223228// MCP endpoint handlers
224- app . all (
225- "/mcp" ,
226- createMCPHandlerFor ( GLOBAL_TOOLS ) ,
227- ) ;
228- app . all (
229- "/:root/:slug/mcp" ,
230- createMCPHandlerFor ( WORKSPACE_TOOLS ) ,
231- ) ;
232- app . all (
233- "/:root/:slug/agents/:agentId/mcp" ,
234- createMCPHandlerFor ( AGENT_TOOLS ) ,
235- ) ;
229+ app . all ( "/mcp" , createMCPHandlerFor ( GLOBAL_TOOLS ) ) ;
230+ app . all ( "/:root/:slug/mcp" , createMCPHandlerFor ( WORKSPACE_TOOLS ) ) ;
231+ app . all ( "/:root/:slug/agents/:agentId/mcp" , createMCPHandlerFor ( AGENT_TOOLS ) ) ;
236232
237233// Tool call endpoint handlers
238- app . post (
239- "/tools/call/:tool" ,
240- createToolCallHandlerFor ( GLOBAL_TOOLS ) ,
241- ) ;
234+ app . post ( "/tools/call/:tool" , createToolCallHandlerFor ( GLOBAL_TOOLS ) ) ;
242235app . post (
243236 "/:root/:slug/tools/call/:tool" ,
244237 createToolCallHandlerFor ( WORKSPACE_TOOLS ) ,
@@ -302,8 +295,8 @@ app.get("/files/:root/:slug/:path{.+}", async (c) => {
302295 }
303296
304297 return c . body ( response . body , 200 , {
305- "Content-Type" : response . headers . get ( "content-type" ) ||
306- "application/octet-stream" ,
298+ "Content-Type" :
299+ response . headers . get ( "content-type" ) || "application/octet-stream" ,
307300 } ) ;
308301} ) ;
309302
@@ -313,7 +306,7 @@ const getPublicKey = async (): Promise<JsonWebKey> => {
313306} ;
314307app . get ( "/.well-known/jwks.json" , async ( ) => {
315308 return Response . json ( {
316- keys : [ { ...await getPublicKey ( ) , kid : DECO_CHAT_KEY_ID } ] ,
309+ keys : [ { ...( await getPublicKey ( ) ) , kid : DECO_CHAT_KEY_ID } ] ,
317310 } ) ;
318311} ) ;
319312// External webhooks
0 commit comments