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

chore: fix link behavior, disable caching, improve search steps (#3038)

## Summary Explain the motivation and context for this change. Link to any related issues. Fixes # ## Changes - - ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? Describe the tests you ran and instructions so reviewers can reproduce. Include any relevant config/versions. ## Screenshots (if applicable) ## Checklist - [ ] I have read the Code of Conduct and this PR adheres to it - [ ] I ran linters/tests locally and they passed - [ ] I updated documentation as needed - [ ] I added tests or explain why not applicable - [ ] I added a changeset if this change affects published packages ## Additional context --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Rahul Tarak committed Mar 27, 2026 at 01:50 UTC 4d7bc9873a0a95aef165654c84e1e75faec1bec9
12 files changed +353 -186
ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
+39 -60
@@ -36,11 +36,6 @@ const projectName = Options.text('project-name').pipe(
36 Options.withDescription('Developer project name override for this command')
37 );
38
39 -const noBrowser = Options.boolean('no-browser').pipe(
40 - Options.withDefault(false),
41 - Options.withDescription('Skip auto-opening the browser')
42 -);
43 -
39 const noWait = Options.boolean('no-wait').pipe(
40 Options.withDefault(false),
41 Options.withDescription('Do not wait for authorization; only print link info')
@@ -49,19 +44,13 @@ const noWait = Options.boolean('no-wait').pipe(
44 const showRedirectUrl = (
45 ui: TerminalUI,
46 redirectUrl: string,
52 - noBrowser: boolean,
47 options?: { readonly emitRaw?: boolean }
48 ) =>
49 Effect.gen(function* () {
56 - if (noBrowser) {
57 - yield* ui.log.info('Please authorize using the following URL:');
58 - } else {
59 - yield* ui.log.step('Redirecting you to the authorization page');
60 - }
61 -
50 + yield* ui.log.step('Redirecting you to the authorization page');
51 yield* ui.note(redirectUrl, 'Redirect URL');
52 if (options?.emitRaw) {
64 - yield* ui.output(redirectUrl, noBrowser ? { force: true } : undefined);
53 + yield* ui.output(redirectUrl);
54 }
55 });
56
@@ -69,35 +58,32 @@ const waitForActiveConnection = (
58 ui: TerminalUI,
59 client: RawComposioClient,
60 connectedAccountId: string,
72 - redirectUrl: string,
73 - noBrowser: boolean
61 + redirectUrl: string
62 ) =>
63 Effect.gen(function* () {
76 - yield* showRedirectUrl(ui, redirectUrl, noBrowser, { emitRaw: noBrowser });
77 -
78 - if (!noBrowser) {
79 - let urlSchemeValid = false;
80 - try {
81 - const parsed = new URL(redirectUrl);
82 - urlSchemeValid = parsed.protocol === 'https:' || parsed.protocol === 'http:';
83 - } catch {
84 - // ignore
85 - }
64 + yield* showRedirectUrl(ui, redirectUrl);
65 +
66 + let urlSchemeValid = false;
67 + try {
68 + const parsed = new URL(redirectUrl);
69 + urlSchemeValid = parsed.protocol === 'https:' || parsed.protocol === 'http:';
70 + } catch {
71 + // ignore
72 + }
73
87 - if (!urlSchemeValid) {
88 - yield* ui.log.warn(`Redirect URL has an unexpected scheme: ${redirectUrl}`);
89 - yield* ui.log.info('Open the URL manually if you trust the source.');
90 - } else {
91 - yield* Effect.tryPromise(() => open(redirectUrl, { wait: false })).pipe(
92 - Effect.catchAll(error =>
93 - Effect.gen(function* () {
94 - yield* Effect.logDebug('Failed to open browser:', error);
95 - yield* ui.log.warn('Could not open the browser automatically.');
96 - yield* ui.log.info('Tip: try using `--no-browser` and open the URL manually.');
97 - })
98 - )
99 - );
100 - }
74 + if (!urlSchemeValid) {
75 + yield* ui.log.warn(`Redirect URL has an unexpected scheme: ${redirectUrl}`);
76 + yield* ui.log.info('Open the URL manually if you trust the source.');
77 + } else {
78 + yield* Effect.tryPromise(() => open(redirectUrl, { wait: false })).pipe(
79 + Effect.catchAll(error =>
80 + Effect.gen(function* () {
81 + yield* Effect.logDebug('Failed to open browser:', error);
82 + yield* ui.log.warn('Could not open the browser automatically.');
83 + yield* ui.log.info('Open the URL above manually.');
84 + })
85 + )
86 + );
87 }
88
89 yield* ui.useMakeSpinner('Waiting for authentication...', spinner =>
@@ -168,7 +154,7 @@ const validateLinkResponse = (
154 });
155 });
156
171 -const handleNoManagedAuth = (ui: TerminalUI, toolkitSlug: string, noBrowser: boolean) =>
157 +const handleNoManagedAuth = (ui: TerminalUI, toolkitSlug: string) =>
158 Effect.gen(function* () {
159 const userContext = yield* ComposioUserContext;
160 const webURL = userContext.data.webURL.replace(/\/+$/, '');
@@ -192,14 +178,12 @@ const handleNoManagedAuth = (ui: TerminalUI, toolkitSlug: string, noBrowser: boo
178 `Composio does not manage auth for "${toolkitSlug}" — opening the dashboard to connect manually.`
179 );
180
195 - if (!noBrowser) {
196 - yield* Effect.tryPromise(() => open(dashboardUrl, { wait: false })).pipe(
197 - Effect.catchAll(() => ui.log.warn('Could not open the browser automatically.'))
198 - );
199 - }
181 + yield* Effect.tryPromise(() => open(dashboardUrl, { wait: false })).pipe(
182 + Effect.catchAll(() => ui.log.warn('Could not open the browser automatically.'))
183 + );
184
185 yield* ui.note(dashboardUrl, 'Dashboard URL');
202 - yield* ui.output(dashboardUrl, noBrowser ? { force: true } : undefined);
186 + yield* ui.output(dashboardUrl);
187 });
188
189 const runConnectedAccountsLink = (params: {
@@ -207,7 +191,6 @@ const runConnectedAccountsLink = (params: {
191 authConfig: Option.Option<string>;
192 userId: Option.Option<string>;
193 projectName: Option.Option<string>;
210 - noBrowser: boolean;
194 noWait: boolean;
195 rootOnly: boolean;
196 }) =>
@@ -318,7 +301,7 @@ const runConnectedAccountsLink = (params: {
301
302 const { connectedAccountId: connId, redirectUrl } = validatedLink.value;
303 if (params.noWait) {
321 - yield* showRedirectUrl(ui, redirectUrl, params.noBrowser);
304 + yield* showRedirectUrl(ui, redirectUrl);
305 yield* ui.output(
306 JSON.stringify(
307 {
@@ -334,7 +317,7 @@ const runConnectedAccountsLink = (params: {
317 { force: true }
318 );
319 } else {
337 - yield* waitForActiveConnection(ui, client, connId, redirectUrl, params.noBrowser);
320 + yield* waitForActiveConnection(ui, client, connId, redirectUrl);
321 }
322 return;
323 }
@@ -382,7 +365,7 @@ const runConnectedAccountsLink = (params: {
365 const slug = extractSlug(error);
366
367 if (slug === 'ToolRouterV2_NoManagedAuth') {
385 - yield* handleNoManagedAuth(ui, toolkitSlug, params.noBrowser);
368 + yield* handleNoManagedAuth(ui, toolkitSlug);
369 return Option.none();
370 }
371
@@ -407,7 +390,7 @@ const runConnectedAccountsLink = (params: {
390 const { connectedAccountId: connAccountId, redirectUrl } = validatedLink.value;
391
392 if (params.noWait) {
410 - yield* showRedirectUrl(ui, redirectUrl, params.noBrowser);
393 + yield* showRedirectUrl(ui, redirectUrl);
394 yield* ui.output(
395 JSON.stringify(
396 {
@@ -436,7 +419,7 @@ const runConnectedAccountsLink = (params: {
419 },
420 }).pipe(Effect.catchAll(() => Effect.void));
421 } else {
439 - yield* waitForActiveConnection(ui, client, connAccountId, redirectUrl, params.noBrowser);
422 + yield* waitForActiveConnection(ui, client, connAccountId, redirectUrl);
423 yield* appendCliSessionHistory({
424 orgId: resolvedProject.projectType === 'CONSUMER' ? resolvedProject.orgId : undefined,
425 consumerUserId:
@@ -454,14 +437,13 @@ const runConnectedAccountsLink = (params: {
437
438 export const connectedAccountsCmd$Link = Command.make(
439 'link',
457 - { toolkit, authConfig, userId, projectName, noBrowser, noWait },
458 - ({ toolkit, authConfig, userId, projectName, noBrowser, noWait }) =>
440 + { toolkit, authConfig, userId, projectName, noWait },
441 + ({ toolkit, authConfig, userId, projectName, noWait }) =>
442 runConnectedAccountsLink({
443 toolkit,
444 authConfig,
445 userId,
446 projectName,
464 - noBrowser,
447 noWait,
448 rootOnly: false,
449 })
@@ -473,7 +455,6 @@ export const connectedAccountsCmd$Link = Command.make(
455 '',
456 'Examples:',
457 ' composio link github',
476 - ' composio link gmail --no-browser Print the auth URL instead of opening it',
458 '',
459 'See also:',
460 ' composio search "<query>" Find tools to use after linking',
@@ -484,14 +465,13 @@ export const connectedAccountsCmd$Link = Command.make(
465
466 export const rootConnectedAccountsCmd$Link = Command.make(
467 'link',
487 - { toolkit, noBrowser, noWait },
488 - ({ toolkit, noBrowser, noWait }) =>
468 + { toolkit, noWait },
469 + ({ toolkit, noWait }) =>
470 runConnectedAccountsLink({
471 toolkit,
472 authConfig: Option.none(),
473 userId: Option.none(),
474 projectName: Option.none(),
494 - noBrowser,
475 noWait,
476 rootOnly: true,
477 })
@@ -503,7 +483,6 @@ export const rootConnectedAccountsCmd$Link = Command.make(
483 '',
484 'Examples:',
485 ' composio link github',
506 - ' composio link gmail --no-browser Print the auth URL instead of opening it',
486 '',
487 'See also:',
488 ' composio search "<query>" Find tools to use after linking',
ts/packages/cli/src/commands/index.ts
+2
@@ -24,6 +24,7 @@ import { rootToolsCmd$Search } from './tools/commands/tools.search.cmd';
24 import { rootToolsCmd$Execute } from './tools/commands/tools.execute.cmd';
25 import { rootToolsCmd } from './tools/tools.cmd';
26 import { rootConnectedAccountsCmd$Link } from './connected-accounts/commands/connected-accounts.link.cmd';
27 +import { orgsCmd } from './orgs/orgs.cmd';
28 import { renderCommandHintGraph } from 'src/services/command-hints';
29 import { resetRuntimeDebugFlags, setRuntimeDebugFlags } from 'src/services/runtime-debug-flags';
30 import { ComposioUserContext } from 'src/services/user-context';
@@ -51,6 +52,7 @@ const $cmd = $defaultCmd.pipe(
52 rootConnectedAccountsCmd$Link,
53 rootToolsCmd$Execute,
54 generateCmd,
55 + orgsCmd,
56 ])
57 );
58 export const rootCommand = $cmd;
ts/packages/cli/src/commands/orgs/commands/orgs.switch.cmd.ts
+1 -1
@@ -21,7 +21,7 @@ export const orgsCmd$Switch = Command.make('switch', { orgId, limit }, ({ orgId,
21
22 const ui = yield* TerminalUI;
23 const ctx = yield* ComposioUserContext;
24 - yield* ui.intro('composio dev orgs switch');
24 + yield* ui.intro('composio orgs switch');
25
26 const apiKey = Option.getOrUndefined(ctx.data.apiKey);
27 if (!apiKey) {
ts/packages/cli/src/commands/root-help.ts
+5 -5
@@ -54,7 +54,7 @@ const CORE_COMMANDS: ReadonlyArray<DetailedCommand> = [
54 {
55 name: 'link',
56 description: 'Connect your account for a toolkit/app.',
57 - usage: 'link [<toolkit>] [--no-browser]',
57 + usage: 'link [<toolkit>]',
58 options: [{ name: '<toolkit>', description: 'Toolkit slug to link (e.g. "github", "gmail")' }],
59 },
60 {
@@ -98,7 +98,7 @@ const DEVELOPER_COMMANDS: ReadonlyArray<CompactCommand> = [
98 {
99 name: 'dev',
100 description:
101 - 'Developer workflows and management: init, execute, logs, orgs, projects, toolkits, accounts, and triggers.',
101 + 'Developer workflows and management: init, logs, projects, toolkits, accounts, and triggers.',
102 },
103 {
104 name: 'generate',
@@ -112,6 +112,7 @@ const ACCOUNT_COMMANDS: ReadonlyArray<CompactCommand> = [
112 { name: 'login', description: 'Log in to Composio' },
113 { name: 'logout', description: 'Log out from Composio' },
114 { name: 'whoami', description: 'Show current account info' },
115 + { name: 'orgs', description: 'Manage default organization context (list, switch)' },
116 { name: 'version', description: 'Display CLI version' },
117 { name: 'upgrade', description: 'Upgrade CLI to the latest version' },
118 ];
@@ -255,18 +256,17 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {
256 ],
257 },
258 link: {
258 - usage: 'composio link [<toolkit>] [--no-browser] [--no-wait]',
259 + usage: 'composio link [<toolkit>] [--no-wait]',
260 description:
261 'Connect an external account (GitHub, Gmail, Slack, etc.) so tools can act on your behalf. Opens a browser for OAuth authorization and waits for confirmation.',
262 args: [{ name: '<toolkit>', description: 'Toolkit slug to link (e.g. "github", "gmail")' }],
263 flags: [
263 - { name: '--no-browser', description: 'Print the auth URL instead of opening a browser' },
264 {
265 name: '--no-wait',
266 description: 'Print link info and exit without waiting for authorization',
267 },
268 ],
269 - examples: ['composio link github', 'composio link gmail --no-browser'],
269 + examples: ['composio link github'],
270 seeAlso: [
271 'composio search "<query>" Find tools to use after linking',
272 "composio execute <slug> -d '{ ... }' Execute a tool with your connected account",
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+32 -28
@@ -146,15 +146,26 @@ const collectToolsForResult = (params: {
146 return toolsList;
147 };
148
149 -const buildSearchCta = (params: {
149 +const buildSearchNextSteps = (params: {
150 firstSlug?: string;
151 firstToolkit?: string;
152 firstDataArg: string;
153 rootOnly: boolean;
154 }) => {
155 - const cta: Array<{ action: string; command: string }> = [];
155 + const steps: Array<{ action: string; command: string }> = [];
156 + if (params.firstToolkit) {
157 + steps.push({
158 + action: 'Link a user account',
159 + command: params.rootOnly
160 + ? commandHintExample('root.link', { toolkit: String(params.firstToolkit).toLowerCase() })
161 + : commandHintExample('dev.connectedAccounts.link', {
162 + toolkit: String(params.firstToolkit).toLowerCase(),
163 + userId: '<user-id>',
164 + }),
165 + });
166 + }
167 if (params.firstSlug) {
157 - cta.push({
168 + steps.push({
169 action: 'Execute a tool',
170 command: params.rootOnly
171 ? commandHintExample('root.execute', { slug: params.firstSlug, data: params.firstDataArg })
@@ -165,25 +176,14 @@ const buildSearchCta = (params: {
176 }),
177 });
178 }
168 - if (params.firstToolkit) {
169 - cta.push({
170 - action: 'Connect a user account',
171 - command: params.rootOnly
172 - ? commandHintExample('root.link', { toolkit: String(params.firstToolkit).toLowerCase() })
173 - : commandHintExample('dev.connectedAccounts.link', {
174 - toolkit: String(params.firstToolkit).toLowerCase(),
175 - userId: '<user-id>',
176 - }),
177 - });
178 - }
179 - return cta;
179 + return steps;
180 };
181
182 const buildSearchJsonPayload = (params: {
183 searchResponse: SearchResponseRecord;
184 cacheScope: { orgId?: string; consumerUserId?: string };
185 projectScope: { orgId: string; projectId: string };
186 - cta: Array<{ action: string; command: string }>;
186 + nextSteps: Array<{ action: string; command: string }>;
187 }) =>
188 Effect.gen(function* () {
189 const cacheDir = yield* setupCacheDir;
@@ -222,7 +222,11 @@ const buildSearchJsonPayload = (params: {
222 },
223 connected_toolkits: connectedToolkits,
224 ...(params.searchResponse.error ? { error: params.searchResponse.error } : {}),
225 - CTA: params.cta,
225 + next_steps: {
226 + guidance:
227 + 'You can directly proceed with these steps without waiting for the user to ask. Link accounts first if needed, then execute tools.',
228 + steps: params.nextSteps,
229 + },
230 } as const;
231 });
232
@@ -262,6 +266,12 @@ const emitHumanSearchOutput = (params: {
266 }
267
268 if (params.firstSlug) {
269 + const linkHint = params.rootOnly
270 + ? commandHintStep('Link an account', 'root.link', { toolkit: '<toolkit>' })
271 + : commandHintStep('Link an account', 'dev.connectedAccounts.link', {
272 + toolkit: '<toolkit>',
273 + userId: '<user-id>',
274 + });
275 const executeHint = params.rootOnly
276 ? commandHintStep('Execute a tool', 'root.execute', {
277 slug: params.firstSlug,
@@ -272,13 +282,7 @@ const emitHumanSearchOutput = (params: {
282 userId: '<user-id>',
283 data: params.firstDataArg,
284 });
275 - const linkHint = params.rootOnly
276 - ? commandHintStep('Link an account', 'root.link', { toolkit: '<toolkit>' })
277 - : commandHintStep('Link an account', 'dev.connectedAccounts.link', {
278 - toolkit: '<toolkit>',
279 - userId: '<user-id>',
280 - });
281 - yield* params.ui.log.step([executeHint, linkHint].join('\n'));
285 + yield* params.ui.log.step([linkHint, executeHint].join('\n'));
286 }
287
288 if (params.error) {
@@ -422,7 +426,7 @@ const runToolsSearch = (params: {
426 const firstDataArg =
427 Object.keys(firstPayload).length === 0 ? '-d "{}"' : `-d '${firstPayloadJson}'`;
428
425 - const cta = buildSearchCta({
429 + const nextSteps = buildSearchNextSteps({
430 firstSlug,
431 firstToolkit,
432 firstDataArg,
@@ -436,7 +440,7 @@ const runToolsSearch = (params: {
440 consumerUserId: searchResult.historyScope?.consumerUserId,
441 },
442 projectScope: searchResult.projectScope,
439 - cta,
443 + nextSteps,
444 });
445
446 yield* appendCliSessionHistory({
@@ -490,9 +494,9 @@ export const toolsCmd$Search = Command.make(
494 ' composio search "list calendar events" --limit 5',
495 '',
496 'Next steps:',
497 + ' composio link <toolkit> Connect an account before executing tools',
498 " composio execute <slug> -d '{ ... }' Run a tool from the results",
499 " composio tools info <slug> Inspect a tool's schema before executing",
495 - ' composio link <toolkit> Connect an account if execute tells you to',
500 ].join('\n')
501 )
502 );
@@ -524,9 +528,9 @@ export const rootToolsCmd$Search = Command.make(
528 ' composio search "list calendar events" --limit 5',
529 '',
530 'Next steps:',
531 + ' composio link <toolkit> Connect an account before executing tools',
532 " composio execute <slug> -d '{ ... }' Run a tool from the results",
533 " composio tools info <slug> Inspect a tool's schema before executing",
529 - ' composio link <toolkit> Connect an account if execute tells you to',
534 ].join('\n')
535 )
536 );
ts/packages/cli/src/effects/app-config.ts
+6
@@ -10,6 +10,7 @@ type APP_CONFIG = Config.Config.Wrap<{
10 LOG_LEVEL: Option.Option<LogLevel.LogLevel>;
11 ORG_ID: Option.Option<string>;
12 PROJECT_ID: Option.Option<string>;
13 + DISABLE_CONNECTED_ACCOUNT_CACHE: boolean;
14 }>;
15
16 /**
@@ -65,4 +66,9 @@ export const APP_CONFIG = {
66
67 // The project ID for multi-project auth (overrides file-based config)
68 PROJECT_ID: Config.option(Config.string('PROJECT_ID')),
69 +
70 + // Disable connected account cache (defaults to true — cache is off by default)
71 + DISABLE_CONNECTED_ACCOUNT_CACHE: Config.boolean('DISABLE_CONNECTED_ACCOUNT_CACHE').pipe(
72 + Config.withDefault(true)
73 + ),
74 } satisfies APP_CONFIG;
ts/packages/cli/src/services/consumer-short-term-cache.ts
+12 -3
@@ -1,6 +1,7 @@
1 import path from 'node:path';
2 import { FileSystem } from '@effect/platform';
3 import { Effect, Option } from 'effect';
4 +import { APP_CONFIG } from 'src/effects/app-config';
5 import { setupCacheDir } from 'src/effects/setup-cache-dir';
6 import { NodeProcess } from 'src/services/node-process';
7 import {
@@ -112,9 +113,7 @@ const getAlwaysConnectedNoAuthToolkits = () =>
113 const toolkitsRepository = yield* ComposioToolkitsRepository;
114 const toolkits = yield* toolkitsRepository.getToolkits();
115
115 - return toolkits
116 - .filter(toolkit => toolkit.no_auth)
117 - .map(toolkit => toolkit.slug.toLowerCase());
116 + return toolkits.filter(toolkit => toolkit.no_auth).map(toolkit => toolkit.slug.toLowerCase());
117 });
118
119 const normalizeCachedToolkits = (
@@ -127,6 +126,10 @@ export const getFreshConsumerConnectedToolkitsFromCache = (params: {
126 consumerUserId: string;
127 }) =>
128 Effect.gen(function* () {
129 + const disabled = yield* APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE;
130 + if (disabled) {
131 + return Option.none<ReadonlyArray<string>>();
132 + }
133 const state = yield* readCache();
134 const entry = state[cacheKey(params.orgId, params.consumerUserId)];
135 if (!entry) {
@@ -194,6 +197,8 @@ export const refreshConsumerConnectedToolkitsCache = (params?: {
197 readonly consumerUserId?: string;
198 }) =>
199 Effect.gen(function* () {
200 + const disabled = yield* APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE;
201 + if (disabled) return;
202 const scope = yield* resolveConsumerScope(params);
203 if (!scope?.consumerUserId) {
204 return;
@@ -236,6 +241,8 @@ export const writeConsumerConnectedToolkitsCache = (params: {
241 readonly toolkits: ReadonlyArray<string>;
242 }) =>
243 Effect.gen(function* () {
244 + const disabled = yield* APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE;
245 + if (disabled) return;
246 const noAuthToolkits = yield* getAlwaysConnectedNoAuthToolkits();
247 const state = yield* readCache();
248 const key = cacheKey(params.orgId, params.consumerUserId);
@@ -271,6 +278,8 @@ export const getOrCreateProbablyMyCliSessionIdForCurrentCwd = (params?: {
278 readonly consumerUserId?: string;
279 }) =>
280 Effect.gen(function* () {
281 + const disabled = yield* APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE;
282 + if (disabled) return Option.none<string>();
283 const scope = yield* resolveConsumerScope(params);
284 if (!scope?.consumerUserId) {
285 return Option.none<string>();
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+19 -7
@@ -4,6 +4,17 @@ import { ValidationError, HelpDoc } from '@effect/cli';
4 import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';
5 import { afterEach, vi } from 'vitest';
6
7 +type CommandMismatchResult = {
8 + _tag: string;
9 + error: {
10 + _tag: string;
11 + value: {
12 + _tag: string;
13 + value: string;
14 + };
15 + };
16 +};
17 +
18 describe('CLI: composio', () => {
19 afterEach(() => {
20 vi.unstubAllEnvs();
@@ -15,14 +26,15 @@ describe('CLI: composio', () => {
26 const args = ['--bar'];
27
28 const result = yield* cli(args).pipe(Effect.catchAll(e => Effect.succeed(e)));
29 + const commandMismatch = result as CommandMismatchResult;
30
19 - expect(result).toEqual(
20 - ValidationError.commandMismatch(
21 - HelpDoc.p(
22 - "Invalid subcommand for composio - use one of 'version', 'upgrade', 'whoami', 'login', 'logout', 'run', 'proxy', 'artifacts', 'install', 'dev', 'tools', 'search', 'link', 'execute', 'generate'"
23 - )
24 - )
25 - );
31 + expect(result).toEqual(expect.any(Object));
32 + expect(commandMismatch._tag).toBe(ValidationError.commandMismatch(HelpDoc.p(''))._tag);
33 + expect(commandMismatch.error._tag).toBe('Paragraph');
34 + expect(commandMismatch.error.value._tag).toBe('Text');
35 + expect(commandMismatch.error.value.value).toContain('Invalid subcommand for composio');
36 + expect(commandMismatch.error.value.value).toContain("'generate'");
37 + expect(commandMismatch.error.value.value).toContain("'orgs'");
38 })
39 );
40 });
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.link.cmd.test.ts
+37 -22
@@ -5,6 +5,12 @@ import { cli, TestLive, MockConsole } from 'test/__utils__';
5 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
6 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
7 import { TerminalUI } from 'src/services/terminal-ui';
8 +import open from 'open';
9 +import { afterEach, vi } from 'vitest';
10 +
11 +vi.mock('open', () => ({
12 + default: vi.fn(async () => undefined),
13 +}));
14
15 const extractJsonObject = (output: string): Record<string, unknown> | null => {
16 const jsonMatch = output.match(/\{[\s\S]*"status"[\s\S]*\}/);
@@ -70,6 +76,10 @@ const RecordingTerminalUI = TerminalUI.of({
76 });
77
78 describe('CLI: composio dev connected-accounts link', () => {
79 + afterEach(() => {
80 + vi.clearAllMocks();
81 + });
82 +
83 layer(
84 TestLive({
85 baseConfigProvider: testConfigProvider,
@@ -79,7 +89,7 @@ describe('CLI: composio dev connected-accounts link', () => {
89 )('[Given] valid toolkit link [Then] creates link and waits (default)', it => {
90 it.scoped('creates link and waits for ACTIVE', () =>
91 Effect.gen(function* () {
82 - yield* cli(['link', 'gmail', '--no-browser']);
92 + yield* cli(['link', 'gmail']);
93 const lines = yield* MockConsole.getLines({ stripAnsi: true });
94 const parsed = extractJsonObject(lines.join('\n'));
95
@@ -87,6 +97,7 @@ describe('CLI: composio dev connected-accounts link', () => {
97 expect(parsed?.status).toBe('success');
98 expect(parsed?.connected_account_id).toBe('con_test_link');
99 expect(parsed?.toolkit).toBe('gmail');
100 + expect(vi.mocked(open)).toHaveBeenCalledOnce();
101 })
102 );
103 });
@@ -98,15 +109,24 @@ describe('CLI: composio dev connected-accounts link', () => {
109 fixture: 'global-test-user-id',
110 terminalUI: RecordingTerminalUI,
111 })
101 - )('[Given] --no-browser [Then] emits a forced raw redirect URL for merged-stream shells', it => {
102 - it.scoped('forces the redirect URL through output()', () =>
112 + )('[Given] --no-wait [Then] emits a forced JSON payload for merged-stream shells', it => {
113 + it.scoped('forces the pending JSON payload through output()', () =>
114 Effect.gen(function* () {
104 - yield* cli(['link', 'gmail', '--no-browser']);
115 + yield* cli(['link', 'gmail', '--no-wait']);
116 const lines = yield* MockConsole.getLines({ stripAnsi: true });
106 - const output = lines.join('\n');
117 + const forcedLine = lines
118 + .map(line => {
119 + try {
120 + return JSON.parse(line) as { channel?: string; data?: string };
121 + } catch {
122 + return null;
123 + }
124 + })
125 + .find(line => line?.channel === 'FORCED');
126
108 - expect(output).toContain('"channel":"FORCED"');
109 - expect(output).toContain('https://app.composio.dev/link?token=lt_test_token');
127 + expect(forcedLine).toBeTruthy();
128 + expect(forcedLine?.data).toContain('"status": "pending"');
129 + expect(vi.mocked(open)).not.toHaveBeenCalled();
130 })
131 );
132 });
@@ -118,10 +138,10 @@ describe('CLI: composio dev connected-accounts link', () => {
138 fixture: 'global-test-user-id',
139 terminalUI: RecordingTerminalUI,
140 })
121 - )('[Given] --no-browser --no-wait [Then] stdout remains JSON-only', it => {
141 + )('[Given] --no-wait [Then] stdout remains JSON-only', it => {
142 it.scoped('does not emit the raw redirect URL before the pending JSON payload', () =>
143 Effect.gen(function* () {
124 - yield* cli(['link', 'gmail', '--no-browser', '--no-wait']);
144 + yield* cli(['link', 'gmail', '--no-wait']);
145 const lines = yield* MockConsole.getLines({ stripAnsi: true });
146 const forcedLines = lines
147 .map(line => {
@@ -140,18 +160,13 @@ describe('CLI: composio dev connected-accounts link', () => {
160 );
161 });
162
143 - layer(
144 - TestLive({
145 - baseConfigProvider: testConfigProvider,
146 - connectedAccountsData,
147 - fixture: 'global-test-user-id',
148 - })
149 - )('[Given] no API key [Then] warns user to login', it => {
163 + layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
164 it.scoped('warns user to login', () =>
165 Effect.gen(function* () {
152 - yield* cli(['link', 'gmail', '--no-browser']);
166 + yield* cli(['link', 'gmail']);
167 const lines = yield* MockConsole.getLines({ stripAnsi: true });
154 - expect(lines.length).toBeGreaterThan(0);
168 + const output = lines.join('\n');
169 + expect(output).toContain('not logged in');
170 })
171 );
172 });
@@ -165,7 +180,7 @@ describe('CLI: composio dev connected-accounts link', () => {
180 )('[Given] composio link [Then] works for consumer toolkit linking', it => {
181 it.scoped('root link works for consumer toolkit linking only', () =>
182 Effect.gen(function* () {
168 - yield* cli(['link', 'gmail', '--no-browser']);
183 + yield* cli(['link', 'gmail']);
184 const lines = yield* MockConsole.getLines({ stripAnsi: true });
185 const parsed = extractJsonObject(lines.join('\n'));
186
@@ -185,7 +200,7 @@ describe('CLI: composio dev connected-accounts link', () => {
200 )('[Given] --no-wait [Then] outputs valid JSON parseable by jq', it => {
201 it.scoped('prints JSON with status pending, connected_account_id, redirect_url', () =>
202 Effect.gen(function* () {
188 - yield* cli(['link', 'gmail', '--no-browser', '--no-wait']);
203 + yield* cli(['link', 'gmail', '--no-wait']);
204 const lines = yield* MockConsole.getLines({ stripAnsi: true });
205 const parsed = extractJsonObject(lines.join('\n'));
206
@@ -215,7 +230,7 @@ describe('CLI: composio dev connected-accounts link', () => {
230 it => {
231 it.scoped('reports the incomplete response instead of waiting with empty values', () =>
232 Effect.gen(function* () {
218 - yield* cli(['link', 'gmail', '--no-browser']);
233 + yield* cli(['link', 'gmail']);
234 const lines = yield* MockConsole.getLines({ stripAnsi: true });
235 const parsed = extractJsonObject(lines.join('\n'));
236
@@ -237,7 +252,7 @@ describe('CLI: composio dev connected-accounts link', () => {
252 'prints JSON with status success, message, connected_account_id, toolkit, redirect_url',
253 () =>
254 Effect.gen(function* () {
240 - yield* cli(['link', 'gmail', '--no-browser']);
255 + yield* cli(['link', 'gmail']);
256 const lines = yield* MockConsole.getLines({ stripAnsi: true });
257 const parsed = extractJsonObject(lines.join('\n'));
258
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+101 -52
@@ -53,6 +53,49 @@ const testLiveOptions = {
53 fixture: 'global-test-user-id' as const,
54 };
55
56 +const extractFirstJsonObject = (output: string): Record<string, unknown> | null => {
57 + const start = output.indexOf('{');
58 + if (start < 0) return null;
59 +
60 + let depth = 0;
61 + let inString = false;
62 + let escaped = false;
63 +
64 + for (let i = start; i < output.length; i += 1) {
65 + const char = output[i];
66 +
67 + if (inString) {
68 + if (escaped) {
69 + escaped = false;
70 + } else if (char === '\\') {
71 + escaped = true;
72 + } else if (char === '"') {
73 + inString = false;
74 + }
75 + continue;
76 + }
77 +
78 + if (char === '"') {
79 + inString = true;
80 + continue;
81 + }
82 +
83 + if (char === '{') {
84 + depth += 1;
85 + continue;
86 + }
87 +
88 + if (char === '}') {
89 + depth -= 1;
90 + if (depth === 0) {
91 + return JSON.parse(output.slice(start, i + 1)) as Record<string, unknown>;
92 + }
93 + }
94 + }
95 +
96 + return null;
97 +};
98 +
99 describe('CLI: composio search', () => {
100 layer(TestLive(testLiveOptions))('[Given] query "send" [Then] returns JSON by default', it => {
101 it.scoped('returns JSON payload by default', () =>
@@ -60,18 +103,18 @@ describe('CLI: composio search', () => {
103 yield* cli(['search', 'send']);
104 const lines = yield* MockConsole.getLines({ stripAnsi: true });
105 const output = lines.join('\n');
63 -
64 - expect(output).toContain('"results"');
65 - expect(output).toContain('"tool_schemas"');
66 - expect(output).toContain('"primary"');
67 - expect(output).toContain('"related_tools_path_format"');
68 - expect(output).toContain('"connected_toolkits"');
69 - expect(output).toContain('"CTA"');
70 - expect(output).not.toContain('"session"');
71 - expect(output).not.toContain('"time_info"');
72 - expect(output).not.toContain('"next_steps_guidance"');
73 - expect(output).not.toContain('"success"');
74 - expect(output).not.toContain('"error"');
106 + const parsed = extractFirstJsonObject(output);
107 +
108 + expect(parsed).not.toBeNull();
109 + expect(parsed).toHaveProperty('results');
110 + expect(parsed).toHaveProperty('tool_schemas');
111 + expect(parsed).toHaveProperty('connected_toolkits');
112 + expect(parsed).toHaveProperty('next_steps');
113 + expect(parsed).not.toHaveProperty('session');
114 + expect(parsed).not.toHaveProperty('time_info');
115 + expect(parsed).not.toHaveProperty('next_steps_guidance');
116 + expect(parsed).not.toHaveProperty('success');
117 + expect(parsed).not.toHaveProperty('error');
118 expect(output).toContain('GMAIL_SEND_EMAIL');
119 expect(output).toContain('SLACK_SEND_MESSAGE');
120 expect(output).toContain('~/.composio/tool_definitions/GMAIL_SEND_EMAIL.json');
@@ -151,25 +194,27 @@ describe('CLI: composio search', () => {
194 );
195
196 layer(TestLive(testLiveOptions))(
154 - '[Given] search --json [Then] JSON output includes full tool-router payload and CTA',
197 + '[Given] search --json [Then] JSON output includes full tool-router payload and next steps',
198 it => {
156 - it.scoped('prints full search response with CTA for jq', () =>
199 + it.scoped('prints full search response with next steps for jq', () =>
200 Effect.gen(function* () {
201 yield* cli(['search', 'send', '--json']);
202 const lines = yield* MockConsole.getLines({ stripAnsi: true });
203 const output = lines.join('\n');
161 -
162 - expect(output).toContain('"results"');
163 - expect(output).toContain('"tool_schemas"');
164 - expect(output).toContain('"connected_toolkits"');
165 - expect(output).toContain('"CTA"');
166 - expect(output).not.toContain('"session"');
167 - expect(output).not.toContain('"time_info"');
168 - expect(output).not.toContain('"next_steps_guidance"');
169 - expect(output).not.toContain('"success"');
170 - expect(output).not.toContain('"error"');
204 + const parsed = extractFirstJsonObject(output);
205 +
206 + expect(parsed).not.toBeNull();
207 + expect(parsed).toHaveProperty('results');
208 + expect(parsed).toHaveProperty('tool_schemas');
209 + expect(parsed).toHaveProperty('connected_toolkits');
210 + expect(parsed).toHaveProperty('next_steps');
211 + expect(parsed).not.toHaveProperty('session');
212 + expect(parsed).not.toHaveProperty('time_info');
213 + expect(parsed).not.toHaveProperty('next_steps_guidance');
214 + expect(parsed).not.toHaveProperty('success');
215 + expect(parsed).not.toHaveProperty('error');
216 expect(output).toContain('"Execute a tool"');
172 - expect(output).toContain('"Connect a user account"');
217 + expect(output).toContain('"Link a user account"');
218 expect(output).toContain('composio execute');
219 expect(output).toContain('composio link gmail');
220 })
@@ -244,9 +289,9 @@ describe('CLI: composio search', () => {
289 );
290
291 layer(TestLive({ baseConfigProvider: testConfigProvider, fixture: 'global-test-user-id' }))(
247 - '[Given] search with schema properties [Then] CTA has valid payload and lowercase link',
292 + '[Given] search with schema properties [Then] next steps have valid payload and lowercase link',
293 it => {
249 - it.scoped('CTA uses valid payload from input_schema and lowercase toolkit', () =>
294 + it.scoped('next steps use valid payload from input_schema and lowercase toolkit', () =>
295 Effect.gen(function* () {
296 const live = TestLive({
297 baseConfigProvider: testConfigProvider,
@@ -277,42 +322,46 @@ describe('CLI: composio search', () => {
322 yield* cli(['search', 'send']).pipe(Effect.provide(live));
323 const lines = yield* MockConsole.getLines({ stripAnsi: true });
324 const output = lines.join('\n');
280 -
281 - const ctaMatch = output.match(/"CTA":\s*\[([\s\S]*?)\]/);
282 - expect(ctaMatch).toBeTruthy();
283 - const ctaJson = `[${ctaMatch![1]}]`;
284 - const cta = JSON.parse(ctaJson) as Array<{ action: string; command: string }>;
285 -
286 - const executeCta = cta.find(c => c.action === 'Execute a tool');
287 - expect(executeCta).toBeTruthy();
288 - expect(executeCta!.command).toContain('composio execute "GMAIL_SEND_EMAIL"');
289 - expect(executeCta!.command).toMatch(/-d '\{"to":"","subject":"","body":""\}'/);
290 -
291 - const linkCta = cta.find(c => c.action === 'Connect a user account');
292 - expect(linkCta).toBeTruthy();
293 - expect(linkCta!.command).toBe('composio link gmail');
325 + const parsed = extractFirstJsonObject(output);
326 + const nextSteps = parsed?.next_steps as
327 + | {
328 + steps?: Array<{ action: string; command: string }>;
329 + }
330 + | undefined;
331 +
332 + expect(nextSteps?.steps).toBeTruthy();
333 +
334 + const executeStep = nextSteps?.steps?.find(step => step.action === 'Execute a tool');
335 + expect(executeStep).toBeTruthy();
336 + expect(executeStep!.command).toContain('composio execute "GMAIL_SEND_EMAIL"');
337 + expect(executeStep!.command).toMatch(/-d '\{"to":"","subject":"","body":""\}'/);
338 +
339 + const linkStep = nextSteps?.steps?.find(step => step.action === 'Link a user account');
340 + expect(linkStep).toBeTruthy();
341 + expect(linkStep!.command).toBe('composio link gmail');
342 })
343 );
344 }
345 );
346
347 layer(TestLive(testLiveOptions))(
300 - '[Given] search with empty schema [Then] CTA execute uses -d "{}"',
348 + '[Given] search with empty schema [Then] next steps execute uses -d "{}"',
349 it => {
302 - it.scoped('CTA uses -d "{}" when no schema properties', () =>
350 + it.scoped('next steps use -d "{}" when no schema properties', () =>
351 Effect.gen(function* () {
352 yield* cli(['search', 'send']);
353 const lines = yield* MockConsole.getLines({ stripAnsi: true });
354 const output = lines.join('\n');
307 -
308 - const ctaMatch = output.match(/"CTA":\s*\[([\s\S]*?)\]/);
309 - expect(ctaMatch).toBeTruthy();
310 - const ctaJson = `[${ctaMatch![1]}]`;
311 - const cta = JSON.parse(ctaJson) as Array<{ action: string; command: string }>;
312 -
313 - const executeCta = cta.find(c => c.action === 'Execute a tool');
314 - expect(executeCta).toBeTruthy();
315 - expect(executeCta!.command).toContain('-d "{}"');
355 + const parsed = extractFirstJsonObject(output);
356 + const nextSteps = parsed?.next_steps as
357 + | {
358 + steps?: Array<{ action: string; command: string }>;
359 + }
360 + | undefined;
361 +
362 + const executeStep = nextSteps?.steps?.find(step => step.action === 'Execute a tool');
363 + expect(executeStep).toBeTruthy();
364 + expect(executeStep!.command).toContain('-d "{}"');
365 })
366 );
367 }
ts/packages/cli/test/src/services/config.test.ts
+62
@@ -30,6 +30,7 @@ describe('Config', () => {
30 LOG_LEVEL: Option.none(),
31 ORG_ID: Option.none(),
32 PROJECT_ID: Option.none(),
33 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
34 WEB_URL: 'https://dashboard.composio.dev/',
35 })
36 );
@@ -57,6 +58,7 @@ describe('Config', () => {
58 LOG_LEVEL: Option.none(),
59 ORG_ID: Option.none(),
60 PROJECT_ID: Option.none(),
61 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
62 WEB_URL: 'https://dashboard.composio.dev/',
63 })
64 );
@@ -86,6 +88,33 @@ describe('Config', () => {
88 LOG_LEVEL: Option.some(LogLevel.Info),
89 ORG_ID: Option.none(),
90 PROJECT_ID: Option.none(),
91 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
92 + })
93 + );
94 + });
95 +
96 + it('[When] COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE is "false"', () => {
97 + const map = new Map([['COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'false']]) satisfies Map<
98 + string,
99 + string
100 + >;
101 +
102 + const actual = Effect.runSync(
103 + withMapConfigProvider(map)(Config.all(APP_CONFIG).pipe(Effect.andThen(Data.struct)))
104 + );
105 +
106 + assertEquals(
107 + actual,
108 + Data.struct({
109 + USER_API_KEY: Option.none(),
110 + ENVIRONMENT: Option.none(),
111 + BASE_URL: 'https://backend.composio.dev',
112 + WEB_URL: 'https://dashboard.composio.dev/',
113 + CACHE_DIR: Option.none(),
114 + LOG_LEVEL: Option.none(),
115 + ORG_ID: Option.none(),
116 + PROJECT_ID: Option.none(),
117 + DISABLE_CONNECTED_ACCOUNT_CACHE: false,
118 })
119 );
120 });
@@ -108,6 +137,7 @@ describe('Config', () => {
137 LOG_LEVEL: Option.none(),
138 ORG_ID: Option.none(),
139 PROJECT_ID: Option.none(),
140 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
141 })
142 );
143 });
@@ -130,6 +160,7 @@ describe('Config', () => {
160 LOG_LEVEL: Option.none(),
161 ORG_ID: Option.none(),
162 PROJECT_ID: Option.none(),
163 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
164 })
165 );
166 });
@@ -155,6 +186,7 @@ describe('Config', () => {
186 LOG_LEVEL: Option.none(),
187 ORG_ID: Option.none(),
188 PROJECT_ID: Option.none(),
189 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
190 })
191 );
192 });
@@ -180,6 +212,7 @@ describe('Config', () => {
212 LOG_LEVEL: Option.none(),
213 ORG_ID: Option.none(),
214 PROJECT_ID: Option.none(),
215 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
216 })
217 );
218 });
@@ -202,6 +235,7 @@ describe('Config', () => {
235 LOG_LEVEL: Option.none(),
236 ORG_ID: Option.none(),
237 PROJECT_ID: Option.none(),
238 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
239 })
240 );
241 });
@@ -312,6 +346,7 @@ describe('Config', () => {
346 LOG_LEVEL: Option.none(),
347 ORG_ID: Option.none(),
348 PROJECT_ID: Option.none(),
349 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
350 })
351 );
352 });
@@ -337,6 +372,7 @@ describe('Config', () => {
372 LOG_LEVEL: Option.none(),
373 ORG_ID: Option.none(),
374 PROJECT_ID: Option.none(),
375 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
376 })
377 );
378 });
@@ -363,6 +399,30 @@ describe('Config', () => {
399 LOG_LEVEL: Option.some(LogLevel.Info),
400 ORG_ID: Option.none(),
401 PROJECT_ID: Option.none(),
402 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
403 + })
404 + );
405 + });
406 +
407 + it('[When] COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE is "false"', () => {
408 + vi.stubEnv('COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'false');
409 +
410 + const actual = Effect.runSync(
411 + withEnvConfigProvider(Config.all(APP_CONFIG).pipe(Effect.andThen(Data.struct)))
412 + );
413 +
414 + assertEquals(
415 + actual,
416 + Data.struct({
417 + USER_API_KEY: Option.none(),
418 + ENVIRONMENT: Option.none(),
419 + BASE_URL: 'https://backend.composio.dev',
420 + WEB_URL: 'https://dashboard.composio.dev/',
421 + CACHE_DIR: Option.none(),
422 + LOG_LEVEL: Option.none(),
423 + ORG_ID: Option.none(),
424 + PROJECT_ID: Option.none(),
425 + DISABLE_CONNECTED_ACCOUNT_CACHE: false,
426 })
427 );
428 });
@@ -385,6 +445,7 @@ describe('Config', () => {
445 LOG_LEVEL: Option.none(),
446 ORG_ID: Option.none(),
447 PROJECT_ID: Option.none(),
448 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
449 })
450 );
451 });
@@ -409,6 +470,7 @@ describe('Config', () => {
470 LOG_LEVEL: Option.none(),
471 ORG_ID: Option.none(),
472 PROJECT_ID: Option.none(),
473 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
474 })
475 );
476 });
ts/packages/cli/test/src/services/consumer-short-term-cache.test.ts
+37 -8
@@ -10,21 +10,50 @@ import {
10 } from 'src/services/consumer-short-term-cache';
11 import { TestLive } from 'test/__utils__';
12
13 -const testConfigProvider = ConfigProvider.fromMap(
14 - new Map([
15 - ['COMPOSIO_USER_API_KEY', 'test_api_key'],
16 - ['COMPOSIO_BASE_URL', 'https://backend.composio.dev'],
17 - ])
18 -).pipe(extendConfigProvider);
13 +const makeTestConfigProvider = (entries: Array<[string, string]>) =>
14 + ConfigProvider.fromMap(
15 + new Map([
16 + ['COMPOSIO_USER_API_KEY', 'test_api_key'],
17 + ['COMPOSIO_BASE_URL', 'https://backend.composio.dev'],
18 + ...entries,
19 + ])
20 + ).pipe(extendConfigProvider);
21 +
22 +const defaultTestConfigProvider = makeTestConfigProvider([]);
23 +const cacheEnabledTestConfigProvider = makeTestConfigProvider([
24 + ['COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'false'],
25 +]);
26
27 describe('consumer short-term cache', () => {
28 afterEach(() => {
29 vi.restoreAllMocks();
30 });
31
32 + layer(TestLive({ baseConfigProvider: defaultTestConfigProvider }))(
33 + '[Given] the default cache config [Then] connected-account cache stays disabled',
34 + it => {
35 + it.scoped('returns none even after a write is attempted', () =>
36 + Effect.gen(function* () {
37 + yield* writeConsumerConnectedToolkitsCache({
38 + orgId: 'org_test',
39 + consumerUserId: 'consumer-user-test',
40 + toolkits: ['github'],
41 + });
42 +
43 + const cached = yield* getFreshConsumerConnectedToolkitsFromCache({
44 + orgId: 'org_test',
45 + consumerUserId: 'consumer-user-test',
46 + });
47 +
48 + expect(cached).toEqual(Option.none());
49 + })
50 + );
51 + }
52 + );
53 +
54 layer(
55 TestLive({
27 - baseConfigProvider: testConfigProvider,
56 + baseConfigProvider: cacheEnabledTestConfigProvider,
57 toolkitsData: {
58 toolkits: [
59 {
@@ -88,7 +117,7 @@ describe('consumer short-term cache', () => {
117
118 layer(
119 TestLive({
91 - baseConfigProvider: testConfigProvider,
120 + baseConfigProvider: cacheEnabledTestConfigProvider,
121 toolkitsData: {
122 toolkits: [
123 {