File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,9 +11,6 @@ let getRawToolRouterSessionTools: ReturnType<typeof mock>
1111
1212beforeAll ( async ( ) => {
1313 mock . module ( 'server-only' , ( ) => ( { } ) )
14- mock . module ( '@codebuff/internal/env' , ( ) => ( {
15- env : { COMPOSIO_API_KEY : 'test-composio-api-key' } ,
16- } ) )
1714 mock . module ( '@composio/core' , ( ) => ( {
1815 Composio : class {
1916 tools = {
@@ -93,6 +90,7 @@ describe('getComposioToolsForUser', () => {
9390 db,
9491 userId : 'user-123' ,
9592 logger,
93+ apiKey : 'test-composio-api-key' ,
9694 } )
9795
9896 expect ( result ) . toEqual ( {
@@ -128,6 +126,7 @@ describe('getComposioToolsForUser', () => {
128126 db,
129127 userId : 'user-123' ,
130128 logger,
129+ apiKey : 'test-composio-api-key' ,
131130 } ) ,
132131 ) . rejects . toThrow ( 'Composio unavailable' )
133132
Original file line number Diff line number Diff line change @@ -271,8 +271,9 @@ async function getSessionForUser(params: {
271271 db : CodebuffPgDatabase
272272 userId : string
273273 logger : Logger
274+ apiKey ?: string
274275} ) : Promise < CachedComposioSession | null > {
275- const apiKey = getComposioApiKey ( )
276+ const apiKey = params . apiKey ?? getComposioApiKey ( )
276277 if ( ! apiKey ) return null
277278
278279 try {
@@ -335,6 +336,7 @@ export async function getComposioToolsForUser(params: {
335336 db : CodebuffPgDatabase
336337 userId : string
337338 logger : Logger
339+ apiKey ?: string
338340} ) : Promise < { sessionId : string ; tools : ComposioToolDefinition [ ] } | null > {
339341 const cached = await getSessionForUser ( params )
340342 if ( ! cached ) return null
@@ -351,6 +353,7 @@ export async function executeComposioTool(params: {
351353 sessionId : string
352354 toolName : string
353355 input : Record < string , unknown >
356+ apiKey ?: string
354357} ) : Promise < ToolResultOutput [ ] | null > {
355358 if ( ! allowedToolNames . has ( params . toolName ) ) {
356359 return [
@@ -363,7 +366,7 @@ export async function executeComposioTool(params: {
363366 ]
364367 }
365368
366- const apiKey = getComposioApiKey ( )
369+ const apiKey = params . apiKey ?? getComposioApiKey ( )
367370 if ( ! apiKey ) return null
368371
369372 const storedSession = await getStoredSessionById ( {
You can’t perform that action at this time.
0 commit comments