n8n
Version:
n8n Workflow Automation Tool
44 lines (43 loc) • 2.22 kB
TypeScript
import type { BuiltTool } from '@n8n/agents';
import { type AgentJsonToolConfig } from '@n8n/api-types';
import type { WorkflowEntity } from '@n8n/db';
import type { INode, IPinData, WorkflowExecuteMode } from 'n8n-workflow';
import { z } from 'zod';
import type { ActiveExecutions } from '../../../active-executions';
import type { WorkflowRunner } from '../../../workflow-runner';
import type { InstrumentToolAdditionalData } from '../agent-runtime-instrumentation';
import type { WorkflowToolWorkflowLoader } from './workflow-tool-workflow-loader.service';
export type WorkflowToolExecutionMode = Extract<WorkflowExecuteMode, 'manual' | 'integrated'>;
export interface WorkflowToolContext {
workflowLoader: WorkflowToolWorkflowLoader;
workflowRunner: WorkflowRunner;
activeExecutions: ActiveExecutions;
projectId: string;
executionMode: WorkflowToolExecutionMode;
webhookBaseUrl?: string;
instrumentToolAdditionalData?: InstrumentToolAdditionalData;
}
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>, executionMode: WorkflowToolExecutionMode): 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, instrumentedToolName?: string): Promise<{
executionId: string;
status: string;
data?: Record<string, unknown>;
error?: string;
}>;
export declare function extractResult(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 {};