UNPKG

@gravityai-dev/plugin-base

Version:

Base package for Gravity plugin development

180 lines 4.84 kB
/** * Essential types for plugin base classes * These are the core types needed by PromiseNode and CallbackNode */ export declare enum NodeInputType { STRING = "string", NUMBER = "number", BOOLEAN = "boolean", OBJECT = "object", ARRAY = "array", ANY = "any", SIGNAL = "signal",// Pure control signal with no data RESET = "reset",// Reset callback node state PAUSE = "pause",// Pause callback node execution RESUME = "resume",// Resume callback node execution SPAWN = "spawn" } export interface NodeInput { name: string; type: NodeInputType; description?: string; default?: any; } export interface NodeOutput { name: string; type: NodeInputType; description?: string; } export interface NodeExecutionContext { nodeId: string; executionId: string; workflowId?: string; config?: any; inputs?: Record<string, any>; credentials?: Record<string, any>; shouldPublishStatus?: boolean; workflow?: { id: string; runId: string; variables?: Record<string, any>; }; logger?: { info: (message: string) => void; error: (message: string) => void; debug: (message: string) => void; warn: (message: string) => void; }; services?: Record<string, Record<string, (...args: any[]) => Promise<any>>>; serviceCall?: { method: string; args: any[]; caller: { nodeId: string; executionId: string; }; }; } export interface NodeDefinition { name: string; description: string; category: string; color: string; icon?: string; inputs: NodeInput[]; outputs: NodeOutput[]; } export type NodeExecutor = (inputs: any, context: NodeExecutionContext) => Promise<any>; export interface NodeCredential { name: string; required: boolean; displayName?: string; description?: string; } export declare enum NodeConcurrency { SEQUENTIAL = 1,// One at a time (for strict ordering or shared resources) LOW = 50,// External APIs with user credentials MEDIUM = 100,// Database operations, file processing with user credentials HIGH = 200,// CPU-only operations, transformations UNLIMITED = -1 } export declare enum NodeExecutionMode { PROMISE = "promise", CALLBACK = "callback" } export interface EnhancedNodeDefinition extends NodeDefinition { type: string; logoUrl?: string; configSchema?: any; credentials?: NodeCredential[]; capabilities?: { isTrigger?: boolean; requiresConnection?: boolean; parallelizable?: boolean; concurrency?: NodeConcurrency; executionMode?: NodeExecutionMode; }; services?: { provides?: Array<{ name: string; description: string; implementation?: string; inputSchema?: any; outputSchema?: any; }>; requires?: Record<string, { description: string; methods: string[]; }>; }; serviceConnectors?: Array<{ name: string; description: string; serviceType: string; methods: string[]; }>; interactions?: Record<string, { label: string; description: string; icon?: string; color?: string; }>; testData?: any; isService?: boolean; } export interface NodeLifecycle { onAdd?: (context: { nodeId: string; workflowId: string; config?: Record<string, any>; }) => Promise<void>; onRemove?: (context: { nodeId: string; workflowId: string; config?: Record<string, any>; }) => Promise<void>; onBeforeExecute?: (context: { nodeId: string; workflowId: string; config?: Record<string, any>; }) => Promise<void>; onAfterExecute?: (context: { nodeId: string; workflowId: string; config?: Record<string, any>; }) => Promise<void>; } export interface WorkflowNode { definition: NodeDefinition; executor: NodeExecutor; lifecycle?: NodeLifecycle; } export interface TokenUsage { workflowId: string; executionId: string; nodeId: string; nodeType?: string; model: string; promptTokens?: number; completionTokens?: number; totalTokens: number; inputTokens?: number; outputTokens?: number; timestamp?: Date; } export interface PlatformConfig { openai?: { maxTokens?: number; }; REDIS_HOST?: string; REDIS_PORT?: number; REDIS_PASSWORD?: string; REDIS_USERNAME?: string; } export interface Logger { info: (...args: any[]) => void; error: (...args: any[]) => void; debug: (...args: any[]) => void; warn?: (...args: any[]) => void; } //# sourceMappingURL=types.d.ts.map