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

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

export type Event =
  | EventModelsDevRefreshed
  | EventIntegrationUpdated
  | EventIntegrationConnectionUpdated
  | EventCatalogUpdated
  | EventSessionCreated
  | EventSessionUpdated
  | EventSessionDeleted
  | EventMessageUpdated
  | EventMessageRemoved
  | EventMessagePartUpdated
  | EventMessagePartRemoved
  | EventSessionNextAgentSwitched
  | EventSessionNextModelSwitched
  | EventSessionNextMoved
  | EventSessionNextPrompted
  | EventSessionNextPromptAdmitted
  | EventSessionNextContextUpdated
  | EventSessionNextSynthetic
  | EventSessionNextShellStarted
  | EventSessionNextShellEnded
  | EventSessionNextStepStarted
  | EventSessionNextStepEnded
  | EventSessionNextStepFailed
  | EventSessionNextTextStarted
  | EventSessionNextTextDelta
  | EventSessionNextTextEnded
  | EventSessionNextReasoningStarted
  | EventSessionNextReasoningDelta
  | EventSessionNextReasoningEnded
  | EventSessionNextToolInputStarted
  | EventSessionNextToolInputDelta
  | EventSessionNextToolInputEnded
  | EventSessionNextToolCalled
  | EventSessionNextToolProgress
  | EventSessionNextToolSuccess
  | EventSessionNextToolFailed
  | EventSessionNextRetried
  | EventSessionNextCompactionStarted
  | EventSessionNextCompactionDelta
  | EventSessionNextCompactionEnded
  | EventSessionNextRevertStaged
  | EventSessionNextRevertCleared
  | EventSessionNextRevertCommitted
  | EventMessagePartDelta
  | EventSessionDiff
  | EventSessionError
  | EventInstallationUpdated
  | EventInstallationUpdateAvailable
  | EventFileEdited
  | EventReferenceUpdated
  | EventPermissionV2Asked
  | EventPermissionV2Replied
  | EventPluginAdded
  | EventProjectDirectoriesUpdated
  | EventFileWatcherUpdated
  | EventPtyCreated
  | EventPtyUpdated
  | EventPtyExited
  | EventPtyDeleted
  | EventQuestionV2Asked
  | EventQuestionV2Replied
  | EventQuestionV2Rejected
  | EventTodoUpdated
  | EventLspUpdated
  | EventPermissionAsked
  | EventPermissionReplied
  | EventTuiPromptAppend2
  | EventTuiCommandExecute2
  | EventTuiToastShow2
  | EventTuiSessionSelect2
  | EventMcpToolsChanged
  | EventMcpBrowserOpenFailed
  | EventCommandExecuted
  | EventProjectUpdated
  | EventSessionStatus
  | EventSessionIdle
  | EventQuestionAsked
  | EventQuestionReplied
  | EventQuestionRejected
  | EventSessionCompacted
  | EventVcsBranchUpdated
  | EventWorkspaceReady
  | EventWorkspaceFailed
  | EventWorkspaceStatus
  | EventWorktreeReady
  | EventWorktreeFailed
  | EventServerConnected
  | EventGlobalDisposed
  | EventServerInstanceDisposed

export type QuestionReplied = {
  sessionID: string
  requestID: string
  answers: Array<QuestionAnswer>
}

export type QuestionRejected = {
  sessionID: string
  requestID: string
}

export type OAuth = {
  type: "oauth"
  refresh: string
  access: string
  expires: number
  accountId?: string
  enterpriseUrl?: string
}

export type ApiAuth = {
  type: "api"
  key: string
  metadata?: {
    [key: string]: string
  }
}

export type WellKnownAuth = {
  type: "wellknown"
  key: string
  token: string
}

export type Auth = OAuth | ApiAuth | WellKnownAuth

export type EffectHttpApiErrorBadRequest = {
  _tag: "BadRequest"
}

export type InvalidRequestError = {
  _tag: "InvalidRequestError"
  message: string
  kind?: string
  field?: string
}

export type MoveSessionError = {
  name: "MoveSessionError"
  data: {
    message: string
  }
}

export type SnapshotFileDiff = {
  file?: string
  patch?: string
  additions: number
  deletions: number
  status?: "added" | "deleted" | "modified"
}

export type PermissionAction = "allow" | "deny" | "ask"

export type PermissionRule = {
  permission: string
  pattern: string
  action: PermissionAction
}

export type PermissionRuleset = Array<PermissionRule>

export type Session = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<SnapshotFileDiff>
  }
  cost?: number
  tokens?: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  share?: {
    url: string
  }
  title: string
  agent?: string
  model?: {
    id: string
    providerID: string
    variant?: string
  }
  version: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    updated: number
    compacting?: number
    archived?: number
  }
  permission?: PermissionRuleset
  revert?: {
    messageID: string
    partID?: string
    snapshot?: string
    diff?: string
  }
}

export type OutputFormatText = {
  type: "text"
}

export type JsonSchema = {
  [key: string]: unknown
}

export type OutputFormatJsonSchema = {
  type: "json_schema"
  schema: JsonSchema
  retryCount?: number
}

export type OutputFormat = OutputFormatText | OutputFormatJsonSchema

export type UserMessage = {
  id: string
  sessionID: string
  role: "user"
  time: {
    created: number
  }
  format?: OutputFormat
  summary?: {
    title?: string
    body?: string
    diffs: Array<SnapshotFileDiff>
  }
  agent: string
  model: {
    providerID: string
    modelID: string
    variant?: string
  }
  system?: string
  tools?: {
    [key: string]: boolean
  }
}

export type ProviderAuthError = {
  name: "ProviderAuthError"
  data: {
    providerID: string
    message: string
  }
}

export type UnknownError = {
  name: "UnknownError"
  data: {
    message: string
    ref?: string
  }
}

export type MessageOutputLengthError = {
  name: "MessageOutputLengthError"
  data: {
    [key: string]: unknown
  }
}

export type MessageAbortedError = {
  name: "MessageAbortedError"
  data: {
    message: string
  }
}

export type StructuredOutputError = {
  name: "StructuredOutputError"
  data: {
    message: string
    retries: number
  }
}

export type ContextOverflowError = {
  name: "ContextOverflowError"
  data: {
    message: string
    responseBody?: string
  }
}

export type ContentFilterError = {
  name: "ContentFilterError"
  data: {
    message: string
  }
}

export type ApiError = {
  name: "APIError"
  data: {
    message: string
    statusCode?: number
    isRetryable: boolean
    responseHeaders?: {
      [key: string]: string
    }
    responseBody?: string
    metadata?: {
      [key: string]: string
    }
  }
}

export type AssistantMessage = {
  id: string
  sessionID: string
  role: "assistant"
  time: {
    created: number
    completed?: number
  }
  error?:
    | ProviderAuthError
    | UnknownError
    | MessageOutputLengthError
    | MessageAbortedError
    | StructuredOutputError
    | ContextOverflowError
    | ContentFilterError
    | ApiError
  parentID: string
  modelID: string
  providerID: string
  mode: string
  agent: string
  path: {
    cwd: string
    root: string
  }
  summary?: boolean
  cost: number
  tokens: {
    total?: number
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  structured?: unknown
  variant?: string
  finish?: string
}

export type Message = UserMessage | AssistantMessage

export type TextPart = {
  id: string
  sessionID: string
  messageID: string
  type: "text"
  text: string
  synthetic?: boolean
  ignored?: boolean
  time?: {
    start: number
    end?: number
  }
  metadata?: {
    [key: string]: unknown
  }
}

export type SubtaskPart = {
  id: string
  sessionID: string
  messageID: string
  type: "subtask"
  prompt: string
  description: string
  agent: string
  model?: {
    providerID: string
    modelID: string
  }
  command?: string
}

export type ReasoningPart = {
  id: string
  sessionID: string
  messageID: string
  type: "reasoning"
  text: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    start: number
    end?: number
  }
}

export type FilePartSourceText = {
  value: string
  start: number
  end: number
}

export type FileSource = {
  text: FilePartSourceText
  type: "file"
  path: string
}

export type Range = {
  start: {
    line: number
    character: number
  }
  end: {
    line: number
    character: number
  }
}

export type SymbolSource = {
  text: FilePartSourceText
  type: "symbol"
  path: string
  range: Range
  name: string
  kind: number
}

export type ResourceSource = {
  text: FilePartSourceText
  type: "resource"
  clientName: string
  uri: string
}

export type FilePartSource = FileSource | SymbolSource | ResourceSource

export type FilePart = {
  id: string
  sessionID: string
  messageID: string
  type: "file"
  mime: string
  filename?: string
  url: string
  source?: FilePartSource
}

export type ToolStatePending = {
  status: "pending"
  input: {
    [key: string]: unknown
  }
  raw: string
}

export type ToolStateRunning = {
  status: "running"
  input: {
    [key: string]: unknown
  }
  title?: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    start: number
  }
}

export type ToolStateCompleted = {
  status: "completed"
  input: {
    [key: string]: unknown
  }
  output: string
  title: string
  metadata: {
    [key: string]: unknown
  }
  time: {
    start: number
    end: number
    compacted?: number
  }
  attachments?: Array<FilePart>
}

export type ToolStateError = {
  status: "error"
  input: {
    [key: string]: unknown
  }
  error: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    start: number
    end: number
  }
}

export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError

export type ToolPart = {
  id: string
  sessionID: string
  messageID: string
  type: "tool"
  callID: string
  tool: string
  state: ToolState
  metadata?: {
    [key: string]: unknown
  }
}

export type StepStartPart = {
  id: string
  sessionID: string
  messageID: string
  type: "step-start"
  snapshot?: string
}

export type StepFinishPart = {
  id: string
  sessionID: string
  messageID: string
  type: "step-finish"
  reason: string
  snapshot?: string
  cost: number
  tokens: {
    total?: number
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
}

export type SnapshotPart = {
  id: string
  sessionID: string
  messageID: string
  type: "snapshot"
  snapshot: string
}

export type PatchPart = {
  id: string
  sessionID: string
  messageID: string
  type: "patch"
  hash: string
  files: Array<string>
}

export type AgentPart = {
  id: string
  sessionID: string
  messageID: string
  type: "agent"
  name: string
  source?: {
    value: string
    start: number
    end: number
  }
}

export type RetryPart = {
  id: string
  sessionID: string
  messageID: string
  type: "retry"
  attempt: number
  error: ApiError
  time: {
    created: number
  }
}

export type CompactionPart = {
  id: string
  sessionID: string
  messageID: string
  type: "compaction"
  auto: boolean
  overflow?: boolean
  tail_start_id?: string
}

export type Part =
  | TextPart
  | SubtaskPart
  | ReasoningPart
  | FilePart
  | ToolPart
  | StepStartPart
  | StepFinishPart
  | SnapshotPart
  | PatchPart
  | AgentPart
  | RetryPart
  | CompactionPart

export type Prompt = {
  text: string
  files?: Array<PromptFileAttachment>
  agents?: Array<PromptAgentAttachment>
}

export type Pty = {
  id: string
  title: string
  command: string
  args: Array<string>
  cwd: string
  status: "running" | "exited"
  pid: number
  exitCode?: number
}

export type Todo = {
  /**
   * Brief description of the task
   */
  content: string
  /**
   * Current status of the task: pending, in_progress, completed, cancelled
   */
  status: string
  /**
   * Priority level of the task: high, medium, low
   */
  priority: string
}

export type SessionStatus =
  | {
      type: "idle"
    }
  | {
      type: "retry"
      attempt: number
      message: string
      action?: {
        reason: string
        provider: string
        title: string
        message: string
        label: string
        link?: string
      }
      next: number
    }
  | {
      type: "busy"
    }

export type QuestionOption = {
  /**
   * Display text (1-5 words, concise)
   */
  label: string
  /**
   * Explanation of choice
   */
  description: string
}

export type QuestionInfo = {
  /**
   * Complete question
   */
  question: string
  /**
   * Very short label (max 30 chars)
   */
  header: string
  /**
   * Available choices
   */
  options: Array<QuestionOption>
  multiple?: boolean
  custom?: boolean
}

export type QuestionTool = {
  messageID: string
  callID: string
}

export type QuestionAnswer = Array<string>

export type GlobalEvent = {
  directory: string
  project?: string
  workspace?: string
  payload:
    | {
        id: string
        type: "models-dev.refreshed"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.connection.updated"
        properties: {
          integrationID: string
        }
      }
    | {
        id: string
        type: "catalog.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "session.created"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "session.updated"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "session.deleted"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "message.updated"
        properties: {
          sessionID: string
          info: Message
        }
      }
    | {
        id: string
        type: "message.removed"
        properties: {
          sessionID: string
          messageID: string
        }
      }
    | {
        id: string
        type: "message.part.updated"
        properties: {
          sessionID: string
          part: Part
          time: number
        }
      }
    | {
        id: string
        type: "message.part.removed"
        properties: {
          sessionID: string
          messageID: string
          partID: string
        }
      }
    | {
        id: string
        type: "session.next.agent.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          agent: string
        }
      }
    | {
        id: string
        type: "session.next.model.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          model: ModelRef
        }
      }
    | {
        id: string
        type: "session.next.moved"
        properties: {
          timestamp: number
          sessionID: string
          location: LocationRef
          subdirectory?: string
        }
      }
    | {
        id: string
        type: "session.next.prompted"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          prompt: Prompt
          delivery: "steer" | "queue"
        }
      }
    | {
        id: string
        type: "session.next.prompt.admitted"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          prompt: Prompt
          delivery: "steer" | "queue"
        }
      }
    | {
        id: string
        type: "session.next.context.updated"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.synthetic"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.shell.started"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          callID: string
          command: string
        }
      }
    | {
        id: string
        type: "session.next.shell.ended"
        properties: {
          timestamp: number
          sessionID: string
          callID: string
          output: string
        }
      }
    | {
        id: string
        type: "session.next.step.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          agent: string
          model: ModelRef
          snapshot?: string
        }
      }
    | {
        id: string
        type: "session.next.step.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          finish: string
          cost: number
          tokens: {
            input: number
            output: number
            reasoning: number
            cache: {
              read: number
              write: number
            }
          }
          snapshot?: string
          files?: Array<string>
        }
      }
    | {
        id: string
        type: "session.next.step.failed"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          error: SessionErrorUnknown
        }
      }
    | {
        id: string
        type: "session.next.text.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
        }
      }
    | {
        id: string
        type: "session.next.text.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.text.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.reasoning.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        id: string
        type: "session.next.reasoning.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.reasoning.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          text: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        id: string
        type: "session.next.tool.input.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          name: string
        }
      }
    | {
        id: string
        type: "session.next.tool.input.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.tool.input.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.tool.called"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          tool: string
          input: {
            [key: string]: unknown
          }
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.tool.progress"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
        }
      }
    | {
        id: string
        type: "session.next.tool.success"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
          outputPaths?: Array<string>
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.tool.failed"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          error: SessionErrorUnknown
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.retried"
        properties: {
          timestamp: number
          sessionID: string
          attempt: number
          error: SessionNextRetryError
        }
      }
    | {
        id: string
        type: "session.next.compaction.started"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          reason: "auto" | "manual"
        }
      }
    | {
        id: string
        type: "session.next.compaction.delta"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.compaction.ended"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          reason: "auto" | "manual"
          text: string
          recent: string
        }
      }
    | {
        id: string
        type: "session.next.revert.staged"
        properties: {
          timestamp: number
          sessionID: string
          revert: RevertState
        }
      }
    | {
        id: string
        type: "session.next.revert.cleared"
        properties: {
          timestamp: number
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.next.revert.committed"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
        }
      }
    | {
        id: string
        type: "message.part.delta"
        properties: {
          sessionID: string
          messageID: string
          partID: string
          field: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.diff"
        properties: {
          sessionID: string
          diff: Array<SnapshotFileDiff>
        }
      }
    | {
        id: string
        type: "session.error"
        properties: {
          sessionID?: string
          error?:
            | ProviderAuthError
            | UnknownError
            | MessageOutputLengthError
            | MessageAbortedError
            | StructuredOutputError
            | ContextOverflowError
            | ContentFilterError
            | ApiError
        }
      }
    | {
        id: string
        type: "installation.updated"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "installation.update-available"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "file.edited"
        properties: {
          file: string
        }
      }
    | {
        id: string
        type: "reference.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "permission.v2.asked"
        properties: {
          id: string
          sessionID: string
          action: string
          resources: Array<string>
          save?: Array<string>
          metadata?: {
            [key: string]: unknown
          }
          source?: PermissionV2Source
        }
      }
    | {
        id: string
        type: "permission.v2.replied"
        properties: {
          sessionID: string
          requestID: string
          reply: PermissionV2Reply
        }
      }
    | {
        id: string
        type: "plugin.added"
        properties: {
          id: string
        }
      }
    | {
        id: string
        type: "project.directories.updated"
        properties: {
          projectID: string
        }
      }
    | {
        id: string
        type: "file.watcher.updated"
        properties: {
          file: string
          event: "add" | "change" | "unlink"
        }
      }
    | {
        id: string
        type: "pty.created"
        properties: {
          info: Pty
        }
      }
    | {
        id: string
        type: "pty.updated"
        properties: {
          info: Pty
        }
      }
    | {
        id: string
        type: "pty.exited"
        properties: {
          id: string
          exitCode: number
        }
      }
    | {
        id: string
        type: "pty.deleted"
        properties: {
          id: string
        }
      }
    | {
        id: string
        type: "question.v2.asked"
        properties: {
          id: string
          sessionID: string
          /**
           * Questions to ask
           */
          questions: Array<QuestionV2Info>
          tool?: QuestionV2Tool
        }
      }
    | {
        id: string
        type: "question.v2.replied"
        properties: {
          sessionID: string
          requestID: string
          answers: Array<QuestionV2Answer>
        }
      }
    | {
        id: string
        type: "question.v2.rejected"
        properties: {
          sessionID: string
          requestID: string
        }
      }
    | {
        id: string
        type: "todo.updated"
        properties: {
          sessionID: string
          todos: Array<Todo>
        }
      }
    | {
        id: string
        type: "lsp.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "permission.asked"
        properties: {
          id: string
          sessionID: string
          permission: string
          patterns: Array<string>
          metadata: {
            [key: string]: unknown
          }
          always: Array<string>
          tool?: {
            messageID: string
            callID: string
          }
        }
      }
    | {
        id: string
        type: "permission.replied"
        properties: {
          sessionID: string
          requestID: string
          reply: "once" | "always" | "reject"
        }
      }
    | {
        id: string
        type: "tui.prompt.append"
        properties: {
          text: string
        }
      }
    | {
        id: string
        type: "tui.command.execute"
        properties: {
          command:
            | "session.list"
            | "session.new"
            | "session.share"
            | "session.interrupt"
            | "session.compact"
            | "session.page.up"
            | "session.page.down"
            | "session.line.up"
            | "session.line.down"
            | "session.half.page.up"
            | "session.half.page.down"
            | "session.first"
            | "session.last"
            | "prompt.clear"
            | "prompt.submit"
            | "agent.cycle"
            | string
        }
      }
    | {
        id: string
        type: "tui.toast.show"
        properties: {
          title?: string
          message: string
          variant: "info" | "success" | "warning" | "error"
          duration?: number
        }
      }
    | {
        id: string
        type: "tui.session.select"
        properties: {
          /**
           * Session ID to navigate to
           */
          sessionID: string
        }
      }
    | {
        id: string
        type: "mcp.tools.changed"
        properties: {
          server: string
        }
      }
    | {
        id: string
        type: "mcp.browser.open.failed"
        properties: {
          mcpName: string
          url: string
        }
      }
    | {
        id: string
        type: "command.executed"
        properties: {
          name: string
          sessionID: string
          arguments: string
          messageID: string
        }
      }
    | {
        id: string
        type: "project.updated"
        properties: {
          id: string
          worktree: string
          vcs?: ProjectVcs
          name?: string
          icon?: ProjectIcon
          commands?: ProjectCommands
          time: ProjectTime
          sandboxes: Array<string>
        }
      }
    | {
        id: string
        type: "session.status"
        properties: {
          sessionID: string
          status: SessionStatus
        }
      }
    | {
        id: string
        type: "session.idle"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "question.asked"
        properties: {
          id: string
          sessionID: string
          /**
           * Questions to ask
           */
          questions: Array<QuestionInfo>
          tool?: QuestionTool
        }
      }
    | {
        id: string
        type: "question.replied"
        properties: {
          sessionID: string
          requestID: string
          answers: Array<QuestionAnswer>
        }
      }
    | {
        id: string
        type: "question.rejected"
        properties: {
          sessionID: string
          requestID: string
        }
      }
    | {
        id: string
        type: "session.compacted"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "vcs.branch.updated"
        properties: {
          branch?: string
        }
      }
    | {
        id: string
        type: "workspace.ready"
        properties: {
          name: string
        }
      }
    | {
        id: string
        type: "workspace.failed"
        properties: {
          message: string
        }
      }
    | {
        id: string
        type: "workspace.status"
        properties: {
          workspaceID: string
          status: "connected" | "connecting" | "disconnected" | "error"
        }
      }
    | {
        id: string
        type: "worktree.ready"
        properties: {
          name: string
          branch?: string
        }
      }
    | {
        id: string
        type: "worktree.failed"
        properties: {
          message: string
        }
      }
    | {
        id: string
        type: "server.connected"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "global.disposed"
        properties: {
          [key: string]: unknown
        }
      }
    | EventServerInstanceDisposed
    | SyncEventSessionCreated
    | SyncEventSessionUpdated
    | SyncEventSessionDeleted
    | SyncEventMessageUpdated
    | SyncEventMessageRemoved
    | SyncEventMessagePartUpdated
    | SyncEventMessagePartRemoved
    | SyncEventSessionNextAgentSwitched
    | SyncEventSessionNextModelSwitched
    | SyncEventSessionNextMoved
    | SyncEventSessionNextPrompted
    | SyncEventSessionNextPromptAdmitted
    | SyncEventSessionNextContextUpdated
    | SyncEventSessionNextSynthetic
    | SyncEventSessionNextShellStarted
    | SyncEventSessionNextShellEnded
    | SyncEventSessionNextStepStarted
    | SyncEventSessionNextStepEnded
    | SyncEventSessionNextStepFailed
    | SyncEventSessionNextTextStarted
    | SyncEventSessionNextTextEnded
    | SyncEventSessionNextReasoningStarted
    | SyncEventSessionNextReasoningEnded
    | SyncEventSessionNextToolInputStarted
    | SyncEventSessionNextToolInputEnded
    | SyncEventSessionNextToolCalled
    | SyncEventSessionNextToolProgress
    | SyncEventSessionNextToolSuccess
    | SyncEventSessionNextToolFailed
    | SyncEventSessionNextRetried
    | SyncEventSessionNextCompactionStarted
    | SyncEventSessionNextCompactionEnded
    | SyncEventSessionNextRevertStaged
    | SyncEventSessionNextRevertCleared
    | SyncEventSessionNextRevertCommitted
}

/**
 * Log level
 */
export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR"

/**
 * Server configuration for opencode serve and web commands
 */
export type ServerConfig = {
  port?: number
  hostname?: string
  mdns?: boolean
  mdnsDomain?: string
  cors?: Array<string>
}

export type PermissionActionConfig = "ask" | "allow" | "deny"

export type PermissionObjectConfig = {
  [key: string]: PermissionActionConfig
}

export type PermissionRuleConfig = PermissionActionConfig | PermissionObjectConfig

export type PermissionConfig =
  | PermissionActionConfig
  | {
      read?: PermissionRuleConfig
      edit?: PermissionRuleConfig
      glob?: PermissionRuleConfig
      grep?: PermissionRuleConfig
      list?: PermissionRuleConfig
      bash?: PermissionRuleConfig
      task?: PermissionRuleConfig
      external_directory?: PermissionRuleConfig
      todowrite?: PermissionActionConfig
      question?: PermissionActionConfig
      webfetch?: PermissionActionConfig
      websearch?: PermissionActionConfig
      lsp?: PermissionRuleConfig
      doom_loop?: PermissionActionConfig
      skill?: PermissionRuleConfig
      [key: string]: PermissionRuleConfig | PermissionActionConfig | undefined
    }

export type AgentConfig = {
  model?: string
  variant?: string
  temperature?: number
  top_p?: number
  prompt?: string
  tools?: {
    [key: string]: boolean
  }
  disable?: boolean
  description?: string
  mode?: "subagent" | "primary" | "all"
  hidden?: boolean
  options?: {
    [key: string]: unknown
  }
  /**
   * Hex color code (e.g., #FF5733) or theme color (e.g., primary)
   */
  color?: string | "primary" | "secondary" | "accent" | "success" | "warning" | "error" | "info"
  steps?: number
  maxSteps?: number
  permission?: PermissionConfig
  [key: string]:
    | unknown
    | string
    | number
    | {
        [key: string]: boolean
      }
    | boolean
    | "subagent"
    | "primary"
    | "all"
    | {
        [key: string]: unknown
      }
    | string
    | "primary"
    | "secondary"
    | "accent"
    | "success"
    | "warning"
    | "error"
    | "info"
    | number
    | PermissionConfig
    | undefined
}

export type ProviderConfig = {
  api?: string
  name?: string
  env?: Array<string>
  id?: string
  npm?: string
  whitelist?: Array<string>
  blacklist?: Array<string>
  options?: {
    apiKey?: string
    baseURL?: string
    enterpriseUrl?: string
    setCacheKey?: boolean
    /**
     * Timeout in milliseconds for full requests to this provider. Set to false to disable timeout.
     */
    timeout?: number | false
    /**
     * Timeout in milliseconds to wait for response headers. Provider integrations may set defaults. Set to false to disable timeout.
     */
    headerTimeout?: number | false
    chunkTimeout?: number
    [key: string]: unknown | string | boolean | number | false | number | false | number | undefined
  }
  models?: {
    [key: string]: {
      id?: string
      name?: string
      family?: string
      release_date?: string
      attachment?: boolean
      reasoning?: boolean
      temperature?: boolean
      tool_call?: boolean
      interleaved?:
        | true
        | {
            field: "reasoning" | "reasoning_content" | "reasoning_details"
          }
      cost?: {
        input: number
        output: number
        cache_read?: number
        cache_write?: number
        context_over_200k?: {
          input: number
          output: number
          cache_read?: number
          cache_write?: number
        }
      }
      limit?: {
        context: number
        input?: number
        output: number
      }
      modalities?: {
        input?: Array<"text" | "audio" | "image" | "video" | "pdf">
        output?: Array<"text" | "audio" | "image" | "video" | "pdf">
      }
      experimental?: boolean
      status?: "alpha" | "beta" | "deprecated" | "active"
      provider?: {
        npm?: string
        api?: string
      }
      options?: {
        [key: string]: unknown
      }
      headers?: {
        [key: string]: string
      }
      /**
       * Variant-specific configuration
       */
      variants?: {
        [key: string]: {
          disabled?: boolean
          [key: string]: unknown | boolean | undefined
        }
      }
    }
  }
}

export type McpLocalConfig = {
  /**
   * Type of MCP server connection
   */
  type: "local"
  /**
   * Command and arguments to run the MCP server
   */
  command: Array<string>
  cwd?: string
  environment?: {
    [key: string]: string
  }
  enabled?: boolean
  timeout?: number
}

export type McpOAuthConfig = {
  clientId?: string
  clientSecret?: string
  scope?: string
  callbackPort?: number
  redirectUri?: string
}

export type McpRemoteConfig = {
  /**
   * Type of MCP server connection
   */
  type: "remote"
  /**
   * URL of the remote MCP server
   */
  url: string
  enabled?: boolean
  headers?: {
    [key: string]: string
  }
  /**
   * OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection.
   */
  oauth?: McpOAuthConfig | false
  timeout?: number
}

/**
 * @deprecated Always uses stretch layout.
 */
export type LayoutConfig = "auto" | "stretch"

export type ImageAttachmentConfig = {
  auto_resize?: boolean
  max_width?: number
  max_height?: number
  max_base64_bytes?: number
}

export type AttachmentConfig = {
  image?: ImageAttachmentConfig
}

export type Config = {
  $schema?: string
  shell?: string
  logLevel?: LogLevel
  server?: ServerConfig
  command?: {
    [key: string]: {
      template: string
      description?: string
      agent?: string
      model?: string
      variant?: string
      subtask?: boolean
    }
  }
  skills?: {
    paths?: Array<string>
    urls?: Array<string>
  }
  references?: {
    [key: string]: string | ConfigV2ReferenceGit | ConfigV2ReferenceLocal
  }
  reference?: {
    [key: string]: string | ConfigV2ReferenceGit | ConfigV2ReferenceLocal
  }
  watcher?: {
    ignore?: Array<string>
  }
  snapshot?: boolean
  plugin?: Array<
    | string
    | [
        string,
        {
          [key: string]: unknown
        },
      ]
  >
  share?: "manual" | "auto" | "disabled"
  autoshare?: boolean
  /**
   * Automatically update to the latest version. Set to true to auto-update, false to disable, or 'notify' to show update notifications
   */
  autoupdate?: boolean | "notify"
  disabled_providers?: Array<string>
  enabled_providers?: Array<string>
  model?: string
  small_model?: string
  default_agent?: string
  username?: string
  mode?: {
    build?: AgentConfig
    plan?: AgentConfig
    [key: string]: AgentConfig | undefined
  }
  agent?: {
    plan?: AgentConfig
    build?: AgentConfig
    general?: AgentConfig
    explore?: AgentConfig
    title?: AgentConfig
    summary?: AgentConfig
    compaction?: AgentConfig
    [key: string]: AgentConfig | undefined
  }
  provider?: {
    [key: string]: ProviderConfig
  }
  mcp?: {
    [key: string]:
      | McpLocalConfig
      | McpRemoteConfig
      | {
          enabled: boolean
        }
  }
  /**
   * Enable or configure formatters. Omit or set to false to disable, true to enable built-ins, or an object to enable built-ins with overrides.
   */
  formatter?:
    | boolean
    | {
        [key: string]: {
          disabled?: boolean
          command?: Array<string>
          environment?: {
            [key: string]: string
          }
          extensions?: Array<string>
        }
      }
  /**
   * Enable or configure LSP servers. Omit or set to false to disable, true to enable built-ins, or an object to enable built-ins with overrides.
   */
  lsp?:
    | boolean
    | {
        [key: string]:
          | {
              disabled: true
            }
          | {
              command: Array<string>
              extensions?: Array<string>
              disabled?: boolean
              env?: {
                [key: string]: string
              }
              initialization?: {
                [key: string]: unknown
              }
            }
      }
  instructions?: Array<string>
  layout?: LayoutConfig
  permission?: PermissionConfig
  tools?: {
    [key: string]: boolean
  }
  attachment?: AttachmentConfig
  enterprise?: {
    url?: string
  }
  tool_output?: {
    max_lines?: number
    max_bytes?: number
  }
  compaction?: {
    auto?: boolean
    prune?: boolean
    tail_turns?: number
    preserve_recent_tokens?: number
    reserved?: number
  }
  experimental?: {
    disable_paste_summary?: boolean
    batch_tool?: boolean
    openTelemetry?: boolean
    primary_tools?: Array<string>
    continue_loop_on_deny?: boolean
    mcp_timeout?: number
    policies?: Array<ConfigV2ExperimentalPolicy>
  }
}

export type Model = {
  id: string
  providerID: string
  api: {
    id: string
    url: string
    npm: string
  }
  name: string
  family?: string
  capabilities: {
    temperature: boolean
    reasoning: boolean
    attachment: boolean
    toolcall: boolean
    input: {
      text: boolean
      audio: boolean
      image: boolean
      video: boolean
      pdf: boolean
    }
    output: {
      text: boolean
      audio: boolean
      image: boolean
      video: boolean
      pdf: boolean
    }
    interleaved:
      | boolean
      | {
          field: "reasoning" | "reasoning_content" | "reasoning_details"
        }
  }
  cost: {
    input: number
    output: number
    cache: {
      read: number
      write: number
    }
    tiers?: Array<{
      input: number
      output: number
      cache: {
        read: number
        write: number
      }
      tier: {
        type: "context"
        size: number
      }
    }>
    experimentalOver200K?: {
      input: number
      output: number
      cache: {
        read: number
        write: number
      }
    }
  }
  limit: {
    context: number
    input?: number
    output: number
  }
  status: "alpha" | "beta" | "deprecated" | "active"
  options: {
    [key: string]: unknown
  }
  headers: {
    [key: string]: string
  }
  release_date: string
  variants?: {
    [key: string]: {
      [key: string]: unknown
    }
  }
}

export type Provider = {
  id: string
  name: string
  source: "env" | "config" | "custom" | "api"
  env: Array<string>
  key?: string
  options: {
    [key: string]: unknown
  }
  models: {
    [key: string]: Model
  }
}

export type ExperimentalCapabilities = {
  backgroundSubagents: boolean
}

export type ConsoleState = {
  consoleManagedProviders: Array<string>
  activeOrgName?: string
  switchableOrgCount: number
}

export type EffectHttpApiErrorInternalServerError = {
  _tag: "InternalServerError"
}

export type ToolListItem = {
  id: string
  description: string
  parameters: unknown
}

export type ToolList = Array<ToolListItem>

export type ToolIds = Array<string>

export type WorktreeError = {
  name:
    | "WorktreeNotGitError"
    | "WorktreeNameGenerationFailedError"
    | "WorktreeCreateFailedError"
    | "WorktreeStartCommandFailedError"
    | "WorktreeRemoveFailedError"
    | "WorktreeResetFailedError"
    | "WorktreeListFailedError"
  data: {
    message: string
  }
}

export type WorktreeCreateInput = {
  name?: string
  /**
   * Additional startup script to run after the project's start command
   */
  startCommand?: string
}

export type Worktree = {
  name: string
  branch?: string
  directory: string
}

export type WorktreeRemoveInput = {
  directory: string
}

export type WorktreeResetInput = {
  directory: string
}

export type ProjectSummary = {
  id: string
  name?: string
  worktree: string
}

export type GlobalSession = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<SnapshotFileDiff>
  }
  cost?: number
  tokens?: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  share?: {
    url: string
  }
  title: string
  agent?: string
  model?: {
    id: string
    providerID: string
    variant?: string
  }
  version: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    updated: number
    compacting?: number
    archived?: number
  }
  permission?: PermissionRuleset
  revert?: {
    messageID: string
    partID?: string
    snapshot?: string
    diff?: string
  }
  project: ProjectSummary | null
}

export type McpResource = {
  name: string
  uri: string
  description?: string
  mimeType?: string
  client: string
}

export type Symbol = {
  name: string
  kind: number
  location: {
    uri: string
    range: Range
  }
}

export type FileNode = {
  name: string
  path: string
  absolute: string
  type: "file" | "directory"
  ignored: boolean
}

export type FileContent = {
  type: "text" | "binary"
  content: string
  diff?: string
  patch?: {
    oldFileName: string
    newFileName: string
    oldHeader?: string
    newHeader?: string
    hunks: Array<{
      oldStart: number
      oldLines: number
      newStart: number
      newLines: number
      lines: Array<string>
    }>
    index?: string
  }
  encoding?: "base64"
  mimeType?: string
}

export type File = {
  path: string
  added: number
  removed: number
  status: "added" | "deleted" | "modified"
}

export type Path = {
  home: string
  state: string
  config: string
  worktree: string
  directory: string
}

export type VcsInfo = {
  branch?: string
  default_branch?: string
}

export type VcsFileStatus = {
  file: string
  additions: number
  deletions: number
  status: "added" | "deleted" | "modified"
}

export type VcsFileDiff = {
  file: string
  patch?: string
  additions: number
  deletions: number
  status?: "added" | "deleted" | "modified"
}

export type VcsApplyError = {
  name: "VcsApplyError"
  data: {
    message: string
    reason: "non-git" | "not-clean"
  }
}

export type Command = {
  name: string
  description?: string
  agent?: string
  model?: string
  source?: "command" | "mcp" | "skill"
  template: string
  subtask?: boolean
  hints: Array<string>
}

export type Agent = {
  name: string
  description?: string
  mode: "subagent" | "primary" | "all"
  native?: boolean
  hidden?: boolean
  topP?: number
  temperature?: number
  color?: string
  permission: PermissionRuleset
  model?: {
    modelID: string
    providerID: string
  }
  variant?: string
  prompt?: string
  options: {
    [key: string]: unknown
  }
  steps?: number
}

export type LspStatus = {
  id: string
  name: string
  root: string
  status: "connected" | "error"
}

export type FormatterStatus = {
  name: string
  extensions: Array<string>
  enabled: boolean
}

export type McpStatusConnected = {
  status: "connected"
}

export type McpStatusDisabled = {
  status: "disabled"
}

export type McpStatusFailed = {
  status: "failed"
  error: string
}

export type McpStatusNeedsAuth = {
  status: "needs_auth"
}

export type McpStatusNeedsClientRegistration = {
  status: "needs_client_registration"
  error: string
}

export type McpStatus =
  | McpStatusConnected
  | McpStatusDisabled
  | McpStatusFailed
  | McpStatusNeedsAuth
  | McpStatusNeedsClientRegistration

export type McpUnsupportedOAuthError = {
  error: string
}

export type McpServerNotFoundError = {
  _tag: "McpServerNotFoundError"
  name: string
  message: string
}

export type Project = {
  id: string
  worktree: string
  vcs?: ProjectVcs
  name?: string
  icon?: ProjectIcon
  commands?: ProjectCommands
  time: ProjectTime
  sandboxes: Array<string>
}

export type ProjectNotFoundError = {
  _tag: "ProjectNotFoundError"
  projectID: string
  message: string
}

export type PtyNotFoundError = {
  _tag: "PtyNotFoundError"
  ptyID: string
  message: string
}

export type PtyForbiddenError = {
  _tag: "PtyForbiddenError"
  message: string
}

export type QuestionRequest = {
  id: string
  sessionID: string
  /**
   * Questions to ask
   */
  questions: Array<QuestionInfo>
  tool?: QuestionTool
}

export type QuestionNotFoundError = {
  _tag: "QuestionNotFoundError"
  requestID: string
  message: string
}

export type PermissionRequest = {
  id: string
  sessionID: string
  permission: string
  patterns: Array<string>
  metadata: {
    [key: string]: unknown
  }
  always: Array<string>
  tool?: {
    messageID: string
    callID: string
  }
}

export type PermissionNotFoundError = {
  _tag: "PermissionNotFoundError"
  requestID: string
  message: string
}

export type ProviderAuthMethod = {
  type: "oauth" | "api"
  label: string
  prompts?: Array<
    | {
        type: "text"
        key: string
        message: string
        placeholder?: string
        when?: {
          key: string
          op: "eq" | "neq"
          value: string
        }
      }
    | {
        type: "select"
        key: string
        message: string
        options: Array<{
          label: string
          value: string
          hint?: string
        }>
        when?: {
          key: string
          op: "eq" | "neq"
          value: string
        }
      }
  >
}

export type ProviderAuthAuthorization = {
  url: string
  method: "auto" | "code"
  instructions: string
}

export type ProviderAuthError1 = {
  name:
    | "BadRequest"
    | "ProviderAuthOauthMissing"
    | "ProviderAuthOauthCodeMissing"
    | "ProviderAuthOauthCallbackFailed"
    | "ProviderAuthValidationFailed"
  data: {
    providerID?: string
    field?: string
    message?: string
    kind?: string
  }
}

export type NotFoundError = {
  name: "NotFoundError"
  data: {
    message: string
  }
}

export type TextPartInput = {
  id?: string
  type: "text"
  text: string
  synthetic?: boolean
  ignored?: boolean
  time?: {
    start: number
    end?: number
  }
  metadata?: {
    [key: string]: unknown
  }
}

export type FilePartInput = {
  id?: string
  type: "file"
  mime: string
  filename?: string
  url: string
  source?: FilePartSource
}

export type AgentPartInput = {
  id?: string
  type: "agent"
  name: string
  source?: {
    value: string
    start: number
    end: number
  }
}

export type SubtaskPartInput = {
  id?: string
  type: "subtask"
  prompt: string
  description: string
  agent: string
  model?: {
    providerID: string
    modelID: string
  }
  command?: string
}

export type SessionBusyError = {
  _tag: "SessionBusyError"
  sessionID: string
  message: string
}

export type EventTuiPromptAppend = {
  type: "tui.prompt.append"
  properties: {
    text: string
  }
}

export type EventTuiCommandExecute = {
  type: "tui.command.execute"
  properties: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.compact"
      | "session.page.up"
      | "session.page.down"
      | "session.line.up"
      | "session.line.down"
      | "session.half.page.up"
      | "session.half.page.down"
      | "session.first"
      | "session.last"
      | "prompt.clear"
      | "prompt.submit"
      | "agent.cycle"
      | string
  }
}

export type EventTuiToastShow = {
  type: "tui.toast.show"
  properties: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number
  }
}

export type EventTuiSessionSelect = {
  type: "tui.session.select"
  properties: {
    /**
     * Session ID to navigate to
     */
    sessionID: string
  }
}

export type Workspace = {
  id: string
  type: string
  name: string
  branch?: string | null
  directory?: string | null
  extra?: unknown | null
  projectID: string
  timeUsed: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type WorkspaceCreateError = {
  name: "WorkspaceCreateError"
  data: {
    message: string
  }
}

export type WorkspaceWarpError = {
  name: "WorkspaceWarpError"
  data: {
    message: string
  }
}

export type UnauthorizedError = {
  _tag: "UnauthorizedError"
  message: string
}

export type SessionsResponse = {
  data: Array<SessionV2Info>
  cursor: {
    previous?: string
    next?: string
  }
}

export type InvalidCursorError = {
  _tag: "InvalidCursorError"
  message: string
}

export type SessionActive = {
  type: "running"
}

export type SessionNotFoundError = {
  _tag: "SessionNotFoundError"
  sessionID: string
  message: string
}

export type PromptInput = {
  text: string
  files?: Array<PromptInputFileAttachment>
  agents?: Array<PromptAgentAttachment>
}

export type ConflictError = {
  _tag: "ConflictError"
  message: string
  resource?: string
}

export type ServiceUnavailableError = {
  _tag: "ServiceUnavailableError"
  message: string
  service?: string
}

export type MessageNotFoundError = {
  _tag: "MessageNotFoundError"
  sessionID: string
  messageID: string
  message: string
}

export type UnknownError1 = {
  _tag: "UnknownError"
  message: string
  ref?: string
}

export type SessionDurableEvent =
  | SessionNextAgentSwitched
  | SessionNextModelSwitched
  | SessionNextMoved
  | SessionNextPrompted
  | SessionNextPromptAdmitted
  | SessionNextContextUpdated
  | SessionNextSynthetic
  | SessionNextShellStarted
  | SessionNextShellEnded
  | SessionNextStepStarted
  | SessionNextStepEnded
  | SessionNextStepFailed
  | SessionNextTextStarted
  | SessionNextTextEnded
  | SessionNextToolInputStarted
  | SessionNextToolInputEnded
  | SessionNextToolCalled
  | SessionNextToolProgress
  | SessionNextToolSuccess
  | SessionNextToolFailed
  | SessionNextReasoningStarted
  | SessionNextReasoningEnded
  | SessionNextRetried
  | SessionNextCompactionStarted
  | SessionNextCompactionEnded
  | SessionNextRevertStaged
  | SessionNextRevertCleared
  | SessionNextRevertCommitted

export type SessionHistory = {
  data: Array<SessionDurableEvent>
  hasMore: boolean
}

export type SessionDurableEventStream = string

export type SessionMessagesResponse = {
  data: Array<SessionMessage>
  cursor: {
    previous?: string
    next?: string
  }
}

export type ProviderNotFoundError = {
  _tag: "ProviderNotFoundError"
  providerID: string
  message: string
}

export type OutputFormat1 =
  | {
      type: "text"
    }
  | {
      type: "json_schema"
      schema: JsonSchema
      retryCount?: number
    }

export type SessionStatus2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.status"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    status: SessionStatus
  }
}

export type QuestionReplied2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.replied"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    answers: Array<QuestionAnswer>
  }
}

export type QuestionRejected2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.rejected"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
  }
}

export type V2Event =
  | ModelsDevRefreshed
  | IntegrationUpdated
  | IntegrationConnectionUpdated
  | CatalogUpdated
  | SessionCreated
  | SessionUpdated
  | SessionDeleted
  | MessageUpdated
  | MessageRemoved
  | MessagePartUpdated
  | MessagePartRemoved
  | SessionNextAgentSwitched
  | SessionNextModelSwitched
  | SessionNextMoved
  | SessionNextPrompted
  | SessionNextPromptAdmitted
  | SessionNextContextUpdated
  | SessionNextSynthetic
  | SessionNextShellStarted
  | SessionNextShellEnded
  | SessionNextStepStarted
  | SessionNextStepEnded
  | SessionNextStepFailed
  | SessionNextTextStarted
  | SessionNextTextDelta
  | SessionNextTextEnded
  | SessionNextReasoningStarted
  | SessionNextReasoningDelta
  | SessionNextReasoningEnded
  | SessionNextToolInputStarted
  | SessionNextToolInputDelta
  | SessionNextToolInputEnded
  | SessionNextToolCalled
  | SessionNextToolProgress
  | SessionNextToolSuccess
  | SessionNextToolFailed
  | SessionNextRetried
  | SessionNextCompactionStarted
  | SessionNextCompactionDelta
  | SessionNextCompactionEnded
  | SessionNextRevertStaged
  | SessionNextRevertCleared
  | SessionNextRevertCommitted
  | MessagePartDelta
  | SessionDiff
  | SessionError
  | InstallationUpdated
  | InstallationUpdateAvailable
  | FileEdited
  | ReferenceUpdated
  | PermissionV2Asked
  | PermissionV2Replied
  | PluginAdded
  | ProjectDirectoriesUpdated
  | FileWatcherUpdated
  | PtyCreated
  | PtyUpdated
  | PtyExited
  | PtyDeleted
  | QuestionV2Asked
  | QuestionV2Replied
  | QuestionV2Rejected
  | TodoUpdated
  | LspUpdated
  | PermissionAsked
  | PermissionReplied
  | TuiPromptAppend
  | TuiCommandExecute
  | TuiToastShow
  | TuiSessionSelect
  | McpToolsChanged
  | McpBrowserOpenFailed
  | CommandExecuted
  | ProjectUpdated
  | SessionStatus2
  | SessionIdle
  | QuestionAsked
  | QuestionReplied2
  | QuestionRejected2
  | SessionCompacted
  | VcsBranchUpdated
  | WorkspaceReady
  | WorkspaceFailed
  | WorkspaceStatus
  | WorktreeReady
  | WorktreeFailed
  | ServerConnected
  | GlobalDisposed

export type V2EventStream = string

export type ForbiddenError = {
  _tag: "ForbiddenError"
  message: string
}

export type ProjectCopyError = {
  name: "ProjectCopyError"
  data: {
    message: string
    forceRequired?: boolean
  }
}

export type EffectHttpApiErrorForbidden = {
  _tag: "Forbidden"
}

export type EventTuiPromptAppend2 = {
  id: string
  type: "tui.prompt.append"
  properties: {
    text: string
  }
}

export type EventTuiCommandExecute2 = {
  id: string
  type: "tui.command.execute"
  properties: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.compact"
      | "session.page.up"
      | "session.page.down"
      | "session.line.up"
      | "session.line.down"
      | "session.half.page.up"
      | "session.half.page.down"
      | "session.first"
      | "session.last"
      | "prompt.clear"
      | "prompt.submit"
      | "agent.cycle"
      | string
  }
}

export type EventTuiToastShow2 = {
  id: string
  type: "tui.toast.show"
  properties: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number
  }
}

export type EventTuiSessionSelect2 = {
  id: string
  type: "tui.session.select"
  properties: {
    /**
     * Session ID to navigate to
     */
    sessionID: string
  }
}

export type CredentialValue = CredentialOAuth | CredentialKey

export type IntegrationInputs = {
  [key: string]: string
}

export type IntegrationMethod = IntegrationOAuthMethod | IntegrationKeyMethod | IntegrationEnvMethod

export type IntegrationRef = {
  id: string
  name: string
}

export type SkillV2Source = SkillV2DirectorySource | SkillV2UrlSource | SkillV2EmbeddedSource

export type MoveSessionDestination = {
  directory: string
}

export type ModelRef = {
  id: string
  providerID: string
  variant?: string
}

export type LocationRef = {
  directory: string
  workspaceID?: string
}

export type PromptSource = {
  start: number
  end: number
  text: string
}

export type PromptFileAttachment = {
  uri: string
  mime: string
  name?: string
  description?: string
  source?: PromptSource
}

export type PromptAgentAttachment = {
  name: string
  source?: PromptSource
}

export type SessionErrorUnknown = {
  type: "unknown"
  message: string
}

export type LlmProviderMetadata = {
  [key: string]: {
    [key: string]: unknown
  }
}

export type ToolTextContent = {
  type: "text"
  text: string
}

export type ToolFileContent = {
  type: "file"
  uri: string
  mime: string
  name?: string
}

export type LlmToolContent = ToolTextContent | ToolFileContent

export type SessionNextRetryError = {
  message: string
  statusCode?: number
  isRetryable: boolean
  responseHeaders?: {
    [key: string]: string
  }
  responseBody?: string
  metadata?: {
    [key: string]: string
  }
}

export type FileDiff = {
  path: string
  status: "added" | "modified" | "deleted"
  additions: number
  deletions: number
  patch: string
}

export type RevertState = {
  messageID: string
  partID?: string
  snapshot?: string
  diff?: string
  files?: Array<FileDiff>
}

export type PermissionV2Source = {
  type: "tool"
  messageID: string
  callID: string
}

export type PermissionV2Reply = "once" | "always" | "reject"

export type QuestionV2Option = {
  /**
   * Display text (1-5 words, concise)
   */
  label: string
  /**
   * Explanation of choice
   */
  description: string
}

export type QuestionV2Info = {
  /**
   * Complete question
   */
  question: string
  /**
   * Very short label (max 30 chars)
   */
  header: string
  /**
   * Available choices
   */
  options: Array<QuestionV2Option>
  multiple?: boolean
  custom?: boolean
}

export type QuestionV2Tool = {
  messageID: string
  callID: string
}

export type QuestionV2Answer = Array<string>

export type ProjectVcs = "git"

export type ProjectIcon = {
  url?: string
  override?: string
  color?: string
}

export type ProjectCommands = {
  /**
   * Startup script to run when creating a new workspace (worktree)
   */
  start?: string
}

export type ProjectTime = {
  created: number
  updated: number
  initialized?: number
}

export type EventServerInstanceDisposed = {
  id: string
  type: "server.instance.disposed"
  properties: {
    directory: string
  }
}

export type SyncEventSessionCreated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.created.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      info: Session
    }
  }
}

export type SyncEventSessionUpdated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.updated.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      info: Session
    }
  }
}

export type SyncEventSessionDeleted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.deleted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      info: Session
    }
  }
}

export type SyncEventMessageUpdated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "message.updated.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      info: Message
    }
  }
}

export type SyncEventMessageRemoved = {
  type: "sync"
  id: string
  syncEvent: {
    type: "message.removed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      messageID: string
    }
  }
}

export type SyncEventMessagePartUpdated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "message.part.updated.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      part: Part
      time: number
    }
  }
}

export type SyncEventMessagePartRemoved = {
  type: "sync"
  id: string
  syncEvent: {
    type: "message.part.removed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      messageID: string
      partID: string
    }
  }
}

export type SyncEventSessionNextAgentSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.agent.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      agent: string
    }
  }
}

export type SyncEventSessionNextModelSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.model.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      model: ModelRef
    }
  }
}

export type SyncEventSessionNextMoved = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.moved.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      location: LocationRef
      subdirectory?: string
    }
  }
}

export type SyncEventSessionNextPrompted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.prompted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      prompt: Prompt
      delivery: "steer" | "queue"
    }
  }
}

export type SyncEventSessionNextPromptAdmitted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.prompt.admitted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      prompt: Prompt
      delivery: "steer" | "queue"
    }
  }
}

export type SyncEventSessionNextContextUpdated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.context.updated.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      text: string
    }
  }
}

export type SyncEventSessionNextSynthetic = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.synthetic.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      text: string
    }
  }
}

export type SyncEventSessionNextShellStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.shell.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      callID: string
      command: string
    }
  }
}

export type SyncEventSessionNextShellEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.shell.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      callID: string
      output: string
    }
  }
}

export type SyncEventSessionNextStepStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.step.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      agent: string
      model: ModelRef
      snapshot?: string
    }
  }
}

export type SyncEventSessionNextStepEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.step.ended.2"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      finish: string
      cost: number
      tokens: {
        input: number
        output: number
        reasoning: number
        cache: {
          read: number
          write: number
        }
      }
      snapshot?: string
      files?: Array<string>
    }
  }
}

export type SyncEventSessionNextStepFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.step.failed.2"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      error: SessionErrorUnknown
    }
  }
}

export type SyncEventSessionNextTextStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.text.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      textID: string
    }
  }
}

export type SyncEventSessionNextTextEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.text.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      textID: string
      text: string
    }
  }
}

export type SyncEventSessionNextReasoningStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.reasoning.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      reasoningID: string
      providerMetadata?: LlmProviderMetadata
    }
  }
}

export type SyncEventSessionNextReasoningEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.reasoning.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      reasoningID: string
      text: string
      providerMetadata?: LlmProviderMetadata
    }
  }
}

export type SyncEventSessionNextToolInputStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.input.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      name: string
    }
  }
}

export type SyncEventSessionNextToolInputEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.input.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      text: string
    }
  }
}

export type SyncEventSessionNextToolCalled = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.called.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      tool: string
      input: {
        [key: string]: unknown
      }
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

export type SyncEventSessionNextToolProgress = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.progress.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      structured: {
        [key: string]: unknown
      }
      content: Array<LlmToolContent>
    }
  }
}

export type SyncEventSessionNextToolSuccess = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.success.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      structured: {
        [key: string]: unknown
      }
      content: Array<LlmToolContent>
      outputPaths?: Array<string>
      result?: unknown
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

export type SyncEventSessionNextToolFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.tool.failed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      assistantMessageID: string
      callID: string
      error: SessionErrorUnknown
      result?: unknown
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

export type SyncEventSessionNextRetried = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.retried.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      attempt: number
      error: SessionNextRetryError
    }
  }
}

export type SyncEventSessionNextCompactionStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.compaction.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      reason: "auto" | "manual"
    }
  }
}

export type SyncEventSessionNextCompactionEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.compaction.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      reason: "auto" | "manual"
      text: string
      recent: string
    }
  }
}

export type SyncEventSessionNextRevertStaged = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.revert.staged.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      revert: RevertState
    }
  }
}

export type SyncEventSessionNextRevertCleared = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.revert.cleared.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
    }
  }
}

export type SyncEventSessionNextRevertCommitted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.revert.committed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
    }
  }
}

export type ConfigV2ReferenceGit = {
  repository: string
  branch?: string
  description?: string
  hidden?: boolean
}

export type ConfigV2ReferenceLocal = {
  path: string
  description?: string
  hidden?: boolean
}

export type PolicyEffect = "allow" | "deny"

export type ConfigV2ExperimentalPolicy = {
  action: "provider.use"
  effect: PolicyEffect
  resource: string
}

export type ProjectDirectories = Array<{
  directory: string
  strategy?: string
}>

export type PtyTicketConnectToken = {
  ticket: string
  expires_in: number
}

export type WorkspaceEventConnectionStatus = {
  workspaceID: string
  status: "connected" | "connecting" | "disconnected" | "error"
}

export type LocationInfo = {
  directory: string
  workspaceID?: string
  project: {
    id: string
    directory: string
  }
}

export type ProviderRequest = {
  headers: {
    [key: string]: string
  }
  body: {
    [key: string]: unknown
  }
}

export type AgentColor = string | "primary" | "secondary" | "accent" | "success" | "warning" | "error" | "info"

export type PermissionV2Effect = "allow" | "deny" | "ask"

export type PermissionV2Rule = {
  action: string
  resource: string
  effect: PermissionV2Effect
}

export type PermissionV2Ruleset = Array<PermissionV2Rule>

export type AgentV2Info = {
  id: string
  model?: ModelRef
  request: ProviderRequest
  system?: string
  description?: string
  mode: "subagent" | "primary" | "all"
  hidden: boolean
  color?: AgentColor
  steps?: number
  permissions: PermissionV2Ruleset
}

export type SessionV2Info = {
  id: string
  parentID?: string
  projectID: string
  agent?: string
  model?: ModelRef
  cost: number
  tokens: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  time: {
    created: number
    updated: number
    archived?: number
  }
  title: string
  location: LocationRef
  subpath?: string
  revert?: RevertState
}

export type PromptInputFileAttachment = {
  uri: string
  name?: string
  description?: string
  source?: PromptSource
}

export type SessionInputAdmitted = {
  admittedSeq: number
  id: string
  sessionID: string
  prompt: Prompt
  delivery: "steer" | "queue"
  timeCreated: number
  promotedSeq?: number
}

export type SessionMessageAgentSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "agent-switched"
  agent: string
}

export type SessionMessageModelSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "model-switched"
  model: ModelRef
}

export type SessionMessageUser = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  text: string
  files?: Array<PromptFileAttachment>
  agents?: Array<PromptAgentAttachment>
  type: "user"
}

export type SessionMessageSynthetic = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  sessionID: string
  text: string
  type: "synthetic"
}

export type SessionMessageSystem = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "system"
  text: string
}

export type SessionMessageShell = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "shell"
  callID: string
  command: string
  output: string
}

export type SessionMessageAssistantText = {
  type: "text"
  id: string
  text: string
}

export type SessionMessageAssistantReasoning = {
  type: "reasoning"
  id: string
  text: string
  providerMetadata?: LlmProviderMetadata
  time?: {
    created: number
    completed?: number
  }
}

export type SessionMessageToolStatePending = {
  status: "pending"
  input: string
}

export type SessionMessageToolStateRunning = {
  status: "running"
  input: {
    [key: string]: unknown
  }
  structured: {
    [key: string]: unknown
  }
  content: Array<LlmToolContent>
}

export type SessionMessageToolStateCompleted = {
  status: "completed"
  input: {
    [key: string]: unknown
  }
  attachments?: Array<PromptFileAttachment>
  content: Array<LlmToolContent>
  outputPaths?: Array<string>
  structured: {
    [key: string]: unknown
  }
  result?: unknown
}

export type SessionMessageToolStateError = {
  status: "error"
  input: {
    [key: string]: unknown
  }
  content: Array<LlmToolContent>
  structured: {
    [key: string]: unknown
  }
  error: SessionErrorUnknown
  result?: unknown
}

export type SessionMessageAssistantTool = {
  type: "tool"
  id: string
  name: string
  provider?: {
    executed: boolean
    metadata?: LlmProviderMetadata
    resultMetadata?: LlmProviderMetadata
  }
  state:
    | SessionMessageToolStatePending
    | SessionMessageToolStateRunning
    | SessionMessageToolStateCompleted
    | SessionMessageToolStateError
  time: {
    created: number
    ran?: number
    completed?: number
    pruned?: number
  }
}

export type SessionMessageAssistant = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "assistant"
  agent: string
  model: ModelRef
  content: Array<SessionMessageAssistantText | SessionMessageAssistantReasoning | SessionMessageAssistantTool>
  snapshot?: {
    start?: string
    end?: string
    files?: Array<string>
  }
  finish?: string
  cost?: number
  tokens?: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  error?: SessionErrorUnknown
}

export type SessionMessageCompaction = {
  type: "compaction"
  reason: "auto" | "manual"
  summary: string
  recent: string
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
}

export type SessionMessage =
  | SessionMessageAgentSwitched
  | SessionMessageModelSwitched
  | SessionMessageUser
  | SessionMessageSynthetic
  | SessionMessageSystem
  | SessionMessageShell
  | SessionMessageAssistant
  | SessionMessageCompaction

export type SessionNextAgentSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.agent.switched"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    agent: string
  }
}

export type SessionNextModelSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.model.switched"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    model: ModelRef
  }
}

export type SessionNextMoved = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.moved"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    location: LocationRef
    subdirectory?: string
  }
}

export type SessionNextPrompted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.prompted"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    prompt: Prompt
    delivery: "steer" | "queue"
  }
}

export type SessionNextPromptAdmitted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.prompt.admitted"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    prompt: Prompt
    delivery: "steer" | "queue"
  }
}

export type SessionNextContextUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.context.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type SessionNextSynthetic = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.synthetic"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type SessionNextShellStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.shell.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    callID: string
    command: string
  }
}

export type SessionNextShellEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.shell.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    callID: string
    output: string
  }
}

export type SessionNextStepStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.step.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    agent: string
    model: ModelRef
    snapshot?: string
  }
}

export type SessionNextStepEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.step.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    finish: string
    cost: number
    tokens: {
      input: number
      output: number
      reasoning: number
      cache: {
        read: number
        write: number
      }
    }
    snapshot?: string
    files?: Array<string>
  }
}

export type SessionNextStepFailed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.step.failed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    error: SessionErrorUnknown
  }
}

export type SessionNextTextStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.text.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
  }
}

export type SessionNextTextEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.text.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
    text: string
  }
}

export type SessionNextToolInputStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.input.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    name: string
  }
}

export type SessionNextToolInputEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.input.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    text: string
  }
}

export type SessionNextToolCalled = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.called"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    tool: string
    input: {
      [key: string]: unknown
    }
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type SessionNextToolProgress = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.progress"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
  }
}

export type SessionNextToolSuccess = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.success"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    outputPaths?: Array<string>
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type SessionNextToolFailed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.failed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionErrorUnknown
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type SessionNextReasoningStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.reasoning.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    providerMetadata?: LlmProviderMetadata
  }
}

export type SessionNextReasoningEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.reasoning.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    text: string
    providerMetadata?: LlmProviderMetadata
  }
}

export type SessionNextRetried = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.retried"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    attempt: number
    error: SessionNextRetryError
  }
}

export type SessionNextCompactionStarted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.compaction.started"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    reason: "auto" | "manual"
  }
}

export type SessionNextCompactionEnded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.compaction.ended"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    reason: "auto" | "manual"
    text: string
    recent: string
  }
}

export type SessionNextRevertStaged = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.revert.staged"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    revert: RevertState
  }
}

export type SessionNextRevertCleared = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.revert.cleared"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
  }
}

export type SessionNextRevertCommitted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.revert.committed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
  }
}

export type ModelApi =
  | {
      id: string
      type: "aisdk"
      package: string
      url?: string
      settings?: {
        [key: string]: unknown
      }
    }
  | {
      id: string
      type: "native"
      url?: string
      settings: {
        [key: string]: unknown
      }
    }

export type ModelCapabilities = {
  tools: boolean
  input: Array<string>
  output: Array<string>
}

export type ModelCost = {
  tier?: {
    type: "context"
    size: number
  }
  input: number
  output: number
  cache: {
    read: number
    write: number
  }
}

export type ModelV2Info = {
  id: string
  providerID: string
  family?: string
  name: string
  api: ModelApi
  capabilities: ModelCapabilities
  request: {
    headers: {
      [key: string]: string
    }
    body: {
      [key: string]: unknown
    }
    variant?: string
  }
  variants: Array<{
    id: string
    headers: {
      [key: string]: string
    }
    body: {
      [key: string]: unknown
    }
  }>
  time: {
    released: number
  }
  cost: Array<ModelCost>
  status: "alpha" | "beta" | "deprecated" | "active"
  enabled: boolean
  limit: {
    context: number
    input?: number
    output: number
  }
}

export type ProviderAisdk = {
  type: "aisdk"
  package: string
  url?: string
  settings?: {
    [key: string]: unknown
  }
}

export type ProviderNative = {
  type: "native"
  url?: string
  settings: {
    [key: string]: unknown
  }
}

export type ProviderApi = ProviderAisdk | ProviderNative

export type ProviderV2Info = {
  id: string
  integrationID?: string
  name: string
  disabled?: boolean
  api: ProviderApi
  request: ProviderRequest
}

export type IntegrationWhen = {
  key: string
  op: "eq" | "neq"
  value: string
}

export type IntegrationTextPrompt = {
  type: "text"
  key: string
  message: string
  placeholder?: string
  when?: IntegrationWhen
}

export type IntegrationSelectPrompt = {
  type: "select"
  key: string
  message: string
  options: Array<{
    label: string
    value: string
    hint?: string
  }>
  when?: IntegrationWhen
}

export type IntegrationOAuthMethod = {
  id: string
  type: "oauth"
  label: string
  prompts?: Array<IntegrationTextPrompt | IntegrationSelectPrompt>
}

export type IntegrationKeyMethod = {
  type: "key"
  label?: string
}

export type IntegrationEnvMethod = {
  type: "env"
  names: Array<string>
}

export type ConnectionCredentialInfo = {
  type: "credential"
  id: string
  label: string
}

export type ConnectionEnvInfo = {
  type: "env"
  name: string
}

export type ConnectionInfo = ConnectionCredentialInfo | ConnectionEnvInfo

export type IntegrationInfo = {
  id: string
  name: string
  methods: Array<IntegrationMethod>
  connections: Array<ConnectionInfo>
}

export type IntegrationAttempt = {
  attemptID: string
  url: string
  instructions: string
  mode: "auto" | "code"
  time: {
    created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type IntegrationAttemptStatus =
  | {
      status: "pending"
      time: {
        created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
        expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      }
    }
  | {
      status: "complete"
      time: {
        created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
        expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      }
    }
  | {
      status: "failed"
      message: string
      time: {
        created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
        expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      }
    }
  | {
      status: "expired"
      time: {
        created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
        expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      }
    }

export type PermissionV2Request = {
  id: string
  sessionID: string
  action: string
  resources: Array<string>
  save?: Array<string>
  metadata?: {
    [key: string]: unknown
  }
  source?: PermissionV2Source
}

export type PermissionSavedInfo = {
  id: string
  projectID: string
  action: string
  resource: string
}

export type FileSystemEntry = {
  path: string
  type: "file" | "directory"
}

export type CommandV2Info = {
  name: string
  template: string
  description?: string
  agent?: string
  model?: ModelRef
  subtask?: boolean
}

export type SkillV2Info = {
  name: string
  description?: string
  slash?: boolean
  location: string
  content: string
}

export type ModelsDevRefreshed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "models-dev.refreshed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type IntegrationUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "integration.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type IntegrationConnectionUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "integration.connection.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    integrationID: string
  }
}

export type CatalogUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "catalog.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type SessionCreated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.created"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    info: Session
  }
}

export type SessionUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    info: Session
  }
}

export type SessionDeleted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.deleted"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    info: Session
  }
}

export type MessageUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "message.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    info: Message
  }
}

export type MessageRemoved = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "message.removed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    messageID: string
  }
}

export type MessagePartUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "message.part.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    part: Part
    time: number
  }
}

export type MessagePartRemoved = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "message.part.removed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    messageID: string
    partID: string
  }
}

export type SessionNextTextDelta = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.text.delta"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
    delta: string
  }
}

export type SessionNextReasoningDelta = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.reasoning.delta"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    delta: string
  }
}

export type SessionNextToolInputDelta = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.tool.input.delta"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    delta: string
  }
}

export type SessionNextCompactionDelta = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.compaction.delta"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type MessagePartDelta = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "message.part.delta"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    messageID: string
    partID: string
    field: string
    delta: string
  }
}

export type SessionDiff = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.diff"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    diff: Array<SnapshotFileDiff>
  }
}

export type SessionError = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.error"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID?: string
    error?:
      | ProviderAuthError
      | UnknownError
      | MessageOutputLengthError
      | MessageAbortedError
      | StructuredOutputError
      | ContextOverflowError
      | ContentFilterError
      | ApiError
  }
}

export type InstallationUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "installation.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    version: string
  }
}

export type InstallationUpdateAvailable = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "installation.update-available"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    version: string
  }
}

export type FileEdited = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "file.edited"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    file: string
  }
}

export type ReferenceUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "reference.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type PermissionV2Asked = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.asked"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    sessionID: string
    action: string
    resources: Array<string>
    save?: Array<string>
    metadata?: {
      [key: string]: unknown
    }
    source?: PermissionV2Source
  }
}

export type PermissionV2Replied = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.replied"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    reply: PermissionV2Reply
  }
}

export type PluginAdded = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "plugin.added"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
  }
}

export type ProjectDirectoriesUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "project.directories.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    projectID: string
  }
}

export type FileWatcherUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "file.watcher.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    file: string
    event: "add" | "change" | "unlink"
  }
}

export type PtyCreated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.created"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    info: Pty
  }
}

export type PtyUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    info: Pty
  }
}

export type PtyExited = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.exited"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    exitCode: number
  }
}

export type PtyDeleted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.deleted"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
  }
}

export type QuestionV2Asked = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.asked"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionV2Info>
    tool?: QuestionV2Tool
  }
}

export type QuestionV2Replied = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.replied"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    answers: Array<QuestionV2Answer>
  }
}

export type QuestionV2Rejected = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.rejected"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
  }
}

export type TodoUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "todo.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    todos: Array<Todo>
  }
}

export type LspUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "lsp.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type PermissionAsked = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.asked"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    sessionID: string
    permission: string
    patterns: Array<string>
    metadata: {
      [key: string]: unknown
    }
    always: Array<string>
    tool?: {
      messageID: string
      callID: string
    }
  }
}

export type PermissionReplied = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.replied"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    reply: "once" | "always" | "reject"
  }
}

export type TuiPromptAppend = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.prompt.append"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    text: string
  }
}

export type TuiCommandExecute = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.command.execute"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.compact"
      | "session.page.up"
      | "session.page.down"
      | "session.line.up"
      | "session.line.down"
      | "session.half.page.up"
      | "session.half.page.down"
      | "session.first"
      | "session.last"
      | "prompt.clear"
      | "prompt.submit"
      | "agent.cycle"
      | string
  }
}

export type TuiToastShow = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.toast.show"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number
  }
}

export type TuiSessionSelect = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.session.select"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    /**
     * Session ID to navigate to
     */
    sessionID: string
  }
}

export type McpToolsChanged = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.tools.changed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    server: string
  }
}

export type McpBrowserOpenFailed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.browser.open.failed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    mcpName: string
    url: string
  }
}

export type CommandExecuted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "command.executed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    name: string
    sessionID: string
    arguments: string
    messageID: string
  }
}

export type ProjectUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "project.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    worktree: string
    vcs?: ProjectVcs
    name?: string
    icon?: ProjectIcon
    commands?: ProjectCommands
    time: ProjectTime
    sandboxes: Array<string>
  }
}

export type SessionIdle = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.idle"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
  }
}

export type QuestionAsked = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "question.asked"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionInfo>
    tool?: QuestionTool
  }
}

export type SessionCompacted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compacted"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
  }
}

export type VcsBranchUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "vcs.branch.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    branch?: string
  }
}

export type WorkspaceReady = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "workspace.ready"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    name: string
  }
}

export type WorkspaceFailed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "workspace.failed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    message: string
  }
}

export type WorkspaceStatus = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "workspace.status"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    workspaceID: string
    status: "connected" | "connecting" | "disconnected" | "error"
  }
}

export type WorktreeReady = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "worktree.ready"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    name: string
    branch?: string
  }
}

export type WorktreeFailed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "worktree.failed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    message: string
  }
}

export type ServerConnected = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "server.connected"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type GlobalDisposed = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "global.disposed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type QuestionV2Request = {
  id: string
  sessionID: string
  /**
   * Questions to ask
   */
  questions: Array<QuestionV2Info>
  tool?: QuestionV2Tool
}

export type QuestionV2Reply = {
  /**
   * User answers in order of questions (each answer is an array of selected labels)
   */
  answers: Array<QuestionV2Answer>
}

export type ReferenceLocalSource = {
  type: "local"
  path: string
  description?: string
  hidden?: boolean
}

export type ReferenceGitSource = {
  type: "git"
  repository: string
  branch?: string
  description?: string
  hidden?: boolean
}

export type ReferenceSource = ReferenceLocalSource | ReferenceGitSource

export type ReferenceInfo = {
  name: string
  path: string
  description?: string
  hidden?: boolean
  source: ReferenceSource
}

export type ProjectCopyCopy = {
  directory: string
}

export type EventModelsDevRefreshed = {
  id: string
  type: "models-dev.refreshed"
  properties: {
    [key: string]: unknown
  }
}

export type EventIntegrationUpdated = {
  id: string
  type: "integration.updated"
  properties: {
    [key: string]: unknown
  }
}

export type EventIntegrationConnectionUpdated = {
  id: string
  type: "integration.connection.updated"
  properties: {
    integrationID: string
  }
}

export type EventCatalogUpdated = {
  id: string
  type: "catalog.updated"
  properties: {
    [key: string]: unknown
  }
}

export type EventSessionCreated = {
  id: string
  type: "session.created"
  properties: {
    sessionID: string
    info: Session
  }
}

export type EventSessionUpdated = {
  id: string
  type: "session.updated"
  properties: {
    sessionID: string
    info: Session
  }
}

export type EventSessionDeleted = {
  id: string
  type: "session.deleted"
  properties: {
    sessionID: string
    info: Session
  }
}

export type EventMessageUpdated = {
  id: string
  type: "message.updated"
  properties: {
    sessionID: string
    info: Message
  }
}

export type EventMessageRemoved = {
  id: string
  type: "message.removed"
  properties: {
    sessionID: string
    messageID: string
  }
}

export type EventMessagePartUpdated = {
  id: string
  type: "message.part.updated"
  properties: {
    sessionID: string
    part: Part
    time: number
  }
}

export type EventMessagePartRemoved = {
  id: string
  type: "message.part.removed"
  properties: {
    sessionID: string
    messageID: string
    partID: string
  }
}

export type EventSessionNextAgentSwitched = {
  id: string
  type: "session.next.agent.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    agent: string
  }
}

export type EventSessionNextModelSwitched = {
  id: string
  type: "session.next.model.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    model: ModelRef
  }
}

export type EventSessionNextMoved = {
  id: string
  type: "session.next.moved"
  properties: {
    timestamp: number
    sessionID: string
    location: LocationRef
    subdirectory?: string
  }
}

export type EventSessionNextPrompted = {
  id: string
  type: "session.next.prompted"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    prompt: Prompt
    delivery: "steer" | "queue"
  }
}

export type EventSessionNextPromptAdmitted = {
  id: string
  type: "session.next.prompt.admitted"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    prompt: Prompt
    delivery: "steer" | "queue"
  }
}

export type EventSessionNextContextUpdated = {
  id: string
  type: "session.next.context.updated"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type EventSessionNextSynthetic = {
  id: string
  type: "session.next.synthetic"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type EventSessionNextShellStarted = {
  id: string
  type: "session.next.shell.started"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    callID: string
    command: string
  }
}

export type EventSessionNextShellEnded = {
  id: string
  type: "session.next.shell.ended"
  properties: {
    timestamp: number
    sessionID: string
    callID: string
    output: string
  }
}

export type EventSessionNextStepStarted = {
  id: string
  type: "session.next.step.started"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    agent: string
    model: ModelRef
    snapshot?: string
  }
}

export type EventSessionNextStepEnded = {
  id: string
  type: "session.next.step.ended"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    finish: string
    cost: number
    tokens: {
      input: number
      output: number
      reasoning: number
      cache: {
        read: number
        write: number
      }
    }
    snapshot?: string
    files?: Array<string>
  }
}

export type EventSessionNextStepFailed = {
  id: string
  type: "session.next.step.failed"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    error: SessionErrorUnknown
  }
}

export type EventSessionNextTextStarted = {
  id: string
  type: "session.next.text.started"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
  }
}

export type EventSessionNextTextDelta = {
  id: string
  type: "session.next.text.delta"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
    delta: string
  }
}

export type EventSessionNextTextEnded = {
  id: string
  type: "session.next.text.ended"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    textID: string
    text: string
  }
}

export type EventSessionNextReasoningStarted = {
  id: string
  type: "session.next.reasoning.started"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    providerMetadata?: LlmProviderMetadata
  }
}

export type EventSessionNextReasoningDelta = {
  id: string
  type: "session.next.reasoning.delta"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    delta: string
  }
}

export type EventSessionNextReasoningEnded = {
  id: string
  type: "session.next.reasoning.ended"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    text: string
    providerMetadata?: LlmProviderMetadata
  }
}

export type EventSessionNextToolInputStarted = {
  id: string
  type: "session.next.tool.input.started"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    name: string
  }
}

export type EventSessionNextToolInputDelta = {
  id: string
  type: "session.next.tool.input.delta"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    delta: string
  }
}

export type EventSessionNextToolInputEnded = {
  id: string
  type: "session.next.tool.input.ended"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    text: string
  }
}

export type EventSessionNextToolCalled = {
  id: string
  type: "session.next.tool.called"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    tool: string
    input: {
      [key: string]: unknown
    }
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type EventSessionNextToolProgress = {
  id: string
  type: "session.next.tool.progress"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
  }
}

export type EventSessionNextToolSuccess = {
  id: string
  type: "session.next.tool.success"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    outputPaths?: Array<string>
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type EventSessionNextToolFailed = {
  id: string
  type: "session.next.tool.failed"
  properties: {
    timestamp: number
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionErrorUnknown
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type EventSessionNextRetried = {
  id: string
  type: "session.next.retried"
  properties: {
    timestamp: number
    sessionID: string
    attempt: number
    error: SessionNextRetryError
  }
}

export type EventSessionNextCompactionStarted = {
  id: string
  type: "session.next.compaction.started"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    reason: "auto" | "manual"
  }
}

export type EventSessionNextCompactionDelta = {
  id: string
  type: "session.next.compaction.delta"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    text: string
  }
}

export type EventSessionNextCompactionEnded = {
  id: string
  type: "session.next.compaction.ended"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    reason: "auto" | "manual"
    text: string
    recent: string
  }
}

export type EventSessionNextRevertStaged = {
  id: string
  type: "session.next.revert.staged"
  properties: {
    timestamp: number
    sessionID: string
    revert: RevertState
  }
}

export type EventSessionNextRevertCleared = {
  id: string
  type: "session.next.revert.cleared"
  properties: {
    timestamp: number
    sessionID: string
  }
}

export type EventSessionNextRevertCommitted = {
  id: string
  type: "session.next.revert.committed"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
  }
}

export type EventMessagePartDelta = {
  id: string
  type: "message.part.delta"
  properties: {
    sessionID: string
    messageID: string
    partID: string
    field: string
    delta: string
  }
}

export type EventSessionDiff = {
  id: string
  type: "session.diff"
  properties: {
    sessionID: string
    diff: Array<SnapshotFileDiff>
  }
}

export type EventSessionError = {
  id: string
  type: "session.error"
  properties: {
    sessionID?: string
    error?:
      | ProviderAuthError
      | UnknownError
      | MessageOutputLengthError
      | MessageAbortedError
      | StructuredOutputError
      | ContextOverflowError
      | ContentFilterError
      | ApiError
  }
}

export type EventInstallationUpdated = {
  id: string
  type: "installation.updated"
  properties: {
    version: string
  }
}

export type EventInstallationUpdateAvailable = {
  id: string
  type: "installation.update-available"
  properties: {
    version: string
  }
}

export type EventFileEdited = {
  id: string
  type: "file.edited"
  properties: {
    file: string
  }
}

export type EventReferenceUpdated = {
  id: string
  type: "reference.updated"
  properties: {
    [key: string]: unknown
  }
}

export type EventPermissionV2Asked = {
  id: string
  type: "permission.v2.asked"
  properties: {
    id: string
    sessionID: string
    action: string
    resources: Array<string>
    save?: Array<string>
    metadata?: {
      [key: string]: unknown
    }
    source?: PermissionV2Source
  }
}

export type EventPermissionV2Replied = {
  id: string
  type: "permission.v2.replied"
  properties: {
    sessionID: string
    requestID: string
    reply: PermissionV2Reply
  }
}

export type EventPluginAdded = {
  id: string
  type: "plugin.added"
  properties: {
    id: string
  }
}

export type EventProjectDirectoriesUpdated = {
  id: string
  type: "project.directories.updated"
  properties: {
    projectID: string
  }
}

export type EventFileWatcherUpdated = {
  id: string
  type: "file.watcher.updated"
  properties: {
    file: string
    event: "add" | "change" | "unlink"
  }
}

export type EventPtyCreated = {
  id: string
  type: "pty.created"
  properties: {
    info: Pty
  }
}

export type EventPtyUpdated = {
  id: string
  type: "pty.updated"
  properties: {
    info: Pty
  }
}

export type EventPtyExited = {
  id: string
  type: "pty.exited"
  properties: {
    id: string
    exitCode: number
  }
}

export type EventPtyDeleted = {
  id: string
  type: "pty.deleted"
  properties: {
    id: string
  }
}

export type EventQuestionV2Asked = {
  id: string
  type: "question.v2.asked"
  properties: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionV2Info>
    tool?: QuestionV2Tool
  }
}

export type EventQuestionV2Replied = {
  id: string
  type: "question.v2.replied"
  properties: {
    sessionID: string
    requestID: string
    answers: Array<QuestionV2Answer>
  }
}

export type EventQuestionV2Rejected = {
  id: string
  type: "question.v2.rejected"
  properties: {
    sessionID: string
    requestID: string
  }
}

export type EventTodoUpdated = {
  id: string
  type: "todo.updated"
  properties: {
    sessionID: string
    todos: Array<Todo>
  }
}

export type EventLspUpdated = {
  id: string
  type: "lsp.updated"
  properties: {
    [key: string]: unknown
  }
}

export type EventPermissionAsked = {
  id: string
  type: "permission.asked"
  properties: {
    id: string
    sessionID: string
    permission: string
    patterns: Array<string>
    metadata: {
      [key: string]: unknown
    }
    always: Array<string>
    tool?: {
      messageID: string
      callID: string
    }
  }
}

export type EventPermissionReplied = {
  id: string
  type: "permission.replied"
  properties: {
    sessionID: string
    requestID: string
    reply: "once" | "always" | "reject"
  }
}

export type EventMcpToolsChanged = {
  id: string
  type: "mcp.tools.changed"
  properties: {
    server: string
  }
}

export type EventMcpBrowserOpenFailed = {
  id: string
  type: "mcp.browser.open.failed"
  properties: {
    mcpName: string
    url: string
  }
}

export type EventCommandExecuted = {
  id: string
  type: "command.executed"
  properties: {
    name: string
    sessionID: string
    arguments: string
    messageID: string
  }
}

export type EventProjectUpdated = {
  id: string
  type: "project.updated"
  properties: {
    id: string
    worktree: string
    vcs?: ProjectVcs
    name?: string
    icon?: ProjectIcon
    commands?: ProjectCommands
    time: ProjectTime
    sandboxes: Array<string>
  }
}

export type EventSessionStatus = {
  id: string
  type: "session.status"
  properties: {
    sessionID: string
    status: SessionStatus
  }
}

export type EventSessionIdle = {
  id: string
  type: "session.idle"
  properties: {
    sessionID: string
  }
}

export type EventQuestionAsked = {
  id: string
  type: "question.asked"
  properties: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionInfo>
    tool?: QuestionTool
  }
}

export type EventQuestionReplied = {
  id: string
  type: "question.replied"
  properties: {
    sessionID: string
    requestID: string
    answers: Array<QuestionAnswer>
  }
}

export type EventQuestionRejected = {
  id: string
  type: "question.rejected"
  properties: {
    sessionID: string
    requestID: string
  }
}

export type EventSessionCompacted = {
  id: string
  type: "session.compacted"
  properties: {
    sessionID: string
  }
}

export type EventVcsBranchUpdated = {
  id: string
  type: "vcs.branch.updated"
  properties: {
    branch?: string
  }
}

export type EventWorkspaceReady = {
  id: string
  type: "workspace.ready"
  properties: {
    name: string
  }
}

export type EventWorkspaceFailed = {
  id: string
  type: "workspace.failed"
  properties: {
    message: string
  }
}

export type EventWorkspaceStatus = {
  id: string
  type: "workspace.status"
  properties: {
    workspaceID: string
    status: "connected" | "connecting" | "disconnected" | "error"
  }
}

export type EventWorktreeReady = {
  id: string
  type: "worktree.ready"
  properties: {
    name: string
    branch?: string
  }
}

export type EventWorktreeFailed = {
  id: string
  type: "worktree.failed"
  properties: {
    message: string
  }
}

export type EventServerConnected = {
  id: string
  type: "server.connected"
  properties: {
    [key: string]: unknown
  }
}

export type EventGlobalDisposed = {
  id: string
  type: "global.disposed"
  properties: {
    [key: string]: unknown
  }
}

export type CredentialOAuth = {
  type: "oauth"
  methodID: string
  refresh: string
  access: string
  expires: number
  metadata?: {
    [key: string]: unknown
  }
}

export type CredentialKey = {
  type: "key"
  key: string
  metadata?: {
    [key: string]: unknown
  }
}

export type SkillV2DirectorySource = {
  type: "directory"
  path: string
}

export type SkillV2UrlSource = {
  type: "url"
  url: string
}

export type SkillV2EmbeddedSource = {
  type: "embedded"
  skill: SkillV2Info
}

export type BadRequestError = {
  name: "BadRequest"
  data: {
    message: string
    kind?: "Params" | "Headers" | "Query" | "Body" | "Payload"
  }
}

export type AuthRemoveData = {
  body?: never
  path: {
    providerID: string
  }
  query?: never
  url: "/auth/{providerID}"
}

export type AuthRemoveErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type AuthRemoveError = AuthRemoveErrors[keyof AuthRemoveErrors]

export type AuthRemoveResponses = {
  /**
   * Successfully removed authentication credentials
   */
  200: boolean
}

export type AuthRemoveResponse = AuthRemoveResponses[keyof AuthRemoveResponses]

export type AuthSetData = {
  body?: Auth
  path: {
    providerID: string
  }
  query?: never
  url: "/auth/{providerID}"
}

export type AuthSetErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type AuthSetError = AuthSetErrors[keyof AuthSetErrors]

export type AuthSetResponses = {
  /**
   * Successfully set authentication credentials
   */
  200: boolean
}

export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses]

export type AppLogData = {
  body?: {
    /**
     * Service name for the log entry
     */
    service: string
    /**
     * Log level
     */
    level: "debug" | "info" | "error" | "warn"
    /**
     * Log message
     */
    message: string
    extra?: {
      [key: string]: unknown
    }
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/log"
}

export type AppLogErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type AppLogError = AppLogErrors[keyof AppLogErrors]

export type AppLogResponses = {
  /**
   * Log entry written successfully
   */
  200: boolean
}

export type AppLogResponse = AppLogResponses[keyof AppLogResponses]

export type ExperimentalControlPlaneMoveSessionData = {
  body?: {
    sessionID: string
    destination: MoveSessionDestination
    moveChanges?: boolean
  }
  path?: never
  query?: never
  url: "/experimental/control-plane/move-session"
}

export type ExperimentalControlPlaneMoveSessionErrors = {
  /**
   * MoveSessionError | InvalidRequestError
   */
  400: MoveSessionError | InvalidRequestError
}

export type ExperimentalControlPlaneMoveSessionError =
  ExperimentalControlPlaneMoveSessionErrors[keyof ExperimentalControlPlaneMoveSessionErrors]

export type ExperimentalControlPlaneMoveSessionResponses = {
  /**
   * Session moved
   */
  204: void
}

export type ExperimentalControlPlaneMoveSessionResponse =
  ExperimentalControlPlaneMoveSessionResponses[keyof ExperimentalControlPlaneMoveSessionResponses]

export type GlobalHealthData = {
  body?: never
  path?: never
  query?: never
  url: "/global/health"
}

export type GlobalHealthErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type GlobalHealthError = GlobalHealthErrors[keyof GlobalHealthErrors]

export type GlobalHealthResponses = {
  /**
   * Health information
   */
  200: {
    healthy: true
    version: string
  }
}

export type GlobalHealthResponse = GlobalHealthResponses[keyof GlobalHealthResponses]

export type GlobalEventData = {
  body?: never
  path?: never
  query?: never
  url: "/global/event"
}

export type GlobalEventErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type GlobalEventError = GlobalEventErrors[keyof GlobalEventErrors]

export type GlobalEventResponses = {
  /**
   * Event stream
   */
  200: GlobalEvent
}

export type GlobalEventResponse = GlobalEventResponses[keyof GlobalEventResponses]

export type GlobalConfigGetData = {
  body?: never
  path?: never
  query?: never
  url: "/global/config"
}

export type GlobalConfigGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type GlobalConfigGetError = GlobalConfigGetErrors[keyof GlobalConfigGetErrors]

export type GlobalConfigGetResponses = {
  /**
   * Get global config info
   */
  200: Config
}

export type GlobalConfigGetResponse = GlobalConfigGetResponses[keyof GlobalConfigGetResponses]

export type GlobalConfigUpdateData = {
  body?: Config
  path?: never
  query?: never
  url: "/global/config"
}

export type GlobalConfigUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type GlobalConfigUpdateError = GlobalConfigUpdateErrors[keyof GlobalConfigUpdateErrors]

export type GlobalConfigUpdateResponses = {
  /**
   * Successfully updated global config
   */
  200: Config
}

export type GlobalConfigUpdateResponse = GlobalConfigUpdateResponses[keyof GlobalConfigUpdateResponses]

export type GlobalDisposeData = {
  body?: never
  path?: never
  query?: never
  url: "/global/dispose"
}

export type GlobalDisposeErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type GlobalDisposeError = GlobalDisposeErrors[keyof GlobalDisposeErrors]

export type GlobalDisposeResponses = {
  /**
   * Global disposed
   */
  200: boolean
}

export type GlobalDisposeResponse = GlobalDisposeResponses[keyof GlobalDisposeResponses]

export type GlobalUpgradeData = {
  body?: {
    target?: string
  }
  path?: never
  query?: never
  url: "/global/upgrade"
}

export type GlobalUpgradeErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type GlobalUpgradeError = GlobalUpgradeErrors[keyof GlobalUpgradeErrors]

export type GlobalUpgradeResponses = {
  /**
   * Upgrade result
   */
  200:
    | {
        success: true
        version: string
      }
    | {
        success: false
        error: string
      }
}

export type GlobalUpgradeResponse = GlobalUpgradeResponses[keyof GlobalUpgradeResponses]

export type EventSubscribeData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/event"
}

export type EventSubscribeResponses = {
  /**
   * Event stream
   */
  200: Event
}

export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]

export type ConfigGetData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/config"
}

export type ConfigGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ConfigGetError = ConfigGetErrors[keyof ConfigGetErrors]

export type ConfigGetResponses = {
  /**
   * Get config info
   */
  200: Config
}

export type ConfigGetResponse = ConfigGetResponses[keyof ConfigGetResponses]

export type ConfigUpdateData = {
  body?: Config
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/config"
}

export type ConfigUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ConfigUpdateError = ConfigUpdateErrors[keyof ConfigUpdateErrors]

export type ConfigUpdateResponses = {
  /**
   * Successfully updated config
   */
  200: Config
}

export type ConfigUpdateResponse = ConfigUpdateResponses[keyof ConfigUpdateResponses]

export type ConfigProvidersData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/config/providers"
}

export type ConfigProvidersErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ConfigProvidersError = ConfigProvidersErrors[keyof ConfigProvidersErrors]

export type ConfigProvidersResponses = {
  /**
   * List of providers
   */
  200: {
    providers: Array<Provider>
    default: {
      [key: string]: string
    }
  }
}

export type ConfigProvidersResponse = ConfigProvidersResponses[keyof ConfigProvidersResponses]

export type ExperimentalCapabilitiesGetData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/capabilities"
}

export type ExperimentalCapabilitiesGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalCapabilitiesGetError =
  ExperimentalCapabilitiesGetErrors[keyof ExperimentalCapabilitiesGetErrors]

export type ExperimentalCapabilitiesGetResponses = {
  /**
   * Experimental capabilities
   */
  200: ExperimentalCapabilities
}

export type ExperimentalCapabilitiesGetResponse =
  ExperimentalCapabilitiesGetResponses[keyof ExperimentalCapabilitiesGetResponses]

export type ExperimentalConsoleGetData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/console"
}

export type ExperimentalConsoleGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * InternalServerError
   */
  500: EffectHttpApiErrorInternalServerError
}

export type ExperimentalConsoleGetError = ExperimentalConsoleGetErrors[keyof ExperimentalConsoleGetErrors]

export type ExperimentalConsoleGetResponses = {
  /**
   * Active Console provider metadata
   */
  200: ConsoleState
}

export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses]

export type ExperimentalConsoleListOrgsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/console/orgs"
}

export type ExperimentalConsoleListOrgsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * InternalServerError
   */
  500: EffectHttpApiErrorInternalServerError
}

export type ExperimentalConsoleListOrgsError =
  ExperimentalConsoleListOrgsErrors[keyof ExperimentalConsoleListOrgsErrors]

export type ExperimentalConsoleListOrgsResponses = {
  /**
   * Switchable Console orgs
   */
  200: {
    orgs: Array<{
      accountID: string
      accountEmail: string
      accountUrl: string
      orgID: string
      orgName: string
      active: boolean
    }>
  }
}

export type ExperimentalConsoleListOrgsResponse =
  ExperimentalConsoleListOrgsResponses[keyof ExperimentalConsoleListOrgsResponses]

export type ExperimentalConsoleSwitchOrgData = {
  body?: {
    accountID: string
    orgID: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/console/switch"
}

export type ExperimentalConsoleSwitchOrgResponses = {
  /**
   * Switch success
   */
  200: boolean
}

export type ExperimentalConsoleSwitchOrgResponse =
  ExperimentalConsoleSwitchOrgResponses[keyof ExperimentalConsoleSwitchOrgResponses]

export type ToolListData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    provider: string
    model: string
  }
  url: "/experimental/tool"
}

export type ToolListErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ToolListError = ToolListErrors[keyof ToolListErrors]

export type ToolListResponses = {
  /**
   * Tools
   */
  200: ToolList
}

export type ToolListResponse = ToolListResponses[keyof ToolListResponses]

export type ToolIdsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/tool/ids"
}

export type ToolIdsErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ToolIdsError = ToolIdsErrors[keyof ToolIdsErrors]

export type ToolIdsResponses = {
  /**
   * Tool IDs
   */
  200: ToolIds
}

export type ToolIdsResponse = ToolIdsResponses[keyof ToolIdsResponses]

export type WorktreeRemoveData = {
  body?: WorktreeRemoveInput
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/worktree"
}

export type WorktreeRemoveErrors = {
  /**
   * WorktreeError | InvalidRequestError
   */
  400: WorktreeError | InvalidRequestError
}

export type WorktreeRemoveError = WorktreeRemoveErrors[keyof WorktreeRemoveErrors]

export type WorktreeRemoveResponses = {
  /**
   * Worktree removed
   */
  200: boolean
}

export type WorktreeRemoveResponse = WorktreeRemoveResponses[keyof WorktreeRemoveResponses]

export type WorktreeListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/worktree"
}

export type WorktreeListErrors = {
  /**
   * WorktreeError | InvalidRequestError
   */
  400: WorktreeError | InvalidRequestError
}

export type WorktreeListError = WorktreeListErrors[keyof WorktreeListErrors]

export type WorktreeListResponses = {
  /**
   * List of worktree directories
   */
  200: Array<string>
}

export type WorktreeListResponse = WorktreeListResponses[keyof WorktreeListResponses]

export type WorktreeCreateData = {
  body?: WorktreeCreateInput
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/worktree"
}

export type WorktreeCreateErrors = {
  /**
   * WorktreeError | InvalidRequestError
   */
  400: WorktreeError | InvalidRequestError
}

export type WorktreeCreateError = WorktreeCreateErrors[keyof WorktreeCreateErrors]

export type WorktreeCreateResponses = {
  /**
   * Worktree created
   */
  200: Worktree
}

export type WorktreeCreateResponse = WorktreeCreateResponses[keyof WorktreeCreateResponses]

export type WorktreeResetData = {
  body?: WorktreeResetInput
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/worktree/reset"
}

export type WorktreeResetErrors = {
  /**
   * WorktreeError | InvalidRequestError
   */
  400: WorktreeError | InvalidRequestError
}

export type WorktreeResetError = WorktreeResetErrors[keyof WorktreeResetErrors]

export type WorktreeResetResponses = {
  /**
   * Worktree reset
   */
  200: boolean
}

export type WorktreeResetResponse = WorktreeResetResponses[keyof WorktreeResetResponses]

export type ExperimentalSessionListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
    roots?: boolean | "true" | "false"
    start?: number
    cursor?: number
    search?: string
    limit?: number
    archived?: boolean | "true" | "false"
  }
  url: "/experimental/session"
}

export type ExperimentalSessionListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalSessionListError = ExperimentalSessionListErrors[keyof ExperimentalSessionListErrors]

export type ExperimentalSessionListResponses = {
  /**
   * List of sessions
   */
  200: Array<GlobalSession>
}

export type ExperimentalSessionListResponse = ExperimentalSessionListResponses[keyof ExperimentalSessionListResponses]

export type ExperimentalSessionBackgroundData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/session/{sessionID}/background"
}

export type ExperimentalSessionBackgroundErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ExperimentalSessionBackgroundError =
  ExperimentalSessionBackgroundErrors[keyof ExperimentalSessionBackgroundErrors]

export type ExperimentalSessionBackgroundResponses = {
  /**
   * Backgrounded subagents
   */
  200: boolean
}

export type ExperimentalSessionBackgroundResponse =
  ExperimentalSessionBackgroundResponses[keyof ExperimentalSessionBackgroundResponses]

export type ExperimentalResourceListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/resource"
}

export type ExperimentalResourceListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalResourceListError = ExperimentalResourceListErrors[keyof ExperimentalResourceListErrors]

export type ExperimentalResourceListResponses = {
  /**
   * MCP resources
   */
  200: {
    [key: string]: McpResource
  }
}

export type ExperimentalResourceListResponse =
  ExperimentalResourceListResponses[keyof ExperimentalResourceListResponses]

export type FindTextData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    pattern: string
  }
  url: "/find"
}

export type FindTextErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FindTextError = FindTextErrors[keyof FindTextErrors]

export type FindTextResponses = {
  /**
   * Matches
   */
  200: Array<{
    path: {
      text: string
    }
    lines: {
      text: string
    }
    line_number: number
    absolute_offset: number
    submatches: Array<{
      match: {
        text: string
      }
      start: number
      end: number
    }>
  }>
}

export type FindTextResponse = FindTextResponses[keyof FindTextResponses]

export type FindFilesData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    query: string
    dirs?: "true" | "false"
    type?: "file" | "directory"
    limit?: number
  }
  url: "/find/file"
}

export type FindFilesErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FindFilesError = FindFilesErrors[keyof FindFilesErrors]

export type FindFilesResponses = {
  /**
   * File paths
   */
  200: Array<string>
}

export type FindFilesResponse = FindFilesResponses[keyof FindFilesResponses]

export type FindSymbolsData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    query: string
  }
  url: "/find/symbol"
}

export type FindSymbolsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FindSymbolsError = FindSymbolsErrors[keyof FindSymbolsErrors]

export type FindSymbolsResponses = {
  /**
   * Symbols
   */
  200: Array<Symbol>
}

export type FindSymbolsResponse = FindSymbolsResponses[keyof FindSymbolsResponses]

export type FileListData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    path: string
  }
  url: "/file"
}

export type FileListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FileListError = FileListErrors[keyof FileListErrors]

export type FileListResponses = {
  /**
   * Files and directories
   */
  200: Array<FileNode>
}

export type FileListResponse = FileListResponses[keyof FileListResponses]

export type FileReadData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    path: string
  }
  url: "/file/content"
}

export type FileReadErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FileReadError = FileReadErrors[keyof FileReadErrors]

export type FileReadResponses = {
  /**
   * File content
   */
  200: FileContent
}

export type FileReadResponse = FileReadResponses[keyof FileReadResponses]

export type FileStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/file/status"
}

export type FileStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FileStatusError = FileStatusErrors[keyof FileStatusErrors]

export type FileStatusResponses = {
  /**
   * File status
   */
  200: Array<File>
}

export type FileStatusResponse = FileStatusResponses[keyof FileStatusResponses]

export type InstanceDisposeData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/instance/dispose"
}

export type InstanceDisposeErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type InstanceDisposeError = InstanceDisposeErrors[keyof InstanceDisposeErrors]

export type InstanceDisposeResponses = {
  /**
   * Instance disposed
   */
  200: boolean
}

export type InstanceDisposeResponse = InstanceDisposeResponses[keyof InstanceDisposeResponses]

export type PathGetData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/path"
}

export type PathGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type PathGetError = PathGetErrors[keyof PathGetErrors]

export type PathGetResponses = {
  /**
   * Path
   */
  200: Path
}

export type PathGetResponse = PathGetResponses[keyof PathGetResponses]

export type VcsGetData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/vcs"
}

export type VcsGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type VcsGetError = VcsGetErrors[keyof VcsGetErrors]

export type VcsGetResponses = {
  /**
   * VCS info
   */
  200: VcsInfo
}

export type VcsGetResponse = VcsGetResponses[keyof VcsGetResponses]

export type VcsStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/vcs/status"
}

export type VcsStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type VcsStatusError = VcsStatusErrors[keyof VcsStatusErrors]

export type VcsStatusResponses = {
  /**
   * VCS status
   */
  200: Array<VcsFileStatus>
}

export type VcsStatusResponse = VcsStatusResponses[keyof VcsStatusResponses]

export type VcsDiffData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    mode: "git" | "branch"
    context?: number
  }
  url: "/vcs/diff"
}

export type VcsDiffErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type VcsDiffError = VcsDiffErrors[keyof VcsDiffErrors]

export type VcsDiffResponses = {
  /**
   * VCS diff
   */
  200: Array<VcsFileDiff>
}

export type VcsDiffResponse = VcsDiffResponses[keyof VcsDiffResponses]

export type VcsDiffRawData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/vcs/diff/raw"
}

export type VcsDiffRawErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type VcsDiffRawError = VcsDiffRawErrors[keyof VcsDiffRawErrors]

export type VcsDiffRawResponses = {
  /**
   * Raw VCS diff
   */
  200: string
}

export type VcsDiffRawResponse = VcsDiffRawResponses[keyof VcsDiffRawResponses]

export type VcsApplyData = {
  body?: {
    patch: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/vcs/apply"
}

export type VcsApplyErrors = {
  /**
   * VcsApplyError | InvalidRequestError
   */
  400: VcsApplyError | InvalidRequestError
}

export type VcsApplyError2 = VcsApplyErrors[keyof VcsApplyErrors]

export type VcsApplyResponses = {
  /**
   * VCS patch applied
   */
  200: {
    applied: boolean
  }
}

export type VcsApplyResponse = VcsApplyResponses[keyof VcsApplyResponses]

export type CommandListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/command"
}

export type CommandListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type CommandListError = CommandListErrors[keyof CommandListErrors]

export type CommandListResponses = {
  /**
   * List of commands
   */
  200: Array<Command>
}

export type CommandListResponse = CommandListResponses[keyof CommandListResponses]

export type AppAgentsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/agent"
}

export type AppAgentsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type AppAgentsError = AppAgentsErrors[keyof AppAgentsErrors]

export type AppAgentsResponses = {
  /**
   * List of agents
   */
  200: Array<Agent>
}

export type AppAgentsResponse = AppAgentsResponses[keyof AppAgentsResponses]

export type AppSkillsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/skill"
}

export type AppSkillsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type AppSkillsError = AppSkillsErrors[keyof AppSkillsErrors]

export type AppSkillsResponses = {
  /**
   * List of skills
   */
  200: Array<{
    name: string
    description?: string
    location: string
    content: string
  }>
}

export type AppSkillsResponse = AppSkillsResponses[keyof AppSkillsResponses]

export type LspStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/lsp"
}

export type LspStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type LspStatusError = LspStatusErrors[keyof LspStatusErrors]

export type LspStatusResponses = {
  /**
   * LSP server status
   */
  200: Array<LspStatus>
}

export type LspStatusResponse = LspStatusResponses[keyof LspStatusResponses]

export type FormatterStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/formatter"
}

export type FormatterStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type FormatterStatusError = FormatterStatusErrors[keyof FormatterStatusErrors]

export type FormatterStatusResponses = {
  /**
   * Formatter status
   */
  200: Array<FormatterStatus>
}

export type FormatterStatusResponse = FormatterStatusResponses[keyof FormatterStatusResponses]

export type McpStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp"
}

export type McpStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type McpStatusError = McpStatusErrors[keyof McpStatusErrors]

export type McpStatusResponses = {
  /**
   * MCP server status
   */
  200: {
    [key: string]: McpStatus
  }
}

export type McpStatusResponse = McpStatusResponses[keyof McpStatusResponses]

export type McpAddData = {
  body?: {
    name: string
    config: McpLocalConfig | McpRemoteConfig
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp"
}

export type McpAddErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type McpAddError = McpAddErrors[keyof McpAddErrors]

export type McpAddResponses = {
  /**
   * MCP server added successfully
   */
  200: {
    [key: string]: McpStatus
  }
}

export type McpAddResponse = McpAddResponses[keyof McpAddResponses]

export type McpAuthRemoveData = {
  body?: never
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/auth"
}

export type McpAuthRemoveErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpAuthRemoveError = McpAuthRemoveErrors[keyof McpAuthRemoveErrors]

export type McpAuthRemoveResponses = {
  /**
   * OAuth credentials removed
   */
  200: {
    success: true
  }
}

export type McpAuthRemoveResponse = McpAuthRemoveResponses[keyof McpAuthRemoveResponses]

export type McpAuthStartData = {
  body?: never
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/auth"
}

export type McpAuthStartErrors = {
  /**
   * McpUnsupportedOAuthError | InvalidRequestError
   */
  400: McpUnsupportedOAuthError | InvalidRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpAuthStartError = McpAuthStartErrors[keyof McpAuthStartErrors]

export type McpAuthStartResponses = {
  /**
   * OAuth flow started
   */
  200: {
    authorizationUrl: string
    oauthState: string
  }
}

export type McpAuthStartResponse = McpAuthStartResponses[keyof McpAuthStartResponses]

export type McpAuthCallbackData = {
  body?: {
    code: string
  }
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/auth/callback"
}

export type McpAuthCallbackErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpAuthCallbackError = McpAuthCallbackErrors[keyof McpAuthCallbackErrors]

export type McpAuthCallbackResponses = {
  /**
   * OAuth authentication completed
   */
  200: McpStatus
}

export type McpAuthCallbackResponse = McpAuthCallbackResponses[keyof McpAuthCallbackResponses]

export type McpAuthAuthenticateData = {
  body?: never
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/auth/authenticate"
}

export type McpAuthAuthenticateErrors = {
  /**
   * McpUnsupportedOAuthError | InvalidRequestError
   */
  400: McpUnsupportedOAuthError | InvalidRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpAuthAuthenticateError = McpAuthAuthenticateErrors[keyof McpAuthAuthenticateErrors]

export type McpAuthAuthenticateResponses = {
  /**
   * OAuth authentication completed
   */
  200: McpStatus
}

export type McpAuthAuthenticateResponse = McpAuthAuthenticateResponses[keyof McpAuthAuthenticateResponses]

export type McpConnectData = {
  body?: never
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/connect"
}

export type McpConnectErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpConnectError = McpConnectErrors[keyof McpConnectErrors]

export type McpConnectResponses = {
  /**
   * MCP server connected successfully
   */
  200: boolean
}

export type McpConnectResponse = McpConnectResponses[keyof McpConnectResponses]

export type McpDisconnectData = {
  body?: never
  path: {
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/mcp/{name}/disconnect"
}

export type McpDisconnectErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * McpServerNotFoundError
   */
  404: McpServerNotFoundError
}

export type McpDisconnectError = McpDisconnectErrors[keyof McpDisconnectErrors]

export type McpDisconnectResponses = {
  /**
   * MCP server disconnected successfully
   */
  200: boolean
}

export type McpDisconnectResponse = McpDisconnectResponses[keyof McpDisconnectResponses]

export type ProjectListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/project"
}

export type ProjectListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProjectListError = ProjectListErrors[keyof ProjectListErrors]

export type ProjectListResponses = {
  /**
   * List of projects
   */
  200: Array<Project>
}

export type ProjectListResponse = ProjectListResponses[keyof ProjectListResponses]

export type ProjectCurrentData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/project/current"
}

export type ProjectCurrentErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProjectCurrentError = ProjectCurrentErrors[keyof ProjectCurrentErrors]

export type ProjectCurrentResponses = {
  /**
   * Current project information
   */
  200: Project
}

export type ProjectCurrentResponse = ProjectCurrentResponses[keyof ProjectCurrentResponses]

export type ProjectInitGitData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/project/git/init"
}

export type ProjectInitGitErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProjectInitGitError = ProjectInitGitErrors[keyof ProjectInitGitErrors]

export type ProjectInitGitResponses = {
  /**
   * Project information after git initialization
   */
  200: Project
}

export type ProjectInitGitResponse = ProjectInitGitResponses[keyof ProjectInitGitResponses]

export type ProjectUpdateData = {
  body?: {
    name?: string
    icon?: ProjectIcon
    commands?: ProjectCommands
  }
  path: {
    projectID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/project/{projectID}"
}

export type ProjectUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * ProjectNotFoundError
   */
  404: ProjectNotFoundError
}

export type ProjectUpdateError = ProjectUpdateErrors[keyof ProjectUpdateErrors]

export type ProjectUpdateResponses = {
  /**
   * Updated project information
   */
  200: Project
}

export type ProjectUpdateResponse = ProjectUpdateResponses[keyof ProjectUpdateResponses]

export type ProjectDirectoriesData = {
  body?: never
  path: {
    projectID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/project/{projectID}/directories"
}

export type ProjectDirectoriesErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProjectDirectoriesError = ProjectDirectoriesErrors[keyof ProjectDirectoriesErrors]

export type ProjectDirectoriesResponses = {
  /**
   * Project directories
   */
  200: ProjectDirectories
}

export type ProjectDirectoriesResponse = ProjectDirectoriesResponses[keyof ProjectDirectoriesResponses]

export type ExperimentalProjectCopyGenerateNameData = {
  body?: {
    context?: string
  }
  path: {
    projectID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/project/{projectID}/copy/generate-name"
}

export type ExperimentalProjectCopyGenerateNameErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalProjectCopyGenerateNameError =
  ExperimentalProjectCopyGenerateNameErrors[keyof ExperimentalProjectCopyGenerateNameErrors]

export type ExperimentalProjectCopyGenerateNameResponses = {
  /**
   * Success
   */
  200: {
    name: string
  }
}

export type ExperimentalProjectCopyGenerateNameResponse =
  ExperimentalProjectCopyGenerateNameResponses[keyof ExperimentalProjectCopyGenerateNameResponses]

export type PtyShellsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty/shells"
}

export type PtyShellsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type PtyShellsError = PtyShellsErrors[keyof PtyShellsErrors]

export type PtyShellsResponses = {
  /**
   * List of shells
   */
  200: Array<{
    path: string
    name: string
    acceptable: boolean
  }>
}

export type PtyShellsResponse = PtyShellsResponses[keyof PtyShellsResponses]

export type PtyListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty"
}

export type PtyListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type PtyListError = PtyListErrors[keyof PtyListErrors]

export type PtyListResponses = {
  /**
   * List of sessions
   */
  200: Array<Pty>
}

export type PtyListResponse = PtyListResponses[keyof PtyListResponses]

export type PtyCreateData = {
  body?: {
    command?: string
    args?: Array<string>
    cwd?: string
    title?: string
    env?: {
      [key: string]: string
    }
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty"
}

export type PtyCreateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type PtyCreateError = PtyCreateErrors[keyof PtyCreateErrors]

export type PtyCreateResponses = {
  /**
   * Created session
   */
  200: Pty
}

export type PtyCreateResponse = PtyCreateResponses[keyof PtyCreateResponses]

export type PtyRemoveData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty/{ptyID}"
}

export type PtyRemoveErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type PtyRemoveError = PtyRemoveErrors[keyof PtyRemoveErrors]

export type PtyRemoveResponses = {
  /**
   * Session removed
   */
  200: boolean
}

export type PtyRemoveResponse = PtyRemoveResponses[keyof PtyRemoveResponses]

export type PtyGetData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty/{ptyID}"
}

export type PtyGetErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type PtyGetError = PtyGetErrors[keyof PtyGetErrors]

export type PtyGetResponses = {
  /**
   * Session info
   */
  200: Pty
}

export type PtyGetResponse = PtyGetResponses[keyof PtyGetResponses]

export type PtyUpdateData = {
  body?: {
    title?: string
    size?: {
      rows: number
      cols: number
    }
  }
  path: {
    ptyID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty/{ptyID}"
}

export type PtyUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type PtyUpdateError = PtyUpdateErrors[keyof PtyUpdateErrors]

export type PtyUpdateResponses = {
  /**
   * Updated session
   */
  200: Pty
}

export type PtyUpdateResponse = PtyUpdateResponses[keyof PtyUpdateResponses]

export type PtyConnectTokenData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/pty/{ptyID}/connect-token"
}

export type PtyConnectTokenErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * PtyForbiddenError
   */
  403: PtyForbiddenError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type PtyConnectTokenError = PtyConnectTokenErrors[keyof PtyConnectTokenErrors]

export type PtyConnectTokenResponses = {
  /**
   * WebSocket connect token
   */
  200: PtyTicketConnectToken
}

export type PtyConnectTokenResponse = PtyConnectTokenResponses[keyof PtyConnectTokenResponses]

export type QuestionListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/question"
}

export type QuestionListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type QuestionListError = QuestionListErrors[keyof QuestionListErrors]

export type QuestionListResponses = {
  /**
   * List of pending questions
   */
  200: Array<QuestionRequest>
}

export type QuestionListResponse = QuestionListResponses[keyof QuestionListResponses]

export type QuestionReplyData = {
  body?: {
    /**
     * User answers in order of questions (each answer is an array of selected labels)
     */
    answers: Array<QuestionAnswer>
  }
  path: {
    requestID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/question/{requestID}/reply"
}

export type QuestionReplyErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * QuestionNotFoundError
   */
  404: QuestionNotFoundError
}

export type QuestionReplyError = QuestionReplyErrors[keyof QuestionReplyErrors]

export type QuestionReplyResponses = {
  /**
   * Question answered successfully
   */
  200: boolean
}

export type QuestionReplyResponse = QuestionReplyResponses[keyof QuestionReplyResponses]

export type QuestionRejectData = {
  body?: never
  path: {
    requestID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/question/{requestID}/reject"
}

export type QuestionRejectErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * QuestionNotFoundError
   */
  404: QuestionNotFoundError
}

export type QuestionRejectError = QuestionRejectErrors[keyof QuestionRejectErrors]

export type QuestionRejectResponses = {
  /**
   * Question rejected successfully
   */
  200: boolean
}

export type QuestionRejectResponse = QuestionRejectResponses[keyof QuestionRejectResponses]

export type PermissionListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/permission"
}

export type PermissionListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type PermissionListError = PermissionListErrors[keyof PermissionListErrors]

export type PermissionListResponses = {
  /**
   * List of pending permissions
   */
  200: Array<PermissionRequest>
}

export type PermissionListResponse = PermissionListResponses[keyof PermissionListResponses]

export type PermissionReplyData = {
  body?: {
    reply: "once" | "always" | "reject"
    message?: string
  }
  path: {
    requestID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/permission/{requestID}/reply"
}

export type PermissionReplyErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * PermissionNotFoundError
   */
  404: PermissionNotFoundError
}

export type PermissionReplyError = PermissionReplyErrors[keyof PermissionReplyErrors]

export type PermissionReplyResponses = {
  /**
   * Permission processed successfully
   */
  200: boolean
}

export type PermissionReplyResponse = PermissionReplyResponses[keyof PermissionReplyResponses]

export type ProviderListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/provider"
}

export type ProviderListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProviderListError = ProviderListErrors[keyof ProviderListErrors]

export type ProviderListResponses = {
  /**
   * List of providers
   */
  200: {
    all: Array<Provider>
    default: {
      [key: string]: string
    }
    connected: Array<string>
  }
}

export type ProviderListResponse = ProviderListResponses[keyof ProviderListResponses]

export type ProviderAuthData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/provider/auth"
}

export type ProviderAuthErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ProviderAuthError2 = ProviderAuthErrors[keyof ProviderAuthErrors]

export type ProviderAuthResponses = {
  /**
   * Provider auth methods
   */
  200: {
    [key: string]: Array<ProviderAuthMethod>
  }
}

export type ProviderAuthResponse = ProviderAuthResponses[keyof ProviderAuthResponses]

export type ProviderOauthAuthorizeData = {
  body?: {
    /**
     * Auth method index
     */
    method: number
    inputs?: {
      [key: string]: string
    }
  }
  path: {
    providerID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/provider/{providerID}/oauth/authorize"
}

export type ProviderOauthAuthorizeErrors = {
  /**
   * ProviderAuthError | InvalidRequestError
   */
  400: ProviderAuthError1 | InvalidRequestError
}

export type ProviderOauthAuthorizeError = ProviderOauthAuthorizeErrors[keyof ProviderOauthAuthorizeErrors]

export type ProviderOauthAuthorizeResponses = {
  /**
   * Authorization URL and method
   */
  200: ProviderAuthAuthorization
}

export type ProviderOauthAuthorizeResponse = ProviderOauthAuthorizeResponses[keyof ProviderOauthAuthorizeResponses]

export type ProviderOauthCallbackData = {
  body?: {
    /**
     * Auth method index
     */
    method: number
    code?: string
  }
  path: {
    providerID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/provider/{providerID}/oauth/callback"
}

export type ProviderOauthCallbackErrors = {
  /**
   * ProviderAuthError | InvalidRequestError
   */
  400: ProviderAuthError1 | InvalidRequestError
}

export type ProviderOauthCallbackError = ProviderOauthCallbackErrors[keyof ProviderOauthCallbackErrors]

export type ProviderOauthCallbackResponses = {
  /**
   * OAuth callback processed successfully
   */
  200: boolean
}

export type ProviderOauthCallbackResponse = ProviderOauthCallbackResponses[keyof ProviderOauthCallbackResponses]

export type SessionListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
    scope?: "project"
    path?: string
    roots?: boolean | "true" | "false"
    start?: number
    search?: string
    limit?: number
  }
  url: "/session"
}

export type SessionListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type SessionListError = SessionListErrors[keyof SessionListErrors]

export type SessionListResponses = {
  /**
   * List of sessions
   */
  200: Array<Session>
}

export type SessionListResponse = SessionListResponses[keyof SessionListResponses]

export type SessionCreateData = {
  body?: {
    parentID?: string
    title?: string
    agent?: string
    model?: {
      id: string
      providerID: string
      variant?: string
    }
    metadata?: {
      [key: string]: unknown
    }
    permission?: PermissionRuleset
    workspaceID?: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session"
}

export type SessionCreateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SessionCreateError = SessionCreateErrors[keyof SessionCreateErrors]

export type SessionCreateResponses = {
  /**
   * Successfully created session
   */
  200: Session
}

export type SessionCreateResponse = SessionCreateResponses[keyof SessionCreateResponses]

export type SessionStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/status"
}

export type SessionStatusErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SessionStatusError = SessionStatusErrors[keyof SessionStatusErrors]

export type SessionStatusResponses = {
  /**
   * Get session status
   */
  200: {
    [key: string]: SessionStatus
  }
}

export type SessionStatusResponse = SessionStatusResponses[keyof SessionStatusResponses]

export type SessionDeleteData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}"
}

export type SessionDeleteErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionDeleteError = SessionDeleteErrors[keyof SessionDeleteErrors]

export type SessionDeleteResponses = {
  /**
   * Successfully deleted session
   */
  200: boolean
}

export type SessionDeleteResponse = SessionDeleteResponses[keyof SessionDeleteResponses]

export type SessionGetData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}"
}

export type SessionGetErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionGetError = SessionGetErrors[keyof SessionGetErrors]

export type SessionGetResponses = {
  /**
   * Get session
   */
  200: Session
}

export type SessionGetResponse = SessionGetResponses[keyof SessionGetResponses]

export type SessionUpdateData = {
  body?: {
    title?: string
    metadata?: {
      [key: string]: unknown
    }
    permission?: PermissionRuleset
    time?: {
      archived?: number
    }
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}"
}

export type SessionUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionUpdateError = SessionUpdateErrors[keyof SessionUpdateErrors]

export type SessionUpdateResponses = {
  /**
   * Successfully updated session
   */
  200: Session
}

export type SessionUpdateResponse = SessionUpdateResponses[keyof SessionUpdateResponses]

export type SessionChildrenData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/children"
}

export type SessionChildrenErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionChildrenError = SessionChildrenErrors[keyof SessionChildrenErrors]

export type SessionChildrenResponses = {
  /**
   * List of children
   */
  200: Array<Session>
}

export type SessionChildrenResponse = SessionChildrenResponses[keyof SessionChildrenResponses]

export type SessionTodoData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/todo"
}

export type SessionTodoErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionTodoError = SessionTodoErrors[keyof SessionTodoErrors]

export type SessionTodoResponses = {
  /**
   * Todo list
   */
  200: Array<Todo>
}

export type SessionTodoResponse = SessionTodoResponses[keyof SessionTodoResponses]

export type SessionDiffData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
    messageID?: string
  }
  url: "/session/{sessionID}/diff"
}

export type SessionDiffErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type SessionDiffError = SessionDiffErrors[keyof SessionDiffErrors]

export type SessionDiffResponses = {
  /**
   * Successfully retrieved diff
   */
  200: Array<SnapshotFileDiff>
}

export type SessionDiffResponse = SessionDiffResponses[keyof SessionDiffResponses]

export type SessionMessagesData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
    limit?: number
    before?: string
  }
  url: "/session/{sessionID}/message"
}

export type SessionMessagesErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionMessagesError = SessionMessagesErrors[keyof SessionMessagesErrors]

export type SessionMessagesResponses = {
  /**
   * List of messages
   */
  200: Array<{
    info: Message
    parts: Array<Part>
  }>
}

export type SessionMessagesResponse2 = SessionMessagesResponses[keyof SessionMessagesResponses]

export type SessionPromptData = {
  body?: {
    messageID?: string
    model?: {
      providerID: string
      modelID: string
    }
    agent?: string
    noReply?: boolean
    tools?: {
      [key: string]: boolean
    }
    format?: OutputFormat
    system?: string
    variant?: string
    parts: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput>
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/message"
}

export type SessionPromptErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionPromptError = SessionPromptErrors[keyof SessionPromptErrors]

export type SessionPromptResponses = {
  /**
   * Created message
   */
  200: {
    info: AssistantMessage
    parts: Array<Part>
  }
}

export type SessionPromptResponse = SessionPromptResponses[keyof SessionPromptResponses]

export type SessionDeleteMessageData = {
  body?: never
  path: {
    sessionID: string
    messageID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/message/{messageID}"
}

export type SessionDeleteMessageErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
}

export type SessionDeleteMessageError = SessionDeleteMessageErrors[keyof SessionDeleteMessageErrors]

export type SessionDeleteMessageResponses = {
  /**
   * Successfully deleted message
   */
  200: boolean
}

export type SessionDeleteMessageResponse = SessionDeleteMessageResponses[keyof SessionDeleteMessageResponses]

export type SessionMessageData = {
  body?: never
  path: {
    sessionID: string
    messageID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/message/{messageID}"
}

export type SessionMessageErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionMessageError = SessionMessageErrors[keyof SessionMessageErrors]

export type SessionMessageResponses = {
  /**
   * Message
   */
  200: {
    info: Message
    parts: Array<Part>
  }
}

export type SessionMessageResponse = SessionMessageResponses[keyof SessionMessageResponses]

export type SessionForkData = {
  body?: {
    messageID?: string
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/fork"
}

export type SessionForkErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionForkError = SessionForkErrors[keyof SessionForkErrors]

export type SessionForkResponses = {
  /**
   * 200
   */
  200: Session
}

export type SessionForkResponse = SessionForkResponses[keyof SessionForkResponses]

export type SessionAbortData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/abort"
}

export type SessionAbortErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SessionAbortError = SessionAbortErrors[keyof SessionAbortErrors]

export type SessionAbortResponses = {
  /**
   * Aborted session
   */
  200: boolean
}

export type SessionAbortResponse = SessionAbortResponses[keyof SessionAbortResponses]

export type SessionInitData = {
  body?: {
    modelID: string
    providerID: string
    messageID: string
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/init"
}

export type SessionInitErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionInitError = SessionInitErrors[keyof SessionInitErrors]

export type SessionInitResponses = {
  /**
   * 200
   */
  200: boolean
}

export type SessionInitResponse = SessionInitResponses[keyof SessionInitResponses]

export type SessionUnshareData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/share"
}

export type SessionUnshareErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * InternalServerError
   */
  500: EffectHttpApiErrorInternalServerError
}

export type SessionUnshareError = SessionUnshareErrors[keyof SessionUnshareErrors]

export type SessionUnshareResponses = {
  /**
   * Successfully unshared session
   */
  200: Session
}

export type SessionUnshareResponse = SessionUnshareResponses[keyof SessionUnshareResponses]

export type SessionShareData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/share"
}

export type SessionShareErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * InternalServerError
   */
  500: EffectHttpApiErrorInternalServerError
}

export type SessionShareError = SessionShareErrors[keyof SessionShareErrors]

export type SessionShareResponses = {
  /**
   * Successfully shared session
   */
  200: Session
}

export type SessionShareResponse = SessionShareResponses[keyof SessionShareResponses]

export type SessionSummarizeData = {
  body?: {
    providerID: string
    modelID: string
    auto?: boolean
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/summarize"
}

export type SessionSummarizeErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionSummarizeError = SessionSummarizeErrors[keyof SessionSummarizeErrors]

export type SessionSummarizeResponses = {
  /**
   * Summarized session
   */
  200: boolean
}

export type SessionSummarizeResponse = SessionSummarizeResponses[keyof SessionSummarizeResponses]

export type SessionPromptAsyncData = {
  body?: {
    messageID?: string
    model?: {
      providerID: string
      modelID: string
    }
    agent?: string
    noReply?: boolean
    tools?: {
      [key: string]: boolean
    }
    format?: OutputFormat
    system?: string
    variant?: string
    parts: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput>
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/prompt_async"
}

export type SessionPromptAsyncErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionPromptAsyncError = SessionPromptAsyncErrors[keyof SessionPromptAsyncErrors]

export type SessionPromptAsyncResponses = {
  /**
   * Prompt accepted
   */
  204: void
}

export type SessionPromptAsyncResponse = SessionPromptAsyncResponses[keyof SessionPromptAsyncResponses]

export type SessionCommandData = {
  body?: {
    messageID?: string
    agent?: string
    model?: string
    arguments: string
    command: string
    variant?: string
    parts?: Array<{
      id?: string
      type: "file"
      mime: string
      filename?: string
      url: string
      source?: FilePartSource
    }>
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/command"
}

export type SessionCommandErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type SessionCommandError = SessionCommandErrors[keyof SessionCommandErrors]

export type SessionCommandResponses = {
  /**
   * Created message
   */
  200: {
    info: AssistantMessage
    parts: Array<Part>
  }
}

export type SessionCommandResponse = SessionCommandResponses[keyof SessionCommandResponses]

export type SessionShellData = {
  body?: {
    messageID?: string
    agent: string
    model?: {
      providerID: string
      modelID: string
    }
    command: string
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/shell"
}

export type SessionShellErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
}

export type SessionShellError = SessionShellErrors[keyof SessionShellErrors]

export type SessionShellResponses = {
  /**
   * Created message
   */
  200: {
    info: Message
    parts: Array<Part>
  }
}

export type SessionShellResponse = SessionShellResponses[keyof SessionShellResponses]

export type SessionRevertData = {
  body?: {
    messageID: string
    partID?: string
  }
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/revert"
}

export type SessionRevertErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
}

export type SessionRevertError = SessionRevertErrors[keyof SessionRevertErrors]

export type SessionRevertResponses = {
  /**
   * Updated session
   */
  200: Session
}

export type SessionRevertResponse = SessionRevertResponses[keyof SessionRevertResponses]

export type SessionUnrevertData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/unrevert"
}

export type SessionUnrevertErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
}

export type SessionUnrevertError = SessionUnrevertErrors[keyof SessionUnrevertErrors]

export type SessionUnrevertResponses = {
  /**
   * Updated session
   */
  200: Session
}

export type SessionUnrevertResponse = SessionUnrevertResponses[keyof SessionUnrevertResponses]

export type PermissionRespondData = {
  body?: {
    response: "once" | "always" | "reject"
  }
  path: {
    sessionID: string
    permissionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/permissions/{permissionID}"
}

export type PermissionRespondErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError | PermissionNotFoundError
   */
  404: NotFoundError | PermissionNotFoundError
}

export type PermissionRespondError = PermissionRespondErrors[keyof PermissionRespondErrors]

export type PermissionRespondResponses = {
  /**
   * Permission processed successfully
   */
  200: boolean
}

export type PermissionRespondResponse = PermissionRespondResponses[keyof PermissionRespondResponses]

export type PartDeleteData = {
  body?: never
  path: {
    sessionID: string
    messageID: string
    partID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/message/{messageID}/part/{partID}"
}

export type PartDeleteErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type PartDeleteError = PartDeleteErrors[keyof PartDeleteErrors]

export type PartDeleteResponses = {
  /**
   * Successfully deleted part
   */
  200: boolean
}

export type PartDeleteResponse = PartDeleteResponses[keyof PartDeleteResponses]

export type PartUpdateData = {
  body?: Part
  path: {
    sessionID: string
    messageID: string
    partID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/session/{sessionID}/message/{messageID}/part/{partID}"
}

export type PartUpdateErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type PartUpdateError = PartUpdateErrors[keyof PartUpdateErrors]

export type PartUpdateResponses = {
  /**
   * Successfully updated part
   */
  200: Part
}

export type PartUpdateResponse = PartUpdateResponses[keyof PartUpdateResponses]

export type SyncStartData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/sync/start"
}

export type SyncStartErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type SyncStartError = SyncStartErrors[keyof SyncStartErrors]

export type SyncStartResponses = {
  /**
   * Workspace sync started
   */
  200: boolean
}

export type SyncStartResponse = SyncStartResponses[keyof SyncStartResponses]

export type SyncReplayData = {
  body?: {
    directory: string
    events: Array<{
      id: string
      aggregateID: string
      seq: number
      type: string
      data: {
        [key: string]: unknown
      }
    }>
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/sync/replay"
}

export type SyncReplayErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SyncReplayError = SyncReplayErrors[keyof SyncReplayErrors]

export type SyncReplayResponses = {
  /**
   * Replayed sync events
   */
  200: {
    sessionID: string
  }
}

export type SyncReplayResponse = SyncReplayResponses[keyof SyncReplayResponses]

export type SyncStealData = {
  body?: {
    sessionID: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/sync/steal"
}

export type SyncStealErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SyncStealError = SyncStealErrors[keyof SyncStealErrors]

export type SyncStealResponses = {
  /**
   * Session stolen into workspace
   */
  200: {
    sessionID: string
  }
}

export type SyncStealResponse = SyncStealResponses[keyof SyncStealResponses]

export type SyncHistoryListData = {
  body?: {
    [key: string]: number
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/sync/history"
}

export type SyncHistoryListErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type SyncHistoryListError = SyncHistoryListErrors[keyof SyncHistoryListErrors]

export type SyncHistoryListResponses = {
  /**
   * Sync events
   */
  200: Array<{
    id: string
    aggregate_id: string
    seq: number
    type: string
    data: {
      [key: string]: unknown
    }
  }>
}

export type SyncHistoryListResponse = SyncHistoryListResponses[keyof SyncHistoryListResponses]

export type TuiAppendPromptData = {
  body?: {
    text: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/append-prompt"
}

export type TuiAppendPromptErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type TuiAppendPromptError = TuiAppendPromptErrors[keyof TuiAppendPromptErrors]

export type TuiAppendPromptResponses = {
  /**
   * Prompt processed successfully
   */
  200: boolean
}

export type TuiAppendPromptResponse = TuiAppendPromptResponses[keyof TuiAppendPromptResponses]

export type TuiOpenHelpData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/open-help"
}

export type TuiOpenHelpErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiOpenHelpError = TuiOpenHelpErrors[keyof TuiOpenHelpErrors]

export type TuiOpenHelpResponses = {
  /**
   * Help dialog opened successfully
   */
  200: boolean
}

export type TuiOpenHelpResponse = TuiOpenHelpResponses[keyof TuiOpenHelpResponses]

export type TuiOpenSessionsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/open-sessions"
}

export type TuiOpenSessionsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiOpenSessionsError = TuiOpenSessionsErrors[keyof TuiOpenSessionsErrors]

export type TuiOpenSessionsResponses = {
  /**
   * Session dialog opened successfully
   */
  200: boolean
}

export type TuiOpenSessionsResponse = TuiOpenSessionsResponses[keyof TuiOpenSessionsResponses]

export type TuiOpenThemesData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/open-themes"
}

export type TuiOpenThemesErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiOpenThemesError = TuiOpenThemesErrors[keyof TuiOpenThemesErrors]

export type TuiOpenThemesResponses = {
  /**
   * Theme dialog opened successfully
   */
  200: boolean
}

export type TuiOpenThemesResponse = TuiOpenThemesResponses[keyof TuiOpenThemesResponses]

export type TuiOpenModelsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/open-models"
}

export type TuiOpenModelsErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiOpenModelsError = TuiOpenModelsErrors[keyof TuiOpenModelsErrors]

export type TuiOpenModelsResponses = {
  /**
   * Model dialog opened successfully
   */
  200: boolean
}

export type TuiOpenModelsResponse = TuiOpenModelsResponses[keyof TuiOpenModelsResponses]

export type TuiSubmitPromptData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/submit-prompt"
}

export type TuiSubmitPromptErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiSubmitPromptError = TuiSubmitPromptErrors[keyof TuiSubmitPromptErrors]

export type TuiSubmitPromptResponses = {
  /**
   * Prompt submitted successfully
   */
  200: boolean
}

export type TuiSubmitPromptResponse = TuiSubmitPromptResponses[keyof TuiSubmitPromptResponses]

export type TuiClearPromptData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/clear-prompt"
}

export type TuiClearPromptErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiClearPromptError = TuiClearPromptErrors[keyof TuiClearPromptErrors]

export type TuiClearPromptResponses = {
  /**
   * Prompt cleared successfully
   */
  200: boolean
}

export type TuiClearPromptResponse = TuiClearPromptResponses[keyof TuiClearPromptResponses]

export type TuiExecuteCommandData = {
  body?: {
    command: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/execute-command"
}

export type TuiExecuteCommandErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type TuiExecuteCommandError = TuiExecuteCommandErrors[keyof TuiExecuteCommandErrors]

export type TuiExecuteCommandResponses = {
  /**
   * Command executed successfully
   */
  200: boolean
}

export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses]

export type TuiShowToastData = {
  body?: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/show-toast"
}

export type TuiShowToastErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiShowToastError = TuiShowToastErrors[keyof TuiShowToastErrors]

export type TuiShowToastResponses = {
  /**
   * Toast notification shown successfully
   */
  200: boolean
}

export type TuiShowToastResponse = TuiShowToastResponses[keyof TuiShowToastResponses]

export type TuiPublishData = {
  body?: EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/publish"
}

export type TuiPublishErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type TuiPublishError = TuiPublishErrors[keyof TuiPublishErrors]

export type TuiPublishResponses = {
  /**
   * Event published successfully
   */
  200: boolean
}

export type TuiPublishResponse = TuiPublishResponses[keyof TuiPublishResponses]

export type TuiSelectSessionData = {
  body?: {
    /**
     * Session ID to navigate to
     */
    sessionID: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/select-session"
}

export type TuiSelectSessionErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type TuiSelectSessionError = TuiSelectSessionErrors[keyof TuiSelectSessionErrors]

export type TuiSelectSessionResponses = {
  /**
   * Session selected successfully
   */
  200: boolean
}

export type TuiSelectSessionResponse = TuiSelectSessionResponses[keyof TuiSelectSessionResponses]

export type TuiControlNextData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/control/next"
}

export type TuiControlNextErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiControlNextError = TuiControlNextErrors[keyof TuiControlNextErrors]

export type TuiControlNextResponses = {
  /**
   * Next TUI request
   */
  200: {
    path: string
    body: unknown
  }
}

export type TuiControlNextResponse = TuiControlNextResponses[keyof TuiControlNextResponses]

export type TuiControlResponseData = {
  body?: unknown
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/tui/control/response"
}

export type TuiControlResponseErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type TuiControlResponseError = TuiControlResponseErrors[keyof TuiControlResponseErrors]

export type TuiControlResponseResponses = {
  /**
   * Response submitted successfully
   */
  200: boolean
}

export type TuiControlResponseResponse = TuiControlResponseResponses[keyof TuiControlResponseResponses]

export type ExperimentalWorkspaceAdapterListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/adapter"
}

export type ExperimentalWorkspaceAdapterListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalWorkspaceAdapterListError =
  ExperimentalWorkspaceAdapterListErrors[keyof ExperimentalWorkspaceAdapterListErrors]

export type ExperimentalWorkspaceAdapterListResponses = {
  /**
   * Workspace adapters
   */
  200: Array<{
    type: string
    name: string
    description: string
  }>
}

export type ExperimentalWorkspaceAdapterListResponse =
  ExperimentalWorkspaceAdapterListResponses[keyof ExperimentalWorkspaceAdapterListResponses]

export type ExperimentalWorkspaceListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace"
}

export type ExperimentalWorkspaceListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalWorkspaceListError = ExperimentalWorkspaceListErrors[keyof ExperimentalWorkspaceListErrors]

export type ExperimentalWorkspaceListResponses = {
  /**
   * Workspaces
   */
  200: Array<Workspace>
}

export type ExperimentalWorkspaceListResponse =
  ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses]

export type ExperimentalWorkspaceCreateData = {
  body?: {
    id?: string
    type: string
    branch?: string | null
    extra?: unknown | null
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace"
}

export type ExperimentalWorkspaceCreateErrors = {
  /**
   * WorkspaceCreateError | BadRequest | InvalidRequestError
   */
  400: WorkspaceCreateError | EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ExperimentalWorkspaceCreateError =
  ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors]

export type ExperimentalWorkspaceCreateResponses = {
  /**
   * Workspace created
   */
  200: Workspace
}

export type ExperimentalWorkspaceCreateResponse =
  ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses]

export type ExperimentalWorkspaceSyncListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/sync-list"
}

export type ExperimentalWorkspaceSyncListErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalWorkspaceSyncListError =
  ExperimentalWorkspaceSyncListErrors[keyof ExperimentalWorkspaceSyncListErrors]

export type ExperimentalWorkspaceSyncListResponses = {
  /**
   * Workspace list synced
   */
  204: void
}

export type ExperimentalWorkspaceSyncListResponse =
  ExperimentalWorkspaceSyncListResponses[keyof ExperimentalWorkspaceSyncListResponses]

export type ExperimentalWorkspaceStatusData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/status"
}

export type ExperimentalWorkspaceStatusErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
}

export type ExperimentalWorkspaceStatusError =
  ExperimentalWorkspaceStatusErrors[keyof ExperimentalWorkspaceStatusErrors]

export type ExperimentalWorkspaceStatusResponses = {
  /**
   * Workspace status
   */
  200: Array<WorkspaceEventConnectionStatus>
}

export type ExperimentalWorkspaceStatusResponse =
  ExperimentalWorkspaceStatusResponses[keyof ExperimentalWorkspaceStatusResponses]

export type ExperimentalWorkspaceRemoveData = {
  body?: never
  path: {
    id: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/{id}"
}

export type ExperimentalWorkspaceRemoveErrors = {
  /**
   * BadRequest | InvalidRequestError
   */
  400: EffectHttpApiErrorBadRequest | InvalidRequestError
}

export type ExperimentalWorkspaceRemoveError =
  ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors]

export type ExperimentalWorkspaceRemoveResponses = {
  /**
   * Workspace removed
   */
  200: Workspace
}

export type ExperimentalWorkspaceRemoveResponse =
  ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses]

export type ExperimentalWorkspaceWarpData = {
  body?: {
    id: string | null
    sessionID: string
    copyChanges?: boolean
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/warp"
}

export type ExperimentalWorkspaceWarpErrors = {
  /**
   * WorkspaceWarpError | VcsApplyError | InvalidRequestError
   */
  400: WorkspaceWarpError | VcsApplyError | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type ExperimentalWorkspaceWarpError = ExperimentalWorkspaceWarpErrors[keyof ExperimentalWorkspaceWarpErrors]

export type ExperimentalWorkspaceWarpResponses = {
  /**
   * Session warped
   */
  204: void
}

export type ExperimentalWorkspaceWarpResponse =
  ExperimentalWorkspaceWarpResponses[keyof ExperimentalWorkspaceWarpResponses]

export type V2HealthGetData = {
  body?: never
  path?: never
  query?: never
  url: "/api/health"
}

export type V2HealthGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2HealthGetError = V2HealthGetErrors[keyof V2HealthGetErrors]

export type V2HealthGetResponses = {
  /**
   * Success
   */
  200: {
    healthy: true
  }
}

export type V2HealthGetResponse = V2HealthGetResponses[keyof V2HealthGetResponses]

export type V2LocationGetData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/location"
}

export type V2LocationGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2LocationGetError = V2LocationGetErrors[keyof V2LocationGetErrors]

export type V2LocationGetResponses = {
  /**
   * Location.Info
   */
  200: LocationInfo
}

export type V2LocationGetResponse = V2LocationGetResponses[keyof V2LocationGetResponses]

export type V2AgentListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/agent"
}

export type V2AgentListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2AgentListError = V2AgentListErrors[keyof V2AgentListErrors]

export type V2AgentListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<AgentV2Info>
  }
}

export type V2AgentListResponse = V2AgentListResponses[keyof V2AgentListResponses]

export type V2SessionListData = {
  body?: never
  path?: never
  query?: {
    workspace?: string
    limit?: number
    order?: "asc" | "desc"
    search?: string
    directory?: string
    project?: string
    subpath?: string
    /**
     * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.
     */
    cursor?: string
  }
  url: "/api/session"
}

export type V2SessionListErrors = {
  /**
   * InvalidCursorError | InvalidRequestError
   */
  400: InvalidCursorError | InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SessionListError = V2SessionListErrors[keyof V2SessionListErrors]

export type V2SessionListResponses = {
  /**
   * SessionsResponse
   */
  200: SessionsResponse
}

export type V2SessionListResponse = V2SessionListResponses[keyof V2SessionListResponses]

export type V2SessionCreateData = {
  body: {
    id?: string
    agent?: string
    model?: ModelRef
    location?: LocationRef
  }
  path?: never
  query?: never
  url: "/api/session"
}

export type V2SessionCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SessionCreateError = V2SessionCreateErrors[keyof V2SessionCreateErrors]

export type V2SessionCreateResponses = {
  /**
   * Success
   */
  200: {
    data: SessionV2Info
  }
}

export type V2SessionCreateResponse = V2SessionCreateResponses[keyof V2SessionCreateResponses]

export type V2SessionActiveData = {
  body?: never
  path?: never
  query?: never
  url: "/api/session/active"
}

export type V2SessionActiveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SessionActiveError = V2SessionActiveErrors[keyof V2SessionActiveErrors]

export type V2SessionActiveResponses = {
  /**
   * Success
   */
  200: {
    data: {
      [key: string]: unknown | SessionActive
    }
  }
}

export type V2SessionActiveResponse = V2SessionActiveResponses[keyof V2SessionActiveResponses]

export type V2SessionGetData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}"
}

export type V2SessionGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionGetError = V2SessionGetErrors[keyof V2SessionGetErrors]

export type V2SessionGetResponses = {
  /**
   * Success
   */
  200: {
    data: SessionV2Info
  }
}

export type V2SessionGetResponse = V2SessionGetResponses[keyof V2SessionGetResponses]

export type V2SessionSwitchAgentData = {
  body: {
    agent: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/agent"
}

export type V2SessionSwitchAgentErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionSwitchAgentError = V2SessionSwitchAgentErrors[keyof V2SessionSwitchAgentErrors]

export type V2SessionSwitchAgentResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionSwitchAgentResponse = V2SessionSwitchAgentResponses[keyof V2SessionSwitchAgentResponses]

export type V2SessionSwitchModelData = {
  body: {
    model: ModelRef
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/model"
}

export type V2SessionSwitchModelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionSwitchModelError = V2SessionSwitchModelErrors[keyof V2SessionSwitchModelErrors]

export type V2SessionSwitchModelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionSwitchModelResponse = V2SessionSwitchModelResponses[keyof V2SessionSwitchModelResponses]

export type V2SessionPromptData = {
  body: {
    id?: string
    prompt: PromptInput
    delivery?: "steer" | "queue"
    resume?: boolean
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/prompt"
}

export type V2SessionPromptErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictError
}

export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]

export type V2SessionPromptResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInputAdmitted
  }
}

export type V2SessionPromptResponse = V2SessionPromptResponses[keyof V2SessionPromptResponses]

export type V2SessionCompactData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/compact"
}

export type V2SessionCompactErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]

export type V2SessionCompactResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionCompactResponse = V2SessionCompactResponses[keyof V2SessionCompactResponses]

export type V2SessionWaitData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/wait"
}

export type V2SessionWaitErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2SessionWaitError = V2SessionWaitErrors[keyof V2SessionWaitErrors]

export type V2SessionWaitResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionWaitResponse = V2SessionWaitResponses[keyof V2SessionWaitResponses]

export type V2SessionRevertStageData = {
  body: {
    messageID: string
    files?: boolean
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/revert/stage"
}

export type V2SessionRevertStageErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * MessageNotFoundError | SessionNotFoundError
   */
  404: MessageNotFoundError | SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError1
}

export type V2SessionRevertStageError = V2SessionRevertStageErrors[keyof V2SessionRevertStageErrors]

export type V2SessionRevertStageResponses = {
  /**
   * Success
   */
  200: {
    data: RevertState
  }
}

export type V2SessionRevertStageResponse = V2SessionRevertStageResponses[keyof V2SessionRevertStageResponses]

export type V2SessionRevertClearData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/revert/clear"
}

export type V2SessionRevertClearErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError1
}

export type V2SessionRevertClearError = V2SessionRevertClearErrors[keyof V2SessionRevertClearErrors]

export type V2SessionRevertClearResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionRevertClearResponse = V2SessionRevertClearResponses[keyof V2SessionRevertClearResponses]

export type V2SessionRevertCommitData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/revert/commit"
}

export type V2SessionRevertCommitErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionRevertCommitError = V2SessionRevertCommitErrors[keyof V2SessionRevertCommitErrors]

export type V2SessionRevertCommitResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionRevertCommitResponse = V2SessionRevertCommitResponses[keyof V2SessionRevertCommitResponses]

export type V2SessionContextData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/context"
}

export type V2SessionContextErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError1
}

export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]

export type V2SessionContextResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionMessage>
  }
}

export type V2SessionContextResponse = V2SessionContextResponses[keyof V2SessionContextResponses]

export type V2SessionHistoryData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    limit?: number
    after?: number
  }
  url: "/api/session/{sessionID}/history"
}

export type V2SessionHistoryErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionHistoryError = V2SessionHistoryErrors[keyof V2SessionHistoryErrors]

export type V2SessionHistoryResponses = {
  /**
   * SessionHistory
   */
  200: SessionHistory
}

export type V2SessionHistoryResponse = V2SessionHistoryResponses[keyof V2SessionHistoryResponses]

export type V2SessionEventsData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    after?: string
  }
  url: "/api/session/{sessionID}/event"
}

export type V2SessionEventsErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionEventsError = V2SessionEventsErrors[keyof V2SessionEventsErrors]

export type V2SessionEventsResponses = {
  /**
   * Success
   */
  200: {
    id: string
    event: string
    data: SessionDurableEventStream
  }
}

export type V2SessionEventsResponse = V2SessionEventsResponses[keyof V2SessionEventsResponses]

export type V2SessionInterruptData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/interrupt"
}

export type V2SessionInterruptErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionInterruptError = V2SessionInterruptErrors[keyof V2SessionInterruptErrors]

export type V2SessionInterruptResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionInterruptResponse = V2SessionInterruptResponses[keyof V2SessionInterruptResponses]

export type V2SessionMessageData = {
  body?: never
  path: {
    sessionID: string
    messageID: string
  }
  query?: never
  url: "/api/session/{sessionID}/message/{messageID}"
}

export type V2SessionMessageErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | MessageNotFoundError
   */
  404: MessageNotFoundError | SessionNotFoundError
}

export type V2SessionMessageError = V2SessionMessageErrors[keyof V2SessionMessageErrors]

export type V2SessionMessageResponses = {
  /**
   * Success
   */
  200: {
    data: SessionMessage
  }
}

export type V2SessionMessageResponse = V2SessionMessageResponses[keyof V2SessionMessageResponses]

export type V2SessionMessagesData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    limit?: number
    order?: "asc" | "desc"
    /**
     * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.
     */
    cursor?: string
  }
  url: "/api/session/{sessionID}/message"
}

export type V2SessionMessagesErrors = {
  /**
   * InvalidCursorError | InvalidRequestError
   */
  400: InvalidCursorError | InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError1
}

export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]

export type V2SessionMessagesResponses = {
  /**
   * SessionMessagesResponse
   */
  200: SessionMessagesResponse
}

export type V2SessionMessagesResponse = V2SessionMessagesResponses[keyof V2SessionMessagesResponses]

export type V2ModelListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/model"
}

export type V2ModelListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]

export type V2ModelListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<ModelV2Info>
  }
}

export type V2ModelListResponse = V2ModelListResponses[keyof V2ModelListResponses]

export type V2ProviderListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/provider"
}

export type V2ProviderListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]

export type V2ProviderListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<ProviderV2Info>
  }
}

export type V2ProviderListResponse = V2ProviderListResponses[keyof V2ProviderListResponses]

export type V2ProviderGetData = {
  body?: never
  path: {
    providerID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/provider/{providerID}"
}

export type V2ProviderGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ProviderNotFoundError
   */
  404: ProviderNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]

export type V2ProviderGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: ProviderV2Info
  }
}

export type V2ProviderGetResponse = V2ProviderGetResponses[keyof V2ProviderGetResponses]

export type V2IntegrationListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration"
}

export type V2IntegrationListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationListError = V2IntegrationListErrors[keyof V2IntegrationListErrors]

export type V2IntegrationListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<IntegrationInfo>
  }
}

export type V2IntegrationListResponse = V2IntegrationListResponses[keyof V2IntegrationListResponses]

export type V2IntegrationGetData = {
  body?: never
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/{integrationID}"
}

export type V2IntegrationGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationGetError = V2IntegrationGetErrors[keyof V2IntegrationGetErrors]

export type V2IntegrationGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationInfo
  }
}

export type V2IntegrationGetResponse = V2IntegrationGetResponses[keyof V2IntegrationGetResponses]

export type V2IntegrationConnectKeyData = {
  body: {
    key: string
    label?: string
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/{integrationID}/connect/key"
}

export type V2IntegrationConnectKeyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationConnectKeyError = V2IntegrationConnectKeyErrors[keyof V2IntegrationConnectKeyErrors]

export type V2IntegrationConnectKeyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationConnectKeyResponse = V2IntegrationConnectKeyResponses[keyof V2IntegrationConnectKeyResponses]

export type V2IntegrationConnectOauthData = {
  body: {
    methodID: string
    inputs: {
      [key: string]: string
    }
    label?: string
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/{integrationID}/connect/oauth"
}

export type V2IntegrationConnectOauthErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationConnectOauthError = V2IntegrationConnectOauthErrors[keyof V2IntegrationConnectOauthErrors]

export type V2IntegrationConnectOauthResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationAttempt
  }
}

export type V2IntegrationConnectOauthResponse =
  V2IntegrationConnectOauthResponses[keyof V2IntegrationConnectOauthResponses]

export type V2IntegrationAttemptCancelData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}"
}

export type V2IntegrationAttemptCancelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationAttemptCancelError = V2IntegrationAttemptCancelErrors[keyof V2IntegrationAttemptCancelErrors]

export type V2IntegrationAttemptCancelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationAttemptCancelResponse =
  V2IntegrationAttemptCancelResponses[keyof V2IntegrationAttemptCancelResponses]

export type V2IntegrationAttemptStatusData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}"
}

export type V2IntegrationAttemptStatusErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationAttemptStatusError = V2IntegrationAttemptStatusErrors[keyof V2IntegrationAttemptStatusErrors]

export type V2IntegrationAttemptStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationAttemptStatus
  }
}

export type V2IntegrationAttemptStatusResponse =
  V2IntegrationAttemptStatusResponses[keyof V2IntegrationAttemptStatusResponses]

export type V2IntegrationAttemptCompleteData = {
  body: {
    code?: string
  }
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}/complete"
}

export type V2IntegrationAttemptCompleteErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationAttemptCompleteError =
  V2IntegrationAttemptCompleteErrors[keyof V2IntegrationAttemptCompleteErrors]

export type V2IntegrationAttemptCompleteResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationAttemptCompleteResponse =
  V2IntegrationAttemptCompleteResponses[keyof V2IntegrationAttemptCompleteResponses]

export type V2CredentialRemoveData = {
  body?: never
  path: {
    credentialID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/credential/{credentialID}"
}

export type V2CredentialRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2CredentialRemoveError = V2CredentialRemoveErrors[keyof V2CredentialRemoveErrors]

export type V2CredentialRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2CredentialRemoveResponse = V2CredentialRemoveResponses[keyof V2CredentialRemoveResponses]

export type V2CredentialUpdateData = {
  body: {
    label: string
  }
  path: {
    credentialID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/credential/{credentialID}"
}

export type V2CredentialUpdateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2CredentialUpdateError = V2CredentialUpdateErrors[keyof V2CredentialUpdateErrors]

export type V2CredentialUpdateResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2CredentialUpdateResponse = V2CredentialUpdateResponses[keyof V2CredentialUpdateResponses]

export type V2PermissionRequestListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/permission/request"
}

export type V2PermissionRequestListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PermissionRequestListError = V2PermissionRequestListErrors[keyof V2PermissionRequestListErrors]

export type V2PermissionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<PermissionV2Request>
  }
}

export type V2PermissionRequestListResponse = V2PermissionRequestListResponses[keyof V2PermissionRequestListResponses]

export type V2PermissionSavedListData = {
  body?: never
  path?: never
  query?: {
    projectID?: string
  }
  url: "/api/permission/saved"
}

export type V2PermissionSavedListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PermissionSavedListError = V2PermissionSavedListErrors[keyof V2PermissionSavedListErrors]

export type V2PermissionSavedListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionSavedInfo>
  }
}

export type V2PermissionSavedListResponse = V2PermissionSavedListResponses[keyof V2PermissionSavedListResponses]

export type V2PermissionSavedRemoveData = {
  body?: never
  path: {
    id: string
  }
  query?: never
  url: "/api/permission/saved/{id}"
}

export type V2PermissionSavedRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PermissionSavedRemoveError = V2PermissionSavedRemoveErrors[keyof V2PermissionSavedRemoveErrors]

export type V2PermissionSavedRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2PermissionSavedRemoveResponse = V2PermissionSavedRemoveResponses[keyof V2PermissionSavedRemoveResponses]

export type V2SessionPermissionListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission"
}

export type V2SessionPermissionListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionPermissionListError = V2SessionPermissionListErrors[keyof V2SessionPermissionListErrors]

export type V2SessionPermissionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionV2Request>
  }
}

export type V2SessionPermissionListResponse = V2SessionPermissionListResponses[keyof V2SessionPermissionListResponses]

export type V2SessionPermissionCreateData = {
  body: {
    id?: string
    action: string
    resources: Array<string>
    save?: Array<string>
    metadata?: {
      [key: string]: unknown
    }
    source?: PermissionV2Source
    agent?: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission"
}

export type V2SessionPermissionCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionPermissionCreateError = V2SessionPermissionCreateErrors[keyof V2SessionPermissionCreateErrors]

export type V2SessionPermissionCreateResponses = {
  /**
   * Success
   */
  200: {
    data: {
      id: string
      effect: PermissionV2Effect
    }
  }
}

export type V2SessionPermissionCreateResponse =
  V2SessionPermissionCreateResponses[keyof V2SessionPermissionCreateResponses]

export type V2SessionPermissionGetData = {
  body?: never
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission/{requestID}"
}

export type V2SessionPermissionGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundError | SessionNotFoundError
}

export type V2SessionPermissionGetError = V2SessionPermissionGetErrors[keyof V2SessionPermissionGetErrors]

export type V2SessionPermissionGetResponses = {
  /**
   * Success
   */
  200: {
    data: PermissionV2Request
  }
}

export type V2SessionPermissionGetResponse = V2SessionPermissionGetResponses[keyof V2SessionPermissionGetResponses]

export type V2SessionPermissionReplyData = {
  body: {
    reply: PermissionV2Reply
    message?: string
  }
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission/{requestID}/reply"
}

export type V2SessionPermissionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundError | SessionNotFoundError
}

export type V2SessionPermissionReplyError = V2SessionPermissionReplyErrors[keyof V2SessionPermissionReplyErrors]

export type V2SessionPermissionReplyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionPermissionReplyResponse =
  V2SessionPermissionReplyResponses[keyof V2SessionPermissionReplyResponses]

export type V2FsReadData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/fs/read/*"
}

export type V2FsReadErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FsReadError = V2FsReadErrors[keyof V2FsReadErrors]

export type V2FsReadResponses = {
  /**
   * Success
   */
  200: Blob | File
}

export type V2FsReadResponse = V2FsReadResponses[keyof V2FsReadResponses]

export type V2FsListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
    path?: string
  }
  url: "/api/fs/list"
}

export type V2FsListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FsListError = V2FsListErrors[keyof V2FsListErrors]

export type V2FsListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<FileSystemEntry>
  }
}

export type V2FsListResponse = V2FsListResponses[keyof V2FsListResponses]

export type V2FsFindData = {
  body?: never
  path?: never
  query: {
    location?: {
      directory?: string
      workspace?: string
    }
    query: string
    type?: "file" | "directory"
    limit?: string
  }
  url: "/api/fs/find"
}

export type V2FsFindErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FsFindError = V2FsFindErrors[keyof V2FsFindErrors]

export type V2FsFindResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<FileSystemEntry>
  }
}

export type V2FsFindResponse = V2FsFindResponses[keyof V2FsFindResponses]

export type V2CommandListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/command"
}

export type V2CommandListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2CommandListError = V2CommandListErrors[keyof V2CommandListErrors]

export type V2CommandListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<CommandV2Info>
  }
}

export type V2CommandListResponse = V2CommandListResponses[keyof V2CommandListResponses]

export type V2SkillListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/skill"
}

export type V2SkillListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SkillListError = V2SkillListErrors[keyof V2SkillListErrors]

export type V2SkillListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<SkillV2Info>
  }
}

export type V2SkillListResponse = V2SkillListResponses[keyof V2SkillListResponses]

export type V2EventSubscribeData = {
  body?: never
  path?: never
  query?: never
  url: "/api/event"
}

export type V2EventSubscribeErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2EventSubscribeError = V2EventSubscribeErrors[keyof V2EventSubscribeErrors]

export type V2EventSubscribeResponses = {
  /**
   * Event stream
   */
  200: V2Event
}

export type V2EventSubscribeResponse = V2EventSubscribeResponses[keyof V2EventSubscribeResponses]

export type V2PtyListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty"
}

export type V2PtyListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PtyListError = V2PtyListErrors[keyof V2PtyListErrors]

export type V2PtyListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<Pty>
  }
}

export type V2PtyListResponse = V2PtyListResponses[keyof V2PtyListResponses]

export type V2PtyCreateData = {
  body: {
    command?: string
    args?: Array<string>
    cwd?: string
    title?: string
    env?: {
      [key: string]: string
    }
  }
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty"
}

export type V2PtyCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PtyCreateError = V2PtyCreateErrors[keyof V2PtyCreateErrors]

export type V2PtyCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyCreateResponse = V2PtyCreateResponses[keyof V2PtyCreateResponses]

export type V2PtyRemoveData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyRemoveError = V2PtyRemoveErrors[keyof V2PtyRemoveErrors]

export type V2PtyRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2PtyRemoveResponse = V2PtyRemoveResponses[keyof V2PtyRemoveResponses]

export type V2PtyGetData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyGetError = V2PtyGetErrors[keyof V2PtyGetErrors]

export type V2PtyGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyGetResponse = V2PtyGetResponses[keyof V2PtyGetResponses]

export type V2PtyUpdateData = {
  body: {
    title?: string
    size?: {
      rows: number
      cols: number
    }
  }
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyUpdateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyUpdateError = V2PtyUpdateErrors[keyof V2PtyUpdateErrors]

export type V2PtyUpdateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyUpdateResponse = V2PtyUpdateResponses[keyof V2PtyUpdateResponses]

export type V2PtyConnectTokenData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/pty/{ptyID}/connect-token"
}

export type V2PtyConnectTokenErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ForbiddenError
   */
  403: ForbiddenError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyConnectTokenError = V2PtyConnectTokenErrors[keyof V2PtyConnectTokenErrors]

export type V2PtyConnectTokenResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: PtyTicketConnectToken
  }
}

export type V2PtyConnectTokenResponse = V2PtyConnectTokenResponses[keyof V2PtyConnectTokenResponses]

export type V2PtyConnectData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    "location[directory]"?: string
    "location[workspace]"?: string
    cursor?: string
    ticket?: string
  }
  url: "/api/pty/{ptyID}/connect"
}

export type V2PtyConnectErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ForbiddenError
   */
  403: ForbiddenError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyConnectError = V2PtyConnectErrors[keyof V2PtyConnectErrors]

export type V2PtyConnectResponses = {
  /**
   * Success
   */
  200: boolean
}

export type V2PtyConnectResponse = V2PtyConnectResponses[keyof V2PtyConnectResponses]

export type V2QuestionRequestListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/question/request"
}

export type V2QuestionRequestListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2QuestionRequestListError = V2QuestionRequestListErrors[keyof V2QuestionRequestListErrors]

export type V2QuestionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<QuestionV2Request>
  }
}

export type V2QuestionRequestListResponse = V2QuestionRequestListResponses[keyof V2QuestionRequestListResponses]

export type V2SessionQuestionListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question"
}

export type V2SessionQuestionListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionQuestionListError = V2SessionQuestionListErrors[keyof V2SessionQuestionListErrors]

export type V2SessionQuestionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<QuestionV2Request>
  }
}

export type V2SessionQuestionListResponse = V2SessionQuestionListResponses[keyof V2SessionQuestionListResponses]

export type V2SessionQuestionReplyData = {
  body: QuestionV2Reply
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question/{requestID}/reply"
}

export type V2SessionQuestionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundError | SessionNotFoundError
}

export type V2SessionQuestionReplyError = V2SessionQuestionReplyErrors[keyof V2SessionQuestionReplyErrors]

export type V2SessionQuestionReplyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionQuestionReplyResponse = V2SessionQuestionReplyResponses[keyof V2SessionQuestionReplyResponses]

export type V2SessionQuestionRejectData = {
  body?: never
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question/{requestID}/reject"
}

export type V2SessionQuestionRejectErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundError | SessionNotFoundError
}

export type V2SessionQuestionRejectError = V2SessionQuestionRejectErrors[keyof V2SessionQuestionRejectErrors]

export type V2SessionQuestionRejectResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionQuestionRejectResponse = V2SessionQuestionRejectResponses[keyof V2SessionQuestionRejectResponses]

export type V2ReferenceListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/reference"
}

export type V2ReferenceListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ReferenceListError = V2ReferenceListErrors[keyof V2ReferenceListErrors]

export type V2ReferenceListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Array<ReferenceInfo>
  }
}

export type V2ReferenceListResponse = V2ReferenceListResponses[keyof V2ReferenceListResponses]

export type V2ProjectCopyRemoveData = {
  body?: {
    directory: string
    force: boolean
  }
  path: {
    projectID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/experimental/project/{projectID}/copy"
}

export type V2ProjectCopyRemoveErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyError | InvalidRequestError
}

export type V2ProjectCopyRemoveError = V2ProjectCopyRemoveErrors[keyof V2ProjectCopyRemoveErrors]

export type V2ProjectCopyRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2ProjectCopyRemoveResponse = V2ProjectCopyRemoveResponses[keyof V2ProjectCopyRemoveResponses]

export type V2ProjectCopyCreateData = {
  body?: {
    strategy: string
    directory: string
    name?: string
  }
  path: {
    projectID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/experimental/project/{projectID}/copy"
}

export type V2ProjectCopyCreateErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyError | InvalidRequestError
}

export type V2ProjectCopyCreateError = V2ProjectCopyCreateErrors[keyof V2ProjectCopyCreateErrors]

export type V2ProjectCopyCreateResponses = {
  /**
   * ProjectCopy.Copy
   */
  200: ProjectCopyCopy
}

export type V2ProjectCopyCreateResponse = V2ProjectCopyCreateResponses[keyof V2ProjectCopyCreateResponses]

export type V2ProjectCopyRefreshData = {
  body?: never
  path: {
    projectID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/experimental/project/{projectID}/copy/refresh"
}

export type V2ProjectCopyRefreshErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyError | InvalidRequestError
}

export type V2ProjectCopyRefreshError = V2ProjectCopyRefreshErrors[keyof V2ProjectCopyRefreshErrors]

export type V2ProjectCopyRefreshResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2ProjectCopyRefreshResponse = V2ProjectCopyRefreshResponses[keyof V2ProjectCopyRefreshResponses]

export type PtyConnectData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    directory?: string
    workspace?: string
    cursor?: string
    ticket?: string
  }
  url: "/pty/{ptyID}/connect"
}

export type PtyConnectErrors = {
  /**
   * Forbidden
   */
  403: EffectHttpApiErrorForbidden
  /**
   * Not found
   */
  404: NotFoundError
}

export type PtyConnectError = PtyConnectErrors[keyof PtyConnectErrors]

export type PtyConnectResponses = {
  /**
   * Connected session
   */
  200: boolean
}

export type PtyConnectResponse = PtyConnectResponses[keyof PtyConnectResponses]
