@devries-cameron20 / composio-1 / commits / d741a1f27
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.

refactor(cli): answer every mock client call with an Effect (#4915)

This PR: - makes every mock `ComposioClientSingleton` call answer with an Effect instead of a promise: the account, session-info, and consumer endpoints in `test/__utils__/layers/accounts.ts`, `link.create` and `connectedAccounts.list` in `layers/connected-accounts.ts`, and in `test-layer.ts` the Tool Router session defaults (`create`, `execute`, `executeMeta`, `link`, `proxyExecute`, `search`, `toolkits`), `files.createPresignedURL`, and `triggerInstances.manage.update` - drops the promise branch from `withShadows`: a mock call is now `Effect.suspend(() => shadow(...args))`, so the body still runs only when the call runs - in `accounts.ts`, an endpoint without test data fails through `withTestData` (`Effect.fromOption(Option.fromUndefinedOr(value), () => noTestData(operation))`), which gives the same `APIConnectionError` as the old `throw`, and the two escape-hatch paths are named regexes ## Behaviour What a suite sees stays the same: the answers, the typed failures, the recorded `MockAccountRequest`s and their order, and when `onRequest`/`onDelete` run. A few things change: - A call no longer waits on a promise, so each mock call has one async step fewer. No CLI path runs these calls concurrently (`link`'s `Effect.all` is sequential). - A `sessionInfo` callback that throws still fails the call with what it threw, through `Effect.try`. The login suite's "selected-org enrichment fails" case depends on this, and the field's doc now says so. - An `onRequest` callback that throws now dies instead of failing the call; no suite throws from one. - An unhandled `get`/`post` path still fails with a plain `Error`, as before. The `test-layer.ts` diff is mostly re-indentation: with whitespace ignored, it is +32/−27. ## Verification On the branch tip: - `pnpm typecheck`: `@composio/cli:typecheck` a cache miss, passes - `pnpm --filter @composio/cli test`: 153 files, 1815 passed, 1 skipped; `validate:command-tests` at 18 exemptions, unchanged - `pnpm --filter @composio/cli run lint:effect`: 0 errors, 0 warnings - `oxlint` and `prettier --check` clean on every touched file

Alberto Schiabel committed Oct 16, 2026 at 02:47 UTC d741a1f27dfd874343a3cd1c6eeb2e4b127bd022
3 files changed +235 -210
ts/packages/cli/test/__utils__/layers/accounts.ts
+63 -43
@@ -1,5 +1,6 @@
1 import { APIConnectionError, type RequestOptions } from '@composio/client/effect';
2 import type { SessionRetrieveInfoResponse } from '@composio/client/resources/auth';
3 +import { Effect, Option } from 'effect';
4 import type { OrganizationSummary, OrgProject } from 'src/services/composio-account';
5 import { TIMESTAMP } from '../models/account';
6
@@ -41,6 +42,7 @@ export interface MockAccountRequest {
42 * answers, echoing the requested org.
43 */
44 export interface AccountTestData {
45 + /** A function answers per scope; whatever it throws becomes the call's failure. */
46 sessionInfo?:
47 SessionRetrieveInfoResponse | ((scope: MockRequestScope) => SessionRetrieveInfoResponse);
48 organizations?: ReadonlyArray<OrganizationSummary>;
@@ -60,6 +62,15 @@ const noTestData = (operation: MockAccountRequest['operation']) =>
62 description: `No test data for ${operation}`,
63 });
64
65 +/**
66 + * `value`, or the connection error an endpoint without test data rejects with.
67 + */
68 +const withTestData = <A>(value: A | undefined, operation: MockAccountRequest['operation']) =>
69 + Effect.fromOption(Option.fromUndefinedOr(value), () => noTestData(operation));
70 +
71 +const LATEST_TOOL_VERSION_PATH = /^\/api\/v3\/tools\/[^/]+\/get_latest_version$/;
72 +const CREATE_PROJECT_API_KEY_PATH = /^\/api\/v3\/org\/project\/[^/]+\/api_keys\/create$/;
73 +
74 const scopeOf = (base: MockRequestScope, options?: RequestOptions): MockRequestScope => {
75 // The CLI only ever passes plain header records.
76 const headers = (options?.headers ?? {}) as Record<string, string | null | undefined>;
@@ -96,43 +107,45 @@ export const mockAccountResources = (accountData: AccountTestData, base: MockReq
107
108 return {
109 org: {
99 - list: async (query?: { limit?: number } | null, options?: RequestOptions) => {
110 + list: (query?: { limit?: number } | null, options?: RequestOptions) => {
111 record('org.list', options, query);
101 - if (!accountData.organizations) throw noTestData('org.list');
102 - const organizations = accountData.organizations.map(org => ({ ...org, ...timestamps }));
103 - return {
104 - organizations,
105 - next_cursor: null,
106 - total_pages: 1,
107 - current_page: 1,
108 - total_items: organizations.length,
109 - };
112 + return withTestData(accountData.organizations, 'org.list').pipe(
113 + Effect.map(organizations => organizations.map(org => ({ ...org, ...timestamps }))),
114 + Effect.map(organizations => ({
115 + organizations,
116 + next_cursor: null,
117 + total_pages: 1,
118 + current_page: 1,
119 + total_items: organizations.length,
120 + }))
121 + );
122 },
123 project: {
112 - list: async (
124 + list: (
125 query?: { limit?: number; list_all_org_projects?: boolean | null } | null,
126 options?: RequestOptions
127 ) => {
128 record('org.project.list', options, query);
117 - if (!accountData.projects) throw noTestData('org.project.list');
118 - return {
119 - data: [...accountData.projects],
120 - next_cursor: null,
121 - total_pages: 1,
122 - current_page: 1,
123 - total_items: accountData.projects.length,
124 - };
129 + return withTestData(accountData.projects, 'org.project.list').pipe(
130 + Effect.map(projects => ({
131 + data: [...projects],
132 + next_cursor: null,
133 + total_pages: 1,
134 + current_page: 1,
135 + total_items: projects.length,
136 + }))
137 + );
138 },
139 },
140 consumer: {
141 project: {
129 - resolve: async (
142 + resolve: (
143 params: { 'x-user-api-key': string; 'x-org-id': string },
144 options?: RequestOptions
145 ) => {
146 record('org.consumer.project.resolve', options, params);
147 const orgId = params['x-org-id'];
135 - return {
148 + return Effect.succeed({
149 project_id: 'consumer_project_id_test',
150 project_nano_id: 'consumer_project_test',
151 project_name: 'Consumer Project',
@@ -140,46 +153,53 @@ export const mockAccountResources = (accountData: AccountTestData, base: MockReq
153 project_type: 'CONSUMER' as const,
154 config: { consumer_experience_enabled: true, enhanced_controls: false },
155 consumer_user_id: `consumer-user-${orgId}`,
143 - };
156 + });
157 },
158 },
146 - listConnectedToolkits: async (
159 + listConnectedToolkits: (
160 params: { user_id: string; 'x-user-api-key': string; 'x-org-id': string },
161 options?: RequestOptions
162 ) => {
163 record('org.consumer.listConnectedToolkits', options, params);
151 - if (!accountData.connectedToolkits) {
152 - throw noTestData('org.consumer.listConnectedToolkits');
153 - }
154 - return { toolkits: [...accountData.connectedToolkits] };
164 + return withTestData(
165 + accountData.connectedToolkits,
166 + 'org.consumer.listConnectedToolkits'
167 + ).pipe(Effect.map(toolkits => ({ toolkits: [...toolkits] })));
168 },
169 },
170 },
171 auth: {
172 session: {
160 - retrieveInfo: async (options?: RequestOptions) => {
173 + retrieveInfo: (options?: RequestOptions) => {
174 const scope = record('auth.session.retrieveInfo', options);
162 - const sessionInfo = accountData.sessionInfo;
163 - if (sessionInfo === undefined) throw noTestData('auth.session.retrieveInfo');
164 - return typeof sessionInfo === 'function' ? sessionInfo(scope) : sessionInfo;
175 + return withTestData(accountData.sessionInfo, 'auth.session.retrieveInfo').pipe(
176 + // A test fails the call by throwing from its callback.
177 + Effect.flatMap(sessionInfo =>
178 + Effect.try({
179 + try: () => (typeof sessionInfo === 'function' ? sessionInfo(scope) : sessionInfo),
180 + catch: cause => cause,
181 + })
182 + )
183 + );
184 },
185 },
186 },
168 - get: async (path: string, options?: RequestOptions) => {
169 - if (/^\/api\/v3\/tools\/[^/]+\/get_latest_version$/.test(path)) {
170 - record('tools.getLatestVersion', options, { path });
171 - if (!accountData.latestToolVersion) throw noTestData('tools.getLatestVersion');
172 - return accountData.latestToolVersion;
187 + get: (path: string, options?: RequestOptions) => {
188 + if (!LATEST_TOOL_VERSION_PATH.test(path)) {
189 + return Effect.fail(new Error(`Unhandled GET path "${path}"`));
190 }
174 - throw new Error(`Unhandled GET path "${path}"`);
191 + record('tools.getLatestVersion', options, { path });
192 + return withTestData(accountData.latestToolVersion, 'tools.getLatestVersion');
193 },
176 - post: async (path: string, options?: RequestOptions & { body?: unknown }) => {
177 - if (/^\/api\/v3\/org\/project\/[^/]+\/api_keys\/create$/.test(path)) {
178 - record('org.project.createApiKey', options, { path, body: options?.body });
179 - if (!accountData.projectApiKey) throw noTestData('org.project.createApiKey');
180 - return { api_key: accountData.projectApiKey };
194 + post: (path: string, options?: RequestOptions & { body?: unknown }) => {
195 + if (!CREATE_PROJECT_API_KEY_PATH.test(path)) {
196 + return Effect.fail(new Error(`Unhandled POST path "${path}"`));
197 }
182 - throw new Error(`Unhandled POST path "${path}"`);
198 + record('org.project.createApiKey', options, { path, body: options?.body });
199 + // An empty key counts as missing, as it always has.
200 + return withTestData(accountData.projectApiKey || undefined, 'org.project.createApiKey').pipe(
201 + Effect.map(apiKey => ({ api_key: apiKey }))
202 + );
203 },
204 };
205 };
ts/packages/cli/test/__utils__/layers/connected-accounts.ts
+12 -12
@@ -161,18 +161,18 @@ export const mockConnectedAccountResources = (
161 connectedAccountsData: ResolvedConnectedAccountsTestData
162 ) => ({
163 link: {
164 - create: async (params: { auth_config_id: string; user_id: string }) => {
165 - const response = connectedAccountsData.linkResponse ?? {
166 - connected_account_id: 'con_test_link',
167 - expires_at: '2026-12-31T23:59:59Z',
168 - link_token: 'lt_test_token',
169 - redirect_url: `https://app.composio.dev/link?token=lt_test_token`,
170 - };
171 - return response;
172 - },
164 + create: (_params: { auth_config_id: string; user_id: string }) =>
165 + Effect.succeed(
166 + connectedAccountsData.linkResponse ?? {
167 + connected_account_id: 'con_test_link',
168 + expires_at: '2026-12-31T23:59:59Z',
169 + link_token: 'lt_test_token',
170 + redirect_url: `https://app.composio.dev/link?token=lt_test_token`,
171 + }
172 + ),
173 },
174 connectedAccounts: {
175 - list: async (params?: {
175 + list: (params?: {
176 toolkit_slugs?: string[];
177 user_ids?: string[];
178 statuses?: string[];
@@ -196,13 +196,13 @@ export const mockConnectedAccountResources = (
196 }
197
198 const limit = params?.limit ?? DEFAULT_PAGE_LIMIT;
199 - return {
199 + return Effect.succeed({
200 items: results.slice(0, limit),
201 total_items: results.length,
202 total_pages: Math.ceil(results.length / limit),
203 current_page: 1,
204 next_cursor: null,
205 - };
205 + });
206 },
207 retrieve: (nanoid: string) =>
208 findById(connectedAccountsData.items, nanoid, () =>
ts/packages/cli/test/__utils__/services/test-layer.ts
+160 -155
@@ -481,119 +481,125 @@ export const TestLayer = (input?: TestLiveInput) =>
481
482 const toolRouterOverrides = input?.toolRouter;
483
484 - const defaultToolkitsHandler = async (
484 + const defaultToolkitsHandler = (
485 _sessionId: string,
486 params?: SessionToolkitsParams | null
487 - ): Promise<SessionToolkitsResponse> => {
488 - let results: SessionToolkitsResponse['items'] = toolkitsData.toolkits.map(t => ({
489 - slug: t.slug,
490 - name: t.name,
491 - meta: { description: t.meta.description, logo: '' },
492 - is_no_auth: t.no_auth ?? false,
493 - enabled: true,
494 - connected_account: null,
495 - composio_managed_auth_schemes: [...(t.composio_managed_auth_schemes ?? [])],
496 - }));
497 -
498 - if (params?.search) {
499 - const q = params.search.toLowerCase();
500 - results = results.filter(
501 - t =>
502 - t.name.toLowerCase().includes(q) ||
503 - t.slug.toLowerCase().includes(q) ||
504 - t.meta.description.toLowerCase().includes(q)
505 - );
506 - }
487 + ): Effect.Effect<SessionToolkitsResponse> =>
488 + Effect.sync(() => {
489 + let results: SessionToolkitsResponse['items'] = toolkitsData.toolkits.map(t => ({
490 + slug: t.slug,
491 + name: t.name,
492 + meta: { description: t.meta.description, logo: '' },
493 + is_no_auth: t.no_auth ?? false,
494 + enabled: true,
495 + connected_account: null,
496 + composio_managed_auth_schemes: [...(t.composio_managed_auth_schemes ?? [])],
497 + }));
498 +
499 + if (params?.search) {
500 + const q = params.search.toLowerCase();
501 + results = results.filter(
502 + t =>
503 + t.name.toLowerCase().includes(q) ||
504 + t.slug.toLowerCase().includes(q) ||
505 + t.meta.description.toLowerCase().includes(q)
506 + );
507 + }
508
508 - if (params?.toolkits) {
509 - const slugSet = new Set(params.toolkits.map(s => s.toLowerCase()));
510 - results = results.filter(t => slugSet.has(t.slug.toLowerCase()));
511 - }
509 + if (params?.toolkits) {
510 + const slugSet = new Set(params.toolkits.map(s => s.toLowerCase()));
511 + results = results.filter(t => slugSet.has(t.slug.toLowerCase()));
512 + }
513
513 - const limit = params?.limit ?? 1000;
514 - const items = results.slice(0, limit);
515 - return {
516 - items,
517 - current_page: 1,
518 - total_items: results.length,
519 - total_pages: Math.ceil(results.length / limit),
520 - next_cursor: null,
521 - };
522 - };
514 + const limit = params?.limit ?? 1000;
515 + const items = results.slice(0, limit);
516 + return {
517 + items,
518 + current_page: 1,
519 + total_items: results.length,
520 + total_pages: Math.ceil(results.length / limit),
521 + next_cursor: null,
522 + };
523 + });
524
524 - const defaultSearchHandler = async (
525 + const defaultSearchHandler = (
526 _sessionId: string,
527 params: SessionSearchParams
527 - ): Promise<SessionSearchResponse> => {
528 - const results = params.queries.map((query, index) => {
529 - const queryUseCase = query.use_case ?? '';
530 - const normalizedQuery = queryUseCase.toLowerCase();
531 - const matchedTools = toolkitsData.tools.filter(
532 - tool =>
533 - tool.name.toLowerCase().includes(normalizedQuery) ||
534 - tool.slug.toLowerCase().includes(normalizedQuery) ||
535 - tool.description.toLowerCase().includes(normalizedQuery)
528 + ): Effect.Effect<SessionSearchResponse> =>
529 + Effect.sync(() => {
530 + const results = params.queries.map((query, index) => {
531 + const queryUseCase = query.use_case ?? '';
532 + const normalizedQuery = queryUseCase.toLowerCase();
533 + const matchedTools = toolkitsData.tools.filter(
534 + tool =>
535 + tool.name.toLowerCase().includes(normalizedQuery) ||
536 + tool.slug.toLowerCase().includes(normalizedQuery) ||
537 + tool.description.toLowerCase().includes(normalizedQuery)
538 + );
539 +
540 + return {
541 + index: index + 1,
542 + use_case: queryUseCase,
543 + primary_tool_slugs: matchedTools.map(tool => tool.slug),
544 + related_tool_slugs: [],
545 + toolkits: Array.from(
546 + new Set(
547 + matchedTools
548 + .map(tool => tool.slug.split('_')[0]?.toLowerCase() ?? '')
549 + .filter(Boolean)
550 + )
551 + ),
552 + matchedTools,
553 + };
554 + });
555 +
556 + const allMatchedTools = results.flatMap(result => result.matchedTools);
557 + const toolSchemas = Object.fromEntries(
558 + allMatchedTools.map(tool => [
559 + tool.slug,
560 + {
561 + tool_slug: tool.slug,
562 + toolkit: tool.slug.split('_')[0]?.toLowerCase() ?? '',
563 + description: tool.description,
564 + hasFullSchema: true,
565 + input_schema: tool.input_parameters,
566 + output_schema: tool.output_parameters,
567 + },
568 + ])
569 );
570 + const toolkitConnectionStatuses = Array.from(
571 + new Set(
572 + allMatchedTools
573 + .map(tool => tool.slug.split('_')[0]?.toLowerCase() ?? '')
574 + .filter(Boolean)
575 + )
576 + ).map(toolkitSlug => ({
577 + toolkit: toolkitSlug,
578 + description: `${toolkitSlug} toolkit`,
579 + has_active_connection: false,
580 + status_message: 'No active connection',
581 + }));
582
583 return {
539 - index: index + 1,
540 - use_case: queryUseCase,
541 - primary_tool_slugs: matchedTools.map(tool => tool.slug),
542 - related_tool_slugs: [],
543 - toolkits: Array.from(
544 - new Set(
545 - matchedTools.map(tool => tool.slug.split('_')[0]?.toLowerCase() ?? '').filter(Boolean)
546 - )
547 - ),
548 - matchedTools,
584 + success: true,
585 + error: null,
586 + results: results.map(({ matchedTools: _matchedTools, ...result }) => result),
587 + tool_schemas: toolSchemas,
588 + toolkit_connection_statuses: toolkitConnectionStatuses,
589 + next_steps_guidance: [],
590 + session: {
591 + id: 'trs_test_session',
592 + generate_id: false,
593 + instructions: 'Reuse this session id for follow-up calls.',
594 + },
595 + time_info: {
596 + current_time_utc: TIMESTAMP,
597 + current_time_utc_epoch_seconds: 1767225600,
598 + message: 'UTC time',
599 + },
600 };
601 });
602
552 - const allMatchedTools = results.flatMap(result => result.matchedTools);
553 - const toolSchemas = Object.fromEntries(
554 - allMatchedTools.map(tool => [
555 - tool.slug,
556 - {
557 - tool_slug: tool.slug,
558 - toolkit: tool.slug.split('_')[0]?.toLowerCase() ?? '',
559 - description: tool.description,
560 - hasFullSchema: true,
561 - input_schema: tool.input_parameters,
562 - output_schema: tool.output_parameters,
563 - },
564 - ])
565 - );
566 - const toolkitConnectionStatuses = Array.from(
567 - new Set(
568 - allMatchedTools.map(tool => tool.slug.split('_')[0]?.toLowerCase() ?? '').filter(Boolean)
569 - )
570 - ).map(toolkitSlug => ({
571 - toolkit: toolkitSlug,
572 - description: `${toolkitSlug} toolkit`,
573 - has_active_connection: false,
574 - status_message: 'No active connection',
575 - }));
576 -
577 - return {
578 - success: true,
579 - error: null,
580 - results: results.map(({ matchedTools: _matchedTools, ...result }) => result),
581 - tool_schemas: toolSchemas,
582 - toolkit_connection_statuses: toolkitConnectionStatuses,
583 - next_steps_guidance: [],
584 - session: {
585 - id: 'trs_test_session',
586 - generate_id: false,
587 - instructions: 'Reuse this session id for follow-up calls.',
588 - },
589 - time_info: {
590 - current_time_utc: TIMESTAMP,
591 - current_time_utc_epoch_seconds: 1767225600,
592 - message: 'UTC time',
593 - },
594 - };
595 - };
596 -
603 // What the mock client answers with instead of calling the network.
604 const resourceShadows = {
605 ...mockConnectedAccountResources(connectedAccountsData),
@@ -628,10 +634,11 @@ export const TestLayer = (input?: TestLiveInput) =>
634 });
635 },
636 manage: {
631 - update: async (triggerId: string, params: { status: 'enable' | 'disable' }) => ({
632 - trigger_id: triggerId,
633 - status: params.status,
634 - }),
637 + update: (triggerId: string, params: { status: 'enable' | 'disable' }) =>
638 + Effect.succeed({
639 + trigger_id: triggerId,
640 + status: params.status,
641 + }),
642 },
643 },
644 toolkits: {
@@ -667,64 +674,70 @@ export const TestLayer = (input?: TestLiveInput) =>
674 },
675 },
676 files: {
670 - createPresignedURL: async (params: {
677 + createPresignedURL: (params: {
678 filename: string;
679 mimetype: string;
680 md5: string;
681 tool_slug: string;
682 toolkit_slug: string;
676 - }) => ({
677 - key: `uploads/${params.filename}`,
678 - new_presigned_url: 'https://s3.test.composio.dev/upload',
679 - }),
683 + }) =>
684 + Effect.succeed({
685 + key: `uploads/${params.filename}`,
686 + new_presigned_url: 'https://s3.test.composio.dev/upload',
687 + }),
688 },
689 toolRouter: {
690 session: {
691 create:
692 toolRouterOverrides?.create ??
685 - (async (params: SessionCreateParams) => ({
686 - session_id: 'trs_test_session',
687 - config: { user_id: params.user_id },
688 - mcp: { type: 'http' as const, url: 'https://mcp.test.composio.dev' },
689 - tool_router_tools: ['COMPOSIO_SEARCH_TOOLS', 'COMPOSIO_MANAGE_CONNECTIONS'],
690 - })),
693 + ((params: SessionCreateParams) =>
694 + Effect.succeed({
695 + session_id: 'trs_test_session',
696 + config: { user_id: params.user_id },
697 + mcp: { type: 'http' as const, url: 'https://mcp.test.composio.dev' },
698 + tool_router_tools: ['COMPOSIO_SEARCH_TOOLS', 'COMPOSIO_MANAGE_CONNECTIONS'],
699 + })),
700 execute:
701 toolRouterOverrides?.execute ??
693 - (async (_sessionId: string, params: SessionExecuteParams) => ({
694 - result_type: 'completed' as const,
695 - data: { tool_slug: params.tool_slug, arguments: params.arguments },
696 - error: null,
697 - log_id: 'log_test',
698 - })),
702 + ((_sessionId: string, params: SessionExecuteParams) =>
703 + Effect.succeed({
704 + result_type: 'completed' as const,
705 + data: { tool_slug: params.tool_slug, arguments: params.arguments },
706 + error: null,
707 + log_id: 'log_test',
708 + })),
709 executeMeta:
710 toolRouterOverrides?.executeMeta ??
701 - (async (_sessionId: string, params: SessionExecuteMetaParams) => ({
702 - result_type: 'completed' as const,
703 - data: { slug: params.slug, arguments: params.arguments },
704 - error: null,
705 - log_id: 'log_test',
706 - })),
711 + ((_sessionId: string, params: SessionExecuteMetaParams) =>
712 + Effect.succeed({
713 + result_type: 'completed' as const,
714 + data: { slug: params.slug, arguments: params.arguments },
715 + error: null,
716 + log_id: 'log_test',
717 + })),
718 link:
719 toolRouterOverrides?.link ??
709 - (async () => ({
710 - connected_account_id: 'con_test_link',
711 - link_token: 'lt_test_token',
712 - redirect_url: 'https://app.composio.dev/link?token=lt_test_token',
713 - account_type: 'PRIVATE' as const,
714 - })),
720 + (() =>
721 + Effect.succeed({
722 + connected_account_id: 'con_test_link',
723 + link_token: 'lt_test_token',
724 + redirect_url: 'https://app.composio.dev/link?token=lt_test_token',
725 + account_type: 'PRIVATE' as const,
726 + })),
727 proxyExecute:
728 toolRouterOverrides?.proxyExecute ??
717 - (async (_sessionId: string, params: SessionProxyExecuteParams) => ({
718 - status: 200,
719 - data: {
720 - toolkit_slug: params.toolkit_slug,
721 - endpoint: params.endpoint,
722 - method: params.method,
723 - body: params.body ?? null,
724 - parameters: params.parameters ?? [],
725 - },
726 - headers: {},
727 - })),
729 + ((_sessionId: string, params: SessionProxyExecuteParams) =>
730 + Effect.succeed({
731 + status: 200,
732 + data: {
733 + toolkit_slug: params.toolkit_slug,
734 + endpoint: params.endpoint,
735 + method: params.method,
736 + body: params.body ?? null,
737 + parameters: params.parameters ?? [],
738 + },
739 + headers: {},
740 + })),
741 search: toolRouterOverrides?.search ?? defaultSearchHandler,
742 toolkits: toolRouterOverrides?.toolkits ?? defaultToolkitsHandler,
743 },
@@ -737,8 +750,8 @@ export const TestLayer = (input?: TestLiveInput) =>
750 Effect.die(new Error(`unexpected network call from the mock Composio client: ${request.url}`))
751 );
752
740 - // Each shadow answers with an Effect or a promise; a rejection becomes
741 - // the call's failure as it is. A shadow ignores the request options
753 + // Each shadow answers with an Effect, built when the call runs. A shadow
754 + // ignores the request options
755 // (`signal`, `maxRetries`, headers beyond `decode`), and the
756 // `connectedAccounts.list` shadow never pages (`next_cursor` is null):
757 // pagination, retries, and abort are covered by `stubComposioClient`,
@@ -749,15 +762,7 @@ export const TestLayer = (input?: TestLiveInput) =>
762 shadowed[key] =
763 typeof shadow === 'function'
764 ? (...args: ReadonlyArray<unknown>) =>
752 - Effect.suspend(() => {
753 - const answer: unknown = shadow(...args);
754 - return Effect.isEffect(answer)
755 - ? answer
756 - : Effect.tryPromise({
757 - try: () => answer as Promise<unknown>,
758 - catch: cause => cause,
759 - });
760 - })
765 + Effect.suspend(() => shadow(...args) as Effect.Effect<unknown, unknown>)
766 : withShadows((shadowed[key] ?? {}) as object, shadow as object);
767 }
768 return shadowed as Resources;