@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

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