Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 15 lines 592 Bytes
Raw
1 import process from 'node:process';
2 import { Cause, Exit } from 'effect';
3 import type { Teardown } from 'effect/Runtime';
4
5 /**
6 * Shared teardown for CLI scripts.
7 *
8 * Keep this module dependency-light so release-only scripts can use it without
9 * loading the CLI runtime or requiring built workspace packages.
10 */
11 export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
12 const shouldFail = Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause);
13 const errorCode = Number(process.exitCode ?? 1);
14 onExit(shouldFail ? errorCode : 0);
15 };