UNPKG

n8n

Version:

n8n Workflow Automation Tool

44 lines (43 loc) 2.1 kB
import type { BuiltTool } from '@n8n/agents'; import type { ExecutionRepository, UserRepository, WorkflowRepository, WorkflowEntity } from '@n8n/db'; import type { INode, IPinData } from 'n8n-workflow'; import { z } from 'zod'; import type { ActiveExecutions } from '../../../active-executions'; import type { WorkflowRunner } from '../../../workflow-runner'; import type { WorkflowFinderService } from '../../../workflows/workflow-finder.service'; import type { AgentJsonToolConfig } from '../json-config/agent-json-config'; export interface WorkflowToolContext { workflowRepository: WorkflowRepository; workflowRunner: WorkflowRunner; activeExecutions: ActiveExecutions; executionRepository: ExecutionRepository; workflowFinderService: WorkflowFinderService; userRepository: UserRepository; userId: string; projectId?: string; webhookBaseUrl?: string; } interface DetectedTrigger { node: INode; triggerType: string; } export declare function detectTriggerNode(workflow: WorkflowEntity): DetectedTrigger; export declare function validateCompatibility(workflow: WorkflowEntity): void; export declare function normalizeTriggerInput(triggerNode: INode, triggerType: string, inputData: Record<string, unknown>): IPinData; export declare function inferInputSchema(triggerNode: INode, triggerType: string): z.ZodObject<z.ZodRawShape>; export declare function executeWorkflow(workflow: WorkflowEntity, triggerNode: INode, triggerType: string, inputData: Record<string, unknown>, context: WorkflowToolContext, allOutputs?: boolean): Promise<{ executionId: string; status: string; data?: Record<string, unknown>; error?: string; }>; export declare function extractResult(executionRepository: ExecutionRepository, executionId: string, allOutputs: boolean): Promise<{ executionId: string; status: string; data?: Record<string, unknown>; error?: string; }>; export declare function resolveWorkflowTool(descriptor: Extract<AgentJsonToolConfig, { type: 'workflow'; }>, context: WorkflowToolContext): Promise<BuiltTool>; export {};