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

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

export type WorkflowGeneratePayload = {
  current_graph?: WorkflowGraph | null
  ideal_output?: string
  instruction: string
  mode: 'advanced-chat' | 'auto' | 'workflow'
  model_config: ModelConfig
}

export type WorkflowGenerateResponse = {
  app_name?: string
  error?: string
  errors?: Array<WorkflowGenerateErrorResponse>
  graph: WorkflowGraph
  icon?: string
  message?: string
  mode?: 'advanced-chat' | 'workflow' | null
}

export type WorkflowGenerateStreamEventResponse =
  | WorkflowGeneratePlanEventResponse
  | WorkflowGenerateResultEventResponse

export type WorkflowInstructionSuggestionsPayload = {
  count?: number
  language?: string | null
  mode: 'advanced-chat' | 'workflow'
}

export type WorkflowInstructionSuggestionsResponse = {
  suggestions: Array<string>
}

export type WorkflowGraph = {
  edges: Array<WorkflowGraphEdge>
  nodes: Array<WorkflowGraphNode>
  viewport: WorkflowGraphViewport
}

export type ModelConfig = {
  completion_params?: {
    [key: string]: unknown
  }
  mode: LlmMode
  name: string
  provider: string
}

export type WorkflowGenerateErrorResponse = {
  code: WorkflowGenerateErrorCode
  detail: string
  node_id?: string | null
}

export type WorkflowGeneratePlanEventResponse = {
  app_name?: string
  description?: string
  event?: 'plan'
  icon?: string
  mode: 'advanced-chat' | 'workflow'
  nodes: Array<WorkflowPlanNodeResponse>
  start_inputs?: Array<WorkflowPlanStartInputResponse>
  title?: string
}

export type WorkflowGenerateResultEventResponse = {
  app_name?: string
  error?: string
  errors?: Array<WorkflowGenerateErrorResponse>
  event?: 'result'
  graph: WorkflowGraph
  icon?: string
  message?: string
  mode?: 'advanced-chat' | 'workflow' | null
}

export type WorkflowGraphEdge = {
  id: string
  source: string
  target: string
  type: string
  [key: string]: unknown
}

export type WorkflowGraphNode = {
  data: {
    [key: string]: unknown
  }
  id: string
  position: WorkflowGraphPosition
  type: string
  [key: string]: unknown
}

export type WorkflowGraphViewport = {
  x: number
  y: number
  zoom: number
}

export type LlmMode = 'chat' | 'completion'

export type WorkflowGenerateErrorCode =
  | 'DANGLING_EDGE'
  | 'DUPLICATE_NODE_ID'
  | 'EMPTY_INSTRUCTION'
  | 'EMPTY_PLAN'
  | 'GRAPH_CYCLE'
  | 'INSTRUCTION_TOO_LONG'
  | 'INVALID_CONTAINER'
  | 'INVALID_JSON'
  | 'INVALID_SCHEMA'
  | 'MISSING_START'
  | 'MISSING_TERMINAL'
  | 'MODEL_ERROR'
  | 'UNKNOWN_NODE_REFERENCE'
  | 'UNKNOWN_TOOL'
  | 'UNRESOLVED_REFERENCE'

export type WorkflowPlanNodeResponse = {
  label: string
  node_type: string
  purpose?: string
}

export type WorkflowPlanStartInputResponse = {
  label?: string
  type?: string
  variable: string
}

export type WorkflowGraphPosition = {
  x: number
  y: number
}

export type PostWorkflowGenerateData = {
  body: WorkflowGeneratePayload
  path?: never
  query?: never
  url: '/workflow-generate'
}

export type PostWorkflowGenerateErrors = {
  400: unknown
  402: unknown
}

export type PostWorkflowGenerateResponses = {
  200: WorkflowGenerateResponse
}

export type PostWorkflowGenerateResponse =
  PostWorkflowGenerateResponses[keyof PostWorkflowGenerateResponses]

export type PostWorkflowGenerateStreamData = {
  body: WorkflowGeneratePayload
  path?: never
  query?: never
  url: '/workflow-generate/stream'
}

export type PostWorkflowGenerateStreamErrors = {
  400: unknown
}

export type PostWorkflowGenerateStreamResponses = {
  200: WorkflowGenerateStreamEventResponse
}

export type PostWorkflowGenerateStreamResponse =
  PostWorkflowGenerateStreamResponses[keyof PostWorkflowGenerateStreamResponses]

export type PostWorkflowGenerateSuggestionsData = {
  body: WorkflowInstructionSuggestionsPayload
  path?: never
  query?: never
  url: '/workflow-generate/suggestions'
}

export type PostWorkflowGenerateSuggestionsErrors = {
  400: unknown
}

export type PostWorkflowGenerateSuggestionsResponses = {
  200: WorkflowInstructionSuggestionsResponse
}

export type PostWorkflowGenerateSuggestionsResponse =
  PostWorkflowGenerateSuggestionsResponses[keyof PostWorkflowGenerateSuggestionsResponses]
