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

main
ts 31 lines 998 Bytes
Raw
1 import * as Effect from "effect/Effect";
2 import * as Semaphore from "effect/Semaphore";
3
4 // Amazon Macie exposes one session per account and Region. The session,
5 // resource, classification-job, and bindings files all enable/disable or
6 // depend on that singleton while alchemy-test executes files concurrently in
7 // one process. Hold this lease for each file's complete setup → test → cleanup
8 // lifecycle so one file cannot disable Macie underneath another.
9 const macie2TestLock = Semaphore.makeUnsafe(1);
10
11 export const makeMacie2TestLease = () => {
12 let held = false;
13
14 return {
15 acquire: Effect.uninterruptibleMask((restore) =>
16 restore(macie2TestLock.take(1)).pipe(
17 Effect.tap(() =>
18 Effect.sync(() => {
19 held = true;
20 }),
21 ),
22 Effect.asVoid,
23 ),
24 ),
25 release: Effect.suspend(() => {
26 if (!held) return Effect.void;
27 held = false;
28 return macie2TestLock.release(1).pipe(Effect.asVoid);
29 }),
30 };
31 };