The best way to control Claude Code, Codex and more from any computer or phone

main
ts 54 lines 1.79 KB
Raw
1 /**
2 * Bun process runner for Effect programs.
3 *
4 * This module exports `runMain`, which runs one Effect as the main process
5 * fiber in Bun. It reuses the shared Node runtime runner, including its error
6 * reporting, signal handling, and optional teardown behavior.
7 *
8 * @stability unstable
9 * @since 4.0.0
10 */
11 import * as NodeRuntime from "@effect/platform-node-shared/NodeRuntime"
12 import type { Effect } from "effect/Effect"
13 import type { Teardown } from "effect/Runtime"
14
15 /**
16 * Helps you run a main effect with built-in error handling, logging, and signal management.
17 *
18 * **When to use**
19 *
20 * Use to run a Bun application's main Effect with structured error handling,
21 * log management, interrupt support, or advanced teardown capabilities.
22 *
23 * **Details**
24 *
25 * This function launches an Effect as the main entry point, setting exit codes
26 * based on success or failure, handling interrupts (e.g., Ctrl+C), and optionally
27 * logging errors. By default, it logs errors and uses a "pretty" format, but both
28 * behaviors can be turned off. You can also provide custom teardown logic to
29 * finalize resources or produce different exit codes.
30 *
31 * An optional object that can include:
32 * - `disableErrorReporting`: Turn off automatic error logging.
33 * - `disablePrettyLogger`: Avoid adding the pretty logger.
34 * - `teardown`: Provide custom finalization logic.
35 *
36 * @stability unstable
37 * @category running
38 * @since 4.0.0
39 */
40 export const runMain: {
41 (
42 options?: {
43 readonly disableErrorReporting?: boolean | undefined
44 readonly teardown?: Teardown | undefined
45 }
46 ): <E, A>(effect: Effect<A, E>) => void
47 <E, A>(
48 effect: Effect<A, E>,
49 options?: {
50 readonly disableErrorReporting?: boolean | undefined
51 readonly teardown?: Teardown | undefined
52 }
53 ): void
54 } = NodeRuntime.runMain