Reminix TypeScript SDK - v0.7.1
    Preparing search index...

    Agent class for defining invoke and chat handlers.

    Use separate handlers for non-streaming and streaming responses:

    • onInvoke / onChat for non-streaming
    • onInvokeStream / onChatStream for streaming
    const agent = new Agent('my-agent');

    agent.onInvoke(async (input, ctx) => {
    return { output: `Processed: ${input.message}` };
    });

    agent.onInvokeStream(async function* (input, ctx) {
    yield { chunk: 'Hello ' };
    yield { chunk: 'World!' };
    });

    agent.onChat(async (messages, ctx) => {
    return { message: { role: 'assistant', content: 'Hello!' } };
    });

    agent.onChatStream(async function* (messages, ctx) {
    yield { chunk: 'Hello!' };
    });
    Index

    Constructors

    • Create a new Agent.

      Parameters

      • name: string

        Unique identifier for the agent (lowercase letters, numbers, hyphens, underscores)

      • Optionaloptions: AgentOptions

        Optional configuration including metadata

      Returns Agent

      If name is empty or contains invalid characters

    Properties

    name: string

    Accessors

    Methods

    • Handle a non-streaming chat request.

      Parameters

      • messages: {
            content: string | any[] | null;
            name?: string;
            role: "system" | "user" | "assistant" | "tool";
            tool_call_id?: string;
            tool_calls?: {
                function: { arguments: string; name: string };
                id: string;
                type: "function";
            }[];
        }[]

        The conversation messages

      • Optionalctx: Context

        Optional request context

      Returns Promise<
          {
              message: {
                  content: string
                  | any[]
                  | null;
                  role: "assistant";
                  tool_calls?: {
                      function: { arguments: string; name: string };
                      id: string;
                      type: "function";
                  }[];
              };
          },
      >

      The response

      If no chat handler is registered

      If the response is invalid

    • Handle a streaming chat request.

      Parameters

      • messages: {
            content: string | any[] | null;
            name?: string;
            role: "system" | "user" | "assistant" | "tool";
            tool_call_id?: string;
            tool_calls?: {
                function: { arguments: string; name: string };
                id: string;
                type: "function";
            }[];
        }[]

        The conversation messages

      • Optionalctx: Context

        Optional request context

      Returns Promise<AsyncGenerator<{ chunk: string }, void, unknown>>

      An async generator yielding chunks

      If no streaming chat handler is registered

    • Handle a non-streaming invoke request.

      Parameters

      • input: InvokeInput

        The input data from the request

      • Optionalctx: Context

        Optional request context

      Returns Promise<{ output: any }>

      The response

      If no invoke handler is registered

      If the response is invalid

    • Handle a streaming invoke request.

      Parameters

      • input: InvokeInput

        The input data from the request

      • Optionalctx: Context

        Optional request context

      Returns Promise<AsyncGenerator<{ chunk: string }, void, unknown>>

      An async generator yielding chunks

      If no streaming invoke handler is registered

    • Register a non-streaming chat handler.

      Parameters

      • handler: ChatHandler

        Function that processes chat requests

      Returns this

      The agent instance for chaining

      agent.onChat(async (messages) => {
      return {
      message: { role: 'assistant', content: 'Hello!' }
      };
      });
    • Register a streaming chat handler.

      Parameters

      • handler: ChatStreamHandler

        Async generator function that yields chunks

      Returns this

      The agent instance for chaining

      agent.onChatStream(async function* (messages) {
      yield { chunk: 'Hello!' };
      });
    • Register a non-streaming invoke handler.

      Parameters

      Returns this

      The agent instance for chaining

      agent.onInvoke(async (input) => {
      return { output: processData(input) };
      });
    • Register a streaming invoke handler.

      Parameters

      • handler: InvokeStreamHandler

        Async generator function that yields chunks

      Returns this

      The agent instance for chaining

      agent.onInvokeStream(async function* (input) {
      yield { chunk: 'Hello ' };
      yield { chunk: 'World!' };
      });