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

fix(cli): print expected errors without the crash banner (#5039)

This PR: - Prints more expected CLI errors as a plain message on stderr with exit 1, instead of the `💥` banner with the error tag and a stack location. Nothing is printed on stdout, and no message wording changes. - Marks each expected error where its class is defined, with a `get [ExpectedFailure]()` getter from `src/effects/expected-failure.ts`. `isUsageFailure` checks that marker, replacing the hand-kept union and `instanceof` chain, so a new expected error needs no central list. - Makes the not-connected fast fail of `execute` and `proxy` fail with a `Reported*` error. It has already printed its message, tips, and `{"successful": false}` JSON, so the CLI now exits 1 without printing anything more. - Adds a classification table test for `isUsageFailure`, plus spawned-CLI tests for `login --poll`, `execute --file`, `proxy` without a consumer user, and both not-connected fast fails. All of them fail without the fix. - Adds an `Unreleased` entry to the CLI changelog and updates the `UsageFailure` note in `ts/packages/cli/AGENTS.md`. ## Context Now printed as plain messages: - `ToolExecutionError`: `missing_user_id`, `file_input`, and the `--parallel` `connection_check`. The single-call `connection_check` was already reported, so it now uses `ReportedToolExecutionError`. - `ProxyCommandError` (no consumer user). The not-connected case now uses `ReportedProxyCommandError`. - `MissingLinkUserIdError` and `ConnectionPollingError` (`link`) - `InvalidOrganizationError`, `LoginSessionError`, and `PendingLoginError` (`login`) - `ComposioCorePkgNotFound` and `ProjectEnvironmentDetectorError` (`generate`) - `InvalidToolkitVersionsValidationError`, and `ToolkitVersionValidationError` with reason `invalid-toolkit` (a `COMPOSIO_TOOLKIT_VERSION_*` override naming an unknown toolkit or version) Still shown with the banner: - `ToolkitVersionValidationError` with reasons `request`, `decode`, or `client-unavailable`. These wrap a failed request, a response that did not decode, or a missing client behind a generic message, so they stay defects, like other unhandled request failures. - `ListenCommandError` is unchanged because #4804 is reworking `triggers listen` in the same file.

Alberto Schiabel committed Oct 22, 2026 at 01:18 UTC e5f5de4c038d79ffdd0f1e1d5bbf58b09008d597
21 files changed +557 -70
ts/packages/cli/AGENTS.md
+1 -1
@@ -214,7 +214,7 @@ Each `Arr.bind` adds one independent axis to the generated cases.
214 - Never branch on an Effect value's internal tag field directly. Use the owning module's public refinement or matcher (`Option`, `Result`, `Exit`, `Cause`, `CliError`), `Match.valueTags` for exhaustive unions, or `Predicate.isTagged` for a single narrowing guard.
215 - Do not wrap a plain `Error` in `Effect.fail` for expected failures. Give the failure a meaningful `Data.TaggedError` type with structured fields and a preserved cause, then recover with `catchTag` / `catchTags`. Reserve `Effect.die` and `Effect.dieMessage` for impossible invariants.
216 - Treat `unknown`, JSON, and persisted state as trust boundaries. Decode them with `effect/Schema` or narrow them with `Predicate`; an `as` assertion is not validation, and hand-rolled structural guards (`'x' in obj` / `typeof` chains) are not a substitute for a schema. Each typed API response is validated at most once. The CLI's own schema validates a response the CLI transforms, filters for stdout, or writes to a cache file: the catalog models (`src/models/toolkits.ts`, `tools.ts`, `trigger-types.ts`), the auth-config and connected-account allowlists that keep credential-bearing fields off stdout (including the list responses and the `auth-configs create` response in `src/models/auth-configs.ts` and `connected-accounts.ts`), the `ToolkitSlug` path-safety check, the `Session` `DateTime` transform, and `TriggerInstanceItems`. Those calls decode with the CLI schema, failing with `services/HttpDecodingError`. The client validates a response against its own generated schema only when the call passes the `validated` request option (`src/services/composio-request.ts`); a mismatch fails with the client's `DecodeError`, which the CLI reports with the operation, the request id, and an upgrade hint. Pass `validated` only on a read the CLI consumes whole through the client's types, where no field may drift: `cli.realtime.credentials` (every field feeds the realtime connection), `org.list` (organization ids and names for login), and `org.consumer.listConnectedToolkits` (a list of slugs). Every other typed call leaves it off: calls that are not reads, because failing after the server acted would invite a retry that repeats the side effect; reads the CLI validates with its own schema; and reads that must tolerate drift because the CLI consumes a few fields of a response whose client schema fixes enums or requires fields the CLI never reads (`logs.tools.*`, `logs.triggers.*`, `tools.list`, `tools.retrieve`, `org.project.list`, `toolRouter.session.search`, `toolRouter.session.toolkits`, `connectedAccounts.list`, which tolerates unknown statuses, and `triggerInstances.listActive`, whose page counts the CLI defaults). Adding a validated read means saying in its doc comment why the CLI cannot tolerate drift there. Responses fetched with the raw `client.get`/`client.post` are untyped and always need a CLI schema (`LatestToolVersionResponse` in `src/models/tools.ts`, and the consumer config and permission payloads in `tool-permissions.ts`). `effect/Schema` is the CLI's schema tool — do not introduce zod here (zod is the convention in the SDK packages and docs).
217 -- Do not inspect private `effect/cli` internals (parser state, `HelpDoc` string shapes, `CliError` suggestion machinery). `Command.runWith` renders help and parse/validation errors itself — see the entry-point section above — so command-tree introspection must stay on the public `Command.Any` surface (`name`, `alias`, `subcommands`). `CliError.InvalidValue` takes structured `{ option, value, expected, kind }` fields, not a free-form message — handler-level validation raises `CommandInputError` from `src/commands/errors.ts` (built with `commandInputError('<command>')`, carrying `command`, `message`, and the `option` at fault), not a hand-built `CliError`. It, `NotLoggedInError`, `ProjectResolutionError`, and `ConnectedAccountResolutionError` (an `--account` selector that matches no connected account, or the account lookup behind it failing) are the `UsageFailure` union (`isUsageFailure` in `errors.ts`): `cli-main.ts` prints the message as one line and exits 1, with no defect banner.
217 +- Do not inspect private `effect/cli` internals (parser state, `HelpDoc` string shapes, `CliError` suggestion machinery). `Command.runWith` renders help and parse/validation errors itself — see the entry-point section above — so command-tree introspection must stay on the public `Command.Any` surface (`name`, `alias`, `subcommands`). `CliError.InvalidValue` takes structured `{ option, value, expected, kind }` fields, not a free-form message — handler-level validation raises `CommandInputError` from `src/commands/errors.ts` (built with `commandInputError('<command>')`, carrying `command`, `message`, and the `option` at fault), not a hand-built `CliError`. It, `NotLoggedInError`, `ProjectResolutionError`, `ConnectedAccountResolutionError` (an `--account` selector that matches no connected account, or the account lookup behind it failing), and the other expected failures (a missing user id, login, or SDK install; an unknown org, toolkit, or version) declare `get [ExpectedFailure]() { return true; }` from `src/effects/expected-failure.ts` where the class is defined; `isUsageFailure` in `errors.ts` checks that marker, and `cli-main.ts` prints the message and exits 1, with no defect banner. A new expected error opts in the same way, with no central list to update; a defect stays unmarked. A failure the command already printed (on stderr and as `{ "successful": false }` on stdout) fails with a `Reported*` error instead, which `cli-main.ts` turns into exit 1 without printing more.
218 - Prefer `Effect.mapError`, `Effect.matchEffect`, and typed recovery over `Effect.catch` blocks (the v4 name for what was `Effect.catchAll`) that flatten distinct failures into one message-only error.
219
220 ### Effect Boundary Policy
ts/packages/cli/CHANGELOG.md
+26
@@ -1,5 +1,31 @@
1 # @composio/cli
2
3 +## Unreleased
4 +
5 +### Patch Changes
6 +
7 +- More expected errors now print as a plain message on stderr and exit 1, like
8 + other usage errors. They used to print under a `💥` banner with the error tag
9 + and a stack location, as if the CLI had crashed. The message itself is
10 + unchanged, and nothing is printed on stdout. This covers:
11 + - `composio execute` without a user id, or with a `--file` the tool has no
12 + file input for (or whose field `-d` already sets)
13 + - `composio proxy` when the project has no consumer user
14 + - `composio link` without a user id, or when the authorization is not
15 + finished before the CLI stops waiting
16 + - `composio login` with an `--org` that does not exist, a session key that
17 + expired or is not linked yet, a login that is not finished in time, or
18 + `--poll` without a pending (or with an expired) login
19 + - `composio generate` outside a recognizable JavaScript or Python project, or
20 + without `@composio/core` or `composio-core` installed
21 + - a `COMPOSIO_TOOLKIT_VERSION_<TOOLKIT>` override naming a toolkit or version
22 + that does not exist
23 +
24 +- `composio execute` and `composio proxy` no longer print a `💥` banner after
25 + reporting that the toolkit is not connected (when the connected-account cache
26 + is on). The message, tips, and `{"successful": false, ...}` JSON on stdout
27 + are unchanged, and the exit code is still 1.
28 +
29 ## 0.5.0
30
31 ### Minor Changes
ts/packages/cli/src/cli-main.ts
+8 -5
@@ -72,6 +72,7 @@ import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
72 import { PendingLoginSession } from 'src/services/pending-login-session';
73 import { SetupCommandError } from 'src/services/setup-command-error';
74 import { ShellSetupAbortError } from 'src/commands/install/install.errors';
75 +import { ReportedProxyCommandError } from 'src/commands/proxy.cmd';
76 import { ReportedToolExecutionError } from 'src/commands/tools/commands/tools.execute.cmd';
77 import { isUsageFailure, type UsageFailure } from 'src/commands/errors';
78 import { cliInvocationContext } from 'src/services/runtime-cli-context';
@@ -318,8 +319,8 @@ const cliProgram = (argv: ReadonlyArray<string>) =>
319 process.exitCode = 1;
320 })
321 ),
321 - // A usage mistake, a missing login, an unresolved project, or an `--account` that selects
322 - // no connected account is not a broken invariant: print the one-line fix and exit non-zero
322 + // A usage mistake, a missing setup or login, or a failure a remote service reported clearly
323 + // (see `UsageFailure`) is not a broken invariant: print the message and exit non-zero
324 // instead of routing it through the defect reporter below.
325 Effect.catchIf(
326 (error): error is UsageFailure => isUsageFailure(error),
@@ -340,10 +341,12 @@ const cliProgram = (argv: ReadonlyArray<string>) =>
341 process.exitCode = 1;
342 })
343 ),
343 - // `composio execute` already printed the failed result as JSON on stdout; the typed
344 - // failure only exists so scripts and agents see a non-zero exit code.
344 + // `composio execute` and `composio proxy` already printed the failure, and the failed result
345 + // as JSON on stdout; the typed failure only exists so scripts and agents see a non-zero exit
346 + // code.
347 Effect.catchIf(
346 - (error): error is ReportedToolExecutionError => error instanceof ReportedToolExecutionError,
348 + (error): error is ReportedToolExecutionError | ReportedProxyCommandError =>
349 + error instanceof ReportedToolExecutionError || error instanceof ReportedProxyCommandError,
350 () =>
351 Effect.sync(() => {
352 process.exitCode = 1;
ts/packages/cli/src/commands/connected-accounts/link/connected-accounts.link.errors.ts
+11 -2
@@ -1,16 +1,25 @@
1 import { Data } from 'effect';
2 +import { ExpectedFailure } from 'src/effects/expected-failure';
3 import { requestError } from 'src/effects/request-error';
4
5 export class ConnectionPollingError extends Data.TaggedError('commands/ConnectionPollingError')<{
6 readonly message: string;
7 readonly connectedAccountId: string;
8 readonly status: string;
8 -}> {}
9 +}> {
10 + get [ExpectedFailure]() {
11 + return true;
12 + }
13 +}
14
15 export class MissingLinkUserIdError extends Data.TaggedError('commands/MissingLinkUserIdError')<{
16 readonly message: string;
17 readonly flow: 'list' | 'legacy' | 'tool-router';
13 -}> {}
18 +}> {
19 + get [ExpectedFailure]() {
20 + return true;
21 + }
22 +}
23
24 export class ConnectedAccountsDecodeError extends Data.TaggedError(
25 'commands/ConnectedAccountsDecodeError'
ts/packages/cli/src/commands/errors.ts
+17 -13
@@ -1,6 +1,5 @@
1 import { Data } from 'effect';
2 -import { ProjectResolutionError } from 'src/services/command-project';
3 -import { ConnectedAccountResolutionError } from 'src/services/connected-account-selection';
2 +import { ExpectedFailure, isExpectedFailure } from 'src/effects/expected-failure';
3
4 /**
5 * A usage mistake the parser cannot see: a flag combination, a value that fails a business
@@ -15,28 +14,33 @@ export class CommandInputError extends Data.TaggedError('commands/CommandInputEr
14 readonly message: string;
15 /** The flag or argument at fault, e.g. `--alias` or `<toolkit>`, when there is one. */
16 readonly option?: string | undefined;
18 -}> {}
17 +}> {
18 + get [ExpectedFailure]() {
19 + return true;
20 + }
21 +}
22
23 /** The command needs a logged-in user and `~/.composio` holds no API key. */
24 export class NotLoggedInError extends Data.TaggedError('commands/NotLoggedInError')<{
25 readonly message: string;
23 -}> {}
26 +}> {
27 + get [ExpectedFailure]() {
28 + return true;
29 + }
30 +}
31
32 export const notLoggedIn = (): NotLoggedInError =>
33 new NotLoggedInError({ message: 'You are not logged in yet. Please run `composio login`.' });
34
35 /**
29 - * Failures the user fixes by changing the invocation or their setup, not defects. `cli-main.ts`
30 - * prints the message as one line on stderr and exits 1.
36 + * Failures the user fixes by changing the invocation or their setup, or that a remote service
37 + * reported clearly, not defects: any error whose class declares `ExpectedFailure` (see
38 + * `src/effects/expected-failure.ts`). `cli-main.ts` prints the message on stderr and exits 1,
39 + * with no defect banner.
40 */
32 -export type UsageFailure =
33 - CommandInputError | NotLoggedInError | ProjectResolutionError | ConnectedAccountResolutionError;
41 +export type UsageFailure = ExpectedFailure;
42
35 -export const isUsageFailure = (error: unknown): error is UsageFailure =>
36 - error instanceof CommandInputError ||
37 - error instanceof NotLoggedInError ||
38 - error instanceof ProjectResolutionError ||
39 - error instanceof ConnectedAccountResolutionError;
43 +export const isUsageFailure = isExpectedFailure;
44
45 /** Builds the constructor a command uses for its own input errors. */
46 export const commandInputError =
ts/packages/cli/src/commands/login/login.errors.ts
+13 -1
@@ -1,4 +1,6 @@
1 import { Data } from 'effect';
2 +import { ExpectedFailure } from 'src/effects/expected-failure';
3 +import { requestError } from 'src/effects/request-error';
4
5 /** `--org` names no organization the user API key can see. */
6 export class InvalidOrganizationError extends Data.TaggedError(
@@ -6,4 +8,14 @@ export class InvalidOrganizationError extends Data.TaggedError(
8 )<{
9 readonly message: string;
10 readonly requestedOrg: string;
9 -}> {}
11 +}> {
12 + get [ExpectedFailure]() {
13 + return true;
14 + }
15 +}
16 +
17 +/**
18 + * Looking up the CLI session behind `--key` failed for a reason other than the session not
19 + * existing (a connection, server, or decoding failure). A defect, reported with its cause.
20 + */
21 +export class LoginSessionRequestError extends requestError('commands/LoginSessionRequestError') {}
ts/packages/cli/src/commands/login/login.handler.ts
+10 -10
@@ -1,4 +1,4 @@
1 -import { Array as Arr, Data, Effect, Match, Option, pipe } from 'effect';
1 +import { Array as Arr, Data, Effect, Match, Option, Predicate, pipe } from 'effect';
2 import { commandInputError } from 'src/commands/errors';
3 import { APP_VERSION } from 'src/constants';
4 import {
@@ -32,7 +32,7 @@ import { primeConsumerConnectedToolkitsCacheInBackground } from 'src/services/co
32 import { PendingLoginSession } from 'src/services/pending-login-session';
33 import { TerminalUI } from 'src/services/terminal-ui';
34 import { ComposioUserContext } from 'src/services/user-context';
35 -import { InvalidOrganizationError } from './login.errors';
35 +import { InvalidOrganizationError, LoginSessionRequestError } from './login.errors';
36 import {
37 AGENT_WITH_OTHER_FLAGS_MESSAGE,
38 ALREADY_LOGGED_IN_MESSAGE,
@@ -124,14 +124,14 @@ const loginWithKey = (params: {
124 }) =>
125 Effect.gen(function* () {
126 const client = yield* ComposioSessionRepository;
127 - const getSession = client
128 - .getSession({ id: params.key })
129 - .pipe(
130 - Effect.mapError(
131 - cause =>
132 - new LoginSessionError({ message: SESSION_NOT_FOUND_MESSAGE, operation: 'load', cause })
133 - )
134 - );
127 + const getSession = client.getSession({ id: params.key }).pipe(
128 + // Only a 404 means the session is gone; any other failure keeps its cause.
129 + Effect.mapError(cause =>
130 + Predicate.isTagged(cause, '@composio/client/NotFoundError')
131 + ? new LoginSessionError({ message: SESSION_NOT_FOUND_MESSAGE, operation: 'load', cause })
132 + : new LoginSessionRequestError({ message: 'Failed to load the login session.', cause })
133 + )
134 + );
135 const linkedSession = yield* params.noWait
136 ? Effect.flatMap(getSession, requireLinkedNow)
137 : waitForLinkedSession(getSession, params.pollRetries);
ts/packages/cli/src/commands/proxy.cmd.ts
+23 -6
@@ -5,6 +5,7 @@ import type {
5 SessionProxyExecuteParams,
6 SessionProxyExecuteResponse,
7 } from '@composio/client/resources/tool-router/session';
8 +import { ExpectedFailure } from 'src/effects/expected-failure';
9 import { requestError } from 'src/effects/request-error';
10 import { resolveOptionalTextInput } from 'src/effects/resolve-optional-text-input';
11 import { resolveToolRouterSession } from 'src/effects/create-tool-router-session';
@@ -77,11 +78,29 @@ const SUPPORTED_PROXY_METHODS: ReadonlyArray<ProxyMethod> = [
78 'PATCH',
79 ];
80
81 +/**
82 + * `composio proxy` has no consumer user to send the request as. An expected failure:
83 + * `cli-main.ts` prints the message and exits 1.
84 + */
85 export class ProxyCommandError extends Data.TaggedError('commands/ProxyCommandError')<{
81 - readonly reason: 'missing_consumer_user' | 'toolkit_not_connected';
86 readonly message: string;
83 - readonly toolkit?: string;
84 - readonly endpoint?: string;
87 +}> {
88 + get [ExpectedFailure]() {
89 + return true;
90 + }
91 +}
92 +
93 +/**
94 + * A proxy call refused before sending it because the toolkit is not connected, already reported
95 + * on stderr and as `{ "successful": false, ... }` on stdout. `cli-main.ts` prints nothing more
96 + * and exits 1.
97 + */
98 +export class ReportedProxyCommandError extends Data.TaggedError(
99 + 'commands/ReportedProxyCommandError'
100 +)<{
101 + readonly message: string;
102 + readonly toolkit: string;
103 + readonly endpoint: string;
104 }> {}
105
106 class ProxyRequestError extends requestError('commands/ProxyRequestError') {}
@@ -246,8 +265,7 @@ const runProxyConnectedToolkitFailFast = (params: {
265 2
266 )
267 );
249 - return yield* new ProxyCommandError({
250 - reason: 'toolkit_not_connected',
268 + return yield* new ReportedProxyCommandError({
269 message,
270 toolkit: params.toolkit,
271 endpoint: params.endpoint,
@@ -289,7 +307,6 @@ export const proxyCmd = Command.make('proxy', {
307
308 if (resolvedProject.projectType !== 'CONSUMER' || !resolvedProject.consumerUserId) {
309 return yield* new ProxyCommandError({
292 - reason: 'missing_consumer_user',
310 message: 'No consumer project user is available for proxy execution in this context.',
311 });
312 }
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+22 -19
@@ -1,6 +1,7 @@
1 import { requireLogin } from 'src/effects/require-auth';
2 import { CommandSurface, directoryTestUserId, missingUserIdMessage } from 'src/commands/surface';
3 import { commandInputError } from 'src/commands/errors';
4 +import { ExpectedFailure } from 'src/effects/expected-failure';
5 import { Argument, Command, Flag } from 'effect/cli';
6 import util from 'node:util';
7 import { Data, Effect, Context, Option, Result } from 'effect';
@@ -124,31 +125,33 @@ const resolveInput = (input: Option.Option<string>) =>
125 // Also raised by the hand-rolled `--parallel` mini-parser (`parseParallelExecuteArgs` below).
126 const invalidArguments = commandInputError('execute');
127
127 -type ToolExecutionErrorFields = {
128 - readonly reason:
129 - | 'invalid_arguments'
130 - | 'file_input'
131 - | 'connected_account'
132 - | 'missing_user_id'
133 - | 'connection_check'
134 - | 'execution_failed'
135 - | 'parallel_failed';
128 +// The reasons below are the ones this file constructs each error with; TypeScript cannot infer a
129 +// union from scattered constructor calls, so a new reason is added here next to its first use.
130 +
131 +/**
132 + * `composio execute` cannot run the tool as invoked: a `--file` the tool cannot take, no user
133 + * id to run it for, or (with `--parallel`) a toolkit the user has not connected. An expected
134 + * failure: `cli-main.ts` prints the message and exits 1.
135 + */
136 +export class ToolExecutionError extends Data.TaggedError('ToolExecutionError')<{
137 + readonly reason: 'file_input' | 'missing_user_id' | 'connection_check';
138 readonly message: string;
139 readonly toolSlug?: string;
138 - readonly cause?: unknown;
139 -};
140 -
141 -export class ToolExecutionError extends Data.TaggedError(
142 - 'ToolExecutionError'
143 -)<ToolExecutionErrorFields> {}
140 +}> {
141 + get [ExpectedFailure]() {
142 + return true;
143 + }
144 +}
145
146 /**
147 * A failed execution whose result is already on stdout as `{ "successful": false, ... }`.
148 * `cli-main.ts` prints nothing more for it and exits 1.
149 */
149 -export class ReportedToolExecutionError extends Data.TaggedError(
150 - 'ReportedToolExecutionError'
151 -)<ToolExecutionErrorFields> {}
150 +export class ReportedToolExecutionError extends Data.TaggedError('ReportedToolExecutionError')<{
151 + readonly reason: 'connection_check' | 'execution_failed' | 'parallel_failed';
152 + readonly message: string;
153 + readonly toolSlug?: string;
154 +}> {}
155
156 const parseArguments = (raw: string) =>
157 Effect.fromResult(
@@ -1081,7 +1084,7 @@ const runConnectedToolkitFailFast = (params: {
1084 2
1085 )
1086 );
1084 - return yield* new ToolExecutionError({
1087 + return yield* new ReportedToolExecutionError({
1088 reason: 'connection_check',
1089 toolSlug: params.slug,
1090 message,
ts/packages/cli/src/effects/browser-login.ts
+6 -1
@@ -4,6 +4,7 @@
4 * to be linked, then store the user API key it carries.
5 */
6 import { Data, DateTime, Effect, Option, Schedule, pipe } from 'effect';
7 +import { ExpectedFailure } from 'src/effects/expected-failure';
8 import open from 'open';
9 import type { RetrievedSession } from 'src/models/session';
10 import { ComposioSessionRepository } from 'src/services/composio-clients';
@@ -26,7 +27,11 @@ export class LoginSessionError extends Data.TaggedError('commands/LoginSessionEr
27 readonly operation: 'load' | 'poll';
28 readonly status?: string;
29 readonly cause?: unknown;
29 -}> {}
30 +}> {
31 + get [ExpectedFailure]() {
32 + return true;
33 + }
34 +}
35
36 class LoginBrowserOpenError extends Data.TaggedError('commands/LoginBrowserOpenError')<{
37 readonly message: string;
ts/packages/cli/src/effects/expected-failure.ts new
+37
@@ -0,0 +1,37 @@
1 +import { Predicate } from 'effect';
2 +
3 +/**
4 + * Marks an error class as an expected failure: the user fixes it by changing the invocation or
5 + * their setup, or a remote service reported it clearly. `cli-main.ts` prints its `message` on
6 + * stderr and exits 1, with no defect banner. Anything unmarked is a defect.
7 + *
8 + * An error class opts in where it is defined, with a getter, so no central list needs updating:
9 + *
10 + * @example
11 + * ```ts
12 + * class MissingThingError extends Data.TaggedError('commands/MissingThingError')<{
13 + * readonly message: string;
14 + * }> {
15 + * get [ExpectedFailure]() {
16 + * return true;
17 + * }
18 + * }
19 + * ```
20 + *
21 + * A getter, rather than an instance field, stays off the instance's own properties, so it does
22 + * not change structural equality or serialization, and it can depend on a field, e.g. only one
23 + * `reason` is expected.
24 + */
25 +export const ExpectedFailure: unique symbol = Symbol.for('@composio/cli/ExpectedFailure');
26 +
27 +/** An error `cli-main.ts` prints as its message alone. */
28 +export interface ExpectedFailure {
29 + readonly [ExpectedFailure]: boolean;
30 + readonly message: string;
31 +}
32 +
33 +export const isExpectedFailure = (error: unknown): error is ExpectedFailure =>
34 + Predicate.hasProperty(error, ExpectedFailure) &&
35 + error[ExpectedFailure] === true &&
36 + Predicate.hasProperty(error, 'message') &&
37 + Predicate.isString(error.message);
ts/packages/cli/src/effects/find-composio-core-generated.ts
+6 -1
@@ -1,4 +1,5 @@
1 import { Data, Effect, FileSystem, Match, Path } from 'effect';
2 +import { ExpectedFailure } from 'src/effects/expected-failure';
3 import { ChildProcess } from 'effect/process';
4 import { ChildProcessSpawner } from 'effect/process/ChildProcessSpawner';
5 import {
@@ -10,7 +11,11 @@ export class ComposioCorePkgNotFound extends Data.TaggedError('error/ComposioCor
11 readonly message: string;
12 readonly cause: string;
13 readonly fix?: string;
13 -}> {}
14 +}> {
15 + get [ExpectedFailure]() {
16 + return true;
17 + }
18 +}
19
20 const DEFAULT_PACKAGE_MANAGER: PackageManager = 'npm';
21
ts/packages/cli/src/effects/validate-toolkit-versions.ts
+11 -1
@@ -1,4 +1,5 @@
1 import { Data, Effect } from 'effect';
2 +import { ExpectedFailure } from 'src/effects/expected-failure';
3 import colors from 'picocolors';
4 import { S_BAR, unicodeOr } from '@clack/prompts';
5 import { TerminalUI } from 'src/services/terminal-ui';
@@ -24,6 +25,10 @@ export class InvalidToolkitVersionsValidationError extends Data.TaggedError(
25 });
26 }
27
28 + get [ExpectedFailure]() {
29 + return true;
30 + }
31 +
32 /**
33 * Returns a JSON-serializable representation of the error for programmatic access.
34 */
@@ -41,7 +46,12 @@ export class ToolkitVersionValidationError extends Data.TaggedError(
46 readonly cause?: unknown;
47 readonly message: string;
48 readonly reason: 'invalid-toolkit' | 'request' | 'decode' | 'client-unavailable';
44 -}> {}
49 +}> {
50 + /** Only an override naming an unknown toolkit; request, decoding, and client failures are defects. */
51 + get [ExpectedFailure]() {
52 + return this.reason === 'invalid-toolkit';
53 + }
54 +}
55
56 const MAX_VERSIONS_TO_SHOW = 5;
57 const S_CORNER_BOTTOM_LEFT = unicodeOr('╰', '+');
ts/packages/cli/src/services/command-project.ts
+6 -1
@@ -1,5 +1,6 @@
1 import { isAPIError } from '@composio/client/effect';
2 import { Data, Effect, Option } from 'effect';
3 +import { ExpectedFailure } from 'src/effects/expected-failure';
4 import { extractMessage } from 'src/utils/api-error-extraction';
5 import { ProjectContext } from './project-context';
6 import { ComposioUserContext } from './user-context';
@@ -39,7 +40,11 @@ export class ProjectResolutionError extends Data.TaggedError('services/ProjectRe
40 | 'request_failed';
41 readonly message: string;
42 readonly cause?: unknown;
42 -}> {}
43 +}> {
44 + get [ExpectedFailure]() {
45 + return true;
46 + }
47 +}
48
49 const missingOrg = () =>
50 new ProjectResolutionError({
ts/packages/cli/src/services/connected-account-selection.ts
+6 -1
@@ -1,5 +1,6 @@
1 import type { ComposioClientShape } from '@composio/client/effect';
2 import { Data, Effect, Option, Schema } from 'effect';
3 +import { ExpectedFailure } from 'src/effects/expected-failure';
4 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
5 import { decodeConnectedAccountItems } from 'src/effects/decode-connected-account-list';
6 import type { TerminalUI } from 'src/services/terminal-ui';
@@ -244,7 +245,11 @@ export class ConnectedAccountResolutionError extends Data.TaggedError(
245 readonly message: string;
246 readonly toolkitSlug: string;
247 readonly cause?: unknown;
247 -}> {}
248 +}> {
249 + get [ExpectedFailure]() {
250 + return true;
251 + }
252 +}
253
254 export const resolveConnectedAccountForToolkit = (params: {
255 readonly client: ComposioClientShape;
ts/packages/cli/src/services/pending-login-session.ts
+7 -1
@@ -7,6 +7,7 @@
7 import * as FileSystem from 'effect/FileSystem';
8 import * as Path from 'effect/Path';
9 import type { Config, PlatformError } from 'effect';
10 +import { ExpectedFailure } from 'src/effects/expected-failure';
11 import { Clock, Context, Data, DateTime, Effect, Layer, Schema } from 'effect';
12 import { setupCacheDir } from 'src/effects/setup-cache-dir';
13 import { atomicWritePrivateFileString, ensurePrivateFileMode } from 'src/utils/atomic-write';
@@ -29,7 +30,12 @@ export class PendingLoginError extends Data.TaggedError('commands/PendingLoginEr
30 readonly message: string;
31 readonly reason: 'invalid' | 'io' | 'missing' | 'expired';
32 readonly cause?: unknown;
32 -}> {}
33 +}> {
34 + /** No login was started, or it expired; a cache that cannot be read or decoded is a defect. */
35 + get [ExpectedFailure]() {
36 + return this.reason === 'missing' || this.reason === 'expired';
37 + }
38 +}
39
40 export type PendingLoginSessionShape = {
41 /** Caches a started login, stamped with the current time, in a file only the user can read. */
ts/packages/cli/src/services/project-environment-detector.ts
+6 -1
@@ -2,6 +2,7 @@ import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
2 import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import { Data, Effect, Match, Context, Layer } from 'effect';
5 +import { ExpectedFailure } from 'src/effects/expected-failure';
6 import { getAncestors } from 'src/utils/get-ancestors';
7 import { HOST_CONFIG } from 'src/config';
8
@@ -34,7 +35,11 @@ export class ProjectEnvironmentDetectorError extends Data.TaggedError(
35 readonly message: string;
36 readonly checkedPaths: string[];
37 readonly details?: string;
37 -}> {}
38 +}> {
39 + get [ExpectedFailure]() {
40 + return true;
41 + }
42 +}
43
44 // ---------------------------------------------------------------------------
45 // Constants
ts/packages/cli/test/src/cli-main.test.ts
+124 -1
@@ -363,8 +363,17 @@ const fakeComposio = (req: IncomingMessage, res: ServerResponse) => {
363 /** Shorter than the tests' 30s timeout. */
364 const CLI_DEADLINE_MS = 20_000;
365
366 -const runCliAgainst = (baseUrl: string, args: ReadonlyArray<string>) => {
366 +const runCliAgainst = (
367 + baseUrl: string,
368 + args: ReadonlyArray<string>,
369 + options: {
370 + /** Writes files into the CLI's cache directory before it starts. */
371 + readonly seed?: (configDirectory: string) => void;
372 + readonly env?: Readonly<Record<string, string>>;
373 + } = {}
374 +) => {
375 const configDirectory = tempy.temporaryDirectory();
376 + options.seed?.(configDirectory);
377 fs.writeFileSync(
378 path.join(configDirectory, 'user_data.json'),
379 JSON.stringify({
@@ -394,6 +403,7 @@ const runCliAgainst = (baseUrl: string, args: ReadonlyArray<string>) => {
403 COMPOSIO_BASE_URL: baseUrl,
404 COMPOSIO_WEB_URL: baseUrl,
405 COMPOSIO_CLI_TELEMETRY_DISABLED: '1',
406 + ...options.env,
407 },
408 });
409 let stdout = '';
@@ -526,3 +536,116 @@ describe('account selection errors', () => {
536 30_000
537 );
538 });
539 +
540 +describe('expected failures without the crash banner', () => {
541 + /**
542 + * The connected-toolkits cache turned on, and fresh with no toolkit connected for the consumer
543 + * user `fakeComposio` resolves.
544 + */
545 + const noConnectedToolkits = {
546 + env: { COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE: 'false' },
547 + seed: (configDirectory: string) =>
548 + fs.writeFileSync(
549 + path.join(configDirectory, 'consumer-short-term-cache.json'),
550 + JSON.stringify({
551 + 'org_test:consumer-user-test': {
552 + toolkits: [],
553 + // The spawned CLI reads the real clock, so the entry must outlive any test run.
554 + expiresAt: '2999-01-01T00:00:00.000Z',
555 + },
556 + })
557 + ),
558 + };
559 +
560 + /** `fakeComposio`, except the consumer project has no consumer user. */
561 + const withoutConsumerUser = (req: IncomingMessage, res: ServerResponse) =>
562 + new URL(req.url ?? '/', 'http://127.0.0.1').pathname.endsWith('/org/consumer/project/resolve')
563 + ? sendJson(res, 200, {
564 + org_id: 'org_test',
565 + project_id: 'proj_test',
566 + project_nano_id: 'pr_test',
567 + project_name: 'consumer',
568 + consumer_user_id: '',
569 + })
570 + : fakeComposio(req, res);
571 +
572 + const notConnected = (toolkit: string) =>
573 + `Toolkit "${toolkit}" is not connected for this user (cached within the last 5 minutes). If you just connected the account, use --skip-connection-check.`;
574 +
575 + it.each([
576 + {
577 + name: '`login --poll` without a pending login',
578 + args: ['login', '--poll'],
579 + setup: {},
580 + server: fakeComposio,
581 + tag: 'PendingLoginError',
582 + message: 'No pending login found. Run `composio login < /dev/null` first.',
583 + },
584 + {
585 + name: '`execute --file` for a tool without a file input',
586 + args: ['execute', 'GMAIL_FETCH_EMAILS', '--file', 'report.pdf', '-d', '{}'],
587 + setup: {},
588 + server: fakeComposio,
589 + tag: 'ToolExecutionError',
590 + message:
591 + 'Tool "GMAIL_FETCH_EMAILS" has no file_uploadable input. Remove --file or pass JSON via -d.',
592 + },
593 + {
594 + name: '`proxy` without a consumer user',
595 + args: [
596 + 'proxy',
597 + 'https://gmail.googleapis.com/gmail/v1/users/me/profile',
598 + '--toolkit',
599 + 'gmail',
600 + ],
601 + setup: {},
602 + server: withoutConsumerUser,
603 + tag: 'ProxyCommandError',
604 + message: 'No consumer project user is available for proxy execution in this context.',
605 + },
606 + ])(
607 + '[Given] $name [Then] prints the message without the banner and exits 1',
608 + ({ args, setup, server, tag, message }) =>
609 + withHttpServer(server, async baseUrl => {
610 + const result = await runCliAgainst(baseUrl, args, setup);
611 +
612 + expect(result.status).toBe(1);
613 + expect(result.stdout).toBe('');
614 + expect(result.stderr.trim()).toBe(message);
615 + expect(result.stderr).not.toContain('💥');
616 + expect(result.stderr).not.toContain(tag);
617 + expect(result.stderr).not.toContain('composio-cli');
618 + }),
619 + 30_000
620 + );
621 +
622 + it.each([
623 + {
624 + name: '`execute` with a toolkit that is not connected',
625 + args: ['execute', 'GMAIL_FETCH_EMAILS', '-d', '{}'],
626 + },
627 + {
628 + name: '`proxy` with a toolkit that is not connected',
629 + args: [
630 + 'proxy',
631 + 'https://gmail.googleapis.com/gmail/v1/users/me/profile',
632 + '--toolkit',
633 + 'gmail',
634 + ],
635 + },
636 + ])(
637 + '[Given] $name [Then] prints only the failed result and exits 1',
638 + ({ args }) =>
639 + withHttpServer(fakeComposio, async baseUrl => {
640 + const result = await runCliAgainst(baseUrl, args, noConnectedToolkits);
641 +
642 + expect(result.status).toBe(1);
643 + expect(JSON.parse(result.stdout)).toMatchObject({
644 + successful: false,
645 + error: notConnected('gmail'),
646 + });
647 + expect(result.stderr).toBe('');
648 + }),
649 + 30_000
650 + );
651 +});
ts/packages/cli/test/src/commands/errors.test.ts new
+177
@@ -0,0 +1,177 @@
1 +import { Predicate } from 'effect';
2 +import { describe, expect, it } from 'vitest';
3 +import {
4 + ConnectionPollingError,
5 + MissingLinkUserIdError,
6 +} from 'src/commands/connected-accounts/link/connected-accounts.link.errors';
7 +import { commandInputError, isUsageFailure, notLoggedIn } from 'src/commands/errors';
8 +import { InvalidOrganizationError } from 'src/commands/login/login.errors';
9 +import { ProxyCommandError, ReportedProxyCommandError } from 'src/commands/proxy.cmd';
10 +import {
11 + ReportedToolExecutionError,
12 + ToolExecutionError,
13 +} from 'src/commands/tools/commands/tools.execute.cmd';
14 +import { LoginSessionError } from 'src/effects/browser-login';
15 +import { ExpectedFailure } from 'src/effects/expected-failure';
16 +import { ComposioCorePkgNotFound } from 'src/effects/find-composio-core-generated';
17 +import {
18 + InvalidToolkitVersionsValidationError,
19 + ToolkitVersionValidationError,
20 +} from 'src/effects/validate-toolkit-versions';
21 +import { ProjectResolutionError } from 'src/services/command-project';
22 +import { ConnectedAccountResolutionError } from 'src/services/connected-account-selection';
23 +import { PendingLoginError } from 'src/services/pending-login-session';
24 +import { ProjectEnvironmentDetectorError } from 'src/services/project-environment-detector';
25 +
26 +const expected = [
27 + { name: 'a usage mistake', error: commandInputError('execute')('Bad flag.', '--flag') },
28 + { name: 'a missing login', error: notLoggedIn() },
29 + {
30 + name: 'an unresolved project',
31 + error: new ProjectResolutionError({ reason: 'missing_org', message: 'No current org.' }),
32 + },
33 + {
34 + name: 'an --account that matches no connected account',
35 + error: new ConnectedAccountResolutionError({ message: 'No match.', toolkitSlug: 'gmail' }),
36 + },
37 + {
38 + name: 'execute without a user id',
39 + error: new ToolExecutionError({ reason: 'missing_user_id', message: 'Missing user id.' }),
40 + },
41 + {
42 + name: 'execute with a --file the tool cannot take',
43 + error: new ToolExecutionError({ reason: 'file_input', message: 'No file input.' }),
44 + },
45 + {
46 + name: 'execute with a toolkit that is not connected',
47 + error: new ToolExecutionError({ reason: 'connection_check', message: 'Not connected.' }),
48 + },
49 + {
50 + name: 'proxy without a consumer user',
51 + error: new ProxyCommandError({ message: 'No user.' }),
52 + },
53 + {
54 + name: 'link without a user id',
55 + error: new MissingLinkUserIdError({ message: 'Missing user id.', flow: 'list' }),
56 + },
57 + {
58 + name: 'link with an authorization not finished in time',
59 + error: new ConnectionPollingError({
60 + message: "Connection status is still 'INITIATED', waiting for 'ACTIVE'",
61 + connectedAccountId: 'ca_1',
62 + status: 'INITIATED',
63 + }),
64 + },
65 + {
66 + name: 'login with an unknown --org',
67 + error: new InvalidOrganizationError({ message: 'Invalid organization.', requestedOrg: 'x' }),
68 + },
69 + {
70 + name: 'login with an expired session',
71 + error: new LoginSessionError({ message: 'Session not found.', operation: 'load' }),
72 + },
73 + {
74 + name: 'login --poll without a pending login',
75 + error: new PendingLoginError({ message: 'No pending login found.', reason: 'missing' }),
76 + },
77 + {
78 + name: 'login --poll with an expired pending login',
79 + error: new PendingLoginError({ message: 'Pending login expired.', reason: 'expired' }),
80 + },
81 + {
82 + name: 'generate without @composio/core installed',
83 + error: new ComposioCorePkgNotFound({
84 + message: '@composio/core not found',
85 + cause: '@composio/core not installed',
86 + }),
87 + },
88 + {
89 + name: 'generate outside a recognizable project',
90 + error: new ProjectEnvironmentDetectorError({
91 + cause: new Error('No project language detected'),
92 + message: 'No recognizable project indicators found.',
93 + checkedPaths: [],
94 + }),
95 + },
96 + {
97 + name: 'a toolkit version override naming an unknown version',
98 + error: new InvalidToolkitVersionsValidationError([
99 + { toolkit: 'gmail', requestedVersion: 'nope', availableVersions: ['20260101_00'] },
100 + ]),
101 + },
102 + {
103 + name: 'a toolkit version override naming an unknown toolkit',
104 + error: new ToolkitVersionValidationError({
105 + message: 'Invalid toolkit(s) in version overrides: gmal.',
106 + reason: 'invalid-toolkit',
107 + }),
108 + },
109 +];
110 +
111 +const defects = [
112 + {
113 + name: 'a toolkit version check whose request failed',
114 + error: new ToolkitVersionValidationError({ message: 'Failed.', reason: 'request' }),
115 + },
116 + {
117 + name: 'a toolkit version check whose response did not decode',
118 + error: new ToolkitVersionValidationError({ message: 'Failed.', reason: 'decode' }),
119 + },
120 + {
121 + name: 'a toolkit version check without a client',
122 + error: new ToolkitVersionValidationError({
123 + message: 'API client not initialized',
124 + reason: 'client-unavailable',
125 + }),
126 + },
127 + {
128 + name: 'a pending login cache that cannot be read',
129 + error: new PendingLoginError({
130 + message: 'Failed to read pending login cache',
131 + reason: 'io',
132 + cause: new Error('EACCES'),
133 + }),
134 + },
135 + {
136 + name: 'a pending login cache that does not decode',
137 + error: new PendingLoginError({ message: 'Pending login cache is invalid', reason: 'invalid' }),
138 + },
139 + {
140 + name: 'an execute failure already printed',
141 + error: new ReportedToolExecutionError({ reason: 'execution_failed', message: 'Failed.' }),
142 + },
143 + {
144 + name: 'a proxy failure already printed',
145 + error: new ReportedProxyCommandError({
146 + message: 'Not connected.',
147 + toolkit: 'gmail',
148 + endpoint: 'https://gmail.googleapis.com',
149 + }),
150 + },
151 + { name: 'a plain Error', error: new Error('boom') },
152 +];
153 +
154 +describe('isUsageFailure', () => {
155 + it.each(expected)('[Given] $name [Then] it is a usage failure', ({ error }) => {
156 + expect(isUsageFailure(error)).toBe(true);
157 + });
158 +
159 + it.each(defects)('[Given] $name [Then] it is not a usage failure', ({ error }) => {
160 + expect(isUsageFailure(error)).toBe(false);
161 + });
162 +
163 + // The marker is a prototype getter: declaring it must not add an own property, which would
164 + // change the error's structural equality and what a reporter prints for it.
165 + it.each(expected)(
166 + '[Given] $name [Then] its class declares the marker off the instance',
167 + ({ error }) => {
168 + expect(Predicate.hasProperty(error, ExpectedFailure)).toBe(true);
169 + expect(Object.getOwnPropertySymbols(error)).not.toContain(ExpectedFailure);
170 + }
171 + );
172 +
173 + it('[Given] an object that only claims the marker [Then] it still needs a string message', () => {
174 + expect(isUsageFailure({ [ExpectedFailure]: true })).toBe(false);
175 + expect(isUsageFailure({ [ExpectedFailure]: true, message: 'Fix it.' })).toBe(true);
176 + });
177 +});
ts/packages/cli/test/src/commands/login/login.handler.test.ts
+37 -2
@@ -1,4 +1,10 @@
1 -import { Auth, make, type ComposioClientShape, type NotFoundError } from '@composio/client/effect';
1 +import {
2 + APIConnectionError,
3 + Auth,
4 + make,
5 + type ComposioClientShape,
6 + type NotFoundError,
7 +} from '@composio/client/effect';
8 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
9 import * as BunPath from '@effect/platform-bun/BunPath';
10 import { describe, expect, it } from '@effect/vitest';
@@ -32,6 +38,7 @@ import { NodeProcess } from 'src/services/node-process';
38 import { ProjectContext } from 'src/services/project-context';
39 import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
40 import { ComposioUserContext } from 'src/services/user-context';
41 +import { isUsageFailure } from 'src/commands/errors';
42 import { MockConsole, ToolkitsTest } from 'test/__utils__';
43 import { notFoundError } from 'test/__utils__/layers/not-found';
44 import { mockAccountResources, type MockRequestScope } from 'test/__utils__/layers/accounts';
@@ -126,7 +133,7 @@ interface LoginFixture {
133 readonly orgId?: Option.Option<string>;
134 readonly pending?: Parameters<typeof PendingLoginSessionTest>[0];
135 /** What `getSession` answers; a failure stands for an unknown or expired session. */
129 - readonly session?: Effect.Effect<RetrievedSession, NotFoundError>;
136 + readonly session?: Effect.Effect<RetrievedSession, NotFoundError | APIConnectionError>;
137 }
138
139 // A resource the account mocks do not shadow reaches this transport and dies with its URL.
@@ -421,10 +428,38 @@ describe('handleSessionKeyLogin', () => {
428 operation: 'load',
429 message: SESSION_NOT_FOUND_MESSAGE,
430 });
431 + expect(isUsageFailure(error)).toBe(true);
432 expect(logins).toEqual([]);
433 }).pipe(Effect.provide(layer));
434 });
435
436 + it.effect(
437 + '[Given] the session lookup fails to connect [Then] keeps the cause and does not report an expired session',
438 + () => {
439 + const connectionError = new APIConnectionError({
440 + message: 'Connection error.',
441 + method: 'GET',
442 + url: 'https://mock.invalid',
443 + reason: 'TransportError',
444 + description: 'fetch failed: connect ECONNREFUSED 127.0.0.1:1',
445 + });
446 + const { layer, logins } = loginHandlerTest({ session: Effect.fail(connectionError) });
447 + return Effect.gen(function* () {
448 + const error = yield* Effect.flip(
449 + handleSessionKeyLogin({ key: 'session-key', noWait: true, noSkillInstall: true })
450 + );
451 +
452 + expect(error).toMatchObject({
453 + _tag: 'commands/LoginSessionRequestError',
454 + cause: connectionError,
455 + });
456 + expect(error.message).not.toBe(SESSION_NOT_FOUND_MESSAGE);
457 + expect(isUsageFailure(error)).toBe(false);
458 + expect(logins).toEqual([]);
459 + }).pipe(Effect.provide(layer));
460 + }
461 + );
462 +
463 it.effect(
464 '[Given] --no-wait and a session still pending [Then] reports it and stores nothing',
465 () => {
ts/packages/cli/test/src/commands/proxy.cmd.test.ts
+3 -3
@@ -10,7 +10,7 @@ import {
10 normalizeProxyMethod,
11 parseProxyBody,
12 parseProxyHeader,
13 - ProxyCommandError,
13 + ReportedProxyCommandError,
14 } from 'src/commands/proxy.cmd';
15 import * as consumerShortTermCache from 'src/services/consumer-short-term-cache';
16 import { cli, MockConsole, TestLive } from 'test/__utils__';
@@ -250,8 +250,8 @@ describe('CLI: composio proxy', () => {
250 }).pipe(Effect.provide(live));
251
252 expect(createCalled).toBe(false);
253 - expect(failure).toBeInstanceOf(ProxyCommandError);
254 - expect(failure).toMatchObject({ reason: 'toolkit_not_connected', toolkit: 'gmail' });
253 + expect(failure).toBeInstanceOf(ReportedProxyCommandError);
254 + expect(failure).toMatchObject({ toolkit: 'gmail' });
255
256 expect(output).toContain('Toolkit "gmail" is not connected for this user');
257 expect(output).toContain('composio link gmail');