Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Command, Flag } from 'effect/cli'; |
| 2 | import { Effect } from 'effect'; |
| 3 | import { getVersion } from 'src/effects/version'; |
| 4 | import { getUpdateStatus } from 'src/services/update-check'; |
| 5 | import { TerminalUI } from 'src/services/terminal-ui'; |
| 6 | import { bold, cyanBright } from 'src/ui/colors'; |
| 7 | |
| 8 | const check = Flag.Boolean('check').pipe( |
| 9 | Flag.withDefault(false), |
| 10 | Flag.withDescription( |
| 11 | 'Check for a newer stable release and print a machine-readable JSON status ' + |
| 12 | '({current, latestStable, updateAvailable, checkStatus, lastChecked}). ' + |
| 13 | 'Refreshes the release cache when it is older than 24 hours.' |
| 14 | ) |
| 15 | ); |
| 16 | |
| 17 | /** |
| 18 | * CLI command to display the version of the Composio CLI. |
| 19 | * |
| 20 | * @example |
| 21 | * ```bash |
| 22 | * composio version |
| 23 | * composio version --check |
| 24 | * ``` |
| 25 | */ |
| 26 | export const versionCmd = Command.make('version', { check }).pipe( |
| 27 | Command.withDescription('Display the current Composio CLI version.'), |
| 28 | Command.withHandler(({ check }) => |
| 29 | Effect.gen(function* () { |
| 30 | const ui = yield* TerminalUI; |
| 31 | |
| 32 | if (check) { |
| 33 | const status = yield* getUpdateStatus; |
| 34 | if (status.updateAvailable && status.latestStable) { |
| 35 | yield* ui.log.info( |
| 36 | `Update available: ${status.current} → ${bold(cyanBright(status.latestStable))} — run ${cyanBright('composio upgrade')}` |
| 37 | ); |
| 38 | } else if (status.checkStatus === 'unknown') { |
| 39 | yield* ui.log.warn('Unable to determine the latest stable Composio CLI release.'); |
| 40 | } else { |
| 41 | yield* ui.log.info(`${status.current} is up to date.`); |
| 42 | } |
| 43 | yield* ui.output(JSON.stringify(status)); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | const version = yield* getVersion; |
| 48 | yield* ui.log.info(version); |
| 49 | yield* ui.output(version); |
| 50 | |
| 51 | yield* Effect.logDebug('Composio CLI version command executed successfully.'); |
| 52 | }) |
| 53 | ) |
| 54 | ); |