// This file is auto-generated by @hey-api/openapi-ts

export type ClientOptions = {
  baseUrl: `${string}://${string}/console/api` | (string & {})
}

export type AgentRosterListResponse = {
  data: Array<AgentRosterResponse>
  has_more: boolean
  limit: number
  page: number
  total: number
}

export type RosterAgentCreatePayload = {
  agent_soul?: AgentSoulConfig
  description?: string
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType
  name: string
  version_note?: string | null
}

export type AgentRosterResponse = {
  active_config_snapshot?: AgentConfigSnapshotSummaryResponse
  active_config_snapshot_id?: string | null
  agent_kind: AgentKind
  app_id?: string | null
  archived_at?: string | null
  archived_by?: string | null
  created_at?: string | null
  created_by?: string | null
  description: string
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType
  id: string
  name: string
  scope: AgentScope
  source: AgentSource
  status: AgentStatus
  updated_at?: string | null
  updated_by?: string | null
  workflow_id?: string | null
  workflow_node_id?: string | null
}

export type AgentInviteOptionsResponse = {
  data: Array<AgentInviteOptionResponse>
  has_more: boolean
  limit: number
  page: number
  total: number
}

export type RosterAgentUpdatePayload = {
  description?: string | null
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType
  name?: string | null
}

export type AgentConfigSnapshotListResponse = {
  data: Array<AgentConfigSnapshotSummaryResponse>
}

export type AgentConfigSnapshotDetailResponse = {
  agent_id?: string | null
  config_snapshot: AgentSoulConfig
  created_at?: string | null
  created_by?: string | null
  id: string
  revisions?: Array<AgentConfigRevisionResponse>
  summary?: string | null
  version: number
  version_note?: string | null
}

export type AgentSoulConfig = {
  app_features?: {
    [key: string]: unknown
  }
  app_variables?: Array<AppVariableConfig>
  env?: AgentSoulEnvConfig
  human?: AgentSoulHumanConfig
  knowledge?: AgentSoulKnowledgeConfig
  memory?: AgentSoulMemoryConfig
  misc_legacy?: {
    [key: string]: unknown
  }
  model?: AgentSoulModelConfig
  prompt?: AgentSoulPromptConfig
  sandbox?: AgentSoulSandboxConfig
  schema_version?: number
  skills_files?: AgentSoulSkillsFilesConfig
  tools?: AgentSoulToolsConfig
}

export type AgentIconType = 'emoji' | 'image' | 'link'

export type AgentConfigSnapshotSummaryResponse = {
  agent_id?: string | null
  created_at?: string | null
  created_by?: string | null
  id: string
  summary?: string | null
  version: number
  version_note?: string | null
}

export type AgentKind = 'dify_agent'

export type AgentScope = 'roster' | 'workflow_only'

export type AgentSource = 'agent_app' | 'imported' | 'system' | 'workflow'

export type AgentStatus = 'active' | 'archived'

export type AgentInviteOptionResponse = {
  active_config_snapshot?: AgentConfigSnapshotSummaryResponse
  active_config_snapshot_id?: string | null
  agent_kind: AgentKind
  app_id?: string | null
  archived_at?: string | null
  archived_by?: string | null
  created_at?: string | null
  created_by?: string | null
  description: string
  existing_node_ids?: Array<string>
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType
  id: string
  in_current_workflow_count?: number
  is_in_current_workflow?: boolean
  name: string
  scope: AgentScope
  source: AgentSource
  status: AgentStatus
  updated_at?: string | null
  updated_by?: string | null
  workflow_id?: string | null
  workflow_node_id?: string | null
}

export type AgentConfigRevisionResponse = {
  created_at?: string | null
  created_by?: string | null
  current_snapshot_id: string
  id: string
  operation: AgentConfigRevisionOperation
  previous_snapshot_id?: string | null
  revision: number
  summary?: string | null
  version_note?: string | null
}

export type AppVariableConfig = {
  default?: unknown
  name: string
  required?: boolean
  type: string
}

export type AgentSoulEnvConfig = {
  secret_refs?: Array<{
    [key: string]: unknown
  }>
  variables?: Array<{
    [key: string]: unknown
  }>
}

export type AgentSoulHumanConfig = {
  contacts?: Array<{
    [key: string]: unknown
  }>
  tools?: Array<{
    [key: string]: unknown
  }>
}

export type AgentSoulKnowledgeConfig = {
  datasets?: Array<{
    [key: string]: unknown
  }>
  query_config?: {
    [key: string]: unknown
  }
  query_mode?: AgentKnowledgeQueryMode
}

export type AgentSoulMemoryConfig = {
  artifacts?: Array<{
    [key: string]: unknown
  }>
  budget?: string | null
  scope?: string | null
}

export type AgentSoulModelConfig = {
  credential_ref?: AgentSoulModelCredentialRef
  model: string
  model_provider: string
  model_settings?: {
    [key: string]: unknown
  }
  plugin_id: string
}

export type AgentSoulPromptConfig = {
  system_prompt?: string
}

export type AgentSoulSandboxConfig = {
  config?: {
    [key: string]: unknown
  }
  provider?: string | null
}

export type AgentSoulSkillsFilesConfig = {
  files?: Array<{
    [key: string]: unknown
  }>
  skills?: Array<{
    [key: string]: unknown
  }>
}

export type AgentSoulToolsConfig = {
  cli_tools?: Array<{
    [key: string]: unknown
  }>
  dify_tools?: Array<AgentSoulDifyToolConfig>
}

export type AgentConfigRevisionOperation
  = | 'create_version'
    | 'save_current_version'
    | 'save_new_agent'
    | 'save_new_version'
    | 'save_to_roster'

export type AgentKnowledgeQueryMode = 'generated_query' | 'user_query'

export type AgentSoulModelCredentialRef = {
  id?: string | null
  provider?: string | null
  type: string
}

export type AgentSoulDifyToolConfig = {
  credential_ref?: AgentSoulDifyToolCredentialRef
  credential_type?: 'api-key' | 'oauth2' | 'unauthorized'
  description?: string | null
  enabled?: boolean
  name?: string | null
  plugin_id?: string | null
  provider?: string | null
  provider_id?: string | null
  provider_type?: string
  runtime_parameters?: {
    [key: string]: unknown
  }
  tool_name: string
}

export type AgentSoulDifyToolCredentialRef = {
  id?: string | null
  provider?: string | null
  type?: 'provider' | 'tool'
}

export type GetAgentsData = {
  body?: never
  path?: never
  query?: {
    keyword?: string
    limit?: number
    page?: number
  }
  url: '/agents'
}

export type GetAgentsResponses = {
  200: AgentRosterListResponse
}

export type GetAgentsResponse = GetAgentsResponses[keyof GetAgentsResponses]

export type PostAgentsData = {
  body: RosterAgentCreatePayload
  path?: never
  query?: never
  url: '/agents'
}

export type PostAgentsResponses = {
  201: AgentRosterResponse
}

export type PostAgentsResponse = PostAgentsResponses[keyof PostAgentsResponses]

export type GetAgentsInviteOptionsData = {
  body?: never
  path?: never
  query?: {
    app_id?: string
    keyword?: string
    limit?: number
    page?: number
  }
  url: '/agents/invite-options'
}

export type GetAgentsInviteOptionsResponses = {
  200: AgentInviteOptionsResponse
}

export type GetAgentsInviteOptionsResponse
  = GetAgentsInviteOptionsResponses[keyof GetAgentsInviteOptionsResponses]

export type DeleteAgentsByAgentIdData = {
  body?: never
  path: {
    agent_id: string
  }
  query?: never
  url: '/agents/{agent_id}'
}

export type DeleteAgentsByAgentIdResponses = {
  204: {
    [key: string]: never
  }
}

export type DeleteAgentsByAgentIdResponse
  = DeleteAgentsByAgentIdResponses[keyof DeleteAgentsByAgentIdResponses]

export type GetAgentsByAgentIdData = {
  body?: never
  path: {
    agent_id: string
  }
  query?: never
  url: '/agents/{agent_id}'
}

export type GetAgentsByAgentIdResponses = {
  200: AgentRosterResponse
}

export type GetAgentsByAgentIdResponse
  = GetAgentsByAgentIdResponses[keyof GetAgentsByAgentIdResponses]

export type PatchAgentsByAgentIdData = {
  body: RosterAgentUpdatePayload
  path: {
    agent_id: string
  }
  query?: never
  url: '/agents/{agent_id}'
}

export type PatchAgentsByAgentIdResponses = {
  200: AgentRosterResponse
}

export type PatchAgentsByAgentIdResponse
  = PatchAgentsByAgentIdResponses[keyof PatchAgentsByAgentIdResponses]

export type GetAgentsByAgentIdVersionsData = {
  body?: never
  path: {
    agent_id: string
  }
  query?: never
  url: '/agents/{agent_id}/versions'
}

export type GetAgentsByAgentIdVersionsResponses = {
  200: AgentConfigSnapshotListResponse
}

export type GetAgentsByAgentIdVersionsResponse
  = GetAgentsByAgentIdVersionsResponses[keyof GetAgentsByAgentIdVersionsResponses]

export type GetAgentsByAgentIdVersionsByVersionIdData = {
  body?: never
  path: {
    agent_id: string
    version_id: string
  }
  query?: never
  url: '/agents/{agent_id}/versions/{version_id}'
}

export type GetAgentsByAgentIdVersionsByVersionIdResponses = {
  200: AgentConfigSnapshotDetailResponse
}

export type GetAgentsByAgentIdVersionsByVersionIdResponse
  = GetAgentsByAgentIdVersionsByVersionIdResponses[keyof GetAgentsByAgentIdVersionsByVersionIdResponses]
