@devries-cameron20 / composio Mirror · read-only / commits / 106799cb0
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, 09:45 UTC

refactor(cli): raise one `CommandInputError` for handler-level usage mistakes (#4890)

This PR: - builds on top of https://github.com/ComposioHQ/composio/pull/4887 (PR 2 of the command-layout series) - adds `CommandInputError` in `src/commands/errors.ts`, with `command`, `message`, and the `option` at fault, plus `commandInputError('<command>')` as the per-command constructor - replaces the thirteen message-only `commands/*` tagged errors (`LoginOptionError`, `LinkInputError`, `ListenOptionError`, `ConfigOptionError`, `TriggersListOptionError`, `ParallelExecuteArgumentError`, `ToolsSearchInputError`, `TypeScriptGenerationInputError`, `GenerateInputError`, `MissingRunSourceError`, `DangerousDeveloperCommandError`, `DeveloperModeError`, `DebugCommandError`) and their six local `invalidOptionValue`-style helpers with it - routes every usage mistake through the quiet path in `cli-main.ts` that until now only `composio run` had: the message prints as one line on stderr and the process exits 1, with no defect banner or stack - leaves the structured errors (`PendingLoginError`, `ListenCommandError`, `ProxyCommandError`, …), the `{ message, cause }` request wrappers, and `ShellSetupAbortError` untouched; those carry fields or an exit contract this error does not - updates the tests that matched on the old tags to match on `commands/CommandInputError` and, where it is set, the `option` ## Context `effect/cli`'s `CliError.InvalidValue` is a fixed option-and-value struct built only by the parser, so each command had grown its own message-only `Data.TaggedError` for validation that is only knowable after parsing. Twelve of those went through the defect reporter, which printed the tag name and a banner for what is a one-line usage fix. One shared class with one rendering path removes the per-command classes and makes the output consistent. The remaining PRs in the series move commands into the layout documented in #4887 one at a time.

Alberto Schiabel committed Oct 15, 2026 at 17:07 UTC 106799cb0513adb4d5fb4e423e4f2d6f4af4a2d8
27 files changed +160 -200
.agents/skills/cli-command/references/implementation.md
+1
@@ -16,6 +16,7 @@ test/src/commands/<group>/<name>/<group>.<name>.handler.test.ts handler-level
16
17 - Top-level commands use the same shape without a group: `src/commands/<name>/<name>.cmd.ts`.
18 - Register new commands through `src/commands/index.ts` or the nearest group entry.
19 +- A usage mistake the parser cannot see (flag combination, business rule, missing input) raises `CommandInputError` via `commandInputError('<command>')` from `src/commands/errors.ts`, with the `option` at fault; `cli-main.ts` prints the message and exits 1. Do not add a per-command message-only error class.
20 - A command still in the legacy single-file shape (`<group>/commands/<group>.<name>.cmd.ts`, or top-level `<name>.cmd.ts`) is migrated in the PR that next changes it substantively, one command per PR.
21 - `pnpm run validate:command-tests` (in `pnpm test`) fails on a command without its mirrored `.cmd.test.ts`, on an orphan `.cmd.test.ts`, and on a stale exemption. Add the test with the command; do not add exemptions.
22
ts/packages/cli/AGENTS.md
+3 -2
@@ -69,11 +69,12 @@ Every command is a directory named after the command, holding files that share t
69 src/commands/
70 index.ts root command tree, argv contract with cli-main.ts
71 $default.cmd.ts root command: shared flags and description
72 + errors.ts CommandInputError, the one usage error every command raises
73 <group>/<group>.cmd.ts group entry: Command.make(name) + withSubcommands, nothing else
74 <group>/<name>/<group>.<name>.cmd.ts flags, arguments, description, examples, Command.make
75 <group>/<name>/<group>.<name>.handler.ts (params) => Effect; imports nothing from effect/cli
76 <group>/<name>/<group>.<name>.format.ts human renderer (stderr) and machine renderer (stdout)
76 - <group>/<name>/<group>.<name>.errors.ts command-owned Data.TaggedError classes, when any
77 + <group>/<name>/<group>.<name>.errors.ts command-owned Data.TaggedError classes with structured fields, when any; usage errors use errors.ts
78 <group>/<shared-module>.ts helpers used by several commands of the group (triggers/parse.ts)
79 <name>/<name>.cmd.ts a top-level command follows the same shape without a group
80 ```
@@ -210,7 +211,7 @@ Each `Arr.bind` adds one independent axis to the generated cases.
211 - 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.
212 - 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.
213 - 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 pass `decode: false` and decode with the CLI schema, failing with `services/HttpDecodingError`. The client's generated schema validates a read only where the CLI consumes the whole response through the client's types and no field of it 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). Those three are the loader table in `src/services/composio-schema-loaders.ts`; a mismatch fails with the client's `DecodeError`. Every other typed call passes `undecoded` (`decode: false`): 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). A typed call with no loader and no `decode: false` fails before it is sent, so adding a client-decoded read means adding its loader to the table and 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).
213 -- 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 — commands that need a custom validation message raise a local `Data.TaggedError` instead (see `src/commands/login.cmd.ts`'s `LoginOptionError`) and let it flow through the existing `effect-errors` pretty-printer, not a hand-built `CliError`.
214 +- 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) and `cli-main.ts` prints its message as one line and exits 1, not a hand-built `CliError`.
215 - 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.
216
217 ### Effect Boundary Policy
ts/packages/cli/src/cli-main.ts
+4 -4
@@ -53,7 +53,7 @@ import { mapOnlyComposioOverrideError } from 'src/services/composio-error-overri
53 import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
54 import { SetupCommandError } from 'src/services/setup-command-error';
55 import { ShellSetupAbortError } from 'src/commands/install.cmd';
56 -import { MissingRunSourceError } from 'src/commands/run.cmd';
56 +import { CommandInputError } from 'src/commands/errors';
57 import { cliInvocationContext } from 'src/services/runtime-cli-context';
58 import { readTelemetryDebugOverride, telemetryDebugModeLayer } from 'src/services/runtime-flags';
59 import { normalizeRunScriptArgs } from 'src/commands/argv-compat';
@@ -263,10 +263,10 @@ const cliProgram = (argv: ReadonlyArray<string>) =>
263 process.exitCode = 1;
264 })
265 ),
266 - // A bare `composio run` is a usage mistake, not a broken invariant: print the one-line fix and
267 - // exit non-zero instead of routing it through the defect reporter below.
266 + // A usage mistake is not a broken invariant: print the one-line fix and exit non-zero
267 + // instead of routing it through the defect reporter below.
268 Effect.catchIf(
269 - (error): error is MissingRunSourceError => error instanceof MissingRunSourceError,
269 + (error): error is CommandInputError => error instanceof CommandInputError,
270 error =>
271 Effect.gen(function* () {
272 const ui = yield* TerminalUI;
ts/packages/cli/src/commands/config/config.experimental.cmd.ts
+4 -7
@@ -1,4 +1,5 @@
1 -import { Data, Effect, Option } from 'effect';
1 +import { commandInputError } from 'src/commands/errors';
2 +import { Effect, Option } from 'effect';
3 import { Argument, Command } from 'effect/cli';
4 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
5 import { TerminalUI } from 'src/services/terminal-ui';
@@ -10,9 +11,7 @@ import type { SkillFeatureFlag } from '../../../skills-src/composio-cli/referenc
11
12 const knownFeatures: ReadonlyArray<SkillFeatureFlag> = Object.values(CLI_EXPERIMENTAL_FEATURES);
13
13 -class ConfigOptionError extends Data.TaggedError('commands/ConfigOptionError')<{
14 - readonly message: string;
15 -}> {}
14 +const invalidState = commandInputError('config experimental');
15
16 const featureArg = Argument.String('feature').pipe(
17 Argument.withDescription(
@@ -104,9 +103,7 @@ export const configExperimentalCmd = Command.make(
103 const stateValue = state.value.toLowerCase();
104 if (stateValue !== 'on' && stateValue !== 'off') {
105 return yield* Effect.fail(
107 - new ConfigOptionError({
108 - message: `Invalid state "${state.value}". Use "on" or "off".`,
109 - })
106 + invalidState(`Invalid state "${state.value}". Use "on" or "off".`, '<state>')
107 );
108 }
109
ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
+5 -19
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
3 import { Data, Effect, Option, Schedule } from 'effect';
4 import type { ComposioClientShape } from '@composio/client/effect';
@@ -57,23 +58,7 @@ class BrowserOpenError extends Data.TaggedError('commands/BrowserOpenError')<{
58 readonly cause: unknown;
59 }> {}
60
60 -/**
61 - * Business-level validation failure for `link` inputs that are only
62 - * knowable after parsing (e.g. an `--alias` that is empty after trimming,
63 - * or an option combination that's invalid for this command variant).
64 - *
65 - * v3 raised these via `ValidationError.invalidValue`, which piggybacked on
66 - * `@effect/cli`'s parse-error rendering. v4's `CliError.InvalidValue` always
67 - * renders a fixed, option-specific template (see `CliError.ts`) that can't
68 - * carry a free-form message, so these are modeled as an ordinary typed
69 - * domain error instead and rendered through the same `effect-errors` path
70 - * as this file's other business errors (`ConnectionPollingError`, etc.).
71 - */
72 -class LinkInputError extends Data.TaggedError('commands/LinkInputError')<{
73 - readonly message: string;
74 -}> {}
75 -
76 -const invalidOptionValue = (message: string) => new LinkInputError({ message });
61 +const invalidOptionValue = commandInputError('link');
62
63 const toolkit = Argument.String('toolkit').pipe(
64 Argument.withDescription('Toolkit slug to link (e.g. "github", "gmail")'),
@@ -319,7 +304,7 @@ const resolveNormalizedAliasOption = (alias: Option.Option<string>) =>
304
305 const normalizedAlias = normalizeAlias(alias.value);
306 if (normalizedAlias.length === 0) {
322 - return yield* Effect.fail(invalidOptionValue('`--alias` cannot be empty.'));
307 + return yield* Effect.fail(invalidOptionValue('`--alias` cannot be empty.', '--alias'));
308 }
309
310 return Option.some(normalizedAlias);
@@ -806,7 +791,8 @@ const runConnectedAccountsLink = (params: {
791 if (Option.isSome(params.authConfig)) {
792 return yield* Effect.fail(
793 invalidOptionValue(
809 - 'Top-level `composio link` is consumer-only and does not accept `--auth-config`. Use `composio dev connected-accounts link --auth-config ...` for developer-scoped usage.'
794 + 'Top-level `composio link` is consumer-only and does not accept `--auth-config`. Use `composio dev connected-accounts link --auth-config ...` for developer-scoped usage.',
795 + '--auth-config'
796 )
797 );
798 }
ts/packages/cli/src/commands/debug.cmd.ts
+5 -8
@@ -1,5 +1,6 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Command } from 'effect/cli';
2 -import { Data, Effect, Option } from 'effect';
3 +import { Effect, Option } from 'effect';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { renderCommandHintGraph } from 'src/services/command-hints';
6 import { ComposioUserContext } from 'src/services/user-context';
@@ -9,9 +10,7 @@ import {
10 resolveCommandProject,
11 } from 'src/services/command-project';
12
12 -class DebugCommandError extends Data.TaggedError('commands/DebugCommandError')<{
13 - readonly message: string;
14 -}> {}
13 +const debugError = commandInputError('debug');
14
15 const printCommandHintGraph = Effect.suspend(() =>
16 Effect.flatMap(TerminalUI, ui =>
@@ -26,14 +25,12 @@ const printDebugApiInfo = Effect.gen(function* () {
25 { defaultValue: false }
26 );
27 if (!confirmed) {
29 - return yield* new DebugCommandError({ message: 'Aborted printing API credentials.' });
28 + return yield* debugError('Aborted printing API credentials.');
29 }
30 const ctx = yield* ComposioUserContext;
31 const apiKey = Option.getOrUndefined(ctx.data.apiKey);
32 if (!apiKey) {
34 - return yield* new DebugCommandError({
35 - message: 'No user API key found in the current CLI session.',
36 - });
33 + return yield* debugError('No user API key found in the current CLI session.');
34 }
35 const orgId = Option.getOrUndefined(ctx.data.orgId);
36 const consumerProject = yield* resolveCommandProject({ mode: 'consumer' }).pipe(
ts/packages/cli/src/commands/dev.cmd.ts
+5 -6
@@ -1,5 +1,6 @@
1 import { Command, Flag } from 'effect/cli';
2 -import { Data, Effect, Option } from 'effect';
2 +import { Effect, Option } from 'effect';
3 +import { CommandInputError } from './errors';
4 import { initCmd } from './init.cmd';
5 import { triggersCmd$Listen } from './triggers/commands/triggers.listen.cmd';
6 import { logsCmd } from './logs/logs.cmd';
@@ -31,10 +32,6 @@ export const devSubcommands = [
32 projectsCmd,
33 ] as const;
34
34 -export class DeveloperModeError extends Data.TaggedError('commands/DeveloperModeError')<{
35 - readonly message: string;
36 -}> {}
37 -
35 const describeCurrentMode = (enabled: boolean) =>
36 enabled
37 ? 'Developer mode is on. Developer subcommands are available.'
@@ -54,7 +51,9 @@ const applyDeveloperModeChange = (enabled: boolean) =>
51 if (enabled) {
52 if (!stdin.isTTY()) {
53 const configPath = yield* resolveCliConfigPath;
57 - return yield* new DeveloperModeError({
54 + return yield* new CommandInputError({
55 + command: 'dev',
56 + option: '--mode',
57 message: `Enabling developer mode requires an interactive terminal. Set "developer.enabled": true in ${configPath} to enable it outside an interactive session.`,
58 });
59 }
ts/packages/cli/src/commands/errors.ts new
+22
@@ -0,0 +1,22 @@
1 +import { Data } from 'effect';
2 +
3 +/**
4 + * A usage mistake the parser cannot see: a flag combination, a value that fails a business
5 + * rule, a missing input, or an environment the command cannot run in. `effect/cli`'s
6 + * `CliError.InvalidValue` is a fixed option-and-value struct built only by the parser, so
7 + * handler-level validation raises this instead. `cli-main.ts` prints `message` as one line
8 + * and exits 1, with no defect banner.
9 + */
10 +export class CommandInputError extends Data.TaggedError('commands/CommandInputError')<{
11 + /** The command path without `composio`, e.g. `login` or `dev triggers disable`. */
12 + readonly command: string;
13 + readonly message: string;
14 + /** The flag or argument at fault, e.g. `--alias` or `<toolkit>`, when there is one. */
15 + readonly option?: string | undefined;
16 +}> {}
17 +
18 +/** Builds the constructor a command uses for its own input errors. */
19 +export const commandInputError =
20 + (command: string) =>
21 + (message: string, option?: string): CommandInputError =>
22 + new CommandInputError({ command, message, option });
ts/packages/cli/src/commands/listen.cmd.ts
+18 -12
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
3 import * as FileSystem from 'effect/FileSystem';
4 import * as Path from 'effect/Path';
@@ -44,11 +45,7 @@ export class ListenCommandError extends Data.TaggedError('commands/ListenCommand
45 readonly cause?: unknown;
46 }> {}
47
47 -class ListenOptionError extends Data.TaggedError('commands/ListenOptionError')<{
48 - readonly message: string;
49 -}> {}
50 -
51 -const invalidOptionValue = (message: string) => new ListenOptionError({ message });
48 +const invalidOptionValue = commandInputError('listen');
49
50 const errorMessage = (error: unknown): string =>
51 Predicate.isError(error) ? error.message : String(error);
@@ -134,7 +131,8 @@ const parseCreateParams = (raw: string) =>
131 invalidOptionValue(
132 error.reason === 'not-a-record'
133 ? "Expected --params to be an object, e.g. -p '{ trigger_config: { ... } }'."
137 - : "Invalid --params input. Provide JSON or a JS-style object literal, e.g. -p '{ trigger_config: { ... } }'."
134 + : "Invalid --params input. Provide JSON or a JS-style object literal, e.g. -p '{ trigger_config: { ... } }'.",
135 + '--params'
136 )
137 )
138 );
@@ -147,7 +145,8 @@ const assertSupportedListenParams = (params: {
145 params.listeningToProjectEvent && Object.keys(params.createParamsInput).length > 0
146 ? Effect.fail(
147 invalidOptionValue(
150 - `--params is only supported for trigger slugs. "${params.slug}" is a project-level composio.* event type and does not create a temporary trigger.`
148 + `--params is only supported for trigger slugs. "${params.slug}" is a project-level composio.* event type and does not create a temporary trigger.`,
149 + '--params'
150 )
151 )
152 : Effect.void;
@@ -194,7 +193,8 @@ const resolveConnectedAccountIdForTrigger = (params: {
193 if (!toolkitSlug) {
194 return yield* Effect.fail(
195 invalidOptionValue(
197 - `Could not infer a toolkit from trigger slug "${params.slug}". Use a standard trigger slug such as "GMAIL_NEW_GMAIL_MESSAGE", or a project event type such as "composio.connected_account.expired".`
196 + `Could not infer a toolkit from trigger slug "${params.slug}". Use a standard trigger slug such as "GMAIL_NEW_GMAIL_MESSAGE", or a project event type such as "composio.connected_account.expired".`,
197 + '<slug>'
198 )
199 );
200 }
@@ -284,7 +284,10 @@ const parseStreamPath = (expression: string) =>
284 const trimmed = expression.trim();
285 if (!trimmed.startsWith('.')) {
286 return yield* Effect.fail(
287 - invalidOptionValue('Expected --stream to contain a jq-like path starting with "."')
287 + invalidOptionValue(
288 + 'Expected --stream to contain a jq-like path starting with "."',
289 + '--stream'
290 + )
291 );
292 }
293
@@ -296,7 +299,8 @@ const parseStreamPath = (expression: string) =>
299 if ((match.index ?? -1) !== lastIndex) {
300 return yield* Effect.fail(
301 invalidOptionValue(
299 - 'Unsupported --stream expression. Use a jq-like path such as ".foo.bar" or ".items[0].id".'
302 + 'Unsupported --stream expression. Use a jq-like path such as ".foo.bar" or ".items[0].id".',
303 + '--stream'
304 )
305 );
306 }
@@ -309,7 +313,8 @@ const parseStreamPath = (expression: string) =>
313 if (lastIndex !== trimmed.length) {
314 return yield* Effect.fail(
315 invalidOptionValue(
312 - 'Unsupported --stream expression. Use a jq-like path such as ".foo.bar" or ".items[0].id".'
316 + 'Unsupported --stream expression. Use a jq-like path such as ".foo.bar" or ".items[0].id".',
317 + '--stream'
318 )
319 );
320 }
@@ -395,7 +400,8 @@ const parseTimeoutMs = (value: string) =>
400 if (!match || !Number.isFinite(amount) || amount <= 0 || unitMs === undefined) {
401 return yield* Effect.fail(
402 invalidOptionValue(
398 - 'Invalid --timeout value. Use a duration such as "30s", "5m", "1hr", or "1day".'
403 + 'Invalid --timeout value. Use a duration such as "30s", "5m", "1hr", or "1day".',
404 + '--timeout'
405 )
406 );
407 }
ts/packages/cli/src/commands/login.cmd.ts
+9 -20
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Command, Flag } from 'effect/cli';
3 import * as FileSystem from 'effect/FileSystem';
4 import * as Path from 'effect/Path';
@@ -118,22 +119,7 @@ class InvalidOrganizationError extends Data.TaggedError('commands/InvalidOrganiz
119 readonly requestedOrg: string;
120 }> {}
121
121 -class LoginOptionError extends Data.TaggedError('commands/LoginOptionError')<{
122 - readonly message: string;
123 -}> {}
124 -
125 -/**
126 - * v4 migration note: v3's `ValidationError.invalidValue(HelpDoc.p(message))` produced a value
127 - * that `@effect/cli`'s `Command.run` printed to stderr and mapped to exit code 1 itself.
128 - * `effect/cli`'s `CliError.InvalidValue` is now a fixed flag/argument-name-and-value
129 - * struct (see `CliError.ts`) built by the parser, not a freeform validation message constructor,
130 - * and `Command.runWith` only renders errors it produces during parsing — it does not intercept or
131 - * render failures raised from inside a command handler. A plain typed domain error (matching the
132 - * `LoginSessionError`/`PendingLoginError` pattern already used in this file) instead flows through
133 - * the CLI's normal `effect-errors` renderer at the top level (see `cli-main.ts`), so this must not
134 - * print the message itself — that would double-print alongside that renderer.
135 - */
136 -const invalidOptionValue = (message: string) => new LoginOptionError({ message });
122 +const invalidOptionValue = commandInputError('login');
123
124 const pendingLoginPath = Effect.gen(function* () {
125 const path = yield* Path.Path;
@@ -907,23 +893,26 @@ export const loginCmd = Command.make(
893 (noBrowser || noWait || Option.isSome(key) || Option.isSome(userApiKey) || agent)
894 ) {
895 return yield* invalidOptionValue(
910 - '`--poll` cannot be combined with browser, session, direct-login, or agent flags.'
896 + '`--poll` cannot be combined with browser, session, direct-login, or agent flags.',
897 + '--poll'
898 );
899 }
900
901 if (agent && (noBrowser || noWait || Option.isSome(key) || Option.isSome(userApiKey))) {
902 return yield* invalidOptionValue(
916 - '`--agent` cannot be combined with browser, session, or direct-login flags.'
903 + '`--agent` cannot be combined with browser, session, or direct-login flags.',
904 + '--agent'
905 );
906 }
907
908 if (Option.isSome(org) && Option.isNone(userApiKey)) {
921 - return yield* invalidOptionValue('`--org` requires `--user-api-key`.');
909 + return yield* invalidOptionValue('`--org` requires `--user-api-key`.', '--org');
910 }
911
912 if (Option.isSome(userApiKey) && (noBrowser || noWait || Option.isSome(key))) {
913 return yield* invalidOptionValue(
926 - '`--user-api-key` is a direct login path and cannot be combined with browser or session flags.'
914 + '`--user-api-key` is a direct login path and cannot be combined with browser or session flags.',
915 + '--user-api-key'
916 );
917 }
918
ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
+6 -14
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Command, Flag } from 'effect/cli';
3 import { Array, Data, Effect, Option, pipe, String } from 'effect';
4 import * as FileSystem from 'effect/FileSystem';
@@ -23,18 +24,7 @@ export class PythonGenerationWriteError extends Data.TaggedError(
24 readonly message: string;
25 }> {}
26
26 -/**
27 - * Business-level validation failure for `generate py` inputs (output
28 - * directory location, toolkit filter values) that are only knowable after
29 - * parsing. See the analogous comment on `LinkInputError` in
30 - * `connected-accounts.link.cmd.ts` for why this is a plain typed domain
31 - * error rather than a `CliError.InvalidValue` in v4.
32 - */
33 -class GenerateInputError extends Data.TaggedError('commands/GenerateInputError')<{
34 - readonly message: string;
35 -}> {}
36 -
37 -const invalidGenerateValue = (message: string) => new GenerateInputError({ message });
27 +const invalidGenerateValue = commandInputError('generate py');
28
29 export const outputOpt = Flag.optional(Flag.Directory('output-dir')).pipe(
30 Flag.withAlias('o'),
@@ -85,7 +75,8 @@ export function generatePythonTypeStubs({
75 if (normalizedPath.includes('node_modules')) {
76 return Effect.fail(
77 invalidGenerateValue(
88 - 'Output directory cannot be inside node_modules. Please specify a different directory.'
78 + 'Output directory cannot be inside node_modules. Please specify a different directory.',
79 + '--output-dir'
80 )
81 );
82 }
@@ -123,7 +114,8 @@ export function generatePythonTypeStubs({
114 Effect.fail(
115 invalidGenerateValue(
116 `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. ` +
126 - `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`
117 + `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`,
118 + '--toolkits'
119 )
120 )
121 )
ts/packages/cli/src/commands/run.cmd.ts
+6 -8
@@ -1,3 +1,4 @@
1 +import { CommandInputError } from 'src/commands/errors';
2 import process from 'node:process';
3 import { Argument, Command, Flag } from 'effect/cli';
4 import * as FileSystem from 'effect/FileSystem';
@@ -196,16 +197,15 @@ const createRunHelpersPreloadFile = (
197 * An ordinary usage mistake rather than a broken invariant, so it is a typed failure with a
198 * one-line message instead of a defect: the caller sees the fix, not a stack trace.
199 */
199 -export class MissingRunSourceError extends Data.TaggedError('commands/MissingRunSourceError')<{
200 - readonly message: string;
201 -}> {}
202 -
200 const MISSING_RUN_SOURCE_MESSAGE = [
201 'Provide inline code or use --file to run a script file.',
202 ` composio run 'console.log(1)'`,
203 ' composio run --file ./script.ts',
204 ].join('\n');
205
206 +const missingRunSource = () =>
207 + new CommandInputError({ command: 'run', message: MISSING_RUN_SOURCE_MESSAGE });
208 +
209 export const buildRunCommand = ({
210 path,
211 file,
@@ -260,7 +260,7 @@ export const buildRunCommand = ({
260 };
261 }
262
263 - return yield* Effect.fail(new MissingRunSourceError({ message: MISSING_RUN_SOURCE_MESSAGE }));
263 + return yield* Effect.fail(missingRunSource());
264 });
265
266 const resolveRunHelperContext = () =>
@@ -449,9 +449,7 @@ export const runCmd = Command.make('run', {
449 // Checked before any setup work so a bare `composio run` neither creates a run-artifacts
450 // directory nor advertises a log file for a script that will never start.
451 if (Option.isNone(file) && !args[0]) {
452 - return yield* Effect.fail(
453 - new MissingRunSourceError({ message: MISSING_RUN_SOURCE_MESSAGE })
454 - );
452 + return yield* Effect.fail(missingRunSource());
453 }
454
455 const fs = yield* FileSystem.FileSystem;
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+3 -13
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
3 import util from 'node:util';
4 import { Data, Effect, Context, Option, Result } from 'effect';
@@ -131,19 +132,8 @@ const resolveInput = (input: Option.Option<string>) =>
132 missingValue: '{}',
133 });
134
134 -/**
135 - * Business-error type for the hand-rolled `--parallel` mini-parser
136 - * (`parseParallelExecuteArgs` below), not a `Command`-level parse failure —
137 - * v4's `CliError.InvalidValue` requires structured `option`/`kind` fields
138 - * that don't fit this free-text validation.
139 - */
140 -export class ParallelExecuteArgumentError extends Data.TaggedError(
141 - 'commands/ParallelExecuteArgumentError'
142 -)<{
143 - readonly message: string;
144 -}> {}
145 -
146 -const invalidArguments = (message: string) => new ParallelExecuteArgumentError({ message });
135 +// Also raised by the hand-rolled `--parallel` mini-parser (`parseParallelExecuteArgs` below).
136 +const invalidArguments = commandInputError('execute');
137
138 type ToolExecutionErrorFields = {
139 readonly reason:
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+7 -13
@@ -1,3 +1,4 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
3 import type { SessionSearchResponse } from '@composio/client/resources/tool-router';
4 import { Data, Effect, Option } from 'effect';
@@ -73,10 +74,7 @@ type SearchResponseRecord = Pick<
74 'results' | 'toolkit_connection_statuses' | 'tool_schemas' | 'next_steps_guidance' | 'error'
75 >;
76
76 -export class ToolsSearchInputError extends Data.TaggedError('commands/ToolsSearchInputError')<{
77 - readonly reason: 'missing_query' | 'missing_user_id';
78 - readonly message: string;
79 -}> {}
77 +const invalidSearchInput = commandInputError('search');
78
79 class ToolsSearchRequestError extends Data.TaggedError('commands/ToolsSearchRequestError')<{
80 readonly message: string;
@@ -317,10 +315,7 @@ const runToolsSearch = (params: {
315 const emitJson = params.json || !emitHuman;
316 const queries = params.query.map(q => q.trim()).filter(Boolean);
317 if (queries.length === 0) {
320 - return yield* new ToolsSearchInputError({
321 - reason: 'missing_query',
322 - message: 'At least one query is required.',
323 - });
318 + return yield* invalidSearchInput('At least one query is required.', '<query>');
319 }
320 const toolkitFilter = Option.getOrUndefined(params.toolkits);
321 const toolkitList =
@@ -344,11 +339,10 @@ const runToolsSearch = (params: {
339 onNone: () => userContext.data.testUserId,
340 });
341 if (Option.isNone(resolvedUserId)) {
347 - return yield* new ToolsSearchInputError({
348 - reason: 'missing_user_id',
349 - message:
350 - 'Missing user id. Provide --user-id or run composio login to set global test_user_id.',
351 - });
342 + return yield* invalidSearchInput(
343 + 'Missing user id. Provide --user-id or run composio login to set global test_user_id.',
344 + '--user-id'
345 + );
346 }
347 const clientSingleton = yield* ComposioClientSingleton;
348 const client = yield* clientSingleton.getFor({
ts/packages/cli/src/commands/triggers/commands/triggers.disable.cmd.ts
+10 -12
@@ -1,5 +1,6 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
2 -import { Data, Effect, Option } from 'effect';
3 +import { Effect, Option } from 'effect';
4 import { requireAuth } from 'src/effects/require-auth';
5 import { handleClientApiError } from 'src/effects/handle-http-error';
6 import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
@@ -12,9 +13,7 @@ const id = Argument.String('id').pipe(
13 Argument.optional
14 );
15
15 -export class DangerousDeveloperCommandError extends Data.TaggedError(
16 - 'commands/DangerousDeveloperCommandError'
17 -)<{ readonly message: string }> {}
16 +const notAllowed = commandInputError('dev triggers disable');
17
18 const dangerouslyAllow = Flag.Boolean('dangerously-allow').pipe(
19 Flag.withDescription('Acknowledge disabling this trigger instance'),
@@ -31,16 +30,15 @@ export const triggersCmd$Disable = Command.make(
30 Effect.gen(function* () {
31 const config = yield* ComposioCliUserConfig;
32 if (!config.areDeveloperDangerousCommandsEnabled()) {
34 - return yield* new DangerousDeveloperCommandError({
35 - message:
36 - 'This developer command is disabled by config. Set developer.destructive_actions to true in ~/.composio/config.json to allow it.',
37 - });
33 + return yield* notAllowed(
34 + 'This developer command is disabled by config. Set developer.destructive_actions to true in ~/.composio/config.json to allow it.'
35 + );
36 }
37 if (!dangerouslyAllow) {
40 - return yield* new DangerousDeveloperCommandError({
41 - message:
42 - 'This developer command requires explicit acknowledgement. Re-run with --dangerously-allow.',
43 - });
38 + return yield* notAllowed(
39 + 'This developer command requires explicit acknowledgement. Re-run with --dangerously-allow.',
40 + '--dangerously-allow'
41 + );
42 }
43 if (!(yield* requireAuth)) return;
44
ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts
+7 -7
@@ -1,5 +1,6 @@
1 +import { commandInputError } from 'src/commands/errors';
2 import { Argument, Command, Flag } from 'effect/cli';
2 -import { Data, Effect } from 'effect';
3 +import { Effect } from 'effect';
4 import { requireAuth } from 'src/effects/require-auth';
5 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 import { TerminalUI } from 'src/services/terminal-ui';
@@ -11,9 +12,7 @@ type TriggersListCommandConfig = {
12 readonly infoCommand: string;
13 };
14
14 -class TriggersListOptionError extends Data.TaggedError('commands/TriggersListOptionError')<{
15 - readonly message: string;
16 -}> {}
15 +const invalidToolkit = commandInputError('triggers list');
16
17 const toolkit = Argument.String('toolkit').pipe(
18 Argument.withDescription('Toolkit slug to list trigger types for (e.g. "gmail")')
@@ -48,9 +47,10 @@ const makeTriggersListCommand = ({ noResultsCommand, infoCommand }: TriggersList
47 const availableExample = error.availableToolkits.slice(0, 8).join(', ');
48 yield* ui.log.step(`List valid toolkits with:\n> ${noResultsCommand}`);
49 return yield* Effect.fail(
51 - new TriggersListOptionError({
52 - message: `Toolkit "${toolkit}" is not available. ${availableExample ? `Examples: ${availableExample}` : ''}`,
53 - })
50 + invalidToolkit(
51 + `Toolkit "${toolkit}" is not available. ${availableExample ? `Examples: ${availableExample}` : ''}`,
52 + '<toolkit>'
53 + )
54 );
55 })
56 )
ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+8 -13
@@ -40,6 +40,7 @@ import {
40 } from 'src/effects/toolkit-version-overrides';
41 import { validateToolkitVersionOverrides } from 'src/effects/validate-toolkit-versions';
42 import { TerminalUI, type SpinnerHandle } from 'src/services/terminal-ui';
43 +import { CommandInputError, commandInputError } from 'src/commands/errors';
44
45 export class TypeScriptGenerationWriteError extends Data.TaggedError(
46 'commands/TypeScriptGenerationWriteError'
@@ -49,13 +50,7 @@ export class TypeScriptGenerationWriteError extends Data.TaggedError(
50 readonly message: string;
51 }> {}
52
52 -export class TypeScriptGenerationInputError extends Data.TaggedError(
53 - 'commands/TypeScriptGenerationInputError'
54 -)<{
55 - readonly message: string;
56 -}> {}
57 -
58 -const invalidGenerateValue = (message: string) => new TypeScriptGenerationInputError({ message });
53 +const invalidGenerateValue = commandInputError('generate ts');
54
55 export const outputOpt = Flag.optional(Flag.Directory('output-dir')).pipe(
56 Flag.withAlias('o'),
@@ -123,7 +118,7 @@ function fetchFilteredData(
118 typeTools: boolean,
119 versionOverrides: ToolkitVersionOverrides,
120 spinner: SpinnerHandle
126 -): Effect.Effect<FetchResult, Error | TypeScriptGenerationInputError, never> {
121 +): Effect.Effect<FetchResult, Error | CommandInputError, never> {
122 return Effect.gen(function* () {
123 yield* spinner.message(`Fetching data for ${slugs.length} toolkit(s): ${slugs.join(', ')}...`);
124
@@ -144,7 +139,8 @@ function fetchFilteredData(
139 Effect.catchTag('services/InvalidToolkitsError', error =>
140 Effect.fail(
141 invalidGenerateValue(
147 - `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. Toolkit not found.`
142 + `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. Toolkit not found.`,
143 + '--toolkits'
144 )
145 )
146 )
@@ -327,9 +323,7 @@ function fetchAllData(
323 /**
324 * Validates that the output directory is not inside node_modules
325 */
330 -function validateOutputDir(
331 - outputDir: string
332 -): Effect.Effect<string, TypeScriptGenerationInputError, Path.Path> {
326 +function validateOutputDir(outputDir: string): Effect.Effect<string, CommandInputError, Path.Path> {
327 return Effect.gen(function* () {
328 const path = yield* Path.Path;
329 const normalizedPath = path.normalize(outputDir);
@@ -337,7 +331,8 @@ function validateOutputDir(
331 if (normalizedPath.includes('node_modules')) {
332 return yield* Effect.fail(
333 invalidGenerateValue(
340 - 'Output directory cannot be inside node_modules. Please specify a different directory.'
334 + 'Output directory cannot be inside node_modules. Please specify a different directory.',
335 + '--output-dir'
336 )
337 );
338 }
ts/packages/cli/test/src/commands/config/config.experimental.cmd.test.ts
+2 -1
@@ -122,7 +122,8 @@ layer(TestLive())('config experimental state validation', it => {
122 if (Exit.isFailure(exit)) {
123 const failure = Cause.squash(exit.cause);
124 expect(failure).toMatchObject({
125 - _tag: 'commands/ConfigOptionError',
125 + _tag: 'commands/CommandInputError',
126 + option: '<state>',
127 message: 'Invalid state "sometimes". Use "on" or "off".',
128 });
129 }
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.link.cmd.test.ts
+5 -6
@@ -300,17 +300,16 @@ describe('CLI: composio dev connected-accounts link', () => {
300 fixture: 'global-test-user-id',
301 })
302 )('[Given] a blank --alias [Then] fails with a CLI validation error', it => {
303 - // v4 migration note: `effect/cli`'s `CliError.InvalidValue` is a fixed
304 - // flag/argument-name-and-value struct produced only by the parser; it can't carry a
305 - // freeform message. This business-level validation (only knowable after parsing) is
306 - // now a plain typed domain error (`LinkInputError`), matching the pattern documented in
307 - // `connected-accounts.link.cmd.ts`.
303 + // Business-level validation (only knowable after parsing) raises `CommandInputError`;
304 + // see `src/commands/errors.ts`.
305 it.effect('reports the invalid option value before making a link request', () =>
306 Effect.gen(function* () {
307 const error = yield* cli(['link', 'gmail', '--alias', ' ']).pipe(Effect.flip);
308
309 expect(error).toMatchObject({
313 - _tag: 'commands/LinkInputError',
310 + _tag: 'commands/CommandInputError',
311 + command: 'link',
312 + option: '--alias',
313 message: '`--alias` cannot be empty.',
314 });
315 expect(vi.mocked(open)).not.toHaveBeenCalled();
ts/packages/cli/test/src/commands/listen.cmd.test.ts
+4 -6
@@ -182,10 +182,8 @@ describe('CLI: composio listen', () => {
182 },
183 })
184 )('listen validation and domain failures', it => {
185 - // v4 migration note: `CliError.InvalidValue` is a fixed flag/argument-name-and-value
186 - // struct produced only by the parser. These are business-level validations (only
187 - // knowable after parsing), so `listen.cmd.ts` models them as a plain typed domain error
188 - // (`ListenOptionError`) instead — see the migration note above `invalidOptionValue`.
185 + // Business-level validation (only knowable after parsing) raises `CommandInputError`;
186 + // see `src/commands/errors.ts`.
187 it.effect('reports malformed trigger params as CLI input validation', () =>
188 Effect.gen(function* () {
189 yield* enableListen;
@@ -196,7 +194,7 @@ describe('CLI: composio listen', () => {
194 expect(Exit.isFailure(exit)).toBe(true);
195 if (Exit.isFailure(exit)) {
196 const failure = Cause.squash(exit.cause);
199 - expect(failure).toMatchObject({ _tag: 'commands/ListenOptionError' });
197 + expect(failure).toMatchObject({ _tag: 'commands/CommandInputError', command: 'listen' });
198 }
199 })
200 );
@@ -211,7 +209,7 @@ describe('CLI: composio listen', () => {
209 expect(Exit.isFailure(exit)).toBe(true);
210 if (Exit.isFailure(exit)) {
211 const failure = Cause.squash(exit.cause);
214 - expect(failure).toMatchObject({ _tag: 'commands/ListenOptionError' });
212 + expect(failure).toMatchObject({ _tag: 'commands/CommandInputError', command: 'listen' });
213 }
214 })
215 );
ts/packages/cli/test/src/commands/login.cmd.test.ts
+2 -3
@@ -116,9 +116,8 @@ describe('CLI: composio login', () => {
116 });
117 });
118
119 - // v4 migration note: this business-level validation (only knowable after parsing) is a
120 - // plain typed domain error (`LoginOptionError`), not a `CliError.InvalidValue` — see the
121 - // migration note in `login.cmd.ts` above `invalidOptionValue`.
119 + // Business-level validation (only knowable after parsing) raises `CommandInputError`,
120 + // not a `CliError.InvalidValue`; see `src/commands/errors.ts`.
121 layer(TestLive())(it => {
122 it.effect('[Given] conflicting login options [Then] fails with a CLI validation error', () =>
123 Effect.gen(function* () {
ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
+2 -2
@@ -368,8 +368,8 @@ describe('CLI: composio generate py', () => {
368 const args = ['generate', 'py', '--toolkits', 'nonexistent', '--output-dir', outputDir];
369 const result = yield* cli(args).pipe(Effect.catch(e => Effect.succeed(e)));
370
371 - assert.ok(Predicate.isTagged(result, 'commands/GenerateInputError'));
372 - if (Predicate.isTagged(result, 'commands/GenerateInputError')) {
371 + assert.ok(Predicate.isTagged(result, 'commands/CommandInputError'));
372 + if (Predicate.isTagged(result, 'commands/CommandInputError')) {
373 expect((result as unknown as { message: string }).message).toContain(
374 'Invalid toolkit(s): nonexistent'
375 );
ts/packages/cli/test/src/commands/run.cmd.test.ts
+6 -9
@@ -1,3 +1,4 @@
1 +import { CommandInputError } from 'src/commands/errors';
2 import * as fs from 'node:fs';
3 import * as os from 'node:os';
4 import * as path from 'node:path';
@@ -9,11 +10,7 @@ import { Cause, ConfigProvider, Effect, Exit, Layer, Option, Sink, Stream } from
10 import { ChildProcess, ChildProcessSpawner } from 'effect/process';
11 import { afterEach, it, vi } from 'vitest';
12 import { createCliCommandTelemetryContext } from 'src/analytics/events';
12 -import {
13 - buildRunHelpersSource,
14 - inferCliInvocationPrefix,
15 - MissingRunSourceError,
16 -} from 'src/commands/run.cmd';
13 +import { buildRunHelpersSource, inferCliInvocationPrefix } from 'src/commands/run.cmd';
14 import {
15 extractInlineExecuteToolSlugs,
16 wrapInlineCodeForRun,
@@ -425,10 +422,10 @@ describe('CLI: composio run', () => {
422
423 const failure = Cause.findErrorOption(exit.cause);
424 expect(Option.isSome(failure)).toBe(true);
428 - expect(failure.pipe(Option.getOrThrow)).toBeInstanceOf(MissingRunSourceError);
429 - expect(
430 - String((failure.pipe(Option.getOrThrow) as MissingRunSourceError).message)
431 - ).toContain('Provide inline code or use --file to run a script file.');
425 + expect(failure.pipe(Option.getOrThrow)).toBeInstanceOf(CommandInputError);
426 + expect(String((failure.pipe(Option.getOrThrow) as CommandInputError).message)).toContain(
427 + 'Provide inline code or use --file to run a script file.'
428 + );
429 // Nothing was set up before the check, so no child process was started.
430 expect(commandRuns).not.toHaveBeenCalled();
431 })
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+5 -7
@@ -16,10 +16,8 @@ import * as redactModule from 'src/ui/redact';
16 import { cli, TestLive, MockConsole } from 'test/__utils__';
17 import { liveEnvConfigProvider } from 'test/__utils__/live-env-config-provider';
18 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
19 -import {
20 - parseParallelExecuteArgs,
21 - type ParallelExecuteArgumentError,
22 -} from 'src/commands/tools/commands/tools.execute.cmd';
19 +import { parseParallelExecuteArgs } from 'src/commands/tools/commands/tools.execute.cmd';
20 +import type { CommandInputError } from 'src/commands/errors';
21 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
22 import type { ToolkitDetailed } from 'src/models/toolkits';
23 import { makeToolkitFixture } from 'test/__utils__/models/toolkits';
@@ -107,10 +105,10 @@ const largeOutputConfigProvider = ConfigProvider.fromEnvRecord({
105 }).pipe(ConfigProvider.orElse(testArtifactConfigProvider));
106
107 const expectInvalidValueMessage = (failure: unknown, message: string) => {
110 - expect(Predicate.isTagged(failure, 'commands/ParallelExecuteArgumentError')).toBe(true);
111 - if (!Predicate.isTagged(failure, 'commands/ParallelExecuteArgumentError')) return;
108 + expect(Predicate.isTagged(failure, 'commands/CommandInputError')).toBe(true);
109 + if (!Predicate.isTagged(failure, 'commands/CommandInputError')) return;
110
113 - expect((failure as ParallelExecuteArgumentError).message).toContain(message);
111 + expect((failure as CommandInputError).message).toContain(message);
112 };
113
114 const parseLastJson = (lines: ReadonlyArray<string>) => {
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+4 -4
@@ -7,7 +7,7 @@ import type {
7 import { cli, TestLive, MockConsole } from 'test/__utils__';
8 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
9 import type { Tools } from 'src/models/tools';
10 -import { ToolsSearchInputError } from 'src/commands/tools/commands/tools.search.cmd';
10 +import { CommandInputError } from 'src/commands/errors';
11
12 const testTools: Tools = [
13 {
@@ -101,9 +101,9 @@ describe('CLI: composio search', () => {
101 it.effect('returns the structured missing-query error', () =>
102 Effect.gen(function* () {
103 const failure = yield* cli(['search', ' ']).pipe(Effect.flip);
104 - expect(failure).toBeInstanceOf(ToolsSearchInputError);
105 - if (failure instanceof ToolsSearchInputError) {
106 - expect(failure.reason).toBe('missing_query');
104 + expect(failure).toBeInstanceOf(CommandInputError);
105 + if (failure instanceof CommandInputError) {
106 + expect(failure.option).toBe('<query>');
107 expect(failure.message).toBe('At least one query is required.');
108 }
109 })
ts/packages/cli/test/src/commands/triggers/triggers.list.cmd.test.ts
+4 -2
@@ -80,7 +80,8 @@ describe('CLI: composio dev triggers list', () => {
80 if (Exit.isFailure(exit)) {
81 const failure = Cause.squash(exit.cause);
82 expect(failure).toMatchObject({
83 - _tag: 'commands/TriggersListOptionError',
83 + _tag: 'commands/CommandInputError',
84 + option: '<toolkit>',
85 message: expect.stringContaining('not available'),
86 });
87 }
@@ -211,7 +212,8 @@ describe('CLI: composio dev triggers list', () => {
212 if (Exit.isFailure(exit)) {
213 const failure = Cause.squash(exit.cause);
214 expect(failure).toMatchObject({
214 - _tag: 'commands/TriggersListOptionError',
215 + _tag: 'commands/CommandInputError',
216 + option: '<toolkit>',
217 message: expect.stringContaining('not available'),
218 });
219 }
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+3 -2
@@ -11,7 +11,7 @@ import {
11 assertTypeScriptIsValid,
12 } from 'test/__utils__/typescript-compiler';
13 import { ComposioCorePkgNotFound } from 'src/effects/find-composio-core-generated';
14 -import { TypeScriptGenerationInputError } from 'src/commands/ts/commands/ts.generate.cmd';
14 +import { CommandInputError } from 'src/commands/errors';
15 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
16 import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
17 import { TOOLS_TYPES_GMAIL } from 'test/__mocks__/tools-types-gmail';
@@ -998,7 +998,8 @@ describe('CLI: composio generate ts', () => {
998 const args = ['generate', 'ts', '--toolkits', 'nonexistent', '--output-dir', outputDir];
999 const result = yield* cli(args).pipe(Effect.catch(e => Effect.succeed(e)));
1000
1001 - assert.ok(result instanceof TypeScriptGenerationInputError);
1001 + assert.ok(result instanceof CommandInputError);
1002 + expect(result.option).toBe('--toolkits');
1003 expect(result.message).toContain('Invalid toolkit(s): nonexistent');
1004 })
1005 );