@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 27 lines 1.07 KB
Raw
1 import { Auth, make, type ComposioClientShape } from '@composio/client/effect';
2 import { Effect } from 'effect';
3 import { HttpClient } from 'effect/http';
4 import { mockAccountResources, type AccountTestData, type MockRequestScope } from './accounts';
5
6 // A resource the account mocks do not shadow reaches this transport and dies with its URL.
7 const baseClient = make(
8 { auth: Auth.project('test'), baseURL: 'https://mock.invalid' },
9 HttpClient.make(request =>
10 Effect.die(new Error(`unexpected network call from a shadowed test client: ${request.url}`))
11 )
12 );
13
14 /**
15 * A Composio client whose account resources answer from `mockAccountResources` and whose
16 * unshadowed resources die loudly, so a handler test can never reach the network. Callers
17 * supply only the account data their handler reads; `test-layer.ts` shadows its mock client
18 * the same way.
19 */
20 export const makeShadowClient = (
21 accountData: AccountTestData,
22 scope: MockRequestScope
23 ): ComposioClientShape =>
24 ({
25 ...baseClient,
26 ...mockAccountResources(accountData, scope),
27 }) as unknown as ComposioClientShape;