functai for TypeScript - v0.1.0
    Preparing search index...

    Class Plugin

    A named, versioned set of hooks. name is lower-case letters, digits, _ and - (its changes and entries are named by it); version its own, recorded with every change; api the plugin API it was written for (1). Register handlers with on(hook, fn) or the hook's own method (.toolCall(fn), chainable); each is given an event and returns a change, or nothing.

    const guard = new Plugin("no-deletes", { version: "1.0.0" })
    .toolCall((tool) => tool.name === "delete_file" ? { block: "deleting files is not allowed here" } : undefined);
    configure({ plugins: [guard] });
    Index
    • Parameters

      • name: string
      • opts: { api?: number; description?: string; version?: string } = {}

      Returns Plugin

    api: number
    description: string
    handlers: Partial<Record<Hook, Handler[]>> = {}
    name: string
    version: string
    • An AI function is about to be asked: its instruction, sections, model, settings, tools.

      Parameters

      Returns this

    • Its manifest, as data: name, version, api, the hooks it uses (by the contract's names).

      Returns Rec

    • Register fn for hook.

      Parameters

      • hook: Hook
      • fn: Handler

      Returns this

    • The escape hatch: replace the provider request (the call is then not replayable).

      Parameters

      • fn: (event: RequestHook) => void | Request | null | undefined

      Returns this

    • A tool is about to run: change its input, block it, or ask a person (event.ask()).

      Parameters

      • fn: (
            event: ToolCallHook,
        ) =>
            | void
            | Change
            | Promise<void | Change | null | undefined>
            | null
            | undefined

      Returns this

    • A conversation's turn ended (hears only; may keep entries in its conversation).

      Parameters

      Returns this