Skip to content

Mule

Runs an AI model's reply-and-tool-call loop as one awaited, cancellable call, so a TypeScript service doesn't have to write that control flow itself.

  • @fungi.computer/mule
  • v0.2.1
  • MIT

Fastest path

  1. Install

    Add it to your project with npm, pnpm, Yarn or Bun.

    TERMINAL
    npm install @fungi.computer/mule
  2. Run a scripted model reply

    A faux model answers once, with no network call or credential; prints the run's final status.

    home.ts
    import { fauxAssistantMessage } from "@earendil-works/pi-ai/providers/faux";
    import { mule } from "@fungi.computer/mule";
    import { fauxModel } from "@fungi.computer/mule/testing";
    const faux = fauxModel([fauxAssistantMessage("pong")]);
    const outcome = await mule.run(
    {
    model: faux.model,
    retryable: faux.retryable,
    stream: faux.stream,
    systemPrompt: "Reply once.",
    messages: [{ role: "user", content: "ping", timestamp: 1 }],
    },
    () => {},
    );
    console.log(outcome.status); // "completed"