import type { BuiltTool } from '@n8n/agents'; import { type AgentJsonToolConfig } from '@n8n/api-types'; import type { WorkflowEntity } from '@n8n/db'; import type { INode, RelatedAgentRun, WorkflowExecuteMode } from 'n8n-workflow'; import { z } from 'zod'; import type { ActiveExecutions } from '../../../active-executions'; import type { SubworkflowPolicyChecker } from '../../../executions/pre-execution-checks'; import type { WorkflowRunner } from '../../../workflow-runner'; import type { InstrumentToolAdditionalData } from '../agent-runtime-instrumentation'; import type { WorkflowToolWorkflowLoader } from './workflow-tool-workflow-loader.service'; interface WorkflowWaitState { waitTill?: Date; } interface WorkflowToolResult { executionId: string; status: string; data?: Record; error?: string; note?: string; } export interface WorkflowToolExecutionResult extends WorkflowToolResult { wait?: WorkflowWaitState; } export type WorkflowToolExecutionMode = Extract; export interface WorkflowToolContext { workflowLoader: WorkflowToolWorkflowLoader; workflowRunner: WorkflowRunner; subworkflowPolicyChecker: SubworkflowPolicyChecker; activeExecutions: ActiveExecutions; projectId: string; executionMode: WorkflowToolExecutionMode; usePublishedWorkflowVersion?: boolean; agentId?: string; integrationType?: string; previewChat?: boolean; userId?: string; supportsHitl?: boolean; backgroundTasksEnabled?: boolean; instrumentToolAdditionalData?: InstrumentToolAdditionalData; } export interface WorkflowToolRunContext extends WorkflowToolContext { agentRun?: RelatedAgentRun; } interface DetectedTrigger { node: INode; triggerType: string; } export declare function detectTriggerNode(workflow: WorkflowEntity): DetectedTrigger; export declare function validateCompatibility(workflow: WorkflowEntity): void; export type WorkflowInputFieldDef = { name: string; type?: string; }; export declare function listWorkflowInputFields(triggerNode: INode): WorkflowInputFieldDef[]; export declare function inferInputSchema(triggerNode: INode, triggerType: string): z.ZodObject; type WorkflowToolInputsConfig = NonNullable['inputs']>; export declare function getFixedWorkflowToolInputs(inputs: WorkflowToolInputsConfig | undefined): Record; export declare function omitFixedFieldsFromSchema(schema: z.ZodObject, inputs: WorkflowToolInputsConfig | undefined): z.ZodObject; export declare function mergeWorkflowToolInput(llmInput: Record, inputs: WorkflowToolInputsConfig | undefined, fullSchema: z.ZodObject): Record; export declare function executeWorkflow(workflow: WorkflowEntity, triggerNode: INode, inputData: Record, context: WorkflowToolRunContext, allOutputs?: boolean, instrumentedToolName?: string): Promise; export declare function extractResult(executionId: string, allOutputs: boolean): Promise; export declare function resolveWorkflowTool(descriptor: Extract, context: WorkflowToolContext): Promise; export declare function buildUnavailableWorkflowTool(descriptor: Extract, context: WorkflowToolContext): BuiltTool; export {};