@elimeleth/vct-flow
Version:
Crea un archivo app.ts, coloca el codigo de abajo alli y luego puedes correrlo con `npx tsx src/app.ts`
71 lines (70 loc) • 2.8 kB
TypeScript
import { Assistant, BaseAssistant, ClaudeAsst, GeminiAsst, OpenAILegacyAsst } from "@elimeleth/vct-assistants";
import { Workflow } from ".";
import { Context, GlobalRouterArgs } from "..";
import { ProviderClass } from "../io/providerClass";
export declare class GlobalRouter<TFlows extends Workflow<string>[], TProvider extends Partial<ProviderClass>> {
private args;
private parentNodes;
private state;
private checkpointer;
private messageQueues;
private processingFlags;
private messages;
private port;
private host;
private hub_setup;
private abortController;
private model;
assistant: Assistant | BaseAssistant | ClaudeAsst | GeminiAsst | OpenAILegacyAsst;
/**
* Constructs an instance of the class.
*
* @param args - Partial arguments for GlobalRouterArgs.
*/
constructor(args: Partial<GlobalRouterArgs<TProvider>>);
private send_message_to_hub;
private send_connection_to_hub;
private send_healthcheck_config;
private listenerBusEvents;
private setState;
/**
* Initializes the provider and sets up event listeners.
*
* This method performs the following steps:
* 1. Initializes the provider with the specified port and options.
* 2. Sets up event listeners from the listener bus events.
* 3. When the provider is ready, loads all checkpoints and optionally restores previous checkpoints.
*
* @returns {Promise<void>} A promise that resolves when the setup is complete.
*/
listen(): Promise<void>;
/**
* Adds the given parent nodes to the workflow, ensuring that each node has a unique name.
*
* @param {Workflow[]} parentNodes - An array of Workflow objects to be added as parent nodes.
* @returns {this} The current instance of the class, allowing for method chaining.
* @throws {Error} If a node with the same name already exists in the parent nodes.
*/
addFlows<NewFlows extends Workflow<string>[]>(parentNodes: NewFlows): GlobalRouter<[...TFlows, ...NewFlows], TProvider>;
/**
* Routes the trigger to the appropriate workflow node based on the provided context.
*
* @param {string} trigger - The trigger string to match against nodes.
* @param {Context} ctx - The context in which the trigger is being evaluated.
* @returns {Workflow | null} - The matched workflow node or null if no match is found.
*/
routeTrigger(trigger: string, ctx: Context): Workflow<string> | null;
private captureIntention;
private enqueueMessage;
private containsMedia;
private isPaused;
private circuitBreaker;
private handleMedia;
private captureParentIntention;
private executeNode;
private processQueue;
private matchTrigger;
private matchArrayKeys;
private matchNonStringKey;
private matchKeys;
}