// 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 {
  AdhocDiscardErrors,
  AdhocDiscardResponses,
  AdhocListErrors,
  AdhocListResponses,
  AdhocPromoteErrors,
  AdhocPromoteResponses,
  AppAgentsErrors,
  AppAgentsResponses,
  AppListErrors,
  AppListResponses,
  AppLogErrors,
  AppLogResponses,
  AppRegisterErrors,
  AppRegisterResponses,
  AppSkillsErrors,
  AppSkillsResponses,
  Auth as Auth3,
  AuthRemoveErrors,
  AuthRemoveResponses,
  AuthSetErrors,
  AuthSetResponses,
  CommandListErrors,
  CommandListResponses,
  ConfigGetErrors,
  ConfigGetResponses,
  ConfigInfo,
  ConfigProvidersErrors,
  ConfigProvidersResponses,
  ConfigUpdateErrors,
  ConfigUpdateResponses,
  ConfigV2McpLocal,
  ConfigV2McpRemote,
  EventSubscribeResponses,
  ExperimentalCapabilitiesGetErrors,
  ExperimentalCapabilitiesGetResponses,
  ExperimentalConsoleGetErrors,
  ExperimentalConsoleGetResponses,
  ExperimentalConsoleListOrgsErrors,
  ExperimentalConsoleListOrgsResponses,
  ExperimentalConsoleSwitchOrgResponses,
  ExperimentalControlPlaneMoveSessionErrors,
  ExperimentalControlPlaneMoveSessionResponses,
  ExperimentalResourceListErrors,
  ExperimentalResourceListResponses,
  ExperimentalSessionBackgroundErrors,
  ExperimentalSessionBackgroundResponses,
  ExperimentalWorkspaceAdapterListErrors,
  ExperimentalWorkspaceAdapterListResponses,
  ExperimentalWorkspaceCreateErrors,
  ExperimentalWorkspaceCreateResponses,
  ExperimentalWorkspaceListErrors,
  ExperimentalWorkspaceListResponses,
  ExperimentalWorkspaceRemoveErrors,
  ExperimentalWorkspaceRemoveResponses,
  ExperimentalWorkspaceStatusErrors,
  ExperimentalWorkspaceStatusResponses,
  ExperimentalWorkspaceSyncListErrors,
  ExperimentalWorkspaceSyncListResponses,
  ExperimentalWorkspaceWarpErrors,
  ExperimentalWorkspaceWarpResponses,
  FileListErrors,
  FileListResponses,
  FileMkdirErrors,
  FileMkdirResponses,
  FileReadErrors,
  FileReadResponses,
  FileStatusErrors,
  FileStatusResponses,
  FileTrashErrors,
  FileTrashListErrors,
  FileTrashListResponses,
  FileTrashResponses,
  FileTrashRestoreErrors,
  FileTrashRestoreResponses,
  FileWriteErrors,
  FileWriteResponses,
  FindFilesErrors,
  FindFilesResponses,
  FindTextErrors,
  FindTextResponses,
  FormatterStatusErrors,
  FormatterStatusResponses,
  GlobalConfigGetErrors,
  GlobalConfigGetResponses,
  GlobalConfigUpdateErrors,
  GlobalConfigUpdateResponses,
  GlobalDiscoveryErrors,
  GlobalDiscoveryResponses,
  GlobalDisposeErrors,
  GlobalDisposeResponses,
  GlobalEventErrors,
  GlobalEventResponses,
  GlobalHealthErrors,
  GlobalHealthResponses,
  GlobalUpgradeErrors,
  GlobalUpgradeResponses,
  InstanceDisposeErrors,
  InstanceDisposeResponses,
  InstanceSchedulerErrors,
  InstanceSchedulerResponses,
  LocationRef,
  McpAddErrors,
  McpAddResponses,
  McpAuthAuthenticateErrors,
  McpAuthAuthenticateResponses,
  McpAuthCallbackErrors,
  McpAuthCallbackResponses,
  McpAuthRemoveErrors,
  McpAuthRemoveResponses,
  McpAuthStartErrors,
  McpAuthStartResponses,
  McpConnectErrors,
  McpConnectResponses,
  McpDisconnectErrors,
  McpDisconnectResponses,
  McpStatusErrors,
  McpStatusResponses,
  MemoryClearScopeErrors,
  MemoryClearScopeResponses,
  MemoryGraphErrors,
  MemoryGraphResponses,
  MemoryIngestErrors,
  MemoryIngestResponses,
  MemoryInvalidateErrors,
  MemoryInvalidateResponses,
  MemoryListErrors,
  MemoryListResponses,
  MemoryNeighborsErrors,
  MemoryNeighborsResponses,
  MemoryPathErrors,
  MemoryPathResponses,
  MemoryPurgeErrors,
  MemoryPurgeResponses,
  MemoryRememberErrors,
  MemoryRememberResponses,
  MemorySearchErrors,
  MemorySearchResponses,
  MemoryStatsErrors,
  MemoryStatsResponses,
  MessengerTrust,
  ModelRef,
  MoveSessionDestination,
  PathGetErrors,
  PathGetResponses,
  PermissionListErrors,
  PermissionListResponses,
  PermissionReplyErrors,
  PermissionReplyResponses,
  PermissionRuleset,
  PermissionV2Reply,
  PermissionV2Source,
  PromptInput,
  ProviderAuthErrors,
  ProviderAuthResponses,
  ProviderListErrors,
  ProviderListResponses,
  ProviderOauthAuthorizeErrors,
  ProviderOauthAuthorizeResponses,
  ProviderOauthCallbackErrors,
  ProviderOauthCallbackResponses,
  ProviderPresetsErrors,
  ProviderPresetsResponses,
  ProviderProbeErrors,
  ProviderProbeResponses,
  PtyConnectErrors,
  PtyConnectResponses,
  PtyConnectTokenErrors,
  PtyConnectTokenResponses,
  PtyCreateErrors,
  PtyCreateResponses,
  PtyGetErrors,
  PtyGetResponses,
  PtyListErrors,
  PtyListResponses,
  PtyRemoveErrors,
  PtyRemoveResponses,
  PtyShellsErrors,
  PtyShellsResponses,
  PtyUpdateErrors,
  PtyUpdateResponses,
  QuestionAnswer,
  QuestionListErrors,
  QuestionListResponses,
  QuestionRejectErrors,
  QuestionRejectResponses,
  QuestionReplyErrors,
  QuestionReplyResponses,
  QuestionV2Reply,
  RegistryDeleteRowErrors,
  RegistryDeleteRowResponses,
  RegistryInsertRowErrors,
  RegistryInsertRowResponses,
  RegistryRowsErrors,
  RegistryRowsResponses,
  RegistryTablesErrors,
  RegistryTablesResponses,
  RegistryUpdateRowErrors,
  RegistryUpdateRowResponses,
  SessionStrictOverride,
  ShellOfflineErrors,
  ShellOfflineResponses,
  ShellProvisionErrors,
  ShellProvisionResponses,
  ShellStatusErrors,
  ShellStatusResponses,
  SyncHistoryListErrors,
  SyncHistoryListResponses,
  SyncReplayErrors,
  SyncReplayResponses,
  SyncStartErrors,
  SyncStartResponses,
  SyncStealErrors,
  SyncStealResponses,
  ToolIdsErrors,
  ToolIdsResponses,
  ToolListErrors,
  ToolListResponses,
  V2AgentListErrors,
  V2AgentListResponses,
  V2CommandListErrors,
  V2CommandListResponses,
  V2CredentialRemoveErrors,
  V2CredentialRemoveResponses,
  V2CredentialUpdateErrors,
  V2CredentialUpdateResponses,
  V2EventSubscribeErrors,
  V2EventSubscribeResponses,
  V2FsFindErrors,
  V2FsFindResponses,
  V2FsListErrors,
  V2FsListResponses,
  V2FsReadErrors,
  V2FsReadResponses,
  V2HealthGetErrors,
  V2HealthGetResponses,
  V2IntegrationAttemptCancelErrors,
  V2IntegrationAttemptCancelResponses,
  V2IntegrationAttemptCompleteErrors,
  V2IntegrationAttemptCompleteResponses,
  V2IntegrationAttemptStatusErrors,
  V2IntegrationAttemptStatusResponses,
  V2IntegrationConnectKeyErrors,
  V2IntegrationConnectKeyResponses,
  V2IntegrationConnectOauthErrors,
  V2IntegrationConnectOauthResponses,
  V2IntegrationGetErrors,
  V2IntegrationGetResponses,
  V2IntegrationListErrors,
  V2IntegrationListResponses,
  V2LocationGetErrors,
  V2LocationGetResponses,
  V2MessengerAccountChatsErrors,
  V2MessengerAccountChatsResponses,
  V2MessengerAccountCreateErrors,
  V2MessengerAccountCreateResponses,
  V2MessengerAccountListErrors,
  V2MessengerAccountListResponses,
  V2MessengerAccountPairErrors,
  V2MessengerAccountPairResponses,
  V2MessengerAccountRemoveErrors,
  V2MessengerAccountRemoveResponses,
  V2MessengerAccountUpdateErrors,
  V2MessengerAccountUpdateResponses,
  V2MessengerBindingCreateErrors,
  V2MessengerBindingCreateResponses,
  V2MessengerBindingListErrors,
  V2MessengerBindingListResponses,
  V2MessengerBindingRemoveErrors,
  V2MessengerBindingRemoveResponses,
  V2MessengerDriverListErrors,
  V2MessengerDriverListResponses,
  V2MessengerLoginBeginErrors,
  V2MessengerLoginBeginResponses,
  V2MessengerLoginCancelErrors,
  V2MessengerLoginCancelResponses,
  V2MessengerLoginCompleteErrors,
  V2MessengerLoginCompleteResponses,
  V2MessengerLoginStatusErrors,
  V2MessengerLoginStatusResponses,
  V2ModelListErrors,
  V2ModelListResponses,
  V2PermissionRequestListErrors,
  V2PermissionRequestListResponses,
  V2PermissionSavedListErrors,
  V2PermissionSavedListResponses,
  V2PermissionSavedRemoveErrors,
  V2PermissionSavedRemoveResponses,
  V2ProviderGetErrors,
  V2ProviderGetResponses,
  V2ProviderListErrors,
  V2ProviderListResponses,
  V2ProviderRemoveErrors,
  V2ProviderRemoveResponses,
  V2PtyConnectErrors,
  V2PtyConnectResponses,
  V2PtyConnectTokenErrors,
  V2PtyConnectTokenResponses,
  V2PtyCreateErrors,
  V2PtyCreateResponses,
  V2PtyGetErrors,
  V2PtyGetResponses,
  V2PtyListErrors,
  V2PtyListResponses,
  V2PtyRemoveErrors,
  V2PtyRemoveResponses,
  V2PtyUpdateErrors,
  V2PtyUpdateResponses,
  V2QuestionRequestListErrors,
  V2QuestionRequestListResponses,
  V2ReferenceListErrors,
  V2ReferenceListResponses,
  V2SessionActiveErrors,
  V2SessionActiveResponses,
  V2SessionChildrenErrors,
  V2SessionChildrenResponses,
  V2SessionCommandErrors,
  V2SessionCommandResponses,
  V2SessionCompactErrors,
  V2SessionCompactResponses,
  V2SessionContextErrors,
  V2SessionContextResponses,
  V2SessionCreateErrors,
  V2SessionCreateResponses,
  V2SessionEventsErrors,
  V2SessionEventsResponses,
  V2SessionForkErrors,
  V2SessionForkResponses,
  V2SessionGetErrors,
  V2SessionGetResponses,
  V2SessionHistoryErrors,
  V2SessionHistoryResponses,
  V2SessionInterruptErrors,
  V2SessionInterruptResponses,
  V2SessionListErrors,
  V2SessionListResponses,
  V2SessionMessageErrors,
  V2SessionMessageResponses,
  V2SessionMessagesErrors,
  V2SessionMessagesResponses,
  V2SessionPermissionCreateErrors,
  V2SessionPermissionCreateResponses,
  V2SessionPermissionGetErrors,
  V2SessionPermissionGetResponses,
  V2SessionPermissionListErrors,
  V2SessionPermissionListResponses,
  V2SessionPermissionReplyErrors,
  V2SessionPermissionReplyResponses,
  V2SessionPromptErrors,
  V2SessionPromptResponses,
  V2SessionQuestionListErrors,
  V2SessionQuestionListResponses,
  V2SessionQuestionRejectErrors,
  V2SessionQuestionRejectResponses,
  V2SessionQuestionReplyErrors,
  V2SessionQuestionReplyResponses,
  V2SessionRemoveErrors,
  V2SessionRemoveResponses,
  V2SessionRevertClearErrors,
  V2SessionRevertClearResponses,
  V2SessionRevertCommitErrors,
  V2SessionRevertCommitResponses,
  V2SessionRevertStageErrors,
  V2SessionRevertStageResponses,
  V2SessionShellErrors,
  V2SessionShellResponses,
  V2SessionSwitchAgentErrors,
  V2SessionSwitchAgentResponses,
  V2SessionSwitchFeatureErrors,
  V2SessionSwitchFeatureResponses,
  V2SessionSwitchModeErrors,
  V2SessionSwitchModelErrors,
  V2SessionSwitchModelResponses,
  V2SessionSwitchModeResponses,
  V2SessionSwitchPromptOverrideErrors,
  V2SessionSwitchPromptOverrideResponses,
  V2SessionSwitchResponderErrors,
  V2SessionSwitchResponderResponses,
  V2SessionSwitchStrictErrors,
  V2SessionSwitchStrictResponses,
  V2SessionSwitchTypeErrors,
  V2SessionSwitchTypeResponses,
  V2SessionTagsAllErrors,
  V2SessionTagsAllResponses,
  V2SessionTagsSetErrors,
  V2SessionTagsSetResponses,
  V2SessionTodoErrors,
  V2SessionTodoResponses,
  V2SessionUpdateErrors,
  V2SessionUpdateResponses,
  V2SessionWaitErrors,
  V2SessionWaitResponses,
  V2SkillListErrors,
  V2SkillListResponses,
  VcsApplyErrors,
  VcsApplyResponses,
  VcsDiffErrors,
  VcsDiffRawErrors,
  VcsDiffRawResponses,
  VcsDiffResponses,
  VcsGetErrors,
  VcsGetResponses,
  VcsStatusErrors,
  VcsStatusResponses,
  WorktreeCreateErrors,
  WorktreeCreateInput,
  WorktreeCreateResponses,
  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 NovaclawClient()" 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 NovaClaw 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 NovaClaw 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,
    })
  }

  /**
   * List home apps
   *
   * List persisted home-app manifests (agent- or user-registered launchers).
   */
  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<AppListResponses, AppListErrors, ThrowOnError>({
      url: "/app",
      ...options,
      ...params,
    })
  }

  /**
   * Register a home app
   *
   * Register (or update, by id) a home-app manifest: a launcher tile opening a route, URL, or chat prompt.
   */
  public register<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      title?: string
      icon?: string
      accent?: string
      subtitle?: string
      open?: {
        type: "route" | "url" | "prompt"
        value: 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: "title" },
            { in: "body", key: "icon" },
            { in: "body", key: "accent" },
            { in: "body", key: "subtitle" },
            { in: "body", key: "open" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<AppRegisterResponses, AppRegisterErrors, ThrowOnError>({
      url: "/app",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class ControlPlane extends HeyApiClient {
  /**
   * Move session
   *
   * Move a session to another project directory, optionally transferring local changes.
   */
  public moveSession<ThrowOnError extends boolean = false>(
    parameters?: {
      sessionID?: string
      destination?: MoveSessionDestination
      moveChanges?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "body", key: "sessionID" },
            { in: "body", key: "destination" },
            { in: "body", key: "moveChanges" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      ExperimentalControlPlaneMoveSessionResponses,
      ExperimentalControlPlaneMoveSessionErrors,
      ThrowOnError
    >({
      url: "/experimental/control-plane/move-session",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Capabilities extends HeyApiClient {
  /**
   * Get experimental capabilities
   *
   * Get experimental features enabled on the NovaClaw server.
   */
  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<
      ExperimentalCapabilitiesGetResponses,
      ExperimentalCapabilitiesGetErrors,
      ThrowOnError
    >({
      url: "/experimental/capabilities",
      ...options,
      ...params,
    })
  }
}

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 NovaClaw 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 {
  /**
   * Background subagents
   *
   * Detach any synchronous subagents currently blocking the session and continue them in the background.
   */
  public background<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<
      ExperimentalSessionBackgroundResponses,
      ExperimentalSessionBackgroundErrors,
      ThrowOnError
    >({
      url: "/experimental/session/{sessionID}/background",
      ...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 _controlPlane?: ControlPlane
  get controlPlane(): ControlPlane {
    return (this._controlPlane ??= new ControlPlane({ client: this.client }))
  }

  private _capabilities?: Capabilities
  get capabilities(): Capabilities {
    return (this._capabilities ??= new Capabilities({ client: this.client }))
  }

  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 Config extends HeyApiClient {
  /**
   * Get global configuration
   *
   * Retrieve the current global NovaClaw 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 NovaClaw configuration settings and preferences.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters?: {
      configInfo?: ConfigInfo
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ key: "configInfo", 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 NovaClaw 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 NovaClaw 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 NovaClaw 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 novaclaw
   *
   * Upgrade novaclaw 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,
      },
    })
  }

  /**
   * Discover LAN instances
   *
   * Scan the local network (mDNS) for NovaClaw instances advertising themselves via serve --mdns.
   */
  public discovery<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<GlobalDiscoveryResponses, GlobalDiscoveryErrors, ThrowOnError>({
      url: "/global/discovery",
      ...options,
    })
  }

  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 Adhoc extends HeyApiClient {
  /**
   * List session recipes (4E)
   *
   * The ad-hoc tool recipes the model defined in this session.
   */
  public list<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<AdhocListResponses, AdhocListErrors, ThrowOnError>({
      url: "/adhoc/session/{sessionID}",
      ...options,
      ...params,
    })
  }

  /**
   * Discard a session recipe (4E)
   *
   * Throw away one session-defined recipe by name.
   */
  public discard<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<AdhocDiscardResponses, AdhocDiscardErrors, ThrowOnError>({
      url: "/adhoc/session/{sessionID}/{name}",
      ...options,
      ...params,
    })
  }

  /**
   * Promote a session recipe to instance config (4E)
   *
   * Write a session-defined recipe into the instance adhoc_tools settings store, making it permanent.
   */
  public promote<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      name: string
      directory?: string
      workspace?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "name" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<AdhocPromoteResponses, AdhocPromoteErrors, ThrowOnError>({
      url: "/adhoc/session/{sessionID}/{name}/promote",
      ...options,
      ...params,
    })
  }
}

export class Config2 extends HeyApiClient {
  /**
   * Get configuration
   *
   * Retrieve the current NovaClaw 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 NovaClaw configuration settings and preferences.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      configInfo?: ConfigInfo
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { key: "configInfo", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<ConfigUpdateResponses, ConfigUpdateErrors, ThrowOnError>({
      url: "/config",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * 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,
    })
  }
}

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 sandbox worktrees 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<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,
      },
    })
  }
}

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,
    })
  }
}

export class Trash extends HeyApiClient {
  /**
   * List trash
   *
   * List trashed entries, newest first (expired entries are purged lazily).
   */
  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<FileTrashListResponses, FileTrashListErrors, ThrowOnError>({
      url: "/file/trash",
      ...options,
      ...params,
    })
  }

  /**
   * Restore from trash
   *
   * Restore a trashed entry to its original path (collision-safe suffix if occupied).
   */
  public restore<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<FileTrashRestoreResponses, FileTrashRestoreErrors, ThrowOnError>({
      url: "/file/trash/restore",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

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,
    })
  }

  /**
   * Write file
   *
   * Write text content to a file under the routed directory (parents created).
   */
  public write<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      path?: string
      content?: 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: "content" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<FileWriteResponses, FileWriteErrors, ThrowOnError>({
      url: "/file/content",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * 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,
    })
  }

  /**
   * Create directory
   *
   * Create a directory (recursive) under the routed directory.
   */
  public mkdir<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: "body", key: "path" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<FileMkdirResponses, FileMkdirErrors, ThrowOnError>({
      url: "/file/mkdir",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Trash file or directory
   *
   * Safe-delete: move a file or directory into the dated Trash store (restorable, TTL ~2 days).
   */
  public trash<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: "body", key: "path" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<FileTrashResponses, FileTrashErrors, ThrowOnError>({
      url: "/file/trash",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  private _trash?: Trash
  get trash2(): Trash {
    return (this._trash ??= new Trash({ client: this.client }))
  }
}

export class Instance extends HeyApiClient {
  /**
   * Dispose instance
   *
   * Clean up and dispose the current NovaClaw 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,
    })
  }

  /**
   * Scheduler snapshot
   *
   * Per-device in-flight and waiting sessions plus the EEVDF ledger — the live `ps` view.
   */
  public scheduler<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<InstanceSchedulerResponses, InstanceSchedulerErrors, ThrowOnError>({
      url: "/scheduler/snapshot",
      ...options,
      ...params,
    })
  }
}

export class Path extends HeyApiClient {
  /**
   * Get paths
   *
   * Retrieve the current working directory and related path information for the NovaClaw 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 NovaClaw 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 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?: ConfigV2McpLocal | ConfigV2McpRemote
    },
    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 Memory extends HeyApiClient {
  /**
   * Memory counts
   *
   * Total and currently-valid memory counts.
   */
  public stats<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<MemoryStatsResponses, MemoryStatsErrors, ThrowOnError>({
      url: "/memory/stats",
      ...options,
      ...params,
    })
  }

  /**
   * List memories
   *
   * Enumerate memories (no query); filter by scope/kind/validity, paginated.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scopes?: string
      kinds?: string
      includeInvalid?: string
      limit?: string
      offset?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scopes" },
            { in: "query", key: "kinds" },
            { in: "query", key: "includeInvalid" },
            { in: "query", key: "limit" },
            { in: "query", key: "offset" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<MemoryListResponses, MemoryListErrors, ThrowOnError>({
      url: "/memory/list",
      ...options,
      ...params,
    })
  }

  /**
   * Memory graph
   *
   * A bounded graph slice for the visualizer: nodes + valid edges among them.
   */
  public graph<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scopes?: string
      limit?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "scopes" },
            { in: "query", key: "limit" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<MemoryGraphResponses, MemoryGraphErrors, ThrowOnError>({
      url: "/memory/graph",
      ...options,
      ...params,
    })
  }

  /**
   * Search memory
   *
   * Keyword/FTS search over memory, scope-filtered.
   */
  public search<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      query?: string
      k?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      scopes?: Array<string>
      kinds?: Array<string>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "query" },
            { in: "body", key: "k" },
            { in: "body", key: "scopes" },
            { in: "body", key: "kinds" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemorySearchResponses, MemorySearchErrors, ThrowOnError>({
      url: "/memory/search",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Memory neighbours
   *
   * The directly-linked memories of one node.
   */
  public neighbors<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
      k?: 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: "body", key: "id" },
            { in: "body", key: "k" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryNeighborsResponses, MemoryNeighborsErrors, ThrowOnError>({
      url: "/memory/neighbors",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Memory path
   *
   * Shortest path (by edge count) between two memories.
   */
  public path<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      from?: string
      to?: string
      maxHops?: 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: "body", key: "from" },
            { in: "body", key: "to" },
            { in: "body", key: "maxHops" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryPathResponses, MemoryPathErrors, ThrowOnError>({
      url: "/memory/path",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Add a memory
   *
   * Record a new memory (staged) in the given scope.
   */
  public remember<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      text?: string
      name?: string
      scope?: string
      kind?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "text" },
            { in: "body", key: "name" },
            { in: "body", key: "scope" },
            { in: "body", key: "kind" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryRememberResponses, MemoryRememberErrors, ThrowOnError>({
      url: "/memory/remember",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Forget (invalidate)
   *
   * Supersede a memory bitemporally — kept in history, dropped from search.
   */
  public invalidate<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryInvalidateResponses, MemoryInvalidateErrors, ThrowOnError>({
      url: "/memory/invalidate",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Purge (hard delete)
   *
   * Hard-delete a memory with no history — for secrets.
   */
  public purge<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      id?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "id" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryPurgeResponses, MemoryPurgeErrors, ThrowOnError>({
      url: "/memory/purge",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Ingest a document
   *
   * Chunk a text document into searchable passages. Idempotent: re-ingesting the same document stores nothing new.
   */
  public ingest<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      text?: string
      name?: string
      scope?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "text" },
            { in: "body", key: "name" },
            { in: "body", key: "scope" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryIngestResponses, MemoryIngestErrors, ThrowOnError>({
      url: "/memory/ingest",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Clear a scope
   *
   * Delete every memory in a scope (e.g. one chat, or all global).
   */
  public clearScope<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      scope?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "scope" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<MemoryClearScopeResponses, MemoryClearScopeErrors, ThrowOnError>({
      url: "/memory/clearScope",
      ...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 NovaClaw.
   */
  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
      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: "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
      cursor?: string
      ticket?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "cursor" },
            { in: "query", key: "ticket" },
          ],
        },
      ],
    )
    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 Registry extends HeyApiClient {
  /**
   * List database tables
   *
   * Every user table in the instance database with its current row count.
   */
  public tables<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<RegistryTablesResponses, RegistryTablesErrors, ThrowOnError>({
      url: "/registry/tables",
      ...options,
      ...params,
    })
  }

  /**
   * Page table rows
   *
   * One page of a table's rows, rowid-addressed, values in their raw stored form.
   */
  public rows<ThrowOnError extends boolean = false>(
    parameters: {
      directory?: string
      workspace?: string
      table: string
      limit?: string
      offset?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "query", key: "table" },
            { in: "query", key: "limit" },
            { in: "query", key: "offset" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<RegistryRowsResponses, RegistryRowsErrors, ThrowOnError>({
      url: "/registry/rows",
      ...options,
      ...params,
    })
  }

  /**
   * Update one row
   *
   * Update the given columns of one row (by rowid). Unknown columns are rejected.
   */
  public updateRow<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      table?: string
      rowid?: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
      values?: {
        [key: string]: unknown
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "table" },
            { in: "body", key: "rowid" },
            { in: "body", key: "values" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<RegistryUpdateRowResponses, RegistryUpdateRowErrors, ThrowOnError>({
      url: "/registry/row/update",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Insert a row
   *
   * Insert a new row into a table. Constraint violations come back as a readable error.
   */
  public insertRow<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      table?: string
      values?: {
        [key: string]: unknown
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "table" },
            { in: "body", key: "values" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<RegistryInsertRowResponses, RegistryInsertRowErrors, ThrowOnError>({
      url: "/registry/row/insert",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Delete one row
   *
   * Delete one row by rowid. Foreign-key cascades apply — this is real database editing.
   */
  public deleteRow<ThrowOnError extends boolean = false>(
    parameters?: {
      directory?: string
      workspace?: string
      table?: string
      rowid?: 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: "body", key: "table" },
            { in: "body", key: "rowid" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<RegistryDeleteRowResponses, RegistryDeleteRowErrors, ThrowOnError>({
      url: "/registry/row/delete",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

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

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,
    })
  }

  /**
   * Probe a provider endpoint
   *
   * One-shot health probe: validates the provider URL, key, and (optionally) that a model is listed, in one GET /models round trip. Reports the server's honored context window where available.
   */
  public probe<ThrowOnError extends boolean = false>(
    parameters: {
      providerID: string
      directory?: string
      workspace?: string
      modelID?: string
      baseURL?: string
      apiKey?: string
      authStyle?: "bearer" | "anthropic"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "providerID" },
            { in: "query", key: "directory" },
            { in: "query", key: "workspace" },
            { in: "body", key: "modelID" },
            { in: "body", key: "baseURL" },
            { in: "body", key: "apiKey" },
            { in: "body", key: "authStyle" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<ProviderProbeResponses, ProviderProbeErrors, ThrowOnError>({
      url: "/provider/{providerID}/probe",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List provider import presets
   *
   * The effective provider-import preset catalog: built-in defaults merged field-wise with the `provider_presets` config key, so endpoint fixes applied at runtime (self-healing) are always reflected.
   */
  public presets<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<ProviderPresetsResponses, ProviderPresetsErrors, ThrowOnError>({
      url: "/provider/presets",
      ...options,
      ...params,
    })
  }

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

export class Shell extends HeyApiClient {
  /**
   * Shell substrate status
   *
   * Which bash/git the agents get (bundled PortableGit, system, or platform fallback) and whether the bundle is provisioned.
   */
  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<ShellStatusResponses, ShellStatusErrors, ThrowOnError>({
      url: "/shell/status",
      ...options,
      ...params,
    })
  }

  /**
   * Offline layer status
   *
   * The airgap posture: how many of the 9 offline layers are active, with per-layer detail (OFF-C).
   */
  public offline<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<ShellOfflineResponses, ShellOfflineErrors, ThrowOnError>({
      url: "/shell/offline",
      ...options,
      ...params,
    })
  }

  /**
   * Provision the bundled shell
   *
   * Download + verify + extract the pinned PortableGit bundle (bash + git) into the data dir. Windows-only; fails closed in offline mode (provision before going airgapped).
   */
  public provision<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<ShellProvisionResponses, ShellProvisionErrors, ThrowOnError>({
      url: "/shell/provision",
      ...options,
      ...params,
    })
  }
}

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 Health extends HeyApiClient {
  /**
   * Check server health
   *
   * Check whether the API server is ready to accept requests.
   */
  public get<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<V2HealthGetResponses, V2HealthGetErrors, ThrowOnError>({
      url: "/api/health",
      ...options,
    })
  }
}

export class Location extends HeyApiClient {
  /**
   * Get location
   *
   * Resolve the requested location or the server default location.
   */
  public get<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<V2LocationGetResponses, V2LocationGetErrors, ThrowOnError>({
      url: "/api/location",
      ...options,
      ...params,
    })
  }
}

export class Agent extends HeyApiClient {
  /**
   * List agents
   *
   * Retrieve currently registered agents.
   */
  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<V2AgentListResponses, V2AgentListErrors, ThrowOnError>({
      url: "/api/agent",
      ...options,
      ...params,
    })
  }
}

export class Tags extends HeyApiClient {
  /**
   * Set session tags
   *
   * Replace the chat's tag set — tags organize chat processes; tag a root to organize its thread tree.
   */
  public set<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      tags?: Array<string>
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "tags" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<V2SessionTagsSetResponses, V2SessionTagsSetErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/tags",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List all session tags
   *
   * The instance-wide tag map: session id → tags. The client store's bootstrap source.
   */
  public all<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<V2SessionTagsAllResponses, V2SessionTagsAllErrors, ThrowOnError>({
      url: "/api/tag",
      ...options,
    })
  }
}

export class Revert extends HeyApiClient {
  /**
   * Stage session revert
   *
   * Stage or move a reversible session boundary and optionally apply its file changes.
   */
  public stage<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID?: string
      files?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "messageID" },
            { in: "body", key: "files" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionRevertStageResponses,
      V2SessionRevertStageErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/revert/stage",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Clear staged revert
   */
  public clear<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).post<
      V2SessionRevertClearResponses,
      V2SessionRevertClearErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/revert/clear",
      ...options,
      ...params,
    })
  }

  /**
   * Commit staged revert
   */
  public commit<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).post<
      V2SessionRevertCommitResponses,
      V2SessionRevertCommitErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/revert/commit",
      ...options,
      ...params,
    })
  }
}

export class Permission2 extends HeyApiClient {
  /**
   * List session permission requests
   *
   * Retrieve pending permission requests owned by a session.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).get<
      V2SessionPermissionListResponses,
      V2SessionPermissionListErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/permission",
      ...options,
      ...params,
    })
  }

  /**
   * Create permission request
   *
   * Evaluate and, when approval is required, create a permission request for a session.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      id?: string
      action?: string
      resources?: Array<string>
      save?: Array<string>
      metadata?: {
        [key: string]: unknown
      }
      source?: PermissionV2Source
      agent?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "id" },
            { in: "body", key: "action" },
            { in: "body", key: "resources" },
            { in: "body", key: "save" },
            { in: "body", key: "metadata" },
            { in: "body", key: "source" },
            { in: "body", key: "agent" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionPermissionCreateResponses,
      V2SessionPermissionCreateErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/permission",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Get permission request
   *
   * Retrieve a pending permission request owned by a session.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      requestID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "requestID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      V2SessionPermissionGetResponses,
      V2SessionPermissionGetErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/permission/{requestID}",
      ...options,
      ...params,
    })
  }

  /**
   * Reply to pending permission request
   *
   * Respond to a pending permission request owned by a session.
   */
  public reply<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      requestID: string
      reply?: PermissionV2Reply
      message?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "requestID" },
            { in: "body", key: "reply" },
            { in: "body", key: "message" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionPermissionReplyResponses,
      V2SessionPermissionReplyErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/permission/{requestID}/reply",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Question2 extends HeyApiClient {
  /**
   * List session question requests
   *
   * Retrieve pending question requests owned by a session.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).get<
      V2SessionQuestionListResponses,
      V2SessionQuestionListErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/question",
      ...options,
      ...params,
    })
  }

  /**
   * Reply to pending question request
   *
   * Answer a pending question request owned by a session.
   */
  public reply<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      requestID: string
      questionV2Reply: QuestionV2Reply
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "requestID" },
            { key: "questionV2Reply", map: "body" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionQuestionReplyResponses,
      V2SessionQuestionReplyErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/question/{requestID}/reply",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Reject pending question request
   *
   * Reject a pending question request owned by a session.
   */
  public reject<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      requestID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "requestID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionQuestionRejectResponses,
      V2SessionQuestionRejectErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/question/{requestID}/reject",
      ...options,
      ...params,
    })
  }
}

export class Session2 extends HeyApiClient {
  /**
   * List 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?: {
      workspace?: string
      roots?: boolean | "true" | "false"
      limit?: number
      order?: "asc" | "desc"
      search?: string
      directory?: string
      under?: string
      cursor?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "workspace" },
            { in: "query", key: "roots" },
            { in: "query", key: "limit" },
            { in: "query", key: "order" },
            { in: "query", key: "search" },
            { in: "query", key: "directory" },
            { in: "query", key: "under" },
            { in: "query", key: "cursor" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionListResponses, V2SessionListErrors, ThrowOnError>({
      url: "/api/session",
      ...options,
      ...params,
    })
  }

  /**
   * Create session
   *
   * Create a session at the requested location.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      id?: string
      parentID?: string
      agent?: string
      model?: ModelRef
      systemPromptOverride?: string
      type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
      priority?: number
      permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
      location?: LocationRef
      title?: string
      permission?: PermissionRuleset
      strict?: SessionStrictOverride
      introspection?: boolean
      quality?: boolean
      affective?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "body", key: "id" },
            { in: "body", key: "parentID" },
            { in: "body", key: "agent" },
            { in: "body", key: "model" },
            { in: "body", key: "systemPromptOverride" },
            { in: "body", key: "type" },
            { in: "body", key: "priority" },
            { in: "body", key: "permissionMode" },
            { in: "body", key: "location" },
            { in: "body", key: "title" },
            { in: "body", key: "permission" },
            { in: "body", key: "strict" },
            { in: "body", key: "introspection" },
            { in: "body", key: "quality" },
            { in: "body", key: "affective" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionCreateResponses, V2SessionCreateErrors, ThrowOnError>({
      url: "/api/session",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List active sessions
   *
   * Retrieve foreground Session drains currently owned by this NovaClaw process. Sessions absent from the result are inactive.
   */
  public active<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<V2SessionActiveResponses, V2SessionActiveErrors, ThrowOnError>({
      url: "/api/session/active",
      ...options,
    })
  }

  /**
   * Delete session
   *
   * Permanently delete a session and its descendants (messages, todos, tags cascade).
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).delete<V2SessionRemoveResponses, V2SessionRemoveErrors, ThrowOnError>({
      url: "/api/session/{sessionID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get session
   *
   * Retrieve a session by ID.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).get<V2SessionGetResponses, V2SessionGetErrors, ThrowOnError>({
      url: "/api/session/{sessionID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update session
   *
   * Rename a session and/or replace its metadata; returns the updated record.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      title?: string
      metadata?: {
        [key: string]: unknown
      }
      archived?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "title" },
            { in: "body", key: "metadata" },
            { in: "body", key: "archived" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<V2SessionUpdateResponses, V2SessionUpdateErrors, ThrowOnError>({
      url: "/api/session/{sessionID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List child sessions
   *
   * Retrieve the sessions forked or spawned from the given parent session.
   */
  public children<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).get<V2SessionChildrenResponses, V2SessionChildrenErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/children",
      ...options,
      ...params,
    })
  }

  /**
   * Fork session
   *
   * Clone a session's transcript into a fresh session, optionally truncated at (and excluding) a message.
   */
  public fork<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionForkResponses, V2SessionForkErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/fork",
      ...options,
      ...params,
    })
  }

  /**
   * Get session todos
   *
   * Retrieve the todo list the session's agent maintains.
   */
  public todo<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).get<V2SessionTodoResponses, V2SessionTodoErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/todo",
      ...options,
      ...params,
    })
  }

  /**
   * Switch session agent
   *
   * Switch the agent used by subsequent provider turns.
   */
  public switchAgent<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      agent?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "agent" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchAgentResponses,
      V2SessionSwitchAgentErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/agent",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Switch session model
   *
   * Switch the model used by subsequent provider turns.
   */
  public switchModel<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      model?: ModelRef
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "model" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchModelResponses,
      V2SessionSwitchModelErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/model",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Switch session responder (B10 handoff)
   *
   * Take control (operator) so Nova stops auto-responding, or hand back (nova) so it resumes and drains queued input.
   */
  public switchResponder<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      responder?: "nova" | "operator"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "responder" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchResponderResponses,
      V2SessionSwitchResponderErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/responder",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Switch session permission mode (1K)
   *
   * Change the permission mode mid-session; the MODE_RULES overlay applies from the next turn.
   */
  public switchMode<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "permissionMode" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionSwitchModeResponses, V2SessionSwitchModeErrors, ThrowOnError>(
      {
        url: "/api/session/{sessionID}/mode",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }

  /**
   * Set the session's Strict-harness override (jh.md)
   *
   * Enable/disable Strict mode for this session and set its racing attempts + time budget; null clears the override back to inherit (parent chain, then global config). Applies from the next turn.
   */
  public switchStrict<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      strict?: SessionStrictOverride
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "strict" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchStrictResponses,
      V2SessionSwitchStrictErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/strict",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Set a per-session harness-feature override (introspection · quality · affective)
   *
   * Enable/disable one harness feature for this session; null clears the override back to inherit (parent chain, then global config). Applies from the next turn.
   */
  public switchFeature<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      feature?: "introspection" | "quality" | "affective"
      enabled?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "feature" },
            { in: "body", key: "enabled" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchFeatureResponses,
      V2SessionSwitchFeatureErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/feature",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Set the session's kernel thread type (Mode)
   *
   * Switch this chat between interactive and the unattended types (auto-prompting · goal-oriented). Attendance derives from the chain root's type: an unattended chat auto-allows permission asks and runs shell commands confined by the Agent Jail. Applies immediately.
   */
  public switchType<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      type?: "interactive" | "auto-prompting" | "goal-oriented"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "type" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionSwitchTypeResponses, V2SessionSwitchTypeErrors, ThrowOnError>(
      {
        url: "/api/session/{sessionID}/type",
        ...options,
        ...params,
        headers: {
          "Content-Type": "application/json",
          ...options?.headers,
          ...params.headers,
        },
      },
    )
  }

  /**
   * Set the session's system-prompt override layer
   *
   * Replace this session's system-prompt override (composed after the persona baseline, before the agent prompt); null clears it. Children and forks inherit through the config walk. Applies from the next turn.
   */
  public switchPromptOverride<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      override?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "override" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2SessionSwitchPromptOverrideResponses,
      V2SessionSwitchPromptOverrideErrors,
      ThrowOnError
    >({
      url: "/api/session/{sessionID}/prompt-override",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Run a shell command
   *
   * Run one shell command to completion against the session's location; the transcript renders from the durable shell events (no model turn).
   */
  public shell<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      command?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "command" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionShellResponses, V2SessionShellErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/shell",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Run a slash command
   *
   * Expand and dispatch a slash command: a prompt-kind command runs a turn on this session; a subtask command spawns a child session (surfaced via session events).
   */
  public command<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      command?: string
      arguments?: string
      agent?: string
      model?: string
      variant?: string
      messageID?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "command" },
            { in: "body", key: "arguments" },
            { in: "body", key: "agent" },
            { in: "body", key: "model" },
            { in: "body", key: "variant" },
            { in: "body", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<V2SessionCommandResponses, V2SessionCommandErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/command",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Send message
   *
   * Durably admit one session input and schedule agent-loop execution unless resume is false.
   */
  public prompt<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      id?: string
      prompt?: PromptInput
      delivery?: "steer" | "queue"
      resume?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "body", key: "id" },
            { in: "body", key: "prompt" },
            { in: "body", key: "delivery" },
            { in: "body", key: "resume" },
          ],
        },
      ],
    )
    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 session
   *
   * Compact a session conversation.
   */
  public compact<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).post<V2SessionCompactResponses, V2SessionCompactErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/compact",
      ...options,
      ...params,
    })
  }

  /**
   * Wait for session
   *
   * Block until the session completes via exit() (its result is recorded). Times out after ~2 minutes with 503 — re-call to continue waiting.
   */
  public wait<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).post<V2SessionWaitResponses, V2SessionWaitErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/wait",
      ...options,
      ...params,
    })
  }

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

  /**
   * Get session history
   *
   * Read one finite page of public durable Session events after an exclusive aggregate sequence. Newly committed events may appear on later pages.
   */
  public history<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      limit?: number
      after?: number
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "limit" },
            { in: "query", key: "after" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionHistoryResponses, V2SessionHistoryErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/history",
      ...options,
      ...params,
    })
  }

  /**
   * Subscribe to session events
   *
   * Replay durable events after an aggregate sequence, then continue with new durable events.
   */
  public events<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      after?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "query", key: "after" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).sse.get<V2SessionEventsResponses, V2SessionEventsErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/event",
      ...options,
      ...params,
    })
  }

  /**
   * Interrupt session execution
   *
   * Interrupt active execution owned by this NovaClaw process. Idle interruption is a no-op.
   */
  public interrupt<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
    return (options?.client ?? this.client).post<V2SessionInterruptResponses, V2SessionInterruptErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/interrupt",
      ...options,
      ...params,
    })
  }

  /**
   * Get session message
   *
   * Retrieve one projected message owned by the Session.
   */
  public message<ThrowOnError extends boolean = false>(
    parameters: {
      sessionID: string
      messageID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { in: "path", key: "messageID" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2SessionMessageResponses, V2SessionMessageErrors, ThrowOnError>({
      url: "/api/session/{sessionID}/message/{messageID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get session messages
   *
   * Retrieve projected 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
      limit?: number
      order?: "asc" | "desc"
      cursor?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "sessionID" },
            { 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,
    })
  }

  private _tags?: Tags
  get tags(): Tags {
    return (this._tags ??= new Tags({ client: this.client }))
  }

  private _revert?: Revert
  get revert(): Revert {
    return (this._revert ??= new Revert({ client: this.client }))
  }

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

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

export class Model extends HeyApiClient {
  /**
   * List models
   *
   * Retrieve available 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 providers
   *
   * Retrieve active 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,
    })
  }

  /**
   * Remove provider
   *
   * Delete a config-defined provider from the instance catalog store (T10iv: a true key delete, not a disable-list hide). Takes effect fully on the next serve boot.
   */
  public remove<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).delete<V2ProviderRemoveResponses, V2ProviderRemoveErrors, ThrowOnError>({
      url: "/api/provider/{providerID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get provider
   *
   * Retrieve a single 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 Connect extends HeyApiClient {
  /**
   * Connect with key
   *
   * Run a key authentication method and store the resulting credential.
   */
  public key<ThrowOnError extends boolean = false>(
    parameters: {
      integrationID: string
      location?: {
        directory?: string
        workspace?: string
      }
      key?: string
      label?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "integrationID" },
            { in: "query", key: "location" },
            { in: "body", key: "key" },
            { in: "body", key: "label" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2IntegrationConnectKeyResponses,
      V2IntegrationConnectKeyErrors,
      ThrowOnError
    >({
      url: "/api/integration/{integrationID}/connect/key",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Begin OAuth connection
   *
   * Start an OAuth attempt and return the authorization details.
   */
  public oauth<ThrowOnError extends boolean = false>(
    parameters: {
      integrationID: string
      location?: {
        directory?: string
        workspace?: string
      }
      methodID?: string
      inputs?: {
        [key: string]: string
      }
      label?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "integrationID" },
            { in: "query", key: "location" },
            { in: "body", key: "methodID" },
            { in: "body", key: "inputs" },
            { in: "body", key: "label" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2IntegrationConnectOauthResponses,
      V2IntegrationConnectOauthErrors,
      ThrowOnError
    >({
      url: "/api/integration/{integrationID}/connect/oauth",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Attempt extends HeyApiClient {
  /**
   * Cancel OAuth connection
   *
   * Cancel an OAuth attempt and release its resources.
   */
  public cancel<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "attemptID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<
      V2IntegrationAttemptCancelResponses,
      V2IntegrationAttemptCancelErrors,
      ThrowOnError
    >({
      url: "/api/integration/attempt/{attemptID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get OAuth attempt status
   *
   * Poll the current status of an OAuth attempt.
   */
  public status<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "attemptID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<
      V2IntegrationAttemptStatusResponses,
      V2IntegrationAttemptStatusErrors,
      ThrowOnError
    >({
      url: "/api/integration/attempt/{attemptID}",
      ...options,
      ...params,
    })
  }

  /**
   * Complete OAuth connection
   *
   * Complete a code-based OAuth attempt and store the resulting credential.
   */
  public complete<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
      location?: {
        directory?: string
        workspace?: string
      }
      code?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "attemptID" },
            { in: "query", key: "location" },
            { in: "body", key: "code" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2IntegrationAttemptCompleteResponses,
      V2IntegrationAttemptCompleteErrors,
      ThrowOnError
    >({
      url: "/api/integration/attempt/{attemptID}/complete",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Integration extends HeyApiClient {
  /**
   * List integrations
   *
   * Retrieve available integrations and their authentication methods.
   */
  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<V2IntegrationListResponses, V2IntegrationListErrors, ThrowOnError>({
      url: "/api/integration",
      ...options,
      ...params,
    })
  }

  /**
   * Get integration
   *
   * Retrieve one integration and its authentication methods.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      integrationID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "integrationID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2IntegrationGetResponses, V2IntegrationGetErrors, ThrowOnError>({
      url: "/api/integration/{integrationID}",
      ...options,
      ...params,
    })
  }

  private _connect?: Connect
  get connect(): Connect {
    return (this._connect ??= new Connect({ client: this.client }))
  }

  private _attempt?: Attempt
  get attempt(): Attempt {
    return (this._attempt ??= new Attempt({ client: this.client }))
  }
}

export class Credential extends HeyApiClient {
  /**
   * Remove credential
   *
   * Remove a stored integration credential.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      credentialID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "credentialID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<V2CredentialRemoveResponses, V2CredentialRemoveErrors, ThrowOnError>(
      {
        url: "/api/credential/{credentialID}",
        ...options,
        ...params,
      },
    )
  }

  /**
   * Update credential
   *
   * Update a stored credential label.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      credentialID: string
      location?: {
        directory?: string
        workspace?: string
      }
      label?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "credentialID" },
            { in: "query", key: "location" },
            { in: "body", key: "label" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<V2CredentialUpdateResponses, V2CredentialUpdateErrors, ThrowOnError>({
      url: "/api/credential/{credentialID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Driver extends HeyApiClient {
  /**
   * List messenger drivers
   *
   * Retrieve the installed messenger platform drivers and their capabilities.
   */
  public list<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<
      V2MessengerDriverListResponses,
      V2MessengerDriverListErrors,
      ThrowOnError
    >({ url: "/api/messenger/driver", ...options })
  }
}

export class Account extends HeyApiClient {
  /**
   * List messenger accounts
   *
   * Retrieve every configured messenger account with its live connection status.
   */
  public list<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<
      V2MessengerAccountListResponses,
      V2MessengerAccountListErrors,
      ThrowOnError
    >({ url: "/api/messenger/account", ...options })
  }

  /**
   * Create messenger account
   *
   * Configure a messenger account for an installed driver. The optional secret (bot token, API key) is stored in the credential store and never returned.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      driverID?: string
      label?: string
      enabled?: boolean
      settings?: {
        [key: string]: string
      }
      secret?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "body", key: "driverID" },
            { in: "body", key: "label" },
            { in: "body", key: "enabled" },
            { in: "body", key: "settings" },
            { in: "body", key: "secret" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2MessengerAccountCreateResponses,
      V2MessengerAccountCreateErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Remove messenger account
   *
   * Remove a messenger account, its stored credential, seen chats, contacts, bindings, and cursor.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      accountID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "accountID" }] }])
    return (options?.client ?? this.client).delete<
      V2MessengerAccountRemoveResponses,
      V2MessengerAccountRemoveErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account/{accountID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update messenger account
   *
   * Update a messenger account's label, enabled state, settings, or stored secret.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      accountID: string
      label?: string
      enabled?: boolean
      settings?: {
        [key: string]: string
      }
      secret?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "accountID" },
            { in: "body", key: "label" },
            { in: "body", key: "enabled" },
            { in: "body", key: "settings" },
            { in: "body", key: "secret" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).patch<
      V2MessengerAccountUpdateResponses,
      V2MessengerAccountUpdateErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account/{accountID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Mint pairing code
   *
   * Mint a single-use, 10-minute pairing code. A remote sender redeems it with /pair <code> in a DM to become a paired contact at the chosen trust.
   */
  public pair<ThrowOnError extends boolean = false>(
    parameters: {
      accountID: string
      trust?: "operator" | "client"
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "accountID" },
            { in: "body", key: "trust" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2MessengerAccountPairResponses,
      V2MessengerAccountPairErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account/{accountID}/pair",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * List an account's chats
   *
   * The account's known chats — the live driver list where the platform allows enumeration (seeding the seen-cache), else the seen-cache. `ok:false` carries a plain-words reason (not connected, nothing seen yet).
   */
  public chats<ThrowOnError extends boolean = false>(
    parameters: {
      accountID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "accountID" }] }])
    return (options?.client ?? this.client).get<
      V2MessengerAccountChatsResponses,
      V2MessengerAccountChatsErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account/{accountID}/chats",
      ...options,
      ...params,
    })
  }
}

export class Binding extends HeyApiClient {
  /**
   * List chat bindings
   *
   * Every live session↔chat binding on this instance, with the chat's human title from the seen-cache where known.
   */
  public list<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).get<
      V2MessengerBindingListResponses,
      V2MessengerBindingListErrors,
      ThrowOnError
    >({ url: "/api/messenger/binding", ...options })
  }

  /**
   * Bind a session to a chat
   *
   * Link a session to a remote chat at an explicit trust tier (operator | client | audience — always user-chosen, never inferred). One session per chat: if the chat is already bound the call fails naming the holding session; pass steal:true to rebind deliberately.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      accountID?: string
      chatID?: string
      sessionID?: string
      trust?: MessengerTrust
      steal?: boolean
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "body", key: "accountID" },
            { in: "body", key: "chatID" },
            { in: "body", key: "sessionID" },
            { in: "body", key: "trust" },
            { in: "body", key: "steal" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2MessengerBindingCreateResponses,
      V2MessengerBindingCreateErrors,
      ThrowOnError
    >({
      url: "/api/messenger/binding",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Unbind a chat
   *
   * Remove a session↔chat binding. The chat stops driving (or reporting to) the session immediately.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      bindingID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "bindingID" }] }])
    return (options?.client ?? this.client).delete<
      V2MessengerBindingRemoveResponses,
      V2MessengerBindingRemoveErrors,
      ThrowOnError
    >({
      url: "/api/messenger/binding/{bindingID}",
      ...options,
      ...params,
    })
  }
}

export class Login extends HeyApiClient {
  /**
   * Begin messenger login
   *
   * Start a login-auth attempt for an account whose driver signs into the user's own messenger account (inputs answer the driver's loginPrompts — e.g. phone and optional 2FA password). The provider sends a confirmation code; complete the attempt with it.
   */
  public begin<ThrowOnError extends boolean = false>(
    parameters: {
      accountID: string
      inputs?: {
        [key: string]: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "accountID" },
            { in: "body", key: "inputs" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2MessengerLoginBeginResponses,
      V2MessengerLoginBeginErrors,
      ThrowOnError
    >({
      url: "/api/messenger/account/{accountID}/login",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Cancel messenger login
   *
   * Abandon a pending messenger login attempt and release its resources.
   */
  public cancel<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "attemptID" }] }])
    return (options?.client ?? this.client).delete<
      V2MessengerLoginCancelResponses,
      V2MessengerLoginCancelErrors,
      ThrowOnError
    >({
      url: "/api/messenger/login/{attemptID}",
      ...options,
      ...params,
    })
  }

  /**
   * Messenger login attempt status
   *
   * Retrieve the state of a pending or recently finished messenger login attempt, including the step's CURRENT instructions and scannable image — poll this while an attempt is pending, because providers may rotate what the user must act on (WhatsApp mints a fresh linked-device QR every ~20s).
   */
  public status<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "attemptID" }] }])
    return (options?.client ?? this.client).get<
      V2MessengerLoginStatusResponses,
      V2MessengerLoginStatusErrors,
      ThrowOnError
    >({
      url: "/api/messenger/login/{attemptID}",
      ...options,
      ...params,
    })
  }

  /**
   * Complete messenger login
   *
   * Finish a login attempt with the confirmation code the provider sent. On success the session credential is stored and the account reconnects; a mistyped code keeps the attempt pending (error kind messenger_login_retry).
   */
  public complete<ThrowOnError extends boolean = false>(
    parameters: {
      attemptID: string
      code?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "attemptID" },
            { in: "body", key: "code" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).post<
      V2MessengerLoginCompleteResponses,
      V2MessengerLoginCompleteErrors,
      ThrowOnError
    >({
      url: "/api/messenger/login/{attemptID}/complete",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }
}

export class Messenger extends HeyApiClient {
  private _driver?: Driver
  get driver(): Driver {
    return (this._driver ??= new Driver({ client: this.client }))
  }

  private _account?: Account
  get account(): Account {
    return (this._account ??= new Account({ client: this.client }))
  }

  private _binding?: Binding
  get binding(): Binding {
    return (this._binding ??= new Binding({ client: this.client }))
  }

  private _login?: Login
  get login(): Login {
    return (this._login ??= new Login({ client: this.client }))
  }
}

export class Request extends HeyApiClient {
  /**
   * List pending permission requests
   *
   * Retrieve pending permission requests for a location.
   */
  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<
      V2PermissionRequestListResponses,
      V2PermissionRequestListErrors,
      ThrowOnError
    >({
      url: "/api/permission/request",
      ...options,
      ...params,
    })
  }
}

export class Saved extends HeyApiClient {
  /**
   * List saved permissions
   *
   * Retrieve saved permissions, optionally filtered by project.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      origin?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "origin" }] }])
    return (options?.client ?? this.client).get<
      V2PermissionSavedListResponses,
      V2PermissionSavedListErrors,
      ThrowOnError
    >({
      url: "/api/permission/saved",
      ...options,
      ...params,
    })
  }

  /**
   * Remove saved permission
   *
   * Remove a saved permission by ID.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      id: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "id" }] }])
    return (options?.client ?? this.client).delete<
      V2PermissionSavedRemoveResponses,
      V2PermissionSavedRemoveErrors,
      ThrowOnError
    >({
      url: "/api/permission/saved/{id}",
      ...options,
      ...params,
    })
  }
}

export class Permission3 extends HeyApiClient {
  private _request?: Request
  get request(): Request {
    return (this._request ??= new Request({ client: this.client }))
  }

  private _saved?: Saved
  get saved(): Saved {
    return (this._saved ??= new Saved({ client: this.client }))
  }
}

export class Fs extends HeyApiClient {
  /**
   * Read file
   *
   * Serve one file relative to the requested location.
   */
  public read<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<V2FsReadResponses, V2FsReadErrors, ThrowOnError>({
      url: "/api/fs/read/*",
      ...options,
      ...params,
    })
  }

  /**
   * List directory
   *
   * List direct children of one directory relative to the requested location.
   */
  public list<ThrowOnError extends boolean = false>(
    parameters?: {
      location?: {
        directory?: string
        workspace?: string
      }
      path?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "location" },
            { in: "query", key: "path" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2FsListResponses, V2FsListErrors, ThrowOnError>({
      url: "/api/fs/list",
      ...options,
      ...params,
    })
  }

  /**
   * Find files
   *
   * Find recursively ranked filesystem entries relative to the requested location.
   */
  public find<ThrowOnError extends boolean = false>(
    parameters: {
      location?: {
        directory?: string
        workspace?: string
      }
      query: string
      type?: "file" | "directory"
      limit?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "query", key: "location" },
            { in: "query", key: "query" },
            { in: "query", key: "type" },
            { in: "query", key: "limit" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2FsFindResponses, V2FsFindErrors, ThrowOnError>({
      url: "/api/fs/find",
      ...options,
      ...params,
    })
  }
}

export class Command2 extends HeyApiClient {
  /**
   * List commands
   *
   * Retrieve currently registered commands.
   */
  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<V2CommandListResponses, V2CommandListErrors, ThrowOnError>({
      url: "/api/command",
      ...options,
      ...params,
    })
  }
}

export class Skill extends HeyApiClient {
  /**
   * List skills
   *
   * Retrieve currently registered skills.
   */
  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<V2SkillListResponses, V2SkillListErrors, ThrowOnError>({
      url: "/api/skill",
      ...options,
      ...params,
    })
  }
}

export class Event2 extends HeyApiClient {
  /**
   * Subscribe to events
   *
   * Subscribe to native event payloads for the server.
   */
  public subscribe<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
    return (options?.client ?? this.client).sse.get<V2EventSubscribeResponses, V2EventSubscribeErrors, ThrowOnError>({
      url: "/api/event",
      ...options,
    })
  }
}

export class Pty2 extends HeyApiClient {
  /**
   * List PTY sessions
   *
   * List PTY sessions for a location, including exited sessions retained until removal.
   */
  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<V2PtyListResponses, V2PtyListErrors, ThrowOnError>({
      url: "/api/pty",
      ...options,
      ...params,
    })
  }

  /**
   * Create PTY session
   *
   * Create a pseudo-terminal session for a location.
   */
  public create<ThrowOnError extends boolean = false>(
    parameters?: {
      location?: {
        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: "location" },
            { 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<V2PtyCreateResponses, V2PtyCreateErrors, ThrowOnError>({
      url: "/api/pty",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

  /**
   * Remove PTY session
   *
   * Terminate and remove one PTY session.
   */
  public remove<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).delete<V2PtyRemoveResponses, V2PtyRemoveErrors, ThrowOnError>({
      url: "/api/pty/{ptyID}",
      ...options,
      ...params,
    })
  }

  /**
   * Get PTY session
   *
   * Get one PTY session, including its exit code once exited.
   */
  public get<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      location?: {
        directory?: string
        workspace?: string
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "location" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2PtyGetResponses, V2PtyGetErrors, ThrowOnError>({
      url: "/api/pty/{ptyID}",
      ...options,
      ...params,
    })
  }

  /**
   * Update PTY session
   *
   * Update the title or viewport size of one PTY session.
   */
  public update<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      location?: {
        directory?: string
        workspace?: string
      }
      title?: string
      size?: {
        rows: number
        cols: number
      }
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "location" },
            { in: "body", key: "title" },
            { in: "body", key: "size" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).put<V2PtyUpdateResponses, V2PtyUpdateErrors, ThrowOnError>({
      url: "/api/pty/{ptyID}",
      ...options,
      ...params,
      headers: {
        "Content-Type": "application/json",
        ...options?.headers,
        ...params.headers,
      },
    })
  }

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

  /**
   * Connect to PTY session
   *
   * Establish a WebSocket connection streaming PTY output and accepting terminal input.
   */
  public connect<ThrowOnError extends boolean = false>(
    parameters: {
      ptyID: string
      "location[directory]"?: string
      "location[workspace]"?: string
      cursor?: string
      ticket?: string
    },
    options?: Options<never, ThrowOnError>,
  ) {
    const params = buildClientParams(
      [parameters],
      [
        {
          args: [
            { in: "path", key: "ptyID" },
            { in: "query", key: "location[directory]" },
            { in: "query", key: "location[workspace]" },
            { in: "query", key: "cursor" },
            { in: "query", key: "ticket" },
          ],
        },
      ],
    )
    return (options?.client ?? this.client).get<V2PtyConnectResponses, V2PtyConnectErrors, ThrowOnError>({
      url: "/api/pty/{ptyID}/connect",
      ...options,
      ...params,
    })
  }
}

export class Request2 extends HeyApiClient {
  /**
   * List pending question requests
   *
   * Retrieve pending question requests for a location.
   */
  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<
      V2QuestionRequestListResponses,
      V2QuestionRequestListErrors,
      ThrowOnError
    >({
      url: "/api/question/request",
      ...options,
      ...params,
    })
  }
}

export class Question3 extends HeyApiClient {
  private _request?: Request2
  get request(): Request2 {
    return (this._request ??= new Request2({ client: this.client }))
  }
}

export class Reference extends HeyApiClient {
  /**
   * List references
   *
   * List references available in the requested location.
   */
  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<V2ReferenceListResponses, V2ReferenceListErrors, ThrowOnError>({
      url: "/api/reference",
      ...options,
      ...params,
    })
  }
}

export class V2 extends HeyApiClient {
  private _health?: Health
  get health(): Health {
    return (this._health ??= new Health({ client: this.client }))
  }

  private _location?: Location
  get location(): Location {
    return (this._location ??= new Location({ client: this.client }))
  }

  private _agent?: Agent
  get agent(): Agent {
    return (this._agent ??= new Agent({ client: this.client }))
  }

  private _session?: Session2
  get session(): Session2 {
    return (this._session ??= new Session2({ 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 }))
  }

  private _integration?: Integration
  get integration(): Integration {
    return (this._integration ??= new Integration({ client: this.client }))
  }

  private _credential?: Credential
  get credential(): Credential {
    return (this._credential ??= new Credential({ client: this.client }))
  }

  private _messenger?: Messenger
  get messenger(): Messenger {
    return (this._messenger ??= new Messenger({ client: this.client }))
  }

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

  private _fs?: Fs
  get fs(): Fs {
    return (this._fs ??= new Fs({ client: this.client }))
  }

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

  private _skill?: Skill
  get skill(): Skill {
    return (this._skill ??= new Skill({ client: this.client }))
  }

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

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

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

  private _reference?: Reference
  get reference(): Reference {
    return (this._reference ??= new Reference({ client: this.client }))
  }
}

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

  constructor(args?: { client?: Client; key?: string }) {
    super(args)
    NovaclawClient.__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 _experimental?: Experimental
  get experimental(): Experimental {
    return (this._experimental ??= new Experimental({ 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 _adhoc?: Adhoc
  get adhoc(): Adhoc {
    return (this._adhoc ??= new Adhoc({ client: this.client }))
  }

  private _config?: Config2
  get config(): Config2 {
    return (this._config ??= new Config2({ 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 _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 _memory?: Memory
  get memory(): Memory {
    return (this._memory ??= new Memory({ 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 _registry?: Registry
  get registry(): Registry {
    return (this._registry ??= new Registry({ 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 _shell?: Shell
  get shell(): Shell {
    return (this._shell ??= new Shell({ 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 }))
  }
}
