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

import { client } from "./client.gen.js"
import { buildClientParams, type Client, type Options as Options2, type TDataShape } from "./client/index.js"
import type {
  AgentBuilderPreviewErrors,
  AgentBuilderPreviewResponses,
  AgentBuilderSaveErrors,
  AgentBuilderSaveResponses,
  AgentPartInput,
  AppAgentsErrors,
  AppAgentsResponses,
  AppLogErrors,
  AppLogResponses,
  AppSkillsErrors,
  AppSkillsResponses,
  Auth as Auth3,
  AuthRemoveErrors,
  AuthRemoveResponses,
  AuthSetErrors,
  AuthSetResponses,
  BackgroundProcessGetErrors,
  BackgroundProcessGetResponses,
  BackgroundProcessListErrors,
  BackgroundProcessListResponses,
  BackgroundProcessLogsErrors,
  BackgroundProcessLogsResponses,
  BackgroundProcessRestartErrors,
  BackgroundProcessRestartResponses,
  BackgroundProcessStopErrors,
  BackgroundProcessStopResponses,
  BackgroundProcessStopSessionErrors,
  BackgroundProcessStopSessionResponses,
  CommandListErrors,
  CommandListResponses,
  CommitMessageGenerateErrors,
  CommitMessageGenerateResponses,
  Config as Config4,
  ConfigEffectiveErrors,
  ConfigEffectiveResponses,
  ConfigGetErrors,
  ConfigGetResponses,
  ConfigModelStateErrors,
  ConfigModelStateResponses,
  ConfigModelStateUpdateErrors,
  ConfigModelStateUpdateResponses,
  ConfigOverlayErrors,
  ConfigOverlayResponses,
  ConfigOverlayUpdateErrors,
  ConfigOverlayUpdateResponses,
  ConfigProvidersErrors,
  ConfigProvidersResponses,
  ConfigRulesErrors,
  ConfigRulesResponses,
  ConfigRulesUpdateErrors,
  ConfigRulesUpdateResponses,
  ConfigSourcesErrors,
  ConfigSourcesResponses,
  ConfigUpdateErrors,
  ConfigUpdateResponses,
  ConfigWarningsErrors,
  ConfigWarningsResponses,
  EnhancePromptEnhanceErrors,
  EnhancePromptEnhanceResponses,
  EventSubscribeResponses,
  EventTuiCommandExecute2,
  EventTuiPromptAppend2,
  EventTuiSessionSelect2,
  EventTuiToastShow2,
  ExperimentalConsoleGetErrors,
  ExperimentalConsoleGetResponses,
  ExperimentalConsoleListOrgsErrors,
  ExperimentalConsoleListOrgsResponses,
  ExperimentalConsoleSwitchOrgResponses,
  ExperimentalResourceListErrors,
  ExperimentalResourceListResponses,
  ExperimentalSessionListErrors,
  ExperimentalSessionListResponses,
  ExperimentalWorkspaceAdapterListErrors,
  ExperimentalWorkspaceAdapterListResponses,
  ExperimentalWorkspaceCreateErrors,
  ExperimentalWorkspaceCreateResponses,
  ExperimentalWorkspaceListErrors,
  ExperimentalWorkspaceListResponses,
  ExperimentalWorkspaceRemoveErrors,
  ExperimentalWorkspaceRemoveResponses,
  ExperimentalWorkspaceStatusErrors,
  ExperimentalWorkspaceStatusResponses,
  ExperimentalWorkspaceSyncListErrors,
  ExperimentalWorkspaceSyncListResponses,
  ExperimentalWorkspaceWarpErrors,
  ExperimentalWorkspaceWarpResponses,
  FileListErrors,
  FileListResponses,
  FilePartInput,
  FilePartSource,
  FileReadErrors,
  FileReadResponses,
  FileStatusErrors,
  FileStatusResponses,
  FindFilesErrors,
  FindFilesResponses,
  FindSymbolsErrors,
  FindSymbolsResponses,
  FindTextErrors,
  FindTextResponses,
  FormatterStatusErrors,
  FormatterStatusResponses,
  GlobalConfigGetErrors,
  GlobalConfigGetResponses,
  GlobalConfigUpdateErrors,
  GlobalConfigUpdateResponses,
  GlobalDisposeErrors,
  GlobalDisposeResponses,
  GlobalEventErrors,
  GlobalEventResponses,
  GlobalHealthErrors,
  GlobalHealthResponses,
  GlobalUpgradeErrors,
  GlobalUpgradeResponses,
  IndexingModelsErrors,
  IndexingModelsResponses,
  IndexingStatusErrors,
  IndexingStatusResponses,
  IndexingWarningsErrors,
  IndexingWarningsResponses,
  InstanceDisposeErrors,
  InstanceDisposeResponses,
  KiloAudioTranscriptionsErrors,
  KiloAudioTranscriptionsResponses,
  KiloAuthStatusErrors,
  KiloAuthStatusResponses,
  KiloClawChatCredentialsErrors,
  KiloClawChatCredentialsResponses,
  KiloClawStatusErrors,
  KiloClawStatusResponses,
  KiloCloudSessionGetErrors,
  KiloCloudSessionGetResponses,
  KiloCloudSessionImportErrors,
  KiloCloudSessionImportResponses,
  KiloCloudSessionsErrors,
  KiloCloudSessionsResponses,
  KilocodeHeapSnapshotErrors,
  KilocodeHeapSnapshotResponses,
  KilocodeRemoveAgentErrors,
  KilocodeRemoveAgentResponses,
  KilocodeRemoveSkillErrors,
  KilocodeRemoveSkillResponses,
  KilocodeSessionImportMessageErrors,
  KilocodeSessionImportMessageResponses,
  KilocodeSessionImportPartErrors,
  KilocodeSessionImportPartResponses,
  KilocodeSessionImportProjectErrors,
  KilocodeSessionImportProjectResponses,
  KilocodeSessionImportSessionErrors,
  KilocodeSessionImportSessionResponses,
  KiloEditErrors,
  KiloEditResponses,
  KiloFimErrors,
  KiloFimResponses,
  KiloModesErrors,
  KiloModesResponses,
  KiloNotificationsErrors,
  KiloNotificationsResponses,
  KiloOrganizationSetErrors,
  KiloOrganizationSetResponses,
  KiloProfileErrors,
  KiloProfileResponses,
  LspStatusErrors,
  LspStatusResponses,
  McpAddErrors,
  McpAddResponses,
  McpAuthAuthenticateErrors,
  McpAuthAuthenticateResponses,
  McpAuthCallbackErrors,
  McpAuthCallbackResponses,
  McpAuthRemoveErrors,
  McpAuthRemoveResponses,
  McpAuthStartErrors,
  McpAuthStartResponses,
  McpConnectErrors,
  McpConnectResponses,
  McpDisconnectErrors,
  McpDisconnectResponses,
  McpLocalConfig,
  McpRemoteConfig,
  McpStatusErrors,
  McpStatusResponses,
  NetworkListErrors,
  NetworkListResponses,
  NetworkRejectErrors,
  NetworkRejectResponses,
  NetworkReplyErrors,
  NetworkReplyResponses,
  OutputFormat,
  Part as Part2,
  PartDeleteErrors,
  PartDeleteResponses,
  PartUpdateErrors,
  PartUpdateResponses,
  PathGetErrors,
  PathGetResponses,
  PermissionAllowEverythingErrors,
  PermissionAllowEverythingResponses,
  PermissionListErrors,
  PermissionListResponses,
  PermissionReplyErrors,
  PermissionReplyResponses,
  PermissionRespondErrors,
  PermissionRespondResponses,
  PermissionRuleset,
  PermissionSaveAlwaysRulesErrors,
  PermissionSaveAlwaysRulesResponses,
  ProjectCurrentErrors,
  ProjectCurrentResponses,
  ProjectInitGitErrors,
  ProjectInitGitResponses,
  ProjectListErrors,
  ProjectListResponses,
  ProjectUpdateErrors,
  ProjectUpdateResponses,
  Prompt,
  ProviderAuthErrors,
  ProviderAuthResponses,
  ProviderListErrors,
  ProviderListResponses,
  ProviderOauthAuthorizeErrors,
  ProviderOauthAuthorizeResponses,
  ProviderOauthCallbackErrors,
  ProviderOauthCallbackResponses,
  PtyConnectErrors,
  PtyConnectResponses,
  PtyConnectTokenErrors,
  PtyConnectTokenResponses,
  PtyCreateErrors,
  PtyCreateResponses,
  PtyGetErrors,
  PtyGetResponses,
  PtyListErrors,
  PtyListResponses,
  PtyRemoveErrors,
  PtyRemoveResponses,
  PtyShellsErrors,
  PtyShellsResponses,
  PtyUpdateErrors,
  PtyUpdateResponses,
  QuestionAnswer,
  QuestionListErrors,
  QuestionListResponses,
  QuestionRejectErrors,
  QuestionRejectResponses,
  QuestionReplyErrors,
  QuestionReplyResponses,
  RemoteDisableErrors,
  RemoteDisableResponses,
  RemoteEnableErrors,
  RemoteEnableResponses,
  RemoteStatusErrors,
  RemoteStatusResponses,
  SessionAbortErrors,
  SessionAbortResponses,
  SessionChildrenErrors,
  SessionChildrenResponses,
  SessionCommandErrors,
  SessionCommandResponses,
  SessionCreateErrors,
  SessionCreateResponses,
  SessionDeleteErrors,
  SessionDeleteMessageErrors,
  SessionDeleteMessageResponses,
  SessionDeleteResponses,
  SessionDelivery,
  SessionDiffErrors,
  SessionDiffResponses,
  SessionForkErrors,
  SessionForkResponses,
  SessionGetErrors,
  SessionGetResponses,
  SessionInitErrors,
  SessionInitResponses,
  SessionListErrors,
  SessionListResponses,
  SessionMessageErrors,
  SessionMessageResponses,
  SessionMessagesErrors,
  SessionMessagesResponses,
  SessionPromptAsyncErrors,
  SessionPromptAsyncResponses,
  SessionPromptErrors,
  SessionPromptResponses,
  SessionRevertErrors,
  SessionRevertResponses,
  SessionShareErrors,
  SessionShareResponses,
  SessionShellErrors,
  SessionShellResponses,
  SessionStatusErrors,
  SessionStatusResponses,
  SessionSummarizeErrors,
  SessionSummarizeResponses,
  SessionTodoErrors,
  SessionTodoResponses,
  SessionUnrevertErrors,
  SessionUnrevertResponses,
  SessionUnshareErrors,
  SessionUnshareResponses,
  SessionUpdateErrors,
  SessionUpdateResponses,
  SessionViewedErrors,
  SessionViewedResponses,
  SubtaskPartInput,
  SuggestionAcceptErrors,
  SuggestionAcceptResponses,
  SuggestionDismissErrors,
  SuggestionDismissResponses,
  SuggestionListErrors,
  SuggestionListResponses,
  SyncHistoryListErrors,
  SyncHistoryListResponses,
  SyncReplayErrors,
  SyncReplayResponses,
  SyncStartErrors,
  SyncStartResponses,
  SyncStealErrors,
  SyncStealResponses,
  TelemetryCaptureErrors,
  TelemetryCaptureResponses,
  TelemetrySetEnabledErrors,
  TelemetrySetEnabledResponses,
  TextPartInput,
  ToolIdsErrors,
  ToolIdsResponses,
  ToolListErrors,
  ToolListResponses,
  TuiAppendPromptErrors,
  TuiAppendPromptResponses,
  TuiClearPromptErrors,
  TuiClearPromptResponses,
  TuiConfigGetErrors,
  TuiConfigGetResponses,
  TuiConfigUpdateErrors,
  TuiConfigUpdateResponses,
  TuiControlNextErrors,
  TuiControlNextResponses,
  TuiControlResponseErrors,
  TuiControlResponseResponses,
  TuiExecuteCommandErrors,
  TuiExecuteCommandResponses,
  TuiKeybindListErrors,
  TuiKeybindListResponses,
  TuiOpenHelpErrors,
  TuiOpenHelpResponses,
  TuiOpenModelsErrors,
  TuiOpenModelsResponses,
  TuiOpenSessionsErrors,
  TuiOpenSessionsResponses,
  TuiOpenThemesErrors,
  TuiOpenThemesResponses,
  TuiPublishErrors,
  TuiPublishResponses,
  TuiSelectSessionErrors,
  TuiSelectSessionResponses,
  TuiShowToastErrors,
  TuiShowToastResponses,
  TuiSubmitPromptErrors,
  TuiSubmitPromptResponses,
  V2ModelListErrors,
  V2ModelListResponses,
  V2ProviderGetErrors,
  V2ProviderGetResponses,
  V2ProviderListErrors,
  V2ProviderListResponses,
  V2SessionCompactErrors,
  V2SessionCompactResponses,
  V2SessionContextErrors,
  V2SessionContextResponses,
  V2SessionListErrors,
  V2SessionListResponses,
  V2SessionMessagesErrors,
  V2SessionMessagesResponses,
  V2SessionPromptErrors,
  V2SessionPromptResponses,
  V2SessionWaitErrors,
  V2SessionWaitResponses,
  VcsApplyErrors,
  VcsApplyResponses,
  VcsDiffErrors,
  VcsDiffRawErrors,
  VcsDiffRawResponses,
  VcsDiffResponses,
  VcsGetErrors,
  VcsGetResponses,
  VcsStatusErrors,
  VcsStatusResponses,
  WorktreeCreateErrors,
  WorktreeCreateInput,
  WorktreeCreateResponses,
  WorktreeDiffErrors,
  WorktreeDiffFileErrors,
  WorktreeDiffFileResponses,
  WorktreeDiffResponses,
  WorktreeDiffSummaryErrors,
  WorktreeDiffSummaryResponses,
  WorktreeListErrors,
  WorktreeListResponses,
  WorktreeRemoveErrors,
  WorktreeRemoveInput,
  WorktreeRemoveResponses,
  WorktreeResetErrors,
  WorktreeResetInput,
  WorktreeResetResponses,
} from "./types.gen.js"

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<
  TData,
  ThrowOnError
> & {
  /**
   * You can provide a client instance returned by `createClient()` instead of
   * individual options. This might be also useful if you want to implement a
   * custom client.
   */
  client?: Client
  /**
   * You can pass arbitrary values through the `meta` object. This can be
   * used to access values that aren't defined as part of the SDK function.
   */
  meta?: Record<string, unknown>
}

class HeyApiClient {
  protected client: Client

  constructor(args?: { client?: Client }) {
    this.client = args?.client ?? client
  }
}

class HeyApiRegistry<T> {
  private readonly defaultKey = "default"

  private readonly instances: Map<string, T> = new Map()

  get(key?: string): T {
    const instance = this.instances.get(key ?? this.defaultKey)
    if (!instance) {
      throw new Error(`No SDK client found. Create one with "new KiloClient()" to fix this error.`)
    }
    return instance
  }

  set(value: T, key?: string): void {
    this.instances.set(key ?? this.defaultKey, value)
  }
}

export class Auth extends HeyApiClient {
  /**
   * Remove auth credentials
   *
   * Remove authentication credentials
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "providerID" }] }])
    return (options?.client ?? this.client).delete<AuthRemoveResponses, AuthRemoveErrors, ThrowOnError>({
      url: "/auth/{providerID}",
      ...options,
      ...params,
    })
  }

  /**
   * Set auth credentials
   *
   * Set authentication credentials
   */
  public set<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
      auth?: Auth3
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "providerID" },
            { key: "auth", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<AuthSetResponses, AuthSetErrors, ThrowOnError>({
      url: "/auth/{providerID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class App extends HeyApiClient {
  /**
   * Write log
   *
   * Write a log entry to the server logs with specified level and metadata.
   */
  public log<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      service?: string
      level?: "debug" | "info" | "error" | "warn"
      message?: string
      extra?: {
        [key: string]: unknown
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "service" },
            { in: "body", key: "level" },
            { in: "body", key: "message" },
            { in: "body", key: "extra" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<AppLogResponses, AppLogErrors, ThrowOnError>({
      url: "/log",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List agents
   *
   * Get a list of all available AI agents in the Kilo system.
   */
  public agents<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<AppAgentsResponses, AppAgentsErrors, ThrowOnError>({
      url: "/agent",
      ...options,
      ...params,
    })
  }

  /**
   * List skills
   *
   * Get a list of all available skills in the Kilo system.
   */
  public skills<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<AppSkillsResponses, AppSkillsErrors, ThrowOnError>({
      url: "/skill",
      ...options,
      ...params,
    })
  }
}

export class Config extends HeyApiClient {
  /**
   * Get global configuration
   *
   * Retrieve the current global Kilo configuration settings and preferences.
   */
  public get<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<GlobalConfigGetResponses, GlobalConfigGetErrors, ThrowOnError>({
      url: "/global/config",
      ...options,
    })
  }

  /**
   * Update global configuration
   *
   * Update global Kilo configuration settings and preferences.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters?: {
      config?: Config4
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }])
    return (options?.client ?? this.client).patch<GlobalConfigUpdateResponses, GlobalConfigUpdateErrors, ThrowOnError>({
      url: "/global/config",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Global extends HeyApiClient {
  /**
   * Get health
   *
   * Get health information about the Kilo server.
   */
  public health<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<GlobalHealthResponses, GlobalHealthErrors, ThrowOnError>({
      url: "/global/health",
      ...options,
    })
  }

  /**
   * Get global events
   *
   * Subscribe to global events from the Kilo system using server-sent events.
   */
  public event<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).sse.get<GlobalEventResponses, GlobalEventErrors, ThrowOnError>({
      url: "/global/event",
      ...options,
    })
  }

  /**
   * Dispose instance
   *
   * Clean up and dispose all Kilo instances, releasing all resources.
   */
  public dispose<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).post<GlobalDisposeResponses, GlobalDisposeErrors, ThrowOnError>({
      url: "/global/dispose",
      ...options,
    })
  }

  /**
   * Upgrade kilo
   *
   * Upgrade kilo to the specified version or latest if not specified.
   */
  public upgrade<ThrowOnError extends boolean = false>(
    parameters?: {
      target?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }])
    return (options?.client ?? this.client).post<GlobalUpgradeResponses, GlobalUpgradeErrors, ThrowOnError>({
      url: "/global/upgrade",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _config?: Config
  get config(): Config {
    return (this._config ??= new Config({ client: this.client }))
  }
}

export class Event extends HeyApiClient {
  /**
   * Subscribe to events
   *
   * Get events
   */
  public subscribe<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).sse.get<EventSubscribeResponses, unknown, ThrowOnError>({
      url: "/event",
      ...options,
      ...params,
    })
  }
}

export class Config2 extends HeyApiClient {
  /**
   * Get configuration
   *
   * Retrieve the current Kilo configuration settings and preferences.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigGetResponses, ConfigGetErrors, ThrowOnError>({
      url: "/config",
      ...options,
      ...params,
    })
  }

  /**
   * Update configuration
   *
   * Update Kilo configuration settings and preferences.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      config?: Config4
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "config", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<ConfigUpdateResponses, ConfigUpdateErrors, ThrowOnError>({
      url: "/config",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get config warnings
   *
   * Get warnings generated during config loading (e.g., invalid JSON, schema errors).
   */
  public warnings<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigWarningsResponses, ConfigWarningsErrors, ThrowOnError>({
      url: "/config/warnings",
      ...options,
      ...params,
    })
  }

  /**
   * List config providers
   *
   * Get a list of all configured AI providers and their default models.
   */
  public providers<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigProvidersResponses, ConfigProvidersErrors, ThrowOnError>({
      url: "/config/providers",
      ...options,
      ...params,
    })
  }

  /**
   * Get config overlay
   *
   * Resolve global, project, and effective config values with source metadata for inheritance-aware settings UI.
   */
  public overlay<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "global" | "project"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scope" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigOverlayResponses, ConfigOverlayErrors, ThrowOnError>({
      url: "/config/overlay",
      ...options,
      ...params,
    })
  }

  /**
   * Patch config overlay
   *
   * Apply a minimal global or project config patch, including unset paths for reverting local overrides.
   */
  public overlayUpdate<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "global" | "project"
      set?: {
        [key: string]: unknown
      }
      unset?: Array<Array<string>>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "scope" },
            { in: "body", key: "set" },
            { in: "body", key: "unset" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<
      ConfigOverlayUpdateResponses,
      ConfigOverlayUpdateErrors,
      ThrowOnError
    >({
      url: "/config/overlay",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List config sources
   *
   * List config source metadata in load order without exposing config contents or secrets.
   */
  public sources<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigSourcesResponses, ConfigSourcesErrors, ThrowOnError>({
      url: "/config/sources",
      ...options,
      ...params,
    })
  }

  /**
   * Get effective configuration
   *
   * Retrieve effective config for the current instance directory.
   */
  public effective<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigEffectiveResponses, ConfigEffectiveErrors, ThrowOnError>({
      url: "/config/effective",
      ...options,
      ...params,
    })
  }

  /**
   * Get project rules
   *
   * List project instruction files used by Kilo and return their current contents.
   */
  public rules<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "project"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scope" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigRulesResponses, ConfigRulesErrors, ThrowOnError>({
      url: "/config/rules",
      ...options,
      ...params,
    })
  }

  /**
   * Update project rules
   *
   * Create or update the project AGENTS.md rules file.
   */
  public rulesUpdate<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "project"
      content?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "scope" },
            { in: "body", key: "content" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<ConfigRulesUpdateResponses, ConfigRulesUpdateErrors, ThrowOnError>({
      url: "/config/rules",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get model state
   *
   * Retrieve TUI-compatible recent and favorite model selections.
   */
  public modelState<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ConfigModelStateResponses, ConfigModelStateErrors, ThrowOnError>({
      url: "/config/model-state",
      ...options,
      ...params,
    })
  }

  /**
   * Update model state
   *
   * Patch TUI-compatible model selections shared with Kilo Console.
   */
  public modelStateUpdate<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      favorite?: Array<{
        providerID: string
        modelID: string
      }>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "favorite" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<
      ConfigModelStateUpdateResponses,
      ConfigModelStateUpdateErrors,
      ThrowOnError
    >({
      url: "/config/model-state",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Console extends HeyApiClient {
  /**
   * Get active Console provider metadata
   *
   * Get the active Console org name and the set of provider IDs managed by that Console org.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalConsoleGetResponses,
      ExperimentalConsoleGetErrors,
      ThrowOnError
    >({
      url: "/experimental/console",
      ...options,
      ...params,
    })
  }

  /**
   * List switchable Console orgs
   *
   * Get the available Console orgs across logged-in accounts, including the current active org.
   */
  public listOrgs<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalConsoleListOrgsResponses,
      ExperimentalConsoleListOrgsErrors,
      ThrowOnError
    >({
      url: "/experimental/console/orgs",
      ...options,
      ...params,
    })
  }

  /**
   * Switch active Console org
   *
   * Persist a new active Console account/org selection for the current local Kilo state.
   */
  public switchOrg<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      accountID?: string
      orgID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "accountID" },
            { in: "body", key: "orgID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<ExperimentalConsoleSwitchOrgResponses, unknown, ThrowOnError>({
      url: "/experimental/console/switch",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Session extends HeyApiClient {
  /**
   * List sessions
   *
   * Get a list of all Kilo sessions across projects, sorted by most recently updated. Archived sessions are excluded by default.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      projectID?: string
      worktrees?: boolean
      current?: "true" | "false"
      roots?: boolean | "true" | "false"
      start?: number
      cursor?: number
      search?: string
      limit?: number
      archived?: boolean | "true" | "false"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "projectID" },
            { in: "query", key: "worktrees" },
            { in: "query", key: "current" },
            { in: "query", key: "roots" },
            { in: "query", key: "start" },
            { in: "query", key: "cursor" },
            { in: "query", key: "search" },
            { in: "query", key: "limit" },
            { in: "query", key: "archived" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalSessionListResponses,
      ExperimentalSessionListErrors,
      ThrowOnError
    >({
      url: "/experimental/session",
      ...options,
      ...params,
    })
  }
}

export class Resource extends HeyApiClient {
  /**
   * Get MCP resources
   *
   * Get all available MCP resources from connected servers. Optionally filter by name.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalResourceListResponses,
      ExperimentalResourceListErrors,
      ThrowOnError
    >({
      url: "/experimental/resource",
      ...options,
      ...params,
    })
  }
}

export class Adapter extends HeyApiClient {
  /**
   * List workspace adapters
   *
   * List all available workspace adapters for the current project.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalWorkspaceAdapterListResponses,
      ExperimentalWorkspaceAdapterListErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace/adapter",
      ...options,
      ...params,
    })
  }
}

export class Workspace extends HeyApiClient {
  /**
   * List workspaces
   *
   * List all workspaces.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalWorkspaceListResponses,
      ExperimentalWorkspaceListErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace",
      ...options,
      ...params,
    })
  }

  /**
   * Create workspace
   *
   * Create a workspace for the current project.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      type?: string
      branch?: string | null
      extra?: unknown | null
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "type" },
            { in: "body", key: "branch" },
            { in: "body", key: "extra" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ExperimentalWorkspaceCreateResponses,
      ExperimentalWorkspaceCreateErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Sync workspace list
   *
   * Register missing workspaces returned by workspace adapters.
   */
  public syncList<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ExperimentalWorkspaceSyncListResponses,
      ExperimentalWorkspaceSyncListErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace/sync-list",
      ...options,
      ...params,
    })
  }

  /**
   * Workspace status
   *
   * Get connection status for workspaces in the current project.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      ExperimentalWorkspaceStatusResponses,
      ExperimentalWorkspaceStatusErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace/status",
      ...options,
      ...params,
    })
  }

  /**
   * Remove workspace
   *
   * Remove an existing workspace.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      id: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "id" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<
      ExperimentalWorkspaceRemoveResponses,
      ExperimentalWorkspaceRemoveErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace/{id}",
      ...options,
      ...params,
    })
  }

  /**
   * Warp session into workspace
   *
   * Move a session's sync history into the target workspace, or detach it to the local project.
   */
  public warp<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string | null
      sessionID?: string
      copyChanges?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "sessionID" },
            { in: "body", key: "copyChanges" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ExperimentalWorkspaceWarpResponses,
      ExperimentalWorkspaceWarpErrors,
      ThrowOnError
    >({
      url: "/experimental/workspace/warp",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _adapter?: Adapter
  get adapter(): Adapter {
    return (this._adapter ??= new Adapter({ client: this.client }))
  }
}

export class Experimental extends HeyApiClient {
  private _console?: Console
  get console(): Console {
    return (this._console ??= new Console({ client: this.client }))
  }

  private _session?: Session
  get session(): Session {
    return (this._session ??= new Session({ client: this.client }))
  }

  private _resource?: Resource
  get resource(): Resource {
    return (this._resource ??= new Resource({ client: this.client }))
  }

  private _workspace?: Workspace
  get workspace(): Workspace {
    return (this._workspace ??= new Workspace({ client: this.client }))
  }
}

export class Tool extends HeyApiClient {
  /**
   * List tools
   *
   * Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      provider: string
      model: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "provider" },
            { in: "query", key: "model" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ToolListResponses, ToolListErrors, ThrowOnError>({
      url: "/experimental/tool",
      ...options,
      ...params,
    })
  }

  /**
   * List tool IDs
   *
   * Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
   */
  public ids<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ToolIdsResponses, ToolIdsErrors, ThrowOnError>({
      url: "/experimental/tool/ids",
      ...options,
      ...params,
    })
  }
}

export class Worktree extends HeyApiClient {
  /**
   * Remove worktree
   *
   * Remove a git worktree and delete its branch.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      worktreeRemoveInput?: WorktreeRemoveInput
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "worktreeRemoveInput", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<WorktreeRemoveResponses, WorktreeRemoveErrors, ThrowOnError>({
      url: "/experimental/worktree",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List worktrees
   *
   * List all git worktrees for the current project and whether Kilo manages them.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<WorktreeListResponses, WorktreeListErrors, ThrowOnError>({
      url: "/experimental/worktree",
      ...options,
      ...params,
    })
  }

  /**
   * Create worktree
   *
   * Create a new git worktree for the current project and run any configured startup scripts.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      worktreeCreateInput?: WorktreeCreateInput
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "worktreeCreateInput", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<WorktreeCreateResponses, WorktreeCreateErrors, ThrowOnError>({
      url: "/experimental/worktree",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Reset worktree
   *
   * Reset a worktree branch to the primary default branch.
   */
  public reset<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      worktreeResetInput?: WorktreeResetInput
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "worktreeResetInput", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<WorktreeResetResponses, WorktreeResetErrors, ThrowOnError>({
      url: "/experimental/worktree/reset",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get worktree diff
   *
   * Get file diffs for a worktree compared to its base branch. Includes uncommitted changes.
   */
  public diff<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      base?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "base" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<WorktreeDiffResponses, WorktreeDiffErrors, ThrowOnError>({
      url: "/experimental/worktree/diff",
      ...options,
      ...params,
    })
  }

  /**
   * Get worktree diff summary
   *
   * Get lightweight file diff metadata for a worktree compared to its base branch.
   */
  public diffSummary<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      base?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "base" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<WorktreeDiffSummaryResponses, WorktreeDiffSummaryErrors, ThrowOnError>({
      url: "/experimental/worktree/diff/summary",
      ...options,
      ...params,
    })
  }

  /**
   * Get worktree diff detail
   *
   * Get full diff contents for one worktree file compared to its base branch.
   */
  public diffFile<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      base?: string
      file: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "base" },
            { in: "query", key: "file" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<WorktreeDiffFileResponses, WorktreeDiffFileErrors, ThrowOnError>({
      url: "/experimental/worktree/diff/file",
      ...options,
      ...params,
    })
  }
}

export class Find extends HeyApiClient {
  /**
   * Find text
   *
   * Search for text patterns across files in the project using ripgrep.
   */
  public text<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      pattern: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "pattern" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FindTextResponses, FindTextErrors, ThrowOnError>({
      url: "/find",
      ...options,
      ...params,
    })
  }

  /**
   * Find files
   *
   * Search for files or directories by name or pattern in the project directory.
   */
  public files<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      query: string
      dirs?: "true" | "false"
      type?: "file" | "directory"
      limit?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "query" },
            { in: "query", key: "dirs" },
            { in: "query", key: "type" },
            { in: "query", key: "limit" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FindFilesResponses, FindFilesErrors, ThrowOnError>({
      url: "/find/file",
      ...options,
      ...params,
    })
  }

  /**
   * Find symbols
   *
   * Search for workspace symbols like functions, classes, and variables using LSP.
   */
  public symbols<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      query: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "query" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FindSymbolsResponses, FindSymbolsErrors, ThrowOnError>({
      url: "/find/symbol",
      ...options,
      ...params,
    })
  }
}

export class File extends HeyApiClient {
  /**
   * List files
   *
   * List files and directories in a specified path.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      path: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "path" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FileListResponses, FileListErrors, ThrowOnError>({
      url: "/file",
      ...options,
      ...params,
    })
  }

  /**
   * Read file
   *
   * Read the content of a specified file.
   */
  public read<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      path: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "path" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FileReadResponses, FileReadErrors, ThrowOnError>({
      url: "/file/content",
      ...options,
      ...params,
    })
  }

  /**
   * Get file status
   *
   * Get the git status of all files in the project.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FileStatusResponses, FileStatusErrors, ThrowOnError>({
      url: "/file/status",
      ...options,
      ...params,
    })
  }
}

export class Instance extends HeyApiClient {
  /**
   * Dispose instance
   *
   * Clean up and dispose the current Kilo instance, releasing all resources.
   */
  public dispose<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<InstanceDisposeResponses, InstanceDisposeErrors, ThrowOnError>({
      url: "/instance/dispose",
      ...options,
      ...params,
    })
  }
}

export class Path extends HeyApiClient {
  /**
   * Get paths
   *
   * Retrieve the current working directory and related path information for the Kilo instance.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PathGetResponses, PathGetErrors, ThrowOnError>({
      url: "/path",
      ...options,
      ...params,
    })
  }
}

export class Diff extends HeyApiClient {
  /**
   * Get raw VCS diff
   *
   * Retrieve a raw patch for current uncommitted changes.
   */
  public raw<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<VcsDiffRawResponses, VcsDiffRawErrors, ThrowOnError>({
      url: "/vcs/diff/raw",
      ...options,
      ...params,
    })
  }
}

export class Vcs extends HeyApiClient {
  /**
   * Get VCS info
   *
   * Retrieve version control system (VCS) information for the current project, such as git branch.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<VcsGetResponses, VcsGetErrors, ThrowOnError>({
      url: "/vcs",
      ...options,
      ...params,
    })
  }

  /**
   * Get VCS status
   *
   * Retrieve changed files in the current working tree without patches.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<VcsStatusResponses, VcsStatusErrors, ThrowOnError>({
      url: "/vcs/status",
      ...options,
      ...params,
    })
  }

  /**
   * Get VCS diff
   *
   * Retrieve the current git diff for the working tree or against the default branch.
   */
  public diff<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      mode: "git" | "branch"
      context?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "mode" },
            { in: "query", key: "context" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<VcsDiffResponses, VcsDiffErrors, ThrowOnError>({
      url: "/vcs/diff",
      ...options,
      ...params,
    })
  }

  /**
   * Apply VCS patch
   *
   * Apply a raw patch to the current working tree.
   */
  public apply<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      patch?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "patch" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<VcsApplyResponses, VcsApplyErrors, ThrowOnError>({
      url: "/vcs/apply",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _diff?: Diff
  get diff2(): Diff {
    return (this._diff ??= new Diff({ client: this.client }))
  }
}

export class Command extends HeyApiClient {
  /**
   * List commands
   *
   * Get a list of all available commands in the Kilo system.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<CommandListResponses, CommandListErrors, ThrowOnError>({
      url: "/command",
      ...options,
      ...params,
    })
  }
}

export class Lsp extends HeyApiClient {
  /**
   * Get LSP status
   *
   * Get LSP server status
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<LspStatusResponses, LspStatusErrors, ThrowOnError>({
      url: "/lsp",
      ...options,
      ...params,
    })
  }
}

export class Formatter extends HeyApiClient {
  /**
   * Get formatter status
   *
   * Get formatter status
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<FormatterStatusResponses, FormatterStatusErrors, ThrowOnError>({
      url: "/formatter",
      ...options,
      ...params,
    })
  }
}

export class Auth2 extends HeyApiClient {
  /**
   * Remove MCP OAuth
   *
   * Remove OAuth credentials for an MCP server.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<McpAuthRemoveResponses, McpAuthRemoveErrors, ThrowOnError>({
      url: "/mcp/{name}/auth",
      ...options,
      ...params,
    })
  }

  /**
   * Start MCP OAuth
   *
   * Start OAuth authentication flow for a Model Context Protocol (MCP) server.
   */
  public start<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpAuthStartResponses, McpAuthStartErrors, ThrowOnError>({
      url: "/mcp/{name}/auth",
      ...options,
      ...params,
    })
  }

  /**
   * Complete MCP OAuth
   *
   * Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.
   */
  public callback<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
      code?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "code" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpAuthCallbackResponses, McpAuthCallbackErrors, ThrowOnError>({
      url: "/mcp/{name}/auth/callback",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Authenticate MCP OAuth
   *
   * Start OAuth flow and wait for callback (opens browser).
   */
  public authenticate<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpAuthAuthenticateResponses, McpAuthAuthenticateErrors, ThrowOnError>(
      {
        url: "/mcp/{name}/auth/authenticate",
        ...options,
        ...params,
      },
    )
  }
}

export class Mcp extends HeyApiClient {
  /**
   * Get MCP status
   *
   * Get the status of all Model Context Protocol (MCP) servers.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<McpStatusResponses, McpStatusErrors, ThrowOnError>({
      url: "/mcp",
      ...options,
      ...params,
    })
  }

  /**
   * Add MCP server
   *
   * Dynamically add a new Model Context Protocol (MCP) server to the system.
   */
  public add<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      name?: string
      config?: McpLocalConfig | McpRemoteConfig
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "name" },
            { in: "body", key: "config" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpAddResponses, McpAddErrors, ThrowOnError>({
      url: "/mcp",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Connect an MCP server.
   */
  public connect<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpConnectResponses, McpConnectErrors, ThrowOnError>({
      url: "/mcp/{name}/connect",
      ...options,
      ...params,
    })
  }

  /**
   * Disconnect an MCP server.
   */
  public disconnect<ThrowOnError extends boolean = false>(
    parameters: {
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<McpDisconnectResponses, McpDisconnectErrors, ThrowOnError>({
      url: "/mcp/{name}/disconnect",
      ...options,
      ...params,
    })
  }

  private _auth?: Auth2
  get auth(): Auth2 {
    return (this._auth ??= new Auth2({ client: this.client }))
  }
}

export class Project extends HeyApiClient {
  /**
   * List all projects
   *
   * Get a list of projects that have been opened with Kilo.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ProjectListResponses, ProjectListErrors, ThrowOnError>({
      url: "/project",
      ...options,
      ...params,
    })
  }

  /**
   * Get current project
   *
   * Retrieve the currently active project that Kilo is working with.
   */
  public current<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ProjectCurrentResponses, ProjectCurrentErrors, ThrowOnError>({
      url: "/project/current",
      ...options,
      ...params,
    })
  }

  /**
   * Initialize git repository
   *
   * Create a git repository for the current project and return the refreshed project info.
   */
  public initGit<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<ProjectInitGitResponses, ProjectInitGitErrors, ThrowOnError>({
      url: "/project/git/init",
      ...options,
      ...params,
    })
  }

  /**
   * Update project
   *
   * Update project properties such as name, icon, and commands.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      projectID: string
      directory?: string
      workspace?: string
      name?: string
      icon?: {
        url?: string
        override?: string
        color?: string
      }
      commands?: {
        /**
         * Startup script to run when creating a new workspace (worktree)
         */
        start?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "projectID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "name" },
            { in: "body", key: "icon" },
            { in: "body", key: "commands" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<ProjectUpdateResponses, ProjectUpdateErrors, ThrowOnError>({
      url: "/project/{projectID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Pty extends HeyApiClient {
  /**
   * List available shells
   *
   * Get a list of available shells on the system.
   */
  public shells<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PtyShellsResponses, PtyShellsErrors, ThrowOnError>({
      url: "/pty/shells",
      ...options,
      ...params,
    })
  }

  /**
   * List PTY sessions
   *
   * Get a list of all active pseudo-terminal (PTY) sessions managed by Kilo.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PtyListResponses, PtyListErrors, ThrowOnError>({
      url: "/pty",
      ...options,
      ...params,
    })
  }

  /**
   * Create PTY session
   *
   * Create a new pseudo-terminal (PTY) session for running shell commands and processes.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      command?: string
      args?: Array<string>
      cwd?: string
      title?: string
      env?: {
        [key: string]: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "command" },
            { in: "body", key: "args" },
            { in: "body", key: "cwd" },
            { in: "body", key: "title" },
            { in: "body", key: "env" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<PtyCreateResponses, PtyCreateErrors, ThrowOnError>({
      url: "/pty",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Remove PTY session
   *
   * Remove and terminate a specific pseudo-terminal (PTY) session.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<PtyRemoveResponses, PtyRemoveErrors, ThrowOnError>({
      url: "/pty/{ptyID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get PTY session
   *
   * Retrieve detailed information about a specific pseudo-terminal (PTY) session.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PtyGetResponses, PtyGetErrors, ThrowOnError>({
      url: "/pty/{ptyID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update PTY session
   *
   * Update properties of an existing pseudo-terminal (PTY) session.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      directory?: string
      workspace?: string
      title?: string
      sessionID?: string | null
      size?: {
        rows: number
        cols: number
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "title" },
            { in: "body", key: "sessionID" },
            { in: "body", key: "size" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<PtyUpdateResponses, PtyUpdateErrors, ThrowOnError>({
      url: "/pty/{ptyID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Create PTY WebSocket token
   *
   * Create a short-lived ticket for opening a PTY WebSocket connection.
   */
  public connectToken<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<PtyConnectTokenResponses, PtyConnectTokenErrors, ThrowOnError>({
      url: "/pty/{ptyID}/connect-token",
      ...options,
      ...params,
    })
  }

  /**
   * Connect to PTY session
   *
   * Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.
   */
  public connect<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PtyConnectResponses, PtyConnectErrors, ThrowOnError>({
      url: "/pty/{ptyID}/connect",
      ...options,
      ...params,
    })
  }
}

export class Question extends HeyApiClient {
  /**
   * List pending questions
   *
   * Get all pending question requests across all sessions.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<QuestionListResponses, QuestionListErrors, ThrowOnError>({
      url: "/question",
      ...options,
      ...params,
    })
  }

  /**
   * Reply to question request
   *
   * Provide answers to a question request from the AI assistant.
   */
  public reply<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
      answers?: Array<QuestionAnswer>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "answers" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<QuestionReplyResponses, QuestionReplyErrors, ThrowOnError>({
      url: "/question/{requestID}/reply",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Reject question request
   *
   * Reject a question request from the AI assistant.
   */
  public reject<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<QuestionRejectResponses, QuestionRejectErrors, ThrowOnError>({
      url: "/question/{requestID}/reject",
      ...options,
      ...params,
    })
  }
}

export class Permission extends HeyApiClient {
  /**
   * List pending permissions
   *
   * Get all pending permission requests across all sessions.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<PermissionListResponses, PermissionListErrors, ThrowOnError>({
      url: "/permission",
      ...options,
      ...params,
    })
  }

  /**
   * Respond to permission request
   *
   * Approve or deny a permission request from the AI assistant.
   */
  public reply<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
      reply?: "once" | "always" | "reject"
      message?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "reply" },
            { in: "body", key: "message" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<PermissionReplyResponses, PermissionReplyErrors, ThrowOnError>({
      url: "/permission/{requestID}/reply",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Save always-allow/deny permission rules
   *
   * Save approved/denied always-rules for a pending permission request.
   */
  public saveAlwaysRules<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
      approvedAlways?: Array<string>
      deniedAlways?: Array<string>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "approvedAlways" },
            { in: "body", key: "deniedAlways" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      PermissionSaveAlwaysRulesResponses,
      PermissionSaveAlwaysRulesErrors,
      ThrowOnError
    >({
      url: "/permission/{requestID}/always-rules",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Allow everything
   *
   * Enable or disable allowing all permissions without prompts.
   */
  public allowEverything<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      enable?: boolean
      requestID?: string
      sessionID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "enable" },
            { in: "body", key: "requestID" },
            { in: "body", key: "sessionID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      PermissionAllowEverythingResponses,
      PermissionAllowEverythingErrors,
      ThrowOnError
    >({
      url: "/permission/allow-everything",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Respond to permission
   *
   * Approve or deny a permission request from the AI assistant.
   *
   * @deprecated
   */
  public respond<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      permissionID: string
      directory?: string
      workspace?: string
      response?: "once" | "always" | "reject"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "permissionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "response" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<PermissionRespondResponses, PermissionRespondErrors, ThrowOnError>({
      url: "/session/{sessionID}/permissions/{permissionID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Oauth extends HeyApiClient {
  /**
   * Start OAuth authorization
   *
   * Start the OAuth authorization flow for a provider.
   */
  public authorize<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
      directory?: string
      workspace?: string
      method?: number
      inputs?: {
        [key: string]: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "providerID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "method" },
            { in: "body", key: "inputs" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ProviderOauthAuthorizeResponses,
      ProviderOauthAuthorizeErrors,
      ThrowOnError
    >({
      url: "/provider/{providerID}/oauth/authorize",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Handle OAuth callback
   *
   * Handle the OAuth callback from a provider after user authorization.
   */
  public callback<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
      directory?: string
      workspace?: string
      method?: number
      code?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "providerID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "method" },
            { in: "body", key: "code" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ProviderOauthCallbackResponses,
      ProviderOauthCallbackErrors,
      ThrowOnError
    >({
      url: "/provider/{providerID}/oauth/callback",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Provider extends HeyApiClient {
  /**
   * List providers
   *
   * Get a list of all available AI providers, including both available and connected ones.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ProviderListResponses, ProviderListErrors, ThrowOnError>({
      url: "/provider",
      ...options,
      ...params,
    })
  }

  /**
   * Get provider auth methods
   *
   * Retrieve available authentication methods for all AI providers.
   */
  public auth<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<ProviderAuthResponses, ProviderAuthErrors, ThrowOnError>({
      url: "/provider/auth",
      ...options,
      ...params,
    })
  }

  private _oauth?: Oauth
  get oauth(): Oauth {
    return (this._oauth ??= new Oauth({ client: this.client }))
  }
}

export class Session2 extends HeyApiClient {
  /**
   * List sessions
   *
   * Get a list of all Kilo sessions, sorted by most recently updated.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "project"
      path?: string
      roots?: boolean | "true" | "false"
      start?: number
      search?: string
      limit?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scope" },
            { in: "query", key: "path" },
            { in: "query", key: "roots" },
            { in: "query", key: "start" },
            { in: "query", key: "search" },
            { in: "query", key: "limit" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionListResponses, SessionListErrors, ThrowOnError>({
      url: "/session",
      ...options,
      ...params,
    })
  }

  /**
   * Create session
   *
   * Create a new Kilo session for interacting with AI assistants and managing conversations.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      parentID?: string
      title?: string
      agent?: string
      model?: {
        id: string
        providerID: string
        variant?: string
      }
      permission?: PermissionRuleset
      platform?: string
      workspaceID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "parentID" },
            { in: "body", key: "title" },
            { in: "body", key: "agent" },
            { in: "body", key: "model" },
            { in: "body", key: "permission" },
            { in: "body", key: "platform" },
            { in: "body", key: "workspaceID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionCreateResponses, SessionCreateErrors, ThrowOnError>({
      url: "/session",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get session status
   *
   * Retrieve the current status of all sessions, including active, idle, and completed states.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionStatusResponses, SessionStatusErrors, ThrowOnError>({
      url: "/session/status",
      ...options,
      ...params,
    })
  }

  /**
   * Delete session
   *
   * Delete a session and permanently remove all associated data, including messages and history.
   */
  public delete<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<SessionDeleteResponses, SessionDeleteErrors, ThrowOnError>({
      url: "/session/{sessionID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get session
   *
   * Retrieve detailed information about a specific Kilo session.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionGetResponses, SessionGetErrors, ThrowOnError>({
      url: "/session/{sessionID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update session
   *
   * Update properties of an existing session, such as title or other metadata.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      title?: string
      permission?: PermissionRuleset
      time?: {
        archived?: number
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "title" },
            { in: "body", key: "permission" },
            { in: "body", key: "time" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<SessionUpdateResponses, SessionUpdateErrors, ThrowOnError>({
      url: "/session/{sessionID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get session children
   *
   * Retrieve all child sessions that were forked from the specified parent session.
   */
  public children<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionChildrenResponses, SessionChildrenErrors, ThrowOnError>({
      url: "/session/{sessionID}/children",
      ...options,
      ...params,
    })
  }

  /**
   * Get session todos
   *
   * Retrieve the todo list associated with a specific session, showing tasks and action items.
   */
  public todo<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionTodoResponses, SessionTodoErrors, ThrowOnError>({
      url: "/session/{sessionID}/todo",
      ...options,
      ...params,
    })
  }

  /**
   * Get message diff
   *
   * Get the file changes (diff) that resulted from a specific user message in the session.
   */
  public diff<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionDiffResponses, SessionDiffErrors, ThrowOnError>({
      url: "/session/{sessionID}/diff",
      ...options,
      ...params,
    })
  }

  /**
   * Get session messages
   *
   * Retrieve all messages in a session, including user prompts and AI responses.
   */
  public messages<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      limit?: number
      before?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "limit" },
            { in: "query", key: "before" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionMessagesResponses, SessionMessagesErrors, ThrowOnError>({
      url: "/session/{sessionID}/message",
      ...options,
      ...params,
    })
  }

  /**
   * Send message
   *
   * Create and send a new message to a session, streaming the AI response.
   */
  public prompt<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
      model?: {
        providerID: string
        modelID: string
      }
      agent?: string
      noReply?: boolean
      tools?: {
        [key: string]: boolean
      }
      format?: OutputFormat
      system?: string
      variant?: string
      snapshotInitialization?: "wait"
      editorContext?: {
        visibleFiles?: Array<string>
        openTabs?: Array<string>
        activeFile?: string
        shell?: string
      }
      parts?: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
            { in: "body", key: "model" },
            { in: "body", key: "agent" },
            { in: "body", key: "noReply" },
            { in: "body", key: "tools" },
            { in: "body", key: "format" },
            { in: "body", key: "system" },
            { in: "body", key: "variant" },
            { in: "body", key: "snapshotInitialization" },
            { in: "body", key: "editorContext" },
            { in: "body", key: "parts" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionPromptResponses, SessionPromptErrors, ThrowOnError>({
      url: "/session/{sessionID}/message",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Delete message
   *
   * Permanently delete a specific message and all of its parts from a session without reverting file changes.
   */
  public deleteMessage<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "messageID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<
      SessionDeleteMessageResponses,
      SessionDeleteMessageErrors,
      ThrowOnError
    >({
      url: "/session/{sessionID}/message/{messageID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get message
   *
   * Retrieve a specific message from a session by its message ID.
   */
  public message<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "messageID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SessionMessageResponses, SessionMessageErrors, ThrowOnError>({
      url: "/session/{sessionID}/message/{messageID}",
      ...options,
      ...params,
    })
  }

  /**
   * Fork session
   *
   * Create a new session by forking an existing session at a specific message point.
   */
  public fork<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionForkResponses, SessionForkErrors, ThrowOnError>({
      url: "/session/{sessionID}/fork",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Abort session
   *
   * Abort an active session and stop any ongoing AI processing or command execution.
   */
  public abort<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionAbortResponses, SessionAbortErrors, ThrowOnError>({
      url: "/session/{sessionID}/abort",
      ...options,
      ...params,
    })
  }

  /**
   * Initialize session
   *
   * Analyze the current application and create an AGENTS.md file with project-specific agent configurations.
   */
  public init<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      modelID?: string
      providerID?: string
      messageID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "modelID" },
            { in: "body", key: "providerID" },
            { in: "body", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionInitResponses, SessionInitErrors, ThrowOnError>({
      url: "/session/{sessionID}/init",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Unshare session
   *
   * Remove the shareable link for a session, making it private again.
   */
  public unshare<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<SessionUnshareResponses, SessionUnshareErrors, ThrowOnError>({
      url: "/session/{sessionID}/share",
      ...options,
      ...params,
    })
  }

  /**
   * Share session
   *
   * Create a shareable link for a session, allowing others to view the conversation.
   */
  public share<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionShareResponses, SessionShareErrors, ThrowOnError>({
      url: "/session/{sessionID}/share",
      ...options,
      ...params,
    })
  }

  /**
   * Summarize session
   *
   * Generate a concise summary of the session using AI compaction to preserve key information.
   */
  public summarize<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      providerID?: string
      modelID?: string
      auto?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "providerID" },
            { in: "body", key: "modelID" },
            { in: "body", key: "auto" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionSummarizeResponses, SessionSummarizeErrors, ThrowOnError>({
      url: "/session/{sessionID}/summarize",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Send async message
   *
   * Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.
   */
  public promptAsync<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
      model?: {
        providerID: string
        modelID: string
      }
      agent?: string
      noReply?: boolean
      tools?: {
        [key: string]: boolean
      }
      format?: OutputFormat
      system?: string
      variant?: string
      snapshotInitialization?: "wait"
      editorContext?: {
        visibleFiles?: Array<string>
        openTabs?: Array<string>
        activeFile?: string
        shell?: string
      }
      parts?: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
            { in: "body", key: "model" },
            { in: "body", key: "agent" },
            { in: "body", key: "noReply" },
            { in: "body", key: "tools" },
            { in: "body", key: "format" },
            { in: "body", key: "system" },
            { in: "body", key: "variant" },
            { in: "body", key: "snapshotInitialization" },
            { in: "body", key: "editorContext" },
            { in: "body", key: "parts" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionPromptAsyncResponses, SessionPromptAsyncErrors, ThrowOnError>({
      url: "/session/{sessionID}/prompt_async",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Send command
   *
   * Send a new command to a session for execution by the AI assistant.
   */
  public command<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
      agent?: string
      model?: string
      arguments?: string
      command?: string
      variant?: string
      snapshotInitialization?: "wait"
      parts?: Array<{
        id?: string
        type: "file"
        mime: string
        filename?: string
        url: string
        source?: FilePartSource
      }>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
            { in: "body", key: "agent" },
            { in: "body", key: "model" },
            { in: "body", key: "arguments" },
            { in: "body", key: "command" },
            { in: "body", key: "variant" },
            { in: "body", key: "snapshotInitialization" },
            { in: "body", key: "parts" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionCommandResponses, SessionCommandErrors, ThrowOnError>({
      url: "/session/{sessionID}/command",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Run shell command
   *
   * Execute a shell command within the session context and return the AI's response.
   */
  public shell<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
      agent?: string
      model?: {
        providerID: string
        modelID: string
      }
      command?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
            { in: "body", key: "agent" },
            { in: "body", key: "model" },
            { in: "body", key: "command" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionShellResponses, SessionShellErrors, ThrowOnError>({
      url: "/session/{sessionID}/shell",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Revert message
   *
   * Revert a specific message in a session, undoing its effects and restoring the previous state.
   */
  public revert<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      messageID?: string
      partID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "messageID" },
            { in: "body", key: "partID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionRevertResponses, SessionRevertErrors, ThrowOnError>({
      url: "/session/{sessionID}/revert",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Restore reverted messages
   *
   * Restore all previously reverted messages in a session.
   */
  public unrevert<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionUnrevertResponses, SessionUnrevertErrors, ThrowOnError>({
      url: "/session/{sessionID}/unrevert",
      ...options,
      ...params,
    })
  }

  /**
   * Set viewed sessions
   *
   * Notify the server which sessions the user is currently viewing, or clear all.
   */
  public viewed<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      focused?: Array<string>
      open?: Array<string>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "focused" },
            { in: "body", key: "open" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SessionViewedResponses, SessionViewedErrors, ThrowOnError>({
      url: "/session/viewed",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Part extends HeyApiClient {
  /**
   * Delete a part from a message.
   */
  public delete<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID: string
      partID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "messageID" },
            { in: "path", key: "partID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<PartDeleteResponses, PartDeleteErrors, ThrowOnError>({
      url: "/session/{sessionID}/message/{messageID}/part/{partID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update a part in a message.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID: string
      partID: string
      directory?: string
      workspace?: string
      part?: Part2
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "messageID" },
            { in: "path", key: "partID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "part", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<PartUpdateResponses, PartUpdateErrors, ThrowOnError>({
      url: "/session/{sessionID}/message/{messageID}/part/{partID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class History extends HeyApiClient {
  /**
   * List sync events
   *
   * List sync events for all aggregates. Keys are aggregate IDs the client already knows about, values are the last known sequence ID. Events with seq > value are returned for those aggregates. Aggregates not listed in the input get their full history.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      body?: {
        [key: string]: number
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "body", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SyncHistoryListResponses, SyncHistoryListErrors, ThrowOnError>({
      url: "/sync/history",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Sync extends HeyApiClient {
  /**
   * Start workspace sync
   *
   * Start sync loops for workspaces in the current project that have active sessions.
   */
  public start<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SyncStartResponses, SyncStartErrors, ThrowOnError>({
      url: "/sync/start",
      ...options,
      ...params,
    })
  }

  /**
   * Replay sync events
   *
   * Validate and replay a complete sync event history.
   */
  public replay<ThrowOnError extends boolean = false>(
    parameters?: {
      query_directory?: string
      workspace?: string
      body_directory?: string
      events?: Array<{
        id: string
        aggregateID: string
        seq: number
        type: string
        data: {
          [key: string]: unknown
        }
      }>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            {
              in: "query",
              key: "query_directory",
              map: "directory",
            },
            { in: "query", key: "workspace" },
            {
              in: "body",
              key: "body_directory",
              map: "directory",
            },
            { in: "body", key: "events" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SyncReplayResponses, SyncReplayErrors, ThrowOnError>({
      url: "/sync/replay",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Steal session into workspace
   *
   * Update a session to belong to the current workspace through the sync event system.
   */
  public steal<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      sessionID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "sessionID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SyncStealResponses, SyncStealErrors, ThrowOnError>({
      url: "/sync/steal",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _history?: History
  get history(): History {
    return (this._history ??= new History({ client: this.client }))
  }
}

export class Session3 extends HeyApiClient {
  /**
   * List v2 sessions
   *
   * Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      limit?: number
      order?: "asc" | "desc"
      path?: string
      roots?: boolean | "true" | "false"
      start?: number
      search?: string
      cursor?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "limit" },
            { in: "query", key: "order" },
            { in: "query", key: "path" },
            { in: "query", key: "roots" },
            { in: "query", key: "start" },
            { in: "query", key: "search" },
            { in: "query", key: "cursor" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionListResponses, V2SessionListErrors, ThrowOnError>({
      url: "/api/session",
      ...options,
      ...params,
    })
  }

  /**
   * Send v2 message
   *
   * Create a v2 session message and queue it for the agent loop.
   */
  public prompt<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      prompt?: Prompt
      delivery?: SessionDelivery
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "prompt" },
            { in: "body", key: "delivery" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionPromptResponses, V2SessionPromptErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/prompt",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Compact v2 session
   *
   * Compact a v2 session conversation.
   */
  public compact<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionCompactResponses, V2SessionCompactErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/compact",
      ...options,
      ...params,
    })
  }

  /**
   * Wait for v2 session
   *
   * Wait for a v2 session agent loop to become idle.
   */
  public wait<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionWaitResponses, V2SessionWaitErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/wait",
      ...options,
      ...params,
    })
  }

  /**
   * Get v2 session context
   *
   * Retrieve the active context messages for a v2 session (all messages after the last compaction).
   */
  public context<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionContextResponses, V2SessionContextErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/context",
      ...options,
      ...params,
    })
  }

  /**
   * Get v2 session messages
   *
   * Retrieve projected v2 messages for a session. Items keep the requested order across pages; use cursor.next or cursor.previous to move through the ordered timeline.
   */
  public messages<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
      limit?: number
      order?: "asc" | "desc"
      cursor?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "limit" },
            { in: "query", key: "order" },
            { in: "query", key: "cursor" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionMessagesResponses, V2SessionMessagesErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/message",
      ...options,
      ...params,
    })
  }
}

export class Model extends HeyApiClient {
  /**
   * List v2 models
   *
   * Retrieve available v2 models ordered by release date.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "location" }] }])
    return (options?.client ?? this.client).get<V2ModelListResponses, V2ModelListErrors, ThrowOnError>({
      url: "/api/model",
      ...options,
      ...params,
    })
  }
}

export class Provider2 extends HeyApiClient {
  /**
   * List v2 providers
   *
   * Retrieve active v2 AI providers so clients can show provider availability and configuration.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "location" }] }])
    return (options?.client ?? this.client).get<V2ProviderListResponses, V2ProviderListErrors, ThrowOnError>({
      url: "/api/provider",
      ...options,
      ...params,
    })
  }

  /**
   * Get v2 provider
   *
   * Retrieve a single v2 AI provider so clients can inspect its availability and endpoint settings.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "providerID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2ProviderGetResponses, V2ProviderGetErrors, ThrowOnError>({
      url: "/api/provider/{providerID}",
      ...options,
      ...params,
    })
  }
}

export class V2 extends HeyApiClient {
  private _session?: Session3
  get session(): Session3 {
    return (this._session ??= new Session3({ client: this.client }))
  }

  private _model?: Model
  get model(): Model {
    return (this._model ??= new Model({ client: this.client }))
  }

  private _provider?: Provider2
  get provider(): Provider2 {
    return (this._provider ??= new Provider2({ client: this.client }))
  }
}

export class Control extends HeyApiClient {
  /**
   * Get next TUI request
   *
   * Retrieve the next TUI request from the queue for processing.
   */
  public next<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<TuiControlNextResponses, TuiControlNextErrors, ThrowOnError>({
      url: "/tui/control/next",
      ...options,
      ...params,
    })
  }

  /**
   * Submit TUI response
   *
   * Submit a response to the TUI request queue to complete a pending request.
   */
  public response<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      body?: unknown
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "body", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiControlResponseResponses, TuiControlResponseErrors, ThrowOnError>({
      url: "/tui/control/response",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Config3 extends HeyApiClient {
  /**
   * Get TUI configuration
   *
   * Retrieve the effective TUI configuration for the current instance directory.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<TuiConfigGetResponses, TuiConfigGetErrors, ThrowOnError>({
      url: "/tui/config",
      ...options,
      ...params,
    })
  }

  /**
   * Update TUI configuration
   *
   * Patch global or project TUI configuration and return the effective TUI configuration.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: "project" | "global"
      $schema?: string
      theme?: string
      keybinds?: {
        [key: string]: string
      }
      plugin?: Array<
        | string
        | [
            string,
            {
              [key: string]: unknown
            },
          ]
      >
      plugin_enabled?: {
        [key: string]: boolean
      }
      title_icon?: "none" | "unicode" | "emojis"
      scroll_speed?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      scroll_acceleration?: {
        enabled: boolean
      }
      diff_style?: "auto" | "stacked"
      mouse?: boolean
      attention?: {
        enabled?: boolean
        notifications?: boolean
        sound?: boolean
        volume?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scope" },
            { in: "body", key: "$schema" },
            { in: "body", key: "theme" },
            { in: "body", key: "keybinds" },
            { in: "body", key: "plugin" },
            { in: "body", key: "plugin_enabled" },
            { in: "body", key: "title_icon" },
            { in: "body", key: "scroll_speed" },
            { in: "body", key: "scroll_acceleration" },
            { in: "body", key: "diff_style" },
            { in: "body", key: "mouse" },
            { in: "body", key: "attention" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<TuiConfigUpdateResponses, TuiConfigUpdateErrors, ThrowOnError>({
      url: "/tui/config",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Keybind extends HeyApiClient {
  /**
   * List TUI keybinds
   *
   * List valid TUI keybind commands, descriptions, groups, and default bindings from the CLI schema.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<TuiKeybindListResponses, TuiKeybindListErrors, ThrowOnError>({
      url: "/tui/keybinds",
      ...options,
      ...params,
    })
  }
}

export class Tui extends HeyApiClient {
  /**
   * Append TUI prompt
   *
   * Append prompt to the TUI.
   */
  public appendPrompt<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      text?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "text" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiAppendPromptResponses, TuiAppendPromptErrors, ThrowOnError>({
      url: "/tui/append-prompt",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Open help dialog
   *
   * Open the help dialog in the TUI to display user assistance information.
   */
  public openHelp<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiOpenHelpResponses, TuiOpenHelpErrors, ThrowOnError>({
      url: "/tui/open-help",
      ...options,
      ...params,
    })
  }

  /**
   * Open sessions dialog
   *
   * Open the session dialog.
   */
  public openSessions<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiOpenSessionsResponses, TuiOpenSessionsErrors, ThrowOnError>({
      url: "/tui/open-sessions",
      ...options,
      ...params,
    })
  }

  /**
   * Open themes dialog
   *
   * Open the theme dialog.
   */
  public openThemes<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiOpenThemesResponses, TuiOpenThemesErrors, ThrowOnError>({
      url: "/tui/open-themes",
      ...options,
      ...params,
    })
  }

  /**
   * Open models dialog
   *
   * Open the model dialog.
   */
  public openModels<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiOpenModelsResponses, TuiOpenModelsErrors, ThrowOnError>({
      url: "/tui/open-models",
      ...options,
      ...params,
    })
  }

  /**
   * Submit TUI prompt
   *
   * Submit the prompt.
   */
  public submitPrompt<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiSubmitPromptResponses, TuiSubmitPromptErrors, ThrowOnError>({
      url: "/tui/submit-prompt",
      ...options,
      ...params,
    })
  }

  /**
   * Clear TUI prompt
   *
   * Clear the prompt.
   */
  public clearPrompt<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiClearPromptResponses, TuiClearPromptErrors, ThrowOnError>({
      url: "/tui/clear-prompt",
      ...options,
      ...params,
    })
  }

  /**
   * Execute TUI command
   *
   * Execute a TUI command.
   */
  public executeCommand<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      command?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "command" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiExecuteCommandResponses, TuiExecuteCommandErrors, ThrowOnError>({
      url: "/tui/execute-command",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Show TUI toast
   *
   * Show a toast notification in the TUI.
   */
  public showToast<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      title?: string
      message?: string
      variant?: "info" | "success" | "warning" | "error"
      duration?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "title" },
            { in: "body", key: "message" },
            { in: "body", key: "variant" },
            { in: "body", key: "duration" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiShowToastResponses, TuiShowToastErrors, ThrowOnError>({
      url: "/tui/show-toast",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Publish TUI event
   *
   * Publish a TUI event.
   */
  public publish<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      body?: EventTuiPromptAppend2 | EventTuiCommandExecute2 | EventTuiToastShow2 | EventTuiSessionSelect2
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "body", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiPublishResponses, TuiPublishErrors, ThrowOnError>({
      url: "/tui/publish",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Select session
   *
   * Navigate the TUI to display the specified session.
   */
  public selectSession<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      sessionID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "sessionID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TuiSelectSessionResponses, TuiSelectSessionErrors, ThrowOnError>({
      url: "/tui/select-session",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _control?: Control
  get control(): Control {
    return (this._control ??= new Control({ client: this.client }))
  }

  private _config?: Config3
  get config(): Config3 {
    return (this._config ??= new Config3({ client: this.client }))
  }

  private _keybind?: Keybind
  get keybind(): Keybind {
    return (this._keybind ??= new Keybind({ client: this.client }))
  }
}

export class AgentBuilder extends HeyApiClient {
  /**
   * Preview agent markdown
   *
   * Validate an agent builder payload and return the canonical agent markdown without writing it.
   */
  public preview<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      scope?: "global" | "project"
      description?: string
      mode?: "primary" | "subagent" | "all"
      model?: string
      color?: string
      steps?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      tools?: Array<string>
      permission?: {
        [key: string]: unknown
      }
      prompt?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "scope" },
            { in: "body", key: "description" },
            { in: "body", key: "mode" },
            { in: "body", key: "model" },
            { in: "body", key: "color" },
            { in: "body", key: "steps" },
            { in: "body", key: "tools" },
            { in: "body", key: "permission" },
            { in: "body", key: "prompt" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<AgentBuilderPreviewResponses, AgentBuilderPreviewErrors, ThrowOnError>(
      {
        url: "/agent-builder/preview",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }

  /**
   * Save agent markdown
   *
   * Save an agent builder payload as a canonical agent markdown file.
   */
  public save<ThrowOnError extends boolean = false>(
    parameters: {
      path_id: string
      directory?: string
      workspace?: string
      body_id?: string
      scope?: "global" | "project"
      description?: string
      mode?: "primary" | "subagent" | "all"
      model?: string
      color?: string
      steps?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      tools?: Array<string>
      permission?: {
        [key: string]: unknown
      }
      prompt?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            {
              in: "path",
              key: "path_id",
              map: "id",
            },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            {
              in: "body",
              key: "body_id",
              map: "id",
            },
            { in: "body", key: "scope" },
            { in: "body", key: "description" },
            { in: "body", key: "mode" },
            { in: "body", key: "model" },
            { in: "body", key: "color" },
            { in: "body", key: "steps" },
            { in: "body", key: "tools" },
            { in: "body", key: "permission" },
            { in: "body", key: "prompt" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<AgentBuilderSaveResponses, AgentBuilderSaveErrors, ThrowOnError>({
      url: "/agent-builder/{id}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class BackgroundProcess extends HeyApiClient {
  /**
   * List background processes
   *
   * List tracked background processes for the current instance.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      BackgroundProcessListResponses,
      BackgroundProcessListErrors,
      ThrowOnError
    >({
      url: "/background-process",
      ...options,
      ...params,
    })
  }

  /**
   * Get background process
   *
   * Get status and retained output for one background process.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      processID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "processID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      BackgroundProcessGetResponses,
      BackgroundProcessGetErrors,
      ThrowOnError
    >({
      url: "/background-process/{processID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get background process logs
   *
   * Get the retained output tail for one background process.
   */
  public logs<ThrowOnError extends boolean = false>(
    parameters: {
      processID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "processID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      BackgroundProcessLogsResponses,
      BackgroundProcessLogsErrors,
      ThrowOnError
    >({
      url: "/background-process/{processID}/logs",
      ...options,
      ...params,
    })
  }

  /**
   * Stop background process
   *
   * Terminate a background process and its child process tree.
   */
  public stop<ThrowOnError extends boolean = false>(
    parameters: {
      processID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "processID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      BackgroundProcessStopResponses,
      BackgroundProcessStopErrors,
      ThrowOnError
    >({
      url: "/background-process/{processID}/stop",
      ...options,
      ...params,
    })
  }

  /**
   * Restart background process
   *
   * Stop and restart a background process with its original command.
   */
  public restart<ThrowOnError extends boolean = false>(
    parameters: {
      processID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "processID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      BackgroundProcessRestartResponses,
      BackgroundProcessRestartErrors,
      ThrowOnError
    >({
      url: "/background-process/{processID}/restart",
      ...options,
      ...params,
    })
  }

  /**
   * Stop session background processes
   *
   * Terminate and forget all background processes associated with one session.
   */
  public stopSession<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      BackgroundProcessStopSessionResponses,
      BackgroundProcessStopSessionErrors,
      ThrowOnError
    >({
      url: "/background-process/session/{sessionID}/stop",
      ...options,
      ...params,
    })
  }
}

export class CommitMessage extends HeyApiClient {
  /**
   * Generate commit message
   *
   * Generate a commit message using AI based on the current git diff.
   */
  public generate<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      path?: string
      selectedFiles?: Array<string>
      previousMessage?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "path" },
            { in: "body", key: "selectedFiles" },
            { in: "body", key: "previousMessage" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      CommitMessageGenerateResponses,
      CommitMessageGenerateErrors,
      ThrowOnError
    >({
      url: "/commit-message",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class EnhancePrompt extends HeyApiClient {
  /**
   * Enhance prompt
   *
   * Rewrite a user's draft prompt into a clearer, more specific, and more effective prompt.
   */
  public enhance<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      text?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "text" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      EnhancePromptEnhanceResponses,
      EnhancePromptEnhanceErrors,
      ThrowOnError
    >({
      url: "/enhance-prompt",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Indexing extends HeyApiClient {
  /**
   * Get indexing status
   *
   * Retrieve the current code indexing status for the active project.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<IndexingStatusResponses, IndexingStatusErrors, ThrowOnError>({
      url: "/indexing/status",
      ...options,
      ...params,
    })
  }

  /**
   * Get indexing warnings
   *
   * Retrieve code indexing warnings for the active project.
   */
  public warnings<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<IndexingWarningsResponses, IndexingWarningsErrors, ThrowOnError>({
      url: "/indexing/warnings",
      ...options,
      ...params,
    })
  }

  /**
   * List Kilo embedding models
   *
   * Retrieve the embedding models available through the active Kilo account.
   */
  public models<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<IndexingModelsResponses, IndexingModelsErrors, ThrowOnError>({
      url: "/indexing/models",
      ...options,
      ...params,
    })
  }
}

export class Audio extends HeyApiClient {
  /**
   * Speech to text transcription
   *
   * Proxy an audio transcription request to the Kilo Gateway
   */
  public transcriptions<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      model?: string
      input_audio?: {
        data: string
        format: string
      }
      language?: string
      prompt?: string
      temperature?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "model" },
            { in: "body", key: "input_audio" },
            { in: "body", key: "language" },
            { in: "body", key: "prompt" },
            { in: "body", key: "temperature" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KiloAudioTranscriptionsResponses,
      KiloAudioTranscriptionsErrors,
      ThrowOnError
    >({
      url: "/kilo/audio/transcriptions",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Organization extends HeyApiClient {
  /**
   * Update Kilo Gateway organization
   *
   * Switch to a different Kilo Gateway organization
   */
  public set<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      organizationId?: string | null
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "organizationId" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<KiloOrganizationSetResponses, KiloOrganizationSetErrors, ThrowOnError>(
      {
        url: "/kilo/organization",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }
}

export class Claw extends HeyApiClient {
  /**
   * Get KiloClaw instance status
   *
   * Fetch the user's KiloClaw instance status via the KiloClaw worker
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloClawStatusResponses, KiloClawStatusErrors, ThrowOnError>({
      url: "/kilo/claw/status",
      ...options,
      ...params,
    })
  }

  /**
   * Get KiloClaw chat credentials
   *
   * Returns the bearer token and endpoint URLs the client uses to talk to the Kilo Chat worker and the Event Service. The bearer is the user's existing long-lived Kilo JWT — kilo-chat and event-service both verify it directly with NEXTAUTH_SECRET, so no separate token mint is needed.
   */
  public chatCredentials<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      KiloClawChatCredentialsResponses,
      KiloClawChatCredentialsErrors,
      ThrowOnError
    >({
      url: "/kilo/claw/chat-credentials",
      ...options,
      ...params,
    })
  }
}

export class Session4 extends HeyApiClient {
  /**
   * Get cloud session
   *
   * Fetch full session data from the Kilo cloud for preview
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      id: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "id" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloCloudSessionGetResponses, KiloCloudSessionGetErrors, ThrowOnError>({
      url: "/kilo/cloud/session/{id}",
      ...options,
      ...params,
    })
  }

  /**
   * Import session from cloud
   *
   * Download a cloud-synced session and write it to local storage with fresh IDs.
   */
  public import<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      sessionId?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "sessionId" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KiloCloudSessionImportResponses,
      KiloCloudSessionImportErrors,
      ThrowOnError
    >({
      url: "/kilo/cloud/session/import",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Cloud extends HeyApiClient {
  private _session?: Session4
  get session(): Session4 {
    return (this._session ??= new Session4({ client: this.client }))
  }
}

export class Kilo extends HeyApiClient {
  /**
   * Get Kilo Gateway profile
   *
   * Fetch user profile and organizations from Kilo Gateway
   */
  public profile<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloProfileResponses, KiloProfileErrors, ThrowOnError>({
      url: "/kilo/profile",
      ...options,
      ...params,
    })
  }

  /**
   * Get Kilo authentication status
   *
   * Check whether a locally stored Kilo credential can authenticate Gateway requests
   */
  public authStatus<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloAuthStatusResponses, KiloAuthStatusErrors, ThrowOnError>({
      url: "/kilo/auth-status",
      ...options,
      ...params,
    })
  }

  /**
   * Get organization custom modes
   *
   * Fetch custom modes defined for the current organization
   */
  public modes<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloModesResponses, KiloModesErrors, ThrowOnError>({
      url: "/kilo/modes",
      ...options,
      ...params,
    })
  }

  /**
   * FIM completion
   *
   * Proxy a Fill-in-the-Middle completion request to the Kilo Gateway
   */
  public fim<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      prefix?: string
      suffix?: string
      provider?: string
      model?: string
      maxTokens?: number
      temperature?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "prefix" },
            { in: "body", key: "suffix" },
            { in: "body", key: "provider" },
            { in: "body", key: "model" },
            { in: "body", key: "maxTokens" },
            { in: "body", key: "temperature" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).sse.post<KiloFimResponses, KiloFimErrors, ThrowOnError>({
      url: "/kilo/fim",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Next Edit completion
   *
   * Proxy a Mercury-style Next Edit request. The client supplies structured editor context; the gateway assembles the sentinel-tagged prompt and forwards to the upstream edit endpoint.
   */
  public edit<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      provider?: string
      model?: string
      maxTokens?: number
      currentFilePath?: string
      currentFileContent?: string
      cursorLine?: number
      cursorCharacter?: number
      editableRegionStartLine?: number
      editableRegionEndLine?: number
      recentlyViewedSnippets?: Array<{
        filepath: string
        content: string
      }>
      editDiffHistory?: Array<string>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "provider" },
            { in: "body", key: "model" },
            { in: "body", key: "maxTokens" },
            { in: "body", key: "currentFilePath" },
            { in: "body", key: "currentFileContent" },
            { in: "body", key: "cursorLine" },
            { in: "body", key: "cursorCharacter" },
            { in: "body", key: "editableRegionStartLine" },
            { in: "body", key: "editableRegionEndLine" },
            { in: "body", key: "recentlyViewedSnippets" },
            { in: "body", key: "editDiffHistory" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<KiloEditResponses, KiloEditErrors, ThrowOnError>({
      url: "/kilo/edit",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get Kilo notifications
   *
   * Fetch notifications from Kilo Gateway for CLI display
   */
  public notifications<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloNotificationsResponses, KiloNotificationsErrors, ThrowOnError>({
      url: "/kilo/notifications",
      ...options,
      ...params,
    })
  }

  /**
   * Get cloud sessions
   *
   * Fetch cloud CLI sessions from Kilo API
   */
  public cloudSessions<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      cursor?: string
      limit?: number
      gitUrl?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "cursor" },
            { in: "query", key: "limit" },
            { in: "query", key: "gitUrl" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<KiloCloudSessionsResponses, KiloCloudSessionsErrors, ThrowOnError>({
      url: "/kilo/cloud-sessions",
      ...options,
      ...params,
    })
  }

  private _audio?: Audio
  get audio(): Audio {
    return (this._audio ??= new Audio({ client: this.client }))
  }

  private _organization?: Organization
  get organization(): Organization {
    return (this._organization ??= new Organization({ client: this.client }))
  }

  private _claw?: Claw
  get claw(): Claw {
    return (this._claw ??= new Claw({ client: this.client }))
  }

  private _cloud?: Cloud
  get cloud(): Cloud {
    return (this._cloud ??= new Cloud({ client: this.client }))
  }
}

export class Heap extends HeyApiClient {
  /**
   * Write heap snapshot
   *
   * Write a heap snapshot for the CLI process to the log directory.
   */
  public snapshot<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KilocodeHeapSnapshotResponses,
      KilocodeHeapSnapshotErrors,
      ThrowOnError
    >({
      url: "/kilocode/heap/snapshot",
      ...options,
      ...params,
    })
  }
}

export class SessionImport extends HeyApiClient {
  /**
   * Insert project for session import
   *
   * Insert or update a project row used by legacy session import.
   */
  public project<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      worktree?: string
      vcs?: string
      name?: string
      iconUrl?: string
      iconColor?: string
      timeCreated?: number
      timeUpdated?: number
      timeInitialized?: number
      sandboxes?: Array<string>
      commands?: {
        start?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "worktree" },
            { in: "body", key: "vcs" },
            { in: "body", key: "name" },
            { in: "body", key: "iconUrl" },
            { in: "body", key: "iconColor" },
            { in: "body", key: "timeCreated" },
            { in: "body", key: "timeUpdated" },
            { in: "body", key: "timeInitialized" },
            { in: "body", key: "sandboxes" },
            { in: "body", key: "commands" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KilocodeSessionImportProjectResponses,
      KilocodeSessionImportProjectErrors,
      ThrowOnError
    >({
      url: "/kilocode/session-import/project",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Insert session for session import
   *
   * Insert or update a session row used by legacy session import.
   */
  public session<ThrowOnError extends boolean = false>(
    parameters?: {
      query_directory?: string
      workspace?: string
      id?: string
      projectID?: string
      force?: boolean
      workspaceID?: string
      parentID?: string
      slug?: string
      body_directory?: string
      title?: string
      version?: string
      shareURL?: string
      summary?: {
        additions: number
        deletions: number
        files: number
        diffs?: Array<{
          [key: string]: unknown
        }>
      }
      revert?: {
        messageID: string
        partID?: string
        snapshot?: string
        diff?: string
      }
      permission?: {
        [key: string]: unknown
      }
      timeCreated?: number
      timeUpdated?: number
      timeCompacting?: number
      timeArchived?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            {
              in: "query",
              key: "query_directory",
              map: "directory",
            },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "projectID" },
            { in: "body", key: "force" },
            { in: "body", key: "workspaceID" },
            { in: "body", key: "parentID" },
            { in: "body", key: "slug" },
            {
              in: "body",
              key: "body_directory",
              map: "directory",
            },
            { in: "body", key: "title" },
            { in: "body", key: "version" },
            { in: "body", key: "shareURL" },
            { in: "body", key: "summary" },
            { in: "body", key: "revert" },
            { in: "body", key: "permission" },
            { in: "body", key: "timeCreated" },
            { in: "body", key: "timeUpdated" },
            { in: "body", key: "timeCompacting" },
            { in: "body", key: "timeArchived" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KilocodeSessionImportSessionResponses,
      KilocodeSessionImportSessionErrors,
      ThrowOnError
    >({
      url: "/kilocode/session-import/session",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Insert message for session import
   *
   * Insert or update a message row used by legacy session import.
   */
  public message<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      sessionID?: string
      timeCreated?: number
      data?:
        | {
            role: "user"
            time: {
              created: number
            }
            agent: string
            model: {
              providerID: string
              modelID: string
            }
            tools?: {
              [key: string]: boolean
            }
          }
        | {
            role: "assistant"
            time: {
              created: number
              completed?: number
            }
            parentID: string
            modelID: string
            providerID: string
            mode: string
            agent: string
            path: {
              cwd: string
              root: string
            }
            summary?: boolean
            cost: number
            tokens: {
              total?: number
              input: number
              output: number
              reasoning: number
              cache: {
                read: number
                write: number
              }
            }
            structured?: unknown
            variant?: string
            finish?: string
          }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "sessionID" },
            { in: "body", key: "timeCreated" },
            { in: "body", key: "data" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KilocodeSessionImportMessageResponses,
      KilocodeSessionImportMessageErrors,
      ThrowOnError
    >({
      url: "/kilocode/session-import/message",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Insert part for session import
   *
   * Insert or update a part row used by legacy session import.
   */
  public part<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      messageID?: string
      sessionID?: string
      timeCreated?: number
      data?:
        | {
            type: "text"
            text: string
            synthetic?: boolean
            ignored?: boolean
            time?: {
              start: number
              end?: number
            }
            metadata?: {
              [key: string]: unknown
            }
          }
        | {
            type: "reasoning"
            text: string
            metadata?: {
              [key: string]: unknown
            }
            time: {
              start: number
              end?: number
            }
          }
        | {
            type: "tool"
            callID: string
            tool: string
            state:
              | {
                  status: "pending"
                  input: {
                    [key: string]: unknown
                  }
                  raw: string
                }
              | {
                  status: "running"
                  input: {
                    [key: string]: unknown
                  }
                  title?: string
                  metadata?: {
                    [key: string]: unknown
                  }
                  time: {
                    start: number
                  }
                }
              | {
                  status: "completed"
                  input: {
                    [key: string]: unknown
                  }
                  output: string
                  title: string
                  metadata: {
                    [key: string]: unknown
                  }
                  time: {
                    start: number
                    end: number
                    compacted?: number
                  }
                }
              | {
                  status: "error"
                  input: {
                    [key: string]: unknown
                  }
                  error: string
                  metadata?: {
                    [key: string]: unknown
                  }
                  time: {
                    start: number
                    end: number
                  }
                }
            metadata?: {
              [key: string]: unknown
            }
          }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
            { in: "body", key: "messageID" },
            { in: "body", key: "sessionID" },
            { in: "body", key: "timeCreated" },
            { in: "body", key: "data" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      KilocodeSessionImportPartResponses,
      KilocodeSessionImportPartErrors,
      ThrowOnError
    >({
      url: "/kilocode/session-import/part",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Kilocode extends HeyApiClient {
  /**
   * Remove a skill
   *
   * Remove a skill by deleting its manifest from disk and clearing it from cache.
   */
  public removeSkill<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      location?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<KilocodeRemoveSkillResponses, KilocodeRemoveSkillErrors, ThrowOnError>(
      {
        url: "/kilocode/skill/remove",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }

  /**
   * Remove a custom agent
   *
   * Remove a custom (non-native) agent by deleting its markdown file from disk and refreshing state.
   */
  public removeAgent<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      name?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "name" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<KilocodeRemoveAgentResponses, KilocodeRemoveAgentErrors, ThrowOnError>(
      {
        url: "/kilocode/agent/remove",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }

  private _heap?: Heap
  get heap(): Heap {
    return (this._heap ??= new Heap({ client: this.client }))
  }

  private _sessionImport?: SessionImport
  get sessionImport(): SessionImport {
    return (this._sessionImport ??= new SessionImport({ client: this.client }))
  }
}

export class Network extends HeyApiClient {
  /**
   * List pending network waits
   *
   * Get all pending network reconnect requests across all sessions.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<NetworkListResponses, NetworkListErrors, ThrowOnError>({
      url: "/network",
      ...options,
      ...params,
    })
  }

  /**
   * Resume after network wait
   *
   * Resume a pending session after reconnecting network-dependent services.
   */
  public reply<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<NetworkReplyResponses, NetworkReplyErrors, ThrowOnError>({
      url: "/network/{requestID}/reply",
      ...options,
      ...params,
    })
  }

  /**
   * Reject network resume request
   *
   * Stop a pending session instead of resuming after network reconnect.
   */
  public reject<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<NetworkRejectResponses, NetworkRejectErrors, ThrowOnError>({
      url: "/network/{requestID}/reject",
      ...options,
      ...params,
    })
  }
}

export class Remote extends HeyApiClient {
  /**
   * Enable remote connection
   *
   * Enable WebSocket connection to UserConnectionDO for real-time session relay and commands.
   */
  public enable<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<RemoteEnableResponses, RemoteEnableErrors, ThrowOnError>({
      url: "/remote/enable",
      ...options,
      ...params,
    })
  }

  /**
   * Disable remote connection
   *
   * Close the remote WebSocket connection to UserConnectionDO.
   */
  public disable<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<RemoteDisableResponses, RemoteDisableErrors, ThrowOnError>({
      url: "/remote/disable",
      ...options,
      ...params,
    })
  }

  /**
   * Get remote connection status
   *
   * Get the current state of the remote WebSocket connection.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<RemoteStatusResponses, RemoteStatusErrors, ThrowOnError>({
      url: "/remote/status",
      ...options,
      ...params,
    })
  }
}

export class Suggestion extends HeyApiClient {
  /**
   * List pending suggestions
   *
   * Get all pending suggestion requests across all sessions.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<SuggestionListResponses, SuggestionListErrors, ThrowOnError>({
      url: "/suggestion",
      ...options,
      ...params,
    })
  }

  /**
   * Accept suggestion request
   *
   * Accept a suggestion request from the AI assistant.
   */
  public accept<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
      index?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "index" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SuggestionAcceptResponses, SuggestionAcceptErrors, ThrowOnError>({
      url: "/suggestion/{requestID}/accept",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Dismiss suggestion request
   *
   * Dismiss a suggestion request from the AI assistant.
   */
  public dismiss<ThrowOnError extends boolean = false>(
    parameters: {
      requestID: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "requestID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<SuggestionDismissResponses, SuggestionDismissErrors, ThrowOnError>({
      url: "/suggestion/{requestID}/dismiss",
      ...options,
      ...params,
    })
  }
}

export class Telemetry extends HeyApiClient {
  /**
   * Capture telemetry event
   *
   * Forward a telemetry event to PostHog via kilo-telemetry.
   */
  public capture<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      event?: string
      properties?: {
        [key: string]: unknown
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "event" },
            { in: "body", key: "properties" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TelemetryCaptureResponses, TelemetryCaptureErrors, ThrowOnError>({
      url: "/telemetry/capture",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Set PostHog telemetry enabled state
   *
   * Update the PostHog client's opt-in/out state at runtime. The CLI reads KILO_TELEMETRY_LEVEL once at spawn — this route lets clients (e.g. the VS Code extension) propagate runtime telemetry consent changes.
   */
  public setEnabled<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      enabled?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "enabled" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<TelemetrySetEnabledResponses, TelemetrySetEnabledErrors, ThrowOnError>(
      {
        url: "/telemetry/setEnabled",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }
}

export class KiloClient extends HeyApiClient {
  public static readonly __registry = new HeyApiRegistry<KiloClient>()

  constructor(args?: { client?: Client; key?: string }) {
    super(args)
    KiloClient.__registry.set(this, args?.key)
  }

  private _auth?: Auth
  get auth(): Auth {
    return (this._auth ??= new Auth({ client: this.client }))
  }

  private _app?: App
  get app(): App {
    return (this._app ??= new App({ client: this.client }))
  }

  private _global?: Global
  get global(): Global {
    return (this._global ??= new Global({ client: this.client }))
  }

  private _event?: Event
  get event(): Event {
    return (this._event ??= new Event({ client: this.client }))
  }

  private _config?: Config2
  get config(): Config2 {
    return (this._config ??= new Config2({ client: this.client }))
  }

  private _experimental?: Experimental
  get experimental(): Experimental {
    return (this._experimental ??= new Experimental({ client: this.client }))
  }

  private _tool?: Tool
  get tool(): Tool {
    return (this._tool ??= new Tool({ client: this.client }))
  }

  private _worktree?: Worktree
  get worktree(): Worktree {
    return (this._worktree ??= new Worktree({ client: this.client }))
  }

  private _find?: Find
  get find(): Find {
    return (this._find ??= new Find({ client: this.client }))
  }

  private _file?: File
  get file(): File {
    return (this._file ??= new File({ client: this.client }))
  }

  private _instance?: Instance
  get instance(): Instance {
    return (this._instance ??= new Instance({ client: this.client }))
  }

  private _path?: Path
  get path(): Path {
    return (this._path ??= new Path({ client: this.client }))
  }

  private _vcs?: Vcs
  get vcs(): Vcs {
    return (this._vcs ??= new Vcs({ client: this.client }))
  }

  private _command?: Command
  get command(): Command {
    return (this._command ??= new Command({ client: this.client }))
  }

  private _lsp?: Lsp
  get lsp(): Lsp {
    return (this._lsp ??= new Lsp({ client: this.client }))
  }

  private _formatter?: Formatter
  get formatter(): Formatter {
    return (this._formatter ??= new Formatter({ client: this.client }))
  }

  private _mcp?: Mcp
  get mcp(): Mcp {
    return (this._mcp ??= new Mcp({ client: this.client }))
  }

  private _project?: Project
  get project(): Project {
    return (this._project ??= new Project({ client: this.client }))
  }

  private _pty?: Pty
  get pty(): Pty {
    return (this._pty ??= new Pty({ client: this.client }))
  }

  private _question?: Question
  get question(): Question {
    return (this._question ??= new Question({ client: this.client }))
  }

  private _permission?: Permission
  get permission(): Permission {
    return (this._permission ??= new Permission({ client: this.client }))
  }

  private _provider?: Provider
  get provider(): Provider {
    return (this._provider ??= new Provider({ client: this.client }))
  }

  private _session?: Session2
  get session(): Session2 {
    return (this._session ??= new Session2({ client: this.client }))
  }

  private _part?: Part
  get part(): Part {
    return (this._part ??= new Part({ client: this.client }))
  }

  private _sync?: Sync
  get sync(): Sync {
    return (this._sync ??= new Sync({ client: this.client }))
  }

  private _v2?: V2
  get v2(): V2 {
    return (this._v2 ??= new V2({ client: this.client }))
  }

  private _tui?: Tui
  get tui(): Tui {
    return (this._tui ??= new Tui({ client: this.client }))
  }

  private _agentBuilder?: AgentBuilder
  get agentBuilder(): AgentBuilder {
    return (this._agentBuilder ??= new AgentBuilder({ client: this.client }))
  }

  private _backgroundProcess?: BackgroundProcess
  get backgroundProcess(): BackgroundProcess {
    return (this._backgroundProcess ??= new BackgroundProcess({ client: this.client }))
  }

  private _commitMessage?: CommitMessage
  get commitMessage(): CommitMessage {
    return (this._commitMessage ??= new CommitMessage({ client: this.client }))
  }

  private _enhancePrompt?: EnhancePrompt
  get enhancePrompt(): EnhancePrompt {
    return (this._enhancePrompt ??= new EnhancePrompt({ client: this.client }))
  }

  private _indexing?: Indexing
  get indexing(): Indexing {
    return (this._indexing ??= new Indexing({ client: this.client }))
  }

  private _kilo?: Kilo
  get kilo(): Kilo {
    return (this._kilo ??= new Kilo({ client: this.client }))
  }

  private _kilocode?: Kilocode
  get kilocode(): Kilocode {
    return (this._kilocode ??= new Kilocode({ client: this.client }))
  }

  private _network?: Network
  get network(): Network {
    return (this._network ??= new Network({ client: this.client }))
  }

  private _remote?: Remote
  get remote(): Remote {
    return (this._remote ??= new Remote({ client: this.client }))
  }

  private _suggestion?: Suggestion
  get suggestion(): Suggestion {
    return (this._suggestion ??= new Suggestion({ client: this.client }))
  }

  private _telemetry?: Telemetry
  get telemetry(): Telemetry {
    return (this._telemetry ??= new Telemetry({ client: this.client }))
  }
}
