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 process from 'node:process'; |
| 2 | import { Effect, Layer } from 'effect'; |
| 3 | import { FetchHttpClient } from 'effect/http'; |
| 4 | import * as BunFileSystem from '@effect/platform-bun/BunFileSystem'; |
| 5 | import * as BunPath from '@effect/platform-bun/BunPath'; |
| 6 | import * as BunRuntime from '@effect/platform-bun/BunRuntime'; |
| 7 | import { isBackgroundWorkerInvocation, runBackgroundWorkerFromArgv } from 'src/analytics/dispatch'; |
| 8 | import { NodeOs } from 'src/services/node-os'; |
| 9 | import { TerminalUILive } from 'src/services/terminal-ui'; |
| 10 | import { readTelemetryDebugOverride, telemetryDebugModeLayer } from 'src/services/runtime-flags'; |
| 11 | |
| 12 | // Read process.argv once and pass it unchanged to the worker or command framework. |
| 13 | const argv = process.argv; |
| 14 | |
| 15 | const workerLayers = Layer.mergeAll( |
| 16 | BunFileSystem.layer, |
| 17 | BunPath.layer, |
| 18 | FetchHttpClient.layer, |
| 19 | NodeOs.Default, |
| 20 | TerminalUILive |
| 21 | ); |
| 22 | |
| 23 | if (isBackgroundWorkerInvocation(argv)) { |
| 24 | runBackgroundWorkerFromArgv(argv).pipe( |
| 25 | Effect.provide( |
| 26 | readTelemetryDebugOverride(argv) === true |
| 27 | ? Layer.merge(workerLayers, telemetryDebugModeLayer(true)) |
| 28 | : workerLayers |
| 29 | ), |
| 30 | effect => |
| 31 | BunRuntime.runMain(effect, { |
| 32 | disableErrorReporting: true, |
| 33 | teardown: (_exit, onExit) => onExit(0), |
| 34 | }) |
| 35 | ); |
| 36 | } else { |
| 37 | void import('./cli-main').then(({ runCli }) => runCli({ argv })); |
| 38 | } |