UNPKG

arcananex-synapse

Version:

Agentic AI framework

45 lines 1.48 kB
export interface CommandInterface<T, R> { execute(taskData?: T): Promise<R>; getDescription(): string | undefined; } /** * Example usage: * @example * ```typescript * // Create an instance of Command for a synchronous task. * const multiplyCommand = new Command<number, number>(); * * // Set the task to multiply the input by 2. * multiplyCommand.setTask((num: number) => { * return num * 2; * }); * * // Execute the task, passing in a number. * multiplyCommand.execute(5) * .then(result => console.log("Synchronous task result:", result)) // Expected output: 10 * .catch(err => console.error(err)); * ``` */ export declare class Command<T, R> implements CommandInterface<T, R> { private task?; private description?; private agentName?; constructor(agentName: string); execute(taskData?: T): Promise<R>; getDescription(): string | undefined; getTask(): Task<T, R> | undefined; setTask(task: Task<T, R>, description: string): void; } /** * ChainCommand supports chaining several tasks. * When execute() is called, it runs all tasks in order, * feeding the output of task[i] as input to task[i+1]. */ export declare class ChainCommand<T, R> implements CommandInterface<T, R> { private commands; add<In, Out>(command: CommandInterface<In, Out>): this; getDescription(): string; execute(input?: T): Promise<R>; } export type Task<T, R> = (arg?: T) => R | Promise<R>; //# sourceMappingURL=command.d.ts.map