@relayplane/sdk
Version:
RelayPlane SDK - Local-first AI workflow engine for building multi-step AI workflows
103 lines • 2.85 kB
TypeScript
/**
* SDK Adapter Executor
*
* Bridges the SDK to the engine's adapter interface.
* Routes step executions to the appropriate provider adapter.
*
* @packageDocumentation
*/
import type { AdapterExecutor } from '@relayplane/engine';
import type { IAdapterRegistry } from '@relayplane/adapters';
/**
* SDK Adapter Executor
*
* Implements the engine's AdapterExecutor interface and routes
* step executions to registered provider adapters.
*
* @example
* ```typescript
* const registry = new AdapterRegistry();
* registry.register('openai', new OpenAIAdapter());
*
* const executor = new SDKAdapterExecutor(registry, {
* openai: process.env.OPENAI_API_KEY
* });
*
* const result = await executor({
* model: 'gpt-4o',
* input: 'Hello',
* stepName: 'greet',
* stepMetadata: { provider: 'openai' }
* });
* ```
*/
export declare class SDKAdapterExecutor {
/**
* Adapter registry for provider lookup.
*/
private registry;
/**
* Configuration for each provider (API keys, base URLs, etc).
*/
private configs;
/**
* Creates a new SDKAdapterExecutor.
*
* @param registry - Adapter registry
* @param configs - Provider configurations
*/
constructor(registry: IAdapterRegistry, configs: Record<string, {
apiKey: string;
baseUrl?: string;
}>);
/**
* Creates an AdapterExecutor function bound to this instance.
* This is what gets passed to the engine's runWorkflow function.
*
* @returns AdapterExecutor function
*
* @example
* ```typescript
* const adapterExecutor = executor.createExecutor();
* const result = await runWorkflow(workflow, input, adapterExecutor);
* ```
*/
createExecutor(): AdapterExecutor;
/**
* Executes a step using the appropriate provider adapter.
*
* @param args - Step execution arguments
* @returns Adapter execution result
*
* @private
*/
private execute;
/**
* Normalizes errors from adapters into standard format.
*
* @param error - Error from adapter or unexpected error
* @returns Normalized error object
* @private
*/
private normalizeError;
}
/**
* Creates an adapter executor from a registry and configurations.
* Convenience function for common use case.
*
* @param registry - Adapter registry
* @param configs - Provider configurations (API keys, base URLs)
* @returns AdapterExecutor function
*
* @example
* ```typescript
* const executor = createAdapterExecutor(registry, {
* openai: { apiKey: process.env.OPENAI_API_KEY }
* });
* ```
*/
export declare function createAdapterExecutor(registry: IAdapterRegistry, configs: Record<string, {
apiKey: string;
baseUrl?: string;
}>): AdapterExecutor;
//# sourceMappingURL=executor.d.ts.map