Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

521 B
Raw Blame
import * as Context from "effect/Context";

export const GenericService =
  <
    Fn extends (T: { Type: string }) => Context.Service<any, any> = (
      ...args: any[]
    ) => Context.Service<any, any>,
  >() =>
  <Kind extends string>(Kind: Kind): ReturnType<Fn> & Fn => {
    const service = Context.Service<any, any>(Kind);
    const make = (Type: string) => Context.Service(`${Kind}<${Type}>`);
    return Object.assign(
      Object.setPrototypeOf(make, service),
      service,
    ) as ReturnType<Fn> & Fn;
  };