import type { NovaClawEventEncoded } from "@novaclaw/protocol/groups/event"

export type JsonValue =
  | null
  | boolean
  | number
  | string
  | ReadonlyArray<JsonValue>
  | { readonly [key: string]: JsonValue }

export type UnauthorizedError = { readonly _tag: "UnauthorizedError"; readonly message: string }
export const isUnauthorizedError = (value: unknown): value is UnauthorizedError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "UnauthorizedError"

export type InvalidRequestError = {
  readonly _tag: "InvalidRequestError"
  readonly message: string
  readonly kind?: string | undefined
  readonly field?: string | undefined
}
export const isInvalidRequestError = (value: unknown): value is InvalidRequestError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidRequestError"

export type InvalidCursorError = { readonly _tag: "InvalidCursorError"; readonly message: string }
export const isInvalidCursorError = (value: unknown): value is InvalidCursorError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidCursorError"

export type SessionNotFoundError = {
  readonly _tag: "SessionNotFoundError"
  readonly sessionID: string
  readonly message: string
}
export const isSessionNotFoundError = (value: unknown): value is SessionNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "SessionNotFoundError"

export type MessageNotFoundError = {
  readonly _tag: "MessageNotFoundError"
  readonly sessionID: string
  readonly messageID: string
  readonly message: string
}
export const isMessageNotFoundError = (value: unknown): value is MessageNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "MessageNotFoundError"

export type ConflictError = {
  readonly _tag: "ConflictError"
  readonly message: string
  readonly resource?: string | undefined
}
export const isConflictError = (value: unknown): value is ConflictError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ConflictError"

export type ServiceUnavailableError = {
  readonly _tag: "ServiceUnavailableError"
  readonly message: string
  readonly service?: string | undefined
}
export const isServiceUnavailableError = (value: unknown): value is ServiceUnavailableError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ServiceUnavailableError"

export type UnknownError = {
  readonly _tag: "UnknownError"
  readonly message: string
  readonly ref?: string | undefined
}
export const isUnknownError = (value: unknown): value is UnknownError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "UnknownError"

export type ProviderNotFoundError = {
  readonly _tag: "ProviderNotFoundError"
  readonly providerID: string
  readonly message: string
}
export const isProviderNotFoundError = (value: unknown): value is ProviderNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ProviderNotFoundError"

export type PermissionNotFoundError = {
  readonly _tag: "PermissionNotFoundError"
  readonly requestID: string
  readonly message: string
}
export const isPermissionNotFoundError = (value: unknown): value is PermissionNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "PermissionNotFoundError"

export type PtyNotFoundError = { readonly _tag: "PtyNotFoundError"; readonly ptyID: string; readonly message: string }
export const isPtyNotFoundError = (value: unknown): value is PtyNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "PtyNotFoundError"

export type QuestionNotFoundError = {
  readonly _tag: "QuestionNotFoundError"
  readonly requestID: string
  readonly message: string
}
export const isQuestionNotFoundError = (value: unknown): value is QuestionNotFoundError =>
  typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "QuestionNotFoundError"

export type HealthGetOutput = { readonly healthy: true }

export type LocationGetInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

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

export type AgentsListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type AgentsListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly request: {
      readonly headers: { readonly [x: string]: string }
      readonly body: { readonly [x: string]: JsonValue }
    }
    readonly system?: string
    readonly description?: string
    readonly mode: "subagent" | "primary" | "all"
    readonly hidden: boolean
    readonly color?: string | "primary" | "secondary" | "accent" | "success" | "warning" | "error" | "info"
    readonly steps?: number
    readonly permissions: ReadonlyArray<{
      readonly action: string
      readonly resource: string
      readonly effect: "allow" | "deny" | "ask"
    }>
  }>
}

export type SessionsListInput = {
  readonly workspace?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["workspace"]
  readonly roots?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["roots"]
  readonly limit?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["limit"]
  readonly order?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["order"]
  readonly search?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["search"]
  readonly directory?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["directory"]
  readonly under?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["under"]
  readonly cursor?: {
    readonly workspace?: string | undefined
    readonly roots?: boolean | undefined
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly search?: string | undefined
    readonly directory?: string | undefined
    readonly under?: string | undefined
    readonly cursor?: string | undefined
  }["cursor"]
}

export type SessionsListOutput = {
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }>
  readonly cursor: { readonly previous?: string | null; readonly next?: string | null }
}

export type SessionsCreateInput = {
  readonly id?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["id"]
  readonly parentID?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["parentID"]
  readonly agent?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["agent"]
  readonly model?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["model"]
  readonly systemPromptOverride?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["systemPromptOverride"]
  readonly type?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["type"]
  readonly priority?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["priority"]
  readonly permissionMode?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["permissionMode"]
  readonly location?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["location"]
  readonly title?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["title"]
  readonly permission?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["permission"]
  readonly strict?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["strict"]
  readonly introspection?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["introspection"]
  readonly quality?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["quality"]
  readonly affective?: {
    readonly id?: string | null
    readonly parentID?: string | null
    readonly agent?: string | null
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
    readonly systemPromptOverride?: string | null
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented" | null
    readonly priority?: number | null
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo" | null
    readonly location?: { readonly directory: string; readonly workspaceID?: string } | null
    readonly title?: string | null
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }> | null
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
    readonly introspection?: boolean | null
    readonly quality?: boolean | null
    readonly affective?: boolean | null
  }["affective"]
}

export type SessionsCreateOutput = {
  readonly data: {
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }
}["data"]

export type SessionsSetInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly tags: { readonly tags: ReadonlyArray<string> }["tags"]
}

export type SessionsSetOutput = void

export type SessionsAllOutput = { readonly data: { readonly [x: string]: ReadonlyArray<string> } }["data"]

export type SessionsActiveOutput = { readonly data: { readonly [x: string]: { readonly type: "running" } } }["data"]

export type SessionsGetInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsGetOutput = {
  readonly data: {
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }
}["data"]

export type SessionsChildrenInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsChildrenOutput = {
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }>
}["data"]

export type SessionsUpdateInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly title?: {
    readonly title?: string | undefined
    readonly metadata?: { readonly [x: string]: unknown } | undefined
    readonly archived?: number | null | undefined
  }["title"]
  readonly metadata?: {
    readonly title?: string | undefined
    readonly metadata?: { readonly [x: string]: unknown } | undefined
    readonly archived?: number | null | undefined
  }["metadata"]
  readonly archived?: {
    readonly title?: string | undefined
    readonly metadata?: { readonly [x: string]: unknown } | undefined
    readonly archived?: number | null | undefined
  }["archived"]
}

export type SessionsUpdateOutput = {
  readonly data: {
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }
}["data"]

export type SessionsRemoveInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsRemoveOutput = void

export type SessionsForkInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly messageID?: { readonly messageID?: string | undefined }["messageID"]
}

export type SessionsForkOutput = {
  readonly data: {
    readonly id: string
    readonly parentID?: string
    readonly slug: string
    readonly version: string
    readonly permission?: ReadonlyArray<{
      readonly permission: string
      readonly pattern: string
      readonly action: "allow" | "deny" | "ask"
    }>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly systemPromptOverride?: string
    readonly type?: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
    readonly priority?: number
    readonly responder?: "nova" | "operator"
    readonly permissionMode?: "plan" | "ask" | "surgical" | "bypass" | "yolo"
    readonly strict?: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number }
    readonly introspection?: boolean
    readonly quality?: boolean
    readonly affective?: boolean
    readonly result?: JsonValue
    readonly cost: number
    readonly tokens: {
      readonly input: number
      readonly output: number
      readonly reasoning: number
      readonly cache: { readonly read: number; readonly write: number }
    }
    readonly time: { readonly created: number; readonly updated: number; readonly archived?: number }
    readonly title: string
    readonly location: { readonly directory: string; readonly workspaceID?: string }
    readonly subpath?: string
    readonly revert?: {
      readonly messageID: string
      readonly partID?: string
      readonly snapshot?: string
      readonly diff?: string
      readonly files?: ReadonlyArray<{
        readonly path: string
        readonly status: "added" | "modified" | "deleted"
        readonly additions: number
        readonly deletions: number
        readonly patch: string
      }>
    }
    readonly summary?: {
      readonly additions: number
      readonly deletions: number
      readonly files: number
      readonly diffs?: ReadonlyArray<{
        readonly file?: string
        readonly patch?: string
        readonly additions: number
        readonly deletions: number
        readonly status?: "added" | "deleted" | "modified"
      }>
    }
  }
}["data"]

export type SessionsTodoInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsTodoOutput = {
  readonly data: ReadonlyArray<{ readonly content: string; readonly status: string; readonly priority: string }>
}["data"]

export type SessionsSwitchAgentInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly agent: { readonly agent: string }["agent"]
}

export type SessionsSwitchAgentOutput = void

export type SessionsSwitchModelInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly model: {
    readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
  }["model"]
}

export type SessionsSwitchModelOutput = void

export type SessionsSwitchResponderInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly responder: { readonly responder: "nova" | "operator" }["responder"]
}

export type SessionsSwitchResponderOutput = void

export type SessionsSwitchModeInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly permissionMode: {
    readonly permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
  }["permissionMode"]
}

export type SessionsSwitchModeOutput = void

export type SessionsSwitchStrictInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly strict: {
    readonly strict: { readonly enabled?: boolean; readonly attempts?: number; readonly wallMinutes?: number } | null
  }["strict"]
}

export type SessionsSwitchStrictOutput = void

export type SessionsSwitchFeatureInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly feature: {
    readonly feature: "introspection" | "quality" | "affective"
    readonly enabled: boolean | null
  }["feature"]
  readonly enabled: {
    readonly feature: "introspection" | "quality" | "affective"
    readonly enabled: boolean | null
  }["enabled"]
}

export type SessionsSwitchFeatureOutput = void

export type SessionsSwitchTypeInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly type: { readonly type: "interactive" | "auto-prompting" | "goal-oriented" }["type"]
}

export type SessionsSwitchTypeOutput = void

export type SessionsSwitchPromptOverrideInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly override: { readonly override: string | null }["override"]
}

export type SessionsSwitchPromptOverrideOutput = void

export type SessionsShellInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly command: { readonly command: string }["command"]
}

export type SessionsShellOutput = void

export type SessionsCommandInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly command: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["command"]
  readonly arguments: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["arguments"]
  readonly agent?: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["agent"]
  readonly model?: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["model"]
  readonly variant?: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["variant"]
  readonly messageID?: {
    readonly command: string
    readonly arguments: string
    readonly agent?: string | undefined
    readonly model?: string | undefined
    readonly variant?: string | undefined
    readonly messageID?: string | undefined
  }["messageID"]
}

export type SessionsCommandOutput = void

export type SessionsPromptInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly id?: {
    readonly id?: string | null
    readonly prompt: {
      readonly text: string
      readonly files?: ReadonlyArray<{
        readonly uri: string
        readonly name?: string
        readonly description?: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly agents?: ReadonlyArray<{
        readonly name: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly origin?:
        | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
        | {
            readonly via: "messenger"
            readonly driver: string
            readonly accountID: string
            readonly chatID: string
            readonly chatKind?: string
            readonly chatTitle?: string
            readonly senderID: string
            readonly senderName: string
            readonly messageID: string
            readonly replyTo?: string
            readonly trust: "operator" | "client" | "audience"
            readonly at?: number
          }
    }
    readonly delivery?: "steer" | "queue" | null
    readonly resume?: boolean | null
  }["id"]
  readonly prompt: {
    readonly id?: string | null
    readonly prompt: {
      readonly text: string
      readonly files?: ReadonlyArray<{
        readonly uri: string
        readonly name?: string
        readonly description?: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly agents?: ReadonlyArray<{
        readonly name: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly origin?:
        | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
        | {
            readonly via: "messenger"
            readonly driver: string
            readonly accountID: string
            readonly chatID: string
            readonly chatKind?: string
            readonly chatTitle?: string
            readonly senderID: string
            readonly senderName: string
            readonly messageID: string
            readonly replyTo?: string
            readonly trust: "operator" | "client" | "audience"
            readonly at?: number
          }
    }
    readonly delivery?: "steer" | "queue" | null
    readonly resume?: boolean | null
  }["prompt"]
  readonly delivery?: {
    readonly id?: string | null
    readonly prompt: {
      readonly text: string
      readonly files?: ReadonlyArray<{
        readonly uri: string
        readonly name?: string
        readonly description?: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly agents?: ReadonlyArray<{
        readonly name: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly origin?:
        | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
        | {
            readonly via: "messenger"
            readonly driver: string
            readonly accountID: string
            readonly chatID: string
            readonly chatKind?: string
            readonly chatTitle?: string
            readonly senderID: string
            readonly senderName: string
            readonly messageID: string
            readonly replyTo?: string
            readonly trust: "operator" | "client" | "audience"
            readonly at?: number
          }
    }
    readonly delivery?: "steer" | "queue" | null
    readonly resume?: boolean | null
  }["delivery"]
  readonly resume?: {
    readonly id?: string | null
    readonly prompt: {
      readonly text: string
      readonly files?: ReadonlyArray<{
        readonly uri: string
        readonly name?: string
        readonly description?: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly agents?: ReadonlyArray<{
        readonly name: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly origin?:
        | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
        | {
            readonly via: "messenger"
            readonly driver: string
            readonly accountID: string
            readonly chatID: string
            readonly chatKind?: string
            readonly chatTitle?: string
            readonly senderID: string
            readonly senderName: string
            readonly messageID: string
            readonly replyTo?: string
            readonly trust: "operator" | "client" | "audience"
            readonly at?: number
          }
    }
    readonly delivery?: "steer" | "queue" | null
    readonly resume?: boolean | null
  }["resume"]
}

export type SessionsPromptOutput = {
  readonly data: {
    readonly admittedSeq: number
    readonly id: string
    readonly sessionID: string
    readonly prompt: {
      readonly text: string
      readonly files?: ReadonlyArray<{
        readonly uri: string
        readonly mime: string
        readonly name?: string
        readonly description?: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly agents?: ReadonlyArray<{
        readonly name: string
        readonly source?: { readonly start: number; readonly end: number; readonly text: string }
      }>
      readonly origin?:
        | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
        | {
            readonly via: "messenger"
            readonly driver: string
            readonly accountID: string
            readonly chatID: string
            readonly chatKind?: string
            readonly chatTitle?: string
            readonly senderID: string
            readonly senderName: string
            readonly messageID: string
            readonly replyTo?: string
            readonly trust: "operator" | "client" | "audience"
            readonly at?: number
          }
    }
    readonly delivery: "steer" | "queue"
    readonly timeCreated: number
    readonly promotedSeq?: number
  }
}["data"]

export type SessionsCompactInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsCompactOutput = void

export type SessionsWaitInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsWaitOutput = void

export type SessionsStageInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly messageID: { readonly messageID: string; readonly files?: boolean | undefined }["messageID"]
  readonly files?: { readonly messageID: string; readonly files?: boolean | undefined }["files"]
}

export type SessionsStageOutput = {
  readonly data: {
    readonly messageID: string
    readonly partID?: string
    readonly snapshot?: string
    readonly diff?: string
    readonly files?: ReadonlyArray<{
      readonly path: string
      readonly status: "added" | "modified" | "deleted"
      readonly additions: number
      readonly deletions: number
      readonly patch: string
    }>
  }
}["data"]

export type SessionsClearInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsClearOutput = void

export type SessionsCommitInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsCommitOutput = void

export type SessionsContextInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsContextOutput = {
  readonly data: ReadonlyArray<
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "agent-switched"
        readonly agent: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "model-switched"
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly text: string
        readonly files?: ReadonlyArray<{
          readonly uri: string
          readonly mime: string
          readonly name?: string
          readonly description?: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly agents?: ReadonlyArray<{
          readonly name: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly origin?:
          | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
          | {
              readonly via: "messenger"
              readonly driver: string
              readonly accountID: string
              readonly chatID: string
              readonly chatKind?: string
              readonly chatTitle?: string
              readonly senderID: string
              readonly senderName: string
              readonly messageID: string
              readonly replyTo?: string
              readonly trust: "operator" | "client" | "audience"
              readonly at?: number
            }
        readonly type: "user"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly sessionID: string
        readonly text: string
        readonly type: "synthetic"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "system"
        readonly text: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "shell"
        readonly callID: string
        readonly command: string
        readonly output: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "assistant"
        readonly agent: string
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
        readonly content: ReadonlyArray<
          | { readonly type: "text"; readonly id: string; readonly text: string }
          | {
              readonly type: "reasoning"
              readonly id: string
              readonly text: string
              readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              readonly time?: { readonly created: number; readonly completed?: number }
            }
          | {
              readonly type: "tool"
              readonly id: string
              readonly name: string
              readonly provider?: {
                readonly executed: boolean
                readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                readonly resultMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              }
              readonly state:
                | { readonly status: "pending"; readonly input: string }
                | {
                    readonly status: "running"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                  }
                | {
                    readonly status: "completed"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly attachments?: ReadonlyArray<{
                      readonly uri: string
                      readonly mime: string
                      readonly name?: string
                      readonly description?: string
                      readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                    }>
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly outputPaths?: ReadonlyArray<string>
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly result?: JsonValue
                  }
                | {
                    readonly status: "error"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly error: { readonly type: "unknown"; readonly message: string }
                    readonly result?: JsonValue
                  }
              readonly time: {
                readonly created: number
                readonly ran?: number
                readonly completed?: number
                readonly pruned?: number
              }
            }
        >
        readonly snapshot?: { readonly start?: string; readonly end?: string; readonly files?: ReadonlyArray<string> }
        readonly finish?: string
        readonly cost?: number
        readonly tokens?: {
          readonly input: number
          readonly output: number
          readonly reasoning: number
          readonly cache: { readonly read: number; readonly write: number }
        }
        readonly error?: { readonly type: "unknown"; readonly message: string }
      }
    | {
        readonly type: "compaction"
        readonly reason: "auto" | "manual"
        readonly summary: string
        readonly recent: string
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
      }
  >
}["data"]

export type SessionsHistoryInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly limit?: { readonly limit?: number | undefined; readonly after?: number | undefined }["limit"]
  readonly after?: { readonly limit?: number | undefined; readonly after?: number | undefined }["after"]
}

export type SessionsHistoryOutput = {
  readonly data: ReadonlyArray<
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.completed"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: { readonly timestamp: number; readonly sessionID: string; readonly result?: JsonValue }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.agent.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly agent: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.model.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.responder.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly responder: "nova" | "operator"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.mode.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.strict.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly strict: {
            readonly enabled?: boolean
            readonly attempts?: number
            readonly wallMinutes?: number
          } | null
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.feature.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly feature: "introspection" | "quality" | "affective"
          readonly enabled: boolean | null
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.type.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.prompt-override.switched"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly override: string | null
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.moved"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly location: { readonly directory: string; readonly workspaceID?: string }
          readonly subdirectory?: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.prompted"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly prompt: {
            readonly text: string
            readonly files?: ReadonlyArray<{
              readonly uri: string
              readonly mime: string
              readonly name?: string
              readonly description?: string
              readonly source?: { readonly start: number; readonly end: number; readonly text: string }
            }>
            readonly agents?: ReadonlyArray<{
              readonly name: string
              readonly source?: { readonly start: number; readonly end: number; readonly text: string }
            }>
            readonly origin?:
              | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
              | {
                  readonly via: "messenger"
                  readonly driver: string
                  readonly accountID: string
                  readonly chatID: string
                  readonly chatKind?: string
                  readonly chatTitle?: string
                  readonly senderID: string
                  readonly senderName: string
                  readonly messageID: string
                  readonly replyTo?: string
                  readonly trust: "operator" | "client" | "audience"
                  readonly at?: number
                }
          }
          readonly delivery: "steer" | "queue"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.prompt.admitted"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly prompt: {
            readonly text: string
            readonly files?: ReadonlyArray<{
              readonly uri: string
              readonly mime: string
              readonly name?: string
              readonly description?: string
              readonly source?: { readonly start: number; readonly end: number; readonly text: string }
            }>
            readonly agents?: ReadonlyArray<{
              readonly name: string
              readonly source?: { readonly start: number; readonly end: number; readonly text: string }
            }>
            readonly origin?:
              | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
              | {
                  readonly via: "messenger"
                  readonly driver: string
                  readonly accountID: string
                  readonly chatID: string
                  readonly chatKind?: string
                  readonly chatTitle?: string
                  readonly senderID: string
                  readonly senderName: string
                  readonly messageID: string
                  readonly replyTo?: string
                  readonly trust: "operator" | "client" | "audience"
                  readonly at?: number
                }
          }
          readonly delivery: "steer" | "queue"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.context.updated"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly text: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.synthetic"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly text: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.message.recorded"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly message:
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
                readonly type: "agent-switched"
                readonly agent: string
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
                readonly type: "model-switched"
                readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
                readonly text: string
                readonly files?: ReadonlyArray<{
                  readonly uri: string
                  readonly mime: string
                  readonly name?: string
                  readonly description?: string
                  readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                }>
                readonly agents?: ReadonlyArray<{
                  readonly name: string
                  readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                }>
                readonly origin?:
                  | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
                  | {
                      readonly via: "messenger"
                      readonly driver: string
                      readonly accountID: string
                      readonly chatID: string
                      readonly chatKind?: string
                      readonly chatTitle?: string
                      readonly senderID: string
                      readonly senderName: string
                      readonly messageID: string
                      readonly replyTo?: string
                      readonly trust: "operator" | "client" | "audience"
                      readonly at?: number
                    }
                readonly type: "user"
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
                readonly sessionID: string
                readonly text: string
                readonly type: "synthetic"
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
                readonly type: "system"
                readonly text: string
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number; readonly completed?: number }
                readonly type: "shell"
                readonly callID: string
                readonly command: string
                readonly output: string
              }
            | {
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number; readonly completed?: number }
                readonly type: "assistant"
                readonly agent: string
                readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
                readonly content: ReadonlyArray<
                  | { readonly type: "text"; readonly id: string; readonly text: string }
                  | {
                      readonly type: "reasoning"
                      readonly id: string
                      readonly text: string
                      readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                      readonly time?: { readonly created: number; readonly completed?: number }
                    }
                  | {
                      readonly type: "tool"
                      readonly id: string
                      readonly name: string
                      readonly provider?: {
                        readonly executed: boolean
                        readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                        readonly resultMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                      }
                      readonly state:
                        | { readonly status: "pending"; readonly input: string }
                        | {
                            readonly status: "running"
                            readonly input: { readonly [x: string]: JsonValue }
                            readonly structured: { readonly [x: string]: JsonValue }
                            readonly content: ReadonlyArray<
                              | { readonly type: "text"; readonly text: string }
                              | {
                                  readonly type: "file"
                                  readonly uri: string
                                  readonly mime: string
                                  readonly name?: string
                                }
                            >
                          }
                        | {
                            readonly status: "completed"
                            readonly input: { readonly [x: string]: JsonValue }
                            readonly attachments?: ReadonlyArray<{
                              readonly uri: string
                              readonly mime: string
                              readonly name?: string
                              readonly description?: string
                              readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                            }>
                            readonly content: ReadonlyArray<
                              | { readonly type: "text"; readonly text: string }
                              | {
                                  readonly type: "file"
                                  readonly uri: string
                                  readonly mime: string
                                  readonly name?: string
                                }
                            >
                            readonly outputPaths?: ReadonlyArray<string>
                            readonly structured: { readonly [x: string]: JsonValue }
                            readonly result?: JsonValue
                          }
                        | {
                            readonly status: "error"
                            readonly input: { readonly [x: string]: JsonValue }
                            readonly content: ReadonlyArray<
                              | { readonly type: "text"; readonly text: string }
                              | {
                                  readonly type: "file"
                                  readonly uri: string
                                  readonly mime: string
                                  readonly name?: string
                                }
                            >
                            readonly structured: { readonly [x: string]: JsonValue }
                            readonly error: { readonly type: "unknown"; readonly message: string }
                            readonly result?: JsonValue
                          }
                      readonly time: {
                        readonly created: number
                        readonly ran?: number
                        readonly completed?: number
                        readonly pruned?: number
                      }
                    }
                >
                readonly snapshot?: {
                  readonly start?: string
                  readonly end?: string
                  readonly files?: ReadonlyArray<string>
                }
                readonly finish?: string
                readonly cost?: number
                readonly tokens?: {
                  readonly input: number
                  readonly output: number
                  readonly reasoning: number
                  readonly cache: { readonly read: number; readonly write: number }
                }
                readonly error?: { readonly type: "unknown"; readonly message: string }
              }
            | {
                readonly type: "compaction"
                readonly reason: "auto" | "manual"
                readonly summary: string
                readonly recent: string
                readonly id: string
                readonly metadata?: { readonly [x: string]: JsonValue }
                readonly time: { readonly created: number }
              }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.shell.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly callID: string
          readonly command: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.shell.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly callID: string
          readonly output: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.step.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly agent: string
          readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
          readonly snapshot?: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.step.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly finish: string
          readonly cost: number
          readonly tokens: {
            readonly input: number
            readonly output: number
            readonly reasoning: number
            readonly cache: { readonly read: number; readonly write: number }
          }
          readonly snapshot?: string
          readonly files?: ReadonlyArray<string>
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.step.failed"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly error: { readonly type: "unknown"; readonly message: string }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.text.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly textID: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.text.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly textID: string
          readonly text: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.input.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly name: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.input.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly text: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.called"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly tool: string
          readonly input: { readonly [x: string]: JsonValue }
          readonly provider: {
            readonly executed: boolean
            readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
          }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.progress"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly structured: { readonly [x: string]: JsonValue }
          readonly content: ReadonlyArray<
            | { readonly type: "text"; readonly text: string }
            | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
          >
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.success"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly structured: { readonly [x: string]: JsonValue }
          readonly content: ReadonlyArray<
            | { readonly type: "text"; readonly text: string }
            | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
          >
          readonly outputPaths?: ReadonlyArray<string>
          readonly result?: JsonValue
          readonly provider: {
            readonly executed: boolean
            readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
          }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.tool.failed"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly callID: string
          readonly error: { readonly type: "unknown"; readonly message: string }
          readonly result?: JsonValue
          readonly provider: {
            readonly executed: boolean
            readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
          }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.reasoning.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly reasoningID: string
          readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.reasoning.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly assistantMessageID: string
          readonly reasoningID: string
          readonly text: string
          readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.retried"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly attempt: number
          readonly error: {
            readonly message: string
            readonly statusCode?: number
            readonly isRetryable: boolean
            readonly responseHeaders?: { readonly [x: string]: string }
            readonly responseBody?: string
            readonly metadata?: { readonly [x: string]: string }
          }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.compaction.started"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly reason: "auto" | "manual"
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.compaction.ended"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly messageID: string
          readonly reason: "auto" | "manual"
          readonly text: string
          readonly recent: string
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.revert.staged"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: {
          readonly timestamp: number
          readonly sessionID: string
          readonly revert: {
            readonly messageID: string
            readonly partID?: string
            readonly snapshot?: string
            readonly diff?: string
            readonly files?: ReadonlyArray<{
              readonly path: string
              readonly status: "added" | "modified" | "deleted"
              readonly additions: number
              readonly deletions: number
              readonly patch: string
            }>
          }
        }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.revert.cleared"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: { readonly timestamp: number; readonly sessionID: string }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly type: "session.next.revert.committed"
        readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
        readonly location?: { readonly directory: string; readonly workspaceID?: string }
        readonly data: { readonly timestamp: number; readonly sessionID: string; readonly messageID: string }
      }
  >
  readonly hasMore: boolean
}

export type SessionsEventsInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly after?: { readonly after?: number | undefined }["after"]
}

export type SessionsEventsOutput =
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.completed"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: { readonly timestamp: number; readonly sessionID: string; readonly result?: unknown }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.agent.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly agent: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.model.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.responder.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly responder: "nova" | "operator"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.mode.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly permissionMode: "plan" | "ask" | "surgical" | "bypass" | "yolo"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.strict.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly strict: {
          readonly enabled?: boolean
          readonly attempts?: number
          readonly wallMinutes?: number
        } | null
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.feature.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly feature: "introspection" | "quality" | "affective"
        readonly enabled: boolean | null
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.type.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly sessionType: "interactive" | "sub-agent" | "auto-prompting" | "goal-oriented"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.prompt-override.switched"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly override: string | null
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.moved"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly location: { readonly directory: string; readonly workspaceID?: string }
        readonly subdirectory?: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.prompted"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly prompt: {
          readonly text: string
          readonly files?: ReadonlyArray<{
            readonly uri: string
            readonly mime: string
            readonly name?: string
            readonly description?: string
            readonly source?: { readonly start: number; readonly end: number; readonly text: string }
          }>
          readonly agents?: ReadonlyArray<{
            readonly name: string
            readonly source?: { readonly start: number; readonly end: number; readonly text: string }
          }>
          readonly origin?:
            | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
            | {
                readonly via: "messenger"
                readonly driver: string
                readonly accountID: string
                readonly chatID: string
                readonly chatKind?: string
                readonly chatTitle?: string
                readonly senderID: string
                readonly senderName: string
                readonly messageID: string
                readonly replyTo?: string
                readonly trust: "operator" | "client" | "audience"
                readonly at?: number
              }
        }
        readonly delivery: "steer" | "queue"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.prompt.admitted"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly prompt: {
          readonly text: string
          readonly files?: ReadonlyArray<{
            readonly uri: string
            readonly mime: string
            readonly name?: string
            readonly description?: string
            readonly source?: { readonly start: number; readonly end: number; readonly text: string }
          }>
          readonly agents?: ReadonlyArray<{
            readonly name: string
            readonly source?: { readonly start: number; readonly end: number; readonly text: string }
          }>
          readonly origin?:
            | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
            | {
                readonly via: "messenger"
                readonly driver: string
                readonly accountID: string
                readonly chatID: string
                readonly chatKind?: string
                readonly chatTitle?: string
                readonly senderID: string
                readonly senderName: string
                readonly messageID: string
                readonly replyTo?: string
                readonly trust: "operator" | "client" | "audience"
                readonly at?: number
              }
        }
        readonly delivery: "steer" | "queue"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.context.updated"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly text: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.synthetic"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly text: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.message.recorded"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly message:
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
              readonly type: "agent-switched"
              readonly agent: string
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
              readonly type: "model-switched"
              readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
              readonly text: string
              readonly files?: ReadonlyArray<{
                readonly uri: string
                readonly mime: string
                readonly name?: string
                readonly description?: string
                readonly source?: { readonly start: number; readonly end: number; readonly text: string }
              }>
              readonly agents?: ReadonlyArray<{
                readonly name: string
                readonly source?: { readonly start: number; readonly end: number; readonly text: string }
              }>
              readonly origin?:
                | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
                | {
                    readonly via: "messenger"
                    readonly driver: string
                    readonly accountID: string
                    readonly chatID: string
                    readonly chatKind?: string
                    readonly chatTitle?: string
                    readonly senderID: string
                    readonly senderName: string
                    readonly messageID: string
                    readonly replyTo?: string
                    readonly trust: "operator" | "client" | "audience"
                    readonly at?: number
                  }
              readonly type: "user"
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
              readonly sessionID: string
              readonly text: string
              readonly type: "synthetic"
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
              readonly type: "system"
              readonly text: string
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number; readonly completed?: number }
              readonly type: "shell"
              readonly callID: string
              readonly command: string
              readonly output: string
            }
          | {
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number; readonly completed?: number }
              readonly type: "assistant"
              readonly agent: string
              readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
              readonly content: ReadonlyArray<
                | { readonly type: "text"; readonly id: string; readonly text: string }
                | {
                    readonly type: "reasoning"
                    readonly id: string
                    readonly text: string
                    readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
                    readonly time?: { readonly created: number; readonly completed?: number }
                  }
                | {
                    readonly type: "tool"
                    readonly id: string
                    readonly name: string
                    readonly provider?: {
                      readonly executed: boolean
                      readonly metadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
                      readonly resultMetadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
                    }
                    readonly state:
                      | { readonly status: "pending"; readonly input: string }
                      | {
                          readonly status: "running"
                          readonly input: { readonly [x: string]: unknown }
                          readonly structured: { readonly [x: string]: unknown }
                          readonly content: ReadonlyArray<
                            | { readonly type: "text"; readonly text: string }
                            | {
                                readonly type: "file"
                                readonly uri: string
                                readonly mime: string
                                readonly name?: string
                              }
                          >
                        }
                      | {
                          readonly status: "completed"
                          readonly input: { readonly [x: string]: unknown }
                          readonly attachments?: ReadonlyArray<{
                            readonly uri: string
                            readonly mime: string
                            readonly name?: string
                            readonly description?: string
                            readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                          }>
                          readonly content: ReadonlyArray<
                            | { readonly type: "text"; readonly text: string }
                            | {
                                readonly type: "file"
                                readonly uri: string
                                readonly mime: string
                                readonly name?: string
                              }
                          >
                          readonly outputPaths?: ReadonlyArray<string>
                          readonly structured: { readonly [x: string]: unknown }
                          readonly result?: unknown
                        }
                      | {
                          readonly status: "error"
                          readonly input: { readonly [x: string]: unknown }
                          readonly content: ReadonlyArray<
                            | { readonly type: "text"; readonly text: string }
                            | {
                                readonly type: "file"
                                readonly uri: string
                                readonly mime: string
                                readonly name?: string
                              }
                          >
                          readonly structured: { readonly [x: string]: unknown }
                          readonly error: { readonly type: "unknown"; readonly message: string }
                          readonly result?: unknown
                        }
                    readonly time: {
                      readonly created: number
                      readonly ran?: number
                      readonly completed?: number
                      readonly pruned?: number
                    }
                  }
              >
              readonly snapshot?: {
                readonly start?: string
                readonly end?: string
                readonly files?: ReadonlyArray<string>
              }
              readonly finish?: string
              readonly cost?: number
              readonly tokens?: {
                readonly input: number
                readonly output: number
                readonly reasoning: number
                readonly cache: { readonly read: number; readonly write: number }
              }
              readonly error?: { readonly type: "unknown"; readonly message: string }
            }
          | {
              readonly type: "compaction"
              readonly reason: "auto" | "manual"
              readonly summary: string
              readonly recent: string
              readonly id: string
              readonly metadata?: { readonly [x: string]: unknown }
              readonly time: { readonly created: number }
            }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.shell.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly callID: string
        readonly command: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.shell.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly callID: string
        readonly output: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.step.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly agent: string
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
        readonly snapshot?: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.step.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly finish: string
        readonly cost: number
        readonly tokens: {
          readonly input: number
          readonly output: number
          readonly reasoning: number
          readonly cache: { readonly read: number; readonly write: number }
        }
        readonly snapshot?: string
        readonly files?: ReadonlyArray<string>
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.step.failed"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly error: { readonly type: "unknown"; readonly message: string }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.text.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly textID: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.text.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly textID: string
        readonly text: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.input.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly name: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.input.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly text: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.called"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly tool: string
        readonly input: { readonly [x: string]: unknown }
        readonly provider: {
          readonly executed: boolean
          readonly metadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
        }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.progress"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly structured: { readonly [x: string]: unknown }
        readonly content: ReadonlyArray<
          | { readonly type: "text"; readonly text: string }
          | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
        >
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.success"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly structured: { readonly [x: string]: unknown }
        readonly content: ReadonlyArray<
          | { readonly type: "text"; readonly text: string }
          | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
        >
        readonly outputPaths?: ReadonlyArray<string>
        readonly result?: unknown
        readonly provider: {
          readonly executed: boolean
          readonly metadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
        }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.tool.failed"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly callID: string
        readonly error: { readonly type: "unknown"; readonly message: string }
        readonly result?: unknown
        readonly provider: {
          readonly executed: boolean
          readonly metadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
        }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.reasoning.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly reasoningID: string
        readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.reasoning.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly assistantMessageID: string
        readonly reasoningID: string
        readonly text: string
        readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: unknown } }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.retried"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly attempt: number
        readonly error: {
          readonly message: string
          readonly statusCode?: number
          readonly isRetryable: boolean
          readonly responseHeaders?: { readonly [x: string]: string }
          readonly responseBody?: string
          readonly metadata?: { readonly [x: string]: string }
        }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.compaction.started"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly reason: "auto" | "manual"
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.compaction.ended"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly messageID: string
        readonly reason: "auto" | "manual"
        readonly text: string
        readonly recent: string
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.revert.staged"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: {
        readonly timestamp: number
        readonly sessionID: string
        readonly revert: {
          readonly messageID: string
          readonly partID?: string
          readonly snapshot?: string
          readonly diff?: string
          readonly files?: ReadonlyArray<{
            readonly path: string
            readonly status: "added" | "modified" | "deleted"
            readonly additions: number
            readonly deletions: number
            readonly patch: string
          }>
        }
      }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.revert.cleared"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: { readonly timestamp: number; readonly sessionID: string }
    }
  | {
      readonly id: string
      readonly metadata?: { readonly [x: string]: unknown }
      readonly type: "session.next.revert.committed"
      readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
      readonly location?: { readonly directory: string; readonly workspaceID?: string }
      readonly data: { readonly timestamp: number; readonly sessionID: string; readonly messageID: string }
    }

export type SessionsInterruptInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type SessionsInterruptOutput = void

export type SessionsMessageInput = {
  readonly sessionID: { readonly sessionID: string; readonly messageID: string }["sessionID"]
  readonly messageID: { readonly sessionID: string; readonly messageID: string }["messageID"]
}

export type SessionsMessageOutput = {
  readonly data:
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "agent-switched"
        readonly agent: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "model-switched"
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly text: string
        readonly files?: ReadonlyArray<{
          readonly uri: string
          readonly mime: string
          readonly name?: string
          readonly description?: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly agents?: ReadonlyArray<{
          readonly name: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly origin?:
          | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
          | {
              readonly via: "messenger"
              readonly driver: string
              readonly accountID: string
              readonly chatID: string
              readonly chatKind?: string
              readonly chatTitle?: string
              readonly senderID: string
              readonly senderName: string
              readonly messageID: string
              readonly replyTo?: string
              readonly trust: "operator" | "client" | "audience"
              readonly at?: number
            }
        readonly type: "user"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly sessionID: string
        readonly text: string
        readonly type: "synthetic"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "system"
        readonly text: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "shell"
        readonly callID: string
        readonly command: string
        readonly output: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "assistant"
        readonly agent: string
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
        readonly content: ReadonlyArray<
          | { readonly type: "text"; readonly id: string; readonly text: string }
          | {
              readonly type: "reasoning"
              readonly id: string
              readonly text: string
              readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              readonly time?: { readonly created: number; readonly completed?: number }
            }
          | {
              readonly type: "tool"
              readonly id: string
              readonly name: string
              readonly provider?: {
                readonly executed: boolean
                readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                readonly resultMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              }
              readonly state:
                | { readonly status: "pending"; readonly input: string }
                | {
                    readonly status: "running"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                  }
                | {
                    readonly status: "completed"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly attachments?: ReadonlyArray<{
                      readonly uri: string
                      readonly mime: string
                      readonly name?: string
                      readonly description?: string
                      readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                    }>
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly outputPaths?: ReadonlyArray<string>
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly result?: JsonValue
                  }
                | {
                    readonly status: "error"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly error: { readonly type: "unknown"; readonly message: string }
                    readonly result?: JsonValue
                  }
              readonly time: {
                readonly created: number
                readonly ran?: number
                readonly completed?: number
                readonly pruned?: number
              }
            }
        >
        readonly snapshot?: { readonly start?: string; readonly end?: string; readonly files?: ReadonlyArray<string> }
        readonly finish?: string
        readonly cost?: number
        readonly tokens?: {
          readonly input: number
          readonly output: number
          readonly reasoning: number
          readonly cache: { readonly read: number; readonly write: number }
        }
        readonly error?: { readonly type: "unknown"; readonly message: string }
      }
    | {
        readonly type: "compaction"
        readonly reason: "auto" | "manual"
        readonly summary: string
        readonly recent: string
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
      }
}["data"]

export type MessagesListInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly limit?: {
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly cursor?: string | undefined
  }["limit"]
  readonly order?: {
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly cursor?: string | undefined
  }["order"]
  readonly cursor?: {
    readonly limit?: number | undefined
    readonly order?: "asc" | "desc" | undefined
    readonly cursor?: string | undefined
  }["cursor"]
}

export type MessagesListOutput = {
  readonly data: ReadonlyArray<
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "agent-switched"
        readonly agent: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "model-switched"
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly text: string
        readonly files?: ReadonlyArray<{
          readonly uri: string
          readonly mime: string
          readonly name?: string
          readonly description?: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly agents?: ReadonlyArray<{
          readonly name: string
          readonly source?: { readonly start: number; readonly end: number; readonly text: string }
        }>
        readonly origin?:
          | { readonly via: "agent"; readonly sessionID: string; readonly label?: string }
          | {
              readonly via: "messenger"
              readonly driver: string
              readonly accountID: string
              readonly chatID: string
              readonly chatKind?: string
              readonly chatTitle?: string
              readonly senderID: string
              readonly senderName: string
              readonly messageID: string
              readonly replyTo?: string
              readonly trust: "operator" | "client" | "audience"
              readonly at?: number
            }
        readonly type: "user"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly sessionID: string
        readonly text: string
        readonly type: "synthetic"
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
        readonly type: "system"
        readonly text: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "shell"
        readonly callID: string
        readonly command: string
        readonly output: string
      }
    | {
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number; readonly completed?: number }
        readonly type: "assistant"
        readonly agent: string
        readonly model: { readonly id: string; readonly providerID: string; readonly variant?: string }
        readonly content: ReadonlyArray<
          | { readonly type: "text"; readonly id: string; readonly text: string }
          | {
              readonly type: "reasoning"
              readonly id: string
              readonly text: string
              readonly providerMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              readonly time?: { readonly created: number; readonly completed?: number }
            }
          | {
              readonly type: "tool"
              readonly id: string
              readonly name: string
              readonly provider?: {
                readonly executed: boolean
                readonly metadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
                readonly resultMetadata?: { readonly [x: string]: { readonly [x: string]: JsonValue } }
              }
              readonly state:
                | { readonly status: "pending"; readonly input: string }
                | {
                    readonly status: "running"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                  }
                | {
                    readonly status: "completed"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly attachments?: ReadonlyArray<{
                      readonly uri: string
                      readonly mime: string
                      readonly name?: string
                      readonly description?: string
                      readonly source?: { readonly start: number; readonly end: number; readonly text: string }
                    }>
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly outputPaths?: ReadonlyArray<string>
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly result?: JsonValue
                  }
                | {
                    readonly status: "error"
                    readonly input: { readonly [x: string]: JsonValue }
                    readonly content: ReadonlyArray<
                      | { readonly type: "text"; readonly text: string }
                      | { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string }
                    >
                    readonly structured: { readonly [x: string]: JsonValue }
                    readonly error: { readonly type: "unknown"; readonly message: string }
                    readonly result?: JsonValue
                  }
              readonly time: {
                readonly created: number
                readonly ran?: number
                readonly completed?: number
                readonly pruned?: number
              }
            }
        >
        readonly snapshot?: { readonly start?: string; readonly end?: string; readonly files?: ReadonlyArray<string> }
        readonly finish?: string
        readonly cost?: number
        readonly tokens?: {
          readonly input: number
          readonly output: number
          readonly reasoning: number
          readonly cache: { readonly read: number; readonly write: number }
        }
        readonly error?: { readonly type: "unknown"; readonly message: string }
      }
    | {
        readonly type: "compaction"
        readonly reason: "auto" | "manual"
        readonly summary: string
        readonly recent: string
        readonly id: string
        readonly metadata?: { readonly [x: string]: JsonValue }
        readonly time: { readonly created: number }
      }
  >
  readonly cursor: { readonly previous?: string | null; readonly next?: string | null }
}

export type ModelsListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type ModelsListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly providerID: string
    readonly family?: string
    readonly tier?: "micro" | "tiny" | "small" | "medium" | "large" | "frontier"
    readonly name: string
    readonly api:
      | {
          readonly id: string
          readonly type: "aisdk"
          readonly package: string
          readonly url?: string
          readonly settings?: { readonly [x: string]: JsonValue }
        }
      | {
          readonly id: string
          readonly type: "native"
          readonly url?: string
          readonly settings: { readonly [x: string]: JsonValue }
        }
    readonly capabilities: {
      readonly tools: boolean
      readonly input: ReadonlyArray<string>
      readonly output: ReadonlyArray<string>
    }
    readonly request: {
      readonly headers: { readonly [x: string]: string }
      readonly body: { readonly [x: string]: JsonValue }
      readonly variant?: string
    }
    readonly variants: ReadonlyArray<{
      readonly id: string
      readonly headers: { readonly [x: string]: string }
      readonly body: { readonly [x: string]: JsonValue }
    }>
    readonly time: { readonly released: number }
    readonly cost: ReadonlyArray<{
      readonly tier?: { readonly type: "context"; readonly size: number }
      readonly input: number
      readonly output: number
      readonly cache: { readonly read: number; readonly write: number }
    }>
    readonly status: "alpha" | "beta" | "deprecated" | "active"
    readonly enabled: boolean
    readonly limit: { readonly context: number; readonly input?: number; readonly output: number }
  }>
}

export type ProvidersListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type ProvidersListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly integrationID?: string
    readonly name: string
    readonly disabled?: boolean
    readonly api:
      | {
          readonly type: "aisdk"
          readonly package: string
          readonly url?: string
          readonly settings?: { readonly [x: string]: JsonValue }
        }
      | { readonly type: "native"; readonly url?: string; readonly settings: { readonly [x: string]: JsonValue } }
    readonly request: {
      readonly headers: { readonly [x: string]: string }
      readonly body: { readonly [x: string]: JsonValue }
    }
  }>
}

export type ProvidersGetInput = {
  readonly providerID: { readonly providerID: string }["providerID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type ProvidersGetOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly id: string
    readonly integrationID?: string
    readonly name: string
    readonly disabled?: boolean
    readonly api:
      | {
          readonly type: "aisdk"
          readonly package: string
          readonly url?: string
          readonly settings?: { readonly [x: string]: JsonValue }
        }
      | { readonly type: "native"; readonly url?: string; readonly settings: { readonly [x: string]: JsonValue } }
    readonly request: {
      readonly headers: { readonly [x: string]: string }
      readonly body: { readonly [x: string]: JsonValue }
    }
  }
}

export type ProvidersRemoveInput = {
  readonly providerID: { readonly providerID: string }["providerID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type ProvidersRemoveOutput = void

export type IntegrationsListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type IntegrationsListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly name: string
    readonly methods: ReadonlyArray<
      | {
          readonly id: string
          readonly type: "oauth"
          readonly label: string
          readonly prompts?: ReadonlyArray<
            | {
                readonly type: "text"
                readonly key: string
                readonly message: string
                readonly placeholder?: string
                readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
              }
            | {
                readonly type: "select"
                readonly key: string
                readonly message: string
                readonly options: ReadonlyArray<{
                  readonly label: string
                  readonly value: string
                  readonly hint?: string
                }>
                readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
              }
          >
        }
      | { readonly type: "key"; readonly label?: string }
      | { readonly type: "env"; readonly names: ReadonlyArray<string> }
    >
    readonly connections: ReadonlyArray<
      | { readonly type: "credential"; readonly id: string; readonly label: string }
      | { readonly type: "env"; readonly name: string }
    >
  }>
}

export type IntegrationsGetInput = {
  readonly integrationID: { readonly integrationID: string }["integrationID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type IntegrationsGetOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly id: string
    readonly name: string
    readonly methods: ReadonlyArray<
      | {
          readonly id: string
          readonly type: "oauth"
          readonly label: string
          readonly prompts?: ReadonlyArray<
            | {
                readonly type: "text"
                readonly key: string
                readonly message: string
                readonly placeholder?: string
                readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
              }
            | {
                readonly type: "select"
                readonly key: string
                readonly message: string
                readonly options: ReadonlyArray<{
                  readonly label: string
                  readonly value: string
                  readonly hint?: string
                }>
                readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
              }
          >
        }
      | { readonly type: "key"; readonly label?: string }
      | { readonly type: "env"; readonly names: ReadonlyArray<string> }
    >
    readonly connections: ReadonlyArray<
      | { readonly type: "credential"; readonly id: string; readonly label: string }
      | { readonly type: "env"; readonly name: string }
    >
  } | null
}

export type IntegrationsConnectKeyInput = {
  readonly integrationID: { readonly integrationID: string }["integrationID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly key: { readonly key: string; readonly label?: string | undefined }["key"]
  readonly label?: { readonly key: string; readonly label?: string | undefined }["label"]
}

export type IntegrationsConnectKeyOutput = void

export type IntegrationsConnectOauthInput = {
  readonly integrationID: { readonly integrationID: string }["integrationID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly methodID: {
    readonly methodID: string
    readonly inputs: { readonly [x: string]: string }
    readonly label?: string | undefined
  }["methodID"]
  readonly inputs: {
    readonly methodID: string
    readonly inputs: { readonly [x: string]: string }
    readonly label?: string | undefined
  }["inputs"]
  readonly label?: {
    readonly methodID: string
    readonly inputs: { readonly [x: string]: string }
    readonly label?: string | undefined
  }["label"]
}

export type IntegrationsConnectOauthOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly attemptID: string
    readonly url: string
    readonly instructions: string
    readonly mode: "auto" | "code"
    readonly time: {
      readonly created: number | "Infinity" | "-Infinity" | "NaN"
      readonly expires: number | "Infinity" | "-Infinity" | "NaN"
    }
  }
}

export type IntegrationsAttemptStatusInput = {
  readonly attemptID: { readonly attemptID: string }["attemptID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type IntegrationsAttemptStatusOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data:
    | {
        readonly status: "pending"
        readonly time: {
          readonly created: number | "Infinity" | "-Infinity" | "NaN"
          readonly expires: number | "Infinity" | "-Infinity" | "NaN"
        }
      }
    | {
        readonly status: "complete"
        readonly time: {
          readonly created: number | "Infinity" | "-Infinity" | "NaN"
          readonly expires: number | "Infinity" | "-Infinity" | "NaN"
        }
      }
    | {
        readonly status: "failed"
        readonly message: string
        readonly time: {
          readonly created: number | "Infinity" | "-Infinity" | "NaN"
          readonly expires: number | "Infinity" | "-Infinity" | "NaN"
        }
      }
    | {
        readonly status: "expired"
        readonly time: {
          readonly created: number | "Infinity" | "-Infinity" | "NaN"
          readonly expires: number | "Infinity" | "-Infinity" | "NaN"
        }
      }
}

export type IntegrationsAttemptCompleteInput = {
  readonly attemptID: { readonly attemptID: string }["attemptID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly code?: { readonly code?: string | undefined }["code"]
}

export type IntegrationsAttemptCompleteOutput = void

export type IntegrationsAttemptCancelInput = {
  readonly attemptID: { readonly attemptID: string }["attemptID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type IntegrationsAttemptCancelOutput = void

export type CredentialsUpdateInput = {
  readonly credentialID: { readonly credentialID: string }["credentialID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly label: { readonly label: string }["label"]
}

export type CredentialsUpdateOutput = void

export type CredentialsRemoveInput = {
  readonly credentialID: { readonly credentialID: string }["credentialID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type CredentialsRemoveOutput = void

export type MessengerListDriversOutput = ReadonlyArray<{
  readonly id: string
  readonly name: string
  readonly icon: string
  readonly auth: "login" | "key" | "none"
  readonly settings: ReadonlyArray<
    | {
        readonly type: "text"
        readonly key: string
        readonly message: string
        readonly placeholder?: string
        readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
      }
    | {
        readonly type: "select"
        readonly key: string
        readonly message: string
        readonly options: ReadonlyArray<{ readonly label: string; readonly value: string; readonly hint?: string }>
        readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
      }
  >
  readonly loginPrompts?: ReadonlyArray<
    | {
        readonly type: "text"
        readonly key: string
        readonly message: string
        readonly placeholder?: string
        readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
      }
    | {
        readonly type: "select"
        readonly key: string
        readonly message: string
        readonly options: ReadonlyArray<{ readonly label: string; readonly value: string; readonly hint?: string }>
        readonly when?: { readonly key: string; readonly op: "eq" | "neq"; readonly value: string }
      }
  >
  readonly capabilities: {
    readonly listChats: "full" | "seen" | "none"
    readonly files: {
      readonly up: boolean
      readonly down: boolean
      readonly maxBytes?: number | "Infinity" | "-Infinity" | "NaN"
    }
    readonly edits: boolean
    readonly typing: boolean
    readonly threads: boolean
    readonly moderation: {
      readonly delete: boolean
      readonly ban: boolean
      readonly kick: boolean
      readonly mute: boolean
      readonly pin: boolean
    }
    readonly format: "plain" | "markdown" | "html"
    readonly maxChars: number | "Infinity" | "-Infinity" | "NaN"
    readonly maxBytes?: number | "Infinity" | "-Infinity" | "NaN"
  }
}>

export type MessengerListAccountsOutput = ReadonlyArray<{
  readonly account: {
    readonly id: string
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly credentialID?: string
    readonly settings: { readonly [x: string]: string }
  }
  readonly status:
    | { readonly state: "disabled" }
    | { readonly state: "airgapped" }
    | { readonly state: "connecting" }
    | { readonly state: "connected" }
    | { readonly state: "backoff"; readonly until: number | "Infinity" | "-Infinity" | "NaN"; readonly message: string }
    | { readonly state: "challenge"; readonly message: string }
    | { readonly state: "error"; readonly message: string }
}>

export type MessengerCreateAccountInput = {
  readonly driverID: {
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly settings: { readonly [x: string]: string }
    readonly secret?: string | undefined
  }["driverID"]
  readonly label: {
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly settings: { readonly [x: string]: string }
    readonly secret?: string | undefined
  }["label"]
  readonly enabled: {
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly settings: { readonly [x: string]: string }
    readonly secret?: string | undefined
  }["enabled"]
  readonly settings: {
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly settings: { readonly [x: string]: string }
    readonly secret?: string | undefined
  }["settings"]
  readonly secret?: {
    readonly driverID: string
    readonly label: string
    readonly enabled: boolean
    readonly settings: { readonly [x: string]: string }
    readonly secret?: string | undefined
  }["secret"]
}

export type MessengerCreateAccountOutput = {
  readonly id: string
  readonly driverID: string
  readonly label: string
  readonly enabled: boolean
  readonly credentialID?: string
  readonly settings: { readonly [x: string]: string }
}

export type MessengerUpdateAccountInput = {
  readonly accountID: { readonly accountID: string }["accountID"]
  readonly label?: {
    readonly label?: string | undefined
    readonly enabled?: boolean | undefined
    readonly settings?: { readonly [x: string]: string } | undefined
    readonly secret?: string | undefined
  }["label"]
  readonly enabled?: {
    readonly label?: string | undefined
    readonly enabled?: boolean | undefined
    readonly settings?: { readonly [x: string]: string } | undefined
    readonly secret?: string | undefined
  }["enabled"]
  readonly settings?: {
    readonly label?: string | undefined
    readonly enabled?: boolean | undefined
    readonly settings?: { readonly [x: string]: string } | undefined
    readonly secret?: string | undefined
  }["settings"]
  readonly secret?: {
    readonly label?: string | undefined
    readonly enabled?: boolean | undefined
    readonly settings?: { readonly [x: string]: string } | undefined
    readonly secret?: string | undefined
  }["secret"]
}

export type MessengerUpdateAccountOutput = void

export type MessengerRemoveAccountInput = { readonly accountID: { readonly accountID: string }["accountID"] }

export type MessengerRemoveAccountOutput = void

export type MessengerMintPairingInput = {
  readonly accountID: { readonly accountID: string }["accountID"]
  readonly trust: { readonly trust: "operator" | "client" }["trust"]
}

export type MessengerMintPairingOutput = { readonly code: string; readonly expiresAt: number }

export type MessengerListAccountChatsInput = { readonly accountID: { readonly accountID: string }["accountID"] }

export type MessengerListAccountChatsOutput = {
  readonly ok: boolean
  readonly chats: ReadonlyArray<{
    readonly accountID: string
    readonly chatID: string
    readonly kind: "dm" | "group" | "channel" | "thread" | "mailbox" | "topic"
    readonly title: string
    readonly lastSeen: number
  }>
  readonly reason?: string | undefined
}

export type MessengerListBindingsOutput = ReadonlyArray<{
  readonly binding: {
    readonly id: string
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly status: "active" | "paused"
  }
  readonly chatTitle?: string | undefined
}>

export type MessengerCreateBindingInput = {
  readonly accountID: {
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly steal?: boolean | undefined
  }["accountID"]
  readonly chatID: {
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly steal?: boolean | undefined
  }["chatID"]
  readonly sessionID: {
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly steal?: boolean | undefined
  }["sessionID"]
  readonly trust: {
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly steal?: boolean | undefined
  }["trust"]
  readonly steal?: {
    readonly accountID: string
    readonly chatID: string
    readonly sessionID: string
    readonly trust: "operator" | "client" | "audience"
    readonly steal?: boolean | undefined
  }["steal"]
}

export type MessengerCreateBindingOutput = {
  readonly id: string
  readonly accountID: string
  readonly chatID: string
  readonly sessionID: string
  readonly trust: "operator" | "client" | "audience"
  readonly status: "active" | "paused"
}

export type MessengerRemoveBindingInput = { readonly bindingID: { readonly bindingID: string }["bindingID"] }

export type MessengerRemoveBindingOutput = void

export type MessengerLoginBeginInput = {
  readonly accountID: { readonly accountID: string }["accountID"]
  readonly inputs: { readonly inputs: { readonly [x: string]: string } }["inputs"]
}

export type MessengerLoginBeginOutput = {
  readonly attemptID: string
  readonly instructions: string
  readonly time: { readonly created: number; readonly expires: number }
}

export type MessengerLoginStatusInput = { readonly attemptID: { readonly attemptID: string }["attemptID"] }

export type MessengerLoginStatusOutput =
  | { readonly status: "pending"; readonly time: { readonly created: number; readonly expires: number } }
  | { readonly status: "complete"; readonly time: { readonly created: number; readonly expires: number } }
  | {
      readonly status: "failed"
      readonly message: string
      readonly time: { readonly created: number; readonly expires: number }
    }
  | { readonly status: "expired"; readonly time: { readonly created: number; readonly expires: number } }

export type MessengerLoginCompleteInput = {
  readonly attemptID: { readonly attemptID: string }["attemptID"]
  readonly code: { readonly code: string }["code"]
}

export type MessengerLoginCompleteOutput = void

export type MessengerLoginCancelInput = { readonly attemptID: { readonly attemptID: string }["attemptID"] }

export type MessengerLoginCancelOutput = void

export type PermissionsListRequestsInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type PermissionsListRequestsOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly sessionID: string
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
  }>
}

export type PermissionsListSavedInput = { readonly origin?: { readonly origin?: string | undefined }["origin"] }

export type PermissionsListSavedOutput = {
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly origin: string
    readonly action: string
    readonly resource: string
    readonly effect?: "allow" | "deny" | undefined
  }>
}["data"]

export type PermissionsRemoveSavedInput = { readonly id: { readonly id: string }["id"] }

export type PermissionsRemoveSavedOutput = void

export type PermissionsCreateInput = {
  readonly sessionID: { readonly sessionID: string }["sessionID"]
  readonly id?: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["id"]
  readonly action: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["action"]
  readonly resources: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["resources"]
  readonly save?: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["save"]
  readonly metadata?: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["metadata"]
  readonly source?: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["source"]
  readonly agent?: {
    readonly id?: string | null
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
    readonly agent?: string | null
  }["agent"]
}

export type PermissionsCreateOutput = {
  readonly data: { readonly id: string; readonly effect: "allow" | "deny" | "ask" }
}["data"]

export type PermissionsListInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type PermissionsListOutput = {
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly sessionID: string
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
  }>
}["data"]

export type PermissionsGetInput = {
  readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
  readonly requestID: { readonly sessionID: string; readonly requestID: string }["requestID"]
}

export type PermissionsGetOutput = {
  readonly data: {
    readonly id: string
    readonly sessionID: string
    readonly action: string
    readonly resources: ReadonlyArray<string>
    readonly save?: ReadonlyArray<string>
    readonly metadata?: { readonly [x: string]: JsonValue }
    readonly source?: { readonly type: "tool"; readonly messageID: string; readonly callID: string }
  }
}["data"]

export type PermissionsReplyInput = {
  readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
  readonly requestID: { readonly sessionID: string; readonly requestID: string }["requestID"]
  readonly reply: {
    readonly reply:
      | "once"
      | "always"
      | "reject"
      | "allow-once"
      | "allow-file"
      | "allow-always"
      | "deny-once"
      | "deny-file"
      | "deny-always"
    readonly message?: string | undefined
  }["reply"]
  readonly message?: {
    readonly reply:
      | "once"
      | "always"
      | "reject"
      | "allow-once"
      | "allow-file"
      | "allow-always"
      | "deny-once"
      | "deny-file"
      | "deny-always"
    readonly message?: string | undefined
  }["message"]
}

export type PermissionsReplyOutput = void

export type FilesListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly path?: string | undefined
  }["location"]
  readonly path?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly path?: string | undefined
  }["path"]
}

export type FilesListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{ readonly path: string; readonly type: "file" | "directory" }>
}

export type FilesFindInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly query: string
    readonly type?: "file" | "directory" | undefined
    readonly limit?: number | undefined
  }["location"]
  readonly query: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly query: string
    readonly type?: "file" | "directory" | undefined
    readonly limit?: number | undefined
  }["query"]
  readonly type?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly query: string
    readonly type?: "file" | "directory" | undefined
    readonly limit?: number | undefined
  }["type"]
  readonly limit?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
    readonly query: string
    readonly type?: "file" | "directory" | undefined
    readonly limit?: number | undefined
  }["limit"]
}

export type FilesFindOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{ readonly path: string; readonly type: "file" | "directory" }>
}

export type CommandsListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type CommandsListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly name: string
    readonly template: string
    readonly description?: string
    readonly agent?: string
    readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string }
    readonly subtask?: boolean
    readonly source?: "command" | "mcp" | "skill"
    readonly hints?: ReadonlyArray<string>
  }>
}

export type SkillsListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type SkillsListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly name: string
    readonly description?: string
    readonly slash?: boolean
    readonly location: string
    readonly content: string
  }>
}

export type EventsSubscribeOutput = NovaClawEventEncoded

export type PtysListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type PtysListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly title: string
    readonly command: string
    readonly args: ReadonlyArray<string>
    readonly cwd: string
    readonly status: "running" | "exited"
    readonly pid: number
    readonly exitCode?: number
  }>
}

export type PtysCreateInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly command?: {
    readonly command?: string
    readonly args?: ReadonlyArray<string>
    readonly cwd?: string
    readonly title?: string
    readonly env?: { readonly [x: string]: string }
  }["command"]
  readonly args?: {
    readonly command?: string
    readonly args?: ReadonlyArray<string>
    readonly cwd?: string
    readonly title?: string
    readonly env?: { readonly [x: string]: string }
  }["args"]
  readonly cwd?: {
    readonly command?: string
    readonly args?: ReadonlyArray<string>
    readonly cwd?: string
    readonly title?: string
    readonly env?: { readonly [x: string]: string }
  }["cwd"]
  readonly title?: {
    readonly command?: string
    readonly args?: ReadonlyArray<string>
    readonly cwd?: string
    readonly title?: string
    readonly env?: { readonly [x: string]: string }
  }["title"]
  readonly env?: {
    readonly command?: string
    readonly args?: ReadonlyArray<string>
    readonly cwd?: string
    readonly title?: string
    readonly env?: { readonly [x: string]: string }
  }["env"]
}

export type PtysCreateOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly id: string
    readonly title: string
    readonly command: string
    readonly args: ReadonlyArray<string>
    readonly cwd: string
    readonly status: "running" | "exited"
    readonly pid: number
    readonly exitCode?: number
  }
}

export type PtysGetInput = {
  readonly ptyID: { readonly ptyID: string }["ptyID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type PtysGetOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly id: string
    readonly title: string
    readonly command: string
    readonly args: ReadonlyArray<string>
    readonly cwd: string
    readonly status: "running" | "exited"
    readonly pid: number
    readonly exitCode?: number
  }
}

export type PtysUpdateInput = {
  readonly ptyID: { readonly ptyID: string }["ptyID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
  readonly title?: {
    readonly title?: string
    readonly size?: { readonly rows: number; readonly cols: number }
  }["title"]
  readonly size?: { readonly title?: string; readonly size?: { readonly rows: number; readonly cols: number } }["size"]
}

export type PtysUpdateOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: {
    readonly id: string
    readonly title: string
    readonly command: string
    readonly args: ReadonlyArray<string>
    readonly cwd: string
    readonly status: "running" | "exited"
    readonly pid: number
    readonly exitCode?: number
  }
}

export type PtysRemoveInput = {
  readonly ptyID: { readonly ptyID: string }["ptyID"]
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type PtysRemoveOutput = void

export type QuestionsListRequestsInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type QuestionsListRequestsOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly sessionID: string
    readonly questions: ReadonlyArray<{
      readonly question: string
      readonly header: string
      readonly options: ReadonlyArray<{ readonly label: string; readonly description: string }>
      readonly multiple?: boolean
      readonly custom?: boolean
    }>
    readonly tool?: { readonly messageID: string; readonly callID: string }
  }>
}

export type QuestionsListInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }

export type QuestionsListOutput = {
  readonly data: ReadonlyArray<{
    readonly id: string
    readonly sessionID: string
    readonly questions: ReadonlyArray<{
      readonly question: string
      readonly header: string
      readonly options: ReadonlyArray<{ readonly label: string; readonly description: string }>
      readonly multiple?: boolean
      readonly custom?: boolean
    }>
    readonly tool?: { readonly messageID: string; readonly callID: string }
  }>
}["data"]

export type QuestionsReplyInput = {
  readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
  readonly requestID: { readonly sessionID: string; readonly requestID: string }["requestID"]
  readonly answers: { readonly answers: ReadonlyArray<ReadonlyArray<string>> }["answers"]
}

export type QuestionsReplyOutput = void

export type QuestionsRejectInput = {
  readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
  readonly requestID: { readonly sessionID: string; readonly requestID: string }["requestID"]
}

export type QuestionsRejectOutput = void

export type ReferencesListInput = {
  readonly location?: {
    readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
  }["location"]
}

export type ReferencesListOutput = {
  readonly location: {
    readonly directory: string
    readonly workspaceID?: string
    readonly root: string
    readonly origin: string
  }
  readonly data: ReadonlyArray<{
    readonly name: string
    readonly path: string
    readonly description?: string
    readonly hidden?: boolean
    readonly source:
      | { readonly type: "local"; readonly path: string; readonly description?: string; readonly hidden?: boolean }
      | {
          readonly type: "git"
          readonly repository: string
          readonly branch?: string
          readonly description?: string
          readonly hidden?: boolean
        }
  }>
}
