Sole entry point for runner creation.

RunnerFactory is the single factory for creating Runner and AgentGraphRunner instances. It mirrors the Python RunnerFactory pattern: it knows about supported provider packages, loads them dynamically via _getProviderFactory, and delegates creation to the factory instance methods on AIProvider.

Provider packages subclass AIProvider and override its factory methods (createModel, createAgent, createAgentGraph).

Hierarchy

  • RunnerFactory

Constructors

Methods

  • Load and return the AIProvider factory for the given provider type.

    This is the single place in the codebase that knows provider package names. Each supported provider package exports a *RunnerFactory class that extends AIProvider; this method instantiates it directly.

    Parameters

    • providerType: "openai" | "langchain" | "vercel"

      One of the SUPPORTED_AI_PROVIDERS values.

    • Optional logger: LDLogger

      Optional logger forwarded to the provider factory.

      Optional

    Returns Promise<undefined | AIProvider>

    A configured AIProvider instance, or undefined if the package cannot be loaded.

  • Determine which providers to try based on defaultAiProvider and providerName.

    Mirrors Python's _get_providers_to_try helper.

    Parameters

    • Optional defaultAiProvider: "openai" | "langchain" | "vercel"
      Optional
    • Optional providerName: string
      Optional

    Returns ("openai" | "langchain" | "vercel")[]

  • Try each provider in order and return the first non-undefined result.

    Mirrors Python's _with_fallback helper. Loads each provider factory via _getProviderFactory and calls fn with it. Returns the first truthy result, or undefined if no provider succeeds.

    Type Parameters

    • T

    Parameters

    • providers: ("openai" | "langchain" | "vercel")[]

      Ordered list of provider types to try.

    • fn: ((factory) => Promise<undefined | T>)

      Callback that calls the appropriate factory method on the provider.

        • (factory): Promise<undefined | T>
        • Parameters

          Returns Promise<undefined | T>

    • Optional logger: LDLogger

      Optional logger forwarded to each provider factory.

      Optional

    Returns Promise<undefined | T>

  • Create a Runner for an agent AI Config.

    Delegates to the provider factory's AIProvider.createAgent method.

    Parameters

    • config: LDAIAgentConfig

      The agent AI configuration.

    • Optional tools: ToolRegistry

      Optional registry of callable tools.

      Optional
    • Optional logger: LDLogger

      Optional logger forwarded to the underlying provider.

      Optional
    • Optional defaultAiProvider: "openai" | "langchain" | "vercel"

      Optional provider override.

      Optional

    Returns Promise<undefined | Runner>

    A configured Runner, or undefined if no suitable provider could be loaded.

  • Create an AgentGraphRunner for the given agent graph definition.

    Delegates to the provider factory's AIProvider.createAgentGraph method.

    Parameters

    • graphDef: AgentGraphDefinition

      The agent graph definition.

    • Optional tools: ToolRegistry

      Optional registry of callable tools.

      Optional
    • Optional logger: LDLogger

      Optional logger forwarded to the underlying provider.

      Optional
    • Optional defaultAiProvider: "openai" | "langchain" | "vercel"

      Optional provider override.

      Optional

    Returns Promise<undefined | AgentGraphRunner>

    A configured AgentGraphRunner, or undefined if no suitable provider could be loaded.

  • Create a Runner for the given AI configuration.

    Suitable for completion, judge, and agent config modes. Dynamically loads the matching provider package via _getProviderFactory and delegates to its AIProvider.createModel method.

    Parameters

    • config: LDAIJudgeConfig | LDAICompletionConfig

      The AI configuration (completion, agent, or judge).

    • Optional logger: LDLogger

      Optional logger forwarded to the underlying provider.

      Optional
    • Optional defaultAiProvider: "openai" | "langchain" | "vercel"

      Optional provider override ('openai', 'langchain', 'vercel', …). When set, only that provider is tried. When omitted, providers are tried in priority order based on the provider name in the config.

      Optional

    Returns Promise<undefined | Runner>

    A configured Runner ready to invoke the model, or undefined if no suitable provider could be loaded.

Generated using TypeDoc