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

main
ts 15 lines 638 Bytes
Raw
1 import * as Context from "effect/Context";
2
3 export const GenericService =
4 <
5 Fn extends (T: { Type: string }) => Context.Service<any, any> = (
6 ...args: any[]
7 ) => Context.Service<any, any>,
8 >() =>
9 <Kind extends string>(Kind: Kind): ReturnType<Fn> & Fn => {
10 // Tag key is a runtime `Kind`, so it can't be a class declaration.
11 // oxlint-disable-next-line effecttsgo/service-not-as-class
12 const service = Context.Service<any, any>(Kind);
13 const make = (Type: string) => Context.Service(`${Kind}<${Type}>`);
14 return Object.assign(Object.setPrototypeOf(make, service), service) as ReturnType<Fn> & Fn;
15 };