/**
 * AI Agent Node - Version 1.3
 * Generates an action plan and executes it. Can use external tools.
 */


export interface LcAgentV13Params {
/**
 * Agent
 * @default conversationalAgent
 */
    agent?: 'conversationalAgent' | 'openAiFunctionsAgent' | 'planAndExecuteAgent' | 'reActAgent' | 'sqlAgent';
/**
 * Source for Prompt (User Message)
 * @default auto
 */
    promptType?: 'auto' | 'guardrails' | 'define' | Expression<string>;
/**
 * Require Specific Output Format
 * @displayOptions.hide { agent: ["sqlAgent"] }
 * @default false
 */
    hasOutputParser?: boolean;
/**
 * Options
 * @displayOptions.show { agent: ["toolsAgent", "conversationalAgent", "openAiFunctionsAgent", "reActAgent", "sqlAgent", "planAndExecuteAgent"] }
 * @default {}
 */
    options?: {
    /** The message that will be sent to the agent before the conversation starts
     * @builderHint Must include: agent's purpose, exact names of connected tools, and response instructions
     * @default You are a helpful assistant
     */
    systemMessage?: string | Expression<string>;
    /** The maximum number of iterations the agent will run before stopping
     * @default 10
     */
    maxIterations?: number | Expression<number>;
    /** Whether or not the output should include intermediate steps the agent took
     * @default false
     */
    returnIntermediateSteps?: boolean | Expression<boolean>;
    /** Whether or not binary images should be automatically passed through to the agent as image type messages
     * @default true
     */
    passthroughBinaryImages?: boolean | Expression<boolean>;
    /** Custom metadata added to tracing events
     * @default {}
     */
    tracingMetadata?: {
        /** Metadata
     */
    values?: Array<{
      /** Key
       */
      key?: string | Expression<string>;
      /** The field value type
       * @default stringValue
       */
      type?: 'arrayValue' | 'booleanValue' | 'numberValue' | 'objectValue' | 'stringValue' | Expression<string>;
      /** Value
       * @displayOptions.show { type: ["stringValue"] }
       */
      stringValue?: string | Expression<string>;
      /** Value
       * @displayOptions.show { type: ["numberValue"] }
       */
      numberValue?: string | Expression<string>;
      /** Value
       * @displayOptions.show { type: ["booleanValue"] }
       * @default true
       */
      booleanValue?: 'true' | 'false' | Expression<string>;
      /** Value
       * @displayOptions.show { type: ["arrayValue"] }
       */
      arrayValue?: string | Expression<string>;
      /** Value
       * @displayOptions.show { type: ["objectValue"] }
       * @default ={}
       */
      objectValue?: IDataObject | string | Expression<string>;
    }>;
  };
    /** The message that will provide the agent with a list of tools to use
     */
    humanMessage?: string | Expression<string>;
    /** String to use directly as the human message template
     */
    humanMessageTemplate?: string | Expression<string>;
    /** String to put before the list of tools
     * @default Answer the following questions as best you can. You have access to the following tools:
     */
    prefix?: string | Expression<string>;
    /** String to put after the list of tools that will be used if chat model is used
     * @default Begin! Reminder to always use the exact characters `Final Answer` when responding.
     */
    suffixChat?: string | Expression<string>;
    /** String to put after the list of tools that will be used if regular model is used
     */
    suffix?: string | Expression<string>;
    /** Comma-separated list of tables to ignore from the database. If empty, no tables are ignored.
     */
    ignoredTables?: string | Expression<string>;
    /** Number of sample rows to include in the prompt to the agent. It helps the agent to understand the schema of the database but it also increases the amount of tokens used.
     * @default 3
     */
    includedSampleRows?: number | Expression<number>;
    /** Comma-separated list of tables to include in the database. If empty, all tables are included.
     */
    includedTables?: string | Expression<string>;
    /** Prefix prompt to use for the agent
     */
    prefixPrompt?: string | Expression<string>;
    /** Suffix prompt to use for the agent
     */
    suffixPrompt?: string | Expression<string>;
    /** The maximum number of results to return
     * @default 10
     */
    topK?: number | Expression<number>;
  };
/**
 * SQL database to connect to
 * @displayOptions.show { agent: ["sqlAgent"] }
 * @default sqlite
 */
    dataSource?: 'mysql' | 'postgres' | 'sqlite' | Expression<string>;
/**
 * Input Binary Field
 * @hint The name of the input binary field containing the file to be extracted
 * @displayOptions.show { agent: ["sqlAgent"], dataSource: ["sqlite"] }
 * @default data
 */
    binaryPropertyName?: string | Expression<string>;
/**
 * Prompt (User Message)
 * @builderHint Use expressions to include dynamic data from previous nodes (e.g., expr('{{ $json.input }}')). Static text prompts ignore incoming data.
 * @placeholderSupported false
 * @displayOptions.show { promptType: ["define"], agent: ["sqlAgent"] }
 */
    text: string | Expression<string>;
}

export interface LcAgentV13SubnodeConfig {
  model: LanguageModelInstance | LanguageModelInstance[];
  memory?: MemoryInstance;
  tools?: ToolInstance[];
  /**
   * @displayOptions.show { hasOutputParser: [true] }
   */
  outputParser?: OutputParserInstance;
}

export interface LcAgentV13Credentials {
  mySql: CredentialReference;
  postgres: CredentialReference;
}

interface LcAgentV13NodeBase {
  type: '@n8n/n8n-nodes-langchain.agent';
  version: 1.3;
  credentials?: LcAgentV13Credentials;
  isTrigger: true;
}

export type LcAgentV13ParamsNode = LcAgentV13NodeBase & {
  config: NodeConfig<LcAgentV13Params> & { subnodes: LcAgentV13SubnodeConfig };
};

export type LcAgentV13Node = LcAgentV13ParamsNode;