D-ID Client SDK - v3.0.0-0
    Preparing search index...

    Type Alias ClientToolHandler

    ClientToolHandler: (args: Record<string, unknown>) => string | Promise<string>

    A client tool's implementation: the function that runs in the browser when the agent calls it.

    Register it with registerClientTool(), under the tool name defined in the agent's configuration. The SDK parses the arguments the agent's LLM produced and passes them in; whatever the handler resolves with is sent back to the agent as the tool's result. Throwing rejects the call, and the error message is forwarded to the agent. Expressive (V4) agents only — registerClientTool() throws a ValidationError on a Talks (V2) or Clips (V3) agent.

    Type Declaration

      • (args: Record<string, unknown>): string | Promise<string>
      • Parameters

        • args: Record<string, unknown>

          The arguments the LLM produced for this call, already parsed from JSON.

        Returns string | Promise<string>

        A JSON string with the tool's result, at most 15 KiB — the LiveKit RPC response limit; a larger result fails the call with an RPC error. A synchronous handler may return the string directly; the SDK awaits the result either way.

    agentManager.registerClientTool('get_cart_total', async args => {
    const total = await cart.total(args.currency as string);
    return JSON.stringify({ total });
    });

    // Nothing to await: the string is enough.
    agentManager.registerClientTool('get_locale', () => JSON.stringify({ locale: navigator.language }));