@devries-cameron20 / composio Mirror · read-only / commits / 341cdcf59
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, 23:30 UTC

Add CLI dev mode config toggle (#3181)

## Summary Turns `composio dev` into a real developer-mode switch backed by CLI user config, and hides the developer subcommand tree when the mode is off. ## `composio dev` changes - **New `--mode on|off` option** on the `dev` command (`Options.choice('mode', ['on', 'off'])`, optional). - **Visibility-gated subcommands.** `buildDevCommand(visibility)` only attaches the developer subcommand tree (`init`, `tools execute`, `triggers listen`, `logs`, `toolkits`, `auth-configs`, `connected-accounts`, `triggers`, `projects`) when `visibility.isDevModeEnabled` is true. When off, `composio dev` is a leaf command whose only job is toggling the mode. - **Handler behavior:** - `composio dev` with no flag → interactive `select` prompt (Turn on / Turn off / Keep current). Non-TTY → prints current state and exits with a hint to pass `--mode on|off`. - `composio dev --mode on` → shows a boxed warning note about unlocking advanced commands, then `confirm` before flipping. Non-TTY refuses to enable and points the user at the config file path. - `composio dev --mode off` → flips immediately. - No-op if the requested state already matches; logs current state instead of rewriting config. - **Description swaps with mode.** When dev mode is on: *"Developer workflows: init, playground execution, logs, projects, toolkits, accounts, and triggers."* When off: *"Developer mode controls access to developer-only workflows. When off, only `composio dev --mode on|off` is available."* ## Config wiring - `CliUserConfig` gains a `developer` struct (`{ enabled, destructive_actions }`) replacing the flat `developer_mode_enabled` / `developer_dangerous_commands_enabled` keys. `normalizeRawConfigJson` migrates existing configs on read. - `ComposioCliUserConfig` service exposes `isDevModeEnabled()`, `areDeveloperDangerousCommandsEnabled()`, and an `update()` that persists partial changes to `~/.composio/<cli-config>.json`. - `cli-main.ts` / `root-help.ts` / `commands/index.ts` consume visibility so the help output and command tree match the toggle. ## Collateral cleanup Removed deprecated destructive/info commands that were being guarded ad-hoc and now fall under the dev-mode gate: - `auth-configs delete`, `auth-configs info` - `connected-accounts delete`, `connected-accounts info` - `triggers delete` - Corresponding tests deleted; `auth-configs create`, `projects list/switch`, and `triggers` mutation tests updated for the new layer/visibility shape. ## Testing - `ts/packages/cli/test/src/commands/dev.cmd.test.ts` — new coverage for the toggle handler (TTY/non-TTY, on→on no-op, confirm path, persisted config). - `ts/packages/cli/test/src/services/cli-user-config.test.ts` — new coverage for the `developer` struct, legacy key migration, and `update()`. - `ts/packages/cli/test/src/commands/feature-visibility.test.ts` — updated to exercise visibility-gated subcommands. - Not run: full workspace test suite. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Rahul Tarak committed Apr 13, 2026 at 19:12 UTC 341cdcf596a92b76aa52fac4290f44eadd7064cc
36 files changed +722 -812
.claude/scheduled_tasks.lock new
+1
@@ -0,0 +1 @@
1 +{"sessionId":"0c33a336-176b-419b-bf11-3a02d7b9e7fd","pid":83505,"acquiredAt":1776130817189}
\ No newline at end of file
ts/packages/cli/src/cli-main.ts
+2
@@ -204,6 +204,7 @@ runWithArgs.pipe(
204 return Effect.gen(function* () {
205 const cliUserConfig = yield* ComposioCliUserConfig;
206 const visibility = {
207 + isDevModeEnabled: cliUserConfig.isDevModeEnabled(),
208 isExperimentalFeatureEnabled: (feature: string) =>
209 cliUserConfig.isExperimentalFeatureEnabled(feature),
210 };
@@ -255,6 +256,7 @@ runWithArgs.pipe(
256 yield* Console.error(message);
257 const cliUserConfig = yield* ComposioCliUserConfig;
258 const visibility = {
259 + isDevModeEnabled: cliUserConfig.isDevModeEnabled(),
260 isExperimentalFeatureEnabled: (feature: string) =>
261 cliUserConfig.isExperimentalFeatureEnabled(feature),
262 };
ts/packages/cli/src/commands/auth-configs/auth-configs.cmd.ts
+1 -7
@@ -2,7 +2,6 @@ import { Command } from '@effect/cli';
2 import { authConfigsCmd$List } from './commands/auth-configs.list.cmd';
3 import { authConfigsCmd$Info } from './commands/auth-configs.info.cmd';
4 import { authConfigsCmd$Create } from './commands/auth-configs.create.cmd';
5 -import { authConfigsCmd$Delete } from './commands/auth-configs.delete.cmd';
5
6 /**
7 * CLI entry point for auth config management commands.
@@ -14,10 +13,5 @@ import { authConfigsCmd$Delete } from './commands/auth-configs.delete.cmd';
13 */
14 export const authConfigsCmd = Command.make('auth-configs').pipe(
15 Command.withDescription('View and manage Composio auth configs.'),
17 - Command.withSubcommands([
18 - authConfigsCmd$List,
19 - authConfigsCmd$Info,
20 - authConfigsCmd$Create,
21 - authConfigsCmd$Delete,
22 - ])
16 + Command.withSubcommands([authConfigsCmd$List, authConfigsCmd$Info, authConfigsCmd$Create])
17 );
ts/packages/cli/src/commands/auth-configs/commands/auth-configs.delete.cmd.ts deleted
-81
@@ -1,81 +0,0 @@
1 -import { Args, Command, Options } from '@effect/cli';
2 -import { Effect, Option } from 'effect';
3 -import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 -import { TerminalUI } from 'src/services/terminal-ui';
5 -import { requireAuth } from 'src/effects/require-auth';
6 -import { handleHttpServerError } from 'src/effects/handle-http-error';
7 -
8 -const id = Args.text({ name: 'id' }).pipe(
9 - Args.withDescription('Auth config ID (nanoid)'),
10 - Args.optional
11 -);
12 -
13 -const yes = Options.boolean('yes').pipe(
14 - Options.withAlias('y'),
15 - Options.withDescription('Skip confirmation prompt'),
16 - Options.withDefault(false)
17 -);
18 -
19 -/**
20 - * Delete an auth config.
21 - *
22 - * This is a soft-delete — the auth config is marked as deleted and cannot be used
23 - * for new connections. This operation cannot be undone.
24 - *
25 - * @example
26 - * ```bash
27 - * composio dev auth-configs delete "ac_1232323"
28 - * composio dev auth-configs delete "ac_1232323" --yes
29 - * ```
30 - */
31 -export const authConfigsCmd$Delete = Command.make('delete', { id, yes }, ({ id, yes }) =>
32 - Effect.gen(function* () {
33 - if (!(yield* requireAuth)) return;
34 -
35 - const ui = yield* TerminalUI;
36 - const repo = yield* ComposioToolkitsRepository;
37 -
38 - // Missing ID guard
39 - if (Option.isNone(id)) {
40 - yield* ui.log.warn('Missing required argument: <id>');
41 - yield* ui.log.step(
42 - 'Try specifying an auth config ID, e.g.:\n> composio dev auth-configs delete "ac_1232323"\n\nTo find auth config IDs:\n> composio dev auth-configs list'
43 - );
44 - return;
45 - }
46 -
47 - const idValue = id.value;
48 -
49 - // Confirmation prompt (skipped with --yes or in non-interactive/piped mode)
50 - if (!yes) {
51 - const confirmed = yield* ui.confirm(
52 - `Delete auth config "${idValue}"? This cannot be undone.`,
53 - { defaultValue: false }
54 - );
55 - if (!confirmed) {
56 - yield* ui.log.warn('Deletion cancelled.');
57 - return;
58 - }
59 - }
60 -
61 - const deleted = yield* ui
62 - .withSpinner(`Deleting auth config "${idValue}"...`, repo.deleteAuthConfig(idValue))
63 - .pipe(
64 - Effect.as(true),
65 - Effect.catchTag(
66 - 'services/HttpServerError',
67 - handleHttpServerError(ui, {
68 - fallbackMessage: `Failed to delete auth config "${idValue}".`,
69 - hint: 'Browse available auth configs:\n> composio dev auth-configs list',
70 - fallbackValue: false,
71 - })
72 - )
73 - );
74 -
75 - if (!deleted) {
76 - return;
77 - }
78 -
79 - yield* ui.log.success(`Auth config "${idValue}" deleted.`);
80 - })
81 -).pipe(Command.withDescription('Delete an auth config.'));
ts/packages/cli/src/commands/auth-configs/commands/auth-configs.info.cmd.ts
-8
@@ -4,7 +4,6 @@ import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { requireAuth } from 'src/effects/require-auth';
6 import { handleHttpServerError } from 'src/effects/handle-http-error';
7 -import { redact } from 'src/ui/redact';
7 import { formatAuthConfigInfo } from '../format';
8
9 const id = Args.text({ name: 'id' }).pipe(
@@ -61,13 +60,6 @@ export const authConfigsCmd$Info = Command.make('info', { id }, ({ id }) =>
60
61 yield* ui.note(formatAuthConfigInfo(item), `Auth Config: ${item.name}`);
62
64 - const redactedId = redact({ value: item.id, prefix: 'ac_' });
65 -
66 - // Next step hint
67 - yield* ui.log.step(
68 - `To delete this auth config:\n> composio dev auth-configs delete "${redactedId}"`
69 - );
70 -
63 yield* ui.output(JSON.stringify(item, null, 2));
64 })
65 ).pipe(Command.withDescription('View details of a specific auth config.'));
ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.delete.cmd.ts deleted
-84
@@ -1,84 +0,0 @@
1 -import { Args, Command, Options } from '@effect/cli';
2 -import { Effect, Option } from 'effect';
3 -import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 -import { TerminalUI } from 'src/services/terminal-ui';
5 -import { requireAuth } from 'src/effects/require-auth';
6 -import { handleHttpServerError } from 'src/effects/handle-http-error';
7 -
8 -const id = Args.text({ name: 'id' }).pipe(
9 - Args.withDescription('Connected account ID (nanoid)'),
10 - Args.optional
11 -);
12 -
13 -const yes = Options.boolean('yes').pipe(
14 - Options.withAlias('y'),
15 - Options.withDescription('Skip confirmation prompt'),
16 - Options.withDefault(false)
17 -);
18 -
19 -/**
20 - * Delete a connected account.
21 - *
22 - * This is a soft-delete — the connected account is marked as deleted and cannot
23 - * be used for API calls. This operation cannot be undone.
24 - *
25 - * @example
26 - * ```bash
27 - * composio dev connected-accounts delete "con_1a2b3c4d5e6f"
28 - * composio dev connected-accounts delete "con_1a2b3c4d5e6f" --yes
29 - * ```
30 - */
31 -export const connectedAccountsCmd$Delete = Command.make('delete', { id, yes }, ({ id, yes }) =>
32 - Effect.gen(function* () {
33 - if (!(yield* requireAuth)) return;
34 -
35 - const ui = yield* TerminalUI;
36 - const repo = yield* ComposioToolkitsRepository;
37 -
38 - // Missing ID guard
39 - if (Option.isNone(id)) {
40 - yield* ui.log.warn('Missing required argument: <id>');
41 - yield* ui.log.step(
42 - 'Try specifying a connected account ID, e.g.:\n> composio dev connected-accounts delete "con_1a2b3c4d5e6f"\n\nTo find connected account IDs:\n> composio dev connected-accounts list'
43 - );
44 - return;
45 - }
46 -
47 - const idValue = id.value;
48 -
49 - // Confirmation prompt (skipped with --yes or in non-interactive/piped mode)
50 - if (!yes) {
51 - const confirmed = yield* ui.confirm(
52 - `Delete connected account "${idValue}"? This cannot be undone.`,
53 - { defaultValue: false }
54 - );
55 - if (!confirmed) {
56 - yield* ui.log.warn('Deletion cancelled.');
57 - return;
58 - }
59 - }
60 -
61 - const deleted = yield* ui
62 - .withSpinner(
63 - `Deleting connected account "${idValue}"...`,
64 - repo.deleteConnectedAccount(idValue)
65 - )
66 - .pipe(
67 - Effect.as(true),
68 - Effect.catchTag(
69 - 'services/HttpServerError',
70 - handleHttpServerError(ui, {
71 - fallbackMessage: `Failed to delete connected account "${idValue}".`,
72 - hint: 'Browse available connected accounts:\n> composio dev connected-accounts list',
73 - fallbackValue: false,
74 - })
75 - )
76 - );
77 -
78 - if (!deleted) {
79 - return;
80 - }
81 -
82 - yield* ui.log.success(`Connected account "${idValue}" deleted.`);
83 - })
84 -).pipe(Command.withDescription('Delete a connected account.'));
ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.info.cmd.ts
-8
@@ -4,7 +4,6 @@ import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { requireAuth } from 'src/effects/require-auth';
6 import { handleHttpServerError } from 'src/effects/handle-http-error';
7 -import { redact } from 'src/ui/redact';
7 import { formatConnectedAccountInfo } from '../format';
8
9 const id = Args.text({ name: 'id' }).pipe(
@@ -60,13 +59,6 @@ export const connectedAccountsCmd$Info = Command.make('info', { id }, ({ id }) =
59
60 yield* ui.note(formatConnectedAccountInfo(item), `Connected Account: ${item.toolkit.slug}`);
61
63 - const redactedId = redact({ value: item.id, prefix: 'con_' });
64 -
65 - // Next step hint
66 - yield* ui.log.step(
67 - `To delete this connected account:\n> composio dev connected-accounts delete "${redactedId}"`
68 - );
69 -
62 yield* ui.output(JSON.stringify(item, null, 2));
63 })
64 ).pipe(Command.withDescription('View details of a specific connected account.'));
ts/packages/cli/src/commands/connected-accounts/connected-accounts.cmd.ts
-2
@@ -2,7 +2,6 @@ import { Command } from '@effect/cli';
2 import { connectedAccountsCmd$List } from './commands/connected-accounts.list.cmd';
3 import { connectedAccountsCmd$Info } from './commands/connected-accounts.info.cmd';
4 import { connectedAccountsCmd$Whoami } from './commands/connected-accounts.whoami.cmd';
5 -import { connectedAccountsCmd$Delete } from './commands/connected-accounts.delete.cmd';
5 import { connectedAccountsCmd$Link } from './commands/connected-accounts.link.cmd';
6
7 /**
@@ -20,6 +19,5 @@ export const connectedAccountsCmd = Command.make('connected-accounts').pipe(
19 connectedAccountsCmd$List,
20 connectedAccountsCmd$Info,
21 connectedAccountsCmd$Whoami,
23 - connectedAccountsCmd$Delete,
22 ])
23 );
ts/packages/cli/src/commands/dev.cmd.ts
+128 -18
@@ -1,4 +1,5 @@
1 -import { Command } from '@effect/cli';
1 +import { Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 import { initCmd } from './init.cmd';
4 import { triggersCmd$Listen } from './triggers/commands/triggers.listen.cmd';
5 import { logsCmd } from './logs-cmd/logs.cmd';
@@ -7,23 +8,132 @@ import { toolkitsCmd } from './toolkits/toolkits.cmd';
8 import { authConfigsCmd } from './auth-configs/auth-configs.cmd';
9 import { connectedAccountsCmd } from './connected-accounts/connected-accounts.cmd';
10 import { triggersCmd } from './triggers/triggers.cmd';
10 -import { orgsCmd } from './orgs/orgs.cmd';
11 import { projectsCmd } from './projects/projects.cmd';
12 +import { ComposioCliUserConfig, resolveCliConfigPathSync } from 'src/services/cli-user-config';
13 +import { Stdin } from 'src/services/stdin';
14 +import { TerminalUI } from 'src/services/terminal-ui';
15 +import type { CommandVisibility } from './feature-tags';
16
13 -export const devCmd = Command.make('dev').pipe(
14 - Command.withDescription(
15 - 'Developer workflows: initialize local project context, test tool executions against playground users, inspect logs, and manage orgs, projects, toolkits, auth configs, accounts, and triggers.'
16 - ),
17 - Command.withSubcommands([
18 - initCmd,
19 - devToolsCmd$Execute,
20 - triggersCmd$Listen,
21 - logsCmd,
22 - toolkitsCmd,
23 - authConfigsCmd,
24 - connectedAccountsCmd,
25 - triggersCmd,
26 - orgsCmd,
27 - projectsCmd,
28 - ])
17 +const devMode = Options.choice('mode', ['on', 'off'] as const).pipe(
18 + Options.withDescription('Set developer mode on or off.'),
19 + Options.optional
20 );
21 +
22 +const devSubcommands = [
23 + initCmd,
24 + devToolsCmd$Execute,
25 + triggersCmd$Listen,
26 + logsCmd,
27 + toolkitsCmd,
28 + authConfigsCmd,
29 + connectedAccountsCmd,
30 + triggersCmd,
31 + projectsCmd,
32 +] as const;
33 +
34 +const describeCurrentMode = (enabled: boolean) =>
35 + enabled
36 + ? 'Developer mode is on. Developer subcommands are available.'
37 + : 'Developer mode is off. Only `composio dev --mode on|off` is available.';
38 +
39 +const applyDeveloperModeChange = (enabled: boolean) =>
40 + Effect.gen(function* () {
41 + const ui = yield* TerminalUI;
42 + const stdin = yield* Stdin;
43 + const cliConfig = yield* ComposioCliUserConfig;
44 + const current = cliConfig.isDevModeEnabled();
45 + if (enabled === current) {
46 + yield* ui.log.info(describeCurrentMode(current));
47 + return;
48 + }
49 +
50 + if (enabled) {
51 + if (!stdin.isTTY()) {
52 + yield* ui.log.error('Enabling developer mode requires an interactive terminal.');
53 + yield* ui.log.step(
54 + `Set "developer.enabled": true manually in ${resolveCliConfigPathSync()} if you really want to enable it outside an interactive session.`
55 + );
56 + return;
57 + }
58 +
59 + yield* ui.note(
60 + [
61 + 'Developer mode is for engineers building with the CLI.',
62 + '',
63 + 'It is powerful, but it unlocks more advanced commands like creating or updating auth configs and connected accounts.',
64 + ].join('\n'),
65 + 'Warning'
66 + );
67 + const confirmed = yield* ui.confirm('Enable developer mode?', { defaultValue: false });
68 + if (!confirmed) {
69 + yield* ui.outro('Aborted.');
70 + return;
71 + }
72 + }
73 +
74 + yield* cliConfig.update({
75 + developer: {
76 + ...cliConfig.raw.developer,
77 + enabled,
78 + },
79 + });
80 +
81 + yield* ui.log.success(
82 + enabled
83 + ? 'Developer mode enabled.'
84 + : 'Developer mode disabled. Only `composio dev --mode on|off` remains available.'
85 + );
86 + yield* ui.log.step(`Config updated: ${resolveCliConfigPathSync()}`);
87 + });
88 +
89 +const promptForDeveloperMode = () =>
90 + Effect.gen(function* () {
91 + const cliConfig = yield* ComposioCliUserConfig;
92 + const stdin = yield* Stdin;
93 + const ui = yield* TerminalUI;
94 + const current = cliConfig.isDevModeEnabled();
95 +
96 + if (!stdin.isTTY()) {
97 + yield* ui.log.info(describeCurrentMode(current));
98 + yield* ui.log.step('Pass `--mode on` or `--mode off` to change developer mode.');
99 + return;
100 + }
101 +
102 + const next = yield* ui.select('Developer mode', [
103 + {
104 + value: 'off' as const,
105 + label: current ? 'Turn off' : 'Keep off',
106 + hint: 'Hide developer subcommands and block developer workflows.',
107 + },
108 + {
109 + value: 'on' as const,
110 + label: current ? 'Keep on' : 'Turn on',
111 + hint: 'Show developer subcommands after an interactive warning.',
112 + },
113 + ]);
114 +
115 + if ((next === 'on') === current) {
116 + yield* ui.log.info(describeCurrentMode(current));
117 + return;
118 + }
119 +
120 + yield* applyDeveloperModeChange(next === 'on');
121 + });
122 +
123 +export const buildDevCommand = (visibility: CommandVisibility) => {
124 + const cmd = Command.make('dev', { devMode }).pipe(
125 + Command.withDescription(
126 + visibility.isDevModeEnabled
127 + ? 'Developer workflows: init, playground execution, logs, projects, toolkits, accounts, and triggers.'
128 + : 'Developer mode controls access to developer-only workflows. When off, only `composio dev --mode on|off` is available.'
129 + ),
130 + Command.withHandler(({ devMode }) =>
131 + Option.match(devMode, {
132 + onNone: () => promptForDeveloperMode(),
133 + onSome: value => applyDeveloperModeChange(value === 'on'),
134 + })
135 + )
136 + );
137 +
138 + return visibility.isDevModeEnabled ? cmd.pipe(Command.withSubcommands([...devSubcommands])) : cmd;
139 +};
ts/packages/cli/src/commands/feature-tags.ts
+1
@@ -6,6 +6,7 @@ export type TaggedValue<T> = {
6 };
7
8 export type CommandVisibility = {
9 + readonly isDevModeEnabled: boolean;
10 readonly isExperimentalFeatureEnabled: (feature: string) => boolean;
11 };
12
ts/packages/cli/src/commands/index.ts
+72 -4
@@ -14,7 +14,7 @@ import { proxyCmd } from './proxy.cmd';
14 import { artifactsCmd } from './artifacts.cmd';
15 import { installCmd } from './install.cmd';
16 import { generateCmd } from './generate/generate.cmd';
17 -import { devCmd } from './dev.cmd';
17 +import { buildDevCommand } from './dev.cmd';
18 import {
19 runParallelToolsExecuteFromArgv,
20 showToolsExecuteInputHelp,
@@ -59,7 +59,6 @@ const ROOT_COMMANDS: ReadonlyArray<TaggedValue<Command.Command<any, any, any, an
59 tagged(proxyCmd),
60 tagged(artifactsCmd),
61 tagged(installCmd),
62 - tagged(devCmd),
62 tagged(rootToolsCmd),
63 tagged(rootTriggersCmd),
64 tagged(rootToolsCmd$Search),
@@ -71,7 +70,7 @@ const ROOT_COMMANDS: ReadonlyArray<TaggedValue<Command.Command<any, any, any, an
70 ];
71
72 export const buildRootCommand = (visibility: CommandVisibility) => {
74 - const subcommands = visibleValues(ROOT_COMMANDS, visibility);
73 + const subcommands = [...visibleValues(ROOT_COMMANDS, visibility), buildDevCommand(visibility)];
74 // eslint-disable-next-line @typescript-eslint/no-explicit-any
75 return $defaultCmd.pipe(Command.withSubcommands(subcommands as any));
76 };
@@ -430,9 +429,50 @@ const isDebugWhoIsMyMaster = (argv: ReadonlyArray<string>): boolean => {
429 return args.length === 2 && args[0] === 'debug' && args[1] === 'who-is-my-master';
430 };
431
432 +const normalizeDangerouslyAllowFlag = (argv: ReadonlyArray<string>) => {
433 + const normalized: string[] = [...argv.slice(0, 2)];
434 + let dangerouslyAllow = false;
435 +
436 + for (const arg of argv.slice(2)) {
437 + if (arg === '--dangerously-allow') {
438 + dangerouslyAllow = true;
439 + continue;
440 + }
441 + normalized.push(arg);
442 + }
443 +
444 + return {
445 + argv: normalized,
446 + dangerouslyAllow,
447 + };
448 +};
449 +
450 +const isHelpRequest = (args: ReadonlyArray<string>) =>
451 + args.includes('--help') || args.includes('-h');
452 +
453 +const isDevModeOnlyInvocation = (args: ReadonlyArray<string>) => {
454 + if (args[0] !== 'dev') return false;
455 + if (isHelpRequest(args)) return true;
456 + if (args.length === 1) return true;
457 + if (args.length === 2 && (args[1] === '--mode' || args[1].startsWith('--mode='))) return true;
458 + if (args.length === 3 && args[1] === '--mode') return true;
459 + return false;
460 +};
461 +
462 +const isDangerousDevCommand = (args: ReadonlyArray<string>): boolean => {
463 + if (args[0] !== 'dev' || isHelpRequest(args)) return false;
464 +
465 + if (args[1] === 'triggers') {
466 + return args[2] === 'disable';
467 + }
468 +
469 + return false;
470 +};
471 +
472 export const runWithConfig = Effect.gen(function* () {
473 const cliUserConfig = yield* ComposioCliUserConfig;
474 const visibility: CommandVisibility = {
475 + isDevModeEnabled: cliUserConfig.isDevModeEnabled(),
476 isExperimentalFeatureEnabled: feature => cliUserConfig.isExperimentalFeatureEnabled(feature),
477 };
478 const version = yield* getVersion;
@@ -444,9 +484,12 @@ export const runWithConfig = Effect.gen(function* () {
484 });
485
486 return (argv: ReadonlyArray<string>) => {
487 + const { argv: argvWithoutDangerouslyAllow, dangerouslyAllow } =
488 + normalizeDangerouslyAllowFlag(argv);
489 const normalizedArgv = normalizeHiddenDebugFlags(
448 - normalizeListenStreamFlag(normalizeVersionShortFlag(argv))
490 + normalizeListenStreamFlag(normalizeVersionShortFlag(argvWithoutDangerouslyAllow))
491 );
492 + const args = normalizedArgv.slice(2);
493 const installSkillRequest = parseRootInstallSkillRequest(normalizedArgv);
494 if (installSkillRequest) {
495 if (installSkillRequest._tag === 'error') {
@@ -524,6 +567,31 @@ export const runWithConfig = Effect.gen(function* () {
567 if (executeHelpSlug) {
568 return showToolsExecuteInputHelp(executeHelpSlug);
569 }
570 + if (!visibility.isDevModeEnabled && args[0] === 'dev' && !isDevModeOnlyInvocation(args)) {
571 + return Effect.gen(function* () {
572 + const ui = yield* TerminalUI;
573 + yield* ui.log.error('Developer mode is off.');
574 + yield* ui.log.step('Run `composio dev --mode on` in an interactive terminal to enable it.');
575 + });
576 + }
577 + if (isDangerousDevCommand(args)) {
578 + return Effect.gen(function* () {
579 + const ui = yield* TerminalUI;
580 + if (!cliUserConfig.areDeveloperDangerousCommandsEnabled()) {
581 + yield* ui.log.error('This developer command is disabled by config.');
582 + yield* ui.log.step(
583 + 'Set `developer.destructive_actions` to `true` in `~/.composio/config.json` to allow dangerous developer commands.'
584 + );
585 + return;
586 + }
587 + if (!dangerouslyAllow) {
588 + yield* ui.log.error('This developer command requires explicit acknowledgement.');
589 + yield* ui.log.step('Re-run the command with `--dangerously-allow`.');
590 + return;
591 + }
592 + return yield* run(normalizedArgv);
593 + });
594 + }
595 return run(normalizedArgv);
596 };
597 });
ts/packages/cli/src/commands/install.cmd.ts
+1
@@ -177,6 +177,7 @@ export const installShellIntegration = (params: {
177 const mod = yield* Effect.promise(() => import('src/commands'));
178 const lines = yield* getCompletionScript(
179 mod.buildRootCommand({
180 + isDevModeEnabled: cliUserConfig.isDevModeEnabled(),
181 isExperimentalFeatureEnabled: feature =>
182 cliUserConfig.isExperimentalFeatureEnabled(feature),
183 }),
ts/packages/cli/src/commands/projects/commands/projects.list.cmd.ts
+2 -2
@@ -32,7 +32,7 @@ export const projectsCmd$List = Command.make('list', { orgId, limit }, ({ orgId,
32 const resolvedOrgId = Option.getOrUndefined(orgId) ?? Option.getOrUndefined(ctx.data.orgId);
33 if (!resolvedOrgId) {
34 yield* ui.log.warn('No default org is configured.');
35 - yield* ui.outro('Hint: run `composio dev orgs switch` first, or pass `--org-id`.');
35 + yield* ui.outro('Hint: run `composio orgs switch` first, or pass `--org-id`.');
36 return;
37 }
38
@@ -66,7 +66,7 @@ export const projectsCmd$List = Command.make('list', { orgId, limit }, ({ orgId,
66 yield* ui.outro(
67 [
68 'Hint: run `composio dev init` in a directory to bind it to a developer project.',
69 - 'Run `composio dev orgs switch` to change your default org.',
69 + 'Run `composio orgs switch` to change your default org.',
70 ].join('\n')
71 );
72
ts/packages/cli/src/commands/root-help.ts
+125 -45
@@ -149,17 +149,10 @@ const OTHER_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
149 }),
150 ];
151
152 -const DEVELOPER_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
153 - tagged({
154 - name: 'dev',
155 - description:
156 - 'Developer workflows and management: init, logs, projects, toolkits, accounts, and triggers.',
157 - }),
158 - tagged({
159 - name: 'generate',
160 - description: 'Generate type stubs for toolkits, tools, and triggers (TypeScript | Python).',
161 - }),
162 -];
152 +const GENERATE_COMMAND: TaggedValue<CompactCommand> = tagged({
153 + name: 'generate',
154 + description: 'Generate type stubs for toolkits, tools, and triggers (TypeScript | Python).',
155 +});
156
157 // ── Account commands ───────────────────────────────────────────────────
158
@@ -196,6 +189,98 @@ function renderCompactCommands(commands: ReadonlyArray<CompactCommand>): string[
189 return commands.map(cmd => ` ${cmd.name.padEnd(maxLen + 2)}${cmd.description}`);
190 }
191
192 +function renderDevHelp(visibility: CommandVisibility): string {
193 + const lines: string[] = [
194 + '',
195 + bold('USAGE'),
196 + visibility.isDevModeEnabled
197 + ? ' composio dev [--mode on|off] <command> [options]'
198 + : ' composio dev [--mode on|off]',
199 + '',
200 + bold('DESCRIPTION'),
201 + visibility.isDevModeEnabled
202 + ? ' Developer workflows for local project setup, playground execution, logs, and developer-scoped management.'
203 + : ' Developer mode is off. Only mode switching is available until you turn it back on.',
204 + '',
205 + bold('MODE'),
206 + ' --mode <on|off> Turn developer mode on or off.',
207 + '',
208 + ];
209 +
210 + if (!visibility.isDevModeEnabled) {
211 + lines.push(bold('EXAMPLES'));
212 + lines.push(' composio dev --mode on');
213 + lines.push(' composio dev --mode off');
214 + lines.push('');
215 + lines.push(bold('NOTE'));
216 + lines.push(
217 + ' Developer mode is for engineers building with the CLI. It unlocks more advanced commands like creating or updating auth configs and connected accounts.'
218 + );
219 + lines.push('');
220 + return lines.join('\n');
221 + }
222 +
223 + lines.push(bold('PROJECT'));
224 + lines.push(' dev init Initialize this directory with a developer project');
225 + lines.push('');
226 +
227 + lines.push(bold('EXECUTION'));
228 + lines.push(' dev playground-execute Execute a tool against a developer playground user');
229 + lines.push(' dev listen Listen to developer-project trigger events');
230 + lines.push(' dev logs tools Browse tool logs');
231 + lines.push(' dev logs triggers Browse trigger logs');
232 + lines.push('');
233 +
234 + lines.push(bold('TOOLKITS'));
235 + lines.push(' dev toolkits list Browse available toolkits');
236 + lines.push(' dev toolkits info Inspect a toolkit');
237 + lines.push(' dev toolkits search Search toolkits');
238 + lines.push(' dev toolkits version Inspect toolkit versions');
239 + lines.push('');
240 +
241 + lines.push(bold('AUTH CONFIGS'));
242 + lines.push(' dev auth-configs list List auth configs');
243 + lines.push(' dev auth-configs info View one auth config');
244 + lines.push(' dev auth-configs create Create an auth config');
245 + lines.push('');
246 +
247 + lines.push(bold('CONNECTED ACCOUNTS'));
248 + lines.push(' dev connected-accounts link Link a connected account');
249 + lines.push(' dev connected-accounts list List connected accounts');
250 + lines.push(' dev connected-accounts info View one connected account');
251 + lines.push(' dev connected-accounts whoami Resolve an account identity');
252 + lines.push('');
253 +
254 + lines.push(bold('TRIGGERS'));
255 + lines.push(' dev triggers list List trigger types');
256 + lines.push(' dev triggers info View one trigger type');
257 + lines.push(' dev triggers status Inspect trigger instances');
258 + lines.push(' dev triggers create Create a trigger instance');
259 + lines.push(' dev triggers enable Enable a trigger instance');
260 + lines.push(' dev triggers disable Disable a trigger instance [guarded]');
261 + lines.push('');
262 +
263 + lines.push(bold('PROJECTS'));
264 + lines.push(' dev projects list List projects');
265 + lines.push(' dev projects switch Switch default project');
266 + lines.push('');
267 +
268 + lines.push(bold('GUARDED'));
269 + lines.push(' dev triggers disable Disable a trigger instance');
270 + lines.push(
271 + ' This requires `developer.destructive_actions: true` in `~/.composio/config.json` and `--dangerously-allow` on the command line.'
272 + );
273 + lines.push('');
274 + lines.push(bold('EXAMPLES'));
275 + lines.push(' composio dev --mode off');
276 + lines.push(' composio dev toolkits list');
277 + lines.push(
278 + ' composio dev playground-execute GMAIL_SEND_EMAIL --dangerously-allow -d \'{ recipient_email: "a@b.com" }\''
279 + );
280 + lines.push('');
281 + return lines.join('\n');
282 +}
283 +
284 // ── Subcommand help definitions ────────────────────────────────────────
285
286 type SubcommandHelp = {
@@ -828,12 +913,6 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
913 { name: '--custom-credentials <text>', description: 'Custom credentials JSON' },
914 ],
915 },
831 - 'dev auth-configs delete': {
832 - usage: 'composio dev auth-configs delete [-y, --yes] [<id>]',
833 - description: 'Delete an auth config.',
834 - args: [{ name: '<id>', description: 'Auth config ID' }],
835 - flags: [{ name: '-y, --yes', description: 'Skip confirmation prompt' }],
836 - },
916 'dev connected-accounts list': {
917 usage:
918 'composio dev connected-accounts list [--toolkits text] [--user-id text] [--status text] [--limit integer]',
@@ -855,12 +934,6 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
934 description: 'Show the external account profile for a connected account.',
935 args: [{ name: '<id>', description: 'Connected account ID' }],
936 },
858 - 'dev connected-accounts delete': {
859 - usage: 'composio dev connected-accounts delete [-y, --yes] [<id>]',
860 - description: 'Delete a connected account.',
861 - args: [{ name: '<id>', description: 'Connected account ID' }],
862 - flags: [{ name: '-y, --yes', description: 'Skip confirmation prompt' }],
863 - },
937 'dev triggers list': {
938 usage: 'composio dev triggers list <toolkit> [--limit integer]',
939 description: 'List available trigger types for a toolkit.',
@@ -908,25 +981,6 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
981 description: 'Disable a trigger instance.',
982 args: [{ name: '<id>', description: 'Trigger instance ID' }],
983 },
911 - 'dev triggers delete': {
912 - usage: 'composio dev triggers delete [-y, --yes] [<id>]',
913 - description: 'Delete a trigger instance.',
914 - args: [{ name: '<id>', description: 'Trigger instance ID' }],
915 - flags: [{ name: '-y, --yes', description: 'Skip confirmation prompt' }],
916 - },
917 - 'dev orgs list': {
918 - usage: 'composio dev orgs list [--limit integer]',
919 - description: 'List organizations and show current global selection.',
920 - options: [{ name: '--limit <integer>', description: 'Number of results' }],
921 - },
922 - 'dev orgs switch': {
923 - usage: 'composio dev orgs switch [--org-id text] [--limit integer]',
924 - description: 'Switch default organization context.',
925 - options: [
926 - { name: '--org-id <text>', description: 'Organization ID to switch to' },
927 - { name: '--limit <integer>', description: 'Number of orgs to show in picker' },
928 - ],
929 - },
984 'dev projects list': {
985 usage: 'composio dev projects list [--org-id text] [--limit integer]',
986 description: 'List developer projects for the current organization.',
@@ -994,6 +1048,17 @@ const getVisibleSubcommandHelp = (
1048 cmd: string,
1049 visibility: CommandVisibility
1050 ): Option.Option<SubcommandHelp> => {
1051 + if (cmd === 'dev') {
1052 + return Option.some({
1053 + usage: 'composio dev [--mode on|off]',
1054 + description: 'Developer mode and developer-scoped workflows.',
1055 + });
1056 + }
1057 +
1058 + if (cmd.startsWith('dev ') && !visibility.isDevModeEnabled) {
1059 + return Option.none();
1060 + }
1061 +
1062 const entry = SUBCOMMAND_HELP[cmd];
1063 if (!entry) {
1064 return Option.none();
@@ -1101,6 +1166,7 @@ export function printSubcommandHelp(
1166 cmd: string,
1167 visibility: CommandVisibility
1168 ): Effect.Effect<void> {
1169 + if (cmd === 'dev') return Console.log(renderDevHelp(visibility));
1170 const help = getVisibleSubcommandHelp(cmd, visibility);
1171 if (Option.isNone(help)) return Console.log(`Unknown command: ${cmd}`);
1172 return Console.log(renderSubcommandHelp(help.value));
@@ -1127,6 +1193,7 @@ export function matchCommandFromArgv(
1193 * Get rendered help text for a command, or undefined if not found.
1194 */
1195 export function getCommandHelpText(cmd: string, visibility: CommandVisibility): string | undefined {
1196 + if (cmd === 'dev') return renderDevHelp(visibility);
1197 return Option.match(getVisibleSubcommandHelp(cmd, visibility), {
1198 onNone: () => undefined,
1199 onSome: help => renderSubcommandHelp(help),
@@ -1142,6 +1209,15 @@ export function getCommandHelpText(cmd: string, visibility: CommandVisibility):
1209 */
1210 export function printRootHelp(visibility: CommandVisibility): Effect.Effect<void> {
1211 const name = 'composio';
1212 + const developerCommands: ReadonlyArray<CompactCommand> = [
1213 + {
1214 + name: 'dev',
1215 + description: visibility.isDevModeEnabled
1216 + ? 'Developer workflows and management: init, logs, projects, toolkits, accounts, and triggers.'
1217 + : 'Developer mode toggle. Use `composio dev --mode on` to enable developer workflows.',
1218 + },
1219 + GENERATE_COMMAND.value,
1220 + ];
1221
1222 const lines: string[] = [
1223 '',
@@ -1150,8 +1226,12 @@ export function printRootHelp(visibility: CommandVisibility): Effect.Effect<void
1226 `Try ${bold('execute')} sooner than you'd think — it validates inputs, checks connections, and tells`,
1227 'you what to fix.',
1228 '',
1153 - `Use ${bold('dev')} when you are building an agent with Composio's SDK and want scaffolding,`,
1154 - 'playground execution, logs, and developer-scoped management commands.',
1229 + visibility.isDevModeEnabled
1230 + ? `Use ${bold('dev')} when you are building an agent with Composio's SDK and want scaffolding,`
1231 + : `Use ${bold('dev')} to control access to developer-only workflows.`,
1232 + visibility.isDevModeEnabled
1233 + ? 'playground execution, logs, and developer-scoped management commands.'
1234 + : 'Developer mode is currently off.',
1235 '',
1236 bold('USAGE'),
1237 ` ${name} <command> [options]`,
@@ -1199,7 +1279,7 @@ export function printRootHelp(visibility: CommandVisibility): Effect.Effect<void
1279 ` '`,
1280 '',
1281 bold('DEVELOPER COMMANDS'),
1202 - ...renderCompactCommands(visibleValues(DEVELOPER_COMMANDS, visibility)),
1282 + ...renderCompactCommands(developerCommands),
1283 '',
1284 bold('ACCOUNT'),
1285 ...renderCompactCommands(visibleValues(ACCOUNT_COMMANDS, visibility)),
ts/packages/cli/src/commands/triggers/commands/triggers.delete.cmd.ts deleted
-67
@@ -1,67 +0,0 @@
1 -import { Args, Command, Options } from '@effect/cli';
2 -import { Effect, Option } from 'effect';
3 -import { requireAuth } from 'src/effects/require-auth';
4 -import { handleHttpServerError } from 'src/effects/handle-http-error';
5 -import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 -import { TerminalUI } from 'src/services/terminal-ui';
7 -
8 -const id = Args.text({ name: 'id' }).pipe(
9 - Args.withDescription('Trigger instance ID'),
10 - Args.optional
11 -);
12 -
13 -const yes = Options.boolean('yes').pipe(
14 - Options.withAlias('y'),
15 - Options.withDescription('Skip confirmation prompt'),
16 - Options.withDefault(false)
17 -);
18 -
19 -/**
20 - * Delete a trigger instance.
21 - */
22 -export const triggersCmd$Delete = Command.make('delete', { id, yes }, ({ id, yes }) =>
23 - Effect.gen(function* () {
24 - if (!(yield* requireAuth)) return;
25 -
26 - const ui = yield* TerminalUI;
27 - const repo = yield* ComposioToolkitsRepository;
28 -
29 - if (Option.isNone(id)) {
30 - yield* ui.log.warn('Missing required argument: <id>');
31 - yield* ui.log.step(
32 - 'Try specifying a trigger ID, e.g.:\n> composio dev triggers delete "trg_123" --yes\n\nTo find trigger IDs:\n> composio dev triggers status --show-disabled'
33 - );
34 - return;
35 - }
36 -
37 - const idValue = id.value;
38 -
39 - if (!yes) {
40 - const confirmed = yield* ui.confirm(`Delete trigger "${idValue}"? This cannot be undone.`, {
41 - defaultValue: false,
42 - });
43 - if (!confirmed) {
44 - yield* ui.log.warn('Deletion cancelled.');
45 - return;
46 - }
47 - }
48 -
49 - const deleted = yield* ui
50 - .withSpinner(`Deleting trigger "${idValue}"...`, repo.deleteTrigger(idValue))
51 - .pipe(
52 - Effect.as(true),
53 - Effect.catchTag(
54 - 'services/HttpServerError',
55 - handleHttpServerError(ui, {
56 - fallbackMessage: `Failed to delete trigger "${idValue}".`,
57 - hint: 'Browse available triggers:\n> composio dev triggers status --show-disabled',
58 - fallbackValue: false,
59 - })
60 - )
61 - );
62 -
63 - if (!deleted) return;
64 -
65 - yield* ui.log.success(`Trigger "${idValue}" deleted.`);
66 - })
67 -).pipe(Command.withDescription('Delete a trigger instance.'));
ts/packages/cli/src/commands/triggers/triggers.cmd.ts
-2
@@ -5,7 +5,6 @@ import { triggersCmd$Status } from './commands/triggers.status.cmd';
5 import { triggersCmd$Create } from './commands/triggers.create.cmd';
6 import { triggersCmd$Enable } from './commands/triggers.enable.cmd';
7 import { triggersCmd$Disable } from './commands/triggers.disable.cmd';
8 -import { triggersCmd$Delete } from './commands/triggers.delete.cmd';
8 import { triggersCmd$Listen } from './commands/triggers.listen.cmd';
9
10 /**
@@ -26,6 +25,5 @@ export const triggersCmd = Command.make('triggers').pipe(
25 triggersCmd$Create,
26 triggersCmd$Enable,
27 triggersCmd$Disable,
29 - triggersCmd$Delete,
28 ])
29 );
ts/packages/cli/src/models/cli-user-config.ts
+17
@@ -11,7 +11,24 @@ export const ExperimentalFeatures = Schema.Record({
11 });
12 export type ExperimentalFeatures = Schema.Schema.Type<typeof ExperimentalFeatures>;
13
14 +export const DeveloperConfig = Schema.Struct({
15 + enabled: Schema.optionalWith(Schema.Boolean, {
16 + default: () => true,
17 + }),
18 + destructiveActions: Schema.optionalWith(Schema.Boolean, {
19 + default: () => false,
20 + }).pipe(Schema.fromKey('destructive_actions')),
21 +});
22 +export type DeveloperConfig = Schema.Schema.Type<typeof DeveloperConfig>;
23 +
24 export const CliUserConfig = Schema.Struct({
25 + developer: Schema.optionalWith(DeveloperConfig, {
26 + default: () =>
27 + DeveloperConfig.make({
28 + enabled: true,
29 + destructiveActions: false,
30 + }),
31 + }),
32 experimentalFeatures: Schema.optionalWith(ExperimentalFeatures, {
33 default: () => ({}),
34 }).pipe(Schema.fromKey('experimental_features')),
ts/packages/cli/src/services/cli-user-config.ts
+48 -1
@@ -17,6 +17,8 @@ import type { CliReleaseChannel } from 'src/constants';
17
18 export type CliUserConfigResolved = {
19 readonly channel: CliReleaseChannel;
20 + readonly developerModeEnabled: boolean;
21 + readonly developerDangerousCommandsEnabled: boolean;
22 readonly experimentalFeatures: Readonly<Record<string, boolean>>;
23 readonly artifactDirectory: string | undefined;
24 readonly experimentalSubagentTarget: 'auto' | 'claude' | 'codex';
@@ -37,6 +39,8 @@ export class ComposioCliUserConfig extends Context.Tag('ComposioCliUserConfig')<
39 readonly data: CliUserConfigResolved;
40 readonly raw: CliUserConfig;
41 readonly channel: CliReleaseChannel;
42 + readonly isDevModeEnabled: () => boolean;
43 + readonly areDeveloperDangerousCommandsEnabled: () => boolean;
44 readonly isExperimentalFeatureEnabled: (feature: string) => boolean;
45 readonly update: (
46 next: Partial<CliUserConfig>
@@ -46,6 +50,8 @@ export class ComposioCliUserConfig extends Context.Tag('ComposioCliUserConfig')<
50
51 const resolveConfig = (raw: CliUserConfig, channel: CliReleaseChannel): CliUserConfigResolved => ({
52 channel,
53 + developerModeEnabled: raw.developer.enabled,
54 + developerDangerousCommandsEnabled: raw.developer.destructiveActions,
55 experimentalFeatures: raw.experimentalFeatures,
56 artifactDirectory: Option.getOrUndefined(raw.artifactDirectory),
57 experimentalSubagentTarget: Option.match(raw.experimentalSubagent, {
@@ -64,11 +70,43 @@ export const ComposioCliUserConfigLive = Layer.effect(
70 const jsonConfigPath = path.join(configDir, constants.CLI_CONFIG_FILE_NAME);
71
72 let rawConfig = CliUserConfig.make({
73 + developer: {
74 + enabled: true,
75 + destructiveActions: false,
76 + },
77 experimentalFeatures: {},
78 artifactDirectory: Option.none(),
79 experimentalSubagent: Option.none(),
80 });
81
82 + const normalizeRawConfigJson = (value: unknown): unknown => {
83 + if (!value || typeof value !== 'object' || Array.isArray(value)) {
84 + return value;
85 + }
86 +
87 + const record = { ...(value as Record<string, unknown>) };
88 + const existingDeveloper =
89 + record.developer && typeof record.developer === 'object' && !Array.isArray(record.developer)
90 + ? { ...(record.developer as Record<string, unknown>) }
91 + : {};
92 +
93 + if (!('enabled' in existingDeveloper) && 'developer_mode_enabled' in record) {
94 + existingDeveloper.enabled = record.developer_mode_enabled;
95 + }
96 + if (
97 + !('destructive_actions' in existingDeveloper) &&
98 + 'developer_dangerous_commands_enabled' in record
99 + ) {
100 + existingDeveloper.destructive_actions = record.developer_dangerous_commands_enabled;
101 + }
102 +
103 + delete record.developer_mode_enabled;
104 + delete record.developer_dangerous_commands_enabled;
105 +
106 + record.developer = existingDeveloper;
107 + return record;
108 + };
109 +
110 const persist = (next: CliUserConfig) =>
111 Effect.gen(function* () {
112 const encoded = yield* cliUserConfigToJSON(next);
@@ -88,7 +126,9 @@ export const ComposioCliUserConfigLive = Layer.effect(
126
127 const load = Effect.gen(function* () {
128 const configJson = yield* fs.readFileString(jsonConfigPath, 'utf8');
91 - rawConfig = yield* cliUserConfigFromJSON(configJson);
129 + rawConfig = yield* cliUserConfigFromJSON(
130 + JSON.stringify(normalizeRawConfigJson(JSON.parse(configJson)))
131 + );
132 return rawConfig;
133 });
134
@@ -97,6 +137,10 @@ export const ComposioCliUserConfigLive = Layer.effect(
137 Effect.catchAll(() =>
138 persist(
139 CliUserConfig.make({
140 + developer: {
141 + enabled: true,
142 + destructiveActions: false,
143 + },
144 experimentalFeatures: {},
145 artifactDirectory: Option.none(),
146 experimentalSubagent: Option.none(),
@@ -121,6 +165,9 @@ export const ComposioCliUserConfigLive = Layer.effect(
165 return rawConfig;
166 },
167 channel,
168 + isDevModeEnabled: () => resolveConfig(rawConfig, channel).developerModeEnabled,
169 + areDeveloperDangerousCommandsEnabled: () =>
170 + resolveConfig(rawConfig, channel).developerDangerousCommandsEnabled,
171 isExperimentalFeatureEnabled,
172 update,
173 });
ts/packages/cli/test/__utils__/services/test-layer.ts
+39 -12
@@ -125,6 +125,12 @@ export interface TestLiveInput {
125 events?: ReadonlyArray<Record<string, unknown>>;
126 };
127
128 + cliUserConfig?: {
129 + developerModeEnabled?: boolean;
130 + developerDangerousCommandsEnabled?: boolean;
131 + experimentalFeatures?: Record<string, boolean>;
132 + };
133 +
134 /**
135 * Mock stdin for commands that read input.
136 */
@@ -802,23 +808,44 @@ export const TestLayer = (input?: TestLiveInput) =>
808 Layer.merge(BunFileSystem.layer, NodeOsTest)
809 );
810
811 + let rawCliUserConfig = CliUserConfig.make({
812 + developer: {
813 + enabled: input?.cliUserConfig?.developerModeEnabled ?? true,
814 + destructiveActions: input?.cliUserConfig?.developerDangerousCommandsEnabled ?? false,
815 + },
816 + experimentalFeatures: input?.cliUserConfig?.experimentalFeatures ?? {},
817 + artifactDirectory: Option.none(),
818 + experimentalSubagent: Option.none(),
819 + });
820 +
821 const ComposioCliUserConfigTest = Layer.succeed(
822 ComposioCliUserConfig,
823 ComposioCliUserConfig.of({
808 - data: {
809 - channel: 'beta',
810 - experimentalFeatures: {},
811 - artifactDirectory: undefined,
812 - experimentalSubagentTarget: 'auto',
824 + get data() {
825 + return {
826 + channel: 'beta' as const,
827 + developerModeEnabled: rawCliUserConfig.developer.enabled,
828 + developerDangerousCommandsEnabled: rawCliUserConfig.developer.destructiveActions,
829 + experimentalFeatures: rawCliUserConfig.experimentalFeatures,
830 + artifactDirectory: undefined,
831 + experimentalSubagentTarget: 'auto' as const,
832 + };
833 + },
834 + get raw() {
835 + return rawCliUserConfig;
836 },
814 - raw: CliUserConfig.make({
815 - experimentalFeatures: {},
816 - artifactDirectory: Option.none(),
817 - experimentalSubagent: Option.none(),
818 - }),
837 channel: 'beta',
820 - isExperimentalFeatureEnabled: () => true,
821 - update: () => Effect.void,
838 + isDevModeEnabled: () => rawCliUserConfig.developer.enabled,
839 + areDeveloperDangerousCommandsEnabled: () => rawCliUserConfig.developer.destructiveActions,
840 + isExperimentalFeatureEnabled: feature =>
841 + rawCliUserConfig.experimentalFeatures[feature] ?? true,
842 + update: next =>
843 + Effect.sync(() => {
844 + rawCliUserConfig = CliUserConfig.make({
845 + ...rawCliUserConfig,
846 + ...next,
847 + });
848 + }),
849 })
850 );
851
ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
+60 -19
@@ -8,13 +8,26 @@ const testConfigProvider = ConfigProvider.fromMap(
8 new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
9 ).pipe(extendConfigProvider);
10
11 +const dangerousDevConfig = {
12 + cliUserConfig: {
13 + developerDangerousCommandsEnabled: true,
14 + },
15 +} satisfies TestLiveInput;
16 +
17 describe('CLI: composio dev auth-configs create', () => {
12 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
18 + layer(TestLive({ baseConfigProvider: testConfigProvider, ...dangerousDevConfig }))(
19 '[Given] --toolkit "gmail" [Then] creates with Composio managed auth',
20 it => {
21 it.scoped('creates successfully', () =>
22 Effect.gen(function* () {
17 - yield* cli(['dev', 'auth-configs', 'create', '--toolkit', 'gmail']);
23 + yield* cli([
24 + 'dev',
25 + 'auth-configs',
26 + 'create',
27 + '--toolkit',
28 + 'gmail',
29 + '--dangerously-allow',
30 + ]);
31 const lines = yield* MockConsole.getLines({ stripAnsi: true });
32 const output = lines.join('\n');
33
@@ -26,12 +39,20 @@ describe('CLI: composio dev auth-configs create', () => {
39 }
40 );
41
29 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
42 + layer(TestLive({ baseConfigProvider: testConfigProvider, ...dangerousDevConfig }))(
43 '[Given] named config --toolkit "gmail" [Then] creates with name',
44 it => {
45 it.scoped('creates with name successfully', () =>
46 Effect.gen(function* () {
34 - yield* cli(['dev', 'auth-configs', 'create', 'my-config', '--toolkit', 'gmail']);
47 + yield* cli([
48 + 'dev',
49 + 'auth-configs',
50 + 'create',
51 + 'my-config',
52 + '--toolkit',
53 + 'gmail',
54 + '--dangerously-allow',
55 + ]);
56 const lines = yield* MockConsole.getLines({ stripAnsi: true });
57 const output = lines.join('\n');
58
@@ -42,7 +63,7 @@ describe('CLI: composio dev auth-configs create', () => {
63 }
64 );
65
45 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
66 + layer(TestLive({ baseConfigProvider: testConfigProvider, ...dangerousDevConfig }))(
67 '[Given] --auth-scheme "OAUTH2" [Then] creates with custom auth',
68 it => {
69 it.scoped('creates with custom auth scheme', () =>
@@ -55,6 +76,7 @@ describe('CLI: composio dev auth-configs create', () => {
76 'gmail',
77 '--auth-scheme',
78 'OAUTH2',
79 + '--dangerously-allow',
80 ]);
81 const lines = yield* MockConsole.getLines({ stripAnsi: true });
82 const output = lines.join('\n');
@@ -68,6 +90,7 @@ describe('CLI: composio dev auth-configs create', () => {
90 layer(
91 TestLive({
92 baseConfigProvider: testConfigProvider,
93 + ...dangerousDevConfig,
94 authConfigsData: {
95 createResponse: {
96 auth_config: { id: 'ac_custom', auth_scheme: 'API_KEY', is_composio_managed: false },
@@ -78,7 +101,7 @@ describe('CLI: composio dev auth-configs create', () => {
101 )('[Given] custom create response [Then] shows correct details', it => {
102 it.scoped('shows custom response data', () =>
103 Effect.gen(function* () {
81 - yield* cli(['dev', 'auth-configs', 'create', '--toolkit', 'slack']);
104 + yield* cli(['dev', 'auth-configs', 'create', '--toolkit', 'slack', '--dangerously-allow']);
105 const lines = yield* MockConsole.getLines({ stripAnsi: true });
106 const output = lines.join('\n');
107
@@ -89,7 +112,7 @@ describe('CLI: composio dev auth-configs create', () => {
112 );
113 });
114
92 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
115 + layer(TestLive({ baseConfigProvider: testConfigProvider, ...dangerousDevConfig }))(
116 '[Given] invalid JSON in --custom-credentials [Then] shows error',
117 it => {
118 it.scoped('shows JSON parse error', () =>
@@ -104,6 +127,7 @@ describe('CLI: composio dev auth-configs create', () => {
127 'OAUTH2',
128 '--custom-credentials',
129 '{invalid json}',
130 + '--dangerously-allow',
131 ]);
132 const lines = yield* MockConsole.getLines({ stripAnsi: true });
133 const output = lines.join('\n');
@@ -114,24 +138,41 @@ describe('CLI: composio dev auth-configs create', () => {
138 }
139 );
140
117 - layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
118 - it.scoped('warns user to login', () =>
119 - Effect.gen(function* () {
120 - yield* cli(['dev', 'auth-configs', 'create', '--toolkit', 'gmail']);
121 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
122 - const output = lines.join('\n');
141 + layer(TestLive({ ...dangerousDevConfig }))(
142 + '[Given] no API key [Then] warns user to login',
143 + it => {
144 + it.scoped('warns user to login', () =>
145 + Effect.gen(function* () {
146 + yield* cli([
147 + 'dev',
148 + 'auth-configs',
149 + 'create',
150 + '--toolkit',
151 + 'gmail',
152 + '--dangerously-allow',
153 + ]);
154 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
155 + const output = lines.join('\n');
156
124 - expect(output).toContain('not logged in');
125 - })
126 - );
127 - });
157 + expect(output).toContain('not logged in');
158 + })
159 + );
160 + }
161 + );
162
129 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
163 + layer(TestLive({ baseConfigProvider: testConfigProvider, ...dangerousDevConfig }))(
164 '[Given] next step hint [Then] includes auth config ID',
165 it => {
166 it.scoped('shows next step hint', () =>
167 Effect.gen(function* () {
134 - yield* cli(['dev', 'auth-configs', 'create', '--toolkit', 'gmail']);
168 + yield* cli([
169 + 'dev',
170 + 'auth-configs',
171 + 'create',
172 + '--toolkit',
173 + 'gmail',
174 + '--dangerously-allow',
175 + ]);
176 const lines = yield* MockConsole.getLines({ stripAnsi: true });
177 const output = lines.join('\n');
178
ts/packages/cli/test/src/commands/auth-configs/auth-configs.delete.cmd.test.ts deleted
-91
@@ -1,91 +0,0 @@
1 -import { describe, expect, layer } from '@effect/vitest';
2 -import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
4 -import { cli, TestLive, MockConsole } from 'test/__utils__';
5 -import type { TestLiveInput } from 'test/__utils__/services/test-layer';
6 -import type { AuthConfigItem } from 'src/models/auth-configs';
7 -
8 -const testAuthConfigs: AuthConfigItem[] = [
9 - {
10 - id: 'ac_gmail_default',
11 - name: 'Gmail Default',
12 - no_of_connections: 5,
13 - status: 'ENABLED',
14 - type: 'default',
15 - uuid: 'uuid-1',
16 - toolkit: { logo: '', slug: 'gmail' },
17 - auth_scheme: 'OAUTH2',
18 - is_composio_managed: true,
19 - is_enabled_for_tool_router: true,
20 - created_at: '2026-01-01T00:00:00Z',
21 - },
22 -];
23 -
24 -const authConfigsData = {
25 - items: testAuthConfigs,
26 -} satisfies TestLiveInput['authConfigsData'];
27 -
28 -const testConfigProvider = ConfigProvider.fromMap(
29 - new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
30 -).pipe(extendConfigProvider);
31 -
32 -describe('CLI: composio dev auth-configs delete', () => {
33 - layer(TestLive({ baseConfigProvider: testConfigProvider, authConfigsData }))(
34 - '[Given] valid ID with --yes [Then] deletes successfully',
35 - it => {
36 - it.scoped('shows success message', () =>
37 - Effect.gen(function* () {
38 - yield* cli(['dev', 'auth-configs', 'delete', 'ac_gmail_default', '--yes']);
39 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
40 - const output = lines.join('\n');
41 -
42 - expect(output).toContain('ac_gmail_default');
43 - expect(output).toContain('deleted');
44 - })
45 - );
46 - }
47 - );
48 -
49 - layer(TestLive({ baseConfigProvider: testConfigProvider, authConfigsData }))(
50 - '[Given] no ID [Then] warns missing argument',
51 - it => {
52 - it.scoped('shows missing argument warning', () =>
53 - Effect.gen(function* () {
54 - yield* cli(['dev', 'auth-configs', 'delete']);
55 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
56 - const output = lines.join('\n');
57 -
58 - expect(output).toContain('Missing required argument');
59 - })
60 - );
61 - }
62 - );
63 -
64 - layer(TestLive({ baseConfigProvider: testConfigProvider, authConfigsData }))(
65 - '[Given] invalid ID with --yes [Then] shows error',
66 - it => {
67 - it.scoped('shows not found error', () =>
68 - Effect.gen(function* () {
69 - yield* cli(['dev', 'auth-configs', 'delete', 'ac_nonexistent', '--yes']);
70 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
71 - const output = lines.join('\n');
72 -
73 - expect(output).toContain('not found');
74 - expect(output).toContain('composio dev auth-configs list');
75 - })
76 - );
77 - }
78 - );
79 -
80 - layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
81 - it.scoped('warns user to login', () =>
82 - Effect.gen(function* () {
83 - yield* cli(['dev', 'auth-configs', 'delete', 'ac_gmail_default', '--yes']);
84 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
85 - const output = lines.join('\n');
86 -
87 - expect(output).toContain('not logged in');
88 - })
89 - );
90 - });
91 -});
ts/packages/cli/test/src/commands/auth-configs/auth-configs.info.cmd.test.ts
-2
@@ -45,8 +45,6 @@ describe('CLI: composio dev auth-configs info', () => {
45 expect(output).toContain('OAUTH2');
46 expect(output).toContain('ENABLED');
47 expect(output).toContain('Yes'); // is_composio_managed
48 - // Next step hint
49 - expect(output).toContain('composio dev auth-configs delete');
48 })
49 );
50 }
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.delete.cmd.test.ts deleted
-95
@@ -1,95 +0,0 @@
1 -import { describe, expect, layer } from '@effect/vitest';
2 -import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
4 -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 -
8 -const testConnectedAccounts: ConnectedAccountItem[] = [
9 - {
10 - id: 'con_gmail_active',
11 - status: 'ACTIVE',
12 - status_reason: null,
13 - is_disabled: false,
14 - user_id: 'default',
15 - toolkit: { slug: 'gmail' },
16 - auth_config: {
17 - id: 'ac_gmail_oauth',
18 - auth_scheme: 'OAUTH2',
19 - is_composio_managed: true,
20 - is_disabled: false,
21 - },
22 - created_at: '2026-01-01T00:00:00Z',
23 - updated_at: '2026-01-15T00:00:00Z',
24 - test_request_endpoint: '',
25 - },
26 -];
27 -
28 -const connectedAccountsData = {
29 - items: testConnectedAccounts,
30 -} satisfies TestLiveInput['connectedAccountsData'];
31 -
32 -const testConfigProvider = ConfigProvider.fromMap(
33 - new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
34 -).pipe(extendConfigProvider);
35 -
36 -describe('CLI: composio dev connected-accounts delete', () => {
37 - layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(
38 - '[Given] valid ID with --yes [Then] deletes successfully',
39 - it => {
40 - it.scoped('deletes the connected account', () =>
41 - Effect.gen(function* () {
42 - yield* cli(['dev', 'connected-accounts', 'delete', 'con_gmail_active', '--yes']);
43 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
44 - const output = lines.join('\n');
45 -
46 - expect(output).toContain('deleted');
47 - })
48 - );
49 - }
50 - );
51 -
52 - layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(
53 - '[Given] nonexistent ID with --yes [Then] shows error with hint',
54 - it => {
55 - it.scoped('shows error for nonexistent account', () =>
56 - Effect.gen(function* () {
57 - yield* cli(['dev', 'connected-accounts', 'delete', 'con_nonexistent', '--yes']);
58 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
59 - const output = lines.join('\n');
60 -
61 - expect(output).toContain('not found');
62 - expect(output).toContain('composio dev connected-accounts list');
63 - })
64 - );
65 - }
66 - );
67 -
68 - layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(
69 - '[Given] no ID argument [Then] shows missing argument warning',
70 - it => {
71 - it.scoped('warns about missing argument', () =>
72 - Effect.gen(function* () {
73 - yield* cli(['dev', 'connected-accounts', 'delete']);
74 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
75 - const output = lines.join('\n');
76 -
77 - expect(output).toContain('Missing required argument');
78 - expect(output).toContain('composio dev connected-accounts delete');
79 - })
80 - );
81 - }
82 - );
83 -
84 - layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
85 - it.scoped('warns user to login', () =>
86 - Effect.gen(function* () {
87 - yield* cli(['dev', 'connected-accounts', 'delete', 'con_gmail_active', '--yes']);
88 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
89 - const output = lines.join('\n');
90 -
91 - expect(output).toContain('not logged in');
92 - })
93 - );
94 - });
95 -});
ts/packages/cli/test/src/commands/dev.cmd.test.ts new
+93
@@ -0,0 +1,93 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import { extendConfigProvider } from 'src/services/config';
4 +import { cli, MockConsole, TestLive } from 'test/__utils__';
5 +
6 +const testConfigProvider = ConfigProvider.fromMap(
7 + new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
8 +).pipe(extendConfigProvider);
9 +
10 +describe('CLI: composio dev', () => {
11 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
12 + it.scoped('renders custom help when developer mode is on', () =>
13 + Effect.gen(function* () {
14 + yield* cli(['dev', '--help']);
15 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
16 +
17 + expect(output).toContain('PROJECT');
18 + expect(output).toContain('GUARDED');
19 + expect(output).toContain('--mode <on|off>');
20 + })
21 + );
22 + });
23 +
24 + layer(
25 + TestLive({
26 + baseConfigProvider: testConfigProvider,
27 + cliUserConfig: { developerModeEnabled: false },
28 + })
29 + )(it => {
30 + it.scoped('renders reduced help when developer mode is off', () =>
31 + Effect.gen(function* () {
32 + yield* cli(['dev', '--help']);
33 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
34 +
35 + expect(output).toContain('Developer mode is off');
36 + expect(output).toContain('composio dev --mode on');
37 + expect(output).not.toContain('PROJECT');
38 + })
39 + );
40 +
41 + it.scoped('blocks dev subcommands when developer mode is off', () =>
42 + Effect.gen(function* () {
43 + yield* cli(['dev', 'init']);
44 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
45 +
46 + expect(output).toContain('Developer mode is off');
47 + expect(output).toContain('composio dev --mode on');
48 + })
49 + );
50 + });
51 +
52 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
53 + it.scoped('persists mode changes through the config service', () =>
54 + Effect.gen(function* () {
55 + yield* cli(['dev', '--mode', 'off']);
56 + yield* cli(['dev', 'init']);
57 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
58 +
59 + expect(output).toContain('Developer mode disabled');
60 + expect(output).toContain('Developer mode is off');
61 + })
62 + );
63 + });
64 +
65 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
66 + it.scoped('blocks destructive dev commands until config enables them', () =>
67 + Effect.gen(function* () {
68 + yield* cli(['dev', 'triggers', 'disable', 'trg_123']);
69 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
70 +
71 + expect(output).toContain('disabled by config');
72 + expect(output).toContain('developer.destructive_actions');
73 + })
74 + );
75 + });
76 +
77 + layer(
78 + TestLive({
79 + baseConfigProvider: testConfigProvider,
80 + cliUserConfig: { developerDangerousCommandsEnabled: true },
81 + })
82 + )(it => {
83 + it.scoped('requires --dangerously-allow for destructive dev commands', () =>
84 + Effect.gen(function* () {
85 + yield* cli(['dev', 'triggers', 'disable', 'trg_123']);
86 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
87 +
88 + expect(output).toContain('requires explicit acknowledgement');
89 + expect(output).toContain('--dangerously-allow');
90 + })
91 + );
92 + });
93 +});
ts/packages/cli/test/src/commands/feature-visibility.test.ts
+2
@@ -9,10 +9,12 @@ import {
9 } from 'src/commands/root-help';
10
11 const stableVisibility = {
12 + isDevModeEnabled: true,
13 isExperimentalFeatureEnabled: () => false,
14 };
15
16 const betaVisibility = {
17 + isDevModeEnabled: true,
18 isExperimentalFeatureEnabled: () => true,
19 };
20
ts/packages/cli/test/src/commands/orgs/orgs.list.cmd.test.ts deleted
-48
@@ -1,48 +0,0 @@
1 -import { Effect } from 'effect';
2 -import { describe, expect, layer } from '@effect/vitest';
3 -import { afterEach, vi } from 'vitest';
4 -import { cli, MockConsole, TestLive } from 'test/__utils__';
5 -
6 -const mockFetchResponse = (body: unknown, status = 200) =>
7 - new Response(JSON.stringify(body), {
8 - status,
9 - headers: { 'Content-Type': 'application/json' },
10 - });
11 -
12 -describe('CLI: composio dev orgs list', () => {
13 - afterEach(() => {
14 - vi.restoreAllMocks();
15 - });
16 -
17 - layer(TestLive({ fixture: 'user-config-with-global-context' }))(it => {
18 - it.scoped('[Then] lists orgs, marks selected global org, and shows switch hint', () =>
19 - Effect.gen(function* () {
20 - const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
21 - mockFetchResponse({
22 - organizations: [
23 - { id: 'org_1', name: 'Org One' },
24 - { id: 'org_2', name: 'Org Two' },
25 - ],
26 - })
27 - );
28 -
29 - yield* cli(['dev', 'orgs', 'list']);
30 -
31 - expect(fetchSpy).toHaveBeenCalledTimes(1);
32 - const [orgUrl, orgRequest] = fetchSpy.mock.calls[0]!;
33 - expect(orgUrl).toContain('/api/v3/org/list?limit=50');
34 - expect((orgRequest as RequestInit).headers).toMatchObject({
35 - 'x-user-api-key': 'uak_test_key',
36 - });
37 -
38 - const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
39 - expect(output).toContain('Loaded 2 orgs');
40 - expect(output).toContain('✓ Org One (org_1)');
41 - expect(output).toContain(' Org Two (org_2)');
42 - expect(output).toContain(
43 - 'Hint: run `composio dev orgs switch` to switch the default global org/project.'
44 - );
45 - })
46 - );
47 - });
48 -});
ts/packages/cli/test/src/commands/orgs/orgs.switch.cmd.test.ts deleted
-81
@@ -1,81 +0,0 @@
1 -import path from 'node:path';
2 -import { ConfigProvider, Effect } from 'effect';
3 -import { describe, expect, layer } from '@effect/vitest';
4 -import { afterEach, vi } from 'vitest';
5 -import { FileSystem } from '@effect/platform';
6 -import { cli, MockConsole, TestLive } from 'test/__utils__';
7 -import * as constants from 'src/constants';
8 -import { setupCacheDir } from 'src/effects/setup-cache-dir';
9 -
10 -const testConfigProvider = ConfigProvider.fromMap(
11 - new Map([
12 - ['COMPOSIO_USER_API_KEY', 'uak_test_key'],
13 - ['USER_API_KEY', 'uak_test_key'],
14 - ])
15 -);
16 -
17 -const mockFetchResponse = (body: unknown, status = 200) =>
18 - new Response(JSON.stringify(body), {
19 - status,
20 - headers: { 'Content-Type': 'application/json' },
21 - });
22 -
23 -describe('CLI: composio dev orgs switch', () => {
24 - afterEach(() => {
25 - vi.restoreAllMocks();
26 - });
27 -
28 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
29 - it.scoped(
30 - '[When] no --org-id is provided [Then] lists orgs with limit=50 and stores org only',
31 - () =>
32 - Effect.gen(function* () {
33 - const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(
34 - mockFetchResponse({
35 - organizations: [{ id: 'org_1', name: 'Org One' }],
36 - })
37 - );
38 -
39 - yield* cli(['dev', 'orgs', 'switch']);
40 -
41 - expect(fetchSpy).toHaveBeenCalledTimes(1);
42 - const [orgUrl, orgRequest] = fetchSpy.mock.calls[0]!;
43 - expect(orgUrl).toContain('/api/v3/org/list?limit=50');
44 - expect((orgRequest as RequestInit).headers).toMatchObject({
45 - 'x-user-api-key': 'uak_test_key',
46 - });
47 -
48 - const fs = yield* FileSystem.FileSystem;
49 - const cacheDir = yield* setupCacheDir;
50 - const userConfigPath = path.join(cacheDir, constants.USER_CONFIG_FILE_NAME);
51 - const rawUserConfig = yield* fs.readFileString(userConfigPath, 'utf8');
52 - const userConfig = JSON.parse(rawUserConfig) as Record<string, unknown>;
53 - expect(userConfig.org_id).toBe('org_1');
54 - expect(userConfig.project_id).toBeUndefined();
55 -
56 - const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
57 - expect(output).toContain('Updated default org');
58 - })
59 - );
60 - });
61 -
62 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
63 - it.scoped('[When] --org-id is provided [Then] skips org list and stores org only', () =>
64 - Effect.gen(function* () {
65 - const fetchSpy = vi.spyOn(globalThis, 'fetch');
66 -
67 - yield* cli(['dev', 'orgs', 'switch', '--org-id', 'org_manual']);
68 -
69 - expect(fetchSpy).toHaveBeenCalledTimes(0);
70 -
71 - const fs = yield* FileSystem.FileSystem;
72 - const cacheDir = yield* setupCacheDir;
73 - const userConfigPath = path.join(cacheDir, constants.USER_CONFIG_FILE_NAME);
74 - const rawUserConfig = yield* fs.readFileString(userConfigPath, 'utf8');
75 - const userConfig = JSON.parse(rawUserConfig) as Record<string, unknown>;
76 - expect(userConfig.org_id).toBe('org_manual');
77 - expect(userConfig.project_id).toBeUndefined();
78 - })
79 - );
80 - });
81 -});
ts/packages/cli/test/src/commands/projects/projects.list.cmd.test.ts
+1 -1
@@ -43,7 +43,7 @@ describe('CLI: composio dev projects list', () => {
43 expect(output).toContain(
44 'Hint: run `composio dev init` in a directory to bind it to a developer project.'
45 );
46 - expect(output).toContain('Run `composio dev orgs switch` to change your default org.');
46 + expect(output).toContain('Run `composio orgs switch` to change your default org.');
47 })
48 );
49 });
ts/packages/cli/test/src/commands/projects/projects.switch.cmd.test.ts
+4 -2
@@ -3,10 +3,12 @@ import { describe, expect, layer } from '@effect/vitest';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4
5 describe('CLI: composio dev projects switch', () => {
6 - layer(TestLive())(it => {
6 + layer(TestLive({ cliUserConfig: { developerDangerousCommandsEnabled: true } }))(it => {
7 it.scoped('[Then] it reports global developer project switching is deprecated', () =>
8 Effect.gen(function* () {
9 - yield* cli(['dev', 'projects', 'switch']).pipe(Effect.catchAll(() => Effect.void));
9 + yield* cli(['dev', 'projects', 'switch', '--dangerously-allow']).pipe(
10 + Effect.catchAll(() => Effect.void)
11 + );
12 const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
13 expect(output).toMatch(/composio dev init/);
14 })
ts/packages/cli/test/src/commands/triggers/triggers.mutations.cmd.test.ts
+36 -61
@@ -7,8 +7,13 @@ const testConfigProvider = ConfigProvider.fromMap(
7 new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
8 ).pipe(extendConfigProvider);
9
10 +const dangerousDevConfig = {
11 + baseConfigProvider: testConfigProvider,
12 + cliUserConfig: { developerDangerousCommandsEnabled: true },
13 +} as const;
14 +
15 describe('CLI: composio dev triggers mutations', () => {
11 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
16 + layer(TestLive(dangerousDevConfig))(
17 '[Given] create with valid args [Then] creates trigger',
18 it => {
19 it.scoped('creates trigger and prints id', () =>
@@ -20,6 +25,7 @@ describe('CLI: composio dev triggers mutations', () => {
25 'GMAIL_NEW_GMAIL_MESSAGE',
26 '--connected-account-id',
27 'con_123',
28 + '--dangerously-allow',
29 ]);
30 const lines = yield* MockConsole.getLines({ stripAnsi: true });
31 const output = lines.join('\n');
@@ -31,7 +37,7 @@ describe('CLI: composio dev triggers mutations', () => {
37 }
38 );
39
34 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
40 + layer(TestLive(dangerousDevConfig))(
41 '[Given] create with invalid JSON config [Then] shows JSON validation error',
42 it => {
43 it.scoped('rejects invalid trigger config JSON', () =>
@@ -43,6 +49,7 @@ describe('CLI: composio dev triggers mutations', () => {
49 'GMAIL_NEW_GMAIL_MESSAGE',
50 '--trigger-config',
51 '{',
52 + '--dangerously-allow',
53 ]);
54 const lines = yield* MockConsole.getLines({ stripAnsi: true });
55 const output = lines.join('\n');
@@ -53,49 +60,29 @@ describe('CLI: composio dev triggers mutations', () => {
60 }
61 );
62
56 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
57 - '[Given] enable with ID [Then] enables trigger',
58 - it => {
59 - it.scoped('enables trigger successfully', () =>
60 - Effect.gen(function* () {
61 - yield* cli(['dev', 'triggers', 'enable', 'trg_123']);
62 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
63 - const output = lines.join('\n');
64 - expect(output).toContain('enabled');
65 - })
66 - );
67 - }
68 - );
63 + layer(TestLive(dangerousDevConfig))('[Given] enable with ID [Then] enables trigger', it => {
64 + it.scoped('enables trigger successfully', () =>
65 + Effect.gen(function* () {
66 + yield* cli(['dev', 'triggers', 'enable', 'trg_123', '--dangerously-allow']);
67 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
68 + const output = lines.join('\n');
69 + expect(output).toContain('enabled');
70 + })
71 + );
72 + });
73
70 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
71 - '[Given] disable with ID [Then] disables trigger',
72 - it => {
73 - it.scoped('disables trigger successfully', () =>
74 - Effect.gen(function* () {
75 - yield* cli(['dev', 'triggers', 'disable', 'trg_123']);
76 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
77 - const output = lines.join('\n');
78 - expect(output).toContain('disabled');
79 - })
80 - );
81 - }
82 - );
74 + layer(TestLive(dangerousDevConfig))('[Given] disable with ID [Then] disables trigger', it => {
75 + it.scoped('disables trigger successfully', () =>
76 + Effect.gen(function* () {
77 + yield* cli(['dev', 'triggers', 'disable', 'trg_123', '--dangerously-allow']);
78 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
79 + const output = lines.join('\n');
80 + expect(output).toContain('disabled');
81 + })
82 + );
83 + });
84
84 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
85 - '[Given] delete with --yes [Then] deletes trigger',
86 - it => {
87 - it.scoped('deletes trigger successfully', () =>
88 - Effect.gen(function* () {
89 - yield* cli(['dev', 'triggers', 'delete', 'trg_123', '--yes']);
90 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
91 - const output = lines.join('\n');
92 - expect(output).toContain('deleted');
93 - })
94 - );
95 - }
96 - );
97 -
98 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
85 + layer(TestLive(dangerousDevConfig))(
86 '[Given] create with non-object JSON config [Then] shows type validation error',
87 it => {
88 it.scoped('rejects array JSON in --trigger-config', () =>
@@ -107,6 +94,7 @@ describe('CLI: composio dev triggers mutations', () => {
94 'GMAIL_NEW_GMAIL_MESSAGE',
95 '--trigger-config',
96 '[1,2,3]',
97 + '--dangerously-allow',
98 ]);
99 const lines = yield* MockConsole.getLines({ stripAnsi: true });
100 const output = lines.join('\n');
@@ -124,6 +112,7 @@ describe('CLI: composio dev triggers mutations', () => {
112 'GMAIL_NEW_GMAIL_MESSAGE',
113 '--trigger-config',
114 '42',
115 + '--dangerously-allow',
116 ]);
117 const lines = yield* MockConsole.getLines({ stripAnsi: true });
118 const output = lines.join('\n');
@@ -134,12 +123,12 @@ describe('CLI: composio dev triggers mutations', () => {
123 }
124 );
125
137 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
126 + layer(TestLive(dangerousDevConfig))(
127 '[Given] missing ID for enable [Then] warns about missing argument',
128 it => {
129 it.scoped('shows missing id warning', () =>
130 Effect.gen(function* () {
142 - yield* cli(['dev', 'triggers', 'enable']);
131 + yield* cli(['dev', 'triggers', 'enable', '--dangerously-allow']);
132 const lines = yield* MockConsole.getLines({ stripAnsi: true });
133 const output = lines.join('\n');
134 expect(output).toContain('Missing required argument');
@@ -148,26 +137,12 @@ describe('CLI: composio dev triggers mutations', () => {
137 }
138 );
139
151 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
140 + layer(TestLive(dangerousDevConfig))(
141 '[Given] missing ID for disable [Then] warns about missing argument',
142 it => {
143 it.scoped('shows missing id warning', () =>
144 Effect.gen(function* () {
156 - yield* cli(['dev', 'triggers', 'disable']);
157 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
158 - const output = lines.join('\n');
159 - expect(output).toContain('Missing required argument');
160 - })
161 - );
162 - }
163 - );
164 -
165 - layer(TestLive({ baseConfigProvider: testConfigProvider }))(
166 - '[Given] missing ID for delete [Then] warns about missing argument',
167 - it => {
168 - it.scoped('shows missing id warning', () =>
169 - Effect.gen(function* () {
170 - yield* cli(['dev', 'triggers', 'delete']);
145 + yield* cli(['dev', 'triggers', 'disable', '--dangerously-allow']);
146 const lines = yield* MockConsole.getLines({ stripAnsi: true });
147 const output = lines.join('\n');
148 expect(output).toContain('Missing required argument');
ts/packages/cli/test/src/services/cli-user-config.test.ts
+67
@@ -30,6 +30,8 @@ describe('ComposioCliUserConfig', () => {
30 return Effect.gen(function* () {
31 const config = yield* ComposioCliUserConfig;
32 assertEquals(config.channel, 'stable');
33 + assertEquals(config.data.developerModeEnabled, true);
34 + assertEquals(config.data.developerDangerousCommandsEnabled, false);
35 assertEquals(config.data.experimentalFeatures.listen, undefined);
36 assertEquals(config.isExperimentalFeatureEnabled('listen'), false);
37 assertEquals(config.data.experimentalFeatures.multi_account, undefined);
@@ -54,6 +56,8 @@ describe('ComposioCliUserConfig', () => {
56 return Effect.gen(function* () {
57 const config = yield* ComposioCliUserConfig;
58 assertEquals(config.channel, 'beta');
59 + assertEquals(config.data.developerModeEnabled, true);
60 + assertEquals(config.data.developerDangerousCommandsEnabled, false);
61 assertEquals(config.data.experimentalFeatures.listen, undefined);
62 assertEquals(config.isExperimentalFeatureEnabled('listen'), true);
63 assertEquals(config.data.experimentalFeatures.multi_account, undefined);
@@ -69,6 +73,10 @@ describe('ComposioCliUserConfig', () => {
73 fs.writeFileSync(
74 path.join(cwd, '.composio', 'config.json'),
75 JSON.stringify({
76 + developer: {
77 + enabled: false,
78 + destructive_actions: true,
79 + },
80 experimental_features: {
81 listen: false,
82 multi_account: false,
@@ -89,6 +97,8 @@ describe('ComposioCliUserConfig', () => {
97 return Effect.gen(function* () {
98 const fileSystem = yield* FileSystem.FileSystem;
99 const config = yield* ComposioCliUserConfig;
100 + assertEquals(config.data.developerModeEnabled, false);
101 + assertEquals(config.data.developerDangerousCommandsEnabled, true);
102 assertEquals(config.data.experimentalFeatures.listen, false);
103 assertEquals(config.isExperimentalFeatureEnabled('listen'), false);
104 assertEquals(config.data.experimentalFeatures.multi_account, false);
@@ -101,17 +111,74 @@ describe('ComposioCliUserConfig', () => {
111 'utf8'
112 );
113 const parsed = JSON.parse(persisted) as {
114 + developer: {
115 + enabled: boolean;
116 + destructive_actions: boolean;
117 + };
118 experimental_features: { listen: boolean; multi_account: boolean };
119 artifact_directory: string;
120 experimental_subagent: { target: string };
121 };
122
123 + assertEquals(parsed.developer.enabled, false);
124 + assertEquals(parsed.developer.destructive_actions, true);
125 assertEquals(parsed.experimental_features.listen, false);
126 assertEquals(parsed.experimental_features.multi_account, false);
127 assertEquals(parsed.artifact_directory, '/tmp/composio-artifacts');
128 assertEquals(parsed.experimental_subagent.target, 'claude');
129 }).pipe(Effect.provide(CliUserConfigTest));
130 });
131 +
132 + it.scoped('loads legacy flat developer keys and persists nested developer config', () => {
133 + const cwd = tempy.temporaryDirectory();
134 + const map = new Map([['DEBUG_OVERRIDE_VERSION', '1.2.3-beta.4']]) satisfies Map<string, string>;
135 + fs.mkdirSync(path.join(cwd, '.composio'), { recursive: true });
136 + fs.writeFileSync(
137 + path.join(cwd, '.composio', 'config.json'),
138 + JSON.stringify({
139 + developer_mode_enabled: false,
140 + developer_dangerous_commands_enabled: true,
141 + })
142 + );
143 +
144 + const NodeOsTest = Layer.succeed(NodeOs, defaultNodeOs({ homedir: cwd }));
145 + const CliUserConfigTest = Layer.provideMerge(
146 + ComposioCliUserConfigLive,
147 + Layer.mergeAll(BunFileSystem.layer, NodeOsTest, withMapConfigProvider(map))
148 + );
149 +
150 + return Effect.gen(function* () {
151 + const fileSystem = yield* FileSystem.FileSystem;
152 + const config = yield* ComposioCliUserConfig;
153 + assertEquals(config.data.developerModeEnabled, false);
154 + assertEquals(config.data.developerDangerousCommandsEnabled, true);
155 +
156 + yield* config.update({
157 + developer: {
158 + ...config.raw.developer,
159 + enabled: true,
160 + },
161 + });
162 +
163 + const persisted = yield* fileSystem.readFileString(
164 + path.join(cwd, '.composio', 'config.json'),
165 + 'utf8'
166 + );
167 + const parsed = JSON.parse(persisted) as {
168 + developer: {
169 + enabled: boolean;
170 + destructive_actions: boolean;
171 + };
172 + developer_mode_enabled?: boolean;
173 + developer_dangerous_commands_enabled?: boolean;
174 + };
175 +
176 + assertEquals(parsed.developer.enabled, true);
177 + assertEquals(parsed.developer.destructive_actions, true);
178 + assertEquals(parsed.developer_mode_enabled, undefined);
179 + assertEquals(parsed.developer_dangerous_commands_enabled, undefined);
180 + }).pipe(Effect.provide(CliUserConfigTest));
181 + });
182 it.effect('resolves sync config path from COMPOSIO_CACHE_DIR when provided', () => {
183 const cacheDir = tempy.temporaryDirectory();
184 process.env.COMPOSIO_CACHE_DIR = cacheDir;
ts/packages/core/src/lib/toolRouterParams.ts
+1 -1
@@ -127,7 +127,7 @@ export const transformToolRouterWorkbenchParams = (
127
128 export const transformToolRouterMultiAccountParams = (
129 params?: ToolRouterCreateSessionConfig['multiAccount']
130 -): SessionCreateParams.MultiAccount | undefined => {
130 +): Record<string, unknown> | undefined => {
131 if (!params) {
132 return undefined;
133 }
ts/packages/core/src/models/ConnectedAccounts.ts
+5 -16
@@ -14,7 +14,6 @@ import {
14 ConnectedAccountUpdateStatusResponse,
15 ConnectedAccountListParams as ConnectedAccountListParamsRaw,
16 ConnectedAccountCreateParams as ConnectedAccountCreateParamsRaw,
17 - ConnectedAccountPatchResponse,
17 } from '@composio/client/resources/connected-accounts';
18 import {
19 CreateConnectedAccountOptions,
@@ -471,28 +470,18 @@ export class ConnectedAccounts {
470 *
471 * @param {string} nanoid - The unique identifier of the connected account
472 * @param {UpdateConnectedAccountParams} params - The update parameters
474 - * @returns {Promise<ConnectedAccountPatchResponse>} The update response
473 + * @returns {Promise<ConnectedAccountUpdateStatusResponse>} The update response
474 *
475 * @example
476 * ```typescript
478 - * // Set an alias
479 - * await composio.connectedAccounts.update('ca_abc123', { alias: 'work-gmail' });
480 - *
481 - * // Update credentials
482 - * await composio.connectedAccounts.update('ca_abc123', {
483 - * connection: {
484 - * state: {
485 - * authScheme: 'BEARER_TOKEN',
486 - * val: { token: 'new-access-token' },
487 - * },
488 - * },
489 - * });
477 + * // Disable an account
478 + * await composio.connectedAccounts.update('ca_abc123', { enabled: false });
479 * ```
480 */
481 async update(
482 nanoid: string,
483 params: UpdateConnectedAccountParams
495 - ): Promise<ConnectedAccountPatchResponse> {
484 + ): Promise<ConnectedAccountUpdateStatusResponse> {
485 const parsedParams = UpdateConnectedAccountParamsSchema.safeParse(params);
486 if (!parsedParams.success) {
487 throw new ValidationError('Failed to parse connected account update params', {
@@ -500,6 +489,6 @@ export class ConnectedAccounts {
489 });
490 }
491
503 - return this.client.connectedAccounts.patch(nanoid, parsedParams.data);
492 + return this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data);
493 }
494 }
ts/packages/core/src/models/ToolRouter.ts
+1 -1
@@ -128,7 +128,7 @@ export class ToolRouter<
128
129 const multiAccountPayload = transformToolRouterMultiAccountParams(routerConfig.multiAccount);
130
131 - const payload: SessionCreateParams = {
131 + const payload: SessionCreateParams & { multi_account?: Record<string, unknown> } = {
132 user_id: userId,
133 auth_configs: routerConfig.authConfigs,
134 connected_accounts: routerConfig.connectedAccounts,
ts/packages/core/src/types/connectedAccounts.types.ts
+2 -19
@@ -214,25 +214,8 @@ export const ConnectedAccountRefreshOptionsSchema = z.object({
214 export type ConnectedAccountRefreshOptions = z.infer<typeof ConnectedAccountRefreshOptionsSchema>;
215
216 // Use the Stainless-generated type as the source of truth for update params.
217 -export type { ConnectedAccountPatchParams as UpdateConnectedAccountParams } from '@composio/client/resources/connected-accounts';
217 +export type { ConnectedAccountUpdateStatusParams as UpdateConnectedAccountParams } from '@composio/client/resources/connected-accounts';
218
219 export const UpdateConnectedAccountParamsSchema = z.object({
220 - alias: z.string().optional(),
221 - connection: z
222 - .object({
223 - state: z.object({
224 - authScheme: z.enum([
225 - 'BEARER_TOKEN',
226 - 'API_KEY',
227 - 'BASIC',
228 - 'BASIC_WITH_JWT',
229 - 'GOOGLE_SERVICE_ACCOUNT',
230 - 'SERVICE_ACCOUNT',
231 - ]),
232 - val: z.record(z.unknown()),
233 - }),
234 - })
235 - .optional(),
220 + enabled: z.boolean(),
221 });
237 -
238 -// UpdateConnectedAccountResponse is now ConnectedAccountPatchResponse from @composio/client
ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
+13 -34
@@ -24,7 +24,6 @@ const extendedMockClient = {
24 refresh: vi.fn(),
25 updateStatus: vi.fn(),
26 createConnectedAccountLink: vi.fn(),
27 - patch: vi.fn(),
27 },
28 link: {
29 create: vi.fn(),
@@ -937,58 +936,38 @@ describe('ConnectedAccounts', () => {
936 });
937
938 describe('update', () => {
940 - it('should set an alias on a connected account', async () => {
939 + it('should enable a connected account', async () => {
940 const nanoid = 'conn_abc123';
941 const mockResponse = { success: true, id: nanoid, status: 'ACTIVE' };
942
944 - extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce(mockResponse);
943 + extendedMockClient.connectedAccounts.updateStatus.mockResolvedValueOnce(mockResponse);
944
946 - const result = await connectedAccounts.update(nanoid, { alias: 'work-gmail' });
945 + const result = await connectedAccounts.update(nanoid, { enabled: true });
946
948 - expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith(nanoid, {
949 - alias: 'work-gmail',
947 + expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {
948 + enabled: true,
949 });
950 expect(result).toEqual({ success: true, id: nanoid, status: 'ACTIVE' });
951 });
952
954 - it('should clear an alias by passing an empty string', async () => {
953 + it('should disable a connected account', async () => {
954 const nanoid = 'conn_abc123';
955 const mockResponse = { success: true };
956
958 - extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce(mockResponse);
957 + extendedMockClient.connectedAccounts.updateStatus.mockResolvedValueOnce(mockResponse);
958
960 - const result = await connectedAccounts.update(nanoid, { alias: '' });
959 + const result = await connectedAccounts.update(nanoid, { enabled: false });
960
962 - expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith(nanoid, {
963 - alias: '',
961 + expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {
962 + enabled: false,
963 });
964 expect(result).toEqual({ success: true });
965 });
966
968 - it('should update credentials via connection param', async () => {
969 - const nanoid = 'conn_abc123';
970 - const mockResponse = { success: true, id: nanoid, status: 'ACTIVE' };
971 - const params = {
972 - connection: {
973 - state: {
974 - authScheme: 'BEARER_TOKEN' as const,
975 - val: { token: 'new-access-token' },
976 - },
977 - },
978 - };
979 -
980 - extendedMockClient.connectedAccounts.patch.mockResolvedValueOnce(mockResponse);
981 -
982 - const result = await connectedAccounts.update(nanoid, params);
983 -
984 - expect(extendedMockClient.connectedAccounts.patch).toHaveBeenCalledWith(nanoid, params);
985 - expect(result).toEqual({ success: true, id: nanoid, status: 'ACTIVE' });
986 - });
987 -
967 it('should throw ValidationError for invalid params', async () => {
989 - await expect(connectedAccounts.update('conn_abc123', { alias: 123 } as any)).rejects.toThrow(
990 - 'Failed to parse connected account update params'
991 - );
968 + await expect(
969 + connectedAccounts.update('conn_abc123', { enabled: 'yes' } as any)
970 + ).rejects.toThrow('Failed to parse connected account update params');
971 });
972 });
973