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

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

export type Event =
  | EventModelsDevRefreshed
  | EventIntegrationUpdated
  | EventIntegrationConnectionUpdated
  | EventCatalogUpdated
  | EventSessionCreated
  | EventSessionUpdated
  | EventSessionDeleted
  | EventSessionNextCompleted
  | EventSessionNextAgentSwitched
  | EventSessionNextModelSwitched
  | EventSessionNextResponderSwitched
  | EventSessionNextModeSwitched
  | EventSessionNextStrictSwitched
  | EventSessionNextFeatureSwitched
  | EventSessionNextTypeSwitched
  | EventSessionNextPromptOverrideSwitched
  | EventSessionNextMoved
  | EventSessionNextPrompted
  | EventSessionNextPromptAdmitted
  | EventSessionNextContextUpdated
  | EventSessionNextSynthetic
  | EventSessionNextMessageRecorded
  | EventSessionNextShellStarted
  | EventSessionNextShellEnded
  | EventSessionNextStepStarted
  | EventSessionNextStepEnded
  | EventSessionNextStepFailed
  | EventSessionNextTextStarted
  | EventSessionNextTextDelta
  | EventSessionNextTextEnded
  | EventSessionNextReasoningStarted
  | EventSessionNextReasoningDelta
  | EventSessionNextReasoningEnded
  | EventSessionNextToolInputStarted
  | EventSessionNextToolInputDelta
  | EventSessionNextToolInputEnded
  | EventSessionNextToolCalled
  | EventSessionNextToolProgress
  | EventSessionNextToolSuccess
  | EventSessionNextToolFailed
  | EventSessionNextRetried
  | EventSessionNextCompactionStarted
  | EventSessionNextCompactionDelta
  | EventSessionNextCompactionEnded
  | EventSessionNextRevertStaged
  | EventSessionNextRevertCleared
  | EventSessionNextRevertCommitted
  | EventSessionError
  | EventInstallationUpdated
  | EventInstallationUpdateAvailable
  | EventAppRegistered
  | EventFileEdited
  | EventReferenceUpdated
  | EventPermissionV2Asked
  | EventPermissionV2Replied
  | EventPluginAdded
  | EventFileWatcherUpdated
  | EventPtyCreated
  | EventPtyUpdated
  | EventPtyExited
  | EventPtyDeleted
  | EventQuestionV2Asked
  | EventQuestionV2Replied
  | EventQuestionV2Rejected
  | EventMessengerAccountStatus
  | EventMessengerChatSeen
  | EventMessengerBindingUpdated
  | EventTodoUpdated
  | EventSessionTagsUpdated
  | EventPermissionAsked
  | EventPermissionReplied
  | EventMcpToolsChanged
  | EventMcpBrowserOpenFailed
  | 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
}

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

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

export type Auth = OAuth | ApiAuth | WellKnownAuth

export type EffectHttpApiErrorBadRequest = {
  _tag: "BadRequest"
}

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

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

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

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

export type PermissionRuleset = Array<PermissionRule>

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

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"
    }
  | {
      type: "exited"
    }

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

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

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

export type QuestionAnswer = Array<string>

export type GlobalEvent = {
  directory: string
  project?: string
  workspace?: string
  payload:
    | {
        id: string
        type: "models-dev.refreshed"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "integration.connection.updated"
        properties: {
          integrationID: string
        }
      }
    | {
        id: string
        type: "catalog.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "session.created"
        properties: {
          sessionID: string
          info: SessionV2Info
        }
      }
    | {
        id: string
        type: "session.updated"
        properties: {
          sessionID: string
          info: SessionV2Info
        }
      }
    | {
        id: string
        type: "session.deleted"
        properties: {
          sessionID: string
          info: SessionV2Info
        }
      }
    | {
        id: string
        type: "session.next.completed"
        properties: {
          timestamp: number
          sessionID: string
          result?: unknown
        }
      }
    | {
        id: string
        type: "session.next.agent.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          agent: string
        }
      }
    | {
        id: string
        type: "session.next.model.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          model: ModelRef
        }
      }
    | {
        id: string
        type: "session.next.responder.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          responder: "nova" | "operator"
        }
      }
    | {
        id: string
        type: "session.next.mode.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
        }
      }
    | {
        id: string
        type: "session.next.strict.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          strict: SessionStrictOverride
        }
      }
    | {
        id: string
        type: "session.next.feature.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          feature: "introspection" | "quality" | "affective"
          enabled: boolean
        }
      }
    | {
        id: string
        type: "session.next.type.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
        }
      }
    | {
        id: string
        type: "session.next.prompt-override.switched"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          override: string
        }
      }
    | {
        id: string
        type: "session.next.moved"
        properties: {
          timestamp: number
          sessionID: string
          location: LocationRef
          subdirectory?: string
        }
      }
    | {
        id: string
        type: "session.next.prompted"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          prompt: Prompt
          delivery: "steer" | "queue"
        }
      }
    | {
        id: string
        type: "session.next.prompt.admitted"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          prompt: Prompt
          delivery: "steer" | "queue"
        }
      }
    | {
        id: string
        type: "session.next.context.updated"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.synthetic"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.message.recorded"
        properties: {
          timestamp: number
          sessionID: string
          message: SessionMessage
        }
      }
    | {
        id: string
        type: "session.next.shell.started"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          callID: string
          command: string
        }
      }
    | {
        id: string
        type: "session.next.shell.ended"
        properties: {
          timestamp: number
          sessionID: string
          callID: string
          output: string
        }
      }
    | {
        id: string
        type: "session.next.step.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          agent: string
          model: ModelRef
          snapshot?: string
        }
      }
    | {
        id: string
        type: "session.next.step.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          finish: string
          cost: number
          tokens: {
            input: number
            output: number
            reasoning: number
            cache: {
              read: number
              write: number
            }
          }
          snapshot?: string
          files?: Array<string>
        }
      }
    | {
        id: string
        type: "session.next.step.failed"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          error: SessionErrorUnknown
        }
      }
    | {
        id: string
        type: "session.next.text.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
        }
      }
    | {
        id: string
        type: "session.next.text.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.text.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          textID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.reasoning.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        id: string
        type: "session.next.reasoning.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.reasoning.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          reasoningID: string
          text: string
          providerMetadata?: LlmProviderMetadata
        }
      }
    | {
        id: string
        type: "session.next.tool.input.started"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          name: string
        }
      }
    | {
        id: string
        type: "session.next.tool.input.delta"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          delta: string
        }
      }
    | {
        id: string
        type: "session.next.tool.input.ended"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.tool.called"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          tool: string
          input: {
            [key: string]: unknown
          }
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.tool.progress"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
        }
      }
    | {
        id: string
        type: "session.next.tool.success"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          structured: {
            [key: string]: unknown
          }
          content: Array<LlmToolContent>
          outputPaths?: Array<string>
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.tool.failed"
        properties: {
          timestamp: number
          sessionID: string
          assistantMessageID: string
          callID: string
          error: SessionErrorUnknown
          result?: unknown
          provider: {
            executed: boolean
            metadata?: LlmProviderMetadata
          }
        }
      }
    | {
        id: string
        type: "session.next.retried"
        properties: {
          timestamp: number
          sessionID: string
          attempt: number
          error: SessionNextRetryError
        }
      }
    | {
        id: string
        type: "session.next.compaction.started"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          reason: "auto" | "manual"
        }
      }
    | {
        id: string
        type: "session.next.compaction.delta"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          text: string
        }
      }
    | {
        id: string
        type: "session.next.compaction.ended"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
          reason: "auto" | "manual"
          text: string
          recent: string
        }
      }
    | {
        id: string
        type: "session.next.revert.staged"
        properties: {
          timestamp: number
          sessionID: string
          revert: RevertState
        }
      }
    | {
        id: string
        type: "session.next.revert.cleared"
        properties: {
          timestamp: number
          sessionID: string
        }
      }
    | {
        id: string
        type: "session.next.revert.committed"
        properties: {
          timestamp: number
          sessionID: string
          messageID: string
        }
      }
    | {
        id: string
        type: "session.error"
        properties: {
          sessionID?: string
          error: unknown
        }
      }
    | {
        id: string
        type: "installation.updated"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "installation.update-available"
        properties: {
          version: string
        }
      }
    | {
        id: string
        type: "app.registered"
        properties: {
          id: string
          title: string
        }
      }
    | {
        id: string
        type: "file.edited"
        properties: {
          file: string
        }
      }
    | {
        id: string
        type: "reference.updated"
        properties: {
          [key: string]: unknown
        }
      }
    | {
        id: string
        type: "permission.v2.asked"
        properties: {
          id: string
          sessionID: string
          action: string
          resources: Array<string>
          save?: Array<string>
          metadata?: {
            [key: string]: unknown
          }
          source?: PermissionV2Source
        }
      }
    | {
        id: string
        type: "permission.v2.replied"
        properties: {
          sessionID: string
          requestID: string
          reply: PermissionV2Reply
        }
      }
    | {
        id: string
        type: "plugin.added"
        properties: {
          id: string
        }
      }
    | {
        id: string
        type: "file.watcher.updated"
        properties: {
          file: string
          event: "add" | "change" | "unlink"
        }
      }
    | {
        id: string
        type: "pty.created"
        properties: {
          info: Pty
        }
      }
    | {
        id: string
        type: "pty.updated"
        properties: {
          info: Pty
        }
      }
    | {
        id: string
        type: "pty.exited"
        properties: {
          id: string
          exitCode: number
        }
      }
    | {
        id: string
        type: "pty.deleted"
        properties: {
          id: string
        }
      }
    | {
        id: string
        type: "question.v2.asked"
        properties: {
          id: string
          sessionID: string
          /**
           * Questions to ask
           */
          questions: Array<QuestionV2Info>
          tool?: QuestionV2Tool
        }
      }
    | {
        id: string
        type: "question.v2.replied"
        properties: {
          sessionID: string
          requestID: string
          answers: Array<QuestionV2Answer>
        }
      }
    | {
        id: string
        type: "question.v2.rejected"
        properties: {
          sessionID: string
          requestID: string
        }
      }
    | {
        id: string
        type: "messenger.account.status"
        properties: {
          accountID: string
          status: MessengerAccountStatus2
        }
      }
    | {
        id: string
        type: "messenger.chat.seen"
        properties: {
          accountID: string
          chatID: string
        }
      }
    | {
        id: string
        type: "messenger.binding.updated"
        properties: {
          bindingID: string
          sessionID: string
        }
      }
    | {
        id: string
        type: "todo.updated"
        properties: {
          sessionID: string
          todos: Array<Todo>
        }
      }
    | {
        id: string
        type: "session.tags.updated"
        properties: {
          sessionID: string
          tags: Array<string>
        }
      }
    | {
        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"
            | "allow-once"
            | "allow-file"
            | "allow-always"
            | "deny-once"
            | "deny-file"
            | "deny-always"
        }
      }
    | {
        id: string
        type: "mcp.tools.changed"
        properties: {
          server: string
        }
      }
    | {
        id: string
        type: "mcp.browser.open.failed"
        properties: {
          mcpName: string
          url: 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
    | SyncEventSessionNextCompleted
    | SyncEventSessionNextAgentSwitched
    | SyncEventSessionNextModelSwitched
    | SyncEventSessionNextResponderSwitched
    | SyncEventSessionNextModeSwitched
    | SyncEventSessionNextStrictSwitched
    | SyncEventSessionNextFeatureSwitched
    | SyncEventSessionNextTypeSwitched
    | SyncEventSessionNextPromptOverrideSwitched
    | SyncEventSessionNextMoved
    | SyncEventSessionNextPrompted
    | SyncEventSessionNextPromptAdmitted
    | SyncEventSessionNextContextUpdated
    | SyncEventSessionNextSynthetic
    | SyncEventSessionNextMessageRecorded
    | SyncEventSessionNextShellStarted
    | SyncEventSessionNextShellEnded
    | SyncEventSessionNextStepStarted
    | SyncEventSessionNextStepEnded
    | SyncEventSessionNextStepFailed
    | SyncEventSessionNextTextStarted
    | SyncEventSessionNextTextEnded
    | SyncEventSessionNextReasoningStarted
    | SyncEventSessionNextReasoningEnded
    | SyncEventSessionNextToolInputStarted
    | SyncEventSessionNextToolInputEnded
    | SyncEventSessionNextToolCalled
    | SyncEventSessionNextToolProgress
    | SyncEventSessionNextToolSuccess
    | SyncEventSessionNextToolFailed
    | SyncEventSessionNextRetried
    | SyncEventSessionNextCompactionStarted
    | SyncEventSessionNextCompactionEnded
    | SyncEventSessionNextRevertStaged
    | SyncEventSessionNextRevertCleared
    | SyncEventSessionNextRevertCommitted
}

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

export type ProviderCatalog = {
  providers: Array<ProviderV2Info>
  models: Array<ModelV2Info>
  connected: Array<string>
  default: {
    [key: string]: string
  }
}

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 McpResource = {
  name: string
  uri: string
  description?: string
  mimeType?: string
  client: string
}

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

export type FileContent = {
  type: "text" | "binary" | "missing"
  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 TrashEntry = {
  id: string
  originalPath: string
  trashedAt: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  type: "file" | "directory"
}

export type Path = {
  home: string
  state: string
  config: string
  data: string
  worktree: string
  directory: string
  roots: Array<string>
  virtual?: boolean
  virtualRoot?: string
  scratchDir?: string
  places?: Array<{
    name: string
    path: 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 FormatterStatus = {
  name: string
  extensions: Array<string>
  enabled: boolean
}

export type AppManifest = {
  id: string
  title: string
  icon?: string
  accent?: string
  subtitle?: string
  open: {
    type: "route" | "url" | "prompt"
    value: string
  }
  createdAt: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  updatedAt: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

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

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 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 ProviderAuthError = {
  name:
    | "BadRequest"
    | "ProviderAuthOauthMissing"
    | "ProviderAuthOauthCodeMissing"
    | "ProviderAuthOauthCallbackFailed"
    | "ProviderAuthValidationFailed"
  data: {
    providerID?: string
    field?: string
    message?: string
    kind?: string
  }
}

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

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

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

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

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

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

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

export type SessionActive = {
  type: "running"
}

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

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

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

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

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

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

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

export type SessionDurableEventStream = string

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

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

export type MessengerAccountStatus = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "messenger.account.status"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    accountID: string
    status: MessengerAccountStatus1
  }
}

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

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

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

export type V2Event =
  | ModelsDevRefreshed
  | IntegrationUpdated
  | IntegrationConnectionUpdated
  | CatalogUpdated
  | SessionCreated
  | SessionUpdated
  | SessionDeleted
  | SessionNextCompleted
  | SessionNextAgentSwitched
  | SessionNextModelSwitched
  | SessionNextResponderSwitched
  | SessionNextModeSwitched
  | SessionNextStrictSwitched
  | SessionNextFeatureSwitched
  | SessionNextTypeSwitched
  | SessionNextPromptOverrideSwitched
  | SessionNextMoved
  | SessionNextPrompted
  | SessionNextPromptAdmitted
  | SessionNextContextUpdated
  | SessionNextSynthetic
  | SessionNextMessageRecorded
  | SessionNextShellStarted
  | SessionNextShellEnded
  | SessionNextStepStarted
  | SessionNextStepEnded
  | SessionNextStepFailed
  | SessionNextTextStarted
  | SessionNextTextDelta
  | SessionNextTextEnded
  | SessionNextReasoningStarted
  | SessionNextReasoningDelta
  | SessionNextReasoningEnded
  | SessionNextToolInputStarted
  | SessionNextToolInputDelta
  | SessionNextToolInputEnded
  | SessionNextToolCalled
  | SessionNextToolProgress
  | SessionNextToolSuccess
  | SessionNextToolFailed
  | SessionNextRetried
  | SessionNextCompactionStarted
  | SessionNextCompactionDelta
  | SessionNextCompactionEnded
  | SessionNextRevertStaged
  | SessionNextRevertCleared
  | SessionNextRevertCommitted
  | SessionError
  | InstallationUpdated
  | InstallationUpdateAvailable
  | AppRegistered
  | FileEdited
  | ReferenceUpdated
  | PermissionV2Asked
  | PermissionV2Replied
  | PluginAdded
  | FileWatcherUpdated
  | PtyCreated
  | PtyUpdated
  | PtyExited
  | PtyDeleted
  | QuestionV2Asked
  | QuestionV2Replied
  | QuestionV2Rejected
  | MessengerAccountStatus
  | MessengerChatSeen
  | MessengerBindingUpdated
  | TodoUpdated
  | SessionTagsUpdated
  | PermissionAsked
  | PermissionReplied
  | McpToolsChanged
  | McpBrowserOpenFailed
  | 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 EffectHttpApiErrorForbidden = {
  _tag: "Forbidden"
}

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 SessionStrictOverride = {
  enabled?: boolean
  attempts?: number
  wallMinutes?: number
}

export type LocationRef = {
  directory: string
  workspaceID?: 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 SessionChangeDiff = {
  file?: string
  patch?: string
  additions: number
  deletions: number
  status?: "added" | "deleted" | "modified"
}

export type SessionChangesSummary = {
  additions: number
  deletions: number
  files: number
  diffs?: Array<SessionChangeDiff>
}

export type SessionV2Info = {
  id: string
  parentID?: string
  slug: string
  version: string
  permission?: PermissionRuleset
  metadata?: {
    [key: string]: unknown
  }
  agent?: string
  model?: ModelRef
  systemPromptOverride?: string
  type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
  priority?: number
  responder?: "nova" | "operator"
  permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
  strict?: SessionStrictOverride
  introspection?: boolean
  quality?: boolean
  affective?: boolean
  result?: unknown
  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
  summary?: SessionChangesSummary
}

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 PromptOrigin =
  | {
      via: "agent"
      sessionID: string
      label?: string
    }
  | {
      via: "messenger"
      driver: string
      accountID: string
      chatID: string
      chatKind?: string
      chatTitle?: string
      senderID: string
      senderName: string
      messageID: string
      replyTo?: string
      trust: "operator" | "client" | "audience"
      at?: number
    }

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

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

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

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

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

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

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

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

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 ToolTextContent = {
  type: "text"
  text: string
}

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

export type LlmToolContent = ToolTextContent | ToolFileContent

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 SessionErrorUnknown = {
  type: "unknown"
  message: string
}

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

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

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

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

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

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

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

export type PermissionV2Reply =
  | "once"
  | "always"
  | "reject"
  | "allow-once"
  | "allow-file"
  | "allow-always"
  | "deny-once"
  | "deny-file"
  | "deny-always"

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 MessengerAccountStatus2 =
  | {
      state: "disabled"
    }
  | {
      state: "airgapped"
    }
  | {
      state: "connecting"
    }
  | {
      state: "connected"
    }
  | {
      state: "backoff"
      until: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      message: string
    }
  | {
      state: "challenge"
      message: string
    }
  | {
      state: "error"
      message: string
    }

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

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

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

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

export type SyncEventSessionNextCompleted = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.completed.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      result?: unknown
    }
  }
}

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

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

export type SyncEventSessionNextResponderSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.responder.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      responder: "nova" | "operator"
    }
  }
}

export type SyncEventSessionNextModeSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.mode.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    }
  }
}

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

export type SyncEventSessionNextFeatureSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.feature.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      feature: "introspection" | "quality" | "affective"
      enabled: boolean
    }
  }
}

export type SyncEventSessionNextTypeSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.type.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    }
  }
}

export type SyncEventSessionNextPromptOverrideSwitched = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.prompt-override.switched.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      messageID: string
      override: string
    }
  }
}

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

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

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

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

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

export type SyncEventSessionNextMessageRecorded = {
  type: "sync"
  id: string
  syncEvent: {
    type: "session.next.message.recorded.1"
    id: string
    seq: number
    aggregateID: string
    data: {
      timestamp: number
      sessionID: string
      message: SessionMessage
    }
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type ConfigV2Server = {
  port?: number
  hostname?: string
  password?: string
  mdns?: boolean
  mdnsDomain?: string
  cors?: Array<string>
}

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

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

export type PermissionV2Ruleset = Array<PermissionV2Rule>

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

export type ConfigV2Agent = {
  model?: string
  variant?: string
  request?: ConfigV2ProviderRequest
  system?: string
  description?: string
  mode?: "subagent" | "primary" | "all"
  hidden?: boolean
  color?: string | "primary" | "secondary" | "accent" | "success" | "warning" | "error" | "info"
  steps?: number
  disabled?: boolean
  permissions?: PermissionV2Ruleset
}

export type ConfigV2Watcher = {
  ignore?: Array<string>
}

export type ConfigV2FormatterEntry = {
  disabled?: boolean
  command?: Array<string>
  environment?: {
    [key: string]: string
  }
  extensions?: Array<string>
}

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

export type ConfigV2Attachments = {
  image?: ConfigV2AttachmentsImage
}

export type ConfigV2ToolOutput = {
  max_lines?: number
  max_bytes?: number
}

export type ConfigV2McpTimeout = {
  startup?: number
  request?: number
}

export type ConfigV2McpLocal = {
  type: "local"
  command: Array<string>
  cwd?: string
  environment?: {
    [key: string]: string
  }
  disabled?: boolean
  timeout?: ConfigV2McpTimeout
}

export type ConfigV2McpoAuth = {
  client_id?: string
  client_secret?: string
  scope?: string
  callback_port?: number
  redirect_uri?: string
}

export type ConfigV2McpRemote = {
  type: "remote"
  url: string
  headers?: {
    [key: string]: string
  }
  oauth?: ConfigV2McpoAuth | false
  disabled?: boolean
  timeout?: ConfigV2McpTimeout
}

export type ConfigV2Mcp = {
  timeout?: ConfigV2McpTimeout
  servers?: {
    [key: string]: ConfigV2McpLocal | ConfigV2McpRemote
  }
}

export type ConfigV2CompactionKeep = {
  tokens?: number
}

export type ConfigV2Compaction = {
  auto?: boolean
  prune?: boolean
  keep?: ConfigV2CompactionKeep
  buffer?: number
}

export type ConfigV2Command = {
  template: string
  description?: string
  agent?: string
  model?: string
  variant?: string
  subtask?: boolean
}

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

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

export type ConfigV2PluginEntry = {
  package: string
  options?: {
    [key: string]: unknown
  }
}

export type PolicyEffect = "allow" | "deny"

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

export type ConfigV2Experimental = {
  policies?: Array<ConfigV2ExperimentalPolicy>
}

export type ConfigV2ProviderPreset = {
  name?: string
  description?: string
  baseURL?: string
  keyURL?: string
  api?: "@ai-sdk/openai" | "@ai-sdk/anthropic" | "@ai-sdk/openai-compatible"
  authStyle?: "bearer" | "anthropic"
  hidden?: boolean
}

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 ModelCapabilities = {
  tools: boolean
  input: Array<string>
  output: Array<string>
}

export type ConfigV2ModelCostCache = {
  read?: number
  write?: number
}

export type ConfigV2ModelCost = {
  tier?: {
    type: "context"
    size: number
  }
  input: number
  output: number
  cache?: ConfigV2ModelCostCache
}

export type ConfigV2ModelLimit = {
  context?: number
  input?: number
  output?: number
}

export type ConfigV2Model = {
  family?: string
  name?: string
  api?:
    | {
        id?: string
        type: "aisdk"
        package: string
        url?: string
        settings?: {
          [key: string]: unknown
        }
      }
    | {
        id?: string
        type: "native"
        url?: string
        settings: {
          [key: string]: unknown
        }
      }
    | {
        id: string
      }
  capabilities?: ModelCapabilities
  request?: {
    headers?: {
      [key: string]: string
    }
    body?: {
      [key: string]: unknown
    }
    variant?: string
  }
  variants?: Array<{
    id: string
    headers?: {
      [key: string]: string
    }
    body?: {
      [key: string]: unknown
    }
  }>
  cost?: ConfigV2ModelCost | Array<ConfigV2ModelCost>
  tier?: "micro" | "tiny" | "small" | "medium" | "large" | "frontier"
  disabled?: boolean
  limit?: ConfigV2ModelLimit
}

export type ConfigV2Provider = {
  name?: string
  env?: Array<string>
  api?: ProviderApi
  request?: ConfigV2ProviderRequest
  models?: {
    [key: string]: ConfigV2Model
  }
}

export type ConfigV2ModelEntry = {
  name?: string
  url?: string
  family?: string
  api?:
    | {
        id?: string
        type: "aisdk"
        package: string
        url?: string
        settings?: {
          [key: string]: unknown
        }
      }
    | {
        id?: string
        type: "native"
        url?: string
        settings: {
          [key: string]: unknown
        }
      }
    | {
        id: string
      }
  capabilities?: ModelCapabilities
  request?: {
    headers?: {
      [key: string]: string
    }
    body?: {
      [key: string]: unknown
    }
    variant?: string
  }
  variants?: Array<{
    id: string
    headers?: {
      [key: string]: string
    }
    body?: {
      [key: string]: unknown
    }
  }>
  cost?: ConfigV2ModelCost | Array<ConfigV2ModelCost>
  tier?: "micro" | "tiny" | "small" | "medium" | "large" | "frontier"
  disabled?: boolean
  limit?: ConfigV2ModelLimit
}

export type ConfigInfo = {
  $schema?: string
  shell?: string
  model?: string
  default_agent?: string
  /**
   * Automatically update or notify when a new version is available
   */
  autoupdate?: boolean | "notify"
  username?: string
  expertise?: "normal" | "advanced" | "developer"
  server?: ConfigV2Server
  permissions?: PermissionV2Ruleset
  agents?: {
    [key: string]: ConfigV2Agent
  }
  snapshots?: boolean
  watcher?: ConfigV2Watcher
  /**
   * Enable built-in formatters or configure formatter overrides
   */
  formatter?:
    | boolean
    | {
        [key: string]: ConfigV2FormatterEntry
      }
  attachments?: ConfigV2Attachments
  tool_output?: ConfigV2ToolOutput
  mcp?: ConfigV2Mcp
  compaction?: ConfigV2Compaction
  persona?: {
    enabled?: boolean
    name?: string
    prompt?: string
  }
  user_profile?: {
    enabled?: boolean
    name?: string
    about?: string
  }
  introspection?: {
    enabled?: boolean
    /**
     * Judge every N continuation steps within a turn drain (default: 3)
     */
    cadence?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    model?: string
    prompt?: string
    interjection?: string
    generateInterjection?: boolean
  }
  adhoc_tools?: Array<{
    /**
     * Tool name (lowercase slug) listed in the system prompt
     */
    name: string
    /**
     * One-line description shown beside the name (the model decides from this alone)
     */
    description: string
    /**
     * Free-text manual the model pulls on demand: the API shape plus 1-2 curl/shell examples
     */
    manual: string
    enabled?: boolean
  }>
  affective?: {
    enabled?: boolean
    /**
     * Calm-baseline temperature when the model config sets none (default: 0.7)
     */
    temperature?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    extended?: boolean
  }
  strict?: {
    enabled?: boolean
    verification?: boolean
    recovery?: boolean
    editingAids?: boolean
    budgetSteering?: boolean
    /**
     * Wall-clock budget per Strict task in minutes; the engine stops through its terminal best-restore at exhaustion (default: 45)
     */
    wallMinutes?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    /**
     * Best-of-N racing (jh.md §14.2): run N isolated attempts on FORKED copies of the workspace and keep the first verified winner (1 = off, max 8). Explicit opt-in — costs ~N× compute; the Spark's bandwidth-bound decoding makes concurrent attempts nearly free capacity (default: 1)
     */
    attempts?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    /**
     * Token budget for EXECUTION steps — the calls that fill in the step schema and write files. Truncation is fatal here (jh.md §3: a non-trivial C source file is ~13-15k tokens), so leave headroom (default: 24576)
     */
    executionTokens?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    /**
     * Token budget for the REASONING stage that plans a step before it runs — 0 disables the stage (notes/jh-think-stage.md). MEASURED on qwen3.6-35b: a reasoning model cut off mid-thought returns EMPTY, because the close of its <think> block never arrives and the parser has nothing to extract — 3072 and 8192 both yield nothing, 24576 completes (18974 tokens used). Budget it generously or not at all: an empty finish=length reply is a BUDGET reading, never a capability reading (default: 0 = off)
     */
    reasoningTokens?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
  instances?: Array<{
    /**
     * Peer name (also keys the NOVACLAW_INSTANCE_<NAME>_* env vars)
     */
    name: string
    /**
     * The peer's base URL, e.g. http://127.0.0.1:4097
     */
    url: string
    token?: string
  }>
  folder_bookmarks?: Array<string>
  virtualFs?: boolean
  offline?: boolean
  telemetry?: {
    enabled?: boolean
  }
  memory?: {
    enabled?: boolean
    rerank?: boolean
    embedding?: {
      url?: string
      model?: string
    }
  }
  quality?: {
    enabled?: boolean
    cadence?: number
    testTimeout?: number
    commands?: {
      syntax?: string
      check?: string
      typecheck?: string
      test?: string
      lint?: string
    }
  }
  skills?: Array<string>
  commands?: {
    [key: string]: ConfigV2Command
  }
  instructions?: Array<string>
  references?: {
    [key: string]: string | ConfigV2ReferenceGit | ConfigV2ReferenceLocal
  }
  plugins?: Array<string | ConfigV2PluginEntry>
  experimental?: ConfigV2Experimental
  provider_presets?: {
    [key: string]: ConfigV2ProviderPreset
  }
  providers?: {
    [key: string]: ConfigV2Provider
  }
  models?: {
    [key: string]: ConfigV2ModelEntry
  }
  disabled_providers?: Array<string>
  enabled_providers?: Array<string>
}

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

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

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 ModelCost = {
  tier?: {
    type: "context"
    size: number
  }
  input: number
  output: number
  cache: {
    read: number
    write: number
  }
}

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

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

export type DbRegistryTableSummary = {
  name: string
  rowCount: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type DbRegistryTableRow = {
  rowid: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  values: {
    [key: string]: unknown
  }
}

export type DbRegistryTablePage = {
  table: string
  columns: Array<string>
  rowCount: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  rows: Array<DbRegistryTableRow>
}

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

export type LocationInfo = {
  directory: string
  workspaceID?: string
  root: string
  origin: string
}

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

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 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 SessionNextCompleted = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.completed"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    result?: unknown
  }
}

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

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

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

export type SessionNextModeSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.mode.switched"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
  }
}

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

export type SessionNextFeatureSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.feature.switched"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    feature: "introspection" | "quality" | "affective"
    enabled: boolean
  }
}

export type SessionNextTypeSwitched = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "session.next.type.switched"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    timestamp: number
    sessionID: string
    messageID: string
    sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type 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 MessengerAuth = "login" | "key" | "none"

export type MessengerCapabilities = {
  listChats: "full" | "seen" | "none"
  files: {
    up: boolean
    down: boolean
    maxBytes?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
  edits: boolean
  typing: boolean
  threads: boolean
  moderation: {
    delete: boolean
    ban: boolean
    kick: boolean
    mute: boolean
    pin: boolean
  }
  format: "plain" | "markdown" | "html"
  maxChars: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  maxBytes?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type MessengerDriverMeta = {
  id: string
  name: string
  icon: string
  auth: MessengerAuth
  settings: Array<IntegrationTextPrompt | IntegrationSelectPrompt>
  loginPrompts?: Array<IntegrationTextPrompt | IntegrationSelectPrompt>
  loginStyle?: "code" | "browser"
  capabilities: MessengerCapabilities
}

export type MessengerAccountInfo = {
  id: string
  driverID: string
  label: string
  enabled: boolean
  credentialID?: string
  settings: {
    [key: string]: string
  }
}

export type MessengerAccountWithStatus = {
  account: MessengerAccountInfo
  status: MessengerAccountStatus2
}

export type MessengerChatKind = "dm" | "group" | "channel" | "thread" | "mailbox" | "topic"

export type MessengerChatInfo = {
  accountID: string
  chatID: string
  kind: MessengerChatKind
  title: string
  lastSeen: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}

export type MessengerTrust = "operator" | "client" | "audience"

export type MessengerBindingStatus = "active" | "paused"

export type MessengerBindingInfo = {
  id: string
  accountID: string
  chatID: string
  sessionID: string
  trust: MessengerTrust
  status: MessengerBindingStatus
}

export type MessengerLoginAttempt = {
  attemptID: string
  instructions: string
  qrImage?: string
  time: {
    created: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    expires: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

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

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

export type PermissionSavedInfo = {
  id: string
  origin: string
  action: string
  resource: string
  effect?: "allow" | "deny"
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type AppRegistered = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "app.registered"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    id: string
    title: string
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

export type MessengerAccountStatus1 =
  | {
      state: "disabled"
    }
  | {
      state: "airgapped"
    }
  | {
      state: "connecting"
    }
  | {
      state: "connected"
    }
  | {
      state: "backoff"
      until: number | "NaN" | "Infinity" | "-Infinity"
      message: string
    }
  | {
      state: "challenge"
      message: string
    }
  | {
      state: "error"
      message: string
    }

export type MessengerChatSeen = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "messenger.chat.seen"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    accountID: string
    chatID: string
  }
}

export type MessengerBindingUpdated = {
  id: string
  metadata?: {
    [key: string]: unknown
  }
  type: "messenger.binding.updated"
  durable?: {
    aggregateID: string
    seq: number
    version: number
  }
  location?: LocationRef
  data: {
    bindingID: string
    sessionID: string
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type ReferenceSource = ReferenceLocalSource | ReferenceGitSource

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

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

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

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

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

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

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

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

export type EventSessionNextCompleted = {
  id: string
  type: "session.next.completed"
  properties: {
    timestamp: number
    sessionID: string
    result?: unknown
  }
}

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

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

export type EventSessionNextResponderSwitched = {
  id: string
  type: "session.next.responder.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    responder: "nova" | "operator"
  }
}

export type EventSessionNextModeSwitched = {
  id: string
  type: "session.next.mode.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
  }
}

export type EventSessionNextStrictSwitched = {
  id: string
  type: "session.next.strict.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    strict: SessionStrictOverride
  }
}

export type EventSessionNextFeatureSwitched = {
  id: string
  type: "session.next.feature.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    feature: "introspection" | "quality" | "affective"
    enabled: boolean
  }
}

export type EventSessionNextTypeSwitched = {
  id: string
  type: "session.next.type.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
  }
}

export type EventSessionNextPromptOverrideSwitched = {
  id: string
  type: "session.next.prompt-override.switched"
  properties: {
    timestamp: number
    sessionID: string
    messageID: string
    override: string
  }
}

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

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

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

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

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

export type EventSessionNextMessageRecorded = {
  id: string
  type: "session.next.message.recorded"
  properties: {
    timestamp: number
    sessionID: string
    message: SessionMessage
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type EventSessionError = {
  id: string
  type: "session.error"
  properties: {
    sessionID?: string
    error: unknown
  }
}

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 EventAppRegistered = {
  id: string
  type: "app.registered"
  properties: {
    id: string
    title: string
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

export type EventMessengerAccountStatus = {
  id: string
  type: "messenger.account.status"
  properties: {
    accountID: string
    status: MessengerAccountStatus1
  }
}

export type EventMessengerChatSeen = {
  id: string
  type: "messenger.chat.seen"
  properties: {
    accountID: string
    chatID: string
  }
}

export type EventMessengerBindingUpdated = {
  id: string
  type: "messenger.binding.updated"
  properties: {
    bindingID: string
    sessionID: string
  }
}

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

export type EventSessionTagsUpdated = {
  id: string
  type: "session.tags.updated"
  properties: {
    sessionID: string
    tags: Array<string>
  }
}

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"
      | "allow-once"
      | "allow-file"
      | "allow-always"
      | "deny-once"
      | "deny-file"
      | "deny-always"
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export type AuthRemoveError = AuthRemoveErrors[keyof AuthRemoveErrors]

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

export type AuthRemoveResponse = AuthRemoveResponses[keyof AuthRemoveResponses]

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

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

export type AuthSetError = AuthSetErrors[keyof AuthSetErrors]

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

export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses]

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

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

export type AppLogError = AppLogErrors[keyof AppLogErrors]

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

export type AppLogResponse = AppLogResponses[keyof AppLogResponses]

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

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

export type ExperimentalControlPlaneMoveSessionError =
  ExperimentalControlPlaneMoveSessionErrors[keyof ExperimentalControlPlaneMoveSessionErrors]

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

export type ExperimentalControlPlaneMoveSessionResponse =
  ExperimentalControlPlaneMoveSessionResponses[keyof ExperimentalControlPlaneMoveSessionResponses]

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

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

export type GlobalHealthError = GlobalHealthErrors[keyof GlobalHealthErrors]

export type GlobalHealthResponses = {
  /**
   * Health information
   */
  200: {
    healthy: true
    version: string
    instanceID: 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: ConfigInfo
}

export type GlobalConfigGetResponse = GlobalConfigGetResponses[keyof GlobalConfigGetResponses]

export type GlobalConfigUpdateData = {
  body?: ConfigInfo
  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: ConfigInfo
}

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 GlobalDiscoveryData = {
  body?: never
  path?: never
  query?: never
  url: "/global/discovery"
}

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

export type GlobalDiscoveryError = GlobalDiscoveryErrors[keyof GlobalDiscoveryErrors]

export type GlobalDiscoveryResponses = {
  /**
   * NovaClaw instances discovered on the local network
   */
  200: {
    instances: Array<{
      name: string
      url: string
      instanceID?: string
      version?: string
      self: boolean
    }>
  }
}

export type GlobalDiscoveryResponse = GlobalDiscoveryResponses[keyof GlobalDiscoveryResponses]

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 AdhocListData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/adhoc/session/{sessionID}"
}

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

export type AdhocListError = AdhocListErrors[keyof AdhocListErrors]

export type AdhocListResponses = {
  /**
   * The session's model-defined recipes
   */
  200: Array<{
    name: string
    description: string
    manual: string
    enabled?: boolean
  }>
}

export type AdhocListResponse = AdhocListResponses[keyof AdhocListResponses]

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

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

export type AdhocDiscardError = AdhocDiscardErrors[keyof AdhocDiscardErrors]

export type AdhocDiscardResponses = {
  /**
   * Whether a recipe was removed
   */
  200: {
    removed: boolean
  }
}

export type AdhocDiscardResponse = AdhocDiscardResponses[keyof AdhocDiscardResponses]

export type AdhocPromoteData = {
  body?: never
  path: {
    sessionID: string
    name: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/adhoc/session/{sessionID}/{name}/promote"
}

export type AdhocPromoteErrors = {
  /**
   * Bad request
   */
  400: BadRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type AdhocPromoteError = AdhocPromoteErrors[keyof AdhocPromoteErrors]

export type AdhocPromoteResponses = {
  /**
   * The config key written
   */
  200: {
    promoted: string
  }
}

export type AdhocPromoteResponse = AdhocPromoteResponses[keyof AdhocPromoteResponses]

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

export type ConfigGetResponse = ConfigGetResponses[keyof ConfigGetResponses]

export type ConfigUpdateData = {
  body?: ConfigInfo
  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: ConfigInfo
}

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

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 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 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 FileWriteData = {
  body?: {
    path: string
    content: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/file/content"
}

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

export type FileWriteError = FileWriteErrors[keyof FileWriteErrors]

export type FileWriteResponses = {
  /**
   * File written
   */
  200: {
    ok: true
  }
}

export type FileWriteResponse = FileWriteResponses[keyof FileWriteResponses]

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 FileMkdirData = {
  body?: {
    path: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/file/mkdir"
}

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

export type FileMkdirError = FileMkdirErrors[keyof FileMkdirErrors]

export type FileMkdirResponses = {
  /**
   * Directory created
   */
  200: {
    ok: true
  }
}

export type FileMkdirResponse = FileMkdirResponses[keyof FileMkdirResponses]

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

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

export type FileTrashListError = FileTrashListErrors[keyof FileTrashListErrors]

export type FileTrashListResponses = {
  /**
   * Trash entries
   */
  200: Array<TrashEntry>
}

export type FileTrashListResponse = FileTrashListResponses[keyof FileTrashListResponses]

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

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

export type FileTrashError = FileTrashErrors[keyof FileTrashErrors]

export type FileTrashResponses = {
  /**
   * Trashed entry
   */
  200: TrashEntry
}

export type FileTrashResponse = FileTrashResponses[keyof FileTrashResponses]

export type FileTrashRestoreData = {
  body?: {
    id: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/file/trash/restore"
}

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

export type FileTrashRestoreError = FileTrashRestoreErrors[keyof FileTrashRestoreErrors]

export type FileTrashRestoreResponses = {
  /**
   * Restored path
   */
  200: {
    restoredPath: string
  }
}

export type FileTrashRestoreResponse = FileTrashRestoreResponses[keyof FileTrashRestoreResponses]

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 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 InstanceSchedulerData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/scheduler/snapshot"
}

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

export type InstanceSchedulerError = InstanceSchedulerErrors[keyof InstanceSchedulerErrors]

export type InstanceSchedulerResponses = {
  /**
   * Live scheduler state, one entry per device
   */
  200: Array<{
    deviceKey: string
    inFlightInteractive: Array<string>
    inFlightBatch: Array<string>
    waiting: Array<string>
    ledger: Array<{
      id: string
      weight: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      sliceTokens: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      lag: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      vdeadline: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    }>
  }>
}

export type InstanceSchedulerResponse = InstanceSchedulerResponses[keyof InstanceSchedulerResponses]

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

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

export type AppListError = AppListErrors[keyof AppListErrors]

export type AppListResponses = {
  /**
   * Persisted home-app manifests
   */
  200: Array<AppManifest>
}

export type AppListResponse = AppListResponses[keyof AppListResponses]

export type AppRegisterData = {
  body?: {
    id?: string
    title: string
    icon?: string
    accent?: string
    subtitle?: string
    open: {
      type: "route" | "url" | "prompt"
      value: string
    }
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/app"
}

export type AppRegisterErrors = {
  /**
   * AppRegisterError | InvalidRequestError
   */
  400: AppRegisterError | InvalidRequestError
}

export type AppRegisterError2 = AppRegisterErrors[keyof AppRegisterErrors]

export type AppRegisterResponses = {
  /**
   * The persisted manifest
   */
  200: AppManifest
}

export type AppRegisterResponse = AppRegisterResponses[keyof AppRegisterResponses]

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: ConfigV2McpLocal | ConfigV2McpRemote
  }
  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 MemoryStatsData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/stats"
}

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

export type MemoryStatsError = MemoryStatsErrors[keyof MemoryStatsErrors]

export type MemoryStatsResponses = {
  /**
   * Total + currently-valid memory counts
   */
  200: {
    total: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    valid: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type MemoryStatsResponse = MemoryStatsResponses[keyof MemoryStatsResponses]

export type MemoryListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
    scopes?: string
    kinds?: string
    includeInvalid?: string
    limit?: string
    offset?: string
  }
  url: "/memory/list"
}

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

export type MemoryListError = MemoryListErrors[keyof MemoryListErrors]

export type MemoryListResponses = {
  /**
   * Memories, newest first (valid only unless includeInvalid)
   */
  200: Array<{
    id: string
    kind: string
    text: string
    name: string
    scope: string
    source: string
    confidence: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    relation: string
  }>
}

export type MemoryListResponse = MemoryListResponses[keyof MemoryListResponses]

export type MemoryGraphData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
    scopes?: string
    limit?: string
  }
  url: "/memory/graph"
}

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

export type MemoryGraphError = MemoryGraphErrors[keyof MemoryGraphErrors]

export type MemoryGraphResponses = {
  /**
   * Graph slice: nodes + the edges among them
   */
  200: {
    nodes: Array<{
      id: string
      kind: string
      text: string
      name: string
      scope: string
      source: string
      confidence: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      relation: string
    }>
    edges: Array<{
      from: string
      to: string
      type: string
    }>
  }
}

export type MemoryGraphResponse = MemoryGraphResponses[keyof MemoryGraphResponses]

export type MemorySearchData = {
  body?: {
    query: string
    k?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    scopes?: Array<string>
    kinds?: Array<string>
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/search"
}

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

export type MemorySearchError = MemorySearchErrors[keyof MemorySearchErrors]

export type MemorySearchResponses = {
  /**
   * Ranked memory hits
   */
  200: Array<{
    id: string
    kind: string
    text: string
    name: string
    scope: string
    source: string
    confidence: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    relation: string
    score: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }>
}

export type MemorySearchResponse = MemorySearchResponses[keyof MemorySearchResponses]

export type MemoryNeighborsData = {
  body?: {
    id: string
    k?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/neighbors"
}

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

export type MemoryNeighborsError = MemoryNeighborsErrors[keyof MemoryNeighborsErrors]

export type MemoryNeighborsResponses = {
  /**
   * One-hop typed neighbours
   */
  200: Array<{
    id: string
    type: string
    text: string
  }>
}

export type MemoryNeighborsResponse = MemoryNeighborsResponses[keyof MemoryNeighborsResponses]

export type MemoryPathData = {
  body?: {
    from: string
    to: string
    maxHops?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/path"
}

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

export type MemoryPathError = MemoryPathErrors[keyof MemoryPathErrors]

export type MemoryPathResponses = {
  /**
   * Shortest path between two memories, if any
   */
  200: {
    ids: Array<string>
    hops: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type MemoryPathResponse = MemoryPathResponses[keyof MemoryPathResponses]

export type MemoryRememberData = {
  body?: {
    text: string
    name?: string
    scope: string
    kind?: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/remember"
}

export type MemoryRememberErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type MemoryRememberError = MemoryRememberErrors[keyof MemoryRememberErrors]

export type MemoryRememberResponses = {
  /**
   * The new memory's id
   */
  200: {
    id: string
  }
}

export type MemoryRememberResponse = MemoryRememberResponses[keyof MemoryRememberResponses]

export type MemoryInvalidateData = {
  body?: {
    id: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/invalidate"
}

export type MemoryInvalidateErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type MemoryInvalidateError = MemoryInvalidateErrors[keyof MemoryInvalidateErrors]

export type MemoryInvalidateResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type MemoryInvalidateResponse = MemoryInvalidateResponses[keyof MemoryInvalidateResponses]

export type MemoryPurgeData = {
  body?: {
    id: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/purge"
}

export type MemoryPurgeErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type MemoryPurgeError = MemoryPurgeErrors[keyof MemoryPurgeErrors]

export type MemoryPurgeResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type MemoryPurgeResponse = MemoryPurgeResponses[keyof MemoryPurgeResponses]

export type MemoryIngestData = {
  body?: {
    text: string
    name: string
    scope?: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/ingest"
}

export type MemoryIngestErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type MemoryIngestError = MemoryIngestErrors[keyof MemoryIngestErrors]

export type MemoryIngestResponses = {
  /**
   * How many passages were stored, and how many the document chunked into
   */
  200: {
    stored: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    passages: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type MemoryIngestResponse = MemoryIngestResponses[keyof MemoryIngestResponses]

export type MemoryClearScopeData = {
  body?: {
    scope: string
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/memory/clearScope"
}

export type MemoryClearScopeErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type MemoryClearScopeError = MemoryClearScopeErrors[keyof MemoryClearScopeErrors]

export type MemoryClearScopeResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type MemoryClearScopeResponse = MemoryClearScopeResponses[keyof MemoryClearScopeResponses]

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 RegistryTablesData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/registry/tables"
}

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

export type RegistryTablesError = RegistryTablesErrors[keyof RegistryTablesErrors]

export type RegistryTablesResponses = {
  /**
   * Every user table with its row count
   */
  200: Array<DbRegistryTableSummary>
}

export type RegistryTablesResponse = RegistryTablesResponses[keyof RegistryTablesResponses]

export type RegistryRowsData = {
  body?: never
  path?: never
  query: {
    directory?: string
    workspace?: string
    table: string
    limit?: string
    offset?: string
  }
  url: "/registry/rows"
}

export type RegistryRowsErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type RegistryRowsError = RegistryRowsErrors[keyof RegistryRowsErrors]

export type RegistryRowsResponses = {
  /**
   * One page of rows (rowid-addressed)
   */
  200: DbRegistryTablePage
}

export type RegistryRowsResponse = RegistryRowsResponses[keyof RegistryRowsResponses]

export type RegistryUpdateRowData = {
  body?: {
    table: string
    rowid: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    values: {
      [key: string]: unknown
    }
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/registry/row/update"
}

export type RegistryUpdateRowErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type RegistryUpdateRowError = RegistryUpdateRowErrors[keyof RegistryUpdateRowErrors]

export type RegistryUpdateRowResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type RegistryUpdateRowResponse = RegistryUpdateRowResponses[keyof RegistryUpdateRowResponses]

export type RegistryInsertRowData = {
  body?: {
    table: string
    values: {
      [key: string]: unknown
    }
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/registry/row/insert"
}

export type RegistryInsertRowErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type RegistryInsertRowError = RegistryInsertRowErrors[keyof RegistryInsertRowErrors]

export type RegistryInsertRowResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type RegistryInsertRowResponse = RegistryInsertRowResponses[keyof RegistryInsertRowResponses]

export type RegistryDeleteRowData = {
  body?: {
    table: string
    rowid: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/registry/row/delete"
}

export type RegistryDeleteRowErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type RegistryDeleteRowError = RegistryDeleteRowErrors[keyof RegistryDeleteRowErrors]

export type RegistryDeleteRowResponses = {
  /**
   * True on success
   */
  200: boolean
}

export type RegistryDeleteRowResponse = RegistryDeleteRowResponses[keyof RegistryDeleteRowResponses]

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"
      | "allow-once"
      | "allow-file"
      | "allow-always"
      | "deny-once"
      | "deny-file"
      | "deny-always"
    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: ProviderCatalog
}

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: ProviderAuthError | 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: ProviderAuthError | InvalidRequestError
}

export type ProviderOauthCallbackError = ProviderOauthCallbackErrors[keyof ProviderOauthCallbackErrors]

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

export type ProviderOauthCallbackResponse = ProviderOauthCallbackResponses[keyof ProviderOauthCallbackResponses]

export type ProviderProbeData = {
  body?: {
    modelID?: string
    baseURL?: string
    apiKey?: string
    authStyle?: "bearer" | "anthropic"
  }
  path: {
    providerID: string
  }
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/provider/{providerID}/probe"
}

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

export type ProviderProbeError = ProviderProbeErrors[keyof ProviderProbeErrors]

export type ProviderProbeResponses = {
  /**
   * Provider probe result
   */
  200: {
    status: "ok" | "unreachable" | "auth" | "model-missing" | "no-url" | "error"
    latencyMs?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    window?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
    detail?: string
    models?: Array<string>
  }
}

export type ProviderProbeResponse = ProviderProbeResponses[keyof ProviderProbeResponses]

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

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

export type ProviderPresetsError = ProviderPresetsErrors[keyof ProviderPresetsErrors]

export type ProviderPresetsResponses = {
  /**
   * Provider import presets (builtins merged with config overrides)
   */
  200: {
    [key: string]: ConfigV2ProviderPreset
  }
}

export type ProviderPresetsResponse = ProviderPresetsResponses[keyof ProviderPresetsResponses]

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

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

export type ShellStatusError = ShellStatusErrors[keyof ShellStatusErrors]

export type ShellStatusResponses = {
  /**
   * The agent shell substrate on this machine
   */
  200: {
    platform: string
    agentShell: string
    bash: string
    git: string
    bundle: {
      root: string
      bash: string
      git: string
      version?: string
      provisionedAt?: number
    }
    provisionSupported: boolean
  }
}

export type ShellStatusResponse = ShellStatusResponses[keyof ShellStatusResponses]

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

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

export type ShellOfflineError = ShellOfflineErrors[keyof ShellOfflineErrors]

export type ShellOfflineResponses = {
  /**
   * The N/9 offline-layer posture
   */
  200: {
    enabled: boolean
    active: number
    total: number
    layers: Array<{
      layer: number
      name: string
      active: boolean
      detail?: string
    }>
  }
}

export type ShellOfflineResponse = ShellOfflineResponses[keyof ShellOfflineResponses]

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

export type ShellProvisionErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
}

export type ShellProvisionError = ShellProvisionErrors[keyof ShellProvisionErrors]

export type ShellProvisionResponses = {
  /**
   * Status after provisioning
   */
  200: {
    platform: string
    agentShell: string
    bash: string
    git: string
    bundle: {
      root: string
      bash: string
      git: string
      version?: string
      provisionedAt?: number
    }
    provisionSupported: boolean
  }
}

export type ShellProvisionResponse = ShellProvisionResponses[keyof ShellProvisionResponses]

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 ExperimentalWorkspaceAdapterListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/adapter"
}

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

export type ExperimentalWorkspaceAdapterListError =
  ExperimentalWorkspaceAdapterListErrors[keyof ExperimentalWorkspaceAdapterListErrors]

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

export type ExperimentalWorkspaceAdapterListResponse =
  ExperimentalWorkspaceAdapterListResponses[keyof ExperimentalWorkspaceAdapterListResponses]

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

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

export type ExperimentalWorkspaceListError = ExperimentalWorkspaceListErrors[keyof ExperimentalWorkspaceListErrors]

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

export type ExperimentalWorkspaceListResponse =
  ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses]

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

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

export type ExperimentalWorkspaceCreateError =
  ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors]

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

export type ExperimentalWorkspaceCreateResponse =
  ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses]

export type ExperimentalWorkspaceSyncListData = {
  body?: never
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/sync-list"
}

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

export type ExperimentalWorkspaceSyncListError =
  ExperimentalWorkspaceSyncListErrors[keyof ExperimentalWorkspaceSyncListErrors]

export type ExperimentalWorkspaceSyncListResponses = {
  /**
   * Workspace list synced
   */
  204: void
}

export type ExperimentalWorkspaceSyncListResponse =
  ExperimentalWorkspaceSyncListResponses[keyof ExperimentalWorkspaceSyncListResponses]

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

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

export type ExperimentalWorkspaceStatusError =
  ExperimentalWorkspaceStatusErrors[keyof ExperimentalWorkspaceStatusErrors]

export type ExperimentalWorkspaceStatusResponses = {
  /**
   * Workspace status
   */
  200: Array<WorkspaceEventConnectionStatus>
}

export type ExperimentalWorkspaceStatusResponse =
  ExperimentalWorkspaceStatusResponses[keyof ExperimentalWorkspaceStatusResponses]

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

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

export type ExperimentalWorkspaceRemoveError =
  ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors]

export type ExperimentalWorkspaceRemoveResponses = {
  /**
   * Workspace removed
   */
  200: Workspace
}

export type ExperimentalWorkspaceRemoveResponse =
  ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses]

export type ExperimentalWorkspaceWarpData = {
  body?: {
    id: string | null
    sessionID: string
    copyChanges?: boolean
  }
  path?: never
  query?: {
    directory?: string
    workspace?: string
  }
  url: "/experimental/workspace/warp"
}

export type ExperimentalWorkspaceWarpErrors = {
  /**
   * WorkspaceWarpError | VcsApplyError | InvalidRequestError
   */
  400: WorkspaceWarpError | VcsApplyError | InvalidRequestError
  /**
   * NotFoundError
   */
  404: NotFoundError
}

export type ExperimentalWorkspaceWarpError = ExperimentalWorkspaceWarpErrors[keyof ExperimentalWorkspaceWarpErrors]

export type ExperimentalWorkspaceWarpResponses = {
  /**
   * Session warped
   */
  204: void
}

export type ExperimentalWorkspaceWarpResponse =
  ExperimentalWorkspaceWarpResponses[keyof ExperimentalWorkspaceWarpResponses]

export type V2HealthGetData = {
  body?: never
  path?: never
  query?: never
  url: "/api/health"
}

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

export type V2HealthGetError = V2HealthGetErrors[keyof V2HealthGetErrors]

export type V2HealthGetResponses = {
  /**
   * Success
   */
  200: {
    healthy: true
  }
}

export type V2HealthGetResponse = V2HealthGetResponses[keyof V2HealthGetResponses]

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

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

export type V2LocationGetError = V2LocationGetErrors[keyof V2LocationGetErrors]

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

export type V2LocationGetResponse = V2LocationGetResponses[keyof V2LocationGetResponses]

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

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

export type V2AgentListError = V2AgentListErrors[keyof V2AgentListErrors]

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

export type V2AgentListResponse = V2AgentListResponses[keyof V2AgentListResponses]

export type V2SessionListData = {
  body?: never
  path?: never
  query?: {
    workspace?: string
    roots?: boolean | "true" | "false"
    limit?: number
    order?: "asc" | "desc"
    search?: string
    directory?: string
    under?: string
    /**
     * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.
     */
    cursor?: string
  }
  url: "/api/session"
}

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

export type V2SessionListError = V2SessionListErrors[keyof V2SessionListErrors]

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

export type V2SessionListResponse = V2SessionListResponses[keyof V2SessionListResponses]

export type V2SessionCreateData = {
  body: {
    id?: string
    parentID?: string
    agent?: string
    model?: ModelRef
    systemPromptOverride?: string
    type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    priority?: number
    permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    location?: LocationRef
    title?: string
    permission?: PermissionRuleset
    strict?: SessionStrictOverride
    introspection?: boolean
    quality?: boolean
    affective?: boolean
  }
  path?: never
  query?: never
  url: "/api/session"
}

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

export type V2SessionCreateError = V2SessionCreateErrors[keyof V2SessionCreateErrors]

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

export type V2SessionCreateResponse = V2SessionCreateResponses[keyof V2SessionCreateResponses]

export type V2SessionTagsSetData = {
  body: {
    tags: Array<string>
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/tags"
}

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

export type V2SessionTagsSetError = V2SessionTagsSetErrors[keyof V2SessionTagsSetErrors]

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

export type V2SessionTagsSetResponse = V2SessionTagsSetResponses[keyof V2SessionTagsSetResponses]

export type V2SessionTagsAllData = {
  body?: never
  path?: never
  query?: never
  url: "/api/tag"
}

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

export type V2SessionTagsAllError = V2SessionTagsAllErrors[keyof V2SessionTagsAllErrors]

export type V2SessionTagsAllResponses = {
  /**
   * Success
   */
  200: {
    data: {
      [key: string]: Array<string>
    }
  }
}

export type V2SessionTagsAllResponse = V2SessionTagsAllResponses[keyof V2SessionTagsAllResponses]

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

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

export type V2SessionActiveError = V2SessionActiveErrors[keyof V2SessionActiveErrors]

export type V2SessionActiveResponses = {
  /**
   * Success
   */
  200: {
    data: {
      [key: string]: unknown | SessionActive
    }
  }
}

export type V2SessionActiveResponse = V2SessionActiveResponses[keyof V2SessionActiveResponses]

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

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

export type V2SessionRemoveError = V2SessionRemoveErrors[keyof V2SessionRemoveErrors]

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

export type V2SessionRemoveResponse = V2SessionRemoveResponses[keyof V2SessionRemoveResponses]

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

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

export type V2SessionGetError = V2SessionGetErrors[keyof V2SessionGetErrors]

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

export type V2SessionGetResponse = V2SessionGetResponses[keyof V2SessionGetResponses]

export type V2SessionUpdateData = {
  body: {
    title?: string
    metadata?: {
      [key: string]: unknown
    }
    archived?: number
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}"
}

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

export type V2SessionUpdateError = V2SessionUpdateErrors[keyof V2SessionUpdateErrors]

export type V2SessionUpdateResponses = {
  /**
   * Success
   */
  200: {
    data: SessionV2Info
  }
}

export type V2SessionUpdateResponse = V2SessionUpdateResponses[keyof V2SessionUpdateResponses]

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

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

export type V2SessionChildrenError = V2SessionChildrenErrors[keyof V2SessionChildrenErrors]

export type V2SessionChildrenResponses = {
  /**
   * Success
   */
  200: {
    data: Array<SessionV2Info>
  }
}

export type V2SessionChildrenResponse = V2SessionChildrenResponses[keyof V2SessionChildrenResponses]

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

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

export type V2SessionForkError = V2SessionForkErrors[keyof V2SessionForkErrors]

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

export type V2SessionForkResponse = V2SessionForkResponses[keyof V2SessionForkResponses]

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

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

export type V2SessionTodoError = V2SessionTodoErrors[keyof V2SessionTodoErrors]

export type V2SessionTodoResponses = {
  /**
   * Success
   */
  200: {
    data: Array<Todo>
  }
}

export type V2SessionTodoResponse = V2SessionTodoResponses[keyof V2SessionTodoResponses]

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

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

export type V2SessionSwitchAgentError = V2SessionSwitchAgentErrors[keyof V2SessionSwitchAgentErrors]

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

export type V2SessionSwitchAgentResponse = V2SessionSwitchAgentResponses[keyof V2SessionSwitchAgentResponses]

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

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

export type V2SessionSwitchModelError = V2SessionSwitchModelErrors[keyof V2SessionSwitchModelErrors]

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

export type V2SessionSwitchModelResponse = V2SessionSwitchModelResponses[keyof V2SessionSwitchModelResponses]

export type V2SessionSwitchResponderData = {
  body: {
    responder: "nova" | "operator"
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/responder"
}

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

export type V2SessionSwitchResponderError = V2SessionSwitchResponderErrors[keyof V2SessionSwitchResponderErrors]

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

export type V2SessionSwitchResponderResponse =
  V2SessionSwitchResponderResponses[keyof V2SessionSwitchResponderResponses]

export type V2SessionSwitchModeData = {
  body: {
    permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/mode"
}

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

export type V2SessionSwitchModeError = V2SessionSwitchModeErrors[keyof V2SessionSwitchModeErrors]

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

export type V2SessionSwitchModeResponse = V2SessionSwitchModeResponses[keyof V2SessionSwitchModeResponses]

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

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

export type V2SessionSwitchStrictError = V2SessionSwitchStrictErrors[keyof V2SessionSwitchStrictErrors]

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

export type V2SessionSwitchStrictResponse = V2SessionSwitchStrictResponses[keyof V2SessionSwitchStrictResponses]

export type V2SessionSwitchFeatureData = {
  body: {
    feature: "introspection" | "quality" | "affective"
    enabled: boolean
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/feature"
}

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

export type V2SessionSwitchFeatureError = V2SessionSwitchFeatureErrors[keyof V2SessionSwitchFeatureErrors]

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

export type V2SessionSwitchFeatureResponse = V2SessionSwitchFeatureResponses[keyof V2SessionSwitchFeatureResponses]

export type V2SessionSwitchTypeData = {
  body: {
    type: "interactive" | "auto-prompting" | "goal-oriented"
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/type"
}

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

export type V2SessionSwitchTypeError = V2SessionSwitchTypeErrors[keyof V2SessionSwitchTypeErrors]

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

export type V2SessionSwitchTypeResponse = V2SessionSwitchTypeResponses[keyof V2SessionSwitchTypeResponses]

export type V2SessionSwitchPromptOverrideData = {
  body: {
    override: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/prompt-override"
}

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

export type V2SessionSwitchPromptOverrideError =
  V2SessionSwitchPromptOverrideErrors[keyof V2SessionSwitchPromptOverrideErrors]

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

export type V2SessionSwitchPromptOverrideResponse =
  V2SessionSwitchPromptOverrideResponses[keyof V2SessionSwitchPromptOverrideResponses]

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

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

export type V2SessionShellError = V2SessionShellErrors[keyof V2SessionShellErrors]

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

export type V2SessionShellResponse = V2SessionShellResponses[keyof V2SessionShellResponses]

export type V2SessionCommandData = {
  body: {
    command: string
    arguments: string
    agent?: string
    model?: string
    variant?: string
    messageID?: string
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/command"
}

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

export type V2SessionCommandError = V2SessionCommandErrors[keyof V2SessionCommandErrors]

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

export type V2SessionCommandResponse = V2SessionCommandResponses[keyof V2SessionCommandResponses]

export type V2SessionPromptData = {
  body: {
    id?: string
    prompt: PromptInput
    delivery?: "steer" | "queue"
    resume?: boolean
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/prompt"
}

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

export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]

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

export type V2SessionPromptResponse = V2SessionPromptResponses[keyof V2SessionPromptResponses]

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

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

export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]

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

export type V2SessionCompactResponse = V2SessionCompactResponses[keyof V2SessionCompactResponses]

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

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

export type V2SessionWaitError = V2SessionWaitErrors[keyof V2SessionWaitErrors]

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

export type V2SessionWaitResponse = V2SessionWaitResponses[keyof V2SessionWaitResponses]

export type V2SessionRevertStageData = {
  body: {
    messageID: string
    files?: boolean
  }
  path: {
    sessionID: string
  }
  query?: never
  url: "/api/session/{sessionID}/revert/stage"
}

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

export type V2SessionRevertStageError = V2SessionRevertStageErrors[keyof V2SessionRevertStageErrors]

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

export type V2SessionRevertStageResponse = V2SessionRevertStageResponses[keyof V2SessionRevertStageResponses]

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

export type V2SessionRevertClearErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError
}

export type V2SessionRevertClearError = V2SessionRevertClearErrors[keyof V2SessionRevertClearErrors]

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

export type V2SessionRevertClearResponse = V2SessionRevertClearResponses[keyof V2SessionRevertClearResponses]

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

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

export type V2SessionRevertCommitError = V2SessionRevertCommitErrors[keyof V2SessionRevertCommitErrors]

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

export type V2SessionRevertCommitResponse = V2SessionRevertCommitResponses[keyof V2SessionRevertCommitResponses]

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

export type V2SessionContextErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError
   */
  404: SessionNotFoundError
  /**
   * UnknownError
   */
  500: UnknownError
}

export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]

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

export type V2SessionContextResponse = V2SessionContextResponses[keyof V2SessionContextResponses]

export type V2SessionHistoryData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    limit?: number
    after?: number
  }
  url: "/api/session/{sessionID}/history"
}

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

export type V2SessionHistoryError = V2SessionHistoryErrors[keyof V2SessionHistoryErrors]

export type V2SessionHistoryResponses = {
  /**
   * SessionHistory
   */
  200: SessionHistory
}

export type V2SessionHistoryResponse = V2SessionHistoryResponses[keyof V2SessionHistoryResponses]

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

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

export type V2SessionEventsError = V2SessionEventsErrors[keyof V2SessionEventsErrors]

export type V2SessionEventsResponses = {
  /**
   * Success
   */
  200: {
    id: string
    event: string
    data: SessionDurableEventStream
  }
}

export type V2SessionEventsResponse = V2SessionEventsResponses[keyof V2SessionEventsResponses]

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

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

export type V2SessionInterruptError = V2SessionInterruptErrors[keyof V2SessionInterruptErrors]

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

export type V2SessionInterruptResponse = V2SessionInterruptResponses[keyof V2SessionInterruptResponses]

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

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

export type V2SessionMessageError = V2SessionMessageErrors[keyof V2SessionMessageErrors]

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

export type V2SessionMessageResponse = V2SessionMessageResponses[keyof V2SessionMessageResponses]

export type V2SessionMessagesData = {
  body?: never
  path: {
    sessionID: string
  }
  query?: {
    limit?: number
    order?: "asc" | "desc"
    /**
     * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.
     */
    cursor?: string
  }
  url: "/api/session/{sessionID}/message"
}

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

export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]

export type V2SessionMessagesResponses = {
  /**
   * SessionMessagesResponse
   */
  200: SessionMessagesResponse
}

export type V2SessionMessagesResponse = V2SessionMessagesResponses[keyof V2SessionMessagesResponses]

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

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

export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]

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

export type V2ModelListResponse = V2ModelListResponses[keyof V2ModelListResponses]

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

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

export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]

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

export type V2ProviderListResponse = V2ProviderListResponses[keyof V2ProviderListResponses]

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

export type V2ProviderRemoveErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * ServiceUnavailableError
   */
  503: ServiceUnavailableError
}

export type V2ProviderRemoveError = V2ProviderRemoveErrors[keyof V2ProviderRemoveErrors]

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

export type V2ProviderRemoveResponse = V2ProviderRemoveResponses[keyof V2ProviderRemoveResponses]

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

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

export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]

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

export type V2ProviderGetResponse = V2ProviderGetResponses[keyof V2ProviderGetResponses]

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

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

export type V2IntegrationListError = V2IntegrationListErrors[keyof V2IntegrationListErrors]

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

export type V2IntegrationListResponse = V2IntegrationListResponses[keyof V2IntegrationListResponses]

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

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

export type V2IntegrationGetError = V2IntegrationGetErrors[keyof V2IntegrationGetErrors]

export type V2IntegrationGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationInfo
  }
}

export type V2IntegrationGetResponse = V2IntegrationGetResponses[keyof V2IntegrationGetResponses]

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

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

export type V2IntegrationConnectKeyError = V2IntegrationConnectKeyErrors[keyof V2IntegrationConnectKeyErrors]

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

export type V2IntegrationConnectKeyResponse = V2IntegrationConnectKeyResponses[keyof V2IntegrationConnectKeyResponses]

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

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

export type V2IntegrationConnectOauthError = V2IntegrationConnectOauthErrors[keyof V2IntegrationConnectOauthErrors]

export type V2IntegrationConnectOauthResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationAttempt
  }
}

export type V2IntegrationConnectOauthResponse =
  V2IntegrationConnectOauthResponses[keyof V2IntegrationConnectOauthResponses]

export type V2IntegrationAttemptCancelData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}"
}

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

export type V2IntegrationAttemptCancelError = V2IntegrationAttemptCancelErrors[keyof V2IntegrationAttemptCancelErrors]

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

export type V2IntegrationAttemptCancelResponse =
  V2IntegrationAttemptCancelResponses[keyof V2IntegrationAttemptCancelResponses]

export type V2IntegrationAttemptStatusData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}"
}

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

export type V2IntegrationAttemptStatusError = V2IntegrationAttemptStatusErrors[keyof V2IntegrationAttemptStatusErrors]

export type V2IntegrationAttemptStatusResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: IntegrationAttemptStatus
  }
}

export type V2IntegrationAttemptStatusResponse =
  V2IntegrationAttemptStatusResponses[keyof V2IntegrationAttemptStatusResponses]

export type V2IntegrationAttemptCompleteData = {
  body: {
    code?: string
  }
  path: {
    attemptID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/integration/attempt/{attemptID}/complete"
}

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

export type V2IntegrationAttemptCompleteError =
  V2IntegrationAttemptCompleteErrors[keyof V2IntegrationAttemptCompleteErrors]

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

export type V2IntegrationAttemptCompleteResponse =
  V2IntegrationAttemptCompleteResponses[keyof V2IntegrationAttemptCompleteResponses]

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

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

export type V2CredentialRemoveError = V2CredentialRemoveErrors[keyof V2CredentialRemoveErrors]

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

export type V2CredentialRemoveResponse = V2CredentialRemoveResponses[keyof V2CredentialRemoveResponses]

export type V2CredentialUpdateData = {
  body: {
    label: string
  }
  path: {
    credentialID: string
  }
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/credential/{credentialID}"
}

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

export type V2CredentialUpdateError = V2CredentialUpdateErrors[keyof V2CredentialUpdateErrors]

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

export type V2CredentialUpdateResponse = V2CredentialUpdateResponses[keyof V2CredentialUpdateResponses]

export type V2MessengerDriverListData = {
  body?: never
  path?: never
  query?: never
  url: "/api/messenger/driver"
}

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

export type V2MessengerDriverListError = V2MessengerDriverListErrors[keyof V2MessengerDriverListErrors]

export type V2MessengerDriverListResponses = {
  /**
   * Success
   */
  200: Array<MessengerDriverMeta>
}

export type V2MessengerDriverListResponse = V2MessengerDriverListResponses[keyof V2MessengerDriverListResponses]

export type V2MessengerAccountListData = {
  body?: never
  path?: never
  query?: never
  url: "/api/messenger/account"
}

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

export type V2MessengerAccountListError = V2MessengerAccountListErrors[keyof V2MessengerAccountListErrors]

export type V2MessengerAccountListResponses = {
  /**
   * Success
   */
  200: Array<MessengerAccountWithStatus>
}

export type V2MessengerAccountListResponse = V2MessengerAccountListResponses[keyof V2MessengerAccountListResponses]

export type V2MessengerAccountCreateData = {
  body: {
    driverID: string
    label: string
    enabled: boolean
    settings: {
      [key: string]: string
    }
    secret?: string
  }
  path?: never
  query?: never
  url: "/api/messenger/account"
}

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

export type V2MessengerAccountCreateError = V2MessengerAccountCreateErrors[keyof V2MessengerAccountCreateErrors]

export type V2MessengerAccountCreateResponses = {
  /**
   * Messenger.AccountInfo
   */
  200: MessengerAccountInfo
}

export type V2MessengerAccountCreateResponse =
  V2MessengerAccountCreateResponses[keyof V2MessengerAccountCreateResponses]

export type V2MessengerAccountRemoveData = {
  body?: never
  path: {
    accountID: string
  }
  query?: never
  url: "/api/messenger/account/{accountID}"
}

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

export type V2MessengerAccountRemoveError = V2MessengerAccountRemoveErrors[keyof V2MessengerAccountRemoveErrors]

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

export type V2MessengerAccountRemoveResponse =
  V2MessengerAccountRemoveResponses[keyof V2MessengerAccountRemoveResponses]

export type V2MessengerAccountUpdateData = {
  body: {
    label?: string
    enabled?: boolean
    settings?: {
      [key: string]: string
    }
    secret?: string
  }
  path: {
    accountID: string
  }
  query?: never
  url: "/api/messenger/account/{accountID}"
}

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

export type V2MessengerAccountUpdateError = V2MessengerAccountUpdateErrors[keyof V2MessengerAccountUpdateErrors]

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

export type V2MessengerAccountUpdateResponse =
  V2MessengerAccountUpdateResponses[keyof V2MessengerAccountUpdateResponses]

export type V2MessengerAccountPairData = {
  body: {
    trust: "operator" | "client"
  }
  path: {
    accountID: string
  }
  query?: never
  url: "/api/messenger/account/{accountID}/pair"
}

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

export type V2MessengerAccountPairError = V2MessengerAccountPairErrors[keyof V2MessengerAccountPairErrors]

export type V2MessengerAccountPairResponses = {
  /**
   * Success
   */
  200: {
    code: string
    expiresAt: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
  }
}

export type V2MessengerAccountPairResponse = V2MessengerAccountPairResponses[keyof V2MessengerAccountPairResponses]

export type V2MessengerAccountChatsData = {
  body?: never
  path: {
    accountID: string
  }
  query?: never
  url: "/api/messenger/account/{accountID}/chats"
}

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

export type V2MessengerAccountChatsError = V2MessengerAccountChatsErrors[keyof V2MessengerAccountChatsErrors]

export type V2MessengerAccountChatsResponses = {
  /**
   * Success
   */
  200: {
    ok: boolean
    chats: Array<MessengerChatInfo>
    reason?: string
  }
}

export type V2MessengerAccountChatsResponse = V2MessengerAccountChatsResponses[keyof V2MessengerAccountChatsResponses]

export type V2MessengerBindingListData = {
  body?: never
  path?: never
  query?: never
  url: "/api/messenger/binding"
}

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

export type V2MessengerBindingListError = V2MessengerBindingListErrors[keyof V2MessengerBindingListErrors]

export type V2MessengerBindingListResponses = {
  /**
   * Success
   */
  200: Array<{
    binding: MessengerBindingInfo
    chatTitle?: string
  }>
}

export type V2MessengerBindingListResponse = V2MessengerBindingListResponses[keyof V2MessengerBindingListResponses]

export type V2MessengerBindingCreateData = {
  body: {
    accountID: string
    chatID: string
    sessionID: string
    trust: MessengerTrust
    steal?: boolean
  }
  path?: never
  query?: never
  url: "/api/messenger/binding"
}

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

export type V2MessengerBindingCreateError = V2MessengerBindingCreateErrors[keyof V2MessengerBindingCreateErrors]

export type V2MessengerBindingCreateResponses = {
  /**
   * Messenger.BindingInfo
   */
  200: MessengerBindingInfo
}

export type V2MessengerBindingCreateResponse =
  V2MessengerBindingCreateResponses[keyof V2MessengerBindingCreateResponses]

export type V2MessengerBindingRemoveData = {
  body?: never
  path: {
    bindingID: string
  }
  query?: never
  url: "/api/messenger/binding/{bindingID}"
}

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

export type V2MessengerBindingRemoveError = V2MessengerBindingRemoveErrors[keyof V2MessengerBindingRemoveErrors]

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

export type V2MessengerBindingRemoveResponse =
  V2MessengerBindingRemoveResponses[keyof V2MessengerBindingRemoveResponses]

export type V2MessengerLoginBeginData = {
  body: {
    inputs: {
      [key: string]: string
    }
  }
  path: {
    accountID: string
  }
  query?: never
  url: "/api/messenger/account/{accountID}/login"
}

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

export type V2MessengerLoginBeginError = V2MessengerLoginBeginErrors[keyof V2MessengerLoginBeginErrors]

export type V2MessengerLoginBeginResponses = {
  /**
   * Messenger.LoginAttempt
   */
  200: MessengerLoginAttempt
}

export type V2MessengerLoginBeginResponse = V2MessengerLoginBeginResponses[keyof V2MessengerLoginBeginResponses]

export type V2MessengerLoginCancelData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: never
  url: "/api/messenger/login/{attemptID}"
}

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

export type V2MessengerLoginCancelError = V2MessengerLoginCancelErrors[keyof V2MessengerLoginCancelErrors]

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

export type V2MessengerLoginCancelResponse = V2MessengerLoginCancelResponses[keyof V2MessengerLoginCancelResponses]

export type V2MessengerLoginStatusData = {
  body?: never
  path: {
    attemptID: string
  }
  query?: never
  url: "/api/messenger/login/{attemptID}"
}

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

export type V2MessengerLoginStatusError = V2MessengerLoginStatusErrors[keyof V2MessengerLoginStatusErrors]

export type V2MessengerLoginStatusResponses = {
  /**
   * Messenger.LoginStatus
   */
  200: MessengerLoginStatus
}

export type V2MessengerLoginStatusResponse = V2MessengerLoginStatusResponses[keyof V2MessengerLoginStatusResponses]

export type V2MessengerLoginCompleteData = {
  body: {
    code: string
  }
  path: {
    attemptID: string
  }
  query?: never
  url: "/api/messenger/login/{attemptID}/complete"
}

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

export type V2MessengerLoginCompleteError = V2MessengerLoginCompleteErrors[keyof V2MessengerLoginCompleteErrors]

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

export type V2MessengerLoginCompleteResponse =
  V2MessengerLoginCompleteResponses[keyof V2MessengerLoginCompleteResponses]

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

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

export type V2PermissionRequestListError = V2PermissionRequestListErrors[keyof V2PermissionRequestListErrors]

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

export type V2PermissionRequestListResponse = V2PermissionRequestListResponses[keyof V2PermissionRequestListResponses]

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

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

export type V2PermissionSavedListError = V2PermissionSavedListErrors[keyof V2PermissionSavedListErrors]

export type V2PermissionSavedListResponses = {
  /**
   * Success
   */
  200: {
    data: Array<PermissionSavedInfo>
  }
}

export type V2PermissionSavedListResponse = V2PermissionSavedListResponses[keyof V2PermissionSavedListResponses]

export type V2PermissionSavedRemoveData = {
  body?: never
  path: {
    id: string
  }
  query?: never
  url: "/api/permission/saved/{id}"
}

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

export type V2PermissionSavedRemoveError = V2PermissionSavedRemoveErrors[keyof V2PermissionSavedRemoveErrors]

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

export type V2PermissionSavedRemoveResponse = V2PermissionSavedRemoveResponses[keyof V2PermissionSavedRemoveResponses]

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

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

export type V2SessionPermissionListError = V2SessionPermissionListErrors[keyof V2SessionPermissionListErrors]

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

export type V2SessionPermissionListResponse = V2SessionPermissionListResponses[keyof V2SessionPermissionListResponses]

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

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

export type V2SessionPermissionCreateError = V2SessionPermissionCreateErrors[keyof V2SessionPermissionCreateErrors]

export type V2SessionPermissionCreateResponses = {
  /**
   * Success
   */
  200: {
    data: {
      id: string
      effect: PermissionV2Effect
    }
  }
}

export type V2SessionPermissionCreateResponse =
  V2SessionPermissionCreateResponses[keyof V2SessionPermissionCreateResponses]

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

export type V2SessionPermissionGetErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundError | SessionNotFoundError
}

export type V2SessionPermissionGetError = V2SessionPermissionGetErrors[keyof V2SessionPermissionGetErrors]

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

export type V2SessionPermissionGetResponse = V2SessionPermissionGetResponses[keyof V2SessionPermissionGetResponses]

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

export type V2SessionPermissionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | PermissionNotFoundError
   */
  404: PermissionNotFoundError | SessionNotFoundError
}

export type V2SessionPermissionReplyError = V2SessionPermissionReplyErrors[keyof V2SessionPermissionReplyErrors]

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

export type V2SessionPermissionReplyResponse =
  V2SessionPermissionReplyResponses[keyof V2SessionPermissionReplyResponses]

export type V2FsReadData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/fs/read/*"
}

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

export type V2FsReadError = V2FsReadErrors[keyof V2FsReadErrors]

export type V2FsReadResponses = {
  /**
   * Success
   */
  200: Blob | File
}

export type V2FsReadResponse = V2FsReadResponses[keyof V2FsReadResponses]

export type V2FsListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
    path?: string
  }
  url: "/api/fs/list"
}

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

export type V2FsListError = V2FsListErrors[keyof V2FsListErrors]

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

export type V2FsListResponse = V2FsListResponses[keyof V2FsListResponses]

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

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

export type V2FsFindError = V2FsFindErrors[keyof V2FsFindErrors]

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

export type V2FsFindResponse = V2FsFindResponses[keyof V2FsFindResponses]

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

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

export type V2CommandListError = V2CommandListErrors[keyof V2CommandListErrors]

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

export type V2CommandListResponse = V2CommandListResponses[keyof V2CommandListResponses]

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

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

export type V2SkillListError = V2SkillListErrors[keyof V2SkillListErrors]

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

export type V2SkillListResponse = V2SkillListResponses[keyof V2SkillListResponses]

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

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

export type V2EventSubscribeError = V2EventSubscribeErrors[keyof V2EventSubscribeErrors]

export type V2EventSubscribeResponses = {
  /**
   * Event stream
   */
  200: V2Event
}

export type V2EventSubscribeResponse = V2EventSubscribeResponses[keyof V2EventSubscribeResponses]

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

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

export type V2PtyListError = V2PtyListErrors[keyof V2PtyListErrors]

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

export type V2PtyListResponse = V2PtyListResponses[keyof V2PtyListResponses]

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

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

export type V2PtyCreateError = V2PtyCreateErrors[keyof V2PtyCreateErrors]

export type V2PtyCreateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyCreateResponse = V2PtyCreateResponses[keyof V2PtyCreateResponses]

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

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

export type V2PtyRemoveError = V2PtyRemoveErrors[keyof V2PtyRemoveErrors]

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

export type V2PtyRemoveResponse = V2PtyRemoveResponses[keyof V2PtyRemoveResponses]

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

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

export type V2PtyGetError = V2PtyGetErrors[keyof V2PtyGetErrors]

export type V2PtyGetResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyGetResponse = V2PtyGetResponses[keyof V2PtyGetResponses]

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

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

export type V2PtyUpdateError = V2PtyUpdateErrors[keyof V2PtyUpdateErrors]

export type V2PtyUpdateResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: Pty
  }
}

export type V2PtyUpdateResponse = V2PtyUpdateResponses[keyof V2PtyUpdateResponses]

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

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

export type V2PtyConnectTokenError = V2PtyConnectTokenErrors[keyof V2PtyConnectTokenErrors]

export type V2PtyConnectTokenResponses = {
  /**
   * Success
   */
  200: {
    location: LocationInfo
    data: PtyTicketConnectToken
  }
}

export type V2PtyConnectTokenResponse = V2PtyConnectTokenResponses[keyof V2PtyConnectTokenResponses]

export type V2PtyConnectData = {
  body?: never
  path: {
    ptyID: string
  }
  query?: {
    "location[directory]"?: string
    "location[workspace]"?: string
    cursor?: string
    ticket?: string
  }
  url: "/api/pty/{ptyID}/connect"
}

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

export type V2PtyConnectError = V2PtyConnectErrors[keyof V2PtyConnectErrors]

export type V2PtyConnectResponses = {
  /**
   * Success
   */
  200: boolean
}

export type V2PtyConnectResponse = V2PtyConnectResponses[keyof V2PtyConnectResponses]

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

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

export type V2QuestionRequestListError = V2QuestionRequestListErrors[keyof V2QuestionRequestListErrors]

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

export type V2QuestionRequestListResponse = V2QuestionRequestListResponses[keyof V2QuestionRequestListResponses]

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

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

export type V2SessionQuestionListError = V2SessionQuestionListErrors[keyof V2SessionQuestionListErrors]

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

export type V2SessionQuestionListResponse = V2SessionQuestionListResponses[keyof V2SessionQuestionListResponses]

export type V2SessionQuestionReplyData = {
  body: QuestionV2Reply
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question/{requestID}/reply"
}

export type V2SessionQuestionReplyErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundError | SessionNotFoundError
}

export type V2SessionQuestionReplyError = V2SessionQuestionReplyErrors[keyof V2SessionQuestionReplyErrors]

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

export type V2SessionQuestionReplyResponse = V2SessionQuestionReplyResponses[keyof V2SessionQuestionReplyResponses]

export type V2SessionQuestionRejectData = {
  body?: never
  path: {
    sessionID: string
    requestID: string
  }
  query?: never
  url: "/api/session/{sessionID}/question/{requestID}/reject"
}

export type V2SessionQuestionRejectErrors = {
  /**
   * InvalidRequestError
   */
  400: InvalidRequestError
  /**
   * UnauthorizedError
   */
  401: UnauthorizedError
  /**
   * SessionNotFoundError | QuestionNotFoundError
   */
  404: QuestionNotFoundError | SessionNotFoundError
}

export type V2SessionQuestionRejectError = V2SessionQuestionRejectErrors[keyof V2SessionQuestionRejectErrors]

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

export type V2SessionQuestionRejectResponse = V2SessionQuestionRejectResponses[keyof V2SessionQuestionRejectResponses]

export type V2ReferenceListData = {
  body?: never
  path?: never
  query?: {
    location?: {
      directory?: string
      workspace?: string
    }
  }
  url: "/api/reference"
}

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

export type V2ReferenceListError = V2ReferenceListErrors[keyof V2ReferenceListErrors]

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

export type V2ReferenceListResponse = V2ReferenceListResponses[keyof V2ReferenceListResponses]

export type 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]
