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

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

export type Event =
  | EventModelsDevRefreshed
  | EventIntegrationUpdated
  | EventIntegrationConnectionUpdated
  | EventCatalogUpdated
  | EventAgentUpdated
  | EventSessionCreated
  | EventSessionUpdated
  | EventSessionDeleted
  | EventMessageUpdated
  | EventMessageRemoved
  | EventMessagePartUpdated
  | EventMessagePartRemoved
  | EventSessionAgentSelected
  | EventSessionModelSelected
  | EventSessionMoved
  | EventSessionRenamed
  | EventSessionUsageUpdated
  | EventSessionForked
  | EventSessionInputPromoted
  | EventSessionInputAdmitted
  | EventSessionExecutionStarted
  | EventSessionExecutionSucceeded
  | EventSessionExecutionFailed
  | EventSessionExecutionInterrupted
  | EventSessionInstructionsUpdated
  | EventSessionSynthetic
  | EventSessionSkillActivated
  | EventSessionShellStarted
  | EventSessionShellEnded
  | EventSessionStepStarted
  | EventSessionStepEnded
  | EventSessionStepFailed
  | EventSessionTextStarted
  | EventSessionTextDelta
  | EventSessionTextEnded
  | EventSessionReasoningStarted
  | EventSessionReasoningDelta
  | EventSessionReasoningEnded
  | EventSessionToolInputStarted
  | EventSessionToolInputDelta
  | EventSessionToolInputEnded
  | EventSessionToolCalled
  | EventSessionToolProgress
  | EventSessionToolSuccess
  | EventSessionToolFailed
  | EventSessionRetryScheduled
  | EventSessionCompactionAdmitted
  | EventSessionCompactionStarted
  | EventSessionCompactionDelta
  | EventSessionCompactionEnded
  | EventSessionCompactionFailed
  | EventSessionRevertStaged
  | EventSessionRevertCleared
  | EventSessionRevertCommitted
  | EventMessagePartDelta
  | EventSessionDiff
  | EventSessionError
  | EventInstallationUpdated
  | EventInstallationUpdateAvailable
  | EventFilesystemChanged
  | EventReferenceUpdated
  | EventPermissionV2Asked
  | EventPermissionV2Replied
  | EventPluginAdded
  | EventPluginUpdated
  | EventProjectDirectoriesUpdated
  | EventCommandUpdated
  | EventConfigUpdated
  | EventSkillUpdated
  | EventPtyCreated
  | EventPtyUpdated
  | EventPtyExited
  | EventPtyDeleted
  | EventShellCreated
  | EventShellExited
  | EventShellDeleted
  | EventQuestionV2Asked
  | EventQuestionV2Replied
  | EventQuestionV2Rejected
  | EventFormCreated
  | EventFormReplied
  | EventFormCancelled
  | EventLspUpdated
  | EventPermissionAsked
  | EventPermissionReplied
  | EventTuiPromptAppend2
  | EventTuiCommandExecute2
  | EventTuiToastShow2
  | EventTuiSessionSelect2
  | EventMcpToolsChanged
  | EventMcpResourcesChanged
  | EventMcpStatusChanged
  | EventCommandExecuted
  | EventFileEdited
  | 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 PermissionAction = "allow" | "deny" | "ask"

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

export type PermissionRuleset = Array<PermissionRule>

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<FileDiffLegacyInfo>
  }
  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 Pty = {
  id: string
  title: string
  command: string
  args: Array<string>
  cwd: string
  status: "running" | "exited"
  pid: number
  exitCode?: number
}

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: "agent.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "session.created"
        properties: {
          sessionID: string
          info: SessionV1Info
        }
      }
    | {
        id: string
        type: "session.updated"
        properties: {
          sessionID: string
          info: SessionV1Info
        }
      }
    | {
        id: string
        type: "session.deleted"
        properties: {
          sessionID: string
        }
      }
    | {
        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.agent.selected"
        properties: {
          sessionID: string
          agent: string
        }
      }
    | {
        id: string
        type: "session.model.selected"
        properties: {
          sessionID: string
          model: ModelRef
        }
      }
    | {
        id: string
        type: "session.moved"
        properties: {
          sessionID: string
          location: LocationRef
          projectID?: string
          subpath?: string
        }
      }
    | {
        id: string
        type: "session.renamed"
        properties: {
          sessionID: string
          title: string
        }
      }
    | {
        id: string
        type: "session.usage.updated"
        properties: {
          sessionID: string
          cost: MoneyUsd
          tokens: TokenUsageInfo
        }
      }
    | {
        id: string
        type: "session.forked"
        properties: {
          sessionID: string
          parentID: string
          parentSeq: number
          from?: string
        }
      }
    | {
        id: string
        type: "session.input.promoted"
        properties: {
          sessionID: string
          inputID: string
        }
      }
    | {
        id: string
        type: "session.input.admitted"
        properties: {
          sessionID: string
          inputID: string
          input: SessionPendingMessage
        }
      }
    | {
        id: string
        type: "session.execution.started"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.execution.succeeded"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.execution.failed"
        properties: {
          sessionID: string
          error: SessionStructuredError
        }
      }
    | {
        id: string
        type: "session.execution.interrupted"
        properties: {
          sessionID: string
          reason: "user" | "shutdown" | "superseded"
        }
      }
    | {
        id: string
        type: "session.instructions.updated"
        properties: {
          sessionID: string
          delta: {
            [key: string]: string | "removed"
          }
        }
      }
    | {
        id: string
        type: "session.synthetic"
        properties: {
          sessionID: string
          text: string
          description?: string
          metadata?: {
            [key: string]: unknown
          }
        }
      }
    | {
        id: string
        type: "session.skill.activated"
        properties: {
          sessionID: string
          id: string
          name: string
          text: string
        }
      }
    | {
        id: string
        type: "session.shell.started"
        properties: {
          sessionID: string
          shell: ShellInfo
        }
      }
    | {
        id: string
        type: "session.shell.ended"
        properties: {
          sessionID: string
          shell: ShellInfo
          output: {
            output: string
            cursor: number
            size: number
            truncated: boolean
          }
        }
      }
    | {
        id: string
        type: "session.step.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          agent: string
          model: ModelRef
          snapshot?: string
        }
      }
    | {
        id: string
        type: "session.step.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          finish: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
          cost: MoneyUsd
          tokens: TokenUsageInfo
          snapshot?: string
          files?: Array<string>
        }
      }
    | {
        id: string
        type: "session.step.failed"
        properties: {
          sessionID: string
          assistantMessageID: string
          error: SessionStructuredError
          cost?: MoneyUsd
          tokens?: TokenUsageInfo
        }
      }
    | {
        id: string
        type: "session.text.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
        }
      }
    | {
        id: string
        type: "session.text.delta"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
          delta: string
        }
      }
    | {
        id: string
        type: "session.text.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
          text: string
        }
      }
    | {
        id: string
        type: "session.reasoning.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
          state?: SessionMessageProviderState
        }
      }
    | {
        id: string
        type: "session.reasoning.delta"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
          delta: string
        }
      }
    | {
        id: string
        type: "session.reasoning.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          ordinal: number
          text: string
          state?: SessionMessageProviderState
        }
      }
    | {
        id: string
        type: "session.tool.input.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          name: string
        }
      }
    | {
        id: string
        type: "session.tool.input.delta"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.tool.input.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.tool.called"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          input: {
            [key: string]: unknown
          }
          executed: boolean
          state?: SessionMessageProviderState
        }
      }
    | {
        id: string
        type: "session.tool.progress"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
        }
      }
    | {
        id: string
        type: "session.tool.success"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
          result?: unknown
          executed: boolean
          resultState?: SessionMessageProviderState
        }
      }
    | {
        id: string
        type: "session.tool.failed"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          error: SessionStructuredError
          result?: unknown
          executed: boolean
          resultState?: SessionMessageProviderState
        }
      }
    | {
        id: string
        type: "session.retry.scheduled"
        properties: {
          sessionID: string
          assistantMessageID: string
          attempt: number
          at: number
          error: SessionStructuredError
        }
      }
    | {
        id: string
        type: "session.compaction.admitted"
        properties: {
          sessionID: string
          inputID: string
        }
      }
    | {
        id: string
        type: "session.compaction.started"
        properties: {
          sessionID: string
          reason: "auto" | "manual"
          recent: string
          inputID?: string
        }
      }
    | {
        id: string
        type: "session.compaction.delta"
        properties: {
          sessionID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.compaction.ended"
        properties: {
          sessionID: string
          reason: "auto" | "manual"
          text: string
          recent: string
        }
      }
    | {
        id: string
        type: "session.compaction.failed"
        properties: {
          sessionID: string
          reason: "auto" | "manual"
          error: SessionStructuredError
          inputID?: string
        }
      }
    | {
        id: string
        type: "session.revert.staged"
        properties: {
          sessionID: string
          revert: SessionRevert
        }
      }
    | {
        id: string
        type: "session.revert.cleared"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.revert.committed"
        properties: {
          sessionID: string
          to: 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<FileDiffLegacyInfo>
        }
      }
    | {
        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: "filesystem.changed"
        properties: {
          file: string
          event: "add" | "change" | "unlink"
        }
      }
    | {
        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: "plugin.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "project.directories.updated"
        properties: {
          projectID: string
        }
      }
    | {
        id: string
        type: "command.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "config.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "skill.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        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: "shell.created"
        properties: {
          info: ShellInfo
        }
      }
    | {
        id: string
        type: "shell.exited"
        properties: {
          id: string
          exit?: number
          status: "running" | "exited" | "timeout" | "killed"
        }
      }
    | {
        id: string
        type: "shell.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: "form.created"
        properties: {
          form: FormInfo
        }
      }
    | {
        id: string
        type: "form.replied"
        properties: {
          id: string
          sessionID: string
          answer: FormAnswer
        }
      }
    | {
        id: string
        type: "form.cancelled"
        properties: {
          id: string
          sessionID: string
        }
      }
    | {
        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.background"
            | "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.resources.changed"
        properties: {
          server: string
        }
      }
    | {
        id: string
        type: "mcp.status.changed"
        properties: {
          server: string
        }
      }
    | {
        id: string
        type: "command.executed"
        properties: {
          name: string
          sessionID: string
          arguments: string
          messageID: string
        }
      }
    | {
        id: string
        type: "file.edited"
        properties: {
          file: 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
    | SyncEventSessionAgentSelected
    | SyncEventSessionModelSelected
    | SyncEventSessionMoved
    | SyncEventSessionRenamed
    | SyncEventSessionForked
    | SyncEventSessionInputPromoted
    | SyncEventSessionInputAdmitted
    | SyncEventSessionExecutionStarted
    | SyncEventSessionExecutionSucceeded
    | SyncEventSessionExecutionFailed
    | SyncEventSessionExecutionInterrupted
    | SyncEventSessionInstructionsUpdated
    | SyncEventSessionSynthetic
    | SyncEventSessionSkillActivated
    | SyncEventSessionShellStarted
    | SyncEventSessionShellEnded
    | SyncEventSessionStepStarted
    | SyncEventSessionStepEnded
    | SyncEventSessionStepFailed
    | SyncEventSessionTextStarted
    | SyncEventSessionTextEnded
    | SyncEventSessionReasoningStarted
    | SyncEventSessionReasoningEnded
    | SyncEventSessionToolInputStarted
    | SyncEventSessionToolInputEnded
    | SyncEventSessionToolCalled
    | SyncEventSessionToolProgress
    | SyncEventSessionToolSuccess
    | SyncEventSessionToolFailed
    | SyncEventSessionRetryScheduled
    | SyncEventSessionCompactionAdmitted
    | SyncEventSessionCompactionStarted
    | SyncEventSessionCompactionEnded
    | SyncEventSessionCompactionFailed
    | SyncEventSessionRevertStaged
    | SyncEventSessionRevertCleared
    | SyncEventSessionRevertCommitted
}

/**
 * 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
      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
  subagent_depth?: number
  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>
    subagent_depth?: number
    continue_loop_on_deny?: boolean
    mcp_timeout?: number
  }
}

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<FileDiffLegacyInfo>
  }
  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 Session = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<FileDiffLegacyInfo>
  }
  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 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.background"
      | "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 ServiceHealth = {
  healthy: true
  version: string
  pid: number
}

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

export type ServiceStopRequest = {
  instanceID: string
}

export type ServiceStopResponse = {
  accepted: boolean
}

export type SessionsResponse = {
  data: Array<SessionInfo>
  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 MessageNotFoundError = {
  _tag: "MessageNotFoundError"
  sessionID: string
  messageID: string
  message: string
}

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

export type CommandNotFoundError = {
  _tag: "CommandNotFoundError"
  command: string
  message: string
}

export type CommandEvaluationError = {
  _tag: "CommandEvaluationError"
  command: string
  message: string
}

export type SkillNotFoundError = {
  _tag: "SkillNotFoundError"
  skill: string
  message: string
}

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

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

export type InstructionEntryValueTooLargeError = {
  _tag: "InstructionEntryValueTooLargeError"
  actualBytes: number
  maxBytes: number
  message: string
}

export type SessionGenerateResponse = {
  data: {
    text: string
  }
}

export type SessionLogItem = SessionEventDurable | EventLogSynced

export type SessionLogItemJsonString = string

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

export type GenerateTextResponse = {
  data: {
    text: string
  }
}

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

export type McpResource2 = {
  server: string
  name: string
  uri: string
  description?: string
  mimeType?: string
}

export type FormNotFoundError = {
  _tag: "FormNotFoundError"
  id: string
  message: string
}

export type FormAlreadySettledError = {
  _tag: "FormAlreadySettledError"
  id: string
  message: string
}

export type FormInvalidAnswerError = {
  _tag: "FormInvalidAnswerError"
  id: string
  message: string
}

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

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

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

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

export type V2Event =
  | ModelsDevRefreshed
  | IntegrationUpdated
  | IntegrationConnectionUpdated
  | CatalogUpdated
  | AgentUpdated
  | SessionCreated
  | SessionUpdated
  | SessionDeleted
  | MessageUpdated
  | MessageRemoved
  | MessagePartUpdated
  | MessagePartRemoved
  | SessionAgentSelected
  | SessionModelSelected
  | SessionMoved
  | SessionRenamed
  | SessionUsageUpdated
  | SessionForked
  | SessionInputPromoted
  | SessionInputAdmitted
  | SessionExecutionStarted
  | SessionExecutionSucceeded
  | SessionExecutionFailed
  | SessionExecutionInterrupted
  | SessionInstructionsUpdated
  | SessionSynthetic
  | SessionSkillActivated
  | SessionShellStarted
  | SessionShellEnded
  | SessionStepStarted
  | SessionStepEnded
  | SessionStepFailed
  | SessionTextStarted
  | SessionTextDelta
  | SessionTextEnded
  | SessionReasoningStarted
  | SessionReasoningDelta
  | SessionReasoningEnded
  | SessionToolInputStarted
  | SessionToolInputDelta
  | SessionToolInputEnded
  | SessionToolCalled
  | SessionToolProgress
  | SessionToolSuccess
  | SessionToolFailed
  | SessionRetryScheduled
  | SessionCompactionAdmitted
  | SessionCompactionStarted
  | SessionCompactionDelta
  | SessionCompactionEnded
  | SessionCompactionFailed
  | SessionRevertStaged
  | SessionRevertCleared
  | SessionRevertCommitted
  | MessagePartDelta
  | SessionDiff
  | SessionError
  | InstallationUpdated
  | InstallationUpdateAvailable
  | FilesystemChanged
  | ReferenceUpdated
  | PermissionV2Asked
  | PermissionV2Replied
  | PluginAdded
  | PluginUpdated
  | ProjectDirectoriesUpdated
  | CommandUpdated
  | ConfigUpdated
  | SkillUpdated
  | PtyCreated
  | PtyUpdated
  | PtyExited
  | PtyDeleted
  | ShellCreated
  | ShellExited
  | ShellDeleted
  | QuestionV2Asked
  | QuestionV2Replied
  | QuestionV2Rejected
  | FormCreated
  | FormReplied
  | FormCancelled
  | LspUpdated
  | PermissionAsked
  | PermissionReplied
  | TuiPromptAppend
  | TuiCommandExecute
  | TuiToastShow
  | TuiSessionSelect
  | McpToolsChanged
  | McpResourcesChanged
  | McpStatusChanged
  | CommandExecuted
  | FileEdited
  | ProjectUpdated
  | SessionStatus2
  | SessionIdle
  | QuestionAsked
  | QuestionReplied2
  | QuestionRejected2
  | SessionCompacted
  | VcsBranchUpdated
  | WorkspaceReady
  | WorkspaceFailed
  | WorkspaceStatus
  | WorktreeReady
  | WorktreeFailed
  | ServerConnected
  | GlobalDisposed

export type V2EventJsonString = string

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

export type ShellNotFoundError = {
  _tag: "ShellNotFoundError"
  id: string
  message: string
}

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

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

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.background"
      | "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
  | IntegrationCommandMethod
  | IntegrationKeyMethod
  | IntegrationEnvMethod

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

export type SkillSource = SkillDirectorySource | SkillUrlSource | SkillEmbeddedSource

export type MoveSessionDestination = {
  directory: string
}

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

export type SessionV1Info = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<FileDiffLegacyInfo>
  }
  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 ModelRef = {
  id: string
  providerID: string
  variant?: string
}

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

export type MoneyUsd = number

export type TokenUsageInfo = {
  input: number
  output: number
  reasoning: number
  cache: {
    read: number
    write: number
  }
}

export type PromptBase64 = string

export type PromptFileSource =
  | {
      type: "inline"
    }
  | {
      type: "uri"
      uri: string
    }

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

export type PromptFileAttachment = {
  data: PromptBase64
  mime: string
  source: PromptFileSource
  name?: string
  description?: string
  mention?: PromptMention
}

export type PromptAgentAttachment = {
  name: string
  mention?: PromptMention
}

export type SessionPendingUserData = {
  text: string
  files?: Array<PromptFileAttachment>
  agents?: Array<PromptAgentAttachment>
  metadata?: {
    [key: string]: unknown
  }
}

export type SessionPendingUserMessage = {
  type: "user"
  data: SessionPendingUserData
  delivery: "steer" | "queue"
}

export type SessionPendingSyntheticData = {
  text: string
  description?: string
  metadata?: {
    [key: string]: unknown
  }
}

export type SessionPendingSyntheticMessage = {
  type: "synthetic"
  data: SessionPendingSyntheticData
  delivery: "steer" | "queue"
}

export type SessionPendingMessage = SessionPendingUserMessage | SessionPendingSyntheticMessage

export type SessionStructuredError = {
  type: string
  message: string
}

export type ShellInfo = {
  id: string
  status: "running" | "exited" | "timeout" | "killed"
  command: string
  cwd: string
  shell: string
  file: string
  pid?: number
  exit?: number
  metadata: {
    [key: string]: unknown
  }
  time: {
    started: number
    completed?: number
  }
}

export type SessionMessageProviderState = {
  [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 FileDiffInfo = {
  file: string
  patch: string
  additions: number
  deletions: number
  status: "added" | "deleted" | "modified"
}

export type SessionRevert = {
  messageID: string
  partID?: string
  snapshot?: string
  files?: Array<FileDiffInfo>
}

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 FormMetadata = {
  [key: string]: unknown
}

export type FormWhen = {
  key: string
  op: "eq" | "neq"
  value: string | number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN" | boolean
}

export type FormOption = {
  value: string
  label: string
  description?: string
}

export type FormStringField = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen>
  type: "string"
  format?: "email" | "uri" | "date" | "date-time"
  minLength?: number
  maxLength?: number
  pattern?: string
  placeholder?: string
  default?: string
  options?: Array<FormOption>
  custom?: boolean
}

export type FormNumberField = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen>
  type: "number"
  minimum?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  maximum?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  default?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type FormIntegerField = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen>
  type: "integer"
  minimum?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  maximum?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  default?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type FormBooleanField = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen>
  type: "boolean"
  default?: boolean
}

export type FormMultiselectField = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen>
  type: "multiselect"
  options: Array<FormOption>
  minItems?: number
  maxItems?: number
  custom?: boolean
  default?: Array<string>
}

export type FormExternalField = {
  key: string
  type: "external"
  url: string
  title?: string
  description?: string
}

export type FormField =
  | FormStringField
  | FormNumberField
  | FormIntegerField
  | FormBooleanField
  | FormMultiselectField
  | FormExternalField

export type FormFields = Array<FormField>

export type FormInfo = {
  id: string
  sessionID: string
  title: string
  metadata?: FormMetadata
  fields: FormFields
}

export type FormValue =
  | string
  | number
  | "NaN"
  | "Infinity"
  | "-Infinity"
  | "Infinity"
  | "-Infinity"
  | "NaN"
  | boolean
  | Array<string>

export type FormAnswer = {
  [key: string]: FormValue
}

export type ProjectVcs = "git" | "hg"

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

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

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

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 SyncEventSessionAgentSelected = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.agent.selected.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      agent: string
    }
  }
}

export type SyncEventSessionModelSelected = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.model.selected.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      model: ModelRef
    }
  }
}

export type SyncEventSessionMoved = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.moved.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      location: LocationRef
      projectID?: string
      subpath?: string
    }
  }
}

export type SyncEventSessionRenamed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.renamed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      title: string
    }
  }
}

export type SyncEventSessionForked = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.forked.2"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      parentID: string
      parentSeq: number
      from?: string
    }
  }
}

export type SyncEventSessionInputPromoted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.input.promoted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      inputID: string
    }
  }
}

export type SyncEventSessionInputAdmitted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.input.admitted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      inputID: string
      input: SessionPendingMessage
    }
  }
}

export type SyncEventSessionExecutionStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.execution.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
    }
  }
}

export type SyncEventSessionExecutionSucceeded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.execution.succeeded.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
    }
  }
}

export type SyncEventSessionExecutionFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.execution.failed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      error: SessionStructuredError
    }
  }
}

export type SyncEventSessionExecutionInterrupted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.execution.interrupted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      reason: "user" | "shutdown" | "superseded"
    }
  }
}

export type SyncEventSessionInstructionsUpdated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.instructions.updated.2"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      delta: {
        [key: string]: string | "removed"
      }
    }
  }
}

export type SyncEventSessionSynthetic = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.synthetic.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      text: string
      description?: string
      metadata?: {
        [key: string]: unknown
      }
    }
  }
}

export type SyncEventSessionSkillActivated = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.skill.activated.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      id: string
      name: string
      text: string
    }
  }
}

export type SyncEventSessionShellStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.shell.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      shell: ShellInfo
    }
  }
}

export type SyncEventSessionShellEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.shell.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      shell: ShellInfo
      output: {
        output: string
        cursor: number
        size: number
        truncated: boolean
      }
    }
  }
}

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

export type SyncEventSessionStepEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.step.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      finish: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
      cost: MoneyUsd
      tokens: TokenUsageInfo
      snapshot?: string
      files?: Array<string>
    }
  }
}

export type SyncEventSessionStepFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.step.failed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      error: SessionStructuredError
      cost?: MoneyUsd
      tokens?: TokenUsageInfo
    }
  }
}

export type SyncEventSessionTextStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.text.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      ordinal: number
    }
  }
}

export type SyncEventSessionTextEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.text.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      ordinal: number
      text: string
    }
  }
}

export type SyncEventSessionReasoningStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.reasoning.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      ordinal: number
      state?: SessionMessageProviderState
    }
  }
}

export type SyncEventSessionReasoningEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.reasoning.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      ordinal: number
      text: string
      state?: SessionMessageProviderState
    }
  }
}

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

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

export type SyncEventSessionToolCalled = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.tool.called.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      callID: string
      input: {
        [key: string]: unknown
      }
      executed: boolean
      state?: SessionMessageProviderState
    }
  }
}

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

export type SyncEventSessionToolSuccess = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.tool.success.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      callID: string
      structured: {
        [key: string]: unknown
      }
      content: Array<LlmToolContent>
      result?: unknown
      executed: boolean
      resultState?: SessionMessageProviderState
    }
  }
}

export type SyncEventSessionToolFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.tool.failed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      callID: string
      error: SessionStructuredError
      result?: unknown
      executed: boolean
      resultState?: SessionMessageProviderState
    }
  }
}

export type SyncEventSessionRetryScheduled = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.retry.scheduled.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      attempt: number
      at: number
      error: SessionStructuredError
    }
  }
}

export type SyncEventSessionCompactionAdmitted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.compaction.admitted.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      inputID: string
    }
  }
}

export type SyncEventSessionCompactionStarted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.compaction.started.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      reason: "auto" | "manual"
      recent: string
      inputID?: string
    }
  }
}

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

export type SyncEventSessionCompactionFailed = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.compaction.failed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      reason: "auto" | "manual"
      error: SessionStructuredError
      inputID?: string
    }
  }
}

export type SyncEventSessionRevertStaged = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.revert.staged.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      revert: SessionRevert
    }
  }
}

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

export type SyncEventSessionRevertCommitted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.revert.committed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      to: string
    }
  }
}

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

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

export type ProjectDirectory = {
  directory: string
  strategy?: string
}

export type ProjectDirectories = Array<ProjectDirectory>

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 ProviderSettings = {
  [key: string]: unknown
}

export type ProviderRequest = {
  settings: ProviderSettings
  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 AgentInfo = {
  id: string
  name: string
  model?: ModelRef
  request: ProviderRequest
  system?: string
  description?: string
  mode: "subagent" | "primary" | "all"
  hidden: boolean
  color?: AgentColor
  steps?: number
  permissions: PermissionV2Ruleset
}

export type PluginInfo = {
  id: string
}

export type SessionInfo = {
  id: string
  parentID?: string
  fork?: {
    sessionID: string
    messageID?: string
  }
  projectID: string
  agent?: string
  model?: ModelRef
  cost: MoneyUsd
  tokens: TokenUsageInfo
  time: {
    created: number
    updated: number
    archived?: number
  }
  title: string
  location: LocationRef
  subpath?: string
  revert?: SessionRevert
}

export type PromptInputFileAttachment = {
  uri: string
  name?: string
  description?: string
  mention?: PromptMention
}

export type SessionPendingUser = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "user"
  data: SessionPendingUserData
  delivery: "steer" | "queue"
}

export type SessionPendingSynthetic = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "synthetic"
  data: SessionPendingSyntheticData
  delivery: "steer" | "queue"
}

export type SessionPendingCompaction = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "compaction"
}

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

export type SessionMessageModelSelected = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "model-switched"
  model: ModelRef
  previous?: 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
  }
  text: string
  description?: string
  type: "synthetic"
}

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

export type SessionMessageSkill = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "skill"
  skill: string
  name: string
  text: string
}

export type SessionMessageShell = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "shell"
  shellID: string
  command: string
  status: "running" | "exited" | "timeout" | "killed"
  exit?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  output?: {
    output: string
    cursor: number
    size: number
    truncated: boolean
  }
}

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

export type SessionMessageAssistantReasoning = {
  type: "reasoning"
  text: string
  state?: SessionMessageProviderState
  time?: {
    created: number
    completed?: number
  }
}

export type SessionMessageToolStateStreaming = {
  status: "streaming"
  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
  }
  content: Array<LlmToolContent>
  structured: {
    [key: string]: unknown
  }
  result?: unknown
}

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

export type SessionMessageAssistantTool = {
  type: "tool"
  id: string
  name: string
  executed?: boolean
  providerState?: SessionMessageProviderState
  providerResultState?: SessionMessageProviderState
  state:
    | SessionMessageToolStateStreaming
    | SessionMessageToolStateRunning
    | SessionMessageToolStateCompleted
    | SessionMessageToolStateError
  time: {
    created: number
    ran?: number
    completed?: number
  }
}

export type SessionMessageAssistantRetry = {
  attempt: number
  at: number
  error: SessionStructuredError
}

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?: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
  cost?: MoneyUsd
  tokens?: TokenUsageInfo
  error?: SessionStructuredError
  retry?: SessionMessageAssistantRetry
}

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

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

export type SessionMessageCompactionFailed = {
  type: "compaction"
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  status: "failed"
  reason: "auto" | "manual"
  error: SessionStructuredError
}

export type SessionMessageCompaction =
  | SessionMessageCompactionRunning
  | SessionMessageCompactionCompleted
  | SessionMessageCompactionFailed

export type SessionMessageInfo =
  | SessionMessageAgentSelected
  | SessionMessageModelSelected
  | SessionMessageUser
  | SessionMessageSynthetic
  | SessionMessageSystem
  | SessionMessageSkill
  | SessionMessageShell
  | SessionMessageAssistant
  | SessionMessageCompaction

export type SessionPendingInfo = SessionPendingUser | SessionPendingSynthetic | SessionPendingCompaction

export type InstructionEntryKey = string

export type InstructionEntryInfo = {
  key: InstructionEntryKey
  value: unknown
}

export type SessionAgentSelected = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.agent.selected"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    agent: string
  }
}

export type SessionModelSelected = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.model.selected"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    model: ModelRef
  }
}

export type SessionMoved = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.moved"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    location: LocationRef
    projectID?: string
    subpath?: string
  }
}

export type SessionRenamed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.renamed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    title: string
  }
}

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

export type SessionForked = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.forked"
  durable: {
    aggregateID: string
    seq: number
    version: 2
  }
  location?: LocationRef
  data: {
    sessionID: string
    parentID: string
    parentSeq: number
    from?: string
  }
}

export type SessionInputPromoted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.input.promoted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    inputID: string
  }
}

export type SessionInputAdmitted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.input.admitted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    inputID: string
    input: SessionPendingMessage
  }
}

export type SessionExecutionStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
  }
}

export type SessionExecutionSucceeded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.succeeded"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
  }
}

export type SessionExecutionFailed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    error: SessionStructuredError
  }
}

export type SessionExecutionInterrupted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.interrupted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    reason: "user" | "shutdown" | "superseded"
  }
}

export type SessionInstructionsUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.instructions.updated"
  durable: {
    aggregateID: string
    seq: number
    version: 2
  }
  location?: LocationRef
  data: {
    sessionID: string
    delta: {
      [key: string]: string | "removed"
    }
  }
}

export type SessionSynthetic = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.synthetic"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    text: string
    description?: string
    metadata?: {
      [key: string]: unknown
    }
  }
}

export type SessionSkillActivated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.skill.activated"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    id: string
    name: string
    text: string
  }
}

export type SessionShellStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.shell.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    shell: ShellInfo
  }
}

export type SessionShellEnded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.shell.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    shell: ShellInfo
    output: {
      output: string
      cursor: number
      size: number
      truncated: boolean
    }
  }
}

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

export type SessionStepEnded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.step.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    finish: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
    cost: MoneyUsd
    tokens: TokenUsageInfo
    snapshot?: string
    files?: Array<string>
  }
}

export type SessionStepFailed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.step.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    error: SessionStructuredError
    cost?: MoneyUsd
    tokens?: TokenUsageInfo
  }
}

export type SessionTextStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
  }
}

export type SessionTextEnded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
  }
}

export type SessionReasoningStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    state?: SessionMessageProviderState
  }
}

export type SessionReasoningEnded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
    state?: SessionMessageProviderState
  }
}

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

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

export type SessionToolCalled = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.called"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    input: {
      [key: string]: unknown
    }
    executed: boolean
    state?: SessionMessageProviderState
  }
}

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

export type SessionToolSuccess = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.success"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState
  }
}

export type SessionToolFailed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionStructuredError
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState
  }
}

export type SessionRetryScheduled = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.retry.scheduled"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    attempt: number
    at: number
    error: SessionStructuredError
  }
}

export type SessionCompactionAdmitted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.admitted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    inputID: string
  }
}

export type SessionCompactionStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    reason: "auto" | "manual"
    recent: string
    inputID?: string
  }
}

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

export type SessionCompactionFailed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    reason: "auto" | "manual"
    error: SessionStructuredError
    inputID?: string
  }
}

export type SessionRevertStaged = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.staged"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    revert: SessionRevert
  }
}

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

export type SessionRevertCommitted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.committed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    to: string
  }
}

export type SessionUsageRecorded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.usage.recorded"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRef
  data: {
    sessionID: string
    source: "title" | "compaction"
    cost: MoneyUsd
    tokens: TokenUsageInfo
  }
}

export type SessionEventDurable =
  | SessionAgentSelected
  | SessionModelSelected
  | SessionMoved
  | SessionRenamed
  | SessionDeleted
  | SessionForked
  | SessionInputPromoted
  | SessionInputAdmitted
  | SessionExecutionStarted
  | SessionExecutionSucceeded
  | SessionExecutionFailed
  | SessionExecutionInterrupted
  | SessionInstructionsUpdated
  | SessionSynthetic
  | SessionSkillActivated
  | SessionShellStarted
  | SessionShellEnded
  | SessionStepStarted
  | SessionStepEnded
  | SessionStepFailed
  | SessionTextStarted
  | SessionTextEnded
  | SessionReasoningStarted
  | SessionReasoningEnded
  | SessionToolInputStarted
  | SessionToolInputEnded
  | SessionToolCalled
  | SessionToolProgress
  | SessionToolSuccess
  | SessionToolFailed
  | SessionRetryScheduled
  | SessionCompactionAdmitted
  | SessionCompactionStarted
  | SessionCompactionEnded
  | SessionCompactionFailed
  | SessionRevertStaged
  | SessionRevertCleared
  | SessionRevertCommitted
  | SessionUsageRecorded

export type EventLogSynced = {
  type: "log.synced"
  aggregateID: string
  seq?: number
}

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

export type ModelVariant = {
  id: string
  settings?: {
    [key: string]: unknown
  }
  headers?: {
    [key: string]: string
  }
  body?: {
    [key: string]: unknown
  }
}

export type MoneyUsdPerMillionTokens = number

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

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

export type ProviderV2Info = {
  id: string
  integrationID?: string
  name: string
  disabled?: boolean
  package: string
  settings?: {
    [key: string]: unknown
  }
  headers?: {
    [key: string]: string
  }
  body?: {
    [key: string]: unknown
  }
}

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 IntegrationCommandMethod = {
  id: string
  type: "command"
  label: string
  command: Array<string>
}

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 IntegrationCommandAttempt = {
  attemptID: string
  time: {
    created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type IntegrationCommandAttemptStatus =
  | {
      status: "pending"
      message?: string
      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 McpStatusConnected2 = {
  status: "connected"
}

export type McpStatusPending = {
  status: "pending"
}

export type McpStatusDisabled2 = {
  status: "disabled"
}

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

export type McpStatusNeedsAuth2 = {
  status: "needs_auth"
}

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

export type McpServer = {
  name: string
  status:
    | McpStatusConnected2
    | McpStatusPending
    | McpStatusDisabled2
    | McpStatusFailed2
    | McpStatusNeedsAuth2
    | McpStatusNeedsClientRegistration2
  integrationID?: string
}

export type McpResourceTemplate = {
  server: string
  name: string
  uriTemplate: string
  description?: string
  mimeType?: string
}

export type McpResourceCatalog = {
  resources: Array<McpResource2>
  templates: Array<McpResourceTemplate>
}

export type ProjectCurrent = {
  id: string
  directory: string
}

export type FormCreatePayload = {
  id?: string
  title: string
  metadata?: FormMetadata
  fields: FormFields
}

export type FormState =
  | {
      status: "pending"
    }
  | {
      status: "answered"
      answer: FormAnswer
    }
  | {
      status: "cancelled"
    }

export type FormReply = {
  answer: FormAnswer
}

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 CommandInfo = {
  name: string
  template: string
  description?: string
  agent?: string
  model?: ModelRef
  subtask?: boolean
}

export type SkillInfo = {
  id: string
  name: string
  description?: string
  slash?: boolean
  autoinvoke?: boolean
  location: string
  content: string
}

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

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

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

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

export type AgentUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "agent.updated"
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

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

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

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

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

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

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

export type SessionUsageUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.usage.updated"
  location?: LocationRef
  data: {
    sessionID: string
    cost: MoneyUsd
    tokens: TokenUsageInfo
  }
}

export type SessionTextDelta = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.delta"
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type SessionReasoningDelta = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.delta"
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type SessionToolInputDelta = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.input.delta"
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    delta: string
  }
}

export type SessionCompactionDelta = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.delta"
  location?: LocationRef
  data: {
    sessionID: string
    text: string
  }
}

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

export type SessionDiff = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.diff"
  location?: LocationRef
  data: {
    sessionID: string
    diff: Array<FileDiffLegacyInfo>
  }
}

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

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

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

export type FilesystemChanged = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "filesystem.changed"
  location?: LocationRef
  data: {
    file: string
    event: "add" | "change" | "unlink"
  }
}

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

export type PermissionV2Asked = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.asked"
  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
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.replied"
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    reply: PermissionV2Reply
  }
}

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

export type PluginUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "plugin.updated"
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

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

export type CommandUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "command.updated"
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type ConfigUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "config.updated"
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

export type SkillUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "skill.updated"
  location?: LocationRef
  data: {
    [key: string]: unknown
  }
}

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

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

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

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

export type ShellCreated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.created"
  location?: LocationRef
  data: {
    info: ShellInfo
  }
}

export type ShellExited = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.exited"
  location?: LocationRef
  data: {
    id: string
    exit?: number
    status: "running" | "exited" | "timeout" | "killed"
  }
}

export type ShellDeleted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.deleted"
  location?: LocationRef
  data: {
    id: string
  }
}

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

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

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

export type FormWhen1 = {
  key: string
  op: "eq" | "neq"
  value: string | number | "NaN" | "Infinity" | "-Infinity" | boolean
}

export type FormNumberField1 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "number"
  minimum?: number | "NaN" | "Infinity" | "-Infinity"
  maximum?: number | "NaN" | "Infinity" | "-Infinity"
  default?: number | "NaN" | "Infinity" | "-Infinity"
}

export type FormIntegerField1 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "integer"
  minimum?: number | "NaN" | "Infinity" | "-Infinity"
  maximum?: number | "NaN" | "Infinity" | "-Infinity"
  default?: number | "NaN" | "Infinity" | "-Infinity"
}

export type FormCreated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.created"
  location?: LocationRef
  data: {
    form: FormInfo
  }
}

export type FormValue1 = string | number | "NaN" | "Infinity" | "-Infinity" | boolean | Array<string>

export type FormReplied = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.replied"
  location?: LocationRef
  data: {
    id: string
    sessionID: string
    answer: FormAnswer
  }
}

export type FormCancelled = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.cancelled"
  location?: LocationRef
  data: {
    id: string
    sessionID: string
  }
}

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

export type PermissionAsked = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.asked"
  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
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.replied"
  location?: LocationRef
  data: {
    sessionID: string
    requestID: string
    reply: "once" | "always" | "reject"
  }
}

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

export type TuiCommandExecute = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.command.execute"
  location?: LocationRef
  data: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.background"
      | "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
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.toast.show"
  location?: LocationRef
  data: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number
  }
}

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

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

export type McpResourcesChanged = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.resources.changed"
  location?: LocationRef
  data: {
    server: string
  }
}

export type McpStatusChanged = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.status.changed"
  location?: LocationRef
  data: {
    server: string
  }
}

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

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

export type ProjectUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "project.updated"
  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
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.idle"
  location?: LocationRef
  data: {
    sessionID: string
  }
}

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

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

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

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

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

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

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

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

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

export type GlobalDisposed = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "global.disposed"
  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 VcsMode = "working" | "branch"

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 EventAgentUpdated = {
  id: string
  type: "agent.updated"
  properties: {
    [key: string]: unknown
  }
}

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

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

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

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 EventSessionAgentSelected = {
  id: string
  type: "session.agent.selected"
  properties: {
    sessionID: string
    agent: string
  }
}

export type EventSessionModelSelected = {
  id: string
  type: "session.model.selected"
  properties: {
    sessionID: string
    model: ModelRef
  }
}

export type EventSessionMoved = {
  id: string
  type: "session.moved"
  properties: {
    sessionID: string
    location: LocationRef
    projectID?: string
    subpath?: string
  }
}

export type EventSessionRenamed = {
  id: string
  type: "session.renamed"
  properties: {
    sessionID: string
    title: string
  }
}

export type EventSessionUsageUpdated = {
  id: string
  type: "session.usage.updated"
  properties: {
    sessionID: string
    cost: MoneyUsd
    tokens: TokenUsageInfo
  }
}

export type EventSessionForked = {
  id: string
  type: "session.forked"
  properties: {
    sessionID: string
    parentID: string
    parentSeq: number
    from?: string
  }
}

export type EventSessionInputPromoted = {
  id: string
  type: "session.input.promoted"
  properties: {
    sessionID: string
    inputID: string
  }
}

export type EventSessionInputAdmitted = {
  id: string
  type: "session.input.admitted"
  properties: {
    sessionID: string
    inputID: string
    input: SessionPendingMessage
  }
}

export type EventSessionExecutionStarted = {
  id: string
  type: "session.execution.started"
  properties: {
    sessionID: string
  }
}

export type EventSessionExecutionSucceeded = {
  id: string
  type: "session.execution.succeeded"
  properties: {
    sessionID: string
  }
}

export type EventSessionExecutionFailed = {
  id: string
  type: "session.execution.failed"
  properties: {
    sessionID: string
    error: SessionStructuredError
  }
}

export type EventSessionExecutionInterrupted = {
  id: string
  type: "session.execution.interrupted"
  properties: {
    sessionID: string
    reason: "user" | "shutdown" | "superseded"
  }
}

export type EventSessionInstructionsUpdated = {
  id: string
  type: "session.instructions.updated"
  properties: {
    sessionID: string
    delta: {
      [key: string]: string | "removed"
    }
  }
}

export type EventSessionSynthetic = {
  id: string
  type: "session.synthetic"
  properties: {
    sessionID: string
    text: string
    description?: string
    metadata?: {
      [key: string]: unknown
    }
  }
}

export type EventSessionSkillActivated = {
  id: string
  type: "session.skill.activated"
  properties: {
    sessionID: string
    id: string
    name: string
    text: string
  }
}

export type EventSessionShellStarted = {
  id: string
  type: "session.shell.started"
  properties: {
    sessionID: string
    shell: ShellInfo
  }
}

export type EventSessionShellEnded = {
  id: string
  type: "session.shell.ended"
  properties: {
    sessionID: string
    shell: ShellInfo
    output: {
      output: string
      cursor: number
      size: number
      truncated: boolean
    }
  }
}

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

export type EventSessionStepEnded = {
  id: string
  type: "session.step.ended"
  properties: {
    sessionID: string
    assistantMessageID: string
    finish: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
    cost: MoneyUsd
    tokens: TokenUsageInfo
    snapshot?: string
    files?: Array<string>
  }
}

export type EventSessionStepFailed = {
  id: string
  type: "session.step.failed"
  properties: {
    sessionID: string
    assistantMessageID: string
    error: SessionStructuredError
    cost?: MoneyUsd
    tokens?: TokenUsageInfo
  }
}

export type EventSessionTextStarted = {
  id: string
  type: "session.text.started"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
  }
}

export type EventSessionTextDelta = {
  id: string
  type: "session.text.delta"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type EventSessionTextEnded = {
  id: string
  type: "session.text.ended"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
  }
}

export type EventSessionReasoningStarted = {
  id: string
  type: "session.reasoning.started"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    state?: SessionMessageProviderState
  }
}

export type EventSessionReasoningDelta = {
  id: string
  type: "session.reasoning.delta"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type EventSessionReasoningEnded = {
  id: string
  type: "session.reasoning.ended"
  properties: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
    state?: SessionMessageProviderState
  }
}

export type EventSessionToolInputStarted = {
  id: string
  type: "session.tool.input.started"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    name: string
  }
}

export type EventSessionToolInputDelta = {
  id: string
  type: "session.tool.input.delta"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    delta: string
  }
}

export type EventSessionToolInputEnded = {
  id: string
  type: "session.tool.input.ended"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    text: string
  }
}

export type EventSessionToolCalled = {
  id: string
  type: "session.tool.called"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    input: {
      [key: string]: unknown
    }
    executed: boolean
    state?: SessionMessageProviderState
  }
}

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

export type EventSessionToolSuccess = {
  id: string
  type: "session.tool.success"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState
  }
}

export type EventSessionToolFailed = {
  id: string
  type: "session.tool.failed"
  properties: {
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionStructuredError
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState
  }
}

export type EventSessionRetryScheduled = {
  id: string
  type: "session.retry.scheduled"
  properties: {
    sessionID: string
    assistantMessageID: string
    attempt: number
    at: number
    error: SessionStructuredError
  }
}

export type EventSessionCompactionAdmitted = {
  id: string
  type: "session.compaction.admitted"
  properties: {
    sessionID: string
    inputID: string
  }
}

export type EventSessionCompactionStarted = {
  id: string
  type: "session.compaction.started"
  properties: {
    sessionID: string
    reason: "auto" | "manual"
    recent: string
    inputID?: string
  }
}

export type EventSessionCompactionDelta = {
  id: string
  type: "session.compaction.delta"
  properties: {
    sessionID: string
    text: string
  }
}

export type EventSessionCompactionEnded = {
  id: string
  type: "session.compaction.ended"
  properties: {
    sessionID: string
    reason: "auto" | "manual"
    text: string
    recent: string
  }
}

export type EventSessionCompactionFailed = {
  id: string
  type: "session.compaction.failed"
  properties: {
    sessionID: string
    reason: "auto" | "manual"
    error: SessionStructuredError
    inputID?: string
  }
}

export type EventSessionRevertStaged = {
  id: string
  type: "session.revert.staged"
  properties: {
    sessionID: string
    revert: SessionRevert
  }
}

export type EventSessionRevertCleared = {
  id: string
  type: "session.revert.cleared"
  properties: {
    sessionID: string
  }
}

export type EventSessionRevertCommitted = {
  id: string
  type: "session.revert.committed"
  properties: {
    sessionID: string
    to: 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<FileDiffLegacyInfo>
  }
}

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 EventFilesystemChanged = {
  id: string
  type: "filesystem.changed"
  properties: {
    file: string
    event: "add" | "change" | "unlink"
  }
}

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 EventPluginUpdated = {
  id: string
  type: "plugin.updated"
  properties: {
    [key: string]: unknown
  }
}

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

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

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

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

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 EventShellCreated = {
  id: string
  type: "shell.created"
  properties: {
    info: ShellInfo
  }
}

export type EventShellExited = {
  id: string
  type: "shell.exited"
  properties: {
    id: string
    exit?: number
    status: "running" | "exited" | "timeout" | "killed"
  }
}

export type EventShellDeleted = {
  id: string
  type: "shell.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 FormNumberField2 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "number"
  minimum?: number | "NaN" | "Infinity" | "-Infinity"
  maximum?: number | "NaN" | "Infinity" | "-Infinity"
  default?: number | "NaN" | "Infinity" | "-Infinity"
}

export type FormIntegerField2 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "integer"
  minimum?: number | "NaN" | "Infinity" | "-Infinity"
  maximum?: number | "NaN" | "Infinity" | "-Infinity"
  default?: number | "NaN" | "Infinity" | "-Infinity"
}

export type EventFormCreated = {
  id: string
  type: "form.created"
  properties: {
    form: FormInfo
  }
}

export type EventFormReplied = {
  id: string
  type: "form.replied"
  properties: {
    id: string
    sessionID: string
    answer: FormAnswer
  }
}

export type EventFormCancelled = {
  id: string
  type: "form.cancelled"
  properties: {
    id: string
    sessionID: string
  }
}

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 EventMcpResourcesChanged = {
  id: string
  type: "mcp.resources.changed"
  properties: {
    server: string
  }
}

export type EventMcpStatusChanged = {
  id: string
  type: "mcp.status.changed"
  properties: {
    server: string
  }
}

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

export type EventFileEdited = {
  id: string
  type: "file.edited"
  properties: {
    file: 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 SkillDirectorySource = {
  type: "directory"
  path: string
}

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

export type SkillEmbeddedSource = {
  type: "embedded"
  skill: SkillInfo
}

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

export type ServiceHealthV2 = {
  healthy: true
  version: string
  pid: number
}

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

export type SessionsResponseV2 = {
  data: Array<SessionInfoV2>
  cursor: {
    previous?: string | null
    next?: string | null
  }
}

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

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

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

export type UnknownErrorV2 = {
  _tag: "UnknownError"
  message: string
  ref?: string | null
}

export type SessionMessagesResponseV2 = {
  data: Array<SessionMessageInfo>
  cursor: {
    previous?: string | null
    next?: string | null
  }
}

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

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

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

export type MessageOutputLengthErrorV2 = {
  name: "MessageOutputLengthError"
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

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

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

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

export type AssistantMessageV2 = {
  id: string
  sessionID: string
  role: "assistant"
  time: {
    created: number
    completed?: number | null
  }
  error?:
    | ProviderAuthError
    | UnknownError1V2
    | MessageOutputLengthErrorV2
    | MessageAbortedError
    | StructuredOutputErrorV2
    | ContextOverflowErrorV2
    | ContentFilterError
    | ApiErrorV2
    | null
  parentID: string
  modelID: string
  providerID: string
  mode: string
  agent: string
  path: {
    cwd: string
    root: string
  }
  summary?: boolean | null
  cost: number
  tokens: {
    total?: number | null
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  structured?: unknown | null
  variant?: string | null
  finish?: string | null
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type SessionStatusV2 =
  | {
      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 SessionStatusV22 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.status"
  location?: LocationRefV2
  data: {
    sessionID: string
    status: SessionStatusV2
  }
}

export type QuestionInfoV2 = {
  /**
   * Complete question
   */
  question: string
  /**
   * Very short label (max 30 chars)
   */
  header: string
  /**
   * Available choices
   */
  options: Array<QuestionOption>
  /**
   * Allow selecting multiple choices
   */
  multiple?: boolean | null
  /**
   * Allow typing a custom answer (default: true)
   */
  custom?: boolean | null
}

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

export type V2EventV2 =
  | ModelsDevRefreshedV2
  | IntegrationUpdatedV2
  | IntegrationConnectionUpdatedV2
  | CatalogUpdatedV2
  | AgentUpdatedV2
  | SessionCreatedV2
  | SessionUpdatedV2
  | SessionDeleted1
  | MessageUpdatedV2
  | MessageRemovedV2
  | MessagePartUpdatedV2
  | MessagePartRemovedV2
  | SessionAgentSelectedV2
  | SessionModelSelectedV2
  | SessionMovedV2
  | SessionRenamedV2
  | SessionUsageUpdatedV2
  | SessionDeletedV2
  | SessionForkedV2
  | SessionInputPromotedV2
  | SessionInputAdmittedV2
  | SessionExecutionStartedV2
  | SessionExecutionSucceededV2
  | SessionExecutionFailedV2
  | SessionExecutionInterruptedV2
  | SessionInstructionsUpdatedV2
  | SessionSyntheticV2
  | SessionSkillActivatedV2
  | SessionShellStartedV2
  | SessionShellEndedV2
  | SessionStepStartedV2
  | SessionStepEndedV2
  | SessionStepFailedV2
  | SessionTextStartedV2
  | SessionTextDeltaV2
  | SessionTextEndedV2
  | SessionReasoningStartedV2
  | SessionReasoningDeltaV2
  | SessionReasoningEndedV2
  | SessionToolInputStartedV2
  | SessionToolInputDeltaV2
  | SessionToolInputEndedV2
  | SessionToolCalledV2
  | SessionToolProgressV2
  | SessionToolSuccessV2
  | SessionToolFailedV2
  | SessionRetryScheduledV2
  | SessionCompactionAdmittedV2
  | SessionCompactionStartedV2
  | SessionCompactionDeltaV2
  | SessionCompactionEndedV2
  | SessionCompactionFailedV2
  | SessionRevertStagedV2
  | SessionRevertClearedV2
  | SessionRevertCommittedV2
  | FilesystemChangedV2
  | ReferenceUpdatedV2
  | PermissionV2AskedV2
  | PermissionV2RepliedV2
  | PluginAddedV2
  | PluginUpdatedV2
  | ProjectDirectoriesUpdatedV2
  | CommandUpdatedV2
  | ConfigUpdatedV2
  | SkillUpdatedV2
  | PtyCreatedV2
  | PtyUpdatedV2
  | PtyExitedV2
  | PtyDeletedV2
  | ShellCreatedV2
  | ShellExitedV2
  | ShellDeletedV2
  | QuestionV2AskedV2
  | QuestionV2RepliedV2
  | QuestionV2RejectedV2
  | FormCreatedV2
  | FormRepliedV2
  | FormCancelledV2
  | SessionStatusV22
  | SessionIdleV2
  | TuiPromptAppendV2
  | TuiCommandExecuteV2
  | TuiToastShowV2
  | TuiSessionSelectV2
  | InstallationUpdatedV2
  | InstallationUpdateAvailableV2
  | VcsBranchUpdatedV2
  | McpStatusChangedV2
  | McpResourcesChangedV2
  | PermissionAskedV2
  | PermissionRepliedV2
  | QuestionAskedV2
  | QuestionRepliedV2
  | QuestionRejectedV2
  | SessionErrorV2
  | V2EventServerConnected

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

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

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

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

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

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

export type SessionRevertV2 = {
  messageID: string
  partID?: string
  snapshot?: string
  files?: Array<FileDiffInfoV2>
}

export type SessionInfoV2 = {
  id: string
  parentID?: string
  fork?: {
    sessionID: string
    messageID?: string
  }
  projectID: string
  agent?: string
  model?: ModelRef
  cost: MoneyUsd
  tokens: TokenUsageInfo
  time: {
    created: number
    updated: number
    archived?: number
  }
  title: string
  location: LocationRefV2
  subpath?: string
  revert?: SessionRevertV2
}

export type PromptBase64V2 = string

export type SessionPendingUserV2 = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "user"
  data: SessionPendingUserData
  delivery: "steer" | "queue"
}

export type SessionPendingSyntheticV2 = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "synthetic"
  data: SessionPendingSyntheticData
  delivery: "steer" | "queue"
}

export type SessionPendingCompactionV2 = {
  admittedSeq: number
  id: string
  sessionID: string
  timeCreated: number
  type: "compaction"
}

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

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

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

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

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

export type SessionMessageSkillV2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  type: "skill"
  skill: string
  name: string
  text: string
}

export type SessionMessageShellV2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "shell"
  shellID: string
  command: string
  status: "running" | "exited" | "timeout" | "killed"
  exit?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  output?: {
    output: string
    cursor: number
    size: number
    truncated: boolean
  }
}

export type SessionMessageAssistantRetryV2 = {
  attempt: number
  at: number
  error: SessionStructuredError
}

export type SessionMessageAssistantV2 = {
  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?: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
  cost?: MoneyUsd
  tokens?: TokenUsageInfo
  error?: SessionStructuredError
  retry?: SessionMessageAssistantRetryV2
}

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

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

export type SessionMessageCompactionFailedV2 = {
  type: "compaction"
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
  }
  status: "failed"
  reason: "auto" | "manual"
  error: SessionStructuredError
}

/**
 * Instruction entry key (lowercase alphanumerics plus . _ -)
 */
export type InstructionEntryKeyV2 = string

export type SessionAgentSelectedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.agent.selected"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    agent: string
  }
}

export type SessionModelSelectedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.model.selected"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    model: ModelRef
  }
}

export type SessionMovedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.moved"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    location: LocationRefV2
    projectID?: string
    subpath?: string
  }
}

export type SessionRenamedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.renamed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    title: string
  }
}

export type SessionDeletedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.deleted"
  durable: {
    aggregateID: string
    seq: number
    version: 2
  }
  location?: LocationRefV2
  data: {
    sessionID: string
  }
}

export type SessionForkedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.forked"
  durable: {
    aggregateID: string
    seq: number
    version: 2
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    parentID: string
    parentSeq: number
    from?: string
  }
}

export type SessionInputPromotedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.input.promoted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    inputID: string
  }
}

export type SessionPendingUserData1 = {
  text: string
  files?: Array<PromptFileAttachment>
  agents?: Array<PromptAgentAttachment>
  metadata?: {
    [key: string]: unknown
  }
}

export type SessionPendingUserMessageV2 = {
  type: "user"
  data: SessionPendingUserData1
  delivery: "steer" | "queue"
}

export type SessionPendingSyntheticData1 = {
  text: string
  description?: string
  metadata?: {
    [key: string]: unknown
  }
}

export type SessionPendingSyntheticMessageV2 = {
  type: "synthetic"
  data: SessionPendingSyntheticData1
  delivery: "steer" | "queue"
}

export type SessionInputAdmittedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.input.admitted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    inputID: string
    input: SessionPendingMessage
  }
}

export type SessionExecutionStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
  }
}

export type SessionExecutionSucceededV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.succeeded"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
  }
}

export type SessionExecutionFailedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    error: SessionStructuredError
  }
}

export type SessionExecutionInterruptedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.interrupted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    reason: "user" | "shutdown" | "superseded"
  }
}

export type SessionInstructionsUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.instructions.updated"
  durable: {
    aggregateID: string
    seq: number
    version: 2
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    delta: {
      [key: string]: string | "removed"
    }
  }
}

export type SessionSyntheticV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.synthetic"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    text: string
    description?: string
    metadata?: {
      [key: string]: unknown
    }
  }
}

export type SessionSkillActivatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.skill.activated"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    id: string
    name: string
    text: string
  }
}

export type ShellInfoV2 = {
  id: string
  status: "running" | "exited" | "timeout" | "killed"
  command: string
  cwd: string
  shell: string
  file: string
  pid?: number
  exit?: number
  metadata: {
    [key: string]: unknown
  }
  time: {
    started: number
    completed?: number
  }
}

export type SessionShellStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.shell.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    shell: ShellInfoV2
  }
}

export type SessionShellEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.shell.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    shell: ShellInfoV2
    output: {
      output: string
      cursor: number
      size: number
      truncated: boolean
    }
  }
}

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

export type SessionStepEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.step.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    finish: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown"
    cost: MoneyUsd
    tokens: TokenUsageInfo
    snapshot?: string
    files?: Array<string>
  }
}

export type SessionStepFailedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.step.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    error: SessionStructuredError
    cost?: MoneyUsd
    tokens?: TokenUsageInfo
  }
}

export type SessionTextStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
  }
}

export type SessionTextEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
  }
}

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

export type SessionReasoningStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    state?: SessionMessageProviderState3
  }
}

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

export type SessionReasoningEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    text: string
    state?: SessionMessageProviderState4
  }
}

export type SessionToolInputStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.input.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    name: string
  }
}

export type SessionToolInputEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.input.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    text: string
  }
}

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

export type SessionToolCalledV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.called"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    input: {
      [key: string]: unknown
    }
    executed: boolean
    state?: SessionMessageProviderState5
  }
}

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

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

export type SessionToolSuccessV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.success"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState6
  }
}

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

export type SessionToolFailedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionStructuredError
    result?: unknown
    executed: boolean
    resultState?: SessionMessageProviderState7
  }
}

export type SessionRetryScheduledV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.retry.scheduled"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    attempt: number
    at: number
    error: SessionStructuredError
  }
}

export type SessionCompactionAdmittedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.admitted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    inputID: string
  }
}

export type SessionCompactionStartedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.started"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    reason: "auto" | "manual"
    recent: string
    inputID?: string
  }
}

export type SessionCompactionEndedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.ended"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    reason: "auto" | "manual"
    text: string
    recent: string
  }
}

export type SessionCompactionFailedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.failed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    reason: "auto" | "manual"
    error: SessionStructuredError
    inputID?: string
  }
}

export type SessionRevertStagedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.staged"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    revert: SessionRevertV2
  }
}

export type SessionRevertClearedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.cleared"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
  }
}

export type SessionRevertCommittedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.committed"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    to: string
  }
}

export type SessionUsageRecordedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.usage.recorded"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    source: "title" | "compaction"
    cost: MoneyUsd
    tokens: TokenUsageInfo
  }
}

/**
 * Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.
 */
export type EventLogSyncedV2 = {
  type: "log.synced"
  aggregateID: string
  seq?: number
}

export type McpResourceV2 = {
  server: string
  name: string
  uri: string
  description?: string
  mimeType?: string
}

export type McpResourceCatalogV2 = {
  resources: Array<McpResourceV2>
  templates: Array<McpResourceTemplate>
}

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

export type FormWhenV2 = {
  key: string
  op: "eq" | "neq"
  value: string | number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN" | boolean
}

export type FormStringFieldV2 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhenV2>
  type: "string"
  format?: "email" | "uri" | "date" | "date-time"
  minLength?: number
  maxLength?: number
  pattern?: string
  placeholder?: string
  default?: string
  options?: Array<FormOption>
  custom?: boolean
}

export type FormMultiselectFieldV2 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhenV2>
  type: "multiselect"
  options: Array<FormOption>
  minItems?: number
  maxItems?: number
  custom?: boolean
  default?: Array<string>
}

export type FormFieldsV2 = [FormField, FormField]

export type FormInfoV2 = {
  id: string
  sessionID: string
  title: string
  metadata?: FormMetadata
  fields: FormFieldsV2
}

export type FormCreatePayloadV2 = {
  id?: string | null
  title: string
  metadata?: FormMetadata
  fields: FormFieldsV2
}

export type FormValueV2 =
  | string
  | number
  | "NaN"
  | "Infinity"
  | "-Infinity"
  | "Infinity"
  | "-Infinity"
  | "NaN"
  | boolean
  | Array<string>

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

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

export type ModelsDevRefreshedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "models-dev.refreshed"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type IntegrationUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "integration.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type IntegrationConnectionUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "integration.connection.updated"
  location?: LocationRefV2
  data: {
    integrationID: string
  }
}

export type CatalogUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "catalog.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type AgentUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "agent.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type SessionV1InfoV2 = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<FileDiffLegacyInfo>
  }
  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 SessionCreatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.created"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    info: SessionV1InfoV2
  }
}

export type SessionUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.updated"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    info: SessionV1InfoV2
  }
}

export type SessionDeleted1 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.deleted"
  durable: {
    aggregateID: string
    seq: number
    version: 1
  }
  location?: LocationRefV2
  data: {
    sessionID: string
    info: SessionV1InfoV2
  }
}

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

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

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

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

export type SessionUsageUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.usage.updated"
  location?: LocationRefV2
  data: {
    sessionID: string
    cost: MoneyUsd
    tokens: TokenUsageInfo
  }
}

export type SessionTextDeltaV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.text.delta"
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type SessionReasoningDeltaV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.delta"
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    ordinal: number
    delta: string
  }
}

export type SessionToolInputDeltaV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.input.delta"
  location?: LocationRefV2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    delta: string
  }
}

export type SessionCompactionDeltaV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.compaction.delta"
  location?: LocationRefV2
  data: {
    sessionID: string
    text: string
  }
}

export type FilesystemChangedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "filesystem.changed"
  location?: LocationRefV2
  data: {
    file: string
    event: "add" | "change" | "unlink"
  }
}

export type ReferenceUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "reference.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type PermissionV2AskedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.asked"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
    action: string
    resources: Array<string>
    save?: Array<string>
    metadata?: {
      [key: string]: unknown
    }
    source?: PermissionV2SourceV2
  }
}

export type PermissionV2RepliedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.v2.replied"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
    reply: PermissionV2Reply
  }
}

export type PluginAddedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "plugin.added"
  location?: LocationRefV2
  data: {
    id: string
  }
}

export type PluginUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "plugin.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type ProjectDirectoriesUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "project.directories.updated"
  location?: LocationRefV2
  data: {
    projectID: string
  }
}

export type CommandUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "command.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type ConfigUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "config.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type SkillUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "skill.updated"
  location?: LocationRefV2
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

export type PtyCreatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.created"
  location?: LocationRefV2
  data: {
    info: PtyV2
  }
}

export type PtyUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.updated"
  location?: LocationRefV2
  data: {
    info: PtyV2
  }
}

export type PtyExitedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.exited"
  location?: LocationRefV2
  data: {
    id: string
    exitCode: number
  }
}

export type PtyDeletedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "pty.deleted"
  location?: LocationRefV2
  data: {
    id: string
  }
}

export type ShellCreatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.created"
  location?: LocationRefV2
  data: {
    info: ShellInfoV2
  }
}

export type ShellExitedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.exited"
  location?: LocationRefV2
  data: {
    id: string
    exit?: number
    status: "running" | "exited" | "timeout" | "killed"
  }
}

export type ShellDeletedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.deleted"
  location?: LocationRefV2
  data: {
    id: string
  }
}

export type QuestionV2AskedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.asked"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionV2Info>
    tool?: QuestionV2Tool
  }
}

export type QuestionV2RepliedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.replied"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
    answers: Array<QuestionV2Answer>
  }
}

export type QuestionV2RejectedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.v2.rejected"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
  }
}

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

export type FormStringField1 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "string"
  format?: "email" | "uri" | "date" | "date-time"
  minLength?: number
  maxLength?: number
  pattern?: string
  placeholder?: string
  default?: string
  options?: Array<FormOption>
  custom?: boolean
}

export type FormBooleanField1 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "boolean"
  default?: boolean
}

export type FormMultiselectField1 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen1>
  type: "multiselect"
  options: Array<FormOption>
  minItems?: number
  maxItems?: number
  custom?: boolean
  default?: Array<string>
}

export type FormField1 =
  | FormStringField1
  | FormNumberField1
  | FormIntegerField1
  | FormBooleanField1
  | FormMultiselectField1
  | FormExternalField

export type FormFields1 = [FormField1, FormField1]

export type FormInfo1 = {
  id: string
  sessionID: string
  title: string
  metadata?: FormMetadata1
  fields: FormFields1
}

export type FormCreatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.created"
  location?: LocationRefV2
  data: {
    form: FormInfo1
  }
}

export type FormAnswer1 = {
  [key: string]: FormValue1
}

export type FormRepliedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.replied"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
    answer: FormAnswer1
  }
}

export type FormCancelledV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.cancelled"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
  }
}

export type SessionIdleV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.idle"
  location?: LocationRefV2
  data: {
    sessionID: string
  }
}

export type TuiPromptAppendV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.prompt.append"
  location?: LocationRefV2
  data: {
    text: string
  }
}

export type TuiCommandExecuteV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.command.execute"
  location?: LocationRefV2
  data: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.background"
      | "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 TuiToastShowV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.toast.show"
  location?: LocationRefV2
  data: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number | null
  }
}

export type TuiSessionSelectV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.session.select"
  location?: LocationRefV2
  data: {
    /**
     * Session ID to navigate to
     */
    sessionID: string
  }
}

export type InstallationUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "installation.updated"
  location?: LocationRefV2
  data: {
    version: string
  }
}

export type InstallationUpdateAvailableV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "installation.update-available"
  location?: LocationRefV2
  data: {
    version: string
  }
}

export type VcsBranchUpdatedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "vcs.branch.updated"
  location?: LocationRefV2
  data: {
    branch?: string
  }
}

export type McpStatusChangedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.status.changed"
  location?: LocationRefV2
  data: {
    server: string
  }
}

export type McpResourcesChangedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "mcp.resources.changed"
  location?: LocationRefV2
  data: {
    server: string
  }
}

export type PermissionAskedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.asked"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
    permission: string
    patterns: Array<string>
    metadata: {
      [key: string]: unknown
    }
    always: Array<string>
    tool?: {
      messageID: string
      callID: string
    } | null
  }
}

export type PermissionRepliedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "permission.replied"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
    reply: "once" | "always" | "reject"
  }
}

export type QuestionAskedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.asked"
  location?: LocationRefV2
  data: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionInfoV2>
    tool?: QuestionToolV2 | null
  }
}

export type QuestionRepliedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.replied"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
    answers: Array<QuestionAnswer>
  }
}

export type QuestionRejectedV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.rejected"
  location?: LocationRefV2
  data: {
    sessionID: string
    requestID: string
  }
}

export type SessionErrorV2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.error"
  location?: LocationRefV2
  data: {
    sessionID?: string | null
    error?:
      | ProviderAuthError
      | UnknownError1V2
      | MessageOutputLengthErrorV2
      | MessageAbortedError
      | StructuredOutputErrorV2
      | ContextOverflowErrorV2
      | ContentFilterError
      | ApiErrorV2
      | null
  }
}

export type V2EventServerConnected = {
  id: string
  metadata?: {
    [key: string]: unknown
  } | null
  location?: LocationRefV2 | null
  type: "server.connected"
  data:
    | {
        [key: string]: unknown
      }
    | Array<unknown>
}

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

export type ShellInfo1 = {
  id: string
  status: "running" | "exited" | "timeout" | "killed"
  command: string
  cwd: string
  shell: string
  file: string
  pid?: number
  exit?: number
  metadata: {
    [key: string]: unknown
  }
  time: {
    started: number
    completed?: number
  }
}

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

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

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 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<FileDiffLegacyInfo>
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2HealthGetError = V2HealthGetErrors[keyof V2HealthGetErrors]

export type V2HealthGetResponses = {
  /**
   * ServiceHealth
   */
  200: ServiceHealthV2
}

export type V2HealthGetResponse = V2HealthGetResponses[keyof V2HealthGetResponses]

export type V2HealthStopData = {
  body: ServiceStopRequest
  path?: never
  query?: never
  url: "/api/service/stop"
}

export type V2HealthStopErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2HealthStopError = V2HealthStopErrors[keyof V2HealthStopErrors]

export type V2HealthStopResponses = {
  /**
   * ServiceStopResponse
   */
  200: ServiceStopResponse
}

export type V2HealthStopResponse = V2HealthStopResponses[keyof V2HealthStopResponses]

export type V2ServerGetData = {
  body?: never
  path?: never
  query?: never
  url: "/api/server"
}

export type V2ServerGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ServerGetError = V2ServerGetErrors[keyof V2ServerGetErrors]

export type V2ServerGetResponses = {
  /**
   * Success
   */
  200: {
    urls: Array<string>
  }
}

export type V2ServerGetResponse = V2ServerGetResponses[keyof V2ServerGetResponses]

export type V2LocationGetData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/location"
}

export type V2LocationGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2LocationGetError = V2LocationGetErrors[keyof V2LocationGetErrors]

export type V2LocationGetResponses = {
  /**
   * Location.Info
   */
  200: LocationInfoV2
}

export type V2LocationGetResponse = V2LocationGetResponses[keyof V2LocationGetResponses]

export type V2AgentListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/agent"
}

export type V2AgentListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2AgentListError = V2AgentListErrors[keyof V2AgentListErrors]

export type V2AgentListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<AgentInfoV2>
  }
}

export type V2AgentListResponse = V2AgentListResponses[keyof V2AgentListResponses]

export type V2PluginListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/plugin"
}

export type V2PluginListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PluginListError = V2PluginListErrors[keyof V2PluginListErrors]

export type V2PluginListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<PluginInfo>
  }
}

export type V2PluginListResponse = V2PluginListResponses[keyof V2PluginListResponses]

export type V2SessionListData = {
  body?: never
  path?: never
  query?: {
    workspace?: string | null
    /**
     * Maximum number of sessions to return. Defaults to the newest 50 sessions.
     */
    limit?: number | null
    /**
     * Session order for the first page. Use desc for newest first or asc for oldest first.
     */
    order?: "asc" | "desc" | null
    search?: string | null
    parentID?: string | "null" | null
    directory?: string | null
    project?: string | null
    subpath?: string | null
    cursor?: string | null
  }
  url: "/api/session"
}

export type V2SessionListErrors = {
  /**
   * InvalidCursorError | InvalidRequestError
   */
  400: InvalidCursorError | InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SessionListError = V2SessionListErrors[keyof V2SessionListErrors]

export type V2SessionListResponses = {
  /**
   * SessionsResponse
   */
  200: SessionsResponseV2
}

export type V2SessionListResponse = V2SessionListResponses[keyof V2SessionListResponses]

export type V2SessionCreateData = {
  body: {
    id?: string | null
    agent?: string | null
    model?: ModelRef | null
    location?: LocationRefV2 | null
  }
  path?: never
  query?: never
  url: "/api/session"
}

export type V2SessionCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SessionCreateError = V2SessionCreateErrors[keyof V2SessionCreateErrors]

export type V2SessionCreateResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInfoV2
  }
}

export type V2SessionCreateResponse = V2SessionCreateResponses[keyof V2SessionCreateResponses]

export type V2SessionActiveData = {
  body?: never
  path?: never
  query?: never
  url: "/api/session/active"
}

export type V2SessionActiveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 V2SessionRemoveData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}"
}

export type V2SessionRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionRemoveError = V2SessionRemoveErrors[keyof V2SessionRemoveErrors]

export type V2SessionRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionRemoveResponse = V2SessionRemoveResponses[keyof V2SessionRemoveResponses]

export type V2SessionGetData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}"
}

export type V2SessionGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionGetError = V2SessionGetErrors[keyof V2SessionGetErrors]

export type V2SessionGetResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInfoV2
  }
}

export type V2SessionGetResponse = V2SessionGetResponses[keyof V2SessionGetResponses]

export type V2SessionForkData = {
  body: {
    messageID?: string | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/fork"
}

export type V2SessionForkErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | MessageNotFoundError
   */
  404: MessageNotFoundError | SessionNotFoundError
}

export type V2SessionForkError = V2SessionForkErrors[keyof V2SessionForkErrors]

export type V2SessionForkResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInfoV2
  }
}

export type V2SessionForkResponse = V2SessionForkResponses[keyof V2SessionForkResponses]

export type V2SessionSwitchAgentData = {
  body: {
    agent: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/agent"
}

export type V2SessionSwitchAgentErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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: InvalidRequestErrorV2
  /**
   * 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 V2SessionRenameData = {
  body: {
    title: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/rename"
}

export type V2SessionRenameErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionRenameError = V2SessionRenameErrors[keyof V2SessionRenameErrors]

export type V2SessionRenameResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionRenameResponse = V2SessionRenameResponses[keyof V2SessionRenameResponses]

export type V2SessionMoveData = {
  body: LocationRefV2
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/move"
}

export type V2SessionMoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionMoveError = V2SessionMoveErrors[keyof V2SessionMoveErrors]

export type V2SessionMoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionMoveResponse = V2SessionMoveResponses[keyof V2SessionMoveResponses]

export type V2SessionPromptData = {
  body: {
    id?: string | null
    text: string
    files?: Array<PromptInputFileAttachment>
    agents?: Array<PromptAgentAttachment>
    metadata?: {
      [key: string]: unknown
    }
    delivery?: "steer" | "queue" | null
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/prompt"
}

export type V2SessionPromptErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]

export type V2SessionPromptResponses = {
  /**
   * Success
   */
  200: {
    data: SessionPendingUserV2
  }
}

export type V2SessionPromptResponse = V2SessionPromptResponses[keyof V2SessionPromptResponses]

export type V2SessionCommandData = {
  body: {
    id?: string | null
    command: string
    arguments?: string | null
    agent?: string | null
    model?: ModelRef | null
    files?: Array<PromptInputFileAttachment>
    agents?: Array<PromptAgentAttachment>
    delivery?: "steer" | "queue" | null
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/command"
}

export type V2SessionCommandErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | CommandNotFoundError
   */
  404: CommandNotFoundError | SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictErrorV2
  /**
   * CommandEvaluationError
   */
  500: CommandEvaluationError
}

export type V2SessionCommandError = V2SessionCommandErrors[keyof V2SessionCommandErrors]

export type V2SessionCommandResponses = {
  /**
   * Success
   */
  200: {
    data: SessionPendingUserV2
  }
}

export type V2SessionCommandResponse = V2SessionCommandResponses[keyof V2SessionCommandResponses]

export type V2SessionSkillData = {
  body: {
    id?: string | null
    skill: string
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/skill"
}

export type V2SessionSkillErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | SkillNotFoundError
   */
  404: SkillNotFoundError | SessionNotFoundError
}

export type V2SessionSkillError = V2SessionSkillErrors[keyof V2SessionSkillErrors]

export type V2SessionSkillResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionSkillResponse = V2SessionSkillResponses[keyof V2SessionSkillResponses]

export type V2SessionSyntheticData = {
  body: {
    id?: string | null
    text: string
    description?: string | null
    metadata?: {
      [key: string]: unknown
    }
    delivery?: "steer" | "queue" | null
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/synthetic"
}

export type V2SessionSyntheticErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionSyntheticError = V2SessionSyntheticErrors[keyof V2SessionSyntheticErrors]

export type V2SessionSyntheticResponses = {
  /**
   * Success
   */
  200: {
    data: SessionPendingSyntheticV2
  }
}

export type V2SessionSyntheticResponse = V2SessionSyntheticResponses[keyof V2SessionSyntheticResponses]

export type V2SessionShellData = {
  body: {
    id?: string | null
    command: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/shell"
}

export type V2SessionShellErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionShellError = V2SessionShellErrors[keyof V2SessionShellErrors]

export type V2SessionShellResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionShellResponse = V2SessionShellResponses[keyof V2SessionShellResponses]

export type V2SessionCompactData = {
  body: {
    id?: string | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/compact"
}

export type V2SessionCompactErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]

export type V2SessionCompactResponses = {
  /**
   * Success
   */
  200: {
    data: SessionPendingCompactionV2
  }
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

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 | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/revert/stage"
}

export type V2SessionRevertStageErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * MessageNotFoundError | SessionNotFoundError
   */
  404: MessageNotFoundError | SessionNotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2SessionRevertStageError = V2SessionRevertStageErrors[keyof V2SessionRevertStageErrors]

export type V2SessionRevertStageResponses = {
  /**
   * Success
   */
  200: {
    data: SessionRevertV2
  }
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * SessionBusyError
   */
  409: SessionBusyError
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]

export type V2SessionContextResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionMessageInfo>
  }
}

export type V2SessionContextResponse = V2SessionContextResponses[keyof V2SessionContextResponses]

export type V2SessionPendingListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/pending"
}

export type V2SessionPendingListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionPendingListError = V2SessionPendingListErrors[keyof V2SessionPendingListErrors]

export type V2SessionPendingListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionPendingInfo>
  }
}

export type V2SessionPendingListResponse = V2SessionPendingListResponses[keyof V2SessionPendingListResponses]

export type V2SessionInstructionsEntryListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/instructions/entries"
}

export type V2SessionInstructionsEntryListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionInstructionsEntryListError =
  V2SessionInstructionsEntryListErrors[keyof V2SessionInstructionsEntryListErrors]

export type V2SessionInstructionsEntryListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<InstructionEntryInfo>
  }
}

export type V2SessionInstructionsEntryListResponse =
  V2SessionInstructionsEntryListResponses[keyof V2SessionInstructionsEntryListResponses]

export type V2SessionInstructionsEntryRemoveData = {
  body?: never
  path: {
    sessionID: string
    key: InstructionEntryKeyV2
  }
  query?: never
  url: "/api/session/{sessionID}/instructions/entries/{key}"
}

export type V2SessionInstructionsEntryRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionInstructionsEntryRemoveError =
  V2SessionInstructionsEntryRemoveErrors[keyof V2SessionInstructionsEntryRemoveErrors]

export type V2SessionInstructionsEntryRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionInstructionsEntryRemoveResponse =
  V2SessionInstructionsEntryRemoveResponses[keyof V2SessionInstructionsEntryRemoveResponses]

export type V2SessionInstructionsEntryPutData = {
  body: {
    value: unknown
  }
  path: {
    sessionID: string
    key: InstructionEntryKeyV2
  }
  query?: never
  url: "/api/session/{sessionID}/instructions/entries/{key}"
}

export type V2SessionInstructionsEntryPutErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * InstructionEntryValueTooLargeError
   */
  413: InstructionEntryValueTooLargeError
}

export type V2SessionInstructionsEntryPutError =
  V2SessionInstructionsEntryPutErrors[keyof V2SessionInstructionsEntryPutErrors]

export type V2SessionInstructionsEntryPutResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionInstructionsEntryPutResponse =
  V2SessionInstructionsEntryPutResponses[keyof V2SessionInstructionsEntryPutResponses]

export type V2SessionGenerateData = {
  body: {
    prompt: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/generate"
}

export type V2SessionGenerateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2SessionGenerateError = V2SessionGenerateErrors[keyof V2SessionGenerateErrors]

export type V2SessionGenerateResponses = {
  /**
   * SessionGenerateResponse
   */
  200: SessionGenerateResponse
}

export type V2SessionGenerateResponse = V2SessionGenerateResponses[keyof V2SessionGenerateResponses]

export type V2SessionLogData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    after?: number | null
    follow?: "true" | "false" | null
  }
  url: "/api/experimental/session/{sessionID}/log"
}

export type V2SessionLogErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionLogError = V2SessionLogErrors[keyof V2SessionLogErrors]

export type V2SessionLogResponses = {
  /**
   * Success
   */
  200: {
    id: string | null
    event: string
    data: SessionLogItemJsonString
  }
}

export type V2SessionLogResponse = V2SessionLogResponses[keyof V2SessionLogResponses]

export type V2SessionInterruptData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/interrupt"
}

export type V2SessionInterruptErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 V2SessionBackgroundData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/background"
}

export type V2SessionBackgroundErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionBackgroundError = V2SessionBackgroundErrors[keyof V2SessionBackgroundErrors]

export type V2SessionBackgroundResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionBackgroundResponse = V2SessionBackgroundResponses[keyof V2SessionBackgroundResponses]

export type V2SessionMessageData = {
  body?: never
  path: {
    sessionID: string
    messageID: string
  }
  query?: never
  url: "/api/session/{sessionID}/message/{messageID}"
}

export type V2SessionMessageErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | MessageNotFoundError
   */
  404: MessageNotFoundError | SessionNotFoundError
}

export type V2SessionMessageError = V2SessionMessageErrors[keyof V2SessionMessageErrors]

export type V2SessionMessageResponses = {
  /**
   * Success
   */
  200: {
    data: SessionMessageInfo
  }
}

export type V2SessionMessageResponse = V2SessionMessageResponses[keyof V2SessionMessageResponses]

export type V2MessageListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    /**
     * Maximum number of messages to return. When omitted, the endpoint returns its default page size.
     */
    limit?: number | null
    /**
     * Message order for the first page. Use desc for newest first or asc for oldest first.
     */
    order?: "asc" | "desc" | null
    cursor?: string | null
  }
  url: "/api/session/{sessionID}/message"
}

export type V2MessageListErrors = {
  /**
   * InvalidCursorError | InvalidRequestError
   */
  400: InvalidCursorError | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2MessageListError = V2MessageListErrors[keyof V2MessageListErrors]

export type V2MessageListResponses = {
  /**
   * SessionMessagesResponse
   */
  200: SessionMessagesResponseV2
}

export type V2MessageListResponse = V2MessageListResponses[keyof V2MessageListResponses]

export type V2ModelListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/model"
}

export type V2ModelListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]

export type V2ModelListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<ModelInfo>
  }
}

export type V2ModelListResponse = V2ModelListResponses[keyof V2ModelListResponses]

export type V2ModelDefaultData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/model/default"
}

export type V2ModelDefaultErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ModelDefaultError = V2ModelDefaultErrors[keyof V2ModelDefaultErrors]

export type V2ModelDefaultResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: ModelInfo | null
  }
}

export type V2ModelDefaultResponse = V2ModelDefaultResponses[keyof V2ModelDefaultResponses]

export type V2GenerateTextData = {
  body: {
    prompt: string
    model?: ModelRef | null
  }
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/generate"
}

export type V2GenerateTextErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2GenerateTextError = V2GenerateTextErrors[keyof V2GenerateTextErrors]

export type V2GenerateTextResponses = {
  /**
   * GenerateTextResponse
   */
  200: GenerateTextResponse
}

export type V2GenerateTextResponse = V2GenerateTextResponses[keyof V2GenerateTextResponses]

export type V2ProviderListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/provider"
}

export type V2ProviderListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]

export type V2ProviderListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<ProviderV2Info>
  }
}

export type V2ProviderListResponse = V2ProviderListResponses[keyof V2ProviderListResponses]

export type V2ProviderGetData = {
  body?: never
  path: {
    providerID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/provider/{providerID}"
}

export type V2ProviderGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ProviderNotFoundError
   */
  404: ProviderNotFoundError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]

export type V2ProviderGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: ProviderV2Info
  }
}

export type V2ProviderGetResponse = V2ProviderGetResponses[keyof V2ProviderGetResponses]

export type V2IntegrationListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration"
}

export type V2IntegrationListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationListError = V2IntegrationListErrors[keyof V2IntegrationListErrors]

export type V2IntegrationListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<IntegrationInfo>
  }
}

export type V2IntegrationListResponse = V2IntegrationListResponses[keyof V2IntegrationListResponses]

export type V2IntegrationGetData = {
  body?: never
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}"
}

export type V2IntegrationGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationGetError = V2IntegrationGetErrors[keyof V2IntegrationGetErrors]

export type V2IntegrationGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: IntegrationInfo | null
  }
}

export type V2IntegrationGetResponse = V2IntegrationGetResponses[keyof V2IntegrationGetResponses]

export type V2ExperimentalIntegrationWellknownAddData = {
  body: {
    url: string
  }
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/experimental/integration/wellknown"
}

export type V2ExperimentalIntegrationWellknownAddErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ExperimentalIntegrationWellknownAddError =
  V2ExperimentalIntegrationWellknownAddErrors[keyof V2ExperimentalIntegrationWellknownAddErrors]

export type V2ExperimentalIntegrationWellknownAddResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2ExperimentalIntegrationWellknownAddResponse =
  V2ExperimentalIntegrationWellknownAddResponses[keyof V2ExperimentalIntegrationWellknownAddResponses]

export type V2IntegrationConnectKeyData = {
  body: {
    key: string
    label?: string | null
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/key"
}

export type V2IntegrationConnectKeyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationConnectKeyError = V2IntegrationConnectKeyErrors[keyof V2IntegrationConnectKeyErrors]

export type V2IntegrationConnectKeyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationConnectKeyResponse = V2IntegrationConnectKeyResponses[keyof V2IntegrationConnectKeyResponses]

export type V2IntegrationOauthConnectData = {
  body: {
    methodID: string
    inputs: {
      [key: string]: string
    }
    label?: string | null
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/oauth"
}

export type V2IntegrationOauthConnectErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationOauthConnectError = V2IntegrationOauthConnectErrors[keyof V2IntegrationOauthConnectErrors]

export type V2IntegrationOauthConnectResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: IntegrationAttempt
  }
}

export type V2IntegrationOauthConnectResponse =
  V2IntegrationOauthConnectResponses[keyof V2IntegrationOauthConnectResponses]

export type V2IntegrationOauthCancelData = {
  body?: never
  path: {
    integrationID: string
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/oauth/{attemptID}"
}

export type V2IntegrationOauthCancelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationOauthCancelError = V2IntegrationOauthCancelErrors[keyof V2IntegrationOauthCancelErrors]

export type V2IntegrationOauthCancelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationOauthCancelResponse =
  V2IntegrationOauthCancelResponses[keyof V2IntegrationOauthCancelResponses]

export type V2IntegrationOauthStatusData = {
  body?: never
  path: {
    integrationID: string
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/oauth/{attemptID}"
}

export type V2IntegrationOauthStatusErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationOauthStatusError = V2IntegrationOauthStatusErrors[keyof V2IntegrationOauthStatusErrors]

export type V2IntegrationOauthStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: IntegrationAttemptStatus
  }
}

export type V2IntegrationOauthStatusResponse =
  V2IntegrationOauthStatusResponses[keyof V2IntegrationOauthStatusResponses]

export type V2IntegrationOauthCompleteData = {
  body: {
    code?: string | null
  }
  path: {
    integrationID: string
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/oauth/{attemptID}/complete"
}

export type V2IntegrationOauthCompleteErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationOauthCompleteError = V2IntegrationOauthCompleteErrors[keyof V2IntegrationOauthCompleteErrors]

export type V2IntegrationOauthCompleteResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationOauthCompleteResponse =
  V2IntegrationOauthCompleteResponses[keyof V2IntegrationOauthCompleteResponses]

export type V2IntegrationCommandConnectData = {
  body: {
    methodID: string
    label?: string | null
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/command"
}

export type V2IntegrationCommandConnectErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationCommandConnectError =
  V2IntegrationCommandConnectErrors[keyof V2IntegrationCommandConnectErrors]

export type V2IntegrationCommandConnectResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: IntegrationCommandAttempt
  }
}

export type V2IntegrationCommandConnectResponse =
  V2IntegrationCommandConnectResponses[keyof V2IntegrationCommandConnectResponses]

export type V2IntegrationCommandCancelData = {
  body?: never
  path: {
    integrationID: string
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/command/{attemptID}"
}

export type V2IntegrationCommandCancelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationCommandCancelError = V2IntegrationCommandCancelErrors[keyof V2IntegrationCommandCancelErrors]

export type V2IntegrationCommandCancelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationCommandCancelResponse =
  V2IntegrationCommandCancelResponses[keyof V2IntegrationCommandCancelResponses]

export type V2IntegrationCommandStatusData = {
  body?: never
  path: {
    integrationID: string
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/command/{attemptID}"
}

export type V2IntegrationCommandStatusErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2IntegrationCommandStatusError = V2IntegrationCommandStatusErrors[keyof V2IntegrationCommandStatusErrors]

export type V2IntegrationCommandStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: IntegrationCommandAttemptStatus
  }
}

export type V2IntegrationCommandStatusResponse =
  V2IntegrationCommandStatusResponses[keyof V2IntegrationCommandStatusResponses]

export type V2McpListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/mcp"
}

export type V2McpListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2McpListError = V2McpListErrors[keyof V2McpListErrors]

export type V2McpListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<McpServer>
  }
}

export type V2McpListResponse = V2McpListResponses[keyof V2McpListResponses]

export type V2McpResourceCatalogData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/mcp/resource"
}

export type V2McpResourceCatalogErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2McpResourceCatalogError = V2McpResourceCatalogErrors[keyof V2McpResourceCatalogErrors]

export type V2McpResourceCatalogResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: McpResourceCatalogV2
  }
}

export type V2McpResourceCatalogResponse = V2McpResourceCatalogResponses[keyof V2McpResourceCatalogResponses]

export type V2CredentialRemoveData = {
  body?: never
  path: {
    credentialID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/credential/{credentialID}"
}

export type V2CredentialRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 | null
      workspace?: string | null
    } | null
  }
  url: "/api/credential/{credentialID}"
}

export type V2CredentialUpdateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2CredentialUpdateError = V2CredentialUpdateErrors[keyof V2CredentialUpdateErrors]

export type V2CredentialUpdateResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2CredentialUpdateResponse = V2CredentialUpdateResponses[keyof V2CredentialUpdateResponses]

export type V2ProjectListData = {
  body?: never
  path?: never
  query?: never
  url: "/api/project"
}

export type V2ProjectListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ProjectListError = V2ProjectListErrors[keyof V2ProjectListErrors]

export type V2ProjectListResponses = {
  /**
   * Success
   */
  200: Array<Project>
}

export type V2ProjectListResponse = V2ProjectListResponses[keyof V2ProjectListResponses]

export type V2ProjectCurrentData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/project/current"
}

export type V2ProjectCurrentErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ProjectCurrentError = V2ProjectCurrentErrors[keyof V2ProjectCurrentErrors]

export type V2ProjectCurrentResponses = {
  /**
   * Project.Current
   */
  200: ProjectCurrent
}

export type V2ProjectCurrentResponse = V2ProjectCurrentResponses[keyof V2ProjectCurrentResponses]

export type V2ProjectDirectoriesData = {
  body?: never
  path: {
    projectID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/project/{projectID}/directories"
}

export type V2ProjectDirectoriesErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ProjectDirectoriesError = V2ProjectDirectoriesErrors[keyof V2ProjectDirectoriesErrors]

export type V2ProjectDirectoriesResponses = {
  /**
   * Project.Directories
   */
  200: ProjectDirectories
}

export type V2ProjectDirectoriesResponse = V2ProjectDirectoriesResponses[keyof V2ProjectDirectoriesResponses]

export type V2FormRequestListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/form/request"
}

export type V2FormRequestListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FormRequestListError = V2FormRequestListErrors[keyof V2FormRequestListErrors]

export type V2FormRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<FormInfoV2>
  }
}

export type V2FormRequestListResponse = V2FormRequestListResponses[keyof V2FormRequestListResponses]

export type V2SessionFormListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form"
}

export type V2SessionFormListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionFormListError = V2SessionFormListErrors[keyof V2SessionFormListErrors]

export type V2SessionFormListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<FormInfoV2>
  }
}

export type V2SessionFormListResponse = V2SessionFormListResponses[keyof V2SessionFormListResponses]

export type V2SessionFormCreateData = {
  body: FormCreatePayloadV2
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form"
}

export type V2SessionFormCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionFormCreateError = V2SessionFormCreateErrors[keyof V2SessionFormCreateErrors]

export type V2SessionFormCreateResponses = {
  /**
   * Success
   */
  200: {
    data: FormInfoV2
  }
}

export type V2SessionFormCreateResponse = V2SessionFormCreateResponses[keyof V2SessionFormCreateResponses]

export type V2SessionFormGetData = {
  body?: never
  path: {
    sessionID: string
    formID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form/{formID}"
}

export type V2SessionFormGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundError | SessionNotFoundError
}

export type V2SessionFormGetError = V2SessionFormGetErrors[keyof V2SessionFormGetErrors]

export type V2SessionFormGetResponses = {
  /**
   * Success
   */
  200: {
    data: FormInfoV2
  }
}

export type V2SessionFormGetResponse = V2SessionFormGetResponses[keyof V2SessionFormGetResponses]

export type V2SessionFormStateData = {
  body?: never
  path: {
    sessionID: string
    formID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form/{formID}/state"
}

export type V2SessionFormStateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundError | SessionNotFoundError
}

export type V2SessionFormStateError = V2SessionFormStateErrors[keyof V2SessionFormStateErrors]

export type V2SessionFormStateResponses = {
  /**
   * Success
   */
  200: {
    data: FormState
  }
}

export type V2SessionFormStateResponse = V2SessionFormStateResponses[keyof V2SessionFormStateResponses]

export type V2SessionFormReplyData = {
  body: FormReply
  path: {
    sessionID: string
    formID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form/{formID}/reply"
}

export type V2SessionFormReplyErrors = {
  /**
   * FormInvalidAnswerError | InvalidRequestError
   */
  400: FormInvalidAnswerError | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundError | SessionNotFoundError
  /**
   * FormAlreadySettledError
   */
  409: FormAlreadySettledError
}

export type V2SessionFormReplyError = V2SessionFormReplyErrors[keyof V2SessionFormReplyErrors]

export type V2SessionFormReplyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionFormReplyResponse = V2SessionFormReplyResponses[keyof V2SessionFormReplyResponses]

export type V2SessionFormCancelData = {
  body?: never
  path: {
    sessionID: string
    formID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form/{formID}/cancel"
}

export type V2SessionFormCancelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundError | SessionNotFoundError
  /**
   * FormAlreadySettledError
   */
  409: FormAlreadySettledError
}

export type V2SessionFormCancelError = V2SessionFormCancelErrors[keyof V2SessionFormCancelErrors]

export type V2SessionFormCancelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionFormCancelResponse = V2SessionFormCancelResponses[keyof V2SessionFormCancelResponses]

export type V2PermissionRequestListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/permission/request"
}

export type V2PermissionRequestListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PermissionRequestListError = V2PermissionRequestListErrors[keyof V2PermissionRequestListErrors]

export type V2PermissionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<PermissionV2RequestV2>
  }
}

export type V2PermissionRequestListResponse = V2PermissionRequestListResponses[keyof V2PermissionRequestListResponses]

export type V2PermissionSavedListData = {
  body?: never
  path?: never
  query?: {
    projectID?: string | null
  }
  url: "/api/permission/saved"
}

export type V2PermissionSavedListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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: InvalidRequestErrorV2
  /**
   * 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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionPermissionListError = V2SessionPermissionListErrors[keyof V2SessionPermissionListErrors]

export type V2SessionPermissionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionV2RequestV2>
  }
}

export type V2SessionPermissionListResponse = V2SessionPermissionListResponses[keyof V2SessionPermissionListResponses]

export type V2SessionPermissionCreateData = {
  body: {
    id?: string | null
    action: string
    resources: Array<string>
    save?: Array<string>
    metadata?: {
      [key: string]: unknown
    }
    source?: PermissionV2SourceV2
    agent?: string | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission"
}

export type V2SessionPermissionCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundError | SessionNotFoundError
}

export type V2SessionPermissionGetError = V2SessionPermissionGetErrors[keyof V2SessionPermissionGetErrors]

export type V2SessionPermissionGetResponses = {
  /**
   * Success
   */
  200: {
    data: PermissionV2RequestV2
  }
}

export type V2SessionPermissionGetResponse = V2SessionPermissionGetResponses[keyof V2SessionPermissionGetResponses]

export type V2SessionPermissionReplyData = {
  body: {
    reply: PermissionV2Reply
    message?: string | null
  }
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission/{requestID}/reply"
}

export type V2SessionPermissionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 | null
      workspace?: string | null
    } | null
  }
  url: "/api/fs/read/*"
}

export type V2FsReadErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 | null
      workspace?: string | null
    } | null
    path?: string | null
  }
  url: "/api/fs/list"
}

export type V2FsListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FsListError = V2FsListErrors[keyof V2FsListErrors]

export type V2FsListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<FileSystemEntry>
  }
}

export type V2FsListResponse = V2FsListResponses[keyof V2FsListResponses]

export type V2FsFindData = {
  body?: never
  path?: never
  query: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
    query: string
    type?: "file" | "directory"
    limit?: string | null
  }
  url: "/api/fs/find"
}

export type V2FsFindErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2FsFindError = V2FsFindErrors[keyof V2FsFindErrors]

export type V2FsFindResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<FileSystemEntry>
  }
}

export type V2FsFindResponse = V2FsFindResponses[keyof V2FsFindResponses]

export type V2CommandListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/command"
}

export type V2CommandListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2CommandListError = V2CommandListErrors[keyof V2CommandListErrors]

export type V2CommandListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<CommandInfo>
  }
}

export type V2CommandListResponse = V2CommandListResponses[keyof V2CommandListResponses]

export type V2SkillListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/skill"
}

export type V2SkillListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2SkillListError = V2SkillListErrors[keyof V2SkillListErrors]

export type V2SkillListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<SkillInfo>
  }
}

export type V2SkillListResponse = V2SkillListResponses[keyof V2SkillListResponses]

export type V2EventSubscribeData = {
  body?: never
  path?: never
  query?: never
  url: "/api/event"
}

export type V2EventSubscribeErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2EventSubscribeError = V2EventSubscribeErrors[keyof V2EventSubscribeErrors]

export type V2EventSubscribeResponses = {
  /**
   * Success
   */
  200: V2Event
}

export type V2EventSubscribeResponse = V2EventSubscribeResponses[keyof V2EventSubscribeResponses]

export type V2PtyListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty"
}

export type V2PtyListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PtyListError = V2PtyListErrors[keyof V2PtyListErrors]

export type V2PtyListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<PtyV2>
  }
}

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 | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty"
}

export type V2PtyCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2PtyCreateError = V2PtyCreateErrors[keyof V2PtyCreateErrors]

export type V2PtyCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: PtyV2
  }
}

export type V2PtyCreateResponse = V2PtyCreateResponses[keyof V2PtyCreateResponses]

export type V2PtyRemoveData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * 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 | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyGetError = V2PtyGetErrors[keyof V2PtyGetErrors]

export type V2PtyGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: PtyV2
  }
}

export type V2PtyGetResponse = V2PtyGetResponses[keyof V2PtyGetResponses]

export type V2PtyUpdateData = {
  body: {
    title?: string
    size?: {
      rows: number
      cols: number
    }
  }
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty/{ptyID}"
}

export type V2PtyUpdateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyUpdateError = V2PtyUpdateErrors[keyof V2PtyUpdateErrors]

export type V2PtyUpdateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: PtyV2
  }
}

export type V2PtyUpdateResponse = V2PtyUpdateResponses[keyof V2PtyUpdateResponses]

export type V2PtyConnectTokenData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/pty/{ptyID}/connect-token"
}

export type V2PtyConnectTokenErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ForbiddenError
   */
  403: ForbiddenError
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundError
}

export type V2PtyConnectTokenError = V2PtyConnectTokenErrors[keyof V2PtyConnectTokenErrors]

export type V2PtyConnectTokenResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: PtyTicketConnectTokenV2
  }
}

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: InvalidRequestErrorV2
  /**
   * 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 V2ShellListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/shell"
}

export type V2ShellListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ShellListError = V2ShellListErrors[keyof V2ShellListErrors]

export type V2ShellListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<ShellInfo1>
  }
}

export type V2ShellListResponse = V2ShellListResponses[keyof V2ShellListResponses]

export type V2ShellCreateData = {
  body: {
    command: string
    cwd?: string
    timeout: number
    metadata?: {
      [key: string]: unknown
    }
  }
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/shell"
}

export type V2ShellCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ShellCreateError = V2ShellCreateErrors[keyof V2ShellCreateErrors]

export type V2ShellCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: ShellInfo1
  }
}

export type V2ShellCreateResponse = V2ShellCreateResponses[keyof V2ShellCreateResponses]

export type V2ShellRemoveData = {
  body?: never
  path: {
    id: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/shell/{id}"
}

export type V2ShellRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundError
}

export type V2ShellRemoveError = V2ShellRemoveErrors[keyof V2ShellRemoveErrors]

export type V2ShellRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2ShellRemoveResponse = V2ShellRemoveResponses[keyof V2ShellRemoveResponses]

export type V2ShellGetData = {
  body?: never
  path: {
    id: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/shell/{id}"
}

export type V2ShellGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundError
}

export type V2ShellGetError = V2ShellGetErrors[keyof V2ShellGetErrors]

export type V2ShellGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: ShellInfo1
  }
}

export type V2ShellGetResponse = V2ShellGetResponses[keyof V2ShellGetResponses]

export type V2ShellTimeoutData = {
  body: {
    timeout: number
  }
  path: {
    id: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/shell/{id}/timeout"
}

export type V2ShellTimeoutErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundError
}

export type V2ShellTimeoutError = V2ShellTimeoutErrors[keyof V2ShellTimeoutErrors]

export type V2ShellTimeoutResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: ShellInfo1
  }
}

export type V2ShellTimeoutResponse = V2ShellTimeoutResponses[keyof V2ShellTimeoutResponses]

export type V2ShellOutputData = {
  body?: never
  path: {
    id: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
    cursor?: string
    limit?: string
  }
  url: "/api/shell/{id}/output"
}

export type V2ShellOutputErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundError
}

export type V2ShellOutputError = V2ShellOutputErrors[keyof V2ShellOutputErrors]

export type V2ShellOutputResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: {
      output: string
      cursor: number
      size: number
      truncated: boolean
    }
  }
}

export type V2ShellOutputResponse = V2ShellOutputResponses[keyof V2ShellOutputResponses]

export type V2QuestionRequestListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/question/request"
}

export type V2QuestionRequestListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2QuestionRequestListError = V2QuestionRequestListErrors[keyof V2QuestionRequestListErrors]

export type V2QuestionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<QuestionV2RequestV2>
  }
}

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: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
}

export type V2SessionQuestionListError = V2SessionQuestionListErrors[keyof V2SessionQuestionListErrors]

export type V2SessionQuestionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<QuestionV2RequestV2>
  }
}

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: InvalidRequestErrorV2
  /**
   * 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: InvalidRequestErrorV2
  /**
   * 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 | null
      workspace?: string | null
    } | null
  }
  url: "/api/reference"
}

export type V2ReferenceListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ReferenceListError = V2ReferenceListErrors[keyof V2ReferenceListErrors]

export type V2ReferenceListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<ReferenceInfo>
  }
}

export type V2ReferenceListResponse = V2ReferenceListResponses[keyof V2ReferenceListResponses]

export type V2ProjectCopyRemoveData = {
  body: {
    directory: string
    force: boolean
  }
  path: {
    projectID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/experimental/project/{projectID}/copy"
}

export type V2ProjectCopyRemoveErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyErrorV2 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

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 | null
      workspace?: string | null
    } | null
  }
  url: "/experimental/project/{projectID}/copy"
}

export type V2ProjectCopyCreateErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyErrorV2 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

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 | null
      workspace?: string | null
    } | null
  }
  url: "/experimental/project/{projectID}/copy/refresh"
}

export type V2ProjectCopyRefreshErrors = {
  /**
   * ProjectCopyError | InvalidRequestError
   */
  400: ProjectCopyErrorV2 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2ProjectCopyRefreshError = V2ProjectCopyRefreshErrors[keyof V2ProjectCopyRefreshErrors]

export type V2ProjectCopyRefreshResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2ProjectCopyRefreshResponse = V2ProjectCopyRefreshResponses[keyof V2ProjectCopyRefreshResponses]

export type V2VcsStatusData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/vcs/status"
}

export type V2VcsStatusErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2VcsStatusError = V2VcsStatusErrors[keyof V2VcsStatusErrors]

export type V2VcsStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<VcsFileStatusV2>
  }
}

export type V2VcsStatusResponse = V2VcsStatusResponses[keyof V2VcsStatusResponses]

export type V2VcsDiffData = {
  body?: never
  path?: never
  query: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
    mode: VcsMode
    context?: string | null
  }
  url: "/api/vcs/diff"
}

export type V2VcsDiffErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2VcsDiffError = V2VcsDiffErrors[keyof V2VcsDiffErrors]

export type V2VcsDiffResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfoV2
    data: Array<FileDiffInfoV2>
  }
}

export type V2VcsDiffResponse = V2VcsDiffResponses[keyof V2VcsDiffResponses]

export type V2DebugLocationEvictData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/debug/location"
}

export type V2DebugLocationEvictErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2DebugLocationEvictError = V2DebugLocationEvictErrors[keyof V2DebugLocationEvictErrors]

export type V2DebugLocationEvictResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2DebugLocationEvictResponse = V2DebugLocationEvictResponses[keyof V2DebugLocationEvictResponses]

export type V2DebugLocationListData = {
  body?: never
  path?: never
  query?: never
  url: "/api/debug/location"
}

export type V2DebugLocationListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
}

export type V2DebugLocationListError = V2DebugLocationListErrors[keyof V2DebugLocationListErrors]

export type V2DebugLocationListResponses = {
  /**
   * Success
   */
  200: Array<LocationRefV2>
}

export type V2DebugLocationListResponse = V2DebugLocationListResponses[keyof V2DebugLocationListResponses]

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]
