@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 54 lines 1.72 KB
Raw
1 #!/usr/bin/env bun
2
3 /**
4 * Build the `composio run` companion modules next to an already-compiled binary.
5 *
6 * `scripts/build-binary.ts` does this as part of a full release build. This
7 * entry point exists for builds that compile the binary themselves, such as the
8 * CLI e2e image.
9 *
10 * Usage: `bun scripts/build-companion-modules.ts <OUTPUT_DIR>`
11 */
12
13 import process from 'node:process';
14 import { Config, ConfigProvider, Console, Effect, Logger, Layer, References } from 'effect';
15 import * as BunServices from '@effect/platform-bun/BunServices';
16 import * as BunRuntime from '@effect/platform-bun/BunRuntime';
17 import { buildCompanionModules, teardown } from './_shared';
18 import { BinaryBuildError } from './build-error';
19
20 export function buildCompanionModulesCommand() {
21 return Effect.gen(function* () {
22 const outputDir = process.argv[2];
23
24 if (!outputDir) {
25 return yield* new BinaryBuildError({
26 message: 'Missing <OUTPUT_DIR> argument',
27 exitCode: 1,
28 });
29 }
30
31 yield* buildCompanionModules(outputDir);
32
33 yield* Console.log(`Companion modules built in ${outputDir}`);
34 });
35 }
36
37 const ConfigLive = Effect.gen(function* () {
38 const logLevel = yield* Config.LogLevel('COMPOSIO_LOG_LEVEL').pipe(Config.withDefault('Info'));
39
40 return Layer.succeed(References.MinimumLogLevel, logLevel);
41 }).pipe(Layer.unwrap, Layer.merge(ConfigProvider.layer(ConfigProvider.fromEnv())));
42
43 if (require.main === module) {
44 buildCompanionModulesCommand().pipe(
45 Effect.provide(ConfigLive),
46 Effect.provide(Logger.layer([Logger.consolePretty()])),
47 Effect.provide(BunServices.layer),
48 Effect.scoped,
49 Effect.map(() => ({ message: 'Process completed successfully.' })),
50 BunRuntime.runMain({
51 teardown,
52 })
53 );
54 }