// 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 | null
  name: string
  role?: string
  version_note?: string | null
}

export type AgentRosterResponse = {
  active_config_snapshot?: AgentConfigSnapshotSummaryResponse | null
  active_config_snapshot_id?: string | null
  agent_kind: AgentKind
  app_id?: string | null
  archived_at?: number | null
  archived_by?: string | null
  created_at?: number | null
  created_by?: string | null
  description: string
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType | null
  id: string
  name: string
  published_node_reference_count?: number
  published_reference_count?: number
  published_references?: Array<AgentPublishedReferenceResponse>
  role?: string
  scope: AgentScope
  source: AgentSource
  status: AgentStatus
  updated_at?: number | 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 | null
  name?: string | null
  role?: string | null
}

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

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

export type AgentSoulConfig = {
  app_features?: AgentSoulAppFeaturesConfig
  app_variables?: Array<AppVariableConfig>
  env?: AgentSoulEnvConfig
  human?: AgentSoulHumanConfig
  knowledge?: AgentSoulKnowledgeConfig
  memory?: AgentSoulMemoryConfig
  misc_legacy?: AgentSoulAppFeaturesConfig
  model?: AgentSoulModelConfig | null
  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?: number | null
  created_by?: string | null
  id: string
  summary?: string | null
  version: number
  version_note?: string | null
}

export type AgentKind = 'dify_agent'

export type AgentPublishedReferenceResponse = {
  app_id: string
  app_mode: string
  app_name: string
  node_ids?: Array<string>
  workflow_id: string
  workflow_version: string
}

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 | null
  active_config_snapshot_id?: string | null
  agent_kind: AgentKind
  app_id?: string | null
  archived_at?: number | null
  archived_by?: string | null
  created_at?: number | null
  created_by?: string | null
  description: string
  existing_node_ids?: Array<string>
  icon?: string | null
  icon_background?: string | null
  icon_type?: AgentIconType | null
  id: string
  in_current_workflow_count?: number
  is_in_current_workflow?: boolean
  name: string
  published_node_reference_count?: number
  published_reference_count?: number
  published_references?: Array<AgentPublishedReferenceResponse>
  role?: string
  scope: AgentScope
  source: AgentSource
  status: AgentStatus
  updated_at?: number | null
  updated_by?: string | null
  workflow_id?: string | null
  workflow_node_id?: string | null
}

export type AgentConfigRevisionResponse = {
  created_at?: number | 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 AgentSoulAppFeaturesConfig = {
  opening_statement?: string | null
  retriever_resource?: AgentFeatureToggleConfig | null
  sensitive_word_avoidance?: AgentSensitiveWordAvoidanceFeatureConfig | null
  speech_to_text?: AgentFeatureToggleConfig | null
  suggested_questions?: Array<string> | null
  suggested_questions_after_answer?: AgentSuggestedQuestionsAfterAnswerFeatureConfig | null
  text_to_speech?: AgentTextToSpeechFeatureConfig | null
  [key: string]: unknown
}

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

export type AgentSoulEnvConfig = {
  secret_refs?: Array<AgentSecretRefConfig>
  variables?: Array<AgentEnvVariableConfig>
}

export type AgentSoulHumanConfig = {
  contacts?: Array<AgentHumanContactConfig>
  tools?: Array<AgentHumanToolConfig>
}

export type AgentSoulKnowledgeConfig = {
  datasets?: Array<AgentKnowledgeDatasetConfig>
  query_config?: AgentKnowledgeQueryConfig
  query_mode?: AgentKnowledgeQueryMode | null
}

export type AgentSoulMemoryConfig = {
  artifacts?: Array<AgentMemoryArtifactConfig>
  budget?: string | null
  scope?: string | null
}

export type AgentSoulModelConfig = {
  credential_ref?: AgentSoulModelCredentialRef | null
  model: string
  model_provider: string
  model_settings?: AgentSoulModelSettings
  plugin_id: string
}

export type AgentSoulPromptConfig = {
  system_prompt?: string
}

export type AgentSoulSandboxConfig = {
  config?: AgentSandboxProviderConfig
  provider?: string | null
}

export type AgentSoulSkillsFilesConfig = {
  files?: Array<AgentFileRefConfig>
  skills?: Array<AgentSkillRefConfig>
}

export type AgentSoulToolsConfig = {
  cli_tools?: Array<AgentCliToolConfig>
  dify_tools?: Array<AgentSoulDifyToolConfig>
}

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

export type AgentFeatureToggleConfig = {
  enabled?: boolean
  [key: string]: unknown
}

export type AgentSensitiveWordAvoidanceFeatureConfig = {
  config?: AgentModerationProviderConfig | null
  enabled?: boolean
  type?: string | null
  [key: string]: unknown
}

export type AgentSuggestedQuestionsAfterAnswerFeatureConfig = {
  enabled?: boolean
  model?: AgentSoulModelConfig | null
  prompt?: string | null
  [key: string]: unknown
}

export type AgentTextToSpeechFeatureConfig = {
  autoPlay?: string | null
  enabled?: boolean
  language?: string | null
  voice?: string | null
  [key: string]: unknown
}

export type AgentSecretRefConfig = {
  credential_id?: string | null
  env_name?: string | null
  id?: string | null
  key?: string | null
  name?: string | null
  permission?: AgentPermissionConfig | null
  permission_status?: string | null
  provider?: string | null
  provider_credential_id?: string | null
  ref?: string | null
  type?: string | null
  variable?: string | null
  [key: string]: unknown
}

export type AgentEnvVariableConfig = {
  default?:
    | string
    | number
    | number
    | boolean
    | Array<string>
    | Array<number>
    | Array<number>
    | Array<boolean>
    | null
  env_name?: string | null
  key?: string | null
  name?: string | null
  required?: boolean
  type?: string | null
  value?:
    | string
    | number
    | number
    | boolean
    | Array<string>
    | Array<number>
    | Array<number>
    | Array<boolean>
    | null
  variable?: string | null
  [key: string]: unknown
}

export type AgentHumanContactConfig = {
  channel?: string | null
  contact_id?: string | null
  contact_method?: string | null
  email?: string | null
  human_id?: string | null
  id?: string | null
  method?: string | null
  name?: string | null
  tenant_id?: string | null
  [key: string]: unknown
}

export type AgentHumanToolConfig = {
  description?: string | null
  enabled?: boolean
  name?: string | null
  [key: string]: unknown
}

export type AgentKnowledgeDatasetConfig = {
  description?: string | null
  id?: string | null
  name?: string | null
  [key: string]: unknown
}

export type AgentKnowledgeQueryConfig = {
  query?: string | null
  score_threshold?: number | null
  score_threshold_enabled?: boolean | null
  top_k?: number | null
  [key: string]: unknown
}

export type AgentKnowledgeQueryMode = 'generated_query' | 'user_query'

export type AgentMemoryArtifactConfig = {
  id?: string | null
  name?: string | null
  type?: string | null
  url?: string | null
  [key: string]: unknown
}

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

export type AgentSoulModelSettings = {
  frequency_penalty?: number | null
  max_tokens?: number | null
  presence_penalty?: number | null
  response_format?: AgentModelResponseFormatConfig | null
  stop?: Array<string> | null
  temperature?: number | null
  top_p?: number | null
}

export type AgentSandboxProviderConfig = {
  cpu?: number | null
  env?: Array<AgentEnvVariableConfig>
  image?: string | null
  working_dir?: string | null
  [key: string]: unknown
}

export type AgentFileRefConfig = {
  drive_key?: string | null
  file_id?: string | null
  id?: string | null
  name?: string | null
  reference?: string | null
  remote_url?: string | null
  tenant_id?: string | null
  transfer_method?: string | null
  type?: string | null
  upload_file_id?: string | null
  url?: string | null
  [key: string]: unknown
}

export type AgentSkillRefConfig = {
  description?: string | null
  file_id?: string | null
  full_archive_file_id?: string | null
  full_archive_key?: string | null
  id?: string | null
  manifest_files?: Array<string> | null
  name?: string | null
  path?: string | null
  skill_md_file_id?: string | null
  skill_md_key?: string | null
  [key: string]: unknown
}

export type AgentCliToolConfig = {
  approved?: boolean
  authorization_status?: AgentCliToolAuthorizationStatus | null
  command?: string | null
  dangerous?: boolean
  dangerous_accepted?: boolean
  dangerous_acknowledged?: boolean
  dangerous_command?: boolean
  description?: string | null
  enabled?: boolean
  env?: AgentCliToolEnvConfig
  id?: string | null
  inferred_from?: string | null
  install?: string | null
  install_command?: string | null
  install_commands?: Array<string>
  invoke_metadata?: {
    [key: string]: unknown
  }
  label?: string | null
  name?: string | null
  permission?: AgentPermissionConfig | null
  pre_authorized?: boolean | null
  requires_confirmation?: boolean
  risk_accepted?: boolean
  risk_level?: AgentCliToolRiskLevel | null
  setup_command?: string | null
  tool_name?: string | null
  [key: string]: unknown
}

export type AgentSoulDifyToolConfig = {
  credential_ref?: AgentSoulDifyToolCredentialRef | null
  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]:
      | string
      | number
      | number
      | boolean
      | Array<string>
      | Array<number>
      | Array<number>
      | Array<boolean>
      | null
  }
  tool_name?: string | null
}

export type AgentModerationProviderConfig = {
  api_based_extension_id?: string | null
  inputs_config?: AgentModerationIoConfig | null
  keywords?: string | null
  outputs_config?: AgentModerationIoConfig | null
  [key: string]: unknown
}

export type AgentPermissionConfig = {
  allowed?: boolean | null
  state?: string | null
  status?: string | null
}

export type AgentModelResponseFormatConfig = {
  type?: string | null
  [key: string]: unknown
}

export type AgentCliToolAuthorizationStatus
  = | 'allowed'
    | 'authorized'
    | 'denied'
    | 'forbidden'
    | 'not_required'
    | 'pending'
    | 'pre_authorized'
    | 'unauthorized'

export type AgentCliToolEnvConfig = {
  secret_refs?: Array<AgentSecretRefConfig>
  variables?: Array<AgentEnvVariableConfig>
}

export type AgentCliToolRiskLevel = 'dangerous' | 'safe' | 'unknown'

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

export type AgentModerationIoConfig = {
  enabled?: boolean
  preset_response?: string | null
  [key: string]: unknown
}

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: void
}

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]
