@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 2.18 KB
Raw
1 import * as BunServices from '@effect/platform-bun/BunServices';
2 import { describe, expect, it } from '@effect/vitest';
3 import { ConfigProvider, Effect, FileSystem, Option, Path } from 'effect';
4 import { resolveWindowsExecutable } from 'src/services/windows-executable';
5
6 const withPath = (entries: Record<string, string>) =>
7 Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ env: entries }));
8
9 describe('resolveWindowsExecutable', () => {
10 it.effect('finds an npm command shim and marks it as needing a shell', () =>
11 Effect.gen(function* () {
12 const fs = yield* FileSystem.FileSystem;
13 const path = yield* Path.Path;
14 const empty = yield* fs.makeTempDirectoryScoped();
15 const npmBin = yield* fs.makeTempDirectoryScoped();
16 yield* fs.writeFileString(path.join(npmBin, 'claude.cmd'), '@echo off');
17
18 const resolved = yield* resolveWindowsExecutable('claude').pipe(
19 withPath({ Path: `${empty};${npmBin}` })
20 );
21
22 expect(resolved).toEqual(
23 Option.some({ path: path.join(npmBin, 'claude.cmd'), needsShell: true })
24 );
25 }).pipe(Effect.provide(BunServices.layer))
26 );
27
28 it.effect('prefers a native executable over a shim in the same directory', () =>
29 Effect.gen(function* () {
30 const fs = yield* FileSystem.FileSystem;
31 const path = yield* Path.Path;
32 const bin = yield* fs.makeTempDirectoryScoped();
33 yield* fs.writeFileString(path.join(bin, 'claude.cmd'), '@echo off');
34 yield* fs.writeFileString(path.join(bin, 'claude.exe'), '');
35
36 const resolved = yield* resolveWindowsExecutable('claude').pipe(withPath({ PATH: bin }));
37
38 expect(resolved).toEqual(
39 Option.some({ path: path.join(bin, 'claude.exe'), needsShell: false })
40 );
41 }).pipe(Effect.provide(BunServices.layer))
42 );
43
44 it.effect('finds nothing when the command is not on PATH', () =>
45 Effect.gen(function* () {
46 const fs = yield* FileSystem.FileSystem;
47 const empty = yield* fs.makeTempDirectoryScoped();
48
49 const resolved = yield* resolveWindowsExecutable('claude').pipe(withPath({ Path: empty }));
50
51 expect(Option.isNone(resolved)).toBe(true);
52 }).pipe(Effect.provide(BunServices.layer))
53 );
54 });