UNPKG

n8n

Version:

n8n Workflow Automation Tool

110 lines (109 loc) 4.75 kB
import type { User } from '@n8n/db'; import z from 'zod'; import type { ToolDefinition } from '../mcp.types'; import { type FoundWorkflow } from './workflow-validation.utils'; import type { McpService } from '../../../modules/mcp/mcp.service'; import type { Telemetry } from '../../../telemetry'; import type { WorkflowRunner } from '../../../workflow-runner'; import type { WorkflowFinderService } from '../../../workflows/workflow-finder.service'; export { type FoundWorkflow }; declare const inputSchema: z.ZodObject<{ workflowId: z.ZodString; executionMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["manual", "production"]>>>; inputs: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ type: z.ZodLiteral<"chat">; chatInput: z.ZodString; }, "strip", z.ZodTypeAny, { type: "chat"; chatInput: string; }, { type: "chat"; chatInput: string; }>, z.ZodObject<{ type: z.ZodLiteral<"form">; formData: z.ZodRecord<z.ZodString, z.ZodUnknown>; }, "strip", z.ZodTypeAny, { type: "form"; formData: Record<string, unknown>; }, { type: "form"; formData: Record<string, unknown>; }>, z.ZodObject<{ type: z.ZodLiteral<"webhook">; webhookData: z.ZodObject<{ method: z.ZodDefault<z.ZodOptional<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]>>>; query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, "strip", z.ZodTypeAny, { method: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT"; headers?: Record<string, string> | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }, { headers?: Record<string, string> | undefined; method?: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }>; }, "strip", z.ZodTypeAny, { type: "webhook"; webhookData: { method: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT"; headers?: Record<string, string> | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }; }, { type: "webhook"; webhookData: { headers?: Record<string, string> | undefined; method?: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }; }>]>>; }, "strip", z.ZodTypeAny, { workflowId: string; executionMode: "manual" | "production"; inputs?: { type: "chat"; chatInput: string; } | { type: "form"; formData: Record<string, unknown>; } | { type: "webhook"; webhookData: { method: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT"; headers?: Record<string, string> | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }; } | undefined; }, { workflowId: string; inputs?: { type: "chat"; chatInput: string; } | { type: "form"; formData: Record<string, unknown>; } | { type: "webhook"; webhookData: { headers?: Record<string, string> | undefined; method?: "OPTIONS" | "GET" | "DELETE" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; }; } | undefined; executionMode?: "manual" | "production" | undefined; }>; type ExecuteWorkflowOutput = { executionId: string | null; status: 'started' | 'error'; error?: string; }; export declare const createExecuteWorkflowTool: (user: User, workflowFinderService: WorkflowFinderService, workflowRunner: WorkflowRunner, telemetry: Telemetry, mcpService: McpService) => ToolDefinition<typeof inputSchema.shape>; export declare const executeWorkflow: (user: User, workflowFinderService: WorkflowFinderService, workflowRunner: WorkflowRunner, mcpService: McpService, workflowId: string, inputs?: z.infer<typeof inputSchema>["inputs"], executionMode?: z.infer<typeof inputSchema>["executionMode"]) => Promise<ExecuteWorkflowOutput>;