// @ts-ignore
/* eslint-disable */
import request from '@repo/api-client'

/** 发布智能体 POST /api/agent/doAgentPublish */
export async function postAgentDoAgentPublish(
  body: {
    start_node_id: string
    appAgentId: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/agent/doAgentPublish',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除智能体节点 POST /api/agent/doDeleteAgentNode */
export async function postAgentDoDeleteAgentNode(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/agent/doDeleteAgentNode',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除智能体边缘信息 POST /api/agent/doDeleteEdge */
export async function postAgentDoDeleteEdge(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/agent/doDeleteEdge',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 智能体编辑 POST /api/agent/doEditAgent */
export async function postAgentDoEditAgent(options?: { [key: string]: any }) {
  return request<{ isSuccess: boolean; code: number; result: string; isAuthorized: boolean }>(
    '/api/agent/doEditAgent',
    {
      method: 'POST',
      ...(options || {})
    }
  )
}

/** 运行智能体 POST /api/agent/doExecute */
export async function postAgentDoExecute(
  body: {
    appAgentId: string
    start_node_id: string
    is_debugger: boolean
    responseType: string
    params: Record<string, any>
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string; isAuthorized: boolean }>(
    '/api/agent/doExecute',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 智能体添加节点 POST /api/agent/doNewAgentNode */
export async function postAgentDoNewAgentNode(
  body: {
    appAgentId: string
    parentId?: string
    position: { x: number; y: number }
    width: number
    height: number
    selected: boolean
    nodeType: string
    zIndex: number
    prevNodeId?: string
    nodeHandleId?: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string; isAuthorized: boolean }>(
    '/api/agent/doNewAgentNode',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 根据边缘线，创建新的智能体节点 POST /api/agent/doNewAgentNodeWithEdge */
export async function postAgentDoNewAgentNodeWithEdge(
  body: {
    edgeId: string
    newNode: {
      appAgentId: string
      parentId: string
      position: { x: number; y: number }
      width: number
      height: number
      selected: boolean
      nodeType: string
      zIndex: number
      prevNodeId: string
      nodeHandleId: string
    }
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string; isAuthorized: boolean }>(
    '/api/agent/doNewAgentNodeWithEdge',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 新增智能体边缘信息 POST /api/agent/doNewEdge */
export async function postAgentDoNewEdge(
  body: {
    appAgentId: string
    source: string
    sourceHandle?: string
    target: string
    zIndex: number
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/agent/doNewEdge',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 保存智能体变量 POST /api/agent/doSaveAgentVariables */
export async function postAgentDoSaveAgentVariables(
  body: {
    appAgentId: string
    conversation_variables: string[]
    env_variables: { name?: string; value?: string; type?: string }[]
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string; isAuthorized: boolean }>(
    '/api/agent/doSaveAgentVariables',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 选中智能体边缘 POST /api/agent/doSelectedEdge */
export async function postAgentDoSelectedEdge(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/agent/doSelectedEdge',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 更新智能体节点 POST /api/agent/doUpdateAgentNode */
export async function postAgentDoUpdateAgentNode(
  body: {
    id: string
    appAgentId: string
    parentId: string
    position: { x: number; y: number }
    width: number
    height: number
    selected: boolean
    nodeType: string
    zIndex: number
    data: Record<string, any>
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    isAuthorized: boolean
    result?: Record<string, any>
  }>('/api/agent/doUpdateAgentNode', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取智能体信息 POST /api/agent/getAgentInfo */
export async function postAgentGetAgentInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      conversation_variables: string[]
      edges: {
        appAgentId: string
        creationTime: string
        data: { isInLoop: boolean; sourceType: string; targetType: string }
        id: string
        isDeleted: boolean
        selected: boolean
        source: string
        sourceHandle: string
        target: string
        targetHandle: string
        type: string
        updateTime: string
        zIndex: number
      }[]
      env_variables: { is_require?: boolean; name?: string; type?: string; value?: string }[]
      id: string
      name: string
      nodes: {
        appAgentId: string
        creationTime: string
        creatorUserId: string
        data: {
          outputs: { name: string; describe: string; is_require: boolean; type: string }[]
          bodyType: string
          exception: string
          ssl_verify: boolean
          body: { data: { type: string; value: string; key: string }[]; type: string }
          title: string
          type: string
          error_strategy: string
          retry_config: { max_retries: number; retry_enabled: boolean; retry_interval: number }
          authorization: { type: string; config: { api_key: string; header: string; type: string } }
          output: { headers: string[]; status_code: number; files: string[]; body: string }
          timeout_config: {
            max_write_timeout: number
            max_read_timeout: number
            max_connect_timeout: number
          }
          exceptionDefaultValue: { headers: string; status_code: number; body: string }
          id: string
          selected: boolean
          height: number
          errorConfig: { retry_delay: number; retry: boolean; max_retry: number }
          output_can_alter: boolean
          timeoutConfig: { read: number; write: number; connect: number }
          variables: { name: string; type: string; value: string }[]
          method: string
          isInIteration: boolean
          default_value: string[]
          params: string[]
          nodeType: string
          url: string
          width: number
          verifySSL: boolean
          heads: string[]
          position: { x: number; y: number }
          desc: string
          isInLoop: boolean
          filter_by: {
            conditions: { varType?: string; comparison_operator?: string; right_value?: string }[]
            enabled: boolean
          }
          limit: { size: number; enabled: boolean }
          order_by: { value: string; enabled: boolean; key: string }
          extract_by: { serial: string; enabled: boolean }
          code?: string
          code_language?: string
          cases?: {
            logical_operator: string
            id: string
            conditions: {
              varType: string
              left_value: string
              comparison_operator: string
              right_value: string
            }[]
          }[]
        }
        height: number
        id: string
        isDeleted: boolean
        position: { x: number; y: number }
        selected: boolean
        type: string
        updateTime: string
        width: number
        zIndex: number
        deleterUserId?: string
        deletionTime?: string
      }[]
      profilePhoto: string
      viewPort: { x: number; y: number; zoom: number }
    }
    isAuthorized: boolean
  }>('/api/agent/getAgentInfo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取智能体列表 POST /api/agent/getAgentList */
export async function postAgentGetAgentList(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.postAgentGetAgentListParams,
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        conversation_variables: string[]
        env_variables: { name: string; type: string; value: string }[]
        id: string
        name: string
        profilePhoto: string
        viewPort: { x: number; y: number; zoom: number }
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/agent/getAgentList', {
    method: 'POST',
    params: {
      ...params
    },
    ...(options || {})
  })
}

/** 获取智能体MonacoEditor提示器配置对象 POST /api/agent/getAgentMonacoEditorCompletions */
export async function postAgentGetAgentMonacoEditorCompletions(
  body: {},
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      javascript: {
        methods: string[]
        object: string
        properties: {
          detail: string
          documentation: string
          insertText: string
          kind: string
          label: string
          snippet: boolean
        }[]
        triggerCharacters: string[]
      }[]
    }
    isAuthorized: boolean
  }>('/api/agent/getAgentMonacoEditorCompletions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取智能体节点的最后一次运行日志 POST /api/agent/getAgentNodeLastRunnerLogs */
export async function postAgentGetAgentNodeLastRunnerLogs(
  body: {
    node_id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      appAgentId: string
      appAgentNodeId: string
      appAgentRunnerId: string
      creationTime: string
      errorMsg: string
      id: string
      isDeleted: boolean
      raw: {
        agent_node_id: string
        children: string[]
        end_time: number
        input_variable: { str: string }
        is_success: boolean
        node_name: string
        node_type: string
        output_variable: { result: string[] }
        start_time: number
        use_time: number
      }
      status: string
      updateTime: string
      useTime: number
    }
    isAuthorized: boolean
  }>('/api/agent/getAgentNodeLastRunnerLogs', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 根据节点id，获取节点之前的所有变量列表 POST /api/agent/getPrevNodeOutVariableList */
export async function postAgentGetPrevNodeOutVariableList(
  body: {
    node_id: string
    varTypeList: string[]
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      id: string
      name: string
      variableList: { expression: string; name: string; type: string }[]
    }[]
    isAuthorized: boolean
  }>('/api/agent/getPrevNodeOutVariableList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取支持的自定义智能体节点yaml列表 POST /api/agent/getSupportCustomAgentNodeYamlList */
export async function postAgentGetSupportCustomAgentNodeYamlList(
  body: {},
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string[]; isAuthorized: boolean }>(
    '/api/agent/getSupportCustomAgentNodeYamlList',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}
