export interface N8nWorkflow {
    name: string;
    nodes: N8nNode[];
    connections: N8nConnections;
    active?: boolean;
    settings?: {
        executionOrder?: 'v1' | 'v0';
        saveExecutionProgress?: boolean;
        saveManualExecutions?: boolean;
        saveDataErrorExecution?: 'all' | 'none';
        saveDataSuccessExecution?: 'all' | 'none';
        executionTimeout?: number;
        timezone?: string;
    };
    tags?: N8nTag[];
    meta?: Record<string, unknown>;
    id?: string;
    createdAt?: string;
    updatedAt?: string;
    /**
     * Metadata generated by LLM (not sent to n8n API)
     * Used internally for preview and clarification
     */
    _meta?: WorkflowMeta;
}
/**
 * Workflow metadata for internal use
 * Generated by LLM, used for preview and clarification
 * NOT sent to n8n API
 */
export interface WorkflowMeta {
    assumptions?: string[];
    suggestions?: string[];
    requiresClarification?: string[];
}
export interface N8nNode {
    id?: string;
    name: string;
    type: string;
    typeVersion: number;
    position: [number, number];
    parameters: Record<string, unknown>;
    credentials?: Record<string, N8nCredentialReference>;
    disabled?: boolean;
    notes?: string;
    notesInFlow?: boolean;
    color?: string;
    continueOnFail?: boolean;
    executeOnce?: boolean;
    alwaysOutputData?: boolean;
    retryOnFail?: boolean;
    maxTries?: number;
    waitBetweenTries?: number;
    onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow';
}
export interface N8nCredentialReference {
    id: string;
    name: string;
}
export interface N8nConnections {
    [nodeName: string]: {
        [outputType: string]: Array<Array<{
            node: string;
            type: string;
            index: number;
        }>>;
    };
}
export interface N8nWorkflowResponse extends N8nWorkflow {
    id: string;
    createdAt: string;
    updatedAt: string;
    versionId: string;
}
export interface N8nCredential {
    id: string;
    name: string;
    type: string;
    data?: Record<string, unknown>;
    isResolvable?: boolean;
    createdAt: string;
    updatedAt: string;
}
export interface N8nExecution {
    id: string;
    finished: boolean;
    mode: 'cli' | 'error' | 'integrated' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook' | 'evaluation' | 'chat';
    retryOf?: string | null;
    retrySuccessId?: string | null;
    startedAt: string;
    stoppedAt?: string | null;
    workflowId: string;
    status: 'canceled' | 'crashed' | 'error' | 'new' | 'running' | 'success' | 'unknown' | 'waiting';
    waitTill?: string | null;
    customData?: Record<string, unknown>;
    data?: {
        resultData?: {
            runData?: Record<string, unknown[]>;
            lastNodeExecuted?: string;
            error?: {
                message: string;
                stack?: string;
            };
        };
        executionData?: {
            contextData?: Record<string, unknown>;
            nodeExecutionStack?: unknown[];
            waitingExecution?: Record<string, unknown>;
        };
    };
}
export interface N8nTag {
    id: string;
    name: string;
    createdAt: string;
    updatedAt: string;
}
export interface NodeDefinition {
    name: string;
    displayName: string;
    description: string;
    icon?: string;
    iconUrl?: string;
    group: string[];
    version: number | number[];
    subtitle?: string;
    defaults: {
        name: string;
        color?: string;
    };
    inputs: string[] | string;
    outputs: string[] | string;
    credentials?: Array<{
        name: string;
        required: boolean;
        displayOptions?: unknown;
    }>;
    properties: NodeProperty[];
    webhooks?: unknown[];
    polling?: boolean;
    triggerPanel?: unknown;
}
export interface NodeProperty {
    displayName: string;
    name: string;
    type: string;
    default: unknown;
    required?: boolean;
    description?: string;
    options?: Array<{
        name: string;
        value: string | number | boolean;
        description?: string;
    }>;
    displayOptions?: unknown;
    placeholder?: string;
    hint?: string;
    routing?: unknown;
}
export interface NodeSearchResult {
    node: NodeDefinition;
    score: number;
    matchReason: string;
}
export interface IntegrationFilterResult {
    remaining: NodeSearchResult[];
    removed: NodeSearchResult[];
}
export interface KeywordExtractionResult {
    keywords: string[];
}
/**
 * Result of semantic workflow matching
 */
export interface WorkflowMatchResult {
    matchedWorkflowId: string | null;
    confidence: 'high' | 'medium' | 'low' | 'none';
    matches: Array<{
        id: string;
        name: string;
        score: number;
    }>;
    reason: string;
}
export interface WorkflowValidationResult {
    valid: boolean;
    errors: string[];
    warnings: string[];
}
export declare const N8N_CREDENTIAL_PROVIDER_TYPE = "n8n_credential_provider";
/**
 * Result of a credential resolution attempt by an external provider.
 */
export type CredentialProviderResult = {
    status: 'credential_data';
    data: Record<string, unknown>;
} | {
    status: 'needs_auth';
    authUrl: string;
} | null;
/**
 * External credential provider interface.
 *
 * Hosts (e.g. eliza-cloud) can register a service implementing this interface
 * to automatically resolve credentials (via OAuth, API keys, etc.).
 * The plugin works without one — it's an optional enhancement.
 *
 * Register on runtime as service type 'n8n_credential_provider'.
 */
export interface CredentialProvider {
    resolve(userId: string, credType: string): Promise<CredentialProviderResult>;
    checkCredentialTypes?(credTypes: string[]): CheckCredentialTypesResult;
}
export interface CheckCredentialTypesResult {
    supported: string[];
    unsupported: string[];
}
export interface FeasibilityResult {
    feasible: boolean;
    reason: string;
}
/**
 * Type guard to check if a service implements CredentialProvider
 */
export declare function isCredentialProvider(service: unknown): service is CredentialProvider;
export declare const N8N_CREDENTIAL_STORE_TYPE = "n8n_credential_store";
export interface CredentialMapping {
    credType: string;
    n8nCredentialId: string;
}
export interface N8nCredentialStoreApi {
    get(userId: string, credType: string): Promise<string | null>;
    set(userId: string, credType: string, n8nCredId: string): Promise<void>;
    listByUser(userId: string): Promise<CredentialMapping[]>;
}
export interface CredentialResolutionResult {
    workflow: N8nWorkflow;
    missingConnections: MissingConnection[];
    injectedCredentials: Map<string, string>;
}
export interface MissingConnection {
    credType: string;
    authUrl?: string;
}
export interface N8nPluginConfig {
    apiKey: string;
    host: string;
    credentials?: Record<string, string>;
}
export interface WorkflowDraft {
    workflow: N8nWorkflow;
    prompt: string;
    userId: string;
    createdAt: number;
    /** ID of the message that created this draft — used to prevent same-turn auto-confirm. */
    originMessageId?: string;
}
export interface DraftIntentResult {
    intent: 'confirm' | 'cancel' | 'modify' | 'new' | 'show_preview';
    modificationRequest?: string;
    reason: string;
}
export interface WorkflowCreationResult extends Record<string, unknown> {
    id: string;
    name: string;
    active: boolean;
    nodeCount: number;
    missingCredentials: MissingConnection[];
}
export declare class N8nApiError extends Error {
    statusCode?: number | undefined;
    response?: unknown | undefined;
    constructor(message: string, statusCode?: number | undefined, response?: unknown | undefined);
}
export declare class UnsupportedIntegrationError extends Error {
    unsupportedServices: string[];
    availableServices: string[];
    constructor(unsupportedServices: string[], availableServices: string[]);
}
/**
 * JSON schema content from n8n output schemas
 */
export interface SchemaContent {
    type: string;
    properties?: Record<string, unknown>;
    items?: SchemaContent;
    [key: string]: unknown;
}
/**
 * Expression reference found in node parameters
 */
export interface ExpressionRef {
    fullExpression: string;
    field: string;
    path: string[];
    paramPath: string;
    sourceNodeName?: string;
}
/**
 * Invalid output reference detected during validation
 */
export interface OutputRefValidation {
    nodeName: string;
    expression: string;
    field: string;
    sourceNodeName: string;
    sourceNodeType: string;
    resource: string;
    operation: string;
    availableFields: string[];
}
//# sourceMappingURL=index.d.ts.map