// 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
  | EventSessionForked
  | EventSessionPromptPromoted
  | EventSessionPromptAdmitted
  | EventSessionExecutionSettled
  | EventSessionContextUpdated
  | EventSessionSynthetic
  | EventSessionSkillActivated
  | EventSessionShellStarted
  | EventSessionShellEnded
  | EventSessionStepStarted
  | EventSessionStepEnded
  | EventSessionStepFailed
  | EventSessionTextStarted
  | EventSessionTextDelta
  | EventSessionTextEnded
  | EventSessionReasoningStarted
  | EventSessionReasoningDelta
  | EventSessionReasoningEnded
  | EventSessionToolInputStarted
  | EventSessionToolInputDelta
  | EventSessionToolInputEnded
  | EventSessionToolCalled
  | EventSessionToolProgress
  | EventSessionToolSuccess
  | EventSessionToolFailed
  | EventSessionRetried
  | EventSessionCompactionStarted
  | EventSessionCompactionDelta
  | EventSessionCompactionEnded
  | 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
  | EventTodoUpdated
  | EventLspUpdated
  | EventPermissionAsked
  | EventPermissionReplied
  | EventTuiPromptAppend2
  | EventTuiCommandExecute2
  | EventTuiToastShow2
  | EventTuiSessionSelect2
  | EventMcpToolsChanged
  | 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 SnapshotFileDiff = {
  file?: string
  patch?: string
  additions: number
  deletions: number
  status?: "added" | "deleted" | "modified"
}

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

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

export type PermissionRuleset = Array<PermissionRule>

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

export type OutputFormatText = {
  type: "text"
}

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

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

export type OutputFormat = OutputFormatText | OutputFormatJsonSchema

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

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

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

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

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

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

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

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

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

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

export type Message = UserMessage | AssistantMessage

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

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

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

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

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

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

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

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

export type FilePartSource = FileSource | SymbolSource | ResourceSource

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

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

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

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

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

export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type QuestionAnswer = Array<string>

export type GlobalEvent = {
  directory: string
  project?: string
  workspace?: string
  payload:
    | {
        id: string
        type: "models-dev.refreshed"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.connection.updated"
        properties: {
          integrationID: string
        }
      }
    | {
        id: string
        type: "catalog.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "agent.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "session.created"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "session.updated"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "session.deleted"
        properties: {
          sessionID: string
          info: Session
        }
      }
    | {
        id: string
        type: "message.updated"
        properties: {
          sessionID: string
          info: Message
        }
      }
    | {
        id: string
        type: "message.removed"
        properties: {
          sessionID: string
          messageID: string
        }
      }
    | {
        id: string
        type: "message.part.updated"
        properties: {
          sessionID: string
          part: Part
          time: number
        }
      }
    | {
        id: string
        type: "message.part.removed"
        properties: {
          sessionID: string
          messageID: string
          partID: string
        }
      }
    | {
        id: string
        type: "session.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
          subpath?: string
        }
      }
    | {
        id: string
        type: "session.renamed"
        properties: {
          sessionID: string
          title: string
        }
      }
    | {
        id: string
        type: "session.forked"
        properties: {
          sessionID: string
          parentID: string
          from?: string
        }
      }
    | {
        id: string
        type: "session.prompt.promoted"
        properties: {
          sessionID: string
          inputID: string
        }
      }
    | {
        id: string
        type: "session.prompt.admitted"
        properties: {
          sessionID: string
          inputID: string
          prompt: Prompt
          delivery: "steer" | "queue"
        }
      }
    | {
        id: string
        type: "session.execution.settled"
        properties: {
          sessionID: string
          outcome: "success" | "failure" | "interrupted"
          error?: SessionErrorUnknown
        }
      }
    | {
        id: string
        type: "session.context.updated"
        properties: {
          sessionID: string
          text: string
        }
      }
    | {
        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
          name: string
          text: string
        }
      }
    | {
        id: string
        type: "session.shell.started"
        properties: {
          sessionID: string
          shell: Shell
        }
      }
    | {
        id: string
        type: "session.shell.ended"
        properties: {
          sessionID: string
          shell: Shell
          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: string
          cost: number
          tokens: {
            input: number
            output: number
            reasoning: number
            cache: {
              read: number
              write: number
            }
          }
          snapshot?: string
          files?: Array<string>
        }
      }
    | {
        id: string
        type: "session.step.failed"
        properties: {
          sessionID: string
          assistantMessageID: string
          error: SessionErrorUnknown
        }
      }
    | {
        id: string
        type: "session.text.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          textID: string
        }
      }
    | {
        id: string
        type: "session.text.delta"
        properties: {
          sessionID: string
          assistantMessageID: string
          textID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.text.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          textID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.reasoning.started"
        properties: {
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        id: string
        type: "session.reasoning.delta"
        properties: {
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.reasoning.ended"
        properties: {
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          text: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        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
          tool: string
          input: {
            [key: string]: unknown
          }
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        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>
          outputPaths?: Array<string>
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.tool.failed"
        properties: {
          sessionID: string
          assistantMessageID: string
          callID: string
          error: SessionErrorUnknown
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.retried"
        properties: {
          sessionID: string
          attempt: number
          error: SessionRetryError
        }
      }
    | {
        id: string
        type: "session.compaction.started"
        properties: {
          sessionID: string
          reason: "auto" | "manual"
        }
      }
    | {
        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.revert.staged"
        properties: {
          sessionID: string
          revert: RevertState
        }
      }
    | {
        id: string
        type: "session.revert.cleared"
        properties: {
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.revert.committed"
        properties: {
          sessionID: string
          messageID: string
        }
      }
    | {
        id: string
        type: "message.part.delta"
        properties: {
          sessionID: string
          messageID: string
          partID: string
          field: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.diff"
        properties: {
          sessionID: string
          diff: Array<SnapshotFileDiff>
        }
      }
    | {
        id: string
        type: "session.error"
        properties: {
          sessionID?: string
          error?:
            | ProviderAuthError
            | UnknownError
            | MessageOutputLengthError
            | MessageAbortedError
            | StructuredOutputError
            | ContextOverflowError
            | ContentFilterError
            | ApiError
        }
      }
    | {
        id: string
        type: "installation.updated"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "installation.update-available"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "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: Shell
        }
      }
    | {
        id: string
        type: "shell.exited"
        properties: {
          id: string
          exit?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
          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: FormFormInfo | FormUrlInfo
        }
      }
    | {
        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: "todo.updated"
        properties: {
          sessionID: string
          todos: Array<Todo>
        }
      }
    | {
        id: string
        type: "lsp.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "permission.asked"
        properties: {
          id: string
          sessionID: string
          permission: string
          patterns: Array<string>
          metadata: {
            [key: string]: unknown
          }
          always: Array<string>
          tool?: {
            messageID: string
            callID: string
          }
        }
      }
    | {
        id: string
        type: "permission.replied"
        properties: {
          sessionID: string
          requestID: string
          reply: "once" | "always" | "reject"
        }
      }
    | {
        id: string
        type: "tui.prompt.append"
        properties: {
          text: string
        }
      }
    | {
        id: string
        type: "tui.command.execute"
        properties: {
          command:
            | "session.list"
            | "session.new"
            | "session.share"
            | "session.interrupt"
            | "session.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.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
    | SyncEventSessionPromptPromoted
    | SyncEventSessionPromptAdmitted
    | SyncEventSessionContextUpdated
    | SyncEventSessionSynthetic
    | SyncEventSessionSkillActivated
    | SyncEventSessionShellStarted
    | SyncEventSessionShellEnded
    | SyncEventSessionStepStarted
    | SyncEventSessionStepEnded
    | SyncEventSessionStepFailed
    | SyncEventSessionTextStarted
    | SyncEventSessionTextEnded
    | SyncEventSessionReasoningStarted
    | SyncEventSessionReasoningEnded
    | SyncEventSessionToolInputStarted
    | SyncEventSessionToolInputEnded
    | SyncEventSessionToolCalled
    | SyncEventSessionToolProgress
    | SyncEventSessionToolSuccess
    | SyncEventSessionToolFailed
    | SyncEventSessionRetried
    | SyncEventSessionCompactionStarted
    | SyncEventSessionCompactionEnded
    | 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
      todowrite?: PermissionActionConfig
      question?: PermissionActionConfig
      webfetch?: PermissionActionConfig
      websearch?: PermissionActionConfig
      lsp?: PermissionRuleConfig
      doom_loop?: PermissionActionConfig
      skill?: PermissionRuleConfig
      [key: string]: PermissionRuleConfig | PermissionActionConfig | undefined
    }

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

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

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

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

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

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

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

export type AttachmentConfig = {
  image?: ImageAttachmentConfig
}

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

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

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

export type ExperimentalCapabilities = {
  backgroundSubagents: boolean
}

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

export type EffectHttpApiErrorInternalServerError = {
  _tag: "InternalServerError"
}

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

export type ToolList = Array<ToolListItem>

export type ToolIds = Array<string>

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

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

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

export type WorktreeRemoveInput = {
  directory: string
}

export type WorktreeResetInput = {
  directory: string
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type McpStatusConnected = {
  status: "connected"
}

export type McpStatusDisabled = {
  status: "disabled"
}

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

export type McpStatusNeedsAuth = {
  status: "needs_auth"
}

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

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

export type McpUnsupportedOAuthError = {
  error: string
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type EventTuiCommandExecute = {
  type: "tui.command.execute"
  properties: {
    command:
      | "session.list"
      | "session.new"
      | "session.share"
      | "session.interrupt"
      | "session.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 UnauthorizedError = {
  _tag: "UnauthorizedError"
  message: string
}

export type SessionWatermarks = {
  [key: string]: unknown | number
}

export type SessionsResponse = {
  data: Array<SessionV2Info>
  watermarks: SessionWatermarks
  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 PromptInput = {
  text: string
  files?: Array<PromptInputFileAttachment>
  agents?: Array<PromptAgentAttachment>
}

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 Shell1 = {
  id: string
  status: "running" | "exited" | "timeout" | "killed"
  command: string
  cwd: string
  shell: string
  file: string
  pid?: number
  exit?: number | "NaN" | "Infinity" | "-Infinity"
  metadata: {
    [key: string]: unknown
  }
  time: {
    started: number | "NaN" | "Infinity" | "-Infinity"
    completed?: number | "NaN" | "Infinity" | "-Infinity"
  }
}

export type SessionDurableEvent =
  | SessionAgentSelected
  | SessionModelSelected
  | SessionMoved
  | SessionRenamed
  | SessionForked
  | SessionPromptPromoted
  | SessionPromptAdmitted
  | SessionContextUpdated
  | SessionSynthetic
  | SessionSkillActivated
  | SessionShellStarted
  | SessionShellEnded
  | SessionStepStarted
  | SessionStepEnded
  | SessionStepFailed
  | SessionTextStarted
  | SessionTextEnded
  | SessionReasoningStarted
  | SessionReasoningEnded
  | SessionToolInputStarted
  | SessionToolInputEnded
  | SessionToolCalled
  | SessionToolProgress
  | SessionToolSuccess
  | SessionToolFailed
  | SessionRetried
  | SessionCompactionStarted
  | SessionCompactionEnded
  | SessionRevertStaged
  | SessionRevertCleared
  | SessionRevertCommitted

export type SessionLogItem = SessionDurableEvent | EventLogSynced

export type SessionLogItemStream = string

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

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

export type ProviderNotFoundError = {
  _tag: "ProviderNotFoundError"
  providerID: string
  message: 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
  | SessionForked
  | SessionPromptPromoted
  | SessionPromptAdmitted
  | SessionExecutionSettled
  | SessionContextUpdated
  | SessionSynthetic
  | SessionSkillActivated
  | SessionShellStarted
  | SessionShellEnded
  | SessionStepStarted
  | SessionStepEnded
  | SessionStepFailed
  | SessionTextStarted
  | SessionTextDelta
  | SessionTextEnded
  | SessionReasoningStarted
  | SessionReasoningDelta
  | SessionReasoningEnded
  | SessionToolInputStarted
  | SessionToolInputDelta
  | SessionToolInputEnded
  | SessionToolCalled
  | SessionToolProgress
  | SessionToolSuccess
  | SessionToolFailed
  | SessionRetried
  | SessionCompactionStarted
  | SessionCompactionDelta
  | SessionCompactionEnded
  | 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
  | TodoUpdated
  | LspUpdated
  | PermissionAsked
  | PermissionReplied
  | TuiPromptAppend
  | TuiCommandExecute
  | TuiToastShow
  | TuiSessionSelect
  | McpToolsChanged
  | McpStatusChanged
  | CommandExecuted
  | FileEdited
  | ProjectUpdated
  | SessionStatus2
  | SessionIdle
  | QuestionAsked
  | QuestionReplied2
  | QuestionRejected2
  | SessionCompacted
  | VcsBranchUpdated
  | WorkspaceReady
  | WorkspaceFailed
  | WorkspaceStatus
  | WorktreeReady
  | WorktreeFailed
  | ServerConnected
  | GlobalDisposed

export type V2EventStream = string

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

export type 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 Shell2 = {
  id: string
  status: "running" | "exited" | "timeout" | "killed"
  command: string
  cwd: string
  shell: string
  file: string
  pid?: number
  exit?: number | "NaN" | "Infinity" | "-Infinity"
  metadata: {
    [key: string]: unknown
  }
  time: {
    started: number | "NaN" | "Infinity" | "-Infinity"
    completed?: number | "NaN" | "Infinity" | "-Infinity"
  }
}

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 | IntegrationKeyMethod | IntegrationEnvMethod

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

export type SkillV2Source = SkillV2DirectorySource | SkillV2UrlSource | SkillV2EmbeddedSource

export type MoveSessionDestination = {
  directory: string
}

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

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

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

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

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

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

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

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

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

export type LlmToolContent = ToolTextContent | ToolFileContent

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

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

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

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

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

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

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

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

export type QuestionV2Answer = Array<string>

export type 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 FormFormInfo = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata
  mode: "form"
  fields: Array<FormStringField | FormNumberField | FormIntegerField | FormBooleanField | FormMultiselectField>
}

export type FormUrlInfo = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata
  mode: "url"
  url: string
}

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

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

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

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

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

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

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

export type 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
      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.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      parentID: string
      from?: string
    }
  }
}

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

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

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

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

export type SyncEventSessionShellEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.shell.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      shell: Shell
      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: string
      cost: number
      tokens: {
        input: number
        output: number
        reasoning: number
        cache: {
          read: number
          write: number
        }
      }
      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: SessionErrorUnknown
    }
  }
}

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

export type SyncEventSessionTextEnded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.text.ended.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      assistantMessageID: string
      textID: string
      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
      reasoningID: string
      providerMetadata?: LlmProviderMetadata
    }
  }
}

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

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
      tool: string
      input: {
        [key: string]: unknown
      }
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

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>
      outputPaths?: Array<string>
      result?: unknown
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

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: SessionErrorUnknown
      result?: unknown
      provider: {
        executed: boolean
        metadata?: LlmProviderMetadata
      }
    }
  }
}

export type SyncEventSessionRetried = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.retried.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      attempt: number
      error: SessionRetryError
    }
  }
}

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

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 SyncEventSessionRevertStaged = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.revert.staged.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      sessionID: string
      revert: RevertState
    }
  }
}

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

export type PluginInfo = {
  id: string
}

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

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

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

export type 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
  }
  sessionID: string
  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"
  name: string
  text: string
}

export type SessionMessageShell = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "shell"
  shell: Shell
  output?: {
    output: string
    cursor: number
    size: number
    truncated: boolean
  }
}

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

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

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

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

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

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

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

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

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

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

export type SessionContextEntryKey = string

export type SessionContextEntryInfo = {
  key: SessionContextEntryKey
  value: unknown
}

export type SessionAgentSelected = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.agent.selected"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  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: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    location: LocationRef
    subpath?: string
  }
}

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

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

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

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

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

export type SessionSynthetic = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.synthetic"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: 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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    shell: Shell1
  }
}

export type SessionShellEnded = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.shell.ended"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    shell: Shell1
    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: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    finish: string
    cost: number
    tokens: {
      input: number
      output: number
      reasoning: number
      cache: {
        read: number
        write: number
      }
    }
    snapshot?: string
    files?: Array<string>
  }
}

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

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

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

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

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

export type SessionToolInputStarted = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.input.started"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  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: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    tool: string
    input: {
      [key: string]: unknown
    }
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

export type SessionToolProgress = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.progress"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent>
    outputPaths?: Array<string>
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

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

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

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

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

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

export type SessionRevertCleared = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.revert.cleared"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    messageID: string
  }
}

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

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

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

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

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

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

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

export type ProviderApi = ProviderAisdk | ProviderNative

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

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

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

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

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

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

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

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

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

export type ConnectionInfo = ConnectionCredentialInfo | ConnectionEnvInfo

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

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

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

export type 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 ProjectCurrent = {
  id: string
  directory: string
}

export type FormCreatePayload = {
  id?: string
  title?: string
  metadata?: FormMetadata
  mode: "form" | "url"
  fields?: Array<FormStringField | FormNumberField | FormIntegerField | FormBooleanField | FormMultiselectField>
  url?: string
}

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

export type SkillV2Info = {
  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: number
  }
  location?: LocationRef
  data: {
    sessionID: string
    info: Session
  }
}

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

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

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

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

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

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

export type SessionExecutionSettled = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.settled"
  location?: LocationRef
  data: {
    sessionID: string
    outcome: "success" | "failure" | "interrupted"
    error?: SessionErrorUnknown
  }
}

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

export type SessionReasoningDelta = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.delta"
  location?: LocationRef
  data: {
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    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<SnapshotFileDiff>
  }
}

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

export type ShellExited = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.exited"
  location?: LocationRef
  data: {
    id: string
    exit?: number | "NaN" | "Infinity" | "-Infinity"
    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: FormFormInfo | FormUrlInfo
  }
}

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 TodoUpdated = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "todo.updated"
  location?: LocationRef
  data: {
    sessionID: string
    todos: Array<Todo>
  }
}

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 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 EventLogHint = {
  type: "log.hint"
  aggregateID: string
  seq: number
}

export type EventLogSweepRequired = {
  type: "log.sweep_required"
}

export type EventLogChange = EventLogHint | EventLogSweepRequired

export type EventLogChangeStream = string

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

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

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

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

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

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

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

export type 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
    subpath?: string
  }
}

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

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

export type EventSessionPromptPromoted = {
  id: string
  type: "session.prompt.promoted"
  properties: {
    sessionID: string
    inputID: string
  }
}

export type EventSessionPromptAdmitted = {
  id: string
  type: "session.prompt.admitted"
  properties: {
    sessionID: string
    inputID: string
    prompt: Prompt
    delivery: "steer" | "queue"
  }
}

export type EventSessionExecutionSettled = {
  id: string
  type: "session.execution.settled"
  properties: {
    sessionID: string
    outcome: "success" | "failure" | "interrupted"
    error?: SessionErrorUnknown
  }
}

export type EventSessionContextUpdated = {
  id: string
  type: "session.context.updated"
  properties: {
    sessionID: string
    text: string
  }
}

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
    name: string
    text: string
  }
}

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

export type EventSessionShellEnded = {
  id: string
  type: "session.shell.ended"
  properties: {
    sessionID: string
    shell: Shell2
    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: string
    cost: number
    tokens: {
      input: number
      output: number
      reasoning: number
      cache: {
        read: number
        write: number
      }
    }
    snapshot?: string
    files?: Array<string>
  }
}

export type EventSessionStepFailed = {
  id: string
  type: "session.step.failed"
  properties: {
    sessionID: string
    assistantMessageID: string
    error: SessionErrorUnknown
  }
}

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

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

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

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

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

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

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
    tool: string
    input: {
      [key: string]: unknown
    }
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

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>
    outputPaths?: Array<string>
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata
    }
  }
}

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

export type EventSessionRetried = {
  id: string
  type: "session.retried"
  properties: {
    sessionID: string
    attempt: number
    error: SessionRetryError
  }
}

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

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 EventSessionRevertStaged = {
  id: string
  type: "session.revert.staged"
  properties: {
    sessionID: string
    revert: RevertState
  }
}

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

export type EventSessionRevertCommitted = {
  id: string
  type: "session.revert.committed"
  properties: {
    sessionID: string
    messageID: string
  }
}

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

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

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

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

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

export type 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: Shell2
  }
}

export type EventShellExited = {
  id: string
  type: "shell.exited"
  properties: {
    id: string
    exit?: number | "NaN" | "Infinity" | "-Infinity"
    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: FormFormInfo | FormUrlInfo
  }
}

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 EventTodoUpdated = {
  id: string
  type: "todo.updated"
  properties: {
    sessionID: string
    todos: Array<Todo>
  }
}

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

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

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

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

export type 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 SkillV2DirectorySource = {
  type: "directory"
  path: string
}

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

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

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

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

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

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

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

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

export type ProviderRequest2 = {
  settings: ProviderSettings2
  headers: {
    [key: string]: string
  }
  body: {
    [key: string]: unknown
  }
}

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

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

export type PermissionV2Rule2 = {
  action: string
  resource: string
  effect: PermissionV2Effect2
}

export type PermissionV2Ruleset2 = Array<PermissionV2Rule2>

export type AgentV2Info2 = {
  id: string
  model?: ModelRef2
  request: ProviderRequest2
  system?: string
  description?: string
  mode: "subagent" | "primary" | "all"
  hidden: boolean
  color?: AgentColor2
  steps?: number
  permissions: PermissionV2Ruleset2
}

export type PluginInfo2 = {
  id: string
}

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

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

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

export type SessionV2Info2 = {
  id: string
  parentID?: string
  projectID: string
  agent?: string
  model?: ModelRef2
  cost: number
  tokens: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  time: {
    created: number
    updated: number
    archived?: number
  }
  title: string
  location: LocationRef2
  subpath?: string
  revert?: RevertState2
}

/**
 * Durable log seq each session's snapshot was computed at. Attach a live log read after the watermark to compose fetch and stream gap-free; apply a snapshot only where its watermark is at or beyond already-applied events. Sessions without durable events are absent.
 */
export type SessionWatermarksV2 = {
  [key: string]: unknown | number
}

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

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

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

export type SessionActiveV2 = {
  type: "running"
}

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

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

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

export type PromptInputFileAttachment2 = {
  uri: string
  name?: string
  description?: string
  source?: PromptSource2
}

export type PromptAgentAttachment2 = {
  name: string
  source?: PromptSource2
}

export type PromptInputV2 = {
  text: string
  files?: Array<PromptInputFileAttachment2>
  agents?: Array<PromptAgentAttachment2>
}

export type PromptFileAttachment2 = {
  uri: string
  mime: string
  name?: string
  description?: string
  source?: PromptSource2
}

export type PromptV2 = {
  text: string
  files?: Array<PromptFileAttachment2>
  agents?: Array<PromptAgentAttachment2>
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type SessionMessageShell2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "shell"
  shell: ShellV2
  output?: {
    output: string
    cursor: number
    size: number
    truncated: boolean
  }
}

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

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

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

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

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

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

export type LlmToolContent2 = ToolTextContent2 | ToolFileContent2

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

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

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

export type SessionMessageToolStateError2 = {
  status: "error"
  input: {
    [key: string]: unknown
  }
  content: Array<LlmToolContent2>
  structured: {
    [key: string]: unknown
  }
  error: SessionErrorUnknown2
  result?: unknown
}

export type SessionMessageAssistantTool2 = {
  type: "tool"
  id: string
  name: string
  provider?: {
    executed: boolean
    metadata?: LlmProviderMetadata2
    resultMetadata?: LlmProviderMetadata2
  }
  state:
    | SessionMessageToolStatePending2
    | SessionMessageToolStateRunning2
    | SessionMessageToolStateCompleted2
    | SessionMessageToolStateError2
  time: {
    created: number
    ran?: number
    completed?: number
    pruned?: number
  }
}

export type SessionMessageAssistant2 = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  time: {
    created: number
    completed?: number
  }
  type: "assistant"
  agent: string
  model: ModelRef2
  content: Array<SessionMessageAssistantText2 | SessionMessageAssistantReasoning2 | SessionMessageAssistantTool2>
  snapshot?: {
    start?: string
    end?: string
    files?: Array<string>
  }
  finish?: string
  cost?: number
  tokens?: {
    input: number
    output: number
    reasoning: number
    cache: {
      read: number
      write: number
    }
  }
  error?: SessionErrorUnknown2
}

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

export type SessionMessage2 =
  | SessionMessageAgentSelected2
  | SessionMessageModelSelected2
  | SessionMessageUser2
  | SessionMessageSynthetic2
  | SessionMessageSystem2
  | SessionMessageSkill2
  | SessionMessageShell2
  | SessionMessageAssistant2
  | SessionMessageCompaction2

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

export type SessionContextEntryInfo2 = {
  key: SessionContextEntryKey2
  value: unknown
}

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

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

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

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

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

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

export type SessionPromptAdmitted2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.prompt.admitted"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    inputID: string
    prompt: PromptV2
    delivery: "steer" | "queue"
  }
}

export type SessionContextUpdated2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.context.updated"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    text: string
  }
}

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

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

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

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

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

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

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

export type SessionStepFailed2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.step.failed"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    error: SessionErrorUnknown2
  }
}

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

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

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

export type SessionReasoningStarted2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.started"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    providerMetadata?: LlmProviderMetadata3
  }
}

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

export type SessionReasoningEnded2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.reasoning.ended"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    reasoningID: string
    text: string
    providerMetadata?: LlmProviderMetadata4
  }
}

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

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

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

export type SessionToolCalled2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.called"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    tool: string
    input: {
      [key: string]: unknown
    }
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata5
    }
  }
}

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

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

export type SessionToolSuccess2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.success"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    structured: {
      [key: string]: unknown
    }
    content: Array<LlmToolContent2>
    outputPaths?: Array<string>
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata6
    }
  }
}

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

export type SessionToolFailed2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.tool.failed"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    assistantMessageID: string
    callID: string
    error: SessionErrorUnknown2
    result?: unknown
    provider: {
      executed: boolean
      metadata?: LlmProviderMetadata7
    }
  }
}

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

export type SessionRetried2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.retried"
  durable: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef2
  data: {
    sessionID: string
    attempt: number
    error: SessionRetryError2
  }
}

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

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

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

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

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

export type SessionDurableEventV2 =
  | SessionAgentSelected2
  | SessionModelSelected2
  | SessionMoved2
  | SessionRenamed2
  | SessionForked2
  | SessionPromptPromoted2
  | SessionPromptAdmitted2
  | SessionContextUpdated2
  | SessionSynthetic2
  | SessionSkillActivated2
  | SessionShellStarted2
  | SessionShellEnded2
  | SessionStepStarted2
  | SessionStepEnded2
  | SessionStepFailed2
  | SessionTextStarted2
  | SessionTextEnded2
  | SessionReasoningStarted2
  | SessionReasoningEnded2
  | SessionToolInputStarted2
  | SessionToolInputEnded2
  | SessionToolCalled2
  | SessionToolProgress2
  | SessionToolSuccess2
  | SessionToolFailed2
  | SessionRetried2
  | SessionCompactionStarted2
  | SessionCompactionEnded2
  | SessionRevertStaged2
  | SessionRevertCleared2
  | SessionRevertCommitted2

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

export type SessionLogItemV2 = SessionDurableEventV2 | EventLogSynced2

export type SessionLogItemStreamV2 = string

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

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

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

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

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

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

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

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

export type ProviderApi2 = ProviderAisdk2 | ProviderNative2

export type ProviderV2Info2 = {
  id: string
  integrationID?: string
  name: string
  disabled?: boolean
  api: ProviderApi2
  request: ProviderRequest2
}

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

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

export type IntegrationTextPrompt2 = {
  type: "text"
  key: string
  message: string
  placeholder?: string
  when?: IntegrationWhen2
}

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

export type IntegrationOAuthMethod2 = {
  id: string
  type: "oauth"
  label: string
  prompts?: Array<IntegrationTextPrompt2 | IntegrationSelectPrompt2>
}

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

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

export type IntegrationMethod2 = IntegrationOAuthMethod2 | IntegrationKeyMethod2 | IntegrationEnvMethod2

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

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

export type ConnectionInfo2 = ConnectionCredentialInfo2 | ConnectionEnvInfo2

export type IntegrationInfo2 = {
  id: string
  name: string
  methods: Array<IntegrationMethod2>
  connections: Array<ConnectionInfo2>
}

export type IntegrationAttempt2 = {
  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 IntegrationAttemptStatus2 =
  | {
      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 McpStatusConnected3 = {
  status: "connected"
}

export type McpStatusPending2 = {
  status: "pending"
}

export type McpStatusDisabled3 = {
  status: "disabled"
}

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

export type McpStatusNeedsAuth3 = {
  status: "needs_auth"
}

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

export type McpServer2 = {
  name: string
  status:
    | McpStatusConnected3
    | McpStatusPending2
    | McpStatusDisabled3
    | McpStatusFailed3
    | McpStatusNeedsAuth3
    | McpStatusNeedsClientRegistration3
  integrationID?: string
}

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

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

export type ProjectDirectories2 = Array<ProjectDirectory2>

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

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

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

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

export type FormNumberField3 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen2>
  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 FormIntegerField3 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen2>
  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 FormBooleanField2 = {
  key: string
  title?: string
  description?: string
  required?: boolean
  when?: Array<FormWhen2>
  type: "boolean"
  default?: boolean
}

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

export type FormFormInfo2 = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata2
  mode: "form"
  fields: Array<FormStringField2 | FormNumberField3 | FormIntegerField3 | FormBooleanField2 | FormMultiselectField2>
}

export type FormUrlInfo2 = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata2
  mode: "url"
  url: string
}

export type FormCreatePayload2 = {
  id?: string | null
  title?: string
  metadata?: FormMetadata2
  mode: "form" | "url"
  fields?: Array<
    FormStringField2 | FormNumberField3 | FormIntegerField3 | FormBooleanField2 | FormMultiselectField2
  > | null
  url?: string | null
}

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

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

export type FormAnswer2 = {
  [key: string]: FormValue2
}

export type FormState2 =
  | {
      status: "pending"
    }
  | {
      status: "answered"
      answer: FormAnswer2
    }
  | {
      status: "cancelled"
    }

export type FormReply2 = {
  answer: FormAnswer2
}

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

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

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

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

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

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

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

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

export type CommandV2Info2 = {
  name: string
  template: string
  description?: string
  agent?: string
  model?: ModelRef2
  subtask?: boolean
}

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

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

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

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

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

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

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

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

export type PermissionRuleV2 = {
  permission: string
  pattern: string
  action: PermissionActionV2
}

export type PermissionRulesetV2 = Array<PermissionRuleV2>

export type SessionV2 = {
  id: string
  slug: string
  projectID: string
  workspaceID?: string
  directory: string
  path?: string
  parentID?: string
  summary?: {
    additions: number
    deletions: number
    files: number
    diffs?: Array<SnapshotFileDiffV2>
  }
  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?: PermissionRulesetV2
  revert?: {
    messageID: string
    partID?: string
    snapshot?: string
    diff?: string
  }
}

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

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

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

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

export type OutputFormatV2 =
  | {
      type: "text"
    }
  | {
      type: "json_schema"
      schema: JsonSchemaV2
      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<SnapshotFileDiffV2>
  } | null
  agent: string
  model: {
    providerID: string
    modelID: string
    variant?: string | null
  }
  system?: string | null
  tools?: {
    [key: string]: boolean
  } | null
}

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

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

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

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

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

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

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

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?:
    | ProviderAuthErrorV2
    | UnknownError1V2
    | MessageOutputLengthErrorV2
    | MessageAbortedErrorV2
    | StructuredOutputErrorV2
    | ContextOverflowErrorV2
    | ContentFilterErrorV2
    | 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 MessageV2 = UserMessageV2 | AssistantMessageV2

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

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

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 FilePartSourceTextV2 = {
  value: string
  start: number
  end: number
}

export type FileSourceV2 = {
  text: FilePartSourceTextV2
  type: "file"
  path: string
}

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

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

export type ResourceSourceV2 = {
  text: FilePartSourceTextV2
  type: "resource"
  clientName: string
  uri: string
}

export type FilePartSourceV2 = FileSourceV2 | SymbolSourceV2 | ResourceSourceV2

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

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

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 ToolStateV2 = ToolStatePendingV2 | ToolStateRunningV2 | ToolStateCompletedV2 | ToolStateErrorV2

export type ToolPartV2 = {
  id: string
  sessionID: string
  messageID: string
  type: "tool"
  callID: string
  tool: string
  state: ToolStateV2
  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 PartV2 =
  | TextPartV2
  | SubtaskPartV2
  | ReasoningPartV2
  | FilePartV2
  | ToolPartV2
  | StepStartPartV2
  | StepFinishPartV2
  | SnapshotPartV2
  | PatchPartV2
  | AgentPartV2
  | RetryPartV2
  | CompactionPartV2

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

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

export type SessionExecutionSettled2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.execution.settled"
  location?: LocationRef2
  data: {
    sessionID: string
    outcome: "success" | "failure" | "interrupted"
    error?: SessionErrorUnknown2
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type ShellCreated2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "shell.created"
  location?: LocationRef2
  data: {
    info: Shell1V2
  }
}

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

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

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

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

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

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

export type QuestionV2Answer2 = Array<string>

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

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

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

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

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

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

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

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

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

export type FormFormInfo1 = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata1
  mode: "form"
  fields: Array<FormStringField1 | FormNumberField12 | FormIntegerField12 | FormBooleanField1 | FormMultiselectField1>
}

export type FormUrlInfo1 = {
  id: string
  sessionID: string
  title?: string
  metadata?: FormMetadata1
  mode: "url"
  url: string
}

export type FormCreated2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "form.created"
  location?: LocationRef2
  data: {
    form: FormFormInfo1 | FormUrlInfo1
  }
}

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

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

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

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

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

export type TodoUpdated2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "todo.updated"
  location?: LocationRef2
  data: {
    sessionID: string
    todos: Array<TodoV2>
  }
}

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?: LocationRef2
  data: {
    sessionID: string
    status: SessionStatusV2
  }
}

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

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

export type TuiCommandExecute2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.command.execute"
  location?: LocationRef2
  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 TuiToastShow2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "tui.toast.show"
  location?: LocationRef2
  data: {
    title?: string
    message: string
    variant: "info" | "success" | "warning" | "error"
    duration?: number | null
  }
}

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

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

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

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

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

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

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

export type QuestionInfoV2 = {
  /**
   * Complete question
   */
  question: string
  /**
   * Very short label (max 30 chars)
   */
  header: string
  /**
   * Available choices
   */
  options: Array<QuestionOptionV2>
  /**
   * 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 QuestionAsked2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "question.asked"
  location?: LocationRef2
  data: {
    id: string
    sessionID: string
    /**
     * Questions to ask
     */
    questions: Array<QuestionInfoV2>
    tool?: QuestionToolV2 | null
  }
}

export type QuestionAnswerV2 = Array<string>

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

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

export type SessionError2 = {
  id: string
  created: number
  metadata?: {
    [key: string]: unknown
  }
  type: "session.error"
  location?: LocationRef2
  data: {
    sessionID?: string | null
    error?:
      | ProviderAuthErrorV2
      | UnknownError1V2
      | MessageOutputLengthErrorV2
      | MessageAbortedErrorV2
      | StructuredOutputErrorV2
      | ContextOverflowErrorV2
      | ContentFilterErrorV2
      | ApiErrorV2
      | null
  }
}

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

export type V2EventV2 =
  | ModelsDevRefreshed2
  | IntegrationUpdated2
  | IntegrationConnectionUpdated2
  | CatalogUpdated2
  | AgentUpdated2
  | SessionCreated2
  | SessionUpdated2
  | SessionDeleted2
  | MessageUpdated2
  | MessageRemoved2
  | MessagePartUpdated2
  | MessagePartRemoved2
  | SessionAgentSelected2
  | SessionModelSelected2
  | SessionMoved2
  | SessionRenamed2
  | SessionForked2
  | SessionPromptPromoted2
  | SessionPromptAdmitted2
  | SessionExecutionSettled2
  | SessionContextUpdated2
  | SessionSynthetic2
  | SessionSkillActivated2
  | SessionShellStarted2
  | SessionShellEnded2
  | SessionStepStarted2
  | SessionStepEnded2
  | SessionStepFailed2
  | SessionTextStarted2
  | SessionTextDelta2
  | SessionTextEnded2
  | SessionReasoningStarted2
  | SessionReasoningDelta2
  | SessionReasoningEnded2
  | SessionToolInputStarted2
  | SessionToolInputDelta2
  | SessionToolInputEnded2
  | SessionToolCalled2
  | SessionToolProgress2
  | SessionToolSuccess2
  | SessionToolFailed2
  | SessionRetried2
  | SessionCompactionStarted2
  | SessionCompactionDelta2
  | SessionCompactionEnded2
  | SessionRevertStaged2
  | SessionRevertCleared2
  | SessionRevertCommitted2
  | FilesystemChanged2
  | ReferenceUpdated2
  | PermissionV2Asked2
  | PermissionV2Replied2
  | PluginAdded2
  | PluginUpdated2
  | ProjectDirectoriesUpdated2
  | CommandUpdated2
  | ConfigUpdated2
  | SkillUpdated2
  | PtyCreated2
  | PtyUpdated2
  | PtyExited2
  | PtyDeleted2
  | ShellCreated2
  | ShellExited2
  | ShellDeleted2
  | QuestionV2Asked2
  | QuestionV2Replied2
  | QuestionV2Rejected2
  | FormCreated2
  | FormReplied2
  | FormCancelled2
  | TodoUpdated2
  | SessionStatusV22
  | SessionIdle2
  | TuiPromptAppend2
  | TuiCommandExecute2
  | TuiToastShow2
  | TuiSessionSelect2
  | InstallationUpdated2
  | InstallationUpdateAvailable2
  | VcsBranchUpdated2
  | McpStatusChanged2
  | PermissionAsked2
  | PermissionReplied2
  | QuestionAsked2
  | QuestionRepliedV2
  | QuestionRejectedV2
  | SessionError2
  | V2EventServerConnected

export type V2EventStreamV2 = string

/**
 * Payload-free change hint: the aggregate's durable log advanced to at least seq. Hints coalesce under backpressure (latest per aggregate) and are never a delivery guarantee.
 */
export type EventLogHint2 = {
  type: "log.hint"
  aggregateID: string
  seq: number
}

/**
 * Hints may have been lost; treat every aggregate as potentially dirty and recover via bounded sweep plus durable log reads. Emitted first on every (re)subscribe.
 */
export type EventLogSweepRequired2 = {
  type: "log.sweep_required"
}

export type EventLogChange2 = EventLogHint2 | EventLogSweepRequired2

export type EventLogChangeStream2 = string

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

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

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

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

export type QuestionV2Request2 = {
  id: string
  sessionID: string
  /**
   * Questions to ask
   */
  questions: Array<QuestionV2Info2>
  tool?: QuestionV2Tool2
}

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

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

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

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

export type ReferenceSource2 = ReferenceLocalSource2 | ReferenceGitSource2

export type ReferenceInfo2 = {
  name: string
  path: string
  description?: string
  hidden?: boolean
  source: ReferenceSource2
}

export type ProjectCopyCopy2 = {
  directory: string
}

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

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

export type VcsMode2 = "working" | "branch"

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

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

export type AuthRemoveError = AuthRemoveErrors[keyof AuthRemoveErrors]

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

export type AuthRemoveResponse = AuthRemoveResponses[keyof AuthRemoveResponses]

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

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

export type AuthSetError = AuthSetErrors[keyof AuthSetErrors]

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

export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses]

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

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

export type AppLogError = AppLogErrors[keyof AppLogErrors]

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

export type AppLogResponse = AppLogResponses[keyof AppLogResponses]

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

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

export type ExperimentalControlPlaneMoveSessionError =
  ExperimentalControlPlaneMoveSessionErrors[keyof ExperimentalControlPlaneMoveSessionErrors]

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

export type ExperimentalControlPlaneMoveSessionResponse =
  ExperimentalControlPlaneMoveSessionResponses[keyof ExperimentalControlPlaneMoveSessionResponses]

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

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

export type GlobalHealthError = GlobalHealthErrors[keyof GlobalHealthErrors]

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

export type GlobalHealthResponse = GlobalHealthResponses[keyof GlobalHealthResponses]

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

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

export type GlobalEventError = GlobalEventErrors[keyof GlobalEventErrors]

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

export type GlobalEventResponse = GlobalEventResponses[keyof GlobalEventResponses]

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

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

export type GlobalConfigGetError = GlobalConfigGetErrors[keyof GlobalConfigGetErrors]

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

export type GlobalConfigGetResponse = GlobalConfigGetResponses[keyof GlobalConfigGetResponses]

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

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

export type GlobalConfigUpdateError = GlobalConfigUpdateErrors[keyof GlobalConfigUpdateErrors]

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

export type GlobalConfigUpdateResponse = GlobalConfigUpdateResponses[keyof GlobalConfigUpdateResponses]

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

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

export type GlobalDisposeError = GlobalDisposeErrors[keyof GlobalDisposeErrors]

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

export type GlobalDisposeResponse = GlobalDisposeResponses[keyof GlobalDisposeResponses]

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

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

export type GlobalUpgradeError = GlobalUpgradeErrors[keyof GlobalUpgradeErrors]

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

export type GlobalUpgradeResponse = GlobalUpgradeResponses[keyof GlobalUpgradeResponses]

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

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

export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]

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

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

export type ConfigGetError = ConfigGetErrors[keyof ConfigGetErrors]

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

export type ConfigGetResponse = ConfigGetResponses[keyof ConfigGetResponses]

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

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

export type ConfigUpdateError = ConfigUpdateErrors[keyof ConfigUpdateErrors]

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

export type ConfigUpdateResponse = ConfigUpdateResponses[keyof ConfigUpdateResponses]

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

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

export type ConfigProvidersError = ConfigProvidersErrors[keyof ConfigProvidersErrors]

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

export type ConfigProvidersResponse = ConfigProvidersResponses[keyof ConfigProvidersResponses]

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

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

export type ExperimentalCapabilitiesGetError =
  ExperimentalCapabilitiesGetErrors[keyof ExperimentalCapabilitiesGetErrors]

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

export type ExperimentalCapabilitiesGetResponse =
  ExperimentalCapabilitiesGetResponses[keyof ExperimentalCapabilitiesGetResponses]

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

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

export type ExperimentalConsoleGetError = ExperimentalConsoleGetErrors[keyof ExperimentalConsoleGetErrors]

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

export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses]

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

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

export type ExperimentalConsoleListOrgsError =
  ExperimentalConsoleListOrgsErrors[keyof ExperimentalConsoleListOrgsErrors]

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

export type ExperimentalConsoleListOrgsResponse =
  ExperimentalConsoleListOrgsResponses[keyof ExperimentalConsoleListOrgsResponses]

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

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

export type ExperimentalConsoleSwitchOrgResponse =
  ExperimentalConsoleSwitchOrgResponses[keyof ExperimentalConsoleSwitchOrgResponses]

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

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

export type ToolListError = ToolListErrors[keyof ToolListErrors]

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

export type ToolListResponse = ToolListResponses[keyof ToolListResponses]

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

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

export type ToolIdsError = ToolIdsErrors[keyof ToolIdsErrors]

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

export type ToolIdsResponse = ToolIdsResponses[keyof ToolIdsResponses]

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

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

export type WorktreeRemoveError = WorktreeRemoveErrors[keyof WorktreeRemoveErrors]

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

export type WorktreeRemoveResponse = WorktreeRemoveResponses[keyof WorktreeRemoveResponses]

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

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

export type WorktreeListError = WorktreeListErrors[keyof WorktreeListErrors]

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

export type WorktreeListResponse = WorktreeListResponses[keyof WorktreeListResponses]

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

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

export type WorktreeCreateError = WorktreeCreateErrors[keyof WorktreeCreateErrors]

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

export type WorktreeCreateResponse = WorktreeCreateResponses[keyof WorktreeCreateResponses]

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

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

export type WorktreeResetError = WorktreeResetErrors[keyof WorktreeResetErrors]

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

export type WorktreeResetResponse = WorktreeResetResponses[keyof WorktreeResetResponses]

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

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

export type ExperimentalSessionListError = ExperimentalSessionListErrors[keyof ExperimentalSessionListErrors]

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

export type ExperimentalSessionListResponse = ExperimentalSessionListResponses[keyof ExperimentalSessionListResponses]

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

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

export type ExperimentalSessionBackgroundError =
  ExperimentalSessionBackgroundErrors[keyof ExperimentalSessionBackgroundErrors]

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

export type ExperimentalSessionBackgroundResponse =
  ExperimentalSessionBackgroundResponses[keyof ExperimentalSessionBackgroundResponses]

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

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

export type ExperimentalResourceListError = ExperimentalResourceListErrors[keyof ExperimentalResourceListErrors]

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

export type ExperimentalResourceListResponse =
  ExperimentalResourceListResponses[keyof ExperimentalResourceListResponses]

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

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

export type FindTextError = FindTextErrors[keyof FindTextErrors]

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

export type FindTextResponse = FindTextResponses[keyof FindTextResponses]

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

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

export type FindFilesError = FindFilesErrors[keyof FindFilesErrors]

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

export type FindFilesResponse = FindFilesResponses[keyof FindFilesResponses]

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

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

export type FindSymbolsError = FindSymbolsErrors[keyof FindSymbolsErrors]

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

export type FindSymbolsResponse = FindSymbolsResponses[keyof FindSymbolsResponses]

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

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

export type FileListError = FileListErrors[keyof FileListErrors]

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

export type FileListResponse = FileListResponses[keyof FileListResponses]

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

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

export type FileReadError = FileReadErrors[keyof FileReadErrors]

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

export type FileReadResponse = FileReadResponses[keyof FileReadResponses]

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

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

export type FileStatusError = FileStatusErrors[keyof FileStatusErrors]

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

export type FileStatusResponse = FileStatusResponses[keyof FileStatusResponses]

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

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

export type InstanceDisposeError = InstanceDisposeErrors[keyof InstanceDisposeErrors]

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

export type InstanceDisposeResponse = InstanceDisposeResponses[keyof InstanceDisposeResponses]

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

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

export type PathGetError = PathGetErrors[keyof PathGetErrors]

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

export type PathGetResponse = PathGetResponses[keyof PathGetResponses]

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

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

export type VcsGetError = VcsGetErrors[keyof VcsGetErrors]

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

export type VcsGetResponse = VcsGetResponses[keyof VcsGetResponses]

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

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

export type VcsStatusError = VcsStatusErrors[keyof VcsStatusErrors]

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

export type VcsStatusResponse = VcsStatusResponses[keyof VcsStatusResponses]

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

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

export type VcsDiffError = VcsDiffErrors[keyof VcsDiffErrors]

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

export type VcsDiffResponse = VcsDiffResponses[keyof VcsDiffResponses]

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

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

export type VcsDiffRawError = VcsDiffRawErrors[keyof VcsDiffRawErrors]

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

export type VcsDiffRawResponse = VcsDiffRawResponses[keyof VcsDiffRawResponses]

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

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

export type VcsApplyError2 = VcsApplyErrors[keyof VcsApplyErrors]

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

export type VcsApplyResponse = VcsApplyResponses[keyof VcsApplyResponses]

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

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

export type CommandListError = CommandListErrors[keyof CommandListErrors]

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

export type CommandListResponse = CommandListResponses[keyof CommandListResponses]

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

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

export type AppAgentsError = AppAgentsErrors[keyof AppAgentsErrors]

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

export type AppAgentsResponse = AppAgentsResponses[keyof AppAgentsResponses]

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

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

export type AppSkillsError = AppSkillsErrors[keyof AppSkillsErrors]

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

export type AppSkillsResponse = AppSkillsResponses[keyof AppSkillsResponses]

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

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

export type LspStatusError = LspStatusErrors[keyof LspStatusErrors]

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

export type LspStatusResponse = LspStatusResponses[keyof LspStatusResponses]

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

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

export type FormatterStatusError = FormatterStatusErrors[keyof FormatterStatusErrors]

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

export type FormatterStatusResponse = FormatterStatusResponses[keyof FormatterStatusResponses]

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

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

export type McpStatusError = McpStatusErrors[keyof McpStatusErrors]

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

export type McpStatusResponse = McpStatusResponses[keyof McpStatusResponses]

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

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

export type McpAddError = McpAddErrors[keyof McpAddErrors]

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

export type McpAddResponse = McpAddResponses[keyof McpAddResponses]

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

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

export type McpAuthRemoveError = McpAuthRemoveErrors[keyof McpAuthRemoveErrors]

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

export type McpAuthRemoveResponse = McpAuthRemoveResponses[keyof McpAuthRemoveResponses]

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

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

export type McpAuthStartError = McpAuthStartErrors[keyof McpAuthStartErrors]

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

export type McpAuthStartResponse = McpAuthStartResponses[keyof McpAuthStartResponses]

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

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

export type McpAuthCallbackError = McpAuthCallbackErrors[keyof McpAuthCallbackErrors]

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

export type McpAuthCallbackResponse = McpAuthCallbackResponses[keyof McpAuthCallbackResponses]

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

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

export type McpAuthAuthenticateError = McpAuthAuthenticateErrors[keyof McpAuthAuthenticateErrors]

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

export type McpAuthAuthenticateResponse = McpAuthAuthenticateResponses[keyof McpAuthAuthenticateResponses]

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

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

export type McpConnectError = McpConnectErrors[keyof McpConnectErrors]

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

export type McpConnectResponse = McpConnectResponses[keyof McpConnectResponses]

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

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

export type McpDisconnectError = McpDisconnectErrors[keyof McpDisconnectErrors]

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

export type McpDisconnectResponse = McpDisconnectResponses[keyof McpDisconnectResponses]

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

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

export type ProjectListError = ProjectListErrors[keyof ProjectListErrors]

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

export type ProjectListResponse = ProjectListResponses[keyof ProjectListResponses]

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

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

export type ProjectCurrentError = ProjectCurrentErrors[keyof ProjectCurrentErrors]

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

export type ProjectCurrentResponse = ProjectCurrentResponses[keyof ProjectCurrentResponses]

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

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

export type ProjectInitGitError = ProjectInitGitErrors[keyof ProjectInitGitErrors]

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

export type ProjectInitGitResponse = ProjectInitGitResponses[keyof ProjectInitGitResponses]

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

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

export type ProjectUpdateError = ProjectUpdateErrors[keyof ProjectUpdateErrors]

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

export type ProjectUpdateResponse = ProjectUpdateResponses[keyof ProjectUpdateResponses]

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

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

export type ProjectDirectoriesError = ProjectDirectoriesErrors[keyof ProjectDirectoriesErrors]

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

export type ProjectDirectoriesResponse = ProjectDirectoriesResponses[keyof ProjectDirectoriesResponses]

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

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

export type ExperimentalProjectCopyGenerateNameError =
  ExperimentalProjectCopyGenerateNameErrors[keyof ExperimentalProjectCopyGenerateNameErrors]

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

export type ExperimentalProjectCopyGenerateNameResponse =
  ExperimentalProjectCopyGenerateNameResponses[keyof ExperimentalProjectCopyGenerateNameResponses]

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

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

export type PtyShellsError = PtyShellsErrors[keyof PtyShellsErrors]

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

export type PtyShellsResponse = PtyShellsResponses[keyof PtyShellsResponses]

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

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

export type PtyListError = PtyListErrors[keyof PtyListErrors]

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

export type PtyListResponse = PtyListResponses[keyof PtyListResponses]

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

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

export type PtyCreateError = PtyCreateErrors[keyof PtyCreateErrors]

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

export type PtyCreateResponse = PtyCreateResponses[keyof PtyCreateResponses]

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

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

export type PtyRemoveError = PtyRemoveErrors[keyof PtyRemoveErrors]

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

export type PtyRemoveResponse = PtyRemoveResponses[keyof PtyRemoveResponses]

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

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

export type PtyGetError = PtyGetErrors[keyof PtyGetErrors]

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

export type PtyGetResponse = PtyGetResponses[keyof PtyGetResponses]

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

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

export type PtyUpdateError = PtyUpdateErrors[keyof PtyUpdateErrors]

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

export type PtyUpdateResponse = PtyUpdateResponses[keyof PtyUpdateResponses]

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

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

export type PtyConnectTokenError = PtyConnectTokenErrors[keyof PtyConnectTokenErrors]

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

export type PtyConnectTokenResponse = PtyConnectTokenResponses[keyof PtyConnectTokenResponses]

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

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

export type QuestionListError = QuestionListErrors[keyof QuestionListErrors]

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

export type QuestionListResponse = QuestionListResponses[keyof QuestionListResponses]

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

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

export type QuestionReplyError = QuestionReplyErrors[keyof QuestionReplyErrors]

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

export type QuestionReplyResponse = QuestionReplyResponses[keyof QuestionReplyResponses]

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

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

export type QuestionRejectError = QuestionRejectErrors[keyof QuestionRejectErrors]

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

export type QuestionRejectResponse = QuestionRejectResponses[keyof QuestionRejectResponses]

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

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

export type PermissionListError = PermissionListErrors[keyof PermissionListErrors]

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

export type PermissionListResponse = PermissionListResponses[keyof PermissionListResponses]

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

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

export type PermissionReplyError = PermissionReplyErrors[keyof PermissionReplyErrors]

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

export type PermissionReplyResponse = PermissionReplyResponses[keyof PermissionReplyResponses]

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

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

export type ProviderListError = ProviderListErrors[keyof ProviderListErrors]

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

export type ProviderListResponse = ProviderListResponses[keyof ProviderListResponses]

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

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

export type ProviderAuthError2 = ProviderAuthErrors[keyof ProviderAuthErrors]

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

export type ProviderAuthResponse = ProviderAuthResponses[keyof ProviderAuthResponses]

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

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

export type ProviderOauthAuthorizeError = ProviderOauthAuthorizeErrors[keyof ProviderOauthAuthorizeErrors]

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

export type ProviderOauthAuthorizeResponse = ProviderOauthAuthorizeResponses[keyof ProviderOauthAuthorizeResponses]

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

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

export type ProviderOauthCallbackError = ProviderOauthCallbackErrors[keyof ProviderOauthCallbackErrors]

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

export type ProviderOauthCallbackResponse = ProviderOauthCallbackResponses[keyof ProviderOauthCallbackResponses]

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

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

export type SessionListError = SessionListErrors[keyof SessionListErrors]

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

export type SessionListResponse = SessionListResponses[keyof SessionListResponses]

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

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

export type SessionCreateError = SessionCreateErrors[keyof SessionCreateErrors]

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

export type SessionCreateResponse = SessionCreateResponses[keyof SessionCreateResponses]

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

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

export type SessionStatusError = SessionStatusErrors[keyof SessionStatusErrors]

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

export type SessionStatusResponse = SessionStatusResponses[keyof SessionStatusResponses]

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

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

export type SessionDeleteError = SessionDeleteErrors[keyof SessionDeleteErrors]

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

export type SessionDeleteResponse = SessionDeleteResponses[keyof SessionDeleteResponses]

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

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

export type SessionGetError = SessionGetErrors[keyof SessionGetErrors]

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

export type SessionGetResponse = SessionGetResponses[keyof SessionGetResponses]

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

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

export type SessionUpdateError = SessionUpdateErrors[keyof SessionUpdateErrors]

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

export type SessionUpdateResponse = SessionUpdateResponses[keyof SessionUpdateResponses]

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

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

export type SessionChildrenError = SessionChildrenErrors[keyof SessionChildrenErrors]

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

export type SessionChildrenResponse = SessionChildrenResponses[keyof SessionChildrenResponses]

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

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

export type SessionTodoError = SessionTodoErrors[keyof SessionTodoErrors]

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

export type SessionTodoResponse = SessionTodoResponses[keyof SessionTodoResponses]

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

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

export type SessionDiffError = SessionDiffErrors[keyof SessionDiffErrors]

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

export type SessionDiffResponse = SessionDiffResponses[keyof SessionDiffResponses]

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

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

export type SessionMessagesError = SessionMessagesErrors[keyof SessionMessagesErrors]

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

export type SessionMessagesResponse2 = SessionMessagesResponses[keyof SessionMessagesResponses]

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

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

export type SessionPromptError = SessionPromptErrors[keyof SessionPromptErrors]

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

export type SessionPromptResponse = SessionPromptResponses[keyof SessionPromptResponses]

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

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

export type SessionDeleteMessageError = SessionDeleteMessageErrors[keyof SessionDeleteMessageErrors]

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

export type SessionDeleteMessageResponse = SessionDeleteMessageResponses[keyof SessionDeleteMessageResponses]

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

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

export type SessionMessageError = SessionMessageErrors[keyof SessionMessageErrors]

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

export type SessionMessageResponse = SessionMessageResponses[keyof SessionMessageResponses]

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

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

export type SessionForkError = SessionForkErrors[keyof SessionForkErrors]

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

export type SessionForkResponse = SessionForkResponses[keyof SessionForkResponses]

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

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

export type SessionAbortError = SessionAbortErrors[keyof SessionAbortErrors]

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

export type SessionAbortResponse = SessionAbortResponses[keyof SessionAbortResponses]

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

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

export type SessionInitError = SessionInitErrors[keyof SessionInitErrors]

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

export type SessionInitResponse = SessionInitResponses[keyof SessionInitResponses]

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

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

export type SessionUnshareError = SessionUnshareErrors[keyof SessionUnshareErrors]

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

export type SessionUnshareResponse = SessionUnshareResponses[keyof SessionUnshareResponses]

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

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

export type SessionShareError = SessionShareErrors[keyof SessionShareErrors]

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

export type SessionShareResponse = SessionShareResponses[keyof SessionShareResponses]

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

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

export type SessionSummarizeError = SessionSummarizeErrors[keyof SessionSummarizeErrors]

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

export type SessionSummarizeResponse = SessionSummarizeResponses[keyof SessionSummarizeResponses]

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

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

export type SessionPromptAsyncError = SessionPromptAsyncErrors[keyof SessionPromptAsyncErrors]

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

export type SessionPromptAsyncResponse = SessionPromptAsyncResponses[keyof SessionPromptAsyncResponses]

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

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

export type SessionCommandError = SessionCommandErrors[keyof SessionCommandErrors]

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

export type SessionCommandResponse = SessionCommandResponses[keyof SessionCommandResponses]

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

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

export type SessionShellError = SessionShellErrors[keyof SessionShellErrors]

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

export type SessionShellResponse = SessionShellResponses[keyof SessionShellResponses]

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

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

export type SessionRevertError = SessionRevertErrors[keyof SessionRevertErrors]

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

export type SessionRevertResponse = SessionRevertResponses[keyof SessionRevertResponses]

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

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

export type SessionUnrevertError = SessionUnrevertErrors[keyof SessionUnrevertErrors]

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

export type SessionUnrevertResponse = SessionUnrevertResponses[keyof SessionUnrevertResponses]

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

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

export type PermissionRespondError = PermissionRespondErrors[keyof PermissionRespondErrors]

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

export type PermissionRespondResponse = PermissionRespondResponses[keyof PermissionRespondResponses]

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

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

export type PartDeleteError = PartDeleteErrors[keyof PartDeleteErrors]

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

export type PartDeleteResponse = PartDeleteResponses[keyof PartDeleteResponses]

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

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

export type PartUpdateError = PartUpdateErrors[keyof PartUpdateErrors]

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

export type PartUpdateResponse = PartUpdateResponses[keyof PartUpdateResponses]

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

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

export type SyncStartError = SyncStartErrors[keyof SyncStartErrors]

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

export type SyncStartResponse = SyncStartResponses[keyof SyncStartResponses]

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

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

export type SyncReplayError = SyncReplayErrors[keyof SyncReplayErrors]

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

export type SyncReplayResponse = SyncReplayResponses[keyof SyncReplayResponses]

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

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

export type SyncStealError = SyncStealErrors[keyof SyncStealErrors]

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

export type SyncStealResponse = SyncStealResponses[keyof SyncStealResponses]

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

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

export type SyncHistoryListError = SyncHistoryListErrors[keyof SyncHistoryListErrors]

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

export type SyncHistoryListResponse = SyncHistoryListResponses[keyof SyncHistoryListResponses]

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

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

export type TuiAppendPromptError = TuiAppendPromptErrors[keyof TuiAppendPromptErrors]

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

export type TuiAppendPromptResponse = TuiAppendPromptResponses[keyof TuiAppendPromptResponses]

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

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

export type TuiOpenHelpError = TuiOpenHelpErrors[keyof TuiOpenHelpErrors]

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

export type TuiOpenHelpResponse = TuiOpenHelpResponses[keyof TuiOpenHelpResponses]

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

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

export type TuiOpenSessionsError = TuiOpenSessionsErrors[keyof TuiOpenSessionsErrors]

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

export type TuiOpenSessionsResponse = TuiOpenSessionsResponses[keyof TuiOpenSessionsResponses]

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

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

export type TuiOpenThemesError = TuiOpenThemesErrors[keyof TuiOpenThemesErrors]

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

export type TuiOpenThemesResponse = TuiOpenThemesResponses[keyof TuiOpenThemesResponses]

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

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

export type TuiOpenModelsError = TuiOpenModelsErrors[keyof TuiOpenModelsErrors]

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

export type TuiOpenModelsResponse = TuiOpenModelsResponses[keyof TuiOpenModelsResponses]

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

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

export type TuiSubmitPromptError = TuiSubmitPromptErrors[keyof TuiSubmitPromptErrors]

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

export type TuiSubmitPromptResponse = TuiSubmitPromptResponses[keyof TuiSubmitPromptResponses]

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

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

export type TuiClearPromptError = TuiClearPromptErrors[keyof TuiClearPromptErrors]

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

export type TuiClearPromptResponse = TuiClearPromptResponses[keyof TuiClearPromptResponses]

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

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

export type TuiExecuteCommandError = TuiExecuteCommandErrors[keyof TuiExecuteCommandErrors]

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

export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses]

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

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

export type TuiShowToastError = TuiShowToastErrors[keyof TuiShowToastErrors]

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

export type TuiShowToastResponse = TuiShowToastResponses[keyof TuiShowToastResponses]

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

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

export type TuiPublishError = TuiPublishErrors[keyof TuiPublishErrors]

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

export type TuiPublishResponse = TuiPublishResponses[keyof TuiPublishResponses]

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

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

export type TuiSelectSessionError = TuiSelectSessionErrors[keyof TuiSelectSessionErrors]

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

export type TuiSelectSessionResponse = TuiSelectSessionResponses[keyof TuiSelectSessionResponses]

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

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

export type TuiControlNextError = TuiControlNextErrors[keyof TuiControlNextErrors]

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

export type TuiControlNextResponse = TuiControlNextResponses[keyof TuiControlNextResponses]

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

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

export type TuiControlResponseError = TuiControlResponseErrors[keyof TuiControlResponseErrors]

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

export type TuiControlResponseResponse = TuiControlResponseResponses[keyof TuiControlResponseResponses]

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

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

export type ExperimentalWorkspaceAdapterListError =
  ExperimentalWorkspaceAdapterListErrors[keyof ExperimentalWorkspaceAdapterListErrors]

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

export type ExperimentalWorkspaceAdapterListResponse =
  ExperimentalWorkspaceAdapterListResponses[keyof ExperimentalWorkspaceAdapterListResponses]

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

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

export type ExperimentalWorkspaceListError = ExperimentalWorkspaceListErrors[keyof ExperimentalWorkspaceListErrors]

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

export type ExperimentalWorkspaceListResponse =
  ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses]

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

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

export type ExperimentalWorkspaceCreateError =
  ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors]

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

export type ExperimentalWorkspaceCreateResponse =
  ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses]

export type ExperimentalWorkspaceSyncListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/sync-list"
}

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

export type ExperimentalWorkspaceSyncListError =
  ExperimentalWorkspaceSyncListErrors[keyof ExperimentalWorkspaceSyncListErrors]

export type ExperimentalWorkspaceSyncListResponses = {
  /**
   * Workspace list synced
   */
  204: void
}

export type ExperimentalWorkspaceSyncListResponse =
  ExperimentalWorkspaceSyncListResponses[keyof ExperimentalWorkspaceSyncListResponses]

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

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

export type ExperimentalWorkspaceStatusError =
  ExperimentalWorkspaceStatusErrors[keyof ExperimentalWorkspaceStatusErrors]

export type ExperimentalWorkspaceStatusResponses = {
  /**
   * Workspace status
   */
  200: Array<WorkspaceEventConnectionStatus>
}

export type ExperimentalWorkspaceStatusResponse =
  ExperimentalWorkspaceStatusResponses[keyof ExperimentalWorkspaceStatusResponses]

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

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

export type ExperimentalWorkspaceRemoveError =
  ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors]

export type ExperimentalWorkspaceRemoveResponses = {
  /**
   * Workspace removed
   */
  200: Workspace
}

export type ExperimentalWorkspaceRemoveResponse =
  ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses]

export type ExperimentalWorkspaceWarpData = {
  body?: {
    id: string | null
    sessionID: string
    copyChanges?: boolean
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/warp"
}

export type ExperimentalWorkspaceWarpErrors = {
  /**
   * WorkspaceWarpError | VcsApplyError | InvalidRequestError
   */
  400: WorkspaceWarpError | VcsApplyError | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type ExperimentalWorkspaceWarpError = ExperimentalWorkspaceWarpErrors[keyof ExperimentalWorkspaceWarpErrors]

export type ExperimentalWorkspaceWarpResponses = {
  /**
   * Session warped
   */
  204: void
}

export type ExperimentalWorkspaceWarpResponse =
  ExperimentalWorkspaceWarpResponses[keyof ExperimentalWorkspaceWarpResponses]

export type V2HealthGetData = {
  body?: never
  path?: never
  query?: never
  url: "/api/health"
}

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

export type V2HealthGetError = V2HealthGetErrors[keyof V2HealthGetErrors]

export type V2HealthGetResponses = {
  /**
   * Success
   */
  200: {
    healthy: true
    version: string
    pid: number
  }
}

export type V2HealthGetResponse = V2HealthGetResponses[keyof V2HealthGetResponses]

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

export type V2LocationGetError = V2LocationGetErrors[keyof V2LocationGetErrors]

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

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

export type V2AgentListError = V2AgentListErrors[keyof V2AgentListErrors]

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

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

export type V2PluginListError = V2PluginListErrors[keyof V2PluginListErrors]

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

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

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?: ModelRef2 | null
    location?: LocationRef2 | null
  }
  path?: never
  query?: never
  url: "/api/session"
}

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

export type V2SessionCreateError = V2SessionCreateErrors[keyof V2SessionCreateErrors]

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

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

export type V2SessionActiveError = V2SessionActiveErrors[keyof V2SessionActiveErrors]

export type V2SessionActiveResponses = {
  /**
   * Success
   */
  200: {
    data: {
      [key: string]: unknown | SessionActiveV2
    }
    watermarks: SessionWatermarksV2
  }
}

export type V2SessionActiveResponse = V2SessionActiveResponses[keyof V2SessionActiveResponses]

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

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

export type V2SessionGetError = V2SessionGetErrors[keyof V2SessionGetErrors]

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

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | MessageNotFoundError
   */
  404: MessageNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionForkError = V2SessionForkErrors[keyof V2SessionForkErrors]

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

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionSwitchAgentError = V2SessionSwitchAgentErrors[keyof V2SessionSwitchAgentErrors]

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

export type V2SessionSwitchAgentResponse = V2SessionSwitchAgentResponses[keyof V2SessionSwitchAgentResponses]

export type V2SessionSwitchModelData = {
  body: {
    model: ModelRef2
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/model"
}

export type V2SessionSwitchModelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionRenameError = V2SessionRenameErrors[keyof V2SessionRenameErrors]

export type V2SessionRenameResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionRenameResponse = V2SessionRenameResponses[keyof V2SessionRenameResponses]

export type V2SessionPromptData = {
  body: {
    id?: string | null
    prompt: PromptInputV2
    delivery?: "steer" | "queue" | null
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/prompt"
}

export type V2SessionPromptErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]

export type V2SessionPromptResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInputAdmitted2
  }
}

export type V2SessionPromptResponse = V2SessionPromptResponses[keyof V2SessionPromptResponses]

export type V2SessionCommandData = {
  body: {
    id?: string | null
    command: string
    arguments?: string | null
    agent?: string | null
    model?: ModelRef2 | null
    files?: Array<PromptInputFileAttachment2>
    agents?: Array<PromptAgentAttachment2>
    delivery?: "steer" | "queue" | null
    resume?: boolean | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/command"
}

export type V2SessionCommandErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | CommandNotFoundError
   */
  404: CommandNotFoundErrorV2 | SessionNotFoundErrorV2
  /**
   * ConflictError
   */
  409: ConflictErrorV2
  /**
   * CommandEvaluationError
   */
  500: CommandEvaluationErrorV2
}

export type V2SessionCommandError = V2SessionCommandErrors[keyof V2SessionCommandErrors]

export type V2SessionCommandResponses = {
  /**
   * Success
   */
  200: {
    data: SessionInputAdmitted2
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | SkillNotFoundError
   */
  404: SkillNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionSkillError = V2SessionSkillErrors[keyof V2SessionSkillErrors]

export type V2SessionSkillResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionSkillResponse = V2SessionSkillResponses[keyof V2SessionSkillResponses]

export type V2SessionSyntheticData = {
  body: {
    text: string
    description?: string | null
    metadata?: {
      [key: string]: unknown
    }
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/synthetic"
}

export type V2SessionSyntheticErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionSyntheticError = V2SessionSyntheticErrors[keyof V2SessionSyntheticErrors]

export type V2SessionSyntheticResponses = {
  /**
   * <No Content>
   */
  204: void
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionShellError = V2SessionShellErrors[keyof V2SessionShellErrors]

export type V2SessionShellResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionShellResponse = V2SessionShellResponses[keyof V2SessionShellResponses]

export type V2SessionCompactData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/compact"
}

export type V2SessionCompactErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * SessionBusyError
   */
  409: SessionBusyErrorV2
  /**
   * UnknownError
   */
  500: UnknownErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]

export type V2SessionCompactResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionCompactResponse = V2SessionCompactResponses[keyof V2SessionCompactResponses]

export type V2SessionWaitData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/wait"
}

export type V2SessionWaitErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * 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: UnauthorizedErrorV2
  /**
   * MessageNotFoundError | SessionNotFoundError
   */
  404: MessageNotFoundErrorV2 | SessionNotFoundErrorV2
  /**
   * SessionBusyError
   */
  409: SessionBusyErrorV2
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2SessionRevertStageError = V2SessionRevertStageErrors[keyof V2SessionRevertStageErrors]

export type V2SessionRevertStageResponses = {
  /**
   * Success
   */
  200: {
    data: RevertState2
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * SessionBusyError
   */
  409: SessionBusyErrorV2
  /**
   * 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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * SessionBusyError
   */
  409: SessionBusyErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]

export type V2SessionContextResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionMessage2>
  }
}

export type V2SessionContextResponse = V2SessionContextResponses[keyof V2SessionContextResponses]

export type V2SessionContextEntryListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/context-entry"
}

export type V2SessionContextEntryListErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionContextEntryListError = V2SessionContextEntryListErrors[keyof V2SessionContextEntryListErrors]

export type V2SessionContextEntryListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionContextEntryInfo2>
  }
}

export type V2SessionContextEntryListResponse =
  V2SessionContextEntryListResponses[keyof V2SessionContextEntryListResponses]

export type V2SessionContextEntryRemoveData = {
  body?: never
  path: {
    sessionID: string
    key: SessionContextEntryKey2
  }
  query?: never
  url: "/api/session/{sessionID}/context-entry/{key}"
}

export type V2SessionContextEntryRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionContextEntryRemoveError =
  V2SessionContextEntryRemoveErrors[keyof V2SessionContextEntryRemoveErrors]

export type V2SessionContextEntryRemoveResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionContextEntryRemoveResponse =
  V2SessionContextEntryRemoveResponses[keyof V2SessionContextEntryRemoveResponses]

export type V2SessionContextEntryPutData = {
  body: {
    value: unknown
  }
  path: {
    sessionID: string
    key: SessionContextEntryKey2
  }
  query?: never
  url: "/api/session/{sessionID}/context-entry/{key}"
}

export type V2SessionContextEntryPutErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionContextEntryPutError = V2SessionContextEntryPutErrors[keyof V2SessionContextEntryPutErrors]

export type V2SessionContextEntryPutResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2SessionContextEntryPutResponse =
  V2SessionContextEntryPutResponses[keyof V2SessionContextEntryPutResponses]

export type V2SessionLogData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    after?: number | null
    follow?: "true" | "false" | null
  }
  url: "/api/session/{sessionID}/log"
}

export type V2SessionLogErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionLogError = V2SessionLogErrors[keyof V2SessionLogErrors]

export type V2SessionLogResponses = {
  /**
   * Success
   */
  200: {
    id: string | null
    event: string
    data: SessionLogItemStreamV2
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | MessageNotFoundError
   */
  404: MessageNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionMessageError = V2SessionMessageErrors[keyof V2SessionMessageErrors]

export type V2SessionMessageResponses = {
  /**
   * Success
   */
  200: {
    data: SessionMessage2
  }
}

export type V2SessionMessageResponse = V2SessionMessageResponses[keyof V2SessionMessageResponses]

export type V2SessionMessagesData = {
  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 V2SessionMessagesErrors = {
  /**
   * InvalidCursorError | InvalidRequestError
   */
  400: InvalidCursorErrorV2 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * UnknownError
   */
  500: UnknownErrorV2
}

export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]

export type V2SessionMessagesResponses = {
  /**
   * SessionMessagesResponse
   */
  200: SessionMessagesResponseV2
}

export type V2SessionMessagesResponse = V2SessionMessagesResponses[keyof V2SessionMessagesResponses]

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: UnauthorizedErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]

export type V2ModelListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<ModelV2Info2>
  }
}

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: UnauthorizedErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ModelDefaultError = V2ModelDefaultErrors[keyof V2ModelDefaultErrors]

export type V2ModelDefaultResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: ModelV2Info2 | null
  }
}

export type V2ModelDefaultResponse = V2ModelDefaultResponses[keyof V2ModelDefaultResponses]

export type V2GenerateTextData = {
  body: {
    prompt: string
    model?: ModelRef2 | null
  }
  path?: never
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/generate"
}

export type V2GenerateTextErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2GenerateTextError = V2GenerateTextErrors[keyof V2GenerateTextErrors]

export type V2GenerateTextResponses = {
  /**
   * GenerateTextResponse
   */
  200: GenerateTextResponseV2
}

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: UnauthorizedErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]

export type V2ProviderListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<ProviderV2Info2>
  }
}

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: UnauthorizedErrorV2
  /**
   * ProviderNotFoundError
   */
  404: ProviderNotFoundErrorV2
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableErrorV2
}

export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]

export type V2ProviderGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: ProviderV2Info2
  }
}

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: UnauthorizedErrorV2
}

export type V2IntegrationListError = V2IntegrationListErrors[keyof V2IntegrationListErrors]

export type V2IntegrationListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<IntegrationInfo2>
  }
}

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: UnauthorizedErrorV2
}

export type V2IntegrationGetError = V2IntegrationGetErrors[keyof V2IntegrationGetErrors]

export type V2IntegrationGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: IntegrationInfo2 | null
  }
}

export type V2IntegrationGetResponse = V2IntegrationGetResponses[keyof V2IntegrationGetResponses]

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: UnauthorizedErrorV2
}

export type V2IntegrationConnectKeyError = V2IntegrationConnectKeyErrors[keyof V2IntegrationConnectKeyErrors]

export type V2IntegrationConnectKeyResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationConnectKeyResponse = V2IntegrationConnectKeyResponses[keyof V2IntegrationConnectKeyResponses]

export type V2IntegrationConnectOauthData = {
  body: {
    methodID: string
    inputs: {
      [key: string]: string
    }
    label?: string | null
  }
  path: {
    integrationID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/{integrationID}/connect/oauth"
}

export type V2IntegrationConnectOauthErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2IntegrationConnectOauthError = V2IntegrationConnectOauthErrors[keyof V2IntegrationConnectOauthErrors]

export type V2IntegrationConnectOauthResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: IntegrationAttempt2
  }
}

export type V2IntegrationConnectOauthResponse =
  V2IntegrationConnectOauthResponses[keyof V2IntegrationConnectOauthResponses]

export type V2IntegrationAttemptCancelData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/attempt/{attemptID}"
}

export type V2IntegrationAttemptCancelErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2IntegrationAttemptCancelError = V2IntegrationAttemptCancelErrors[keyof V2IntegrationAttemptCancelErrors]

export type V2IntegrationAttemptCancelResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationAttemptCancelResponse =
  V2IntegrationAttemptCancelResponses[keyof V2IntegrationAttemptCancelResponses]

export type V2IntegrationAttemptStatusData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/attempt/{attemptID}"
}

export type V2IntegrationAttemptStatusErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2IntegrationAttemptStatusError = V2IntegrationAttemptStatusErrors[keyof V2IntegrationAttemptStatusErrors]

export type V2IntegrationAttemptStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: IntegrationAttemptStatus2
  }
}

export type V2IntegrationAttemptStatusResponse =
  V2IntegrationAttemptStatusResponses[keyof V2IntegrationAttemptStatusResponses]

export type V2IntegrationAttemptCompleteData = {
  body: {
    code?: string | null
  }
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string | null
      workspace?: string | null
    } | null
  }
  url: "/api/integration/attempt/{attemptID}/complete"
}

export type V2IntegrationAttemptCompleteErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2IntegrationAttemptCompleteError =
  V2IntegrationAttemptCompleteErrors[keyof V2IntegrationAttemptCompleteErrors]

export type V2IntegrationAttemptCompleteResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2IntegrationAttemptCompleteResponse =
  V2IntegrationAttemptCompleteResponses[keyof V2IntegrationAttemptCompleteResponses]

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: UnauthorizedErrorV2
}

export type V2McpListError = V2McpListErrors[keyof V2McpListErrors]

export type V2McpListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<McpServer2>
  }
}

export type V2McpListResponse = V2McpListResponses[keyof V2McpListResponses]

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: UnauthorizedErrorV2
}

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: UnauthorizedErrorV2
}

export type V2CredentialUpdateError = V2CredentialUpdateErrors[keyof V2CredentialUpdateErrors]

export type V2CredentialUpdateResponses = {
  /**
   * <No Content>
   */
  204: void
}

export type V2CredentialUpdateResponse = V2CredentialUpdateResponses[keyof V2CredentialUpdateResponses]

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: UnauthorizedErrorV2
}

export type V2ProjectCurrentError = V2ProjectCurrentErrors[keyof V2ProjectCurrentErrors]

export type V2ProjectCurrentResponses = {
  /**
   * Project.Current
   */
  200: ProjectCurrent2
}

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: UnauthorizedErrorV2
}

export type V2ProjectDirectoriesError = V2ProjectDirectoriesErrors[keyof V2ProjectDirectoriesErrors]

export type V2ProjectDirectoriesResponses = {
  /**
   * Project.Directories
   */
  200: ProjectDirectories2
}

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: UnauthorizedErrorV2
}

export type V2FormRequestListError = V2FormRequestListErrors[keyof V2FormRequestListErrors]

export type V2FormRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<FormFormInfo2 | FormUrlInfo2>
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionFormListError = V2SessionFormListErrors[keyof V2SessionFormListErrors]

export type V2SessionFormListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<FormFormInfo2 | FormUrlInfo2>
  }
}

export type V2SessionFormListResponse = V2SessionFormListResponses[keyof V2SessionFormListResponses]

export type V2SessionFormCreateData = {
  body: FormCreatePayload2
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form"
}

export type V2SessionFormCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError1 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
  /**
   * ConflictError
   */
  409: ConflictErrorV2
}

export type V2SessionFormCreateError = V2SessionFormCreateErrors[keyof V2SessionFormCreateErrors]

export type V2SessionFormCreateResponses = {
  /**
   * Success
   */
  200: {
    data: FormFormInfo2 | FormUrlInfo2
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionFormGetError = V2SessionFormGetErrors[keyof V2SessionFormGetErrors]

export type V2SessionFormGetResponses = {
  /**
   * Success
   */
  200: {
    data: FormFormInfo2 | FormUrlInfo2
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionFormStateError = V2SessionFormStateErrors[keyof V2SessionFormStateErrors]

export type V2SessionFormStateResponses = {
  /**
   * Success
   */
  200: {
    data: FormState2
  }
}

export type V2SessionFormStateResponse = V2SessionFormStateResponses[keyof V2SessionFormStateResponses]

export type V2SessionFormReplyData = {
  body: FormReply2
  path: {
    sessionID: string
    formID: string
  }
  query?: never
  url: "/api/session/{sessionID}/form/{formID}/reply"
}

export type V2SessionFormReplyErrors = {
  /**
   * FormInvalidAnswerError | InvalidRequestError
   */
  400: FormInvalidAnswerErrorV2 | InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundErrorV2 | SessionNotFoundErrorV2
  /**
   * FormAlreadySettledError
   */
  409: FormAlreadySettledErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | FormNotFoundError
   */
  404: FormNotFoundErrorV2 | SessionNotFoundErrorV2
  /**
   * FormAlreadySettledError
   */
  409: FormAlreadySettledErrorV2
}

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: UnauthorizedErrorV2
}

export type V2PermissionRequestListError = V2PermissionRequestListErrors[keyof V2PermissionRequestListErrors]

export type V2PermissionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<PermissionV2Request2>
  }
}

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: UnauthorizedErrorV2
}

export type V2PermissionSavedListError = V2PermissionSavedListErrors[keyof V2PermissionSavedListErrors]

export type V2PermissionSavedListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionSavedInfo2>
  }
}

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: UnauthorizedErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionPermissionListError = V2SessionPermissionListErrors[keyof V2SessionPermissionListErrors]

export type V2SessionPermissionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionV2Request2>
  }
}

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?: PermissionV2Source2
    agent?: string | null
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/permission"
}

export type V2SessionPermissionCreateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionPermissionCreateError = V2SessionPermissionCreateErrors[keyof V2SessionPermissionCreateErrors]

export type V2SessionPermissionCreateResponses = {
  /**
   * Success
   */
  200: {
    data: {
      id: string
      effect: PermissionV2Effect2
    }
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundErrorV2 | SessionNotFoundErrorV2
}

export type V2SessionPermissionGetError = V2SessionPermissionGetErrors[keyof V2SessionPermissionGetErrors]

export type V2SessionPermissionGetResponses = {
  /**
   * Success
   */
  200: {
    data: PermissionV2Request2
  }
}

export type V2SessionPermissionGetResponse = V2SessionPermissionGetResponses[keyof V2SessionPermissionGetResponses]

export type V2SessionPermissionReplyData = {
  body: {
    reply: PermissionV2Reply2
    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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundErrorV2 | SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
}

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: UnauthorizedErrorV2
}

export type V2FsListError = V2FsListErrors[keyof V2FsListErrors]

export type V2FsListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<FileSystemEntry2>
  }
}

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: UnauthorizedErrorV2
}

export type V2FsFindError = V2FsFindErrors[keyof V2FsFindErrors]

export type V2FsFindResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<FileSystemEntry2>
  }
}

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: UnauthorizedErrorV2
}

export type V2CommandListError = V2CommandListErrors[keyof V2CommandListErrors]

export type V2CommandListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<CommandV2Info2>
  }
}

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: UnauthorizedErrorV2
}

export type V2SkillListError = V2SkillListErrors[keyof V2SkillListErrors]

export type V2SkillListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<SkillV2Info2>
  }
}

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: UnauthorizedErrorV2
}

export type V2EventSubscribeError = V2EventSubscribeErrors[keyof V2EventSubscribeErrors]

export type V2EventSubscribeResponses = {
  /**
   * Success
   */
  200: V2Event
}

export type V2EventSubscribeResponse = V2EventSubscribeResponses[keyof V2EventSubscribeResponses]

export type V2EventChangesData = {
  body?: never
  path?: never
  query?: never
  url: "/api/event/changes"
}

export type V2EventChangesErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2EventChangesError = V2EventChangesErrors[keyof V2EventChangesErrors]

export type V2EventChangesResponses = {
  /**
   * Success
   */
  200: {
    id: string | null
    event: string
    data: EventLogChangeStream2
  }
}

export type V2EventChangesResponse = V2EventChangesResponses[keyof V2EventChangesResponses]

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: UnauthorizedErrorV2
}

export type V2PtyListError = V2PtyListErrors[keyof V2PtyListErrors]

export type V2PtyListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: UnauthorizedErrorV2
}

export type V2PtyCreateError = V2PtyCreateErrors[keyof V2PtyCreateErrors]

export type V2PtyCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: UnauthorizedErrorV2
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundErrorV2
}

export type V2PtyGetError = V2PtyGetErrors[keyof V2PtyGetErrors]

export type V2PtyGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: UnauthorizedErrorV2
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundErrorV2
}

export type V2PtyUpdateError = V2PtyUpdateErrors[keyof V2PtyUpdateErrors]

export type V2PtyUpdateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: UnauthorizedErrorV2
  /**
   * ForbiddenError
   */
  403: ForbiddenErrorV2
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundErrorV2
}

export type V2PtyConnectTokenError = V2PtyConnectTokenErrors[keyof V2PtyConnectTokenErrors]

export type V2PtyConnectTokenResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: PtyTicketConnectToken2
  }
}

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: UnauthorizedErrorV2
  /**
   * ForbiddenError
   */
  403: ForbiddenErrorV2
  /**
   * PtyNotFoundError
   */
  404: PtyNotFoundErrorV2
}

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: UnauthorizedErrorV2
}

export type V2ShellListError = V2ShellListErrors[keyof V2ShellListErrors]

export type V2ShellListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<ShellV2>
  }
}

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: UnauthorizedErrorV2
}

export type V2ShellCreateError = V2ShellCreateErrors[keyof V2ShellCreateErrors]

export type V2ShellCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: ShellV2
  }
}

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: UnauthorizedErrorV2
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundErrorV2
}

export type V2ShellGetError = V2ShellGetErrors[keyof V2ShellGetErrors]

export type V2ShellGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: ShellV2
  }
}

export type V2ShellGetResponse = V2ShellGetResponses[keyof V2ShellGetResponses]

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: UnauthorizedErrorV2
  /**
   * ShellNotFoundError
   */
  404: ShellNotFoundErrorV2
}

export type V2ShellOutputError = V2ShellOutputErrors[keyof V2ShellOutputErrors]

export type V2ShellOutputResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: UnauthorizedErrorV2
}

export type V2QuestionRequestListError = V2QuestionRequestListErrors[keyof V2QuestionRequestListErrors]

export type V2QuestionRequestListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<QuestionV2Request2>
  }
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundErrorV2
}

export type V2SessionQuestionListError = V2SessionQuestionListErrors[keyof V2SessionQuestionListErrors]

export type V2SessionQuestionListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<QuestionV2Request2>
  }
}

export type V2SessionQuestionListResponse = V2SessionQuestionListResponses[keyof V2SessionQuestionListResponses]

export type V2SessionQuestionReplyData = {
  body: QuestionV2Reply2
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question/{requestID}/reply"
}

export type V2SessionQuestionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundErrorV2 | SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundErrorV2 | SessionNotFoundErrorV2
}

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: UnauthorizedErrorV2
}

export type V2ReferenceListError = V2ReferenceListErrors[keyof V2ReferenceListErrors]

export type V2ReferenceListResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<ReferenceInfo2>
  }
}

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: UnauthorizedErrorV2
}

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: UnauthorizedErrorV2
}

export type V2ProjectCopyCreateError = V2ProjectCopyCreateErrors[keyof V2ProjectCopyCreateErrors]

export type V2ProjectCopyCreateResponses = {
  /**
   * ProjectCopy.Copy
   */
  200: ProjectCopyCopy2
}

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: UnauthorizedErrorV2
}

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: UnauthorizedErrorV2
}

export type V2VcsStatusError = V2VcsStatusErrors[keyof V2VcsStatusErrors]

export type V2VcsStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    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: VcsMode2
    context?: string | null
  }
  url: "/api/vcs/diff"
}

export type V2VcsDiffErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2VcsDiffError = V2VcsDiffErrors[keyof V2VcsDiffErrors]

export type V2VcsDiffResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo2
    data: Array<SnapshotFileDiffV2>
  }
}

export type V2VcsDiffResponse = V2VcsDiffResponses[keyof V2VcsDiffResponses]

export type V2DebugLocationData = {
  body?: never
  path?: never
  query?: never
  url: "/api/debug/location"
}

export type V2DebugLocationErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestErrorV2
  /**
   * UnauthorizedError
   */
  401: UnauthorizedErrorV2
}

export type V2DebugLocationError = V2DebugLocationErrors[keyof V2DebugLocationErrors]

export type V2DebugLocationResponses = {
  /**
   * Success
   */
  200: Array<LocationRef2>
}

export type V2DebugLocationResponse = V2DebugLocationResponses[keyof V2DebugLocationResponses]

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]
