crann
Version:
Effortless State Synchronization for Web Extensions
36 lines (35 loc) • 1.31 kB
TypeScript
/**
* ActionExecutor - Executes RPC actions
*
* Responsibilities:
* - Execute action handlers with context object
* - Validate action arguments
* - Handle errors
*/
import type { AgentInfo } from "../transport";
import { ConfigSchema, ValidatedConfig, DerivedState } from "./types";
export declare class ActionExecutor<TConfig extends ConfigSchema> {
private readonly config;
private readonly getState;
private readonly setState;
constructor(config: ValidatedConfig<TConfig>, getState: () => DerivedState<TConfig>, setState: (state: Partial<DerivedState<TConfig>>, agentId: string) => Promise<void>);
/**
* Execute an action by name.
*
* @param actionName - The name of the action to execute
* @param args - Arguments to pass to the action handler
* @param agentInfo - Info about the calling agent
* @returns The result of the action handler
* @throws {ActionError} If the action doesn't exist or fails
* @throws {ValidationError} If action validation fails
*/
execute(actionName: string, args: unknown[], agentInfo: AgentInfo): Promise<unknown>;
/**
* Check if an action exists.
*/
hasAction(actionName: string): boolean;
/**
* Get list of available action names.
*/
getActionNames(): string[];
}