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

next
ts 17 lines 885 Bytes
Raw
1 import { Option, type Exit } from 'effect';
2 import { runnerExit } from 'src/invocation/invocation';
3 import { ExitAction, exitActionFor } from 'src/run-main';
4 import { signalExitCode } from 'src/services/shutdown-signal';
5
6 /**
7 * The code the CLI process exits with when an invocation ends with `exit` and no signal arrived,
8 * mapped the way `runCli` maps it: `forRunner`, then the runner's `exitActionFor` (by way of
9 * `Runtime.defaultTeardown`). 0 on success, otherwise the failure's `[Runtime.errorExitCode]`,
10 * or 1 without one; a child `composio run` a signal ended reports 128 + its number, as a shell
11 * would for the re-raised signal.
12 */
13 export const exitCodeOf = (exit: Exit.Exit<unknown, unknown>): number =>
14 ExitAction.$match(exitActionFor(runnerExit(exit), Option.none()), {
15 ExitWith: ({ code }) => code,
16 Reraise: ({ signal }) => signalExitCode(signal),
17 });