Skip to content

agents / Exports / LocalExecutor

Class: LocalExecutor

Local executor that directly delegates to AI provider instances

This executor maintains a registry of AI provider instances and delegates chat execution requests to the appropriate provider based on the provider name in the request. This is the "traditional" execution mode where API calls are made directly from the client.

Example

typescript
import { LocalExecutor } from '@robota-sdk/agents';
import { OpenAIProvider } from '@robota-sdk/openai';

const executor = new LocalExecutor();
executor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));

const response = await executor.executeChat({
  messages: [{ role: 'user', content: 'Hello!' }],
  provider: 'openai',
  model: 'gpt-4'
});

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LocalExecutor(config?): LocalExecutor

Parameters

NameType
configLocalExecutorConfig

Returns

LocalExecutor

Overrides

BaseExecutor.constructor

Defined in

packages/agents/src/executors/local-executor.ts:40

Properties

name

Readonly name: "local"

Get executor name/identifier

Overrides

BaseExecutor.name

Defined in

packages/agents/src/executors/local-executor.ts:34


version

Readonly version: "1.0.0"

Get executor version

Overrides

BaseExecutor.version

Defined in

packages/agents/src/executors/local-executor.ts:35

Methods

registerProvider

registerProvider(name, provider): void

Register an AI provider instance for use with this executor

Parameters

NameTypeDescription
namestringProvider name (e.g., 'openai', 'anthropic', 'google')
providerAIProviderInstanceProvider instance that implements the required chat methods

Returns

void

Defined in

packages/agents/src/executors/local-executor.ts:57


unregisterProvider

unregisterProvider(name): void

Unregister an AI provider

Parameters

NameTypeDescription
namestringProvider name to remove

Returns

void

Defined in

packages/agents/src/executors/local-executor.ts:66


getProvider

getProvider(name): undefined | AIProviderInstance

Get registered provider instance

Parameters

NameTypeDescription
namestringProvider name

Returns

undefined | AIProviderInstance

Provider instance or undefined if not registered

Defined in

packages/agents/src/executors/local-executor.ts:76


executeChat

executeChat(request): Promise<AssistantMessage>

Execute a chat completion request by delegating to the appropriate provider

Parameters

NameType
requestChatExecutionRequest

Returns

Promise<AssistantMessage>

Overrides

BaseExecutor.executeChat

Defined in

packages/agents/src/executors/local-executor.ts:83


executeChatStream

executeChatStream(request): AsyncIterable<UniversalMessage, any, any>

Execute a streaming chat completion request

Parameters

NameType
requestStreamExecutionRequest

Returns

AsyncIterable<UniversalMessage, any, any>

Overrides

BaseExecutor.executeChatStream

Defined in

packages/agents/src/executors/local-executor.ts:133


supportsTools

supportsTools(): boolean

Check if any registered providers support tools

Returns

boolean

Overrides

BaseExecutor.supportsTools

Defined in

packages/agents/src/executors/local-executor.ts:175


validateConfig

validateConfig(): boolean

Validate executor configuration and all registered providers

Returns

boolean

Overrides

BaseExecutor.validateConfig

Defined in

packages/agents/src/executors/local-executor.ts:187


dispose

dispose(): Promise<void>

Clean up all registered providers

Returns

Promise<void>

Overrides

BaseExecutor.dispose

Defined in

packages/agents/src/executors/local-executor.ts:216

Released under the MIT License.