UNPKG

n8n

Version:

n8n Workflow Automation Tool

108 lines (107 loc) 4.54 kB
import type { User } from '@n8n/db'; import { type IRunExecutionData } from 'n8n-workflow'; import z from 'zod'; import type { ToolDefinition } from '../mcp.types'; import type { ActiveExecutions } from '../../../active-executions'; import type { Telemetry } from '../../../telemetry'; import type { WorkflowRunner } from '../../../workflow-runner'; import type { WorkflowFinderService } from '../../../workflows/workflow-finder.service'; declare const inputSchema: z.ZodObject<{ workflowId: z.ZodString; 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" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT"; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }, { body?: Record<string, unknown> | undefined; method?: "OPTIONS" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }>; }, "strip", z.ZodTypeAny, { type: "webhook"; webhookData: { method: "OPTIONS" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT"; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }; }, { type: "webhook"; webhookData: { body?: Record<string, unknown> | undefined; method?: "OPTIONS" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }; }>]>>; }, "strip", z.ZodTypeAny, { workflowId: string; inputs?: { type: "chat"; chatInput: string; } | { type: "form"; formData: Record<string, unknown>; } | { type: "webhook"; webhookData: { method: "OPTIONS" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT"; body?: Record<string, unknown> | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }; } | undefined; }, { workflowId: string; inputs?: { type: "chat"; chatInput: string; } | { type: "form"; formData: Record<string, unknown>; } | { type: "webhook"; webhookData: { body?: Record<string, unknown> | undefined; method?: "OPTIONS" | "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | undefined; query?: Record<string, string> | undefined; headers?: Record<string, string> | undefined; }; } | undefined; }>; type ExecuteWorkflowOutput = { success: boolean; executionId: string | null; result?: IRunExecutionData['resultData']; error?: unknown; }; export declare const createExecuteWorkflowTool: (user: User, workflowFinderService: WorkflowFinderService, activeExecutions: ActiveExecutions, workflowRunner: WorkflowRunner, telemetry: Telemetry) => ToolDefinition<typeof inputSchema.shape>; export declare const executeWorkflow: (user: User, workflowFinderService: WorkflowFinderService, activeExecutions: ActiveExecutions, workflowRunner: WorkflowRunner, workflowId: string, inputs?: z.infer<typeof inputSchema>["inputs"]) => Promise<ExecuteWorkflowOutput>; export {};